2012年12月18日 星期二

[IPv6] IPv6 HOWTO

Linux IPv6 HOWTO
Linux IPv6 HowTo Guide
Linux 上的 IPv6 路由
DomLinux支援IPv6
Individual Lab: RIP IPv6 Routing (RIPng)
IPv6 RIPng Introduction
USAGI Project

IBM IPv6 Static Routing
IBM IPv6 RIP Protocol

2012年12月4日 星期二

[PS] 製作舊紙

Photoshop幾步制作有年代的舊紙
Apple海報設計教程

2012年10月16日 星期二

[iOS] iOS 6 - Contact's Privacy


Request Permission
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
// Do whatever you need.
});
}


iOS SDK Release Notes for iOS6

2012年10月3日 星期三

[Programming] scanf()

Issue: scanf() by char or string goes wrong result.

#include <stdio.h>

int main(int argc, char **argv)
{
        int valA;
        char valB;

        scanf ("%d", &valA);
        printf ("valA=%d\n", valA);
        scanf ("%c", &valB);
        printf ("valB=%c\n", valB);

        return 0;
}

Result:

3
valA=3
valB=

Expect result:
3
valA=3
4
valB=4

Reason: scanf() doesn't handle new line character, "\n".


Solution1: Discard the last character "\n" by "%*c".


#include <stdio.h>

int main(int argc, char **argv)
{
        int valA;
        char valB;

        scanf ("%d%*c", &valA);
        printf ("valA=%d\n", valA);
        scanf ("%c%*c", &valB);
        printf ("valB=%c\n", valB);

        return 0;
}


Solution2: Add a space character to second scanf().
#include <stdio.h>

int main(int argc, char **argv)
{
        int valA;
        char valB;

        scanf ("%d", &valA);
        printf ("valA=%d\n", valA);
        scanf (" %c", &valB); // It is " %c". There is a space character in front of %c.
        printf ("valB=%c\n", valB);

        return 0;
}


Solution3: Read out the "\n" by getchar();

#include <stdio.h>

int main(int argc, char **argv)
{
        int valA;
        char valB;

        scanf ("%d", &valA);
        getchar();
        printf ("valA=%d\n", valA);

        scanf ("%c", &valB);
        getchar();
        printf ("valB=%c\n", valB);

        return 0;
}

2012年9月21日 星期五

[iOS] Retina display


iPhone and iPod touch
Portrait: 320 x 480 pixels
Portrait Retina: 640 x 960 pixels (@2x)

iPhone 5 and iPod touch (5th generation)
Portrait: 640 x 1136 pixels (@2x)

iPad
Portrait: 768 x 1004 pixels
Portrait Retina: 1536 x 2008 pixels (@2x)
Landscape: 1024 x 748 pixels
Landscape Retina: 2048 x 1496 pixels (@2x)

2048x1536 with 264 ppi.
960x640 with 326 ppi.

normal: 32x32 :image.png
retina: 64x64: image@2x.png

App-Related resources
Font size for Retina display
How to Define UIImageView size as UIImage resolution?
Preparing your iPhone App for Higher Resolution
Detect Retina device
How to serve high-resolution website images for retina displays

2012年9月18日 星期二

[Adobe] Adobe Illustrator

AI 裁圖
CG數位學習網
飛爾酥創意設計
Illustrator 繪圖教學
Vectips.com
50 多個 Adobe Illustrator 圖示製作教學

[English] Useful sentences

Hopefully you get this mail in time.

[Mac] Enable/Disable Root User

How to Enable/Disable Root User on Mac

[Law] 著作權與肖像權

著作權與肖像權
淺談[肖像權]

[Linux] Makefile autotools

Autotools for Makefile
PKG_CHECK_MODULES

[OpenSource] Follow up

COSCUP
FreedomHEC Taipei
GNOME.Asia
Jserv's blog

[English] MyOOPS 開放式課程

MyOOPS 開放式課程

2012年9月6日 星期四

[iOS] Icon glossy

Add a row with key named "Icon already includes gloss effects" and boolean value set to "YES".


Glossy icon



Not glossy icon

2012年7月16日 星期一

2012年7月5日 星期四

2012年6月28日 星期四

[Linux] Minimal syslog file

# fix logs into memory instead of /var/log/messages. and the log size is 512 KB
syslogd -C 512
# to read the logs
logread

2012年6月23日 星期六

[iOS] Link new xib to File's Owner

