Skip to content

Instantly share code, notes, and snippets.

View krishna-shilpakar's full-sized avatar

krishna shilpakar krishna-shilpakar

View GitHub Profile
Use TCPDUMP to Monitor HTTP Traffic
1. To monitor HTTP traffic including request and response headers and message body:
tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
2. To monitor HTTP traffic including request and response headers and message body from a particular source:
tcpdump -A -s 0 'src example.com and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
3. To monitor HTTP traffic including request and response headers and message body from local host to local host:
require "amqp"
EventMachine.run do
connection = AMQP.connect
channel = AMQP::Channel.new(connection)
replies_queue = channel.queue("citizen40.install.app.acknowledge", :exclusive => true, :auto_delete => true)
replies_queue.subscribe do |metadata, payload|
puts "[response] Response for #{metadata.correlation_id}: #{payload.inspect}"
# if payload[:success] == true
require "amqp"
EventMachine.run do
connection = AMQP.connect
channel = AMQP::Channel.new(connection)
requests_queue = channel.queue("citizen40.install.app", :exclusive => true, :auto_delete => true)
requests_queue.subscribe(:ack => true) do |metadata, payload|
puts "[requests] Got a request #{metadata.message_id}. Sending a reply..."
# codes that will install the softwares.
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@krishna-shilpakar
krishna-shilpakar / .irbrc
Created November 23, 2012 05:02 — forked from adamcrown/.irbrc
My Bundler proof .irbrc file including wirble, awesome_print, hirb, console logging and route helpers
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
def unbundled_require(gem)
loaded = false
if defined?(::Bundler)
Gem.path.each do |gems_path|
gem_path = Dir.glob("#{gems_path}/gems/#{gem}*").last
@krishna-shilpakar
krishna-shilpakar / sublime-text-2-settings
Created September 25, 2012 10:28 — forked from olivierlacan/sublime-text-2-settings.json
Basic Sublime Text 2 settings for Rails development
{
"use_simple_full_screen": false,
// calculates indentation automatically when pressing enter
"auto_indent": true,
// sets the colors used within the text area (default)
// see https://github.com/olivierlacan/monokaim to download
// the customized Monokai I use.
"color_scheme": "Packages/Color Scheme - Default/Monokaim.tmTheme",
@krishna-shilpakar
krishna-shilpakar / rails-rspec-capybara.md
Created August 15, 2012 08:36
Rails with rspec, capybara

#Rails with Rspec, Capybara (with selenium driver), FactoryGirl #

Generate new app, skipping Test::Unit file generation and skipping bundle

rails new my_app -T --skip-bundle

Setup Gemfile

@krishna-shilpakar
krishna-shilpakar / index.md
Created March 21, 2012 05:49 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@krishna-shilpakar
krishna-shilpakar / .gitconfig
Created March 2, 2012 08:18 — forked from millisami/.gitconfig
Global settings for git at ~/.gitconfig
[user]
name = your_username
email = [email protected]
[github]
user = github_username
token = github_your_own_token
[core]
#Global .gitignore file
excludesfile = /Users/millisami/.gitignore
editor = mate -w
@krishna-shilpakar
krishna-shilpakar / rails31init.md
Created February 8, 2012 06:10 — forked from jraines/rails31init.md
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile