Skip to content

Instantly share code, notes, and snippets.

View guidanoli's full-sized avatar

Guilherme Dantas guidanoli

  • PUC-Rio
  • Rio de Janeiro, Brazil
View GitHub Profile
@guidanoli
guidanoli / main.py
Created March 9, 2025 03:57
Calculate discount of equal installments with zero interest
YEARLY_INTEREST = 0.1375
MONTHLY_INTEREST = ((1 + YEARLY_INTEREST) ** (1/12)) - 1
NUM_INSTALLMENTS = 12
print("+--------------+----------+")
print("| Installments | Discount |")
print("+--------------+----------+")
installments = [1.0]
for num_installments in range(1, NUM_INSTALLMENTS + 1):
@guidanoli
guidanoli / hardhat-gas-report-diff.py
Last active May 12, 2022 17:27
Calculate difference in gas costs from Hardhat Gas Reports
#!/usr/bin/env python3
################################################################
# Hardhat Gas Report Diff
# ==============================================================
# Steps:
# 1) Have `hardhat-gas-reporter`
# 2) Run `npx hardhat test` before and after applying
# some change to the smart contracts you're testing
# 3) Save the gas reports into separate files (e.g.
@guidanoli
guidanoli / hiragana.py
Last active April 15, 2022 00:47
Exercise Hiragana
#!/usr/bin/env python3
import random
from colorama import Fore
hiraganas = {
"あ": "a",
"い": "i",
"う": "u",
"え": "e",
@guidanoli
guidanoli / find-cases.sh
Last active March 8, 2022 15:45
Count directories by cases in git repository
#!/usr/bin/env bash
set -euo pipefail
[ $# -ge 1 ] || (echo "Expected URI for git clone" >&2 && exit 1)
repodir=`mktemp -d`
git clone -- "$1" "$repodir"
pushd "$repodir" >/dev/null
folders=`git ls-files | xargs -r -d '\n' -n1 dirname | sort | uniq | xargs -r -d '\n' -n1 basename`
popd >/dev/null
rm -rf "$repodir"
snake_case=`echo "$folders" | grep -- '_' | tee snake | wc -l`
@guidanoli
guidanoli / aulas.html
Created September 28, 2021 10:38
Template HTML para Horário de Aulas
<html>
<head>
<title>Horário das aulas</title>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
padding: 10px;
}
table {
@guidanoli
guidanoli / bernoulli.c
Created August 28, 2019 12:44
Bernoulli distribution simulation
/*
* bernoulli.c
*
* Bernoulli distribution simulation
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@guidanoli
guidanoli / pi.c
Created August 28, 2019 03:16
Approximation of Pi by probability
/*
* pi.c
*
* Approximation of Pi by the probability
* of a point to fall into the circle of
* a circumscribed square in the xy-plane.
*
* Inspired by Simulation Fifth Edition
* Book by Sheldon Ross
*/
@guidanoli
guidanoli / pow.c
Created August 22, 2019 03:04
Optimised power function for integer values
/*
* pow.c
*
* Optimised power function for integer values
*/
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@guidanoli
guidanoli / perm.c
Created August 21, 2019 13:29
Array permutation
/*
* perm.c
*
* Array permutation
*/
#include <assert.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
@guidanoli
guidanoli / puc-prereq.py
Last active July 23, 2019 13:34
PUC Prerequisites graph
import urllib.request
import xlrd
import tkinter as tk
from tkinter import filedialog
# ############################################
# PUC Dependency Graph Viewer
# ############################################
# Guilherme Dantas, 7/23/2019
# ############################################