Skip to content

Instantly share code, notes, and snippets.

View inem's full-sized avatar
🌰
In progress

Ivan Nemytchenko inem

🌰
In progress
View GitHub Profile
# 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
@inem
inem / gist:60711
Created February 9, 2009 08:05 — forked from pauldix/gist:57285
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"
@inem
inem / bloat.rb
Created February 10, 2009 13:09 — forked from nakajima/bloat.rb
# 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
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
// 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)})})}
# 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
# 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
@inem
inem / result.js
Created August 23, 2009 12:59 — forked from ehlyzov/result.js
{
"people":[
{
"person":{
"animals":[
{
"animal":{
"id":416016843,
"name":"Poiyo",
"pet_type":"fish",
# Controller
def dull_party
Human.class_eval do
def login
name
end
def hello_world
'Hello world!'
@inem
inem / 0what.md
Created August 24, 2009 02:59 — 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?