Skip to content

Instantly share code, notes, and snippets.

View dschep's full-sized avatar

Daniel Schep dschep

View GitHub Profile

Keybase proof

I hereby claim:

  • I am dschep on github.
  • I am dschep (https://keybase.io/dschep) on keybase.
  • I have a public key ASAOASCVweS-lajGgb690KEptFPhZSdZuPmTrBs5BkcTQgo

To claim this, I am signing this object:

@dschep
dschep / swc
Created March 24, 2016 01:29
Streaming version of wc -l
#!/bin/bash
exec awk '{printf "\r%lu", NR}'
@dschep
dschep / gnu-mac.sh
Created February 24, 2016 03:43
Stupid Macs
#!/bin/bash
#
# Are you tired of making sure your scripts work on a Mac? Source this (or
# copy it!) in your script and use $sed and always be sure it's GNU sed. If
# the GNU tools required aren't installed, it suggest the user install them via
# brew and exits
#
# Default tools: sed & grep
# Override via GNU_TOOLS env variable, ex:
# GNU_TOOLS=sed . gnu-mac.sh
@dschep
dschep / bootlocal.sh
Last active March 4, 2016 21:41
Workaround bug in Linux boot2docker hosts not mounting home dirs (boot2docker/boot2docker#1085)
#!/bin/sh
# Work around for boot2docker/boot2docker#1085
# Extracted from boot2docker/boot2docker#1086
mkdir -p /hosthome
mount | grep -q /hosthome || mount -t vboxsf hosthome /hosthome \
-o defaults,uid=$(id -u docker),gid=$(id -g docker)
ls -1 /hosthome | while read d
do
@dschep
dschep / .scrn_dev
Last active February 12, 2016 23:59
A shortcut for loading different GNU screen profiles.
source ~/.screenrc
screen vim
split -v
focus right
screen
split
focus down
#!/usr/bin/env python
from unittest import TestCase
def truthyish(value):
"""
same as standard python truthyness except that strings are different.
True, t, yes, y and 1 (case insensitive) are considered truthy.
"""
@dschep
dschep / pypi_git_semantic_version.py
Last active November 29, 2016 21:52
Generate PEP 440 conformant version numbers from sematic version git tags (vX.Y.Z)
from subprocess import check_output
version_parts = (check_output(['git', 'describe', '--dirty=+dirty'])
.decode()
.rstrip('\n')
.lstrip('v')
.split('-'))
if len(version_parts) == 1:
version, = version_parts
else:
@dschep
dschep / gh-ntfy
Last active April 18, 2016 15:59
Desktop notifications from Github using ntfy
#!/usr/bin/env python3
import json
import time
import requests
from ntfy.backends.default import notify
USER = 'YOUR USERNAME'
@dschep
dschep / docker-compose-subcommand-wrapper.sh
Created December 3, 2015 03:07
Allow for calling `docker-compose` via `docker compose`
function docker() {
if [ "$1" == 'compose' ] ; then
docker-compose "${@:2}"
else
env docker "${@:1}"
fi
}
@dschep
dschep / fix-apple-kbd.sh
Created November 25, 2015 15:23
Swap Alt & Meta and default to Fkeys not media keys
#!/bin/bash
echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode
echo 1 | sudo tee /sys/module/hid_apple/parameters/swap_opt_cmd