Skip to content

Instantly share code, notes, and snippets.

View deepakprasanna's full-sized avatar

Deepak Prasanna deepakprasanna

View GitHub Profile
shikeb@psi:~/rails$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 130 commits.
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .gitignore
# modified: Gemfile
shikeb@psi:~/rails$ git stash list
stash@{0}: WIP on master: 95fdaf9 Merge branch 'master' of github.com:lifo/docrails
shikeb@psi:~/rails$ git stash pop
# On branch master
# Your branch is ahead of 'origin/master' by 131 commits.
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
shikeb@psi:~/rails$ git stash list <--- Nothing in the stash location.
shikeb@psi:~/rails$ git stash
Saved working directory and index state WIP on master: 95fdaf9 Merge branch 'master' of github.com:lifo/docrails
HEAD is now at 95fdaf9 Merge branch 'master' of github.com:lifo/docrails
shikeb@psi:~/rails$ git stash list
stash@{0}: WIP on master: 95fdaf9 Merge branch 'master' of github.com:lifo/docrails <--- State of the index has been stashed.
shikeb@psi:~/rails$ git status
# On branch master
This is file
@deepakprasanna
deepakprasanna / mig.rb
Created September 6, 2011 15:42
Rails 3.1 Migrations
####Before Rails 3.1
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.string :email
t.timestamps
end
end
@deepakprasanna
deepakprasanna / migration.rb
Created September 6, 2011 15:41
Rails 3.1 Migrations
#Before Rails 3.1
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.string :email
t.timestamps
end
end
if(params[:user][:own_organizations_attributes])
params[:user][:own_organizations_attributes][:org_phone_number] = params[:user][:contact_number].to_i
resource.own_organizations_attributes = params[:user][:own_organizations_attributes]
resource.time_zone = params[:user][:time_zone]
end
#role membership after create
if self.organization.contact_number.nil?
self.organization.update_attributes(:contact_number => self.user.contact_number)
end
@deepakprasanna
deepakprasanna / doc_pdf_crawler.rb
Created June 14, 2011 09:42
Jruby script which parses the PDF/doc/docx files.
JARS_PATH = File.join(RAILS_ROOT, "lib/jars")
Dir["#{JARS_PATH}/*jar"].each {|j| require j} #Suck the jars.
require "java"
import org.apache.pdfbox.pdfparser.PDFParser
import org.apache.pdfbox.pdmodel.PDDocument
import org.apache.pdfbox.util.PDFTextStripper
import org.apache.poi.extractor.ExtractorFactory
#importing all the required classes.
Some more interesting things that I found
===========================================
1. Empty array has a hidden boolean value of false
arr = []
arr == false // Evaluates to true.
///////////////////////////////////////////////////////////////////
2. Concat
var a = 0;
a == false // Evalutes to true