Forgot that LaTeX symbol? Use Detexify to find it for you

I just came over this website called Detexify that helps you figure out the name of a symbol based on your drawing of it. With most the symbols I tested, it managed to suggest correctly the symbol I was trying to draw. Quite impressive, and very useful!

detexify.kirelabs.org

Try it out for yourself.

Posted in LaTeX | Leave a comment

Norwegian keyboard on the N950

The N950 is delivered with a keyboard without Norwegian keys, so I decided to map holding the function/arrow key and pressing comma (,), period (.) or asterix (*) to ø, æ and å, respectively.

I you are Norwegian and just want this to work straight away, you can do the following on your device:

ssh root@localhost
wget http://dragly.org/wp-content/uploads/2011/08/rm-680
cp /usr/share/X11/xkb/symbols/nokia_vndr/rm-680 /usr/share/X11/xkb/symbols/nokia_vndr/rm-680-backup
cp rm-680 /usr/share/X11/xkb/symbols/nokia_vndr/
setxkbmap -model nokiarm680 -layout us

And that should do the trick. The keys are mapped as follows:

FN + .             æ
FN + ,             ø
FN + *             å
FN + SHIFT + .     Æ
FN + SHIFT + ,     Ø
FN + SHIFT + *     Å

If you’re speaking a different language and just want to edit the keymap manually, you can open up the rm-680 keymap file Continue reading

Posted in Mobile, N950 | Tagged , , , , | 1 Comment

Handling locked screen event in Qt for Maemo

If you want to pause an application to save battery power when the screen is turned off, you can do this by listening for the locked screen event in Qt for Maemo. However, this is not made easily available through a wrapper function (that I know of), so in this case we’ll need to resort to listening for the right DBus call. (Thanks to Diph from Maemo.org for providing the recipe to make this possible.)

First of all, you’ll need to enable dbus in your project (.pro) file:

maemo5 {
    CONFIG += qdbus
}

Next up, in your .h file you should add the following to import the DBus headers:

#ifdef Q_WS_MAEMO_5
#include <QtDBus/QtDBus>
#endif

And you’ll need to add a slot for the screen state change:

Continue reading

Posted in C++, Mobile, N900, Programming, Qt | Tagged , , , , , , , , , | Leave a comment

Handling application minimization in Maemo with Qt

When you are developing with Qt on Maemo you might want to minimize or detect minimization of your application to the dashboard. Qt lacks clean functions for these use cases, but thankfully it’s still very easy to accomplish them.

Minimizing the application

First of all, to minimize your application you’ll need to add the following CONFIG line to your project file (the .pro file):

maemo5 {
    CONFIG += qdbus
}

Then, in your .cpp or .h file, you’ll need to include the QtDBus headers:

#ifdef Q_WS_MAEMO_5
#include <QtDBus/QtDBus>
#endif

You may of course skip the #ifdef statements if you’d like DBus for other systems as well, but here I’d like to make this exception only for Maemo. Now, anywhere in your application you may add the following lines to minimize to Maemo’s dashboard:

Continue reading

Posted in C++, Mobile, N900, Programming, Qt | Tagged , , , , , | Leave a comment

Loading local gems in cPanel shared host

I had some trouble today figuring out why my Redmine installation wouldn’t start running on my shared server. I received the following error in my log/mongrel.log file:

** Starting Rails with production environment...
Missing the i18n 0.4.2 gem. Please `gem install -v=0.4.2 i18n`

Now, I had finally gotten rid of this problem while using SSH by running

export GEM_PATH=/home/<my username>/ruby/gems

in terminal (or adding it to .bashrc), resulting in successful rake commands and running the server with WEBrick. However, Mongrel seemed to have serious issues with loading the gems in my local files.

This should be solved by adding

ENV['GEM_PATH']= "/home/<my username>/ruby/gems:/usr/lib/ruby/gems/1.8"

