Skip to content

Instantly share code, notes, and snippets.

View crtr0's full-sized avatar

Carter Rabasa crtr0

View GitHub Profile
@crtr0
crtr0 / install_rvm_rails.sh
Created February 21, 2012 18:11
Installing RVM and Rails on Mac OSX Lion
#!/bin/sh
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
source ~/.bash_profile
rvm install 1.9.2
rvm --default 1.9.2
gem update
gem install rails
@crtr0
crtr0 / twilio_demo.js
Created April 5, 2012 19:49
Fetch some SMS messages from Twilio and call the senders
var magic = function () {
twilio.getSmsMessages("623-850-4926", "2012-04-02", function (success) {
success.sms_messages.forEach(function (message) {
twilio.makeCall("623-850-4926", message.from, "http://demo.rabasa.com/tombstone.php");
});
});
};
@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@crtr0
crtr0 / win8-js-restapi-boilerplate.js
Created June 15, 2012 19:37
Win8 JS library boilerplate for REST services
(function (globals) {
var
// The username and password for BASIC auth
username,
password,
// CHANGE THIS
apiRoot = "https://api.foo.com/version",
@crtr0
crtr0 / gist:2976718
Created June 23, 2012 03:41
Infinite loop
[06/22 20:39:58 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:58 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:58 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:58 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:58 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:58 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:59 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:59 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:59 PDT] ERROR: failed to save vote info to DB, retrying
[06/22 20:39:59 PDT] ERROR: failed to save vote info to DB, retrying
Application = Thorax.Application.create()
# convenience for debugging
window.Application = Application
# main view controller
Application.ViewController.create
parent: Application
routes:
'': 'index'
@crtr0
crtr0 / gist:3382587
Created August 17, 2012 20:57
Sample event doc
{
"name": "Demo Voting",
"shortname": "demo",
"voteoptions": [{
"id": 1,
"name": "foo",
"votes": 0,
"numbers": []
},
{
@crtr0
crtr0 / gist:3382595
Created August 17, 2012 20:58
CouchDB views for events
{
"_id": "_design/event",
"views": {
"byShortname": {
"map": "function (doc) { if (doc.shortname) { emit(doc.shortname, doc) } } "
},
"byPhonenumber": {
"map": "function (doc) { if (doc.phonenumber) { emit(doc.phonenumber, doc) } } "
},
"all": {
@crtr0
crtr0 / lxjs_sms.js
Created September 29, 2012 09:54
LxJs Texting
// Twilio API: http://twilio.com/api
// Twilio Node.js module: https://github.com/stevegraham/twilio-js
var Twilio = require('twilio-js')
, twilioNumber = "your SMS-enabled Twilio #";
require('./creds')(Twilio);
// creds.js should look like:
//
var request = require('request'),
querystring = require('querystring'),
Buffer = require('buffer').Buffer;
var numbers = ['+12068666338'];
var vote = process.argv[2];
var attack = function(i) {
var dataHash = {Body: vote, From: vote + "-" + i, To: numbers[0]},