Showing posts with label ramblings. Show all posts
Showing posts with label ramblings. Show all posts

Saturday, January 3, 2009

MySQL and Unicode

I just wanted to point out. MySQL STILL uses ISO-Latin-1 as the default encoding. LAME!!! I ran into again the problem today of having to set up my production database to use UTF-8. Not a difficult thing, but a hassle none the less. The thing is in these days everyone is using UTF-8, I mean i18n and l13n are two big deals. Some web programming frameworks make it a huge point of how well they handle the two.

Well anyway what to do? I had already created the database and tables, in the default ISO-Latin-1 encoding, and there was a few months of data in them. Therefore I had to start by fixing the encoding on the database and tables. Here are the commands that can make this happen:
alter table xxx character set = utf8;
alter database xxx character set = utf8;
Of course insert your table and database names. Now any new tables created in the database will have utf8 encoding. You probably WANT to make sure that everything in your database is UTF-8. The best way I know of doing this is my setting the proper values in the my.cnf file in /etc. If the file is not in /etc then you probably will need to create it. If someone else admins the machine and installed mysql there is a possibility also that the file is in another castle, er sorry location.

So crack open the my.cnf and insert this line:
default-character-set=utf8
Thats it, restart MySQL. To test this out create a new database, then a table in the database. Issue the 'show create table xxx' where xxx is the table name, you should see some text indicating it has UTF-8 as the encoding.

Tuesday, October 28, 2008

Openssl, when checking a digest...

I've been working on my own implementation of SHA-1 hashing function. In the bigger picture I've put together a mostly working OAuth client using Groovy, and part of that is using HMAC-SHA1 to compute a secret value. Well I started by using the built in Java version but decided i would create my own... this is good exercise.

So first thing I did was write some unit tests. I needed SHA1 hashes to start with to make sure that my algorithm implementation works. The obvious choices are either sha1sum or openssl. I'm on a iMac running Leopard, and by default openssl is installed. I used that to compute some hash values. Unfortunately for me I spent a lot of time trying to get my algorithm working when it was already working. The problem was I computed the values wrong with openssl. I used the following:

echo "the quick fox jumps the brown dog" | openssl sha1

Which gave me a incorrect value. Why you ask? Well I didn't remember the -n flag and a newline character was being included in the string passed to openssl. Ooops! Well once I added the -n flag everything was fine and I now have a number of hash values to use in my tests.

Friday, May 2, 2008

Perl how you offend me (sometimes)

I've been fishing around with Perl over the last month. Got a big legacy PIM application to deal with. Oh my! This app is running on Apache and mod_perl. These are some old school technologies. I'm sure there are lots of burnt out mod_perl programmers out there who are much more qualified to work on this shit. I bet they don't bother to put this stuff on their resume, not as long as they have money in the bank, and/or a roof over their head. Scratch that maybe even without those... having gotten acquainted to this stuff homelessness may be preferable. Sad sad. I don't dislike Perl. It has it's charms and especially evokes finer feelings of classic-ness. It's the language that helped build the net into what it is... a giant commercial cesspool slash platform for extremists of the opinionated sort and trans-generational masturbatory aid. Wow what a legacy.

So there it is. Why should I respect something merely because it's author has a rad mustache and sweet Hawaiian shirt collection? Perl in my very humble opinion is too prickly for the newer generation (which I kinda am in). It has nice features: hashes real nice.. lists real nice... CPAN amazing... come on though, for each thing it does right it does numerous things wrong or in poor taste. Arguments to functions blah, references why are you so lousy looking and overly complicated? And strict, dumbest vestigial lousy feature ever. Classes are disgustingly complicated to pick up... bless?!? Lots of sharp edges. Dispite all this Perl has lit the way for many. I've met people that are now programmers because they found Perl. Lets face it though, languages have severely changed since Perl's founding. Most people who program Perl have changed too.

I recently read Perl is not dead, sure I agree, it is just legacy. Cobol and Fortran are not REALLY dead either. But you couldn't lure me into doing either, not with a six pack of Micky's and a Snickers bar. There are few things golden left for those of great Perl skills to be looked forward to. All the cool kids have moved onto Python and Ruby, even Java I may argue. These people of skill would have little difficulty picking up another language. The true hacker/scholar/intellectual will thrive on a new language, enjoying the diversity of human creation. They also should have little holding them back from trying something new. I wager those who make the effort will quickly make the transition to the new language and never look back. This may include a change of job.

To wrap it up Perl is like the obnoxious slob at a party to which you want to avoid. Difficult to deal, disheveled and unkempt, but also sometimes fun. If you are learning to program, or have done a bit of programming learn Python (or maybe Ruby). Stay away from Perl. Also don't go near PHP, please!

Sunday, November 4, 2007

Super Cheap Functioning Laptops

Many people have heard of the "One Laptop Per Child" (OLPC) program (Please excuse the terrible site. Here is the wiki, much better ;). The gist of OLPC is many companies have banded together to create a sub $200 laptop geared towards school children. It is expected the developing nations of the world will buy these units up in large numbers. They then will use them to increase the quality of education by giving the children a chance to experience the "greatness" of the internet, the word processor, the spreadsheet program, the mp3 yada yada yada... So anyway some guy over at Asustek, the maker of Asus brand computers decided "hey, lets build a ultra cheap laptop that is geared towards the Adult demographic". Great idea guy. Check out the EEE pc.

I had some hands on time with the OLPC at the OSCON convention last July. It was neat in the sense of how far technology has come. It seems to work, which is an accomplishment considering the nature of the project, and conference attendees all seemed genuinely impressed. My deal though is this: it is a laptop geared towards a 8 to 10 year old boy. The color scheme and user interface all scream to this effect. I would not buy one of these and lug it into a coffee shop. Guys like me already have enough trouble making acquaintances without hauling a "hello kitty" lunch box everywhere we go. So in comes the Asus EEE pc. Seems to look good enough. The interface is simple. See mock up here. It also includes all the applications a person such as my mother, god mother, or wife need. Its perfect for Facebooking, instant messaging, video conferencing, writing email, browsing the web, plus the rest of the top 20. If it provides a seemless enough experience I think soon we will be seeing many more of these types of machines around.

Now the crazy thing is both the EEE pc and OLPC are Linux based. Why you ask? Duh, because a copy of Windows is a few hundred bucks. The computer itself will likely cost less than a copy of Windows Vista Professional! Oh oh M$, your days may soon be the slightest bit darker. As an aside I read somewhere, not saying I believe it, but M$ got scared that Windows would not be running on the EEE and so are giving Asus a chance to offer XP at $40 dollers as an upgrade. How many will spring for this? Not a single person I know. When you figure that the Linux based OS is tailored to the EEE it would be hard to beat it. Not to mention but the EEE runs on a very small amount of disk space. This disk space is all flash memory and clocks in at 4 to 8 gigs. Windows will suck up your whole disk!