楽しいgitのインストール

//楽しいgitのインストールのはじまりはじまり。
# vi /etc/yum.repos.d/rpmforge.repo
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

//python-hashlibいれる
# rpm -ivh python-hashlib-20081119-2.i386.rpm
Preparing... ########################################### [100%]
1:python-hashlib ########################################### [100%]
# rpm -qa | grep hashlib
python-hashlib-20081119-2

//yumアップデート
# yum update
(略)

//gitインストール
# yum install git --enablerepo=rpmforge
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* rpmforge: mirror.fairway.ne.jp
* updates: ftp.nara.wide.ad.jp
rpmforge | 1.9 kB 00:00
rpmforge/primary_db | 6.8 MB 00:08
Setting up Install Process
Resolving Dependencies

    • > Running transaction check
      • > Package git.x86_64 0:1.7.10.1-1.el5.rf set to be updated
    • > Processing Dependency: perl-Git = 1.7.10.1-1.el5.rf for package: git
    • > Processing Dependency: perl(Git) for package: git
    • > Running transaction check
      • > Package perl-Git.x86_64 0:1.7.10.1-1.el5.rf set to be updated
    • > Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
git x86_64 1.7.10.1-1.el5.rf rpmforge 8.0 M
Installing for dependencies:
perl-Git x86_64 1.7.10.1-1.el5.rf rpmforge 28 k

Transaction Summary
================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)

Total download size: 8.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): perl-Git-1.7.10.1-1.el5.rf.x86_64.rpm | 28 kB 00:00
(2/2): git-1.7.10.1-1.el5.rf.x86_64.rpm | 8.0 MB 00:10

                                                                                                                                                              • -

Total 755 kB/s | 8.0 MB 00:10
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6


GPG key retrieval failed: [Errno 5] OSError: [Errno 2] No such file or directory: '/etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag'

//キーがないと怒られたので追加
# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

Resolving dag.wieers.com... 62.213.193.149
Connecting to dag.wieers.com|62.213.193.149|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://apt.sw.be/RPM-GPG-KEY.dag.txt [following]

Resolving apt.sw.be... 193.1.193.67
Connecting to apt.sw.be|193.1.193.67|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1672 (1.6K) [text/plain]
Saving to: `RPM-GPG-KEY.dag.txt'

100%[======================================>] 1,672 --.-K/s in 0s

2012-06-03 10:31:48 (145 MB/s) - `RPM-GPG-KEY.dag.txt' sa

//キーのインストール
# rpm --import RPM-GPG-KEY.dag.txt

//リトライ
# yum install git --enablerepo=rpmforgeLoaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* rpmforge: mirror.fairway.ne.jp
* updates: ftp.nara.wide.ad.jp
Setting up Install Process
Resolving Dependencies

    • > Running transaction check
      • > Package git.x86_64 0:1.7.10.1-1.el5.rf set to be updated
    • > Processing Dependency: perl-Git = 1.7.10.1-1.el5.rf for package: git
    • > Processing Dependency: perl(Git) for package: git
    • > Running transaction check
      • > Package perl-Git.x86_64 0:1.7.10.1-1.el5.rf set to be updated
    • > Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
git x86_64 1.7.10.1-1.el5.rf rpmforge 8.0 M
Installing for dependencies:
perl-Git x86_64 1.7.10.1-1.el5.rf rpmforge 28 k

Transaction Summary
================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)

Total size: 8.0 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : git 1/2
Installing : perl-Git 2/2

Installed:
git.x86_64 0:1.7.10.1-1.el5.rf

Dependency Installed:
perl-Git.x86_64 0:1.7.10.1-1.el5.rf

Complete!

//バージョン確認
# git --version
git version 1.7.10.1

//OK!

ここいらへんを参考に

http://d.hatena.ne.jp/mrgoofy33/20110206/1296952248
http://d.hatena.ne.jp/kazuokohchi/20120208

apacheにrailsを連携

昨日に引き続き、ApacheRailsを連携させる。

apacherailsを設定
# gem install passenger
# export PATH=/usr/local/apache2/bin:$PATH
# passenger-install-apache2-module

パスを通しておかないと、モジュールをインストールしようとしても
apacheが見つからないよorソースからインストールしたapacheじゃないほうを参照されるので注意。
※このエントリの環境では、apacheはソースからインストールしてます。

以下が成功したときのコメントだけど、
なんだかすごく丁寧な解説でほっこりしたw


The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.12
PassengerRuby /usr/local/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:


ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /somewhere/public

# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

はじめてEC2にrails環境をつくってみたメモ

・前準備
# yum -y install gcc
# yum -y install make
# yum -y install gcc-c++
# yum -y install openssl-devel
# yum -y install curl-devel
# gem update --system

・apache2インストール
# yum install openssl-devel
# wget http://ftp.riken.jp/net/apache//httpd/httpd-2.2.22.tar.gz
# tar zxvf httpd-2.2.22.tar.gz
# ./configure --enable-so --enable-ssl --enable-module=rewrite --enable-mods-shared=all
# yum -y install make
# make
# make install

