For my thesis I've to produce plot of a lot of data. These plot are fairly simple: basically I have a set of points and I simply need to plot them in various styles. The data is taken from a text file containing the outputs of various simulations.
First attempt was python + gnuplot. It worked, by I wasn't satisfied. Then i discover matplotlib, a python plotting library. It does everything I need (actually a lot more than what I need) and it's in python... that is: integrate it into my parsing/manipulating script it's flawless.
In a few minutes I've managed to write a script that parses the data... manipulates it in the way I need (average/variation calculation and stuff like that), plots it, saves the plots in eps and in the end produces a latex file which shows all the generated plot.
I already was a fan of the coding speed of python. Now I've found another thing that make it even more appealing to me.
Sunday, June 08, 2008
OpenSolaris upgrade & Boot Environment
I finally did an "image-update" of my OpenSolaris2008.05 installation. The process was a little slow (especially in the "generating plan" part) but otherwise effortless on my side.
Anyway some gigabyte of download later I had my OpenSolaris 2008.05 updated to svn90. The output tells me a new BE was created (like I knew what a BE is!) and it tells me to reboot when ready to use it.
To make a long story short booting using the new GRUB entry didn't work so well. The computer started the boot process but silently rebooted. So I begun to suspect something wasn't going that well as I thought. Rebooted in the old Boot Environment and did a little googling and here's what I found:
Did that and finally I was able to boot using the new Boot Environment. Cool!
I've had to spend some time studying this... uhm... well I'll add it to the list of
things to check out.
Anyway some gigabyte of download later I had my OpenSolaris 2008.05 updated to svn90. The output tells me a new BE was created (like I knew what a BE is!) and it tells me to reboot when ready to use it.
To make a long story short booting using the new GRUB entry didn't work so well. The computer started the boot process but silently rebooted. So I begun to suspect something wasn't going that well as I thought. Rebooted in the old Boot Environment and did a little googling and here's what I found:
Instructions to update OpenSolaris 2008.05 to build 89 or later
================================================================
The command "pkg image-update" can be used to update an OpenSolaris
2008.05 system to build 89 or later. However due to changes in the
GRUB boot system, one must manually update the Master Boot Record (MBR)
to include these latest changes.
When "pkg image-update" completes successfully, it will print a message
of the form
A clone of opensolaris exists and has been updated and
activated. On next boot the Boot Environment opensolaris-1 will
be mounted on '/'. Reboot when ready to switch to this updated
BE.
The name of the newly created clone can also be seen by looking for the
"Active on reboot" entry in the output of the "beadm list" command
$ beadm list
BE Active Active on Mountpoint Space
Name reboot Used
---- ------ --------- ---------- -----
opensolaris-1 no yes - 17.06M
opensolaris yes no - 33.92M
First, mount the clone under the /mnt directory
$ pfexec mount -F zfs rpool/ROOT/opensolaris-1 /mnt
Next, update the GRUB configuration on your ZFS boot device(s) using
$ pfexec /mnt/boot/solaris/bin/update_grub -R /mnt
When you're ready to boot into the updated boot environment, you can
reboot(1M) or init(1M) as usual.
Did that and finally I was able to boot using the new Boot Environment. Cool!
I've had to spend some time studying this... uhm... well I'll add it to the list of
things to check out.
Tuesday, February 19, 2008
Macosx resize partition
A great feature of macosx 10.5 (leopard) that I discover only yesterday (just after having done damages!) is the ability to resize a hfs+ journaled partition on the fly. This means you don't have to boot from the install cd. All you need to do is open DiskUtility. Select the disk you want to modify, go to the Partition tab and simply adjust the partitions size. Awesome!
I found out this features becouse my System volume was almost full but I had a lot of free space on my user volume (BTW: partitions are evil! Long live to ZFS).
So the next time I'll have to modify the space allocation on my disk I'll just backup important data and let DiskUtility do the job.
Friday, February 15, 2008
Mercurial repository @ SourceForge
Today I set up 2 mercurial repositories on sourceforge.net for my project jMmsLib.
It's been quite easy... I basically followed this simple howto and all went straight once I solved one little problem.
Thought the howto state that you have to put you hg distribution inside your project directory, I decided to put it in my user home directory and make a symbolic link in the project home. So at the moment of trying the cgi page I get a python error. It was telling me that it couldn't find a module that was inside the hg distribution.
At first I thought I had messed up the path in the cgi script, so I checked, but all seemed right to me. So I tried to set the path to the hg distribution in the mutt prject home. This time it worked.
Mmm... So thinking the problem was in my hg distribution (maybe a corrupted one!) I substitute it with the one from mutt (always putting it in my user home directory). But still it didn't work...
To make a long story short, the problem was apache (or at least I think it was apache) refuses to include a python module outside the file system portion devoted to projects. So I had to move the hg distribution from my user home to my project home and after all worked like a charm.
Thinking about it now, it is a normal security policy. I wonder why I didn't thought it from the first moment. Besides that, I hope SF will support mercurial soon or later!
It's been quite easy... I basically followed this simple howto and all went straight once I solved one little problem.
Thought the howto state that you have to put you hg distribution inside your project directory, I decided to put it in my user home directory and make a symbolic link in the project home. So at the moment of trying the cgi page I get a python error. It was telling me that it couldn't find a module that was inside the hg distribution.
At first I thought I had messed up the path in the cgi script, so I checked, but all seemed right to me. So I tried to set the path to the hg distribution in the mutt prject home. This time it worked.
Mmm... So thinking the problem was in my hg distribution (maybe a corrupted one!) I substitute it with the one from mutt (always putting it in my user home directory). But still it didn't work...
To make a long story short, the problem was apache (or at least I think it was apache) refuses to include a python module outside the file system portion devoted to projects. So I had to move the hg distribution from my user home to my project home and after all worked like a charm.
Thinking about it now, it is a normal security policy. I wonder why I didn't thought it from the first moment. Besides that, I hope SF will support mercurial soon or later!
Tuesday, February 12, 2008
Latex: lstlistings pseudo language
For my thesis I need to display a lot of algorithm to document the actions taken by peers talking a specific protocol. Since the thesis should present a theoretical view of the protocol itself and the algorithms, I do not want to display them in a specific language. I do want to use a pseudo language. Also I want the keyword of the language to be highlighted to ease the reading.
Here's the definition of my pseudo language to be used with lstlistings latex package:
This is an example of what your listing will look like:
Here's the definition of my pseudo language to be used with lstlistings latex package:
\lstdefinelanguage{pseudo}{
morekeywords={if, else, for, in, remove, from, case, do, forever, to, False, True},
sensitive=true,%
morecomment=[l]\#,%
morestring=[b]',%
}
\lstset{language=pseudo}
\lstset{commentstyle=\textit}
\lstset{literate=
{<=} {$\le$}{2} {!=} {$\neq$}{2} {=} {$\leftarrow$}{2} {==} {=}{2} {&&} {$\cap$}{2} {||} {$\cup$}{2} }
This is an example of what your listing will look like:
Monday, February 11, 2008
Gmail IMAP backup
Today I decided to try out Gmail IMAP. Untill today I downloaded mail via POP from gmail and keep them in my home IMAP server. This way I was able to use thunderbird and have my mail synched on all my computers. Now that gmail offer an integrated imap server I decided to switch to that so I'll able to use also gmail web interface and have all synched (before I used to use OverLook that's quite useful, but really slow... at least on my small home server).
In the end now all my mail reside on gmail and I have no local copy (except for thunderbird local file...). I want to keep a local copy of the gmail account to be able to recover from loss of data by google. Also I want it to be synched daily.
Well, the first solution I thought is imapsync.
Here's how to backup a gmail account with it:
In the end now all my mail reside on gmail and I have no local copy (except for thunderbird local file...). I want to keep a local copy of the gmail account to be able to recover from loss of data by google. Also I want it to be synched daily.
Well, the first solution I thought is imapsync.
Here's how to backup a gmail account with it:
imapsync --host1 imap.gmail.com --ssl1 --user1 user@gmail.com \
--password1 gmailPass --host2 local --user2 user@local \
--password2 localPass --prefix2 INBOX.gmail-backup. \
--authuser1 user@gmail.com --authmech1 LOGIN \
--authmech2 LOGIN --syncinternaldates
A more secure way is to put the passwords in 2 file and use --passfile1 and --passfile2.
Latex: listings side by side
Here's how to display two listings side by side in a figure using the subfig and lstlistings packages.
First, put the code you want to display in 2 files (say a and b). Then do the following:
This way you obtain the listing side by side. The only issue is that their vertical align is centered. So if the height of the two listings is not the same, the short one is not vertically aligned to the long one.
One way to solve this issue is to use \raisebox{xxpt}{\subfloat[...]{...}} where xx is how much points you want to raise the listing. Anyway I found the result not good enough.
Googling a little bit I found something on the faq section of subfig'sdocumentation. Here it is:
First, put the code you want to display in 2 files (say a and b). Then do the following:
\begin{figure}
\subfloat[subcaption 1]{\lstinputlisting{a}}
\hspace{20pt}
\subfloat[subcaption 2]{\lstinputlisting{b}}
\caption{Global caption}
\end{figure}
This way you obtain the listing side by side. The only issue is that their vertical align is centered. So if the height of the two listings is not the same, the short one is not vertically aligned to the long one.
One way to solve this issue is to use \raisebox{xxpt}{\subfloat[...]{...}} where xx is how much points you want to raise the listing. Anyway I found the result not good enough.
Googling a little bit I found something on the faq section of subfig'sdocumentation. Here it is:
I tried (not that hard to be honest), but I wasn't able to align both figure to the top. After all I think I'll keep the center valign...
6.1 "My sub-floats are not aligned along their bottoms. Why?"
Remember! The subfig package aligns sub-floats along their baselines with the sub- caption (if any) sticking out above or below. The above problem is usually due to using a minipage, tabular or array environment that, by default, places the baseline at the center of the box that it generates. If the two sub-floats are different sizes, or if onesub-float is generated in some other way with its baseline not at the expected place (perhaps an \includegraphics), then the sub-float will be misaligned. One solution is to use the environment options `[t]' or `[b]' to move the baseline to the top or bottom rather than the center.
Thursday, February 07, 2008
CVS to Mercurial
This week I finally tried out Mercurial.
Having used only CVS before, I found this VCS simply amazing.
It's really simple to use and also to learn. Useless to say I decided
to move all my projects from CVS to mercurial.
After searching a while on the net I found some alternatives:
Mercurial ConvertExtension is shipped with mercurial 0.95 so I decided to
use this but probably Tailor is the most flexible of all. Surely it deserve
a try.
Anyhow, the documentation on the ConvertExtension wiki page is just non
existent and the online help of mercurial does not helped me a lot.
So here's how to convert a CVS module:
First of all checkout the module you want to convert as usual.
Let's say myproject is the checked out module, then do the following in
the directory containing the module:
Now mercurial convert CVS commits to changesets and in the end it creates
a .hgtags file containing the mapping between CVS releases and mercurial
changesets.
Here it is. Now your module is ready to be used with mercurial. Just to see
if all is ok:
Having used only CVS before, I found this VCS simply amazing.
It's really simple to use and also to learn. Useless to say I decided
to move all my projects from CVS to mercurial.
After searching a while on the net I found some alternatives:
Mercurial ConvertExtension is shipped with mercurial 0.95 so I decided to
use this but probably Tailor is the most flexible of all. Surely it deserve
a try.
Anyhow, the documentation on the ConvertExtension wiki page is just non
existent and the online help of mercurial does not helped me a lot.
So here's how to convert a CVS module:
First of all checkout the module you want to convert as usual.
Let's say myproject is the checked out module, then do the following in
the directory containing the module:
$ hg convert myproject/
assuming destination myproject-hg
initializing destination myproject-hg repository
connecting to :ext:user@cvs.example.com:/cvsroot
scanning source...
sorting...
converting...
Now mercurial convert CVS commits to changesets and in the end it creates
a .hgtags file containing the mapping between CVS releases and mercurial
changesets.
Here it is. Now your module is ready to be used with mercurial. Just to see
if all is ok:
$ cd myproject-hgAnd you should see all you CVS history.
$ hg log
Tuesday, February 05, 2008
Send MMS
Some months ago I've had to write a simple software for sending MMS. Before that moment, my knowledge of MMS or WAP was very limited. Indeed my mobile phone do not even supports MMS... (or color to be honest).
So I've start to search the internet for some documentation regarding MMS and how to send them through a GPRS connection. Unfortunately there's not so much documentation on these matters. In the end I figured out that I could use jWAP to send the binary MMS message to the MMSC of the provider. The last problem was how to build a binary MMS. The only Java library I found capable of encoding a binary MMS was "MMS Java Library" from Nokia. The first problem with this libarry was the download (for some reason, it's not downloadable from the Nokia web site anymore and I had to search for it a lot to find a copy). The second problem was the license that wasn't so clear (the only thing I found it's a post on the Nokia forum where it's said you cand modify if freely).
So after all I decided it was a better idea to write a simple library to encode MMS messages. Fortunately the specification avaiable at Open Mobile Alliance are quite detailed. The only problematic thing is to find the informations you need in all those pdf files.
In the end the results of this work are avaiable here. You'll find the library for encoding and decoding MMS and a simple client to send them trough a WAP gateway. At the moment the library is quite simple, it supports encoding of send_req messages and decoding of send_conf ones only. Also it does supports only image and text parts. In the future it's possible that new features will be added.
Anyway if someone is searching information on how to send MMS take a look at the sources of SendMMS (a total of 3 classes with one being an Exception and one a container).
If you want details on how to encode a MMS message take a look at the sources of jMmsLib, they are quite simple to read and understand.
So I've start to search the internet for some documentation regarding MMS and how to send them through a GPRS connection. Unfortunately there's not so much documentation on these matters. In the end I figured out that I could use jWAP to send the binary MMS message to the MMSC of the provider. The last problem was how to build a binary MMS. The only Java library I found capable of encoding a binary MMS was "MMS Java Library" from Nokia. The first problem with this libarry was the download (for some reason, it's not downloadable from the Nokia web site anymore and I had to search for it a lot to find a copy). The second problem was the license that wasn't so clear (the only thing I found it's a post on the Nokia forum where it's said you cand modify if freely).
So after all I decided it was a better idea to write a simple library to encode MMS messages. Fortunately the specification avaiable at Open Mobile Alliance are quite detailed. The only problematic thing is to find the informations you need in all those pdf files.
In the end the results of this work are avaiable here. You'll find the library for encoding and decoding MMS and a simple client to send them trough a WAP gateway. At the moment the library is quite simple, it supports encoding of send_req messages and decoding of send_conf ones only. Also it does supports only image and text parts. In the future it's possible that new features will be added.
Anyway if someone is searching information on how to send MMS take a look at the sources of SendMMS (a total of 3 classes with one being an Exception and one a container).
If you want details on how to encode a MMS message take a look at the sources of jMmsLib, they are quite simple to read and understand.
Subscribe to:
Posts (Atom)