Monday, November 9, 2009

Rails migration

  • Add/Remove index
  • add_index :table_name, :column_name remove_index :table_name, :column_name
  • Add fulltext index via "execute"
  • execute SQL_QUERY


See more at Migration Cheat Sheet

Tuesday, October 6, 2009

PNG optimizers

These days, one of my main tasks is to reduce the loading time for ForeCite (FC) reader - a web interface which allows users to read and annotate academic papers. I'll write a more thorough introduction about it in my next entries.

Since FC reader needs to display quite a number of PNG images, each image corresponds to a page in a paper. Thus, by reducing the size of the images, I hope to reduce the loading time of FC reader.

What follows are two PNG optimizers I've found out today. Basically, these tools help to recompress PNG image files to a smaller size, without losing any information

I've tried to run both and PNGout turns out to perform better than OptiPNG in reducing the image file size, however, it does take longer time to run

Thursday, October 1, 2009

Google analytics

To obtain the statistics of ForeCiteNote's traffic, I use Google Analytics(GA) - a free web tracking service offered by Google. In short, GA helps you to know how visitors find your page, how they interact with it and from that information, you may enhance your page to meet the users' need.

You can incorporate GA into your website in 4 simple steps . First of all, you need a Google Account to login to GA. Next, you enter the name of your site and its URL. Then, GA asks you to copy the tracking code which is a javascript snippet into every webpage you want to track immediately before the </body> tag . Finally, check the status of your tracking code to see if it's been successfully installed in your webpage. Note that you may need to wait a day before you can get any data from GA.

Wednesday, September 30, 2009

ForeCiteNote

I've come to know about TiddlyWiki 3 years ago, when I first began my final year project. I was recommended to use TiddlyWiki as a tool to keep track of my working progress. One of the main advantanges of TiddlyWiki is its portability. Since it's a single HTML file, you can email it, put it on a web server or share it via a USB stick. Besides, users can customize the appearance as well as the behaviour of TiddlyWiki to almost any degree you want.

Back then I thought this tool is quite useful, that's all that was. I didn't know that I'd have to actually modify TiddlyWiki some day. That day started when I began to work on ForeCiteNote (FCN). FCN is a personal digital library system built on top of TiddlyWiki by our research group WING. FCN aims to support beginning researchers, such as advanced undergraduates and beginning graduate students, take notes and synthesize their ideas in their literature search for related work to their projects. FCN supports following features:

  • Create a note that links to a paper,automatically retrieve metadata for that paper from server, allowing access to PDF file, with keywords/references extracted from the paper
  • Organize notes by tagging and assigning what actions to take
  • Ingest PDFs, BIBs or ZIPs of papers
  • Synchronize your notes with server
  • Publish your notes as public or keep them private
  • Locally organize a user's local document storage


Following is a short demonstration of FCN:


Hpricot

As part of my work, I have to work with a large number of XML files. Since my project is implemented using Ruby on Rails, I first used Rexml to process the XML files. However, when dealing with large XML files, Rexml takes quite long a time to process. Thus, I switched to Hpricot . Though Hpricot is originally written to do HTML parsing, it turns out to be capable of working with XML also. It suits my need in traversing through the XML document and extracting values using XPath queries. Besides, it does help to improve the speed tremendously as compared to Rexml.


However, while using Hpricot, I encountered this error

TypeError: can't convert nil into String from /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot/parse.rb:51:in `scan'


As what I've found in this post, this is a known error, Hpricot can’t handle files whose size is multiple of 16384 bytes. The fix is to add some extra bytes to your "special-sized" files

echo " " >> special_sized_file

Firefox extension

Basic reading for how to develop Firefox extensions can be found here.

Starting my work log today ...

...to keep track of what I've learnt during my working time as a research assistant at National University of Singapore (NUS).