Skip to content

Instantly share code, notes, and snippets.

View MagnetonBora's full-sized avatar
🚀
Focusing

MagnetonBora

🚀
Focusing
View GitHub Profile
def pyramid(n: int) -> list:
size = 2 * n - 1
table = [size * [0] for _ in range(size)]
for start in range(n):
for j in range(size - start):
table[start][start + j] = start + 1
for j in range(size - start):
table[size - 1][start + j] = start + 1
for i in range(size - start):
table[start + i][start] = start + 1
@MagnetonBora
MagnetonBora / products.py
Last active May 20, 2021 18:29
Original vs refactored
import json
import os
import pathlib
from . import db, config
sponsored_id_list = config.get_sponsored()
@MagnetonBora
MagnetonBora / excel_example.y
Created October 25, 2023 13:53
This is an example of how to append some records to a given Excel spreadsheet without altering the rest of the spreadsheet, using pandas and openpyxl.
import openpyxl # for working with Excel files
import pandas as pd # for working with DataFrames
from openpyxl.utils.dataframe import dataframe_to_rows # for converting DataFrames to rows in Excel
# openpyxl and pandas need to be installed with pip
# Function to generate sample data as a DataFrame
def generate_sample_data():
return pd.DataFrame({