Skip to content

Instantly share code, notes, and snippets.

@kuy
kuy / gist:675168
Created November 13, 2010 07:25
Keymapping for F1 extension
" toggle F1 panel
js <<EOF
liberator.modules.mappings.addUserMap(
[liberator.modules.modes.NORMAL],
[",f"],
'toggle F1 panel',
function(){
ffshare.toggle();
}
);
@kuy
kuy / pre-commit
Last active November 10, 2021 03:52
git: pre-commit hook script to prevent committing FIXME code
#!/bin/sh
matches=$(git diff --cached | grep -E '\+.*?FIXME')
if [ "$matches" != "" ]
then
echo "'FIXME' tag is detected."
echo "Please fix it before committing."
echo " ${matches}"
exit 1
@kuy
kuy / git
Created October 2, 2014 04:57
Detects placeholder in git command and start branch selector using peco/percol
#!/usr/bin/env bash
# NOTE: brought from rbenv https://github.com/sstephenson/rbenv/blob/master/libexec/rbenv-which
expand_path() {
if [ ! -d "$1" ]; then
return 1
fi
local cwd="$(pwd)"
cd "$1"
@kuy
kuy / posparams.sh
Created October 10, 2014 02:25
Swaps positional parameters in Bash script.
#!/bin/bash
echo "before: $#: $@"
pos=1
for arg in "$@"; do
echo "$pos: $arg"
pos=$((pos + 1))
done
args=
@kuy
kuy / np-main.sh
Created October 22, 2014 06:23
Learning Named Pipe
#!/usr/bin/env bash
root=$(cd $(dirname $0); pwd)
pipe="/tmp/np-$$"
mkfifo $pipe
echo "np-main: pipe created: $pipe"
"$root/np-sub.sh" "$pipe" "$@" &
echo "np-main: from sub: $(cat $pipe)"
@kuy
kuy / qiita-tag-search-enhancer.user.js
Created February 24, 2015 04:32
Qiita Tag Search Enhancer: Provide a way to search by multiple tags easily.
// ==UserScript==
// @name Qiita Tag Search Enhancer
// @namespace http://endflow.net/
// @version 0.2.0
// @description Provide a way to search by multiple tags easily.
// @author Yuki Kodama <endflow.net@gmail.com>
// @match http://qiita.com/*
// ==/UserScript==
$('.itemsShowHeaderTags .itemsShowHeaderTags_list')
@kuy
kuy / qiita-post-freshness.user.js
Last active March 10, 2016 15:01
Qiita Post Freshness
// ==UserScript==
// @name Qiita Post Freshness
// @namespace http://endflow.net/
// @version 0.1
// @description changes background color of header based on post's freshness.
// @author You
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser-polyfill.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.min.js
// @require https://d3js.org/d3.v4.0.0-alpha.28.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.min.js
// Presentational コンポーネント
class List extends Component {
render() {
const { items, onClick } = this.props;
return <ul>
{items.map(item =>
<li onClick={() => onClick(item)}>{item}</li>
)}
</ul>;
}
@kuy
kuy / sagas.js
Created April 24, 2016 16:45
redux-sagaを使ったとてもシンプルな認証処理
import { push } from 'react-router-redux';
function* authSaga() {
while (true) {
// ログインするまでずっと待つ
const { user, pass } = yield take(REQUEST_LOGIN);
// 認証処理の呼び出し(ここではtry-catchを使わず戻り値にエラー情報が含まれるスタイル)
let { token, error } = yield call(authorize, user, pass);
if (!token && error) {
@kuy
kuy / README.md
Last active June 9, 2016 13:38
SSリーダー開発メモ

目的

日々たくさん更新されるSS(ショートショート)まとめサイトの新着には古いものがまざっていたり、 すでに読んだことのあるSSだったりして巡回が面倒になってきている。 自分の好きな作品の新着SSの発見と既読管理、よかった作品のストック、評価を付けたりできるような サービスとそのクライアントアプリケーションの開発をする。 どこでも読めることが大事で、基本的にはスマホで使うことが多い。

機能