Skip to content

Instantly share code, notes, and snippets.

View nelsoncbf's full-sized avatar
:octocat:

Nelson Fonseca nelsoncbf

:octocat:
View GitHub Profile
@nelsoncbf
nelsoncbf / Clipboard.js
Created May 2, 2023 03:25 — forked from rproenca/Clipboard.js
Copy text to clipboard using Javascript. It works on Safari (iOS) and other browsers.
window.Clipboard = (function(window, document, navigator) {
var textArea,
copy;
function isOS() {
return navigator.userAgent.match(/ipad|iphone/i);
}
function createTextArea(text) {
textArea = document.createElement('textArea');
@nelsoncbf
nelsoncbf / expiration.py
Last active September 14, 2022 20:40
set expiration in redis python keys
from apiman.redis import db
from datetime import timedelta
def set_expiration(data):
c = 0
for x in data:
if 'analytics' in x:
db.expire(x, timedelta(minutes=20))
print(f'Implementada expiração em {c} chaves')
@nelsoncbf
nelsoncbf / Estados Brasileiros Python Array WTForms SelectField
Last active October 14, 2020 20:38
Estados Brasileiros Python Array WTForms SelectField
from flask_wtf import FlaskForm
from wtforms.fields import SelectField
def opcoes_UF():
return [
("AC", "Acre"),
("AL", "Alagoas"),
("AP", "Amapá"),
("AM", "Amazonas"),
("BA", "Bahia"),
pacientes_alergias = db.Table('pacientes_alergias',
db.Column('paciente_id', Integer, ForeignKey('paciente.id'), primary_key=True),
db.Column('alergias.id', Integer, ForeignKey('alergias.id'), primary_key=True)
)
pacientes_doencas = db.Table('pacientes_doencas',
db.Column('paciente_id', Integer, ForeignKey('paciente.id'), primary_key=True),
db.Column('doencas.id', Integer, ForeignKey('doencas.id'), primary_key=True)
)
@nelsoncbf
nelsoncbf / supervisor_client.py
Last active May 11, 2020 21:59 — forked from jalp/supervisor_client.py
Supervisor api client in Python
#import xmlrpclib
from xmlrpc import client
class ProcessStatus(object):
RUNNING = 'RUNNING'
STOPPED = 'STOPPED'
FATAL = 'FATAL'
RESTARTING = 'RESTARTING'
SHUTDOWN = 'SHUTDOWN'
@nelsoncbf
nelsoncbf / index.html
Created August 1, 2019 02:44
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Ativador - MamboRouter</title>
</head>
<body>
<h1>Insira a hash para ativação</h1><br>
<p>
<b>Hash</b> <input type="text" placeholder="insira a hash aqui"><br>
@nelsoncbf
nelsoncbf / environment
Created June 21, 2019 02:45
/etc/environment
# Androidsdk /etc/profile
export ANDROID=/opt/android
export PATH=$PATH:$ANDROID/tools
export PATH=$PATH:$ANDROID/tools/bin
export PATH=$PATH:$ANDROID/platform-tools
# Nodejs /etc/profile
VERSION=v10.16.0
DISTRO=linux-x64
export OPT_RAIZ=/opt
@nelsoncbf
nelsoncbf / Comandos Django 2.2
Last active June 18, 2019 16:20
Comandos Django 2.2
1: Ver versão Django
$ python -m django --version
2: Criar projeto MySite
$ django-admin startproject mysite
3: Levantar servidor de desenvolvimento
$ python manage.py runserver (opcionl: 8000 ou 8080)
4: Criar App Polls
@nelsoncbf
nelsoncbf / Documentação VENV.txt
Last active June 18, 2019 13:35
Documentação VENV
#VENV DOCUMENTAÇÃO
1: Instalando
$ sudo apt install python3-venv
2: Criar diretório do projeto
$ mkdir projeto && cd projeto
3: Criando ambiente venv dentro do projeto
$ python -m venv meuenv
@nelsoncbf
nelsoncbf / vscode-produtividade
Created April 12, 2019 05:28
vscode-produtividade
//Function no JavaScript
function helloWorld() {
console.log("Hello World");
}
//Function no EcmaScript
const saudacao = () => {
const hora = new Date().getHours();
if (hora <= 12) return "Bom dia";
if (hora <= 18) return "Boa tarde";