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
| (function() { | |
| var d = document, | |
| s = d.createElement('script'); | |
| s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'; | |
| s.onload = function() {(function($) { | |
| // $('body') ... | |
| })(jQuery)}; | |
| d.body.appendChild(s); |
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 count = 0; | |
| function countUp() { | |
| count++; | |
| process.nextTick(countUp); | |
| } | |
| countUp(); | |
| setInterval(function() { | |
| var c = count; | |
| count = 0; | |
| console.log(c + ' count/s, ' + parseInt(c / 1000) + ' tick/ms'); |
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
| function now() { | |
| var d = new Date(), | |
| yyyy = d.getYear() + 1900, | |
| MM = ('0' + (d.getMonth() + 1)).slice(-2), | |
| dd = ('0' + d.getDate()).slice(-2), | |
| hh = ('0' + d.getHours()).slice(-2), | |
| mm = ('0' + d.getMinutes()).slice(-2), | |
| ss = ('0' + d.getSeconds()).slice(-2), | |
| SSS = ('00' + d.getMilliseconds()).slice(-3); | |
| return yyyy + '-' + MM + '-' + dd + ' ' + hh + ':' + mm + ':' + ss + '.' + SSS; |
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 spawn = require('child_process').spawn; | |
| var argv = require('optimist') | |
| .usage('Usage: $0 -c [num] [cmd]\nExample: $0 -c 4 ls ..') | |
| .demand('c') | |
| .alias('c', 'concurrency') | |
| .argv; | |
| console.time(argv.$0); | |
| for (var i = 1; i <= argv.c; i++) { |
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
| function loop(fn, times, unit) { | |
| unit = unit || 10; | |
| function _loop(n) { | |
| for (var i = n; i < n + unit; i++) { | |
| fn(i); | |
| if (i === times - 1) { | |
| return; | |
| } | |
| } | |
| process.nextTick(function() { |
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
| function loop(fn, times, delay) { | |
| if (!times || times < 0) { | |
| throw new Error('illegal parameter times', times); | |
| } | |
| if (!delay || delay < 0) { | |
| throw new Error('illegal parameter delay', delay); | |
| } | |
| function _loop(n) { | |
| if (n === times) { | |
| return; |
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 Benchmark = require('benchmark'); | |
| var options = { | |
| onStart : function() { | |
| console.log('h1. ' + this.name + 'で一番速いのは?'); | |
| }, | |
| onCycle : function(event, bench) { | |
| console.log('* ' + bench.name + '\t' + bench.hz.toFixed(bench.hz < 100 ? 2 : 0)); | |
| }, | |
| onComplete : function() { |
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
| for x in optimist async jshint; do | |
| if ! npm ls -g | grep $x > /dev/null; then | |
| npm install -g $x | |
| fi | |
| done |
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
| use strict; | |
| use warnings; | |
| for my $js(<*.js>) { | |
| open my $new, '>', "$js.2" or die $!; | |
| open my $old, '<', $js or die $!; | |
| my $spaces = ''; | |
| while (my $line = <$old>) { | |
| if (!$spaces && (($spaces) = ($line =~ /^(\s+)config.hoge/))) { |
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 fs = require('fs'); | |
| var buffer = ''; | |
| var out = fs.createWriteStream('test.txt', { | |
| encoding: 'utf8', | |
| mode: 0644, | |
| }); | |
| process.stdin.resume(); | |
| process.stdin.setEncoding('utf8'); |
OlderNewer