Skip to content

Instantly share code, notes, and snippets.

@kumazo
kumazo / Dockerfile
Last active October 10, 2016 15:30
64-bit Windows で MeCab の Java バインディングを使いたい ref: http://qiita.com/kumazo/items/5c5c57d94b2080ffbb5a
FROM ubuntu:trusty
RUN apt-get update && apt-get -f install
RUN apt-get install -y mingw-w64 --no-install-recommends
RUN apt-get install -y make patch
RUN apt-get install -y wget vim
RUN apt-get install -y swig
RUN find /usr -name '*.dll' -delete
RUN find /usr -name '*.dll.a' -delete
public interface DbToolMapper {
@Select("${sql}")
List<Map<String, Object>> query(@Param("sql") String sql);
}
@kumazo
kumazo / file1.txt
Last active February 6, 2016 01:36
データをエクセルにて添付いたしますのでご査収のほどよろしくお願いいたします ref: http://qiita.com/kumazo@github/items/ba0332fe4b8823f14b6a
C:\work>cscript xls2csv.vbs Book1.xlsx
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
完了しました
@kumazo
kumazo / List.2-10_ヘッダ出力
Last active July 16, 2016 03:30
Java 8 Stream API にテキストを流してみた(終端操作編) ref: http://qiita.com/kumazo@github/items/284098c530fceb05805c
// ファイルは最初の空行まで読み込まれる。
Files.lines(path)
.peek(s -> {
System.out.println(s);
})
.anyMatch(String::isEmpty);
@kumazo
kumazo / Docker
Last active August 29, 2015 14:25
PostgreSQL JSON の応用メモ ref: http://qiita.com/kumazo@github/items/19361acffddb6be10ac2
# ActiveRecord と postgres アダプタの gem が入ったイメージを用意する。
# DockerHub 公式の ruby:onbuild を使うと、Gemfile を用意するだけで
# その内容をインストールした ruby 環境イメージを簡単に作成することができる。
$ docker pull ruby
$ docker run --rm ruby ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
$ ls
Gemfile Dockerfile
@kumazo
kumazo / 1-xx_テキストファイルからURLを抽出する
Last active October 10, 2016 15:51
Java 8 Stream API にテキストを流してみる(生成編) ref: http://qiita.com/kumazo/items/0876c5b251ecc131c960
// splitAsStream() を使った実装
// 指定の正規表現を反転し、splitAsStream()を使ってテキストから文字列を抽出する。
public List<String> extract1(String file, String regex) throws IOException {
// 任意の正規表現を反転(否定)した正規表現にするが、保証はできない。
// 後読みとかしているので重い。ものによっては帰ってこれないかもしれない。
final String inverse = String.format("(?<=^|(%1$s))((?!(%1$s)).)+", regex);
final Pattern invertedPattern = Pattern.compile(inverse);
try(Stream<String> lines = Files.lines(Paths.get(file))) {
return lines
package hoge;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Iterator;
@kumazo
kumazo / Vagrantfile
Last active May 29, 2016 01:08
vagrant ssh で TeraTerm を起動する ref: http://qiita.com/kumazo@github/items/026ebbc646505681e61f
ENV['PATH'] += ";" + File.expand_path(File.dirname(__FILE__))
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>my-application-id</application>
<version>v1</version>
<!-- TODO review code for thread-safety. -->
<threadsafe>false</threadsafe>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
@kumazo
kumazo / file0.sql
Last active August 29, 2015 14:07
PostgreSQL 9.4 の JSON サポートについて ref: http://qiita.com/kumazo@github/items/9010f9dad134b9d9d16d
SELECT value, jsonb_typeof(value)
FROM jsonb_array_elements(
'[1, 1.00, 10.0e-3, "1", true, "2014-01-01T12:34:56", null, "", {}, []]'
);
value | jsonb_typeof
-----------------------+--------------
1 | number
1.00 | number
0.0100 | number