What's the most unconventional, innovative, or straight-up wildest coding hack you've ever seen? Was it something you came up with, or was it someone else's creative solution?
Follow the DEVteam for more awesome discussions and online camaraderie!
What's the most unconventional, innovative, or straight-up wildest coding hack you've ever seen? Was it something you came up with, or was it someone else's creative solution?
Follow the DEVteam for more awesome discussions and online camaraderie!
For further actions, you may consider blocking this person and/or reporting abuse
Niklas -
Niklas -
Ben Halpern -
Ben Halpern -
Once suspended, devteam will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, devteam will be able to comment and publish posts again.
Once unpublished, all posts by devteam will become hidden and only accessible to themselves.
If devteam is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to dev.to staff.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag devteam:
Unflagging devteam will restore default visibility to their posts.
Top comments (14)
xkcd.com/221/
There's the classic fast inverse square root:
And here's something I wrote myself:
It's been a while since I wrote this so it took me a hot minute to understand it :P
It's a little terminal color library I golfed, called planckcolors
The fast inverse square root, definitely my favorite one 😁
For those who are not familiar with C++, the
#define private public
say that "Starting from now, each time you see “private” word, replace it with “public”.Meaning, you can now access private members of following class.
I had to do this to workaround an uninitialized private variable in a 3rd part, leading to a crash.
Definitely an anti-pattern and doesn't work every time (create some low level binary incompatibilities).
If by whacky, you mean bad:
It was the source of a bug, but the developer put it back when I fixed it to
if else
. 🤷The
FizzBuzz
code challenge, where developers are asked to write a program that prints the numbers from 1 to 100. But for multiples of three, the program should printFizz
instead of the number, and for multiples of five, it should printBuzz
. For numbers that are multiples of both three and five, the program should printFizzBuzz
. This challenge has led to some creative solutions, including one developer who wrote the entire program in one line of code using a ternary operator.I saw one that worked by finding the right seed for an RNG, then
for int ii from 0 to 100 { print [ "Fizz", "Buzz", "FizzBuzz", ii ][rand.nextInt() % 4] }
Another one, that I want to do myself, used a genetic algorithm to evolve an array containing the correct sequence of strings.
I honestly don't remember where, but I saw some code that used an array of function pointers, like
Probably the classic clear fix
I'm with you on that. Whackiest not by its nature so much as the fact that it fulfilled such a ubiquitous need for so long before the language deigned to provide more logical solutions, even then I don't think it's been killed off completely yet.
I've used it while working as a frontend-developer back in 2009. And you know, in 2009 I really thought, that I've invented this trick🤷♂️ I didn't know, that the others do the same😅
Valid css and functioning too.
In typescript, you can use
require()
to work around a circular dependency error.I've always been in awe of Duff's Device
Duff's Device(Wikipedia)