Skip to content

Instantly share code, notes, and snippets.

View berndbausch's full-sized avatar

Bernd Bausch berndbausch

  • I work and speak for myself
  • Tokyo
View GitHub Profile
@berndbausch
berndbausch / linuxcolours.md
Last active June 11, 2023 01:24
Linux default colours on dark terminals

I set S_COLORS_SGR="I=32;22:N=36;1:W=35;1:X=31;1:Z=36;22" in my environment. Why?

The output of many command line commands uses colours, which is great for efficiently grasping information at a single glance. Unfortunately, default colours are often not suitable for dark backgrounds; for example, ls displays directories in dark blue, and iostat uses the same colour for most of its numbers. Almost unreadable.

Colours of the two abovementioned tools can be configured with environment variables, namely LS_COLORS and S_COLORS_SGR, respectively. LS_COLORS is very complex; it can be generated with the dircolors command, whose config file is perhaps even more complex but well documented by the dir_colors(5) man page. Thankfully, several useful dircolors configurations have been published, for example https://github.com/seebi/dircolors-solarized.

@berndbausch
berndbausch / autoinst.yml
Created February 8, 2019 22:41
autoyast for simple OpenSuse 15 installation
<?xml version="1.0"?>
<!DOCTYPE profile>
<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
<add-on>
<add_on_products config:type="list"/>
</add-on>
<bootloader>
<global>
<append>resume=/dev/disk/by-uuid/ba6011fb-7d2a-45d9-acf9-4ffee031f253 splash=silent quiet showopts</append>
<gfxmode>auto</gfxmode>
Each motor needs three pins, two normal digital output pins for setting the direction, and one PWM pin that sets the speed.
I started with pins 6(PWM)/7/8 and 11(PWM)/12/13. Works well.
I added infrared control software IRRemote. The motor connected to 11/12/13 doesn't turn anymore.
Solution: Use pin 5 instead of 11. IRRemote seems to use pin 11 to implement timer interrupts; I don't quite understand the details.
@berndbausch
berndbausch / container-process-mapping.md
Last active February 28, 2018 08:07
Find the container of a process, and the processes of a container

How to find containers of processes and vice versa

This is about Linux Containers, managed with LXC or LXD.

What are the processes of a container?

# lxc-info -p -n CONTAINERNAME                  # -p or --pid displays init's PID
PID:            27149
# pstree -p 27149
@berndbausch
berndbausch / LXD-cheat-sheet.md
Last active April 9, 2024 18:18
LXD cheat sheet

Useful LXD commands

Summarized from https://stgraber.org/2016/03/19/lxd-2-0-your-first-lxd-container-312/.

Interestingly, the LXD command line client is named.... lxc!

List available containers

lxc image list ubuntu:        # ubuntu: is officially supported image source
lxc image list images:        # images: is an unsupported source
lxc image alias list images:  # lists user-friendly names
@berndbausch
berndbausch / creating-docker-containers.md
Last active February 28, 2018 01:00
Creating Docker containers

Creating Docker containers

To write an application contained by Docker, one may start with an existing container that has the required environment. If the application is written in Python, a Python programming environment would make sense.

Docker's layered images allow us to take a Python image and layer the application on top of it. A Dockerfile describes what has to be done to create the new application container image. The following is a summary of the instructions on the Docker Get Started site:

  • get a Python image
  • specify the directory in the container where the application lives - its work directory
@berndbausch
berndbausch / Fedora-Laptop-Lid.md
Last active February 28, 2018 00:34
Prevent Fedora laptop from suspending when closing its lid

How to close the laptop lid in Fedora 23 without suspending the PC

Since I often use my laptop as a desktop PC, I don't want it to suspend itself when I close the lid.

Gnome has the Tweak Tool, a GUI tool to change a number of settings. You can use it to ignore a closing lid, but this setting doesn't seem to be persistent. When I restart the laptop, closing the lid suspends it again.

It turns out that systemd manages this particular detail. It can be configured in /etc/systemd/logind.conf:

$ sudo vi /etc/systemd/logind.conf