This file contains 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
import XMonad | |
import qualified Data.Map as M | |
import Data.Bits ((.|.)) | |
import XMonad.Layout.Grid | |
import XMonad.Config.Gnome | |
import XMonad.Layout.TwoPane | |
import XMonad.Layout.LayoutScreens | |
import XMonad.Config.Desktop (desktopLayoutModifiers) |
This file contains 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 demo-interface.xhr-util | |
(:require [cljs.core.async :as async :refer [<! >! chan close! timeout put!]] | |
[goog.net.XhrIo :as xhr] | |
[goog.structs :as structs] | |
[goog.Uri.QueryData :as QueryData])) | |
;; goog xhr helpers | |
(defn xhr-event-to-edn | |
"Extract useful info from a response, return a map" | |
[event] |
This file contains 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 concur [] | |
(let [numchan (chan) | |
stringchan (chan)] | |
(go | |
(let [a (<! numchan) | |
b (<! numchan) | |
c (<! numchan)] | |
(>! stringchan (str a " + " b " + " c " = " (+ a b c))))) | |
(go (<! (timeout (rand-int 100))) (>! numchan (* 2 10))) | |
(go (<! (timeout (rand-int 100))) (>! numchan (* 2 20))) |
This file contains 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
# !/usr/bin/env sh | |
hook() { | |
local hook=.git/hooks/$1.sh | |
if test -f $hook; then | |
echo "... $1" | |
. $hook | |
fi | |
} |
This file contains 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
kernel=`uname` | |
if [ "$kernel" = 'Darwin' ]; then | |
function grep_port { | |
lsof -n -i4TCP:$1 | grep LISTEN | |
} | |
else | |
function grep_port { | |
netstat -pntl | grep $1 | |
} |
This file contains 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 fb-smileys.core | |
(:use [clojure.test]) | |
(:gen-class)) | |
(def reg #"(\(.*?)(:\))?(:\()?(\))") | |
(defn rm-smileys [line] | |
(-> line | |
(clojure.string/replace ":)" "") | |
(clojure.string/replace ":(" ""))) |
This file contains 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
from functools import partial, wraps | |
from threading import Thread | |
from time import sleep | |
import tornado | |
from tornado.ioloop import IOLoop | |
def threaded(func): | |
@wraps(func) |
This file contains 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
;; response to http://squirrel.pl/blog/2013/01/16/clojurescript-painkiller-for-oop/ | |
(defn Bag [] | |
(this-as this | |
(set! (.-store this) (array)) | |
this)) | |
(defprotocol MyBag | |
(add [this val]) | |
(print [this])) |
This file contains 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
""" | |
Turn an example dictionary into a voluptious schema | |
""" | |
import pprint | |
import re | |
import sys | |
import voluptuous | |
This file contains 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
def trim(text, max=100): | |
"""Trim a string to `max` chars | |
""" | |
if len(text) > max: | |
return text[:max] | |
return text | |
class StatsDict(dict): |