Sep
6
2020
Corona US Open and other thoughts

Nice to finally see some live tennis after so long! The US Open has started. Some top players are missing — no Nadal, no Halep (they rather concentrate on Rolland Garros; understandably, since clay is their preferred surface); no Federer (some knee injury).

Some of the bad boys who had the coronavirus are playing, like Djokovic and Dimitrov. The latter just went out. But it was a good match, take a look at the highlights if you like tennis. How strange it feels to watch these intense points without hearing the crowds' murmur of amazement! There are no crowds, because... pandemic! These huge arenas are empty.

Of course, players don't wear a mask during play; on average, a match takes 2-3 hours — it would be impossible to put that effort with a mask. But after the match, the winner gives an interview and that's... with a mask on! Take a look at Sofia Kenin. She's alone, in the middle of the empty court, with the mask on. The interviewer is nowhere to be seen, she's probably not even there.

Is it player's choice to wear the mask here? I don't think so, she's already been all over the place for two hours without a mask. Most probably, these are the regulations, but what could be the purpose? Clearly there is no risk to get infected, nor to infect anyone, because there's no one around! The virus doesn't just fall from the sky; if it did there would be no tennis and we'd stay indoors and homo sapiens would end, which probably wouldn't be too bad.. but I digress. The only purpose that can be is to maintain fear.

The most heartbreaking change is that they are no longer allowed to shake hands. Most players known each other for years, they are friends and they remain friends even after a hard fight; they used to shake hands and hug at the end, which is really what friends do, but now they just tick rackets and that's it. Sad. Meanwhile in footbal:

You can see these images after every goal. Now, I get it, manifestation of joy is part of the game, is something human and it shouldn't be forbidden, but then why not allowing tennis players to shake hands at the end? It just doesn't make sense. Also, while restaurants reopened just days ago with very strict rules, here's our beloved football players:

No distancing, no masks, indoors. This is practically illegal. What I'm trying to say, I guess, is that nothing seems to make sense! I feel like something more sinister than just the virus is going on. I want and try hard not to believe in conspiracy theories, but I feel like some unseen hand is manipulating all of the press and all the governments, worldwide, silencing voices that try to sing a different kind of music.

I find it weird that the Bill and Melinda Gates Foundation is pouring money both into the WHO, which declared the pandemic and dictates the regulations worldwide, and in ID2020, which recognizes “the opportunity for immunization to serve as a platform for digital identity“, which pretty much means they'd like to use vaccines to insert RFID tags into us; and that the press is talking about how the pandemic will not end until a vaccine is available, which kind of implies that vaccination will be mandatory, and all of a sudden conspiracy theories seem to become reality, in your face! They don't even hide!

I'm not exactly “anti-vaxxer”, but I try to get informed and think, and it's not hard to connect these dots. I wouldn't like to get an ID chip inside my body, so I will refuse vaccination... if I can! I think that's the end goal of this “pandemic” — mandatory vaccination of the whole planet, and that could mean digitally stamping everyone. My cat has a chip, but I'm not a cat and I'd rather not have one.

Apr
30
2020
Coronashit

I haven't blogged in a while. I guess I didn't have anything good to say. There's nothing good here either, but I just have to vent my frustration.

1. “Stay the fuck home”

I'm fed up with this shit! When I hear “coronavirus”, “social distancing” or “self-isolation” I almost feel physically ill. That's all we hear these days.

I hate the lockdown. Perhaps it made sense, initially, but it seems to be getting way too far. It's easy to shout “stay the fuck home” when you can work from home, or when you're extremely rich, but what about the others?

My wife closed her after-school. It was a flourishing business. Children loved them. Their parents and their dog loved them. It was an organic, small but profitable business. It was a dream come true! And now it's closed for like two months, with no reopening hopes in sight. With schools closed until fall, she might as well file for bankruptcy.

Like her, there are hundreds of millions. What will these people do? How many of them will kill themselves? Things are quite depressing already: you can't see friends, you can't see family, you have to carry a paper with you at all times, where you declare where you're going to and why, as if that stupid paper would help preventing the spread! Add to this the loss of job/business/income, and no immediate hopes for a better future, and to many people suicide will start looking like a sweet outcome.

Wouldn't these people rather go on with their lifes, even if that means to risk getting infected?

I wish we at least stop parroting the news, stop shouting “stay the fuck home”, that's disrespect for those who did or will lose everything because everybody had to stay home.

2. The media

Why are these guys being censored? I'm just wondering, I mean, they're not just some random dude on Facebook; they are doctors, they have some pertinent opinions, that deserve to be mentioned. They're not saying it's a hoax. The disease is real, but perhaps it's not so bad as to warrant shutting down the planet. The discussion on the mainstream news is completely imbalanced, nobody who dares to question the benefits of the lockdown is allowed. Isn't this at least suspicious?

I'd like to see some balanced discussion, I'd like to see someone objectively analyzing the usefulness of the lockdown, and the long-term effects. Like these two doctors seem to do. But nope, the mass media is universally one-sided: lockdown! Anybody who suggests otherwise is “fake news”. Allow me to be skeptical.

