Skip to content

Instantly share code, notes, and snippets.

@hiroosak
hiroosak / content.html
Last active April 21, 2018 08:44
html/template で layoutファイルとcontentファイルを分けたい場合
{{ define "content" }}
<p>Hello {{ .Name }}</p>
{{ end }}
package tmpl
import (
"bytes"
"fmt"
"html/template"
)
func Parser(tmpl *template.Template) string {
var b bytes.Buffer
// copystruct is a package that copy to structure
package copystruct
import (
"fmt"
"reflect"
)
// copyStruct is a struct value copy to a new struct.
func copyStruct(src interface{}, dst interface{}) error {
@hiroosak
hiroosak / app.go
Created August 12, 2014 10:29
Goで外部リクエストが関わる処理をテストする ref: http://qiita.com/taizo/items/32d895e35397336bf285
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func fetch(url string) []byte {
$ go get github.com/go-sql-driver/mysql
@hiroosak
hiroosak / file1.go
Last active August 29, 2015 14:04
Go言語でhttpサーバーを立ち上げてHello Worldをする ref: http://qiita.com/taizo/items/bf1ec35a65ad5f608d45
package main
import (
"fmt"
"net/http"
)
type String string
func (s String) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@hiroosak
hiroosak / async.cc
Created July 28, 2014 21:38
node-gypを使ってnative addonを作成する (2) - 非同期関数をとりあえず作ってみる ref: http://qiita.com/taizo/items/44bf02878f5fc0842703
#include <node.h>
#include <v8.h>
using namespace v8;
typedef struct asyncData {
Persistent<Function> callback;
const char *result;
} AsyncData;
@hiroosak
hiroosak / binding.gyp
Created July 26, 2014 16:13
node-gypを使ってnative addonを作成する (1) - Hello World ref: http://qiita.com/taizo/items/dee4ee85fe6f4e28428b
{
"targets": [
{
"target_name": "addon",
"sources": [
"hello.cc"
]
}
]
}
@hiroosak
hiroosak / index.html
Last active August 29, 2015 14:04
画像表紙テスト
<!doctype html>
<html>
<head>
<title>-</title>
<style>
body {
overflow: hidden;
margin: 0;
padding: 0;
@hiroosak
hiroosak / app.js
Created July 22, 2014 22:54
テストランナーkarmaをとりあえず使ってみる方法 ref: http://qiita.com/taizo/items/04c80dcd2841cb1119a8
var Foo = function() {
};
Foo.prototype.sum = function(x, y) {
return x + y;
};
Foo.prototype.div = function(x, y) {
return x / y;
};