Skip to content

Instantly share code, notes, and snippets.

@arc279
arc279 / serializer_json.rb
Created October 24, 2017 03:01
nest of ActiveModel::Serializers::JSON (rails5)
class Bar
include ActiveModel::Model
attr_accessor :foo, :bar
end
class Foo
include ActiveModel::Model
include ActiveModel::Serializers::JSON
FROM docker.elastic.co/elasticsearch/elasticsearch:6.1.2
RUN elasticsearch-plugin install analysis-kuromoji
RUN elasticsearch-plugin install org.codelibs:elasticsearch-analysis-kuromoji-neologd:5.6.1
@arc279
arc279 / gist:21e5257b24cda1a652ff48601fc29366
Created February 7, 2018 07:13
平成29年版 厚生労働白書 のpdfから文章抽出した結果
This file has been truncated, but you can view the full file.
平成29年版
厚生労働白書
(平成28年度厚生労働行政年次報告)
厚 生 労 働 省
―社会保障と経済成長―
@arc279
arc279 / iris-dask-xgb.py
Created March 29, 2018 08:26
dask xgboost で irisの分類までの一連の流れ
"""
# pip install pandas sklearn dask_xgboost
"""
from sklearn import datasets
#--- dataset
iris = datasets.load_iris()
print(iris.feature_names)
X = iris.data
@arc279
arc279 / Dockerfile
Last active March 30, 2018 08:07
livedoor グルメの研究用データセット の中の ratings.csv から、Elasticsearchで簡単なアナライザを設定して、ユーザレビューを検索できるようにするところまで。
FROM docker.elastic.co/elasticsearch/elasticsearch:6.2.1
LABEL maintainer "kuryu <[email protected]>"
RUN elasticsearch-plugin install analysis-icu
RUN elasticsearch-plugin install analysis-kuromoji
RUN elasticsearch-plugin install ingest-attachment
@arc279
arc279 / draw-cabocha.ipynb
Created April 16, 2018 08:18
cabochaの係り受け解析をgraphvizで描いてみる
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arc279
arc279 / make_s3_rm_cmd.sh
Created April 18, 2018 07:19
s3のファイルをまとめて消すコマンドを出力
BUCKET_NAME=some_bucket
PATTERN='some_pattern'
aws s3 ls --recursive s3://${BUCKET_NAME} | rev | cut -f1 -d' ' | rev > file_lst
cat file_lst | grep -oP "$PATTERN" | xargs -I{} echo "aws s3 rm --recursive 's3://${BUCKET_NAME}/{}'" > rm_cmd.sh
@arc279
arc279 / client.sh
Last active April 27, 2018 05:31
groovyでpdfbox
curl -s -v -XPOST localhost:6001 --data-binary @all.pdf
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import itertools
def each_slice(iterable, n):
for i, item in itertools.groupby(enumerate(iterable), lambda x: x[0] // n):
yield (x[1] for x in item)
for x in each_slice(range(10), 3):
print(tuple(x))
"""output
(0, 1, 2)