In a previous blog post, I demonstrated how Java’ enums that
contain one or more values/objects can be emulated with C#. One thing
bothered me, though: the switch statement and how inconvenient it
was to determine the proper type. Worst of all, it was not type-safe.
In my simple example, it was easy because I was using strings. Imagine
your fake-enum does not contain a string to quickly identify the
instance.
Well, there is a prettier workaround – and it involves an actual
enum. I was thinking about how the same could be done in C++ and in
C++, you can have type conversion operators. Then I searched if such a
feature also exists in C#, and sure enough, it does.
I have written a follow-up that improves on the following
solution using a type conversion operator overload.
When I started dabbling in C#, I wondered if it supports values in
enums. In Java, an enum instance can have properties (called fields in
Java lingo) associated with the enum’s literals. By taking advantage
of this feature, you can encode more information in an enum, like a
string, for example, or a constant number. You can even embed
instantiated class objects, maybe to associate an object factory with
a literal.
In my use case, I wanted to achieve a form of a key-value-pair
mapping. I require certain illegal characters in the NTFS file or
directory names to be replaced with a given code. I use HTML encoding
for my needs because I can simply look up the values online if I need
to.
Here is the Java reference example. First, let me start with the basic
enum definition (I use Lombok to auto-generate boilerplate code like
the constructor and accessors).
@Getter
@RequiredArgsConstructor
enum CharacterReplacementCode {
COLON(":", "&58;"),
POUND("#", "&35;"),
QUESTION_MARK("?", "&63;");
private final String character;
private final String replacement;
@Override
public String toString() {
return String.format("Character '%s' substituted by code '%s'", character, replacement);
}
}
Sometimes I want to run applications that I do not have pinned to the
quick-launch bar of my choice’s operating system/desktop environment.
To do that, I am used to pressing the Windows/Meta Key, begin typing a
few characters, and hit Enter. This is muscle memory and hard to get
rid of. Although it does not matter which UI opens, I do not need the
full-blown KDE Application Launcher, Gnome Shell, or Windows Start
Menu. The amount of UI that pops up and changes while searching for
the app is distracting.
Therefore, I wondered whether I could remap the Meta/Windows key from
opening the Application Launcher to opening KRunner. And you can, but
only on the command line.
Remove the key mapping from the Application Launcher.
kwriteconfig5 --file kwinrc --group ModifierOnlyShortcuts --key Meta ""
Open KRunner instead.
kwriteconfig5 --file kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.krunner,/App,,toggleDisplay"
Early July 2021, US president Joe Biden signed an executive order
strengthening the right to repair in America. It is all the rage in
the YouTuber space. Over here in Europe, the European Parliament is
also working on encouraging reuse and repair to save on resources
(Ecodesign Requirements, Grant EU Consumers Right to
Repair, Europe Reduce Waste by Guaranteeing Right to
Repair). However, I do not think the movement is as strong as
in the US, based on my perception of the media coverage. I had to
actively search for information rather than having it thrown at me by
media outlets, old-school and modern alike.
Disclaimer: This might just be my way of looking for and consuming
information. I strongly prefer non-German modern tech media (read
YouTube creators) because I am yet to find one that produces at the
same level of production quality as someone like Linus Media Group, as
one example. I watch German news, though, so I am not entirely
ignoring my own country 😉
Now, the topic of this post is not where I get my information or how
far the current state of legislation has come everywhere in the world.
I know that "Right to Repair" goes way beyond smartphones and
computers. My focus is on consumer technology because that is where my
interests are.
I want to talk about the software that runs on the hardware since it
is just as important to a product’s lifetime. Washing machines and
similar household appliances are becoming "smarter and smarter" with
every new generation, so it is no longer just phones and tablets.
Together with mobile computers, the latter two categories are likely
what everybody interested in tech immediately thinks about when
hearing "Right to Repair".
I just ran into a frustrating error that seemed unexplainable to me.
My goal was to replace an existing Azure Resource Group with a new one
managed entirely with Terraform. Besides a few other errors, this
SoftDeletedVaultDoesNotExist was incredibly confusing because no
more Key Vaults were found in the Resource Group’s list of resources.
Error: creating Vault: (Name "my-fancy-key-vault" / Resource Group "The-Codeslinger"):
keyvault.VaultsClient#CreateOrUpdate: Failure sending request: StatusCode=0 --
Original Error: Code="SoftDeletedVaultDoesNotExist"
Message="A soft deleted vault with the given name does not exist.
Ensure that the name for the vault that is being attempted to recover is in a recoverable state.
For more information on soft delete please follow this link https://go.microsoft.com/fwlink/?linkid=2149745"
with module.base.azurerm_key_vault.keyvault,
on terraform\key_vault.tf line 9, in resource "azurerm_key_vault" "keyvault":
9: resource "azurerm_key_vault" "keyvault" {
That is because it was soft-delete enabled. And it was the Key Vault
from the other Resource Group that I previously cleared of all
resources, not the new Resource Group.
Hopping Linux distributions, I came to Ubuntu 21.04, and one of the
first things I do is install Qt manually. I have described the process
in a previous blog post on Linux Mint, and it is the same for
Ubuntu. Except for a tiny detail. On Ubuntu, the bundled QtCreator
immediately crashes and triggers a "Send Diagnostic" dialog.
$ /opt/Qt/Tools/QtCreator/bin/qtcreator
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was
found. This application failed to start because no Qt platform plugin could be
initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc,
xcb.
Nautilus is the default file manager in basically all Gnome-based
distributions. I wonder why I cannot configure the default Bookmarks
in the left panel through a context menu with that wide adoption. Is
there no demand?
I managed to achieve my goal by editing two files. One is for the
user, and the other one is a system file. I have not tried multiple
user accounts, but I assume it affects everyone that uses the
computer.
I wanted to remove "Desktop", "Public", "Templates", and "Video"
because I never need that. What I ended up doing was to also change
the location of "Documents", "Music", and "Pictures" to point to their
respective OneDrive equivalents. That saves me from creating symbolic
links, as I have explained in one of my OneDrive posts.
First, the user file.
vim ~/.config/user-dirs.dirs
#XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
#XDG_TEMPLATES_DIR="$HOME/Templates"
#XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/OneDrive/Files"
XDG_MUSIC_DIR="$HOME/OneDrive/Music"
XDG_PICTURES_DIR="$HOME/OneDrive/Pictures"
#XDG_VIDEOS_DIR="$HOME/Videos"
Next, the system file. If you only remove entries from the user file,
they will be added again the next time you log in. My tests showed
that it is enough to customize the location in the user file. The
other way around does not work, however.
sudo vim /etc/xdg/user-dirs.defaults
#DESKTOP=Desktop
DOWNLOAD=Downloads
#TEMPLATES=Templates
#PUBLICSHARE=Public
DOCUMENTS=Files
MUSIC=Music
PICTURES=Pictures
#VIDEOS=Videos
# Another alternative is:
#MUSIC=Documents/Music
#PICTURES=Documents/Pictures
#VIDEOS=Documents/Videos
Finally, you need to log out and log in again for this change to take
effect.
In a previous blog post, I showed another way of syncing OneDrive folders on Linux as an alternative to using RCLONE. It was the Open-Source project “onedrive” by Github user “abraunegg” (a fork of an abandoned project by user “skilion”). One thing I was having trouble with was the installation as a daemon. I used an @reboot crontab workaround to achieve my goal instead. However, I was not satisfied, so I went back to the documentation to see if I missed something. And miss I did. To my defense, other steps I had tried are omitting a necessary detail required to make it work.
I have mentioned the installation in the other post, but I also left out a thing or two that I came across. That is why I will include the setup process again, this time in more detail, and refer you to the other blog post for configuration tips. That is the part I will skip here.
My test system is the same Fedora 34 distribution, and I have also tested the steps on Pop!_OS, which means it should work on the other Ubuntu derivates.
Edit: There is a part 3 that solves the daemon problem.
It has been about a year since my first blog post about
syncing Microsoft’s OneDrive cloud storage on Linux. The last time
around, I used RCLONE, which required a more hands-on approach. I have
found a new tool that I think is better because it can sync
automatically in the background without scripting or manually hacking.
It is aptly called onedrive that you can find on Github.
Its name might suggest that Microsoft finally ported their Windows and
Mac clients to Linux, but, unfortunately, that is not the case. I
would still like to see this happen, and if there is ever a time for
Microsoft to do it, it is probably now.
Let me briefly explain how I have installed and configured the
onedrive tool to suit my needs. Thanks to good default values, it is
straightforward, and you might not need any configuration at all.
(I wonder how I managed to not find this tool a year ago)
In a recent blog post (that I somehow accidentally deleted;
thank you to WordPress for having a Trashed section from which you can
restore), I already summarized my first impressions of the smaller
variant of the new Xbox consoles, the Series S. Now that I have had
the Xbox Series S for a couple of months, it is about time that I go
into more detail.
There are a few reasons why I bought the Series S:
Overall hardware shortage, especially GPUs because I wanted a PC
upgrade
The Series X was available nowhere or only overpriced (even worse
for PlayStation)
It was the only console of the new generation available in Germany
for MSRP
Before I took the plunge, I was very conscious about what to expect. I
watch Digital Foundry videos regularly where their team
investigates the performance and target resolutions of many console
games, old and new, among other things. From my experience with
connecting my PC to my 4K TV, I was confident that a resolution of
1080p is actually good enough for me to enjoy a game. Sure, I can see
the difference to 4K. But my TV does an excellent job of upscaling,
and the picture does not wash out and become a blurry mess. Therefore,
the Series S should not disappoint. And it didn’t. There is a caveat,
though, and I will address it in a later section of this probably
pretty long wall of text that is going to come.
I demoted a former Windows OS drive to a data drive recently without
formatting it. The SSD still contained my OneDrive folder, and I did
not want to download it again or copy it from a backup. Therefore, all
of the Windows system folders were still on the drive. I tried to
delete them, but whatever I did using the GUI, Windows slapped my
fingers. I was not able to remove the Program Files and Windows
folder.
There is a solution using the command line, though. You must execute
all commands in an Administrator command prompt.
Gotcha: I have noticed that I had to execute the statements a second
time on some folders to delete them finally.
An exception is the Windows directory. It cannot be removed using
these commands. I have found another workaround that tricks Windows
into believing it is a previous Windows installation. Rename the
Windows directory to “Windows.old” and then run Disk Cleanup -> Clean
up system files. Windows will detect this as an old installation and
offer to remove it.
It has been a long time since I have played a first-person shooter in
single-player mode. The last playthrough was probably the original
Half-Life as a Let’s Play on YouTube about three years ago (I expected
it to be longer, though). Since then, it has mainly been 3rd person
shooters or action adventures. The majority of 1st person shooting
games I have played are the Borderlands franchise and Counter-Strike
until version 1.6. There have been a couple of others, of course; big
names like Half-Life 2, Doom, Unreal (Tournament), Serious Sam, and so
on. But that was at a time I would now call my youth. I like the skill
aspect of shooters, but other than that, I have not found many that
got me interested in a way that made me want to continue to play them.
I have barely played through any of the previous games (Half-Life 2
being the exception 😉). In the here and now, I am looking for a
well-told story and character development. And by that, I mean the
main character’s personality and the relations the character has with
others, not a role-playing system.
I have heard many praises about the quality of Titanfall 2, despite it
not being a huge hit. When I discovered this game for a whopping 2.99€
in the Xbox game store, I figured why not try it out. Since I usually
try to write reviews for games I find noteworthy in a specific way, be
it good or bad, there must be something about Titanfall 2 that made me
mash some keys on my keyboard and publish it on the Internet. Is it a
Witcher 3 or a Battlefield 4? Curious?
The start of Q4 2020 was supposed to be an incredible time for PC
gamers – or gamers in general. Firstly, Microsoft and Sony released
their latest Next-Gen consoles, the Xbox Series X and S and the
PlayStation 5. Secondly, AMD and NVIDIA battled it out in the GPU
market, and AMD unleashed the Ryzen 5000 CPU family that ate Intel’s
10th generation for breakfast. And lunch. And supper, and dinner, and
as a snack in between. Unfortunately for Intel, the only thing the
11th generation of Core Processors can do is hold AMD’s beer. In
theory.
Excellent Hardware, No Stock, High Prices
I think by now, about six months later, we all know how things played
out. It is not about having the best performance anymore. Instead, it
is about who can get products on the shelves or into retailers’
warehouses so people can buy them. It seems like the price does not
even matter. Some affluent enthusiast gamers may be more willing to
overpay for their hobby, and first-time builders might not know any
better. I am neither in the first nor in the last category. I could
afford new PC hardware, but I am not willing to overpay a single Oren
for any of it. The reasons for these prices are manifold, and many
YouTubers discussed this very topic in many a video.
The story I want to tell you today is how all of that brought me into
Microsoft’s console hardware and gaming service arms. Well, I guess I
kind of already spoiled the reason: PC hardware is ridiculously
overpriced, let alone readily available to buy. But there is more to
it than that.
I’ll try to make this quick. I started gaming on my 2019 Sony Android
TV, and it frequently displayed a banner at the top with connection
and resolution information. I hate when things constantly pop up, but
it also blocked a pretty large portion of the screen. After some
research, I found references about older versions of the operating
system where Banners have their own menu item. Not on my TV, though,
and I was starting to become very frustrated.
The option is there! It is in a location where I did not expect it.
Open the settings and navigate to "Watching TV".
I associate that with a cable connection which is why I never looked
there in the first place. I do not have cable. Next, disable "Info
banner" and feel relieved.
I recently purchased the smaller of the Xbox Series, and it came in a
bundle with three months of Game Pass Ultimate. As part of Game Pass
Ultimate, you get access to EA Play games and, therefore, some of the
Battlefield franchise. Since I have never played this game before, and
I was in the mood for a simple shooter, I wanted to try it out. I am
only interested in the single-player campaign and have no interest in
the multiplayer modes. Hence, I base my thoughts on the single-player
experience.
The idea of the introduction is not bad. You find yourself trapped in
a car with the rest of your squad. It is apparent that there was an
accident, and one of your buddies is badly injured or trapped and
cannot get out. The situation is intense because the car is sinking in
a lake or river or some other large body of water. Panic starts to
break out, especially since your leader wants you to leave him behind.
He hands you his handgun and orders you to shoot the windows so you
and your fellow soldiers can get out. They, on the other hand, do not
want to leave him behind. And from there, the game rewinds to where it
all began.