From 30fc4e8f74315a92aaec36dfb9a8d4efa0a21791 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 7 Apr 2023 00:49:19 +0300 Subject: exact style --- gemfeed/2008-06-26-perl-poetry.html | 52 ++-- ...12-29-using-my-nokia-n95-for-fixing-my-mta.html | 32 ++- gemfeed/2010-04-09-standard-ml-and-haskell.html | 82 ++++-- ...010-05-07-lazy-evaluation-with-standarn-ml.html | 44 ++- .../2010-05-09-the-fype-programming-language.html | 262 ++++++++++++----- .../2011-05-07-perl-daemon-service-framework.html | 96 +++++-- .../2014-03-24-the-fibonacci.pl.c-polyglot.html | 41 ++- ...2-05-run-debian-on-your-phone-with-debroid.html | 78 ++++-- gemfeed/2016-04-03-offsite-backup-with-zfs.html | 50 ++-- ...04-09-jails-and-zfs-on-freebsd-with-puppet.html | 71 +++-- .../2016-04-16-offsite-backup-with-zfs-part2.html | 26 +- ...inning-up-my-own-authoritative-dns-servers.html | 77 +++-- ...20-object-oriented-programming-with-ansi-c.html | 65 +++-- ...alistic-load-testing-with-ioriot-for-linux.html | 190 +++++++++---- ...-22-dtail-the-distributed-log-tail-program.html | 148 ++++++---- gemfeed/2021-04-24-welcome-to-the-geminispace.html | 99 ++++--- ...021-05-16-personal-bash-coding-style-guide.html | 237 +++++++++++----- ...5-gemtexter-one-bash-script-to-rule-it-all.html | 161 +++++++---- gemfeed/2021-07-04-the-well-grounded-rubyist.html | 129 ++++++--- ...-08-01-on-being-pedantic-about-open-source.html | 158 +++++++---- gemfeed/2021-09-12-keep-it-simple-and-stupid.html | 131 ++++++--- gemfeed/2021-10-22-defensive-devops.html | 127 ++++++--- gemfeed/2021-11-29-bash-golf-part-1.html | 239 +++++++++++----- ...-12-26-how-to-stay-sane-as-a-devops-person.html | 155 ++++++---- gemfeed/2022-01-01-bash-golf-part-2.html | 221 ++++++++++----- gemfeed/2022-01-23-welcome-to-the-foo.zone.html | 53 ++-- ...022-02-04-computer-operating-systems-i-use.html | 306 ++++++++++++-------- gemfeed/2022-03-06-the-release-of-dtail-4.0.0.html | 183 ++++++++---- gemfeed/2022-04-10-creative-universe.html | 157 +++++++---- .../2022-05-27-perl-is-still-a-great-choice.html | 191 ++++++++----- gemfeed/2022-06-15-sweating-the-small-stuff.html | 312 ++++++++++++++------- ...22-07-30-lets-encrypt-with-openbsd-and-rex.html | 190 +++++++++---- ...2-08-27-gemtexter-1.1.0-lets-gemtext-again.html | 97 ++++--- gemfeed/2022-09-30-after-a-bad-nights-sleep.html | 119 +++++--- .../2022-10-30-installing-dtail-on-openbsd.html | 167 +++++++---- ...-tried-emacs-but-i-switched-back-to-neovim.html | 158 +++++++---- ...22-12-24-ultrarelearning-java-my-takeaways.html | 147 ++++++---- gemfeed/2023-01-23-why-grapheneos-rox.html | 177 ++++++++---- .../2023-02-26-how-to-shut-down-after-work.html | 90 ++++-- ...-03-16-the-pragmatic-programmer-book-notes.html | 92 +++--- ...03-25-gemtexter-2.0.0-lets-gemtext-again-2.html | 103 ++++--- ...4-01-never-split-the-difference-book-notes.html | 126 ++++++--- gemfeed/index.html | 90 +++--- index.html | 124 ++++---- notes/index.html | 22 +- notes/mental-combat.html | 36 ++- notes/never-split-the-difference.html | 126 ++++++--- notes/soft-skills.html | 256 ++++++++++------- notes/the-pragmatic-programmer.html | 92 +++--- notes/the-stoic-challenge.html | 45 +-- other-resources.html | 53 ++-- projects.html | 23 +- resources.html | 92 +++--- site-mirrors.html | 47 ++-- style.css | 6 +- testpage.html | 102 +++---- uptime-stats.html | 115 +++++--- 57 files changed, 4525 insertions(+), 2343 deletions(-) diff --git a/gemfeed/2008-06-26-perl-poetry.html b/gemfeed/2008-06-26-perl-poetry.html index 8548d656..635d0ac0 100644 --- a/gemfeed/2008-06-26-perl-poetry.html +++ b/gemfeed/2008-06-26-perl-poetry.html @@ -8,8 +8,10 @@ -

Perl Poetry

-

Published at 2008-06-26T21:43:51+01:00; Updated at 2021-05-04

+

Perl Poetry


+
+Published at 2008-06-26T21:43:51+01:00; Updated at 2021-05-04
+
  '\|/'                                  *
 -- * -----
