Skip to content

Instantly share code, notes, and snippets.

View asakasinsky's full-sized avatar

Vasily Asakasinsky asakasinsky

View GitHub Profile
@asakasinsky
asakasinsky / rm_lines_by_num_sed.md
Created September 18, 2024 18:17 — forked from nilforooshan/rm_lines_by_num_sed.md
sed: Delete lines by line numbers

Delete lines by line numbers

Example 1: Delete lines 1, 3 and 5.

sed -e '1d;3d;5d' $filename

Example 2: Delete line 1.

@asakasinsky
asakasinsky / gitlab_migrate.py
Created August 20, 2024 20:47 — forked from mjnaderi/gitlab_migrate.py
Migrate from gitlab.com to self-hosted gitlab
"""
We used this script to migrate from gitlab.com to our self-hosted gitlab.
Author: Mohammad Javad Naderi
Before running the script, install `python-gitlab` package.
Important Note:
In order to keep the authors of merge requests and comments, before running this script make
sure all users have enabled "Public Email" in their gitlab.com profile and create account for
all users in self-hosted Gitlab (with the same e-mail address as their gitlab.com public email).
@asakasinsky
asakasinsky / gh-mirror.py
Created August 20, 2024 20:47 — forked from pcheng17/gh-mirror.py
Script for mirroring repositories
import os
import subprocess
import requests
import logging
from logging.handlers import RotatingFileHandler
logger = logging.getLogger("gh-mirror.py")
logfile = os.path.join(os.path.dirname(__file__), "logs", "gh-mirror.log")
logdir = os.path.dirname(logfile)
@asakasinsky
asakasinsky / gitlab-export.py
Created August 20, 2024 20:47 — forked from jwhb/gitlab-export.py
Create export of all GitLab user project.
# GitLab user project export
#
# Install gitlab module: python3 -m pip install python-gitlab==3.15.0
#
# Set environment variables GITLAB_URL and GITLAB_OAUTH_TOKEN (Personal Access Token):
# GITLAB_URL=https://gitlab.com GITLAB_OAUTH_TOKEN=changeme python3 gitlab-export.py
import gitlab
import time
import tarfile
@asakasinsky
asakasinsky / call-gitlab-api.py
Created August 20, 2024 20:47 — forked from all4dich/call-gitlab-api.py
Sample Script to call GitLab Project Management API
import requests
import os
import argparse
import logging
logging.basicConfig(level=logging.INFO)
arg_parser = argparse.ArgumentParser(description='Call GitLab API')
arg_parser.add_argument('--gitlab-token', required=True, help='GitLab token')
arg_parser.add_argument('--gitlab-url', required=True, help='GitLab URL')
arg_parser.add_argument('--org-name', required=True, help='Organization name')
@asakasinsky
asakasinsky / README.md
Created August 17, 2024 13:04 — forked from dsample/README.md
ASCII art diagrams

ASCI art characters for creating diagrams

Characters:

Single line

  • ASCII code 191 = ┐ ( Box drawing character single line upper right corner )
  • ASCII code 192 = └ ( Box drawing character single line lower left corner )
  • ASCII code 193 = ┴ ( Box drawing character single line horizontal and up )
  • ASCII code 194 = ┬ ( Box drawing character single line horizontal down )
@asakasinsky
asakasinsky / vm-backup.sh
Created February 6, 2024 07:12 — forked from cabal95/vm-backup.sh
I use this script to backup my QEMU/KVM/libVirt virtual machines. The script requires KVM 2.1+ since it uses the live blockcommit mode. This means the data in the snapshot disk is rolled back into the original instead of the other way around. Script does NOT handle spaces in paths.
#!/bin/bash
#
BACKUPDEST="$1"
DOMAIN="$2"
MAXBACKUPS="$3"
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]"
exit 1
@asakasinsky
asakasinsky / resize_disk_image.md
Created February 6, 2024 07:11 — forked from joseluisq/resize_disk_image.md
How to resize a qcow2 disk image on Linux

How to resize a qcow2 disk image on Linux

This example takes olddisk.qcow2 and resizes it into newdisk.qcow2, extending one of the guest's partitions to fill the extra space.

1. qcow2 format

1.1. Verify the filesystems of olddisk.qcow2

@asakasinsky
asakasinsky / mount_qcow2.md
Created February 3, 2024 14:45 — 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
@asakasinsky
asakasinsky / Documentation.md
Created August 29, 2023 15:30 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs