This file contains 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 hiredman.schedule | |
(:import (java.util.concurrent ScheduledThreadPoolExecutor TimeUnit))) | |
(def unit {:minutes TimeUnit/MINUTES :seconds TimeUnit/SECONDS :hours TimeUnit/HOURS}) | |
(def tasks (ref {})) | |
(def #^{:doc "ScheduledThreadPoolExecutor for scheduling repeated/delayed tasks"} | |
task-runner (ScheduledThreadPoolExecutor. (+ 1 (.availableProcessors (Runtime/getRuntime))))) |
This file contains 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
(defn multi-split-with | |
"Returns a lazy collection of lists which elements ..." | |
[pred coll] | |
(let [[head tail] (split-with pred coll) | |
tail-without-seps (drop-while (complement pred) tail)] | |
(lazy-seq | |
(if (seq tail-without-seps) | |
(cons head (multi-split-with pred tail-without-seps)) | |
(list head))))) |
This file contains 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
// usage: | |
// var double = function(a){Functional.map(a, function{return 2*a})}; | |
// double([1,2,3]) -> [2,4,6] | |
// var even = function(a){Functional.map(a, function{return a%2 == 0})}; | |
// even([1,2,3,4,5,6,7]) -> [2,4,6] | |
var Functional = { |
This file contains 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
var Functional = { | |
isFunction: function(obj) { | |
return toString.call(obj) === "[object Function]"; | |
}, | |
reduce: function(accumulator, object, callback) { | |
var name, i = 0, | |
length = object.length, | |
isObj = length === undefined || Functional.isFunction(object); |
This file contains 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
[ | |
{"name":"flare.analytics.cluster.AgglomerativeCluster","size":3938,"imports":["flare.animate.Transitioner","flare.vis.data.DataList","flare.util.math.IMatrix","flare.analytics.cluster.MergeEdge","flare.analytics.cluster.HierarchicalCluster","flare.vis.data.Data"]}, | |
{"name":"flare.analytics.cluster.CommunityStructure","size":3812,"imports":["flare.analytics.cluster.HierarchicalCluster","flare.animate.Transitioner","flare.vis.data.DataList","flare.analytics.cluster.MergeEdge","flare.util.math.IMatrix"]}, | |
{"name":"flare.analytics.cluster.HierarchicalCluster","size":6714,"imports":["flare.vis.data.EdgeSprite","flare.vis.data.NodeSprite","flare.vis.data.DataList","flare.vis.data.Tree","flare.util.Arrays","flare.analytics.cluster.MergeEdge","flare.util.Sort","flare.vis.operator.Operator","flare.util.Property","flare.vis.data.Data"]}, | |
{"name":"flare.analytics.cluster.MergeEdge","size":743,"imports":[]}, | |
{"name":"flare.analytics.graph.BetweennessCentrality","size":3534,"imports":["flare.animate.Transitioner","flare |
This file contains 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
$(function() { | |
//run the accordion plugin, set height of sections to height of content | |
$("#accordion").accordion({ autoHeight: false }); | |
}); | |
;(function($) { | |
//write new sammy application | |
var app = new Sammy.Application(function() { | |
with(this) { | |
//corresponds to routes such as #/section/1 | |
get('#/section/:section_id', function() { with(this) { |
This file contains 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
function(newDoc, oldDoc, userCtx) { | |
if (newDoc._deleted === true) { | |
// allow deletes by 'cluster admins', 'system admins' and matching users | |
// without checking the other fields | |
if ((userCtx.roles.indexOf('_admin') !== -1) || (userCtx.roles.indexOf('system_admin') !== -1) || (userCtx.name == oldDoc.name)) { | |
return; | |
} else { | |
throw({forbidden: 'Only admins may delete other user docs. **************'}); | |
} |
This file contains 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
function _factorial(acc, n, callback){ | |
if(n==0){ | |
callback(acc); | |
}else{ | |
var callback_wrapper = function(result){ | |
callback(result); | |
}; | |
setTimeout(function(){_factorial(acc * n, n-1, callback_wrapper)}, 10); | |
} | |
} |
This file contains 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
<!DOCTYPE html> | |
<!-- Helpful things to keep in your <head/> | |
// Brian Blakely, 360i | |
// http://twitter.com/brianblakely/ | |
--> | |
<head> | |
<!-- According to Heather Champ, former community manager at flickr, | |
you should not allow search engines to index your "Contact Us" |
This file contains 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 &&> | |
"Clojure quivalent of ruby's andand. Threads the expr through the forms, short circuiting in case of falsey result. | |
Inserts x as the second item in the first form, making a list of it if it is not a | |
list already. If there are more forms, inserts the first form as the | |
second item in second form, etc. | |
example: | |
(let [o {:a 123}] | |
(assert (= 124 (&&> o :a (+ 1)))) | |
(assert (= nil (&&> o :a (+ 1) :c :b))) | |
(assert (= false (&&> false :a (+ 1) :c :b))) |
OlderNewer