Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nathanleclaire's full-sized avatar
👨‍🍳
Cooking up great code

Nathan LeClaire nathanleclaire

👨‍🍳
Cooking up great code
View GitHub Profile
class LinkedList:
next = None
val = None
def __init__(self, val):
self.val = val
def add(self, val):
if self.next == None:
self.next = LinkedList(val)
@nathanleclaire
nathanleclaire / floodfill.go
Created March 6, 2014 01:36
Beginnings of a concurrent flood fill implementation in Go.
package main;
import (
"fmt"
"runtime"
"sync"
)
type Canvas struct {
height int
@nathanleclaire
nathanleclaire / docker-local.service
Last active August 29, 2015 13:58
Systemd script to initialize docker daemon in CoreOS Vagrant box for talking to from OSX.
[Unit]
Description=docker local
[Service]
PermissionsStartOnly=true
ExecStartPre=/usr/bin/systemctl kill docker.service
ExecStart=/usr/bin/docker -H 0.0.0.0:4243 -H unix:///var/run/docker.sock -d
[Install]
WantedBy=local.target

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

~$ docker run --rm -v /usr/local/bin/docker:/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba volume_container
Unable to find image 'svendowideit/samba' locally
Pulling repository svendowideit/samba
f458f834a657: Download complete
511136ea3c5a: Download complete
574c4c3fda05: Download complete
d8309758b8fe: Download complete
7622a3fd4d7e: Download complete
948960c0d5bf: Download complete
28614c3b76a1: Download complete
Client version: 1.0.0
Client API version: 1.12
Go version (client): go1.2.1
Git commit (client): 63fe64c
Server version: 1.0.0
Server API version: 1.12
Go version (server): go1.2.1
Git commit (server): 63fe64c
$ time vagrant
Usage: vagrant [options] <command> [<args>]
-v, --version Print the version and exit.
-h, --help Print this help.
Common commands:
box manages boxes: installation, removal, etc.
connect connect to a remotely shared Vagrant environment
destroy stops and deletes all traces of the vagrant machine
$ make binary
docker build -t "docker:master" .
Sending build context to Docker daemon 44.7 MB
Sending build context to Docker daemon
Step 0 : docker-version 0.6.1
# Skipping unknown instruction DOCKER-VERSION
Step 1 : FROM ubuntu:14.04
---> e54ca5efa2e9
Step 2 : MAINTAINER Tianon Gravi <admwiggin@gmail.com> (@tianon)
---> Using cache
@nathanleclaire
nathanleclaire / gist:0ea0672dee3b2458c2ad
Last active August 29, 2015 14:04
print all numbers < 1 million that have digits which sum to 42
print len([n for n in range(0, 1000000) if sum(int(i) for i in str(n)) == 42])
@nathanleclaire
nathanleclaire / couchbasecluster.sh
Last active August 29, 2015 14:04
Kick up a couchbase cluster, print IP addresses for containers
docker run -d -p 11210:11210 -p 11211:11211 -p 8091:8091 -p 8092:8092 --name cb1 dustin/couchbase
for name in cb{2..5}; do
docker run -d --name $name dustin/couchbase
done
for name in cb{1..5}; do
docker inspect -f '{{ .NetworkSettings.IPAddress }}' $name
done