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
async function alertResult() { | |
callApi() // Promise를 이용한 Non Blocking IO 처리 | |
.then(result => { | |
console.log(result) | |
}) | |
} |
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 returnDataAfter2Seconds() { // 2초 뒤에 값을 돌려주는 IO 작업 | |
return new Promise(resolve => { // 2초 동안 Blocking 되지 않기 위해 Promise 객체를 return 한다 | |
setTimeout(() => { | |
resolve('data'); | |
}, 2000); | |
}); | |
} | |
f = returnDataAfter2Seconds(); | |
// const data = f.result(); Blocking IO이기 때문에 js에는 존재하지 않는다 |
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
future = excutor.submit(open, "example.txt", "r") // Non-Blocking IO로 IO 작업 시작 | |
some_cpu_job1() // cpu 작업이 IO작업이 끝나기 전에 끝난다 | |
f = future.result() // 결과값을 가져올 떄까지 쓰레드가 Blocking된다 -> 비효율적 | |
print(f.readline()) | |
some_cpu_job2() | |
some_cpu_job3() |
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
f = open('example.txt', 'r') // example.txt를 읽어서 파일 객체 f를 리턴해준다 | |
print(f.readline()) // 한 줄을 읽어서 화면에 출력한다 |
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
async function returnPromiseResolveOne() { | |
return 1; | |
} | |
returnPromiseResolveOne().then(alert); |
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 resolveAfter3Seconds() { // 3초 동안 대기하게 함 | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve('resolved1'); | |
}, 3000); | |
}); | |
} | |
function resolveAfter2Seconds() { // 2초 동안 대기하게 함 | |
return new Promise(resolve => { |
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
class SortEx { | |
public void main() { | |
int[] intArr = new int[3] {1, 2, 3}; | |
# 배열 오름차순 정렬 | |
Arrays.sort(intArr); | |
# 배열 내림차순 정렬 | |
Arrays.sort(intArr, Comparator.reverseOrder()); | |
# 리스트 정렬 | |
List<String> strList = Arrays.asList("1", "2", "3"); |
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
!h:: SendInput,{LEFT} | |
!j:: SendInput,{DOWN} | |
!k:: SendInput,{UP} | |
!l:: SendInput,{RIGHT} | |
LCtrl::Capslock | |
Capslock::LCtrl | |
; Tab을 한 번 누르면 esc 후 무조건 영어로 | |
; Tab이 더블클릭되면 원래처럼 Tab | |
; https://autohotkey.com/board/topic/96752-need-help-with-a-double-tap-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
# git lg 로 git 명령어 alias | |
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
# staing과 work directory의 차이 | |
git diff | |
# HEAD와 Stage의 차이 | |
git diff --cached | |
# HEAD와 work directory의 차이 |
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
public static void stringFormat() { | |
for (int i=0; i<10; i++) { | |
String.format("%d%d", i, i); | |
} | |
} |