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
-- Open a SQLite shell by issuing the command below | |
-- sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* | |
select LSQuarantineDataURLString from LSQuarantineEvent order by LSQuarantineTimeStamp asc limit 1; | |
-- For me, it's GNU Emacs. | |
-- sqlite> select LSQuarantineDataURLString from LSQuarantineEvent order by LSQuarantineTimeStamp asc limit 1; | |
-- http://bandwidth.porkrind.org/emacs-builds/Emacs-24.2-universal-10.6.8.dmg |
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 ^{:doc "Word frequencies in a text file." | |
:author "Baishampayan Ghose <b.ghose@helpshift.com>"} | |
meetup.freq | |
(:require [clojure.java.io :as io] | |
[clojure.string :as s])) | |
(def stop-word? #{"is" "the" "am" "i" "that" "if"}) ;; fill it up! | |
;;; all these functions are written in a "point free" style | |
(def get-lines (comp line-seq io/reader)) |
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 ^{:doc "Read Java properties file." | |
:author "Baishampayan Ghose <b.ghose@gmail.com>"} | |
in.freegeek.props | |
(:import java.util.Properties) | |
(:require [clojure.java.io :refer [resource reader]] | |
[clojure.string :refer [split]])) | |
(defn- load-props | |
"Load a Java properties file. File should be in classpath." | |
[props-file] |
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 props.core | |
(:require [clojure.string :refer [split]] | |
[clojure.java.io :refer [reader]]) | |
(:import java.util.Properties)) | |
(defn- split-key | |
"Split a string key to its subparts. | |
foo -> [foo] | |
foo.bar.baz -> [foo bar baz]" |
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
; STM history stress-test | |
(defn stress [hmin hmax] | |
(let [r (ref 0 :min-history hmin :max-history hmax) | |
slow-tries (atom 0)] | |
(future | |
(dosync | |
(swap! slow-tries inc) | |
(Thread/sleep 200) | |
@r) |
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
;;; 99 bottles of beer in Clojure | |
(def bottles " | |
# 99 Bottles of Beer | |
# Brainfuck version | |
# by Michal Wojciech Tarnowski | |
+>+++++++[>>>+++ | |
+++++<<<<+++++ |
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 ^{:doc "Uniquify" | |
:author "Baishampayan Ghose <b.ghose@helpshift.com>"} | |
uniquify | |
(:require [clojure.string :refer [join]])) | |
(defn explode | |
"Explode a directory name to its subcomponents." | |
[^String dir] | |
(seq (.split dir "/"))) |
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 prime-sieve | |
(:require [clojure.core.async :as async :refer [chan go <! >!]])) | |
;;; concurrent prime sieve in Clojure using core.async | |
;; inspired by a similar implementation in Go | |
;; http://golang.org/doc/play/sieve.go | |
(defmacro go-forever | |
"An infinite loop that runs in a go block." |
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 gevent import monkey; monkey.patch_all() | |
import gevent | |
import gevent.greenlet | |
from functools import partial | |
from random import random | |
import urllib | |
import urllib2 | |
def on_exception(fun, greenlet): |
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 clj-spec-playground | |
(:require [clojure.string :as str] | |
[clojure.spec :as s] | |
[clojure.test.check.generators :as gen])) | |
;;; examples of clojure.spec being used like a gradual/dependently typed system. | |
(defn make-user | |
"Create a map of inputs after splitting name." | |
([name email] |