This file contains 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
/** | |
* @param {Object} query - query parameter object | |
* @param {String} `application/x-www-form-urlencoded` encoded string | |
*/ | |
function param(query) { | |
var list = []; | |
for(var key in query) { | |
var val = query[key]; | |
if ('object' === typeof val) { |
This file contains 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
server_tokens off; |
This file contains 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 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 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 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 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 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 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 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) { | |
// | |
} |
OlderNewer