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 memotest │ | |
(:require [clojure.core.memoize :as memo]) │ | |
(:import [java.util Date])) │ | |
│ | |
(defn memo-test-impl [] │ | |
(when (< 0.5 (rand)) |
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
;; Good | |
(try | |
(insert-a-batch …) | |
(publish-message {:type “redshift-connection”, :state “ok”, :client_id 3, :connection_id 123, :created-at “…”}) | |
(catch DiskFullError e | |
(publish-message {”redshift-connection”, :state “error”, :client_id 3, “error-type “disk full”, :created-at "..."})) | |
(catch ConnectionError e | |
(publish-message {”redshift-connection”, :state “error”, :client_id 3, “error-type “connection error”, :created-at "..."}))) | |
;; Bad |
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 make-user [first-name last-name email] | |
(cond-> {} | |
first-name (assoc :first-name first-name) | |
last-name (assoc :last-name last-name) | |
email (assoc :email email))) |
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
EXPLAIN UPDATE | |
"25" | |
SET | |
"556" = "555", | |
"654" = "653", | |
"655" = "651", | |
"656" = "652", | |
"533" = "347" | |
FROM | |
"24" |
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
(defprotocol Ageable | |
(age [this])) | |
(defprotocol Nameable | |
(get-name [this])) | |
(defrecord Person [first-name last-name birthday] | |
Ageable | |
(age [this] |
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
"""Code for grouping samples together. | |
A layout is simply a list of collections of numbers. Each number | |
represents a a column number in the (feature x sample) table. Each of | |
the inner collections represents a group of samples that share the | |
same value of some attribute. So the whole layout represents some | |
grouping of samples. | |
For example, this layout represents four groups, each with three columns:: |
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
(let [total 1000 | |
period 100 | |
progress (lang/make-periodic-invoker | |
period | |
#(printf "So far we did %d, we are %3.2f%% complete.\n" % (* 100.0 (/ % 1.0 total))))] | |
(dotimes [ii total] | |
;; do some work / processing here | |
(progress)) | |
(println "I'm all done")) |
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
package com.whatever | |
import org.apache.commons.logging.LogFactory | |
class Foo { | |
private static final def LOG = LogFactory.getLog("com.whatever.Foo") | |
def var() { | |
LOG.debug("Some message") |
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
if(table[i][k].contains(p.tail.substring(0,1)) && | |
table[k+1][j].contains(p.tail.substring(1, 2))){ | |
table[i][j] += p.head; | |
} |
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 your.programs.namespace | |
;; ... | |
(:use [swank/swank :as swank]) | |
(defn main [& args] | |
;; ... | |
(swank/start-repl)) |
NewerOlder