2012年4月18日水曜日

組込み Tomcat と Jetty : Embedded in java

TomcatとJettyの組込みです バージョンは下記です
  • Tomcat 7.0.26
  • Jetty 8.1.12

Tomcat 参考サイト

embedding-tomcat

コマンド

起動は下の感じで、止めるのは Ctrl-C でお願いします
# tomcat
$ java -cp srv.jar:lib/* web.server.WebServer

# jetty
$ java -cp srv.jar:lib/* web.server.WebServer -jetty

# set port
$ java -cp srv.jar:lib/* web.server.WebServer server.port 8123

他のパラメータはソースを見てください
動かした感じ, jetty の後 tomcat 動かしてます










ソース

2012年4月11日水曜日

タネマキは使える

週末にフラッとタネマキに行ってきました。

混む時もあるそうですが、おおよそ使えるのでは無いでしょうか?

ここです!!タネマキ

2012年3月27日火曜日

CAEmitterCell のパクリネタ

ネタが無いので、パクリました。_( TxT)_

Emitting (発光 by Google 翻訳先生) のパクリネタ

本家を読んでくださいね。

パクリ元

UIKit Particle System in iOS 5 Tutorial

参考という名目のパクリ元

CAEmitterLayer and CAEmitterCellアップるぅぅぅの記事ですよね

その他ぽいの


プロパティの説明

CAEmitterCell
birthRate毎秒どれくらいオブジェクトを作るか
lifetimeセルのライフタイム
colortint 色合いを設定
contentsCGImageRef を設定


Layer は emitterShape と emitterPosition を設定するくらいでしょうか

CAEmitterLayer
emitterShapeオブジェクトの作成方法を設定

動かすとこんな感じ


使った適当な画像はこれです


ソース

ファイルのコメント的にはコピペはOKそうだったのですが。
問題ありましたらご指摘ください

2012年1月25日水曜日

続 NSURLConnectionDelegateで証明書(ry..方法

前回の記事が適当すぎたので、少ししっかり調べたーー

参考になると幸いです

結論

SSL周りのリリースノート、仕様書とかきちんとでてますか?

知っている方いたら教えてください

環境

  • iOS 5.0
  • tomcat 7.0.23 / 6.0.32
  • xcode 4.2.1

適当にする方法(改め)

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
  NSURLProtectionSpace * protectionSpace = [challenge protectionSpace];
  NSURLCredential* credentail = [NSURLCredential credentialForTrust:[protectionSpace serverTrust]];
  [[challenge sender] useCredential:credentail forAuthenticationChallenge:challenge];
}

ハマった事

結論

RSAはOKでDSAはNG

ハマっている世界

iOS 5.0 は 証明書に MD5 を非サポートになったので、

keytool のデフォルト動作だと MD5withRSA なので

自己証明のSSL通信が軒並み エラーになると思っていた

SHA1withRSA とかkeystoreを作り直すと上のコード動いたと勘違いした。

安心したので,MD5の証明書でもやってみたら案の定動作したので、アレ?と思い

DSA で作成したら軒並みエラーなった。

--- 以上 ----

エラーの違い

xcode: Console

SHA1withRAS, MD5withRAS

SHA1withDAS

iPad : Safari : RSA

iPad : Safari : DSA

証明書一部

2012年1月23日月曜日

NSURLConnectionDelegateで証明書周りを適当にする方法

自己証明書だと、通信に失敗するでの軒並みOKにするには下のコードで行ける!!

おすすめはしない!!

※ コマンドラインでしか試してません ※


- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
  return YES;
}

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection {
  return YES;
}

- (void) connection:(NSURLConnection *)conn didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
  NSURLProtectionSpace * protectionSpace = [challenge protectionSpace];
  NSURLCredential* credentail = [NSURLCredential credentialForTrust:[protectionSpace serverTrust]];
  [[challenge sender] useCredential:credentail forAuthenticationChallenge:challenge];
}

リンク

参考またはこうすべきサイト

サンプルコード

2011年12月6日火曜日

USB Vender ID

USBのベンダーIDの取得方法

MAC

$ system_profiler SPUSBDataType
USB:

    USB High-Speed Bus:

      Host Controller Location: Built-in USB
      Host Controller Driver: AppleUSBEHCI
      PCI Device ID: 0x3b3c 
      PCI Revision ID: 0x0006 
      PCI Vendor ID: 0x8086 
      Bus Number: 0xfa 

        Hub:

          Product ID: 0x2514
          Vendor ID: 0x0424  (SMSC)
                       ^^^^ <- vender id

Linux

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
                       ^^^^ <- vender id

実行結果

参考

lsusb on OS X

2011年11月28日月曜日

ARC をソースで!?

前置き

iOSというかllvmでコンパイルするときのARCをソースで管理するときの話です。 この方法はMacでしかできないと思います。

結論

追記1(後で別に書くかも・・・)

[Target] -> [Build Phase] -> [Compile Sources] にてコンパイラフラグを個別に指定してできる。(参考元)

追記2 個人的には混在は嫌いなので、共有ものはライブラリにする方向でその中はARCのON/OFFに依存して統一して書いたのがよいと思う。

ソースで管理するなら、ライブラリを作成してそれを使用するのがいいと思いました。

判断方法

この方法が正攻法かは不明... orz
#if __has_feature(objc_arc)

一応ARCの設定方法

XCode 4.2 の SingleViewApp のとき対応方法

ARC の ON/OFF 対応ようヘッダーファイルを ARCHandle.h を作成

#if __has_feature(objc_arc)
#define AUTORELEASE(A) A
#define ARC_ON
#else
#define AUTORELEASE(A) [A autorelease]
#define ARC_OFF
#endif

AppDelegate.m を変更


// ARC ON の時は基本的に dealloc 書かないので丸ごと削除
#ifdef ARC_OFF
- (void)dealloc
{
    [_window release];
    [_viewController release];
    [super dealloc];
}
#endif


//
// マクロで autorelease を隠蔽したりしなかったり
//
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.window = AUTORELEASE([[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] );
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
   self.viewController = AUTORELEASE([[GVViewController alloc] initWithNibName:@"GVViewController_iPhone" bundle:nil]);
    } else {
   self.viewController = AUTORELEASE([[GVViewController alloc] initWithNibName:@"GVViewController_iPad" bundle:nil]);
    }
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

ViewController.m を変更

UILabel に ARC ON/OFFでラベルの内容をかえてます


#if __has_feature(objc_arc)
#define HELLO  @"Hello ARC"
#else
#define HELLO  @"Hello ..."
#endif

ARC ON
ARC OFF