Skip to content

Instantly share code, notes, and snippets.

View phlash's full-sized avatar
🐠
staring at my fish instead of coding...

Phil Ashby phlash

🐠
staring at my fish instead of coding...
View GitHub Profile
@phlash
phlash / Makefile
Created September 12, 2021 21:52
Linux - finding the executable path reliably (no /proc, invalid argv[0] from caller)
# Build/test findme program
all: tests
clean:
@rm -rf fakeme findme
tests: bins
@echo '--- Run directly from the shell, relative location ---'
./findme
@phlash
phlash / Makefile
Created September 8, 2021 00:48
Obtaining a pointer directly to a virtual member function in a C++ class
# Build disp and dump some info
disp: disp.cc
g++ -o $@ -no-pie $<
dump: disp
./disp
nm disp |fgrep DoThing
@phlash
phlash / Ick.java
Created March 2, 2018 21:53
Self-executing single-file Java programs...
#!/bin/sh
# This self-executing Java program uses the following /embedded shell script/ to compile & execute itself..
# magic constant holding length of script
SKIP=26
# parse our name..
FILE=`basename $0 .java`
# get some working space, clean up old crud