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
#!/bin/bash | |
# Pseudo-globals | |
todo_file=$HOME/.todo | |
temp_file=/tmp/todo-$$ | |
temp_file2=/tmp/todo--$$ | |
# Make sure we've got a todo list | |
if [[ ! -e ${todo_file} ]] | |
then |
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
// = Name | |
// tracker.js | |
// Douglass - Cross-browser, cross-platform alternative to CTA BusTracker | |
// | |
// = Description | |
// The ChicagoTransit module queries the CTA BusTracker Service using the | |
// official version 1.0 API. CTA uses the BusTime system to provide developers | |
// with real-time route information through BusTracker. The BusTracker Service | |
// allows deveopers to make HTTP requests and recieve XML responses. The CTA | |
// provides {official API documentation (PDF)}[http://www.transitchicago.com/assets/1/developer_center/BusTime_Developer_API_Guide.pdf], |
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
-- Return the number of tuples in a list whose first member is prefixed by a | |
foo :: Char -> [(String, a)] -> Int | |
foo a = foldl succIfPrefixed 0 where | |
succIfPrefixed acc (x:xs, y) | x == a = succ acc | |
| otherwise = acc | |
-- Or more compactly... | |
foo' :: Char -> [(String, a)] -> Int | |
foo' a = foldl (\acc (x:xs, y) -> if x == a then acc + 1 else acc) 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 -w | |
# Sean Clemmer Why the QR code? | |
# Basically cause I don't like it. It's a token, like all physical art in a way | |
# It's obscure and immutable and insensitive and secretive. It's the leftovers you ant | |
# But also well-formed and regular and geeky. Cause the "real thing" is gone. | |
# A QR code is just a two-dimensional bar code But it's a token that explicitly | |
# it has some neat stuff like error detection and speed directs its viewers, and that's a powerful tool | |
# it doesn't store all that much data--mostly we encounter links Because I'm nosy and human | |
# URLs, pointers, addresses, identifiers and yeah I wanna see what people do | |
# {PRAGMA INSERT QUOTE and yeah also change them |
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 | |
# Just some practice for interviews and whatnot. | |
require 'set' | |
class Array | |
# Shift each element in the array by N positions. | |
# Use a negative N to rotate left. | |
def rotate_by n | |
len = length |
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
package Bowling; | |
public class Game { | |
int nrolls = 0; | |
int[] rolls = new int[21]; | |
public void roll(int pins) { | |
rolls[nrolls++] = pins; | |
} |
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
import java.util.Collections; | |
import java.util.List; | |
import java.util.ArrayList; | |
public class Change { | |
List<Integer> coins; | |
public Change(int numCoins, int[] rawCoins) { | |
ArrayList<Integer> coins = new ArrayList<Integer>(numCoins); |
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 Array | |
def merge_with other | |
res = [] | |
until self.empty? or other.empty? | |
a, b = self.shift, other.shift | |
if a == b | |
res << a | |
elsif a < b | |
res << a | |
other.unshift b |
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
package Exercise; | |
import java.util.HashMap; | |
public class ArraysAndStrings { | |
public static boolean isUniq(String s) { | |
int len = s.length(); | |
boolean isUniq = true; | |
for (int i = 0; isUniq && i < len; ++i) { | |
char c = s.charAt(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
-- Linked List | |
data LL a = Empty | Cons a (LL a) | |
instance (Show a) => Show (LL a) where | |
show Empty = "[]" | |
show (Cons a l) = (show a) ++ ":" ++ (show l) | |
nth :: LL a -> Int -> a | |
nth (Cons a _) 0 = a |