Skip to content

Instantly share code, notes, and snippets.

View ricardodani's full-sized avatar
🐍
Coding python

Ricardo L. Dani ricardodani

🐍
Coding python
View GitHub Profile
@ricardodani
ricardodani / Decorator.py
Created May 11, 2022 01:56
Python decorator
def print_result(func):
def decorated_func(a, b):
return f"o resultado é {func(a, b)}"
return decorated_func
@print_result
def soma(a, b):
return a + b
@print_result
def ppm():
REQUIRED_PH = 5.9
solution_volume = int(input('Type solution volume (0-20): '))
desired_solution_volume = int(input('Type desired volume (0-20):'))
required_volume = desired_solution_volume - solution_volume
print(f"Required volume is {required_volume} liters")
current_ppm = int(input('Type current ppm: '))
@ricardodani
ricardodani / messages.html
Created March 25, 2022 21:59 — forked from dimitrov/messages.html
Bootstrap Alerts for Django
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible text-center" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>{% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}Error{% else %}{{ message.tags|title }}{% endif %}!</strong> {{ message }}
</div>
{% endfor %}
{% endif %}
273999,873977,873978,873979,873980,873981,989911,1151875,1151906,1151907,1151909,1151911,1154286,1154289,1154290,1154291,1154293,1154294,1157694,1161159,1161160,1161174,1161175,1161176,1161179,1161187,1161197,1161201,1161210,1161222,1161252,1161254,1161258,1161264,1161265,1161276,1161284,1161297,1161302,1161332,1161333,1161343,1177341,1177343,1185408,1185450,1185454,1185455,1204236,1206064,1216822,1217288,1217880,1217906,1219905,1219906,1219907,1219908,1219911,1224861,1224875,1225203,1225204,1225205,1225207,1225208,1225211,1225212,1225214,1225215,1225216,1225217,1225219,1225220,1225222,1225224,1225225,1225227,1225232,1225233,1225234,1225237,1225238,1225240,1225243,1225244,1225245,1225246,1225250,1225251,1225254,1225255,1225256,1225257,1225258,1225260,1225261,1225267,1225268,1225270,1225272,1225298,1225299,1225300,1225301,1225302,1225303,1225306,1225307,1225311,1225312,1225318,1225319,1225320,1225325,1225326,1225327,1225328,1225329,1225331,1225332,1225333,1225334,1225336,1225337,1225338,1225339,1225340,1225341
@ricardodani
ricardodani / fakeserver_aiohttp.py
Last active July 11, 2020 21:00
fakeserver_aiohttp.py
import pytest
import aiohttp
from aiohttp import web
def create_magic_app():
app = web.Application()
return app
@ricardodani
ricardodani / test_client_fake_server.py
Created July 11, 2020 20:52 — forked from ambivalentno/test_client_fake_server.py
pytest-asyncio aiohttp client testing with fake server
import asyncio
import pathlib
import socket
import ssl
import pytest
import aiohttp
from aiohttp import web
from aiohttp.resolver import DefaultResolver
@ricardodani
ricardodani / jokenpo.py
Last active April 12, 2020 20:36
pedra papel tesoura
import random
from ansi.colour import fg, bg
PEDRA = 0
TESOURA = 1
PAPEL = 2
WINNERS_LOOSERS = {PEDRA: TESOURA, TESOURA: PAPEL, PAPEL: PEDRA}
LABELS = {
TESOURA: 'Tesoura',
PEDRA: 'Pedra',
@ricardodani
ricardodani / aliasesforgit.zsh
Created July 11, 2019 15:08
Aliases for git
# Git alias (tested on zsh)
alias gpull="git pull origin \`git branch --show-current\`"
alias gpush="git push origin \`git branch --show-current\`"
alias gcomm="git commit -v"
alias glogp="git log -p"
alias glogs="git log --stat"
from django.template.loader import get_template
from django.template.exceptions import TemplateDoesNotExist
class TemplateViewOrRedirect(TemplateView):
def get_template_names(self):
template_names = super().get_template_names()
for t in template_names:
get_template(t)
@ricardodani
ricardodani / tmux-cheatsheet.markdown
Created July 1, 2019 17:48 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname