2011年3月25日 星期五

[Python] Install pip on Windows

1. 下載並安裝easy_install

Easy Install: http://pypi.python.org/pypi/setuptools#using-setuptools-and-easyinstall

2. 透過easy_install直接安裝pip

$ easy_install pip

3. 如果安裝不順利可以透過下載pip的壓縮檔來安裝

Pip: http://pypi.python.org/pypi/pip

4. 用cmd到pip的資料夾下, 安裝pip

python setup.py install

5. 將Python的路徑加至環境變數的PATH中 (C:\Python2x\Scripts)

成功! 之後就可以用pip install來安裝Package
$ pip install *package*

[Django] Detect Django Version - 取得Django版本

$ pip freeze | grep 'Django'

Django==1.5.1

Or

$ python

Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 3, 0, 'final', 0)

Or

python -c "import django; print(django.get_version())"

[iOS Dev] Detect App Running on Simulator or Actual Device - 判斷App執行在模擬器或是實體

對於開發時要設定不同參數很有幫助
It's helpful to set different config.

#if TARGET_IPHONE_SIMULATOR
  // It's running on the simulator 目前跑在模擬器上
#else
  // Running on Actual Device  在實機上跑
#endif

2011年3月21日 星期一

[iOS Dev] 日期轉換 Date and Timestamp converter

NSDate *now = [NSDate date];
NSTimeInterval interval = [now timeIntervalSince1970];
NSLog(@"%@", now);   // Date
NSLog(@"%f", interval);    // Date to Timesatmp
NSLog(@"%@", [NSDate dateWithTimeIntervalSince1970:interval]); // Timestamp to Date

2011年3月19日 星期六

[影片分享] TEDxTaipei - Janet Hsieh -

"You can only live once, but if you do it right, once is enough." - TEDxTaipei - Janet Hsieh -



JANET HSIEH
// TV show host

Janet Hsieh is a lifestyle expert. She is the host of all nine seasons of "Fun Taiwan" on the Discovery, Travel, & Living channel.

Hsieh enjoys traveling, cooking, dancing, exercising, kickboxing, and photo taking. She describes herself as a professional traveler and a lifelong student. Through her talks, she shares her outlook on lifestyle with others.


謝怡芬
// 旅遊節目主持人

身為連續九季的旅遊節目主持人,Janet是最佳台灣旅遊代言人。
但這只是她其中一項專業而已,活動主持、廣告代言、公益活動、寫作、音樂錄影帶甚至戲劇,都是她活躍的舞台。
喜歡旅行、攝影、跳舞、運動、烹飪、跆拳道,並且通曉五種語言的她,形容自己是一位職業的旅行家和一輩子的學生。
Janet呈現出多變的風貌,傳達出永不設限自己的理念,每個角色都是真實的她,是玩出風格和專業的最佳寫照

[JavaScript] trim() function for IE

if(typeof String.prototype.trim !== 'function') {
   String.prototype.trim = function() {
          return this.replace(/^\s+|\s+$/g, ''); 
   }
}

"We don't well support any IE browsers as that is killing all of the web engineers' time." -- GuruDigger

2011年3月16日 星期三

[Python] 將Run Python的快捷鍵新增至Komodo的Toolbox

在Toolbox新增一個Command

Command填即可
%(python) %F

可以在Key Binding裡設定你要的快捷鍵

[Linux] 使用 pwgen 產生隨機密碼 Use pwgen generate random password

$ sudo apt-get install pwgen

$ pwgen


