Skip to content

Instantly share code, notes, and snippets.

@jaysonsantos
jaysonsantos / quiz.py
Created August 10, 2011 14:23
Google developer quiz solver
# Google tricked us a bit, some logic is different, just check it
import sys
WORDS_A = open(sys.argv[1]).read().strip('\n').split(' ')
WORDS_B = open(sys.argv[2]).read().strip('\n').split(' ')
FOO_LETTERS = tuple('csmgj')
BLACKLIST = 'f'
ALPHABET_ORDER = tuple('cfjvqmhldtkrzwnbgxsp')
MAPPED_ORDER = tuple('0123456789abcdefghij')
@jaysonsantos
jaysonsantos / uwsgi.ini
Created October 31, 2011 13:39
uWSGI INI sample
[uwsgi]
touch-reload=/diretorio/projeto/tmp/restart.txt # Usado para que o uWSGI recarrege o seu fonte com um simples touch restart.txt
listen=1024 # Número de itens em fila de espera
disable-logging=true # Deixa de logar requisições, fará log apenas de erros.
socket=/diretorio/que/voce/quiser.sock # Caminho do socket que o uWSGI ouvirá/escreverá.
master=true # Ativa o processo master para controlar os rebeldes.
harakiri=60 # Modo suicida que matará a app após x segundos em execução.
processes=4 # Número de workers.
buffer-size=25000 # Buffer mais alto porque muitas vezes alguns browsers mandam headers gigantes.
daemonize=/diretorio/que/voce/quiser.log # Joga o processo para background e escreve o log no arquivo determinado.
#!/bin/bash
sudo memcached stop
memcached -S -d
memached -s/tmp/memached.sock -d
memached -p5000 -d
nosetests
exit $?
@jaysonsantos
jaysonsantos / mysql-ram.sh
Created July 10, 2012 20:26
MySQL in ram with ubuntu
#!/bin/bash
function quit {
echo "Umounting temp"
cd /
umount /media/tmp
}
trap quit SIGINT
@jaysonsantos
jaysonsantos / lazy.sh
Created May 17, 2013 13:25
Create a git flow hotfix with last tag + 1.
alias gh="git fetch; git checkout master; git merge origin/master; git checkout develop; git merge origin/develop; git flow hotfix start \$(git tag|sort -V|grep '^[0-9]'|tail -n 1|awk 'BEGIN { FS = \".\" } ; { print \$1\".\"\$2\".\"\$3+1 }')"
data <- read.csv2('d_sabesp.csv', colClasses=c('character', 'character', 'character', rep('numeric', 4)))
data$data = as.Date(strptime(data$data, '%Y-%m-%d'))
plot(data$data, data$media_historica_do_mes)

Keybase proof

I hereby claim:

  • I am jaysonsantos on github.
  • I am jaysonsantos (https://keybase.io/jaysonsantos) on keybase.
  • I have a public key whose fingerprint is CCA0 2976 DD0B DE62 3BDE 1689 32CA A472 083D 88E2

To claim this, I am signing this object:

@jaysonsantos
jaysonsantos / analyser.py
Last active October 8, 2015 16:41
Analyses a organization to find all python projects and it's requirements
import asyncio
import base64
import concurrent.futures
from functools import partial
import os
import pip
import re
import requests
@jaysonsantos
jaysonsantos / verify.sh
Created March 21, 2015 18:40
List only outdated pip packages that exists in local requirements
#!/bin/bash
pip list -o|while read i; do
pkg_name="$(echo $i | awk '{print $1}')"
grep -rin "$pkg_name" requirements/ &> /dev/null
if [ "$?" -eq "0" ]; then
echo $i
fi
done
@jaysonsantos
jaysonsantos / buergerbot.py
Created June 11, 2015 13:34
bürgeramt bot
import subprocess
import time
import bs4
import requests
url = 'http://service.berlin.de/terminvereinbarung/termin/tag.php?termin=1&dienstleister%5B%5D=122210&dienstleister%5B%5D=122217&dienstleister%5B%5D=122219&dienstleister%5B%5D=122227&dienstleister%5B%5D=122231&dienstleister%5B%5D=122238&dienstleister%5B%5D=122243&dienstleister%5B%5D=122252&dienstleister%5B%5D=122260&dienstleister%5B%5D=122262&dienstleister%5B%5D=122254&dienstleister%5B%5D=122271&dienstleister%5B%5D=122273&dienstleister%5B%5D=122277&dienstleister%5B%5D=122280&dienstleister%5B%5D=122282&dienstleister%5B%5D=122284&dienstleister%5B%5D=122291&dienstleister%5B%5D=122285&dienstleister%5B%5D=122286&dienstleister%5B%5D=122296&dienstleister%5B%5D=150230&dienstleister%5B%5D=122301&dienstleister%5B%5D=122297&dienstleister%5B%5D=122294&dienstleister%5B%5D=122312&dienstleister%5B%5D=122314&dienstleister%5B%5D=122304&dienstleister%5B%5D=122311&dienstleister%5B%5D=122309&dienstleister%5B%5D=317869&dienstleister%5B%5D=324433&dienstleister%5B%5D=325341