Category Archives: Programming

Beautify SQL code

Recently I had the oportunity to test SQL Pretty Printer (Add-In for SSMS). I don’t have to waste time formatting long sql queries. In no time, SQL Pretty Printer does the job
for me. It can also translate the sql code into C#, Java, Php and many other program languages so I can use it in my own programs.
SQL Pretty printer is designed to deal with SQL statement used by different Database Such as MSSQL, Oracle, DB2, Informix, Sybase, Postgres, MySQL and so on. The code conforms to most of the entry-level SQL99 Standard.
To use this add-in you need to have SQL Server Management Studio (SSMS), with .NET2.0 installed. In sql editor you can use shortcut key (ctrl+k,ctrl+j for all sqls, and ctrl+k, ctrl+h for selected sql). There is also a toolbar with two buttons to format sql or selected sql.
To see it in action, take a look here, where you have some sample code blocks before and after the formatting.

XMLStarlet: command line XML toolkit

XMLStarlet is a set of command line utilities (tools) which can be used to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands.

This set of command line utilities can be used by those who deal with many XML documents on UNIX shell command prompt as well as for automated XML processing with shell scripts.
Ubuntu allready has it in the repos, so issue the following command in your terminal to install it:

sudo aptitude install xmlstarlet

Google Wave

The guys behind the Google Maps are working on a tool for communication and collaboration on the web. It’s called Google Wave and it’s planned for release later this year. The nice thing is that will be open source’d and you can allready use their API to start building your stuff.
You can watch the video from the Google I/O where they unveiled the project.


Bash script to retrieve info about current playing track on ARM.FM

I am a big fan of ARM.FM.
Their playlist contains the freshest tracks in the dance music.
I wanted to keep track of the tunes I like the most, so I made a little script to update a file on my desktop with the name of the track currently playing.
Here is the script, you may use and/or modify it as you please.

## 1.0
## Keep track of the best tracks playing on
## It creates the file 'tracks' on your desktop
## Also, the file _output.html can be used on your site
## to display last 3 tracks played on ARM FM
curl -s -o _arm.txt
start_line=`grep -n 'current' _arm.txt | cut -f1 -d':'`
<table align="center" cellpadding="0" cellspacing="0">
    <td valign="top">
      <div style="width: 250px; margin: 20px 0px 0px 0px;">
        <div style="margin: 10px 0px 0px 0px;">
          <table cellspacing="0">
              <td style="padding: 10px;"></td>
echo $html_tag > _output.html
sed -n "$start_line,81p" _arm.txt >> _output.html
sed -i -e 's/<img src="\/tpl\/images\/dot.jpg">//g' _output.html
sed -n '2,2p' _output.html > _temp
sed -i -e 's/              <td valign="top" style="border: 1px solid #ccc; border-top: 0px; border-right: 0px; padding: 10px; font-size: 11px; color: #444"><b><font style="color: #900">//g' _temp
sed -i -e 's/<\/font><\/b><br> //g' _temp
sed -i -e 's/<br><\/td>//g' _temp
sed -i -e 's/  (current)/ - /g' _temp
artist=`cut -f1 -d '-' _temp`
track=`cut -f2 -d '-' _temp | sed 's/^ *//'`
echo $artist - $track >> $HOME/Desktop/tracks
rm _output.html _arm.txt _temp

Install Django on Ubuntu 8.10

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
To install it on your Ubuntu, follow the next steps:

1. Install python (if you have it installed, skip this step)

sudo apt-get install python

2. Download the tarball from the Django Project website. You can download this file to your home directory.

tar xzvf Django-1.0.2-final.tar.gz

3. Now we can just move this entire package to somewhere logical. You can move it anywhere you like, but remember to modify the links accordingly. I use /usr/local/lib/.

sudo mv Django-1.0.2-final/  /usr/local/lib/django-1.0.2/

4. Link to it from the Python site-packages directory, and create a link to the executable.

cd /usr/local/lib/django-1.0.2/
sudo ln -s `pwd`/django /usr/lib/python2.5/site-packages/django
sudo ln -s `pwd`/django/bin/ /usr/local/bin/

5. Test it by changing to your home directory and running django-admin! --version

You should see this:

1.0.2 final

6. Happy programming!

RFID tags

RFID (Radio-frequency identification) is an automatic identification method.
RFID tags can be used in passports, transportation payments, product tracking, transportation and logistics, lap scoring, animal identification.
Human implants are also available but the experts warned against using RFID for authenticating people due to the risk of identity theft.
In the video you’ll see how RFID tags can be accesed using inexpensive off-the-shelf components.
Researcher Chris Paget built a device consisting of a Symbol XR400 RFID reader (now manufactured by Motorola), a Motorola AN400 patch antenna mounted to the side of his Volvo XC90, and a Dell 710m that’s connected to the RFID reader by ethernet cable. The laptop runs a Windows application Paget developed that continuously prompts the RFID reader to look for tags and logs the serial number each time one is detected. He bought most of the gear via auctions listed on eBay.
Watch and be scared!



This extension provides syntax highlighting features for COOoder will be usefull for developers wanting to present code fragments in writer documents.
More info here:

Change the number of comments per page in admin interface of wordpress

Let’s have this situation:

You need to make a backup of your blog, you have access only in the admin interface of wordpress and you have 3000+ comments containing spam in the ‘awaiting moderation’ state. Do you spend your day selecting 20 comments at a time and hittind the delete button? Hell, NO!

You hack the edit-comments.php file located in the wp-admin folder.
Locate the following line:

$comments_per_page = apply_filters('comments_per_page', 20, $comment_status);

Now you need to change the figure 20 to another figure, e.g. 100 so that it looks like this:

$comments_per_page = apply_filters('comments_per_page', 100, $comment_status);

Save the file and check the display of the comments in the admin interface.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.