티스토리 툴바


잡다2009/08/21 05:32

www.omegle.com

오호라... 여기 사이트 접속하면 외국에 있는 아무나하고나 연결을 시켜주고 채팅을 하게 한다.

뭐 대부분 접속하자마자 나가는 사람도 있고 Hi! 하고 나가는 사람도 있긴있는데

국적이 다양하네

대만에 인도에.. ㅋㅋㅋㅋㅋ 어떤 녀석은 한국 17살 여자랜다 ㅋㅋㅋㅋㅋㅋㅋ 속을 수가 없자나!!

여튼 심심풀이 용으로 재밌을듯

영어 써보고 싶은 사람 추천


Posted by SmallWish
Programming2009/02/21 15:07

Unix/Linux 환경에서 일하다보면 가끔씩 필요할 법한 명령어들

history - 이제까지 자신이 썼던 커맨드들을 모두 보여준다
!(number) - history와 조합해서 쓰면 쓸만한거... history에서 나온 번호에 있는 명령어를 재사용한다.

makefile -뭐 워낙 유명한거... compile시 유용하다

cp -R (source) (destination)        : Copy시 하위 디렉토리 내용까지 전부 복사한다.
rm -r (source)                            : Remove시 하위 디렉토리까지 전부 삭제.

source (source)                       : source file을 reload한다. bash파일 변경시 재접속 할 필요없이
                                                 변경사항을 활성화시킬수 있다.

env       - 현재 유저의 환경변수 상태들을 확인할수있음
Posted by SmallWish
Programming2009/02/17 16:27

Developing atoi or itoa function would be really easy in C/C++ if you remind these functions, printf, sscanf, sprintf functions.

And also remember that printf returns number of chars it reads, sscanf is reading data from string, and sprintf is writing data into string

Here is the code

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 255

//char* ITOA(int);
int ATOI(char*);

void main()
{
    char input[MAX];
    int output;

    printf("Input : ");
    scanf(" %s",input);

    output = ATOI(input);

    printf("output = %d\n",output);

//    free(output);

}
/*   
char* ITOA(int num)
{
    int cnt;    // number of char
    char* result;    // will store the string of number

    cnt = printf("%d",num);    // to count the number of chars

    result = (char*)malloc(sizeof(char)*cnt +1);    // allocate memory for return value

    sprintf(result,"%d",num);
   
    return result;
}
*/   

int ATOI(char* strNum)
{
    int result;        // will store the number in int

    sscanf(strNum," %d",&result);    // read the integer from the given string, strNum

    return result;
}

There is a ton of developing these function and it is just a one way to develop easily.

As this function could be developed like this, there would be better way to develop all other things.

Never forget that your way is not the only way. There always be better way.



Posted by SmallWish
Programming2009/02/15 00:22

DSTM2 library를 잘 보면 atomic array를 따로 제공하는 것을 볼 수있다.

atomic Array만드는게 뭐가 힘드냐 그냥 atomic 인터페이스 만들고 그냥 그거 배열만들면 안되나? 라는 생각에

@atomic interface INode {
int getValue();
void setValue(int i);
}

이런 인터페이스만들고 배열 만들어서 쓰려고

INode[] nodes = INode[5];

이런 뻘짓을 해봤었는데 나중에 보이는것 factory가 뱉는 에러뿐이었다..

고로 DSTM2에서 제공하는 AtomicArray를 사용해야지만 제대로된 Atomic array를 만들 수 있다.

간단히 AtomicArray 클래스를 보면 Constructor, getter, setter만 알면 되는거 같다.

AtomicArray<T>(Class _class,int n)

AtomicArray constructor는 2개의 파라메터,Array를 만들 class와 배열의 크기, 를 가진다.

T get(int i);
void set(int i,T value);

getter와 setter다 뭐 다른 배열을 사용하는 법과 다른점은 없다.


- AtomicArray를 이용해서 2차배열을 만드려면 어떻게 해야할까..

약간 번거롭지만 약간 돌아서 만들면 된다.

