Play2系でplayコマンド実行時にsbtが無いと言われる場合の対処法

下記のようなエラーが発生したときは、project/build.propertiesのsbtのバージョンを確認すること。
ソースは古いplayのままでframework側のsbtが新しいかもしれない。
project/build.properties内のsbtバージョンを正しいバージョンに書き換えれば動く。

$ play run
Picked up _JAVA_OPTIONS: -Xms1024m -Xmx1024m
Getting org.scala-sbt sbt 0.11.3 ...

:: problems summary ::
:::: WARNINGS
		module not found: org.scala-sbt#sbt;0.11.3

	==== local: tried

	  /Users/Shared/play-2.1-RC3/repository/local/org.scala-sbt/sbt/0.11.3/ivys/ivy.xml

	==== Maven2 Local: tried

	  file:///Users/kurodaitsuki/.m2/repository/org/scala-sbt/sbt/0.11.3/sbt-0.11.3.pom

	==== typesafe-ivy-releases: tried

	  http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.11.3/ivys/ivy.xml

	==== Maven Central: tried

	  http://repo1.maven.org/maven2/org/scala-sbt/sbt/0.11.3/sbt-0.11.3.pom

		::::::::::::::::::::::::::::::::::::::::::::::

		::          UNRESOLVED DEPENDENCIES         ::

		::::::::::::::::::::::::::::::::::::::::::::::

		:: org.scala-sbt#sbt;0.11.3: not found

		::::::::::::::::::::::::::::::::::::::::::::::



:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-sbt#sbt;0.11.3: not found
Error during sbt execution: Error retrieving required libraries
  (see /Users/Shared/play-2.1-RC3/framework/sbt/boot/update.log for complete log)
Error: Could not retrieve sbt 0.11.3

hatena blogのデザイン変更メモ(横幅を広げる)

hatena blogデフォルトだと横幅が狭く、ソースコード等が見難いのでカスタマイズしたのでメモ。

/* <system section="theme" selected="report"> */
@import "/css/theme/report/report.css";
/* </system> */

/* <system section="background" selected="fff"> */
body{background:#fff;}
/* </system> */

pre.code{
   font-size: 70%;
   background:#EEEEEE;
   max-height: 500px;
   white-space: pre;
   overflow: auto;
}

#container {
  width: 1200px;
}

#content {
  padding-left: 70px;
}

#main {
  width: 810px;
}

Social.framework & Account.framework

社内のスマホエンジニア勉強会で発表したのでブログにしときます。

サンプルアプリはGitHubに公開しているのでどうぞ。
https://github.com/i2key/SocialframeworkExample

最初のほうは当たり前なツイートシートとかの内容なので、試してて引っかかったところのみ掲載します。
Facebookに対してAPIコールを行う(SLRequestを使う)場合、パーミッションFacebookの指定する順序で取得しないといけません。

基本的には以下の順にパーミッションをとる必要があります。
Step 1: Request basic profile information
 ex) email, user_birthday , user_location
Step 2: Request read permissions
 ex) user_about_me, read_stream
Step 3: Request publish permissions
 ex) publish_actions, publish_stream
参考:https://developers.facebook.com/docs/howtos/ios-6/

そのため、最初からemail,publish_action のような組み合わせではパーミッション取得時に以下のようなエラーがでます。

The Facebook server could not fulfill this access request: The app must ask for a basic read permission at install time.

例えば、FacebookAPIをSLRequestで叩いてウォールポストを行いたい場合。
準備として・・・
FacebookのAPP登録画面(https://developers.facebook.com/apps)にてAppIDを発行します。
・「アプリをFacebookに統合する方法を選択」にて「ネイティブiOSアプリ」のバンドルIDを入力します。
・「詳細設定」の「認証」でAppTypeを「Native/Desktop」。AppSecretinClientを「いいえ」

初めにemailのパーミッションを取得します。(上記step1)

ACAccountType *facebookType
 = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = @{
                        ACFacebookAppIdKey : @"AppID",
                        ACFacebookPermissionsKey : @[@"email"],
                        ACFacebookAudienceKey : ACFacebookAudienceOnlyMe};

[self.accountStore requestAccessToAccountsWithType:facebookType 
                                               options:options
                                            completion:^(BOOL granted, NSError *error) {
        if(granted){
            //ActionSheet表示する処理
        }
}]

次にpublish_actionsのパーミッションを取得して(上記step3)、ポストします。

ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
    
NSDictionary *options = @{ACFacebookAppIdKey : @"AppID",
                        ACFacebookPermissionsKey : @[@"publish_actions"],
                            ACFacebookAudienceKey : ACFacebookAudienceOnlyMe};
    
[accountStore requestAccessToAccountsWithType:facebookType options:options completion:^(BOOL granted, NSError *error) {
    if(granted){
        NSString *urlStr = [NSString stringWithFormat:@"https://graph.facebook.com/me/feed"];
        NSURL *url = [NSURL URLWithString:urlStr];
        NSDictionary *params = @{@"message" : @"hogehoge"};
           
        SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                                    requestMethod:SLRequestMethodPOST
                                                              URL:url parameters:params];
            
        [request setAccount:self.selectedAccount];
        [request performRequestWithHandler:^(NSData *response, NSHTTPURLResponse *urlResponse, NSError *error){
            NSLog(@"response:%@",[[NSString alloc]initWithData:response encoding:NSUTF8StringEncoding]);
        }];
    }
}];

