Skip to content

Instantly share code, notes, and snippets.

View lukaszkorecki's full-sized avatar
🌴
🛹

Łukasz Korecki lukaszkorecki

🌴
🛹
View GitHub Profile
@gotascii
gotascii / tco.rb
Created October 25, 2010 22:46
continuations via blocks and exceptions
# I got this idea from http://mihai.bazon.net/blog/redis-client-library-javascript-node
# The technique relies on the fact that raising an exception clears the call stack.
# The context is passed along with a block attached to an exception.
# I thought it was brilliant js hackery so I decided to try my hand at it in ruby.
# I've also included some other stack-dependent implementations.
# straight recursion, not quite a tail-call
# I can't go above 8.1k without stack error
def rsum(num)
if num == 0
@joefiorini
joefiorini / .vmail.sh
Created December 16, 2010 16:44
Shell function to support multiple accounts for vmail (http://danielchoi.com/software/vmail.html) using one command.
mail() {
if [[ $1 = "p" ]]; then
rvm system exec vmail -c ~/.vmailrc-p
elif [[ $1 = "w" ]]; then
rvm system exec vmail -c ~/.vmailrc-w
else
echo "Please specify an account."
fi
}
anonymous
anonymous / contactos.rb
Created January 7, 2011 21:08
#!/usr/bin/env ruby1.8
##
# File: contactos.rb
# Author: Horacio Sanson (hsanson at gmail)
# Date: 2010/01/22
#
# Descr:
# Small script to facilitate use of GMail contacts within mutt email client.
#
# Features:
@adammw
adammw / gs_htmlswf_v8.js
Created January 14, 2011 17:07
Grooveshark HTML5 Audio Injector
/*
* Grooveshark HTML5 Audio Injector for Flash-less browsers
* <https://gist.github.com/gists/779895>
* Version 0.0.8
*
* To use, simply copy and paste this code into the Developer Console
* for the open Grooveshark page and hit enter. Only tested with Google Chrome.
*
* Porting to Javascript Copyright (C) 2011 Adam Malcontenti-Wilson <adman.com@gmail.com>
* All other elements Copyright (C) Escape Media Group ("Grooveshark")
@funkatron
funkatron / chrometest.sh
Created February 9, 2011 15:20
To do testing on local HTML/JS apps in Chrome, I start it with this script to disable some security checks.
#!/bin/bash
# USAGE: /path/to/chrometest <localfile.html>
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--disable-web-security \
--allow-file-access-from-files \
--allow-file-access \
--log-level 3 \
$@
@cpowell
cpowell / Datastore.rb
Created May 27, 2011 19:36
A singleton class to manage a MacRuby application's data storage requirements.
#
# Datastore.rb
# A singleton class to manage a MacRuby application's data storage requirements.
#
# Chris Powell, cpowell@prylis.com, http://cbpowell.wordpress.com
#
# This work is licensed under a Creative Commons Attribution 3.0 Unported License.
# http://creativecommons.org/licenses/by/3.0/
#
# For usage and discussion, see http://cbpowell.wordpress.com/category/macruby/
@cdcarter
cdcarter / form_helper.rb
Created June 4, 2011 02:52
NS Form Helper Class
class FormHelper
attr_accessor :form
def initialize(nsform=nil)
@form = nsform
end
def length
form.numberOfRows
end
@jandudulski
jandudulski / strem_notifier.rb
Created October 19, 2011 13:45
Stream notifier for earthquake
# coding: utf-8
Earthquake.init do
output do |item|
if item["_stream"] && item["text"]
notify item["text"], title: "#{item["user"]["name"]} (#{item["user"]["screen_name"]})"
end
end
end
@sxua
sxua / brew_uninstall.sh
Created November 20, 2011 00:05
Remove Homebrew's "has multiple installed versions"
#!/bin/bash
ruby -I/usr/local/Library/Homebrew -rglobal -rkeg -e 'k = Keg.new("/usr/local/Cellar/#{pkg}/#{version}"); puts k.unlink; k.uninstall'
@filiptepper
filiptepper / const_get.rb
Created November 21, 2011 13:56
Today I Learned
module Oink
class Doink
end
end
> Kernel.const_get("Oink::Doink")
NameError: wrong constant name Oink::Doink
> Kernel.const_get("Oink").const_get("Doink")
=> Oink::Doink