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
  • 04:21 (UTC -03:00)
View GitHub Profile
@beatorizu
beatorizu / MATHLETE.png
Last active July 17, 2024 13:40
Show the letter in the 2010th position
MATHLETE.png
@beatorizu
beatorizu / is_magic_square.py
Last active July 11, 2024 18:45
Generate all 3x3 magic squares
magic_constant = 15
def is_magic_square(square):
line = [column for row in square for column in row]
if len(line) != len(set(line)):
return False
for row in square:
if sum(row) != magic_constant:
return False
for column in zip(*square):
@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