Skip to content

Instantly share code, notes, and snippets.

View jsmorph's full-sized avatar

Jamie Stephens jsmorph

View GitHub Profile
@jsmorph
jsmorph / logicrels-lucene.clj
Created July 6, 2012 14:01
Lucenalog: Datalog interface to Lucene in 10 lines
(ns lucenalog.core
"Lucenalog = Datalog interface to Lucene in 10 lines.
Simple but powerful.
Use
(db/add (index) {:a \"foo\" :b \"bar\"})
to index a map with Lucene. Then you can use the relation
@jsmorph
jsmorph / logicrels-fred.clj
Created July 6, 2012 18:50
St. Louis Fed FRED relation for clojure.core.logic
(ns logicrels.fred
(:require [clojure.xml :as xml]
[clojure.core.logic :as logic]))
;; (config :fred-key (do "See http://api.stlouisfed.org/api_key.html" nil))
;; (clojure.pprint/pprint (sort-by :date (fred-test "DGS10" "2012-07-02")))
;; ({:target "1.61", :date "2012-05-31", :value "1.59"}
;; {:target "1.61", :date "2012-06-01", :value "1.47"}
@jsmorph
jsmorph / HistCombiner.java
Last active December 19, 2015 01:09
Histogram Accumulo Combiner
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@jsmorph
jsmorph / ClojureSeqCombiner.java
Last active December 19, 2015 01:39
A Clojure-driven, seq-based Accumulo Combiner
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@jsmorph
jsmorph / MutationHook.java
Last active December 19, 2015 02:09
Accumulo mutation hook that publishes mutations to Redis
package org.apache.accumulo.examples.simple.constraints;
import java.util.Collections;
import java.util.List;
import org.apache.accumulo.core.constraints.Constraint;
import org.apache.accumulo.core.data.Mutation;
public class MutationHook implements Constraint {
@jsmorph
jsmorph / desc.txt
Last active December 19, 2015 22:28
QCEW Examples
# java -jar qcew.jar desc ENU0603700562441_77Y
{:id "ENU0603700562441_77Y",
:size "0: All establishment sizes",
:owner "5: Private",
:ind "62441: NAICS 62441 Child day care services",
:agg "77: County, NAICS 5-digit -- by ownership sector",
:area "06037: Los Angeles County, California",
:span "Year"}
@jsmorph
jsmorph / kg-ex.txt
Created July 18, 2013 21:31
KyotoGraph Example
java -jar kg.jar --threads 2 --partitioned-grandchildren-test
:kc-open 000-foo.kct
:kc-open 001-foo.kct
:load-synthetic-data #<DB 000-foo.kct: 0: 400128> :start
:load-synthetic-data #<DB 000-foo.kct: 0: 400128> :nodes 0
:load-synthetic-data #<DB 001-foo.kct: 0: 400128> :start
:load-synthetic-data #<DB 001-foo.kct: 0: 400128> :nodes 0
:load-synthetic-data #<DB 001-foo.kct: 44505: 400128> :done
{:triples-added 44505, :nodes 10000, :triples-total 44505, :triples-per-second 35718.29855537721}
:load-synthetic-data #<DB 000-foo.kct: 45235: 400128> :done
@jsmorph
jsmorph / clj1152.clj
Last active December 25, 2015 21:19
Ugly mitigation of CLJ-1152 (PermGen) bugs in the protocols case
;; Ugly mitigation of http://dev.clojure.org/jira/browse/CLJ-1152 in
;; the protocols case. Motivation: Need to eval lots domain-specific
;; language code rendered in core.logic. Approach: Start a thread to
;; purge protocol caches every second. You should probable write a
;; fancier version.
(defn protocol? [x]
(and (instance? clojure.lang.PersistentArrayMap x)
(boolean (:on-interface x))))
@jsmorph
jsmorph / _pixhawkkml.md
Last active July 15, 2020 11:50
Script for generating KML with track timestamps from Pixhawk logs

A Python script for generating KML with timestamps from Pixhawk logs.

See the script for a few comments.

@jsmorph
jsmorph / uncertainty.md
Last active May 13, 2018 18:47
Uncertainty

Notes on representing and computing uncertainty

Approach

A simple approach that uses sampling from either probability distributions or approximations of distributions as input and output from deterministic functions.

Terminology

As examples, we'll consider observations and predictions. A prediction is computed from a set of observations. We'll work with observations and predictions of probability distributions of tuples .