Skip to content

Instantly share code, notes, and snippets.

View marccampbell's full-sized avatar

Marc Campbell marccampbell

View GitHub Profile
@marccampbell
marccampbell / pager.io examples
Created July 28, 2011 21:27
Creating Authorization Header for Pager.io API in Python
import base64
header = 'Basic ' + base64.b64encode('pager.io:1234567890')
print header
'Basic cGFnZXIuaW86MTIzNDU2Nzg5MA=='
@marccampbell
marccampbell / create_alert.py
Created July 28, 2011 21:49
Pager.io API Example: Create Alert
import urllib, urllib2, base64
team_name = 'My Pager.io Team Name'
api_key = 'My Pager.io API Key'
alert_subject = 'Test Alert'
alert_message = 'This is where you would put a longer alert message'
data = {'subject': alert_subject, 'message': alert_message}
base64string = base64.encodestring('%s:%s' % (team_name, api_key)).replace('\n', '')
var mongoose = require('mongoose');
function Account() {
this.isValid = false;
this.fields = {};
var AccountData = new mongoose.Schema({
createdOn:{type:Date, required:true},
email:{type:String},
phone:{type:String},
@marccampbell
marccampbell / ios_basic.m
Created September 27, 2011 21:28
Look.IO Basic iOS Inegeration
- (void)helpButtonWasTapped {
[[LIOLookIOManager sharedLookIOManager] beginSession];
}
@marccampbell
marccampbell / ios_advanced.m
Created September 27, 2011 21:36
Look.IO Advanced iOS Features
[[LIOLookIOManager sharedLookIOManager]setUsesControlButton:NO];
@marccampbell
marccampbell / delegates.m
Created December 19, 2011 19:25
LookIO iOS Delegate Implementation
[[LIOLookIOManager sharedLookIOManager] performSetupWithDelegate:aDelegate];
// Delegate protocol
@protocol LIOLookIOManagerDelegate
- (UIWindow *)lookIOManangerMainWindowForHostApp:(LIOLookIOManager *)aManager;
- (void)lookIOManager:(LIOLookIOManager *)aManager didUpdateEnabledStatus:(BOOL)lookioIsEnabled;
- (BOOL)lookIOManager:(LIOLookIOManager *)aManager shouldRotateToInterfaceOrientation:(UIInterfaceOrientation)anOrientation;
@end
@marccampbell
marccampbell / private_addr.erl
Created January 30, 2012 23:56
Get Private IP Address
{ok, Interfaces} = inet:getifaddrs(),
Addresses = lists:map(fun({_, Props}) -> proplists:get_all_values(addr, Props) end, Interfaces),
Private_Addresses = lists:filter(fun({F,_,_,_}) -> lists:member(F, [10, 172, 192]); (_) -> false end, lists:flatten(Addresses)),
io:format("Private Addresses = ~p\n", [Private_Addresses]),
case Private_Addresses of
[] -> io:format("Unable to start monitor listener, no private address was found.\n", []),
undefined;
_ -> {A, B, C, D} = lists:nth(1, Private_Addresses),
IP_Address = lists:flatten(io_lib:format("~.10B.~.10B.~.10B.~.10B", [A, B, C, D])),
io:format("Starting listener on ~s\n", [IP_Address]),
@marccampbell
marccampbell / joyent-smartos.erb
Created August 22, 2012 22:14 — forked from benjaminws/joyent-smartos.erb
joyent-smartos.erb
# shove this in ~/.chef/bootstrap/joyent-smartos.erb
# run knife bootstrap <hostname> -d joyent-smartos
bash -c '
if [ ! -f /opt/local/bin/chef-client ]; then
cd /tmp
pkgin install gcc-compiler gcc-runtime gcc-tools-0 ruby19 scmgit-base scmgit-docs gmake sun-jdk6
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
tar -xzf rubygems-1.8.10.tgz
cd rubygems-1.8.10
@marccampbell
marccampbell / joyent-smartos.erb
Created August 22, 2012 22:15 — forked from benjaminws/joyent-smartos.erb
joyent-smartos.erb
# shove this in ~/.chef/bootstrap/joyent-smartos.erb
# run knife bootstrap <hostname> -d joyent-smartos
bash -c '
if [ ! -f /opt/local/bin/chef-client ]; then
cd /tmp
sudo pkgin -y install gcc-compiler gcc-runtime gcc-tools-0 ruby19 scmgit-base scmgit-docs gmake
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz
tar -xzf rubygems-1.8.10.tgz
cd rubygems-1.8.10
%%
%% run this from the console with the following command:
%%
%% eunit:test({timeout, 60, mnesia_performance_tests}).
%%
-module(mnesia_performance_tests).
-author('[email protected]').