Skip to content

Instantly share code, notes, and snippets.

View renatocfrancisco's full-sized avatar
:shipit:
still js

Renato C. Francisco renatocfrancisco

:shipit:
still js
View GitHub Profile
# https://www3.bcb.gov.br/CALCIDADAO/publico/exibirFormFinanciamentoPrestacoesFixas.do?method=exibirFormFinanciamentoPrestacoesFixas
def financiamentoPrestacoesFixas(n, j, p):
"""
Calcula o valor financiado (q0) usando a fórmula de juros compostos e capitalização mensal.
Parâmetros:
n (int): Número de meses
j (float): Taxa de juros mensal
p (float): Valor da prestação
@renatocfrancisco
renatocfrancisco / exampleSteamDetails.json
Created November 3, 2023 20:52
example of data from appdetails response of steam store api
{
"10": {
"success": true,
"data": {
"type": "game",
"name": "Counter-Strike",
"steam_appid": 10,
"required_age": 0,
"is_free": false,
"detailed_description": "Jogue o jogo de ação número 1 no mundo. Junte-se a uma guerra incrivelmente realística contra o terrorismo neste jogo baseado em equipes. Alie-se com os seus colegas e complete missões estratégicas. Acabe com os inimigos. Resgate reféns. A forma como você joga afeta o sucesso da sua equipe. O sucesso da sua equipe afeta você.",
@renatocfrancisco
renatocfrancisco / uninstall_all_pip_packages.bat
Last active August 16, 2023 15:56
listing installed global pip packages in a txt file and uninstalling all - github copilot
@echo off
REM Get a list of all globally installed packages
pip list --format=freeze > packages.txt
REM Uninstall each package one by one
for /f "delims=" %%i in (packages.txt) do (
pip uninstall -y %%i
)
const capitalize = (str) => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
const calculatePercent = (value, total) => Math.round((value / total) * 100)
const getRandomItem = (items) => items[Math.floor(Math.random() * items.length)];
const removeDuplicates = (arr) => [...new Set(arr)];
const sortBy = (arr, key) => arr.sort((a, b) => a[key] > b[key] ? 1 : a[key] < b[key] ? -1 : 0);
const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
const countOccurrences = (arr, value) => arr.reduce((a, v) => (v === value ? a + 1 : a), 0);
const wait = async (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
const pluck = (objs, key) => objs.map((obj) => obj[key]);
const insert = (arr, index, newItem) => [...arr.slice(0, index), newItem, ...arr.slice(index)];
@renatocfrancisco
renatocfrancisco / mp.py
Last active July 19, 2023 15:50
Multi processing in Python with mp.Process and concurrent
import multiprocessing as mp
import time
import concurrent.futures
def do_some(seconds = 1):
print(f'sleeping {seconds}')
time.sleep(seconds)
return f'done {seconds}'
if __name__ == '__main__':
@renatocfrancisco
renatocfrancisco / teste-bancos.js
Created February 24, 2023 19:50
explicando req. axios com funções array/object
// executando com node, npm -> package.json -> axios 1.3.4
import axios from "axios";
import fs from "fs";
// config e req. tirado do postman
var config = {
method: "get",
maxBodyLength: Infinity,
url: "https://brasilapi.com.br/api/banks/v1",
@renatocfrancisco
renatocfrancisco / sql_python_query_statement.md
Last active July 19, 2023 15:51
Query statement in python

The _metadata attribute of the Pandas DataFrame was removed in version 1.3.0, which is why you are receiving a "list indices must be integers or slices, not str" error. The approach I suggested in my previous response would only work for Pandas versions earlier than 1.3.0.

In newer versions of Pandas, you can still access the compiled SQL statement by using the query attribute of the sqlalchemy.engine.ResultProxy object that is returned by pandas.read_sql_query. Here's an example:

import pandas as pd
from sqlalchemy import create_engine

# create a SQLAlchemy engine
engine = create_engine('postgresql://user:password@host:port/database')
@renatocfrancisco
renatocfrancisco / random_pwd_generator.py
Last active January 13, 2023 14:56
Random Password Generator in Python
import string
import random
def main():
password_length = int(input("Length (int) of password? "))
punctuation_option = input("Punctuation on password? (y/n)")
if(punctuation_option == 'y'):
characters = list(string.ascii_letters + string.digits + string.punctuation)
else:
characters = list(string.ascii_letters + string.digits)
@renatocfrancisco
renatocfrancisco / sql-tirar-acent.sql
Created August 10, 2022 19:03
Tirar Acentuação de String SQL
-- https://felipelauffer.com/2019/03/01/remover-acentos-e-cedilhas-de-uma-string/
-- Usando COLLATE SQL_Latin, retira acentuação de string
SELECT 'çáéíóúâêîôûãõç' COLLATE SQL_Latin1_General_Cp1251_CS_AS AS nova_string
@renatocfrancisco
renatocfrancisco / datatypes.sql
Created August 4, 2022 17:55
SQL Script to check datatypes in a table
SELECT
TABLE_NAME,
COLUMN_NAME,
DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'table';