question
dict
answers
list
id
stringlengths
2
5
accepted_answer_id
stringlengths
2
5
popular_answer_id
stringlengths
2
5
{ "accepted_answer_id": null, "answer_count": 0, "body": "Rails4で作成したアプリをHerokuにデプロイすると、CSSが効かなくなります。\n\nデプロイした時はCSSが効いていても、数時間後あるいは翌日にアクセスするとCSSが効かなくなっています。これはどういうことなのでしょうか?ずっとこのような事態が続いています。\n\nまた効かないといっても完全に効かないというわけではなさそうです(99.5%のCSSは効いていませんが)。キャッシュの問題なのですかね?一部背景色が適用されている部分があります。\n\n当方プログラミングには素人でわからないことだらけなのですが、どなたか対処法をご教授いただけますと幸いです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T06:21:45.833", "favorite_count": 0, "id": "11602", "last_activity_date": "2015-06-22T06:21:45.833", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10243", "post_type": "question", "score": 3, "tags": [ "ruby-on-rails", "html", "css", "heroku" ], "title": "Rails アプリのCSSが効かなくなります。", "view_count": 349 }
[]
11602
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "よくある画面で、入力フォームで入力したデータを<送信>ボタンにより送信したいのですが、実機でデバックすると、「ネットワークエラーが発生しました。(file:///data/data/mobi.monaca.debugger/file/projects/cloud/・・・/www/mail.php)」というエラーメッセージが出ます。何か設定したりするところは、ありますか?無料版ではできませんか? \n(以下コード)\n\n```\n\n <!DOCTYPE HTML>\n <html lang=\"ja\">\n <meta charset=\"UTF-8\">\n <body>\n <form action=\"mail.php\" method=\"post\">\n <p><label>名前:<input type=\"text\" name=\"name\" size=\"40\"></label></p>\n <p><label>コメント:<br><textarea name=\"comments\" rows=\"2\" cols=\"40\"></textarea></label></p>\n <p><input type=\"submit\" value=\"送信\"><input type=\"reset\" value=\"リセット\"></p>\n </form>\n </body>\n </html>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T07:58:24.613", "favorite_count": 0, "id": "11604", "last_activity_date": "2015-07-29T07:31:46.027", "last_edit_date": "2015-07-29T07:31:46.027", "last_editor_user_id": "49", "owner_user_id": "10244", "post_type": "question", "score": 1, "tags": [ "monaca", "html5" ], "title": "<送信>ボタンで、入力フォームのデータをサーバー(または、メール)に送信したいがエラーになる", "view_count": 1521 }
[ { "body": "action 属性が相対URLで指定されているため、デバッガ上の `mail.php` に送信しようとしています。\n\n`mail.php` が置かれた場所にアップロードすれば動作すると思いますが、デバッガ上で動かしたいのであれば、 action 属性を\n`http://hogehoge.com/mail.php` のように絶対URLで指定する必要があります。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T12:41:25.133", "id": "11615", "last_activity_date": "2015-06-22T12:41:25.133", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "11604", "post_type": "answer", "score": 1 } ]
11604
null
11615
{ "accepted_answer_id": "11608", "answer_count": 1, "body": "IE8で動作させていたものを、IE11でも動作するように改修しています。\n\nASPにてDBへアクセスし取得した内容をXMLとして出力し、 \nリスト形式で表示するためにXSLを使用しています。 \nリストの動的ソートを行うためそのXSLからJavascriptを呼出しているのですが\n\n```\n\n var objXml = document.XMLDocument;\n var objXsl = document.XSLDocument;\n \n```\n\n上記コードで各内容がundefinedとなってしまいました。\n\nそれぞれの内容を取得する方法、 \nもしくはXMLの内容を動的ソートさせる方法があれば教えてください。\n\n* * *\n\n追記\n\n```\n\n document.implementation.createDocument\n \n```\n\n上記コードでXMLDocumentは代替できましたが、XSLDocumentの実装方法がまだわかりません。 \nxsl:sortのみの実装では難しそうです。\n\n* * *\n\n追記2 \n実装は難しそうなので、今回はなしになりました。 \nありがとうございました。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T08:52:56.080", "favorite_count": 0, "id": "11607", "last_activity_date": "2015-06-24T10:21:06.327", "last_edit_date": "2015-06-24T10:21:06.327", "last_editor_user_id": "8000", "owner_user_id": "10246", "post_type": "question", "score": 1, "tags": [ "javascript", "xml", "internet-explorer", "xsl" ], "title": "IE11で document.XMLDocument や document.XSLDocument を使いたい", "view_count": 587 }
[ { "body": "[XMLDocument property](https://msdn.microsoft.com/en-\nus/library/ms535155\\(v=vs.85\\).aspx)(のサンプルコード内のコメント)によると\n\n> XML islands are not supported in Internet Explorer 9 and later.\n\nです。具体的には[XML data islands are no longer\nsupported](https://msdn.microsoft.com/en-\nus/library/hh801224\\(v=vs.85\\).aspx)によるとIE10で削除されたとのことです。\n\nとりあえず[MozillaでのXML\nデータアイランドの利用](https://developer.mozilla.org/ja/docs/Using_XML_Data_Islands_in_Mozilla)というドキュメントがありました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T09:09:51.383", "id": "11608", "last_activity_date": "2015-06-22T09:09:51.383", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "11607", "post_type": "answer", "score": 3 } ]
11607
11608
11608
{ "accepted_answer_id": "11612", "answer_count": 3, "body": "C++初心者です。 \n今までJava主体だったので、参照関係の知識は最低限(プリミティブかそうでないか)程度の認識しかありませんでした。 \nPHPも少し触っていたので参照はわかりますが、ポインタがどうも理解しきれません。\n\n参照 = 変数のアドレス \nポインタ = 変数のアドレスの値、つまり参照の値ということでいいんでしょうか?\n\nまた、上と仮定した時、ダブルポインタが配列になる意味が納得できません。 \nlistとか、vectorのポインタはどうなるんですか? \nchar **argv がcharの連想配列、 \nchar *argv[]がchar配列の配列 = stringの配列 \nとなるのであれば、 \nlist *arrayは「string型リスト」の配列にはなりませんよね? \ncharはプリミティブだから扱いが違うという話なんでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T09:50:01.920", "favorite_count": 0, "id": "11609", "last_activity_date": "2017-07-25T01:37:46.397", "last_edit_date": "2017-07-25T01:37:46.397", "last_editor_user_id": "76", "owner_user_id": "8396", "post_type": "question", "score": 2, "tags": [ "c++", "ポインタ" ], "title": "ポインタについて", "view_count": 768 }
[ { "body": "`char *argv[]` は、`char *` の配列を意味します(関数の引数の場合実際はポインタ(`char**argv`))。「char\n配列の配列」ではありません。 \n`char **argv` は、`char *` へのポインタを意味します。「charの連想配列」ではありません。 \n`argv`が`char *`の配列の最初を要素を指している時、 \n配列のそれぞれの要素(つまりchar へのポインタ)を`argv[インデックス]`でアクセスできるという意味で同じです。\n\nポインタは単純に最初の要素を指していて`[ ]`演算によって配列と同じようにアクセスできます。 \nもちろんその場合要素は並びになっている必要があります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T10:03:43.343", "id": "11612", "last_activity_date": "2015-06-22T10:03:43.343", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "11609", "post_type": "answer", "score": 5 }, { "body": "ポインタは、アドレスを入れるための「変数」です。 \n参照は、ある変数の別名(エイリアス)と考えるとわかりやすいです。 \nダブルポインタ(foo_t**)とは、ポインタ変数のアドレスを入れるための変数です。\n\nchar**は、char*型の変数のアドレスを格納するための変数です。\n\nchar* argv[]は、char*型の変数の配列です。\n\nポインタ変数で配列を保持できることを思い出すと、両者が同じように使えることが理解できます。 \n(この使い方では同じ用に使えますが、実際のメモリ上にどのようにデータが置かれるかを考えると、まったく異なるものであることも理解できるでしょう)\n\nlist* array; は、list型変数のアドレスを入れるための変数です。 \nなので、list型配列を宣言して、この変数に代入すると配列であるかのように扱えます。\n\n```\n\n list* array;\n list array_body[10];\n array = array_body;\n array[5] = xxx; // array_body[5]に対する操作と等価\n \n```\n\nなお、char* argv[]; と char *argv[]; は単に流儀の違いですので同じ意味です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T07:56:33.030", "id": "11673", "last_activity_date": "2015-06-24T07:56:33.030", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10272", "parent_id": "11609", "post_type": "answer", "score": 2 }, { "body": "C言語は厳密な意味では文字列型はありません。 \nchar型の配列を文字列と見なしているだけです。(文字列は値0の「文字」'\\0'を最後に追加するのが普通。単なるchar型の配列と見る場合はその限りではないです。)\n\n配列とポインタはC言語でも異なったものですが、関数の引数として配列を与えた場合、それは配列の先頭アドレスしか関数には渡りません(配列の長さも関数にわたらないことに注意してください)。\n\n従って、「関数の仮引数では」 char *argv[] とchar **argv が同じ意味になってしまいます。\n\nargvは事実上は「(コマンドラインの)文字列の配列」を表しているがmain関数に渡されるのはその先頭ポインタだということです。argcがあるのはjavaと違って配列の長さは自動的には関数にわたらないからです。\n\n関数の中で変数を宣言するときは、 \nchar a[100]; \nchar *b; \nでは、sizeof(a) は100になりますが、sizeof(b)\nはchar型のポインタのサイズになります。このような使い方の場合は配列とポインタは別物になります。C言語ではこの場合はa,bが初期化されていないのでよい例ではありません。\n\nちなみに、C/C++では argvの中身は書き換え可能となっているので取り扱いには注意が必要です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-07-24T16:35:31.067", "id": "36638", "last_activity_date": "2017-07-24T16:35:31.067", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24517", "parent_id": "11609", "post_type": "answer", "score": 0 } ]
11609
11612
11612
{ "accepted_answer_id": null, "answer_count": 2, "body": "SSL対応済のページから外部の非保護コンテンツ(CSSファイルやjsファイルなど)を呼びこむには、非保護コンテンツを内部ファイルとして保存して読み込む以外に方法はないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T09:50:20.713", "favorite_count": 0, "id": "11610", "last_activity_date": "2015-06-23T08:55:34.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10247", "post_type": "question", "score": 1, "tags": [ "ssl" ], "title": "外部の非保護コンテンツの読み込みについて", "view_count": 3061 }
[ { "body": "まず、 HTTPS でアクセスしたサイトから HTTP のリソースを読み込めない技術的な理由はありません。\n\nしかし「HTTPS のサイトでは全ての通信が HTTPS\nで行われるだろう」とユーザーは期待しますから、それに反して安全でない通信が行われるという理由で、ブラウザが警告を表示したりブロックしたりします。\n\nよって、 **全てのリソースを HTTPS で読み込む** ことがポイントになります。\n\n具体的にはその外部リソースに HTTPS でアクセスできるようにするか、 HTTPS でアクセスできる場所( HTML\nと同じ場所など)に移動させるか、どちらかでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-22T12:36:37.493", "id": "11614", "last_activity_date": "2015-06-22T12:36:37.493", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "11610", "post_type": "answer", "score": 2 }, { "body": "同じドメイン上のファイルであれば同じhttps(ssl)プロトコルで読み込めます。 \nもし別のドメインのサーバーのhttp(非ssl)のリソースを埋め込むということであれば \nブラウザの警告は出ますが、許可をしたら画像とCSS「だけ」は表示できます。 \nJSはドメインが違うとセキュリティ上の制限が掛かります。\n\n回避する手段は幾つか有ります。 \n・リソースファイルを同一サーバーにコピーする \n・リソースのあるサーバーのストレージを設置したいサーバーに \nマウントしてエリアスを設定する。(同じサーバー内で実ファイルが内部で見えていればエリアス設定だけでも可能) \n・サーバー上に対象となるリソースファイルへのリバースプロキシを設定する。 \n※相手によってはセキュリティに穴が出来る場合があるので、相手先が信頼できる事が必須です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T08:55:34.467", "id": "11638", "last_activity_date": "2015-06-23T08:55:34.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9262", "parent_id": "11610", "post_type": "answer", "score": 1 } ]
11610
null
11614
{ "accepted_answer_id": "11627", "answer_count": 2, "body": "AngularJSを使って以下のようにラジオボタンを動的に配置したのですが、1つのラジオボタンを押すとすべてのラジオボタンが選択状態になってしまい困っています。どこが間違っているのか教えて下さい。よろしくおねがいします。\n\n```\n\n 271 $scope.satisfactions=[];\n 272 for(var i=1; i<6; i++){\n 273 $scope.satisfactions.push(i);\n 274 }\n \n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js\"></script>\n 28 <div class=\"form-group\">\n 29 <label for=\"satisfaction\" class=\"control-label col-sm-3 col-xs-12\" class=\"fontrol-label\">満足度</label>\n 30 <div ng-repeat=\"satisfaction in satisfactions\" class=\"checkbox-inline\">\n 31 <label for=\"satisfaction{{satisfaction}}\">\n 32 <input type=\"radio\" id=\"satisfaction_{{satisfaction}}\" name=\"satisfaction_{{satisfaction}}\" ng-model=\"$parent.inquery.satisfaction\" value=\"$index\"/> {{satisfaction}}\n 33 </label>\n 34 </div>\n 35 </div>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T00:05:12.987", "favorite_count": 0, "id": "11620", "last_activity_date": "2015-06-23T02:44:07.110", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "html", "angularjs" ], "title": "ラジオボタンを押すとすべての選択肢が変わってしまう。", "view_count": 1244 }
[ { "body": "ラジオボタンの`value`が同じ値になっているのが原因ではないかと思います。 \n`value`にindexを設定するのであれば、こんな感じに変更してみてください。\n\n```\n\n <div class=\"form-group\">\n <label for=\"satisfaction\" class=\"control-label col-sm-3 col-xs-12\" class=\"fontrol-label\">満足度</label>\n <div ng-repeat=\"(index, satisfaction) in satisfactions\" class=\"checkbox-inline\">\n <label for=\"satisfaction{{satisfaction}}\">\n <input type=\"radio\" id=\"satisfaction_{{satisfaction}}\" name=\"satisfaction_{{satisfaction}}\" ng-model=\"$parent.inquery.satisfaction\" value=\"{{index}}\"/> {{satisfaction}}\n </label>\n </div>\n </div>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T01:57:05.200", "id": "11625", "last_activity_date": "2015-06-23T01:57:05.200", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3516", "parent_id": "11620", "post_type": "answer", "score": 1 }, { "body": "`$index`は0から始まるので値がズレませんか?\n\nAngularJSでラジオボタンを使うときは、ng-modelに同じ値を指定してvalueもしくはng-valueで値を設定すると良いと思います。\n\n```\n\n $scope.satisfactions=[];\n for(var i=1; i<6; i++){\n $scope.satisfactions.push(i);\n }\n $scope.select_satisfaction=1;\n \n```\n\n・・・\n\n```\n\n <label><input type=\"radio\" ng-model=\"$parent.select_satisfaction\" ng-value=\"satisfaction\"> {{satisfaction}}</label>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T02:44:07.110", "id": "11627", "last_activity_date": "2015-06-23T02:44:07.110", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2232", "parent_id": "11620", "post_type": "answer", "score": 1 } ]
11620
11627
11625
{ "accepted_answer_id": "11623", "answer_count": 3, "body": "**Wikiページのように長いURLを、MySQLのVARCHAR( 255 ) に格納したら途中で切れてしまいました** \n・とりあえずTEXT型カラムへ変更して格納しましたが、通常は何のデータ型カラムに格納するものなのでしょうか?\n\n・VARCHAR( 255 )と、TINYTEXTは同じ? \n・TEXT型はバイト数指定した方が良い? \n・BLOB型?\n\n**知りたいこと** \n・それぞれのデータ型のメリットデメリット \n・バイト数を指定するメリットデメリット", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T00:26:40.990", "favorite_count": 0, "id": "11621", "last_activity_date": "2015-06-23T09:05:28.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 2, "tags": [ "mysql" ], "title": "WikiページURLを、VARCHAR( 255 ) に格納しようとするも途中までしか格納されない", "view_count": 7914 }
[ { "body": "> ・とりあえずTEXT型カラムへ変更して格納しましたが、通常は何のデータ型カラムに格納するものなのでしょうか?\n\nHTTP/1.1 の仕様を定めた RFC 2616 では、URIの長さは制限がないことになっています。 \n<http://www.spencernetwork.org/reference/rfc2616-ja-HTTP1.1.txt>\n\nとはいえ無限の容量を持つ型はありませんので、「ほぼほぼカバーできるだろう」という長さにしておいた方がよさそうです。\n\n通常がどうなのかはちょっとわかりませんが、私なら VARCHAR(8190) くらいにするでしょうか。Apache\nが受け付けられるURLの長さがデフォルト8190バイトなので。 \n<http://httpd.apache.org/docs/2.4/mod/core.html#limitrequestline>\n\nなお、どの程度の長さのURLが許容されるかというのはブラウザにも依存するので、これが正解というのはなかなか難しいです。不安であればVARCHARの最大値(65,535)でもいいのではないでしょうか。\n\n> ・VARCHAR( 255 )と、TINYTEXTは同じ?\n\n型が違うので同じではないですが、データ記録時に必要となる容量は同じ(指定された文字列値のバイト数+1)ようです。 \n<http://mysql.stu.edu.tw/doc/refman/5.1-olh/ja/storage-requirements.html>\n\n> ・TEXT型はバイト数指定した方が良い?\n\n指定できないような?\n\n> ・BLOB型?\n\nバイナリデータ(画像、音楽、動画、など)を格納するための型です。 \n<http://mysql.stu.edu.tw/doc/refman/5.1-olh/ja/blob.html>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T01:02:15.730", "id": "11623", "last_activity_date": "2015-06-23T01:14:20.447", "last_edit_date": "2015-06-23T01:14:20.447", "last_editor_user_id": "76", "owner_user_id": "9801", "parent_id": "11621", "post_type": "answer", "score": 2 }, { "body": "VARCHAR と TEXT の違いなら昔下記のような記事を書きました\n\n[VARCHAR と ~TEXT の違い - ngの日記](http://ngyuki.hatenablog.com/entry/20110804/p1\n\"VARCHAR と 〜TEXT の違い - ngの日記\")\n\nVARCHAR で指定するものは『文字数』 \nTEXT は型ごとに『バイト数』が決まってます", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T05:26:23.340", "id": "11629", "last_activity_date": "2015-06-23T05:26:23.340", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2494", "parent_id": "11621", "post_type": "answer", "score": 1 }, { "body": "現在URLの長さ制限に関する規定は取り決められていません。\n\nRFC 7230~7237に置き換えられる前の RFC 2616(Hypertext Transfer Protocol -- HTTP/1.1) \n<http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2.1> \nここでは無制限とした後で注意書きとして古いブラウザ対応の為に255以下推奨としてありますが、 \n置き換えられた後は255以下の記述がありません。 \n(昔は某ブラウザの対応が255迄だったのです。)\n\nサーバー側の受け付ける長さは設定で無制限に変更できるので \nブラウザ側を参考にしてみてはどうでしょうか?\n\n<https://support.microsoft.com/ja-jp/kb/208427/ja> \n<http://logicalerror.seesaa.net/article/383427331.html> \n制限の厳しいIEは最大2,083文字です。 \nWEB関係の制作でIEの対応を無視するとは考え難いのでこれを参考値として \n文字コードやURLエンコードの差分を考慮して決めれば良いかと思います。\n\n型についてはこの辺りを参照してみてください。 \n<http://ftp.stu.edu.tw/Unix/Database/Mysql/doc/refman/5.1-olh/ja/blob.html> \n<http://ftp.stu.edu.tw/Unix/Database/Mysql/doc/refman/5.1-olh/ja/string-\ntypes.html> \n<http://www.dbonline.jp/mysql/type/>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T09:05:28.590", "id": "11639", "last_activity_date": "2015-06-23T09:05:28.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9262", "parent_id": "11621", "post_type": "answer", "score": 1 } ]
11621
11623
11623
{ "accepted_answer_id": null, "answer_count": 0, "body": "Ubuntu 14.04でL2TP/IPsecのVPN接続をl2tp-ipsec-vpnでしているのですが、うまくいきません\n\n[Linux から L2TP/IPsec で VPN](http://blog.hktechno.net/2013/02/linux-l2tpipsec-\nvpn.html) \nを見て設定しました\n\nVPNのサーバーへはWindowsやAndroidからはつながるのですが、Ubuntuだけつながりません\n\nインストールされてるバージョンです \nl2tp-ipsec-vpn: 1.0.9-1 \nopenswan: 1:2.6.38-1 \nppp: 2.4.5-5.1ubuntu2.2\n\nログは以下の通りです \n接続先のIPをxx.xx.xx.xxに置き換えています\n\nsyslog\n\n```\n\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Opening client connection\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Opening client connection\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Closing client connection\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Executing command ipsec setup start\n Jun 23 09:18:50 user-x240 kernel: [ 5120.551126] NET: Registered protocol family 15\n Jun 23 09:18:50 user-x240 ipsec_setup: Starting Openswan IPsec U2.6.38/K3.13.0-55-generic...\n Jun 23 09:18:50 user-x240 ipsec_setup: Using NETKEY(XFRM) stack\n Jun 23 09:18:50 user-x240 kernel: [ 5120.645493] Initializing XFRM netlink socket\n Jun 23 09:18:50 user-x240 ipsec_setup: ...Openswan IPsec started\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Command ipsec setup start finished with exit code 0\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Executing command service xl2tpd start\n Jun 23 09:18:50 user-x240 pluto: adjusting ipsec.d to /etc/ipsec.d\n Jun 23 09:18:50 user-x240 ipsec__plutorun: adjusting ipsec.d to /etc/ipsec.d\n Jun 23 09:18:50 user-x240 xl2tpd[31680]: setsockopt recvref[30]: Protocol not available\n Jun 23 09:18:50 user-x240 xl2tpd[31680]: This binary does not support kernel L2TP.\n Jun 23 09:18:50 user-x240 xl2tpd[31683]: xl2tpd version xl2tpd-1.3.6 started on user-x240 PID:31683\n Jun 23 09:18:50 user-x240 xl2tpd[31683]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.\n Jun 23 09:18:50 user-x240 xl2tpd[31683]: Forked by Scott Balmos and David Stipp, (C) 2001\n Jun 23 09:18:50 user-x240 xl2tpd[31683]: Inherited by Jeff McAdams, (C) 2002\n Jun 23 09:18:50 user-x240 xl2tpd[31683]: Forked again by Xelerance (www.xelerance.com) (C) 2006\n Jun 23 09:18:50 user-x240 xl2tpd[31683]: Listening on IP address 0.0.0.0, port 1701\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Command service xl2tpd start finished with exit code 0\n Jun 23 09:18:50 user-x240 ipsec__plutorun: 002 added connection description \"vpntest\"\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Executing command ipsec auto --ready\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Command ipsec auto --ready finished with exit code 0\n Jun 23 09:18:50 user-x240 L2tpIPsecVpnControlDaemon: Executing command ipsec auto --up vpntest\n Jun 23 09:20:10 user-x240 L2tpIPsecVpnControlDaemon: Closing client connection\n Jun 23 09:20:10 user-x240 L2tpIPsecVpnControlDaemon: Command ipsec auto --up vpntest finished with error code 93\n Jun 23 09:20:10 user-x240 L2tpIPsecVpnControlDaemon: Command ipsec auto --up vpntest finished with exit code 0\n Jun 23 09:20:10 user-x240 L2tpIPsecVpnControlDaemon: Opening client connection\n Jun 23 09:20:10 user-x240 L2tpIPsecVpnControlDaemon: Executing command service xl2tpd stop\n Jun 23 09:20:10 user-x240 xl2tpd[31683]: death_handler: Fatal signal 15 received\n Jun 23 09:20:10 user-x240 L2tpIPsecVpnControlDaemon: Command service xl2tpd stop finished with exit code 0\n Jun 23 09:20:10 user-x240 L2tpIPsecVpnControlDaemon: Executing command ipsec setup stop\n Jun 23 09:20:10 user-x240 ipsec_setup: Stopping Openswan IPsec...\n Jun 23 09:20:11 user-x240 kernel: [ 5201.856486] NET: Unregistered protocol family 15\n Jun 23 09:20:11 user-x240 ipsec_setup: ...Openswan IPsec stopped\n Jun 23 09:20:11 user-x240 L2tpIPsecVpnControlDaemon: Command ipsec setup stop finished with exit code 0\n Jun 23 09:20:11 user-x240 L2tpIPsecVpnControlDaemon: Closing client connection\n \n```\n\nauth.log\n\n```\n\n Jun 23 09:18:50 user-x240 ipsec__plutorun: Starting Pluto subsystem...\n Jun 23 09:18:50 user-x240 pluto[31665]: Starting Pluto (Openswan Version 2.6.38; Vendor ID OEvy\\134kgzWq\\134s) pid:31665\n Jun 23 09:18:50 user-x240 pluto[31665]: LEAK_DETECTIVE support [disabled]\n Jun 23 09:18:50 user-x240 pluto[31665]: OCF support for IKE [disabled]\n Jun 23 09:18:50 user-x240 pluto[31665]: SAref support [disabled]: Protocol not available\n Jun 23 09:18:50 user-x240 pluto[31665]: SAbind support [disabled]: Protocol not available\n Jun 23 09:18:50 user-x240 pluto[31665]: NSS support [disabled]\n Jun 23 09:18:50 user-x240 pluto[31665]: HAVE_STATSD notification support not compiled in\n Jun 23 09:18:50 user-x240 pluto[31665]: Setting NAT-Traversal port-4500 floating to on\n Jun 23 09:18:50 user-x240 pluto[31665]: port floating activation criteria nat_t=1/port_float=1\n Jun 23 09:18:50 user-x240 pluto[31665]: NAT-Traversal support [enabled]\n Jun 23 09:18:50 user-x240 pluto[31665]: using /dev/urandom as source of random entropy\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_enc(): Activating OAKLEY_AES_CBC: Ok (ret=0)\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_hash(): Activating OAKLEY_SHA2_512: Ok (ret=0)\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_hash(): Activating OAKLEY_SHA2_256: Ok (ret=0)\n Jun 23 09:18:50 user-x240 pluto[31665]: starting up 3 cryptographic helpers\n Jun 23 09:18:50 user-x240 pluto[31665]: started helper pid=31671 (fd:6)\n Jun 23 09:18:50 user-x240 pluto[31665]: started helper pid=31672 (fd:7)\n Jun 23 09:18:50 user-x240 pluto[31671]: using /dev/urandom as source of random entropy\n Jun 23 09:18:50 user-x240 pluto[31665]: started helper pid=31673 (fd:8)\n Jun 23 09:18:50 user-x240 pluto[31665]: Using Linux 2.6 IPsec interface code on 3.13.0-55-generic (experimental code)\n Jun 23 09:18:50 user-x240 pluto[31672]: using /dev/urandom as source of random entropy\n Jun 23 09:18:50 user-x240 pluto[31673]: using /dev/urandom as source of random entropy\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_enc(): Activating aes_ccm_8: Ok (ret=0)\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_add(): ERROR: algo_type '0', algo_id '0', Algorithm type already exists\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_enc(): Activating aes_ccm_12: FAILED (ret=-17)\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_add(): ERROR: algo_type '0', algo_id '0', Algorithm type already exists\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_enc(): Activating aes_ccm_16: FAILED (ret=-17)\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_add(): ERROR: algo_type '0', algo_id '0', Algorithm type already exists\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_enc(): Activating aes_gcm_8: FAILED (ret=-17)\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_add(): ERROR: algo_type '0', algo_id '0', Algorithm type already exists\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_enc(): Activating aes_gcm_12: FAILED (ret=-17)\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_add(): ERROR: algo_type '0', algo_id '0', Algorithm type already exists\n Jun 23 09:18:50 user-x240 pluto[31665]: ike_alg_register_enc(): Activating aes_gcm_16: FAILED (ret=-17)\n Jun 23 09:18:50 user-x240 pluto[31665]: added connection description \"vpntest\"\n Jun 23 09:18:50 user-x240 pluto[31665]: listening for IKE messages\n Jun 23 09:18:50 user-x240 pluto[31665]: adding interface wlan0/wlan0 192.168.24.54:500\n Jun 23 09:18:50 user-x240 pluto[31665]: adding interface wlan0/wlan0 192.168.24.54:4500\n Jun 23 09:18:50 user-x240 pluto[31665]: adding interface lo/lo 127.0.0.1:500\n Jun 23 09:18:50 user-x240 pluto[31665]: adding interface lo/lo 127.0.0.1:4500\n Jun 23 09:18:50 user-x240 pluto[31665]: adding interface wlan0/wlan0 2001:a033:6c71:0:591e:8386:990a:5d43:500\n Jun 23 09:18:50 user-x240 pluto[31665]: adding interface wlan0/wlan0 2001:a033:6c71:0:eab1:fcff:feab:1aad:500\n Jun 23 09:18:50 user-x240 pluto[31665]: adding interface lo/lo ::1:500\n Jun 23 09:18:50 user-x240 pluto[31665]: loading secrets from \"/etc/ipsec.secrets\"\n Jun 23 09:18:50 user-x240 pluto[31665]: listening for IKE messages\n Jun 23 09:18:50 user-x240 pluto[31665]: forgetting secrets\n Jun 23 09:18:50 user-x240 pluto[31665]: loading secrets from \"/etc/ipsec.secrets\"\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: initiating Main Mode\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: received Vendor ID payload [RFC 3947] method set to=115 \n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: enabling possible NAT-traversal with method RFC 3947 (NAT-Traversal)\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: transition from state STATE_MAIN_I1 to state STATE_MAIN_I2\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: STATE_MAIN_I2: sent MI2, expecting MR2\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: NAT-Traversal: Result using draft-ietf-ipsec-nat-t-ike (MacOS X): i am NATed\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: transition from state STATE_MAIN_I2 to state STATE_MAIN_I3\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: STATE_MAIN_I3: sent MI3, expecting MR3\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: Main mode peer ID is ID_IPV4_ADDR: '192.168.100.1'\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: we require peer to have ID 'xx.xx.xx.xx', but peer declares '192.168.100.1'\n Jun 23 09:18:50 user-x240 pluto[31665]: \"vpntest\" #1: sending encrypted notification INVALID_ID_INFORMATION to xx.xx.xx.xx:4500\n Jun 23 09:20:10 user-x240 pluto[31665]: shutting down\n Jun 23 09:20:10 user-x240 pluto[31665]: forgetting secrets\n Jun 23 09:20:10 user-x240 pluto[31665]: \"vpntest\": deleting connection\n Jun 23 09:20:10 user-x240 pluto[31665]: \"vpntest\" #1: deleting state (STATE_MAIN_I3)\n Jun 23 09:20:10 user-x240 pluto[31665]: shutting down interface lo/lo ::1:500\n Jun 23 09:20:10 user-x240 pluto[31665]: shutting down interface wlan0/wlan0 2001:a033:6c71:0:eab1:fcff:feab:1aad:500\n Jun 23 09:20:10 user-x240 pluto[31665]: shutting down interface wlan0/wlan0 2001:a033:6c71:0:591e:8386:990a:5d43:500\n Jun 23 09:20:10 user-x240 pluto[31665]: shutting down interface lo/lo 127.0.0.1:4500\n Jun 23 09:20:10 user-x240 pluto[31665]: shutting down interface lo/lo 127.0.0.1:500\n Jun 23 09:20:10 user-x240 pluto[31665]: shutting down interface wlan0/wlan0 192.168.24.54:4500\n Jun 23 09:20:10 user-x240 pluto[31665]: shutting down interface wlan0/wlan0 192.168.24.54:500\n \n```\n\nいろいろ試したのですが、解決できてません \nなにか分かる方いらっしゃいませんでしょうか", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T00:38:36.333", "favorite_count": 0, "id": "11622", "last_activity_date": "2015-06-23T04:27:48.130", "last_edit_date": "2015-06-23T04:27:48.130", "last_editor_user_id": "3639", "owner_user_id": "10253", "post_type": "question", "score": 1, "tags": [ "network", "ubuntu" ], "title": "Ubuntu 14.04でL2TP/IPsecのVPN接続ができない", "view_count": 1875 }
[]
11622
null
null
{ "accepted_answer_id": "11634", "answer_count": 3, "body": "vimで以下のようにコマンドを入力すると設定が一覧で確認できるのですが、出力される結果が多すぎて見辛いと思っています。出力結果は何かページャーの様な感じで表示されるのですが、内容をキーワードで検索したり、絞り込んだりできないでしょうか?もしくは出力結果を何か便利なページャーに差替えて表示することは可能でしょうか?\n\n変数の確認\n\n```\n\n :let\n ...\n ... 変数の一覧\n ...\n \n```\n\nオプションの確認\n\n```\n\n :set\n ...\n ... 変数の一覧\n ...\n \n```\n\nマッピングの確認\n\n```\n\n :map\n ...\n ... 変数の一覧\n ...\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T05:47:12.257", "favorite_count": 0, "id": "11631", "last_activity_date": "2015-06-23T19:41:22.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10150", "post_type": "question", "score": 7, "tags": [ "vim" ], "title": "vimの設定確認で絞込や検索はできますか?", "view_count": 1082 }
[ { "body": "[capture.vim](https://github.com/tyru/capture.vim)\nを使うと、コマンドの結果をバッファに出力することができます。 \nインストールしたら、\n\n```\n\n :Capture let\n :Capture set\n :Capture map\n \n```\n\nなどでそれぞれ結果がバッファに出力されます。\n\n変数とマッピングについては、[unite.vim](https://github.com/Shougo/unite.vim)も使えます。 \n変数の場合は、\n\n```\n\n :Unite variable\n \n```\n\nマッピングの場合は、\n\n```\n\n :Unite mapping\n \n```\n\nとすると一覧を表示でき、絞り込みもできます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T05:57:53.933", "id": "11632", "last_activity_date": "2015-06-23T05:57:53.933", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2541", "parent_id": "11631", "post_type": "answer", "score": 2 }, { "body": "Vim標準セットでのコマンドラインの絞込み方法を`:set`の場合で説明します。\n\n```\n\n :set <C-D>\n \n```\n\n`:set`(後ろにスペースあり)と入力した後に`ctrl-d`を入力するとカーソルより前のパターンに一致するオプションを一覧表示します。(この場合は全オプションを一覧表示) \n一覧表示が画面に全部表示しきれない時は画面下に`\\-- 継続 --`(または`\\-- More\n--`)と表示され、スペースキーを押すことで続きが見れますし、`q`でキャンセルすることが出来ます。\n\n一覧表示をキャンセルしたあと、`a`を入力後に再度`ctrl-d`を入力してみてください。\n\n```\n\n :set a\n all arabic allowrevins ambiwidth autoindent autowrite\n aleph arabicshape altkeymap autochdir autoread autowriteall\n :set a\n \n```\n\n`a`から始まるオプションが一覧表示されました。ここまで絞り込めたらあとは`<Tab>`キーを押してオプション名を補完すれば楽に入力できます。\n\n`ctrl-d`と`<Tab>`のパターンには`*`も使えますので、たとえば「オプション名に`time`が含まれるものを一覧表示/補完したい」場合は\n\n```\n\n :set *time\n \n```\n\nと入力した後に`ctrl-d`や`<Tab>`を押します。 \n以下は`ctrl-d`を押した場合の表示です。\n\n```\n\n :set *time\n matchtime redrawtime timeout ttimeout updatetime\n mousetime runtimepath timeoutlen ttimeoutlen\n :set *time\n \n```\n\nちなみにパターンは`*time`ですがVimの内部で後ろに`*`を付加して`*time*`でマッチングしているので途中に`time`を含むオプション名も対象になっています。\n\n詳細はヘルプを参照下さい。この2つを知っているだけでだいぶ捗ります。 \n`:h c_ctrl-d` \n`:h c_<Tab>`\n\nもちろん、`:let`と`:map`の場合でも同様のことがおこなえます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T07:45:54.010", "id": "11634", "last_activity_date": "2015-06-23T19:41:22.810", "last_edit_date": "2015-06-23T19:41:22.810", "last_editor_user_id": "2687", "owner_user_id": "2687", "parent_id": "11631", "post_type": "answer", "score": 8 }, { "body": "redir を使うとコマンドの実行結果がリダイレクト出来ます。\n\n```\n\n :redir > file\n :set\n :redir END\n \n```\n\nこれで `file` に出力されます。`>>` で追記になります。`:redir @a` でレジスタ @a に結果が格納されます。 \n同様に`:redir => a` とすると変数 a に結果が出力されます。なので\n\n```\n\n :redir => a\n :silent map\n :redir END\n \n```\n\nとした後、新しいバッファ等で\n\n```\n\n :put =a\n \n```\n\nとする事でコマンドの実行結果が貼りつけられます。あとは絞り込むなり検索するなり自由にどうぞ。 \nthinca さんが紹介してくれている capture コマンドもこの仕組みで動いています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T08:21:26.490", "id": "11636", "last_activity_date": "2015-06-23T08:21:26.490", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "440", "parent_id": "11631", "post_type": "answer", "score": 4 } ]
11631
11634
11634
{ "accepted_answer_id": "11646", "answer_count": 1, "body": "Emacsで`(global-set-key \"\\C-w\" 'backward-kill-\nword)`とカーソルから左方向に一単語をkillする操作をRubyMineでも行いたいのですが該当する機能を見つけられませんでした。\n\nそのような操作をRubyMineで行う方法はありますか?\n\n## 追記\n\nRubyMineに対する要望としてReportしておきました。まだ誰にもAssignされていませんので、もし同じ機能を希望してる方がいましたら up\nvote よろしくお願いします。 \n<https://youtrack.jetbrains.com/issue/RUBY-16882>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T08:51:01.897", "favorite_count": 0, "id": "11637", "last_activity_date": "2015-08-12T07:02:01.333", "last_edit_date": "2015-08-12T07:02:01.333", "last_editor_user_id": "3271", "owner_user_id": "3271", "post_type": "question", "score": 1, "tags": [ "rubymine" ], "title": "Emacsのbackward-kill-word に当たる編集操作を RubyMine行う方法", "view_count": 81 }
[ { "body": "ALT(Option)+Backspace ではどうでしょうか? \n以下の参考サイトで'Word'で検索するといろいろ見つかります。\n\n参考サイト \n<https://www.jetbrains.com/ruby/help/basic-editing.html>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T12:23:06.263", "id": "11646", "last_activity_date": "2015-06-23T12:23:06.263", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10150", "parent_id": "11637", "post_type": "answer", "score": 1 } ]
11637
11646
11646
{ "accepted_answer_id": "11645", "answer_count": 1, "body": "Handler.post()へ受け渡すRunnableオブジェクトは、よく匿名クラスとして受け渡すように記述されている事が多いと思います。\n\n```\n\n mHandler.post(new Runnable() {\n @Override\n public void run() {\n \n }\n });\n \n```\n\nしかし例えば、この処理を呼び出す頻度が非常に高い場合、毎回新たにRunnableオブジェクトを作りたくありません。\n\nそこで以下のようにオブジェクトを使い回して、例えばtest1()が呼ばれた時とtest2()が呼ばれた時とで表示したい文字列だけを上書きするようにした場合、まだHandler側でまだ処理されていない文字列が上書きされて消えてしまう等の問題が発生するものでしょうか。 \nこのような使い方は正しいのでしょうか、教えて頂けると助かります。\n\n```\n\n private class TestRunnable implements Runnable {\n private String mMessage;\n \n public TestRunnable setStr(final String message) {\n mMessage = message;\n return this;\n }\n \n @Override\n public void run() {\n Log.d(\"Test\", \"Message:\" + mMessage);\n }\n }\n \n private Handler mHandler = new Handler();\n private TestRunnable mTestRunnable = new TestRunnable();\n \n public void test1(String msg) {\n mHandler.post(mTestRunnable.setStr(msg));\n }\n \n public void test2(String msg) {\n mHandler.post(mTestRunnable.setStr(msg));\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T09:07:20.737", "favorite_count": 0, "id": "11640", "last_activity_date": "2015-06-23T12:02:39.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4232", "post_type": "question", "score": 1, "tags": [ "android", "java" ], "title": "Handler.post()へ受け渡すRunnableオブジェクトを使い回しても良いでしょうか", "view_count": 4784 }
[ { "body": "OS としては大丈夫そうですが、例に上げられているそのソースコードでは意図通りに動かない可能性が高いです。\n\nまず「OS\nとしては大丈夫」とした根拠ですが、[Handler.javaのソースコード](https://android.googlesource.com/platform/frameworks/base/+/android-5.1.1_r4/core/java/android/os/Handler.java#324)\nを追うことでわかります。 細部は省略しますが、`Handler#post()` では引数の `Runnable` を `Message`\nでラップしてキューに追加します。よって仮に1つの `Runnable` インスタンスを複数回渡しても、それぞれが別の `Message`\nとして解釈され、呼び出されると推定できます。\n\nしかしながら例に上げられたコードでは、`test1()` 呼出し後に `mTestRunnable#run()` が実行される前に `test2()`\nが呼び出されてしまうと、`mTestRunnable#mMessage` が更新されてしまい、\n意図せぬ実行結果(同じメッセージ/テキストが2度処理される)になると推測されます。\n\n以上をまとめますと、`Handler#post()`\nには同じインスタンスを複数回渡すことができますが、だいたいの場合その「インスタンスが再入可能であること」が必須といえるでしょう。あと、どうしても再入不可能なまま再利用をするのであれば、オブジェクトプールを使うなどの手段も考えられます。なお\n`Message` はこのオブジェクトプールを使う実装になっていましたので、興味があれば一度読まれることをオススメしておきます。\n\n個人的には毎回作成することを推奨いたします。ヘタに凝るとわかりにくいバグになりそうですから。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T11:57:27.393", "id": "11645", "last_activity_date": "2015-06-23T12:02:39.253", "last_edit_date": "2015-06-23T12:02:39.253", "last_editor_user_id": "208", "owner_user_id": "208", "parent_id": "11640", "post_type": "answer", "score": 1 } ]
11640
11645
11645
{ "accepted_answer_id": "11643", "answer_count": 1, "body": "たとえばDateTimePickerのFormatをCustomにして \nCustomFormatをdd-MMM-yyに指定することで、 \n2015/6/23を \n23-Jun-15というように表示したいです。\n\n以下の記事のようにPCのコントロールパネルから環境を変更すれば \n上記を実現できるのですが、プログラム上で変更できないでしょうか? \n<https://social.msdn.microsoft.com/forums/vstudio/ja-\nJP/a3c0a8e1-7908-4706-b9f2-9bdb053d3648/datetimepicker>\n\nお知恵を拝借できれば幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T09:26:45.150", "favorite_count": 0, "id": "11641", "last_activity_date": "2015-06-23T11:14:37.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9228", "post_type": "question", "score": 0, "tags": [ "c#", "winforms" ], "title": "C# Form部品のDateTimePickerのCustomFormatのMMMを英語表記にできますか?", "view_count": 505 }
[ { "body": "サポート情報[KB889834](https://support.microsoft.com/en-\nus/kb/889834)によると`DateTimePicker`のカルチャはOSの設定のみを参照しているため変更不能のようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T11:14:37.590", "id": "11643", "last_activity_date": "2015-06-23T11:14:37.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "11641", "post_type": "answer", "score": 1 } ]
11641
11643
11643
{ "accepted_answer_id": null, "answer_count": 0, "body": "Smarty で JSON データを `json_decode` で配列にしてその要素数を取得しようとしています。\n\n想定する JSON データは以下の通りです。\n\n```\n\n $json_member = '\n [\n {\"userid\":\"0\",\"name\":\"Taro Yamada\",\"email\":\"taro@xxx.com\"},\n {\"userid\":\"1\",\"name\":\"Jiro Yamada\",\"email\":\"jiro@xxx.com\"},\n {\"userid\":\"2\",\"name\":\"Saburoh Yamada\",\"email\":\"saburoh@xxx.com\"},\n :\n ]';\n \n```\n\nSmarty で以下のコードで実行すると「0 名」になります。\n\n```\n\n { $json_member|@json_decode|@count|cat:' 名' }\n \n```\n\nググってみていろいろと試しているのですが、あるべき出力になりません。 \nもしご存知でしたらご教授のほどおねがいいたします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2015-06-23T10:13:15.560", "favorite_count": 0, "id": "11642", "last_activity_date": "2019-06-10T06:24:35.133", "last_edit_date": "2019-06-10T06:24:35.133", "last_editor_user_id": "2238", "owner_user_id": "9561", "post_type": "question", "score": 1, "tags": [ "smarty" ], "title": "Smartyでjson_decodeして要素数を取得する方法", "view_count": 1913 }
[]
11642
null
null
{ "accepted_answer_id": "11650", "answer_count": 1, "body": "JGitを利用してリポジトリのクローンを行を行うため、次のようなコードを記述しました。\n\n```\n\n Git result = Git\n .cloneRepository()\n .setBare(true)\n .setURI(remoteUrl)\n .setCredentialsProvider(\n new UsernamePasswordCredentialsProvider(user,\n password)).setDirectory(localDir)\n .setBranch(branch).call();\n \n```\n\n上記のコードを実行すると、エラーとなります。\n\n```\n\n java.lang.InternalError: Should not get here\n at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink0(Native Method)\n at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink(WindowsNativeDispatcher.java:890)\n at sun.nio.fs.WindowsFileSystemProvider.createSymbolicLink(WindowsFileSystemProvider.java:578)\n at java.nio.file.Files.createSymbolicLink(Files.java:1043)\n at org.eclipse.jgit.util.FileUtil.createSymLink(FileUtil.java:111)\n at org.eclipse.jgit.util.FS_Win32.detectSymlinkSupport(FS_Win32.java:171)\n at org.eclipse.jgit.util.FS_Win32.supportsSymlinks(FS_Win32.java:162)\n at org.eclipse.jgit.internal.storage.file.FileRepository.create(FileRepository.java:306)\n at org.eclipse.jgit.api.InitCommand.call(InitCommand.java:115)\n at org.eclipse.jgit.api.CloneCommand.init(CloneCommand.java:161)\n at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:132)\n at jp.hotpepper.ant.task.git.GitCloneTask.execute(GitCloneTask.java:59)\n at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:497)\n at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)\n at org.apache.tools.ant.Task.perform(Task.java:348)\n at org.apache.tools.ant.Target.execute(Target.java:435)\n at org.apache.tools.ant.Target.performTasks(Target.java:456)\n at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)\n at org.apache.tools.ant.Project.executeTarget(Project.java:1376)\n at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)\n at org.apache.tools.ant.Project.executeTargets(Project.java:1260)\n at org.apache.tools.ant.Main.runBuild(Main.java:853)\n at org.apache.tools.ant.Main.startAnt(Main.java:235)\n at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)\n at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)\n \n```\n\n何か設定が足りないのでしょうか? \nご教示のほどお願いいたします。\n\n実行環境です。 \nWindows 7 Professional SP1 64bit \njava version \"1.6.0_17\" \npom.xml :\n\n```\n\n <dependency>\n <groupId>org.eclipse.jgit</groupId>\n <artifactId>org.eclipse.jgit</artifactId>\n <version>4.0.0.201506090130-r</version>\n </dependency>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T11:42:12.700", "favorite_count": 0, "id": "11644", "last_activity_date": "2015-06-23T14:58:28.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6070", "post_type": "question", "score": 2, "tags": [ "java" ], "title": "JGitでリポジトリクローンを行うと失敗する", "view_count": 813 }
[ { "body": "JGit 4.0ではJava7が必要です。\n\n<https://github.com/eclipse/jgit/tree/stable-4.0>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T14:58:28.590", "id": "11650", "last_activity_date": "2015-06-23T14:58:28.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "241", "parent_id": "11644", "post_type": "answer", "score": 3 } ]
11644
11650
11650
{ "accepted_answer_id": null, "answer_count": 0, "body": "Codeigniter の `/application/config/routes.php` のルーティングに `$route['(:any)']`\nを設定すると、 `$route['404_override']` が動かなくなってしまうので治したいです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2015-06-23T13:04:03.473", "favorite_count": 0, "id": "11647", "last_activity_date": "2019-06-06T19:54:01.917", "last_edit_date": "2019-06-06T19:54:01.917", "last_editor_user_id": "32986", "owner_user_id": null, "post_type": "question", "score": 1, "tags": [ "php", "codeigniter" ], "title": "Codeigniterのルーティングについて", "view_count": 231 }
[]
11647
null
null
{ "accepted_answer_id": "11653", "answer_count": 1, "body": "全モデルの中での偏差値を求めたく、現在は全件取得してきて自分で実装した方法で特定のカラムの値からその偏差値を求めているのですが、これをPostgresqlの機能で行うことはできますか?\n\n例えば `price`というカラムを持つモデル`Company`があるとき、`deviation_of_price`というカラムに偏差値を保存しています。\n\nPostgresqlのマニュアルに該当する関数が用意されてるようなのですが具体的にどう呼び出せばよいかわかりませんでした。 \n<https://www.postgresql.jp/document/8.2/html/functions-aggregate.html>\n\n[英語版Stackoverflowの記述](https://stackoverflow.com/questions/15618053/how-to-\ngroup-by-last-20-days-and-do-an-aggregate-\nfunction)を参考に書いてみましたが、`nil`が返ってくるだけです。\n\n```\n\n Company.select('stddev_pop(price) as stddev')\n Company Load (6.6ms) SELECT stddev_pop(price) as stddev FROM \"companies\"\n => [#<Company:0x007fdc7d27ed48 id: nil>]\n \n```\n\nどのようにかけばRailsからPostgresqlの機能で偏差値を求めることが出来るのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T14:18:18.743", "favorite_count": 0, "id": "11649", "last_activity_date": "2015-06-23T16:15:04.527", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "3271", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails", "postgresql" ], "title": "Rails経由でPostgresqlの機能を使って偏差値を求める", "view_count": 255 }
[ { "body": "おそらくなにかの数値が返ってきてると思います。 \n確認してみてください。\n\n```\n\n company = Company.select('stddev_pop(price) as stddev')\n p company.stddev\n \n```\n\nActiveRecordでは集計関数を使った場合、idがnilのオブジェクトが返ってきます.", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T16:15:04.527", "id": "11653", "last_activity_date": "2015-06-23T16:15:04.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "199", "parent_id": "11649", "post_type": "answer", "score": 1 } ]
11649
11653
11653
{ "accepted_answer_id": "15028", "answer_count": 2, "body": "ネットで見かけたサンプルを使わせていただいてアプリを開発していますが、どうにも上手く表示させれないので質問させて頂きます。\n\nどうも画面のほうが先に描画されている気がします。 \nアプリ起動時は何も表示できなくてpreタグで表示している配列も空なのですが。 \nタブバーのtestボタンをタップすると表示されます。\n\nlist.htmlはなぜかコピペできなかったので手書き、重要な箇所だけを手打ちしたので記述ミスあるかもしれないです。\n\nどうすれば起動時から表示できるようになるでしょうか?\n\n## script.js\n\n* * *\n```\n\n // アプリの設定\n 'use strict';\n \n // APIの読み込み\n google.load(\"feeds\", \"1\");\n var app = ons.bootstrap('myApp');\n \n // 表示させる記事の数\n var disp_entry_count = 10;\n \n // 取得するサイトURL\n var site = new Array();\n \n site[0] = {\n title: 'GIZUMODO',\n url: 'http://feeds.gizmodo.jp/rss/gizmodo/index.xml',\n disp_entry: 2 // 取得する記事の数\n };\n \n site[1] = {\n title: 'Gigazin',\n url: 'http://feed.rssad.jp/rss/gigazine/rss_2.0',\n disp_entry: 3 // 取得する記事の数\n };\n \n site[2] = {\n title: 'ウェブソク',\n url: 'http://news.7zz.jp/feed',\n disp_entry: 5 // 取得する記事の数\n };\n \n // △△ここまでアプリの設定△△\n \n function init() {\n \n var channel = new Array();\n var entry = new Array();\n var entries = new Array();\n var Feed = \"\";\n \n var site_count = 0;\n \n for (var i = 0; i < site.length; i++) {\n \n // 読み込むRSSを設定\n var feed = new google.feeds.Feed(site[i]['url']);\n feed.setNumEntries(site[i]['disp_entry'])\n feed.load(function(rss) {\n \n var hoge = setInterval(function() {\n \n //終了条件\n if (!rss == nil) {\n clearInterval(hoge);\n console.log(\"終わり\");\n }\n }, 500);\n \n if (!rss.error) {\n // RSSからサイトの情報を配列に格納\n channel['title'] = rss.feed.title;\n channel['link'] = rss.feed.link;\n \n channel['description'] = rss.feed.description;\n channel['author'] = rss.feed.author;\n \n // RSSから記事の情報を配列に格納\n for (var j = 0; j < rss.feed.entries.length; j++) {\n \n var feed_entry = rss.feed.entries[j];\n var entry = {\n site_title: channel['title'],\n site_link: channel['link'],\n // site_favicon : channel['favicon'],\n title: feed_entry.title,\n link: feed_entry.link,\n content: feed_entry.content,\n contentSnippet: feed_entry.contentSnippet,\n publishedDate: feed_entry.publishedDate\n };\n \n var date = new Date(entry['publishedDate']);\n entry['time'] = date.getTime();\n var yy = date.getYear();\n var mm = date.getMonth() + 1;\n var dd = date.getDate();\n if (yy < 2000) {\n yy += 1900;\n }\n if (mm < 10) {\n mm = \"0\" + mm;\n }\n if (dd < 10) {\n dd = \"0\" + dd;\n }\n entry['date'] = yy + \"年\" + mm + \"月\" + dd + \"日\";\n \n entries.push(entry);\n }\n }\n site_count++;\n if (site.length == site_count) {\n disp();\n }\n });\n }\n return entries;\n }\n \n //日付順に並べ替え\n function disp() {\n entries.sort(function(b1, b2) {\n return b1.time < b2.time ? 1 : -1;\n });\n }\n \n app.controller('main', function($scope) {\n $scope.data = init();\n });\n \n```\n\n* * *\n\n## list.html\n\n* * *\n```\n\n <ons-list ng-controller=\"main\">\n <ons-list-item ng-repeat=\"item in dara\">\n <ons-row>\n <ons-col>\n <div>{{ item.site_title }}</div>\n <div> \n <span>{{ item.title }}</span> \n </div>\n <div>{{ item.dis }}</div>\n </ons-col>\n </ons-row>\n </ons-list-item>\n </ons-list>\n \n <!--デバッグ用-->\n <ons-list-item>\n <pre>{{ data|json }}</pre>\n </ons-list-item>\n \n```\n\n## inedx.html\n\n* * *\n\n \n \n \n \n\n```\n\n <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>\n <script type=\"text/javascript\" src=\"js/angular/angula.js\"></script>\n \n <script src=\"components/loader.js\"></script>\n <link rel=\"stylesheet\" href=\"components/loader.css\">\n \n <link rel=\"stylesheet\" href=\"css/onsenui.css\">\n <link rel=\"stylesheet\" href=\"css/onsen-css-components-blue-basic-theme.css\">\n <link rel=\"stylesheet\" href=\"css/timeline.css\">\n <script type=\"text/javascript\" src=\"js/onsenui.js\"></script>\n <script type=\"text/javascript\" src=\"js/script.js\"></script>\n \n </head>\n \n <body>\n \n <ons-tabbar>\n <ons-tab page=\"list.html\" active=\"true\">\n <ons-icon icon=\"ion-home\" class=\"tab-icon\">test</ons-icon>\n </ons-tab>\n <ons-tab page=\"temp.html\">\n <div class=\"notification reply-notification\" ons-tab-inactive>4</div>\n <ons-icon icon=\"ion-at\" class=\"tab-icon\"></ons-icon>\n </ons-tab>\n <ons-tab page=\"temp.html\">\n <ons-icon icon=\"ion-heart\" class=\"tab-icon\"></ons-icon>\n </ons-tab>\n <ons-tab page=\"temp.html\">\n <ons-icon icon=\"ion-person\" class=\"tab-icon\"></ons-icon>\n </ons-tab>\n </ons-tabbar>\n \n </body>\n </html>\n \n```\n\n![画像の説明をここに入力](https://i.stack.imgur.com/HzzOV.png) \n![画像の説明をここに入力](https://i.stack.imgur.com/Rb0S9.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T15:02:35.050", "favorite_count": 0, "id": "11651", "last_activity_date": "2015-08-30T05:26:39.307", "last_edit_date": "2015-06-24T01:42:46.283", "last_editor_user_id": "3516", "owner_user_id": "5967", "post_type": "question", "score": 5, "tags": [ "monaca", "onsen-ui", "angularjs" ], "title": "monacaでAngularjsとOnsenUIを使ってリストを表示したい", "view_count": 1162 }
[ { "body": "サーバーなどからデータを取得するときはAngularのデータバインディングがうまく作用しない場合があります \n$scope.dataをapplyで囲ってあげると直ると思います。 \n$scope.$apply(function(){ \n//$scopeの更新処理 \n});\n\nみたいな感じです。またはtimeoutなどが使えるかと", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T06:02:34.793", "id": "11874", "last_activity_date": "2015-06-30T06:02:34.793", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8748", "parent_id": "11651", "post_type": "answer", "score": 1 }, { "body": "だいぶ時間が経過していますが、これは非同期によるもので、init()は取得前の空のentriesを先に返すため、起動時に$scope.dataに反映されず表示されません。 \n各処理の間にconsole.log()を入れて動作させればわかります。 \n例えば、init()に$scopeを渡して、データがすべて揃った段階で$scope.$emit()でデータを渡し、コントローラ側の$scope.$on()でデータを受け取るようにすれば解決できると思います。\n\n```\n\n app.controller(\"main\", function($scope) {\n ons.ready(function() {\n init($scope);\n });\n $scope.$on(\"updateData\", function(e, entries) {\n $scope.data = entries;\n $scope.$apply();\n });\n });\n \n function init($scope) {\n var entries = [];\n // 取得処理\n //\n //\n // すべてのデータが揃った場合\n $scope.$emit(\"updateData\", entries);\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-30T05:26:39.307", "id": "15028", "last_activity_date": "2015-08-30T05:26:39.307", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9566", "parent_id": "11651", "post_type": "answer", "score": 1 } ]
11651
15028
11874
{ "accepted_answer_id": null, "answer_count": 1, "body": "はじめまして。\n\nSlim + sass + middlemanでプロトタイピングをしています。 \nSlimファイル内でSass・SCSSを記述する際に、Slim内で定義した変数をSass・SCSSで参照する方法をご存知の方はいらっしゃらないでしょうか。 \n※Hamlでは同様のことができたような記憶があるのですが…\n\n例として、下記のようなことを実現したいと思っています。\n\nよろしくお願いします。\n\n## sample.slim\n\n* * *\n```\n\n //slimで変数を定義\n - height = 177.0\n - width = Time.now.min\n .rectangle\n \n sass:\n .rectangle\n //sassで変数を呼び出し\n height: $height\n width: $width\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T15:50:51.823", "favorite_count": 0, "id": "11652", "last_activity_date": "2015-06-24T06:07:27.367", "last_edit_date": "2015-06-24T05:07:58.443", "last_editor_user_id": "10170", "owner_user_id": "10260", "post_type": "question", "score": 1, "tags": [ "sass", "slim-lang" ], "title": "Slimファイル内で記述された変数をsassに渡す方法について", "view_count": 553 }
[ { "body": "出来ないと思います。 \nslimで完結するしか無いのでは?\n\n[slim]\n\n```\n\n - height = 177.0\n - width = Time.now.min\n \n .rectangle style=\"height: #{height}; width: #{width};\"\n \n```\n\nもしくは、jQueryを使うとか\n\n[slim + jQuery]\n\n```\n\n - height = 177.0\n - width = Time.now.min\n \n .rectangle\n \n javascript:\n $(document).ready(function(){$('.rectangle').css({'height': #{height}, 'width': #{width}});});\n \n```\n\nしかし、上記の例でmiddlemanだと、widthはビルドした時の値なので、動的に変化するわけでもなく、slimを使ってTime.now.minしていること自体に疑問を感じます。時刻に応じて、動的にwidthの値を変えたいのであれば、widthの値算出をJavaScriptでやる必要があるのでは?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T05:50:26.937", "id": "11668", "last_activity_date": "2015-06-24T06:07:27.367", "last_edit_date": "2015-06-24T06:07:27.367", "last_editor_user_id": "10170", "owner_user_id": "10170", "parent_id": "11652", "post_type": "answer", "score": 1 } ]
11652
null
11668
{ "accepted_answer_id": null, "answer_count": 2, "body": "MySQL 5.6を利用しています。\n\n分析関数を持たないRDBMSのSQLでは、どのようなSQLを書くのが一般的でしょうか? \n一般的ではなくとも、解決できるSQLがありましたら教えてください。 \nよろしくお願いいたします。\n\nやりたいこと:\n\n下記のテーブルがあります。\n\n```\n\n ユーザID 作成日時\n --------------------------\n 10012 2015-01-04\n 10010 2015-01-01\n 10011 2014-01-15\n 10010 2015-01-02\n 10011 2015-12-09\n 10010 2015-01-03\n 10012 2015-11-01\n 10011 2015-05-08\n 10012 2015-01-03\n \n```\n\nSQLで下記の結果を取得したいです。 \n※「ユーザID」「作成日時」で昇順に並べかえて、 \nグループ内(同じユーザID内)で通番を付与\n\n```\n\n ユーザID 作成日時 グループ内通番\n -------------------------------\n 10010 2015-01-01 1\n 10010 2015-01-02 2\n 10010 2015-01-03 3\n 10011 2014-01-15 1\n 10011 2015-05-08 2\n 10011 2015-12-09 3\n 10012 2015-01-03 1\n 10012 2015-01-04 2\n 10012 2015-11-01 3\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-23T16:51:29.460", "favorite_count": 0, "id": "11654", "last_activity_date": "2016-04-28T03:15:07.327", "last_edit_date": "2015-06-24T01:24:12.700", "last_editor_user_id": "5778", "owner_user_id": "9501", "post_type": "question", "score": 3, "tags": [ "mysql", "sql" ], "title": "MySQLのSQLにてグループ内で連番を付けたい", "view_count": 15436 }
[ { "body": "MySQL だとユーザー変数で連番をつけたりします。\n\n```\n\n set @no:=0;\n set @user_id:=null;\n \n select\n if(@user_id <> user_id, @no:=1, @no:=@no+1) as no,\n @user_id:=user_id as user_id,\n created_at\n from t order by user_id, created_at\n \n```\n\nMySQL 特有の機能を使わないのであれば、次のように相関サブクエリを使うとかでしょうか。\n\n```\n\n select\n t1.user_id, t1.created_at, (\n select count(*) from t t2\n where t1.user_id = t2.user_id\n and t1.created_at >= t2.created_at\n ) as no\n from t t1\n order by\n t1.user_id, t1.created_at\n \n```\n\n(同値があるときの結果がちょっと変わりますが)\n\nそのテーブルの主キーが `id` だとして、次のようにただのサブクエリでもいいかもしれません。\n\n```\n\n select\n t1.user_id,\n t1.created_at,\n sum(t1.created_at >= t2.created_at) as no\n from t t1 inner join t t2 on t1.user_id = t2.user_id\n group by t1.id, t1.user_id, t1.created_at\n order by t1.user_id, no\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T03:31:35.723", "id": "11661", "last_activity_date": "2016-03-16T00:53:31.553", "last_edit_date": "2016-03-16T00:53:31.553", "last_editor_user_id": "2494", "owner_user_id": "2494", "parent_id": "11654", "post_type": "answer", "score": 2 }, { "body": "ngyukiさんが投稿されてる \nユーザ変数を使う方法ですが\n\nMySQLのマニュアルと \nOracleACEのAketiJyuuzouさんとyoku0825さんと \n日本オラクルの木村明治さんによると \nMySQLのユーザ変数は評価順序が未定義です。 \n<http://qiita.com/AketiJyuuzou/items/cced9b70cc714b382d98>\n\nなので結果が保証されません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-04-28T01:35:19.183", "id": "24402", "last_activity_date": "2016-04-28T03:15:07.327", "last_edit_date": "2016-04-28T03:15:07.327", "last_editor_user_id": "15293", "owner_user_id": "15293", "parent_id": "11654", "post_type": "answer", "score": 0 } ]
11654
null
11661
{ "accepted_answer_id": null, "answer_count": 1, "body": "アプリの審査で却下された理由の部分に \nOn cellular network とありました。 \nこれってどのような状況なのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T01:48:33.603", "favorite_count": 0, "id": "11657", "last_activity_date": "2015-06-24T04:47:16.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7950", "post_type": "question", "score": 1, "tags": [ "ios" ], "title": "アプリの審査についてOn cellular networkとは?", "view_count": 261 }
[ { "body": "電話回線=3GやLTEでの接続時に問題があるよ、という意味です。\n\nおそらく他にも却下された理由が記載されているはずで、それが電話回線での接続時に発生しますよ、という意味だと考えられます。\n\nより詳しく知りたい場合は、そのメッセージの全文を転載されたほうが良いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T04:47:16.603", "id": "11666", "last_activity_date": "2015-06-24T04:47:16.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "208", "parent_id": "11657", "post_type": "answer", "score": 1 } ]
11657
null
11666
{ "accepted_answer_id": "11670", "answer_count": 3, "body": "下記を「for … of」でループするには、どうすれば良いでしょうか? \n・配列でないと無理?\n\n```\n\n var hoge = {\"area23\": \"東京\", \"area47\": \"沖縄\"};\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T03:26:05.350", "favorite_count": 0, "id": "11660", "last_activity_date": "2015-06-24T06:21:19.487", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 1, "tags": [ "javascript", "ecmascript-6" ], "title": "配列ではなくオブジェクトを「for … of」でループするにはどうすれば良いでしょうか?", "view_count": 3444 }
[ { "body": "これですかね?\n\n```\n\n for (var k in hoge) {\n console.log(k + ' = ' + hoge[k]);\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T04:35:58.743", "id": "11664", "last_activity_date": "2015-06-24T04:35:58.743", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "845", "parent_id": "11660", "post_type": "answer", "score": 1 }, { "body": "ofはECMAScript6の書き方なので今はまだinで逃げるべきかと… \n余分なプロトタイプチェーンのプロパティが出てくる場合はtypeofの判定を追加で。 \nif (typeof(hoge[i]) !== 'function') {~~~}\n\n```\n\n var hoge = {\"area23\": \"東京\", \"area47\": \"沖縄\"};\r\n for (var i in hoge){\r\n alert(i+':'+hoge[i]);\r\n }\n```\n\n<https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Statements/for...of> \n同じことをofでやる場合は下記のようですが・・・ \n自分の環境では確認できなかったり^^;\n\n```\n\n let hoge = {\"area23\": \"東京\", \"area47\": \"沖縄\"};\n for (let i of hoge){\n alert(i);\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T04:45:25.600", "id": "11665", "last_activity_date": "2015-06-24T04:45:25.600", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9262", "parent_id": "11660", "post_type": "answer", "score": 0 }, { "body": "`for..of` は Iterator と組み合わせるものであり、 **プロパティ名の列挙にはこれまで通り`for..in` を使う必要があります。**\nArray や Map は Iterator を提供している(Iterable)ので `for...of` が使えます。\n\nこれまでプロパティの列挙が `for..in` でできていた一方で、 arguments のような配列モドキや独自のコレクションを\n`Array.prototype.forEach` のように反復処理する方法はありませんでした。一部の処理系では `Array.forEach`\nなどの一般化した実装も提供していましたが、これは配列のように `length` プロパティとインデックスアクセスを用いるものですから、ES6 で登場する\nGenerator のように要素数がわからないオブジェクトでは利用できません。\n\nそこで、「次の要素に進む」「現在の値」「続きがあるかどうか」のみを使った Iterator が生まれ、それを用いた foreach のようなものが\n`for...of` 、ということになります。\n\nちなみに、ES6 の `for..in` は[「プロパティ名を列挙するイテレータ」](http://www.ecma-\ninternational.org/ecma-262/6.0/#sec-ordinary-object-internal-methods-and-\ninternal-slots-enumerate)を生成し、それを反復する、といった書き方になっていました。\n\n参考\n\n * [for...of - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of)\n * [Iteration protocols - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols)\n * [ES6のイテレータについて調べた - ひよこ3分07秒のTechブログ](http://tech.chick307.com/2014/05/09/es6-iterator/)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T06:21:19.487", "id": "11670", "last_activity_date": "2015-06-24T06:21:19.487", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "11660", "post_type": "answer", "score": 2 } ]
11660
11670
11670
{ "accepted_answer_id": null, "answer_count": 1, "body": "swiftのWebViewで指定箇所から表示させる方法は? \n下の写真の赤のライン以下を検索結果として表示したいんですが、コードがわかりません。 \nよろしくお願いします \n![](https://i.stack.imgur.com/QXjmU.jpg)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T04:25:07.847", "favorite_count": 0, "id": "11662", "last_activity_date": "2015-06-24T23:59:19.713", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10264", "post_type": "question", "score": -1, "tags": [ "ios", "swift", "xcode" ], "title": "swiftのWebViewで指定箇所から表示させる方法は?", "view_count": 171 }
[ { "body": "方法としては二通りあると思います。 \n一つは表示する位置を固定して赤線から上の部分を見えなくする方法です、こちらはちょっとわかりませんでした。\n\n二つ目は、赤線から上の部分を消してしまう方法です。\n\nswift側からjavascriptを実行して、htmlを操作しページのソースコードを書き換えればいいと思います。\n\nですが、これにはhtmlとjavascriptの知識が若干必要になると思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T23:59:19.713", "id": "11698", "last_activity_date": "2015-06-24T23:59:19.713", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5967", "parent_id": "11662", "post_type": "answer", "score": 0 } ]
11662
null
11698
{ "accepted_answer_id": null, "answer_count": 1, "body": "> certificate subject name (*.opendns.com) does not match target host name\n> 'github.com' while accessing <https://github.com/>\n\nというメッセージが出て使えません。 \nどのようにしたらよいでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T04:32:02.933", "favorite_count": 0, "id": "11663", "last_activity_date": "2015-08-24T04:38:36.807", "last_edit_date": "2015-08-24T04:38:36.807", "last_editor_user_id": "62", "owner_user_id": "10265", "post_type": "question", "score": 1, "tags": [ "wordpress", "ssl" ], "title": "PixabayがWordPressで使えません", "view_count": 195 }
[ { "body": "Pixabayは「WordPress」のプラグインで、エディタの編集画面でPixabayの版権フリー写真を一発挿入出来るという物です。\n\n> 質問主さん \n> 興味深い事例ですが、「設定」に入り、「設定」画面の変更で使える様になりませんか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-05T01:47:10.260", "id": "12036", "last_activity_date": "2015-07-05T01:58:36.837", "last_edit_date": "2015-07-05T01:58:36.837", "last_editor_user_id": "10398", "owner_user_id": "10398", "parent_id": "11663", "post_type": "answer", "score": 1 } ]
11663
null
12036
{ "accepted_answer_id": "11678", "answer_count": 1, "body": "cocoapodsでPodfileに書かれていないのがインストールされます。 \nこれの解決方法をご存知の方は教えていただければ幸いです。\n\n一応勝手にインストールされるライブラリー名はGHODictionary (1.0.7)でございます。\n\n過去に一回ぐらい入れた記憶もあります。 \nただ、今はPodfileには書いていません。\n\nコメントありがとうございます。中身は以下の通りです。\n\n```\n\n pod 'Alamofire', '~> 1.2'\n pod 'SwiftyJSON', '~> 2.2'\n pod 'Alamofire-SwiftyJSON', :git => \"https://github.com/SwiftyJSON/Alamofire-SwiftyJSON.git\"\n pod 'Starscream', '~> 0.9'\n pod 'MPMessagePack', '~> 1.1'\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T05:47:17.533", "favorite_count": 0, "id": "11667", "last_activity_date": "2015-06-25T00:38:53.007", "last_edit_date": "2015-06-24T07:56:36.463", "last_editor_user_id": "8000", "owner_user_id": "10188", "post_type": "question", "score": 0, "tags": [ "xcode", "cocoapods" ], "title": "cocoapodsでPodfileに書かれていないのがインストールされる", "view_count": 282 }
[ { "body": "MPMessagePackがGHODictionaryに依存しているためです。\n\nMPMessagePackを使うにはGHODictionaryが必要なため、自動的にインストールされます。\n\n<https://github.com/gabriel/MPMessagePack/blob/master/MPMessagePack.podspec#L12>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T09:03:00.667", "id": "11678", "last_activity_date": "2015-06-25T00:38:53.007", "last_edit_date": "2015-06-25T00:38:53.007", "last_editor_user_id": "5519", "owner_user_id": "5519", "parent_id": "11667", "post_type": "answer", "score": 1 } ]
11667
11678
11678
{ "accepted_answer_id": null, "answer_count": 1, "body": "android端末のアプリ使用でTCP切断時、正常であれば『サーバ⇒端末』にFINが投げられた後、即『端末⇒サーバ』へFINを返しています。 \nただ時たま、『サーバ⇒端末』にFINが投げられた後、『端末⇒サーバ』へFINを返す際に120sほどかることがあります。\n\nこちら、遅れる原因としてどういったものが考えられますでしょうか。 \nOSの問題でしょうか。 \n※端末アプリにはHTTPリクエスト時の共通処理として、ソケットのクローズ処理があります", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T06:03:29.430", "favorite_count": 0, "id": "11669", "last_activity_date": "2017-03-05T07:50:24.437", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10267", "post_type": "question", "score": 1, "tags": [ "android", "tcp" ], "title": "TCP接続切断時のandroid端末⇒サーバへのFINが遅延する", "view_count": 1367 }
[ { "body": "AndroidOSに搭載されているTCPプロトコルのソフトウェアのバグの可能性も否定出来ませんが \nTCPのクローズ処理のシーケンスとして以下のような流れになります。\n\nサーバ:FIN(これをもってサーバからデータ送信しない) -> ACK応答(OKわかった。でもクライアントはまだ送信するかもしれないよ) \nクライアント:FIN(これをもってクライアントからデータ送信しない) -> ACK応答(OKわかった) \nサーバ・クライアント:双方FINを認識したのでじゃあクローズとしよう。\n\nつまり、『サーバ -> 端末』でのFIN時点ではTCP切断は成立していません。(shutdown状態) \nまた、サーバ側はsend()する事は出来ませんが、shutdown(読込)していなければrecv()は可能)ですし \nクライアント側はsend()もrecv()もする事が出来ます。但し、使用しているソケットに対して \nクライアントがrecv()をした時、TCPプロトコル側に\" **受信データがない**\n\"と戻り値として「0」が返ります。(もうサーバから送られる可能性が無いので)\n\nなのでクライアントからのFINが遅れる原因として考えられる可能性は、 \nクライアント側がclose()またはshutdown(書込)を実行してサーバ側にFIN送信をしていないのではないでしょうか。 \n具体的にはクライアント側がまだ受信処理をしている、とか送信処理をしているとか。(まだ仕事をしている) \nまたはクライアント側のアプリケーションの問題で適切にclose()を発行していないのかもしれませんね。 \n話を聞く限り、120秒も掛かっているのでTCPプロトコルかアプリケーションの何らかの問題の可能性が高いかもしれません。 \n設定にもよりますが120秒という切りの良い時間ですし、サーバ側が実行したclose()がタイムアウトして切断が成立しているのかもしれません。 \nパケットキャプチャ見ないとわかりませんが、サーバがclose()でタイムアウト(TIME-WAIT2 ->\nCLOSED)になった後にクライアントからデータ送信が来た場合RSTを返すはずなので \nそういう動きになっていればclose()のタイムアウトで強制切断になっている可能性が高いと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-05T07:33:24.593", "id": "33106", "last_activity_date": "2017-03-05T07:50:24.437", "last_edit_date": "2017-03-05T07:50:24.437", "last_editor_user_id": "20931", "owner_user_id": "20931", "parent_id": "11669", "post_type": "answer", "score": 1 } ]
11669
null
33106
{ "accepted_answer_id": "11677", "answer_count": 1, "body": "現在`ViewController`に`UICollectionView`を二つ置き、一つの`UICollectionView`はカスタムセルを使っています。カスタムセルには`UILabel`を一つ置いており、これに文字列を入れて表示させようとしているのですが、セルには何も表示されません。カスタムセルのUIを定義している`xib`ファイルの名前は「WeekPlanCell」で、`nibWithNibName`メソッドの引数と一致しています。WeekPlanCellというクラスを作り、そのヘッダファイルに`WeekPlanCell.xib`にある`UILabel`を紐付けています。そして`Storyboard`の`Collection\nReusable\nView`の`identifier`には「afterDayCell」と入力しており、`cellForItemAtIndexPath`の`dequeueReusableCellWithReuseIdentifier`の引数の文字列と一致しています。 \nまた、`Storyboard`のカスタムセルを用いた`UICollectionView`のセルの`Custom\nClass`のClassには「WeekPlanCell」と入力しています。 \n上記の手順でどこが間違っているのでしょう? \nどなたか分かる方がいれば教えていただきたいです。 \nすみませんが、よろしくお願いします。\n\n```\n\n - (void)viewDidLoad {\n [super viewDidLoad];\n \n [self initCustomCell];\n }\n \n - (void)initCustomCell {\n UINib *nib = [UINib nibWithNibName:@\"WeekPlanCell\" bundle:nil];\n [self.collectionView registerNib:nib forCellWithReuseIdentifier:@\"afterDayCell\"];\n }\n \n - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView\n {\n if (collectionView == self.collectionView) {\n return 1;\n } else {\n return 1;\n }\n }\n \n - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {\n if (collectionView == self.collectionView) {\n return 1;\n } else {\n return 6;\n }\n }\n \n - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {\n UICollectionViewCell *cell;\n \n if (collectionView == self.collectionView) {\n cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@\"todayCell\" forIndexPath:indexPath];\n } else {\n cell = [self.afterDayCollectionView dequeueReusableCellWithReuseIdentifier:@\"afterDayCell\" forIndexPath:indexPath];\n \n WeekPlanCell *weekPlanCell = (WeekPlanCell*)cell;\n weekPlanCell.layer.borderWidth = 0.4f;\n weekPlanCell.layer.borderColor = [UIColor blackColor].CGColor;\n \n weekPlanCell.label.text = @\"book\";\n }\n \n return cell;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T07:31:42.133", "favorite_count": 0, "id": "11672", "last_activity_date": "2015-06-24T09:01:40.190", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5210", "post_type": "question", "score": 0, "tags": [ "ios", "objective-c", "xcode", "uicollectionview", "uicollectionviewcell" ], "title": "CollectionViewのカスタムセルに何も表示ができない", "view_count": 3695 }
[ { "body": "`UICollectionView` でカスタムセルを実装する方法は:\n\n 1. `UICollectionViewCell` をサブクラス化し、ビューのレイアウトもコードで行う\n 2. `UICollectionViewCell` をサブクラス化し、ビューのレイアウトは xib ファイルで行う\n 3. `UICollectionViewCell` をサブクラス化し、ビューのレイアウトは、Storyboard で配置した Collection View の中の、Collection View Cell を編集して行う\n\nの 3 つになるかな、と思います。\n\n質問文では、2 と 3 の方法を重複して使われているように見えるのですが、本来どちらの方法を使われたいのでしょうか?\n\n* * *\n\nこの部分で:\n\n```\n\n [self.collectionView registerNib:nib forCellWithReuseIdentifier:@\"afterDayCell\"];\n \n```\n\n`self.afterDayCollectionView`\nに対して呼び出されるべきなのではないかな、と思われるカスタムセルの登録が、`self.collectionView` に対して行われています。\n\nこの場合は、Storyboard で設定した方の内容が反映される(3 の方法)と思うので、Storyboard の Collection View Cell\n内で `UILabel` が配置されていなかったり、outlet の接続ができていないと、何も表示されないと思うのですが、いかがでしょうか。\n\n2 の方法を使われる場合は、Storyboard\n上のカスタムセルの設定を削除して、引用させていただいた部分のコードを修正すれば、解決できるのではないかと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T09:01:40.190", "id": "11677", "last_activity_date": "2015-06-24T09:01:40.190", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2299", "parent_id": "11672", "post_type": "answer", "score": 1 } ]
11672
11677
11677
{ "accepted_answer_id": null, "answer_count": 1, "body": "複数のModelを利用してViewを表示した場合、どのように受け渡すのでしょうか?\n\n```\n\n public ActionResult Index()\n {\n \n using (var context = new testDBEntities())\n {\n //一つ目のModel\n ViewData.Model = (from u in context.test1data\n orderby u.startTime ascending\n select u).Take(5).ToList();\n }\n \n using (var context = new testDBEntities())\n {\n //二つ目のModel\n ViewData.Model = (from u in context.test2data\n orderby u.startTime ascending\n select u).Take(5).ToList();\n }\n \n return View();\n }\n \n```\n\nindex.cshtml\n\n//一つ目のModelをループで表示 \n@foreach (var s in ViewData.Model) \n{ \n@s.itemName \n} \n//二つ目のModelをループで表示 \n@foreach (var s in ViewData.Model) \n{ \n@s.itemName2 \n}", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T08:28:52.820", "favorite_count": 0, "id": "11674", "last_activity_date": "2015-06-25T02:11:05.710", "last_edit_date": "2015-06-25T02:11:05.710", "last_editor_user_id": "2238", "owner_user_id": "8271", "post_type": "question", "score": 3, "tags": [ "c#", ".net", "asp.net" ], "title": "C# MVC4で複数のViewData.ModelをView に渡す方法", "view_count": 7935 }
[ { "body": "2つのモデルを保持する型をモデルとしてください。\n\n```\n\n // 変数model1, model2;があるとする\n \n using (var context = new testDBEntities())\n {\n //一つ目のModel\n model1 = (from u in context.test1data\n orderby u.startTime ascending\n select u).Take(5).ToList();\n }\n \n using (var context = new testDBEntities())\n {\n //二つ目のModel\n model2 = (from u in context.test2data\n orderby u.startTime ascending\n select u).Take(5).ToList();\n }\n \n ViewData.Model = new { Model1 = model1, Model2 = model2 };\n \n return View();\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T10:34:18.753", "id": "11680", "last_activity_date": "2015-06-24T10:34:18.753", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "11674", "post_type": "answer", "score": 4 } ]
11674
null
11680
{ "accepted_answer_id": null, "answer_count": 0, "body": "ビルドツールのgulpを使っているのですが、存在しないファイルをさし、エラーがでてしまいます。\n\n```\n\n events.js:85\n throw er; // Unhandled 'error' event\n ^\n CssSyntaxError: /Volumes/project/main.scss:5:4: Unknown word\n \n // bower:scss\n ^\n \n```\n\n(このプロジェクトではmainという名前のscssは存在しないですが)cacheかな?と思い \nnpm cache cleanをしても解消されず。。\n\n```\n\n npm cache clean && sudo npm cache clean -g \n \n```\n\n以前も、なぜか別プロジェクトのファイルを読み込もうとし、存在しないよ。とエラーが出ました。 \n(その時はパスが完全に別のプロジェクト名だったので気がつきました。)\n\n今回も前回も、Macを再起動したら治りましたが、これに躓くたびに再起動は少々厳しく、、 \nnodeを理解しきれてないのも問題なのかと思いますが、こういった現象の対処策など \nご存知でしたら教えていただけますと幸いです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T08:51:31.247", "favorite_count": 0, "id": "11676", "last_activity_date": "2015-08-26T15:16:05.503", "last_edit_date": "2015-08-26T15:16:05.503", "last_editor_user_id": "2238", "owner_user_id": "3131", "post_type": "question", "score": 1, "tags": [ "node.js", "gulp", "npm" ], "title": "npmで存在しないファイルを指し、エラーがでる。", "view_count": 367 }
[]
11676
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "swiftで、下の写真のようなデータの編集(追加)ができるTableViewの、画面遷移先でもデータの編集や追加もできるTableViewにするにはどうすればいいですか? \nイメージとしてはフォルダーの中にファイルがある感じです。 \nデータベースみたいのも使いますか? \n![画像の説明をここに入力](https://i.stack.imgur.com/CcL7l.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T09:31:04.710", "favorite_count": 0, "id": "11679", "last_activity_date": "2015-06-25T05:26:33.177", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10264", "post_type": "question", "score": -2, "tags": [ "ios", "swift", "xcode" ], "title": "swiftでTableViewの画面遷移先も同じようなTableViewを表示させる方法は?", "view_count": 655 }
[ { "body": "質問に書かれてる情報だけでは前提としている条件がよくわからないため、StoryboardとUINavigationControllerを使用している状況で、同じ画面に遷移する方法を説明します。\n\nやることは簡単で、実際に遷移するタイミングで同じViewControllerを生成してpushするだけです。\n\n```\n\n func moveToNext() {\n let id = \"Folder\"\n let vc = storyboard?.instantiateViewControllerWithIdentifier(id) as! UIViewController\n navigationController?.pushViewController(vc, animated: true)\n }\n \n```\n\nidには、Storyboardで指定したStoryboard IDが入ります。\n\nあとは、それぞれの画面がデータのどこに対応するのかを管理するようにすれば、どの画面でもデータの編集ができるようになるかと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T05:26:33.177", "id": "11710", "last_activity_date": "2015-06-25T05:26:33.177", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7459", "parent_id": "11679", "post_type": "answer", "score": 0 } ]
11679
null
11710
{ "accepted_answer_id": null, "answer_count": 2, "body": "Go言語で、標準入力から文字列を受け取り、その文字列を標準出力に出力する実行ファイルを生成するプログラムを作る、といったようなことは可能でしょうか? \nまた、可能ならばどのような方法ありますか?\n\nGo言語で簡単なコンパイラを作ってみたいと思っているのですが、プログラムから動的に実行ファイルを生成する方法がよくわかりません。 \nよろしくお願いします。\n\n> 6/24 8:48 コメントで指摘頂いた点を修正しました。", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T10:42:07.933", "favorite_count": 0, "id": "11681", "last_activity_date": "2015-08-25T13:03:30.413", "last_edit_date": "2015-06-24T23:45:41.343", "last_editor_user_id": "8528", "owner_user_id": "8528", "post_type": "question", "score": 2, "tags": [ "go" ], "title": "Go言語における実行ファイルの生成について", "view_count": 525 }
[ { "body": "文字通りに解釈すると下記でしょうか。\n\nUPDATE: 2015-06-25 1:04 \n`os.Args[1:]` を使った例を投稿していましたが、標準入力ではない、というご指摘をいただき、修正しました。\n\nGo言語で標準入力から文字列を受け取り、その文字列を標準出力に出力する\n\n[bufio - The Go Programming\nLanguage](http://golang.org/pkg/bufio/#example_Scanner_lines) より転載\n\n```\n\n package main\n \n import (\n \"bufio\"\n \"fmt\"\n \"os\"\n )\n \n func main() {\n scanner := bufio.NewScanner(os.Stdin)\n for scanner.Scan() {\n fmt.Println(scanner.Text()) // Println will add back the final '\\n'\n }\n if err := scanner.Err(); err != nil {\n fmt.Fprintln(os.Stderr, \"reading standard input:\", err)\n }\n }\n \n```\n\n実行ファイルを生成する\n\n```\n\n $ go build echo.go\n $ echo Hello World | ./echo\n Hello World\n \n $ ./echo\n Hello World! // <- User input\n Hello World! // <- Response\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T13:31:32.183", "id": "11690", "last_activity_date": "2015-06-24T16:11:57.510", "last_edit_date": "2015-06-24T16:11:57.510", "last_editor_user_id": "7471", "owner_user_id": "7471", "parent_id": "11681", "post_type": "answer", "score": 1 }, { "body": "> Go言語で簡単なコンパイラを作ってみたいと思っているのですが、プログラムから動的に実行ファイルを生成する方法がよくわかりません。\n>\n>\n> [コメント引用](https://ja.stackoverflow.com/questions/11681/#comment10862_11681):Linux上でネイティブ動作するものを考えています。\n\nGo言語でコンパイラを作ることは可能です。Linux上でネイティブ動作する実行ファイルを直接生成したいならば、まずは[ELF(Executable and\nLinkable\nFormat)](https://ja.wikipedia.org/wiki/Executable_and_Linkable_Format)ヘッダを出力し、つづいて対象アーキテクチャに応じた機械語コード列を出力することになります。\n\n>\n> [コメント引用](https://ja.stackoverflow.com/questions/11681/#comment10862_11681):Goで実行ファイル形式のバイナリファイルを出力する方法は、byteを1つずつ手作業で指定して出力するしかないのでしょうか。\n\nはい。実行ファイル形式のbyteを出力していくことは、(広義の)コンパイラにおける主要機能そのものです。\n\nとはいえ実際のコンパイラ・ツールチェインでは、単一プログラムで全ての処理を担当するのではなく、その処理フェーズに応じて役割分担を行うのが一般的です。\n\n * ソースコードからの 字句解析、構文解析、意味解析 あたりまではフロントエンド部と呼ばれます。抽象構文木はこれらの過程の出力となります。\n * 続く コード最適化、コード生成 あたりがバックエンド部と呼ばれます。コード生成部では、対象アーキテクチャ専用のものがそれぞれ必要となります。\n\nバックエンド部を自作する場合は、少なくとも、対象CPUアーキテクチャでアセンブラ・プログラミングが出来る程度の知識は必須です。そこまで自作するのが困難ならば、[LLVMの中間表現(IR)](http://llvm.org/)などの既存のコンパイラ・インフラストラクチャ活用をおすすめします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-25T13:03:30.413", "id": "14836", "last_activity_date": "2015-08-25T13:03:30.413", "last_edit_date": "2017-04-13T12:52:38.920", "last_editor_user_id": "-1", "owner_user_id": "49", "parent_id": "11681", "post_type": "answer", "score": 2 } ]
11681
null
14836
{ "accepted_answer_id": null, "answer_count": 1, "body": "プリンタにXPSを指定した状態で、C#からWorksheet.PrintOutを実行すると、ファイル保存ダイアログが表示されますが。 \nその状態で少し放置すると、サーバー使用中ダイアログがでてきてしまいます。 \nサーバー使用中ダイアログを表示させない方法は、印刷を別スレッドで実行するしかないのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T11:18:55.537", "favorite_count": 0, "id": "11683", "last_activity_date": "2015-08-21T14:17:05.947", "last_edit_date": "2015-06-24T16:22:06.213", "last_editor_user_id": "2266", "owner_user_id": "2266", "post_type": "question", "score": 2, "tags": [ "c#", "windows", "excel", "com" ], "title": "C#からExcel印刷するとサーバー使用中ダイアログが表示されるのを回避する方法", "view_count": 512 }
[ { "body": "タイマーを使用して、別スレッドで実行することで解決しました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-22T12:27:48.970", "id": "12577", "last_activity_date": "2015-07-22T12:27:48.970", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2266", "parent_id": "11683", "post_type": "answer", "score": 2 } ]
11683
null
12577
{ "accepted_answer_id": "11685", "answer_count": 2, "body": ":wqとかでvimを終了した際に \n「今日もお疲れ様」などをshellのsayコマンドを通して \n鳴らしたいのですが、どうすれば良いでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T12:17:28.710", "favorite_count": 0, "id": "11684", "last_activity_date": "2015-06-24T14:39:58.983", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10274", "post_type": "question", "score": 4, "tags": [ "vim" ], "title": "vim終了時にイベントを起こしたい。", "view_count": 502 }
[ { "body": "以下のようなコードをvimrcに記述すればできると思います。 \n下記の例はWindowsでエクスプローラを起動する例ですが、Macなら「start explorer.exe」の部分を「open say\n\"今日もお疲れ様\"」のような感じ(未検証)でコマンドを記述すれば出来ると思います。\n\n```\n\n augroup quitcmd\n autocmd!\n autocmd VimLeave * :silent !start explorer.exe\n augroup END\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T12:38:58.843", "id": "11685", "last_activity_date": "2015-06-24T12:38:58.843", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10276", "parent_id": "11684", "post_type": "answer", "score": 7 }, { "body": "解決されたようですが、別の方法も書いておきます。 \n以下のシェルスクリプトを path の通った場所に vim という名前で置きます。\n\n```\n\n #!/bin/bash\n /usr/bin/vim \"$@\"\n say '今日もお疲れ様'\n \n```\n\nvim の知識がなくてもできます。 \nsay の行を aplay に変えれば、例えば Linux で音を鳴らすくらいはできるでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T14:39:58.983", "id": "11692", "last_activity_date": "2015-06-24T14:39:58.983", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5288", "parent_id": "11684", "post_type": "answer", "score": 2 } ]
11684
11685
11685
{ "accepted_answer_id": "11689", "answer_count": 3, "body": "ROT13という簡単な換字式暗号をRubyで作ってみました。\n\n```\n\n str = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\"\n # ROT13\n p str.tr(\"A-Za-z\", \"N-ZA-Mn-za-m\")\n p str.tr(\"\\x41-\\x5a\\x61-\\x7a\", \"\\x4e-\\x5a\\x41-\\x4d\\x6e-\\x7a\\x61-\\x6d\")\n \n```\n\n実行結果 \n\"NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm0123456789\" \n\"NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm0123456789\"\n\nこれを次のようにダブルクォートをシングルクォートにかえると、 \n下の方の出力が上手くいかないのはなぜでしょうか? \nまた修正可能であるなら、どのように修正すればよろしいでしょうか?\n\n```\n\n str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\n # ROT13\n p str.tr('A-Za-z', 'N-ZA-Mn-za-m')\n p str.tr('\\x41-\\x5a\\x61-\\x7a', '\\x4e-\\x5a\\x41-\\x4d\\x6e-\\x7a\\x61-\\x6d')\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T13:09:19.897", "favorite_count": 0, "id": "11687", "last_activity_date": "2015-06-24T14:31:56.477", "last_edit_date": "2015-06-24T13:41:50.260", "last_editor_user_id": "5363", "owner_user_id": "5363", "post_type": "question", "score": 5, "tags": [ "ruby" ], "title": "ROT13について", "view_count": 616 }
[ { "body": "[ダブルクォートで囲まれた文字列ではバックスラッシュ記法と式展開(後述)が有効になります。](http://docs.ruby-\nlang.org/ja/2.1.0/doc/spec=2fliteral.html#string)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T13:22:51.597", "id": "11688", "last_activity_date": "2015-06-24T13:22:51.597", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7471", "parent_id": "11687", "post_type": "answer", "score": 2 }, { "body": "シングルクォートの中ではバックスラッシュ記法が使えないため、`\\`が`\\`という文字そのものとして解釈されます。\n\nそうすると`String#tr`は、`\\x4e-\\x5a`と`\\x6e-\\x7a`の`e-\\`の部分を`e`から`\\`までの範囲として解釈しますが、`\\`のコードポイントが`e`より小さいため、不正な範囲としてエラーになります。\n\nドキュメントには明確に書かれていませんが、`String#tr`の範囲指定では右辺のコードポイントが左辺のコードポイント以上でなければいけないという制約があるようです。 \n(a-zはOKだがz-aという逆順の指定はNG)\n\n> 文字列はダブルクォートまたはシングルクォートで囲まれています。ダブルクォートで囲まれた文字列ではバックスラッシュ記法と式展開(後述)が有効になります。\n> シングルクォートで囲まれた文字列では、 \\(バックスラッシュそのもの)と \\' (シングルクォート) を除いて文字列の中身の解釈は行われません。\n\n<http://docs.ruby-lang.org/ja/2.1.0/doc/spec=2fliteral.html#string>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T13:25:46.747", "id": "11689", "last_activity_date": "2015-06-24T13:25:46.747", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "11687", "post_type": "answer", "score": 7 }, { "body": "クォート方法を変えるとか。\n\n```\n\n p str.tr(%Q(\\x41-\\x5a\\x61-\\x7a), %Q(\\x4e-\\x5a\\x41-\\x4d\\x6e-\\x7a\\x61-\\x6d))\n \n```\n\n実質的にはダブルクォートと変わりませんが。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T14:31:56.477", "id": "11691", "last_activity_date": "2015-06-24T14:31:56.477", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5288", "parent_id": "11687", "post_type": "answer", "score": 2 } ]
11687
11689
11689
{ "accepted_answer_id": null, "answer_count": 1, "body": "例えば`~/hoge/fuga/piyo` にアクセスしたいとして。 \nEmacsだと`C-x C-f`して「`~/h/f/p`」と入力してTab押すと「`~/hoge/fuga/piyo`」と補完してくれます。 \nvimでこれをやる方法はあるでしょうか? \nできればプラグインとかじゃなくてvimrcに数行書くだけでこれができるようになると最高です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T14:50:52.833", "favorite_count": 0, "id": "11693", "last_activity_date": "2015-06-25T01:30:00.127", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10277", "post_type": "question", "score": 2, "tags": [ "vim" ], "title": "vimでファイルパスを動的に補完したい", "view_count": 1768 }
[ { "body": "Emacsの`C-x C-f`相当ということなので、Vimの`:e`コマンドでファイル名を指定する場合で説明させていただきます。(`:h :edit_f`)\n\n> 「~/h/f/p」と入力してTab押すと「~/hoge/fuga/piyo」と補完してくれます。\n\n近いのは `~/h*/f*/p` と入力してTab押下ですかね。\n\nあと、ディレクトリ名を1つずつ補完する方法を説明します。\n\n 1. `:e ~/h`と入力したあと`:e ~/hoge/`になるまで`Tab`を押す。\n 2. `:e ~/hoge/`の状態で`f`を押して`:e ~/hoge/fuga/`になるまで`Tab`を押す。\n 3. `:e ~/hoge/fuga/`の状態で`p`を押して`:e ~/hoge/fuga/piyo/`になるまで`Tab`を押す。\n 4. `:e ~/hoge/fuga/piyo/`の状態で`ctrl-]`を押して補完を確定させる。(`:h c_ctrl-]`)\n 5. あとは`Tab`や`ctrl-d`を押したり、ファイル名の一部を入力したりを繰り返して開きたいファイルを選ぶ。(`:h c_<Tab>`, `:h c_ctrl-d`)\n 6. `Enter`を押してファイル編集開始。\n\n逆にファイル名しか分かっていない場合はディレクトリツリー全体の検索をおこなう `**` を使うと便利です。(`:h starstar`) \n`:e ~/**/file`等と入力して`Tab`や`ctrl-d`を押します。 \n(ディレクトリやファイルが多すぎると時間が掛かります。そのときは`ctrl-c`でキャンセルして下さい)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T01:30:00.127", "id": "11701", "last_activity_date": "2015-06-25T01:30:00.127", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2687", "parent_id": "11693", "post_type": "answer", "score": 6 } ]
11693
null
11701
{ "accepted_answer_id": null, "answer_count": 1, "body": "deque関数を受け取ったキューの先頭を返し、 先頭以外が残るようにしたいのですがご教授お願いいたします。\n\n/* basetypes.c */\n\n```\n\n #include <stdlib.h>\n #include <stdio.h>\n #include \"basetypes.h\"\n \n PCB *pcb_new (int start, int required)\n {\n PCB *pcb = (PCB *)malloc(sizeof(PCB));\n pcb->next = NULL;\n pcb->pid = 0; \n pcb->state = READY;\n pcb->waiting_time = 0;\n pcb->executed_time = 0;\n pcb->start_time = start; \n pcb->required_time = required; \n return pcb;\n } \n \n void pcb_enqueue(PCB *pcb, PCB **q)\n {\n if (*q == pcb) {\n printf(\"Failed!!!\\n\");\n exit(0);\n }\n pcb->next = NULL;\n if (! *q)\n *q = pcb;\n else {\n PCB *p = *q;\n while (p->next != NULL) {\n p = p->next;\n }\n if (p->next == pcb) {\n printf(\"Failed!!!\\n\");\n exit(0);\n }\n p->next = pcb;\n }\n }\n \n PCB *pcb_dequeue(PCB **q)\n {\n PCB *pcb;\n if (! *q)\n return NULL;\n PCB *p = (*q);\n pcb = (*q)->next;\n (*q) = pcb;\n return p;\n }\n \n void pcb_print_list(PCB *top)\n {\n if (top == NULL) {\n printf(\"[]\");\n }\n else {\n while(top != NULL){\n printf(\"[pid%d,%d,%d]\", top->pid, top->start_time, top->required_time);\n top=top->next;\n if (top)\n printf(\", \");\n }\n }\n printf(\"\\n\");\n }\n \n int main (void)\n {\n /* 変数の宣言 */\n PCB *p1 = pcb_new(0, 1);\n PCB *p2 = pcb_new(1, 2);\n PCB *p3 = pcb_new(2, 3);\n PCB *p4 = pcb_new(3, 4);\n PCB *p5 = pcb_new(4, 5);\n PCB *x1;\n /* pcb_enqueue */\n pcb_enqueue(p2, &p1);\n pcb_enqueue(p3, &p1);\n pcb_enqueue(p4, &p1);\n pcb_enqueue(p5, &p1);\n pcb_print_list(p1);\n /* pcb_dequeue */\n x1 = pcb_dequeue(&p1);\n pcb_print_list(x1);\n pcb_print_list(p1);\n \n return 0;\n }\n \n```\n\n/* basetypes.h */\n\n```\n\n #define BASETYPES_H\n typedef int boolean;\n #define true (1 == 1)\n #define false 0\n \n typedef enum { RUNNING, READY, WAITING } Pstate;\n \n /* Process Control Block */\n typedef struct PCB {\n struct PCB *next;\n int pid; /* Process ID */\n Pstate state; /* joutai */\n int waiting_time; /* jikkoumachi deno keika jikan */\n int executed_time; /* jikkou zumi jikan */\n int start_time; /* seisei jikoku */\n int finished_time; /* shuryo jikoku */\n int required_time; /* hituyou jikan */\n } PCB;\n \n /* PCB comparing function type */\n typedef PCB *(pcb_compare_function)(PCB *, PCB *);\n \n PCB *pcb_new(int, int);\n void pcb_enqueue(PCB *, PCB **);\n PCB *pcb_dequeue(PCB **);\n void pcb_remove(PCB *, PCB **);\n void pcb_print_list(PCB*);\n \n int current_clock;\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T15:17:28.553", "favorite_count": 0, "id": "11694", "last_activity_date": "2015-09-03T14:29:36.797", "last_edit_date": "2015-09-03T14:29:36.797", "last_editor_user_id": null, "owner_user_id": "10019", "post_type": "question", "score": 1, "tags": [ "c" ], "title": "deque関数を受け取ったキューの先頭を返し、 先頭以外が残るようにしたい", "view_count": 435 }
[ { "body": "取り出した先頭要素のリンク先に NULL を指定してあげれば良いのではないでしょうか。\n\n```\n\n PCB *pcb_dequeue(PCB **q)\n {\n if (! *q)\n return NULL;\n PCB *p = *q;\n *q = (*q)->next;\n p->next = NULL;\n return p;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-24T15:44:44.760", "id": "11696", "last_activity_date": "2015-06-24T15:44:44.760", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "11694", "post_type": "answer", "score": 5 } ]
11694
null
11696
{ "accepted_answer_id": "11724", "answer_count": 1, "body": "以下のサイトに書いてある通りにangularJSのCSRF対策をしたいと考えています。 \n<https://docs.angularjs.org/api/ng/service/>$http \nそこで以下のサイトを参考にしてCookieにトークンを保存しようとしました。 \n<https://code.angularjs.org/1.3.14/docs/api/ngCookies/service/>$cookies\n\n```\n\n $cookies.XSRF-TOKEN = data['token'];\n \n```\n\nしかしこれでは\n\n```\n\n Uncaught ReferenceError: Invalid left-hand side in assignment\n \n```\n\nというエラーがでてできませんでした。 \nおそらくXSRF-TOKENが悪いのだと考えていますがこの場合どのようにして解決すればいいのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T00:06:59.597", "favorite_count": 0, "id": "11699", "last_activity_date": "2015-06-25T11:03:11.293", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "angularjs", "security", "cookie" ], "title": "angularJSのCSRF対策をしたい", "view_count": 389 }
[ { "body": "XSRF-TOKENが引き算でないのなら\n\n```\n\n $cookies['XSRF-TOKEN'] = data['token'];\n \n```\n\nと書けばいいと思いますが", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T11:03:11.293", "id": "11724", "last_activity_date": "2015-06-25T11:03:11.293", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8136", "parent_id": "11699", "post_type": "answer", "score": 3 } ]
11699
11724
11724
{ "accepted_answer_id": null, "answer_count": 0, "body": "やりたいことは表題の通りなのですが以下に詳細を付け加えておきます。\n\n■作りたいもの \n対象のお店をストリートビューで表示させることです。件数が数万件に及ぶのでAPIで対応したいと考えています。\n\n■やっていること \nグーグルストリートビューAPIでお店のジオコードの最寄りのストリートビュー対象エリア(道路)を取得。そこから対象の建物の方角を取得して表示。\n\n■問題点 \n都内のお店はインドアビューを設定されているところが多く、最寄りのストリートビュー対象地点としてインドアビューが表示されてしまいます。\n\n■解決したいこと \nストリートビューAPIでインドアビューを除外するような方法は有るのでしょうか?\n\nお手数ですが、もしお分かりになるようでしたらご教授の程、よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T00:57:41.543", "favorite_count": 0, "id": "11700", "last_activity_date": "2015-06-25T00:57:41.543", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10279", "post_type": "question", "score": 3, "tags": [ "google-maps" ], "title": "GoogleストリートビューAPIでインドアビューを除外したい", "view_count": 314 }
[]
11700
null
null
{ "accepted_answer_id": "11704", "answer_count": 3, "body": "一般的には以下の命名が通例かと思われます。 \n国内のみの利用ですので日本語での命名についてはご容赦下さい。\n\nテーブル名: **商品マスタ** または 商品テーブル \nフィールド: **商品コード** ,商品名,単価\n\n熟練した方からの命名提案 \nテーブル名: **商品** \nフィールド: **商品** ,商品名,単価\n\n利点として \nマスタという言葉が冗長であるので省略できる \nコードという言葉が全てのテーブルに出てくるので省略可能である \nプログラム側で入力文字数の削減が可能である\n\n英語であればitem **s** とSを付けてテーブル名を作成することが可能ですが、 \nテーブル名が商品だけですと違和感を感じてしまいます。 \n日本語ですと商品群というイメージしにくいテーブル名になってしまいます。\n\n~コードを省略することについても、実際に商品コードは想像できても \n商品というフィールドから商品コードは想像できないような気がします。\n\n皆様の現場ではテーブルとフィールドにどのような命名を行っていますでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T02:14:59.137", "favorite_count": 0, "id": "11702", "last_activity_date": "2015-06-26T21:24:54.680", "last_edit_date": "2015-06-26T21:24:54.680", "last_editor_user_id": "7462", "owner_user_id": "7462", "post_type": "question", "score": 2, "tags": [ "sql" ], "title": "SQL テーブル フィールド 命名規則について", "view_count": 3272 }
[ { "body": "個人的な意見ではありますが、テーブル名で\"商品\"を示しているので、商品の属性であるカラム名には、\"商品\"をつけないで定義します。\n\n * 商品テーブル \n * コード\n * 名称\n * 単価\n\nという感じでしょうか。\n\nただしRDBを使う都合上、1つのテーブルに他のテーブルのコードを持つこともあるでしょうから、その時は\"他テーブル名\"+\"コード\"としています。\n\nテーブル名に「テーブル」をつけるか否かについては、私は「つけるべき」と思っており、RDBを使うシステムでは、たいていテーブル以外にもビューを使うことも少なくありませんので、つけております。\n\nご参考になれば幸いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T02:31:18.673", "id": "11704", "last_activity_date": "2015-06-25T02:31:18.673", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5778", "parent_id": "11702", "post_type": "answer", "score": 4 }, { "body": "PKeyとなりうる商品コードは他のテーブルに外部キーなどで値がコピーされていくため、 \nテーブルと独立して識別できるべきものです。省略はしません。\n\nテーブル名: **商品** \nフィールド: **商品コード** , 商品名, 単価\n\nとします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T03:58:12.317", "id": "11707", "last_activity_date": "2015-06-25T03:58:12.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8431", "parent_id": "11702", "post_type": "answer", "score": 4 }, { "body": "基本的な考え方は\n\nテーブル名:そのテーブルが何の集合かを示す \nフィールド名:テーブルに含まれる個々の対象の属性を示す \nでしょう。なので素直には\n\nテーブル名:商品 \nフィールド名:コード、名前、単価\n\nとなります。少なくともSQLの文脈上ではこれで十分に誤解無く識別できます。\n\nテーブル名に「テーブル」とか「マスタ」とかつける文化もありますが、その場の文化の話なのでお好きにどうぞと言う話になります。\n\n英語の\"item\"\n\"items\"の対比から「商品」「商品群」とすべし、というのは、日本語では単数複数の区別をしないので同じ理屈でどちらも「商品」とすべきとも言えるのであまり理由にならないでしょう。「テーブル」などとおなじ接尾辞の一種としてそれをつけるなら上記と同じく「お好きにどうぞ」という話です。\n\nフィールド名について、特に主キーについては、\n\n * JOINの結合条件指定でONが使えるので一意とすべき\n * 主キーはすべて「ID」「コード」としたほうがわかりやすい\n\nという相反するがどちらももっともな理由があるので、どちらを選択するかはこれも文化の話になります。\n\n主キー名が`商品`というのは、属性を表してないのでこれは明らかにおかしいと言えます。\n\n他のフィールド名について、「一意となる名前がよい」という主張もありますが、これを突き詰めると`テーブル名+属性名`、例えば`商品_名前`のような命名規則になってしまうのであまり意味がないと思います。\n\n`商品名`については、日本語的には十分簡潔なので、`名前`ではなく`商品名`を使うのにはあまり違和感がありません。その場合は他のテーブルでも同様に「○○名」を使うようにすべきです。統一できないのなら`名前`にしたほうがよいでしょう。また、`単価`を`商品単価`とするのは冗長です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T00:28:18.783", "id": "11743", "last_activity_date": "2015-06-26T00:28:18.783", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "11702", "post_type": "answer", "score": 2 } ]
11702
11704
11704
{ "accepted_answer_id": null, "answer_count": 1, "body": "こんにちは。 \n今まで、FacebookからRSSが出力されていてそれを利用していたのですが、RSSが出力されなくなったのに本日気づきました。 \n何か仕様が変わったのでしょうか?\n\n<http://www.facebook.com/feeds/page.php?id=>(ID番号)&format=rss20\n\nとして使っていました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T03:47:33.053", "favorite_count": 0, "id": "11706", "last_activity_date": "2015-08-24T10:26:02.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10283", "post_type": "question", "score": 2, "tags": [ "facebook" ], "title": "FacebookからRSS出力を取得する方法", "view_count": 419 }
[ { "body": "仕様が変わってRSSはそのままでは取得できなくなったようです。 \n<https://developers.facebook.com/docs/apps/changelog?locale=en_US#v2_3_90_day_deprecations>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T09:02:59.523", "id": "11718", "last_activity_date": "2015-06-25T09:02:59.523", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7900", "parent_id": "11706", "post_type": "answer", "score": 1 } ]
11706
null
11718
{ "accepted_answer_id": null, "answer_count": 2, "body": "GNU RadioをUbuntuにインストールして \nsudo wget <http://www.sbrac.org/files/build-gnuradio> \nsudo chmod a+x ./build-gnuradio \nsudo ./build-gnuradioを端末に入力すると \n./build-gnuradio: 1: ./build-gnuradio: cannot open !DOCTYPE: No such file \n./build-gnuradio: 1: ./build-gnuradio: HTML: not found \n./build-gnuradio: 2: ./build-gnuradio: cannot open html: No such file \n: not foundradio: 3: ./build-gnuradio: \n./build-gnuradio: 4: ./build-gnuradio: cannot open META: No such file \n./build-gnuradio: 5: ./build-gnuradio: cannot open META: No such file \n./build-gnuradio: 5: ./build-gnuradio: http-equiv=Content-Type: not found \n./build-gnuradio: 6: ./build-gnuradio: cannot open META: No such file \n./build-gnuradio: 6: ./build-gnuradio: http-equiv=Content-Style-Type: not\nfound \n./build-gnuradio: 7: ./build-gnuradio: cannot open title: No such file \n: not foundradio: 8: ./build-gnuradio: NW�F�E���u�V�X�e���@���O�C����� \n./build-gnuradio: 9: ./build-gnuradio: cannot open /title: No such file \n./build-gnuradio: 10: ./build-gnuradio: cannot open body: No such file \n./build-gnuradio: 11: ./build-gnuradio: cannot open center: No such file \n./build-gnuradio: 12: ./build-gnuradio: cannot open img: No such file \n./build-gnuradio: 13: ./build-gnuradio: cannot open h1: No such file \n./build-gnuradio: 14: ./build-gnuradio: cannot open TABLE: No such file \n./build-gnuradio: 15: ./build-gnuradio: cannot open TBODY: No such file \n./build-gnuradio: 16: ./build-gnuradio: cannot open TR: No such file \n./build-gnuradio: 17: ./build-gnuradio: Syntax error: redirection unexpected\n\n最後にSyntax error: redirection unexpectedが出てきます。 \n文字化けもしていてファイルもありません。 \nGNU Radioのパッケージを入れたいのですがどうすればいいかわかりません \nもしよろしければ教えていただきたいです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T05:00:33.280", "favorite_count": 0, "id": "11708", "last_activity_date": "2015-08-01T23:58:31.390", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10284", "post_type": "question", "score": 1, "tags": [ "ubuntu" ], "title": "Syntax error: redirection unexpected と出てきます。", "view_count": 691 }
[ { "body": "エラーメッセージから推察するに、`./build-gnuradio` ファイルが HTML ファイルになっているのではないでしょうか。`./build-\ngnuradio` ファイルの内容をご確認される事をお勧めします。\n\nちなみに、手元の Ubuntu 15.04 で `build-gnuradio` を実行すると以下の様に表示されます。\n\n```\n\n $ sudo ./build-gnuradio\n Please run this script as an ordinary user\n it will acquire root privileges as it needs them via \"sudo\".\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T05:23:47.057", "id": "11709", "last_activity_date": "2015-06-25T05:23:47.057", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "11708", "post_type": "answer", "score": 1 }, { "body": "GNU RadioはUbuntuのパッケージでいれればいいのだから`sudo apt-get install\ngnuradio`でOK。自分でビルドしなくていいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T23:34:22.440", "id": "11978", "last_activity_date": "2015-07-02T23:34:22.440", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7837", "parent_id": "11708", "post_type": "answer", "score": 1 } ]
11708
null
11709
{ "accepted_answer_id": "11716", "answer_count": 1, "body": "intとStringの2つのメンバ変数をもったオリジナルクラスItemを作成しました。 \nMainActivityでは、Itemのリストを作成しています。\n\nItem.java\n\n```\n\n public class Item{\n \n int id;\n String name;\n \n Item(int id,String name){\n this.id = id;\n this.name = name;\n }\n \n```\n\nMainActivity.java\n\n```\n\n Item item1 = new Item(\"111\",\"TANAKA\");\n Item item2 = new Item(\"222\",\"MATUMOTO\");\n Item item3 = new Item(\"333\",\"UEDA\");\n ArrayList<Item> itemList = new ArrayList<Item>();\n itemList.add(item1);\n itemList.add(item2);\n itemList.add(item3);\n \n```\n\n上のitemListはアプリが起動している間は使えますが、 \nアプリが終了すると空になってしまい、次回起動時には使えません。 \nArrayListを保存して、永続化させる方法をご教示ください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T07:36:06.467", "favorite_count": 0, "id": "11712", "last_activity_date": "2015-06-25T08:50:44.020", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7699", "post_type": "question", "score": 0, "tags": [ "android" ], "title": "ArrayList<CustomClass>を保存して、次回起動時に読み出したい", "view_count": 227 }
[ { "body": "JacksonやGSONを使ってjsonに変換し、PreferenceやSQLiteに保存する方法はいかがでしょう?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T08:50:44.020", "id": "11716", "last_activity_date": "2015-06-25T08:50:44.020", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8216", "parent_id": "11712", "post_type": "answer", "score": 0 } ]
11712
11716
11716
{ "accepted_answer_id": "11723", "answer_count": 2, "body": "お世話になります。\n\nC#のListBoxで、ValueMemberとDisplayMemnerを設定した後、 \n自由に項目を削除したいと考えています。\n\n下記の様なソースで、初めにDataTableで管理できるようにし、addItemメソッドで \n項目を追加するところまで作成しました。\n\n```\n\n public void init()\n {\n this.Font = new System.Drawing.Font(\"MSゴシック\", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));\n this.ScrollAlwaysVisible = true;\n \n this.Items.Clear();\n \n //DataTableオブジェクトを用意\n dtItem = new DataTable();\n \n //DataTableに列を追加\n dtItem.Columns.Add(\"VALUE\", typeof(string));\n dtItem.Columns.Add(\"NAME\", typeof(string));\n \n //リストボックスのDataSourceにDataTableを割り当てる\n this.DataSource = dtItem;\n \n //表示される値はDataTableのNAME列\n this.DisplayMember = \"NAME\";\n \n //対応する値はDataTableのValue列\n this.ValueMember = \"VALUE\";\n \n }\n \n public void addItem(string id,string name)\n {\n //新しい行を作成\n DataRow row = dtItem.NewRow();\n \n //各列に値をセット\n row[\"VALUE\"] = id;\n row[\"NAME\"] = name;\n dtItem.Rows.Add(row);\n }\n \n```\n\nここから、removeItem(string id)などのようなメソッドで、 \n項目が削除できると良いのですが、DataTable.Rows.Removeメソッドなどでは \nDataRowを渡さなければならなかったり、どのように削除を行えばよいのか、 \n途方に暮れています。\n\n解決方法をお教えいただけないでしょうか。\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T07:39:33.097", "favorite_count": 0, "id": "11713", "last_activity_date": "2015-06-25T11:00:49.517", "last_edit_date": "2015-06-25T08:38:39.630", "last_editor_user_id": "8870", "owner_user_id": "9374", "post_type": "question", "score": 2, "tags": [ "c#", "winforms" ], "title": "C# ValueMemberやDisplayMemberを設定したListBoxから項目を削除する方法", "view_count": 2611 }
[ { "body": "ソースがDataTableと予め判っているなら、DataViewを作ってFindRowsするのが楽です。 \nそうでなくソースが不定な状態であるなら以下のように、ListBox.DataManagerからCurrentcyManagerを取って、そこからDataViewを取り出すことができます。\n\nDataViewが取れれば後はValueMemberをキーにして検索するとDataRowViewが得られるので、そのDataRowView.Rowが対象のDataRowになります。\n\n```\n\n public void RemoveItemByID(string id) //このコードはListBoxを継承したクラス内のいうメソッド\n {\n var manager = this.DataManager as CurrencyManager;\n if (manager == null)\n {\n return;\n }\n \n if (manager.Count == 0)\n {\n return;\n }\n \n var dv = manager.List as System.Data.DataView;\n if (dv != null && false)\n {\n var dt = dv.Table;\n var column = dt.Columns[this.ValueMember];\n if (dt.PrimaryKey != null && dt.PrimaryKey.Length == 1 && dt.PrimaryKey[0] == column)\n {\n //プライマリーキーならそのままをキーにして削除\n int index = dv.Find(id);\n dv.Delete(index);\n }\n else\n {\n //見つかったのを入れておくリスト\n List<DataRow> foundRows = new List<DataRow>();//プライマリーキーでない場合は複数見つかる可能性がある\n \n if (false)\n {\n //プライマリーキーでない場合は一時的にDataViewを作って\n //そのDataViewで検索を行う\n var dvTemp = new System.Data.DataView(dv.Table);\n dvTemp.Sort = this.ValueMember;//検索する列名を指定\n \n \n foreach (DataRowView drv in dvTemp.FindRows(id))\n {\n foundRows.Add(drv.Row);\n }\n //見つかったのを削除\n foreach (DataRow row in foundRows)\n {\n dv.Table.Rows.Remove(row);\n }\n }\n else\n {\n //DataViewを作るまでもないなら自分で探す\n foreach (DataRowView drv in dv)\n {\n object value = drv[this.ValueMember];\n if ((value == null && id == null)\n || (value != null && id == value.ToString()))\n {\n foundRows.Add(drv.Row);\n }\n }\n }\n \n foreach (DataRow row in foundRows)\n {\n dv.Table.Rows.Remove(row);\n }\n }\n \n }\n else\n {\n //DataViewでないならIBindingListか調べる\n var bindingList = manager.List as System.ComponentModel.IBindingList;\n if (bindingList != null)\n {\n var props = System.ComponentModel.TypeDescriptor.GetProperties(bindingList[0]);\n foreach (System.ComponentModel.PropertyDescriptor pd in props)\n {\n if (pd.Name == this.ValueMember)\n {\n var index = bindingList.Find(pd, id);\n if (index >= 0)\n {\n bindingList.RemoveAt(index);\n }\n break;\n }\n }\n }\n else\n { //IBindingListですらないなら全部をリフレクションで\n for (int index = this.Items.Count - 1; index >= 0; --index)\n {\n object o = this.Items[index];\n if (o != null)\n {\n var pi = o.GetType().GetProperty(this.ValueMember);\n if (pi != null)\n {\n object value = pi.GetValue(o, null);\n if ((value == null && id == null)\n || (value != null && id == value.ToString()))\n {\n this.Items.Remove(index);\n }\n }\n }\n }\n }\n }\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T10:54:08.737", "id": "11721", "last_activity_date": "2015-06-25T10:54:08.737", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4926", "parent_id": "11713", "post_type": "answer", "score": 1 }, { "body": "一番基礎的な方法はループによるものです。削除時にインデックスが変わるため逆順ループにしています。\n\n```\n\n for (var i = dtItem.Rows.Count - 1; i >= 0; i--)\n {\n var row = dtItem.Rows[i];\n if (id.Equals(row[\"VALUE\"]))\n {\n dtItem.Rows.Remove(row);\n // 一件削除ならbreak;する\n }\n }\n \n```\n\nLINQを使う場合は以下の通りです。\n\n```\n\n var row = dtItem.AsEnumerable().FirstOrDefault(_ => _.Field<string>(\"VALUE\") == id);\n if (row != null)\n {\n dtItem.Rows.Remove(row);\n }\n \n```\n\n複数行削除であれば`ToArray()`などで削除対象を一時的なリストに格納します。\n\n```\n\n var rows = dtItem.AsEnumerable().Where(_ => _.Field<string>(\"VALUE\") == id).ToArray();\n foreach (var row in rows)\n {\n dtItem.Rows.Remove(row);\n }\n \n```\n\nレガシーな手法ですが、`DataRow`の抽出には`Select`という手もあります。\n\n```\n\n var rows = dtItem.Select(\"VALUE='\" + id + \"'\");\n \n //以下略\n \n```\n\nまたテーブルに主キーを設定しておけば`Find`で検索できます。\n\n```\n\n // 一度だけ実行する\n dtItem.PrimaryKey = new[] { dtItem.Columns[\"VALUE\"] };\n \n var row = dtItem.Rows.Find(id);\n \n //以下略\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T11:00:49.517", "id": "11723", "last_activity_date": "2015-06-25T11:00:49.517", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "11713", "post_type": "answer", "score": 1 } ]
11713
11723
11721
{ "accepted_answer_id": "11765", "answer_count": 1, "body": "CakePHP1.3でAPIの開発しています。 \nビューには下記のようにjson_encodeが1行書かれているのみです。\n\n```\n\n echo json_encode($result);\n \n```\n\nすべてのAPIビューは同じ内容を書くので、ビューファイルを共通化したいと考えました。 \nアクションにrender()を書くとビューファイルを共通化できました。\n\n```\n\n $this->render(null, null, VIEWS . \"api.json\");\n \n```\n\nしかし、これでは全てのアクションに上記の記述を書かなければなりません。 \nそこで、app_controller.phpなどにビューの指定をまとめて記述する方法があるかを教えていただきたいです。\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T07:55:16.190", "favorite_count": 0, "id": "11714", "last_activity_date": "2015-06-26T06:20:36.310", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4098", "post_type": "question", "score": 1, "tags": [ "php", "cakephp" ], "title": "CakePHP1.3でビューを共通化する方法を教えて下さい。", "view_count": 152 }
[ { "body": "アクション毎に特別な設定を行わずAppController等で共通化するのであれば、次の2つのやり方が考えられます。\n\n 1. 2.x系のJsonViewを移植し、`AppController::beforeFilter()`でビュークラスを切り替える。\n 2. `AppController::beforeRender()`で、レンダリングを行い終了させる。\n\n1の方が望ましいと考えますが、ここではより簡易にできる2の方法を示します。\n\n`app/config/routes.php`に追加\n\n```\n\n Router::parseExtensions();\n \n```\n\n`app/app_controller.php`\n\n```\n\n <?php\n class AppController extends Controller {\n public $components = array('RequestHandler', // ... (他にあれば追記) );\n \n // (...snip...)\n \n public function beforeRender() {\n if ($this->RequestHandler->ext === 'json') {\n // リクエストされたURLの拡張子がjsonであれば\n Configure::write('debug', 0);\n // レンダリング\n $this->RequestHandler->respondAs('json');\n $View = new View($this);\n echo $View->render('/json/default');\n // 終了処理\n $this->_stop();\n }\n }\n \n // (...snip...)\n \n }\n \n```\n\n`app/view/json/default.ctp`\n\n```\n\n <?php\n echo json_encode($result, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);\n \n```\n\nこれで、`/foo/bar.json`\nのようなURLでアクセスされた場合に、`app/view/json/default.ctp`でレンダリングされるようになります。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T06:20:36.310", "id": "11765", "last_activity_date": "2015-06-26T06:20:36.310", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2668", "parent_id": "11714", "post_type": "answer", "score": 1 } ]
11714
11765
11765
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n import java.io.*;\n \n public class Many years calendar\n {\n public static void main(String[] args) throws Exception{\n BufferedReader in = \n new BufferedReader(new InputStreamReader(System.in));\n \n System.out.print(\"年は?: \");\n String str1 = in.readLine();\n System.out.print(\"月は?: \");\n String str2 = in.readLine();\n \n int year = Integer.parseInt(str1);\n int month = Integer.parseInt(str2);\n int dow = dayofweek(year, month);\n int dim = daysinmonth(year, month);\n \n showcal(dow, dim);\n }\n \n // カレンダーを表示する\n public static void showcal(int dow, int days) throws Exception{\n System.out.println(\"日 月 火 水 木 金 土\");\n \n int d = 1;\n int i;\n \n // 最初の週の表示 \n for(i = 0; i < dow; i++){\n System.out.print(\" \");\n }\n for(; i < 7; i++){\n System.out.print(\" \" + d + \" \");\n d++;\n }\n System.out.println();\n \n // 二週目以降の表示\n for(int j = 0; d <= days; j++){\n for(i = 0; i < 7 && d <= days; i++){\n if(d < 10)\n System.out.print(\" \" + d + \" \");\n else\n System.out.print(d + \" \");\n d++;\n }\n System.out.println();\n }\n }\n \n // 月の日数をかえす\n public static int daysinmonth(int year, int month) throws Exception{\n int dim = 31;\n if(month == 4 || month == 6 || month == 9 || month == 11)\n dim = 30;\n if(month == 2){\n if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)\n dim = 29; // うるう年\n else\n dim = 28;\n }\n return dim;\n }\n \n // 年の日数をかえす\n public static int daysinyear(int year) throws Exception{\n int diy;\n if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)\n diy = 366; // うるう年\n else\n diy = 365;\n return diy;\n }\n \n // 月の初日の曜日をかえす\n public static int dayofweek(int year, int month) throws Exception{\n int days = 0;\n int y = 0, m = 0;\n int dow = 0;\n \n // 2000年以降\n if(year >= 2000){\n for(y = 2000; y < year; y++){\n days = days + daysinyear(y);\n }\n for(m = 1; m < month; m++){\n days = days + daysinmonth(year, m);\n }\n dow = (days + 6) % 7;\n }\n \n // 1999年以前\n else{\n for(m = month; m <= 12; m++){\n days = days + daysinmonth(year, m);\n }\n for(y = year + 1; y < 2000; y++){\n days = days + daysinyear(y);\n }\n dow = 6 - days % 7;\n }\n return dow;\n }\n }\n \n```\n\n上のjavaのやつをcalendar obj = new calendar2();もいれて、コンパイルして、calendar2.classとMany\nyears calendar.classを出したいのです。\n\nどうやったらいいか分かりますか?\n\nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T07:57:27.660", "favorite_count": 0, "id": "11715", "last_activity_date": "2015-07-10T01:06:42.273", "last_edit_date": "2015-07-10T01:06:42.273", "last_editor_user_id": "3516", "owner_user_id": "10289", "post_type": "question", "score": 0, "tags": [ "java" ], "title": "Calendar2(calendar2は元コードに見当たらないですが...)", "view_count": 137 }
[ { "body": "まずこのクラスを Many years calendarから Many_years_calendar に変えます。 \nファイル名とクラス名は一致させる必要があるため、Many_years_calendar.javaの名前に変更してください。\n\nまた、\n\n> calendar obj = new calendar2();もいれて、コンパイルして、calendar2.classとMany years\n> calendar.classを出したい\n\nとありますが、Many_years_calendarクラスからcalendar2クラスを利用している箇所はありません。これは何故コンパイルする必要があると思われたのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T02:44:02.470", "id": "11749", "last_activity_date": "2015-06-26T02:44:02.470", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5778", "parent_id": "11715", "post_type": "answer", "score": 1 } ]
11715
null
11749
{ "accepted_answer_id": "11737", "answer_count": 1, "body": "```\n\n ApiManager.getSuggestions(newText, {\n \n receiver ->\n \n val keywords = receiver.receive()\n \n if (keywords.isEmpty()) {\n \n self.updateKeywordList(arrayOf(newText), \"このキーワードで検索\")\n \n } else {\n \n self.updateKeywordList(keywords, \"以下のキーワードで検索\")\n \n }\n \n \n }\n \n```\n\n言語コトリンについて質問させてください \n質問1 ->はラムダ式でしょうか? \n質問2 receiverに対してどんな処理が行われていますか? \n質問3 オブジェクトApiManagerに対してどんな処理が行われています?\n\nいただいた解答によってkotlinとAndroidについて理解を深めようとしています。 \n質問の仕方が悪いかもしれませんがご指摘いただければ直したいと思います。 \nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T09:01:29.980", "favorite_count": 0, "id": "11717", "last_activity_date": "2015-06-25T15:06:46.470", "last_edit_date": "2015-06-25T11:52:18.087", "last_editor_user_id": "3639", "owner_user_id": "10291", "post_type": "question", "score": 2, "tags": [ "android-studio", "kotlin" ], "title": "言語kotlinの->はラムダ式でしょうか?", "view_count": 427 }
[ { "body": "質問1\n\nはい。 \n->はラムダ式の引数リストとボディを分けるための記号です。\n\n質問2, 3\n\n実際のコードを見ないことには何とも言えませんが \nreceiverはgetSuggestionsの結果のコールバック関数の引数のようです。 \nreceiver.receive()で、受け取った結果のキーワードを取得しているようですね。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T15:06:46.470", "id": "11737", "last_activity_date": "2015-06-25T15:06:46.470", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10296", "parent_id": "11717", "post_type": "answer", "score": 1 } ]
11717
11737
11737
{ "accepted_answer_id": "11764", "answer_count": 1, "body": "AudioUnitを用いてマイク入力信号を色々編集するプログラムを書こうとしたのですが、一向に上手く行かないので質問させていただきます。\n\nやりたいこと \nマイク入力信号→LPF→コールバック関数( AUNode は二つになるのでしょうか?)\n\n確認済なこと \nマイク入力信号→コールバック関数( AUNode は変数名 inNode 1つです)\n\n環境 \niOS 7.1.1\n\nバグ \n以下のソースの直後のAuGraphStart(mAuGraph)でプログラムが落ちる。 \nエラーすら出ないときと、OSStatusのエラーコード10863が得られるときがある。\n\n質問内容 \n上記バグを修正するにはどのように変更したら良いのでしょうか\n\nソース\n\n```\n\n OSStatus status;\n \n NewAUGraph(&mAuGraph);\n AUGraphOpen(mAuGraph);\n \n AUNode inNode;\n //AudioUnit inUnit;\n AudioComponentDescription acd;\n acd.componentType = kAudioUnitType_Output;\n acd.componentSubType = kAudioUnitSubType_RemoteIO;\n acd.componentManufacturer = kAudioUnitManufacturer_Apple;\n acd.componentFlags = testAcd.componentFlagsMask = 0;\n AUGraphAddNode(mAuGraph, &acd, &inNode);\n AUGraphNodeInfo(mAuGraph, inNode, NULL, &_inUnit);\n \n //LPF設定\n AUNode lpfNode;\n //AudioUnit lpfUnit;\n acd.componentType = kAudioUnitType_Effect;\n acd.componentSubType = kAudioUnitSubType_kAudioUnitSubType_LowPassFilter;\n AUGraphAddNode(mAuGraph, &acd, &lpfNode);\n AUGraphNodeInfo(mAuGraph, lpfNode, NULL, &_lpfUnit);\n AudioUnitSetParameter(_lpfUnit,\n kLowPassParam_CutoffFrequency,\n kAudioUnitScope_Global,\n 0,\n 300,\n 0),\n \n \n \n //マイク入出力設定\n UInt32 flag = 1;\n AudioUnitSetProperty(_inUnit,\n kAudioOutputUnitProperty_EnableIO,\n kAudioUnitScope_Input,\n 1,\n &flag,\n sizeof(UInt32));\n status = AudioUnitSetProperty(_inUnit,\n kAudioOutputUnitProperty_EnableIO, \n kAudioUnitScope_Output,\n kOutputBus,\n &flag,\n sizeof(flag));\n \n AudioStreamBasicDescription audioFormat;\n audioFormat.mSampleRate = 22050;\n audioFormat.mFormatID = kAudioFormatLinearPCM;\n audioFormat.mFormatFlags = kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger;\n audioFormat.mBitsPerChannel = 16;\n audioFormat.mChannelsPerFrame = 1;\n audioFormat.mBytesPerFrame = 2;\n audioFormat.mFramesPerPacket = 1;\n audioFormat.mBytesPerPacket = 2;\n AudioUnitSetProperty(_inUnit,\n kAudioUnitProperty_StreamFormat,\n kAudioUnitScope_Output,\n 1,\n &audioFormat,\n sizeof(audioFormat));\n \n //接続\n AUGraphConnectNodeInput(mAuGraph, inNode, 1, lpfNode, 0);\n \n //コールバック設定\n AURenderCallbackStruct callbackStruct;\n callbackStruct.inputProc = callbackfunc;\n callbackStruct.inputProcRefCon = (__bridge void *)(self);\n status = AudioUnitSetProperty(_lpfUnit,\n kAudioOutputUnitProperty_SetInputCallback,\n kAudioUnitScope_Global,\n kInputBus,\n &callbackStruct,\n sizeof(callbackStruct));\n \n flag = 0;\n \n status = AudioUnitSetProperty(_lpfUnit,\n kAudioUnitProperty_ShouldAllocateBuffer,\n kAudioUnitScope_Output,\n kInputBus,\n &flag,\n sizeof(flag));\n \n status = AudioUnitInitialize(_inUnit);\n status = AudioUnitInitialize(_lpfUnit);\n AUGraphInitialize(mAuGraph);\n CAShow(mAuGraph);\n \n```\n\n以上、ご教授ください。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T10:18:50.600", "favorite_count": 0, "id": "11719", "last_activity_date": "2015-06-26T06:18:41.833", "last_edit_date": "2015-06-25T11:24:07.930", "last_editor_user_id": "10065", "owner_user_id": "10065", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c", "iphone" ], "title": "iOS)AudioUnitを用いてマイク入力にLPFをかける方法について", "view_count": 1083 }
[ { "body": "iOS8 ですが以下のコードで動作確認しました。\n\nポイントは\n\n * マイク > エフェクト > スピーカ の流れではコールバック関数は必要ない\n * `kAudioUnitType_Effect` に設定できるオーディオのフォーマットは `float` でなければいけない(環境依存?)\n * `AudioGraph` を使用する場合は `AudioUnitInitialize` の関数で `AudioUnit` の初期化は必要ない。今回のコードには含まれていなですが破棄等も同様に必要なし。\n\n* * *\n```\n\n @interface MicInput ()\n {\n AUGraph _processingGraph;\n \n AUNode _ioNode;\n AudioUnit _ioUnit;\n AUNode _filterNode;\n AudioUnit _filterUnit;\n }\n \n @end\n \n @implementation MicInput\n \n - (void)start\n {\n OSStatus status;\n \n status = NewAUGraph(&self->_processingGraph);\n NSAssert(status == noErr, @\"NewAUGraph fail : %@\", @(status));\n status = AUGraphOpen(self->_processingGraph);\n NSAssert(status == noErr, @\"AUGraphOpen fail : %@\", @(status));\n \n {// AUNode の登録\n {// io\n AudioComponentDescription cd;\n cd.componentType = kAudioUnitType_Output;\n cd.componentSubType = kAudioUnitSubType_RemoteIO;\n cd.componentManufacturer = kAudioUnitManufacturer_Apple;\n cd.componentFlags = 0;\n cd.componentFlagsMask = 0;\n \n status = AUGraphAddNode(self->_processingGraph, &cd, &self->_ioNode);\n NSAssert(status == noErr, @\"AUGraphAddNode fail : %@\", @(status));\n }\n {// filter\n AudioComponentDescription cd;\n cd.componentType = kAudioUnitType_Effect;\n cd.componentSubType = kAudioUnitSubType_LowPassFilter;\n cd.componentManufacturer = kAudioUnitManufacturer_Apple;\n cd.componentFlags = 0;\n cd.componentFlagsMask = 0;\n \n status = AUGraphAddNode(self->_processingGraph, &cd, &self->_filterNode);\n NSAssert(status == noErr, @\"AUGraphAddNode fail : %@\", @(status));\n }\n }\n \n {// AudioUnit の取得\n // io\n status = AUGraphNodeInfo(self->_processingGraph, self->_ioNode, NULL, &self->_ioUnit);\n NSAssert(status == noErr, @\"AUGraphNodeInfo fail : %@\", @(status));\n // filter\n \n status = AUGraphNodeInfo(self->_processingGraph, self->_filterNode, NULL, &self->_filterUnit);\n NSAssert(status == noErr, @\"AUGraphNodeInfo fail : %@\", @(status));\n }\n \n {// processingGraph 内のフォーマットを統一する\n \n AudioStreamBasicDescription description;\n description.mSampleRate = 44100;\n description.mFormatID = kAudioFormatLinearPCM;\n description.mFormatFlags = kAudioFormatFlagIsFloat | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;\n description.mChannelsPerFrame = 1;\n description.mBytesPerPacket = sizeof(Float32);\n description.mBytesPerFrame = sizeof(Float32);\n description.mFramesPerPacket = 1;\n description.mBitsPerChannel = 8 * sizeof(Float32);\n description.mReserved = 0;\n \n // mic out\n status = AudioUnitSetProperty(self->_ioUnit,\n kAudioUnitProperty_StreamFormat,\n kAudioUnitScope_Output,\n 1,\n &description,\n sizeof(description));\n NSAssert(status == noErr, @\"AudioUnitSetProperty fail : %@\", @(status));\n \n // filter in\n status = AudioUnitSetProperty(self->_filterUnit,\n kAudioUnitProperty_StreamFormat,\n kAudioUnitScope_Input,\n 0,\n &description,\n sizeof(description));\n NSAssert(status == noErr, @\"AudioUnitSetProperty fail : %@\", @(status));\n \n // filter out\n status = AudioUnitSetProperty(self->_filterUnit,\n kAudioUnitProperty_StreamFormat,\n kAudioUnitScope_Output,\n 0,\n &description,\n sizeof(description));\n NSAssert(status == noErr, @\"AudioUnitSetProperty fail : %@\", @(status));\n \n // speaker in\n status = AudioUnitSetProperty(self->_ioUnit,\n kAudioUnitProperty_StreamFormat,\n kAudioUnitScope_Input,\n 0,\n &description,\n sizeof(description));\n NSAssert(status == noErr, @\"AudioUnitSetProperty fail : %@\", @(status));\n }\n \n {// マイク入力を有効化\n UInt32 flag = 1;\n AudioUnitSetProperty(self->_ioUnit,\n kAudioOutputUnitProperty_EnableIO,\n kAudioUnitScope_Input,\n 1,\n &flag,\n sizeof(UInt32));\n NSAssert(status == noErr, @\"AudioUnitSetProperty fail : %@\", @(status));\n }\n \n {// filter の設定\n AudioUnitSetParameter(self->_filterUnit,\n kLowPassParam_CutoffFrequency,\n kAudioUnitScope_Global,\n 0,\n 300,\n 0);\n NSAssert(status == noErr, @\"AudioUnitSetProperty fail : %@\", @(status));\n }\n \n // ioNode(mic out) -> filterNode -> ioNode(speaker in)\n status = AUGraphConnectNodeInput(self->_processingGraph,\n self->_ioNode, 1,\n self->_filterNode, 0);\n NSAssert(status == noErr, @\"AUGraphConnectNodeInput fail : %@\", @(status));\n \n status = AUGraphConnectNodeInput(self->_processingGraph,\n self->_filterNode, 0,\n self->_ioNode, 0);\n NSAssert(status == noErr, @\"AUGraphConnectNodeInput fail : %@\", @(status));\n \n status = AUGraphInitialize(self->_processingGraph);\n NSAssert(status == noErr, @\"AUGraphInitialize fail : %@\", @(status));\n \n AUGraphStart(self->_processingGraph);\n NSAssert(status == noErr, @\"AUGraphStart fail : %@\", @(status));\n }\n \n @end\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T06:18:41.833", "id": "11764", "last_activity_date": "2015-06-26T06:18:41.833", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5106", "parent_id": "11719", "post_type": "answer", "score": 1 } ]
11719
11764
11764
{ "accepted_answer_id": "11733", "answer_count": 1, "body": "Nokogiriを使い、`img`タグの`src`要素にアクセスする時に xpathなら\n\n```\n\n doc = Nokogiri::HTML(\"<img src='foo.jpg' />\")\n doc.xpath(\"//img/@src\")\n \n```\n\nで属性自体を直接指定できるのですが、cssセレクタですと\n\n```\n\n doc.css(\"img\").attr(\"src\")\n \n```\n\nという呼び出し方しか見つかりませんでした。属性名をCSSセレクタだけで呼び出す方法はありますか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T10:39:35.757", "favorite_count": 0, "id": "11720", "last_activity_date": "2015-06-25T14:10:55.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3271", "post_type": "question", "score": 0, "tags": [ "ruby", "nokogiri" ], "title": "CSSセレクタでXpathのように属性に直接アクセスできる記述方法", "view_count": 940 }
[ { "body": "厳密にはCSSセレクタではないと思いますが、`css` メソッドで取り出したいというだけであれば、\n\n```\n\n doc.css(\"img/@src\")\n \n```\n\nで取り出すことができるようです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T14:10:55.987", "id": "11733", "last_activity_date": "2015-06-25T14:10:55.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3249", "parent_id": "11720", "post_type": "answer", "score": 1 } ]
11720
11733
11733
{ "accepted_answer_id": null, "answer_count": 1, "body": "タイトルの通りです。ng-\ninitを使った、bindingされた値のviewからcontrollerへの渡し方について苦戦しているので質問させていただきました。\n\n1つのshopの中にn個のitem_listがあり、そのなかに紐付く形で複数のitemが格納されているという前提です。\n\nshop(1) -> item_list(n) -> item(n)\n\nこのような状況のとき、new_itemの追加フォームからitem_listに紐付いた新しいitemを追加しようとしているのですが、追加しようとしているitem_listのidの、controllerへの渡し方に悩んでいます...\n\nそのまま実行しようとすると、ng-\ninit時にまだ{{item_list.id}}に値が格納されていないため(合ってるか不安ですが)、undefinedとして渡されてしまいます。\n\nbindingされた値をcontrollerに渡すにはng-\ninitでは不可能なのでしょうか。また、その他にbestな方法がありましたらこの機会に教えていただきたいと思っています。どうかよろしくお願いいたします。\n\n```\n\n ul\n li ng-repeat=\"item_list in shop.item_lists\"\n span item_list.id -> {{item_list.id}}\n ul\n li ng-repeat=\"item in item_list.items\"\n span item.id -> {{item.id}}\n input type=\"submit\" value=\"削除\" ng-click=\"deleteItem(item)\"\n \n form id=\"new_item\" ng-submit=\"addItem(itemBody, itemListId)\"\n input type=\"text\" id=\"itemBody\" ng-model=\"itemBody\" ng-init=\"itemListId={{item_list.id}}\"\n input type=\"submit\" value=\"追加({{item_list.id}})\"\n \n```\n\n-\n```\n\n angular.module('angularApp').controller \"ShopController\", ($scope) ->\n $scope.addItem = (itemBody, itemListId) ->\n alert(itemBody)\n alert(itemListId)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T11:14:18.890", "favorite_count": 0, "id": "11725", "last_activity_date": "2015-06-29T00:57:54.647", "last_edit_date": "2015-06-29T00:57:54.647", "last_editor_user_id": "76", "owner_user_id": "10309", "post_type": "question", "score": 0, "tags": [ "javascript", "angularjs" ], "title": "ng-initを使った、bindingされた値のviewからcontrollerへの渡し方について", "view_count": 759 }
[ { "body": "shopの値が非同期で入っているので無ければ、\n\n```\n\n ng-init=\"itemListId=item_list.id\"\n \n```\n\nで値が入るのではないかと思います。\n\nそれ以前に、ng-initを消して、addItem(item_list.body,\nitem_list.id)と直接bind値を入れたほうが良いと思いますが。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T00:57:58.943", "id": "11744", "last_activity_date": "2015-06-26T00:57:58.943", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2232", "parent_id": "11725", "post_type": "answer", "score": 1 } ]
11725
null
11744
{ "accepted_answer_id": null, "answer_count": 0, "body": "WordPressでMemcacheを使ったオブジェクトキャッシュをしようと、[Memcached Object\nCacheプラグイン](https://wordpress.org/plugins/memcached/)の`object-cache.php`を`/wp-\ncontent/`以下に設置しました。\n\nすると、`PHP Fatal error: Class 'Memcache' not found`のエラーが出たので、指示通りに`sudo yum -y\ninstall php-pecl-memcache`を実行してMemcache Extensionを入れて、`service httpd\nrestart`でApache再起動しても同じ状況のままでした。 \n`Memcached`の方もインストールしてみても結果は同じでした。\n\n`/etc/php.d/memcache.ini`のファイルのは存在し、その中で`extension=memcache.so`で読み込んでいるのも確認しました。\n\nこの状況の解決方法をご存知の方いれば教えていただきたいです。お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T11:25:09.880", "favorite_count": 0, "id": "11726", "last_activity_date": "2015-06-25T11:25:09.880", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3691", "post_type": "question", "score": 1, "tags": [ "php", "wordpress", "memcached" ], "title": "PHPのMemcache Extensionを入れても、「PHP Fatal error: Class 'Memcache' not found」になる", "view_count": 1543 }
[]
11726
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "<http://blog.asial.co.jp/1403?category_id=21> \nこの通りにやってもうまく行きません。 \nまず、zipファイルをアップロードするとfailedとでます。URLでインストールしてもビルドが失敗します。どうすればいいでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T11:42:08.410", "favorite_count": 0, "id": "11727", "last_activity_date": "2016-06-10T10:59:20.260", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8748", "post_type": "question", "score": 1, "tags": [ "monaca" ], "title": "ローカル通知プラグインがインストールできない", "view_count": 379 }
[ { "body": "同じようになっていましたが解決しました。\n\nファイルはZIPでアップロードできました。GitHubの右側のDownloadZIPからダウンロードしたものをアップしました。 \n・プラグインをZIPファイルからインストール(GitHubのURLのからのインポートはファイルの修正ができないのでNG) \n・プラグインが足りていないのでインストール(ZIP) \ncordova-plugin-device \ncordova-plugin-android-support-v4 \n・cordova-plugin-android-support-v4の名前が違うので設定ファイルの記述を変更\n\n詳細は下記に記載してみましたのでご参考になれば。 \n<http://qiita.com/hironaito/items/b0bb0a3de3ba82fc8895>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-09-29T13:12:41.157", "id": "17067", "last_activity_date": "2015-09-29T13:12:41.157", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12494", "parent_id": "11727", "post_type": "answer", "score": 1 } ]
11727
null
17067
{ "accepted_answer_id": "11739", "answer_count": 1, "body": "`Selenium WebDrier`というのを今までブラウザそのものではなく、ブラウザを操作するものだと思っていたのですが、Railsのテストでは\nphantomjs か selenium かを選択する場面があり、ブラウザそのものとして扱われているようです。\n\n公式サイトを読んでみたのですが、いまいちよくわかりませんでした。 \n<http://www.seleniumhq.org/projects/webdriver/> \n<https://en.wikipedia.org/wiki/Selenium_(software)>\n\nSelenium というプロジェクトの中に Selenium WebDriver があるようなのですが、それぞれの分類はどうなっているのでしょうか?", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T12:06:39.110", "favorite_count": 0, "id": "11728", "last_activity_date": "2015-06-26T22:41:45.807", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3271", "post_type": "question", "score": 2, "tags": [ "selenium", "selenium-webdriver" ], "title": "Selenium WebDriverとはブラウザを操作するものか、それともブラウザ自体?", "view_count": 996 }
[ { "body": "Selenium WebDriverを使うには別途ブラウザをインストールする必要があります。ブラウザその物ではありません。\n\nSelenium WebDriverはブラウザをスクリプトで操作する為のドライバで、Selenium WebDriver +\nブラウザの組合せで使用します。主にJavaScriptも含めたウェブサイトのテストに使用されますが、ブラウザの画面表示を伴うため、動きが遅いです。\n\nphantomjsはスクリプトで操作可能なヘッドレスブラウザです。画面表示を行わない分高速で、こちらも主にウェブサイトのテストに使用され‌​ます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T16:28:14.057", "id": "11739", "last_activity_date": "2015-06-26T22:41:45.807", "last_edit_date": "2015-06-26T22:41:45.807", "last_editor_user_id": "10170", "owner_user_id": "10170", "parent_id": "11728", "post_type": "answer", "score": 3 } ]
11728
11739
11739
{ "accepted_answer_id": null, "answer_count": 1, "body": "追記\n\n```\n\n void awake (){\n monstar = Getcomponent<monstarstatus>(); //外部から\n monstar2 = Getcomponent<monstar2status> ();//外部から\n int monstarability = monstar.attack;\n int monstar2ability = monstar2.attack;\n \n int monstarHP = monstar.HP();\n int monstar2HP = monstar2.HP();\n \n```\n\n条件 monstarHPかつmonstar2HPの数値が>0の場合 \nmonstarが先に行動するとして、\n\n```\n\n int monstar2LEFTHP = (monstar2HP -= monstarability);\n int monstarLEFTHP = (monstarHP -= monstar2ability);\n \n```\n\n上記の動作を永続的に行う。なお、どちらかのLEFTHPが<0になった場合その場で終了する\n\nこれはif と forを使うのでしょうか? または、ほかの方法を求みます。\n\n```\n\n int monstarLEFTHP = monstarHP - damage;// モンスターLEFTHP = モンスターHP100- damage 20 \n \n```\n\nこの繰り返しの処理をする場合 \nLEFTHP100ではなく、80になっているので \n次は80から-20を引きたい。", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T12:16:43.163", "favorite_count": 0, "id": "11729", "last_activity_date": "2015-07-26T01:00:20.100", "last_edit_date": "2015-06-26T00:02:54.647", "last_editor_user_id": "440", "owner_user_id": "9268", "post_type": "question", "score": 2, "tags": [ "c#" ], "title": "変数の引渡し方法についてc #", "view_count": 274 }
[ { "body": "だいたい以下の様にしているかと思います。\n\n```\n\n using System;\n \n public class Monster {\n private int hp = 100;\n \n public int HP(){\n return hp;\n }\n }\n class Sample{\n static void Main(){\n Monster monster = new Monster();\n int hp = monster.HP();//モンスターの現在のHPを取り出す\n int damage = 20;\n while(hp > 0){\n Console.WriteLine(\"モンスターの現在のHPは{0}です。\", hp);\n hp -= damage;//ダメージの計算\n Console.WriteLine(\"ダメージを受けてHPは{0}になりました。\", hp);\n }\n }\n }\n \n```\n\n値をメソッド(`monster.HP()`)で取り出していることから \n外部のメソッドで実行していると思いますが、 \nHPは`monster`の属性値ですから書き戻す必要があります。 \n例えば以下の様に属性値をセットするメソッドを追加します。\n\n```\n\n using System;\n \n public class Monster {\n private int hp = 100;\n \n public int HP(){\n return hp;\n }\n public void HP(int value){\n hp = value;\n }\n }\n class Sample{\n static void Main(){\n Monster monster = new Monster();\n int hp;\n int damage = 20;\n do {\n hp = monster.HP();//読み出し\n Console.WriteLine(\"モンスターの現在のHPは{0}です。\", hp);\n hp -= damage;\n monster.HP(hp);//書き出し\n Console.WriteLine(\"ダメージを受けてHPは{0}になりました。\", hp);\n } while(hp > 0);\n }\n }\n \n```\n\nこうすると、モンスターの値を取り出し、ダメージの計算をして、書き戻すというループにできます。\n\nC#では、こういう属性値でprivateにしておいて直接値を扱わせたくない(のでメソッド経由でやりとりする)ような場合にプロパティとしての構文があります。 \nプロパティを使って同じように書くと以下の様になります。\n\n```\n\n using System;\n \n public class Monster {\n private int hp = 100;\n \n public int HP{\n get {\n return hp;\n }\n set {\n if(value < 0){\n hp = 0;\n } else {\n hp = value;\n }\n }\n }\n }\n class Sample{\n static void Main(){\n Monster monster = new Monster();\n int hp;\n int damage = 20;\n do {\n hp = monster.HP;\n Console.WriteLine(\"モンスターの現在のHPは{0}です。\", hp);\n hp -= damage;\n monster.HP = hp;\n Console.WriteLine(\"ダメージを受けてHPは{0}になりました。\", hp);\n } while(hp > 0);\n }\n }\n \n```\n\n外部からは直接属性値を扱っているように見えるので、単純に以下の様に書けます。\n\n```\n\n Monster monster = new Monster();\n int damage = 20;\n do {\n Console.WriteLine(\"モンスターの現在のHPは{0}です。\", monster.HP);\n monster.HP -= damage;\n Console.WriteLine(\"ダメージを受けてHPは{0}になりました。\", monster.HP);\n } while(monster.HP > 0);\n \n```\n\n個人的にはこういうのを外部でやるより \n`monster.damage(damege);` \nのような呼び出しでやる方がいいような気がします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T22:13:01.983", "id": "11741", "last_activity_date": "2015-06-25T22:13:01.983", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "11729", "post_type": "answer", "score": 1 } ]
11729
null
11741
{ "accepted_answer_id": null, "answer_count": 0, "body": "<https://docs.angularjs.org/api/ng/service/>$http \nこのサイトを参考にしてCSRF対策をしたのですが、以下のコードで自動的にHeaderとして送られるX-XSRF-TOKENが以前のものになってしまいます。\n\n```\n\n $cookies['XSRF-TOKEN'] = data['token']; //ここでサーバから送られたトークンをクッキーに保存している。ここで保存されるクッキーをcooke1とする\n $scope.queries = Admin.query(); //このリクエストでサーバサイドでトークンの検証が行われるがX-XSRF-TOKENヘッダとして送られるトークンがcookie1ではなくcookie0なので、検証に失敗する。\n //このあとcookie1が保存される?\n //なおcookie0は以前のセッションでクッキーに登録されたトークン。\n \n```\n\n要するにリクエストのタイミングでまだクッキーが保存されていないのではないかとうのが私の予想です。なのでCookieの保存が終了時にリクエストを送ればいいのだと考えられますが、そのようなことはできるのでしょうか。もしできないのであれば別の方法を教えて下さい。よろしくお願いします。 \nサーバサイドはPHPです。\n\nこちらのサイトも参考にさせて頂きました。 \n<http://blog.sarabande.jp/post/88301895178>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T13:48:22.847", "favorite_count": 0, "id": "11730", "last_activity_date": "2015-06-25T13:57:00.177", "last_edit_date": "2015-06-25T13:57:00.177", "last_editor_user_id": "7232", "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "php", "angularjs", "cookie" ], "title": "AnglarJSでCookieの保存が遅延する。", "view_count": 185 }
[]
11730
null
null
{ "accepted_answer_id": "11738", "answer_count": 1, "body": "0〜9やa〜zの配列の要素から3個を選んだときの重複順列を数え上げたければ、\n\n```\n\n p ('000'..'999').to_a\n p ('aaa'..'zzz').to_a\n \n```\n\nですみます。 \n平仮名で同様のことをしようと\n\n```\n\n # -*- coding: cp932 -*-\n p ('あああ'..'んんん').to_a\n \n```\n\nとするとパソコンが止まりました。( **上記コードは実行しないでください。** ) \nなぜ上手くいかないか知ろうと、\n\n```\n\n # -*- coding: cp932 -*-\n p ('ああ'..'んん').to_a\n \n```\n\nを実行すると、 \n重複順列に「あ〜ん以外の別の文字が混ざっている」ことがわかりました。 \nなぜ、「あ〜ん以外の別の文字が混ざる」か教えてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T14:07:30.947", "favorite_count": 0, "id": "11731", "last_activity_date": "2015-06-25T17:21:33.980", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5363", "post_type": "question", "score": 6, "tags": [ "ruby" ], "title": "平仮名の重複順列が上手く出力されないのはなぜか?", "view_count": 499 }
[ { "body": "調べてみました。\n\n`('ああ'..'んん').to_a` では [Range#each](http://docs.ruby-\nlang.org/ja/2.1.0/method/Range/i/each.html) が呼ばれるので、2 つめ以降の要素は `String#succ`\nで生成されます。\n\nたとえば `'aa'.succ` は `'ab'` に `'az'.succ` は `'ba'` になるので、最初に挙げられた例は期待通り動作します。\n\nただしこれは、英数字の場合で、[String#succ のドキュメント](http://docs.ruby-\nlang.org/ja/2.1.0/method/String/i/succ.html) を見てみると、下記の記述があります。\n\n> アルファベットや数字をまったく含まない場合は、 単純に文字コードを 1 増やします。\n\nこのため \"あん\" の次が \"いあ\" などにはならず、カタカナや漢字など、文字コード表で \"ん\" より後にある文字も含むことになります。\n\n期待する結果を得るには、例えば、配列の組み合わせを得る `Array#permutation` を使って次のように書く事ができます。\n\n```\n\n ('ぁ'..'ん').to_a.permutation(3){|chars| p chars.join }\n \n```\n\nなお、エンコーディングが UTF-8 だと、`\"ん\".succ.succ.succ.succ` が `\"ぁぁ\"`\nになり、英数字に似た挙動になりました。ご参考まで。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T16:05:56.237", "id": "11738", "last_activity_date": "2015-06-25T17:21:33.980", "last_edit_date": "2015-06-25T17:21:33.980", "last_editor_user_id": "5789", "owner_user_id": "5789", "parent_id": "11731", "post_type": "answer", "score": 9 } ]
11731
11738
11738
{ "accepted_answer_id": "11740", "answer_count": 2, "body": "シェルスクリプトを始めたばかりなのですが、 \n件名の処理をどのようにしたら良いかわからず質問しました。\n\nmacにてシェルスクリプトを使って、Node.jsが入っていなければ、 \nNode.jsをダウンロードするという処理を書きたいのですが \n入っていればと言うのをどのように書けば良いかわかりません。\n\nNode.jsのダウンロードは、 \n下記のコマンドで実現できました。\n\n```\n\n curl -O https://nodejs.org/dist/v0.12.5/node-v0.12.5.pkg\n \n```\n\n処理としては下記のようになるはずです。\n\n```\n\n #!/bin/sh\n if アプリが存在しない then\n curl -O https://nodejs.org/dist/v0.12.5/node-v0.12.5.pkg\n fi\n \n```\n\n \nMacOSX:10.10.3 \n\n* * *\n\n**■最終目的は下記の手順をシェルスクリプト化する事です。**\n\n●Node.jsダウンロード\n\n<https://nodejs.org/download/>\n\n●ファイルサーバーとするフォルダを指定\n\n1:フォルダ作成 \n2:コマンドプロンプトから1:のフォルダへ移動 \n例)cd /path/to/my/project \n3:コマンドプロンプトにて下記入力 \nnpm install connect\n\n●jsファイルを1のフォルダに作成\n\n・jsファイルの中身は下記ソース\n\n```\n\n var connect = require('connect'),\n serveStatic = require('serve-static');\n \n var app = connect();\n app.use(serveStatic(__dirname));\n app.listen(5000);\n \n```\n\n・適当な名前で保存 \n仮にserver.jsとする。\n\n●コマンドラインからサーバー実行 \n1:コマンドプロンプトからjsファイルのフォルダへ移動 \n2:下記コマンド入力 \nnpm install serve-static\n\n3:下記コマンド入力 \nnode server.js\n\n●下記htmlをindex.htmlという名前で作成し、 \njsファイルと同じフォルダに置く\n\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta charset=\"utf-8\">\n <title>hello connect</title>\n </head>\n <body>\n hello connect\n </body>\n </html>\n \n```\n\n●ブラウザから下記URLをたたいてみると、 \nhello connect と表示される。 \n表示されない時は、app.listen(5000)の \nポート番号を変えてみて下さい。\n\n<http://127.0.0.1:5000/>\n\n* * *\n\n06/26 追記\n\n* * *\n\nお力添えのおかげでとりあえず版ができました。\n\n```\n\n #!/bin/sh\n node -v &> /dev/null\n if [ $? -ne 0 ]; then\n curl -O https://nodejs.org/dist/v0.12.5/node-v0.12.5.pkg\n fi\n \n Current=`pwd`\n NodePath=/NodeJs\n CheckPath=$Current$NodePath\n if [ ! -e $CheckPath ]; then\n mkdir -m 777 NodeJs\n fi\n \n cd $CheckPath\n npm install connect\n \n echo $CheckPath\n \n JsFileName=LocalServer.js\n if [ ! -e $JsFileName ]; then\n touch $JsFileName\n chmod 777 $JsFileName\n \n \n JsString=\"var connect = require('connect'),\n serveStatic = require('serve-static');\n var app = connect();\n app.use(serveStatic(__dirname));\n app.listen(5000);\"\n \n echo \"$JsString\" > $JsFileName\n fi\n \n echo $JsFileName\n \n HtmlFileName=Index.html\n if [ ! -e $HtmlFileName ]; then\n touch $HtmlFileName\n chmod 777 $HtmlFileName\n \n HtmlString=\"<!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta charset=\"utf-8\">\n <title>hello connect</title>\n </head>\n <body>\n Make FileServer Success!\n </body>\n </html>\"\n \n echo \"$HtmlString\" > $HtmlFileName\n fi\n \n echo $HtmlFileName\n \n npm install serve-static\n \n echo \"Install End\"\n \n node $JsFileName\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T14:07:52.533", "favorite_count": 0, "id": "11732", "last_activity_date": "2015-06-26T08:28:27.057", "last_edit_date": "2015-06-26T08:28:27.057", "last_editor_user_id": "5261", "owner_user_id": "5261", "post_type": "question", "score": 4, "tags": [ "macos", "node.js", "shellscript" ], "title": "シェルスクリプトでnode.jsがすでにインストール済みかチェックするには?", "view_count": 1937 }
[ { "body": "簡易的な方法として、`node -v`の実行に成功するかチェックするというのはどうでしょうか。\n\n```\n\n node -v &> /dev/null\n if [ $? -ne 0 ]; then\n # nodeがインストールされていない\n fi\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T14:21:50.793", "id": "11735", "last_activity_date": "2015-06-25T14:21:50.793", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "11732", "post_type": "answer", "score": 3 }, { "body": "以下のような感じで、コマンドの存在確認用の関数を定義して、 \nそれを利用して、下記のサンプルコードのようにして、 \nコマンドの存在確認を行ってみるといいのではないでしょうか?\n\n```\n\n function command_exists {\n command -v \"$1\" > /dev/null;\n }\n \n # node.jsがインストール済みかチェック\n if ! command_exists node ; then\n curl -O https://nodejs.org/dist/v0.12.5/node-v0.12.5.pkg\n fi\n # npmが利用可能かチェック\n if ! command_exists npm ; then\n #npmの手動インストール処理・・・\n fi\n \n```\n\nまた、シェルスクリプトを書き始めたばかりとのことでしたので、 \n私がシェルスクリプトを書き始めたときに、参考にしたサイトのURLを記載しておきます。\n\n<http://shellscript.sunone.me/>", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T16:36:07.603", "id": "11740", "last_activity_date": "2015-06-25T16:36:07.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3104", "parent_id": "11732", "post_type": "answer", "score": 2 } ]
11732
11740
11735
{ "accepted_answer_id": null, "answer_count": 2, "body": "rubyのirbでrubyのコードを2回以上loadすると失敗します。 \nなぜなのでしょうか?\n\npythonだと\n\n```\n\n \n import mymodule\n import importlib\n \n importlib.reload(mymodule) # 変更が反映される\n \n \n```\n\nとするとモジュールの変更が反映されますが\n\nrubyだとどうするのでしょうか?\n\n```\n\n \n >> load \"./big_step.rb\" #2回目\n TypeError: superclass mismatch for class Number\n \n \n```\n\nbig_step.rb\n\n```\n\n \n class Number < Struct.new(:value)\n def to_s\n return value.to_s\n end\n \n def evaluate(environment)\n self\n end\n \n def inspect\n return \"<<#{self}>>\"\n end\n end\n \n \n class Multiply < Struct.new(:left, :right)\n def to_s\n return \"#{left} * #{right}\"\n end\n \n def inspect\n return \"<<#{self}>>\"\n end\n \n def evaluate(environment)\n Number.new(left.evaluate(environment).value * right.environment(environment).value)\n end\n end\n \n class Add < Struct.new(:left, :right)\n def to_s\n return \"#{left} + #{right}\"\n end\n \n def inspect\n return \"<<#{self}>>\"\n end\n \n def evaluate(environment)\n Number.new(left.evaluate(environment).value + right.evaluate(environment).value)\n end\n end\n \n class Boolean < Struct.new(:value)\n def to_s\n value.to_s\n end\n \n def inspect\n \"<<#{self}>>\"\n end\n \n def evaluate(environment)\n self\n end\n end\n \n class LessThan < Struct.new(:left, :right)\n def to_s\n \"#{left} < #{right}\"\n end\n \n def inspect\n \"<<#{self}>>\"\n end\n \n end\n \n class Variable < Struct.new(:name)\n def to_s\n name.to_s\n end\n \n def inspect\n \"<<#{self}>>\"\n end\n \n def evaluate(environment)\n environment[name]\n end\n end\n \n class DoNothing\n def to_s\n \"do-noting\"\n end\n \n def inspect\n \"<<#{self}>>\"\n end\n \n def ==(other_statement)\n other_statement.instance_of?(DoNothing)\n end\n end\n \n \n class Assign < Struct.new(:name, :expression)\n def to_s\n \"#{name} = #{expression}\"\n end\n \n def inspect\n \"<<#{self}>>\"\n end\n \n def evaluate(environment)\n environment.merge({name => expression.evaluate(environment)})\n end\n end\n \n \n class If < Struct.new(:condition, :true_exe, :false_exe)\n def to_s\n \"if (#{condition}) { #{true_exe} } else { #{false_exe} }\"\n end\n \n def inspect\n \"<<#{self}>>\"\n end\n \n def evaluate(environment)\n case condition.evaluate(environment)\n when Boolean.new(true)\n true_exe.evaluate(environment)\n when Boolean.new(false)\n false_exe.evaluate(environment)\n end\n end\n end\n \n class Sequence < Struct.new(:first, :second)\n def to_s\n \"#{first}; #{second}\"\n end\n \n def inspect\n \"<<#{self}>>\"\n end\n \n \n def evaluate(environment)\n second.evaluate(first.evaluate(environment))\n end\n end\n \n \n class While < Struct.new(:condition, :body)\n def to_s\n \"while (#{condition}) { #{body} }\"\n end\n \n def inspect\n \"<<#{self}>>\"\n end\n \n def evaluate(environment)\n case condition.evaluate(environment)\n when Boolean.new(true)\n evaluate(body.evaluate(environment))\n when Boolean.new(false)\n environment\n end\n end\n end\n \n \n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T14:21:37.707", "favorite_count": 0, "id": "11734", "last_activity_date": "2015-08-22T03:33:18.253", "last_edit_date": "2015-06-26T13:54:14.197", "last_editor_user_id": "5246", "owner_user_id": "5246", "post_type": "question", "score": 4, "tags": [ "ruby", "python", "irb" ], "title": "irbで2回以上loadすると失敗する", "view_count": 364 }
[ { "body": "2回loadすると`class Number <\nStruct.new(:value)`が2回実行されますが、`Struct.new(:value)`はそれぞれ別のクラスを新しく生成して返すので、クラス定義を追加するときに間違ったスーパークラスを指定したことになりエラーが発生します。\n\n```\n\n irb(main):001:0> Struct.new(:value)\n => #<Class:0x00000000aab338>\n irb(main):002:0> Struct.new(:value)\n => #<Class:0x00000000a9fb28>\n irb(main):003:0> Struct.new(:value)\n => #<Class:0x00000000a90790>\n irb(main):004:0> Struct.new(:value) == Struct.new(:value)\n => false\n \n```\n\n<http://docs.ruby-lang.org/ja/1.9.3/doc/spec=2fdef.html#class>\n\n> クラスが既に定義されているとき、さらに同じクラス名でクラス定義を書くとクラスの定義の追加になります。ただし、元のクラスと異なるスーパークラスを指定すると\n> TypeError が発生します。\n```\n\n> class Foo < Array\n> def foo\n> end\n> end\n> \n> # 定義を追加(スーパークラス Array を明示的に指定しても同じ)\n> class Foo\n> def bar\n> end\n> end\n> \n> # 間違ったスーパークラスを指定するとエラー\n> class Foo < String\n> end\n> # => superclass mismatch for class Foo (TypeError)\n> \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T14:46:48.997", "id": "11736", "last_activity_date": "2015-06-25T14:52:44.033", "last_edit_date": "2015-06-25T14:52:44.033", "last_editor_user_id": "3639", "owner_user_id": "3639", "parent_id": "11734", "post_type": "answer", "score": 4 }, { "body": "いくつか対策を考えました。\n\n 1. Strict.newしたサブクラスを定数に入れて、1度だけ作成する。 \n定数を作ってあるかはdefinde?でチェックします。\n\n``` unless defined? Struct_value\n\n Struct_value = Struct.new(:value)\n end\n class Number < Struct_value\n # 以下略\n \n```\n\n 2. クラスが定義されている場合は、未定義にしてから定義する。 \n参照: <https://stackoverflow.com/questions/11503558/how-to-undefine-class-in-\nruby> \n参照: <http://www.iwazer.com/~iwazawa/diary/2013/05/ruby-remove-defined-\nclass.html> \n参照: <http://qiita.com/ogawatti/items/0e69125ef4155241f598>\n\n``` if defined? Number\n\n Object.send(:remove_const, :Number)\n end\n class Number < Struct.new(:value)\n # 以下略\n \n```\n\n 3. シングルトンなStructファクトリーを作る。 \nコードは結構適当なので、参考程度にしてください。\n\n``` require 'singleton'\n\n class StructFactory\n include Singleton\n def initialize\n @structs = {}\n end\n def [](*key)\n unless @structs.has_key?(key)\n @structs[key] = Struct.new(*key)\n end\n return @structs[key]\n end\n def self.[](*key)\n instance[*key]\n end\n end\n class Number < StructFactory[:value]\n # 以下略\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-22T03:33:18.253", "id": "14721", "last_activity_date": "2015-08-22T03:33:18.253", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "7347", "parent_id": "11734", "post_type": "answer", "score": 2 } ]
11734
null
11736
{ "accepted_answer_id": "11748", "answer_count": 1, "body": "`UIButton`の`titleLabel`に、Xcode付属のヒラギノ角ゴシックという日本語フォントを使いたいのですが、英字を入力すると一部が切れ、文字の全体が表示されません。\n\nこのような状態です。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/hYmLJ.png)\n\n左のボタンには Helvetica Neue、右のボタンにはヒラギノ角ゴシックを Interface Builderで設定しています。\n\n`titleLabel?.backgroundColor`の色を変え、サイズを確かめてみました。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/bDuxa.png)\n\nヒラギノフォントを使っている右のボタンの`titleLabel`サイズが小さいので、`frame.size.height`をコードで変更してみたのですが、反映されませんでした。\n\nまた、`titleLabel`で表示したいテキストを`NSMutableAttributedString`にし、`drawInRect`でサイズを指定してから、`setAttributedTitle()`を使ってボタンに設定してみたのですが、表示に変化はありませんでした。\n\n`titleEdgeInsets`を使い、余白をすべて`0.0`に設定してもみたのですが、これも成果はありませんでした。\n\n検索したところ、『[CoreText\nヒラギノフォント(日本語)で正確に描画サイズを取得する](http://qiita.com/yusuga/items/2be8c55ca561bba44702)』という記事を見つけました。が残念ながらまだ初心者の身でしてどうにも、`UIButton`に応用する方法が分かりません。\n\n`UIButton`でヒラギノ角ゴシックの英字グリフ全体を表示させるには、どうしたらいいでしょうか?\n\nできれば swiftでご回答いただけますとありがたいです。 \nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-25T23:58:11.070", "favorite_count": 0, "id": "11742", "last_activity_date": "2015-06-26T02:41:24.663", "last_edit_date": "2015-06-26T00:06:16.420", "last_editor_user_id": "9833", "owner_user_id": "9833", "post_type": "question", "score": 2, "tags": [ "ios", "swift", "xcode" ], "title": "UIButtonにヒラギノ角ゴシックの英字を表示させたい", "view_count": 1460 }
[ { "body": "フォントの上下位置を調節するというのは、 **ベースラインのオフセットを調節する** という処理になります。具体的には、「Character\nAttributes」の「NSBaselineOffsetAttributeName」の値を変更します。\n\nXcodeの **Playground** で、以下のプログラムを実行してみてください。\n\n```\n\n import UIKit\n \n let button = UIButton(frame: CGRectMake(0.0, 0.0, 100.0, 44.0))\n button.backgroundColor = UIColor.lightGrayColor()\n \n var attrText = NSAttributedString(string: \"Hello\", attributes: [NSBaselineOffsetAttributeName: NSNumber(float: 0.0)])\n button.setAttributedTitle(attrText, forState: UIControlState.Normal)\n \n```\n\n![画像の説明をここに入力](https://i.stack.imgur.com/w1FVI.png)\n\n6行目の`[NSBaselineOffsetAttributeName: NSNumber(float:\n0.0)]`を、`[NSBaselineOffsetAttributeName: NSNumber(float: 10.0)]`にすると\n\n![画像の説明をここに入力](https://i.stack.imgur.com/NNAjN.png)\n\n`[NSBaselineOffsetAttributeName: NSNumber(float: -10.0)]`にすると、\n\n![画像の説明をここに入力](https://i.stack.imgur.com/qeyVz.png)\n\n以上、参考にしていただければさいわいです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T02:41:24.663", "id": "11748", "last_activity_date": "2015-06-26T02:41:24.663", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "11742", "post_type": "answer", "score": 5 } ]
11742
11748
11748
{ "accepted_answer_id": "11873", "answer_count": 1, "body": "HTML5,CSS,Javascript (Monava) でバックグラウンドでアプリを起動していなくてもiBeaconを検知できるようにしたいです。 \n機種は iOS8,3 です。 \nObjective-C ではできるようですが \n<http://www.gaprot.jp/pickup/ibeacon/ibeacon-vol2/> \nMonacaを使ってはできないのでしょうか? \nご回答よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T01:09:41.333", "favorite_count": 0, "id": "11745", "last_activity_date": "2015-07-30T06:57:48.237", "last_edit_date": "2015-06-26T04:16:31.407", "last_editor_user_id": "845", "owner_user_id": "10112", "post_type": "question", "score": 2, "tags": [ "ios", "monaca", "ibeacon" ], "title": "JavascriptでiBeaconを検知したい(バックグラウンド)", "view_count": 768 }
[ { "body": "できますよ。バッググラウンドだけでなく、Killしても検知します。(rangingでなくmonitoringのみ) \n<https://stackoverflow.com/questions/29940742/cordova-ibeacon-send-local-\nnotification-after-the-app-got-killed-but-does-not> \nこの辺りが参考になるかと思います!", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T05:51:46.173", "id": "11873", "last_activity_date": "2015-06-30T05:51:46.173", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "8748", "parent_id": "11745", "post_type": "answer", "score": 2 } ]
11745
11873
11873
{ "accepted_answer_id": "11747", "answer_count": 1, "body": "2番目の数値が小さい順に、名前順でソートしたい。 \nファイラーのようにフォルダの後にファイルが並ぶ。\n\n配列の1番目の値が名前です。 \n二番目の値は0がフォルダ、1がファイルとして付けます。 \n次のコードを実行すると2番目の値に沿ってソートはされますが、配列の内容によっては名前順にソートされません。\n\n```\n\n var ary = [\n ['あ0', 0],\n ['b', 0],\n ['c.txt', 1],\n ['た', 0],\n ['e', 0],\n ['ぜ.txt', 1],\n ['a', 0],\n ['a.txt', 1],\n ['d', 0],\n ['あ', 0],\n ['c', 0],\n ['b.txt', 1],\n ];\n \n ary.sort(function(a, b) {\n return (a[1] - b[1]) || (a[0] > b[0]);\n });\n \n for (var i = 0; i < ary.length; i++) {\n console.log('%d: %s', ary[i][1], ary[i][0]);\n }\n \n```\n\n次の配列に差し替えるとうまくソートできました。\n\n```\n\n var ary = [\n ['あ0', 0],\n ['b', 0],\n ['c.txt', 1],\n ['た', 0],\n ['e', 0],\n ['ぜ.txt', 1],\n ['a', 0],\n // ['a.txt', 1],\n ['d', 0],\n ['あ', 0],\n ['c', 0],\n ['b.txt', 1],\n ];\n \n```\n\nアドバイスお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T01:52:03.513", "favorite_count": 0, "id": "11746", "last_activity_date": "2015-06-26T02:03:03.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10022", "post_type": "question", "score": 1, "tags": [ "javascript" ], "title": "二次元配列をソートしたい", "view_count": 3328 }
[ { "body": "[Array.prototype.sort()](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)に渡している比較関数が間違っています。\n\n```\n\n function(a, b) {\n return (a[1] - b[1]) || (a[0] > b[0]);\n }\n \n```\n\nですが、2番目の値は減算で整数が返されますが、1番目の値については大小比較でbool値が返されてしまいます。\n\n```\n\n function(a, b) {\n return (a[1] - b[1]) || (a[0] > b[0] ? 1 : a[0] < b[0] ? -1 : 0);\n }\n \n```\n\n等、条件に合った整数を返すべきです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T02:03:03.120", "id": "11747", "last_activity_date": "2015-06-26T02:03:03.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "11746", "post_type": "answer", "score": 3 } ]
11746
11747
11747
{ "accepted_answer_id": "11779", "answer_count": 6, "body": "現在C#とNinjectを使ったDIについて学習を進めております.\n\nコンストラクタ・Setter・メソッドの引数の型にインターフェイスを使う方法(※1)と比較して,DIコンテナを使う方法(※2)が優れている点がわかりません.\n\n```\n\n interface IPerson { string Name(); }\n class Sol : IPerson { string Name() { return \"Sol\"; } }\n class Ky : IPerson { string Name() { return \"Ky\"; } }\n \n class PersonManager\n {\n private IPerson _p;\n <Inject> public PersonManager(IPerson p) { _p = p; }\n public string SayMyName() { return _p.Name(); }\n }\n \n // ※1\n void Test1()\n {\n var sol = new PersonManager(new Sol());\n sol.SayMyName();\n }\n \n // ※2\n void Test2()\n {\n var kernel = new StandardKernel();\n kernel.Bind<IPerson>().To<Sol>();\n kernel.Bind<PersonManager>().ToSelf();\n \n var sol = kernel.Get<PersonManager>();\n sol.SayMyName();\n }\n \n```\n\n以下の記事を参考にコードを書きました. \n参考:taediumの日記 Ninjectを使ってみた <http://d.hatena.ne.jp/taedium/20100307/p1>\n\n※1,※2のどちらの場合でも`PersonManager`は`IPerson`にのみ依存し,`Test1`,`Test2`はどちらも`Sol`に依存しているので,依存関係に関しては※1,※2どちらが優れているということは無いと考えています.\n\n※2は※1よりコードが複雑になっていますし,どういう場面でDIコンテナを使用するといいのかがわかりません.\n\nDIコンテナを使用するとこういう場面で非常に役に立つ,という例を教えてください. \nC#以外の言語,Ninject以外のDIコンテナでも構いません.\n\n## 以下追記 2015.06.30\n\n皆さんありがとうございます.\n\n特に@thubさん, @unaristさんのコメントで理解が深まりました.\n\n端的に言えば`new Sol(new Hoge(new Foo()), MAGIC_NUMBER, new\nBar())`のように生成が複雑になった場合,DIコンテナを使ったほうが便利.ということだと理解しました.\n\nまた,DIコンテナ側の機能で,オブジェクトのスコープをSingletonやThreadLocalにできたり,Privateなフィールド,メソッドにDIできるというのは確かなメリットだと感じました.\n\n## 追記の追記(読み飛ばして結構です) 2015.07.01\n\n私の質問の仕方が良くなかったのですが,この質問はDI自体のメリットを聞くつもりではなく,DIのコードを自分で書く場合と,DIコンテナを使った場合の差が知りたい.という意図で質問をしたつもりでした.InterfaceによるDIは日常的に行っており,そのメリットも理解・体感しております.\n\nDIのコードを自分で書く場合も,DIコンテナを使う場合でも,オブジェクトの生成ルールを書く際は具象クラスに依存する.DIコンテナのオブジェクト生成ルールを書く場合も,自分でFactoryメソッドを用意する場合と比較してコード量も減るようには見えない.どこにメリットがあるんだろう?という疑問からの質問でした.\n\nみなさんのコメントのおかげでとても理解が深まりました.ありがとうございました.", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T02:54:15.063", "favorite_count": 0, "id": "11750", "last_activity_date": "2015-07-01T08:34:17.793", "last_edit_date": "2015-07-01T08:34:17.793", "last_editor_user_id": "9532", "owner_user_id": "9532", "post_type": "question", "score": 18, "tags": [ "c#", "テスト" ], "title": "DIコンテナを使うメリットが分からない", "view_count": 23512 }
[ { "body": "### DIコンテナを使わない場合\n\n```\n\n var sol = new PersonManager(new Sol());\n \n```\n\nこの部分は具象クラスであるSolクラスに依存してしまいます。 \nPersonManagerを使う箇所が多数ある場合、`new\nSol()`する箇所も多くなります。SolクラスをKyクラスに変更したくなった場合、修正箇所が多くなりメンテナンス性が低くなります。\n\nまた、SolクラスがAクラスに依存していて、AクラスがBクラスに依存しているといった感じで、構造を持っている場合、依存性の注入を多段階で行う必要があり、`new\nSol()`する箇所が多くなると非常に辛くなってきます。構造に変更があった場合、修正が大変です。\n\n### DIコンテナを使うと\n\nnew\nSol()する箇所をDIコンテナにバインドする一箇所に限定することができ、メンテナンス性が高くなります。構造が複雑な場合でも、構造はバインド箇所のみに隠蔽されます。 \nまた、DIコンテナにオブジェクトを格納して、シングルトンパターンとして利用することもでき、メモリの効率化も行えます。\n\nPHPとpimpleというDIコンテナの例になりますが、以下のサイトが参考になります。\n\n参考サイト \n<https://laravel10.wordpress.com/2015/03/29/%E4%BE%9D%E5%AD%98%E6%80%A7%E3%81%AE%E6%B3%A8%E5%85%A5%E3%81%A8%E3%81%AF/>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T04:12:03.997", "id": "11752", "last_activity_date": "2015-06-26T22:11:41.333", "last_edit_date": "2015-06-26T22:11:41.333", "last_editor_user_id": "10170", "owner_user_id": "10170", "parent_id": "11750", "post_type": "answer", "score": 5 }, { "body": "DIコンテナを使った場合、ユニットテストが容易になります。 \n依存している実装を外部から差し替えることが可能になるためです。\n\n<http://moonstruckdrops.github.io/blog/2013/06/27/dependency-injection/>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T04:38:21.850", "id": "11753", "last_activity_date": "2015-06-26T04:38:21.850", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8239", "parent_id": "11750", "post_type": "answer", "score": 1 }, { "body": "DI(Dependency\nInjection)一般論としては、「ソフトウェア・コンポーネント間の依存性軽減」が目的でありメリットでもあると思います。コンポーネント間の依存性が小さくなる(モジュール結合度が小さくなる)ことの副次効果として、部品単位での単体テストのやり易さや、部品の再利用性向上も挙げられます。特に、大規模ソフトウェア開発でこのようなメリットが歓迎されます。\n\n * [なぜDIコンテナを使うのか](http://www.atmarkit.co.jp/ait/articles/0608/10/news111.html)\n * [DIの何が嬉しいの?](http://d.hatena.ne.jp/imai78/20090310/1236688846)\n\n一方で依存性軽減の実現には、インターフェイスのような抽象レイヤを追加する必要があり、実装面ではオーバーヘッドがあることも確かです。万能なソフトウェア設計という物は存在しませんから、対象や状況に応じて採用可否を判断すべきですね。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T05:22:18.697", "id": "11756", "last_activity_date": "2015-06-26T05:22:18.697", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49", "parent_id": "11750", "post_type": "answer", "score": 3 }, { "body": "歴史には沿っていないと思いますが、次のように考えてみました。\n\n * 巨大なプログラムがある\n * それをコンポーネントに切り分けていく。けれど替えがきかない。\n * インターフェイスを挟む。替えはきくが、内部を変更する必要がある。\n * 依存性を注入する。その代りオブジェクト生成が複雑になり、その生成ロジックが分散している。\n * **あらかじめ登録しておいた生成ルールを使い、DIコンテナにオブジェクトを生成させる**\n\n依存性の注入までは小規模のコードでもわかりやすく、実際テストに便利だったりします。一方で、それぞれのオブジェクトへの依存が少ない、質問に例示されたようなコードでは「同じ生成ロジックが分散する」と感じにくいですし、コンテナを使うメリットは薄いかもしれません。\n\nしかし `IPerson` や `PersonManager` を生成しなければならない個所が増えた場合はどうでしょうか。個別に new\nしたとして、それを変更したくなったら?単に具象クラスが違うということ以外にも、生成方法が異なることがあります。あるいは既存のインスタンスを使いたいかもしれません。\n\nDIコンテナを使えば、「これはこうすれば生成できる」というパターンを最初に登録しておくだけで、あとはコンテナが適切に組み合わせてくれます。Aが依存するBはさらにCに依存していて・・・みたいなのも含め。\n\nまた、どのような場合でも `kernel.Get<T>()`\nという一貫した手順でオブジェクトを生成できるというのは、コードの可読性にもつながるのではないでしょうか。\n\nなお、DI は外部からオブジェクトを注入しますが、直接具象クラスに依存することを避けるだけならファクトリパターンやサービスロケータといった手法もあります。\n\n参考\n\n * [Dependency Injection By Hand · ninject/Ninject Wiki](https://github.com/ninject/Ninject/wiki/Dependency-Injection-By-Hand)\n * [依存性の注入 - Wikipedia](https://ja.wikipedia.org/wiki/%E4%BE%9D%E5%AD%98%E6%80%A7%E3%81%AE%E6%B3%A8%E5%85%A5)\n * [PHPメンターズ -> DIとサービスロケータの違い](http://phpmentors.jp/post/100741112503/di-service-locator)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T12:20:15.457", "id": "11779", "last_activity_date": "2015-06-26T12:20:15.457", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "11750", "post_type": "answer", "score": 8 }, { "body": "マルチプラットフォーム開発をしているとDIは便利に使えます。\n\nHoge.Core.Dll プラットフォームに依存しないロジックが書かれている \nHoge.Win32.Dll プラットフォーム(この場合Windows)に依存するロジックが書かれている \nHoge.Win32.exe プラットフォームに依存したアプリケーション(この場合はWindows) \nこのほかにインターフェイスを定義したDLLなどなどがあるとします。\n\n例えばWindowsプラットフォームに依存するクラスをHoge.Win32.Dllに作って \nそのクラスを使用するクラスをPCLなどでHoge.Core.Dllとかに作ったとき。\n\nHoge.Core.Dll内ではHoge.Win32.Dll内のクラスを知らないままインターフェイス経由で利用しなければなりません。 \nこの時にクラスの生成に困るのです。そこで \nHoge.Win32.exeにてDIの設定をすることで、 \nHoge.Core.Dll内でWin32の具象クラスを知らなくてもインスタンス化できて利用できるのです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T05:55:00.987", "id": "11793", "last_activity_date": "2015-06-27T05:55:00.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8514", "parent_id": "11750", "post_type": "answer", "score": 0 }, { "body": "具体的な例は他の方が回答されているとおりですが、私がDIのメリットとして理解しているのは、次の点です。\n\n 1. オブジェクトの生成の問題とその他の問題を分ける強制力となること\n 2. 1の恩恵として、狭いスコープ(インターフェイス指向)でのプログラミングが可能になること\n 3. 2の恩恵として、個々のクラスをメンテナンスしやすくなること\n\nここで、2が重要なポイントです。\n\n質問に書かれているコードにおいて、`Test1()`、`Test2()`はいずれも、オブジェクト生成の問題と、それ以降の処理の問題とを1つの視点から見たコードになっている、という点で全く同じです。 \n示されたコードの意図をそのまま、DIを活かしたコードへ書き換えることは難しいのですが、\n\n```\n\n kernel.Bind<IPerson>().To<Sol>();\n kernel.Bind<PersonManager>().ToSelf();\n \n```\n\nこの2行のあたりが、オブジェクトの生成の仕方を指示しているコードですから、通常は何らかの用意された専用の場所([モジュール](https://github.com/ninject/Ninject/wiki/Modules-\nand-the-Kernel)等)へ記述して管理します。\n\n次に、オブジェクトの生成以外の処理は、オブジェクトの生成の仕方を気にしないというだけでなく、それが具体的にどのクラスのオブジェクトであるのかも、通常は気にしないようにプログラミングします。つまり、PersonManagerを抽象化したインターフェイスのみを使うようにします。\n\n```\n\n void Test3(IPersonManager pm)\n {\n pm.SayMyName(); // pmがSolなのかKyなのかを気にしない\n }\n \n```\n\nこのように、処理の部分はIPersonManagerに定義された、限られたメソッドだけを使うコードになります。\n\nこのようなスタイルでのプログラミングは、DI(コンテナ)に頼らなくても可能ですが、DIを使う場合はある意味強制的にこのようなスタイルにせざるを得なくなるため、一定の設計改善効果があるといえます。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T14:36:14.037", "id": "11902", "last_activity_date": "2015-06-30T14:36:14.037", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5444", "parent_id": "11750", "post_type": "answer", "score": 2 } ]
11750
11779
11779
{ "accepted_answer_id": "11768", "answer_count": 3, "body": "C++初心者です。複数のファイルを取り込んだプログラムがコンパイルできず、その理由もわかりません。\n\nA.cpp\n\n```\n\n #include \"B.h\"\n \n int main(int argc, char **argv) {\n B test;\n test.show(*argv);\n return 0;\n }\n \n```\n\nB.h\n\n```\n\n #pragma once\n \n #ifndef __B_H__\n #define __B_H__\n \n #include <string>\n \n class B {\n public:\n void show(std::string);\n };\n \n #endif\n \n```\n\nB.cpp\n\n```\n\n #include \"B.h\"\n \n #include <string>\n #include <iostream>\n \n using namespace std;\n \n class B {\n public:\n void show(const char *var) {\n cout << var << endl;\n }\n };\n \n```\n\nこれでコンパイル\n\n```\n\n g++ -o a.exe A.cpp\n \n```\n\nすると\n\n```\n\n /tmp/ccGn41oP.o:A.cpp:(.text+0x4c): `B::show(std::string)' に対する定義されていない参照です\n /tmp/ccGn41oP.o:A.cpp:(.text+0x4c): 再配置がオーバーフローしないように切り詰められました: R_X86_64_PC32 (未定義シンボル `B::show(std::string)' に対して)\n collect2: エラー: ld はステータス 1 で終了しました\n \n```\n\nこうなってしまいます。 \nこれはどういうエラーなんでしょうか。 \nこんな初歩的な質問で恐縮ですが、教えてください。\n\n> ご回答について\n\nご回答ありがとうございます。 \nコンパイルの流れを理解していませんでした。 \nおっしゃる通り、\n\n```\n\n g++ -c B.cpp\n \n```\n\nを実行したところ、\n\n```\n\n $ g++ -c B.cpp\n B.cpp:8:7: エラー: ‘class B’ が再定義されています\n class B {\n ^\n In file included from B.cpp:1:0:\n B.h:8:7: エラー: ‘class B’ の前の定義\n class B {\n ^\n \n```\n\nとなってしまったため、プロトタイプの実装本体はクラス宣言しないのかと思い、 \n下記に変更して再度実行しました。\n\nB.cpp\n\n```\n\n #include \"B.h\"\n \n #include <string>\n #include <iostream>\n \n using namespace std;\n \n void show(const char *var) {\n cout << var << endl;\n }\n \n```\n\nこれで\"B.o\"というファイルが生成され、改めて\n\n```\n\n g++ -o A.exe A.cpp\n \n```\n\nを実行したものの、エラーの内容が変わりませんでした。\n\n> sayuri さん\n\nちなみにですが・・・ \n引数を\n\n```\n\n void show(std::string var);\n \n```\n\nに統一し、\n\n```\n\n g++ -c B.cpp\n g++ -o A.exe A.cpp\n \n```\n\nを行うと\n\n```\n\n $ g++ -o a.exe A.cpp\n /tmp/ccSVMoNA.o:A.cpp:(.text+0x4c): `B::show(std::string)' に対する定義されていない参照です\n /tmp/ccSVMoNA.o:A.cpp:(.text+0x4c): 再配置がオーバーフローしないように切り詰められました: R_X86_64_PC32 (未定義シンボル `B::show(std::string)' に対して)\n collect2: エラー: ld はステータス 1 で終了しました\n \n```\n\nというエラーになります。\n\n<http://d.hatena.ne.jp/pknight/20090826/1251303641>\n\nこのブログを見ると、この場合はtemplate関数の場合ですが、 \n「この関数は使われていないから.objを生成しても実態がないのでA.cppからは実装が見えません」 \nというようなことが書いてありました。 \nもしこれと同様の現象が起きているのだとすると、今回show()関数はグローバルメンバ関数ではなくクラスメンバ関数なのでA.cppから見ることはできない \nということになってしまうんでしょうか。 \n言語仕様をほとんどよくわかっていないので、さすがにそんなことはないんじゃないかと思いますが・・・\n\nC++開発者の方も、実行ファイル1つで完結するプログラムなんてそうそう書かないと思いますが、 \n皆さんはどうやって外部関数を参照しているのかわかりません。", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T05:13:20.657", "favorite_count": 0, "id": "11755", "last_activity_date": "2017-07-25T06:21:09.100", "last_edit_date": "2015-06-26T07:20:47.617", "last_editor_user_id": "8396", "owner_user_id": "8396", "post_type": "question", "score": 3, "tags": [ "c++" ], "title": "C++で外部クラスを使用したプログラムがコンパイルできない", "view_count": 42735 }
[ { "body": "コンパイル、コンパイルといいますが、厳密には以下のフェーズに分かれています。 \n(1)コンパイル:ソースコードからオブジェクトファイルを生成 \n(2)リンク:オブジェクトファイルを紐づけて実行形式ファイルを生成\n\nつまり、 \n[A.cpp, B.cpp, B.h] --(1)--> [A.o, B.o] --(2)--> [A.exe] \nということです。\n\nで、上記のエラーメッセージを見る限りリンクのフェーズでエラーが発生しています。 \n内容を見るとB::Showが、恐らくはB.obj見つかりません、という事ですね。 \n(1)はソースコード単位で行われます。 \nですので、B.objが作成されていないのでは?、と見受けられます。。 \ng++ -c B.cpp \nを実施すれば解決するかと。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T05:30:54.637", "id": "11757", "last_activity_date": "2015-06-26T05:30:54.637", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10256", "parent_id": "11755", "post_type": "answer", "score": 1 }, { "body": "C言語及びC++言語には宣言と定義の2つが存在します。 \nB.hに\n\n```\n\n class B {\n public:\n void show(std::string);\n };\n \n```\n\nと宣言した場合、B.cppに記述すべきこれに対応する定義は\n\n```\n\n void B::show(std::string){\n ...\n }\n \n```\n\nとなります。C言語と異なりC++言語には関数オーバーロードがあるため、引数を完全に一致させる必要があります。また `void\nB::show(std::string)` と `void show(std::string)` も別関数です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T06:46:38.657", "id": "11768", "last_activity_date": "2015-06-26T06:46:38.657", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "11755", "post_type": "answer", "score": 1 }, { "body": "ソースファイルが複数に分かれている場合, ビルド手順は以下のいずれかの方法になります.\n\nA. ソースファイルを個別にコンパイルし, 後でリンクする.\n\n```\n\n g++ -c A.cpp\n g++ -c B.cpp\n g++ -o a.exe A.o B.o\n \n```\n\n最初の2行で, それぞれ A.o と B.o を生成します. 「-c」オプションをつけた場合,\n拡張子を.oに置き換えたものがデフォルトの出力ファイル名になります. \n3行目で, リンクします. \n規模が大きいとこの方法が主流です. 下の方法と比べて, ソースを一部変更した後の再コンパイル・ビルドがです.\n\nB. まとめてコンパイル, リンクする.\n\n```\n\n g++ -o a.exe A.cpp B.cpp\n \n```\n\n1行でかけるので手軽ですが, 中間のオブジェクトファイルが残らないので, 一部を修正した場合でも両方のソースをコンパイルし直すことになり,\n時間がかかります.\n\nソースコードにエラーがあり, sayuriさんの回答にもあるとおり, B.cppを以下のように修正する必要があります.\n\n```\n\n #include \"B.h\"\n #include <string>\n #include <iostream>\n using namespace std;\n void B::show(std::string var) {\n cout << var << endl;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-07-25T06:21:09.100", "id": "36651", "last_activity_date": "2017-07-25T06:21:09.100", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "68", "parent_id": "11755", "post_type": "answer", "score": 1 } ]
11755
11768
11757
{ "accepted_answer_id": "11761", "answer_count": 1, "body": "AngularJSとNode.jsを併用しているWEBアプリを作成しています。 \nAngularJS側で保存したLocalStrageの値をNode.js側で取得したいです。 \n(JSだとwindow.localStrage()で取得できるもの)\n\nNode.js側ではどうすれば取得できますでしょうか?\n\n*JavaScriptのwindow.localStrageではエラーとなり取得できませんでした。 \n*node-localstorageというパッケージを使ってみましたが開発環境のディレクトリ一覧が取得できたので \nそもそも取得できる場所が違いますかね?\n\nご存知の方がいらっしゃいましたら、ご教授願います。 \n(他サイトでも同様の質問を投げてます。)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T05:47:16.427", "favorite_count": 0, "id": "11758", "last_activity_date": "2015-06-26T05:56:00.087", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9336", "post_type": "question", "score": 1, "tags": [ "node.js" ], "title": "Node.jsで(同ドメインの)LocalStrageを取得する方法", "view_count": 918 }
[ { "body": "LocalStorage は Cookie などと同じくクライアント=ブラウザ側で記憶されるものです。また Cookie\nと違い、自動的にサーバーへ送信されることはありません。\n\nですから、 Node.js であろうと「サーバー側から LocalStorage の値を読みだす」ことはできません。\n\nLocalStorage からデータを取り出してサーバーに送る、といった処理をブラウザ側の Javascript で実装する必要があります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T05:56:00.087", "id": "11761", "last_activity_date": "2015-06-26T05:56:00.087", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "11758", "post_type": "answer", "score": 2 } ]
11758
11761
11761
{ "accepted_answer_id": "11766", "answer_count": 1, "body": "コード:\n\n```\n\n struct hoge {\n var a: Int = 0\n }\n \n var obj: hoge = hoge(a: 10)\n println(obj.a) //一度目のprintln\n obj.a = 5\n println(obj.a) //二度目のprintln\n \n```\n\n出力結果:\n\n```\n\n 10\n 5\n \n```\n\nコード:\n\n```\n\n struct hoge {\n var a: Int = 0\n }\n \n var obj: hoge = hoge(a: 10)\n //println(obj.a) //一度目のprintlnをコメントアウト\n obj.a = 5\n println(obj.a) //二度目のprintln\n \n```\n\n出力結果:\n\n```\n\n 10\n \n```\n\n上記の様に、一度目のprintlnを実行するかしないかで、二度目のprintlnの結果が変わってきます。(「obj.a = 5」が処理されていない?)\n\n実行環境は、<http://www.runswiftlang.com/> です。\n\nこれはswiftの仕様なのでしょうか? \nだとしたらどう理解すれば良いでしょうか?\n\nそれとも、<http://www.runswiftlang.com/> のバグなのでしょうか?\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T05:52:08.813", "favorite_count": 0, "id": "11759", "last_activity_date": "2015-06-26T06:30:46.013", "last_edit_date": "2015-06-26T06:25:47.157", "last_editor_user_id": "76", "owner_user_id": null, "post_type": "question", "score": 1, "tags": [ "swift" ], "title": "構造体のプロパティについて", "view_count": 80 }
[ { "body": "> それとも、<http://www.runswiftlang.com/> のバグなのでしょうか?\n\nその線がいちばん濃いと思います。\n\nXcode 6.3.2のPlaygroundで実行した結果がこちら。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/g6QQY.png)\n\nXcode 6.3.2のCommandLineToolで実行した結果がこちら。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/dIkn4.png)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T06:30:46.013", "id": "11766", "last_activity_date": "2015-06-26T06:30:46.013", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "11759", "post_type": "answer", "score": 0 } ]
11759
11766
11766
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在画面に7つの`UICollectionView`のセルがあり、一つのセルのサイズのみを変更し、他は全て同じサイズで表示させようとしているのですが、同じサイズの6つのセルが下の画像のように離れ離れで表示され、綺麗に詰めて表示がされません。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/iIywd.jpg)\n\nサイズを変更したコードは下記のようになっています。\n\n```\n\n -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {\n if (indexPath.row == 0) {\n return CGSizeMake(375, 200);\n } else {\n return CGSizeMake(188, 155);\n }\n }\n \n```\n\n一番上のセルだけ大きく、残りは全て同じサイズで隙間なく綺麗に並んで欲しいのです。もう少し詳しく言うと、一番上に画面の横いっぱいのサイズを持った大きなセルを配置し、その大きいセルの下に画面左側に3つのセルを配置し、大きいセルの下の画面右側に3つのセルを配置するというレイアウトです。どうすればよろしいでしょうか? \nどなたか分かる方がいれば教えていただきたいです。すみませんが、よろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T05:52:13.360", "favorite_count": 0, "id": "11760", "last_activity_date": "2015-06-26T23:32:35.573", "last_edit_date": "2015-06-26T23:32:35.573", "last_editor_user_id": "5210", "owner_user_id": "5210", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c", "uicollectionview" ], "title": "CollectionViewの一つのセルのみサイズを変更する", "view_count": 1021 }
[]
11760
null
null
{ "accepted_answer_id": "11769", "answer_count": 2, "body": "現在、TwitterのタイムラインのようなUIを持つアプリを開発しておりまして、実装方法に悩んでおります。\n\nあるユーザを選択した時に、ヘッダー部分にユーザのアイコンや自己紹介文を表示し、その下には、当該ユーザのコメントリストが並ぶというありきたりのUIとなります。また、ヘッダ部分は位置が固定ではなく、コメントリストのスクロールと共に上部へスライドしていくというものになります。\n\nそこで、単にListViewを用いて一度実装を行いました。\n\nArrayAdapterのgetViewをオーバーライドして、positionが0、つまりヘッダ部分のみ異なるレイアウトファイルを適用し、それ以外のpositionについては、コメントを表示するためのレイアウトファイルを適用して、当初予定していたUIは実装が行えました。\n\nその後、これを拡張することになり、ヘッダ部分内にタブ切り替えのようなボタンを配置し、選択されたボタンにより、下位のリスト内容をごっそり切り替えるということになりました。\n\nデフォルトでは、コメントリストなのですが、切り替えボタンを押すと、内容もレイアウトも全く異なるものを表示することになります。(例えば、当該ユーザがフォローしている他ユーザの一覧等。リスト形式であることには変わりません)\n\nヘッダ部分の内容は全く変更せず(ただし、選択されたボタンはハイライト化)、positionが1以降のリストを、内容もレイアウトも異なるものに切り替えるために、皆さんならどのように実装されるかご意見をお聞かせ願えないでしょうか。\n\n要件として、ヘッダー部のスクロール位置の変更はしないという制限があります。 (例えばちょっとだけスクロールしていて、一部が隠れている状態での切替時)\n\n私が今考えているのは、getViewの中で、現在positionが0かそれ以外でレイアウトファイルを切り替えるだけでなく、さらにどの切替ボタンが選択されているかで、適用するレイアウトファイルを増やすというものなのですが、何か強引な感じがして・・・\n\nもっとスマートな方法がございましたら、ご教示いただきたく。 (違うアクティビティなり、フラグメントに切り替えて、前画面と同じ位置にスクロールさせる等?)\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T06:02:33.497", "favorite_count": 0, "id": "11762", "last_activity_date": "2015-06-26T07:13:43.813", "last_edit_date": "2015-06-26T06:27:51.397", "last_editor_user_id": "76", "owner_user_id": "10298", "post_type": "question", "score": 1, "tags": [ "android" ], "title": "TwitterアプリのようなUIについて", "view_count": 601 }
[ { "body": "Androidですと、Action\nBarにTabを追加するのが一般です。Tab切替時に表示するFragmentを切り替えます。その上で、各フラグメント上に共通で表示したい物(ユーザ情報等)を部品化する設計にするのがよろしいかと思います。\n\n参考サイト \n<http://developer.android.com/guide/topics/ui/actionbar.html#Tabs> \n<http://android.keicode.com/basics/actionbar-tab.php> \n<http://qiita.com/mackiso/items/bb3cacac6c0bfb9eb3df>", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T06:49:43.830", "id": "11769", "last_activity_date": "2015-06-26T06:49:43.830", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10170", "parent_id": "11762", "post_type": "answer", "score": 1 }, { "body": "ヘッダー(タブ)はリストに含めないほうがよいと思います。\n\n[Design Support Library](http://android-\ndevelopers.blogspot.jp/2015/05/android-design-support-\nlibrary.html)の`CoordinatorLayout`は使えませんかね?\n\n参考:<https://guides.codepath.com/android/Handling-Scrolls-with-\nCoordinatorLayout>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T07:13:43.813", "id": "11771", "last_activity_date": "2015-06-26T07:13:43.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8216", "parent_id": "11762", "post_type": "answer", "score": 1 } ]
11762
11769
11769
{ "accepted_answer_id": null, "answer_count": 1, "body": "AサーバーBサーバに全データを移行して、また、データベースもAデータベースサーバーからBデータベースにインポートしましたら下記のエラーでました、なぜでしょうか? \nぜひご教授くださいませ\n\nStrict (2048): Declaration of BaseCompanyComponent::initialize() should be\ncompatible with Component::initialize(Controller $controller)\n[APP/Controller/Component/BaseCompanyComponent.php, line 999]\n\nStrict (2048): Declaration of CaptureUtilityComponent::initialize() should be\ncompatible with Component::initialize(Controller $controller)\n[APP/Controller/Component/CaptureUtilityComponent.php, line 66] \ntest CMS", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T06:06:28.453", "favorite_count": 0, "id": "11763", "last_activity_date": "2015-06-27T11:22:21.483", "last_edit_date": "2015-06-27T11:22:21.483", "last_editor_user_id": "49", "owner_user_id": "9013", "post_type": "question", "score": 0, "tags": [ "php", "cakephp" ], "title": "Cakeb DB 移行後 エラー Strict (2048): Declaration of BaseCompanyComponent::initialize()", "view_count": 3327 }
[ { "body": "PHP5以降、クラスを継承してメソッドを上書きする際には親クラスと互換性のある宣言を使う必要があります。 `Declaration of A::hoge()\nshould be compatible with B::hoge(...)` は「A が B を継承しているが、 `hoge()`\nの宣言に互換性がない」といったものです。\n\n[PHP: クラスの抽象化 - Manual](http://php.net/manual/ja/language.oop5.abstract.php)\n\nCakePHP 2.x の `Component::initialize()` は次のように宣言されています。\n\n```\n\n public function initialize(Controller $controller) {\n }\n \n```\n\nこれを継承する `CaptureUtilityComponent::initialize()` が次のような宣言になっていませんか?\n\n```\n\n // NG: private は親クラスに比べて可視性が低い -> public にしましょう\n private initialize(Controller $controller) {\n }\n \n // NG: 型ヒントがなくなっている -> つけましょう\n public initialize($controller) {\n }\n \n // NG: 必須引数が増えている -> デフォルト値を指定するか、別メソッドにする\n public initialize(Controller $controller, $hoge) {\n }\n \n```\n\nなお今回のケースでは両方とも PHP 5.x とのことなので、元のサーバーでは php.ini の error_reporting が E_STRICT\nを含んでいなかったために、エラーが表示されなかったのだと思います。\n\nその他の設定も異なる可能性がありますから、両サーバーの php.ini を比較してみてください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T06:51:08.253", "id": "11770", "last_activity_date": "2015-06-26T06:51:08.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "11763", "post_type": "answer", "score": 1 } ]
11763
null
11770
{ "accepted_answer_id": null, "answer_count": 0, "body": "良い autotools 向けのコーディング規約があったら教えてください。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T08:14:58.657", "favorite_count": 0, "id": "11772", "last_activity_date": "2015-06-26T08:14:58.657", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10300", "post_type": "question", "score": 1, "tags": [ "makefile" ], "title": "autotools 向けのコーディング規約はありますか?", "view_count": 144 }
[]
11772
null
null
{ "accepted_answer_id": "11775", "answer_count": 1, "body": "```\n\n buildscript {\n ext.kotlin_version = '0.12.613'\n ext.kotlin_version = '0.12.412'\n \n repositories {\n \n jcenter()\n mavenCentral()\n \n }\n \n dependencies {\n \n classpath 'com.android.tools.build:gradle:1.2.3'\n classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n classpath \"org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version\"\n \n }\n }\n \n apply plugin: \"com.android.application\"\n apply plugin: 'kotlin-android'\n \n repositories {\n \n jcenter()\n mavenCentral()\n \n }\n \n android {\n \n compileSdkVersion 22\n buildToolsVersion \"22.0.1\"\n \n defaultConfig {\n \n applicationId \"jp.trustridge.macaroni.app\"\n minSdkVersion 16\n targetSdkVersion 22\n versionCode 10\n versionName \"1.6\"\n \n }\n \n compileOptions {\n \n sourceCompatibility JavaVersion.VERSION_1_7\n targetCompatibility JavaVersion.VERSION_1_7\n \n }\n \n buildTypes {\n \n release {\n \n minifyEnabled true\n proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n \n }\n \n }\n \n sourceSets {\n \n main.java.srcDirs += 'src/main/kotlin'\n \n }\n }\n \n dependencies {\n \n compile 'com.android.support:support-v13:+'\n compile 'com.android.support:appcompat-v7:+'\n compile 'com.android.support:recyclerview-v7:+'\n compile 'com.google.android.gms:play-services:+'\n \n \n compile \"org.jetbrains.kotlin:kotlin-stdlib:+\"\n \n compile 'com.parse.bolts:bolts-android:+'\n \n compile fileTree(dir: 'libs', include: ['*.jar'])\n \n // volley\n compile 'com.mcxiaoke.volley:library:+'\n \n // realm\n compile 'io.realm:realm-android:+'\n compile \"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version\"\n \n // adjust\n //compile 'com.adjust.sdk:adjust-android:+'\n \n }\n \n```\n\n質問 \n勉強しながらソースを解析しています。 \nGradleについて調べています。環境はAndroidStudio1.2.2です。 \n場所はプロジェクト名/app/build.gradle\n\ndependenciesにGradleでビルドしたい外部ライブラリが書いてあると思っています。 \n上記の場合コトリンに関するもの2つ含めた、クラスパスが3つあります。 \nこちらについては最新があれば勝手にダウンロードして更新されるもの。\n\nこれとは別にapp/libsの中にParse-182.jarともうひとつJarファイルが入っています。 \nこちらは更新される事なく使われ続ける外部ライブラリ。\n\nこのプロジェクトは上記以外には外部ライブラリは使われて無い。 \n以上の事は正しいでしょうか?よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T08:16:27.020", "favorite_count": 0, "id": "11773", "last_activity_date": "2015-06-26T09:45:16.580", "last_edit_date": "2015-06-26T09:33:20.607", "last_editor_user_id": "2356", "owner_user_id": "10291", "post_type": "question", "score": 0, "tags": [ "android", "gradle" ], "title": "Gradle プロジェクト名/app/build.gradleについて", "view_count": 1492 }
[ { "body": "このbuild.gradle内にdependencies というブロックが2カ所出現しています。 \n一つは先頭のbuildscript配下。もう一つは後ろの方にルートレベルで。\n\nそれぞれ以下のようになっています。\n\n * buildscript配下のdependenciesはGradleのプラグイン等のようにビルド仕組み自体で必要な外部依存モジュール\n * 直下のdependenciesはビルド処理中にコンパイルや実行のために使われる外部依存モジュール\n\nそれぞれ記述方法が若干違います(先頭のキーワードをclasspathと書くか、compileと書くか、など)。\n\n以上を踏まえて回答します。\n\n> dependenciesにGradleでビルドしたい外部ライブラリが書いてあると思っています。\n\nNo. \n表現上の問題かもしれませんが「 **ビルドしたい** 外部ライブラリ」ではなく、厳密に言えば、前述のように「ビルドの仕組みで **使う**\n外部ライブラリ」または「コンパイルや実行時に **使う** 外部ライブラリ」です。\n\n> 上記の場合コトリンに関するもの2つ含めた、クラスパスが3つあります。\n\nこれはbuildscript配下の方のdependenciesですね。\n\n> こちらについては最新があれば勝手にダウンロードして更新されるもの。\n\nYes. \nbuildscript配下のもルートの方もどちらも、ビルド実行時に自動的にダウンロードされます。 \n2カ所あるrepositoriesのどちらにもjecenterとmavenCentralが定義されているので、指定された外部モジュールはまずJCenterからダウンロードしようとして、そこで見つからないと次にMavenセントラルからダウンロードしようとします。どちらにも見つからなければ依存関係解決エラーになります。\n\n> これとは別にapp/libsの中にParse-182.jarともうひとつJarファイルが入っています。 \n> こちらは更新される事なく使われ続ける外部ライブラリ。\n\n`app/libs`→`libs`でしょうか?\n\n直下の方のdependenciesに、以下のような記述があります。\n\n```\n\n compile fileTree(dir: 'libs', include: ['*.jar'])\n \n```\n\nこれは`libs`配下にあるすべての拡張子jarのファイルをコンパイル時&実行時の依存ライブラリとする、というファイル依存関係を示しています。 \nlibs/Parse-182.jarが利用できるのは、この設定が効いているためです。\n\n> このプロジェクトは上記以外には外部ライブラリは使われて無い。\n\nNo. \ndependencies配下に上記のfileTree意外に9個のcompileへの依存関係が定義されています。 \nこれらも外部ライブラリとして使われています。\n\nちなみに、`compile` という記述は「コンフィギュレーション」といいます。 \nGradleではコンフィギュレーションごとに依存関係を定義できます。 \n`compile`は、「プロダクトコードのコンパイル時&実行時」「テストコードのコンパイル時&テスト実行時」に対する依存関係となります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T09:38:24.673", "id": "11775", "last_activity_date": "2015-06-26T09:45:16.580", "last_edit_date": "2015-06-26T09:45:16.580", "last_editor_user_id": "2356", "owner_user_id": "2356", "parent_id": "11773", "post_type": "answer", "score": 1 } ]
11773
11775
11775
{ "accepted_answer_id": "11786", "answer_count": 1, "body": "railsのあるmodelで複数のscopeを使いオブジェクトの並べ方を定義しています。\n\n```\n\n scope :scope_A, -> { where(...).order('created_at DESC') }\n scope :scope_B, -> { ......... }\n scope :scope_C, -> { ........ }\n \n```\n\nこの3つのscope結果を上から順番に取り出して結合した結果を得るにはどうすればいいのでしょうか? \n例えばscope_A の結果が `A1,A2,A3` \nscope_B の結果が `B1,B2,B3` \nscope_C の結果が `C1,C2,C3` とすると \n結合結果が `A1,A2,A3,B1,B2,B3,C1,C2,C3` のように並べたいと考えています。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T08:32:16.033", "favorite_count": 0, "id": "11774", "last_activity_date": "2015-06-27T02:32:47.753", "last_edit_date": "2015-06-26T14:22:08.140", "last_editor_user_id": "9202", "owner_user_id": "9202", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "rails-activerecord" ], "title": "複数のscopeの結果をひとつにまとめる方法は?", "view_count": 3608 }
[ { "body": "PostgreSQLのように行番号(ここでは ROW_NUMBER)が簡単に取れるRDBMSを使うことが前提ですが、こんなふうに実装するのはどうでしょうか?\n\n```\n\n class Language\n scope :ruby, ->{ where(lang_type: :ruby).order(:id) }\n scope :perl, ->{ where(lang_type: :perl).order(:id) }\n scope :java, ->{ where(lang_type: :java).order(:id) }\n \n def self.order_by_lang_type\n full_sql = %w(ruby perl java).map.with_index {|type, i|\n sql = self.send(type).select(\"#{i} AS type_no, ROW_NUMBER() OVER() AS row_no, languages.*\").to_sql\n \"SELECT * FROM (#{sql}) AS t_#{i}\"\n }.join(\" UNION ALL \") + \" ORDER BY type_no, row_no\"\n \n self.find_by_sql(full_sql)\n end\n end\n \n```\n\n参考にしたページはこのあたりです。\n\n * [Rails - ActiveRecordでunion使いたい - Qiita](http://qiita.com/kwgch/items/11d88d50bdfb183d6207)\n * [ms access - SQL Query - Using Order By in UNION - Stack Overflow](https://stackoverflow.com/questions/213851/sql-query-using-order-by-in-union)\n\nがんばればscopeにもできるようです。\n\n```\n\n scope :order_by_lang_type, -> {\n full_sql = %w(ruby perl java).map.with_index {|type, i|\n sql = self.send(type).select(\"#{i} AS type_no, ROW_NUMBER() OVER() AS row_no, languages.*\").to_sql\n \"SELECT * FROM (#{sql}) AS t_#{i}\"\n }.join(\" UNION ALL \")\n \n select(\"t.*\").from(Arel.sql(\"(#{full_sql}) as t\")).order('t.type_no, t.row_no')\n }\n \n```\n\n参考ページ: [ruby on rails - Turn SQL query into ActiveRecord Relation - Stack\nOverflow](https://stackoverflow.com/questions/16324305/turn-sql-query-into-\nactiverecord-relation)\n\nとはいえ件数が少なければ単純に \"+\" で連結するのありかもしれません。\n\n```\n\n def self.order_by_lang_type\n ruby + perl + java\n end\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T23:01:00.650", "id": "11786", "last_activity_date": "2015-06-27T02:32:47.753", "last_edit_date": "2017-05-23T12:38:56.083", "last_editor_user_id": "-1", "owner_user_id": "85", "parent_id": "11774", "post_type": "answer", "score": 1 } ]
11774
11786
11786
{ "accepted_answer_id": "11778", "answer_count": 2, "body": "昨日と同じ質問で申し訳ありません。 \n**[https://ja.stackoverflow.com/questions/11732/シェルスクリプトでnode-\njsがすでにインストール済みかチェックするには/11740#11740](https://ja.stackoverflow.com/questions/11732/%E3%82%B7%E3%82%A7%E3%83%AB%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%A7node-\njs%E3%81%8C%E3%81%99%E3%81%A7%E3%81%AB%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E6%B8%88%E3%81%BF%E3%81%8B%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF/11740#11740)**\n\nMac側ではシェルスクリプトにて、Node.jsのインストール済み確認ができ、 \nファイルサーバーを構築する事ができました。\n\nWindowsを使用しているデザイナーさんもいるため \nPowerShellでも同じことをしたいです。 \nですがアプリのインストール一覧の取得は検索でヒットしますが、指定アプリのインストール済みをチェックする方法がわかりません。\n\nまた、できるだけデザイナーさんのインストールの手間などを省くために \nPowerShellを使用してスクリプトを作っていますが、結構苦戦しています。\n\nWindows上でシェルスクリプトを実行するのに、PowerShell以外のツールで \nおすすめがあれば教えていただけませんか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T11:13:27.423", "favorite_count": 0, "id": "11777", "last_activity_date": "2015-06-26T21:45:44.143", "last_edit_date": "2017-04-13T12:52:39.113", "last_editor_user_id": "-1", "owner_user_id": "5261", "post_type": "question", "score": 2, "tags": [ "windows", "node.js", "powershell", "shellscript" ], "title": "PowerShellにてアプリのインストールチェックをするには?", "view_count": 1735 }
[ { "body": "Windows vista 以降のwindowsの場合パスが通っているコマンドの検索に`WHERE`を使うことができます。 \nそれを利用して、\n\n```\n\n if (where.exe node 2> $null) { # コマンドがある場合\n #Write-Output 'Find!'\n } else { #コマンドがない場合\n #Write-Error 'Error!'\n }\n \n```\n\nのようにnodeコマンドが使える場合と使えない場合のスクリプトを書くことができます。\n\n* * *\n\n$lastexitcode を使う方法\n\n```\n\n where.exe /Q node\n if ($lastexitcode -eq 0) { # コマンドがある場合\n Write-Output 'Find!'\n } else { #コマンドがない場合\n #Write-Error 'Error!'\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T12:06:34.573", "id": "11778", "last_activity_date": "2015-06-26T21:45:44.143", "last_edit_date": "2015-06-26T21:45:44.143", "last_editor_user_id": "5044", "owner_user_id": "5044", "parent_id": "11777", "post_type": "answer", "score": 4 }, { "body": "無事できました。\n\n■教えていただいた最適な方法\n\n```\n\n if (where.exe node 2> Out-Null) { # コマンドがある場合\n #Write-Output 'Find!'\n echo \"Find\"\n } else { #コマンドがない場合\n #Write-Error 'Error!'\n echo \"None\"\n Invoke-WebRequest -Uri https://nodejs.org/dist/v0.12.5/x64/node-v0.12.5-x64.msi -OutFile ./node.msi\n ./node.msi -ms\n }\n \n```\n\n■自分で調べて作ってみた方法\n\n```\n\n $exist = 0\n $path = \"\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\"\n $wow = \"HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\"\n $patharray = (\"HKLM:\" + $path),(\"HKCU:\" + $path)\n if(Test-Path $wow){$patharray += $wow}\n Get-ChildItem -Path $patharray | foreach {\n $CurrentKey = (Get-ItemProperty -Path $_.PsPath) |\n ?{$_.systemcomponent -ne 1 -and $_.parentkeyname -eq $null} |\n sort displayname |\n select DisplayName\n echo $CurrentKey\n if ($CurrentKey -match 'Node.js') {\n $exist = 1\n echo \"*****NodeJs OK*****\"\n echo $exist\n }\n }\n \n \n if($exist -eq 1){\n echo \"NodeJs がありました。\"\n }\n else{\n echo \"NodeJs のインストールが必要です。。\"\n Invoke-WebRequest -Uri https://nodejs.org/dist/v0.12.5/x64/node-v0.12.5-x64.msi -OutFile ./node.msi\n ./node.msi -ms\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T12:21:40.017", "id": "11780", "last_activity_date": "2015-06-26T12:21:40.017", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5261", "parent_id": "11777", "post_type": "answer", "score": 0 } ]
11777
11778
11778
{ "accepted_answer_id": null, "answer_count": 1, "body": "gulp-watchで監視中のフォルダに新しくフォルダを作成してリネームした場合、ENOENTエラーが出て監視がストップしてしまいます。 \n日本語のフォルダ名を使用しないという対応ではなく、 \nできれば、気軽にフォルダを追加できるようにしたいです。\n\nOSはMacとWindowsの両方で試しました。 \nnodeのバージョンはv0.12.5 gulpのversionは3.9.0です。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T13:11:18.800", "favorite_count": 0, "id": "11781", "last_activity_date": "2015-08-01T17:51:28.337", "last_edit_date": "2015-06-27T02:17:17.757", "last_editor_user_id": "10306", "owner_user_id": "10306", "post_type": "question", "score": 2, "tags": [ "javascript", "node.js", "gulp" ], "title": "gulp-watchで監視しているフォルダ内で日本語フォルダを入れるとエラーでストップ", "view_count": 827 }
[ { "body": "MAC&WINDOWS両方のOSで、問題が解決いたしました。\n\n```\n\n gulp.watch\n \n```\n\nを使わずに\n\n```\n\n gulp-watch\n \n```\n\nという[プラグイン](https://www.npmjs.com/package/gulp-\nwatch)を使うことで、監視がストップする状況は回避出来ました。\n\n【2015/07/01追記】WINDOWSの場合、フォルダの削除でエラーが発生して監視がストップしてしまいます。 \n【2015/0702追追記】WINDOWSでフォルダ削除時にエラーが発生して監視がストップしてしまう件ですが、gulp-\nwatch制作者が以前、別件で回答している内容で理解いたしました。\n\n> vinyl-file is not about directories (as gulp itself), so events\n> forcreateanddeleteon directories are not emitted. If there is any files in\n> this directory - then you will getunlink ` event for these files.\n\n[gulp-watch制作者の回答](https://github.com/floatdrop/gulp-watch/issues/70)\n\nMACの場合は、ディレクトリごと削除してもエラー発生していなかったのですが、 \nWINDOWSの場合は、ファイルを全て削除した上で、フォルダを削除すれば、上記エラーの発生を回避できました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T03:17:26.373", "id": "11868", "last_activity_date": "2015-07-02T05:19:29.887", "last_edit_date": "2015-07-02T05:19:29.887", "last_editor_user_id": "10306", "owner_user_id": "10306", "parent_id": "11781", "post_type": "answer", "score": 1 } ]
11781
null
11868
{ "accepted_answer_id": null, "answer_count": 1, "body": "Androidの画像処理ライブラリPicassoを使って、以下の画像処理した時以下のTransformationを実装したクラスでreturnされず(recycleまではされている)に何度も、このメソッドがループ?して最終的に画像サイズや切り取り位置の値が以下のようになりクラッシュします。もと画像にサイズは640×480です。他の画像ではできているのでなんでそうなるのかさっぱりわかりません。原因がわかれば教えていただければ幸いです。よろしくおねがいします。\n\n画像URL \n<https://i.ytimg.com/vi/RFinNxS5KN4/sddefault.jpg>\n\nPicassoの利用箇所\n\n```\n\n Picasso.with(mContext)\n .load(APIUtil.checkThumbnail(item))\n .transform(new ViewUtils.TopThumbnailEditor())\n .placeholder(R.drawable.top_thumbnail_placeholder)\n .fit()\n .into(holder.thumbnail);\n \n```\n\nTransformation実装クラス\n\n```\n\n private static final float THUMBNAIL_HEIGHT_DIVINER = 9f/16f;\n private static final float TOP_HEIGHT_DIVINER = 16f/43f;\n \n public static class TopThumbnailEditor implements Transformation{\n \n @Override\n public Bitmap transform(Bitmap source) {\n float width = source.getWidth();\n float height = source.getHeight();\n \n float newHeight = width * THUMBNAIL_HEIGHT_DIVINER;\n float heightCutSize = (height - newHeight)/2;\n newHeight = width * TOP_HEIGHT_DIVINER;\n float moreHeightCutSize = newHeight/2;\n \n Bitmap result = Bitmap.createBitmap(source, 0, (int)(heightCutSize+moreHeightCutSize), (int)width, (int)newHeight);\n if(result!=source)\n source.recycle();\n return result;\n }\n \n @Override\n public String key() {\n return \"TopThumbnailEditor\";\n }\n }\n \n```\n\n最終的な画像のサイズ、切り取り位置など\n\n```\n\n width: 1020.0\n height: 379.0\n X座標の切り取り位置: -97.375\n Y座標の切り取り位置: 189.76744\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T13:38:19.473", "favorite_count": 0, "id": "11782", "last_activity_date": "2015-07-30T01:57:21.643", "last_edit_date": "2015-06-26T14:22:26.567", "last_editor_user_id": "7232", "owner_user_id": "7232", "post_type": "question", "score": 2, "tags": [ "android" ], "title": "Picassoで特定の画像を処理した時に、returnされない。", "view_count": 371 }
[ { "body": "うまく動く他の画像というのはワイド画像ではないですか?\n\n```\n\n private static final float THUMBNAIL_HEIGHT_DIVINER = 9f/16f;\n \n```\n\nで入って来る画像は16:9だと決め込んでいるのに4:3を渡すから負の座標が作られて、後段がエラーになってループするのだと思いますが。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T01:18:57.703", "id": "11864", "last_activity_date": "2015-06-30T01:18:57.703", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8136", "parent_id": "11782", "post_type": "answer", "score": 2 } ]
11782
null
11864
{ "accepted_answer_id": "11784", "answer_count": 1, "body": "[こちらのサイト](http://lchikaamazon.hatenablog.com/entry/2013/11/18/171637)を参考にボタンでRaspberry\nPiに命令を送ることが出来るようになったのですが、ボタンひとつに付き、電源とGPIOとGroundが必要になるようでボタンを5つ作りたいのに電源が4つしか見つからず困っています。\n\n何か方法があるとは思うのですが、このような場合どう対処するもなのでしょうか? \n恥ずかしながら電子工作の知識は全くといっていいほどない状態です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T13:44:02.517", "favorite_count": 0, "id": "11783", "last_activity_date": "2018-05-11T03:51:18.247", "last_edit_date": "2018-05-11T03:51:18.247", "last_editor_user_id": "3060", "owner_user_id": "3271", "post_type": "question", "score": 3, "tags": [ "raspberry-pi", "gpio" ], "title": "Raspberry Piにボタンを5個以上設定する方法", "view_count": 1976 }
[ { "body": "ブレッドボードを使う場合の例ですが、こんな感じに配線すれば電源をたくさん引き出す必要はありません。\n\n * 青: GPIO\n * 赤: 3.3V\n * 黒: Ground \n(図では赤を2ピンに接続してありますが、1ピン/3.3Vに接続してください)\n\n![回路](https://i.stack.imgur.com/APIbP.png)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-26T15:21:22.883", "id": "11784", "last_activity_date": "2016-01-15T02:33:25.307", "last_edit_date": "2016-01-15T02:33:25.307", "last_editor_user_id": "-1", "owner_user_id": "3639", "parent_id": "11783", "post_type": "answer", "score": 8 } ]
11783
11784
11784
{ "accepted_answer_id": null, "answer_count": 1, "body": "タイトルの通りです。Angularを採用したフォームで、テキストボックスの値が送信されたらcontroller側で空にする処理を書いているのですが、ng-\nrepeat内で思うように動作しなくて苦戦しているので質問させていただきました。\n\n1つのshopの中にn個のitem_listがあり、そのなかに紐付く形で複数のitemが格納されているという前提です。\n\nshop(1) -> item_list(n) -> item(n)\n\nng-repeatの外(コメントアウトしている部分のコード)では問題なくフォームを送信後にテキストボックスが空にできるのですが、ng-\nrepeatの中で同じことができなくて困っています。特定のテキストボックスを空にするのではなく、itemBodyに関連づいたテキストボックスを全て空にしたいだけなくのですが上手くいきません...\nどうかよろしくお願いいたします。\n\n```\n\n angular.module('angularApp').controller \"ShopController\", ($scope) ->\n $scope.addItem = (itemBody, contentId) ->\n $scope.itemBody = \"\"\n \n```\n\n-\n```\n\n .container ng-controller=\"ShopController\" ng-init=\"init()\"\n \n //form id=\"new_item\" ng-submit=\"addItem(itemBody, item_list.id)\"\n //input type=\"text\" id=\"itemBody\" ng-model=\"itemBody\"\n //input type=\"submit\" value=\"追加\"\n \n ul\n li ng-repeat=\"item_list in article.item_lists\"\n ul\n li ng-repeat=\"item in item_list.items\"\n input type=\"submit\" value=\"削除\" ng-click=\"deleteItem(item)\"\n \n form id=\"new_item\" ng-submit=\"addItem(itemBody, item_list.id)\"\n input type=\"text\" id=\"itemBody\" ng-model=\"itemBody\"\n input type=\"submit\" value=\"追加\"\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T04:18:53.260", "favorite_count": 0, "id": "11789", "last_activity_date": "2015-07-29T06:47:13.863", "last_edit_date": "2015-06-29T01:47:03.973", "last_editor_user_id": "9900", "owner_user_id": "10309", "post_type": "question", "score": 2, "tags": [ "angularjs", "coffeescript" ], "title": "Angularでフォームが送信された後、テキストボックスを空にしたい", "view_count": 1270 }
[ { "body": "`ng-repeat`が新たにスコープを生成するので参照ができていないのだと思います。 \nひとまず下記のように記述すれば入力欄は空になると思います。 \n※その他の処理への影響は保証できませんのでご了承ください。\n\nhtml \n`addItem`の第一引数を`this`に変更\n\n```\n\n form id=\"new_item\" ng-submit=\"addItem(this, item_list.id)\"\n input type=\"text\" id=\"itemBody\" ng-model=\"itemBody\"\n input type=\"submit\" value=\"追加\"\n \n```\n\njs \n`addItem`の第一引数を`<object>`に変更 \n`itemBody`を`<object>.itemBody`に変更\n\n```\n\n angular.module('angularApp').controller \"ShopController\", ($scope) ->\n $scope.addItem = (obj, contentId) ->\n obj.itemBody = \"\"\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T05:48:01.193", "id": "11839", "last_activity_date": "2015-06-29T05:48:01.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3516", "parent_id": "11789", "post_type": "answer", "score": 1 } ]
11789
null
11839
{ "accepted_answer_id": "11792", "answer_count": 1, "body": "![画像の説明をここに入力](https://i.stack.imgur.com/MA9xW.png) \nあるサイトでfont-familyがsans-serifが適用されているにも関わらずMeiryoで描画されていました。 \ncssの中を確認した所font-familyはsans-serifしか設定されていません。\n\nsans-serifが無かった場合Meiryoで描画されるのかと思い、 \n同じように作ってみたのですが、MeiryoではなくMS PGothicで描画されてしまいました。\n\nRendered Fontsに適用されるフォントはfont-family以外何か別の方法があるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T04:52:38.287", "favorite_count": 0, "id": "11791", "last_activity_date": "2015-06-27T05:25:18.820", "last_edit_date": "2015-06-27T05:25:18.820", "last_editor_user_id": "3639", "owner_user_id": "4191", "post_type": "question", "score": 3, "tags": [ "css" ], "title": "Rendered Fontsに適用されるフォントについて", "view_count": 2415 }
[ { "body": "`sans-serif`というのはフォントの種類を指定するためのキーワードです。`sans-\nserif`という名前のフォントが存在するわけではありません。これは`generic\nfamily`と呼ばれ、他にも`cursive`や`monospace`などのキーワードがあります。\n\n実際にRendered\nFontsに適用されるフォントはブラウザ側でキーワードから自動的に判断されます。chromeの場合は`chrome://settings/fonts`を開くとキーワードとフォントの関連付けを変更できます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T05:25:01.803", "id": "11792", "last_activity_date": "2015-06-27T05:25:01.803", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "11791", "post_type": "answer", "score": 3 } ]
11791
11792
11792
{ "accepted_answer_id": "11959", "answer_count": 3, "body": "Ubuntuでの1ディレクトリあたりのファイル数上限、容量上限はあるのでしょうか? \nある場合は教えていただけますでしょうか。\n\n現在CMSを構築していて記事のサムネイル画像を記事IDと紐付けて保存している状況でして、 \n上記のようなことが気になりました。 \n何十万という記事が書かれ、その分サムネイルが設定される場合は問題が生じるのか気になっております。 \nUbuntu 14.04 LTSを使用しております。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T07:59:53.853", "favorite_count": 0, "id": "11794", "last_activity_date": "2015-07-02T09:50:38.677", "last_edit_date": "2015-06-27T10:31:44.590", "last_editor_user_id": "3639", "owner_user_id": "7641", "post_type": "question", "score": 8, "tags": [ "linux", "ubuntu", "filesystems" ], "title": "Ubuntuでの1ディレクトリあたりのファイル数上限、容量上限はあるのでしょうか?", "view_count": 43427 }
[ { "body": "おそらく、ファイルシステム単位で利用可能な `i-node` の最大数の事をおっしゃられているのかと思いますが、例えば以下の様にして確認する事ができます。\n\n```\n\n $ df -i .\n Filesystem Inodes IUsed IFree IUse% Mounted on\n /dev/sda7 1831424 78532 1752892 5% /home\n \n```\n\n特に説明しなくても表示されている内容はお分かりいただけるかと思います。\n\nまた、`tune2fs` コマンドでも同等の結果を得ることができます。\n\n```\n\n $ sudo tune2fs -l /dev/sda7 | grep -i inode\n :\n Inode count: 1831424\n Free inodes: 1750561\n :\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T09:35:41.543", "id": "11796", "last_activity_date": "2015-06-27T09:35:41.543", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "11794", "post_type": "answer", "score": 6 }, { "body": "実質的に上限はないと思って構いません。ただし、上限が無いからと言って数万ものファイルを置くような設計にすればすぐにパフォーマンストラブルに見舞われると思います。\n\nまず、ディレクトリが管理できるファイル数ですが、ディレクトリの実態はファイル名と所在するi-\nnodeの番号を記入したファイルです。管理するファイルが多くなるほど、記録したファイルの名前が長いほどディレクトリのサイズも大きくなっていきます。そういう意味では一つのディレクトリが管理できる上限はファイルシステムで作成できる最大のファイルサイズになるまで、ということになります。しかし、現実的には数TB位のストレージ全部をディレクトリで使うわけにもいかず、もちろんメモリにも読み込めず、全く実用になりません。\n\nプロバイダのブログが日付でディレクトリを分けているのは一つのディレクトリのファイルが多くならないよう設計されているのです。おおくても1ディレクトリあたり数千に止めるよう設計される方がいいと思います。これでも、トラブルがあると表示さえできず、パニックになりますが。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T09:08:09.687", "id": "11824", "last_activity_date": "2015-06-28T09:08:09.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8136", "parent_id": "11794", "post_type": "answer", "score": 1 }, { "body": "クォータを設定していない前提であれば ファイル数がinodeの最大値に達するもしくは マウントポイントの最大容量が上限になります。\n\n性能については、ディレクトリ内のファイル郡をリストアップする場合や\n検索するような場合はファイルが多いほど負荷が上がり性能が劣化します。ファイル名がわかっていて直接ファイルを読み書き出来る場合は性能劣化は見られません。\n\nCMSはわかりませんが、記事とサムネイル画像の紐付をDB等で管理されていて ファイル名がわかっているのであればファイルの読み書きの性能劣化はないと思います。\n\nディレクトリ内のファイルを検索して画像を探すような場合は CPU負荷、メモリ使用量、ディスクIOが増え、応答時間は長くなるでしょう。\n\nまたShellでのファイル操作するが面倒になります。(ls が終わらない、ファイル名の展開が終わらない、引数が多すぎてコマンドに渡せない、など)\n\nどのくらいの数で性能が劣化するかは、お使いの環境によって違いますので性能測定を実施して適切な数を見極めるといいと思います。\n\n以下、どこまでファイルを作成できるか実験した結果です。\n\n環境\n\n * VirtualBox VM \n * 1024 MB Memory\n * Processor 6\n * Sotrage Controller : IDE \n * Disk 1 16.00GB main.vdi (/dev/sda)\n * Disk 2 100.00 GB test.vdi (/dev/sdb)\n * Centos7.1\n\n100GB の ext4 ファイルシステム構築後 Inodes の値は 10 使用、6,553,590 がフリーでした。\n\n```\n\n FileSystem Inodes IUsed IFree IUse% Mounted on\n /dev/sdb1 6553600 10 6553590 1% /var/test\n \n```\n\n1,000,000,000 Bytes のファイルを split で 10バイトずつ分割し 一億個のファイル作成を試みますが途中でエラー終了しました。\n\n```\n\n # dd if=/dev/zero of=zero.dat bs=1000 count=1000000\n \n # split -a 8 -b 10 zero.dat\n split: xaaaoiwra: No space left on device\n \n```\n\nファイルの数はIFreeで表示された値と同じでした。なお、数えている間 ls コマンドは\nCPUが30-100%くらいメモリは85%くらい消費した状態で、1時間以上かかりました。\n\n```\n\n # time ls -1 | wc -l\n 6553590\n \n real 68m27.671s\n user 1m2.893s\n sys 21m7.490s\n \n```\n\nIUse% は 100% 使用中となり、これ以上ファイルを作成できない状態だとわかります。\n\n```\n\n # df -i\n Filesystem Inodes IUsed IUse% Mounted on\n /dev/sdb1 6553600 6553600 100% /var/test\n \n```\n\nディスクの容量は 27GB Used ですのでまだ余裕があります。\n\n```\n\n # df -h\n Filesystem Size Used Avail Use% Mounted on\n /dev/sdb1 99G 27G 68G 29% /var/test\n \n```\n\nファイル名を直接指定して読み書きした場合、目立った遅延はありませんでした。\n\n```\n\n # time od -x xaaaaxxxx\n 00000000 0000 0000 0000 0000 0000\n 00000012\n \n real 0m0.169s\n user 0m0.000s\n sys 0m0.008s\n \n```\n\nShellのファイル名の補完や正規表現の展開は恐ろしく時間がかかりますし 引数が多すぎて rm xa* などはエラーになりました。\n\nファイルの削除は次のように行いました。\n\n```\n\n # ls -1 | egrep -e '^xa*$' |xargs rm\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-02T09:50:38.677", "id": "11959", "last_activity_date": "2015-07-02T09:50:38.677", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "11794", "post_type": "answer", "score": 7 } ]
11794
11959
11959
{ "accepted_answer_id": "11801", "answer_count": 3, "body": "軽いメモを取るときにGmailのメール下書きを利用しています。\n\n理由としては、PCがフリーズしてもGmailの下書きであれば、データが残るからです。\n\nMacOS X Yosemiteを利用していますが、何故かブラウザで動画を閲覧しているとフリーズすることが頻繁に発生します。(Flashのせい?)\n\n本日、たまたまEmacsでメモをとっており、メモの途中で電話が入り、そこで動画を閲覧していたところ、OSがフリーズしてしまいました。\n\nマルチディスプレイで、Emacsを画面に表示したままだったので、アナログ的にモニタをiphoneのカメラで撮影することで、なんとかテキストを失うことは避けれたのですが、これがディスプレイに表示されていなかったらということを考えるとフリーズが恐ろしくてたまりません。\n\nいちいちGmailを利用するのも面倒なので、Emacsのスクラッチバッファが自動保存される仕組みが作ることができればよいのでは?とおもいました。\n\n既にemacsでファイルを保存すると、その段階で`~/.emacs.d/backup`にもバックアップを作成するような設定は行っていますので(1日だけでものすごい大量のファイルが作られますが)、スクラッチバッファのテキストを`~/.emacs.d/.scratch`などに自動保存できれば、恐らくそれだけで世代バックアップもできると考えられますので素敵だなと思っています。\n\nemacsで指定時間放置または指定文字以上の編集が行われた時に自動保存する仕組みが備わっているのは、わりとよく聞く話で、検索すると設定方法も出てくるのですが、この自動保存の仕組をスクラッチバッファのみ有効にする方法がわかりません。できれば、その自動保存の条件(放置時間やタイプ数)もカスタマイズしたいとおもっていますので、以下の3点を教えていただきたいです。\n\n 1. スクラッチバッファを自動保存するelisp\n 2. 操作の放置による自動保存発動時間の設定方法\n 3. テキスト入力数による自動保存発動文字数の設定方法\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T08:23:47.553", "favorite_count": 0, "id": "11795", "last_activity_date": "2020-05-16T22:58:41.773", "last_edit_date": "2020-05-16T22:58:41.773", "last_editor_user_id": "19110", "owner_user_id": "5840", "post_type": "question", "score": 1, "tags": [ "emacs", "elisp" ], "title": "emacsでスクラッチバッファのテキストを自動保存したい。", "view_count": 739 }
[ { "body": "`*scratch*` バッファで以下を実行するとできます。\n\n```\n\n ; 自動保存を有効にする\n (auto-save-mode)\n \n ; 自動保存するまでの時間\n (make-local-variable 'auto-save-timeout)\n (setq auto-save-timeout 10)\n \n ; 自動保存するまでのタイプ数\n (make-local-variable 'auto-save-interval)\n (setq auto-save-interval 20)\n \n```\n\n追記: ~/.emacs.d/init.el とのことですので、以下のようにするとよろしいかと思います。\n\n```\n\n (setq initial-buffer-choice t)\n (add-hook 'emacs-startup-hook\n (function\n (lambda ()\n (auto-save-mode)\n (make-local-variable 'auto-save-timeout)\n (setq auto-save-timeout 10)\n (make-local-variable 'auto-save-interval)\n (setq auto-save-interval 20)\n )))\n \n```\n\nemacs 24.5 で確認しました。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T09:48:13.350", "id": "11797", "last_activity_date": "2015-06-27T13:07:57.967", "last_edit_date": "2015-06-27T13:07:57.967", "last_editor_user_id": "5288", "owner_user_id": "5288", "parent_id": "11795", "post_type": "answer", "score": 1 }, { "body": "使ったことはないですが、るびきちさんのブログで幾つか紹介されています。\n\n * [emacs scratch-log.el : *scratch*バッファのログを取り、削除不能にし、再起動時に復元する | MELPA Emacs Lisp Elisp パッケージ インストール 設定 使い方 | るびきち「日刊Emacs」](http://rubikitch.com/2015/01/05/scratch-log/)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T12:08:48.733", "id": "11801", "last_activity_date": "2015-06-27T12:08:48.733", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7291", "parent_id": "11795", "post_type": "answer", "score": 2 }, { "body": "masm さんの回答ですが、`with-current-buffer` を使うと以下の様に書く事ができます。\n\n```\n\n (add-hook 'emacs-startup-hook\n '(lambda ()\n (with-current-buffer \"*scratch*\"\n ;;(setq default-directory user-emacs-directory)\n ;; or\n ;;(setq buffer-file-name (concat user-emacs-directory \".scratch\"))\n (auto-save-mode)\n (set (make-local-variable 'auto-save-timeout) 10)\n (set (make-local-variable 'auto-save-interval) 20))))\n \n```\n\nただ、この方法ですと、自動保存されるファイルが `default-directory`(`*scratch*`\nバッファでの初期値はホームディレクトリ)に作成される事になります。\n\n```\n\n $ ls -l ~/\n -rw-r--r-- 1 nemo nemo 12 Jun 28 00:55 #%2Ascratch%2A#27799ads#\n \n```\n\n`~/.emacs.d/` ディレクトリに作成したい場合は、`default-directory` か `buffer-file-name`(どちらも\nbuffer local 変数)を設定すると良いかもしれません。 \n`buffer-file-name` を設定する場合、`*scratch*` バッファがファイルに関連付けられますので、Emacs\nを終了する際にセーブしていない場合には「`Save file\n~/.emacs.d/.scratch?`」などと尋ねられる事になります(ファイルと同じ扱い)。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T16:22:21.703", "id": "11807", "last_activity_date": "2015-06-27T16:22:21.703", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "11795", "post_type": "answer", "score": 0 } ]
11795
11801
11801
{ "accepted_answer_id": "11931", "answer_count": 2, "body": "お世話になります。 \njavascriptからphpへのデータ渡しについて質問です。 \n下記のように記述したのですが引数がうまく渡っていません。 \nどこがおかしいのでしょうか? \nphpは正常に起動できているようです。 \najaxは経験がほとんどないのでアドバイスいただければ幸いです. \nソースコードは下記です。\n\nhtml\n\n```\n\n $.ajax({\n type: 'POST',\n url: 'sample.php',\n data: {\n 'test': 'こんにちは'\n },\n success: function(data){\n alert(data);\n }\n });\n \n```\n\nphp\n\n```\n\n echo $_POST[\"test\"];\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T09:58:55.583", "favorite_count": 0, "id": "11798", "last_activity_date": "2015-07-01T11:38:12.510", "last_edit_date": "2015-06-27T10:28:56.850", "last_editor_user_id": "3639", "owner_user_id": "8168", "post_type": "question", "score": 1, "tags": [ "javascript", "php", "ajax" ], "title": "javascriptからphpへの引数について", "view_count": 1576 }
[ { "body": "phpファイルに間違いましたね。\n\nサーバに送信する値(data)はオブジェクトだから、phpファイルにechoを使わずに、print_rを使うとうまくいけると思います。つまり、下記の通り\n\nprint_r($_POST);", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T21:01:46.373", "id": "11809", "last_activity_date": "2015-06-27T21:09:07.467", "last_edit_date": "2015-06-27T21:09:07.467", "last_editor_user_id": "10317", "owner_user_id": "10317", "parent_id": "11798", "post_type": "answer", "score": 0 }, { "body": "皆様 \n色々回答ありがとうございました。 \nソースがまとまっていなくて全ソース出せなかったのですが、 \najaxの記述がheadの外にあり、位置を変えたところ無事に動きました。 \nphpが動いていたと判断したのはphpでログを出していたので為です。\n\nお騒がせして申し訳ございません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-01T11:38:12.510", "id": "11931", "last_activity_date": "2015-07-01T11:38:12.510", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8168", "parent_id": "11798", "post_type": "answer", "score": 1 } ]
11798
11931
11931
{ "accepted_answer_id": null, "answer_count": 1, "body": "サーバーとJSONを用いて通信するWebアプリケーションをTypescriptで書いています.JSONにシリアライズ/デシリアライズするとき,JSONにメソッドが含まれないので,デシリアライズしたデータを使ってオブジェクトを作ろうと考えたのですが,いい方法が分かりません.\n\n今は次のようなコードを書いています.\n\n```\n\n class Pen{\n constructor(public color: String,public size:number) { }\n draw(): void {\n //do something\n }\n }\n var json = JSON.stringify(new Pen(\"rgb(0,0,0)\",10));\n var pen_data = <Pen> JSON.parse(json);\n //pen_data.draw(); //TypeError: pen_data.draw is not a function\n \n //pen_dataからPenのオブジェクトを作りたい\n var new_pen = new Pen(pen_data.color, pen_data.size);\n \n```\n\nですが,このコードはPenのプロパティが増えたときに一々書き直す必要がありますし,他のクラスでも同じことがしたくなったら同じようなコードを書かなければいけません.\n\nこのコードをジェネリックに書くにはどうすればよいでしょうか.", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T10:54:26.793", "favorite_count": 0, "id": "11799", "last_activity_date": "2015-06-28T17:36:06.653", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8573", "post_type": "question", "score": 5, "tags": [ "javascript", "json", "typescript" ], "title": "デシリアライズしたプロパティからオブジェクトをつくりたい", "view_count": 3358 }
[ { "body": "直接的な方法はないと思います。オブジェクト指向の「オブジェクト」はデータと操作をひとまとめにして扱うものであるのに対して、シリアライズはオブジェクトの「データ」の部分のみを保存したり復元するものであり、原理的にオブジェクト指向の「オブジェクト」はデータの永続化と相性の悪いものだからです。\n\n幾つか解決策は考えられます。\n\n# 1. 我慢してそれぞれのオブジェクトの内容にあわせていちいちプロパティを復元する方法\n\n質問者さんが提示したサンプルコードの方法です。Penオブジェクトと対応するJSON形式のデータをまったく別々に扱います。デシリアライズの時にいちいちコンストラクタを呼ばなければなりませんし、プロパティが増減したらその都度デシリアライズの部分も修正します。とにかく手間がかかり面倒ですし、Penオブジェクトとそれに対応するJSONデータが存在することでデータ構造としても重複しているなどあまりに冗長ですが、オブジェクト指向プログラミングではある意味「真っ当」な方法ではあります。\n\n# 2. データと操作を分離する方法\n\nクラスを使うのを諦め、`draw`はPenクラスのメソッドではなく、独立した関数として定義します。`Pen`はクラスではなくインターフェイスになり、penの実体はメソッドを持たない単なるオブジェクトになります。\n\n```\n\n function draw(pen: Pen){\n ....\n }\n \n interface Pen { \n color: String; \n size: Number; \n }\n \n var blackPen: Pen = { color: \"rgb(0,0,0)\", size: 10 };\n \n draw(blackPen);\n \n var json = JSON.stringify(blackPen);\n var pen = <Pen> JSON.parse(json);\n \n draw(pen);\n \n```\n\n単純でわかりやすい方法だと思いますし、データ構造がもっと複雑になっても、`stringify/parse`一発でシリアライズ/デシリアライズできるという利点もあります。たとえば、\n\n```\n\n interface PaintTool {\n penList: [Pen];\n canvasWidth: Number;\n canvasHeight: Number;\n filePath: String;\n }\n \n```\n\nのような、内部に`Pen`を持つような更に大きなデータ構造でも、内部にメソッドを持たないオブジェクトであればデータ構造全体を一発でシリアライズ/デシリアライズできます。ただし、クラスやプロトタイプのようなオブジェクト指向プログラミングらしい機能をほとんど使えないという欠点があります。`Pen`がサブクラスを持っていて`draw`がオーバーライドされるようなときには使えません。\n\n# 3. シリアライズ用のライブラリを使う方法\n\n[resurrect-js](https://github.com/skeeto/resurrect-\njs)のようなライブラリを使う方法があります。幾らか制限があって、どんなオブジェクトでもシリアライズできるというわけではありませんし、TypeScriptの「クラス」に対して使用可能なのかどうか確認していませんが、おそらく質問者さんがイメージしている方法に近い方法だと思います。\n\nReadmeによれば、resurrect-jsでは次のように書けるようです。\n\n```\n\n function Foo() {}\n Foo.prototype.greet = function() { return \"hello\"; };\n \n // Behavior is preserved:\n var necromancer = new Resurrect();\n var json = necromancer.stringify(new Foo());\n var foo = necromancer.resurrect(json);\n foo.greet(); // => \"hello\"\n \n```\n\n`JSON.strongify`の代わりに`Resurrect#stringify`メソッドを、`JSON.parse`の代わりに`Resurrect#resurrect`を呼ぶなど、使いかたとしても直感的だと思います。メソッドも条件付きでシリアライズ可能なようです。用途によりますが、検討する価値はありそうです。\n\n# 4. メタプログラミングで無理やり復元する方法\n\nJavaScriptには極めて柔軟なメタプログラミングの方法が提供されており、`__proto__`を直接いじることができますし、`Object.keys`でオブジェクトが保持しているプロパティの名前を動的に調べることもできます。`constructor`プロパティでコンストラクタを調べることもできますし、何らかの規約を定めてオブジェクトのプロトタイプを文字列の形でJSONデータに格納しておき、デシリアライズ時には動的にそのコンストラクタを探してきて呼び出し、プロトタイプオブジェクトを設定し、プロパティを設定して復元するような方法は不可能ではないと思います(\n参考: [dynamic object construction in\njavascript?](https://stackoverflow.com/questions/3871731/dynamic-object-\nconstruction-in-javascript) )。\n\nJavaなどではリフレクションを駆使してそのようなシリアライゼーションを行う機能があります。Javaでオブジェクトをシリアライズ可能にするには引数のないコンストラクタの定義が必要なのは、そのような方法で動的にデシリアライズするためです。3で挙げたresurrect-\njsでやっているのもそういった方法です。ただし、そのような方法が自分の用途で使えるとは限らず、例えば質問者さんはTypeScriptを使っているので、JavaScript向けに作られているresurrect-\njsが流用できるとは限りません。resurrect-jsのようなライブラリが使えないなら、同様の機構を自分の用途に合わせて独自に実装する方法もあります。\n\nメタプログラミングを駆使してそのような機構を独自に実装すれば、プロパティが増減してもそれに合わせて自動でシリアライズ/デシリアライズするようなことを実現するのも不可能ではないでしょうが、そのようなメタプログラミングは複雑でバグが紛れ込みやすく、決して扱いやすい方法とは言えないでしょう。TypeScriptの静的型付けも役に立ちません。決して簡単ではないので、メタプログラミングは最終手段だと思ったほうがいいと思います。\n\n* * *\n\n私なら2を選びます。オブジェクト指向プログラミングに拘泥しないのであれば、もっとも単純でわかりやすい方法だと思うからです。この場面では、オブジェクト指向のクラスやプロトタイプが使えなくて不便だとも思いません。このシリアライズの問題は、データと操作をひとまとめにしてしまうオブジェクト指向プログラミングの欠点を示すわかりやすい例だと思います。`color`や`size`のような永続化可能なデータと、`draw`メソッドという永続化不可能な操作を、分離せずに`Pen`というオブジェクトしてまとめて永続化や復元しようとしているのが問題を引き起こした原因であり、データと操作を分離してしまえば問題は自然に解決します。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T15:57:52.877", "id": "11832", "last_activity_date": "2015-06-28T17:36:06.653", "last_edit_date": "2017-05-23T12:38:56.083", "last_editor_user_id": "-1", "owner_user_id": "10330", "parent_id": "11799", "post_type": "answer", "score": 7 } ]
11799
null
11832
{ "accepted_answer_id": null, "answer_count": 1, "body": "`Windows PowerShell`を使って`python`の`Setuptools`をインストールしようとしているものです。\n\n<https://www.youtube.com/watch?v=Es_kdnPUgDg>\n\n上記、youtubeを参考に、動画の手順道理に進めているのですが、なかなか上手く行かず、\n\n```\n\n PS C:\\> python ez_setup.py\n Extracting in c:\\users\\somasoma\\appdata\\local\\temp\\tmpqfz8v7\n Now working in c:\\users\\somasoma\\appdata\\local\\temp\\tmpqfz8v7\\setuptools-18.0.1\n Installing Setuptools\n Traceback (most recent call last):\n File \"ez_setup.py\", line 391, in <module>\n sys.exit(main())\n File \"ez_setup.py\", line 388, in main\n return _install(archive, _build_install_args(options))\n File \"ez_setup.py\", line 53, in _install\n if not _python_cmd('setup.py', 'install', *install_args):\n File \"ez_setup.py\", line 45, in _python_cmd\n return subprocess.call(args) == 0\n File \"C:\\Python27\\Lib\\subprocess.py\", line 524, in call\n return Popen(*popenargs, **kwargs).wait()\n File \"C:\\Python27\\Lib\\subprocess.py\", line 711, in __init__\n errread, errwrite)\n File \"C:\\Python27\\Lib\\subprocess.py\", line 948, in _execute_child\n startupinfo)\n WindowsError: [Error 2] The system cannot find the file specified\n PS C:\\>\n \n```\n\nとなってしまい。システムがファイルを見つけ出せない状態です。解決方法の分かる方、いらしましたらよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T12:15:30.497", "favorite_count": 0, "id": "11802", "last_activity_date": "2016-01-23T18:28:35.707", "last_edit_date": "2015-08-26T15:18:03.470", "last_editor_user_id": "2238", "owner_user_id": "10314", "post_type": "question", "score": 3, "tags": [ "python", "powershell", "setuptools" ], "title": "python のSetuptoolsがインストールできません。", "view_count": 344 }
[ { "body": "見たところ、 ez_setup.py 44行目で指定している `sys.executable`\n変数に格納されているPythonの実行ファイルを見つけられずエラーになっているようです。\n\n以下を実行するとどのような値が表示されますか?\n\n```\n\n python -c \"import sys; print sys.executable\"\n \n```\n\n期待する値は `'C:\\Python27\\python.exe'`\nですが、そうでない場合それが原因でしょう。Pythonのインストール自体がよくない手順だったのか等、その原因を調べる必要があります。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T14:11:11.127", "id": "11806", "last_activity_date": "2015-06-27T14:11:11.127", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "11802", "post_type": "answer", "score": 1 } ]
11802
null
11806
{ "accepted_answer_id": null, "answer_count": 2, "body": "<http://pastebin.com/KTCkMu1p> \n1枚を裏返ったトランプ[img_0]、3枚の異なる絵柄の画像[img_s1~s3]を計4枚のカードとして、 \n画面に6枚裏返ったトランプの画像を表示し、三回連続して異なる絵柄を出したらクリア \n三回目までに同じ絵柄を出してしまったらゲームオーバー \nという内容のアプリを作りたいと考えています。現在詰まっている事t\n\n * タップしたカードをどうやって1枚目にタップしたカード変数として処理 \ncard1 = 一枚目に出てきたカード; のように宣言し、\n\n * if(二枚目にタップしたカード!=一枚目にタップしたカード)\n * if(三枚目!=二枚目 || 一枚目)\n\nというifのネストで処理するのはどういったように書けばいいでしょうか。 \nご教授お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T12:18:49.557", "favorite_count": 0, "id": "11803", "last_activity_date": "2015-07-08T00:31:39.207", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10313", "post_type": "question", "score": 1, "tags": [ "android" ], "title": "神経衰弱の逆を目的にカードをめくるアプリ", "view_count": 719 }
[ { "body": "Javaは分からないので、一般的なコーディングの仕方での回答となります。\n\nif文をたくさん組み合わせて判定することもできますが、それよりも判定ロジックを抽象化した、こんな感じの関数を用意するほうがよいと思います。\n\n```\n\n boolean めくったカードが重複しているか(今までにめくったカードのリスト, 新しくめくったカード) {\n for (カード : 今までにめくったカードのリスト) {\n if (カード == 新しくめくったカード) return true;\n }\n return false;\n }\n \n```\n\nあとは、新しくカードをめくるたびに \n1. 「めくったカードが重複しているか」関数を呼ぶ \n2. 「今までにめくったカードのリスト」に、めくったカードを追加する \nという処理を繰り返せば良いはずです。 \n何枚めくっても、この関数を呼ぶだけで判定できます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-04T05:47:22.520", "id": "12016", "last_activity_date": "2015-07-04T05:47:22.520", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8078", "parent_id": "11803", "post_type": "answer", "score": 2 }, { "body": "contains()が使えるかもしれません。 \nカードが何種類あっても、めくる回数が増えても対応できます。\n\n```\n\n ArrayList<カード> cards = new ArrayList<>();\n \n // カードがめくられた\n if (cards.contains(めくったカード)) {\n // 同じ絵柄(過去にめくった事がある)\n } else {\n // 異なる絵柄(はじめて)\n cards.add(めくったカード); // 追加しておく\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-08T00:31:39.207", "id": "12132", "last_activity_date": "2015-07-08T00:31:39.207", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7241", "parent_id": "11803", "post_type": "answer", "score": 1 } ]
11803
null
12016
{ "accepted_answer_id": null, "answer_count": 1, "body": "InterfaceBuilderを使用しないでカスタムCellを使用したTableViewを作成しています。\n\n`ViewController`で`UITableView`を追加して \n`CustomCell`クラスを作成し、その`ContentView`に`CustomView`クラスを追加しています。\n\n`ViewController`で\n\n```\n\n [_tableView registerClass:[CustomCell class] forCellReuseIdentifier:@\"Cell\"];\n \n```\n\nを使用して起動すると \n1つのセルに複数のセルがかぶって表示されます\n\n`ViewController.m`\n\n```\n\n - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {\n CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@\"Cell\"];\n return cell;\n }\n \n```\n\n`CustomCell.m`\n\n```\n\n - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier\n {\n self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];\n \n if (self) {\n for (UIView *subview in [self.contentView subviews]) {\n [subview removeFromSuperview];\n }\n \n _dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, 320 - (16 * 2), 20)];\n _dateLabel.font = [UIFont systemFontOfSize:15];\n _dateLabel.text = [[NSDate date] description];\n [self.contentView addSubview:self.dateLabel];\n \n // ここのビューがスクロール時に2重に表示されることがある\n CGRect rect1 = CGRectMake(0, 20, 160, 20);\n _view1 = [[CustomView alloc] initWithFrame:rect1];\n [self.contentView addSubview:_view1];\n \n CGRect rect2 = CGRectMake(160, 20, 160, 20);\n // その他ViewをaddSubView\n }\n return self;\n }\n \n```\n\n`CustomView.m`\n\n```\n\n - (id)initWithFrame:(CGRect)frame\n {\n self = [super initWithFrame:frame];\n if (self) {\n // Initialization code\n [self initializeView:frame];\n }\n return self;\n }\n -(void)initializeView:(CGRect)frame\n {\n for (UIView *subview in [self subviews]) {\n [subview removeFromSuperview];\n }\n \n _titleLabel = [[UILabel alloc] init];\n _titleLabel.frame = CGRectMake(44 + 16, 0, 160 - 44, 22);\n _titleLabel.text = @\"text\";\n [self addSubview:_titleLabel];\n \n _conditionLabel = [[UILabel alloc] init];\n _conditionLabel.frame = CGRectMake(44 + 16, 22 + 4, 160 - 44, 22);\n _conditionLabel.text = @\"text2\";\n [self addSubview:_conditionLabel];\n }\n \n```\n\n原因は`cellForRowAtIndexPath`で@\"Cell\"のIDでセルを再使用しているため起こる原因と思いますが、 \n`registerClass`でIDを固定しているため、複数のIDで再使用をしないということができません。 \nカスタムCellを使用して、そのCellに`addView`した状態で表示が重ならない方法はありますか?\n\n![こんな状態で表示されます](https://i.stack.imgur.com/1fjvX.png)", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T12:32:42.400", "favorite_count": 0, "id": "11804", "last_activity_date": "2015-06-28T09:57:07.650", "last_edit_date": "2015-06-28T09:57:07.650", "last_editor_user_id": "356", "owner_user_id": "356", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c", "uitableview" ], "title": "UITableViewでカスタムCellを使用した時に表示が重なる", "view_count": 2641 }
[ { "body": "スクリーンショットを拝見させていただいた範囲で判断できるのは、テーブルの行の高さと、ひとつひとつのセルの高さが一致していないという点です。テーブルの行の高さは、セルのサイズにあわせて、自動で調節されるわけではないという点を、ご留意ください(※)。 \nテーブルの行の高さは、`UITableView`のプロパティ`rowHeight`で調節します。セルが重ならないようにするには、すくなくとも現状の2.7倍にはしないといけなさそうです。 \nなお、行間をひとつずつ異なる値にするには、`UITableViewDataSource`プロトコルの、`\\-\n(CGFloat)tableView:(UITableView *)tableView\nheightForRowAtIndexPath:(NSIndexPath *)indexPath`メソッドを使います。\n\n※Auto Layoutを利用して、セルのサイズに合わせて、行間を自動調節する手法は、あるらしい。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T03:17:16.393", "id": "11814", "last_activity_date": "2015-06-28T05:53:40.433", "last_edit_date": "2015-06-28T05:53:40.433", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "11804", "post_type": "answer", "score": 1 } ]
11804
null
11814
{ "accepted_answer_id": null, "answer_count": 1, "body": "下記のサイトの様にFacebookのURLをUserIdやGroupIdに変換したいのですが\n\n<http://lookup-id.com/>\n\nFacebook Graph APIには相当する物が見当たりません。 \nどうやって変換しているかお分かりになられる方はいませんでしょうか?\n\n以前はこの方法で動作していたのですが\n\n<https://stackoverflow.com/questions/19030282/get-facebook-group-id-using-\nidentifier-or-url>\n\n何故か、戻り値のJSONがブランクデーターになってしまって使えなくなりました。\n\nex. \n{ \"data\": [ ] }", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T12:44:08.580", "favorite_count": 0, "id": "11805", "last_activity_date": "2016-04-29T00:40:47.193", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "10315", "post_type": "question", "score": 2, "tags": [ "facebook", "ajax", "facebook-graph-api", "facebook-api", "facebook-php-sdk" ], "title": "Facebook Graph APIでWEBページのURLをUserIdやGroupIdに変換したい。", "view_count": 138 }
[ { "body": "自己レスです。\n\nFacebook Graph APIの search で jsonデータが取得出来るようになっているようです。 \nfacebook側の不具合だったのかもしれません。\n\nですが search での変換はスマートでないような気もします。\n\nURLを変換できればいいのですが。私が知る限り、良い方法は無いようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-03T18:26:17.477", "id": "12002", "last_activity_date": "2015-07-03T18:26:17.477", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10315", "parent_id": "11805", "post_type": "answer", "score": 1 } ]
11805
null
12002
{ "accepted_answer_id": null, "answer_count": 1, "body": "windows powershellにおいて、pipを使用して`virtualenvwrapper-\npowershell`をダウンロードしようとしているのですが、うまくいきません。 \npipのダウンロード自体は上手くいき、\n\n```\n\n python -m pip install virtualenv\n \n```\n\nと入力し、virtualenvはインストールすることができたのですが、\n\n```\n\n python -m pip install virtualenvwrapper-powershell\n \n```\n\nと入力しても`virtualenvwrapper-powershell`をインストールすることができません。 \n以下、エラーメッセージとなります。\n\n```\n\n PS C:\\windows\\system32> python -m pip install virtualenvwrapper-powershell\n Collecting virtualenvwrapper-powershell\n C:\\Python27\\lib\\site-packages\\pip\\_vendor\\requests\\packages\\urllib3\\util\\ssl_.py:90: InsecurePlatformWarning: A true\n Context object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL c\n ections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwa\n ng.\n InsecurePlatformWarning\n Using cached virtualenvwrapper-powershell-12.7.8.zip\n Error [Error 2] The system cannot find the file specified while executing command python setup.py egg_info\n Exception:\n Traceback (most recent call last):\n File \"C:\\Python27\\lib\\site-packages\\pip\\basecommand.py\", line 223, in main\n status = self.run(options, args)\n File \"C:\\Python27\\lib\\site-packages\\pip\\commands\\install.py\", line 291, in run\n wb.build(autobuilding=True)\n File \"C:\\Python27\\lib\\site-packages\\pip\\wheel.py\", line 705, in build\n self.requirement_set.prepare_files(self.finder)\n File \"C:\\Python27\\lib\\site-packages\\pip\\req\\req_set.py\", line 317, in prepare_files\n functools.partial(self._prepare_file, finder))\n File \"C:\\Python27\\lib\\site-packages\\pip\\req\\req_set.py\", line 304, in _walk_req_to_install\n more_reqs = handler(req_to_install)\n File \"C:\\Python27\\lib\\site-packages\\pip\\req\\req_set.py\", line 483, in _prepare_file\n abstract_dist.prep_for_dist()\n File \"C:\\Python27\\lib\\site-packages\\pip\\req\\req_set.py\", line 123, in prep_for_dist\n self.req_to_install.run_egg_info()\n File \"C:\\Python27\\lib\\site-packages\\pip\\req\\req_install.py\", line 402, in run_egg_info\n command_desc='python setup.py egg_info')\n File \"C:\\Python27\\lib\\site-packages\\pip\\utils\\__init__.py\", line 701, in call_subprocess\n cwd=cwd, env=env)\n File \"C:\\Python27\\Lib\\subprocess.py\", line 711, in __init__\n errread, errwrite)\n File \"C:\\Python27\\Lib\\subprocess.py\", line 948, in _execute_child\n startupinfo)\n WindowsError: [Error 2] The system cannot find the file specified\n \n PS C:\\windows\\system32>\n \n```\n\nお力添えいただけますと幸いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T16:26:13.150", "favorite_count": 0, "id": "11808", "last_activity_date": "2021-05-21T04:55:25.603", "last_edit_date": "2017-07-07T04:50:53.817", "last_editor_user_id": "19110", "owner_user_id": "10314", "post_type": "question", "score": 5, "tags": [ "python", "windows", "powershell" ], "title": "pipを使用して、virtualenvwrapper-powershellをダウンロード", "view_count": 248 }
[ { "body": "web上からパッケージをダウンロードして、直接setup.pyを起動させる形ではどうでしょか。\n\nダウンロードurl(21年5月段階の最新版)\n\n> <https://pypi.python.org/pypi/virtualenvwrapper-powershell/12.7.8>\n\nダウンロードしたファイルを解凍し、ディレクトリ内のsetup.pyをpowershall内で \n`python setup.py install`\n\nを行えばインストールできると思われます", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2021-05-21T04:55:25.603", "id": "75992", "last_activity_date": "2021-05-21T04:55:25.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "45438", "parent_id": "11808", "post_type": "answer", "score": 1 } ]
11808
null
75992
{ "accepted_answer_id": "11812", "answer_count": 1, "body": "Laravel 5.1でメール本文にURLを記載して送信しています。 \nメールをキュー使わずに送信した時と、キューを使って送信した時で、メール本文のURLが変わってしまいます。どの様にしたら修正できるでしょうか?\n\nテストは`php artisan serve`で実行しているので、URLは`http://localhost:8000`です。\n\n### メール送信\n\n```\n\n private function sendConfirmMail(Mailer $mailer, User $user)\n {\n // $mailer->send(\n $mailer->queue( // <--ここをキューに変更した\n 'emails.confirm',\n ['user' => $user, 'token' => $user->confirmation_token],\n function($message) use ($user) {\n $message->to($user->email, $user->name)->subject('ユーザー登録確認');\n }\n );\n }\n \n```\n\n### メールビュー: emails.confirm\n\n```\n\n <p>\n ようこそ、{{ $user['name'] }} さん\n </p>\n \n <p>\n 以下のリンクをクリックしてユーザーを有効化してください。\n </p>\n \n <p>\n <a href=\"{{ url('auth/confirm', [$token]) }}\">ユーザーを有効化する</a>\n </p>\n \n <p>\n {{ url('auth/confirm', [$token]) }}\n </p>\n \n```\n\n### 届いたメール:$mail->send()の時\n\n```\n\n ようこそ、Hoge さん\n \n 以下のリンクをクリックしてユーザーを有効化してください。\n \n ユーザーを有効化する\n \n http://localhost:8000/auth/confirm/d1533d919888227a3b2a48a4ed483686bcb19a45ad3b9c46e4c1f0c144dde269\n \n```\n\nURLは正しく`http://localhost:8000`と表示されている\n\n### 届いたメール:$mail->queue()の時\n\n```\n\n ようこそ、Hoge さん\n \n 以下のリンクをクリックしてユーザーを有効化してください。\n \n ユーザーを有効化する\n \n http://localhost/auth/confirm/d1533d919888227a3b2a48a4ed483686bcb19a45ad3b9c46e4c1f0c144dde269\n \n```\n\nURLが何故か`http://localhost`と表示される", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T23:44:51.700", "favorite_count": 0, "id": "11810", "last_activity_date": "2015-06-28T00:00:44.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10150", "post_type": "question", "score": 4, "tags": [ "php", "laravel" ], "title": "Laravelでキューでメール送信するとURLが変わってしまう", "view_count": 920 }
[ { "body": "config/app.phpのurlを変更すれば直ります。 \nこのurlはartisanコマンドラインアプリ内でurlを生成する時に使用されます。\n\nキューは`artisan queue:listen`もしくは`artisan\nqueue:work`で処理されるので、urlを生成するurl()を使った時に、ここで設定したurlを使用します。\n\nキューで無い時は、実際にリクエストを受けたサーバのurlが使用されます。\n\n```\n\n // config/app.php\n \n /*\n |--------------------------------------------------------------------------\n | Application URL\n |--------------------------------------------------------------------------\n |\n | This URL is used by the console to properly generate URLs when using\n | the Artisan command line tool. You should set this to the root of\n | your application so that it is used when running Artisan tasks.\n |\n */\n \n 'url' => 'http://localhost:8000',\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T00:00:44.527", "id": "11812", "last_activity_date": "2015-06-28T00:00:44.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9529", "parent_id": "11810", "post_type": "answer", "score": 3 } ]
11810
11812
11812
{ "accepted_answer_id": null, "answer_count": 1, "body": "Red Hat Enterprise Linux Server 5.3で、sysstat 7.0.2-11.el5を使用しています。\n\nsarコマンドで前日の稼働状況を集計するスクリプトを動かしているのですが、マルチコア環境でCPU利用率が100%を超えることがあり、スクリプトで\n”Please give a smaller interval value” というエラーが出てしまうことがあります。\n\n何とかしてこのエラーを回避することは出来ませんでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-27T23:48:40.473", "favorite_count": 0, "id": "11811", "last_activity_date": "2015-06-28T03:40:03.070", "last_edit_date": "2015-06-28T03:03:47.630", "last_editor_user_id": "76", "owner_user_id": "10318", "post_type": "question", "score": 1, "tags": [ "linux" ], "title": "マルチコア環境でsarを使うとCPU利用率が100%を超える", "view_count": 664 }
[ { "body": "とりあえずバージョンをあげてみたらいかがでしょう。バージョン10.2.0では明らかにマルチCPUの計算が修正されています。どのバージョンから修正が入ったのかまでは見ていませんが。\n\n```\n\n 350 /* Reduce interval value to one processor */\n 351 if (cpu_nr > 1) {\n 352 itv = get_interval(uptime0[prev], uptime0[curr]);\n 353 }\n 354 else {\n 355 itv = g_itv;\n 356 }\n \n```\n\nmpstat.c", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T03:40:03.070", "id": "11815", "last_activity_date": "2015-06-28T03:40:03.070", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7837", "parent_id": "11811", "post_type": "answer", "score": 1 } ]
11811
null
11815
{ "accepted_answer_id": "11817", "answer_count": 2, "body": "お世話になります \nこれはもしかしたら解決策はないのかもしれないのですが、 \n一応聞いてみました\n\nベースにあるviewをalpha0.7で設定してるのですが、そうすると一緒に上のボタンもalpha値が0.7になってしまいます。 \nこれって回避手段はないのでしょうか\n\nこんなかんじです \n![画像の説明をここに入力](https://i.stack.imgur.com/lqonz.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T02:29:02.153", "favorite_count": 0, "id": "11813", "last_activity_date": "2015-06-28T07:21:51.553", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "403", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c", "swift" ], "title": "Baseにあるviewのalphaを下げると、上にあるviewも一緒に透過してしまう", "view_count": 295 }
[ { "body": "デザイン上の制約が出るかもしれませんが、ベースにあるviewのalphaは1.0のままにしてviewの背景色のalphaを0.7に設定すると乗っているボタンに影響しないと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T05:08:46.430", "id": "11817", "last_activity_date": "2015-06-28T05:08:46.430", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7283", "parent_id": "11813", "post_type": "answer", "score": 1 }, { "body": "こんな感じになりました。 \n0.7でほぼ、透過している色が白かどうかすらわからないほど、透過しますが、こんなもんなのでしょうか\n\nコードは以下になってます\n\n```\n\n //背景色のアルファを透過させる\n self.toolbar.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.70)\n \n```\n\n![画像の説明をここに入力](https://i.stack.imgur.com/ZcCaX.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T07:21:51.553", "id": "11819", "last_activity_date": "2015-06-28T07:21:51.553", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "403", "parent_id": "11813", "post_type": "answer", "score": 0 } ]
11813
11817
11817
{ "accepted_answer_id": "12199", "answer_count": 1, "body": "![画像の説明をここに入力](https://i.stack.imgur.com/cVDwJ.jpg)\n\nfirefoxのスタートページに表示されるスクリーンショットをサーバー側から指定することはできますか? \n適当なスクロール状態でキャプチャされた画像が表示されるのカッコ悪いので、いっその事こっち側(サイトを作ってる側)で画像を指定したいのですが、そんなこと可能でしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T05:06:06.353", "favorite_count": 0, "id": "11816", "last_activity_date": "2015-07-09T08:29:41.440", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "705", "post_type": "question", "score": 6, "tags": [ "html", "firefox" ], "title": "firefoxのスタートページに表示されるスクリーンショットを指定できるか?", "view_count": 113 }
[ { "body": "サムネイルに関してはFirefox側の処理で取得していると思いますので \nサーバー側からは明示的に指定することは出来ないと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-07-09T08:29:41.440", "id": "12199", "last_activity_date": "2015-07-09T08:29:41.440", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6040", "parent_id": "11816", "post_type": "answer", "score": 1 } ]
11816
12199
12199
{ "accepted_answer_id": "20522", "answer_count": 2, "body": "DartでWebページを作成しており、Webページ上の作業データをテキスト形式でダウンロードさせているのですが、 \nデータの容量が数メガバイトととても大きくなってしまい困っております。 \nダウンロードファイルをZIPで圧縮すると数十キロバイトまで下がるので圧縮したいです。 \nJavascritp のライブラリを使う方法は見つかりましたが、 \nDart の機能で文字列を圧縮した文字列に変換する方法はないでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T06:49:45.970", "favorite_count": 0, "id": "11818", "last_activity_date": "2016-01-01T11:16:43.770", "last_edit_date": "2016-01-01T11:16:43.770", "last_editor_user_id": "10074", "owner_user_id": "10074", "post_type": "question", "score": 1, "tags": [ "javascript" ], "title": "Dart で文字列を圧縮した文字列に変換する方法はないですか?", "view_count": 1216 }
[ { "body": "[How to serve gzip-encoded html page - Stack\nOverflow](https://stackoverflow.com/questions/18672578/dart-how-to-serve-gzip-\nencoded-html-page) が参考になります。 \nHTTP/1.1の応答としてその文字列をクライアントに渡す場合は、`HttpServer.autoCompress`を`true`にしておけば相手がGZIP対応であれば自動的にGZIP圧縮されます。 \n単にある文字列をGZIP圧縮したバイト列に変換したいときは次のようになります:\n\n```\n\n List<int> compressed = GZIP.encode(UTF8.encode(yourText));\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-08-11T03:10:35.170", "id": "14257", "last_activity_date": "2015-08-11T03:43:27.703", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "10872", "parent_id": "11818", "post_type": "answer", "score": 0 }, { "body": "2016/01/01 \n回答で書くようにと指摘があったので書き直します。\n\n2015/12/30 \n>Terryさん、holywiseさん \nすみません。今更ですが解決できました。\n\n```\n\n List<int> compressed = GZIP.encode(UTF8.encode(yourText));\n \n```\n\n上記のコードはライブラリが見つからなかったので、そのまま実装はできませんでしたが、 \n参考にして下記のように実装したら希望通りに動きました。\n\n```\n\n GZipEncoder gzip = new GZipEncoder();\n Utf8Encoder utf8 = new Utf8Encoder();\n List<int> compressed = gzip.encode(utf8.convert(json));\n String zipStr = CryptoUtils.bytesToBase64(compressed);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-01T11:16:02.077", "id": "20522", "last_activity_date": "2016-01-01T11:16:02.077", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10074", "parent_id": "11818", "post_type": "answer", "score": 0 } ]
11818
20522
14257
{ "accepted_answer_id": "11825", "answer_count": 1, "body": "swiftDocsのCoreMotionのサンプル( <https://sites.google.com/a/gclue.jp/swift-docs/ni-\nyinki100-ios/5-coremotion/001-jia-su-dusensano-zhiwo-qu-de>\n)をコピペして動かしてみようとしたのですが、importの段階でエラーが出てしまいます。 \nエラーメッセージは\n\n```\n\n Cannot load module 'coremotion' as 'CoreMotion'\n \n```\n\nとなっています。\n\n設定のLinked Frameworks and LibraryでCoreMotion.frameworkはすでに追加済みです。 \nXcodeの再起動等を試しても解決はしませんでした。\n\n環境は \nXcode - version 7.0 beta \niphone - ios version 8.3\n\nとなっています。 \nエラーを取るにはどうしたら良いでしょうか。ご教授下さい。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T08:14:06.253", "favorite_count": 0, "id": "11820", "last_activity_date": "2015-06-29T19:44:55.930", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10321", "post_type": "question", "score": 2, "tags": [ "ios", "swift", "xcode" ], "title": "swiftでCoreMotionフレームワークをimportしたい", "view_count": 618 }
[ { "body": "私もご紹介のリンク先のコードを、Xcode\n7betaのプロジェクトにコピー&ペーストしてみましたが、おっしゃるようなエラーメッセージは出ませんでした。なお、Xcode\n7betaは先週beta2がリリースされており、私はそれをインストールしてあります。beta2のリビジョンは「7A1211」です。\n\nコードについては、下記の箇所にエラーが出ただけで、書きかえたあと、iPhone 5sにてビルドしたら、問題なく動作しました。\n\n```\n\n // 加速度の取得を開始\n myMotionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue(), withHandler: {(accelerometerData:CMAccelerometerData!, error:NSError!) -> Void in\n myXLabel.text = \"x=\\(accelerometerData.acceleration.x)\"\n myYLabel.text = \"y=\\(accelerometerData.acceleration.y)\"\n myZLabel.text = \"z=\\(accelerometerData.acceleration.z)\"\n })\n \n```\n\n**訂正後:**\n\n```\n\n // 「!」を「?」に変更\n myMotionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue(), withHandler: {(accelerometerData:CMAccelerometerData?, error:NSError?) -> Void in\n // Optional Bindingの書式を使う\n if let theData = accelerometerData {\n myXLabel.text = \"x=\\(theData.acceleration.x)\"\n myYLabel.text = \"y=\\(theData.acceleration.y)\"\n myZLabel.text = \"z=\\(theData.acceleration.z)\"\n }\n })\n \n```\n\nということで、Xcode 7betaのアップデートをしたら、解決するのではないかという見方を、私はしています。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T09:24:57.387", "id": "11825", "last_activity_date": "2015-06-29T19:44:55.930", "last_edit_date": "2015-06-29T19:44:55.930", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "11820", "post_type": "answer", "score": 0 } ]
11820
11825
11825
{ "accepted_answer_id": "11822", "answer_count": 1, "body": "Vim Scriptで画面の書き換えを禁止する方法と解除する方法を教えてください。 \n大量の文字列を入力すると重たいので描画を止めておきたい。\n\n秀丸マクロでいうとdisabledrawとenabledrawに相当することがやりたいです。 \n<http://hidemaruo.mydns.jp:81/helpsite/hidemac/html/110_MacroStatement_disabledraw_enabledraw.html>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T08:40:19.377", "favorite_count": 0, "id": "11821", "last_activity_date": "2015-06-28T15:23:32.323", "last_edit_date": "2015-06-28T15:23:32.323", "last_editor_user_id": "10022", "owner_user_id": "10022", "post_type": "question", "score": 1, "tags": [ "vim" ], "title": "描画を禁止したり解除する方法", "view_count": 261 }
[ { "body": "```\n\n set lazyredraw\n \n```\n\nで、不要な再描画を避けられます。元に戻すには、\n\n```\n\n set nolazyredraw\n \n```\n\nとします。 \n参考リンク: <http://vim-jp.org/vimdoc-ja/options.html#%27lazyredraw%27>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T08:57:53.200", "id": "11822", "last_activity_date": "2015-06-28T08:57:53.200", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2541", "parent_id": "11821", "post_type": "answer", "score": 3 } ]
11821
11822
11822
{ "accepted_answer_id": "11828", "answer_count": 1, "body": "Golangのhtml/templateを使った下記のコードがうまく動きません。 \ntemplate内でrangeを使い、struct a の\nrの要素を$index2で一つずつ展開させたいのですが、展開されず、Stdoutに何も表示されません。どうすれいいのでしょうか?\n\n[このコードのPlayGround](http://play.golang.org/p/gmDFsYtq51)\n\n```\n\n \n package main\n \n import (\n \"html/template\"\n \"os\"\n )\n \n type a struct {\n r []string\n }\n \n func main() {\n my_struct := a{r:[]string{\"A\", \"B\", \"C\"}}\n template_string := \"{{ range $index, $index2 := .r }} {{ $index2 }}{{ end }}\"\n //range\n temp := template.Must(template.New(\"foo\").Parse(template_string))\n temp.Execute(os.Stdout, my_struct)\n \n }\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T11:45:27.847", "favorite_count": 0, "id": "11826", "last_activity_date": "2015-06-28T12:16:22.703", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5246", "post_type": "question", "score": 2, "tags": [ "html", "go" ], "title": "Golangのhtml/templateでrangeの変数展開ができない", "view_count": 723 }
[ { "body": "```\n\n temp.Execute(os.Stdout, my_struct)\n \n```\n\nを、\n\n```\n\n if err := temp.Execute(os.Stdout, my_struct); err != nil {\n fmt.Println(err)\n }\n \n```\n\nとして実行しますと、以下のメッセージが表示されます。\n\n```\n\n template: foo:1:28: executing \"foo\" at <.r>: r is an unexported field of struct type main.a\n \n```\n\nつまり、フィールド `r` を `R` など(大文字で始まる名前)にする必要がありそうです。\n\n実際、`R` に置き換えて実行しますと、\n\n```\n\n $ go run a.go\n A B C\n \n```\n\nとなります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T12:16:22.703", "id": "11828", "last_activity_date": "2015-06-28T12:16:22.703", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "11826", "post_type": "answer", "score": 2 } ]
11826
11828
11828
{ "accepted_answer_id": null, "answer_count": 1, "body": "poewrshellを使って、Data Visualizationを学びはじめた者です。 \nPythonのversionは2.7 \nwindowsは8.1を使用しています。\n\n私の、システム環境変数パスは、下記の通りです。\n\n```\n\n c:\\python27\\;c:\\python27\\scripts;c:\\python27\\tools\\scripts;C:\\Program Files (x86)\\Common Files\\Apple\\Apple Application Support;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Windows Live\\Shared;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Program Files (x86)\\Common Files\\Roxio Shared\\DLLShared\\;C:\\Program Files (x86)\\Common Files\\Roxio Shared\\OEM\\12.0\\DLLShared\\;C:\\Program Files (x86)\\Roxio 2010\\OEM\\AudioCore\\;C:\\Program Files (x86)\\Brackets\\command;C:\\Program Files (x86)\\QuickTime\\QTSystem\\;C:\\Program Files (x86)\\Skype\\Phone\\;C:\\Program Files\\Git\\bin;C:\\Program Files (x86)\\Git\\cmd\n \n```\n\n現在、基本的に(<http://newcoder.io/begin/setup-your-\nmachine/#windows>)のガイダンスに沿って、コンピューター環境を整えている状態です。 \npowershell, python, git, pip, virtualenv, virtualenvwrapper-\npowershellのインストールは(助けてもらいながら)順調に進んだのですが、 \ntype:`Import-Module virtualenvwrapper` という所でスタックしてしまいました。。(virtualenvwrapper-\npowershellのインストールは完了しています。。)\n\n私が、`Import-Module virtualenvwrapper`と入力すると、以下のエラーメッセージが得られます。\n\n```\n\n PS C:\\python27> Import-Module virtualenvwrapper\n Import-Module : The specified module 'virtualenvwrapper' was not loaded because no valid module file was found in any\n module directory.\n At line:1 char:1\n + Import-Module virtualenvwrapper\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ResourceUnavailable: (virtualenvwrapper:String) [Import-Module], FileNotFoundException\n + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand\n \n```\n\nまた、モジュールを、そのモジュールと同じ名前のフォルダに保存するか、.psm1をコマンドに使うと上手くいくかもしれないよ。とのご指摘を頂き、((<https://stackoverflow.com/questions/31096527/import-\nmodule-virtualenvwrapper/31097136#31097136>))\n\n```\n\n C:\\Python27\\virtualenvwrapper\n \n```\n\nに`virtualenvwrapper.psm1`を配置し、 \n`Import-Module virtualenvwrapper`を実行してみましたが、エラーメッセージは上記と同じでした。。\n\n```\n\n Import-Module : The specified module 'virtualenvwrapper' was not loaded because no valid module file was found in any\n module directory.\n At line:1 char:1\n + Import-Module virtualenvwrapper\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ResourceUnavailable: (virtualenvwrapper:String) [Import-Module], FileNotFoundException\n + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand\n \n```\n\nまた、`Import-Module virtualenvwrapper.psm1`も実行してみましたが、以下のエラーメッセージが得られました。。。\n\n```\n\n Import-Module : The specified module 'virtualenvwrapper.psm1' was not loaded because no valid module file was found in\n any module directory.\n At line:1 char:1\n + Import-Module virtualenvwrapper.psm1\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ResourceUnavailable: (virtualenvwrapper.psm1:String) [Import-Module], FileNotFoundExcept\n ion\n + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand\n \n```\n\nまた、 `Import-Module C:\\Python27\\virtualenvwrapper\\virtualenvwrapper.psm1`\nも実行してみましたが、以下のエラーメッセージが得られました。。。\n\n```\n\n PS C:\\python27> Import-Module C:\\Python27\\virtualenvwrapper\\virtualenvwrapper.psm1\n Import-Module : The specified module 'C:\\Python27\\virtualenvwrapper\\virtualenvwrapper.psm1' was not loaded because no\n valid module file was found in any module directory.\n At line:1 char:2\n + Import-Module C:\\Python27\\virtualenvwrapper\\virtualenvwrapper.psm1\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ResourceUnavailable: (C:\\Python27\\vir...envwrapper.psm1:String) [Import-Module], FileNot\n FoundException\n + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand\n \n```\n\nまた、このページを参考に(<https://stackoverflow.com/questions/31035903/installing-\nvirtualenvwrapper-powershell-in-windows-8-1-import-module-failing>)、 \n`WindowsPowerShell\\Modules` というフォルダーをドキュメントに作成し、(the virtualenvwrapper-\npowershell bitbucket )からとってきた、`VirtualEnvWrapper` ディレクトリを \nModulesフォルダに設置し、`Set-ExecutionPolicy Unrestricted` を実行してから`Import-Module\nvirtualenvwrapper`を実行したのですが、やはりエラーとなりました。。\n\nエラーメッセージは以下の通りです。\n\n```\n\n PS C:\\python27> Set-ExecutionPolicy Unrestricted\n \n Execution Policy Change\n The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose\n you to the security risks described in the about_Execution_Policies help topic at\n http://go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?\n [Y] Yes [N] No [S] Suspend [?] Help (default is \"Y\"): y\n PS C:\\python27> Import-Module virtualenvwrapper\n Import-Module : The specified module 'virtualenvwrapper' was not loaded because no valid module file was found in any\n module directory.\n At line:1 char:1\n + Import-Module virtualenvwrapper\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ResourceUnavailable: (virtualenvwrapper:String) [Import-Module], FileNotFoundException\n + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand\n \n```\n\n長々と申し訳ございませんでした。 \nどなたか、何かアイデアのございます方、お力を貸して頂けますと助かります。。\n\n★追記★ \nBLUEPIXY様へ、下記新たなエラーメッセージとなります。。\n\n```\n\n PS C:\\windows\\system32> Import-Module virtualenvwrapper\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run\n C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:48 char:3\n + if [ \"$VIRTUALENVWRAPPER_PYTHON\" = \"\" ]\n + ~\n Missing '(' after 'if' in if statement.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:48 char:5\n + if [ \"$VIRTUALENVWRAPPER_PYTHON\" = \"\" ]\n + ~\n Missing type name after '['.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:54 char:3\n + if [ \"$VIRTUALENVWRAPPER_VIRTUALENV\" = \"\" ]\n + ~\n Missing '(' after 'if' in if statement.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:54 char:5\n + if [ \"$VIRTUALENVWRAPPER_VIRTUALENV\" = \"\" ]\n + ~\n Missing type name after '['.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:59 char:38\n + virtualenvwrapper_derive_workon_home() {\n + ~\n An expression was expected after '('.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:64 char:7\n + if [ \"$workon_home_dir\" = \"\" ]\n + ~\n Missing '(' after 'if' in if statement.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:64 char:9\n + if [ \"$workon_home_dir\" = \"\" ]\n + ~\n Missing type name after '['.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:71 char:7\n + if echo \"$workon_home_dir\" | (unset GREP_OPTIONS; \\grep '^[^/~]' > /dev/null ...\n + ~\n Missing '(' after 'if' in if statement.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:71 char:53\n + if echo \"$workon_home_dir\" | (unset GREP_OPTIONS; \\grep '^[^/~]' > /dev/null ...\n + ~\n Missing closing ')' in expression.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:71 char:34\n + if echo \"$workon_home_dir\" | (unset GREP_OPTIONS; \\grep '^[^/~]' > /dev/null ...\n + ~~~~~~~~~~~~~~~~~~~\n Expressions are only allowed as the first element of a pipeline.\n Not all parse errors were reported. Correct the reported errors and try again.\n + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException\n + FullyQualifiedErrorId : MissingOpenParenthesisInIfStatement\n \n Import-Module : The specified module 'virtualenvwrapper' was not loaded because no valid module file was found in any\n module directory.\n At line:1 char:1\n + Import-Module virtualenvwrapper\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ResourceUnavailable: (virtualenvwrapper:String) [Import-Module], FileNotFoundException\n + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand\n \n```\n\n★追追記★\n\n以下が、新しいエラーメッセージとなります。。 \nだいぶエラーメッセージが、短くなりました!!\n\n```\n\n PS C:\\windows\\system32> Import-Module virtualenvwrapper\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run\n C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n Switch-DefaultPython : The term 'Switch-DefaultPython' is not recognized as the name of a cmdlet, function, script\n file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct\n and try again.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:16 char:1\n + Switch-DefaultPython\n + ~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ObjectNotFound: (Switch-DefaultPython:String) [], CommandNotFoundException\n + FullyQualifiedErrorId : CommandNotFoundException\n \n Initialize : The term 'Initialize' is not recognized as the name of a cmdlet, function, script file, or operable\n program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:334 char:1\n + Initialize\n + ~~~~~~~~~~\n + CategoryInfo : ObjectNotFound: (Initialize:String) [], CommandNotFoundException\n + FullyQualifiedErrorId : CommandNotFoundException\n \n```\n\n★追追追記★\n\n下記、エラーメッセージ \nメッセージがら見るに、いろんなものが自動化されていないようですね。。\n\n```\n\n PS C:\\windows\\system32> Import-Module virtualenvwrapper\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run\n C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\Win\\Win.psm1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n Initialize : The term 'Initialize' is not recognized as the name of a cmdlet, function, script file, or operable\n program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1:334 char:1\n + Initialize\n + ~~~~~~~~~~\n + CategoryInfo : ObjectNotFound: (Initialize:String) [], CommandNotFoundException\n + FullyQualifiedErrorId : CommandNotFoundException\n \n```\n\n★@追記★ \n遂に成功したかのように見えます。以下のメッセージの様に、今回のエラーは、『TabExpansion』によるものだけで、これは無視してよいエラーみたいです! \nということは、今回の”Import-Module virtualenvwrapper”の実行は、成功かと思います。 \nしかし、メッセージ中に、何も『成功』形跡がありません。。 \nこれは本当に成功したのでしょうか。。\n\n```\n\n PS C:\\windows\\system32> Import-Module virtualenvwrapper\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\support.psm1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\win.psm1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run\n C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\VirtualenvWrapperTabExpansion.psm1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n Get-Content : Cannot find path 'Function:\\TabExpansion' because it does not exist.\n At C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\VirtualenvWrapperTabExpansion.psm1:12\n char:21\n + $_oldTabExpansion = Get-Content Function:TabExpansion\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : ObjectNotFound: (Function:\\TabExpansion:String) [Get-Content], ItemNotFoundException\n + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand\n \n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run\n C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\virtualenvwrapper.psm1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run\n C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\Extensions\\Extension.Project.ps1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n \n Security warning\n Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your\n computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning\n message. Do you want to run\n C:\\Users\\SomaSoma\\Documents\\WindowsPowerShell\\Modules\\virtualenvwrapper\\Extensions\\Extension.UserScripts.ps1?\n [D] Do not run [R] Run once [S] Suspend [?] Help (default is \"D\"): r\n PS C:\\windows\\system32>\n \n```\n\nまた、`Get-Command *virtualenv*`\n\nを実行すると、下記の様に表示され、やはり成功したかのように見えます。\n\n```\n\n PS C:\\windows\\system32> Get-Command *virtualenv*\n \n CommandType Name ModuleName\n ----------- ---- ----------\n Alias cdvirtualenv -> VirtualEnvWrapper\n Alias cpvirtualenv -> VirtualEnvWrapper\n Alias lsvirtualenv -> VirtualEnvWrapper\n Alias mkvirtualenv -> VirtualEnvWrapper\n Alias rmvirtualenv -> VirtualEnvWrapper\n Function add_posh_to_virtualenv VirtualEnvWrapper\n Function add2virtualenv VirtualEnvWrapper\n Function CDIntoVirtualEnvironment VirtualEnvWrapper\n Function Copy-VirtualEnvironment VirtualEnvWrapper\n Function GetVirtualEnvCompletions VirtualEnvWrapper\n Function GetVirtualEnvData VirtualEnvWrapper\n Function Get-VirtualEnvironment VirtualEnvWrapper\n Function LetVirtualEnvsThru VirtualEnvWrapper\n Function LooksLikeAVirtualEnv VirtualEnvWrapper\n Function NewVirtualEnvData VirtualEnvWrapper\n Function New-VirtualEnvironment VirtualEnvWrapper\n Function Remove-VirtualEnvironment VirtualEnvWrapper\n Function Set-VirtualEnvironment VirtualEnvWrapper\n Function showvirtualenv VirtualEnvWrapper\n Application add2virtualenv.bat\n Application cdvirtualenv.bat\n Application lsvirtualenv.bat\n Application mkvirtualenv.bat\n Application rmvirtualenv.bat\n Application virtualenv.exe\n Application virtualenv-3.4.exe\n Application virtualenv-clone.exe\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T14:11:38.773", "favorite_count": 0, "id": "11830", "last_activity_date": "2016-10-13T16:01:44.327", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "10314", "post_type": "question", "score": 3, "tags": [ "python", "powershell" ], "title": "powershell を使って Import-Module virtualenvwrapper の実行", "view_count": 1825 }
[ { "body": "モジュールを置く場所はモジュールパスで示される場所になければいけません。 \n標準のスクリプトモジュールのユーザーレベル(ユーザー毎のモジュール)パスは \n`C:\\Users\\UserName\\Documents\\WindowsPowerShell\\Modules` \nです。(UserNameは、それぞれのユーザー名) \nそういう意味で、モジュールを置く正しいディレクトリは最後のやつです。 \nつまりドキュメントフォルダにWindowsPowerShell\\Modulesフォルダを作り \nModulesフォルダにモジュール名のフォルダ`virtualenvwrapper.psm1`の場合は`virtualenvwrapper`フォルダを作りそこに`virtualenvwrapper.psm1`ファイルを置きます。 \nそれで、 \n`Import-Module virtualenvwrapper`を実行すればいいかと思います。 \n(バージョン3以降は起動時に自動読込されるはず)", "comment_count": 25, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-28T15:11:42.747", "id": "11831", "last_activity_date": "2015-06-28T15:11:42.747", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "11830", "post_type": "answer", "score": 1 } ]
11830
null
11831
{ "accepted_answer_id": "11891", "answer_count": 2, "body": "[プログラミング言語C++ 第4版](http://www.amazon.co.jp/gp/product/4797375957)の「27.4.2\nクラス階層の線形化」に、菱形継承は線形継承より遅いというような事が書かれています。\n\n> 設計の第一歩目では、伝統的な多重継承による“ダイアモンド”型の階層だった:\n```\n\n> Node <-- Expr <-- Stmt <-- Decl <-- Var\n> ^ ^ ^ ^ ^\n> | | | | |\n> impl::Node <-- impl::Expr <-- impl::Stmt <-- impl::Decl <-- impl::Var\n> \n```\n\n>\n>\n> これでも動作したが、大きなメモリオーバヘッドが発生していた。仮想基底を移動するためのデータのために、ノードが大きくなりすぎていたからだ。さらに、各オブジェクトがもつ数多くの仮想基底への間接アクセスが多いので、プログラム動作の速度も深刻なほど低下していた(§21.3.5)。 \n> この解決策が、二つの階層を線形化することであった。それによって仮想基底が排除される:\n```\n\n> Node <-- Expr <-- Stmt <-- Decl <-- Var\n> ^\n> +-----------------------------------------------------------+\n> |\n> impl::Node <-- impl::Expr <-- impl::Stmt <-- impl::Decl <-- impl::Var\n> \n```\n\n中ほどに理由は書かれていますが、「21.3.5 仮想基底クラス」を読んでも、もう少し具体的にどこにどういう理由で時間がかかるのか理解できませんでした。 \n(なんとなく「インターフェイスの検索と実装の検索で2回検索するから?でも1回(線形継承の場合)か2回(菱形継承の場合)の差で深刻なほど速度差があるものなのか…?」と思っていますが…)\n\n一応以下のテストプログラムで、手元のClang 3.5.2では若干線形継承の方が速いことは確認できました。 \n(手元のマシンでは`std::chrono::high_resolution_clock`でもミリ秒単位ぐらいでしか計測できませんでしたが、1000回`call_function()`をまわして4ミリ秒くらいの差しかありませんでした。)\n\n```\n\n #include <chrono>\n #include <iomanip>\n #include <iostream>\n #include <memory>\n #include <string>\n #include <type_traits>\n #include <sstream>\n \n using namespace std;\n using namespace std::chrono;\n \n \n #ifdef DIAMOND_INHERITANCE\n // 菱形継承\n template<size_t N>\n struct Interface: virtual Interface<N - 1>\n {\n using Interface<N - 1>::function;\n virtual void function() = 0;\n virtual void function(integral_constant<size_t, N>) = 0;\n };\n \n template<>\n struct Interface<1>\n {\n virtual ~Interface() = default;\n virtual void function() = 0;\n virtual void function(integral_constant<size_t, 1>) = 0;\n };\n \n \n template<size_t N>\n struct Implementation: virtual Interface<N>, Implementation<N - 1>\n {\n using Implementation<N - 1>::function;\n void function() override {\n cout << \"Implementation<N>::function(): N = \" << N << \"\\n\";\n }\n void function(integral_constant<size_t, N>) override {\n cout << \"Implementation<N>::function(integral_constant<size_t, N>): N = \" << N << \"\\n\";\n }\n };\n \n template<>\n struct Implementation<1>: virtual Interface<1>\n {\n void function() override {\n cout << \"Implementation<N>::function(): N = \" << 1 << \"\\n\";\n }\n void function(integral_constant<size_t, 1>) override {\n cout << \"Implementation<N>::function(integral_constant<size_t, N>): N = \" << 1 << \"\\n\";\n }\n };\n \n #else\n \n // 線形継承\n template<size_t N>\n struct Interface: Interface<N - 1>\n {\n using Interface<N - 1>::function;\n virtual void function() = 0;\n virtual void function(integral_constant<size_t, N>) = 0;\n };\n \n template<>\n struct Interface<1>\n {\n virtual ~Interface() = default;\n virtual void function() = 0;\n virtual void function(integral_constant<size_t, 1>) = 0;\n };\n \n \n template<size_t N, size_t MAX_N>\n struct Implementation: Implementation<N - 1, MAX_N>\n {\n using Implementation<N - 1, MAX_N>::function;\n void function() override {\n cout << \"Implementation<N>::function(): N = \" << N << \"\\n\";\n }\n void function(integral_constant<size_t, N>) override {\n cout << \"Implementation<N>::function(integral_constant<size_t, N>): N = \" << N << \"\\n\";\n }\n };\n \n template<size_t MAX_N>\n struct Implementation<1, MAX_N>: Interface<MAX_N>\n {\n using Interface<MAX_N>::function;\n void function() override {\n cout << \"Implementation<N>::function(): N = \" << 1 << \"\\n\";\n }\n void function(integral_constant<size_t, 1>) override {\n cout << \"Implementation<N>::function(integral_constant<size_t, N>): N = \" << 1 << \"\\n\";\n }\n };\n #endif\n \n \n template<size_t N>\n void call_function(Interface<1> *obj)\n {\n obj->function();\n dynamic_cast<Interface<N> *>(obj)->function(integral_constant<size_t, N>{});\n if ( N > 1 ) call_function<N - 1>(obj);\n }\n \n template<>\n void call_function<0>(Interface<1> *obj) {}\n \n int main(int argc, char *argv[])\n {\n if ( argc < 2 ) return 1;\n istringstream is{argv[1]};\n size_t loop;\n is >> loop;\n \n constexpr std::size_t n{10};\n unique_ptr<Interface<1>> obj{\n #ifdef DIAMOND_INHERITANCE\n new Implementation<n>\n #else\n new Implementation<n, n>\n #endif\n };\n \n using clock = high_resolution_clock;\n const auto tp1 = clock::now();\n \n for ( std::size_t i{0}; i < loop; ++i ) {\n call_function<n>(obj.get());\n }\n \n const auto tp2 = clock::now();\n cerr << duration_cast<microseconds>(tp2 - tp1).count() << \"us\\n\";\n }\n \n```\n\n```\n\n clang++ -Wall -std=c++11 test_inheritance.cpp -DDIAMOND_INHERITANCE\n ./a.out 1000 > /dev/null\n 20001us\n clang++ -Wall -std=c++11 test_inheritance.cpp\n ./a.out 1000 > /dev/null\n 16001us\n \n```\n\nもう少し具体的にどこにどういう理由で時間がかかるのでしょうか?", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T02:55:23.237", "favorite_count": 0, "id": "11833", "last_activity_date": "2015-08-24T04:41:29.450", "last_edit_date": "2015-06-29T03:06:02.767", "last_editor_user_id": "7291", "owner_user_id": "7291", "post_type": "question", "score": 9, "tags": [ "c++" ], "title": "菱形継承が線形継承より遅い理由は?", "view_count": 1236 }
[ { "body": "上手く説明できませんが…\n\n> 「インターフェイスの検索と実装の検索で2回検索するから?でも1回(線形継承の場合)か2回(菱形継承の場合)の差で深刻なほど速度差があるものなのか…?」\n\nの通りです。`sizeof Interface<1>` ~ `sizeof Interface<10>`\nを見るとわかりますが、virtual継承をしている菱形継承の場合はサイズが8バイトずつ増加していきます。(もちろん実装依存です。) \n線形継承の場合はサイズは変わりません。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T23:20:57.223", "id": "11863", "last_activity_date": "2015-06-29T23:20:57.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "11833", "post_type": "answer", "score": 2 }, { "body": "仮想継承(virtual\ninheritance)を利用すると、C++オブジェクトを表現する仮想関数テーブル(vtbl)が複雑になるため、追加の実行時オーバーヘッドを生じます。仮想継承をどのように実現するかはC++コンパイラに依存しますが、内部処理としては同程度の操作を要求するため、どのような処理系でも同じ傾向となるはずです。\n\n線形継承では単純で直線的なvtbl構成で済むため、キャスト処理はほぼゼロ・オーバーヘッドで行えます。一方、仮想継承を用いた場合は複雑なvtbl構成となり、キャスト処理では間接参照やオフセット再計算など追加処理が必要となります。\n\n仮想継承とvtblの関係は、下記記事の図示などを参考にください:\n\n * [Memory Layout for Multiple and Virtual Inheritance](http://www.phpcompiler.org/articles/virtualinheritance.html)\n * [Multiple Inheritance Considered Useful](http://www.drdobbs.com/cpp/multiple-inheritance-considered-useful/184402074)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-30T10:12:15.080", "id": "11891", "last_activity_date": "2015-07-01T01:33:24.507", "last_edit_date": "2015-07-01T01:33:24.507", "last_editor_user_id": "49", "owner_user_id": "49", "parent_id": "11833", "post_type": "answer", "score": 8 } ]
11833
11891
11891
{ "accepted_answer_id": "11838", "answer_count": 3, "body": "お世話になります。\n\nPHP+mysqlで、簡単なWebシミュレーションゲーム的なものを \n作ってみようと思っています。\n\nそこで、よく見られるような、一定時間ごとに民が米や鉄を生産して \n増えていくと言ったつくりをしたいのですが、これはどのような仕組みで \n実現しているのかが解りません。\n\nmysql自体に、一定時間に決まった処理をするという機能がついているのか、 \nそれとも、サーバー側のPHPかその他の言語かなんかで一定時間ごとにSQLを \n走らせているのか。別の言語でそういったプログラムを入れれば簡単そうですが、 \n実際はどうなのでしょうか。\n\n少し質問の内容からは逸れてしまいますが、PHP+mysqlが使えるレンタルサーバー \nなどでも実現できるのでしょうか。\n\nここまでのことをするには、自分でサーバーを立てるしか方法がないのでしょうか。\n\n初心者で申し訳ありませんが、ご助言をお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T04:41:02.650", "favorite_count": 0, "id": "11834", "last_activity_date": "2015-06-29T06:02:29.007", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9374", "post_type": "question", "score": 1, "tags": [ "php", "mysql" ], "title": "mysql で一秒ごとにカウントアップさせたい", "view_count": 913 }
[ { "body": "時間で計算したらダメでしょうかね?\n\n毎度毎度DBに保存させるのではなく、任意のタイミング(消費したりとか、生産数が変わったりとか)で保持させて、次回利用時に時差から増加分を計算して現在の資源数を計算する。\n\nブラウザ側でリアルタイムに資源が増えていく様子は、ブラウザ内でタイマー使って増やしていくってのはどうでしょう? \n当然、ブラウザ側とサーバ側とでズレは発生すると思うので、何分かおきにでもサーバと同期してやると。このタイミングでサーバ側の資源テーブルを更新してやってもいいですかね。\n\n1秒以内に何度も通信とか、ユーザが増えたりしたら...(((;゜Д゜)))ガクガクブルブル", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T05:45:54.997", "id": "11838", "last_activity_date": "2015-06-29T05:45:54.997", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2383", "parent_id": "11834", "post_type": "answer", "score": 2 }, { "body": "一定時間ごとに処理を行うのはnode.jsなどを使えば簡単に実現できます。\n\n普通のレンタルサーバーであっても、最近はcronの使えるサーバーが多いと思いますので、cronで一定時間ごとにPHPを実行してみてはいかがでしょうか。\n\ncronの使えないレンタルサーバーでは一定時間ごとの処理は基本的には不可能ですが、「一定時間ごとに民が米や鉄を生産して増えていく」という処理を馬鹿正直に一定時間ごとに実行する必要はありません。 \nプレイヤーがアクセスしたタイミングで、今までの生産処理を一気に実行すれば同じことだと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T05:50:18.707", "id": "11840", "last_activity_date": "2015-06-29T05:50:18.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2232", "parent_id": "11834", "post_type": "answer", "score": 1 }, { "body": "> mysql自体に、一定時間に決まった処理をするという機能\n\nという部分に関してのみの回答になりますが、\n\n[CREATE EVENT 構文](http://dev.mysql.com/doc/refman/5.6/ja/create-\nevent.html)を使えば実現はできそうです。 \nこちらは stored procedure を使う例ですが、参考程度に。 \n[How to schedule a stored procedure in\nMySQL](https://stackoverflow.com/questions/6560639/how-to-schedule-a-stored-\nprocedure-in-mysql)\n\nただ、他の方が回答に記載しているように、 \nWebシミュレーションゲーム的なものでRDBを使用して毎秒処理は中々に危険な気がします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T06:02:29.007", "id": "11842", "last_activity_date": "2015-06-29T06:02:29.007", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "3516", "parent_id": "11834", "post_type": "answer", "score": 2 } ]
11834
11838
11838
{ "accepted_answer_id": "11837", "answer_count": 1, "body": "何秒毎に値をプラスしていき、それを3分間一番大きな値をだす組み合わせを出すアプリケーションをつくってみようとおもい \nまずはじめに ruinというものが2.5秒に一回、80の値を出すとして4分間でどのくらいの値を出すかということで\n\n```\n\n class act{\n public static void main (String args[]){\n for(int i = 0; i < 240; i++){//4m\n try{\n Thread.sleep((long) (ActionSkill.ruin[0]*1000));//2.5秒に一回動く\n }catch(InterruptedException e){\n System.out.println(e);\n }\n }\n double x = 0;\n x = + ActionSkill.ruin[2];\n System.out.println(x);\n }\n \n }\n class ActionSkill{\n \n static double ruin[] ={2.50, 2.50, 80};\n //{cast, recast, dmg};\n \n }\n \n```\n\nとまず初めに書いてみましたが、実行しようとしても上手くいきません。また\n\n```\n\n class ActionSkill{\n \n static double ruin[] ={2.50, 2.50, 80};\n //{cast, recast, dmg};\n \n }\n \n```\n\nといった書き方がまだいまいちよくわからないので、\n\n```\n\n class act{\n public static void main (String args[]){\n double ruin[] ={2.50, 2.50, 80};\n for(int i = 0; i < 240; i++){//4m\n try{\n Thread.sleep((long) (ruin[0]*1000));//2.5秒に一回動く\n }catch(InterruptedException e){\n System.out.println(e);\n }\n }\n double x = 0;\n x = + ruin[2];\n System.out.println(x);\n }\n \n }\n \n```\n\nと書いてみても上手くいきません。コンパイルエラーはでないのですが上手く実行されません。 \nおそらく\n\n```\n\n try{\n Thread.sleep((long) (ruin[0]*1000));//2.5秒に一回動く\n }catch(InterruptedException e){\n System.out.println(e);\n }\n \n```\n\nこの部分に間違いがあるのだと思うのですが、自分だとわかりませんでした。 \nいずれは複数の組み合わせを足していきたいと考えているのですが初めから躓いてしまいました。 \nよろしくお願い致します。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T04:47:20.377", "favorite_count": 0, "id": "11835", "last_activity_date": "2015-06-29T05:32:46.647", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10197", "post_type": "question", "score": 1, "tags": [ "java" ], "title": "毎秒毎の値をだしたいのですが", "view_count": 228 }
[ { "body": "こういうことがしたいんですかね?\n\n```\n\n public class test {\n public static void main (String args[]){\n double x = 0;\n \n for(int i = 0; i < 240; i++){//4m\n try{\n Thread.sleep((long) (ActionSkill.ruin[0]*1000));//2.5秒に一回動く\n }catch(InterruptedException e){\n System.out.println(e);\n }\n \n x += ActionSkill.ruin[2];\n System.out.println(x);\n }\n }\n \n }\n \n class ActionSkill{\n static double ruin[] ={2.50, 2.50, 80}; //{cast, recast, dmg};\n }\n \n```\n\n上記を実行すれば2.5秒おきに、80を足してった値を出力します。\n\n* * *\n\nまず、for loop内に`println()`を書いてあげないと、loopが全部終わってから1回だけ出力されるだけです。 \n次に、xの宣言時に初期化してますが、loop内に初期化処理を買いちゃうと、loopするたんびに初期化されるので、加算されていきません。毎回80を出したいのが所望の動きなら合ってますが、`x`に`ruin[2]`を入れる必要も無いかなぁ...という気がします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T05:32:46.647", "id": "11837", "last_activity_date": "2015-06-29T05:32:46.647", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2383", "parent_id": "11835", "post_type": "answer", "score": 1 } ]
11835
11837
11837
{ "accepted_answer_id": "11846", "answer_count": 1, "body": "poewrshellを使って、Data Visualizationを学びはじめた者です。 \nPythonのversionは2.7 \nwindowsは8.1を使用しています。\n\n私の、システム環境変数パスは、下記の通りです。\n\n```\n\n c:\\python27\\;c:\\python27\\scripts;c:\\python27\\tools\\scripts;C:\\Program Files (x86)\\Common Files\\Apple\\Apple Application Support;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Windows Live\\Shared;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Program Files (x86)\\Common Files\\Roxio Shared\\DLLShared\\;C:\\Program Files (x86)\\Common Files\\Roxio Shared\\OEM\\12.0\\DLLShared\\;C:\\Program Files (x86)\\Roxio 2010\\OEM\\AudioCore\\;C:\\Program Files (x86)\\Brackets\\command;C:\\Program Files (x86)\\QuickTime\\QTSystem\\;C:\\Program Files (x86)\\Skype\\Phone\\;C:\\Program Files\\Git\\bin;C:\\Program Files (x86)\\Git\\cmd\n \n```\n\nVirtualenvwrapperをインストールし、`mkvirtualenv TestEnv` を実行したのですが、以下のエラーが得られます。\n\n```\n\n PS C:\\windows\\system32> mkvirtualenv TestEnv\n Fatal error in launcher: Unable to create process using '\"C:\\windows\\system32\\python.exe\" \"c:\\python27\\scripts\\virtualenv.exe\" TestEnv\n \n```\n\nどなたか、何かアイデアのございます方、お力を貸して頂けますと助かります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-06-29T05:16:04.553", "favorite_count": 0, "id": "11836", "last_activity_date": "2020-12-13T07:35:45.170", "last_edit_date": "2020-12-13T07:35:45.170", "last_editor_user_id": "3060", "owner_user_id": "10314", "post_type": "question", "score": 1, "tags": [ "python", "powershell" ], "title": "powershell で mkvirtualenv TestEnv を実行するとエラーになる", "view_count": 200 }
[ { "body": "`\"C:\\windows\\system32\\python.exe\"` は存在していますか? \nあるのなら、アクセス権の問題、ないのならPythonインストールの問題でしょう。\n\nPythonを一度完全に削除してから、再インストールすることをお勧めします。\n\nなお、他に出されている質問全て、同じ問題で発生しているように見えます。 \nPythonをどうやってインストールしたのか分からないので、その手順や利用したインストーラなどの情報があれば問題点が明確になるかもしれません。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T07:05:19.267", "id": "11846", "last_activity_date": "2015-06-29T07:05:19.267", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "11836", "post_type": "answer", "score": 1 } ]
11836
11846
11846
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在iOS8でMPMoviePlayerControllerを利用して動画再生機能を実現しようとしているのですが \nフルスクリーンの状態で表示される>>|ボタンを長押しではなく、シングルタップすると \n画面上部中央にLoading...と表示され、動画の再生ができなくなります。 \n(長押しでの早送りは正常に動いています。) \nこのシングルタップ時の挙動を無効、もしくはタップしたら再生中動画の再生終了時間まで移動する \nという処理に変更することはできないでしょうか?\n\nMPMoviePlayerControllerは下記の設定を入れています。\n\n```\n\n _moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];\n _moviePlayer.backgroundView.backgroundColor = [UIColor whiteColor];\n _moviePlayer.scalingMode = MPMovieScalingModeAspectFit;\n _moviePlayer.controlStyle = MPMovieControlStyleDefault;\n [_moviePlayer prepareToPlay];\n [_moviePlayer play];\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T05:56:45.293", "favorite_count": 0, "id": "11841", "last_activity_date": "2015-06-29T06:14:17.007", "last_edit_date": "2015-06-29T06:14:17.007", "last_editor_user_id": "3516", "owner_user_id": "9986", "post_type": "question", "score": 1, "tags": [ "ios", "xcode" ], "title": "MPMoviePlayerControllerの>>|ボタンの挙動について", "view_count": 188 }
[]
11841
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "[\"さとう\",\"あおき\"、\"おおの\"]というように名前の文字列が入っている配列を、 \n「\"あおき\"、\"おおの\"、\"さとう\"」というように五十音順に並び変えるにはどのような方法が \nありますか?\n\n```\n\n class person :NSObject{\n \n var name : NSString?\n \n init(nam:NSString) {\n \n name = nam\n }\n \n }\n \n \n var person1 = person(nam: \"おおの\")\n var person2 = person(nam: \"さとう\")\n var person3 = person(nam: \"あおき\")\n \n println(person1.name)\n println(person2.name)\n println(person3.name)\n \n```\n\nこのようなインスタンスが入った配列の場合も同様に可能でしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T06:14:53.050", "favorite_count": 0, "id": "11843", "last_activity_date": "2015-06-29T08:32:37.380", "last_edit_date": "2015-06-29T07:12:47.413", "last_editor_user_id": "8060", "owner_user_id": "8060", "post_type": "question", "score": 1, "tags": [ "swift" ], "title": "Swiftの配列の要素を五十音順に並べたい。", "view_count": 2319 }
[ { "body": "このように出来ます。\n\n```\n\n var strings = [\"さとう\", \"あおき\", \"おおの\", \"かみきど\", \"すずき\"]\n sort(strings) { str1, str2 in str1 > str2 }\n \n strings.sort { (lhs, rhs) in return lhs < rhs }\n \n```\n\n<http://qiita.com/mst/items/b18e9531ac0cbdf2f3c3>\n\n編集\n\n```\n\n class person {\n \n var name : NSString\n \n init(nam:NSString) {\n \n name = nam\n }\n \n }\n \n \n var person1 = person(nam: \"おおの\")\n var person2 = person(nam: \"さとう\")\n var person3 = person(nam: \"あおき\")\n \n var people: Array<person> = []\n \n \n people += [person1]\n people += [person2]\n people += [person3]\n \n var sortedPeople = people.sorted({ ($0.name as? String) < ($1.name as? String) })\n \n \n println(person1.name)\n println(person2.name)\n println(person3.name)\n \n println(sortedPeople[0].name)\n println(sortedPeople[1].name)\n println(sortedPeople[2].name)\n \n```\n\nもし片仮名対応も出来たいのなら、こんなふうに出来ます。\n\n```\n\n extension String {\n func hiragana() -> String {\n var str = \"\"\n for c in unicodeScalars {\n if c.value >= 0x30A1 && c.value <= 0x30F6 {\n str.append(UnicodeScalar(c.value-96))\n } else {\n str.append(c)\n }\n }\n return str\n }\n }\n class person {\n \n var name : NSString\n \n init(nam:NSString) {\n \n name = nam\n }\n \n }\n \n \n var person1 = person(nam: \"おおの\")\n var person2 = person(nam: \"さとう\")\n var person3 = person(nam: \"あおき\")\n var person4 = person(nam: \"カミキド\")\n \n var people: Array<person> = []\n \n \n people += [person1]\n people += [person2]\n people += [person3]\n people += [person4]\n \n var sortedPeople = people.sorted({ ($0.name as String).hiragana() < ($1.name as String).hiragana() })\n \n \n println(person1.name) //おおの\n println(person2.name) //さとう\n println(person3.name) //あおき\n println(person4.name) //カミキド\n \n println(sortedPeople[0].name) //あおき\n println(sortedPeople[1].name) //おおの\n println(sortedPeople[2].name) //カミキド\n println(sortedPeople[3].name) //さとう\n \n```", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T06:30:04.120", "id": "11844", "last_activity_date": "2015-06-29T08:32:37.380", "last_edit_date": "2015-06-29T08:32:37.380", "last_editor_user_id": "4336", "owner_user_id": "4336", "parent_id": "11843", "post_type": "answer", "score": 1 } ]
11843
null
11844
{ "accepted_answer_id": "11857", "answer_count": 3, "body": "Visual Studio Community\n2013で、C++のプログラムを作成するうえで、libxml2というライブラリを使いたいんですが、依存ライブラリの取り込み方がよくわかりません。\n\nライブラリまるごとアーカイブ化されているわけでもないのでクラスパスに追加して実行すればいいというわけでもなさそうだし、実行はターミナルからコンパイルして実行しているので、g++でのコンパイル時の、依存ライブラリの取り込み方法と、VC++Expressでのビルドが通る状態にする方法(IDE上で依存関係を追加する方法)を教えてください。\n\n初歩的な質問で申し訳ございませんが、よろしくお願いします。\n\n> miteiさん\n\nXML読み込みのやり方をググっていろいろ調べていたのですが、 \nブログなど皆さんが公開されている実装を見て、どんな関数があるのか調べ、それぞれ移植しながら実装を行っていたのですが、どうもI/O系の関数が丸ごとなくなっており、何か漏れている感じがします。\n\nライブラリディレクトリの多くはlibとのことでしたが、 \nDLしたlibxml2にはlibディレクトリがなかったため、DL直下をライブラリディレクトリとしました。これが何か悪さをしているのでしょうか?\n\nダウンロードしたライブラリ本体はこちらです。 \n<ftp://xmlsoft.org/libxml2/libxml2-2.9.2.tar.gz>\n\nincludeディレクトリはあったので、Include Directoryはこちらで間違いないかと思いますが、 \nlibraryディレクトリはこれであっているのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T06:30:48.440", "favorite_count": 0, "id": "11845", "last_activity_date": "2015-06-29T13:27:10.123", "last_edit_date": "2015-06-29T11:22:54.387", "last_editor_user_id": "8396", "owner_user_id": "8396", "post_type": "question", "score": 3, "tags": [ "c++", "visual-studio" ], "title": "C++ VisualStudioで外部ライブラリを取り込んでビルドする方法", "view_count": 32804 }
[ { "body": "とりあえずVisualStudio上で入れる方法を...\n\nVisualStudio2013を起動したら、メニューから`[ツール]-[NuGetパッケージマネージャー]-[ソリューションのNuGetパッケージの管理]`を選択。 \nNuGetパッケージの管理ダイアログが開くので、右上の『オンラインの検索』ってtextboxに『libxml2』と入力。 \n検索結果に『libxml2』が出てくるので『インストール』ボタンを押下。ライブラリを利用したいプロジェクトを選択するダイアログが出るので、プロジェクトにチェックを入れて『OK』押下。 \nこれで『libxml2』と『libxml2 Redist』が入るみたいです。\n\n後は、ライブラリを使用するとしていしたプロジェクトのファイル上で`#include\n\"libxml\\hogehoge.h\"`とかってやってやれば使えると思いますよ。 \n※hogehogeの部分は当然、自分が利用したいheader file名ですね。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T07:31:39.120", "id": "11848", "last_activity_date": "2015-06-29T07:31:39.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2383", "parent_id": "11845", "post_type": "answer", "score": 2 }, { "body": "NuGet パッケージがあれば良いですが…すべてのライブラリが提供されているわけではないので通常の手順も紹介しておきます。 \n通常、C++ でライブラリを使うにはライブラリ本体(.lib, .a)と、ヘッダファイル群が必要になります。 \nヘッダファイルが入っているディレクトリまでのパスを、一般的にインクルードパスと呼びます。このディレクトリには慣習的に include\nという名前が付けられることが多いです。 \nまた、ライブラリが入っているディレクトリの名前は慣習的に lib という名前が付けられることが多いです。 \nどちらも Unix 系の慣習なので Windows 専用のライブラリの場合はこれに当てはまらないこともあります。\n\ng++ の場合、 \n`-I[インクルードパス]` \n`-L[ライブラリの検索パス]` \n`-l[ライブラリ名]` \nなどのオプションを使ってライブラリを使うための設定をします。ライブラリ名は libxml2.a の場合、`-lxml2` のように頭の lib と拡張子\n.a を省略して記述します。\n\nVisual Studio の場合、 \nソリューションエクスプローラーからプロジェクト名を右クリックしてプロパティを選択。 \nC/C++→全般→追加のインクルードディレクトリ を編集してインクルードパスを追加。 \nリンカー→全般→追加のライブラリディレクトリ を編集してライブラリの検索パスを追加。 \nリンカー→入力→追加の依存ファイル を編集してライブラリを追加。こちらは g++ の場合とは異なり、拡張子を含むファイル名をそのまま入力します。\n\nクロスプラットフォームの開発を行う場合は、プラットフォーム毎にこれらの設定を行うのは面倒なので cmake などのビルドツールを使うのが一般的です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T08:54:56.347", "id": "11854", "last_activity_date": "2015-06-29T08:54:56.347", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2748", "parent_id": "11845", "post_type": "answer", "score": 2 }, { "body": "> libraryディレクトリはこれであっているのでしょうか?\n\nあってません。というか手順が足りていないんですね。 \nライブラリを使用するにはヘッダファイルと .lib や .a といったバイナリ形式のライブラリファイルが必要になります。 \nライブラリディレクトリにはこれらのライブラリファイルが含まれるディレクトリを指定する必要があります。\n\n> ダウンロードしたライブラリ本体はこちらです。 \n> <ftp://xmlsoft.org/libxml2/libxml2-2.9.2.tar.gz>\n\nこれに含まれているのはライブラリのソースコードのみであって、ビルド済みのバイナリは含まれていません。 \nREADME に従ってビルドするのが通常の手順ですが、libxml2 の Windows でのビルド手順がちょっと特殊なようですね…。\n\n<http://xmlsoft.org/sources/win32/libxml2-2.7.8.win32.zip> \nバージョンが古いですが公式でビルド済みバイナリが配布されているのでこれを使ってもよいかもしれません。 \n残念ながら最新版の libxml2 の Visual Studio 用のバイナリは提供されていないようです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-29T13:27:10.123", "id": "11857", "last_activity_date": "2015-06-29T13:27:10.123", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2748", "parent_id": "11845", "post_type": "answer", "score": 1 } ]
11845
11857
11848