From 2fa917c369447694dc76308560d0c5f65673ec59 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 18 May 2021 21:35:38 +0100 Subject: add polyglot post change html quotes --- .../2014-03-24-the-fibonacci.pl.c-polyglot.gmi | 110 ++++++++++++++++ ...-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi | 2 + content/gemtext/gemfeed/atom.xml | 111 +++++++++++++++- content/gemtext/gemfeed/index.gmi | 1 + content/gemtext/index.gmi | 1 + content/html/contact-information.html | 4 - content/html/gemfeed/2008-06-26-perl-poetry.html | 4 - .../2010-04-09-standard-ml-and-haskell.html | 4 - .../2010-05-09-the-fype-programming-language.html | 4 - .../2011-05-07-perl-daemon-service-framework.html | 4 - .../2014-03-24-the-fibonacci.pl.c-polyglot.html | 146 +++++++++++++++++++++ ...2-05-run-debian-on-your-phone-with-debroid.html | 4 - .../2016-04-03-offsite-backup-with-zfs.html | 4 - ...04-09-jails-and-zfs-on-freebsd-with-puppet.html | 5 +- .../2016-04-16-offsite-backup-with-zfs-part2.html | 4 - ...inning-up-my-own-authoritative-dns-servers.html | 4 - content/html/gemfeed/2016-11-20-methods-in-c.html | 4 - ...alistic-load-testing-with-ioriot-for-linux.html | 4 - ...-22-dtail-the-distributed-log-tail-program.html | 4 - .../2021-04-24-welcome-to-the-geminispace.html | 4 - ...rg.sh-one-bash-script-to-rule-it-all.draft.html | 4 - ...021-05-16-personal-bash-coding-style-guide.html | 4 - content/html/gemfeed/atom.xml | 111 +++++++++++++++- content/html/gemfeed/index.html | 5 +- content/html/index.html | 5 +- content/html/resources.html | 4 - .../2014-03-24-the-fibonacci.pl.c-polyglot.md | 110 ++++++++++++++++ ...6-04-09-jails-and-zfs-on-freebsd-with-puppet.md | 2 + content/md/gemfeed/index.md | 1 + content/md/index.md | 1 + .../2014-03-24-the-fibonacci.pl.c-polyglot.meta | 5 + header.html.part | 4 - 32 files changed, 602 insertions(+), 82 deletions(-) create mode 100644 content/gemtext/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.gmi create mode 100644 content/html/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html create mode 100644 content/md/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md create mode 100644 content/meta/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.meta diff --git a/content/gemtext/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.gmi b/content/gemtext/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.gmi new file mode 100644 index 00000000..06a463c6 --- /dev/null +++ b/content/gemtext/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.gmi @@ -0,0 +1,110 @@ +# The fibonacci.pl.c Polyglot + +> Written by Paul Buetow 2014-03-24 + +In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it + +=> https://en.wikipedia.org/wiki/Polyglot_(computing) + +## The Fibonacci numbers + +For fun, I programmed my own Polyglot, which is both, valid Perl and C code. The interesting part about C is, that $ is a valid character to start variable names with: + +``` +#include + +#define $arg function_argument +#define my int +#define sub int +#define BEGIN int main(void) + +my $arg; + +sub hello() { + printf("Hello, welcome to Perl-C!\n"); + printf("This program is both, valid C and Perl code!\n"); + printf("It calculates all fibonacci numbers from 0 to 9!\n\n"); + return 0; +} + +sub fibonacci() { + my $n = $arg; + + if ($n < 2) { + return $n; + } + + $arg = $n - 1; + my $fib1 = fibonacci(); + $arg = $n - 2; + my $fib2 = fibonacci(); + + return $fib1 + $fib2; +} + +BEGIN { + hello(); + my $i = 0; + + for ($i = 0; $i <= 10; ++$i) { + $arg = $i; + printf("fib(%d) = %d\n", $i, fibonacci()); + } + + return 0; +} +``` + +You can find the whole source code at GitHub: + +=> https://github.com/snonux/perl-c-fibonacci + +### Let's run it with Perl: + +``` +❯ perl fibonacci.pl.c +Hello, welcome to Perl-C! +This program is both, valid C and Perl code! +It calculates all fibonacci numbers from 0 to 9! + +fib(0) = 0 +fib(1) = 1 +fib(2) = 1 +fib(3) = 2 +fib(4) = 3 +fib(5) = 5 +fib(6) = 8 +fib(7) = 13 +fib(8) = 21 +fib(9) = 34 +fib(10) = 55 +``` + + +### Let's compile it as C and run the binary: + +``` +❯ gcc fibonacci.pl.c -o fibonacci +❯ ./fibonacci +Hello, welcome to Perl-C! +This program is both, valid C and Perl code! +It calculates all fibonacci numbers from 0 to 9! + +fib(0) = 0 +fib(1) = 1 +fib(2) = 1 +fib(3) = 2 +fib(4) = 3 +fib(5) = 5 +fib(6) = 8 +fib(7) = 13 +fib(8) = 21 +fib(9) = 34 +fib(10) = 55 +``` + +It's really fun to play with :-). + +E-Mail me your thoughts at comments@mx.buetow.org! + +=> ../ Go back to the main site diff --git a/content/gemtext/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi b/content/gemtext/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi index 16396b00..8ef18d8f 100644 --- a/content/gemtext/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi +++ b/content/gemtext/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi @@ -24,6 +24,8 @@ Over the last couple of years I wrote quite a few Puppet modules in order to manage my personal server infrastructure. One of them manages FreeBSD Jails and another one ZFS file systems. I thought I would give a brief overview in how it looks and feels. +=> https://github.com/snonux/puppet-modules + ## ZFS The ZFS module is a pretty basic one. It does not manage ZFS pools yet as I am not creating them often enough which would justify implementing an automation. But let's see how we can create a ZFS file system (on an already given ZFS pool named ztank): diff --git a/content/gemtext/gemfeed/atom.xml b/content/gemtext/gemfeed/atom.xml index acc1a984..bc95ba61 100644 --- a/content/gemtext/gemfeed/atom.xml +++ b/content/gemtext/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-17T21:01:05+01:00 + 2021-05-18T21:32:49+01:00 buetow.org feed Having fun with computers! @@ -976,6 +976,7 @@ apply Service "dig6" {

