Skip to content

Instantly share code, notes, and snippets.

View crtr0's full-sized avatar

Carter Rabasa crtr0

View GitHub Profile
@crtr0
crtr0 / gist:4197929
Created December 3, 2012 20:53
JS array of vote option objects
[
{
"id": 1,
"name": "foo",
"votes": 0
},
{
"id": 2,
"name": "bar",
"votes": 0
@crtr0
crtr0 / gist:4197923
Created December 3, 2012 20:52
Loads an event from CouchDB based on the "shortname" parameter in the URL
var event = function(req, res){
events.findBy('shortname', req.params.shortname, function(err, event) {
if (event) {
// remove sensitive data
event.voteoptions.forEach(function(vo){
delete vo.numbers;
});
res.render('event', {
name: event.name, shortname: event.shortname, state: event.state,
@crtr0
crtr0 / gist:4197917
Created December 3, 2012 20:51
Initializing highcharts.js
var chart;
// Attach a handler to the window load event.
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'chart',
type: 'bar'
},
title: {
var Twilio = require('./twilio-js');
Twilio.AccountSid = "AC57534a35a8284eb49d22b122fb5be0e6";
Twilio.AuthToken = "bc80e083030a3c14638923c335c82854";
Twilio.UsageRecord.all(function(err, res) {
res.usageRecords.forEach(function(record) {
// have at it!
});
});
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]},
@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:
//
@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 / gist:3382587
Created August 17, 2012 20:57
Sample event doc
{
"name": "Demo Voting",
"shortname": "demo",
"voteoptions": [{
"id": 1,
"name": "foo",
"votes": 0,
"numbers": []
},
{
Application = Thorax.Application.create()
# convenience for debugging
window.Application = Application
# main view controller
Application.ViewController.create
parent: Application
routes:
'': 'index'
@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