Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pierrel's full-sized avatar

Pierre Larochelle pierrel

  • LinkedIn
  • San Francisco, CA
View GitHub Profile
(def people-view
(html [:html
[:h1 "People"]
[:ul
(let [rows '({:id 1 :name "johanna"} {:id 2 :name "vincent"})]
(reduce html
(map (fn [hash] [:li (str (get hash :id) " - " (get hash :name))]) rows)))]]))
(defn flatten [s]
(remove seq? (tree-seq seq? seq s)))
{
"env": {
"default": {
"db": "http://[adminusername]:[adminpassword]@localhost:5984/wear"
}
}
}
var Mannequin = new Object();
Mannequin.element_id = 'mannequin-canvas';
Mannequin.shirt_id = '';
Mannequin.pant_id = '';
Mannequin.shoes_id = '';
Mannequin.last_piece_hover = ''; // The last piece the mouse was over, to detect changes
require 'rest_client'
require 'json'
class Couch
def initialize(url)
@db = url.gsub(/\/$/, '')
end
# Updates the given doc by yielding the current state of the doc
# and trying to update update_limit times. Returns the new doc
#! /usr/bin/python
import sys
import Image
def corners(image, test_square_size = 1):
"""returns an array of the corner bounds of the image"""
size_x, size_y = image.size
max_x, max_y = (size_x-1, size_y-1)
if max_x < test_square_size or max_y < test_square_size:
raise Exception, 'test_square_size cannot be larger than the image size'
@pierrel
pierrel / gist:279132
Created January 17, 2010 01:30
switching back with git
git commit -a -m 'finished implementing x, still need y and z'
git checkout bug-branch
git stash pop
@pierrel
pierrel / gist:279131
Created January 17, 2010 01:27
quick switch with git
git stash
git checkout -b new-branch
@pierrel
pierrel / gist:279134
Created January 17, 2010 01:32
finished implementation with git
git commit -a -m 'done changing the world'
git checkout bug-branch
git merge new-branch
require 'enumerator'
module Poker
def royal_flush?
high_in_flush = flush?
if high_in_flush
suite = high_in_flush.suite
if (@cards.sort.reverse.select { |card| card.suite == suite }.map { |card| card.number }.uniq)[0..5] == [14, 13, 12, 11, 10]
return Card.new("A" + suite)
else