달력

3

« 2024/3 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'삽질예방'에 해당되는 글 46

  1. 2010.01.28 Unpacking rpm package / Find linux version 2
  2. 2010.01.17 Windows 7 Sleep problem
  3. 2009.11.17 changing firefox changing cache and paths
  4. 2009.11.11 Changing JAVA jre
  5. 2009.10.10 find, unique, cumsum
  6. 2009.09.18 Finally clause
  7. 2009.08.24 Latex 변환하기 1
  8. 2009.07.16 Flex 3 조각지식
  9. 2009.07.16 Kunth-Morris-Pratt(KMP) Algorithm Visualizer 2
  10. 2009.07.01 Profiler
2010. 1. 28. 09:15

Unpacking rpm package / Find linux version 삽질예방/Linux2010. 1. 28. 09:15

Unpacking rpm package without using package manager

rpm2cpio myrpmfile.rpm | cpio -idmv

find out linux version

uname -a

:
Posted by Kwang-sung Jun
2010. 1. 17. 09:33

Windows 7 Sleep problem 삽질예방/Windows 72010. 1. 17. 09:33

There are so many reports on sleep problem. The symptom is that it wakes up itself after going to sleep mode. Following is the one helped me troubleshoot.

Generally, googling for "windows 7 sleep problem" will give you answers. Mostly, people says that by unchecking wake up option from network drivers

To figure out the source of problem, enter following from the command line.
powercfg -ENERGY

this will make a report saying problems by html. you can further google with keywords in it.

By the way, in my case, I updated all drivers available, and then unchecked "allow this device to wake the computer" in Properties of mouse in Device Manger. Common sense tells me that it means that I could wake up computer by moving mouse while in sleep mode, but this function worked as simply "waking up right after going to sleep mode". I really don't know why, but it worked for me.

cf. rare note while I fix the problem
:
Posted by Kwang-sung Jun
2009. 11. 17. 07:29

changing firefox changing cache and paths 삽질예방/Firefox2009. 11. 17. 07:29

firefox cache path changing!!

1.
type
about:config
in address bar.

2.
edit (or add if not exist)
browser.cache.disk.parent_directory
set value as
/scratch/firefox.cache

and then , make firefox.cache folder in /scratch (or, wherever you want)

now it works way faster than before... !!


3. one more

./mozilla -profilemanager
-> create a new account with directory in anywhere you want and delete default


citation:
http://kb.mozillazine.org/Profile_Manager#Accessing_the_Profile_Manager

:
Posted by Kwang-sung Jun
2009. 11. 11. 01:15

Changing JAVA jre 삽질예방/Java2009. 11. 11. 01:15


Right click on project name and choose properties -> Run/Debug Settings -> Edit (or duplicate and edit) -> JRE tab
:
Posted by Kwang-sung Jun
2009. 10. 10. 08:13

find, unique, cumsum 삽질예방/Matlab2009. 10. 10. 08:13

>> A = magic(3)
A =
     8     1     6
     3     5     7
     4     9     2

>> find(A>5)
ans =
     1
     6
     7
     8

>> [I,J] = find(A>5)
I =
     1
     3
     1
     2
J =
     1
     2
     3
     3

>> [I,J] = find(A==3)
I =
     2
J =
     1


>> A = [1 1 1; 2 2 2; 1 1 1];
>> unique(A,'rows')
ans =
     1     1     1
     2     2     2

>> unique(A)
ans =
     1
     2

