Skip to content

Instantly share code, notes, and snippets.

View rboyd's full-sized avatar

Robert Boyd rboyd

  • Anarchist
  • Bentonville, AR
View GitHub Profile
(let ((buf (first
(remove* nil (buffer-list)
:test-not #'(lambda (a b)
(string-match "^\*cider-repl" (buffer-name b)))))))
(save-excursion
(set-buffer buf)
(goto-char (point-max))
(insert "(start-figwheel \"ios\")")
(cider-repl-return)))
@rboyd
rboyd / ns_walk.clj
Last active January 30, 2019 00:24
(defn instrument-resolvers!
"Look for any fns matching the pattern resolve-.* in the ns*, instrument them with
iapetos for Prometheus monitoring."
[ns* registry]
(doseq [resolver-str (filter #(re-matches #"resolve-.*" (str %)) (keys (ns-publics (ns-name ns*))))]
(->> resolver-str symbol resolve (iapetos.collector.fn/instrument! registry))))
(instrument-resolvers! *ns* registry)
@rboyd
rboyd / cep-dedup.clj
Created March 26, 2014 16:08
dedup using first unique window with core.async
(ns cep-dedup
(:require [clj-time.coerce :as c]
[clojure.core.async :refer :all]))
; something like esper's std:firstunique. for a given time window ignore any duplicate messages received
; on channels after the first unique. subsequent messages on the first receiving channel pass through.
(defn update-sources [sources msgs min-time]
(clojure.core/reduce (fn [s msg]
(let [remaining (set (filter (fn [m] (not= (:ts m) min-time)) (get s (hash msg))))]
@rboyd
rboyd / fressian-util.clj
Last active August 29, 2015 13:57
lazy-seq over fressian objects
(ns fressian-util
(:require [clojure.java.io :as io]
[clojure.data.fressian :as fress]))
(defn lazy-fressian-objects [file]
(letfn [(helper [rdr]
(lazy-seq
(if-let [is-avail (> (.available rdr) 0)]
(cons (fress/read-object (fress/create-reader rdr)) (helper rdr))
(do (.close rdr) nil))))]
@rboyd
rboyd / gist:5833763
Created June 21, 2013 19:38
'lein immutant overlay torquebox 2.3.2' standalone.xml
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns='urn:jboss:domain:1.4'>
<extensions>
<extension module='org.jboss.as.clustering.infinispan'/>
<extension module='org.jboss.as.cmp'/>
<extension module='org.jboss.as.configadmin'/>
<extension module='org.jboss.as.connector'/>
<extension module='org.jboss.as.deployment-scanner'/>
<extension module='org.jboss.as.ee'/>
<extension module='org.jboss.as.ejb3'/>
@rboyd
rboyd / gist:5833751
Created June 21, 2013 19:37
'lein immutant overlay torquebox 2.3.2' log
15:35:15,063 INFO [org.jboss.modules] (main) JBoss Modules version 1.2.0.CR1
15:35:15,371 INFO [org.jboss.msc] (main) JBoss MSC version 1.0.2.GA
15:35:15,445 INFO [org.jboss.as] (MSC service thread 1-2) JBAS015899: JBoss AS 7.1.x.incremental.129 "Arges" starting
15:35:15,455 DEBUG [org.jboss.as.config] (MSC service thread 1-2) Configured system properties:
[Standalone] =
awt.toolkit = sun.awt.X11.XToolkit
file.encoding = UTF-8
file.encoding.pkg = sun.io
file.separator = /
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
~/.pallet/config.clj:
(defpallet
:admin-user {:username "vagrant"
:private-key-path "/Users/robertb/.vagrant.d/insecure_private_key"}
:services
{
:my-servers {
:provider "node-list"
:node-list [["vagrant" "utility" "localhost" :ubuntu :ssh-port 2222]]
2013-06-18 12:28:34,791 DEBUG [operate-27] p.c.operations lift :phases [:pallet/os :settings] :targets []
2013-06-18 12:28:34,798 DEBUG [operate-28] p.c.primitives build-and-execute-phase :pallet/os on 0 target(s)
2013-06-18 12:28:34,805 DEBUG [operate-28] p.c.primitives build-and-execute-phase :settings on 0 target(s)
2013-06-18 12:28:34,810 DEBUG [operate-27] p.c.operations lift-partitions :phases [:phase13801] :targets []
in ~/.pallet/config.clj:
(defpallet
:services
{
:my-servers {
:provider "node-list"
:node-list [["hostname1.local" "staging" "hostname1.local" :ubuntu]]
}
})
@rboyd
rboyd / random-str.clj
Created February 28, 2013 03:30
random string (clojure)
(defn rand-str [len]
(apply str (take len (repeatedly #(char (+ (rand 26) 65))))))