Skip to content

Instantly share code, notes, and snippets.

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)
(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]
@minimal
minimal / core.cljs
Last active December 19, 2015 18:39
(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)))
# !/usr/bin/env sh
hook() {
local hook=.git/hooks/$1.sh
if test -f $hook; then
echo "... $1"
. $hook
fi
}
@minimal
minimal / .zshrc.sh
Last active December 15, 2015 11:29
kernel=`uname`
if [ "$kernel" = 'Darwin' ]; then
function grep_port {
lsof -n -i4TCP:$1 | grep LISTEN
}
else
function grep_port {
netstat -pntl | grep $1
}
@minimal
minimal / core.clj
Last active December 11, 2015 21:09
facebook balanced smilies
(ns fb-smileys.core
(:use [clojure.test])
(:gen-class))
(def reg #"(\(.*?)(:\))?(:\()?(\))")
(defn rm-smileys [line]
(-> line
(clojure.string/replace ":)" "")
(clojure.string/replace ":(" "")))
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)
;; 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]))
"""
Turn an example dictionary into a voluptious schema
"""
import pprint
import re
import sys
import voluptuous
def trim(text, max=100):
"""Trim a string to `max` chars
"""
if len(text) > max:
return text[:max]
return text
class StatsDict(dict):