Skip to content

Instantly share code, notes, and snippets.

View purintai's full-sized avatar

Purintai purintai

View GitHub Profile
@purintai
purintai / json_ext_patch.rb
Last active March 25, 2020 03:33
CVE-2020-10663
# for CVE-2020-10663
# https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/
if Gem::Version.create(JSON::VERSION) < Gem::Version.create('2.3.0')
module JSON
class << self
alias :old_parse :parse
def parse(json, args = {})
old_parse(json, args || {})
end
end
### Keybase proof
I hereby claim:
* I am purintai on github.
* I am purintai (https://keybase.io/purintai) on keybase.
* I have a public key ASCMsA1xrtUKUuJY1i_NgUnLfzA_crDmAKvdz5fKgeX2zgo
To claim this, I am signing this object:
@purintai
purintai / product_only_on_sale.json
Last active November 10, 2016 11:29
Elasticsearch inline script よくわからない
GET /products/_search
{
"query": {
"bool": {
"must": {
"script": {
"script": {
"lang": "painless",
"inline": "doc['sale_price'].value > 0 && doc['sale_begin_at'].value <= params.t && doc['sale_end_at'].value > params.t",
"params": {
@purintai
purintai / not_in.rb
Last active October 19, 2016 05:49
touch or delete (if csv rows over 500k)
csv = CSV.open(path, headers: true)
touched = []
csv.each do |row|
params = row.to_h
ProductUpdateWorker.perform_async(params)
touched << params['code']
end
Product.where.not(code: touched).destroy_all
@purintai
purintai / kakakucomPrice.gs
Last active February 20, 2017 06:34
価格.comのitemページから値段取得して返すだけの関数
// Only for Google Scripts
function kakakucomPrice(itemUrl) {
try {
var response = UrlFetchApp.fetch(itemUrl);
if (response.getResponseCode() == 200) {
var html = response.getContentText();
re = /ecomm_totalvalue: \'(\d+)\'/;
var result = html.match(re);
if (result == null) {
return "Sold out";