Skip to content

Instantly share code, notes, and snippets.

@koyudoon
koyudoon / xsel-test.zsh
Created December 31, 2014 21:30
xsel issue
#! /bin/zsh
for i in {3900..4100}; do
cmd="cat /dev/urandom | tr -dc '[:alnum:]' | head -c $i | xsel -ib; xsel -ob | wc -c"
echo "$ $cmd"
eval $cmd
done
$ zsh --version
zsh 5.0.7 (x86_64-unknown-linux-gnu)
$ xsel --version
xsel version 1.2.0 by Conrad Parker <conrad@vergenet.net>
$ history -nm 'find *' 1 | wc -l
107
@koyudoon
koyudoon / PKGBUILD
Created November 1, 2014 08:16
Arch Linux AUR PKGBUILD for lilyterm-git
# Maintainer : koyudoon <koyudoon at gmail dot com>
# Contributors by way of lilyterm package in arch repos
# Contributor: Kyle Keen <keenerd@gmail.com>
# Contributor: TDY <tdy@gmx.com>
# Contributor: DonVla <donvla@users.sourceforge.net>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>
pkgname=lilyterm-git
provides=('lilyterm')
@koyudoon
koyudoon / getVolumeForXmobar.sh
Last active August 29, 2015 14:06
This script generates a volume level indicator for use in Xmobar.
#! /bin/sh
# getVolumeForXmobar.sh
# based on: https://bbs.archlinux.org/viewtopic.php?id=74842
# UUID: a9160756-7e31-4daa-a26a-010fe05e762f
# 状態の取得
vol=`amixer get Master`
@koyudoon
koyudoon / result.md
Last active August 29, 2015 14:06
ShellScript で標準入力を処理したいとき (間違っている可能性大)
$ sh stdin.sh
端末
$ sh stdin.sh < /dev/null
リダイレクト
stdin:
$ cat /dev/null | sh stdin.sh
名前付きパイプ
stdin:
@koyudoon
koyudoon / REDME.md
Last active August 29, 2015 14:06
github で公開されているプロジェクトの description を手っ取り早く取得する

require

  • zsh
  • wget
  • jq

usage

$ () { wget -q "https://api.github.com/repos/$1" -O - | jq -r -M '.description' } 'USER/REPO'
@koyudoon
koyudoon / revealjs4printing.bml.js
Created September 14, 2014 04:37
reveal.js 製のスライドショーを印刷用の一括表示にするブックマークレット
// description: reveal.js 製のスライドショーを印刷用の一括表示にする
// UUID: c72f4e91-210a-4840-9d72-050ffe7c44ab
// javascript:(function(){var a,b;a=Array.prototype.slice.call(document.querySelectorAll("script"));b=/reveal(\.min)?\.js$/;1>a.filter(function(a){return b.test(a.src)}).length||location.replace([location.origin,location.pathname,"?print-pdf#/"].join(""))})();
(function() {
var eles_script, re, revealjs;
eles_script = Array.prototype.slice.call(document.querySelectorAll('script'));
re = /reveal(\.min)?\.js$/;
@koyudoon
koyudoon / decimal_round.bc
Last active August 29, 2015 14:06
Round off the decimal value in GNU bc
#! /usr/bin/bc
# UUID: 3bf231de-04dc-4c02-92f4-20b891a6f50d
# based on: http://gauc.no-ip.org/awk-users-jp/blis.cgi/DoukakuAWK_294
define decimal_round(num, decimal_pos) {
if ( decimal_pos <= 0 ) halt
decimal_pos = decimal_pos - 1
scale = decimal_pos
#! /bin/sh
# require: [zsh, git, ghq, porg]
HOME_BIN="${HOME_BIN:-$HOME/bin}"
ZSH_COMP_DIR="${ZSH_COMP_DIR:-$HOME/.zsh/vendor/completion}"
GHQ_DIR="${GHQ_DIR:-$(\
eval printf '%s' "$(git config --get 'ghq.root')"\
)}"
@koyudoon
koyudoon / gist:f22c8d92ea32fba104e8
Last active August 29, 2015 14:04
今まで適当に git clone していたのを ghq で管理するために、対象プロジェクトを点呼する。
find $HOME -name '.git' -print0 | while read -r -d '' f; do
() {
cd ${f%/*}
local remote="$(git remote)"
[ -z "$remote" ] && continue
pwd
git remote -v
echo
}