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
void shell_sort(int a[], int n) { | |
for (int interval = n/2; interval > 0; interval /= 2) { | |
for (int start = 0; start < interval; start++) { | |
select_sort(a, n, start, interval); | |
} | |
} | |
} | |
// 시작위치(start)와 Interval을 지정하여 select sort 수행하는 함수 | |
void select_sort(int a[], int n, int start, int interval) { |
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
void quick_sort(int a[], int n) { | |
// 종료 조건 | |
if (n < 2) { | |
return; | |
} | |
// pivot 기준으로 좌우 이동 | |
int pivot = a[n-1]; // 마지막 요소를 pivot으로 설정 | |
int left = -1; | |
int right = n-1; |
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); |
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
<?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
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
// 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
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); | |
}); |