Skip to content

Instantly share code, notes, and snippets.

@plasticine
plasticine / help.makefile
Last active August 28, 2019 11:30
Automatically extract help from your Makefiles using some fully sick awk hacks
# You're looking at it! :)
help:
@makehelp < $(MAKEFILE_LIST)
.PHONY: help
@michaelsauter
michaelsauter / gist:297c0a67ba277b9c508f933ef9f70cdf
Last active February 16, 2021 15:21
Find and remove old Git branches
# Update local repo
git fetch origin --prune
# Merged branches at least 2 months old
for branch in `git branch -r --merged | grep -v HEAD`; do echo -e `git show --format="%ci %cr %an" $branch | head -n 1` \\t$branch; done | grep "months" | awk '{print $(NF)}' | sed -e "s/^origin\///" | xargs git push origin --delete --dry-run
# All branches at least a year old
for branch in `git branch -r | grep -v HEAD`; do echo -e `git show --format="%ci %cr %an" $branch | head -n 1` \\t$branch; done | grep "1 year" | awk '{print $(NF)}' | sed -e "s/^origin\///" | xargs git push origin --delete --dry-run
@michaelsauter
michaelsauter / gnupg.md
Created November 10, 2014 04:20
gnupg

Encrypt file:

gpg --encrypt --armor --recipient email@example.com file

Decrypt file:

gpg --decrypt file
@joost
joost / README.md
Last active January 8, 2024 20:03
How to fix invalid byte sequence in UTF-8 rack in Rails

Add the utf8_sanitizer.rb to your Rails 3.2 project in app/middleware. Instead of removing the invalid request characters and continuing the request (as some gems do) it returns a 400 error.

Add the following line to your config/application.rb:

config.middleware.use 'Utf8Sanitizer'

If you only need it in production add to config/environments/production.rb. This can be without quotes:

config.middleware.use Utf8Sanitizer
#!/bin/bash
set -eu
shopt -s nullglob
readonly base_dir=/var/local/docker-registry
readonly output_dir=$(mktemp -d -t trace-images-XXXX)
readonly jq=/tmp/jq
readonly repository_dir=$base_dir/repositories
@wikimatze
wikimatze / gist:9790374
Created March 26, 2014 18:43
Github Two-Factor Authentication Failed For HTTPS

I heard from GitHub Two-Factor Authentication](https://github.com/blog/1614-two-factor-authentication) nearly a couple of days ago when I was reading my RSS feed. I enabled it and couldn' push to any of my repositories anymore. Learn in this blog post how to fix it.

Two-Factor Authentication

"Is a process involving two stages to verify the identity of an entity trying to access services in a computer or in a network". Github solves this authentication with sending an SMS to a device which wants to push to their platform.

Enabling Two-Factor Authentication

@matisojka
matisojka / measure_gem_loading_time.rb
Created July 4, 2012 07:05
Measure Gem loading time in your Rails APP
# Disclaimer: this solution has been taken from the post: http://stackoverflow.com/a/5071198/784270
# navigate to the bundler gem and in lib/bundler/runtime.rb,
# find the line that does Kernel.require and wrap it like this
puts Benchmark.measure("require #{file}") {
Kernel.require file
}.format("%n: %t %r")
# Add
@GUI
GUI / install_vagrant_sudoers.sh
Created June 3, 2012 19:13 — forked from beddari/install_vagrant_sudoers.sh
Allow Vagrant sudo-access without password for NFS-setup (for OS X)
#!/bin/bash
# Script for placing sudoers.d files with syntax-checking
# Making a temporary file to contain the sudoers-changes to be pre-checked
TMP=$(mktemp -t vagrant_sudoers)
cat /etc/sudoers > $TMP
cat >> $TMP <<EOF
# Allow passwordless startup of Vagrant when using NFS.
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/su root -c echo '*' >> /etc/exports