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
#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 () |
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
#lang sicp | |
; A collection of functions | |
; that can be added to your functions | |
; to have them produce graphviz dot notation | |
; as they're run. | |
; | |
; ;------------- | |
; ; Usage inside functions to be graphed | |
; |
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
class Array | |
# Performs the same function as | |
# flatten, only slower (because it's in Ruby | |
# and .flatten is implemented in C) | |
def slow_flatten(arr = self, result = []) | |
if arr.size > 0 | |
first = arr.first | |
if ! arr.first.is_a? Array | |
result.push(first) | |
else |
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
#!/usr/bin/env ruby | |
# it expects you're going to pass it the spreadsheet found here | |
# http://masukomi.org/misc/spreadsheet_float_test.xls | |
raise "Needs a path argument" unless ARGV[0] | |
require 'spreadsheet' | |
file_path = ARGV[0] | |
Spreadsheet.client_encoding = 'UTF-8' |
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
def paralleln(items : Indexable(T), &block : T -> R) forall T, R | |
results = Array(R).new(items.size) { r = uninitialized R } | |
done = Channel(Exception?).new | |
items.each_with_index do |item, i| | |
spawn do | |
begin | |
results[i] = block.call(item) | |
rescue e | |
done.send e |
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 | |
[insert command to compile your app here] | |
# copy all the optional ones | |
rm -rf dylibs/* | |
# REPLACE path/to/my/new/binary below with the path to your newly compiled binary | |
DYLIBS=`otool -L path/to/my/new/binary | grep "/opt" | awk -F' ' '{ print $1 }'` | |
for dylib in $DYLIBS | |
do |
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 | |
# find the last thing edited and add it to git. | |
# useful when you're editing items in a merge conflict | |
# and are running a command to edit each file in the command line. | |
# Run gale after each edit so that the list of conflicting items gets shorter | |
# and you don't have to keep copy pasting the name of the file | |
HISTFILE=~/.bash_history | |
set -o history |
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
extract | |
┌─────────────────this ──────────────────────────┐ | |
│ column │ | |
│ ▼ | |
│ ┌──┐ | |
│ │ │ | |
│ ┌────────────┼──┼───────┐ |
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 | |
for i in `cal | awk '{print $5}'`; do | |
if [ "x" != "x"$i ]; then | |
target_day=$i | |
fi | |
done | |
today=`date | awk '{print $3}'` |
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
# I need your help geeks. ;) | |
# I have an array of items | |
# Some items have a number on both sides | |
# I'll call these "matched pairs". | |
# The matched pairs are the keystones of this problem. | |
# I need to sort the items between the matched pairs | |
# in a particular way. | |
# There's a "from number" and a "to number" |