ジョジョの奇妙な冒険 Advent Calendar 2013 2日目。
特にネタがないので今年買ったジョジョ関連のものの感想などをだらだらと書こう。
書けばよかろうなのだァァッ!
はい。
| (function() { | |
| function Dispatcher() { | |
| this.routes = []; | |
| } | |
| Dispatcher.prototype.route = function route(path, action) { | |
| this.routes.push({ path: path, action: action }); | |
| return this; | |
| }; |
| 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)); |
| (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 } | |
| }); |