Skip to content

Instantly share code, notes, and snippets.

View skeller88's full-sized avatar

Shane Keller skeller88

View GitHub Profile
@skeller88
skeller88 / Gruntfile.js
Created August 18, 2014 02:22
Gruntfile for typical grunt workflow
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
build: {
src: ['dist/']
}
},
@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",
@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>
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
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
@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')

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, 
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
}
@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
import json
import time
import warnings
import numpy as np
from tensorflow.keras.callbacks import ModelCheckpoint
class ModelCheckpointGCS(ModelCheckpoint):
"""