Wednesday, November 26, 2008

Delhi Manali rohtnag-paas and back to Delhi

Recently was on a out-of-station trip to manali and to be precise rohtang paas, with other two friends of mine... trip was dangerous as it was my car which ran this long trip(my swift) and you know what!! i have started loving my car and really proud owner of it :)

here are few of snapshots from trip...

View SlideShare presentation or Upload your own. (tags: delhi manali)


Tuesday, November 25, 2008

Praveen Kumar Sinha @ first in google search

Hey,

Has just returned from a long weekend trip.
A trip from dehi to kullu-manali to rohtang paas and back to delhi... will blog about this later  but after to my surprise and a fair long interval of time 
my blog is coming at no1 in google search result  yaa yaa.. screen shot is available, have a look

 
and in yahoo my linkedin profile, my digg profile are on the first page... feeling happy and feeling great!!!


and will surely talk about the trip.. pakka!!! :))


Tuesday, November 18, 2008

Is there any 'Forward' or just 'Redirect' in RAILS?

I have been thinking from the very start what is the difference between the two? when i just heard this question(refer the heading my dear). and the answer is the 'browser', yes!! the browser...

Redirect means from one controller/action to another controller/action via browser meaning a 302 response is sent after evaluation completes for the first controller/action pair and then the new controller/action is called from the browse( one can see the url changing as a result of this in the address bar)
[this Gyan is achieved by

redirect_to(options = {}, response_status = {})
Redirects the browser to the target specified in options.

&

Forward means hopping to new controller/action from the correct place without going to browser.
but does rails ever legally allowed any thing like forward.. i personally don't think so... (because either i am not aware of it or rails don;t have it) :))

in that case how to implement this forwarding thing(which as such don't exist)
two ways that i can figure it out to achieve is..

1) using "render" i.e by calling some desirable template or other render option(s) for the current controller/action (but issue arises when one need to render action of some other controller, ya ya i know in rails you have your own pilot seat so go ahead :) )

2) is using normal function call i.e calling the action defined as function(with override/non overrides params) and here also drawback is same... but remember to use return after that otherwise DoubleRenderError is for you :)

and quest is on and rest will become history very soon....


Monday, November 17, 2008

Image cut-outs(css style) to make icon display

I am on the development side only when it comes to web portals and all, but many of time i have been asked to do some adjustment in CSS (which i feel undesirable, as i am not even OK in it) and some time these web browser behave in a naughty way

So to the issue to tackle is : How to use small images in icons as small icons are sometimes not loaded in IE (you have to pre load them and things like that in javascript)
and the answer is hidden in CSS (i recently came to know about it and implemented my self)

well for this the prerequisites is to have a images with many small icons inside it like this

and a css style class with something like
.icons {
background-image:url(/images/icon_collection.png);
background-repeat:no-repeat;
display:block;
height:18px;
margin-left:10px;
margin-right:6px;
width:18px;
}

.icon_one {
background-position:-156px -83px;
}

and apply it on div like this
<div class="icons icon_one"> </div>

so that can give result like this ...


point to note is
background-position:x-pos y-pos;

:) happy cssing

Saturday, November 15, 2008

Customized collage from picasa3


Hello world,
This time nothing from the coding side :) . I am just sharing a quicky of a new advanced feature from picasa3… and that is one can customize collage while creating it.

First and foremost thing is that many are not even known to picasa and those of you are aware of it is not aware of its making collage feature and those of you are aware must have noticed it that picasa although use to provide the facility of making a collage but nothing more than that (at max user has the option to randomize the snaps and nothing more), well that was the story of Picasa2.

But good news guys, drawing board has changed and now you are in full control of what you want to show and how to show and how much to show.. an all thanks to picasa3
 

Thursday, November 13, 2008

Hacking out JIRA from atlassian

Note: i am not being negative over here just a bit naughty :)
Relax guys!! i am not actually hacking it out... i have just exploited one of the processes and what purpose it solves.. well it depends...

One can reuse expired evaluation version of JIRA any number of time and successfully running this hack will again grant you one cycle of 30 days evaluation
(this will do work till the time real guys didn't come to know about it :)) )

so now what if you evaluated jira and you liked it but not want to pay (but guys, developers too are human beings so don;t make it a habit :)) ) 

Try this work around.

Even if everything is hanged up at your local jira server, it provides the facility to get the backup in the from of xml(a single file) and system even provides a zipped version too 

so the prerequisite is to have a backup file from the jira running machine and unzip to get the backup XML, and then follow the following steps..

Step 1: Get a JIRA back up and un-compressed it to get the real xml if was compressed.

Step 2: In the XML search in the lines which contains following strings.
<OSPropertyString id="10013"
<OSPropertyString id="10014"

Clear their values.. and the lines should look something like
<OSPropertyString id="10013" value=""/>
<OSPropertyString id="10014" value=""/>

Step 3: Now in the out of date jira... go in section for "Restore data from xml"

Step 4: Provide the modified jira backup file path and jira location file path and <don't> enter any licence........ and click "restore"

Step 5: It will give "JIRA Access Constraints" on the page with some details like 
< 2008-11-12 17:47:07   error   Invalid license key specified. >

Step 6: Click the "Edit License" link, which will take you to "Confirm License Update" page

