Twitter Updates

Archive for March, 2007

Moving my Blog from Blojsom to Wordpress

Saturday, March 31st, 2007

Moving my Blog from Blojsom to Wordpress

I recently changed my ISP from my old friend Aligen (courtesy of Farrad Ali for providing free access since ‘98) to HostMonster. So, instead of running my own Tomcat now I am relying on PHP and Rails. The next thing was how do I move my blogs and preserve the dates. Blojsom was simple file based software, but Wordpress uses mysql. So I wrote a simple ruby script to convert it.

The first thing I did was to download dbi from

http://rubyforge.org/projects/ruby-dbi/

I then uncompressed it

		tar xzf dbi-0.1.1.tar.gz

Then

cd ~/ruby-dbi

Since, I don’t have root access on my host, I could not install it to the /usr/bin directory. So I created my own ruby directory

mkdir ~/ruby

and then ran config with my own bin directory as

ruby setup.rb config –bin-dir=~/bin –with=dbi,dbd_mysql –rb-dir=~/ruby –so-dir=~/ruby

Next I ran
ruby setup.rb setup

and then

ruby setup.rb install

Now then fun part, following is a ruby script that reads my flat files and inserts them into wordpress database:

 1 #!/usr/bin/ruby
 2 require 'dbi'
 3
 4 #
 5 ### import blogs from old blog directory to wordpress
 6 #
 7 class ImportBlogs
 8   def initialize(webapp_dir)
 9     @webapp_dir = webapp_dir
10   end
11
12   def delete_all
13     DBI.connect('DBI:Mysql:weblog', 'weblog', '*****') do | dbh |
14       dbh.do('delete from wp_posts where id > 2')
15     end
16   end
17
18   def add_all
19     files = Dir.glob("#{@webapp_dir}/*").delete_if { |f| File.directory?(f) }
20     DBI.connect('DBI:Mysql:weblog', 'weblog', '*****') do | dbh |
21       id = 3
22       post_author = 1
23       sql = "insert into wp_posts(post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_excerpt, post_name, post_modified, post_modified_gmt, guid) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
24       dbh.prepare(sql) do | sth |
25         files.each do |f|
26           lines = nil
27           File.open(f, "r") do |file|
28             lines = file.readlines
29           end
30           post_content = lines.join(' ')
31           post_title = lines[0]
32           post_excerpt = post_content.slice(0,255)
33           post_date = post_date_gmt = post_modified = post_modified_gmt = File.new(f).mtime
34           post_category = 3
35           post_name = File.basename(f)
36           guid = "http://weblog.plexobject.com/?p=#{id}"
37           puts "Adding #{f} mtime #{post_date}"
38           sth.execute(post_author, post_date, post_date_gmt, post_content, post_title, post_category, post_excerpt, post_name, post_modified, post_modified_gmt, guid)
39           id += 1
40         end
41       end
42     end
43   end
44 end
45
46 ib = ImportBlogs.new('~/webapps/blojsom/computing')
47 ib.delete_all
48 ib.add_all
49
50 

Finally, I ran it as follows:
ruby -I /usr/lib/ruby/gems/1.8/gems/mysql-2.7 -I /usr/lib/ruby/gems/1.8/gems/mysql-2.7/lib -I ~/ruby -I ~/ruby/DBD -I ~/ruby/dbi -I ~/ruby/DBD/Mysql import_blogs.rb
Voilla, I got everything as expected.

About Shahzad Bhatti

Thursday, March 29th, 2007

Welcome to the my neck of the woods. My name is Shahzad Bhatti and I am living in Seattle area and married with children. For about fifteen years, I have been software developer by day job and a software hacker by night, i.e, after ten hours of day job, I work on personal commercial and open source projects.
I generally distinguish developers into following categories:

So, I consider myself hacker, generalist and tool builder. Like many other
enthusiastics, I chase any new computer technologies and after chasing
OO, Java, Jini, CORBA, and J2EE for many years, I have putting more focus
lately on light-weight J2EE, JXTA, J2ME, aspect-oriented programming, ruby, rails and agile methodologies.

My academic interest includes distributed and parallel programming. I developed
a Java based framework called “JavaNOW” to write parallel applications similar
to Linda and PVM systems. You can find some links to parallel programming
at my bookmarks page, from my del.icio.us page or myspace.

Besides computing, I like to read books on Astronomy, unsolved mysterious,
mathematics, aliens/UFOs and ancient civilizations. In Astronomy, I like
String or Unified theory and hopefully one day it can sort out the
difference between Quantum Mechanics and General theory of relativity.
I love to read ancient
civilizations such as Egyptians, Summerians, Babylonians, etc. There
is a wealth of knowledge that has been lost specially prior to Noah’s
flood. May be we will find a huge library in one of the pyramids one day.
You can checkout some cool sites at
my bookmarks page or from my del.icio.us links section. My link to Ward’s wiki page is http://c2.com/cgi/wiki?ShahzadBhatti and my link to wikipedia is http://en.wikipedia.org/wiki/User:Bhatti_shahzad.