@@ -32,10 +34,15 @@ _~~|~/_|_|__/|~~~~~~~ |  / ~~~~~ |   | ~~~~~~~~
              ~ ~ ~~~ _|| (_/ (___)_| |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

+
+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
 
@@ -77,7 +84,9 @@ home: //ig,'nore', time and sleep $very =~ s/tr/on/g;
 __END__
 
 
-

christmas.pl

+
+

christmas.pl


+
 #!/usr/bin/perl
 
@@ -121,7 +130,9 @@ __END__
 
 This is perl, v5.8.8 built for i386-freebsd-64int
 
-

shopping.pl

+
+

shopping.pl


+
 #!/usr/bin/perl
 
@@ -153,15 +164,22 @@ and sleep until unpack$ing, cool products();
 __END__
 This is perl, v5.8.8 built for i386-freebsd-64int
 
-

More...

-

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

-https://codeberg.org/snonux/perl-poetry
-

Other related posts are:

-2022-05-27 Perl is still a great choice
-2011-05-07 Perl Daemon (Service Framework)
-2008-06-26 Perl Poetry (You are currently reading this)
-

E-Mail your comments to hi@paul.cyou :-)

-Back to the main site
+
+

More...


+
+Did you like what you saw? Have a look at Codeberg to see my other poems too:
+
+https://codeberg.org/snonux/perl-poetry
+
+Other related posts are:
+
+2022-05-27 Perl is still a great choice
+2011-05-07 Perl Daemon (Service Framework)
+2008-06-26 Perl Poetry (You are currently reading this)
+
+E-Mail your comments to hi@paul.cyou :-)
+
+Back to the main site

Using my Nokia N95 for fixing my MTA

-

Published at 2008-12-29T09:10:41+00:00; Updated at 2021-12-01

+

Using my Nokia N95 for fixing my MTA


+
+Published at 2008-12-29T09:10:41+00:00; Updated at 2021-12-01
+
 
            _
@@ -26,20 +28,28 @@
 _jgs_\|//_\\|///_\V/_\|//__
                       Art by Joan Stark
 
-

The last week I was in Vidin, Bulgaria with no internet access and I had to fix my MTA (Postfix) at host.0.buetow.org which serves E-Mail for all my customers at P. B. Labs. Good, that I do not guarantee high availability on my web services (I've to do a full time job somewhere else too).

-

My first attempt to find an internet café, which was working during Christmastime, failed. However, I found with my N95 phone lots of free WLAN hotspots. The hotspots refused me logging into my server using SSH as I have configured a non-standard port for SSH for security reasons. Without knowing the costs, I used the GPRS internet access of my German phone provider (yes, I had to pay roaming fees).

-Picture of a Nokia N95
-

With Putty for N95 and configuring Postfix with Vim and the T9 input mechanism, I managed to fix the problem. But it took half of an hour:

+
+The last week I was in Vidin, Bulgaria with no internet access and I had to fix my MTA (Postfix) at host.0.buetow.org which serves E-Mail for all my customers at P. B. Labs. Good, that I do not guarantee high availability on my web services (I've to do a full time job somewhere else too).
+
+My first attempt to find an internet café, which was working during Christmastime, failed. However, I found with my N95 phone lots of free WLAN hotspots. The hotspots refused me logging into my server using SSH as I have configured a non-standard port for SSH for security reasons. Without knowing the costs, I used the GPRS internet access of my German phone provider (yes, I had to pay roaming fees).
+
+Picture of a Nokia N95
+
+With Putty for N95 and configuring Postfix with Vim and the T9 input mechanism, I managed to fix the problem. But it took half of an hour:
+
-

It was a pain in the ass. My next mobile phone MUST have a full QWERTY keyboard. This would have made my life lots easier. :)

-

At the moment I am in Sofia, Bulgaria. Here I can use at least an unprotected WLAN hotspot which belongs to one of the neighbours which I don’t know in person, and it is not blocking any port at all :)

-

E-Mail your comments to hi@paul.cyou :-)

-Back to the main site
+
+It was a pain in the ass. My next mobile phone MUST have a full QWERTY keyboard. This would have made my life lots easier. :)
+
+At the moment I am in Sofia, Bulgaria. Here I can use at least an unprotected WLAN hotspot which belongs to one of the neighbours which I don’t know in person, and it is not blocking any port at all :)
+
+E-Mail your comments to hi@paul.cyou :-)
+
+Back to the main site

Standard ML and Haskell

-

Published at 2010-04-09T22:57:36+01:00

-

I am currently looking into the functional programming language Standard ML (aka SML). The purpose is to refresh my functional programming skills and to learn something new too. Since I already knew a little Haskell, I could not help myself, and I also implemented the same exercises in Haskell.

-

As you will see, SML and Haskell are very similar (at least when it comes to the basics). However, the syntax of Haskell is a bit more "advanced". Haskell utilizes fewer keywords (e.g. no val, end, fun, fn ...). Haskell also allows to write down the function types explicitly. What I have been missing in SML so far is the so-called pattern guards. Although this is a very superficial comparison for now, so far, I like Haskell more than SML. Nevertheless, I thought it would be fun to demonstrate a few simple functions of both languages to show off the similarities.

-

Haskell is also a "pure functional" programming language, whereas SML also makes explicit use of imperative concepts. I am by far not a specialist in either of these languages, but here are a few functions implemented in both SML and Haskell:

-

Defining a multi-data type

-

Standard ML:

+

