Skip to content

Instantly share code, notes, and snippets.

View tkatochin's full-sized avatar

かとちん tkatochin

View GitHub Profile
@tkatochin
tkatochin / git-push-current.sh
Last active February 8, 2016 02:30
強制push
#!/bin/sh
git push origin `git rev-parse --abbrev-ref HEAD` -f
@tkatochin
tkatochin / is_last_commit_in_other_branch.sh
Last active April 22, 2016 05:53
あるブランチの最後のコミットが、別のブランチにマージ済みかを判定するコマンド
#!/bin/sh
if [ $# != 2 -o "$1" = "$2" ]; then
echo "Usage ${0##*/} branch1 branch2"
echo ""
echo "branch2の中に、branch1の最後のコミットが含まれているか(マージ済みか)を判定します。"
echo "以下はリモートのdevelopブランチにローカルのdevelopブランチの最後のコミットが含まれているかを判定する例です。"
echo "例) ${0##*/} develop origin/develop"
echo ""
echo "実行直後、\$? で判定結果が得られます。"
@tkatochin
tkatochin / git-dir-all
Created April 22, 2016 06:04
カレントディレクトリの直下のディレクトリから.gitを持つディレクトリをリストアップし、パラメータで渡したコマンドを各ディレクトリ内で実行する。
#!/bin/sh
for dir in `find . -maxdepth 1 -type d`; do
if [ -d $dir/.git ]; then
pushd . > /dev/null 2>&1
cd $dir
echo "======== ${dir##*/} ========"
$*
popd > /dev/null 2>&1
fi
@tkatochin
tkatochin / taputsukimasen.css
Last active June 3, 2016 08:45
はてなブログのデザインCSSのバックアップ
/* <system section="theme" selected="bordeaux"> */
@import "http://blog.hatena.ne.jp/css/theme/bordeaux/bordeaux.css";
/* </system> */
/* <system section="background" selected="bg17"> */
body{
background-color:#1a2637; background-image:url('/images/theme/backgrounds/theme17.png'); background-repeat:no-repeat; background-attachment:scroll; background-position:right top;
}
/* </system> */
/*
@tkatochin
tkatochin / backgroundCaller.js
Last active June 6, 2018 06:22
Content ScriptからBackground Script内の関数を直接呼びだす(ように見せる) ref: https://qiita.com/tkatochin/items/30e077f7a8f94d39d714
/**
* バックグラウンドにRPCする呼び出し側の実装(manifestのcontent_scriptsに記述して配備すること)
*/
'use strict';
(function(){
function createAsyncRpcFunction(methodName) {
return async function() {
const req = {
method: methodName,
@tkatochin
tkatochin / add-tkatochin-japanese.json
Last active June 8, 2018 03:14
macで英字キーボードのコマンドキーだけで英数←→かなをトグルで切り替える ref: https://qiita.com/tkatochin/items/049f02d3552382f15b75
{
"title": "For Japanese (日本語環境向けの設定) by tkatochin",
"rules": [
{
"description": "コマンドキー(左右どちらでも)を単体で押したときに、英数・かなをトグルで切り替える。",
"manipulators": [
{
"type": "basic",
"conditions": [
{
@tkatochin
tkatochin / file0.txt
Last active July 25, 2018 08:41
Promiseへの翻訳コードでasync/awaitの挙動を理解する ref: https://qiita.com/tkatochin/items/4603c4ec06fc6eb4f371
function hoge() {
// なんかかんか
var foo = ...
var bar = ...
if (foo < ...) {
return foo+bar;
}
var result = innerHoge(foo, bar);
var lastResult = ... // result使ってごにょごにょ
return lastResult;
@tkatochin
tkatochin / git-pull-origin-all.sh
Last active November 29, 2018 09:41
master、ブランチを一括pull
#!/bin/sh
export current_branch=`git rev-parse --abbrev-ref HEAD`
if [ 0 == `git status | grep -E "nothing to commit, working (directory|tree) clean" | wc -l` ]; then
echo "管理外の未コミットのファイルがあるので中止します。"
exit 1;
fi
abs_dirname() {