Skip to content

Instantly share code, notes, and snippets.

View hokaccha's full-sized avatar

Kazuhito Hokamura hokaccha

View GitHub Profile
@hokaccha
hokaccha / git-export-diff
Created September 22, 2012 02:14
gitの差分のファイルをつくる
#!/bin/sh
set -e
if [ $# -ne 2 -a $# -ne 3 ]; then
echo 'Usage:'
echo ' $ git export-diff <commit> <output_dir>'
echo ' $ git export-diff <commit> <commit> <output_dir>'
exit 1
fi
// http://ejohn.org/blog/simple-javascript-inheritance/
function Class() {}
Class.extend = function extend(props) {
var SuperClass = this;
function Class() {
if (typeof this.init === 'function') {
this.init.apply(this, arguments);
@hokaccha
hokaccha / sushi
Created April 30, 2014 07:52
Macのターミナルに寿司を降らせる
$ ruby -e 'C=`stty size`.scan(/\d+/)[1].to_i;S="\xf0\x9f\x8d\xa3";a={};puts "\033[2J";loop{a[rand(C)]=0;a.each{|x,o|;a[x]+=1;print "\033[#{o};#{x}H \033[#{a[x]};#{x}H#{S} \033[0;0H"};$stdout.flush;sleep 0.01}'
@hokaccha
hokaccha / .vimrc
Created April 27, 2010 09:19 — forked from Shougo/.vimrc
" Capture {{{
command!
\ -nargs=1
\ -complete=command
\ Capture
\ call Capture(<f-args>)
function! Capture(cmd)
redir => result
silent execute a:cmd
@hokaccha
hokaccha / answer.txt
Created November 22, 2012 02:44 — forked from shigeki/hello.js
第1回Node.js入門勉強会 レポート課題
**課題1
なぜエラーが発生したのかその理由を記述しなさい。
server.close()を呼ぶとこれ以上のコネクションは受け付けなくなるが、
既存のコネクションに関してはそのまま接続された状態になる。
また、HTTPの接続はkeep-aliveで行われるため、明示的にコネクションを
終了させなければ接続がタイムアウトするまでコネクションは生きている。
最初のリクエスト(GET /)のときにserver.close()が呼ばれ、新規接続を
@hokaccha
hokaccha / assert.js
Created December 5, 2011 13:57
node.js aseert for client side javascript
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
//
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
//
// Originally from narwhal.js (http://narwhaljs.org)
// Copyright (c) 2009 Thomas Robinson <280north.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to
// deal in the Software without restriction, including without limitation the
" こういうHTMLがあったときに
" <div id="hoge" class="fuga">
" ...
" </div>
"
" 実行するとこうなる
" <div id="hoge" class="fuga">
" ...
" <!-- /div#hoge.fuga --></div>
(function() {
function Dispatcher() {
this.routes = [];
}
Dispatcher.prototype.route = function route(path, action) {
this.routes.push({ path: path, action: action });
return this;
};
import React from 'react';
import { Frame, FrameSet } from './react-flex-frame';
class App extends React.Component {
render() {
return (
<FrameSet direction="row">
<Frame width="300" resiable={true} className="side">
<h1>Side Bar</h1>
</Frame>
p AhoCorasick.new(["8年", "18年"]).match('平成18年') #=> ["18年"]
p AhoCorasick.new(["8年", "18年", "平成17年台風第11号"]).match('平成18年') #=> ["8年"]