Skip to content

Instantly share code, notes, and snippets.

View morgant's full-sized avatar

Morgan Aldridge morgant

View GitHub Profile
@morgant
morgant / clipcat
Created December 8, 2010 20:10
My updates to David Kendall's original, and now part of tools-osx (https://github.com/morgant/tools-osx).
#!/usr/bin/perl -w
#
# clipcat - Concatenate and print Text Clippings.
#
# v0.1 2010-11-18 - David Kendal <https://gist.github.com/705623>
# Initial version. Used with permission.
# v0.2 2010-12-08 - Morgan Aldridge <morgant@makkintosshu.com>
# Now concatenates multiple text clippings. Usage instructions.
#
@morgant
morgant / google_convert_currency.php
Created February 26, 2011 03:31 — forked from SeanJA/google_convert_currency.php
Caching currency conversion using Google Calculator.
<?php
$currencyCache = array();
/**
* Looks for unquoted keys in a json string and fixes them ie: {a:"b"} => {"a":"b"}
* @param string $string A json string that is suspect
* @return string A valid json string
*/
function fix_json($string){
@morgant
morgant / mime2mdwn
Created April 18, 2011 01:56
Convert MIME format wiki export (developed for PhpWiki exports) to Markdown
#!/bin/bash
#
# mime2mdwn - Convert MIME format wiki export (developed for PhpWiki exports) to Markdown
#
# globals
debug=false
# the actual heavy lifting
#!/bin/bash
# get the Mac OS X version
version_major=$(sw_vers -productVersion | cut -d . -f 2)
#version_minor=$(sw_vers -productVersion | cut -d . -f 3)
interpreter=''
# 10.7.x now has no 32-bit only version of Perl included, so we
# need to set Perl's prefer-32-Bit default
if [ $version_major -eq 7 ]; then
@morgant
morgant / gist:1753095
Created February 6, 2012 16:25
Building GnuTLS on Mac OS X

Preparing the Build Environment

cd ~/Desktop
mkdir wget-build
cd wget-build

Building & Installing GMP 5.0.2

@morgant
morgant / mirror_homepage.mac.com_sites_instructions.txt
Created June 18, 2012 18:23
Notes/instructions for how I've been mirroring homepage.mac.com sites to mirrors.unna.org
Mirroring homepage.mac.com sites to mirrors.unna.org:
1) Use `wget` to pull down a copy of the site. If pulling down a single file & all its prerequisites, use the following:
/usr/local/bin/wget -p --mirror -k -t 30 -w 5 -e robots=off -o homepage.mac.com-splorp.$(date +%Y-%m-%d-%H%M).log "http://homepage.mac.com/splorp/PhotoAlbum3.html" &
Alternatively, if pulling down an entire directory, use the following (Note: _make sure_ you include the trailing slash on the directory name!):
/usr/local/bin/wget --mirror -k -t 30 -w 5 -e robots=off -o homepage.mac.com-splorp.$(date +%Y-%m-%d-%H%M).log "http://homepage.mac.com/splorp/" &
@morgant
morgant / NewtFns.c
Created July 25, 2012 01:20
NewtonScript Perform() for NEWT/0
/** Send a message to a method in a frame by name with an array of parameters
*
* @param rcvr [in] レシーバ
* @param frame [in] Frame
* @param message [in] Message
* @param params [in] Parameters
*
* @return Return value
*/
newtRef NsPerform(newtRefArg rcvr, newtRefArg frame, newtRefArg message, newtRefArg params)
@morgant
morgant / compress_and_encrypt-no_exposed_password.txt
Last active July 10, 2018 21:22
Compress & Encrypt to Disk Using OpenSSL in Bash Without Exposing Password
#
# This is the simplest and cleanest way I've come up with for securely compressing (gzip, in this example) & encrypting data to disk with OpenSSL from a bash script without exposing the password to inspection of process or environment variable using `ps` and the likes. Naturally, `cat` is just used as an example so the data can come from anywhere. If the compressed data is to be sent via email instead of written to disk, don't use '-out' and use '-a' to base64 encode the compressed data.
#
# References:
# http://www.madboa.com/geek/openssl/#encrypt-simple
# http://unix.stackexchange.com/questions/29111/safe-way-to-pass-password-for-1-programs-in-bash#answer-29186
# http://stackoverflow.com/questions/6607675/shell-script-password-security-of-command-line-parameters/6607773#6607773
# https://gist.github.com/philfreo/2321650
cat "$file" | gzip -c | openssl enc -e -salt -aes-256-cbc -pass fd:3 -out "$file.gz.enc" 3<<<"$password"
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@morgant
morgant / gist:d21fd94fa01a30a91ff1
Last active August 29, 2015 14:09
Asterisk 12.2.0 build failure on OS X Yosemite 10.10.1 when using homebrew-asterisk formula
$ brew install -vd ~/Projects/homebrew-asterisk/asterisk.rb
/usr/local/Library/brew.rb (Formulary::FromPathLoader): loading /Users/someuser/Projects/homebrew-asterisk/asterisk.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/gcc48.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/gmp4.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/libmpc08.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/mpfr2.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/cloog018.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Formula/pkg-config.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions