Saturday, October 26, 2013

Conserving screen space in GNOME

I finally found a tool to accomplish something I have wanted for a long time, namely tuning the size of icons and buttons in Gnome. Gnome applications waste a lot of precious screen space by default, probably the default settings are developed for and by people with six HD monitors at their desks. On a tiny screen such as the 1024x600 screen in my eee-pc, pixels are precious and should not be wasted.

The tool I found is called gnome-color-chooser. Install it with

sudo aptitude install gnome-color-chooser

I should say that I'm using Linux Mint Debian, with the Mate desktop based on Gnome 2. Gnome 3 appears to be configured differently, judging from a quick search.

The color chooser tool allows you to choose the colors of different elements, but it has several settings for button sizes and icon sizes as well. First, let's set all paddings to 0, except the y-padding of widgets which I chose to keep as 1. Check Use shadowless Menubars and Use shadowless Toolbars. On the Icons tab, you can set icon sizes. I set the sizes to 14-12-12-12. I particularly liked the setting Start menu, setting it to 12 pixels made the menu small, nice and manageable.

What the tool actually does is to provide settings in a file included from .gtkrc-2.0.
As the Archlinux Wiki points out, one can also modify the .gtkrc-2.0 file by hand.

Other settings to change for a compact look:
  • System > Preferences > Appearance, Fonts-tab, Details-button. Change Screen resolution from 96 to 80. For some reason, this setting works better than changing the font sizes.
  • System > Preferences > Appearance, Themes-tab. Controls: Clearlooks, Window borders: Mint-X, Icons: Gnome

While at it, fix the file manager preferences:
  • View new folders using: Compact View
  • Compact view defaults, Default zoom level 66%
  • Uncheck All columns have the same width
With the latest update pack for LMDE, many application started to display the following warning when run in a terminal. I frequently launch emacs from a terminal to edit files, then the message clutters up the terminal.

Fontconfig warning: "/etc/fonts/conf.d/53-monospace-lcd-filter.conf", line 10: Having multiple values in <test> isn't supported and may not work as expected

A quick fix to get rid of this annoyance is to comment out line 10 of the offending file:
<!--  <string>Bitstream Vera Sans Mono</string> -->
I figure this might change something, but it looks that the file was broken anyway as it was shipped.

Sunday, October 20, 2013

New disk for an old eee-pc

Our trusty eee-pc 901 was getting slower and slower. The 16G SSD in it was not very fast to begin with, but has definitely become slower over time. To keep the otherwise nice laptop running for a few more years, I decided to upgrade the SSD. The drive I ended up buying a 64G Super Talent FPM64GLSE. RunCore disks have a reputation for being faster, but they were also more expensive and hard to obtain. The eee-pc requires a PCI-E disk. There are also newer mSata disks available. These use a physically similar connector as PCI-E, but are not compatible.

A quick test of the Super Talent with iozone yielded the following results, in KB/s. The same settings were the same as when measuring SD card performance on the raspberry Pi earlier,
./iozone -e -I -a -s 50M -r 4k -r 512k -r 16M -i 0 -i 1 -i 2

                                   random random
reclen write rewrite   read reread   read  write
     4 17258   20110  12626  12623  12528   1457
   512 74590   41339 127710 127909 121887  74354
 16384 40403   75312 129705 129748 130483  40077

As with SD cards, the speeds that the manufacturers specify is the rate of sequential reading or writing of large contiguous blocks (Reading max 150 MB/s, writing max 100 MB/s is what they specify). Randomly writing small blocks of data is a much slower. Still, I am pleased with this result. Also in practice the upgrade had a large effect, the laptop feels much more responsive.

An annoyance with this drive is that it is configured as a slave. When booting the eee, it complains that no master disk is present and demands to press F1. When F1 is pressed, the boot proceeds normally, the unnecessary message just prevents the machine from booting unsupervised.

