Skip to content

Instantly share code, notes, and snippets.

View Neurostep's full-sized avatar

Maksim Terekhin Neurostep

  • Amsterdam, Netherlands
View GitHub Profile
@Neurostep
Neurostep / jwtRS256.sh
Created April 19, 2023 09:44 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@Neurostep
Neurostep / convertFunctionFromSnakeTo.sh
Created January 28, 2022 09:35 — forked from nishidy/convertFunctionFromSnakeTo.sh
To convert function name from snake case to camel case or pascal case in go on OS X with bash 3
#!/bin/bash
if [[ $# -eq 1 ]] ;then
case $1 in
-c) option="camel" ;;
-p) option="pascal" ;;
*) echo "This option $1 is not supported."; exit 1 ;;
esac
else
echo "Give an option -c (Camel case) or -p (Pascal case)."

This gist shows how to use rebase to change the Git history of a repo. Imagine you realise that the first commit to your repo should be different (maybe it's incomplete, includes something it shouldn't or simply could be cleaner). However, since then you and others have made many changes to the repo that you want to preserve. Here we show how to split the first commit into multiple and re-attach the remaining version history to these new commits.

Let's make a dummy git repo rebase-root and add two files to it. We commit them with the commit #1.

@Neurostep
Neurostep / fifo.go
Created May 3, 2021 10:36
Go: Simple non-blocking FIFO channel
package main
import (
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
ch := make(chan int, 10)
package main
// Demonstrates how taking the address of an embedded struct
// leaks the embedding struct's memory.
type Inner struct {
x int
}
type Outer struct {
@Neurostep
Neurostep / Netfilter-IPTables-Diagrams.md
Created October 4, 2020 11:47 — forked from nerdalert/Netfilter-IPTables-Diagrams.md
Linux NetFilter, IP Tables and Conntrack Diagrams

Linux NetFilter, IP Tables and Conntrack Diagrams

IPTABLES TABLES and CHAINS

IPTables has the following 4 built-in tables.

1) Filter Table

Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.

@Neurostep
Neurostep / tcpdump & ngrep
Created August 4, 2020 16:21 — forked from PellePedro/tcpdump & ngrep
tcpdump & ngrep
tcpdump advanced filters
========================
Sebastien Wains <sebastien -the at sign- wains -dot- be>
http://www.wains.be
$Id: tcpdump_advanced_filters.txt 36 2013-06-16 13:05:04Z sw $
Notes :
@Neurostep
Neurostep / k8s-update-secret.md
Created July 1, 2020 12:27 — forked from dleske/k8s-update-secret.md
k8s: Updating a Secret

Hopefully helped another k8s newbie with the following. The question was, how do you update a single key in a secret in k8s? I don't know anything about secrets but I will probably want to know this in the future, so here we go.

First, to create a dummy secret:

apiVersion: v1
kind: Secret
metadata:
  name: test-secret
data:
@Neurostep
Neurostep / find-k8snode-interface.sh
Created May 29, 2020 14:25 — forked from r0mdau/find-k8snode-interface.sh
How to get tcpdump for containers inside Kubernetes pods
# find the kube node of the running pod, appear next to hostIP, and note containerID hash
kubectl get pod mypod -o json
# -> save hostIP
# -> save containerID
# connect to the node and find the pods unique network interface index inside it's container
docker exec containerID /bin/bash -c 'cat /sys/class/net/eth0/iflink'
# -> returns index
# locate the interface of the node