Skip to content

Instantly share code, notes, and snippets.

@smeghead
smeghead / gist:11205195
Created April 23, 2014 07:04
testの戻り値がtrueになってから、procを実行する関数
var execAfter = function(test, proc) {
var timer = setInterval(function(){
if (test()) {
clearInterval(timer);
proc();
return;
}
}, 500);
};
@smeghead
smeghead / missing_modules.pl
Created July 16, 2012 15:12
check missing modules.
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Data::Dumper;
die 'no argument.' if scalar @ARGV < 1;
my $check_path = $ARGV[0];
my $uses = `fgrep -r 'use ' $check_path | sed -e 's/.*use \\([A-Z][a-zA-Z0-9:]\\+\\).*/\\1/' | grep -v '^/' | sort | uniq`;
@smeghead
smeghead / gist:2651925
Created May 10, 2012 08:41
一括置換
find . -name '*.ext' | xargs -n 1 perl -pi.bak -e 's/before string/after string/'
@smeghead
smeghead / rename.sh
Created April 25, 2012 07:59
拡張子の変更
for f in *.php; do n=${f%.*}; mv $n.php $n.tx; done;
@smeghead
smeghead / ja.po
Created April 20, 2012 14:50
Locale::Maketext::Simpleが動かない
msgid "hello"
msgstr "konnnitiwa"
@smeghead
smeghead / sslcert-check
Created November 10, 2011 01:01
check ssl cert expire.
#!/bin/sh
if [ $# == 0 ]; then
echo "usage: $1 <ssl cert file>"
exit 1
fi
FILENAME=$1
if [ ! -f "$FILENAME" ]; then
echo "ERROR: <ssl cert file> not exists. $FILENAME"
exit 1
(defn fib [n]
(cond
(< n 0) (throw (IllegalArgumentException. "fib argument must be plus number."))
(= n 1) 1
(= n 2) 1
:else (+ (fib (- n 2)) (fib (- n 1)))))
(loop [x 1]
(if (< x 10)
(do
@smeghead
smeghead / sample.clj
Created October 1, 2011 15:37
sample
(defn hogehoge [x]
(let [x 0
y 0]
hoge)
(fn [x 0
y 0]
(+ x y)))
@smeghead
smeghead / default
Created August 26, 2011 01:41
apache killer killer
# for Apache Killer. ignore Range Header.
RewriteEngine on
RewriteCond %{HTTP:range} !(^bytes=[^,]+(,[^,]+){0,4}$|^$)
RewriteRule .* - [F]
@smeghead
smeghead / perl.vim
Created July 27, 2011 09:58
perltidy on vim
map ,ptv <Esc>:'<,'>! LANG=C perltidy<CR>
map ,pt <Esc>:%! LANG=C perltidy<CR>