From f5ce31404124f8cf0fcb265f9b82389fcf339a8f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 28 Mar 2026 00:01:57 +0200 Subject: Update content for html --- ...b6ffe2de2faa0100ea27a3b5b8d237fb8934c293dfc74a9 | 172 ------- ...0e722c80728d34887bad242e066320ff17119682ffdf5d2 | 41 -- ...c8a1074d627e76fa9bf9aaa54d9dbd59a106a495c02c138 | 68 --- ...e0f68d54010656f2fc707f8265377a801426e1e04351f3b | 176 ------- ...f0503c9ed61a11918e2db7b75fa0bd93a5b7402d87cce43 | 102 ---- ...39245ea4138babc12364c18bb386e7d7543fc61b8b529dc | 512 --------------------- ...e8117128b31b664f56d5c4fd0bcd6c62eca6994b9b1fa63 | 169 ------- ...ae8630218bf7929803353053b21f20d55de72dec5e3d073 | 180 -------- ...50d3650714e4f5485d943e8015f956eefabf0ad617fe617 | 396 ---------------- ...b4991d23cd55cf95cc1d66fc0abd0db147a8478d3a2177c | 239 ---------- ...a1d09327d0bcc8e2e2ecae80760ebb0d4341338c4aecf55 | 191 -------- ...2b1c0323f75427f77265ee7cf35d302e9b655eb88267d6b | 114 ----- ...7d09d0610f3a8b9ff63c8852afd8cca146767b119895f9a | 89 ---- ...0ec16c4e13131db3954e915a6c7259bf1eb7f8f15d2297e | 395 ---------------- ...98651ed83fd6328ef19314610df8b3e6347725a2951143e | 174 ------- gemfeed/2024-10-24-staff-engineer-book-notes.html | 32 +- ...4-11-17-f3s-kubernetes-with-freebsd-part-1.html | 6 +- ...4-12-03-f3s-kubernetes-with-freebsd-part-2.html | 25 +- .../2025-01-15-working-with-an-sre-interview.html | 4 +- gemfeed/2025-02-08-random-weird-things-ii.html | 10 +- gemfeed/2025-06-22-task-samurai.html | 2 +- .../2025-08-05-local-coding-llm-with-ollama.html | 2 +- ...6-01-01-cloudless-kobo-forma-with-koreader.html | 4 +- .../2026-01-01-using-supernote-nomad-offline.html | 6 +- ...-03-01-site-reliability-engineering-part-5.html | 8 +- gemfeed/atom.xml | 101 ++-- notes/staff-engineer.html | 32 +- 27 files changed, 91 insertions(+), 3159 deletions(-) delete mode 100644 gemfeed/.rcmbackup/2008-06-26-perl-poetry.gmi.tpl.49f27f3f6cfb364dfb6ffe2de2faa0100ea27a3b5b8d237fb8934c293dfc74a9 delete mode 100644 gemfeed/.rcmbackup/2008-12-29-using-my-nokia-n95-for-fixing-my-mta.gmi.8f549e73479399b4d0e722c80728d34887bad242e066320ff17119682ffdf5d2 delete mode 100644 gemfeed/.rcmbackup/2009-02-13-sgi-onyx-3200.gmi.e8c19f9d9486a1d74c8a1074d627e76fa9bf9aaa54d9dbd59a106a495c02c138 delete mode 100644 gemfeed/.rcmbackup/2010-04-09-standard-ml-and-haskell.gmi.tpl.94827a5494a2149e0e0f68d54010656f2fc707f8265377a801426e1e04351f3b delete mode 100644 gemfeed/.rcmbackup/2010-05-07-lazy-evaluation-with-standard-ml.gmi.f3bdd7120c249354bf0503c9ed61a11918e2db7b75fa0bd93a5b7402d87cce43 delete mode 100644 gemfeed/.rcmbackup/2010-05-09-the-fype-programming-language.gmi.tpl.9797b465fab8bb78c39245ea4138babc12364c18bb386e7d7543fc61b8b529dc delete mode 100644 gemfeed/.rcmbackup/2011-05-07-perl-daemon-service-framework.gmi.tpl.62ef757776fbb71d8e8117128b31b664f56d5c4fd0bcd6c62eca6994b9b1fa63 delete mode 100644 gemfeed/.rcmbackup/2015-12-05-run-debian-on-your-phone-with-debroid.gmi.tpl.6b6aaeb972eb69a3fae8630218bf7929803353053b21f20d55de72dec5e3d073 delete mode 100644 gemfeed/.rcmbackup/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi.tpl.221f1043b07e8b62c50d3650714e4f5485d943e8015f956eefabf0ad617fe617 delete mode 100644 gemfeed/.rcmbackup/2016-05-22-spinning-up-my-own-authoritative-dns-servers.gmi.tpl.ae0939420799accbfb4991d23cd55cf95cc1d66fc0abd0db147a8478d3a2177c delete mode 100644 gemfeed/.rcmbackup/2018-06-01-realistic-load-testing-with-ioriot-for-linux.gmi.tpl.7f5d7ea30eb225959a1d09327d0bcc8e2e2ecae80760ebb0d4341338c4aecf55 delete mode 100644 gemfeed/.rcmbackup/2021-04-22-dtail-the-distributed-log-tail-program.gmi.tpl.f52534829ec99bc552b1c0323f75427f77265ee7cf35d302e9b655eb88267d6b delete mode 100644 gemfeed/.rcmbackup/2021-04-24-welcome-to-the-geminispace.gmi.tpl.13614cbbfbbb35af77d09d0610f3a8b9ff63c8852afd8cca146767b119895f9a delete mode 100644 gemfeed/.rcmbackup/2021-05-16-personal-bash-coding-style-guide.gmi.tpl.d38b7b180488f50c00ec16c4e13131db3954e915a6c7259bf1eb7f8f15d2297e delete mode 100644 gemfeed/.rcmbackup/2021-06-05-gemtexter-one-bash-script-to-rule-it-all.gmi.tpl.48552bc263f579a1f98651ed83fd6328ef19314610df8b3e6347725a2951143e diff --git a/gemfeed/.rcmbackup/2008-06-26-perl-poetry.gmi.tpl.49f27f3f6cfb364dfb6ffe2de2faa0100ea27a3b5b8d237fb8934c293dfc74a9 b/gemfeed/.rcmbackup/2008-06-26-perl-poetry.gmi.tpl.49f27f3f6cfb364dfb6ffe2de2faa0100ea27a3b5b8d237fb8934c293dfc74a9 deleted file mode 100644 index bb16451a..00000000 --- a/gemfeed/.rcmbackup/2008-06-26-perl-poetry.gmi.tpl.49f27f3f6cfb364dfb6ffe2de2faa0100ea27a3b5b8d237fb8934c293dfc74a9 +++ /dev/null @@ -1,172 +0,0 @@ -# Perl Poetry - -> Published at 2008-06-26T21:43:51+01:00; Updated at 2021-05-04 - -Here are some Perl Poems I wrote. They don't do anything useful when you run them, but they don't produce a compiler error either. They only exist for fun and demonstrate what you can do with Perl syntax. - -Wikipedia: "Perl poetry is the practice of writing poems that can be compiled as legal Perl code, for example the piece known as Black Perl. Perl poetry is made possible by the large number of English words that are used in the Perl language. New poems are regularly submitted to the community at PerlMonks." - -=> https://en.wikipedia.org/wiki/Perl - -``` - '\|/' * --- * ----- - /|\ ____ - ' | ' {_ o^> * - : -_ /) - : ( ( .-''`'. - . \ \ / \ - . \ \ / \ - \ `-' `'. - \ . ' / `. - \ ( \ ) ( .') - ,, t '. | / | ( - '|``_/^\___ '| |`'-..-'| ( () -_~~|~/_|_|__/|~~~~~~~ | / ~~~~~ | | ~~~~~~~~ - -_ |L[|]L|/ | |\ MJP ) ) - ( |( / /| - ~~ ~ ~ ~~~~ | /\\ / /| | - || \\ _/ / | | - ~ ~ ~~~ _|| (_/ (___)_| |Nov291999 - (__) (____) -``` - -<< template::inline::toc - -## math.pl - -```perl -#!/usr/bin/perl - -# (C) 2006 by Paul C. Buetow - -goto library for study $math; -BEGIN { s/earching/ books/ -and read $them, $at, $the } library: - -our $topics, cos and tan, -require strict; import { of, tied $patience }; - -do { int'egrate'; sub trade; }; -do { exp'onentize' and abs'olutize' }; -study and study and study and study; - -foreach $topic ({of, math}) { -you, m/ay /go, to, limits } - -do { not qw/erk / unless $success -and m/ove /o;$n and study }; - -do { int'egrate'; sub trade; }; -do { exp'onentize' and abs'olutize' }; -study and study and study and study; - -grep /all/, exp'onents' and cos'inuses'; -/seek results/ for @all, log'4rithms'; - -'you' =~ m/ay /go, not home -unless each %book ne#ars -$completion; - -do { int'egrate'; sub trade; }; -do { exp'onentize' and abs'olutize' }; - -#at -home: //ig,'nore', time and sleep $very =~ s/tr/on/g; -__END__ - -``` - -## christmas.pl - -```perl -#!/usr/bin/perl - -# (C) 2006 by Paul C. Buetow - -Christmas:{time;#!!! - -Children: do tell $wishes; - -Santa: for $each (@children) { -BEGIN { read $each, $their, wishes and study them; use Memoize#ing - -} use constant gift, 'wrapping'; -package Gifts; pack $each, gift and bless $each and goto deliver -or do import if not local $available,!!! HO, HO, HO; - -redo Santa, pipe $gifts, to_childs; -redo Santa and do return if last one, is, delivered; - -deliver: gift and require diagnostics if our $gifts ,not break; -do{ use NEXT; time; tied $gifts} if broken and dump the, broken, ones; -The_children: sleep and wait for (each %gift) and try { to => untie $gifts }; - -redo Santa, pipe $gifts, to_childs; -redo Santa and do return if last one, is, delivered; - -The_christmas_tree: formline s/ /childrens/, $gifts; -alarm and warn if not exists $Christmas{ tree}, @t, $ENV{HOME}; -write < $sell }; -for $their (@business) { to:; earn:; a:; lot:; of:; money: } - -do not goto home and exit mall if exists $new{product}; -foreach $of (q(uality rich products)){} package products; - -our $news; do tell cool products() and do{ sub#tract -cool{ $products and shift @the, @bad, @ones; - -do bless [q(uality)], $products -and return not undef $stuff if not (local $available) }}; - -do { study and study and study for cool products() } -and do { seek $all, cool products(), { to => $buy } }; - -do { write $them, $down } and do { order: foreach (@case) { package s } }; -goto home if not exists $more{money} or die q(uerying) ;for( @money){}; - -at:;home: do { END{} and:; rest:; a:; bit: exit $shopping } -and sleep until unpack$ing, cool products(); - -__END__ -This is perl, v5.8.8 built for i386-freebsd-64int -``` - -## More... - -Did you like what you saw? Have a look at Codeberg to see my other poems too: - -=> https://codeberg.org/snonux/perl-poetry - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -Other related posts are: - -<< template::inline::rindex perl - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2008-12-29-using-my-nokia-n95-for-fixing-my-mta.gmi.8f549e73479399b4d0e722c80728d34887bad242e066320ff17119682ffdf5d2 b/gemfeed/.rcmbackup/2008-12-29-using-my-nokia-n95-for-fixing-my-mta.gmi.8f549e73479399b4d0e722c80728d34887bad242e066320ff17119682ffdf5d2 deleted file mode 100644 index 33484e6c..00000000 --- a/gemfeed/.rcmbackup/2008-12-29-using-my-nokia-n95-for-fixing-my-mta.gmi.8f549e73479399b4d0e722c80728d34887bad242e066320ff17119682ffdf5d2 +++ /dev/null @@ -1,41 +0,0 @@ -# Using my Nokia N95 for fixing my MTA - -> Published at 2008-12-29T09:10:41+00:00; Updated at 2021-12-01 - -``` - - _ - |E] - .-|=====-. - | | mail | - ___|________| - || - || - || www - ,;, || )_(,;;;, - <_> \ || \|/ \_/ - \|/ \\|| \\| |// -_jgs_\|//_\\|///_\V/_\|//__ - Art by Joan Stark -``` - -The last week I was in Vidin, Bulgaria with no internet access and I had to fix my MTA (Postfix) at host.0.buetow.org which serves E-Mail for all my customers at P. B. Labs. Good, that I do not guarantee high availability on my web services (I've to do a full time job somewhere else too). - -My first attempt to find an internet café, which was working during Christmastime, failed. However, I found with my N95 phone lots of free WLAN hotspots. The hotspots refused me logging into my server using SSH as I have configured a non-standard port for SSH for security reasons. Without knowing the costs, I used the GPRS internet access of my German phone provider (yes, I had to pay roaming fees). - -=> ./using-my-nokia-n95-for-fixing-my-mta/nokia-n95.jpg Picture of a Nokia N95 - -With Putty for N95 and configuring Postfix with Vim and the T9 input mechanism, I managed to fix the problem. But it took half of an hour: - -* First, getting a shell prompt -* Second, use the "tail" command to analyse the Postfix logs -* Third, use the "sed" command to fix a syntax error in the Postfix config -* Fourth, restart Postfix - -It was a pain in the ass. My next mobile phone MUST have a full QWERTY keyboard. This would have made my life lots easier. :) - -At the moment I am in Sofia, Bulgaria. Here I can use at least an unprotected WLAN hotspot which belongs to one of the neighbours which I don’t know in person, and it is not blocking any port at all :) - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2009-02-13-sgi-onyx-3200.gmi.e8c19f9d9486a1d74c8a1074d627e76fa9bf9aaa54d9dbd59a106a495c02c138 b/gemfeed/.rcmbackup/2009-02-13-sgi-onyx-3200.gmi.e8c19f9d9486a1d74c8a1074d627e76fa9bf9aaa54d9dbd59a106a495c02c138 deleted file mode 100644 index fd10c754..00000000 --- a/gemfeed/.rcmbackup/2009-02-13-sgi-onyx-3200.gmi.e8c19f9d9486a1d74c8a1074d627e76fa9bf9aaa54d9dbd59a106a495c02c138 +++ /dev/null @@ -1,68 +0,0 @@ -# SGI Onyx 3200 - -> Published at 2025-02-13T21:17:16+02:00 - -For nostalgia, I've kept this output of the 'dmesg' around. It's from an SGI Onyx 3200 graphics supercomputer running IRIX with the following specs: - -* 4 x 400 MHz IP35 MIPS CPUs -* 4GB of RAM - -=> ./sgi-onyx-3200/desk.webp - -We used this monster when I was a student worker at the Fraunhofer Institute for Production Technology around the year 2006. It operated a walk-in 2-sided 3D cave (unfortunately, I don't have any pictures of that cave), where you could literally walk around with a set of VR glasses and see everything in 3D (that was when there wasn't any Oculus Quest yet). That was useful for running industrial simulations. - -``` -4 400 MHZ IP35 Processors -CPU: MIPS R12000 Processor Chip Revision: 3.5 -FPU: MIPS R12010 Floating Point Chip Revision: 3.5 -Main memory size: 4096 Mbytes -Instruction cache size: 32 Kbytes -Data cache size: 32 Kbytes -Secondary unified instruction/data cache size: 8 Mbytes -Integral SCSI controller 8: Version Fibre Channel QL2200A -Integral SCSI controller 6: Version QL12160, single ended -Integral SCSI controller 7: Version QL12160, low voltage differential -Integral SCSI controller 9: Version IEEE1394 SBP2 - IEEE1394 CDROM: node 1010031001a454 port 0 on SCSI controller 9 -Integral SCSI controller 0: Version Fibre Channel QL2200A - Disk drive: unit 1 on SpCSI controller 0 - Disk drive: unit 2 on SCSI controller 0 -Integral SCSI controller 5: Version IEEE1394 SBP2 - IEEE1394 CDROM: node 1010031001c080 port 0 on SCSI controller 5 -IOC3 serial port: tty3 -IOC3 serial port: tty4 -IOC3 serial port: tty10 -IOC3 serial port: tty11 -IOC3 serial port: tty12 -IOC3 serial port: tty5 -IOC3 serial port: tty6 -IOC3 serial port: tty7 -IOC3 serial port: tty8 -IOC3 serial port: tty9 -Graphics board: InfiniteReality3 -Graphics board: InfiniteReality3 -Gigabit Ethernet: eg0, module 001c04, pci_bus 2, pci_slot 2, firmware version 12.4.10 -Fast Ethernet: ef1, version 1, module 001c07, pci 4 -Integral Fast Ethernet: ef0, version 1, module 001c04, pci 4 -Iris Audio Processor: version RAD revision 13.0, number 1 -IOC3 external interrupts: 2 -IOC3 external interrupts: 1 -IEEE 1394 High performance serial bus controller 0: Type: OHCI, Version 0 0 -IEEE 1394 High performance serial bus controller 1: Type: OHCI, Version 0 0 -USB controller: type OHCI -USB Human Interface Device: device id 1 type keyboard -USB Human Interface Device: device id 1 type mouse -USB controller: type OHCI -USB Human Interface Device: device id 0 type keyboard -USB Human Interface Device: device id 0 type mouse -``` - -=> ./sgi-onyx-3200/collage.webp - -I was mainly working on drilling simulations on this machine. Sometimes I worked directly at one of the 2 terminal screens of the Onyx, or often I used a nearby Linux machine and forwarded the X11 windows to my local screen. - -=> ./sgi-onyx-3200/collage2.webp - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2010-04-09-standard-ml-and-haskell.gmi.tpl.94827a5494a2149e0e0f68d54010656f2fc707f8265377a801426e1e04351f3b b/gemfeed/.rcmbackup/2010-04-09-standard-ml-and-haskell.gmi.tpl.94827a5494a2149e0e0f68d54010656f2fc707f8265377a801426e1e04351f3b deleted file mode 100644 index a3d3ed79..00000000 --- a/gemfeed/.rcmbackup/2010-04-09-standard-ml-and-haskell.gmi.tpl.94827a5494a2149e0e0f68d54010656f2fc707f8265377a801426e1e04351f3b +++ /dev/null @@ -1,176 +0,0 @@ -# Standard ML and Haskell - -> Published at 2010-04-09T22:57:36+01:00 - -I am currently looking into the functional programming language Standard ML (aka SML). The purpose is to refresh my functional programming skills and to learn something new too. Since I already knew a little Haskell, I could not help myself, and I also implemented the same exercises in Haskell. - -As you will see, SML and Haskell are very similar (at least when it comes to the basics). However, the syntax of Haskell is a bit more "advanced". Haskell utilizes fewer keywords (e.g. no val, end, fun, fn ...). Haskell also allows to write down the function types explicitly. What I have been missing in SML so far is the so-called pattern guards. Although this is a very superficial comparison for now, so far, I like Haskell more than SML. Nevertheless, I thought it would be fun to demonstrate a few simple functions of both languages to show off the similarities. - -Haskell is also a "pure functional" programming language, whereas SML also makes explicit use of imperative concepts. I am by far not a specialist in either of these languages, but here are a few functions implemented in both SML and Haskell: - -<< template::inline::toc - -## Defining a multi-data type - -Standard ML: - -```sml -datatype ’a multi - = EMPTY - | ELEM of ’a - | UNION of ’a multi * ’a multi -``` - -Haskell: - -```haskell -data (Eq a) => Multi a - = Empty - | Elem a - | Union (Multi a) (Multi a) - deriving Show -``` - -## Processing a multi - -Standard ML: - -```sml -fun number (EMPTY) _ = 0 - | number (ELEM x) w = if x = w then 1 else 0 - | number (UNION (x,y)) w = (number x w) + (number y w) -fun test_number w = number (UNION (EMPTY, \ - UNION (ELEM 4, UNION (ELEM 6, \ - UNION (UNION (ELEM 4, ELEM 4), EMPTY))))) w -``` - -Haskell: - -```haskell -number Empty _ = 0 -number (Elem x) w = if x == w then 1 else 0 -test_number w = number (Union Empty \ - (Union (Elem 4) (Union (Elem 6) \ - (Union (Union (Elem 4) (Elem 4)) Empty)))) w -``` - -## Simplify function - -Standard ML: - -```sml -fun simplify (UNION (x,y)) = - let fun is_empty (EMPTY) = true | is_empty _ = false - val x’ = simplify x - val y’ = simplify y - in if (is_empty x’) andalso (is_empty y’) - then EMPTY - else if (is_empty x’) - then y’ - else if (is_empty y’) - then x’ - else UNION (x’, y’) - end - | simplify x = x -``` - -Haskell: - -```haskell -simplify (Union x y) - | (isEmpty x’) && (isEmpty y’) = Empty - | isEmpty x’ = y’ - | isEmpty y’ = x’ - | otherwise = Union x’ y’ - where - isEmpty Empty = True - isEmpty _ = False - x’ = simplify x - y’ = simplify y -simplify x = x -``` - -## Delete all - -Standard ML: - -```sml -fun delete_all m w = - let fun delete_all’ (ELEM x) = if x = w then EMPTY else ELEM x - | delete_all’ (UNION (x,y)) = UNION (delete_all’ x, delete_all’ y) - | delete_all’ x = x - in simplify (delete_all’ m) - end -``` - -Haskell: - -```haskell -delete_all m w = simplify (delete_all’ m) - where - delete_all’ (Elem x) = if x == w then Empty else Elem x - delete_all’ (Union x y) = Union (delete_all’ x) (delete_all’ y) - delete_all’ x = x -``` - -## Delete one - -Standard ML: - -```sml -fun delete_one m w = - let fun delete_one’ (UNION (x,y)) = - let val (x’, deleted) = delete_one’ x - in if deleted - then (UNION (x’, y), deleted) - else let val (y’, deleted) = delete_one’ y - in (UNION (x, y’), deleted) - end - end - | delete_one’ (ELEM x) = - if x = w then (EMPTY, true) else (ELEM x, false) - | delete_one’ x = (x, false) - val (m’, _) = delete_one’ m - in simplify m’ - end -``` - -Haskell: - -```haskell -delete_one m w = do - let (m’, _) = delete_one’ m - simplify m’ - where - delete_one’ (Union x y) = - let (x’, deleted) = delete_one’ x - in if deleted - then (Union x’ y, deleted) - else let (y’, deleted) = delete_one’ y - in (Union x y’, deleted) - delete_one’ (Elem x) = - if x == w then (Empty, True) else (Elem x, False) - delete_one’ x = (x, False) -``` - -## Higher-order functions - -The first line is always the SML code, the second line the Haskell variant: - -``` -fun make_map_fn f1 = fn (x,y) => f1 x :: y -make_map_fn f1 = \x y -> f1 x : y - -fun make_filter_fn f1 = fn (x,y) => if f1 x then x :: y else y -make_filter_fn f1 = \x y -> if f1 then x : y else y - -fun my_map f l = foldr (make_map_fn f) [] l -my_map f l = foldr (make_map_fn f) [] l - -fun my_filter f l = foldr (make_filter_fn f) [] l -my_filter f l = foldr (make_filter_fn f) [] l -``` - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2010-05-07-lazy-evaluation-with-standard-ml.gmi.f3bdd7120c249354bf0503c9ed61a11918e2db7b75fa0bd93a5b7402d87cce43 b/gemfeed/.rcmbackup/2010-05-07-lazy-evaluation-with-standard-ml.gmi.f3bdd7120c249354bf0503c9ed61a11918e2db7b75fa0bd93a5b7402d87cce43 deleted file mode 100644 index 738d54a8..00000000 --- a/gemfeed/.rcmbackup/2010-05-07-lazy-evaluation-with-standard-ml.gmi.f3bdd7120c249354bf0503c9ed61a11918e2db7b75fa0bd93a5b7402d87cce43 +++ /dev/null @@ -1,102 +0,0 @@ -# Lazy Evaluation with Standard ML - -> Published at 2010-05-07T08:17:59+01:00 - -``` - - _____|~~\_____ _____________ - _-~ \ | \ - _- | ) \ |__/ \ \ - _- ) | | | \ \ - _- | ) / |--| | | - __-_______________ /__/_______| |_________ -( |---- | | - `---------------'--\\\\ .`--' -Glyde- - `|||| -``` - -In contrast to Haskell, Standard SML does not use lazy evaluation by default but an eager evaluation. - -=> https://en.wikipedia.org/wiki/Eager_evaluation -=> https://en.wikipedia.org/wiki/Lazy_evaluation - - -You can solve specific problems with lazy evaluation easier than with eager evaluation. For example, you might want to list the number Pi or another infinite list of something. With the help of lazy evaluation, each element of the list is calculated when it is accessed first, but not earlier. - -## Emulating lazy evaluation in SML - -However, it is possible to emulate lazy evaluation in most eager evaluation languages. This is how it is done with Standard ML (with some play with an infinite list of natural number tuples filtering out 0 elements): - -``` -type ’a lazy = unit -> ’a; - -fun force (f:’a lazy) = f (); -fun delay x = (fn () => x) : ’a lazy; - -datatype ’a sequ = NIL | CONS of ’a * ’a sequ lazy; - -fun first 0 s = [] - | first n NIL = [] - | first n (CONS (i,r)) = i :: first (n-1) (force r); - -fun filters p NIL = NIL - | filters p (CONS (x,r)) = - if p x - then CONS (x, fn () => filters p (force r)) - else - filters p (force r); - -fun nat_pairs () = - let - fun from_pair (x,0) = - CONS ((x,0), fn () => from_pair (0,x+1)) - | from_pair (up,dn) = - CONS ((up,dn), fn () => from_pair (up+1,dn-1)) - in from_pair (0,0) - end; - -(* Test -val test = first 10 (nat_pairs ()) -*) - -fun nat_pairs_not_null () = - filters (fn (x,y) => x > 0 andalso y > 0) (nat_pairs ()); - -(* Test -val test = first 10 (nat_pairs_not_null ()); -*) -``` - -=> http://smlnj.org/ - -## Real laziness with Haskell - -As Haskell already uses lazy evaluation by default, there is no need to construct a new data type. Lists in Haskell are lazy by default. You will notice that the code is also much shorter and easier to understand than the SML version. - -``` -{- Just to make it look like the ML example -} -first = take -filters = filter - -{- Implementation -} -nat_pairs = from_pair 0 0 - where - from_pair x 0 = [x,0] : from_pair 0 (x+1) - from_pair up dn = [up,dn] : from_pair (up+1) (dn-1) - -{- Test: -first 10 nat_pairs --} - -nat_pairs_not_null = filters (\[x,y] -> x > 0 && y > 0) nat_pairs - -{- Test: -first 10 nat_pairs_not_null --} -``` - -=> http://www.haskell.org/ - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2010-05-09-the-fype-programming-language.gmi.tpl.9797b465fab8bb78c39245ea4138babc12364c18bb386e7d7543fc61b8b529dc b/gemfeed/.rcmbackup/2010-05-09-the-fype-programming-language.gmi.tpl.9797b465fab8bb78c39245ea4138babc12364c18bb386e7d7543fc61b8b529dc deleted file mode 100644 index 683e2357..00000000 --- a/gemfeed/.rcmbackup/2010-05-09-the-fype-programming-language.gmi.tpl.9797b465fab8bb78c39245ea4138babc12364c18bb386e7d7543fc61b8b529dc +++ /dev/null @@ -1,512 +0,0 @@ -# The Fype Programming Language - -> Published at 2010-05-09T12:48:29+01:00; Updated at 2021-05-05 - -Fype is an interpreted programming language created by me for learning and fun. The interpreter is written in C. It has been tested on FreeBSD and NetBSD and may also work on other Unix like operating systems such as Linux based ones. Besides learning and fun, there is no other use case of why Fype exists as many other programming languages are much faster and more powerful. - -The Fype syntax is straightforward and uses a maximum look ahead of 1 and an effortless top-down parsing mechanism. Fype is parsing and interpreting its code simultaneously. This means that syntax errors are only detected during program runtime. - -Fype is a recursive acronym and means "Fype is For Your Program Execution" or "Fype is Free Yak Programmed for ELF". You could also say, "It's not a hype - it's Fype!". - -``` - ____ _ __ - / / _|_ _ _ __ ___ _ _ ___ __ _| |__ / _|_ _ - / / |_| | | | '_ \ / _ \ | | | |/ _ \/ _` | '_ \ | |_| | | | - _ / /| _| |_| | |_) | __/ | |_| | __/ (_| | | | |_| _| |_| | -(_)_/ |_| \__, | .__/ \___| \__, |\___|\__,_|_| |_(_)_| \__, | - |___/|_| |___/ |___/ -``` - -<< template::inline::toc - -## Object-oriented C style - -The Fype interpreter is written in an object-oriented style of C. Each "main component" has its own .h and .c file. There is a struct type for each (most components at least) component, which can be initialized using a "COMPONENT_new" function and destroyed using a "COMPONENT_delete" function. Method calls follow the same schema, e.g. "COMPONENT_METHODNAME". There is no such as class inheritance and polymorphism involved. - -To give you an idea of how it works here as an example is a snippet from the main Fype "class header": - -```c -typedef struct { - Tupel *p_tupel_argv; // Contains command line options - List *p_list_token; // Initial list of token - Hash *p_hash_syms; // Symbol table - char *c_basename; -} Fype; -``` - -And here is a snippet from the primary Fype "class implementation": - -```c -Fype* -fype_new() { - Fype *p_fype = malloc(sizeof(Fype)); - - p_fype->p_hash_syms = hash_new(512); - p_fype->p_list_token = list_new(); - p_fype->p_tupel_argv = tupel_new(); - p_fype->c_basename = NULL; - - garbage_init(); - - return (p_fype); -} - -void -fype_delete(Fype *p_fype) { - argv_tupel_delete(p_fype->p_tupel_argv); - - hash_iterate(p_fype->p_hash_syms, symbol_cleanup_hash_syms_cb); - hash_delete(p_fype->p_hash_syms); - - list_iterate(p_fype->p_list_token, token_ref_down_cb); - list_delete(p_fype->p_list_token); - - if (p_fype->c_basename) - free(p_fype->c_basename); - - garbage_destroy(); -} - -int -fype_run(int i_argc, char **pc_argv) { - Fype *p_fype = fype_new(); - - // argv: Maintains command line options - argv_run(p_fype, i_argc, pc_argv); - - // scanner: Creates a list of token - scanner_run(p_fype); - - // interpret: Interpret the list of token - interpret_run(p_fype); - - fype_delete(p_fype); - - return (0); -} -``` - -## Data types - -Fype uses auto type conversion. However, if you want to know what's going on, you may take a look at the following basic data types: -* integer - Specifies a number -* double - Specifies a double-precision number -* string - Specifies a string -* number - May be an integer or a double number -* any- May be any type above -* void - No type -* identifier - It's a variable name or a procedure name, or a function name - -There is no boolean type, but we can use the integer values 0 for false and 1 for true. There is support for explicit type casting too. - -## Syntax - -### Comments - -Text from a # character until the end of the current line is considered being a comment. Multi-line comments may start with an #* and with a *# anywhere. Exceptions are if those signs are inside of strings. - -### Variables - -Variables are defined with the "my" keyword (inspired by Perl :-). If you don't assign a value during declaration, it uses the default integer value 0. Variables may be changed during program runtime. Variables may be deleted using the "undef" keyword! Example: - -``` -my foo = 1 + 2; -say foo; - -my bar = 12, baz = foo; -say 1 + bar; -say bar; - -my baz; -say baz; # Will print out 0 -``` - -You may use the "defined" keyword to check if an identifier has been defined or not: - -``` -ifnot defined foo { - say "No foo yet defined"; -} - -my foo = 1; - -if defined foo { - put "foo is defined and has the value "; - say foo; -} -``` - -### Synonyms - -Each variable can have as many synonyms as wished. A synonym is another name to access the content of a specific variable. Here is an example of how to use it: - -``` -my foo = "foo"; -my bar = \foo; -foo = "bar"; - -# The synonym variable should now also set to "bar" -assert "bar" == bar; -``` - -Synonyms can be used for all kind of identifiers. It's not limited to standard variables but can also be used for function and procedure names (more about functions and procedures later). - -``` -# Create a new procedure baz -proc baz { say "I am baz"; } - -# Make a synonym baz, and undefine baz -my bay = \baz; - -undef baz; - -# bay still has a reference of the original procedure baz -bay; # this prints aut "I am baz" -``` - -The "syms" keyword gives you the total number of synonyms pointing to a specific value: - -``` -my foo = 1; -say syms foo; # Prints 1 - -my baz = \foo; -say syms foo; # Prints 2 -say syms baz; # Prints 2 - -undef baz; -say syms foo; # Prints 1 -``` - -## Statements and expressions - -A Fype program is a list of statements. Each keyword, expression or function call is part of a statement. Each statement is ended with a semicolon. Example: - -``` -my bar = 3, foo = 1 + 2; -say foo; -exit foo - bar; -``` - -### Parenthesis - -All parenthesis for function arguments is optional. They help to make the code better readable. They also help to force the precedence of expressions. - -### Basic expressions - -Any "any" value holding a string will be automatically converted to an integer value. - -``` -(any) + -(any) - -(any) * -(any) / -(integer) == -(integer) != -(integer) <= -(integer) gt -(integer) <> -(integer) gt -(integer) not -``` - -### Bitwise expressions - -``` -(integer) :< -(integer) :> -(integer) and -(integer) or -(integer) xor -``` - -### Numeric expressions - -``` -(number) neg -``` - -... returns the negative value of "number": - -``` -(integer) no -``` - -... returns 1 if the argument is 0; otherwise, it will return 0! If no argument is given, then 0 is returned! - -``` -(integer) yes -``` - -... always returns 1. The parameter is optional. Example: - -``` -# Prints out 1, because foo is not defined -if yes { say no defined foo; } -``` - -## Control statements - -Control statements available in Fype: - -``` -if { } -``` - -... runs the statements if the expression evaluates to a true value. - -``` -ifnot { } -``` - -... runs the statements if the expression evaluates to a false value. - -``` -while { } -``` - -... runs the statements as long as the expression evaluates to a true value. - -``` -until { } -``` - -... runs the statements as long as the expression evaluates to a false value. - -## Scopes - -A new scope starts with an { and ends with an }. An exception is a procedure, which does not use its own scope (see later in this manual). Control statements and functions support scopes. The "scope" function prints out all available symbols at the current scope. Here is a small example: - -``` -my foo = 1; - -{ - # Prints out 1 - put defined foo; - { - my bar = 2; - - # Prints out 1 - put defined bar; - - # Prints out all available symbols at this - # point to stdout. Those are: bar and foo - scope; - } - - # Prints out 0 - put defined bar; - - my baz = 3; -} - -# Prints out 0 -say defined bar; -``` - -Another example including an actual output: - -``` -./fype -e ’my global; func foo { my var4; func bar { my var2, var3; func baz { my var1; scope; } baz; } bar; } foo;’ -Scopes: -Scope stack size: 3 -Global symbols: -SYM_VARIABLE: global (id=00034, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) -SYM_FUNCTION: foo -Local symbols: -SYM_VARIABLE: var1 (id=00038, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) -1 level(s) up: -SYM_VARIABLE: var2 (id=00036, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) -SYM_VARIABLE: var3 (id=00037, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) -SYM_FUNCTION: baz -2 level(s) up: -SYM_VARIABLE: var4 (id=00035, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1) -SYM_FUNCTION: bar -``` - -## Definedness - -``` -(integer) defined -``` - -... returns 1 if "identifier" has been defined. Returns 0 otherwise. - -``` -(integer) undef -``` - -... tries to undefine/delete the "identifier". Returns 1 if it succeeded, otherwise 0 is returned. - -## System - -These are some system and interpreter specific built-in functions supported: - -``` -(void) end -``` - -... exits the program with the exit status of 0. - -``` -(void) exit -``` - -... exits the program with the specified exit status. - -``` -(integer) fork -``` - -... forks a subprocess. It returns 0 for the child process and the PID of the child process otherwise! Example: - -``` -my pid = fork; - -if pid { - put "I am the parent process; child has the pid "; - say pid; - -} ifnot pid { - say "I am the child process"; -} -``` - -To execute the garbage collector do: - -``` -(integer) GC -``` - -It returns the number of items freed! You may wonder why most of the time, it will produce a value of 0! Fype tries to free not needed memory ASAP. This may change in future versions to gain faster execution speed! - -### I/O - -``` -(any) put -``` - -... prints out the argument - -``` -(any) say -``` - -is the same as put, but also includes an ending newline. - -``` -(void) ln -``` - -... just prints a new line. - -## Procedures and functions - -### Procedures - -A procedure can be defined with the "proc" keyword and deleted with the "undef" keyword. A procedure does not return any value and does not support parameter passing. It's using already defined variables (e.g. global variables). A procedure does not have its own namespace. It's using the calling namespace. It is possible to define new variables inside of a procedure in the current namespace. - -``` -proc foo { - say 1 + a * 3 + b; - my c = 6; -} - -my a = 2, b = 4; - -foo; # Run the procedure. Print out "11\n" -say c; # Print out "6\n"; -``` - -### Nested procedures - -It's possible to define procedures inside of procedures. Since procedures don't have their own scope, nested procedures will be available to the current scope as soon as the main procedure has run the first time. You may use the "defined" keyword to check if a procedure has been defined or not. - -``` -proc foo { - say "I am foo"; - - undef bar; - proc bar { - say "I am bar"; - } -} - -# Here bar would produce an error because -# the proc is not yet defined! -# bar; - -foo; # Here the procedure foo will define the procedure bar! -bar; # Now the procedure bar is defined! -foo; # Here the procedure foo will redefine bar again! -``` - -### Functions - -A function can be defined with the "func" keyword and deleted with the "undef" keyword. Function do not yet return values and do not yet supports parameter passing. It's using local (lexical scoped) variables. If a certain variable does not exist, when It's using already defined variables (e.g. one scope above). - -``` -func foo { - say 1 + a * 3 + b; - my c = 6; -} - -my a = 2, b = 4; - -foo; # Run the procedure. Print out "11\n" -say c; # Will produce an error because c is out of scope! -``` - -### Nested functions - -Nested functions work the same way the nested procedures work, except that nested functions will not be available anymore after the function has been left! - -``` -func foo { - func bar { - say "Hello i am nested"; - } - - bar; # Calling nested -} - -foo; -bar; # Will produce an error because bar is out of scope! -``` - -## Arrays - -Some progress on arrays has been made too. The following example creates a multidimensional array "foo". Its first element is the return value of the func which is "bar". The fourth value is a string" 3" converted to a double number. The last element is an anonymous array which itself contains another anonymous array as its final element: - -``` -func bar { say ”bar” } -my foo = [bar, 1, 4/2, double ”3”, [”A”, [”BA”, ”BB”]]]; -say foo; -``` - -It produces the following output: - -``` -% ./fype arrays.fy -bar -01 -2 -3.000000 -A -BA -BB -``` - -## Fancy stuff - -Fancy stuff like OOP or Unicode or threading is not planed. But fancy stuff like function pointers and closures may be considered.:) - -## May the source be with you - -You can find all of this on the GitHub page. There is also an "examples" folders containing some Fype scripts! - -=> https://codeberg.org/snonux/fype - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2011-05-07-perl-daemon-service-framework.gmi.tpl.62ef757776fbb71d8e8117128b31b664f56d5c4fd0bcd6c62eca6994b9b1fa63 b/gemfeed/.rcmbackup/2011-05-07-perl-daemon-service-framework.gmi.tpl.62ef757776fbb71d8e8117128b31b664f56d5c4fd0bcd6c62eca6994b9b1fa63 deleted file mode 100644 index 8465297b..00000000 --- a/gemfeed/.rcmbackup/2011-05-07-perl-daemon-service-framework.gmi.tpl.62ef757776fbb71d8e8117128b31b664f56d5c4fd0bcd6c62eca6994b9b1fa63 +++ /dev/null @@ -1,169 +0,0 @@ -# Perl Daemon (Service Framework) - -> Published at 2011-05-07T22:26:02+01:00; Updated at 2021-05-07 - -PerlDaemon is a minimal daemon for Linux and other Unix like operating systems programmed in Perl. It is a minimal but pretty functional and fairly generic service framework. This means that it does not do anything useful other than providing a framework for starting, stopping, configuring and logging. To do something useful, a module (written in Perl) must be provided. - -``` - a'! _,,_ a'! _,,_ a'! _,,_ - \\_/ \ \\_/ \ \\_/ \.-, - \, /-( /'-,\, /-( /'-, \, /-( / - //\ //\\ //\ //\\ //\ //\\jrei -``` - -<< template::inline::toc - -## Features - -PerlDaemon supports: - -* Automatic daemonizing -* Logging -* log rotation (via SIGHUP) -* Clean shutdown support (SIGTERM) -* Pid file support (incl. check on startup) -* Easy to configure -* Easy to extend -* Multi-instance support (just use a different directory for each instance). - -## Quick Guide - -```sh -# Starting - ./bin/perldaemon start (or shortcut ./control start) - -# Stopping - ./bin/perldaemon stop (or shortcut ./control stop) - -# Alternatively: Starting in foreground -./bin/perldaemon start daemon.daemonize=no (or shortcut ./control foreground) -``` - -To stop a daemon from running in foreground mode, "Ctrl+C" must be hit. To see more available startup options run "./control" without any argument. - -## How to configure - -The daemon instance can be configured in "./conf/perldaemon.conf". If you want to change a property only once, it is also possible to specify it on the command line (which will take precedence over the config file). All available config properties can be displayed via "./control keys": - -```sh -pb@titania:~/svn/utils/perldaemon/trunk$ ./control keys -# Path to the logfile -daemon.logfile=./log/perldaemon.log - -# The amount of seconds until the next event look takes place -daemon.loopinterval=1 - -# Path to the modules dir -daemon.modules.dir=./lib/PerlDaemonModules - -# Specifies either the daemon should run in daemon or foreground mode -daemon.daemonize=yes - -# Path to the pidfile -daemon.pidfile=./run/perldaemon.pid - -# Each module should run every run interval seconds -daemon.modules.runinterval=3 - -# Path to the alive file (is touched every loop interval seconds, usable for monitoring) -daemon.alivefile=./run/perldaemon.alive - -# Specifies the working directory -daemon.wd=./ -``` - -## Example - -So let's start the daemon with a loop interval of 10 seconds: - -```sh -$ ./control keys | grep daemon.loopinterval -daemon.loopinterval=1 -$ ./control keys daemon.loopinterval=10 | grep daemon.loopinterval -daemon.loopinterval=10 -$ ./control start daemon.loopinterval=10; sleep 10; tail -n 2 log/perldaemon.log -Starting daemon now... -Mon Jun 13 11:29:27 2011 (PID 2838): Triggering PerlDaemonModules::ExampleModule -(last triggered before 10.002106s; carry: 7.002106s; wanted interval: 3s) -Mon Jun 13 11:29:27 2011 (PID 2838): ExampleModule Test 2 -$ ./control stop -Stopping daemon now... -``` - -If you want to change that property forever, either edit perldaemon.conf or do this: - -```sh -$ ./control keys daemon.loopinterval=10 > new.conf; mv new.conf conf/perldaemon.conf -``` - -## HiRes event loop - -PerlDaemon uses `Time::HiRes` to make sure that all the events run incorrect intervals. For each loop run, a time carry value is recorded and added to the next loop run to catch up on lost time. - -## Writing your own modules - -### Example module - -This is one of the example modules you will find in the source code. It should be pretty self-explanatory if you know Perl :-). - -```perl -package PerlDaemonModules::ExampleModule; - -use strict; -use warnings; - -sub new ($$$) { - my ($class, $conf) = @_; - - my $self = bless { conf => $conf }, $class; - - # Store some private module stuff - $self->{counter} = 0; - - return $self; -} - -# Runs periodically in a loop (set interval in perldaemon.conf) -sub do ($) { - my $self = shift; - my $conf = $self->{conf}; - my $logger = $conf->{logger}; - - # Calculate some private module stuff - my $count = ++$self->{counter}; - - $logger->logmsg("ExampleModule Test $count"); -} - -1; -``` - -### Your own module - -Want to give it some better use? It's just as easy as: - -```sh - cd ./lib/PerlDaemonModules/ - cp ExampleModule.pm YourModule.pm - vi YourModule.pm - cd - - ./bin/perldaemon restart (or shortcurt ./control restart) -``` - -Now watch `./log/perldaemon.log` closely. It is a good practice to test your modules in 'foreground mode' (see above how to do that). - -BTW: You can install as many modules within the same instance as desired. But they are run in sequential order (in future, they can also run in parallel using several threads or processes). - -## May the source be with you - -You can find PerlDaemon (including the examples) at: - -=> https://codeberg.org/snonux/perldaemon - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -Other related posts are: - -<< template::inline::rindex perl - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2015-12-05-run-debian-on-your-phone-with-debroid.gmi.tpl.6b6aaeb972eb69a3fae8630218bf7929803353053b21f20d55de72dec5e3d073 b/gemfeed/.rcmbackup/2015-12-05-run-debian-on-your-phone-with-debroid.gmi.tpl.6b6aaeb972eb69a3fae8630218bf7929803353053b21f20d55de72dec5e3d073 deleted file mode 100644 index 8b153366..00000000 --- a/gemfeed/.rcmbackup/2015-12-05-run-debian-on-your-phone-with-debroid.gmi.tpl.6b6aaeb972eb69a3fae8630218bf7929803353053b21f20d55de72dec5e3d073 +++ /dev/null @@ -1,180 +0,0 @@ -# Run Debian on your phone with Debroid - -> Published at 2015-12-05T16:12:57+00:00; Updated at 2021-05-16 - -You can use the following tutorial to install a full-blown Debian GNU/Linux Chroot on an LG G3 D855 CyanogenMod 13 (Android 6). First of all, you need to have root permissions on your phone, and you also need to have the developer mode activated. The following steps have been tested on Linux (Fedora 23). - -=> ./run-debian-on-your-phone-with-debroid/Deboroid.png - -A couple of years have passed since I last worked on Debroid. Currently, I am using the Termux app on Android, which is less sophisticated than a fully blown Debian installation but sufficient for my current requirements. The content of this site may be still relevant, and it would also work with more recent versions of Debian and Android. I would expect that some minor modifications need to be made, though. - -``` - ____ _ _ _ -| _ \ ___| |__ _ __ ___ (_) __| | -| | | |/ _ \ '_ \| '__/ _ \| |/ _` | -| |_| | __/ |_) | | | (_) | | (_| | -|____/ \___|_.__/|_| \___/|_|\__,_| - -``` - -<< template::inline::toc - -## Step by step guide - -All scripts mentioned here can be found on GitHub at: - -=> https://codeberg.org/snonux/debroid - -### First debootstrap stage - -This is to be performed on a Fedora Linux machine (could work on a Debian too, but Fedora is just what I use on my Laptop). The following steps prepare an initial Debian base image, which can then be transferred to the phone. - -```sh -sudo dnf install debootstrap -# 5g -dd if=/dev/zero of=jessie.img bs=$[ 1024 * 1024 ] \ - count=$[ 1024 * 5 ] - -# Show used loop devices -sudo losetup -f -# Store the next free one to $loop -loop=loopN -sudo losetup /dev/$loop jessie.img - -mkdir jessie -sudo mkfs.ext4 /dev/$loop -sudo mount /dev/$loop jessie -sudo debootstrap --foreign --variant=minbase \ - --arch armel jessie jessie/ \ - http://http.debian.net/debian -sudo umount jessie -``` - -### Copy Debian image to the phone - -Now setup the Debian image on an external SD card on the Phone via Android Debugger as follows: - -```sh -adb root && adb wait-for-device && adb shell -mkdir -p /storage/sdcard1/Linux/jessie -exit - -# Sparse image problem, may be too big for copying otherwise -gzip jessie.img -# Copy over -adb push jessie.img.gz /storage/sdcard1/Linux/jessie.img.gz -adb shell -cd /storage/sdcard1/Linux -gunzip jessie.img.gz - -# Show used loop devices -losetup -f -# Store the next free one to $loop -loop=loopN - -# Use the next free one (replace the loop number) -losetup /dev/block/$loop $(pwd)/jessie.img -mount -t ext4 /dev/block/$loop $(pwd)/jessie - -# Bind-Mound proc, dev, sys` -busybox mount --bind /proc $(pwd)/jessie/proc -busybox mount --bind /dev $(pwd)/jessie/dev -busybox mount --bind /dev/pts $(pwd)/jessie/dev/pts -busybox mount --bind /sys $(pwd)/jessie/sys - -# Bind-Mound the rest of Android -mkdir -p $(pwd)/jessie/storage/sdcard{0,1} -busybox mount --bind /storage/emulated \ - $(pwd)/jessie/storage/sdcard0 -busybox mount --bind /storage/sdcard1 \ - $(pwd)/jessie/storage/sdcard1 - -# Check mounts -mount | grep jessie -``` - -### Second debootstrap stage - -This is to be performed on the Android phone itself (inside a Debian chroot): - -```sh -chroot $(pwd)/jessie /bin/bash -l -export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin -/debootstrap/debootstrap --second-stage -exit # Leave chroot -exit # Leave adb shell -``` - -### Setup of various scripts - -jessie.sh deals with all the loopback mount magic and so on. It will be run later every time you start Debroid on your phone. - -```sh -# Install script jessie.sh -adb push storage/sdcard1/Linux/jessie.sh /storage/sdcard/Linux/jessie.sh -adb shell -cd /storage/sdcard1/Linux -sh jessie.sh enter - -# Bashrc -cat <~/.bashrc -export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH -export EDITOR=vim -hostname $(cat /etc/hostname) -END - -# Fixing an error message while loading the profile -sed -i s#id#/usr/bin/id# /etc/profile - -# Setting the hostname -echo phobos > /etc/hostname -echo 127.0.0.1 phobos > /etc/hosts -hostname phobos - -# Apt-sources -cat < sources.list -deb http://ftp.uk.debian.org/debian/ jessie main contrib non-free -deb-src http://ftp.uk.debian.org/debian/ jessie main contrib non-free -END -apt-get update -apt-get upgrade -apt-get dist-upgrade -exit # Exit chroot -``` - -### Entering Debroid and enable a service - -This enters Debroid on your phone and starts the example service uptimed: - -```sh -sh jessie.sh enter - -# Setup example serice uptimed -apt-get install uptimed -cat < /etc/rc.debroid -export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH -service uptimed status &>/dev/null || service uptimed start -exit 0 -END - -chmod 0755 /etc/rc.debroid -exit # Exit chroot -exit # Exit adb shell -``` - -### Include to Android startup: - -If you want to start Debroid automatically whenever your phone starts, then do the following: - -```sh -adb push data/local/userinit.sh /data/local/userinit.sh -adb shell -chmod +x /data/local/userinit.sh -exit -``` - -Reboot & test! Enjoy! - -E-Mail your comments to `paul@nospam.buetow.org` :-) - -=> ../ Back to the main site diff --git a/gemfeed/.rcmbackup/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi.tpl.221f1043b07e8b62c50d3650714e4f5485d943e8015f956eefabf0ad617fe617 b/gemfeed/.rcmbackup/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi.tpl.221f1043b07e8b62c50d3650714e4f5485d943e8015f956eefabf0ad617fe617 deleted file mode 100644 index 75bb7ac3..00000000 --- a/gemfeed/.rcmbackup/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi.tpl.221f1043b07e8b62c50d3650714e4f5485d943e8015f956eefabf0ad617fe617 +++ /dev/null @@ -1,396 +0,0 @@ -# Jails and ZFS with Puppet on FreeBSD - -> Published at 2016-04-09T18:29:47+01:00 - -Over the last couple of years I wrote quite a few Puppet modules in order to manage my personal server infrastructure. One of them manages FreeBSD Jails and another one ZFS file systems. I thought I would give a brief overview in how it looks and feels. - -``` - __ __ - (( \---/ )) - )__ __( - / ()___() \ - \ /(_)\ / - \ \_|_/ / - _______> <_______ - //\ |>o<| /\\ - \\/___ ___\// - | | - | | - | | - | | - `--....---' - \ \ - \ `. hjw - \ `. -``` - -<< template::inline::toc - -## ZFS - -The ZFS module is a pretty basic one. It does not manage ZFS pools yet as I am not creating them often enough which would justify implementing an automation. But let's see how we can create a ZFS file system (on an already given ZFS pool named ztank): - -Puppet snippet: - -``` -zfs::create { 'ztank/foo': - ensure => present, - filesystem => '/srv/foo', - - require => File['/srv'], -} -``` - -Puppet run: - -``` -admin alphacentauri:/opt/git/server/puppet/manifests [1212]% puppet.apply -Password: -Info: Loading facts -Info: Loading facts -Info: Loading facts -Info: Loading facts -Notice: Compiled catalog for alphacentauri.home in environment production in 7.14 seconds -Info: Applying configuration version '1460189837' -Info: mount[files]: allowing * access -Info: mount[restricted]: allowing * access -Notice: /Stage[main]/Main/Node[alphacentauri]/Zfs::Create[ztank/foo]/Exec[ztank/foo_create]/returns: executed successfully -Notice: Finished catalog run in 25.41 seconds -admin alphacentauri:~ [1213]% zfs list | grep foo -ztank/foo 96K 1.13T 96K /srv/foo -admin alphacentauri:~ [1214]% df | grep foo -ztank/foo 1214493520 96 1214493424 0% /srv/foo -admin alphacentauri:~ [1215]% -``` - -The destruction of the file system just requires to set "ensure" to "absent" in Puppet: - -``` -zfs::create { 'ztank/foo': - ensure => absent, - filesystem => '/srv/foo', - - require => File['/srv'], -}¬ -``` - -Puppet run: - -``` -admin alphacentauri:/opt/git/server/puppet/manifests [1220]% puppet.apply -Password: -Info: Loading facts -Info: Loading facts -Info: Loading facts -Info: Loading facts -Notice: Compiled catalog for alphacentauri.home in environment production in 6.14 seconds -Info: Applying configuration version '1460190203' -Info: mount[files]: allowing * access -Info: mount[restricted]: allowing * access -Notice: /Stage[main]/Main/Node[alphacentauri]/Zfs::Create[ztank/foo]/Exec[zfs destroy -r ztank/foo]/returns: executed successfully -Notice: Finished catalog run in 22.72 seconds -admin alphacentauri:/opt/git/server/puppet/manifests [1221]% zfs list | grep foo -zsh: done zfs list | -zsh: exit 1 grep foo -admin alphacentauri:/opt/git/server/puppet/manifests [1222:1]% df | grep foo -zsh: done df | -zsh: exit 1 grep foo -``` - -## Jails - -Here is an example in how a FreeBSD Jail can be created. The Jail will have its own public IPv6 address. And it will have its own internal IPv4 address with IPv4 NAT to the internet (this is due to the limitation that the host server only got one public IPv4 address which requires sharing between all the Jails). - -Furthermore, Puppet will ensure that the Jail will have its own ZFS file system (internally it is using the ZFS module). Please notice that the NAT requires the packet filter to be setup correctly (not covered in this blog post). - -``` -include jail::freebsd - -# Cloned interface for Jail IPv4 NAT -freebsd::rc_config { 'cloned_interfaces': - value => 'lo1', -} -freebsd::rc_config { 'ipv4_addrs_lo1': - value => '192.168.0.1-24/24' -} - -freebsd::ipalias { '2a01:4f8:120:30e8::17': - ensure => up, - proto => 'inet6', - preflen => '64', - interface => 're0', - aliasnum => '8', -} - -class { 'jail': - ensure => present, - jails_config => { - sync => { - '_ensure' => present, - '_type' => 'freebsd', - '_mirror' => 'ftp://ftp.de.freebsd.org', - '_remote_path' => 'FreeBSD/releases/amd64/10.1-RELEASE', - '_dists' => [ 'base.txz', 'doc.txz', ], - '_ensure_directories' => [ '/opt', '/opt/enc' ], - '_ensure_zfs' => [ '/sync' ], - 'host.hostname' => "'sync.ian.buetow.org'", - 'ip4.addr' => '192.168.0.17', - 'ip6.addr' => '2a01:4f8:120:30e8::17', - }, - } -} -``` - -This is how the result looks like: - -``` -admin sun:/etc [1939]% puppet.apply -Info: Loading facts -Info: Loading facts -Info: Loading facts -Info: Loading facts -Notice: Compiled catalog for sun.ian.buetow.org in environment production in 1.80 seconds -Info: Applying configuration version '1460190986' -Notice: /Stage[main]/Jail/File[/etc/jail.conf]/ensure: created -Info: mount[files]: allowing * access -Info: mount[restricted]: allowing * access -Info: Computing checksum on file /etc/motd -Info: /Stage[main]/Motd/File[/etc/motd]: Filebucketed /etc/motd to puppet with sum fced1b6e89f50ef2c40b0d7fba9defe8 -Notice: /Stage[main]/Jail/Jail::Create[sync]/File[/jail/sync]/ensure: created -Notice: /Stage[main]/Jail/Jail::Create[sync]/Zfs::Create[zroot/jail/sync]/Exec[zroot/jail/sync_create]/returns: executed successfully -Notice: /Stage[main]/Jail/Jail::Create[sync]/File[/jail/sync/opt]/ensure: created -Notice: /Stage[main]/Jail/Jail::Create[sync]/File[/jail/sync/opt/enc]/ensure: created -Notice: /Stage[main]/Jail/Jail::Create[sync]/Jail::Ensure_zfs[/sync]/Zfs::Create[zroot/jail/sync/sync]/Exec[zroot/jail/sync/sync_create]/returns: executed successfully -Notice: /Stage[main]/Jail/Jail::Create[sync]/Jail::Freebsd::Create[sync]/File[/jail/sync/.jailbootstrap]/ensure: created -Notice: /Stage[main]/Jail/Jail::Create[sync]/Jail::Freebsd::Create[sync]/File[/etc/fstab.jail.sync]/ensure: created -Notice: /Stage[main]/Jail/Jail::Create[sync]/Jail::Freebsd::Create[sync]/File[/jail/sync/.jailbootstrap/bootstrap.sh]/ensure: created -Notice: /Stage[main]/Jail/Jail::Create[sync]/Jail::Freebsd::Create[sync]/Exec[sync_bootstrap]/returns: executed successfully -Notice: Finished catalog run in 49.72 seconds -admin sun:/etc [1942]% ls -l /jail/sync -total 154 --r--r--r-- 1 root wheel 6198 11 Nov 2014 COPYRIGHT -drwxr-xr-x 2 root wheel 47 11 Nov 2014 bin -drwxr-xr-x 7 root wheel 43 11 Nov 2014 boot -dr-xr-xr-x 2 root wheel 2 11 Nov 2014 dev -drwxr-xr-x 23 root wheel 101 9 Apr 10:37 etc -drwxr-xr-x 3 root wheel 50 11 Nov 2014 lib -drwxr-xr-x 3 root wheel 4 11 Nov 2014 libexec -drwxr-xr-x 2 root wheel 2 11 Nov 2014 media -drwxr-xr-x 2 root wheel 2 11 Nov 2014 mnt -drwxr-xr-x 3 root wheel 3 9 Apr 10:36 opt -dr-xr-xr-x 2 root wheel 2 11 Nov 2014 proc -drwxr-xr-x 2 root wheel 143 11 Nov 2014 rescue -drwxr-xr-x 2 root wheel 6 11 Nov 2014 root -drwxr-xr-x 2 root wheel 132 11 Nov 2014 sbin -drwxr-xr-x 2 root wheel 2 9 Apr 10:36 sync -lrwxr-xr-x 1 root wheel 11 11 Nov 2014 sys -> usr/src/sys -drwxrwxrwt 2 root wheel 2 11 Nov 2014 tmp -drwxr-xr-x 14 root wheel 14 11 Nov 2014 usr -drwxr-xr-x 24 root wheel 24 11 Nov 2014 var -admin sun:/etc [1943]% zfs list | grep sync;df | grep sync -zroot/jail/sync 162M 343G 162M /jail/sync -zroot/jail/sync/sync 144K 343G 144K /jail/sync/sync -/opt/enc 5061624 84248 4572448 2% /jail/sync/opt/enc -zroot/jail/sync 360214972 166372 360048600 0% /jail/sync -zroot/jail/sync/sync 360048744 144 360048600 0% /jail/sync/sync -admin sun:/etc [1944]% cat /etc/fstab.jail.sync -# Generated by Puppet for a Jail. -# Can contain file systems to be mounted curing jail start. -admin sun:/etc [1945]% cat /etc/jail.conf -# Generated by Puppet - -allow.chflags = true; -exec.start = '/bin/sh /etc/rc'; -exec.stop = '/bin/sh /etc/rc.shutdown'; -mount.devfs = true; -mount.fstab = "/etc/fstab.jail.$name"; -path = "/jail/$name"; - -sync { - host.hostname = 'sync.ian.buetow.org'; - ip4.addr = 192.168.0.17; - ip6.addr = 2a01:4f8:120:30e8::17; -} -admin sun:/etc [1955]% sudo service jail start sync -Password: -Starting jails: sync. -admin sun:/etc [1956]% jls | grep sync - 103 192.168.0.17 sync.ian.buetow.org /jail/sync -admin sun:/etc [1957]% sudo jexec 103 /bin/csh -root@sync:/ # ifconfig -a -re0: flags=8843 metric 0 mtu 1500 - options=8209b - ether 50:46:5d:9f:fd:1e - inet6 2a01:4f8:120:30e8::17 prefixlen 64 - nd6 options=8021 - media: Ethernet autoselect (1000baseT ) - status: active -lo0: flags=8049 metric 0 mtu 16384 - options=600003 - nd6 options=21 - lo1: flags=8049 metric 0 mtu 16384 - options=600003 - inet 192.168.0.17 netmask 0xffffffff - nd6 options=29 -``` - -## Inside-Jail Puppet - -To automatically setup the applications running in the Jail I am using Puppet as well. I wrote a few scripts which bootstrap Puppet inside of a newly created Jail. It is doing the following: - -* Mounts an encrypted container (containing a secret Puppet manifests [git repository]) -* Activates "pkg-ng", the FreeBSD binary package manager, in the Jail -* Installs Puppet plus all dependencies in the Jail -* Updates the Jail via "freebsd-update" to the latest version -* Restarts the Jail and invokes Puppet. -* Puppet then also schedules a periodic cron job for the next Puppet runs. - -``` -admin sun:~ [1951]% sudo /opt/snonux/local/etc/init.d/enc activate sync -Starting jails: dns. -The package management tool is not yet installed on your system. -Do you want to fetch and install it now? [y/N]: y -Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/freebsd:10:x86:64/latest, please wait... -Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done -[sync.ian.buetow.org] Installing pkg-1.7.2... -[sync.ian.buetow.org] Extracting pkg-1.7.2: 100% -Updating FreeBSD repository catalogue... -[sync.ian.buetow.org] Fetching meta.txz: 100% 944 B 0.9kB/s 00:01 -[sync.ian.buetow.org] Fetching packagesite.txz: 100% 5 MiB 5.6MB/s 00:01 -Processing entries: 100% -FreeBSD repository update completed. 25091 packages processed. -Updating database digests format: 100% -The following 20 package(s) will be affected (of 0 checked): - - New packages to be INSTALLED: - git: 2.7.4_1 - expat: 2.1.0_3 - python27: 2.7.11_1 - libffi: 3.2.1 - indexinfo: 0.2.4 - gettext-runtime: 0.19.7 - p5-Error: 0.17024 - perl5: 5.20.3_9 - cvsps: 2.1_1 - p5-Authen-SASL: 2.16_1 - p5-Digest-HMAC: 1.03_1 - p5-GSSAPI: 0.28_1 - curl: 7.48.0_1 - ca_root_nss: 3.22.2 - p5-Net-SMTP-SSL: 1.03 - p5-IO-Socket-SSL: 2.024 - p5-Net-SSLeay: 1.72 - p5-IO-Socket-IP: 0.37 - p5-Socket: 2.021 - p5-Mozilla-CA: 20160104 - - The process will require 144 MiB more space. - 30 MiB to be downloaded. -[sync.ian.buetow.org] Fetching git-2.7.4_1.txz: 100% 4 MiB 3.7MB/s 00:01 -[sync.ian.buetow.org] Fetching expat-2.1.0_3.txz: 100% 98 KiB 100.2kB/s 00:01 -[sync.ian.buetow.org] Fetching python27-2.7.11_1.txz: 100% 10 MiB 10.7MB/s 00:01 -[sync.ian.buetow.org] Fetching libffi-3.2.1.txz: 100% 35 KiB 36.2kB/s 00:01 -[sync.ian.buetow.org] Fetching indexinfo-0.2.4.txz: 100% 5 KiB 5.0kB/s 00:01 -[sync.ian.buetow.org] Fetching gettext-runtime-0.19.7.txz: 100% 148 KiB 151.1kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-Error-0.17024.txz: 100% 24 KiB 24.8kB/s 00:01 -[sync.ian.buetow.org] Fetching perl5-5.20.3_9.txz: 100% 13 MiB 6.9MB/s 00:02 -[sync.ian.buetow.org] Fetching cvsps-2.1_1.txz: 100% 41 KiB 42.1kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-Authen-SASL-2.16_1.txz: 100% 44 KiB 45.1kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-Digest-HMAC-1.03_1.txz: 100% 9 KiB 9.5kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-GSSAPI-0.28_1.txz: 100% 41 KiB 41.7kB/s 00:01 -[sync.ian.buetow.org] Fetching curl-7.48.0_1.txz: 100% 2 MiB 2.2MB/s 00:01 -[sync.ian.buetow.org] Fetching ca_root_nss-3.22.2.txz: 100% 324 KiB 331.4kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-Net-SMTP-SSL-1.03.txz: 100% 11 KiB 10.8kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-IO-Socket-SSL-2.024.txz: 100% 153 KiB 156.4kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-Net-SSLeay-1.72.txz: 100% 234 KiB 239.3kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-IO-Socket-IP-0.37.txz: 100% 27 KiB 27.4kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-Socket-2.021.txz: 100% 37 KiB 38.0kB/s 00:01 -[sync.ian.buetow.org] Fetching p5-Mozilla-CA-20160104.txz: 100% 147 KiB 150.8kB/s 00:01 -Checking integrity... -[sync.ian.buetow.org] [1/12] Installing libyaml-0.1.6_2... -[sync.ian.buetow.org] [1/12] Extracting libyaml-0.1.6_2: 100% -[sync.ian.buetow.org] [2/12] Installing libedit-3.1.20150325_2... -[sync.ian.buetow.org] [2/12] Extracting libedit-3.1.20150325_2: 100% -[sync.ian.buetow.org] [3/12] Installing ruby-2.2.4,1... -[sync.ian.buetow.org] [3/12] Extracting ruby-2.2.4,1: 100% -[sync.ian.buetow.org] [4/12] Installing ruby22-gems-2.6.2... -[sync.ian.buetow.org] [4/12] Extracting ruby22-gems-2.6.2: 100% -[sync.ian.buetow.org] [5/12] Installing libxml2-2.9.3... -[sync.ian.buetow.org] [5/12] Extracting libxml2-2.9.3: 100% -[sync.ian.buetow.org] [6/12] Installing dmidecode-3.0... -[sync.ian.buetow.org] [6/12] Extracting dmidecode