Skip to content

Instantly share code, notes, and snippets.

View matsubo's full-sized avatar

Yuki Matsukura matsubo

View GitHub Profile
@matsubo
matsubo / container.sh
Created May 19, 2021 01:20
yarn 2 + webpacker test
gem i rails
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
npm install -g yarn
rails new myapp --webpack
cd myapp/
yarn set version berry
yarn install
bin/webpack-dev-server
document.getElementById('postcode').addEventListener('keyup', function(e) {
if (!e.key.match(/[0-9]/)) return;
const postcode = e.target.value;
if (postcode.length !== 7) return;
const url = `https://postcode.teraren.com/postcodes/${postcode}.json`;
fetch(url)
.then(response => response.json())

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";
}