Standard ML and Haskell


+
+Published at 2010-04-09T22:57:36+01:00
+
+I am currently looking into the functional programming language Standard ML (aka SML). The purpose is to refresh my functional programming skills and to learn something new too. Since I already knew a little Haskell, I could not help myself, and I also implemented the same exercises in Haskell.
+
+As you will see, SML and Haskell are very similar (at least when it comes to the basics). However, the syntax of Haskell is a bit more "advanced". Haskell utilizes fewer keywords (e.g. no val, end, fun, fn ...). Haskell also allows to write down the function types explicitly. What I have been missing in SML so far is the so-called pattern guards. Although this is a very superficial comparison for now, so far, I like Haskell more than SML. Nevertheless, I thought it would be fun to demonstrate a few simple functions of both languages to show off the similarities.
+
+Haskell is also a "pure functional" programming language, whereas SML also makes explicit use of imperative concepts. I am by far not a specialist in either of these languages, but here are a few functions implemented in both SML and Haskell:
+
+

Defining a multi-data type


+
+Standard ML:
+
 datatype ’a multi
 	= EMPTY
 	| ELEM of ’a
 	| UNION of ’a multi * ’a multi
 
-

Haskell:

+
+Haskell:
+
 data (Eq a) => Multi a
     = Empty
@@ -29,8 +38,11 @@ data (Eq a) => Multi a
     | Union (Multi a) (Multi a)
     deriving Show
 
-

Processing a multi

-

Standard ML:

+
+

Processing a multi


+
+Standard ML:
+
 fun number (EMPTY) _ = 0
 	| number (ELEM x) w = if x = w then 1 else 0
@@ -39,7 +51,9 @@ fun test_number w = number (UNION (EMPTY, \
     UNION (ELEM 4, UNION (ELEM 6, \
     UNION (UNION (ELEM 4, ELEM 4), EMPTY))))) w 
 
-

Haskell:

+
+Haskell:
+
 number Empty _ = 0
 number (Elem x) w = if x == w then 1 else 0
@@ -47,8 +61,11 @@ test_number w = number (Union Empty \
     (Union (Elem 4) (Union (Elem 6) \
     (Union (Union (Elem 4) (Elem 4)) Empty)))) w
 
-

Simplify function

-

Standard ML:

+
+

Simplify function


+
+Standard ML:
+
 fun simplify (UNION (x,y)) =
     let fun is_empty (EMPTY) = true | is_empty _ = false
@@ -64,7 +81,9 @@ fun simplify (UNION (x,y)) =
     end
   | simplify x = x
 
-

Haskell:

+
+Haskell:
+
 simplify (Union x y)
     | (isEmpty x’) && (isEmpty y’) = Empty
@@ -78,8 +97,11 @@ simplify (Union x y)
         y’ = simplify y
 simplify x = x
 
-

Delete all

-

Standard ML:

+
+

Delete all


+
+Standard ML:
+
 fun delete_all m w =
     let fun delete_all’ (ELEM x) = if x = w then EMPTY else ELEM x
@@ -88,7 +110,9 @@ fun delete_all m w =
     in simplify (delete_all’ m)
     end
 
-

Haskell:

+
+Haskell:
+
 delete_all m w = simplify (delete_all’ m)
     where
@@ -96,8 +120,11 @@ delete_all m w = simplify (delete_all’ m)
         delete_all’ (Union x y) = Union (delete_all’ x) (delete_all’ y)
         delete_all’ x = x
 
-

Delete one

-

Standard ML:

+
+

Delete one


+
+Standard ML:
+
 fun delete_one m w =
     let fun delete_one’ (UNION (x,y)) =
@@ -115,7 +142,9 @@ fun delete_one m w =
         in simplify m’
     end
 
-

Haskell:

+
+Haskell:
+
 delete_one m w = do
     let (m’, _) = delete_one’ m
@@ -131,8 +160,11 @@ delete_one m w = do
             if x == w then (Empty, True) else (Elem x, False)
         delete_one’ x = (x, False)
 
-

Higher-order functions

-

The first line is always the SML code, the second line the Haskell variant:

+
+

Higher-order functions


+
+The first line is always the SML code, the second line the Haskell variant:
+
 fun make_map_fn f1 = fn (x,y) => f1 x :: y
 make_map_fn f1 = \x y -> f1 x : y
@@ -146,8 +178,10 @@ my_map f l = foldr (make_map_fn f) [] l
 fun my_filter f l = foldr (make_filter_fn f) [] l
 my_filter f l = foldr (make_filter_fn f) [] l
 
-

E-Mail your comments to hi@paul.cyou :-)

-Back to the main site
+
+E-Mail your comments to hi@paul.cyou :-)
+
+Back to the main site

Lazy Evaluation with Standard ML

-

Published at 2010-05-07T08:17:59+01:00

+

Lazy Evaluation with Standard ML


+
+Published at 2010-05-07T08:17:59+01:00
+
 
       _____|~~\_____      _____________