Written by Paul Buetow 2016-04-09

Over the last couple of years I wrote quite a few Puppet modules in order to manage my personal server infrastructure. One of them manages FreeBSD Jails and another one ZFS file systems. I thought I would give a brief overview in how it looks and feels.

+https://github.com/snonux/puppet-modules

ZFS

The ZFS module is a pretty basic one. It does not manage ZFS pools yet as I am not creating them often enough which would justify implementing an automation. But let's see how we can create a ZFS file system (on an already given ZFS pool named ztank):

Puppet snippet:

@@ -1522,6 +1523,114 @@ chmod +x /data/local/userinit.sh exit

Reboot & test! Enjoy!

+

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

+ + + + + The fibonacci.pl.c Polyglot + + gemini://buetow.org/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.gmi + 2014-03-24T21:32:53+00:00 + + Paul Buetow + comments@mx.buetow.org + + 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. .....to read on please visit my site. + +
+

The fibonacci.pl.c Polyglot

+

Written by Paul Buetow 2014-03-24

+

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

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

The Fibonacci numbers

+

For fun, I programmed my own Polyglot, which is both, valid Perl and C code. The interesting part about C is, that $ is a valid character to start variable names with:

+
+#include <stdio.h>
+
+#define $arg function_argument
+#define my int
+#define sub int
+#define BEGIN int main(void)
+
+my $arg;
+
+sub hello() {
+	printf("Hello, welcome to Perl-C!\n");
+	printf("This program is both, valid C and Perl code!\n");
+	printf("It calculates all fibonacci numbers from 0 to 9!\n\n");
+	return 0;
+}
+
+sub fibonacci() {
+	my $n = $arg;
+
+	if ($n < 2) {
+		return $n;
+	}
+
+	$arg = $n - 1;
+	my $fib1 = fibonacci();
+	$arg = $n - 2;
+	my $fib2 = fibonacci();
+
+	return $fib1 + $fib2;
+}
+
+BEGIN {
+	hello();
+	my $i = 0;
+
+	for ($i = 0; $i <= 10; ++$i) {
+		$arg = $i;
+		printf("fib(%d) = %d\n", $i, fibonacci());
+	}
+
+	return 0;
+}
+
+

You can find the whole source code at GitHub:

+https://github.com/snonux/perl-c-fibonacci
+

Let's run it with Perl:

