Skip to content

Instantly share code, notes, and snippets.

View mndoci's full-sized avatar

Deepak Singh mndoci

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mndoci on github.
  • I am mndoci (https://keybase.io/mndoci) on keybase.
  • I have a public key whose fingerprint is 3AD7 E277 F8AB 9D56 A881 59FD E7CA 6BFD 380B 2456

To claim this, I am signing this object:

@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 / aws-cli-jq
Last active December 12, 2015 06:19
Various AWS cli calls parsed using jq
aws ec2 describe-images | jq '.Images[] | {name, description}'
aws ec2 describe-instances | jq -c '.Reservations[] | .Instances[] | {InstanceId, InstanceType}'
aws ec2 describe-instances | jq -c '.Reservations[] | .Instances[] | {InstanceId, InstanceType, PublicIpAddress}'
@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'
#!/bin/bash
# from http://www.hilarymason.com/blog/bash-get-http-response-codes-for-a-list-of-urls/
while read line
do
echo $(curl --write-out %{http_code} --silent --output /dev/null $line)
done <$1
@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!"