Skip to content

Instantly share code, notes, and snippets.

View civitaspo's full-sized avatar
❄️

Takahiro Nakayama civitaspo

❄️
View GitHub Profile
@civitaspo
civitaspo / Study_OOP.md
Last active December 23, 2015 01:09
Study_OOP

継承による拡張性の追加

関数を直接継承するのではなく、クラス変数、そして関数のパラメータ となる関数を継承する・させることで、設計思想や、インターフェースを残しながら、 大きく拡張することが可能になる。

以下に自身のvalueを出力する3つの例を示す。

  • 直に継承してオーバーライドする場合(拡張性小)
  • 直接、to_valuesがオーバーライドされる
@civitaspo
civitaspo / default.css
Last active August 29, 2015 14:12 — forked from leiming/default.css
.ace_editor{position:relative;overflow:hidden;font-family:'Microsoft Yahei','Menlo','Ubuntu Mono','Consolas','source-code-pro',monospace;font-size:12px;line-height:normal;color:black;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none;user-select:none}
.ace_scroller{position:absolute;overflow:hidden;top:0;bottom:0;background-color:inherit}
.ace_content{position:absolute;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;cursor:text}
.ace_dragging,.ace_dragging *{cursor:move !important}
.ace_dragging .ace_scroller:before{position:absolute;top:0;left:0;right:0;bottom:0;content:'';background:rgba(250,250,250,0.01);z-index:1000}
.ace_dragging.ace_dark .ace_scroller:before{background:rgba(0,0,0,0.01)}
.ace_selecting,.ace_selecting *{cursor:text !important}
.ace_gutter{position:absolute;overflow:hidden;width:auto;top:0;bottom:0;left:0;cursor:default;z-index:4}
.ace_gutter-active-line{position:absolute;left:0;right:0}
.ace_scroller.ace_scroll-left{box-shadow:17px 0 16px -1
@civitaspo
civitaspo / how_to_write_embulk_plugin_test.md
Last active November 1, 2015 09:40
Qiita投稿用draft: Embulk Plugin の Task の書き方

はじめに

これまでEmbulkのPluginをいくつか書かせてもらってきましたが、初期の頃はテスト用のAPIが整備されていなくて後回しにしてきました。 この記事は、そろそろ書かねばという気持ちになり、奮闘した時のメモです。良かったら参考にしてくだい。

おことわり

  • Pluginの単体テストに焦点を絞ってます。クラスやメソッドの単体テストは普通に書けると思うので省略します。
  • 現存するPluginのテストやEmbulkのコードを参考にして書いてますが、これよりいい方法があるかもなので知っている方がいたら教えて下さい。
  • Encoder/Decoderでも同じ方法でテストできるのか試してません。(-> ためす)
  • Javaを書き始めて、まだ日が浅いので作法などで問題有りましたら、連絡いただけると嬉しいです。
@civitaspo
civitaspo / output.txt
Created February 3, 2016 12:08
s3 から file にデータを格納するときに遭遇したエラー(これでは落ちない)
embulk -J-Dio.netty.leakDetectionLevel=advanced run config.yml -b embulk-bundle
...
2016-02-02 23:25:14.309 +0900 [ERROR] (task-0311): LEAK: ByteBuf.release() was not called before it's garbage-collected.
Recent access records: 0
Created at:
io.netty.util.ResourceLeakDetector.open(ResourceLeakDetector.java:163)
io.netty.buffer.AbstractByteBufAllocator.toLeakAwareBuffer(AbstractByteBufAllocator.java:42)
io.netty.buffer.PooledByteBufAllocator.newHeapBuffer(PooledByteBufAllocator.java:228)
io.netty.buffer.AbstractByteBufAllocator.heapBuffer(AbstractByteBufAllocator.java:136)
io.netty.buffer.AbstractByteBufAllocator.heapBuffer(AbstractByteBufAllocator.java:127)
@civitaspo
civitaspo / s3_to_file.yml.liquid
Created February 4, 2016 01:38
embulkでデータ欠損が発生した際の全ログとconfig
in:
type: s3
access_key_id: "{{ env.AWS_ACCESS_KEY_ID }}"
secret_access_key: "{{ env.AWS_SECRET_ACCESS_KEY }}"
bucket: "{{ env.S3_BUCKET }}"
path_prefix: "{{ env.INPUT_PREFIX }}"
decoders:
- type: gzip
parser:
type: csv
@civitaspo
civitaspo / config.yml
Last active March 1, 2016 03:56
embulk-input-command is not built for java7?
[embulk-test] cat config.yml
in:
type: command
command: 'cat /Users/takahiro.nakayama/work/embulk-test/data/data*'
parser:
type: csv
columns:
- {name: t, type: string}
out:
type: file
require 'embulk'
Embulk.setup
class MyError1 < ::Embulk::DataError; end
class MyError2 < ::Embulk::DataError; end
begin
raise MyError1.new("hoge")
rescue MyError2 => e
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-01-24 14:28:14 +0900 using RuboCop version 0.36.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
AllCops:
Exclude:

optimist

optimist is a simple option parser for golang which is inspired by minimist, Getopt::Casual.

Usage

The below code returns optimist.Args that is the result of parsing arguments and structuring them.

@civitaspo
civitaspo / newGemPush.gradle
Last active May 18, 2017 10:20
modified after `embulk new java-filter test`
plugins {
id "com.jfrog.bintray" version "1.1"
id "com.github.jruby-gradle.base" version "0.1.5"
id "java"
id "checkstyle"
}
import com.github.jrubygradle.JRubyExec
repositories {
mavenCentral()
jcenter()