Telemeter plasmoid v0.1

The telemeter plasmoid works for some time now but when I tried to distribute it, I entered packaging hell and things got deferred.. until some guy reminded me about it in the comments. 🙂

I could explain how I eventually managed to work around the packaging issue, but I’ll save that for another post 😉

Without further ado, Telemeter plasmoid v0.1 is released, go get it at kde-look.org!

Changelog:
v0.1 / 2011-04-06
=================
– fetch telenet account usage from telemeter webservice using gsoap
– store credentials in plasmoid config or kde wallet
– click on plasmoid to trigger manual refresh (telemeter service protects itself by denying access when too many requests happen consecutively, the plasmoid currently does not prevent you from doing this)
– automatically refreshes at configurable interval
– use Plasma::Meter::AnalogMeter with custom svg for better text positioning

Telemeter plasmoid configuration

Convert PDF to image files

Another entry in my PDF series. 🙂

At work I had to convert a few PDFs into jpeg files. The PDF files actually contain just images, so extracting the images would’ve been as good, but converting PDF pages to images is easier. 🙂 At least on windows. On linux you could use pdfimages, which should be available for your distro through some poppler util package.

A general approach is to use the versatile ImageMagick software. Using the convert command, it’s simply a matter of:

convert -density 200x200 -quality 85% inputfile.pdf outputfile%03d.jpg

to convert inputfile.pdf to a set of jpeg files. Of course you can choose any supported output format you like: png/bmp/gif/etc.. The density option is important as it specifies the output dpi which is only 72 by default. Imagemagick uses Ghostscript to do the pdf reading, so on windows you have to make sure that environment is set up correctly. In my case I had to add its bin directory to the path and set the working dir to the lib path as it didn’t find gs_init.ps otherwise (adding to the path didn’t help). If you know a better way, please let me know in the comments. I also specified the quality option to have a jpeg quality factor of 85, which is 75 by default.

Since I had to process a batch of them, I thought it would be nice to have a cool batch script to do them automatically. Here is what I came up with:

C:
set path=%path%;C:\programs\gs\gs8.54\bin
cd C:\programs\gs\gs8.54\lib
for %%C in (%*) do call :startconvert %%C
goto :eof

:startconvert
convert -density 200x200 -quality 85%% %1 %~dp1%~n1%%03d.jpg
goto :eof

Replace the paths as appropiate. To use the bat file, simply drag and drop one or more pdf file on the bat file. It will put jpeg files in the same directory as the pdf file and number them using 3 digits (%03d printf format). %~dp1 stands for the full path of the 1st argument file, %~n1 for the name only (without extension). Also note you have to escape all other %’s.

iTunes on linux

Read the update below!

I hate to admit it: today I created an iTunes store account. In my defense, I felt forced, as the CD I wanted to buy was only available as a physical CD and not in digital download form. It will probably become available in digital form in a year or so, but who wants to buy a 2010 compilation CD in 2012? 😉 And who wants a jewel case CD which you have to rip anyway to have any use of it (besides gathering dust).

So today, once again, I gave installing iTunes on linux another try. I followed the google #1 guide which suggested to install an old version (7.2). Unfortunately, when you go to the store, it says it can’t connect or that the service is temporarily down or something. So I thought, wine updates every 5 breaths, I wouldn’t be surprised if it actually runs the latest version. Store connection works indeed in iTunes 10! I created a login from within iTunes, made a test purchase, and yes, we have lift off. 🙂 I can see how iTunes is such a success. Just type in the search box, click and a few seconds later you have a high quality drm free mp4/AAC on your harddrive. Very tempting indeed. And the excellent recommendation system only encourages too of course.
A guide for converting to mp3 (or wave) from within iTunes can be found here. I don’t need that on the desktop, .m4a plays back fine, but my car lofi radio only plays mp3/wma.

I’m still a bit confused as to why the CD is only downloadable from iTunes and not form the publisher’s webshop. I guess they have an exclusive deal with Apple to only release the downloads after some time..

Update: The next morning I arrived at work and installed iTunes to download my newly purchased album. Surprise, surprise! iTunes does not allow one to redownload a purchased song!! It’s insanely unbelievable in this time and age, but yes, it is impossible right now. I guess most people don’t know any other way, but for a lot of gamers who use steam, it is the most ordinary thing to do.

Git: how to tag old commit

Another noob git tip. Tagging with git is easy and I won’t duplicate another explanation here. But suppose you want to tag a commit which you already pushed to another repo. When you push, nothing happens. I had tagged before, so I thought the problem was that I wanted to tag a commit which I already pushed.

But the trick to know here is: push simply does not push tags by default. You have to specify an option. So any tag you would want to share, on your last commit or any other commit, you would have to push explicitly:

git push origin <mytag>

or if you’d want to sync all tags in one go:

git push --tags origin

So, the title of this blog post was actually a trick question 😉

Win7RCAutoShutdownAlarm v0.2

Today I finally discovered why there always remained some garbage in the transparent area of the systrayicon where the piechart had passed by. It also turned out it really pays to read up-to-date Qt docs. I accidentally noticed the difference when reading the source. 🙂

Things learned:

  • when constructing an QImage you plan on using transparency on, always initialize it properly (using some fill you like).
  • when using QPainter on QImage, always use a alpha premultiplied format, for performance reasons.

I thought this new acquired knowledge justifies a new release. 🙂 So welcome v0.2 with the following changelog:


v0.2
- fixed systray render bug leaving garbage in transparent area
- added 128px taskbar icon
- added transparent circle background, otherwise you don't see anything near the end ;)

Getting mic to work with NVidia VT1708S

Ever since I installed opensuse 11.3, I hadn’t used my mic/headset. Today I decided to fool a bit around in Ardour, but somehow my mic didn’t work. And alas, I made a classic beginner’s mistake: “the solution has to be difficult because it does not work out of the box”.

I tried the standard stuff like trying out all input sources, adding hidden channels, etc. but when that didn’t help I was quickly diving into custom .asoundrc configuration, arecord/aplay sysinfo scripts, probing kernel modules, looking into alsa upgrade scripts and the like.. 🙂

Until I had an epiphany while reading random forum post words. I had been adding the “hidden” channels to my mixer which indeed included “mic” and “front mic” with accompanying boost controls. I noticed a few others which I threw in as well for good measure. I neglected them though, as I didn’t feel interested in enabling “smart” 5.1 or IEC958 2, whatever that was. But then I suddenly remembered: motherboards come with configurable audio backpanels, so this wasn’t really about enabling a fancy audioprocessing feature but rather switching between the 5.1 and standard audio panel, duh!

Apparently, the 5.1 was enabled by default, so “muting” it solved my problem!

Btw, in case you wonder: the HDA NVidia VT1708S chipset is actually a HDA Intel chipset with VIA codec, hence the VTxxxx name. To keep things intesting. 😉

Git: set up remote branch tracking post factum

I often have the following scenario:
– create local repository/branch
– create gitorious project/repository
– push branch to gitorious

This way you end up with your local branch not tracking the remote one. You know you’re not tracking when you have to specify the branch every time you push/pull and when you don’t see how much commits you are ahead of the remote. It is a matter of setting up the correct tracking configuration, something like this for the master branch:

git config branch.master.remote origin
git config branch.master.merge refs/heads/master

However, I just discovered that since git 1.7 there is now a command for this:

git branch --set-upstream master origin/master

much easier to remember!