Skip to content

Instantly share code, notes, and snippets.

View binarytemple's full-sized avatar

Bryan Hunt binarytemple

  • The mountains of mourne
View GitHub Profile
@binarytemple
binarytemple / elixir_process_playing.ex
Created January 29, 2016 15:12
Playing around with elixir processes
defmodule TProcesses do
def listener() do
receive do
{:hello} -> IO.puts "hello";
Other -> IO.puts "other"
after
12_000 -> IO.puts "timeout"
end
listener()
end
@binarytemple
binarytemple / png-to-ico.sh
Created January 25, 2016 15:00 — forked from espeed/png-to-ico.sh
ImageMagick command to convert PNG file to transparent favicon.ico
convert app-icon.png
\( -clone 0 -resize 16x16 \)
\( -clone 0 -resize 32x32 \)
\( -clone 0 -resize 48x48 \)
\( -clone 0 -resize 64x64 \)
-delete 0 -alpha on -background transparent favicon.ico
@binarytemple
binarytemple / dump-x509-multi-cert-file.awk
Last active February 10, 2016 11:47
I'm sure it's been done before, but here's a script which dumps asn information from PEM encoded x509 certificate files
#!/usr/bin/awk -f
# Takes a single argument, the path to a file containing PEM encoded certificate(s)
BEGIN{count=0}
/-----BEGIN CERTIFICATE-----/{
count++
items[count] = $0
}

etcd is configured to only listen on certain interfaces - set the interface IP address.

IF=$(ip addr show eth0 | sed -n '/inet /{s_[^1-9]*__;s_/.*__;p}')

By default etcd is configured to listen on port 2379 for client communication and on port 2380 for server-to-server communication.

#!/bin/bash
########################################################################
# Target : OSX
# Description :
# Port forwarding and networking can sometimes be a tricky to set up
# particularly when using vmware fusion.
# This script takes a port as a single argument then attempts to
# connect on each of the local ipv4 interfaces in turn.
# Use 'nc' to check for open port is as it has less overhead than curl.
#!/bin/bash
#########################################################
# Check first to ensure the docker machines -
# local and swarm-master don't already exist on the sytem
docker-machine ls | sed -ne '/NAME/!{s/[ ].*//;p;}' | egrep "(local|swarm-master)" > /dev/null
if [ $? == 0 ];
@binarytemple
binarytemple / nginx.conf
Created January 5, 2016 14:59 — forked from dctrwatson/nginx.conf
Caching NPM proxy using Nginx
user www-data;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@binarytemple
binarytemple / cnxsoft.md
Created December 24, 2015 14:24 — forked from stefanozanella/cnxsoft.md
Emulate a Raspberry Pi with Qemu+ KVM

Booting with CNXSoft image

Reference: http://www.cnx-software.com/2012/07/31/84-mb-minimal-raspbian-armhf-image-for-raspberry-pi/

wget -r https://dl.dropbox.com/u/45842273/2012-07-15-wheezy-raspian-minimal.img.7z

yum install p7zip
7za e 2012-07-15-wheezy-raspian-minimal.img.7z

qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda 2012-07-15-wheezy-raspian-minimal.img -net nic -net user -vnc :0 -net tap,ifname=vnet0,script=no,downscript=no
@binarytemple
binarytemple / investigation.markdown
Last active December 16, 2015 13:20
docker-machine trying to run ejabberd docker image on osx/vmware fusion

Adopted from code I found on Benjamin Tan's blog

Simplest case

Define module

defmodule Helloer do
  def hola(msg) do
    IO.puts "Hola! #{msg}"