Skip to content

Instantly share code, notes, and snippets.

View knadh's full-sized avatar

Kailash Nadh knadh

View GitHub Profile
@knadh
knadh / flatten_test.go
Last active June 9, 2021 10:52
Benchmark of flattening nested maps ({ "parent": { "child": 123 }}` -> `{ "parent.child": 123 }): Recursion vs. iteration
package main
import (
"encoding/json"
"strings"
"testing"
)
var nested map[string]interface{}
#!/usr/bin/env bash
DATABASE_URL="postgres://MyPostgresUser:[email protected]:5432/MyPostgresDB"
# `cut` is used to cut out the separators (:, @, /) that come matched with the groups.
DATABASE_USER=$(echo $DATABASE_URL | grep -oP "postgres://\K(.+?):" | cut -d: -f1)
DATABASE_PASSWORD=$(echo $DATABASE_URL | grep -oP "postgres://.*:\K(.+?)@" | cut -d@ -f1)
DATABASE_HOST=$(echo $DATABASE_URL | grep -oP "postgres://.*@\K(.+?):" | cut -d: -f1)
DATABASE_PORT=$(echo $DATABASE_URL | grep -oP "postgres://.*@.*:\K(\d+)/" | cut -d/ -f1)
@knadh
knadh / numbers-to-words.go
Created June 12, 2022 08:22
Simple algorithm for converting numbers to English words (Golang)
package main
import (
"fmt"
)
var (
ones = []string{
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine",
@knadh
knadh / unix-to-time.go
Created July 1, 2022 07:36
Convert a unix (milli) timestamp to year, month, day ... without using the standard library
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println(unixToTime(time.Now().UnixMilli()))
}
@knadh
knadh / hide-linked-in-feed.md
Created October 4, 2024 09:53
Hide LinkedIn feed with uBlock origin

To block the insufferable infinite scroll "social" feed that LinkedIn renders when one logs in, add this rule to uBlock origin's "My Filters" list.

www.linkedin.com##main[aria-label="Main Feed"] .scaffold-finite-scroll