This file contains hidden or 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
# Simple perl repl (in bash). Works w/readline, but no support for multi-line statements | |
alias re.pl="rlwrap perl -de 0" |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'ptools' | |
start = ARGV.first || '.' | |
Dir.glob("#{start}/**/**").each do |f| | |
begin | |
next if(File.directory?(f) || File.binary?(f)) |
This file contains hidden or 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
#N canvas 162 163 176 386 10; | |
#X msg 17 336 \; pd dsp 1; | |
#X msg 84 336 \; pd dsp 0; | |
#X obj 61 291 dac~; | |
#X obj 22 74 samphold~; | |
#X obj 73 53 phasor~ 8000; | |
#X obj 22 24 adc~; | |
#X obj 22 206 spigot~; | |
#X obj 61 185 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 | |
1; |
This file contains hidden or 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
// traverses a tree of DisplayObjects, calling the callback function on each | |
function descendClips(clip, callback) { | |
callback(clip); | |
for(var i = 0; i < clip.numChildren; i++) { | |
var child = clip.getChildAt(i); | |
try { descendClips(child, callback); } catch(e) {} | |
} | |
} |
This file contains hidden or 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
#include <assert.h>#include <stdio.h> | |
#include <gc.h> | |
int main(void) | |
{ | |
int i; | |
GC_INIT(); | |
for (i = 0; i < 10000000; ++i) | |
{ |
This file contains hidden or 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
#!/usr/bin/env ruby | |
# usage: | |
# | |
# ruby extra_steps.rb SCRIPT ROOT_URL RELATIVE_URL | |
require 'nokogiri' rescue puts "Needs nokogiri. Type in `gem install nokogiri` to install." | |
require 'erb' | |
def pretty_print_xslt |
This file contains hidden or 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
// use a hashing algorithm (in this case, SHA-1) to predictably assign | |
// a key to a particular slot. May be useful for sharding purposes. | |
// Based off of ideas found at: | |
// | |
// https://github.com/antirez/redis/blob/master/design-documents/REDIS-CLUSTER | |
var crypto = require('crypto'); | |
// digits -- number of digits to check | |
// slotSize -- number of slots to assign to |
This file contains hidden or 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
class ViewNib | |
def self.load(name) | |
nib = NSNib.alloc.initWithNibNamed(name, bundle: nil) | |
objects = Pointer.new_with_type('@') | |
view = nil | |
nib.instantiateNibWithOwner(NSApp, topLevelObjects: objects) | |
objects[0].each { |object| view = object if object.is_a? NSView } | |
This file contains hidden or 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
class Dice | |
attr_accessor :sides | |
# set "sides" to default to 6 | |
def initialize | |
self.sides = 6 | |
end | |
# take a random number from 0 to 1, multiply by number of sides, | |
# then round up |
This file contains hidden or 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
# formulas to convert between kilos and pounds | |
def pounds_to_kilos pounds | |
pounds * 0.45359237 | |
end | |
def kilos_to_pounds kilos | |
kilos / 0.45359237 | |
end |