Archive

Archive for June, 2006

Playing with Ruby

June 30th, 2006 No comments

I need to add support a new interface panel to the my Plutohome installation. To do it I use Generic Serial Device (GSD) which works perfect. GSD has embedded Ruby interpretator to provide a tool for implementing desire device logic. In my case, I receive a hexdecimal binary string which contains a device ID, device port, command and data. All of them should be converted in integer exept data. The data should be converted in float. I found this solution how to convert hex string to float on Ruby forum:

irb(main):001:0> s=’0×44361000′
=> “0×44361000″
irb(main):002:0> f=[s.to_i(16)].pack(‘L’).unpack(‘F’)[0]
=> 728.25

I like Ruby. It’s the similar to Perl but, of course, with some specificity.

Mysql useful tips

June 30th, 2006 No comments

I decided to put in one post several Mysql commands and tips which I used during this week.

1. Get a table structure
To get a table structure in a SQL it can be used a command

show create table <table name> \G

2. Get ID of last inserted record.
To get the ID of the last inserted record just use mysql built-in function LAST_INSERT_ID(). Perl geeks can get the ID from DBI connection property – mysql_insertid:

my $id = $dbh->{mysql_insertid};

3. Update summary counters.
To update some counters in a table you can do following:

  • do UPDATE everytime but catch a case if the record is not existing and do INSERT in this case:
    my $ret = $dbh->do(‘UPDATE counters SET hits=hits+1 WHERE IP=”192.168.1.1″‘);
    $ret = $dbh->do(‘INSERT INTO counters (hits, IP) VALUES(1, “192.168.1.1″)) unless $ret;
  • use INSERT ON DUPLICATE KEY UPDATE (via MySQL Performance Blog):
    my $ret = $dbh->do(“INSERT INTO ipstat VALUES(inet_aton(’192.168.0.1′),1,now()) ON duplicate KEY UPDATE hits=hits+1″);

    Note: IP should be a primary key in this case

Categories: Digital Life Tags: ,

FJAX: Ajax with Flash

June 29th, 2006 No comments

Ajax is a standart de-facto for Web 2.0 applications. Using Ajax technology it’s possible to create a flexible and handy web-based user interface. But the computer world is not at a standstill. The new web technology is coming: FJAX. FJAX is a Flash-based implementation of Ajax:

Fjax uses the Flash Player to load a 1 pixel by 1 pixel transparent SWF to simply get XML from the server. Once it has the XML, it parses it into HTML and then lets JavaScript know it’s ready. JavaScript then gets the HTML from Flash and DHTMLs it into the web page — it uses JavaScript to write (X)HTML/CSS onto the page.

I also started to use Ajax. I didn’t develop something serious yet. But that’s down the road :)

[via O'Reilly Radar]

Fedora Core 6 and Mactel

June 23rd, 2006 No comments

Fedora Core 6 will support Intel-based Macs. It’s good news espessially I need to boot Linux on Mac Mini to have possibility use it as Plutohome media director. But it should be Debian and Mini should boot from via network.
Anyway, you can find a short explanation how to make Dual Booting with OS/X and Fedora Core 6. Also, Jeremy Katz reports some problems with Apple hardware like wireless with Atheros chipset. So, let’s wait release of 6th Fedora to use it on Macs.

Categories: Linux Tags: , , ,

Flash Plugin and X.Org 7.0

June 19th, 2006 2 comments

After upgrate my work PC to Fedora Core 5 I found that Google Analytics didn’t display any text. I left it as it was (yes, yes, I know that it’s not characterize me good side). Today I lost my patience when tried to see SmartBlog statistic. The good article – “The flash plugin and X.Org 7.0 (X11R7) font problems” helped me resolve my problem. I made a symlink to X11 fonts configuration:

ln -s /etc/X11/fs/ /usr/X11R6/lib/X11/fs

and restart Firefox. After that flash player found fonts and displayed text correctly.

Categories: Linux, Personal Tags: , , ,

Lost in Translation

June 16th, 2006 No comments

Today I tryed to implement a functionality to create some CRM entities from email. I needed to retrieve an email, first name and last name (if possible) and body of the email. The last name is a mandatory property. I made a mistake when I used perlish style to initialize the last name:
preg_match('/\"(.*)\"\s+\< (.*)\>/', $from, $from_arr);
$names = preg_split('/\s+/', $from_arr[1]);
$email = $from_arr[2];
$first_name = $names[0];
$email_user = preg_match('/^(.*?)@/', $email);
$last_name = $names[1] || $first_name || $email_user;

But PHP is not Perl. I got “1″ as the last name. So, I changed it on PHP manner:
$last_name = $names[1];
if(!$last_name) $last_name = $name[0];
if(!$last_name) $last_name = $email_user[1];

IMHO Perl variant is much better :)

Start another blog

June 15th, 2006 No comments

In view of a big number of posts related with smart home stuff I decided to create a new blog and move all smart home posts here. The blog is SmartBlog. You can add blog entries RSS or/and comments RSS in your preferable RSS reader to have an always fresh information.
I’m planning to write in the SmartBlog about home automation technologies and gadgets and describe my progress in the building smart home based on Plutohome. So, I hope it’ll be interesting for you :)

Categories: Personal Tags:

Prodrive P2

June 15th, 2006 No comments

Prodrive P2 is amazing sport coupe based on a Subaru R1 (a four seat mini car), which was completely reengineered to give P2 its coupe styling and to accommodate the new engine and drivetrain. See more information and photos here.

Categories: Auto mania Tags:
Get Adobe Flash playerPlugin by wpburn.com wordpress themes