Skip to content

Instantly share code, notes, and snippets.

View lskbr's full-sized avatar

Nilo Menezes lskbr

View GitHub Profile
@lskbr
lskbr / gist:75eca2c0ae1aebc5100347c495efc843
Last active March 15, 2022 16:23 — forked from arthcc/gist:0b92fee0d2d195b37fd7f42b88ad6be5
#Validação de Dados em Python
name = input("Type your Name [At least 4 Characters]: ")
while len(name) <= 2:
name = input("Your name needs to have at least 4 characters, please type your name again: ")
age = int(input("Type here your age: "))
while age < 0 or age > 150:
age = int(input("Your age needs to be between 0 and 150 years: "))
salary = float(input("Type here the value of your salary in USD: "))
while salary <= 0:
@lskbr
lskbr / 5_2.py
Created March 22, 2021 21:22
Troco
cedulas = {
"moeda":[100, 50, 20, 10, 5, 2, 1, 0.5, 0.25, 0.10, 0.05, 0.01],
"tipo":["nota","nota","nota","nota","nota","nota","moeda","moeda","moeda","moeda","moeda"],
}
troco = {}
valor = float(input("Valor: "))
for cedula in cedulas["moeda"]:
c = valor // cedula
valor = valor % cedula
package main
import (
"fmt"
"os"
"time"
"github.com/gdamore/tcell"
)
@lskbr
lskbr / espera5s.py
Created May 1, 2019 09:25
Espera 5s por uma tecla
from datetime import datetime
from colorconsole import terminal
from time import sleep
segundos = 5
screen = terminal.get_terminal(conEmu=False)
try:
screen.enable_unbuffered_input_mode()
print(f"Digite algo para continuar ou em {segundos} s ativará sozinho")
@lskbr
lskbr / xliff_reader_to_tmx.py
Created April 2, 2019 18:49
Version with AWS
import os
import re
import boto3
import json
from bs4 import BeautifulSoup
from lxml import etree
from functools import lru_cache
@lskbr
lskbr / xliff_reader.py
Created April 1, 2019 18:32
Draft to export xliff to AWS translate than tmx
# Requires Python +3.6
# pip install bs4 boto3 lxml
from bs4 import BeautifulSoup
from lxml import etree
FILE = "omegat - Copy.xlf"
SRC_LANG = "PT-BR"
DST_LANG = "FR-BE"
@lskbr
lskbr / xliff_export.groovy
Created April 1, 2019 17:40
Small fix to be compatible with latest changes on OmegaT
/*
* @author: Kos Ivantsov
* @date: 2014-01-16
* @version: 0.6
* Original source: https://libretraduko.wordpress.com/2014/01/16/convert-omegat-project-to-xliff-for-other-cat-tools/
* Changed by: Nilo Menezes based on comments found at: https://groups.yahoo.com/neo/groups/OmegaT/conversations/messages/36979?guccounter=1&guce_referrer=aHR0cHM6Ly93d3cucHJvei5jb20vZm9ydW0vb21lZ2F0X3N1cHBvcnQvMjk1Njk3LXNjcmlwdGluZ19lcnJvcl93cml0ZV9ub3Rlc2dyb292eS5odG1sP3ByaW50PTE&guce_referrer_sig=AQAAACDZGXME9vTwjAuMHaM7j3K0FEPwQrvNY_LsWUBToTf6SFPwBzx9MSTH7iqrgsLmAtpPdtImfYEwM3fBuxiPBQcHakGJ87H1xbk_9UWYO0KrQeQXjQD0IsaR-0t6vXk6VPJJS2d6Ln_fgRptS2qozN9VM34PzhQZM51-jYSsdbrM
*/
/* set to true to write a settings file for Okapi Rainbow that can be
* used to convert the XLF file produced by this script, to TMX
@lskbr
lskbr / boxes.c
Created February 24, 2019 13:52
Desenha bordas com caracteres utf-8
#include <stdio.h>
#include <stdio.h>
#include <utf8proc.h>
#include <string.h>
// 012345678911
char borda_simples[] = {u8"┌─┐│ │└─┘abc"};
// 03691112222
// 2581234
@lskbr
lskbr / main.rs
Last active March 30, 2022 15:37
Inkey function
extern crate epoll;
extern crate libc;
extern crate termion;
use std::io;
use std::io::{Read, Write};
use std::os::unix::io::AsRawFd;
use termion::raw::IntoRawMode;
/// Waits for a key press timeout milisseconds
@lskbr
lskbr / tempo.py
Created March 15, 2017 12:01
Exemplo de uso da API do OpenWeatherMap
import requests
import sys
# Pegue sua chave aqui: http://openweathermap.org
CHAVE = "SUA_CHAVE_AQUI"
URL = "http://api.openweathermap.org/data/2.5/weather"
CIDADE = "Manaus"
PAIS = "br"