Skip to content

Instantly share code, notes, and snippets.

View lxfontes's full-sized avatar
🌋

Lucas Fontes lxfontes

🌋
View GitHub Profile
@lxfontes
lxfontes / resignation.rb
Created April 13, 2012 06:04
Resignation Letter
class Resignation
attr_accessor :name,:date,:kind_note,:reason_array,:signoff
def initialize(employee_name,end_date)
@name=employee_name
@date=end_date
@kind_note = "With great sorrow"
end
def random_reasons(reasons)
@reason_array=Array(reasons)
end
@lxfontes
lxfontes / sortable.py
Created July 12, 2012 02:26
sortable coding challenge
#!/usr/bin/env python
# coding=utf-8
# starting point for those looking to apply @ sortable
# http://sortable.com/blog/coding-challenge/
# not so bad for 15 mins of coding
# pass in listings.txt products.txt
# say Hi to Mark for me ;)
import json
@lxfontes
lxfontes / gist:3268565
Created August 6, 2012 00:43
pluralize
def pluralize(name, lang='en'):
rules = {
'en': [
('[sxz]$' , '$' , 'es') ,
('[^aeioudgkprt]h$' , '$' , 'es') ,
('[^aeiou]y$' , 'y$' , 'ies') ,
('$' , '$' , 's')
]
}
m = rules[lang]
@lxfontes
lxfontes / bruce_buffer.rb
Created July 23, 2013 02:57
easiest tts api ever.
require 'sinatra'
require 'tempfile'
post '/tts' do
text = params[:q] || ""
file = Tempfile.new("tts")
file.write(text)
file.close
IO.popen("swift -n Callie -o - #{file.path}", "r") do |io|
response.write(io.read)
@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
@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 / 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 / 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'
#!/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

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: