Skip to content

Instantly share code, notes, and snippets.

Steve Purcell purcell

Block or report user

Report or block purcell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@purcell
purcell / feed_word_counter.rb
Created Nov 24, 2009
Hacky script to count words in RSS feeds
View feed_word_counter.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
class String
def strip_tags
gsub(/&lt;/, '<').gsub(/&gt;/, '>').gsub(/<.*?>/, ' ').gsub(/&amp;#\d{4};/, '~')
View foo.clj
;; Feedback on http://www.fatvat.co.uk/2009/07/merging-rss-feeds.html
;; Original
(defn join-all
"Join the lists provided using f to select an element each time"
[f & lists]
(let [l (remove empty? lists)]
(when-not (empty? l)
(let [n (reduce f (map first l))
c (count (filter #(= (first %) n) l))
View *slime-repl clojure*
user> (pprint (macroexpand-1 '(bar-chart (map (comp str first) d) (map (comp #(/ % 1000.0) second) d) :title "Distance by week" :x-label "Week" :y-label "km")))
(clojure.core/let
[opts__1904__auto__
(clojure.core/when
'(:title "Distance by week" :x-label "Week" :y-label "km")
(clojure.core/assoc
{}
:title
"Distance by week"
:x-label
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 fullscreen.patch
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 157b2dd..f3807b7 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -1263,6 +1263,11 @@ the operating system.")
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
+(defun ns-toggle-fullscreen ()
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() {
You can’t perform that action at this time.