Skip to content

Instantly share code, notes, and snippets.

View kazgoto's full-sized avatar

Kazutaka Goto kazgoto

View GitHub Profile
@kazgoto
kazgoto / macos-office-emacs-keybinds.json
Created July 26, 2022 04:15
macOS の Microsoft Office 向け Karabiner Elements 用 Emacs キーバインド設定(オリジナル https://hattomo.github.io/posts/main/21/q1/0215-karabiner-office/ + Teams追加)
{
"title": "Microsoft Office で Emacs キーバインド",
"rules": [
{
"description": "Microsoft Office で Emacs キーバインド",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "b",
@kazgoto
kazgoto / batch-delete-email.gs
Last active December 15, 2021 08:14
Gmail で特定ラベルの大量なメールを削除するバッチ関数(どっかで拾ったもの)
function batchDeleteEmail() {
var loopNumber = 50
var batchSize = 100 // Process up to 100 threads at once
var searchSize = 400 // Limit search result to a max of 400 threads. Use this if you encounter the "Exceeded maximum execution time" error
for (i = 0; i < loopNumber; i += 1) {
var threads = GmailApp.search('label:XXXX', 0, searchSize);
for (j = 0; j < threads.length; j += batchSize) {
GmailApp.moveThreadsToTrash(threads.slice(j, j + batchSize));
}
@kazgoto
kazgoto / speech-api-test.html
Created April 14, 2021 06:59
Simple Speech API test application for Chrome
<html>
<body>
<textarea class="form-control" rows="5" readonly></textarea>
<br>
<button type="button" class="btn btn-primary">Recognize</button>
<script type="text/javascript">
const recognition = new webkitSpeechRecognition();
const textarea = document.querySelector('textarea');
const button = document.querySelector('button');
button.addEventListener('click', function () {
wget --mirror –w 2 –p -E --convert-links –P ./ https://example.com/
# see more options: https://linux.die.net/man/1/wget
cd example.com/
php -S localhost:8081
# open URL http://localhost:8081 on your browser
@kazgoto
kazgoto / my-custom-setting.json
Created January 7, 2021 09:08
Karabiner-Elements用カスタム設定
{
"title": "オリジナル",
"rules": [
{
"description": "[my] Screen Brightness (fn + cmd + up/down)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "down_arrow",
@kazgoto
kazgoto / revoke-permission.gs
Last active November 1, 2020 13:45
Google Drive内、特定のフォルダ以下のファイルとフォルダの共有権限を削除してアクセス制限するバッチスクリプト
// Google Drive内、特定のフォルダ以下のファイルとフォルダの共有権限を削除してアクセス制限する
var TARGET_FOLDERS = [ // ターゲットのフォルダリスト(URLの最後の文字列部分)
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // 権限削除したいフォルダ1
'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy' // 権限削除したいフォルダ2
];
var me = Session.getActiveUser().getEmail(); // 自アカウントのメールアドレス
function main() {
@kazgoto
kazgoto / thirdparty-RI-offering-search.sh
Last active October 28, 2020 09:46
Thirdparty RI を調べるワンライナー with Docker
docker run --rm -i -v ~/.aws:/root/.aws amazon/aws-cli ec2 describe-reserved-instances-offerings \
--profile kaz@cloudpack.jp --instance-type m1.large \
--offering-class standard \
--product-description "Linux/UNIX" \
--instance-tenancy default \
--filters Name=marketplace,Values=true | jq -r '.ReservedInstancesOfferings[] |
[.OfferingClass, .ProductDescription, .InstanceType, .OfferingType, .FixedPrice, .Duration, .ReservedInstancesOfferingId] | @csv'
@kazgoto
kazgoto / current-usdjpy.sh
Created July 15, 2015 03:49
get current USDJPY from Yahoo! Japan Finance
curl -s http://info.finance.yahoo.co.jp/fx/ | ruby -ne '$_.match(/<span id="USDJPY_top_bid">(.*?)<\/span>/){|s| puts s[1]}'
@kazgoto
kazgoto / make-user-list-tsv.sh
Last active August 29, 2015 14:24
Active Slack User List TSV from user-list.json
cat user-list.json | jq -r '.members[] | select(.deleted==false) | "\(.id)\t\(.name)\t\(.real_name)"'
@kazgoto
kazgoto / unescape-unicode.sh
Last active December 28, 2017 16:13
Ruby One Liner to unescape unicode chars in JSON
cat unicode-escaped.json | ruby -ne 'puts $_.gsub(/\\u([\da-fA-F]{4})/) { [$1].pack("H*").unpack("n*").pack("U*") }'