Skip to content

Instantly share code, notes, and snippets.

@Kastet85
Kastet85 / libtar-list.c
Created November 2, 2020 07:32 — forked from cat-in-136/libtar-list.c
Study for reading/writing a tar file using libtar
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <libtar.h>
int main(int argc, char *argv[]) {
TAR *tar = NULL;
int ret = 0;
int exitcode = 0;
@Kastet85
Kastet85 / ovs-cheat.md
Created March 31, 2021 13:38 — forked from djoreilly/ovs-cheat.md
OVS cheat sheet

DB

ovs-vsctl list open_vswitch
ovs-vsctl list interface
ovs-vsctl list interface vxlan-ac000344
ovs-vsctl --columns=options list interface vxlan-ac000344
ovs-vsctl --columns=ofport,name list Interface
ovs-vsctl --columns=ofport,name --format=table list Interface
ovs-vsctl -f csv --no-heading --columns=_uuid list controller
ovs-vsctl -f csv --no-heading -d bare --columns=other_config list port
@Kastet85
Kastet85 / etc_NetworkManager_conf.d_90-disable-randomization.conf
Created May 12, 2021 11:08 — forked from ctubbsii/etc_NetworkManager_conf.d_90-disable-randomization.conf
NetworkManager configuration to disable WiFi MAC address randomization while scanning
# Place file in
# /etc/NetworkManager/conf.d/90-disable-randomization.conf
[device-mac-randomization]
# "yes" is the default for scanning in Fedora 25
wifi.scan-rand-mac-address=no
[connection-mac-randomization]
ethernet.cloned-mac-address=random
wifi.cloned-mac-address=random

Потоковая репликация PostgreSQL

Потоковая репликация (Streaming Replication) - это репликация, при которой от основного сервера PostgreSQL на реплики передается WAL (Write Ahead Log). И каждая реплика затем по этому журналу изменяет свои данные. Для настройки такой репликации все серверы должны быть одной версии, работать на одной ОС и архитектуре.

Шаги настройки:

  1. Настройка master-сервера
  2. Настройка доп. сервера (slave)
  3. Тестирование репликации

Отправка файлов в Yandex Disk через REST API из Bash

Пример выгрузки файлов на Яндекс.Диск из Bash через официальный REST API.

Подготовка токена для работы с API

Тут все просто.

  1. Идем по ссылке и входим под нужной учетной записью Яндекса, после чего нажимаем "Зарегистрировать новое приложение".
  2. Настраиваем новое приложение:
@Kastet85
Kastet85 / bash_strict_mode.md
Created May 5, 2022 12:37 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@Kastet85
Kastet85 / Jenkinsfile
Created August 12, 2022 08:45 — forked from bcomnes/Jenkinsfile
Git env vars you might need in jenkins
/*
Jenkins ENV Reference:
env.GIT_COMMIT: the commit sha of the current build
env.BRANCH_NAME: the branch name OR tag name of the current build, when it exists
env.GIT_BRANCH: same as BRANCH_NAME
env.TAG_NAME: the tag name of the current build, when it exists
*/
@Kastet85
Kastet85 / stash_dropped.md
Created March 15, 2023 09:49 — forked from joseluisq/stash_dropped.md
How to recover a dropped stash in Git?

How to recover a dropped stash in Git?

1. Find the stash commits

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.

Reload the DNS Cache in Network Manager

You may be using NetworkManager with dnsmasq as the DNS plugin. If so, it's being used as a local caching nameserver.

When its data is outdated, you can force it to reload its DNS cache with:

Use:

nmcli general reload dns-full
@Kastet85
Kastet85 / mount_qcow2.md
Created September 18, 2023 08:33 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8