Skip to content

Instantly share code, notes, and snippets.

View sunny4381's full-sized avatar

NAKANO Hideo sunny4381

  • 株式会社ウェブチップス
View GitHub Profile
data:text/html,<html contenteditable> <script>window.onbeforeunload=function(){ return "%E9%96%89%E3%81%98%E3%81%BE%E3%81%99%E3%81%8B%EF%BC%9F" }</script>
# SHIRASAGI OAuth 2.0 IdP 機能を利用したサンプルコード
# このサンプルでは authorization code flow を用います。
#
# 実行方法
# bin/rails runner oauth2_sample_with_authorization_code_flow.rb
# ドメイン
your_domain = "https://localhost:3551/"
# 認可エンドポイントの URL
authorize_url = URI.join(your_domain, "/.mypage/login/oauth2/authorize")
# SHIRASAGI OAuth 2.0 IdP 機能を利用したサンプルコード
# このサンプルでは implicit flow を用います。
#
# 実行方法
# bin/rails runner oauth2_sample_with_implicit_flow.rb
# ドメイン
your_domain = "https://localhost:3551/"
# 認可エンドポイントの URL
authorize_url = URI.join(your_domain, "/.mypage/login/oauth2/authorize")
# SHIRASAGI OAuth 2.0 IdP 機能を利用したサンプルプログラム
# このサンプルでは jwt 拡張フローを用います。
#
# 実行方法
# bin/rails runner oauth2_sample_with_jwt_flow.rb
# ドメイン
your_domain = "https://localhost:3551/"
# トークンエンドポイントの URL
token_url = URI.join(your_domain, "/.mypage/login/oauth2/token")
#
# 使用方法:
# bundle exec rails runner all_contents_download.rb www > all_contents.csv
#
site = Cms::Site.find_by(host: ARGV[0])
exporter = Cms::AllContent.new(site: site)
enumerable = exporter.enum_csv(encoding: "Shift_JIS")
enumerable.each do |csv|
STDOUT.write csv
#!/bin/bash
base_dir=$(cd "$(dirname $0)" && pwd)
proj_dir=$(pwd)
prefix=${prefix:-"ss"}
version=${version:-"20190529-1356"}
echo "pwd: $proj_dir"
cd $proj_dir
rm -rf private public
tar xf $proj_dir/,memo/$prefix-files-$version.tar.bz2
@sunny4381
sunny4381 / mongodbのslow query集計.txt
Last active July 25, 2024 08:52
jqコマンドを利用してmongodbのlogからslow queryを抽出して集計するスクリプト
# slow query のみ抽出 & 整形
head -500 /var/log/mongodb/mongod.log |\
jq -c 'select(.msg == "Slow query" and .attr.type == "command") | { collection: (.attr.command.find // .attr.command.aggregate // .attr.command.mapReduce), durationMillis: .attr.durationMillis, count: 1 } | select(.collection != null)' \
> work-0
# slow query の集計
cat work-0 |\
jq -s -c 'group_by(.collection) | .[] | reduce .[] as {$collection,$durationMillis,$count} (null; .collection = $collection | .durationMillis += $durationMillis | .count += $count)' \
> work-1