Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "riddles"
-
Some of these have been mentioned already but here they are, these things make me be a bit better at programming (at least I think so)
• sleep, I love sleep and I think a good night's sleep can do wonders
• music, music theory which is a language in itself and playing an instrument which teaches hand-eye-coordination and also creates patterns in your head, but certainly teaches us that you need to practice a lot to achieve your goals, that it's hard for beginners but gets a bit easier with time
• solving puzzles and riddles, I've been a huge fan of puzzles from an early age, it is something that teaches us solving problems and creating strategies
• other types of games that are helpful are games where you have to find things in a picture or in an environment, this has trained me a bit on finding nasty bugs in my code or at least syntax errors
• googling: sometimes you find out something that is not really related to your problem, but you remember it nevertheless and later on it can help you with something else
• maths, yes, you read correctly, I'm not a big fan of maths either, but what you learn in maths is that there are certain procedures you're often repeating and that you're always building on your knowledge and expanding it, sometimes solving mathematical problems is fun too ;)
• getting fresh air - self explanatory
• listening to other people's life stories, this helps me generally in life, to know that I'm not the only one struggling with something and so on
And I probably could go on with a lot more things, but I think that's enough for now15 -
Well... I had in over 15 years of programming a lot of PHP / HTML projects where I asked myself: What psychopath could have written this?
(PHP haters: Just go trolling somewhere else...)
In my current project I've "inherited" a project which was running around ~ 15 years. Code Base looked solid to me... (Article system for ERP, huge company / branches system, lot of other modules for internal use... All in all: Not small.)
The original goal was to port to PHP 7 and to give it a fresh layout. Seemed doable...
The first days passed by - porting to an asset system, cleaning up the base system (login / logout / session & cookies... you know the drill).
And that was where it all went haywire.
I really have no clue how someone could have been so ignorant to not even think twice before setting cookies or doing other "header related" stuff without at least checking the result codes...
Basically the authentication / permission system was fully fucked up. It relied on redirecting the user via header modification to the login page with an error set in a GET variable...
Uh boy. That ain't funny.
Ported to session flash messages, checked if headers were sent, hard exit otherwise - redirect.
But then I got to the first layers of the whole "OOP class" related shit...
It's basically "whack a mole".
Whoever wrote this, was as dumb and as ignorant to build up a daisy chain of commands for fixing corner cases of corner cases of the regular command... If you don't understand what I mean, take the following example:
Permissions are based on group (accumulation of single permissions) and single permissions - to get all permissions from a user, you need to fetch both and build a unique array.
Well... The "names" for permissions are not unique. I'd never expected to be someone to be so stupid. Yes. You could have two permissions name "article_search" - while relying on uniqueness.
All in all all permissions are fetched once for lifetime of script and stored to a cache...
To fix this corner case… There is another function that fetches the results from the cache and returns simply "one" of the rights (getting permission array).
In case you need to get the ID of the other (yes... two identifiers used in the project for permissions - name and ID (auto increment key))...
Let's write another function on top of the function on top of the function.
My brain is seriously in deep fried mode.
Untangling this mess is basically like getting pumped up with pain killers and trying to solve logic riddles - it just doesn't work....
So... From redesigning and porting from PHP 7 I'm basically rewriting the whole base system to MVC, porting and touching every script, untangling this dumb shit of "functions" / "OOP" [or whatever you call this garbage] and then hoping everything works...
A huge thanks to AURA. http://auraphp.com/
It's incredibily useful in this case, as it has no dependencies and makes it very easy to get a solid ground without writing a whole framework by myself.
Amen.2 -
A lot of online games (mainstream) tend to make me kind of angry or stressed. Lots of either blatantly stupid or negative players kill the fun.
A few days ago I've startet to see videos about "Among Us". It's on a big hype right now and their machmaking servers must be glowing.
Well, this game is fucking awesome and it makes me really happy! 😊
Nothing beats a 30 minute game of lying, betrayal, teamwork and good old 30'000 IQ big-brain detective work.
I think it's a great execise for remembering stuff.
You remember colors, who's said what and who faked or did which task. And the hardest part is, even if you fucking saw the killer, you have to present the facts in a way that people believe you.
Each round is unique and full of riddles.
Yeah, I just wanted to say: Fucking great game 😄2 -
I post riddles and puzzles outside my office door to keep people distracted before bothering me. they must answer all right before disturbing me.2
-
I solved this riddle/puzzle. Now my inner completionist split into two and both are arguing what is worse: taking the solved puzzle apart or leaving the 15 remaining possibilities unsolved...
*rips of his face* 💀3 -
You are telling me I have
to wait 24 times for 24h
to receive new riddles,
ahh I want them NOW!
https://adventofcode.com/4 -
For fuck sake why would you put in documentation some functionalities you did not even develop ?! How am I supposed to guess that my error comes from your code when event the fucking DOCSTRING of the method says the use case is handled ?
It's nice to have documentation and commented code, but could you please make it FUCKING coherent with what the code actually does ? I feel like I'm playing fucking riddles here !!2 -
That moment where you see code of someone who riddles their code with nested if-else and if-elseif statements.
I don't remember writing an else statement for years. It almost always can be avoided (and the rare cases where it makes sense I prefer the switch statement).
Yet I never grasp why people do:
```
if(someCondition) {
// huge nested code block
} else {
throw new Error();
}
```
Instead of
```
if (!someCondition) {
throw new Error();
}
// continue in the normal scope
```
And then we have experts that like doing:
```
if(someCondition) {
if (bar) {
$foo = 'narf';
} else {
$foo = 'poit';
}
// huge code block
if($foo == 'narf') {
if(yetAntherCondition) {
// huge code block
} else {
throw new Error();
}
// huge code block
} else {
throw new Error();
}
} else {
throw new Error();
}
```
Help!
If ever was to design a programming language, I'd forbid the `else` and `elseif` keywords. I have yet to find an instance where I could not replace some `else` by either a guard or an early return or introducing some polymorphism.1 -
Guys I heard a rumor that you like riddles, I'm stuck on my theory project and I'd like to throw a bone:
Say you have a list p = [7,6,2,3,4,5,1,0] and you want to order it, i.e. change it to [0,1,2,3,4,5,6,7], by swapping adjacent elements. Provide an algorithm to do this optimally, when:
a. (Warm-up) each swap costs 1
b. Swaps weight is [4,3,2,1,2,3,4], i.e. if you want to swap position 0 with 1 it'd cost 4, position 3 with 4 will cost 1 and so on.
The optimal overall cost for b is 50 (I did an exhaustive search), however you need to find a general approach which is able to order every list with minimal overall cost (no time constraints as long as the solution is not exponential in the list length), using the provided weight function.
(you get a credit if the solution goes to a paper or anything 😉 it's actually a computer science open problem, but seems possible to me)16 -
[CSS]
I'd like to create a fixed aspect ratio box that remains centered in its parent such that two of its sides are always touching the parent. I know about the padding-top hack, the problem is that that won't make the box narrower if the parent isn't tall enough.
Is this even possible in CSS?
I like riddles and I don't expect a solution, but I'd like to know if it's even possible before I spend days researching.18 -
tl;dr i am proud of my universal program but annoyed it won't get appreciation.
<brag type='slightly'>the last three days i refactored my various snippets to a kind of modular and scalable software package. restricted to a rigid company system i make use of the technologies i feel confident in. so i created a javascript app that can be used with internet explorer. it is a neat tool to work smarter and mainly to make repetitive writing tasks efficient using predefined textblocks that have automated linguistic adjustments and are multilingual usable. after refactoring it is possible to extend any desired functionality by just adding another module. i learned a lot about implementing separated data structures, data processing, output and asynchronous script loading (and the annoying limitations of ie11).</brag>
i kept in mind that this tool might not only help my personal duties to be done more efficient but also might come in handy to all my colleagues having similar tasks to do. the downside is my colleagues having irrational computerphobia and i know for sure they will proceed to do these repetitive writings manually resulting in inconsistencies and an inefficient time management. while my wise wife tries to convice me that at least i had fun coding this stuff and having it supporting me with annoying tasks, it still bothers me being the only user, as it means no progression for the company. it riddles me how the colleagues, acknowledging us all being craftspeople in the first place, avoid use of computers whenever possible and rather rely on medieval working flows.
i find it quite amusing to be the 'can you fix my printer'-guy, but i just cannot handle this attitude. and everyone complains about having so much to do. get your shit together and start clicking these few buttons goddammit! -
Recep Tayyip Erdogan had a problem — after his army service, he got so used to cold that he could only sleep on a raw, cold metal grill. Usually, normal people put mattress on top, but Erdogan didn’t feel right this way. So, in one of his personal prisons, he established a social project for making a full metal bed for himself.
For starters, to calculate the shape, he took the smallest man ever (3 inches high) with his fingers and sunk him into molten plastic. “What are you doing?! It hurts!” — man screamed. “Shut up. You’re on an important mission. Your motherland won’t forget you.”
After three months, the bed was ready. It was more of the same — metal bars, but this time with some kind of structure built of metal hinges, rebar and strong springs. This was the day — this was the big reveal event. It took place in the same prison — three prisoners were ready to lay on their new full metal beds, while news crews congratulated Erdogan and celebrated his greatness. “Well, it is time!” — he said.
Prisoners laid flat. An awful screeching sound. Prisoner number two is bleeding out. The spring mechanism broke out and impaled his chest onto a large metal bar. He’s not breathing.
“Shut it down. Shut it all down. No more cameras, no more news”, — said Erdogan.
“Yes, our master”, — said news crews.
They wanted to draft me to Afghanistan.
“No!”, — a young officer shouted, misgendering me — “He doesn’t know the stages of pain. Useless.”
“Are you perhaps arguing pain with a bipolar patient?” — I replied.
“You are a rave. Nothing but a rave.”
Raves spawned near your doors at night. Sometimes, they even spawned on the inside. I can’t say you were in danger, but it certainly wasn’t a pleasant thing to happen to anyone. They looked ugly. They dressed weird. They spoke in riddles.
“How do I move to Europe?”, — a rave asked.
“I…”
“Shut up!”
Rave took a door, suspiciously painted over and over multiple times, and started to slam my door with it, using it as a ram.
My door started giving in.
Alarm system.
On a separate note, to disable the alarm system, you have to speedrun Stanley Parable. It’s the hardest speedrun ever, specifically its hidden ending. It disables all alarm systems in three-mile radius IRL. No one knows how it works, but it does. Back to the danger zone!
“The better quality time you spend sitting on your toilet, the more you’ll live.”, — an officer said.
“I once had a girl blow me while I was shitting,” — Matthias replied — “You have nothing on me.”
“Fair enough!”
It is a little known fact, but the liquid that Northern cities use to clean up snow isn’t quite what it seems like. It’s not salt — in reality, there are bases on Mars, and they store pink goo that… “iMpRoVeS” dead bodies. The liquid is biological in nature, and it expires. Expired liquid is recycled as snow melter. You learn that in high school, but now, living on a train, you should know that there are special learning rooms here, in every. single. carriage. The small gym ball with two handles on its sides is called Gandhi ball. Fun fact: if you wear headless Segways on top of your shoes, and then lay flat holding a Gandhi ball, you can reach the speed of 270 kph!
Today’s news: a Reddit moderator and a legless woman gave birth to a living sex toy for their domestic boar.2 -
Currently fixing concurrency issues with a callback which is called so frequently it probably has multiple instances running and which can't ever be paused. Also, it isn't allowed to allocate or free memory. Riddles like this are the reason I got into computer science.