pkgsrc and Catalyst
Well, I maintaining alot of the Catalyst related Perl packages inside the pkgsrc tree and keep them up-to-date. I was looking for a webframework sometime ago and I found Catalyst. Catalyst is a very nice MVC webframework which is fully 2.0 compliant (don't cry BINGO now). They had a nice idea - they are running a small calendar for advent and I decided to write an article for it. Explore the worlds of modern art of Perl - go Catalyst! References:
written by: Ulrich Habel (rhaen)
10/19/2008Time for Rockbox and Perl graphing
Wheeew, I was on holiday and thanks to FLOSS Weekly I decided to install
Rockbox on my iPod right before I left. It's quite amazing what these
guys reverse engineered and how well the support for the Apple iPod is.
I own a 30gb iPod video device - nothing really fancy, however I wanted
to have a look on it. No clue what I am talking about? Rockbox is an
alternative firmware for your MP3 player. You'll just update your iPod to
Rockbox and have a whole bunch of new features available. The most
impressive part is the "I-need-no-iTunes" part. Rockbox will find all
the songs on your iPod and builds a tag database out of it. Actually you
can use rsync to sync your music on the iPod. I really like it.
There are also alot of small applications bundled with Rockbox. One of
them is battery_bench. It's writes the current state of your battery
frequently to a textfile on the iPod disk. Do you want to know how long
the battery of your iPod lasts? Here is a way to draw a graph from the
collected data. It's quite simple, charge the iPod until it's fully
charged, play an album in an endless loop and run the battery_bench
tool. After the iPod turned off due to power loss, get the datafile from
the iPod and draw fancy graphs out of it.
I really had some nice feedback about the awk gnuplot thing and I wanted
to introduce you to another gem in our pkgsrc collection. The gem is
called p5-GDGraph. It's a great Perl module to draw graphics out of
data, so let's look into the example of the iPod.
The collected data is stored in a file called battery_bench.txt and looks
like this:
[...] Battery type: 400 mAh Buffer Entries: 1000 Time:, Seconds:, Level:, Time Left:, Voltage[mV]:, C:, S:, U: 02:18:34, 08314, 100%, 11:25, 4223, -, -, - 02:19:34, 08374, 100%, 11:25, 4223, -, -, - 02:20:34, 08434, 100%, 11:25, 4206, -, -, - [...]This structure can be easily caught by Perl. I will read the file line by line, and store the data inside an array. As I wanted to draw a graph out of the time for the x-value and the Voltage for the y-axis, I will put those values into two seperated arrays. After I got all the data from the file, I will build an array of arrays out of the data, this will be passed to p5-GDGraph to draw a nice graph out of it (just like the one in the article).
1.) Get the data out of the file
my $battery_bench = "battery_bench.txt";
my @plot_data;
my @x_data;
my @y_data;
# Pulling the data out of the data file
open DATA, $battery_bench
or die "Can't open file: $battery_bench\n";
while (<DATA>) {
# we don't want the explanation, just the data
if (m/^[0-9]{2}/) {
my $dataline = $_;
$dataline =~ s/\s//g;
my @dataparts = split( /,/, $dataline );
push( @x_data, $dataparts[0] );
push( @y_data, $dataparts[4] );
}
}
close DATA;
After we read the whole file we'll have all the data inside the two
arrays, @x_data and @y_data. You already guessed it, it's the data for the
X and for the Y values. The Perl module however expects the data inside
an array of arrays. The construction of it is quite easy and will be
shown in the next section. 2.) Pass the data to the graphing module GD::Graph::lines
# Setting up the graph
my $graph = GD::Graph::lines->new( 600, 300 );
@plot_data = ( [@x_data], [@y_data] );
$graph->set(
x_label => 'Time played',
y_label => 'Voltage (mV)',
title => 'Voltage graph of my iPod',
transparent => 0,
x_labels_vertical => 1,
x_label_skip => 25,
) or die $graph->error;
my $gd = $graph->plot( \@plot_data ) or die $graph->error;
Voila, you just plotted the first graph out of it. You can use different
output formats to get the actual graph as an image out of the Perl code.
# Write the graph to a file open( IMG, '>battery_bench.png' ) or die $!; binmode IMG; print IMG $gd->png; close IMG;It's a nice way to draw some quick graphs with Perl without messing around with RRD databases. Of course this module is also an excellent way to draw graphs out of iostat, sar and other tools. If you want to draw multiple lines inside a single graph just add another array to the @plot_data. The maintainer of the module inside the pkgsrc packages collection keeps this module always updated. He's already done a great job about it, thanks for keeping it uptodate.
You can find the full example with code and graphs inside the tar.gz file inside the references. References:
- iostat - gnuplot, drawing graphs
- Rockbox - Open Source Jukebox firmware
- Rockbox battery_bench
- CPAN GD::Graph
- pkgsrc.se p5-GDGraph
- FLOSS Weekly - Podcast with Leo Laporte and Randal Schwartz
- battery bench - Perl script and example data
written by: Ulrich Habel (rhaen)
09/13/2008multimedia/ffmpeg-devel - Converting to iPod video
Do you know the ffmpeg-package? It's very useful to convert nearly any kind of video to an iPod compatible video format. Just convert your favorite video from the googletech channel on YouTube to an iPod format and take it with you. That's quite simple. Just take a video you'd like to convert and use the following commandline to convert it:
ffmpeg -i foo.avi -f mov -b 1800 -vcodec mpeg4 -qmin 3 \
-qmax 5 -s 320x180 -acodec libfaac -ab 128 foo.ipod.mov
Please note - this example is for a 16:9 aspect ratio, change the
-s parameter to 320x240 for 4:3 aspect radio.Update:
I was asked if there is a way to detect the resolution of a video file. There certainly is and it's just easy. As we are using ffmpeg to detect the solution we could use it to identify the resolution for us.
ffmpeg -i sample.flv 2>&1 | awk '/Stream/ && /Video/ {gsub(/,/," ");print $6}'
If you want to check the results mplayer is also a handy tool.
mplayer -identify sample.flv -ao null -vo null -frames 0 2>/dev/null | \ grep -E -e '^ID_VIDEO_(WIDTH|HEIGHT)'btw, don't blame me if you Linux box bails out - this is NetBSD land
written by: Ulrich Habel (rhaen)
pbulk - The diff(erence)
Joerg Sonnenberger is the creator of pbulk - a cool tool for running software bulk builds on pkgsrc. I really like it's way to build things, it creates reproducable build results, generates nice reports, I like it. However, a few problems with pbulk, at least for me. I don't like the way the config file pbulk looks like. I usually enjoy preconfigured files with comments. I made a config file which suits my needs perfectly and I am using it on NetBSD 4, NetBSD -current on i386 and for the builds on Sun Solaris 9/sparc.
The patch for it was denied some time ago as it was to restrictive for NetBSD. I worked on it, however I never submitted a new version for it. Anyway, here it is, the diff to the regular pbulk.conf diff. Just apply it, give me feedback about it - enjoy it. For me it's an easy way to set up things, so I put it on the webpage.
cd /usr/pkgsrc ftp -o - -V http://pkgbox.org/Sources/pbulk.conf.diff | patch -p0Please note: I will try to keep this file updated, but maybe there will be a few days until this file is fixed after pbulk changed a few things. It's fine to use this diff for NetBSD and non NetBSD-platforms.
References:
Update
There was an error in the command line a- was missing. Sorry about it
written by: Ulrich Habel (rhaen)
09/04/2008Ready for tomboy (0.11.3)!
Hooray! Do you know tomboy? Well,
ok - tomboy is a small desktop application for the Gnome desktop. It's
just a small sticky notes application. Tomtom is written in Mono and
requires tons of dependencies. But why should someone with a computer
should small sticky notes? You've already guessed it - for writing down
small things that you won't forget. I just read a book about Getting
things done by David Allen. He says everything what's in your mind is an
open loop. Your brain keeps you reminding frequently about these items,
you should write them down. As I am a person who writes alot of stickies
I decided to look for an application which I could use for such purpose.
Tomboy has some really great features for such an idea. It allows you to
link your stickies together. So you can have your project stickies and
write down several task. If you click on the task a new sticky shows you
more about this task. That's great! Of course, there is HTML export,
Evolution support, plugin support, plus plus plus - the feature list is
amazing.
I decided to give tomboy a shot and couldn't find it inside
pkgsrc, not even in wip. So I made my own pkgbox pkg. pkgbox pkgs are my
own personal packages which I make to keep things together. pkgsrc is a
great framework and building a package is usually quite easy. I won't
import it into pkgsrc, neither to wip - take this package as
it-works-for-me package and feel free to use it. Send me some feedback
if it's working for you and if you think that I should import it
somewhere. I am not a mono guy, I don't even understand the problems :)
so, feel free to send me your coments about this.
The homepage
for tomboy is located at Gnome - use this link
Download tomboy 0.11.3 pkgsrc pkg
You'll get a tar.gz archive. Just untar it inside your pkgsrc directory.
It will create a structure like pkgbox/tomboy in it (just like wip).
rhaen@arkanum.pkgbox.org:rhaen $ cd /usr/pkgsrc rhaen@arkanum.pkgbox.org:pkgsrc $ tar xzf ~/tomboy-pkg.tar.gz rhaen@arkanum.pkgbox.org:pkgsrc $ cd pkgbox/tomboy rhaen@arkanum.pkgbox.org:pkgsrc $ make package
written by: Ulrich Habel (rhaen)
