Skip to content

Instantly share code, notes, and snippets.

View lxfontes's full-sized avatar
🌋

Lucas Fontes lxfontes

🌋
View GitHub Profile
@lxfontes
lxfontes / elasticsearch.nse
Created January 6, 2015 20:59
elasticsearch nmap scanner
--[[
nmap --script ./elasticsearch.nse 192.168.0.0/24 -p 9200,80,8080
PORT STATE SERVICE
9200/tcp open wap-wsp
|_elasticsearch: looks like elasticsearch
--]]
local http = require "http"
@lxfontes
lxfontes / gist:e5ad6526ef4fca32fb89
Last active August 29, 2015 14:11
postgresql daily tables
CREATE LANGUAGE plpgsql;
CREATE TABLE request_logs(
id SERIAL PRIMARY KEY,
ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
ev JSONB
);
CREATE OR REPLACE FUNCTION daily_table_setup(schema_name text,
@lxfontes
lxfontes / gist:8a6ce11a33a1171a9390
Created December 8, 2014 20:16
nginx + consul
server {
server_name titans.local;
location / {
set $target '';
set $upstream_name 'titans_staging_web';
rewrite_by_lua '
local resolver = require "resty.dns.resolver"
local r, err = resolver:new {
nameservers = {{"127.0.0.1", 8600}},
@lxfontes
lxfontes / simpleMorris.js
Created August 17, 2014 02:50
SimpleMorris
'use strict';
angular.module('simpleMorris', []);
var morrisTypes = {
lineChart: Morris.Line,
areaChart: Morris.Area,
barChart: Morris.Bar,
donutChart: Morris.Donut
};

Keybase proof

I hereby claim:

  • I am lxfontes on github.
  • I am lxfontes (https://keybase.io/lxfontes) on keybase.
  • I have a public key whose fingerprint is 6995 5889 131A 12B0 E89B 628F AF16 90E7 1C16 5AB6

To claim this, I am signing this object:

#!/usr/bin/env ruby
require 'digest/sha1'
tree=`cd level1 && git write-tree`.strip
parent=`cd level1 && git rev-parse HEAD`.strip
i = 0
count = 0
while true
@lxfontes
lxfontes / timeit.js
Created December 14, 2013 02:05
browser timing events
(function() {
if(window.chrome) {
setTimeout(function(){
var timing = window.performance.timing;
var pairs = ['connect',
'domContentLoadedEvent',
'loadEvent',
'domainLookup',
'response',
'unloadEvent'
@lxfontes
lxfontes / kill.sql
Created November 26, 2013 14:49
kill idle mysql sessions
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `uKillSleepingSessions`()
READS SQL DATA
COMMENT 'This routne is used to kill idle sessions'
BEGIN
DECLARE no_more_rows BOOLEAN;
DECLARE loop_cntr INT DEFAULT 0;
DECLARE num_rows INT DEFAULT 0;
@lxfontes
lxfontes / gist:6599926
Last active December 23, 2015 07:19
haproxy X-Queue-Start header (new relic)
diff -Naubr haproxy-1.4.24_orig/include/types/proxy.h haproxy-1.4.24/include/types/proxy.h
--- haproxy-1.4.24_orig/include/types/proxy.h 2013-06-17 13:28:14.000000000 +0000
+++ haproxy-1.4.24/include/types/proxy.h 2013-09-17 18:51:58.884894297 +0000
@@ -146,6 +146,7 @@
/* unused: 0x08000000, 0x10000000 */
#define PR_O2_FF_ALWAYS 0x20000000 /* always set x-forwarded-for */
#define PR_O2_NODELAY 0x40000000 /* fully interactive mode, never delay outgoing data */
+#define PR_O2_TAGTIME 0x80000000 /* append X-Queue-Start */
/* end of proxy->options2 */
@lxfontes
lxfontes / orbital_cert.rb
Created July 31, 2013 03:12
Section B for Orbital Paymentech certification. It is a pain to do it manually. gem install activemerchant run with [merchant_id] [username] [password] then just copy / paste results into certification document.
require 'activemerchant'
require 'pp'
# Send requests to the gateway's test servers
ActiveMerchant::Billing::Base.mode = :test
def get_gateway(mid, login, password)
return ActiveMerchant::Billing::OrbitalGateway.new(
:merchant_id => mid,
:login => login,
:password => password