Skip to content

Instantly share code, notes, and snippets.

View skeller88's full-sized avatar

Shane Keller skeller88

View GitHub Profile
# Tensorflow image Dockerfile:
# https://github.com/tensorflow/tensorflow/blob/d73faf5fbb7c8bfbf96cc6334111e4352f209e82/tensorflow/tools/dockerfiles/dockerfiles/gpu-jupyter.Dockerfile
# FROM continuumio/miniconda:4.7.12
# Image Dockerfile:
# https://gitlab.com/nvidia/container-images/cuda/-/blob/ubuntu18.04/10.0/runtime/Dockerfile
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
# https://askubuntu.com/questions/141928/what-is-the-difference-between-bin-sh-and-bin-bash
# bash has more functionality than bin, such as "source"
import json
import time
import warnings
import numpy as np
from tensorflow.keras.callbacks import ModelCheckpoint
class ModelCheckpointGCS(ModelCheckpoint):
"""
@skeller88
skeller88 / dask.py
Last active October 22, 2019 15:59
import dask
import dask.array as da
from distributed import Client
import gcsfs
import imageio
import numpy as np
import time
def main(start_datetime_str: str, end_datetime_str: Optional[str],
base_currency: str, quote_currency: str):
url = f"https://api-pub.bitfinex.com/v2/candles/trade:1h:t{base_currency}{quote_currency}/hist"
params = {
"limit": 5000,
"sort": 1,
"start": datetime.datetime.strptime(start_datetime_str, strftime_days).timestamp() * 1000,
"end": datetime.datetime.strptime(end_datetime_str, strftime_days).timestamp() * 1000
}

size is in bytes

trade update json {"exchange_channel_name": "trades", "symbol": "BTCUSD", "exchange_create_timestamp": 1533930346.634666, "app_create_timestamp": 1533955546.635748, "schema_name": "bitfinex_messages_trade_update", "schema_version": 0, "channel_id": 30, "trade_message_type": "te", "trade": {"trade_id": 278290579, "exchange_trade_timestamp": 1533930346500, "amount": 0.075, "price": 6385.7}} 
 size 422
order snapshot json {"exchange_channel_name": "book", "symbol": "BTCUSD", "exchange_create_timestamp": 1533930339.132575, "app_create_timestamp": 1533955539.133975, "schema_version": 0, "schema_name": "bitfinex_messages_orderbook_snapshot", "orders": [{"price": 6385.6, "count": 4, "amount": 2.8684482}, {"price": 6385.5, "count": 1, "amount": 0.15}, {"price": 6385.1, "count": 2, "amount": 3.69599999}, {"price": 6385, "count": 1, "amount": 1.06845933}, {"price": 6384.7, "count": 1, "amount": 0.05}, {"price": 6384.3, "count": 2, "amount": 0.59966192}, {"price": 6384.2, "count": 1, 
@skeller88
skeller88 / lock_acquire_and_release.py
Created August 1, 2018 18:39
python multithreading lock acquire and release
if __name__ == '__main__':
lock = threading.Lock()
def watch(num):
while True:
sleep(random.randint(0,5))
acquired = lock.acquire(blocking=False)
if acquired:
print('\n')
print(num, 'acquired lock')
from typing import Dict
# Start
# binance - 2 BTC
# bittrex - 4 ETH
# allocations: {
# 'free': {'binance': {'BTC': 2}, 'bittrex: {'ETH': 4} }
# }
# receive arbitrage signal for BTC and ETH
aiodns==1.1.1
aiohttp==3.0.1
alembic==0.9.7
appnope==0.1.0
async-timeout==2.0.0
attrdict==2.0.0
attrs==17.4.0
backcall==0.1.0
bcolz==1.2.1
bleach==2.1.3
@skeller88
skeller88 / gist:ad79cdb9cb260226ff0b7f9cf73079d1
Created April 16, 2016 20:25
Adding responsive legend to D3 charts
<div class="sk-legend-wrapper" ng-show="isLegendShown">
<div kendo-window="chartLegend" k-title="'Legend'" k-visible="false" k-on-open="chartLegendVisible = true" k-on-close="chartLegendVisible = false">
<div class="sk-legend-content k-content" kendo-tab-strip="" k-options="tabStripOptions">
<!-- tab list -->
<ul>
<li class="k-state-active">Career Names</li>
<li>Bubbles</li>
</ul>
<div class="sk-legend-careers">
<ul>
@skeller88
skeller88 / gist:c7a0f5888032f7e6d77e
Created June 18, 2015 18:26
Java url regex tests
@Test
public void testShouldMatch() throws Exception {
Collection<ValidationError> validationErrors = Lists.newArrayList();
List<String> shouldMatch = new ArrayList<>(Arrays.asList(
"http://مثال.إختبار",
"http://userid@example.com",
"http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
"http://उदाहरण.परीक्षा",
"ftps://foo.com",