Skip to content

Instantly share code, notes, and snippets.

View sinmetal's full-sized avatar

sinmetal sinmetal

View GitHub Profile
package main
import (
"fmt"
"log"
"net/http"
"cloud.google.com/go/compute/metadata"
)
@sinmetal
sinmetal / cron.yaml
Created July 12, 2017 01:43
DatastoreBackup Sample
cron:
- description: Daily Backup
url: /_ah/datastore_admin/backup.create?name=BackupToCloud&kind=Billing&kind=Project&filesystem=gs&gs_bucket_name=datastore-backup&queue=backup
schedule: every day 02:00
timezone: Asia/Tokyo
target: ah-builtin-python-bundle
- description: Billing Report to Slack
url: /cron/1/billing/ratio
schedule: every day 10:00
timezone: Asia/Tokyo
@sinmetal
sinmetal / dns-ch.sh
Created April 18, 2017 10:04
Cloud DNSのRecordを、動作しているCompute EngineのGlobal IP Addrに変更する。元ネタは http://stackoverflow.com/questions/34726498/how-to-update-google-cloud-dns-with-ephemeral-ip-for-an-instance
#!/bin/bash
ttlify() {
local i
for i in "$@"; do
[[ "${i}" =~ ^([0-9]+)([a-z]*)$ ]] || continue
local num="${BASH_REMATCH[1]}"
local unit="${BASH_REMATCH[2]}"
case "${unit}" in
weeks|week|wee|we|w) unit=''; num=$[num*60*60*24*7];;
package cpt
import (
"google.golang.org/appengine"
"golang.org/x/net/context"
)
// IsProduction is Production環境で動いていればtrueを返す
func IsProduction(c context.Context) bool {
[
{
"name": "documentSentiment",
"type": "RECORD",
"fields": [
{
"name": "magnitude",
"type": "FLOAT",
"mode": "NULLABLE"
},
package main
import (
"fmt"
"log"
"github.com/zabawaba99/firego"
)
func main() {
@sinmetal
sinmetal / naturalLanguageAPIResponseSchema.json
Last active July 29, 2016 01:59
Cloud Natural Language APIのResponseをBigQueryに入れるためのschema
[{
"name": "entities",
"mode": "repeated",
"type": "record",
"fields": [{
"name": "mentions",
"mode": "repeated",
"type": "record",
"fields": [{
"name": "text",
package main
import (
"net/http"
)
func init() {
http.HandleFunc("/.well-known/acme-challenge/", handlerLetsencypt)
}
@sinmetal
sinmetal / gcs_sample.go
Created June 24, 2016 05:32
example google.DefaultClient()
package gcs_sample
import (
"net/http"
"fmt"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
"golang.org/x/oauth2/google"
@sinmetal
sinmetal / matchArray.bjs
Created May 27, 2016 09:41
keyword, arrayを渡して、arrayに含まれる文字を正規表現で探してマッチしたら、マッチした文字列を返すBQのUDF
function passthroughExample(row, emit) {
var output = [];
row.keyword. forEach(function(element, index, array) {
var match = row.data.match(element);
if (match) {
output.push(match[0]);
}
})
emit({output:output})
}