Skip to content

Instantly share code, notes, and snippets.

@pope
pope / gist:4902
Created August 11, 2008 17:37 — forked from anonymous/gist:4900
require 'autotest/redgreen'
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{ msg.inspect} #{title} #{stick}"
end
Autotest.add_hook :ran_command do |autotest|
results = [autotest.results].flatten.join("\n")
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
@pope
pope / fbr.rb
Created November 15, 2008 15:01 — forked from tmm1/fbr.rb
# Poor Man's Fiber (API compatible Thread based Fiber implementation for Ruby 1.8)
# (c) 2008 Aman Gupta (tmm1)
unless defined? Fiber
require 'thread'
class FiberError < StandardError; end
class Fiber
def initialize
@pope
pope / .bashrc
Created July 8, 2009 19:16 — forked from defunkt/.bashrc
# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# (Thanks to @anildigital and @grundprinzip for curl-fu)
function tweet {
curl -n -d status="$*" https://twitter.com/statuses/update.xml --insecure &> /dev/null
echo "tweet'd"
@pope
pope / .bashrc
Created July 8, 2009 19:17 — forked from defunkt/.bashrc
# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# (Thanks to @anildigital and @grundprinzip for curl-fu)
function tweet {
curl -n -d status="$*" https://twitter.com/statuses/update.xml --insecure &> /dev/null
echo "tweet'd"
#!/usr/bin/env ruby
#
# A hook script to verify that only syntactically valid ruby code is commited.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Put this code into a file called "pre-commit" inside your .git/hooks
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit")
#
=begin
host_ip_info.rb (http://gist.github.com/169374)
Copyright (c) 2009 Jason L Perry
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
# requires "isightcapture" in the cwd (http://www.intergalactic.de/pages/iSight.html)
require "eventmachine"
INTERVAL = 20
EM::run do
timer = EM::PeriodicTimer.new(INTERVAL) do
time = Time.now.strftime("%Y%m%d%H%M%S")
system "./isightcapture #{time}.jpg &"
puts time
@pope
pope / echo.c
Created October 19, 2009 23:48 — forked from paulsmith/echo.c
/**
* A simple preforking echo server in C.
*
* Building:
*
* $ gcc -Wall -o echo echo.c
*
* Usage:
*
* $ ./echo
@pope
pope / gist:262117
Created December 22, 2009 22:27 — forked from ezmobius/gist:262085
require 'rubygems'
require 'redis'
require 'json'
require 'eventmachine'
class RedisLoop
class << self
attr_accessor :queues
def start(opts={}, &blk)
EM.run {
@pope
pope / url_dsl.rb
Created December 28, 2009 11:12 — 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