Skip to content

Instantly share code, notes, and snippets.

View chillenious's full-sized avatar

Eelco Hillenius chillenious

View GitHub Profile
@chillenious
chillenious / gist:8624061
Created January 25, 2014 21:40
example of builder that allows for fluent-like API (e.g. call like: Checks.argument(node).withName("node").and(type).withName("type").shouldNotBeNull(); )
package com.teachscape.provisioning.util;
import com.teachscape.commons.util.Strings;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/**
@chillenious
chillenious / gist:7681521
Created November 27, 2013 19:20
Duration print in Clojure
(defn as-seconds [milliseconds] (/ milliseconds 1000))
(defn as-minutes [milliseconds] (/ (as-seconds milliseconds) 60))
(defn as-hours [milliseconds] (/ (as-minutes milliseconds) 60))
(defn as-days [milliseconds] (/ (as-hours milliseconds) 24))
(defn to-unit-str
[value unit]
$scope.initAddPersonModal = function () {
$scope.dialog = {
title: 'Select Users for Group',
url: '/partials/groups/select_person_form.html',
callback: $scope.savePeopleTo
};
$scope.showModal();
$("#personForm").livequery(function(){
@chillenious
chillenious / gist:5362157
Created April 11, 2013 09:58
fun with Clojure's futures
(defn sync-all
"Synchronize all UMS objects, starting with a check - and possibly filling - of
relevant dimension tables, then parallel execution of the involved synchronizations
and when these finish, a rebuild of the materialized views.
Returns a map of {:stat stat-for-sync}"
[]
(log/debug "starting sync run for UMS")
(dsdb/init-date-and-time-dimensions!)
;; run separate sync async
(let [sync-fns (seq [(future (sync-organizations))
@chillenious
chillenious / CommaSeperatedValuesProcessor.java
Created July 29, 2012 05:21
Simple CSV processor converts rows to JSON and then uses Jackson to populate objects
package com.teachscape.provisioning.util;
import com.teachscape.commons.util.Duration;
import com.teachscape.commons.util.Strings;
import org.codehaus.jackson.map.ObjectMapper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;