C# Notify Windows

C# Notify Windows test code. 트레이아이콘과는 다른 notify window
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Drawing;

namespace NotifyWindow
{
    class StartNotifyWindow
    {
        Form nForm = new Form();
        Label notiLabel;

        Thread t1;

        public StartNotifyWindow()
        {
            initLable("Notification Test");
            initNotifyForm();
        }

        public StartNotifyWindow(string msg)
        {
            initLable(msg);
            initNotifyForm();
        }
        
        private void initLable(string a_text)
        {
            notiLabel = new Label();
            notiLabel.Text = a_text;
            notiLabel.Font = new Font("Arial", 15);
            notiLabel.Font = new Font(notiLabel.Font, FontStyle.Bold);

            //notiLabel.Font.Bold = true;
            notiLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            notiLabel.Location = new System.Drawing.Point(50, 10);
            notiLabel.Size = new System.Drawing.Size(300, 80);
            nForm.Controls.Add(notiLabel);
        }


        private void initNotifyForm()
        {
            nForm.TopMost = true;
            nForm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            nForm.ControlBox = false;
            nForm.StartPosition = FormStartPosition.CenterScreen;
            nForm.ClientSize = new System.Drawing.Size(400, 100);

            nForm.Opacity = 0;
            nForm.BackColor = Color.Snow;


            nForm.Visible = true;
            nForm.ShowInTaskbar = false;

        }

        private void nForm_MouseClick(object sender, EventArgs e)
        {
            /* 이벤트가 필요할 경우 사용 */
        }

        public void showNotifyWindow()
        {
            startThread();
        }

        private void stopThread()
        {
            t1.Abort();
        }


        private void startThread()
        {
            t1 = new Thread(new ThreadStart(StartNotify));
            t1.Start();
        }

        private void StartNotify()
        {
            /* 이벤트가 필요할 경우 사용 */

            //nForm.MouseClick += nForm_MouseClick;
            //notiLabel.MouseClick += nForm_MouseClick;


            // fade-in
            while (nForm.Opacity < 1)
            {

                nForm.Opacity += .01;
                nForm.Refresh();

                //sleep
                System.Threading.Thread.Sleep(10);
            }

            // remain for 1.5 sec
            System.Threading.Thread.Sleep(1500);

            // fade-out
            while (nForm.Opacity != 0)
            {
                nForm.Opacity -= .01;

                nForm.Refresh();

                //sleep
                System.Threading.Thread.Sleep(15);
            }
            
            nForm.Visible = false;            

            // when finished Notify, abort the thread.
            stopThread();

            // and dispose nForm            
            nForm.Dispose();

        }
    }
}


SyntaxHighlighter test

 

#include 
#include 

void fnc(){
}

int main(){
 fnc();
 return 0;
}

481 call leg/transaction does not exist

En.
Meaning of '481 call leg/transaction does not exist' is that pbx or gw could not find dialog information. So, to find out this problem, have to check out call-id, from tag, and to tag.

3 entities, call-id, from tag, to tag, are essential elements of a dialog.
u

*surely, cSeq of INFO message also has to be same as cSeq of INVITE message.


Quotation of RFC 2796
RFC 2796
A 481 Call Leg/Transaction Does Not Exist message MUST be sent by a UAS if the INFO request does not match any existing call leg.



Kr.
INFO method는 현재 다이얼로그 정보를 기반으로 DTMF와 같은 정보를 전달하기 위해 

사용한다고 이해하면 될듯 하다. 

'481 call leg/transaction does not exist.' 응답의 의미는 메시지를 수신한 pbx 또는 gw에서 

수신 INFO 메시지에 해당하는 다이얼로그를 찾을 수 없다는 뜻이다.



즉, 다이얼로그는 call-id, from tag, to tag를 기반으로 체크하기 때문에 
위 응답을 받으면 송신하는 INFO 메시지의 call-id, from tag, to tag를 체크해봐야 한다.
*다이얼로그 기반이므로 INFO 메시지의  cSeq는 최초 INVITE의 cSeq와 같아야 한다.

