Just give up.
No, really, just give up. Ignore those clichés they tell you from the movie screens, about how it does not matter how many times you fall, but what matters is how many times you stand back up. That's bullshit. If you think about it, another cliché should come to your mind as well, the one about definition of insanity. Because why would you be trying and failing in perpetuity? Would it not make sense to allocate your energy to something else, that you are succeeding at?
Bugging thought
Why am I bring this up? I had this bug for months, where "remember me" function on my website still resulted in the website forgetting me. It felt completely random, because sometimes it was working fine for a several weeks, but then it forgot me. It took me quite a while to figure out it was because of concurrency, a "race condition", and that it was happening specifically when opening multiple pages at the same time, but it did not guarantee it if there were just a few pages, and it was also "covered" by the fact that sessions still remembered me, when it happened. Do you know, how I solved it?
I gave up on it.
Really, 2 days ago I decided to just address this when I migrate to Symfony, since it has the logic there already, and I thought that I may be reinventing the wheel, even though my original code was essentially a copy-paste with very minor tweaks. I gave up, because even with some improvements to sessions and cookies handling it was still replicable for me. I gave up. I let it go. But apparently, not entirely, because later that day a random thought came to me, I tried it... And it worked. The thought was, essentially an extra check in 1 place, (a copy of the same check I was doing at earlier stages in the flow), and that check took me a minute to add and test.
And it worked.
I still do not think I understand fully how it works. After that I did find some article that explained some things about how PHP sessions work (even when custom handler is used), so I think it's related to that, but not sure. Not like it matters that much.
Suspicious pattern
This is not the first time something like this has happened to me, too. On various occasions I was trying to get something, was failing, then gave up, switched to something else, and after sometime, something random would happen, that would allow me to get what I was trying to achieve earlier. Was not necessarily automatic, could still require some work, but just a little bit compared to what was done before.
In fact, I think I got my current job because I gave up. At the time I was looking for a job for 11 months, 12th one has just started. I had barely any interviews, and had savings for next 2 maybe 3 months (in euros, at least), and residence permit expiring in a bit less than 5 months. I went for integration courses (which started after I got an offer, so that was a waste), and started planning my return to Russia, and how I may need to handle different things on my return... I was mentally preparing myself to leave Finland. Or try to apply for asylum.
And suddenly I got an interview. Even an interview process. And got an offer. It was relatively quick. I still had to wait a bit to start the job, but that was fine, because it was still while I had savings and permit was still valid. It is hard for me to not see a pattern through-out my life after, practically, life-saving intervention of "giving up".
Mahjong paradox
I used to play quite Mahjong quite a lot. Or, I guess, the correct term would be "Mahjong Solitaire". The game, that uses Mahjong tiles, that you need to get pairs of to clear them from a board. Simple game, really, but after playing for a while, I noticed 2 patterns, that felt almost like a life philosophy:
- Sometimes things start up quickly, you find the pairs fast and easy, but then suddenly get hit by "no more pairs". Because there are games, which you can't complete no matter how you try.
- Sometimes things start up slow, you are ready to give up, but then you select a certain pair and things speed up and you clear the board.
The paradox I see here is...
How do you know which one is which?
Yes, I know it's not really a "paradox", you get my point. How do you know when to give up, and when to persist? What if you will give up seconds before hitting that treasure trove? What if you will be doing something for years, and then suddenly hit a wall and feel like you've wasted all your life? Personally, I have no idea how to differentiate the two.
My best guess is, that you need to be flexible enough in your mind to be able to put things away "for the time being". You do not necessarily literally "give them up", but "postpone", you re-allocate your resources. You know kind of like a video re-encoding process will take over the resources temporarily pausing some background indexing task (if only Windows knew how to do that). And even if there will be no opportunity to "resume" your previous task - let it go with no regrets.
You may still want to not give up on some principles, probably... Since you need to have a strong "core". But I do not think I am wise enough to really draw any conclusions here, let alone give life advises, so I will give up on this article now. Which just happened to be written on first day of "year of the snake", and snakes are famous for giving up their old skin.