question
dict
answers
list
id
stringlengths
2
5
accepted_answer_id
stringlengths
2
5
popular_answer_id
stringlengths
2
5
{ "accepted_answer_id": "11851", "answer_count": 2, "body": "コード:\n\n```\n\n class Hoge {\n var a: Int = 0\n var b: Int = 0\n \n init(a: Int, b: Int) {\n self.a = a\n self.b = b\n }\n \n func tasi() {\n println(a + b)\n }\n }\n \n var hoge: Hoge = Hoge(a: 10, b: 20)\n \n hoge.tasi()\n \n extension Hoge {\n func kake() {\n println(a * b)\n }\n }\n \n hoge.kake()\n \n```\n\n結果:\n\n```\n\n 30\n 200\n \n```\n\n上記コードでextension Hogeのあと、再度インスタンス化する必要があると思うのですが、hoge.kake()が実行できてしまいます。\n\n実行環境が、<http://www.runswiftlang.com/> なので、バグかなと思っているのですが、これはswiftの正しい動きなのでしょうか?\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T07:40:49.813", "favorite_count": 0, "id": "11849", "last_activity_date": "2015-06-30T11:50:48.760", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 3, "tags": [ "swift" ], "title": "extensionについて", "view_count": 134 }
[ { "body": "正しい動作です。\n\n>\n> extensionを定義して既存の型に新しい機能を追加した場合、その新しい機能はextensionを定義する前に作られていたものを含むすべてのインスタンスにおいて有効になります。\n\n<https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Extensions.html#//apple_ref/doc/uid/TP40014097-CH24-ID470>\n\n> If you define an extension to add new functionality to an existing \n> type, the new functionality will be available on all existing \n> instances of that type, even if they were created before the extension \n> was defined.", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T08:21:46.070", "id": "11851", "last_activity_date": "2015-06-29T08:21:46.070", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "11849", "post_type": "answer", "score": 7 }, { "body": "正しい動きなようです。 \nXcode 6.3.2のPlaygroundで実行した結果:\n\n![画像の説明をここに入力](https://i.stack.imgur.com/eahwR.png)\n\n出力位置がわかりにくい場所にあるので、見落とさないでください。\n\nXcode 6.3.2のCommand Line Toolで実行した結果:\n\n![画像の説明をここに入力](https://i.stack.imgur.com/RyBom.png)\n\n私は、おかしな挙動だという印象を持ちません。むしろ、コンパイラが賢くなったという好意的な印象を持ちます。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T08:24:40.060", "id": "11852", "last_activity_date": "2015-06-30T11:50:48.760", "last_edit_date": "2015-06-30T11:50:48.760", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "11849", "post_type": "answer", "score": 1 } ]
11849
11851
11851
{ "accepted_answer_id": null, "answer_count": 1, "body": "ブラウザーで以下のような特徴を持ったWEBサービスがあるのですが、 \nどのような技術を使えばできるのか、わかりましたら教えて下さい。\n\n知人が作ったウェブサービスですが、当人が音信不通で要素技術がわかりません。\n\n----WEBサービスのイメージ----\n\nブラウザー上で同じ画面を共有し、 \n離れた二つのPCで画像やカードなどのオブジェクトの動きを共有します。\n\n画面はキャンバスのようになっており、 \n画像・カードの配置・移動・リサイズ・削除などが可能です。 \n※イメージ的にはトランプのように複数のカードが盤面に配置されているように思って下さい。 \nそれぞれのカードの移動・リサイズ・削除などが可能です。\n\n片方のPCで画像やカードを移動すると、もう一台のPCブラウザー上で \nカードの動きがほぼ同時に再現されます。 \nただしマウスは相手のPCには表示されません。\n\n移動・リサイズ・削除はほぼ同時に再現されており、タイムラグは殆どありません。 \nサーバーに情報を上げているのは確実ですが、 \nいわゆるAjaxだけで相手側のPCでリアルタイムにリロードはできるのでしょうか。\n\n私が感じているのは、リアルタイムにデータベースから画像の座標などをリロードするのは \n速度に限界があるのではないかと思います。\n\nサーバーは、一般のレンタルサーバーを使っており、 \nnode.jsのようなサーバー側からのプッシュは使ってないようです。\n\nちょっと的外れの質問もあるかもしれませんが、 \nご回答いただけますと幸いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T08:16:57.403", "favorite_count": 0, "id": "11850", "last_activity_date": "2015-06-29T11:43:49.827", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8020", "post_type": "question", "score": 2, "tags": [ "javascript", "html" ], "title": "ブラウザで同じ画面を共有する方法", "view_count": 1745 }
[ { "body": "全くの的外れかもしれませんが\n\nWebRTCのデータチャネルを使っているのではないでしょうか?\n\n[WebRTCのデータチャネル解説 -\nQiita](http://qiita.com/udonchan/items/7f5ffa9e8982ae1636c3)\n\n[WebRTCコトハジメ - Qiita](http://qiita.com/Y-NAKA/items/286f569d110daede721e)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T11:43:49.827", "id": "11856", "last_activity_date": "2015-06-29T11:43:49.827", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5246", "parent_id": "11850", "post_type": "answer", "score": 5 } ]
11850
null
11856
{ "accepted_answer_id": null, "answer_count": 0, "body": "`.fb-like iframe {z-index: 999;max-width: none !important;overflow: visible;}`\n\nを指定してみたり、ほぼ全ての要素にz-indexを指定したりしてみたのですが、どうしてもコンテンツの下に隠れてしまいます。\n\nまた覆っている要素にはz-indexは指定していません。(z-index :\n0では変化なく、z-index:-1ですとbackgroundに隠れてしまいました。)\n\n![画像の説明をここに入力](https://i.stack.imgur.com/3qwcr.png)\n\nどなたか解決策をご存知の方いらっしゃいましたら宜しくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T08:25:33.780", "favorite_count": 0, "id": "11853", "last_activity_date": "2015-06-29T08:25:33.780", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8500", "post_type": "question", "score": 1, "tags": [ "facebook" ], "title": "facebook いいねダイアログのz-indexについて", "view_count": 84 }
[]
11853
null
null
{ "accepted_answer_id": null, "answer_count": 3, "body": "アドレス指定方式についてです。\n\n直接アドレス指定方式 \n指標アドレス指定方式 \nベースアドレス指定方式 \n相対アドレス指定方式 \n間接アドレス指定方式 \nレジスタアドレス指定方式 \n即値アドレス指定方式\n\nこの7つの違いはわかりました。 \nしかし、それが具体的に何に使われているのか? \nこの思想の違いが何故生まれてきたかなどの歴史的な経緯がわかりません。 \n多分OSの設計思想の話だと思うのですが...", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T14:05:31.750", "favorite_count": 0, "id": "11858", "last_activity_date": "2015-08-28T10:02:39.170", "last_edit_date": "2015-08-28T09:30:30.057", "last_editor_user_id": "10945", "owner_user_id": "10338", "post_type": "question", "score": 2, "tags": [ "アルゴリズム", "アセンブリ言語" ], "title": "アドレス指定方式についてです", "view_count": 1923 }
[ { "body": "鶏が先か卵が先かなところがありますが \n・コンパイラが作りやすいように CPU のアドレッシングを設計する \n・既にある CPU のアドレッシングに適合するようにコンパイラを設計する \nわけです。 \nOS はあまり関係ないですね (CPU に適合するように OS を作るわけですし)\n\n32bit を想定 \nC/C++ でコード例を出し説明のための仮 CPU (x86, SH, RX 等を想定) で命令例を出すこととします\n\n直接アドレッシング \n大域静的変数は固定アドレスに配置されます。\n\n```\n\n int global_scoped_static_variable;\n void some_func() {\n global_scoped_static_variable=1;\n }\n \n```\n\nこの代入に対しては直接アドレッシング命令が生成でき \nMOV.L #1, @_global_scoped_static_variable\n\n即値アドレッシング \n同様 `int* p=&global_scoped_static_variable` なるソースコードに対して \nMOV.L #_global_scoped_static_variable, R3\n\nレジスタアドレッシング \n先のソースコードに引き続き `++*p;` としたなら \nINC.L @R3 \nあるいは関数ポインタ経由の関数呼び出しは JSR @R3 とかがこれに該当します。\n\nベースアドレッシング、ベース+インデックスアドレッシング \n配列変数を扱うときに使います。 \n`int array[NNN];` に対して `array[x]=2;` があれば \nベースアドレス= array \nインデックス = x \n乗算因子 = 4 \nとすることで MOV.L [EBX+EAX*4], 2 とできます。\n\n他は省略(宿題)\n\n命令語数が少ないほうがプログラムが小さく高速になるわけで、 \nそうできるようにアドレッシングモードやコンパイラが設計されてきました。 \nほぼ完成形まで来ているので「アドレッシングモード」が今後大幅に変化することはなさそうです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T21:52:21.843", "id": "11862", "last_activity_date": "2015-06-29T21:52:21.843", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8589", "parent_id": "11858", "post_type": "answer", "score": 1 }, { "body": "アセンブリ言語の命令を分類したものです。 \n例えばマイコンのデータシートに命令表が用意されています。そこでアドレッシング・モードを確認しながらプログラムを書きます。\n\n命令の記述量が多くなって複雑さが増さないように、簡潔に表現できるようにしたのです。この機能がなければ機械語でプログラムを書くのとほとんど同じ規模になってしまいます。アセンブラによってCPUの機能の範囲内に展開されるので複雑な処理の記述やハードウエアに近い詳細なアーキテクチャを理解や重複したコードを記述する必要がないという利点があります。特にマイコンでは発信水晶子が一つで同一クロックで管理されているのにも関わらず実行ステート数が異なる理由はそこにあります。\n\nOSでのアドレッシング・モードについて触れていますが、ページ管理の`Physical Addressing Mode` と `Virtual\nAddressing Mode`\nは物理アドレス空間と仮想アドレス空間のことです。しかもマイナーな表現です。同時に勉強している場合は混同しないように注意してください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-28T07:07:37.237", "id": "14945", "last_activity_date": "2015-08-28T07:12:43.550", "last_edit_date": "2015-08-28T07:12:43.550", "last_editor_user_id": "10945", "owner_user_id": "10945", "parent_id": "11858", "post_type": "answer", "score": 0 }, { "body": "かつてはメモリーの決まった位置にプログラムを置いて、データや命令がある場所を示すアドレスは固定で動いていたようですね。そうすると、アドレス指定はすべて「直接指定(絶対指定)」で問題ありませんでした。プログラムを組む人は、プログラムがロードされるアドレスを知っていて、「どこに飛ぶ」といった指示を直接指定するわけですね。\n\nしかし、メモリにいろんなプログラムがロードされたり、足りないメモリを補うためにメモリじゃないところにプログラムを置いたり、果てはプログラムが不正アクセスされないようにロード場所を意図して毎回変えたり、といった実行方法が普通になってきました。そうすると、実際のアドレスはプログラムが動くその時までわかりません。\n\nそうなると、\n\n * 今の場所から**だけ先のアドレス\n * スタート地点から**だけずれたアドレス\n * アドレスは変数に入れといたから\n\nみたいなアドレスの指定方法が必要になってきました……というような経緯で、いろんなアドレッシング方式が生まれてきたのだったと思います。\n\nWikipediaですが[位置独立コード](https://ja.wikipedia.org/wiki/%E4%BD%8D%E7%BD%AE%E7%8B%AC%E7%AB%8B%E3%82%B3%E3%83%BC%E3%83%89)や[リロケータブルバイナリ](https://ja.wikipedia.org/wiki/%E3%83%AA%E3%83%AD%E3%82%B1%E3%83%BC%E3%82%BF%E3%83%96%E3%83%AB%E3%83%90%E3%82%A4%E3%83%8A%E3%83%AA)などの説明を読んでみられてもいいかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-28T10:02:39.170", "id": "14955", "last_activity_date": "2015-08-28T10:02:39.170", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10538", "parent_id": "11858", "post_type": "answer", "score": 3 } ]
11858
null
14955
{ "accepted_answer_id": null, "answer_count": 2, "body": "MITライセンスで公開されているライブラリを参考にした上で、独自の機能や設計を加えたライブラリを作り、公開しようと考えているのですが、その場合、参考にしたライブラリのライセンスに従うべきでしょうか?\nまたそうならばどのようにライセンスの記載を行うべきでしょうか。\n\nソースコードそのものとしては、900行ほどの参考元のコード中に存在する10行程度の関数がほぼそのまま(コメントや変数名を除き)残っている状態です。また大きな参考元は前述のライブラリですが、もう一つ同種のライブラリで設計面で参考にしたライブラリも存在します。こちらはどのように実装されているかを見た程度で実装そのものを移すといった事は行っていません。\n\n元のソースコードを一部改変して公開という場合は元のライセンスを記載する必要がありますが、こういった場合はどのように判断すればよいのかわかりません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T16:19:49.517", "favorite_count": 0, "id": "11859", "last_activity_date": "2015-06-30T09:35:00.103", "last_edit_date": "2015-06-30T07:46:35.443", "last_editor_user_id": "49", "owner_user_id": "10340", "post_type": "question", "score": 6, "tags": [ "ライセンス", "mit-license" ], "title": "ライセンスの適用をすべきかどうかの境界とどのように行うべきかについて", "view_count": 1283 }
[ { "body": "技術的というより法的な内容なので、詳しい判断は知的財産権の専門家に相談したほうがいいと思います。ただし、そこまでシビアな内容ではなさそうなので、わかる範囲で回答しておきます。\n\n元のソースコードとの共通部分がたった10行であっても著作権が無効になるわけではないので、元のソースコードのライセンスに従って表示を行う必要があるでしょう。それに、現在のソースコードが元のソースコードを改変した結果なのであれば、多くの改変の結果元のソースコードの痕跡がなくなってしまっていたとしても、それは元のソースコードの派生物だと考えるべきでしょう。\n\n「どのように実装しているかを見て参考にした」の方についてはケースバイケースとしか言いようがありませんし、人によって判断がわかれるでしょうが、とりあえず元のソースコードのライセンスに従っておけば安全でしょう。\n\nいずれにせよ、MITライセンスは最も制限の緩いライセンスのひとつであり、そのライセンスの影響を受けるとしてもほとんど不都合はないはずです。元のソースコードがGPLならいわゆる「GPL汚染」に十二分に注意しなければなりませんが、MITライセンスならとりあえず従っておくという方針で構わないと思います。\n\n> またそうならばどのようにライセンスの記載を行うべきでしょうか。\n\nそれについては、MITライセンスの本文で示されているとおりです。参考訳から引用すれば、\n\n> 上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。\n\n<http://osdn.jp/projects/opensource/wiki/licenses%2FMIT_license>\n\nということで、つまり元のソースコードのライセンス表示をまるごとコピーしてReadmeなりマニュアルなりに付記しておき、「このソフトウェアは〇〇というライブラリを使用しています。以下は〇〇というライブラリのライセンス表示です」などと一言付け加えておけば十分だと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T09:09:25.373", "id": "11883", "last_activity_date": "2015-06-30T09:09:25.373", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10330", "parent_id": "11859", "post_type": "answer", "score": 4 }, { "body": "[オープンソースのコードを取り込んだ時のライセンス表記について -\n30歳からのブラウザづくり](http://d.hatena.ne.jp/mozxxx/20110529/p4)\n\nで面白い表記が紹介されていたので、参考までに。\n\n> The sock_readline() function is:\n>\n> Copyright (c) 1999 Eric S. Raymond\n>\n> Permission is hereby granted, free of charge, to any person \n> obtaining a copy of this software and associated documentation \n> (略)\n\nちょっと調べてみると、 WebDAV のクライアントライブラリである Neon の `src/socket.c`\nに書かれていた著作権表記のようです。最近のNeonでは `sock_readline()` が書き直されているようで上記の記述は見られませんが、 Neon\n0.5.1 とかだと書いてありますね。\n\n<http://www.webdav.org/neon/history.html>\n\nファイル先頭に加え、実際の引用部分にも書かれていました。\n\n```\n\n /* This is from from Eric Raymond's fetchmail (SockRead() in socket.c)\n * since I wouldn't have a clue how to do it properly.\n * This function is Copyright 1999 (C) Eric Raymond.\n * Modifications Copyright 2000 (C) Joe Orton\n */\n int sock_readline(nsocket *sock, char *buf, int len)\n {\n \n```\n\nライセンス上の理由を抜きにしても、そのコード片の由来が示されているのは後から見たときに役立ちそうですね。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T09:35:00.103", "id": "11887", "last_activity_date": "2015-06-30T09:35:00.103", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "11859", "post_type": "answer", "score": 2 } ]
11859
null
11883
{ "accepted_answer_id": null, "answer_count": 1, "body": "![最初はこの状態です。](https://i.stack.imgur.com/sMt7N.png)\n\n![Option 1というところをクリックすると、このような状態になります。](https://i.stack.imgur.com/U5V1K.png)\n\n![もう一度Option\n1を押すと、Comboboxは閉じるのですが、もう一度クリックするとこの画像のようになってしまいます。](https://i.stack.imgur.com/HmoUE.png)\n\n上記の画像のように、Cellを選択するたびに、表示が反転してしまいます。\n\nこれが、UITableViewのdidSelectRowAtIndexPathです。\n\n```\n\n - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath\n {\n switch ([indexPath section]) {\n case 1: {\n \n switch ([indexPath row]) {\n case 0:\n {\n DropDownCell *cell = (DropDownCell*) [tableView cellForRowAtIndexPath:indexPath];\n \n NSIndexPath *path0 = [NSIndexPath indexPathForRow:[indexPath row]+1 inSection:[indexPath section]];\n NSIndexPath *path1 = [NSIndexPath indexPathForRow:[indexPath row]+2 inSection:[indexPath section]];\n NSIndexPath *path2 = [NSIndexPath indexPathForRow:[indexPath row]+3 inSection:[indexPath section]];\n \n NSArray *indexPathArray = [NSArray arrayWithObjects:path0, path1, path2, nil];\n \n if ([cell isOpen])\n {\n [cell setClosed];\n dropDown1Open = [cell isOpen];\n \n [tableView deleteRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationTop];\n }\n else\n {\n [cell setOpen];\n dropDown1Open = [cell isOpen];\n \n [tableView insertRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationTop];\n \n }\n \n break;\n }\n default:\n {\n dropDown1 = [[[tableView cellForRowAtIndexPath:indexPath] textLabel] text];\n \n NSIndexPath *path = [NSIndexPath indexPathForRow:0 inSection:[indexPath section]];\n DropDownCell *cell = (DropDownCell*) [tableView cellForRowAtIndexPath:path];\n \n [[cell textLabel] setText:dropDown1];\n \n NSIndexPath *path0 = [NSIndexPath indexPathForRow:[path row]+1 inSection:[indexPath section]];\n NSIndexPath *path1 = [NSIndexPath indexPathForRow:[path row]+2 inSection:[indexPath section]];\n NSIndexPath *path2 = [NSIndexPath indexPathForRow:[path row]+3 inSection:[indexPath section]];\n \n NSArray *indexPathArray = [NSArray arrayWithObjects:path0, path1, path2, nil];\n \n [cell setClosed];\n dropDown1Open = [cell isOpen];\n \n [tableView deleteRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationTop];\n \n break;\n \n }\n }\n \n }\n \n }\n \n [tableView deselectRowAtIndexPath:indexPath animated:YES];\n }\n \n```\n\nといった感じなのですが、念のためcellForRowAtIndexPathも載せておきます。\n\n```\n\n - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {\n UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@\"Cell\"];\n if (cell == nil){\n \n switch ([indexPath section]) {\n case 0:{\n cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@\"Cell\"];\n \n cell.textLabel.text = @\"first\";\n break;\n }\n case 1:{\n switch ([indexPath row]) {\n case 0: {\n \n DropDownCell *cell = (DropDownCell*) [tableView dequeueReusableCellWithIdentifier:@\"DropDownCell\"];\n \n if (cell == nil){\n NSLog(@\"New Cell Made\");\n \n NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@\"DropDownCell\" owner:nil options:nil];\n \n for(id currentObject in topLevelObjects)\n {\n if([currentObject isKindOfClass:[DropDownCell class]])\n {\n cell = (DropDownCell *)currentObject;\n break;\n }\n }\n \n if (dropDown1Open) {\n [cell setOpen];\n }\n \n [[cell textLabel] setText:dropDown1];\n }\n \n // Configure the cell.\n return cell;\n \n break;\n }\n default: {\n UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@\"Cell\"];\n \n if (cell == nil) {\n cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@\"Cell\"];\n }\n \n NSString *label = [NSString stringWithFormat:@\"Option %ld\", [indexPath row]];\n \n [[cell textLabel] setText:label];\n \n // Configure the cell.\n return cell;\n \n break;\n }\n }\n \n break;\n }\n \n }\n }\n return cell;\n }\n \n```\n\nはまってしまって、なかなか前に進めません。 \n回答の方をよろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T20:26:20.173", "favorite_count": 0, "id": "11861", "last_activity_date": "2015-07-09T08:14:07.053", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10343", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c", "uitableview" ], "title": "UITableViewにて、Cell内にComboBoxを作ったら、なぜか反転してしまいます・・・。", "view_count": 246 }
[ { "body": "おそらく \n<https://github.com/floriankrueger/iOS-Examples--UITableView-Combo-Box> \nにあるサンプルを参考にしてコーディングしたのだと思います。\n\nサンプルと見比べてみるとすぐわかりますが、 \n`cellForRowAtIndexPath`のあなたのコーディングの最初の2行\n\n```\n\n UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@\"Cell\"];\n if (cell == nil){\n \n```\n\nは、サンプルにはありません。 \nあなたが追加したこの部分が不具合の原因だと思います。\n\n`dequeueReusableCellWithIdentifier`は、以前に使ったセルを再利用するメソッドですが、 \n別のテーブル行で使ったセルが再利用される可能性があります。 \nあなたのコーディングは取得したセルを何もせずそのままメソッドの戻りとして返してしまいますから、 \n以前にOption3の表示に使っていたセルをそのままOption1表示用のセルとして返却してしまい、 \nテーブル表示を更新すると、表示順序が不正になってしまうのだと思います。\n\n`dequeueReusableCellWithIdentifier`で以前に使ったセルを取得した後は、 \nセルの内容をindexPathで指定された行の表示になるよう更新する必要があります。 \n参考にしたサンプルコーディングにその処理はもともと入っていて、 \ncase文のdefault処理の中に\n\n```\n\n NSString *label = [NSString stringWithFormat:@\"Option %ld\", [indexPath row]];\n [[cell textLabel] setText:label];\n \n```\n\nと書かれています。 \nつまり、あなたが追加した2行が余計な処理で、それを取り除けば \ncase文のdefault処理が動作して正しく表示できるようになるはずです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-09T08:14:07.053", "id": "12197", "last_activity_date": "2015-07-09T08:14:07.053", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9367", "parent_id": "11861", "post_type": "answer", "score": 2 } ]
11861
null
12197
{ "accepted_answer_id": "11872", "answer_count": 2, "body": "タイトルの通りですが、ズバリ、 xxxオブジェクトのxxxを知りたく質問しています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T02:11:18.577", "favorite_count": 0, "id": "11866", "last_activity_date": "2018-10-18T08:49:32.773", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7844", "post_type": "question", "score": 9, "tags": [ "c++" ], "title": "nothrowのようなそれ自体機能をもたないが、指定することで別の演算子やクラスに振るまいを変更させるためのオブジェクトを一般的になんと言いますが?", "view_count": 462 }
[ { "body": "『修飾子』でどうでしょう?\n\nこれをオブジェクトとは言わないでしょうけど。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T04:34:29.043", "id": "11870", "last_activity_date": "2015-06-30T04:34:29.043", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7459", "parent_id": "11866", "post_type": "answer", "score": -3 }, { "body": "[`std::nothrow`オブジェクトと`std::nothrow_t`型](http://cpprefjp.github.io/reference/new/nothrow_t.html)のことであれば、一般に「タグ(tag)」オブジェクト/型と呼ばれます。\n\nC++標準ライブラリでは`std::nothrow`の他にも、[`std::piecewise_construct`](https://cpprefjp.github.io/reference/utility/piecewise_construct_t.html)や[`std::defer_lock`](http://cpprefjp.github.io/reference/mutex/defer_lock.html)などが該当します。\n\nオブジェクトそのものよりも、同オブジェクトを利用してオーバーロード関数選択を行う「タグ・ディスパッチ(Tag\nDispatch)」の方がよく知られている気がします。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2015-06-30T05:25:55.060", "id": "11872", "last_activity_date": "2018-10-18T08:49:32.773", "last_edit_date": "2018-10-18T08:49:32.773", "last_editor_user_id": "49", "owner_user_id": "49", "parent_id": "11866", "post_type": "answer", "score": 9 } ]
11866
11872
11872
{ "accepted_answer_id": null, "answer_count": 0, "body": "## 発生している問題\n\nAWS上にjobschedulerをインストールして利用しようとしているのですが、ジョブの終了時にメールが送信されずにいます。 \n/var/log/maillog を見ても送信されたログが無いので、jobschedulerの設定がおかしいと考えています。\n\n現在、以下のサイトのオーダ(3つのジョブを実行するジョブチェーン)が登録されているので、まずはこのオーダが終了した時に、成功・失敗をメールで通知させたいと考えています。 \n<http://tech-\nsketch.jp/2014/04/%E3%82%AA%E3%83%BC%E3%83%97%E3%83%B3%E3%82%BD%E3%83%BC%E3%82%B9%E3%81%AA%E3%82%B8%E3%83%A7%E3%83%96%E7%AE%A1%E7%90%86%E3%83%84%E3%83%BC%E3%83%AB-\nsos-jobscheduler-%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6-3.html>\n\nもしお分かりの方がいらっしゃいましたら、jobschedulerのメール送信設定をご教授いただけないでしょうか。\n\n* * *\n\n## 補足情報 (OS, ツールのバージョンなど)\n\n### ■ 環境\n\n * Amazon Linux \n * jobscheduler.1.9.2\n * openjdk version \"1.8.0_45\"\n\n※ec2-userがsendmailコマンドでメール送信できるように設定を変更済み\n\n### ■ メール送信の設定(メールアドレスは※で伏せています)\n\n```\n\n /home/ec2-user/jobscheduler/scheduler/config/factory.ini\n ~略~\n [spooler]\n ; directory of the OperationsGUI\n html_dir = ${SCHEDULER_HOME}/operations_gui\n \n ; send mail with job log in case of error (yes|no, default: no)\n mail_on_error = yes\n ; send mail with job log in case of errors and warnings (yes|no, default: no)\n mail_on_warning = yes\n ; send mail with job log in case of success (yes|no, default: no)\n mail_on_success = yes\n ; send mail with job log in case of process steps (yes|no|1|2|n, default: no)\n mail_on_process = no\n \n ; sender and recipients for mails with job logs\n log_mail_from = ※@gmail.com\n log_mail_to = ※@gmail.com\n log_mail_cc = ※@gmail.com\n log_mail_bcc =\n \n ; mail server hostname\n smtp = localhost\n ; directory in which mails are stored if your mail server is not available\n mail_queue_dir = ${SCHEDULER_DATA}/mail\n ~略~\n [smtp]\n mail.smtp.user =\n \n mail.smtp.password =\n \n mail.smtp.port = 25\n ~略~\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-06-30T03:00:22.767", "favorite_count": 0, "id": "11867", "last_activity_date": "2019-05-08T04:39:52.487", "last_edit_date": "2019-05-08T04:39:52.487", "last_editor_user_id": "32986", "owner_user_id": "7609", "post_type": "question", "score": 1, "tags": [ "aws", "sendmail" ], "title": "jobschedulerのメール送信設定について", "view_count": 840 }
[]
11867
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "職場や、自宅、ノートPCなど、複数のPCにSublime\nText3をインストールして同じ環境にしたいと思っています。1台ずつ手動設定したり、パッケージをインストールするのではなく、1台のPCに構築した設定、パッケージを他のPCに簡単に移行する方法はないでしょうか?\n\nvimではプラグインのインストールにVundlerやneobundleを使っていれば、.vimrcのみ他のPCにコピーすれば、設定の移行が済みますし、プラグインのインストールもコマンドを1回実行するだけで済みます。\n\nSublime Text3でも同様に、設定ファイルやインストール済みパッケージ一覧をエクスポート/インポートできたりすると良いのですが...", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T06:48:24.247", "favorite_count": 0, "id": "11877", "last_activity_date": "2018-12-10T23:01:30.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9529", "post_type": "question", "score": 3, "tags": [ "sublimetext" ], "title": "Sublime Text 3で設定やパッケージを他のPCに移行したい", "view_count": 3013 }
[ { "body": "端的に申し上げますと、`Packages/User/`を同期すれば、すべてのSublimeTextの環境を同期することができます。\n\nSublimeTextのパッケージマネージャとして有名なPackage\nControlは、インストールしたプラグインを同期する機能を持っています。同期の仕方は下記URLに記載されていますが、ここでは`Packages/User/`を同期することを要求されています。 \n<https://packagecontrol.io/docs/syncing> \n私はGitを使って同期しています。この場合、いくつか指定されたファイルを.gitignoreに入れておく必要はありますが、後は`Packages/User/`を同期してくれれば、足りないプラグインを自動的にインストール/アップデートしてくれます。\n\nまた、プラグイン以外で個人的にSublimeTextに設定を施した場合についても、個人設定ファイルは普通`Packages/User/`に保存されます。\n\n従って、`Packages/User/`を同期すれば、すべての設定が同期されることになります。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2018-07-10T17:17:56.707", "id": "45489", "last_activity_date": "2018-07-10T17:17:56.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25734", "parent_id": "11877", "post_type": "answer", "score": 1 } ]
11877
null
45489
{ "accepted_answer_id": null, "answer_count": 2, "body": "swiftでアプリ開発をしています。\n\n画面A・画面Bとありまして \n画面Aから画面Bが呼ばれます。 \nで、画面Bから画面Aに戻った時に、画面Aの関数を実行したいのですが \n方法がわかりません。 \n画面Aから画面Bは下記のようにStoryboard IDを使ってモーダル表示しています。 \n【画面A】\n\n```\n\n var selfStoryboard: UIStoryboard?\n selfStoryboard = self.storyboard\n nex = selfStoryboard!.instantiateViewControllerWithIdentifier(\"Storyboard_ID\") as UIViewController\n self.presentViewController(nex, animated: true, completion: nil)\n \n```\n\n画面Bでは下記のように記述し画面を閉じています。 \n【画面B】\n\n```\n\n self.dismissViewControllerAnimated(true, completion:nil)\n \n```\n\nこのようにして画面を閉じた後に、画面Aの特定な関数を実行するにはどうしたらよいのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T07:56:05.407", "favorite_count": 0, "id": "11879", "last_activity_date": "2023-08-23T07:09:16.077", "last_edit_date": "2016-12-30T11:12:22.473", "last_editor_user_id": "76", "owner_user_id": "9987", "post_type": "question", "score": 1, "tags": [ "swift", "iphone" ], "title": "swiftで画面遷移時の関数の実行", "view_count": 8181 }
[ { "body": "モーダルによる画面遷移の場合、遷移元のViewControllerは、`UIViewController`クラスのプロパティ`presentingViewController`で取得できます。 \n遷移元のViewControllerを、`BaseViewController`、呼びたい`BaseViewController`のメソッドを、`func\ndoAnything()`とすると\n\n```\n\n if let controller = self.presentingViewController as? BaseViewController {\n controller.doAnyThing()\n }\n \n```\n\n> 画面Bから画面Aに戻った時に、画面Aの関数を実行したい\n\n戻ったときに実行されるのではなく、上のコードは戻る前に実行されますから、厳密にいうと、あなたのご要望には沿っておりません。それで問題ないとは思いますが、どうしても「閉じた後」でなければならない事情があるのなら、`dismissViewControllerAnimated()`の引数`completion`を使います。\n\n```\n\n let controller = self.presentingViewController as? BaseViewController\n self.dismissViewControllerAnimated(true, completion: {\n controller?.doAnything()\n })\n \n```\n\nクロージャ内で`self.presentingViewController`を使うと、うまく動かないので、こういう書き方になっています。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T00:37:20.883", "id": "11910", "last_activity_date": "2015-07-01T22:25:32.817", "last_edit_date": "2015-07-01T22:25:32.817", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "11879", "post_type": "answer", "score": 0 }, { "body": "viewWillAppear関数を使えばできると思います。\n\n```\n\n class ViewController: UIViewController {\n override func viewWillAppear(_ animated: Bool) { // 戻ってきた時に実行されます\n super.viewWillAppear(animated)\n // ここにコードを記載\n }\n }\n \n```\n\n注意: ただし、このやり方だと、一番最初画面Aが表示された時にも実行されてしまいます。 \nですので、\n\n```\n\n class ViewController: UIViewController {\n var isBack = false\n override func viewWillAppear(_ animated: Bool) { // 戻ってきた時に実行されます\n super.viewWillAppear(animated)\n // ここにコードを記載\n if isBack {\n // ここにコードを記載\n }\n isBack.toggle()\n }\n }\n \n```\n\nのように、変数を定義しておき、条件分岐を使用して戻ったか確かめればいいと思います。 \nただ、このやり方ですと\n\n```\n\n C -> A -> B\n \n```\n\nのような構造になっていた場合に、\n\n```\n\n C -> *A -> C -> */A\n \n```\n\nこのような順番で遷移したときには *マーク でviewWillAppearが実行されますが、/マーク\nのところで戻ってきたときに実行されるはずの処理が実行されてしまうので、そのような場合にはBから値渡しをするなど、別のやり方が必要になります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-05-05T01:32:04.787", "id": "66298", "last_activity_date": "2021-04-01T08:11:48.970", "last_edit_date": "2021-04-01T08:11:48.970", "last_editor_user_id": "39579", "owner_user_id": "39579", "parent_id": "11879", "post_type": "answer", "score": 0 } ]
11879
null
11910
{ "accepted_answer_id": null, "answer_count": 4, "body": "「$ vagrant up」でvccwの立ち上げをやろうとしているのですが、「Connection timeout.\nRetrying...」から先に進めません。\n\n> $ vagrant up \n> Bringing machine 'default' up with 'virtualbox' provider... \n> ==> default: Importing base box 'centos'... \n> ==> default: Matching MAC address for NAT networking... \n> ==> default: Setting the name of the VM: vagrant-\n> wataca_default_1435643479833_86344 \n> ==> default: Clearing any previously set forwarded ports... \n> ==> default: Fixed port collision for 22 => 2222. Now on port 2200. \n> ==> default: Clearing any previously set network interfaces... \n> ==> default: Preparing network interfaces based on configuration... \n> default: Adapter 1: nat \n> ==> default: Forwarding ports... \n> default: 22 => 2200 (adapter 1) \n> ==> default: Booting VM... \n> ==> default: Waiting for machine to boot. This may take a few minutes... \n> default: SSH address: 127.0.0.1:2200 \n> default: SSH username: vagrant \n> default: SSH auth method: private key \n> default: Warning: Connection timeout. Retrying... \n> default: Warning: Connection timeout. Retrying..\n\nその際のエラー文は以下のとおりです。\n\n> Timed out while waiting for the machine to boot. This means that \n> Vagrant was unable to communicate with the guest machine within \n> the configured (\"config.vm.boot_timeout\" value) time period.\n>\n> If you look above, you should be able to see the error(s) that \n> Vagrant had when attempting to connect to the machine. These errors \n> are usually good hints as to what may be wrong.\n>\n> If you're using a custom box, make sure that networking is properly \n> working and you're able to connect to the machine. It is a common \n> problem that networking isn't setup properly in these boxes. \n> Verify that authentication configurations are also setup properly, \n> as well.\n>\n> If the box appears to be booting properly, you may want to increase \n> the timeout (\"config.vm.boot_timeout\") value.\n\nconfig.vm.boot_timeoutを10秒→120秒に書き換えると以下のようなメッセージに変わりました。\n\n> The guest machine entered an invalid state while waiting for it \n> to boot. Valid states are 'starting, running'. The machine is in the \n> 'poweroff' state. Please verify everything is configured \n> properly and try again.\n>\n> If the provider you're using has a GUI that comes with it, \n> it is often helpful to open that and watch the machine, since the \n> GUI often has more helpful error messages than Vagrant can retrieve. \n> For example, if you're using VirtualBox, run `vagrant up` while the \n> VirtualBox GUI is open.\n\n「vagrant up」後に「vagrant ssh」で接続することもできません。\n\nまた他のVagrantfileでも同様の問題が発生していますので、\n\nVirtualBoxまわりかSSHの設定が漏れているのかなと思っていますが、この先どう調べていけばいいのか手詰まり状態です。\n\nかなり基本的なミスではないかと思うのですが、アドバイスを頂けると幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T08:07:32.817", "favorite_count": 0, "id": "11880", "last_activity_date": "2016-04-23T02:31:11.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3555", "post_type": "question", "score": 4, "tags": [ "vagrant" ], "title": "Vagrant upがConnection timeout. Retrying...から進まない", "view_count": 13378 }
[ { "body": "----- こちらに該当する場合は、難しいかもしれません -----\n\n・Nested Virtualizationをやろうとしている \n・ゲストで64bitOSを起動しようとしている\n\nVirtualBoxはハードウェア仮想化支援機能が正常に働かないため、 \n64bitのNested Virtualizationはできないと思います(ゲストOSが32bitなら多分いけます)。 \n[VirtualBoxでのNested\nVirtualizationは無理だったという話](http://heroween.hateblo.jp/entry/2014/05/28/125451)\n\n余談ですが、さくらのVPSもvmx・svmはサポートしていないそうです。\n\n----- 上記に該当しないのであれば、こちらで解決するかもしれません -----\n\n[Vagrant で CentOS64bit に ssh 接続出来なかったのを解消](http://sakashushu.blog.so-\nnet.ne.jp/2014-06-16) \n[vagrant up起動に失敗したら](http://qiita.com/last-resort/items/21e4456b8318db877f5b)\n\n> VirtualBox GUI is open.\n\nは[3.Vagrantfileをいじる](http://qiita.com/last-\nresort/items/21e4456b8318db877f5b#3vagrantfile%E3%82%92%E3%81%84%E3%81%98%E3%82%8B)あたりが参考になるかと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T09:20:03.310", "id": "11884", "last_activity_date": "2015-06-30T09:27:18.610", "last_edit_date": "2015-06-30T09:27:18.610", "last_editor_user_id": "3516", "owner_user_id": "3516", "parent_id": "11880", "post_type": "answer", "score": 2 }, { "body": "出力を見る限りVCCWのバージョンが古いかVCCWではありません。 \nVCCWは最新版を使ってください。 \nVirtualBoxとVagrantも最新版がいいです。\n\nさらにいえばVagrantのボックスも以下のコマンドでアップデートしてください。\n\n```\n\n vagrant box update\n \n```\n\nたぶん原因はVagrant 1.7での仕様変更によるものじゃないかと思われます。 \n<https://twitter.com/mitchellh/status/525704126647128064>\n\nこういうツールはサードパーティのツールとの依存関係のかたまりなので、なるべく新しいものを使うのがコツだと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T15:55:31.817", "id": "11907", "last_activity_date": "2015-06-30T15:55:31.817", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10355", "parent_id": "11880", "post_type": "answer", "score": 1 }, { "body": "普段は問題なかったのに、突然上手く行かなくなったというときの意外な線での可能性では、例えば無線LAN子機等の外部ネットワーク接続デバイスを使っていて同様のことが起きることがあります。 \nもしそういうものが接続されていたら、一度外してからvagrant up してみると上手く行くかもしれません。 \n原因としてはゲストOS側のsshdがクライアントの名前解決を行おうとしていることがあり得ます。 \n[vagrantの本家サイトにも同様の記述](https://docs.vagrantup.com/v2/boxes/base.html)があります。\n\n> In order to keep SSH speedy even when your machine or the Vagrant machine is\n> not connected to the internet, set the UseDNS configuration to no in the SSH\n> server configuration. \n> This avoids a reverse DNS lookup on the connecting SSH client which can\n> take many seconds.", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-30T00:22:49.247", "id": "15021", "last_activity_date": "2015-08-30T00:30:42.730", "last_edit_date": "2015-08-30T00:30:42.730", "last_editor_user_id": "9403", "owner_user_id": "9403", "parent_id": "11880", "post_type": "answer", "score": 1 }, { "body": "似たような症状が出て、いろいろはまった結果、私の場合は、Hyper-Vを切ったらうまくいきました。どうも、仮想環境の構築がバッティングしているらしいです。\n\n以下のサイトを参照しました。\n\n[Windows 10 で Hyper-V と Oracle VirtualBox v5.0.0 は両立できない !?](http://app-\nreview.poox.xyz/archives/1449#Hyper-V)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-04-23T02:31:11.193", "id": "24276", "last_activity_date": "2016-04-23T02:31:11.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "15262", "parent_id": "11880", "post_type": "answer", "score": 0 } ]
11880
null
11884
{ "accepted_answer_id": "11886", "answer_count": 1, "body": "xmlParseFile(); \nで読み込んだファイルは確実に読み込めているようなのですが、 \nXpathで抽出しようとするとうごきません。\n\nxmlParseFile()の抽出結果の確認は \nxmlDocGetRootElement()でルートノードを取得しtag名を標準出力したところ、正常に表示できたという根拠です。\n\n```\n\n <project xmlns=\"略\">\n <modelVersion>4.0.0</modelVersion>\n <groupId>略</groupId>\n <artifactId>略</artifactId>\n <version>1.0.2</version>\n <name>略</name>\n \n ...\n </project>\n \n```\n\nようするにmavenのpom.xmlを読み込んで、Xpathで特定ノードを抽出したいんですが、\n\n```\n\n xmlNodeSetPtr executeXpath(xmlDocPtr &doc, xmlChar *xpath_expr) {\n xmlXPathContextPtr xpath_context;\n xmlXPathObjectPtr xpath_obj;\n \n xpath_context = xmlXPathNewContext(doc);\n if (xpath_context == NULL) {\n cerr << \"Error: unable to create new XPath context\" << endl;\n xmlFreeDoc(doc);\n return NULL;\n }\n xmlNodePtr node = xmlDocGetRootElement(doc);\n \n /* Evaluate xpath expression */\n xpath_obj = xmlXPathEvalExpression(xpath_expr, xpath_context);\n if (xmlXPathNodeSetIsEmpty(xpath_obj->nodesetval)) {\n cerr << \"Error: unable to evaluate xpath expression\" << endl;\n xmlXPathFreeContext(xpath_context);\n xmlFreeDoc(doc);\n return NULL;\n }\n \n /* Print results */\n return xpath_obj->nodesetval;\n }\n \n```\n\nこの関数を\n\n```\n\n xmlNodeSetPtr versionObj = domParser.executeXpath(pomData, (xmlChar *)\"//version[1]\");\n \n```\n\nこうしても、\n\n```\n\n Error: unable to evaluate xpath expression\n \n```\n\nの箇所で落ちてしまいます。\n\nなぜなのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T08:50:51.367", "favorite_count": 0, "id": "11882", "last_activity_date": "2015-06-30T09:30:15.937", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8396", "post_type": "question", "score": 1, "tags": [ "c++", "xpath" ], "title": "C++でlibxml2(Xpath)が動かない", "view_count": 909 }
[ { "body": "libxml2は指定通り動作しているのかもしれません。 \nxmlns(デフォルト名前空間)の指定されたXMLに対して、名前空間未指定のXPathを実行したために一致しなかっただけでは。\n\n<https://stackoverflow.com/questions/5239685/xml-namespace-breaking-my-xpath>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T09:30:15.937", "id": "11886", "last_activity_date": "2015-06-30T09:30:15.937", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "4236", "parent_id": "11882", "post_type": "answer", "score": 1 } ]
11882
11886
11886
{ "accepted_answer_id": "11909", "answer_count": 2, "body": "eclipse(Luna Service Release 2 (4.4.2))でAndroidアプリを作っています。 \n一度はビルド&動作していたのですが、色々とソースコードを変更したところ、あるときから「Rを変数に解決できません」とのエラーが出るようになりました。 \nGoogleで調べてみると \n1. import android.R;が存在する \n→存在しません。 \n2. res/layout/activity_main.xmlの確認 \n→存在しますし、activity_main.xmlで画面を作っています。\n\n今まで動いていたのに急にこのようなエラーが出て困り果てています。何をしたのか・・・。 \n解決方法ご存知であればご教示お願いします。\n\n![エラー画面](https://i.stack.imgur.com/L0zYT.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T09:43:24.673", "favorite_count": 0, "id": "11888", "last_activity_date": "2015-07-01T00:29:59.357", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8593", "post_type": "question", "score": 1, "tags": [ "android" ], "title": "Androidプログラミング(Rを変数に解決できません)", "view_count": 1505 }
[ { "body": "編集したxmlファイルのどれかにエラーがあると思われます。 \nレイアウトxml以外も確認してみてください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T00:27:21.640", "id": "11908", "last_activity_date": "2015-07-01T00:27:21.640", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "845", "parent_id": "11888", "post_type": "answer", "score": 1 }, { "body": "クリーンプロジェクトはもう行いましたか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T00:29:59.357", "id": "11909", "last_activity_date": "2015-07-01T00:29:59.357", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8044", "parent_id": "11888", "post_type": "answer", "score": 1 } ]
11888
11909
11908
{ "accepted_answer_id": "11898", "answer_count": 2, "body": "3つにウィンドウを分割してそれぞれ異なるバッファを作成したかったのですが、1番目と2番目のウィンドウのバッファ番号が同じでした。\n\n```\n\n :split enew\n :split enew\n :echo bufnr('%') \" 2\n :wincmd w\n :echo bufnr('%') \" 2\n :wincmd w:\n :echo bufnr('%') \" 1\n \n```\n\nsplitとenewを分けて書けばそれぞれ異なるバッファ番号になりました。\n\n```\n\n :split\n :enew\n :split\n :enew\n :echo bufnr('%') \" 3\n :wincmd w\n :echo bufnr('%') \" 2\n :wincmd w:\n :echo bufnr('%') \" 1\n \n```\n\n何故、前者のコードでは重複したバッファ番号が存在するのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T10:01:48.417", "favorite_count": 0, "id": "11889", "last_activity_date": "2015-06-30T14:12:40.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10022", "post_type": "question", "score": 1, "tags": [ "vim" ], "title": "ウィンドウを分割して新しくバッファを作るときにバッファ番号が被る", "view_count": 289 }
[ { "body": "`:enew` は新しいバッファを作成するコマンドです。また `:split`\nは引数で与えられたバッファをウィンドウを分割して開くコマンドであり、引数に与えたコマンドを実行するコマンドではありません。\n\nそのために前者の例では、ウィンドウを分割して `enew` という名前のバッファを開いていることになります。また2回めの `:split enew`\nは、1回めで作成済みの `enew` という名前のバッファを別ウィンドウで開いてることになります。当然バッファ番号は同じものになります。\n\n対して後者の例では、まずウィンドウを分割しそれから `:enew` で新しいバッファを作成しています。それを2回繰り返すのですから、別のバッファとなります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T13:42:09.100", "id": "11898", "last_activity_date": "2015-06-30T13:42:09.100", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "208", "parent_id": "11889", "post_type": "answer", "score": 5 }, { "body": "brasizyさんが実行したいコマンドは `:new` なのではないでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T14:12:40.707", "id": "11900", "last_activity_date": "2015-06-30T14:12:40.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2687", "parent_id": "11889", "post_type": "answer", "score": 4 } ]
11889
11898
11898
{ "accepted_answer_id": null, "answer_count": 1, "body": "C#でビデオ再生をするプログラムを作っています。 \nマウスホイールによるコマ送り再生を実装したいのですが表題の事例が発生してしまいます。\n\n起動直後はちゃんと1回だけ呼び出されるのですが、フォーム内をクリックする等をしてアクティブなコントロールがある状態になると2回呼び出されてしまいます。\n\nイベントはメインフォームにのみ\n\n```\n\n this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.frmMainForm_MouseWheel)\n \n```\n\nの形で登録しています。\n\n今は\n\n```\n\n if (this.ActiveControl != null)\n {\n frameSec = frameMSec / 2;\n }\n \n```\n\nというようにアクティブなコントロールがあれば、1コマの半分の時間だけ動画を進めるという形をとっているのですが、このような対症療法的なものではなく根本的な解決法が知りたいです。\n\nどうすれば2回目の呼び出しを回避できるのでしょうか?\n\nそもそも、何故2回呼び出されてしまうのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T10:01:59.607", "favorite_count": 0, "id": "11890", "last_activity_date": "2015-08-29T11:53:03.780", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8521", "post_type": "question", "score": 4, "tags": [ "c#" ], "title": "マウスホイールのイベントが2回呼び出されてしまう", "view_count": 1795 }
[ { "body": "情報が少なくて何とも言えませんが、イベントハンドラーの追加処理\n\n```\n\n this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.frmMainForm_MouseWheel);\n \n```\n\nがデザイナーではなくコーディングによって追加されているのであれば、何らかの理由で2回追加されているだけかもしれません。\n\nもし、\n\n```\n\n this.MouseWheel -= new System.Windows.Forms.MouseEventHandler(this.frmMainForm_MouseWheel);\n this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.frmMainForm_MouseWheel);\n \n```\n\nと追加の前に削除を行って改善するのであれば上記の理由だと判断できます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T10:26:29.663", "id": "11893", "last_activity_date": "2015-06-30T10:26:29.663", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "11890", "post_type": "answer", "score": 1 } ]
11890
null
11893
{ "accepted_answer_id": "11920", "answer_count": 1, "body": "こんにちは。\n\n現在、java(tomcatのアプリケーション)で作ったシステムがすでに本番稼動中なのですが、つい先日、想定外のエラーが発生しました。(java.sql.SQLExceptionでした。)\n\nエラーの原因自体はわかったのですが、ログがlog4jのログファイルではなく、 \ntomcatのログファイル(localhost.yyyy-mm-dd.log)に出力されたことが問題となり、 \nログの集約を求められました。\n\nもちろん、exceptionが発生しそうな場所に \nlogger.error・・ \nをしかけておけばよいのですが、そもそも今の作りとして、ほとんどlogger.errorを \nしかけていないので、エラーログを出力するためにアプリケーションを直さなくてはならない、 \nというのがあまりいい策でないと思っています。\n\nlog4jの設定ファイル変更で対応できないかと思っているのですが、可能でしょうか・・。\n\nご存じの方いらっしゃれば、コメントをお願いします!", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T10:23:10.470", "favorite_count": 0, "id": "11892", "last_activity_date": "2015-07-01T05:36:07.490", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10349", "post_type": "question", "score": 1, "tags": [ "java" ], "title": "log4jでRuntimeExceptionのStacktraceを出力したいです。", "view_count": 1576 }
[ { "body": "こちらが参考になるでしょうか。\n\ntomcat6 のログ出力を Log4j で行う方法: \n<http://www.deftrash.com/blog/archives/2008/06/tomcat6_log4j.html>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T05:36:07.490", "id": "11920", "last_activity_date": "2015-07-01T05:36:07.490", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5778", "parent_id": "11892", "post_type": "answer", "score": 2 } ]
11892
11920
11920
{ "accepted_answer_id": "11924", "answer_count": 1, "body": "画面をタッチされた時に反応するタッチビギャンイベントなのですが、 \n下記のジャンプ先であるfunc dangen内などでも使いたいです。 \nしかし、なぜか二つ目のタッチイベントはオーバーライドを消せと言われてしまいます。\n\nタッチイベントを別のfuncの中では使えないのでしょうか?\n\n```\n\n override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {\n for touch: AnyObject in touches {\n // タッチされた位置にあるものを調べて\n let location = touch.locationInNode(self)\n let touchNode = self.nodeAtPoint(location)\n \n // もし、ボタンなら\n if touchNode == aLabel {\n self.dangeon()\n }\n \n //ショップへ\n if touchNode == bLabel {\n self.shop()\n }\n }\n }\n \n func shop(){\n override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {\n for touch: AnyObject in touches {\n // タッチされた位置にあるものを調べて\n let location = touch.locationInNode(self)\n let touchNode = self.nodeAtPoint(location)\n \n // もし、ボタンなら\n if touchNode == cLabel {\n self.next()\n }\n }\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T13:50:42.563", "favorite_count": 0, "id": "11899", "last_activity_date": "2015-07-01T07:19:04.243", "last_edit_date": "2015-06-30T21:04:05.750", "last_editor_user_id": "7362", "owner_user_id": "10353", "post_type": "question", "score": 1, "tags": [ "swift" ], "title": "swift1.1のタッチイベントについて", "view_count": 568 }
[ { "body": "> タッチイベントを別のfuncの中では使えないのでしょうか?\n\nはい、使えません。 \nご提示のコードから推測できる、あなたがやりたいプログラムは、関数の基本に立ち返れば、引数に値を渡して、引き継ぎをするということになると思います。\n\n以下のサンプルコードは、ビュー上に5つの`UILabel`があり、それのいずれかをタップすると、6つめの`UILabel`インスタンス`resultLabel`に、何番目のラベルがタップされたかを、表示します。\n\n**ViewController.swift**\n\n```\n\n import UIKit\n \n class ViewController: UIViewController {\n \n @IBOutlet weak var labelA: UILabel!\n @IBOutlet weak var labelB: UILabel!\n @IBOutlet weak var labelC: UILabel!\n @IBOutlet weak var labelD: UILabel!\n @IBOutlet weak var labelE: UILabel!\n @IBOutlet weak var resultLabel: UILabel!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n // ラベルのtagに、一意に決まる整数値を与える。\n labelA.tag = 1\n labelB.tag = 2\n labelC.tag = 3\n labelD.tag = 4\n labelE.tag = 5\n }\n \n override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {\n self.selectNumber(touches) // touchesBeganの引数を、そのままselectNumber()の引数に渡す。\n }\n \n func selectNumber(touches: Set<NSObject>) {\n // ひとつのタッチを取得。\n let theTouch = touches.first as! UITouch\n // 最初にタッチイベントを受け取ったUIViewインスタンスを取得。\n let touchedView = theTouch.view\n // そのタグの値をresultLabelに表示する。\n resultLabel.text? = \"The selected number = \\(touchedView.tag)\"\n }\n \n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T06:48:47.230", "id": "11924", "last_activity_date": "2015-07-01T07:19:04.243", "last_edit_date": "2015-07-01T07:19:04.243", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "11899", "post_type": "answer", "score": 1 } ]
11899
11924
11924
{ "accepted_answer_id": "11923", "answer_count": 1, "body": "Laravel\n5.1のElixirでファイルの監視とテストを実施しています。appとtestsディレクトリ以下のファイルを変更した時には自動でPHPUnitが動きます。\n\nresources/viewsディレクトリ以下のファイルも監視対象に加えたいのですが、どの様にしたら出来るでしょうか?\n\n[設定ファイル]\n\n```\n\n // gulpfile.js\n \n elixir(function(mix) {\n mix.phpUnit();\n });\n \n```\n\n[テスト監視の実行]\n\n```\n\n $ gulp tdd\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T14:31:05.760", "favorite_count": 0, "id": "11901", "last_activity_date": "2015-07-01T13:59:51.450", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9529", "post_type": "question", "score": 3, "tags": [ "php", "laravel" ], "title": "Elixirのテスト監視にビューを加えたい", "view_count": 118 }
[ { "body": "```\n\n elixir(function(mix) {\n mix.phpUnit([\n \"tests/**/*Test.php\",\n \"resources/views/**/*.php\"\n ]);\n });\n \n```\n\nでいかがでしょうか。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T06:44:52.840", "id": "11923", "last_activity_date": "2015-07-01T13:59:51.450", "last_edit_date": "2015-07-01T13:59:51.450", "last_editor_user_id": "10364", "owner_user_id": "10364", "parent_id": "11901", "post_type": "answer", "score": 2 } ]
11901
11923
11923
{ "accepted_answer_id": "11905", "answer_count": 2, "body": "現在時刻から任意の時間を加算する方法について \n現在時刻に任意の数字を加算し、取り出したいです。また日付の繰り上げなどもさせたいです \n以下のようにすると数字が大きくなると取り出した時に時間がおかしくなります \nいいやり方などあれば教えて下さい、よろしくお願いします。\n\n```\n\n var time = new Date();\n var a = 10.5\n time.setMinutes(time.getMinutes()+a);\n \n var b = time.getMonth();\n var c = time.getDate();\n var d = time.getHours();\n var e = time.getMinutes();\n console.log(time);\n console.log(b);\n console.log(c);\n console.log(d);\n console.log(e);\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T15:11:00.153", "favorite_count": 0, "id": "11903", "last_activity_date": "2015-06-30T15:35:55.237", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10354", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "日時の加算について", "view_count": 1076 }
[ { "body": "Date オブジェクトには、特定の時刻をミリ秒で表す数値が格納されます。 \nなので、ミリ秒単位での加算をすればいいです。 \n例えば10.5分を加算する場合以下の様にすればいいです。\n\n```\n\n var t = new Date();\n var b = new Date(t*1+10.5*60000);//*1で数値に変換、1分は60000ミリ秒\n console.log(t);\n console.log(b);\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T15:32:47.767", "id": "11904", "last_activity_date": "2015-06-30T15:32:47.767", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "11903", "post_type": "answer", "score": 1 }, { "body": "こういうことでしょうか。\n\n * 現在時刻に、分単位 (ただし10.5分など、分未満の単位もある) で時刻を加算したい。\n * 現在の分 + 加算したい値を、現在時刻を表す `Date` オブジェクトに `Date.prototype.setMinutes` しても \n * 少数点以下の数が扱えない。\n * 加算結果が 60 を超える場合を扱えない。\n\nもし、そうなら、`Date.now()` に望みの値を加算したものを引数にして `Date` オブジェクトを作るのが簡単です。\n\n```\n\n var a = 10.5; // 10分半 -> 60000 倍することでミリ秒単位の値になる。\n var time = new Date(Date.now() + a * 60000);\n \n console.log(time)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T15:35:55.237", "id": "11905", "last_activity_date": "2015-06-30T15:35:55.237", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7831", "parent_id": "11903", "post_type": "answer", "score": 1 } ]
11903
11905
11904
{ "accepted_answer_id": "16308", "answer_count": 1, "body": "現在AppleWatchアプリの開発を行っています。 \nWatchKitのopenparentapplicationを利用してiPhone側でプッシュ通知を送る機能を実装しているのですが、iPhoneの状態がフォアグラウンドもしくはバックグラウンドで動いている場合しか動作しません。アプリがterminatedの状態でもopenparentapplicationメソッドを使えばiPhone側ではアプリがバックグラウンドで起動されるとリファレンスには書いてあるのですがうまくいきません。何かアドバイスをいただけると幸いです。\n\n```\n\n func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {\n \n self.backgroundTaskIdentifier =\n UIApplication.sharedApplication().beginBackgroundTaskWithName(\n \"MyTask\",\n expirationHandler: {\n print(\"Background task is expired now\")\n })\n \n dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {\n //長めの処理\n }\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T01:11:01.920", "favorite_count": 0, "id": "11911", "last_activity_date": "2015-09-09T08:23:13.607", "last_edit_date": "2015-07-08T15:51:41.480", "last_editor_user_id": "8000", "owner_user_id": "5346", "post_type": "question", "score": 3, "tags": [ "ios", "swift", "watchkit" ], "title": "親アプリがterminatedの際にopenparentapplicationが作動しない件", "view_count": 179 }
[ { "body": "遅いレスで恐縮ですが、私もこの件でかなり悩みましたが、結局解決することができませんでした。まわりのハイスキルなエンジニアさんたちも同じことを言ってましたので、おそらくopenParentApplicationにはバグがあったのではないかと思います。\n\nwatchOS2のWatchConnectivityを使い始めましたが、こちらは今のところいい感じで動いてますので、今後はこちらを使い、既存ユーザーにはなるべく早くwatchOS2へのアップデートをお願いするのが得策かと思います。\n\nちなみに、私のwatchOS1アプリをwatchOS2へ対応させたときのログをもとに、[Qiitaにtips](http://qiita.com/sassymanyuichi/items/ed32c5a10bdc1b799c6a)を書きましたので、もしよければご参考にされて下さい。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-09-06T11:59:05.707", "id": "16308", "last_activity_date": "2015-09-09T08:23:13.607", "last_edit_date": "2015-09-09T08:23:13.607", "last_editor_user_id": "682", "owner_user_id": "682", "parent_id": "11911", "post_type": "answer", "score": 2 } ]
11911
16308
16308
{ "accepted_answer_id": null, "answer_count": 0, "body": "以下のような構造のJSONをObjective-Cで生成したいと考えております。\n\n```\n\n {{\"category\":\"picture1\",\"name\":\"test1\"},{\"category\":\"picture2\",\"name\":\"test2\"},....}\n \n```\n\n`{\"category\":\"picture1\",\"name\":\"test1\"}` の部分を一旦配列に入れて JSON\nにする方法を試したのですが、配列に格納すると以下のように `[]` に囲まれる構造になってしまいます。\n\n```\n\n {[{\"category\":\"picture1\",\"name\":\"test1\"},{\"category\":\"picture2\",\"name\":\"test2\"},....]}\n \n```\n\n冒頭の JSON のような形式にするためには、配列を使用せずに、 NSDictionary の中に NSDictionary\nを羅列するような構造にすれば良いと思うのですが、やり方が思いつかずに困っております。\n\nこれを実現する方法がありましたら、ご教授いただきたく思います。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2015-07-01T02:13:19.503", "favorite_count": 0, "id": "11913", "last_activity_date": "2019-05-04T17:06:10.993", "last_edit_date": "2019-05-04T17:06:10.993", "last_editor_user_id": "32986", "owner_user_id": "8682", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c", "json" ], "title": "iOSでのJSONを生成する際の構造について", "view_count": 305 }
[]
11913
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "NullReferenceException はハンドルされませんでした。 \nオブジェクト参照がオブジェクト インスタンスに設定されていません。 \nとエラーが出ます。\n\nmi1.cs\n\n```\n\n namespace mip\n {\n public enum enumMessageType\n {\n mtA, mtB, mtC, ...\n }\n 後略\n \n```\n\nForm1.cs\n\n```\n\n namespace mipTest\n {\n public partial class Form1 : Form\n {\n private void btnInsert_Click(object sender, EventArgs e)\n {\n QueueInfo qi = new QueueInfo();\n qi.COmmandInfo.MessageType = enumMessageType.mtA; ←ここでエラーがでます。\n 後略\n \n```\n\n解決の手がかりはありますでしょうか。 \nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T03:42:37.277", "favorite_count": 0, "id": "11914", "last_activity_date": "2015-07-01T06:11:12.427", "last_edit_date": "2015-07-01T06:11:12.427", "last_editor_user_id": "8000", "owner_user_id": "9674", "post_type": "question", "score": 0, "tags": [ "c#" ], "title": "C#, 列挙型で NullReferenceException はハンドルされませんでした。", "view_count": 3462 }
[ { "body": "デバッグ実行を行い、エラーが発生する行でブレークし、 Null になっているものを探してください。\n\n見た感じ、QueueInfoクラスのCOmmandInfoメンバ変数が初期化されていない可能性が高いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T03:53:54.590", "id": "11915", "last_activity_date": "2015-07-01T03:53:54.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4391", "parent_id": "11914", "post_type": "answer", "score": 1 } ]
11914
null
11915
{ "accepted_answer_id": null, "answer_count": 2, "body": "CentOS 7.1.1503にMariaDBをインストールし、`systemctl start mysql`をしましたが起動できませんでした。\n\nこちらのサイトを参考に作業しました。 \n<http://love-\nzawa.hatenablog.com/entry/2014/07/24/CentOS_6_5%E3%81%ABMariaDB_10_0_12%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB(yum%E3%82%92%E4%BD%BF%E7%94%A8)>\n\n```\n\n # vim /etc/yum.repos.d/mariadb.repo\n [mariadb]\n name = MariaDB\n baseurl = http://yum.mariadb.org/10.0.20/centos7-amd64\n gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB\n gpgcheck=1\n enabled=1\n \n```\n\n> これで問題なければインストールは完了です。「Transaction Check Error:」とかが出たら、mysql-libsを削除すると良いそうな。\n\n途中Transaction Check Error:が出てしまったのでmysql-libsは削除しました。\n\n`systemctl start mysql`の結果は\n\n```\n\n # systemctl start mysql\n Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.\n \n```\n\n`systemctl status mysql`とか`journalctl -xn`の結果は\n\n```\n\n # systemctl status mysql\n mysql.service - LSB: start and stop MySQL\n Loaded: loaded (/etc/rc.d/init.d/mysql)\n Active: failed (Result: exit-code) since 水 2015-07-01 12:12:03 JST; 6min ago\n Process: 6341 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=1/FAILURE)\n \n 7月 01 12:12:02 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL...\n 7月 01 12:12:03 localhost.localdomain mysql[6341]: Starting MySQL. ERROR!\n 7月 01 12:12:03 localhost.localdomain systemd[1]: mysql.service: control process exited, code=exited status=1\n 7月 01 12:12:03 localhost.localdomain systemd[1]: Failed to start LSB: start and stop MySQL.\n 7月 01 12:12:03 localhost.localdomain systemd[1]: Unit mysql.service entered failed state.\n \n \n # journalctl -xn\n -- Logs begin at 水 2015-07-01 01:58:42 JST, end at 水 2015-07-01 12:20:01 JST. --\n 7月 01 12:17:12 localhost.localdomain avahi-daemon[597]: Withdrawing address record for fe80::a00:27ff:fe51:68d4\n 7月 01 12:19:29 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL...\n -- Subject: Unit mysql.service has begun with start-up\n -- Defined-By: systemd\n -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel\n -- \n -- Unit mysql.service has begun starting up.\n 7月 01 12:19:30 localhost.localdomain mysql[6869]: Starting MySQL. ERROR!\n 7月 01 12:19:30 localhost.localdomain systemd[1]: mysql.service: control process exited, code=exited status=1\n 7月 01 12:19:30 localhost.localdomain systemd[1]: Failed to start LSB: start and stop MySQL.\n -- Subject: Unit mysql.service has failed\n -- Defined-By: systemd\n -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel\n -- \n -- Unit mysql.service has failed.\n -- \n -- The result is failed.\n 7月 01 12:19:30 localhost.localdomain systemd[1]: Unit mysql.service entered failed state.\n -- Logs begin at 水 2015-07-01 01:58:42 JST, end at 水 2015-07-01 12:20:01 JST. --\n 7月 01 12:17:12 localhost.localdomain avahi-daemon[597]: Withdrawing address record for fe80::a00:27ff:fe51:68d4\n 7月 01 12:19:29 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL...\n -- Subject: Unit mysql.service has begun with start-up\n -- Defined-By: systemd\n -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel\n -- \n -- Unit mysql.service has begun starting up.\n 7月 01 12:19:30 localhost.localdomain mysql[6869]: Starting MySQL. ERROR!\n 7月 01 12:19:30 localhost.localdomain systemd[1]: mysql.service: control process exited, code=exited status=1\n 7月 01 12:19:30 localhost.localdomain systemd[1]: Failed to start LSB: start and stop MySQL.\n -- Subject: Unit mysql.service has failed\n -- Defined-By: systemd\n -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel\n -- \n -- Unit mysql.service has failed.\n -- \n -- The result is failed.\n 7月 01 12:19:30 localhost.localdomain systemd[1]: Unit mysql.service entered failed state.\n 7月 01 12:20:01 localhost.localdomain systemd[1]: Created slice user-0.slice.\n -- Subject: Unit user-0.slice has finished start-up\n -- Defined-By: systemd\n -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel\n -- \n -- Unit user-0.slice has finished starting up.\n -- \n -- The start-up result is done.\n 7月 01 12:20:01 localhost.localdomain systemd[1]: Starting Session 10 of user root.\n -- Subject: Unit session-10.scope has begun with start-up\n -- Defined-By: systemd\n -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel\n -- \n -- Unit session-10.scope has begun starting up.\n 7月 01 12:20:01 localhost.localdomain systemd[1]: Started Session 10 of user root.\n -- Subject: Unit session-10.scope has finished start-up\n -- Defined-By: systemd\n -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel\n -- \n -- Unit session-10.scope has finished starting up.\n -- \n -- The start-up result is done.\n 7月 01 12:20:01 localhost.localdomain CROND[6983]: (root) CMD (/usr/lib64/sa/sa1 1 1)\n \n```\n\nでした。情報が少ないので苦戦しています。\n\n* * *\n```\n\n # mysqladmin ping\n mysqladmin: connect to server at 'localhost' failed\n error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 \"No such file or directory\")'\n Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!\n \n```\n\n* * *\n\n> /var/lib/mysql/ホスト名.err ファイルに何かエラーの原因が記録されているかもしれません。\n>\n> また、mysql-libs は CentOS 7.1 にはありません。mariadb-libs (5.5.41) でしょうか? \n> mysql.com など別のリポジトリのものでしょうか? \n> CentOS 7.1 の mariadb-libs であれば、MariaDB-shared\n> がインストールされるときに置き換わるので、手動でアンインストールする必要はないはず。\n```\n\n # cat localhost.localdomain.err\n 150703 09:46:47 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql\n 150703 9:46:47 [Note] /usr/sbin/mysqld (mysqld 10.0.20-MariaDB) starting as process 8775 ...\n 150703 9:46:47 [Note] InnoDB: Using mutexes to ref count buffer pool pages\n 150703 9:46:47 [Note] InnoDB: The InnoDB memory heap is disabled\n 150703 9:46:47 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins\n 150703 9:46:47 [Note] InnoDB: Memory barrier is not used\n 150703 9:46:47 [Note] InnoDB: Compressed tables use zlib 1.2.7\n 150703 9:46:47 [Note] InnoDB: Using Linux native AIO\n 150703 9:46:47 [Note] InnoDB: Not using CPU crc32 instructions\n 150703 9:46:47 [Note] InnoDB: Initializing buffer pool, size = 128.0M\n 150703 9:46:47 [Note] InnoDB: Completed initialization of buffer pool\n 150703 9:46:47 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode\n 150703 9:46:47 [ERROR] InnoDB: The system tablespace must be writable!\n 150703 9:46:47 [ERROR] Plugin 'InnoDB' init function returned error.\n 150703 9:46:47 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.\n 150703 9:46:47 [ERROR] mysqld: File '/var/lib/mysql/aria_log_control' not found (Errcode: 13 \"Permission denied\")\n 150703 9:46:47 [ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/var/lib/mysql/aria_log_control'\n 150703 9:46:47 [ERROR] Plugin 'Aria' init function returned error.\n 150703 9:46:47 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.\n 150703 9:46:47 [Note] Plugin 'FEEDBACK' is disabled.\n 150703 9:46:47 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.\n 150703 9:46:47 [ERROR] Unknown/unsupported storage engine: InnoDB\n 150703 9:46:47 [ERROR] Aborting\n \n 150703 9:46:47 [Note] /usr/sbin/mysqld: Shutdown complete\n \n 150703 09:46:47 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended\n \n```\n\n`./ibdata1`の書き込みができないっぽいので所有者/所有グループを変えてみました。\n\n```\n\n # cd /var/lib/mysql\n # ls -l\n 合計 110644\n -rw-rw----. 1 root root 16384 7月 1 11:44 aria_log.00000001\n -rw-rw----. 1 root root 52 7月 1 11:44 aria_log_control\n -rw-rw----. 1 root root 50331648 7月 1 11:44 ib_logfile0\n -rw-rw----. 1 root root 50331648 7月 1 11:44 ib_logfile1\n -rw-rw----. 1 root root 12582912 7月 1 11:44 ibdata1\n -rw-r-----. 1 mysql root 22584 7月 3 09:46 localhost.localdomain.err\n drwx------. 2 root root 4096 7月 1 11:44 mysql\n drwx------. 2 root root 4096 7月 1 11:44 performance_schema\n drwx------. 2 root root 6 7月 1 11:44 test\n \n # cd ../\n # chown mysql:mysql mysql -R\n \n```\n\nこれで`systemctl start mysql`を実行したところ、うまくいきました!\n\n```\n\n # systemctl start mysql\n # systemctl status mysql\n mysql.service - LSB: start and stop MySQL\n Loaded: loaded (/etc/rc.d/init.d/mysql)\n Active: active (running) since 金 2015-07-03 09:50:42 JST; 12s ago\n Process: 20024 ExecStart=/etc/rc.d/init.d/mysql start (code=exited, status=0/SUCCESS)\n CGroup: /system.slice/mysql.service\n ├─20029 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/...\n └─20102 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-...\n \n 7月 03 09:50:40 localhost.localdomain systemd[1]: Starting LSB: start and stop MyS....\n 7月 03 09:50:42 localhost.localdomain mysql[20024]: Starting MySQL. SUCCESS!\n 7月 03 09:50:42 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.\n Hint: Some lines were ellipsized, use -l to show in full.\n \n```\n\nmariaDBの起動後は`mysql.sock`ができました\n\n```\n\n # ls -l\n 合計 110648\n -rw-rw----. 1 mysql mysql 16384 7月 1 11:44 aria_log.00000001\n -rw-rw----. 1 mysql mysql 52 7月 1 11:44 aria_log_control\n -rw-rw----. 1 mysql mysql 50331648 7月 3 09:50 ib_logfile0\n -rw-rw----. 1 mysql mysql 50331648 7月 1 11:44 ib_logfile1\n -rw-rw----. 1 mysql mysql 12582912 7月 3 09:50 ibdata1\n -rw-r-----. 1 mysql mysql 24010 7月 3 09:50 localhost.localdomain.err\n -rw-rw----. 1 mysql mysql 6 7月 3 09:50 localhost.localdomain.pid\n -rw-rw----. 1 mysql mysql 0 7月 3 09:50 multi-master.info\n drwx------. 2 mysql mysql 4096 7月 1 11:44 mysql\n srwxrwxrwx. 1 mysql mysql 0 7月 3 09:50 mysql.sock\n drwx------. 2 mysql mysql 4096 7月 1 11:44 performance_schema\n drwx------. 2 mysql mysql 6 7月 1 11:44 test\n \n```\n\n起動の確認\n\n```\n\n # mysql\n Welcome to the MariaDB monitor. Commands end with ; or \\g.\n Your MariaDB connection id is 3\n Server version: 10.0.20-MariaDB MariaDB Server\n \n Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.\n \n Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n \n```\n\nmysql-libsはmysql.comのものです。 \nmariaDBをインストールする前にやったことを簡単にご説明いたしますと、以前MySQLをインストールしました。しかし起動に`error: 'Can't\nconnect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2\n\"No such file or\ndirectory\")'`とのエラーが出て、解決できずに放置しておりました。それでとりあえずmariaDBに移行してみようと思ったのです。ちなみにこのCentOS7.1はVirtualBoxで動かしてるものです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T04:11:52.157", "favorite_count": 0, "id": "11916", "last_activity_date": "2015-08-02T10:09:44.850", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "10357", "post_type": "question", "score": 2, "tags": [ "mysql", "centos" ], "title": "[解決済み]MariaDBの起動に失敗する", "view_count": 43206 }
[ { "body": "あいにくファイル現物が手元にないので、ここだ、というのは特定できませんが\n\nsystemctl status\nmysqlの出力によれば/etc/rc.d/init.d/mysqlをExecStartしたときのプロセスidは6341で、そのプロセス6341は\n\n```\n\n 7月 01 12:12:03 localhost.localdomain mysql[6341]: Starting MySQL. ERROR!\n \n```\n\nと言って止まっているので、/etc/rc.d/init.d/mysqlの中でERROR!というメッセージを出す判定をしているところを見つければ原因もわかると思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T07:43:06.573", "id": "11926", "last_activity_date": "2015-07-01T07:43:06.573", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8136", "parent_id": "11916", "post_type": "answer", "score": 1 }, { "body": "/var/lib/mysql/ホスト名.err ファイルに何かエラーの原因が記録されているかもしれません。\n\nまた、mysql-libs は CentOS 7.1 にはありません。mariadb-libs (5.5.41) でしょうか? \nmysql.com など別のリポジトリのものでしょうか? \nCentOS 7.1 の mariadb-libs であれば、MariaDB-shared\nがインストールされるときに置き換わるので、手動でアンインストールする必要はないはず。\n\n念のため、RPM が正しくインストールされているか、ファイルに破損がないか調べるといいと思います。\n\n```\n\n # rpm -qa \"MariaDB*\"\n MariaDB-shared-10.0.20-1.el7.centos.x86_64\n MariaDB-common-10.0.20-1.el7.centos.x86_64\n MariaDB-server-10.0.20-1.el7.centos.x86_64\n MariaDB-client-10.0.20-1.el7.centos.x86_64\n \n # rpm -Va \"MariaDB*\"\n (修正した設定ファイル以外、出力されない) \n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T09:51:20.360", "id": "11960", "last_activity_date": "2015-07-02T09:51:20.360", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4603", "parent_id": "11916", "post_type": "answer", "score": 1 } ]
11916
null
11926
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在、swiftで簡単なスクロービュー(スライドすると、次の写真にすすむ)を作っています。画像表示はできたのですが、画像が画面いっぱいに伸びきった状態でアスペクト比を整えたきれいな表示ができません。\n\n`scrollView.contentMode = UIViewContentMode.ScaleAspectFit` \nを挿入しているのですが、どこがいけないのでしょうか?\n\nご教授お願いしたします。\n\n```\n\n import UIKit\n \n class ViewController: UIViewController {\n var scrollView: UIScrollView!\n var pageImagesArr = [\"1.jpg\",\"2.jpg\",\"3.jpg\"];\n \n override func viewDidLoad() {\n super.viewDidLoad()\n let width = self.view.frame.maxX, height = self.view.frame.maxY\n let pageSize = self.pageImagesArr.count;\n \n //ScrollViewの作成\n scrollView = UIScrollView(frame: self.view.frame)\n scrollView.pagingEnabled = true\n scrollView.frame = CGRectMake(0,0,width,height);\n scrollView.contentSize = CGSizeMake(CGFloat(pageSize) * width, 0)\n __scrollView.contentMode = UIViewContentMode.ScaleAspectFit__\n \n //各ページの作成\n for var i = 0; i < pageSize; i++ {\n let img:UIImage = UIImage(named:self.pageImagesArr[i])!;\n let iv:UIImageView = UIImageView(image:img);\n iv.frame = CGRectMake(CGFloat(i) * width, 0, width, height);\n scrollView.addSubview(iv)\n }\n self.view.addSubview(scrollView)\n }\n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T04:30:22.187", "favorite_count": 0, "id": "11917", "last_activity_date": "2015-07-01T05:10:14.010", "last_edit_date": "2015-07-01T05:03:53.130", "last_editor_user_id": "3516", "owner_user_id": "9427", "post_type": "question", "score": 1, "tags": [ "swift" ], "title": "swiftでスクロールビュー", "view_count": 269 }
[ { "body": "手元で確認できなくて申し訳ないのですが、 \nUIImageViewにAspectFitを設定してみたらどうですか?\n\n```\n\n //各ページの作成\n for var i = 0; i < pageSize; i++ {\n let img:UIImage = UIImage(named:self.pageImagesArr[i])!;\n let iv:UIImageView = UIImageView(image:img);\n // 画像のアスペクト比を保持する\n iv.contentMode = UIViewContentMode.ScaleAspectFit\n iv.frame = CGRectMake(CGFloat(i) * width, 0, width, height);\n scrollView.addSubview(iv)\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T05:10:14.010", "id": "11919", "last_activity_date": "2015-07-01T05:10:14.010", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3516", "parent_id": "11917", "post_type": "answer", "score": 1 } ]
11917
null
11919
{ "accepted_answer_id": "11966", "answer_count": 1, "body": "2つのファイルをハッシュに格納して重複するキーを作成してからマージしたいのですが、出力ファイルのようにデリファレンスできていないデータが表示されます。どうすれば、ファイルにデータが正常通り出力されますか?\n\n出力したい内容:キーを1項目目として、重複するキーを削除して2項目、3項目目を足し合わせます。 \n4項目目は最新の月を表示したいです。5項目目はそのまま出力します。\n\n```\n\n ・入力ファイル01\n きゅうり,7800,40,20150629,a\n 牛乳,10000,24,20150629,b\n 水,5000,48,2015029,b\n にんじん,6500,30,20150629,a\n きゅうり,4800,20,20150628,a\n \n \n ・入力ファイル02\n きゅうり,7800,40,20150630,a\n にんじん,6500,30,20150630,a\n 牛乳,5000,12,20150630,b\n 水,2500,24,20150630,b\n 水,2500,24,20150627,b\n にんじん,3500,15,20150630,a\n \n \n ・出力ファイル01\n きゅうりARRAY(0x204bbf0)\n 牛乳ARRAY(0x204bd70)きゅうりARRAY(0x204bbf0)\n 水ARRAY(0x204bfc8)牛乳ARRAY(0x204bd70)きゅうりARRAY(0x204bbf0)\n 水ARRAY(0x204bfc8)牛乳ARRAY(0x204bd70)にんじんARRAY(0x55a1a8)きゅうりARRAY(0x204bbf0)\n 水ARRAY(0x204bfc8)牛乳ARRAY(0x204bd70)にんじんARRAY(0x55a1a8)きゅうりARRAY(0x204be90)\n \n \n ・出力ファイル02\n きゅうりARRAY(0x204bed8)\n にんじんARRAY(0x561e08)きゅうりARRAY(0x204bed8)\n 牛乳ARRAY(0x482d28)にんじんARRAY(0x561e08)きゅうりARRAY(0x204bed8)\n 水ARRAY(0x561dc0)牛乳ARRAY(0x482d28)にんじんARRAY(0x561e08)きゅうりARRAY(0x204bed8)\n 水ARRAY(0x204bcb0)牛乳ARRAY(0x482d28)にんじんARRAY(0x561e08)きゅうりARRAY(0x204bed8)\n 水ARRAY(0x204bcb0)牛乳ARRAY(0x482d28)にんじんARRAY(0x561dc0)きゅうりARRAY(0x204bed8)\n \n \n use strict;\n use warnings; \n \n # 処理開始\n my $input_FILE = \"sales.txt\";\n my $input_FILE_2 = \"sales_2.txt\";\n \n my $output_FILE = $input_FILE.\".cyoufuku\";\n my $output_FILE_2 = $input_FILE_2.\".cyoufuku\";\n \n cyofuku_CHAECK($input_FILE, $output_FILE);\n cyofuku_CHAECK($input_FILE_2, $output_FILE_2);\n \n sub cyofuku_CHAECK\n {\n my $f_input = shift; #--- 入力ファイル名\n my $f_output = shift; #--- 出力ファイル名\n \n # 変数定義\n my $rec = \"\";\n my %data = ();\n \n #### ファイルオープン ####\n open my $fh_in , \"<:encoding(utf8)\" ,$f_input or die;\n open my $fh_out , \">:encoding(utf8)\" ,$f_output or die;\n \n #### [処理内容記述] ####\n while($rec = <$fh_in>){\n \n my @InRecord = ();\n \n chomp $rec;\n \n @InRecord = split(/,/,$rec,-1);\n \n my $key = $InRecord[0];\n \n $data{$key} = [ \\@InRecord ]; \n \n print $fh_out %data,\"\\n\";\n }\n \n return 1;\n \n```\n\n}", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T07:01:15.107", "favorite_count": 0, "id": "11925", "last_activity_date": "2015-07-02T12:30:16.587", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9088", "post_type": "question", "score": -2, "tags": [ "perl" ], "title": "perlのハッシュで重複するキーの削除と足し合わせ", "view_count": 1691 }
[ { "body": "書き方は色々あると思いますが、一例として次の様な感じ。\n\n```\n\n &cyofuku_CHECK($input_FILE, $output_FILE);\n &cyofuku_CHECK($input_FILE_2, $output_FILE_2);\n \n sub cyofuku_CHECK($$){\n my $f_input = shift; #--- 入力ファイル名\n my $f_output = shift; #--- 出力ファイル名\n \n my %data = ();\n \n open my $fh_in , \"<:encoding(utf8)\", $f_input or die;\n open my $fh_out, \">:encoding(utf8)\", $f_output or die;\n \n while(<$fh_in>){\n chomp;\n \n my ($key, @InRecord) = split(/,/, $_, -1);\n if($data{$key}){ #既にキーが存在する\n $data{$key}->[0] += $InRecord[0];\n $data{$key}->[1] += $InRecord[1];\n $data{$key}->[2] = $InRecord[2] if $data{$key}->[2] < $InRecord[2];\n $data{$key}->[3] = $InRecord[3]; #単に上書き\n } else { #まだ同じキーが存在しない\n $data{$key} = \\@InRecord;\n }\n }\n foreach my $key (keys %data){\n print $fh_out join(',', $key, @{$data{$key}}),\"\\n\";#連結して書きだし\n }\n close $fh_in;\n close $fh_out;\n return 1;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T12:30:16.587", "id": "11966", "last_activity_date": "2015-07-02T12:30:16.587", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "11925", "post_type": "answer", "score": 1 } ]
11925
11966
11966
{ "accepted_answer_id": "11928", "answer_count": 1, "body": "```\n\n import java.io.*;\n class sample44{\n public static void main(String[] args){\n \n kasan1 obj1 = new kasan1();\n obj1.a = 10;\n obj1.b = 20;\n int ans1 = obj1.tasu(10,20);\n System.out.println(ans1);\n \n kasan1 obj2 = new kasan1();\n obj2.a = 30;\n obj2.b = 40;\n int ans2 = obj2.tasu(30,40);\n System.out.println(ans2);\n }\n }\n \n```\n\nkasan1\n\n```\n\n class kasan1{\n \n // int a;\n // int b;\n int c;\n \n void tasu(int a, int b){\n int c = a + b;\n return c;\n }\n }\n \n```\n\ncmdでのエラー\n\nsample44.java:6: エラー: シンボルを見つけられません obj1.a = 10; \n^ シンボル: 変数 a 場所: タイプkasan1の変数 obj1 sample44.java:7: エラー: シンボルを見つけられません obj1.b\n= 20; \n^ シンボル: 変数 b 場所: タイプkasan1の変数 obj1 sample44.java:8: エラー: 互換性のない型 int ans1 =\nobj1.tasu(10,20); \n^ 期待値: int 検出値: void sample44.java:12: エラー: シンボルを見つけられません obj2.a = 30; \n^ シンボル: 変数 a 場所: タイプkasan1の変数 obj2 sample44.java:13: エラー: シンボルを見つけられません obj2.b\n= 40; \n^ シンボル: 変数 b 場所: タイプkasan1の変数 obj2 sample44.java:14: エラー: 互換性のない型 int ans2 =\nobj2.tasu(30,40); \n^ 期待値: int 検出値: void .\\kasan1.java:9: エラー: 戻り値の型がvoidのメソッドからは値を返せません return c; \n^ エラー:7個\n\nどこが問題なんでしょうか?\n\nわかる方お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T08:22:04.580", "favorite_count": 0, "id": "11927", "last_activity_date": "2015-07-01T08:34:41.140", "last_edit_date": "2015-07-01T08:25:43.357", "last_editor_user_id": "5044", "owner_user_id": "10289", "post_type": "question", "score": 1, "tags": [ "java" ], "title": "kasan1及びsample44のエラーについて", "view_count": 142 }
[ { "body": "1. `a` と `b` がコメントアウトされている。\n``` // int a;\n\n // int b;\n \n```\n\nコメントをはずす\n\n``` int a;\n\n int b;\n \n```\n\n 2. `void tasu(int a, int b){` で、メソッド`tasu` が期待される返値は`int`なのに`void`で「値を返さない」となっている。\n\n`int` に変更する\n\n``` int tasu(int a, int b){\n\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T08:34:41.140", "id": "11928", "last_activity_date": "2015-07-01T08:34:41.140", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "11927", "post_type": "answer", "score": 1 } ]
11927
11928
11928
{ "accepted_answer_id": "30785", "answer_count": 2, "body": "Ruby 2.2.2、Rails 4.2.1 にて以下のやり方でログを出力しています。\n\nconfig/development.rb\n\n```\n\n config.logger = Logger.new('log/my.log', 'daily')\n config.log_formatter = Logger::Formatter.new\n \n```\n\nログ出力コード\n\n```\n\n Rails.logger.info \"hogehoge\"\n \n```\n\nログは出力されるのですが、日をまたいでも初めのmy.logに追記されていき、ローテーションされません。開発しながらなので、サーバーは常時起動ではなく、止めたり、起動したりしています。\n\nバッチ的な処理をrailsで書いていて、cronで定期的にURLにアクセスして、処理をして終わるということをしています。\n\n処理は複数スレッドで内部で並列化しています。(常駐スレッドはなし)\n\nテスト環境の別サーバーは常時稼働していますが、同様に初めのファイルに追記されローテーションされません。\n\nためしに、 dailyをやめて、\n\n```\n\n config.logger = Logger.new('log/my.log', 5, 1 * 1024)\n \n```\n\nのようにサイズ指定にしてみましたが、やはりローテーションされず、かつ今度はログ出力がとても遅くなり、全体的に処理が重くなっているように見えます。\n\nできれば、dailyでログを回したいのですが、どなたか参考情報などありますでしょうか?\n\nLogger自体スレッドセーフだと思ったのですが、マルチスレッド処理が弊害を起こしていますかね?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T08:34:56.267", "favorite_count": 0, "id": "11929", "last_activity_date": "2016-11-30T02:03:37.343", "last_edit_date": "2015-07-06T07:34:39.787", "last_editor_user_id": "9260", "owner_user_id": "9260", "post_type": "question", "score": 2, "tags": [ "ruby-on-rails" ], "title": "Rails loggerがローテーションしない", "view_count": 4164 }
[ { "body": "> サーバーは常時起動ではなく、止めたり、起動したりしています。\n\nに関しては、サーバの起動時に次回のローテーション時刻を設定しているため、 \nサーバを止めると無効になると考えます。\n\nLogger.new の際に、 \nLogDevice.new され、 \n`@next_rotate_time` に更新日が記憶され、 \n`write` の度に、`check_shift_log` を行い、 \n`next_rotate_time` に達していたら、`shift_log_period` で今のファイルをローテーションする、 \nという動作のようです。\n\n[ruby/logger.rb at trunk ·\nruby/ruby](https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L589)\n\n```\n\n class LogDevice\n def initialize(log = nil, opt = {})\n # ...\n @dev = open_logfile(log)\n # ...\n @shift_age = opt[:shift_age] || 7\n # ...\n @next_rotate_time = next_rotate_time(Time.now, @shift_age) unless @shift_age.is_a?(Integer)\n end\n \n def write(message)\n begin\n @mutex.synchronize do\n if @shift_age and @dev.respond_to?(:stat)\n begin\n check_shift_log\n ...\n \n def check_shift_log\n if @shift_age.is_a?(Integer)\n # Note: always returns false if '0'.\n if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)\n lock_shift_log { shift_log_age }\n end\n else\n now = Time.now\n if now >= @next_rotate_time\n @next_rotate_time = next_rotate_time(now, @shift_age)\n lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) }\n end\n end\n end\n \n```\n\n> テスト環境の別サーバーは常時稼働して\n\nということですが、例えば Rails.env が異なる、などといったことは無いでしょうか?\n\n# 追記\n\n> daily=24時間ってことですかね?\n> 自分はカレンダ情報だと思っていたのですが、24時間だと、24時間いないに毎回サーバー落としていたらローテーションされない仕組みですよね?\n\n参照が不足していたようで、スミマセン。 \n`daily` など文字列で指定した場合は特殊処理をしており、24時間ではなく、日が変わるまでです。\n\n```\n\n SiD = 24 * 60 * 60\n \n def next_rotate_time(now, shift_age)\n case shift_age\n when /^daily$/\n t = Time.mktime(now.year, now.month, now.mday) + SiD\n \n```\n\n例えば、2015-07-03 の 9:00 にサーバを起動しても、23:00 に起動しても、 \n同じく 2015-07-04 には切り替わります。\n\n>\n> Rails.loggerとlogger(コントローラ以外だとRailsをつけないと呼べないってどこかで見ましたが)って、参照してるメソッド(実体)は同じですよね‌​?\n\n`environment.rb` で下記のように設定されていることと思います。 \nこれは、Rails の logger に、Logger クラスを代入しているので、同じものと考えました。\n\n```\n\n config.logger = Logger.new('log/my.log', 'daily')\n \n```\n\n別の logger を使っていれば、そちらの挙動になると考えます。\n\n```\n\n # environment.rb の sample に記載の例\n config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T14:04:56.917", "id": "11934", "last_activity_date": "2015-07-03T14:51:41.707", "last_edit_date": "2015-07-03T14:51:41.707", "last_editor_user_id": "7471", "owner_user_id": "7471", "parent_id": "11929", "post_type": "answer", "score": 2 }, { "body": "dailyを指定するとローテートしないのは、Ruby 2.2以降のLoggerのバグだったようです。 \n修正パッチが登録されていました。\n\n<https://github.com/ruby/ruby/commit/f6e77b9d3555c1fbaa8aab1cdc0bd6bde95f62c6>\n\nbugs.ruby-lang.org の Bug #12948 と、リビジョン 56815 の変更です。\n\n私の手元の環境(ruby 2.2.1p85, Rails 4.2.1)で同様の現象が起きていましたが、 \n上記の修正を行った所、dailyでローテートするようになりました。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-11-30T02:03:37.343", "id": "30785", "last_activity_date": "2016-11-30T02:03:37.343", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19776", "parent_id": "11929", "post_type": "answer", "score": 3 } ]
11929
30785
30785
{ "accepted_answer_id": "11965", "answer_count": 1, "body": "以下のサイトでJava Appletではダイアログ表示ができることがわかりました。 \n<http://syunpon.com/programing/java/sample/applet/dialogsample.shtml>\n\n現在このダイアログにセレクトボックスを設置して値を取得したりしたいのですがどのようにすれば良いでしょうか?\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T16:15:25.633", "favorite_count": 0, "id": "11935", "last_activity_date": "2015-07-02T12:29:12.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9577", "post_type": "question", "score": 1, "tags": [ "java" ], "title": "Java Appletでセレクトボックス付きのダイアログ作成", "view_count": 277 }
[ { "body": "こんなコードはいかがでしょう。 \n[コードの参照元](http://www1.megaegg.ne.jp/~yasu/Programmer%27s%20Page/swing/JOptionPane/JOptionPane.html)\n\n```\n\n import java.awt.Container;\n import java.awt.BorderLayout;\n import javax.swing.JApplet;\n import javax.swing.JLabel;\n import javax.swing.JOptionPane;\n \n public class DialogSample extends JApplet {\n private static final long serialVersionUID = 1L;\n private static Container c;\n public void init() {\n c = getContentPane();\n JLabel label = new JLabel(\"未入力です\");\n c.add(label, BorderLayout.CENTER);\n \n String selectvalues[] = {\"10代\", \"20代\", \"30代\", \"40代\",\"50以上\"};\n Object ans = JOptionPane.showInputDialog(c, \"あなたの年齢?\", \n \"年齢\", JOptionPane.INFORMATION_MESSAGE,\n null, selectvalues, selectvalues[0]);\n \n if (ans == null){\n label.setText(\"取消されました\");\n }else{\n label.setText(\"あなたの年齢は\" + (String)ans + \"ですね\");\n }\n }\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T12:29:12.210", "id": "11965", "last_activity_date": "2015-07-02T12:29:12.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "11935", "post_type": "answer", "score": 2 } ]
11935
11965
11965
{ "accepted_answer_id": "11940", "answer_count": 3, "body": "Laravel5.0で行数の多いCSVファイルの内容を MySQL の「LOAD DATA local INFILE\n〜」コマンドを使ってデータベースを書き換えようとしています。 \n既存の内容を新しい内容で完全に置き換えるので、一旦内容を truncate\nしてから書き込むようにしていますが、タイムアウトなどで処理が中断されてしまった場合はロールバックさせるために次のようにしました。($destination\nにはファイルの場所が格納されています。)\n\n```\n\n $query = sprintf(\"LOAD DATA local INFILE '%s' INTO TABLE `zip_codes` FIELDS TERMINATED BY ','\n OPTIONALLY ENCLOSED BY '\\\"' ESCAPED BY '\\\"' LINES TERMINATED BY '\\n'\n IGNORE 0 LINES (`zip`, `address1`, `address2`, `address3`)\", addslashes($destination));\n \n $pdo = DB::connection()->getpdo();\n $pdo->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n try {\n $pdo->beginTransaction();\n $pdo->exec(\"TRUNCATE TABLE `zip_codes`\");\n $pdo->exec($query);\n $pdo->commit();\n }catch(\\PDOException $e){\n $pdo->rollBack();\n }\n \n```\n\nわざと存在しないファイル名を指定すると catch 部分は実行されているようですが内容は truncate で消去された状態のままでした。\n\n専用の DB::transaction() や、DB::beginTransaction()、DB::rollback() を使ってみても catch\n処理が行われる前にフレームワーク側で catch されてしまっているようで同じような結果になりました。\n\nこのような場合どのようにしてロールバック処理を行えばいいのでしょうか。 \nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T02:40:30.403", "favorite_count": 0, "id": "11937", "last_activity_date": "2015-07-02T04:41:17.757", "last_edit_date": "2015-07-02T04:41:17.757", "last_editor_user_id": "10083", "owner_user_id": "10083", "post_type": "question", "score": 3, "tags": [ "php", "mysql" ], "title": "MySQLでPDOのエラー時にロールバックされない", "view_count": 1685 }
[ { "body": "ファイルが存在しない時は、PDOException以外のExceptionが上がってきているかも知れません。まずは、Exceptionクラスをハンドリングしてチェックしてみては?\n\n```\n\n try {\n $pdo->beginTransaction();\n $pdo->exec(\"TRUNCATE TABLE `zip_codes`\");\n $pdo->exec($query);\n } catch (\\PDOException $e) {\n dd(get_class($e));\n \n $pdo->rollBack();\n } catch (\\Exception $e) {\n dd(get_class($e));\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T03:17:23.920", "id": "11939", "last_activity_date": "2015-07-02T03:17:23.920", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9529", "parent_id": "11937", "post_type": "answer", "score": 3 }, { "body": "(コメントに書いていましたが、Whoopsに関する記述が削除されたようなので回答にします)\n\nMySQL では TRUNCATE\n時に自動でコミットが行われます。したがってTRUNCATE自体はもちろん、それ以前に行った操作も、TRUNCATE後にロールバックすることはできません。\n\n * [MySQL :: MySQL 5.7 Reference Manual :: 13.1.29 TRUNCATE TABLE Syntax](http://dev.mysql.com/doc/refman/5.7/en/truncate-table.html)\n * [TRUNCATE (SQL) - Wikipedia](https://ja.wikipedia.org/wiki/TRUNCATE_\\(SQL\\))\n\nなお、PHPの [`set_exception_handler()`](http://php.net/manual/ja/function.set-\nexception-handler.php) では例外 **発生時**\nにハンドリングすることはできませんから、通常そのようなことはないと考えてよいと思います。\n\n> 例外が try/catch ブロックの中でキャッチされなかった場合の デフォルトの例外ハンドラを設定します。 例外は、exception_handler\n> がコールされた後に 停止します。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T03:52:14.730", "id": "11940", "last_activity_date": "2015-07-02T03:52:14.730", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "11937", "post_type": "answer", "score": 4 }, { "body": "MySQLでは`TRUNCATE`はRollbackできないみたいです。 \n`DELETE`を使うとRollbackできます。\n\n参考サイト \n<http://www.sria.co.jp/blog/2014/08/mysql-can-do-rollback-truncate/>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T03:57:27.600", "id": "11941", "last_activity_date": "2015-07-02T03:57:27.600", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9529", "parent_id": "11937", "post_type": "answer", "score": 5 } ]
11937
11940
11941
{ "accepted_answer_id": null, "answer_count": 1, "body": "`UIImagePickerController`を使ってカメラを実装したのですが、カメラ撮影が終わったことを検知するにはどうすればいいでしょうか?`UIImagePickerController`ではできないのでしょうか?試しに以下のサイトの「AVCaptureStillImageOutputを使用する方法」という記事を参考に組んでみるとカメラ撮影が終わったことを検知できるようになったのですが、iOSのデフォルトのカメラUIではなくなってしまいました。 \n<http://dev.classmethod.jp/smartphone/ios-camera-intro/>\n\nできればデフォルトのカメラを使いたいので`UIImagePickerController`で実装したいのですが、可能でしょうか? \nどなたか分かる方がいれば教えていただきたいです。すみませんが、よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T05:06:29.090", "favorite_count": 0, "id": "11943", "last_activity_date": "2015-08-31T08:25:35.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5210", "post_type": "question", "score": 2, "tags": [ "ios", "objective-c", "uiimagepickercontroller" ], "title": "カメラ撮影が終わったことを検知する", "view_count": 142 }
[ { "body": "UIImagePickerControllerDelegateプロトコルを実装し、 \n- imagePickerController:didFinishPickingMediaWithInfo:メソッドを使えば可能です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T07:08:03.463", "id": "11951", "last_activity_date": "2015-07-02T07:08:03.463", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10370", "parent_id": "11943", "post_type": "answer", "score": 1 } ]
11943
null
11951
{ "accepted_answer_id": null, "answer_count": 2, "body": "お世話になります。\n\n前回の質問から、ろくに時間もかけていないのに申し訳ありません。\n\nPHP+Mysqlで、シミュレーションゲーム的なものを作る際(前回と同じです)、 \n今度は、自分の国から相手の国に攻め込んだ時の様な処理です。\n\n自分のブラウザ側で、相手の国を選択して出陣し、到着(結果が出るのが)が \n30分後だとします。然し、その前に自分側も相手側もブラウザを閉じ、 \n一切手動のデータ更新を行わないながらも、出陣した30分後には、第三者が \n攻められた相手の国がどうなったかを知ることができるような状態の時は、 \n必ずその『30分後』に更新を行わないといけないと思うのですが、こういったことは \nサーバー側に『後~秒後に処理を行う』という仕組みはできるのでしょうか。\n\nただSQLを発行するだけでなく、自分と相手の国のデータを取得し、攻撃力やら \n耐久力やらの計算を行った後、結果をデータベースに反映させたいのです。\n\nこれはもう、mysqlではなく、PHPの問題になるのでしょうか?\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T05:13:35.167", "favorite_count": 0, "id": "11944", "last_activity_date": "2015-07-02T06:40:22.800", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9374", "post_type": "question", "score": 1, "tags": [ "php", "mysql", "sql" ], "title": "特定時間後に処理をさせる方法", "view_count": 341 }
[ { "body": "一般的には出陣を押した時点で勝敗の結果はデータベースに格納されていると思います。 \nその際に閲覧可能時刻(30分後)を合わせて登録しておき、ユーザーがログインした際にその閲覧可能時刻を超えていれば結果を表示し、超えていなければ「出陣中」などの表示をすることになると思います。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T05:24:05.317", "id": "11945", "last_activity_date": "2015-07-02T05:24:05.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10083", "parent_id": "11944", "post_type": "answer", "score": 2 }, { "body": "厳密に時間通りにイベントをこなす例を書きます。\n\n何かイベントが起こったときに、MySQLのテーブルにイベントの種類、イベントの処理を行う時間、それと処理済フラグを0で入れておきます。\n\nそして、誰かがアクセスしたタイミングでテーブルを見て、現在時刻>処理を行う時間、かつ処理済フラグが0のものを時間順に処理し、処理済フラグを立てます。\n\nこれで漏れなく順番にイベントを処理できると思います。\n\n処理済フラグを使わず、処理が終わったレコード自体を削除してしまっても良いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T06:40:22.800", "id": "11950", "last_activity_date": "2015-07-02T06:40:22.800", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2232", "parent_id": "11944", "post_type": "answer", "score": 1 } ]
11944
null
11945
{ "accepted_answer_id": null, "answer_count": 1, "body": "ラズパイカメラで取得した動画をffmpegでエンコード生成したファイルをiPhoneで再生したいのですが、ffmpegで生成したmp4のファイルを再生することはできますか? \niPhoneはmp4形式を再生できるので、そうなるとiPhone側で再生用のアプリを作る場合デコーダーは必要でしょうか? \nもし必要なのであれば、使えそうなデコーダーを教えて欲しいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T05:55:27.357", "favorite_count": 0, "id": "11947", "last_activity_date": "2015-07-06T05:49:16.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9349", "post_type": "question", "score": 1, "tags": [ "ios", "iphone" ], "title": "iPhoneでの動画再生", "view_count": 127 }
[ { "body": "MPMoviePlayerViewController にファイルパスを渡すだけで QuickTime を利用して標準的な動画ファイルが再生可能です。\n\n```\n\n MPMoviePlayerViewController *controller = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:filePath]]; \n \n [controller.moviePlayer setMovieSourceType:MPMovieSourceTypeFile]; \n \n [controller.moviePlayer setRepeatMode:YES]; \n \n [controller.moviePlayer prepareToPlay]; \n \n [self presentMoviePlayerViewControllerAnimated:controller];\n```\n\n`", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T05:49:16.967", "id": "12070", "last_activity_date": "2015-07-06T05:49:16.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7376", "parent_id": "11947", "post_type": "answer", "score": 1 } ]
11947
null
12070
{ "accepted_answer_id": "12038", "answer_count": 2, "body": "Laravel v5.1.4を使っています。 \nLaravelインストーラv1.2.1を使ってプロジェクトを作成すると以下のようにphpunitが\"Permission\ndenied\"でエラーになってしまいます。どの様に対処したらよいでしょうか?\n\n```\n\n $ laravel -V\n Laravel Installer version 1.2.1\n \n $ laravel new project\n $ cd project\n \n $ phpunit\n -bash: ./vendor/bin/phpunit: Permission denied\n \n```\n\nパーミッションを確認すると実行権限がありません。\n\n```\n\n $ ls -l ./vendor/bin\n total 24\n -rw-r--r-- 1 user staff 750 7 2 13:51 phpspec\n -rw-r--r-- 1 user staff 930 7 2 13:51 phpunit\n -rw-r--r-- 1 user staff 3296 7 2 13:51 psysh\n \n```\n\n実行権限を追加してphpunitしてみましたが、新たなエラーが...\n\n```\n\n $ chmod +x ./vendor/bin/phpunit\n $ ls -l ./vendor/bin\n total 24\n -rw-r--r-- 1 user staff 750 7 2 13:51 phpspec\n -rwxr-xr-x 1 user staff 930 7 2 13:51 phpunit\n -rw-r--r-- 1 user staff 3296 7 2 13:51 psysh\n \n $ phpunit\n You need to set up the project dependencies using the following commands:\n wget http://getcomposer.org/composer.phar\n php composer.phar install\n \n```\n\nちなみに、composer経由でのプロジェクト作成ではphpunitはエラーになりません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T06:02:06.457", "favorite_count": 0, "id": "11948", "last_activity_date": "2015-07-07T04:39:27.737", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9529", "post_type": "question", "score": 4, "tags": [ "php", "laravel" ], "title": "Laravelインストーラーでプロジェクトを作成するとphpunitが\"Permission denied\"になる", "view_count": 2984 }
[ { "body": "laravel new [プロジェクト]をするとバグの所為で権限は設定されてないらしいです。\n\nこれら削除してcomposer installしたら行けるはずです。\n\n```\n\n vendor/bin \n vendor/classpreloader \n vendor/phpspec \n vendor/phpunit \n vendor/psy\n \n```\n\nもちろん、作成の時にcomposer create-project laravel/laravelをしたら問題はありません。\n\n一応、イッシューもあります。 <https://github.com/laravel/framework/issues/9491>", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T08:48:28.903", "id": "11957", "last_activity_date": "2015-07-06T03:18:22.177", "last_edit_date": "2015-07-06T03:18:22.177", "last_editor_user_id": "4336", "owner_user_id": "4336", "parent_id": "11948", "post_type": "answer", "score": 0 }, { "body": "本件はインストーラのバグによるものです。 \n以下のように`laravel new`でプロジェクトを作成した場合に発生します。 \nマニュアルに書いてあるので、普通にこのコマンドを使うと思いますが、バグがあります。\n\n```\n\n larval new [project]\n \n```\n\n以下のディレクトリを削除して`composer install`を実行すると復旧します。\n\n```\n\n vendor/bin \n vendor/classpreloader \n vendor/phpspec \n vendor/phpunit \n vendor/psy\n \n```\n\nもしくは、少し時間がかかりますが、`vendor`ディレクトリ全体を削除してから`composer\ninstall`でも復旧します。こちらは細かくディレクトリを指定しなくて良いので、簡単です。\n\nこのバグを踏まない為には、インストーラを使わず`composer`を使ってプロジェクトを作成します。\n\n```\n\n composer create-project laravel/laravel --prefer-dist [project]\n \n```\n\n■ 参考 \n<https://laracasts.com/discuss/channels/general-discussion/gulp-tdd-phpunit-\npermission-denied> \n<https://laracasts.com/index.php/discuss/channels/general-discussion/phpunit-\nwoes> \n※ 上記のサイトは4ヶ月前の情報です。復旧手順で`composer update`とありますが、現在はエラーになる為、`composer\ninstall`するのが正解です。\n\n■ Issues \n<https://github.com/laravel/installer/pull/26> \n<https://github.com/laravel/framework/issues/9051> \n<https://github.com/laravel/framework/issues/9491>\n\n確実に開発者にバグが伝わってから、2ヶ月間は放置されてます。 \n最初のisuueの報告は説明もなく簡単にcloseされています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T02:28:19.080", "id": "12038", "last_activity_date": "2015-07-07T04:39:27.737", "last_edit_date": "2015-07-07T04:39:27.737", "last_editor_user_id": "10170", "owner_user_id": "10170", "parent_id": "11948", "post_type": "answer", "score": 4 } ]
11948
12038
12038
{ "accepted_answer_id": null, "answer_count": 1, "body": "java初心者です。 \n以前投稿していたのを削除し改めてコードを書き直しアプリケーションを作成しているのですが、初の自作アプリが上手くつくれません。 \nコンセプトはゲームのアクションの技でどの組み合わせが一番ダメージをだせるかとうものです。\n\nまだ作成段階ですがコードは\n\n```\n\n class Act{\n public static void main(String args[]){\n ActDmgTotalReject act = new ActDmgTotalReject();\n act.ActDmgTotal();\n }\n }\n class ActDmgSrc{\n \n static double ruin[] = {2.50, 2.50, 80, 53, 0};\n //ActionSkillの{cast, recast, dmg, cost dmg_time};\n static double baio[] = { 0, 2.50, 40, 110, 18};\n \n }\n class ActDmgTotalReject extends ActDmgSrc{\n void ActDmgTotal(){\n double count = 240; //処理回数を数えて、240こえたらループを終わらせる関数\n double total = 0; //ダメージの総ダメージ\n double ruin_count = 0;//ruinの数\n double baio_count = 0;//baioの数\n double dmg_ruin = 0;//ruinのダメージ\n double dmg_baio = 0;//baioのダメージ\n if(count <= 240 ){\n for(;ruin_count <= 240; ruin_count++){\n baio_count =((count - ruin_count * ActDmgSrc.ruin[1])\n / ActDmgSrc.baio[1]);\n if(baio_count >=0){\n System.out.println(\"ruin_count = \" + ruin_count);\n System.out.println(\"baio_count = \" + baio_count);\n dmg_ruin = ActDmgSrc.ruin[2]* ruin_count;//ruinのダメージ計算\n dmg_baio = ActDmgSrc.baio[2]* baio_count\n +ActDmgSrc. baio[2]*(ActDmgSrc.baio[4] / 3);//baioのダメージ計算\n total = dmg_ruin+ dmg_baio;\n System.out.println(\"total = \" + total);\n }\n }\n }\n \n }\n }\n \n```\n\nです。 \n4分間で最大のダメージを出す組み合わせを求めるということでまずcountを240としcountが240になったら計算を終わりという式にしました(そのつもりです) \nそしてruin_countとbaio_countでその技の回数と場合分けを全部だしました。 \nその使用回数とダメージを掛けて組み合わせに対する総ダメージを求めたいのですが \nbaioというのが18秒間自動で40のダメージを出していてその間も他の技が打てるということを上手くコードでかけませんでした。またruin_countとbaio_countの組み合わせはいいのですがダメージの値がおかしいです。\n\n```\n\n ruin_count = 0.0\n baio_count = 96.0\n total = 4080.0\n ruin_count = 1.0\n baio_count = 95.0\n total = 4120.0\n ruin_count = 2.0\n baio_count = 94.0\n total = 4160.0\n ruin_count = 3.0\n baio_count = 93.0\n total = 4200.0\n ruin_count = 4.0\n baio_count = 92.0\n total = 4240.0\n ruin_count = 5.0\n baio_count = 91.0\n total = 4280.0\n ruin_count = 6.0\n baio_count = 90.0\n total = 4320.0\n ruin_count = 7.0\n baio_count = 89.0\n total = 4360.0\n ruin_count = 8.0\n baio_count = 88.0\n total = 4400.0\n ruin_count = 9.0\n baio_count = 87.0\n total = 4440.0\n ruin_count = 10.0\n baio_count = 86.0\n total = 4480.0\n ruin_count = 11.0\n baio_count = 85.0\n total = 4520.0\n ruin_count = 12.0\n baio_count = 84.0\n total = 4560.0\n ruin_count = 13.0\n baio_count = 83.0\n total = 4600.0\n ruin_count = 14.0\n baio_count = 82.0\n total = 4640.0\n ruin_count = 15.0\n baio_count = 81.0\n total = 4680.0\n ruin_count = 16.0\n baio_count = 80.0\n total = 4720.0\n ruin_count = 17.0\n baio_count = 79.0\n total = 4760.0\n ruin_count = 18.0\n baio_count = 78.0\n total = 4800.0\n ruin_count = 19.0\n baio_count = 77.0\n total = 4840.0\n ruin_count = 20.0\n baio_count = 76.0\n total = 4880.0\n ruin_count = 21.0\n baio_count = 75.0\n total = 4920.0\n ruin_count = 22.0\n baio_count = 74.0\n total = 4960.0\n ruin_count = 23.0\n baio_count = 73.0\n total = 5000.0\n ruin_count = 24.0\n baio_count = 72.0\n total = 5040.0\n ruin_count = 25.0\n baio_count = 71.0\n total = 5080.0\n ruin_count = 26.0\n baio_count = 70.0\n total = 5120.0\n ruin_count = 27.0\n baio_count = 69.0\n total = 5160.0\n ruin_count = 28.0\n baio_count = 68.0\n total = 5200.0\n ruin_count = 29.0\n baio_count = 67.0\n total = 5240.0\n ruin_count = 30.0\n baio_count = 66.0\n total = 5280.0\n ruin_count = 31.0\n baio_count = 65.0\n total = 5320.0\n ruin_count = 32.0\n baio_count = 64.0\n total = 5360.0\n ruin_count = 33.0\n baio_count = 63.0\n total = 5400.0\n ruin_count = 34.0\n baio_count = 62.0\n total = 5440.0\n ruin_count = 35.0\n baio_count = 61.0\n total = 5480.0\n ruin_count = 36.0\n baio_count = 60.0\n total = 5520.0\n ruin_count = 37.0\n baio_count = 59.0\n total = 5560.0\n ruin_count = 38.0\n baio_count = 58.0\n total = 5600.0\n ruin_count = 39.0\n baio_count = 57.0\n total = 5640.0\n ruin_count = 40.0\n baio_count = 56.0\n total = 5680.0\n ruin_count = 41.0\n baio_count = 55.0\n total = 5720.0\n ruin_count = 42.0\n baio_count = 54.0\n total = 5760.0\n ruin_count = 43.0\n baio_count = 53.0\n total = 5800.0\n ruin_count = 44.0\n baio_count = 52.0\n total = 5840.0\n ruin_count = 45.0\n baio_count = 51.0\n total = 5880.0\n ruin_count = 46.0\n baio_count = 50.0\n total = 5920.0\n ruin_count = 47.0\n baio_count = 49.0\n total = 5960.0\n ruin_count = 48.0\n baio_count = 48.0\n total = 6000.0\n ruin_count = 49.0\n baio_count = 47.0\n total = 6040.0\n ruin_count = 50.0\n baio_count = 46.0\n total = 6080.0\n ruin_count = 51.0\n baio_count = 45.0\n total = 6120.0\n ruin_count = 52.0\n baio_count = 44.0\n total = 6160.0\n ruin_count = 53.0\n baio_count = 43.0\n total = 6200.0\n ruin_count = 54.0\n baio_count = 42.0\n total = 6240.0\n ruin_count = 55.0\n baio_count = 41.0\n total = 6280.0\n ruin_count = 56.0\n baio_count = 40.0\n total = 6320.0\n ruin_count = 57.0\n baio_count = 39.0\n total = 6360.0\n ruin_count = 58.0\n baio_count = 38.0\n total = 6400.0\n ruin_count = 59.0\n baio_count = 37.0\n total = 6440.0\n ruin_count = 60.0\n baio_count = 36.0\n total = 6480.0\n ruin_count = 61.0\n baio_count = 35.0\n total = 6520.0\n ruin_count = 62.0\n baio_count = 34.0\n total = 6560.0\n ruin_count = 63.0\n baio_count = 33.0\n total = 6600.0\n ruin_count = 64.0\n baio_count = 32.0\n total = 6640.0\n ruin_count = 65.0\n baio_count = 31.0\n total = 6680.0\n ruin_count = 66.0\n baio_count = 30.0\n total = 6720.0\n ruin_count = 67.0\n baio_count = 29.0\n total = 6760.0\n ruin_count = 68.0\n baio_count = 28.0\n total = 6800.0\n ruin_count = 69.0\n baio_count = 27.0\n total = 6840.0\n ruin_count = 70.0\n baio_count = 26.0\n total = 6880.0\n ruin_count = 71.0\n baio_count = 25.0\n total = 6920.0\n ruin_count = 72.0\n baio_count = 24.0\n total = 6960.0\n ruin_count = 73.0\n baio_count = 23.0\n total = 7000.0\n ruin_count = 74.0\n baio_count = 22.0\n total = 7040.0\n ruin_count = 75.0\n baio_count = 21.0\n total = 7080.0\n ruin_count = 76.0\n baio_count = 20.0\n total = 7120.0\n ruin_count = 77.0\n baio_count = 19.0\n total = 7160.0\n ruin_count = 78.0\n baio_count = 18.0\n total = 7200.0\n ruin_count = 79.0\n baio_count = 17.0\n total = 7240.0\n ruin_count = 80.0\n baio_count = 16.0\n total = 7280.0\n ruin_count = 81.0\n baio_count = 15.0\n total = 7320.0\n ruin_count = 82.0\n baio_count = 14.0\n total = 7360.0\n ruin_count = 83.0\n baio_count = 13.0\n total = 7400.0\n ruin_count = 84.0\n baio_count = 12.0\n total = 7440.0\n ruin_count = 85.0\n baio_count = 11.0\n total = 7480.0\n ruin_count = 86.0\n baio_count = 10.0\n total = 7520.0\n ruin_count = 87.0\n baio_count = 9.0\n total = 7560.0\n ruin_count = 88.0\n baio_count = 8.0\n total = 7600.0\n ruin_count = 89.0\n baio_count = 7.0\n total = 7640.0\n ruin_count = 90.0\n baio_count = 6.0\n total = 7680.0\n ruin_count = 91.0\n baio_count = 5.0\n total = 7720.0\n ruin_count = 92.0\n baio_count = 4.0\n total = 7760.0\n ruin_count = 93.0\n baio_count = 3.0\n total = 7800.0\n ruin_count = 94.0\n baio_count = 2.0\n total = 7840.0\n ruin_count = 95.0\n baio_count = 1.0\n total = 7880.0\n ruin_count = 96.0\n baio_count = 0.0\n total = 7920.0\n \n```\n\nといった形になりbaioを一度もつかってない状態が一番ダメージをだしているという結果になってしまっています。 \n独学で完成しても正しいかわかりませんが、初の試みなのでどうやって作成していくといいかもわかっていません。 \nいずれもっと攻撃技を増やしていくことを考えるとこのコードの書き方だと難しいのではないかとも考えています。 \nアクションの組み合わせとダメージの計算の仕方をご教授願いたいです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T07:10:44.357", "favorite_count": 0, "id": "11952", "last_activity_date": "2015-07-02T12:07:31.833", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10197", "post_type": "question", "score": -1, "tags": [ "java" ], "title": "javaで計算式が上手くいかない。", "view_count": 306 }
[ { "body": "ご自身も書いていますが、costの概念が全くないので単純にダメージが大きい技?を繰り返し使えば最大値になるのごく当然でしょう。 \nコストが時間経過とどう関係するのか決まれば、2つの不等式になるので、線形計画法という問題として解くことができます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T12:07:31.833", "id": "11964", "last_activity_date": "2015-07-02T12:07:31.833", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8136", "parent_id": "11952", "post_type": "answer", "score": 1 } ]
11952
null
11964
{ "accepted_answer_id": null, "answer_count": 1, "body": "Yosemite 10.10.4,Ruby 2.2.0\n\nbundle install で RMagick が入らないのです。普通に gem install なら入りました。\n\nビルドがコケてるようなんですが、 \n何が問題なのかエラーを見てもわからず、教えていただきたいです。\n\n```\n\n $ bundle install --path vendor/bundle\n Fetching gem metadata from https: //rubygems.org/............\n Fetching version metadata from https: //rubygems.org/...\n Fetching dependency metadata from https: //rubygems.org/..\n Installing rmagick 2.13.4 with native extensions\n \n Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.\n \n /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb\n checking for Ruby version >= 1.8.5... yes\n checking for xcrun... yes\n checking for Magick-config... yes\n checking for ImageMagick version >= 6.4.9... yes\n checking for stdint.h... yes\n checking for sys/types.h... yes\n checking for wand/MagickWand.h... yes\n checking for snprintf() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for AcquireImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for AffinityImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for AffinityImages() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for AutoGammaImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for AutoLevelImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for BlueShiftImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for ColorMatrixImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for ConstituteComponentTerminus() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for DeskewImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for DestroyConstitute() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for EncipherImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for EqualizeImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for EvaluateImages() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for FloodfillPaintImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for FunctionImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for GetAuthenticIndexQueue() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for GetAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for GetImageAlphaChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for GetMagickFeatures() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for GetVirtualPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for LevelImageColors() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for LevelColorsImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for LevelizeImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for LiquidRescaleImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for MagickLibAddendum() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for OpaquePaintImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for QueueAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for RemapImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for RemapImages() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for RemoveImageArtifact() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for RotationalBlurImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for RotationalBlurImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for SelectiveBlurImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for SetImageAlphaChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for SetImageArtifact() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for SetMagickMemoryMethods() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for SparseColorImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for StatisticImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for SyncAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for TransformImageColorspace() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for TransparentPaintImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for TransparentPaintImageChroma() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no\n checking for QueryMagickColorname() new signature... yes\n checking for Image.type in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for DrawInfo.kerning in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for DrawInfo.interline_spacing in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for DrawInfo.interword_spacing in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for DitherMethod in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for MagickFunction in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for ImageLayerMethod in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for long double in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes\n checking for AlphaChannelType.CopyAlphaChannel... yes\n checking for AlphaChannelType.BackgroundAlphaChannel... yes\n checking for CompositeOperator.BlurCompositeOp... yes\n checking for CompositeOperator.DistortCompositeOp... yes\n checking for CompositeOperator.LinearBurnCompositeOp... yes\n checking for CompositeOperator.LinearDodgeCompositeOp... yes\n checking for CompositeOperator.MathematicsCompositeOp... yes\n checking for CompositeOperator.PegtopLightCompositeOp... yes\n checking for CompositeOperator.PinLightCompositeOp... yes\n checking for CompositeOperator.VividLightCompositeOp... yes\n checking for CompressionType.DXT1Compression... yes\n checking for CompressionType.DXT3Compression... yes\n checking for CompressionType.DXT5Compression... yes\n checking for CompressionType.ZipSCompression... yes\n checking for CompressionType.PizCompression... yes\n checking for CompressionType.Pxr24Compression... yes\n checking for CompressionType.B44Compression... yes\n checking for CompressionType.B44ACompression... yes\n checking for DistortImageMethod.BarrelDistortion... yes\n checking for DistortImageMethod.BarrelInverseDistortion... yes\n checking for DistortImageMethod.BilinearForwardDistortion... yes\n checking for DistortImageMethod.BilinearReverseDistortion... yes\n checking for DistortImageMethod.DePolarDistortion... yes\n checking for DistortImageMethod.PolarDistortion... yes\n checking for DistortImageMethod.PolynomialDistortion... yes\n checking for DistortImageMethod.ShepardsDistortion... yes\n checking for DitherMethod.NoDitherMethod... yes\n checking for FilterTypes.KaiserFilter... yes\n checking for FilterTypes.WelshFilter... yes\n checking for FilterTypes.ParzenFilter... yes\n checking for FilterTypes.LagrangeFilter... yes\n checking for FilterTypes.BohmanFilter... yes\n checking for FilterTypes.BartlettFilter... yes\n checking for FilterTypes.SentinelFilter... yes\n checking for MagickEvaluateOperator.PowEvaluateOperator... yes\n checking for MagickEvaluateOperator.LogEvaluateOperator... yes\n checking for MagickEvaluateOperator.ThresholdEvaluateOperator... yes\n checking for MagickEvaluateOperator.ThresholdBlackEvaluateOperator... yes\n checking for MagickEvaluateOperator.ThresholdWhiteEvaluateOperator... yes\n checking for MagickEvaluateOperator.GaussianNoiseEvaluateOperator... yes\n checking for MagickEvaluateOperator.ImpulseNoiseEvaluateOperator... yes\n checking for MagickEvaluateOperator.LaplacianNoiseEvaluateOperator... yes\n checking for MagickEvaluateOperator.MultiplicativeNoiseEvaluateOperator... yes\n checking for MagickEvaluateOperator.PoissonNoiseEvaluateOperator... yes\n checking for MagickEvaluateOperator.UniformNoiseEvaluateOperator... yes\n checking for MagickEvaluateOperator.CosineEvaluateOperator... yes\n checking for MagickEvaluateOperator.SineEvaluateOperator... yes\n checking for MagickEvaluateOperator.AddModulusEvaluateOperator... yes\n checking for MagickFunction.ArcsinFunction... yes\n checking for MagickFunction.ArctanFunction... yes\n checking for MagickFunction.PolynomialFunction... yes\n checking for MagickFunction.SinusoidFunction... yes\n checking for ImageLayerMethod.FlattenLayer... yes\n checking for ImageLayerMethod.MergeLayer... yes\n checking for ImageLayerMethod.MosaicLayer... yes\n checking for ImageLayerMethod.TrimBoundsLayer... yes\n checking for VirtualPixelMethod.HorizontalTileVirtualPixelMethod... yes\n checking for VirtualPixelMethod.VerticalTileVirtualPixelMethod... yes\n checking for VirtualPixelMethod.HorizontalTileEdgeVirtualPixelMethod... yes\n checking for VirtualPixelMethod.VerticalTileEdgeVirtualPixelMethod... yes\n checking for VirtualPixelMethod.CheckerTileVirtualPixelMethod... yes\n checking for ruby/io.h... yes\n checking for rb_frame_this_func() in ruby.h,ruby/io.h... yes\n creating extconf.h\n creating Makefile\n \n \n ======================================================================\n Thu 02Jul15 16:15:32\n This installation of RMagick 2.13.4 is configured for\n Ruby 2.0.0 (universal.x86_64-darwin14) and ImageMagick \n ======================================================================\n \n \n \n make \"DESTDIR=\"\n compiling rmagick.c\n compiling rmdraw.c\n rmdraw.c:315:15: warning: comparison of constant 100 with expression of type 'WeightType' is always true [-Wtautological-constant-out-of-range-compare]\n if (w < 100 || w > 900)\n ~ ^ ~~~\n rmdraw.c:315:26: warning: comparison of constant 900 with expression of \n \n \n (中略)\n \n \n \n ^\n rmmain.c:1724:28: error: use of undeclared identifier 'MagickSupport'\n /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:761:14: note: expanded from macro 'rb_str_new_cstr'\n rb_str_new((str), (long)strlen(str)) : \\\n ^\n rmmain.c:1724:28: error: use of undeclared identifier 'MagickSupport'\n /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:761:33: note: expanded from macro 'rb_str_new_cstr'\n rb_str_new((str), (long)strlen(str)) : \\\n ^\n rmmain.c:1724:28: error: use of undeclared identifier 'MagickSupport'\n /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:762:18: note: expanded from macro 'rb_str_new_cstr'\n rb_str_new_cstr(str); \\\n ^\n rmmain.c:1724:14: error: assigning to 'volatile VALUE' (aka 'volatile unsigned long') from incompatible type 'void'\n features = rb_str_new2(MagickSupport);\n ^\n 5 errors generated.\n make: *** [rmmain.o] Error 1\n \n \n Gem files will remain installed in /path/to/project/vendor/bundle/ruby/2.0.0/gems/rmagick-2.13.4 for inspection.\n Results logged to /path/to/project/vendor/bundle/ruby/2.0.0/gems/rmagick-2.13.4/ext/RMagick/gem_make.out\n An error occurred while installing rmagick (2.13.4), and Bundler cannot continue.\n Make sure that `gem install rmagick -v '2.13.4'` succeeds before bundling.\n \n ```\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T07:27:45.130", "favorite_count": 0, "id": "11953", "last_activity_date": "2016-10-20T19:01:10.687", "last_edit_date": "2015-07-03T21:45:18.523", "last_editor_user_id": "85", "owner_user_id": "10371", "post_type": "question", "score": 3, "tags": [ "ruby-on-rails", "ruby", "rubygems", "bundler", "imagemagick" ], "title": "Yosemite,bundle install で RMagick が入らない", "view_count": 360 }
[ { "body": "gem install でインストールしたrmagick のバージョンとbundle install で要求されているバージョンが異なっているようです。 \nまず、下記コマンドでrails プロジェクトが要求しているバージョンのrmagick をインストールしましょう。\n\ngem install rmagick -v '2.13.4'\n\nもし、上記コマンドも失敗するのであればかなり無理矢理な手段ですが下記に紹介する手法でbundle install は成功するはずです。\n\n* * *\n\nまずGemfile.lock ファイル内のrmagick のバージョン指定を変えてみてください。 \n指定するバージョンはgem list コマンドで表示される rmagick のバージョンと同じものです。\n\nこれによってbundle install 自体は成功します。 \nが、rails プロジェクトが要求するバージョンと実際に使用するgem のバージョンとに差異が生じます。 \nプロジェクト内でバージョン固有の機能などを使用する場合は不具合が生じるかもしれませんのでその点だけご注意ください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T13:37:18.353", "id": "11968", "last_activity_date": "2015-07-02T13:37:18.353", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2373", "parent_id": "11953", "post_type": "answer", "score": 1 } ]
11953
null
11968
{ "accepted_answer_id": "16577", "answer_count": 2, "body": "jsからlocalhostで動いているpythonにリクエストを送ってます。\n\njsではget引数にmain.py?url={jsでencodeURIComponentしたURL}という形でリクエストしています。\n\n受け取り側では\n\n```\n\n form = cgi.FieldStorage()\n form['url'].value\n \n```\n\nという形で取得しています。\n\njsでencodeURIComponentする前のURLが「<http://example.com/>」のような場合には問題なく取得できるのですが「<http://example.com/?hoge=fuga>」のようにこちらにもget引数がついていると、その部分がcgi.FieldStorage()で取得されてしまい、逆に'url'というキーの値がない、という状態になっています。\n\nこういう場合、pythonではどのように受け取るべきなのでしょうか。\n\nちなみに、リクエストしているURLを直接ブラウザで叩いても同じ状態になります。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T07:54:23.610", "favorite_count": 0, "id": "11954", "last_activity_date": "2015-09-13T20:52:17.667", "last_edit_date": "2015-07-02T08:01:38.037", "last_editor_user_id": "10373", "owner_user_id": "10373", "post_type": "question", "score": 2, "tags": [ "python" ], "title": "pythonでget引数にjavascriptでencodeURIComponent()したurlを渡したらcgi.FieldStrage()がおかしくなる", "view_count": 770 }
[ { "body": "僕がテストする限りとくに問題なく動きました。ブラウザのJavaScriptコンソールで`encodeURIComponent('http://example.com/?hoge=fuga')`とすると`http%3A%2F%2Fexample.com%2F%3Fhoge%3Dfuga`が得られます。\n\nテストプログラム test.py\n\n```\n\n #!/usr/bin/env python\n import cgi\n form = cgi.FieldStorage()\n print 'Content-Type: text/html'\n print\n print form['url'].value\n \n```\n\n端末で\n\n```\n\n mkdir cgi-bin\n # 上のtest.pyをcgi-binの下に保存して実行属性をつける\n chmod 755 cgi-bin/test.py\n \n # CGIサーバ起動\n python -m CGIHTTPServer\n \n```\n\nブラウザで`http://localhost:8000/cgi-\nbin/test.py?url=http%3A%2F%2Fexample.com%2F%3Fhoge%3Dfuga`をアクセス\n\nソースを確認すると`http://example.com/?hoge=fuga`が正しく得られました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-15T02:05:02.900", "id": "12364", "last_activity_date": "2015-07-15T02:05:02.900", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7837", "parent_id": "11954", "post_type": "answer", "score": 0 }, { "body": "動作確認にPythonの標準ライブラリのサーバを使っている事と思いますが、そのサーバの問題です。手元でも`python3 -m http.server\n--cgi`で起動したサーバで再現しました。CGIはそのままで、他のサーバでは動くはずです。\n\n`cgi.FieldStorage()`はサーバが用意した環境変数`QUERY_STRING`を使用すると思うのですが、標準ライブラリのサーバはこれが大雑把で、urlを`rfind('?')`で分割して使っているようです。\n\n`http://localhost:8000/cgi-bin/cgi-try.py?url=http://example.com/?hoge=fuga`\nという url\nだと、通常のサーバから渡される`QUERY_STRING`は`url=http://example.com/?hoge=fuga`だと思いますが\nPython のサーバでは`hoge=fuga`になってしまいます。\n\n(こういう物なのか、バグと考えるべきなのか分かりません)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-09-13T20:52:17.667", "id": "16577", "last_activity_date": "2015-09-13T20:52:17.667", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "11954", "post_type": "answer", "score": 0 } ]
11954
16577
12364
{ "accepted_answer_id": null, "answer_count": 1, "body": "スクロール時の動きが地味なのでhttp://lab.hakim.se/scroll-\neffects/のような動きをつけたいのですが、あまりに構造が違いすぎて途方に暮れているのですが、これに似た動きをする別のおすすめのjqueryはありますでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T08:19:12.890", "favorite_count": 0, "id": "11955", "last_activity_date": "2015-11-30T19:24:26.110", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7724", "post_type": "question", "score": 1, "tags": [ "monaca" ], "title": "ons-listにエフェクトをかけたい", "view_count": 137 }
[ { "body": "`<ons-list>`は単なるCSSのプリセットですので、スタイリングにこだわりたいなら`<ons-\nlist>`をあえて使う必要はありません。普通に`<ul>`と`<li>`でマークアップして、CSSをいくらか書いてstroll.jsを使われてはどうでしょうか。\n\n以下はAngularでの使用例です。\n\n```\n\n ons.bootstrap().controller('appController', function($scope, $timeout){\r\n $timeout(function(){\r\n stroll.bind('.stroll');\r\n });\r\n \r\n $scope.range = function(min, max, step){\r\n step = step || 1;\r\n var input = [];\r\n for (var i = min; i <= max; i += step) input.push(i);\r\n return input;\r\n };\r\n });\n```\n\n```\n\n /**\r\n * Demo page styles, all list scroll effects styles are in sctroll.css\r\n */\r\n html, body {\r\n margin: 0px;\r\n padding: 0px;\r\n }\r\n \r\n body {\r\n background: #323232;\r\n font-family: 'Lato', Times, 'Times New Roman', serif;\r\n font-size: 16px;\r\n color: #eee;\r\n margin-bottom: 40px;\r\n line-height: 1;\r\n }\r\n article {\r\n display: inline-block;\r\n margin: 20px;\r\n }\r\n \r\n h2 {\r\n font-size: 16px;\r\n margin-bottom: 20px;\r\n text-transform: uppercase;\r\n }\r\n \r\n /**\r\n * List used for the demo page\r\n */\r\n ul {\r\n position: relative;\r\n width: 230px;\r\n height: 480px;\r\n margin: 0;\r\n padding: 0;\r\n overflow-x: hidden;\r\n overflow-y: scroll;\r\n list-style: none;\r\n \r\n -webkit-perspective: 400px;\r\n -moz-perspective: 400px;\r\n -ms-perspective: 400px;\r\n -o-perspective: 400px;\r\n perspective: 400px;\r\n }\r\n ul li {\r\n position: relative;\r\n padding: 16px;\r\n background: #eee;\r\n color: #252525;\r\n font-size: 18px;\r\n z-index: 2;\r\n \r\n -webkit-transform: translateZ(0px);\r\n -moz-transform: translateZ(0px);\r\n -ms-transform: translateZ(0px);\r\n -o-transform: translateZ(0px);\r\n transform: translateZ(0px);\r\n }\r\n ul li:nth-child(odd) {\r\n background: #fff;\r\n }\n```\n\n```\n\n <link href=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.3.6/build/css/onsen-css-components.css\" rel=\"stylesheet\"/>\r\n <link href=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.3.6/build/css/onsenui.css\" rel=\"stylesheet\"/>\r\n <link href=\"https://cdn.rawgit.com/hakimel/stroll.js/master/css/stroll.min.css\" rel=\"stylesheet\" />\r\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js\"></script>\r\n <script src=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.3.6/build/js/angular/angular.min.js\"></script>\r\n <script src=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.3.6/build/js/onsenui.min.js\"></script>\r\n <script src=\"https://cdn.rawgit.com/hakimel/stroll.js/master/js/stroll.min.js\"></script>\r\n \r\n <body ng-controller=\"appController\">\r\n <article>\r\n <h2>Grow</h2>\r\n <ul class=\"grow stroll\"><li ng-repeat=\"i in range(1, 100)\">Item{{i}}</li></ul>\r\n </article>\r\n <article>\r\n <h2>Cards</h2>\r\n <ul class=\"cards stroll\"><li ng-repeat=\"i in range(1, 100)\">Item{{i}}</li></ul>\r\n </article>\r\n </body>\n```\n\n-", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-09-01T15:44:10.617", "id": "15123", "last_activity_date": "2015-09-01T15:44:10.617", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8532", "parent_id": "11955", "post_type": "answer", "score": 1 } ]
11955
null
15123
{ "accepted_answer_id": "11962", "answer_count": 2, "body": "※xcode6.1.1 swift1.1 spriteKitを使用しています。\n\nおみくじアプリをテストで作っているのですが \nタッチするボタンを二つつくって、どちらをタッチしたかによって \n反応をかえたいのですが、うまくいきません。 \nタッチイベントでどの選択肢をタッチしたかは作れないのでしょうか? \nご教授よろしくお願いします。\n\n発生するエラーは、ボタンをクリックするとThread 1:breakpoint 1.1と出ます。\n\n```\n\n if touchNode == btn2Sprite {\n \n```\n\nの行で\n\n```\n\n override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {\n for touch: AnyObject in touches {\n // タッチされた位置にあるものを調べて\n let location = touch.locationInNode(self)\n let touchNode = self.nodeAtPoint(location)\n // もし、ボタン1なら\n if touchNode == btnSprite {\n // 悪い予感がすると表示してから、おみくじを振る\n myLabel.text = \"悪い予感がする\"\n shakeOmikuji()\n }\n // もし、ボタン2なら\n if touchNode == btn2Sprite {\n // 大吉の予感と表示してから、おみくじを振る\n myLabel.text = \"大吉の予感\"\n shakeOmikuji()\n }\n }\n }\n \n```\n\n全文\n\n```\n\n // GameScene.swift\n \n import SpriteKit\n \n class GameScene: SKScene {\n // イラスト用スプライトを用意する\n let mySprite = SKSpriteNode(imageNamed: \"omikuji.png\")\n // ボタン用スプライトを用意する\n let btnSprite = SKSpriteNode(imageNamed: \"button.png\")\n let btn2Sprite = SKSpriteNode(imageNamed: \"button.png\")\n // おみくじ結果用ラベルを用意する\n let myLabel = SKLabelNode(fontNamed: \"Verdana-bold\")\n \n override func didMoveToView(view: SKView) {\n // 背景色をつける\n self.backgroundColor = SKColor.whiteColor()\n // イラストを表示する\n mySprite.position = CGPoint(x: 375, y: 900)\n addChild(mySprite)\n // ボタンを表示する\n btnSprite.position = CGPoint(x:375, y:200)\n self.addChild(btnSprite)\n // ボタンを表示する\n btn2Sprite.position = CGPoint(x:575, y:200)\n self.addChild(btn2Sprite)\n // おみくじ結果用ラベルを表示する\n myLabel.text = \"???\"\n myLabel.fontSize = 65\n myLabel.fontColor = SKColor.blackColor()\n myLabel.position = CGPoint(x:375, y:500)\n self.addChild(myLabel)\n }\n // タッチしたときの処理\n override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {\n for touch: AnyObject in touches {\n // タッチされた位置にあるものを調べて\n let location = touch.locationInNode(self)\n let touchNode = self.nodeAtPoint(location)\n // もし、ボタンなら\n if touchNode == btnSprite {\n // ???と表示してから、おみくじを振る\n myLabel.text = \"悪い予感がする\"\n shakeOmikuji()\n }\n // もし、ボタン2なら\n if touchNode == btn2Sprite {\n // ???と表示してから、おみくじを振る\n myLabel.text = \"大吉の予感\"\n shakeOmikuji()\n }\n }\n }\n // おみくじを振る処理\n func shakeOmikuji() {\n // 【おみくじを振るアクションをつける】\n // おみくじを少し右に傾けるアクション\n let action1 = SKAction.rotateToAngle(-0.3, duration: 0.2)\n // おみくじを少し左に傾けるアクション\n let action2 = SKAction.rotateToAngle( 0.3, duration: 0.2)\n // おみくじをひっくり返すアクション\n let action3 = SKAction.rotateToAngle( 3.14, duration: 0.2)\n // action1,action2,action3を指定した順番に行う\n let actionS = SKAction.sequence(\n [action1, action2, action1, action2, action1, action3])\n \n // おみくじに「左右に振ってひっくり返すアクション」をつけて、最後にkekkaを実行する\n mySprite.runAction(actionS, completion: showOmikuji)\n }\n // 結果を表示する処理\n func showOmikuji() {\n var omikuji = [\"大吉\",\"中吉\",\"吉\",\"凶\"]\n var r = Int(arc4random_uniform(4))\n myLabel.text = omikuji[r]\n }\n \n override func update(currentTime: CFTimeInterval) {\n }\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T08:24:05.077", "favorite_count": 0, "id": "11956", "last_activity_date": "2015-07-02T11:04:12.273", "last_edit_date": "2015-07-02T11:04:12.273", "last_editor_user_id": "8000", "owner_user_id": "10353", "post_type": "question", "score": 1, "tags": [ "swift", "spritekit" ], "title": "touchesBeganについて分からない事があります", "view_count": 1335 }
[ { "body": "nodeAtPoint メソッドよりも containsPoint メソッドを使うほうが適切に見えます。\n\n```\n\n println(location)\n println(btnSprite)\n println(btn2Sprite)\n if btnSprite.containsPoint(location) {\n // もし、ボタン1なら\n // 悪い予感がすると表示してから、おみくじを振る\n myLabel.text = \"悪い予感がする\"\n shakeOmikuji()\n }else if btn2Sprite.containsPoint(location) {\n // もし、ボタン2なら\n // 大吉の予感と表示してから、おみくじを振る\n myLabel.text = \"大吉の予感\"\n shakeOmikuji()\n }\n \n```\n\nそれから「どのようにうまくいかないのか」も一緒に投稿してもらえると回答しやすくなります。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T10:12:16.617", "id": "11962", "last_activity_date": "2015-07-02T10:42:35.287", "last_edit_date": "2015-07-02T10:42:35.287", "last_editor_user_id": "2373", "owner_user_id": "2373", "parent_id": "11956", "post_type": "answer", "score": 1 }, { "body": "```\n\n import UIKit\n import SpriteKit\n \n class GameScene: SKScene {\n // イラスト用スプライトを用意する\n let mySprite = SKSpriteNode(imageNamed: \"omikuji.png\")\n // ボタン用スプライトを用意する\n let btnSprite = SKSpriteNode(imageNamed: \"button.png\")\n let btn2Sprite = SKSpriteNode(imageNamed: \"button.png\")\n // おみくじ結果用ラベルを用意する\n let myLabel = SKLabelNode(fontNamed: \"Verdana-bold\")\n \n // 中略\n \n // タッチしたときの処理\n override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {\n for touch: AnyObject in touches {\n // タッチされた位置にあるものを調べて\n // let location = touch.locationInNode(self) // ここで赤色マークが出ているはず。\n let location = (touch as! UITouch).locationInNode(self) // touchをダウンキャストする。\n let touchNode = self.nodeAtPoint(location)\n // もし、ボタンなら\n if touchNode == btnSprite {\n // ???と表示してから、おみくじを振る\n myLabel.text = \"悪い予感がする\"\n shakeOmikuji()\n }\n // もし、ボタン2なら\n if touchNode == btn2Sprite {\n // ???と表示してから、おみくじを振る\n myLabel.text = \"大吉の予感\"\n shakeOmikuji()\n }\n }\n }\n \n // 後略\n }\n \n```\n\nとりあえず一箇所、`touches`を`UITouch`にダウンキャストすれば、エラーが出なくなるはずです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T10:43:46.633", "id": "11963", "last_activity_date": "2015-07-02T10:43:46.633", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "11956", "post_type": "answer", "score": 0 } ]
11956
11962
11962
{ "accepted_answer_id": null, "answer_count": 2, "body": "iOSプログラム(Swift)でsliderバーで変更した際に画像をhttpアクセスして取得した画像を表示するプログラムを作っています。同期処理にするとスライド動作が非常に重くなります。非同期にすると必要の無い画像を律儀に取得して画像が出るまで時間がかかります。やりたいことはスライドバー変更時に前にたまっていたキューをキャンセルして、最後のキューのみ処理させたいと思います。非同期の際のソースの一部を載せておきます。どうやればいいかご存知の方はご教授ください。\n\n```\n\n @IBAction func slidertime(sender: UISlider) {\n let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)\n let group = dispatch_group_create()\n dispatch_group_async(group, queue, { () -> Void in\n var urlstring = \"http://test.com/img.php?number=\" + String(Int(sender.value * 100))\n var url = NSURL(string: urlstring)\n var err: NSError?\n var imgeData :NSData = NSData(contentsOfURL: url!, options: NSDataReadingOptions.DataReadingMappedIfSafe, error: &err)!\n self.thumbnail.image = UIImage(data:imgeData)\n })\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T09:52:06.950", "favorite_count": 0, "id": "11961", "last_activity_date": "2015-08-07T11:55:05.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8593", "post_type": "question", "score": 1, "tags": [ "ios", "swift", "xcode" ], "title": "(Swift) スライダーバーで画像を変更するが処理が遅い対応", "view_count": 634 }
[ { "body": "スライダーを動かして、動かし終わった時のみ処理をしたいということですよね?\n\n 1. スライダーの最新の値を保持\n 2. タイマーなどで一定間隔で「現在の値」と「保持した値」を比較\n 3. 現在の値と保持した値が同一な場合に処理\n\nといった処理ではいかがでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-09T04:34:34.010", "id": "12187", "last_activity_date": "2015-07-09T04:34:34.010", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7376", "parent_id": "11961", "post_type": "answer", "score": 1 }, { "body": "スライダーのvalueChangedイベントではなく、touchUpInsideイベントが走った時に画像を取得するのはどうですか??", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-07T11:55:05.143", "id": "13147", "last_activity_date": "2015-08-07T11:55:05.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3574", "parent_id": "11961", "post_type": "answer", "score": 0 } ]
11961
null
12187
{ "accepted_answer_id": null, "answer_count": 0, "body": "MONACAで作ったアプリのパーミッションで \nRead Phone State \nModify Audio Setting \nRecord Audio \n等を消したいのですが、できません。\n\nMONACAのヘルプをみるとAndroidManifest.xmlで設定できるようなのですが、\n\n```\n\n <uses-permission android:name=\"android.permission.INTERNET\"/>\n \n```\n\nしか見当たらないのです。弄れないようになったのでしょうか?\n\nMdeiaプラグインを使用したら上記のパーミッションが強制的に追加されちゃうんですかね? \n不必要なパーミッションを要求しているので、ダウンロード数にも影響しちゃいます。こまったこまった。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T13:09:02.803", "favorite_count": 0, "id": "11967", "last_activity_date": "2015-07-02T13:46:18.730", "last_edit_date": "2015-07-02T13:46:18.730", "last_editor_user_id": "3639", "owner_user_id": "8789", "post_type": "question", "score": 1, "tags": [ "monaca" ], "title": "MONACAのパーミッション マイクの録音等を消したい", "view_count": 178 }
[]
11967
null
null
{ "accepted_answer_id": "11979", "answer_count": 1, "body": "この形式の日付データをphpのstrtotimeで解釈させたいのですが \nどのように書くのが適切でしょうか?\n\n曜日, 日 月 年 時:分:秒 時差\n\n例 ) 水, 02 01 2015 01:00:00 +09:00", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T13:47:00.103", "favorite_count": 0, "id": "11969", "last_activity_date": "2015-07-03T03:02:37.357", "last_edit_date": "2015-07-03T03:02:37.357", "last_editor_user_id": "691", "owner_user_id": "691", "post_type": "question", "score": 0, "tags": [ "php" ], "title": "phpの日付解釈", "view_count": 157 }
[ { "body": "日付データを基にunix epochtimeを求めたいというなら以下でできます。\n\n```\n\n $theday = 'Mon, 11 30 2015 10:00:22 +0900';\n $dt = DateTime::createFromFormat('D, n j Y H:i:s T', $theday);\n $epoch = $dt->format('U');\n var_dump( $epoch);\n \n```\n\nただ、自分のテスト環境ではロケールの設定がおかしいのか、曜日の'月'は受け付けてくれませんでした。 \n3番目の項目は31から30に変更しました。 \n要素のフォーマットについては、ゼロが付くのかサンプルから判断できないものはこちらで勝手に選びました。詳細は \n<http://php.net/manual/ja/datetime.createfromformat.php> \nを参照してください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T23:35:34.340", "id": "11979", "last_activity_date": "2015-07-02T23:35:34.340", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8136", "parent_id": "11969", "post_type": "answer", "score": 3 } ]
11969
11979
11979
{ "accepted_answer_id": "11971", "answer_count": 1, "body": "下記のソースコードは、マウスストーカーのアナログ時計の外周(DATE)の移動速度を、 \nセレクトタグで作ったものですが、検索したところ、optionに\"onclick\"を入れても \nIEでは動作しない,と書かれていました(*一応、動作していますが…?)。 \n全てのブラウザで見られるようにするには、どのように書き換えたらよろしいのでしょうか。\n\n```\n\n <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n <html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=shift_jis\"> \n \n <TITLE>妖怪クロック(アナログ1) - JavaScript</TITLE>\n \n <style type=\"text/css\">\n <!--\n .butt{\n BACKGROUND:maroon; \n COLOR:gold;\n }\n //-->\n </style>\n \n \n \n </head>\n <BODY bgcolor=\"black\" text=\"white\">\n \n <div id=\"clock\" style=\"visibility:hidden\">\n <div id=\"Od\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n \n <div id=\"Of\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n \n <div id=\"Oh\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n \n <div id=\"Om\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n \n <div id=\"Os\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n </div>\n \n <script type=\"text/javascript\">\n <!--\n var   step=0; \n     currStep=0;\n function changeSTEP1(){\n step=0.05;\n }\n function changeSTEP2(){\n step=0.02;\n }\n function changeSTEP3(){\n step=0;\n }\n function changeSTEP4(){\n step=-0.02;\n }\n \n (function(){\n \"use strict\";\n \n function $(sel)\n {\n return document.getElementById(sel);\n }\n \n function $$(sel)\n {\n if (typeof document.getElementsByClassName === 'undefined')\n {\n return document.getElementsByName(sel);\n }\n return document.getElementsByClassName(sel);\n }\n \n var dCol = '', //date colour.\n sCol = '', //seconds colour.\n mCol = '', //minutes colour.\n hCol = '', //hours colour.\n fCol = '', //face color\n \n ClockHeight = 55,\n ClockWidth = 55,\n ClockFromMouseY = 0,\n ClockFromMouseX = 100,\n d = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"],\n m = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"],\n date = new Date(),\n day = date.getDate(),\n year = date.getYear() + 1900;\n var TodaysDate = \" \" + d[date.getDay()] + \" \" + day + \" \" + m[date.getMonth()] + \" \" + year;\n var D = TodaysDate.split('');\n var H = '☆☆☆';\n H = H.split('');\n var M = '☆☆☆☆';\n M = M.split('');\n var S = '・・・・・';\n S = S.split('');\n var Face = '1 2 3 4 5 6 7 8 9 10 11 12',\n font = 'Helvetica, Arial, sans-serif',\n size = 1,\n speed = 0.45;\n Face = Face.split(' ');\n var n = Face.length;\n var a = size * 10;\n var ymouse = 0,\n xmouse = 0,\n scrll = 0,\n props = '<span style=\"font-family:' + font + ';font-size:' + size + 'em; color:#' + fCol + '\">',\n props2 = '<span style=\"font-family:' + font + ';font-size:' + size + 'em; color:#' + dCol + '\">';\n var Split = 360 / n;\n var Dsplit = 360 / D.length;\n var HandHeight = ClockHeight / 4.5; \n var HandWidth = ClockWidth / 4.5;\n var HandY = -7,\n HandX = -2.5,\n \n y = [],\n x = [],\n Y = [],\n X = [],\n Dy = [],\n Dx = [],\n DY = [],\n DX = [];\n var i;\n \n for (i = 0; i < n; i++) \n {\n y[i] = 0;\n x[i] = 0;\n Y[i] = 0;\n X[i] = 0;\n }\n \n for (i = 0; i < D.length; i++) \n {\n Dy[i] = 0;\n Dx[i] = 0;\n DY[i] = 0;\n DX[i] = 0;\n }\n var wrapper = $('clock');\n var html = '';\n // Date wrapper\n \n html = '';\n \n for (i = 0; i < D.length; i++)\n {\n html += '<div class=\"Date\" name=\"Date\" style=\"position:absolute;top:0px;left:0;height:' + a + ';width:' + a + ';text-align:center\">' + props2 + D[i] + '</span></div>';\n }\n $('Od').children[0].innerHTML = html;\n \n // Face wrapper\n \n html = '';\n \n for (i = 0; i < n; i++) \n {\n html += '<div class=\"Face\" name=\"Face\" style=\"position:absolute;top:0px;left:0;height:' + a + ';width:' + a + ';text-align:center\">' + props + Face[i] + '</span></div>';\n }\n $('Of').children[0].innerHTML = html;\n // Hours wrapper\n \n html = '';\n \n for (i = 0; i < H.length; i++)\n {\n html += '<div class=\"Hours\" name=\"Hours\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + hCol + ';text-align:center;font-weight:bold\">' + H[i] + '</div>';\n } \n $('Oh').children[0].innerHTML = html;\n // Minute wrapper\n \n html = '';\n \n for (i = 0; i < M.length; i++)\n {\n html += '<div class=\"Minutes\" name=\"Minutes\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + mCol + ';text-align:center;font-weight:bold\">' + M[i] + '</div>';\n } \n $('Om').children[0].innerHTML = html;\n // Seconds wrapper\n \n html = '';\n \n for (i = 0; i < S.length; i++)\n {\n html += '<div class=\"Seconds\" name=\"Seconds\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + sCol + ';text-align:center;font-weight:bold\">' + S[i] + '</div>';\n } \n $('Os').children[0].innerHTML = html;\n // Mouse move event handler\n \n function Mouse(evnt) \n {\n if (typeof evnt === 'undefined')\n {\n ymouse = event.Y + ClockFromMouseY;\n xmouse = event.X + ClockFromMouseX;\n }\n else\n {\n ymouse = evnt.clientY + ClockFromMouseY;\n xmouse = evnt.clientX + ClockFromMouseX;\n }\n }\n \n document.onmousemove = Mouse;\n \n function ClockAndAssign() \n {\n var time = new Date();\n var secs = time.getSeconds();\n var sec = -1.57 + Math.PI * secs / 30;\n var mins = time.getMinutes();\n var min = -1.57 + Math.PI * mins / 30;\n var hr = time.getHours();\n var hrs = -1.575 + Math.PI * hr / 6 + Math.PI * parseInt(time.getMinutes(), 10) / 360;\n $('Od').style.top = window.document.body.scrollTop;\n $('Of').style.top = window.document.body.scrollTop;\n $('Oh').style.top = window.document.body.scrollTop;\n $('Om').style.top = window.document.body.scrollTop;\n $('Os').style.top = window.document.body.scrollTop;\n \n for (i = 0; i < n; i++)\n {\n var F = $$('Face')[i];\n F.style.top = y[i] + ClockHeight * Math.sin(-1.0471 + i * Split * Math.PI / 180) + scrll;\n F.style.left = x[i] + ClockWidth * Math.cos(-1.0471 + i * Split * Math.PI / 180);\n }\n \n for (i = 0; i < H.length; i++)\n {\n var HL = $$('Hours')[i];\n HL.style.top = y[i] + HandY + (i * HandHeight) * Math.sin(hrs) + scrll;\n HL.style.left = x[i] + HandX + (i * HandWidth) * Math.cos(hrs);\n }\n \n for (i = 0; i < M.length; i++)\n {\n var ML = $$('Minutes')[i].style;\n ML.top = y[i] + HandY + (i * HandHeight) * Math.sin(min) + scrll;\n ML.left = x[i] + HandX + (i * HandWidth) * Math.cos(min);\n }\n \n for (i = 0; i < S.length; i++)\n {\n var SL = $$('Seconds')[i].style;\n SL.top = y[i] + HandY + (i * HandHeight) * Math.sin(sec) + scrll;\n SL.left = x[i] + HandX + (i * HandWidth) * Math.cos(sec);\n }\n \n for (i = 0; i < D.length; i++)\n {\n var DL = $$('Date')[i].style;\n DL.top = Dy[i] + ClockHeight * 1.5 * Math.sin(currStep + i * Dsplit * Math.PI / 180) + scrll;\n DL.left = Dx[i] + ClockWidth * 1.5 * Math.cos(currStep + i * Dsplit * Math.PI / 180);\n }\n currStep -= step;\n }\n \n function Delay() \n {\n scrll = 0;\n Dy[0] = Math.round(DY[0] += ((ymouse) - DY[0]) * speed);\n Dx[0] = Math.round(DX[0] += ((xmouse) - DX[0]) * speed);\n \n for (i = 1; i < D.length; i++) {\n Dy[i] = Math.round(DY[i] += (Dy[i - 1] - DY[i]) * speed);\n Dx[i] = Math.round(DX[i] += (Dx[i - 1] - DX[i]) * speed);\n }\n y[0] = Math.round(Y[0] += ((ymouse) - Y[0]) * speed);\n x[0] = Math.round(X[0] += ((xmouse) - X[0]) * speed);\n \n for (i = 1; i < n; i++) {\n y[i] = Math.round(Y[i] += (y[i - 1] - Y[i]) * speed);\n x[i] = Math.round(X[i] += (x[i - 1] - X[i]) * speed);\n }\n ClockAndAssign();\n setTimeout(Delay, 20);\n }\n \n Delay();\n \n }());\n \n num = 1;\n function toggle(){\n num ^= 1; \n if(num == 1){ \n document.getElementById('clock').style.visibility=\"hidden\";\n document.getElementById('step').disabled=true;\n }\n else { \n document.getElementById('clock').style.visibility=\"visible\";\n document.getElementById('step').disabled=false;\n } \n document.getElementById(\"tog\").value = num ?\" Appear \":\"Kill(切る)\";\n }\n </script>\n \n \n <font id=\"text1\" size=\"5\"><b>妖怪クロック(アナログ1):</b></font>\n \n <br><br><br>\n \n \n <div align=\"center\"><div>\n <input class=\"butt\" type=\"button\" id=\"tog\" value=\"今何時?\" onclick=\"toggle()\">\n </div><br>\n <div>\n <select id=\"step\" style=\"background:lightblue\" disabled>\n <option onClick=\"changeSTEP1()\">FAST</option>\n <option onClick=\"changeSTEP2()\">SLOW</option>\n <option onClick=\"changeSTEP3()\" selected>ORIGINAL</option>\n <option onClick=\"changeSTEP4()\">REVERSE</option>\n </select>\n </div></div>\n \n </body>\n </html>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T14:09:48.533", "favorite_count": 0, "id": "11970", "last_activity_date": "2015-07-02T14:29:41.177", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9359", "post_type": "question", "score": 1, "tags": [ "javascript", "html" ], "title": "すべてのブラウザで見られるようにするには?", "view_count": 159 }
[ { "body": "`select` の `onchange` を使うのが定番かなと思います。\n\n```\n\n <select id=\"step\" onchange=\"changeSTEP(this.value)\">\n <option value=\"0.05\">FAST</option>\n <option value=\"0.02\">SLOW</option>\n <option value=\"0\" selected>ORIGINAL</option>\n <option value=\"-0.02\">REVERSE</option>\n </select>\n \n```\n\nとしておいて、 \n呼び出されたスクリプトでは次の様にします。\n\n```\n\n function changeSTEP(value){\n step = value * 1;//数値に変換\n }\n \n```\n\n※セレクトしたアイテムが変化しない場合にはイベントは起こりません。`var step=0;`としているので問題はないはず。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T14:29:41.177", "id": "11971", "last_activity_date": "2015-07-02T14:29:41.177", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "11970", "post_type": "answer", "score": 1 } ]
11970
11971
11971
{ "accepted_answer_id": "11982", "answer_count": 1, "body": "idsはArrayで中にPostモデルの取り出したいidが先頭から順番に入っています。\n\n```\n\n ids = [23, 12, 34, 45, 9]\n \n```\n\nこれとwhere句を使ってPostを取り出すことはできていますが、順番が意図している順序になりません。\n\n```\n\n > p = Post.where(id: ids)\n > p\n => [#<Post id: 9, name: 'test_9'>,\n #<Post id: 12, name: 'test_12'>,\n #<Post id: 23, name: 'test_23'>,\n #<Post id: 34, name: 'test_34'>,\n \n```\n\nこれをidsの配列に格納した要素と同じ順番で取り出すにはどうすればいいのでしょうか? \nつまり結果のPostを[23, 12, 34, 45, 9]の順に得たいと考えています。\n\n```\n\n Post.where(id: ids).sort_by{|o| ids.index(o.id)}\n \n```\n\nを考えましたが、この結果はArrayクラスで返ってくるため使えませんでした。 \nPostモデルで指定したscopeなどをこの後で利用するため、結果はPost::ActiveRecord_Relationで得る必要があります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T14:57:28.843", "favorite_count": 0, "id": "11972", "last_activity_date": "2015-07-03T06:18:33.307", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9202", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "rails-activerecord" ], "title": "rails のwhere句の結果を指定の順番で取り出す方法は?", "view_count": 8214 }
[ { "body": "こちらの回答が参考になるかもしれません。\n\n<https://stackoverflow.com/a/26777669/1058763>\n\n## MySQLの場合 => FIELD関数を使う\n\n```\n\n > ids = [11,31,29]\n => [11, 31, 29]\n > User.where(id: ids).order(\"field(id, #{ids.join(',')})\")\n \n```\n\nこちらも参考になりそうです。\n\n[Rails - MySQL+ActiveRecordで、与えられた配列順にorderしたい時 -\nQiita](http://qiita.com/chezou/items/8c0481044c954c4bca3b)\n\n## PostgreSQLの場合 => CASE WHENを動的に生成してorderに渡す\n\n```\n\n def self.order_by_ids(ids)\n order_by = [\"case\"]\n ids.each_with_index.map do |id, index|\n order_by << \"WHEN id='#{id}' THEN #{index}\"\n end\n order_by << \"end\"\n order(order_by.join(\" \"))\n end\n \n User.where(:id => [3,2,1]).order_by_ids([3,2,1]).map(&:id) \n #=> [3,2,1]\n \n```\n\n## 追記:[order_as_specified](https://github.com/panorama-ed/order_as_specified)\ngemを使う\n\nこちらの回答の中に「gemを作ったよ」と回答している人がいました。\n\n<https://stackoverflow.com/a/29039262/1058763>\n\n```\n\n # 使い方\n MyModel.where(id: ids).order_as_specified(id: ids)\n \n # 生成されるORDER BY句\n ... ORDER BY ID='5' DESC, ID='1' DESC, ID='17' DESC, ID='84' DESC\n \n```\n\nこういうSQLでも順番を指定できるとは知りませんでした。 \nこちらもご参考までに。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T02:10:51.157", "id": "11982", "last_activity_date": "2015-07-03T06:18:33.307", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "85", "parent_id": "11972", "post_type": "answer", "score": 3 } ]
11972
11982
11982
{ "accepted_answer_id": "11976", "answer_count": 1, "body": "以下の通りにpackage.jsonとweb.jsを記述しherokuにデプロイしましたが、以下のエラーでデプロイできません。\n\nエラー内容\n\n```\n\n remote: -----> Building dependencies\n remote: Pruning any extraneous modules\n remote: Installing node modules (package.json)\n remote:\n remote: > [email protected] postinstall /tmp/build_11023d05cefa4e84389aa595131ba028\n remote: > bower install\n remote:\n remote: sh: 1: bower: not found\n remote:\n remote: npm ERR! Linux 3.13.0-49-generic\n remote: npm ERR! argv \"/tmp/build_11023d05cefa4e84389aa595131ba028/.heroku/node/bin/node\" \"/tmp/build_11023d05cefa4e84389aa595131ba028/.heroku/node/bin/npm\" \"install\" \"--unsafe-perm\" \"--userconfig\" \"/tmp/build_11023d05cefa4e84389aa595131ba028/.npmrc\"\n remote: npm ERR! node v0.12.5\n 1 {\n remote: npm ERR! npm v2.11.2\n remote: npm ERR! file sh\n remote: npm ERR! code ELIFECYCLE\n remote: npm ERR! errno ENOENT\n remote: npm ERR! syscall spawn\n remote: npm ERR! [email protected] postinstall: `bower install`\n remote: npm ERR! spawn ENOENT\n remote: npm ERR!\n remote: npm ERR! Failed at the [email protected] postinstall script 'bower install'.\n remote: npm ERR! This is most likely a problem with the package,\n remote: npm ERR! not with npm itself.\n remote: npm ERR! Tell the author that this fails on your system:\n remote: npm ERR! bower install\n remote: npm ERR! You can get their info via:\n remote: npm ERR! npm owner ls app_name\n remote: npm ERR! There is likely additional logging output above.\n remote:\n remote: npm ERR! Please include the following file with any support request:\n remote: npm ERR! /tmp/build_11023d05cefa4e84389aa595131ba028/npm-debug.log\n remote:\n remote: -----> Build failed\n \n```\n\npackage.json\n\n```\n\n 1 {\n 2 \"name\": \"app_name\",\n 3 \"version\": \"0.0.1\",\n 4 \"private\": true,\n 5 \"devDependencies\": {\n 6 \"http-server\": \"^0.8.0\",\n 7 \"bower\": \"1.4.1\",\n 8 \"express\": \"4.13.0\"\n 9 },\n 10 \"engine\": {\n 11 \"node\": \"0.12.4\",\n 12 \"npm\": \"2.10.1\"\n 13 },\n 14 \"scripts\": {\n 15 \"postinstall\": \"bower install\",\n 16 \"prestart\": \"npm install\",\n 17 \"start\": \"http-server -a localhost -p 8000 -c-1\"\n 18 }\n 19 }\n \n```\n\nweb.js\n\n```\n\n 1 var express = require('express');\n 2 var app = express();\n 3 var port = Number(process.env.PORT || 8000);\n 4\n 5 app.use(express.static(__dirname + '/'));\n 6 var server = app.listen(port, function(){console.log('Listening on port %d', server.address().port);});\n \n```\n\nエラーを見る限りbower install\nができていないみたいですが、どこが間違っているのかわからない状況です。どなたかおわかりになるかたぎ教授ください。よろしくおねがいします。\n\n補足: \nちなみにこのpackage.jsonはhttps://github.com/angular/angular-seedを参考にしました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T17:22:57.753", "favorite_count": 0, "id": "11974", "last_activity_date": "2015-07-13T08:16:34.343", "last_edit_date": "2015-07-13T08:16:34.343", "last_editor_user_id": "7232", "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "angularjs", "node.js", "heroku", "デプロイ" ], "title": "herokuにAngularJSのアプリをNodeを使ってデプロイしたい。", "view_count": 301 }
[ { "body": "自己解決しました。 \ndevDependenciesは開発用の記述で本番庸ではdependenciesを書かなければなりませんでした。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T22:32:01.843", "id": "11976", "last_activity_date": "2015-07-02T22:32:01.843", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "parent_id": "11974", "post_type": "answer", "score": 1 } ]
11974
11976
11976
{ "accepted_answer_id": "11981", "answer_count": 1, "body": "MySQLの`DROP TABLE`は`DROP TABLE TABLE1\nTABLE2`のように列挙することでまとめて削除できますが、全て削除したい、または正規表現で指定して削除するための方法を共有します。\n\nテーブル例\n\n```\n\n データベース名:test_database\n テーブル:\n table_2012\n table_2012_test1\n table_2012_test2\n table_2013\n table_2014\n table_2014_test1\n table_2015\n \n```\n\ntestとついているテーブルだけを削除したいとします。\n\n削除対象\n\n```\n\n データベース名:test_database\n テーブル:\n table_2012_test1\n table_2012_test2\n table_2014_test1\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T01:27:19.627", "favorite_count": 0, "id": "11980", "last_activity_date": "2015-07-03T01:27:19.627", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7214", "post_type": "question", "score": 1, "tags": [ "mysql" ], "title": "MySQLでテーブルを全て、または正規表現で指定して削除する方法", "view_count": 5537 }
[ { "body": "Linux環境のみとなりますが、テーブル名の一覧を取得し、`egrep`で正規表現による絞り込みを行い、`xargs`で対象テーブルを渡すことで実現できました。\n\n```\n\n mysql -h ホスト名 -u ユーザ名 -pパスワード -D test_database -e \"show tables\" -s | egrep \"test\" | xargs -I \"@@\" echo mysql -h ホスト名 -u ユーザ名 -pパスワード -D test_database -e \"DROP TABLE @@\"\n \n```\n\n危険な操作なので、参考URLに倣ってechoでコンソール表示するだけにしてあります。 \n実際にテーブルを削除する際はコマンド内の`echo`を削除して実行してください。\n\n全てのテーブルを削除する際は、`egrep`のパイプは不要です。\n\n参考URL:<https://stackoverflow.com/questions/456751/drop-mysql-databases-\nmatching-some-wildcard>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T01:27:19.627", "id": "11981", "last_activity_date": "2015-07-03T01:27:19.627", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "7214", "parent_id": "11980", "post_type": "answer", "score": 1 } ]
11980
11981
11981
{ "accepted_answer_id": null, "answer_count": 1, "body": "リストの一番最後に自動スクロールをしたいと考えてます。ng-attr-\nidと$indexを使えばできそうなのですが、具体的にどんなコードを書けばいいかわかりません。アドバイスお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T03:55:22.403", "favorite_count": 0, "id": "11983", "last_activity_date": "2015-09-01T07:57:10.500", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8748", "post_type": "question", "score": 1, "tags": [ "monaca", "angularjs" ], "title": "ng-repeatで最後のリストにIDを追加する方法", "view_count": 366 }
[ { "body": "最後の要素にだけIDを付けるのであれば`$last`を使用すると簡単だと思います。\n\n```\n\n app = angular.module('SampleApp', []);\r\n app.controller('SampleCtrl', [\r\n '$scope',\r\n function ($scope) {\r\n return $scope.items = [\r\n {\r\n 'name': 'Item1',\r\n 'price': 1200\r\n },\r\n {\r\n 'name': 'Item2',\r\n 'price': 1000\r\n },\r\n {\r\n 'name': 'Item3',\r\n 'price': 1600\r\n },\r\n {\r\n 'name': 'Item4',\r\n 'price': 2000\r\n },\r\n {\r\n 'name': 'Item5',\r\n 'price': 1800\r\n }\r\n ];\r\n }\r\n ]);\n```\n\n```\n\n ul {\r\n list-style: none;\r\n padding-left: 0;\r\n }\r\n #last_element {\r\n color: #ff0000;\r\n }\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js\"></script>\r\n \r\n <body ng-app='SampleApp'>\r\n <div class='container' ng-controller='SampleCtrl'>\r\n <h4>「#last_element」だけ色を変える</h4>\r\n <ul>\r\n <li ng-repeat='item in items'>\r\n <div ng-attr-id=\"{{$last &amp;&amp; 'last_element'}}\">名前: {{item.name}}, 値段: {{item.price}}</div>\r\n </li>\r\n </ul>\r\n </div>\r\n </body>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T06:03:59.320", "id": "11986", "last_activity_date": "2015-07-03T06:03:59.320", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3516", "parent_id": "11983", "post_type": "answer", "score": 1 } ]
11983
null
11986
{ "accepted_answer_id": null, "answer_count": 0, "body": "`Itamae`を使ってIPのフォワーディングを有効にするために\n\n```\n\n execute 'echo 1 > /proc/sys/net/ipv4/ip_forward'\n execute 'sysctl -e -p'\n \n```\n\nと `execute`\nリソースを使って設定を行ったのですが、できるだけ`execute`は使わずに設定をして行きたく思っています。何かもっと良い方法はありますか?", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T04:04:33.933", "favorite_count": 0, "id": "11984", "last_activity_date": "2016-04-20T04:20:46.320", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3271", "post_type": "question", "score": 1, "tags": [ "itamae", "provisioning" ], "title": "Itamaeのsysctlの値を変更する方法に execute を使わずに済む方法", "view_count": 167 }
[]
11984
null
null
{ "accepted_answer_id": "11989", "answer_count": 1, "body": "画面左側の`MasterView`の`TableViewCell`をそれぞれタップすると、画面右側の`DetailView`に背景色が違う`View`をそれぞれ表示させようとしているのですが、現在は`TableViewCell`をタップすると`MasterView`内で背景色の違う`View`に画面遷移してしまい、`DetailView`の方には何も変化がない状態です。 \nどうすればiPhoneの設定アプリのように画面左側のセルを押すとその内容が画面右側に表示されるようになるでしょうか? \n下記に現在のコードと`Storyboard`の内容を記します。 \nどなたか分かる方がいれば教えていただきたいです。 \nすみませんが、よろしくお願いします。\n\n```\n\n @interface TableViewController ()\n \n @end\n \n @implementation TableViewController\n \n - (void)viewDidLoad {\n [super viewDidLoad];\n }\n \n - (void)didReceiveMemoryWarning {\n [super didReceiveMemoryWarning];\n }\n \n -(NSInteger)numberOfSectionsInTableView: (UITableView *)tableView {\n return 1;\n }\n \n -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {\n return 2;\n }\n \n -(UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {\n UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@\"Cell\" forIndexPath:indexPath];\n NSString *str = @\"color\";\n cell.textLabel.text = [str stringByAppendingString:[NSString stringWithFormat:@\"%ld\", (long)indexPath.row]];\n \n return cell;\n }\n \n -(void)tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {\n UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@\"Main\" bundle:nil];\n \n if (indexPath.row == 0) {\n PinkViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@\"ViewController\"];\n [self.navigationController pushViewController:vc animated:YES];\n } else {\n GreenViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@\"GreenViewController\"];\n [self.navigationController pushViewController:vc animated:YES];\n }\n }\n \n @end\n \n```\n\n![画像の説明をここに入力](https://i.stack.imgur.com/seM6n.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T07:23:19.780", "favorite_count": 0, "id": "11987", "last_activity_date": "2015-07-03T07:46:55.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5210", "post_type": "question", "score": 0, "tags": [ "ios", "objective-c", "uisplitviewcontroller" ], "title": "SplitViewControllerのMasterViewのTableViewCellを選択するとMasterViewの画面が切り替わる", "view_count": 262 }
[ { "body": "showDetailViewControllerを使えば、期待されるような動作になるかと思います。\n\n```\n\n - (void)tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {\n UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@\"Main\" bundle:nil];\n UIViewController* vc = nil;\n if (indexPath.row == 0) {\n vc = [storyboard instantiateViewControllerWithIdentifier:@\"ViewController\"];\n } else {\n vc = [storyboard instantiateViewControllerWithIdentifier:@\"GreenViewController\"];\n }\n [self.splitViewController showDetailViewController:vc sender:nil];\n }\n \n```\n\nこんな感じでどうでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T07:46:55.433", "id": "11989", "last_activity_date": "2015-07-03T07:46:55.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7459", "parent_id": "11987", "post_type": "answer", "score": 1 } ]
11987
11989
11989
{ "accepted_answer_id": null, "answer_count": 1, "body": "初めまして、質問なんですが \nサイコロを振り、出た目を2x+5して結果が100以下の場合もう一度2x+5をし、 \n結果が100を超えたらその結果と何回計算したかを出力しろ\n\nという問題なんですがランダムな数字を生成することはできました。 \nしかしその先で躓いてしまい、中々うまくいきません。 \nどなたかアドバイスを下さい。 \nよろしくお願いします。\n\nとりあえず書いてみたソースです。\n\n```\n\n <html>\n <head>\n <meta charset=\"UTF-8\">\n </head>\n <body>\n <script>\n function GetRandomNumber() {\n var randnum = Math.floor( Math.random() * 9 );\n document.getElementById(\"sample\").innerHTML = randnum;\n }\n // -->\n var a = 0;\n var count = 0;\n var y = randnum;\n \n while(randnum < 100) {\n if(randnum > 100) {\n document.write(a+count+\"回目です\");\n }\n a += 2 * (y) + 5\n ++count;\n }\n </script>\n <p>\n <input type=\"button\" value=\"サイコロ\" onclick=\"GetRandomNumber();\">\n </p>\n <p>\n 出た目: <span id=\"sample\">***</span>\n </p>\n </body>\n </html>\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T07:42:10.937", "favorite_count": 0, "id": "11988", "last_activity_date": "2015-07-03T08:53:30.193", "last_edit_date": "2015-07-03T08:18:45.203", "last_editor_user_id": "3516", "owner_user_id": "10383", "post_type": "question", "score": -4, "tags": [ "javascript" ], "title": "Javascript超初心者です", "view_count": 340 }
[ { "body": "`document.write` は、ページを構成する時に使いますので、 \nボタンを押した時を起点に動作するようにする必要があります。 \n例えば以下のような感じにします。\n\n```\n\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <title>Sample</title>\n <script>\n function Dice() {\n return Math.floor(Math.random() * 6 ) + 1;\n }\n \n function DoIt() {\n var x = Dice();\n var count = 0;\n do {\n x = 2*x + 5;\n ++count;\n }while(x <= 100);\n document.getElementById(\"result\").innerHTML = \n x + \"になるまで\" + count + \"回計算しました。\";\n }\n </script>\n </head>\n <body>\n <p>\n <button type=\"button\" onclick=\"DoIt()\">実行</button>\n </p>\n <p>\n 結果: <span id=\"result\"></span>\n </p>\n </body>\n </html>\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T08:53:30.193", "id": "11995", "last_activity_date": "2015-07-03T08:53:30.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "11988", "post_type": "answer", "score": 1 } ]
11988
null
11995
{ "accepted_answer_id": "11991", "answer_count": 1, "body": "<http://dotinstall.com/lessons/basic_rails_v2/24923>\n\nドットインストールでのTaskAppを学習していたところ、 \nプロジェクト内で、Taskを追加していく処理ができなくてつまずいています。\n\n```\n\n class TasksController < ApplicationController \n def create \n @projerct = Project.find(params[:project_id]) \n @task = @project.tasks.create(task_params) \n redirect_to project_path(@project.id) \n end \n \n private \n \n def task_pramas \n params[:task].permit(:titele) \n end \n end \n \n```\n\n![エラー画面](https://i.stack.imgur.com/LcckA.png)\n\n上記のような処理をし、このようなエラメッセージが出ます。 \nなんども見直し、写経しましたが、原因がわかりません。\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T07:54:11.127", "favorite_count": 0, "id": "11990", "last_activity_date": "2015-07-03T08:08:43.107", "last_edit_date": "2015-07-03T08:08:43.107", "last_editor_user_id": "85", "owner_user_id": "9988", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails" ], "title": "ドットインストール Rails:TaskContlloerが生成できない", "view_count": 62 }
[ { "body": "`@projerct =`の部分がtypoしています。 \nスペルを修正してください。\n\n## 参考\n\nRubyは以下のような言語仕様があります。\n\n<http://docs.ruby-lang.org/ja/2.0.0/doc/spec=2fvariables.html>\n\n> `@'で始まる変数はインスタンス変数であり、特定の オブジェクトに所属しています。インスタンス変数はそのクラスま\n> たはサブクラスのメソッドから参照できます。 **初期化されていない インスタンス変数を参照した時の値はnilです。**\n\ntypoしていた`@projerct`は初期化されていますが、正しいスペルの`@project`は初期化されていなかったので`nil`となり、`nil`に対して`tasks`メソッドを呼びだしたので、質問のようなエラーが発生しています。\n\n今後も「うっかり」やってしまう可能性があるので、注意してくださいね。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T08:00:42.127", "id": "11991", "last_activity_date": "2015-07-03T08:00:42.127", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "85", "parent_id": "11990", "post_type": "answer", "score": 1 } ]
11990
11991
11991
{ "accepted_answer_id": "11993", "answer_count": 2, "body": "UICollectionViewにUILabel、UIImageViewを描画しています。 \ncellForItemAtIndexPathでaddSubViewしているUILabelが \nスクロールするたびに重なってしまう現象で悩んでいます。\n\n※UICollectionView自体はStoryboard上にあり、ReuseIdentifierを設定しています。\n\nsubviewを削除するように入れてみても重なってしまいます。 \nどこか間違っていますでしょうか? \nアドバイスいただけますと幸いです。\n\n```\n\n - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {\n \n UICollectionViewCell * cell;\n NSString *cellIdentifier = @\"newscell\";\n cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];\n \n for (UIView* view in cell.contentView.subviews)\n {\n [view removeFromSuperview];\n \n }\n \n UILabel *titleLabel = [[UILabel alloc] init];\n UILabel *dateLabel = [[UILabel alloc] init];\n UILabel *textLabel = [[UILabel alloc] init];\n UIImageView *imageView = [[UIImageView alloc] init];\n \n //ここに各Viewのframeなどを設定するコード(割愛)\n \n [cell addSubview:titleLabel];\n [cell addSubview:dateLabel];\n [cell addSubview:textLabel];\n return cell;\n \n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T08:25:23.710", "favorite_count": 0, "id": "11992", "last_activity_date": "2015-07-06T05:41:47.723", "last_edit_date": "2015-07-03T08:41:38.547", "last_editor_user_id": "8772", "owner_user_id": "8772", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c", "uicollectionview" ], "title": "UICollectionViewをスクロールすると描画が重なってしまう", "view_count": 1454 }
[ { "body": "```\n\n //ここに各Viewのframeなどを設定するコード(割愛)\n \n // [cell addSubview:titleLabel];\n [cell.contentView addSubView: titleLabel];\n // [cell addSubview:dateLabel];\n [cell.contentView addSubView: dateLabel];\n // [cell addSubview:textLabel];\n [cell.contentView addSubView: textLabel];\n return cell;\n \n }\n \n```\n\nこのように変更したら、どうなりますか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T08:34:31.367", "id": "11993", "last_activity_date": "2015-07-03T08:34:31.367", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "11992", "post_type": "answer", "score": 2 }, { "body": "-cellForItemAtIndexPath: の中で -addSubview: するのをそもそもやめた方がいいと思います。 \nUICollectionViewCell のサブクラスを作成し、サブクラスの初期化時にラベルを生成、プロパティとしましょう。 \nそうすることで subviews を removeFromSuperview する余計な処理もいらなくなります。\n\n上記を行った上で -cellForItemAtIndexPath: の中で行うのは「ラベルの表示内容の変更」としましょう。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T05:41:47.723", "id": "12069", "last_activity_date": "2015-07-06T05:41:47.723", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7376", "parent_id": "11992", "post_type": "answer", "score": 2 } ]
11992
11993
11993
{ "accepted_answer_id": null, "answer_count": 1, "body": "Androidアプリを起動した時Cookieが残っていたら直接WebViewを表示して \n残っていなかったらログイン画面を表示させようとしています。\n\nCookieManagerにセットしたCookieの生存期間は同じCookieをブラウザで保存した時と同じでしょうか? \nまた、今回の場合はSharedPreferencesかなにかに保存したほうが効果的でしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T09:16:08.647", "favorite_count": 0, "id": "11997", "last_activity_date": "2016-01-23T06:17:20.933", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9710", "post_type": "question", "score": 2, "tags": [ "android", "cookie" ], "title": "CookieManagerにセットしたCookieの生存期限が知りたい。", "view_count": 1306 }
[ { "body": "ログインしてすぐ再起動とかでは \n`CookieManager`がCookieをきちんと保存できていない(nullが返ってくる)ことに気づきました。 \nなので`SharedPreferences`かなにかに保存したほうがよいかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-26T02:53:05.527", "id": "14848", "last_activity_date": "2015-08-26T02:53:05.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9710", "parent_id": "11997", "post_type": "answer", "score": 1 } ]
11997
null
14848
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在、以下の環境でPDFを帳票出力しています。\n\n* * *\n\nCentOS6.6 \nRails 4.0.2 \nruby 2.1.0 \nwkhtmltox-0.12.2.1 \nwicked_pdf 0.11.0\n\n* * *\n\nこの環境でHTMLのテーブルで帳票レイアウトし、PDFを出力し、テーブルがページをまたがると、またがった方のページの帳票の \nレイアウトが崩れてしまいます。\n\n具体的には、テーブルのヘッダーが再度表示されその次に表示するはずの行をさらに上に印字してしまっているような表示です。\n\n例) \n1ページ目 \nid | name | age | \n1 | tanaka | 30 | \n2 | aikawa | 48 | \n3 | nomura | 29 | \n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n2ページ目 \nid 32 | name noda | age 32 | \n33 | tanabe | 18 | \n34 | tamura | 25 |\n\nテーブルのヘッダーが再度表示される事自体は非常に喜ばしい事なんですが、 \nどうしても上記のような表示になるのならヘッダーは始めの一つだけで構わないと考えております。\n\nなにか、良い回避方法などありますでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T12:20:14.433", "favorite_count": 0, "id": "11998", "last_activity_date": "2015-07-03T12:20:14.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10388", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails", "ruby" ], "title": "Rails&wicked_pdfによるPDF出力について", "view_count": 176 }
[]
11998
null
null
{ "accepted_answer_id": "12000", "answer_count": 1, "body": "Mac OSX上でPHP 5.6.2を使っています。\n\n以下のディレクトリ構成を`zip -ry`して圧縮ファイルを作成しました。 \nこのファイルをunzipコマンドで解凍すると、シンボリックリンクを正しく抽出できるのですが、PHPのZipArchiveクラスを使って解凍すると、ただのファイルになってしまいます。\n\nPHPを使って、シンボリックリンクを正しく解凍するよい方法はないでしょうか? \nなお、圧縮ファイルの種類や、PHPのライブラリの種類は問いません。\n\n### 圧縮ファイルの作成\n\nシンボリックリンクを含んでいます。\n\n```\n\n $ tree samples\n samples\n ├── symlinks\n │   ├── text1.txt -> ../text1.txt\n │   └── text2.txt -> ../text2.txt\n ├── text1.txt\n └── text2.txt\n \n $ zip -ry samples.zip samples\n \n```\n\n### unzipで解凍\n\nシンボリックリンクを正しく解凍できています。\n\n```\n\n $ unzip samples.zip -d tmp\n $ tree tmp\n tmp\n └── samples\n ├── symlinks\n │   ├── text1.txt -> ../text1.txt\n │   └── text2.txt -> ../text2.txt\n ├── text1.txt\n └── text2.txt\n \n```\n\n### PHPで解凍\n\nシンボリックリンクがただのファイルになってしまいました。\n\n```\n\n $ php unzip.php \n $ tree tmp\n tmp\n └── samples\n ├── symlinks\n │   ├── text1.txt\n │   └── text2.txt\n ├── text1.txt\n └── text2.txt\n \n```\n\nPHPの解凍用プログラム\n\n```\n\n <?php // unzip.php\n \n $zip = new ZipArchive;\n $zip->open(\"samples.zip\");\n $zip->extractTo(\"tmp\");\n $zip->close();\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T12:31:14.307", "favorite_count": 0, "id": "11999", "last_activity_date": "2015-07-05T01:45:58.800", "last_edit_date": "2015-07-05T01:45:58.800", "last_editor_user_id": "9529", "owner_user_id": "9529", "post_type": "question", "score": 4, "tags": [ "php" ], "title": "PHPでシンボリックリンクを含む圧縮ファイルを解凍したい", "view_count": 576 }
[ { "body": "`php5.6.0`で追加された[`getExternalAttributesIndex`](http://php.net/manual/ja/ziparchive.getexternalattributesindex.php)を利用するとシンボリックリンクかどうかが判定できます。\n\n```\n\n <?php\n \n function extractToSym($zip, $dir)\n {\n for ($idx=0; $s = $zip->statIndex($idx); $idx++) {\n if ($zip->getExternalAttributesIndex($idx, $opsys, $attr) && $opsys == ZipArchive::OPSYS_UNIX) {\n if ((($attr >> 16) & 0120000) === 0120000) {\n symlink($zip->getFromIndex($idx), $dir . '/' . $s['name']);\n } else {\n $zip->extractTo($dir, $s['name']);\n }\n }\n }\n }\n \n $zip = new ZipArchive();\n if ($zip->open('samples.zip') === TRUE) {\n extractToSym($zip, '.');\n $zip->close();\n }\n \n```\n\n**追記:**\n\nzipファイルの`ExternalAttributes`について、ドキュメントは見つかりませんでしたが[`Info-\nZIP`](http://sourceforge.net/projects/infozip/?source=typ_redirect)のソースコードを見る限りでは、この数値は`stat`構造体の`st_mode`フィールドの値を16bit左にシフトしたもののようです。\n\n```\n\n *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE);\n \n```\n\n[`sys/stat.h`](http://linuxjm.osdn.jp/html/LDP_man-\npages/man2/stat.2.html)ではシンボリックリンクのフラグが`0120000`と定義されています。\n\nソースコードを見る限りではwindowsでも似たような構造になっているようですが、手元に確認できる環境がないので詳しくは分かりません。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T13:19:33.980", "id": "12000", "last_activity_date": "2015-07-04T10:53:12.737", "last_edit_date": "2015-07-04T10:53:12.737", "last_editor_user_id": "3639", "owner_user_id": "3639", "parent_id": "11999", "post_type": "answer", "score": 5 } ]
11999
12000
12000
{ "accepted_answer_id": null, "answer_count": 1, "body": "# 背景と質問\n\n以下のようなプログラムを見掛けました。\n\n```\n\n char *token1 = strtok(str, \" \");\n char *token2 = strtok(NULL, \" \");\n char *token3 = strtok(NULL, \" \");\n \n if(token1 == NULL) {\n // トークンがない場合の処理\n }\n else if(token2 == NULL) {\n // トークンが1個の場合の処理\n ...\n }\n else if(token3 == NULL) {\n // トークンが2個の場合の処理\n ...\n }\n else {\n // トークンが3個以上の場合の処理\n ...\n }\n \n```\n\nこのプログラムでは、`strtok()` が一度 `NULL` を返した後、続けて `strtok(NULL, ...)`\nを呼ぶことができる、ということが前提になっています。 \nこういった使い方は今まで思い付かず、考えたことがない、というより無意識のうちに未定義と思い込んでいたのですが、このような使い方は規格上保証されているものなのでしょうか。\n\n# 規格調査\n\n検証のために、規格を調べてみました。 \nISO/IEC 9899:2011 の 7.24.5.8 The `strtok` function から引用します (強調は引用者による)。 \nこの引用中の `s1`、`s2` は、それぞれ `strtok` の第1引数、第2引数を表します。\n\n> 3 \n> The first call in the sequence searches the string pointed to by `s1` for\n> the first character \n> that is not contained in the current separator string pointed to by `s2`.\n> If no such character \n> is found, then there are no tokens in the string pointed to by `s1` and the\n> **`strtok` function \n> returns a null pointer**. If such a character is found, it is the start of\n> the first token.\n>\n> 4 \n> The `strtok` function then searches from there for a character that is\n> contained in the \n> current separator string. If no such character is found, the current token\n> extends to the \n> end of the string pointed to by `s1`, and **subsequent searches for a token\n> will return a null \n> pointer**. If such a character is found, it is overwritten by a null\n> character, which \n> terminates the current token. **The`strtok` function saves a pointer to the\n> following \n> character**, from which the next search for a token will start.\n>\n> 5 \n> Each subsequent call, with a null pointer as the value of the first\n> argument, starts \n> searching from the saved pointer and behaves as described above.\n\nこの記述について、以下のように場合分けして考えてみました。\n\nここで、パラグラフ5の書き方は曖昧に感じましたが、`strtok(NULL, ...)` 呼び出しについては、パラグラフ3と4の `s1` を\nパラグラフ4で保存したポインタに置き換えて実行する、という意味であると解釈しました。\n\n## ケース1: `s1` = `\"abc def\"` のように、トークン文字で終わる場合\n\n`\"def\"` が返った後の呼び出しで、パラグラフ 4 の「subsequent **searches** for a token will return\na null pointer」のパターンに合致し、`NULL` が返ります。「search」が複数形となっているため、何度 `strtok(NULL,\n...)` を呼んでも `NULL` が返ります。\n\n## ケース2: `s1` = `\"abc def \"` のように、トークン列の末尾に区切り文字がある場合\n\n`\"def\"` が返った後の呼び出しで、パラグラフ 3 の「`strtok` function returns a null\npointer」のパターンに合致し、`NULL` が返ります。何かしら保存したポインタ (このケースでは文字列末尾)\nがあり、そのポインタのアップデートがないため、何度呼んでもパラグラフ3のパターンに合致して `NULL` が返ります。\n\n## ケース3: `s1` = `\" \"` のように、トークン列がない場合\n\n前項と同様、パラグラフ3のパターンに合致して `NULL` が返ります。この場合、保存したポインタというものがないため、\n**後続の`strtok(NULL, ...)` は未定義になりそう**です。\n\n以上、場合によっては `NULL` が返った後の `strtok(NULL, ...)` は `NULL`\nが返り、別の場合では未定義になりそうに思えました。 \nしかし、それでは何とも中途半端で気持ち悪く感じます。 \nこれをどう考えるか、ということで、以下の2通りの可能性を考えました。\n\n * 上記の解釈に間違いがあり、`NULL` が返るか未定義かはどちらか一方に定まる。\n * 基本的に未定義と考えるべき。パラグラフ4で 「search」が複数形になっていることに特に意味はない。\n\nしかし、何が正しいのかという確証は取れませんでした。\n\n# 実験\n\n参考までに、手持ちの環境ではどうなのか実験してみました。\n\n## 環境:\n\n * OS: Gentoo Linux\n * コンパイラ: gcc 4.8.4, clang 3.5.0\n * ライブラリ: glibc 2.20\n\n## プログラム:\n\n```\n\n #include <stdio.h>\n #include <string.h>\n \n // トークンの内容を出力。ただし NULL の場合は \"(null)\" を出力。\n #define PR_TOKEN(token) do { printf(#token \" = %s\\n\", (token)? token: \"(null)\"); } while(0)\n \n int main(void)\n {\n // ケース1: 文字列がトークン文字で終わる\n char str1[] = \"abc def\";\n char *token1_1 = strtok(str1, \" \");\n char *token1_2 = strtok(NULL, \" \");\n char *token1_3 = strtok(NULL, \" \");\n char *token1_4 = strtok(NULL, \" \");\n PR_TOKEN(token1_1);\n PR_TOKEN(token1_2);\n PR_TOKEN(token1_3);\n PR_TOKEN(token1_4);\n \n // ケース2: 文字列が区切り文字で終わる\n char str2[] = \"abc def \";\n char *token2_1 = strtok(str2, \" \");\n char *token2_2 = strtok(NULL, \" \");\n char *token2_3 = strtok(NULL, \" \");\n char *token2_4 = strtok(NULL, \" \");\n PR_TOKEN(token2_1);\n PR_TOKEN(token2_2);\n PR_TOKEN(token2_3);\n PR_TOKEN(token2_4);\n \n // ケース3: トークン列がない\n char str3[] = \" \";\n char *token3_1 = strtok(str3, \" \");\n char *token3_2 = strtok(NULL, \" \");\n char *token3_3 = strtok(NULL, \" \");\n char *token3_4 = strtok(NULL, \" \");\n PR_TOKEN(token3_1);\n PR_TOKEN(token3_2);\n PR_TOKEN(token3_3);\n PR_TOKEN(token3_4);\n \n return 0;\n }\n \n```\n\n## 結果:\n\n```\n\n token1_1 = abc\n token1_2 = def\n token1_3 = (null)\n token1_4 = (null)\n token2_1 = abc\n token2_2 = def\n token2_3 = (null)\n token2_4 = (null)\n token3_1 = (null)\n token3_2 = (null)\n token3_3 = (null)\n token3_4 = (null)\n \n```\n\nすべてのケースについて、一度 `NULL` が返った後の `strtok()` 呼び出しで `NULL` が返っています。 \n今回、正当性について疑問が残るケース3について、ケース1\n、ケース2で保存していた情報が残っているため、たまたまうまく動いている、ということを疑い、ケース3のみを実行したり、ケース2の最初の `strtok()`\n呼び出しの直後にケース3に入ってみても同様でした。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T17:39:14.040", "favorite_count": 0, "id": "12001", "last_activity_date": "2015-07-03T21:26:12.550", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7831", "post_type": "question", "score": 10, "tags": [ "c" ], "title": "strtok() が NULL を返した後、さらに strtok(NULL, ...) を呼んでもよいのか。", "view_count": 1677 }
[ { "body": "> 7 \n> The strtok function returns a pointer to the first character of a token, or\n> a null pointer if there is no token.\n\nとありますので、該当するトークンがない場合にはNULLを返すと考えて良いと思います。\n\n参考までに、 \nCリファレンスマニュアル第5版の解説によると、\n\n> すべての文字がsetに属していればstrtokはナルポインタを返し内部状態ポインタをナルポインタに設定する.\n\nとありますので、ケース3の場合も内部ポインタがナルに設定される。のが質問者の想定と違います。 \nまた、\n\n>\n> strと内部状態ポインタが共にナルポインタであれば,strtokはナルポインタを返し,内部状態ポインタはそのままにする.(すべての字句を返してもなおstrtokが呼ばれた時の備えである)\n\n(※strは第一引数setは第2引数のこと) \nとあるので、 \n「strtok() が一度 NULL を返した後、続けて strtok(NULL, ...) を呼ぶことができる」 \nは、前提としてよく、NULLを返すということになります。", "comment_count": 15, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T21:26:12.550", "id": "12004", "last_activity_date": "2015-07-03T21:26:12.550", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "12001", "post_type": "answer", "score": 4 } ]
12001
null
12004
{ "accepted_answer_id": null, "answer_count": 2, "body": "以下のコードで `num` は0~6になる思うのですが、すべて4になってしまいます。 \n`num=rand()%7` の7を他の数字でやると0〜その数字の間の数となります。 \n7の時のみこのようになってしまうのですがなぜでしょうか?\n\n環境は MacBook Pro、xcode Version 6.1です。\n\n```\n\n #include<time.h>\n #include<stdio.h>\n #include<stdlib.h>\n \n int main(void){\n int i,num;\n \n srand(time(NULL));\n num=rand()%7;\n \n for(i=0;i<10;i++){\n printf(\"%d\\n\",num);\n }\n return 0;\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2015-07-03T21:23:49.240", "favorite_count": 0, "id": "12003", "last_activity_date": "2021-03-10T05:21:57.690", "last_edit_date": "2021-03-10T05:21:57.690", "last_editor_user_id": "3060", "owner_user_id": "10389", "post_type": "question", "score": 4, "tags": [ "xcode", "c", "random" ], "title": "C言語での乱数生成で常に同じ値となってしまうケースがある", "view_count": 5312 }
[ { "body": "forループの中で `num`\nの値は変更されていませんから、最初に決まった値を毎回表示することになります。必要であればforループの中で`num`の値を再設定してください。\n\n```\n\n for(i=0;i<10;i++){\n num=rand()%7;\n printf(\"%d\\n\",num);\n }\n \n```\n\n* * *\n\nquesera2さんがXcodeにおけるrandの実装のリンクを張られています。\n\n```\n\n static int\n do_rand(unsigned long *ctx)\n {\n #ifdef USE_WEAK_SEEDING\n /*\n * Historic implementation compatibility.\n * The random sequences do not vary much with the seed,\n * even with overflowing.\n */\n return ((*ctx = *ctx * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));\n #else /* !USE_WEAK_SEEDING */\n /*\n * Compute x = (7^5 * x) mod (2^31 - 1)\n * wihout overflowing 31 bits:\n * (2^31 - 1) = 127773 * (7^5) + 2836\n * From \"Random number generators: good ones are hard to find\",\n * Park and Miller, Communications of the ACM, vol. 31, no. 10,\n * October 1988, p. 1195.\n */\n long hi, lo, x;\n \n /* Can't be initialized with 0, so use another value. */\n if (*ctx == 0)\n *ctx = 123459876;\n hi = *ctx / 127773;\n lo = *ctx % 127773;\n x = 16807 * lo - 2836 * hi;\n if (x < 0)\n x += 0x7fffffff;\n return ((*ctx = x) % ((u_long)RAND_MAX + 1));\n #endif /* !USE_WEAK_SEEDING */\n }\n \n```\n\nとなっています。`srand(time(NULL));`直後の`rand()%7`の値に限定すると、 \n変数`hi`は`127773`で除算しているので127773秒ごとにしか変化しません。変数`lo`は`7^5`を乗じているので7の倍数です。つまり、127773秒(およそ35.5時間)周期でしか7の剰余の値は変化しません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-07-03T21:29:44.673", "id": "12005", "last_activity_date": "2021-01-25T04:33:56.133", "last_edit_date": "2021-01-25T04:33:56.133", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "12003", "post_type": "answer", "score": 17 }, { "body": "`num=rand()%7;`を`for`文に移動すれば、同じ数値が返ってくることはなくなります。\n\n```\n\n #include<time.h>\n #include<stdio.h>\n #include<stdlib.h>\n \n int main(void){\n int i,num;\n \n srand((unsigned int)time(NULL)); // キャストしないと警告文が出ると思いますが?\n \n for(i=0;i<10;i++){ \n num=rand()%7;\n printf(\"%d\\n\",num);\n }\n return 0;\n }\n \n```\n\nしかし、これでもじつはまだ問題が残ってしまいます。というのは、なんどビルドして実行しても初回の値がかならず4になるという現象が現れます。乱数を使用する目的からすれば、都合が悪い現象です。 \nこれはXcodeがインストールする、 **CLang+LLVMが内蔵する擬似乱数発生のアルゴリズム** に欠陥があるからといえると思います。 \n乱数表の冒頭は捨てて、途中を採用すれば、より良い結果が得られると思います。\n\n```\n\n #include<time.h>\n #include<stdio.h>\n #include<stdlib.h>\n \n int main(void){\n int i,num;\n \n srand((unsigned int)time(NULL));\n // 乱数表の冒頭10個は捨てる。\n for (i=0;i<10;i++) {\n rand();\n };\n \n for(i=0;i<10;i++){\n num=rand()%7;\n printf(\"%d\\n\",num);\n }\n return 0;\n }\n \n```\n\n擬似乱数発生のアルゴリズムに完璧なものはないと言われています。用途に応じて、使い分けるか、上のような工夫が必要でしょう。 \nMac、iOS上のプログラムなら、`arc4random()`、`arc4random_uiiform()`という、Free\nBSD由来の関数が使え、C言語の`rand()`関数より高い品質の乱数表を得られるといいます。", "comment_count": 12, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T22:43:49.123", "id": "12006", "last_activity_date": "2015-07-05T12:09:41.713", "last_edit_date": "2015-07-05T12:09:41.713", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "12003", "post_type": "answer", "score": 8 } ]
12003
null
12005
{ "accepted_answer_id": null, "answer_count": 0, "body": "WPFでコレクションバインドを行うコントロールを作成しています。\n\nコントロールにバインドされているデータの関連を表現するため、`HierarchicalDataTemplate`のような`BindingBase`型のプロパティを持つ`DataTemplate`派生型を定義しました。しかしC#コードのビルドは可能ですがXAMLでプロパティを設定すると、\n\n> プロパティ 'Fuga' は、テンプレートのプロパティ要素として設定できません。Triggers と Storyboards\n> だけをプロパティ要素として使用できます。\n\nと出力されてしまいます。Visual Studio 2013と.NET4.5.1で条件を変えて試したところ、\n\n 1. 元の事象→NG\n\nC#\n\n```\n\n public class HogeDataTemplate : DataTemplate\n {\n public BindingBase Fuga { get; set; }\n }\n \n```\n\nXAML\n\n```\n\n <c:CustomControl1>\n <c:CustomControl1.HogeTemplate>\n <c:HogeDataTemplate Fuga=\"{Binding Piyo}\" />\n </c:CustomControl1.HogeTemplate>\n </c:CustomControl1>\n \n```\n\n 2. Resourcesに記述した場合→NG\n\nXAML\n\n```\n\n <Window>\n <c:Window.Resources>\n <c:HogeDataTemplate x:Key=\"hoge\" Fuga=\"{Binding Piyo}\" />\n </c:Window.Resources>\n </Window>\n \n```\n\n 3. `{Binding}`以外のマークアップ拡張を使用した場合→NG\n\nXAML\n\n```\n\n <c:HogeDataTemplate Fuga=\"{x:Null}\" />\n \n```\n\n 4. プリミティブ型に変更した場合→OK\n\nC#\n\n```\n\n public class HogeDataTemplate : DataTemplate\n {\n public int Fuga { get; set; }\n }\n \n```\n\nXAML\n\n```\n\n <c:HogeDataTemplate Fuga=\"123\" />\n \n```\n\n 5. 要素記法を使用した場合→OK\n\nXAML\n\n```\n\n <c:HogeDataTemplate>\n <c:HogeDataTemplate.Fuga>123</c:HogeDataTemplate.Fuga>\n </c:HogeDataTemplate>\n \n```\n\n 6. 要素記法で型を明示した場合→NG\n\nXAML\n\n```\n\n <c:HogeDataTemplate>\n <c:HogeDataTemplate.Fuga>\n <sys:Int32>123</sys:Int32>\n </c:HogeDataTemplate.Fuga>\n </c:HogeDataTemplate>\n \n```\n\nと、文字列でプロパティを記述することのみ可能であるように思われました。[HierarchicalDataTemplateの実装](http://referencesource.microsoft.com/#PresentationFramework/Framework/System/Windows/HierarchicalDataTemplate.cs,4c41161ffea91bc9)では特にカスタム属性などを指定してはいないのでBAML変換ランタイムで`DataTemplate`専用の最適化がかかっている影響ではないかと思いますが、`Style`でバインドさせる以外の回避方法は無いでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T00:38:59.087", "favorite_count": 0, "id": "12007", "last_activity_date": "2015-07-04T00:38:59.087", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "post_type": "question", "score": 1, "tags": [ "c#", "visual-studio", "wpf" ], "title": "DataTemplate継承クラスにプロパティを設定するとビルド時に例外が発生する", "view_count": 484 }
[]
12007
null
null
{ "accepted_answer_id": "12012", "answer_count": 1, "body": "Adaptiveなレイアウトを作成する為に、まず`Auto Layout`でレイアウトを組めるようになったので次は`Size\nClass`について理解を深めたいと思うのですが、理解が及んでいないので質問させていただきます。 \nまず`Size\nClass`を使う目的は、「iPhoneとiPadのレイアウトを一つの`Storyboard`で作成できるようにすること」という認識でよろしいでしょうか? \nまた、iPhoneとiPadの縦画面、横画面に対応するアプリを作成するには「Compact Width|Regular Height」、「Regular\nWidth|Compact Height」、「Regular Width|Regular Height」の3つの`Size\nClass`でレイアウトを作成していけばいいでしょうか?(「Any Width|Any Height」はiPadも対応するとなるとあまり使わない...?) \nしかしなぜ`Auto Layout`のみでマルチデバイス対応ができないのでしょうか?`Size\nClass`を使う時はなにか特別なことを行うレイアウトの場合とかでしょうか?(例えば`SplitView`とか?)\n\nイマイチ`Size Class`を使うメリットや使うシチュエーションがわからず、どう使っていいかが分かりません。 \nどなたか分かる方に教えていただきたいです。分からない点が多く、質問が多くてすみませんが、よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T00:59:32.343", "favorite_count": 0, "id": "12008", "last_activity_date": "2015-07-04T02:38:40.187", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5210", "post_type": "question", "score": 2, "tags": [ "ios", "xcode", "sizeclass" ], "title": "Size Classの使い方", "view_count": 709 }
[ { "body": "まずAutoLayoutだけでマルチデバイス対応をすることも可能です。これはあくまで一例ですが、AutoLayoutだけでは対応しにくいレイアウト、例えばiPhoneでは縦に並べていたものをiPadでは横に並べる、あるいはiPadではiPhoneに存在しない項目がある、みたいなときにはSizeClassを利用するとよいです。\n\n考え方でいうと、SizeClassはStoryBoardを差分で構築できる仕組みです。 \nベースとなるStoryBoardがあり、特定のデバイスにおいて、レイアウトが大きく違ったり、項目の増減があるような場合は、1つのStoryBoardだけでそれを実現するのは難しいので、「基本的にはベースのレイアウトだけど、このサイズのときはこの部分が少し変わる」という感覚で使います。\n\nSizeClassが道入される以前は、そういった対応は複数のStoryBoardを使い分けるか、コードで条件を分岐する必要がありました。 \nそれを1つのStoryBoardで部分的に切り替える、ようなことができるようになったのがSizeClassのメリットです。\n\nただし、残念ながらXcodeのSizeClassを編集するUIはあまり分かりやすくなく、どこに別のSizeClassが使われているかを目で確認するのが難しいので、あえてSizeClassを使わずに複数のStoryBoardあるいはコードで書くという選択も有効です。\n\nまた、SizeClassはすべての画面サイズの違いや特定のデバイスに対応できるわけではないので、例えばiPhone\n6だけ特別な画面を提供したい、などという場合はSizeClassだけでは対応できません。\n\nなので上記の仕組みを理解して、SizeClassを使うとシンプルに分かりやすくなる、という場合に上手に活用することが大事になります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T02:38:40.187", "id": "12012", "last_activity_date": "2015-07-04T02:38:40.187", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "12008", "post_type": "answer", "score": 7 } ]
12008
12012
12012
{ "accepted_answer_id": null, "answer_count": 1, "body": "Webbrowserでホームページを指定できるようにしたいのですが。 \nTextBoxにホームページにするURLを設定して、Enterを押したら、ホームページが、 \nさっき指定したURLが出る?みたいなようにする方法を教えて下さい。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T01:14:04.297", "favorite_count": 0, "id": "12009", "last_activity_date": "2015-07-04T01:49:48.563", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10390", "post_type": "question", "score": 1, "tags": [ "c#" ], "title": "Webbrowserでホームページを設定できるようにしたい。", "view_count": 210 }
[ { "body": "Forms、WPFともに`WebBrowser.Navigate(string)`というメソッドを使用すればよいです。以下はFormsのコード例です。\n\n```\n\n public partial class Form1 : Form\n {\n public Form1()\n {\n // コントロールの配置。通常はInitializeComponent();で良い\n var button1 = new Button();\n button1.Dock = DockStyle.Top;\n button1.Text = \"Go\";\n Controls.Add(button1);\n \n var textBox1 = new TextBox();\n textBox1.Dock = DockStyle.Top;\n textBox1.Text = \"http://ja.stackoverflow.com/\";\n Controls.Add(textBox1);\n \n \n var webBrowser = new WebBrowser();\n webBrowser.Dock = DockStyle.Fill;\n Controls.Add(webBrowser);\n \n // イベントハンドラーの登録(確定ボタンを使用する場合)\n AcceptButton = button1;\n button1.Click += (s, e) =>\n {\n // URL移動\n webBrowser.Navigate(textBox1.Text);\n };\n \n // イベントハンドラーの登録(リターンキーの直接ハンドル)\n textBox1.KeyDown += (s, e) => \n {\n if (!e.Handled && e.KeyCode == Keys.Return)\n {\n // URL移動\n webBrowser.Navigate(textBox1.Text);\n e.Handled = true;\n }\n };\n }\n }\n \n```\n\nなおコード中にラムダ式を使用している箇所(~`+= (s, e)\n=>`~)が2個ありますが、これは通常のイベントハンドラーで問題ありません。プロパティウィンドウから該当イベントを探して登録してください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T01:37:00.217", "id": "12010", "last_activity_date": "2015-07-04T01:49:48.563", "last_edit_date": "2015-07-04T01:49:48.563", "last_editor_user_id": "5750", "owner_user_id": "5750", "parent_id": "12009", "post_type": "answer", "score": 1 } ]
12009
null
12010
{ "accepted_answer_id": null, "answer_count": 2, "body": "SNIにてSSLを使用する際に、ホスト名無し「hogehoge.com」の証明書は使用できますか? \n現在、2ドメイン登録しています。 \n1.「domain1.com」 \n2.「www.domain2.com」 \nこの時、「www.domain2.com」は、正常に認識しますが、「domain1.com」は、先に読み込まれた証明書を認識してしまいエラーとなります。 \n環境は、 \nhttpd-2.2.15-39 \nopenssl-1.0.1e-30 \nmod_ssl-2.2.15-39 \nです。 \nOSはcentos6.6\n\n```\n\n LoadModule ssl_module modules/mod_ssl.so\n Listen 443\n SSLPassPhraseDialog builtin\n SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)\n SSLSessionCacheTimeout 300\n SSLMutex default\n SSLRandomSeed startup file:/dev/urandom 256\n SSLRandomSeed connect builtin\n SSLCryptoDevice builtin\n \n NameVirtualHost *:443\n SSLStrictSNIVHostCheck off\n \n <VirtualHost *:443>\n ServerName domain1.com:443\n DocumentRoot \"/home/data/domain1.com/public_html\"\n SSLEngine on\n SSLProtocol all -SSLv2 -SSLv3\n SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW\n SSLCertificateFile /home/config/ssl_key/domain1.com/server.crt\n SSLCertificateKeyFile /home/config/ssl_key/domain1.com/server.key\n SSLCACertificateFile /home/config/ssl_key/domain1.com/ca-bundle.crt\n </VirtualHost>\n \n <VirtualHost *:443>\n ServerName www.domain2.com:443\n DocumentRoot \"/home/data/domain2.com/public_html\"\n SSLEngine on\n SSLProtocol all -SSLv2 -SSLv3\n SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW\n SSLCertificateFile /home/config/ssl_key/www.domain2.com/server.crt\n SSLCertificateKeyFile /home/config/ssl_key/www.domain2.com/server.key\n SSLCACertificateFile /home/config/ssl_key/www.domain2.com/ca-bundle.crt\n </VirtualHost>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T02:11:47.277", "favorite_count": 0, "id": "12011", "last_activity_date": "2015-07-06T10:37:40.253", "last_edit_date": "2015-07-06T10:37:40.253", "last_editor_user_id": "8000", "owner_user_id": "10391", "post_type": "question", "score": 1, "tags": [ "apache", "ssl" ], "title": "apacheでのSSL(SNI)設定について", "view_count": 5265 }
[ { "body": "こちらの記事などが参考になるでしょうか。\n\n<https://blog.apar.jp/linux/378/> \n<http://e-garakuta.net/techinfo/doku.php/linux/apache-sni>\n\nSNIはホスト名に対して制約は特にないようですが、使うときにいくつか留意点があるようです。\n\n * OpenSSLではTLS拡張オプションを指定\n * 上記のOpenSSLを使ってApache Httpdをビルド\n * ブラウザがSNIに対応していないと利用できない\n\nまた、できればインストールしたOSやApache\nHTTPDの導入や、httpd.confや参照しているconfファイルが提示されていれば、より明確になるかも知れません。ご参考になれば幸いです。", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T02:54:46.140", "id": "12013", "last_activity_date": "2015-07-04T02:54:46.140", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5778", "parent_id": "12011", "post_type": "answer", "score": 1 }, { "body": "1つの証明書しか有効にならないのは、「NameVirtualHost\n*:443」が設定されていないのではないでしょうか。もしくは、ブラウザが対応していないか。\n\n「NameVirtualHost *:443」が設定されていないと、\"httpd -t\" で以下のエラーが出ます。\n\n```\n\n [warn] _default_ VirtualHost overlap on port 443, the first has precedence\n \n```", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T06:01:21.937", "id": "12017", "last_activity_date": "2015-07-04T06:01:21.937", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4603", "parent_id": "12011", "post_type": "answer", "score": 0 } ]
12011
null
12013
{ "accepted_answer_id": "12028", "answer_count": 1, "body": "TwitterでC++の情報を得ようと思い、 \n`C++`で検索をしたのですが、 \n検索結果が`c`が含まれる全ての呟きになってしまい、 \nうまくC++に関する呟きを抽出できませんでした。\n\nC++に関する呟きを探すにはどのようにして検索すればよいでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T05:09:41.170", "favorite_count": 0, "id": "12014", "last_activity_date": "2015-07-04T13:36:19.187", "last_edit_date": "2015-07-04T12:01:32.077", "last_editor_user_id": "8000", "owner_user_id": "9758", "post_type": "question", "score": 2, "tags": [ "twitter" ], "title": "TwitterでC++に関する呟きを探すには", "view_count": 714 }
[ { "body": "同じ目的でたまにYahoo!リアルタイム検索 <http://search.yahoo.co.jp/realtime> を使っています。 \nただ正確さはよくわかりません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T13:36:19.187", "id": "12028", "last_activity_date": "2015-07-04T13:36:19.187", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "12014", "post_type": "answer", "score": 1 } ]
12014
12028
12028
{ "accepted_answer_id": null, "answer_count": 0, "body": "Unityの開発でMonoDevelopを使用していますが、 \nEclipseを使い慣れているため、キー配置をEclipseに合わせたいです。 \nキー配置を一つ一つ見比べるのではなくて、すぐにEclipseに合わせる方法などないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T05:15:20.593", "favorite_count": 0, "id": "12015", "last_activity_date": "2015-07-04T05:15:20.593", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10074", "post_type": "question", "score": 1, "tags": [ "c#", "eclipse" ], "title": "MonoDevelop のキー配置を Eclipse に合わせる方法", "view_count": 80 }
[]
12015
null
null
{ "accepted_answer_id": "12110", "answer_count": 2, "body": "```\n\n String s = System.console().readLine(); // 1\n \n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String s = br.readLine(); // 2\n \n```\n\n1と2の違いはなんなのでしょうか? \n違いがある場合、それぞれのメリット、デメリットについても教えて頂けるとありがたいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T07:02:25.673", "favorite_count": 0, "id": "12018", "last_activity_date": "2015-07-07T08:13:33.340", "last_edit_date": "2015-07-07T08:13:33.340", "last_editor_user_id": "8000", "owner_user_id": "9850", "post_type": "question", "score": 3, "tags": [ "java" ], "title": "コンソール入力を読み取る際、System.console() と System.in の違いは?", "view_count": 4990 }
[ { "body": "入力に対する読み取り機能そのものには差がないのですが、入力を隠す機能があります。\n\nこちらの記事が参考になると思います。\n\n<http://www.javainthebox.net/laboratory/JavaSE6/console/console.html>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T15:12:10.083", "id": "12031", "last_activity_date": "2015-07-04T15:12:10.083", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5778", "parent_id": "12018", "post_type": "answer", "score": 2 }, { "body": "すでに挙げられているパスワードの入力非表示の他には、以下のような違いがあります。\n\n * `Console`のメリット \n * コンソールのエンコーディングなどが自動的に設定される\n * 標準的なWindows環境のコマンドプロンプトで、以下の`ConsoleTest.java`を`UTF-8`で保存して実行し、例えば日本語を入力すると`2`の方法では、文字化けする\n * `Console`のデメリット \n * `JDK 1.6.0`以降でのみ使用可能\n * `IDE`などで実行すると`JVM`に関連付けられているコンソール・デバイスが存在しない場合があり、`System.console()`が`null`で使用できない\n\n```\n\n > java -Dfile.encoding=UTF-8 -classpath \".\" ConsoleTest\n \n```\n\n```\n\n import java.io.*;\n public class ConsoleTest {\n public static void main(String[] args) {\n Console c = System.console();\n if (c != null) {\n String s = c.readLine(\"入力: \"); // 1\n System.out.println(\"出力: \" + s);\n }\n //else {\n System.out.println(\"----\");\n \n //try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in, \"MS932\"))) {\n try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n System.out.print(\"入力: \");\n String s = br.readLine(); // 2\n System.out.println(\"出力: \" + s);\n } catch (Exception ex) {\n ex.printStackTrace();\n }\n }\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-07T06:37:21.177", "id": "12110", "last_activity_date": "2015-07-07T06:37:21.177", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "46", "parent_id": "12018", "post_type": "answer", "score": 3 } ]
12018
12110
12110
{ "accepted_answer_id": "12023", "answer_count": 1, "body": "下記の3つのソースコードは、アナログ時計(マウスストーカー)のサイズを変えるために \npulldown式のボタンを用いたものです。\n\n1つ目のソースは、掟破りでoptionタグ内にonClickを使ってイベントを発生させたものですが、 \n動きそのものはスムーズで問題はありません。\n\nしかし2つ目のソースは、本道selectタグ内にonChangeを用いたものですが、動きがギクシャクしていて同じスクリプトの内容とは思えません。どうすれば、1つ目のソースのようにスムーズに動くようになるでしょうか。\n\n3つめのソースは、サイズは切り替わるのですが、記述が足りないためか\"秒針\"・\"分針\"・\"時間針\"のサイズはそのままの大きさで変化しません。問題箇所を指摘していただたら、幸いです。\n\n1つ目のソースです。\n\n```\n\n <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n <html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=shift_jis\"> \n \n <TITLE>妖怪クロック(アナログ) - JavaScript</TITLE>\n \n <style type=\"text/css\">\n <!--\n .butt{\n BACKGROUND:maroon; \n COLOR:gold;\n }\n //-->\n </style>\n </head>\n \n <BODY bgcolor=\"black\" text=\"white\">\n \n <div id=\"clock\" style=\"visibility:hidden\">\n <div id=\"Od\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n \n <div id=\"Of\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n \n <div id=\"Oh\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n \n <div id=\"Om\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n \n <div id=\"Os\" style=\"position:absolute;top:0px;left:0px\">\n <div style=\"position:relative\">\n </div>\n </div>\n </div>\n \n <script type=\"text/javascript\">\n \n // 状態変数>\n var scale = 1;\n var transitionStarted = 0;\n var transitionFrom = 0;\n var transitionTo = 0;\n var transitionDuration = 0;\n \n // サイズの変更を開始する処理\n \n function changeSIZE1()\n {\n transitionStarted = new Date().getTime();\n transitionFrom = scale;\n transitionTo = 2.5; // 最終的な倍率。状態により変化\n transitionDuration = 1000;\n }\n function changeSIZE2()\n {\n transitionStarted = new Date().getTime();\n transitionFrom = scale;\n transitionTo = 1; // 最終的な倍率。状態により変化\n transitionDuration = 1000;\n }\n function changeSIZE3()\n {\n transitionStarted = new Date().getTime();\n transitionFrom = scale;\n transitionTo = 0.5; // 最終的な倍率。状態により変化\n transitionDuration = 1000;\n }\n \n \n \n (function(){\n \"use strict\";\n \n function $(sel)\n {\n return document.getElementById(sel);\n }\n \n function $$(sel)\n {\n if (typeof document.getElementsByClassName === 'undefined')\n {\n return document.getElementsByName(sel);\n }\n return document.getElementsByClassName(sel);\n }\n \n var dCol = '', //date colour.\n sCol = '', //seconds colour.\n mCol = '', //minutes colour.\n hCol = '', //hours colour.\n fCol = '', //face color\n \n ClockHeight = 65,\n ClockWidth = 65,\n ClockFromMouseY = 0,\n ClockFromMouseX = 100,\n d = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"],\n m = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"],\n date = new Date(),\n day = date.getDate(),\n year = date.getYear() + 1900;\n var TodaysDate = \" \" + d[date.getDay()] + \" \" + day + \" \" + m[date.getMonth()] + \" \" + year;\n var D = TodaysDate.split('');\n var H = '☆☆☆';\n H = H.split('');\n var M = '☆☆☆☆';\n M = M.split('');\n var S = '・・・・・';\n S = S.split('');\n var Face = '1 2 3 4 5 6 7 8 9 10 11 12',\n font = 'Helvetica, Arial, sans-serif',\n size = 1,\n speed = 0.55;\n Face = Face.split(' ');\n var n = Face.length;\n var a = size * 10;\n var ymouse = 0,\n xmouse = 0,\n scrll = 0,\n props = '<span style=\"font-family:' + font + ';font-size:' + size + 'em; color:#' + fCol + '\">',\n props2 = '<span style=\"font-family:' + font + ';font-size:' + size + 'em; color:#' + dCol + '\">';\n var Split = 360 / n;\n var Dsplit = 360 / D.length;\n var HandHeight = ClockHeight / 4.5; \n var HandWidth = ClockWidth / 4.5;\n var HandY = -7,\n HandX = -2.5,\n step = 0.02,\n currStep = 0,\n y = [],\n x = [],\n Y = [],\n X = [],\n Dy = [],\n Dx = [],\n DY = [],\n DX = [];\n var i;\n \n for (i = 0; i < n; i++) \n {\n y[i] = 0;\n x[i] = 0;\n Y[i] = 0;\n X[i] = 0;\n }\n \n for (i = 0; i < D.length; i++) \n {\n Dy[i] = 0;\n Dx[i] = 0;\n DY[i] = 0;\n DX[i] = 0;\n }\n var wrapper = $('clock');\n var html = '';\n // Date wrapper\n \n html = '';\n \n for (i = 0; i < D.length; i++)\n {\n html += '<div class=\"Date\" name=\"Date\" style=\"position:absolute;top:0px;left:0;height:' + a + ';width:' + a + ';text-align:center\">' + props2 + D[i] + '</span></div>';\n }\n $('Od').children[0].innerHTML = html;\n \n // Face wrapper\n \n html = '';\n \n for (i = 0; i < n; i++) \n {\n html += '<div class=\"Face\" name=\"Face\" style=\"position:absolute;top:0px;left:0;height:' + a + ';width:' + a + ';text-align:center\">' + props + Face[i] + '</span></div>';\n }\n $('Of').children[0].innerHTML = html;\n // Hours wrapper\n \n html = '';\n \n for (i = 0; i < H.length; i++)\n {\n html += '<div class=\"Hours\" name=\"Hours\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + hCol + ';text-align:center;font-weight:bold\">' + H[i] + '</div>';\n } \n $('Oh').children[0].innerHTML = html;\n // Minute wrapper\n \n html = '';\n \n for (i = 0; i < M.length; i++)\n {\n html += '<div class=\"Minutes\" name=\"Minutes\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + mCol + ';text-align:center;font-weight:bold\">' + M[i] + '</div>';\n } \n $('Om').children[0].innerHTML = html;\n // Seconds wrapper\n \n html = '';\n \n for (i = 0; i < S.length; i++)\n {\n html += '<div class=\"Seconds\" name=\"Seconds\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + sCol + ';text-align:center;font-weight:bold\">' + S[i] + '</div>';\n } \n $('Os').children[0].innerHTML = html;\n // Mouse move event handler\n \n function Mouse(evnt) \n {\n if (typeof evnt === 'undefined')\n {\n ymouse = event.Y + ClockFromMouseY;\n xmouse = event.X + ClockFromMouseX;\n }\n else\n {\n ymouse = evnt.clientY + ClockFromMouseY;\n xmouse = evnt.clientX + ClockFromMouseX;\n }\n }\n \n document.onmousemove = Mouse;\n \n function ClockAndAssign() \n {\n var time = new Date();\n \n // 状態変更処理\n if(transitionStarted)\n {\n var d = time.getTime() - transitionStarted;\n if (d < transitionDuration)\n {\n scale = transitionFrom + (transitionTo - transitionFrom) * d / transitionDuration;\n }\n else\n {\n // トランジション終了\n scale = transitionTo;\n transitionStarted = 0;\n }\n }\n \n var secs = time.getSeconds();\n var sec = -1.57 + Math.PI * secs / 30;\n var mins = time.getMinutes();\n var min = -1.57 + Math.PI * mins / 30;\n var hr = time.getHours();\n var hrs = -1.575 + Math.PI * hr / 6 + Math.PI * parseInt(time.getMinutes(), 10) / 360;\n $('Od').style.top = window.document.body.scrollTop;\n $('Of').style.top = window.document.body.scrollTop;\n $('Oh').style.top = window.document.body.scrollTop;\n $('Om').style.top = window.document.body.scrollTop;\n $('Os').style.top = window.document.body.scrollTop;\n \n for (i = 0; i < n; i++)\n {\n var F = $$('Face')[i];\n F.style.top = y[i] + scale * ClockHeight * Math.sin(-1.0471 + i * Split * Math.PI / 180) + scrll;\n F.style.left = x[i] + scale * ClockWidth * Math.cos(-1.0471 + i * Split * Math.PI / 180);\n }\n \n for (i = 0; i < H.length; i++)\n {\n var HL = $$('Hours')[i];\n HL.style.top = y[i] + HandY + scale * (i * HandHeight) * Math.sin(hrs) + scrll;\n HL.style.left = x[i] + HandX + scale * (i * HandWidth) * Math.cos(hrs);\n }\n \n for (i = 0; i < M.length; i++)\n {\n var ML = $$('Minutes')[i].style;\n ML.top = y[i] + HandY + scale * (i * HandHeight) * Math.sin(min) + scrll;\n ML.left = x[i] + HandX + scale * (i * HandWidth) * Math.cos(min);\n }\n \n for (i = 0; i < S.length; i++)\n {\n var SL = $$('Seconds')[i].style;\n SL.top = y[i] + HandY + scale * (i * HandHeight) * Math.sin(sec) + scrll;\n SL.left = x[i] + HandX + scale * (i * HandWidth) * Math.cos(sec);\n }\n \n for (i = 0; i < D.length; i++)\n {\n var DL = $$('Date')[i].style;\n DL.top = Dy[i] + scale * ClockHeight * 1.5 * Math.sin(currStep + i * Dsplit * Math.PI / 180) + scrll;\n DL.left = Dx[i] + scale * ClockWidth * 1.5 * Math.cos(currStep + i * Dsplit * Math.PI / 180);\n }\n currStep -= step;\n }\n \n function Delay() \n {\n scrll = 0;\n Dy[0] = Math.round(DY[0] += ((ymouse) - DY[0]) * speed);\n Dx[0] = Math.round(DX[0] += ((xmouse) - DX[0]) * speed);\n \n for (i = 1; i < D.length; i++) {\n Dy[i] = Math.round(DY[i] += (Dy[i - 1] - DY[i]) * speed);\n Dx[i] = Math.round(DX[i] += (Dx[i - 1] - DX[i]) * speed);\n }\n y[0] = Math.round(Y[0] += ((ymouse) - Y[0]) * speed);\n x[0] = Math.round(X[0] += ((xmouse) - X[0]) * speed);\n \n for (i = 1; i < n; i++) {\n y[i] = Math.round(Y[i] += (y[i - 1] - Y[i]) * speed);\n x[i] = Math.round(X[i] += (x[i - 1] - X[i]) * speed);\n }\n ClockAndAssign();\n setTimeout(Delay, 20);\n }\n \n Delay();\n \n }());\n \n num = 1;\n function toggle(){\n num ^= 1; \n if(num == 1){\n document.getElementById('clock').style.visibility=\"hidden\";\n document.getElementById('size').disabled=true;\n } \n else {\n document.getElementById('clock').style.visibility=\"visible\";\n document.getElementById('size').disabled=false;\n }\n document.getElementById(\"tog\").value = num ?\" APPEAR \":\"KILL(切る)\";\n }\n //-->\n </script>\n \n <br><br><br><br><br><br><br><br><br>\n <br><br><br><br><br><br><br><br><br>\n <div align=\"center\"><div>\n <input class=\"butt\" type=\"button\" id=\"tog\" value=\"今何時?\" onclick=\"toggle()\">\n </div><br>\n <div>\n <select id=\"size\" style=\"background:lightblue\" disabled>\n <option onClick=\"changeSIZE1()\">2.5倍</option>\n <option onClick=\"changeSIZE2()\" selected>サイズ</option>\n <option onClick=\"changeSIZE3()\">半  分</option>\n </select>\n </div></div>\n </body>\n </html>\n \n```\n\n2つ目のソースです。 \n記述コード以上は、同じですので省略します。\n\n```\n\n <script type=\"text/javascript\">\n \n // 状態変数>\n var scale = 1;\n var transitionStarted = 0;\n var transitionFrom = 0;\n var transitionTo = 0;\n var transitionDuration = 0;\n \n // サイズの変更を開始する処理\n \n function changeSIZE(value)\n {\n transitionStarted = new Date().getTime();\n transitionFrom = scale;\n transitionTo = value; // 最終的な倍率。状態により変化\n transitionDuration = 1000;\n }\n \n (function(){\n \"use strict\";\n \n function $(sel)\n {\n return document.getElementById(sel);\n }\n \n function $$(sel)\n {\n if (typeof document.getElementsByClassName === 'undefined')\n {\n return document.getElementsByName(sel);\n }\n return document.getElementsByClassName(sel);\n }\n \n var dCol = '', //date colour.\n sCol = '', //seconds colour.\n mCol = '', //minutes colour.\n hCol = '', //hours colour.\n fCol = '', //face color\n \n ClockHeight = 65,\n ClockWidth = 65,\n ClockFromMouseY = 0,\n ClockFromMouseX = 100,\n d = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"],\n m = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"],\n date = new Date(),\n day = date.getDate(),\n year = date.getYear() + 1900;\n var TodaysDate = \" \" + d[date.getDay()] + \" \" + day + \" \" + m[date.getMonth()] + \" \" + year;\n var D = TodaysDate.split('');\n var H = '☆☆☆';\n H = H.split('');\n var M = '☆☆☆☆';\n M = M.split('');\n var S = '・・・・・';\n S = S.split('');\n var Face = '1 2 3 4 5 6 7 8 9 10 11 12',\n font = 'Helvetica, Arial, sans-serif',\n size = 1,\n speed = 0.55;\n Face = Face.split(' ');\n var n = Face.length;\n var a = size * 10;\n var ymouse = 0,\n xmouse = 0,\n scrll = 0,\n props = '<span style=\"font-family:' + font + ';font-size:' + size + 'em; color:#' + fCol + '\">',\n props2 = '<span style=\"font-family:' + font + ';font-size:' + size + 'em; color:#' + dCol + '\">';\n var Split = 360 / n;\n var Dsplit = 360 / D.length;\n var HandHeight = ClockHeight / 4.5; \n var HandWidth = ClockWidth / 4.5;\n var HandY = -7,\n HandX = -2.5,\n step = 0.02,\n currStep = 0,\n y = [],\n x = [],\n Y = [],\n X = [],\n Dy = [],\n Dx = [],\n DY = [],\n DX = [];\n var i;\n \n for (i = 0; i < n; i++) \n {\n y[i] = 0;\n x[i] = 0;\n Y[i] = 0;\n X[i] = 0;\n }\n \n for (i = 0; i < D.length; i++) \n {\n Dy[i] = 0;\n Dx[i] = 0;\n DY[i] = 0;\n DX[i] = 0;\n }\n var wrapper = $('clock');\n var html = '';\n // Date wrapper\n \n html = '';\n \n for (i = 0; i < D.length; i++)\n {\n html += '<div class=\"Date\" name=\"Date\" style=\"position:absolute;top:0px;left:0;height:' + a + ';width:' + a + ';text-align:center\">' + props2 + D[i] + '</span></div>';\n }\n $('Od').children[0].innerHTML = html;\n \n // Face wrapper\n \n html = '';\n \n for (i = 0; i < n; i++) \n {\n html += '<div class=\"Face\" name=\"Face\" style=\"position:absolute;top:0px;left:0;height:' + a + ';width:' + a + ';text-align:center\">' + props + Face[i] + '</span></div>';\n }\n $('Of').children[0].innerHTML = html;\n // Hours wrapper\n \n html = '';\n \n for (i = 0; i < H.length; i++)\n {\n html += '<div class=\"Hours\" name=\"Hours\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + hCol + ';text-align:center;font-weight:bold\">' + H[i] + '</div>';\n } \n $('Oh').children[0].innerHTML = html;\n // Minute wrapper\n \n html = '';\n \n for (i = 0; i < M.length; i++)\n {\n html += '<div class=\"Minutes\" name=\"Minutes\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + mCol + ';text-align:center;font-weight:bold\">' + M[i] + '</div>';\n } \n $('Om').children[0].innerHTML = html;\n // Seconds wrapper\n \n html = '';\n \n for (i = 0; i < S.length; i++)\n {\n html += '<div class=\"Seconds\" name=\"Seconds\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + sCol + ';text-align:center;font-weight:bold\">' + S[i] + '</div>';\n } \n $('Os').children[0].innerHTML = html;\n // Mouse move event handler\n \n function Mouse(evnt) \n {\n if (typeof evnt === 'undefined')\n {\n ymouse = event.Y + ClockFromMouseY;\n xmouse = event.X + ClockFromMouseX;\n }\n else\n {\n ymouse = evnt.clientY + ClockFromMouseY;\n xmouse = evnt.clientX + ClockFromMouseX;\n }\n }\n \n document.onmousemove = Mouse;\n \n function ClockAndAssign() \n {\n var time = new Date();\n \n // 状態変更処理\n if(transitionStarted)\n {\n var d = time.getTime() - transitionStarted;\n if (d < transitionDuration)\n {\n scale = transitionFrom + (transitionTo - transitionFrom) * d / transitionDuration;\n }\n else\n {\n // トランジション終了\n scale = transitionTo;\n transitionStarted = 0;\n }\n }\n \n var secs = time.getSeconds();\n var sec = -1.57 + Math.PI * secs / 30;\n var mins = time.getMinutes();\n var min = -1.57 + Math.PI * mins / 30;\n var hr = time.getHours();\n var hrs = -1.575 + Math.PI * hr / 6 + Math.PI * parseInt(time.getMinutes(), 10) / 360;\n $('Od').style.top = window.document.body.scrollTop;\n $('Of').style.top = window.document.body.scrollTop;\n $('Oh').style.top = window.document.body.scrollTop;\n $('Om').style.top = window.document.body.scrollTop;\n $('Os').style.top = window.document.body.scrollTop;\n \n for (i = 0; i < n; i++)\n {\n var F = $$('Face')[i];\n F.style.top = y[i] + scale * ClockHeight * Math.sin(-1.0471 + i * Split * Math.PI / 180) + scrll;\n F.style.left = x[i] + scale * ClockWidth * Math.cos(-1.0471 + i * Split * Math.PI / 180);\n }\n \n for (i = 0; i < H.length; i++)\n {\n var HL = $$('Hours')[i];\n HL.style.top = y[i] + HandY + scale * (i * HandHeight) * Math.sin(hrs) + scrll;\n HL.style.left = x[i] + HandX + scale * (i * HandWidth) * Math.cos(hrs);\n }\n \n for (i = 0; i < M.length; i++)\n {\n var ML = $$('Minutes')[i].style;\n ML.top = y[i] + HandY + scale * (i * HandHeight) * Math.sin(min) + scrll;\n ML.left = x[i] + HandX + scale * (i * HandWidth) * Math.cos(min);\n }\n \n for (i = 0; i < S.length; i++)\n {\n var SL = $$('Seconds')[i].style;\n SL.top = y[i] + HandY + scale * (i * HandHeight) * Math.sin(sec) + scrll;\n SL.left = x[i] + HandX + scale * (i * HandWidth) * Math.cos(sec);\n }\n \n for (i = 0; i < D.length; i++)\n {\n var DL = $$('Date')[i].style;\n DL.top = Dy[i] + scale * ClockHeight * 1.5 * Math.sin(currStep + i * Dsplit * Math.PI / 180) + scrll;\n DL.left = Dx[i] + scale * ClockWidth * 1.5 * Math.cos(currStep + i * Dsplit * Math.PI / 180);\n }\n currStep -= step;\n }\n \n function Delay() \n {\n scrll = 0;\n Dy[0] = Math.round(DY[0] += ((ymouse) - DY[0]) * speed);\n Dx[0] = Math.round(DX[0] += ((xmouse) - DX[0]) * speed);\n \n for (i = 1; i < D.length; i++) {\n Dy[i] = Math.round(DY[i] += (Dy[i - 1] - DY[i]) * speed);\n Dx[i] = Math.round(DX[i] += (Dx[i - 1] - DX[i]) * speed);\n }\n y[0] = Math.round(Y[0] += ((ymouse) - Y[0]) * speed);\n x[0] = Math.round(X[0] += ((xmouse) - X[0]) * speed);\n \n for (i = 1; i < n; i++) {\n y[i] = Math.round(Y[i] += (y[i - 1] - Y[i]) * speed);\n x[i] = Math.round(X[i] += (x[i - 1] - X[i]) * speed);\n }\n ClockAndAssign();\n setTimeout(Delay, 20);\n }\n \n Delay();\n \n }());\n \n num = 1;\n function toggle(){\n num ^= 1; \n if(num == 1){\n document.getElementById('clock').style.visibility=\"hidden\";\n document.getElementById('size').disabled=true;\n } \n else {\n document.getElementById('clock').style.visibility=\"visible\";\n document.getElementById('size').disabled=false;\n }\n document.getElementById(\"tog\").value = num ?\" APPEAR \":\"KILL(切る)\";\n }\n //-->\n </script>\n \n <br><br><br><br><br><br><br><br><br>\n <br><br><br><br><br><br><br><br><br>\n <div align=\"center\"><div>\n <input class=\"butt\" type=\"button\" id=\"tog\" value=\"今何時?\" onclick=\"toggle()\">\n </div><br>\n <div>\n <select id=\"size\" style=\"background:lightblue\" onChange=\"changeSIZE(this.value)\" disabled>\n <option value=\"2.5\">2.5倍</option>\n <option value=\"1\" selected>サイズ</option>\n <option value=\"0.5\">半  分</option>\n </select>\n </div></div>\n \n </body>\n </html>\n \n```\n\n3つ目のソースです。 \n記述コード以上は、同じですので省略します。\n\n```\n\n <script type=\"text/javascript\">\n <!--\n \n var ClockHeight = 55,\n ClockWidth = 55;\n \n function changeSIZE(value){\n ClockHeight = value;\n ClockWidth = value;\n }\n \n (function(){\n \"use strict\";\n \n function $(sel)\n {\n return document.getElementById(sel);\n }\n \n function $$(sel)\n {\n if (typeof document.getElementsByClassName === 'undefined')\n {\n return document.getElementsByName(sel);\n }\n return document.getElementsByClassName(sel);\n }\n \n var dCol = '', //date colour.\n sCol = '', //seconds colour.\n mCol = '', //minutes colour.\n hCol = '', //hours colour.\n fCol = '', //face color.\n \n \n ClockFromMouseY = 0,\n ClockFromMouseX = 100,\n d = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"],\n m = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"],\n date = new Date(),\n day = date.getDate(),\n year = date.getYear() + 1900;\n var TodaysDate = \" \" + d[date.getDay()] + \" \" + day + \" \" + m[date.getMonth()] + \" \" + year;\n var D = TodaysDate.split('');\n var H = '☆☆☆';\n H = H.split('');\n var M = '☆☆☆☆';\n M = M.split('');\n var S = '・・・・・';\n S = S.split('');\n var Face = '1 2 3 4 5 6 7 8 9 10 11 12',\n font = 'Helvetica, Arial, sans-serif',\n size = 1,\n speed = 0.55;\n Face = Face.split(' ');\n var n = Face.length;\n var a = size * 10;\n var ymouse = 0,\n xmouse = 0,\n scrll = 0,\n props = '<span style=\"font-family:' + font + ';font-size:' + size + 'em; color:#' + fCol + '\">',\n props2 = '<span style=\"font-family:' + font + ';font-size:' + size + 'em; color:#' + dCol + '\">';\n var Split = 360 / n;\n var Dsplit = 360 / D.length;\n var HandHeight = ClockHeight / 4.5; \n var HandWidth = ClockWidth / 4.5;\n var HandY = -7, \n HandX = -2.5, \n step = 0.02,\n currStep = 0,\n y = [],\n x = [],\n Y = [],\n X = [],\n Dy = [],\n Dx = [],\n DY = [],\n DX = [];\n var i;\n \n for (i = 0; i < n; i++) \n {\n y[i] = 0;\n x[i] = 0;\n Y[i] = 0;\n X[i] = 0;\n }\n \n for (i = 0; i < D.length; i++) \n {\n Dy[i] = 0;\n Dx[i] = 0;\n DY[i] = 0;\n DX[i] = 0;\n }\n var wrapper = $('clock');\n var html = '';\n // Date wrapper\n \n html = '';\n \n for (i = 0; i < D.length; i++)\n {\n html += '<div class=\"Date\" name=\"Date\" style=\"position:absolute;top:0px;left:0;height:' + a + ';width:' + a + ';text-align:center\">' + props2 + D[i] + '</span></div>';\n }\n $('Od').children[0].innerHTML = html;\n \n // Face wrapper\n \n html = '';\n \n for (i = 0; i < n; i++) \n {\n html += '<div class=\"Face\" name=\"Face\" style=\"position:absolute;top:0px;left:0;height:' + a + ';width:' + a + ';text-align:center\">' + props + Face[i] + '</span></div>';\n }\n $('Of').children[0].innerHTML = html;\n // Hours wrapper\n \n html = '';\n \n for (i = 0; i < H.length; i++)\n {\n html += '<div class=\"Hours\" name=\"Hours\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + hCol + ';text-align:center;font-weight:bold\">' + H[i] + '</div>';\n } \n $('Oh').children[0].innerHTML = html;\n // Minute wrapper\n \n html = '';\n \n for (i = 0; i < M.length; i++)\n {\n html += '<div class=\"Minutes\" name=\"Minutes\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + mCol + ';text-align:center;font-weight:bold\">' + M[i] + '</div>';\n } \n $('Om').children[0].innerHTML = html;\n // Seconds wrapper\n \n html = '';\n \n for (i = 0; i < S.length; i++)\n {\n html += '<div class=\"Seconds\" name=\"Seconds\" style=\"position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:' + sCol + ';text-align:center;font-weight:bold\">' + S[i] + '</div>';\n } \n $('Os').children[0].innerHTML = html;\n // Mouse move event handler\n \n function Mouse(evnt) \n {\n if (typeof evnt === 'undefined')\n {\n ymouse = event.Y + ClockFromMouseY;\n xmouse = event.X + ClockFromMouseX;\n }\n else\n {\n ymouse = evnt.clientY + ClockFromMouseY;\n xmouse = evnt.clientX + ClockFromMouseX;\n }\n }\n \n document.onmousemove = Mouse;\n \n function ClockAndAssign() \n {\n var time = new Date();\n var secs = time.getSeconds();\n var sec = -1.57 + Math.PI * secs / 30;\n var mins = time.getMinutes();\n var min = -1.57 + Math.PI * mins / 30;\n var hr = time.getHours();\n var hrs = -1.575 + Math.PI * hr / 6 + Math.PI * parseInt(time.getMinutes(), 10) / 360;\n $('Od').style.top = window.document.body.scrollTop;\n $('Of').style.top = window.document.body.scrollTop;\n $('Oh').style.top = window.document.body.scrollTop;\n $('Om').style.top = window.document.body.scrollTop;\n $('Os').style.top = window.document.body.scrollTop;\n \n for (i = 0; i < n; i++)\n {\n var F = $$('Face')[i];\n F.style.top = y[i] + ClockHeight * Math.sin(-1.0471 + i * Split * Math.PI / 180) + scrll;\n F.style.left = x[i] + ClockWidth * Math.cos(-1.0471 + i * Split * Math.PI / 180);\n }\n \n for (i = 0; i < H.length; i++)\n {\n var HL = $$('Hours')[i];\n HL.style.top = y[i] + HandY + (i * HandHeight) * Math.sin(hrs) + scrll;\n HL.style.left = x[i] + HandX + (i * HandWidth) * Math.cos(hrs);\n }\n \n for (i = 0; i < M.length; i++)\n {\n var ML = $$('Minutes')[i].style;\n ML.top = y[i] + HandY + (i * HandHeight) * Math.sin(min) + scrll;\n ML.left = x[i] + HandX + (i * HandWidth) * Math.cos(min);\n }\n \n for (i = 0; i < S.length; i++)\n {\n var SL = $$('Seconds')[i].style;\n SL.top = y[i] + HandY + (i * HandHeight) * Math.sin(sec) + scrll;\n SL.left = x[i] + HandX + (i * HandWidth) * Math.cos(sec);\n }\n \n for (i = 0; i < D.length; i++)\n {\n var DL = $$('Date')[i].style;\n DL.top = Dy[i] + ClockHeight * 1.5 * Math.sin(currStep + i * Dsplit * Math.PI / 180) + scrll;\n DL.left = Dx[i] + ClockWidth * 1.5 * Math.cos(currStep + i * Dsplit * Math.PI / 180);\n }\n currStep -= step;\n }\n \n function Delay() \n {\n scrll = 0;\n Dy[0] = Math.round(DY[0] += ((ymouse) - DY[0]) * speed);\n Dx[0] = Math.round(DX[0] += ((xmouse) - DX[0]) * speed);\n \n for (i = 1; i < D.length; i++) {\n Dy[i] = Math.round(DY[i] += (Dy[i - 1] - DY[i]) * speed);\n Dx[i] = Math.round(DX[i] += (Dx[i - 1] - DX[i]) * speed);\n }\n y[0] = Math.round(Y[0] += ((ymouse) - Y[0]) * speed);\n x[0] = Math.round(X[0] += ((xmouse) - X[0]) * speed);\n \n for (i = 1; i < n; i++) {\n y[i] = Math.round(Y[i] += (y[i - 1] - Y[i]) * speed);\n x[i] = Math.round(X[i] += (x[i - 1] - X[i]) * speed);\n }\n ClockAndAssign();\n setTimeout(Delay, 20);\n }\n \n Delay();\n \n }());\n \n num = 1;\n function toggle(){\n num ^= 1; \n if(num == 1){ \n document.getElementById('clock').style.visibility=\"hidden\";\n document.getElementById('size').disabled=true;\n }\n else { \n document.getElementById('clock').style.visibility=\"visible\";\n document.getElementById('size').disabled=false;\n } \n document.getElementById(\"tog\").value = num ?\" Appear \":\"Kill(切る)\";\n }\n </script>\n \n \n <font id=\"text1\" size=\"5\"><b>妖怪クロック(アナログ1):</b></font>\n \n <br><br><br>\n \n \n <div align=\"center\"><div>\n <input class=\"butt\" type=\"button\" id=\"tog\" value=\"今何時?\" onclick=\"toggle()\">\n </div><br>\n <div>\n <select id=\"size\" style=\"background:lightblue\" onchange=\"changeSIZE(this.value)\" disabled>\n <option value=\"138\";\"138\">2.5倍</option>\n <option value=\"55\";\"55\" selected>サイズ</option>\n <option value=\"28\";\"28\">半 分</option>\n </select>\n </div></div>\n \n </body>\n </html>\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T10:35:54.347", "favorite_count": 0, "id": "12020", "last_activity_date": "2015-07-04T11:53:36.063", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9359", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "同じ設定で、動きが違う理由は?", "view_count": 137 }
[ { "body": "まず、1 と 2 の違いを抜き出してみます。\n\n```\n\n function changeSIZE1()\n {\n transitionStarted = new Date().getTime();\n transitionFrom = scale;\n transitionTo = 2.5; // 最終的な倍率。状態により変化\n transitionDuration = 1000;\n }\n \n function changeSIZE(value)\n {\n transitionStarted = new Date().getTime();\n transitionFrom = scale;\n transitionTo = value;\n transitionDuration = 1000;\n }\n \n```\n\n異なるのは value だけです。では value には何が入るでしょうか?\n\n```\n\n <select id=\"size\" style=\"background:lightblue\" onChange=\"changeSIZE(this.value)\" disabled>\n <option value=\"2.5\">2.5倍</option>\n <option value=\"1\" selected>サイズ</option>\n <option value=\"0.5\">半  分</option>\n </select>\n <select i\n \n```\n\nこのとき、`this.value` に何が入るかというと、`\"2.5\"` です。 \n数値の`2.5` ではなく、文字列の`\"2.5\"`です。\n\nよって、解法としては、下記のように数値に変換することで対応できると考えます\n\n```\n\n function changeSIZE(value)\n {\n transitionStarted = new Date().getTime();\n transitionFrom = scale;\n transitionTo = parseFloat(value); // 最終的な倍率。状態により変化\n transitionDuration = 1000;\n } \n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T11:45:08.930", "id": "12023", "last_activity_date": "2015-07-04T11:53:36.063", "last_edit_date": "2015-07-04T11:53:36.063", "last_editor_user_id": "7471", "owner_user_id": "7471", "parent_id": "12020", "post_type": "answer", "score": 1 } ]
12020
12023
12023
{ "accepted_answer_id": "12024", "answer_count": 1, "body": "現在テーブルビュー2枚、再生画面1枚で音楽プレイヤーを作成しています。 \n[アルバム一覧(ViewController.swift)] \n↓ \n[選択されたアルバムの曲一覧(songsViewController.swift)] \n↓ \n[再生画面(playerViewController.swift)] \nその他に再生の制御を行うplayerController.swiftがあります。\n\n再生に`AVAudioPlayer`を使用しており、`audioPlayerDidFinishPlaying`を検出したら通知を用いて \nどの画面にいても再生終了を検出しようとしています。 \n以下はそれぞれの.swiftに書いたコードです。\n\n【playerController.swift】 \nここに`AVAudioPlayer`も宣言されています。\n\n```\n\n //再生終了を検出\n func audioPlayerDidFinishPlaying(player: AVAudioPlayer!, successfully flag: Bool) {\n println(\"finish\")\n //再生終了を他クラスに通知\n let notification = NSNotification(name: \"getStop\", object: self)\n NSNotificationCenter.defaultCenter().postNotification(notification)\n }\n \n```\n\n他の三つの`ViewController`には通知を検出するコードを`viewDidLoad()`以下に書いています。 \n【ViewController.swift、songsViewController.swift、playerViewController.swift】\n\n```\n\n //再生終了を監視\n var nc: NSNotificationCenter?\n \n override func viewDidLoad() {\n super.viewDidLoad()\n nc = NSNotificationCenter.defaultCenter()\n nc?.addObserver(self, selector: \"myAction\", name: \"getStop\", object: nil)\n }\n \n //再生終了通知を受けた時に起動\n @objc func myAction() {\n //再生終了時の処理\n //次の曲へ移動する処理を書いています。\n }\n \n```\n\nこれでは画面遷移する度に通知登録されてしまうので、画面移動時に削除しています。\n\n```\n\n //画面移動時に通知を削除\n override func viewDidDisappear(animated: Bool) {\n super.viewDidDisappear(animated)\n nc = NSNotificationCenter.defaultCenter()\n nc?.removeObserver(self)\n }\n \n```\n\n以上のように通知に関するコードを書いたのですが、再生画面にいる時にしか再生終了時の処理が行われません。 \n正確には「どのページにいても再生終了は検出するが、再生終了時の処理が行われない」となります。 \n再生終了 -> `audioPlayerDidFinishPlaying`に書いた`println(\"finish\")`が表示される -> \nセレクタである`\"myAction\"`の処理内容が実行されない。\n\nどの画面にいても通知を検出するには何が足りないのでしょうか? \nアドバイスをお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T11:16:10.177", "favorite_count": 0, "id": "12022", "last_activity_date": "2015-07-04T11:51:24.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9857", "post_type": "question", "score": 1, "tags": [ "swift", "notification" ], "title": "NSNotificationCenterが正常に検出できない。", "view_count": 960 }
[ { "body": "`viewDidLoad()`はその名の通り、Viewが生成されたタイミングでしか呼び出されません。\n\n複数の`ViewController`を跨いで通知を受け取りたい場合、`NSNotificationCenter`の`addObserver()`で登録するタイミングを、`viewDidAppear()`に変更してみてはどうでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T11:51:24.277", "id": "12024", "last_activity_date": "2015-07-04T11:51:24.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5337", "parent_id": "12022", "post_type": "answer", "score": 1 } ]
12022
12024
12024
{ "accepted_answer_id": "12026", "answer_count": 1, "body": "AmazonEC2 の AmazonLinux 上に、Redmine2.6.5 をインストールしまして、Backlogs\n(<http://www.redminebacklogs.net/>)をインストールしようと、操作をしている最中の事です。\n\n<http://www.redminebacklogs.net/en/installation.html#>\n\nを見ながら操作して、\n\n```\n\n gem install holidays --version 1.0.3\n gem install holidays\n git clone git://github.com/backlogs/redmine_backlogs.git\n cd redmine_backlogs\n git checkout v1.0.6\n \n```\n\nから始まり、\n\n```\n\n bundle exec rake tmp:cache:clear\n bundle exec rake tmp:sessions:clear\n \n```\n\nまで完了した後の操作です。 \nRedmine ルートディレクトリ上で、\n\n```\n\n bundle exec rake redmine:backlogs:install\n \n```\n\nまたは、production を指定した\n\n```\n\n bundle exec rake redmine:backlogs:install RAILS_ENV=production\n \n```\n\nどちらのパターン(bundle exec 有無も含め)においても、\n\n```\n\n # bundle exec rake redmine:backlogs:install\n rake aborted!\n You must set the default issue priority in redmine prior to installing backlogs\n /var/lib/redmine/plugins/redmine_backlogs/lib/tasks/install.rake:11:in `block (3 levels) in <top (required)>'\n Tasks: TOP => redmine:backlogs:install\n (See full trace by running task with --trace)\n \n```\n\nとなっています。 \n正直に言いますと、「default issue」が何なのか、加えて、その設定方法について知識・情報が不足しており、解決に至っておりません。\n\nそもそも Backlogs\nの対応してるバージョンも相当古いですし、さっさと捨てて新しいプラグインに走れという結論もやむなしとは考えていますが、使えるものなら使いたいという事もありますので、ご存知の方は知恵をお貸し頂けると助かります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T12:50:30.790", "favorite_count": 0, "id": "12025", "last_activity_date": "2015-07-04T13:01:14.513", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "380", "post_type": "question", "score": 0, "tags": [ "redmine" ], "title": "Redmine2.6.5 に Backlogs をインストールするときの「You must set the default issue priority in redmine prior to installing backlogs」", "view_count": 866 }
[ { "body": "自己完結しました。 \nインストール操作上の「優先度」、つまりプラグインの適用優先度みたいなものがあると勝手に思い込んでいましたが、これは Redmine の\nチケット優先度のデフォルトの事だったのですね…。\n\n管理者でログインして、チケット優先度を表示した後、正常にインストール操作を継続できました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T13:01:14.513", "id": "12026", "last_activity_date": "2015-07-04T13:01:14.513", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "380", "parent_id": "12025", "post_type": "answer", "score": 0 } ]
12025
12026
12026
{ "accepted_answer_id": "12030", "answer_count": 1, "body": "Golangでwebsocketを使って、\n\nある一定時間だけReceiveし、もし、その間になんらかのデータが送られてきたらそのデータについて処理するが、その時間内に何も来なかったら、こちらからデータを送る方法はありますか?\n\n下の例だとずっとReceiveで送られてくるのを待ち続けてしまいます。どうすればいいのでしょうか?\n\n一定時間(例えば5秒間)Receiveする -> もし、その間にデータが送られてきたら ->\nそのデータを処理する。送られて来なければ、こちらからデータを送る\n\nということがしたいです。\n\n```\n\n \n package main\n \n import (\n \"fmt\"\n \"golang.org/x/net/websocket\"\n \"io/ioutil\"\n \"net/http\"\n \"os\"\n )\n \n func picHandler(ws *websocket.Conn) {\n websocket.Message.Receive(ws, &s) \n // なんらかの処理\n \n // もし、一定時間過ぎたなら\n websocket.Message.Send(ws, pic)\n }\n \n func main() {\n if err != nil {\n fmt.Fprintln(os.Stderr, err)\n }\n http.HandleFunc(\"/pic\", func(w http.ResponseWriter, req *http.Request) {\n s := websocket.Server{Handler: websocket.Handler(picHandler)}\n s.ServeHTTP(w, req)\n \n })\n fmt.Println(\"port:\", 9563)\n http.ListenAndServe(\":9563\", nil)\n }\n \n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T13:44:31.243", "favorite_count": 0, "id": "12029", "last_activity_date": "2015-07-05T09:35:57.980", "last_edit_date": "2015-07-05T09:35:57.980", "last_editor_user_id": "5246", "owner_user_id": "5246", "post_type": "question", "score": 2, "tags": [ "go", "websocket" ], "title": "GolangでWebsocketでReceiveで一定時間を経過したらデータを送る", "view_count": 931 }
[ { "body": "`SetReadDeadline`を使うことで、 \n指定時間までに受信できなかった場合にタイムアウトエラーを発生させることができます。\n\n```\n\n func picHandler(ws *websocket.Conn) {\n var s, pic string\n \n // 5秒後にタイムアウト\n ws.SetReadDeadline(time.Now().Add(time.Second * 5))\n \n err := websocket.Message.Receive(ws, &s)\n \n // タイムアウトが発生したかチェック\n if operr, ok := err.(*net.OpError); ok && operr.Timeout() {\n websocket.Message.Send(ws, pic)\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T14:07:15.063", "id": "12030", "last_activity_date": "2015-07-04T14:07:15.063", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "12029", "post_type": "answer", "score": 1 } ]
12029
12030
12030
{ "accepted_answer_id": null, "answer_count": 1, "body": "こんばんわ、monacaのiPhone用デバッガーで,時刻が扱えません。 \n現在\n\n```\n\n <input type=\"date\">と<input type=\"time\">\n \n```\n\nの値を取得して計算させようとしています。 \n取得した値をdateに入れて計算させればいいと思うのですが時刻の部分(timeの部分、00:00) \nがnew Dateで扱えません。 \npcでのプレビューでは\n\nvar test = new Date(\"2015-07-04 12:00\"); \nvar test2 = new Date(\"2015-07-04 11:00\"); \nvar kekka = test - test2\n\nこれでも動作はしますがiPhoneのデバッガーだとNaNになります。\n\nvar time = new Date(\"11:00\"); \nconsole.log(time) \nこれでもNaNになってしまいます\n\nどうすればいいでしょうか、よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T16:10:57.123", "favorite_count": 0, "id": "12032", "last_activity_date": "2015-07-04T17:38:40.893", "last_edit_date": "2015-07-04T16:34:10.507", "last_editor_user_id": "10354", "owner_user_id": "10354", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "monacaのiPhoneデバッガーで時刻が扱えない", "view_count": 89 }
[ { "body": "すみません、自己解決しました、お恥ずかしいことに、new Date()を使わずに日時を記入してました。現在はデバッガーで表示されました \n疲れてるのかもしれません。。失礼しました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T17:38:40.893", "id": "12034", "last_activity_date": "2015-07-04T17:38:40.893", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10354", "parent_id": "12032", "post_type": "answer", "score": 1 } ]
12032
null
12034
{ "accepted_answer_id": "12109", "answer_count": 2, "body": "pi(n)をn以下の素数の個数と定義します。 \npi(n)の正確な値を高速に求めるにはどのようなアルゴリズムを用いればよいでしょうか。\n\n2×√n 程度のデータを用いて計算するコードを記しておきます。\n\n(Ruby 2.2)\n\n```\n\n def pi(n)\n m = Math.sqrt(n).to_i\n keys = (1..m).map{|i| n / i}\n keys += (1..keys[-1] - 1).to_a.reverse\n h = {}\n # 1を除いた個数\n keys.each{|i| h[i] = i - 1}\n # 「素数」もしくは「i以下の素数では割り切れない合成数」の個数\n (2..m).each{|i|\n if h[i] > h[i - 1] # このときiは素数\n hp = h[i - 1]\n i2 = i * i\n keys.each{|j|\n break if j < i2\n h[j] -= h[j / i] - hp # iで初めて割り切れる合成数(ちなみにi2以上)を除く\n }\n end\n }\n h[n]\n end\n \n p pi(10 ** 8)\n \n```\n\n(Python 2.7)\n\n```\n\n import math\n \n def pi(n):\n m = int(math.sqrt(n))\n keys = [n // i for i in range(1, m + 1)]\n keys += range(keys[-1] - 1, 0, -1)\n h = {i : i - 1 for i in keys}\n for i in range(2, m + 1):\n if h[i] > h[i - 1]:\n hp = h[i - 1]\n i2 = i * i\n for j in keys:\n if j < i2: break\n h[j] -= h[j // i] - hp\n \n return h[n]\n \n print pi(10 ** 8)\n \n```\n\n(参考) \n(Ruby 2.2) \n上記コードと、Rosetta Code で紹介されている Wheel factorization を用いた方法 \n(<http://rosettacode.org/wiki/Sieve_of_Eratosthenes#With_a_wheel>)とで比較してみた。\n\n```\n\n require 'benchmark'\n puts Benchmark::CAPTION\n puts Benchmark.measure{\n p pi(10 ** 8)\n }\n puts Benchmark.measure{\n p eratosthenes2(10 ** 8).size\n }\n \n```\n\nおおよそ以下のような結果になります。\n\n```\n\n user system total real\n 5761455\n 0.218000 0.000000 0.218000 ( 0.210384)\n 5761455\n 8.362000 0.312000 8.674000 ( 8.699177)\n \n```\n\n速さで比較すると、 \n上記コード> Wheel factorization を用いた方法(>エラトステネスの篩) \nとなっている。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T16:25:28.910", "favorite_count": 0, "id": "12033", "last_activity_date": "2015-07-08T14:05:49.237", "last_edit_date": "2015-07-07T13:51:52.100", "last_editor_user_id": "5363", "owner_user_id": "5363", "post_type": "question", "score": 4, "tags": [ "ruby", "python", "アルゴリズム" ], "title": "n以下の素数の個数を高速に求めるには?", "view_count": 2956 }
[ { "body": "時間が書いてないので早いのか遅いのか分かりませんが・・・ \nCでエラトステネスの篩を使った場合1.6秒程度でカウントできます。 \n~ ./a.out 100000000 \nTime:1.625000\n\n*** prime count: 5761455 *** \n~ \n[エラトステネスの篩](http://www.crimsoneyes.jp/src/soe.c) \nちなみに計算量はO(n log log n)です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T09:20:35.217", "id": "12045", "last_activity_date": "2015-07-05T13:14:54.393", "last_edit_date": "2015-07-05T13:14:54.393", "last_editor_user_id": "9528", "owner_user_id": "9528", "parent_id": "12033", "post_type": "answer", "score": 1 }, { "body": "MathWorld の以下のページに method, time complexity, storage complexity\nが載っているので、実装したときの速さの目安になるかと思われます。 \n(<http://mathworld.wolfram.com/PrimeCountingFunction.html>)\n\n余談ですが、上記ページには Π(10^25) (Büthe (2014)) までしか載っていませんが、OEISのA006880には Π(10^26)\nまで載っています。 \n(<https://oeis.org/A006880/list>)\n\nなお、次のように改良してみました。\n\n```\n\n def pi(n)\n m = Math.sqrt(n).to_i\n keys = (1..m).map{|i| n / i}\n keys += (1..keys[-1] - 1).to_a.reverse\n h = {}\n keys.each{|i| h[i] = i - 1}\n (2..m).each{|i|\n if h[i] > h[i - 1] # このときiは素数\n hp = h[i - 1]\n i2 = i * i\n h[n] -= h[n / i] - hp\n # h[n / j]は「i = jのときのh[n]に呼び出されるまでは計算しておく」ことにし、\n # i = jのとき、h[n / (j + 1)]から計算していくことにする\n keys[i..-1].each{|j|\n break if j < i2\n h[j] -= h[j / i] - hp\n }\n end\n }\n h[n]\n end\n \n```\n\nn = 10^12 を計算させた結果\n\n```\n\n user system total real\n 37607912018\n 264.796000 0.078000 264.874000 (268.561594)\n \n```\n\n元々のコードで計算させた結果\n\n```\n\n user system total real\n 37607912018\n 304.062000 0.078000 304.140000 (308.404353)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-07T06:37:01.727", "id": "12109", "last_activity_date": "2015-07-08T14:05:49.237", "last_edit_date": "2015-07-08T14:05:49.237", "last_editor_user_id": "5363", "owner_user_id": "5363", "parent_id": "12033", "post_type": "answer", "score": 2 } ]
12033
12109
12109
{ "accepted_answer_id": null, "answer_count": 2, "body": "Unityで作成したゲームをデバッグし、x-code上でArchiveし、Archiveビルドが作成されValidateボタンを押したら、 \n「iTunes Store operation failed. \nNo suitable application records were found Verify your bundle identifier\n'boundle name' is correct」というエラーで成功しません。\n\nこのエラーの解決方法を教えていただけないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T19:22:54.613", "favorite_count": 0, "id": "12035", "last_activity_date": "2018-10-09T03:23:05.060", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10024", "post_type": "question", "score": 0, "tags": [ "ios", "unity3d" ], "title": "iosアプリのリリース申請のエラー", "view_count": 7386 }
[ { "body": "ご自分のアカウントで、itunesconnectに、ログインして、そのappが、waiting for upload になってますか?\nなってなければ、そういうエラーは、出るべくして出ます。 \nitunesconnect側で、AppStore用スクリーンショット、Appの説明文などのメタデータを入力して、waiting for\nuploadの状態にすることが必要です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T04:19:04.903", "id": "12040", "last_activity_date": "2015-07-05T04:19:04.903", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "75", "parent_id": "12035", "post_type": "answer", "score": 2 }, { "body": "itunes connectってサイトで先に+を押さないとダメですね", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2018-10-09T03:23:05.060", "id": "49080", "last_activity_date": "2018-10-09T03:23:05.060", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7934", "parent_id": "12035", "post_type": "answer", "score": 0 } ]
12035
null
12040
{ "accepted_answer_id": "12039", "answer_count": 1, "body": "Mac OSX上でPHP 5.6.2を使っています。\n\n以下のように`zip`で圧縮ファイルを作成しました。 \nそのファイルを`unzip`で解凍すると、パーミッションを正しく再現できるのですが、PHPのZipArchiveクラスを使って解凍すると、実行権限がなくなってしまいます。\n\nPHPを使って、実行権限をを正しく解凍するよい方法はないでしょうか? \nなお、圧縮ファイルの種類や、PHPのライブラリの種類は問いませんが、先日質問をさせていただいた、シンボリックリンクを含む圧縮ファイルが正しく解凍できる方法であることが前提になります。\n\n先日の質問 \n[PHPでシンボリックリンクを含む圧縮ファイルを解凍したい](https://ja.stackoverflow.com/questions/11999)\n\n### 圧縮ファイルの作成\n\ncommand.shには実行権限が付いています。\n\n```\n\n $ ls -l\n total 8\n -rwxr-xr-x 1 foo bar 22 7 5 10:20 command.sh\n \n $ zip ../command.zip *\n adding: command.sh (stored 0%)\n \n```\n\n### unzipで解凍\n\ncommand.shの実行権限は付いたまま正しく解凍されます。\n\n```\n\n $ unzip command.zip -d tmp\n Archive: command.zip\n extracting: tmp/command.sh\n \n $ ls -l tmp\n total 8\n -rwxr-xr-x 1 foo bar 22 7 5 10:20 command.sh\n \n```\n\n### PHPのZipArchiveで解凍\n\ncommand.shの実行権限が無くなってしまいます。\n\n```\n\n $ php unzip.php \n \n $ ls -l tmp\n total 8\n -rw-r--r-- 1 foo bar 22 7 5 10:42 command.sh\n \n```\n\nPHPの解凍用プログラム\n\n```\n\n <?php\n \n $zip = new ZipArchive;\n $zip->open(\"command.zip\");\n $zip->extractTo(\"tmp\");\n $zip->close();\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T01:53:58.183", "favorite_count": 0, "id": "12037", "last_activity_date": "2015-07-05T06:47:52.120", "last_edit_date": "2017-04-13T12:52:38.920", "last_editor_user_id": "-1", "owner_user_id": "9529", "post_type": "question", "score": 2, "tags": [ "php" ], "title": "PHPのZipArchiveで圧縮ファイルを解凍するとパーミッションが変わってしまう", "view_count": 1863 }
[ { "body": "シンボリックリンクと同じく`getExternalAttributesIndex`を使ってパーミッションを復元します。\n\n```\n\n <?php\n \n function extractToSym($zip, $dir)\n {\n for ($idx=0 ; $s = $zip->statIndex($idx) ; $idx++) {\n if ($zip->getExternalAttributesIndex($idx, $opsys, $attr) && $opsys==ZipArchive::OPSYS_UNIX) {\n $st_mode = $attr >> 16;\n if (($st_mode & 0120000) === 0120000) {\n symlink($zip->getFromIndex($idx), $dir . '/' . $s['name']);\n } else {\n $zip->extractTo($dir, $s['name']);\n chmod($dir . '/' . $s['name'], $st_mode & 07777);\n }\n }\n }\n }\n \n $zip = new ZipArchive();\n if ($zip->open('samples.zip') === TRUE) {\n extractToSym($zip, '.');\n $zip->close();\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T03:45:22.987", "id": "12039", "last_activity_date": "2015-07-05T06:47:52.120", "last_edit_date": "2015-07-05T06:47:52.120", "last_editor_user_id": "3639", "owner_user_id": "3639", "parent_id": "12037", "post_type": "answer", "score": 5 } ]
12037
12039
12039
{ "accepted_answer_id": null, "answer_count": 0, "body": "Mediawikiの1.20よりも前のバージョンで、新しい画像のリストを取得しようとしましたが、方法がみつかりません。どうすればよいでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T04:56:04.663", "favorite_count": 0, "id": "12041", "last_activity_date": "2015-07-05T04:56:04.663", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10399", "post_type": "question", "score": 1, "tags": [ "api" ], "title": "Mediawiki api.php での新しい画像の取得", "view_count": 70 }
[]
12041
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "以下のようなアプリは実現可能でしょうか?\n\n 1. アイコンをタップして起動すると、特定のURLがGoogleのChromeで表示される。\n 2. Chromeがない場合、ダウンロードを促すメッセージが表示され、OKならばダウンロードページへと移動する。\n 3. Chromeがバックグラウンドに移行した状態でアイコンをクリックすると、Chromeがバックグラウンドからフォアグラウンドへ移行して表示される。\n 4. その際、バックグラウンドのChromeが特定のドメインであればそのまま表示されるが、そうではなかった場合はそのドメインへと移動する。\n\n要は、WebアプリをChromeで使用するためのアプリです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T07:42:45.883", "favorite_count": 0, "id": "12042", "last_activity_date": "2016-08-18T12:25:59.800", "last_edit_date": "2015-09-06T00:55:35.620", "last_editor_user_id": "2238", "owner_user_id": "10401", "post_type": "question", "score": 0, "tags": [ "android", "google-chrome" ], "title": "WebアプリをChromeで使用するためのアプリを実現したい", "view_count": 817 }
[ { "body": "手元にAndroid機が無く未検証ですが、以下のようなコードでChromeの有無で処理は分岐出来ると思います。 \n4番の特定のドメインが既に開いていたら・・・というのは難しいのではないでしょうか。\n\n```\n\n String urlString=\"http://www.google.com\";\n Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse(urlString));\n intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n intent.setPackage(\"com.android.chrome\");\n try {\n // ChromeがインストールされていればChromeで開く\n startActivity(intent);\n } catch (ActivityNotFoundException ex) {\n // Chromeが見つからなければダウンロード\n startActivity(new Intent(Intent.ACTION_VIEW, \n Uri.parse(\"market://details?id=com.android.chrome\")));\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T14:33:05.147", "id": "12094", "last_activity_date": "2015-07-06T14:33:05.147", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6105", "parent_id": "12042", "post_type": "answer", "score": 1 } ]
12042
null
12094
{ "accepted_answer_id": null, "answer_count": 1, "body": "GitHubの使い方についてよくわかるサイトなどをなるべくたくさん教えて下さい。初心者です。Source\nTreeの使い方もよくわからないので、よろしくお願いします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T08:39:56.183", "favorite_count": 0, "id": "12043", "last_activity_date": "2015-07-05T10:47:49.580", "last_edit_date": "2015-07-05T10:47:49.580", "last_editor_user_id": "8870", "owner_user_id": "10400", "post_type": "question", "score": -7, "tags": [ "git", "github" ], "title": "GitHubとSource Treeの使い方を教えてください", "view_count": 429 }
[ { "body": "GitHub/Git関連\n\n[GitHub Help - GitHub Enterprise Documentation](https://help.github.com/) \nGitHub公式のHelp\n\n[ 海外Webサービスのトリセツ(4):GitHub(ギットハブ)の使い方:登録編 -\n@IT](http://www.atmarkit.co.jp/ait/articles/1407/22/news019.html) \nGitHubの使い方を登録から日本語で解説している\n\n[Qiita GitHub](https://qiita.com/tags/github) \nQiitaのGitHubについての投稿が集まっているページ\n\n[サルでもわかるGit入門](http://www.backlog.jp/git-guide/ \"サルでもわかるGit入門 〜バージョン管理を使いこなそう〜\n| どこでもプロジェクト管理バックログ\") \nわかりやすいGit(GitHubではない)の使い方\n\n[git入門 (全22回) - プログラミングならドットインストール](http://dotinstall.com/lessons/basic_git) \nGitの基本的なことについて3分動画で学べる\n\n[Qiita Git](https://qiita.com/tags/git) \nQiitaのGitについての投稿が集まっているページ\n\n* * *\n\nSourceTree関連\n\n[リポジトリの作成と基本的なバージョン管理――SourceTreeで始めるGitバージョン管理入門 第1回 | OSDN\nMagazine](http://osdn.jp/magazine/14/11/06/200000) \nSourceTreeの基本的な部分の記事\n\n[Qiita SourceTree](https://qiita.com/tags/sourcetree) \nQiitaのSourceTreeについての投稿が集まっているページ", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T09:29:47.357", "id": "12046", "last_activity_date": "2015-07-05T09:29:47.357", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "5246", "parent_id": "12043", "post_type": "answer", "score": 5 } ]
12043
null
12046
{ "accepted_answer_id": "12050", "answer_count": 2, "body": "**質問するきっかけ** \n・使用検討しているライブラリが、cdnjsでホストされていました\n\n**質問1** \n・以前から疑問に思っていたのですが、色々なホストがCDNを公開していますが、ホスト側にはどういうメリットがあるのでしょうか? \n・ある日、いきなりクローズしたりしないのでしょうか? \n・何のために公開している?\n\n**質問2** \n・これまでずっと稼働環境にライブラリを配置して使用してきたのですが、環境によってはCDNを使用した方が早い場合もあるのでしょうか? \n・キャッシュ対策が施されている?\n\n**質問3** \n・対象ライブラリが、複数のCDNで公開されている場合、選定基準はどこで判断すれば良いのでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T09:10:51.590", "favorite_count": 0, "id": "12044", "last_activity_date": "2016-03-11T03:53:31.887", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 3, "tags": [ "javascript" ], "title": "CDNは何のために存在? 本番環境で使用しても良い?", "view_count": 1605 }
[ { "body": "**質問1** \n同じファイルを世界中のサイトでそれぞれ配信するより、同じURLで公開することでクライアント側でもキャッシュが効きトラフィックを抑えられるため、と考えられます。彼らの場合、トラフィックをさばくコストが膨大であるためそれを抑えること、Webアプリを速くすることは経済的です。 \nホスティングを辞めてしまう可能性は少なからずあります。ポリシーを確認しましょう。\n\n**質問2** \nCDNのキャッシュサーバの配置にもよりますが、稼働環境よりも近いキャッシュサーバが存在する可能性が高いので、早さの効果はあると思われます。 \nキャッシュ対策がどのレイヤでの話か分かりませんが、CDNはキャッシュをユーザの近くに置くことが至上命題なので、対策済みと言えます。\n\n**質問3** \n利用者がたどると予想される経路周辺にキャッシュサーバを持っていそうなホストを選ぶことと考えます。 \nまた、選定にこだわりすぎず、止まった場合などを考慮してfallbackの仕組みを入れることもご検討ください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T12:15:48.560", "id": "12050", "last_activity_date": "2015-07-05T12:15:48.560", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2238", "parent_id": "12044", "post_type": "answer", "score": 6 }, { "body": "質問1 \nホスト側は宣伝のためJSやCSSを自社CDNをつかって配信しています。 \n勿論いきなりクローズすることもあります。\n\n質問2\n\nCDNを利用したほうが早くなるケースもあります。 \n例えばCDNを使いコンテンツをリクエストする先のドメインを分けることにより、ブラウザが1回にリクエストできる上限が緩和され、シングルドメインより複数同時にリクエストが発行できるというメリットがあります。\n\n逆に経路やアクセスするユーザーのDNSがANY CASTを使っている場合、近隣のサーバーから配信することが出来なくなり逆に遅くなる場合があります。\n\nキャッシュがきくか、きかないかという点については、どこでキャッシュをきかせるのか、というお話になってきます。 \nCDNは元々のサーバーにあるコンテンツを常にキャッシュしていますので、CDN側だけのお話であればCDN=常にキャッシュしてるといえます。\n\n逆に、利用者側の視点でいうとブラウザ側のキャッシュがきくようになるのか否かということが重要だと思います。これらは別にCDNを使わなくとも適切なヘッダを出力してあげる設定をすれば、きちんとブラウザキャッシュをきかせることが出来ます。\n\n質問3\n\n基本的には大手ベンダーさんを選んでおけば問題ありません。\nCDN事業者が独自で提供しているライブラリもありますが、よほど大きいところで無い限りスタンダードな名前がしれてるところを選ぶべきでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-03-11T03:53:31.887", "id": "23013", "last_activity_date": "2016-03-11T03:53:31.887", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14736", "parent_id": "12044", "post_type": "answer", "score": 0 } ]
12044
12050
12050
{ "accepted_answer_id": null, "answer_count": 2, "body": "Xcode7にて無料で実機テストが出来ると聞き、Xcode7で実機テストをしてみました。 \nすると、表題の通り、\n\nXcode cannot run using the selected device.\n\nと出てしまい実機テストができない状態です。 \nまたエミュレーターを選ぶ部分の \nineligible deviseにはunavailableと出てしまい、それを選択して実機テストをしようとしても\n\nCould not find Developer Disk Image\n\nとなってしまいます。 \n解決策を教えてください。\n\n・使用OSや実機のスペック \nXcode7 beta \nMac Os:10.10.4 \nIOS実機:iphone4s IOS8.4\n\n・Xcodeの設定 \nIOS deployment Target:8.4", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T09:57:22.537", "favorite_count": 0, "id": "12047", "last_activity_date": "2015-07-11T05:27:33.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10353", "post_type": "question", "score": 2, "tags": [ "xcode" ], "title": "xcode7にて「Xcode cannot run using the selected device」と出て実機テストが出来ません", "view_count": 1896 }
[ { "body": "自己解決しました。\n\n参考ブログ:[seiya-orz.hatenablog.com](http://seiya-orz.hatenablog.com/)\n\nいま調べていたのですが、どうやらxcode7betaではIOS8.4対応のimage diskが入っていないようです。\nxcode6.4には入っているようなので、そこからコピペをして稼働してみます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T13:36:19.187", "id": "12052", "last_activity_date": "2015-07-05T19:25:56.820", "last_edit_date": "2015-07-05T19:25:56.820", "last_editor_user_id": "7362", "owner_user_id": "10353", "parent_id": "12047", "post_type": "answer", "score": 1 }, { "body": "記事のURLが変更になりましたので、こちらを参考にしてください。 \n<http://seiya-orz.hatenablog.com/entry/2015/07/05/163207>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-11T05:27:33.527", "id": "12272", "last_activity_date": "2015-07-11T05:27:33.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10487", "parent_id": "12047", "post_type": "answer", "score": 0 } ]
12047
null
12052
{ "accepted_answer_id": "12054", "answer_count": 1, "body": "AWSのIAMを利用して、他のユーザが特定のリソースのみにアクセスできるようにしたいです。\n\n様々なサイトを参考にしながらPolicyのJSONファイルを記述しているのですが、そのなかで以下の様な例みつかりました。\n\n```\n\n {\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"Stmt1373379896000\",\n \"Action\": [\n \"ec2:describe*\"\n ],\n \"Resource\": [\n \"*\"\n ],\n \"Effect\": \"Allow\"\n },\n {\n \"Sid\": \"Stmt1373381303000\",\n \"Action\": [\n \"ec2:RebootInstances\",\n \"ec2:StartInstances\",\n \"ec2:StopInstances\",\n \"ec2:TerminateInstances\"\n ],\n \"Resource\": [\n \"arn:aws:ec2:ap-northeast-1:0123456789:instance/i-e0123456\"\n ],\n \"Effect\": \"Allow\"\n }\n ]\n }\n \n```\n\nこのPolicyを設定されたグループに所属するユーザは以下のことが可能になると思います。\n\n * 全てのEC2インスタンスを閲覧できる\n * 特定のインスタンス(i-e0123456)に対しReboot、Start、Stop,Terminateができる\n\nしかし、今回は特定のインスタンスに対してすべての権限を与え、それ以外のインスタンスを閲覧できないようにしたいです。\n\n`Statement`配列の1つ目のステートメントでは、`ec2:describe*`アクションが有効になっており、対象のリソースが`Resource:[\"*\"]`となっていますので、全てのEC2インスタンスに対しての閲覧権限を与えるという意味になるかと思います。\n\nこの設定のせいで、見せたくないインスタンスが閲覧できるようになってしまっていると思われるので、`Resouce:[\"*\"]`を特定のインスタンスを指定するようにする必要があります。\n\nしかし、そのようなリソースを指定しているステートメントは`Statement`配列の2つ目のステートメントに設定されていますので、こちらの`Action`に`ec2:describe*`を追加すれば良いということになります。\n\n加えて、2番めのステートメントでは、`Action`がRebootやStartなど特定のアクションのみの操作に限定されています。今回は特定のインスタンスに全てのアクション権限を与えたいと思っていますのでこちらの`Action`も`ec2:*`に変更します。\n\nすると以下のようなPolicyJSONが出来上がります。\n\n```\n\n {\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"Stmt1373381303000\",\n \"Action\": [\"ec2:*\"],\n \"Resource\": [\"arn:aws:ec2:ap-northeast-1:0123456789:instance/i-e0123456\"],\n \"Effect\": \"Allow\"\n }\n ]\n }\n \n```\n\nしかし、上記のPolicyを設定されたアカウントでログインしてみても、インスタンスが一つも表示されず、目的の権限を与えることができていません。\n\n試しに初めに記述したPolicyJSONを設定してみたところ、全てのインスタンスが表示されることが確認できました。\n\narnの記述方法としましては以下のようになっており\n\n```\n\n arn:aws:service:region:account:resource\n \n```\n\n今回、質問用に書き換えさせて頂いておりますが\n\n```\n\n arn:aws:ec2:ap-northeast-1:0123456789:instance/i-e0123456\"\n \n```\n\n上記arnは\n\n```\n\n arn:aws:ec2:[リージョンのID]:[AWSアカウントのID]:instance/[インスタンスID]\"\n \n```\n\nと認識しており、リージョンは東京リージョンを利用していて、AWSアカウントIDもインスタンスIDにも間違いがありません。\n\nインスタンスの詳細を見てみたところ、リージョンが`ap-\nnortheast-1a`となっていたので、`a`を付け加えてみたのですが、Policyの検証時に`invalid region for vendor\nec2.`というようなエラーが表示されてしまいました。\n\nどこに間違いがあるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T10:10:35.707", "favorite_count": 0, "id": "12048", "last_activity_date": "2015-07-05T14:49:50.110", "last_edit_date": "2015-07-05T10:23:27.677", "last_editor_user_id": "5840", "owner_user_id": "5840", "post_type": "question", "score": 1, "tags": [ "aws" ], "title": "AWSでIAMのPolicyの設定で特定のインスタンス以外のインスタンスを閲覧できないようにしたい", "view_count": 3792 }
[ { "body": "API によっては arn によるリソース区別をサポートしていないものがあります。 \n現時点では、EC2 の DescribeInstances もこれに該当します。\n\n<http://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/ec2-supported-iam-\nactions-resources.html> \n<http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ec2-api-\npermissions.html#ec2-api-unsupported-resource-permissions>\n\nリソース区別をサポートしていない API の場合、IAM Policy のリソースには \"*\" と設定しなければならないようです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T14:49:50.110", "id": "12054", "last_activity_date": "2015-07-05T14:49:50.110", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4603", "parent_id": "12048", "post_type": "answer", "score": 2 } ]
12048
12054
12054
{ "accepted_answer_id": null, "answer_count": 0, "body": "rubyで10MBのtsvを処理すると途中で止まってしまいます。 \ntsvの行数は41,452ですが、以下のコードで実行すると164で止まってしまいます。\n\n```\n\n i = 1\n CSV.foreach(filename, :col_sep => \"\\t\", encoding: \"Windows-31J:UTF-8\") do |row|\n p i += 1\n end\n \n```\n\n止まるときはエラーになどで終了されず、そのまま実行の状態で停止します。 \nメモリなどの問題でしょうか。 \nすべて同時に処理する必要はなく、1行ずつ個別に処理できれば問題なので、解決方法を教えて下さい。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T11:21:53.947", "favorite_count": 0, "id": "12049", "last_activity_date": "2015-07-05T11:21:53.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9149", "post_type": "question", "score": 1, "tags": [ "ruby", "csv" ], "title": "rubyでtsvを処理すると途中でとまる", "view_count": 212 }
[]
12049
null
null
{ "accepted_answer_id": "12055", "answer_count": 1, "body": "表題の件について質問です。 \nHackerRankというサイトでプログラミングの問題を解いています。 \nデータ構造は以下のコードで作りその後ノードの値を足しあわせていこうと思ったのですが、 \nどのように合計値を計算すればよいのか方針が分かりません。 \nヒントやアドバイスをいただけないでしょうか。 \n※もし、データ構造に問題がありましたらそれも合わせてご教示いただけると幸いです。\n\nよろしくお願いします。\n\n[問題] \n<https://www.hackerrank.com/challenges/cut-the-tree>\n\n[コード]\n\n```\n\n class Tree:\n \"\"\"\n Original Tree Structure which is representing the Input\n \"\"\"\n def __init__(self, value, position):\n \"\"\"\n Initialize class instance\n :param value: value of the node\n \"\"\"\n self.value = value\n self.position = position\n self.connection = []\n \n def set_connection(self, connection):\n \"\"\"\n set connection with other instance\n :param connection:\n \"\"\"\n self.connection.append(connection)\n \n def set_value(self, value):\n \"\"\"\n set value of the instance\n :param value: value\n \"\"\"\n self.connection = value\n \n def get_value(self, position):\n return self.value\n \n def get_sum(self):\n \"\"\"\n Running Tree and sum up the value of node.\n :param frm: which node coming from\n :param to: which node goes next\n :return: sum value\n \"\"\"\n return self.value\n \n def get_position(self):\n return self\n \n if __name__ == \"__main__\":\n \n # ----- Initializing ------\n N = int(input())\n values = input().split()\n T = []\n a = 0\n for value in values:\n T.append(Tree(int(value), a))\n a += 1\n \n input_list = []\n for i in range(N-1):\n in_con = input().split()\n T[int(in_con[0])-1].set_connection(int(in_con[1])-1)\n T[int(in_con[1])-1].set_connection(int(in_con[0])-1)\n input_list.append(in_con)\n \n # ----- Start searching -----\n \n 〜ここから値の走査を始める〜\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T13:04:48.480", "favorite_count": 0, "id": "12051", "last_activity_date": "2015-07-05T15:55:58.173", "last_edit_date": "2015-07-05T15:55:58.173", "last_editor_user_id": "5363", "owner_user_id": "7738", "post_type": "question", "score": 0, "tags": [ "python", "binary-tree" ], "title": "Tree 構造の走査及び値の算出", "view_count": 491 }
[ { "body": "リンク先の問題文をよく読んでみると、どの vertex がルートになるかの指定がありませんし、一つの vertex から出ていく edge\nの数が高々2本であるという制約もありません。したがってバイナリツリーで表現するのは得策ではありません。\n\nむしろ (ループのない) 無向グラフとして表した方がよいと思います。深さ優先探索 (depth first search)\nというアルゴリズムを使って、edge の一方の側の合計を求めていきます。全体の合計は簡単に求められるので、片方の合計が分かれば、Tree_diff\nも簡単に求められます。 \nこの方法なら、どの vertex から始めても大丈夫なはずです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T15:15:58.837", "id": "12055", "last_activity_date": "2015-07-05T15:15:58.837", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3605", "parent_id": "12051", "post_type": "answer", "score": 1 } ]
12051
12055
12055
{ "accepted_answer_id": "12082", "answer_count": 1, "body": "はじめまして、 \nMonacaにおいて動的に要素(テキストフォーム)を作り、そのうち最初のものにフォーカスを合わせるということをしたくて、以下のようにコードを書いたのですが、\n\n```\n\n function drawAnsSheet(){\n var text_form = \"\";\n for(i=0; i < digits; i++){\n text_form = text_form + '<INPUT type=\"text\" class=\"class1\" id=\"col' + i + '\">';\n }\n \n $(\"#call_text\").html(text_form);\n $('input:visible').eq(0).focus();\n }\n \n```\n\nChromeではうまく最初の要素にフォーカスが合ったのですが、Monacaですと、フォーカスが合いませんでした。フォーカスを合わせるにはどうすればいいのでしょうか。 \nよろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T13:49:24.937", "favorite_count": 0, "id": "12053", "last_activity_date": "2015-07-06T09:01:44.310", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9621", "post_type": "question", "score": 1, "tags": [ "monaca" ], "title": "[monaca]動的に作った要素にフォーカスを合わせるには?", "view_count": 802 }
[ { "body": "タイミングの問題の様な気がします(画面に要素が表示される前に`focus()`が呼ばれている)。 \n`onload`とか`setTimeout`でタイミングをずらしてみると違った結果が出るのではないでしょうか。\n\nもし、サンプルのメモ帳アプリのように`changePage`を使用しており、かつ移動先のページに追加した要素があるのであれば、ページが表示された時にフォーカスを合わせるようにするとうまくいくのではないかと思います。\n\n少し分かりにくいかもしれませんがサンプルです(メモ帳アプリをベースにしています)。\n\nindex.html\n\n```\n\n <!-- TOP Page -->\n <div data-role=\"page\" id=\"TopPage\">\n <header data-role=\"header\" data-position=\"fixed\" data-theme=\"c\">\n <h1>Monaca Memo</h1>\n <a href=\"#AddPage\" data-icon=\"plus\" class=\"ui-btn-right\">Add</a>\n </header>\n </div>\n \n <!-- Add Memo Page -->\n <div data-role=\"page\" id=\"AddPage\">\n <section id=\"call_text\">\n </section>\n </div>\n \n```\n\njavascript\n\n```\n\n //// append input element\n function appendForm() {\n var text_form = \"\";\n for(i=0; i < 5; i++){\n text_form = text_form + '<INPUT type=\"text\" class=\"class1\" id=\"col' + i + '\">';\n }\n \n $(\"#call_text\").html(text_form);\n }\n \n //// focus element\n function focusElement() {\n $('input:visible').eq(0).focus();\n }\n \n ///// Called when app launch\n function onReady() {\n appendForm();\n \n // AddPageが表示されたら先頭の要素にフォーカスを合わせる\n $('#AddPage').on('pageshow', function(event, ui) {\n focusElement();\n });\n }\n \n $(onReady); // on DOMContentLoaded\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T09:01:44.310", "id": "12082", "last_activity_date": "2015-07-06T09:01:44.310", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3516", "parent_id": "12053", "post_type": "answer", "score": 1 } ]
12053
12082
12082
{ "accepted_answer_id": null, "answer_count": 2, "body": "MonacaクラウドIDEにてiBeaconサンプルを試すべく cordova-plugin-\nibeaconをダウンロードの上、Monacaの「cordovaプラグインの管理」にてインポートしました。\n\nここまでは以下のAsial BLOGを参考にしています。 \n<http://blog.asial.co.jp/1343>\n\nGalaxy S4(Android 4.4.2)\nにインストールして実行したところ、iBeaconサンプルのページにある1から6までのアイコンは正常に表示されたのですが、Monacaのコンソールに以下のようなエラーが出力され、iBeaconを認識していないようです。\n\n> CreateBeacon err:TypeError: Cannot read property 'locationManager' of\n> undefined \n> Delegate err: TypeError: Cannot read property 'locationManager' of\n> undefined\n\nBeaconは Aplix社のものを用意し、同社の提供サンプルアプリにて正しく認識され、電波強度表示、測距ができています。\n\nMonacaのiBeaconサンプルのページ \n<http://docs.monaca.mobi/cur/ja/sampleapp/samples/ibeacon/>\n\ncordova-plugin-ibeaconは、MonacaクラウドIDEのplugins\nフォルダ以下に正しく展開されているようですが、サンプル記事にはそこまでの画像/記述がないため正しく展開・設定されているのかどうかを確認できていません。 \nサンプルコードはいじっていません。\n\ncordova-plugin-\nibeaconをアプリに認識させるための何かがたりないのだと思うのですが、ネット上を一日探してもそれらしい情報に行き当たりませんでした。\n\niBeacon対応アプリはiOS向けに開発されている方が多いと思いますが、 \nサンプルコードはAndroidでは動かないのでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T20:41:17.527", "favorite_count": 0, "id": "12057", "last_activity_date": "2015-08-07T08:11:11.370", "last_edit_date": "2015-07-08T02:22:53.623", "last_editor_user_id": "8000", "owner_user_id": "10408", "post_type": "question", "score": 1, "tags": [ "monaca", "ibeacon" ], "title": "iBeaconのサンプルコードで Cannot read property 'locationManager'", "view_count": 874 }
[ { "body": "同じエラーに遭遇し、正しくdeviceready後に実行されるようにしたら解決した、という例を見つけました。\n\n<https://github.com/petermetz/cordova-plugin-ibeacon/issues/110>\n\nで、 <http://blog.asial.co.jp/1343> を参考にされたとのことですが、載っているコードをそのまま貼り付けたのでしょうか。\n\n> DeviceReadyになってから実行してください。\n\nと書かれていますが、この点は問題ありませんか?\n\n* * *\n\nサンプルプロジェクトのことを忘れていました。確かに、deviceready内に書かれていますね。。\n\n<https://github.com/monaca/project-\ntemplates/blob/4.1_cordova/24-ibeacon/www/js/app.js#L35>\n\n> ちょっとでもコードが正しく解釈されない場合、推測不能な今回のようなエラーが発生するのでは\n\n前述のIssueの場合、 `onDeviceReady` という関数を渡すつもりが、 `onDeviceReady()`\nをその場で実行した結果を渡してしまったために、deviceready時に実行したかった処理がすぐさま実行され、実行時エラーになったということです。エラーを直訳すると「undefined\nの 'locationManager' プロパティを読み取れない」なので、 `cordova.plugins` が undefined\n(未定義のプロパティを参照したときの値)だったということになります。\n\nなので、私はこれと同じように「何らかの間違いでdevicereadyを待たずに実行している」ことを疑ったのですが、そうでなければ確かに「プラグインを読み込めていない」のかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-08T02:33:07.880", "id": "12135", "last_activity_date": "2015-07-08T07:51:26.640", "last_edit_date": "2015-07-08T07:51:26.640", "last_editor_user_id": "8000", "owner_user_id": "8000", "parent_id": "12057", "post_type": "answer", "score": 1 }, { "body": "ご回答有難うございます。\n\n以下、ご指摘の点についてです。\n\n□載っているコードをそのまま貼り付けたのでしょうか。 \nサンプルプロジェクトをそのまま利用していますので、全体としてコーディング上の欠陥が \nないはずのものです。 \nご指摘のonDeviceReadyについては、コーディング上にコールバック関数として定義されています。\n\n□参考サイトの情報 \n<https://github.com/petermetz/cordova-plugin-ibeacon/issues/110> \nは、検索でヒットしていたので見ていました。 \nこの解決は、本来、\"onDeviceReady\" とすべきところを\n\"onDeviceReady()\"としていたためのエラーで、これを修正することによって正常に機能した、という内容ではないかと。。。\n\n上記の場合と同じ、 \nCreateBeacon err:TypeError: Cannot read property 'locationManager' of\nundefined \nDelegate err: TypeError: Cannot read property 'locationManager' of undefined \nが発生するのは、ちょっとでもコードが正しく解釈されない場合、推測不能な今回のようなエラーが発生するのではないかと想像しています。\n\n※英語版のstackoverflowは、回答者と質問者のキャッチボールがそれらしく区分されているのですが、日本語版では、質問者の投稿をどのようにしていいのか不明だったため、回答欄を利用しています。 \nもしかしたら、質問者を識別してくれるのかもしれません。\n\n宜しくお願いします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-08T06:40:51.497", "id": "12150", "last_activity_date": "2015-07-08T06:40:51.497", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10409", "parent_id": "12057", "post_type": "answer", "score": 1 } ]
12057
null
12135
{ "accepted_answer_id": "12458", "answer_count": 4, "body": "PCに接続されているキーボードの数と種類を取得するにはどうすればいいでしょうか? \nノートPCを使用している場合に、USBにてテンキー有りのキーボードが接続されたかどうかを \n調べたいと思います。\n\n`GetKeyboardType`を使ってみましたが、テンキー有りキーボードを接続しても、 \n接続しなくても結果は変わりませんでした。\n\n環境はVisual C++です。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T00:06:44.097", "favorite_count": 0, "id": "12058", "last_activity_date": "2015-07-23T12:21:14.707", "last_edit_date": "2015-07-06T00:25:20.250", "last_editor_user_id": "4236", "owner_user_id": "8328", "post_type": "question", "score": 2, "tags": [ "c++", "windows" ], "title": "PCに接続されているキーボードの数と種類の取得について", "view_count": 2525 }
[ { "body": "テンキー無しキーボードにとって、テンキー有りキーボードで単にテンキーが使われなかったことと大差ありません。また物理的に独立したテンキーが用意されていなくてもノートパソコンのように既存のキー部分にテンキーをマッピングされているものもあります。 \nですので区別する機構は用意されていないと思われます。\n\n本気で識別するのであればBLUEPIXYさんも提案されているようにWMIのWin32_Keyboardを使い、DeviceIDからキーボードの機種を判別することぐらいでしょうか。そうだとしてもやはりテンキーの有無は識別できないかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-17T22:54:34.257", "id": "12458", "last_activity_date": "2015-07-17T22:54:34.257", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "12058", "post_type": "answer", "score": 1 }, { "body": "使ったことはありませんが、この辺りの情報が参考にならないでしょうか。\n\nKeyboard and Mouse Input \n<https://msdn.microsoft.com/en-us/library/ms632585(v=vs.85).aspx>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-18T02:52:11.763", "id": "12462", "last_activity_date": "2015-07-18T02:52:11.763", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8505", "parent_id": "12058", "post_type": "answer", "score": -1 }, { "body": "USB-HID の規格上は、デバイスは Report Descriptor に使用するキーコードの一覧を返してくれるはずなので、そこに keypad〇〇\n(テンキー)のコードが含まれるかどうかで判別できると思います。 \nただ、Windows で任意のデバイスの Report Descriptor を取得する方法は、申し訳ないですが詳しく知りません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-22T15:26:21.920", "id": "12579", "last_activity_date": "2015-07-22T15:26:21.920", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9935", "parent_id": "12058", "post_type": "answer", "score": 2 }, { "body": "キーボードそのものの判別ではありませんが、 \nコメントにある NumKeyロックOff時のDeleteキーなどについては、拡張キーフラグも組み合わせて見れば区別できるんじゃないかと思います。\n\n[WM_KEYDOWN](https://msdn.microsoft.com/ja-\njp/library/windows/desktop/ms646280\\(v=vs.85\\).aspx)\n\n上記のbits 24のところです。\n\n[GetKeyNameText](https://msdn.microsoft.com/ja-\njp/library/cc364675.aspx)でもこのフラグを見ています。\n\nただし拡張キーフラグが 1の時がNumpadというわけではないのでそこは注意してください。 \nたとえばEnterであれば拡張キーフラグが 1のとき、NumpadのEnterですが、 \nDeleteキーはNumPadのDelが拡張キーフラグ 0になります。\n\n一見するとSCANCODEでも判別できそうに見えますが、SCANCODEはOEM依存(キーボードメーカー依存)なので正確とは言えません。 \n(実際は 3種類くらいに落ち着くとは思いますが絶対ではないので)\n\n以下はWM_KEYDOWNでタイトルバーにGetKeyNameTextや拡張キーフラグなどの内容を出力する VC++のサンプルです。\n\n```\n\n LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\n {\n int wmId, wmEvent;\n PAINTSTRUCT ps;\n HDC hdc;\n \n switch (message)\n {\n case WM_KEYDOWN:\n TCHAR buffer[256];\n TCHAR keyname[128];\n \n GetKeyNameText(lParam, keyname, sizeof(TCHAR) * 128);\n \n \n _stprintf_s(buffer, _T(\"%s , ext: %d vkey: %X scancode :%04X \\0\"),\n keyname, (lParam & 0x01000000) >> 24, wParam, (lParam & 0x00FF0000) >> 16);\n \n SetWindowText(hWnd, buffer);\n \n break;\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-23T12:21:14.707", "id": "12622", "last_activity_date": "2015-07-23T12:21:14.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "728", "parent_id": "12058", "post_type": "answer", "score": 0 } ]
12058
12458
12579
{ "accepted_answer_id": null, "answer_count": 1, "body": "IntelliJにて作成した既存のcordova/phonegapプロジェクトへionicを追加(?)するにはどうすれば良いのでしょうか? \nプラグインにてサポートされていると書いていますが使用方法がわかりません。\n\nまた、新規プロジェクト作成時に設定する方法もあれは教えていただけると嬉しいです。\n\nちなみに使用中のバージョンは\n\nIntelliJ IDEA 14 Ultimate\n\nです。\n\nよろしくお願いします", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T00:26:47.457", "favorite_count": 0, "id": "12059", "last_activity_date": "2015-08-11T11:56:38.263", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5319", "post_type": "question", "score": 2, "tags": [ "android-studio", "cordova", "intellij-idea" ], "title": "IntelliJでionicしたい", "view_count": 172 }
[ { "body": "他サイトで解決できました! \n回答を記載しておきます。\n\n「ionic start」にて作成したプロジェクトをIntelliJで開くことができました!\n\n「Import Project」ではなく「Open」から作成したAppのフォルダを選択することでできました。 \nあとは、設定からexecutableへ「/usr/local/bin/ionic」を選択すれば実行できました! \n詳しくは「<https://www.jetbrains.com/idea/help/using-phonegap-\ncordova.html>」を参照ください。\n\n既存プロジェクトへは試していませんが、同様の操作でいける気がします。\n\nまた、「Import Project」でもできるのかもしれませんが私のやり方が悪いのか「www」フォルダなどが含まれませんでした。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-12T10:57:46.147", "id": "12298", "last_activity_date": "2015-07-12T10:57:46.147", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5319", "parent_id": "12059", "post_type": "answer", "score": 1 } ]
12059
null
12298
{ "accepted_answer_id": null, "answer_count": 0, "body": "初心者です。 \nPUSH通知機能を設定したいのですが、クラウドのアイコンにある「プッシュ通知」をダブルクリックして、「アプリ宛に作成」\nをクリックして、「追加」をクリックすると\n\n> 通知情報の登録に失敗:There are no target devices\n\nと表示されて追加できません。 \n何が原因なのでしょうか?(AndroidManifest.xmlにを記入済み。Google API Console で GCM\nを有効化。コレクションを追加済みです。) \nPUSH通知の設定等は色々なところにあって、どこから手をつけていいのか分かりません。 \nどなたか、分かる方お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T01:40:04.927", "favorite_count": 0, "id": "12061", "last_activity_date": "2015-07-08T15:35:44.330", "last_edit_date": "2015-07-08T15:35:44.330", "last_editor_user_id": "8000", "owner_user_id": "10244", "post_type": "question", "score": 1, "tags": [ "android", "push-notification" ], "title": "PUSH通知。「アプリ宛てに作成」エラー", "view_count": 285 }
[]
12061
null
null
{ "accepted_answer_id": "12068", "answer_count": 1, "body": "お世話になっております。\n\n<https://github.com/zaru/Cakephp2_AWS_S3_DataSource> \nこのプラグインを使用してS3アップにしたいのですが、導入してページを開くと\n\nError: Class 'Aws\\S3\\S3Client' not found \nFile:\n/var/www/html/cakephp/app/Plugin/AmazonWebServices/Model/Datasource/S3.php \nLine: 21\n\nこのようなエラーがでてしまいます。\n\nS3のクライアントが認識されていないと思われるのですが、どこに何を記述していいのかわかりません。パケット名は記述したのですが、クライアントとはAWS、S3のどこの部分でしょうか?\n\nuse Aws\\S3\\Enum\\CannedAcl; \nuse Aws\\S3\\S3Client; \nuse Aws\\S3\\Exception\\S3Exception; \nuse Guzzle\\Http\\EntityBody;\n\nclass S3 extends DataSource { \npublic $description = 'AmazonWebServices S3 File Controller'; \npublic $S3 = ''; \npublic $bucketName = '****'; //パケット名入力\n\n```\n\n public function __construct($config = array(), $autoConnect = true){\n parent::__construct($config);\n $this->S3 = S3Client::factory($config);\n $this->bucketName = $config['bucket_name'];\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T02:05:58.627", "favorite_count": 0, "id": "12062", "last_activity_date": "2015-09-04T06:24:08.923", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10088", "post_type": "question", "score": 1, "tags": [ "cakephp", "aws" ], "title": "CakePHP2.6でAWSのS3をプラグインを使用して使いたいのですが", "view_count": 706 }
[ { "body": "このプラグインの動作にはAWS SDKのv2系がインストールされていることが前提のようです。\n\n<https://github.com/aws/aws-sdk-php/tree/2.8>\n\nから、v2系を取得して適切なパスを通すか、\n\n```\n\n composer require aws/aws-sdk-php:\"2.*\"\n \n```\n\nのようにComposerでバージョンを指定してインストールすると良いと思います。\n\n(CakePHP 2系でComposerを利用する方法はGoogle等で検索してみてください。\n\nなお、データソースとして利用することにこだわりが無ければ、AWS SDKのv3系を直接利用するのもありだと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T05:40:25.813", "id": "12068", "last_activity_date": "2015-07-06T05:40:25.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2668", "parent_id": "12062", "post_type": "answer", "score": 1 } ]
12062
12068
12068
{ "accepted_answer_id": null, "answer_count": 1, "body": "raspividで取得した動画をffmpegの`-c:v`でコーデックを指定してエンコードするとProtocol not foundとエラーがでます。 \nコマンドは\n\n```\n\n ffmpeg test -y -i -c:v libx264 test01.mp4\n \n```\n\nこれでやっています。testはraspividで取得した動画です。 \n`c:v`を使わずにmp4にエンコードするとmp4の動画ができます。\n\nなぜ`c:v`を使うとProtocol not foundがでるのかの原因がわかりません。 \nどなたか教えて欲しいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T03:46:00.760", "favorite_count": 0, "id": "12065", "last_activity_date": "2015-07-07T03:37:59.860", "last_edit_date": "2015-07-07T03:37:59.860", "last_editor_user_id": "49", "owner_user_id": "9349", "post_type": "question", "score": 1, "tags": [ "raspberry-pi", "ffmpeg" ], "title": "ffmpegのオプション -c:vについて質問です。", "view_count": 1058 }
[ { "body": "オプションの順番が間違っていませんか?入力ファイル名は `-i` の直後に指定します。\n\n```\n\n ffmpeg -i test -c:v libx264 test01.mp4\n \n```\n\nなぜ Protocol not found というエラーになったのかはわかりませんが・・・。\n\n[ffmpegの使い方:tech.ckme.co.jp](http://tech.ckme.co.jp/ffmpeg.shtml)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T13:11:16.903", "id": "12092", "last_activity_date": "2015-07-06T13:11:16.903", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "12065", "post_type": "answer", "score": 3 } ]
12065
null
12092
{ "accepted_answer_id": null, "answer_count": 1, "body": "XHTMLからJava\nAppletを起動しようとしましたがhoge.classが存在しないとclassnotfoundexceptionが発生します。LocalのEclipse環境では起動しましたが、Glassfishにデプロイするとエラーが発生します。\n\n以下は起動するときに呼び出すindex.xhtmlです。 \nclass,jar,xhmtl共にWebContentフォルダに入れてあります。\n\n```\n\n <div style=\"margin: 0 auto;\">\n <object type=\"application/x-java-applet\" codebase=\".\" width=\"200px\" height=\"50px\">\n <param name=\"code\" value= \"hoge.class\" />\n <param name=\"codebase\" value=\".\" />\n <param name=\"archive\" value=\"signedHoge.jar\" />\n <param name=\"archive\" value=\"hoge.jar\" />\n </object>\n \n```\n\nよろしくお願い致します。\n\n※編集 \n・フォルダ構成 \nWebContent \n- index.xhtml \n- hoge.class ※1 \n- signedhoge.jar \n- hoge.jar\n\n※1 \nhoge.classは同プロジェクトの以下に作成したものを移動しました。 \nbuild \n- test \n-- hoge.class\n\n・jarファイルは以下のコマンドで作成しました。\n\n```\n\n keytool -genkey -keyalg rsa -storepass changeit -alias appletkey -keypass changeit -validity 365\n \n jar cfM hoge.jar hoge.class\n \n jarsigner -storepass changeit -keypass changeit -signedjar signedHoge.jar hoge.jar appletkey\n \n```\n\n・マニフェストファイル内容\n\n```\n\n Manifest-Version: 1.0\n Created-By: 1.8.0_45 (Oracle Corporation)\n Permissions: sandbox\n Name: hoge.class\n SHA-256-Digest: RZ71edQJoTbT9OHsDBLcXXJ+fMthkHIynfD/+mzXfRk=\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T04:56:52.640", "favorite_count": 0, "id": "12067", "last_activity_date": "2015-08-05T14:22:02.630", "last_edit_date": "2015-07-06T13:37:07.650", "last_editor_user_id": "9577", "owner_user_id": "9577", "post_type": "question", "score": 3, "tags": [ "java", "jsf" ], "title": "Java Applet起動時にclassnotfoundexception", "view_count": 1462 }
[ { "body": "* archive \nhoge.classを含む署名済みのjarのみを指定します。 \n`<param name=\"archive\" value=\"signedHoge.jar\" />`\n\n * マニフェスト \n7u51以降ではMANIFEST.MFファイルにPermissions属性が必須です。 \n[【Java 7 u51 関連情報(1)】Java 7\nUpdate51におけるRIAの新しいセキュリティ要件について](https://blogs.oracle.com/otnjp/entry/java_7_u51_update_info)\n\n * 署名 \n7u51以降、自己署名はブロックされるので証明書の購入か例外サイトへの追加が必要です。 \n[Generating a Certificate Signing Request (CSR) for a Public Key\nCertificate](http://docs.oracle.com/javase/tutorial/security/sigcert/index.html#GenCSR) \n[どうすれば例外サイト・リストを構成できますか。](https://www.java.com/ja/download/faq/exception_sitelist.xml)", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T07:13:07.147", "id": "12073", "last_activity_date": "2015-07-06T10:21:30.360", "last_edit_date": "2015-07-06T10:21:30.360", "last_editor_user_id": "241", "owner_user_id": "241", "parent_id": "12067", "post_type": "answer", "score": 1 } ]
12067
null
12073
{ "accepted_answer_id": null, "answer_count": 0, "body": "ons-navigatorタグとons-templateタグを指定するとアラートダイアログが利用できません。\n\n<http://codepen.io/anon/pen/mJxEWN>\n\n```\n\n ons.bootstrap()\r\n \r\n .controller('NotificationController', function($scope) {\r\n $scope.alert = function() {\r\n ons.notification.alert({\r\n message: 'An error has occurred!'\r\n });\r\n }\r\n \r\n $scope.confirm = function() {\r\n ons.notification.confirm({\r\n message: 'Are you sure you want to continue?',\r\n callback: function(idx) {\r\n switch (idx) {\r\n case 0:\r\n ons.notification.alert({\r\n message: 'You pressed \"Cancel\".'\r\n });\r\n break;\r\n case 1:\r\n ons.notification.alert({\r\n message: 'You pressed \"OK\".'\r\n });\r\n break;\r\n }\r\n }\r\n });\r\n }\r\n \r\n $scope.prompt = function() {\r\n ons.notification.prompt({\r\n message: \"Please enter your age\",\r\n callback: function(age) {\r\n ons.notification.alert({\r\n message: 'You are ' + parseInt(age || 0) + ' years old.'\r\n });\r\n }\r\n });\r\n }\r\n });\n```\n\n```\n\n <link href=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.3.3/build/css/onsen-css-components.css\" rel=\"stylesheet\" />\r\n <link href=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.3.3/build/css/onsenui.css\" rel=\"stylesheet\" />\r\n <script src=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.3.3/build/js/onsenui.min.js\"></script>\r\n <script src=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.3.3/build/js/angular/angular.min.js\"></script>\r\n <ons-navigator var=\"navigator\" page=\"alert.html\"></ons-navigator>\r\n \r\n <ons-template id=\"alert.html\">\r\n <ons-page>\r\n <ons-toolbar>\r\n <div class=\"center\">\r\n Notifications\r\n </div>\r\n </ons-toolbar>\r\n \r\n <ons-list ng-controller=\"NotificationController\">\r\n <ons-list-item ng-click=\"alert()\" modifier=\"tappable\">\r\n Alert\r\n </ons-list-item>\r\n <ons-list-item ng-click=\"confirm()\" modifier=\"tappable\">\r\n Confirm\r\n </ons-list-item>\r\n <ons-list-item ng-click=\"prompt()\" modifier=\"tappable\">\r\n Prompt\r\n </ons-list-item>\r\n </ons-list>\r\n </ons-page>\r\n </ons-template>\n```\n\n教えてください。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2015-07-06T06:25:00.037", "favorite_count": 0, "id": "12071", "last_activity_date": "2019-12-13T20:08:13.143", "last_edit_date": "2019-12-13T20:08:13.143", "last_editor_user_id": "32986", "owner_user_id": "10417", "post_type": "question", "score": 1, "tags": [ "onsen-ui" ], "title": "<ons-navigator>と<ons-template>を指定したアラートダイアログ", "view_count": 167 }
[]
12071
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "mod_pagespeedを有効にした状態(設定はデフォルトのまま)で、<https://developers.google.com/speed/pagespeed/insights/> \nで確認すると、画像の最適化が必要、という形で以下のようなファイル名のものが \nx10311228024_6742e515d2_k.jpg.pagespeed.ic.5t2_fLEght.jpg \n怒られてしまうのですが、このような場合どういう対処をすれば良いでしょうか?\n\nよろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T07:00:40.027", "favorite_count": 0, "id": "12072", "last_activity_date": "2015-07-06T07:00:40.027", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4989", "post_type": "question", "score": 1, "tags": [ "apache" ], "title": "mod_pagespeedを利用した時のPageSpeed画面での確認について", "view_count": 40 }
[]
12072
null
null
{ "accepted_answer_id": "12091", "answer_count": 1, "body": "お世話になっております。 \n`<?php echo $uploads[\"Upload\"][\"tags\"]; ?>`とすると \n`php, html, cakephp` \nのように,(カンマ)がついて表示されますが、 \n`php html cakephp` の一つ一つを表示させて、タグの一つ一つを分けてデザインがつくようにしたいです。 \n`<?php echo $uploads[\"Upload\"][\"Tagged\"][\"name\"]; ?>` \nとしても個別で表示されないのですが、どうしたら個別でタグを表示させることができるでしょうか? \nよろしくお願いいたします。\n\n```\n\n array(4) { \n [\"Upload\"]=> array(18) { \n [\"id\"]=> string(1) \"7\" \n [\"name\"]=> string(0) \"\" \n [\"subject\"]=> string(15) \"文字列表示\" \n [\"body\"]=> string(36) \"PHPで文字列を表示させる。\" \n [\"tags\"]=> string(18) \"php, html, cakephp\"\n } \n \n [\"Tag\"]=> array(3) { \n [0]=> array(8) { \n [\"id\"]=> string(36) \"558fee8a-01c4-4cad-9d54-23caac1f12c5\" \n [\"identifier\"]=> NULL \n [\"name\"]=> string(3) \"php\" \n [\"keyname\"]=> string(3) \"php\" \n [\"weight\"]=> string(1) \"0\" \n \n [\"Tagged\"]=> array(8) {\n \n [1]=> array(8) { \n [\"id\"]=> string(36) \"558fee8a-dddc-407b-af90-23caac1f12c5\" \n [\"identifier\"]=> NULL \n [\"name\"]=> string(4) \"html\" \n [\"keyname\"]=> string(4) \"html\" \n [\"weight\"]=> string(1) \"0\" \n \n [\"Tagged\"]=> array(8) { \n [\"id\"]=> string(36) \"5595e50c-0e04-4177-9de8-79eaac1f12c5\" \n [\"foreign_key\"]=> string(1) \"7\" \n [\"tag_id\"]=> string(36) \"558fee8a-dddc-407b-af90-23caac1f12c5\" \n [\"model\"]=> string(6) \"Upload\"\n [\"language\"]=> string(2) \"ja\" \n [\"times_tagged\"]=> string(1) \"1\" \n \n [2]=> array(8) { \n [\"id\"]=> string(36) \"55922ed8-757c-4dc4-b50b-79edac1f12c5\" \n [\"identifier\"]=> NULL \n [\"name\"]=> string(7) \"cakephp\" \n [\"keyname\"]=> string(7) \"cakephp\" \n [\"weight\"]=> string(1) \"0\" \n \n [\"Tagged\"]=> array(8) { \n [\"id\"]=> string(36) \"5595e50c-8180-4c4a-80a2-79eaac1f12c5\" \n [\"foreign_key\"]=> string(1) \"7\" \n [\"tag_id\"]=> string(36) \"55922ed8-757c-4dc4-b50b-79edac1f12c5\" \n [\"model\"]=> string(6) \"Upload\" \n [\"language\"]=> string(2) \"ja\" \n [\"times_tagged\"]=> string(1) \"1\" \n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T08:05:57.973", "favorite_count": 0, "id": "12077", "last_activity_date": "2015-08-06T02:41:13.000", "last_edit_date": "2015-07-07T02:12:39.140", "last_editor_user_id": "2668", "owner_user_id": "10088", "post_type": "question", "score": 1, "tags": [ "php", "cakephp" ], "title": "cakephpのtagsプラグインを使用しているのですが配列の取り出しかたがわかりません。", "view_count": 71 }
[ { "body": "`$uploads[\"Upload\"][\"Tagged\"]` が配列になっているようですから、それを foreach で順番に取り出し、その中の\n`[\"name\"]` を表示してはいかがでしょうか。\n\n```\n\n <ul>\n <?php foreach ($uploads[\"Upload\"][\"Tagged\"] as $tag): ?>\n <li><?php echo $tag[\"name\"]; ?></li>\n <?php endforeach; ?>\n </ul>\n \n```\n\nここでは `foreach(...):` `endforeach;`\nという書き方を使いましたが、まとまったPHPコードであれば以下のような記法も一般的です。\n\n```\n\n <?php\n \n foreach (...) {\n echo \"hoge\";\n }\n \n```\n\n[PHP: foreach - Manual](http://php.net/manual/ja/control-\nstructures.foreach.php)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T13:03:19.303", "id": "12091", "last_activity_date": "2015-07-06T13:03:19.303", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "12077", "post_type": "answer", "score": 1 } ]
12077
12091
12091
{ "accepted_answer_id": "12090", "answer_count": 4, "body": "初質問失礼します。 \nrubyでif文を記述する際、1つの配列のすべての要素を同じ条件式に格納して、andで結びたいです。\n\n```\n\n if hoge[0]!=\"\" and hoge[1]!=\"\" and hoge[2]!=\"\".. then\n \n```\n\nというようにです。しかし、配列全てに対してこのような記述をすると、あまりにも長くなりすぎてしまいます。 \nそこで、以下のような記述ができないだろうかと試してみました。a~zは変数です。\n\n```\n\n hoge=[a,b,c,d,..z]\n if hoge[0..-1] != \"\" then\n puts \"all exist\"\n else\n puts \"foo\"\n end\n \n```\n\n出力結果: \n変数a~zの値が全て \"\" の時でも、どこかに値が入っている時でも、\"all exist\"が出力されました。 \nどうしてこのような出力結果になったかも私にはよく分かりませんでした。\n\n1つの配列の条件式を全てandで結びたい場合に、何か良い記述の方法はないでしょうか。 \nよろしければ、私の記述方法が間違っている理由も教えていただきたいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T08:09:11.380", "favorite_count": 0, "id": "12078", "last_activity_date": "2015-07-06T20:48:56.007", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10421", "post_type": "question", "score": 1, "tags": [ "ruby" ], "title": "if文での配列の取り扱い方について", "view_count": 1677 }
[ { "body": "`inject`で頑張るとできそうな気がしました(条件部分があってるかはやや自信なし。。)\n\n```\n\n if hoge.inject {|ret, i| ret && i != \"\"} then\n puts \"all exist\"\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T08:20:17.170", "id": "12079", "last_activity_date": "2015-07-06T08:20:17.170", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "845", "parent_id": "12078", "post_type": "answer", "score": 0 }, { "body": "配列中に一つでも空の要素があれば \"foo\" を出力し、そうでなければ \"all exist\" を出力したいということであれば、次のようにすればできます。\n\n```\n\n if hoge.any?(&:empty?)\n puts \"foo\"\n else\n puts \"all exist\"\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T09:06:30.607", "id": "12083", "last_activity_date": "2015-07-06T09:06:30.607", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3249", "parent_id": "12078", "post_type": "answer", "score": 3 }, { "body": "この場合は`all?`を使うのがいちばん素直な方法だと思います。\n\n```\n\n if hoge.all? {|item| item!=\"\"}\n puts \"all exist\"\n else\n puts \"foo\"\n end\n \n```\n\n> そこで、以下のような記述ができないだろうかと試してみました。a~zは変数です。\n```\n\n> hoge=[a,b,c,d,..z]\n> if hoge[0..-1] != \"\" then\n> puts \"all exist\"\n> else\n> puts \"foo\"\n> end\n> \n```\n\n>\n> 出力結果: 変数a~zの値が全て \"\" の時でも、どこかに値が入っている時でも、\"all exist\"が出力されました。 \n> どうしてこのような出力結果になったかも私にはよく分かりませんでした。\n\n`hoge[0..-1]`という表現は「hogeの1番最初の要素」から「hogeの後ろから1番目の要素」までの配列を返します。つまりhogeと同じものを返します。\n\nhogeは配列であって文字列ではないので、hogeの中身に関わらず`hoge[0..-1] != \"\"`は常に真となります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T12:22:39.553", "id": "12090", "last_activity_date": "2015-07-06T12:52:33.627", "last_edit_date": "2015-07-06T12:52:33.627", "last_editor_user_id": "3639", "owner_user_id": "3639", "parent_id": "12078", "post_type": "answer", "score": 6 }, { "body": "1行で書くならこんな感じですね。\n\n```\n\n puts hoge.any?(&:empty?) ? 'foo' : 'all exist'\n \n```\n\nもしくはこう。\n\n```\n\n puts hoge.none?(&:empty?) ? 'all exist' : 'foo'\n \n```\n\nついでにこんなパターンも\n\n```\n\n puts hoge.count(\"\").zero? ? 'all exist' : 'foo'\n \n```\n\n確認用に書いたテスト(Minitest)も載せておきます。\n\n```\n\n require 'minitest/autorun'\n \n describe Array do\n let(:all_empty) { ['', '', '']}\n let(:all_exist) { ['1', '2', '3']}\n let(:mixed) { ['1', '', '3']}\n \n def all_ok?\n ->{ans(all_empty)}.must_output \"foo\\n\"\n ->{ans(all_exist)}.must_output \"all exist\\n\"\n ->{ans(mixed)}.must_output \"foo\\n\"\n end\n \n it do\n def ans(hoge)\n puts hoge.count(\"\").zero? ? 'all exist' : 'foo'\n end\n all_ok?\n end\n \n it do\n def ans(hoge)\n puts hoge.none?(&:empty?) ? 'all exist' : 'foo'\n end\n all_ok?\n end\n \n it do\n def ans(hoge)\n puts hoge.any?(&:empty?) ? 'foo' : 'all exist'\n end\n all_ok?\n end\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T20:27:48.437", "id": "12100", "last_activity_date": "2015-07-06T20:48:56.007", "last_edit_date": "2015-07-06T20:48:56.007", "last_editor_user_id": "85", "owner_user_id": "85", "parent_id": "12078", "post_type": "answer", "score": 0 } ]
12078
12090
12090
{ "accepted_answer_id": "12086", "answer_count": 1, "body": "現在下記ソースのような、ファイルダウンロードの実装しています。 \nそこで、Chromeブラウザで「名前を付けて保存」ダイアログを表示し保存するようにしたいのですが、下記ソースですとダイアログが出ずに保存されてしまいます。 \n方法のわかる方がいましたら、ご教授をお願いします。\n\nまた、自身で調査した観点としましては、 \n・javascriptで右クリック押下→Aキーを発火し、ダイアログを出す \n・ファイル保存時に別タブで表示し、javascriptでCtrl + sを発火する\n\n```\n\n var saveText = function(text, filename) {\r\n var a = document.createElement('a');\r\n a.href = 'data:text/plain,' + encodeURIComponent(text);\r\n a.download = filename;\r\n var evt = document.createEvent('MouseEvents');\r\n evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, true, false, false, 0, null);\r\n a.dispatchEvent(evt);\r\n }\r\n \r\n saveText('テキスト', 'ファイル名.txt');\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T09:01:13.187", "favorite_count": 0, "id": "12081", "last_activity_date": "2015-07-06T11:22:43.433", "last_edit_date": "2015-07-06T11:02:06.307", "last_editor_user_id": "8000", "owner_user_id": "7626", "post_type": "question", "score": 1, "tags": [ "javascript", "google-chrome" ], "title": "javascript:Chromeブラウザで「名前を付けて保存」ダイアログを表示し保存するようにしたい", "view_count": 14443 }
[ { "body": "本家 StackOverflow にも同様の質問はいくつか見られますが、Chrome の設定を変える以外の方法は見つかりませんでした。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/MmtHm.png)\n\nChromeアプリであれば「[保存先の選択ダイアログを表示する](https://developer.chrome.com/apps/fileSystem#method-\nchooseEntry)」といった機能も用意されているようですが、お使いのテクニックはあくまで「ダウンロード」させるものですから、「ダウンロードしたファイルはダイアログなしで保存されることをユーザーが望んでいる」以上、それに従うのが正しいのではないでしょうか。\n\nなお、Javascriptを使って **ブラウザに対する**\nキーボード・マウス操作のエミュレーションが行えないのはChromeの実装上の理由もあるでしょうが、セキュリティ上の観点からもできるとは思えません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T11:22:43.433", "id": "12086", "last_activity_date": "2015-07-06T11:22:43.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "12081", "post_type": "answer", "score": 1 } ]
12081
12086
12086
{ "accepted_answer_id": "12103", "answer_count": 1, "body": "お世話になっております。 \nご回答ありがとうございます。 \n現在、ご紹介いただいた <https://github.com/robmcvey/cakephp-amazon-s3> のプラグインを使用しているのですが、\n\n```\n\n Error: Call to a member function put() on null \n File: /var/www/html/cakephp-2.6.4/app/Controller/UploadsController.php \n Line: 25\n \n```\n\nという、エラーが発生しています。 `$AmazonS3->put('/*****/files/');` の部分です。 \nReadmeの通りに記述しましたがうまくいかないのですが、記述の仕方がまちがっているのでしょうか? \nよろしくお願いいたします。\n\n```\n\n public function add() {\n if ($this->request->is('post')) {\n \n $tmp = $this->request->data['Upload']['file']['tmp_name'];\n if(is_uploaded_file($tmp)) {\n $filename = basename($this->request->data['Upload']['file']['name']);\n $file = WWW_ROOT.'files'.DS.$filename;\n \n // S3にファイル保存\n $AmazonS3->put('/*****/files/'); // *****はパケット名、filesは作成したフォルダ\n \n if (move_uploaded_file($tmp, $file)) {\n $this->Upload->create();\n $this->request->data['Upload']['filename'] = $filename;\n if ($this->Upload->saveAll($this->request->data)) {\n $this->Session->setFlash(__('アップロードしました。'));\n $this->redirect(array('action' => 'index'));\n } else {\n $this->Session->setFlash(__('アップロードできませんでした。'));\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T09:44:06.070", "favorite_count": 0, "id": "12084", "last_activity_date": "2015-08-06T03:41:11.890", "last_edit_date": "2015-07-07T02:13:15.743", "last_editor_user_id": "2668", "owner_user_id": "10088", "post_type": "question", "score": 1, "tags": [ "cakephp", "aws" ], "title": "CakePHP2でAWSのS3プラグインを使用しているのですがアップロードがうまくいきません。", "view_count": 475 }
[ { "body": "`$AmazonS3`が作成されていません。\n\nREADMEをもう一度よく読んでみましょう。\n\n```\n\n App::uses('AmazonS3', 'AmazonS3.Lib');\n $AmazonS3 = new AmazonS3(array('{access key}', '{secret key}', '{bucket name}'));\n \n```\n\nとあるはずです。", "comment_count": 11, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-07T01:48:02.340", "id": "12103", "last_activity_date": "2015-07-07T01:48:02.340", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2668", "parent_id": "12084", "post_type": "answer", "score": 1 } ]
12084
12103
12103
{ "accepted_answer_id": null, "answer_count": 2, "body": "wordpressの画像のアップロードを少し前まで、サーバに直接アップロードしていたのですが、 \nストレージを別に用意してそちらに画像をアップロードする様にしました。\n\nすると今まで画像のURLは\n\n<http://hogehoge.com/wp-content/upload/wp-content/uploads/2014/04/image.jpg>\n\nの様になっていたのですが、それが\n\n<http://hogehoge.s3.amazonaws.com/wp-content/upload/wp-\ncontent/uploads/2014/04/image.jpg>\n\nという感じにドメイン名が変わりました。\n\nところが、ストレージに切り替える前のファイルのURLは、古い方のURLで、データベースに保存されています。 \nメディアファイルのURLを一括して新しい方のドメイン名に変更したいく、試行錯誤したのですがうまくいきませんでした。\n\nwordpressでアップロードした画像のURLだけを変更する方法をご存知の方がいらしたら、 \nよろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T09:55:50.493", "favorite_count": 0, "id": "12085", "last_activity_date": "2015-11-04T03:23:06.747", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5436", "post_type": "question", "score": 1, "tags": [ "wordpress" ], "title": "wordpressでアップロードしたメディアファイルのURLを変更する方法", "view_count": 7969 }
[ { "body": "WordPressのDB内に記述されているURLを変更したいということでよろしいでしょうか?\n\n`Search Replace DB`というツールを使うとよい、という記事を発見しました。 \n初めはSQLを使って、一括置換すればよいのかと思ったのですが、WordPressの場合、シリアライズされたデータがあり、これをやってしまうと整合性があわなくなるようです。詳細は参考サイトをご覧ください。\n\n参考サイトは少し前の記事ですが、ツール自体はアクティブにメンテナンスされているようで、最近も更新されています。\n\nただ、私もこのツールを使ったことはないので、あくまで自己責任でご利用ください。ツールの作者さんも全てのケースを想定するのは努力はしているが難しいので、バックアップをとって自己責任で実行するように警告しています。\n\n参考サイト \n<http://www.infoscoop.org/blogjp/2014/08/14/use-search-and-replace-for-\nwordpress-when-moving/> \n<http://webcre-archive.com/2012/10/04/wordpress-db-url-replace/>\n\nツールのサイト \n<https://interconnectit.com/products/search-and-replace-for-wordpress-\ndatabases/> \n<https://github.com/interconnectit/Search-Replace-DB>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T15:19:50.247", "id": "12095", "last_activity_date": "2015-07-06T15:19:50.247", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9529", "parent_id": "12085", "post_type": "answer", "score": 1 }, { "body": "最近メジャーな方法はWP-CLIを使うことでしょうか。 \nWP-CLIでWordPressをコマンドラインから操作できるのですが、そのコマンドの1つに「search-replace」というものがあります。 \nこれでURLの一括置換が行えるので、サイト移転の際などに重宝されています。 \n参考記事:<http://gatespace.jp/2014/12/02/wp-cli-wp-search-replace/>\n\nWP-CLIは公式ドキュメントも英語ながら豊富ですので、この機会にお試しください。 \n<http://wp-cli.org/>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-04T03:23:06.747", "id": "18391", "last_activity_date": "2015-11-04T03:23:06.747", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3555", "parent_id": "12085", "post_type": "answer", "score": 0 } ]
12085
null
12095
{ "accepted_answer_id": "12089", "answer_count": 1, "body": "Golangで書かれたWebsocketサーバーで、非同期でReceive, Sendをできるようにしたいと思っています。 \n下のように`chat_receiver`, `chat_sender`関数内でfor\nをつかってループさせ、それをgoroutineを使って並列実行させようと考えています。 \nしかし、このコードを実行しwebsocket clientでアクセスすると、`use of closed network\nconnection`と表示されます。 \nこの問題を解決するにはどうすればいいのでしょうか?\n\nchat_senderはStdinから読み込まれた文字列を相手に送り、 \nchat_receiverは相手から送られた文字列をStdoutに表示しようとしています。\n\n```\n\n \n package main\n \n import (\n \"bufio\"\n \"fmt\"\n \"golang.org/x/net/websocket\"\n \"net/http\"\n \"os\"\n )\n \n func chat_sender(ws *websocket.Conn) {\n for {\n bio := bufio.NewReader(os.Stdin)\n line, _, err := bio.ReadLine()\n if err != nil {\n fmt.Println(err)\n fmt.Println(\"returned\")\n return\n }\n websocket.Message.Send(ws, line)\n \n }\n }\n \n func chat_receiver(ws *websocket.Conn) {\n for {\n var st string\n if err := websocket.Message.Receive(ws, &st); err != nil {\n fmt.Println(\"err: \", err)\n return\n }\n fmt.Println(\"chat receive:\", st)\n fmt.Println(\"returned\")\n }\n }\n \n func chatHandler(ws *websocket.Conn) {\n go chat_sender(ws)\n go chat_receiver(ws)\n }\n \n func main() {\n http.HandleFunc(\"/chat\", func(w http.ResponseWriter, req *http.Request) {\n s := websocket.Server{Handler: websocket.Handler(chatHandler)}\n s.ServeHTTP(w, req)\n \n })\n fmt.Println(\"port:\", 9563)\n http.ListenAndServe(\":9563\", nil)\n }\n \n \n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T11:47:57.270", "favorite_count": 0, "id": "12087", "last_activity_date": "2015-07-06T12:11:39.977", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5246", "post_type": "question", "score": 2, "tags": [ "go", "websocket" ], "title": "GolangでWebsocketで非同期でReceive, Sendをする", "view_count": 1098 }
[ { "body": "chatHandler関数を抜けた時点でコネクションが終了してしまうので、接続中はchatHandler内でブロックするようにしてください。\n\n```\n\n func chatHandler(ws *websocket.Conn) {\n go chat_receiver(ws)\n chat_sender(ws)\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T12:11:39.977", "id": "12089", "last_activity_date": "2015-07-06T12:11:39.977", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "12087", "post_type": "answer", "score": 1 } ]
12087
12089
12089
{ "accepted_answer_id": null, "answer_count": 1, "body": "java6では正常に動いていたXMLの読み込みが、java8にアップデートしたら \n以下のようなExcepitonをはきだすようになってしまいました。 \n同じような現象を経験した方、解法をご存知の方がいましたら、お知恵を拝借できないでしょうか?\n\n```\n\n 重大: null\n org.xml.sax.SAXNotRecognizedException: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized.\n at org.apache.xerces.parsers.AbstractSAXParser.setFeature(Unknown Source)\n at org.apache.xerces.jaxp.SAXParserImpl.setFeatures(Unknown Source)\n at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)\n at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParserImpl(Unknown Source)\n at org.apache.xerces.jaxp.SAXParserFactoryImpl.setFeature(Unknown Source)\n at com.sun.xml.internal.bind.v2.util.XmlFactory.createParserFactory(XmlFactory.java:121)\n at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.getXMLReader(UnmarshallerImpl.java:139)\n at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:157)\n at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:214)\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T11:58:15.293", "favorite_count": 0, "id": "12088", "last_activity_date": "2015-07-07T13:38:52.133", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10425", "post_type": "question", "score": 3, "tags": [ "java", "java8" ], "title": "java6→java8にアップデートしたらXML読み込み時にSAXNotRecognizedExceptionが発生", "view_count": 13084 }
[ { "body": "kenji Noguchi様、ありがとうございます。 \nおっしゃるとおり、Xercesのjarを最新にしたら上手く動かすことが出来ました。\n\n<http://xml.apache.org/xalan-j/downloads.html> \n<http://archive.apache.org/dist/xml/xalan-j/> \n上記サイトから、xalan-j_2_7_1-bin.zip をダウンロードして \nxercesImpl.jar \nxml-apis.jar \nserializer.jar \nxalan.jar \nこれらのファイルを差し替えることで、問題解決をすることが出来ました。\n\n改めて、ありがとうございました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-07T13:38:52.133", "id": "12125", "last_activity_date": "2015-07-07T13:38:52.133", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10425", "parent_id": "12088", "post_type": "answer", "score": 3 } ]
12088
null
12125
{ "accepted_answer_id": null, "answer_count": 0, "body": "背景モデルにライト情報をbakeの設定で焼き付け、プレハブ化したものを別シーンで使用したいと思っています。 \nあらかじめヒエラルキーにプレハブを放り込んだ場合はただしくライトマップが反映されているのですが、シーンの途中でプログラムからResources.Loadで読み込み実体化した場合、bakeではなく全てリアルタイムの処理がなされており、焼き付けの影よりも精度が落ちています。 \n上記のような工程でも正しく焼き付けのライトマップを使える方法があるでしょうか。 \nあるいはunityの仕様なのでしょうか? (ちなみに5.1.1のパーソナル版を使用しています)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T13:47:03.203", "favorite_count": 0, "id": "12093", "last_activity_date": "2015-07-06T13:47:03.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10426", "post_type": "question", "score": 3, "tags": [ "unity3d" ], "title": "ライトマップをベイクしたプレハブをResources.Loadで読み込んだ場合", "view_count": 527 }
[]
12093
null
null
{ "accepted_answer_id": "12099", "answer_count": 1, "body": "RailsからSendgridでメールを送信しようとしているのですが、正しく送信されません。次のエラーが原因でしょうか?\n\n```\n\n sh: 1: /usr/sbin/sendmail: not found\n \n```\n\nconfig/environments/prduction.rb\n\n```\n\n config.action_mailer.perform_deliveries = true\n config.action_mailer.raise_delivery_errors = false\n config.action_mailer.default_url_options = { :host => '###'}\n config.action_mailer.delivery_method = :smtp\n config.action_mailer.smtp_settings = {\n :address => 'smtp.mandrillapp.com',\n :port => 25,\n :authentication => \"login\",\n :user_name => '###',\n :password => '###',\n :domain => '###',\n :enable_starttls_auto => true\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T19:00:46.970", "favorite_count": 0, "id": "12098", "last_activity_date": "2017-01-22T22:42:13.150", "last_edit_date": "2017-01-22T22:42:13.150", "last_editor_user_id": "8000", "owner_user_id": "8991", "post_type": "question", "score": -2, "tags": [ "ruby-on-rails", "heroku", "sendmail" ], "title": "Herokuから確認メールを送信することができない", "view_count": 1018 }
[ { "body": "SendGridを使うのであれば、まず使用中のHerokuインスタンスにSendGridアドオンが追加されていることを確認して下さい。\n\nそれから smtp_settings のなかに mandrillapp の文字が見えます。MandrillはSendGridとは別のメール送信サービスです。 \nSendGridのヘルプページを見て正しい設定を入力して下さい。\n\n<https://devcenter.heroku.com/articles/sendgrid#ruby-rails>\n\n```\n\n ActionMailer::Base.smtp_settings = {\n :address => 'smtp.sendgrid.net',\n :port => '587',\n :authentication => :plain,\n :user_name => ENV['SENDGRID_USERNAME'],\n :password => ENV['SENDGRID_PASSWORD'],\n :domain => 'heroku.com',\n :enable_starttls_auto => true\n }\n \n```\n\nもしアドオンを使わずにSendGridを外部サービスとして使うのであれば以下のような設定になるかもしれません。(僕は試したことがないですが)\n\n<https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html>\n\n```\n\n ActionMailer::Base.smtp_settings = {\n :user_name => 'your_sendgrid_username',\n :password => 'your_sendgrid_password',\n :domain => 'yourdomain.com',\n :address => 'smtp.sendgrid.net',\n :port => 587,\n :authentication => :plain,\n :enable_starttls_auto => true\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T20:07:29.203", "id": "12099", "last_activity_date": "2015-07-06T20:07:29.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "85", "parent_id": "12098", "post_type": "answer", "score": 0 } ]
12098
12099
12099
{ "accepted_answer_id": null, "answer_count": 2, "body": "現在、おみくじのサンプルアプリで勉強をしています。 \nサンプルコードを参考にBGMの再生はできたのですが、BGMの切り替え方法がわかりません。 \n画面推移を使わず、同一画面のままBGMを切り替えたいです。\n\nどんなコードをどの部分に入れればBGMが切り替え出来ますか?\n\nわかる方いましたら、ご教授よろしくおねがします。 \n使用している環境はXcode7 swift2.0です。\n\nーーGameViewController BGM1を再生ーー\n\n```\n\n import UIKit\n import SpriteKit\n import AVFoundation //AVFoundationフレームワークをインポートする。\n \n class GameViewController: UIViewController {\n \n var player:AVAudioPlayer? //BGM を制御するための変数\n var soundManager = SEManager() //SEManager でインスタンス化した変数\n //BGM再生メソッド\n func play(soundName:String){\n //サウンドファイルを読み込む\n let soundPath = NSBundle.mainBundle().bundlePath.stringByAppendingPathComponent(soundName)\n //読み込んだファイルにパスを付ける\n let url:NSURL? = NSURL.fileURLWithPath(soundPath)\n do {\n //↓playerに読み込んだmp3ファイルへのパスを設定する\n player = try AVAudioPlayer(contentsOfURL:url!)\n } catch _ {\n player = nil\n }\n player?.numberOfLoops = -1 //BGMを無限にループさせる\n player?.prepareToPlay() //音声を即時再生させる。\n player?.play() //音を再生する\n }\n \n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n //bgm\n // Do any additional setup after loading the view, typically from a nib.\n //playメソッドの呼び出し。引数はファイル名。\n play(\"bgm1.mp3\")\n \n \n let scene = GameScene(size:CGSize(width: 750, height: 1334))\n let skView = self.view as! SKView\n scene.scaleMode = .AspectFit\n skView.presentScene(scene)\n }\n \n override func shouldAutorotate() -> Bool {\n return true\n }\n \n override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {\n if UIDevice.currentDevice().userInterfaceIdiom == .Phone {\n return UIInterfaceOrientationMask.AllButUpsideDown\n } else {\n return UIInterfaceOrientationMask.All\n }\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Release any cached data, images, etc that aren't in use.\n }\n \n override func prefersStatusBarHidden() -> Bool {\n return true\n }\n }\n \n```\n\n・・・・・GameScene.swift\n\n```\n\n import SpriteKit\n import AVFoundation\n \n class GameScene: SKScene {\n // イラスト用スプライトを用意する\n let mySprite = SKSpriteNode(imageNamed: \"omikuji.png\")\n // ボタン用スプライトを用意する\n let btnSprite = SKSpriteNode(imageNamed: \"button.png\")\n // おみくじ結果用ラベルを用意する\n let myLabel = SKLabelNode(fontNamed: \"Verdana-bold\")\n \n override func didMoveToView(view: SKView) {\n \n \n \n // 背景色をつける\n self.backgroundColor = SKColor.whiteColor()\n // イラストを表示する\n mySprite.position = CGPoint(x: 375, y: 900)\n addChild(mySprite)\n // ボタンを表示する\n btnSprite.position = CGPoint(x:375, y:200)\n self.addChild(btnSprite)\n // おみくじ結果用ラベルを表示する\n myLabel.text = \"???\"\n myLabel.fontSize = 65\n myLabel.fontColor = SKColor.blackColor()\n myLabel.position = CGPoint(x:375, y:500)\n self.addChild(myLabel)\n }\n // タッチしたときの処理\n override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {\n for touch: AnyObject in touches {\n // タッチされた位置にあるものを調べて\n let location = touch.locationInNode(self)\n let touchNode = self.nodeAtPoint(location)\n // もし、ボタンなら\n if touchNode == btnSprite {\n \n //効果音がなった時、BGMは停止しない\n \n \n // 効果音データの作成.\n let mySoundAction: SKAction = SKAction.playSoundFileNamed(\"hit.wav\", waitForCompletion: true)\n // 再生アクション.\n self.runAction(mySoundAction);\n \n // ???と表示してから、おみくじを振る\n myLabel.text = \"???\"\n shakeOmikuji()\n }\n }\n }\n // おみくじを振る処理\n func shakeOmikuji() {\n \n //BGMサンプル1再生停止\n //ここでBGMをサンプル2に切り替えたい\n \n \n // 【おみくじを振るアクションをつける】\n // おみくじを少し右に傾けるアクション\n let action1 = SKAction.rotateToAngle(-0.3, duration: 0.2)\n // おみくじを少し左に傾けるアクション\n let action2 = SKAction.rotateToAngle( 0.3, duration: 0.2)\n // おみくじをひっくり返すアクション\n let action3 = SKAction.rotateToAngle( 3.14, duration: 0.2)\n // action1,action2,action3を指定した順番に行う\n let actionS = SKAction.sequence(\n [action1, action2, action1, action2, action1, action3])\n \n // おみくじに「左右に振ってひっくり返すアクション」をつけて、最後にkekkaを実行する\n mySprite.runAction(actionS, completion: showOmikuji)\n }\n // 結果を表示する処理\n func showOmikuji() {\n var omikuji = [\"大吉\",\"中吉\",\"吉\",\"凶\"]\n let r = Int(arc4random_uniform(4))\n myLabel.text = omikuji[r]\n }\n \n override func update(currentTime: CFTimeInterval) {\n }\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-06T23:58:45.427", "favorite_count": 0, "id": "12101", "last_activity_date": "2015-07-07T16:44:59.093", "last_edit_date": "2015-07-07T06:27:49.433", "last_editor_user_id": "7362", "owner_user_id": "10353", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "XcodeでAVFoundationを使いBGMを切り替える方法を教えてください", "view_count": 1778 }
[ { "body": "どんなきっかけでBGMの変更がしたいですか? \nそれにより追加するコードが変わります。 \n例えば、ボタンのタップでBGMが変更される。などです。 \n単純に音楽を変えたい場合は、AVAudioPlayerをstop()して、再度パス指定をしてprepareToPlay()をすれば変更できます。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-07T06:43:06.970", "id": "12111", "last_activity_date": "2015-07-07T06:43:06.970", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8772", "parent_id": "12101", "post_type": "answer", "score": 1 }, { "body": "以下、一本指タップで、BGMが変わり、二本指(以上)タップで、BGM再生を止めたり再開するプログラムです。\n\n```\n\n import UIKit\n import SpriteKit\n import AVFoundation\n \n class GameScene: SKScene {\n \n private var southernURL: NSURL!\n private var happyURL: NSURL!\n var currentBGM: AVAudioPlayer!\n \n override init(size: CGSize) {\n super.init(size: size)\n \n self.backgroundColor = UIColor.yellowColor()\n }\n \n required init?(coder aDecoder: NSCoder) {\n fatalError(\"init(coder:) has not been implemented\")\n }\n \n override func didMoveToView(view: SKView) {\n super.didMoveToView(view)\n \n let bndl = NSBundle.mainBundle()\n southernURL = bndl.URLForResource(\"southern\", withExtension: \"m4a\")\n happyURL = bndl.URLForResource(\"happy\", withExtension: \"m4a\")\n \n currentBGM = AVAudioPlayer(contentsOfURL: southernURL, error: nil)\n currentBGM.numberOfLoops = -1\n currentBGM.play()\n }\n \n override func willMoveFromView(view: SKView) {\n super.willMoveFromView(view)\n \n if currentBGM.playing == true {\n currentBGM.stop()\n }\n }\n \n override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {\n if touches.count < 2 { // 一本指タップなら\n changeBGM()\n } else { // 二本指以上なら\n pauseBGM()\n }\n }\n \n func changeBGM() {\n if currentBGM.playing {\n currentBGM.stop()\n if currentBGM.url == southernURL {\n currentBGM = AVAudioPlayer(contentsOfURL: happyURL, error: nil)\n } else {\n currentBGM = AVAudioPlayer(contentsOfURL: southernURL, error: nil)\n }\n currentBGM.numberOfLoops = -1\n currentBGM.play()\n }\n }\n \n func pauseBGM() {\n if currentBGM.playing {\n currentBGM.pause() // pause()なら、サウンドファイルとのつながりが切れない。そして再開時、停止したところから始まる。\n } else {\n currentBGM.play()\n }\n }\n \n }\n \n```\n\n確実にnilにならないことが保証されているケースでは、インスタンス変数をOptional(?)ではなく、Inplicitly Unwrapped\nOptional(!)にすることができます。なお、「確実にnilにならない保証」をするのは、プログラマ自身です。\n\n`NSBundle`の`URLForResource()`などは、リソースファイルの取得に失敗すると、`nil`を返します。なので、swift2.0の例外処理を使う必要はありません。今回は、「プログラマの責任」で、まちがいなくサウンドファイルがある前提で、Inplicitly\nUnwrapped Optional(!)としましたが、サウンドファイル取得を失敗した時のケースを考慮するなら、Optional\nBinding等を使って、変数の内容が`nil`かそうでないかで条件分岐してください。\n\n再生開始時のタイムラグ(遅延)を気にしなければ、`prepareToPlay()`メソッドは呼ぶ必要はありません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-07T12:05:51.467", "id": "12122", "last_activity_date": "2015-07-07T16:44:59.093", "last_edit_date": "2015-07-07T16:44:59.093", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "12101", "post_type": "answer", "score": 0 } ]
12101
null
12111
{ "accepted_answer_id": "12232", "answer_count": 1, "body": "Djangoのアプリを作っていて、Bootstrapを使いたかったのですが、読み込んでくれません。 \nログは以下のように出ます。\n\n```\n\n [07/Jul/2015 09:10:52]\"GET /static/css/bootstrap-theme.min.css HTTP/1.1\" 404 1694\n [07/Jul/2015 09:10:52]\"GET /static/css/bootstrap.min.css HTTP/1.1\" 404 1676\n [07/Jul/2015 09:10:52]\"GET /static/js/iquery-1.11.3.min.js HTTP/1.1\" 404 1682\n [07/Jul/2015 09:10:52]\"GET /static/js/bootstrap.min.js HTTP/1.1\" 404 1670\n \n```\n\nSettings.pyは以下のようになっています。\n\n```\n\n BASE_DIR = os.path.dirname(os.path.dirname(__file__))\n \n TEMPLATES = [\n {\n 'BACKEND': 'django.template.backends.django.DjangoTemplates',\n 'DIRS': [os.path.join(BASE_DIR, 'templates')],\n 'APP_DIRS': True,\n 'OPTIONS': {\n 'context_processors': [\n 'django.template.context_processors.debug',\n 'django.template.context_processors.request',\n 'django.contrib.auth.context_processors.auth',\n 'django.contrib.messages.context_processors.messages',\n 'social.apps.django_app.context_processors.backends',\n 'social.apps.django_app.context_processors.login_redirect'\n ],\n },\n },\n ]\n \n STATIC_ROOT = 'staticfiles'\n STATIC_URL = '/static/'\n \n STATICFILES_DIR = (\n os.path.join(BASE_DIR, \"static\"),\n )\n \n```\n\nディレクトリ構成は以下のようになっています。\n\n```\n\n Project\n |\n |-project_name\n | |-settings.py\n | |-urls.py\n | |-db.sqlite3\n | |....\n |\n |-app_name1\n | |-templates\n | | |-app_name1\n | | | |-template-extend-no-nav-base.html\n | | |-no-nav-base.html\n | |-views.py\n | |-urls.py\n | |-admin.py\n |\n |-app_name2\n | |...\n |\n |-static\n | |\n | |-js\n | | |-bootstrap.min.js\n | | |-bootstrap-theme.js\n | |-css\n | | |-bootstrap.min.css\n | |-fonts\n |\n |-templates\n | |-base.html\n \n```\n\n上のディレクトリ構成の`template-extend-no-nav-\nbase.html`を表示してみたのですが、botstrapが上のエラー(404)で適用されませんでした。以下に、no-nav-\nbase.htmlとtemplate-extend-no-nav-base.htmlを示します。\n\n```\n\n #no-nav-base.html\n \n {% load staticfiles %}\n <html lang=\"ja\">\n <head>\n <meta charset=\"utf-8\">\n <title>{% block title %}Title{% endblock %}</title>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <link href=\"{% static 'css/bootstrap.min.css' %}\" rel=\"stylesheet\">\n <link href=\"{% static 'css/bootstrap-theme.min.css' %}\" rel=\"stylesheet\">\n {% block extrahead %}{% endblock %}\n </head>\n <body>\n <div class=\"container-fluid\">\n {%block content %}\n {{ content }}\n {% endblock %}\n </div>\n \n <script src=\"{% static 'js/iquery-1.11.3.min.js' %}\"></script>\n <script src=\"{% static 'js/bootstrap.min.js' %}\"></script>\n </body>\n </html>\n \n```\n\n```\n\n #template-extend-no-nav-base.html\n \n {% extends \"no-nav-base.html\" %}\n {% block content %}\n <div class=\"jumbotron\">\n <h1>title</h1>\n <div class=\"row\">\n <div class=\"col-sm-5\">\n <p>ログインしてください。</p>\n <a href=\"{% url 'social:begin' 'twitter' %}\">Twitterログイン</a>\n </div>\n </div>\n </div>\n {% endblock %}\n \n```\n\nファイル名などは実際の名前とは一部変えているので間違いがあるかもしれません。どこが間違っているのかわかりましたら、教えていただけると幸いです。よろしくおねがいします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-07T00:38:39.847", "favorite_count": 0, "id": "12102", "last_activity_date": "2015-07-10T00:00:22.290", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "post_type": "question", "score": 0, "tags": [ "python", "django", "bootstrap" ], "title": "DjangoでBootstrapがロードされない。", "view_count": 3826 }
[ { "body": "STATICFILES_DIRS が STATICFILES_DIRになっていました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-10T00:00:22.290", "id": "12232", "last_activity_date": "2015-07-10T00:00:22.290", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "parent_id": "12102", "post_type": "answer", "score": 1 } ]
12102
12232
12232