Monster Oasis
覺得累就是進步的開始!

2010/07/09

iphone / hello world 2 / single rows in the table view

Filed under: Copy_N_Paste,Programming/C,Programming/misc — Tags: — 5:21 pm
// --
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    [cell.textLabel setText:@"Hello World!"];
    return cell;
}
// --
// --
Related URL:
  1. [memo] iphone dev / table view sample code
  2. iPhone class / method / instance naming convention
  3. [書上沒教的] iphone / xcode 出現這種 error : Check dependencies …error: There is no SDK with the name or path ‘iphoneosx.x’
  4. Protected: iPhone dev misc…. 授權憑證重建的方式
  5. 推薦 iPhone & iPad App 開發參考書 / dev books
  6. 我的第一隻 iPhone 程式 – HelloMap !
  7. Programming in Objective-C , sample code
  8. [URL] iPhone programming bookmarks / reference
  9. A simple Objective-C Method Declaration and Definition
  10. [導覽] 有趣的 iPad iPhone development video 教學

2010/07/08

[導覽] 有趣的 iPad iPhone development video 教學

Filed under: Copy_N_Paste,Programming/C,Programming/misc — Tags: , — 6:15 pm

From : Rory Lewis, PhD, JD

URL : http://www.rorylewis.com/docs/02_iPad_iPhone/05_iPhoneTutorials.htm

另外給初接觸 objective-c 的介紹:

URL : http://maciku.blogspot.com/2009/12/iphone-objective-c.html

中文開發網站 : http://www.cocoachina.com/iphonedev/

// ——————

obj->method(argv);

[obj method: argv];

// ——————

@implementation HelloController
- (IBAction)sayHello:(id)sender {
  [destinationTextField setStringValue:[sourceTextField stringValue]];
}
@end
(id)sender 是一個可以選擇性的用法,
若您有需要取得發出 IBAction的元件時,可以用這個 sender變數來取得.
但記得可能需要 cast一下.
UIButton *senderButton=(UIbutton*) sender;
[senderButton setHidden: YES];
這樣就會把該button隱藏起來.

(id)sender 是一個可以選擇性的用法,若您有需要取得發出 IBAction的元件時,可以用這個 sender變數來取得.但記得可能需要 cast一下.

UIButton *senderButton=(UIbutton*) sender;[senderButton setHidden: YES];

這樣就會把該button隱藏起來.

// ——————

[2010/7/9 下午 04:48:25] Rimmon 2.0: jason 有 mac os 的 sftp GUI 的 tools 嗎?

[2010/7/9 下午 04:48:40] Rimmon 2.0: 想要用 tools 傳 code 比較方便

[2010/7/9 下午 04:51:05] _RTN Jason Chen: http://www.versiontracker.com/dyn/moreinfo/macosx/15693

[2010/7/9 下午 04:51:08] _RTN Jason Chen: Fugu

[2010/7/9 下午 04:51:35] _RTN Jason Chen: www.versiontracker.com 有非常多的 OSX 軟體可下載

[2010/7/9 下午 04:53:59] _RTN Jason Chen: 還有 Microsoft Remote Desktop Connection 可遠端遙控 Windows

[2010/7/9 下午 04:55:13] _RTN Jason Chen: smb://172.30.0.29/Install   這樣 OSX 才看得懂網路分享目錄

[2010/7/9 下午 05:00:10] _RTN Jason Chen: Finder, 用 apple鍵 + K 再輸入 cifs://172.30.0.19/Install 即可連 server shared

Related URL:
  1. 推薦 iPhone & iPad App 開發參考書 / dev books
  2. 我的第一隻 iPhone 程式 – HelloMap !

2010/03/18

開啟 vmware esxi server virtual switch Promiscuous Mode 的方法 – for sniff network purpose

Filed under: JOB,Programming/C,System/Linux/Unix* — 4:49 pm

要研究這麼深?! 沒辦法, 最近遇到奇怪問題非得啟用 Promiscuous Mode 來看看發生啥事了.

設定 step by step 看圖:056a3fd358a30a988ad401d605afe440

 

這是 免費的 sniff tools: http://www.ethereal.com/

2010/03/17

tracking system 新點子

Filed under: JOB,Network service,Programming/C — 2:55 pm

上週聽了 ora 公司的產品說明, 覺得不錯.

它是 tracking system 產品, 可是更 friendly / 非侵入式的作法, 它利用 switch 或 SLB設備的 mirror port 把流經的 traffic 導進這個 program , 由這個 program 來進行 traffic 分析.

架構簡圖:

420dbc62a3d3bc44984d3a927888b7fe

 

若要自行作的話可能會需要看懂這個

Programming with pcap
http://www.tcpdump.org/pcap.htm

The Sniffer’s Guide to Raw Traffic (a libpcap tutorial)
http://yuba.stanford.edu/~casado/pcap/section1.html

2009/11/20

Get MAC address using C

Filed under: Copy_N_Paste,JOB,Programming/C,System/Linux/Unix* — Tags: — 5:00 pm

不過 , 這邊有指定 eth0 , 若 server 有很多 interface 的話就要注意一下了.

#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>

int main( int argc, char *argv[] )
{
	int s;
	struct ifreq buffer;

	s = socket(PF_INET, SOCK_DGRAM, 0);

	memset(&buffer, 0x00, sizeof(buffer));

	strcpy(buffer.ifr_name, "eth0");

	ioctl(s, SIOCGIFHWADDR, &buffer);

	close(s);

	for( s = 0; s < 6; s++ )
	{
		printf("%.2X ", (unsigned char)buffer.ifr_hwaddr.sa_data[s]);
	}

	printf("\n");

	return 0;
}
Related URL:
  1. [好文推薦] A TUTORIAL ON POINTERS AND ARRAYS IN C
  2. The Expat XML Parser – XML 分析/拆解工具 – C – 這個讚! 用 C 寫 spider 會用到
  3. Protected: Some Simple C Programs – 好用的 C 範例程式/片段
  4. 新的轉碼方法 , libiconv , BIG5 轉 UTF8
  5. get my ip address useing c / sample code
  6. 解決 error while loading shared libraries 的方法
  7. compile multiple source code

2009/09/10

[好文推薦] A TUTORIAL ON POINTERS AND ARRAYS IN C

Filed under: Copy_N_Paste,Programming/C — Tags: — 1:40 pm

"C 語言" … ㄏㄏ.. 這麼古老且重要的語言,從 1972年開始到現在至少超過30年! 學會 pointer 後 C 就算是懂 90% 了

REF: http://en.wikipedia.org/wiki/C_%28programming_language%29

FROM URL : http://home.netcom.com/~tjensen/ptr/pointers.htm

TABLE OF CONTENTS

Preface

Introduction

Chapter 1: What is a Pointer?

Chapter 2: Pointer Types and Arrays.

Chapter 3: Pointers and Strings

Chapter 4: More on Strings

Chapter 5: Pointers and Structures

Chapter 6: More on Strings and Arrays of Strings

Chapter 7: More on Multi-Dimensional Arrays

Chapter 8: Pointers to Arrays

Chapter 9: Pointers and Dynamic Allocation of Memory

Chapter 10: Pointers to Functions

Related URL:
  1. Get MAC address using C
  2. The Expat XML Parser – XML 分析/拆解工具 – C – 這個讚! 用 C 寫 spider 會用到
  3. Protected: Some Simple C Programs – 好用的 C 範例程式/片段
  4. 新的轉碼方法 , libiconv , BIG5 轉 UTF8
  5. get my ip address useing c / sample code
  6. 解決 error while loading shared libraries 的方法
  7. compile multiple source code

2009/08/20

編程最佳的字型 consolas / notepad++ 及 winscp 設定 / Best programming fonts

http://www.sitepoint.com/blogs/2009/05/01/top-10-programming-fonts/

173dd6cf51cee56ee41c03a4eea53d43 5f51869c4d702101b28643d2ce7ee81f eb97be5da4e6ee5ee99f97467c5b3187

Related URL:
  1. unix shell programming / sh / csh syntax

2009/08/13

The Expat XML Parser – XML 分析/拆解工具 – C – 這個讚! 用 C 寫 spider 會用到

Expat is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers for things the parser might find in the XML document (like start tags). An introductory article on using Expat is available on xml.com.

Function reference : http://www.xml.com/pub/a/1999/09/expat/reference.html

