Skip to content

Instantly share code, notes, and snippets.

View rue's full-sized avatar

Rue Saynatkari rue

View GitHub Profile
@pkieltyka
pkieltyka / web_proxy.rb
Created December 27, 2011 21:37
web_proxy.rb
module Nulayer
class WebProxy
ENDPOINT = '/webp'
URL_PARAM_NAME = 'url'
attr_accessor :env, :params, :referred, :url
def initialize(env, params, referred=false)
self.env = env
self.params = params
@jefftrull
jefftrull / main.cpp
Created January 9, 2012 09:53
Example of producer-consumer for Ruby interpreter with separate thread in C++
// Example of running Ruby in a separate thread
// 2012-01-08 by Jeff Trull <jetrull@sbcglobal.net>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>
@zzak
zzak / util.rb
Created January 12, 2012 23:05
Catch all exceptions and airbrake them
require 'airbrake'
Airbrake.configure do |config|
config.api_key = AIRBRAKE_API_KEY
end
at_exit {
if $!
e = $!
Airbrake.notify(

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
  • NBC
@apeiros
apeiros / capabilities.rb
Created June 29, 2012 22:38
Require files and provide an interface to check what's available
Moved to https://github.com/apeiros/available
@peter
peter / creating-edgerails-app.sh
Created June 30, 2012 21:03
Creating and Deploying an EdgeRails (Rails 4) Application to Heroku
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew
# https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it
gem install bundler
# 1. Get edge Rails source (master branch)
git clone https://github.com/rails/rails.git
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@certainty
certainty / gist:3792694
Created September 27, 2012 07:33
generalized method chaining and array as applicative
class Array
def >>(other); self + [other]; end
def to_proc(*args)
->(r) { inject(r){ |o,(m,*args)| o.send(m,*args) } }
end
def apply(rec)
self.to_proc[rec]
end