Skip to content

Instantly share code, notes, and snippets.

View andrewvc's full-sized avatar

Andrew Cholakian andrewvc

View GitHub Profile
git branch | grep -v '*' | egrep -o '[^ ]+' | xargs -n1 git show -s | less
@andrewvc
andrewvc / index.html
Created August 15, 2012 19:29
A web page created at CodePen.io.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- IF PEN IS PRIVATE -->
<!-- <meta name="robots" content="noindex"> -->
<!-- END -->
@andrewvc
andrewvc / index.html
Created August 15, 2012 19:29
A web page created at CodePen.io.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- IF PEN IS PRIVATE -->
<!-- <meta name="robots" content="noindex"> -->
<!-- END -->
@andrewvc
andrewvc / markov.clj
Created August 5, 2012 21:02
Test for markov generation in engulf
(ns engulf.formulas.markov-requests
"Support for generating markov chains of requests"
(:use clojure.pprint
[clojure.walk :only [keywordize-keys]])
(:require [clojure.string :as string]
[clojure.tools.logging :as log]
[cheshire.core :as json])
(:import java.util.TreeMap))
(defn compile-transitions
@andrewvc
andrewvc / count-clj-sloc.sh
Created July 23, 2012 04:19
Counting SLOC in clojure is pretty easy since the syntax is so simple.
# Count SLOC
export SLF=`mktemp -t cljsloc`; find src test -name "*.clj" | xargs egrep -v "(^[[:space:]]*$|^[[:space:]]*;)" | cut -d: -f1 > $SLF && echo "Files"; uniq -c $SLF; echo "Total" `cat $SLF | wc -l`; rm $SLF
x = _.reduce("a=b,c=d".split(/,/), function (m,kv) { s = kv.split(/=/); m[s[0]] = s[1]; return(m) }, {})
Pose.Models.LabelTag = Backbone.Model.extend
Pose.Models.Color = Backbone.Model.extend
Pose.Models.Label = Backbone.Model.extend
defaults:
color: Pose.Models.Color
label_tags: Pose.Collections.LabelTags
Pose.Collections.Colors = Backbone.Collection.extend
model: Pose.Models.Color
Pose.Collections.LabelTags = Backbone.Collection.extend
@andrewvc
andrewvc / end-stack
Created February 24, 2012 07:53
Thread-704
java.util.concurrent.ThreadPoolExecutor.setCorePoolSize(int)
lamina.executors.core$thread_pool$reify__1673.execute(Runnable)
lamina.core.pipeline$start_pipeline$fn__1045$fn__1049.invoke(Object)
lamina.core.queue$r_obs$fn__883.invoke(Object)
lamina.core.observable$observer$reify__329.on_message(Object)
lamina.core.observable.ConstantObservable$fn__548.invoke()
lamina.core.observable.ConstantObservable.message(Object)
lamina.core.channel$enqueue.doInvoke(Object, Object)
clojure.lang.RestFn.invoke(Object, Object)
lamina.core.channel$poll$callback__966$fn__967$fn__968.invoke(Object)
(defn increment-keys
"Given a map and a list of keys, this will return an identical map with those keys
with those keys incremented.
Keys with a null value will be set to 1."
[src-map & xs]
(into src-map (map #(vector %1 (inc (get src-map %1 0))) xs)))
; Example (increment-keys {:a 2} :a :b) => {:a 3 :b 1}
@andrewvc
andrewvc / complex-view.clj
Created December 2, 2011 06:21
Noir Examples
; Define the route, and specify that we want the 'garden-file' param
(defpage [:post "/upload"] {:keys [garden-file]}
; do some work
(let [{:keys [decoded-file uuid]} (decode-upload garden-file)]
(try
(garden/create uuid decoded-file)
(finally
(.delete decoded-file)))
; render some HTML based on that work
(common/layout [:p (format "File %s was created" uuid)]))