Skip to content

Instantly share code, notes, and snippets.

@depressed-pho
depressed-pho / fibonacci.sh
Created April 17, 2012 07:44
Fibonacci series in /bin/sh
#!/bin/sh
fibonacci_init() {
_fib_0=1
_fib_1=1
_fib_2=1
_fib_n=0
}
fibonacci_next() {
@depressed-pho
depressed-pho / colours.sh
Created April 18, 2012 05:23
Manipulating ANSI colour sequences in Bash
#!/usr/bin/env bash
#
# Example:
#
# . colours.sh
#
# setColour bold underline green:black
# echo "Hello, world!"
# setColour reset
#
@depressed-pho
depressed-pho / HsOpenSSL-touch-SSLContext-on-withSSL.patch
Created October 2, 2012 17:44
HsOpenSSL: touch SSLContext on withSSL
diff --git a/OpenSSL/Session.hsc b/OpenSSL/Session.hsc
index de054fe..c4637e6 100644
--- a/OpenSSL/Session.hsc
+++ b/OpenSSL/Session.hsc
@@ -319,7 +319,9 @@ fdConnection :: SSLContext -> Fd -> IO SSL
fdConnection context fd = connection' context fd Nothing
withSSL :: SSL -> (Ptr SSL_ -> IO a) -> IO a
-withSSL = withMVar . sslMVar
+withSSL ssl f = do a <- withMVar (sslMVar ssl) f
@depressed-pho
depressed-pho / config.h
Created January 16, 2013 13:32
AC_SYS_LARGEFILE bug
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "[email protected]"
/* Define to the full name of this package. */
#define PACKAGE_NAME "ac-sys-largefile-bug"
/* Define to the full name and version of this package. */
@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...
@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 / 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 / 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 / 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

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?