Skip to content

Instantly share code, notes, and snippets.

View lmars's full-sized avatar

Lewis Marshall lmars

View GitHub Profile
@lmars
lmars / deployer.rb
Last active August 29, 2015 13:55
Docker Deployer
class Deployer
attr_accessor :current_id
attr_reader :image
def initalize(image)
@image = image
end
def start
self.current_id = run "docker run #{image}"
@lmars
lmars / Dockerfile
Created February 20, 2014 16:12
dicoverd Dockerfile
FROM ubuntu:precise
# Set DEBIAN_FRONTEND to non-interactive to avoid useless warnings
ENV DEBIAN_FRONTEND noninteractive
# Update apt sources
RUN apt-get update
# Support adding PPAs
RUN apt-get install -y python-software-properties
@lmars
lmars / config-exec.rb
Created March 2, 2014 20:27
config-exec
#!/usr/local/bin/ruby
#
# config-exec will render any files in /config and then exec
# whatever command was given on the command line.
#
# For example, if /config/etc/redis.conf.erb exists, then to
# render it into /etc/redis.conf and run Redis with the result:
#
# $ config-exec redis-server /etc/redis.conf
@lmars
lmars / ssl.rb
Created April 23, 2014 16:08
Strowger SSL
require "socket"
require "openssl"
puts OpenSSL::OPENSSL_VERSION
socket = TCPSocket.new("127.0.0.1", 8081)
ssl_version = ARGV[0].to_sym
ssl_context = OpenSSL::SSL::SSLContext.new
@lmars
lmars / keybase.md
Created April 30, 2014 01:20
keybase.md

Keybase proof

I hereby claim:

  • I am lmars on github.
  • I am lmars (https://keybase.io/lmars) on keybase.
  • I have a public key whose fingerprint is 6BFE 8AC3 30EA B9F9 317D 5837 9E4F E42F D94C 0795

To claim this, I am signing this object:

@lmars
lmars / scheduler.log
Created June 2, 2014 15:27
Flynn Scheduler Restarts
# flynn scale web=2
now=2014-06-02T15:14:46+0000 app=controller-scheduler fn=watchFormations app.id=6f98d85441b94de0bf003a40882db52a release.id=7afc7da66395445fa7a8372cdb915001 at=new
now=2014-06-02T15:14:46+0000 fn=rectify app.id=6f98d85441b94de0bf003a40882db52a release.id=7afc7da66395445fa7a8372cdb915001 type=web expected=2 actual=0 app=controller-scheduler at=update diff=2
now=2014-06-02T15:14:46+0000 app=controller-scheduler fn=add app.id=6f98d85441b94de0bf003a40882db52a release.id=7afc7da66395445fa7a8372cdb915001 host.id=00687624bf25 job.id=032bb075d20a44eb8108117be085b5cb
now=2014-06-02T15:14:46+0000 app=controller-scheduler fn=add app.id=6f98d85441b94de0bf003a40882db52a release.id=7afc7da66395445fa7a8372cdb915001 host.id=00687624bf25 job.id=75197216462545ed9d5cb0d84081fe12
# docker kill flynn-032bb075d20a44eb8108117be085b5cb
# job restarted immediately
now=2014-06-02T15:15:32+0000 app=controller-scheduler fn=watchHost host.id=00687624bf25 at=remove job.id=032bb075d20a44eb8108117be085b5cb event=stop
no
@lmars
lmars / ip-tables-debug.txt
Created May 14, 2015 19:29
IP Tables Debug
# log ICMP packets
sudo iptables -t raw -A OUTPUT -p icmp -j TRACE
sudo iptables -t raw -A PREROUTING -p icmp -j TRACE
sudo modprobe ipt_LOG
# in the container
ping -c 1 8.8.8.8
@lmars
lmars / README.md
Created December 11, 2011 23:01
Game Of Life Rules

Game Of Life Rules

You have a grid of cells in 2 dimensions. Each cell has 2 possible states, alive or dead. Each cell has 8 neighbours: above, below, left, right, and the 4 diagonals.

  • any life cell < 2 neighbours dies
  • any life cell > 3 neighbours dies
  • any live cell with 2 or 3 neighbours lives to next generation
  • any dead cell with exactly 3 live neighbours becomes a live cell
@lmars
lmars / gist:1939629
Created February 29, 2012 10:16
Numeral to digit
NUMERALS = {
'i' => 1,
'v' => 5,
'x' => 10,
'l' => 50,
'c' => 100,
'd' => 500,
'm' => 1000
}
@lmars
lmars / gist:1939737
Created February 29, 2012 10:27
Iterating over a string
string = 'ABCDE'
string.reverse.each_char do |numeral|
# inside this block numeral will be a character from the string
puts numeral
end
# This will output:
E
D