The correct answer was given by user763308:
To link a .xib to a class under Xcode4:
  1. Open your .xib.
  2. In placeholder: select File's Owner.
  3. In the third thumbnail:"Identity Inspector" of the right panel, edit the "Custom Class" field and enter the name of your class.
I also then had to:
  1. Click the root view under Objects.
  2. Click the last tab: "Show Connections".
  3. Drag "New referencing outlet" to "File's Owner" and select "view".

2012年6月18日 星期一

[iOS] Hide Status Bar


[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
or
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

plist:
UIStatusBarHidden, value boolean

[iOS] Change APP name

TARGETS -> UnoOnline -> Build Settings -> Product Name -> UNO Online

2012年6月7日 星期四

[Technology] 3G-4G 理論速度


Downstream Upstream
3G WCDMA 384kbps 384kbps 中華電信, 台灣大, 遠傳, 威寶
CDMA2000 3.1Mbps 1.8Mbps 亞太
3.5G HSDPA 14.4Mbps 384kbps
3.75G HSUPA 14.4Mbps 5.76Mbps
---- HSPA+ 21.6Mbps 5.76Mbps
3.9G HSDPA+ 42Mbps 5.76Mbps 威寶
4G LTE 326.4Mbps 86.4Mbps

2012年6月6日 星期三

[TOOL] CVS add directories recursively


First, add all the directories, but not any named "CVS":
find . -type d \! -name CVS -exec cvs add '{}' \;
Then add all the files, excluding anything in a CVS directory:
find . \( -type d -name CVS -prune \) -o \( -type f -exec cvs add '{}' \; \)
find . -type f -print0| xargs -0 cvs add
Reference

2012年6月5日 星期二

[Linux] DNS Relay

1. Download BIND
http://www.bind9.net/download

2. Cross compile ./configure --host=mips --disable-static --prefix=$(TOOLCHAIN) --includedir=$(INC_GPL_HEADER_PATH) --libdir=$(INC_GPL_LIB_PATH) --with-openssl=no --with-pkcs11=no --with-gssapi=no --with-randomdev=no --without-iconv --without-libiconv --without-docbook-xsl --with-libxml2=no --with-purify=no --with-docbook-xsl=no --with-libiconv=no --with-iconv=no --with-idnlib=no --with-atf=no --with-dlopen=no --with-dlz-mysql=no --with-dlz-postgres=no --with-dlz-bdb=no --with-dlz-filesystem=no --with-dlz-ldap=no --with-dlz-odbc=no --with-dlz-stub=no --disable-developer --disable-devpoll --disable-epoll --disable-largefile --disable-backtrace --disable-isc-spnego --disable-chroot
3. to fix gen issue (bind-tools-BJA-gen-HOSTCC.diff) : modify configure
if test "$cross_compiling" = "yes"; then
        if test -z "$BUILD_CC"; then
               as_fn_error $? "BUILD_CC not set" "$LINENO" 5
        fi
        BUILD_CFLAGS="$BUILD_CFLAGS"
        BUILD_CPPFLAGS="$BUILD_CPPFLAGS"
        BUILD_LDFLAGS="$BUILD_LDFLAGS"
        BUILD_LIBS="$BUILD_LIBS"
else

to

if test "$cross_compiling" = "yes"; then
        #if test -z "$BUILD_CC"; then
        #       as_fn_error $? "BUILD_CC not set" "$LINENO" 5
        #fi
        BUILD_CC="$CC"
        BUILD_CFLAGS="$BUILD_CFLAGS"
        BUILD_CPPFLAGS="$BUILD_CPPFLAGS"
        BUILD_LDFLAGS="$BUILD_LDFLAGS"
        BUILD_LIBS="$BUILD_LIBS"
else

4. to fix epoll issue (or compile it with "--disable-epoll" in step 2.)
bind-tools-BJA-epoll-AC_TRY_RUN-cross.diff

5. /var/named.conf
#Disable query logging
logging {
        category default { null; };
        category lame-servers { null; };
        category edns-disabled { null; };
}

options {
        directory "/var/named";
        version "not currently available";
        listen-on { 192.168.0.1; };
        avoid-v4-udp-ports { range 1 32767; };
        avoid-v6-udp-ports { range 1 32767; };
        forwarders { 168.95.1.1;168.95.192.1; };
        forward only;
        max-ncache-ttl 3;
        allow-transfer { none; };
        allow-update-forwarding { none; };
        allow-notify { none; };
};

6. run named
mkdir /var/named
named -c /var/named.conf -d 10 -p 53

7. messages and logs
/var/log/messages  (if syslogd exists.)
/var/log/named.run

References:
DNS BIND - Operations Statements
DNS HOWTO
bind - DNS 設定
example 1
example 2

2012年3月11日 星期日

[iOS] UIAlertView

UIAlert View with multiple options.

in .h: include UIAlertViewDelegate


@interface MyController : UIViewController <UIAlertViewDelegate> {
}

in .m: implement delegate for UIAlertViewDelegate


#pragma UIAlertView
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"%d", buttonIndex);