만약 double type의 2차배열을 만들고 싶다면..

@atomic public interface ArrayHolder {
        AtomicArray<Double> getAtomicArray();
        void setAtomicArray(AtomicArray<Double> d);
}

이렇게 인터페이스를 만들어주고..

static Factory<ArrayHolder> ArrayHolderfactory = Thread.makeFactory(ArrayHolder.class);

a = new AtomicArray<ArrayHolder>(ArrayHolder.class,L);    // create row of atomic array
       
 for(int i=0;i<L;i++)       {
            ArrayHolder arrayHolder = ArrayHolderfactory.create();    // will be the row
           
            AtomicArray<Double> doubleArray = new AtomicArray<Double>(Double.class,M);    // create column
             
            arrayHolder.setAtomicArray(doubleArray);    // set the pointer to double array
         
            a.set(i,arrayHolder);
}

이렇게 만들어주면 된다. ArrayHolder 을 element로 하는 배열을 만들고 각각 index의 ArrayHolder 안에다가

Double을 element로 하는 AtomicArray를 생성하는 것이다...

이러면 또 번거로운게 각각의 element를 찾아 들어가려면 이것과 똑같은 짓을 해줘야 한다

ArrayHolder arrayHolder;

    for(int i = 0; i < L; i++) {    // row
            arrayHolder = a.get(i);
            AtomicArray<Double> ai = arrayHolder.getAtomicArray();    // get the column of array
           
            for(int j = 0; j < M; j++) {
                ai.set(j,Double.valueOf(j+1));    // a[i][j] = j+1
            }
        }

이렇게 귀찮은 짓을 해야된다는거...

뭐 그래도 이런거 조금 응용하면 2dim이 아닌 3dim 4dim도 만들 수는 있을 꺼같다.. 좀 귀찮긴 해도 말이다
Posted by SmallWish
Programming2009/02/07 21:54

DSTM2 - 썬 마이크로시스템에서 동적 트랜젝션 라이브러리

요즘에 Dual Core, Quad Core가 나오면서 생기는 트랙젝션 문제들을 해결하기 위해 연구중인 라이브러리인듯 하다.

CPU가 한개만 있었던 시기에는 아무리 Thread를 많이 돌린다고 하여도 단 한개의 CPU가 처리를 해야되기때문에 저 밑 바닥

에서는 순차적인 처리가 될수밖에 없었다. 그래서 같은 데이터 동시 접근이라도 엄밀히 따지게 되면 순서대로 접근하게

되는 것이므로 큰 별다른 문제는 없었다.

그런데!!! CPU들이 한개에서 두개로... 세개로 늘어나게 되자 이게 문제가 생긴 것이다. CPU가 한개일때는 어찌되었던

순차적이었지만 CPU가 두개이상이 되니 정말로 같은 데이터에 동시접근이라는 일이 생겨버린 것이다.

예를 들어서 담배 한개피를 두사람이서 같이 피려고 한다고 할까나...둘다 담배는 피고 싶은데 두 사람이 동시에 필수는 없는

노릇이니 한명은 먼저 사람이 그 담배를 줄때까지 기다려야되는 상황이 되는 것이다. 이런 동시 접근이 상황이 생기게되면

가끔 특이한 문제가 생기기 마련이다. a는 담배를 한 모금 빨고 물을 마시려고 하고 b 물을 마시고 담배를 피려고 한다. 그런데

a가 먼저 물을 가져가서 담배를 찾으니까 담배는 b가 먼저 가져간 것이다. 그러고선 서로 먼저 물과 담배를 내놓으라고 싸우는

상황이 되는데 이처럼 A와 B가 서로의 응답을 마냥 기다리기만 하게 되는 상황 이런 상황을 Deadlock 이라고 한다.


이처럼 CPU가 듀얼과 쿼드로 증가하면서 생기는 트랙잭션 문제들을 연구하기 위해서 개발되고 있는 라이브러리가

DSTM이다.

DSTM2 라이브러리에 관한 설명과 사용법에 관한 논문

