Skip to content

Instantly share code, notes, and snippets.

@sshell
Created July 8, 2020 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sshell/649fbdf713e5e35eff69647891eb563c to your computer and use it in GitHub Desktop.
Save sshell/649fbdf713e5e35eff69647891eb563c to your computer and use it in GitHub Desktop.
faviconer.go
package main
import (
"encoding/base64"
"fmt"
"io/ioutil"
"net/http"
"github.com/twmb/murmur3"
)
func main() {
final := ""
fix := 76
s := make([]string, 0)
// pull file from the internet
f, _ := http.Get("https://medium.com/favicon.ico")
content, _ := ioutil.ReadAll(f.Body)
str := base64.StdEncoding.EncodeToString(content)
// slice up string
for i := 0; i*fix+fix < len(str); i++ {
it := str[i*fix : i*fix+fix]
s = append(s, it)
}
// find last piece of string
findlen := len(s) * fix
last := str[findlen:] + "\n"
// put it all together
for _, s := range s {
final = final + s + "\n"
}
str = final + last
// do murmurhash3 stuff
mm3 := murmur3.StringSum32(str)
// convert uint32 to int32
fmt.Println(int32(mm3))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment