Skip to content

Instantly share code, notes, and snippets.

View hogedigo's full-sized avatar

Daigo Ikeda hogedigo

View GitHub Profile
@hogedigo
hogedigo / TestServlet.java
Last active August 29, 2015 14:26
Queue#addAsync with Tx loses tasks sometimes.
package asynctqtest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.logging.Logger;
@hogedigo
hogedigo / aets.go
Last active December 5, 2018 10:04
GAE/GoでTaskQueueのテスト(単純なPUSHキューAddだけ)
// Test Support Context
package aets
import (
"appengine"
"appengine/taskqueue"
"appengine_internal"
tqpb "appengine_internal/taskqueue"
"sync"
"time"
@hogedigo
hogedigo / getmultierr.go
Created February 18, 2015 13:34
GetMutiでentityがなかった場合
package getmultitest
import (
"appengine"
"appengine/datastore"
"fmt"
"net/http"
)
func init() {
@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 / 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 / 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 / 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 / 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 / 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 / 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 {