Skip to content

Instantly share code, notes, and snippets.

Avatar

ota42y ota42y

View GitHub Profile
View application.rb
schema_path = Rails.root.join("config/openapi.yaml").to_s
config.middleware.use Committee::Middleware::RequestValidation,
schema_path: schema_path,
params_key: 'action_dispatch.request.request_parameters'
View go-txdb-test.go
package main
import (
"fmt"
"math/rand"
"time"
"github.com/DATA-DOG/go-txdb"
"github.com/jinzhu/gorm"
@ota42y
ota42y / techbookfest_calc
Created Mar 22, 2020
技術書典 応援祭 の販売数集計スクリプト(2020/03/22時点)
View techbookfest_calc
out = []
document.getElementsByClassName("css-1dbjc4n r-1l7z4oj r-ymttw5")[0].children.forEach(c => {
if (c.children.length == 1) { return; } // header
datetime = c.children[0].innerText.split("\n")[0];
s = c.children[2].innerText.split("\n");
title = s[0]
type = s[1]
price = c.children[3].innerText.split("\n")[0];
out.push(datetime + "," + type + "," + title + "," + price);
});
View validation.rb
# return path for validation, if return nil we doesn't validation
def validation_path_hook(request)
# only
# request.path.start_with?('/something') ? request.path : nil
# except
# request.path.start_with?('/something') ? nil : request.path
# prefix option (/v1/test => /test)
# request.path.gsub(/^\/v1/, "")
View gist:420fe3d789ca417dcf623157be6d604c
% ./alertmanager --log.level=debug
level=info ts=2019-10-05T12:41:23.678Z caller=main.go:217 msg="Starting Alertmanager" version="(version=0.19.0, branch=HEAD, revision=7aa5d19fea3f58e3d27dbdeb0f2883037168914a)"
level=info ts=2019-10-05T12:41:23.678Z caller=main.go:218 build_context="(go=go1.12.8, user=root@587d0268f963, date=20190903-15:04:14)"
level=debug ts=2019-10-05T12:41:23.678Z caller=cluster.go:149 component=cluster msg="resolved peers to following addresses" peers=
level=info ts=2019-10-05T12:41:23.679Z caller=cluster.go:161 component=cluster msg="setting advertise address explicitly" addr=192.168.11.8 port=9094
level=debug ts=2019-10-05T12:41:23.681Z caller=delegate.go:230 component=cluster received=NotifyJoin node=01DPDZ0PYZT9KRQ6MWV5SCAFKM addr=192.168.11.8:9094
level=debug ts=2019-10-05T12:41:23.681Z caller=cluster.go:233 component=cluster msg="joined cluster" peers=0
level=info ts=2019-10-05T12:41:23.681Z caller=cluster.go:623 component=cluster msg="Waiting for gossip to settle..." interval=2s
l
View log.txt
level=info ts=2019-10-05T12:41:33.693Z caller=cluster.go:640 component=cluster msg="gossip settled; proceeding" elapsed=10.01120645s
level=debug ts=2019-10-05T12:42:47.040Z caller=dispatch.go:104 component=dispatcher msg="Received alert" alert=server-status[83e172c][active]
level=debug ts=2019-10-05T12:42:57.045Z caller=dispatch.go:432 component=dispatcher aggrGroup="{}:{alertname=\"server-status\"}" msg=flushing alerts=[server-status[83e172c][active]]
level=debug ts=2019-10-05T12:43:07.048Z caller=dispatch.go:432 component=dispatcher aggrGroup="{}:{alertname=\"server-status\"}" msg=flushing alerts=[server-status[83e172c][active]]
level=debug ts=2019-10-05T12:43:17.050Z caller=dispatch.go:432 component=dispatcher aggrGroup="{}:{alertname=\"server-status\"}" msg=flushing alerts=[server-status[83e172c][active]]
View alertmanager.yaml
global:
resolve_timeout: 5m
slack_api_url: "https://hooks.slack.com/services/xxx"
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'slack'
@ota42y
ota42y / text.md
Last active Aug 21, 2019
技術書典7
View text.md

一応最初に書いておくと、身内の恥をpublicな場で行うのは絶対嫌で、やってるのを見るだけでドン引きなんですが、 唯一のコミュニケーション手段であるprivateなパスではしょっちゅう無視されてますし、publicな場では元気なことからこのパスに頼らざるを得ませんでした。 悲しいことにpublicな場に出したことで一瞬で終息してしまったので、最低だが効果的な方法であると証明されてしまいましたし…

今回は「本とビルコン両方やるのは無理だから諦めてビルコンに集中させるという合意を取る」のが目的なので事態としては収束しています。 以下具体的な内容としては

  • 本人から精神的負荷を理由にビルコンの後に記事だけあげるという連絡が来る
    • 現在の状況から考えるとビルコン後からスタートすると間に合わないと判断
View Dockerfile
FROM node:8.11.3-alpine
RUN mkdir -p /app/node_modules
RUN touch /app/node_modules/test
View rubocop_benchmark
require 'benchmark'
actioncable_folder = '/rails/actioncable'
rubocop_folder = '/rubocop'
def reset_rails(actioncable_folder)
Dir.chdir(actioncable_folder) do
system('git checkout -f v5.2.3 >/dev/null 2>&1')
system('mv ../.rubocop.yml ../.rubocop.yml_bk')
end
You can’t perform that action at this time.