Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Strathmeyer strathmeyer

View GitHub Profile
@strathmeyer
strathmeyer / prod.sh
Created Sep 14, 2017
Blames TODOs in Python files
View prod.sh
GIT_GREP="$(git grep -i -n -E '#[ ]*TODO' -- '*.py')"
IFS=$'\n' read -rd '' -a LINES <<<"$GIT_GREP"
for LINE in "${LINES[@]}"
do
IFS=: read FILE LINE MATCH <<<"$LINE"
echo "$FILE:$LINE"
git blame $FILE -L $LINE,+1
echo
done
@strathmeyer
strathmeyer / rename_cbf.py
Last active Aug 29, 2015
Collects .cbf files from multiple subdirectories, copies them to a common output directory, modifies the filename of each and also modifies a line inside the file to match the new filename.
View rename_cbf.py
import glob
import os
import re
# Create the output directory if it doesn't exist
output_dir = './output/'
if not os.path.exists(output_dir):
os.makedirs(output_dir)
# Pull in all the input file names. The "**"" means "this directory and any
@strathmeyer
strathmeyer / hapi_cache.js
Last active Aug 29, 2015
Demo hapi's caching of method results
View hapi_cache.js
var Hapi = require('hapi');
var server = new Hapi.Server('localhost', 8000);
var add = function (a, b, next) {
console.log("Calculating...");
next(null, a + b);
};
server.method('sum', add, { cache: { expiresIn: 2000 } });
@strathmeyer
strathmeyer / Gruntfile.js
Last active Feb 25, 2016
A simple Gruntfile
View Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
concat: {
js: {
src: ['js/jquery-2.0.3.min.js',
'js/plugins/*.js',
'js/site.js'],
dest: 'build.js',
options: {
separator: ';'
View parse_whackness.rb
require 'date'
def parse_whackness(date_string)
year = parse_year(date_string)
month, day = guess_day_month(date_string[0..-5])
Date.new(year.to_i, month.to_i, day.to_i)
end
@strathmeyer
strathmeyer / gist:5230028
Created Mar 24, 2013
Using the sitemap in Middleman
View gist:5230028
<% if current_page.parent %>
<h2>Parent</h2>
<ul>
<li><%= link_to current_page.parent.data.title, current_page.parent %></li>
</ul>
<% end %>
<h2>Children</h2>
<ul>
<% current_page.children.select { |p| p.ext == ".html" && p.data.title }.each do |resource| %>
@strathmeyer
strathmeyer / gist:4990173
Created Feb 19, 2013
Improve OSX Bluetooth quality
View gist:4990173
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Max (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" 48
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool (editable)" 40
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool" 48
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Max" 53
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Min" 48
defaults write com.apple.BluetoothAudioAgent "Stream - Flush Ring on Packet Drop (editable)" 30
defaults write com.apple.BluetoothAudioAgent "Stream - Max Outstanding Packets (editable)" 15
defaults write com.apple.BluetoothAudioAgent "Stream Resume Delay" "0.75"
@strathmeyer
strathmeyer / gist:4433071
Last active Dec 10, 2015
Books I read in 2012
View gist:4433071
1. Poke the Box
2. Anything You Want
3. Snuff (Pratchett)
4. Republic, Lost
5. Guards! Guards!
6. Men At Arms
7. Buddy Does Seattle
8. Buddy Does Jersey
9. Feet of Clay
10. Jingo
View gist:4043583
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
@strathmeyer
strathmeyer / gist:3720224
Created Sep 14, 2012
'bower update' with a component.json
View gist:3720224
~/Development/footest ls
component.json
~/Development/footest cat component.json
{
"name": "footest",
"version": "0.0.1",
"main": [],
"dependencies": {
"jquery": "~1",
"underscore": "~1.3.3",