Skip to content

Instantly share code, notes, and snippets.

@bakkdoor
bakkdoor / thrift-mode.el
Created January 8, 2011 02:56
Simple thrift mode (taken from https://github.com/kragen/stevej-emacs/blob/master/thrift-mode/thrift.el) and adjusted to highlight self-defined types, unions & namespaces nicely.
(require 'font-lock)
(defvar thrift-mode-hook nil)
(add-to-list 'auto-mode-alist '("\\.thrift\\'" . thrift-mode))
(defvar thrift-indent-level 2
"Defines 2 spaces for thrift indentation.")
;; syntax coloring
@weavejester
weavejester / gist:1001206
Created May 31, 2011 20:27
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]
@nathanmarz
nathanmarz / gist:2506020
Created April 27, 2012 05:03
Concise inline operations with Cascalog serfn branch
(use 'cascalog.playground) (bootstrap)
(require '[clojure.set :as set])
(require '[cascalog.vars :as v])
(defn all-syms [form]
(if (coll? form)
(reduce (fn [curr elem] (set/union curr (all-syms elem)))
#{}
form)
(def
^{:doc "Predicate macro aggregator that extracts a timeseries, given
`?chunk`, `?temporal-resolution` and `?date`. Currently only
functions when `?chunk` is an instance of `forma.schema.IntArray`."}
extract-tseries
(<- [?temporal-res ?date ?chunk :> ?pix-idx ?t-start ?t-end ?tseries]
(datetime->period ?temporal-res ?date :> ?tperiod)
(:sort ?tperiod)
(timeseries ?tperiod ?chunk :> ?pix-idx ?t-start ?t-end ?tseries)))
(ns type-level-tagger
{:doc "Implements State-of-the-art Unsupervised Part-of-speech Tagger
from \"Simple Type-Level Unsuperivsed POS Tagging\"
by Yoong-Keok Lee, Aria Haghighi and Regina Barzilay
(http://www.cs.berkeley.edu/~aria42/pubs/typetagging.pdf)
blog post: http://wp.me/pcW6S-x"
:author "Aria Haghighi (aria42@gmail.com)"}
(:use [clojure.java.io :only [reader]]
[clojure.contrib.duck-streams :only [with-out-writer]]
[clojure.contrib.seq-utils :only [indexed]]
handle_call({lookup_popular_replies, TweetId, AuthorId}, _From, #state{client=Client} = State) ->
% reduce fun to get valid tweet keys in tweet response bucket phase 3
Fun = make_local_fun("fun(O, _) ->
lists:foldl(fun
([LinkedTweet = <<Id:128>>, <<Val:128>>, <<\"reply\">>], Acc) ->
[{{<<\"tweet_responses_bucket\">>, LinkedTweet}, {Id, Val}} | Acc];
({{<<\"tweet_responses_bucket\">>, _}, _} = PreviousPass, Acc) ->
[PreviousPass | Acc];
(_, Acc) ->
Acc