아래는 RFC 2796의 일부

RFC 2796
A 481 Call Leg/Transaction Does Not Exist message MUST be sent by a UAS if the INFO request does not match any existing call leg.


몸이 이상해,,,

요즘 왜 이렇게 피곤하지 -_-

몸이 너무 이상하다,,,

천근만근 너무 무겁고 피곤하다.

자도자도 피곤하고

안자도 피곤하고

뭐 어쩌라는건지 ㅠ

덥고 피곤하고 졸리다 ...

자자

APM 설치 가이드

APM( Apache, PHP, Mysql) 설치 가이드

아래는 내 블로그에 올려놓은 글들인데 묶음으로 올려놓으면 찾기 편할것 같아서. 


1. Apache
Apache 2.2 설치 on Ubuntu-10.10, 12.04 ]

2. PHP
PHP 5 설치 on Ubuntu-10.10, 12.04 ]

3. MySql
MySql 설치 on Ubuntu 10.10, 12.04 ]


덤으로,

4. mediawiki 설치파일
참조 : www.mediawiki.org/wiki/Download ]

CentOS 5.8 방화벽 관리

CentOS는 port별 방화벽이 (OS 설치 시 off로 해놓지 않았다면)기본으로 설정되어 있기 때문에

network 통신을 위한 port를 사용하기 위해서는 방화벽을 꺼야 한다.

포트별 방화벽을 끄는 방법은 2가지다.

1. 일괄적으로 방화벽 OFF
2. 선택한 포트에 대해서만 방화벽 OFF

아래에 두 가지 방식을 적는다.



1. 일괄적으로 방화벽 OFF

* 방화벽 일괄 끄기/켜기
$ service iptables stop     // 끄기
$ service iptables start     // 켜기



2. 선택한 포트에 대해서만 방화벽 OFF

*아래는 sip protocol 처리를 위한 5060, 5061 포트 해제

* 포트별 방화벽 해제
$ vi /etc/sysconfig/iptables

*아래에서 3, 4번째 줄 bold 처리한 부분처럼 protocol과 port 번호 맞춰서 끼워넣으면 됨.

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 5060 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5061 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

wq!

$ service iptables restart     // 방화벽 재시작

고속터미널 청년 떡볶이

어제 서울 고속터미널에서 먹은 청년 떡볶이.

여기가 고속터미널 맛집이라는데,,, 진짜야?????!!!!!!!!!!!!!!!?? -_-


 떡볶이 맛은,,, 

어릴적 초등학교 앞에서 사먹던 그런 맛이다 ㅎㅎ

약간 저질스러우면서도 맛있는?? ㅎㅎㅎ

맛은 괜찮은데 떡볶이 양이 너무 적다. 그게 가장 큰 단점인듯.

저 국물을 허우적 허우적 대야 몇 개 건져 먹을 수 있다.

순대는 생각보다 맛있고 주먹밥도 괜츈.

가장 맛있는건 튀김인듯.

기대 안하고 먹었는데 제일 맛있었다 ㅎㅎㅎ

떡볶이 양이 적은게 조금 아쉽긴 하지만 다음에도 또 갈 것 같다. ^^


PS. 원주 자유시장(중앙시장인가?) 지하 떡볶이 가게가 역시 최고인듯.
      원주 떡볶이 만세!!! :)


사진으로 보이는게

국물 떡볶이        : 2,000
순대                   : 3,000
참치 마요 주먹밥 : 3,000
왕새우튀김         : 2,000

총 10,000원


 찾아가는 길은 

1. GoTo Mall 입장 -> 신세계 백화점 방향으로 쭉 걷기->한참 걷기
    -> "겁나 기네" 연발하며 계속 걷기-> "어디까지 가야돼??" 하다가 발견-> 끝!

2. 신세계 지하 반디앤루니스 옆 골목 입장->영화관 쪽으로 입장
    -> 영화 표 끊지말고 나가는 문으로 out->위로 올라가지말고 GoTo Mall 입장
    -> 왼쪽으로 조금 걷기->발견-> 끝!


