Skip to content

Instantly share code, notes, and snippets.

View extrabacon's full-sized avatar

Nicolas Mercier extrabacon

  • Montreal, Canada
View GitHub Profile
@extrabacon
extrabacon / RoutingRules.xml
Created October 22, 2015 12:15
S3 Hosting for HTML5 apps
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>yourdomainname.com</HostName>
<ReplaceKeyPrefixWith>#!/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
@extrabacon
extrabacon / with --harmony
Created July 24, 2015 18:29
ESLint configurations for Node 0.12
{
"env": {
"node": true
},
"ecmaFeatures": {
"forOf": true,
"arrowFunctions": true,
"generators": true,
"blockBindings": true,
"binaryLiterals": true,
@extrabacon
extrabacon / set-keep-alives.sh
Last active June 22, 2023 20:04
TCP keep-alives on Mac
sudo sysctl -w net.inet.tcp.keepidle=20000
sudo sysctl -w net.inet.tcp.keepintvl=20000
sudo sysctl -w net.inet.tcp.keepinit=20000
sudo sysctl -w net.inet.tcp.always_keepalive=1
@extrabacon
extrabacon / extend.js
Last active August 29, 2015 13:57
Standalone _.extend function
function extend(obj) {
Array.prototype.slice.call(arguments, 1).forEach(function (source) {
if (source) {
for (var key in source) {
obj[key] = source[key];
}
}
});
return obj;
}
@extrabacon
extrabacon / sample.js
Created March 25, 2014 16:45
Proper inheritance with Javascript (sample with Node EventEmitter)
var EventEmitter = require('events').EventEmitter;
var MyClass = function () {
// invoke base constructor - optionally with parameters
EventEmitter.call(this);
// initialization goes here
// ...
};
// copy base prototype
@extrabacon
extrabacon / fix-node-installation-permissions.sh
Last active October 22, 2015 12:17
Node installation permissions
sudo chown -R $USER /usr/local
@extrabacon
extrabacon / browser.jshintrc
Last active August 29, 2015 13:57
.jshintrc for node, mocha and the browser
{
"predef": [],
"browser": true,
"devel": true,
"expr": true
}
@extrabacon
extrabacon / resize.sh
Last active August 29, 2015 13:57
Batch resize images with ImageMagick
mogrify -resize 800x800\> *.*
@extrabacon
extrabacon / flattenArray.js
Created March 5, 2014 20:33
Flattening an array
function flattenArray(array) {
var results = [];
var self = arguments.callee;
array.forEach(function(item) {
Array.prototype.push.apply(results, Array.isArray(item) ? self(item) : [item]);
});
return results;
}