Skip to content

Instantly share code, notes, and snippets.

View BrunoBernardino's full-sized avatar

Bruno Bernardino BrunoBernardino

View GitHub Profile
@BrunoBernardino
BrunoBernardino / session.js
Last active November 13, 2017 17:37
Webtask for session auth.
module.exports = function(context, cb) {
if (context.body) {
if (!context.body.email || !context.body.pass) {
return cb(401, 'Unauthorized');
}
} else if (!context.headers['x-token']) {
return cb(403, 'Forbidden');
}
const now = new Date();
@BrunoBernardino
BrunoBernardino / api-query.js
Created October 17, 2017 09:24
Webtask for api-query auth
module.exports = function(context, cb) {
if (!context.query.apiKey) {
return cb(401, 'Unauthorized');
}
cb(null, {
authenticated: true,
user: 'Zapier',
});
};
@BrunoBernardino
BrunoBernardino / api-header.js
Last active November 13, 2017 17:37
Webtask for api-header auth.
module.exports = function(context, cb) {
if (!context.headers['x-api-key']) {
return cb(401, 'Unauthorized');
}
cb(null, {
authenticated: true,
user: 'user',
});
};
@BrunoBernardino
BrunoBernardino / code.js
Created December 3, 2016 14:05
AWS Lambda Redirect code
'use strict';
const finish = (cb, url) => {
console.log('Sending to', url);
cb(null, {url: url});
}
exports.handler = (event, context, callback) => {
const defaultURL = 'http://example.com';
@BrunoBernardino
BrunoBernardino / keybase.md
Last active August 22, 2018 08:05
keybase.md

Keybase proof

I hereby claim:

  • I am brunobernardino on github.
  • I am brunobernardino (https://keybase.io/brunobernardino) on keybase.
  • I have a public key ASCV1iwLOfJXJPpHapEKwT9wF5v5hjoWwTG4KXAr35uC5go

To claim this, I am signing this object:

@BrunoBernardino
BrunoBernardino / breakVisualCaptcha.js
Created August 15, 2013 20:06
This is code based off of https://gist.github.com/ipeychev/6234050, refactored to be possible to make multiple attempts in one execution. 100 attempts are equivalent to 500 post requests (every "attempt" tries to post 5 images). I'm actually getting < 5-7% successful break attempt rates, but it's still unnacceptable and I'll use this code to che…
// This code has a break rate of < 10%. It's still unnacceptable, though.
var request = require( 'request' ).defaults( { jar: true } ),
q = require( 'q' );
var URI = 'http://demo.visualcaptcha.net/';
// Make a post
var makePost = function makePost( imgHash, partialURL, tryNumber ) {
var deferred = q.defer(),