Sunday, December 23, 2012

Usetrace - first feasible tool to test webapps from users perspective

I have been working on my startup Usetrace since February. It's the first feasible tool to test webapps from users perspective. We participated in Startup Sauna accelerator in November 2012 and loved every bit of it!

I'm explaining more about the idea behind Usetrace at http://blog.usetrace.com/?p=1 so check it out!

Oh, sign up at http://usetrace.com, we're taking new users in as fast as we can. We're also looking for talent. If you feel you can help us, tweet me @dhpe.

Friday, August 24, 2012

Vim tips (especially for the Scandinavian keyboard)

Despite being a Vim user for 9 years I have often felt unhappy about the fact how inefficiently I'm using the editor. I decided to dedicate some time and become more proficient in Vim. Most of the new power comes with the increased use of Vim's basic stuff, e.g. the change command and simply trying to find the simplest way to define what to yank, delete, and where to jump.

Some of the new power comes with better key mappings. This is especially true for Scandinavian keyboard owners like me which is be default unsuitable for Vim. This post is about .vimrc.

The first thing is always enforce use of hjkl for simple navigation by disabling the arrow keys in normal and insert modes.

map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>

Let's note that in Vim hjkl for navigation is usually the most inefficient way.

In Finland the ~ character is behind a combination of altgr, ~, space. That is three keypresses. The ~ toggles between lowercase and uppercase in Vim. The following mapping brings it behind one keypress as it's meant to be.

map § ~ "for Finnish/Swedish keyboard

Often search is the quickest way to define a desired location in the document. Again on the Finnish keyboard the / is behind two keypresses. Search should be behind one press, so it was mapped to space.

map <space> /

Switching between windows should be quicker. I mapped Ctrl with hjkl for window navigation.

map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l

For buffer navigation I mapped leader (the comma) with ö and ä. This is again useful for the unfortunate using Scandinavion keyboard, which by the way is not at all optimal for programming either.

map <leader>ö :bNext<cr>
map <leader>ä :bprev<cr>

For switching to paste mode and back I have previously used the :set paste and :set nopaste commands. Now it is mapped to leader pp which toggles between the modes quickly.

map <leader>pp :setlocal paste!<cr>

Finally, some coffeescript friendly configuration. The compilation stuff demands the coffee.vim plugin which everybody has already.

In coffeescript string interpolation is "done like #{oh boy}". The Scandinavian keyboard users' wrists are in pain. The following very warm and fluffy insert mapping injects the #{} in the context, puts the cursor after the { and stays in the insert mode.

imap <leader>§ #{}<esc>i "The § is located left to 1 on the Scandi kb.

Coffeescript programmers need to check the compiled javascript from time to time. I have mapped leader c to CoffeeCompile which opens the current buffer's compiled version in a new split window.

map <leader>c :CoffeeCompile<CR>

For checking the visually selected region's compiled code, I use

vmap <leader>c <esc>:'<,'>:CoffeeCompile<CR>

I don't want to pollute my source code directories with the compiled .js files. The following can be used to change the compile target path.

let coffee_make_options = '--bare --output ~/tmp/coffeecompiles/'.expand("%:h")

The following setting does CoffeeCompile automatically when a .coffee buffer is saved. Useful!

au BufWritePost *.coffee silent CoffeeMake! -b | cwindow | redraw!

Disclaimer! Most of the stuff here has been found from the net from various forgotten sites, so I reject all credit, except for the #{} mapping which me and my co-founder came up with - yes we write a lot of coffeescript every day!

Sunday, October 23, 2011

Potion - a language of dots

Potion is a little language and runtime by why the lucky stiff. Not much potion can be found from the net, so I wanted to conjure some. Check my Church numerals implementation from github: https://github.com/avuori/Churchpotion.

In many ways conjuring potion feels like writing Python and, not surprisingly, Ruby, but there are differences. One of the most distinctive syntactical feature is that in Potion dot is not used as a separation of an object and a message as in many object oriented languages, but rather, as in prose, as an indication of the end of something. 

Potion is a language of dots, and that becomes quickly apparent, as one ends up ending nested blocks of potion with several dots...... Though in some potion recipe it was mentioned that there is a convenience method of using a single underscore to end nested blocks of code to avoid the trail of dots. To me however, "dotting" was a delightful practise, like sprinkling salt into my sweet potion to make it perfect.

