This file contains 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
// | |
// The following snippet must be inserted at the top of your main js file | |
// | |
process.title = "myapp"; | |
var PID_FILE = "/usr/local/var/run/"+process.title+".pid" | |
, fs = require('fs'); | |
fs.writeFileSync(PID_FILE, process.pid+"\n"); |
This file contains 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
// Ruby = 5.times { |i| puts i } | |
// JS = (1).times(function(i){console.log(i);}) | |
Number.prototype.times = function(cb) { | |
var i = -1; | |
while (++i < this) { | |
cb(i); | |
} | |
return +this; |
This file contains 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
# | |
# Slightly tighter CORS config for nginx | |
# | |
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs | |
# | |
# Despite the W3C guidance suggesting that a list of origins can be passed as part of | |
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox) | |
# don't seem to play nicely with this. | |
# |
This file contains 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
/auth/realms/<realm>/protocol/openid-connect/token | |
/auth/realms/<realm>/protocol/openid-connect/logout | |
/auth/realms/<realm>/protocol/openid-connect/auth | |
/auth/realms/<realm>/login-actions/first-broker-login | |
/auth/realms/<realm>/broker/after-first-broker-login |
This file contains 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
-- strpad(input, pad_length, [pad_string], [pad_type]) | |
-- (php-style) implemented in LUA (inspired from https://gist.github.com/2625581) | |
-- @FGRibreau - Francois-Guillaume Ribreau | |
-- @Redsmin - A full-feature client for Redis http://redsmin.com | |
local function strpad(input, pad_length, pad_string, pad_type) | |
local output = input | |
if not pad_string then pad_string = ' ' end | |
if not pad_type then pad_type = 'STR_PAD_RIGHT' end |
This file contains 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
$('#el').AttributeObserver(attr, callback, [delay]); |
This file contains 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
for file in ./*.MTS | |
do | |
ffmpeg -i $file -vcodec mjpeg -b 100M -acodec pcm_s16be $file.mov | |
done |
This file contains 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
// Basic PostgresToSNSWorker worker | |
const pg = require ('pg'); | |
const pgConString = process.env.POSTGRESQL_CONNECTIONSTRING; | |
pg.connect(pgConString, function(err, client) { | |
if(err) { | |
console.log(err); | |
} | |
client.on('notification', function(msg) { |
This file contains 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 myextend(/* args */){ | |
var o = {} | |
, args = Array.prototype.slice.call(arguments) | |
, obj = args.shift() | |
, src = args.shift(); | |
for (var p in src){ | |
if (src.hasOwnProperty(p)){ | |
if (hasOwn.call(obj,p) && typeof obj[p] === 'object' && obj[p] !== null) { | |
o[p] = myextend(obj[p],src[p]); |
This file contains 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
Object.defineProperty(Array.prototype, 'until',{ | |
/** | |
* Return the array elements until a selector is matched | |
* @param {Number|String|Function} selector | |
* @return {Array} A new array that goes from the first element to `selector` | |
* | |
* Usage: | |
* deepEqual([1,2,3,4,5].until(4), [1, 2, 3, 4]) | |
* deepEqual(['a','b','c','d','e'].until('c'), ['a', 'b', 'c']) | |
* deepEqual([{t:'a'},{t:'b'},{t:'c'},{t:'d'}].until(function(o){return o.t == 'c';}), [{t:'a'},{t:'b'},{t:'c'}]) |