Skip to content

Instantly share code, notes, and snippets.

@xeago
xeago / gist:4625779
Created January 24, 2013 17:57
Elasticsearch directory layout
.
|-- bin
| `-- *
|-- config
| `-- *
|-- homebrew.mxcl.elasticsearch.plist
|-- lib
| `-- *
|-- libexec
| `-- *
{
"query": {
"filtered": {
"query": { "match_all" },
"filter": {
"and": [
{ "type": { "value": "vets" } },
{ "geo_polygon": {
"geoLocation": {
"points": [
We will first describe the infrastructure in use at VideofyMe and introduce new
components. After this we will discuss the changes to the infrastructure and
provide test results of this new infrastructure. We will also discuss how the
software is built up of easy to extend components.
@xeago
xeago / gist:4657407
Last active December 11, 2015 20:48
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"mappings" : {
"test" : {
"properties" : {
"field" : {
"index" : "not_analyzed",
"type" : "string"
}
}
@xeago
xeago / phi.rb
Created July 20, 2013 19:05
Usage: 10.phi #=> 4
class Integer
def phi
fractions = self.prime_division
primes = fractions.map { |b,e| b }
rationals = primes.map {|p| Rational(p-1,p) }
return (rationals.reduce { |a,b| a*b } * self).to_i
end
end
@xeago
xeago / retire.rb
Last active December 28, 2015 19:49 — forked from anonymous/retire.rb
terms = []
terms += { term: { category_id: params[:category_id] } } if params[:category_id].present?
# etc
filter :and, terms if not terms.empty?
(defn moving-trigger-fraction-trigger
[time-window trigger-predicate cancel-predicate & children]
(let [state-ok (atom true)
s (fn [event]
(reset! state-ok (= "ok" (:state event)))
(call-rescue event children))]
(moving-time-window time-window
(fn [events]
(prn events)
((split
(where* trigger-predicate
(with :state "critical" s)
(else (where* (fn [events] (and (not @state-ok) #(cancel-predicate events)))
(with :state "critical" s)
(else (with :state "ok" s)))))))
@xeago
xeago / diff.clj
Last active August 29, 2015 13:57
diff --git a/src/spotify/rules/cia.clj b/src/spotify/rules/cia.clj
index 896c1b2..529a5c1 100644
--- a/src/spotify/rules/cia.clj
+++ b/src/spotify/rules/cia.clj
@@ -76,20 +76,14 @@
((split
(trigger-predicate events)
(smap peek #(prn "crit: " %) (with :state "critical" s))
(and (not @state-ok) (cancel-predicate events))
(smap peek #(prn "trig: " %) (with :state "critical" s))
(defn ratio-calc
[events]
(let [ratio
(/ (count (filter #(= "critical" (:state %)) events))
(count events))]
(assoc (last events) :metric ratio)))