Skip to content

Instantly share code, notes, and snippets.

Avatar
🥑
Avocoding

Bruno Rocha rochacbruno

🥑
Avocoding
View GitHub Profile
@rochacbruno
rochacbruno / README.md
Last active Nov 12, 2020
Vim Configs and CheatSheet
View README.md

VIM CheatSheet

Based on configuration provided in .config/nvim/init.vim

Glossary

  • L = Leader Key, mapped to a single space " "
  • C = Control
  • S = Shift
View countdown.py
"""
Usage:
wait time: 600 (10 minutes)
title: 'Hello World'
duration: 7200 (2 hours)
$ python countdown.py 600 'Titulo da Live' 7200
"""
import os
import sys
@rochacbruno
rochacbruno / A_description.md
Created Jul 11, 2020
Generate SQLAlchemy models from vertabelo.com models
View magic_collect.rs
fn main() {
let vec_opt = [Some(1), Some(2), Some(3)].iter().copied().collect::<Vec<Option<i32>>>();
let opt_vec = [Some(1), Some(2), Some(3)].iter().copied().collect::<Option<Vec<i32>>>();
println!("{:?}", vec_opt);
println!("{:?}", opt_vec);
}
View poker.py
"""
Poker Ranker for Exercism.io
"""
def best_hands(hands):
hands = serialize(hands)
return [
deserialize(hand)
for hand in hands
@rochacbruno
rochacbruno / config.py
Created Apr 30, 2020
Dynaconf loader order example
View config.py
from dynaconf import LazySettings
settings = LazySettings(
# you can pass also default values for settings
FOO="bar",
# You can also pass Dynaconf configuration oprions
# .: Those ending with `_FOR_DYNACONF`: docs/guides/configuration.html
ENVVAR_PREFIX_FOR_DYNACONF="MYPROJECTNAME",
# You can also change order of loaders
LOADERS_FOR_DYNACONF=[
@rochacbruno
rochacbruno / dummy-web-server.py
Created Apr 25, 2020 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
View dummy-web-server.py
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request:
@rochacbruno
rochacbruno / cmus_to_file.sh
Created Mar 28, 2020 — forked from joariasl/cmus_to_file.sh
cmus player playing now to temp file from OBS
View cmus_to_file.sh
#!/usr/bin/env sh
file=/tmp/cmus_playing.txt
while true
do
music=""
if cmus-remote -C status | grep -q playing; then
music=$(cmus-remote -Q | grep -e "tag title" -e "tag artist" | sed "s/^tag\s\w*\s//g" | sed "N;s/\n/ - /g")
if (( ${#music} > 0 )); then
music="Now playing: $music"
fi
@rochacbruno
rochacbruno / send_email.py
Created Mar 25, 2020
Send Email Python Local SMTP postfix
View send_email.py
"""
sudo systemcrl start sendmail
"""
import smtplib
from dynaconf import settings
def get_email_server():
"""Creates an instance of email server.
@rochacbruno
rochacbruno / init.lua
Last active Mar 21, 2020
micro/init.lua
View init.lua
-- Save this file to ~/.config/micro/init.lua
-- requirements:
-- Python3
-- - isort
-- - black
-- - flake8
-- - ipython
-- Rust
-- - cargo-play
-- - evcxr_repl
You can’t perform that action at this time.