Skip to content

Instantly share code, notes, and snippets.

View matsubo's full-sized avatar

Yuki Matsukura matsubo

View GitHub Profile

Usage

"very long time task" | notify
root@ef0f9d3cc50e:/app# diff /usr/local/bundle/gems/actionpack-5.2.5/lib/action_controller/metal/request_forgery_protection.rb /usr/local/bundle/gems/actionpack-5.2.4.5/lib/action_controller/metal/request_forgery_protection.rb --color
323a324,328
> one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN_LENGTH)
> encrypted_csrf_token = xor_byte_strings(one_time_pad, raw_token)
> masked_token = one_time_pad + encrypted_csrf_token
> Base64.urlsafe_encode64(masked_token, padding: false)
>
336c341
< masked_token = Base64.urlsafe_decode64(encoded_masked_token)
---
@matsubo
matsubo / Gemfile
Last active March 12, 2021 06:37 — forked from run26kimo/Gemfile
Ruby AWS cloudwatch put log event example
gem 'aws-sdk-cloudwatchlogs'
% curl -s https://postcode.teraren.com/postcodes.json |jq -r '.[] | [.new, (.prefecture + .city + .suburb)] | @csv ' | head -n 10
"0600000","北海道札幌市中央区"
"0640941","北海道札幌市中央区旭ケ丘"
"0600041","北海道札幌市中央区大通東"
"0600042","北海道札幌市中央区大通西(1〜19丁目)"
"0640820","北海道札幌市中央区大通西(20〜28丁目)"
"0600031","北海道札幌市中央区北一条東"
"0600001","北海道札幌市中央区北一条西(1〜19丁目)"
"0640821","北海道札幌市中央区北一条西(20〜28丁目)"
"0600032","北海道札幌市中央区北二条東"
@matsubo
matsubo / mapping-mention-to-slack.yml
Created January 19, 2021 10:13
github mention to slack sample code
# For Github User
# github_username: "slack_member_id"
# please_replace_me_11: U01G30S9LHW
# please_replace_me_4: U011F5DRG2V
# github_username_A: "slack_member_id_A"
# github_username_B: "slack_member_id_B"
# github_username_C: "slack_member_id_C"
# abeyuya: "XXXXXXXXX"
@matsubo
matsubo / wordpress.rb
Created November 12, 2020 17:52
Post image to wordpress and use it in the article.
require 'faraday'
require 'base64'
require 'json'
# Generated password using application-passwords plugin
authorization = 'Basic ' + Base64.encode64('username:password')
# post image
var os = require('os')
module.exports = Franz =>
class Gmail extends Franz {
overrideUserAgent() {
if (os.platform() == 'linux')
return "Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0"
else
return "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36";
}
@matsubo
matsubo / Gemfile
Last active August 20, 2020 16:46
quick and dirty code for prototyping
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "influxdb"
gem "logger"
[
["北海道", "", "hokkaido"],
["青森県", "あおもり", "aomori"],
["岩手県", "いわて", "iwate"],
["宮城県", "みやぎ", "miyagi"],
["秋田県", "あきた", "akita"],
["山形県", "やまがた", "yamagata"],
["福島県", "ふくしま", "fukushima"],
["茨城県", "いばらき", "ibaraki"],
["栃木県", "とちぎ", "tochigi"],