Skip to content

Instantly share code, notes, and snippets.

// BENCH
const NEW_TEMPLATE_INPUT: &str = r#"{"e":"depthUpdate","E":1571889248277,"T":1571889248276,"s":"BTCUSDT","U":390497796,"u":390497878,"pu":390497794,"b":[["7403.89","0.002"],["7403.90","3.906"],["7404.00","1.428"],["7404.85","5.239"],["7405.43","2.562"]],"a":[["7405.96","3.340"],["7406.63","4.525"],["7407.08","2.475"],["7407.15","4.800"],["7407.20","0.175"]]}"#;
fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("Deserialize using serde", |b| {
b.iter(|| {
let _: BBO =
serde_json::from_str(NEW_TEMPLATE_INPUT).expect("Failed to deserialize JSON");
})
@hanchang
hanchang / main.rs
Created December 1, 2023 00:53 — forked from chrishulbert/main.rs
Interactive Brokers TWS API in Rust
// MIT licensed.
use std::net::TcpStream;
use std::io::{Read, Write};
use std::sync::mpsc::channel;
use std::thread;
fn main() {
let mut stream = TcpStream::connect("127.0.0.1:7496").expect("connect");
stream.set_nodelay(true).expect("nodelay"); // Because we're wannabe HFT traders.
@hanchang
hanchang / not_too_clever.md
Created June 24, 2022 01:30 — forked from raphlinus/not_too_clever.md
Translation of grugbrain.dev into English

The not-too-clever programmer

This is a translation of grugbrain.dev into clear English. All props to the original author.

Introduction

This is a collection of thoughts on software development, originally written by an pseudonymous author styling themselves the "grug brain developer," but then translated into clear English by Raph Levien.

I am not an extremely smart developer, but I have many years of experience and have learned some things, although still don't know everything.

@hanchang
hanchang / music_theory.py
Created April 20, 2021 14:46 — forked from mvanga/music_theory.py
Basic Music Theory in ~200 Lines of Python
# The code for my article with the same name. You can find it at the URL below:
# https://www.mvanga.com/blog/basic-music-theory-in-200-lines-of-python
# MIT License
#
# Copyright (c) 2021 Manohar Vanga
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@hanchang
hanchang / insert-signature-in-pdf.md
Created September 20, 2020 01:46 — forked from chrpinedo/insert-signature-in-pdf.md
How to insert your signature in a PDF file by using PDFtk

How to insert your signature in a PDF file by using PDFtk

Your signature in all the sheets

  1. convert the signature image to PDF file
convert firma.png firma.pdf
@hanchang
hanchang / worker.js
Created July 27, 2020 05:10 — forked from maxkostinevich/worker.js
Serverless Geolocation Service
/*
* Serverless Geolocation Service, hosted on Cloudflare Workers.
*
* Learn more at https://maxkostinevich.com/blog/serverless-geolocation
*
* (c) Max Kostinevich / https://maxkostinevich.com
*/
// https://gist.github.com/maephisto/9228207
remote: -----> SystemFonts app detected
remote: -----> Extracting fonts to /tmp/build_948df2f102ae1f666593d4fdfb9858bf/.fonts
remote: ./fonts/
remote: ./fonts/Arial Bold.ttf
remote: ./fonts/Arial.ttf
remote: ./fonts/Arial Bold Italic.ttf
remote: ./fonts/Arial Italic.ttf
remote: /usr/share/fonts: caching, new cache contents: 0 fonts, 4 dirs
remote: /usr/share/fonts/cMap: caching, new cache contents: 0 fonts, 0 dirs
remote: /usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs
@hanchang
hanchang / bobp-python.md
Last active July 29, 2019 23:47 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@hanchang
hanchang / Rolling 30 Day Correlations.ipynb
Created April 13, 2019 00:55 — forked from anthonytxie/Rolling 30 Day Correlations.ipynb
Rolling 30 Day Correlations between BTC & BCH
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.