Skip to content

Instantly share code, notes, and snippets.

@Voyz
Voyz / timeseries_vertices_voy_A01.py
Created October 23, 2022 14:48
Vertices of a timeseries
def timeseries_vertices(ser:pd.Series, distance=15, coeff=3):
name = ser.name
# remove intermediate vertices on lines
def no_lines(df):
df.loc[:, 'gt_before'] = df.loc[:, name] > df.loc[:, name].shift(1)
df.loc[:, 'gt_after'] = df.loc[:, name] > df.loc[:, name].shift(-1)
df.loc[:, 'is_peak'] = df.loc[:, 'gt_before'] == df.loc[:, 'gt_after']
df = df.loc[df.loc[:, 'is_peak'], :].copy()
@Voyz
Voyz / bouquets_log.json
Last active August 31, 2022 12:34
Tulip matching challenge - pubic data
[
{"side": "SELL", "tulips": 15, "tulip_price": 111.5, "transaction_date": "2022-02-01T00:00:00.250000"},
{"side": "BUY", "tulips": 15, "tulip_price": 107.5, "transaction_date": "2022-02-01T00:30:00.250000"},
{"side": "BUY", "tulips": 15, "tulip_price": 107, "transaction_date": "2022-02-01T01:30:00.250000"},
{"side": "SELL", "tulips": 20, "tulip_price": 104.5, "transaction_date": "2022-02-01T02:00:00.250000"},
{"side": "BUY", "tulips": 10, "tulip_price": 105, "transaction_date": "2022-02-01T02:00:00.250000"},
{"side": "SELL", "tulips": 15, "tulip_price": 112.5, "transaction_date": "2022-02-01T03:00:00.250000"},
{"side": "BUY", "tulips": 15, "tulip_price": 111.5, "transaction_date": "2022-02-01T03:30:00.250000"},
{"side": "SELL", "tulips": 20, "tulip_price": 111.0, "transaction_date": "2022-02-01T04:00:00.250000"},
{"side": "BUY", "tulips": 15, "tulip_price": 109.5, "transaction_date": "2022-02-01T04:30:00.250000"}
@Voyz
Voyz / IBeamDockerfileArm
Created April 14, 2021 13:55
IBeam arm64 Dockerfile
FROM python:3.7.7-slim-buster
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN mkdir -p /usr/share/man/man1
RUN apt-get update && \
apt-get install -y default-jre && \
apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable && \
@Voyz
Voyz / ibkr_inlet.py
Last active March 22, 2021 03:14
Databay Inlet for IBKR CP Web API
TS_DATE_FORMAT_DB_ISO = '%Y-%m-%dT%H:%M:%S,%f' # comma works for mongodb and is valid ISO
def datetimeindex_to_UTC(_dti):
dti = _dti.copy(deep=True)
if 'tz' not in dti or dti.tz is None:
dti = dti.tz_localize('UTC')
else:
dti = dti.tz_convert('UTC')
dti = dti.dt.strftime(TS_DATE_FORMAT_DB_ISO).astype(str).str.slice(0, -3)
return dti
@Voyz
Voyz / databay_batch_outlets_and_splitters.py
Created February 14, 2021 14:09
databay_batch_outlets_and_splitters
import csv
import os
from pathlib import Path
from typing import List
from databay import Outlet, Update, Record, Link
from databay.inlets import RandomIntInlet
from databay.outlet import MetadataKey
from databay.outlets import CsvOutlet
@Voyz
Voyz / path_between_nulls.js
Created January 4, 2021 07:57
After Effects path between nulls
offset = [thisComp.width, thisComp.height]/2
p1 = thisComp.layer("P1").toComp([0,0]).slice(0,2) - offset
p2 = thisComp.layer("P2").toComp([0,0]).slice(0,2) - offset
t1 = thisComp.layer("T1").toComp([0,0]).slice(0,2) - offset - p1
t2 = thisComp.layer("T2").toComp([0,0]).slice(0,2) - offset - p2
ps = [p1, p2]
in_tangents = [[0,0], t2]
out_tangents = [t1, [0,0]]
createPath(ps, in_tangents, out_tangents, is_closed=false)
@Voyz
Voyz / weather_finder_basic.txt
Last active December 7, 2020 08:50
Weather finder basic
*** Originally built for my mate Sam as part of our mentoring sessions. See: https://youtu.be/TXoDvTJuEb0 ***
####################
WEATHER FINDER BASIC
####################
Utilise an online weather API to fetch and display current weather information based on the city and country code provided.
###################
-- Reboot --
Oct 28 08:46:32 gateway systemd[1]: Starting Google Compute Engine Startup Scripts...
Oct 28 08:46:33 gateway startup-script[483]: INFO Starting startup scripts.
Oct 28 08:46:33 gateway startup-script[483]: INFO Found startup-script in metadata.
Oct 28 08:46:38 gateway startup-script[483]: INFO startup-script: Unable to find image 'google/cloud-sdk:latest' locally
Oct 28 08:46:39 gateway startup-script[483]: INFO startup-script: latest: Pulling from google/cloud-sdk
Oct 28 08:46:39 gateway startup-script[483]: INFO startup-script: e4c3d3e4f7b0: Pulling fs layer
Oct 28 08:46:39 gateway startup-script[483]: INFO startup-script: 56c33728d4fb: Pulling fs layer
Oct 28 08:46:39 gateway startup-script[483]: INFO startup-script: bfce832607f8: Pulling fs layer
Oct 28 08:46:39 gateway startup-script[483]: INFO startup-script: f6a95ba73cf4: Pulling fs layer
from keras import Input, Model
from keras.callbacks import Callback
from keras.layers import Dense, BatchNormalization, Lambda, Flatten, Dropout
import numpy as np
from sklearn.metrics import roc_auc_score
import tensorflow as tf
from keras import backend as K
# generate random test data
m = 10000
@Voyz
Voyz / premiere_pro_preload_thumbnails.ahk
Last active June 5, 2019 15:54
Adobe Premiere Pro - thumbnail preloading with AutoHotkey (Windows only)
; Usage:
; 1. Open Premiere
; 2. Select the bin you'd like to preload, even better - fullscreen it using tilde ` key.
; (Make sure you're in Icon View, not List View)
; 3. Run this script
; 4. Manually input the number of items in the bin
; 5. You can grab a coffee or browse internet in the meantime (though be aware keyboard may not work 100% well)
; 6. Repeat for each bin you'd like to preload
#Persistent