Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 21:54 (UTC -07:00)
View GitHub Profile
@codeprimate
codeprimate / gen-ssl.sh
Created July 22, 2016 20:23
Script to Generate self-signed SSL certificate
#!/usr/bin/env bash
[ -z "$SSL_DIR" ] && export SSL_DIR="."
[ -z "$DOMAIN" ] && export DOMAIN="*.lvh.me"
[ -z "$FILENAME" ] && export FILENAME="wild_lvh_me"
echo " => Generating Self-Signed SSL certificate for $DOMAIN (Using ENV[DOMAIN])"
echo " Filename: $SSL_DIR/$FILENAME (Using ENV[SSL_DIR] and ENV[FILENAME])"
if [ -e "$SSL_DIR/$FILENAME.key" ]; then
@codeprimate
codeprimate / myip.sh
Created July 18, 2016 17:50
Get External IP Address
#!/bin/bash
alias myip="dig +short myip.opendns.com @resolver1.opendns.com."
@codeprimate
codeprimate / policy.txt
Last active January 30, 2017 19:28
AWS IAM Policy for S3 Access
# Public read bucket policy: Edit the bucket policy directly and input this (replace BUCKET)
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"AllowPublicRead",
"Effect":"Allow",
"Principal": {
"AWS": "*"
},
"Action":["s3:GetObject"],
@codeprimate
codeprimate / vid2gif.sh
Last active March 4, 2016 16:00
Convert Video to Animated GIF
#!/bin/bash
# Requires: ffmpeg, ImageMagick convert, gifsicle
ffmpeg -i $1 $1-step1.gif && \
convert $1-step1.gif -verbose -coalesce -layers OptimizeFrame $1-step2.gif && \
gifsicle -O2 $1-step2.gif -o $1.gif && \
rm $1-step1.gif $1-step2.gif
@codeprimate
codeprimate / install.sh
Created March 1, 2016 17:05
Install Gems referencing Homebrew installed OpenSSL on OSX
# Example for EventMachine gem
bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include
bundle install
@codeprimate
codeprimate / mysql error.md
Last active March 1, 2016 16:45
MySQL Client Error

Problem

The following error message is thrown when attempting to start the MySQL client.

mysql: [ERROR] Found option without preceding group in config file /usr/local/etc/my.cnf at line 1!
mysql: [ERROR] Fatal error in defaults handling. Program aborted!

Solution

The error is due to a UTF-8 character at the beginning of the file.

@codeprimate
codeprimate / papertrail_bandwidth_parser.rb
Last active March 3, 2016 17:01
Papertrail Bandwidth Calculator
#!/usr/bin/env ruby
#
# Place this file and PaperTrail gz archives in a folder
#
# Usage: gzcat *.gz | ./papertrail_bandwidth_parser.rb > report.csv
#
BYTES_TO_MB=1024 * 1025
hosts = {}
@codeprimate
codeprimate / xcode-git-cfbundleversion.rb
Created February 12, 2016 14:25
XCode Bundle Version Script
#!/usr/bin/ruby
# xcode-git-cfbundleversion.rb
# Update CFBundleVersion in Info.plist file with short Git revision string
# http://github.com/guicocoa/xcode-git-cfbundleversion/
#
# This is based on
# http://github.com/digdog/xcode-git-cfbundleversion/
# http://github.com/jsallis/xcode-git-versioner
# http://github.com/juretta/iphone-project-tools/tree/v1.0.3
@codeprimate
codeprimate / center.css
Created January 30, 2016 01:20
Vertical Center CSS
.element { position: relative; top: 50%; transform: translateY(-50%); }
@codeprimate
codeprimate / resize-gif.sh
Created January 27, 2016 00:27
Add Padding to an Animated GIF
convert loading.gif -coalesce -repage 0x0 -gravity center -extent 200x300 -background '#cccccc' +repage test1.gif