December 14th, 2011 — Links, Random
As 2011 approaches its end, as usual, I copy-paste the links to some of the most interesting, most over-the-top, most random and most obscure stuff I read on the internet (in English) throughout the year, in case you desperately need some reading material for dark and long evenings. Much (but not all) of the more opinionated stuff is the kind that I strongly agree with. Note to self: in 2012 read stuff that challenges, rather than reinforces your biases. So here it goes:
Motivation, lighter stuff
Ribbonfarm: In the real world. Also.
Hanging out with a different crowd.
Xamuel: ways to be more present.
Derek Sivers: flip the stick.
Changing perspective.
Anonymous psychedelic experience.
Ribbonfarm: being an illegible person.
Interesting observations, more substantial stuff
Norvig vs. Chomsky.
Ribbonfarm: Legibility.
Ribbonfarm: Bargaining with your right brain.
Daniel Mendelsohn: Arthur Rimbaud’s brief career.
Idlewords: Rocket to Nowhere – the story of the Shuttle.
Roger Ebert on why he hates 3D movies.
Less Wrong: Excuses.
Ribbonfarm: The Milo criterion.
Essay of N.N. Taleb, a summary of his ideas.
Idlewords: The social graph is neither.
Idlewords: Argentina – on two steaks a day.
RIP Michael Hart .
RIP Steve Jobs. Eulogy by Mona Simpson and by ESR.
Startups, Business, Programming
Ribbonfarm: the end of the Middle Class.
Tips for contract work on websites from a Reddit comment.
Raganwald: You need a degree for BigCo.
Why HR did not respond.
Joel: We hire the best 1%.
Joel: Architecture Astronouts.
Some of us just like to program.
Apenwarr: Interoperability, robustness, etc..
Two essays pointing out a pragmatic way towards startups.
Two other pieces of pragmatic advice on a similar topic.
The Gervais principle or office life according to The Office.
Steve Yegge: Code’s worst enemy.
Life at Google, life at Amazon, and a glimpse of both.
Don’t call yourself a programmer.
Maths, Research
Is it really power law?
Terence Tao: Problem solving strategies.
Michael Nielsen: Open access – a summary.
The Uppsala-affair.
Humorous
Two pieces lightly poking fun at Paul Graham.
How to criticize a computer scientist?
Burnout prevention at MIT.
The credit card prank.
Missy the lost cat.
As a bonus, here are the best books I’ve read in 2011:

