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.HashMap; | |
public enum SampleEnum { | |
AAA(1), | |
BBB(2), | |
CCC(3); | |
public static final int SIZE = java.lang.Integer.SIZE; | |
private int intValue; |
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.Objects; | |
public class Hoge { | |
public static void main(String[] args) { | |
Hoge hoge = Hoge.builder().address("Nagoya").age(23).build("nanashi-san"); | |
} | |
private String name; | |
private int age; |
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
$ npm install --save nosleep.js |
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 example | |
object EitherDemo { | |
def main(args: Array[String]) { | |
println(oddAndPositive(-1)) | |
println(oddAndPositive(0)) | |
println(oddAndPositive(1)) | |
println(oddAndPositive2(-1)) | |
println(oddAndPositive2(0)) | |
println(oddAndPositive2(1)) |
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
>>> from collections import Counter | |
>>> [ k for k, v in Counter([0,1,2,3,2,0,4]).items() if v > 1 ] | |
[0, 2] | |
>>> [ k for k, v in Counter("abcefacc").items() if v > 1 ] | |
['c', 'a'] |
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 javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Button; | |
import javafx.scene.layout.VBox; | |
import javafx.stage.Stage; | |
public class FxButton extends Application { | |
public static void main(final String[] args) { | |
Application.launch(args); |
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.Optional | |
object JavaLambda { | |
def main(args: Array[String]) { | |
val s = Optional.of("Scala") | |
val l = s.map((s:String)=>s.concat("!!!")).get() // Error!! | |
println(l) |
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
object EightQueens { | |
def queen(n: Int): List[List[Int]] = n match { | |
case 0 => List(List()) | |
case `n` => for {b <- queen(n - 1); q <- 0 to 7 if safe(q, b)} yield q :: b | |
} | |
def safe(q: Int, b: List[Int]) = b.indices.forall(i => checks(q, b, i)) | |
def checks(q: Int, b: List[Int], i: Int) = q != b(i) && (Math.abs(q - b(i)) != i + 1) |
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 example.misc; | |
import com.google.common.jimfs.Configuration; | |
import com.google.common.jimfs.Jimfs; | |
import java.nio.charset.StandardCharsets; | |
import java.nio.file.FileSystem; | |
import java.nio.file.Files; | |
import java.nio.file.Path; |
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
public class ZipDemo { | |
public static final String PATH = "/path/to/zipfile.zip"; | |
public static void main(final String[] args) throws IOException { | |
final Path zipfile = Paths.get(PATH); | |
try (ZipInputStream zis = new ZipInputStream( | |
new ByteArrayInputStream(Files.readAllBytes(zipfile)));) { | |
ZipEntry entry; | |
while ((entry = zis.getNextEntry()) != null) { | |
if (entry.isDirectory()) { |
NewerOlder