Prime numbers less than 100

Posted by Michał ‘mina86’ Nazarewicz on 12th of December 2010

Anyone working in a big corporation must have been hit by some ‘funny’ mail from a coworker that helps everyone gets through the day. No different at my office — at one point all engineers have been challenged to write the shortest code in C that prints all prime numbers (and only prime numbers) less than a hundred each on separate line.

This is an interesting brain-teaser so posting it here so others may choose to think about it while their code’s compiling.

Of course, a ‘C program’ needs not to be taken too seriously — depending on not too far fetched undefined behaviours of given implementation is all right (but please do not use system or exec family of calls ;) ).

0 is ambiguous

Posted by Michał ‘mina86’ Nazarewicz on 24th of October 2010

It has been a long time since my last entry, so inspired by Adriaan de Groot’s entry, I decided to write something about 0, NULL and upcoming nullptr.

I will try to be informative and explain what the whole buzz is about and then give my opinion about nullptr. Let us first inspect how a null pointer can be donated in C and C++.

NTP over HTTP

Posted by Michał ‘mina86’ Nazarewicz on 16th of January 2010

Sitting in a dark office, after swearing for hours at ATI video cards I noticed time on my computer was incorrect. ‘No problem,’ I thought as I started typing ntpdate. That’s where it struck me that our beloved IT department had blocked most of the Internet. Checking the time on a watch or a mobile phone was not an option — I had neither — nor was looking at GKrellM on another PC — that’s just lame.

‘I wish there was a NTP-over-HTTP protocol’ I sighed. And then I realised there was…

Total Control Exchange (No Caps Lock)

Posted by Michał ‘mina86’ Nazarewicz on 11th of October 2009

Have you ever wondered why Caps Lock, a key you press twice a decade (once to turn it on and then to turn it off), is in such a lucrative position on the keyboard? And how about Ctrl? Compared to Caps Lock it seems like miles away. If you think about it old unix keyboards with those keys swapped seem to got it right.

I’ve gone one step further and recommend turning Caps Lock into Ctrl key altogether. In this article I will describe how to do that in various systems and platforms. But lets start with some propaganda.

tabbed, urxvt extension

Posted by Michał ‘mina86’ Nazarewicz on 16th of May 2009

Some time ago, I’ve modified the tabbed rxvt-unicode extension adding a few useful features. Somehow upstream did not want it while people started modifying the extension even more and so tabbedex fork came to be. The code can be browsed on GitHub or cloned from git://github.com/mina86/urxvt-tabbedex.git

tabbedex carries a lot of changes and it would be futile to try and list them all here especially as the list would likely become out of date soon. Because of that, I recommend taking a look at the source code, which has, at the very beginning, a comment with a list of changes made.

Public git repository

Posted by Michał ‘mina86’ Nazarewicz on 12th of November 2008

And finally, after doing some paper work, I’ve created a set of public git repositories with various stuff written by me. At the moment, the most interesting is probably a dot-files repository which contains my configuration files — hope someone’ll find it useful.

Double-checked locking pattern

Posted by Michał ‘mina86’ Nazarewicz on 29th of April 2008

Jakiś czas temu w pewnych okolicznościach poruszony został wzorzec double-checked locking singleton, który jak powszechnie wiadomo nie jest do końca poprawny. Wynikła z tego krótka dyskusja, której kompilację pozwolę sobie wkleić poniżej (gdyż nie jest ona ogólnie dostępna, a nie lubię, gdy informacje się marnują).

ls-cmd.pl

Posted by Michał ‘mina86’ Nazarewicz on 15th of April 2008

Something for real unix geeks: Script that makes well known ls command work in Irssi the way God intended, ie. displaying nick list (no slash required).

Irssi AI

Posted by Michał ‘mina86’ Nazarewicz on 26th of February 2008

Script implementing advanced AI algorithms answering yes-or-no questions on a channel. It can answer all questions or only those sent to us (that is prefixed with our nick).

MPD now playing for Irssi

Posted by Michał ‘mina86’ Nazarewicz on 26th of February 2008

Simple script writing title of currently played song in MPD. It has a unique feature of automatically replaying to informations send by other users.