Skip to content

Instantly share code, notes, and snippets.

Henrique Bastos henriquebastos

Block or report user

Report or block henriquebastos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@henriquebastos
henriquebastos / dynamicvalidator.gs
Created Jul 26, 2019
Dynamic Validator by Reference for Google Spreadsheets
View dynamicvalidator.gs
function onEdit(e) {
var rule = e.range.getDataValidation();
if (rule != null) {
var value = e.range.getCell(1,1).getValue();
var criteria = rule.getCriteriaType();
var validationRange = rule.getCriteriaValues()[0];
var i = findInRange(value, validationRange.getValues());
@henriquebastos
henriquebastos / refvalidation.gs
Created Jun 27, 2019
Google Spreadsheet Data Validation by Reference
View refvalidation.gs
/* Google Spreadsheet Data Validation by Reference
Author: Henrique Bastos <henrique@bastos.net>
License: MIT
*/
function onEdit(e) {
var rule = e.range.getDataValidation();
if (rule == null) {
return;
@henriquebastos
henriquebastos / python-guide.sh
Created Jun 24, 2019
The definitive guide to setup my Python workspace
View python-guide.sh
# The definitive guide to setup my Python workspace
# Author: Henrique Bastos <henrique@bastos.net>
PY3=3.7.3
PY2=2.7.16
PY3TOOLS="youtube-dl s3cmd fabric pytest"
PY2TOOLS="rename mercurial"
VENVS=~/.ve
PROJS=~/workspace
View mimic.py
#!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
"""Mimic pyquick exercise -- optional extra exercise.
Google's Python Class
@henriquebastos
henriquebastos / alunos.py
Created Apr 18, 2019
Refatoração do código do David Silveira no Live Coding Jam
View alunos.py
import sys
from collections import namedtuple
from unittest import TestCase, main as runtests
from enum import Enum
from pprint import pprint
Aluno = namedtuple('Aluno', 'nome notas media conceito')
class Conceito(Enum):
View wordcount.py
#!/usr/bin/python -tt
import argparse
import re
from collections import Counter
def read(f):
return re.split(r'\W+', f.read().lower())
def asc(counter):
@henriquebastos
henriquebastos / tudao.py
Created Dec 5, 2017
Esboço para o Antonio
View tudao.py
# models.py
CREDIT = 'C'
DEBIT = 'D'
class CategoryStatementQuerySet(QuerySet):
def credit():
return self.filter(operacao__exact=CREDIT)
def debit():
@henriquebastos
henriquebastos / extenso.py
Created Jun 6, 2017
Exercício muito doido sugerido pelo River
View extenso.py
def decomp(num):
"""decomp(120) == (100, 20)"""
base = 10 ** (len(str(num))-1)
divisor, resto = divmod(num, base)
return divisor * base, resto
def radicais(resto):
while resto > 0:
base, resto = decomp(resto)
@henriquebastos
henriquebastos / fizzbuzz.py
Created Mar 22, 2017
Código do Coding Dojo p/ Calouros do turno da manhã na Unilasalle
View fizzbuzz.py
# coding: utf-8
# Código do Coding Dojo p/ Calouros do turno da manhã na Unilasalle
# 21/03/2017
def robo(num):
msg=num
if num==3:
msg='fizz'
if num==5:
You can’t perform that action at this time.