From 94ba65207cff8b016afa4ba8f378c7a542d28d7c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 19 May 2021 12:41:48 +0100 Subject: md submodule --- .gitmodules | 6 - Makefile | 18 - README.md | 29 -- _config.yml | 1 - buetow.org.conf | 7 - buetow.org.sh | 64 --- contact-information.md | 38 ++ content/gemtext | 1 - content/html | 1 - content/md/contact-information.md | 38 -- content/md/favicon.ico | Bin 1077 -> 0 bytes content/md/gemfeed/2008-06-26-perl-poetry.md | 166 ------- .../gemfeed/2010-04-09-standard-ml-and-haskell.md | 174 ------- .../2010-05-09-the-fype-programming-language.md | 510 --------------------- .../2011-05-07-perl-daemon-service-framework.md | 163 ------- .../2014-03-24-the-fibonacci.pl.c-polyglot.md | 110 ----- ...-12-05-run-debian-on-your-phone-with-debroid.md | 180 -------- .../Deboroid.png | Bin 576510 -> 0 bytes .../gemfeed/2016-04-03-offsite-backup-with-zfs.md | 42 -- ...6-04-09-jails-and-zfs-on-freebsd-with-puppet.md | 392 ---------------- .../2016-04-16-offsite-backup-with-zfs-part2.md | 30 -- ...spinning-up-my-own-authoritative-dns-servers.md | 239 ---------- content/md/gemfeed/2016-11-20-methods-in-c.md | 86 ---- ...realistic-load-testing-with-ioriot-for-linux.md | 191 -------- .../figure1-ioriot-io-recording.png | Bin 220247 -> 0 bytes .../figure2-ioriot-test-preparation.png | Bin 208235 -> 0 bytes .../figure3-ioriot-replay.png | Bin 417034 -> 0 bytes .../figure4-ioriot-read-latency.png | Bin 39552 -> 0 bytes .../figure5-ioriot-write-latency.png | Bin 26547 -> 0 bytes .../figure6-iostat.png | Bin 294346 -> 0 bytes ...04-22-dtail-the-distributed-log-tail-program.md | 108 ----- .../dgrep.gif | Bin 142329 -> 0 bytes .../dtail.gif | Bin 1984520 -> 0 bytes .../title.png | Bin 84933 -> 0 bytes .../2021-04-24-welcome-to-the-geminispace.md | 76 --- .../amfora-screenshot.png | Bin 154951 -> 0 bytes ....org.sh-one-bash-script-to-rule-it-all.draft.md | 183 -------- .../2021-05-16-personal-bash-coding-style-guide.md | 385 ---------------- content/md/gemfeed/index.md | 19 - content/md/index.md | 71 --- content/md/resources.md | 118 ----- content/meta/gemfeed/2008-06-26-perl-poetry.meta | 5 - .../2010-04-09-standard-ml-and-haskell.meta | 5 - .../2010-05-09-the-fype-programming-language.meta | 5 - .../2011-05-07-perl-daemon-service-framework.meta | 5 - .../2014-03-24-the-fibonacci.pl.c-polyglot.meta | 5 - ...2-05-run-debian-on-your-phone-with-debroid.meta | 5 - .../2016-04-03-offsite-backup-with-zfs.meta | 5 - ...04-09-jails-and-zfs-on-freebsd-with-puppet.meta | 5 - .../2016-04-16-offsite-backup-with-zfs-part2.meta | 5 - ...inning-up-my-own-authoritative-dns-servers.meta | 5 - content/meta/gemfeed/2016-11-20-methods-in-c.meta | 5 - ...alistic-load-testing-with-ioriot-for-linux.meta | 5 - ...-22-dtail-the-distributed-log-tail-program.meta | 5 - .../2021-04-24-welcome-to-the-geminispace.meta | 5 - ...021-05-16-personal-bash-coding-style-guide.meta | 5 - favicon.ico | Bin 0 -> 1077 bytes footer.html.part | 2 - gemfeed/2008-06-26-perl-poetry.md | 166 +++++++ gemfeed/2010-04-09-standard-ml-and-haskell.md | 174 +++++++ .../2010-05-09-the-fype-programming-language.md | 510 +++++++++++++++++++++ .../2011-05-07-perl-daemon-service-framework.md | 163 +++++++ gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md | 110 +++++ ...-12-05-run-debian-on-your-phone-with-debroid.md | 180 ++++++++ .../Deboroid.png | Bin 0 -> 576510 bytes gemfeed/2016-04-03-offsite-backup-with-zfs.md | 42 ++ ...6-04-09-jails-and-zfs-on-freebsd-with-puppet.md | 392 ++++++++++++++++ .../2016-04-16-offsite-backup-with-zfs-part2.md | 30 ++ ...spinning-up-my-own-authoritative-dns-servers.md | 239 ++++++++++ gemfeed/2016-11-20-methods-in-c.md | 86 ++++ ...realistic-load-testing-with-ioriot-for-linux.md | 191 ++++++++ .../figure1-ioriot-io-recording.png | Bin 0 -> 220247 bytes .../figure2-ioriot-test-preparation.png | Bin 0 -> 208235 bytes .../figure3-ioriot-replay.png | Bin 0 -> 417034 bytes .../figure4-ioriot-read-latency.png | Bin 0 -> 39552 bytes .../figure5-ioriot-write-latency.png | Bin 0 -> 26547 bytes .../figure6-iostat.png | Bin 0 -> 294346 bytes ...04-22-dtail-the-distributed-log-tail-program.md | 108 +++++ .../dgrep.gif | Bin 0 -> 142329 bytes .../dtail.gif | Bin 0 -> 1984520 bytes .../title.png | Bin 0 -> 84933 bytes gemfeed/2021-04-24-welcome-to-the-geminispace.md | 76 +++ .../amfora-screenshot.png | Bin 0 -> 154951 bytes ....org.sh-one-bash-script-to-rule-it-all.draft.md | 183 ++++++++ .../2021-05-16-personal-bash-coding-style-guide.md | 385 ++++++++++++++++ gemfeed/index.md | 19 + header.html.part | 50 -- index.md | 71 +++ packages/assert.source.sh | 47 -- packages/atomfeed.source.sh | 122 ----- packages/gemfeed.source.sh | 54 --- packages/generate.source.sh | 137 ------ packages/html.source.sh | 153 ------- packages/log.source.sh | 29 -- packages/md.source.sh | 59 --- resources.md | 118 +++++ 96 files changed, 3281 insertions(+), 4136 deletions(-) delete mode 100644 Makefile delete mode 100644 README.md delete mode 100644 _config.yml delete mode 100644 buetow.org.conf delete mode 100755 buetow.org.sh create mode 100644 contact-information.md delete mode 160000 content/gemtext delete mode 160000 content/html delete mode 100644 content/md/contact-information.md delete mode 100644 content/md/favicon.ico delete mode 100644 content/md/gemfeed/2008-06-26-perl-poetry.md delete mode 100644 content/md/gemfeed/2010-04-09-standard-ml-and-haskell.md delete mode 100644 content/md/gemfeed/2010-05-09-the-fype-programming-language.md delete mode 100644 content/md/gemfeed/2011-05-07-perl-daemon-service-framework.md delete mode 100644 content/md/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md delete mode 100644 content/md/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.md delete mode 100644 content/md/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid/Deboroid.png delete mode 100644 content/md/gemfeed/2016-04-03-offsite-backup-with-zfs.md delete mode 100644 content/md/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md delete mode 100644 content/md/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.md delete mode 100644 content/md/gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.md delete mode 100644 content/md/gemfeed/2016-11-20-methods-in-c.md delete mode 100644 content/md/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.md delete mode 100644 content/md/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure1-ioriot-io-recording.png delete mode 100644 content/md/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure2-ioriot-test-preparation.png delete mode 100644 content/md/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure3-ioriot-replay.png delete mode 100644 content/md/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure4-ioriot-read-latency.png delete mode 100644 content/md/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure5-ioriot-write-latency.png delete mode 100644 content/md/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure6-iostat.png delete mode 100644 content/md/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.md delete mode 100644 content/md/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/dgrep.gif delete mode 100644 content/md/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/dtail.gif delete mode 100644 content/md/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/title.png delete mode 100644 content/md/gemfeed/2021-04-24-welcome-to-the-geminispace.md delete mode 100644 content/md/gemfeed/2021-04-24-welcome-to-the-geminispace/amfora-screenshot.png delete mode 100644 content/md/gemfeed/2021-05-15-buetow.org.sh-one-bash-script-to-rule-it-all.draft.md delete mode 100644 content/md/gemfeed/2021-05-16-personal-bash-coding-style-guide.md delete mode 100644 content/md/gemfeed/index.md delete mode 100644 content/md/index.md delete mode 100644 content/md/resources.md delete mode 100644 content/meta/gemfeed/2008-06-26-perl-poetry.meta delete mode 100644 content/meta/gemfeed/2010-04-09-standard-ml-and-haskell.meta delete mode 100644 content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta delete mode 100644 content/meta/gemfeed/2011-05-07-perl-daemon-service-framework.meta delete mode 100644 content/meta/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.meta delete mode 100644 content/meta/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.meta delete mode 100644 content/meta/gemfeed/2016-04-03-offsite-backup-with-zfs.meta delete mode 100644 content/meta/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.meta delete mode 100644 content/meta/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.meta delete mode 100644 content/meta/gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.meta delete mode 100644 content/meta/gemfeed/2016-11-20-methods-in-c.meta delete mode 100644 content/meta/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.meta delete mode 100644 content/meta/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.meta delete mode 100644 content/meta/gemfeed/2021-04-24-welcome-to-the-geminispace.meta delete mode 100644 content/meta/gemfeed/2021-05-16-personal-bash-coding-style-guide.meta create mode 100644 favicon.ico delete mode 100644 footer.html.part create mode 100644 gemfeed/2008-06-26-perl-poetry.md create mode 100644 gemfeed/2010-04-09-standard-ml-and-haskell.md create mode 100644 gemfeed/2010-05-09-the-fype-programming-language.md create mode 100644 gemfeed/2011-05-07-perl-daemon-service-framework.md create mode 100644 gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md create mode 100644 gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.md create mode 100644 gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid/Deboroid.png create mode 100644 gemfeed/2016-04-03-offsite-backup-with-zfs.md create mode 100644 gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md create mode 100644 gemfeed/2016-04-16-offsite-backup-with-zfs-part2.md create mode 100644 gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.md create mode 100644 gemfeed/2016-11-20-methods-in-c.md create mode 100644 gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.md create mode 100644 gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure1-ioriot-io-recording.png create mode 100644 gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure2-ioriot-test-preparation.png create mode 100644 gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure3-ioriot-replay.png create mode 100644 gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure4-ioriot-read-latency.png create mode 100644 gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure5-ioriot-write-latency.png create mode 100644 gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux/figure6-iostat.png create mode 100644 gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.md create mode 100644 gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/dgrep.gif create mode 100644 gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/dtail.gif create mode 100644 gemfeed/2021-04-22-dtail-the-distributed-log-tail-program/title.png create mode 100644 gemfeed/2021-04-24-welcome-to-the-geminispace.md create mode 100644 gemfeed/2021-04-24-welcome-to-the-geminispace/amfora-screenshot.png create mode 100644 gemfeed/2021-05-15-buetow.org.sh-one-bash-script-to-rule-it-all.draft.md create mode 100644 gemfeed/2021-05-16-personal-bash-coding-style-guide.md create mode 100644 gemfeed/index.md delete mode 100644 header.html.part create mode 100644 index.md delete mode 100644 packages/assert.source.sh delete mode 100644 packages/atomfeed.source.sh delete mode 100644 packages/gemfeed.source.sh delete mode 100644 packages/generate.source.sh delete mode 100644 packages/html.source.sh delete mode 100644 packages/log.source.sh delete mode 100644 packages/md.source.sh create mode 100644 resources.md diff --git a/.gitmodules b/.gitmodules index 1d5d0402..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +0,0 @@ -[submodule "content/gemtext"] - path = content/gemtext - url = git@github.com:snonux/buetow.org -[submodule "content/html"] - path = content/html - url = git@github.com:snonux/buetow.org diff --git a/Makefile b/Makefile deleted file mode 100644 index 879b7945..00000000 --- a/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -all: generate -generate: - bash ./buetow.org.sh --generate -publish: - ADD_GIT=yes ./buetow.org.sh --generate - cp ./content/md/index.md index.md - git add index.md - git commit -a - git push -test: shellcheck - LOG_VERBOSE=yes ./buetow.org.sh --test -shellcheck: - shellcheck \ - --norc \ - --external-sources \ - --check-sourced \ - --exclude=SC2155,SC2010,SC2154,SC1090 \ - buetow.org.sh diff --git a/README.md b/README.md deleted file mode 100644 index fb8450b5..00000000 --- a/README.md +++ /dev/null @@ -1,29 +0,0 @@ -buetow.org Gemini capsule -========================= - -This is the source code of my Gemini capsule. You can reach the site(s) here: - -* Via Gemini/Gemtext : [gemini://buetow.org](gemini://buetow.org) -* Via HTTP/HTML: [https://buetow.org](https://buetow.org) -* [Gemini Webproxy](https://portal.mozz.us/gemini/buetow.org) -* [GitHub Markdown](https://github.com/snonux/buetow.org/blob/master/content/md/index.md) -* [GitHub Page](https://snonux.github.io/buetow.org/content/md) - -## Software I use to maintain this capsule - -* Text editor: [Vim](https://www.vim.org) -* Gemini server: [a-h/gemini](https://github.com/a-h/gemini) -* Some Bash scripting (GNU Bash probably 5.x or higher required) - -## HTTP fallback software used - -* Web server: [Apache HTTPD](https://httpd.apache.org) - -## TODO - -These are things I want to do with this project in near future: - -* Speed it up a bit: Make it so, that only changed .gmi files (or changed HTML templates) result into re-generating other formats. -* Write a blog post about buetow.org.sh script -* Maybe put the ./content dirs into different git projects and then include them via submodules. This has the benefit that the GitHub page has the resulting index.md in the root folder. -* Custom alt.buetow.org domain for GitHub page. diff --git a/_config.yml b/_config.yml deleted file mode 100644 index fc24e7a6..00000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-hacker \ No newline at end of file diff --git a/buetow.org.conf b/buetow.org.conf deleted file mode 100644 index 3d6a73d7..00000000 --- a/buetow.org.conf +++ /dev/null @@ -1,7 +0,0 @@ -declare -xr DOMAIN=buetow.org -declare -xr SUBTITLE='Having fun with computers!' -declare -xr CONTENT_DIR=./content -declare -xr AUTHOR='Paul Buetow' -declare -xr EMAIL='comments@mx.buetow.org' -declare -xr IMAGE_PATTERN='\.(jpg|png|gif)$' -declare -xr ATOM_MAX_ENTRIES=42 diff --git a/buetow.org.sh b/buetow.org.sh deleted file mode 100755 index 57535b99..00000000 --- a/buetow.org.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash -# -# The buetow.org.sh static site generator -# by Paul Buetow 2021 - -declare -r ARG="$1"; shift -declare DATE=date -declare SED=sed -declare GREP=grep -which gdate &>/dev/null && DATE=gdate -which gsed &>/dev/null && SED=gsed -which ggrep &>/dev/null && GREP=ggrep -readonly DATE -readonly SED -readonly GREP - -source buetow.org.conf -source ./packages/assert.source.sh -source ./packages/atomfeed.source.sh -source ./packages/gemfeed.source.sh -source ./packages/generate.source.sh -source ./packages/html.source.sh -source ./packages/log.source.sh -source ./packages/md.source.sh - -help () { - cat < * - : -_ /) - : ( ( .-''`'. - . \ \ / \ - . \ \ / \ - \ `-' `'. - \ . ' / `. - \ ( \ ) ( .') - ,, t '. | / | ( - '|``_/^\___ '| |`'-..-'| ( () -_~~|~/_|_|__/|~~~~~~~ | / ~~~~~ | | ~~~~~~~~ - -_ |L[|]L|/ | |\ MJP ) ) - ( |( / /| - ~~ ~ ~ ~~~~ | /\\ / /| | - || \\ _/ / | | - ~ ~ ~~~ _|| (_/ (___)_| |Nov291999 - (__) (____) -``` - -> Written by Paul Buetow 2008-06-26, last updated 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](https://en.wikipedia.org/wiki/Perl) - -## math.pl - -``` -#!/usr/bin/perl - -# (C) 2006 by Paul C. Buetow (http://paul.buetow.org) - -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 - -``` -#!/usr/bin/perl - -# (C) 2006 by Paul C. Buetow (http://paul.buetow.org) - -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 Github to see my other poems too: - -[https://github.com/snonux/perl-poetry](https://github.com/snonux/perl-poetry) - -E-Mail me your thoughts at comments@mx.buetow.org! - -[Go back to the main site](../) diff --git a/content/md/gemfeed/2010-04-09-standard-ml-and-haskell.md b/content/md/gemfeed/2010-04-09-standard-ml-and-haskell.md deleted file mode 100644 index 5b9b38d8..00000000 --- a/content/md/gemfeed/2010-04-09-standard-ml-and-haskell.md +++ /dev/null @@ -1,174 +0,0 @@ -# Standard ML and Haskell - -> Written by Paul Buetow 2010-04-09 - -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 know a little Haskell, could I do not help myself and I implemented the same exercises in Haskell too. - -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 explicitly write down the function types. 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: - -## Defining a multi data type - -Standard ML: - -``` -datatype ’a multi - = EMPTY - | ELEM of ’a - | UNION of ’a multi * ’a multi -``` - -Haskell: - -``` -data (Eq a) => Multi a - = Empty - | Elem a - | Union (Multi a) (Multi a) - deriving Show -``` - -## Processing a multi - -Standard ML: - -``` -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: - -``` -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: - -``` -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: - -``` -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: - -``` -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: - -``` -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: - -``` -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: - -``` -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 always 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 me your thoughts at comments@mx.buetow.org! - -[Go back to the main site](../) diff --git a/content/md/gemfeed/2010-05-09-the-fype-programming-language.md b/content/md/gemfeed/2010-05-09-the-fype-programming-language.md deleted file mode 100644 index 05844b4d..00000000 --- a/content/md/gemfeed/2010-05-09-the-fype-programming-language.md +++ /dev/null @@ -1,510 +0,0 @@ -# The Fype Programming Language - -``` - ____ _ __ - / / _|_ _ _ __ ___ _ _ ___ __ _| |__ / _|_ _ - / / |_| | | | '_ \ / _ \ | | | |/ _ \/ _` | '_ \ | |_| | | | - _ / /| _| |_| | |_) | __/ | |_| | __/ (_| | | | |_| _| |_| | -(_)_/ |_| \__, | .__/ \___| \__, |\___|\__,_|_| |_(_)_| \__, | - |___/|_| |___/ |___/ -``` - -> Written by Paul Buetow 2010-05-09, last updated 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. To be honest, besides learning and fun there is really no other use case of why Fype actually exists as many other programming languages are much faster and more powerful. - -The Fype syntax is very simple and is using a maximum look ahead of 1 and a very easy 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!". - -## 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 how it works here as an example is a snippet from the main Fype "class header": - -``` -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 main Fype "class implementation": - -``` -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 can be defined with the "my" keyword (inspired by Perl :-). If you don't assign a value during declaration, then it's using 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 is: - -``` -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 normal variables but can be also used for function and procedure names etc (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 are optional. They help to make the code better readable. They also help to force 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 return a value of 0! Fype tries to free not needed memory ASAP. This may change in future versions in order 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 newline. - -## 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 its 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 in order 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 scoped! -``` - -### Nested functions - -Nested functions work the same way the nested procedures work, with the exception 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 multi dimensional 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 last 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://github.com/snonux/fype](https://github.com/snonux/fype) - -E-Mail me your thoughts at comments@mx.buetow.org! - -[Go back to the main site](../) diff --git a/content/md/gemfeed/2011-05-07-perl-daemon-service-framework.md b/content/md/gemfeed/2011-05-07-perl-daemon-service-framework.md deleted file mode 100644 index e47f407c..00000000 --- a/content/md/gemfeed/2011-05-07-perl-daemon-service-framework.md +++ /dev/null @@ -1,163 +0,0 @@ -# Perl Daemon (Service Framework) - -``` - a'! _,,_ a'! _,,_ a'! _,,_ - \\_/ \ \\_/ \ \\_/ \.-, - \, /-( /'-,\, /-( /'-, \, /-( / - //\ //\\ //\ //\\ //\ //\\jrei -``` - -> Written by Paul Buetow 2011-05-07, last updated 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. In order to do something useful, a module (written in Perl) must be provided. - -## Features - -PerlDaemon supports: - -* Automatic daemonizing -* Logging -* logrotation (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 - -``` -# 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 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 command line (that then will take precedence over the config file). All available config properties can be viewed via "./control keys": - -``` -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 runinterval seconds -daemon.modules.runinterval=3 - -# Path to the alive file (is touched every loopinterval seconds, usable to monitor) -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: - -``` -$ ./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: - -``` -$ ./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 in correct intervals. Each loop run a time carry value is recorded and added to the next loop run in order to catch up 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 quite self-explanatory if you know 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: - -``` - 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://github.com/snonux/perldaemon](https://github.com/snonux/perldaemon) - -E-Mail me your thoughts at comments@mx.buetow.org! - -[Go back to the main site](../) diff --git a/content/md/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md b/content/md/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md deleted file mode 100644 index a422ef1e..00000000 --- a/content/md/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md +++ /dev/null @@ -1,110 +0,0 @@ -# The fibonacci.pl.c Polyglot - -> Written by Paul Buetow 2014-03-24 - -In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it - -[https://en.wikipedia.org/wiki/Polyglot_(computing)](https://en.wikipedia.org/wiki/Polyglot_(computing)) - -## The Fibonacci numbers - -For fun, I programmed my own Polyglot, which is both, valid Perl and C code. The interesting part about C is, that $ is a valid character to start variable names with: - -``` -#include - -#define $arg function_argument -#define my int -#define sub int -#define BEGIN int main(void) - -my $arg; - -sub hello() { - printf("Hello, welcome to Perl-C!\n"); - printf("This program is both, valid C and Perl code!\n"); - printf("It calculates all fibonacci numbers from 0 to 9!\n\n"); - return 0; -} - -sub fibonacci() { - my $n = $arg; - - if ($n < 2) { - return $n; - } - - $arg = $n - 1; - my $fib1 = fibonacci(); - $arg = $n - 2; - my $fib2 = fibonacci(); - - return $fib1 + $fib2; -} - -BEGIN { - hello(); - my $i = 0; - - for ($i = 0; $i <= 10; ++$i) { - $arg = $i; - printf("fib(%d) = %d\n", $i, fibonacci()); - } - - return 0; -} -``` - -You can find the whole source code at GitHub: - -[https://github.com/snonux/perl-c-fibonacci](https://github.com/snonux/perl-c-fibonacci) - -### Let's run it with Perl: - -``` -❯ perl fibonacci.pl.c -Hello, welcome to Perl-C! -This program is both, valid C and Perl code! -It calculates all fibonacci numbers from 0 to 9! - -fib(0) = 0 -fib(1) = 1 -fib(2) = 1 -fib(3) = 2 -fib(4) = 3 -fib(5) = 5 -fib(6) = 8 -fib(7) = 13 -fib(8) = 21 -fib(9) = 34 -fib(10) = 55 -``` - - -### Let's compile it as C and run the binary: - -``` -❯ gcc fibonacci.pl.c -o fibonacci -❯ ./fibonacci -Hello, welcome to Perl-C! -This program is both, valid C and Perl code! -It calculates all fibonacci numbers from 0 to 9! - -fib(0) = 0 -fib(1) = 1 -fib(2) = 1 -fib(3) = 2 -fib(4) = 3 -fib(5) = 5 -fib(6) = 8 -fib(7) = 13 -fib(8) = 21 -fib(9) = 34 -fib(10) = 55 -``` - -It's really fun to play with :-). - -E-Mail me your thoughts at comments@mx.buetow.org! - -[Go back to the main site](../) diff --git a/content/md/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.md b/content/md/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.md deleted file mode 100644 index 8277601c..00000000 --- a/content/md/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.md +++ /dev/null @@ -1,180 +0,0 @@ -# Run Debian on your phone with Debroid - -``` - ____ _ _ _ -| _ \ ___| |__ _ __ ___ (_) __| | -| | | |/ _ \ '_ \| '__/ _ \| |/ _` | -| |_| | __/ |_) | | | (_) | | (_| | -|____/ \___|_.__/|_| \___/|_|\__,_| - -``` - -> Written by Paul Buetow 2015-12-05, last updated 2021-05-16 - -You can use the following tutorial to install a full-blown Debian GNU/Linux Chroot on a 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). - -[![./2015-12-05-run-debian-on-your-phone-with-debroid/Deboroid.png](./2015-12-05-run-debian-on-your-phone-with-debroid/Deboroid.png)](./2015-12-05-run-debian-on-your-phone-with-debroid/Deboroid.png) - -## Foreword - -A couple of years have passed since I last worked on Debroid. At the moment 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. - -## Step by step guide - -All scripts mentioned here can be found on GitHub at: - -[https://github.com/snonux/debroid](https://github.com/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 personal Laptop). The following steps prepare an initial Debian base image, which then later can be transferred to the phone. - -```code -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: - -``` -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): - -``` -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. - -``` -# 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 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: - -I you want to start Debroid automatically every time when your phone starts, then do the following: - -``` -adb push data/local/userinit.sh /data/local/userinit.sh -adb shell -chmod +x /data/local/userinit.sh -exit -``` - -Reboot & test! Enjoy! - -E-Mail me your thoughts at comments@mx.buetow.org! - -[Go back to the main site](../) diff --git a/content/md/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid/Deboroid.png b/content/md/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid/Deboroid.png deleted file mode 100644 index f76cf226..00000000 Binary files a/content/md/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid/Deboroid.png and /dev/null differ diff --git a/content/md/gemfeed/2016-04-03-offsite-backup-with-zfs.md b/content/md/gemfeed/2016-04-03-offsite-backup-with-zfs.md deleted file mode 100644 index 8e0fdfcf..00000000 --- a/content/md/gemfeed/2016-04-03-offsite-backup-with-zfs.md +++ /dev/null @@ -1,42 +0,0 @@ -# Offsite backup with ZFS - -``` - ________________ -|# : : #| -| : ZFS/GELI : | -| : Offsite : | -| : Backup : | -| :___________: | -| _________ | -| | __ | | -| || | | | -\____||__|_____|__| -``` - -> Written by Paul Buetow 2016-04-03 - -## Please don't lose all my pictures again! - -When it comes to data storage and potential data loss I am a paranoid person. It is not just due to my job but also due to a personal experience I encountered over 10 years ago: A single drive failure and loss of all my data (pictures, music, ....). - -A little about my personal infrastructure: I am running my own (mostly FreeBSD based) root servers (across several countries: Two in Germany, one in Canada, one in Bulgaria) which store all my online data (E-Mail and my Git repositories). I am syncing incremental (and encrypted) ZFS snapshots between these servers forth and back so either data could be recovered from the other server. - -## Local storage box for offline data - -Also, I am operating a local server (an HP MicroServer) at home in my apartment. Full snapshots of all ZFS volumes are pulled from the "online" servers to the local server every other week and the incremental ZFS snapshots every day. That local server has a ZFS ZMIRROR with 3 disks configured (local triple redundancy). I keep up to half a year worth of ZFS snapshots of all volumes. That local server also contains all my offline data such as pictures, private documents, videos, books, various other backups, etc. - -Once weekly all the data of that local server is copied to two external USB drives as a backup (without the historic snapshots). For simplicity these USB drives are not formatted with ZFS but with good old UFS. This gives me a chance to recover from a (potential) ZFS disaster. ZFS is a complex thing. Sometimes it is good not to trust complex things! - -## Storing it at my apartment is not enough - -Now I am thinking about an offsite backup of all this local data. The problem is, that all the data remains on a single physical location: My local MicroServer. What happens when the house burns or someone steals my server including the internal disks and the attached USB drives? My first thought was to back up everything to the "cloud". The major issue here is however the limited amount of available upload bandwidth (only 1MBit/s). - -The solution is adding another USB drive (2TB) with an encryption container (GELI) and a ZFS pool on it. The GELI encryption requires a secret key and a secret passphrase. I am updating the data to that drive once every 3 months (my calendar is reminding me about it) and afterwards I keep that drive at a secret location outside of my apartment. All the information needed to decrypt (mounting the GELI container) is stored at another (secure) place. Key and passphrase are kept at different places though. Even if someone would know of it, he would not be able to decrypt it as some additional insider knowledge would be required as well. - -## Walking one round less - -I am thinking of buying a second 2TB USB drive and to set it up the same way as the first one. So I could alternate the backups. One drive would be at the secret location, and the other drive would be at home. And these drives would swap location after each cycle. This would give some security about the failure of that drive and I would have to go to the secret location only once (swapping the drives) instead of twice (picking that drive up in order to update the data + bringing it back to the secret location). - -E-Mail me your thoughts at comments@mx.buetow.org! - -[Go back to the main site](../) diff --git a/content/md/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md b/content/md/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md deleted file mode 100644 index c6ef908a..00000000 --- a/content/md/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md +++ /dev/null @@ -1,392 +0,0 @@ -# Jails and ZFS with Puppet on FreeBSD - -``` - __ __ - (( \---/ )) - )__ __( - / ()___() \ - \ /(_)\ / - \ \_|_/ / - _______> <_______ - //\ |>o<| /\\ - \\/___ ___\// - | | - | | - | | - | | - `--....---' - \ \ - \ `. hjw - \