Skip to content

Instantly share code, notes, and snippets.

View CreatiCoding's full-sized avatar
🎯
I may be slow to respond.

정석호 CreatiCoding

🎯
I may be slow to respond.
View GitHub Profile
@CreatiCoding
CreatiCoding / helloworld.c
Created July 26, 2018 09:55
hello world!
#include <stdio.h>
int main(){
printf("hello world!\n");
return 0;
}
@CreatiCoding
CreatiCoding / requestWithPromise.js
Created July 27, 2018 00:27
[Node.js] request with promise
const request = require('request');
new Promise((resolve, reject)=>{
console.log(1);
resolve(new Promise((resolve, reject)=>{
request({url:'http://www.naver.com'},()=>{
console.log(2);
resolve(3);
});
}));
}).then(data=>{
@CreatiCoding
CreatiCoding / promiseAllWithFor.js
Created July 27, 2018 00:32
[Node.js] Promise.All with for loop
// It is bad case about using Promise.All
let value = [1,2,3,4,5];
var promises = [];
for(let i=0;i<5;i++){
promises.push(
((data)=>{
return new Promise((resolve, reject)=>{
setTimeout(() => {
@CreatiCoding
CreatiCoding / install-mysql.sh
Created July 29, 2018 10:22
[bash] just install mysql for ubuntu
sudo apt-get install -y mysql-client mysql-server mysql-common
@CreatiCoding
CreatiCoding / install-node-12.sh
Last active May 18, 2019 07:07
[bash] install node 10 in ubuntu including about auth for npm directory.
sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
OUTPUT="$(npm config get prefix)"
echo "$OUTPUT"
if [ "$OUTPUT" == "/usr/local" ]; then
OUTPUT="$(sudo chown -R $USER /usr/local)"
@CreatiCoding
CreatiCoding / install-cra-express.sh
Created July 29, 2018 10:25
[bash] npm install global create-react-app and express-generator
sudo npm install -g yarn
sudo yarn global add create-react-app
sudo yarn global add express-generator
sudo yarn global add nodemon
sudo yarn global add concurrently
# 에러 발생시 global node_modules 초기화
# for create-react-app with redux and router
# yarn add redux react-redux
# yarn add react-router-dom
@CreatiCoding
CreatiCoding / printDivToPdf.js
Last active January 27, 2021 09:18
[javascript] Div to html in chrome
function printElement(ele, w = 800, h = 400){
var divContents = document.querySelector(ele).innerHTML;
var printWindow = window.open('', '', `height=${h},width=${w}`);
printWindow.document.write('<html><head><title>NoName</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.print();
}
@CreatiCoding
CreatiCoding / one_process_increase_client.cpp
Last active August 10, 2018 06:55
c++ socket tcp one process one thread increase one server and client
#include <cstdio>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <iostream>
@CreatiCoding
CreatiCoding / multithread_increase_server.cpp
Last active August 10, 2018 08:52
tcp socket one increase server with multi thread c++11
#include <cstdio>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <iostream>
#include <thread>
@CreatiCoding
CreatiCoding / CyclicRotation.js
Created September 13, 2018 08:55
[codility] CyclicRotation
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, K) {
let arr = [];
// write your code in JavaScript (Node.js 8.9.4)
if(A.length === K || K === 0 || A.length === 0){
return A;
}
for(let i = 0 ; i < K ; i ++ ){