- 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a trivial HTTP proxy server, intended for use as a troubleshooting tool | |
# ONLY (not for real, actual, production use). I wrote this because I couldn't find | |
# a simple HTTP proxy that I could use to test HTTP proxy support in Net::SSH. | |
# | |
# This code is in the public domain, so do with it what you will! | |
require 'socket' | |
server = TCPServer.new('127.0.0.1', 8080) | |
client = server.accept |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'feedzirra' | |
# fetching a single feed | |
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing") | |
# feed and entries accessors | |
feed.title # => "Paul Dix Explains Nothing" | |
feed.url # => "http://www.pauldix.net" | |
feed.feed_url # => "http://feeds.feedburner.com/PaulDixExplainsNothing" | |
feed.etag # => "GunxqnEP4NeYhrqq9TyVKTuDnh0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Measure the amount bloat you're adding by requiring libraries. | |
# | |
# Usage: | |
# | |
# Bloat.measure do | |
# require 'rubygems' | |
# require 'activesupport' | |
# end | |
# | |
# A report will be printed that tells you how many methods were |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_params(context, method_name, params) | |
if params.kind_of?(Array) | |
context.send(method_name, *params) | |
elsif params.kind_of?(Hash) | |
context = context.send(method_name) | |
calculate_params(context, params.keys[0], params.values[0]) | |
elsif params.respond_to?(:to_sym) | |
context.send(method_name, params) | |
else raise ArgumentError, "Unknown type of function params" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BNF parser framework for JavaScript | |
// Oleg Andreev | |
var result = (function(text){ | |
// The Y Combinator | |
var Y=function (gen) { | |
return function(f) {return f(f)}( | |
function(f) { | |
return gen(function() {return f(f).apply(null, arguments)})})} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first you'll want to create a gist then `git clone` the private url | |
# second you'll want to run this script in the gist's directory | |
loop do | |
`git commit -a -m save && git push origin master` | |
sleep 60 * 4 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In boot.rb | |
require File.join RAILS_ROOT, 'config/autogit_libs.rb' | |
require "railties/lib/initializer" | |
Rails::Initializer.run(:set_load_path) | |
# Rails.boot! | |
class AutogitPluginLocator < Rails::Plugin::Locator | |
def plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"people":[ | |
{ | |
"person":{ | |
"animals":[ | |
{ | |
"animal":{ | |
"id":416016843, | |
"name":"Poiyo", | |
"pet_type":"fish", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Controller | |
def dull_party | |
Human.class_eval do | |
def login | |
name | |
end | |
def hello_world | |
'Hello world!' |
OlderNewer