Skip to content

Instantly share code, notes, and snippets.

View vdel26's full-sized avatar

Victor Delgado vdel26

View GitHub Profile
@vdel26
vdel26 / oauthtools
Last active December 21, 2015 01:48
OAuth tooling
OAuth tool - https://www.runscope.com/oauth_tool
Request bin - http://requestb.in/
FOAuth (OAuth for one) - https://foauth.org/
Google OAuth playground - https://developers.google.com/oauthplayground/
OAuth.io - https://oauth.io/
HTTPbin - http://httpbin.org/
@vdel26
vdel26 / public-ami-cleaner
Last active December 21, 2015 20:58
Clean instance before pubslihing custom AMI
# erase bash history
find /root/.*history /home/*/.*history -exec rm -f {} \;
# erase ssh authorized keys
find / -name "authorized_keys" –exec rm –f {} \;
sudo rm /etc/ssg/ssh_host_dsa_key* /etc/ssh/ssh_host_rsa_key* /etc/ssh/ssh_host_key* /etc/ssh/ssh_host_ecdsa_key*
# disable root and ubuntu user password
sudo passwd -l root
@vdel26
vdel26 / debug_server.py
Created September 26, 2013 14:55
Simple webserver for debugging HTTP requests
import SimpleHTTPServer
import SocketServer
import logging
PORT = 80
class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
logging.error(self.headers)
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
@vdel26
vdel26 / learn.lua
Created October 25, 2013 09:12 — forked from tylerneylon/learn.lua
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@vdel26
vdel26 / xml&json pretty print
Created October 28, 2013 15:35
XML and JSON command line pretty printing
# XML (requires libxml2)
echo '<root><foo a="b">lorem</foo><bar value="ipsum" /></root>' | xmllint --format -
# JSON (requires python)
echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool
@vdel26
vdel26 / simple_server.js
Last active August 29, 2015 13:55
simple node.js debugging server
/*
* dummy API that returns the endpoint that was called
* and the apikey in JSON format
*/
var http = require('http');
var server = http.createServer(function (req, res) {
var responseContent = {};
res.writeHead(200, {'Content-type': 'application/json'});
@vdel26
vdel26 / nginx
Last active March 16, 2023 20:31
Openresty init.d script
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
@vdel26
vdel26 / nginx_basicauth.lua
Last active November 13, 2022 18:22
Extracting Basic Auth token
--[[
Authorization logic
]]--
function get_auth_params(where, method)
local params = {}
if where == "headers" then
params = ngx.req.get_headers()
elseif where == "basicauth" then
@vdel26
vdel26 / aws-metadata
Created March 10, 2014 16:57
AWS metadata from within the instance
# curl -s http://169.254.169.254/latest/meta-data/
ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
hostname
instance-action
instance-id
instance-type
kernel-id
@vdel26
vdel26 / Makefile
Last active May 19, 2016 16:44
Makefile for working with a remote Nginx
#### SETTINGS
NGINXDIR = /usr/local/openresty/nginx/
NGXCONF = nginx_dummycustomer.conf
USER = ubuntu
REMOTE = ec2-54-224-138-186.compute-1.amazonaws.com
REMOTEDIR = /home/$(USER)/dummycustomer/
PRIVATEKEY = /Users/victordg/.ssh/aws/vdg-3scale.pem
####