Skip to content

Instantly share code, notes, and snippets.

View hogedigo's full-sized avatar

Daigo Ikeda hogedigo

View GitHub Profile
@hogedigo
hogedigo / index.js
Created February 20, 2014 00:19
Google Spreadsheets APIでGoogleアカウントユーザーのスプレッドシートからデータを取得する。
var fs = require("fs");
var readline = require("readline");
var gapi = require("googleapis");
var CLIENT_ID = "Your client id here";
var CLIENT_SECRET = "Your client secert here";
var REDIRECT_URL = "Your redirect url here";
var SCOPE = "https://spreadsheets.google.com/feeds";
var TOKENS_FILEPATH = "./tokens.json";
@hogedigo
hogedigo / future_sample.go
Created February 21, 2014 00:54
future sample
package main
import "fmt"
type task struct {
url string
result chan string
}
func main() {
@hogedigo
hogedigo / hello.go
Last active August 29, 2015 13:57
GAE/Goでmartini
package hello
import (
"github.com/codegangsta/martini"
"net/http"
)
func init() {
m := martini.Classic()
m.Get("/hello/:name", func(params martini.Params, w http.ResponseWriter) string {
@hogedigo
hogedigo / goab.go
Created March 9, 2014 23:56
go study(implementing apache benchmark)
package main
import (
"fmt"
"flag"
"time"
)
type result struct {
seq int
@hogedigo
hogedigo / gist:f0853fffcfcb3819a4fd
Created July 5, 2014 11:13
GAE/Go save struct to memcache as JSON
memcache.JSON.Add(c, &memcache.Item{Key:"test", Object: struct {
Name string
Address string
} {
"hoge",
"moke",
}})
@hogedigo
hogedigo / sortjsonkeys.js
Created September 9, 2014 11:34
sorting keys in JSON
var json = JSON.stringify(data, function(key, value) {
if (value instanceof Object === false || Object.getPrototypeOf(value) !== Object.prototype) {
return value;
}
var keys = Object.keys(value);
keys.sort();
var newValue = {};
keys.forEach(function(key) {
newValue[key] = value[key];
});
@hogedigo
hogedigo / data.go
Created September 27, 2014 14:35
reflect unexported field
package data
type s struct {
a, b string
}
func NewS(a, b string) s {
return s{a, b}
}
@hogedigo
hogedigo / gist:cc93ecadc73394c20ec2
Created October 27, 2014 05:34
access scope outside component.
function test() {
var scope = angular.element(document.getElementById('test')).scope();
scope.$apply(function() {
scope.test = 'this is test!!!';
});
}
@hogedigo
hogedigo / gist:100a1e978f887eff6ceb
Created December 20, 2014 04:50
マルチバイトを考慮したreverse
package tool
import (
"bytes"
)
func Reverse(s string) string {
runes := make([]rune, 0, 10)
for _, r := range s {
runes = append(runes, r)
@hogedigo
hogedigo / getmultierr.go
Created February 18, 2015 13:34
GetMutiでentityがなかった場合
package getmultitest
import (
"appengine"
"appengine/datastore"
"fmt"
"net/http"
)
func init() {