Probability of being caught in own loops

Suppose you are wondering randomly on a chessboard, starting from a corner, making one step up, down, left or right every time. You are not allowed to step on cells which you have already visited earlier. What are the chances that at some point you’ll not be able to go anywhere, i.e. you get caught in a dead end made by your own previous steps?

I got no idea how to solve this “purely”. Out of curiosity, I calculated the probabilities programmatically for 8×8 board for any path length (up to 63, naturally). Blue line shows the probability of being stuck at given path length or earlier, yellow line – 10 x probability of being stuck exactly at this path length.

Probabilities

Graphs do not show anything unexpected, except – what happens at points 48 and 49? I have no idea.

The calculation was straightforward by “first thought” without any optimizations. For each path length, I did 10^6 runs; with this amount, dispersion in the results between runs was by far under 1%, and run time acceptable (I do not indicate the units of the right Y-axis 🙂 )

Surprisingly I was not able to profile the run with gprof; looks like MacOS default C compiler and/or libraries just do not do it.

Still interested in a general solution, if there exists one.

OpenStreetMap, no dead ends!

I enjoy wandering around the countryside – also without planned route. Would be nice to mark roads, which are less interesting than others? For example, all dead-ends, and in general cut edges of the road graph.

Good that we have OpenStreetMap with open data and tools. I have created software to pre-render a given region (not too large one) with all cut edges marked. This is how it looks like, marking with thick blue dashed line:

Marked dead ends on OSM

Painted dead ends on OpenStreetMap

Storing and providing OpenStreetMap tiles requires a lot of disk space and bandwidth, so for now I only rendered small regions as a proof-of-concept. Welcome to peep at the maps!

Add keyboard layout on lubuntu 12.04

Lubuntu 12.04 seems to have a problem: new keyboard layout can’t be added by graphical menu. Seems to go back to dark times of knowing, which config file to edit… You can add the “layout switcher” (right click on the panel -> Add / remove panel items -> Panel applets -> Add -> Keyboard layout switcher), but I was not able to add any new layout to that “switcher”.

Thanks noobish-nix for a solution. The magic wordconfig file is

/etc/xdg/lxsession/Lubuntu/autostart

After @lxpanel line, add the line with your setxkbmap options, for example:

@setxkbmap -option grp:switch,grp:shifts_toggle us,ru,fi

Restart lxde (logout/login) to take effect.

Bash: different colors for typed command and its output

There are lots of examples showing how to set a nice colorful bash prompt. I wanted more than the output: the typed text should be hi-intensity, but the command output should be normal. I found only a hackish solution:

  • Install a DEBUG trap in your ~/.bashrc:

trap 'echo -ne "\e[0m" > $(tty)' DEBUG

  • And add yourself to the tty group:

sudo adduser <username> tty

It works, although I still have to think what can it break at some moment (long after I completely forget about that .bashrc line):

Screenshot of different colors for command text and output

Meanwhile, grc is a regexp-based colorizer for output.

Web surfing privacy and being multilingual

In many cases, it’s easy to track your browsing – thanks to JavaScript which is by default executed in most browsers. For example, any site can figure out did you visit a particular another site or not. Like, find out which social networks you hang in. So far, it was mostly about showing more targeted advertisements.

Nothing bad has happened to me because of this, and one may argue that targeted ads are better than non-targeted. But I do not like the idea of being tracked – and I shut off all web ads anyway with AdBlock. Additionally, I have NoScript always on (and allow sites selectively each time when “some site does not work”).

Today I have been told that there is a way to track me even without JavaScript and tracking images from spyhouse sites. It is demonstrated here:

https://panopticlick.eff.org/

I have quite long “accept-language” header set in my browsers, as I can read web pages in several languages. panopticlick shows that I’m one such user out of about half million (it might be that I’m just the only one with this value of accept-language, who made a check there).

I’m not feeling paranoid because of this. But I’ll be happy to know, is there a way to pass my (complicated 🙂 ) language preferences without allowing for easy fingerprinting.

Wolfram Alpha: computation for everyone, for free

WolframAlpha exampleWolfram Research, probably most known for their Mathematica calculation product, has launched an online service which makes various calculations and visualizations for free, and with just a web browser:

http://wolframalpha.com

This project makes me really respect Wolfram. I spent quite some time browsing the examples, almost exclusively from the “mathematics” part, picking like a shy visitor at other areas. Some of my online friends write that “knowledge becomes less of a fashion in our times”. I do not agree a bit. Just look at this product.

(La)TeX, 10 years later

tex-lion 10 and more years back, when I studied mathematics, I was an active user and promoter of the (La)TeX typesetting system. Since then, I almost did not use it, but kept the warmest memories of this creation “by mathematicians, for mathematicians”. Yesterday… I can’t say I changed my mind, but I’m not so sure any more about my attitude.

I had to remake a one-page document, for which I already had an old LaTeX template source. Edit the source, “make”, and a nice PDF is ready. Well, now the text which I inserted contained the @ sign. And of course (pdf)LaTeX did not compile.

I did not remember what should one do to typeset ‘@’ literally. I certainly remembered it 10 years back, but that’s not the kind of knowledge which stays alive when not used. It took me about 15 minutes to find the answer.

