Skip to content

Instantly share code, notes, and snippets.

View voidlily's full-sized avatar

voidlily

View GitHub Profile
# Sinatra
error 404 do
"WHAT THE HELL DID YOU DO [PERSON'S NAME HERE]?? YOU BROKE IT, PEOPLE ARE DYING, WHYY"
end
# incorrect
time = Time.zone.parse('2011-11-06T01:00:00')
=> Sun, 06 Nov 2011 01:00:00 PDT -07:00
time.advance(hours: 1).beginning_of_hour
=> Sun, 06 Nov 2011 01:00:00 PDT -07:00
# correct usage
time.utc.advance(hours: 1).change(min: 0).in_time_zone
(defn rent [initial year]
"Calculates the rent for a given year. Assumes 1.9% increase yearly based on SF rent control."
(* initial (Math/pow 1.019 year)))
(defn rent-seq [price]
"Generates a lazy infinite sequence of rent increases based on a given base price."
(map #(rent price %) (iterate inc 0)))
; Get the projected rent increases for living at a place for 10 years
(->> (rent-seq 2000) (take 10) (map #(format "%.2f" %)))
@voidlily
voidlily / universe.clj
Last active January 30, 2017 03:31
Calculate prereqs for a universe in ITRTG
#!/usr/bin/env lein-exec
;;; Calculator for manual creations given a CC value
;;; Based on numbers from
;;; http://www.kongregate.com/forums/2874-idling-to-rule-the-gods/topics/453555-creating-a-universe#posts-9414071
;;;
;;; Usage: universe.clj <cc> <number of universes>
(require '[clojure.pprint :refer (print-table)])