Skip to content

Instantly share code, notes, and snippets.

View yukidarake's full-sized avatar
🎯
Focusing

Toshiyuki Nakamura yukidarake

🎯
Focusing
View GitHub Profile
@yukidarake
yukidarake / bouncy.js
Created March 6, 2014 01:38
bouncyでAPIのレスポンスを遅延させる
var bouncy = require('bouncy');
var server = bouncy(function (req, res, bounce) {
setTimeout(function() {
bounce('xxx.xxx.xxx.xxx', 8080);
}, 8000);
});
server.listen(18080);
@yukidarake
yukidarake / gist:9306106
Created March 2, 2014 12:50
Amazon Cloud Driveで一括選択をするためのワンライナー
jQuery('tr.rowBorder td:contains(-0.JPG)').prev().find('input').click()
@yukidarake
yukidarake / DefaultKeyBinding.dict
Created February 3, 2014 09:53
Macのキーの挙動を変更する。 ~/Library/KeyBindings/DefaultKeyBinding.dict
{
"^w"="deleteWordBackward:";
"^u"="deleteToBeginningOfParagraph";
}
@yukidarake
yukidarake / fibonacci.js
Created September 19, 2013 04:44
クロージャーを利用してキャッシュすると速いよというテク
function fibonacci1(x) {
if (x < 2) {
return 1;
}
return fibonacci1(x - 1) + fibonacci1(x - 2);
}
var fibonacci2 = (function() {
var cache = {};
@yukidarake
yukidarake / say.pl
Created August 14, 2013 10:07
5.10.0以降でsay使いたい
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw(say);
say 'say!';
@yukidarake
yukidarake / macvim-kaoriya.rb
Last active December 21, 2015 01:39
MacVim-Kaoriyaをsnow leopardで入れたときに使ったFormula。 元はこちら https://github.com/splhack/homebrew-splhack brew tap splhack/homebrew-splhack で入れたが、gistの場合もできるだろうか??
require 'formula'
class MacvimKaoriya < Formula
homepage 'http://code.google.com/p/macvim-kaoriya/'
head 'https://github.com/splhack/macvim.git'
depends_on 'cmigemo-mk' => :build
depends_on 'ctags-objc-ja' => :build
depends_on 'gettext-mk' => :build
@yukidarake
yukidarake / jst.pl
Last active December 14, 2015 11:38
Perl5.10以上ならTime::Pieceが標準添付モジュールとなっている。ミリ秒のUNIXタイムをJSTにする。
perl -MTime::Piece -lane 'print localtime(gmtime($F[0]/1000)->epoch)."\t$F[1]"' hoge.log
@yukidarake
yukidarake / gist:4662008
Created January 29, 2013 05:21
行頭のコメントの下に/* jshint unused:false */を加えるというワンライナー。 ポイントは行番号$.をファイルごとにリセットする必要があるので、close ARGV if eofというイディオムを入れてみた。 あと、ackはやっぱり便利。
ack -f lib | xargs perl -i -pe 's#\*/\n#*/\n\n/*jshint unused: false */\n# if $. < 7; close ARGV if eof;'
@yukidarake
yukidarake / gist:4631890
Created January 25, 2013 04:56
new を忘れても大丈夫なパターン2種 from Effective JavaScript
function User(name) {
if (!(this instanceof User)) {
return new User(name);
}
this.name = name;
}
// better way
function User(name) {
var self = this instanceof User
@yukidarake
yukidarake / gist:4618259
Created January 24, 2013 07:12
インデントタブをスペース4に置換するワンライナー
perl -pi -e 's{^(\t+)}{q( ) x (length($1)*4)}e' **/*.js