cocos2dフレームワークのインストール

環境:MacOS10.7(Lion) xcode4.1

http://www.cocos2d-iphone.org/download

からStable versionをダウンロード

今回はDownload: cocos2d-iphone-1.0.1.tar.gz

ターミナルを起動し、ダウンロードしたファイルのパスへ移動。

$ cd /Users/tsukaharam/Downloads/cocos2d-iphone-1.0.1

インストール
$ sudo ./install-templates.sh

nstalling Xcode 4 cocos2d iOS template

                                                                                                      • -

...creating destination directory: /Users/tsukaharam/Library/Developer/Xcode/Templates/cocos2d/
...copying cocos2d files
...copying cocoslive files
...copying TouchJSON files
...copying CocosDenshion files
...copying CocosDenshionExtras files
...copying FontLabel files
...copying template files
done!



Installing Xcode 4 Chipmunk iOS template

                                                                                                      • -

...copying Chipmunk files
done!



Installing Xcode 4 Box2d iOS template

                                                                                                      • -

...copying Box2d files
done!



Installing Xcode 4 CCNode file templates...

                                                                                                      • -

...creating destination directory: /Users/tsukaharam/Library/Developer/Xcode/Templates/File Templates/cocos2d/
done!
...creating cocos2d template directory




Installing Xcode 3 cocos2d iOS template

                                                                                                      • -

...creating destination directory: /Library/Application Support/Developer/Shared/Xcode/Project Templates/cocos2d 1.0.1/cocos2d Application/
...copying template files
...copying cocos2d files
...copying cocos2d dependency files
...copying CocosDenshion files
...copying cocoslive files
...copying cocoslive dependency files
done!



Installing Xcode 3 cocos2d iOS + box2d template

                                                                                                      • -

...creating destination directory: /Library/Application Support/Developer/Shared/Xcode/Project Templates/cocos2d 1.0.1/cocos2d Box2d Application/
...copying template files
...copying cocos2d files
...copying cocos2d dependency files
...copying CocosDenshion files
...copying cocoslive files
...copying cocoslive dependency files
...copying Box2D files
done!



Installing Xcode 3 cocos2d iOS + chipmunk template

                                                                                                      • -

...creating destination directory: /Library/Application Support/Developer/Shared/Xcode/Project Templates/cocos2d 1.0.1/cocos2d Chipmunk Application/
...copying template files
...copying cocos2d files
...copying cocos2d dependency files
...copying CocosDenshion files
...copying cocoslive files
...copying cocoslive dependency files
...copying Chipmunk files
done!



Installing Xcode 3 cocos2d Mac template

                                                                                                      • -

...creating destination directory: /Library/Application Support/Developer/Shared/Xcode/Project Templates/cocos2d 1.0.1/cocos2d Application - Mac/
...copying template files
...copying cocos2d files
...copying CocosDenshion files
done!
...copying file templates
...creating destination directory: /Library/Application Support/Developer/Shared/Xcode/File Templates/cocos2d 1.0.1/



Installing Xcode 3 CCNode file templates...

                                                                                                      • -

done!


たったこれだけ。簡単!

python-twitterにトライしてみる

・simplejsonインストール
# wget http://pypi.python.org/packages/source/s/simplejson/simplejson-2.2.1.tar.gz#md5=070c6467462bd63306f1756b01df6d70
# tar simplejson-2.2.1.tar.gz
# cd simplejson-2.2.1
# python setup.py install

・httplib2インストール
# wget http://httplib2.googlecode.com/files/httplib2-0.7.1.tar.gz
# tar zxvf httplib2-0.7.1.tar.gz
# cd httplib2-0.7.1
# python setup.py install

python-oauth2インストール
# wget https://github.com/simplegeo/python-oauth2/tarball/master

