Skip to content

Instantly share code, notes, and snippets.

View Gurpartap's full-sized avatar
:octocat:
Working from home

Gurpartap Singh Gurpartap

:octocat:
Working from home
View GitHub Profile
@mrrooijen
mrrooijen / Capistrano-Deployment-Recipe.rb
Created July 29, 2009 09:34
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
module Bluepill
module ProcessConditions
class ProcMemUsage < MemUsage
def run(pid)
begin
total = 0
File.read("/proc/#{pid}/smaps").split("\n").each do |line|
line =~ /^(Private)_Dirty: +(\d+)/
if $2
total += $2.to_i
@assimovt
assimovt / chef.rb
Created May 13, 2010 16:36
Chef cookbook
# cookbooks/chef/attributes/chef.rb
set_unless[:chef][:log_location] = "STDOUT"
set_unless[:chef][:log_level] = "info"
set_unless[:chef][:url_type] = "http"
set_unless[:chef][:server_fqdn] = "your-chef-server"
set_unless[:chef][:server_port] = "4000"
set_unless[:chef][:validation_client_name] = "chef-validator"
set_unless[:chef][:cache_path] = "/var/cache/chef"
@gisikw
gisikw / advanced.feature
Created June 9, 2010 01:47
Examples for Interactive Aruba Steps
Feature: Advanced scripting
As a My script writer
I want to nest tasks inside of questions
So I can respond dynamically to the user's needs
@aruba_interactive
Scenario: Nesting questions
Given a file named "yes.template" with:
"""
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Border Image Test</title>
<style type="text/css">
#slider {
/*This shows how to use border-image to mimic the behavior
of stretchableImageWithLeftCapWidth:topCapHeight: in CSS.
This example has a border-left and border-right width of 15px.
@octplane
octplane / mongo_pubsub.rb
Created November 9, 2010 16:17
Simple Pub/Sub system using MongoDB, capped collections and tailable cursors in ruby
require 'rubygems'
require 'mongo'
module MongoPubSub
QUEUES_COLLECTION = 'queues'
class EndSubscriptionException < Exception; end
class Publisher
def initialize(queue_name, mongo_connection)
# Initialize queue collection as a capped collection
if not mongo_connection[QUEUES_COLLECTION].collection_names.include?(queue_name)
@beanieboi
beanieboi / mongoid version diff
Created January 26, 2011 13:13
shows the diff between two versions when you use Mongoid::Versioning
def compare_to(version)
reject_fields = ["_id", "updated_at", "version"]
diff_array = self.versions[version-1].attributes.to_hash.to_a - self.attributes.to_hash.to_a
diff_array.delete_if {|f| reject_fields.include?(f.first) }
Hash[diff_array]
end
@bradwright
bradwright / linode-secure-ubuntu-stackscript.sh
Created February 13, 2011 19:56
StackScript to make a more secure Ubuntu server install out of the box
#!/bin/bash
# Setup script designed to get a Ubuntu 10.4 LTS server
# up and running with secure defaults.
# Documentation for StackScripts
# is pretty sparse: see http://www.linode.com/stackscripts/
# User-inputted values for new Linode
# <UDF name="user_hostname" Label="Hostname for new Linode" />
@mipearson
mipearson / cfn_dsl_mockup.rb
Created February 28, 2011 05:13
Mockup for a DSL to generate Amazon CloudFormation configurations
# Based on half of https://s3.amazonaws.com/cloudformation-templates-us-east-1/WordPress-1.0.0.template
# Methods beginning with a lowercase letter are 'native' and have special behaviour.
# Methods beginning with an uppercase letter get literally transformed into JSON
templates do
Alarm do
EvaluationPeriods 1
Statistic 'Average'
Period 60
AlarmActions: ref('AlarmTopic')
@denmarkin
denmarkin / mysql.god.rb
Created May 10, 2011 07:45
God recipes examples for Rackspace Cloud (Ubuntu) with resque and php-cgi. Try any of them with "sudo god -c /path/to/config -D"
God.watch do |w|
w.name = "mysqld"
w.interval = 30.seconds # default
w.start = "service mysql start"
w.stop = "service mysql stop"
w.restart = "service mysql restart"
w.start_grace = 20.seconds
w.restart_grace = 20.seconds
w.pid_file = "/var/lib/mysql/hostname.pid"