Month: ธันวาคม 2008

Telnet คุยกับ​ Server ( protocol : http )

 - by NAzT

สืบเนื่องมาจากตอนที่แล้ว  Basic Socket ตอนที่ 1.1 : ปลอม Referrer ด้วย php ซึ่งตอนที่แล้วเราคุยกับ Server ด้วย Socket ของ วันนี้เรามาคุยกับ Server ด้วย Telnet กันครับ

Telnet คืออะไรลองหาคำตอบกันที่ google กันก่อนนะครับ  ง่ายๆมันก็คือโปรแกรมสำหรับส่งคำสั่งไปยัง Server  นั่นแหละครับส่งไปเพื่อ  Remote Control เครื่องปลายทาง ไม่ต้องว่ากันมาก ดูรูปประกอบได้เลยครับ (ไม่ดูไม่รู้รื่องนะ)

telnet-http

telnet-http

ซึ่งตอนแรกเราออกคำสั่ง telnet แล้วเกิด   Refuse ก็เพราะ Read this article »

Basic Socket ตอนที่ 1.1 : ปลอม Referrer ด้วย php

 - by NAzT

ผมมี Code  อยู่ที่ http://www.together.in.th/php/referer.php ซึ่ง Code มีแค่

<?php

printf(“You come from : %s”,$_SERVER["HTTP_REFERER"]);

?>

ซึ่งจะบอกว่าเราไปยังหน้านั้น โดยคลิ๊กจากหน้าไหนเท่านั้นเองครับ ถ้าคลิกจากหน้านี้ก็จะได้ว่า

You come from : http://www.together.in.th/

ซึ่งจากคราวที่แล้ว ->  

Read this article »

Basic Socket Programming ตอนที่ 1 (php+wireshark)

 - by NAzT

วันนี้มาเขียนโปรแกรมโดยใช้ Socket แบบง่ายๆกัน โดยใช้ fsockopen ของ ครับ

เราจะทำตัวเป็น Browser กันนะครับ โดย Request ข้อมูลกับ Server เองครับ แต่วันนี้จะส่ง Request อย่างเดียวครับ  แต่ยังไม่ส่งค่าไปด้วย (เช่นค่าจาก Form)

อ้อ วันนี้เราจะใช้ ร่วมกับ PHP นะครับ  ใครจะใช้ Proxomitron ก็ไม่ว่ากันครับ 

โจทย์วันนี้ของเราคือ ถ้าเราใช้ Browser จะยี่ห้ออะไรก็แล้วแต่ครับ เปิดไป

ที่ http://bbs..com/webboard/checksum/index7.php?imgnum=027511150aa7bbd1171c1ae4e1d6e80fcc1681f981fbb2ee1c915983a583d838

Browser ของเราก็จะไป Request ข้อมูลกับทาง Server แล้ว Server ก็จัดให้ตามคำขอครับผม ดูได้จากรูปได้เลยครับ  ซึ่ง No.16 ก็คือ Request ของเรานั่นเอง ส่วน No.26 ก็จะเป็นคำตอบของ Server จะเห็นว่า Server ส่งข้อมูลกลับมาซึ่งเป็นเป็นข้อมูลชนิด PNG ครับผม (ดูจากรูปครับผม)

basic-socket-1-wireshark

basic-socket-1-wireshark

แต่ส่วนข้างบนนั้น  Browser ของเราเป็นคนไป Req Read this article »

Pango Cause Wireshark Crashed!

 - by NAzT

Process:         -bin [563] Path:            /Applications/.app/Contents/Resources/bin/-bin Identifier:      -bin Version:         ??? (???) Code Type:       X86 (Native) Parent Process:   [562]   Date/Time:       2008-12-29 10:11:46.068 +0700 OS Version:      Mac OS X 10.5.5 (9F33) Report Version:  6   Exception Type:  EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000 Crashed Thread:  0   Dyld Error Message:   Symbol not found:   Referenced from: /Applications/.app/Contents/Resources/lib/pango/1.6.0/modules/pango-thai-fc.so   Expected in: flat namespace

วันนี้ Wireshark Crash ทำให้หงุดหงิดมาก Crash ตอนจะ Save  Capture File หลายรอบมาก หงุดหงิดมากๆ

เลยลองดูซิว่า Read this article »

MPI Programming : ตอนที่ 2

 - by NAzT

Blocking Communication

อันนี้เป็น Prototype ของ MPI_Send และ MPI_Recv ซึ่งเป็นการสื่อสารแบบ Blocking ครับ (มันมี Non-blocking ด้วยไว้ค่อยมาคุยกันอีกทีว่ามันต่างกันยังไงในวันหลังนะครับ)

ที่ยกเรื่องนี้มาให้ดูก่อน เพราะตอนหน้าเราจะส่งข้อมูลข้าม Process โดยใช้ MPI (Send & Recv) กันแล้วคร้าบผม

int MPI_Send( void *buf,
              int count,
              MPI_Datatype datatype,
              int dest,
              int tag,
              MPI_Comm comm
);

Read this article »

MPI Programming ตอนที่ 1

 - by NAzT

วันนี้เราลองมาหัดเขียนโปรแกรมแบบ MPI กันดีกว่าครับ ศึกษาจาก Code กันไปเลย ง่ายๆ

แต่ MPI คืออะไรล่ะ?

มันเป็นแบบนี้ครับ เมื่อเราเขียนโปรแกรมแบบ Parallel Computers ซึ่งก็คือการเขียนโปรแกรมที่ให้ Computer หลายตัวช่วยกันประมวลผล (Cluster Computing) พอมีหลายหน่วยประมวลผลแล้วเราก็ต้องมีการส่งข้อมูลไปมาไงครับ

เช่นมีงาน 100 งาน แล้วมี 4 Processors แบ่งกันทำคนละ 25 งาน  พอทำเสร็จแล้วก็ต้องเอางานมารวมกัน ก็ต้องอาศัย MPI เนี่ยแหละครับในการส่งข้อมูลระหว่าง Processor  อันนี้คือความหมายของ MPI แบบคร่าวๆครับผม

MPI = Message Passing Interface  แต่วันนี้ยังไม่มีการส่ง Message ครับผม Code ง่ายๆวันนี้

MPI_0_code

Simple Code

คำอธิบาย Code กด อ่านต่อได้เลยคร้าบบผมม

Read this article »

แนะนำ Ipod touch Clock : Night Stand

 - by NAzT

 

Night Stand

Night Stand

 

 

Night Stand เป็น Application ที่เอาไว้แสดงเวลาแบบในรูปล่ะครับ

ซึ่งมีคุณสมบัติดังนี้

1. ซึ่งเราสามารถปรับได้ว่าจะเอาสีอะไร (มีแดง เขียว น้ำเงินครับ)

2. ดูได้ทั้งแนวตั้งและแนวนอน

3. แสดง/ซ่อน Day of week

4. แสดง/ซ่อน วินาที

5. ปิด Auto Lock

6. แสดงเวลารูปแบบ 12 หรือแบบ 24 

และที่สำคัญฟรีครับ Free หาโหลดได้ใน Store ได้เลยครับ

Read this article »

So Faraway

 - by NAzT

“เราว่าไม่เห็นต้องลืมเลย แค่จำแต่เรื่องดีๆ ชีวิตเราก็มีความสุขได้แล้ว

 

วันนี้ได้ดูตัวอย่างหนังสั้น ที่ชื่อว่า So faraway 

 

เห็นเค้าเขียนไว้ด้วยนะว่าได้รับรางวัลชนะเลิศการประกวด

 

พอได้ดูก็ชอบแฮะ มีคำนึงที่ฟังแล้วสะดุด

 

“เราว่าไม่เห็นต้องลืมเลย

แค่จำแต่เรื่องดีๆ ชีวิตเราก็มีความสุขได้แล้ว”

 

 

Related Blogs

    AdSense Integrator

     - by NAzT

     

    ถ้าใครมองหา Plugin ที่สำหรับแสดง ใน Blog แล้วล่ะก็

    ผมขอแนะนำ ครับ เพราะสะดวกดี ไม่ต้องทำอะไรมาก

    แค่ติดตั้ง แล้วก็เอา Code ของ Google Adsense มาใส่ลงในช่องแล้วก็เลือกตำแหน่งที่จะให้แสดง

    ง่ายไหมล่ะครับ ^0^

    picture-8

    Read this article »

    จำนวนเฉพาะ Sequential (Sieve of Eratosthenes)

     - by NAzT

    การหาจำนวนเฉพาะโดยใช้ Sieve Algorithm โดยใช้ Sieve of Eratosthenes โดยมันจะทำงานแบบนี้ Animated Sieve of Eratosthenes

    อธิบายง่ายๆก็คือมันจะเอาจำนวนเฉพาะไปวนหารจนครบน่ะแหละ Read this article »

    โปรแกรมหาค่า Pi แบบ Parallel

     - by NAzT
    โปรแกรมหาค่า Pi แบบ Parallel โดยคำนวณจากการ Integrate พื้นที่ใต้กราฟนั่นเอง โดย Code นี้ใส่ส่วนที่ทำให้แต่ละ Thread Synchronize ข้อมูลกัน ซึ่งให้เข้าเสียบตัวแปร Sum ทีละ Thread ซึ่ง Codeนี้ จะใช้ omp atomic บน ตัวแปร sum และแต่ละ Thread จะมี local_sum เป็นของตัวเอง

    ปล. ใช้ OpenMP ร่วมกับภาษา C จ้า

    Read this article »

    จำนวนเฉพาะ Sequential [2]

     - by NAzT
    #include
    #include
    #include
    #define MAX 10000000
    int Prime[MAX]={2,3,5,7,11,13,17,19,23,29};
    int found=10;
    int isPrime(int input);
    int myFactor[8]={1,7,11,13,17,19,23,29};
    int main()
    {
        int n=MAX/30;
        clock_t start, stop;
        int i;
        int j=0;
        int factVal=0;
        start = clock();
        for(i=1;i<=n;i+=1)
        {
            for(j = 0; j < 8 ; ++j)
            {
                factVal=i*30+myFactor[j];
                if(isPrime(factVal) && factVal <= MAX)
                {
                    Prime[found]=factVal;
                    ++found;
                }
            }
        }
        stop = clock();
        printf ("Finding Prime in range 1 to %d n ",MAX);
        printf ("Found %d Primesn",found);
        printf("Used  %f secondsn",((double)(stop - start)/1000000.0));
    }
    int isPrime(int input)
    {
        int flag=1;
        int i;
        for(i=0;Prime[i]<=sqrt(input)&&flag;i++)
        {
            if(input%Prime[i] == 0)
            {
                flag=0;
            }
        }
        return flag;
    }

    รอบหน้า findPrime Version Parallel

    Related Blogs

    โปรแกรมหาจำนวนเฉพาะแบบ Sequential

     - by NAzT

    #include 

    include

    int isPrime(int num); int main() { int i; for(i=2;i< =1000000;++i) { if(isPrime(i)==1) { printf ("%dn",i); } } } int isPrime(int num) { int i; int flag=1; // assume input number is prime for(i=2;i<=sqrt(num);i+=2) { if( (num%i) == 0) { flag=0; break; } } return flag; }
    โปรแกรมหาจำนวนเฉพาะแบบ Sequential

    Related Blogs