This gist is a collection of my rough notes from Strange Loop 2012.
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 get-clipboard [] | |
(.getSystemClipboard (java.awt.Toolkit/getDefaultToolkit))) | |
(defn slurp-clipboard [] | |
(try | |
(.getTransferData (.getContents (get-clipboard) nil) (java.awt.datatransfer.DataFlavor/stringFlavor)) | |
(catch java.lang.NullPointerException e nil))) | |
(defn spit-clipboard [text] | |
(.setContents (get-clipboard) (java.awt.datatransfer.StringSelection. text) nil)) |
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
# turn a jar with a Main-Class into a stand alone executable | |
(echo '#!/usr/bin/env java -jar'; cat blahblah.jar) > blah | |
# turn a jar with a particular main clas into a stand alone executable | |
(echo '#!/usr/bin/env java -jar package.MainClass'; cat blahblah.jar) > blah |
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
~/$ lein new ring-on-heroku | |
Created new project in: /home/jim/Development/ring-on-heroku | |
~/$ cd ring-on-heroku | |
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile | |
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj | |
(ns ring-on-heroku.core | |
(:use ring.util.response | |
ring.adapter.jetty)) | |
(defn app [req] |
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 kormatest.core | |
(:require [korma.core :as sql]) | |
(:require [korma.db :as db]) | |
(:require [clojure.contrib.sql :as jdbc])) | |
(def play-con | |
(db/mysql {:db "playground" | |
;; :host "localhost" ;; optional? | |
:port "3406" ;; normal: 3306 | |
:user "root" |
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 foo | |
(:import (java.util Properties) | |
javax.mail.internet.MimeMessage | |
(javax.mail.internet MimeMessage InternetAddress) | |
(javax.mail Session Transport Authenticator | |
PasswordAuthentication Message$RecipientType))) | |
(defn send-gmail [{:keys [from to subject text user password]}] | |
(let [auth (proxy [Authenticator] [] | |
(getPasswordAuthentication [] |
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 nrepl-events | |
(:require [ccw.core.launch :as l] | |
[clojure.java.io :as io] | |
[ccw.eclipse :as e])) | |
(defn spit-globally | |
"global ~/.nrepl file" | |
[{:keys [event-type port project]}] | |
(when (= :creation event-type) | |
(spit (io/file (java.lang.System/getProperty "user.home") ".nrepl") |
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 state-is-a-fold | |
(:use clojure.test)) | |
;;; After all, state is a fold of events. For example let's say the events are a sequence of numbers | |
;;; and we are folding by addition: | |
(deftest simple | |
(let [events [1 5 2 4 3] | |
state (reduce + events)] | |
(is (= 15 state)))) |
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
In http://www.datastax.com/dev/blog/row-level-isolation and | |
http://www.datastax.com/dev/blog/atomic-batches-in-cassandra-1-2, Datastax | |
asserts that batch updates to multiple cells in a single row are | |
guaranteed to be isolated from concurrent batches: | |
"Cassandra 1.1 guarantees that if you update both the login and password in the | |
same update (for the same row key) then no concurrent read may see only a | |
partial update." | |
"...the guarantee is that the new login cannot be persisted without the new |
NewerOlder