Skip to content

Instantly share code, notes, and snippets.


Harvey Chapman sr105

View GitHub Profile
sr105 /
Created Feb 5, 2019
Same named network for multiple docker compose files

Same Network for Multiple docker-compose files

The A file creates the network. The B file connects to it.


docker-compose -f docker-compose-A.yaml up -d
docker-compose -f docker-compose-B.yaml up -d

Testing what names Docker puts into DNS:

sr105 / atoi_strrev.c
Last active Oct 11, 2018
C atoi and strrev (for fun)
View atoi_strrev.c
/* Test:
* gcc -o atoi atoi.c
* ./atoi 12345 123465
* Output:
* Number: 12345 Reverse: 54321 54321 54321
* Number: 123456 Reverse: 654321 654321 654321
#include <stdio.h>
#include <stdlib.h>
sr105 /
Last active Sep 28, 2018
TOTP Authenticator Python Implementation
#!/usr/bin/env python3
import time
import urllib.parse
import base64
import hmac
import types
sr105 / woodLength.js
Last active Aug 30, 2018
woodLength Javascript Kata
View woodLength.js
// Written for node v8.1.3
// nvm install v8.1.3
// nvm use v8.1.3
// node woodLength.js
function woodLength(dimensions) {
sr105 / gdb_commands
Created Sep 27, 2017
gdb sysroot not working
View gdb_commands
# set sysroot /opt/poky/2.3.1/sysroots/corei7-64-poky-linux
directory /opt/poky/2.3.1/sysroots/corei7-64-poky-linux
set breakpoint pending on
file /work/build-mxencoder-Poky-Debug/mxencoder-test/mxencoder-test
target remote | ssh -T root@ gdbserver - /opt/mxencoder-test/bin/mxencoder-test
b mxencoder-test.cpp:67
View gstencodingprofile.c
static GstEncodingProfile* create_encoding_profile()
// At some point, we might want to allow multiple formats etc.
// FIXME: hook up Configure() parameters here
GstEncodingContainerProfile *container;
GstEncodingVideoProfile *video;
GstCaps *caps, *restr;
caps = gst_caps_new_simple("video/quicktime", "variant", G_TYPE_STRING, "iso", NULL);
container = gst_encoding_container_profile_new(NULL, NULL, caps, NULL);
View gist:66c8dc0a55f8970ff1efd342f3a6ce98
gst-launch-1.0 -e v4l2src ! video/x-raw,width=3840,height=2160,format=YV12 \
! vaapih264enc bitrate=20000 rate-control=2 ! queue \
! mpegtsmux ! filesink location=file.mp4
gst-launch-1.0 -e v4l2src ! video/x-raw,width=1280,height=720 ! queue ! xvimagesink
sr105 /
Last active May 25, 2017
Luhn algorithm
def luhn(cc, debug=False):
double = True
sum = 0
doubled = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
if debug:
print('{:15}{:15}{:15}{}'.format('digit', 'sum digit', 'sum', 'double'))
for n in (int(c) for c in reversed(cc.replace(' ', ''))):
value = doubled[n] if double else n
if debug:
print('{:<15}{:<15}{:<15}{}'.format(n, value, sum, double))
sr105 /
Last active Jun 16, 2017
Instructions and script for telling a local emacs to open a remote file via ssh while at the remote prompt using iTerm2 triggers
# Don't forget to read the SECURITY WARNING below, and then don't
# say you didn't know.
## Description
# tl;dr -- Type `e filename` on a remote host via ssh and your local
# emacs will open the remote file. Don't have the `e` function
sr105 /
Created Feb 12, 2017
Re-implement `column -t filename` using python and centering the columns.
#!/usr/bin/env python3
import sys
import itertools
def three_passes_and_storage():
# Read file and split each line into fields (by whitespace)
with open(sys.argv[1]) as f:
lines = [line.split() for line in f.readlines()]
# Check that each line has the same number of fields