blog/ notes/ projects/ colophon

I haven't been updating this site or the software running it very much for the last year and a half. Time sure flies. In the mean time, ideas evolve and mature. So after reading about Toto, a tiny Ruby + git blog software, I resolved to update nnmc and finally implement a few idea I had at the beginning. Here is what I did today:

  • I now use git (via github) for the version control of the software. You can now peek at the ugly php code behind this site.

  • I also use git for the content. Unlike Toto, I use a separate repository for the content of the website. I don't have templates but I have a few different categories of content, not just a blog. As the content is easily scrapable from the web, I just made the raw source available on GitHub (also, it will not count toward my private repo quotas).

  • I finally created a setup script to handle the different configuration between the local (dev) version and the production (remote) sites. You can peek at it.

One nice idea of Toto that I like very much is to not have a component to edit the content from the web. I didn't create that much content via the web interface anyway. That sure simplifies the security aspect, especially when you can't have ssl on your host. I'll see when I have time to remove it.

To migrate this website from being a set of files to being a checkout off github, I had to do a bit of research to find a way around using git clone. The problem was that I wanted to checkout the content of the repository in the public directory from where files are served, not create a 'nnmc' dir and symlinking that. So here is what I did, after ssh-ing into my account. I ran the following commands from /home/public directory that serves the files.

To get the software :

git init
git remote add origin git://github.com/nicolasH/nnmc.git
git fetch origin

The following command will actually make the files appear in the directory. I use the -f to overwrite the files that are both in the repository and on the website.

git checkout -f -t origin/master -b master

Then just symlinks the .htaccess and config.php to the prod_ files:

bash setup.sh prod

To get the content is much simpler, as it was already in a separate directory:

git clone git://github.com/nicolasH/content_nnmc.git

And "that's it". I can update either the content or the software with a git pull. Which I will have done to update this post.

As I am looking into iPhone application development, I did an informal survey to figure out what are the common ways to handle zooming and fullscreen interactions.

Notes:
- The "survey" was conducted on my iPhone 3G 3.1.2.
- By 'controls' I mean any button, toolbar or popup that the user can tap on.
- All the apps were at their latest version as of the 28th of March 2010.

Apps with variable size canvas :

  • Maps: Double tap to zoom in, two fingers tap to zoom out, pinch to zoom in/out.
  • TomTom: Double tap to zoom in, two fingers tap to zoom out, pinch to zoom in/out (in the "explore map" screen).

Apps with a fullscreen view and variable size canvas :

  • Google Earth: Double tap to zoom in, pinch to zoom in/out. Each corner has some buttons to trigger actions or show more controls.
  • OffMaps: Double tap to zoom in, pinch to zoom in/out. Single tap to show/hide controls (but a double tap also triggers this).
  • iOSMaps : Double tap to zoom in, pinch to zoom in/out. Always some controls on the top of the screen.
  • Seadragon : Double tap to zoom in, pinch to zoom in/out. Single tap to show controls, with a delay before tappable elements fade in/out.
  • Moon globe: Pinch to zoom in/out. Single tap to show and hide the controls.
  • Photos app: Double tap to zoom/cancel zoom, pinch to zoom in/out. Single tap to show/hide the controls.

Apps with a fullscreen view and fixed size canvas :

  • Stanza : Pinch to zoom in/out, single tap in the middle to show the controls.
  • MyPaint free : Pinch to zoom in/out, a button in the corner to show the controls, tap in canvas area to dismiss.
  • Koi pond : Buttons in the bottom corners. Fade in after a few seconds in the app, but still tappable.

Zoom :

Pinching is the only standard gesture for zooming.
- Double tap seems to be relatively common for zooming in.
- Pinch is the only common way to zoom out.

I was surprised to find that the two-finger tap gesture was quite rare, as it is featured in the iPhone dev kit samples and in the Maps app. Maybe it is judged as not easily discoverable?

Another interesting point to me is that no one seems to allow zooming out in single-handed operation.

Leaving fullscreen mode :

There seems to be two different ways to trigger showing more controls on the screen.
- For some apps you have to tap on a control, either partially transparent (Koi Pond, My Paint Free) or fully visible (Google Earth).
- For others, the single tap gesture is recognize, and triggers showing / hiding more controls to the user.