http://research.sun.com/scalable/pubs/OOPSLA2006.pdf


Posted by SmallWish
Study/Political Science2009/01/12 17:55
USA - separate institution sharing power( often competing for shared power) : result - harder to accomplish major changes
1999 - Columbine massacre -- policy response - nothing!!

Much easier for minorities in USA to block new policies


PArliamentary democracy - fusion(combination) of legislative & executive power. Result - easier to accomplish major changes
Example - Australia 1996 - Port Arthur massacre gun control accomplished & fast!!!

Adaptability - amendment process - free speech, votes for women, black&over 18 , direct election of senators

Defeated amendment - equal rights for women(ERA)

loose wording in constitution
NECESSARY AND PROPER CLAUSE gives the Congress authority to make all laws which shall be deemed necessary and proper for carrying out all the other powers vested in the national government by the constitution

Great 1973 blackout bill by Congress - regulate interstate commerce

Military draft? Constjtution says may Raise and support military forces

P288 of textbook - Baraj Obama puts this into a candidate's perspective when he write that, "I-like every politician at the federal level- am almost entirely dependent on the media to reach my constituent. It is the filter through which my votes are interpreted, my statements analyzed, my beliefs examined. For the broad public at least....



Criteria for news WHICH sells (man bites the dog)
1) novel - doesn't happen eveyday
2) timely - breaking news; old news is no news
3) action packed - violence, disaster, scandal
4) related to well-known people(president is No.1 star)
5) short, sweet & packaged like a 3 minute mini drama(developing story)

What information becomes news depends on a set of five Ws - those asked in the economic marketplace:

1) who cares about a particular piece of information

2) what are they willing to




Evidence for political bias
1) surveys show journalists are more lib than cons; more Dem. Than Rep.
2) living standards of major journalists are high - they are rich - pro - business; pro- lower taxes
3) live in NYC & DC & LA - socially liberal
4) reformist orientation - what is government doing about any 
Posted by SmallWish
Study/Boolean Algebra2009/01/12 17:52

Zero-one matrix
The relation R represented by Mij = 1 if (ai,bi) ∈ R
                                                  0 if           ∈ ~R

Ex) A = {2,3,4}
      B = {5,8,10,11}
      R = { (2,5) , (2,10),(3,5),(3,8),(3,11) (4,5),(4,10)}

       M(R)  5   8   10    11
          2 |  1   0     1     0
          3 |  1   1     0     1
          4 |  1   0     1     0


R - a relation on a set A, (a1,a2,...,an)
n x n square matrix.

Reflexive
(ai,ai) ∈ R for all ai ∈ A

Symmetric
      R symmetric (ai,aj) ∈ R then (aj,ai) ∈ R.
     
Posted by SmallWish
TAG Matrix
Study/Boolean Algebra2009/01/12 17:47

o Selection Operator
R : n-ary relation
C : a condition that elements in R may satisfy
The selection, Sc, maps the n-ary relation

R to the n-ary relation of all n-tuples from R that satisfy C

o Projection operator
 
The projection Pi1,i2,i3,...,im where i1 < i2 <....<im
 maps the n-tuple(a1,a2,.....an) to the m-tuple (Ai1,Ai2,Ai3,....,Aim) where m<= n

o Join Operator
R relation of degree m
S relation of degree n
(a1,a2,a3,...,am,c1,c2,....,cp) ∈ R
(c1,c2,....,cp,b1,b2,.....,bn) ∈ S

Jp(R,S) = (a1,a2,a3,...,am,c1,c2,....,cp,b1,b2,.....,bn)
Then Jp(R,S) where p<= m and p<= n is a relation of degree m+n-p (m+n-p) tuples

Example
Table : employee records
 Employee Name
Employee #
Dept.
Title
Salary
Smith
123
Mail
carier
30K
Adams  124  R&D  engr.  50K
 Stevens  125  Corporate  VP  200K
 Smith  126  R&D  engr  60K
 Pill  192 Advert.
 assoc 40K