to the environment.rb file, but it did not. Apparently this is because Mongrel loads rubygems by itself, ignoring any environment variables set after this. Therefore, the below fine hack by Rui Lopez found on this page, became necessary:

ENV['GEM_PATH']= "/home/<my username>/ruby/gems:/usr/lib/ruby/gems/1.8"
require 'rubygems'; Gem.clear_paths;
Gem.instance_variable_set(:@searcher, nil)

As Rui puts it himself:

[This] clears the internal cache used by rubygems, and forces it to
re-read the GEM_PATH env. variable.

As he also points out, it might not be the cleanest hack, but it works. And that makes me happy.

Posted in Programming, Ruby | Tagged , , , , , , , | Leave a comment

Making new image in Gimp same size as clipboard

Have you ever tried to copy an image in Gimp and open a new image to paste it into? Then you’ve probably noticed that the size of that new image isn’t automatically adjusted to the size of the image in your clipboard – like it is in Photoshop or in earlier versions of Gimp.

However, a new and simpler feature has replaced the automatic image size in Gimp. That is “Paste into image”. This is easily done by going to Edit -> Paste as -> New Image, as you see in the screenshot below, or simply by pressing Ctrl + Shift + V.

How to paste into a new image with the same size as your clipboard.

How to paste into a new image with the same size as your clipboard.

Happy editing!

Posted in Gimp, Graphics | Tagged , , , , , , | 3 Comments

Using Wacom tablet with dual monitors (TwinView) in Ubuntu

I have a setup with two monitors on my computer and wanted to restrict my Wacom tablet to only one of the screens. Otherwise, the tablet is expanded to the entire two screens, making any drawing stretched.

This has shown to be quite simple to fix if you can live with a script doing the job for you. First, type the following in a terminal and note the output:

xinput --list

You will see a bunch of names for you peripheral devices. You should look for anything that has to do with “Wacom”. For instance, on my machine, I see these names:

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Wacom Graphire4 4x5 eraser              	id=12	[slave  pointer  (2)]
⎜   ↳ Wacom Graphire4 4x5 cursor              	id=13	[slave  pointer  (2)]
⎜   ↳ Wacom Graphire4 4x5 pad                 	id=14	[slave  pointer  (2)]
⎜   ↳ Wacom Graphire4 4x5 stylus              	id=15	[slave  pointer  (2)]

Now, create a file somewhere on your computer. I’ve put mine in a subdir of my home directory, naming it “wacom-settings.sh”. Add these contents to the file and change the name of each “Wacom…” to whatever you received as output above:

#!/bin/sh
xsetwacom --set "Wacom Graphire4 4x5 stylus" Twinview Horizontal
xsetwacom --set "Wacom Graphire4 4x5 stylus" Screen_No 0x001
xsetwacom --set "Wacom Graphire4 4x5 cursor" Twinview Horizontal
xsetwacom --set "Wacom Graphire4 4x5 cursor" Screen_No 0x001
xsetwacom --set "Wacom Graphire4 4x5 pad" Twinview Horizontal
xsetwacom --set "Wacom Graphire4 4x5 pad" Screen_No 0x001
xsetwacom --set "Wacom Graphire4 4x5 eraser" Twinview Horizontal
xsetwacom --set "Wacom Graphire4 4x5 eraser" Screen_No 0x001

Then you’ll just have to make the file executable. This could be done from terminal by issuing the command

chmod +x wacom-settings.sh

in the same directory as the file.

You could also right-click the file, select Properties > Permissions tab and check “Allow executing this file as a program”.

You might either add this file to your startup applications under System > Preferences > Startup Applications (this will only work if your tablet is connected when logging in) or you could add a launcher on either your desktop or in one of your panels by dragging the file there.

This should be it. To test that the configuration really works, double click the file and click “Run in Terminal”. If the tablet appears on the wrong screen, change the Screen_No above from  0×001 to 0×000.

Good luck with your notes and drawings!

Posted in Graphics | Tagged , , , , , , , , | 11 Comments

Spotify for Linux