Related URL:
  1. Get MAC address using C
  2. [好文推薦] A TUTORIAL ON POINTERS AND ARRAYS IN C
  3. Protected: Some Simple C Programs – 好用的 C 範例程式/片段
  4. 新的轉碼方法 , libiconv , BIG5 轉 UTF8
  5. get my ip address useing c / sample code
  6. 解決 error while loading shared libraries 的方法
  7. compile multiple source code

2009/06/10

Protected: Some Simple C Programs – 好用的 C 範例程式/片段

Filed under: Copy_N_Paste,Programming/C,Software,System/Linux/Unix* — Tags: , — 2:28 pm

This post is password protected. To view it please enter your password below:


Related URL:
  1. Get MAC address using C
  2. [好文推薦] A TUTORIAL ON POINTERS AND ARRAYS IN C
  3. The Expat XML Parser – XML 分析/拆解工具 – C – 這個讚! 用 C 寫 spider 會用到
  4. 新的轉碼方法 , libiconv , BIG5 轉 UTF8
  5. get my ip address useing c / sample code
  6. 解決 error while loading shared libraries 的方法
  7. compile multiple source code

2009/04/07

新的轉碼方法 , libiconv , BIG5 轉 UTF8

Filed under: Copy_N_Paste,JOB,Programming/C — Tags: , — 6:23 pm

Jack 大大寫好了這段 code , 很好用, 就貼在這兒了, 下次可以直接剪下跟貼上

重點有兩個:

1. From encoding 是 CP950

2. libiconv 不要用 libc 的, 因為缺一個 function : iconvctl

int fnConvert(const char *from, const char *to, char* save, int savelen, char *src, int srclen)
{
    iconv_t cd;
    char   *inbuf = src;
    char *outbuf = save;
    size_t outbufsize = savelen;
    int status = 0;
    size_t  savesize = 0;
    size_t inbufsize = srclen+1;
    char* inptr = inbuf;
    size_t      insize = inbufsize;
    char* outptr = outbuf;
    size_t outsize = outbufsize;

    if ( ( cd = iconv_open(to, from) ) == (iconv_t)-1 )
    {
        status = -1;
        goto done;
    }

    iconv(cd,NULL,NULL,NULL,NULL);
    if (inbufsize == 0)
    {
        status = -1;
        goto done;
    }
    while (insize > 0)
    {
        size_t res = iconv(cd, &inptr,&insize,&outptr,&outsize);
        if (outptr != outbuf)
        {
            int saved_errno = errno;
            int outsize = outptr - outbuf;
            strncpy(save+savesize, outbuf, outsize);
            errno = saved_errno;
        }
        if (res == (size_t)(-1))
        {
            if (errno == EILSEQ)
            {
                int one = 1;
                iconvctl(cd,ICONV_SET_DISCARD_ILSEQ,&one);
                status = -3;
            }
            else if (errno == EINVAL)
            {
                if (inbufsize == 0)
                {
                    status = -4;
                    goto done;
                }
                else
                {
                    break;
                }
            }
            else if (errno == E2BIG)
            {
                status = -5;
                goto done;
            }
            else
            {
                status = -6;
                goto done;
            }
        }
    }
    status = strlen(save);
done:
    iconv_close(cd);
    return status;
}

EXAMPLE:
int fnB2U( unsigned char *str )
{
    int srclen, destlen, status;
    unsigned char tmp[2048];

    status = -1;
    if ( ( srclen = strlen( str ) ) == 0 )
        return status;
    destlen  = sizeof( unsigned char ) * ( srclen * 2 ) + 1;
    tmp[0] = '';
    if ( ( status = fnConvert ( "CP950", "UTF-8", tmp, destlen, str, srclen) ) > 0 )
        strcpy( str, tmp);
    else
        printf( "status = %dn");
    return( status);
}
Related URL:
  1. Get MAC address using C
  2. [好文推薦] A TUTORIAL ON POINTERS AND ARRAYS IN C
  3. The Expat XML Parser – XML 分析/拆解工具 – C – 這個讚! 用 C 寫 spider 會用到
  4. Protected: Some Simple C Programs – 好用的 C 範例程式/片段
  5. get my ip address useing c / sample code
  6. 解決 error while loading shared libraries 的方法
  7. compile multiple source code
下頁»

www.monster.com.tw , © Copyright 2008