Skip to content

Instantly share code, notes, and snippets.

View cadecairos's full-sized avatar

Christopher DeCairos cadecairos

View GitHub Profile
@cadecairos
cadecairos / hawkRespond.js
Created July 25, 2013 16:29
Responding using Hawk
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = function() {
var Hawk = require( "hawk" );
return {
Hawk: Hawk,
/*
@cadecairos
cadecairos / hawkClientAuth.js
Created July 25, 2013 17:39
Generating the Hawk Authorization header using makeapi-client
/* The protected paths can only be accessed by Clients running this code in a Node Environment
* See line XX for the Hawk bits
*
* To set up the Make Client for hawk authorized requests, you would do this:
*
* new Make({
* apiURL: "https://makeapi.webmaker.org,
* hawk: {
* key: "key",
* id: "ID",
@cadecairos
cadecairos / apiUser.js
Created July 25, 2013 18:14
apiUser model
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
module.exports = function( env, mongoose ) {
var validate = require( "mongoose-validator" ).validate;
var schema = new mongoose.Schema({
privatekey: {
type: String,
<snippet>
<content><![CDATA[
console.log( JSON.stringify( ${1:value}, null, 2 ) );
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jlog</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.js</scope>
</snippet>
{
"total": 22,
"max_score": null,
"hits": [
{
"_index": "makes",
"_type": "make",
"_id": "525d8e5636921aa626000002",
"_score": null,
"_source": {

POST [/api/20130724/make]

Create a make

  • Headers

    • authorization - Hawk compatible authorization header
      • 'Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", ext="some-app-ext-data", mac="6R4rV5iE+NPoym+WwjeHzjAGXUtLNIxmo1vpMofpLAE="'
      • For more information about using Hawk, see https://github.com/hueniverse/hawk
  • Body

      {
    

make: {

@cadecairos
cadecairos / remixes.js
Last active January 2, 2016 00:09
A script for counting remixes of makes between two dates.
// Title: remixes.js
// Description: a script for counting remixes of makes between two dates.
// Author: Christopher De Cairos
// Dependencies: makeapi-client ( https://github.com/mozilla/makeapi-client ) and async ( https://npmjs.org/package/async )
// Usage: `node remixes "January 1, 2013 12:00:00 AM EST" "December 31, 2013 12:59:59 PM EST"
// you can change the time strings to whatever you wish.
// edit the URLs array with all the make URL's you wish to count remixes for.
// node must be able to find these packages
var Make = require( "makeapi-client" ),
@cadecairos
cadecairos / gallery.html
Last active August 29, 2015 13:55
Make Gallery Generator
@cadecairos
cadecairos / gist:9415386
Created March 7, 2014 17:05
cade's git aliases
pmm = pull moz master
po = push origin
pmoz = push moz master
st = status
suir = submodule update --init --recursive
co = checkout
cob = checkout -b
com = checkout master
br = branch
ass = add
var queue = async.queue(function(message, queue_done) {
if ( !workers[message.ParsedBody.event_type] ) {
return queue_done();
}
async.waterfall([
function(w_done) {
w_done(null, message.ParsedBody.data);
},
workers[message.ParsedBody.event_type]
], function(err) {