Skip to content

Instantly share code, notes, and snippets.

View cadecairos's full-sized avatar

Christopher DeCairos cadecairos

View GitHub Profile
@cadecairos
cadecairos / create_user_db.sql
Last active August 29, 2015 14:20
create DB - api.webmaker.org
CREATE TABLE IF NOT EXISTS "users"
(
id serial NOT NULL,
username varchar(20) NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at timestamp DEFAULT NULL,
language varchar(2) NOT NULL DEFAULT 'en',
country varchar(2) NOT NULL DEFAULT 'US',
moderator boolean NOT NULL DEFAULT FALSE,
@cadecairos
cadecairos / api.json
Created April 28, 2015 20:13
JSON Schema for api.webmaker.org
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://api.webmaker.org/",
"title": "Project Schema",
"type": "object",
"properties": {
"project": {
"id": "https://api.webmaker.org/project",
"type": "object",
"properties": {
@cadecairos
cadecairos / skittles.md
Created April 24, 2015 16:37
Skittles examples

###Example commands below are using the httpie utility

CREATE

  • http --json post https://skittles-api.herokuapp.com/api/skittles color=blue authorization:"token skittlesToken"
  • http --json post https://skittles-api.herokuapp.com/api/skittles color=red authorization:"token skittlesToken2"
  • http --json post https://skittles-api.herokuapp.com/api/skittles color=green authorization:"token missingScope"
  • http --json post https://skittles-api.herokuapp.com/api/skittles color=orange authorization:"token fakeToken"
  • http --json post https://skittles-api.herokuapp.com/api/skittles color=yellow authorization:"garbage"
  • http --json post https://skittles-api.herokuapp.com/api/skittles color=red
@cadecairos
cadecairos / notify.js
Created April 10, 2015 13:43
Fogger Notifications Hack
function displatchNativeNotification(action) {
var params = [];
for (key in action) {
if (action.hasOwnProperty(key)) {
params.push(escape(key) + '=' + escape(action[key]));
}
}
var string = params.join('&');
var uri = 'http://fogger.local/?' + string;
@cadecairos
cadecairos / filegelf.rb
Created June 7, 2014 19:48
Reads in a file of gelf formatted events, line by line.
require 'logstash/inputs/base'
require 'logstash/namespace'
class LogStash::Inputs::FileGelf < LogStash::Inputs::Base
config_name 'filegelf'
milestone 2
default :codec, 'plain'
/*!
* EventEmitter v4.2.7 - git.io/ee
* Oliver Caldwell
* MIT license
* @preserve
*/
(function(){function e(){}function t(e,t){for(var r=e.length;r--;)if(e[r].listener===t)return r;return-1}function r(e){return function(){return this[e].apply(this,arguments)}}var s=e.prototype,n=this,a=n.EventEmitter;s.getListeners=function(e){var t,r,s=this._getEvents();if(e instanceof RegExp){t={};for(r in s)s.hasOwnProperty(r)&&e.test(r)&&(t[r]=s[r])}else t=s[e]||(s[e]=[]);return t},s.flattenListeners=function(e){var t,r=[];for(t=0;t<e.length;t+=1)r.push(e[t].listener);return r},s.getListenersAsObject=function(e){var t,r=this.getListeners(e);return r instanceof Array&&(t={},t[e]=r),t||r},s.addListener=function(e,r){var s,n=this.getListenersAsObject(e),a="object"==typeof r;for(s in n)n.hasOwnProperty(s)&&-1===t(n[s],r)&&n[s].push(a?r:{listener:r,once:!1});return this},s.on=r("addListener"),s.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},s.once=r("addOnceListener"),s.defineEvent=functio
// 1. COPY TO WEBMAKER-EVENTS-SERVICE ROOT DIRECTORY
// 2. RUN `NPM INSTALL AWS-SDK`
// 3. RUN `SQS_QUEUE_REGION=<QUEUE_REGION> SQS_QUEUE_URL=<QUEUE_URL> node create_event_log.js
// 4. RUN `RM -R NODE_MODULES/AWS-SDK`
var loginConnString = process.env.WMLOGIN_CONNECTION_STRING + "/user/username/";
var Habitat = require('habitat');
Habitat.load();
// 1. COPY TO LOGIN.WEBMAKER.ORG ROOT DIRECTORY
// 2. RUN `NPM INSTALL AWS-SDK`
// 3. RUN `SQS_QUEUE_REGION=<QUEUE_REGION> SQS_QUEUE_URL=<QUEUE_URL> node create_user_log.js
// 4. RUN `RM -R NODE_MODULES/AWS-SDK`
var env = require( "./config/environment" );
var db,
dbOptions = {};
// DB Config parsing
db = env.get("DB");
var hyperquest = require("hyperquest");
var querystring = require("querystring");
module.exports = function(data, cb) {
var post = hyperquest.post({
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
uri: "https://sendto.mozilla.org/page/s/webmaker"
});