Skip to content

Instantly share code, notes, and snippets.


Wasin Thonkaew haxpor

View GitHub Profile
haxpor /
Created Jan 15, 2017
Blender Python script to create a new cube, rename it along with set its to new location
import bpy
def strVector3( v3 ):
return str(v3.x) + "," + str(v3.y) + "," + str(v3.z)
# create a new cube
# newly created cube will be automatically selected
cube = bpy.context.selected_objects[0]
haxpor /
Created Mar 25, 2022
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 May 1, 2022
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 / zhbuild
Last active Apr 27, 2022
A handy shell (bash) script to manage (build, export build setting, and deploy) Zombie Hero project
View zhbuild
## A simple shell script to build Zombie Hero Project from command line
## It involves using the following programs
## 1. xcodebuild
## 2. ios-deploy
## Commands support (*specific for this script and project)
haxpor / sysupdown
Created Apr 7, 2022
rc script to execute command(s) when system is up or down. Note the header lines which is required to have.
View sysupdown
# 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 Apr 6, 2022
Guideline and note on crafting out a minimal long running process via systemd config file (sweat and tears in the process)
View template_systemd.conf
Description=My systemd service
# allow cap of 4 attempts to start the process
# within 1 second, if not success, then give up
haxpor / SimpleDownloaders_future.cpp
Last active Apr 5, 2022
C++ studying of parallel + multithreading (c++11) following with some differences. Compile with "g++ -std=c++11 SimpleDownloader.cpp -lpthread -lcurl"
View SimpleDownloaders_future.cpp
/** Downloader app following but
* use libcurl (C API) with some adjusted API usage.
* Compile with
* g++ -std=c++11 -DNO_PROXY SimpleDownloader.cpp -lpthread -lcurl
* */
#include <iostream>
#include <fstream>
#include <string>
haxpor /
Last active Mar 17, 2022
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 Mar 6, 2022
Processed with jq for json data returned from liquidation websocket of bybit - dev purpose
View liquidation.json
"topic": "liquidation.BTCUSD",
"data": {
"symbol": "BTCUSD",
"side": "Buy",
"price": "38931.50",
"qty": "50000",
"time": 1646584807379
haxpor /
Created Mar 2, 2022
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);