Skip to content

Instantly share code, notes, and snippets.

@heyodai
heyodai / ds_store.ipynb
Created December 15, 2023 17:29
How frequently is `.gitignore` in GitHub commit messages?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@heyodai
heyodai / logger.py
Last active July 7, 2023 16:43
Boilerplate for Python logging
import logging
import os
from datetime import datetime
def setup_logging() -> logging.Logger:
"""
Set up logging for the script.
Returns
-------
Download statistics
Time taken: 4.29 seconds
File size: 45.47 MB
Network speed: 10.61 MB/s
Time taken: 2.53 seconds
File size: 45.47 MB
Network speed: 18.00 MB/s
Time taken: 4.13 seconds

I'm tired of having to look these up everytime I need them, so I'm writing them down.

  • Creation
    • Install the package: pip3 install virtualenv
    • Create environment: python3 -m venv env
  • Activation
    • Activate environment: source env/bin/activate
    • Deactivate: deactivate
  • Requirements
  • Save requirements: pip3 freeze > requirements.txt
@heyodai
heyodai / stacker-test.rkt
Created February 28, 2022 22:01
Beautiful Racket - Stacker Tutorial
#lang reader "stacker.rkt"
4
8
+
3
*
@heyodai
heyodai / leetcode-217.js
Created September 22, 2021 00:11
Check an int array for duplicate values. Written for leetcode.com challenge #217.
/**
* Check an int array for duplicate values.
* Written for leetcode.com challenge #217.
*
* @param {int[]} nums Array of int values to check.
* @return {boolean} TRUE if duplicate values found, FALSE if every element is distinct.
*
* @see https://leetcode.com/problems/contains-duplicate/
*/
var containsDuplicate = function(nums) {
@heyodai
heyodai / createDateIntervalFromDurationString.php
Created September 3, 2021 20:16
Unfinished attempt at converting duration strings to DateInterval objects
<?php
/**
* Take duration string from a database - e.g. 00:21:15.2581 - and convert it to
* a DateInterval object (PHP's built-in duration object).
*
* DateInterval does not support construction from these strings directly, which
* is why this function is needed.
*
* Supported units are years, months, days, hours, minutes, and seconds.