Skip to content

Instantly share code, notes, and snippets.

View a-r-d's full-sized avatar
🍌

Aaron Decker a-r-d

🍌
View GitHub Profile
@a-r-d
a-r-d / generate_schema.py
Created July 26, 2024 00:10
Generate supabase dataclasses from a tables that are subscriptable like dicts.
# note: run the sql file in your database first.
import os
from supabase import create_client, Client
from typing import List, Optional, Any, Union
# Ensure the models directory exists
os.makedirs("./models", exist_ok=True)
url: str = os.environ.get("SUPABASE_URL")

To parallelize job processing across multiple servers while ensuring each message is processed only once, we can use Redis' List data structure as a FIFO queue, along with its atomic operations. Here's how you can modify the approach:

Use Redis List as a FIFO queue Use Redis' BRPOPLPUSH command for reliable queue processing Implement a worker model that can run on multiple servers

Key points about this implementation:

@a-r-d
a-r-d / keybase.md
Created July 15, 2021 22:00
keybase

Keybase proof

I hereby claim:

  • I am a-r-d on github.
  • I am a_r_d (https://keybase.io/a_r_d) on keybase.
  • I have a public key ASD4gHJYd1VQoZ7CBS4AH1UQJjHXMOzniVPPT-TKpCXZWgo

To claim this, I am signing this object:

const Alpaca = require('@alpacahq/alpaca-trade-api')
const getKeyId = () => process.env.APCA_API_KEY_ID
const getSecretKey = () => process.env.APCA_API_SECRET_KEY
export const alpaca = new Alpaca({
keyId: getKeyId(),
secretKey: getSecretKey(),
paper: false,
usePolygon: false,
@a-r-d
a-r-d / other-misc-data-assets-v1-INVALID.json
Last active June 18, 2020 20:37
data asset demo public
[
{"Country Code":"USA","Established Customers":"5009","Total Customers":"3900343","Pct Active Accounts":"90"},
{"Country Code":"CAN","Established Customers":"3389","Total Customers":"300043","Pct Active Accounts":"80"},
{"Country Code":"MEX","Established Customerz":"2890","Total Customers":"zzzz","Pct Active Accounts":"70"}
]
@a-r-d
a-r-d / fade_complex.ino
Created December 8, 2018 19:48
Some RGB fade arduino code
/*
* Code for cross-fading 3 LEDs, red, green and blue (RGB)
* To create fades, you need to do two things:
* 1. Describe the colors you want to be displayed
* 2. List the order you want them to fade in
*
* DESCRIBING A COLOR:
* A color is just an array of three percentages, 0-100,
* controlling the red, green and blue LEDs
*
@a-r-d
a-r-d / playing_with_elevatr.R
Last active April 10, 2018 17:40
playing with elevatr public AWS data not authed
library(rgdal)
library(elevatr)
# this is the prjection system given as example in the documentation
ll_prj <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
# Im using this projection system based on reading this document:
# https://www.nceas.ucsb.edu/~frazier/RSpatialGuides/OverviewCoordinateReferenceSystems.pdf
us_prj = "+init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
@a-r-d
a-r-d / scale.py
Created March 8, 2018 20:25
how to scale factors
def featureScaling(arr):
_max = 0
_min = 10000000
for a in arr:
if a < _min:
_min = a
if a > _max:
_max = a
scaled = []
@a-r-d
a-r-d / main.py
Created February 22, 2018 01:42
Basic sector rebalance monthly algorithm
import numpy as np
class BasicTemplateAlgorithm(QCAlgorithm):
'''Basic template algorithm simply initializes the date range and cash'''
def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.SetStartDate(2004, 1, 1) #Set Start Date
self.SetEndDate(2018, 2, 16) #Set End Date
self.SetCash(100000) #Set Strategy Cash
@a-r-d
a-r-d / hold-tlt-version.py
Last active May 18, 2021 13:40
QuantConnect - simple MACD strategy against SPY, 50/150 day cross, long and short, leverage is none
import numpy as np
### <summary>
### Basic template algorithm simply initializes the date range and cash. This is a skeleton
### framework you can use for designing an algorithm.
### </summary>
class BasicTemplateAlgorithm(QCAlgorithm):
'''Basic template algorithm simply initializes the date range and cash'''
def Initialize(self):