Skip to content

Instantly share code, notes, and snippets.

View kamatama41's full-sized avatar
😀
Hello

Shinichi Ishimura kamatama41

😀
Hello
View GitHub Profile
@kamatama41
kamatama41 / gotour_36.go
Created August 27, 2014 05:47
My answer of "a tour of Go #36( http://go-tour-jp.appspot.com/#36 )"
package main
import (
"math"
"code.google.com/p/go-tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
result := make([][]uint8, dx)
for x := 0; x < dx; x++ {
package main
import "fmt"
type Key struct {
Name string
}
type Vertex struct {
Lat, Long float64
@kamatama41
kamatama41 / gotour_41.go
Created August 27, 2014 06:21
My answer of "a tour of Go #44( http://go-tour-jp.appspot.com/#44 )"
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
now, next := 1, 0
return func() int {
new_now, new_next := next, now+next
@kamatama41
kamatama41 / gotour_56.go
Created August 27, 2014 07:14
My answer of "a tour of Go #56( http://go-tour-jp.appspot.com/#56 )"
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
@kamatama41
kamatama41 / file0.go
Created August 27, 2014 12:57
go初心者がgorutineとChannelを使ってみる ref: http://qiita.com/kamatama_41/items/466c7a26069e1c5c6212
package main
import (
"fmt"
"time"
)
func putChannel(c chan int, count int) {
for i := 0; i < count; i++ {
c <- i
package main
import (
"fmt"
"time"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@kamatama41
kamatama41 / XSSFSample.java
Created November 22, 2014 12:14
apache-poiのサンプル
package snippet;
import java.io.FileOutputStream;
import java.util.List;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
@kamatama41
kamatama41 / file0.java
Last active August 29, 2015 14:13
Java1.7以上では、abstractメソッドにもアノテーションが適用される ref: http://qiita.com/kamatama_41/items/950ac13f1864530ae3f3
public abstract class Parent {
public abstract Number someMethod();
}
public class Child extends Parent {
@Override
@Sample
public Integer someMethod() {
return 1;
}
@kamatama41
kamatama41 / 日本人.java
Last active August 29, 2015 14:15
永遠の17歳。 Java8でコンパイル・実行してね。
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
public class 日本人 {
protected final String name;
protected final OffsetDateTime birthdate;
public 日本人(String name, String birthdate) {
this.name = name;
// 2011-12-03T00:00:00+09:00
@kamatama41
kamatama41 / デフォルト引数テスト
Created September 16, 2015 05:28
デフォルト引数のテスト
```
irb(main):001:0> def hoge(a=1, b, c=3) a+b+c end
SyntaxError: (irb):1: syntax error, unexpected '=', expecting ')'
def hoge(a=1, b, c=3) a+b+c end
^
from /Users/shinichi/.rbenv/versions/2.2.3/bin/irb:11:in `<main>'
irb(main):002:0> def hoge(b, a=1, c=3) a+b+c end
=> :hoge
irb(main):003:0> hoge 100
=> 104