asdf
Code you think looks cool, no matter how simple
Other urls found in this thread:
github.com
bisqwit.iki.fi
disney-animation.s3.amazonaws.com
youtube.com
h14s.p5r.org
betterexplained.com
twitter.com
post in my thread reee
I just compressed it down so I will have to check that it is working properly still but I think it looks cool.
i agree, it looks clean and as concise as java can be
also, send my regards to ya mum
forgot to say in op, but i think it looks cool because of the structure, the conciseness and readability too
look at it, the bottom part fits in the third clause
morover, it has patterns all over the place
*the bottom part fits in like a lego with its predecessor clause
>tfw nobody posts in ya interesting threat
is it because its 6 a.m in the morning?
...
what kind of gooey is this
>compete shit
who are you quoting?
I agree, I mean, the image of the code you posted details 10 / 10 code, nothing can compete
I truly now see what is the ideal code, thanks for sharing that image my friend, can I save it??
float Q_rsqrt( float number ) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed return y; }
lern to format
Please add line breaks.
I've been programming Haskell for 5 years and your code is almost utterly incomprehensible, it deviates so heavily from every single established convention
Jesus christ OP
can you post your code?
i wanna know what it looks like
>lines longer than 80 characters
Not cool at all
I really like this shader for some reason, even though it's relatively simple
// Wide usage friendly PRNG, shamelessly stolen from a GLSL tricks forum post
float mod289(float x) { return x - floor(x / 289.0) * 289.0; }
float permute(float x) { return mod289((34.0*x + 1.0) * x); }
float rand(float x) { return fract(x / 41.0); }
// Helper: Calculate a stochastic approximation of the avg color around a pixel
vec4 average(sampler2D tex, vec2 pos, float range, inout float h)
{
// Compute a random rangle and distance
float dist = rand(h) * range; h = permute(h);
float dir = rand(h) * 6.2831853; h = permute(h);
vec2 pt = dist / image_size;
vec2 o = vec2(cos(dir), sin(dir));
// Sample at quarter-turn intervals around the source pixel
vec4 ref[4];
ref[0] = texture(tex, pos + pt * vec2( o.x, o.y));
ref[1] = texture(tex, pos + pt * vec2(-o.y, o.x));
ref[2] = texture(tex, pos + pt * vec2(-o.x, -o.y));
ref[3] = texture(tex, pos + pt * vec2( o.y, -o.x));
// Return the (normalized) average
return (ref[0] + ref[1] + ref[2] + ref[3])/4.0;
}
vec4 sample(sampler2D tex, vec2 pos, vec2 tex_size)
{
float h;
// Initialize the PRNG by hashing the position + a random uniform
vec3 m = vec3(pos, random) + vec3(1.0);
h = permute(permute(permute(m.x)+m.y)+m.z);
// Sample the source pixel
vec4 col = texture(tex, pos);
for (int i = 1; i
well, that depends on what you want to see.
Here's an example of a small program that I think falls in line with typical haskell style
github.com
>if a file l exists, then wait until it doesn't exist
>if it doesn't exist, make a lock file, do things, and then remove the lock file
>unreadable
are you the memer that says "how to average two ints in C"
are you haasn? holy shit
let me guess, you anotate main as having type IO () every time, huh
I've been programming Haskell for 5 years and your code is almost utterly incomprehensible, it deviates so heavily from every single established convention
Jesus christ hasn
can you tell me exactly you find wrong
>let me guess, you anotate main as having type IO () every time, huh
I'm no Haskell pro, but don't you have to do that as soon as you're reading user input?
>been programming in haskell for 5 years
>not a pro
what r u doing?
no, you don't have to annotate anything, only when necessary
and no, reading doesn't require annotation if there's enough context
and reading has nothing to do with annotating main
I'm not that other user. I took course on building compilers a year ago where we had to implement some things in Haskell. Mostly on paper though.
i know, I just wante to criticize the person who criticized my code as being "unreadable"
and for CS, right?
Who woul've though haskell would be taught on unis
vec3 D_Burley( vec3 D, float R, float NoV, float NoL, float VoH ) {
float FD90 = 0.5 + 2 * VoH * VoH * R;
float FdV = 1 + ( FD90 - 1 ) * exp2( ( -5.55473 * NoV - 6.98316 ) * NoV );
float FdL = 1 + ( FD90 - 1 ) * exp2( ( -5.55473 * NoL - 6.98316 ) * NoL );
return D / PI * FdV * FdL;
}
>setting an arbitrary line length limit
Why?
>arbitrary line length limit
>arbitrary
first day programming?
what is this? source?
so you don't have
It's historic, not arbitrary, but despite the history behind it, it still has use.
In the old days a lot of people only had 80-wide terminals and so limiting code to 80 characters per line was extremely practical for those who were limited to them, and it was simply respectful to do so.
Nowadays, that is no longer the case, but the 80 character limit is still extremely useful. It helps the one reading the code to have a fixed focus point, and 80-character wide display is still relevant in cases of text editors using split planes at 80-character intervals.
Just stick to the 80-character limit.
Bisqwit is the best
Burley Diffuse model using approximations
disney-animation.s3.amazonaws.com
who is this Bisqwit?
I was expecting that
Q_rsqrt
see
I think I will leave it as is and tell you to turn on line wrapping you have an issue. If you're limitint your lines to 80 chars then line wrapping will only affect code from people like me anyway so it won't be detrimental to you at all.
I much prefer a "line of code" to be an actual line of code for the most part.
Finnish programming God.
damn.
really nice
You're still sacrificing everyone else's readability of your code. Again, it provides a consistent focus point for human eyes and that it an immense benefit.
Linewrapping is as retarded as not having it, doesn't help readability at all.
I disagree.
Right? Gets posted every time this thread happens. It is pretty fucking neat when you read the description of it
h14s.p5r.org
betterexplained.com
What a non-argument that is.
CHICKEN Scheme
(use streams matchable clojurian-syntax)
(->> (stream-range 1 101)
(stream-map (lambda (x)
(match (list (remainder x 3)
(remainder x 5))
((0 0) "FizzBuzz")
((0 _) "Fizz")
((_ 0) "Buzz")
((_ _) x))))
(stream-for-each print))
Fuck that list match bit is actually pretty cool
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
i'm a coder and i don't understand any of the code posted here lol
Nice meme
Maybe because you're a coder and not a programmer
Loo loo = new Loo();
loo.poo();
> 6am
> in the morning
triggered
Where to even begin?
1. The weird broken definition on lines 5/6. Doesn't help that the editor displays what I assume is a tab character as _ instead. The name ‘b’ is also completely meaningless While it's true that Haskellers often use short variable names, that's usually only true when they're used immediately inside some inner scope, not as a global definition.
2. There's no reason to define f and b on the same line, except for making it much more confusing. There's also no reason to even name the files .u and .l, except to make it more confusing. ‘f’ and ‘l’ are also meaningless names until you see the context later, which adds to the confusion when reading this from the top down.
3. ‘main’ is just a jumbled mess. multiple definitions on the same line, with unconventional syntax (brace/semicolon instead of just using regular indentation rules; unnecessary let/in in what is both directly attached to a definition (meaning you could have used ‘where’) *and* an IO action (meaning you could have used definitions as part of a do block; explicit >>= \b -> garbage instead of using a do block, uncomfortably deep indentation on the nested ifThenElse block; explicit looping/recursion instead of just using something like ‘whileM’; leaky locking system that is also naively designed (e.g. it permits a TOCTOU race condition, unnecessarily writes to a file instead of just creating it, etc.), bad abstraction (you could create a lock and then never remove it, etc.)
In normal Haskell style this main would look more like this:
main = withLock l $ do
whatever
?. I lost count; code duplication inside m, unnecessary if/then/else instead of a pattern match, unnecessarily acquiring a resource only to then free it and then acquire it again. (you could e.g. put the hPutLine inside the withFile), unnecessarily spawning a subshell inside a subshell just to kill a process (also, pkill exists).
(cont)
...
Also, the entire thing seems to be really weird in general:
Not only is the locking contrived and unnecessary (it serves no point since the lock mechanism has the same race conditions as the file itself would also have), but the design is also weird: in every other daemon simply takes the presence of a pidfile (with a pid in it) as the daemon running, and the absence as the daemon missing. Which leads me to my next point:
The entire thing is reinventing the wheel, and doing so badly. Daemon monitoring tools exist, they're generally rolled into the init system. Use runit or OpenRC or systemd or whatever else you want that solves this job properly. In fact, it would have been shorter and easier to write a 3-line systemd unit file to accomplish the same goal you are trying to accomplish.
Heck, there are also existing libraries to properly spawn a daemon *in* Haskell.
The entire thing is just a mess of bad practices, bad formatting and bad code.
...
Okay, then I will not contribute to your software and reject your contributions from mine.
Using new lines solely for separating statements isn't a good thing. For example, would have to be written as:
(use streams matchable clojurian-syntax)
(->> (stream-range 1 101) (stream-map (lambda (x) (match (list (remainder x 3) (remainder x 5)) ((0 0) "FizzBuzz") ((0 _) "Fizz") ((_ 0) "Buzz") ((_ _) x)))) (stream-for-each print))
is actually a mostly good example of how you should be using newlines. The few lines at the bottom going over that 80 column mark are actually okay and I'd leave somethign like that as is, since they can't really be broken up more without looking silly. You can see that in the rest of their code, they split up long argument lists into separate lines and maintain alignment. Their code style isn't exactly how I'd have mine, but what they're doing with newlines is good. As well as their LISP-style argument list alignment, you can also write things like:
c->setRealDimensions(
dimensions[0] - SCROLLBAR_HEIGHT,
dimensions[1] - SCROLLBAR_HEIGHT
);
Beautiful.
for file in $(cat list.txt); do
convert $file -resize 370x220\! "${file%%/*}/${${file#*/}%%.*}-k1.${file#*.}"
convert $file -resize 80 "${file%%/*}/${${file#*/}%%.*}-k2.${file#*.}"
done
what does this do?
Well, he's a faggot, but I agree with you.
I am no Haskell programmer, but I think the code would be far easier to read for me if it wasn't written like a piece of shit.
>this cringeworthy maymay
Kill yourself.
since the context of the code is that of a code not to be released, I find that keeping variable names which make sense to you very ok
b stands for base
and l and f are defined by the base dir
l stands for lock, and f file
>no reason to define f and b on the same line
it makes sense. they're both similar and defined with the same thing, and it'd be wasteful to make a newline for no reason
you have to understand, most of the things you consider abhorrent I had done for both aesthetics and trying to short the loc
>let instead of where
again I use let for aesthetic reasons
realize I could of been straightforward but it'd look disgusting and I wouldn't be happy
>use >>= do block a lot
again aesthetic reasons
and what's with you and do, realize dos are built on bind and lambdas
nothing wrong with using old fashion bind
>whileM
wasn't aware of that
also
>fp
>not using recursion
>race condition
how, it makes sure there's no lock in order to begin work
>could create a lock and never remove it
how?
and I wasn't aware one could just create a file and never write anything to it
as u can see I tried the "" approach, which should write nothing
>normal haskell style
Idk for normal style, specially when the code is private
>code duplication
are you those types where you see anything repeat once and you must create a helper function on the spot
I'd understand if the repetition was big, but in this case is minimal and making a helper function would actually hinder you
you also don't understand the context of the code
its made so that when I press one key binding, if the program unclutter is "on", it kills it otherwise spawns it
and yes I know I could of done ReadWriteMode, but hgetline deletes the \n, and I don't wanna do extra work do delete that from the variable
Sublime mustard race
>saying "maymay"
kill yourself
>desperately trying to defend your shitty code
what is wrong with you
>I don't program in haskell or functional programming but I'd understand what some arbitrary code would do
also, kill yourself please
:(){ :|:& };:
Try it.
this your first day on gee?
here we don't act mean to "be cool"
kek
Jesus, butthurt much?
Looks like a fork bomb.
What's your color scheme?
...
>two (You)'s
That's bad enough
How else would you know if it was 6am at night?
Not everyone keeps healthy sleep schedules, user.
this,
AM is subjective
AM for me could be 9 pm, and 9am could be 9pm
for every image in list.txt, (dir/img.ext (png or jpg)) resizes it and places in dir/img-{k1,k2}.ext
I don't think anyone who's posted code ITT is a professional.