Howto fix redis AOF file

Modify the kubernetes statefull set command and arguments, from this:

        - args:
            - '-c'
            - /opt/bitnami/scripts/start-scripts/start-master.sh
          command:
            - /bin/bash

to this:

        - args:
            - '-c'
            - while true; do sleep 3600; done
          command:
            - /bin/bash

get into the container and execute:

cd data/appendonlydir/
ls -al
redis-check-aof --fix appendonly.aof.manifest 

Then restore the statefull set command and arguments if everything is ok. Last but not least, if you feel the need, backup the data folder before fixing the files.

kubeadm – update expired certificates

Check expired certificates:

kubeadm certs check-expiration

Renew all certificates and restart all the nodes:

kubeadm certs renew all

Prepare kubectl with the new configuration:

cp ~/.kube/config ~/.kube/config.backup
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

Using Git with GNOME Keyring

A default Git installation ships with several credential helpers, so we need to configure Git to use one of these helpers. But this story wouldn’t be about Linux if we could get away without running a make command. The directory /usr/share/doc/git/contrib/credential contains several helpers, including libsecret and gnome-keyring. According to this StackOverflow post we should use libsecret, so lets configure Git to use it:

sudo apt install make gcc libsecret-1-0 libsecret-1-dev
cd /usr/share/doc/git/contrib/credential/libsecret
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret

The next time we call git push the provided credentials (GitHub username + personal access token) are stored in the keyring. Tools such as seahorse (GUI) or secret-tool (CLI) can be used to search or manage stored keys.

To cleanup all credential.helpers:

git config --global --unset-all credential.helper

Vimdiff cheat sheet

This tool can be used with git mergetool during a merge operation. This is how can it be used:

  • Browse for differences and retain
:diffget x        - Choose which version you want to keep with 1, 2 and 3 for the source, base and the target copy
]c                  - next difference
[c                  - previous difference
  • Wrap up the changes
:only       - once you’re resolved all conflicts, this shows only the middle/merged file
:wq (save and quit)
  • split navigations
ctrl-w then j, k, h, l
  • Vim’s defaults are useful for changing split shapes:
"Max out the height of the current split
ctrl + w _"Max out the width of the current split
ctrl + w |"Normalize all split sizes, which is very handy when resizing terminal
ctrl + w =

Deploy artifact to maven central

Open a new OSSRH issue here: https://issues.sonatype.org

Following the documentation from here: https://central.sonatype.org/publish/publish-maven/#distribution-management-and-authentication, add a new profile to the project pom:

<profile>
	<id>release</id>
	<activation>
		<property>
			<name>performRelease</name>
			<value>true</value>
		</property>
	</activation>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<version>2.2.1</version>
				<executions>
					<execution>
						<id>attach-sources</id>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>2.9.1</version>
				<executions>
					<execution>
						<id>attach-javadocs</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-gpg-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<id>sign-artifacts</id>
						<phase>verify</phase>
						<goals>
							<goal>sign</goal>
						</goals>
						<configuration>
							<keyname>${gpg.keyname}</keyname>
							<passphraseServerId>${gpg.passphrase}</passphraseServerId>
							<gpgArguments>
								<arg>--pinentry-mode</arg>
								<arg>loopback</arg>
							</gpgArguments>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</profile>

And the distributionManagement section:

	<distributionManagement>
		<snapshotRepository>
			<id>ossrh</id>
			<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
		</snapshotRepository>
		<repository>
			<id>ossrh</id>
			<url>
				https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
		</repository>
	</distributionManagement>

Create a new GPG key and publish the public part of it:

gpg --full-generate-key
gpg --keyserver keyserver.ubuntu.com --send-keys <key-id>

Update the following maven sections in the settings.xml file

<!-- Servers -->
<servers>
  <server>
    <id>ossrh</id>
    <username>sonatype username</username>
    <password>password</password>
  </server>
</servers>

<!-- Profiles -->
<profiles>
  <profile>
    <id>ossrh</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
      <gpg.keyname>key name</gpg.keyname>
      <gpg.passphrase>key passphrase</gpg.passphrase>
    </properties>
  </profile>
</profiles>

Build the project and deploy it to the staging area:

mvn clean deploy -P release

Release the previously deployed artifacts, by following these instructions: https://central.sonatype.org/publish/release/

Google drive on Ubuntu – Automount

Create the unit file as nano ~/.config/systemd/user/google-drive-ocamlfuse.service (be sure to replace instances of {label} and {mountpoint}):

[Unit]
Description=FUSE filesystem over Google Drive
After=network.target

[Service]
ExecStart=google-drive-ocamlfuse -label {label} {mountpoint}
ExecStop=fusermount -u {mountpoint}
Restart=always
Type=forking

[Install]
WantedBy=default.target

To automount on boot:

systemctl enable --user google-drive-ocamlfuse.service

To mount drive:

systemctl start --user google-drive-ocamlfuse.service

To unmount drive:

systemctl stop --user google-drive-ocamlfuse.service

More info can be found here: https://github.com/astrada/google-drive-ocamlfuse/wiki/Automounting

Google drive on Ubuntu

Configure apt repository:

sudo add-apt-repository ppa:alessandro-strada/ppa
sudo apt update

Install ocamlfuse

sudo apt install google-drive-ocamlfuse

Launch ocamlfuse to configure the authentication tokens

google-drive-ocamlfuse

Configure root_folder in subl ~/.gdfuse/default/config . It should be folder id that you can get from the web interface (it’s the id in the url after https://drive.google.com/drive/folders/). Remember remount with -cc after you change the root folder.

root_folder=the id

Create mount folder and execute the mount command:

mkdir ~/.gdfuse/folders
google-drive-ocamlfuse -cc ~/.gdfuse/folders

When done/tired of google drive, execute:

umount ~/.gdfuse/folders

For automount, please follow the instructions from here: https://blog.ciprianpascu.ro/2023/03/28/google-drive-on-ubuntu-automount/

Postgresql – connect to schema

Connect to database:

psql -U postgres

Play with the following commands:

\l - Display database
\c - Connect to database
\dn - List schemas
\dt - List tables inside public schemas
\dt schema1. - List tables inside particular schemas. For eg: 'schema1'.