Like what I have to say? Subscribe to my blog via RSS or email, and you'll be notified whenever there's a new blog post!
 
Subscribe to Alvin Poh's Blog by RSS reader
Subscribe to Alvin Poh's Blog by Email

Gadgets, Technology, Public speaking and IT from an undergraduate's perspective.

How to Learn and Use Regular Expressions (Regex)

Whoever would have thought that something that looks like gibberish would actually have such powerful usages. Look at this example:

\d\d[/]\d\d[/]\d\d[ ][-][ ]

Would you believe that it’s actually an expression that matches anything of the format of “12/06/08″? Amazing.

I’ve been putting off learning about regular expressions (regex) for the longest time because it seems overly complicated — but I was forced to learn more about it after a recent application demanded of it. And boy was I glad to have finally jumped into it — it’s simply one of the best ways to search for any text pattern.

With regular expressions, you can search for any number of characters, specify whether it’s a number or letter, and even specify a range, like only accept alphabets between B and E. Or only numbers from 1-5.

So if you think about it, the sample regular expression string up there can actually be improved upon. For instance, since the date format is dd/mm/yy, we know that dd can go higher than 31, nor can it go lower than 1. And similarly, we know that for mm, it’s between 01 to 12. The tricky part is yy, because it can vary, depending on how you’re going to use this date. If your application’s more geared towards the future, then keeping the first digit to 0 or 1, and the 2nd digit from 0 to 9 should be just fine.

So as you can see, if you’re a developer, then regular expressions (regex) should be something that you are very familiar and comfortable with, because it makes your life so much easier!

Subscribe to my blog: RSS reader    Email

Book Safe to Keep and Hide Valuables (Cash, Jewelry, etc)

I remember when I was much younger, and I happened to watch this movie where one of the characters stowed some secret item in a book safe. The much-younger-me was very much the impressionable and easily astonished kid, and if I don’t recall wrongly, I was extremely surprised when I first discovered the book safe.

I thought it was an absolutely ingenious idea.

Books were meant for reading and I never did explore the possibilities of actually having a fake book to store valuables in. The premise was simple — have a fake book, or a real book with a hole cut into it — and then storing your cash and valuables inside that book safe.

Book Safe to Keep and Hide Valuables (Cash, Jewelry, etc)

For book safes like that, a lock or combination wouldn’t even be possible. These book safes depend on security by obfuscation, which, is entirely inadequate. The complete system is based on the assumption that another person will not chance upon your book safe by accident.

That said, I know it sure as heck is a great conversational piece. And it’s cool.

Interested? Amazon has it, so you can get your very own book safe.

Subscribe to my blog: RSS reader    Email

Does Ireland Have Postal / Zip Codes?

I was packing a parcel to be sent to Ireland when I realised that there was something missing. There wasn’t any postal code! So I thought that I had the address wrong, so I double-checked it again. But the strange thing was that it was correct!

So I went online, and did a bit of research on zip codes in Ireland. Well it turns out that there are no postal codes for most of Ireland! That’s right, Ireland has no postal/zip codes, except in Dublin. The city of Dublin is divided in postal codes 1-24.

Subscribe to my blog: RSS reader    Email

All-Ett vs The Big Skinny Review (Slim Men’s Leather Wallets Review)

Yay! My new wallet from The Big Skinny came in the mail today. I’ve been on the search for a new wallet to replace my old one for a long time because I felt that it was just too thick.

big skinny review - slim wallet

The search was made more difficult because I had a certain set of criteria that I was looking out for. Namely, the new wallet must be:

  • Super thin / slim
  • Look good and presentable with any kind of attire
  • Preferably compartmentalised
  • Have a convenient compartment for cash notes

For that reason, I decided that I had to get a leather wallet, and the wallet should have a full-sized compartment for holding cash. None of those money clips because I think a little privacy is good, and none of those half-sized pockets that require you to fold your cash, because I don’t like fumbling with cash while I’m trying to make payment or collect change.

big skinny review pictures - slim men's leather wallet

Well, so I shortlisted my choices to finally between either the All-Ett (Check out the choices available here ), or the Big Skinny. I made my ultimate decision the Big Skinny because it released a leather version just as I was about to buy.

big skinny leather wallet review - front pocket wallet

This choice of leather turned out to be a bad idea because leather is inherent thicker, which actually goes against my first criteria (that the wallet must be super thin / slim). So the Big Skinny turned out to be just marginally slimmer than my original leather wallet.

big skinny wallet - thinnest wallet

Perhaps I should have chosen the All-Ett (Check out the choices available here ) or the original version of the Big Skinny wallet instead.

Subscribe to my blog: RSS reader    Email

Using Google For Calculations and Conversions (Metric, Distance, ANYTHING!)

Heh. Other than performing searches, Google’s actually great for calculations and conversions. For instance, try typing:

23oz to ml

to convert ounces to millilitres. I haven’t found anything that Google couldn’t convert — I’ve tried converting distances (km, m, cm, inches), volume (l, ml, oz, gm, m, kg) and even currency, like so:

USD10 to SGD10

Google also works as a math calculator, so you can even type our calculations like:

2 * 6

and Google with give you the answer. It works with more advanced functions too, such as:

(23^2) mod 2

which is essentially 23 to the power of 2, then perform a modulos 2 operation. Cool stuff! The only problem with this is that you’ll need an Internet connection, so if you’re offline, all these functions are unavailable to you.

Subscribe to my blog: RSS reader    Email