Skip to content

Instantly share code, notes, and snippets.

@mattgrayson
mattgrayson / ViewControllerTestHelper.swift
Created April 18, 2017 21:46
Helper class for presenting view controllers from context of an Xcode unit testing target.
//
// Helper class for presenting view controllers from context of an Xcode unit testing target.
//
// Ported from original Objective-C version at
// https://github.com/klaaspieter/KPAViewControllerTestHelper/blob/master/Classes/KPAViewControllerTestHelper.m
//
import Foundation
import UIKit
// DictionaryTypesHelper.h
#import <Foundation/Foundation.h>
@interface NSDictionary (NSDictionary_DictionaryTypesHelper)
- (NSArray*)arrayForKey:(id)key;
- (NSDictionary*)dictionaryForKey:(id)key;
- (NSString*)stringForKey:(id)key;
- (NSNumber*)numberForKey:(id)key;
- (NSData*)dataForKey:(id)key;
@mattgrayson
mattgrayson / keybase.md
Created February 26, 2015 10:39
keybase.md

Keybase proof

I hereby claim:

  • I am mattgrayson on github.
  • I am mattgrayson (https://keybase.io/mattgrayson) on keybase.
  • I have a public key whose fingerprint is E0D9 975B A5A2 2DEA F247 0B31 3D33 BB1A DDDB 94D9

To claim this, I am signing this object:

@mattgrayson
mattgrayson / es.sh
Created November 16, 2012 16:10 — forked from rajraj/es.sh
Install ElasticSearch on CentOS 6
cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk.i686 -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@mattgrayson
mattgrayson / EventSource.js
Created August 3, 2012 01:20 — forked from gdamjan/eventsource.py
This is a python/gevent reimplementation of this EventSource demo https://github.com/remy/eventsource-h5d/
;(function (global) {
if ("EventSource" in global) return;
var reTrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g;
var EventSource = function (url) {
var eventsource = this,
interval = 500, // polling interval
lastEventId = null,
@mattgrayson
mattgrayson / server.js
Created December 8, 2011 11:10 — forked from esperia/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var util = require('util');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
from django.db import models
import uuid
class UUIDField(models.CharField):
"""
A field which stores a UUID value in hex format. This may also have
the Boolean attribute 'auto' which will set the value on initial save to a
new UUID value (calculated using the UUID1 method). Note that while all
UUIDs are expected to be unique we enforce this with a DB constraint.