Step 7: At the bottom of page there is an statement "You can generate an evaluation license instantly online" click the "online" link word which will take you to http://www.atlassian.com

Step 8: Now provide the atlassian credentials i.e email and password.... and log in

Step 9: You will land in "Generate Evaluation License" click the Generate button  and copy the generated "License Key" from the text area

Step 10: Update "License Key" so generated in "Confirm License Update" page and click proceed

if everything remains intact you are done
and now restart the server and you are again up for 30 days

Wednesday, November 12, 2008

Conversion from mysql to sqlite database.. via rails

I faced this problem to have a sqlite database from an existing mysql.. and being the rails guy... i made it the rails way.. but of course there are other option available which will be fast .. this is kind of slow... but works for small stores :))

Steps are..
1. Create a source model which is connected with mysql connection/using mysql adaptor
class SourceDB < ActiveRecord::Base
end
SourceDB.establish_connection($config["database_mysql"])

2. Create a destination model which is connected with sqlite connection/using sqlite adaptor
class TargetDB < ActiveRecord::Base
end
TargetDB.establish_connection($config["database_sqlite"])

3. Create schema from source database so that can reproduce it in destination(sqlite) database.
File.open(name_of_schema_file,"w") do |file|
  ActiveRecord::SchemaDumper.dump(SourceDB.connection, file)
end

4. Alter the generated schema file to remove line which contains "add_index" as these are of no use in sqlite conversion process

5. Then load the altered schema file (change the ActiveRecord::Base.connection to point to destination database before loading)
ActiveRecord::Base.connection = TargetDB.connection
load(name_of_schema_file)

6. and now resurvely iterate with all tables in source database and transport it to derstination (sqlite) database

Source file [mysql_to_sqlite.rb]
require 'rubygems'
require 'active_record'
require 'active_support'
require 'sqlite3'
require 'active_record/schema_dumper'

require "yaml"
require "create_class.rb"

t1 = Time.now
$config   = YAML.load_file("config/config.yml")
name_of_schema_file = ($config["schema_file"])

class SourceDB < ActiveRecord::Base
end
SourceDB.establish_connection($config["database_mysql"])

class TargetDB < ActiveRecord::Base
end
TargetDB.establish_connection($config["database_sqlite"])

puts "dumping the schema"
File.open(name_of_schema_file,"w") do |file|
  ActiveRecord::SchemaDumper.dump(SourceDB.connection, file)
end

puts "discarding index(es)"
line_array = Array.new
File.open(name_of_schema_file,"r") do |file|
  file.each { |line|    line_array << line  unless line.include?("add_index")}
end

File.rename(name_of_schema_file, "original_#{name_of_schema_file}")

File.open(name_of_schema_file,"w") do |file|
  file.puts(line_array)
end

puts "loading the schema"
ActiveRecord::Base.connection = TargetDB.connection
load(name_of_schema_file)


SourceDB.connection.tables.each do |tbl|
  puts "Table_initiated: #{tbl.inspect}"
    SourceDB.set_table_name tbl
    SourceDB.set_inheritance_column ""
    
    create_class('TargetModel', TargetDB) do
      set_table_name tbl
      set_inheritance_column ""
    end
    puts "=========for table: #{tbl}=========="
    total_record_in_table = SourceDB.count_by_sql("SELECT COUNT(*) from #{tbl}")

    tub_size = 1000
    no_of_iteration = ((total_record_in_table % tub_size) == 0) ? (total_record_in_table / tub_size) : ((total_record_in_table / tub_size) + 1)

    for j in 0..(no_of_iteration-1)
      current_record_set = SourceDB.find(:all,:offset => (j*tub_size), :limit => (tub_size - 1))

      current_record_set.each_with_index do |record,ind|
        record_copy = TargetModel.new
        record.attributes.each do |key,value|
        record_copy.send("#{key}=",value)
        end
        record_copy.save
        puts "Completed: #{((j*tub_size) + ind)} of #{total_record_in_table}   with id: #{record_copy.id} ."
      end
    end
end
        
t2 = Time.now

puts "Process initiated at: #{t1}"
puts "Process completed at: #{t2}"
puts "Time elapsed        : #{t2-t1} seconds"

Source file [create_class.rb]
def create_class(class_name, superclass, &block)
  klass = Class.new superclass, &block
  Object.const_set class_name, klass
end

Configuration file [config.yml]
database_mysql:
  adapter: mysql
  database: databse_name
  username: root
  password: xxxxxxxx
  host: xxx.xx.x.xxx
  timeout: 5000
  encoding: utf8

database_sqlite:
  adapter: sqlite3
  database: sqlite_database_file_with_path.db
  
schema_file: schema.txt

Introduction(a bit of me)


Well!!!

to start of

Praveen Kumar Sinha... Indian by heart... &
world by nature(at least to someone)...



and the resume goes like this
riding rails with ruby saddle(and you know what!!! i am lovin it :))

MCA from delhi and the rozi roti media is computers(to be precise, "softwares" and to be more precise, "MPS Technologies Ltd..")

and answer for "kyun" & "why" questions
aweenhee!!!

Product i developed...


Firms is/was associated with...






Honda Civic & A/C problems.

Hello Friends, Got a post again on to Honda Civic (The good old favorite commuter of mine). This car has been doing great except for so...