+
+❯ perl fibonacci.pl.c
+Hello, welcome to Perl-C!
+This program is both, valid C and Perl code!
+It calculates all fibonacci numbers from 0 to 9!
+
+fib(0) = 0
+fib(1) = 1
+fib(2) = 1
+fib(3) = 2
+fib(4) = 3
+fib(5) = 5
+fib(6) = 8
+fib(7) = 13
+fib(8) = 21
+fib(9) = 34
+fib(10) = 55
+
+

Let's compile it as C and run the binary:

+
+❯ gcc fibonacci.pl.c -o fibonacci
+❯ ./fibonacci
+Hello, welcome to Perl-C!
+This program is both, valid C and Perl code!
+It calculates all fibonacci numbers from 0 to 9!
+
+fib(0) = 0
+fib(1) = 1
+fib(2) = 1
+fib(3) = 2
+fib(4) = 3
+fib(5) = 5
+fib(6) = 8
+fib(7) = 13
+fib(8) = 21
+fib(9) = 34
+fib(10) = 55
+
+

It's really fun to play with :-).

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

diff --git a/content/gemtext/gemfeed/index.gmi b/content/gemtext/gemfeed/index.gmi index 6d4e2611..8880df3e 100644 --- a/content/gemtext/gemfeed/index.gmi +++ b/content/gemtext/gemfeed/index.gmi @@ -12,6 +12,7 @@ => ./2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi 2016-04-09 - Jails and ZFS with Puppet on FreeBSD => ./2016-04-03-offsite-backup-with-zfs.gmi 2016-04-03 - Offsite backup with ZFS => ./2015-12-05-run-debian-on-your-phone-with-debroid.gmi 2015-12-05 - Run Debian on your phone with Debroid +=> ./2014-03-24-the-fibonacci.pl.c-polyglot.gmi 2014-03-24 - The fibonacci.pl.c Polyglot => ./2011-05-07-perl-daemon-service-framework.gmi 2011-05-07 - Perl Daemon (Service Framework) => ./2010-05-09-the-fype-programming-language.gmi 2010-05-09 - The Fype Programming Language => ./2010-04-09-standard-ml-and-haskell.gmi 2010-04-09 - Standard ML and Haskell diff --git a/content/gemtext/index.gmi b/content/gemtext/index.gmi index 24a17257..165ebcb3 100644 --- a/content/gemtext/index.gmi +++ b/content/gemtext/index.gmi @@ -64,6 +64,7 @@ I have switched blog software multiple times. I might be back filling some of th => ./gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.gmi 2016-04-09 - Jails and ZFS with Puppet on FreeBSD => ./gemfeed/2016-04-03-offsite-backup-with-zfs.gmi 2016-04-03 - Offsite backup with ZFS => ./gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.gmi 2015-12-05 - Run Debian on your phone with Debroid +=> ./gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.gmi 2014-03-24 - The fibonacci.pl.c Polyglot => ./gemfeed/2011-05-07-perl-daemon-service-framework.gmi 2011-05-07 - Perl Daemon (Service Framework) => ./gemfeed/2010-05-09-the-fype-programming-language.gmi 2010-05-09 - The Fype Programming Language => ./gemfeed/2010-04-09-standard-ml-and-haskell.gmi 2010-04-09 - Standard ML and Haskell diff --git a/content/html/contact-information.html b/content/html/contact-information.html index f9eed219..aac9c9f9 100644 --- a/content/html/contact-information.html +++ b/content/html/contact-information.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2008-06-26-perl-poetry.html b/content/html/gemfeed/2008-06-26-perl-poetry.html index 28635ea6..ad306859 100644 --- a/content/html/gemfeed/2008-06-26-perl-poetry.html +++ b/content/html/gemfeed/2008-06-26-perl-poetry.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2010-04-09-standard-ml-and-haskell.html b/content/html/gemfeed/2010-04-09-standard-ml-and-haskell.html index a1494628..1c372f5b 100644 --- a/content/html/gemfeed/2010-04-09-standard-ml-and-haskell.html +++ b/content/html/gemfeed/2010-04-09-standard-ml-and-haskell.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; 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 3410adf7..5389cbcc 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 @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2011-05-07-perl-daemon-service-framework.html b/content/html/gemfeed/2011-05-07-perl-daemon-service-framework.html index 6f443172..ad8cc9db 100644 --- a/content/html/gemfeed/2011-05-07-perl-daemon-service-framework.html +++ b/content/html/gemfeed/2011-05-07-perl-daemon-service-framework.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html b/content/html/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html new file mode 100644 index 00000000..30ec5588 --- /dev/null +++ b/content/html/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html @@ -0,0 +1,146 @@ + + + + +The fibonacci.pl.c Polyglot + + + + +