And now I’m not sure whether I shall promote TeX at all. From my viewpoint, this 15 minutes is unacceptably too much for such “problem” (actually, the very fact that this made a problem, is unacceptable in my current view). I expected the first link in Google search to give the solution, but the reality was very far from that. And – unfortunately for the others – I consider myself as a quite experienced (La)TeX user: I followed news:comp.text.tex, created own document classes, which were also used by other people, and so on. I knew well how it works. I knew where to look for documentation, and what kind of documentation I need. And still this thing, which should never be a stumble at all, took me 15 minutes. I can easily imagine that it takes full day from a person new to the TeX world.

Conclusion: sorry, none at the moment…

Software update for Nokia phones

Picture from nokia.com

A motivated-looking female character illustrates the software update process. Picture from nokia.com

Nokia gives an option to update the phone’s software, at least, for the more expensive models. I do not know, and would like to know, how other mobile phone vendors score in this area. Below is my rant about Nokia way of doing it. The writing is in negative tone, because things are noticed only when they do not work as expected. I’m interested if there is a vendor who does it better (some do not allow the user to update firmware at all – you must go to the service center for that!)
Continue reading

Get rid of junk on your desktop!


What a vandalism is this? Turning a keyboard into two pieces of junk?

No, it’s just the opposite – Bringing the Order, and Getting Rid of Junk!

I never use the “numeric keypad” on the right side. And it takes valuable space from my right hand. So what’s the problem if I got the hacksaw? Read on how I did it (with pictures and instructions for followers).

Posting from a mobile phone

It may be fun to post to the blog from a mobile phone. Doing so via the default web interface is certainly not the most convenient way (lot of extra traffic). WordPress has blog by email solution, which is OK from traffic viewpoint, but I was scared by instructions – involving setup of a “secret email account” and a cron job. Also, it does not support insertion of images.

Scribe is a free Python WordPress publishing client for Symbian S60 phones. Worked fine so far on Nokia E90 – this post is written in Scribe. Insertion of images is still not supported though; seems that the only client capable of it is a commercial Wavelog.

Nokia E90 camera image sample, or “The bullshit of megapixels”

The camera of Nokia E90 communicator is “3.2 megapixel”. Here is a cut of an image, made with this camera at best light conditions possible (even sunshine, not too bright). Close your eyes, photographers: you may get sick.

nokiae90cameraexample.jpg

Such quality is not just ashaming; I’m now happy that I’m not working at Nokia any more 🙂

Manufacturers increase the number of megapixels, which sales well, but that does not make image any better. Sure, the file size grows, carrying these junk pixels. I always resize these “phone pictures” down at least 2 times (= 4 times file size decrease), often more, before I dare to show them. And the phone does not offer neither option to use lower resolution1, nor any software to resize the captured image. As I feel plain stupid uploading 1MB picture worth of at most 200KB to any web site, I have always to scale it on some other computer. This is called “Mobile life”, “My world with me”, “Always connected” or something like that.

I know that I should pay extra for better camera quality and I’m not objecting to this; what I do not like is the unnecessary pixels which I can’t disable. Next time I may be purposedly looking for a camera with fewer pixels!

Update: 1 I was wrong on this. Camera offers 5 resolutions, smallest 640×480 with file size about 40kB. Finding this menu was not intuitive for me, but one can blame my lack of intuition here.

Gnome has an idea about screen parameters different from Xorg.conf

I rebooted my home computer after a long uptime and suddenly the screen is terribly flickering. Reason? “I did not do anything” 🙂 I installed software updates, added and removed users, but never mangled with the screen, as it was already tuned once and forever.

My Xorg.conf file has only one mode line, the one which works fine at 85Hz. Gnome graphical menu item for “screen resolution” gives only one resolution option… at 60Hz. What the heck?

The GDM screen was at fine refresh rate, but after I log in, it drops to that unbearable 60Hz. This at least gave me a hint that this may have something to do with Gnome. Search in .gconf directory of my home reveals two files:

.gconf/desktop/gnome/screen/default/0/%gconf.xml
.gconf/desktop/gnome/screen/[my host name]/0/%gconf.xml

which differ in one line:

<entry name=”rate” mtime=”1152558455″ type=”int” value=”85“>

Value 85 was different in the [my host name]-version, showing 60!

As a first attempt, I just change that value from 60 to 85; I did not actually hope that it will work… but it does. Now my refresh rate is as it was.

My questions to the audience:

  • Where did this poor refresh rate come from? Was it some upgraded package, which decided to change my monitor settings? (I have Ubuntu 7.10 and Gnome 2.20.1)
  • How is a user supposed to solve such problem?

Example of bullshit

Last years, I was not much exposed to bullshit at work. In fact, almost not at all. Now I received an email with a brilliant example of the subject. A person has an email signature, which ends like this:

[MyCompany] is one of the global leading suppliers of Information Logistics
Solutions and Product Information. Our customers are global leaders, at
the cutting edge of the telecom, software, automotive and industry sectors.
High expectations and demands from our customers drive [MyCompany] to
strive for operational excellence.

[MyCompany] currently employs some 500 highly talented and dedicated
staff globally, with offices in Sweden, Finland, France, Germany, Hungary,
Ukraine, and China. 

They should use some of the on-line bullshit generators to add, for example, “incubate innovative e-markets” or “syndicate customer-centric initiatives”. I think I’ll eventually point the author of the email to this post 🙂