Skip to content

Instantly share code, notes, and snippets.

View JuniorPolegato's full-sized avatar

Junior Polegato JuniorPolegato

View GitHub Profile
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import gi
import cairo
import datetime
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GLib
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import gi
import cairo
import datetime
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GLib
@JuniorPolegato
JuniorPolegato / python_crud_temas_historias.py
Last active July 12, 2022 22:14
Adequanto Python-CRUD para duas tabelas (Temas e Histórias)
import json
# CRUD in dict table (create, read, update, delete, save, load)
# table => {<id_1>: {<field_1>: <value_1>, <field_2>: <value_2>, ...}, ...}
# fields => {<field_1>: <type_1>, <field_2>: <type_2>, ...}
# field name `id´ is reserved
def crud_create(table, fields, register=None,
fields_error="Not all fields in register."):
GTK_VER = '2.0'
USE_STOCK = False
# Descomente abaixo para PyGtk 2.0 com Python 2.x e comente o PyGObject
# Aqui usa-se PyGtk e troca-se de "gtk" para "Gtk" "compatibilizando" o código
# import pygtk
# pygtk.require(GTK_VER)
# import gtk as Gtk
# print(Gtk.ver)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import socket
socket.setdefaulttimeout(.1) # Espera 100 milissegundos pela resposta
TRUE = 1 # pode-se retornar True ou 0 (sucesso) se preferir
FALSE = 0 # pode-se retornar False ou 1 (sem sucesso) se preferir
@JuniorPolegato
JuniorPolegato / warsaw_na_jaula_stretch.txt
Created April 3, 2018 12:00
Rodar o warsaw no Debian Buster dentro de uma jaula com Stretch e já abrir o site do Banco do Brasil
# Criar a jaula
mkdir stretch
debootstrap stretch stretch # se tiver apt-cache ou mirror coloque aqui
# Preparar para montar as partições do sistema dentro da jaula
mount |
sed 's/\(.*\) on \(.*\) type \(.*\) .*/mkdir -p \2; mount -t \3 \1 \2/' |
grep -v /dev/sd >> stretch/root/.bashrc
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
try:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
except Exception:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def disputa_round_robin(nomes, fixar_primeiro=True, sentido_horario=True,
com_volta=False, debug=False):
n = len(nomes)
if n % 2 == 1:
n += 1
nomes['~'] = 'Ninguém'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import random
import locale
# Locale para utilizar agrupamento e ponto decimal da localização configurada
locale.setlocale(locale.LC_ALL, '')
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Para substituir caracteres com acentos e outros por equivalente ascii
from unicodedata import normalize
# Caracteres para ocultar em ASCII (minúsculos) e o caracter oculto
OCULTAR = 'aeiou'
C = '*'