วันพฤหัสบดีที่ 28 กุมภาพันธ์ พ.ศ. 2556

Memcached Mac OSX


Memcached Mac OSX
Install : sudo port install memcached
Start : memcached -d -m 64 -p 11211
Stop : killall memcached
Test : telnet localhost Port 

Comment : 
     get greeting \\ End

Server :
vi /etc/sysconfig/memcached

# /etc/init.d/memcached start
# /etc/init.d/memcached stop
# /etc/init.d/memcached restart
# /etc/init.d/memcached status


# memcached-tool 192.168.1.15:11211 stats

Redis Server CentOS


Redis Server

-- Install :
wget http://redis.googlecode.com/files/redis-2.6.5.tar.gz
tar xzf redis-2.6.5.tar.gz
cd redis-2.6.5
make

Run : redid-server
Connect : redis-cli
Kill : killall redis-server

nginx PHP5 FastCGI Centos


yum install nginx

nginx configuration file
  • Default config file: /etc/nginx/nginx.conf
  • Default SSL config file: /etc/nginx/conf.d/ssl.conf
  • Default virtual hosting config file: /etc/nginx/conf.d/virtual.conf
  • Default documentroot: /usr/share/nginx/html

yum install php-pear-Net-Socket php-pear php-common php-gd php-devel php php-mbstring php-pear-Mail php-cli php-imap php-snmp php-pdo php-xml php-pear-Auth-SASL php-ldap php-pear-Net-SMTP php-mysql

yum install spawn-fcgi

# /etc/init.d/php_cgi start
# netstat -tulpn | grep :9000

vi /etc/nginx/nginx.conf

service nginx restart

Install SVN Centos


SVN หรือ Versioning Control ซึ่งจะสะดวกมาในการทำงานเป็นทีมและสามารถเลือกได้ว่าเราจะอัพเดตไปยัง Revision ไหน(เวอร์ชั่นไหน) โดยหลักๆ เราจะแบ่งโครงการออกเป็นสามส่วนคือ trunk branch และ tags โดยแต่ละส่วนจะมีการกำหนดดังนี้

  • Trunk เป็นส่วน Core ของโปรเจ็ค หรือเรียกง่ายๆ ว่าอะไรที่ Stable แล้วเราจะใส่ไว้ในส่วนนี้
  • Branch เป็นส่วนที่เป็น Feature ที่เราจะทำการเพิ่มเติมขึ้นมา ส่วนใหญ่เมื่อผ่านพ้นช่วงทดสอบต่างๆ และเป็นที่ยอมรับของทีมแล้ว เราก็จะนำเข้าไปไว้ใน Trunk
  • Tags จะเป็นตัวแบ่งเวอร์ชั่นออกจากกันเช่นเมื่อเราออกเวอร์ชั่น Stable แล้วเราก็จะ copy มาใส่ไว้ใน Tags เพื่อที่จะได้มีหลายเวอร์ชั่นให้ผู้พัฒนาได้เลือก

yum install httpd
chkconfig httpd on

ซึ่ง chkconfig จะทำให้ตัว httpd server เริ่มต้นอัตโนมัติเมื่อเริ่มระบบ
หลังจากนั้นทำการแก้ไขไฟล์ httpd.conf
vim /etc/httpd/conf/httpd.conf
แก้ไขตามความต้องการหากต้องการเปลี่ยน Port ก็เปลี่ยนได้เลยครับ
หลังจากนั้นทำการแก้ไขไฟล์ subversion.conf
vim /etc/httpd/conf.d/subversion.conf
ทำการ uncomment บรรทัดต่อไปนี้

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<location /repos>
   DAV svn
   SVNParentPath /var/www/svn/repos
   # Limit write permission to list of valid users.
   #<limitexcept>
      # Require SSL connection for password protection.
      # SSLRequireSSL
      AuthType Basic
      AuthName "Authorization Realm"
      AuthUserFile /etc/svn-auth-conf
      Require valid-user
   #</limitexcept>
</location>

htpasswd -cm /etc/svn-auth-conf yourusername
ระบบจะให้ใส่รหัสสำหรับ User
สองครั้ง

หากหลังจากนี้ต้องการเพิ่ม user ให้ใช้แค่คำสั่ง htpasswd -m /etc/svn-auth-conf เพราะไฟล์ svn-auth-conf นั้นได้ถูกสร้างไว้แล้ว (-c หมายถึงให้สร้างไฟล์ htpasswd ขึ้น)


mkdir /var/www/svn
cd /var/www/svn
svnadmin create repos
chown -R apache.apache repos
service httpd restart

svnadmin เป็นการใช้ svnadmin สร้าง directory repos และ chown เป็นการโดนสิทธิ์ให้กับ apache ซึ่งอยู่ในกลุ่ม apache (apache.apache <-- ตัวแรกหมายถึงกลุ่ม ตัวหลังหมายถึง user ของระบบ ไม่ใช่ของ svn นะครับ) หลังจากนั้นเป็นคำสั่งรีสตาร์ท apache server นั่นเอง

# Compile the c binary
make autoupdate
# Change the owner to the user that owns the website
chown username:username autoupdate
# Make the binary executable
chmod +s autoupdate
# Now change some files in your personal working copy and commit them to the repository so the executable can be tested
# Then run the executable, it should update the files that have changed since the checkout and print out which changes were made
./autoupdate

วันพุธที่ 27 กุมภาพันธ์ พ.ศ. 2556

Remove shadow Keyboard in iOS


- (void)viewDidLoad
{

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(willShowKeyboard:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(didShowKeyboard:)
                                                 name:UIKeyboardDidShowNotification
                                               object:nil];

}

#pragma mark - Keybord function
- (void)willShowKeyboard:(NSNotification *)notification {
    [self performSelector:@selector(removeKeyboardShadow) withObject:nil afterDelay:0.0];
}


#pragma mark - Other Function
- (void)removeKeyboardShadow
{
    for (UIWindow *window in [UIApplication sharedApplication].windows.reverseObjectEnumerator) {
        if (![window.class isEqual:[UIWindow class]]) {
            for (UIView *view in window.subviews) {
                if (strcmp("UIPeripheralHostView", object_getClassName(view)) == 0) {
                    UIView *shadowView = view.subviews[0];
                    if ([shadowView isKindOfClass:[UIImageView class]]) {
                        shadowView.hidden = YES;
                        return;
                    }
                }
            }
        }
    }
}

Adding libxml2 in Xcode 4.3.x


Adding libxml2 is a big, fat, finicky pain in the ass. If you're going to do it do it before you get too far in building your project.
Here's how.
Target settings
Click on your target (not your project) and select "Build Phases". Click on the reveal triangle titled "Link Binary With Libraries". Click on the "+" to add a library. Scroll to the bottom of the list and select "libxml2.dylib". That adds the libxml2 library 2 your project… but wait.
Project settings
Now you have to tell your project where to look for it three more times.
Select the "Build Settings tab". Scroll down to the "Linking" section. Under your project's columns double click on the "Other Linker Flags" row. Click the "+" and add "-lxml2" to the list.
Still more.
In the same tab, scroll down to the "Search Paths" section. Under your project's column in the"Framework Search Paths" row add "/usr/lib/libxml2.dylib".
In the "Header Search Paths" AND the "User Header Search Paths" row add"$(SDKROOT)/usr/include/libxml2". In those last two cases make sure that path is entered in Debug AND Release.
Then. Under the "Product" Menu select "Clean".
Then, if I were you (and let's face it I probably am) I'd quit Xcode and walk away. When you come back and launch you should be good to go.