@@ -22,12 +24,19 @@
  `---------------'--\\\\      .`--'          -Glyde-
                               `||||
 
-

In contrast to Haskell, Standard SML does not use lazy evaluation by default but an eager evaluation.

-https://en.wikipedia.org/wiki/Eager_evaluation
-https://en.wikipedia.org/wiki/Lazy_evaluation
-

You can solve specific problems with lazy evaluation easier than with eager evaluation. For example, you might want to list the number Pi or another infinite list of something. With the help of lazy evaluation, each element of the list is calculated when it is accessed first, but not earlier.

-

Emulating lazy evaluation in SML

-

However, it is possible to emulate lazy evaluation in most eager evaluation languages. This is how it is done with Standard ML (with some play with an infinite list of natural number tuples filtering out 0 elements):

+
+In contrast to Haskell, Standard SML does not use lazy evaluation by default but an eager evaluation.
+
+https://en.wikipedia.org/wiki/Eager_evaluation
+https://en.wikipedia.org/wiki/Lazy_evaluation
+
+
+You can solve specific problems with lazy evaluation easier than with eager evaluation. For example, you might want to list the number Pi or another infinite list of something. With the help of lazy evaluation, each element of the list is calculated when it is accessed first, but not earlier.
+
+

Emulating lazy evaluation in SML


+
+However, it is possible to emulate lazy evaluation in most eager evaluation languages. This is how it is done with Standard ML (with some play with an infinite list of natural number tuples filtering out 0 elements):
+
 type ’a lazy = unit -> ’a;
 
@@ -67,9 +76,13 @@ fun nat_pairs_not_null () =
 val test = first 10 (nat_pairs_not_null ());
 *)
 
-http://smlnj.org/
-

Real laziness with Haskell

-

As Haskell already uses lazy evaluation by default, there is no need to construct a new data type. Lists in Haskell are lazy by default. You will notice that the code is also much shorter and easier to understand than the SML version.

+
+http://smlnj.org/
+
+

Real laziness with Haskell


+
+As Haskell already uses lazy evaluation by default, there is no need to construct a new data type. Lists in Haskell are lazy by default. You will notice that the code is also much shorter and easier to understand than the SML version.
+
 {- Just to make it look like the ML example -}
 first = take
@@ -91,9 +104,12 @@ nat_pairs_not_null = filters (\[x,y] -> x > 0 && y > 0) nat_pai
 first 10 nat_pairs_not_null
 -}
 
-http://www.haskell.org/
-

E-Mail your comments to hi@paul.cyou :-)

-Back to the main site
+
+http://www.haskell.org/
+
+E-Mail your comments to hi@paul.cyou :-)
+
+Back to the main site

The Fype Programming Language

-

Published at 2010-05-09T12:48:29+01:00; Updated at 2021-05-05

+

The Fype Programming Language


+
+Published at 2010-05-09T12:48:29+01:00; Updated at 2021-05-05
+
       ____                                      _        __       
      / / _|_   _ _ __   ___    _   _  ___  __ _| |__    / _|_   _ 
@@ -18,12 +20,19 @@
 (_)_/ |_|  \__, | .__/ \___|   \__, |\___|\__,_|_| |_(_)_|  \__, |
            |___/|_|            |___/                        |___/ 
 
-

Fype is an interpreted programming language created by me for learning and fun. The interpreter is written in C. It has been tested on FreeBSD and NetBSD and may also work on other Unix like operating systems such as Linux based ones. Besides learning and fun, there is no other use case of why Fype exists as many other programming languages are much faster and more powerful.

-

The Fype syntax is straightforward and uses a maximum look ahead of 1 and an effortless top-down parsing mechanism. Fype is parsing and interpreting its code simultaneously. This means that syntax errors are only detected during program runtime.

-

Fype is a recursive acronym and means "Fype is For Your Program Execution" or "Fype is Free Yak Programmed for ELF". You could also say, "It's not a hype - it's Fype!".

-

Object-oriented C style

-

The Fype interpreter is written in an object-oriented style of C. Each "main component" has its own .h and .c file. There is a struct type for each (most components at least) component, which can be initialized using a "COMPONENT_new" function and destroyed using a "COMPONENT_delete" function. Method calls follow the same schema, e.g. "COMPONENT_METHODNAME". There is no such as class inheritance and polymorphism involved.

-

To give you an idea of how it works here as an example is a snippet from the main Fype "class header":

+
+Fype is an interpreted programming language created by me for learning and fun. The interpreter is written in C. It has been tested on FreeBSD and NetBSD and may also work on other Unix like operating systems such as Linux based ones. Besides learning and fun, there is no other use case of why Fype exists as many other programming languages are much faster and more powerful.
+
+The Fype syntax is straightforward and uses a maximum look ahead of 1 and an effortless top-down parsing mechanism. Fype is parsing and interpreting its code simultaneously. This means that syntax errors are only detected during program runtime.
+
+Fype is a recursive acronym and means "Fype is For Your Program Execution" or "Fype is Free Yak Programmed for ELF". You could also say, "It's not a hype - it's Fype!".
+
+

Object-oriented C style


+
+The Fype interpreter is written in an object-oriented style of C. Each "main component" has its own .h and .c file. There is a struct type for each (most components at least) component, which can be initialized using a "COMPONENT_new" function and destroyed using a "COMPONENT_delete" function. Method calls follow the same schema, e.g. "COMPONENT_METHODNAME". There is no such as class inheritance and polymorphism involved.
+
+To give you an idea of how it works here as an example is a snippet from the main Fype "class header":
+
 typedef struct {
    Tupel *p_tupel_argv; // Contains command line options
@@ -32,7 +41,9 @@ typedef struct {
    char *c_basename;
 } Fype;
 
-

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

+
+And here is a snippet from the primary Fype "class implementation":
+
 Fype*
 fype_new() {
@@ -82,8 +93,10 @@ fype_run(int i_argc, char **pc_argv) {
    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:

+
+

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

There is no boolean type, but we can use the integer values 0 for false and 1 for true. There is support for explicit type casting too.

-

Syntax

-

Comments

-

Text from a # character until the end of the current line is considered being a comment. Multi-line comments may start with an #* and with a *# anywhere. Exceptions are if those signs are inside of strings.

-

Variables

-

Variables are defined with the "my" keyword (inspired by Perl :-). If you don't assign a value during declaration, it uses the default integer value 0. Variables may be changed during program runtime. Variables may be deleted using the "undef" keyword! Example:

+
+There is no boolean type, but we can use the integer values 0 for false and 1 for true. There is support for explicit type casting too.
+
+

Syntax


+
+

Comments


+
+Text from a # character until the end of the current line is considered being a comment. Multi-line comments may start with an #* and with a *# anywhere. Exceptions are if those signs are inside of strings.
+
+

Variables


+
+Variables are defined with the "my" keyword (inspired by Perl :-). If you don't assign a value during declaration, it uses the default integer value 0. Variables may be changed during program runtime. Variables may be deleted using the "undef" keyword! Example:
+
 my foo = 1 + 2;
 say foo; 
@@ -110,7 +129,9 @@ 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:

+
+You may use the "defined" keyword to check if an identifier has been defined or not:
+
 ifnot defined foo {
 	say "No foo yet defined";
@@ -123,8 +144,11 @@ if defined foo {
 	say foo;
 }
 
-

Synonyms

-

Each variable can have as many synonyms as wished. A synonym is another name to access the content of a specific variable. Here is an example of how to use it:

+
+

Synonyms


+
+Each variable can have as many synonyms as wished. A synonym is another name to access the content of a specific variable. Here is an example of how to use it:
+
 my foo = "foo";
 my bar = \foo;
@@ -133,7 +157,9 @@ foo = "bar";
 # The synonym variable should now also set to "bar"
 assert "bar" == bar;
 
-

Synonyms can be used for all kind of identifiers. It's not limited to standard variables but can also be used for function and procedure names (more about functions and procedures later).

+
+Synonyms can be used for all kind of identifiers. It's not limited to standard variables but can also be used for function and procedure names (more about functions and procedures later).
+
 # Create a new procedure baz
 proc baz { say "I am baz"; }
@@ -146,7 +172,9 @@ 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:

+
+The "syms" keyword gives you the total number of synonyms pointing to a specific value:
+
 my foo = 1;
 say syms foo; # Prints 1
@@ -158,17 +186,25 @@ 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:

+
+

Statements and expressions


+
+A Fype program is a list of statements. Each keyword, expression or function call is part of a statement. Each statement is ended with a semicolon. Example:
+
 my bar = 3, foo = 1 + 2; 
 say foo;
 exit foo - bar;
 
-

Parenthesis

-

All parenthesis for function arguments is optional. They help to make the code better readable. They also help to force the precedence of expressions.

-

Basic expressions

-

Any "any" value holding a string will be automatically converted to an integer value.

+
+

Parenthesis


+
+All parenthesis for function arguments is optional. They help to make the code better readable. They also help to force the precedence of expressions.
+
+

Basic expressions


+
+Any "any" value holding a string will be automatically converted to an integer value.
+
 (any) <any> + <any>
 (any) <any> - <any>
@@ -182,7 +218,9 @@ exit foo - bar;
 (integer) <any> gt <any>
 (integer) not <any>
 
-

Bitwise expressions

+
+

Bitwise expressions


+
 (integer) <any> :< <any>
 (integer) <any> :> <any>
@@ -190,43 +228,64 @@ exit foo - bar;
 (integer) <any> or <any>
 (integer) <any> xor <any>
 
-

Numeric expressions

+
+

Numeric expressions


+
 (number) neg <number>
 
-

... returns the negative value of "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!

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

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

+
+

Control statements


+
+Control statements available in Fype:
+
 if <expression> { <statements> }
 
-

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

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

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

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

+
+... 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;
 
@@ -253,7 +312,9 @@ my foo = 1;
 # Prints out 0
 say defined bar;
 
-

Another example including an actual output:

+
+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:
@@ -271,29 +332,43 @@ SYM_FUNCTION: baz
 SYM_VARIABLE: var4 (id=00035, line=-0001, pos=-001, type=TT_INTEGER, dval=0.000000, refs=-1)
 SYM_FUNCTION: bar
 
-

Definedness

+
+

Definedness


+
 (integer) defined <identifier>
 
-

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

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

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

+
+... exits the program with the exit status of 0.
+
 (void) exit <integer>
 
-

... exits the program with the specified exit status.

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

+
+... forks a subprocess. It returns 0 for the child process and the PID of the child process otherwise! Example:
+
 my pid = fork;
 
@@ -305,27 +380,41 @@ if pid {
 	say "I am the child process";
 }
 
-

To execute the garbage collector do:

+
+To execute the garbage collector do:
+
 (integer) GC
 
-

It returns the number of items freed! You may wonder why most of the time, it will produce a value of 0! Fype tries to free not needed memory ASAP. This may change in future versions to gain faster execution speed!

-

I/O

+
+It returns the number of items freed! You may wonder why most of the time, it will produce a value of 0! Fype tries to free not needed memory ASAP. This may change in future versions to gain faster execution speed!
+
+

I/O


+
 (any) put <any>
 
-

... prints out the argument

+
+... prints out the argument
+
 (any) say <any>
 
-

is the same as put, but also includes an ending newline.

+
+is the same as put, but also includes an ending newline.
+
 (void) ln
 
-

... just prints a new line.

-

Procedures and functions

-

Procedures

-

A procedure can be defined with the "proc" keyword and deleted with the "undef" keyword. A procedure does not return any value and does not support parameter passing. It's using already defined variables (e.g. global variables). A procedure does not have its own namespace. It's using the calling namespace. It is possible to define new variables inside of a procedure in the current namespace.

+
+... just prints a new line.
+
+

Procedures and functions


+
+

Procedures


+
+A procedure can be defined with the "proc" keyword and deleted with the "undef" keyword. A procedure does not return any value and does not support parameter passing. It's using already defined variables (e.g. global variables). A procedure does not have its own namespace. It's using the calling namespace. It is possible to define new variables inside of a procedure in the current namespace.
+
 proc foo {
 	say 1 + a * 3 + b;
@@ -337,8 +426,11 @@ my a = 2, b = 4;
 foo; # Run the procedure. Print out "11\n"
 say c; # Print out "6\n";
 
-

Nested procedures

-

It's possible to define procedures inside of procedures. Since procedures don't have their own scope, nested procedures will be available to the current scope as soon as the main procedure has run the first time. You may use the "defined" keyword to check if a procedure has been defined or not.

+
+

Nested procedures


+
+It's possible to define procedures inside of procedures. Since procedures don't have their own scope, nested procedures will be available to the current scope as soon as the main procedure has run the first time. You may use the "defined" keyword to check if a procedure has been defined or not.
+
 proc foo {
 	say "I am foo";
@@ -357,8 +449,11 @@ 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).

+
+

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;
@@ -370,8 +465,11 @@ my a = 2, b = 4;
 foo; # Run the procedure. Print out "11\n"
 say c; # Will produce an error because c is out of scope!
 
-

Nested functions

-

Nested functions work the same way the nested procedures work, except that nested functions will not be available anymore after the function has been left!

+
+

Nested functions


+
+Nested functions work the same way the nested procedures work, except that nested functions will not be available anymore after the function has been left!
+
 func foo {
 	func bar {
@@ -384,14 +482,19 @@ 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 multidimensional array "foo". Its first element is the return value of the func which is "bar". The fourth value is a string" 3" converted to a double number. The last element is an anonymous array which itself contains another anonymous array as its final element:

+
+

Arrays


+
+Some progress on arrays has been made too. The following example creates a multidimensional array "foo". Its first element is the return value of the func which is "bar". The fourth value is a string" 3" converted to a double number. The last element is an anonymous array which itself contains another anonymous array as its final element:
+
 func bar { say ”bar” }
 my foo = [bar, 1, 4/2, double ”3”, [”A”, [”BA”, ”BB”]]];
 say foo;
 
-

It produces the following output:

+
+It produces the following output:
+
 % ./fype arrays.fy
 bar
@@ -402,13 +505,20 @@ A
 BA
 BB
 
-

Fancy stuff

-

Fancy stuff like OOP or Unicode or threading is not planed. But fancy stuff like function pointers and closures may be considered.:)

-

May the source be with you

-

You can find all of this on the GitHub page. There is also an "examples" folders containing some Fype scripts!

-https://codeberg.org/snonux/fype
-

E-Mail your comments to hi@paul.cyou :-)

-Back to the main site
+
+

Fancy stuff


+
+Fancy stuff like OOP or Unicode or threading is not planed. But fancy stuff like function pointers and closures may be considered.:)
+
+

May the source be with you


+
+You can find all of this on the GitHub page. There is also an "examples" folders containing some Fype scripts!
+
+https://codeberg.org/snonux/fype
+
+E-Mail your comments to hi@paul.cyou :-)
+
+Back to the main site

Perl Daemon (Service Framework)

-

Published at 2011-05-07T22:26:02+01:00; Updated at 2021-05-07

+

Perl Daemon (Service Framework)


+
+Published at 2011-05-07T22:26:02+01:00; Updated at 2021-05-07
+
    a'!   _,,_ a'!   _,,_     a'!   _,,_
      \\_/    \  \\_/    \      \\_/    \.-,
       \, /-( /'-,\, /-( /'-,    \, /-( /
       //\ //\\   //\ //\\       //\ //\\jrei
 
-

PerlDaemon is a minimal daemon for Linux and other Unix like operating systems programmed in Perl. It is a minimal but pretty functional and fairly generic service framework. This means that it does not do anything useful other than providing a framework for starting, stopping, configuring and logging. To do something useful, a module (written in Perl) must be provided.

-

Features

-

PerlDaemon supports:

+
+PerlDaemon is a minimal daemon for Linux and other Unix like operating systems programmed in Perl. It is a minimal but pretty functional and fairly generic service framework. This means that it does not do anything useful other than providing a framework for starting, stopping, configuring and logging. To do something useful, a module (written in Perl) must be provided.
+
+

Features


+
+PerlDaemon supports:
+
-

Quick Guide

+
+

Quick Guide


+
 # Starting
  ./bin/perldaemon start (or shortcut ./control start)
@@ -40,9 +47,13 @@
 # Alternatively: Starting in foreground 
 ./bin/perldaemon start daemon.daemonize=no (or shortcut ./control foreground)
 
-

To stop a daemon from running in foreground mode, "Ctrl+C" must be hit. To see more available startup options run "./control" without any argument.

-

How to configure

-

The daemon instance can be configured in "./conf/perldaemon.conf". If you want to change a property only once, it is also possible to specify it on the command line (which will take precedence over the config file). All available config properties can be displayed via "./control keys":

+
+To stop a daemon from running in foreground mode, "Ctrl+C" must be hit. To see more available startup options run "./control" without any argument.
+
+

How to configure


+
+The daemon instance can be configured in "./conf/perldaemon.conf". If you want to change a property only once, it is also possible to specify it on the command line (which will take precedence over the config file). All available config properties can be displayed via "./control keys":
+
 pb@titania:~/svn/utils/perldaemon/trunk$ ./control keys
 # Path to the logfile
@@ -69,8 +80,11 @@ daemon.alivefile=./run/perldaemon.alive
 # Specifies the working directory
 daemon.wd=./
 
-

Example

-

So let's start the daemon with a loop interval of 10 seconds:

+
+

Example


+
+So let's start the daemon with a loop interval of 10 seconds:
+
 $ ./control keys | grep daemon.loopinterval
 daemon.loopinterval=1
@@ -84,15 +98,23 @@ Mon Jun 13 11:29:27 2011 (PID 2838): ExampleModule Test 2
 $ ./control stop
 Stopping daemon now...
 
-

If you want to change that property forever, either edit perldaemon.conf or do this:

+
+If you want to change that property forever, either edit perldaemon.conf or do this:
+
 $ ./control keys daemon.loopinterval=10 > new.conf; mv new.conf conf/perldaemon.conf
 
-

HiRes event loop

-

PerlDaemon uses Time::HiRes to make sure that all the events run incorrect intervals. For each loop run, a time carry value is recorded and added to the next loop run to catch up on lost time.

-

Writing your own modules

-

Example module

-

This is one of the example modules you will find in the source code. It should be pretty self-explanatory if you know Perl :-).

+
+

HiRes event loop


+
+PerlDaemon uses Time::HiRes to make sure that all the events run incorrect intervals. For each loop run, a time carry value is recorded and added to the next loop run to catch up on lost time.
+
+

Writing your own modules


+
+

Example module


+
+This is one of the example modules you will find in the source code. It should be pretty self-explanatory if you know Perl :-).
+
 package PerlDaemonModules::ExampleModule;
 
@@ -124,8 +146,11 @@ sub do ($) {
 
 1;
 
-

Your own module

-

Want to give it some better use? It's just as easy as:

+
+

Your own module


+
+Want to give it some better use? It's just as easy as:
+
  cd ./lib/PerlDaemonModules/
  cp ExampleModule.pm YourModule.pm
@@ -133,17 +158,26 @@ sub do ($) {
  cd -
  ./bin/perldaemon restart (or shortcurt ./control restart)
 
-

Now watch ./log/perldaemon.log closely. It is a good practice to test your modules in 'foreground mode' (see above how to do that).

-

BTW: You can install as many modules within the same instance as desired. But they are run in sequential order (in future, they can also run in parallel using several threads or processes).

-

May the source be with you

-

You can find PerlDaemon (including the examples) at:

-https://codeberg.org/snonux/perldaemon
-

Other related posts are:

-2022-05-27 Perl is still a great choice
-2011-05-07 Perl Daemon (Service Framework) (You are currently reading this)
-2008-06-26 Perl Poetry
-

E-Mail your comments to hi@paul.cyou :-)

-Back to the main site
+
+Now watch ./log/perldaemon.log closely. It is a good practice to test your modules in 'foreground mode' (see above how to do that).
+
+BTW: You can install as many modules within the same instance as desired. But they are run in sequential order (in future, they can also run in parallel using several threads or processes).
+
+

May the source be with you


+
+You can find PerlDaemon (including the examples) at:
+
+https://codeberg.org/snonux/perldaemon
+
+Other related posts are:
+
+2022-05-27 Perl is still a great choice
+2011-05-07 Perl Daemon (Service Framework) (You are currently reading this)
+2008-06-26 Perl Poetry
+
+E-Mail your comments to hi@paul.cyou :-)
+
+Back to the main site

The fibonacci.pl.raku.c Polyglot

-

Published at 2014-03-24T21:32:53+00:00; Updated at 2022-04-23

-

In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it.

-https://en.wikipedia.org/wiki/Polyglot_(computing)
-

The Fibonacci numbers

-

For fun, I programmed my own Polyglot, which is both valid Perl, Raku, C and C++ code (I have added C++ and Raku support in 2022). The exciting part about C and C++ is that $ is a valid character to start variable names with:

+

The fibonacci.pl.raku.c Polyglot


+
+Published at 2014-03-24T21:32:53+00:00; Updated at 2022-04-23
+
+In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it.
+
+https://en.wikipedia.org/wiki/Polyglot_(computing)
+
+

The Fibonacci numbers


+
+For fun, I programmed my own Polyglot, which is both valid Perl, Raku, C and C++ code (I have added C++ and Raku support in 2022). The exciting part about C and C++ is that $ is a valid character to start variable names with:
+
 #include <stdio.h>
 
@@ -57,9 +63,13 @@ BEGIN {
     }
 }
 
-

You can find the full source code at GitHub:

-https://codeberg.org/snonux/perl-c-fibonacci
-

Let's run it with C and C++

+
+You can find the full source code at GitHub:
+
+https://codeberg.org/snonux/perl-c-fibonacci
+
+

Let's run it with C and C++


+
 % gcc fibonacci.pl.raku.c -o fibonacci
 % ./fibonacci
@@ -97,7 +107,9 @@ fib(8) = 21
 fib(9) = 34
 fib(10) = 55
 
-

Let's run it with Perl and Raku

+
+

Let's run it with Perl and Raku


+
 % perl fibonacci.pl.raku.c
 Hello, welcome to the Fibonacci Numbers!
@@ -133,9 +145,12 @@ fib(8) = 21
 fib(9) = 34
 fib(10) = 55
 
-

It's entertaining to play with :-).

-

E-Mail your comments to hi@paul.cyou :-)

-Back to the main site
+
+It's entertaining to play with :-).
+
+E-Mail your comments to hi@paul.cyou :-)
+
+Back to the main site

Run Debian on your phone with Debroid

-

Published at 2015-12-05T16:12:57+00:00; Updated at 2021-05-16

+

Run Debian on your phone with Debroid


+
+Published at 2015-12-05T16:12:57+00:00; Updated at 2021-05-16
+
  ____       _               _     _ 
 |  _ \  ___| |__  _ __ ___ (_) __| |
@@ -18,15 +20,25 @@
 |____/ \___|_.__/|_|  \___/|_|\__,_|
                                     
 
-

You can use the following tutorial to install a full-blown Debian GNU/Linux Chroot on an LG G3 D855 CyanogenMod 13 (Android 6). First of all, you need to have root permissions on your phone, and you also need to have the developer mode activated. The following steps have been tested on Linux (Fedora 23).

-
-

Foreword

-

A couple of years have passed since I last worked on Debroid. Currently, I am using the Termux app on Android, which is less sophisticated than a fully blown Debian installation but sufficient for my current requirements. The content of this site may be still relevant, and it would also work with more recent versions of Debian and Android. I would expect that some minor modifications need to be made, though.

-

Step by step guide

-

All scripts mentioned here can be found on GitHub at:

-https://codeberg.org/snonux/debroid
-

First debootstrap stage

-

This is to be performed on a Fedora Linux machine (could work on a Debian too, but Fedora is just what I use on my Laptop). The following steps prepare an initial Debian base image, which can then be transferred to the phone.

+
+You can use the following tutorial to install a full-blown Debian GNU/Linux Chroot on an LG G3 D855 CyanogenMod 13 (Android 6). First of all, you need to have root permissions on your phone, and you also need to have the developer mode activated. The following steps have been tested on Linux (Fedora 23).
+
+
+
+

Foreword


+
+A couple of years have passed since I last worked on Debroid. Currently, I am using the Termux app on Android, which is less sophisticated than a fully blown Debian installation but sufficient for my current requirements. The content of this site may be still relevant, and it would also work with more recent versions of Debian and Android. I would expect that some minor modifications need to be made, though.
+
+

Step by step guide


+
+All scripts mentioned here can be found on GitHub at:
+
+https://codeberg.org/snonux/debroid
+
+

First debootstrap stage


+
+This is to be performed on a Fedora Linux machine (could work on a Debian too, but Fedora is just what I use on my Laptop). The following steps prepare an initial Debian base image, which can then be transferred to the phone.
+
 sudo dnf install debootstrap
 # 5g
@@ -47,8 +59,11 @@ sudo debootstrap --foreign --variant=minbase \
   http://http.debian.net/debian
 sudo umount jessie
 
-

Copy Debian image to the phone

-

Now setup the Debian image on an external SD card on the Phone via Android Debugger as follows:

+
+

Copy Debian image to the phone


+
+Now setup the Debian image on an external SD card on the Phone via Android Debugger as follows:
+
 adb root && adb wait-for-device && adb shell
 mkdir -p /storage/sdcard1/Linux/jessie
@@ -87,8 +102,11 @@ busybox mount --bind /storage/sdcard1 \
 # Check mounts
 mount | grep jessie
 
-

Second debootstrap stage

-

This is to be performed on the Android phone itself (inside a Debian chroot):

+
+

Second debootstrap stage


+
+This is to be performed on the Android phone itself (inside a Debian chroot):
+
 chroot $(pwd)/jessie /bin/bash -l
 export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
@@ -96,8 +114,11 @@ export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
 exit # Leave chroot
 exit # Leave adb shell
 
-

Setup of various scripts

-

jessie.sh deals with all the loopback mount magic and so on. It will be run later every time you start Debroid on your phone.

+
+

Setup of various scripts


+
+jessie.sh deals with all the loopback mount magic and so on. It will be run later every time you start Debroid on your phone.
+
 #