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 / transducer_performance.txt
Created November 9, 2014 15:28
Preliminary transducer benchmarks in Python2 and PyPy
Benchmarks at: https://github.com/cognitect-labs/transducers-python/blob/master/tests/benchmark.py
transducers-python git/master
❯ python tests/benchmark.py
Avg. time for transducers.transducers with T.replace({0:1, 100:200, 1000:500}) is: 68.4194946289
Avg. time for tests.genducers with G.replace({0:1, 100:200, 1000:500}) is: 37.8649584961
Avg. time for transducers.transducers with T.take(10000) is: 8.898671875
Avg. time for tests.genducers with G.take(10000) is: 3.86192871094
Avg. time for transducers.transducers with T.dedupe is: 0.779968261719
Avg. time for tests.genducers with G.dedupe is: 0.304665527344
@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;
@benkamphaus
benkamphaus / creaturecomforts.sh
Last active October 9, 2021 05:42
try to get comfortable in a vanilla amazon linux instance
sudo yum install zsh tmux htop git -y
sudo yum install util-linux-user -y
sudo chsh -s /bin/zsh ec2-user
wget --no-check-certificate http://install.ohmyz.sh -O - | sh
mkdir ~/src
mkdir ~/datomic
# from https://gist.github.com/sebsto/19b99f1fa1f32cae5d00
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
(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.