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
it "should show sorted stream if updated by author after reshare" do
# someone reshares
SocialPost.make :postable => @mac_pics, :user => @tim, :postable_type => "Story", :network_name => SocialUser::BLURB
# then the author updates, causing the original authored socialpost to update, pushing it to the "back"
@mac_pics.title = @mac_pics.title + "_"
@mac_pics.save!
debugger
@tony.story_stream.should == [@john_pics, @people_pics, @dog_pics, @mac_pics]
end
$j('#something').html('fetching');
$j.ajax({
url: '/path/to/epub.epub',
complete: function(response, status, request) {
var the_zip = new JSUnzip(response.responseText);
$j('#something').html('finished with ' + status);
console.log("is it zip?" + the_zip.isZipFile());
var epub = new JSEpub(response.responseText);
class Integer
def score
self * 20
end
end
(4.score + 7).years.ago
@pierrel
pierrel / gist:394842
Created May 8, 2010 23:57
git's not bash
command_not_found_handle() {
# do not run when inside Midnight Commander or within a Pipe
if test -n "$MC_SID" -o ! -t 1 ; then
echo $"$1: command not found"
return 127
fi
if test -x "/usr/local/git/libexec/git-core/git-$1"; then
echo "executing 'git $@'"
git "$@"
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
@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
@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
#! /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'
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