[iOS] UIActionSheet

UIActionSheet Class Reference
Move Cancel Button from top to bottom

In .h: include UIAlertViewDelegate

@interface MyController : UIViewController <UIAlertViewDelegate> {
}


In .m: implement delegates

- (void) ShowActionSheet:(NSString *)title {
    UIActionSheet *actionSheet = [[UIActionSheet alloc
                                  initWithTitle:title
                                  delegate:self
                                  cancelButtonTitle:nil
                                  destructiveButtonTitle:nil 
                                  otherButtonTitles: nil];
    
    [actionSheet addButtonWithTitle:@"Option 1"];
    [actionSheet addButtonWithTitle:@"Option 2"];
    [actionSheet addButtonWithTitle:@"Option 3"];

    [actionSheet addButtonWithTitle:@"Cancel"];
    actionSheet.cancelButtonIndex = actionSheet.numberOfButtons;
    
    [actionSheet showInView:self.view];
    [actionSheet release];
}

- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"title=%@, buttonIndex: %d, cancelButtonIndex: %d, firstOtherButtonIndex: %d",
          actionSheet.title,
          buttonIndex, 
          actionSheet.cancelButtonIndex
          actionSheet.firstOtherButtonIndex);
}


2012年3月9日 星期五

2012年2月19日 星期日

[Marathon] 第六屆台南古都馬拉松 12-Feb. 2012

這次的全馬算是最順利的一次....
20公里內都在肌肉能負荷的情況下....
大致跑了 2:20 ....
過了20公里....
一些平常沒在訓練的肌肉就被拿出來用了....
像是股二頭肌, 半腱肌, 半膜肌, 臀中肌, 臀大肌, 髂脛束......(我抄網路的, 有錯請更正....)
很怕受傷, 就放慢了速度....
目標只要能平安跑完全程就好....

這個時候遇到了 Holy Allan....
邊跑邊哈啦....
大概一公里後我就追不上了....^^
望著那神一般的背影....
說聲 byebye.....

一路跑到30公里....
半腱肌實在是痛到不行....
就開始停下來用走的....
這時候就被一堆人輾過....
包括三超人....蝙蝠俠..蜘蛛人..超人....



走到最後 4 公里的時候....
百馬陪跑團上來了....
陪跑了 1 公里....
這時時間是 4:42....
心想這次不可能五小時內了....
那就........輕鬆走吧.....^^

回到終點....
時間顯示: 5:08....(晶片時間:05:06:18)

PS: 這次全馬第一次吃到西瓜..小蕃茄..手工饅頭....以往都是看人家收攤啊!!

2012年2月17日 星期五

[iOS] Class 1: NSArray, NSMutableArray, NSDictionary, NSMutableDictionary

NSArray

1. Can contain different variable types.
2. Contents of array cannot be modified. (add, remove and sort)

Create NSArray
NSArray *bookList = [NSArray arrayWithObjects: @"iPhone4", @"iOS", @"MacX", nil];

Add an empty object
[NSNull null]

Retrieve NSArray
NSArray *bookList = [NSArray arrayWithObjects:@"Moby", @"Frank", @"Tom", nil];
for (int y=0; y < bookList.count, y++) {
    NSLog (@"Book Title is %@", [bookList objectAtIndex:y])
}
result:
Book Title is Moby
Book Title is Frank
Book Title is Tom


NSMutableArray
1. Similar to NSArray.
2. Contents of array can be modified. (add, remove and sort)

Create NSMutableArray
NSMutableArray *bookList = [NSArray arrayWithObjects:@"iPhone4", @"iOS", @"MacX", nil];

Add an object (append to the end of the bookList)
[bookList addObject:@"New book"];

Insert an object at an specific place "index".
[bookList insertObject:@"New book" atIndex:index];

Remove an object at "index".
[bookList removeObject:index];

Sort Array: in alphabetical order
[bookList sortUsingSelector:@selector(caseInsensitiveCompare:)];


NSDictionary

1. Cannot be modified. (add, remove and sort)

