Skip to content

Instantly share code, notes, and snippets.

View ohoroyoi's full-sized avatar
๐Ÿƒโ€โ™€๏ธ
keep going

ohoroyoi

๐Ÿƒโ€โ™€๏ธ
keep going
View GitHub Profile
const animatedBounce = function({ selector = ".ohoroyoi", ...rest } = {}) {
$(selector).addClass('animated bounce');
return Promise.resolve(true);
}
const makeChosen = function({ selector = "#ohoroyoi_table", ...rest } = {}) {
$(selector).chosen({
width: "100%"
});
return Promise.resolve(true);
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define MAX_VALUE 1001 // (1<= N <= 1000)
int jeongjum;
int gansun;
int start_jeongjum;
import time
from threading import Thread
def myfunc(i):
print("sleeping 5 sec from thread %d" % i)
time.sleep(5)
print("finished sleeping from thread %d" % i)
for i in range(10):
t = Thread(target=myfunc, args=(i,)) # ์™œ i์•„๋‹ˆ๊ณ  i,?? https://docs.python.org/3/library/threading.html#threading.Thread ํŠœํ”Œํ˜•์ด๋ผ ํ•จ
@ohoroyoi
ohoroyoi / samjeon_react.js
Created July 13, 2019 08:17
samjeon_react.js
// // callback
// function add(a, b){
// return a + b;
// }
// function addFour(x, f){ // ์ธ์ž๋กœ ํ•จ์ˆ˜๋ฅผ ๋ฐ›๋Š” ํ˜•ํƒœ
// return f(x, 4);
// }
@ohoroyoi
ohoroyoi / what_is_call_back.js
Last active July 13, 2019 15:34
what_is_call_back.js
// callback : ์ธ์ž๋กœ ํ•จ์ˆ˜๋ฅผ ๋ฐ›๋Š” ํ˜•ํƒœ
function add(a, b){
return a + b;
}
function addFour(x, f){ // ์ธ์ž๋กœ ํ•จ์ˆ˜๋ฅผ ๋ฐ›๋Š” ํ˜•ํƒœ
return f(x, 4);
}
@ohoroyoi
ohoroyoi / callback_usage.js
Created July 13, 2019 15:41
์ด ์งง์€ ์ฝ”๋“œ๊ฐ€ ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ€์„œ ๋ช‡๋ฒˆ์„ ์ฝ์—ˆ๋Š”์ง€
const getTime = (callback) => {
callback('์•ˆ๋…•');
}
getTime((message)=>{
console.log(message);
});
@ohoroyoi
ohoroyoi / callback_usage_more.js
Created July 13, 2019 15:47
ํ• ํŠผ ์ฝœ๋ฐฑ ๋‚ด๊ฐ€ ๋„ˆ ์ดํ•ดํ•ด๋ฒ„๋ฆฐ๋‹ค ์ด๊ฑฐ์ž„
$.getJSON('https://jsonplaceholder.typicode.com/todos/1', (data) => {
console.log(data);
});
const getTodos = (id, onSuccess) => {
$.getJSON(`https://jsonplaceholder.typicode.com/todos/${id}`, (data) => {
// console.log(data);
onSuccess(data);
});
@ohoroyoi
ohoroyoi / promise_first.js
Last active July 13, 2019 15:53
์ถœ๋ ฅ๊ฒฐ๊ณผ๊ฐ€ ์–ด๋–ป๊ฒŒ ๋ ๊นŒ์š”
// const todosPromise = new Promise((resolve, reject) => {
// const condition = Math.random() > 0.5; //true or false
// return condition ? resolve('์„ฑ๊ณตํ–ˆ์–ด์š”') : reject('์‹คํŒจํ–ˆ์–ด์šฉ');
// });
// // console.log(todosPromise);
// todosPromise.then((data) => {
// console.log(data);
@ohoroyoi
ohoroyoi / asyncAwaitNewbie.js
Created July 13, 2019 15:57
async await ์ •๋ง ํŽธํ•˜์กฐ
const getTodos = (id) => {
return new Promise((resolve, reject) => {
$.getJSON(`https://jsonplaceholder.typicode.com/todos/${id}`, (data) => {
resolve(data);
});
});
}
@ohoroyoi
ohoroyoi / whatOrderDoesItHave.js
Created July 13, 2019 15:59
์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ˆœ์„œ๊ฐ€ ์–ด๋–ป๊ฒŒ ์ถœ๋ ฅ์ด ๋ ๊นŒ์š”?
const getTodos = (id) => {
return new Promise((resolve, reject) => {
$.getJSON(`https://jsonplaceholder.typicode.com/todos/${id}`, (data) => {
resolve(data);
console.log(data);
});
});
}
// // ์•„๋ž˜์ฒ˜๋Ÿผ ํ•˜๋ฉด ์ˆœ์„œ๋ณด์žฅ x