Skip to content

Instantly share code, notes, and snippets.

View leite's full-sized avatar
🚩

Francisco Leite leite

🚩
View GitHub Profile
@leite
leite / gist:7381796
Created November 9, 2013 04:47
calculates nearest web safe color
/*
* "THE BEER-WARE LICENSE" (Revision 42):
* <[email protected]> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return
*/
var int = parseInt,
sub = String.prototype.substr,
colors = {
@leite
leite / gist:7456968
Created November 13, 2013 21:45
get cookie from sptrans
redis-cli -s /tmp/redis.sock set sptransCookie $(curl -sI olhovivo.sptrans.com.br | tr -d '\r' | sed -En 's/^Set-Cookie: ([^;]*).*$/\1/p')>/dev/null
@leite
leite / gist:7662837
Created November 26, 2013 17:52
simple naval wargame ...
import java.util.Random;
import java.util.Scanner;
/**
*
* @author Allah
*/
public class BatalhaNaval {
public static void main(String[] args) {
@leite
leite / gist:8326589
Last active January 2, 2016 15:58
basic configuration of nginx.conf
user nginx www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
@leite
leite / gist:8374450
Created January 11, 2014 18:06
dead simple sinatra openresty application
local sinatra = require('sinatra');
local app = sinatra.app:new()
app:get("/", function()
return "Hello, World "
end)
app:get("/:name", function()
return "Hello, " .. params.name;
@leite
leite / gist:10679413
Created April 14, 2014 20:14
basic class simulacrum and basic hash object ... enjoy
-- ----------------------------------------------------------------------------
-- "THE BEER-WARE LICENSE" (Revision 42):
-- <[email protected]> wrote this file. As long as you retain this notice you
-- can do whatever you want with this stuff. If we meet some day, and you think
-- this stuff is worth it, you can buy me a beer in return
-- ----------------------------------------------------------------------------
local table, string = require [[table]], require [[string]]
local type, pairs, rawset, setmetatable, getmetatable =
@leite
leite / gist:11382492
Created April 28, 2014 20:02
APR, Apache 2.4 & fcgid
# apr (apache portable runtime)
wget http://ftp.unicamp.br/pub/apache//apr/apr-1.5.1.tar.gz
tar zxf apr-1.5.1.tar.gz
cd apr-1.5.1
sudo ./configure
sudo make -j2 && sudo make install
cd ..
#apr-utils
wget http://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz
@leite
leite / gist:b4ac06ce014684b8e2ea
Created May 8, 2014 20:54
install sphinx with libstemmer
sudo wget http://sphinxsearch.com/files/sphinx-2.1.8-release.tar.gz
sudo tar zxf sphinx-2.1.8-release.tar.gz
sudo wget http://snowball.tartarus.org/dist/libstemmer_c.tgz
sudo tar zxf libstemmer_c.tgz
sudo cp -fa libstemmer_c/* sphinx-2.1.8-release/libstemmer_c/
cd sphinx-2.1.8-release
sudo ./configure --enable-id64 --with-libstemmer
@leite
leite / gist:9236fe3033d5779cdb05
Last active August 29, 2015 14:01
openresty with LuaJIT (Lua 5.2 compatible)
cd /opt
sudo wget http://www.openssl.org/source/openssl-0.9.8y.tar.gz
sudo tar zxf openssl-0.9.8y.tar.gz
sudo wget http://zlib.net/zlib-1.2.8.tar.gz
sudo tar zxf zlib-1.2.8.tar.gz
cd zlib-1.2.8
sudo ./configure
sudo make -j4 && sudo make install && cd ..
@leite
leite / gist:b085ccef34d8b3b082cb
Created June 18, 2014 02:39
parsing accept header(s)
-- @xxleite under [BeerWare] license
local string, io = require [[string]], require [[io]]
local gmatch, format, byte, write = string.gmatch, string.format, string.byte, io.write
-- common accept(s) content
local charsets = {
'*', 'utf-8', 'utf-8, ISO-8859-1', 'utf-8;q=0.8, ISO-8859-1',