This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(query_start, clock_timestamp()), 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(query_start, clock_timestamp()), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
774713040, | |
154221292, | |
650013, | |
491179627, | |
9891642, | |
149760844, | |
14321259, | |
24870539, | |
164217471, | |
676573, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns mqtt-insertion.core | |
(:require [clojure.core.async :refer :all]) | |
(:import (org.eclipse.paho.client.mqttv3 | |
MqttCallback | |
MqttAsyncClient | |
MqttConnectOptions | |
MqttDeliveryToken | |
MqttException | |
MqttMessage | |
MqttTopic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Collection; | |
import java.util.SortedMap; | |
import java.util.TreeMap; | |
public class ConsistentHash<T> { | |
private final HashFunction hashFunction; | |
private final int numberOfReplicas; | |
private final SortedMap<Integer, T> circle = new TreeMap<Integer, T>(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns device-gateway.tcp | |
(:require [manifold.deferred :as d] | |
[manifold.stream :as s] | |
[clojure.edn :as edn] | |
[aleph.tcp :as tcp] | |
[gloss.core :as gloss] | |
[gloss.io :as gio])) | |
;; ## the basics | |
;; This uses [Gloss](https://github.com/ztellman/gloss), which is a library for defining byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; <<>> DiG 9.8.3-P1 <<>> hellodata.org | |
;; global options: +cmd | |
;; Got answer: | |
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47487 | |
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 0 | |
;; QUESTION SECTION: | |
;hellodata.org. IN A | |
;; ANSWER SECTION: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; it's a bit cumbersome to set up and there's the unfortunate need to ignore the tag | |
; in the individual methods, but this allows you to leave the interpretation of open | |
; variants, well, *open* for extension by multimethod. | |
; dispatch off the first argument, which will be the tag | |
(defmethod command-multi (fn [tag & data] tag)) | |
; the first argument to the *method* is still the tag | |
(defmulti command-multi :print [_ val] (println val)) | |
(defmulti command-multi :read [_ fname] (slurp fname)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmulti transformer-func | |
(fn[structure] | |
(:f structure))) | |
(defmethod transformer-func :url | |
[structure] | |
((:url transformators) (:data structure))) | |
(defmethod transformer-func :data | |
[structure] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def transform-keys (keys transformators)) | |
(defmacro defvariant [name] | |
` (defmulti ~name | |
(fn [structure#] | |
(:f structure#)))) | |
(defmacro defcase [name field ] | |
`(defmethod ~name ~field [structure#] | |
((~field transformators) (:data structure#)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.string :as s]) | |
(require '[cheshire.core :refer [parse-string]) | |
(defn str->long [val] (Long/parseLong val)) | |
(defn parse-date [val] val) | |
(defn extract-date-hour [val] val) | |
(def transformators {:url (comp (partial remove empty?) (fn[x] (when-not (empty? x)(s/split x #"/")))) | |
:data (fn[x] (if-not (nil? x) | |
(-> (parse-string x true) :data))) |