Skip to content

Instantly share code, notes, and snippets.

@michaelwills
michaelwills / gist:1053807
Created June 29, 2011 13:20
Extending a redbeanphp model to handle instantiation with IDE code hints
<?php
// in BaseSimpleModel.php
class BaseSimpleModel extends RedBean_SimpleModel {
/**
* Get or create a model with the bean set
* @static
* @param string $table
@michaelwills
michaelwills / pr.md
Created February 17, 2018 05:18 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@michaelwills
michaelwills / snippets.sh
Last active February 23, 2016 09:28
sphinx 4 audio preparation snippets
# use ffmpeg to extract audio from video file
% ffmpeg -i infile.mp4 -acodec pcm_s16le -ac 1 -ar 16000 outfile.wav
# use sox to convert to raw
sox infile.wav -b 16 -s -c 1 -r 16k -t raw outfile.raw
# https://trac.ffmpeg.org/wiki/audio%20types
# use ffmpeg to extract RAW! audio from video file
ffmpeg -i input -f s16le -acodec pcm_s16le output.raw
% ffmpeg -i infile.mp4 -f s16le -acodec pcm_s16le -ac 1 -ar 16000 outfile.raw
@michaelwills
michaelwills / HuesAppSampleColor
Created July 11, 2013 04:56
Simple Applescript to trigger the Hues app to sample a color
# For http://giantcomet.com/hues/
# inspired by https://twitter.com/JP_Sirois/status/132517964267261952
# with help from UIElementInspector
# Works as a workflow in AlfredApp
tell application "Hues" to activate
tell application "System Events"
tell process "Hues"
click first button of window 1
end tell
# From http://stackoverflow.com/a/14674326/1524448
import collections
freq = collections.Counter()
# sample and output
# line = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod'
# Counter({'ipsum': 1, 'amet,': 1, 'do': 1, 'sit': 1, 'eiusmod': 1, 'consectetur': 1, 'sed': 1, 'elit,': 1, 'dolor': 1, 'Lorem': 1, 'adipisicing': 1})
with open(filename) as f:
@michaelwills
michaelwills / .env.sh
Last active December 11, 2015 06:39
serverless/serverless framework testing .env file
TEST_SERVERLESS_EXE_CF=false
TEST_SERVERLESS_EMAIL=YOUR_EMAIL
TEST_SERVERLESS_REGION1=us-east-1
TEST_SERVERLESS_REGION2=us-west-2
TEST_SERVERLESS_STAGE1=development
TEST_SERVERLESS_STAGE2=production
TEST_SERVERLESS_LAMBDA_ROLE=ARN_FROM_A_PROJECT
TEST_SERVERLESS_AWS_ACCESS_KEY=YOUR_KEY
TEST_SERVERLESS_AWS_SECRET_KEY=YOUR_SECRET
NPM_BIN="/path/to/node /path/to/npm"