Create NSDictionary
NSDictionary *book = [NSDictionary dictionaryWithObjectsAndKeys:
                                      @"a", @"1",
                                      @"b", @"2",
                                      @"c", @"3",
                                      @"d", @"4",
                                      @"e", @"5",
                                       nil];

Retrieve Object
[book objectForKey: @"1"];

NSMutableDictionary
1. Can be modified. (add, remove and sort)

Create NSMutableDictionary
NSMutableDictionary *book = [NSDictionary dictionaryWithObjectsAndKeys:
                                                  @"a", @"1",
                                                  @"b", @"2",
                                                  @"c", @"3",
                                                  @"d", @"4",
                                                  @"e", @"5",
                                                   nil];

Add an object
[book setObject: @"Value" forKey: @"KeyIndex"];


2012年2月8日 星期三

[LVM] Resolve to mount duplicate LVM

I built a new Linux system(Fedora10) in newH.D.(/dev/sda) and wanted to mount the oldH.D.(/dev/sdb) into it. But the oldH.D. has been installed the Linux system(also Fedora 10) before. Therefore, both newH.D. and oldH.D. has the same LVM group, "VolGroup00".
I'm trying to mount the oldH.D. and finally success.

1. Check the volume group.
[root@vincent local]# pvs
  PV         VG         Fmt  Attr PSize   PFree
  /dev/sda2  VolGroup00 lvm2 a-   465.56G 32.00M (newH.D.)
  /dev/sdb2  VolGroup00 lvm2 a-   931.31G 32.00M (oldH.D.)



2. Get the VG UUID of /dev/sdb2.

[root@vincent local]# vgdisplay
  --- Volume group ---
  VG Name                VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               931.31 GB
  PE Size               32.00 MB
  Total PE              29802
  Alloc PE / Size       29801 / 931.28 GB
  Free  PE / Size       1 / 32.00 MB
  VG UUID               CQVzV7-xVVy-Om3Y-P2Ng-67d5-juHK-vTTj5a
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               465.56 GB
  PE Size               32.00 MB
  Total PE              14898
  Alloc PE / Size       14897 / 465.53 GB
  Free  PE / Size       1 / 32.00 MB
  VG UUID               65loFF-2Tee-K4Wa-uUFf-oMRD-E1EH-iCKsQg

The VG UUID of /dev/sdb2 is CQVzV7-xVVy-Om3Y-P2Ng-67d5-juHK-vTTj5a.


3. Change the VG group name of /dev/sdb2.

[root@vincent local]# vgrename CQVzV7-xVVy-Om3Y-P2Ng-67d5-juHK-vTTj5a VG1T
4. Reboot the system. You will see the LVM group of /dev/sdb2 is changed to VG1T.

[root@vincent local]# pvs
  PV         VG         Fmt  Attr PSize   PFree
  /dev/sda2  VolGroup00 lvm2 a-   465.56G 32.00M
  /dev/sdb2  VG1T       lvm2 a-   931.31G 32.00M

5. Mount the /dev/sdb2 into our new system.

[root@vincent local]# mkdir /mnt/oldHD
[root@vincent local]# mount /dev/VG1T/LogVol00 /mnt/oldHD


[XCode] Review App

1. Debugging and Analyzing Your Code

2. Static Analyzing in XCode

2012年2月6日 星期一

2012年1月29日 星期日

[iOS] Icons for App submission

iOS Human Interface Guidelines
Make iPhone & iPod Touch icons


3. 512x512: iTunesArtwork
4. 1024x1024: iTunesArtwork@2x
For Ad-hoc distribution.


For iPhone/iPod touch:
1. 57x57: Icon.png
2. 114x114: Icon@2x.png
3. 320x480: Default.png
4. 640x960: Default@2x.png
5. 29x29: Icon-small.png
6. 58x58: Icon-small@2x.png
7. 50x50: Icon-small-50.png
8. 640x1136: Default-568h@2x.png

For iPad:
1. 72x72: Icon-72.png
2. 144x144: Icon-72@2x.png
3. 1024x748: Default.png
4. 2048x1496: Default@2x.png
5. 50x50: Icon-small.png
6. 100x100: Icon-small@2x.png

Images:
[UIImage imageNamed:@"bg-name-ip5"];

1. bg-name-ip5@2x.png
2. bg-name-ip4@2x.png
3. bg-name-ip4.png
~ipad, ~iphone, ~2x

Free Icons:
1. Reference1
2. Reference2
3. Reference3
4. Reference4

icon companies:
1. icondesign
2. The Iconfactory
3. IconDrawer