Skip to content

Instantly share code, notes, and snippets.

View JohnMurray's full-sized avatar

John Murray JohnMurray

View GitHub Profile
@JohnMurray
JohnMurray / Dictionary.ToJson.cs
Created June 1, 2012 03:03
Code descriptions for log-entry on API Anti-Patterns (johnmurray.io)
public static class IDictionaryExtension
{
public static JsonDictionary<K, V> ToJsonDictionary<K,V>(this IDictionary<K, V> dict)
{
if (dict == null)
return null;
var jsonDict = new JsonDictionary<K, V>();
foreach (var key in dict.Keys)
{
jsonDict[key] = dict[key];
@JohnMurray
JohnMurray / console.rb
Created May 31, 2012 15:41
An example console from my geofence-server-example project
#!/usr/bin/env ruby
# require all the necessary files
$: << ::File.expand_path('../src', __FILE__)
require 'app'
require 'geofence'
# at this point bundler should be setup and the :development group
# should have been included. However, just to be sure, I'm going to
# include bundler again and require the console group.
@JohnMurray
JohnMurray / repetitive_pry_session.rb
Created May 31, 2012 15:35
An example of what a repetitive Pry session _might_ look like
require 'bundler/setup'
bundler.require(:development, :test, :console)
$: << File.expand_path('../src', __FILE__)
require 'app'
require 'models/user_account'
require 'models/car'
# Load config and connect to DB
App.init()
@JohnMurray
JohnMurray / load-keyboard
Created February 20, 2012 12:35
Enable Mac OS X Keyboard (built-in only)
#!/bin/bash
# Load the keyboard back. (Should probably do this
# while the external one is still attached.)
sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
@JohnMurray
JohnMurray / unload-keyboard
Created February 20, 2012 12:34
Disable Mac OS X Keyboard (built-in only)
#!/bin/bash
# Unload the keyboard so I can use my external keyboard
# and not worry about accidentally pressing buttons on
# the built-in. This may not be a problem for you but, you
# should see my desk sometimes (Oh no!!) ;-)
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/