Skip to content

Instantly share code, notes, and snippets.

View alexnoz's full-sized avatar
💡

Alex Nozdriukhin alexnoz

💡
  • Third Stone from the Sun
View GitHub Profile
@alexnoz
alexnoz / remove-iptables-chain.sh
Created August 7, 2023 19:03
Remove custom iptables chain
#!bin/bash
table=$1
pattern=$2
if [[ -z "$table" ]] || [[ -z "$pattern" ]]; then
echo "Usage: $0 <iptables-table-name> <iptables-chain-name-grep-pattern>"
exit 1
fi
#!/bin/bash
kubeadm reset -f
yum remove -y kube* containerd* docker* nginx cri*
rm -rf /etc/containerd /etc/cni/net.d /home/docker /var/log/nginx /home/cert-deploy /home/containerd /etc/ansible-iptables
iptables-save | awk '/^[*]/ { print $1 }
/^:[A-Z]+ [^-]/ { print $1 " ACCEPT" ; }
@alexnoz
alexnoz / type-simulation.html
Last active May 1, 2020 18:12
Simple type simulation
<style>
.text {
position: relative;
}
.text.type-finished::before {
animation: .5s steps(2, jump-none) 0s infinite alternate pulse;
}
.text::before {
content: '';
height: 1em;
@alexnoz
alexnoz / misc.cpp
Created March 20, 2020 20:20
Misc C++ basic stuff (balanced parens, postfix evaluation, infix -> postfix convertion)
#include <iostream>
#include <stack>
#include <iomanip>
#include <map>
#include <cctype>
#include <cstdlib>
using namespace std;
#define SIZE(arr) (sizeof(arr) / sizeof((arr[0])))
@alexnoz
alexnoz / postfix_macro.rs
Last active March 19, 2020 22:47
Rust macro for evaluation of postfix expressions
macro_rules! postfix {
// Terminating rule
(() -> ($res:expr)) => {$res};
// Addition
((+ $($rest:tt)*) -> ($a:tt $b:tt $($stack:tt)*)) => {
postfix!(($($rest)*) -> (($b + $a) $($stack)*))
};
// Subtraction
@alexnoz
alexnoz / pg_hba.conf
Last active March 18, 2020 21:41
PostgreSQL master-slave replication example
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all password
# IPv4 local connections:
host all all 127.0.0.1/32 password
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
@alexnoz
alexnoz / k8s-init-play.yml
Last active February 25, 2020 23:35
A simple Ansible playbook for yum based distributions that installs Docker & K8s and initialises the k8s cluster (with Flannel as a network add-on)
---
- hosts: k8s_master,k8s_workers
become: true
remote_user: ansible
tasks:
# Docker installation
- name: Install helper packages
yum:
@alexnoz
alexnoz / kafka-cheat-sheet.md
Last active July 11, 2021 18:15
Apache Kafka cheat sheet

Config

Set a setting (log rotation)

./bin/kafka-configs.sh --zookeeper zookeeper1:2181/kafka \
--alter --entity-type topics \
--entity-name test \
--add-config segment.ms=60000
@alexnoz
alexnoz / roman.go
Created October 10, 2019 21:22
Basic roman<->arabic numerals conversion utils
package main
import (
"sort"
"strings"
)
var romanIntMap = map[string]int{
"M": 1000,
"D": 500,
@alexnoz
alexnoz / mst.cpp
Created September 5, 2018 21:20
Minimum spanning tree implementation using Prim's algorithm
#include <iostream>
#include <vector>
#include <array>
#include <climits> // INT_MAX
#include <algorithm> // find
using std::vector;
using edges_t = vector<std::array<int, 2>>;
using graph_t = vector<edges_t>;