Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View sgrove's full-sized avatar
💭
Infinigraph, and beyond!

Sean Grove sgrove

💭
Infinigraph, and beyond!
View GitHub Profile
I thought I'd jot down a few notes about our experience posting to <a href="http://news.ycombinator.com">hn</a>.
I had just finished "an acceptable code base" for <a href="http://www.chuwe.com">chuwe.com</a> (our Q&A site for the startup/smallbiz community) and decided that Sunday was the day. Actually, we decided Friday, but personnel issues pushed it back until Sunday.
Our goal was simple - it wasn't a "real" launch per se. We wanted to open the site, get mass feedback in one big jolt, then close it and continue with our original invite-only model.
A Short Crisis
In any case, we posted to HN - my first time showing personal code to so many people. It's difficult to tell if there will be any big problems ahead of time. To minimize the possibility, I followed BDD - we had functional-tests, unit-tests, etc. In fact, we had about a 1:1 code-to-test coverage ratio (whether that's meaningful or not, I don't know). Testing made refactoring fly by, it reassured me that things still worked, and just made m
; T).
; etc.
; --> LET IF LET PROG1 LET LET* MULTIPLE-VALUE-BIND LET UNLESS IF TYPEP LET AND
; --> IF AND THE LOCALLY AND THE >= IF
; ==>
; (< SB-C::X SB-C::Y)
;
; note: forced to do GENERIC-< (cost 10)
; unable to do inline fixnum comparison (cost 3) because:
sean-groves-macbook:bin sgrove$ lein install
Exception in thread "main" java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (core.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:5274)
at clojure.lang.Compiler.eval(Compiler.java:5250)
at clojure.lang.Compiler.load(Compiler.java:5663)
at clojure.lang.RT.loadResourceScript(RT.java:330)
at clojure.lang.RT.loadResourceScript(RT.java:321)
at clojure.lang.RT.load(RT.java:399)
at clojure.lang.RT.load(RT.java:371)
at clojure.core$load__5663$fn__5671.invoke(core.clj:4255)
class Validated:
__fields__ = {} # field -> validator list
def validate(self):
errors = []
for field, validators in self.__fields__.iteritems():
if not hasattr(self, field):
errors.append("field %s missing" % field)
continue
field_errors = []
# Sauce::Selenium_browsers will have all your browsers
JSON.parse(ENV["SAUCE_ONDEMAND_BROWSERS"]).each do |selenium_browser|
@browser = Selenium::Client::Driver.new(:host => ENV["SAUCE_ONDEMAND_SERVER"],
:port => ENV["SAUCE_ONDEMAND_PORT" ],
:url => ENV["SAUCE_ONDEMAND_URL" ],
:browser => selenium_browser,
:timeout_in_second => 90)
@browser.start_new_browser_session
@browser.open "/"
@sgrove
sgrove / gist:676194
Created November 14, 2010 23:06
:vana-inflector example
> (use-package :vana-inflector)
> (let ((dollars 1.7)
(users 34)
(purchases 1))
(format nil "The site has ~D ~A, with a total of ~D ~A and $~D ~A"
users (pluralize users "user")
purchases (pluralize purchases "purchase")
dollars (pluralize dollars "dollar")))
"The site has 34 users, with a total of 1 purchase and $1.7 dollars"
@sgrove
sgrove / gist:676196
Created November 14, 2010 23:08
:vana-inflector pluralize
(defun pluralize (count word &optional plural)
(if (not (= count 1))
(or plural
(plural-of word))
word))
@sgrove
sgrove / gist:676198
Created November 14, 2010 23:09
:vana-inflector inflector-helper
(defun inflector-helper (word regexes)
(if (null regexes)
word
(multiple-value-bind (string match-found?)
(cl-ppcre:regex-replace (first (first regexes)) word (second (first regexes)))
(if match-found?
string
(inflector-helper word (rest regexes))))))
@sgrove
sgrove / gist:676199
Created November 14, 2010 23:10
:vana-inflector plural-of
(defun plural-of (word)
"Returns the plural of a word if it's singular, or itself if already plural"
(cond ((uncountable? word) word)
((irregular? word) (get-irregular-plural word))
(t (inflector-helper word *plurals*))))
@sgrove
sgrove / gist:676200
Created November 14, 2010 23:10
:vana-inflector uncountable? irregular?
(defun uncountable? (word)
(member word *uncountables* :test #'string-equal))
(defun irregular? (word)
(or (-> word *irregulars*)
(rassoc word *irregulars* :test #'string-equal)))