Skip to content

Instantly share code, notes, and snippets.

View haxpor's full-sized avatar
Some of my financial tools

Wasin Thonkaew haxpor

Some of my financial tools
View GitHub Profile
haxpor /
Last active May 1, 2022 06:26
attempt to bypass poisoned mutex (not work yet)
macro_rules! serial_test {
(fn $name: ident() $body: block) => {
fn $name() {
let guard = LOCK.try_lock();
if let Ok(mutex) = guard {
else {
let err = guard.unwrap_err();
haxpor / sysupdown
Created April 7, 2022 03:56
rc script to execute command(s) when system is up or down. Note the header lines which is required to have.
# Provides: <your service name>
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 6
# Short-Description: execute commands when system is up or down
# Description: execute commands when system is up or down
haxpor / template_systemd.conf
Created April 6, 2022 18:10
Guideline and note on crafting out a minimal long running process via systemd config file (sweat and tears in the process)
Description=My systemd service
# allow cap of 4 attempts to start the process
# within 1 second, if not success, then give up
haxpor /
Created March 25, 2022 00:33
Example of using rust-web3 crate to listen to certain event as emitted from target contract.
use hex_literal::hex;
use web3::{
contract::{Contract, Options},
futures::{future, StreamExt},
types::{FilterBuilder, Address},
use std::str::FromStr;
async fn main() -> web3::contract::Result<()> {
haxpor /
Last active March 17, 2022 13:17
Rust with cargo on how to run example in the rust project.

Run with cargo run --example <example-name>.

In Cargo.toml, configure it with the following if each example needs special crate's features.

name = "json"
required-features = ["json", "serde/derive"]
haxpor / liquidation.json
Created March 6, 2022 16:42
Processed with jq for json data returned from liquidation websocket of bybit - dev purpose
"topic": "liquidation.BTCUSD",
"data": {
"symbol": "BTCUSD",
"side": "Buy",
"price": "38931.50",
"qty": "50000",
"time": 1646584807379
haxpor /
Created March 2, 2022 18:50
Use .0 .1 and so on to access unnamed field from the specified arguments to one-line struct declaration
struct Token(usize, usize);
fn main() {
let token = Token(1, 2);
println!("{} {}", token.0, token.1);
haxpor / make_clean.log
Created November 6, 2021 20:30
Compare the coverage of removal of files between `make clean` and `make distclean`. The latter has more coverage. Tested against my project
$ make clean
rm -f test/tests
test -z "" || rm -f
rm -f ./so_locations
rm -rf .libs _libs
rm -rf externals/MurmurHash3/src/.libs externals/MurmurHash3/src/_libs
rm -rf src/.libs src/_libs
rm -rf test/.libs test/_libs
rm -f *.o
rm -f externals/MurmurHash3/src/*.o
haxpor / control
Last active November 6, 2021 12:28
Verbatim copy of content important configurations files for PPA package for libcurl4-openssl-dev. This is for research purpose.
Source: curl
Section: web
Priority: optional
Maintainer: Ubuntu Developers <>
XSBC-Original-Maintainer: Alessandro Ghedini <>
Build-Depends: debhelper (>= 12),
haxpor / successful-sdl2-manpage_ppa.log
Created November 4, 2021 12:53
Succesful PPA package build for my sdl2-manpage
Copy verbatim from
RUN: /usr/share/launchpad-buildd/bin/builder-prep
Kernel version: Linux lgw01-amd64-026 4.15.0-161-generic #169-Ubuntu SMP Fri Oct 15 13:41:54 UTC 2021 x86_64
Buildd toolchain package versions: launchpad-buildd_203~505~ubuntu18.04.1 python3-lpbuildd_203~505~ubuntu18.04.1 sbuild_0.75.0-1ubuntu1 bzr-builder_0.7.3+bzr174~ppa13~ubuntu16.04.1 bzr_2.7.0+bzr6622-10 git-build-recipe_0.3.6~git201906051340.ff11471~ubuntu18.04.1 git_1:2.17.1-1ubuntu0.9 dpkg-dev_1.19.0.5ubuntu2.3 python-debian_0.1.32 python3-debian_0.1.32.
Syncing the system clock with the buildd NTP service...
4 Nov 12:34:41 ntpdate[1782]: adjust time server offset -0.000445 sec