From 23d870c8b628e48d8d20f532fe5e877cbaa79d40 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 4 May 2021 21:45:55 +0100 Subject: Add Perl Poetry post --- content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi | 143 ++++++++++++++++++++ content/gemtext/gemfeed/atom.xml | 13 +- content/gemtext/index.gmi | 1 + content/html/gemfeed/2008-06-26-perl-poetry.html | 150 +++++++++++++++++++++ content/html/gemfeed/atom.xml | 13 +- content/html/index.html | 1 + content/meta/gemfeed/2008-06-26-perl-poetry.meta | 5 + 7 files changed, 324 insertions(+), 2 deletions(-) create mode 100644 content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi create mode 100644 content/html/gemfeed/2008-06-26-perl-poetry.html create mode 100644 content/meta/gemfeed/2008-06-26-perl-poetry.meta diff --git a/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi b/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi new file mode 100644 index 00000000..ea936b91 --- /dev/null +++ b/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi @@ -0,0 +1,143 @@ +> Written by Paul Buetow 2008-06-26 + +=> ../ Go back to the main site + +# Perl Poetry + +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 exists 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 + +## 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 + +E-Mail me your thoughts at comments@mx.buetow.org! diff --git a/content/gemtext/gemfeed/atom.xml b/content/gemtext/gemfeed/atom.xml index b5fbe934..de608389 100644 --- a/content/gemtext/gemfeed/atom.xml +++ b/content/gemtext/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-03T10:06:42+01:00 + 2021-05-04T21:44:21+01:00 buetow.org feed Having fun with computers! @@ -72,4 +72,15 @@ comments@mx.buetow.org + + Perl Poetry + + gemini://buetow.org/gemfeed/2008-06-26-perl-poetry.gmi + 2008-06-26T21:43:51+01:00 + 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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site. + + Paul Buetow + comments@mx.buetow.org + + diff --git a/content/gemtext/index.gmi b/content/gemtext/index.gmi index 15752c19..0d69bd80 100644 --- a/content/gemtext/index.gmi +++ b/content/gemtext/index.gmi @@ -57,3 +57,4 @@ I have switched blog software multiple times. I might be back filling some of th => ./gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.gmi 2016-05-22 Spinning up my own authoritative DNS servers => ./gemfeed/2016-04-16-offsite-backup-with-zfs-part2.gmi 2016-04-16 Offsite backup with ZFS (Part 2) => ./gemfeed/2016-04-03-offsite-backup-with-zfs.gmi 2016-04-03 Offsite backup with ZFS +=> ./gemfeed/2008-06-26-perl-poetry.gmi 2008-06-26 Perl Poetry diff --git a/content/html/gemfeed/2008-06-26-perl-poetry.html b/content/html/gemfeed/2008-06-26-perl-poetry.html new file mode 100644 index 00000000..45658370 --- /dev/null +++ b/content/html/gemfeed/2008-06-26-perl-poetry.html @@ -0,0 +1,150 @@ + + + +Having fun with computers! + + + + + +
Written by Paul Buetow 2008-06-26
+Go back to the main site
+

Perl Poetry

+

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 exists 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
+

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 <<EMail
+ to the parents to buy a new christmas tree!!!!111
+ and send the
+EMail
+;wait and redo deliver until defined local $tree;
+
+redo Santa, pipe $gifts, to_childs;
+redo Santa and do return if last one, is, delivered ;}
+
+END {} our $mission and do sleep until next Christmas ;}
+
+__END__
+
+This is perl, v5.8.8 built for i386-freebsd-64int
+
+

shopping.pl

+
+#!/usr/bin/perl
+
+# (C) 2007 by Paul C. Buetow (http://paul.buetow.org) 
+
+BEGIN{} goto mall for $shopping; 
+
+m/y/; mall: seek$s, cool products(), { to => $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
+

E-Mail me your thoughts at comments@mx.buetow.org!

+ + diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml index 2d43cf31..d3643b93 100644 --- a/content/html/gemfeed/atom.xml +++ b/content/html/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-03T10:04:48+01:00 + 2021-05-04T21:44:21+01:00 buetow.org feed Having fun with computers! @@ -72,4 +72,15 @@ comments@mx.buetow.org + + Perl Poetry + + https://buetow.org/gemfeed/2008-06-26-perl-poetry.html + 2008-06-26T21:43:51+01:00 + 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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site. + + Paul Buetow + comments@mx.buetow.org + + diff --git a/content/html/index.html b/content/html/index.html index 99d03f62..2f6129af 100644 --- a/content/html/index.html +++ b/content/html/index.html @@ -61,5 +61,6 @@ li { color: #98be65; } 2016-05-22 Spinning up my own authoritative DNS servers
2016-04-16 Offsite backup with ZFS (Part 2)
2016-04-03 Offsite backup with ZFS
+2008-06-26 Perl Poetry
diff --git a/content/meta/gemfeed/2008-06-26-perl-poetry.meta b/content/meta/gemfeed/2008-06-26-perl-poetry.meta new file mode 100644 index 00000000..9238d83a --- /dev/null +++ b/content/meta/gemfeed/2008-06-26-perl-poetry.meta @@ -0,0 +1,5 @@ +local meta_date="2008-06-26T21:43:51+01:00" +local meta_author="Paul Buetow" +local meta_email="comments@mx.buetow.org" +local meta_title="Perl Poetry" +local meta_summary="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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site." -- cgit v1.2.3 From 4f4693c142d75d764662f6e501fea5b96c7995a6 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 4 May 2021 21:59:26 +0100 Subject: add camel ascii art --- content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi | 23 ++++++++++++++++++++++ content/html/gemfeed/2008-06-26-perl-poetry.html | 22 +++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi b/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi index ea936b91..15b25861 100644 --- a/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi +++ b/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi @@ -4,6 +4,29 @@ # Perl Poetry +``` + '\|/' * +-- * ----- + /|\ ____ + ' | ' {_ o^> * + : -_ /) + : ( ( .-''`'. + . \ \ / \ + . \ \ / \ + \ `-' `'. + \ . ' / `. + \ ( \ ) ( .') + ,, t '. | / | ( + '|``_/^\___ '| |`'-..-'| ( () +_~~|~/_|_|__/|~~~~~~~ | / ~~~~~ | | ~~~~~~~~ + -_ |L[|]L|/ | |\ MJP ) ) + ( |( / /| + ~~ ~ ~ ~~~~ | /\\ / /| | + || \\ _/ / | | + ~ ~ ~~~ _|| (_/ (___)_| |Nov291999 + (__) (____) +``` + 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 exists 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." diff --git a/content/html/gemfeed/2008-06-26-perl-poetry.html b/content/html/gemfeed/2008-06-26-perl-poetry.html index 45658370..c088b7ae 100644 --- a/content/html/gemfeed/2008-06-26-perl-poetry.html +++ b/content/html/gemfeed/2008-06-26-perl-poetry.html @@ -21,6 +21,28 @@ li { color: #98be65; }
Written by Paul Buetow 2008-06-26
Go back to the main site

Perl Poetry

+
+ '\|/'                                  *
+-- * -----
+  /|\      ____
+ ' | '    {_   o^>       *
+   :        -_  /)
+   :         (   (        .-''`'.
+   .          \   \      /       \
+   .           \    \   /         \
+                \    `-'           `'.
+                 \    . '        /    `.
+                  \  ( \  )     (     .')
+   ,,   t          '. |  /       |     (
+  '|``_/^\___        '|  |`'-..-'|   ( ()
+_~~|~/_|_|__/|~~~~~~~ |  / ~~~~~ |   | ~~~~~~~~
+ -_  |L[|]L|/         | |\ MJP   )   )
+                      ( |(       /  /|
+   ~~ ~  ~ ~~~~       | /\\     / /| |
+                      ||  \\  _/ / | |
+             ~ ~ ~~~ _|| (_/ (___)_| |Nov291999
+                    (__)         (____)
+

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 exists 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
-- cgit v1.2.3 From dce9ea45cd7c6930b6caf6d981626a692831249a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 4 May 2021 22:18:55 +0100 Subject: typos --- content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi | 2 +- content/html/gemfeed/2008-06-26-perl-poetry.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi b/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi index 15b25861..96578921 100644 --- a/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi +++ b/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi @@ -27,7 +27,7 @@ _~~|~/_|_|__/|~~~~~~~ | / ~~~~~ | | ~~~~~~~~ (__) (____) ``` -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 exists for fun and demonstrate what you can do with Perl syntax. +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." diff --git a/content/html/gemfeed/2008-06-26-perl-poetry.html b/content/html/gemfeed/2008-06-26-perl-poetry.html index c088b7ae..fff502de 100644 --- a/content/html/gemfeed/2008-06-26-perl-poetry.html +++ b/content/html/gemfeed/2008-06-26-perl-poetry.html @@ -43,7 +43,7 @@ _~~|~/_|_|__/|~~~~~~~ | / ~~~~~ | | ~~~~~~~~ ~ ~ ~~~ _|| (_/ (___)_| |Nov291999 (__) (____) -

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 exists for fun and demonstrate what you can do with Perl syntax.

+

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

math.pl

-- cgit v1.2.3 From 721f56d3cc981e3424a595bcb78d231ce5f4bdb3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 5 May 2021 09:33:09 +0100 Subject: Add "The Fype Programming Language" --- content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi | 2 +- .../2010-05-09-the-fype-programming-language.gmi | 467 +++++++++++++++++++++ content/gemtext/gemfeed/atom.xml | 13 +- content/gemtext/index.gmi | 1 + content/html/gemfeed/2008-06-26-perl-poetry.html | 2 +- .../2010-05-09-the-fype-programming-language.html | 387 +++++++++++++++++ content/html/gemfeed/atom.xml | 13 +- content/html/index.html | 1 + .../2010-05-09-the-fype-programming-language.meta | 5 + 9 files changed, 887 insertions(+), 4 deletions(-) create mode 100644 content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi create mode 100644 content/html/gemfeed/2010-05-09-the-fype-programming-language.html create mode 100644 content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta diff --git a/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi b/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi index 96578921..1ba53967 100644 --- a/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi +++ b/content/gemtext/gemfeed/2008-06-26-perl-poetry.gmi @@ -1,4 +1,4 @@ -> Written by Paul Buetow 2008-06-26 +> Written by Paul Buetow 2008-06-26, last updated 2021-05-04 => ../ Go back to the main site diff --git a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi new file mode 100644 index 00000000..064a08ce --- /dev/null +++ b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi @@ -0,0 +1,467 @@ +> Written by Paul Buetow 2010-05-09, last updated 2021-05-05 + +=> ../ Go back to the main site + +``` + ____ _ __ + / / _|_ _ _ __ ___ _ _ ___ __ _| |__ / _|_ _ + / / |_| | | | '_ \ / _ \ | | | |/ _ \/ _` | '_ \ | |_| | | | + _ / /| _| |_| | |_) | __/ | |_| | __/ (_| | | | |_| _| |_| | +(_)_/ |_| \__, | .__/ \___| \__, |\___|\__,_|_| |_(_)_| \__, | + |___/|_| |___/ |___/ + +``` + +# The Fype Programming Language + +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": + +``` +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; +``` + +``` +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; +``` + +## 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! +``` + +## 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 + +E-Mail me your thoughts at comments@mx.buetow.org! diff --git a/content/gemtext/gemfeed/atom.xml b/content/gemtext/gemfeed/atom.xml index de608389..57a2d485 100644 --- a/content/gemtext/gemfeed/atom.xml +++ b/content/gemtext/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-04T21:44:21+01:00 + 2021-05-05T09:27:32+01:00 buetow.org feed Having fun with computers! @@ -72,6 +72,17 @@ comments@mx.buetow.org + + The Fype Programming Language + + gemini://buetow.org/gemfeed/2010-05-09-the-fype-programming-language.gmi + 2010-05-09T09:26:28+01:00 + 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.. .....to read on please visit my site. + + Paul Buetow + comments@mx.buetow.org + + Perl Poetry diff --git a/content/gemtext/index.gmi b/content/gemtext/index.gmi index 0d69bd80..1e4aadba 100644 --- a/content/gemtext/index.gmi +++ b/content/gemtext/index.gmi @@ -57,4 +57,5 @@ I have switched blog software multiple times. I might be back filling some of th => ./gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.gmi 2016-05-22 Spinning up my own authoritative DNS servers => ./gemfeed/2016-04-16-offsite-backup-with-zfs-part2.gmi 2016-04-16 Offsite backup with ZFS (Part 2) => ./gemfeed/2016-04-03-offsite-backup-with-zfs.gmi 2016-04-03 Offsite backup with ZFS +=> ./gemfeed/2010-05-09-the-fype-programming-language.gmi 2020-05-09 The Fype Programming Language => ./gemfeed/2008-06-26-perl-poetry.gmi 2008-06-26 Perl Poetry diff --git a/content/html/gemfeed/2008-06-26-perl-poetry.html b/content/html/gemfeed/2008-06-26-perl-poetry.html index fff502de..758732b3 100644 --- a/content/html/gemfeed/2008-06-26-perl-poetry.html +++ b/content/html/gemfeed/2008-06-26-perl-poetry.html @@ -18,7 +18,7 @@ li { color: #98be65; } -
Written by Paul Buetow 2008-06-26
+
Written by Paul Buetow 2008-06-26, last updated 2021-05-04
Go back to the main site

Perl Poetry

diff --git a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html
new file mode 100644
index 00000000..41bfc0e7
--- /dev/null
+++ b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html
@@ -0,0 +1,387 @@
+
+
+
+Having fun with computers!
+
+
+
+
+
+
Written by Paul Buetow 2010-05-09, last updated 2021-05-05
+Go back to the main site
+
+      ____                                      _        __       
+     / / _|_   _ _ __   ___    _   _  ___  __ _| |__    / _|_   _ 
+    / / |_| | | | '_ \ / _ \  | | | |/ _ \/ _` | '_ \  | |_| | | |
+ _ / /|  _| |_| | |_) |  __/  | |_| |  __/ (_| | | | |_|  _| |_| |
+(_)_/ |_|  \__, | .__/ \___|   \__, |\___|\__,_|_| |_(_)_|  \__, |
+           |___/|_|            |___/                        |___/ 
+
+
+

The Fype Programming Language

+

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":

+
+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;
+
+
+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) <any> - <any>
+(any) <any> * <any>
+(any) <any> / <any>
+(integer) <any> == <any>
+(integer) <any> != <any>
+(integer) <any> <= <any>
+(integer) <any> gt <any>
+(integer) <any> <> <any>
+(integer) <any> gt <any>
+(integer) not <any>
+
+

Bitwise expressions

+
+(integer) <any> :< <any>
+(integer) <any> :> <any>
+(integer) <any> and <any>
+(integer) <any> or <any>
+(integer) <any> xor <any>
+
+

Numeric expressions

+
+(number) neg <number>
+
+

... returns the negative value of "number":

+
+(integer) no <integer>
+
+

... returns 1 if the argument is 0, otherwise it will return 0! If no argument is given, then 0 is returned!

+
+(integer) yes <integer>
+
+

... 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 <expression> { <statements> }
+
+

... runs the statements if the expression evaluates to a true value.

+
+ifnot <expression> { <statements> }
+
+

... runs the statements if the expression evaluates to a false value.

+
+while <expression> { <statements> }
+
+

... runs the statements as long as the expression evaluates to a true value.

+
+until <expression> { <statements> }
+
+

... 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;
+
+

Definedness

+
+(integer) defined <identifier>
+
+

... returns 1 if "identifier" has been defined. Returns 0 otherwise.

+
+(integer) undef <identifier>
+
+

... 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 <integer>
+
+

... 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 <any>
+
+

... prints out the argument

+
+(any) say <any>
+
+

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!
+
+

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
+

E-Mail me your thoughts at comments@mx.buetow.org!

+ + diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml index d3643b93..ff147c01 100644 --- a/content/html/gemfeed/atom.xml +++ b/content/html/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-04T21:44:21+01:00 + 2021-05-05T09:27:32+01:00 buetow.org feed Having fun with computers! @@ -72,6 +72,17 @@ comments@mx.buetow.org + + The Fype Programming Language + + https://buetow.org/gemfeed/2010-05-09-the-fype-programming-language.html + 2010-05-09T09:26:28+01:00 + 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.. .....to read on please visit my site. + + Paul Buetow + comments@mx.buetow.org + + Perl Poetry diff --git a/content/html/index.html b/content/html/index.html index 2f6129af..1c3cdf0b 100644 --- a/content/html/index.html +++ b/content/html/index.html @@ -61,6 +61,7 @@ li { color: #98be65; } 2016-05-22 Spinning up my own authoritative DNS servers
2016-04-16 Offsite backup with ZFS (Part 2)
2016-04-03 Offsite backup with ZFS
+2020-05-09 The Fype Programming Language
2008-06-26 Perl Poetry
diff --git a/content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta b/content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta new file mode 100644 index 00000000..77c4a44d --- /dev/null +++ b/content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta @@ -0,0 +1,5 @@ +local meta_date="2010-05-09T09:26:28+01:00" +local meta_author="Paul Buetow" +local meta_email="comments@mx.buetow.org" +local meta_title="The Fype Programming Language" +local meta_summary="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.. .....to read on please visit my site." -- cgit v1.2.3 From abf8a0771b912c5e19368a913827932bc3bd9a21 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 5 May 2021 09:38:11 +0100 Subject: separate header from impl. --- content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi | 4 +++- content/html/gemfeed/2010-05-09-the-fype-programming-language.html | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi index 064a08ce..ac7c3790 100644 --- a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi +++ b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi @@ -24,7 +24,7 @@ Fype is a recursive acronym and means "Fype is For Your Program Execution" or "F 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": +To give you an idea how it works here as an example is a snippet from the main Fype "class header": ``` typedef struct { @@ -35,6 +35,8 @@ typedef struct { } Fype; ``` +And here is a snippet from the main Fype "class implementation": + ``` Fype* fype_new() { diff --git a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html index 41bfc0e7..40beea42 100644 --- a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html +++ b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html @@ -35,7 +35,7 @@ li { color: #98be65; }

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":

+

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
@@ -44,6 +44,7 @@ typedef struct {
    char *c_basename;
 } Fype;
 
+

And here is a snippet from the main Fype "class implementation":

 Fype*
 fype_new() {
-- 
cgit v1.2.3


From 9ae383ee25faf1256e4c5386715634a543d4a314 Mon Sep 17 00:00:00 2001
From: Paul Buetow 
Date: Wed, 5 May 2021 09:40:27 +0100
Subject: fix date in index

---
 content/gemtext/index.gmi | 2 +-
 content/html/index.html   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/content/gemtext/index.gmi b/content/gemtext/index.gmi
index 1e4aadba..b52a970d 100644
--- a/content/gemtext/index.gmi
+++ b/content/gemtext/index.gmi
@@ -57,5 +57,5 @@ I have switched blog software multiple times. I might be back filling some of th
 => ./gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.gmi 2016-05-22 Spinning up my own authoritative DNS servers
 => ./gemfeed/2016-04-16-offsite-backup-with-zfs-part2.gmi 2016-04-16 Offsite backup with ZFS (Part 2)
 => ./gemfeed/2016-04-03-offsite-backup-with-zfs.gmi 2016-04-03 Offsite backup with ZFS
-=> ./gemfeed/2010-05-09-the-fype-programming-language.gmi 2020-05-09 The Fype Programming Language
+=> ./gemfeed/2010-05-09-the-fype-programming-language.gmi 2010-05-09 The Fype Programming Language
 => ./gemfeed/2008-06-26-perl-poetry.gmi 2008-06-26 Perl Poetry
diff --git a/content/html/index.html b/content/html/index.html
index 1c3cdf0b..8e9c7e5d 100644
--- a/content/html/index.html
+++ b/content/html/index.html
@@ -61,7 +61,7 @@ li { color: #98be65; }
 2016-05-22 Spinning up my own authoritative DNS servers
2016-04-16 Offsite backup with ZFS (Part 2)
2016-04-03 Offsite backup with ZFS
-2020-05-09 The Fype Programming Language
+2010-05-09 The Fype Programming Language
2008-06-26 Perl Poetry
-- cgit v1.2.3 From b31d49a9e3e6e8d561731d5e9ff1cd4780e2c0cb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 5 May 2021 09:41:50 +0100 Subject: being expert is relative --- content/gemtext/resources.gmi | 2 +- content/html/resources.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/gemtext/resources.gmi b/content/gemtext/resources.gmi index dd145fa0..a6aadd84 100644 --- a/content/gemtext/resources.gmi +++ b/content/gemtext/resources.gmi @@ -2,7 +2,7 @@ # Resources -This is a list of resources I found useful. I am not an expert in all (but some) of these topics but all the resources listed here made an impact on me. I've read some of the books quite a long time ago, so there might be newer editions out there already and I might need to refresh some of the knowledge. +This is a list of resources I found useful. I am not an expert in all of these topics but all the resources listed here made an impact on me. I've read some of the books quite a long time ago, so there might be newer editions out there already and I might need to refresh some of the knowledge. The list may not be exhaustive but I will be adding more in the future. I strongly believe that educating yourself further is one of the most important things you should do in order to advance. The lists are in random order and reshuffled every time (via *sort -R*) when updates are made. diff --git a/content/html/resources.html b/content/html/resources.html index eece15cc..a0e939be 100644 --- a/content/html/resources.html +++ b/content/html/resources.html @@ -20,7 +20,7 @@ li { color: #98be65; } Go back to the main site

Resources

-

This is a list of resources I found useful. I am not an expert in all (but some) of these topics but all the resources listed here made an impact on me. I've read some of the books quite a long time ago, so there might be newer editions out there already and I might need to refresh some of the knowledge.

+

This is a list of resources I found useful. I am not an expert in all of these topics but all the resources listed here made an impact on me. I've read some of the books quite a long time ago, so there might be newer editions out there already and I might need to refresh some of the knowledge.

The list may not be exhaustive but I will be adding more in the future. I strongly believe that educating yourself further is one of the most important things you should do in order to advance. The lists are in random order and reshuffled every time (via *sort -R*) when updates are made.

You won't find any links on this site because over time the links will break. Please use your favorite search engine when you are interested in one of the resources...

-- 
cgit v1.2.3


From 86edf888ba6cf1be60facd17d5d07d794ecf0b68 Mon Sep 17 00:00:00 2001
From: Paul Buetow 
Date: Wed, 5 May 2021 09:45:07 +0100
Subject: no plenking

---
 content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi
index ac7c3790..74a6c259 100644
--- a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi
+++ b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi
@@ -229,7 +229,6 @@ Any "any" value holding a string will be automatically converted to an integer v
 
 ... returns the negative value of "number":
 
-
 ```
 (integer) no 
 ```
-- 
cgit v1.2.3


From cd604101878eacb63ffe17896e033bd86b5ba936 Mon Sep 17 00:00:00 2001
From: Paul Buetow 
Date: Wed, 5 May 2021 09:54:54 +0100
Subject: add arrays

---
 .../2010-05-09-the-fype-programming-language.gmi   | 43 ++++++++++++++++++++++
 .../2010-05-09-the-fype-programming-language.html  | 36 ++++++++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi
index 74a6c259..9aa3b675 100644
--- a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi
+++ b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi
@@ -305,6 +305,26 @@ my foo = 1;
 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 
 
 ```
@@ -455,6 +475,29 @@ 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 0. 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.:) 
diff --git a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html
index 40beea42..5dd8e5e0 100644
--- a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html
+++ b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html
@@ -265,6 +265,24 @@ my foo = 1;
 # 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 <identifier>
@@ -378,6 +396,24 @@ func foo {
 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 0. 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

-- cgit v1.2.3 From cab10097634694e8d13642bf3dd330fc15333ee3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 5 May 2021 09:56:54 +0100 Subject: fix --- content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi | 2 +- content/html/gemfeed/2010-05-09-the-fype-programming-language.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi index 9aa3b675..3b008457 100644 --- a/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi +++ b/content/gemtext/gemfeed/2010-05-09-the-fype-programming-language.gmi @@ -477,7 +477,7 @@ 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 0. 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: +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” } diff --git a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html index 5dd8e5e0..1dd0d340 100644 --- a/content/html/gemfeed/2010-05-09-the-fype-programming-language.html +++ b/content/html/gemfeed/2010-05-09-the-fype-programming-language.html @@ -397,7 +397,7 @@ 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 0. 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:

+

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”]]];
-- 
cgit v1.2.3


