Skip to content

Instantly share code, notes, and snippets.

View shamil's full-sized avatar
🎯
Focusing

Alex Simenduev shamil

🎯
Focusing
View GitHub Profile
@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 / net_listen.sh
Last active August 29, 2015 14:11
Some commands to find out listening ports
# find all listening ports
cat /proc/net/tcp | awk '$4 == "0A" {print $2}' | awk -F: '{print strtonum("0x"$2)}'
# find all listening ports and print their inodes as well
cat /proc/net/tcp | awk '$4 == "0A" {print $10" "$2}' | tr : ' ' | awk '{printf "%d %d\n", strtonum("0x"$3), $1}'
# find all socket for PID and print their inodes
find -L /proc/<PID>/fd -type s -printf "%i\n"
# find listening ports for by PID

Using Sublime Text for Go Development

Credits goes to Mark Wolfe.

If you're new to golang then before you start setup your workspace, firstly watch this video Writing, building, installing, and testing Go code.

Usually after installing go, I'm running the following commands to make GOPATH available for my user

mkdir -p ~/Documents/My/gocode/src/github.com/shamil

This is what I use in Zabbix email action

Subject (problem):

{TRIGGER.SEVERITY}/{HOST.NAME}: {ITEM.NAME}

Subject (recovery):

OK/{HOST.NAME}: {ITEM.NAME}
@shamil
shamil / gdb_stacktrace.md
Created August 27, 2015 11:10
Viewing stacktrace of running process using GDB

Viewing stacktrace of running process using GDB

to view stacktrace of running process, run

sudo gdb -batch -quiet -nx -ex "backtrace full" -p <PID>

to view stacktrace of running process for all threads, run

sudo gdb -batch -quiet -nx -ex "thread apply all backtrace full" -p

@shamil
shamil / gcr-tags.go
Last active August 22, 2016 20:29 — forked from rjeczalik/gcr-tags.go
Reads a tag list for Google Container Registry for the given image.
package main
import (
"encoding/base64"
"encoding/json"
"flag"
"fmt"
"net/url"
"os"
"os/user"
-- 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 / setup-franz-ubuntu.sh
Created December 26, 2016 18:35 — forked from ruebenramirez/setup-franz-ubuntu.sh
setup franz on ubuntu
#!/bin/bash
sudo rm -fr /opt/franz
sudo rm -fr /usr/share/applications/franz.desktop
# create installation dir
sudo mkdir -p /opt/franz
#install franz
@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

@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