Skip to content

Instantly share code, notes, and snippets.

View gigasquid's full-sized avatar

Carin Meier gigasquid

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / fizzbuzz.hs
Created February 13, 2013 03:03
Fizzbuzz with HUnit and Quick Check - in progress from Cincy FP
-- Example.hs -- Examples from HUnit user's guide
--
-- For more examples, check out the tests directory. It contains unit tests
-- for HUnit.
module Main where
import Test.HUnit
import Test.QuickCheck
@gigasquid
gigasquid / countdown.hs
Created February 13, 2013 03:06
Nasa Countdown in Haskell with HUnit - from Cincy FP
module Main where
import Test.HUnit
-- nasa :: Int -> [Int] -- | []
nasa n = reverse [0..n]
-- | n <= 0 = [0]
-- | otherwise = n : (nasa $ n - 1)
-- test1 :: Test
@gigasquid
gigasquid / brackets.clj
Created June 5, 2013 13:23
Clojure and Coffee with Instaparse
(ns brackets.core-test
(:use clojure.test
brackets.core
instaparse.core))
(def my-parser
(parser
"S = func-apply | vector | integer
integer = #'[0-9]+'
<space> = <' '>