From 062b74ed9b5ab711c391ca7547224cdb80630f9e Mon Sep 17 00:00:00 2001
From: Paul Buetow 
Date: Wed, 5 May 2021 12:48:48 +0100
Subject: can parse meta date from feed's file name

---
 buetow.org.sh                                                  | 10 ++++++----
 content/gemtext/gemfeed/atom.xml                               |  4 ++--
 content/html/gemfeed/atom.xml                                  |  4 ++--
 .../meta/gemfeed/2010-05-09-the-fype-programming-language.meta |  2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/buetow.org.sh b/buetow.org.sh
index d8ead249..c9b3c75e 100755
--- a/buetow.org.sh
+++ b/buetow.org.sh
@@ -26,7 +26,6 @@ ERROR
 ## Atom module
 
 atom::meta () {
-    local -r now="$1"; shift
     local -r gmi_file_path="$1"; shift
     local -r meta_file=$(sed 's|gemtext|meta|; s|.gmi$|.meta|;' <<< "$gmi_file_path")
 
@@ -38,9 +37,12 @@ atom::meta () {
         local title=$(sed -n '/^# / { s/# //; p; q; }' "$gmi_file_path" | tr '"' "'")
         # Extract first paragraph from Gemtext
         local summary=$(sed -n '/^[A-Z]/ { p; q; }' "$gmi_file_path" | tr '"' "'")
+        # Extract the date from the file name.
+        local filename_date=$(basename $gmi_file_path | cut -d- -f1,2,3)
+        local date=$(date --iso-8601=seconds --date "$filename_date $(date +%H:%M:%S)")
 
         cat <> "$atom_file.tmp"
     
@@ -93,7 +95,7 @@ ATOMENTRY
 ATOMFOOTER
 
     # Delete the 3rd line of the atom feeds (global feed update timestamp)
-    if ! diff -u <(sed 3d "$atom_file.tmp") <(sed 3d "$atom_file"); then
+    if ! diff -u <(sed 3d "$atom_file") <(sed 3d "$atom_file.tmp"); then
         echo "Feed got something new!"
         mv "$atom_file.tmp" "$atom_file"
         git add "$atom_file"
diff --git a/content/gemtext/gemfeed/atom.xml b/content/gemtext/gemfeed/atom.xml
index 57a2d485..10049994 100644
--- a/content/gemtext/gemfeed/atom.xml
+++ b/content/gemtext/gemfeed/atom.xml
@@ -1,6 +1,6 @@
 
 
-    2021-05-05T09:27:32+01:00
+    2021-05-05T12:48:29+01:00
     buetow.org feed
     Having fun with computers!
     
@@ -76,7 +76,7 @@
         The Fype Programming Language
         
         gemini://buetow.org/gemfeed/2010-05-09-the-fype-programming-language.gmi
-        2010-05-09T09:26:28+01:00
+        2010-05-09T12:48:29+01:00
         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.. .....to read on please visit my site.
         
             Paul Buetow
diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml
index ff147c01..f9b5cf5b 100644
--- a/content/html/gemfeed/atom.xml
+++ b/content/html/gemfeed/atom.xml
@@ -1,6 +1,6 @@
 
 
-    2021-05-05T09:27:32+01:00
+    2021-05-05T12:48:29+01:00
     buetow.org feed
     Having fun with computers!
     
@@ -76,7 +76,7 @@
         The Fype Programming Language
         
         https://buetow.org/gemfeed/2010-05-09-the-fype-programming-language.html
-        2010-05-09T09:26:28+01:00
+        2010-05-09T12:48:29+01:00
         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.. .....to read on please visit my site.
         
             Paul Buetow
diff --git a/content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta b/content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta
index 77c4a44d..a6265580 100644
--- a/content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta
+++ b/content/meta/gemfeed/2010-05-09-the-fype-programming-language.meta
@@ -1,4 +1,4 @@
-local meta_date="2010-05-09T09:26:28+01:00"
+local meta_date="2010-05-09T12:48:29+01:00"
 local meta_author="Paul Buetow"
 local meta_email="comments@mx.buetow.org"
 local meta_title="The Fype Programming Language"
-- 
cgit v1.2.3


From dfa55b03088b7bf2942f2f252872fdabdc60ffa5 Mon Sep 17 00:00:00 2001
From: Paul Buetow 
Date: Wed, 5 May 2021 13:03:15 +0100
Subject: add index for ./gemfeed folder.

---
 buetow.org.sh                     | 31 +++++++++++++++++++++++++++++--
 content/gemtext/gemfeed/atom.xml  |  2 +-
 content/gemtext/gemfeed/index.gmi | 12 ++++++++++++
 content/html/gemfeed/atom.xml     |  2 +-
 content/html/gemfeed/index.html   | 32 ++++++++++++++++++++++++++++++++
 content/meta/gemfeed/index.meta   |  5 +++++
 6 files changed, 80 insertions(+), 4 deletions(-)
 create mode 100644 content/gemtext/gemfeed/index.gmi
 create mode 100644 content/html/gemfeed/index.html
 create mode 100644 content/meta/gemfeed/index.meta

diff --git a/buetow.org.sh b/buetow.org.sh
index c9b3c75e..d0d8b5c5 100755
--- a/buetow.org.sh
+++ b/buetow.org.sh
@@ -23,6 +23,33 @@ ERROR
     echo "Assert OK: $expected"
 }
 
+## Gemfeed module
+
+# This generates a index.gmi in the ./gemfeed subdir.
+gemfeed::generate () {
+    local -r gemfeed_dir="$CONTENT_DIR/gemtext/gemfeed"
+
+cat < "$gemfeed_dir/index.gmi.tmp"
+# $DOMAIN's Gemfeed
+
+## $SUBTITLE
+
+GEMFEED
+
+    ls "$gemfeed_dir" | grep '\.gmi$' | grep -v '^index.gmi$' | sort -r |
+    while read gmi_file; do
+        # Extract first heading as post title.
+        local title=$(sed -n '/^# / { s/# //; p; q; }' "$gemfeed_dir/$gmi_file" | tr '"' "'")
+        # Extract the date from the file name.
+        local filename_date=$(basename "$gemfeed_dir/$gmi_file" | cut -d- -f1,2,3)
+
+        echo "=> ./$gmi_file $filename_date $title" >> "$gemfeed_dir/index.gmi.tmp"
+    done
+
+    mv "$gemfeed_dir/index.gmi.tmp" "$gemfeed_dir/index.gmi"
+    git add "$gemfeed_dir/index.gmi"
+}
+
 ## Atom module
 
 atom::meta () {
@@ -88,7 +115,7 @@ ATOMHEADER
         
     
 ATOMENTRY
-    done < <(ls "$gemfeed_dir" | sort -r | grep '.gmi$' | head -n $ATOM_MAX_ENTRIES)
+    done < <(ls "$gemfeed_dir" | sort -r | grep '.gmi$' | grep -v '^index.gmi$' | head -n $ATOM_MAX_ENTRIES)
 
     cat <> "$atom_file.tmp"
 
@@ -321,9 +348,9 @@ case $ARG in
         ;;
     --publish)
         html::test
+        gemfeed::generate
         atom::generate
         html::generate
-        # git commit -a
         ;;
     --help|*)
         main::help
