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'); | |
if (process.argv.length < 3) { | |
throw new Error('Input file name'); | |
} | |
var f = process.argv[2]; | |
fs.readFile(f, 'utf8', function (err, data) { | |
if (err) { |
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
fs.readFile(image_origial, function(err, original_data){ | |
fs.writeFile('image_orig.jpg', original_data, function(err) {}); | |
var base64Image = original_data.toString('base64'); | |
var decodedImage = new Buffer(base64Image, 'base64'); | |
fs.writeFile('image_decoded.jpg', decodedImage, function(err) {}); | |
}); |
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 http = require('http'); | |
// Create an HTTP server | |
var srv = http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('okay'); | |
throw 'Error'; | |
}); | |
srv.listen(9999, '127.0.0.1', function() { |
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
describe('test my-moudle.js', function () { | |
describe('test foo() function', function () { | |
describe('Check parameter', function () { | |
it('Empty paramters', function () { | |
foo().should.be.an.instanceof(Array); | |
}); |
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
it('Throw test', function () { | |
(function () { | |
foo(); | |
}).should.throw; | |
}); |
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
it('비동기 테스트', function (done) { | |
foo(function () { | |
done(); | |
}); | |
}); |
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
all: foo boo | |
foo: | |
mocha test_foo.js -R spec | |
boo: | |
mocha test_boo.js -R spec -t 5555 |
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
app.filter('parseUrl', function() { | |
var //URLs starting with http://, https://, or ftp:// | |
replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim, | |
//URLs starting with "www." (without // before it, or it'd re-link the ones done above). | |
replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim, | |
//Change email addresses to mailto:: links. | |
replacePattern3 = /(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})/gim; | |
return function(text, target, otherProp) { | |
angular.forEach(text.match(replacePattern1), function(url) { |
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
<!doctype html> | |
<html ng-app="Demo" ng-controller="AppController"> | |
<head> | |
<meta charset="utf-8" /> | |
<title> | |
Lazy Loading Images With AngularJS | |
</title> | |
<style type="text/css"> |
OlderNewer