Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lzambarda's full-sized avatar
👻
Boo!

Luca Zambarda lzambarda

👻
Boo!
View GitHub Profile
@lzambarda
lzambarda / shellpaper.sh
Last active July 10, 2022 20:56
Automatically set macOS desktop backgorund wallpaper image using pexels' APIs
#!/bin/bash
# This script can be launched at login time by creating an app wrapper with Automator.
# 1. open Automator
# 2. create a new application
# 3. search for and add "Run shell script"
# 4. either copy the code below or invoke it
# 5. save your new "app"
# 6. go to "System Preferences > Users & Groups > Login items" and add the new app
@lzambarda
lzambarda / powerset.go
Last active April 20, 2022 11:56
Find powerset in go
// https://play.golang.com/p/nVrmIlgzZac
package main
import (
"fmt"
)
// FindPowerSet does not include the empty set.
// The imput set must already be distinct values.
func FindPowerSet(set []string) (powerset [][]string) {
@lzambarda
lzambarda / humanize_size_si.go
Created February 23, 2022 16:24
Humanize size SI
// Can be easily modified to work with binary with a unitStep of 1024 and iB as a suffix instead of B.
func HumanizeSize(b int64) string {
const unitStep = 1000
const units = "BkMGTPE"
v := float64(b)
exp := 0
for v > unitStep {
v /= unitStep
exp++
}
@lzambarda
lzambarda / generator.sh
Last active March 8, 2022 15:47
Bash script to use with go generate to register queries on the fly
# This script generates a register_queries.go file which uses embed
# to pack queries in a binary.
#
# The generated file will panic if additional queries are added to
# the query folder.
#
# This can then be hooked up in any go file with:
#
# //go:generate sh ./generator.sh query queries
# var queries map[string]string
@lzambarda
lzambarda / google-keep-to-standard-notes.js
Last active January 5, 2023 15:24
Google Keep to Standard Notes converter
/**
* Basic Google Keep to Standard Notes importer made by
* https://github.com/lzambarda because he was too lazy to manually migrate his
* notes.
*
* How to use:
* 1) Use Google Takeout to export a copy of your Keep notes. The folder you
* will download will contain two files for each note:
* - a sassy html visually resembling your note
* - a tasty JSON file containing the true format of the note