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
; A REPL-based, annotated Seesaw tutorial | |
; Please visit https://github.com/daveray/seesaw for more info | |
; | |
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers | |
; Seesaw's basic features and philosophy, but only scratches the surface | |
; of what's available. It only assumes knowledge of Clojure. No Swing or | |
; Java experience is needed. | |
; | |
; This material was first presented in a talk at @CraftsmanGuild in | |
; Ann Arbor, MI. |
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
;; Datomic example code | |
;; demonstrates various update scenarios, using a news database | |
;; that contains stories, users, and upvotes | |
;; grab an in memory database | |
(use '[datomic.api :only (q db) :as d]) | |
(def uri "datomic:mem://foo") | |
(d/create-database uri) | |
(def conn (d/connect uri)) |
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
;; Datomic example code | |
;; | |
;; The extent of entity ?x is all datoms that are about ?x. | |
;; Drop this into your rules. | |
;; | |
;; Demonstrates | |
;; | |
;; 1. recursive query (extent calls itself) | |
;; 2. disjunction (different extent bodies are ORed) | |
;; 3. component attributes (e.g. your arm is a component, your brother isn't) |
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
(require '[buddy.core.codecs.base64 :as base64] | |
'[cognitect.aws.util :as util] | |
'[clojure.string :as str] | |
'[jsonista.core :as json] | |
'[cognitect.aws.credentials :as creds] | |
'[cognitect.aws.http :as http]) | |
(import '[java.util Date]) | |
(defn host-style-bucket-uri [bucket] | |
(str "http://" bucket ".s3.amazonaws.com/")) |
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
(import '(javax.sound.midi MidiSystem Synthesizer)) | |
(defn play-note [synth channel note-map] | |
(let [{:keys [note velocity duration] | |
:or {note 60 | |
velocity 127 | |
duration 1000}} note-map] | |
(. channel noteOn note velocity) | |
(Thread/sleep duration) | |
(. channel noteOff note))) |
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 net.cgrand.decay | |
"Exponentially decaying lists. See http://awelonblue.wordpress.com/2013/01/24/exponential-decay-of-history-improved/ | |
for background and http://clj-me.cgrand.net/2013/02/12/decaying-lists-log-scale-for-lists/ for documentation") | |
;; PRNG, formulas straight from java.util.Random javadoc | |
(defn- seed ^long [^long n] | |
(bit-and (unchecked-multiply n 0x5DEECE66D) | |
(unchecked-dec (bit-shift-left 1 48)))) | |
(defn- next-seed ^long [^long seed] |
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
;; This previously was CLJX but has now been updated to use cljc. Thanks @caskolkm | |
;; https://gist.github.com/caskolkm/39d823f5bac7051d3062 | |
(ns app.logging | |
(:refer-clojure :exclude [time]) | |
(:require #?(:clj [clojure.tools.logging :as log] | |
:cljs [goog.log :as glog])) | |
#?(:cljs (:import goog.debug.Console))) | |
#?(:cljs |
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
# Commands to initialize a simple heroku noir app. You can cut and paste them together. | |
# Install latest version of noir. If an older version is installed, remove it first. | |
lein plugin install lein-noir "1.1.0-SNAPSHOT" | |
# Create new noir project. | |
lein noir new noir-mongo-heroku | |
cd noir-mongo-heroku | |
# Create instructions for heroku. | |
echo 'web: lein run' > Procfile | |
# Create git repository. |
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
(use '[datomic.api :only [q db] :as d]) | |
(def uri "datomic:mem://accounts") | |
;; create database | |
(d/create-database uri) | |
;; connect to database | |
(def conn (d/connect uri)) |
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
commit 8e51c34ca4d97e48750850d5ba09956f89783b4e | |
Author: Kyle Kingsbury <aphyr@aphyr.com> | |
Date: Wed May 7 19:06:15 2014 -0700 | |
Improve Keyword.intern performance | |
Keyword interning is an expensive factor in many Clojure | |
serialization/deserialization paths, especially where the same set of | |
keywords are created and freed repeatedly; e.g. iterating over records | |
with similar structure. There are two principle costs to keyword |
NewerOlder