This file contains hidden or 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
(defn graphiteisze-path | |
"Graphite uses a dot (.) as a separator. Whisper stores metrics on disk by name, so we cannot have slashes in the metric name" | |
[path] | |
(clojure.string/replace path #"[/\.]" "_")) | |
(defn timed-hook-fn | |
[metric-registry group type name] | |
(let [timer (timer metric-registry [(graphiteisze-path group) (graphiteisze-path type) (graphiteisze-path name)])] | |
(fn [f & args] | |
(time-fn! timer #(apply f args))))) |
This file contains hidden or 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
(defn try-topology [conn fn] | |
(let [ch (lch/open conn)] | |
(try | |
(fn conn ch) | |
true | |
(catch IOException e | |
(when-not (instance? ShutdownSignalException (.getCause e)) | |
(throw (Exception. "Unexpected exception trying RabbitMQ operation" e))) | |
(let [reason (-> e .getCause .getReason)] | |
(when-not (instance? AMQP$Channel$Close reason) |
This file contains hidden or 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
#!/bin/bash -e | |
set +e | |
xchat_pid=$(pidof xchat) | |
set -e | |
if [[ -z $xchat_pid ]]; then | |
xchat & | |
echo "waiting for xchat to calm down" | |
sleep 3 | |
fi | |
xchat -e --command "set net_ping_timeout 60" |
This file contains hidden or 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 default-wait-death (time/seconds 5)) | |
(def default-wait-delay-ms 10) | |
(defn wait-until* | |
"wait until a function has become true" | |
([name fn] (wait-until* name fn default-wait-death)) | |
([name fn wait-death] | |
(let [die (time/plus (time/now) wait-death)] | |
(loop [] | |
(if-let [result (fn)] |
This file contains hidden or 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 gitlab-utils.config) | |
(def api-base "http://localhost/api/v3/") |
This file contains hidden or 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
(defn irc-loop | |
"core.async based main loop" [config] | |
(let [killer (chan)] | |
(go-loop [data config] | |
(when data | |
(println "running") | |
(alt! | |
killer ([reason] (println "killed because:" reason)) | |
(timeout 1000) (do (println "tick!") | |
(recur data))))) |
This file contains hidden or 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 AnyPost | |
{ | |
:id (s/either s/Str s/Int) | |
:slug s/Str | |
:from-feed-id s/Int | |
:url s/Str | |
:url-with-slug s/Str | |
(s/optional-key :tags) [s/Str] | |
}) |
This file contains hidden or 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
#!/usr/bin/env python | |
try: | |
import boto3 | |
except ImportError: | |
print 'Please install boto3 - either set up a virtualenv, or run: pip install boto3' | |
exit(1) | |
import sys |
This file contains hidden or 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
source 'https://rubygems.org' | |
gem 'asciidoctor-pdf', '>= 1.5.0.alpha.11' | |
gem 'asciidoctor' | |
gem 'asciidoctor-diagram', '~> 1.5.1' | |
gem 'rake' | |
gem 'coderay' | |
gem 'pygments.rb' | |
gem 'git' | |
gem 'edn' |
This file contains hidden or 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
// turn a stream into a group | |
Map<String, Long> counting = items.stream().collect( | |
Collectors.groupingBy(Item::getName, Collectors.counting())); |