Skip to content

Instantly share code, notes, and snippets.

Avatar

Stefan Crain stefancrain

View GitHub Profile
@stefancrain
stefancrain / setup.sh
Created Mar 18, 2020
Setup NVIDIA drivers and nvidia-container-runtime for docker on debian / ubuntu 18.04
View setup.sh
#!/bin/bash
# https://github.com/NVIDIA/nvidia-docker#ubuntu-16041804-debian-jessiestretchbuster
curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | \
sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo chmod 644 /etc/apt/sources.list.d/nvidia-container-runtime.list
@stefancrain
stefancrain / alpine.py
Last active Jan 1, 2020
Automatically upgrade pinned packages in a Dockerfile
View alpine.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# A python script to update alpine requirements in docker
#
import glob
import os
import re
import sys
from urllib.request import Request, urlopen
@stefancrain
stefancrain / disable-jenkins-auth.sh
Last active Jul 31, 2018
Disabling Jenkins auth when auth method fails
View disable-jenkins-auth.sh
#!/bin/bash
# Backup Jenkins Config
cp $JENKINS_HOME/config.xml $JENKINS_HOME/config-bk.xml
# Set useSecurity to false to enable login when auth temporarily
# This opens Jenkins to all with access to the URL
grep "useSecurity" $JENKINS_HOME/config.xml
sed -i "s#<useSecurity>true#<useSecurity>false#g" $JENKINS_HOME/config.xml
grep "useSecurity" $JENKINS_HOME/config.xml
@stefancrain
stefancrain / sublime setup.sh
Created Feb 8, 2018
Setup Sublime from a shell prompt
View sublime setup.sh
# Link sublime to its bin
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin
# install package control
subl --command install_package_control
@stefancrain
stefancrain / jenkins_export.sh
Last active Apr 6, 2017
Backup up all Jenkins jobs as XML
View jenkins_export.sh
#!/bin/bash
HOST="JENKINS_URL"
PORT="8443"
URL="http://USERNAME:APIKEY@$HOST:$PORT"
folder=$(date +%Y%m%d-%H%M%S)
mkdir -p "$HOST/$folder"
while read job
do
echo "Job: '$job'";
java -jar ~/Downloads/jenkins-cli.jar -s "$URL" get-job "$job" > "$HOST/$folder/$job".xml
@stefancrain
stefancrain / hook-dns-01-lets-encrypt-route53.py
Created Aug 4, 2016
Python 3 script to use as a hook for the letsencrypt.sh client
View hook-dns-01-lets-encrypt-route53.py
#!/usr/bin/env python3
# How to use:
#
# LE_HOSTED_ZONE=XXXXXX LE_AWS_PROFILE=dns-access ./letsencrypt.sh --cron --domain example.org --challenge dns-01 --hook /tmp/hook-dns-01-lets-encrypt-route53.py
#
# More info about letsencrypt.sh: https://github.com/lukas2511/letsencrypt.sh/wiki/Examples-for-DNS-01-hooks
# Using AWS Profiles: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles
# Obtaining your Hosted Zone ID from Route 53: http://docs.aws.amazon.com/cli/latest/reference/route53/list-hosted-zones-by-name.html
@stefancrain
stefancrain / rsync-lowcpu.sh
Created Jul 14, 2016
skip some file types that don't compress very well
View rsync-lowcpu.sh
export RSYNC_SKIP_COMPRESS=3g2/3gp/3gpp/7z/aac/ace/amr/apk/appx/appxbundle/arc/arj/asf/avi/bz2/cab/crypt5/crypt7/crypt8/deb/dmg/drc/ear/gz/flac/flv/gpg/iso/jar/jp2/jpg/jpeg/lz/lzma/lzo/m4a/m4p/m4v/mkv/msi/mov/mp3/mp4/mpeg/mpg/mpv/oga/ogg/ogv/opus/png/qt/rar/rpm/rzip/s7z/sfx/svgz/tbz/tgz/tlz/txz/vob/wim/wma/wmv/xz/z/zip/cr2/nef/iiq/3fr/dcr/k25/kdc/erf/mef/mos/orf/pef/rw2/arw/srf/sr2
rsync -avzchP --compress-level=9 --skip-compress=$RSYNC_SKIP_COMPRESS /from/disk /to/disk
@stefancrain
stefancrain / keybase.md
Last active Nov 11, 2016
Proof of my identity on Keybase
View keybase.md

Keybase proof

I hereby claim:

  • I am stefancrain on github.
  • I am stefancrain (https://keybase.io/stefancrain) on keybase.
  • I have a public key ASC9kOw1_uHclJ4BABEu_sRxnfxx6OdUb4_5Wj4GfUD2Gwo

To claim this, I am signing this object:

@stefancrain
stefancrain / slowconvert.sh
Created Feb 14, 2015
Find all image files and convert them to a jpgs with ImageMagick's convert
View slowconvert.sh
#!/bin/bash
# 2015 Stefan Crain - stefancrain@gmail.com
# Find all image files and convert them to a jpgs with ImageMagick's convert
#
# Usage
# ./slowconvert.sh toscan/ output/
parsedCLI=("$@")
scandir=${parsedCLI[0]%/}
outputdir=${parsedCLI[1]:-$scandir}
@stefancrain
stefancrain / convert.sh
Created Feb 14, 2015
Fastest image converter on osx
View convert.sh
#!/bin/bash
# 2015 Stefan Crain - stefancrain@gmail.com
# Find all image files and convert them to a jpgs with sips
# OSX only
#
# Usage
# ./convert.sh toScan/ Output/
parsedCLI=("$@")
scandir=${parsedCLI[0]%/}
You can’t perform that action at this time.