This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn score | |
"Score site with pssm" | |
[pssm site] | |
(reduce (fn [acc [col-hash c]] | |
(+ acc (col-hash c))) | |
0 | |
(zip pssm site))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn add-context-fn | |
[attr context] | |
(fn [node] | |
(update-in | |
node | |
[:attrs attr] | |
(fn [val] | |
(let [val (str val)] | |
(if (or (-> val java.net.URI. .isAbsolute) | |
(.startsWith val "//") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns com.gtrak.emu.chips.ym2612) | |
(defmacro defs | |
[& def-specs] | |
(let [def-specs (partition 2 def-specs) | |
forms (for [[var val] def-specs] | |
`(def ~var ~val))] | |
`(do ~@forms))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn restricted-logging | |
"Helper function to make cascading logging do something useful while running Hadoop queries." | |
[] | |
(doto (Logger/getRootLogger) | |
(.setLevel Level/INFO) | |
(.addAppender (WriterAppender. (SimpleLayout.) *out*))) | |
(-> (Logger/getRootLogger) | |
.getLoggerRepository | |
(.getLogger "org.apache.zookeeper") | |
(.setLevel Level/ERROR))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def mailbox-map | |
(vec (flatten [(repeat 20 -1) | |
(map #(do [-1 % -1]) | |
(partition 8 (range 64))) | |
(repeat 20 -1)]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def mailbox-map | |
(vec (concat (repeat 20 -1) | |
(flatten (map #(concat [-1] % [-1]) | |
(partition 8 (range 64)))) | |
(repeat 20 -1)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(12:10:18 PM) Gary Trakhman: screenshotting.. you are a talented noun-verber. | |
(12:10:39 PM) Gary Trakhman: to screenshoot maybe | |
(12:10:43 PM) Scott Bale: I know, right? | |
(12:11:39 PM) Alex Hall: @gary i believe 'screenshoot' is actually the noun form of the verb 'to screenshot' | |
(12:12:07 PM) Gary Trakhman: ah yes, a screenshoot | |
(12:12:15 PM) Scott Bale: but 'screenshot' is past-tense of 'screenshoot' verb | |
(12:13:00 PM) Scott Bale: You have to know how to conjugate these noun-verbs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
no.disassemble> (println (disassemble (class (fn [])))) | |
no/disassemble$eval11772$fn__11773 | |
#<byte[] [B@13940478> | |
// Compiled from NO_SOURCE_FILE (version 1.5 : 49.0, super bit) | |
public final class no.disassemble$eval11772$fn__11773 extends clojure.lang.AFunction { | |
// Method descriptor #7 ()V | |
// Stack: 0, Locals: 0 | |
public static {}; | |
0 return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns reflection | |
;;(:import nothing) | |
) | |
(defn class-loader | |
"could be any classloader" | |
[] | |
(.getContextClassLoader (Thread/currentThread))) | |
(defn get-class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro deferred | |
"Loads and runs a function dynamically to defer loading the namespace. | |
Usage: \"(deferred clojure.core/+ 1 2 3)\" returns 6. There's no issue | |
calling require multiple times on an ns." | |
[fully-qualified-func & args] | |
(let [func (symbol (name fully-qualified-func)) | |
space (symbol (namespace fully-qualified-func))] | |
`(do (require '~space) | |
(let [v# (ns-resolve '~space '~func)] | |
(v# ~@args))))) |