Skip to content

Instantly share code, notes, and snippets.

@skrb
skrb / gist:10264845
Created Apr 9, 2014
文字列の連結
View gist:10264845
public String stringArrayJoining() {
char[] dest = new char[18000];
dest[0]= '[';
int destOffset = 1;
for (int i = 0; i < strarray.length; ++i) {
if (i != 0) {
dest[destOffset] = ']';
destOffset++;
@skrb
skrb / Example.java
Created May 12, 2014
“レッスンは何曜日?”をJavaでやってみた
View Example.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class Example {
static class LessonClass {
@skrb
skrb / gist:9202e62ade9d705e879b
Last active Aug 29, 2015
UTF-8のプロパティファイルを読むための snipet
View gist:9202e62ade9d705e879b
ResourceBundle.Control control = new ResourceBundle.Control() {
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format,
ClassLoader loader, boolean reload)
throws IllegalAccessException, InstantiationException, IOException {
String bundleName = toBundleName(baseName, locale);
ResourceBundle bundle = null;
if (format.equals("java.properties")) {
final String resourceName = toResourceName(bundleName, "properties");
final ClassLoader classLoader = loader;
@skrb
skrb / Album.java
Created Jun 24, 2014
Table Sample
View Album.java
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
public class Album {
private ObjectProperty<String> title = new SimpleObjectProperty<>();
private ObjectProperty<String> artist = new SimpleObjectProperty<>();
View BlinkLED.java
/*
* Java Embedded Raspberry Pi GPIO app
* エルチカ♪
* * 用意するもの
* ジャンパーケーブル(オス×メス:2本)
* LED(RED 3.3v)
* 抵抗 470Ω(黄・紫・茶・金)
*/
import java.io.File;
import java.io.FileWriter;
@skrb
skrb / SwitchOnOff.java
Created Jun 28, 2014
SwitchOnOff.java
View SwitchOnOff.java
/*
* Java Embedded Raspberry Pi GPIO app
* スイッチポチポチ♪
* 用意するもの
* ジャンパーケーブル(オス×メス:2本、オス×オス:1本)
* タクトスイッチ(モーメンタリ)
* 抵抗 10kΩ(茶・黒・橙・金)
*/
import java.io.File;
import java.io.FileWriter;
View AsyncTextAreaUpdater.java
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import javafx.application.Application;
import javafx.beans.property.StringProperty;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
@skrb
skrb / Sum.java
Created Sep 5, 2014
StreamとパラレルStreamの比較
View Sum.java
import java.util.function.IntConsumer;
import java.util.stream.IntStream;
public class Sum {
private static final int SIZE = 1_000_000;
public Sum() {
evaluate("sum000", i -> sum000());
View CircleDemo.java
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class CircleDemo extends Application {
@Override
@skrb
skrb / IrofDrawingSong.java
Created Dec 24, 2014
Irod Drawing Song by JavaFX
View IrofDrawingSong.java
package irofdrawingsong;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;