Skip to content

Instantly share code, notes, and snippets.

class SomeClass
class << self
def hooks
@hooks ||= Hash.new([])
end
def add_hook(kind, &block)
self.hooks[kind] << block
end
var
PARALLEL_CONNECTS = 10,
http = require('http'),
sys = require('sys'),
connectionCount = 0,
messageCount = 0;
lastMessages = 0;
function addClient() {
@kinsteronline
kinsteronline / skeleton.html
Created August 12, 2010 12:50
My (not as good) html5 boilerplate
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/touch-icon.png">
<link rel="stylesheet" href="fancy.css" />
@kinsteronline
kinsteronline / quadratic_cubic_bezier.html
Created August 25, 2010 19:02
How is a Quadratic Bezier Curve drawn? In a naive way...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<canvas id="d" width="800" height="800"></canvas>
<script type="text/javascript">
//
@kinsteronline
kinsteronline / i_really_like_this.js
Created August 25, 2010 20:44
The classic javascript closure
/*
* When I get frustrated with looking a javascript that
* looks far more like java, I really like looking at this
* code to make me a bit happier.
*
* http://en.wikipedia.org/wiki/Closure_%28computer_science%29
*/
var printMessage = function (s) {
var f = function () {
@kinsteronline
kinsteronline / distance_between_points.js
Created August 26, 2010 17:07
Distance w/Pythagorean
// I should have studied harder!
// http://en.wikipedia.org/wiki/Pythagorean_theorem
function distanceBetween(begin, end) {
var xs = end.x - begin.x, ys = end.y - begin.y;
return Math.sqrt(xs * xs + ys * ys);
}
@kinsteronline
kinsteronline / Removing stubborn Gems
Created September 17, 2010 14:16
Removing a gem with a direct reference to the gems directory
sudo gem list -d xmpp4r
sudo gem uninstall -aIx -i /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 xmpp4r
sudo gem list -d activesupport
sudo gem uninstall -aIx -i /Library/Ruby/Gems/1.8 activesupport

(a gist based on the old toolmantim article on setting up remote repos)

To collaborate in a distributed development process you’ll need to push code to remotely accessible repositories.

This is somewhat of a follow-up to the previous article setting up a new rails app with git.

For the impatient

Set up the new bare repo on the server:

(a gist based on the old toolmantim article on setting up remote repos)

To collaborate in a distributed development process you’ll need to push code to remotely accessible repositories.

This is somewhat of a follow-up to the previous article setting up a new rails app with git.

For the impatient

Set up the new bare repo on the server:

@kinsteronline
kinsteronline / How underscore.js does it
Created March 18, 2011 12:53
Using this and exports in Underscore
var root = this;
// Export the Underscore object for **CommonJS**, with backwards-compatibility
// for the old `require()` API. If we're not in CommonJS, add `_` to the
// global object.
if (typeof module !== 'undefined' && module.exports) {
module.exports = _;
_._ = _;
} else {