MySQL and Unicode Thaana

Anyone developing custom code for a Thaana application or website will undoubtedly run into many interesting challenges and issues. Judging by how often I get emails asking for help with getting MySQL to play nice when using Unicode Thaana, I'd say it's one of the very first issues many (newbie?) web developers face.

Here are some of the basics that one should keep in mind when attempting to use Unicode Thaana and MySQL.

Charset
It is very important that the correct character set be used when using Unicode Thaana for MySQL to correctly recognize the text. If you are going nuts over your code returning "???" or junk characters after trying to store Thaana text into a MySQL database, then it most certainly is because of an incorrect charset being used.

I recommend issuing the following SQL commands upon successfully establishing a connection with the MySQL server.
SET NAMES utf8;
SET CHARACTER SET utf8;


Read up the MySQL reference page on connection charsets and collations for more details.

Collation
MySQL does not have special language specific collation rules for Thaana - and there is no need for such far as I am aware. I recommend using the "utf8_unicode_ci" collation when creating tables and fields in MySQL.

Refer to the MySQL reference page Unicode character sets for more details.

Happy databasing :-)

Guide to blogging in Dhivehi using WordPress

Here is a short guide to using Thaana to make posts in Dhivehi using the free WordPress blogging service. I regularly get emails from different people asking me for help on this topic, so I hope this is helpful to all such people :-).

The solution presented here can be used on the free Wordpress blogging accounts available from WordPress.com and also on custom installs of WordPress. Please be aware, however, that there are much better ways to setup WordPress for Dhivehi posting if you have a custom install of WordPress or have a paid WordPress account.

Requirements:
You need to have the Dhivehi keyboard installed on your computer. If you already type Dhivehi, say using MS Word or OpenOffice, then you have this already. See this post by Fayid if you need help with getting the Dhivehi keyboard installed.

Steps:
1. Login to WordPress and click on the "Write" tab to start a new post.


2. In the post editor area, find and click the "HTML" tab to switch the view to HTML mode.


3. Copy and paste the following code into the editing area. It contains the bare minimum HTML/CSS needed to correctly display Dhivehi on all browsers supporting right-to-left text display in Unicode.
<div style="direction: rtl; text-align: right; font-family: faruma, 'mv iyyu nala', 'mv elaaf normal'; font-size: 14px;">Test</div>



4. Tinker around with the font family and font size settings if you know some CSS (or are feeling adventurous enough!). Faruma is probably the most decent Dhivehi Unicode font and is installed on most computers - hence is listed as the first preference. Different people like different font sizes for Dhivehi but 14px and 16px, I think, tend to be the easiest on the eye.

5. Click the "Visual" tab to switch the view back to the normal WYSIWYG mode.


6. Switch the keyboard to "Divehi" on the computer.


7. Select or delete the "Test" text on the post editor and start writing in Dhivehi.


That's all it takes!

Notes:
Unfortunately, there is no way to apply proper formatting to the post title with the free accounts on WordPress so you will have to settle for the out-of-alignment title display.

Video guide:
I thought it'd be fun to make a video guide for this and here is what thus materialized: View good quality | View crap quality (Youtube)

Good luck with the blogging!

Thermite: Towards the rapid destruction of hard disk(s)

A friend of mine, a very paranoid and drama-loving fellow, asked me recently for some suggestions on how to rapidly destroy a computer hard disk. He wanted to destroy his hard drive banks "if police came to get him". I don't know what possible reason the police may have for wanting him and his hard drives but being the dramatic fellow he is, I know he'd want to do it purely for the drama alone. Anyway, my solution to him was simple and most importantly, very dramatic: thermite!

