Wednesday, November 23, 2011

Resizing images and generating animated gifs

After writing my last posts (Plotting memory usage on console and More trickery with gnuplot dumb terminal), I had to put here some lines used to make the screenshot I'd put there.
To resize all screen shot frames:

ls -1 *.png | cut -d . -f 1 | while read line ; do convert $line.png -resize 60% $line.mini.png; done


In stead of resizing the image, they can be cropped:
ls -1 *.png | cut -d . -f 1 | while read line ; do convert $line.png -crop 400x270+92+37 $line.mini.png; done

To make the animated gif
convert -delay 100 -loop 0 screenshot0*mini.png screenshot.gif

More trickery with gnuplot dumb terminal

In my post "Plotting memory usage on console" the chart doesn't panned the data.
Now, using a named pipe, the effect got a little bit nicer.
First we have to run the memUsage.sh script to get a file filled with memory usage info:
./memUsage.sh > memUsage.dat &
Then we have to create a named pipe:
mkfifo pipe
Now we have to run another process to tail only the last 64 lines from the memUsage.dat
while [ 1 ]; do tail -64 memUsage.dat> pipe; done &
And now we just have to plot the data from the pipe:
watch -n 1 'gnuplot -e "set terminal dumb;p \"pipe\" with lines"'
And that is it!

Plotting memory usage on console

This is just a simple hack to play around with gnuplot set to dumb terminal (character console), doesn't meant to be serious application.
First I had written a bash scritp to log memory usage a while ago:


So, while running this script in background (./memUsage.sh > memUsage.dat &), logging the data, the memory usage information can be plotted with gnuplot and watched in real time:
watch -n 1 'gnuplot -e "set terminal dumb;p \"memUsage.dat\" with impulses"'

The chart can be plotted with lines, with impulses or any gnuplot style option.


Tuesday, November 22, 2011

ftdi232 permission on Ubuntu

I'am using the ftdi chip with bitbang mode to control some hardware with linux.
Every time I copy my software to a new desktop, it always take me hours to figure out why it has no permission to run the bitbang mode as a regular user.
Every website or forum I look around tells me about the udev, but I check back on the working desktops and there is no udev rule for the ftdi hardware. And after trying to force permissions with chgrp and chmod directly on /dev/bus/usb/* I figured out that I had to master at least a little about udev rules.

Checking with a little more care at a working machine I´ve found a Virtualbox instalation which created a udev rule for the virtualbox usb driver. Changing that rule to be used with the FTI chip I do the following steps, with had worked perfeclty:

Create the file /etc/udev/rules.d/10-ftdi.rules

Write on it:
SUBSYSTEM=="usb_device", GROUP="dialout", MODE="0664"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="dialout", MODE="0664"

I have to make sure my user belongs to the dialout group, reboot the machine and that´s done.

Thursday, August 25, 2011

powerpoint slides to jpeg

Looking for some way to convert power point slides to JPG, I've found this site:

http://www.commandlinefu.com/commands/browse

It has tons of good linux command line tips.

And here is the tip about the pdf to jpg which brought me there:

http://www.commandlinefu.com/commands/view/719/convert-pdf-to-jpg

And to convert the powerpoint to pdf before, one can issue the unoconv command:


unoconv -f pdf slides.ppt

Friday, August 12, 2011

Books


Tonight I was home alone with my kid. Fortunetly for us (the kid and me) our PC is connected to the TV set. So, he watched his favorites DVDs, while I had Google Reader in play mode with slide show enabled and side by side windows.

After playing the DVDs a dozen times, Google Reader showed this e-book post.

PostgreSQL is my database of choice, so this book will be very appreciated.

The PostgreSQL e-book is at:

Mac OS X in Linux via VirtualBox (as guest OS)

That is some thing I want to do for quite some time:

Install Mac OS X Snow Leopard as a guest OS in a VirtualBox Linux host

http://martinml.com/en/how-to-install-mac-os-x-snow-leopard-in-virtualbox/

http://blog.nguyenvq.com/2010/12/04/mac-os-x-in-linux-via-virtualbox-as-guest-os/

http://myhack.sojugarden.com/guide/

Tuesday, August 9, 2011

JavaScript Pie charts


Considering the "Warning against using pie charts", I'm needing to produce a couple of jquery/json ajax enabled piecharts within a simple webapp I'm designing.

There are some sort of ready to use examples:

Using various javascript libraries to create pie chart

JavaScript charts | Pie charts

Monday, August 1, 2011

dd over ssh

Just to make some backups:


dd if=/dev/sda1 | gzip -c | ssh filipi@10.30.46.11 'dd of=/opt/backups/big/filipi/disk.image.gz'

Flash Calendar V2.0 to iCal

The organization where I work uses a Flash Calendar to show holidays, special day activities and other public calendar. The Flash Calendar loads its events from a XML file which, in our case, is keeped really up to date. So I was willing to view those events on my Google Calendar screen, to better plan my meatings and so on.

After that, I had written a small wrapper to parse the XML and echo iCal output. It still not fully compatible with Flash Calendar XML, but for the uses of my organization is enougth.

I did put it on github.