
Hello and welcome to my little nock of the internet. Here I have my blog which mainly contain posts about tech, the outdoors, cooking, and some times mead brewing.
A bit of background information before you step into my world of crazy. I am Lars, a.k.a. looopTools, a Software Engineer living in East Jutland, Denmark. I have 10+ years of experience from industry mainly through student positions, but also as self-employed consultant, or full-time employee. I mainly work in low-level user space, high-level kernel space, and storage systems in general. Besides research and software development, I also love the outdoors and try to go out as often as possible (not enough at the moment) and I am an aspiring author currently working on a few different novels. I also dabble in being a more advance home cook and baker, which you may see some posts about. Finally I like the ancient art of brewing mead, a.k.a. honey wine, and experiment with different flavour combinations and ageing times.
Why I am reconsidering neovim
So as readers of this blog will know I am an Gnu Emacs and have been for quite a while. In particular I am a huge fan of the features opt in rather than opt out philosophy compared to fully feature IDEs and in some cases text editors. Also I like that I can get Emacs to adopt to my work flow and not the other way around.
Now, this is not to say that I have not dabbled with other text editors. I have had my time with Visual Studio Code, the now dead Atom, Vim, and others. But I always returned to Emacs for the simple reason that I found something I did not like. With Visual Studio Code in particular I have issues with how it splits panes, some of the keyboard bindings are insanely difficult to remember AND TAKE THAT FROM AN EMACS USER!, and the crazy amount of resources it consumes without any plugins (besides the default once) is simply insane.
However, with Vim it was more a case of I couldn’t get use to the default key bindings, which I like to stick with in the beginning of using a text editor and then do the customisation later. Also I had few issues with using in for C++ development, which I find out last year was actually down to me using really bad plugins. But, one thing I could never get past with Vim was the syntax for configuration. I simply dislike it. Whilst Emacs use Emacs Lisp, Vim uses something called Vim Script and I really find it weird and not nice.
However, some years back, I believe it was in 2015 Neovim was released. It is basically Vim but more modern and what is more important is that it use Lua for configuration instead of Vim Script. I do not particular enjoy writing Lua, but I find it more enjoyable than both Emacs Lisp and Vim Script. This alone have actually made me consider neovim as potential to dethrown Emacs in the land of editors for.
So back in 2022, I actually gave it a serious try.
At home I would only use Emacs for writing on my books as these at the time was only in Org Mode and I did not have the energy nor the time to morph them into something else, but for everything else I would use neovim.
I had the initial issues with the keybindings, but I found a pretty good cheat sheet for it and after about two months I was competent enough to no longer need it.
However, I ran into some issues with plugins for C++, C, and Python development with regards to LSP integration.
One of the issues was simply that neovim did not seem able to recognise when a file was C++ and when it was C, even if I used .cpp
and .c
and had this configured recognisable in my configuration.
So why on earth would I reconsider using it? Well after I started my current position, I got a colleague whom is a firm believer in neovim and have helped get over some of the issues. Which now makes neovim usable with Python for me at least, but I still have some issues with C++ which I need to hazel out. But I can see how easy it is for him to develop in C++ using neovim so I believe there is hope.
I may or may not document this. But Emacs be warned!
I still love Emacs and it will take a lot to get me away from it. So neovim will have to put up a fight. But let us see how it will go.
./Lars
[Book Review] I never thought about it that way
Less than a week ago I was looking for books on etiquette because, frankly, that is not my forte. During this quests for book I feel over the book “I never thought about it that way” by Monica Guzman. It had good reviews and I needed a new audio book for commute to work so I got it from one of my Audiobook dealers (in this case Audible) and started Listening. And boy I was blown away.
Whilst the book is more on etiquette in conversations and arguments, it holds a treasure troth of lessons which you can utilise to become better at understanding other people from very different backgrounds. The focus in the book is mainly on political differences but it is clear that the lessons learned can be applied in other conversations as well.
Guzman was born in Mexico from which her parents immigrated to the USA. What might be curious to many about this is that Guzman is Liberal but her parents are Conservatives whom voted for Trump. She starts the book by outlining how some from her social sphere in her lovely liberal Seattle cannot fathom why she is still in contact with her parents.
She continues by outlining different scenarios for who to handle difference of opinion and how to address it. It in particular focus on how to evaluated what others say and try to understand their perspective, how to be a good questioners, and, in my opinion, how deescalated others and your own aggression in conversation.
In particular the concept of sorting, othering, and siloing gets a lot of attention in the book. Where sorting is who we associated with and whom we do not. Followed by othering where we differentiated between us and them. Although these two cause division enough the final of the three siloing is much worse. This is the concept of creating echo chambers where we only expose ourselves to people with similar opinions as ourselves. Although she do not state this out right in the book I feel like she is hinting that this causes greater divides in our society and in the end extremism across all topics, polotics and, opinions. Of the things you can learn in this book I feel the understanding of these three concepts and how damning they can be are the most important.
The rest of the book dives into concepts and examples that underlines the issues SOS as she call sorting, othering, and siloing and how to best meet these issues, how to be aware of them, and how to alleviate them and not just meet them.
All in all I believe this book should be mandatory reading for any whom want to participate in any form of debate or argument about any topic.
However, the books have a two short comings in my opinion. Firstly, it very focused on the united states of america. Which is fair as the is the home of the author. Yet, at times it feels like the author focuses so much on the states that it seems like this is the only place these issues exists. Whilst, I believe this is not the authors intend, I would liked to have seen a reach for a broader worldly audience. Maybe the author can do so in a more expand version of the book. Secondly, and what nearly stopped me for finishing listing. The author have a lot of focus on her own achievements, basically a lot of “I did this”, “I arrange that”, “I helped start X”, and so on. At times the book felt more like the author was promoting herself rather than focus on the topic of the book. I personally think that a reedited version of the book could cut down on this content rather significantly.
./Lars
[Book review] Cult of the Dead Cow
From the first time I head about Cult of the Dead Cow (cDc), I was fascinated beyond my wildest dreams. Not only where they hackers, but they had ethics, a moral compass, and an overall coolness about them. However, I did not know where they came from, how the group worked not exactly what the purpose of their, at times, chaotic .txt files was. But even from the young age of 10 when I read their first .txt file I was hooked and I always wanted to learn more about this Hacktivist group.
A couple of years ago (late 2019) I stumbled upon the book Cult of the Dead Cow by Joseph Menn (fair warning Amazon Link /not affiliated/), in a brick and mortar book store in Aalborg, Denmark of all places and I got very sparkly eyes! I had wanted this book since I heard about the first time right after it was published back in June 2019. I could not believe I had it my hands! I bought it immediately as it was the only copy in the book store.
Here five years later almost I finally had the time and mental capacity to read it, and boy I was not disappointed.
The book is an honest treasure trow of information about the formation of the cDC from a humble Bulletin board in Texas, its turn to one of the most respected hacker groups in the world, and onwards to its legacy. Including the reasons for creating tools such as Back Orifice. Created with the intention of forcing big corporations to take security serious.
But Mr. Menn does not just focus on the positive it also includes the dark stuff like why Jake Laird excluded from the cult, and the impact of WikiLeaks and how the cDC saw WikiLeaks. LulzSec is also discussed and how elements inspired by the cDc may have gone their own ways away from values of the cDc.
The last member of the cDc covered in the book is Psychedelic Warlord a.k.a Beto O’Rourke. It describes how he used the style of thinking he learned from the early counter culture and cDc to campaign.
But even with all that the most important lessons from the book. Is the following
- With a few dedicated people you can do a lot
- Have principals and morals and stick to them
The Cult of the Dead Cow may have faded into a more obscure place but it and its members have left a lasting legacy on the world. Inspired many and let some of us towards better ideals. I am very thankful that I got to read this book.
Honestly my only regret about the book is that I did not buy it in hard cover!!!
./looopTools
[C/C++] Do you need a file system to write to a disk?
Before I did my PhD my interaction with data storage on disk had mainly been in the classic way. With the classic way I mean having a storage medium (SSD, HDD, USB, etc.) formatted and with a file system (HFS, EXT4, APFS, NTFS, XFS, etc.). During my PhD I started to ask the question: Do I actually need the file system?
The reason for this question was that I on Ubuntu was running in to a strange limitation. I was literally hitting an upper bound for how many files there could be in a single directory. I hit this by exceeding the number of open file descriptors allowed by Ubuntu, which was lower at the time than for instance Fedoras limit. Note, it is really confusing when code works on one Linux distribution and not the other and the error you get is related to the limits imposed for file descriptors. ANYWAYS! I had to solve this and the first solution (and worst) I came up was simply to implement a folder structure which essentially mapped a Try tree to disk. Not my smartest idea, but hey we got a FUSE based file system to work. However, after a while I started to consider if could avoid my problems by avoiding the file system all together.
The answer to this is yes, yes you can and it is surprisingly easy.
All you need is!
Is a raw block device.
What is this then?
Basically a raw block device is any device that does not have a file system to manage the data on it.
To keep it simple it is disk partitions that has not been formatted with a file system, an entire disk or in the *NIX Virtual device such as /dev/null
.
You will need knowledge of pwrite
and pread
(or read
/write
or fread
/fwrite
), I will get into why I prefer the p
versions later.
These two functions can be untilised by including the unistd.h
header.
Oh and you need a file descriptor to the device.
Let us start by looking at pread
and pwrite
(see code below).
Both take the same parameters as an input, a file descriptor fd
, a data buffer buf
which in the case of pwrite
is const to indicate it is not changed, a byte counter count
indicating how many bytes should be read/written, and an offset from/to where data should be read/written.
A note, the file descriptor must be capable of seeking.
The return value is the number of bytes read/written can be compared to count
For pwrite
0 indicates nothing was written or end of file (EOF) in the case of pread
.
If -1 is returned and error has occurred and we can use errno
to check what error it is.
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
From this we can create a fairly simple example. /WARNING/: DO NOT RUN THIS EXAMPLE UNLESS YOU ADAPT IT TO A DEVICE WHERE YOU DO NOT MIND LOSING THE DATA!
#include <fcntl.h> // Opening files and related flags
#include <unistd.h> // pread and pwrite
#include <string.h> // strcmp
#include <stdio.h> // prints
int main(void)
{
const char *device = "/dev/sda";
const char *data = "Hello world!";
const size_t data_length = 12;
const off_t offset = 0;
int fd = open(device, O_RDWR); // Opens file descriptor in READ/WRITE mode
if (fd == -1) {
perror("Error opening Device");
return 1;
}
ssize_t bytes_written = pwrite(fd, data, data_length, offset);
if (bytes_written == -1) {
perror("Error writing data");
}
else {
char data_out[data_length];
bytes_written = pread(fd, data_out, data_length, offset);
if (bytes_written == -1) {
perror("Error Reading Data");
} else {
const int result_of_compare = strcmp(data, data_out);
printf("It is the same data: %s", result_of_compare == 0 ? "True" : "False");
}
}
close(fd);
return 0;
}
Based on this example you should be able to see a few issues when reading and writing without a file system.
First, where is the data or where should I put it?
Let us say I run this code again, but with the data
being I love hamburgers
and data_length
being 17
.
Then we will write over the Hello World
on disk.
But how do we know it is there?
Well, we do not and we never will, unless we keep a record of it.
Secondly, how do we know how much data to read?
Let us say that the our write and read happens at two different points in time, how do we know how much data to read?
Well, we do not and we never will, unless we keep a record of it.
So we need to keep a record of both, which essentially is the beginning of a file system…
But still we can read and write without a file system.
Now why do I prefer pread
and pwrite
over read/write
and fread/fwrite
.
Well frankly, I just prefer the way I can provide an offset and then “magic” happens behind the seen doing the seek
operations for me.
But I know purist who prefer read
and write
for the opposite reason and that is fair enough.
Anyways now you can write to disk like a pro.
For the love of all gods and demons be careful.
./Lars
Apps for macOS I cannot live without?
A while back I made these two blog posts “Why I prefer physcial notebooks over software-based” and “Writing my notes by hand”. This resulted in me getting a few emails about note Apps I should try for both mac and Linux which totally would get me to drop the physical notebook. Well it has not, I tried Notion for Notes & Docs but it simply is not me. Honestly, I still prefer Emacs with org-mode if I have to take notes on a computer. Now, I actually also got some questions about what applications do I use and mainly I was asked for macOS. So I this bog post I will cover which Apps I cannot live without on macOS and later I will make a similar post for Linux. So let us get started!
Emacs
Emacs is my drug of choice and by the application I use the most. Not just on macOS but also on Linux. Although it is an old text editor, it can be modernised quite a lot through modifications and plugins. I use it for writing blog post for this blog, writing my books, coding, note taking using org-mode and more. It is my multi-tool and I love it.
I will ammend here that the learning curve is quite steep and I might not recommend vanilla Emacs to most people. There are alternatives such as doomeacs which suites modern people a lot more. Although I have not made that leap yet myself… I have actually considered setting up a virtual machine and testing how much I like it.
Apple Pages
For the rare occasion where I need something written which I need in .docx format I do not use Microsoft Word, I use Apple Pages. But why do I use Pages over let us say OpenOffice, LibreOffice, or ONLYOFFICE. Well first of all! I honestly dislike Microsoft Words user interface. I find it very confusing and very unintuitive, which from the get go removes ONLYOFFICE. Then there is {Open,Libre}Office and while LibreOffice is my go to on Linux, I find it really unstable on macOS doing some very weird things from time to time. But, that is not the only reasons I use Pages. I also use Pages because:
- The UI is simply
- It does what I need
- It is stable
- I have iCloud sync between my personal devices (even my Linux machine(s))
- The online editor when I need it is reasonably good, and miles a head of Google Docs and Office 365.
It is a solid what you see is what you get editor and it never surprises me which I really, really like. Here I particular scowl at Microsoft Word and OpenOffice.
Apple Music
I do not understand the hatred people have towards this application. Did I prefer it when it was called iTunes and the layout was less website like… YES! But do I hate it? No! Apple Music lets me listen to my music and that is really all I want from it. I only really use the Apple curated play lists I do not use custom play lists so much… Yet.
Additionally, I love the automatic synchronisation between my phone, tablet, and computers. Side note here! For the blog post on Linux applications I will talk about Cider which I use to listen to Apple Music on Linux.
Things
I am a todo alcoholic and I have been a heavy user of Apple Reminders and I love it. However, I need a more sophisticated app with some feature in terms of note taking for a todo in the todo app. Enter Things. I had been eyeing this app for quite a while and people promised it would beat Apple Reminders by miles and quite honestly it does. The organisation of projects and areas are unparalleled compared to any app I have tried both on Linux and Mac. I was lucky to get it for iPad, macOS, and iPhone last year at black Friday and I have not regretted buying the App.
So that is the apps I cannot live with out.
./Lars