Skip to content

Instantly share code, notes, and snippets.

View bgnori's full-sized avatar

Noriyuki Hosaka bgnori

  • Itabashi, Tokyo, Japan
View GitHub Profile
from PIL import Image, ImageDraw
def blend(p, q, t):
"""
>>> blend((1.0, 1.0), (1.0, 2.0), 0)
(1.0, 1.0)
@bgnori
bgnori / cicada.py
Created February 23, 2014 16:48
素数ゼミのシミュレーション. 同じ年に羽化した個体がランダムに2匹組み合わさって2匹の子供を残す. ある年に生まれる子孫は同じ年数幼生で過ごす様にはなるが、1つの種類しか生き残らない
#!/usr/bin/python
import heapq
from random import randint, shuffle
import sys
import os
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
r := make([][]uint8, dx)
for j:=0; j < dy; j+=1 {
row := make([]uint8, dx)
for i:=0; i<dx; i+=1 {
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
package main
import (
"fmt"
"code.google.com/p/go-tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
package main
import (
"code.google.com/p/go-tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
package main
import (
"fmt"
)
type T interface{}
type S interface{}
type U interface{}
@bgnori
bgnori / gist:9214691
Created February 25, 2014 18:20
型アサーション(type assertion) と chan
package main
import (
"fmt"
"reflect"
)
type chanS interface{
Type() reflect.Type
}
@bgnori
bgnori / gist:9221353
Created February 26, 2014 01:02
とりあえずbuildできるところまではきた. deadlockしてしまう.
package main
import (
//"reflect"
"fmt"
)
type T interface{}
type S interface{}
type U struct {
@bgnori
bgnori / gist:9286699
Last active August 29, 2015 13:56
BF 習作, string <-> byteがださい. fizzbazzも動いた.
package main
import "fmt"
type BF struct {
pc int
ptr int
mem [3000]byte