ragiragi

The Frontend Engineer

JavaScript steals much of its syntax and some of builtin functionality from Java. One of the things stolen from Java was its set of key and reserved words. float in Java specifies a floating-point value type, and it was left reserved in JavaScript as a result
The problem is that because this structure looks so similar to real classes in other languages, people start expecting it to behave exactly like real classes behave in other languages. But the more you work with these types of “classes”, the more you see that they don’t behave that way at all. So people get upset with JavaScript, and start thinking it is bad language that can’t be used for anything serious.

http://www.adobe.com/devnet/html5/articles/javascript-object-creation.html

점점 javascript 근본주의자(?)가 되어가고 있는 것 같다. 하하

Many JavaScript programmers don’t know that it is also possible to send a listener object as the second argument to addEventListener. When an event is fired, the object’s handleEvent method is called.

http://peter.michaux.ca/articles/our-backwards-dom-event-libraries

호오라…

// Introduced in DOM Level 2:
interface EventListener {
  void handleEvent(in Event evt);
};

http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener

Jasmine Spies

javascript 는 proxing, mocking 이 쉬워 무슨 전용 library 까지 필요할 까 싶지만, Jasmine 에서 제공하는 Spy 는 꽤나 편리하다.

var onMove = jasmine.createSpy();
registerMoveHandler(onMove);
simulateInvalidMoveEvent();
expect(onMove).not.toHaveBeenCalled();

물론 사용하지 않을 수 있다면 사용하지 않는 편이 더 좋다. :)

node.js require() 로 json 읽기

node.js 에선 require() 함수로 json 파일을 읽을 수 있다. 굳이 fs.readFile + JSON.parse 쓸 필요 없음.

$ cat data.json 
{
    "foo": "hello",
    "bar": "world"
}

$ node
> require('./data.json')
{ foo: 'hello', bar: 'world' }

Nokia Lumia 710 with IE 7(2)

정체가 밝혀졌다.

IE9이지만 호환 모드로 동작할 경우 user agent가 아예 IE7 으로 나오던 것. 문제를 정확히 발견하지 못했던 건 meta 등을 이용해서 명시적으로 호환모드로 동작하라고 지정했던게 아니라 해당 사이트가 MS의 Compatibility View List에 포함되어 있어 호환모드로 동작했기 때문이었던 것 같다.

Compatibility meta tag 를 사용하여 edge 모드로 설정해두니 이상없이 IE9으로 동작한다.

<meta http-equiv="X-UA-Compatible" content="IE=edge" >

근본적으론 저 Compatibility View List 에서 domain 을 제거해야할 듯.

Nokia Lumia 710 with IE 7

지난달 국내 출시된 노키아 루미아 710폰. 무려 HTML5 가 지원되는 IE9 이 탑재되어 있다고 광고하고 있는데 실상 폰을 열어보니…

// 국내 출시 모델
Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.5; 
Trident/3.1; IEMobile/7.0; NOKIA; Lumia 710)

// Vodafone 출시 모델
Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5;
Trident/5.0; IEMobile/9.0; NOKIA; Lumia 710; Vodafone)

누구냐 넌?

OS X Chrome 한글 폰트 바꾸기

OS X 의 애플 고딕 한글 폰트가 예쁘지 않아서 기본 폰트를 바꾸기 위한 방법들이 여러가지 소개되고 있는데 그 방법들이 그닥 쉽지 않더라.

그렇게 복잡한거 말고 그냥 Chrome 에서만 폰트를 바꾸고자 한다면 간단하게 바꿀 수 있다. ~/Library/Application Support/Google/Chrome/Default/User StyleSheets 파일을 수정. CSS3 Font 를 이용하여 다른 폰트로 매핑할 수 있다.

@font-face {
    font-family: '굴림';
    src: local(NanumGothic);
}
@font-face {
    font-family: 'gulim';
    src: local(NanumGothic);
}
@font-face {
    font-family: '돋움';
    src: local(NanumGothic);
}
@font-face {
    font-family: 'dotum';
    src: local(NanumGothic);
}
@font-face {
    font-family: '바탕';
    src: local(NanumMyungjo);
}
@font-face {
    font-family: 'Batang';
    src: local(NanumMyungjo);
}

Problem with loading applet on OS X

어느날부터 applet 이 안되는 문제가 있었는데, 요즘 세상에 딱히 applet 을 쓸 일도 없고 신경쓰지 않고 있다가… 무슨 바람이 들어서인지 문득 생각이 나 원인 좀 찾아 보았다.

원인은 ~/Library/Caches/Java/cache 디렉토리 owner 가 root 되어 있었던 것. ~/Library/Caches/Java/ 디렉토리 이하 모든 파일들을 사용자 계정으로 권한을 돌려 놓으니 잘 동작한다.

혹시 같은 경우를 겪는 사람이 있을까봐 잊기 전에 정리.

javascript 로 IE 9 이하 검사하기

IE conditional compilation 이용

var isUnderIE9 = false;
//@cc_on isUnderIE9 = (@_jscript_version < 9);

(Source: msdn.microsoft.com)