Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# execute like: ruby clone_loop.rb | tee clone_loop.log
require 'fileutils'
REPO = 'git@github.com:gorsuch/nothing'
DEST_DIR = 'nothing'
loop do
module SelfRestraint
class UnableToLock < StandardError; end
def lock(redis, base_key, n)
if key = lock_obtain
begin
yield
ensure
redis.del key
end
run Proc.new {|env| [[200, 500].shuffle.first, {"Content-Type" => "text/html"}, ['boom!']]}
@gorsuch
gorsuch / gist:6324795
Last active December 21, 2015 15:09
12.04 puppet build
wget http://apt.puppetlabs.com/puppetlabs-release-wheezy.deb && dpkg -i puppetlabs-release-wheezy.deb && apt-get update && apt-get upgrade -y
apt-get install puppet-common=3.2.4-1puppetlabs1 puppet=3.2.4-1puppetlabs1 -y
[main]
@gorsuch
gorsuch / gist:6298941
Created August 21, 2013 19:18
Sidekick as a service

...

@gorsuch
gorsuch / gist:6149031
Last active December 20, 2015 14:48
saving my work ; starting to get rbenv up and running on a docker image
FROM base
RUN apt-get update
RUN apt-get -y install build-essential git libssl-dev curl
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh
RUN echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh
RUN echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh
@gorsuch
gorsuch / gist:6057681
Created July 22, 2013 21:06
Apps as Data
{:command "java -jar myapp-0.1.3.jar"
 :slug "http://my-store/myapp-0.1.3.jar"
 :env {:aws-secret-key "mysecretkey"}}
irb(main):008:0> PTY.spawn ('ls') { |r, w, pid| puts r.read }
Errno::EIO: Input/output error - /dev/pts/6
  from (irb):8:in `read'
	from (irb):8:in `block in irb_binding'
	from (irb):8:in `spawn'
	from (irb):8
	from /usr/local/bin/irb:12:in `<main>'
@gorsuch
gorsuch / gist:4726919
Last active December 12, 2015 06:08
some clojure queue business
(def q (atom '()))
(defn qpush! [queue value]
(swap! queue conj value))
(defn qpop! [queue]
(let [q @queue
v (first q)
nq (pop q)]
(if (compare-and-set! queue q nq) v (recur queue))))
@gorsuch
gorsuch / gist:4617330
Created January 24, 2013 03:09
queue notes for clojure

Taken from here, recording so I don't lose it:

(defn new-q [] (java.util.concurrent.LinkedBlockingDeque.))

(defn offer! 
  "adds x to the back of queue q"
  [q x] (.offer q x) q)

(defn take!