"; */ ?>


06
Apr 07

Amazing Virtual Piano and Drumkit – Let’s Jam!

Thought for a while about creating a virtual band? Well, then you’ll need these virtual instruments :)

Once in a while my friends need to get something from these huge stores stuffed with electronics. So they drag me along to help them review whatever it is they are after. Since most of the time I buy that kind of stuff online, I quickly get bored walking down those isles, and stop at the one with all these cool pianos (keyboards). There I spent most of my time practicing, while my friends are looking for stuff.

Recently I was googling for something and found Colin’s blog, which had a cool link to this amazing virtual piano with several different modes: organ, saxophone, drums, flute, guitar, strings, bass, etc.

 

online virtual piano

Then I went further and found this great virtual drumkit which probably requires a real mouse, but gives a very realistic feeling:

online virtual drumkit

There are many more cool virtual instruments out there, so feel free to expand this list by adding more links.

Let’s get to jamming people!


05
Apr 07

Music Video Clip of the day: Queen “Bohemian Rhapsody”

Bohemian Rhapsody” is a song written by Freddie Mercury, originally recorded by the band Queen for their 1975 album A Night at the Opera. The song is in the style of a rock opera, and has a very unusual musical structure for a piece of popular music. Its six different sections have no chorus but both a cappella and heavy metal arrangements. Despite this, it was released as a single and became a huge commercial success, marking a decisive point in Queen’s career and setting them on the way to become one of the world’s most popular bands. The single was accompanied by what is generally cited as a groundbreaking “promotional video”, which helped establish the visual language of the modern music video. The song was included in all of Queen’s subsequent live concert performances and still enjoys great popularity all over the world.


04
Apr 07

SED to parse and modify XML element nodes

In one of my previous articles I showed how AWK can be used to get a very useful statistic from server log. Today I want to introduce my other friend – SED, which will help us to modify values of element nodes within an XML file.

Here is a little info on SED from wikipedia:

sed (which stands for Stream EDitor) is a simple and powerful computer program used to apply various textual transformations to a sequential stream of text data. It reads input files line by line, applying the operation which has been specified via the command line (or the sed script), and then finally outputs the line. It was originally developed from 1973 to 1974 as a Unix utility by Lee E. McMahon of Bell Labs, but today sed is now available for Unix (BSD, Mac OS X), Linux, and Win32, as well as many other platforms.

Ok, let’s see what is given. By complete accident we have an access to an XML request (file) from Yanik’s bank (ING), that performs a transfer of $1,000,000.00 dollars to his account today in exactly one hour. Here is what the request looks like (goodnews.xml):

<?xml version="1.0" encoding="ISO-8859-1"?>
<goodnews>
 
      <to>Yanik</to>
      <from>ING Bank</from>
      <date>04/01/2007</date>
      <amount>$1,000,000.00</amount>
      <account>0024549Y48K3-843</account>
      <message>We are pleased to inform you that the above amount was transferred to your bank account</message>
 
</goodnews>

Now, what if we could just made a slight change to this request, and become a receiver of that million dollars – would not that be cool!? Well, I am not asking Yanik here, for an obvious reason… The answer is – yes, it’d be cool and SED can help us archive our goal. Here is how.

Below, I wrote a small shell script that will be using SED. The script will take three parameters from a command line:

    “xml filename”, “element name” and “new value”

Then it will extract the value from the “element name”, and substitute it with a “new value” – that’s it – that is how simple it is. Does it smell like a million dollars already? :)

Here is the code (relement.sh):

# Check that exactly 3 values were passed in
if [ $# -ne 3 ]; then
echo 1>&2 “This script replaces xml element’s value with the one provided as a command parameter \n\n\tUsage: $0 <xml filename> <element name> <new value>exit 127
fi
 
echo "DEBUG: Starting... [Ok]\n"
echo "DEBUG: searching $1 for tagname <$2> and replacing its value with '$3'"
 
# Creating a temporary file for sed to write the changes to
temp_file="repl.temp"
 
# Elegance is the key -> adding an empty last line for Mr. “sed” to pick up
echo ” ” >> $1
 
# Extracting the value from the <$2> element
el_value=`grep<$2>.*<.$2>$1 | sed -e “s/^.*<$2/<$2/| cut -f2 -d”>| cut -f1 -d”<`
 
echo "DEBUG: Found the current value for the element <$2> - '$el_value'"
 
# Replacing elemen’s value with $3
sed -e “s/<$2>$el_value<\/$2>/<$2>$3<\/$2>/g” $1 > $temp_file
 
# Writing our changes back to the original file ($1)
chmod 666 $1
mv $temp_file $1

Let’s run it now and get that million dollars, that we are after:

[me at server]~: ./relement.sh goodnews.xml account my-secure-account
DEBUG: Starting... [Ok]
 
DEBUG: searching goodnews.xml for tagname <account> and replacing its value with 'my-secure-account'
DEBUG: Found the current value for the element <account> - '0024549Y48K3-843'
DEBUG: <account>0024549Y48K3-843</account> was successfully changed to <account>my-secure-account</account>
 
DEBUG: Exiting... [Ok]
 
[me at server]~: cat goodnews.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<goodnews>
 
      <to>Yanik</to>
      <from>ING Bank</from>
      <date>04/01/2007</date>
      <amount>$1,000,000.00</amount>
      <account>my-secure-account</account>
      <message>We are pleased to inform you that the above amount was transferred to your bank account</message>
 
</goodnews>

Now we are getting all the money and not Yanik (well it is MY-secure-account, so technically I get it :) ).