find "help cumsum". (maybe useful when converting multinomial distru to cumulative one.
:
Posted by Kwang-sung Jun
2009. 9. 18. 06:45

Finally clause 삽질예방/Java2009. 9. 18. 06:45


even if another exception is thrown in catch block, finally block is executed before 2nd exception is caught.

Therefore, "every" time control enters try block, finally block is reserved to be run (after finishing try{} and when finished catching. if it is not caught there, then finally block is executed and then jump)

here is a good example.

static void f(int k, int[] A, String S) {
int j = 1 / k;
int len = A.length + 1;
char c;

try {
c = S.charAt(0);
if (k == 10) j = A[3];
} catch (ArrayIndexOutOfBoundsException ex) {
System.out.println("array error");
throw new InternalError();
} catch (ArithmeticException ex) {
System.out.println("arithmetic error");
} catch (NullPointerException ex) {
System.out.println("null ptr");
} finally {
System.out.println("in finally clause");
}
System.out.println("after try block");
}

Part A: Assume that variable X is an array of int that has been initialized to be of length 3. For each of the following calls to method f, say what (if anything) is printed by f and what, if any, uncaught exceptions are thrown by f.

  1. f(0, X, "hi")
  2. f(10, X, "")
  3. f(10, X, "bye")
  4. f(10, X, null)

The answer is following.


:
Posted by Kwang-sung Jun
2009. 8. 24. 12:16

Latex 변환하기 삽질예방/Latex2009. 8. 24. 12:16

dvi파일 생성
latex hello.tex

ps로 변환
dvips hello.dvi -o hello.ps

** dvi to pdf straight
dvipdfm -o hello.pdf hello.dvi

ps를 pf로 변환
ps2pdf hello.ps hello.pdf

top matter
=> 타이틀, 저자 정보, 생성날짜 등...

\\
-> 뉴 라인           
:
Posted by Kwang-sung Jun
2009. 7. 16. 17:42

Flex 3 조각지식 삽질예방/Flex2009. 7. 16. 17:42

팝업 확인 버튼 띄우기
import mx.controls.Alert;
Alert.show('LinkButton selected!');


Application 클래스

<mx:Application  ...> 내부에서 application이라고 하면 Application에 대한 인스턴스, 즉 자기자신을 나타낸다.
Application 클래스는 싱글톤으로써, 자기자신에 대한 객체 참조를 Application.application이라는 static 멤버변수에 집어넣는다.


for each 반복문

var ary:Array = [1, 2, 3, 4];
var a:int;
for each (a in ary) {
    // do something...
}


[Bindable] 은 대체 무슨 역할???

  • [Bindable] 바로 아래에 선언된 set/get함수(프로퍼티)나 클래스가 변동되었을 때 이를 바인딩하고있는 다른 객체들에게 notify해준다.
  • data binding expression ==> {}로 감싼 수식을 말한다. 이 안에서는 & 대신 &amp;를 사용하여야 한다.
  • XMXL로 작성하는 것은 자동으로 Bindable 범주내로 들어가는 듯 하다. MXML에서 자동으로 해주는 건지 그것들이 UIComponent이기 때문인지는 아직 알 수 없다. (UIComponent이기 때문인 것 같다.)
  • 결국 [Bindable]은 바로 아래에 있는 property가 바인딩의 source로 등록되게 해준다. 만약 기존 UIComponent의 property라면 굳이 안해줘도 도리 것이다. source로 등록되어 있으며 property값 변화가 일어나는 이벤트가 일어날 때 source에서 destination으로 값 복사를 해준다. property값 변화가 일어나는 이벤트는 직접 지정 가능하다. 직접 지정하면 setter함수 내에서 자신이 값 복사 시점을 직접 상세히 지정해줄 수 있다.


Property 직접 bind 시키기 / 함수로 바인드시키기

   
BindingUtils.bindSetter(bindFunc, textIn, 'text');
    // 원래 String대신에 Object인자로 받게 됨.
    public function bindFunc(src:String):void {
        textOut.text=String(src);
    }
       
또는
    BindingUtils.bindProperty(textIn, 'text', this, ['textOut', 'text']);

textIn은 텍스트 인풋을 받는 곳이고, textOut은 그냥 레이블이다...

XML 코딩에서 :
<mx:Text id="myText" text="{user.name.firstName.text}" />

액션 스크립트:
bindProperty(myText, "text", user, ["name", "firstName", "text"]);
 => user["name"]["firstName"]["text"] 와 같이 번역된다.!!!


ArrayCollection을 bind 시키기

얘는 직접 멤버를 컨트롤하기 힘드므로,
ary.addEventListener(CollectionEvent.COLLECTION_CHANGE, collChange);

을 추가시켜 주어야 한다.           
그리고 함수에서는
   
public function collChange(e:CollectionEvent):void {
        Button(aryBox.getChildAt(e.location)).label =
 ary.getItemAt(e.location).toString();
}

와 같이 한다. e.location은 변화가 발생된 인덱스를 말한다.


fillColor 바꾸기

css 프로퍼티나, Design모드에서는 해당 항목을 0x000000, 0x000000 라고 하면 그라데이션으로 색을 줄 수 있다.
만약 직접 세팅하고 싶다면
btn.setStyle('fillColors', [0x000000, 0x000000]);

라고하면 된다.


String

'a'.charCodeAt(0);

'a'자체가 스트링이다.

String.fromCharCode(65)
을 이용하면, 직접 아스키코드로부터 캐릭터를 얻어낼 수 있다. 캐릭터 타입은 따로 없고, String을 이용하면 될 것 같다.


Array

            var tmp:Array = [];
            tmp[0] = 3;
            tmp[1] = 3;
            trace('length: ', tmp.length);
말그대로 그냥 동적인 배열.
:
Posted by Kwang-sung Jun


Well I thought it would be nice to learn Flex so that I can visualize things better. I decided to visualize KMP string search algorithm. Click on first and second default buttons, then click start. Enjoy ! Oh, there is source code down there. Click on the link with text "KMPVisualizer.rar". Thanks !

KMP알고리즘의 동작 순서를 간단하게 그려봤습니다. Flex를 한번 해보고 싶었는데, 목표가 분명하지 않으면 랭기지를 배우는데 아무런 의미가 없겠죠? 그래서 간단히 Effect를 이용해서 KMP알고리즘 동작 원리를 시각화해 봤습니다. KMP는 Fail Function이라는 것을 정의해서 기나긴 텍스트 안에서 pattern을 찾아주는 것입니다.

처음에 뜨는 창에서 둘다 default로 놓고 start버튼을 누른 후 Start Animation을 클릭하세요. 잠시 멈춤도 가능하고 리버스(뒤로가기)도 가능합니다만, reverse로 할 경우에는 텍스트 색깔이 의도대로 나오지 않을 수 있으니 참고하세요.

이제 flex질은 그만하고 하던 기계학습 공부를 마무리하고 출국준비를 서둘러야겠습니다.ㅎㅎ. 소스코드도 첨부했으니 혹시라도 내부가 궁금하시다면 아래의 링크로 다운받으세요.

:
Posted by Kwang-sung Jun
2009. 7. 1. 19:32

Profiler 삽질예방/Matlab2009. 7. 1. 19:32

프로파일링
profile on

for i=1:100
    out = myfunc(in);
end

profile viewer

함수 호출 횟수와 수행 시간 등을 보여준다.
테스팅에 편리할듯..
:
Posted by Kwang-sung Jun