Skip to content

Instantly share code, notes, and snippets.

Avatar

Yoshiaki Kawazu kawaz

View GitHub Profile
@kawaz
kawaz / add-digicert-to-cacerts.sh
Last active Apr 2, 2020
digicertのCA証明書をJavaに追加する
View add-digicert-to-cacerts.sh
#!/bin/bash
(
cd /tmp
wget http://cacerts.digicert.com/DigiCertSHA2SecureServerCA.crt
/bin/cp -ap /etc/pki/java/cacerts /tmp/etc_pki_java_cacerts.backup.$(sha1sum /etc/pki/java/cacerts|perl -pe's/ .*//')
keytool -import -trustcacerts -alias digicert -file DigiCertSHA2SecureServerCA.crt -keystore /etc/pki/java/cacerts -storepass changeit
/bin/cp -ap /etc/pki/java/cacerts /tmp/etc_pki_java_cacerts.backup.$(sha1sum /etc/pki/java/cacerts|perl -pe's/ .*//')
diff <(keytool -list -keystore etc_pki_java_cacerts.backup.2f8da47e32696e71801b52ff57fe4b246776a850 -storepass changeit|sort) \
<(keytool -list -keystore /etc/pki/java/cacerts -storepass changeit|sort)
)
@kawaz
kawaz / dumpCurrentKeyboardInputSource.swift
Created Mar 30, 2020
macOSでIME(日本語入力)の情報を取得する
View dumpCurrentKeyboardInputSource.swift
#!/usr/bin/swift
import Carbon
// Carbon.h -> HIToolbox.h -> TextInputSources.h
// grep "extern const" /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/TextInputSources.h
let props: [CFString] = [
kTISPropertyInputSourceCategory,
kTISPropertyInputSourceType,
kTISPropertyInputSourceIsASCIICapable,
kTISPropertyInputSourceIsEnableCapable,
@kawaz
kawaz / run-x-app-on-mac.sh
Created Feb 3, 2020
MacでDocker内のXアプリケーションを実行する手順
View run-x-app-on-mac.sh
# MacにXサーバを入れる(XQuartsの設定→セキュリティ→ネットワーククライアントからの接続を許可をチェックする)
brew cask install xquartz
# XQuarts で OpenGL を使えるようにする
defaults write org.macosforge.xquartz.X11 enable_iglx -bool true
# デモ用のイメージを作成
docker build -t xdemo -f <(echo $'FROM alpine\nRUN apk --no-cache add xeyes mesa-demos') .
# デモを実行してみる
docker run --rm -e DISPLAY=$(hostname):0 -v ~/.Xauthority:/root/.Xauthority xdemo xeyes
@kawaz
kawaz / setup-autoreboot-on-oom-killer.sh
Last active Jan 21, 2020
OOM-Killer が発動したら自動でリブートさせるやつを設定するやつ(コピペ実行で摘要できます)
View setup-autoreboot-on-oom-killer.sh
#!/bin/bash
(
echo '# OOM-Killer が発動したら自動でリブートさせるやつを設定するやつ'
echo '# https://gist.github.com/kawaz/1605bec92acac16d0638591e4bbfd5b1'
echo vm.overcommit_memory = 1
echo vm.panic_on_oom = 1
echo kernel.panic = 1
) > /etc/sysctl.d/99-custom-autoreboot-on-oom-killer
sysctl -p /etc/sysctl.d/99-custom-autoreboot-on-oom-killer
# SWAP止めちゃう
@kawaz
kawaz / cfn.cue
Last active Aug 1, 2021
[CUE](https://cuelang.org/) の練習で CloudFormation のテンプレート定義を適当に書き下してみた。
View cfn.cue
package cfn
Template:: close({
AWSTemplateFormatVersion?: "2010-09-09"
Transform?: string | [...string]
Description?: string
Metadata?: [string]: Value
Parameters?: [string]: Parameter
Mappings?: [string]: [string]: [string]: _
Conditions?: [string]: Condition
@kawaz
kawaz / find-iphone.sh
Created Sep 16, 2019
iphoneを探すのメモ
View find-iphone.sh
#!/bin/bash
username='apple-id@example.com'
password='apple-id-no-password'
authheader="Authorization: Basic $(echo -n "$username:$password" | base64)"
url_initClient="https://fmipmobile.icloud.com/fmipservice/device/$username/initClient"
url_playSound="https://fmipmobile.icloud.com/fmipservice/device/$username/playSound"
# initClient
curl -vXPOST "$url_initClient" -H "$authheader" > initClient.json
@kawaz
kawaz / Dockerfile
Created Aug 2, 2019 — forked from jgamblin/Dockerfile
Apple_Blee Dockerfile
View Dockerfile
FROM ubuntu:18.04
RUN apt-get update && \
apt-get upgrade -y
RUN apt-get update && \
apt-get install -y \
bluetooth \
bluez \
cmake \
@kawaz
kawaz / DefaultKeyBinding.dict
Last active May 14, 2021
macOSのテキスト系コンポーネントでのキーカスタマイズ
View DefaultKeyBinding.dict
// https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html
// ^ for Control
// $ for Shift
// ~ for Option
// @ for Command
// # for numeric keypad
{
// home/end
"\UF729" = "moveToBeginningOfLine:";
@kawaz
kawaz / install-fonts-HackGen.sh
Last active Jan 23, 2021
HackGen フォントを入れる(最近はもう `brew install --cask homebrew/cask-fonts/font-hackgen` だけで行ける)
View install-fonts-HackGen.sh
#!/bin/bash
set -e
latest_zip=$(curl -sL https://api.github.com/repos/yuru7/HackGen/releases/latest | jq -r '.assets|map(select(.name|test("^HackGen_v.*\\.zip$")))[].browser_download_url')
d=$(mktemp -d "${TMPDIR:-/tmp}/${1:-install-fonts-HackGen.sh}.XXXXXXXXXX")
curl -sL "$latest_zip" | tar xz -C "$d"
mv "$d"/*.ttf ~/Library/Fonts
rm -rf "$d"
fc-cache -vf
@kawaz
kawaz / nodejs-schedule.sh
Last active Mar 1, 2019
https://github.com/nodejs/Release/blob/master/schedule.json を用途別に使いやすく整形するスクリプト
View nodejs-schedule.sh
curl -sL https://raw.githubusercontent.com/nodejs/Release/master/schedule.json | jq --arg today "$(date -u +%Y-%m-%d)" '
. as $a | keys | map({release:.}+$a[.]) | sort_by(.start) | reverse |
{
pending: map(select(.start>$today)),
current: map(select(.start<=$today and .lts==null))[0:1],
active_lts: map(select(.lts and .lts<=$today and .maintenance>$today)),
maintenance_lts: map(select(.lts and .lts<=$today and .maintenance<=$today and .end>$today)),
end: map(select(.end<=$today))
}'