Skip to content

Instantly share code, notes, and snippets.

View msgodf's full-sized avatar

Mark Godfrey msgodf

View GitHub Profile
@msgodf
msgodf / euroclojure-2015-talks
Last active August 29, 2015 14:20
EuroClojure 2015 talks
https://twitter.com/pyr "talking about #mesos and mesomatic: the cluster is a library"
https://twitter.com/AdamTornhill "Beyond Code: Repository Mining with #Clojure"
https://twitter.com/kachayev "Reinventing Haxl: Efficient, Concurrent and Concise Data Access"
https://twitter.com/ifesdjeen "Clojure is a sweet spot for Analytics"
https://twitter.com/mtrimpe "building Elephant 2000, McCarthy’s programming language for 2015, using Clojure"
@msgodf
msgodf / intro-clojure.org
Created March 19, 2015 16:18
Clojure intro

Intro to Clojure

Overview

First three hours of Clojure.

Small (~3 people) group, Java experience, some Javascript and other dynamic language experience - no prior Clojure knowledge is assumed.

What can you learn?

@msgodf
msgodf / update_at.clj
Created November 5, 2014 14:13
A function to update multiple parts of a structure.given a function that gives the locations of those parts.
(defn update-at
"Takes a structure, a function that returns a list of paths (lists of keys) and a
function to apply at those paths within the structure.
For any paths that don't already exist in m, then f will be called with nil
and that path in the structure will be created with the result."
[m path-generation-fn f]
(reduce (fn [s v] (update-in s v f))
m
(path-generation-fn m)))
@msgodf
msgodf / .vimrc
Created August 9, 2014 07:31
My .vimrc
set nocompatible
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
@msgodf
msgodf / .Xdefaults
Created July 21, 2014 10:35
My X configuration
! xscreensaver ---------------------------------------------------------------
!font settings
xscreensaver.Dialog.headingFont: -*-dina-bold-r-*-*-10-*-*-*-*-*-*-*
xscreensaver.Dialog.bodyFont: -*-dina-medium-r-*-*-10-*-*-*-*-*-*-*
xscreensaver.Dialog.labelFont: -*-dina-medium-r-*-*-10-*-*-*-*-*-*-*
xscreensaver.Dialog.unameFont: -*-dina-medium-r-*-*-10-*-*-*-*-*-*-*
xscreensaver.Dialog.buttonFont: -*-dina-bold-r-*-*-10-*-*-*-*-*-*-*
xscreensaver.Dialog.dateFont: -*-dina-medium-r-*-*-10-*-*-*-*-*-*-*
xscreensaver.passwd.passwdFont: -*-dina-bold-r-*-*-10-*-*-*-*-*-*-*
@msgodf
msgodf / .bashrc
Created July 17, 2014 11:01
My .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
@msgodf
msgodf / gist:4f6ca8a1df5c65bb9483
Created July 17, 2014 10:46
Encode a bunch of FLAC files in the current directory to MP3
ls -1|sed -e "s/'/\\\'/g" -e "s/.flac//g"|xargs -I{} avconv -i {}.flac -c:a libmp3lame -b:a 256k {}.mp3
@msgodf
msgodf / core_async_merge_behaviour.clj
Created March 5, 2014 17:07
Some code to test the behaviour of Clojure core.async's merge function. Given two channels that produce values at a given intervals, merge them and see whether the two sequences are interleaved or concatenated.
(require '[clojure.core.async :as async refer [<! go timeout])
(defn sleepy-val
[v t]
(go (<! (timeout t)) v))
;; Will this produce [1 2 3 1.5 2.5 3.5] or [1 1.5 2 2.5 3 3.5]?
(go
(prn (<! (async/into []
(async/merge [(.async/merge [(sleepy-val 1 1000)
@msgodf
msgodf / async-merge.clj
Last active August 29, 2015 13:57
Just a quick demo of how the Clojure core.async merge function works. I wanted to check that the values from the input channels appear in the merged channel straight away.
(clojure.core.async/go
(let [sleepy-val (fn [v t] (clojure.core.async/go
(clojure.core.async/<! (clojure.core.async/timeout t))
v))
chans (clojure.core.async/merge (map #(sleepy-val % (rand-int 3000))
(range 10)))]
(while (when-let [v (clojure.core.async/<! chans)]
(prn v)
v))))
@msgodf
msgodf / core.cljs
Created March 1, 2014 20:26
A Clojurescript port of the first of the Web Audio API examples from HTML5 Rocks (http://www.html5rocks.com/en/tutorials/webaudio/intro/)
(ns cljsaudio.core
(:require [goog.net.XhrIo]
[cljs.core.async :as async :refer [<! >! chan close!]])
(:require-macros [cljs.core.async.macros :refer [go]]))
(defn decode-audio-data
[context data]
(let [ch (chan)]
(.decodeAudioData context
data