The blog has moved. Go there!

tiistai 25. helmikuuta 2014

SOLVED: "Unsatisfied dependency: Crypto"

Check the updated post here.

I wanted to install yle-dl on my Mac OSX Mavericks. I run the following command according to the installation instructions at yle-dl Github repository's installation instructions.
brew install python && pip install pycrypto && brew install yle-dl
The series of commands failed with the following error message:
"Unsatisfied dependency: Crypto"
The solution was to install rtmpdump before installing yle-dl, osimoilleen näin:
brew install python && pip install pycrypto && brew install rtmpdump && brew install yle-dl 

sunnuntai 9. helmikuuta 2014

How to purge IndexedDB databases in Google Chrome

See the updated post here.

To remove all Chrome IndexedDB databases run the following in OSX terminal emulator.

rm -rf ${HOME}/Library/Application\ Support/Google/Chrome/Default/IndexedDB/*

Now restart your browser and that's it.

Because I need to purge IndexedDB databases very often, I have set up an alias in my ~./bash_profile.

alias purge-idb="rm -rf ${HOME}/Library/Application\ Support/Google/Chrome/Default

torstai 23. tammikuuta 2014

My first Jolla / Sailfish App, Personal Travis, Released!

My personal trainer app called Personal Travis (Personal Raineri in Finnish) has already been released in Google Android Play Store, but now it is also available for Sailfish OS in Jolla Harbour.

tiistai 21. tammikuuta 2014

Personal Raineri now also in English: Personal Travis

Personal Raineri (beta) is now also in English, and it's available in Android Store for free. In the English-speaking world Personal Raineri is and will be known as Personal Travis the Trainer.

keskiviikko 1. tammikuuta 2014

Using rsync as drop-in replacement for scp

Everyone knows that scp is secure. Everyone also knows that rsync isn't that secure but it's handy. It can e.g. resume interrupted file transfers. It would be nice if those two pros could be combined in one package.

Well, it's possible. Just put the following lines at the bottom of your ~/.bashrc or ~/.bash_profile.
alias rscp="rsync -avzP"
alias rscp-resume="rsync --partial --progress --rsh=ssh"
Reload your BASH (you could for example log out and back in), and you are able to use a command rscp just like scp. You are also able to resume interrupted file transfers by rerunning the interrupted command but putting rscp-resume instead of rscp.

Let me give an example. If your file transfer just failed with command rscp foo.txt user@domain.tld:bar/, just run rscp-resume foo.txt user@domain.tld:bar/ to continue the file transfer.

sunnuntai 22. joulukuuta 2013

Installing Sailfish OS on Nokia N9 using Ubuntu 12.04 LTS

In this blog post I'm going to tell, how I installed Sailfish OS (the OS of Jolla Phones) on my Nokia N9. If you have basic knowlege of Linux, I recommend trying. But only if you acknowledge the risks. I won't be responsible in any way, if you break your phone. So don't try this at home, if you don't know that your phone could be permanently damaged.

Please note that for the first try I failed the bootloader installation. I guess that many of those installing Sailfish OS at this stage will fail it, so see my solution at the bottom of this blog post. After solving the bootloader problem I got Sailfish OS up and running on my Nokia N9.

Why I was ready to take the risk?

I love the design of Nokia N9.  It's simplistic, beautiful, and its white-on-black UI is wonderful. I don't like the idea that there is a box (= screen) in which elements are showed. I want the elements to appear on my phone. No boxes, please. And of course, it was Linux. The opennes let me do anything with the phone, such as modify its behaviour and of course fix malfunctions. Surprisingly, in the era of Apple and Microsoft, ability to fix stuff is luxurious.

This all made me fall in love with N9. But I heard, that Nokia will stop supporting N9, so I didn't buy it. This lead me to one of the biggest mistakes in my life. Nokia Lumia 800 had generally the same design and the UI was white-on-black style. I didn't want to be ideologic and abandon a good phone just because of hating Microsoft categorically. That's why I bought a Nokia Lumia 800. It was terrible. I should have been ideological and fanatic. No Microsoft stuff for me anymore. Ever.

For luck one of my friends broke his N9. I opened it and repaired it, changed a few components and was able to make the N9 function again. MeeGo was old and not supported anymore. But for luck, there was already company called Jolla founded on the ashes of Nokia. It's wonderful that Nokia stopped developing MeeGo and fired those engineers, because Nokia would probably have been too big and unflexible to develop a community-driven operating system. Now those engineers have a company of their own, and they are developing Sailfish OS based on MeeGo. I wanted my N9 to run Linux-based operating system with updates. I think that Sailfish OS on N9 is much cooler than on the original Jolla Phone. Well, I will also buy Jolla Phone anyway.

If you want to install Sailfish OS on your N9, I advise you to follow the instructions at Maemo Wiki. I made these notes to help someone who is struggling with the Maemo Wiki tuturial. Of course, it's quite general and supports many platforms, so there aren't e.g. detailed commands. So, these notes are written to give some hints, how to walk through the installation process. This is just how I did it. I hope this is useful for someone. Please ask if you need help, maybe we manage to figure the things out.

Reflashing N9 to factory firmware

I followed the instructions in Maemo Wiki. I didn't backup anything, because there was nothing to lose on my phone. Btw, I always use ~/Temp as my working directory.

First I downloaded the flasher and installed it.
cd ~/Temp && wget && sudo dpkg -i flasher_3.12.1_i386.deb
Then I downloaded the necessary image files to be flashed. For the first time flashing N9 I was confused with Firmware and EMMC. The role of those files wasn't very well explained anywhere, and I didn't know where to get the proper files. I also didn't know did it matter, which file I downloaded. The good news is, that of course it does matter, but not much. It's enough to download any of these *tar.gz packages, and all the necessary files are included. If you are interested in getting further information, you can find such stuff here. I decided to use Swedish Country Variant, since I wasn't able to find anything referring Finland, when using CTRL + F.
wget && tar xf 059L7N7_N9\ RM-696\ Country\ Variant\ Sweden\ SE\ Magenta.tar.gz
The result was a folder with a dozen files.
erkkimon@lappy:~/Temp$ ls 059L7N7_N9\ RM-696\ Country\ Variant\ Sweden\ SE\ Magenta
I renamed (plus moved to ~/Temp) two files which I was going to flash on my N9 to make things clearer and to avoid typing mistakes. 
mv 059L7N7_N9\ RM-696\ Country\ Variant\ Sweden\ SE\ Magenta/D6C9C818_DFL61_HARMATTAN_40.2012.21-3.339.1_EMMC_339.bin ./emmc.bin && mv 059L7N7_N9\ RM-696\ Country\ Variant\ Sweden\ SE\ Magenta/A0E9827F_DFL61_HARMATTAN_40.2012.21-3.339.2_PR_LEGACY_339_ARM_RM-696_PRD_signed.bin ./main.bin
At this stage, I ensured, that my phone was fully shutdown, pressing power switch for at least 10 seconds. I also made sure that my phone was not connected with my laptop. Then I run the following command in ~/Temp.
sudo flasher -F main.bin -F emmc.bin -f
As the terminal said "Suitable USB interface (bootloader/phonet) not found, waiting..." I connected the phone to my Ubuntu laptop with the USB cable. The flashing began immediately. I went to take a cup of coffee, and after half an hour the flashing was done. I didn't disconnect my phone or touch it.

Flashing the OpenMode

I downloaded OpenMode kernel running the following command in ~/Temp.
Then I flashed the new kernel in my N9. I still had the N9 connected, and I hadn't touched the phone at all after the previous flashing session.
sudo flasher -a main.bin -k zImage_2.6.32.54-openmode_l2fix --flash-only=kernel -f -R
Now my N9 booted up. I typed in the PIN code, set the language and time, etc. The phone seemed to be working properly. I also logged in with my Nokia Account to be able to install stuff. This is necessary to enable developer mode, which requires installing a few packages.

Enabling developer mode

I enabled N9:s developer mode just switching it on at Settings -> Security -> Developer Mode. The phone wanted to install packages, and I naturally allowed to install them. The phone rebooted. After it was up again, I shut it down and disconnected the phone.

Repartitioning the N9

I downloaded the kernel used for partitioning the phone.
It needed to be extracted to use the kernel image in the RPM package.
I started the flashing process.
sudo flasher -k moslo- -n moslo- -l -b
When the terminal told me flasher to be waiting for a flashable device to be connected, I connected the phone to my laptop with the USB cable. Flashing was pretty soon done, and the phone booted up with a message which told, that the phone was partitioned, and that it wasn't advised to unplug or shutdown the phone.

As there was text "Re-partitioning succesful! Rootfs of AlternateOS now exported via USB. You can telnet into" on the screen of N9, I unplugged the phone and shut it down completely.

Installing Ubiboot

I downloaded the ready Ubiboot bootloader package preconfigured to boot Sailfish OS and Harmattan.
I was still in ~/Temp. I extracted the package.
tar xf ubiboot-02_0.3.5_131213_SFOS.tar 
I connected my phone with USB cable to my computer. The phone booted, and after entering my PIN code it asked, if I wanted to use N9 as mass storage. I pressed "Use as mass storage" on the screen of my mass storage. Now I opened the file manager and opened Nokia N9. I dragged ~Temp/ubiboot-02_0.3.5_131213_SFOS.tar to the root of Nokia N9. Then I unmounted the Nokia N9 drive and then unplugged it.

I needed to reboot the phone to be able to find the file which I uploaded just a moment ago. Anyway, I after the reboot I was able to find the file in ~/MyDocs/ubiboot-02_0.3.5_131213_SFOS.tar with my N9's terminal emulator.

In my N9's terminal I logged in as root.
I typed rootme as the password, which is the default password in Meego phones. Then I extracted ubiboot-02_0.3.5_131213_SFOS.tar in the proper location.
cd /home/user/MyDocs/ && tar -xvf ubiboot-02_0.3.5_131213_SFOS.tar -C /
Then I started flashing again. I switched my N9 off and at this time, my phone was unplugged. On my laptop, I run the following command.
sudo flasher -a main.bin -k zImage_2.6.32.54-ubiboot-02_301013 --flash-only=kernel -f -R
Then I plugged in my N9. The flashing was done quickly. When it was done, I left the phone plugged, and didn't shut it down.

Installing Sailfish

I started downloading the Sailfish package. On my laptop, I commanded the following.
I renamed vgrade-sailfish_r4.tar.bz2.
mv vgrade-sailfish_r4.tar.bz2 sailfish.tar.bz2
I made sure that a storage called Alt_OS was mounted. Then I extracted Sailfish OS on my N9 in a proper location.
tar --numeric-owner -xvjf sailfish.tar.bz2 -C /media/Alt_OS/
This took about 5–10 minutes to finish.

Gaining SSH root access to Sailfish OS

The first step was to enable root login to N9. That was done editing sshd configuration of N9/Sailfish i.e. uncommenting "PermitRootLogin yes" line.
sudo sed -i 's/#PermitRootLogin Yes/PermitRootLogin Yes/ig' /media/Alt_OS/etc/ssh/sshd_config
Then to reset the root password. I naturally backed up the /etc/shadow before messing around with it.
sudo cp /media/Alt_OS/etc/shadow /media/Alt_OS/etc/shadow.orig
Then I reset the password.
sudo su -c 'sed -e "s/^\(root:\)[^:]*:/\1:/" /media/Alt_OS/etc/shadow.orig > /media/Alt_OS/etc/shadow'
From now on, I didn't have root password. I was ready to boot up my Sailfish OS. I unplugged my N9, shut it down, and powered it on.

Setting root password for Sailfish OS

This time everything didn't go as expected. I got the following error message on the screen of my N9.
Boot menu script not found! Please run a maintenance boot.
I checked if there was something wrong in my setup. I checked if there was useful info info in the tutorial section, which concerned installing unpreconfigured Ubiboot. According to it, there should have been zImage_2.6.32.54-openmode_l2fix in /media/rootfs/boot/. There should also have been ubiboot.conf and ubiboot-02.035_SF_v1.cpio in /media/Nokia\ N9/boot/.

Well, it was time to do something for these drawbacks. For luck, I naturally had all those files on my disk already. I mounted the volumes Nokia N9 and rootfs with my file manager and commanded the following in my working directory ~/Temp.
sudo cp zImage_2.6.32.54-openmode_l2fix /media/rootfs/boot/
Then I extracted the files in ububoot package and moved the needed files to proper place.
tar xvf ubiboot_035_sailfishos.tar && sudo cp home/user/MyDocs/boot/ubiboot* /media/Nokia\ N9/boot/
Now, I unmounted the volumes, unplugged the phone, shut down the phone, and powered it on. And voila, I had a booting Sailfish OS!

EDIT: After testing Sailfish for a while

After having slept over night I have done some testing during the day. Sailfish is usable, and basic functionality is okay. I already dumped my Lumia 800 and use N9 as my primary phone. If you have a working MeeGo, you probably don't want to install Sailfish yet. But the Sailfish N9 port is so promising that I'm quite sure nearly all N9 owners will be able to use Sailfish as their primary OS. Here are some results so far.

keskiviikko 18. joulukuuta 2013

Personal Travis Beta 0.3.2 Released

Personal Travis aka. Personal Raineri is an application to substitute your personal trainer, training diary and workout programme. Personal Travis is a mobile app coded by me as a part of Mobile Product Development Course taught by Tero Karvinen. 

Personal Travis suggests the user a workout routine and weights. Personal Travis remembers the last suggestion, and will suggest the following workout routine based on former routines. Personal Travis also remembers, if the user has reached the goal set by Personal Travis. 

All goals will be the same until the user reaches them. Then Personal Travis will suggest a higher goal, so all user needs to do is to (1) see what to do this time and (2) tick a checkbox if a goal is reached. Everything else happens automagically.

What is the status of this project?

Although the core functionality of Personal Travis is quite stable, the status of the project is still beta. This is because Personal Travis will be quite large application, and lots of features are yet to be implemented. My goal was to implement the core features of Personal Travis before the end of the year 2013, and now the achievements are available to be tested by anyone at Google Play Store.

As Personal Travis is now available only in Finnish with name Personal Raineri, it will be translated in English. After letting the English-speaking world get their hands on Personal Travis, the app will be fully reprogrammed. There are many things that would have been wiser to be done differently, so I will do them differently. I have also used a few unnecessary libraries, and I want to get rid of them to make the software lighter. The changes are so foundational that it's easier to just reprogram everything.

How is it generally built in the technical point of view?

The deepest level of the program is database, which stores information about the last workout routine, and the reps plus weights for every particular excercice. The database solution is HTML5 database (Web SQL) used through html5sql.js. 

The data in database is utilized by the application, which calculates, which workout routine should be the next one, and what are appropriate weight and amount of reps for this particular user. This data is pushed in the UI, which is built using frameworks named MetroUI CSS and MetroJS.

The app consists of seven HTML pages (index.html + 6 subpages). The animations in the main view are made using MetroJS. The general functions have been coded with JavaScript – or JQuery, to be specific. Triggers are mostly coded in the HTML pages between <script> tags, and the triggers call functions defined in training_functions.js and db_functions.js. Most of functions in training_functions.js are dependent of db_functions.js. There is also transition.js, which just includes the transition fade effect triggered when switching page.

Is the source code available?

Personal Travis is released under GPL v2 License, and the code has been on Github since version 0.2.6. The source code (*.zip) and the Android installation package (*.apk) can be downloaded here. If you want to install the app, the easiest way is to install it using Google Play Store, so just click the link!