Skip to content

Instantly share code, notes, and snippets.

View shamil's full-sized avatar
🎯
Focusing

Alex Simenduev shamil

🎯
Focusing
View GitHub Profile
-- PostgreSQL, create read-only user
-- Option 1
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
@shamil
shamil / .bashrc
Last active June 22, 2020 12:42 — forked from anonymous/.bashrc
Configure OSX shell to be like Debian/Ubuntu. Requires MacPorts.
# ~/.bashrc: executed by bash(1) for non-login shells.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
@shamil
shamil / vlc-merge.md
Last active January 28, 2021 10:18
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 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.

@shamil
shamil / netmask_cidr.md
Last active May 26, 2021 11:52
Netmask / CIDR Translation Table

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 / reroute.py
Last active July 7, 2021 08:24 — forked from FreeTymeKiyan/reroute.py
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
shamil / README.md
Last active January 23, 2023 18:30 — forked from notheotherben/README.md
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.

Running

@shamil
shamil / rundeck_executions_cleanup.sh
Last active March 24, 2023 20:02
Rundeck executions cleanup
#!/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 / pipewire.md
Created June 4, 2023 07:08 — forked from the-spyke/pipewire.md
Enable PipeWire on Ubuntu 22.04

Enable PipeWire on Ubuntu 22.04

This guide is only for original Ubuntu out-of-the-box packages. If you have added a custom PPA like pipewire-debian, you might get into conflicts.

Ubuntu 22.04 has PipeWire partially installed and enabled as it's used by browsers (WebRTC) for recoding the screeen under Wayland. We can enable remaining parts and use PipeWire for audio and Bluetooth instead of PulseAudio.

Starting from WirePlumber version 0.4.8 automatic Bluetooth profile switching (e.g. switching from A2DP to HSP/HFP when an application needs microphone access) is supported. Jammy (22.04) repos provide exactly version 0.4.8. So, we're good.

Based on Debian Wiki, but simplified for Ubuntu 22.04.

@shamil
shamil / uuid.js
Created November 26, 2012 15:52 — forked from jcxplorer/uuid.js
UUID v4 generator in JavaScript (RFC4122 compliant)
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 / tftp_fedora.md
Created February 24, 2017 21:37
TFTP server on Fedora

Source

TFTP server on Fedora

Here are some quick notes on setting up a TFTP server on Fedora 23. This is used, for example, to send Linux kernel images and other binaries to a bootloader on an embedded system.

First, install the packages:

sudo dnf install -y tftp tftp-server