Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
#
# Search upwards for $1 in directory tree.
pwd="`pwd`"
start="$pwd"
while [ ! "$pwd" -ef .. ]; do
[ -e "$1" ] && echo -n "$pwd" && exit
cd .. || exit 1
pwd="`pwd`"
@cornerwings
cornerwings / prettydump.rb
Created October 31, 2010 01:52
Small ruby script to prettify dump output from pin
#!/usr/bin/env ruby
# Dump format should be like this
# (STAGE) OP (OP_ID) ... cycle (CYCLE)
# Matching is case insensitive
#
# Examples:
# FE_STAGE OP 0 is fetched at cycle 1
# ID_STAGE OP 0 is scheduled at cycle 3
# IS_STAGE OP 0 is issued at cycle 3
# The following are the current stages
# FE: after instruction is fetched
# ID: after instruction is added to scheduler
# IS: instruction is selected for execution
# EX: instruction finished execution
# WB: instruction retired
# Dont be confused by ID_stage, Op is added to scheduler in IS_stage, just easier
# to differentiate in the parsing
@cornerwings
cornerwings / readmidi.rb
Created November 9, 2010 05:11
Random note generator in Ruby
require 'midilib'
require 'simple-random'
include MIDI
def get_number
rand(2000)
end
seq = nil unless seq.nil?
seq = Sequence.new()
@cornerwings
cornerwings / will_paginate.rb
Created September 17, 2011 14:43 — forked from isaacbowen/will_paginate.rb
extends will_paginate to play well with Twitter's Bootstrap
# config/initializers/will_paginate.rb
# tested with will_paginate 2.3 stable
module WillPaginate
class BootstrapLinkRenderer < LinkRenderer
def to_html
links = @options[:page_links] ? windowed_links : []
# previous/next buttons
links.unshift page_link_or_span(@collection.previous_page, 'disabled prev', "&larr; Previous")
links.push page_link_or_span(@collection.next_page, 'disabled next', "Next &rarr;")