Skip to content

Instantly share code, notes, and snippets.

@julian-west
julian-west / logging.dev.ini
Last active October 15, 2022 16:00
Simple logging configuration file for Python project
[loggers]
keys=root,file
[handlers]
keys=console,file
[formatters]
keys=console,file
[logger_root]
@julian-west
julian-west / logging-with-config.py
Created August 29, 2022 16:32
Python logging using a configuration file
# src/main.py
import logging
import logging.config
import os
from datetime import datetime
from data_processing.processor import process_data
from dotenv import find_dotenv, load_dotenv
from model_training.trainer import train
@julian-west
julian-west / logging-example.py
Last active January 3, 2023 22:56
Example for setting up logging in a Python project
# src/main.py
import logging
import sys
from data_processing.processor import process_data
from model_training.trainer import train
# instantiate logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
@julian-west
julian-west / hash_split.py
Last active June 19, 2022 12:11
Data splitting using hashing
TEST_RATIO = 0.1
BUCKETS = 10
def assign_hash_bucket(value: Any, total_buckets: int = BUCKETS) -> int:
"""Assign a bucket to an input value using hashing algorithm"""
hashed_value = farmhash.fingerprint64(str(value))
return hashed_value % total_buckets
def test_set_check(bucket: int) -> bool:
@julian-west
julian-west / extract_spotify_playlist_info.py
Last active March 1, 2023 05:37
Extract track name and artist from a Spotify playlist to a csv file
"""Get song titles and artists from Spotify playlist"""
import csv
import os
import re
import spotipy
from dotenv import load_dotenv
from spotipy.oauth2 import SpotifyClientCredentials
service:
type: LoadBalancer
# These values, when defined and not empty, override the provided shared annotations and labels.
# Uncomment only if you are trying to override the chart's shared values.
#annotations: {}
#labels: {}
# If the loadBalancer supports sessionAffinity and you have more than one coordinator,
# uncomment the below line to enable session affinity.
# Control where uploaded files are stored for Dremio.
# For more information, see https://docs.dremio.com/deployment/distributed-storage.html
distStorage:
# The supported distributed storage types are: local (<21.0.0 only), aws, azure, gcp, or azureStorage.
#
# local: (<21.0.0 only) Not recommended for production use. When using local, dist-caching is disabled.
# aws: AWS S3, additional parameters required, see "aws" section.
# azure: ADLS Gen 1, additional parameters required, see "azure" section.
# azureStorage: Azure Storage Gen2, additional paramters required, see "azureStorage" section.
# gcp: Google Cloud Storage, additional parameters required, see "gcp" section.
@julian-west
julian-west / chrome-tab-to-new-window.applescript
Created February 1, 2022 19:30
'Moves' current Chrome tab to a new window
tell application "Google Chrome"
set currentURL to URL of active tab of front window
close active tab of front window
set theWindow to make new window
set URL of active tab of theWindow to currentURL
end tell
@julian-west
julian-west / starship.toml
Created January 25, 2022 19:36
Example starship prompt config file
add_newline = false
[gcloud]
disabled = true
format = 'on [$symbol$account (\($project\)) in (\($region\))]($style) '
[gcloud.region_aliases]
europe-west2 = "eu-w2"
[python]
format = 'via [${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)'
@julian-west
julian-west / .zshrc
Last active June 6, 2022 12:57
Example .zshrc file with oh-my-zsh
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# need to disable in order for exa ls alias to work
DISABLE_LS_COLORS="true"
# FZF settings
export FZF_BASE="$HOME/.fzf"
export FZF_DEFAULT_COMMAND='rg --hidden --no-ignore --files -g "!.git/"'
export FZF_CTRL_T_COMMAND=$FZF_DEFAULT_COMMAND