Skip to content

Instantly share code, notes, and snippets.

@depressed-pho
depressed-pho / Makefile
Last active April 14, 2024 04:13
I thought there was an issue in TLS handling but it doesn't reproduce with this code...
.PHONY: run
run: dlopen-tls-test libtls.so
./dlopen-tls-test
.PHONY: clean
clean:
rm -f dlopen-tls-test *.so
dlopen-tls-test: main.c
cc -o $@ main.c
@depressed-pho
depressed-pho / Makefile
Last active January 15, 2023 15:15
Binutils 2.39 on NetBSD-current
gnu-stack: merged.o
cc -o $@ merged.o
@{ readelf -e $@ | grep -A1 GNU_STACK; } || echo " $@ has no .note.GNU-stack"
merged.o: main.o sub.o sub2.o
ld -r -o $@ main.o sub.o sub2.o
@{ readelf -e $@ | grep -A1 GNU-stack; } || echo " $@ has no .note.GNU-stack"
.s.o:
cc -o $@ -c $<
@depressed-pho
depressed-pho / mmap-with-hint.c
Last active February 17, 2022 07:47
NetBSD: hinted mmap(2) without MAP_FIXED gives up too early
% uname -a
NetBSD yukari.cielonegro.org 9.2 NetBSD 9.2 (GENERIC) #1: Wed Nov 24 12:01:38 JS
T 2021 [email protected]:/home/pho/sysbuild/amd64/obj/usr/src/sys/arch/
amd64/compile/GENERIC amd64
% ./a.out
page size: 4096 octets
length: 4096000 octets
mmap #0 succeeded: got 0x40000000
mmap #1 succeeded: got 0x3fc18000
mmap #2 succeeded: got 0x3f830000

GregTech 5U :: Deuterium-Tritium Fusion Cycle

Ingredients

Deuterium

2000L of Hydrogen can be produced by electrolyzing 3000L of Water at 30 EU/t (LV) taking 100s (2000 ticks). This consumes 60,000 EU per 2,000L so 30 EU/L.

Mechanical Trader Mod

Nobody has ever seen Villagers replenishing their stock. Experiments have shown that they are in fact magical beings that can do some sort of alchemy in their body, transforming mundane things like pumpkins into highly valuable emeralds. They just can't create gems out of thin air. So why not exploit their property without getting (too) bothered by their annoyance?

@depressed-pho
depressed-pho / example
Last active April 9, 2017 12:35
A bash script to manage MCPE data directory mounted on PC
% mcpe-managa-data
You have 31 worlds, 1 world templates, 20 resource packs, and 2 behavior packs.
What do you want to do?
[w]: Manage worlds [t]: Manage templates [r]: Manage resource packs
[b]: Manage behavior packs [B]: Manage backups [q]: Quit
> w
Searching for worlds...
You have 31 worlds. What do you want to do?
[l]: List worlds [e]: Export a world [q]: Return to the main menu
> l
@depressed-pho
depressed-pho / Tarai.hs
Created October 30, 2014 05:24
Tarai function in Haskell
main :: IO ()
main = print (tarai 13 8 0)
 
tarai :: Int -> Int -> Int -> Int
tarai x y z
| x <= y = y
| otherwise = tarai (tarai (x-1) y z)
(tarai (y-1) z x)
(tarai (z-1) x y)
@depressed-pho
depressed-pho / erl-after.log
Last active December 17, 2015 09:39
Bug: httpc's {stream, {self, once}} is not working.
bash-3.2$ erl
Erlang R16B (erts-5.10.1) [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.1 (abort with ^G)
1> inets:start(),
1> inets_trace:enable(max, "/tmp/inets.log"),
1> Opts = [{sync, false}, {stream, {self, once}}, {body_format, binary}],
1> URL = "http://www.erlang.org/",
1> {ok, ReqId} = httpc:request(get, {URL, []}, [], Opts).
{ok,#Ref<0.0.0.45>}
@depressed-pho
depressed-pho / Makefile
Created April 4, 2013 05:18
Old binutils fails to link a shared library if there is a reference to a hidden symbol that isn't locally defined.
all:
ld -v
gcc -fPIC -o caller.o -c caller.c
gcc -fPIC -o callee.o -c callee.c
gcc -shared -o libfoo.so caller.o callee.o
clean:
rm -f *.o *.so
@depressed-pho
depressed-pho / i386-unknown-freebsd8.0.txt
Last active December 14, 2015 23:59
kqueue-poll-select
% uname -a
FreeBSD nem.cielonegro.org 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Tue Jan 5 16:02:27 UTC 2010 [email protected]:/usr/obj/usr/src/sys/GENERIC i386
% ./kqueue-poll-select
Testing stdin...
Type of stdin: tty
Checking if kqueue(2) works...
Great. kevent(2) successfully handled your stdin.
Checking if poll(2) works...