From f59672679db271f6b24a41e215401ab5001ecd96 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Tue, 31 Oct 2023 08:38:25 +0100 Subject: Theme updates --- ...01-03-encoding-binary-data-into-dna-sequence.md | 16 ++--- .../posts/2021-01-24-replacing-dropbox-with-s3.md | 10 +-- ...021-12-25-running-golang-application-as-pid1.md | 79 +++++++++++----------- ...22-07-05-what-would-dna-sound-if-synthesized.md | 8 +-- ...-fix-screen-tearing-on-debian-12-xorg-and-i3.md | 2 +- 5 files changed, 56 insertions(+), 59 deletions(-) (limited to 'content') diff --git a/content/posts/2019-01-03-encoding-binary-data-into-dna-sequence.md b/content/posts/2019-01-03-encoding-binary-data-into-dna-sequence.md index 0d44a40..8bd8d74 100644 --- a/content/posts/2019-01-03-encoding-binary-data-into-dna-sequence.md +++ b/content/posts/2019-01-03-encoding-binary-data-into-dna-sequence.md @@ -99,8 +99,8 @@ Deoxyribonucleic acid, a self-replicating material which is **present in nearly all living organisms** as the main constituent of chromosomes. It is the **carrier of genetic information**. -> The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, -> the carbon in our apple pies were made in the interiors of collapsing stars. +> The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, +> the carbon in our apple pies were made in the interiors of collapsing stars. > We are made of starstuff. > **-- Carl Sagan, Cosmos** @@ -134,9 +134,7 @@ As already mentioned, the Basic Encoding is based on a simple mapping. Since DNA is composed of 4 nucleotides (Adenine, Cytosine, Guanine, Thymine; usually referred using the first letter). Using this technique we can encode -
- -
+ using a single nucleotide. In this way, we are able to use the 4 bases that compose the DNA strand to encode each byte of data. @@ -196,7 +194,7 @@ sequence, often starting with a unique library accession number, and with time it has become commonplace to always use ">" for the first line and to not use ";" comments (which would otherwise be ignored). -``` +```txt ;LCBO - Prolactin precursor - Bovine ; a sample sequence in FASTA format MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHDLSS @@ -273,7 +271,7 @@ First we encode text file into FASTA file. Output of `quote.fa` file contains the encoded DNA sequence in ASCII format. -``` +```txt >SEQ1 GACAGCTTGTGTACAAGTGTGCTTGCTCGCGAGCGGGTACGCGCGTGGGCTAACAAGTGA GCCAGCAGGTGAACAAGTGTGCGGACAAGCCAGCAGGTGCGCGGACAAGCTGGCGGGTGA @@ -325,7 +323,7 @@ I have created a toolkit with two main programs: - dnae-encode (encodes file into FASTA file) - dnae-png (encodes FASTA file into PNG) -Toolkit with full source code is available on +Toolkit with full source code is available on [github.com/mitjafelicijan/dna-encoding](https://github.com/mitjafelicijan/dna-encoding). ### dnae-encode @@ -383,7 +381,7 @@ We create following binary files: - 10MB.bin - 100MB.bin -After this we create FASTA files for all the binary files by encoding them +After this we create FASTA files for all the binary files by encoding them into DNA sequence. ```bash diff --git a/content/posts/2021-01-24-replacing-dropbox-with-s3.md b/content/posts/2021-01-24-replacing-dropbox-with-s3.md index 7724c9c..b7fc424 100644 --- a/content/posts/2021-01-24-replacing-dropbox-with-s3.md +++ b/content/posts/2021-01-24-replacing-dropbox-with-s3.md @@ -31,9 +31,9 @@ so good. I haven't felt this way for a long time. Before you continue you should read my post about [syncing to Dropbox](/digitalocean-spaces-to-sync-between-computers.html). -> Also to note, I am using Linux on my machine with Gnome desktop environment. -This should work on MacOS too. To use this on Windows I suggest using -[Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) +> Also to note, I am using Linux on my machine with Gnome desktop environment. +This should work on MacOS too. To use this on Windows I suggest using +[Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) or [Cygwin](https://www.cygwin.com/). ## Folder structure @@ -93,12 +93,12 @@ This script also backups some of the dotfiles I use and sends notification to Gnome notification center. It is a straightforward solution. Nothing special going on. -> One obvious benefit of this is that I can omit syncing Node's `node_modules` +> One obvious benefit of this is that I can omit syncing Node's `node_modules` > or Python's `.venv` and `.git` folders. You can use this script in a combination with [Cron](https://en.wikipedia.org/wiki/Cron). -``` +```txt 0 2 * * * sh ~/Vault/bin/vault-backup.sh ``` diff --git a/content/posts/2021-12-25-running-golang-application-as-pid1.md b/content/posts/2021-12-25-running-golang-application-as-pid1.md index 251ef4f..e09bbc9 100644 --- a/content/posts/2021-12-25-running-golang-application-as-pid1.md +++ b/content/posts/2021-12-25-running-golang-application-as-pid1.md @@ -13,11 +13,11 @@ I have been reading a lot about very intriguing. When you push away all the marketing speak and look at the idea, it makes a lot of sense. -> A unikernel is a specialized, single address space machine image constructed +> A unikernel is a specialized, single address space machine image constructed > by using library operating systems. ([Wikipedia](https://en.wikipedia.org/wiki/Unikernel)) -I really like the explanation from the article -[Unikernels: Rise of the Virtual Library Operating System](https://queue.acm.org/detail.cfm?id=2566628). +I really like the explanation from the article +[Unikernels: Rise of the Virtual Library Operating System](https://queue.acm.org/detail.cfm?id=2566628). Really worth a read. If we compare a normal operating system to a unikernel side by side, they would @@ -25,14 +25,14 @@ look something like this. ![Virtual machines vs Containers vs Unikernels](/posts/pid1/unikernels.png) -From this image, we can see how the complexity significantly decreases with -the use of Unikernels. This comes with a price, of course. Unikernels are hard +From this image, we can see how the complexity significantly decreases with +the use of Unikernels. This comes with a price, of course. Unikernels are hard to get running and require a lot of work since you don't have an actual proper kernel running in the background providing network access and drivers etc. -So as a half step to make the stack simpler, I started looking into using -Linux kernel as a base and going from there. I came across this -[Youtube video talking about Building the Simplest Possible Linux System](https://www.youtube.com/watch?v=Sk9TatW9ino) +So as a half step to make the stack simpler, I started looking into using +Linux kernel as a base and going from there. I came across this +[Youtube video talking about Building the Simplest Possible Linux System](https://www.youtube.com/watch?v=Sk9TatW9ino) by [Rob Landley](https://landley.net) and apart from statically compiling the application to be run as PID1 there was really no other obstacles. @@ -41,12 +41,12 @@ application to be run as PID1 there was really no other obstacles. PID 1 is the first process that Linux kernel starts after the boot process. It also has a couple of unique properties that are unique to it. -- When the process with PID 1 dies for any reason, all other processes are +- When the process with PID 1 dies for any reason, all other processes are killed with KILL signal. -- When any process having children dies for any reason, its children are +- When any process having children dies for any reason, its children are re-parented to process with PID 1. - Many signals which have default action of Term do not have one for PID 1. -- When the process with PID 1 dies for any reason, kernel panics, which +- When the process with PID 1 dies for any reason, kernel panics, which result in system crash. PID 1 is considered as an Init application which takes care of running other @@ -73,19 +73,19 @@ PPid: 0 ``` As we can see on my machine the process with id of 1 is [systemd](https://systemd.io/) -which is a software suite that provides an array of system components for Linux -operating systems. If you look closely you can also see that the `PPid` -(process id of the parent process) is `0` which additionally confirms that +which is a software suite that provides an array of system components for Linux +operating systems. If you look closely you can also see that the `PPid` +(process id of the parent process) is `0` which additionally confirms that this process doesn't have a parent. ## So why even run application as PID 1 instead of just using a container? -Containers are wonderful, but they come with a lot of baggage. And because they -are in their nature layered, the images require quite a lot of space and also a +Containers are wonderful, but they come with a lot of baggage. And because they +are in their nature layered, the images require quite a lot of space and also a lot of additional software to handle them. They are not as lightweight as they seem, and many popular images require 500 MB plus disk space. -The idea of running this as PID 1 would result in a significantly smaller footprint, +The idea of running this as PID 1 would result in a significantly smaller footprint, as we will see later in the post. > You could run a simple init system inside Docker container described more @@ -95,7 +95,7 @@ as we will see later in the post. 1. Compile Linux kernel with the default definitions. 2. Prepare a Hello World application in Golang that is statically compiled. -3. Run it with [QEMU](https://www.qemu.org/) and providing Golang application +3. Run it with [QEMU](https://www.qemu.org/) and providing Golang application as init application / PID 1. For the sake of simplicity we will not be cross-compiling any of it and just @@ -122,16 +122,16 @@ $ cd .. At this point we have kernel image that is located in `arch/x86_64/boot/bzImage`. We will use this in QEMU later. -To make our lives a bit easier lets move the kernel image to another place. +To make our lives a bit easier lets move the kernel image to another place. Lets create a folder `bin/` in the root of our project with `mkdir -p bin`. -At this point we can copy `bzImage` to `bin/` folder with +At this point we can copy `bzImage` to `bin/` folder with `cp linux-5.15.7/arch/x86_64/boot/bzImage bin/bzImage`. The folder structure of this experiment should look like this. -``` +```txt pid1/ bin/ bzImage @@ -141,7 +141,7 @@ pid1/ ## Preparing PID 1 application in Golang -This step is relatively easy. The only thing we must have in mind that we will +This step is relatively easy. The only thing we must have in mind that we will need to compile the binary as a static one. Let's create `init.go` file in the root of the project. @@ -162,8 +162,8 @@ func main() { } ``` -If you notice, we have a forever loop in the main, with a simple sleep of 1 -second to not overwhelm the CPU. This is because PID 1 should never complete +If you notice, we have a forever loop in the main, with a simple sleep of 1 +second to not overwhelm the CPU. This is because PID 1 should never complete and/or exit. That would result in a kernel panic. Which is BAD! There are two ways of compiling Golang application. Statically and dynamically. @@ -184,9 +184,9 @@ $ ldd init not a dynamic executable ``` -At this point, we need to create [initramfs](https://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html) -(abbreviated from "initial RAM file system", is the successor of initrd. It -is a cpio archive of the initial file system that gets loaded into memory +At this point, we need to create [initramfs](https://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html) +(abbreviated from "initial RAM file system", is the successor of initrd. It +is a cpio archive of the initial file system that gets loaded into memory during the Linux startup process). ```sh @@ -196,7 +196,7 @@ $ mv initramfs bin/initramfs The projects at this stage should look like this. -``` +```txt pid1/ bin/ bzImage @@ -209,7 +209,7 @@ pid1/ ## Running all of it with QEMU [QEMU](https://www.qemu.org/) is a free and open-source hypervisor. It emulates -the machine's processor through dynamic binary translation and provides a set +the machine's processor through dynamic binary translation and provides a set of different hardware and device models for the machine, enabling it to run a variety of guest operating systems. @@ -256,11 +256,11 @@ The whole [log file here](/posts/pid1/qemu.log). ## Size comparison -The cool thing about this approach is that the Linux kernel and the application +The cool thing about this approach is that the Linux kernel and the application together only take around 12 MB, which is impressive as hell. And we need to -also know that the size of bzImage (Linux kernel) could be greatly decreased +also know that the size of bzImage (Linux kernel) could be greatly decreased by going into `make menuconfig` and removing a ton of features from the kernel, -making the size even smaller. I managed to get kernel size down to 2 MB and +making the size even smaller. I managed to get kernel size down to 2 MB and still working properly. ```sh @@ -325,24 +325,23 @@ genisoimage -R \ iso ``` -This will produce `GoAsPID1.iso` which you can use with [Virtualbox](https://www.virtualbox.org/) +This will produce `GoAsPID1.iso` which you can use with [Virtualbox](https://www.virtualbox.org/) or [Gnome Boxes](https://apps.gnome.org/app/org.gnome.Boxes/). ## Is running applications as PID 1 even worth it? -Well, the answer to this is not as simple as one would think. Sometimes it is +Well, the answer to this is not as simple as one would think. Sometimes it is and sometimes it's not. For embedded systems and very specialized applications it is worth for sure. But in normal uses, I don't think so. It was an interesting -exercise in compiling kernels and looking at the guts of the Linux kernel, -but sticking to containers for most of the things is a better option in my +exercise in compiling kernels and looking at the guts of the Linux kernel, +but sticking to containers for most of the things is a better option in my opinion. An interesting experiment would be creating an image that supports networking -and could be deployed to AWS as an EC2 instance and observing how it fares. -But in that case, we would need to write some sort of supervisor that would -run on a separate EC2 that would check if other EC2 instances are running +and could be deployed to AWS as an EC2 instance and observing how it fares. +But in that case, we would need to write some sort of supervisor that would +run on a separate EC2 that would check if other EC2 instances are running properly. Remember that if your application fails, kernel panics and the whole machine is inoperable in this case. - diff --git a/content/posts/2022-07-05-what-would-dna-sound-if-synthesized.md b/content/posts/2022-07-05-what-would-dna-sound-if-synthesized.md index cf0755f..136b9f4 100644 --- a/content/posts/2022-07-05-what-would-dna-sound-if-synthesized.md +++ b/content/posts/2022-07-05-what-would-dna-sound-if-synthesized.md @@ -156,8 +156,8 @@ WAV files here are using short, 16 bit, signed integers for the sample size. So, we multiply the floating-point data we have by 32767, the maximum value for a short integer. -> It is theoretically possible to use the floating point -1.0 to 1.0 data -> directly in a WAV file, but not obvious how to do that using the wave module +> It is theoretically possible to use the floating point -1.0 to 1.0 data +> directly in a WAV file, but not obvious how to do that using the wave module > in Python. ## Generating Spectograms @@ -192,7 +192,7 @@ gnuplot audio.gpi And input file `audio.gpi` that would be passed to gnuplot looks something like this. -``` +```txt # set output format and size set term png size 1000,280 @@ -358,7 +358,7 @@ if done properly. It could replace random note generator with something more intriguing, biological, natural. I actually find the results fascinating. I took some time and listened to this -music of nature. Even though it's quite the same, it's also quite different. +music of nature. Even though it's quite the same, it's also quite different. The subtle differences on repeat kind of creates music on its own. Makes you wonder. It kind of puts Occam’s Razor in its place. Nature for sure loves to make things as energy efficient as possible. diff --git a/content/posts/2023-07-10-fix-screen-tearing-on-debian-12-xorg-and-i3.md b/content/posts/2023-07-10-fix-screen-tearing-on-debian-12-xorg-and-i3.md index 1de0ffe..c7e12ae 100644 --- a/content/posts/2023-07-10-fix-screen-tearing-on-debian-12-xorg-and-i3.md +++ b/content/posts/2023-07-10-fix-screen-tearing-on-debian-12-xorg-and-i3.md @@ -11,7 +11,7 @@ under Debian 12 with Xorg and i3. Using `picom` compositor didn't help. To fix this issue create new file `/etc/X11/xorg.conf.d/20-intel.conf` as root and put the following in the file. -``` +```txt Section "Device" Identifier "Intel Graphics" Driver "intel" -- cgit v1.2.3