Skip to content

Instantly share code, notes, and snippets.

tamtam180 tamtam180

View GitHub Profile
View gist:817c00106bc30972a179b2687cf43b03
# 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 Jul 19, 2016
JSONログから雑にデータ構造を調べるための糞スクリプト。同じキーで異なる型は想定外
View json2bq.rb
# 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)
View gist:04ce72f25760e3c46d34
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 Aug 29, 2015
再現コード
View hoge.rb
# coding: utf-8
require 'json'
rand = Random.new
i = 0
while true do
i += 1
obj = {
View error
[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/
View hoge.rb
# 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
View gist:5433221
public class MyFactory {
public static Configuration newConfiguration() {
Configuration conf = new Configuration();
conf.setInt("xxx", 111);
return conf;
}
}
// こーいう場合(Factoryクラスがstaticメソッドでかつ他のクラスの場合) XMLどう書けばいいの...
// factory-beanはbean指定だからインスタンス化必須?
View gist:5387530

JS

<script type="text/javascript">

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

こんな感じ

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テスト)
View pom.xml
<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>
You can’t perform that action at this time.