(ns playmatch | |
(:use [clojure.core.match.core :only (match)])) | |
(defn len [coll] | |
"calc the length of a sequence" | |
(match [coll] | |
[[]] 0 | |
[[f & r]] (inc (len r)))) |
(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 |
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
#!/bin/bash | |
set -x | |
# | |
# Grab verified boot utilities from ChromeOS. | |
# | |
mkdir -p /usr/share/vboot | |
mount -o ro /dev/sda3 /mnt | |
cp /mnt/usr/bin/vbutil_* /usr/bin |
(ns extend-core-logic.core | |
(:require [clojure.core.logic :refer :all] | |
[clojure.core.logic.protocols :refer [walk]] | |
[clojure.java.io :as jio] | |
[clojure.string :as string]) | |
(:import [java.io BufferedReader StringReader])) | |
;; from: http://federalgovernmentzipcodes.us/ | |
(defn load-db [] | |
(let [data (java.io.BufferedReader. (java.io.StringReader. (slurp "/Users/tim/Downloads/free-zipcode-database.csv"))) |
;; Trident state persisted in redis. | |
;; Implemented in clojure using marceline lib. | |
;; Based on https://github.com/kstyrc/trident-redis | |
(ns state.redis | |
(:require [marceline.storm.trident :as t] | |
[clj-redis.client :as redis]) | |
(:import [storm.trident.state.map CachedMap TransactionalMap NonTransactionalMap OpaqueMap SnapshottableMap])) | |
(defn- get-type-map |
(ns weighted-rand | |
(:import clojure.lang.PersistentQueue)) | |
(defprotocol Rand | |
(nextr [_ rng])) | |
;; Vose's alias method | |
;; http://www.keithschwarz.com/darts-dice-coins/ | |
(deftype Vose [n ^ints alias ^doubles prob] |
In this tutorial, we'll take an in-depth view of what's happening when you execute a simple Onyx program. All of the code can be found in the Onyx Starter repository if you'd like to follow along. The code uses the development environment with HornetQ and ZooKeeper running in memory, so you don't need additional dependencies to run the example for yourself on your machine.
At the core of the program is the workflow - the flow of data that we ingest, apply transformations to, and send to an output for storage. In this program, we're going to ingest some sentences from an input source, split the sentence into individual words, play with capitalization, and add a suffix. Finally, we'll send the transformed data to an output source.
Let's examine the workflow pictorially:
;; extend honeysql | |
(defmethod honeyhelpers/build-clause :returning [ _ m cols] | |
(assoc m :returning (honeyhelpers/collify cols))) | |
(defmethod honeyfmt/format-clause :returning [[_ cols] _] | |
(str "RETURNING " (honeyfmt/comma-join (map honeyfmt/to-sql cols)))) | |
(extend-protocol honeyfmt/ToSql | |
clojure.lang.Sequential |