July 19th, 2011 — Tech
Here’s a small idea I wrote about before: change the desktop wallpaper automatically using random images from Wikipedia. Why Wikipedia and not some other source? Because these images are generally more interesting, more diverse and better quality than any other collection I know.
Click this link a couple of times for some examples of random wiki images:
http://commons.wikimedia.org/wiki/Special:Random/File
Finally I managed to hack it together and here it is for you to download. I only tried it on Linux but probably it can be ran with small modifications on a Mac as well. If you manage to put together something like this on Windows let me know in the comments. Here are the steps:
1. What we need
- feh – this is a nice, lightweight image viewer ( https://wiki.archlinux.org/index.php/Feh )
- convert, mogrify – these are some utilities from the imagemagick set of tools (easily available on most distributions)
- wget – for fetching files from the internet
- sed, awk, grep, xargs – you have these already
If you don’t have the first three, on Ubuntu all you need to do is:
sudo apt-get install feh
sudo apt-get install imagemagick
sudo apt-get install wget
2. The main thing
Make a folder where you put the files needed for this wallpaper-changing-business. For me that is ~/random_wallpaper
Create the file run.sh in this newly created folder and copy the code below into it. The code does the following: it fetches the URL of a random image from Wikipedia, it fetches the image itself, makes an attempt to convert it to a decent size (change resolution in the code if necessary), makes an attempt to add the title of the image to the image, sets it as wallpaper, waits for an hour, removes the image and repeats. Additionally, it saves filenames and timestamps in an archive.txt file, so that if you see something interesting, you can look it up later. Feel free to tweak it to your needs, for example, the 60 minutes repeat period in the end could be made 20s or whatever else.
#!/bin/sh
while true; do
# Remove old file and get new random image
cat filename.txt | xargs rm
echo -n "http://upload" > url.txt
wget -q -O - "$@" http://commons.wikimedia.org/wiki/Special:Random/File | grep -m 1 "href=\"//upload" | sed -e 's/.*href\=\"\/\/upload//g' | sed -e 's/\".*//g' >> url.txt
url=`cat url.txt`
wget -O temp_image.tmp "$url"
echo -n "temp_image." > filename.txt
cat url.txt | sed -e 's/.*\///g' | sed -e 's/.*\.//g' >> filename.txt
filename=`cat filename.txt`
mv temp_image.tmp "$filename"
# Get filename of image for display
echo $url | awk -F"/" '{print $NF}' | awk -F. '{print $1}' > urldisplay.txt
urldisplay=`cat urldisplay.txt`
# Resize image and add title (filename)
mogrify -resize 1024x768\> "$filename"
convert -pointsize 20 -fill red -draw "text 10,30 "$urldisplay"" "$filename" "$filename"
# Set as wallpaper
feh --bg-center "$filename"
# Leave some traces in the logfile
echo -n `date` >> archive.txt
echo -n " " >> archive.txt
echo $url >> archive.txt
# Go to sleep
sleep 60m
done
Make this file executable:
chmod +x run.sh
3. Wrapping it up
All we need now is a way of running our script. If you want to try it out just once, or you want to use it as a slideshow on a birthday party, you can simply run it from the terminal:
./run.sh &
If you want to use it all the time, it should be called at each startup. This can be achieved in different ways, depending a bit on the setup used.
I run Fluxbox as a window manager, which is closely related to Blackbox or Openbox.
Here I add towards the end of my startup file the following:
~/random_wallpaper/run.sh &
If you use Gnome, you could add the same line to your ~/.xinitrc file. The Feh documentation says that to make it play nicely with Feh, you should disable Nautilus’ control of the desktop:
gconftool-2 --set /apps/nautilus/preferences/show_desktop --type boolean false
An alternative way of calling run.sh would be to set up a periodic job using cron. In this case the loop (the while- and the done- lines) are not needed.
Let me know in the comments how it worked out, or if you know a simpler way of setting it all up.
ENJOY!
July 9th, 2011 — Ideas, Random
A few quick web app ideas, not the kind that would lead to the next Facebook, but some that might be slightly interesting/useful if executed properly (for which unfortunately I have too little time, therefore this post). I’ve been pumping out these half-baked ideas at a steady rate on this blog, if you are interested in the previous ones, you could start from here.
1. Your English is so 1890.
There was a popular widget some time ago, in which you paste some text that you wrote (or it processes your blog) and through a statistical analysis of word frequencies it tells you whether you write like Hemingway or more like Virginia Woolf or like Edgar Allan Poe or whoever. Then you get a badge you can put on your blog or on your wall in your favorite social network. It was quite nice and popular, although I can’t find it anymore (EDIT: here it is).
Mine is a tweak on this idea. Google has released a data set with the frequencies of words in books throughout the years (ngrams.googlelabs.com). Say, you might find that “computer” appeared in 5% of the books in 1970 and in 15% of those in 1985 (I am making this up). So, given any year, you can easily find out how likely a certain word is to appear in a randomly picked text. With Bayes rule and some reasonable assumptions we could reverse this and for a given snippet of text, compute the probability that the text was written in 1800 or in 1850 or in 1900, etc. We would pretend that a priori the text is just as likely to come from any year. This is not exactly true, since we know the text comes from the present, or at least we know that the amount of text available from any year grows as we get closer to the present, but let’s ignore all that for a moment. It would be more fun than exact science anyway. However, it could still generate interesting comparisons between the style, choice of words, favorite topics of different people, or the styles of different authors from the past. For example we might discover that some authors had a language that anticipated (or influenced) the future, while others were stuck using the language of the past.
2. World map with radios.
Online radios are a nice tool in learning any language, but often it is hard to find suitable ones. For learning or practicing a language the topic is perhaps less important as long as it is at least mildly interesting and as long as there is sufficient amount of talking (instead of just music), with a clear pronunciation that is representative for a given language/dialect. So what I would like is a world map with a curated list of online radio stations, placed on the map with pins, and for each station it would be given exactly what language/dialect they use, approximately how difficult are the topics discussed, what is the amount of slang, etc.
3. World map with unofficial regions.
Finding a political map with the official borders for countries/states/counties/etc. is easy. There exist however, many other types of regions:
- historical ones (those that in the past might have formed an administrative unit but they don’t anymore)
- linguistic regions (the region where a language/dialect is spoken)
- geographic regions not necessarily corresponding to administrative units (Silicon Valley, Gangetic Plain, etc.)
- regions of scientific interest: (the range of the Neanderthal man, the region of influence of classical Greek culture, the range of the Bengal tiger in 1900)
- etc.
It would be nice to have a tool for annotating maps in this way (possibly based on Google Maps) just as easily as we can add locations or paths between different points. Such regions, once drawn could be saved, embedded, printed, used in presentations, news articles, lectures, etc. or shared similarly to how users can share photos attached to places on Google Maps. Then, instead of the usual political/geographic view of the world, we could choose other filters/overlays created by others.
Another type of overlay would not have strict borders like regions, but would be a mapping of values onto geographical coordinates. The function value could be shown in colors or using contour curves or any other visualization, and the values could come from uploaded datasets or from some specified function. These types of visualizations exist of course, but I don’t know of a simple interface where users could create such maps.
4. World map live postcard.
A simple service that shows an empty world map and generates a unique url on demand. If someone visits the url, their geographic location appears on the map. This can be done of course with analytics software, but the key here is that a) this is real-time b) accessible to everyone who has the url and c) starting a new map is just one click with no registration and then the url can simply be copy/pasted and sent to others.
Example usage: I am regularly visiting a forum, I am curious where the other visitors are from, so I put the link in the message and watch the map in real time.
Example 2: I am chatting with a group of friends and I hear that a common friend of ours is ill. I create a new map, and send the link to everyone, so when they click it, they appear on the map. They can also watch as more and more people click the link. They can also leave one liner messages that will be displayed on the map next to their location. As our friend checks the link, he/she can see “get well soon” messages popping up from all over the world. This is all a bit similar to Wikipediavision, but more user-generated and with throw-away urls.
5. Centralized phpBB spam filter.
PhpBB is a robust, well-known and loved dicussion board (forum) software that has been around for a long time. The main aspect in which I find it inferior to centralized services like Disqus is spam. Spam filtering is something that is simply easier to do in a centralized way than for each individual board separately. This centralized filter would be a subscription-based API that I can call whenever I get a message on my board and it returns a spam/not spam flag. This can be integrated into my phpBB installation and the necessary action is taken automatically. This way, I wouldn’t have to bother users with captcha’s, registration, senseless restrictions, and I could still have them use the familiar interface of phpBB. If such a service works for WordPress comments and other blogging software, surely it can be retrofitted for phpBB (?).
6. Name face search.
When picking a baby name, many parents would like to find out as much as possible about it, including the history and etymology of the name, which historical persons have had that name, current popularity of the name, etc.
In this service you type in a first name and it gives you the photos of 100 random people having that name. Looking at the age of people on the photos, you can guess whether the name was more popular one or two generations ago than it is today. Also useful if you hear a name in a foreign language and you are not sure whether it is a male or female name. Images of faces can be found on Facebook or on Google Images, but there are still some technical difficulties: a) all 100 should be different persons b) the images should be filtered so that they only contain photos of people and not other random images.
July 2nd, 2011 — Math, Random
Bongard problems are a type of puzzle invented by Russian computer scientist M. M. Bongard, intended as challenges for pattern recognition algorithms. Regardless of the possible relevance to computer science, they are much fun simply as puzzles created by people for other people to solve. They were popularized in the Gödel, Escher, Bach book and Hofstadter himself designed many Bongard problems. Harry Foundalis has several pages dedicated to these problems, with an extensive index of example Bongard problems.
The idea of a Bongard problem is the following: given a set A of six figures (examples) and another set B of six figures (counter-examples), discover what is the rule that the figures in A obey and figures in B violate.
Here are some very nice examples of varying difficulty and a much more detailed description:
http://www.foundalis.com/res/diss_research.html
Inspired by these examples I tried my hand at making some Bongard puzzles myself. The modest result is below. If you can solve them, leave the answer in the comments.
Puzzle 1.

