Skip to content

Instantly share code, notes, and snippets.

@mybigman
mybigman / README.md
Created October 28, 2023 05:30 — forked from sancar/README.md
An upgradable read write lock for go

And upgradable read write lock for go

UpgradableRWMutex is an enhanced version of the standard sync.RWMutex. It has the all methods sync.RWMutex with exact same semantics. It gives more methods to give upgradable-read feature.

The new semantics for upgradable-read are as follows:

  • Multiple goroutines can get read-lock together with a single upgradable-read-lock.
  • Only one goroutine can have a write-lock and no read-lock/upgradable-read-lock can be acquired in this state.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/pem"
@mybigman
mybigman / paginator.go
Created September 21, 2023 12:35 — forked from alochym01/paginator.go
Create a simple Pagination - golang programming
package main
import (
"database/sql"
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"os"
@mybigman
mybigman / 0-go-os-arch.md
Created December 9, 2022 09:45 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@mybigman
mybigman / arch-raid1.sh
Created December 6, 2022 07:15 — forked from pvmart/arch-raid1.sh
Install arch linux on btrfs raid1
#!/bin/bash
set -e
set -o pipefail
dd if=/dev/zero of=/dev/sda bs=1024 count=10
dd if=/dev/zero of=/dev/sdb bs=1024 count=10
RAM=$(free -m | awk '/Mem:/{print $2}')
@mybigman
mybigman / ecb.go
Created November 9, 2022 11:33 — forked from yinheli/ecb.go
golang 标准库不支持 AES/ECB/PKCS5Padding issues: https://code.google.com/p/go/issues/detail?id=5597 别人的补丁. https://codereview.appspot.com/7860047/
package main
import (
"crypto/cipher"
)
type ecb struct {
b cipher.Block
blockSize int
}
@mybigman
mybigman / obsidian-pagebreaks.css
Created November 1, 2022 23:16 — forked from liamcain/obsidian-pagebreaks.css
Obsidian Pagebreaks
/**
Create pagebreaks in exported Obsidian PDFs.
Example:
# Heading 1
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
@mybigman
mybigman / blog20181109-01.cfg
Created September 26, 2022 02:12 — forked from haproxytechblog/blog20181109-01.cfg
Application-Layer DDoS Attack Protection with HAProxy
backend per_ip_rates
stick-table type ip size 1m expire 10m store http_req_rate(10s)
@mybigman
mybigman / swag-podman
Created September 24, 2022 13:45 — forked from e-minguez/swag-podman
swag-podman
```
$ sudo firewall-cmd --zone=trusted --add-forward-port=port=443:proto=tcp:toport=8443 --permanent
$ sudo firewall-cmd --zone=trusted --add-forward-port=port=443:proto=tcp:toport=8443
$ sudo firewall-cmd --zone=trusted --add-forward-port=port=80:proto=tcp:toport=8080 --permanent
$ sudo firewall-cmd --zone=trusted --add-forward-port=port=80:proto=tcp:toport=8080
$ sudo firewall-cmd --zone=trusted --add-service=https --permanent
$ sudo firewall-cmd --zone=trusted --add-service=https
$ sudo firewall-cmd --zone=trusted --add-service=http --permanent
$ sudo firewall-cmd --zone=trusted --add-service=http
$ sudo firewall-cmd --zone=trusted --add-masquerade
package main
import (
"encoding/json"
"fmt"
"time"
redis "gopkg.in/redis.v6"
)