This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
records = Google::Cloud::Bigquery.dataset(dataset_id).table(table_id).data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE conv.sh [input] [output] [width] [height] | |
# widthとheightは大きめ(2000以上)の方がいい感じになる | |
# リサイズします | |
convert $1 -resize ${3}x${4}! target.png | |
# 油彩フィルタを重ねがけします | |
convert target.png -modulate 160,180 -colors 400 -paint 2 -paint 2 -paint 2 -blur 3x4 paint.png | |
# ぼかした後の画像からエッジ画像を取り出します |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# 初期値の定義 | |
x=[ | |
[0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,1,0,0,0,0], | |
[0,0,0,0,0,1,0,0,0], | |
[0,0,0,1,1,1,0,0,0], | |
[0,0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0,0], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
# 初期値の定義 | |
# 初期配置 | |
x=[ | |
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateRecommendations < ActiveRecord::Migration[5.2] | |
def change | |
- create_table :recommendations do |t| | |
+ create_table :recommendations, id: false do |t| # idの代わりにuidを使う | |
- t.bigint :uid | |
+ t.bigint :uid, null: false, unique: true | |
- t.blob :recommended_id_list | |
+ t.blob :recommended_id_list, null: false | |
- t.timestamps | |
+ t.datetime :updated_at, null: false # created_atは不要 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ids = [1,2,3] | |
#=> [1, 2, 3] | |
#書き込み | |
recommendation = Recommendation.create(uid: 1, recommended_id_list: ids.pack('Q<*')) | |
#=> #<Recommendation uid: 1, recommended_id_list: "\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00", updated_at: "2020-01-15 09:56:20"> | |
#読み込み | |
recommendation.recommended_id_list.unpack('Q<*') | |
#=> [1, 2, 3] |