Skip to content

Instantly share code, notes, and snippets.

View javaLambdaSort.java
// source: http://java.dzone.com/articles/using-lambda-expression-sort
// sort by first name
people.sort((p1, p2) -> p1.firstName.compareTo(p2.firstName));
// sort by full name
String fullName(Person p) { return p.firstName + " " + p.lastName; }
people.sort((p1, p2) -> fullName(p1).compareTo(fullName(p2)));
@shaunlebron
shaunlebron / om-string-cursor.cljs
Created Jun 26, 2014
problem with using strings as cursors in Om
View om-string-cursor.cljs
; Suggested in Om Basic Tutorial for making strings work as cursors
(extend-type string
ICloneable
(-clone [s] (js/String. s)))
(extend-type js/String
ICloneable
(-clone [s] (js/String. s))
om/IValue
(-value [s] (str s)))
View app-state.clj
(def initial-app-state
{:page "search"
:market nil
:market-strategies []
:market-filter (default-filter)
:edit-strategy nil})
@shaunlebron
shaunlebron / CLJS-866.clj
Last active Aug 29, 2015 — forked from ptaoussanis/CLJS-866.clj
Fix for desugar-ns-specs
View CLJS-866.clj
(comment
;; Bug report for CLJS-721 (support :include-macros true modifier in :require),
;; Ref. http://dev.clojure.org/jira/browse/CLJS-721,
;; http://goo.gl/MQ3fWd (GitHub commit de6ee41b3)
;; desugar-ns-specs from clojurescript/src/clj/cljs/analyzer.clj
;; (`cljs.analyzer` ns)
(desugar-ns-specs '[(:require [foo.bar :as bar :include-macros true])])
;; =>
@shaunlebron
shaunlebron / main.js
Created Feb 2, 2015
cuttle patched main.js for issue #74
View main.js
This file has been truncated, but you can view the full file.
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
Math.imul = function (a, b) {
var ah = (a >>> 16) & 0xffff;
var al = a & 0xffff;
var bh = (b >>> 16) & 0xffff;
var bl = b & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
@shaunlebron
shaunlebron / chance.ext.js
Created Feb 5, 2015
google closure externs for Chance.js
View chance.ext.js
// Chance.js 0.7.2
// http://chancejs.com
// (c) 2013 Victor Quinn
// Chance may be freely distributed or modified under the MIT license.
/** @interface */
function Chance(seed) {}
/** @type {!Chance} */
var chance;
View .vimrc
"==================================================================================
" VUNDLE (auto-install plugins):
" > git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
" > vim +BundleInstall
"==================================================================================
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
@shaunlebron
shaunlebron / test.cljs
Created Jun 26, 2015
js data processing in cljs
View test.cljs
(let [old-arr #js []
new-arr #js []]
(doseq [val old-arr]
(when (should-include? val)
(.push new-arr val))))
View 00-readme.md

Google Closure Library API data

The file below is used by the search box on the official Closure API docs, which is generated by js-dossier. If we want more doc data besides name and type, we can modify js-dossier to spit those out as data.

The data is just a single array of objects at TYPES.types.