scoketエラー等
config確認
mysql_config
which mysql.server /Applications/MAMP/Library/support-files/mysql.server
which mysqld_safe /Applications/MAMP/Library/bin/mysqld_safe
エラーログ
/Applications/MAMP/db/mysql56/**.err
hello world
phpとjsとhtmlでhello worldしてみた。
<?php //print_r($argv); function html($content) { return "<!DOCTYPE html>\n".wrap("html", $content); } function wrap($title,$content, $options=null) { if ($options == null) { return "<$title>\n"." ".$content."</$title>\n"; } else { $res = ""; foreach($options as $key => $value) { $op = "$key"."="."$value"; $res = $res.$op; } return "<$title $res>\n"." ".$content."</$title>\n"; } } function head($content) { return wrap("head", $content); } function body($content) { return wrap("body", $content); } function script($content) { return wrap("script", $content, array("type" => "text/javascript")); } function p($content) { return wrap("p", $content); } // -------------------------------------------- $head = head(" <title>title</title> <meta charset='utf-8' /> <style type='text/css'> p { color: yellow; background-color: black; } </style> "); $script = script(" document.writeln('<p> Hello rorld</p>'); "); $body = body(p("Hello World").$script); $result = html($head.$body); echo $result; ?>
実行すると以下が表示される。
<!DOCTYPE html> <html> <head> <title>title</title> <meta charset='utf-8' /> <style type='text/css'> p { color: yellow; background-color: black; } </style> </head> <body> <p> Hello World</p> <script type=text/javascript> document.writeln('<p> Hello rorld</p>'); </script> </body> </html>
継続モナドその2
APIをFutureで返す。bindはとりあえず省略。
@interface Future<V> : NSObject - (void)get:(void(^)(V))cb; @end @interface API<I,O> : NSObject - (Future<O> *)getAPI:(I)input; @end typedef void(^CallBack)(id); typedef void(^CPS)(CallBack); @interface Future() @property (nonatomic) CPS cps; @end @implementation Future - (instancetype)init:(CPS)cps { self = [super init]; if (self) { self.cps = cps; } return self; } - (void)get:(void (^)(id))cb { self.cps(cb); self.cps = nil; } @end @implementation API - (Future *)getAPI:(id)input { CPS cps = ^(CallBack cb) { return cb(input); }; Future *future = [[Future alloc] init:cps]; return future; } @end
継続モナド
Objective-Cで継続モナドを書いてみた。ジェネリクスの機能が貧弱なので辛いところが多い。
Shell
チュートリアルを参照した。
コンソールツール、シェルとタスク - 3.x
src/Shell直下にHelloShell.phpを作る。
<?php namespace App\Shell; use Cake\Console\Shell; class HelloShell extends Shell { public function main() { $this->out('Hello world.'); } public function heyThere($name = 'Anonymous') { $this->out('Hey there ' . $name); $this->_hoge(); } // _が先頭にあるものは呼べない。 public function _hoge() { $this->out('hoge'); } } ?>
実行は
./bin/cake hello
や
./bin/cake Hello hey_there name
等でできる。
bakeもできる。
./bin/cake bake shell User
画面消えるタイミング
>|swift|
if (self.isBeingDismissed || self.isMovingToParentViewController) {
...
}
|
Migrationの失敗
Exception: There was a problem connecting to the database: SQLSTATE[HY000] [2002] No such file or directory in [/Applications/MAMP/htdocs/hoge/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php, line 115]
のようなエラーに悩まされた。
結果、app.iniのデータベース設定がlocalhostだとダメで、127.0.0.1でうまくいった。また、MAMPのpreferenceでMySQLのポートを調べて、それをapp.iniのデータベースのポート指定に反映させた。
カスタムメニュー
つかったことがないが。。
override func viewDidLoad() { super.viewDidLoad() UIMenuController.shared.arrowDirection = .right; UIMenuController.shared.menuItems = [UIMenuItem.init(title: "a", action: #selector(hello))] let r = CGRect(x: 0, y: 0, width: 40, height: 40) UIMenuController.shared.setTargetRect(r, in: self.view) UIMenuController.shared.setMenuVisible(true, animated: true); UIMenuController.shared.update() } func hello() { print("hello") } override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { if (action == #selector(hello)) { return true } return false }