Skip to content

Instantly share code, notes, and snippets.

View benkamphaus's full-sized avatar
🌊
Focusing

Ben Kamphaus benkamphaus

🌊
Focusing
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.31090480089187622</real>
<key>Green Component</key>
<real>0.31097450852394104</real>
@benkamphaus
benkamphaus / fizzbuzz.clj
Created August 5, 2014 16:47
FizzBuzz for laughs in Clojure
(defn fbuzz [x]
(let [divides (fn [x y]
(= (rem x y) 0))]
(cond (divides x (* 5 3)) "FizzBuzz"
(divides x 5) "Buzz"
(divides x 3) "Fizz"
:else x)))
(doseq [x (map fbuzz (range 1 101))] (print (str x ", ")))
@benkamphaus
benkamphaus / fizzbuzz.py
Last active August 29, 2015 14:04
FizzBuzz for laughs in Python
def fbuzz(x):
str_rep = ""
if (x % 3) == 0:
str_rep += "Fizz"
if (x % 5) == 0:
str_rep += "Buzz"
if not str_rep:
str_rep += str(x)
return str_rep
@benkamphaus
benkamphaus / TransactorRestart.java
Created December 3, 2014 15:16
Expected behavior for Datomic on peers during a transactor restart, in Java.
/**
* Expected behavior during transactor shutdown and restart.
* */
import datomic.Connection;
import datomic.Peer;
import datomic.Database;
import datomic.Util;
import java.util.Scanner;
import java.util.List;
(require '[datomic.api :as d] 'clojure.pprint)
;; You can run this with bin/run in the $DATOMIC_DIR
(println "Printing database schema...")
(def conn (d/connect (first *command-line-args*))) ;; call with db-uri as arg
; Find and pretty-print each attribute in schema
(let [db (d/db conn)]
(clojure.pprint/pprint
(map #(->> % first (d/entity db) d/touch)
@benkamphaus
benkamphaus / or_join.clj
Last active August 29, 2015 14:23
A couple of or-join examples against a toy schema.
(ns datomic-manual-tests.or-join
(:require [datomic.api :as d]))
(def db-uri (apply str ["datomic:mem://test" (d/squuid)]))
(d/create-database db-uri)
(def conn (d/connect db-uri))
(def schema
[{:db/id (d/tempid :db.part/db)
:db/ident :person/name
@benkamphaus
benkamphaus / binterp.ipynb
Created July 24, 2015 21:47
SciPy Interpolate Example Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@benkamphaus
benkamphaus / new_horizons.ipynb
Created July 25, 2015 04:10
Playing with Basic Image Processing using Raw Data of Pluto from New Horizons LORRI instrument
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
function metric-grep () {
cat *.log | perl -n -e 'print "$1 $2\n" if /^(.*) INFO .* '"$1"' {.*?'"$2"' ([0-9]+).*?}/' | less
}
# call like:
# metric-grep :TransactionBytes :sum
# output like
# 2015-04-01 00:00:29.995 34818
@benkamphaus
benkamphaus / with-bonanza.clj
Created August 6, 2015 21:05
Datomic: chaining with to explore a prospective sequence of transactions, fairly dorky schema example
(ns datomic-manual-tests.with-bonanza
(:require [datomic.api :as d]))
(def db-uri "datomic:mem://people")
(d/create-database db-uri)
(def conn (d/connect db-uri))
(def schema
[{:db/id (d/tempid :db.part/db)
:db/ident :person/age