I wrote this tutorial for potential new users that want to try out new stuff and wish to expand their technical knowledge, but also because there are some commands and details around here I might forget some months or years down the line (for example, Xorg video driver configurations). The whole writing process was a very good opportunity for me to extend the CSS I used for my website and to try do to a better job at formatting tech/code/console-related text. I would be glad if someone else found these instructions useful.
Well, this might be a bit embarrassing, but I’ve just installed ZorinOS on my laptop. Yes, you may throw rocks at me because I stated quite the opposite in my previous blog post, almost three months ago.
Sure, most of what I wrote a little while back still stands. My desktop PC, for example, still runs on Windows 10 Pro, and it will on the long term. Being in need of a stable desktop for photo & video work is still the main reason, since Darktable is quite far from Adobe’s Lightroom and most FOSS video editors I’ve tried deal quite poorly with HD footage at 60 fps (general software stability issues aside, of course; I know how it feels to have the video editor simply crashing during rendering and being unable to recover a large chunk of the project file).Continuarea
A (larger) bit of history
Since I was first introduced to Linux at age 12, back in 1999 (with kind mentoring and two Red Hat Linux 5.0 CDs from my godfather), I went through a whole range of experiences, much like every other human being on the planet. In time, this operating system got under my skin. Luckily, my work revolves quite a lot around it and I pulled any reachable lever in order to steer my carrer towards Linux-centered work.Continuarea
What is it?
The nice & “official” explanation: A script that needs to be run on top of a fresh Ubuntu Minimal installation, thus producing a lightweight, fast and cozy work & play environment. Maybe I will manage to produce an ISO at some point in the future, but I do not consider this a must since it’s aimed at personal use.
Actual explanation A very egotistical “project” that allows me to quickly setup an Ubuntu-based system for times when I’m forced to use a more popular distribution (i.e. at the workplace) instead something I favor (like musl-based distros and/or FreeBSD). Since I’m quite a fan of deep work & frugality, it was something I had to try. In the end, I did have some fun with this small project.Continuarea
So, this TP-Link WR841N served our household for about 6 years. Most of the time, we forgot about it, since we encountered no issues. As time went by though, it began to show it’s age (probably): Wi-Fi connections started dropping quite often and the whole system would freeze every other day, requiring a full reboot. Eventually, it got replaced.
Recently I came across a scenario where I needed to process a text file so that a certain portion at the beginning was to be truncated up to a certain given line.
After doing a bit of digging, I came across a very elegant solution on StackOverflow which involved the use of itertools & lambda statements.
Say, for example, that we have the following text:
> Sed posuere urna vel risus scelerisque, sit amet sollicitudin arcu porta. Vestibulum nec posuere erat. Duis nec finibus magna. Phasellus efficitur tempus lacus suscipit tincidunt. Sed efficitur lacinia arcu, ac ullamcorper nisi consectetur eget. > Aliquam nisl eros, tincidunt non commodo ac, lobortis vel quam. Morbi ac magna in sapien imperdiet aliquet nec nec augue. Mauris ut sollicitudin dolor, ut venenatis sapien. Morbi nunc eros, sodales eget justo vel, suscipit porttitor sapien. > THIS IS A DELIMITER > > Ut non eros purus. In fringilla ex arcu, eu vestibulum dui suscipit ac. Duis nec sagittis est. Praesent fringilla metus et congue placerat. Nulla viverra, purus quis mollis mollis, risus tortor interdum ante, id congue sem purus a orci. Vestibulum ante mi, pretium sollicitudin turpis vitae, malesuada finibus velit. Duis feugiat, urna a elementum ullamcorper, nulla felis pretium risus, sed porttitor metus dolor nec purus.
Now, we have the following code:
from itertools import dropwhile import os import sys with open('path/to/your/text/file', 'r') as file: # Provide the text that marks the end of the block #which will be truncated - in this example, it's # "THIS IS A DELIMITER" dropped = dropwhile(lambda _line: "THIS IS A DELIMITER" not in _line, file) next(dropped,"") for line in dropped: # You decide what to do with the remaining lines. # In this example, we just print them out. # Of course, these can be "forwarded" to another # file handle print(line)
The outcome is a text stripped of all content up to (and including) the supplied „delimiter” (in this example, **THIS IS A DELIMITER**)
Just another entry in my Python-related scrapbook :). There are many occasions when having some code snippets related to file searches can prove useful.
Find for the first occurrence of a given filename in a given directory:
import os def findFile(fileName, pathToSearch): for root, directories, files in os.walk(pathToSearch): if fileName in files: return os.path.join(root, fileName)
Find all files matching a given pattern and return a vector (list) with all entries (not that elegant yet, but it’ll do for the moment):
import os import fnmatch def findFileAllMatches(patternToFind, pathToSearch): results =  for root, dirs, files in os.walk(pathToSearch): for name in files: if fnmatch.fnmatch(name, patternToFind): result.append(os.path.join(root, name)) return results