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
console.log( $('<div>').append($obj.clone()).remove().html() ); |
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
#include <stdio.h> | |
#include <string.h> | |
void print_result(int result[], int len) { | |
int i; | |
if(len == 0) | |
printf("NOTHING\n"); | |
else { | |
for(i = 0; i < len; i++) | |
printf("%d ", result[i]); |
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
#include <stdio.h> | |
int count = 0; | |
void subset_sum(int k, int n, int r) { | |
if(n < 0) | |
return; | |
if(r == 0 && n == 0) { | |
count++; | |
return; |
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 Promise = require('bluebird'); | |
var request = require("request-promise"); | |
//////////////////////////////////////////// | |
function requestWithRetry(param, maxRetry) { | |
//////// Inner function //////// | |
function retryBlock(iter, timeout) { |
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 timeout(sec) { | |
if(sec == 0) | |
return Promise.resolve(); | |
return new Promise( | |
(fulfill, reject) => { | |
setTimeout( | |
() => fulfill(Promise.resolve()), | |
sec * 1000 | |
) | |
} |
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
let LOG_FILE = parseInt((new Date()).getTime() / 1000); | |
let winston = require('winston'); | |
winston.remove(winston.transports.Console); | |
winston.add(winston.transports.File, { | |
"name": "debug-log", | |
"json": false, | |
"filename": `log/${LOG_FILE}-debug.log`, | |
"level": "debug" |
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
const spawn = require('child-process-promise').spawn; | |
function convert(conf) { | |
let promise = spawn('convert', conf.cmd); | |
let proc = promise.childProcess; | |
let total = []; | |
proc.stdin.write(conf.bgImageStream); | |
proc.stdin.end(); |
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
const Promise = require('bluebird'); | |
let array = [ | |
10, 10, 10, 10, 10, 10 | |
]; | |
return Promise.reduce(array, | |
(total, key, idx) => { | |
console.log(idx); | |
if(total == 20) |
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 DBPool() { | |
let constants = require('./constants.json'); | |
return mysql.createPool({ | |
"host": constants.SC_DB_HOST, | |
"user": constants.SC_DB_USER, | |
"password": constants.SC_DB_PASSWORD, | |
"database": constants.SC_DB_NAME | |
}); | |
} |
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 params = { | |
Records: [ /* required */ | |
{ | |
Data: new Buffer('...') || 'STRING_VALUE', /* required */ | |
PartitionKey: 'STRING_VALUE', /* required */ | |
ExplicitHashKey: 'STRING_VALUE' | |
}, | |
/* more items */ | |
], | |
StreamName: 'STRING_VALUE' /* required */ |
OlderNewer