As a user, I find that 'single-tap to show UI' works well only in Stanza, maybe because it is a non-scrollable canvas. On scrollable canvas, the only OK implementation I found (in my very limited sample) was in the Photos app. I personally found it sluggish in Seadragon, too sensitive in Moon Globe and too annoying in OffMaps. For example in OffMaps: you can tap-and-hold to add a waypoint; to dismiss the control that appears, you have to tap somewhere else, but that triggers the global "show/hide UI", as does a double-tap to zoom. By contrast, in the Photos app you have to tap to show the controls, but any tap or scroll in the photos area will dismiss the toolbars.

My main problem with single tap to show the UI is that it is too easy to trigger involuntarily in apps in which you interact with the screen for scrolling. Maybe it is much harder to get right? I believe it is easier to have the control out of the way in a corner, where it is still easily found yet harder to trigger unintentionally.

or : how to use synergy and a broken eeepc to get almost decent mouse performances on a mac.

Initial setup

I have a Happy Hacking Keyboard (lite 2) keyboard, which is a very nice japanese keyboard made by PFU/fujitsu. I bought it to use it at work with my linux machine, to replace a kilometer-long keyboard. I am on a two weeks holiday, so I decided to bring it home, and to try to use it with my Macbook Air.

A friend of mine gave me his broken eeepc a while ago. The screen is toast, but the rest works nice. It is slow but has more expansion ports than my Macbook Air ;-) The machine is still running he original linux offspring that came with it, a fork of debian called xandros with some asus modifications. A strange mix.

At work, I sometime bring my laptop and connect my workstation and my laptop using synergy. It works very well, and the mouse moves at the normal speed, not at the sluggish speed that mac os x believe it should. At home, I almost never use the external mouse, keyboard and screen. But for the holidays I wanted to try again. Of course, the simplest solution to make everything work smoothly is to use USB Overdrive. It can make USB mice behave in a more usual fashion. You just have to buy it for 20 USD. And plug and unplug everything everytime you want to use the setup.

I tested both the synergy and the USB overdrive method, and the overdrive way works better, as there isn't 3 networks for the information to travel through. For the synergy method, there is always an almost imperceptible delay when you start a movement, but you don't loose precision as the pointer "teleports" where it should be. The cursor sometimes moves choppily.

0 - How to edit files on the eeepc

To edit files you need to see them. You could use the file browser, but I prefer to use the command line. You can open a command line using two methods.

  • a simple "Ctrl-Alt-t"
  • in the work tab, launch the "File Manager", select the "Tools" menu, then the "open console windows" option.

As you need to be root to edit most of the interesting configuration files, you have to prefix the launch of the editor with the sudo command, which allow a user to do something as if he was root. For example, if you don't know the password of the user but need to set it, the following command allows you to set the password :

sudo passwd user

It will work on the eeepc because the sudo command doesn't ask you for your password as it would on my linux workstation.

For the editor, I use kate, which is a nice not too slow to launch editor.

1 - How to install synergy on a vanilla eeepc 900

The synergy package is not installed by default, and isn't part of the default eeepc repository. You have to install it from a Debian repository. Here's how.

To add a debian repository. In a console execute the following command :

sudo kate /etc/apt/sources.list

Add the following line at the end of the file, save, quit kate :

deb http://http.us.debian.org/debian/ etch main contrib non-free

Launch synaptic from the console :

sudo synaptic

Click on the search button and search for "synergy", select it, and click on the apply button.

You now have synergy on your eeepc.

Here is what i tried but didn't work :

  • Installing the package from source : doesn't work because the gcc package is not installed, and trying to install gcc finds some conflicting dependencies.
  • Installing the binary from the rpm package, by unpacking it : there is no rpm related command in the root or user path.
  • Installing the .deb package from the debian website : I could only get the lenny version, and it seems that the distro on the eeepc is closer to the etch version.

2 - How to configure synergy

