Skip to content

Instantly share code, notes, and snippets.

View kogent's full-sized avatar

Mark Carey kogent

View GitHub Profile
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1382624667 -28800
# Thu Oct 24 22:24:27 2013 +0800
# Node ID dd6d51b7e12be5fab94a8779e890c5558e4d4001
# Parent 86a3bc5c8ff689a291e86950a3d8fd327f42b870
partial import
wiggled scp
@kogent
kogent / .autotest
Created December 3, 2008 18:58 — forked from nicksieger/.autotest
# -*- ruby -*-
module AutoGrowl
def self.pt(msg)
msg.gsub %r{\\e\[[0-9]+m?}, ''
end
def self.growl(title, msg, pri = 0)
system "/usr/local/bin/growlnotify -n autotest --image /Applications/Mail.app/Contents/Resources/Caution.tiff -p #{pri} -m #{pt msg.inspect} #{pt title.inspect}" unless RUBY_PLATFORM =~ /java/
end
# Simple example of using ShadowFacter with RSpec to verify system configuration
# http://twitter.com/bradleyktaylor | http://railsmachine.com
#
# run with 'spec -c installed_test.rb'
require 'shadow_facter'
def installed_fact(n)
name = n
fact(name) { exec("#{name.to_s} --version") ? true : false }
@kogent
kogent / httpdump
Created June 22, 2009 04:18 — 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.
# This is a useful little pattern for working with gems without
# explicitly requiring rubygems in your code.
#
# The approach taken is to require a library and catch any LoadError
# that might get thrown. In the rescue clause we require rubygems.
#
# The require method is nice in that it will return true if the code
# was loaded, and it returns false if the code was _already_ loaded.
# If the require of rubygems returns true, we will retry our original
# require. It will either succeed this time (since we now have rubygems
@kogent
kogent / bench.rb
Created July 2, 2009 04:45 — forked from lifo/bench.rb
require 'rubygems'
require 'curb'
require "net/http"
require 'benchmark'
# http://0.0.0.0:8080
#
# class HomeController < ApplicationController
# def index
# sleep 3
@kogent
kogent / 0what.md
Created August 24, 2009 03:55 — 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?

@kogent
kogent / debug.rb
Created December 8, 2009 20:33 — forked from tmm1/debug.rb
# collect information about a running process
# ruby debug.rb <pid>
begin
raise ArgumentError unless pid = ARGV[0]
pid = pid.to_i
raise ArgumentError unless pid > 0
Process.kill(0,pid)
rescue TypeError, ArgumentError
raise 'pid required'
@kogent
kogent / mini.rb
Created February 24, 2010 19:19 — forked from defunkt/mini.rb
##
# test/spec/mini 5
# http://gist.github.com/307649
# chris@ozmm.org
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
def self.test(name, &block)
@kogent
kogent / url_dsl.rb
Created February 24, 2010 19:40 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json