This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.function.Function; | |
import java.util.function.Predicate; | |
// 任意のListにmap, filterメソッドを追加する。 | |
interface FunctionalList<T> extends List<T> { | |
default <R> FunctionalList<R> map(Function<T, R> f) { | |
FunctionalList<R> list; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Java8 デフォルト実装の使用例 | |
*/ | |
package defaultif; | |
import java.io.File; | |
import java.io.IOException; | |
import java.io.UncheckedIOException; | |
import java.nio.file.Files; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package server; | |
import java.io.File; | |
import java.io.IOException; | |
import java.io.OutputStream; | |
import java.net.InetSocketAddress; | |
import java.nio.file.FileSystem; | |
import java.nio.file.FileSystems; | |
import java.nio.file.FileVisitResult; | |
import java.nio.file.Files; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.co.ulsystems.javafx; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.function.Consumer; | |
/** | |
* execute lanmda statement if value is not null or empty | |
* | |
* this replace following code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scala snippets | |
// read STDIO examples. | |
// read single line. | |
def singleLine():String={ | |
readLine() | |
} | |
// read from redirect(e.g, scala Test.scala < some.txt) | |
def simpleExample():Seq[String]={ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.BufferedWriter; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.OutputStreamWriter; | |
import java.nio.charset.Charset; | |
import java.nio.file.FileSystem; | |
import java.nio.file.FileSystems; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def readStdIn() | |
input = [] | |
while line = gets | |
input << line.chomp | |
end | |
return input | |
end | |
# 1.9 | |
def readFile(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.io.Source | |
import scala.xml._ | |
/** アンパンマンのサイトからキャラクター一覧を引っ張って適当なHTMLにする。 | |
あとは関数型プログラム、関数合成の練習 */ | |
object AmpFriends { | |
case class Friend(name:String, img:String) | |
val base ="http://anpanman.jp/sekai/" | |
val imgBase ="http://anpanman.jp/sekai/friends/" | |
val loadFromUrl:String => String = Source.fromURL(_).mkString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ConcurrentHashMap; | |
public class ConcurrentTest { | |
private static ConcurrentHashMap<Integer, Integer> map = new ConcurrentHashMap<Integer, Integer>(); | |
private static class Update extends Thread { | |
@Override | |
public void run() { | |
for (int i = 0; i < 100; i++) { | |
// forrowing code is incorrect. (probabry happens race condition) | |
if (!map.contains(i)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* Hook.io にて、 Alexa Skill を実行するサンプルです | |
*/ | |
/** | |
* スピーチ内容を作成する関数です。 | |
* 通常、各イベントの処理の最後にbuildResponseと組み合わせて、次のように実行します。 | |
* |
OlderNewer