Skip to content

Instantly share code, notes, and snippets.

View gigasquid's full-sized avatar

Carin Meier gigasquid

View GitHub Profile
@gigasquid
gigasquid / mary.clj
Created February 6, 2013 14:02
Mary had a little lamb in overtone
(ns overtone-tutorial.mary)
(use 'overtone.core)
(boot-external-server)
(definst saw-wave [freq 440 attack 0.01 sustain 0.4 release 0.1 vol 0.4]
(* (env-gen (lin-env attack sustain release) 1 1 0 1 FREE)
(saw freq)
vol))
@gigasquid
gigasquid / flight_with_goals_beliefs.log
Created February 4, 2013 02:24
AR Drone Auto-Flight based on streaming navigation data and goals and beliefs
INFO - Starting navdata stream
INFO - Creating navdata stream
INFO - navdata: {:altitude 0.0, :control-state :default, :seq-num 22291}
INFO - goal list: I want to fly., I want to get to a cruising altitude of 1 m, I want to land current-goal: I want to fly. current-belief: I am too low
INFO - navdata: {:altitude 0.0, :control-state :landed, :seq-num 22292}
INFO - goal list: I want to fly., I want to get to a cruising altitude of 1 m, I want to land current-goal: I want to fly. current-belief: I am landed
INFO - navdata: {:altitude 0.0, :control-state :trans-takeoff, :seq-num 22293}
INFO - goal list: I want to fly., I want to get to a cruising altitude of 1 m, I want to land current-goal: I want to fly. current-belief: I am landed
INFO - navdata: {:altitude 0.0, :control-state :trans-takeoff, :seq-num 22294}
INFO - goal list: I want to fly., I want to get to a cruising altitude of 1 m, I want to land current-goal: I want to fly. current-belief: I am landed
@gigasquid
gigasquid / clj-drone.clj
Created January 2, 2013 03:18
Baby Steps Clojure AR Drone
(ns clj-drone.core
(:import (java.net DatagramPacket DatagramSocket InetAddress)))
(def drone-host (InetAddress/getByName "192.168.1.1"))
(def at-port 5556)
(def socket (DatagramSocket. ))
(defn send-command [data]
(.send socket
@gigasquid
gigasquid / change_for.clj
Created December 5, 2012 14:03
Code and Coffee - 12/5/2012
defn change-for [change coins returning]
(let [ coin (first coins)
others (rest coins)
]
(cond
(= change 0) returning
(>= change coin) (change-for (mod change coin) others (conj returning {coin (int (/ change coin))}))
:else (change-for change others returning))))
(defn make-change [price tendered]
@gigasquid
gigasquid / baba-yaga-reducers.clj
Created July 7, 2012 23:22
Baba Yaga Reducers
(ns reducers.core
(:require [clojure.core.reducers :as r]))
(map + [1 2 3]) ;=> (1 2 3)
(class(map + [1 2 3])) ;=> (1 2 3)
(def odyssey-text (slurp "odyssey.txt"))
(class odyssey-text) ;=> java.lang.String
(first odyssey-text) ;=> \P
@gigasquid
gigasquid / berlin_clock_swarm.clj
Created May 9, 2012 13:04
Berlin Clock Swarm
;; given 3 integers in a sequence
;; generate the number of lights that are on in a berlin clock,
;; returning 5 rows
(defn make-counts [[hours minutes seconds]]
[
(- 1 (mod seconds 2))
(int (/ hours 5))
(mod hours 5)
(int (/ minutes 5))
(mod minutes 5)
@gigasquid
gigasquid / swarmcoding
Created May 8, 2012 22:04
Swarm coding instructions
1) Get a browser open to http://23.23.246.103:8080 (you will need this later)
2) Download the private key for swarming http://23.23.246.103:8080/keys/cincyfp
3) ssh -i cincyfp swarm@23.23.246.103
Follow the instructions when you get in!
@gigasquid
gigasquid / gist:2296961
Created April 4, 2012 01:26 — forked from AlexBaranosky/gist:2296469
Try expect
;; Current version -- note the use of `when-valid`... it is essentially duplicating the work the
;; syntax-validation-m monad should be able to handle, so I've been attempting to
;; clean it up / refactor it to use only the monad
(defmacro expect
"Run the call form, check that all the mocks defined in the fakes
(probably with 'fake') have been satisfied, and check that the actual
results are as expected. If the expected results are a function, it
will be called with the actual result as its single argument.
;; Current version -- note the use of `when-valid`... it is essentially duplicating the work the
;; syntax-validation-m monad should be able to handle, so I've been attempting to
;; clean it up / refactor it to use only the monad
(defmacro expect
"Run the call form, check that all the mocks defined in the fakes
(probably with 'fake') have been satisfied, and check that the actual
results are as expected. If the expected results are a function, it
will be called with the actual result as its single argument.
@gigasquid
gigasquid / roman-number-converter.clj
Created November 23, 2011 14:39
Roman Numbers (Clojure)
(ns roman-nums
(:use clojure.test))
(def chart (zipmap [1 4 5 9 10 40 50 90 100 400 500 900 1000]
["I" "IV" "V" "IX" "X" "XL" "L" "XC" "C" "CD" "D" "CM" "M"]))
;; Using no tail recursion
(defn arabic-to-roman [n]
(let [[val c] (last