Skip to content

Instantly share code, notes, and snippets.

View daveray's full-sized avatar

Dave Ray daveray

View GitHub Profile
@jasonrudolph
jasonrudolph / 00-about.md
Created September 21, 2012 18:42
Rough Notes from Strange Loop 2012
@Folcon
Folcon / clipboard-utils.clj
Created August 24, 2011 11:50
Just a quick clipboard slip/slurp I put together because I didn't find anything similar, don't know if it's useful for anyone but found it invaluable when getting large strings being returned from the repl and sticking the result in an editor for more car
(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))
@briandealwis
briandealwis / gist:782862
Created January 17, 2011 13:55 — forked from spullara/gist:782523
One-liner to turn jar with Main-Class into executable shell script
# 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
@weavejester
weavejester / gist:1001206
Created May 31, 2011 20:27
Clojure on Heroku
~/$ 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]
@andrewsardone
andrewsardone / screen-crash-course.md
Created August 26, 2011 13:10
GNU Screen Crash Course

GNU Screen Crash Course

Introduction

A real quick GNU screen crash course with the key features I use.

man screen

  • Emulates terminals in a full-screen window manager
  • Detachable, so shell sessions aren't attached to a login process
@jramb
jramb / kormatest.clj
Created December 26, 2011 14:07
Playing with Clojure Korma SQL
(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"
@Chouser
Chouser / gmail.clj
Created March 24, 2012 18:18
Send email via gmail from Clojure
(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 []
@laurentpetit
laurentpetit / nrepl_events.clj
Created December 19, 2013 14:26
Adds 2 launch event listeners that spit the created nrepl server port into ~/.nrepl and <project-dir>/.nrepl files
(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")
@ordnungswidrig
ordnungswidrig / state-is-a-fold.clj
Created June 16, 2011 15:50
State is a fold over events
(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))))
@aphyr
aphyr / -log
Last active December 22, 2015 02:19
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