Table : retirement pkg
 Salary Retirement pkg
 30K Basic
 50K  Bronze
 60K  Bronze plus
 100K  Gold
 200K  Platinum

1. Find all employees that are engineers Sc, where C is the condition title ="engr"
 Smith  126  R&D  engr  60K
Adams  124  R&D  engr.  50K

2. Sc2, C2 condition employees in R&D with salary >= 60K.   Dept = R&D, Salary >= 60K
 Smith  126  R&D  engr  60K

3.
P1,3
Employee Name
Dept
 Smith Mail
 Adams  R&D
 Stevens  Corporate
 Smith  R&D
 Pill  Advert.

4. J1(employee, retirement)
Employee Name
Employee #
Dept.
Title
Salary
Retirement Pkg
 ... ...
...
...
...
 ...


Posted by SmallWish
TAG operator
Study/Abstract Math2009/01/12 17:28

1. Direct proof : assume the hypotheses is true then show that the conclusion is also true
     Wiki : http://en.wikipedia.org/wiki/Direct_proof
            
2. Proof by contrapositive : instead of proving the original statement, proving the contrapositive of the original statement since they are equivalent.
     Wiki : http://en.wikipedia.org/wiki/Proof_by_contrapositive

3. Proof by contradiction :
Assume the negation of conclusion is true, then prove that is not true. Since the negation of conclusion is false, the conclusion becomes true statement.
     Wiki : http://en.wikipedia.org/wiki/Proof_by_contradiction

  Ex1) (Direct proof) : if n is an odd integer, then n^2 is odd
                     if n= odd, then n = 2k+1
                      n^2 = (2k+1)(2k+1)
                            = 4k^2 + 4k + 1
                            = 2(2k^2 +2k) +1
                            = 2n' + 1
                    Since n^2 is 2n+1 form, then n^2 is also odd integer by definition of odd integer.    Q.E.D.

 Ex2) (Proof by contrapositive) Suppose that m and b are real numbers with m ≠ 0 and that f is the linear function defind by f(x) = mx + b. If x ≠ y, then f(x) ≠ f(y).

        If x ≠ y, then f(x) ≠ f(y)
        If f(x) = f(y), then x = y          -   contrapositive form
          mx+b = my+b
             mx = my                        
               x = y                  TRUE!!
                             
          Since contrapositive form is true, then if x ≠ y, then f(x) ≠ f(y) is also true.   Q.E.D

   Ex3) (Proof by contradiction) suppose a,b,c ∈ Z, if a and b are even and c is odd then ax+by=c does not have an integer solution for x and y.
            H - a = 2k, b = 2k', c = 2n+1,           C : ax+by=c have no Z solution.

          Suppose that there exists x' and y' such that satisfies ax + by = c
         
            2kx' + 2k'y' = 2 n + 1
             2(kx' + 2k'y') = 2n+1  <- cannot be equal.

         Since a and b are even then ax' and by' are also even number.
         The sum of even integer is even, therefore ax+by ≠ c
         By contradiction, ax+by=c have no integer solution.
       

Posted by SmallWish
Study/Political Science2009/01/09 17:34
Madisonian Constitutional theory

Federal papers#10 & 15
Dahl's preface to democratic theory

1) if unrestrained, people will tyrannize over others
Stanley milgram - "obedience to authority"

2) accumulation of power in the same hands means no checks - that will result in tyranny

Goal - prevent the worst; prevent tyranny

Test of tyranny is not majority/minority, nor election - test is whether government abides by natural rights(see federal)

USA - federalism, bicameralism, written constitution(1789) judical review, leg/exec separation.

USA is only the nation has all five things

NZ has no power separation

Bicameralism - separate Houses that act as check on one another

Prime Minister's question time - c-span @ 6pm & 9pm on Sundays

Tony Blair(labour) vs. PM john major(conservative)

Separate institution sharing power - today - separate institutions COMPETING FOR shared power


                            UK.       USA
Accountabillity.     HI.          LO
Accompdation.     LO          HI
Deliberation.         LO.        HI
Participation.        LO.        HI(potential)
Posted by SmallWish