Potion is jitted to machine code before execution. Before that potion is compiled to an intermediate bytecode format (what seemed like a register-based virtual machine code). You can get the Potion implementation from github: https://github.com/fogus/potion. I think in some fork I saw a REPL as well but I did not try it.

A final tip: If you want to compile Potion runtime in Linux, you may need to create a symlink /lib/libdl.so -> /lib/libdl.so.2.

I discovered Potion from a fogus' post - be sure to check that as well!

Thursday, January 6, 2011

How to listen to a netradio channel when the firewall blocks the port

TCP port 8000 is being blocked in the customer's premises where I'm currently working. This is a Windows box. Putty resolves the problem easily for me, with some support from a remote FreeBSD setup. A GNU/Linux box would do the same.

1. Configure Putty to forward a TCP port to some local port in the FreeBSD machine.
From Putty configuration,
-> Connection -> SSH -> Tunnels -> "Add a new forwarded port"

  • In the Source port field, type some port, that is the port where you will be connecting to from your media player. Use for example, 8080.
  • In the Destination field, type for example, localhost:8000.

2. Now with Putty's SSH port forwarding configured, SSH to your FreeBSD/Linux account.

3. Now we need to forward the netradio data to the port what is being forwarded to the Windows machine. For that, I'm using wget and netcat. So in the Linux/FreeBSD account, command
 wget -qO-  http://relay5.slayradio.org:8000 | nc -l 8000
The above is redirecting wget's output to stdout and that is then piped to netcat that is listening to local port 8000. That was the port that is being forwarded. Note that in some version of nc, you may need to add the -p switch for it to work, e.g. "nc -l -p 8000".

4. Now, the netradio data is available from port 8080 from the Windows computer. You may now connect to http://localhost:8080/ using your favorite media player and start listening.

Sunday, November 7, 2010

Plus sign in email address

I ordered a micro sd memory card from a random Finnish webstore today. The website appeared to have emerged via time machine from the mid 90s. However I have to give them credit. They did not try to be too clever and validate (incorrectly) my email address in their web form. They allowed a plus sign in the email address.

The plus sign is a very handy tool in organizing/labeling email automatically. Anything after the plus sign is ignored by email servers. Thus it can be used as a label. For example, if I order something from Amazon, I use an address like me+amazon@example.com. In my email client, I can then recognize anything that has amazon as the label and do what ever organizing I want automatically.

So good job, you, the webstore from the mid 90s! Many, many others do it wrong. The programmer's lesson is this. Do not try to validate an email address yourself. If you really need to validate it, use a library that does it right. Often the best way to validate an address is to send mail to it.

Saturday, October 2, 2010

Imagine an all-display phone

There are two major forces that are pushing into opposite directions in mobile phones' physical design. One is the space we have for the apps on the phone screen where the screen size and screen resolution matter. We like to have space. Another is the physical size of the device. We like the device to be small, thin and light.

Look at the physical appearance of the current top mobile phone models. The iPhone, for example, has a screen that is almost as large as the front side of the device. However, the utilization of the available area of the whole device is under 50%. There are clearly space for significant improvement.

Imagine a device that utilizes closer to 100% of the available area. This way, we could increase the space we have for apps dramatically without increasing the size of the device.

In this kind of a device, we would have a uniform working area folded around the device. Some applications could use all of it, or you could have a music player on one side and a browser on the other. An e-book application could always have the next page waiting on the other side, and swapping the page could happen by turning the device 180 degrees around its axis. Turning in the opposite direction would naturally work as expected. Scrolling a webpage would make the page flow over the border neatly. The innovative possibilities are vast.

I did not discuss the technical issues here and on purpose. As in UI design, it is often good to forget about the possible constraints, think outside the box, and just imagine freely. Often the engineers can do it anyway sooner or later.

Wednesday, September 1, 2010

Interfacing Win32 API from Qt

If you ever need to do this sin, just include qt_windows.h and you are free to access native Win32 API.

To ensure the monster still compiles on other platforms, you may even use #ifdef Q_WS_WIN evilness as well.

Enjoy your objectionable life.