Skip to content

Instantly share code, notes, and snippets.

View taka011239's full-sized avatar

takafumi tsuchida taka011239

View GitHub Profile
@taka011239
taka011239 / hello.js
Created November 24, 2012 11:22 — forked from shigeki/hello.js
第1回Node.js入門勉強会 レポート課題
var http = require('http');
server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
server.close();
});
server.listen(8080, 0, function () {
console.log('Server running at http://localhost:8080/');
});
@taka011239
taka011239 / treepredict.py
Created February 12, 2013 09:37
集合知プログラミング7章
from PIL import Image, ImageDraw
my_data = [line.split('\t') for line in file('decision_tree_example.txt')]
class decisionnode:
def __init__(self, col = -1, value = None, results = None, tb = None, fb = None):
self.col = col
self.value = value
self.results = results
self.tb = tb
self.fb = fb
plus :: Int -> Int -> Int
plus m 0 = m
plus m n
| n > 0 = plus m (n - 1) + 1
| n < 0 = plus m (n + 1) - 1
minus :: Int -> Int -> Int
minus m 0 = m
minus m n
| n > 0 = minus m (n - 1) - 1
package main
import "fmt"
type EvalFunc func(interface{}) (interface{}, interface{})
func BuildLazyEvaluator(evalFunc EvalFunc, initState interface{}) func() interface{} {
retValChan := make(chan interface{})
loopFunc := func() {
package main
import (
"fmt"
"sync"
)
func main() {
ch := make(chan int)
var wg sync.WaitGroup
@taka011239
taka011239 / closure.go
Last active August 29, 2015 14:02
Goのclosureへのパラメータの渡し方
package closure
type Request struct {
Url string
}
func Closure1(reqs []*Request) {
for _, req := range reqs {
go func(req *Request) {
req.Url = "http://example.org"
@taka011239
taka011239 / buffer channelとunbuffer channelの挙動差異.md
Last active August 29, 2015 14:02
buffer channelとunbuffer channelの挙動差異

buffered channelとunbuffered channelの挙動の違い

channelにbufferがあるかないかで、channelを使った同期の挙動が異なる。

詳しくは、公式のThe Go Memory Modelを参照。

Rule

以下のルールに従う。 bufferの有無で、送信と受信の優先順位が変わるので注意。

@taka011239
taka011239 / gist:9e0d10c3294278dab2be
Last active August 29, 2015 14:03
Go温泉 #2 + #GoCart

Go温泉 #2 + #GoCart

Go 温泉 + GoCart をしに行きましょう!

注意

GoCart の方は人数制限が 6 人なので、 温泉参加者が全員走れるとは限りません。 ご注意下さい。

日程

@taka011239
taka011239 / Linux.sh
Last active August 29, 2015 14:04
CLIでbatteryのステータスを%表示
acpi | grep -oE \[0-9\]+%
@taka011239
taka011239 / index.js
Created April 20, 2015 03:26
requirebin sketch
var http = require('http');
http.createServer(function(req, res) {
if(req.method === 'POST') {
res.end('POST');
console.log('POST');
} else if (req.method === 'GET') {
res.end('GET');
console.log('GET');
} else {