Skip to content

Instantly share code, notes, and snippets.

View zokis's full-sized avatar

Marcelo Fonseca Tambalo zokis

View GitHub Profile
@zokis
zokis / ed.py
Last active September 17, 2021 16:18
ed
with open('ed.txt', 'r') as f: # abre o arquivo de oriem
with open('ed_out.txt', 'w') as fo: # abre o arquivo de saida
for n, linha in enumerate(f.readlines(), 1): # itera nas linhas adicionando o numero da lina
if n % 2 == 0: # se a linha for par o final é nova linha
end = '\n'
else: # se for impar é um tab
end = '\t'
out_line = linha.replace('\n', '') # tira a nova linha das linhas lidas no arquivo de entrada
@zokis
zokis / choices.py
Last active April 5, 2019 18:05
Exemplo de padrão de Choices para Django
# Modelo
class ProjetoPagamento(models.Model):
class TIPOS_PAGAMENTOS(object):
PANTIO = 1
MANUTENCAO = 2
PLANTIO_ADICIONAL = 3
MANUTENCAO_ADICIONAL = 4
CHOICES = (
(PANTIO, 'Plantio'),
print ('____________________________________________________________________')
print ('Olá, bem vindo ao assistente controlador de estoque')
print ('Insira os dados solicitados para realizar a contagem diária de peças')
print ('____________________________________________________________________')
pecas = [
{'name': 'Tela iPhone 6 Branco', 'qtd': 5},
{'name': 'Tela iPhone 6 Preto', 'qtd': 5},
{'name': 'Baterias iPhone 6', 'qtd': 5},
@zokis
zokis / speed_test_csv.py
Created March 8, 2017 16:54
Runs an internet speed test every 1 hour; Throws the result into a csv file named speedtest_result.csv
# coding: utf-8
# pip install speedtest-cli
import subprocess
import time
def main():
c = 0
# coding: utf-8
import codecs
import csv
import cStringIO
import zipfile
from tempfile import NamedTemporaryFile
def force_text(s, encoding='utf-8', errors='strict'):
cd app/migrations/
find ./ -name "0*.py" -exec rm -rf {} \;
# cd to manage.py
python manage.py makemigrations app
# rodar no postgresql "DELETE from django_migrations WHERE app = app"
python manage.py migrate app --fake
@zokis
zokis / pentragram.py
Created April 15, 2016 20:29
pentragram
__ = __import__((lambda f, n: f(f, n))(lambda f, n: chr(n % ((lambda _, ________: (_ << ________))((+True), (((((True << True)) * ((((~~True)) + ((-~True)))))) + ((((~~True)) + ((-~False)))))))) + f(f, n // (lambda _, ________: (_ << ________))((~~True), (((((((-~-~False)) * ((((True << False)) + ((-~True)))))) + ((((((-~-~False)) + ((((~~True)) + ((True << False)))))) - ((True << False)))))) - ((~~True))))) if n else "", (lambda _, __, ___, _____, _______: (((((___ << __) + _) << __) - _) << ((_____ << ___) + _)) - ((((((_ << ___) + _)) << __) + _) << ((_ << _____) + (_ << _))) + (((_______ << __) + _) << ((((___ << __) + _) << _))) + (((_______ << __) + _) << (((((_ << ___) + _)) << _))) - (((___ << ___) + _) << ((___ << __))) + ((((___ << __) - _)) << _______) - (___ << __))((~~True), (-~-~False), (((((~False * ~True)) * ((True + True)))) - ((True << False))), ((((((-~False)) + ((~False * ~True)))) * ((True + True))) - ((+True))), ((((-~-~False)) * ((((((-~-~False)) + ((-~-~False)))) - ((-~False))))) + ((+
{
"poligonos": [
{
"type": "str",
"id": "localizacao",
"label": ""
},
{
"type": "str",
"id": "entorno",
#!/usr/bin/python
# -*- coding: utf-8 -*-
import facebook
import requests
import json
my_token = 'tkn'
graph = facebook.GraphAPI(access_token=my_token)