HTML 한글 인코딩

html 페이지 제작 중 한글 인코딩을 위해서는 euc-kr 또는 utf-8 중 하나를

charset으로 설정 해야 한다.

우선 UTF-8 또는 euc-kr로 설정하는 방식은 아래의 문구를 <head> </head> 사이에

추가하면 된다.

<head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

또는 

<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR" />
</head>

euc-kr과 utf-8은 방식이 조금 다른데,

대~충 설명을 하면

euc-kr은 한글로 표현 할 수 있는 글자의 제한이 존재하고

영어를 제외한 다른 언어를 표현할때 문제가 발생 할 수 있다.

utf-8은 표현 할 수 있는 글자 제한도 없고

모든 문자를 표현 할 수 있다.

범용 및 미래를 생각한다면 UTF-8로 설정하는것을 추천한다.

cygwin 다운로드 최강 속도 미러!

cygwin 다운로드 받을 때 대부분의 미러가 외국 사이트이기 때문에 속도가 엄청 느리다.

이때 다운받는 미러를 아래의 다음 ftp로 지정하면 속도가 엄청 빠르다.!

미러 주소가 바꼈네요. 업데이트!

http://ftp.daum.net/cygwin
http://ftp.daum.net


완전 사랑스럽다 다음 :)




아래는 cygwin 다운로드 및 설치 (혹시 모르는 분들을 위해)


온라인 무료 포토 에디터! (free photo editor)

온라인 무료 포토에디터를 소개할까 한다.


Linkhttp://pixlr.com/editor/



회사 동기를 통해 알게된 사이트인데 왠만한 포토샵 기능은 전부 사용할 수 있는 듯 하다.

액티브엑스 등 별도 플러그인 설치도 필요없고,

속도도 빠르고 단축키도 포토샵과 똑같아서 사용하는데 불편하지 않고 좋다.

가끔씩 이미지 편집을 해야 할 일이 있는데 매우 유용하게 사용하고 있다.

포토샵이 필요하신 분들은 사용해보면 좋을듯 하다.

비꾸라지!! ㅋㅋㅋ


비의 새로운 별명 


비.꾸.라.지!



연예병사 논란을 만들기 시작한건 비 아닌가? ㅋㅋㅋ

안마방 사건때도 외출하고 문제 있더니

혼자 미꾸라지처럼 빠져나왔네

군대 갈때까지만해도 비 좋게 생각했는데,,, 

여러 사기사건에 연루됐을때도 나쁘게 보지 않았었는데,,

아무래도 군대는 치명적이다. 

앞으로 우리나라에서 남자 팬은 많이 줄겠네 ㅎ


그나저나 별명은 누가 만들었는지 빵터졌네 ㅋㅋ


C strtok_r 을 이용한 파일 내의 가입자 정보 읽어오기

readfile.c 는  strtok_r을 이용해 파일에 존재하는 가입자 정보를 불러오는 소스코드다.
sipd.conf 파일에 존재하는 가입자 정보를 불러와서 출력하지만 필요에 따라 가입자 정보를 load 하는 부분으로도 쓸 수 있을듯 하다. 그냥 만든것이므로 성능 및 안정성 장담 못함 ㅋㅋ

sipd.conf
------------------------------------------------------------------------
[you]
type=guest
username= you
host=127.0.0.1
secret=123456

[deoks]
type=friend
host=127.0.0.2
secret=987

[song]
type=gf
host=127.0.0.3
secret=45656

[hye112]
type=lover
host=127.0.0.4
secret=456

[23hye]
type=family
host=8.8.8.8.
secret=409809016



readfile.c

c# 특정 폴더/웹사이트/외부 파일/외부 프로그램 실행

C#에서 특정 폴더/웹사이트/외부 프로그램 실행 시킬때 쓰는 방법

using System;

namespace myTest{
class LogManager{
private void runExcutableFile(object sender, Eventargs e){
System.Diagnostics.Process.Start("D\\my\\Test\\"); // 특정 폴더                 
System.Diagnostics.Process.Start("D\\myTest.exe");      // 외부 프로그램                 
System.Diagnostics.Process.Start("http://google.com");  // 웹사이트         
}
}

}

