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
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 |
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
$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); |
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 Integer | |
def score | |
self * 20 | |
end | |
end | |
(4.score + 7).years.ago |
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
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 "$@" |
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
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 |
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
git commit -a -m 'done changing the world' | |
git checkout bug-branch | |
git merge new-branch |
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
git commit -a -m 'finished implementing x, still need y and z' | |
git checkout bug-branch | |
git stash pop |
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
git stash | |
git checkout -b new-branch |
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/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' |
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
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 |