Skip to content

Instantly share code, notes, and snippets.


Gustavo Henrique gustavohenrique

View GitHub Profile
View openurl.go
func openURL(url string) error {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", "http://localhost:4001/").Start()
case "darwin":
err = exec.Command("open", url).Start()
gustavohenrique /
Created Oct 27, 2021
Building a recommendation engine inside Postgres with python and pandas

I'm a big fan of data in general. It can tell you a lot about what users are doing and help gain all sorts of insights. One such aspect is in making recommendations based on past history or others that have made similar choices. Years ago in fact I wrote a small app that I used among some friends to see if I could recommend wines based on how other ones were rated. It was a small app I shared among just a handful of friends, some with similar taste some with different taste. It at first was largely an academic exercise of writing a recommendation engine, but if I could find some new wines I liked along the way great. Turns out it was a lot more effective at recommending things than I expected, even with only a small handful of wines rated.

The other thing I'm a fan of is Postgres (not a big surprise there), and earlier today I was starting to wonder why couldn't I do more machine learning directly inside it. Yeah, there is madlib, but what if I wanted to write my own recommendation engine. So I set out

export WG_ADMIN_PASSWORD=`xxd -l4 -ps /dev/urandom`
export WG_WIREGUARD_PRIVATE_KEY=`docker run --rm place1/wg-access-server wg genkey` # OC+tBxEc/OFBFEO6Kcn92CWjaahBNBtcAgfhkjNII0E=
docker run \
-d \
--name wireguard \
--cap-add NET_ADMIN \
--device /dev/net/tun:/dev/net/tun \
-v wg-access-server-data:/data \
gustavohenrique /
Last active Jul 9, 2021
Seafile is an open source alternative to Dropbox



Create the LXD container

# Create LXD profile for data storage
mkdir /home/gustavo/Cloud
cat > ~/Cloud/cloud.profile <<EOF
gustavohenrique /
Created Jun 29, 2021
HTML + JS + SharedWorker



  • Worker does not have DOM access
  • console.log does not work
  • The state is shared between tabs


View dgraph-client.go
package main
import (
gustavohenrique /
Last active Nov 27, 2021
Basic commands to run LXD containers


sudo snap install lxd && lxd init


Default repositories:


How do I set and unset shell variable options?

I use -o to set and +o to unset. Example:

# Exit immediately
set -o errexit

# Don't exit immediately
set +o errexit
gustavohenrique /
Last active Dec 7, 2021
Arch Linux installation and setup


loadkeys us-acentos


Wireless connection

View read-file-performance-golang.go
func main() {
s := time.Now()
args := os.Args[1:]
if len(args) != 6 { // for format LogExtractor.exe -f "From Time" -t "To Time" -i "Log file directory location"
fmt.Println("Please give proper command line arguments")
startTimeArg := args[1]
finishTimeArg := args[3]