Skip to content

Instantly share code, notes, and snippets.

View clcollins's full-sized avatar

Christopher Collins clcollins

View GitHub Profile
@clcollins
clcollins / http-master_npm-apache-crypt
Created November 6, 2014 15:56
NPM apache-crypt build fail
> apache-crypt@1.0.4 install /usr/local/lib/node_modules/http-master/node_modules/http-auth/node_modules/htpasswd/node_modules/apache-crypt
> node-gyp rebuild
child_process: customFds option is deprecated, use stdio instead.
make: Entering directory `/usr/local/lib/node_modules/http-master/node_modules/http-auth/node_modules/htpasswd/node_modules/apache-crypt/build'
CXX(target) Release/obj.target/crypt3/deps/crypt3.o
../deps/crypt3.cc: In function 'const char* GetApacheSalt()':
../deps/crypt3.cc:18:20: error: 'time' was not declared in this scope
srand(time(NULL));
^
@clcollins
clcollins / python_subprocess_hang
Last active August 29, 2015 14:10
Python Subprocess Hang
testCmd = "/sbin/iptables -n -L %s"
# <snip>
def checkChain():
cmd = testCmd % chain
check = subprocess.Popen(cmd,
shell=True,
@clcollins
clcollins / automount-enable.sh
Created April 18, 2016 18:53
Systemd NFS Automount
#!/bin/sh
systemctl enable <path-to-mountpoint>.automount
systemctl start <path-to-mountpoint>.automount
#!/bin/bash
# Script that can be run to cleanup a Jenkins slave server that's used to build docker images
# Tries to account for the fact that a job might be running and using images & containers
# Adjust the Docker command to match your environment (esp. the $HOST hostname)
# TLS included as script it designed to be run from the master
DOCKER_TLS_VERIFY=1
DOCKER="docker --tlscacert /ca.pem --tlscert /cert.pem --tlskey /key.pem -H ${HOST}"
RUNNING_CONTAINERS=$($DOCKER ps -q)
@clcollins
clcollins / format-disks.yml
Last active September 16, 2016 16:30
Snippet of Ansible Playbook for auto-expanding a volume group based on disks on the server
---
## Snippet of Ansible Playbook for auto-expanding a volume group based on disks on the server
### Format Partitions ###
- name: Format | find disks
command: find /dev -regex "/dev/sd[b-z]" -exec echo "{}," \;
register: extra_pvs
- name: Format | expand vg if extra_pvs exist
# defaultpv comes last, because extra_pvs are formatted to have a comma on the end
@clcollins
clcollins / keybase.md
Last active December 9, 2016 19:01
Keybase.io verification

Keybase proof

I hereby claim:

  • I am clcollins on github.
  • I am clcollins (https://keybase.io/clcollins) on keybase.
  • I have a public key whose fingerprint is 923E 0218 77DB 3F70 F614 6F62 F575 2BA1 4623 4FD4

To claim this, I am signing this object:

@clcollins
clcollins / dkr.sh
Created February 23, 2017 15:25
Wrapper to handle Docker TLS connection flags
#!/bin/bash
usage () {
cat << EOF
Usage: dkr HOSTNAME
dkr HOSTNAME COMMAND [arg...]
A wrapper around Docker to simplify using TLS connections
In the first form, will watch the output of "docker ps" and "docker images" on the remote host.

Docker Build Pipeline with Remote Asset Compilation

Problem

To compile code into assets/artifacts and build a Docker image with the resulting code only, and no compilers/devel packages/libraries, you have a workflow like so:

@clcollins
clcollins / git-prompt
Created April 18, 2017 16:35
Git Prompt for bash
# Found on Reddit - cannot now remember where
# Modified by Chris Collins to suite his tastes
git rev-parse 2> /dev/null && git status --porcelain -b | awk '
/^## / {
branch = $0;
sub(/^## /, "", branch);
sub(/\.\.\..*/, "", branch);
if ($0 ~ /ahead /) {
@clcollins
clcollins / enable_namespaces_el7.sh
Last active April 25, 2017 20:41
Enable User Namespaces for Docker on EL7-based Systems
#!/bin/bash
# Super basic script outlining the steps to enable namespace support for Docker on
# el7-base systems (CentOS7, RHEL7, etc).
set -e
echo "Enabling user_namespace kernel option..."
grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"