Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rxacevedo
rxacevedo / consul-up.sh
Last active October 1, 2015 22:17
Bring Consul up, start Registrator on swarm nodes, stand up some services and verify that Consul returns SRV records for them via dig.
#!/usr/bin/env bash
# This script assumes that you already have the following VMs or hosts in place/accessible via docker-machine:
# consul
# nginx (in my case, dev)
# swarm-master
# swarm-node-00
# swarm-node-01
CONSUL_HOST_NAME='consul'
@rxacevedo
rxacevedo / run-swarm-manager.sh
Last active September 23, 2015 00:44
Run a Docker Swarm manager container inside of a Boot2Docker host to use Consul as a discovery back-end.
#!/usr/bin/env bash
# The host machine needs access to the proper certs in order for the container to be able to talk to swarm nodes using TLS client auth.
# These don't exist in the container by, and need to be volume mounted in from the Boot2docker host. Port 3376 also needs to be exposed
# on the host since the individual agent processes on the other nodes will be conencting directly to the hsot on which the manager is
# running.
#
# ¯\_(ツ)_/¯
set -e
@rxacevedo
rxacevedo / aprompt.png
Last active August 29, 2015 18:38 — forked from mislav/aprompt.png
My zsh prompt. No oh-my-zsh needed
aprompt.png
(let [data (for [i (range 10)]
[i i])
h (fn [theta-0 theta-1]
(fn [x] (+ theta-0 (* theta-1 x))))
j (fn [theta-0 theta-1]
(* (/ 1 (* 2 (count data)))
(apply + (map (fn [[x y]]
(pow (- ((h theta-0 theta-1) x) y) 2))
data))))
@rxacevedo
rxacevedo / keybase.md
Created March 7, 2015 18:20
Reauthorizing with 4096 bit expiring key

Keybase proof

I hereby claim:

  • I am rxacevedo on github.
  • I am rxacevedo (https://keybase.io/rxacevedo) on keybase.
  • I have a public key whose fingerprint is 1553 A223 5BED 37A0 1539 CD4F 1794 5A14 8A10 5A97

To claim this, I am signing this object:

@rxacevedo
rxacevedo / bootstrap.sh
Last active August 29, 2015 14:16
Quick bootstrap script for fresh Yosemite install - yeah blah blah dotfiles blah blah ansible I WILL DO IT LATER.
#!/usr/bin/env bash
#
# Bootstrap my Mac
set -e
echo ''
echo 'Boostrapping...'
echo ''
;; test suite to go with hashing code
(ns user.test.sha256
(:use [clojure.test]
[clojure.string :only [join]]
[user.hash]))
(def sha256-test-vectors
#^{:doc "test vectors from the NESSIE project (http://is.gd/jdM99e)"}
[{ :message ""
:expected "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
@rxacevedo
rxacevedo / no-consecutive-ones-dfa.clj
Last active August 29, 2015 14:08
The deterministic finite automaton that accepts only strings with no consecutive ones (from the alphabet {{} 0 1}). For each set of possible permutations for a given length, the number of strings that the automaton increases per the Fibonacci sequence.
(require '[clojure [repl :refer :all]]
'[clojure.core [reducers :as rd]])
;; => K done
(defn no-consecutive-ones-fsa [strings]
"An FSA that only accepts strings with no consecutive ones."
(letfn [(no-ones-seen [[x & xs :as xss]]
(fn []
(if (seq xss)
(case x
@rxacevedo
rxacevedo / monoid.clj
Created July 23, 2014 17:40
Monoids, reducers, map, etc.
(require '[clojure.core.reducers :as rd])
;; => nil
(letfn [(monoid-mapping [f]
(rd/monoid
(fn [l r] (conj l (f r))) vector))
(monoid-reducer-map [f coll]
(reduce (monoid-mapping f)
((monoid-mapping f))
coll))]