Skip to content

Instantly share code, notes, and snippets.

View beatorizu's full-sized avatar
🤓
Focusing

beatorizu

🤓
Focusing
  • São José dos Campos, SP Brazil
  • 06:28 (UTC -03:00)
View GitHub Profile
@beatorizu
beatorizu / show_time_elapsed_in_human_friendly.py
Last active April 8, 2021 14:41
human-readable time interval strings
def show_time_elapsed_in_human_friendly(elapsed):
return f'{elapsed / 3600:.0f}h {(elapsed % 3600) / 60:.0f}m {elapsed % 60:0>5.2f}s'
# 3h 13m 07.00s
print(show_time_elapsed_in_human_friendly(timedelta(hours=3, minutes=13, seconds=7).total_seconds()))
# 11587.0
print(timedelta(hours=3, minutes=13, seconds=7).total_seconds())
# 14h 59m 07.00s
@beatorizu
beatorizu / my_gist
Created October 30, 2020 20:55
hello!!
Hello, that is my gist. I'm a super gist!
@beatorizu
beatorizu / my_gist
Created October 29, 2020 23:18
hello!!
Hello, that is my gist. I'm a super gist!
@beatorizu
beatorizu / fps.js
Created July 5, 2020 19:52
Show frame rate on p5 js canvas
let fps = frameRate();
virtualCanvas.textSize(30);
virtualCanvas.fill(255);
virtualCanvas.stroke(0);
virtualCanvas.text(fps.toFixed(2), width - 30, 50);
@beatorizu
beatorizu / dev-requirements.txt
Last active July 4, 2021 18:05
A simple code to generate passwords
-r requirements.txt
autopep8
flake8
@beatorizu
beatorizu / userContent.css
Created March 8, 2020 00:22
Style Firefox scrollbar
:root {
/* Save this file to chrome/ in Firefox Profile Directory */
scrollbar-color: rgba(0, 0, 0, 0.5) rgba(0, 0, 0, 0.01);
scrollbar-width: thin;
}
@beatorizu
beatorizu / _.py
Created February 20, 2020 23:09
paranaês com _
reduce(lambda _, __: _ + __, valores)
ogr2ogr -s_srs EPSG:4326 -t_srs "+proj=latlong +pm=0" paises_0.shp paises.shp
ogr2ogr -s_srs EPSG:4326 -t_srs "+proj=latlong +pm=-360" paises_360.shp paises.shp
ogr2ogr -update -append paises_360.shp paises_0.shp
reduce(lambda _, __: _ + __, valores)
@beatorizu
beatorizu / nested_dict.py
Created November 7, 2018 22:08
Convert values in nested dicts using python
from collections.abc import Mapping
# Recursive function to apply a func to nested dict
def map_nested_dicts(ob, func):
if isinstance(ob, Mapping):
return {key: map_nested_dicts(value, func) for key, value in ob.items()}
return func(ob)