3. The authorities

Politicians announced some gradual relaxing, after May 15. Announcements were made in cautious words and nothing concrete has been said, but some business will be allowed to reopen, like barber shops. The coffee shop where I used to go daily with my colleagues? — mmm nope, that stays closed. They're probably doing the final paperwork for their soon-to-be-history business right now. Or writing their wills.

I find some measures contradictory, if not downright stupid. Why open barber shops and no coffee shops?

Why are we not allowed to go out in groups bigger than three, when there's a hundred people in a grocery store?

It is my understanding that office companies will be allowed to reopen; of course, many of them will chose to continue to work from home, but the point is that they can get people to the office if they like to and that means dozens of people in an open-plan room. Why can't we go out in groups bigger than three, then?

Schools remain closed, because if children go to school they might get infected, and then infect their parents and hell breaks loose. But if their parents go to work, can't the exact same thing happen?

Some people go to church regularly. I'm not one of them, but I understand them. Why can't they attend church for a couple of hours, yet they can stay in an open-plan office for eight hours?

Why can't I drive to another town without having a solid reason — will I get infected in my car? I'd like to visit my parents, is that reason solid enough? Oh, and I can't take my children because then we'd be more than three.

Our PM said the economy will restart when the epidemic is over. Excellent news, thank you very much.

4. Me.

I'm depressed. I guess I'm in the high-risk group, being a smoker for too many years. Still, I'd rather take the risk than live a miserable life for the foreseeable future. If I do get the virus, I ain't going to no fucking hospital; I shut myself indoors and hope for the best, and if I die then so be it!

Dec
10
2017
Emacs and JavaScript in 2017

About an year ago, when it became clear that sooner or later I'll have to write ES6 code, I decided to give js2-mode another look (wow, how time flies!)

Steve Yegge no longer seems to maintain this majestic creation, but as it often happens in the open-source world, quality code finds new home and maintainers. The official fork today is located at https://github.com/mooz/js2-mode, and it's what you get if you install it from Melpa. However, I live on my own fork where I fix bugs as I find them. Eventually, my fixes get merged into the official repo.

On top of js2-mode, Magnar Sveen of emacsrocks.com fame wrote js2-refactor, a collection of tools for working on JavaScript code. It brings new powers at your fingertips — for example, you can select a piece of code and turn it into a function; it figures out what are the variables needed by that piece of code, and turns them into arguments of the new function; and replaces that piece of code with a call to the new function, which is inserted just outside the current function. All that happens in a split second — an operation that would take many seconds to do manually. If you edit JavaScript, and use Emacs, make sure to check js2-refactor.

Before switching to js2-mode + js2-refactor, I had some utilities for editing JS that worked with an external parser (based on UglifyJS). I have ported these tools on top of js2-mode and js2-refactor, so we don't need to call an external parser, and we get support for ES6. I wanted to briefly cover it in this post, and perhaps if more people are interested I will submit a pull request to js2-refactor.

[ read more... ]

Aug
19
2017
Gazing at the numbers: the Collatz sequence

I've been obsessing on this problem for a couple weeks. While thinking on it I made some observations on my own, so it's worth a post on my blog. Note that I'm not a mathematician, so there's more English than Math here (which, for people like me, could in fact make it easier to read). I don't have proofs for the most interesting observations I made, and they might be known already for the trained mind.

If you studied the Collatz conjecture, then you might want to jump to the TL;DR.

The problem

The Collatz conjecture defines a sequence of positive integers that starts with any number $n > 1$, and at each step, in order to get the next number, you apply this simple logic, depending on the parity of the current number $n$:

  • When $n$ is even, the next number is $n / 2$
  • When $n$ is odd, the next number is $3n + 1$

The conjecture states that any such sequence eventually reaches $1$ (of course, we could continue after $1$ but it will loop). For an example, let's start with $n = 6$: 6 → 3 → 10 → 5 → 16 → 8 → 4 → 2 → 1.

[ read more... ]

Jul
30
2017
Don't sudo gnome-disks after beers

So yesterday I was repartitioning an USB stick and I was, say, less vigilant than I usually am when I play with these tools: the wrong disk was selected. I clicked through the confirmation dialogs without thinking too much, and gnome-disks happily removed my /boot and swap partitions. About the third partition, however, it complained with a “can't unmount it” message! (that was the root partition). As I was re-reading the message in horror, I realized I was messing with the wrong disk. Holy shmoly, so it did try to unmount it! "Thanks" goes to whoever made it impossible to remove a mounted partition, and "Thanks NOT!" goes to gnome-disks for not displaying a big fat warning when I try to remove a mounted partition that it can unmount.

[ read more... ]

Mar
18
2017
Pull Request based development (sucks)

Does this workflow sound familiar? The “master” branch is considered sacred, and it's therefore locked so nobody can push directly to it. Before you even start coding, there has to be a task opened in JIRA, and a branch also created from JIRA and linked to that task, and you then start pushing commits to that branch. And when you're done, you submit a Pull Request via Stash, and wait for at least two colleagues to review and approve your patch, and only then can it be merged to master.

As a developer who has been around for almost two decades, I'm going to argue why this workflow sucks. You tell me to run, and then you tie my legs.

[ read more... ]

Mar
5
2017
Tweeg: a Twig to JS compiler

Tweeg is a compiler for the popular PHP template engine Twig. It converts templates to JavaScript. Not being a PHP fan, to say the least, I don't particularly like Twig. But it does the job. At eMAG we're using PHP + Symfony on the server, and Twig is pretty much non-negotiable at this point.

Sometimes we need to render the same template on the server (on initial page load) and also on the client (when we update stuff via AJAX requests). So far, such cases were rare, so we wrote separate templates for JS using a slightly modified version of John Resig's micro-templating. It sucks, but it did the job. However, we will soon face the situation that we'll have to duplicate dozen of templates, just because Twig was not supported in JavaScript. So I took upon myself the lovely task of writing a Twig parser and compiler.

Halfway through, a colleague pointed out a similar package (twig.js). Tweeg was already better in a number of ways, so I didn't give up:

  • Tweeg is a compiler, which twig.js is not. (issue)
  • Tweeg supports string interpolation, which twig.js doesn't
  • Tweeg is much smaller.

eMAG kindly agreed to open-source this package under the MIT license, so here it is. Usage details in the README.

PS: I would welcome a Gulp plugin for it. ;-)

Nov
25
2016
A little JavaScript problem

In fact, this isn't about JavaScript, but that's the context I've discussed it in. I encourage you to think about it in more programming languages. (are there languages in which this can't be done?)

The problem: define functions range, map, reverse and foreach, obeying the restrictions below, such that the following program works properly. It prints the squares of numbers from 1 to 10, in reverse order.

var numbers = range(1, 10);
numbers = map(numbers, function (n) { return n * n });
numbers = reverse(numbers);
foreach(numbers, console.log);

/* output:

   100
   81
   64
   49
   36
   25
   16
   9
   4
   1
*/

Restrictions

  • You must not use arrays. The square bracket characters, [ and ], are forbidden, as well as Array constructor.

  • You must not use objects. The curly braces, { and }, and the dot character (.) are forbidden. You may use curly braces for code blocks, but not for creating JavaScript objects.

  • Should go without saying, these functions must be generic and do what their name implies. They must not be hard-coded for the particular 1..10 example.

Feel free to define utilities; you don't have to restrict your program to these 4 functions. It does not matter how fast, small or elegant it is — if you can do it within the limitations above, I think you're an above-average programmer and I would probably hire you. (however: I'm not hiring)

Just for reference, my implementation (in ES6) is 8 lines of code, and it isn't totally unreadable. :-)

PS: please don't post your solutions, or links, here. I will not publish them. But feel free to email me in private if you really want me to look into it.

Aug
29
2016
QUEEN, chess, and writing fast Lisp code

Back in 2008 I wrote an online chess game. It took me about a month to get it working, and then I gradually fixed bugs and added new features for another 3 months or so. It was online for about three years and I used to play chess there with my dad or friends. Then at some point I had to change my server, and it was a pain to get the server-side dependencies working again so I just dismissed my little service.

This year I've decided to put it back online, so I digged my old hard drives for the sources. As I said, it took like one month to write it -- so productive I was! A quick look at the code explains it, though. The server-side is Perl and it's basically write-only (awful) code. While I probably could sync it with the dependencies and get it back working, the feeling that there are a thousand bugs inside won't let me sleep at night, so I started rewriting the server side in Common Lisp (the client is somewhat OK, I can maintain it).

When you write chess software, even if it's not supposed to play chess but only allow two humans to play chess together, it must still have some notion about the rules of the game, for example to detect checkmate, or to prevent someone from making illegal moves. You need to implement a proper move generator even for something “as simple as” parsing chess moves in algebraic notation -- to read a move like "Ne5", which means “kNight moves to e5”, you must know where on the board is the knight of the current side that can move to e5 (and it better be only one). There's similar pain in generating the SAN notation for a move.

For Perl I wrote Chess::Rep back in 2008, and I knew I'd need something like this in Lisp, so I wrote QUEEN. It's the module I'm writing about here. The full game is not ready yet, but QUEEN is useful in itself so I published it and submitted it for inclusion into Quicklisp.

[ read more... ]

Mar
24
2016
The left-pad case

“Getting tired of people hating npm and JavaScript. Some of those people even make a living through JavaScript.”

— Atanas Korchev (@korchev) March 24, 2016

I felt this was addressed to me, following a number of tweets and retweets. I'm too critic. Point taken. Luckily I don't blog often, otherwise this site would be full of rage and “everything sucks” posts.

I must say I initially sympathised with Azer when I've read his post on “liberating” his modules. I'm a programmer, I love open-source, and I would definitely hate it if somebody asked me to unpublish uglify-js just because. Heck, I've created this trend — I don't remember any packages with the “ify” suffix before Uglify.

[ read more... ]


« Before 24 Mar 2016
Fork me on Github