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
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
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
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
// set timezone | |
process.env.TZ = 'Asia/Seoul'; | |
// winston object | |
var winston = require('winston'); | |
var logger = new (winston.Logger)({ | |
transports: [ | |
new (winston.transports.File)({ | |
filename: 'error.log', | |
json: false, |
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 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
<?php | |
/* | |
Plugin Name: My Test Widget | |
Plugin URI: http://wordpress.org/plugins/??? | |
Description: Test widget. | |
Author: Jeonghwan Kim | |
Version: 1.0 | |
Author URI: mailto:ej88ej@gmail.com | |
*/ |
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, b, 두 배열을 정렬하며 merge하는 함수 | |
void merge(int a[], int n, int b[], int m) { | |
int *c = (int *)calloc(sizeof(int), (n + m)); | |
int i = 0, j = 0, k = 0; | |
while (k < n + m) { | |
// 두 배열중 1개가 종료되면 루프에서 벗어남. | |
if (i >= n || j >= m) break; | |
// 두 배열의 값을 비교하여 순서대로 합침. |
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
// Heap 구조에 따라 출력 로직도 변경되어야 함 (1 ~ n까지만 출력) | |
void print_array(int a[], int n) { | |
for (int i = 1; i <= n; i++) { | |
printf("%3d", a[i]); | |
} | |
} | |
void foo(int a[], int n) { | |
printf("[Before] "); | |
print_array(a, n); |