อาการ: IIS start ไม่ได้ ด้วย Error ดังนี้ unexpected error 0x8ffe2740 occurred
สาเหตุ: เกิดจาก port ชนกัน
วิธีแก้ไข: ให้ไปเปลี่ยน port ของ IIS เช่นเปลี่ยนเป็น port 81
ที่มา: “Unexpected Error 0x8ffe2740 Occurred” Error Message When You Try to Start a Web Site
Monthly Archives: July 2010
Basic Commands
คำสั่งต่างๆที่จำเป็น เช่น
df -h ดูการใช้พื้นที่ Harddisk
du -sh folder_name ดูการใช้พื้นที่ของแต่ละ folder
ที่มา: UsingTheTerminal, Basic Commands
เว็บเมลล์บน Ubuntu
OpenWebMail
https://help.ubuntu.com/community/OpenWebMail
Webmail is software which allows you to view email from any computer, anywhere in the world, through your web browser. OpenWebMail is a simple, fast and popular webmail package. The website is here. This guide will enable you to setup webmail on your own server, for use either within your home network, or outside.
sudo dpkg -i owm2.53-2.deb
Wireless Driver on Ubuntu
ถ้าติดตั้ง Ubuntu เสร็จ แต่ Wireless ยังใช้ไม่ได้ให้ไปที่ System>Administration>Hardware Drivers
รอสักพักก็จะได้หน้าจอแสดง Driver มาให้เลือก โดยมี 2 อัน อันแรกคืออันที่ใช้อยู่ (ซึ่งใช้ไม่ได้) อันที่สองคืออันที่ยังไม่ได้ Activate เพราะไม่ใช่ Open Source ให้เลือกอันนี้ แล้วก็จะใช้ได้
ที่มา: WifiDocs Driver bcm43xx
Mount
แสดงรายระเอียดการ mount ที่เป็นอยู่
mount
ทำการ mount
mount /src /des
C language – compare file
บอกตำแหน่งเริ่มต้นที่ไฟล์ทั้ง 2 ไฟล์ แตกต่างกัน
[code lang=”c”]
//Compare File
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *fp1, *fp2;
char ch1, ch2, same;
unsigned long l;
if (argc != 3) {
printf("Usage: compare <file 1> <file 2>\n");
exit(1);
}
/* open first file */
if ((fp1 = fopen(argv[1], "rb")) == NULL) {
printf("Cannot open first file.\n");
exit(1);
}
/* open second file */
if ((fp2 = fopen(argv[2], "rb")) == NULL) {
printf("Cannot open second file.\n");
exit(1);
}
l = 0;
same = 1;
/* compare the files */
while (!feof(fp1)) {
ch1 = fgetc(fp1);
if (ferror(fp1)) {
printf("Error reading first file.\n");
exit(1);
}
ch2 = fgetc(fp2);
if (ferror(fp2)) {
printf("Error reading second file.\n");
exit(1);
}
if (ch1 != ch2) {
printf("Files differ at byte number %lu", l);
same = 0;
break;
}
l++;
}
if (same)
printf("Files are the same.\n");
if (fclose(fp1) == EOF) {
printf("Error closing first file.\n");
exit(1);
}
if (fclose(fp2) == EOF) {
printf("Error closing second file.\n");
exit(1);
}
return 0;
}
[/code]
C language – fgets
อ่านข้อมูลจากไฟล์ทีละบรรทัด
[code lang=”c”]
/* fgets exmaple */
#include
#define myfile "control"
int main() {
FILE * fp;
fp = fopen(myfile, "r");
if (fp == NULL)
perror("Error opening file");
else {
char mystring[100];
while (fgets(mystring, sizeof(mystring), fp)) {
printf(mystring);
}
fclose(fp);
}
return 0;
}
[/code]
ที่มา: cplusplus
C language – linked list
linked list ของตัวอักษร โดยการเพิ่มข้อมูลต่อท้าย ข้อมูลเดิม
[code lang=”c”]
/*linklist.h*/
typedef struct node * NODEPTR;
struct node {
char * data;
NODEPTR next;
} NODE;
void print_list(NODEPTR link);
int insert_list(char * value, NODEPTR * link);
NODEPTR make_node(char * value);
[/code]
[code lang=”c”]
/*linklist.c*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "linklist.h"
int main() {
NODEPTR link = NULL;
char str1[] = "A10";
char str2[] = "A20";
char str3[] = "B1";
char str4[] = "B5";
insert_list(str1, &link);
insert_list(str2, &link);
insert_list(str3, &link);
insert_list(str4, &link);
print_list(link);
return 0;
}
void print_list(NODEPTR link) {
for (; link != NULL; link = link->next) {
printf("%s\n", link->data);
}
}
int insert_list(char * value, NODEPTR * link) {
NODEPTR curr = *link, prev = NULL, make_node(), temp;
for (; curr != NULL ; curr = curr->next)
prev = curr;
if ((temp = make_node(value)) != NULL) {
temp->next = curr;
if (prev == NULL)
*link = temp;
else
prev->next = temp;
}
return (temp != NULL);
}
NODEPTR make_node(char * value) {
NODEPTR newptr;
if ((newptr = (NODEPTR) malloc(sizeof(struct node))) != NULL) {
newptr->data = value;
newptr->next = NULL;
}
return (newptr);
}
[/code]
C language – strcpy
[code lang=”c”]
/* strcpy example */
#include <stdio.h>
#include <string.h>
int main() {
char str1[] = "Sample string";
char str2[40];
char str3[40];
strcpy(str2, str1);
strcpy(str3, "copy successful");
printf("str1: %s\nstr2: %s\nstr3: %s\n", str1, str2, str3);
return 0;
}
[/code]
เปลี่ยน str2, str3 จาก array เป็น linked list
[code lang=”c”]
/* strcpy example */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char str1[] = "Sample string";
char * str2 = (char*) calloc(0, sizeof(str1));
char * str3 = (char*) calloc(0, sizeof(str1));
strcpy(str2, str1);
strcpy(str3, "copy successful");
printf("str1: %s\nstr2: %s\nstr3: %s\n", str1, str2, str3);
return 0;
}
[/code]
ที่มา: cplusplus.com
C language – linked list
linked list ของ Integer โดยการแทรกข้อมูล แบบเรียงลำดับจากน้อยไปมาก
ที่มา: การโปรแกรมภาษา C ดร.ดวงแก้ว สวามิภักดิ์
linklist.h
[code lang=”c”]
/*linklist.h*/
typedef struct node * NODEPTR;
struct node {
int data;
NODEPTR next;
} NODE;
void print_list(NODEPTR link);
int insert_list(int val, NODEPTR * link);
NODEPTR make_node(int value);
[/code]
linklist.c
[code lang=”c”]
/*linklist.c*/
#include <stdio.h>
#include <stdlib.h>
#include "linklist.h"
int main() {
NODEPTR link = NULL; // the sorted linked list
int val; // input value
val = 10;
insert_list(val, &link);
val = 20;
insert_list(val, &link);
val = 1;
insert_list(val, &link);
val = 15;
insert_list(val, &link);
print_list(link);
return 0;
}
void print_list(NODEPTR link) {
for (; link != NULL; link = link->next) {
printf("%d\n", link->data);
}
}
int insert_list(int val, NODEPTR * link) {
NODEPTR curr = *link;
NODEPTR prev = NULL, make_node(), temp;
for (; curr != NULL && val > curr->data; curr = curr->next)
prev = curr;
if ((temp = make_node(val)) != NULL) {
temp->next = curr;
if (prev == NULL)
*link = temp;
else
prev->next = temp;
}
return (temp != NULL);
}
NODEPTR make_node(int value) {
NODEPTR newptr;
//char *malloc();
if ((newptr = (NODEPTR) malloc(sizeof(struct node))) != NULL) {
newptr->data = value;
newptr->next = NULL;
}
return (newptr);
}
[/code]