Michal Hrušecký

...about me, Linux and OpenSource

June 2010

Car consumption script

About a week ago I was at LinuxTag spreading a word about openSUSE. It was great event and I really liked it. And I was on of the four lucky guys that won Googles Nexus One. Hurray! And now what I want to write today about... I was migrating all my stuff from my Palm Centro to Nexus One. And one of the things I was using my Centro for was tracking how much petrol does my car consume. I was writing in plain text file and I was thinking about writing some script around that... But never had the time to actually do that. But now with Nexus One, my log is synchronized with Google Docs. So I don't have to take care of the synchronization part. So I sat down and wrote a simple script to compute my cars consumption and I want to share it with you. Originaly I wanted to use googlecl, which is available in openSUSE Contrib, but it had some problems with Google Apps, so I decided to use curl instead.

First of all how do I structure my log. I've got currently two types of things I'm tracking - petrol and maintenance. As we are talking about consumption, we are interested only in petrol ones face-wink.png These lines looks like this:

PET:97644:20100430:12.53l:394.4Kč

As you see, it's in semicolon separated values format face-smile-big.png First field means that it's petrol entry. Second one is kilometer counter. Third one is the date %Y%m%d and the fourth one is the number of liters. Fourth one is the price, but it's not really important. My document is named "Auto" but if you want to use the same script, you can name it however you want and just change the $TITLE variable in the script. You'll need to change email and password anyway face-wink.png And you might be also interested in changing $RECENT variable, which states how many entries are used in computation.

Script

openSUSE Paste

openSUSE PasteDo you also feel that Hackweek is nearby? So many people will be working together on so many interesting stuff. And when you are working in large groups around the world, sometimes you need to talk about code snippets. And then you use something like pastebin.com. But there are many similar services on the web. And I already encounter on openSUSE IRC people using for example fpaste.org. So why don't we have some paste thing to show that we are the openSUSE guys and girls? My guess is that nobody cared enough to create other one then opensuse.pastebin.com. But I was part of the Umbrella team, so I want to have everything nicely integrated... So here I come with openSUSE Paste.

It is basically Open Source software called Stikked. I just downloaded it, configured it and make it fit to our Bento theme. Currently it is hosted on my webserver only, but I'll try to get some nice opensuse.org name for it. I'll also publish source code adapted to Bento theme once I figure out how to create a repository on gitorious.org face-smile-big.png

Just one nice tip at the end. If you want to use it frequently, add following to your .profile

SUSEPASTE='curl -v -F "code=<-" -F "name=`whoami`" '
SUSEPASTE="$SUSEPASTE -F \"submit=submit\" -F \"lang=text\" "
SUSEPASTE="$SUSEPASTE http://paste.michal.hrusecky.net "
SUSEPASTE="$SUSEPASTE 2>&1 | grep Location "
alias susepaste="$SUSEPASTE"

Then you can use it like this:

$ dmesg | susepaste
< Location: http://paste.michal.hrusecky.net/index.php/view/33355419

So try it, play with it, and any comments are welcome (and once I publish the code, contributions too)

openSUSE Paste

UPDATE: Public git repository with sources available on http://gitorious.org/opensuse/paste

openSUSE Conference 2010

Identica

  • Last ride in the driving school on Wednesday, then the exams on Monday, I wonder whether I'll make it...
    4 days ago :: link
  • Did you knew that all ducks are wearing dog mask? http://i.imgur.com/XSVIy.jpg
    18 days ago :: link
  • Firt ride in the driving school. No crush, kill or destroy so I guess it's going well so far :-D
    18 days ago :: link
  • Already at #frosconn preparing for !openSUSE Connect hacking session!
    20 days ago :: link
  • Are you interested in !openSUSE Connect? Join us at #froscon! http://bit.ly/dDdKIp
    23 days ago :: link

Ohloh Journal for Michal Hrušecký

  • Working on Affisix slides for ITAT2010. Got frist slide with caption and one from the middle of the slideshow. The rest is still only in my TODO ;-)
    21 hours ago :: link
  • Finally pushed Affisix version that supports variables in the way I'm satisfied with. Time to get back to the documentation fixing ;-)
    11 days ago :: link
  • Article about Affisix was acceptet for ITAT 2010! Time to fix everything that reviewers complained about!
    78 days ago :: link
  • Abstract for ITAT2020 about Affisix sent, working on the article now...
    108 days ago :: link
  • Just commited basit filter mode support to the Affisix repository. It is still missing a lot of features, but the basics are already there!
    134 days ago :: link

Emblems

Powered By Jaws Project
Supports RSS2
Supports Atom
Powered By openSUSE
Powered By Vim
Is Valid XHTML
Is Valid CSS
Is Valid RSS2