: ) wonderful world ( :

the metasyntactic variable

Archive for April 2008

useful key shortcuts on ubuntu

without comments

I’m evil sometimes ; )

As a first scenario, I wanted to save some pages of a book provided by a flash site. This site hides the pages once seen because of copyrigth issues. I had to create a bunch of screenshots : ) I also wanted to minimize clicks or key strokes to use during a screenshot.

On ubuntu, start up ‘gconf-editor’ from a terminal. Go to path ‘apps/metacity/keybinding_commands/command_1′. Place there ‘/somepath/sshot.sh’. Content of that is like this:

afroid-laptop% cat sshot.sh
import -window root -quality 90 /pathtoscreenshotscollection/`date +%Y%m%d%H%M%S`.png
afroid-laptop%

Later on, under ‘global_keybindings/command_1′, insert the string e.g. ‘<Alt>T’.

Obviously you can change names and bindings as it’s appropriate for you.

Next one is to get descriptions for words form a dictionary.
Command to place is: ‘firefox “http://pewebdic2.cw.idm.fr/popup/popupmode.html?search_str=”`xsel`’.
Of course you have to install the xsel package before usage. Later you only select the word with your mouse and press F8 for example and a page appears with the word from that dictionary…

Written by grault

April 27, 2008 - 9:39 pm at April 27, 2008 - 9:39 pm

Posted in command line, linux

two weeks tobacco (new series)

without comments

After a session with already known brands, I ordered again a new pack with big variety of brands (12 of them). The first two portion was parallelly consumed.

Kinda first was Montecristo which is very similar to Romeo y Julieta. These two don’t contain too much water, but they aren’t in the white snus category. Balanced taste, equally distributed dose of nicotine. Bit too expensive, worths a try though.

Kinda second was the Strong Wise. It’s white for sure and advertised with the fact that it is purified from "nitrosamines that can cause cancer". This purification ends up with white powder in portions. I don’t know what to say to the staff on an airport if they ask me about that during check in. This portion somehow gives you a big shot at the beginning as far as I felt. I give it only two stars out of five.

Written by grault

April 19, 2008 - 3:17 pm at April 19, 2008 - 3:17 pm

Posted in tobacco

explanation of previous (part II)

without comments

We ended up with two numbers, 0 and 181. I won’t use the commands producing them, instead simulate them with

afroid-laptop% ( echo 0; echo 181 )
0
181
afroid-laptop%

First of all they’ll go through a loop by which the programmer (me) can transform them into things with a greater benefit. Here we go with a zsh (linux shell’s name I work with) loop which just simply repeat the incoming lines.

afroid-laptop% ( echo 0; echo 181 ) | while read i; do echo $i; done
0
181
afroid-laptop%

In a .cue file these numbers are needed in a minute:second:10th-second format (see my previous article about .cue format).

afroid-laptop% ( echo 0; echo 181 ) | while read i; do echo \ \ INDEX 01 `echo $
i "60 ~ sn p" | dc`:`echo $i "60 ~ p" | dc`:0 ; done
  INDEX 01 0:0:0
  INDEX 01 3:1:0
afroid-laptop%

This have to be surrounded with additional and mandatory informational fields about author and title and the like. Also, I introduce increasing numbers for tracks. Pharenteses are for running stuff in a subshell ((the doubled one is the arithmetic syntactic sugar of zsh)).

afroid-laptop% ( echo 0; echo 181 ) | ( x=1; while read i; do echo \ TRACK $x AUDIO;
 echo \ \ TITLE \"x$x\"; echo \ \ PERFORMER \"x\"; echo \ \ INDEX 01 `echo $i "60
 ~ sn p" | dc`:`echo $i "60 ~ p" | dc`:0 ; (( x = x + 1 )) ; done )
 TRACK 1 AUDIO
  TITLE "x1"
  PERFORMER "x"
  INDEX 01 0:0:0
 TRACK 2 AUDIO
  TITLE "x2"
  PERFORMER "x"
  INDEX 01 3:1:0
afroid-laptop%

.cue files have headers, so a header should be inserted

afroid-laptop% ( echo 0; echo 181 ) | ( echo TITLE \"x\"; echo PERFORMER\"x\";
echo FILE \"file.mp3\" MP3; x=1; while read i; do echo \ TRACK $x AUDIO; echo
\ \ TITLE \"x$x\"; echo \ \ PERFORMER \"x\"; echo \ \ INDEX 01 `echo $i "60
~ sn p" | dc`:`echo $i "60 ~ p" | dc`:0 ; (( x = x + 1 )) ; done )
TITLE "x"
PERFORMER "x"
FILE "file.mp3" MP3
 TRACK 1 AUDIO
  TITLE "x1"
  PERFORMER "x"
  INDEX 01 0:0:0
 TRACK 2 AUDIO
  TITLE "x2"
  PERFORMER "x"
  INDEX 01 3:1:0
afroid-laptop%

The next step is an ugly solution of padding the appearing numbers to length 2 with zeros using some sed magic.

afroid-laptop% ( echo 0; echo 181 ) | ( echo TITLE \"x\"; echo PERFORMER\"x\"; e
cho FILE \"file.mp3\" MP3; x=1; while read i; do echo \ TRACK $x AUDIO; echo \ \
 TITLE \"x$x\"; echo \ \ PERFORMER \"x\"; echo \ \ INDEX 01 `echo $i "60 ~ sn p"
 | dc`:`echo $i "60 ~ p" | dc`:0 ; (( x = x + 1 )) ; done ) | sed -e 's/"x\([0-9
]\)"/"x0\1"/' | sed -e 's/\ \([0-9]\):/ 0\1:/' | sed -e 's/:\([0-9]\):/:0\1:/' |
 sed -e 's/:\([0-9]\)$/:0\1/' | sed -e 's/TRACK\ \([0-9]\) /TRACK 0\1 /'
TITLE "x"
PERFORMER"x"
FILE "file.mp3" MP3
 TRACK 01 AUDIO
  TITLE "x01"
  PERFORMER "x"
  INDEX 01 00:00:00
 TRACK 02 AUDIO
  TITLE "x02"
  PERFORMER "x"
  INDEX 01 03:01:00
afroid-laptop%

As you can see in the original post, I redirect this to a file, because I wasn’t able to find a way by which mp3splt eats the .cue file from standard input. The && is a statement sequence operator in zsh (and in many other shells (e.g. in cmd.exe as well)) where the second command is executed only if the first was successful.

mp3splt -c /tmp/splitter.cue file.mp3 -o @t

Dash o describes the format of output files and t is for title. So the generated files will have names like x01, x02 and so on.

Written by grault

April 4, 2008 - 8:39 pm at April 4, 2008 - 8:39 pm

Posted in command line, linux