Skip to content

Instantly share code, notes, and snippets.

View jfromaniello's full-sized avatar
😀
coding

José F. Romaniello jfromaniello

😀
coding
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jfromaniello on github.
  • I am jose (https://keybase.io/jose) on keybase.
  • I have a public key whose fingerprint is E084 A19D 285D C71D D8C2 1E56 FD13 B550 5327 DB0E

To claim this, I am signing this object:

function onlyStatic (middleware) {
return function (req, res, next) {
var match = /(\.css|\.eot|\.gif|\.html|\.js|\.png|\.svg|\.ttf|\.woff|\.jpg)($|\?.*$)/ig.exec(req.originalUrl);
if (!match) return next();
middleware(req, res, next);
};
}
//usage
this.use(onlyStatic(express.static(__dirname + "/public")));
app.get('/foo', function (req, res) {
var proxy = request.get('https://foo.bar/blah');
//intercept the response:
proxy.pipefilter = function (response, dest) {
console.log('The statusCode was: ', response.statusCode);
};
proxy.pipe(res);
});
//very very bad:
app.use(express.cookieParser())
app.use(express.session({ secret: 'keyboard cat', key: 'sid', cookie: { secure: true }, store: blabla}))
app.use(express.static(__dirname + '/public'));
//good:
app.use(express.static(__dirname + '/public'));
app.use(express.cookieParser())
var foo = {
a: {
b: {
c: 456
}
}
};
function getProp(obj, path) {
return path.split('.').reduce(function (prev, curr) {
@jfromaniello
jfromaniello / install-phantom-ubuntu.sh
Last active August 29, 2015 14:05
Install phantom in ubuntu
#!/usr/bin/env bash
set -e
PHANTOM_FILE=phantomjs-1.9.7-linux-x86_64
cd /usr/local/share
curl -Lo $PHANTOM_FILE.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_FILE.tar.bz2
@jfromaniello
jfromaniello / README.md
Last active August 29, 2015 14:14
Turn internet on and off on ubuntu.

INSTALL

sudo curl -o /usr/local/bin/internet-off \
  https://gist.githubusercontent.com/jfromaniello/9d2b0383feed978afdb4/raw/internet-off

sudo chmod +x /usr/local/bin/internet-off

USAGE

# Description:
# Show an image of a sad panda everytime someone use `@channel` to notify every user on a channel.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
if (!Object.keys) {
Object.keys = (function() {
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',