Skip to content

Instantly share code, notes, and snippets.

@yonchu
yonchu / puyo_another.py
Created September 27, 2014 10:58
Puyo in Python
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Puyo in Python.
Original code:
http://qiita.com/arc279/items/d0a0bc2cfc710f7b1ffe
http://okajima.air-nifty.com/b/2011/01/2011-ffac.html
"""
@yonchu
yonchu / _grunt.zsh
Last active December 20, 2015 07:29
解説用 grunt 補完
#compdef grunt
### 変数や関数を使用する場合の注意
# - 変数を使用する場合は、定義が グローバル に漏れないよう、必ず local or typeset(declare) コマンド使って変数宣言を行うこと
# - 関数はグローバルに定義されるため、重複しないよう名前付けには十分配慮すること
# − 短い補完関数であれば、関数を使わずに書くと良い
function __grunt() {
### 必要な変数を定義
# 現在のコンテキスト(curcontext) を保存
@yonchu
yonchu / _httpstatus.zsh
Last active December 14, 2015 01:19
httpstatusコマンド用zsh補完関数
#compdef httpstatus
#
# httpstatus コマンド用zsh補完関数
#
# このファイルfpathの通ったディレクトリに置きzshを再起動して下さい。
# その際ファイル名を必ず _httpstatus として下さい。
#
# $ cp _httpstatus /usr/local/share/zsh/site-functions
# $ exec zsh
#
@yonchu
yonchu / zaw-git-log.zsh
Last active December 10, 2015 00:19
zaw-src-git-log : Select commit hash from git log with zaw.
#
# zaw-src-git-log
#
# zaw source for git log.
# https://gist.github.com/4350604
#
# zaw : https://github.com/nakamuray/zaw
#
# git log pretty format: For detail, refer to "man git-log"
@yonchu
yonchu / zaw.plugin.zsh
Last active December 9, 2015 22:38
zaw for zsh settings
#
# zaw
#
# https://github.com/zsh-users/zaw
# https://github.com/nakamuray/zaw
#
# zsh anything.el-like widget
#
# Execute action by pressing enter key or
# press Meta-enter for alternative action.
@yonchu
yonchu / directory_aliases.zsh
Created December 3, 2012 21:30
zshでよく使うディレクトリにエイリアスを設定(~/.zshrcに設定して利用します)
### Directory aliases
# e.x.
# $ hash -d hoge=/to/path
# $ ls ~hoge
set_hash_in_links() {
local links=~/links
[ ! -d "$links" ] && return 0
[ $(command ls -1 "$links" | wc -l) -eq 0 ] && return 0
local src
local target
@yonchu
yonchu / cdsite.sh
Created November 25, 2012 18:32
pythonのsite-packagesディレクトリへ移動(cd)
# Add the following function to ~/.bashrc or ~/.zshrc
function cdsite() {
local py_cmd
py_cmd=`cat << 'EOF'
from __future__ import print_function
import sys
import os
import site
@yonchu
yonchu / edit-command.sh
Created November 19, 2012 12:55
$vim `which command` を手軽に
#!/bin/sh
#
# Edit command source
#
if [ $# -lt 1 ]; then
echo 'Should specify commands you want to edit' 1>&2
exit 1
fi
@yonchu
yonchu / br.sh
Created October 23, 2012 01:26
MacのHomebrewの詳細情報を表示, Formula指定にて詳細情報表示も可
#!/bin/sh
#
# 引数なし
# - homebrewの情報を色々表示
#
# 第1引数:
# - Formula名指定でFormulaの詳細情報を表示
# - マッチするFormulaがない場合は検索
#
if ! type brew >/dev/null 2>&1; then
@yonchu
yonchu / gits.sh
Created October 23, 2012 01:14
Gitリポジトリの色んな情報を表示. どんなリポジトリなのかを瞬時に把握するのに便利
#!/bin/bash
#
# Print detail infomation about current git repository.
#
if ! type git > /dev/null 2>&1; then
echo 'Error: Git is not installed' 2>&1
exit 1
fi