This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | -- bundle exec rake db:migrate | |
| -- Level 1 | |
| -- Migrating Country | |
| INSERT INTO countries(name) | |
| SELECT DISTINCT(CountryName) | |
| FROM 527433_iec.iec_country; | |
| -- Migrating Branch | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Get into organizor database | |
| TRUNCATE countries; | |
| ALTER TABLE countries CHANGE id id INT(11) NOT NULL; | |
| insert into organizor.countries (id, name) select CountryId, CountryName from 527433_iec.iec_country; | |
| ALTER TABLE countries MODIFY id INTEGER NOT NULL AUTO_INCREMENT; | |
| TRUNCATE branches; | |
| ALTER TABLE branches CHANGE id id INT(11) NOT NULL; | |
| insert into organizor.branches (id, name, address_line1, email, country_id) select BranchId, BranchName, Address, Email, country from 527433_iec.iec_branch; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'mechanize' | |
| sample_url = "www.example.com" | |
| agent = Mechanize.new | |
| page = agent.get sample_url | |
| raw_link = [] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | set nocompatible | |
| filetype off | |
| set rtp+=~/.vim/bundle/vundle/ | |
| call vundle#rc() | |
| " size of a hard tabstop | |
| set tabstop=2 | |
| " size of an indent" | |
| set shiftwidth=2 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'mechanize' | |
| url = "https://www.google.co.in/" | |
| agent = Mechanize.new | |
| page = agent.get url | |
| google_form = page.form | |
| google_form['q'] = 'hot deal' | |
| search_page_1 = google_form.submit | |
| search_page_1.uri.to_s | |
| url = "/url?q=http://www.infibeam.com/Hot_Deals/search&sa=U&ei=xOxZVKyuFM6IuwSDs4LgAQ&ved=0CCYQFjAA&usg=AFQjCNFTGXidISz5Op1fDPDkbDTYf9-Nwg" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'nokogiri' | |
| require 'open-uri' | |
| doc = Nokogiri::HTML(open("http://shop.8and9.com/")) | |
| data = [] | |
| urls = doc.search('a') | |
| urls.each do |x| | |
| url = x['href'] | |
| if !url.nil? and url.match('^\/collections') | |
| data << x | |
| end | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | sed -n "/^COPY mytable/,/^\\\.$/p" mysqldump.sql > mytable.sql | |
| Steps: | |
| Truncate your existing table. | |
| Import mytable.sql to your database. | |
| psql -U username -d database_name -f mytable.sql | |
| Now, all your mytable data from huge mysqldump.sql is moved to database. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | namespace :backup do | |
| task db: :environment do | |
| if ENV['RAILS_ENV'] | |
| file = YAML.load_file("#{Rails.root}/config/database.yml") | |
| db = file[ENV['RAILS_ENV']] | |
| time = Time.now.strftime("%Y%m%d%H%M") | |
| pgdump = "cd && PGPASSWORD=#{db['password']} pg_dump -U #{db['username']} -f #{time}_backup.sql #{db['database']}" | |
| system(pgdump) | |
| else | |
| p "Please provide RAILS_ENV=(development or production or test)" | 
NewerOlder