Cut Copy Paste
9 Comments
Comments are ordered by helpfulness, as indicated by you. Help us pick out the gems and discourage asshattery by voting on notable comments.
Got something to add? You can leave a comment below.
Steven Grant
Aaron Bassett
remember this – while you were complaining about the syntax, I made something.
And 6 months down the line when someone else has to maintain it I’m sure they’ll appreciate your cowboy coding.
Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live. – Code For The Maintainer
Rodney Rehm
For a random color (6-digit hex string) you don’t need MD5:
Math.random().toString(16).substring(2, 8);
Angela Relle
I think you could neaten that shell script up a bit (and make it easier to read) using head and tail:
FIRST=
for FILE in file*.csv do if [ -z “$FIRST” ] then head -n 1 “$FILE” FIRST=“no” fi tail -n +2 $FILE
done > file.out
Chris van Hasselt
I like your simple use of the modulus operator. The modulus operator is very useful in many situations. As you noted, mod 2 is an easy way to determine if something is odd or even, useful for row coloring. Let’s say you have an arbitrary list of names and you want them divided into 4 columns. The names should all have an index number (1st name, 2nd name, etc) associated with them. Use mod 4 to assign the names to the correct columns – 0, 1, 2, 3. The nice thing is, if you need 5 columns, the same logic works, just change to mod 5, and re-flow the list.
It’s an easy way to put things into a discrete number of buckets.
Bart Lewis
Huge fan of Evernote, but for some reason, storing code snippets within it never occurred to me. Simple and elegant. Love it.
Jeremy Archer
This overall seems interesting, but why are you twice rounding when computing the difference between two points? Aren’t they still floats anyway?
Brendan Dawes
@Angela – love it!
Brendan Dawes
You guys are funny!
Always worth listening to is Brendan and one of the best public speakers I’ve heard live.
Love this comment Some of this stuff is dirty; some of it will make hardcore programmers feel ill. For those people, remember this – while you were complaining about the syntax, I made something.