Skip to content

Instantly share code, notes, and snippets.

View jfromaniello's full-sized avatar
😀
coding

José F. Romaniello jfromaniello

😀
coding
View GitHub Profile
//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())
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);
});
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")));

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:

@jfromaniello
jfromaniello / bcompare-git.md
Last active April 5, 2024 21:53
Integrate beyond compare 4 with git

Install command line tools:

then run this:

git config --global diff.tool bc3
git config --global difftool.bc3 trustExitCode true
git config --global merge.tool bc3
@jfromaniello
jfromaniello / gist:8418116
Last active September 19, 2023 23:38
Example of authenticating websockets with JWTs.
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({port: 8080});
var jwt = require('jsonwebtoken');
/**
The way I like to work with 'ws' is to convert everything to an event if possible.
**/
function toEvent (message) {
try {
define(function (require) {
var $ = require('jquery');
require('typeahead');
//boo
});
@jfromaniello
jfromaniello / example.js
Created November 9, 2013 21:38
use github from client_side only
var auth0 = new Auth0({
clientID: 'KgSjMN3OCwmrjvtjJ8bfuZyAaoKOrgH3',
domain: 'todos.auth0.com',
callbackURL: 'http://localhost:8080/'
});
$(function () {
var tmpl_text = $('#item-tmpl').html();
var item_tmpl = ejs.compile(tmpl_text);
@jfromaniello
jfromaniello / README.md
Last active December 23, 2015 16:09
Hubot script para mostrar placas rojas de cronica.

Script para Hubot que genera placas rojas de cronica.

Usa la página placasrojas.tv para generar la placa.

La imagen se sube a imgur usando el módulo node-imgur antes de enviarla al chat, ya que HipChat y algunos clientes de IRC necesitan una url que termine en .png/jpg etc.

@jfromaniello
jfromaniello / tmpreaper.pp
Created September 17, 2013 18:46
this is how I setup tmpreaper with puppet
class tmpreaper {
package { "tmpreaper":
ensure => installed,
}
cron { "reaptmp on reboot":
command => "/usr/sbin/tmpreaper -af 1h /tmp",
user => root,
special => "reboot",
require => Package['tmpreaper'],