Awesome news! Spotify is now finally available as a native client for Linux. I have no idea why I haven’t spotted this earlier, as it was already announced in July, but in any case it is finally here.

Although they call it a preview, it seems to be a very finished and good-looking product, and I finally might get rid of those annoying sudden playback stops I experienced while Spotify under Wine. At least I haven’t experienced any of them yet.

I wish they would release it as an open source application as well, but for now, I’m very satisfied seeing that the money I’m spending on it pays off for Linux users as well. At the moment though, it seems like it is only packaged for Ubuntu and Debian, but hackers using other distros out there are probably going to figure out how to run it on other machines.

Now I’ll be hoping for a native version for N900, as most of the projects attempting to run Spotify on Maemo appear to be left unusable each time Spotify updates their API.

Posted in Ubuntu | Tagged , , , , , | Leave a comment

Updated method for drawing springs in Inkscape

I’ve written an earlier post on how to draw simple schematically springs in Inkscape. After reading a great tip from ~suv in the Launchpad bug tracker, I figured I should bring you guys another update on how to do this using ~suv’s method.

Basically, what you need to do is to draw a zig-zag line in Inkscape using the pen tool . This is fairly easy to do, so I’ll leave that part up to you. Just turn on the grid by pushing SHIFT+3 first, as this will make it easier to draw it symmetrically. Have a look at the picture below:

A simple zig-zag line in Inkscape

The next thing is to select all the nodes on the sharp edges of your spring as in the image below:

Select all the nodes on the spring, except the outer parts.

Afterwards, push the button outlined in the screenshot to make the selected nodes smooth.

Push the "Make selected nodes smooth" button in the toolbar.

We’re soon done, all we need to do now is to turn each of the node handles on either the top or the bottom of our wiggly line 180 degrees. This is where it’s really nice to have the grid enabled to make sure all the handles are turned just the same amount.

When all the lower handles are turned, my wiggly line became a beautiful spring!

And we’re finished! Below you see my finalized spring:

Look at that spring twisting around itself again and again.

You may put this into whatever physical context you want. Connect it to boxes, power grids or horses – just remember to show off that you have now become a worthy spring master! I decided to go with a good old sports car.

I guess we're looking at a couple of kilonewtons here!

If you like to, you may download the source .svg file here.

Posted in Graphics, Inkscape | Tagged , , , , , | 7 Comments

Trafikanten on Maemo

Update: The package was pushed to Extras testing on 2nd of October. It was delayed because Maemo’s package repository would not import the new package due to some trouble with the version numbering.

There has been missing a native application to access information from Trafikanten on the Nokia N900. Instead it has been necessary to use the mobile version of their websites or maybe even the full version. Even though this is a pretty quick and workable solution, there are several benefits of having a native application available. One that becomes very obvious is the use of GPS to find all nearest bus stops or train stations.

I decided to give it a try in June this year and started by releasing some early versions of what is now named “Journey Planner for Norway” (which is “Reiseplanlegger” in Norwegian). During the summer of 2010 I have been trying to improve the application over several iterations, and feel that it has now come to a point where it is usable and stable enough to get the infamous “Version 1.0″ attached to it.

The application is now finding its way through to the Extras-devel catalogue for Maemo and will be pushed upwards through Extras-testing before it hopefully hits Extras within two or three weeks. In the meantime you might either be a bit careless and enable Extras-devel to use the bleeding edge 1.0 version or head over to Maemo Downloads to fetch the beta which will be automatically updated to 1.0 whenever it is ready.

Below you can check out some more screenshots of the application in action:

The application is developed in C++ using Qt with the Qt Mobility libraries. It should not be too hard to port it to Symbian as well, so I will give that a shot in the future. Symbian users does however already have an option to use the Java application “Trafikanten Sanntid” made by Håvard Tegelsrud.

And of course, you can check out the source code here. The application is licensed with the GNU GPLv3 license.

Posted in C++, N900, Programming, Qt | Tagged , , | Leave a comment