This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( ".tabs" ).each( function() { | |
// a collection of all the tabs for closing over | |
var tabs = []; | |
// find all the anchor links inside | |
$( "a[href^='#']", this ).each( function() { | |
// find the element this anchor targets and stash it | |
var href = this.href.substring( this.href.lastIndexOf( "#" ) ), | |
tab = $( href )[ 0 ]; | |
tabs.push( tab ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function is-git? { | |
git status &> /dev/null | |
[ $? != 128 ] | |
} | |
function git-init-remote { | |
name=$(basename $PWD).git | |
path="~/repos/$name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: flusspferd tree.js grammar.peg inputfile | |
const peg = require( "PEG_generator" ), | |
fs = require( "fs-base" ), | |
system = require( "system" ); | |
var grammar = fs.rawOpen( system.args[ 1 ], "r" ).readWhole(), | |
input = fs.rawOpen( system.args[ 2 ], "r" ).readWhole(), | |
names = eval( peg.generateParserThrowing( grammar ) ), | |
root = names[ 0 ], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Invoke like this: | |
# svn di --diff-cmd=./diffwarp.sh && cat .gitdiff | gitx && rm .gitdiff | |
# | |
# For easier use, stick diffwarp.sh in your path and alias the command | |
# alias svnx='svn di --diff-cmd=diffwarp.sh > /dev/null && cat .gitdiff | gitx && rm .gitdiff' | |
# Subversion provides the paths we need as the sixth and seventh | |
# parameters. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function points_on_a_line( from, to, gap ) { | |
// work out the difference in X and Y, and the hypotenuse | |
var dx = to.x - from.x, | |
dy = to.y - from.y, | |
h = Math.sqrt( dx*dx + dy*dy ) | |
points = [], | |
// work out what proportion of the hypotenuse each step will be | |
step = gap / h, | |
d = 0, | |
i = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require modules under node.js; in a browser they'll already be present | |
if ( typeof chai === "undefined" ) { var chai = require( "chai" ); } | |
if ( typeof markdown === "undefined" ) { var markdown = require( "../lib/markdown" ); } | |
var assert = chai.assert, | |
// test wrapper to pass each a fresh markdown object | |
t = function( fn ) { return function() { fn( new markdown.Markdown() ); }; }; | |
suite( "autolinking", function() { | |
test( "URL", t( function( md ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function double( x ) | |
return x * 2; | |
end | |
function square( x ) | |
return x * x; | |
end | |
s = EventStream.new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object = {}; | |
function Object:clone( o ) | |
return setmetatable( o, { __index = self } ); | |
end | |
function Object:instanceOf( parent ) | |
local mt = getmetatable( self ); | |
if mt == nil or mt.__index == nil then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './lib/point.rb' | |
class Rectangle | |
DEFAULT_COLOR = Gosu::Color::WHITE | |
# The internal representation is two points (top-left and bottom-right) | |
attr_accessor :left, :top, :right, :bottom, :color | |
def self.from_center(window, center, width, height, color = DEFAULT_COLOR) | |
new(window, center.x - width / 2, center.y - height / 2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Eventable | |
def listen(event, method) | |
eventable_listeners[event] << method | |
end | |
def emit(event, *args) | |
eventable_listeners[event].each do |method| | |
method.call(*args) | |
end | |
end |
OlderNewer