Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Search - "oneliner"
Real programmers don't comment their code. It was hard to write, it should be hard to understand.21
Ideas for a strong password:
- a regex matching my laptop's LAN IP address
- a sed command to enable X11 forwarding in sshd_config
- a shell oneliner extracting all the IP addresses from ifconfig / ip a sh
- an awk command to print processes in D state
Dockers JSON output is garbage.
First, you'll get no JSON per se.
You get a JSON string per image, Like this:
Then I tried to parse the labels.
It looked easy: <Key>=<Value> , delimited by comma.
Lil oneliner... Boom.
Turns out that Docker allows comma in the value line and doesn't escape it.
One liner turns into char by char parser to properly tokenize the Labels based on the last known delimiter.
I thought that this was a 5 min task.
Guess what, Docker sucks and this has turned into try and error...
For fucks sake, I hated Docker before, but this makes me more angry than anything else. Properly returning an parseable API isn't that hard :@3
I once made an oopsie in an API for a logistics provider (one of the biggest in Germany...).
To understand the oopsie...
Based on input data a string must be created containing several hex / string / formatted values.
Think of ...
$return .= sprintf("%02X", ...)
I think there were around 15 to 20 lines, although more complicated.
The bug happened because I had a brainfart.
What was previously one line with... Many many many many variables, I had to split into multiple lines since internal stuff changed and it was impossible to change this oneliner of hell with >50 formatting codes.
Of course we didn't test everything.
What we didn't test was - funnily enough - wether the casting was correct in all cases.
I misplaced a formatting code.
And we had a major brainfart because we tested integer, but not double / float values....
We sent for a long time packages much cheaper than allowed (took thw logistics provider nearly 3-4 months to realize this :) ).
Spot the difference:
print sprintf("%01.2s", $money).PHP_EOL;
print sprintf("%01.2f", $money).PHP_EOL;1
php -r 'for(;$r=fread(STDIN,16);)printf("%08x %s $r\n",$i++*16,join(unpack("h*",$r)));'8
My biggest influence on coding style is working with other people's code. I know the temptation to write "clever" code and I've been (and probably still occasionally am) guilty of it myself, but it's not until you have to debug someones oneliner iterator which has !(i-j) as the stop condition that you start to appreciate dumb, boring, obvious code.
If having a series of if checks in a long list makes it readable, keep it that way. If it makes it more readable to rewrite it into a nested switchcase with a couple of ternary bits, go ahead. Just don't spend half a day wrapping it up into two layers of abstraction that will require an onboarding process for the rest of the team.2
Aber method that was supposed to Check If a payment for a (back then) unimplemented payment methode that returns true as a default value...
Do you know some good tech RSS,Atom,... Feeds?
Anything about programming, operating systems, hacking, Hardware would be welcome.
But please not something trash like nixcraft, where every article amounts to "How to do this very basic thing that is literally a oneliner but we felt its so complicated, it justifies writing an article about it."2