Skip to content

Instantly share code, notes, and snippets.

View henriquebastos's full-sized avatar
😏

Henrique Bastos henriquebastos

😏
View GitHub Profile
from itertools import zip_longest
class Bits(bytes):
CHUNK = 8
def __new__(cls, n):
return super().__new__(cls, cls.number_to_bits(n))
@staticmethod
"""Geometry"""
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __eq__(self, other):
return self.x == other.x and self.y == other.y
"""
13. wordcount
Este desafio é um programa que conta palavras de um arquivo qualquer de duas
formas diferentes.
A. Lista todas as palavras por ordem alfabética indicando suas ocorrências.
Ou seja...
"""
01. donuts
Dado um contador inteiro do numero de donuts, retorne uma string
com o formato 'Number of donuts: <count>' onde <count> é o numero
recebido. Entretanto, se o contador for 10 ou mais, use a palavra 'many'
ao invés do contador.
Exemplo: donuts(5) retorna 'Number of donuts: 5'
e donuts(23) retorna 'Number of donuts: many'
"""
@henriquebastos
henriquebastos / Fatorial em Python com 1 linha.ipynb
Last active January 28, 2020 18:10
Assine meu canal no youtube e me envie sugestões de novos exercícios: http://hbn.link/youtube_HB
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@henriquebastos
henriquebastos / dynamicvalidator.gs
Created July 26, 2019 02:05
Dynamic Validator by Reference for Google Spreadsheets
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 June 27, 2019 18:07
Google Spreadsheet Data Validation by Reference
/* 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
Last active March 27, 2023 19:23
The definitive guide to setup my Python workspace
# The definitive guide to setup my Python workspace
# Author: Henrique Bastos <henrique@bastos.net>
# Updated: 2022-07-14 for reference.
PY3=3.10.4
PY3TOOLS="youtube-dl s3cmd fabric pytest poetry requests"
VENVS=~/.ve
PROJS=~/workspace
#!/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
asd
asd
asd
asd
asd
asd