Skip to content

Instantly share code, notes, and snippets.

View JohnMurray's full-sized avatar

John Murray JohnMurray

View GitHub Profile
@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/
@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 / 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 / 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 / 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 / CheckResponse.cs
Created June 4, 2012 00:03
Code descriptions for log-entry on API Anti-Patterns (johnmurray.io)
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
var statusCode = response.StatusCode;
return statusCode == HttpStatusCode.OK;
@JohnMurray
JohnMurray / how_to.md
Created June 12, 2012 18:24
A getting started guide to making requests to my sample geofence-server

John Murray's Sample Geofence Server

Hey, you ran the project! Good for you! You're probably wondering how the heck to use this thing. Well, keep reading and maybe you'll find out.

Pre-Requisites

  1. Install and run Mongo (on default port w/o a password)
  2. Install Gemset with Bundler
  3. Get the server running. (Hey look! You're ahead of the game!)

That's it... keep reading.

@JohnMurray
JohnMurray / ex.sql
Created July 5, 2012 11:56
Link Multi-Where
select *
from (
select *
from carModels as t1,
carMakes as t2
where t1.somePKId = t2.someFKId
and (
t1.Name like '%c%'
or t2.Name like '%c%'
)
@JohnMurray
JohnMurray / JSON.js
Created August 18, 2012 17:18
Fnord Metric and C# Blog Post (http://goo.gl/F8MH5) -- Part 1
{ "_type": "login" }
@JohnMurray
JohnMurray / redis-queue-name.cs
Created August 18, 2012 17:35
Fnord Metric and C# Blog Post (http://goo.gl/F8MH5) -- Part 2
String.Format("mavia-metrics-{0}", guid);