Skip to content

Instantly share code, notes, and snippets.

View haxpor's full-sized avatar
🤓
Some of my financial tools https://www.mql5.com/en/users/haxpor/seller

Wasin Thonkaew haxpor

🤓
Some of my financial tools https://www.mql5.com/en/users/haxpor/seller
View GitHub Profile
@haxpor
haxpor / WindowSnapping.ahk
Last active September 21, 2024 11:26
Current active window snapping window to top or bottom half of the screen with Windows+Shift+Up/Down working with API v.1.1 of AutoKey (but works with Autokey latest version from its download). From upstream https://superuser.com/a/1856438/466443
; ----------
; Move window up (Windows + Shift + UP)
+#Up::
target_monitor := 2
SysGet, MonitorCount, MonitorCount
; get current active window
WinGetPos, curr_win_x, curr_win_y, curr_win_width, curr_win_height, A
@haxpor
haxpor / poisoned.rs
Last active May 1, 2022 06:26
attempt to bypass poisoned mutex (not work yet)
macro_rules! serial_test {
(fn $name: ident() $body: block) => {
#[test]
fn $name() {
let guard = LOCK.try_lock();
if let Ok(mutex) = guard {
$body
}
else {
let err = guard.unwrap_err();
@haxpor
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.
#!/bin/bash
### BEGIN INIT INFO
# 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
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)
[Unit]
Description=My systemd service
After=network.target
# allow cap of 4 attempts to start the process
# within 1 second, if not success, then give up
StartLimitIntervalSec=1
StartLimitBurst=4
[Service]
@haxpor
haxpor / wss_sub_rustweb3.rs
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;
#[tokio::main]
async fn main() -> web3::contract::Result<()> {
@haxpor
haxpor / cargo_run_example.md
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.

[[example]]
name = "json"
required-features = ["json", "serde/derive"]
@haxpor
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
haxpor / example.rs
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
#[derive(Debug)]
struct Token(usize, usize);
fn main() {
let token = Token(1, 2);
println!("{} {}", token.0, token.1);
}
@haxpor
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 https://github.com/haxpor/hashmap_c
$ make clean
rm -f test/tests
test -z "libhashmap_c.la" || rm -f libhashmap_c.la
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
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 <[email protected]>
XSBC-Original-Maintainer: Alessandro Ghedini <[email protected]>
Build-Depends: debhelper (>= 12),
autoconf,
automake,
ca-certificates,
dh-exec,