Skip to content

Instantly share code, notes, and snippets.

View gwnuysw's full-sized avatar
🎯
Focusing

seokwon gwnuysw

🎯
Focusing
View GitHub Profile
@gwnuysw
gwnuysw / 1.10
Created September 5, 2018 08:34
package chattingJava;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class WriteToFileEvent extends Frame implements ActionListener{
Label lfile, ldata;
TextField tfile, tdata;
Button save;
String filename, data;
@gwnuysw
gwnuysw / javascript_this.md
Last active June 26, 2018 01:39
udacity object-oriented-javascript 강의를 참고 했습니다.

this keyword

left of the dot

'This'는 값이 바운드되는 식별자입니다. 마치 변수와 같습니다. 'This'는 올바른 객체에 자동으로 바운드 됩니다. 인터프리터가 'This'에 올바른 바인딩을 하는 방법은 함수의 위치 매개 변수 규칙과 같습니다. 'This'가 위치 매개변수와 구별되는 점은 당신이 객체의 메소드나 생성자를 호출할때 어떤 오브젝트에 초점을 맞출 것인지 직관적인 도움을 주기 위함입니다.

@gwnuysw
gwnuysw / javascript_closure.md
Last active June 28, 2018 00:34
udacity object-oriented javascript 강의를 참조 했습니다.

closure

Every function should have access to all the variables from all the scopes that surraound it. a closure is just any function that somehow remains available after those outer scopes have returned

  • 함수 내부의 lexical-socpe는 외부 lexical-scope의 변수 참조 가능
  • 함수 내부의 lexical-scope를 외부 lexical-scope에서 참조 불가능
  • 리턴된 내부 lexical-scope는 외부에서 참조 가능
  • 리턴된 내부 lexical-scope는 in-memory-scope변수 규칙을 따른다.

lexical Scope

  • 오직 함수 선언의 중괄호만이 새로운 scope를 만들어 낸다.
  • 반복문이나 조건문 등의 중괄호는 새로운 scope를 만들어 낼수 없다.
  • 여러개의 javascript file에서 global scope 영역은 공유됩니다.
  • 내부 스코프가 외부 스코프를 참조 할수 있지만 외부 스코프가 내부 스코프를 참조 할 수는 없다.
var a = 1;
var b = function(){ //내부에서 외부 스코프의 변수 a참조 가능
@gwnuysw
gwnuysw / LampotBakeryAlgorithm.java
Created May 4, 2018 05:44
Lamport Algorithm test java snippet. maximum thread amount is 5
public class LamportBakeryAlgorithm {
int sum;
boolean choosing[];
int number[];
int id;
public LamportBakeryAlgorithm() {
sum = 0;
choosing = new boolean [5];
number = new int [5];
id = -1;
@gwnuysw
gwnuysw / PetersonAlgorithm.java
Created May 4, 2018 02:03
PetersonAlgorithm java snippet
package javaTest;
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
DoubleThread t = new DoubleThread();
Thread t1 = new Thread(t.new MyRunnableA("A"));
Thread t2 = new Thread(t.new MyRunnableB("B"));
t1.start();