Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
yum update -y
yum install httpd24 -y
service httpd start
chkconfig httpd on
EC2_AVAIL_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id/`
echo "<html><body><h1>Hello, this is Instance ID
${INSTANCE_ID} located in ${EC2_AVAIL_ZONE}</h1></body></html>" > /var/www/html/index.html
@gaurish
gaurish / redisinfo.go
Created March 20, 2017 21:46
Returns redis memory info as JSON over HTTP for monitoring
package main
import (
"encoding/json"
"log"
"net/http"
"os"
"strings"
"fmt"
, [2017-01-01T19:03:35.482568 #8908] INFO -- default-ubuntu-1404: -----> Creating <default-ubuntu-1404>...
I, [2017-01-01T19:03:37.537206 #8908] INFO -- default-ubuntu-1404: Bringing machine 'default' up with 'virtualbox' provider...
I, [2017-01-01T19:03:37.985949 #8908] INFO -- default-ubuntu-1404: ==> default: Importing base box 'bento/ubuntu-14.04'...
I, [2017-01-01T19:03:47.400931 #8908] INFO -- default-ubuntu-1404: ^MProgress: 20%^MProgress: 30%^MProgress: 40%^MProgress: 50%^MProgress: 60%^MProgress: 70%^MProgress: 80%^MProgress: 90%^M==> default: Matching MAC address for NAT networking...
I, [2017-01-01T19:03:47.541321 #8908] INFO -- default-ubuntu-1404: ==> default: Checking if box 'bento/ubuntu-14.04' is up to date...
I, [2017-01-01T19:03:52.775636 #8908] INFO -- default-ubuntu-1404: ==> default: A newer version of the box 'bento/ubuntu-14.04' is available! You currently
I, [2017-01-01T19:03:52.775702 #8908] INFO -- default-ubuntu-1404: ==> default: have version '2.2.7'. The latest is version '
@gaurish
gaurish / README.md
Created November 2, 2016 10:26 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


Index:

var http = require('http');
var options = {
host: 'api.twitter.com',
port: 80,
path: '/1/statuses/public_timeline.json'
};
http.get(options, function(res) {
console.log('Got response ' + res.statusCode);
@gaurish
gaurish / db.md
Created December 2, 2013 01:30
rails database best practices
  • null: false, use default value
  • use FKs
  • Use dependant destroy/delete_all/delete_error etc
  • retry ActiveRecord::RecordNotUnique, rescue_from
@gaurish
gaurish / Gemfile
Last active December 28, 2015 21:19
Web Scrapper to get election data
gem 'mechanize'
gem 'pry'
gem 'awesome_print'
gem 'logger'
gem 'activesupport'
$ rvm install jruby
$ rvm use jruby
$ bundle install
$ cd actionpack
$ ruby --client -Itest:lib test/controller/live_stream_test.rb -n test_async_stream
Run options: -n test_async_stream --seed 16798
# Running:
@gaurish
gaurish / nginx.conf
Created November 5, 2013 17:23
nginx config to run http://xyz.com as rails app and run http://xyz.com/blog as wordpress blog. uses fcgi to serve the PHP app & memcache to speed up your blog
location /blog {
index index.html index.php;
#try_files $uri $uri/ /blog/index.php?q=$uri;
try_files $uri $uri/ @memcached;
location ~ \.(css|js|jpg|jpeg|png|gif)$ {
expires 7d;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
add_header "Vary" "Accept-Encoding";
}
@gaurish
gaurish / shell.sh
Created October 1, 2013 07:47
Why this warning?
$ jruby --version
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) Server VM 1.7.0_40-b43 +indy [linux-i386]
$ bundle
Java HotSpot(TM) Server VM warning: You have loaded library /home/gaurish/.rvm/rubies/jruby-1.7.4/lib/native/x86_64-Linux/libjffi-1.2.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Fetching gem metadata from https://rubygems.org/..