I hereby claim:
- I am gaarf on github.
- I am gaarf (https://keybase.io/gaarf) on keybase.
- I have a public key ASDZUnovBGVtp81cnfXv9lAlDlnGdmxGWKXA9cc3E14WJQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
var fs = require('fs'), | |
spawn = require('child_process').spawn; | |
var dataFiles = fs.readdirSync('./data'); | |
function spawnAsPromise() { | |
var args = Array.prototype.slice.call(arguments); | |
return new Promise(function(resolve, reject) { | |
var stdout = '', stderr = ''; | |
var cp = spawn.call(null, args.shift(), args, {cwd: __dirname}); |
(function(){var%20urlWithoutFragment=window.location.href.replace(/%23.*/,'');var%20newWindow=window.open('about:blank','_blank');newWindow.document.write('<!DOCTYPE%20HTML%20PUBLIC%20"-//W3C//DTD%20HTML%204.01%20Frameset//EN"%20"http://www.w3.org/TR/html4/frameset.dtd"><html><head><title>[Autoreload]%20'+urlWithoutFragment+'</title><script%20type="text/javascript">window.addEventListener("load",function(){var%20frame=document.getElementsByTagName("frame")[0];frame.addEventListener("load",function(){window.setTimeout(function(){frame.src=frame.src;},1000);},false);frame.src="'+urlWithoutFragment+'";},false);</script></head><frameset><frame%20src="about:blank"></frameset></html>');newWindow.document.close();})() |
// node.js mode: | |
var CDAPTracker = require('cask-cdaptracker'); | |
var tracker = new CDAPTracker({ | |
endpoint: 'https://somehost.domain.tld/path/foo/bar' | |
}); | |
tracker.track({hello: 'world'}) // it returns a promise | |
.then(function (response) { | |
console.log('the world was tracked!', response) |
Array | |
( | |
[diagnostics] => Array | |
( | |
[publiclyCallable] => true | |
[url] => Array | |
( | |
[0] => Array | |
( | |
[@content] => http://weather.yahooapis.com/forecastrss?w=2502265 |
// First we load the Stripe library - https://github.com/abh/node-stripe | |
// and pass in our secret key, which will uniquely identify us with the Stripe platform. | |
var stripe = require('stripe')(process.env.STRIPE_SECRET); | |
/** | |
* Controller for a Stripe webhook | |
* | |
* @param {Object} app An Express.js app | |
* @param {Object} kit Our business logic | |
*/ |
I am using Mongo v2.0.2, and currently on Mongoose v3.6.0. | |
I have a collection called "Users". Each doc has a String field called "ua", which is NOT indexed - but I tried with an indexed field and the behaviour is the same. | |
I want to find all the docs that have a ua containing, say, "Safari". So I try to use RegExp queries. | |
----- | |
Directly in Mongo console, everything works fine: |
SomeSchema.methods.mapReduce = function(callback) { | |
function map() { | |
/*global emit:true */ | |
emit('something', {foos:this.foos, users:1}); | |
} | |
function reduce(k, av) { | |
var foos = 0; | |
av.forEach(function(v) { |
export VISUAL=nano | |
export EDITOR=nano | |
export CLICOLOR=1 | |
export TERM=xterm-color | |
export LSCOLORS=gxgxcxdxbxegedabagacad # cyan directories | |
export NODE_ENV='development' | |
export RAILS_ENV=$NODE_ENV # haha | |
if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi |
# see https://github.com/ptarjan/base64url/blob/master/ruby.rb | |
def base64_url_decode(str) | |
str += '=' * (4 - str.length.modulo(4)) | |
Base64.decode64(str.gsub("-", "+").gsub("_", "/")) | |
end | |
# see http://developers.facebook.com/docs/authentication/signed_request/ | |
def valid_facebook_signature?(signature, encoded_data) | |
base64_url_decode(signature) == HMAC::SHA256.digest(FACEBOOK_APP_SECRET, encoded_data) | |
end |