Saturday, October 27, 2012

Lazy Coder Camp (Edition 1)

What is Lazy Coder Camp?

Lazy Coder Camp is a user generated conference primarily focused around technology that supports minimalistic programming/coding. The event will be dabbling on conducting camps and workshop events where there is little programming involved. This is an armchair approach to early stage web application development and open source technologies.

This is a community based event and anyone is welcome to join the team as volunteer in organizing future editions. The format of the Lazy Coder Camp will be both learning and hands on workshop focused on various domains.

Lazy Coder Camp (Edition 1)
Come and join us during the launch of Lazy Coder Camp!

The first edition of the camp is a daylong event that is totally free for IT enthusiasts and students to attend. We will be discussing about bootstrapping Drupal. The discussion will cover all aspects of Drupal installation, setting up a basic website and integrating all your social media streams to your basic site. The event will serve as a great learning opportunity for young professionals from other domains to come experience Drupal first hand with the PHP experts. The speakers will bring their unique experiences and insights to share with the audience and will be addressing all apprehensions related to taking up Drupal development.

Note :
  • All attendees who would like to come for the day long workshop cum training its mandatory to carry your laptop to experience installation and customisation first hand.
  • To attend register immediately as we have very limited seats and will be served on first come first basis.
  • Please check back regularly for the most recent updates to our agenda and list of speakers.
  • For any questions, or inquiries regarding speaking or exhibiting at future editions of Lazy Coder Camp, please contact

Monday, August 1, 2011

Truncate all tables in a particular database using a single line command.

Generally if you like to truncate or empty all the records in a database containing more no. of tables, use the below command to do it. It really helps to remove all the records completely only having the structure of the tables left in a database.

mysql -u {user-name} -p {database-name} -BNe "show tables" | awk '{print "TRUNCATE TABLE " $1 ";"}' | mysql -u {user-name} -p {database-name}

Let me know if it doesn't works you out.

Tuesday, May 17, 2011

Dumping Multiple Selected MySQL Tables as SQL

Not sure if anybody already figured out how to dump the selected mysql tables from a particular database. But after googling I found some way which helped me how to proceed and adding my thought little & attained what I need. Ok, not bugging you too much, here is my requirement:

I need to dump 5 tables (employee, address, salary, attendance, payslip) & the tables whose name starts with map_* in a single command.

What I know from the syntax is that I can append as many table name with the mysqldump to get the dump of all the tables.mysqldump -u{user} -p {database} {table1} {table2} {table3} > {destination}.sql
but what here missing is that I can add map_* tables which is really important for me to proceed further.

As said, after googling I got the site and understood how to get map_* tables include with the mysqldump.

The referred site provided me something like this..
mysql databasename -u [root] -p[password] -e 'show tables like "wp_153_%"' | grep -v Tables_in | xargs mysqldump [databasename] -u [root] -p[password] > [target_file]

but what I modified to get my requirement complete is
mysql {databasename} -u {root} -p{password} -e 'show tables like "wp_153_%"' | grep -v Tables_in | xargs mysqldump {databasename} -u {root} -p{password} {table1} {table2} {table3} > {destination}.sql

So my final output was
mysql employeeDB -u root -p -e 'show tables like "map_%"' | grep -v Tables_in | xargs mysqldump employeeDB -u root -p employee address salary attendance payslip > destination.sql

Hope NO other better option than this.

Note: I have remove {password} from my command as I think we should not execute the password in the command line instead asking us

Monday, May 16, 2011

Reading PDF and converting to CSV using RubyCode & pdf-reader plugin

I wanted to convert a PDF document into a XLS table and after a couple of searches I could easily able to write the code in ruby and converted a Citibank PDF Statement to CSV file. This gave me enough relief that I learnt how to read a PDF file if its not password protected.

require 'rubygems'
require 'pdf/reader'
class PageTextReceiver
  attr_accessor :content

  def initialize
    @kk = "false"
    @i = 0
    @ptr_str = ""

  def begin_page(arg=nil)
    puts ""

  def show_text(string, *params)
    if string.strip=="Previous Balance"
    if @i==4
      puts @ptr_str
      @ptr_str = ""
    if string.strip=="Sale Date" or @kk == "true"
      if @i==0
        @ptr_str << string + "/2009,"
        @ptr_str << string + ","
      if (string.reverse.index(".")==2 or string=="Amount (in Rs)")

  def move_to_next_line_and_show_text

  alias :super_show_text :show_text
  alias :set_spacing_next_line_show_text :show_text

  def show_text_with_positioning(*params)
    params.each { |str| show_text(str) if str.kind_of?(String) }

receiver =
(1..45).each do | x |
  pdf = PDF::Reader.file("#{x}.pdf", receiver)
  puts receiver.content.inspect

The above code use to read 45 pdf files. Say the above code is saved in read_pdf.rb

Below is the command to execute the file and store in a file (which I hope the easiest way)
ruby read_pdf.rb >> a.csv
hope it helps you ? or If you know how to read a PDF which is password protected thru code, where I can input the password of the file, please let me know.

Tuesday, January 4, 2011

rmagick installation for MacOSX

Try the below following steps to install rmagick using macports.

sudo port install tiff -macosx imagemagick

If you get an error like this..

Error: Checksum (md5) mismatch for lcms-1.19.tar.gz
Error: Checksum (sha1) mismatch for lcms-1.19.tar.gz
Error: Checksum (rmd160) mismatch for lcms-1.19.tar.gz

then execute the below commands
sudo port selfupdate
sudo port clean --all lcms
sudo port install tiff -macosx imagemagick

now try this below command to really work for Rails

sudo gem install rmagick

hope it helps you ?