Skip to content

Instantly share code, notes, and snippets.

View ScottVinay's full-sized avatar
🏠
Working from home

Scott Vinay ScottVinay

🏠
Working from home
View GitHub Profile
@ScottVinay
ScottVinay / singleton_config.py
Created October 2, 2025 16:00
Shows how to load a singleton config dataclass. Also includes pkg_resources code for loading files from an installed package.
import json
from dataclasses import dataclass
from typing import Optional
import importlib.resources as pkg_resources
from mypackage import control # this points to the folder containing config.json
@dataclass
class ControlConfig:
property_1: bool
property_2: str
from matplotlib import pyplot as plt
import numpy as np
import seaborn as sns
dfrad = df.copy()
# We want a column for the minute of the day.
dfrad['minOfDay'] = 0
for i in range(len(dfrad)):
timestr = dfrad.loc[i,'time']
hrs = int(timestr[:timestr.index(':')])
import datetime
# Initialise the column
df['daynum'] = 0
# Get a list of the elements of the full date
fdl = df.iloc[-1]['full_date'].split('-')
# Find the datetime object corresponding to the first entry
firstDate = datetime.date(
@ScottVinay
ScottVinay / dayliodisplay.py
Created October 15, 2019 10:02
Daylio display
import pandas as pd
# Read the data
df = pd.read_csv('Bobs_daylio_export.csv')
# Days where he did no activities should be a blank string
df['activities'] = df['activities'].fillna(' ')
# Bob made no notes in any of his entries
df.drop(columns='note',inplace=True)