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
| /* fun exercise around aunt Lily and her cats... */ | |
| (function (owner) { | |
| function randomInt(i) { | |
| return Math.floor(Math.random() * i); | |
| } | |
| function randomText() { | |
| var texts = [ |
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
| module CopyableAttributes | |
| def self.included(base) | |
| def copyable_attributes_keys2 | |
| attributes.keys - self.class.protected_attributes.to_a - [ "created_at", "updated_at"] - foreign_key_list | |
| # TODO: we also need to remove foreign keys... maybe have class method 'uncopyable_attributes_keys'? | |
| end | |
| private | |
| def relevant_base_class |
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
| // credit: http://rzrsharp.net/2011/06/27/what-does-coffeescripts-do-do.html | |
| var closures = []; | |
| function createClosures() { | |
| for (var i = 0; i < 5; i++) { | |
| closures[i] = function() { | |
| console.log("i=" + 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
| function floor(i, n) { | |
| var r = i % n; | |
| return i - r; | |
| }; | |
| function floorToHours(date, nHours) { | |
| var hourInMillis = 1000 * 60 * 60; | |
| var dateInMillis = date.valueOf(); | |
| return new Date(floor(dateInMillis, nHours * hourInMillis)); | |
| }; |
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
| // some dummy rows | |
| var rows = []; | |
| for (var i = 0; i < 10000; i++) { | |
| rows.push("this is row " + i); | |
| } | |
| var index = 0; | |
| var currentlyRunning = 0, maxRunning = 200; | |
| function callHandler(row, cb) { |
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
| // same as previous gist, but now via 'async' library | |
| var async = require('async'); | |
| // some dummy rows | |
| var rows = []; | |
| for (var i = 0; i < 10000; i++) { | |
| rows.push("this is row " + 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 EventsEmitter = require('events').EventEmitter; | |
| pg.connect(..., function(err, client, done) { | |
| var pageSize = 50; | |
| var emitter = new EventsEmitter(); | |
| emitter.on('next', function(offset) { | |
| callHandlersPaginated(offset); | |
| }); | |
| emitter.on('end', function() { |
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
| $ModLoad /usr/lib/rsyslog/ommail.so | |
| $ActionMailSMTPServer localhost | |
| $ActionMailFrom rsyslog@uber5.com | |
| $template mailSubject,"Rsyslog alert for %hostname% at %timegenerated%" | |
| $template mailBody,"%msg%" | |
| $ActionMailSubject mailSubject | |
| $ActionExecOnlyonceEveryInterval 60 | |
| $ActionMailTo chris@uber5.com | |
| if ($msg contains 'demo') or ($msg contains 'test') then :ommail:;mailBody |
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
| - certain endpoints are always blocked | |
| if nginx_uri == "/_access_token" or nginx_uri == "/_me" then | |
| ngx.exit(403) | |
| end | |
| -- import requirements | |
| local cjson = require "cjson" | |
| -- setup some app-level vars | |
| local app_id = "APP_ID" |
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 express = require('express'); | |
| var app = express(); | |
| var port = 3100; | |
| app.listen(port, function() { | |
| console.log('listening on port ' + port); | |
| }); | |
| /* public routes */ |