The fibonacci.pl.c Polyglot

+

Written by Paul Buetow 2014-03-24

+

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

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

The Fibonacci numbers

+

For fun, I programmed my own Polyglot, which is both, valid Perl and C code. The interesting part about C is, that $ is a valid character to start variable names with:

+
+#include <stdio.h>
+
+#define $arg function_argument
+#define my int
+#define sub int
+#define BEGIN int main(void)
+
+my $arg;
+
+sub hello() {
+	printf("Hello, welcome to Perl-C!\n");
+	printf("This program is both, valid C and Perl code!\n");
+	printf("It calculates all fibonacci numbers from 0 to 9!\n\n");
+	return 0;
+}
+
+sub fibonacci() {
+	my $n = $arg;
+
+	if ($n < 2) {
+		return $n;
+	}
+
+	$arg = $n - 1;
+	my $fib1 = fibonacci();
+	$arg = $n - 2;
+	my $fib2 = fibonacci();
+
+	return $fib1 + $fib2;
+}
+
+BEGIN {
+	hello();
+	my $i = 0;
+
+	for ($i = 0; $i <= 10; ++$i) {
+		$arg = $i;
+		printf("fib(%d) = %d\n", $i, fibonacci());
+	}
+
+	return 0;
+}
+
+

You can find the whole source code at GitHub:

+https://github.com/snonux/perl-c-fibonacci
+

Let's run it with Perl:

+
+❯ perl fibonacci.pl.c
+Hello, welcome to Perl-C!
+This program is both, valid C and Perl code!
+It calculates all fibonacci numbers from 0 to 9!
+
+fib(0) = 0
+fib(1) = 1
+fib(2) = 1
+fib(3) = 2
+fib(4) = 3
+fib(5) = 5
+fib(6) = 8
+fib(7) = 13
+fib(8) = 21
+fib(9) = 34
+fib(10) = 55
+
+

Let's compile it as C and run the binary:

+
+❯ gcc fibonacci.pl.c -o fibonacci
+❯ ./fibonacci
+Hello, welcome to Perl-C!
+This program is both, valid C and Perl code!
+It calculates all fibonacci numbers from 0 to 9!
+
+fib(0) = 0
+fib(1) = 1
+fib(2) = 1
+fib(3) = 2
+fib(4) = 3
+fib(5) = 5
+fib(6) = 8
+fib(7) = 13
+fib(8) = 21
+fib(9) = 34
+fib(10) = 55
+
+

It's really fun to play with :-).

+

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

