Skip to content

Instantly share code, notes, and snippets.

View kadereub's full-sized avatar
👣

kadereub

👣
  • UK
View GitHub Profile
@kadereub
kadereub / south_african_holidays.py
Last active May 8, 2022 18:24
A Python (pandas) holiday calendar for South Africa - for which there are many public holidays!
# [1] https://github.com/pandas-dev/pandas/blob/main/pandas/tseries/holiday.py
from pandas.tseries.offsets import CDay, Day
from pandas.tseries.holiday import AbstractHolidayCalendar, Holiday, sunday_to_monday, \
DateOffset, MO, next_monday, next_monday_or_tuesday, GoodFriday, EasterMonday
class Holidays_South_Africa(AbstractHolidayCalendar):
rules = [
Holiday('New Years Day', month=1, day=1, observance=next_monday),
Holiday('Human Rights Day', month=3, day=21, observance=sunday_to_monday),
@kadereub
kadereub / m1pro_conda_setup.md
Last active February 4, 2022 10:04
This is a guide to setup & install `miniforge` and `PyTorch` on a Mac M1 Pro for some deep learning tasks

Installing Miniconda and PyTorch the Hard Way

This guide ensures the installation of Python (miniconda) and PyTorch runs using the Apple silicon on a M1 Pro (I know the M1 Max probably has no issues) - os specs:

    System Software Overview:

      System Version: macOS 12.1
      Kernel Version: Darwin 21.2.0
 Boot Volume: Macintosh HD
@kadereub
kadereub / read_in_btc_usd_tick_data.py
Created March 10, 2020 22:16
Read in tick data sourced from the `bitcoincharts` api.
# Step 1: Download zip file for bitstampUSD
##### Link: -> http://api.bitcoincharts.com/v1/csv/
##### See SO post for more detail: https://stackoverflow.com/questions/16143266/get-bitcoin-historical-data
# Step 2: Extract CSV file and save in downloads
# Step 3: Run the below code reading and cleaning the data to save as minute ohlc data...
import os
import numpy as np
import pandas as pd
@kadereub
kadereub / numba_heap_permutation.py
Last active September 22, 2020 08:41
A `numba` implementation of heaps permutation algorithm (non-recursive)
import numpy as np
import numba as nb
# References
# [1] https://en.wikipedia.org/wiki/Heap%27s_algorithm
@nb.njit
def _factorial(n):
if n == 1:
return n
@kadereub
kadereub / numba_polyfit.py
Last active March 27, 2024 14:43
A numba implementation of numpy polfit
# Load relevant libraries
import numpy as np
import numba as nb
import matplotlib.pyplot as plt
# Goal is to implement a numba compatible polyfit (note does not include error handling)
# Define Functions Using Numba
# Idea here is to solve ax = b, using least squares, where a represents our coefficients e.g. x**2, x, constants
@nb.njit