Skip to content

Instantly share code, notes, and snippets.

View AmaiSaeta's full-sized avatar
👨‍💻
PROGRAMMING is the contemporary MAGIC!

天井冴太 AmaiSaeta

👨‍💻
PROGRAMMING is the contemporary MAGIC!
View GitHub Profile
@AmaiSaeta
AmaiSaeta / gist:03bc032a2548d022032932109e363cb2
Last active June 19, 2023 08:07
試作:Gitで、削除済みのリモートブランチの追跡ブランチに対する操作を行うalias
# 以下を、.gitconfigの「[alias]」セクションに追記する。
# git ls-gone : リモートブランチの削除された、リモート追跡ブランチを一覧する。 FIXME: 順次問い合わせを行っている都合上、遅い。
# git rm-gone : リモートブランチの削除された、リモート追跡ブランチを削除する。
ls-gone = "!f() { git branch --remotes | awk '{ print $1 }' | while read branchname; do git ls-remote --exit-code $(echo $branchname | sed --expression 's|/| |') &>/dev/null; if [[ $? -eq 0 ]]; then continue; fi; echo $branchname; done }; f"
rm-gone = "!f() { git ls-gone | while read branchname; do git branch --delete --force ${branchname#*/} && git branch --remotes --delete $branchname; done }; f"
@AmaiSaeta
AmaiSaeta / pre-commit
Last active May 31, 2022 05:38
スクリプトファイル(shebangが書かれているファイル)にGitリポジトリ上の実行パーミッションが付与されていない場合にcommitをエラーにするpre-commit hook(主にGit for Windows向け)
#!/bin/bash
exist_non_exec_perm_exec_file=0
git diff --cached --name-only --diff-filter=AM | while read path
do
if head -1 "$path" | grep '^#!' > /dev/null &&
git ls-files -s "$path" | grep '^100644' > /dev/null
then
echo $(tput smso)\*\*WARNING\*\*$(tput rmso) $path maybe need \"execution\" permission. Run \`git update-index --add --chmod=x $path\` >&2
exist_non_exec_perm_exec_file=1
data:application/json,{"configversion":"1.8","subconfigs":{"www.google.com":{"followpagepatterns":{"next":"Next","prev":"Previous"}}},"priority":0,"exmaps":{"<Enter>":"ex.accept_line","<C-j>":"ex.accept_line","<C-m>":"ex.accept_line","<Escape>":"ex.hide_and_clear","<ArrowUp>":"ex.prev_history","<ArrowDown>":"ex.next_history","<C-a>":"text.beginning_of_line","<C-e>":"text.end_of_line","<C-u>":"text.backward_kill_line","<C-k>":"text.kill_line","<C-c>":"text.kill_whole_line","<C-f>":"ex.complete","<Tab>":"ex.next_completion","<S-Tab>":"ex.prev_completion","<Space>":"ex.insert_space_or_completion"},"ignoremaps":{"<S-Insert>":"mode normal","<AC-Escape>":"mode normal","<AC-`>":"mode normal","<S-Escape>":"mode normal","<C-^>":"tab %23","<C-6>":"tab %23"},"imaps":{"<Escape>":"composite unfocus | mode normal","<C-[>":"composite unfocus | mode normal","<C-i>":"editor","<AC-Escape>":"mode normal","<AC-`>":"mode normal","<C-6>":"tab %23","<C-^>":"tab %23","<S-Escape>":"mode ignore"},"inputmaps":{"<Escape>":"composite unf
@AmaiSaeta
AmaiSaeta / webpack.config.js
Last active December 4, 2016 13:47
copy-webpack-plugin config sample
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
js: './script.js',
},
output: {
filename: '[name].js',
path: 'dist'
},
--Awesome WM configuration
-- based /etc/xdg/awesome/rc.lua
-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
#!/bin/bash
MUTE=`amixer -c 0 get Master|tail -1|cut -d '[' -f 4|sed s/\]//`
if [ $MUTE = "on" ] ; then
ICON="/usr/share/icons/HighContrast/scalable/status/audio-volume-medium.svg"
else
ICON="/usr/share/icons/HighContrast/scalable/status/audio-volume-muted.svg"
fi
:HOGEコマンド:
これはhogehogeをfugafugaします:
actual: !vimexpression foo#bar#baz('hogehoge')
expected: EXPECTED
message: テスト失敗メッセージ
内部的にはpiyopiyoです:
attribute: [ドキュメント化しないよ]
actual: !vimscript |
Foo
Bar baz
@AmaiSaeta
AmaiSaeta / gist:9291862
Last active August 29, 2015 13:56
[JavaScript] Array.flatten()
function flattenArray() {
return this.reduce(function(lhs, rhs) {
// lhs is already flatten.
if((rhs instanceof Array) && rhs.some(Array.isArray)) rhs = flattenArray.call(rhs);
return lhs.concat(rhs);
}, []);
}
@AmaiSaeta
AmaiSaeta / gist:8631399
Created January 26, 2014 11:34
(Vim) :ls の結果を、 Vim script から利用しやすい形にして返す関数
function! s:ls(all)
" Return the STRUCTURED all buffer informations that is similar :ls.
" @param[in] all Include "unlisted" buffer informations.
" @return
" Buffer informations. It's a List that contains Dictionary of a buffer
" informatin. Its Dictionary is composed these members:
" bufnr: Buffer number.
" unlisted: If 1, this buffer is "unlisted", otherwise 0.
" focus: "%" means in current window. "#" means alternate buffer.
" active: "a" means active buffer. "h" means hidden buffer.
@AmaiSaeta
AmaiSaeta / gist:7874062
Created December 9, 2013 15:34
PATHから"HOGEHOGE"を含む物を取り除くPowerShellコマンド。 "HOGEHOGE"を適時変更すれば良し。
((Get-Content Env:Path) -Split ";" | Where-Object { $_ -notmatch "\b" + "HOGEHOGE" + "\b" }) -Join ";" | Set-Content Env:Path