How to cancel a text field edit in a UIWebView

一番簡単なやり方:

[webView stringByEvaluatingJavaScriptFromString:@"document.activeElement.blur();"];

実はjsを利用した

/usr/bin/codesign failed with exit code 1 エラーの原因の一つ

詳細情報に ……/myApp.app: object file format invalid or unsuitable がある場合は、たぶんXcode4.1 のバグだ。codesign_allocateをインストールしなかった。

直す方法はこち

sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin

 

TXT2EPUB

先週リリースた。無料ですから、毎日のダウンロード量は2万ぐらい、びっくりした。

でも、このバージョンにバグがある。修正してる。

説明書
http://dreamo.jp/txt2epub_jp.html

 

APP Store
http://itunes.apple.com/app/txt-to-epub/id506665032?mt=8

Trim all leading whitespace from NSString

@interface NSString (trimLeadingWhitespace)

-(NSString*)stringByTrimmingLeadingWhitespace;

@end

 

@implementation NSString (trimLeadingWhitespace)

-(NSString*)stringByTrimmingLeadingWhitespace {

NSInteger i = 0;

 

while ((i < [self length])

&& [[NSCharacterSet whitespaceCharacterSet] characterIsMember:[self characterAtIndex:i]]) {

i++;

}

return [self substringFromIndex:i];

}

@end

UIImagePickerControllerでビデオしか選択できない

-(IBAction)loadVideo{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *imagePickerController=[[UIImagePickerController alloc] init];
imagePickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.mediaTypes = [[[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil] autorelease];;
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
}
}

サーバ自動管理

午後自動管理システム成功に導入した。

いまは4台のサーバ連動してる。

 

Shellタイマー crontab

1 Command

/sbin/service crond start
/sbin/service crond stop
/sbin/service crond restart
/sbin/service crond reload
/sbin/service crond status

2 Auto Start
/etc/rc.d/rc.local

/sbin/service crond start
を追加する

3 追加
vi /etc/crontab

*  *  *  *  *  command
分  時  日  月  週  命令

 

Shell + PHP + MySQL

#!/usr/bin/php

<?php
$db = mysql_connect("localhost", "vpsee", "password");
mysql_select_db("test");
$result = mysql_query("SELECT * FROM test_mark");
while ($row = mysql_fetch_array($result)) {
        print "$row[0] $row[1] $row[2] $row[3]\n";
}?>

php 5.1.6 + JSON

CentOS 5.3 では php 5.1.6 がインストールされる。JSONが最初から使えるのはphp 5.2 から。

以下、手順

pecl コマンドを使いたいので、次のもので足りないものがあったらインストールしておく。
pear は普段使わないけど、pecl コマンドを使うため。

# yum install php-devel php-pear libtool gcc-c++

引き続き pecl で json インストール

# pecl install json

設定追加

# vi /etc/php.d/json.ini
extension=json.so

httpd再起動

# /etc/init.d/httpd restart

QBottle複数のサーバ導入

今日複数のサーバの導入ができました。

MySQLに外部ホストから接続できるように設定する方法はここです。

1。ログイン

[root@centos ~]#  mysql -u root -p   ※MySQLにrootでログイン
Enter password:    ※パスワード応答

2。ユーザーの確認

mysql> select user,host from mysql.user; ※ユーザーの確認
+-------+-----------------+
| user  | host            |
+-------+-----------------+
| root  | 127.0.0.1       |
| root  | localhost       |
| qb    | localhost       |
+-------+-----------------+

3。データベースの一覧を確認

mysql> show databases;   ※存在するデータベースの一覧を確認
+--------------------+
| Database           |
+--------------------+
| information_schema |
| client_data        |
| mysql              |
| test               |
+--------------------+
mysql> grant all privileges on client_data.* to qb@"example.com"
    -> identified by 'パスワード' with grant option;

外部ホストからのログイン

[root@centos ~]#  mysql -h linuxserver.jp -u user1 -p