Buca Bay - Always nice

Dua tiko noqu toa loaloa, na yacana ko… laga mai…

Joana’s first drawings in Florida

June27

Joana is really improving her drawing skills. Here is two drawings she did this week.

This one is of her and her mommy with Grandmother Willow. (from Pocahontas)

This one is of our family.

posted under drawing, joana | 1 Comment »

JavaScript Regex match all characters

June19

JavaScript regular expressions (browser) do not have a modifier allowing the dot (.) to match all characters including the newline like the ’s’ modifier does for PERL and PCRE in PHP.

However a cool tip I learnt just recently is that using a character class and it’s negated version will allow you to match all characters. Eg: /[\s\S]/g will match all characters in a JavaScript Regular Expression.

I used this trick in the ASCII to Hex conversion JavaScript code I posted a few days ago and thought to mention it.

Joana’s drawing of our Family

June15

Joana did this drawing of our family a few days ago.

posted under drawing, joana | No Comments »

Joana’s drawing of Aunty T

June14

Vara sent me a scan of Joana’s latest masterpiece :). A drawing of her Aunty T.

posted under joana, pictures | No Comments »

ASCII to Hex in JavaScript

June14

This JavaScript will add a method to the String object, that converts the ASCII string to a hex string consisting of the equivalent character codes for each character in the String.

String.prototype.toHex = function() {
    return this.replace(/[\s\S]/g, function(s) {
        return parseInt(s.charCodeAt()).toString(16);
    });
};

Note that hex is base 16 and ASCII is based 256 so the hex string is a longer.

I recently had to save a password in hex (Hexadecimal) instead of plain ASCII since the software that came with my Netgear USB Wireless Adapter didn’t like the ASCII version for some reason.

So for example if your password is “joe”, then to convert it to the Hex equivalent would be:

'joe'.toHex()

Oddly, my computer (Vista) took the Hex password, while the printer took the ASCII version and my friends Windows 7 took the Hex.

posted under javascript | 2 Comments »
Tag Cloud