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 User(name) { | |
if (!(this instanceof User)) { | |
return new User(name); | |
} | |
this.name = name; | |
} | |
// better way | |
function User(name) { | |
var self = this instanceof User |
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
perl -pi -e 's{^(\t+)}{q( ) x (length($1)*4)}e' **/*.js |
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
'<,'>perld s{^(( )+)}{"\t" x (length($1)/2)}e |
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
{ | |
"root": true, | |
"esformatter": { | |
"allowShebang": true | |
}, | |
"indent": { | |
"value": " ", | |
"alignComments": true, |
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 TIMES = 10000; | |
console.time(1); | |
var array1 = []; | |
for (var i = 0; i < TIMES; i++) { | |
array1.push(Math.random()); | |
} | |
console.timeEnd(1); | |
console.time(2); |
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
use strict; | |
use warnings; | |
use utf8; | |
sub slurp { | |
my $file = shift; | |
open my $fh, $file or die $!; | |
my $content = do { | |
local $/; | |
<$fh>; |
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
use strict; | |
use warnings; | |
use utf8; | |
use Image::Magick; | |
use File::Basename; | |
use File::Path; | |
for (<*.jpg>) { | |
resize($_); | |
} |
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
my @use_chars = ( 'a' .. 'z', 0 .. 9 ); | |
my $serial_length = 7; | |
my $serian_num = 120_000; | |
for ( 1 .. $serian_num ) { | |
print random_str($serial_length), "\n"; | |
} | |
sub random_str { | |
my $length = shift; |
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 | |
var fs = require('fs'); | |
var difflet = require('difflet'); | |
var deepEqual = require('deep-equal'); | |
var read = function(file) { | |
return fs.readFileSync(file, 'utf8') | |
.split(/\n/) | |
.filter(function(line) { | |
return line; |
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
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/))) { |