Skip to content

Instantly share code, notes, and snippets.

View technomancy's full-sized avatar

Phil Hagelberg technomancy

View GitHub Profile

Ruby Style

Non-negotiable

  • Indent with two spaces. This is very nearly universally accepted among Rubyists.

  • Never rescue Exception. (See http://technomancy.us/114 for details.) Don't rescue StandardError (without conditionally re-raising it) unless you have a really good reason. Doing this

(defn take-thing [thing]
(dosync
(if (room-contains? @*current-room* thing)
(do (commute *inventory* conj (keyword thing))
(alter (:items @*current-room*)
(partial remove #(= % (keyword thing))))
(str "You picked up the " thing "."))
(str "There isn't any " thing " here."))))
@technomancy
technomancy / chrono.clj
Created February 16, 2009 06:06
Tests for a library that doesn't exist yet. Chrono: date handling in Clojure
(ns clojure.contrib.test-contrib.chrono
(:use clojure.contrib.test-is
clojure.contrib.chrono))
(def christmas (date 2007 12 25, 3 00 02))
(def new-years (date 2008 1 1))
(def day-one (date 2008 11 21, 11 21 48))
(deftest test-date-creation
;; TODO: Not sure about the interface here. We may not be able to
;;; clojure-test-mode --- Minor mode for Clojure tests
;; Copyright (C) 2009 Phil Hagelberg
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://emacswiki.org/cgi-bin/wiki/ClojureTestMode
;; Version: 0.1
;; Keywords: languages, lisp
;; This file is not part of GNU Emacs.
;;; clojure-test-mode --- Minor mode for Clojure tests
;; Copyright (C) 2009 Phil Hagelberg
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://emacswiki.org/cgi-bin/wiki/ClojureTestMode
;; Version: 0.1
;; Keywords: languages, lisp
;; This file is not part of GNU Emacs.
;;; clojure-test-mode --- Minor mode for Clojure tests
;; Copyright (C) 2009 Phil Hagelberg
;; Author: Phil Hagelberg <technomancy@gmail.com>
;; URL: http://emacswiki.org/cgi-bin/wiki/ClojureTestMode
;; Version: 0.1
;; Keywords: languages, lisp
;; This file is not part of GNU Emacs.
[13:32] phil> wait, are you using sqlite in production?
[13:33] Seth> oh totally. We're replacing those query tokens with
sqlite databases embedded in XML responses
[13:33] phil> nice
[13:33] phil> base64-encoded?
[13:34] Seth> then we'll process those client side using the browser's
embedded sqlite
[13:34] phil> that's good
[13:34] phil> better rot13 them too for security's sake
[13:34] phil> you know how important security is these days.
@technomancy
technomancy / testtr.rb
Created February 24, 2009 23:16
Spec-style it-should minitest syntax in ten lines
require 'rubygems'
require 'minitest/unit'
class MiniTest::Unit
def TestCase.test_methods
methods = public_instance_methods(true).map { |m| m.to_s }
methods -= MiniTest::Unit::TestCase.public_instance_methods(true)
methods.sort_by { |m| test_order == :random ? rand : m }
end
end
;;; A date library that follows principle of least surprise
;;;
;;; A few usage examples:
;;;
;;; user> (now)
;;; {:second 24, :minute 10, :hour 0, :type
;;; :clojure.contrib.date/DateTime, :year 2009, :month 1, :day 23
;;; :zone "America/New_York"}
;;;
;;; user> (today)
diff --git a/lib/hoe/git.rb b/lib/hoe/git.rb
index 106fb1b..abb1ac8 100644
--- a/lib/hoe/git.rb
+++ b/lib/hoe/git.rb
@@ -77,6 +77,10 @@ class Hoe #:nodoc:
task :release => "git:tag"
+ "Replace Manifest.txt with a listing of files from your repository."
+ task :dump_manifest do