Skip to content

Instantly share code, notes, and snippets.

msgodf / async-merge.clj
Last active Aug 29, 2015
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.
View async-merge.clj
(let [sleepy-val (fn [v t] (clojure.core.async/go
(clojure.core.async/<! (clojure.core.async/timeout t))
chans (clojure.core.async/merge (map #(sleepy-val % (rand-int 3000))
(range 10)))]
(while (when-let [v (clojure.core.async/<! chans)]
(prn v)
msgodf / core_async_merge_behaviour.clj
Created Mar 5, 2014
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.
View core_async_merge_behaviour.clj
(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]?
(prn (<! (async/into []
(async/merge [(.async/merge [(sleepy-val 1 1000)
msgodf / gist:4f6ca8a1df5c65bb9483
Created Jul 17, 2014
Encode a bunch of FLAC files in the current directory to MP3
View gist:4f6ca8a1df5c65bb9483
ls -1|sed -e "s/'/\\\'/g" -e "s/.flac//g"|xargs -I{} avconv -i {}.flac -c:a libmp3lame -b:a 256k {}.mp3
View .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
msgodf / .Xdefaults
Created Jul 21, 2014
My X configuration
View .Xdefaults
! 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-*-*-*-*-*-*-*
View .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 / update_at.clj
Created Nov 5, 2014
A function to update multiple parts of a structure.given a function that gives the locations of those parts.
View update_at.clj
(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))
(path-generation-fn m)))
msgodf / euroclojure-2015-talks
Last active Aug 29, 2015
EuroClojure 2015 talks
View euroclojure-2015-talks "talking about #mesos and mesomatic: the cluster is a library" "Beyond Code: Repository Mining with #Clojure" "Reinventing Haxl: Efficient, Concurrent and Concise Data Access" "Clojure is a sweet spot for Analytics" "building Elephant 2000, McCarthy’s programming language for 2015, using Clojure"
View gist:888d90bb90b94d87d5bf
st = status
lg = log
ci = commit -v
co = checkout
br = branch
# View stash diffs - use n to go to the next stash and N to go to the previous stash
stp = "!IFS=$'\n';for stash in $(git stash list);do echo $stash;echo;git --no-pager diff --color=always $(echo $stash|cut -f1 -d:);done|less -pstash"
msgodf /
Created Jun 21, 2015
Get host names of any machines connected to my local network
for i in $(seq 255);
nslookup 192.168.1.$(echo $i) >/dev/null;
if [ $? -ne 1 ];
echo -n 192.168.1.$i;
nslookup 192.168.1.$(echo $i)|grep name|cut -d= -f2;