これでエラーが出ずにFacebookAPIを利用したポストが出来ます。

また、上記のようにやってもどうしてもエラーが出る場合は、iPhone側の設定にて、アプリとFacebookの連携の許可を一旦解除して、再度アプリからaccountStoreにアクセスすると直る場合があります。

Amazon Linux にJenkins入れたときのメモ

yumにJenkinsリポジトリ登録してインストール

$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
$ sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
$ sudo yum install jenkins

cf : https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+RedHat+distributions

HOST名/jenkinsで開けるように

/etc/sysconfig/jenkins内で

JENKINS_ARGS="--prefix=/jenkins";

/etc/httpd/conf/httpd.conf内に

<Location /jenkins>
    Order allow,deny
    Allow from all
    ProxyPass   http://localhost:8080/jenkins
    ProxyPassReverse    http://localhost:8080/jenkins
</Location>

設定後 httpdリスタート

Jenkinsのユーザ設定(デフォルトだとJenkinsになるが、任意に変えたい場合)

/etc/sysconfig/jenkins

JENKINS_USER="hogeUser"  //例えばhogeUserでJenkins動かす場合

パーミッションの変更

$ chown -R hogeUser /var/lib/jenkins
$ chown -R hogeUser /var/log/jenkins
$ chown -R hogeUser /var/cache/jenkins

Jenkins strat/stop

$ sudo service jenkins start/stop/restart

TwitterAPI勉強会で発表してきました。 #twtr_hack

8月にTwitterAPI勉強会で発表したスライドを載せていなかったので、
思い出迷子にならないように載せときます。

しかしながら、既にiOS6のSocialFrameworkが出ていたり、リバースオースも申請しないでも使えるようになったりと情報鮮度は著しく悪化しているので、参考にはなりません。
あくまで、思い出記録用。

第三回Playframework勉強会で発表してきました。#play_ja

第三回Playframework勉強会で発表してきました。

当日のtoggetterはこちら

内容は、今回私が開発したソーシャル音楽アプリAttaccaでPlay2.0+Javaを選択した経緯がメインになります。
こんなアプリです。

発表資料はRECRUITの黒田として発表した部分は省いております。i2key個人として発表した部分のみにしております。ご了承ください。

UST録画はこちら。


Video streaming by Ustream
17:14 〜 43:00が私の発表になります。

最後のAction Invoker Actorsの値についてですが、やはり512はやりすぎwwwと@Masahitoさんにご指摘をうけました。まずは2倍の24x2の48にして、徐々にあげて行き、閾値をみないとねーと。仰る通りです><
今迄J2EETomcat脳だったので、スレッドプールはリクエスト毎に消費する感覚で色々やってましたが、Playでは、ノンブロッキングに役割毎にスレッドプールが待機していて、リクエストを裁く感覚(Netty + Akka)が必要だと再認識しました。
また、@ikeike443さんから頂いたご指摘のとおり、多分、中身の処理でブロッキングしちゃってると思いますので、改善できたらと思っております。

スライドにはhozumiさんの日記のnettyの基礎のみをリンクをいれましたが、Nettyの仕組みの概要を掴むために以下も参考にさせていただきました。
ありがとうございます。

Play Netty LT
View more presentations from Go Tanaka

当日は池田さんをはじめ日本Playユーザグループの皆様、及び勉強会に参加された皆様ありがとうございました。とても勉強させていただきました。
これからも精進いたします。