This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func handleGreeter() http.Handler { | |
// TODO: do any setup stuff here | |
//... like prepare a template: | |
tpl, err := template.ParseFiles("pages/_layout.html", "pages/gopher.html") | |
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
if err != nil { | |
// parsing the template failed? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"categories": [{ | |
"id": "artwork/010-Body", | |
"name": "Body", | |
"images": [{ | |
"id": "artwork/010-Body/blue_gopher.png", | |
"name": "blue gopher", | |
"href": "https://storage.googleapis.com/gopherizeme.appspot.com/artwork/010-Body/blue_gopher.png", | |
"thumbnail_href": "https://lh3.googleusercontent.com/2WSrI5x6u8LqWQ-xBzogIu3QrthPiawLH2zCPvrOgpMPU0K240di8pOKSwhz_IL0xiq5I2pBJkWrhyZDJeAPWD4=s71" | |
}, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ArtworkResponse struct { | |
Categories []Category `json:"categories"` | |
TotalCombinations int `json:"total_combinations"` | |
} | |
type Category struct { | |
ID string `json:"id"` | |
Name string `json:"name"` | |
Images []Image `json:"images"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "8d784442c57fa1647259a37c277c6738b2d79d6a", | |
"images": [ | |
"artwork/010-Body/blue_gopher.png", | |
"artwork/020-Eyes/crazy_eyes.png", | |
"artwork/024-Glasses/all_black_sunglasses.png", | |
"artwork/027-Extras/laptop.png" | |
], | |
"original_url": "https://storage.googleapis.com/gopherizeme.appspot.com/gophers/8d784442c57fa1647259a37c277c6738b2d79d6a.png", | |
"url": "https://lh3.googleusercontent.com/dnKffPVPSYSIXhelVR8q88IM2tHxTQ8GgxlCezQjjqLrGvQI9roQIF71NfaOYN5m3txAfbpzyA48nklQMTZ5wgvG", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gentle scrolling | |
// Anything with an href that points to something on the page | |
// is gently scrolled to, rather than jumping. | |
// Everything else is left alone. | |
$("a[href]").click(function(e) { | |
var dest = $(this).attr('href') | |
dest = dest.substr(dest.indexOf('#')+1) | |
var destEl = $('[id="'+dest+'"]') | |
if (destEl.length > 0) { | |
e.preventDefault() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func waitForVideoboxResults(vb *videobox.Client, id string) (*videobox.VideoAnalysis, *videobox.Video, error) { | |
var video *videobox.Video | |
err := func() error { | |
defer fmt.Println() | |
for { | |
time.Sleep(2 * time.Second) | |
var err error | |
video, err = vb.Status(id) | |
if err != nil { | |
return err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// anonymise produces a new image with faces redacted. | |
// see https://becominghuman.ai/anonymising-images-with-go-and-machine-box-fd0866adb9f5 | |
func anonymise(src image.Image, faces []facebox.Face) image.Image { | |
dstImage := image.NewRGBA(src.Bounds()) | |
draw.Draw(dstImage, src.Bounds(), src, image.ZP, draw.Src) | |
for _, face := range faces { | |
faceRect := image.Rect( | |
face.Rect.Left, | |
face.Rect.Top, | |
face.Rect.Left+face.Rect.Width, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var fv = new machinebox.FaceVerify({ | |
facebox: "http://localhost:8080", | |
videoSelector: '#facePreview', | |
snapshotInterval: 1000, | |
error: function(error) { | |
if (!error) { | |
$('.ui.error.message').hide() | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
logclass | |
1. Run Classificationbox (see https://machinebox.io/docs/classificationbox) | |
2. Create a model and train it two classes with IDs: "noise" and "interesting" | |
3. Execute this command and pipe logs through it | |
Any logs that are not "noise" are passed through, others will be dimmed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makePrediction() { | |
// create a prediction request that includes some facts about | |
// the user. | |
var predictRequest = { | |
"inputs": [ | |
{"key": "user_age", "type": "number", "value": ""+user.age}, | |
{"key": "user_interests", "type": "list", "value": user.interests.join(',')}, | |
{"key": "user_location", "type": "keyword", "value": user.city} | |
] | |
} |