Skip to content

Instantly share code, notes, and snippets.

View stnguyen90's full-sized avatar

Steven Nguyen stnguyen90

View GitHub Profile
@stnguyen90
stnguyen90 / get_runtime_networks.sh
Last active June 15, 2022 00:05
Get the networks an open runtime container is part of
docker inspect --format '{{.Name}}:{{range $k, $v := .NetworkSettings.Networks}}{{printf "\n %s" $k}}{{end}}{{printf "\n"}}' `docker ps --filter 'label=utopia-type=runtime' -q`
@stnguyen90
stnguyen90 / log_mysql_queries.sh
Created June 3, 2022 20:41
Enable the general query log for a MySQL/MariaDB docker container and tail it. Disable the general query log on exit.
#!/bin/sh
CONTAINER=appwrite-mariadb
if [ ! -z "$1" ]; then
CONTAINER=$1
fi
docker exec -it $CONTAINER sh -c 'mysql -uroot -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE -e "SET GLOBAL general_log=1"'
docker exec -it $CONTAINER sh -c 'tail -f /var/lib/mysql/$HOSTNAME.log'
docker exec -it $CONTAINER sh -c 'mysql -uroot -p$MYSQL_ROOT_PASSWORD $MYSQL_DATABASE -e "SET GLOBAL general_log=0"'
@stnguyen90
stnguyen90 / Remove-JndiLookup.ps1
Created December 20, 2021 17:48
Apache Log4j2 Remote Code Execution (RCE) Vulnerability - CVE-2021-44228 - ESA-2021-31 emergency patch script for Windows
#
# Copied and tweaked from https://gist.github.com/neoKushan/e156810fc91765aa84857314b92bb22d to add
# backing up of jar
#
# To run it, ensure your execution policy is set correctly, paste the file anywhere you want it to check for
# log4j (This will check subfolders) and just call Remove-JndiLookup from your favourite powershell window.
#
# Note that the script isn't especially clever, running it on your machine doesn't guarantee that you're no longer
# vulnerable to log4shell, just that JndiLookup.class has been removed from any found instance of log4j-core-2.*.jar
#
@stnguyen90
stnguyen90 / handling-null-json-arrays-in-go-performance.go
Last active July 12, 2020 00:35
Handling Null JSON Arrays in Go - Performance
package main
import (
"encoding/json"
"fmt"
"reflect"
"time"
)
// Bag holds items
@stnguyen90
stnguyen90 / handling-null-json-arrays-in-go-dynamic-initialization.go
Last active September 6, 2023 10:09
Handling Null JSON Arrays in Go - Dynamic Initialization
package main
import (
"encoding/json"
"fmt"
"reflect"
)
// Bag holds items
type Bag struct {
@stnguyen90
stnguyen90 / handling-null-json-arrays-in-go-custom-marshaler.go
Last active July 12, 2020 00:36
Handling Null JSON Arrays in Go - Custom Marshaler
package main
import (
"encoding/json"
"fmt"
)
// Bag holds items
type Bag struct {
Items []string
@stnguyen90
stnguyen90 / handling-null-json-arrays-in-go-manual-make.go
Last active July 12, 2020 00:37
Handling Null JSON Arrays in Go - Manual Make
package main
import (
"encoding/json"
"fmt"
)
// Bag holds items
type Bag struct {
Items []string
@stnguyen90
stnguyen90 / handling-null-json-arrays-in-go-the-problem.go
Last active July 12, 2020 00:37
Handling Null JSON Arrays in Go - The Problem
package main
import (
"encoding/json"
"fmt"
)
// Bag holds items
type Bag struct {
Items []string