diff --git a/content/gemtext/gemfeed/atom.xml b/content/gemtext/gemfeed/atom.xml
index 10049994..557cf790 100644
--- a/content/gemtext/gemfeed/atom.xml
+++ b/content/gemtext/gemfeed/atom.xml
@@ -1,6 +1,6 @@
 
 
-    2021-05-05T12:48:29+01:00
+    2021-05-05T13:00:59+01:00
     buetow.org feed
     Having fun with computers!
     
diff --git a/content/gemtext/gemfeed/index.gmi b/content/gemtext/gemfeed/index.gmi
new file mode 100644
index 00000000..1fe0e7e3
--- /dev/null
+++ b/content/gemtext/gemfeed/index.gmi
@@ -0,0 +1,12 @@
+# buetow.org's Gemfeed
+
+## Having fun with computers!
+
+=> ./2021-04-24-welcome-to-the-geminispace.gmi 2021-04-24 Welcome to the Geminispace
+=> ./2021-04-22-dtail-the-distributed-log-tail-program.gmi 2021-04-22 DTail - The distributed log tail program
+=> ./2016-11-20-methods-in-c.gmi 2016-11-20 Methods in C
+=> ./2016-05-22-spinning-up-my-own-authoritative-dns-servers.gmi 2016-05-22 Spinning up my own authoritative DNS servers
+=> ./2016-04-16-offsite-backup-with-zfs-part2.gmi 2016-04-16 Offsite backup with ZFS (Part 2)
+=> ./2016-04-03-offsite-backup-with-zfs.gmi 2016-04-03 Offsite backup with ZFS
+=> ./2010-05-09-the-fype-programming-language.gmi 2010-05-09 The Fype Programming Language
+=> ./2008-06-26-perl-poetry.gmi 2008-06-26 Perl Poetry
diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml
index f9b5cf5b..905ebb2e 100644
--- a/content/html/gemfeed/atom.xml
+++ b/content/html/gemfeed/atom.xml
@@ -1,6 +1,6 @@
 
 
-    2021-05-05T12:48:29+01:00
+    2021-05-05T13:00:59+01:00
     buetow.org feed
     Having fun with computers!
     
diff --git a/content/html/gemfeed/index.html b/content/html/gemfeed/index.html
new file mode 100644
index 00000000..2ff9e052
--- /dev/null
+++ b/content/html/gemfeed/index.html
@@ -0,0 +1,32 @@
+
+
+
+Having fun with computers!
+
+
+
+
+
+

buetow.org's Gemfeed

+

Having fun with computers!

+2021-04-24 Welcome to the Geminispace
+2021-04-22 DTail - The distributed log tail program
+2016-11-20 Methods in C
+2016-05-22 Spinning up my own authoritative DNS servers
+2016-04-16 Offsite backup with ZFS (Part 2)
+2016-04-03 Offsite backup with ZFS
+2010-05-09 The Fype Programming Language
+2008-06-26 Perl Poetry
+ + diff --git a/content/meta/gemfeed/index.meta b/content/meta/gemfeed/index.meta new file mode 100644 index 00000000..b5e56cc9 --- /dev/null +++ b/content/meta/gemfeed/index.meta @@ -0,0 +1,5 @@ +local meta_date="" +local meta_author="Paul Buetow" +local meta_email="comments@mx.buetow.org" +local meta_title="buetow.org's Gemfeed - Having fun with computers!" +local meta_summary=". .....to read on please visit my site." -- cgit v1.2.3 From 45375dfae2699c50e4f9452e268ac0f26df4ca8a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 5 May 2021 13:03:45 +0100 Subject: no need of this meta file --- content/meta/gemfeed/index.meta | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 content/meta/gemfeed/index.meta diff --git a/content/meta/gemfeed/index.meta b/content/meta/gemfeed/index.meta deleted file mode 100644 index b5e56cc9..00000000 --- a/content/meta/gemfeed/index.meta +++ /dev/null @@ -1,5 +0,0 @@ -local meta_date="" -local meta_author="Paul Buetow" -local meta_email="comments@mx.buetow.org" -local meta_title="buetow.org's Gemfeed - Having fun with computers!" -local meta_summary=". .....to read on please visit my site." -- cgit v1.2.3 From 52629f3f4f0bdbd4ce2d6cda3c8a90e14a93b274 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 6 May 2021 09:43:24 +0100 Subject: include content to the atom feed --- content/gemtext/gemfeed/atom.xml | 1007 +++++++++++++++++++++++++++++++++++++- content/html/gemfeed/atom.xml | 1007 +++++++++++++++++++++++++++++++++++++- 2 files changed, 1996 insertions(+), 18 deletions(-) diff --git a/content/gemtext/gemfeed/atom.xml b/content/gemtext/gemfeed/atom.xml index 557cf790..88ed8411 100644 --- a/content/gemtext/gemfeed/atom.xml +++ b/content/gemtext/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-05T13:00:59+01:00 + 2021-05-06T09:41:34+01:00 buetow.org feed Having fun with computers! @@ -11,87 +11,1076 @@ gemini://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.gmi 2021-04-24T19:28:41+01:00 - Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is: ... to read on visit my site. Paul Buetow comments@mx.buetow.org + Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is: ... to read on visit my site. + +

Welcome to the Geminispace

+

Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is:

+gemini://buetow.org
+

If you however still use HTTP then you are just surfing the fallback HTML version of this capsule. In that case I suggest reading on what this is all about :-).

