Skip to content

Instantly share code, notes, and snippets.

View bokwoon95's full-sized avatar
💭
effective. Power لُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ 冗

bokwoon95

💭
effective. Power لُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ 冗
View GitHub Profile
@bokwoon95
bokwoon95 / vim-update-plugins.sh
Last active March 13, 2023 11:35
bash script to automatically download and update vim plugins (lightweight alternative to a plugin manager using native vim 8 packages)
#!/bin/bash
# == USAGE ==
# Put Github URLs inside a file called `plugins.start.txt` inside your vim
# directory (either `$HOME/.vim/plugins.start.txt` or
# `$HOME/.config/nvim/plugins.start.txt`). Then, run this script which will
# clone or update the plugins accordingly.
#
# == EXAMPLE ==
# $ cat "$HOME/.config/nvim/plugins.start.txt"
func (v V_APPLICATIONS) View(dialect string) sq.Query {
USERS := sq.New[USERS]("u")
USER_ROLES := sq.New[USER_ROLES]("ur")
USER_ROLES_APPLICANTS := sq.New[USER_ROLES_APPLICANTS]("ura")
PERIODS := sq.New[PERIODS]("p")
FORMS := sq.New[FORMS]("f")
APPLICATIONS := sq.New[APPLICATIONS]("a")
applicants := NewCTE("applicants", nil, Postgres.
Select(
@bokwoon95
bokwoon95 / deref.go
Last active November 4, 2022 23:11
Go Generics type signature for ensuring argument is a pointer
// https://go.dev/play/p/BT-OUMK5Rtp
package main
import (
"fmt"
)
// Deref will dereference a generic pointer.
// It will fail at compile time if pt is not a pointer.
@bokwoon95
bokwoon95 / salsa20_example.go
Created February 22, 2021 02:39
golang x/crypto/salsa20 example
// https://play.golang.org/p/UPn9o_AMpmr
package main
import (
"fmt"
"golang.org/x/crypto/salsa20"
)
var key = [32]byte{}
@bokwoon95
bokwoon95 / baby_villager.txt
Last active January 6, 2021 07:20
baby_villager.txt
1) Summon baby villager that grows up in a few seconds
/summon villager ~ ~ ~ {Age:-100}
2) Summon baby villager that doesn't grow up (for a very long time)
/summon villager ~ ~ ~ {Age:-2147483648}
package main
import (
"fmt"
"reflect"
)
type Foo struct {
User string `tag_name:"tag 1"`
Fruit string `tag_name:"tag 2"`
@bokwoon95
bokwoon95 / comments.sql
Last active February 28, 2025 17:38
how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- how to model threaded comments (e.g. reddit comments) in SQL with a simple 'ancestors' column
-- The comment tree:
-- [1]
-- / \
-- [2] [4]
-- / \ \
-- [3] [7] [6]
-- /
-- [5]
@bokwoon95
bokwoon95 / speedtest.sh
Created July 23, 2020 12:45
internet speed test without downloading any software or visiting https://www.speedtest.net/
wget -O /dev/null http://speedtest-ams2.digitalocean.com/100mb.test
<!-- Copied from https://codepen.io/PerfectIsShit/pen/zogMXP -->
<!-- made into a gist in case the codepen goes down -->
<h2>HTML5 File Upload Progress Bar Tutorial</h2>
<form id="upload_form" enctype="multipart/form-data" method="post">
<input type="file" name="file1" id="file1" onchange="uploadFile()"><br>
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress>
<h3 id="status"></h3>
<p id="loaded_n_total"></p>
</form>
<script>
@bokwoon95
bokwoon95 / schemaspy-docker-postgres.sh
Last active March 26, 2025 07:27
How to run Docker SchemaSpy on a locally running Postgres
docker run -v "$PWD/schemaspy_output:/output" schemaspy/schemaspy:latest \
-t pgsql \
-host host.docker.internal \
-port 5432 \
-db my_database \
-u my_username \
-p my_password \
-vizjs
# -host needs to be host.docker.internal to refer to your local machine's localhost,
# not the schemaspy container's localhost. Schemaspy's docker documentation for this is horrible.