Updates from May, 2008 Toggle Comment Threads | Keyboard Shortcuts

  • Prasanna 6:40 pm on May 31, 2008 Permalink | Reply
    Tags: bloopers, phone, scientific notation   

    Software blooper 

    Scientific Notation

    Phone numbers aren’t supposed to be written in scientific notation 😛

    Advertisements
     
    • Vinay Hegde 7:41 pm on June 2, 2008 Permalink | Reply

      Lolz! 9.14E+11 for a phone number!!!! its awesome…

    • Ramya 2:40 pm on June 16, 2008 Permalink | Reply

      Wow!!
      what an idea sirji 😛

    • Leela 12:07 pm on July 11, 2008 Permalink | Reply

      Good one!

    • Infy 3:37 am on July 13, 2008 Permalink | Reply

      Ha ha… beautifully sickening.

  • Prasanna 6:32 pm on May 31, 2008 Permalink | Reply
    Tags: doordarshan, , smile, tambura, television   

    Smiling Tambura 

    Smiling Tambura

    🙂

     
    • The lightcone 6:45 pm on May 31, 2008 Permalink | Reply

      he he he… 😀
      Nice…
      Kattai veraL nalla smile pannardhe… 😀

    • Arjun 11:13 am on June 1, 2008 Permalink | Reply

      😀 Dei, n studd for noticing that 😀
      Bows 🙂

  • Prasanna 8:14 pm on May 28, 2008 Permalink | Reply
    Tags: beautiful, , parsing, python, soup   

    Beautiful Soup 

    Beautiful soup is indeed beautiful!

    I wanted to parse an HTML page containing a table and import it into a MySQL table in an automated way. Upon my friend Kumar’s advice, I came to know about Beautiful Soup. Today was the day to explore Beautiful Soup. Being new to python, I had to do a bit of python reading side-by-side. Finally, I was able to successfully pass an HTML file to my script and get a CSV output.

    f = open("input_file.html","r")
    g = open("outfile_file.csv,"w")
    soup = BeautifulSoup(f)
    t = soup.findAll('table')
    for table in t:
        rows = table.findAll('tr')
        for tr in rows:
            cols = tr.findAll('td')
            for td in cols:
                g.write(td.find(text=True))
                g.write(",")
            g.write("\n")
    

    This script parses a simple HTML table without looking for any special tags or anything. Now that this is working, I have to make this more stronger and parse an uglier table, my task for tomorrow.

     
    • Naveen 9:28 pm on May 28, 2008 Permalink | Reply

      Awesome… Beautiful soup is really amazing!
      A very nice idea too… 🙂
      Continue writing such posts… 🙂

    • Akarsh Simha 10:14 pm on May 28, 2008 Permalink | Reply

      Amazing! I didn’t know it would be THAT simple. I like the for…in funda of python a lot for its simplicity.

    • Kumar Appaiah 6:31 pm on May 30, 2008 Permalink | Reply

      I’m glad you’ve also joined the “Python for making life simple” bandwagon! 🙂

    • Prasanna 4:41 pm on May 31, 2008 Permalink | Reply

      @Naveen
      Thanks

      @Akarsh
      Yes. That’s true 🙂

      @Kumar
      Thank you for making me dive in

  • Prasanna 7:40 pm on May 28, 2008 Permalink | Reply
    Tags: , , portrait, professor   

    Photo Session 

    Recently, some of us went around on a photographing spree. The subjects weren’t natural wonders or astronomical objects. They were professors. Yes. I tried my hand at taking professional portrait shots of professors for putting up on the department website. The idea was inspired by the photo on this webpage.

    This was one of the shots that I took.

    After a bit of GIMPing (mostly along the lines of this), I managed to get the photo to look like this.

    I was impressed with the result. So, I decided to take one of mine also. That resulted in this.

     
  • Prasanna 4:44 pm on May 10, 2008 Permalink | Reply
    Tags: apache, apache2, clean url, , drupal, mod_rewrite   

    Drupal and Clean URLs 

    The default unclean URLs that Drupal provides with question marks lurking around, could be annoying. But it does offer an option to have clean URLs. I couldn’t find a neat tutorial to do this and this was not of great help either. So, let us see how to get this done.

    Step 1

    Check whether the rewrite module for your apache is enabled. Assuming you have an apache2 installation, you can do this by

    ls /etc/apache2/mods-enabled/

    If you don’t find rewrite.load, it means that the rewrite module is not enabled. Drupal’s clean URLs feature requires this module to be enabled. If you have a Debian based machine,

    sudo a2enmod

    Which module would you like to enable?
    Your choices are: actions alias asis auth_basic auth_digest authn_alias authn_anon authn_dbd authn_dbm authn_default authn_file authnz_ldap authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cern_meta cgid cgi charset_lite dav_fs dav dav_lock dbd deflate dir disk_cache dump_io env expires ext_filter file_cache filter headers ident imagemap include info ldap log_forensic mem_cache mime mime_magic negotiation php5 proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http proxy rewrite setenvif speling ssl status suexec unique_id userdir usertrack version vhost_alias
    Module name?rewrite
    Module rewrite installed; run /etc/init.d/apache2 force-reload to enable.

    This can also be done like this (say for a non-Debian based OS):

    cd /etc/apache2/mods-enabled
    sudo ln -s ../mods-available/rewrite.load rewrite.load

    There! We have enabled the rewrite module for apache.

    Step 2

    We have to edit /etc/apache2/sites-available/default. Look out for the following lines.

    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny

    Change AllowOverride None to AllowOverride All. Save the File.

    Step 3

    Make sure that the .htaccess file under your Drupal installation folder has the following lines

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </IfModule>

    Step 4

    Restart the apache server

    sudo /etc/init.d/apache2 restart

    Step 5

    Go to your Drupal administration page for clean URLs and enable them.

     
    • Naveen 11:13 pm on May 14, 2008 Permalink | Reply

      Cool da! One of the most educative posts I have come across… continue posting such articles… 🙂

    • Prasanna 10:34 am on May 15, 2008 Permalink | Reply

      Thanks 🙂 Had to hunt lots of places to get the correct combination 😛

    • josh 4:50 am on May 19, 2008 Permalink | Reply

      I do appreciate your write up here but I am sadly lost after trying this in my terninal:
      ls /etc/apache2/mods-enabled

      I am using Mac OS X Leopard.

      I am using MAMP ad my local testing server. I have the Prefs set to PHP 4.

      Could I persuade you to write up something for me to learn how to fix my inability to create clean urls?

      Any help would be greatly appreciated and I can give you more details about my settings.

      Regards,

      Josh

    • Prasanna 5:29 pm on May 19, 2008 Permalink | Reply

      Personally, I have never worked with a Mac. And in India (where I live), a Mac is an extremely rare thing to find :). Hence, I have absolutely no idea about apache on a Mac. Anyhow, what’s your apache version? If its not apache2 then, /etc/apache2 directory will not exist. For apache 1.X, there are other ways to enable modules.

      Basically, for getting clean URLs to work with Drupal, you need the ‘mod_rewrite’ module enabled. This module is by default disabled in a standard apache installation (though I have heard that the latest releases of MAMP come with mod_rewrite enabled). Perhaps you can try this out.

      http://joshuaink2006.johnoxton.co.uk/blog/332/setting-up-an-os-x-development-server-by-an-idiot-

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel