Skip to content

Instantly share code, notes, and snippets.

View lparolari's full-sized avatar
🎯
Focusing

Luca Parolari lparolari

🎯
Focusing
  • University of Padova
  • Padova • Italy
  • 13:47 (UTC +02:00)
View GitHub Profile

Pacman/Yay

sudo pacman -Syu
sudo pacman -Sc
yay -Sc --aur

Snap

@lparolari
lparolari / pytorch_model_disk_size.py
Last active July 11, 2023 12:49
Compute the disk size of a PyTorch model from its weights.
# Reference: https://discuss.pytorch.org/t/why-are-saved-models-so-large/166324/2
for name, param in model.named_parameters():
size = int((param.nelement() * param.element_size()) / (1024 ** 2)) # MB = 1024^2 bytes
print(name, param.nelement(), param.element_size(), f"{size}MB")
# EXAMPLE OUTPUT:
# concept_branch.we.embedding.weight 120005700 4 457MB
# visual_branch.we.embedding.weight 120005700 4 457MB
# visual_branch.fc.weight 78300 4 0MB
round(
if(
prop("Budget") > 0,
if (
prop("Spent") > 0,
prop("Spent") / prop("Budget"),
if (
prop("Spent") < 0,
1 - abs(prop("Spent")) / prop("Budget"),
@lparolari
lparolari / notion-quotes.json
Last active February 12, 2023 14:52
A list of quotes for my Notion dashboard (powered by ChatGPT)
[
{
"author":"Alan Turing",
"content":"La vera maturità della scienza della computazione arriverà quando avremo sviluppato macchine che non possono essere distinguibili da quelle umane."
},
{
"author":"Steve Jobs",
"content":"Design è non solo ciò che sembra e si sente. Design è come funziona."
},
{
@lparolari
lparolari / task-aging.notion
Last active December 16, 2022 14:40
A Notion formula that given the "Created At" prop return ⚡, ☕, 🥱, 😴 as an indicator task aging in inbox state.
if(
prop("Status") == "Not started",
if(
dateBetween(
now(),
prop("Created At"),
"days"
) < 1,
"⚡",
if (
@lparolari
lparolari / day-stress-level-formula.notion
Created December 13, 2022 21:52
A Notion formula that given a number of task and events returns the stress level as a colorful emoji 🦄
if(prop("Tasks Number") == 0 and prop("Events Number") == 0, "🎉",
if(prop("Tasks Number") <= 2 and prop("Events Number") <= 0, "☕️",
if(prop("Tasks Number") <= 2 and prop("Events Number") <= 1, "⚡️",
if(prop("Tasks Number") <= 3 and prop("Events Number") <= 2, "🌩",
if(prop("Tasks Number") <= 4 and prop("Events Number") <= 3, "💥",
🌋
)
)
)
)
@lparolari
lparolari / find-the-symmetric-difference.js
Created September 22, 2021 22:15
Very simple solution for symmetric difference between sets with functional set abstraction. (freecodecamp.org coding interview execise: https://www.freecodecamp.org/learn/coding-interview-prep/algorithms/find-the-symmetric-difference)
function exists(s, x) {
for (let i = 0; i < s.length; i++) {
if (s[i] === x)
return true
}
return false
}
function insert(s, x) {
if (!exists(s, x))
@lparolari
lparolari / no-repeats-please.js
Last active September 19, 2021 21:54
A straightforward solution for "No Repeats Please" coding interview exercise at freecodecamp.org (https://www.freecodecamp.org/learn/coding-interview-prep/algorithms/no-repeats-please)
// A straightforward solution for "No Repeats Please"
// coding interview exercise at freecodecamp.org
// (https://www.freecodecamp.org/learn/coding-interview-prep/algorithms/no-repeats-please)
//
// Luca Parolari
//
// GitHub: github.com/lparolari
// Email: luca.parolari23@gmail.com
// Telegram: @lparolari
@lparolari
lparolari / turing-machine-greater.yaml
Last active April 17, 2021 14:10
A Turing machine implementation of the greater (or equal) algorithm. Powered by https://turingmachine.io/.
input: '00S00'
blank: ' '
start state: init
table:
# we want to start with the tape centered in the separator symbol
init:
0: { R }
S: { L: start }
start:
0: { L }
@lparolari
lparolari / turing-machine-binary-addition.yaml
Last active April 17, 2021 14:10
A Turing machine implementation of the binary sum algorithm. Powered by https://turingmachine.io/.
name: binary addition
source code: |
# Adds two binary numbers together.
# Format: Given input a+b where a and b are binary numbers,
# leaves c b on the tape, where c = a+b.
# Example: '11+1' => '100 1'.
input: '1011+11001'
blank: ' '
start state: right