Skip to content

Instantly share code, notes, and snippets.

View camsaul's full-sized avatar
💭
I am Cam

Cam Saul camsaul

💭
I am Cam
View GitHub Profile
@camsaul
camsaul / git-remove-binary.sh
Last active November 27, 2017 20:42
Git remove binary files
git filter-branch --force --prune-empty --index-filter "git rm -rf --cached --ignore-unmatch *.elc" HEAD && git push --force
@camsaul
camsaul / filter_docker_logs.sh
Created February 25, 2015 00:57
Filtered Docker Logs
docker attach expa_data | perl -ne 'if (!m/^\s*$/ && !m/stdout/) { s/^\[[^\]]+\]\s*(.*$)/$1/m; print; }'
@camsaul
camsaul / gpg2_commands.sh
Last active February 27, 2019 06:13
gpg2 commands
# export a public key
gpg2 --export --armor $KEY(S)
# import a public key
gpg2 --import $INPUT_FILE
# encrypt file
gpg2 --encrypt --armor --local-user $SENDER --recipient $RECIPIENT --output $OUTPUT_FILE $INPUT_FILE
# create detached signature for file
Capture Video with Quicktime Player

File -> New Screen Recording

Convert to GIF

You may need to install ffmpeg/gifsicle via homebrew first.

ffmpeg -i in.mov -f gif - | gifsicle > out.gif
@camsaul
camsaul / git_ssh.sh
Created April 24, 2015 18:17
Setting Up Git SSH Access
pbcopy < ~/.ssh/id_rsa.pub
git remote set-url origin [email protected]:cammsaul/lein-instant-cheatsheet.git
@camsaul
camsaul / .git_submodules.sh
Created August 18, 2015 21:04
Setup Git Submodules To Auto-Pull
git submodule update --init
git config --add fetch.recurseSubmodules true
git config alias.pull '!f(){ git pull "$@" && git submodule update --init --recursive; }; f'
@camsaul
camsaul / https.sh
Last active August 30, 2015 02:43
Self-Signed HTTPS
#!/bin/bash
# PEM files are Base-64 format starting with -----BEGIN. Extensions: .pem, .crt, .cer, .key
# DER files are binary versions. Extensions: .der, .cer
# Keystores:
# PKSC7/P7B - Base64. Extensions: .p7b, .p7c
# PKCS12/PFX - Binary. Extensions: .pfx, .p12
# Generate a new private key
openssl genrsa -out private.pem 2048
@camsaul
camsaul / all_of_the_imessages.sh
Created September 23, 2015 21:49
Send an annoying amount of iMessages
#! /bin/bash
NUM_SECONDS_DELAY=1
while "TRUE"; do
osascript -e 'tell application "Messages" to send "YO!" to buddy "+14151234567" of service "E:[email protected]"'
sleep $NUM_SECONDS_DELAY
done
@camsaul
camsaul / generate_sudoku.clj
Created November 13, 2015 23:59
Core.logic Sudoku Generator
(defn- solve-board [hints & {:keys [max-solutions], :or {max-solutions 1}}]
(let [vars (vec (repeatedly 81 lvar))
rows (mapv vec (partition 9 vars))
cols (apply map vector rows)
squares (for [corner-x (range 0 9 3)
corner-y (range 0 9 3)]
(for [x (range corner-x (+ corner-x 3))
y (range corner-y (+ corner-y 3))]
(get-in rows [x y])))]
(run max-solutions [q]
@camsaul
camsaul / project-authors.pl
Created December 15, 2015 18:00
Perl script to deduce the primary authors of a git project
#! /usr/bin/perl # -*- coding: utf-8 -*-
use strict;
use warnings;
use List::Util qw(reduce);
my %author_aliases = ('Cameron T Saul' => 'Cam',
'Cam Saul' => 'Cam Saül',
'Cam Saül' => 'Cam Saül'); # different umlauts, apparently