Skip to content

Instantly share code, notes, and snippets.

View matryer's full-sized avatar
🔨
Building things at @grafana

Mat Ryer matryer

🔨
Building things at @grafana
View GitHub Profile
@matryer
matryer / Accordian.svelte
Last active November 20, 2020 19:03
Simple Accordian component for Svelte (from https://firesearch.dev)
<script lang='ts'>
import { slide } from 'svelte/transition'
export let open: boolean = false
export function toggle() {
open = !open
}
</script>
<a
href='#open'
on:click|preventDefault={ toggle }
@matryer
matryer / full-text-search-on-app-engine.js
Created November 14, 2020 09:56
Full Text Search with Google App Engine
// Firesearch brings full-text search to Google App Engine
// This sample shows how easy it is to use in JavaScript.
// You run this in Cloud Run, it connected to Cloud Firestore,
// and you write code that interacts with the Firesearch API
// to bring a high performance, highly accurate search experience
// to your apps and websites.
// add or update a document
indexService.putDoc({
indexPath: "firesearch/indexes/my-search-index",
@matryer
matryer / firesearch-sample.go
Created November 14, 2020 09:52
Firesearch Go SDK sample showing how to do full-text search in Google Cloud Platform
// for more information, see https://firesearch.dev
// add or update a document
_, err := indexService.PutDoc(PutDocRequest{
IndexPath: "firesearch/indexes/my-search-index",
Doc: Doc{
ID: "document-1",
SearchFields: []SearchField{
{
Key: "body",
@matryer
matryer / firesearch-sample.js
Last active November 14, 2020 09:52
Firesearch JavaScript API sample showing how to do full-text search in Google Cloud Platform
// for more information, see https://firesearch.dev
// add or update a document
indexService.putDoc({
indexPath: "firesearch/indexes/my-search-index",
doc: {
id: "document-1",
searchFields: [
{
key: "body",
Due to some upgrades that are taking place, Gopherize.me is temporarily unavailable.
It will be back this week.
Thanks for your patience.
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
// all the peeps in a map ensures no duplicates
@matryer
matryer / async.go
Last active August 17, 2020 02:58
Async helper function for Go.
// Released under MIT License
package main
import "sync"
// asyncFn is a function that can be run asychronously by
// async.
type asyncFn func() error
@matryer
matryer / slack.go
Created March 12, 2020 09:28
Post messages to Slack in Go
package main
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
"strings"
"time"
package main
import (
"bufio"
"fmt"
"os"
"os/exec"
)
var speakers = map[string]bool{
// handleProcess runs the incoming chunk through an exif decoder and
// writes the results to the response.
func handleProcess(w http.ResponseWriter, r *http.Request) {
startOffsetMS, err := strconv.Atoi(r.FormValue("startOffsetMS"))
if err != nil {
http.Error(w, "exif: "+err.Error(), http.StatusBadRequest)
return
}
endOffsetMS, err := strconv.Atoi(r.FormValue("endOffsetMS"))
if err != nil {