Skip to content

Instantly share code, notes, and snippets.

@biazzotto
biazzotto / starwars.py
Created July 5, 2016 01:44 — forked from stestagg/starwars.py
micropython starwars
import gc
import machine
import pyb
import time
import network
# Configure GPIO pins 0 and 2 to be used for
# the I²C interface
iic = machine.I2C(pyb.Pin(2), pyb.Pin(0))
@biazzotto
biazzotto / Pense-Bem-Songs.pde
Created July 22, 2016 14:13 — forked from thiagoalz/Pense-Bem-Songs.pde
Arduino file to play Pense-Bem songs
/*
Welcome: 'egage',
GameSelected: 'CgC',
Correct: 'gCC',
Wrong: 'ec',
Fail: 'egec',
Winner: 'gggeCCC',
HighBeep: 'C',
LowBeep: 'c'
@biazzotto
biazzotto / validar_renavam.py
Last active February 3, 2017 10:42
Função para validar sequência de dígitos do Renavam
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Função para validar sequência de dígitos do Renavam.
# Adaptado por Fabricio Biazzotto, a partir do original, feito em java:
# http://blog.victorjabur.com/2010/05/28/renavam_veiculos_java
def validar_renavam(renavam):
# Retorna falso caso o valor passado não seja um número inteiro
@biazzotto
biazzotto / export_guetzli.py
Last active July 30, 2018 17:53
GIMP Plugin that allows exporting as JPEG using the Google Guetzli
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from gimpfu import *
from os import remove, name
from os.path import basename
from tempfile import NamedTemporaryFile
from subprocess import check_output, CalledProcessError, STDOUT
# Export with Google Guetzli Perceptual JPEG encoder
@biazzotto
biazzotto / gist:3fe82a7a8f3fa88c0011e4d423ec594b
Created September 15, 2017 12:41 — forked from marcelograciolli/gist:902018b4464d4c1cc29d
Como criar uma assinatura de e-mail HTML - Graciolli Dotcom
<style type="text/css">
TD {margin: 0px;padding: 0px;}
IMG {margin: 0px;padding: 0px;}
A.headline {TEXT-DECORATION: none;margin:;}
A.headline:link {TEXT-DECORATION: none;}
A.headline:visited {TEXT-DECORATION: none}
A.headline:hover {TEXT-DECORATION: underline;}
A: {margin: 0px;padding: 0px;}
</style>
@biazzotto
biazzotto / python-telegram-api-is-started.py
Created June 27, 2018 13:31 — forked from voider1/python-telegram-api-is-started.py
A decorator for python-telegram-bot API, makes sure a command is only executed when the bot's state is started!
from functools import wraps
from telegram.ext import Updater, CommandHandler
# Using a factory function (closures) to contain the started-state of the bot
# This is cleaner and better-practice than using globals
def state_factory():
"""Factory function for containing the bot state."""
state = False
@biazzotto
biazzotto / install_font_adobe_source_code_pro.sh
Created June 28, 2018 18:05 — forked from enzinier/install_font_adobe_source_code_pro.sh
Install font Adobe Source Code Pro on Ubuntu 16.04 LTS
#!/bin/sh
# Userland mode (~$USER/), (~/).
# ~/.fonts is now deprecated and that
#FONT_HOME=~/.fonts
# ~/.local/share/fonts should be used instead
FONT_HOME=~/.local/share/fonts
echo "installing fonts at $PWD to $FONT_HOME"
mkdir -p "$FONT_HOME/adobe-fonts/source-code-pro"
@biazzotto
biazzotto / rot.py
Created August 28, 2018 18:40 — forked from cincodenada/rot.py
Quick binary rotation (rotl/rotr) in Python
def rotl(num, bits):
bit = num & (1 << (bits-1))
num <<= 1
if(bit):
num |= 1
num &= (2**bits-1)
return num
def rotr(num, bits):
@biazzotto
biazzotto / esp32-oled-demo.py
Created September 7, 2018 17:35 — forked from laurivosandi/esp32-oled-demo.py
OLED screen demo on ESP32 with MicroPython
# Pull the SDD1306 lib from here https://github.com/adafruit/micropython-adafruit-ssd1306/blob/master/ssd1306.py
from time import sleep_ms
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
buf = "wubba lubba dub dub "
i2c = I2C(-1, Pin(4),Pin(5),freq=40000) # Bitbanged I2C bus
assert 60 in i2c.scan(), "No OLED display detected!"
@biazzotto
biazzotto / HowToOTG.md
Created June 15, 2019 15:46 — forked from gbaman/HowToOTG.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int