Skip to content

Instantly share code, notes, and snippets.

@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
#!/usr/bin/env ruby
=begin
INSTALL:
curl http://github.com/defunkt/gist/raw/master/gist.rb > gist &&
chmod 755 gist &&
sudo mv gist /usr/local/bin/gist
$ bundle --version
Bundler version 0.9.26
$ bundle version
Bundler version 0.9.26
$ bundle install --version
Unknown switches '--version'
$ bundle --version
Bundler version 0.9.26
$ bundle --version --version
Unknown switches '--version'
class Punch
class << self
original_load = self.instance_method(:load)
# if you want to call the original use:
# original_load.bind(self).call
define_method(:load) do |file|
raise ArgumentError, 'no filename supplied' unless file
@data = YAML.load(File.read(file))
end
require 'spec/runner/formatter/progress_bar_formatter'
class NescafeFormatter < Spec::Runner::Formatter::ProgressBarFormatter
def example_failed(example, counter, failure)
super
dump_failure(counter, failure)
end
end
#!/usr/bin/env ruby -w
require 'hpricot'
require 'net/http'
require 'net/https'
require 'uri'
require 'tempfile'
test_http = "http://gist.github.com/69452"
test_https = "https://gist.github.com/42af948558a3b3704bab"
@endolith
endolith / Has weird right-to-left characters.txt
Last active July 26, 2025 19:31
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
This allowed for automatic render overrides based on controller
An example:
controller = UsersController
action = show
normal path = RAILS_ROOT/app/views/users/show.html.erb (or haml or rhtml or rjs or whatever)
With this in place,
#!/bin/sh
BRANCHES=`git branch`
if [ $? != 0 ]; then
exit
fi
GIT_SVN=0
git branch -r | grep 'git-svn' > /dev/null
if [ $? = 0 ]; then
GIT_SVN=1
tell application "Caffeine" to turn on
set volume alert volume 0