Skip to content

Instantly share code, notes, and snippets.

View rajeevkannav's full-sized avatar

Rajeev Sharma rajeevkannav

View GitHub Profile
@rajeevkannav
rajeevkannav / gist:2212477
Created March 27, 2012 04:14 — forked from ascrivner-zz/gist:120346
Deploying a Rails App with EC2 + S3 + Ubuntu
Deploying a Rails App with EC2 + S3 + Ubuntu
============================================
Create EC2 Instance
-------------------
create new instance ami-bf5eb9d6 [http://alestic.com/](http://alestic.com/)
create new elastic ip
attach elastic ip to instance
point dns to elastic ip
@rajeevkannav
rajeevkannav / README.md
Created April 4, 2012 10:36 — forked from nebojsaz/README.md
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby 1.9.2 via RVM, MySQL, and Passenger for deploying Rails 3.1 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@rajeevkannav
rajeevkannav / README.md
Created April 4, 2012 10:59 — forked from jpantuso/README.md
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@rajeevkannav
rajeevkannav / _pm_irbrc.rb
Created May 21, 2012 11:07 — forked from inkdeep/_pm_irbrc.rb
Useful method to print an objects methods in an irb/console session.
# pm - Print methods of objects in irb/console sessions.
# Goes in ~./irbrc
#
begin # Utility methods
def pm(obj, *options) # Print methods
methods = obj.methods
methods -= Object.methods unless options.include? :more
filter = options.select {|opt| opt.kind_of? Regexp}.first
methods = methods.select {|name| name =~ filter} if filter
@rajeevkannav
rajeevkannav / gist:4110435
Created November 19, 2012 12:37 — forked from Irio/gist:1496746
Solution for "cannot load such file -- openssl" on RVM
When I tried run "rake test", I received:
rake aborted!
cannot load such file -- openssl
Tasks: TOP => test:units => test:prepare => db:test:prepare => db:abort_if_pending_migrations => environment
(See full trace by running task with --trace)
require 'rss'
p 'Downloading rss index'
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
videos_filenames = videos_urls.map {|url| url.split('/').last }
existing_filenames = Dir.glob('*.mov')
@rajeevkannav
rajeevkannav / ymlrb.rb
Last active December 11, 2015 13:08
To Covert Given Data Strcutre to YML
###################################################################################################
############### To Covert Given Data Strcutre to YML ####################
###################################################################################################
# Example Data Strcutre USED
# {'root' => {'recog' => [{:day => 1, :month => 2},{:day => 1, :month => 2},{:day => 1, :month => 2}],'delivery' => [{:day => 1, :month => 2},{:day => 1, :month => 2},{:day => 1, :month => 2}],'third' => [{:day => 1, :month => 2},{:day => 1, :month => 2},{:day => 1, :month => 2}]}}
require 'yaml'
puts "Enter your Specified Data Strcutre withOut Quotes"
required_ds = gets.chomp
#################################### Solution ####################################
#### Module Rulecheck ####
module Rulecheck
TO_BLOCK = ['!']
def parse(string)
TO_BLOCK.each do |to_block|
return string.include?(to_block)
end
end

Ubuntu 12.04 Ruby on Rails Development Environment

I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.

As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.

Step 1: Get the repos ready and run updates.

sudo apt-get update && sudo apt-get upgrade
@rajeevkannav
rajeevkannav / gist:5211358
Last active December 15, 2015 05:48
Hash Filer unique
Use : hash.invert.invert
Fuck what is wrriten below
hash = {"0"=>{"name"=>"app1103key1", "value"=>"app1103value1", "_destroy"=>"true", "id"=>""}, "1"=>{"name"=>"version102key2",
"value"=>"version102value2"}, "2"=>{"name"=>"version102key1", "value"=>"version102value1"}, "3"=>{"name"=>"version102profile2key1", "value"=>"version102profile2value1"}, "4"=>{"name"=>"app1-103profilekey1", "value"=>"app1-103profilevalue1"}, "5"=>{"name"=>"app1-103profilekey1", "value"=>"app1-103profilevalue1"},"6"=>{"name"=>"version102key1", "value"=>"version102value1"}}
merged_list = {}
hash.values.each do |item|
if merged_list.has_key? item['name']
merged_list[item['name']].merge! item