Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Alex Simenduev shamil

🎯
Focusing
View GitHub Profile
@shamil
shamil / mount_qcow2.md
Last active Dec 3, 2022
How to mount a qcow2 disk image
View mount_qcow2.md

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
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
shamil / rundeck_executions_cleanup.sh
Last active Nov 17, 2022
Rundeck executions cleanup
View rundeck_executions_cleanup.sh
#!/bin/bash -e
# see related issue: https://github.com/rundeck/rundeck/issues/357
# 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
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
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
shamil / README.md
Last active Oct 29, 2021 — forked from notheotherben/README.md
Fix Postgres 9.x Sequences
View README.md

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.

Running

@shamil
shamil / alertmanager.yml
Last active Aug 27, 2021
Prometheus - better slack messages
View alertmanager.yml
receivers:
- name: default
slack_configs:
- api_url: https://hooks.slack.com/services/...
channel: alerts
send_resolved: true
title: '' # important, put empty string here
text: '{{ template "slack.shamil.text" . }}'
@shamil
shamil / reroute.py
Last active Jul 7, 2021 — forked from FreeTymeKiyan/reroute.py
An example python script to reroute unassigned shards to NODE_NAME node thus recovering from the red cluster status
View reroute.py
#!/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
shamil / netmask_cidr.md
Last active May 26, 2021
Netmask / CIDR Translation Table
View netmask_cidr.md

Netmask / CIDR Translation Table

Netmask             Binary                              CIDR    Notes
---------------------------------------------------------------------------
255.255.255.255     11111111.11111111.11111111.11111111 /32     1   useable
255.255.255.254     11111111.11111111.11111111.11111110 /31     0   useable
255.255.255.252     11111111.11111111.11111111.11111100 /30     2   useable
255.255.255.248     11111111.11111111.11111111.11111000 /29     6   useable
255.255.255.240     11111111.11111111.11111111.11110000 /28     14  useable

255.255.255.224 11111111.11111111.11111111.11100000 /27 30 useable

@shamil
shamil / vlc-merge.md
Last active Jan 28, 2021
VLC: how to merge and transcode multiple videos
View vlc-merge.md

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 file1.ps file2.ps file3.ps --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.