I installed Linux Mint Debian Edition on the new drive. I had Ubuntu 11.10 before, which started to show its age. I decided not to upgrade it, after experiencing Ubuntu 12.04 on another machine - I felt that the upgrade to 12.04 broke the user interface.

I am happy with Linux Mint. However, I came across a couple of problems during the installation. One that looked serious was that GParted reported errors about a recursive partition on the newly installed disk. I could not get rid of this message but decided to continue the installation anyway, and it turned out fine. To reduce the disk writes and the wear, I added noatime to the mount options for the disk in /etc/fstab.

Thursday, October 17, 2013

Airport luggage cones

Found these beauties at the airport. My theory is that they have something to do with luggage transport.

Thursday, September 26, 2013

A more classical anti-ad sign

Making a "no ads please" sign from Hama beads. This time, I'm trying out a more elegant and old-fashioned type design, with muted warms colors. This is the one I made for our own door.

The text is 20 Reddish Brown and the background is 21 Light Brown. I also put a frame with the "gold" color, not that that really showed in the final stage.

Thursday, September 19, 2013

Beads with Flowing Stripes

Experimenting with striped patterns in polymer clay. I wanted a natural wavy look that would continue across the beads.

For the base, I used a somewhat translucent dark gray. The gray is mixed from 1 part translucent 'white' (unpigmented) Fimo Soft polymer clay, and 1/32th black Fimo Soft. The stripes are plain white Fimo.

I made sheets of both colors, rolled on the second-thinnest setting on my pasta machine. A layer of white is sandwiched between two layers of gray. The sheet is then cut into four equally-sized pieces. These four pieces were then stacked, with a bit of scrunching in the middle, to create the wave. The edges are kept neat and unscrunched on purpose. The squares in the background are 1 cm.

I made a cylinder of the same gray color as the base, and cut that in half. The wavy stack goes in between the halves. Put together, this approximate cylinder is ready to be reduced! After reducing, I made some of the beads by putting thin slices on a gray base, and some simply by cutting thick slices from the cane (The results were quite similar)

Above, the beads before baking, and below, after baking and polishing.

Sunday, July 28, 2013

Yashica D resurrection

I found my uncle's old camera when sorting some old things, a Yashica D. It has been non-operational for the last 20 years, used mainly for projecting images through the viewfinder onto the ceiling with a flashlight. Now I started wondering if the camera could be used for photography again. The camera looked to be in a nice condition, but the shutter was stuck.

Kalle came to the rescue, armed with an excellent guide to disassembling the shutter on the Yashica D. We followed the guide, disassembled the shutter mechanism, and found that two shutter blades had stuck. We cleaned the blades and assembled the shutter again, and it worked!

While taking the camera appart, we had to unscrew a lens without damaging or scratching it. A bottle opener turned out to fit the lenses well and gave a suitably gentle but firm grip.

The shutter is designed in modules, with the self timer and the shutter speed regulator working as independent units. Each one is a kind of clockwork with several cogwheels in series. At one point we opened the wrong screw, and the shutter speed regulator came apart. Putting it back together again was a real challenge, as it contained several small wheels and springs. It was difficult to get all the pieces positioned correctly, so that the top cover could be put back on. What worked for us in the end was clamping a few pieces of cardboard to the desk, and to keep the timer module and its various parts in place with pins stuck into the cardboard.

I am very impressed by all the small mechanical parts in the shutter, especially considering that it all must have been designed without using computers. It was very pleasing when we got the camera put back together again, and to actually see it work. Kalle has already shot a couple of film rolls with it, here are a few samples.

The shutter disassembly guide by Dave Gauer was invaluable to us. We also found it useful to take photos of the parts in various stages of disassembly, in order to check the placing and orientation of the parts later when reassembling, and to keep the screws and small parts that came off in each step in a separate bowl.

Tuesday, April 9, 2013

ISDN adventures

