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
<?php | |
$url = ""; // ここにgoogle siteのURLをかきます。例: $url = "http://sites.google.com/site/suzukisaigai/"; | |
$a="SHIFT_JIS"; | |
$b="text/html; charset=$a"; | |
header("Content-Type:$b"); | |
echo preg_replace("/ead>/","ead><meta http-equiv=Content-Type content='$b'>", mb_convert_encoding(file_get_contents($url), $a, "UTF-8")); |
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 spawn = require('child_process').spawn, | |
iconv = spawn('iconv', ['-f', 'euc-jp', '-t', 'utf-8']), | |
fs = require('fs'); | |
var filename = __dirname + '/eucjp.html'; | |
var stream = fs.createReadStream(filename); | |
stream.pipe(iconv.stdin); | |
iconv.stdout.on('data', function(data) { |
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
module.exports = (function() { | |
var l = console.log; | |
var assert = require("assert"); | |
var c = 0; | |
var t = 0; | |
function result(name, reset) { | |
l("\n/*-----------------------"); | |
l(" * test: [ "+ name + " ]"); | |
l(" * result: "+ c + "/" + t + " ->" + parseInt(100*c/t) +'%' ); | |
if ( c > 0 && c == t) { |
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 fs = require('fs'); | |
var stream = fs.createWriteStream(__dirname + '/out.txt'); | |
var str = 'hogehogefugafugafoobarpiyo['; | |
for ( var i=0; i < 1000000000; i++) { // 1Gtimes | |
stream.write(str + i + ']\n'); | |
} | |
stream.on('drain', function() { | |
console.log('drain'); // never happen |
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 if just "obj.hoge" is setter or getter */ | |
var obj = {}; | |
Object.defineProperty(obj, 'hoge', { | |
get: function(){console.log("get")}, | |
set: function(){console.log("set")} | |
}); | |
obj.hoge; | |
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 spawn = require('child_process').spawn; | |
var exec = require('child_process').exec; | |
var LineStream = require('linestream'); | |
var parallel = Number(process.argv[2]) || 40; | |
var N = 1000; | |
var script = 'number.js'; | |
var total = 0; | |
var endcount = 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
function compare_version(v1, v2) { | |
var v1a = v1.split('.'); | |
var v2a = v2.split('.'); | |
var c; | |
for (var i=0, l=Math.max(v1a.length, v2a.length); i<l; i++) { | |
c = (v1a[i] || 0) - (v2a[i] || 0); | |
if (!c) continue; | |
return (c > 0) ? 1 : -1; | |
} | |
return 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
function WeightedSelection(table, random) { | |
// TODO validate first. | |
this.names = Object.keys(table); | |
this.hists = this.names.map((function() { | |
var total = 0; | |
return function(v) { | |
total += Number(table[v]); | |
return total; | |
}; | |
})()); |
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 total = 1000; | |
var err_limit = 10; | |
for (var i=0, e=0; i<total && e<err_limit; i++) { | |
if (Math.random() > 0.750) { | |
console.log("error"); | |
e++; | |
i--; | |
} | |
else { | |
console.log("ok"); |
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
function SortedList(arr, options) { | |
if (arr instanceof Array) { | |
return SortedList.build(arr, options); | |
} | |
this.arr = []; | |
options = options || {}; | |
Object.keys(options).forEach(function(k) { | |
this[k] = options[k]; | |
}, this); | |
} |
OlderNewer