Skip to content

Instantly share code, notes, and snippets.

View jac18281828's full-sized avatar
🦌

John Cairns jac18281828

🦌
View GitHub Profile
@jac18281828
jac18281828 / dynamo_schema.json
Created November 20, 2018 19:40
Dynamodb table schema json
{
"AttributeDefinitions": [
{
"AttributeName": "string",
"AttributeType": "string"
}
],
"GlobalSecondaryIndexes": [
{
"IndexName": "string",
@jac18281828
jac18281828 / ConcurrentStack.java
Last active December 21, 2018 15:04
Java Concurrent Stack based on an immutable Linked List
import java.util.concurrent.atomic.AtomicReference;
/*
* #%L
* ConcurrentStack.java
* ~~
* covemarkets.com © 2018, Cove Markets, Inc.
* ~~
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@jac18281828
jac18281828 / filter_unicode.py
Last active July 30, 2022 12:59
Unifi EdgeRouter Ad Blocking Script for dnsmasq
import sys
for buffer in sys.stdin.read():
for ch in buffer:
if (ord(ch) < 128):
sys.stdout.write(ch)
@jac18281828
jac18281828 / MergingSpliterator.java
Created June 27, 2019 18:25
Merge sorted collections using Spliterator
package com.covemarkets.market.filter;
import com.covemarkets.covelibrary.datastructures.Pair;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.Spliterator;
@jac18281828
jac18281828 / bitflyer.py
Last active October 21, 2019 16:29
Print updated bitflyer order book with check for market crossing
# pip install websocket-client
import datetime
import websocket
import json
import sys
#PRODUCTID='BTC_USD'
PRODUCTID='BTC_JPY'
SNAPSHOT_CHANNEL = 'lightning_board_snapshot_' + PRODUCTID
@jac18281828
jac18281828 / InstrumentUpdateFeedBuilder.java
Last active November 13, 2019 15:17
generated feed builder
public static final class InstrumentUpdateFeedBuilder {
private Set<String> supportedInstruments;
private ErrorListener errorListener;
private ExchangeInstrumentTranslator translator;
private InstrumentRepresentationProvider relevantInstrumentInformationProvider;
private InstrumentUpdateFeedBuilder() {
}
public static InstrumentUpdateFeedBuilder aInstrumentUpdateFeed() {
@jac18281828
jac18281828 / networkx_example.py
Last active May 23, 2020 22:40
Toy example for networkx python graph package
import networkx as nx
# pip install networkx
# directed graph example using networkx as a graph engine
G = nx.DiGraph()
roots = set()
@jac18281828
jac18281828 / kafka_tutorial
Created November 21, 2019 16:39
Kafka Tutorial: How to Kafka in 6 lines
$ bin/zookeeper-server-start.sh config/zookeeper.properties.
$ bin/kafka-server-start.sh config/server.properties.
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testtopic
$ bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testtopic
$ bin/kafka-console-consumer.sh --bootstrap-server localhost:9092
--topic testtopic --from-beginning
@jac18281828
jac18281828 / bookscan.sh
Created November 21, 2019 16:41
aws cli dynamodb scan
#!/usr/bin/env /bin/sh
for table in book
do
echo ${table}
aws dynamodb scan \
--table-name=${table} \
--attributes-to-get '["Count", "ScannedCount", "ConsumedCapacity"]' \
--endpoint-url http://localhost:9198
done
@jac18281828
jac18281828 / bookable.sh
Created November 21, 2019 16:42
aws cli dynamodb create table
aws dynamodb delete-table --table-name=book --endpoint-url http://localhost:9198
aws dynamodb create-table \
--table-name=book \
--attribute-definitions \
AttributeName=Sequence,AttributeType=N \
AttributeName=InstrumentId,AttributeType=S \
AttributeName=Exchange,AttributeType=S \
AttributeName=ExchangeTime,AttributeType=N \
AttributeName=CaptureTime,AttributeType=N \
AttributeName=BookJson,AttributeType=S \