This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "pry" | |
class JwtAuthentication | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
req = Rack::Request.new(env) | |
secret = ";Xsc2}M48w33xUvL7N>SG-V}OnU??BG&O&|!az,)yHpLgm/|g,kj^iVNwr<SFqy" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
mongoClient = require('mongodb').MongoClient, | |
foodsJson = JSON.parse(fs.readFileSync('./foods-2011-10-03.json')); | |
mongoClient.connect('mongodb://127.0.0.1:27017/salud', function(err, db) { | |
if (err) throw err; | |
var collection = db.collection('foods-orig'); | |
foodsJson.forEach(function(el, i) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
path = '/path/to/sql/file'; // This represents a 4-5 gb file, way too large for a buffer in memory | |
// Without Streams | |
fs.readFile(path, 'utf8', function(err, data) { // This will fail because the size is too large for BUffer creation | |
if (err) throw err; | |
console.log(data); | |
}); | |
// With Streams |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var EventEmitter = require('events').EventEmitter; | |
// Create the initial Counter class, that emits the named event | |
var Counter = function(init) { | |
this.increment = function() { | |
init++; | |
this.emit('incrementer', init); | |
} | |
}; |
NewerOlder