Skip to content

Instantly share code, notes, and snippets.

View parolkar's full-sized avatar

Abhishek Parolkar parolkar

View GitHub Profile
## Rails development best practices
# An #RMM alternative, open and collaborative set of development practices we can adhere to.
* Distributed Version Control over relying on the File System
* Business Logic in the Models over being spread throughout the MVC layers
* RESTful Architecture over overloaded controllers
* KISS - Short methods with descriptive names
* Tests/Specs covering each layer of MVC and the whole stack
* Document the setup procedure (freeze dependancies where possible)
* Allow developers to listen to favorite music while coding, Put them in zero interruption zone
@parolkar
parolkar / httpdump
Created April 4, 2009 03:35 — forked from peterc/httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*""
# All the above tested only on OS X.
# urlmonitor - print out the URLs requested system wide on the main network interface
# Accept a network interface name as an optional argument
iface = ARGV.first
# No interface specified? Try to guess which one is king..
unless iface
`ifconfig -l`.split.each do |iface|
next if iface =~ /^lo/
break if `ifconfig #{iface}` =~ /inet (0|1|2)/
# SUPER DARING APP TEMPLATE 1.0
# By Peter Cooper
# Link to local copy of edge rails
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' }
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
#!/usr/bin/env ruby
#
# Example:
# $: git log --numstat -w --summary --date=iso | this.rb
# <timestamp> <added> <deleted>
#
require "time"
DATE = /^Date:(.*)/
DIFF = /^(\d+)\s+(\d+)/
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
class UsersController < ApplicationController
respond_to :html, :xml, :json
# GET /users
# GET /users.xml
def index
@users = User.all
respond_with(@users)
end
#!/bin/bash
echo "Setting up chef..."
sudo apt-get -y update
sudo apt-get -y install ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential wget ssl-cert
cd /tmp
wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.4.tgz
tar zxf rubygems-1.3.4.tgz
@parolkar
parolkar / 0what.md
Created August 24, 2009 16:28 — forked from defunkt/0what.md

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

require 'redis'
module Nanite
class State
include Enumerable
# this class encapsulates the state of a nanite system using redis as the
# data store. here is the schema, for each agent we store a number of items,
# for a nanite with the identity: nanite-foobar we store the following things:
#