This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @example | |
| * var app = express(); | |
| * app.use(wrapError); | |
| * app.use(yourMiddleware); | |
| */ | |
| function wrapError(req, res, next) { | |
| var superSend = res.send; | |
| res.send = _send; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Fetch and parse HTML as a JSON representation | |
| * @license MIT | |
| * @author kawanet | |
| * @example | |
| * var parser = require("./html_parser"); | |
| * var url = "https://github.com/kawanet"; | |
| * parser(url, function(err, data) { | |
| * if (err) return console.error(err); | |
| * console.log(JSON.stringify(data, null, " ")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <a href="javascript:(function(){if (location.host != 'suumo.jp') {location.href = 'http://suumo.jp';return;}$('.property_unit').each(function(idx, div) {var m,p,q,r,s,t,u,v;m = {};$(div).find('dt').each(function(idx, dt) {$dt = $(dt);m[$dt.text()] = $dt.parent().find('dd');});t = function($e) {return $e.text().replace(/[\s\r\n]+/g, '').replace(/^\D+/, '').replace(/[^\d\.\,].*$/, '');};p = m['販売価格'] || m['賃料'];s = m['専有面積'] || m['建物面積'];r = t(p) / t(s) * 3.3;u = (r > 10) ? (Math.round(r*10)/10 + '万') : Math.round(r*10000);q = p.find('span:first') || p;q.append('(' + u + '円/坪)');});})()">Suumo</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| trap "pkill -P $$" EXIT | |
| # do something |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require("fs").writeFileSync("build.json",JSON.stringify(require("obop").update({$inc:{build:1}})(JSON.parse(require("fs").readFileSync("build.json"))))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 文字列から ArrayBuffer への変換 | |
| function string_to_buffer(src) { | |
| return (new Uint16Array([].map.call(src, function(c) { | |
| return c.charCodeAt(0) | |
| }))).buffer; | |
| } | |
| // ArrayBuffer から文字列への変換 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @see https://github.com/yomotsu/JS_Packer | |
| // JS_Packer の自己解答処理コードの代案。for ループの文字列結合は遅そうなので join("") を使う。 | |
| // 画像全体を一括処理すると RangeError: Maximum call stack size exceeded. になりそうなので、行単位で変換してから join("") する。 | |
| // でも、元のコードよりも、長くなっちゃった。JS_Packer は小さくするのが主目的で、処理時間は関係ないのか。 | |
| function unpack_JS_Packer() { | |
| var i = document.getElementsByTagName("img")[0]; | |
| var c = document.createElement("canvas").getContext("2d"); | |
| c.drawImage(i, 0, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // $("#id").remove(); | |
| Array.prototype.forEach.call(document.querySelectorAll("#id"), Function.prototype.call.bind(document.body.remove)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var VERBOSE = Array.prototype.filter.call(process.argv, RegExp.prototype.test.bind(RegExp("^-v$"))).length; | |
| console.error("error"); | |
| if (VERBOSE > 0) console.warn("warn"); | |
| if (VERBOSE > 1) console.log("log"); | |
| if (VERBOSE > 2) console.info("info"); | |
| if (VERBOSE > 3) console.debug("debug"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| if (!module.parent) CLI.apply(null, Array.prototype.slice.call(process.argv, 2)); | |
| function CLI(arg1, arg2) { | |
| // | |
| } |