ATM skimmers in Balluta (Malta)

Be careful when you’re withdrawing from ATMs. Authorities have just found an ATM Skimmer in HSBC Balluta. They had already found one a few weeks ago in BOV Paceville. This is attached to the ATM and it reads the credit card details.

Probably there is also a pinhole camera attached by the side of the ATM which will record your pin number as you type it as well.

Remove meta information of JPG files in Linux

To remove, edit and manipulate meta data inside JPG en-masse`, you can use a tool called exiftool. Since this is a perl module you can either install it through CPAN, or in an easier way like this:

$ apt-get install libimage-exiftool-perl

To simple wipe out all the meta data from an image or multiple images (example, for security reasons):

$ exiftool -all= *.jpg

Resizing and editing multiple photos in Linux

One of the easiest ways to manipulate a multitude of images inside Linux is by using the Imagemagick suite of tools, particularly the 'convert' tool. To install imagemagick on an ubuntu system:

$ apt-get install imagemagick

Then you can use the convert command tool to execute massive image edits. For example to resize all images in a folder to 25%, you can use the following command:

$ for img in `ls *`; do convert $img -resize 25% "fb_"$img; done

I suggest you to take a look at the manual page of convert which is very informative.

Ripping a DVD in Linux

You can simply use mencoder to rip a DVD in linux, and use it as follows:

$ mencoder dvd://1 -ovc lavc -lavcopts \
vcodec=mpeg4:vhq:vbitrate="1200" -vf scale -zoom -xy 640 -oac   \
mp3lame -lameopts br=128 -o dvd.avi

Drop/Truncate tables quickly in MySQL

Today I learned a nifty trick from the PalominoDB MySQL geeks to improve the delete or truncate time in MySQL. In both delete and truncate the table data file (assuming the innodb_file_per_table is on), is removed (syscall unlink()) from Unix. Apart from that, Innodb keeps a mutex on the buffer pool while the file is being removed from the filesystem. This is a big bottleneck!

So what's the trick? Forcing the database not to remove the file from the filesystem and we do that manually behind the scenes! How? Simple - by using hardlinks. If you need a refresh lesson on hardlinks, consider the diagram below:

On the left hand side is a file with no hardlinks. When we call unlink() either through unix 'rm' or through MySQL 'delete' or 'truncate', the file name is unlinked from the data and the data subsequently removed from the filesystem since no nodes are pointing to it. On the right handside when we create a hard link prior to the unlink, the data is still being pointed at by this hard link and therefore the data is not removed from the system. The data is only removed after we delete the hardlink as well.

So in summary, if you don't want to understand the above unix theory, from now onwards you can delete/drop/truncate tables as follows:

1. Create hardlink. Ex. ln table_1.ibd delete_me_later
2. Delete table. Ex.  delete table_1
3. Remove hardlink. Ex. rm delete_me_later

Linux DropBox syncing custom folders

As of the writing of this article, DropBox on Linux does not let you sync your work folders, but rather just lets you to take a separate copy. Even if you try to 'move' the DropBox directory from the preferences, you are not allowed to choose a directory like '/home/james' to sync the entire home directory, but rather it has to be named Dropbox i.e. /home/james/Dropbox.

But I recently discovered a trick (I am not claiming I invented it, but I haven't seen it documented elsewhere!) to circumvent this limitation. This is accomplished by the use of symlinks. Let me give you an example - if I want to sync my entire home directory /home/james on DropBox, and my actual DropBox folder is /home/james/Dropbox (but can be anywhere in reality), all I need to do is the following command:

$ ln -s /home/james /home/james/Dropbox/james

This will be a symlink on your local disk but entire full contents (like a hardlink) on Dropbox cloud.

I hope you like this tricks and if you have any comments please leave them below.

.Net error: Unable to find a version of the runtime

I don't normally blog about Windows errors but while installing a Windows virtual machine for work purposes I came across, a rather notorious I must say, error:

"Unable to find a version of the runtime to run this application"

Ok, first of all I am assuming that you already got the .Net framework installed, probably version 4.xxxx - and that's why you're confused why your application is not working - well this application is probably expecting an older version of the framework (v.2). I don't expect you to remove .Net v4 to install v2 :) But there is a hack!

Inside the same folder of the .exe application, create a config file called <application-name>.exe.config where <application-name> is the same name of the application. Put the following configuration in the file:

  <supportedRuntime version="v4.0.30319" />

Restart the application and it should work.

Setting up a Linux box as a router

If you have a virtual machine in a Linux host which requires Internet and physical LAN connectivity, or you just need to pass all traffic of a LAN through a Linux machine, you may need to set up Linux as a router.

  •     Enable IP forwarding on the Linux box
  •     Create a NAT rule to masquerade the IP
A virtual private IP must be configured on the Linux machine:
ifconfig eth0:1

This will serve as the gateway address for the other machines in the network (or of the virtual machine). In this case the other machines must have an IP in the form of 192.168.1.x. IP forwarding must be enabled:
echo 1 > /proc/sys/net/ipv4/ip_forward

Then we need to create the NAT rule to masquerade the private IP into a public one:
iptables -t nat -A POSTROUTING -s -j MASQUERADE

That's it! Remember that for the other machines you must set the gateway IP as You might also need to enter the DNS details (you can easily obtain it from dig [your ISP]. To list all the NAT rules:
iptables -t nat -L

To delete the NAT rule:
iptables -t nat -L

If you need to access your windows share, you can use smbclient as follows:
smbclient -U r00tb0x_user //
smb: \] dir

Note that you can do all the FTP stuff here..If you want to list shares available on a windows host:
smbclient -U r00tb0x_user -L //

If you want to mount a SAMBA share on your filesystem:
mount -t smbfs -o username=r00tb0x_user // /mount/point

MySQL Enable Slow Query Logging

In MySQL, slow queries can be logged in the 'slow query log'. To enable this feature you need to set the following variable:

log_slow_queries = 1

If you are running an older version of MySQL (prior to 5.1) you need to bounce the database. Additionally you can also set the filename as well:

slow_query_log_file = '<filename>'

Note that in MySQL 5.1 and later versions, this parameter can be set while the instance is running:

mysql> set global log_slow_queries = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show variables like '%slow%';
| Variable_name       | Value                            |
| log_slow_queries    | ON                               |
| slow_launch_time    | 2                                |
| slow_query_log      | ON                               |
| slow_query_log_file | /home/james/mysql/ebony-slow.log |
4 rows in set (0.00 sec)