しかしここでgithub.comからのダウンロードにはオプションを付けろと怒られる
To connect to github.com insecurely, use `--no-check-certificate'.
Unable to establish SSL connection.

# wget --no-check-certificate https://github.com/simplegeo/python-oauth2/tarball/master

今度は成功

# cd master
# mv master master.tar.gz
# tar zxvf master.tar.gz
# cd simplegeo-python-oauth2-1fcc1a6/
# python setup.py install

今度はsetuptoolsモジュールが無いと怒られる
Traceback (most recent call last):
File "setup.py", line 2, in ?
from setuptools import setup, find_packages
ImportError: No module named setuptools


デフォルトのpython2.4で実行してたので落とす
# wget http://peak.telecommunity.com/dist/ez_setup.py
# python ez_setup.py


再度実行
# cd /usr/local/src/simplegeo-python-oauth2-1fcc1a6
# python setup.py install

今度はうまくいった

# cd /usr/local/src
# wget http://python-twitter.googlecode.com/files/python-twitter-0.8.2.tar.gz
# tar zxvf python-twitter-0.8.2.tar.gz
# cd python-twitter-0.8.2
# python setup.py install


あとはテストスクリプトをつくって動けばインストール成功


※参考
http://www.yukun.info/blog/2011/03/python-twitter-install.html

pythonクローラを入れるサーバの環境構築

MySQLのインストール
先にもろもろパッケージを。
# yum -y install cmake
# yum -y install gcc
# yum -y install gcc-c++
# yum -y install ncurses-devel


ユーザ追加
# groupadd mysql
# useradd -g mysql mysql


MySQLインストール
# cd /usr/local/src/mysql
# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.16.tar.gz/from/ftp://ftp.iij.ad.jp/pub/db/mysql/
# cd mysql-5.5.16

# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

# cd mysql-5.5.13
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
# make
# make install

cp my-huge.cnf /etc/my.cnf

my-small.cnf :64MB以下のメモリを搭載したPC

my-medium.cnf :128MB以下のメモリを搭載したPC

my-large.cnf :512MB以下のメモリを搭載したPC

my-huge.cnf :1GB〜2GB以下のメモリを搭載したPC

my-innodb-heavy-4G.cnf :4GBのメモリとInnoDBで作成されたデータベースに
よって構築されたPC


初期化
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --skip-name-resolv --collation-server=utf8_general_ci
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h www38146u.sakura.ne.jp password 'new-password'

Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!




起動
/usr/local/mysql/support-files/mysql.server start

しかしここでエラー

ログを見てみるとこんなかんじ
[ERROR] COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8'
[ERROR] Aborting

/etc/my.cnfの[mysqld]に以下を追加
collation-server = utf8_general_ci

再起動して、今度は成功。





|python2.7のインストール

# wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
# tar jxvf Python-2.7.2.tar.bz2
# cd Python-2.7.2
# ./configure --prefix=/usr/local/python

あとあとクローラを入れて実行する際に
zlibが見つからないと怒られたのでオプションで追加。
# ./configure --prefix=/usr/local/python --with-zlib




# make
# make install

#vi ルートのホームディレクトリ/.bash_profile
alias python='/usr/local/python/bin/python'
を追記。

反映
# source /root/.bashrc





apacheのインストール

# wget http://ftp.jaist.ac.jp/pub/apache//httpd/httpd-2.2.21.tar.gz
# tar zxvf httpd-2.2.21.tar.gz

# ./configure --prefix=/usr/local/apache2 --enable-ssl=shared --enable-rewrite=shared --enable-proxy=shared --enable-proxy-ajp=shared --enable-so

# make
# make install


# cp /usr/local/src/apache/httpd-2.2.21/build/rpm/httpd.init /etc/init.d/httpd

# vi /etc/init.d/httpd

                                                                                        • -

pidfile=${PIDFILE-/usr/local/apache2/logs/${prog}.pid}

httpd=/usr/local/apache2/bin/httpd

CONFFILE=/usr/local/apache2/conf/httpd.conf

                                                                                        • -

# chkconfig --add httpd
# chkconfig --level 2345 httpd on

とりあえず今日はここまで。



参考
http://d.hatena.ne.jp/morningmist7/20080303/1204528839
http://wiki.minaco.net/index.php?Python%2F%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%2FLinux%2FPython

インジケータ表示の方法

APIとかネットワーク負荷がかかるような処理がバックグラウンドで起きている場合に
UIActivityIndicatorViewを用いてインジケータを表示する方法


UIActivityIndicatorView *indView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indView.frame = CGRectMake(0, 0, 32, 32);
indView.center = CGPointMake(160, 240);
indView.hidesWhenStopped = YES;
[self.view addSubview:indView];

[indView startAnimating];
[[NSRunLoop currentRunLoop]runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.0]];
[indView stopAnimating];
[indView removeFromSuperview];
[indView release];

自分が情報収集のためにしていること

最近は以前ほど情報収集に時間を使っていないにもかかわらず、
未だに◯◯さんって情報が早いですねーって多々頂きます。

個人的には、どうやら速読?というか、
そのへんのスキルが上昇したのかなと思ったので
かるく整理してみました。



|情報源はどこか


ここは別に特別ってことはなく、

RSS(はてブとかソーシャルブックマーク)
twitter
Facebook

がメインです。誰でもこんな感じだと思います。


CNETとかITmediaとか、昔は一応そのへんもRSSで見てたけど、
明らかに目標本数稼ぎのためのうん◯記事を目に入れるのは正直非効率的なわけです。
(一次情報の方々ゴメンナサイ。有り難さは感じています。)

そういう意味では、ソーシャルフィルタリングされたブックマーク系のほうが
効率的だ、とも言えます。


しかし、それでは自分が拾わないといけない記事を見逃してしまう可能性もあります。

また、はてブの衆愚化みたいなエントリも以前ちらほらあったように、
ゴミ記事がブクマされることも多いので、
それも非効率な要因として成り得るわけです。


ともかく、現状はブクマ系で、twitterなりfacebookで補完、
がベターな情報収集手法だと思っています(ベストはまだ他にあると思ってます)。




|記事の開きかた


まず、RSSリーダーに出てきた時点で、
タイトルだけをざーっと読んでいきます。

少しでも気になったら、ブランクで開いておいて、
とりあえず10本くらいになるまでタイトルを流していきます。

これは、ページを開いてから読み込みが完了するまでの時間を節約するためです。
いちいち、タイトル見て1ページ開いてとかやってたら、
読み込むまでの数秒間を毎回ロスします。


「お前、気が短すぎじゃね?」

という声が飛んできそうですが、こういう積み重ねが効率化への第一歩、だと信じています。




|記事の読み方


サイト全体を眺めるように読みます。
一文一文を読むことはないです。


タイトル→リード文→本文と読んでいくのがデフォだと思いますが、
リード文てのは、ニュースなのか企画読み物なのか、あるいは記者にもよりますけど
記事に興味を持ってもらうための文章として書いていることがあるので、
結論だけ知りたいこちらとしてはかえって時間の無駄なのです。

もちろん、結論から書いている記事もあるので、
サイト全体をぶわーっと見渡す感じで、まず”把握する”のです。

5秒くらいで、このページは何を言わんとしているのかをなんとなく掴んだところで、
じっくり読むか読まないかをジャッジします。


そうすれば、無駄な記事をわざわざ読む数が減るので、
効率的に時間を使える、ということになります。




|記事の共有

気になった記事は誰かと共有するようにしています。

その方法は、ソーシャルメディアであったり、友人・知人・同僚・上司、
誰でも良いので、知見が得られると思った相手に対して共有します。


重要なのは、その記事が、将来的にどういった結果を生み出すか、です。


積極的に共有して、意見交換しましょう。

たぶんここがキモかなーって思うんですよね。

私はむしろ、こいつを見てくれ…こいつをどう思う?
とか、色々聞かれる方が好きなタイプです///




以上、少しでもご参考になれば。


 

mod_wsgiで軽くはまったこと

mod_wsgiインストール後に
wsgiファイルとアプリの設定で

                                                                                                                        • -

import os
import sys

sys.path.append('/home/Django')

os.environ['DJANGO_SETTINGS_MODULE'] = 'myApp.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

                                                                                                                        • -

sys.path.append('/home/Django')
設定ファイル全部にここでパスを通しておかないとImportErrorを吐く。

例えば、Djangoの下層にディレクトリがあった場合、
sys.path.append('/home/Django')
sys.path.append('/home/Django/test')
のように記述。