Skip to content

Instantly share code, notes, and snippets.

View jhickner's full-sized avatar

Jason Hickner jhickner

  • Formation / VaryWell / Kite & Lightning
  • Seattle
View GitHub Profile
a = "22981635076420793197140440112363866165375145564586248763610635385945236317287043748330467627305717813726673479967228777612424589645162359871449118678990935704112591252723259506903857180164066459487282479000924936106359390615851255792782486783825611539272620689971356880964798332754380590030005771560309857523027375721429953891023929412773760555899367294679320436122766251589468422685308936932490108777565566638092564304030758367043977881571032676830821465574149105922106946888975837458532791503723665502656062459429016196415243948409471237970932916479524375074817705815197829260250003099752408091767320864127218772831828682399073865634365526847136046528335512087563161794873994019518959778146554153057008556254461291089006873847990013879516711046214367997203624910548139468568451262332355247109828375685915330115937613723644470698146282936341274372822625012192958803636595625994654162379966473175618778595285739852711797764004657981630164464755041460221238191191589365695497017625302761466469146309379417234199638118286
@jhickner
jhickner / image.clj
Created July 20, 2011 21:08
tablecup image slicing
(import (java.io File FileInputStream)
'javax.imageio.ImageIO)
(use '[clojure.contrib.string :only (split)])
(def x-values [117 279 440 599 763 923 1083 1245])
(def base-path "/Users/jhickner/Desktop/")
(defn file-basename [file] (first (split #"\." (.getName file))))
(defn files-in-dir [dir]
(ns test)
(defn ^:export encoding-example []
(str "Hello " (name :foo)))
; goog.provide('test');
; goog.require('cljs.core');
; test.encoding_example = (function encoding_example(){
; return cljs.core.str.call(null,"Hello ",cljs.core.name.call(null,"﷐'foo"));
; });
; goog.exportSymbol('test.encoding_example', test.encoding_example);
@jhickner
jhickner / clj-to-js.cljs
Created September 7, 2011 03:35
recursive cljs to js
(defn ->js [o]
(cond
(map? o) (let [out (js-obj)]
(doseq [[k v] o]
(aset out (if (keyword? k) (name k) k)
(->js v)))
out)
(or (sequential? o) (set? o)) (.array (vec (map ->js o)))
:else o))
@jhickner
jhickner / gist:1199718
Created September 7, 2011 03:49 — forked from lynaghk/gist:1141054
Clojure sequentials & maps into JavaScript arrays and objects
(defn ->js [o]
(cond
(keyword? o) (name o)
(map? o) (let [out (js-obj)]
(doseq [[k v] o]
(aset out (->js k) (->js v)))
out)
(coll? o) (apply array (map ->js o))
:else o))
@jhickner
jhickner / gist:1215454
Created September 13, 2011 23:18 — forked from swannodette/gist:1210048
example.cljs
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns repl.test
(:require [clojure.browser.repl :as repl]
@jhickner
jhickner / gist:1218258
Created September 15, 2011 00:55 — forked from swannodette/gist:1214547
closure_and_proto.clj
/*
Silly example - close over s (say a string) returning an instance
of an anonymous type that acts like a ClojureScript collection
(defn make-conjable [s]
(reify
ICollection
(-conj [_ c] (str s c))))
*/
@jhickner
jhickner / locals.clj
Created March 17, 2012 22:48 — forked from alandipert/locals.clj
locals map
(defmacro locals
"Returns a map of locals, as keywords, to their values."
[]
(let [locals (keys &env)]
`(zipmap ~@(map vec [(map keyword locals) locals]))))
(let [x 10]
(let [y 20
z (+ x y)]
(locals)))
(ns fj
(:import [java.util.concurrent RecursiveTask
ForkJoinPool]))
(set! *warn-on-reflection* true)
;; -----------------------------------------------
;; Helpers to provide an idiomatic interface to FJ
(defprotocol IFJTask
(defrecord web-socket
Object
(send [msg] ...)
(close [_] ...))