Skip to content

Instantly share code, notes, and snippets.

View Vlad1mir-D's full-sized avatar
🌠
Still dreaming

Vladimir Vlad1mir-D

🌠
Still dreaming
  • Not really
  • Krasnodarium
View GitHub Profile
def ip2hex(cidr, router):
addr, mask = cidr.split("/")
mask = int(mask)
addr = [("%2s" % hex(int(i))[2:]).replace(" ", "0") for i in addr.split(".") if i != "0"]
parts = mask/8 - len(addr)
if mask%8 > 0:
parts += 1
if parts > 0:
for i in range(int(parts)):
addr.append("00")
@Vlad1mir-D
Vlad1mir-D / postgres_queries_and_commands.sql
Created September 23, 2021 04:17 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@Vlad1mir-D
Vlad1mir-D / 0_console.log
Created May 17, 2021 17:41 — forked from rtyler/0_console.log
Demonstrating setters/getters in a Pipeline Shared Library
Started by user rtyler
Loading library pipeline-library@acme-test
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git://github.com/jenkins-infra/pipeline-library.git # timeout=10
Fetching upstream changes from git://github.com/jenkins-infra/pipeline-library.git
> git --version # timeout=10
> git fetch --tags --progress git://github.com/jenkins-infra/pipeline-library.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/acme-test^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/acme-test^{commit} # timeout=10
@Vlad1mir-D
Vlad1mir-D / gnu_getopt_example.sh
Created April 15, 2021 14:04 — forked from bobpaul/gnu_getopt_example.sh
An example showing how to use getopt
#!/usr/bin/env bash
# Time-stamp: <2017-04-27 09:57:21 kmodi>
# Time-stamp: <2018-03-20 12:58:02 bobpaul>
# derived from kmodi's gist: https://gist.github.com/kaushalmodi/74e9875d5ab0a2bc1010447f1bee5d0a
#
# Example of using getopt to parse command line options
# http://stackoverflow.com/a/29754866/1219634 Limitation: All the options
# starting with - have to be listed in --options/--longoptions, else getopt will
# error out.
# The downside is that if you intend to use this as a wrapper to some other program,
#!groovy
def handleCheckout = {
if (env.gitlabMergeRequestId) {
sh "echo 'Merge request detected. Merging...'"
def credentialsId = scm.userRemoteConfigs[0].credentialsId
checkout ([
$class: 'GitSCM',
branches: [[name: "${env.gitlabSourceNamespace}/${env.gitlabSourceBranch}"]],
extensions: [
@Vlad1mir-D
Vlad1mir-D / csrotau.py
Created January 17, 2020 03:54 — forked from dogtopus/csrotau.py
CSR OTAU binary parser
#!/usr/bin/env python3
# CSR OTAU binary parser
# https://developer.qualcomm.com/qfile/34081/csr102x_otau_overview.pdf
# For use with test and demonstration only. This is obviously not official and
# is not affiliated with Qualcomm.
import io
import os
import sys
@Vlad1mir-D
Vlad1mir-D / relayd-igmpproxy.sh
Created July 30, 2018 01:24 — forked from braian87b/relayd-igmpproxy.sh
How to setup Client Bridged / Client Mode / RelayD and IGMPProxy for OpenWRT / LEDE
# Client Bridged / Client Mode / RelayD and IGMPProxy (It works)
# RelayD is to redirect packages and IGMP is for redirect IGMP packages
# Our network is 192.168.1.0/24
# Steps:
# Configure WAN as static
# We should edit our wan iface and put static IP
uci set network.wan='interface'
uci set network.wan.proto='static'
uci set network.wan.ipaddr='192.168.1.239' # Main Network IP
DROP FUNCTION IF EXISTS MurmurHashV3;
DELIMITER //
CREATE FUNCTION `MurmurHashV3`(`keyx` varchar(65535), `seed` int unsigned)
RETURNS int unsigned
BEGIN
DECLARE remainder,bytes,c1,c2,i, m1,m2 INT unsigned;
DECLARE h1,k1,h1b BIGINT unsigned;
SET remainder = LENGTH(keyx) & 3;
SET bytes = LENGTH(keyx) - remainder;
SET h1 = seed;
DROP FUNCTION IF EXISTS MurmurHashV2;
DELIMITER //
CREATE FUNCTION `MurmurHashV2`(`keyx` varchar(65535), `seed` int unsigned)
RETURNS int unsigned
BEGIN
DECLARE l,i,m,r INT unsigned;
DECLARE h,k BIGINT unsigned;
SET l = LENGTH(keyx), i=1, m = 0x5bd1e995, r=24;
SET h = seed ^ l;