Skip to content

Instantly share code, notes, and snippets.

@zakwilson
zakwilson / skummet-fail
Created April 21, 2017 14:17
Skummet fails to compile Ceilingbounce
zak@bigbox ceilingbounce $ lein with-profile lean do clean, droid doall
Generating manifest...
Generating R.java files...
Compiling 3 source files to /media/zak/bd07aeae-4895-4289-88fe-329b1b7b92a2/code/ceilingbounce/target/classes
Compiling Clojure files...
Build type: debug, dynamic compilation: enabled, remote REPL: enabled.
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: clojure.core/*lean-var?* in this context, compiling:(/tmp/form-init52165355158824598.clj:1:269)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6740)
at clojure.lang.Compiler.analyze(Compiler.java:6534)
at clojure.lang.Compiler.analyze(Compiler.java:6495)
(first-truthy
(get-it-from-the-cache)
(get-it-from-the-network)
(ask-the-user)
(make-up-random-value)
(defmacro silence-errors [& body]
"Evaluate body and return the result, or nil if an exception is thrown"
`(try ~@body
(catch Exception e#)))
(defmacro first-truthy [& body]
"Try some expressions; return the result of the first one that neither throws an exception or returns false or nil"
(cons 'or (map (fn [item]
(list 'silence-errors item))
`~body)))
(defmacro silence-errors [& body]
"Evaluate body and return the result, or nil if an exception is thrown"
`(try ~@body
(catch Exception e#)))
(defmacro first-truthy [& body]
"Try some expressions; return the result of the first one that neither throws an exception or returns false or nil"
(cons 'or (map (fn [item]
(list 'silence-errors item))
`~body)))
description "train the spam filter"
instance $x
stop on reddit-stop or runlevel [016]
respawn
respawn limit 10 5
nice 10
@zakwilson
zakwilson / korma-npe.clj
Created December 2, 2011 18:27
Basic example with 0.3.0-alpha5 showing exception
(defdb db
(postgres {:password "a-password", :user "timeline", :db "timeline"})
(defentity tag
(database db)
(table :tags)
(pk :tag))
(sql-only (select tag))
@zakwilson
zakwilson / CQL-query.clj
Created December 1, 2011 09:39
Query in CQL
(defn user-feedback [user-id]
(-> (select users (where (= :users.id user-id)))
(join items (where (= :items.user_id :users.id)))
(join reservations (where (or (= :renter :users.id)
(= :item :items.id))))
(join feedback (where (= :reservation :reservations.id)))
distinct
(project [:feedback.id :feedback.reservation :feedback.score :feedback.sender :feedback.comment])))
(def bot-name "irclj_bot_test")
(def irc-server "irc.freenode.net")
(def irc-channel "#clojure")
(def msgs (agent []))
(def info (agent []))
(defn log-info [{:keys [nick channel message irc errors doing]}]
(send info conj message))
#app/models/document.rb
class Document < ActiveRecord::Base
has_attached_file :attachment, styles: {html: {}}, :processors => [:htmlprocessor]
attr_accessor :attachment_file_name
end
Started POST "/documents" for 127.0.0.1 at 2011-10-21 20:52:27 -0400
Processing by DocumentsController#create as HTML
Parameters: {"Filename"=>"Contract.odt", "_urcollege_session"=>"BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWIxODBkMTJhOWNlMDg1ZTY1NzZiZWM5ZGUxYjgxNGMxBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMXM0bzNzY3Z3TWE4WVh6UGZXandkRzJvTFkvVjJvcWNDRUo0M1JjQ1dnTUk9BjsARg==--4e8e0ce753d8618b22cc2e18e80bc753b4831f35", "authenticity_token"=>"s4o3scvwMa8YXzPfWjwdG2oLY/V2oqcCEJ43RcCWgMI=", "folder"=>"/documents/", "attachment"=>#<ActionDispatch::Http::UploadedFile:0x0000000588afe0 @original_filename="Contract.odt", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"attachment\"; filename=\"Contract.odt\"\r\nContent-Type: application/octet-stream\r\n", @tempfile=#<File:/tmp/RackMultipart20111021-29558-ungtwg>>, "Upload"=>"Submit Query"}
(0.1ms) BEGIN
SQL (5.1ms) INSERT INTO "documents" ("attachment", "created_at", "processed", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id" [