Skip to content

Instantly share code, notes, and snippets.

View kwmt's full-sized avatar
🏠
Working from home

Yasutaka Kawamoto kwmt

🏠
Working from home
View GitHub Profile
@kwmt
kwmt / AppController.java
Created July 10, 2014 09:38
volley sample
package net.kwmt27.volleysample.app;
import android.app.Application;
import android.text.TextUtils;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
dir := createTestDir([]templateFile{
// T0.tmpl はT1をコールします。
{"T0.tmpl", `T0 invokes T1: ({{template "T1"}})`},
// T1.tmpl T2をコールするテンプレートを"T1"として定義しています。
{"T1.tmpl", `{{define "T1"}}T1 invokes T2: ({{template "T2"}}){{end}}`},
// T2.tmpl は"T2"としてテンプレートを定義しています。
{"T2.tmpl", `{{define "T2"}}This is T2{{end}}`},
})
// main関数終了後、作成したディレクトリを削除します。
defer os.RemoveAll(dir)
// まず、FuncMapでカスタム関数名と処理したい関数を登録します。
funcMap := template.FuncMap{
// "title"はテンプレートでコールされる関数名となります。
"title": strings.Title,
}
// 先ほどの関数をテストするために、シンプルなテンプレートを定義します。
// 私たちはいくつかの方法で入力されたテキストを表示します:
// - オリジナルテキスト
// - "title"をコール
<!doctype html>
<html lang="ja">
<head>
<title>jQuery mobile with Google maps - Google maps jQuery plugin</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false&amp;language=ja"> </script>
<script type="text/javascript">
var cityList = [
@kwmt
kwmt / debuglog.go
Last active December 16, 2015 00:09
//定義
var debug = debugT(false)
type debugT bool
func (d debugT) Printf(format string, args ...interface{}) {
if d {
log.Printf(format, args...)
}
}
@kwmt
kwmt / nodejsのインストールとexpressのインストール
Last active December 17, 2015 06:49
node.jsをインストールし、使えることを確認した後、ウェブアプリケーションフレームワークであるexpressをインストールして動かしてみるところまで。
1.Node.jsをダウンロード
http://nodejs.org/download/
http://nodejs.org/dist/v0.10.5/node-v0.10.5-darwin-x64.tar.gz
2.解凍
$ tar xvzf node-v0.10.5-darwin-x64.tar.gz
$ cd node-v0.10.5-darwin-x64/bin
3.コマンドが使えることを確認して
$ ./node --version
標準のnodeはソースを編集後の反映確認は、
Ctrl-C押して再起動する必要があったが、
ブラウザリロードで反映ができるようにするツール
$ npm install -g nodemon
$ nodemon app.js
で起動しておく
@kwmt
kwmt / drawline.go
Created July 11, 2013 01:43
Draws a line between the coordinates in the xy list. Pythonの http://effbot.org/imagingbook/imagedraw.htm#tag-ImageDraw.Draw.line のようなことしたい
package main
import (
"github.com/akavel/polyclip-go"
"github.com/akavel/polyclip-go/polyutil"
"image"
"image/color"
"image/draw"
"image/png"
"os"
@kwmt
kwmt / zipfile.py
Created July 19, 2013 15:57
How to use zipfile
def channel(nothing):
import zipfile
import re
zip = zipfile.ZipFile('channel.zip')
comments = ''
while True:
s = zip.open(nothing+'.txt', 'r').read()
comments += zip.getinfo(nothing+'.txt').comment
@kwmt
kwmt / archive_zip.go
Last active December 20, 2015 00:18
How to use "archive/zip"
//pythonchallenge 6
//問題:http://www.pythonchallenge.com/pc/def/channel.html
//ヒント:channel.zipにreadme.txtがある
//使い方:% go run archive_zip.go 90052
package main
import (
"archive/zip"
"fmt"
"io/ioutil"