Skip to content

Instantly share code, notes, and snippets.

View otfrom's full-sized avatar
I may be slow to respond.

Bruce Durling otfrom

I may be slow to respond.
View GitHub Profile
@otfrom
otfrom / date_parsing.clj
Created September 6, 2014 11:49
nil punning date parsing
;; as opposed to https://github.com/clj-time/clj-time/blob/master/src/clj_time/format.clj#L149-L158
(defn parse-exception-flow-control
"Returns a DateTime instance in the UTC time zone obtained by parsing the
given string according to the given formatter."
([^String s]
(first
(for [f (vals formatters)
:let [d (try (parse f s) (catch Exception _ nil))]
:when d] d))))
----------- DATASETS -------------
-- Divide--
curl -v -H 'Content-Type: application/json' -u <username>:<password> -X POST --data "{\"entity_id\":\"9ac7f5635832d843dda594f58525239263ffdd37\",\"operation\":\"divide\", \"name\": \"systemEfficiencyOverall\", \"members\": [\"interpolatedHeatConsumption-b4f0c7e2b15ba9636f3fb08379cc4b3798a226bb\", \"interpolatedElectricityConsumption-268e93a5249c24482ac1519b77f6a45f36a6231d\"]}" http://www.getembed.com/4/entities/9ac7f5635832d843dda594f58525239263ffdd37/datasets/
-- Subtract --
curl -v -H 'Content-Type: application/json' -u <username>:<password> -X POST --data "{\"entity_id\":\"9ac7f5635832d843dda594f58525239263ffdd37\",\"operation\":\"subtract\", \"name\": \"cop-subtraction\", \"members\": [\"interpolatedElectricityConsumption-268e93a5249c24482ac1519b77f6a45f36a6231d\", \"interpolatedElectricityConsumption-3aae0fe7ddaa5e400a2cf9580a5e548d9255c70a\", \"interpolatedElectricityConsumption-122b4bf8dfa66cbf8f321f2d03c4d73f924bb719\"]}" http://www.getembed.com/4/enti
@otfrom
otfrom / README.md
Last active August 29, 2015 14:06 — forked from mbostock/.block

This examples demonstrates how to use D3's brush component to implement focus + context zooming. Click and drag in the small chart below to pan or zoom.

@otfrom
otfrom / demo.clj
Created January 31, 2012 23:22
Team 1 Battleship Code
(ns battleships.demo)
;; This is an example of how to create a player to submit to the server.
;; The entire namespace is submitted to the server.
;; You submit the file using the submit function in the client namespace.
(defn- random-coord
"Generates a random valid coordinate."
[]
(let [rows ["A" "B" "C" "D" "E" "F" "G" "H" "I" "J"]
@otfrom
otfrom / gist:3980588
Created October 30, 2012 14:40
lein deps :tree for a pallet project
[ch.qos.logback/logback-classic "1.0.0" :exclusions [[org.cloudhoist/pallet] [org.jclouds/jclouds-allblobstore] [org.jclouds/jclouds-allcompute] [org.jclouds/jclouds-compute] [org.jclouds/jclouds-blobstore] [org.jclouds.driver/jclouds-slf4j] [org.jclouds.driver/jclouds-jsch] [org.jclouds.labs/greenqloud-compute]]]
[ch.qos.logback/logback-core "1.0.0" :exclusions [[org.cloudhoist/pallet] [org.jclouds/jclouds-allblobstore] [org.jclouds/jclouds-allcompute] [org.jclouds/jclouds-compute] [org.jclouds/jclouds-blobstore] [org.jclouds.driver/jclouds-slf4j] [org.jclouds.driver/jclouds-jsch] [org.jclouds.labs/greenqloud-compute]]]
[org.clojure/clojure "1.4.0" :exclusions [[org.cloudhoist/pallet] [org.jclouds/jclouds-allblobstore] [org.jclouds/jclouds-allcompute] [org.jclouds/jclouds-compute] [org.jclouds/jclouds-blobstore] [org.jclouds.driver/jclouds-slf4j] [org.jclouds.driver/jclouds-jsch] [org.jclouds.labs/greenqloud-compute]]]
[org.clojure/data.xml "0.0.6" :exclusions [[org.cloudhoist/pallet] [org.jclouds/jclouds
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"property" "annual_emissions" "normalised_cost" "monthly_cost" "Gas" "Electrical"
"foo" 9.48120598985868 3.32516229028219 23.4645618950913 0 9.48120598985868
"bar" 13.9329659660887 4.7563711817271 32.8744521510371 1.06302263189102 12.8699433341977
"baz" 14.8021361709446 5.19127050544977 30.8015383323353 0 14.8021361709446
@otfrom
otfrom / init.el
Last active December 26, 2015 02:49
A minimally broken ~/.emacs.d/init.el for cider.
(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
;; This means we prefer things from ~/.emacs.d/elpa over the standard packages.
(package-initialize)
;; This bootstraps us if we don't have anything
(when (not package-archive-contents)
(maybe-install-and-require 'gist)

Keybase proof

I hereby claim:

  • I am otfrom on github.
  • I am otfrom (https://keybase.io/otfrom) on keybase.
  • I have a public key whose fingerprint is 530E 1B82 4511 B1F9 B7A5 D21E 4458 A97B 2FE3 EE19

To claim this, I am signing this object:

@otfrom
otfrom / copper.clj
Created February 19, 2018 17:09
How I learned core.async
(ns otfrom.copper
(:require [clojure.core.async :as a]))
(def tenner (a/chan))
(def mten (a/mult tenner))
(def t1 (a/tap mten (a/chan)))
(def t2 (a/tap mten (a/chan)))