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){
#!/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 / js-get-fn-name.js
Last active June 14, 2018 13:28 — forked from dfkaye/js-get-fn-name.js
get a javascript function name
function getFnName(fn) {
var f = typeof fn == 'function';
var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/));
return (!f && 'not a function') || (s && s[1] || 'anonymous');
}
function currentFnName() {
try {
return getFnName(arguments.caller);
} catch(e) {
@morgant
morgant / dumpoverssh.sh
Last active July 11, 2018 04:29 — forked from kirkegaard/dumpoverssh.sh
pipe a mysql dump through gzip and send it over ssh
# dump to another server
mysqldump -u MYSQL_USERNAME -p YOUR_DATABASE | gzip -c | ssh USERNAME@YOUR_TO_HOST 'cat > ~/dump.sql.gz'
# dump from another server
ssh USERNAME@YOUR_TO_HOST 'mysqldump -u MYSQL_USERNAME -pPASSWORD YOUR_DATABASE | gzip -c' > ~/dump.sql.gz
export default {
get(page) {
return this.all().find(p => p.page == page)
},
all() {
return [
{
page: 'signup',
title: 'Sign up',
subtitle: 'Please enter your name, email and set a password.',
@morgant
morgant / pt100reg.py
Last active April 4, 2024 13:53 — forked from anonymous/pt100reg.py
PT100Reg - allows you to create a registration key for the PT100 terminal emulator for Newton
maxUnsigned = 0x1FFFFFFF
bitsInUnsigned = int(29)
seventyFivePercent = int(22)
twelvePercent = int(4)
highBits = 0x1E000000
lowBits = 0x01FFFFFF
def generateRegCode(userName):
reg = ""
sn = ""