Skip to content

Instantly share code, notes, and snippets.

View JuniorPolegato's full-sized avatar

Junior Polegato JuniorPolegato

View GitHub Profile
@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
# include <stdio.h>
int main(int argc, char* argv[]){
char a = 1 << 7;
unsigned char b = 2 * (a - 1) + 1;
short int c = 1 << 15;
unsigned short int d = 2 * (c - 1) + 1;
long int e = 1L << 31;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def crc32(string):
crctab = []
for table in range(256):
crc = table << 24
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import threading
import time
# Máximo de conexões/threads simultâneas
MAX_CONEXOES = 30
# Função para imprimir uma linha por vez via lock
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import threading
import time
import sys,os
import subprocess
# Máximo de conexões/threads simultâneas
MAX_CONEXOES = 30
#!/usr/bin/env python
# -*- coding: utf-8 -*-
with open("/tmp/nomes.txt", "r+") as arquivo:
c = arquivo.read(1)
while c:
while c and c not in ("\r", "\n"):
c = arquivo.read(1)
if c:
arquivo.seek(-1, 1) # volta uma posição
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import signal
continuar = True
sinais = dict((signal.__dict__[sinal], sinal) for sinal in dir(signal)
if sinal.startswith("SIG"))
# -*- coding: utf-8 -*-
from __future__ import print_function
ciclos = int(input("Digite o número de ciclos: "))
import time
t0 = time.time()
base = [1, 5, 11, 13, 17, 19, 23, 25, 29, 31, 37, 41]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def perguntar(texto, tipo, igual_a=None, maior_que=None, menor_que=None):
texto += ' ' if texto[-1] in [':', '?'] else ': '
while True:
try:
digitado = tipo(raw_input(texto))
valido = (igual_a is None
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
OPERADORES = (u'√^', '*/', '+-')
RE_OPS = '([\\' + '\\'.join(''.join(OPERADORES)) + '])'
def separar_operandos_e_operadores(expressao):