Skip to content

Instantly share code, notes, and snippets.

@torsten
torsten / proxy.rb
Last active April 30, 2024 17:53
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009-2014 Torsten Becker <[email protected]>
#
# 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,
@tlrobinson
tlrobinson / pump.rb
Created May 12, 2011 00:45
Ruby code for pumping data between multiple pairs of IO streams
#!/usr/bin/env ruby
require 'pty'
require 'socket'
# pump([[reader, writer], ...])
#
# Description:
# pump() takes an array of arrays, with the first element of each being the read stream and the
# second being the write stream. pump() itself is synchronous but it uses select() to
@eric
eric / linux_proc_name.rb
Created November 9, 2011 07:39
Update a process name in linux to change how it shows up in top and lsof
#
# Eric Lindvall <[email protected]>
#
# Update the process name for the process you're running in.
#
# This will allow top, lsof, and killall to see the process as the
# name you specify.
#
# Just use:
#
@nesquena
nesquena / minitest_steps.md
Created November 30, 2011 21:03
Setup Minitest in a Gem

Minitest Steps

Add to gemspec:

# my_gem.gemspec

Gem::Specification.new do |s|
  # ...
 
@JeffreyWay
JeffreyWay / gist:1525217
Created December 27, 2011 21:29
Instant Server for Current Directory
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@holman
holman / gemspec-usage.md
Created February 12, 2012 07:02
test/spec/mini

Just install this in your apps like so:

gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'

@geeksam
geeksam / gist:1881240
Created February 22, 2012 04:03
Slightly friendlier API for adding custom method traces to NewRelic
require 'new_relic/agent/method_tracer'
class NR
# Convenience method for adding NewRelic tracing around specific methods of interest.
#
# Note about performance:
#
# " CAUTION - adding probes to your code adds overhead.
# Each probe burns about 20 microseconds of CPU.
# Be careful not to probe a method that's called frequently in a loop. "
@drnic
drnic / Guardfile
Created April 5, 2012 06:45
An example Guardfile with the works for a Rails app
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
@fnichol
fnichol / Vagrantfile
Created April 9, 2012 18:40
Hack to set vagrant host name (better sol'n is middleware, just wait)
Vagrant::Config.run do |config|
# Make the VM host name the name of the containing folder by default
host = File.basename(Vagrant::Environment.new.root_path || __FILE__).gsub(/_/, '-')
config.vm.host_name = "#{host}.vagrantup.com"
end