URL | HTTP Verb | Action |
---|---|---|
/photos/ | GET | index |
/photos/new | GET | new |
/photos | POST | create |
/photos/:id | GET | show |
/photos/:id/edit | GET | edit |
/photos/:id | PATCH/PUT | update |
/photos/:id | DELETE | destroy |
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
// https://programmers.co.kr/learn/courses/30/lessons/42576 | |
function solution(p, c) { | |
var size = c.length; | |
// 이렇게 하면 오류 발생 | |
// p.sort((a,b)=>(a < b)); | |
// 이렇게 하면 속도 느림 | |
// p.sort((a,b)=>(a.localeCompare(b))); | |
// 속도 제일 빠르고 정확함 | |
p.sort((a,b)=>(a < b ? -1 : (a > b ? 1 : 0))); | |
c.sort((a,b)=>(a < b ? -1 : (a > b ? 1 : 0))); |
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 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(); | |
} |
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
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)" |
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 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(() => { |
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 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=>{ |
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 main(){ | |
printf("hello world!\n"); | |
return 0; | |
} |
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 nodes = [ | |
{ | |
links: [ 1 ], // node 0 is linked to node 1 | |
visited: false | |
}, { | |
links: [ 0, 2 ], // node 1 is linked to node 0 and 2 | |
visited: 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 fs = require('fs'); | |
var deleteFolderRecursive = function(path) { | |
if( fs.existsSync(path) ) { | |
fs.readdirSync(path).forEach(function(file,index){ | |
var curPath = path + "/" + file; | |
if(fs.lstatSync(curPath).isDirectory()) { // recurse | |
deleteFolderRecursive(curPath); | |
} else { // delete file | |
fs.unlinkSync(curPath); | |
} |
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
# Assuming an Ubuntu Docker image | |
$ docker run -it <image> /bin/bash |
NewerOlder