Skip to content

Instantly share code, notes, and snippets.

View kwilczynski's full-sized avatar
:octocat:

Krzysztof Wilczyński kwilczynski

:octocat:
View GitHub Profile
@kwilczynski
kwilczynski / gist:dc69ed5acb27a19ec1e29914895d7666
Last active January 11, 2024 09:40
Install lei for kernel development using lore directly on Ubuntu
apt install -y vim
apt install -y wget
apt install -y sqlite3 (used by a test, not needed for the build to complete)
apt install -y curl
apt install -y git
apt install -y build-essential
apt install -y pkg-config
@kwilczynski
kwilczynski / cidr-to-netmask.sh
Last active November 24, 2023 13:31
CIDR to netmask in bash.
# Return netmask for a given network and CIDR.
cidr_to_netmask() {
value=$(( 0xffffffff ^ ((1 << (32 - $1)) - 1) ))
echo "$(( (value >> 24) & 0xff )).$(( (value >> 16) & 0xff )).$(( (value >> 8) & 0xff )).$(( value & 0xff ))"
}
@kwilczynski
kwilczynski / tags.txt
Created October 27, 2023 11:04
Linux kernel preferred commit tag order
Fixes:
Closes:
Suggested-by:
Link:
Reported-by:
Tested-by:
Co-developed-by: (co-author)
Signed-off-by: (co-author)
Signed-off-by: (author)
Signed-off-by: (chain)
@kwilczynski
kwilczynski / route53
Last active October 2, 2023 08:34
EC2 automatic DNS entry in route53 for Auto Scaling Group
TTL=300
HOSTED_ZONE_ID=
REVERSE_HOSTED_ZONE_ID=
INSTANCE_ID=
REGION=
@kwilczynski
kwilczynski / buckets.txt
Last active August 28, 2023 14:38
Parse S3 URL into bucket, key, region, version ID, etc. Useful when using AWS SDK for Go.
http://s3.amazonaws.com/bucket/key (for a bucket created in the US East (N. Virginia) region)
https://s3.amazonaws.com/bucket/key
http://s3-region.amazonaws.com/bucket/key
https://s3-region.amazonaws.com/bucket/key
http://s3.region.amazonaws.com/bucket/key
https://s3.region.amazonaws.com/bucket/key
http://s3.dualstack.region.amazonaws.com/bucket/key (for requests using IPv4 or IPv6)
package main
import (
"testing"
)
func A() {
m := map[int][]string{}
for i, _ := range []int{1, 2, 3} {
@kwilczynski
kwilczynski / main.go
Last active July 7, 2023 14:49
Parse time duration as string - either assume seconds or parse string as rich format e.g., 5m 30s, etc.
package main
import (
"fmt"
"strconv"
"time"
)
func parseExpiry(s string) (time.Duration, error) {
var t time.Duration
@kwilczynski
kwilczynski / check.md
Last active July 6, 2023 08:35
Recipe / Role check in Chef

If you want to check whether a node run_list includes a specific role (upon expansion), then you could use role? method on the Node object:

node.role?('name')

Alternatively, you can see whether either would work for you:

node.roles.include?('name')

node.run_list?('role[name]')

@kwilczynski
kwilczynski / script.sh
Last active June 30, 2023 14:33
Build cppcheck
make clean
export PATH='/usr/local/bin:/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
sudo make MATCHCOMPILER=yes HAVE_RULES=yes FILESDIR='/usr/share/cppcheck' CXXFLAGS='-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function' -j$(nproc) install
@kwilczynski
kwilczynski / main.go
Created June 12, 2023 12:26
ZooKeeper TLS in Go example
package main
import (
"crypto/dsa"
"crypto/ecdsa"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"encoding/pem"
"flag"