Skip to content

Instantly share code, notes, and snippets.

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

懒人旭 iammeizu

💭
I may be slow to respond.
View GitHub Profile
@miguelmota
miguelmota / interface_to_bytes.go
Last active February 24, 2024 00:07
Golang interface to bytes using gob encoder
package main
import (
"encoding/gob"
"bytes"
)
func GetBytes(key interface{}) ([]byte, error) {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
@nstogner
nstogner / retry.go
Last active January 17, 2023 06:48
Go: Simple retry function
func retry(attempts int, sleep time.Duration, fn func() error) error {
if err := fn(); err != nil {
if s, ok := err.(stop); ok {
// Return the original error for later checking
return s.error
}
if attempts--; attempts > 0 {
time.Sleep(sleep)
return retry(attempts, 2*sleep, fn)
#!/bin/bash
################################################################################
### OpenCV2 Installation Script ###
################################################################################
# Source code at https://github.com/arthurbeggs/scripts #
################################################################################
# #
# Feel free to copy and modify this file. Giving me credit for it is your #
# choice, but please keep references to other people's work, which I don't #