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 / setWebhook-telegram.txt
Last active April 6, 2024 12:00
How to set webhook url for bot on Telegram
https://api.telegram.org/bot<bot-token>/setWebhook?url=<webhook-url>
<bot-token> - bot token get from BotFather on Telegram
<webhook-url> - webhook url in base64
  • list packages adb shell pm list packages -f
  • delegate package adb shell am start -a android.intent.action.DELETE -d package:
@haxpor
haxpor / assert.c
Created November 3, 2018 19:27
Example of assert.c with -DNDEBUG compile flag. Try to compile with `gcc -DNDEBUG assert.c` and `gcc assert.c` to see differences.
#include <stdio.h>
#include <assert.h>
int main(int argc, char* argv[])
{
int a = 10;
assert(a != 10);
printf("end of program\n");
return 0;
}
@haxpor
haxpor / renderdriver.c
Last active October 10, 2023 00:42
Getting rendering driver name and setting hint in SDL2. Minimal testing code. This code tested on macOS mojave.
#include <SDL2/SDL.h>
#include <stdio.h>
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
SDL_Log("failed to init: %s", SDL_GetError());
@haxpor
haxpor / skeleton.cpp
Last active March 11, 2023 12:13
OpenGL with SDL2. Compile it with "gcc -Wall -o skeleton skeleton.cpp -F /Library/Frameworks -lstdc++ -I /Library/Frameworks/SDL2.framework/Headers -framework SDL2 -framework OpenGL" on Mac OSX.
/**
* Simple SDL2 program using OpenGL as rendering pipeline.
*/
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <OpenGL/GLU.h>
#define SCREEN_WIDTH 640
@haxpor
haxpor / note.log
Created October 17, 2018 14:29
Note from Mastering Vim Language By Chris Toomey without plugins section at around 12 minutes at the end
* dw - delete word
* . - to repeat changes
* u - undo changes (atomic operation)
* verbs in vim
- d => delete
- c => change
- > => indent
- v => visually select
- y => yank (copy)
* cw - delete and get into insert mode
@haxpor
haxpor / blender_cube_creation.py
Created January 15, 2017 17:38
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
bpy.ops.mesh.primitive_cube_add()
# newly created cube will be automatically selected
cube = bpy.context.selected_objects[0]
@haxpor
haxpor / AppDelegate.js
Created August 29, 2012 15:31
Example to scale content to fit the current screen resolution with the option to recieve "width" and "height" from external or from browser's available client screen.
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
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
@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 / 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();