A thermite reaction is an exothermic chemical reaction that generates temperatures reaching upto 2500 °C - more than enough to melt the entire hard drive and entirely destroy the magnetic lining of the platters. Thermite consists of aluminium and iron(III) oxide (better known as rust!). The two is to be mixed in a ratio of approximately 8 or 9 parts iron oxide to 3 parts aluminium. The aluminium needs to be powdered and can be obtained by filing/sanding soft drink cans or aluminium tubing. The iron oxide (rust) can be shaved off from a rusting iron rod and should be in powder form as well. I've successfully tried with aluminium filed off aluminium tubing that I had purchased for building an antenna and rust collected from a bunch of iron nails that had been rotting away.

Ignition is the most important part for getting the thermite reaction going and isn't an easy step for the method described above. The easiest way, which I recommended to my friend, was to use a magnesium strip. They aren't available in Male' but can be ordered online or purchased from abroad easily. Alternatively, I suggested, convince a chemistry student at CHSE to get some - they often use it as part of their weekly practicals and throw out a load of half-used strips to the bin anyway!

Finally, the thermite mixture can be placed in a little container and a piece of magnesium strip neatly stuck into it. The container can be placed on top of the hard drive with the magnesium strip accessible and ready for lighting when required! Once ignited, nothing will stop the reaction and extinguishers - be it water, foam or CO2 - will miserably fail too.

Needless to say, the prospects of having his hard disks melted in a fiery fire as cops watch helplessly really excited my friend...

Further info:
- http://www.ilpi.com/genchem/demo/thermite/
- Watch some thermite reactions

Note: Thermite is not fun play - stand well away and avoid using large amounts. Do be careful if you are curious enough to experiment ;-)

Make a spud gun!

One thing I remember particularly from my childhood is my liking for those toy guns that made a bit of explosive flash and sound when triggered. It came in different forms but I remember my favourite one (or rather the only one my parents dared to get me :-P) which was shaped almost like a real gun with a changeable ammunitions magazine. The magazine packed a round of these cool bullets that when fired made a small explosion. The bullets had a teensy weensy amount of gunpowder in them to achieve the effect - I know because I took apart a bullet (and eventually the gun itself) to learn how they worked. But then, the government added fireworks, firecrackers and anything that went bang including these toy guns to their list of banned items. Being an avid experimenter, that got me started on making my own things-that-went-bang...

Here is how to make a spud (potato) gun. It is something quite common and easy to make. It is also pretty powerful - has a range of atleast 30ft when constructed correctly and delivers a punch that would make you go a big "ouch!" if hit by one. I made a mini pistol-like version of this when I was in Male' for holidays in August 2006, just to reminisce the gunslinging days :-D.

Materials:
- Insect repellent spray (shelltox, bop spray...)
- Piezo electric igniter from a cigarette/kitchen lighter
- About 2ft of large diameter plastic pipe
- About 4-6ft of small diameter plastic pipe
- Endcap for the large pipe
- Reducer that connects large pipe to small pipe
- Paperclip
- Small length of wire

Diagram:


Construction:
- Any type of insect repellent should do. I've tried "Shelltox" and "Bop Spray".
- Piezo electric igniters are those things found in some cigarette and kitchen lighters that when pressed makes a spark. I'm sure many have used these things to deliver a jolt of friendly electricity to friends ;-)
- Glue the large diameter pipe to the reducer and then glue the reducer to the small diameter pipe.
- The end cap doesn't need to be glued and can be just plugged onto the large pipe.
- Break the paperclip into two, heat up pieces using a lighter and when hot, push the two pieces about 5mm from each other.
- Connect wires to the paperclips terminals.
- Connect the end of the wires to the piezo igniter.
Construct as shown in the diagram.

Usage:
- Push a Potato into the end of small pipe making sure it fits snugly and there is no space for air to flow. Push the potato till it is almost at the beginning of the reducer.
- Spray some repellant into the large pipe and quickly cover with the end cap.
- Take aim and press the igniter to shoot!

More details:
The above is what I did in August. There are many, many different versions of spud/potato guns available on the net. I suggest reading up more from this guide at instructables.com. They have photos and videos there.

Enjoy!