Skip to content

Instantly share code, notes, and snippets.


Alex Simenduev shamil

View GitHub Profile
shamil /
Last active Dec 3, 2022
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
shamil / uuid.js
Created Nov 26, 2012 — forked from jcxplorer/uuid.js
UUID v4 generator in JavaScript (RFC4122 compliant)
View uuid.js
function uuid() {
var uuid = "", i, random;
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i == 8 || i == 12 || i == 16 || i == 20) {
uuid += "-"
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);
shamil /
Last active Nov 17, 2022
Rundeck executions cleanup
#!/bin/bash -e
# see related issue:
# export required vars
export RD_URL=http://localhost:4440 RD_USER=admin RD_PASSWORD=admin RD_HTTP_TIMEOUT=300
# make sure rd & jq commands are in the PATH
which -- rd jq >/dev/null
del_executions() {
shamil / howto_deb_repackage.txt
Created Jul 19, 2012
Howto repackage deb packages
View howto_deb_repackage.txt
Use folowing steps to repackage dep package:
1: Extract deb package
# dpkg-deb -x <package.deb> <dir>
2: Extract control-information from a package
# dpkg-deb -e <package.deb> <dir/DEBIAN>
3. After completed to make changes to the package, repack the deb
# dpkg-deb -b <dir> <new-package.deb>
shamil / gist:2165160
Created Mar 22, 2012 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.
View gist:2165160

Client-side SSL

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -out ca.key 2048
openssl req -new -x509 -days 365 -key ca.key -out ca.crt

Create the Client Key and CSR

shamil /
Last active Oct 29, 2021 — forked from notheotherben/
Fix Postgres 9.x Sequences

PostgreSQL 9.x Sequence Fixing Script

This script is intended to automatically fix the sequence numbers for all tables in the current database.

This is accomplished through the use of the setval() command, which we provide with the next ID value we wish to make use of. We use the setval(sequence, number, is_called) overload and set is_called = false in conjunction with COALESCE(MAX + 1, 1) to ensure that, with an empty table, the next sequence value is 1 as expected.


shamil / alertmanager.yml
Last active Aug 27, 2021
Prometheus - better slack messages
View alertmanager.yml
- name: default
- api_url:
channel: alerts
send_resolved: true
title: '' # important, put empty string here
text: '{{ template "slack.shamil.text" . }}'
shamil /
Last active Jul 7, 2021 — forked from FreeTymeKiyan/
An example python script to reroute unassigned shards to NODE_NAME node thus recovering from the red cluster status
#!/usr/bin/env python3
# An example python script to reroute unassigned shards to NODE_NAME node,
# thus recovering from the red cluster status
# pip install requests before using requests
import requests
import json
shamil /
Last active May 26, 2021
Netmask / CIDR Translation Table

Netmask / CIDR Translation Table

Netmask             Binary                              CIDR    Notes
---------------------------------------------------------------------------     11111111.11111111.11111111.11111111 /32     1   useable     11111111.11111111.11111111.11111110 /31     0   useable     11111111.11111111.11111111.11111100 /30     2   useable     11111111.11111111.11111111.11111000 /29     6   useable     11111111.11111111.11111111.11110000 /28     14  useable 11111111.11111111.11111111.11100000 /27 30 useable

shamil /
Last active Jan 28, 2021
VLC: how to merge and transcode multiple videos

Merge & Transcode

If you have more than one source files that need to be merged into a single output file, the general way is this (no transcoding is necessary if all streams match):

vlc --sout "#gather:std{access=file,mux=ts,dst=all.ts}" --sout-keep

NB that whenever you use sout, your video and audio codecs must "be appropriate" for the mux you use (in this case, ps works with a ts mux, so we're ok).

If you want to write your files out to a mux that doesn't support the current audio or video encoding, or if you are wanting to join streams that do not have matching video/audio, then it is recommended to transcode as well.