diff options
| author | Paul Buetow <git@mx.buetow.org> | 2021-05-18 21:35:38 +0100 |
|---|---|---|
| committer | Paul Buetow <git@mx.buetow.org> | 2021-05-21 05:11:05 +0100 |
| commit | 2fa917c369447694dc76308560d0c5f65673ec59 (patch) | |
| tree | b099e3a77850c825f65367fd38015d9490d99a83 | |
| parent | d371050f2fb79b6d66a810e60ff9c0ed2381f2cc (diff) | |
add polyglot post
change html quotes
32 files changed, 602 insertions, 82 deletions
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 0000000..06a463c --- /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 <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/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 16396b0..8ef18d8 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 acc1a98..bc95ba6 100644 --- a/content/gemtext/gemfeed/atom.xml +++ b/content/gemtext/gemfeed/atom.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> - <updated>2021-05-17T21:01:05+01:00</updated> + <updated>2021-05-18T21:32:49+01:00</updated> <title>buetow.org feed</title> <subtitle>Having fun with computers!</subtitle> <link href="gemini://buetow.org/gemfeed/atom.xml" rel="self" /> @@ -976,6 +976,7 @@ apply Service "dig6" { </pre> <p class="quote"><i>Written by Paul Buetow 2016-04-09</i></p> <p>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.</p> +<a class="textlink" href="https://github.com/snonux/puppet-modules">https://github.com/snonux/puppet-modules</a><br /> <h2>ZFS</h2> <p>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):</p> <p>Puppet snippet:</p> @@ -1527,6 +1528,114 @@ exit </content> </entry> <entry> + <title>The fibonacci.pl.c Polyglot</title> + <link href="gemini://buetow.org/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.gmi" /> + <id>gemini://buetow.org/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.gmi</id> + <updated>2014-03-24T21:32:53+00:00</updated> + <author> + <name>Paul Buetow</name> + <email>comments@mx.buetow.org</email> + </author> + <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.</summary> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> + <h1>The fibonacci.pl.c Polyglot</h1> +<p class="quote"><i>Written by Paul Buetow 2014-03-24</i></p> +<p>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</p> +<a class="textlink" href="https://en.wikipedia.org/wiki/Polyglot_(computing)">https://en.wikipedia.org/wiki/Polyglot_(computing)</a><br /> +<h2>The Fibonacci numbers</h2> +<p>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:</p> +<pre> +#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; +} +</pre> +<p>You can find the whole source code at GitHub:</p> +<a class="textlink" href="https://github.com/snonux/perl-c-fibonacci">https://github.com/snonux/perl-c-fibonacci</a><br /> +<h3>Let's run it with Perl:</h3> +<pre> +❯ 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 +</pre> +<h3>Let's compile it as C and run the binary:</h3> +<pre> +❯ 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 +</pre> +<p>It's really fun to play with :-).</p> +<p>E-Mail me your thoughts at comments@mx.buetow.org!</p> + </div> + </content> + </entry> + <entry> <title>Perl Daemon (Service Framework)</title> <link href="gemini://buetow.org/gemfeed/2011-05-07-perl-daemon-service-framework.gmi" /> <id>gemini://buetow.org/gemfeed/2011-05-07-perl-daemon-service-framework.gmi</id> diff --git a/content/gemtext/gemfeed/index.gmi b/content/gemtext/gemfeed/index.gmi index 6d4e261..8880df3 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 24a1725..165ebcb 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 f9eed21..aac9c9f 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 28635ea..ad30685 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 a149462..1c372f5 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 3410adf..5389cbc 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 6f44317..ad8cc9d 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 0000000..30ec558 --- /dev/null +++ b/content/html/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html @@ -0,0 +1,146 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<title>The fibonacci.pl.c Polyglot</title> +<link rel="shortcut icon" type="image/gif" href="/favicon.ico" /> +<style type="text/css"> +body { + margin: auto; + max-width: 900px; + background-color: #FFFFEF; + border: 1px dashed #880000; + border-radius: 8px; + padding: 5px; +} +img { + display:block; + max-width: 80%; +} +a.textlink:before { + content: " ⇒ "; + padding-left: 2px; +} +a.textlink { + text-decoration: none; + color: #FF0000; +} +a.textlink:hover { + text-decoration: underline; +} +i { + color: #FFA500; +} +pre { + background-color: #F1F8E9; + border: 1px dashed #BB0000; + border-radius: 8px; + padding: 5px; + font-family: "Lucida Console", "Courier New", monospace; +} +h1 { + text-align: center; + color: #880000; +} +h2, h3 { + color: #BB0000; +} +</style> +</head> +<body> +<h1>The fibonacci.pl.c Polyglot</h1> +<p class="quote"><i>Written by Paul Buetow 2014-03-24</i></p> +<p>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</p> +<a class="textlink" href="https://en.wikipedia.org/wiki/Polyglot_(computing)">https://en.wikipedia.org/wiki/Polyglot_(computing)</a><br /> +<h2>The Fibonacci numbers</h2> +<p>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:</p> +<pre> +#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; +} +</pre> +<p>You can find the whole source code at GitHub:</p> +<a class="textlink" href="https://github.com/snonux/perl-c-fibonacci">https://github.com/snonux/perl-c-fibonacci</a><br /> +<h3>Let's run it with Perl:</h3> +<pre> +❯ 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 +</pre> +<h3>Let's compile it as C and run the binary:</h3> +<pre> +❯ 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 +</pre> +<p>It's really fun to play with :-).</p> +<p>E-Mail me your thoughts at comments@mx.buetow.org!</p> +<a class="textlink" href="../">Go back to the main site</a><br /> +</body> +</html> 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 d81b544..5e4534a 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 4218fc6..c8a74fe 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 d5001ad..2c1d9db 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 { </pre> <p class="quote"><i>Written by Paul Buetow 2016-04-09</i></p> <p>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.</p> +<a class="textlink" href="https://github.com/snonux/puppet-modules">https://github.com/snonux/puppet-modules</a><br /> <h2>ZFS</h2> <p>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):</p> <p>Puppet snippet:</p> 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 cf8c272..3ec4180 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 2edd0bf..e177de6 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 f3c04e8..c96be0e 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 4154326..d8eafcd 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 bcc73c7..538cc56 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 2047883..7ea1c5a 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 21acf53..74fa8b5 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 88702c2..e4c5789 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 b87afe8..7f97acd 100644 --- a/content/html/gemfeed/atom.xml +++ b/content/html/gemfeed/atom.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> - <updated>2021-05-17T21:01:05+01:00</updated> + <updated>2021-05-18T21:32:49+01:00</updated> <title>buetow.org feed</title> <subtitle>Having fun with computers!</subtitle> <link href="https://buetow.org/gemfeed/atom.xml" rel="self" /> @@ -976,6 +976,7 @@ apply Service "dig6" { </pre> <p class="quote"><i>Written by Paul Buetow 2016-04-09</i></p> <p>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.</p> +<a class="textlink" href="https://github.com/snonux/puppet-modules">https://github.com/snonux/puppet-modules</a><br /> <h2>ZFS</h2> <p>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):</p> <p>Puppet snippet:</p> @@ -1527,6 +1528,114 @@ exit </content> </entry> <entry> + <title>The fibonacci.pl.c Polyglot</title> + <link href="https://buetow.org/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html" /> + <id>https://buetow.org/gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html</id> + <updated>2014-03-24T21:32:53+00:00</updated> + <author> + <name>Paul Buetow</name> + <email>comments@mx.buetow.org</email> + </author> + <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.</summary> + <content type="xhtml"> + <div xmlns="http://www.w3.org/1999/xhtml"> + <h1>The fibonacci.pl.c Polyglot</h1> +<p class="quote"><i>Written by Paul Buetow 2014-03-24</i></p> +<p>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</p> +<a class="textlink" href="https://en.wikipedia.org/wiki/Polyglot_(computing)">https://en.wikipedia.org/wiki/Polyglot_(computing)</a><br /> +<h2>The Fibonacci numbers</h2> +<p>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:</p> +<pre> +#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; +} +</pre> +<p>You can find the whole source code at GitHub:</p> +<a class="textlink" href="https://github.com/snonux/perl-c-fibonacci">https://github.com/snonux/perl-c-fibonacci</a><br /> +<h3>Let's run it with Perl:</h3> +<pre> +❯ 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 +</pre> +<h3>Let's compile it as C and run the binary:</h3> +<pre> +❯ 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 +</pre> +<p>It's really fun to play with :-).</p> +<p>E-Mail me your thoughts at comments@mx.buetow.org!</p> + </div> + </content> + </entry> + <entry> <title>Perl Daemon (Service Framework)</title> <link href="https://buetow.org/gemfeed/2011-05-07-perl-daemon-service-framework.html" /> <id>https://buetow.org/gemfeed/2011-05-07-perl-daemon-service-framework.html</id> diff --git a/content/html/gemfeed/index.html b/content/html/gemfeed/index.html index c3c3028..dd6200a 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 { <a class="textlink" href="./2016-04-09-jails-and-zfs-on-freebsd-with-puppet.html">2016-04-09 - Jails and ZFS with Puppet on FreeBSD</a><br /> <a class="textlink" href="./2016-04-03-offsite-backup-with-zfs.html">2016-04-03 - Offsite backup with ZFS</a><br /> <a class="textlink" href="./2015-12-05-run-debian-on-your-phone-with-debroid.html">2015-12-05 - Run Debian on your phone with Debroid</a><br /> +<a class="textlink" href="./2014-03-24-the-fibonacci.pl.c-polyglot.html">2014-03-24 - The fibonacci.pl.c Polyglot</a><br /> <a class="textlink" href="./2011-05-07-perl-daemon-service-framework.html">2011-05-07 - Perl Daemon (Service Framework)</a><br /> <a class="textlink" href="./2010-05-09-the-fype-programming-language.html">2010-05-09 - The Fype Programming Language</a><br /> <a class="textlink" href="./2010-04-09-standard-ml-and-haskell.html">2010-04-09 - Standard ML and Haskell</a><br /> diff --git a/content/html/index.html b/content/html/index.html index 76713db..317a273 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 { <a class="textlink" href="./gemfeed/2016-04-09-jails-and-zfs-on-freebsd-with-puppet.html">2016-04-09 - Jails and ZFS with Puppet on FreeBSD</a><br /> <a class="textlink" href="./gemfeed/2016-04-03-offsite-backup-with-zfs.html">2016-04-03 - Offsite backup with ZFS</a><br /> <a class="textlink" href="./gemfeed/2015-12-05-run-debian-on-your-phone-with-debroid.html">2015-12-05 - Run Debian on your phone with Debroid</a><br /> +<a class="textlink" href="./gemfeed/2014-03-24-the-fibonacci.pl.c-polyglot.html">2014-03-24 - The fibonacci.pl.c Polyglot</a><br /> <a class="textlink" href="./gemfeed/2011-05-07-perl-daemon-service-framework.html">2011-05-07 - Perl Daemon (Service Framework)</a><br /> <a class="textlink" href="./gemfeed/2010-05-09-the-fype-programming-language.html">2010-05-09 - The Fype Programming Language</a><br /> <a class="textlink" href="./gemfeed/2010-04-09-standard-ml-and-haskell.html">2010-04-09 - Standard ML and Haskell</a><br /> diff --git a/content/html/resources.html b/content/html/resources.html index 45b20f6..01890a1 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 0000000..a422ef1 --- /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 <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](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 ad2fdab..c6ef908 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 624ef06..b314429 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 aa6f258..e32b547 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 0000000..15531fd --- /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 45cf151..b8b06e5 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; |
