Skip to content

Instantly share code, notes, and snippets.

View hokaccha's full-sized avatar

Kazuhito Hokamura hokaccha

View GitHub Profile
var co = require('co');
var fs = require('fs');
co(function* () {
var a = yield fs.readFile.bind(fs, 'a.txt', 'utf8');
var b = yield fs.readFile.bind(fs, a.trim(), 'utf8');
var c = yield fs.readFile.bind(fs, b.trim(), 'utf8');
console.log(c.trim());
})();

ジョジョの奇妙な冒険 Advent Calendar 2013 2日目。

特にネタがないので今年買ったジョジョ関連のものの感想などをだらだらと書こう。

書けばよかろうなのだァァッ!

はい。

ジョジョの奇妙な冒険 オールスターバトル

# usage:
# $ mobile-safari 7.0 http://example.com/
function mobile-safari() {
VERSION=$1
URL=$2
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$1.sdk/Applications/MobileSafari.app/MobileSafari -u $2
}
var obj = {};
obj.toJSON = function() {
return { foo: 'bar' };
};
console.log(JSON.stringify(obj));
@hokaccha
hokaccha / font-awsome.jsx
Created September 18, 2013 08:36
イラレで選択したFont Awesomeの文字のクラス名を表示するスクリプト
(function() {
// Font Awesome version: 3.2.1
// map from: http://fortawesome.github.io/Font-Awesome/cheatsheet/
// You can copy for map string using this script at console.
//
// var result = {};
// $('.row .span4').each(function() {
// var $row = $(this);
// var code = ($row.find('.muted').text().match(/&#x(\w+);/) || [])[1];
var qs = require('querystring')
console.log(qs.parse('foo=1&foo=2'));
//=> { foo: [ '1', '2' ] }
console.log(qs.parse('foo[]=1&foo[]=2'));
//=> { 'foo[]': [ '1', '2' ] }
# CRuby
def foo(key: 'foo')
puts key
end
foo(key: 'hoge') #=> 'hoge'
var Model = Backbone.Model.extend({
validate: function(attr) {
var prev = this.previous('key');
console.log(prev);
}
});
var model = new Model({ key: 1 });
model.set('key', 2, { validate: true }); //=> undefined
model.set('key', 3, { validate: true }); //=> 1
// tests
describe('XHR2 Test', { hasXhr2: true }, function() {
//...
});
// setup
mocha.setup({
exclude: { hasXhr2: !support.hasXhr2 }
});
@hokaccha
hokaccha / refinements.js
Last active December 17, 2015 03:48
JavaScript implementation of Ruby2.0 Refinements.
var Refinements = {};
Refinements.modules = {};
Refinements.register = function(name, fn) {
Refinements.modules[name] = fn;
};
Refinements.using = function() {
var args = Array.prototype.slice.call(arguments);