Skip to content

Instantly share code, notes, and snippets.

View gf3's full-sized avatar
🍊
workin' goodly

Gianni Chiappetta gf3

🍊
workin' goodly
View GitHub Profile
@rjungemann
rjungemann / dispatcher.rb
Created February 26, 2010 03:19
Simple Ruby event dispatcher
# simple event dispatcher implementation
module Evented
class Dispatcher < Array
def call *args; self.each do |e|; e.call *args end end
end
class Dispatchers < Hash
def call name, *args; self[name].call(*args) if self[name] end
end
@gf3
gf3 / gist:328089
Created March 10, 2010 17:06
iTerm Colours
Black: 0, 0, 0
Red: 229, 34, 34
Green: 166, 227, 45
Yellow: 252, 149, 30
Blue: 196, 141, 255
Magenta: 250, 37, 115
Cyan: 103, 217, 240
White: 242, 242, 242
@rjungemann
rjungemann / Rakefile
Created July 27, 2010 18:38
Install Boehm GC on OS X
# how to install boehm gc on OS X
task :clean do
sh "rm -rf gc" if File.exists?("gc")
end
task :checkout do
#sh "curl -O http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.2alpha4.tar.gz"
#sh "tar zxf gc-*.tar.gz && rm gc-*.tar.gz"
#sh "mv gc-* gc"
@gf3
gf3 / LOLheritence.js
Created September 29, 2010 03:46
Executable child instances
/* ------------------------------ Main Class ------------------------------ */
// Returns "instances" of itself which are actually functions.
function Ben ( greeting ) { var Parent, scope
function Scope () {
// Here is where you put your normal constructor junk
this.greeting = greeting
this.colours = [ 'yellow', 0xFFFFFF ]
}
// Magic
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@lenary
lenary / gitconfig.ini
Created February 18, 2011 01:21
a special excerpt of my gitconfig
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
@alexrozanski
alexrozanski / gist:972958
Created May 15, 2011 08:00
Reposition Traffic Lights
NSButton *closeButton = [self standardWindowButton:NSWindowCloseButton];
NSView *themeFrame = [closeButton superview];
CGFloat buttonYOrigin = NSMaxY(themeFrame.frame)-34;
//Alter the button frames
NSRect closeFrame = closeButton.frame;
closeFrame.origin.y = buttonYOrigin;
closeButton.frame = closeFrame;
@gf3
gf3 / ago.js
Created June 2, 2011 18:43
Super small relative dates
module.exports = (function(){
const MS =
{ seconds: 1000
, minutes: 60 * 1000
, hours: 60 * 60 * 1000
, days: 24 * 60 * 60 * 1000
, weeks: 7 * 24 * 60 * 60 * 1000
, months: 30 * 7 * 24 * 60 * 60 * 1000
, years: 365 * 24 * 60 * 60 * 1000 }
@danking
danking / gist:1068185
Created July 6, 2011 19:55
A very simple example showing how to use Racket's lexing and parsing utilities
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()
@lojikil
lojikil / gist:1131925
Created August 8, 2011 15:10
SRFI Bookmarklet
javascript:(function(){i=prompt("SRFI Number");window.location="http://srfi.schemers.org/srfi-"+i+"/srfi-"+i+".html";})()