rubyの前にyamlインストール
# wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
# tar -zxvf yaml-0.1.4.tar.gz
# cd yaml-0.1.4
# ./configure
# make;make install


rubyインストール
# wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
# tar zxvf ruby-1.9.3-p125.tar.gz
# cd ruby-1.9.3-p125
# ./configure
# make
# make install

# cd ~/
# vi .bash_profile
PATHに/usr/local/bin/rubyを追加

# ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]


・RubyGems1.3.7インストール
# wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz


# tar zxvf rubygems-1.8.24.tgz
# cd rubygems-1.8.24
# ruby setup.rb

・Rails3.3.2インストール
# gem install rails --no-ri --no-rdoc
# rails -v
Rails 3.2.3

mysqlインストール
# yum -y install mysql-devel
# gem install --remote mysql

sqliteインストール
# wget http://www.sqlite.org/sqlite-amalgamation-3.7.3.tar.gz
# tar xvzf sqlite-amalgamation-3.7.3.tar.gz
# cd sqlite-3.7.3/
# ./configure
# make
# make install


yamlをインストールしていない場合、yamlを入れてrubyを再インストール

# cd ruby-1.9.3-p0
# make clean
# ./configure
# make
# make install

※Gemfileに以下を追記
gem 'execjs'
gem 'therubyracer'


※DBをmysqlにする場合、Gemfileを
gem 'myysql'
に変更


FILE: $RAILS_ROOT/Gemfile



OK!

はじめてcentosにrails環境をつくってみた

環境は、さくらVPS CentOS5.5

rubyインストール
# wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
# tar zxvf ruby-1.9.3-p125.tar.gz
# cd ruby-1.9.3-p125
# sudo ./configure
# sudo make
# sudo make install
# cd ~/

# vi .bash_profile
PATHに/usr/local/bin/rubyを追加

# ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]


・RubyGems1.3.7インストール
# wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz


# tar zxvf rubygems-1.8.24.tgz
# cd rubygems-1.8.24
# ruby setup.rb

・Rails2.3.8インストール
# gem install rails --no-ri --no-rdoc
# rails -v
Rails 3.2.3

mysqlインストール
# yum -y install mysql-devel
# gem install --remote mysql

上部バーではなくビュー内部にインジケータを出す方法

ex.h
@interface ForthViewController : UIViewController
{
UIView* loadingView; // 処理中インジケータ画面
UIActivityIndicatorView* indicator; // 処理中インジケータ
}
@property (nonatomic, retain) UIView *loadingView;
@property (nonatomic, retain) UIActivityIndicatorView *indicator;
@end


ex.m

,,,,,,,

  • (void)webViewDidStartLoad:(UIWebView *)webView{

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
loadingView = [[UIView alloc] initWithFrame:[[self view] bounds]];
[loadingView setBackgroundColor:[UIColor blackColor]];
[loadingView setAlpha:0.5];
indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[[self view] addSubview:loadingView];
[loadingView addSubview:indicator];
[indicator setFrame:CGRectMake ((320/2)-20, (480/2)-60, 40, 40)];
[indicator startAnimating];

}

  • (void)webViewDidFinishLoad:(UIWebView *)webView{

  [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[indicator stopAnimating];
[loadingView removeFromSuperview];
}
,,,,,,,,,,,,,,


ちなみに、バー上部にも表示されます
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
loadingView = [[UIView alloc] initWithFrame:[[self view] bounds]];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

オブジェクトのサイズを取得して位置を指定する

サンプル

  • (CGRect)rect {

CGSize s = [yellow_red contentSize];
return CGRectMake(-100, -60, s.width, s.height);
}

CGRectMake(x, y, w, h);

x,yは画面中央からの座標みたい。
フレームワークの問題なのかしら・・・。
ここの制御は噛んでいないと思う・・・ので
アップデートされたのかな。

ちなみにcocos2dで開発してます。


※参考
http://ameblo.jp/navijet/entry-10823795393.html

cocos2dフレームワークで新規クラス作成の際にデフォルトで修正する箇所メモ

環境:MacOS10.7(Lion) xcode4.2 ios5.0

まず新規クラスを作成。
名前は適当にGameScene とか。


AppDelegate.m を修正

#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];

これはデバイスの向き(縦横)を指定するメソッド呼び出し。


Helloでソートするともう一点でてくるのでそちらも。

[[CCDirector sharedDirector] runWithScene: [GameScene scene]];



GameConfig.m を修正

#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationNone

これはiphoneシミュレータを起動する際に
kGameAutorotationNone(デバイスの向きを指定するメソッド)を
指定するもの。

ほかにもいくつか制御の方法はあるみたい。

最後に
HelloWorldLayer.h
HelloWorldLayer.m
を削除。


と、とても親切にこれらを説明しているサイトを見つけたので
初心者の方はこちらを見たほうが良いかも。
http://applebite.me/archives/91