I have an ISDN internet connection. It is slow, but happens to be provided for free. Getting ISDN set up under Linux has usually been a challenge for me, so when I got a fresh install working today with very little effort, I wanted to document the steps. Once it starts working, it usually works fine. (Special greetings to everyone in the University guest house in Marburg. Ask for a DrayTek modem and not the Fritz modem, which is a real pain when running Linux. Say you have ein Apple Computer).

The modem is a DrayTek miniVigor 128 (USB ID 0675:1688), a small box which connects to a USB port on the computer and to a phone for the phone line. The computer runs Ubuntu 11.10 (but I have used the setup on other versions, up to 12.04 without problems).

There are two ISDN systems in use for Linux. I have used the older one, in particular the HiSax driver supports my ISDN modem. The newer system is called mISDN. The two systems cause a conflict when both try to control the same device. I solved this by blacklisting the mISDN module, to prevent it from being loaded.

Add a file to /etc/modprobe.d/, for example /etc/modprobe.d/blacklist-misdn.conf, with the following lines:
blacklist mISDN_core
blacklist hfcsusb

Install some packages. This is easy if there already is an internet connection...
sudo apt-get install isdnutils-base ipppd

while installing, the installation script for ipppd asks for some information:

  • phone number to dial
  • user name (at your network provider)
  • password
The installer script then sets up the following files:
/etc/ppp/pap-secrets   #user name, password
/etc/ppp/chap-secrets  #user name, password

/etc/isdn/device.ippp0 #phone number, etc
/etc/isdn/ipppd.ippp0  #user name, channel bundling, etc

At this point I rebooted, after that I could dial with
isdnctrl dial ippp0
and had internet access. Not bad. But at this point, the connection uses only one of the two ISDN channels. To double the connection speed to amazing 128 kBit/s, one must set up channel bundling.

Edit /etc/isdn/ipppd.ippp0. Uncomment the line #+mp, and add /dev/ippp1 above it. So:

Create a new device file for the two bundled devices
sudo cp /etc/isdn/device.ippp0 /etc/isdn/device.ippp0+1

Restart the isdn service after changing the configuration files, to make the new settings active.
sudo /etc/init.d/isdnutils restart

Now, it should be possible to dial first ippp0, then ippp1 and use both channels for fast surfing.
isdnctrl dial ippp0
isdnctrl dial ippp1

Note: if you receive the message
ippp0: Device or resource busy
it might be because the line is already connected, possibly since the default setting is to automatically dial when there is network traffic.

If the connection works so far, some adjustments can be done in the configuration files.

Turn on compression negotiation - perhaps it increases the bandwidth a little.
Comment out the command noccp in /etc/isdn/device.ippp0, remember to copy to the other name as well:
sudo cp /etc/isdn/device.ippp0 /etc/isdn/device.ippp0+1

In /etc/isdn/device.ippp0, adjust timeout for terminating an idle connection. It's only 60 seconds as default. If you are lucky and don't pay per minute, set it to something higher, for example 1800. Change this line:
isdnctrl huptimeout ${device} 60

DIALMODE=manual (instead of auto) disables automatic dialing, and gives you control of when to dial.

For convenience, one can make two shell scripts for dialing and hanging up:
isdnctrl dial ippp0
isdnctrl dial ippp1
isdnctrl hangup ippp1
isdnctrl hangup ippp0

The configuration file architecture is probably specific to Debian-based distributions, but the step of blacklisting mISDN should help on any Linux with both ISDN systems. I tried to get the ISDN modem working with my Raspberry Pi router as well, but I never got that to work.

Sunday, March 31, 2013

Masking & red cabbage dyeing Easter eggs

Easter eggs dyed with red cabbage

This year we colored Easter eggs with red cabbage juice. The patterns were made by masking the eggs with washi tape and candle wax.

Straining red cabbage

To extract the color from red cabbage, I boiled slices of five large leaves in water with some vinegar, for roughly 30 minutes, then removed the cabbage leaves by straining, and allowed the dye to cool. On the right is a piece of cotton string we boiled with the cabbage. It turned a very nice purple, I'm hoping the dye will stick to it.

Covering eggs with washi masking tape

To get patterns on the eggs, we covered some parts of them with washi masking tape. We also used molten candle wax, applied with a small paint brush.

Easter eggs soaking in red cabbage dye

The eggs were soaked in the cabbage dye for a few hours.

Dyed Easter eggs

Rinsing and removing the masking tape. The color is a nice blue, even though the cabbage was red and the dye purple! Red cabbage juice works as a pH indicator; it turns red when acidic and blue in alkaline solutions (and can even turn green or yellow for strong alkalines). It seems there is some chemistry going on in the shells.

The masking tape worked well - it kept the dye off the masked parts of the egg. Where two stripes of tape crossed each other an unexpected effect appeared: the upper stripe did not mask the egg perfectly just where it passed the lower stripe, giving an illusion of depth in the final pattern! The lines on the egg that appears to pass below another line were created where the tape stripe passed above another stripe.

The painted-on candle wax gave nice artistic effects!

Dyed Easter eggs

The finished eggs. Happy Easter to everyone!

Friday, March 15, 2013

Favourite Games: Widelands

widelands buildings
Widelands - a strategy game where you build up your civilization and defend it from your enemies. The best defense may well be striking first. Widelands is an open source game, and is said to be similar to Settlers II. The game is still evolving, but is already very enjoyable.

The game contains a complex economy, with different types of goods and buildings that produce goods or process goods from one form to another. In fact, building and then maintaining a working economy is the main part of the gameplay. There is also fighting with your neighbors, of course, but the battles take place with a minimal input. The only real choice is what to attack, and when to do it.

Widelands mines
Each warrior needs an axe. Axes are made in an axe factory using iron and coal. Iron is made by combining coal and iron ore in a smelter, these two resources one gets by constructing a mine at a suitable mountain site. However, the miners work only when they are well fed, which requires bread, meat, or fish, prepared into meals in a tavern. Every item produced is transported along roads between the buildings, so having an efficient road network in necessary for a productive economy. When the flow of wares becomes too much for the carriers, one can breed oxen for use as pack animals.