+
+
+    /\
+   /  \
+  |    |
+  |NASA|
+  |    |
+  |    |
+  |    |
+ '      `
+ |Gemini|
+ |      |
+ |______|
+  '-`'-`   .
+  / . \'\ . .'
+ ''( .'\.' ' .;'
+'.;.;' ;'.;' ..;;' AsH
+
+
+

Motivation

+

My urge to revamp my personal website

+

For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.

+

My still great Laptop running hot

+

Earlier this year (2021) I noticed that my 6 year old but still great Laptop started to become hot and slowed down while surfing the web. Also, the Laptop's fan became quite noisy. This is all due to the additional bloat such as JavaScript, excessive use of CSS, tracking cookies+pixels, ads and so on there was on the website.

+

All what I wanted was to read an interesting article but after a big advertising pop-up banner appeared and made everything worse I gave up and closed the browser tab.

+

Discovering the Gemini internet protocol

+

Around the same time I discovered a relatively new more lightweight protocol named Gemini which does not support all these CPU intensive features like HTML, JavaScript and CSS do. Also, tracking and ads is not supported by the Gemini protocol.

+

The "downside" is that due to the limited capabilities of the Gemini protocol all sites look very old and spartan. But that is not really a downside, that is in fact a design choice people made. It is up to the client software how your capsule looks. For example, you could use a graphical client with nice font renderings and colors to improve the appearance. Or you could just use a very minimalistic command line black-and-white Gemini client. It's your (the user's) choice.

+Screenshot Amfora Gemini terminal client surfing this site:Screenshot Amfora Gemini terminal client surfing this site
+

Why is there a need for a new protocol? As the modern web is a superset of Gemini, can't we just use simple HTML 1.0? That's a good and valid question. It is not a technical problem but a human problem. We tend to abuse the features once they are available. You can be sure that things stay simple and efficient as long as you are using the Gemini protocol. On the other hand you can't force every website in the modern web to only create plain and simple looking HTML pages.

+

My own Gemini capsule

+

As it is very easy to set up and maintain your own Gemini capsule (Gemini server + content composed via the Gemtext markup language) I decided to create my own. What I really like about Gemini is that I can just use my favorite text editor and get typing. I don't need to worry about the style and design of the presence and I also don't have to test anything in ten different web browsers. I can only focus on the content! As a matter of fact, I am using the Vim editor + it's spellchecker + auto word completion functionality to write this.

+

Advantages summarised

+
    +
  • Supports an alternative to the modern bloated web
  • +
  • Easy to operate and easy to write content
  • +
  • No need to worry about various web browser compatibilities
  • +
  • It's the client's responsibility how the content is designed+presented
  • +
  • Lightweight (although not as lightweight as the Gopher protocol)
  • +
  • Supports privacy (no cookies, no request header fingerprinting, TLS encryption)
  • +
  • Fun to play with (it's a bit geeky yes, but a lot of fun!)
  • +
+

Dive into deep Gemini space

+

Check out one of the following links for more information about Gemini. For example, you will find a FAQ which explains why the protocol is named "Gemini". Many Gemini capsules are dual hosted via Gemini and HTTP(S), so that people new to Gemini can sneak peek the content with a normal web browser. As a matter of fact, some people go as far as tri-hosting all their content via HTTP(S), Gemini and Gopher.

+gemini://gemini.circumlunar.space
+https://gemini.circumlunar.space
+

E-Mail me your thoughts at comments@mx.buetow.org!

+
DTail - The distributed log tail program gemini://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.gmi 2021-04-22T19:28:41+01:00 - This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too. ...to read on visit my site. Paul Buetow comments@mx.buetow.org + This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too. ...to read on visit my site. + +

DTail - The distributed log tail program

+DTail logo image:DTail logo image
+

This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too.

+Original Mimecast Engineering Blog post at Medium
+

Running a large cloud-based service requires monitoring the state of huge numbers of machines, a task for which many standard UNIX tools were not really designed. In this post, I will describe a simple program, DTail, that Mimecast has built and released as Open-Source, which enables us to monitor log files of many servers at once without the costly overhead of a full-blown log management system.

+

At Mimecast, we run over 10 thousand server boxes. Most of them host multiple microservices and each of them produces log files. Even with the use of time series databases and monitoring systems, raw application logs are still an important source of information when it comes to analysing, debugging, and troubleshooting services.

+

Every engineer familiar with UNIX or a UNIX-like platform (e.g., Linux) is well aware of tail, a command-line program for displaying a text file content on the terminal which is also especially useful for following application or system log files with tail -f logfile.

+

Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.

+

A Mimecast Pet Project

+

DTail got its inspiration from public domain tools available already in this area but it is a blue sky from-scratch development which was first presented at Mimecast’s annual internal Pet Project competition (awarded with a Bronze prize). It has gained popularity since and is one of the most widely deployed DevOps tools at Mimecast (reaching nearly 10k server installations) and many engineers use it on a regular basis. The Open-Source version of DTail is available at:

+https://dtail.dev
+

Try it out — We would love any feedback. But first, read on…

+

Differentiating from log management systems

+

Why not just use a full-blown log management system? There are various Open-Source and commercial log management solutions available on the market you could choose from (e.g. the ELK stack). Most of them store the logs in a centralized location and are fairly complex to set up and operate. Possibly they are also pretty expensive to operate if you have to buy dedicated hardware (or pay fees to your cloud provider) and have to hire support staff for it.

+

DTail does not aim to replace any of the log management tools already available but is rather an additional tool crafted especially for ad-hoc debugging and troubleshooting purposes. DTail is cheap to operate as it does not require any dedicated hardware for log storage as it operates directly on the source of the logs. It means that there is a DTail server installed on all server boxes producing logs. This decentralized comes with the direct advantages that there is no introduced delay because the logs are not shipped to a central log storage device. The reduced complexity also makes it more robust against outages. You won’t be able to troubleshoot your distributed application very well if the log management infrastructure isn’t working either.

+DTail sample session animated gif:DTail sample session animated gif
+

As a downside, you won’t be able to access any logs with DTail when the server is down. Furthermore, a server can store logs only up to a certain capacity as disks will fill up. For the purpose of ad-hoc debugging, these are not typically issues. Usually, it’s the application you want to debug and not the server. And disk space is rarely an issue for bare metal and VM-based systems these days, with sufficient space for several weeks’ worth of log storage being available. DTail also supports reading compressed logs. The currently supported compression algorithms are gzip and zstd.

+

Combining simplicity, security and efficiency

+

DTail also has a client component that connects to multiple servers concurrently for log files (or any other text files).

+

The DTail client interacts with a DTail server on port TCP/2222 via SSH protocol and does not interact in any way with the system’s SSH server (e.g., OpenSSH Server) which might be running at port TCP/22 already. As a matter of fact, you don’t need a regular SSH server running for DTail at all. There is no support for interactive login shells at TCP/2222 either, as by design that port can only be used for text data streaming. The SSH protocol is used for the public/private key infrastructure and transport encryption only and DTail implements its own protocol on top of SSH for the features provided. There is no need to set up or buy any additional TLS certificates. The port 2222 can be easily reconfigured if you preferred to use a different one.

+

The DTail server, which is a single static binary, will not fork an external process. This means that all features are implemented in native Go code (exception: Linux ACL support is implemented in C, but it must be enabled explicitly on compile time) and therefore helping to make it robust, secure, efficient, and easy to deploy. A single client, running on a standard Laptop, can connect to thousands of servers concurrently while still maintaining a small resource footprint.

+

Recent log files are very likely still in the file system caches on the servers. Therefore, there tends to be a minimal I/O overhead involved.

+

The DTail family of commands

+

Following the UNIX philosophy, DTail includes multiple command-line commands each of them for a different purpose:

+
    +
  • dserver: The DTail server, the only binary required to be installed on the servers involved.
  • +
  • dtail: The distributed log tail client for following log files.
  • +
  • dcat: The distributed cat client for concatenating and displaying text files.
  • +
  • dgrep: The distributed grep client for searching text files for a regular expression pattern.
  • +
  • dmap: The distributed map-reduce client for aggregating stats from log files.
  • +
+DGrep sample session animated gif:DGrep sample session animated gif
+

Usage example

+

The use of these commands is almost self-explanatory for a person already used to the standard command line in Unix systems. One of the main goals is to make DTail easy to use. A tool that is too complicated to use under high-pressure scenarios (e.g., during an incident) can be quite detrimental.

+

The basic idea is to start one of the clients from the command line and provide a list of servers to connect to with –servers. You also must provide a path of remote (log) files via –files. If you want to process multiple files per server, you could either provide a comma-separated list of file paths or make use of file system globbing (or a combination of both).

+

The following example would connect to all DTail servers listed in the serverlist.txt, follow all files with the ending .log and filter for lines containing the string error. You can specify any Go compatible regular expression. In this example we add the case-insensitive flag to the regex:

+
+dtail –servers serverlist.txt –files ‘/var/log/*.log’ –regex ‘(?i:error)’
+
+

You usually want to specify a regular expression as a client argument. This will mean that responses are pre-filtered for all matching lines on the server-side and thus sending back only the relevant lines to the client. If your logs are growing very rapidly and the regex is not specific enough there might be the chance that your client is not fast enough to keep up processing all of the responses. This could be due to a network bottleneck or just as simple as a slow terminal emulator displaying the log lines on the client-side.

+

A green 100 in the client output before each log line received from the server always indicates that there were no such problems and 100% of all log lines could be displayed on your terminal (have a look at the animated Gifs in this post). If the percentage falls below 100 it means that some of the channels used by the servers to send data to the client are congested and lines were dropped. In this case, the color will change from green to red. The user then could decide to run the same query but with a more specific regex.

+

You could also provide a comma-separated list of servers as opposed to a text file. There are many more options you could use. The ones listed here are just the very basic ones. There are more instructions and usage examples on the GitHub page. Also, you can study even more of the available options via the –help switch (some real treasures might be hidden there).

+

Fitting it in

+

DTail integrates nicely into the user management of existing infrastructure. It follows normal system permissions and does not open new “holes” on the server which helps to keep security departments happy. The user would not have more or less file read permissions than he would have via a regular SSH login shell. There is a full SSH key, traditional UNIX permissions, and Linux ACL support. There is also a very low resource footprint involved. On average for tailing and searching log files less than 100MB RAM and less than a quarter of a CPU core per participating server are required. Complex map-reduce queries on big data sets will require more resources accordingly.

+

Advanced features

+

The features listed here are out of the scope of this blog post but are worthwhile to mention:

+
    +
  • Distributed map-reduce queries on stats provided in log files with dmap. dmap comes with its own SQL-like aggregation query language.
  • +
  • Stats streaming with continuous map-reduce queries. The difference to normal queries is that the stats are aggregated over a specified interval only on the newly written log lines. Thus, giving a de-facto live stat view for each interval.
  • +
  • Server-side scheduled queries on log files. The queries are configured in the DTail server configuration file and scheduled at certain time intervals. Results are written to CSV files. This is useful for generating daily stats from the log files without the need for an interactive client.
  • +
  • Server-side stats streaming with continuous map-reduce queries. This for example can be used to periodically generate stats from the logs at a configured interval, e.g., log error counts by the minute. These then can be sent to a time-series database (e.g., Graphite) and then plotted in a Grafana dashboard.
  • +
  • Support for custom extensions. E.g., for different server discovery methods (so you don’t have to rely on plain server lists) and log file formats (so that map-reduce queries can parse more stats from the logs).
  • +
+

For the future

+

There are various features we want to see in the future.

+
    +
  • A spartan mode, not printing out any extra information but the raw remote log files would be a nice feature to have. This will make it easier to post-process the data produced by the DTail client with common UNIX tools. (To some degree this is possible already, just disable the ANSI terminal color output of the client with -noColors and pipe the output to another program).
  • +
  • Tempting would be implementing the dgoawk command, a distributed version of the AWK programming language purely implemented in Go, for advanced text data stream processing capabilities. There are 3rd party libraries available implementing AWK in pure Go which could be used.
  • +
  • A more complex change would be the support of federated queries. You can connect to thousands of servers from a single client running on a laptop. But does it scale to 100k of servers? Some of the servers could be used as middleware for connecting to even more servers.
  • +
  • Another aspect is to extend the documentation. Especially the advanced features such as map-reduce query language and how to configure the server-side queries currently do require more documentation. For now, you can read the code, sample config files or just ask the author for that! But this will be certainly addressed in the future.
  • +
+

Open Source

+

Mimecast highly encourages you to have a look at DTail and submit an issue for any features you would like to see. Have you found a bug? Maybe you just have a question or comment? If you want to go a step further: We would also love to see pull requests for any features or improvements. Either way, if in doubt just contact us via the DTail GitHub page.

+https://dtail.dev
+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Methods in C gemini://buetow.org/gemfeed/2016-11-20-methods-in-c.gmi 2016-11-20T18:36:51+01:00 - You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.. .....to read on please visit my site. Paul Buetow comments@mx.buetow.org + You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.. .....to read on please visit my site. + +

Methods in C

+

You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.

+

Example

+

Lets have a look at the following sample program. Basically all you have to do is to add a function pointer such as "calculate" to the definition of struct "something_s". Later, during the struct initialization, assign a function address to that function pointer:

+
+#include <stdio.h>
+
+typedef struct {
+    double (*calculate)(const double, const double);
+    char *name;
+} something_s;
+
+double multiplication(const double a, const double b) {
+    return a * b;
+}
+
+double division(const double a, const double b) {
+    return a / b;
+}
+
+int main(void) {
+    something_s mult = (something_s) {
+        .calculate = multiplication,
+        .name = "Multiplication"
+    };
+
+    something_s div = (something_s) {
+        .calculate = division,
+        .name = "Division"
+    };
+
+    const double a = 3, b = 2;
+
+    printf("%s(%f, %f) => %f\n", mult.name, a, b, mult.calculate(a,b));
+    printf("%s(%f, %f) => %f\n", div.name, a, b, div.calculate(a,b));
+}
+
+

As you can see you can call the function (pointed by the function pointer) the same way as in C++ or Java via:

+
+printf("%s(%f, %f) => %f\n", mult.name, a, b, mult.calculate(a,b));
+printf("%s(%f, %f) => %f\n", div.name, a, b, div.calculate(a,b));
+
+

However, that's just syntactic sugar for:

+
+printf("%s(%f, %f) => %f\n", mult.name, a, b, (*mult.calculate)(a,b));
+printf("%s(%f, %f) => %f\n", div.name, a, b, (*div.calculate)(a,b));
+
+

Output:

+
+pbuetow ~/git/blog/source [38268]% gcc methods-in-c.c -o methods-in-c
+pbuetow ~/git/blog/source [38269]% ./methods-in-c
+Multiplication(3.000000, 2.000000) => 6.000000
+Division(3.000000, 2.000000) => 1.500000
+
+

Not complicated at all, but nice to know and helps to make the code easier to read!

+

The flaw

+

That's actually not really how it works in object oriented languages such as Java and C++. The method call in this example is not really a method call as "mult" and "div" in this example are not "message receivers". What I mean by that is that the functions can not access the state of the "mult" and "div" struct objects. In C you would need to do something like this instead if you wanted to access the state of "mult" from within the calculate function, you would have to pass it as an argument:

+
+mult.calculate(mult,a,b));
+
+

How to overcome this? You need to take it further...

+

Taking it further

+

If you want to take it further type "Object-Oriented Programming with ANSI-C" into your favorite internet search engine, you will find some crazy stuff. Some go as far as writing a C preprocessor in AWK, which takes some object oriented pseudo-C and transforms it to plain C so that the C compiler can compile it to machine code. This is actually similar to how the C++ language had its origins.

+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Spinning up my own authoritative DNS servers gemini://buetow.org/gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.gmi 2016-05-22T18:59:01+01:00 - Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains 'buetow.org' and 'buetow.zone'. My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now I am making use of that option.. .....to read on please visit my site. Paul Buetow comments@mx.buetow.org + Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains 'buetow.org' and 'buetow.zone'. My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now I am making use of that option.. .....to read on please visit my site. + +

Spinning up my own authoritative DNS servers

+

Background

+

Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains "buetow.org" and "buetow.zone". My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now, I am making use of that option.

+Schlund Technologies
+

All FreeBSD Jails

+

In order to set up my authoritative DNS servers I installed a FreeBSD Jail dedicated for DNS with Puppet on my root machine as follows:

+
+include freebsd
+
+freebsd::ipalias { '2a01:4f8:120:30e8::14':
+  ensure    => up,
+  proto     => 'inet6',
+  preflen   => '64',
+  interface => 're0',
+  aliasnum  => '5',
+}
+
+include jail::freebsd
+
+class { 'jail':
+  ensure              => present,
+  jails_config        => {
+    dns                     => {
+      '_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' ],
+      'host.hostname'       => "'dns.ian.buetow.org'",
+      'ip4.addr'            => '192.168.0.15',
+      'ip6.addr'            => '2a01:4f8:120:30e8::15',
+    },
+    .
+    .
+  }
+}
+
+

PF firewall

+

Please note that "dns.ian.buetow.org" is just the Jail name of the master DNS server (and "caprica.ian.buetow.org" the name of the Jail for the slave DNS server) and that I am using the DNS names "dns1.buetow.org" (master) and "dns2.buetow.org" (slave) for the actual service names (these are the DNS servers visible to the public). Please also note that the IPv4 address is an internal one. I have a PF to use NAT and PAT. The DNS ports are being forwarded (TCP and UDP) to that Jail. By default, all ports are blocked, so I am adding an exception rule for the IPv6 address as well. These are the PF rules in use:

+
+% cat /etc/pf.conf
+.
+.
+# dns.ian.buetow.org 
+rdr pass on re0 proto tcp from any to $pub_ip port {53} -> 192.168.0.15
+rdr pass on re0 proto udp from any to $pub_ip port {53} -> 192.168.0.15
+pass in on re0 inet6 proto tcp from any to 2a01:4f8:120:30e8::15 port {53} flags S/SA keep state
+pass in on re0 inet6 proto udp from any to 2a01:4f8:120:30e8::15 port {53} flags S/SA keep state
+.
+.
+
+

Puppet managed BIND zone files

+

In "manifests/dns.pp" (the Puppet manifest for the Master DNS Jail itself) I configured the BIND DNS server this way:

+
+class { 'bind_freebsd':
+  config         => "puppet:///files/bind/named.${::hostname}.conf",
+  dynamic_config => "puppet:///files/bind/dynamic.${::hostname}",
+}
+
+

The Puppet module is actually a pretty simple one. It installs the file "/usr/local/etc/named/named.conf" and it populates the "/usr/local/etc/named/dynamicdb" directory with all my zone files.

+

Once (Puppet-) applied inside of the Jail I get this:

+
+paul uranus:~/git/blog/source [4268]% ssh admin@dns1.buetow.org.buetow.org pgrep -lf named
+60748 /usr/local/sbin/named -u bind -c /usr/local/etc/namedb/named.conf
+paul uranus:~/git/blog/source [4269]% ssh admin@dns1.buetow.org.buetow.org tail -n 13 /usr/local/etc/namedb/named.conf
+zone "buetow.org" {
+    type master;
+    notify yes;
+    allow-update { key "buetoworgkey"; };
+    file "/usr/local/etc/namedb/dynamic/buetow.org";
+};
+
+zone "buetow.zone" {
+    type master;
+    notify yes;
+    allow-update { key "buetoworgkey"; };
+    file "/usr/local/etc/namedb/dynamic/buetow.zone";
+};
+paul uranus:~/git/blog/source [4277]% ssh admin@dns1.buetow.org.buetow.org cat /usr/local/etc/namedb/dynamic/buetow.org
+$TTL 3600
+@    IN   SOA   dns1.buetow.org. domains.buetow.org. (
+     25       ; Serial
+     604800   ; Refresh
+     86400    ; Retry
+     2419200  ; Expire
+     604800 ) ; Negative Cache TTL
+; Infrastructure domains
+@ IN NS dns1
+@ IN NS dns2
+* 300 IN CNAME web.ian
+buetow.org. 86400 IN A 78.46.80.70
+buetow.org. 86400 IN AAAA 2a01:4f8:120:30e8:0:0:0:11
+buetow.org. 86400 IN MX 10 mail.ian
+dns1 86400 IN A 78.46.80.70
+dns1 86400 IN AAAA 2a01:4f8:120:30e8:0:0:0:15
+dns2 86400 IN A 164.177.171.32
+dns2 86400 IN AAAA 2a03:2500:1:6:20::
+.
+.
+.
+.
+
+

That is my master DNS server. My slave DNS server runs in another Jail on another bare metal machine. Everything is set up similar to the master DNS server. However, that server is located in a different DC and in different IP subnets. The only difference is the "named.conf". It's configured to be a slave and that means that the "dynamicdb" gets populated by BIND itself while doing zone transfers from the master.

+
+paul uranus:~/git/blog/source [4279]% ssh admin@dns2.buetow.org tail -n 11 /usr/local/etc/namedb/named.conf
+zone "buetow.org" {
+    type slave;
+    masters { 78.46.80.70; };
+    file "/usr/local/etc/namedb/dynamic/buetow.org";
+};
+
+zone "buetow.zone" {
+    type slave;
+    masters { 78.46.80.70; };
+    file "/usr/local/etc/namedb/dynamic/buetow.zone";
+};
+
+

The end result

+

The end result looks like this now:

+
+% dig -t ns buetow.org
+; <<>> DiG 9.10.3-P4-RedHat-9.10.3-12.P4.fc23 <<>> -t ns buetow.org
+;; global options: +cmd
+;; Got answer:
+;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37883
+;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
+
+;; OPT PSEUDOSECTION:
+; EDNS: version: 0, flags:; udp: 512
+;; QUESTION SECTION:
+;buetow.org.			IN	NS
+
+;; ANSWER SECTION:
+buetow.org.		600	IN	NS	dns2.buetow.org.
+buetow.org.		600	IN	NS	dns1.buetow.org.
+
+;; Query time: 41 msec
+;; SERVER: 192.168.1.254#53(192.168.1.254)
+;; WHEN: Sun May 22 11:34:11 BST 2016
+;; MSG SIZE  rcvd: 77
+
+% dig -t any buetow.org @dns1.buetow.org
+; <<>> DiG 9.10.3-P4-RedHat-9.10.3-12.P4.fc23 <<>> -t any buetow.org @dns1.buetow.org
+;; global options: +cmd
+;; Got answer:
+;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49876
+;; flags: qr aa rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 7
+
+;; OPT PSEUDOSECTION:
+; EDNS: version: 0, flags:; udp: 4096
+;; QUESTION SECTION:
+;buetow.org.			IN	ANY
+
+;; ANSWER SECTION:
+buetow.org.		86400	IN	A	78.46.80.70
+buetow.org.		86400	IN	AAAA	2a01:4f8:120:30e8::11
+buetow.org.		86400	IN	MX	10 mail.ian.buetow.org.
+buetow.org.		3600	IN	SOA	dns1.buetow.org. domains.buetow.org. 25 604800 86400 2419200 604800
+buetow.org.		3600	IN	NS	dns2.buetow.org.
+buetow.org.		3600	IN	NS	dns1.buetow.org.
+
+;; ADDITIONAL SECTION:
+mail.ian.buetow.org.	86400	IN	A	78.46.80.70
+dns1.buetow.org.	86400	IN	A	78.46.80.70
+dns2.buetow.org.	86400	IN	A	164.177.171.32
+mail.ian.buetow.org.	86400	IN	AAAA	2a01:4f8:120:30e8::12
+dns1.buetow.org.	86400	IN	AAAA	2a01:4f8:120:30e8::15
+dns2.buetow.org.	86400	IN	AAAA	2a03:2500:1:6:20::
+
+;; Query time: 42 msec
+;; SERVER: 78.46.80.70#53(78.46.80.70)
+;; WHEN: Sun May 22 11:34:41 BST 2016
+;; MSG SIZE  rcvd: 322
+
+

Monitoring

+

For monitoring I am using Icinga2 (I am operating two Icinga2 instances in two different DCs). I may have to post another blog article about Icinga2 but to get the idea these were the snippets added to my Icinga2 configuration:

+
+apply Service "dig" {
+    import "generic-service"
+
+    check_command = "dig"
+    vars.dig_lookup = "buetow.org"
+    vars.timeout = 30
+
+    assign where host.name == "dns.ian.buetow.org" || host.name == "caprica.ian.buetow.org"
+}
+
+apply Service "dig6" {
+    import "generic-service"
+
+    check_command = "dig"
+    vars.dig_lookup = "buetow.org"
+    vars.timeout = 30
+    vars.check_ipv6 = true
+
+    assign where host.name == "dns.ian.buetow.org" || host.name == "caprica.ian.buetow.org"
+}
+
+

DNS update workflow

+

Whenever I have to change a DNS entry all have to do is:

+
    +
  • Git clone or update the Puppet repository
  • +
  • Update/commit and push the zone file (e.g. "buetow.org")
  • +
  • Wait for Puppet. Puppet will deploy that updated zone file. And it will reload the BIND server.
  • +
  • The BIND server will notify all slave DNS servers (at the moment only one). And it will transfer the new version of the zone.
  • +
+

That's much more comfortable now than manually clicking at some web UIs at Schlund Technologies.

+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Offsite backup with ZFS (Part 2) gemini://buetow.org/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.gmi 2016-04-16T22:43:42+01:00 - I enhanced the procedure a bit. From now on I am having two external 2TB USB hard drives. Both are setup exactly the same way. To decrease the probability that they will not fail at about the same time both drives are of different brands. One drive is kept at the secret location. The other one is kept at home right next to my HP MicroServer. ...to read on visit my site. Paul Buetow comments@mx.buetow.org + I enhanced the procedure a bit. From now on I am having two external 2TB USB hard drives. Both are setup exactly the same way. To decrease the probability that they will not fail at about the same time both drives are of different brands. One drive is kept at the secret location. The other one is kept at home right next to my HP MicroServer. ...to read on visit my site. + +

Offsite backup with ZFS (Part 2)

+
+ ________________
+|# :           : #|
+|  : ZFS/GELI  :  |________________ 
+|  :   Offsite : |# :           : #|
+|  :  Backup 1 : |  : ZFS/GELI  :  |
+|  :___________: |  :   Offsite :  |
+|     _________  |  :  Backup 2 :  |
+|    | __      | |  :___________:  |
+|    ||  |     | |     _________   |
+\____||__|_____|_|    | __      |  |
+                 |    ||  |     |  |
+                 \____||__|_____|__|
+
+Read the first part before reading any furter here...
+

I enhanced the procedure a bit. From now on I am having two external 2TB USB hard drives. Both are setup exactly the same way. To decrease the probability that they will not fail at about the same time both drives are of different brands. One drive is kept at the secret location. The other one is kept at home right next to my HP MicroServer.

+

Whenever I am updating offsite backup, I am doing it to the drive which is kept locally. Afterwards I bring it to the secret location and swap the drives and bring the other one back home. This ensures that I will always have an offiste backup available at a different location than my home - even while updating one copy of it.

+

Furthermore, I added scrubbing (*zpool scrub...*) to the script. It ensures that the file system is consistent and that there are no bad blocks on the disk and the file system. To increase the reliability I also run a *zfs set copies=2 zroot*. That setting is also synchronized to the offsite ZFS pool. ZFS stores every data block to disk twice now. Yes, it consumes twice as much disk space but it makes it better fault tolerant against hardware errors (e.g. only individual disk sectors going bad).

+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Offsite backup with ZFS gemini://buetow.org/gemfeed/2016-04-03-offsite-backup-with-zfs.gmi 2016-04-03T22:43:42+01:00 - 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, ....). ...to read on visit my site. Paul Buetow comments@mx.buetow.org + 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, ....). ...to read on visit my site. + +

Offsite backup with ZFS

+
+ ________________
+|# :           : #|
+|  : ZFS/GELI  :  |
+|  :   Offsite :  |
+|  :  Backup   :  |
+|  :___________:  |
+|     _________   |
+|    | __      |  |
+|    ||  |     |  |
+\____||__|_____|__|
+
+

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!

+
The Fype Programming Language gemini://buetow.org/gemfeed/2010-05-09-the-fype-programming-language.gmi 2010-05-09T12:48:29+01:00 - 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.. .....to read on please visit my site. Paul Buetow comments@mx.buetow.org + 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.. .....to read on please visit my site. + +

The Fype Programming Language

+

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) <any> - <any>
+(any) <any> * <any>
+(any) <any> / <any>
+(integer) <any> == <any>
+(integer) <any> != <any>
+(integer) <any> <= <any>
+(integer) <any> gt <any>
+(integer) <any> <> <any>
+(integer) <any> gt <any>
+(integer) not <any>
+
+

Bitwise expressions

+
+(integer) <any> :< <any>
+(integer) <any> :> <any>
+(integer) <any> and <any>
+(integer) <any> or <any>
+(integer) <any> xor <any>
+
+

Numeric expressions

+
+(number) neg <number>
+
+

... returns the negative value of "number":

+
+(integer) no <integer>
+
+

... returns 1 if the argument is 0, otherwise it will return 0! If no argument is given, then 0 is returned!

+
+(integer) yes <integer>
+
+

... 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 <expression> { <statements> }
+
+

... runs the statements if the expression evaluates to a true value.

+
+ifnot <expression> { <statements> }
+
+

... runs the statements if the expression evaluates to a false value.

+
+while <expression> { <statements> }
+
+

... runs the statements as long as the expression evaluates to a true value.

+
+until <expression> { <statements> }
+
+

... 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 <identifier>
+
+

... returns 1 if "identifier" has been defined. Returns 0 otherwise.

+
+(integer) undef <identifier>
+
+

... 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 <integer>
+
+

... 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 <any>
+
+

... prints out the argument

+
+(any) say <any>
+
+

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
+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Perl Poetry gemini://buetow.org/gemfeed/2008-06-26-perl-poetry.gmi 2008-06-26T21:43:51+01:00 - 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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site. Paul Buetow comments@mx.buetow.org + 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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site. + +

Perl Poetry

+
+ '\|/'                                  *
+-- * -----
+  /|\      ____
+ ' | '    {_   o^>       *
+   :        -_  /)
+   :         (   (        .-''`'.
+   .          \   \      /       \
+   .           \    \   /         \
+                \    `-'           `'.
+                 \    . '        /    `.
+                  \  ( \  )     (     .')
+   ,,   t          '. |  /       |     (
+  '|``_/^\___        '|  |`'-..-'|   ( ()
+_~~|~/_|_|__/|~~~~~~~ |  / ~~~~~ |   | ~~~~~~~~
+ -_  |L[|]L|/         | |\ MJP   )   )
+                      ( |(       /  /|
+   ~~ ~  ~ ~~~~       | /\\     / /| |
+                      ||  \\  _/ / | |
+             ~ ~ ~~~ _|| (_/ (___)_| |Nov291999
+                    (__)         (____)
+
+

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
+

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 <<EMail
+ to the parents to buy a new christmas tree!!!!111
+ and send the
+EMail
+;wait and redo deliver until defined local $tree;
+
+redo Santa, pipe $gifts, to_childs;
+redo Santa and do return if last one, is, delivered ;}
+
+END {} our $mission and do sleep until next Christmas ;}
+
+__END__
+
+This is perl, v5.8.8 built for i386-freebsd-64int
+
+

shopping.pl

+
+#!/usr/bin/perl
+
+# (C) 2007 by Paul C. Buetow (http://paul.buetow.org) 
+
+BEGIN{} goto mall for $shopping; 
+
+m/y/; mall: seek$s, cool products(), { to => $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
+

E-Mail me your thoughts at comments@mx.buetow.org!

+
diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml index 905ebb2e..23974c1b 100644 --- a/content/html/gemfeed/atom.xml +++ b/content/html/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-05T13:00:59+01:00 + 2021-05-06T09:41:34+01:00 buetow.org feed Having fun with computers! @@ -11,87 +11,1076 @@ https://buetow.org/gemfeed/2021-04-24-welcome-to-the-geminispace.html 2021-04-24T19:28:41+01:00 - Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is: ... to read on visit my site. Paul Buetow comments@mx.buetow.org + Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is: ... to read on visit my site. + +

Welcome to the Geminispace

+

Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is:

+https://buetow.org
+

If you however still use HTTP then you are just surfing the fallback HTML version of this capsule. In that case I suggest reading on what this is all about :-).

+
+
+    /\
+   /  \
+  |    |
+  |NASA|
+  |    |
+  |    |
+  |    |
+ '      `
+ |Gemini|
+ |      |
+ |______|
+  '-`'-`   .
+  / . \'\ . .'
+ ''( .'\.' ' .;'
+'.;.;' ;'.;' ..;;' AsH
+
+
+

Motivation

+

My urge to revamp my personal website

+

For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.

+

My still great Laptop running hot

+

Earlier this year (2021) I noticed that my 6 year old but still great Laptop started to become hot and slowed down while surfing the web. Also, the Laptop's fan became quite noisy. This is all due to the additional bloat such as JavaScript, excessive use of CSS, tracking cookies+pixels, ads and so on there was on the website.

+

All what I wanted was to read an interesting article but after a big advertising pop-up banner appeared and made everything worse I gave up and closed the browser tab.

+

Discovering the Gemini internet protocol

+

Around the same time I discovered a relatively new more lightweight protocol named Gemini which does not support all these CPU intensive features like HTML, JavaScript and CSS do. Also, tracking and ads is not supported by the Gemini protocol.

+

The "downside" is that due to the limited capabilities of the Gemini protocol all sites look very old and spartan. But that is not really a downside, that is in fact a design choice people made. It is up to the client software how your capsule looks. For example, you could use a graphical client with nice font renderings and colors to improve the appearance. Or you could just use a very minimalistic command line black-and-white Gemini client. It's your (the user's) choice.

+Screenshot Amfora Gemini terminal client surfing this site:Screenshot Amfora Gemini terminal client surfing this site
+

Why is there a need for a new protocol? As the modern web is a superset of Gemini, can't we just use simple HTML 1.0? That's a good and valid question. It is not a technical problem but a human problem. We tend to abuse the features once they are available. You can be sure that things stay simple and efficient as long as you are using the Gemini protocol. On the other hand you can't force every website in the modern web to only create plain and simple looking HTML pages.

+

My own Gemini capsule

+

As it is very easy to set up and maintain your own Gemini capsule (Gemini server + content composed via the Gemtext markup language) I decided to create my own. What I really like about Gemini is that I can just use my favorite text editor and get typing. I don't need to worry about the style and design of the presence and I also don't have to test anything in ten different web browsers. I can only focus on the content! As a matter of fact, I am using the Vim editor + it's spellchecker + auto word completion functionality to write this.

+

Advantages summarised

+
    +
  • Supports an alternative to the modern bloated web
  • +
  • Easy to operate and easy to write content
  • +
  • No need to worry about various web browser compatibilities
  • +
  • It's the client's responsibility how the content is designed+presented
  • +
  • Lightweight (although not as lightweight as the Gopher protocol)
  • +
  • Supports privacy (no cookies, no request header fingerprinting, TLS encryption)
  • +
  • Fun to play with (it's a bit geeky yes, but a lot of fun!)
  • +
+

Dive into deep Gemini space

+

Check out one of the following links for more information about Gemini. For example, you will find a FAQ which explains why the protocol is named "Gemini". Many Gemini capsules are dual hosted via Gemini and HTTP(S), so that people new to Gemini can sneak peek the content with a normal web browser. As a matter of fact, some people go as far as tri-hosting all their content via HTTP(S), Gemini and Gopher.

+https://gemini.circumlunar.space
+https://gemini.circumlunar.space
+

E-Mail me your thoughts at comments@mx.buetow.org!

+
DTail - The distributed log tail program https://buetow.org/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html 2021-04-22T19:28:41+01:00 - This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too. ...to read on visit my site. Paul Buetow comments@mx.buetow.org + This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too. ...to read on visit my site. + +

DTail - The distributed log tail program

+DTail logo image:DTail logo image
+

This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too.

+Original Mimecast Engineering Blog post at Medium
+

Running a large cloud-based service requires monitoring the state of huge numbers of machines, a task for which many standard UNIX tools were not really designed. In this post, I will describe a simple program, DTail, that Mimecast has built and released as Open-Source, which enables us to monitor log files of many servers at once without the costly overhead of a full-blown log management system.

+

At Mimecast, we run over 10 thousand server boxes. Most of them host multiple microservices and each of them produces log files. Even with the use of time series databases and monitoring systems, raw application logs are still an important source of information when it comes to analysing, debugging, and troubleshooting services.

+

Every engineer familiar with UNIX or a UNIX-like platform (e.g., Linux) is well aware of tail, a command-line program for displaying a text file content on the terminal which is also especially useful for following application or system log files with tail -f logfile.

+

Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.

+

A Mimecast Pet Project

+

DTail got its inspiration from public domain tools available already in this area but it is a blue sky from-scratch development which was first presented at Mimecast’s annual internal Pet Project competition (awarded with a Bronze prize). It has gained popularity since and is one of the most widely deployed DevOps tools at Mimecast (reaching nearly 10k server installations) and many engineers use it on a regular basis. The Open-Source version of DTail is available at:

+https://dtail.dev
+

Try it out — We would love any feedback. But first, read on…

+

Differentiating from log management systems

+

Why not just use a full-blown log management system? There are various Open-Source and commercial log management solutions available on the market you could choose from (e.g. the ELK stack). Most of them store the logs in a centralized location and are fairly complex to set up and operate. Possibly they are also pretty expensive to operate if you have to buy dedicated hardware (or pay fees to your cloud provider) and have to hire support staff for it.

+

DTail does not aim to replace any of the log management tools already available but is rather an additional tool crafted especially for ad-hoc debugging and troubleshooting purposes. DTail is cheap to operate as it does not require any dedicated hardware for log storage as it operates directly on the source of the logs. It means that there is a DTail server installed on all server boxes producing logs. This decentralized comes with the direct advantages that there is no introduced delay because the logs are not shipped to a central log storage device. The reduced complexity also makes it more robust against outages. You won’t be able to troubleshoot your distributed application very well if the log management infrastructure isn’t working either.

+DTail sample session animated gif:DTail sample session animated gif
+

As a downside, you won’t be able to access any logs with DTail when the server is down. Furthermore, a server can store logs only up to a certain capacity as disks will fill up. For the purpose of ad-hoc debugging, these are not typically issues. Usually, it’s the application you want to debug and not the server. And disk space is rarely an issue for bare metal and VM-based systems these days, with sufficient space for several weeks’ worth of log storage being available. DTail also supports reading compressed logs. The currently supported compression algorithms are gzip and zstd.

+

Combining simplicity, security and efficiency

+

DTail also has a client component that connects to multiple servers concurrently for log files (or any other text files).

+

The DTail client interacts with a DTail server on port TCP/2222 via SSH protocol and does not interact in any way with the system’s SSH server (e.g., OpenSSH Server) which might be running at port TCP/22 already. As a matter of fact, you don’t need a regular SSH server running for DTail at all. There is no support for interactive login shells at TCP/2222 either, as by design that port can only be used for text data streaming. The SSH protocol is used for the public/private key infrastructure and transport encryption only and DTail implements its own protocol on top of SSH for the features provided. There is no need to set up or buy any additional TLS certificates. The port 2222 can be easily reconfigured if you preferred to use a different one.

+

The DTail server, which is a single static binary, will not fork an external process. This means that all features are implemented in native Go code (exception: Linux ACL support is implemented in C, but it must be enabled explicitly on compile time) and therefore helping to make it robust, secure, efficient, and easy to deploy. A single client, running on a standard Laptop, can connect to thousands of servers concurrently while still maintaining a small resource footprint.

+

Recent log files are very likely still in the file system caches on the servers. Therefore, there tends to be a minimal I/O overhead involved.

+

The DTail family of commands

+

Following the UNIX philosophy, DTail includes multiple command-line commands each of them for a different purpose:

+
    +
  • dserver: The DTail server, the only binary required to be installed on the servers involved.
  • +
  • dtail: The distributed log tail client for following log files.
  • +
  • dcat: The distributed cat client for concatenating and displaying text files.
  • +
  • dgrep: The distributed grep client for searching text files for a regular expression pattern.
  • +
  • dmap: The distributed map-reduce client for aggregating stats from log files.
  • +
+DGrep sample session animated gif:DGrep sample session animated gif
+

Usage example

+

The use of these commands is almost self-explanatory for a person already used to the standard command line in Unix systems. One of the main goals is to make DTail easy to use. A tool that is too complicated to use under high-pressure scenarios (e.g., during an incident) can be quite detrimental.

+

The basic idea is to start one of the clients from the command line and provide a list of servers to connect to with –servers. You also must provide a path of remote (log) files via –files. If you want to process multiple files per server, you could either provide a comma-separated list of file paths or make use of file system globbing (or a combination of both).

+

The following example would connect to all DTail servers listed in the serverlist.txt, follow all files with the ending .log and filter for lines containing the string error. You can specify any Go compatible regular expression. In this example we add the case-insensitive flag to the regex:

+
+dtail –servers serverlist.txt –files ‘/var/log/*.log’ –regex ‘(?i:error)’
+
+

You usually want to specify a regular expression as a client argument. This will mean that responses are pre-filtered for all matching lines on the server-side and thus sending back only the relevant lines to the client. If your logs are growing very rapidly and the regex is not specific enough there might be the chance that your client is not fast enough to keep up processing all of the responses. This could be due to a network bottleneck or just as simple as a slow terminal emulator displaying the log lines on the client-side.

+

A green 100 in the client output before each log line received from the server always indicates that there were no such problems and 100% of all log lines could be displayed on your terminal (have a look at the animated Gifs in this post). If the percentage falls below 100 it means that some of the channels used by the servers to send data to the client are congested and lines were dropped. In this case, the color will change from green to red. The user then could decide to run the same query but with a more specific regex.

+

You could also provide a comma-separated list of servers as opposed to a text file. There are many more options you could use. The ones listed here are just the very basic ones. There are more instructions and usage examples on the GitHub page. Also, you can study even more of the available options via the –help switch (some real treasures might be hidden there).

+

Fitting it in

+

DTail integrates nicely into the user management of existing infrastructure. It follows normal system permissions and does not open new “holes” on the server which helps to keep security departments happy. The user would not have more or less file read permissions than he would have via a regular SSH login shell. There is a full SSH key, traditional UNIX permissions, and Linux ACL support. There is also a very low resource footprint involved. On average for tailing and searching log files less than 100MB RAM and less than a quarter of a CPU core per participating server are required. Complex map-reduce queries on big data sets will require more resources accordingly.

+

Advanced features

+

The features listed here are out of the scope of this blog post but are worthwhile to mention:

+
    +
  • Distributed map-reduce queries on stats provided in log files with dmap. dmap comes with its own SQL-like aggregation query language.
  • +
  • Stats streaming with continuous map-reduce queries. The difference to normal queries is that the stats are aggregated over a specified interval only on the newly written log lines. Thus, giving a de-facto live stat view for each interval.
  • +
  • Server-side scheduled queries on log files. The queries are configured in the DTail server configuration file and scheduled at certain time intervals. Results are written to CSV files. This is useful for generating daily stats from the log files without the need for an interactive client.
  • +
  • Server-side stats streaming with continuous map-reduce queries. This for example can be used to periodically generate stats from the logs at a configured interval, e.g., log error counts by the minute. These then can be sent to a time-series database (e.g., Graphite) and then plotted in a Grafana dashboard.
  • +
  • Support for custom extensions. E.g., for different server discovery methods (so you don’t have to rely on plain server lists) and log file formats (so that map-reduce queries can parse more stats from the logs).
  • +
+

For the future

+

There are various features we want to see in the future.

+
    +
  • A spartan mode, not printing out any extra information but the raw remote log files would be a nice feature to have. This will make it easier to post-process the data produced by the DTail client with common UNIX tools. (To some degree this is possible already, just disable the ANSI terminal color output of the client with -noColors and pipe the output to another program).
  • +
  • Tempting would be implementing the dgoawk command, a distributed version of the AWK programming language purely implemented in Go, for advanced text data stream processing capabilities. There are 3rd party libraries available implementing AWK in pure Go which could be used.
  • +
  • A more complex change would be the support of federated queries. You can connect to thousands of servers from a single client running on a laptop. But does it scale to 100k of servers? Some of the servers could be used as middleware for connecting to even more servers.
  • +
  • Another aspect is to extend the documentation. Especially the advanced features such as map-reduce query language and how to configure the server-side queries currently do require more documentation. For now, you can read the code, sample config files or just ask the author for that! But this will be certainly addressed in the future.
  • +
+

Open Source

+

Mimecast highly encourages you to have a look at DTail and submit an issue for any features you would like to see. Have you found a bug? Maybe you just have a question or comment? If you want to go a step further: We would also love to see pull requests for any features or improvements. Either way, if in doubt just contact us via the DTail GitHub page.

+https://dtail.dev
+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Methods in C https://buetow.org/gemfeed/2016-11-20-methods-in-c.html 2016-11-20T18:36:51+01:00 - You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.. .....to read on please visit my site. Paul Buetow comments@mx.buetow.org + You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.. .....to read on please visit my site. + +

Methods in C

+

You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.

+

Example

+

Lets have a look at the following sample program. Basically all you have to do is to add a function pointer such as "calculate" to the definition of struct "something_s". Later, during the struct initialization, assign a function address to that function pointer:

+
+#include <stdio.h>
+
+typedef struct {
+    double (*calculate)(const double, const double);
+    char *name;
+} something_s;
+
+double multiplication(const double a, const double b) {
+    return a * b;
+}
+
+double division(const double a, const double b) {
+    return a / b;
+}
+
+int main(void) {
+    something_s mult = (something_s) {
+        .calculate = multiplication,
+        .name = "Multiplication"
+    };
+
+    something_s div = (something_s) {
+        .calculate = division,
+        .name = "Division"
+    };
+
+    const double a = 3, b = 2;
+
+    printf("%s(%f, %f) => %f\n", mult.name, a, b, mult.calculate(a,b));
+    printf("%s(%f, %f) => %f\n", div.name, a, b, div.calculate(a,b));
+}
+
+

As you can see you can call the function (pointed by the function pointer) the same way as in C++ or Java via:

+
+printf("%s(%f, %f) => %f\n", mult.name, a, b, mult.calculate(a,b));
+printf("%s(%f, %f) => %f\n", div.name, a, b, div.calculate(a,b));
+
+

However, that's just syntactic sugar for:

+
+printf("%s(%f, %f) => %f\n", mult.name, a, b, (*mult.calculate)(a,b));
+printf("%s(%f, %f) => %f\n", div.name, a, b, (*div.calculate)(a,b));
+
+

Output:

+
+pbuetow ~/git/blog/source [38268]% gcc methods-in-c.c -o methods-in-c
+pbuetow ~/git/blog/source [38269]% ./methods-in-c
+Multiplication(3.000000, 2.000000) => 6.000000
+Division(3.000000, 2.000000) => 1.500000
+
+

Not complicated at all, but nice to know and helps to make the code easier to read!

+

The flaw

+

That's actually not really how it works in object oriented languages such as Java and C++. The method call in this example is not really a method call as "mult" and "div" in this example are not "message receivers". What I mean by that is that the functions can not access the state of the "mult" and "div" struct objects. In C you would need to do something like this instead if you wanted to access the state of "mult" from within the calculate function, you would have to pass it as an argument:

+
+mult.calculate(mult,a,b));
+
+

How to overcome this? You need to take it further...

+

Taking it further

+

If you want to take it further type "Object-Oriented Programming with ANSI-C" into your favorite internet search engine, you will find some crazy stuff. Some go as far as writing a C preprocessor in AWK, which takes some object oriented pseudo-C and transforms it to plain C so that the C compiler can compile it to machine code. This is actually similar to how the C++ language had its origins.

+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Spinning up my own authoritative DNS servers https://buetow.org/gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.html 2016-05-22T18:59:01+01:00 - Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains 'buetow.org' and 'buetow.zone'. My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now I am making use of that option.. .....to read on please visit my site. Paul Buetow comments@mx.buetow.org + Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains 'buetow.org' and 'buetow.zone'. My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now I am making use of that option.. .....to read on please visit my site. + +

Spinning up my own authoritative DNS servers

+

Background

+

Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains "buetow.org" and "buetow.zone". My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now, I am making use of that option.

+Schlund Technologies
+

All FreeBSD Jails

+

In order to set up my authoritative DNS servers I installed a FreeBSD Jail dedicated for DNS with Puppet on my root machine as follows:

+
+include freebsd
+
+freebsd::ipalias { '2a01:4f8:120:30e8::14':
+  ensure    => up,
+  proto     => 'inet6',
+  preflen   => '64',
+  interface => 're0',
+  aliasnum  => '5',
+}
+
+include jail::freebsd
+
+class { 'jail':
+  ensure              => present,
+  jails_config        => {
+    dns                     => {
+      '_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' ],
+      'host.hostname'       => "'dns.ian.buetow.org'",
+      'ip4.addr'            => '192.168.0.15',
+      'ip6.addr'            => '2a01:4f8:120:30e8::15',
+    },
+    .
+    .
+  }
+}
+
+

PF firewall

+

Please note that "dns.ian.buetow.org" is just the Jail name of the master DNS server (and "caprica.ian.buetow.org" the name of the Jail for the slave DNS server) and that I am using the DNS names "dns1.buetow.org" (master) and "dns2.buetow.org" (slave) for the actual service names (these are the DNS servers visible to the public). Please also note that the IPv4 address is an internal one. I have a PF to use NAT and PAT. The DNS ports are being forwarded (TCP and UDP) to that Jail. By default, all ports are blocked, so I am adding an exception rule for the IPv6 address as well. These are the PF rules in use:

+
+% cat /etc/pf.conf
+.
+.
+# dns.ian.buetow.org 
+rdr pass on re0 proto tcp from any to $pub_ip port {53} -> 192.168.0.15
+rdr pass on re0 proto udp from any to $pub_ip port {53} -> 192.168.0.15
+pass in on re0 inet6 proto tcp from any to 2a01:4f8:120:30e8::15 port {53} flags S/SA keep state
+pass in on re0 inet6 proto udp from any to 2a01:4f8:120:30e8::15 port {53} flags S/SA keep state
+.
+.
+
+

Puppet managed BIND zone files

+

In "manifests/dns.pp" (the Puppet manifest for the Master DNS Jail itself) I configured the BIND DNS server this way:

+
+class { 'bind_freebsd':
+  config         => "puppet:///files/bind/named.${::hostname}.conf",
+  dynamic_config => "puppet:///files/bind/dynamic.${::hostname}",
+}
+
+

The Puppet module is actually a pretty simple one. It installs the file "/usr/local/etc/named/named.conf" and it populates the "/usr/local/etc/named/dynamicdb" directory with all my zone files.

+

Once (Puppet-) applied inside of the Jail I get this:

+
+paul uranus:~/git/blog/source [4268]% ssh admin@dns1.buetow.org.buetow.org pgrep -lf named
+60748 /usr/local/sbin/named -u bind -c /usr/local/etc/namedb/named.conf
+paul uranus:~/git/blog/source [4269]% ssh admin@dns1.buetow.org.buetow.org tail -n 13 /usr/local/etc/namedb/named.conf
+zone "buetow.org" {
+    type master;
+    notify yes;
+    allow-update { key "buetoworgkey"; };
+    file "/usr/local/etc/namedb/dynamic/buetow.org";
+};
+
+zone "buetow.zone" {
+    type master;
+    notify yes;
+    allow-update { key "buetoworgkey"; };
+    file "/usr/local/etc/namedb/dynamic/buetow.zone";
+};
+paul uranus:~/git/blog/source [4277]% ssh admin@dns1.buetow.org.buetow.org cat /usr/local/etc/namedb/dynamic/buetow.org
+$TTL 3600
+@    IN   SOA   dns1.buetow.org. domains.buetow.org. (
+     25       ; Serial
+     604800   ; Refresh
+     86400    ; Retry
+     2419200  ; Expire
+     604800 ) ; Negative Cache TTL
+; Infrastructure domains
+@ IN NS dns1
+@ IN NS dns2
+* 300 IN CNAME web.ian
+buetow.org. 86400 IN A 78.46.80.70
+buetow.org. 86400 IN AAAA 2a01:4f8:120:30e8:0:0:0:11
+buetow.org. 86400 IN MX 10 mail.ian
+dns1 86400 IN A 78.46.80.70
+dns1 86400 IN AAAA 2a01:4f8:120:30e8:0:0:0:15
+dns2 86400 IN A 164.177.171.32
+dns2 86400 IN AAAA 2a03:2500:1:6:20::
+.
+.
+.
+.
+
+

That is my master DNS server. My slave DNS server runs in another Jail on another bare metal machine. Everything is set up similar to the master DNS server. However, that server is located in a different DC and in different IP subnets. The only difference is the "named.conf". It's configured to be a slave and that means that the "dynamicdb" gets populated by BIND itself while doing zone transfers from the master.

+
+paul uranus:~/git/blog/source [4279]% ssh admin@dns2.buetow.org tail -n 11 /usr/local/etc/namedb/named.conf
+zone "buetow.org" {
+    type slave;
+    masters { 78.46.80.70; };
+    file "/usr/local/etc/namedb/dynamic/buetow.org";
+};
+
+zone "buetow.zone" {
+    type slave;
+    masters { 78.46.80.70; };
+    file "/usr/local/etc/namedb/dynamic/buetow.zone";
+};
+
+

The end result

+

The end result looks like this now:

+
+% dig -t ns buetow.org
+; <<>> DiG 9.10.3-P4-RedHat-9.10.3-12.P4.fc23 <<>> -t ns buetow.org
+;; global options: +cmd
+;; Got answer:
+;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37883
+;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
+
+;; OPT PSEUDOSECTION:
+; EDNS: version: 0, flags:; udp: 512
+;; QUESTION SECTION:
+;buetow.org.			IN	NS
+
+;; ANSWER SECTION:
+buetow.org.		600	IN	NS	dns2.buetow.org.
+buetow.org.		600	IN	NS	dns1.buetow.org.
+
+;; Query time: 41 msec
+;; SERVER: 192.168.1.254#53(192.168.1.254)
+;; WHEN: Sun May 22 11:34:11 BST 2016
+;; MSG SIZE  rcvd: 77
+
+% dig -t any buetow.org @dns1.buetow.org
+; <<>> DiG 9.10.3-P4-RedHat-9.10.3-12.P4.fc23 <<>> -t any buetow.org @dns1.buetow.org
+;; global options: +cmd
+;; Got answer:
+;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49876
+;; flags: qr aa rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 7
+
+;; OPT PSEUDOSECTION:
+; EDNS: version: 0, flags:; udp: 4096
+;; QUESTION SECTION:
+;buetow.org.			IN	ANY
+
+;; ANSWER SECTION:
+buetow.org.		86400	IN	A	78.46.80.70
+buetow.org.		86400	IN	AAAA	2a01:4f8:120:30e8::11
+buetow.org.		86400	IN	MX	10 mail.ian.buetow.org.
+buetow.org.		3600	IN	SOA	dns1.buetow.org. domains.buetow.org. 25 604800 86400 2419200 604800
+buetow.org.		3600	IN	NS	dns2.buetow.org.
+buetow.org.		3600	IN	NS	dns1.buetow.org.
+
+;; ADDITIONAL SECTION:
+mail.ian.buetow.org.	86400	IN	A	78.46.80.70
+dns1.buetow.org.	86400	IN	A	78.46.80.70
+dns2.buetow.org.	86400	IN	A	164.177.171.32
+mail.ian.buetow.org.	86400	IN	AAAA	2a01:4f8:120:30e8::12
+dns1.buetow.org.	86400	IN	AAAA	2a01:4f8:120:30e8::15
+dns2.buetow.org.	86400	IN	AAAA	2a03:2500:1:6:20::
+
+;; Query time: 42 msec
+;; SERVER: 78.46.80.70#53(78.46.80.70)
+;; WHEN: Sun May 22 11:34:41 BST 2016
+;; MSG SIZE  rcvd: 322
+
+

Monitoring

+

For monitoring I am using Icinga2 (I am operating two Icinga2 instances in two different DCs). I may have to post another blog article about Icinga2 but to get the idea these were the snippets added to my Icinga2 configuration:

+
+apply Service "dig" {
+    import "generic-service"
+
+    check_command = "dig"
+    vars.dig_lookup = "buetow.org"
+    vars.timeout = 30
+
+    assign where host.name == "dns.ian.buetow.org" || host.name == "caprica.ian.buetow.org"
+}
+
+apply Service "dig6" {
+    import "generic-service"
+
+    check_command = "dig"
+    vars.dig_lookup = "buetow.org"
+    vars.timeout = 30
+    vars.check_ipv6 = true
+
+    assign where host.name == "dns.ian.buetow.org" || host.name == "caprica.ian.buetow.org"
+}
+
+

DNS update workflow

+

Whenever I have to change a DNS entry all have to do is:

+
    +
  • Git clone or update the Puppet repository
  • +
  • Update/commit and push the zone file (e.g. "buetow.org")
  • +
  • Wait for Puppet. Puppet will deploy that updated zone file. And it will reload the BIND server.
  • +
  • The BIND server will notify all slave DNS servers (at the moment only one). And it will transfer the new version of the zone.
  • +
+

That's much more comfortable now than manually clicking at some web UIs at Schlund Technologies.

+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Offsite backup with ZFS (Part 2) https://buetow.org/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.html 2016-04-16T22:43:42+01:00 - I enhanced the procedure a bit. From now on I am having two external 2TB USB hard drives. Both are setup exactly the same way. To decrease the probability that they will not fail at about the same time both drives are of different brands. One drive is kept at the secret location. The other one is kept at home right next to my HP MicroServer. ...to read on visit my site. Paul Buetow comments@mx.buetow.org + I enhanced the procedure a bit. From now on I am having two external 2TB USB hard drives. Both are setup exactly the same way. To decrease the probability that they will not fail at about the same time both drives are of different brands. One drive is kept at the secret location. The other one is kept at home right next to my HP MicroServer. ...to read on visit my site. + +

Offsite backup with ZFS (Part 2)

+
+ ________________
+|# :           : #|
+|  : ZFS/GELI  :  |________________ 
+|  :   Offsite : |# :           : #|
+|  :  Backup 1 : |  : ZFS/GELI  :  |
+|  :___________: |  :   Offsite :  |
+|     _________  |  :  Backup 2 :  |
+|    | __      | |  :___________:  |
+|    ||  |     | |     _________   |
+\____||__|_____|_|    | __      |  |
+                 |    ||  |     |  |
+                 \____||__|_____|__|
+
+Read the first part before reading any furter here...
+

I enhanced the procedure a bit. From now on I am having two external 2TB USB hard drives. Both are setup exactly the same way. To decrease the probability that they will not fail at about the same time both drives are of different brands. One drive is kept at the secret location. The other one is kept at home right next to my HP MicroServer.

+

Whenever I am updating offsite backup, I am doing it to the drive which is kept locally. Afterwards I bring it to the secret location and swap the drives and bring the other one back home. This ensures that I will always have an offiste backup available at a different location than my home - even while updating one copy of it.

+

Furthermore, I added scrubbing (*zpool scrub...*) to the script. It ensures that the file system is consistent and that there are no bad blocks on the disk and the file system. To increase the reliability I also run a *zfs set copies=2 zroot*. That setting is also synchronized to the offsite ZFS pool. ZFS stores every data block to disk twice now. Yes, it consumes twice as much disk space but it makes it better fault tolerant against hardware errors (e.g. only individual disk sectors going bad).

+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Offsite backup with ZFS https://buetow.org/gemfeed/2016-04-03-offsite-backup-with-zfs.html 2016-04-03T22:43:42+01:00 - 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, ....). ...to read on visit my site. Paul Buetow comments@mx.buetow.org + 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, ....). ...to read on visit my site. + +

Offsite backup with ZFS

+
+ ________________
+|# :           : #|
+|  : ZFS/GELI  :  |
+|  :   Offsite :  |
+|  :  Backup   :  |
+|  :___________:  |
+|     _________   |
+|    | __      |  |
+|    ||  |     |  |
+\____||__|_____|__|
+
+

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!

+
The Fype Programming Language https://buetow.org/gemfeed/2010-05-09-the-fype-programming-language.html 2010-05-09T12:48:29+01:00 - 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.. .....to read on please visit my site. Paul Buetow comments@mx.buetow.org + 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.. .....to read on please visit my site. + +

The Fype Programming Language

+

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) <any> - <any>
+(any) <any> * <any>
+(any) <any> / <any>
+(integer) <any> == <any>
+(integer) <any> != <any>
+(integer) <any> <= <any>
+(integer) <any> gt <any>
+(integer) <any> <> <any>
+(integer) <any> gt <any>
+(integer) not <any>
+
+

Bitwise expressions

+
+(integer) <any> :< <any>
+(integer) <any> :> <any>
+(integer) <any> and <any>
+(integer) <any> or <any>
+(integer) <any> xor <any>
+
+

Numeric expressions

+
+(number) neg <number>
+
+

... returns the negative value of "number":

+
+(integer) no <integer>
+
+

... returns 1 if the argument is 0, otherwise it will return 0! If no argument is given, then 0 is returned!

+
+(integer) yes <integer>
+
+

... 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 <expression> { <statements> }
+
+

... runs the statements if the expression evaluates to a true value.

+
+ifnot <expression> { <statements> }
+
+

... runs the statements if the expression evaluates to a false value.

+
+while <expression> { <statements> }
+
+

... runs the statements as long as the expression evaluates to a true value.

+
+until <expression> { <statements> }
+
+

... 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 <identifier>
+
+

... returns 1 if "identifier" has been defined. Returns 0 otherwise.

+
+(integer) undef <identifier>
+
+

... 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 <integer>
+
+

... 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 <any>
+
+

... prints out the argument

+
+(any) say <any>
+
+

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
+

E-Mail me your thoughts at comments@mx.buetow.org!

+
Perl Poetry https://buetow.org/gemfeed/2008-06-26-perl-poetry.html 2008-06-26T21:43:51+01:00 - 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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site. Paul Buetow comments@mx.buetow.org + 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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site. + +

Perl Poetry

+
+ '\|/'                                  *
+-- * -----
+  /|\      ____
+ ' | '    {_   o^>       *
+   :        -_  /)
+   :         (   (        .-''`'.
+   .          \   \      /       \
+   .           \    \   /         \
+                \    `-'           `'.
+                 \    . '        /    `.
+                  \  ( \  )     (     .')
+   ,,   t          '. |  /       |     (
+  '|``_/^\___        '|  |`'-..-'|   ( ()
+_~~|~/_|_|__/|~~~~~~~ |  / ~~~~~ |   | ~~~~~~~~
+ -_  |L[|]L|/         | |\ MJP   )   )
+                      ( |(       /  /|
+   ~~ ~  ~ ~~~~       | /\\     / /| |
+                      ||  \\  _/ / | |
+             ~ ~ ~~~ _|| (_/ (___)_| |Nov291999
+                    (__)         (____)
+
+

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
+

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 <<EMail
+ to the parents to buy a new christmas tree!!!!111
+ and send the
+EMail
+;wait and redo deliver until defined local $tree;
+
+redo Santa, pipe $gifts, to_childs;
+redo Santa and do return if last one, is, delivered ;}
+
+END {} our $mission and do sleep until next Christmas ;}
+
+__END__
+
+This is perl, v5.8.8 built for i386-freebsd-64int
+
+

shopping.pl

+
+#!/usr/bin/perl
+
+# (C) 2007 by Paul C. Buetow (http://paul.buetow.org) 
+
+BEGIN{} goto mall for $shopping; 
+
+m/y/; mall: seek$s, cool products(), { to => $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
+

E-Mail me your thoughts at comments@mx.buetow.org!

+
-- cgit v1.2.3 From 3af6cdf952a7cc4bfd2fb5eb482ee4b2cdfd852a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 6 May 2021 09:44:23 +0100 Subject: include content to atom feed --- buetow.org.sh | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/buetow.org.sh b/buetow.org.sh index d0d8b5c5..f6a9a95a 100755 --- a/buetow.org.sh +++ b/buetow.org.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash declare -r ARG=$1; shift - source buetow.org.conf ## Test module @@ -52,7 +51,7 @@ GEMFEED ## Atom module -atom::meta () { +atomfeed::meta () { local -r gmi_file_path="$1"; shift local -r meta_file=$(sed 's|gemtext|meta|; s|.gmi$|.meta|;' <<< "$gmi_file_path") @@ -82,7 +81,17 @@ META cat "$meta_file" } -atom::generate () { +atomfeed::content () { + local -r gmi_file_path="$1"; shift + # sed: Remove all before the first header + # sed: Make HTML links absolute, Atom relative URLs feature seems a mess + # across different Atom clients. + html::gemini2html < <(sed '0,/^# / { /^# /!d; }' "$gmi_file_path") | + sed "s|href=\"\./|href=\"https://$DOMAIN/gemfeed/|g" | + sed "s|src=\"\./|src=\"https://$DOMAIN/gemfeed/|g" +} + +atomfeed::generate () { local -r gemfeed_dir="$CONTENT_DIR/gemtext/gemfeed" local -r atom_file="$gemfeed_dir/atom.xml" local -r now=$(date --iso-8601=seconds) @@ -100,7 +109,9 @@ ATOMHEADER while read -r gmi_file; do # Load cached meta information about the post. - source <(atom::meta "$gemfeed_dir/$gmi_file") + source <(atomfeed::meta "$gemfeed_dir/$gmi_file") + # Get HTML content for the feed + local content="$(atomfeed::content "$gemfeed_dir/$gmi_file")" cat <> "$atom_file.tmp" @@ -108,11 +119,14 @@ ATOMHEADER gemini://$DOMAIN/gemfeed/$gmi_file $meta_date - $meta_summary $meta_author $meta_email + $meta_summary + + $content + ATOMENTRY done < <(ls "$gemfeed_dir" | sort -r | grep '.gmi$' | grep -v '^index.gmi$' | head -n $ATOM_MAX_ENTRIES) @@ -246,7 +260,7 @@ html::gemini2html () { html::paragraph "$line" ;; esac - done < "$gmi_file" + done } html::generate () { @@ -257,7 +271,7 @@ html::generate () { local dest_dir=$(dirname "$dest") test ! -d "$dest_dir" && mkdir -p "$dest_dir" cat header.html.part > "$dest.tmp" - html::gemini2html "$src" >> "$dest.tmp" + html::gemini2html < "$src" >> "$dest.tmp" cat footer.html.part >> "$dest.tmp" mv "$dest.tmp" "$dest" git add "$dest" @@ -344,12 +358,12 @@ case $ARG in html::test ;; --atom) - atom::generate + atomfeed::generate ;; --publish) html::test gemfeed::generate - atom::generate + atomfeed::generate html::generate ;; --help|*) -- cgit v1.2.3 From 977b05697c21b4c16642cd46847304c806bb78b0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 7 May 2021 09:48:23 +0100 Subject: atom feed now also includes the whole content --- buetow.org.sh | 34 ++++++++++---- content/gemtext/gemfeed/atom.xml | 54 ++++++++++++++-------- ...-22-dtail-the-distributed-log-tail-program.html | 2 +- .../2021-04-24-welcome-to-the-geminispace.html | 2 +- content/html/gemfeed/atom.xml | 54 ++++++++++++++-------- 5 files changed, 97 insertions(+), 49 deletions(-) diff --git a/buetow.org.sh b/buetow.org.sh index f6a9a95a..738dcb4c 100755 --- a/buetow.org.sh +++ b/buetow.org.sh @@ -124,8 +124,10 @@ ATOMHEADER $meta_email $meta_summary - - $content + +
+ $content +
ATOMENTRY @@ -148,21 +150,29 @@ ATOMFOOTER ## HTML module +html::special () { + sed ' + s|\&|\&|g; + s|<|\<|g; + s|>|\>|g; + ' <<< "$@" +} + html::paragraph () { - local -r text="$1" - test -n "$text" && echo "

$text

" + local -r text="$1"; shift + test -n "$text" && echo "

$(html::special "$text")

" } html::heading () { - local -r text=$(sed -E 's/^#+ //' <<< "$1") - local -r level="$2" + local -r text=$(sed -E 's/^#+ //' <<< "$1"); shift + local -r level="$1"; shift - echo "$text" + echo "$(html::special "$text")" } html::quote () { local -r quote="${1/> }" - echo "
$quote
" + echo "
$(html::special "$quote")
" } html::img () { @@ -192,6 +202,7 @@ html::link () { descr="$descr $token" fi done < <(echo "$line" | tr ' ' '\n') + descr=$(html::special "$descr") if grep -E -q "$IMAGE_PATTERN" <<< "$link"; then html::img "$link" "$descr" @@ -226,7 +237,7 @@ html::gemini2html () { echo "
" is_plain=0 else - echo "$line" | sed 's|<|\<|g; s|>|\>|g' + html::special "$line" fi continue fi @@ -270,6 +281,7 @@ html::generate () { dest=${dest/.gmi/.html} local dest_dir=$(dirname "$dest") test ! -d "$dest_dir" && mkdir -p "$dest_dir" + cat header.html.part > "$dest.tmp" html::gemini2html < "$src" >> "$dest.tmp" cat footer.html.part >> "$dest.tmp" @@ -282,6 +294,7 @@ html::generate () { while read -r src; do local dest=${src/gemtext/html} local dest_dir=$(dirname "$dest") + test ! -d "$dest_dir" && mkdir -p "$dest_dir" cp -v "$src" "$dest" git add "$dest" @@ -308,6 +321,9 @@ html::test () { line="" assert::equals "$(html::paragraph "$line")" "" + line="Foo &<>& Bar!" + assert::equals "$(html::paragraph "$line")" "

Foo &<>& Bar!

" + line="# Header 1" assert::equals "$(html::heading "$line" 1)" "

Header 1

" diff --git a/content/gemtext/gemfeed/atom.xml b/content/gemtext/gemfeed/atom.xml index 88ed8411..2a97e1f2 100644 --- a/content/gemtext/gemfeed/atom.xml +++ b/content/gemtext/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-06T09:41:34+01:00 + 2021-05-07T09:45:39+01:00 buetow.org feed Having fun with computers! @@ -16,8 +16,9 @@ comments@mx.buetow.org Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is: ... to read on visit my site. - -

Welcome to the Geminispace

+ +
+

Welcome to the Geminispace

Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is:

gemini://buetow.org

If you however still use HTTP then you are just surfing the fallback HTML version of this capsule. In that case I suggest reading on what this is all about :-).

@@ -42,7 +43,7 @@

Motivation

My urge to revamp my personal website

-

For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.

+

For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.

My still great Laptop running hot

Earlier this year (2021) I noticed that my 6 year old but still great Laptop started to become hot and slowed down while surfing the web. Also, the Laptop's fan became quite noisy. This is all due to the additional bloat such as JavaScript, excessive use of CSS, tracking cookies+pixels, ads and so on there was on the website.

All what I wanted was to read an interesting article but after a big advertising pop-up banner appeared and made everything worse I gave up and closed the browser tab.

@@ -68,6 +69,7 @@ gemini://gemini.circumlunar.space
https://gemini.circumlunar.space

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -80,15 +82,16 @@ comments@mx.buetow.org This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too. ...to read on visit my site. - -

DTail - The distributed log tail program

+ +
+

DTail - The distributed log tail program

DTail logo image:DTail logo image

This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too.

Original Mimecast Engineering Blog post at Medium

Running a large cloud-based service requires monitoring the state of huge numbers of machines, a task for which many standard UNIX tools were not really designed. In this post, I will describe a simple program, DTail, that Mimecast has built and released as Open-Source, which enables us to monitor log files of many servers at once without the costly overhead of a full-blown log management system.

At Mimecast, we run over 10 thousand server boxes. Most of them host multiple microservices and each of them produces log files. Even with the use of time series databases and monitoring systems, raw application logs are still an important source of information when it comes to analysing, debugging, and troubleshooting services.

Every engineer familiar with UNIX or a UNIX-like platform (e.g., Linux) is well aware of tail, a command-line program for displaying a text file content on the terminal which is also especially useful for following application or system log files with tail -f logfile.

-

Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.

+

Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.

A Mimecast Pet Project

DTail got its inspiration from public domain tools available already in this area but it is a blue sky from-scratch development which was first presented at Mimecast’s annual internal Pet Project competition (awarded with a Bronze prize). It has gained popularity since and is one of the most widely deployed DevOps tools at Mimecast (reaching nearly 10k server installations) and many engineers use it on a regular basis. The Open-Source version of DTail is available at:

https://dtail.dev
@@ -146,6 +149,7 @@ dtail –servers serverlist.txt –files ‘/var/log/*.log’ –regex ‘(?i:er

Mimecast highly encourages you to have a look at DTail and submit an issue for any features you would like to see. Have you found a bug? Maybe you just have a question or comment? If you want to go a step further: We would also love to see pull requests for any features or improvements. Either way, if in doubt just contact us via the DTail GitHub page.

https://dtail.dev

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -158,8 +162,9 @@ dtail –servers serverlist.txt –files ‘/var/log/*.log’ –regex ‘(?i:er comments@mx.buetow.org You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.. .....to read on please visit my site. - -

Methods in C

+ +
+

Methods in C

You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.

Example

Lets have a look at the following sample program. Basically all you have to do is to add a function pointer such as "calculate" to the definition of struct "something_s". Later, during the struct initialization, assign a function address to that function pointer:

@@ -223,6 +228,7 @@ mult.calculate(mult,a,b));

Taking it further

If you want to take it further type "Object-Oriented Programming with ANSI-C" into your favorite internet search engine, you will find some crazy stuff. Some go as far as writing a C preprocessor in AWK, which takes some object oriented pseudo-C and transforms it to plain C so that the C compiler can compile it to machine code. This is actually similar to how the C++ language had its origins.

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -235,8 +241,9 @@ mult.calculate(mult,a,b)); comments@mx.buetow.org Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains 'buetow.org' and 'buetow.zone'. My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now I am making use of that option.. .....to read on please visit my site. - -

Spinning up my own authoritative DNS servers

+ +
+

Spinning up my own authoritative DNS servers

Background

Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains "buetow.org" and "buetow.zone". My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now, I am making use of that option.

Schlund Technologies
@@ -445,6 +452,7 @@ apply Service "dig6" {

That's much more comfortable now than manually clicking at some web UIs at Schlund Technologies.

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -457,8 +465,9 @@ apply Service "dig6" { comments@mx.buetow.org I enhanced the procedure a bit. From now on I am having two external 2TB USB hard drives. Both are setup exactly the same way. To decrease the probability that they will not fail at about the same time both drives are of different brands. One drive is kept at the secret location. The other one is kept at home right next to my HP MicroServer. ...to read on visit my site. - -

Offsite backup with ZFS (Part 2)

+ +
+

Offsite backup with ZFS (Part 2)

  ________________
 |# :           : #|
@@ -478,6 +487,7 @@ apply Service "dig6" {
 

Whenever I am updating offsite backup, I am doing it to the drive which is kept locally. Afterwards I bring it to the secret location and swap the drives and bring the other one back home. This ensures that I will always have an offiste backup available at a different location than my home - even while updating one copy of it.

Furthermore, I added scrubbing (*zpool scrub...*) to the script. It ensures that the file system is consistent and that there are no bad blocks on the disk and the file system. To increase the reliability I also run a *zfs set copies=2 zroot*. That setting is also synchronized to the offsite ZFS pool. ZFS stores every data block to disk twice now. Yes, it consumes twice as much disk space but it makes it better fault tolerant against hardware errors (e.g. only individual disk sectors going bad).

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -490,8 +500,9 @@ apply Service "dig6" { comments@mx.buetow.org 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, ....). ...to read on visit my site. - -

Offsite backup with ZFS

+ +
+

Offsite backup with ZFS

  ________________
 |# :           : #|
@@ -516,6 +527,7 @@ apply Service "dig6" {
 

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!

+
@@ -528,8 +540,9 @@ apply Service "dig6" { comments@mx.buetow.org 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.. .....to read on please visit my site. - -

The Fype Programming Language

+ +
+

The Fype Programming Language

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!".

@@ -920,6 +933,7 @@ BB

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

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -932,8 +946,9 @@ BB comments@mx.buetow.org 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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site. - -

Perl Poetry

+ +
+

Perl Poetry

  '\|/'                                  *
 -- * -----
@@ -1081,6 +1096,7 @@ This is perl, v5.8.8 built for i386-freebsd-64int
 

Did you like what you saw? Have a look at Github to see my other poems too:

https://github.com/snonux/perl-poetry

E-Mail me your thoughts at comments@mx.buetow.org!

+
diff --git a/content/html/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html b/content/html/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html index bc73f30e..2e1e7ec0 100644 --- a/content/html/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html +++ b/content/html/gemfeed/2021-04-22-dtail-the-distributed-log-tail-program.html @@ -27,7 +27,7 @@ li { color: #98be65; }

Running a large cloud-based service requires monitoring the state of huge numbers of machines, a task for which many standard UNIX tools were not really designed. In this post, I will describe a simple program, DTail, that Mimecast has built and released as Open-Source, which enables us to monitor log files of many servers at once without the costly overhead of a full-blown log management system.

At Mimecast, we run over 10 thousand server boxes. Most of them host multiple microservices and each of them produces log files. Even with the use of time series databases and monitoring systems, raw application logs are still an important source of information when it comes to analysing, debugging, and troubleshooting services.

Every engineer familiar with UNIX or a UNIX-like platform (e.g., Linux) is well aware of tail, a command-line program for displaying a text file content on the terminal which is also especially useful for following application or system log files with tail -f logfile.

-

Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.

+

Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.

A Mimecast Pet Project

DTail got its inspiration from public domain tools available already in this area but it is a blue sky from-scratch development which was first presented at Mimecast’s annual internal Pet Project competition (awarded with a Bronze prize). It has gained popularity since and is one of the most widely deployed DevOps tools at Mimecast (reaching nearly 10k server installations) and many engineers use it on a regular basis. The Open-Source version of DTail is available at:

https://dtail.dev
diff --git a/content/html/gemfeed/2021-04-24-welcome-to-the-geminispace.html b/content/html/gemfeed/2021-04-24-welcome-to-the-geminispace.html index eaf5b841..a9b6d431 100644 --- a/content/html/gemfeed/2021-04-24-welcome-to-the-geminispace.html +++ b/content/html/gemfeed/2021-04-24-welcome-to-the-geminispace.html @@ -46,7 +46,7 @@ li { color: #98be65; }

Motivation

My urge to revamp my personal website

-

For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.

+

For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.

My still great Laptop running hot

Earlier this year (2021) I noticed that my 6 year old but still great Laptop started to become hot and slowed down while surfing the web. Also, the Laptop's fan became quite noisy. This is all due to the additional bloat such as JavaScript, excessive use of CSS, tracking cookies+pixels, ads and so on there was on the website.

All what I wanted was to read an interesting article but after a big advertising pop-up banner appeared and made everything worse I gave up and closed the browser tab.

diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml index 23974c1b..41668cbb 100644 --- a/content/html/gemfeed/atom.xml +++ b/content/html/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-06T09:41:34+01:00 + 2021-05-07T09:45:39+01:00 buetow.org feed Having fun with computers! @@ -16,8 +16,9 @@ comments@mx.buetow.org Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is: ... to read on visit my site. - -

Welcome to the Geminispace

+ +
+

Welcome to the Geminispace

Have you reached this article already via Gemini? You need a special client for that, web browsers such as Firefox, Chrome, Safari etc. don't support the Gemini protocol. The Gemini address of this site (or the address of this capsule as people say in Geminispace) is:

https://buetow.org

If you however still use HTTP then you are just surfing the fallback HTML version of this capsule. In that case I suggest reading on what this is all about :-).

@@ -42,7 +43,7 @@

Motivation

My urge to revamp my personal website

-

For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.

+

For some time I had to urge to revamp my personal website. Not to update the technology and the design of it but to update all the content (+ keep it current) and also to start a small tech blog again. So unconsciously I started to search for a good platform and/or software to do all of that in a KISS (keep it simple & stupid) way.

My still great Laptop running hot

Earlier this year (2021) I noticed that my 6 year old but still great Laptop started to become hot and slowed down while surfing the web. Also, the Laptop's fan became quite noisy. This is all due to the additional bloat such as JavaScript, excessive use of CSS, tracking cookies+pixels, ads and so on there was on the website.

All what I wanted was to read an interesting article but after a big advertising pop-up banner appeared and made everything worse I gave up and closed the browser tab.

@@ -68,6 +69,7 @@ https://gemini.circumlunar.space
https://gemini.circumlunar.space

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -80,15 +82,16 @@ comments@mx.buetow.org This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too. ...to read on visit my site. - -

DTail - The distributed log tail program

+ +
+

DTail - The distributed log tail program

DTail logo image:DTail logo image

This article first appeared at the Mimecast Engineering Blog but I made it available here in my personal Gemini capsule too.

Original Mimecast Engineering Blog post at Medium

Running a large cloud-based service requires monitoring the state of huge numbers of machines, a task for which many standard UNIX tools were not really designed. In this post, I will describe a simple program, DTail, that Mimecast has built and released as Open-Source, which enables us to monitor log files of many servers at once without the costly overhead of a full-blown log management system.

At Mimecast, we run over 10 thousand server boxes. Most of them host multiple microservices and each of them produces log files. Even with the use of time series databases and monitoring systems, raw application logs are still an important source of information when it comes to analysing, debugging, and troubleshooting services.

Every engineer familiar with UNIX or a UNIX-like platform (e.g., Linux) is well aware of tail, a command-line program for displaying a text file content on the terminal which is also especially useful for following application or system log files with tail -f logfile.

-

Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.

+

Think of DTail as a distributed version of the tail program which is very useful when you have a distributed application running on many servers. DTail is an Open-Source, cross-platform, fairly easy to use, support and maintain log file analysis & statistics gathering tool designed for Engineers and Systems Administrators. It is programmed in Google Go.

A Mimecast Pet Project

DTail got its inspiration from public domain tools available already in this area but it is a blue sky from-scratch development which was first presented at Mimecast’s annual internal Pet Project competition (awarded with a Bronze prize). It has gained popularity since and is one of the most widely deployed DevOps tools at Mimecast (reaching nearly 10k server installations) and many engineers use it on a regular basis. The Open-Source version of DTail is available at:

https://dtail.dev
@@ -146,6 +149,7 @@ dtail –servers serverlist.txt –files ‘/var/log/*.log’ –regex ‘(?i:er

Mimecast highly encourages you to have a look at DTail and submit an issue for any features you would like to see. Have you found a bug? Maybe you just have a question or comment? If you want to go a step further: We would also love to see pull requests for any features or improvements. Either way, if in doubt just contact us via the DTail GitHub page.

https://dtail.dev

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -158,8 +162,9 @@ dtail –servers serverlist.txt –files ‘/var/log/*.log’ –regex ‘(?i:er comments@mx.buetow.org You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.. .....to read on please visit my site. - -

Methods in C

+ +
+

Methods in C

You can do some sort of object oriented programming in the C Programming Language. However, that is very limited. But also very easy and straight forward to use.

Example

Lets have a look at the following sample program. Basically all you have to do is to add a function pointer such as "calculate" to the definition of struct "something_s". Later, during the struct initialization, assign a function address to that function pointer:

@@ -223,6 +228,7 @@ mult.calculate(mult,a,b));

Taking it further

If you want to take it further type "Object-Oriented Programming with ANSI-C" into your favorite internet search engine, you will find some crazy stuff. Some go as far as writing a C preprocessor in AWK, which takes some object oriented pseudo-C and transforms it to plain C so that the C compiler can compile it to machine code. This is actually similar to how the C++ language had its origins.

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -235,8 +241,9 @@ mult.calculate(mult,a,b)); comments@mx.buetow.org Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains 'buetow.org' and 'buetow.zone'. My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now I am making use of that option.. .....to read on please visit my site. - -

Spinning up my own authoritative DNS servers

+ +
+

Spinning up my own authoritative DNS servers

Background

Finally, I had time to deploy my own authoritative DNS servers (master and slave) for my domains "buetow.org" and "buetow.zone". My domain name provider is Schlund Technologies. They allow their customers to manually edit the DNS records (BIND files). And they also give you the opportunity to set your own authoritative DNS servers for your domains. From now, I am making use of that option.

Schlund Technologies
@@ -445,6 +452,7 @@ apply Service "dig6" {

That's much more comfortable now than manually clicking at some web UIs at Schlund Technologies.

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -457,8 +465,9 @@ apply Service "dig6" { comments@mx.buetow.org I enhanced the procedure a bit. From now on I am having two external 2TB USB hard drives. Both are setup exactly the same way. To decrease the probability that they will not fail at about the same time both drives are of different brands. One drive is kept at the secret location. The other one is kept at home right next to my HP MicroServer. ...to read on visit my site. - -

Offsite backup with ZFS (Part 2)

+ +
+

Offsite backup with ZFS (Part 2)

  ________________
 |# :           : #|
@@ -478,6 +487,7 @@ apply Service "dig6" {
 

Whenever I am updating offsite backup, I am doing it to the drive which is kept locally. Afterwards I bring it to the secret location and swap the drives and bring the other one back home. This ensures that I will always have an offiste backup available at a different location than my home - even while updating one copy of it.

Furthermore, I added scrubbing (*zpool scrub...*) to the script. It ensures that the file system is consistent and that there are no bad blocks on the disk and the file system. To increase the reliability I also run a *zfs set copies=2 zroot*. That setting is also synchronized to the offsite ZFS pool. ZFS stores every data block to disk twice now. Yes, it consumes twice as much disk space but it makes it better fault tolerant against hardware errors (e.g. only individual disk sectors going bad).

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -490,8 +500,9 @@ apply Service "dig6" { comments@mx.buetow.org 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, ....). ...to read on visit my site. - -

Offsite backup with ZFS

+ +
+

Offsite backup with ZFS

  ________________
 |# :           : #|
@@ -516,6 +527,7 @@ apply Service "dig6" {
 

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!

+
@@ -528,8 +540,9 @@ apply Service "dig6" { comments@mx.buetow.org 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.. .....to read on please visit my site. - -

The Fype Programming Language

+ +
+

The Fype Programming Language

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!".

@@ -920,6 +933,7 @@ BB

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

E-Mail me your thoughts at comments@mx.buetow.org!

+
@@ -932,8 +946,9 @@ BB comments@mx.buetow.org 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 exists for fun and demonstrate what you can do with Perl syntax.. .....to read on please visit my site. - -

Perl Poetry

+ +
+

Perl Poetry

  '\|/'                                  *
 -- * -----
@@ -1081,6 +1096,7 @@ This is perl, v5.8.8 built for i386-freebsd-64int
 

Did you like what you saw? Have a look at Github to see my other poems too:

https://github.com/snonux/perl-poetry

E-Mail me your thoughts at comments@mx.buetow.org!

+
-- cgit v1.2.3 From cd15fe1606df4ef2659d59271a01560549e13f69 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 7 May 2021 10:15:50 +0100 Subject: all HTML files are now XHTML 1.0 Transitional --- content/html/contact-information.html | 8 ++++---- content/html/gemfeed/2008-06-26-perl-poetry.html | 8 ++++---- .../html/gemfeed/2010-05-09-the-fype-programming-language.html | 8 ++++---- content/html/gemfeed/2016-04-03-offsite-backup-with-zfs.html | 8 ++++---- .../html/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.html | 8 ++++---- .../2016-05-22-spinning-up-my-own-authoritative-dns-servers.html | 8 ++++---- content/html/gemfeed/2016-11-20-methods-in-c.html | 8 ++++---- .../2021-04-22-dtail-the-distributed-log-tail-program.html | 8 ++++---- content/html/gemfeed/2021-04-24-welcome-to-the-geminispace.html | 8 ++++---- content/html/gemfeed/index.html | 8 ++++---- content/html/index.html | 8 ++++---- content/html/resources.html | 8 ++++---- header.html.part | 8 ++++---- 13 files changed, 52 insertions(+), 52 deletions(-) diff --git a/content/html/contact-information.html b/content/html/contact-information.html index 8ba376ed..20bbec62 100644 --- a/content/html/contact-information.html +++ b/content/html/contact-information.html @@ -1,10 +1,10 @@ - - + + + Having fun with computers! - -