Skip to content

Instantly share code, notes, and snippets.

View mdobson's full-sized avatar
😺
Petting a cat

Matthew Dobson mdobson

😺
Petting a cat
View GitHub Profile
@mdobson
mdobson / gist:3148039
Created July 20, 2012 01:14 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mdobson
mdobson / setup-statsd.sh
Created September 14, 2012 12:39 — forked from jasonroelofs/setup-statsd.sh
Turn an Ubuntu 10.10 EC2 into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
@mdobson
mdobson / 10gen-mongodb.repo
Created November 9, 2012 14:36
Adding the 10gen repo to EC2 instance (64 Bit)
//create the file in /etc/yum.repos.d/10gen-mongodb.repo
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
@mdobson
mdobson / gist:4046402
Created November 9, 2012 15:43
quick note: resizing EBS Block on EC2 so we have what's really allocated
NB: Ran into issues provisioning EC@ servers today where my EBS storage was sticking at the default 8gb storage level. I allocated double that and was wondering where the storage was. Long story short you need to resize the attached hardware so it knows how to do this.
sudo resize2fs /dev/sda1
The above command will resize everything nicely.
@mdobson
mdobson / example.js
Created February 28, 2013 15:09
Issue I'm running into with Chimera in nodejs
var Chimera = require('chimera').Chimera;
var c = new Chimera();
var pageUrl = "http://www.google.com";
c.perform({
url: pageUrl,
locals: {
},
run: function(callback) {
@mdobson
mdobson / gist:5162050
Last active December 14, 2015 22:59
Standard Querying in UserGrid
//Basic query examples in iOS
UGQuery * query = [[UGQuery alloc] init];
//select * wehre name = 'Fred'
[query addUrlTerm:@"name" equals:@"Fred"];
//select * where content contains 'foo'
[query addRequiredContains:@"content" value:@"foo"];
//select * where NOT a = 5
[query addRequirement:@"NOT a=5"];
@mdobson
mdobson / gist:5162194
Last active December 14, 2015 22:59
Geolocation queries in UserGrid
UGQuery * query = [[UGQuery alloc] init];
//This performs a geolocation query on the App Services platform.
//Note that geolocation queries are no different then other queries that can be performed
//on the App Services platform
[query addRequiredWithin:@"restaurants" latitude:37.776753 longitude:-122,407846 distance:16093.00];
//An alternate way to perform this query is to use the SDK method that takes a CLLocation object.
//Set up the CLLocation object with a lat and lon, and simply pass it into the SDK Method
CLLocation *myLocation = [[CLLocation alloc] initWithLatitude:37.776753 longitude:-122.407846];
[query addRequiredWithinLocation:@"restaurants" location:myLocation distance:16093.00];
@mdobson
mdobson / gist:5162316
Last active December 14, 2015 22:59
Following a user
// Following a user currently logged in as fred.
NSString *username = @"barney";
UGClientResponse *response = [usergridClient connectEntities:@"users"
connectorID:@"fred"
connectionType:@"following"
connecteeType:@"users"
connecteeID:username];
@mdobson
mdobson / gist:5162499
Last active December 14, 2015 22:59
Getting followers for a user in UserGrid
//Get the first 30 users that fred is following
UGQuery *query = [[UGQuery alloc] init];
[query addURLTerm:@"limit" equals:@"30"];
UGClientResponse *response = [usergridClient getEntityConnections: @"users"
connectorID:@"fred"
connectionType:@"following"
query:query];
//This array contains the entities fred is following
NSArray * following = [response.response objectForKey:@"entities"];
@mdobson
mdobson / gist:5162692
Created March 14, 2013 16:12
Creating a connection between two entities
// Have fred "like" a dog with an entity connection
NSString *username = @"dino";
UGClientResponse *response = [usergridClient connectEntities:@"users"
connectorID:@"fred"
connectionType:@"likes"
connecteeType:@"dogs"
connecteeID:username];