I also own a small consulting and software development company and spend spare
time writing interesting applications. May be someday I would get to quit my
day job. You can visit
Software Section of my
business website. These products are also available at http://plexobject.myshopify.com/.

Occasionally, I gaze at heavens and stars with my Orion SkyQuest XT8 Dobsonian Reflector
.

Checkout mosaic or list of a few books that I have been reading lately from Amazon. I generally buy 60-70% of my books from Amazon. Luckily, Amazon has nice feature to download history which makes this list easy to view.

Checkout my blog to find insight into my thoughts.

You can also sign my guest book.
I would love to hear your feedback about this site or you can tell me a little bit about
yourself.

Thank you for visiting my website.

Lebanon’s pain grows by the hour as death toll hits 1,300

Saturday, March 3rd, 2007

Lebanon’s pain grows by the hour as death toll hits 1,300

Lebanese Soldiers Lay Scores of Villagers in Mass Grave, More Bodies Stay Buried in Rubble With Rescue Workers Afraid of Missiles

at least 20 children and dozens of other civilians were killed in an
Israeli airstrike on the Lebanese town of Qana.

How soon must we use the words “war crime”? How many children must be scattered in the rubble of Israeli air attacks before we reject the obscene phrase “collateral damage” and start talking about prosecution for crimes against humanity?

The child whose dead body lies like a rag doll beside the cars which were supposedly taking her and her family to safety is a symbol of the latest Lebanon war; she was hurled from the vehicle in which she and her family were travelling in southern Lebanon as they fled their village – on Israel’s own instructions. Because her parents were apparently killed in the same Israeli air attack, her name is still unknown. Not an unknown warrior, but an unknown child.

Fleeing civilian killed by Israel

WITH an expression of utmost calm on her blood-masked face, the woman allowed herself to be gently lowered from the minibus into the waiting arms of two Lebanese Red Cross volunteers. The rescue workers had extracted her through a jagged hole in the roof of the crumpled bus, created by a missile fired minutes earlier by an Israeli helicopter that had blasted the vehicle off the road. Left behind in the vehicle, slumped over each other and soaked in blood, were the bodies of three people.

A war crime? This mother and son were in a convoy fleeing danger yesterday when the Israeli air force bombed the rear minibus, causing carnage.

They are in the schools, in empty hospitals, in halls and mosques and in the streets. The Shia Muslim refugees of southern Lebanon, driven from their homes by the Israelis, are arriving in Sidon by the thousand, cared for by Sunni Muslims and then sent north to join the 600,000 displaced Lebanese in Beirut. More than 34,000 have passed through here in the past four days alone, a tide of misery and anger. It will take years to heal their wounds, and billions of dollars to repair their damaged property.

Israeli missiles hit several buildings in a southern Lebanon village as people slept Sunday, killing at least 56, most of them children, in the deadliest attack in 19 days of fighting.

The bodies of at least 27 children were found in the rubble, said Abu Shadi Jradi, a civil defence official at the scene. At least 10 children’s bodies had been pulled out, placed in plastic bags and loaded in ambulances.

Israeli air raids have killed more than 40 people in Lebanon.

Lebanon pleads for ceasefire as Israeli blitz kills 69

Lebanon says 1,000 dead or missing.

What do you say to a man whose family is buried under the rubble?
And why was the building struck? The Israelis have slaughtered hundreds of civilians, attacking convoys of refugees they themselves ordered to leave. But Saadieh, Ali Rmeiti’s sister-in-law, has a story which matches those of two other survivors. Before the missiles exploded, she said, an Israeli drone flew over the Shiyyah district, a pilotless reconnaissance aircraft which sends live pictures back to Tel Aviv. “Um Kamel”, as the Lebanese call them, whined around for a time and then, without warning, someone drove down Assaad al-Assad street on a motorcycle and fired into the sky with a rifle opposite the Rmeiti home.



Across Lebanon, they are systematically lifting the tons of rubble of old roofs and apartment blocks and finding families below, their arms wrapped around each other in the moment of death as their homes were beaten down upon them by the Israeli air force. By last night, they had found 61 more bodies, taking the Lebanese dead of the 33-day war to almost 1,300.

The UN’s humanitarian chief has accused Israel of “completely immoral” use of cluster bombs in Lebanon.

What’s shocking and completely immoral is: 90% of the cluster bomb strikes occurred in the last 72 hours of the conflict, when we knew there would be a resolution,” he said.

IDF commander: We fired more than a million cluster bombs in Lebanon

Mystery of Israel’s secret uranium bomb
Did Israel use a secret new uranium-based weapon in southern Lebanon this summer in the 34-day assault that cost more than 1,300 Lebanese lives, most of them civilians?

Israel Detonated a Radioactive Bunker Buster Bomb in Lebanon

Human face of collateral damage

Saturday, March 3rd, 2007

Human face of collateral damage

The Shock and Awe Gallery


Horrific images from Labanon



Pictures From Qana

Popular Blog Entries

Saturday, March 3rd, 2007

Popular Blog Entries