Here is the nitty-gritty details of how that financial operation was possible…

Of course, the heart of this script is this line:

el_value=`grep "<$2>.*<.$2>" $1 | sed -e "s/^.*<$2/<$2/" | cut -f2 -d">"| cut -f1 -d"<"`

And here is what happens here:

    1. We grep “<element>whatever</element>” from the file ($1)

    2. Then we apply sed to search to ignore everything from the beginning of the line to the “<element”

    3. And finally we cut the value of this element which is located in between greater and less signs “>value<“

Easy, right?

Now let us look at this line:

sed -e "s/<$2>$el_value<\/$2>/<$2>$3<\/$2>/g" $1 > $temp_file

which uses sed’ (or vi’s) ‘s/search/replace/g” pattern to do the job – to replace all the “<element>oldvalue</element>” to “<element>newvalue</element>”. After that it saves it in a temp file, before replacing the original file.

The line

echo " " >> $1

makes sure that the source file has an empty last line, so sed can identify the “end of file” correctly

There is also one thing to mention – if you export Microsoft (e.g. M$ Word) document to XML, in order to change anything (properties) there, add these lines:

sed -e "s/<w:t>$el_value</<w:t>$3</g" $1 > $temp_file
chmod 666 $1
mv $temp_file $1

it will change all the corresponding elements to the property you need to change.

Now we are completely empowered! Quit your job – learn SED, and earn millions! No.. rather – billions!

Feel free to ask questions or leave comments.


04
Apr 07

Music Video Clip of the day: Guns N’Roses “Don’t Cry”

Don’t Cry” is a song by Guns N’ Roses, two versions of which were released simultaneously on different albums. The version with the original lyrics is the fourth track on Use Your Illusion I; the version with the alternate lyrics is the thirteenth track on Use Your Illusion II. Only the vocal tracks differ, and even then only in the verses; however, in those verses, not only are the words entirely different, but the meter and melody are also slightly different.


02
Apr 07

The big heart of the “Reign over me”

  Movies that were coming from the other side of the planet (US) in late 80s beginning of 90s were not kind of movies that would flow together with your feelings, or open up your mind widely, they were rather: “Cobra”, “Comando”, “Bloodsport” etc.. – not that many Hollywood movies were translated to Russian and available for the general audience (USSR) to watch. So we were not too spoiled with Hollywood classics, so to speak..

  Later on, in mid 90s, when I first saw “Billy Madison”, “Happy Gilmore” and, then later on, “The Waterboy”, they were translated so poorly, that seemed extremely dull and stupid – and that was my take on Adam Sandler, and that what I took with me to the 21st century…

  Things have changed a lot when “Hollywood doors” opened up to a boundless flow of thousands of new and old movies from US to the former USSR, and, of course, when I got to know English a little better.
  I watched movie after movie, and little by little everything started to make sense – I learned to see and appreciate the beauty that was always there, that before I’ve never got a chance to see, or the language to understand. That was phenomenal! (well, for me it was).

  And I did re-discovered Adam Sandler and his work, it finally got to me after a decade. “The Wedding Singer”, “Big Daddy”, “Mr. Deeds”, “Spanglish” – they all “appeared naked” in front of me, and I could feel their kindness, sincerity, and a big and honest heart!

    picture is taken from rottentomatoes
Reign Over Me '2007

  “Reign over me” shows Adam in slightly different angle. While his character (Charlie Fineman) is sort of a combination of “Punch-Drunk Love”, “Big Daddy” and “Mr.Deeds”, it reveals a new inner perception of the world around him. In the movie Charlie “pairs up” with a successful dentist, his former college roommate, Alan Johnson (Don Cheadle), which creates a bridge between Charlie’s insularity and Alan’s overall life unhappiness. During the movie Alan is trying to help Charlie get through an awful tragedy that lives inside Charlie’s mind and soaked with his whole essence. By helping him, Alan comes to realize that Charlie, in spite of his problems has something that such successful dentist as himself does not have – Charlie is free!

  Movie is witty, funny and very sad at the same time. It has this unbelievable power, when you’re watching it, you know it is long, but every 5 minutes, closer to the end, you are alert and constantly worried that it is going to end, when you really want it to be “just a little longer”.

  As most of the previous work of Adam Sandler “Reign over me” has a big, kind and honest heart! There are certain people in our world who have this unique talent, and are able to see and feel “This Heart” – others just go to see comedy or call themselves “critics”.