Skip to content

Instantly share code, notes, and snippets.

View rakyll's full-sized avatar

Jaana Dogan rakyll

View GitHub Profile
@rakyll
rakyll / gist:9d6d8b7aa7a3b05b7eba
Created July 11, 2014 23:17
HAS_ANCESTOR queries
{
"projection": [],
"kinds": [{
"name": "Company"
}],
"filter": {
"compositeFilter": {
"filters": [{
"propertyFilter": {
"property": {
conf, err := google.NewServiceAccountJSONConfig(
"/Users/jbd/Downloads/burcu-gce-a44c472553f8.json",
storage.ScopeFullControl)
if err != nil {
log.Fatal(err)
}
b := storage.New(conf.NewTransport()).Bucket("bamboo-shift-504")
b.Copy("filename1", &storage.ObjectInfo{
Bucket: "another-bucket",
@rakyll
rakyll / gist:5521097
Created May 5, 2013 15:21
Ugly but AppdataPreferencesSyncer is a singleton.
AppdataPreferencesSyncer syncer =
AppdataPreferencesSyncer.get(getApplicationContext());
syncer.setPreferences(mPreferences);
syncer.setCredential(credential);
{
"_id": "_design/rate",
"_rev": "57-8b50b18751ef1f968628606142c84e27",
"language": "javascript",
"views": {
"five_minutes": {
"map": "function(doc) {\n var date = new Date(doc.createdAt).toISOString();\n var key = date.substr(0, 15);\n \n key += (parseInt(date.substr(15,1), 10) < 5) ? '0' : '5';\n emit([key + \":00Z\", doc.tag], 1);\n}",
"reduce": "function(keys, values) {\n return sum(values);\n}"
}
},
{
"_id": "_design/tags",
"_rev": "70-302fb6b6b2181d491b4cc75a6c0c29b5",
"language": "javascript",
"views": {
"relations": {
"map": "function(doc) {\n var mainTag = doc.tag.toLowerCase();\n var tags = doc.text.toLowerCase().split(' ').filter(function (word) {\n return word[0] === '#' && word !== mainTag;\n });\n\n tags.forEach(function(tag) {\n emit(mainTag, tag);\n });\n}",
"reduce": "function(keys, values, rereduce) {\n var mapping = {};\n \n if (rereduce) {\n values.forEach(function (val) {\n for (var tag in val)\n mapping[tag] = (mapping[tag] || 0) + val[tag];\n });\n } else {\n values.forEach(function (val) {\n mapping[val] = (mapping[val] || 0) + 1;\n });\n }\n \n return mapping;\n}"
},
"relations_recent": {
@rakyll
rakyll / README
Last active January 27, 2016 21:47
You need to run tests with:
go test -tags=test
@rakyll
rakyll / main.go
Last active February 9, 2017 05:41
$ go run main.go
fatal error: concurrent map writes
goroutine 34 [running]:
runtime.throw(0x89200, 0x15)
/Users/jbd/go/src/runtime/panic.go:530 +0x90 fp=0xc8200806d8 sp=0xc8200806c0
runtime.mapassign1(0x5e940, 0xc8200161e0, 0xc8200807a0, 0xc8200807a0)
/Users/jbd/go/src/runtime/hashmap.go:445 +0xb1 fp=0xc820080780 sp=0xc8200806d8
main.main.func1(0xc8200161e0, 0xc82000a170)
/Users/jbd/src/github.com/rakyll/experimental/maprace/main.go:11 +0x50 fp=0xc8200807b0 sp=0xc820080780
@rakyll
rakyll / main.go
Created January 16, 2018 20:10
Go Spanner Client with OpenCensus
// Copyright 2018 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// Sample contains a simple program that
// uses Google Spanner Go client, and reports metrics
// and traces for the outgoing requests.
package main
import (
@rakyll
rakyll / a.json
Last active September 18, 2018 21:10
[ {"name": "GET /", "ph": "X", "ts": 123, "dur": 234, "pid": 2343, "tid": 2347,
"args": {
"first": 1,
"http.host": "google.com",
"http.path": "/"
} },
{"pid":64570,"tid":775,"ts":97240123396,"ph":"X","cat":"devtools.timeline","name":"XHRReadyStateChange","args":{"data":{"url":"https://help.github.com/enterprise/2.12/user/articles/about-pull-requests/","readyState":2,"frame":"8950C34E0C7436F9C0E4A0F9706A67EF"}},"dur":10,"tdur":11,"tts":7027341},
{"pid":64570,"tid":775,"ts":97240123476,"ph":"X","cat":"devtools.timeline","name":"XHRReadyStateChange","args":{"data":{"url":"https://help.github.com/enterprise/2.12/user/articles/about-pull-requests/","readyState":3,"frame":"8950C34E0C7436F9C0E4A0F9706A67EF"}},"dur":11,"tdur":10,"tts":7027422},
{"pid":64570,"tid":775,"ts":97240123796,"ph":"X","cat":"devtools.timeline","name":"XHRReadyStateChange","args":{"data":{"url":"https://help.github.com/enterprise/2.12/user/articles/about-pull-requests/","readyState":4,"frame":"8950C34E0C7436F9C0E4A0F9706A67EF"}},"dur
@rakyll
rakyll / gcp-on-board
Last active July 24, 2019 17:53
Average HTTP latency to GCP regions onboard (SFO to SAN)
0. [global] 787.975869ms
1. [us-west2] 834.117729ms
2. [us-central1] 886.366904ms
3. [us-east1] 896.880435ms
4. [us-east4] 897.410807ms
5. [northamerica-northeast1] 927.494263ms
6. [asia-northeast2] 1.016238175s
7. [europe-west2] 1.040375874s
8. [asia-northeast1] 1.04106759s
9. [europe-west3] 1.04748383s