Skip to content

Instantly share code, notes, and snippets.

View soda92's full-sized avatar

Maple soda92

View GitHub Profile
@soda92
soda92 / runfile.ps1
Last active March 14, 2022 06:55
Useful script for compiling and running java
# Environment: PowerShell 7
# Install: put runfile.ps1 in project directory
# create subdirectory lib
# download and put the algs4.jar in lib subdirectory
# Usage:
# it will auto detect args or file as input
# .\runfile.ps1 HelloWorld.java <- no argument or input
# .\runfile.ps1 HelloGoodbye.java aa bb <- passing args aa and bb
# .\runfile.ps1 RandomWord.java <- interactive run (read from stdin)
gcc -c -Wall -Werror -fPIC lib.c
gcc -shared -o lib.dll lib.o
@soda92
soda92 / pointer.c
Created April 27, 2022 05:28
python ctype pointer cast
#include <stdio.h>
#include <stdbool.h>
int main()
{
int t = 0xaabbccdd;
bool * p = (bool *)&t;
printf("%x\n", *p);
printf("%x\n", *(p+1));
printf("%x\n", *(p+2));
printf("%x\n", *(p+3));
@soda92
soda92 / telegram_python_execution_bot.py
Last active May 28, 2022 09:09
telegram python execution bot
import asyncio
import datetime
import os
import sys
import traceback
from typing import Tuple
from telethon.sync import TelegramClient, events
@soda92
soda92 / win_udp.cpp
Created November 21, 2022 14:57
Sending Udp multicast on Windows
extern "C" {
#include <winsock2.h>
}
// https://en.wikipedia.org/wiki/Multicast_address
int main()
{
auto wsaData = WSAData {};
WSAStartup(MAKEWORD(2, 0), &wsaData);
auto sock = socket(AF_INET, SOCK_DGRAM, 0);
@soda92
soda92 / fonts.conf
Created September 25, 2024 00:05 — forked from rydesun/fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<!-- Default system-ui fonts -->
<match target="pattern">
<test name="family">
<string>system-ui</string>
</test>
<edit name="family" mode="prepend" binding="strong">
@soda92
soda92 / settings.json
Last active October 10, 2024 13:48
How to set rust-analyzer extension to use MSYS2 environment in VSCode
{
"rust-analyzer.server.extraEnv": {
"PATH": "C:/msys64/ucrt64/bin"
},
"terminal.integrated.profiles.windows": {
// ...
"MSYS2": {
"path": "C:\\msys64\\usr\\bin\\fish.exe",
"args": [
"--login",
@soda92
soda92 / covert.md
Created October 10, 2024 14:02
convert mouse cursor image to left-handed (horizontally flip) using python

Recently I find that Windows mouse cursor is not very friently for left-handed people. Because it point from right to left.

So I wonder if there is a way to change it to "left to right". I searched the internet but havnen't found one.

Further search give me a message that the "cur" file format is a derivation of the "ico" format: https://en.wikipedia.org/wiki/ICO_(file_format)

So I think if we can flip it programatically.

Currently I can use these steps to modify one image:

@soda92
soda92 / swap_mouse.ps1
Created October 31, 2024 02:15
Swap mouse button, put this in $profile
# PowerShell script to swap mouse buttons for left-handed mouse users.
# (Make right mouse button the primary button...)
$swapButtons = Add-Type -MemberDefinition @'
[DllImport("user32.dll")]
public static extern bool SwapMouseButton(bool swap);
'@ -Name "NativeMethods" -Namespace "PInvoke" -PassThru
function swapleft {
@soda92
soda92 / error.txt
Created November 5, 2024 08:06
Tebaco errors
[ 53%] Building CXX object test/CMakeFiles/core-test.dir/core-test.cc.obj
CMake Error at C:/Users/fts-guest-05600/.tebako/deps/src/_dwarfs_wr/deps/lib/cmake/gflags/gflags-config.cmake:107 (message):
Your gflags installation does not contain a gflags_nothreads_static library
target! Try a different combination of GFLAGS_SHARED and GFLAGS_NOTHREADS.
Call Stack (most recent call first):
CMakeLists.txt:82 (find_package)