Skip to content

Instantly share code, notes, and snippets.

View soda92's full-sized avatar

Maple soda92

View GitHub Profile
@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));
gcc -c -Wall -Werror -fPIC lib.c
gcc -shared -o lib.dll lib.o
@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)