This file contains hidden or 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
;; This buffer is for notes you don't want to save, and for Lisp evaluation. | |
;; If you want to create a file, visit that file with C-x C-f, | |
;; then enter the text in that file's own buffer. | |
curl -XPOST "http://localhost:8098/mapred" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"inputs":"logs", | |
"query":[{ | |
"map":{ |
This file contains hidden or 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
curl -XPOST "http://localhost:8098/mapred" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"inputs":{ | |
"bucket":"cart", | |
"key_filters": [ | |
["tokenize", "-", 2], | |
["string_to_int"], | |
["greater_than", 97000]]}, | |
"query":[{ |
This file contains hidden or 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
#!/bin/bash | |
# * * * * * root /path/to/riak_graphite_stats.sh | |
set -e | |
SOURCE=$(hostname) | |
GRAPHITE_PORT=2003 | |
GRAPHITE_SERVER="server" | |
PREFIX="riak_stats" | |
STATUS=$(/usr/sbin/riak-admin status) |
This file contains hidden or 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 number) | |
(def hex-map {:0 0 :1 1 :2 2 :3 3 :4 4 :5 5 :6 6 :7 7 :8 8 :9 9 | |
:A 10 :B 11 :C 12 :D 13 :E 14 :F 15}) | |
(defn hex->num [s] | |
(let [v (vec (reverse (map #(hex-map (keyword (str %))) (subs s 2)))) | |
m (zipmap (range (count v)) v)] | |
(int (reduce + (for [[k v] m] (* (Math/pow 16 k) v)))))) |
This file contains hidden or 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 number | |
(:require [clojure.tools.trace :refer [trace dotrace]])) | |
(def hex-map {:0 0 :1 1 :2 2 :3 3 :4 4 :5 5 :6 6 :7 7 :8 8 :9 9 | |
:A 10 :B 11 :C 12 :D 13 :E 14 :F 15}) | |
(defn hex->num [s] | |
(let [v (vec (reverse (map #(hex-map (keyword (str %))) (subs s 2)))) | |
m (zipmap (range (count v)) v)] | |
(int (reduce + (for [[k v] m] (* (Math/pow 16 k) v)))))) |
This file contains hidden or 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 try.events) | |
(def events (atom {})) | |
(def futures (atom {})) | |
(declare finish) | |
(defn add | |
[name, description, to_go] | |
(swap! events into {name {:description description, :to_go to_go}}) | |
;; new event process |
This file contains hidden or 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
(defmacro my-future1 | |
[& body] | |
`(let [p# (promise)] | |
(.start (Thread. (deliver p# (do ~@body)))) | |
@p#)) | |
(dotimes [i 15] (my-future1 (prn i))) |
This file contains hidden or 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 '(java.util.concurrent Executors)) | |
(def *pool* (Executors/newFixedThreadPool | |
(+ 2 (.availableProcessors (Runtime/getRuntime))))) | |
(defn dothreads [f & {thread-count :threads exec-count :times :or {thread-count 1 exec-count 1}}] | |
(dotimes [t thread-count] | |
(.submit *pool* #(dotimes [_ exec-count] (f))))) | |
(def ticks (atom 0)) |
This file contains hidden or 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
#include <stdio.h> | |
#define IN 1 | |
#define OUT 0 | |
#define MAX_LENGTH 10 | |
main() { | |
int lengths[MAX_LENGTH]; | |
int i, c, state, l; | |
state = l = OUT; |
This file contains hidden or 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
(deftrace bsearch | |
[x, coll, mids] | |
(let [count (count coll) | |
mid (quot count 2) | |
middle (nth coll mid)] | |
(if (and (= 1 count) (not (= x (first coll)))) | |
nil | |
(cond | |
(= middle x) (reduce + (conj mids mid)) | |
(> middle x) (bsearch x (take mid coll) mids) |