The configuration file contains the relative position of all the screen that will be connected together. You can read the documentation at the synergy website and click on configuration (uses frames, so i can't link to the page with both the nav bar and the content) or straight to the config page.

My own setup is barebone :

section: screens 
    Ikki: 

    asus: 
end

section: aliases 
    Ikki: 
        192.168.0.6 
        Ikki.local 
end

section: links 
    asus: 
        left = Ikki

    Ikki: 
        right = asus 
end

The synergy client is launched from from the command line, with just the address of the server : synergyc serveradress i.e. synergyc 192.168.0.5

The synergy server needs the location of the configuration file:

synergys --config synergy.conf

i.e. on the eeepc synergys --config /home/user/sillyScripts/synergyIkki.conf

3 - How to launch the synergy server at startup

Actually, as the server needs both the network interface up and the X server to be launched, it should be the last thing that is done. You also want the server to run as a the user, and not as root.

First you have to write a script that executes all you need. In the case of the happy hacking keyboard, you might want to change the keymap, then start the synergy server. Here is the script I use :

#change the keyboard layout
setxkbmap -display :0 -model jp106 -layout jp
#remap the keys left and right of space to space.
xmodmap -display :0 -e "keycode 131 = space"
xmodmap -display :0 -e "keycode 129 = space"
killall synergys
sleep 1
/usr/bin/synergys --config /home/user/sillyScripts/synergyIkki.conf
#play a sound when everything is done
mplayer /home/user/sillyScripts/cff_f.mp3

To make sure that everything is working fine, start your script from the command line. i.e.:sudo -u user bash /home/user/sillyScripts/startStuff.sh

Then add that last line the system startup script: sudo kate /usr/sbin/services.sh scroll to the end, and add your command to the last line.sudo -u user bash /home/user/sillyScripts/startStuff.sh`

And voila ! your eeepc can now export its keyboard and mouse to another machine.

Here is what I tried but didn't work : - Adding the startStuff script to the /etc/rc.local file. This file is not used by the system apparently. - Adding the startStuff script to the /etc/fastservices file. The script seemd not to be run either. - Running the startStuff without sudo. I don't know why, but it didn't work either, thus sudo -u user prefix to the bash command.

5 - Bonus: using ssh tunneling for fun and privacy.

As my connection is using the airwaves and I'd like to keep my blog posts private until I publish them, I added ssh tunneling to the setup. Here's how you can do it too.

On the server, you have to start the ssh daemon : open a console, sudo kate /usr/sbin/services.sh Scroll to the end, and just before you start your script add sshd

This will launch the ssh server. You will then have to create an ssh tunnel to the server on you client machine. This machine needs to have the ssh client installed.
To create the tunnel : ssh -f -l user -N -L 24800:192.168.0.5:24800 192.168.0.5 Then to connect to the server through the tunnel : synergyc -f localhost

The command redirects your local port 24800 to the remote machine 192.168.0.5 on its port 24800. the second 192.168.0.5 means that tis is the machine through which the port will be forwarded( it could be any other machine on the same wired network as the destination machine). Every time you will want to securely connect to the synergy server, you will have to start this script first. then,

Afterword:

I understand the exporting your eeepc mouse and keyboard is not the most practical thing to do. It can however be of use when you want to remotely control a HTPC and are too cheap to buy a remote keyboard.

a.k.a (Caesar Cipher)

update 2009/01/09 : I made a JavaScript version you can play with.

There was a text advert on Daring Fireball which seemed to be obviously a shifted text. (i.e. the rotation of an intelligible text was used). That prompted me to try and decode it. I'm lazy, so i didn't want to do it by hand. The scripting laguage that I currently use is php, so I looked for a text rotation method in php, but the only one I could find is rot_13, which rotates the text by 13, but that didn't give me the answer. So I coded my own arbitrary rotation function. Here it is :

$str="Ztte pc tnt dc BprWtxhi iwxh lttz. Hdbtiwx cv’h vdxcv sdlc…";
$rot = 11;
print "rotation = $rot . Rotated text: ". rot_n($str,$rot) . "\n";
function rot_n($str,$rot){
    $upperOffset = 65;
    $lowerOffset = 97;
    $ret="";
    for($i=0; $i<strlen($str); $i++){
        $c = ord(substr($str,$i,1));
        if($c>64 && $c < 91){
            $ret.=chr(($c-$upperOffset+$rot)%26+$upperOffset);
        }
        else {
            if( $c>96 && $c<123){
                $ret.=chr(($c-$lowerOffset+$rot)%26+$lowerOffset);
            }else {
                $ret.=chr($c);
            }
        }
    }
    return $ret;
}

You can use this to code and decode :-). Maybe i'll do a javascript version of this function.Done and commited in github.

moved to the notes section : nnmc status


blog/ notes/ projects/ colophon