I like building my empire more than I like fighting the other players, so it suits me fine that the game emphasizes construction over battles. It feels nice to construct an efficient system of factories. In the game I played while writing this post, I ran out of wood in the beginning and then all construction projects ground to a halt. I had a small border battle with my green neighbor, but that war fizzled out when we both ran out of fighters. Then I lost some time before constructing an axe factory, since I believed it required a master blacksmith (which it doesn't). Another thing that caused trouble is that upgrading a building wastes all resources in it. (To save them, one has to order the stores to be emptied before upgrading. This problem is discussed on the bug tracker.) My greedy neighbors left me alone for quite some time even though my defenses were very thin, but eventually they defeated me by burning down my head quarter and storage. I'll get them next time though.
Widelands headquarter destroyed

There is a bit of a learning curve for this game, it takes time to find out how the wares should flow between the different buildings. There is some in-game help, in the form of a tutorial game and a list of all wares and how they are produced. The game music is quite monotonous. Because of it, the game is locally known as the meeh-meeh game. In all other respects, a great game! There is a multiplayer mode which I have not tried, but it sounds like great fun.

If you feel brave, try out the development version. The current development version, in preparation of release 18, still has some rough edges, but also notable improvements over the last stable release (17). The graphics is nicer and the colors have improved a lot. They were very saturated before, but are calmer now.

The Favorite Game series

Thursday, March 7, 2013

Red Snail Missing

I recently found a box of my childhood favorite candy, the 'Frog butterfly snail' ones - every eighties kid from Finland knows which ones I mean.

As a kid, it was always important that the box contained at least one candy of each of the ultimate correct types: red butterfly, yellow snail, and green frog. I'm happy to report success in the present case! In fact, the only combination missing from the box I bought was a red snail.

Monday, March 4, 2013

Fractures and Fractals

A wintry day I saw cracks in our parking lot asphalt with salt crystallized around the cracks. The patterns looked nice and reminded me of fractals, and gave a nice topic for a small Processing program.

Move the mouse over the picture to see different patterns! Click to zoom in, right-click to zoom out.

This is a drawing of the Julia set. Moving the mouse changes the (complex) parameter of the fractal. If you middle-click, you see a picture of the Mandelbrot set. There is an interesting and beautiful connection between the Mandelbrot and Julia sets, which we will get to after a very brief description of how the fractals are drawn.

Both fractals are drawn by iterating a complex function: \[z_{n+1} = z_n^2 + c.\] Starting with a value \(z_0\), one can use the equation over and over to find a long sequence of \(z\)s. The fractals are images of the complex plane, where each point is colored depending on how the sequence \(z_n\) behaves. Depending on \(c\) and on the staring value \(z_0\), the magnitude of \(z_n\) either stays bounded or explodes when \(n\) grows. If the sequence explodes, the color is chosen according to how many iterations it took for \(|z_n|\) to become larger than some suitable constant.

For the Mandelbrot fractal one always starts with \(z_0 = 0\), and choose \(c\) according to the point one wants to color. In the Julia fractal, \(z_0\) is the complex coordinate of the point you want to color, while \(c\) is a parameter of the fractal kept fixed for the whole image. Moving the mouse cursor over the image above changes the parameter \(c\).

The connection between the Julia and Mandelbrot fractals is this: The parameter \(c\) of the Julia fractal corresponds to one point in the image of the Mandelbrot set. When \(c\) is inside the Mandelbrot set (the central area traditionally colored black), the corresponding Julia set is connected. Try different points! It seems that the Julia set keeps the looks (the curlyness and fuzzyness) of the place one chooses in the Mandelbrot set. Points at the edge of the Mandelbrot set tend to be the most interesting.

While drawing this fractal, I learned that the color map is the key to getting nice pictures. It took some tweaking to get a nice-looking result. Coloring by the logarithm of the iteration count seems to be a good idea. You can have a look at the fractal source code here. Finally, one can choose some other complex function to iterate. Simply changing \(z^2\) to \(z^3\) or \(z^4\) gives interesting results.

Saturday, February 23, 2013

Mini lanterns on a LED series

I made a set of small paper lanterns for a LED light series we have on a wall (indoors!). The paper lanterns are stylish and easy to make - they are a standard type of origami called 'fusen', which means balloon. I learned about them from the book The Simple Art of Japanese Papercrafts by Mari Ono. These little cubes are inflated after folding, and the air hole was very convenient for putting the fusen on a LED lamp.

The ones I made for this project are quite small. I used 7.5x7.5 cm paper, and the side of the cube is always a quarter of the side of the paper you started with. Since the LEDs don't give off any heat, the small size is not a problem. The origami paper diffuses the light very nicely, and the colors of the papers show up very bright.

Best of all, the color scheme infinitely adjustable, just by adding and removing colors according to seasons, holidays and moods!

Tuesday, February 19, 2013

WiFi access point with Raspberry Pi

Raspberry Pi as a WiFi router

In a previous post, I talked about using the Raspberry Pi as a router. Now I wanted to add a WiFi device, and use the Pi as an access point as well. The Pi has three network interfaces: wlan0 is the newly added WLAN device, eth0 is my LAN, and ppp0 is a USB GSM modem connecting everything to the internet.

The primary reason for all of this is to have an access point for an Android phone. It turns out that an ad-hoc network is not enough - Android connects only to real access points (unless rooted and configured to be less suspicious). So the task now is to set up a Linux access point.

Software-wise, the access point functionality is provided by hostapd, which can be installed on the Pi easily.
sudo apt-get install hostapd
The hardware part is quite tricky though - not every wlan card works in access point, or managed, mode in Linux. The state of support in the various drivers can be found at Among the USB WiFi sticks, ath9k_htc seems well supported. I ended up buying a TL-WN722N, since it is supported by the ath9k_htc drier, and the external antenna looks efficient. It has worked very well so far, and is in daily use. Below, I describe the steps required for setting up everything. I am using Raspbian, but most of the things should work on any distribution.

The steps
Set up a DHCP server. Edit /etc/dhcp/dhcpd.conf and add the following lines.
subnet netmask {
option domain-name-servers;
option routers;
interface wlan0;
If you already have an entry for DHCP on another subnet on another interface, make sure that the old subnet declaration also specifies for which interface it applies. Next, execute the following commands in a terminal, as root.

ifconfig wlan0    #bring up the interface
/etc/init.d/isc-dhcp-server restart #restart the DHCP server
echo "1" > /proc/sys/net/ipv4/ip_forward #turn on IP forwarding
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE #add a routing rule.

Replace ppp0 on the last line by the interface connected to the internet. For me ppp0 is a GSM modem.

Edit  /etc/hostapd/hostapd.conf . Add these lines (as a starting point):
wpa_pairwise=TKIP CCMP

Read more about the configuration options here. Next, start the access point by running hostapd.

hostapd -d /etc/hostapd/hostapd.conf

-d is for debugging output. -dd shows even more. Can be useful while setting up.

Now you should be able to connect to your new access point! Note that when hostapd quits, wlan0 looses it's IP address. So the IP must be set each time before hostapd is run.

A TP-link TL-WN722N used as an access point

If everything works with this setup, it is convenient to automate the startup procedure, so that the access point is enabled at each boot.

To bring up wlan0 at boot, add the following to /etc/network/interfaces
auto wlan0
iface wlan0 inet static
To start hostapd automatically, add the command to /etc/rc.local:
hostapd -B /etc/hostapd/hostapd.conf
-B is for running in the background, as a daemon. Messages are logged in /var/log/syslog.

For setting up the IP forwarding stuff permanently, see my previous router post, and this nice guide.

So far I am very pleased with this setup. The only drawback is that the LAN on eth0 and the wireless network are separate and isolated from each other. Perhaps it's possible to construct a network bridge between the LAN and the WLAN interface. Then the two networks would appear as one, but this I leave for the next hacking session.

Add randomness!
Finally a note about a puzzling message from hostapd. When run with the flag -dd, hostapd works, but outputs
Add randomness: count=1 entropy=0
Add randomness: count=2 entropy=1
Add randomness: count=3 entropy=2
and so on, with a new line every second or so. I thought this had to do with /dev/random running out of random bits, but this is not the case.

Reading the source code of hostapd (version 1.0, since this is what I have on the Pi), this turns out to be a normal and harmless debugging message.  Hostapd keeps an internal pool of random bits (for encryption), in addition to the random numbers it reads from /dev/random. In different places in the program, random (or at least unpredictable) data is mixed into this pool. For example the signal strength of each received packet is used in this way. The "Add randomness" message is printed each time data is added to the pool. This is done in the function
random_add_randomness (const void *buf, size_t len)
in the file hostapd-1.0/src/crypto/random.c. So, in summary, the message can safely be ignored, and goes away if one runs hostapd without the -dd flag.

However, on a small system like the Pi, there is a risk of depleting /dev/random, especially just after a boot. I observed these messages from hostapd:
random: Got 18/20 bytes from /dev/random
random: Only 18/20 bytes of strong random data available from /dev/random
At this point I installed the program haveged,
sudo apt-get install haveged
Haveged is a program that helps with providing randomness or entropy, which it collects faster than the kernel does by default. I have not seen the message since then.

Saturday, February 16, 2013

A Pibow case!

My Raspberry Pi in its new Pibow housing.
For Christmas I got a Pibow case. I like it very much! The Pi in the Pibow case feels nice and robust. The Pi gets slightly warmer in the case than without one, but this has not been a problem at all.
Related Posts Plugin for WordPress, Blogger...