방식 1)
     System.Diagnostics.Process.Start("D\\my\\Test\\"); // 특정 폴더
     System.Diagnostics.Process.Start("D\\myTest.exe");      // 외부 프로그램
     System.Diagnostics.Process.Start("http://google.com");    // 웹사이트

방식 2)
     System.Diagnostics.Process.Start("exlorer", "D\\my\\Test\\"); // 특정 폴더
     System.Diagnostics.Process.Start("exlorer", "http://google.com");    // 웹사이트

* 인터넷을 찾아보면 방식 2)와 같은 코드를 많이 볼 수 있는데,
방식 1)과 방식 2)의 결과는 동일하지만 방식 1)의 속도가 훨씬 빠르다.속도 차이가 큼

문제 4. LCD 디스플레이(LCD Display) (Question 4. LC-Display)

문제 4. LCD 디스플레이(LCD Display)

PC/UVa ID : 110104/706, 인기도 : A, 성공률 : 보통, 레벨 : 1

한 친구가 방금 새 컴퓨터를 샀다. 그 친구가 지금까지 샀던 가장 강력한 컴퓨터는 공학용 전자 계산기였다. 그런데 그 친구는 새 컴퓨터의 모니터보다 공학용 계산기에 있는 LCD 디스플레이가 더 좋다며 크게 실망하고 말았다.

그 친구를 만족시킬 수 있도록 숫자를 LCD 디스플레이 방식으로 출력하는 프로그램을 만들어 보자.

입력
입력 파일은 여러 줄로 구성되며 표시될 각각의 숫자마다 한 줄씩 입력된다. 각 줄에는 s와 n이라는 두 개의 정수가 들어있으며, n은 출력될 숫자(0 <= n <= 99,999,999), s는 숫자를 표시하는 크기(1 <= s <= 10)를 의미한다. 0이 두 개 입력된 줄이 있으면 입력이 종료되며 그 줄은 처리되지 않는다.

출력
입력 파일에서 지정한 숫자를 수평 방향은 '-' 기호를, 수직 방향은 '|'를 이용해서 LCD 디스플레이 형태로 출력한다. 각 숫자는 정확하게 s + 2 개의 열, 2s + 3개의 행으로 구성된다.

마지막 숫자를 포함한 모든 숫자를 이루는 공백을 스페이스로 채워야 한다. 두개의 숫자 사이에는 정확하게 한 열의 공백이 있어야 한다.

각 숫자 다음에는 빈 줄을 한 줄로 출력한다. 밑은 각 숫자를 출력하는 방식이 나와 있다.


A friend of yours has just bought a new computer. Before this, the most powerful machine he ever used was a pocket calculator. He is a little disappointed because he liked the LCD display of his calculator more than the screen on his new computer! To make him happy, write a program that prints numbers in LCD display style.

Input

The input file contains several lines, one for each number to be displayed. Each line contains integers s and n, where n is the number to be displayed ( 0$ \le$n$ \le$99, 999, 999) and s is the size in which it shall be displayed ( 1$ \le$s$ \le$10). The input will be terminated by a line containing two zeros, which should not be processed.

Output

Print the numbers specified in the input file in an LCD display-style using s ``-'' signs for the horizontal segments and s ``|'' signs for the vertical ones. Each digit occupies exactly s + 2 columns and 2s + 3 rows. Be sure to fill all the white space occupied by the digits with blanks, including the last digit. There must be exactly one column of blanks between two digits.
Output a blank line after each number. You will find an example of each digit in the sample output below.

Sample Input

2 12345
3 67890
0 0

Sample Output



      --   --        -- 
   |    |    | |  | |   
   |    |    | |  | |   
      --   --   --   -- 
   | |       |    |    |
   | |       |    |    |
      --   --        -- 

 ---   ---   ---   ---   --- 
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   ---       
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   ---






Anyone help me!!! I have no idea why my answer is wrong.
Please let me know what's wrong..

My answers