Skip to content

Instantly share code, notes, and snippets.

@noelrocha
noelrocha / lambda-edge-basic-auth.js
Last active January 31, 2018 13:22
lambda-edge-basic-authentication
'use strict';
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
const headers = request.headers;
const authUser = 'USERNAME';
const authPass = 'PASSWORD';
const authString = 'Basic ' + new Buffer(authUser + ':' + authPass).toString('base64');
@noelrocha
noelrocha / python server
Created June 8, 2017 16:46
python server loggin headers
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
import logging
PORT = 8000
class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
@noelrocha
noelrocha / open_app.html
Created March 16, 2015 18:28
Open app on Google Play or AppStore
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Open App</title>
<!--
URL Params:
customSchemeURL: Your custom scheme app
@noelrocha
noelrocha / gist:76fb56ff7b8e57eb49b6
Created March 16, 2015 18:28
Open app on Google Play or AppStore
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Open App</title>
<!--
URL Params:
customSchemeURL: Your custom scheme app
@noelrocha
noelrocha / Poller.coffee
Created April 9, 2013 21:30
Abstract Poller in coffee script
class Poller
constructor: (name) ->
console.log "[#{name}]"
@name = name
@failed = 0
@interval = 5000
@run = true
timeoutID = null
@noelrocha
noelrocha / export_mysql_privileges.sh
Created December 19, 2011 22:57
export MYSQL privileges
mysql -u [USER] -p[PASSWORD] -B -N $@ -e "SELECT DISTINCT CONCAT(
'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
) AS query FROM mysql.user" | \
mysql -u [USER] -p[PASSWORD] $@ | \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'