- Should make specifying keybindings externally easy, through resources.
- Should be easy like
(listen)
- Should be consistent with rest of event system.
This file contains hidden or 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
;; | |
;; General MIDI defines instruments for 128 program numbers | |
;; http://www.midi.org/techspecs/gm1sound.php | |
;; | |
;; javax.sound.midi numbers the instruments from 0 rather than 1, so acoustic-grand-piano is 0. | |
;; | |
(def GM | |
{:acoustic-grand-piano 0 | |
:bright-acoustic-piano 1 |
This file contains hidden or 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 hidden or 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 tarai.core | |
(:use [overtone.live])) | |
;; basic.clj より | |
(defsynth foo [freq 200 dur 0.5] | |
(let [src (saw [freq (* freq 1.01) (* 0.99 freq)]) | |
low (sin-osc (/ freq 2)) | |
filt (lpf src (line:kr (* 10 freq) freq 10)) | |
env (env-gen (perc 0.1 dur) :action FREE)] | |
(out 0 (pan2 (* 0.1 low env filt))))) |
This file contains hidden or 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
;; chouser's solution to Read Roman numerals | |
;; https://4clojure.com/problem/92 | |
(fn [r] | |
(->> | |
(reverse r) | |
(map {\M 1000 \D 500 \C 100 \L 50 \X 10 \V 5 \I 1}) | |
(cons 0) | |
(partition 2 1) | |
(reduce |
This file contains hidden or 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 hidden or 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 hidden or 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 reify-generic | |
"reify a protocol such that every method is delegated to a specified method") | |
(defmacro reify-generic | |
"Reify the given protocols. Every method of any protocol is implemented such | |
that f is called as (apply f protocol-method args) | |
Example: | |
(defprotocol Calculator |
This file contains hidden or 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] |