Skip to content

Instantly share code, notes, and snippets.

View iantruslove's full-sized avatar

Ian Truslove iantruslove

View GitHub Profile
@iantruslove
iantruslove / StopAnalyzer.java
Created May 11, 2015 22:29
English stop words in Lucene (lucene-5.1.0/analysis/common/src/java/org/apache/lucene/analysis/core/StopAnalyzer.java)
static {
final List<String> stopWords = Arrays.asList(
"a", "an", "and", "are", "as", "at", "be", "but", "by",
"for", "if", "in", "into", "is", "it",
"no", "not", "of", "on", "or", "such",
"that", "the", "their", "then", "there", "these",
"they", "this", "to", "was", "will", "with"
);
final CharArraySet stopSet = new CharArraySet(stopWords, false);
ENGLISH_STOP_WORDS_SET = CharArraySet.unmodifiableSet(stopSet);
@iantruslove
iantruslove / gorilla-repl-helpers.el
Last active August 29, 2015 14:19
Emacs function to remove results from a Gorilla REPL clojure notebook file
(defun gorilla-empty-all-results* ()
(while (re-search-forward
";; @@\n\\(;; ->\n\\)?\\(;;;.*\n\\)*\\(;; <-\n\\)?;; =>\n\\(;;;.*\n\\)+;; <="
nil t)
(replace-match ";; @@")))
(defun gorilla-empty-all-results ()
"Empty all Gorilla REPL result blocks"
(interactive)
(save-excursion
(ns introspect.core
(:require [clojure.core.match :as match]
[clojure.java.io :as io]
[clojure-mail.core :as mail]
[clojure-mail.message :as message]
[opennlp.nlp :as onlp]
[opennlp.treebank :as treebank]
[opennlp.tools.filters :as filters]
[corenlp :as nlp])
(:import (org.apache.tika Tika)
(ns node-cljs-pos.core
(:require [cljs.nodejs :as node]))
(node/enable-util-print!)
(def pos (node/require "pos"))
(defn pos-lexer [s]
(let [Lexer (.-Lexer pos)
lexer (Lexer.)]
@iantruslove
iantruslove / general-case-middleware.clj
Last active August 29, 2015 14:05
Ring: from the ground up
(defn wrap-generic-middleware-example [handler & [other-args]]
(fn [request]
;; Early side-effects:
(log/info "Wrapping incoming request...")
(let [;; Modify request here:
req (assoc request :new-req-key "some value for handlers")
;; Run the handlers:
resp (handler req)]
;; Late side-effects:
(log/info "My middleware is almost done.")
{:uri "/foo"
:http-method :post
:headers {"content-type": "application/json"
"accept": "*/*"}
:body <InputStream ...>}

Dumping Datomic data into a local (free) transactor

Create a database dump from the server running the transactor

bin/datomic backup-db "datomic:ddb://us-east-1/rest/of/url?aws_access_key_id=<ACCESS_KEY_ID>&aws_secret_key=<SECRET_KEY>" file:/home/ian/datomic-backup-`date +"%Y%d%m"`

Transfer the dump to your local machine

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.