Puzzle 2.

Puzzle 3.

Puzzle 4.

May 26th, 2011 — Math
Inequalities are the bread and butter of mathematical proofs, especially those with an “approximate” flavor. I found many useful sources that describe the most important inequalities, there exist even some books dedicated exclusively to inequalities. However, I couldn’t find a concise “cheat-sheet” style summary of the most important ones, so I wrote one myself, collecting information from the sources I found. Check out my useful inequalities cheat sheet.
May 8th, 2011 — Links, Random
May 7th, 2011 — Links, Random
May 5th, 2011 — Links, Random
May 5th, 2011 — Tech
On a language website that I maintain I recently switched to a full-fledged phpBB forum from a previous solution that included a comment box on every page, provided by the online service Disqus.
phpBB is the classical choice for forum software, it is open source, based on php (as the name suggests), well supported, with a lot of information scattered around on the internet, with many useful extensions and a bewildering amount of parameters to be configured.
Here are some of the pros/cons of phpBB that I noticed in comparison to the previous set-up I used:
+ More control over the content, the comments are now stored on my server
+ Better organization of topics, possibility to move messages from one thread to another, the accumulated threads serve as some sort of knowledge-base
+ More fine-grained user permissions and moderating options. While this is useful, I would be happier with some sane defaults, as it takes quite a lot of time to play around with all these settings, to little visible benefit to the users.
+ Better integration: I can customize phpBB to closely match the looks of my site, more so than with the widgets I used previously
+ Users can create user accounts within my site
+ Since phpBB has been around for ages, most people are comfortable using it
- A lot of time wasted setting up, configuring, customizing, upgrading, etc. the software
- A lot of time wasted fighting spam. While there are many half-solutions available, in this regard running your own forum is clearly inferior to a centralized service like Disqus
- The look and feel of the forum is slightly heavy-weight and outdated (not too web2.0-y). This is not a big problem, as it is familiar even to non-technical people.
- Higher threshold for commenting. Although I tried to keep registration requirements, rules, captcha’s to a minimum, the number of messages written is somewhat smaller than in the previous system. However, the posts are longer, usually more substantial and better organized, so this is actually a +.
All in all I am quite happy with phpBB, even though it is not nearly as minimalistic as I would prefer it to be. One thing, however, that I was still missing from the Disqus days is a recent posts widget. This would be embedded on a different page than the actual forum (for example on the front page) and it would show the most recent 5-10 posts that were written in the forum. As I found no obvious ready-made solution, I wrote my own, which was not very difficult, as the database structure of the forums is quite straightforward.
You can download it below, with some explanation on how to install it. Let me know if you find it useful, or if you make any improvements to it. I spent about as much time putting it together, as it took me to write this post, so it is really nothing fancy. It is released under the WTFPL license, which means that you can … well, you know.
You can see it in action on the http://www.nebulo.ro site (text in Romanian), as it shows recent comments for the forum on the same site.
Installation
Put the following line in the web page where you want the recent comments to appear:
<div id="recent-widget"></div>
And somewhere later in the same file:
<script type="text/javascript">
httpRequest("recent-widget.php", showrecent);
function showrecent(WIDGET){
d = document.getElementById('recent-widget');
d.innerHTML = WIDGET;
}
function httpRequest(url, callback) {
var httpObj = false;
if (typeof XMLHttpRequest != 'undefined') {
httpObj = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try{
httpObj = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e) {
try{
httpObj = new ActiveXObject('iMicrosoft.XMLHTTP');
} catch(e) {}
}
}
if (!httpObj) return;
httpObj.onreadystatechange = function() {
if (httpObj.readyState == 4) { // when request is complete
callback(httpObj.responseText);
}
};
httpObj.open('GET', url, true);
httpObj.send(null);
}
</script>
This will load the recent-widget.php file that writes the actual widget and put the output into the HTML file. Upload this on your server, so that it is accessible from your main page. The only advantage to this javascript-loader is that you can easily display the same widget on many different HTML pages. Otherwise you can simply put the stuff from recent-widget.php into your own php files.
Here is the recent-widget.php
Before you upload it, you have to modify some things in it that are about the access to the forum database and links to the forum itself and you can modify other things, like the actual layout, colors used, number of posts, etc. See the TODO comments in the file for more information. This assumes that you are running phpBB with MySQL, but if you run some other database, such as SQLite, it should still be easy to modify. Obviously, this whole widget is nothing too complicated, so even if you never programmed in php, or seen an SQL query before, it is still a decent way to learn if you tweak it to work.
February 25th, 2011 — Ideas, Random
This morning on HN: The Colour Clock (notice the .uk in the domain :).
An elegant clock with changing background color. The exact color is obtained by interpreting the hour, minute, second values as describing the Red, Green, Blue components of the color.
Link here.
The original was in flash, but Brian Collins quickly put together a version using HTML, CSS and JavaScript.
Here is his version:
http://brisy.info/colors/
My only tweak on this idea is to make the color-cycle continuous. When the seconds move from 59 to 00 there is a jump in the Blue value from maximum to minimum, which means a not-so-smooth transition in the background color.
To overcome this, I make the Blue value alternate between going up and coming down, depending on whether the previous value is odd or even. Similarly for the Green value (minutes), depending on the hour value. The Red (hour) value will go up or down according to the parity of the number of days since some remote date in the past. The javascript/jquery code achieving this can be examined (it is just a minor modification of Brian’s code). Now the clock still cycles through all colors but without sudden jumps (and now the numbers are harder to interpret directly as colors).
Here is the working version:
smooth cycling color clock.