+Go back to the main site
+ + diff --git a/content/html/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.html b/content/html/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.html index d81b5443..5e4534a0 100644 --- a/content/html/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.html +++ b/content/html/gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2016-04-03-offsite-backup-with-zfs.html b/content/html/gemfeed/2016-04-03-offsite-backup-with-zfs.html index 4218fc62..c8a74fe4 100644 --- a/content/html/gemfeed/2016-04-03-offsite-backup-with-zfs.html +++ b/content/html/gemfeed/2016-04-03-offsite-backup-with-zfs.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.html b/content/html/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.html index d5001adb..2c1d9db9 100644 --- a/content/html/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.html +++ b/content/html/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; @@ -74,6 +70,7 @@ h2, h3 {

Written by Paul Buetow 2016-04-09

Over the last couple of years I wrote quite a few Puppet modules in order to manage my personal server infrastructure. One of them manages FreeBSD Jails and another one ZFS file systems. I thought I would give a brief overview in how it looks and feels.

+https://github.com/snonux/puppet-modules

ZFS

The ZFS module is a pretty basic one. It does not manage ZFS pools yet as I am not creating them often enough which would justify implementing an automation. But let's see how we can create a ZFS file system (on an already given ZFS pool named ztank):

Puppet snippet:

diff --git a/content/html/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.html b/content/html/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.html index cf8c2723..3ec4180e 100644 --- a/content/html/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.html +++ b/content/html/gemfeed/2016-04-16-offsite-backup-with-zfs-part2.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.html b/content/html/gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.html index 2edd0bf6..e177de6e 100644 --- a/content/html/gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.html +++ b/content/html/gemfeed/2016-05-22-spinning-up-my-own-authoritative-dns-servers.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2016-11-20-methods-in-c.html b/content/html/gemfeed/2016-11-20-methods-in-c.html index f3c04e8f..c96be0e6 100644 --- a/content/html/gemfeed/2016-11-20-methods-in-c.html +++ b/content/html/gemfeed/2016-11-20-methods-in-c.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.html b/content/html/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.html index 41543269..d8eafcdf 100644 --- a/content/html/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.html +++ b/content/html/gemfeed/2018-06-01-realistic-load-testing-with-ioriot-for-linux.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; 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 bcc73c73..538cc564 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 @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; 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 20478835..7ea1c5a1 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 @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2021-05-15-buetow.org.sh-one-bash-script-to-rule-it-all.draft.html b/content/html/gemfeed/2021-05-15-buetow.org.sh-one-bash-script-to-rule-it-all.draft.html index 21acf536..74fa8b5f 100644 --- a/content/html/gemfeed/2021-05-15-buetow.org.sh-one-bash-script-to-rule-it-all.draft.html +++ b/content/html/gemfeed/2021-05-15-buetow.org.sh-one-bash-script-to-rule-it-all.draft.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/2021-05-16-personal-bash-coding-style-guide.html b/content/html/gemfeed/2021-05-16-personal-bash-coding-style-guide.html index 88702c24..e4c57898 100644 --- a/content/html/gemfeed/2021-05-16-personal-bash-coding-style-guide.html +++ b/content/html/gemfeed/2021-05-16-personal-bash-coding-style-guide.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/html/gemfeed/atom.xml b/content/html/gemfeed/atom.xml index b87afe87..7f97acd0 100644 --- a/content/html/gemfeed/atom.xml +++ b/content/html/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2021-05-17T21:01:05+01:00 + 2021-05-18T21:32:49+01:00 buetow.org feed Having fun with computers! @@ -976,6 +976,7 @@ apply Service "dig6" {

Written by Paul Buetow 2016-04-09

Over the last couple of years I wrote quite a few Puppet modules in order to manage my personal server infrastructure. One of them manages FreeBSD Jails and another one ZFS file systems. I thought I would give a brief overview in how it looks and feels.

+https://github.com/snonux/puppet-modules

ZFS

The ZFS module is a pretty basic one. It does not manage ZFS pools yet as I am not creating them often enough which would justify implementing an automation. But let's see how we can create a ZFS file system (on an already given ZFS pool named ztank):

Puppet snippet:

@@ -1522,6 +1523,114 @@ chmod +x /data/local/userinit.sh exit

Reboot & test! Enjoy!

+

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

+ + +
+ + The fibonacci.pl.c Polyglot + + https://buetow.org/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html + 2014-03-24T21:32:53+00:00 + + Paul Buetow + comments@mx.buetow.org + + 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. .....to read on please visit my site. + +
+

The fibonacci.pl.c Polyglot

+

Written by Paul Buetow 2014-03-24

+

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

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

The Fibonacci numbers

+

For fun, I programmed my own Polyglot, which is both, valid Perl and C code. The interesting part about C is, that $ is a valid character to start variable names with:

+
+#include <stdio.h>
+
+#define $arg function_argument
+#define my int
+#define sub int
+#define BEGIN int main(void)
+
+my $arg;
+
+sub hello() {
+	printf("Hello, welcome to Perl-C!\n");
+	printf("This program is both, valid C and Perl code!\n");
+	printf("It calculates all fibonacci numbers from 0 to 9!\n\n");
+	return 0;
+}
+
+sub fibonacci() {
+	my $n = $arg;
+
+	if ($n < 2) {
+		return $n;
+	}
+
+	$arg = $n - 1;
+	my $fib1 = fibonacci();
+	$arg = $n - 2;
+	my $fib2 = fibonacci();
+
+	return $fib1 + $fib2;
+}
+
+BEGIN {
+	hello();
+	my $i = 0;
+
+	for ($i = 0; $i <= 10; ++$i) {
+		$arg = $i;
+		printf("fib(%d) = %d\n", $i, fibonacci());
+	}
+
+	return 0;
+}
+
+

You can find the whole source code at GitHub:

+https://github.com/snonux/perl-c-fibonacci
+

Let's run it with Perl:

+
+❯ perl fibonacci.pl.c
+Hello, welcome to Perl-C!
+This program is both, valid C and Perl code!
+It calculates all fibonacci numbers from 0 to 9!
+
+fib(0) = 0
+fib(1) = 1
+fib(2) = 1
+fib(3) = 2
+fib(4) = 3
+fib(5) = 5
+fib(6) = 8
+fib(7) = 13
+fib(8) = 21
+fib(9) = 34
+fib(10) = 55
+
+

Let's compile it as C and run the binary:

+
+❯ gcc fibonacci.pl.c -o fibonacci
+❯ ./fibonacci
+Hello, welcome to Perl-C!
+This program is both, valid C and Perl code!
+It calculates all fibonacci numbers from 0 to 9!
+
+fib(0) = 0
+fib(1) = 1
+fib(2) = 1
+fib(3) = 2
+fib(4) = 3
+fib(5) = 5
+fib(6) = 8
+fib(7) = 13
+fib(8) = 21
+fib(9) = 34
+fib(10) = 55
+
+

It's really fun to play with :-).

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

diff --git a/content/html/gemfeed/index.html b/content/html/gemfeed/index.html index c3c3028d..dd6200a4 100644 --- a/content/html/gemfeed/index.html +++ b/content/html/gemfeed/index.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; @@ -64,6 +60,7 @@ h2, h3 { 2016-04-09 - Jails and ZFS with Puppet on FreeBSD
2016-04-03 - Offsite backup with ZFS
2015-12-05 - Run Debian on your phone with Debroid
+2014-03-24 - The fibonacci.pl.c Polyglot
2011-05-07 - Perl Daemon (Service Framework)
2010-05-09 - The Fype Programming Language
2010-04-09 - Standard ML and Haskell
diff --git a/content/html/index.html b/content/html/index.html index 76713db1..317a2730 100644 --- a/content/html/index.html +++ b/content/html/index.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; @@ -101,6 +97,7 @@ h2, h3 { 2016-04-09 - Jails and ZFS with Puppet on FreeBSD
2016-04-03 - Offsite backup with ZFS
2015-12-05 - Run Debian on your phone with Debroid
+2014-03-24 - The fibonacci.pl.c Polyglot
2011-05-07 - Perl Daemon (Service Framework)
2010-05-09 - The Fype Programming Language
2010-04-09 - Standard ML and Haskell
diff --git a/content/html/resources.html b/content/html/resources.html index 45b20f6b..01890a10 100644 --- a/content/html/resources.html +++ b/content/html/resources.html @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; diff --git a/content/md/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md b/content/md/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md new file mode 100644 index 00000000..a422ef1e --- /dev/null +++ b/content/md/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md @@ -0,0 +1,110 @@ +# The fibonacci.pl.c Polyglot + +> Written by Paul Buetow 2014-03-24 + +In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it + +[https://en.wikipedia.org/wiki/Polyglot_(computing)](https://en.wikipedia.org/wiki/Polyglot_(computing)) + +## The Fibonacci numbers + +For fun, I programmed my own Polyglot, which is both, valid Perl and C code. The interesting part about C is, that $ is a valid character to start variable names with: + +``` +#include + +#define $arg function_argument +#define my int +#define sub int +#define BEGIN int main(void) + +my $arg; + +sub hello() { + printf("Hello, welcome to Perl-C!\n"); + printf("This program is both, valid C and Perl code!\n"); + printf("It calculates all fibonacci numbers from 0 to 9!\n\n"); + return 0; +} + +sub fibonacci() { + my $n = $arg; + + if ($n < 2) { + return $n; + } + + $arg = $n - 1; + my $fib1 = fibonacci(); + $arg = $n - 2; + my $fib2 = fibonacci(); + + return $fib1 + $fib2; +} + +BEGIN { + hello(); + my $i = 0; + + for ($i = 0; $i <= 10; ++$i) { + $arg = $i; + printf("fib(%d) = %d\n", $i, fibonacci()); + } + + return 0; +} +``` + +You can find the whole source code at GitHub: + +[https://github.com/snonux/perl-c-fibonacci](https://github.com/snonux/perl-c-fibonacci) + +### Let's run it with Perl: + +``` +❯ perl fibonacci.pl.c +Hello, welcome to Perl-C! +This program is both, valid C and Perl code! +It calculates all fibonacci numbers from 0 to 9! + +fib(0) = 0 +fib(1) = 1 +fib(2) = 1 +fib(3) = 2 +fib(4) = 3 +fib(5) = 5 +fib(6) = 8 +fib(7) = 13 +fib(8) = 21 +fib(9) = 34 +fib(10) = 55 +``` + + +### Let's compile it as C and run the binary: + +``` +❯ gcc fibonacci.pl.c -o fibonacci +❯ ./fibonacci +Hello, welcome to Perl-C! +This program is both, valid C and Perl code! +It calculates all fibonacci numbers from 0 to 9! + +fib(0) = 0 +fib(1) = 1 +fib(2) = 1 +fib(3) = 2 +fib(4) = 3 +fib(5) = 5 +fib(6) = 8 +fib(7) = 13 +fib(8) = 21 +fib(9) = 34 +fib(10) = 55 +``` + +It's really fun to play with :-). + +E-Mail me your thoughts at comments@mx.buetow.org! + +[Go back to the main site](../) diff --git a/content/md/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md b/content/md/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md index ad2fdaba..c6ef908a 100644 --- a/content/md/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md +++ b/content/md/gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md @@ -24,6 +24,8 @@ Over the last couple of years I wrote quite a few Puppet modules in order to manage my personal server infrastructure. One of them manages FreeBSD Jails and another one ZFS file systems. I thought I would give a brief overview in how it looks and feels. +[https://github.com/snonux/puppet-modules](https://github.com/snonux/puppet-modules) + ## ZFS The ZFS module is a pretty basic one. It does not manage ZFS pools yet as I am not creating them often enough which would justify implementing an automation. But let's see how we can create a ZFS file system (on an already given ZFS pool named ztank): diff --git a/content/md/gemfeed/index.md b/content/md/gemfeed/index.md index 624ef06d..b314429c 100644 --- a/content/md/gemfeed/index.md +++ b/content/md/gemfeed/index.md @@ -12,6 +12,7 @@ [2016-04-09 - Jails and ZFS with Puppet on FreeBSD](./2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md) [2016-04-03 - Offsite backup with ZFS](./2016-04-03-offsite-backup-with-zfs.md) [2015-12-05 - Run Debian on your phone with Debroid](./2015-12-05-run-debian-on-your-phone-with-debroid.md) +[2014-03-24 - The fibonacci.pl.c Polyglot](./2014-03-24-the-fibonacci.pl.c-polyglot.md) [2011-05-07 - Perl Daemon (Service Framework)](./2011-05-07-perl-daemon-service-framework.md) [2010-05-09 - The Fype Programming Language](./2010-05-09-the-fype-programming-language.md) [2010-04-09 - Standard ML and Haskell](./2010-04-09-standard-ml-and-haskell.md) diff --git a/content/md/index.md b/content/md/index.md index aa6f2589..e32b5472 100644 --- a/content/md/index.md +++ b/content/md/index.md @@ -64,6 +64,7 @@ I have switched blog software multiple times. I might be back filling some of th [2016-04-09 - Jails and ZFS with Puppet on FreeBSD](./gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.md) [2016-04-03 - Offsite backup with ZFS](./gemfeed/2016-04-03-offsite-backup-with-zfs.md) [2015-12-05 - Run Debian on your phone with Debroid](./gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.md) +[2014-03-24 - The fibonacci.pl.c Polyglot](./gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.md) [2011-05-07 - Perl Daemon (Service Framework)](./gemfeed/2011-05-07-perl-daemon-service-framework.md) [2010-05-09 - The Fype Programming Language](./gemfeed/2010-05-09-the-fype-programming-language.md) [2010-04-09 - Standard ML and Haskell](./gemfeed/2010-04-09-standard-ml-and-haskell.md) diff --git a/content/meta/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.meta b/content/meta/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.meta new file mode 100644 index 00000000..15531fdf --- /dev/null +++ b/content/meta/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.meta @@ -0,0 +1,5 @@ +local meta_date="2014-03-24T21:32:53+00:00" +local meta_author="Paul Buetow" +local meta_email="comments@mx.buetow.org" +local meta_title="The fibonacci.pl.c Polyglot" +local meta_summary="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. .....to read on please visit my site." diff --git a/header.html.part b/header.html.part index 45cf151a..b8b06e52 100644 --- a/header.html.part +++ b/header.html.part @@ -17,10 +17,6 @@ img { display:block; max-width: 80%; } -p.quote:before { - content: " | "; - padding-left: 2px; -} a.textlink:before { content: " ⇒ "; padding-left: 2px; -- cgit v1.2.3