Skip to content

Instantly share code, notes, and snippets.

Steve Purcell purcell

View GitHub Profile
View redis_memo.clj
(ns redis-memo
(:require redis)
(:import (java.net URLEncoder)))
;; --------------------------------------------------------------------------------
;; Default connection params
;; --------------------------------------------------------------------------------
(def memo-server {:host "localhost" :port 6379 :db 14})
View all.el
;;; all.el --- Edit all lines matching a given regexp.
;; Copyright (C) 1985, 1986, 1987, 1992, 1994 Free Software Foundation, Inc.
;; Copyright (C) 1994 Per Abrahamsen
;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
;; Version: $Id: all.el,v 5.2 1997/03/04 10:29:42 abraham Exp $
;; Keywords: matching
;; LCD Archive Entry:
View git-svn-copy-local-branches
#!/usr/bin/env ruby
if ARGV.size < 2
puts "Usage: #{$0} <src dir> <dest dir> [branch name]"
puts " CAUTION! Running without a branch name, it will try to copy all 'local' branches, but this is probably not what you want, and is untested. Copy just those branches you really need."
exit
end
src_repo = File.expand_path(ARGV[0])
dest_repo = File.expand_path(ARGV[1])
View *slime-repl clojure*
user> (filter #(re-find #"^[^aeiou]*a[^aeiou]*e[^aeiou]*i[^aeiou]*o[^aeiou]*u[^aeiou]*$" %) (clojure.contrib.io/read-lines "/usr/share/dict/words"))
("abstemious" "abstemiously" "abstentious" "acheilous" "acheirous" "acleistous" "affectious" "annelidous" "arsenious" "arterious" "bacterious" "caesious" "facetious" "facetiously" "fracedinous" "majestious")
@purcell
purcell / fix_habtm_join_table_deletion_order.rb
Created Sep 30, 2010
This initializer patches the Rails bug described in ticket 5674
View fix_habtm_join_table_deletion_order.rb
# This initializer patches the bug described in ticket 5674:
# https://rails.lighthouseapp.com/projects/8994/tickets/5674-regression-habtm-deletion-fails-when-join-table-has-foreign-keys
if Rails.version == '3.0.0'
module ActiveRecord::Associations
autoload :HasAndBelongsToManyAssociation, 'active_record/associations/has_and_belongs_to_many_association'
module ClassMethods
def has_and_belongs_to_many(association_id, options = {}, &extension)
reflection = create_has_and_belongs_to_many_reflection(association_id, options, &extension)
@purcell
purcell / gist:917389
Created Apr 13, 2011
zsh prompt with git branch
View gist:917389
##############################################################################
## Zsh prompt
##############################################################################
# See http://kriener.org/articles/2009/06/04/zsh-prompt-magic
# and http://briancarper.net/blog/570/git-info-in-your-zsh-prompt for more
#autoload -Uz vcs_info
#zstyle ':vcs_info:*:prompt:*' check-for-changes false
cur_git_branch() {
View rinari.el
(defun rinari-test (&optional edit-cmd-args)
"Test the current ruby function. If current function is not a
test, then try to jump to the related test using
`rinari-find-test'. Dump output to a compilation buffer allowing
jumping between errors and source code. With optional prefix
argument allows editing of the test command arguments."
(interactive "P")
(or (string-match "test" (or (ruby-add-log-current-method)
(file-name-nondirectory (buffer-file-name))))
(rinari-find-test))
View eight-places.md

The Eight Wondrous Places of the Human World

According to Buddhist mythology, the human world has eight wondrous places that give us protection. The first is a place where everyone is illuminated by a golden light. This golden light supports all sentient beings and helps them to grow and mature under all circumstances. Consider your own life. For the past ten, twenty, thirty, or forty years, how many troubles have you experienced? Countless troubles. But still, you're alive. How? You don't know. But this is reality. You are a survivor. You have been protected and nurtured by many things -- your parents, your teachers, your friends, and more. All this time, your life has been supported. You have been illumined by a golden light that constantly shines, and constantly helps you.

The second place is one in which you are immune to trouble. Of course, we all have troubles. But if you learn something from your troubles, then those troubles aren't exactly troubles. By realizing the true nature of trouble, trouble

View example.html
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="example.js" type="text/javascript"></script>
</head>
<body>Borken</body>
</html>
@purcell
purcell / example.html
Created Oct 3, 2011
Bootstrap dropdown breakage with yepnope/modernizr
View example.html
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="https://raw.github.com/SlexAxton/yepnope.js/master/yepnope.js" type="text/javascript"></script>
<script type="text/javascript">
yepnope({load: "https://raw.github.com/twitter/bootstrap/master/js/bootstrap-dropdown.js"})
</script>
</head>
<body>Borken</body>
You can’t perform that action at this time.