Result:
ohp1Shei Keiwohr9 nahThe8a Gie6Fiev xie0Un0v phi0GaiL Ie2quufo angie6Qu
sahgoh6U Rubaot4o iphei1Ki tah2uChe oP9uong7 aixieJ0i Yachae6e chipa6In
Reem3ahM ohda2Cei Eib5ohno gieLa0ze uighoo6X Shoom1Ee Goope5sh Viewah1a
Jaito1oo chua9kiD du4eiP3y yohlie4T oc8oPhez Fu1quo0x bei1eaGh thahqu3K
Zeila2ai Aosho2ag fie5aiV8 ooKejiv0 Ieb2kait eeg3Xoh0 quaete7E Shoo5eix
iej2Iehe kee1Ohyu jeuDae9z eeShoh8j Ieth8Hai Queinai8 Zuce3ahb Oqu7ohd6
Thohtei0 aeT0ieth zur6teoZ doh0Oon2 Kooj1Lee uiDoh3jo ohHaiw1r uhet0eiX
Jolei3do to8Thohh Lohmook0 fohH3jei pah1uRae HioTie4e jequ0Iet AhM5ieSo
Voo3uTah Woo4eith Kai1aeth oazu1oT3 Toovah2e Aiz1uing yeiph8Ze Ayoo0po3
Gohqu3zu yohXesh4 pooXai7j zoo6de7E jicoo2oF uo5iez0U ieS7eeYe peFah4ph
eihuoTh7 kooPh4ei Fat6aong re6Axai7 gieNg2ae omaeHee3 Shai3xep yin5aaJu
Zuy3aaho ci3aiH1o aefo5aeW Sei3Phuu cu2wuaZu uu5ReeCo ohNgav5g OhLe9pha
aPei4Iep Xae3Gefu fu8Wixae eox2Duuk Isahcie6 eegai7Mu Reibohj6 noh7AhL4
ea5Thae1 vongoh3W Eey7Uz9h ael4ooBu Lai2iuj2 iaSheap3 Alae8ao3 ee1Aetha
reilaX8O Eenohj2y shee7Or9 uGh4eino Ohyot0mo iShuad9t kei0Eeko iequie8E
nooN2kia ahn5kooH eizaa2Pi Aeth1aof Xalo3ohS Aoquuv2L Aij3pho0 Dah7ooF4
ohwa5ohY daf7JauT Ieko6bih Oox7ieko lain8Eil xe7Af8ei biepooX0 ju8Ied8A
zagol7Qu EeM2etio eeW3ahno Chae5pho Nid0ceiz vie5Goo5 eW3ahbei Eik4thao
Aer9Dini oos8Eeho fi4aBi2R aid2Chei Oob1Eipu iiJie1sh xeiDoo4o Amuu8bah
sheiP9oh AeguGae9 iChee2oh Gah2yahy ZaiPh9Ah Pek0hahj BieM4ahs ooS6chah

2011年3月11日 星期五

[Ubuntu] Install Apache, PHP, MySQL, FTP 安裝指令速記

$ apt-get install apache2
$ apache2 -v
$ a2emod
$ /etc/init.d/apache2 restart

$ apt-get install php5
$ php -v

$ apt-get install mysql-server
$ mysql -u root -p
Enter Password:
mysql> select version();

$ apt-get install php5-mysql
$ vim /var/www/phpinfo.php

$ apt-get install phpmyadmin

$ apt-get install vsftpd

Mount /var/www
$ groupadd webadmin
$ useradd -mG webadmin --shell /bin/bash newUser
$ passwd newUser

$ chgrp -R webadmin /var/www/website
$ chmod 775 /var/www/website
$ chmod -R g+s /var/www/website
$ mount --bind /var/www /home/newUser/www


See Also
[CentOS] vsftpd 安裝與管理
vsftpd 設定啟動

2011年3月9日 星期三

[iOS Dev] Filter FetchedResultsController with NSPredicate

NSPredicate *predicate = [NSPredicate predicateWithFormat:
[NSString stringWithFormat:@"(firstName like '%@')", @"Hank"]];

NSArray *items = [fetchedResultsController.fetchedObjects filteredArrayUsingPredicate:predicate];
 
 for (NSManagedObject *o in items) {
  NSLog(@"%@", o);
 }

[iOS Dev] NSDate, NSString conversion and get TimeZone

2011年3月7日 星期一

[iOS Dev] UITableView indentationLevel 縮排


- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath {
 NSUInteger row = [indexPath row];
 return row;
}
Related Posts Plugin for WordPress, Blogger...