Skip to content

Instantly share code, notes, and snippets.

@sczizzo
sczizzo / todo.sh
Created December 21, 2011 01:45
todo - Simple command line Todos, this time in Bash
#!/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
@sczizzo
sczizzo / tracker.js
Created December 21, 2011 01:46
JavaScript wrapper for CTA BusTracker API
// = 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],
@sczizzo
sczizzo / foo.hs
Created December 29, 2011 05:26
Return the number of tuples in a list whose first member is prefixed by some character
-- 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
@sczizzo
sczizzo / WhyQR.rb
Created January 12, 2012 05:24
Experiment for ARTV150: Obfuscation
#!/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
@sczizzo
sczizzo / practice.rb
Created December 18, 2012 05:40
Just some practice for interviews and whatnot.
#!/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
@sczizzo
sczizzo / Game.java
Created December 21, 2012 16:41
Bowling Game Kata
package Bowling;
public class Game {
int nrolls = 0;
int[] rolls = new int[21];
public void roll(int pins) {
rolls[nrolls++] = pins;
}
@sczizzo
sczizzo / Change.java
Created December 22, 2012 00:01
Making change under ideal conditions
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);
@sczizzo
sczizzo / merge.rb
Last active December 10, 2015 02:48
Coding Interview Practice (Dec. 24)
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
@sczizzo
sczizzo / ArraysAndStrings.java
Created December 24, 2012 23:48
CTCI Chapter 1: Arrays and Strings
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);
@sczizzo
sczizzo / LL.hs
Created December 25, 2012 01:22
Linked List Exercise
-- 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