Skip to content

Instantly share code, notes, and snippets.

View mndoci's full-sized avatar

Deepak Singh mndoci

View GitHub Profile
@mndoci
mndoci / aws_app.rb
Created February 7, 2013 17:22 — forked from yoppi/aws_app.rb
require 'aws-sdk'
require 'yaml'
tag_name = ARGV.shift
tag_values = ARGV
AWS.config(YAML.load_file('config.yml'))
p AWS::EC2.new.instances.tagged(tag_name).tagged_values(tag_values).map {|instance|
instance.public_dns_name
}.join(" ")
@mndoci
mndoci / config.yml
Created February 5, 2013 13:49 — forked from seratch/config.yml
access_key_id: xxx
secret_access_key: yyy
gem 'aws-sdk'
require 'rubygems'
require 'aws-sdk'
ec2 = AWS::EC2.new(:access_key_id => nil,
:secret_access_key => nil,
:proxy_uri => ENV['HTTPS_PROXY'] || ENV['https_proxy'] || ENV['HTTP_PROXY'] || ENV['http_proxy'])
ec2.regions.each do |region|
reg = ec2.regions[region.name]
reg.instances.each do |instance|
@mndoci
mndoci / launch_instances
Created August 5, 2012 17:04 — forked from jlindsey/launch_instances
Launch AWS instances
#!/usr/bin/env ruby
# Require gems with versions
begin
require 'logger'
require 'rubygems'
gem 'fog', '~> 0.6.0'
gem 'trollop', '~> 1.16.2'
require 'fog'; require 'trollop'
@mndoci
mndoci / iam_fog.rb
Created May 29, 2011 03:48 — forked from zapnap/iam_fog.rb
Using Amazon IAM with Fog (example)
# via http://blog.zerosum.org/2011/03/02/better-aws-access-control-with-iam-and-fog.html
require 'fog'
username = 'testuser'
bucket = 'uniquebucketname1234'
aws_credentials = {
:aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
:aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY'
@mndoci
mndoci / 1_aws.rb
Created February 26, 2011 20:43 — forked from geemus/0_rackspace.rb
Forked from Geemus
compute.import_key_pair(
'id_rsa.pub',
File.read('~/.ssh/id_rsa.pub')
)
compute.authorize_security_group_ingress(
'CidrIp' => '0.0.0.0/0',
'FromPort' => 22,
'IpProtocol' => 'tcp',
'GroupName' => 'default',
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
# Check this out, rvm use rbx
ruby_block "rvm use rbx" do
block do
Chef::Mixin::Command.popen4('bash -l -c "rvm use 1.9.1 && env"') do |p,i,o,e|
o.each_line do |line|
env_bits = line.split("=")
ENV[env_bits[0]] = env_bits[1]
end
end
@mndoci
mndoci / wordpress.rb
Created October 8, 2010 06:22 — forked from henrik/wordpress.rb
Getting Wordpress into Jekyll
require 'rubygems'
require 'sequel'
require 'fileutils'
require 'cgi'
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
@mndoci
mndoci / friendfeed2mongodb.rb
Created January 6, 2010 15:10 — forked from neilfws/friendfeed2mongodb.rb
From Neil Saunders I think
#!/usr/bin/ruby
require "rubygems"
require "mongo"
require "json/pure"
require "open-uri"
# db config
db = Mongo::Connection.new.db('friendfeed')
col = db.collection('lifesci')