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 / attempts.md
Last active August 9, 2021 22:11
Guideline to cross-compile CMake that also includes ccmake for Windows on Ubuntu Linux

There are 3 attempts used

  1. Cross-compile CMake with mingw64 + pre-built mingw64 ncurses - See cmake_crosscompile_mingw64_ncurses.md
  2. Cross-compile both CMake and pdcurses with mingw64 - See cmake_crosscompile_mingw64_pdcurses.md (Recommended)
  3. Natively compile CMake and pdcurses with MSVC - See cmake_native_cmake_pdcurses.md

All above 3 attempts shared the common steps but still listing such shared content in each of its own guide for reference and clear guideline.

Problem

@haxpor
haxpor / cmake_v3.20.5_pdcurses_msvc.patch
Created August 8, 2021 23:52
Patch for compile both CMake and PDCurses with MSVC
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2fcf2e372..9d2a8f20da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -656,15 +656,10 @@ macro (CMAKE_BUILD_UTILITIES)
endif()
#---------------------------------------------------------------------
- # Use curses?
- if (UNIX)
@haxpor
haxpor / cmake_mingw64_v3.20.5.patch
Last active August 8, 2021 11:53
Patch to compile CMake from source for specific version v3.20.5 via mingw64 to work with pre-built mingw64 of ncurses
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2fcf2e372..4b78f9ee01 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -656,6 +656,9 @@ macro (CMAKE_BUILD_UTILITIES)
endif()
#---------------------------------------------------------------------
+ set(CURSES_INCLUDE_PATH "/usr/x86_64-w64-mingw32/include/ncursesw")
+ set(CURSES_LIBRARY "/usr/x86_64-w64-mingw32/lib/libncursesw.a;/usr/x86_64-w64-mingw32/lib/libformw.a")
@haxpor
haxpor / open_or_split.sh
Last active June 25, 2021 04:17
Work with terminal application to open target file via vim
#!/bin/bash
# From https://pastebin.com/XSuXNJZs by StingyKarmaWhore and u/yramagicman (upstream https://www.reddit.com/r/godot/comments/b7ad4u/open_terminalvim_from_godot/eqtavz1/)
# Modifed by haxpor: auto read from external changes, getting rid of line, and properly target an existing file on server
[ -n "$1" ] && server=$1
[ -n "$2" ] && file=$2
serverlist=`echo $(vim --serverlist)`
echo ${serverlist,,}
if [[ ${serverlist,,} == *"${server,,}"* ]]; then
vim +'set autoread|au CursorHold * checktime' --servername $server --remote-tab-silent $file
@haxpor
haxpor / .config
Created June 6, 2021 11:54
From `cat /lib/modules/$(uname -r)/build/.config` while running with 5.8.0-50-generic kernel on Ubuntu 20.04. Official ubuntu kernel package.
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.8.0-50-generic Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=90300
CONFIG_LD_VERSION=234000000
CONFIG_CLANG_VERSION=0
CONFIG_CC_CAN_LINK=y
@haxpor
haxpor / do.sh
Created March 27, 2021 23:29
Script updated to make it work withROCm 4.1.x for Ubuntu 20.04 (tested with kernel 5.8.0-48). See context for older version at https://www.youtube.com/watch?v=CcaNLC1IIw8
#/bin/bash
# Original by tuxutku (https://gist.github.com/tuxutku/79daa2edca131c1525a136b650cdbe0a)
# Modified by haxpor (based also on older version tha work with ROcm 3.3 at https://gist.github.com/haxpor/8533fde401853615f4b2e4510048a319)
# This version with following changes
# - support ROCm 4.1.x for Ubuntu 20.04 (tested with kernel 5.8.0-48-generic)
# - improved to not re-download a driver package again unncessary
# - early exit with error if found error
# - refactor misc code
prefix='amdgpu-pro-'
@haxpor
haxpor / listchars_in_vimrc.txt
Created March 25, 2021 21:09
My listchars configuration in .vimrc file
set listchars=eol:↓,space:·,trail:●,tab:→⇥⇥,extends:>,precedes:<
@haxpor
haxpor / .tmux.conf
Created February 20, 2021 10:24
My ~/.tmux.conf
# change prefix key to alt+a
set-option -g prefix M-a
# shorten the key repeat interval
set-option -g repeat-time 200
# to not lose the color when enter into tmux
set -g default-terminal "screen-256color"
# bind switching to panel with vim's motion keys
@haxpor
haxpor / .slate
Created July 7, 2015 20:38
slate config file
# This is the default .slate file.
# If no ~/.slate file exists this is the file that will be used.
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
# Resize Bindings
bind right:alt resize +10% +0
bind left:alt resize -10% +0
@haxpor
haxpor / skeleton.cpp
Last active July 2, 2020 03:47
Skeleton code for sdl
#include <SDL2/SDL.h>
#include <iostream>
// screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
SDL_Window* gWindow = NULL;
SDL_Renderer* gRenderer = NULL;