Skip to content

Instantly share code, notes, and snippets.

View JuniorPolegato's full-sized avatar

Junior Polegato JuniorPolegato

View GitHub Profile
@JuniorPolegato
JuniorPolegato / pesquisa_opiniao.py
Created December 2, 2012 23:42
Projeto em Python + PyGTK para pesquisa de opinião por notas de 1 a 5 em botões
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pygtk
pygtk.require("2.0")
import gtk
import glib
class Projeto(gtk.Window):
def __init__(self):
@JuniorPolegato
JuniorPolegato / debian_packages.py
Created May 29, 2013 16:07
This program gets a list of packages from repositories files in /var/lib/apt/lists and a list of installed packages. Then, list the packages/versions which not in files with stable in your name.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Author: Junior Polegato
Date: 29 May 2013
Description: This program gets a list of packages from repositories
files in /var/lib/apt/lists and a list of installed
packages. Then, list the packages/versions which not in
files with stable in your name.
'''
@JuniorPolegato
JuniorPolegato / select_input.py
Created June 13, 2013 21:05
Input with filter by type and characters with Python in a Linux terminal
#!/bin/env python
# -*- coding: utf-8 -*-
# Author.....: Junior Polegato
# Date.......: 13 Jun 2013
# Description: Input with filter by type and characters with
# Python in a Linux terminal
import sys, tty, termios
import locale
@JuniorPolegato
JuniorPolegato / losango.py
Last active December 24, 2015 02:09
Gerar um losango dado um caracter e uma altura ímpar.
#!/usr/bin/env python
import sys
ESPACO = ' '
caracter = raw_input("Caracter: ")[0]
altura = int(raw_input("Altura (ímpar maior ou igual a 3): "))
if altura < 3 or altura % 2 == 0:
@JuniorPolegato
JuniorPolegato / caixa_eletronico.py
Last active May 29, 2020 02:46
Mostra as possibilidades de saque em caixa eletrônico dado as notas disponíveis e perguntado um valor.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
class SemCaixa(Exception):
pass
# Lista com valor da nota e quantidade disponível no caixa
caixa = {50: 10, 20: 10, 10: 10, 5: 10}
@JuniorPolegato
JuniorPolegato / caixa_eletronico_simples.py
Created April 1, 2014 12:34
Algoritmo simples para caixa eletrônico
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
# quantidade de notas de 50 disponível em notas_50_disponiveis
notas_50_disponiveis = 10
# quantidade de notas de 20 disponível em notas_20_disponiveis
notas_20_disponiveis = 10
@JuniorPolegato
JuniorPolegato / calcular_formula.py
Last active May 29, 2020 02:46
Exemplo de script para se calcular qualquer fórmula, exemplo com juros compostos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import re
# dado um título e lista de listas no formato
# ('<variável>', '<tipo>', '<descricao>', '<fórmula>')
# pede-se qual variável calcular, pede os valores e dá o resultado
# qualquer valor vazio saida da função
@JuniorPolegato
JuniorPolegato / inteiro.py
Created April 16, 2014 12:07
Pedir por uma quantidade de número inteiros entre valores definidos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
MIN = 0
MAX = 255
MAX_ERROS = 3
QTD = 4
def pedir_inteiro(min, max, max_erros):
erros = 0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pole
import re
import urllib2
import os
conexao = pole.http.Conexao('www.receita.fazenda.gov.br')
dados = conexao.obter_dados('/aplicacoes/atcta/cpf/ConsultaPublica.asp')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# PyGTK 3 é incompatível com Pole
try:
# Caso tiver PyGTK 2
import pygtk
pygtk.require("2.0")
import gtk
PixbufLoader = gtk.gdk.PixbufLoader