Skip to content

Instantly share code, notes, and snippets.

View maddie's full-sized avatar
💭
I may be slow to respond.

maddie maddie

💭
I may be slow to respond.
  • Shenzhen, China
  • 20:51 (UTC +08:00)
View GitHub Profile
@maddie
maddie / build-javet-macos.sh
Last active January 24, 2023 14:47
Build Javet on macOS
#!/bin/bash -e
# base directory for everything (output, depot_tools, source code, etc.)
BASEDIR=~/javet-build
###############################################
## DO NOT EDIT BELOW THIS LINE UNLESS NEEDED ##
###############################################
GITHUB_WORKFLOW=$(curl -sL https://raw.githubusercontent.com/caoccao/Javet/596200a7958541a8e1d2845c95ef12953be6b649/.github/workflows/linux_build_artifact.yml | grep -Eo "\w*JAVET_.*:.*")
@maddie
maddie / setup-proxmox-postfix-smtp.sh
Created September 8, 2022 14:03
Proxmox SMTP outgoing mail (SMTP) setup
#!/bin/sh
apt-get update && apt-get install -y libsasl2-modules
# only TLS enabled server is supported
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
[email protected] # replace username with your own
SMTP_PASSWORD=hunter2 # replace password with your own
[email protected] # recepient for test mail
@maddie
maddie / main.go
Last active September 2, 2020 09:12
Migrate BadgerDB v1 to BadgerDB v2 programatically
package main
import (
"flag"
"log"
bv1 "github.com/dgraph-io/badger"
bv2 "github.com/dgraph-io/badger/v2"
)
@maddie
maddie / update-v2ray-geo.sh
Last active November 1, 2023 16:10
Script for updating V2Ray geoip.dat and geosite.dat on OpenWRT
#!/bin/sh
LOGGER_TAG=v2ray-geodata-updater
log () {
echo $@
logger -t $LOGGER_TAG "$@"
}
log "fetching geoip url..."
@maddie
maddie / find_duplicates.go
Last active July 5, 2018 16:59
find duplicate files in a directory recursively
package main
import (
"crypto/sha1"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"os"
@maddie
maddie / genesis_public_key
Last active March 26, 2018 01:56
genesis_public_key
04a8dd82bbe099f689fbb577f2c1adce05795770f256f1b98f19e60e6a080878fd4ffe6d1c68cf66043070134bba0505da873c53d1f9b9097914b20dc214ea2aba;andrewallaway

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }