Skip to content

Instantly share code, notes, and snippets.

View tamtam180's full-sized avatar

tamtam180 tamtam180

View GitHub Profile
# irb
2.3.1 :001 > q = Queue.new
=> #<Thread::Queue:0x00000002150908>
2.3.1 :002 > q.push(:a)
=> #<Thread::Queue:0x00000002150908>
2.3.1 :003 > q.push(:b)
=> #<Thread::Queue:0x00000002150908>
2.3.1 :004 > q.pop
=> :a
2.3.1 :005 > q.pop
@tamtam180
tamtam180 / json2bq.rb
Last active July 19, 2016 12:13
JSONログから雑にデータ構造を調べるための糞スクリプト。同じキーで異なる型は想定外
# coding: utf-8
require 'json'
def get_bqtype(k, obj)
return case obj
when TrueClass, FalseClass then "BOOLEAN"
when String then "STRING"
when Float then "FLOAT"
when Fixnum, Bignum
return "TIMESTAMP" if ["timestamp", "_ts"].include?(k)
irb(main):007:0* require 'Oj'
=> false
irb(main):008:0> Oj.load('{"x": 1e-314}')
=> {"x"=>0.0}
irb(main):009:0> Oj.default_options = { :bigdecimal_load => :bigdecimal }
=> {:bigdecimal_load=>:bigdecimal}
irb(main):010:0> Oj.load('{"x": 1e-314}')
=> {"x"=>#<BigDecimal:7fd73a87d188,'0.1E-313',9(18)>}
@tamtam180
tamtam180 / hoge.rb
Last active August 29, 2015 14:26
再現コード
# coding: utf-8
require 'json'
rand = Random.new
i = 0
while true do
i += 1
obj = {
[2015-07-11T00:40:12+00:00] ERROR: service[td-agent] (td-agent::default line 119) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /sbin/service td-agent start ----
STDOUT: Starting td-agent: [FAILED]
STDERR: /usr/lib64/fluent/ruby/lib/ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': Unable to activate googleauth-0.4.1, because multi_json-1.11.1 conflicts with multi_json (= 1.11) (Gem::LoadError)
from /usr/lib64/fluent/ruby/lib/ruby/1.9.1/rubygems/specification.rb:746:in `activate'
from /usr/lib64/fluent/ruby/lib/ruby/1.9.1/rubygems/specification.rb:780:in `block in activate_dependencies'
from /usr/lib64/fluent/ruby/lib/ruby/1.9.1/rubygems/specification.rb:766:in `each'
from /usr/lib64/fluent/ruby/lib/ruby/1.9.1/rubygems/specification.rb:766:in `activate_dependencies'
from /usr/lib64/fluent/ruby/lib/ruby/1.9.1/rubygems/specification.rb:750:in `activate'
from /usr/lib64/
# coding: utf-8
require 'json'
require 'yajl'
x = eval('{"logType"=>"ads", "abc"=>"\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB", "time"=>"2015-05-17T03:00:00Z", "tag"=>"aaa"}')
puts x["abc"].force_encoding("ASCII-8BIT")
puts x["abc"].encoding
puts x
public class MyFactory {
public static Configuration newConfiguration() {
Configuration conf = new Configuration();
conf.setInt("xxx", 111);
return conf;
}
}
// こーいう場合(Factoryクラスがstaticメソッドでかつ他のクラスの場合) XMLどう書けばいいの...
// factory-beanはbean指定だからインスタンス化必須?

JS

<script type="text/javascript">

var data = {
  "id" : "aaa",
  "hoge" : 100
};

こんな感じ

cd $HIVE_HOME

# パッチをあててビルド
wget https://issues.apache.org/jira/secure/attachment/12577210/HIVE-4299.patch
patch -p0 < HIVE-4299.patch
ant clean package

# テストの内容作成(.qファイルを使ったpositiveテスト)
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>