Skip to content

Instantly share code, notes, and snippets.

View giovaneliberato's full-sized avatar

Giovane Liberato giovaneliberato

View GitHub Profile
@giovaneliberato
giovaneliberato / brainfuck.py
Created May 27, 2013 23:45
Basic brainfuck interpreter written in python
salt = 65
def incr():
compiled[pointer] += 1
def decr():
compiled[pointer] -= 1
def fw():
global pointer
@giovaneliberato
giovaneliberato / globo_puzzle
Last active December 24, 2015 14:09
Globo.com puzzle at Python Brasil 9
#coding: utf-8
numbers = {'1': 'um', '2': 'dois', '3': 'três', '4': 'quatro', '5': 'cinco',
'6': 'seis', '7': 'sete', '8': 'oito', '9': 'nove', '0': 'zero'}
units = ['milhão','milhar', 'centenas', 'dezenas', 'unidades'][::-1]
chars_incidence = {}
def puzzle(n):
fat = 1
@giovaneliberato
giovaneliberato / delete_email.py
Last active December 29, 2023 07:25
Python script to delete emails from a specific sender at gmail
#coding: utf-8
import imaplib
import sys
'''
Simple script that delete emails from a given sender
params:
-username: Gmail username
-pw: gmail pw
-label: If you have a label that holds the emails, specify here
@giovaneliberato
giovaneliberato / matrix_screensaver.sh
Created August 29, 2014 15:31
terminal matrix screensaver
function cmatrix_auto(){
while :
do
read -n 1 -t 100 ch
if [ ! -z "$ch" ]
then
fg
fi
@giovaneliberato
giovaneliberato / alias.sh
Last active August 29, 2015 14:07
aliases.sh
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
alias gts='git status'
alias gcm='git commit -m'
alias gpl='git pull'
alias gps='git pull'
alias gpr='git pull --rebase'
alias gadd='git add'
alias gcp='git cherry-pick'
alias runserver='./gradlew jettyRun'
alias runtests='./gradlew clean build'
angular.forEach($scope.msg_filtradas, function(m){
var url = buscar_todos_pontos_url + m.pk + "/";
$http.get(url).success(function(data){
m.data = data;
})
})
@giovaneliberato
giovaneliberato / slice_json.py
Last active August 29, 2015 14:08
Slice json files in small pieces
import json
with open("erbopencellid.json") as fixtures:
conteudo = json.loads("".join(fixtures.readlines()))
tamanho = len(conteudo)
inicio = 0
range_ = fim = tamanho / 10
for i in range(1, 11):
fname = "erbopencellid%d.json" % i
print fname, inicio, fim
[
{ "keys": ["alt+a"], "command": "toggle_side_bar" },
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["alt+left"], "command": "focus_group", "args": { "group": 0 } },
{ "keys": ["alt+right"], "command": "focus_group", "args": { "group": 1 } },
]
#!/usr/bin/env bash
if [ "$1" == "green" ] ; then
curl -X POST --data-urlencode "payload={\"text\": \"Build is GREEN! Uhuull.\"}" <your-url>
elif [ "$1"== "red" ] ; then
curl -X POST --data-urlencode "payload={\"text\": \"Build is RED!!!\"}" <your-url>
fi
@giovaneliberato
giovaneliberato / multimethod.py
Created September 23, 2015 14:15
python multimethod pattern
# def collide(thing1, thing2):
# if thing1.is_asteroid() and thing2.is_spaceship():
# thing2.destroy()
# elif thing1.is_spaceship() and thing2.is_asteroid():
# thing1.destroy()
# elif thing1.is_spaceship() and thing2.is_spaceship():
# random.choice([thing1, thing2]).desmaterialize()
# elif thing1.is_asteroid() and thing2.is_asteroid():
# universe.boom()
# structured approach