question
dict
answers
list
id
stringlengths
2
5
accepted_answer_id
stringlengths
2
5
popular_answer_id
stringlengths
2
5
{ "accepted_answer_id": "26966", "answer_count": 1, "body": "キーワード検索機能を持つブログで、検索結果の2ページ目にキーワードを引き継ぐためにGETを用いて「?s=キーワード&page=ページ」の形にしています。 \n実際にはマルチバイト文字はエスケープされるので「あ」は「%E3%81%82」に置き換えられて次のようになっています。\n\n```\n\n http://example.com/blog/?s=%E3%81%82&page=2\n \n```\n\nしかし、そのリンクにアクセスしてみるとすぐにリダイレクトされて下記のアドレスに転送されます。「%」が「%25」に置き換えられてしまっています。\n\n```\n\n http://example.com/blog?s=%25E3%2581%2582&page=2\n \n```\n\n転送の原因は末尾のスラッシュを消すための処理を.htaccessに記述しているせいです。\n\n```\n\n RewriteRule ^(.*)/$ /$1 [L,R=301]\n \n```\n\nこの処理をなくすか、URLを「〜blog/?s=」の代わりに「〜blog?s=」となるようにリンクを作成するとリダイレクトは発生しないので正しいURLにアクセスすることができます。 \nしかし、使用しているフレームワーク(Laravel 5.0)のページネーション機能 render() で出力すると不要な末尾の「/」が付加されてしまいます。\n\n・Laravel のビュー部分\n\n```\n\n {!! $posts->render() !!}\n \n```\n\n理想はフレームワーク側で末尾にスラッシュを付けずに render() によるページナビ出力をしたいのですが、.htaccess\n側で対処できるのであればそれでも構いません。 \nリダイレクト時にGETパラメータを正しく保持したままにするにはどうすれば良いのでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-22T09:46:58.607", "favorite_count": 0, "id": "17951", "last_activity_date": "2016-06-23T00:44:31.213", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10083", "post_type": "question", "score": 4, "tags": [ "php", "apache", "laravel" ], "title": ".htaccessでのリダイレクト時にURLが二重にパーセントエンコードされてしまう", "view_count": 4994 }
[ { "body": "[argusさんのコメント](https://ja.stackoverflow.com/questions/17951/htaccess%E3%81%A7%E3%81%AE%E3%83%AA%E3%83%80%E3%82%A4%E3%83%AC%E3%82%AF%E3%83%88%E6%99%82%E3%81%ABurl%E3%81%8C%E4%BA%8C%E9%87%8D%E3%81%AB%E3%83%91%E3%83%BC%E3%82%BB%E3%83%B3%E3%83%88%E3%82%A8%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%89%E3%81%95%E3%82%8C%E3%81%A6%E3%81%97%E3%81%BE%E3%81%86#comment16584_17951)より。\n\n> `RewriteRule ^(.*)/$ /$1 [L,NE,R=301]` としてみて下さい(`NE` を追加)。`NE` は `No Escape`\n> の意味です。\n\n関連: [RewriteRule Flags - Apache HTTP Server Version\n2.4](https://httpd.apache.org/docs/current/rewrite/flags.html#flag_ne)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-06-23T00:44:31.213", "id": "26966", "last_activity_date": "2016-06-23T00:44:31.213", "last_edit_date": "2017-04-13T12:52:39.113", "last_editor_user_id": "-1", "owner_user_id": "8000", "parent_id": "17951", "post_type": "answer", "score": 2 } ]
17951
26966
26966
{ "accepted_answer_id": "17957", "answer_count": 2, "body": "下記の1行でコンパイルできません。\n\n```\n\n import RealmSwift\n \n```\n\n使用しているrealmのVerは0.96.1だと思います。 \nまだiOS9.1に対応できていないのか、私の設定が悪いのか?\n\nただ、開発環境をXCODE7.1にし、Realmのフレームワークを最新に置き換えただけです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-22T10:22:31.290", "favorite_count": 0, "id": "17953", "last_activity_date": "2015-10-23T17:12:47.107", "last_edit_date": "2015-10-22T11:08:49.547", "last_editor_user_id": "5519", "owner_user_id": "10845", "post_type": "question", "score": 0, "tags": [ "swift", "realm" ], "title": "RealmのXcode 7.1の対応状況について", "view_count": 753 }
[ { "body": "```\n\n Module file was created by an older version of the compiler; rebuild 'RealmSwift' and try again: /Volumes/Untitled/TypeArray/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule\n \n```\n\nおそらく上記のようなエラーが出ていると思います。Swiftのコンパイラは少しでも古いバージョンでビルドされたモジュールを使えないので、Xcode\n7.1でビルドされたフレームワークが必要になります。 \nXcode 7.1でビルドされたフレームワークはまもなくリリースされますが、それまで待つか、CocoaPodsなどを利用してインストールしてください。", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-22T11:12:10.423", "id": "17957", "last_activity_date": "2015-10-22T11:12:10.423", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "17953", "post_type": "answer", "score": 1 }, { "body": "私も同じ状況に遭遇しましたが、CocoaPods、インストールで解決しました。今後は、Xcodeのバージョンアップデートを考慮すると、CocoaPodsでインストールした方が良さそうですね。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T02:12:38.207", "id": "17963", "last_activity_date": "2015-10-23T17:12:47.107", "last_edit_date": "2015-10-23T17:12:47.107", "last_editor_user_id": "30", "owner_user_id": "12914", "parent_id": "17953", "post_type": "answer", "score": 2 } ]
17953
17957
17963
{ "accepted_answer_id": null, "answer_count": 1, "body": "Flask / Python 初心者です。\n\n不正アクセスの対策のためなのですが、 \n不正な URL が来たときに、応答を破棄させて、不正アクセス攻撃に対応したいです。 \n他のサイトを見ると、巨大な画像ファイルとしてバイナリを延々と送って、、などもあったのですが、サーバー負荷を掛けたくないため、またレスポンス400などを送ると次の攻撃を早くされてしまうため、何も返さずに要求を捨てたいのですが、Flask\nでは対応方法があるのでしょうか? \nNode.js では response.end 関連を実行しなければ対応できるのですが。。。\n\n詳しい方、教えてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-22T10:54:44.567", "favorite_count": 0, "id": "17955", "last_activity_date": "2015-11-08T03:19:44.243", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12906", "post_type": "question", "score": 0, "tags": [ "python", "flask" ], "title": "応答を破棄する方法について", "view_count": 326 }
[ { "body": "通常の実践環境であれば、Flaskが処理をする前にnginxなどHTTPサーバがルートを処理するので、HTTPサーバの時点でマッチしないURLには応答しないようにすればいいのではないでしょうか。\n\n参考ページ: [How can I tell nginx to silently ignore requests that dont match and\nlet them time out instead of giving 404](http://goo.gl/EnWX46)\n\n上のリンク先では、nginxでHTTPレスポンス444を返すという処理をわざと書く事で、実際には何も応答しないようにするテクニックが紹介されています。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-08T03:19:44.243", "id": "18535", "last_activity_date": "2015-11-08T03:19:44.243", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "197", "parent_id": "17955", "post_type": "answer", "score": 1 } ]
17955
null
18535
{ "accepted_answer_id": null, "answer_count": 3, "body": "JavaのクラスをSerializableにする場合、存在するフィールド全てに再帰的にSerializableを付与する必要がありますが、これを自動的に行うIDEの機能やツールはあるでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-22T11:08:06.600", "favorite_count": 0, "id": "17956", "last_activity_date": "2015-12-05T07:30:22.360", "last_edit_date": "2015-12-05T07:30:22.360", "last_editor_user_id": "46", "owner_user_id": "816", "post_type": "question", "score": 3, "tags": [ "java" ], "title": "Serializableを全てのフィールドに再帰的に自動付与する機能", "view_count": 784 }
[ { "body": "Serializableを実装(implements)したクラスのフィールドには、Serializableの宣言をする必要はありません。\n\n言い換えると、Serializableを実装したクラスのフィールドは、プリミティブ型もしくはシリアライズ可能なクラスでないと、シリアライズできません。\n\nひょっとして、以下のようなことができるエディアをお探しでしょうか。\n\n```\n\n public class Sample implement Serializable {\n public Child child;\n }\n \n```\n\nこのSampleクラスを作った後に、Childクラスを作ろうとすると、\n\n```\n\n public class Child [ implements Serializable ここが自動的に生成] {\n \n }\n \n```\n\nということでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T17:10:51.403", "id": "18062", "last_activity_date": "2015-10-25T17:10:51.403", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5778", "parent_id": "17956", "post_type": "answer", "score": 1 }, { "body": "無いようなのでとりあえず自分でカンタンなものを作ってみました。 \n今のところはあるフォルダ下にあるクラスを全てSerializableにするだけで、少し複雑なクラスだとうまくいかないこともあります。\n\n<https://github.com/lamrongol/MakeJavaClassSerializable>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-04T02:34:41.267", "id": "18390", "last_activity_date": "2015-11-04T02:34:41.267", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "816", "parent_id": "17956", "post_type": "answer", "score": 0 }, { "body": "直接的な回答ではないのですが、勘違いされている可能性もあるかと考えましたので記載します。\n\n> 存在するフィールド全てに再帰的にSerializableを付与する必要があります\n\nというのは十分条件ではあっても、必要条件ではありません。\n\n例えば、以下の様な`Child`型をフィールドに持つ`Parent`があるとき、\n\n```\n\n class Parent implements Serializable {\n \n private Child child;\n \n // ...\n }\n \n class Child {\n }\n \n```\n\n`Child`型が`Serializable`でないので`Parent`は実際にはシリアライズ不能である、 **というわけではありません** 。\n\n`child`フィールドにセットされているのが次のような型のインスタンスであれば、シリアライズ可能です。\n\n```\n\n class SerializableChild extends Child implements Serializable {\n }\n \n```\n\nあるいは、`child`が`null`であってもシリアライズ可能です。\n\n一方、次の型のインスタンスがセットされていれば、シリアライズに失敗します。\n\n```\n\n class NonSerializableChild extends Child {\n }\n \n```\n\n(実行可能サンプルコード: <http://ideone.com/2ER9Dm> )\n\n* * *\n\n[Javadoc](http://docs.oracle.com/javase/jp/8/api/java/io/Serializable.html)が言うところの\n\n>\n> クラスの直列化可能性は、java.io.Serializableインタフェースを実装するクラスによって有効になります。このインタフェースを実装していないクラスでは、その状態が直列化または直列化復元されることはありません。 \n> (略) \n>\n> グラフの巡回中に、直列化可能インタフェースをサポートしていないオブジェクトに遭遇することがあります。この場合は、NotSerializableExceptionがスローされ、この例外によって非直列化可能オブジェクトのクラスが特定されます。\n\nを感覚的に分かりやすいように翻訳すると、\n\n * **クラス** が`Serializable`で無ければシリアライズ、デシリアライズ時に無視される(詳しくはJavadocの後続文章参照)\n * **オブジェクト** が`Serializable`で無ければ実行時に例外がスローされる\n\nということになります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-04T05:22:55.260", "id": "18394", "last_activity_date": "2015-11-04T05:22:55.260", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2808", "parent_id": "17956", "post_type": "answer", "score": 2 } ]
17956
null
18394
{ "accepted_answer_id": "18265", "answer_count": 2, "body": "以下のようなhtmlをjspで出力したいです。\n\n```\n\n <ul id=\"item-list\">\n <script type=\"text/html\">\n <li><%=item.name%>: <%=item.msg%></li>\n </script>\n \n <li>山田: おはようございます</li>\n <li>田中: こんにちは</li>\n </ul>\n \n```\n\n`script`の箇所を除く出力をする場合は以下のようにすれば良いと思います。\n\n```\n\n <ul id=\"item-list\">\n <%for(Item item: items){%>\n <li><%=item.name%>: <%=item.msg%></li>\n <%}%>\n </ul>\n \n```\n\nしかし、今回は`<ul>`の内部に、`<script>`で括られた評価しないテキスト`<li><%=item.name%>:\n<%=item.msg%></li>`を含めたいです。\n\nつまり、以下のようにすれば良いことになります。\n\n```\n\n <ul id=\"item-list\">\n <script type=\"text/html\">\n <li><\\%=item.name%>: <\\%=item.msg%></li>\n </script>\n \n <%for(Item item: items){%>\n <li><%=item.name%>: <%=item.msg%></li>\n <%}%>\n </ul>\n \n```\n\n今回の例では、`<li>`の中身がシンプルなので何も問題がない気がしますが`<li>`の中身が複雑な場合にはほぼ同じHTMLを2度記述する必要が生まれます。\n\n`<li>`部分を別ファイルに分けるというような処理を行わずに、このjspファイル単体で`<li>`部分の文字列を一度変数に入れるなどして、評価する場合としない場合の出力を同時に行うことはできますでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T01:02:00.980", "favorite_count": 0, "id": "17960", "last_activity_date": "2015-11-04T20:03:22.900", "last_edit_date": "2015-10-23T03:22:53.360", "last_editor_user_id": "5840", "owner_user_id": "5840", "post_type": "question", "score": 1, "tags": [ "java", "jsp" ], "title": "jspに記述したhtmlを評価せずに出力するには?", "view_count": 1013 }
[ { "body": "文字列を一度変数に入れる手段としてスタンダードタグライブラリであるcoreのsetを利用すればタグで囲まれた内容を変数に代入することができます。\n\n```\n\n <c:set var=”変数名” [scope=”{page|request|session|application}”]>\n 値 \n </c:set>\n \n```\n\nそして、c:outを利用することで変数に代入した文字列を出力することができます。\n\n```\n\n <c:out value=\"${変数名}\" />\n \n```\n\nしかし、評価する前の値と評価した後の値を出力する方法はおそらくありませんので、独自のtaglibを定義するしかないと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-31T04:29:37.773", "id": "18265", "last_activity_date": "2015-11-04T20:03:22.900", "last_edit_date": "2015-11-04T20:03:22.900", "last_editor_user_id": "8351", "owner_user_id": "8351", "parent_id": "17960", "post_type": "answer", "score": 2 }, { "body": "```\n\n <%for(Item item: items){%>\n <li><%=item.name%>: <%=item.msg%></li>\n <%}%>\n \n```\n\nの部分は、スタンダードタグライブラリの `forEach` でも書けますよ。\n\n```\n\n <%@ taglib prefix=\"c\" uri=\"http://java.sun.com/jsp/jstl/core\"%>\n <c:forEach var=\"item\" items=\"${items}\">\n <li><c:out value=\"${item.name}\": <c:out value=\"${item.msg}\"</li>\n </c:forEach>\n \n```\n\nスタンダードタグライブラリやSpringのタグライブラリを使ったほうが、デフォルトでサニタイズされるので、`<%= %>` を使うより便利かな。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-01T14:49:34.007", "id": "18308", "last_activity_date": "2015-11-01T14:57:15.247", "last_edit_date": "2015-11-01T14:57:15.247", "last_editor_user_id": null, "owner_user_id": "807", "parent_id": "17960", "post_type": "answer", "score": 0 } ]
17960
18265
18265
{ "accepted_answer_id": null, "answer_count": 1, "body": "こちらのサイトを参考にしシリアル通信のプログラムを作成したのですが, \n<http://chicklab.blog84.fc2.com/blog-entry-29.html> \nスレッドで一定周期,例えば20Hz毎にwriteするとし, \n別スレッドで同じポートを使用し任意のタイミングでwriteしたいと考えています \nもし同じタイミングで呼び出された場合競合してしまいますよね? \nboost::asio::strandなどを用いてスレッドセーフにしようかと考えたり \nflag管理なども考えたのですが上手くいきません \n何か良い方法はありますでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T01:17:16.650", "favorite_count": 0, "id": "17961", "last_activity_date": "2015-11-02T02:12:16.103", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12913", "post_type": "question", "score": 2, "tags": [ "c++", "boost" ], "title": "boostのシリアル通信について", "view_count": 736 }
[ { "body": "経験的に一つのポートに対して複数のスレッドからread/writeしたり、readとwriteを別スレッドに分けるのは、実装が複雑になって上手くいきません。 \nこのような場合には一つのスレッドを作って(仮にスレッドhoge)ポートへのread/writeをスレッドhogeから全て行うようにします。他のスレッドからポートへのread/writeを行いたい場合にはqueue等を使ってスレッドAに対して要求を送り、実際のポートへのread/write操作はスレッドhoge内に記述することで排他制御や状態遷移の実装が容易になります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-02T02:12:16.103", "id": "18309", "last_activity_date": "2015-11-02T02:12:16.103", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12774", "parent_id": "17961", "post_type": "answer", "score": 1 } ]
17961
null
18309
{ "accepted_answer_id": null, "answer_count": 0, "body": "apacheのアクセスログをfluentdで収集して、s3に保存しRedShiftに蓄積したいのですが、 \nGETのクエリ文字列部分の取り出し方がわからず苦戦しております。(jsonにパースしたい)\n\n例) \n//hogehoge.co.jp/test.php?test_id=111&param=hoge\n\napacheのLogFormatで%qを指定し、\"?test_id=111&param=hoge\"までは取得できており、 \nfluentdではltsv形式にしているので、通常のログはjson化できています。 \n(現状、path:\"?test_id=111&param=hoge\"になっている)\n\nこれを、path:{\"test_id:111\",\"param\":\"hoge\"}のjsonの形にパースしたいのですが、やり方がわかりません。。。\n\nどなたかご教示いただけますと幸いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T02:52:17.310", "favorite_count": 0, "id": "17964", "last_activity_date": "2015-10-23T03:44:14.657", "last_edit_date": "2015-10-23T03:44:14.657", "last_editor_user_id": "5008", "owner_user_id": "12918", "post_type": "question", "score": 1, "tags": [ "json", "apache", "fluentd" ], "title": "ログ収集でGETのqueryパラメータを取得しjsonにパースする方法がわかりません、、", "view_count": 496 }
[]
17964
null
null
{ "accepted_answer_id": null, "answer_count": 3, "body": "とあるリモートリポジトリ(ここでは「Remote」とします)があり、Githubを用いてこれを僕とAさんで使っています。 \nしかし、僕とAさんのローカルリポジトリでのコミット履歴が異なっていて、これによってconflictが発生してしまいました。現在、このような状況です。 \n・僕のコミット履歴 \nコミットA \nコミットB \nコミットE \nコミットF\n\n・友人Aのコミット履歴 \nコミットC \nコミットD \nコミットE \nコミットF\n\n・Remoteの状態 \n僕がpushしたコミットAが反映されている(push -fを使用してしまいました)\n\nなお、コミットAはコミットCよりも新しいコミットで、 \nコミットBはコミットDよりも新しいコミットとします。\n\nここで、コミットCにはコミットAには無い変更点がありそれを反映させたいのですが \nコミットが干渉してしてしまいどうすれば良いのか困り果てている状況です。 \nrebaseも試みたのですが、上手くいきませんでした。\n\n僕と友人Aのコミットを結合(?)するにはどうすれば良いのでしょうか。 \nまた、コミットCの変更点を今のRemoteに反映させることは可能なのでしょうか。 \n分かりにくく乱雑な文章で申し訳ございませんが、 \nもし分かる方がいらっしゃいましたら回答宜しくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T02:52:54.217", "favorite_count": 0, "id": "17965", "last_activity_date": "2015-10-24T05:12:13.727", "last_edit_date": "2015-10-23T18:45:22.920", "last_editor_user_id": "76", "owner_user_id": "12919", "post_type": "question", "score": 1, "tags": [ "git" ], "title": "Gitでcommitがconflictしてしまった時の対処法", "view_count": 1650 }
[ { "body": "コンフリクトは自動的には解消できませんので人間の判断でマージする必要があります。\n\nあなたと、友人がそれぞれ別のブランチにプッシュして \n両者比較してあるべき姿に修正(手動でマージ)して \n問題なければ 本流のブランチにマージすればどうでしょう?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T04:27:42.627", "id": "17967", "last_activity_date": "2015-10-23T04:27:42.627", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "17965", "post_type": "answer", "score": 0 }, { "body": "GitHubの問題ではなくてGitの問題ですね。\n\nコンフリクトをどのように解決するかは、どのようなソースを完成させたいのかを考えて(必要であればプロジェクトメンバーと話し合って)解消します。\n\nどのファイルがどのようにコンフリクトしてどうしたいのかが質問にないとはっきりとしたことがいえませんが、少なくとも、`push\n-f`や`rebase`はコンフリクトでは余程のことがないと使用しないと思います。\n\n基本的には、 \nGitのオプションだと \n**\\--ours** \n**\\--theirs** \nなどを必要に応じて使います。\n\n以上のオプションが要件を満たさない場合は、直接ソースのファイルをエディタで編集するという方法が一般的です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T09:53:47.083", "id": "17986", "last_activity_date": "2015-10-24T05:12:13.727", "last_edit_date": "2015-10-24T05:12:13.727", "last_editor_user_id": "9008", "owner_user_id": "9008", "parent_id": "17965", "post_type": "answer", "score": -1 }, { "body": "具体例を示したほうがいいかと思いました。\n\nあなたも友人Aも、仮に master ブランチで開発していたとします。 \nまた、 remote のレポジトリは、 origin で設定されていたとします。\n\n友人A が次を行うとよいと思います。\n\n```\n\n git fetch\n git merge origin/master\n \n # コンフリクトが起きた場合は、 git status で何が unmerged かを確認し、\n # そのファイルのコンフリクトを修正する。\n # (ファイルのどこがコンフリクトかは、そのファイルを見ればすぐわかります)\n # 修正を行ったのち、そのファイルを git add する\n \n # コンフリクトが起きていた場合には、最終的にコミットが必要\n # コンフリクトが起きていなかったら、 git merge の時点で、\n # コミットが作成されているはず。\n git commit\n \n git push\n \n```\n\nこれにより、 ABEF と CDEF の歴史を統合したような(マージ)コミットが Remote に push されます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T17:44:47.350", "id": "17993", "last_activity_date": "2015-10-23T17:50:16.037", "last_edit_date": "2015-10-23T17:50:16.037", "last_editor_user_id": "754", "owner_user_id": "754", "parent_id": "17965", "post_type": "answer", "score": 1 } ]
17965
null
17993
{ "accepted_answer_id": "17970", "answer_count": 1, "body": "こんにちは。 \n質問です。よろしくお願いします。\n\n■環境 \nVisualStudio2012 C# Windowsフォームアプリケーション\n\n■やりたいこと \n30個くらいある全てのフォームで、「Enterキーが押されたらTabキーを押したときのように、 \n次のコントロールにフォーカスが遷移する」機能を、効率良く実装したい。\n\n■条件 \n各フォームにKeyDownイベントが存在する。\n\n■やってみたこと \n・基底クラスを作成し、「FrmBase_KeyDown()」を定義して、 \nそこでEnterキーが押されたかを判定して次のコントロールに遷移するよう実装し、 \n各フォームはこの基底クラスを継承した。\n\n・だいたいはうまくいった。\n\n・ところが、派生クラス側にKeyDown()イベントが存在する場合、 \n基底クラスのKeyDown()が先に呼ばれて次のコントロールに遷移してしまい、 \n派生クラスのKeyDown()イベントが呼ばれない。\n\n・先に派生クラスのKeyDown()イベント内の処理が動いてから、 \n次のコントロールに遷移したい。\n\nこういうとき、どのように実装するのが効率良いのでしょうか。 \n意見、参考サイト等、教えて頂けたら幸いです。\n\n```\n\n public class FrmBase : Form\n {\n private void FrmBase_KeyDown(object sender, KeyEventArgs e)\n {\n if (e.KeyCode == Keys.Enter)\n {\n // Enterキーが押されたら、次のコントロールにフォーカス移動\n this.SelectNextControl(this.ActiveControl, true, true, true, true);\n e.Handled = true;\n }\n }\n }\n \n public class FrmChild : FrmBase\n {\n private void TextBox1_KeyDown(object sender, KeyEventArgs e)\n {\n if (e.KeyCode == Keys.Enter)\n {\n // Enterキーが押されたら、ある処理をする\n } \n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T02:58:49.167", "favorite_count": 0, "id": "17966", "last_activity_date": "2015-10-23T06:02:11.920", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12916", "post_type": "question", "score": 0, "tags": [ "c#", "winforms" ], "title": "基底クラスのイベントよりも、派生クラスのイベントを先に処理したい", "view_count": 5968 }
[ { "body": "FrmBase_KeyDownメソッド中の、\n\n```\n\n e.Handled=true;\n \n```\n\nの部分を、\n\n```\n\n e.Handled=false;\n \n```\n\nにしてみてはいかがでしょうか?\n\n先に処理することはできませんが、 \nChild側のイベントも呼ばれます。\n\n前後順が重要な場合は、FrmChildそのもののKeyDownを先行させたければ、 \nOnKeyDownメソッドのoverrideで実現可能です。\n\nしかし、FrmChildに入れ子になっているコントロールのKeyDownを先行させたい場合は、イベントの前後順を変更できない以上、あまり綺麗ではありませんが、のFrmChild.OnKeyDownのオーバーライドしたメソッド内に、実装する必要があるでしょう。 \nただし、KeyPreviewがTrueである以上、目的のコントロール上でKeyDownが発生したか否かを別途確認する必要があるかと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T05:48:30.327", "id": "17970", "last_activity_date": "2015-10-23T06:02:11.920", "last_edit_date": "2015-10-23T06:02:11.920", "last_editor_user_id": "7287", "owner_user_id": "7287", "parent_id": "17966", "post_type": "answer", "score": 1 } ]
17966
17970
17970
{ "accepted_answer_id": null, "answer_count": 0, "body": "# 概要\n\nアクセスすると特定のソフトをダウンロードしてほしい旨がモーダルで表示されるサイトがあります。 \nそのモーダルを開発者ツールで見てみると\n\n```\n\n <div id=\"hoge\">\n <div id=\"hoge2\" title=\"close\"></div>\n <img>\n </div>\n \n```\n\nのような形でアクセス先のHTMLに追加されます。\n\nそのサイトに\n\n```\n\n WebBrowser.Navigate(new Uri(url),null, null,header);\n \n```\n\nのようなコードで画面に遷移後、スクリプトエラーが出る(WebBrowser.ScriptErrorsSuppressed =\ntrue;で消えはする)のとWebBrowserが持っているInnerHtmlを見てもモーダルのが追加されません。\n\nNew_Window2イベントを拾えるようにWebBrowserを拡張していますが、そちらにもモーダルのが追加されません。\n\nどうすればハンドルできるようになるでしょうか?\n\n※コントロールできるようになればHTMLからdivを消すかモーダル右上に表示されている「×」ボタンをクリックすれば消せるかもしれないと思っています。\n\n※WebBrowserからでなく、人がIEからアクセスして一度モーダルを消すと表示されなくなるので、一度表示した状態を作ってアクセスできればそもそもコントロールする必要もないのかもとも思っていますが方法がわかりません。\n\n# 動作環境\n\n・.NET Frame Work 4.5 \n・Visual Studio2013\n\n# 目的\n\n・モーダルの下にあるログインボタンをクリックして次のページに遷移したい。\n\nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T05:22:28.780", "favorite_count": 0, "id": "17969", "last_activity_date": "2019-06-06T23:47:46.057", "last_edit_date": "2019-06-06T23:47:46.057", "last_editor_user_id": "2238", "owner_user_id": "12459", "post_type": "question", "score": 0, "tags": [ "c#", "visual-studio" ], "title": "WebBrowserでアクセスしたサイトのモーダルを消すためにコントロールできるようにするにはどうしたらいいでしょう?", "view_count": 240 }
[]
17969
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "Rails側はAPIの提供(/api/articles/:id\nにて、articleの情報とそれに紐づくitemをjson形式でレンダリングしています)に専念させ、Angular側でjsonを受け取りserviceクラスのfactoryメソッドからデータのやりとりをしようとしています。こちらが現状のコードです。Angularのバージョンは1.4.7を採用しています。\n\n《service》\n\n```\n\n App.factory 'Article', ($resource, $http) ->\n class Article\n constructor: (errorHandler) ->\n @service = $resource('/api/articles/:id',\n { id: '@id' },\n { update: { method: 'PUT' }})\n @errorHandler = errorHandler\n \n find: (id, successHandler) ->\n @service.get(id: id, ((article)->\n successHandler?(article)\n article),\n @errorHandler)\n \n create: (attrs) ->\n new @service(article: attrs).$save()\n \n update: (article, attrs) ->\n new @service(article: attrs).$update {id: article.id}, (-> null), @errorHandler\n \n```\n\nこちらをcontrollerから呼び出し、createやupdateを呼んでいます。\n\n《controller》\n\n```\n\n @articleService = new Article(serverErrorHandler)\n @articleService.update($scope.article, title: article.title, description: article.description)\n \n```\n\nこちらをできればもう少しスマートに記述したいです。参考書やウェブの情報によると今回のようなアプリケーションでは、$httpサービスは基本的に用いずに$resourceサービスだけで実装するのが一般的と推奨されており、リファクタリングをしようとしているのですが、Angular内部のエラーに詰まり、うまく移行できません...\n\n```\n\n Error: [$resource:badcfg] http://errors.angularjs.org/1.4.0/$resource/badcfg?p0=query&p1=array&p2=object&p3=GET&p4=%2Fapi%2Farticles%2F13495\n \n```\n\n* * *\n\nできれば、下記のように(「[Rails+JSフレームワークでリアルタイム掲示板を作成してみる(AngularJS編)](http://www.ohmyenter.com/railsjs%E3%83%95%E3%83%AC%E3%83%BC%E3%83%A0%E3%83%AF%E3%83%BC%E3%82%AF%E3%81%A7%E3%83%AA%E3%82%A2%E3%83%AB%E3%82%BF%E3%82%A4%E3%83%A0%E6%8E%B2%E7%A4%BA%E6%9D%BF%E3%82%92%E4%BD%9C%E6%88%90%E3%81%97/)」を参考にしました)serviceクラスではAPIの受け取りだけに専念させシンプルに記述したいです。この方法がやはり推奨なのか、また、コードに良くない点やエラーの原因が見受けられましたら、どうかアドバイスをいただきたいです。読みにくいコードで申し訳ありませんがどうかよろしくお願いいたします。\n\n《service》\n\n```\n\n App.factory 'Article', ($resource) ->\n $resource '/api/articles/1'\n \n```\n\n《controller》\n\n```\n\n Article.query (article) ->\n $scope.article = articles\n \n $scope.create = ->\n article = Article.save($scope.Article)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T06:52:21.190", "favorite_count": 0, "id": "17972", "last_activity_date": "2015-10-23T08:37:01.480", "last_edit_date": "2015-10-23T08:37:01.480", "last_editor_user_id": "10441", "owner_user_id": "10441", "post_type": "question", "score": 3, "tags": [ "javascript", "angularjs", "coffeescript" ], "title": "Angularを採用したRailsアプリケーションで、$httpサービスを使わずに、factoryメソッドからCRUD操作をしたい", "view_count": 182 }
[]
17972
null
null
{ "accepted_answer_id": "17975", "answer_count": 1, "body": "フォントは一つの文字に一つの字形を割り当てていると思います。\n\nWebフォントにおいても例えばMaterial\nIconsでは、「」(`&#xE0C6;`)という文字に[吹き出しの中にクエスチョンマークが入った字形](https://www.google.com/design/icons/#ic_live_help)が割り当てられています。\n\n```\n\n <i class=\"material-icons\">&#xE0C6;</i>\n \n```\n\nとする事で(class=\"material-icons\" にMaterial Iconsフォントが設定されていれば)、この字形が表示されます。 \nしかし、この字形は「live_help」という文字列にも割り当てられているらしく、\n\n```\n\n <i class=\"material-icons\">live_help</i>\n \n```\n\nとする事でもこの字形が表示されます。 \n幅は一文字分で、完全に一文字のように見えます。\n\nこれはどういった仕組みなのでしょうか。\n\n```\n\n <link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\"\r\n rel=\"stylesheet\">\r\n \r\n <p>\r\n 「&#xE0C6;」 &rarr; <i class=\"material-icons\">&#xE0C6;</i>\r\n </p>\r\n \r\n <p>\r\n 「live_help」&rarr; <i class=\"material-icons\">live_help</i>\r\n </p>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T06:55:34.410", "favorite_count": 0, "id": "17974", "last_activity_date": "2015-10-23T07:22:01.947", "last_edit_date": "2015-10-23T07:02:53.193", "last_editor_user_id": "3054", "owner_user_id": "3054", "post_type": "question", "score": 8, "tags": [ "html", "css", "font" ], "title": "Webフォントで複数文字の文字列が、一文字分の字形で表示される仕組み", "view_count": 572 }
[ { "body": "[合字](https://ja.wikipedia.org/wiki/%E5%90%88%E5%AD%97)です。\n\nlive_helpという文字がアイコン1文字に見えるのは、live_helpの文字列の流れで1つの合字として表示させているからだと思います。 \nCSS3で`-webkit-font-feature-settings`に`liga`を指定しているのは、合字の機能を有効にするためです。(参考:\n[フォントの機能を使えるCSS3のFont feature settingsとは](http://www.riaxdnp.jp/?p=5094)) \n試しに`-webkit-font-feature-settings`をCSSからコメントアウトするとアイコンが表示されないのが確認出来ると思います。\n\n僕は詳しくないのでうまく説明できませんが、合字のフォントの作り方や仕組みについては以下のウェブサイトが参考になると思います。\n\n参考: [【完全版】Ligature Symbols フォントセットの自作方法 -\nくらげだらけ](http://kudakurage.hatenadiary.com/entry/20120720/1342749116)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T07:22:01.947", "id": "17975", "last_activity_date": "2015-10-23T07:22:01.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2599", "parent_id": "17974", "post_type": "answer", "score": 6 } ]
17974
17975
17975
{ "accepted_answer_id": "17981", "answer_count": 1, "body": "SORACOM BeamのHTTPエントリーポイントに設定するヘッダ付与の署名ヘッダ(`X-Soracom-\nSignature`)の検証仕様・アルゴリズムを教えてください。\n\nアプリケーションサーバにて、リクエストの正当性検証のためにIMSIの突き合わせとセットで利用したい次第です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T07:30:27.190", "favorite_count": 0, "id": "17976", "last_activity_date": "2015-10-23T08:23:58.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12845", "post_type": "question", "score": 0, "tags": [ "soracom" ], "title": "Beamの署名ヘッダ検証の仕様について", "view_count": 167 }
[ { "body": "ドキュメントに記載ができておらず、失礼いたしました。追記したいと思います。\n\n### 仕様\n\n現状のシグネチャ仕様としましては、下記のようになっております。\n\n事前共有鍵: topsecret \nIMSI: 440101111111111 \nTIMESTAMP: 1445587157992\n\nであった場合、\n\n```\n\n SHA256('topsecret'+'x-soracom-imsi=440101111111111x-soracom-timestamp=1445587157992')\n \n```\n\nのように計算されます。\n\n### 計算実行例\n\n```\n\n irb(main):001:0> require 'digest/sha2'\n => true\n irb(main):002:0> Digest::SHA256.hexdigest 'topsecret'+'x-soracom-imsi=440101111111111x-soracom-timestamp=1445587157992'\n => \"abb87746040d112848d5b331ccfbc70a9d663173d7e9f928ddab19d4626140d9\"\n \n```\n\n### 検証用サンプルコード(Ruby の Rack環境を想定)\n\n```\n\n def verify_signature(secret = 'topsecret')\n string_to_sign = request.env\n .select{|k,v| k=~/HTTP_X_SORACOM/ && !(k=~/HTTP_X_SORACOM_SIGNATURE/)}\n .map{|k,v| \"#{k.sub(/HTTP_/,'').gsub(/_/,'-').downcase()}=#{v}\"}\n .sort().join()\n calculated_signature = Digest::SHA256.hexdigest secret + string_to_sign\n result = (calculated_signature == env['HTTP_X_SORACOM_SIGNATURE'])\n \n```\n\n### 検証方法\n\nBeamの設定で <https://beamtest.soracom.io> に対して\nIMSIヘッダと署名ヘッダを付けて頂いて、<http://beam.soracom.io:8888> にアクセスしますと、署名検証の過程がご確認頂けます。 \n(beamtest.soracom.io は、事前共有鍵が topsecret である事を期待して動作します)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T08:23:58.113", "id": "17981", "last_activity_date": "2015-10-23T08:23:58.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12626", "parent_id": "17976", "post_type": "answer", "score": 1 } ]
17976
17981
17981
{ "accepted_answer_id": "18012", "answer_count": 2, "body": "ListViewに対して内部的に作成した配列をtextViewに入れて表示をさせているのですが、更なる疑問が上がってきたので質問させていただきます。簡潔に言うと、動的に複数のtextをListView上に配置したい、というものです。 \n前回の質問→[アンドロイドのListViewの背景について](https://ja.stackoverflow.com/questions/17845/%E3%82%A2%E3%83%B3%E3%83%89%E3%83%AD%E3%82%A4%E3%83%89%E3%81%AElistview%E3%81%AE%E8%83%8C%E6%99%AF%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6)\n\nAndroidSDKのsimple_list_item_multiple_choiceから自作したcustom_row.xmlを用いることにしました。 \n現状ArrayAdapter(context,int resource,int textViewResourceId,ArrayList)\nを用いており、第三引数にtextViewのIDを指定しています。その為、第三引数のtextViewのみが動的に動く形となっています。これを複数に増やしたいのですが、最も良い方法を探しております。自分の乏しい知識を駆使して調べたこと、考えたことを以下に箇条書きで記しておきます。\n\n・引数が一つしか取れないことが問題である。 \n→ArrayAdapter ではないAdapterを実装する必要がある?⇒SimpleAdapterも考えました。 \n→動的に配置したい配列を二次元配列にする⇒対応するtextViewに上手く入れることができない。 \n・HashMapを用いてkeyとvalueをタグ付けして持ってくる \n⇒並列するものが関連性の低いものなのでマップで関連付けするのはできれば避けたい。\n\nどうぞ、よろしくお願いします。 \n以下に作ったコードを記しておきます。\n\n```\n\n MainActivity.java\n \n public class MainActivity extends AppCompatActivity {\n \n final String[] baseArray ={\"ApplePie\", \"BananaBread\", \"CupCake\", \"Donut\", \"Eclair\", \"Froyo\",\n \"GingerBread\", \"Honeycomb\", \"IcecreamSandwich\",\"JellyBean\", \"KitKat\", \"Lollipop\", \"Marshmallow\", \"Nougat\", \"Oreo\", \"Popcorn\"};\n ListView list1;\n Button btn1;\n \n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);\n FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);\n fab.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View view) {Snackbar.make(view, \"Replace with your own action\",Snackbar.LENGTH_LONG)\n .setAction(\"Action\", null).show();\n }\n });\n \n findView();\n ArrayAdapter<String> adapter = new MyAdapter(getApplicationContext(),\n R.layout.custom_row,R.id.custom_row_textview2,baseArray);\n \n \n \n list1.setAdapter(adapter);\n list1.setScrollingCacheEnabled(true);\n \n }\n @Override\n public boolean onCreateOptionsMenu (Menu menu){\n // Inflate the menu; this adds items to the action bar if it is present.\n getMenuInflater().inflate(R.menu.menu_main, menu);\n return true;\n }\n \n @Override\n public boolean onOptionsItemSelected (MenuItem item){\n // Handle action bar item clicks here. The action bar will\n // automatically handle clicks on the Home/Up button, so long\n // as you specify a parent activity in AndroidManifest.xml.\n int id = item.getItemId();\n \n //noinspection SimplifiableIfStatement\n if (id == R.id.action_settings) {\n return true;\n }\n \n return super.onOptionsItemSelected(item);\n }\n \n public void findView() {\n \n btn1 = (Button) findViewById(R.id.button1);\n list1 = (ListView) findViewById(R.id.listView1);\n \n \n }\n }\n \n```\n\nMyAdapter.java\n\n```\n\n public class MyAdapter extends ArrayAdapter {\n public MyAdapter(Context context,int resource,int textViewResourceId,String[] objects){\n super(context,resource,textViewResourceId, objects);\n \n }\n @Override\n public View getView(int position, View convertView, ViewGroup parent) {\n View view = super.getView(position, convertView, parent);\n \n if (position % 2 == 0) {\n view.setBackgroundColor(Color.rgb(100, 100, 100));\n } else {\n view.setBackgroundColor(Color.rgb(170,170,170));\n }\n return view;\n }\n }\n \n```\n\ncustom_row.xml\n\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <LinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:orientation=\"horizontal\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:background=\"@drawable/list_item\">\n \n <CheckBox\n android:id=\"@+id/checkbox\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:clickable=\"true\"\n android:focusable=\"false\"\n />\n <TextView\n android:id=\"@+id/custom_row_textview1\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_weight=\"1\"\n android:textSize=\"18sp\"\n android:text=\"gender\"\n android:padding=\"8dp\"\n android:textColor=\"#ff0acc\"\n />\n <TextView\n android:id=\"@+id/custom_row_textview2\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_weight=\"1\"\n android:textSize=\"20sp\"\n android:padding=\"10dp\"\n android:textColor=\"#ff0022\"/>\n \n <TextView\n android:id=\"@+id/custom_row_textview3\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_weight=\"1\"\n android:padding=\"10dp\"\n android:textColor=\"#2050ff\"\n android:textSize=\"15sp\"\n android:text=\"phoneNumber\"/>\n \n </LinearLayout>\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T07:38:38.493", "favorite_count": 0, "id": "17977", "last_activity_date": "2015-10-27T03:18:29.197", "last_edit_date": "2017-04-13T12:52:39.113", "last_editor_user_id": "-1", "owner_user_id": "12789", "post_type": "question", "score": 1, "tags": [ "android", "java", "android-studio", "android-listfragment" ], "title": "ListViewのTextView動的獲得について", "view_count": 1549 }
[ { "body": "ArrayAdapter\nでは複数のテキストを使うには向かないので、SimpleAdapterを使うかBaseAdapterを直接継承してAdapterを作ることになるかと思います。\n\nSimpleAdapter の場合は、データをMap の List として渡す必要があり、またMapのキーは各ListItem\nごとに変えるといったことはできません。もしListItem 毎に異なるキーを使いたいとか、そもそもMapには入れたくないのであれば BaseAdapter\nを継承するのが良さそうに思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T03:35:01.330", "id": "18012", "last_activity_date": "2015-10-24T03:35:01.330", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "319", "parent_id": "17977", "post_type": "answer", "score": 0 }, { "body": "inflateしなおしてArrayAdapter継承という方法もあります。修正の程度にもよりますが、最低限getViewのオーバライドだけなので、最初のうちはやりやすいと思います。\n\n```\n\n class MyAdapter extends ArrayAdapter<String> {\n public MyAdapter(Context context) {\n super(context, R.layout.custom_row);\n }\n \n @Override\n public View getView(int position, View convertView, ViewGroup parent) {\n if (convertView == null) {\n LayoutInflater inflater = getLayoutInflater();\n convertView = inflater.inflate(R.layout.custom_row,\n null);\n }\n \n // ゴニョゴニョ...\n \n return convertView;\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T03:18:29.197", "id": "18108", "last_activity_date": "2015-10-27T03:18:29.197", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12988", "parent_id": "17977", "post_type": "answer", "score": 0 } ]
17977
18012
18012
{ "accepted_answer_id": "17987", "answer_count": 1, "body": "Web APIでのデータの送受信形式にJSONを使用し、リクエストのContent-\nTypeヘッダをapplication/jsonに指定する場合、RequestSpecで以下のように書いてます。\n\nしかし、この書き方だと`spec`ファイル毎に`let(:request_header)`の記入が必要なため、DRYじゃないし、面倒です。 \nこれをデフォルト設定にする、もしくは汎用的に書く方法を知っている方いたら教えて下さい。\n\n```\n\n describe 'Users' do\n \n let(:request_header) do\n { 'CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json' }\n end\n \n describe 'POST /api/v1/users' do\n it 'creates a new user' do\n params = FactoryGirl.attributes_for(:user)\n \n expect {\n post '/api/v1/users', params.to_json, request_header\n }.to change { User.count }.from(0).to(1)\n \n expect(response.status).to eq(201)\n end\n end\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T07:58:54.337", "favorite_count": 0, "id": "17979", "last_activity_date": "2015-10-26T05:52:41.053", "last_edit_date": "2015-10-26T05:52:41.053", "last_editor_user_id": "12927", "owner_user_id": "12927", "post_type": "question", "score": 2, "tags": [ "ruby-on-rails", "ruby", "rspec" ], "title": "RequestSpecでContent-Typeヘッダapplication/jsonをデフォルトにするには?", "view_count": 1304 }
[ { "body": "下記のissueでも同じような質問が挙げられていますが、完全な自動化は難しいようですね。\n\n[ability to add header on every request spec · Issue #1209 · rspec/rspec-\nrails](https://github.com/rspec/rspec-rails/issues/1209)\n\n僕だったら、ショートカット用のメソッドをモジュールとして定義し、request spec全体でincludeするかなーと思います。\n\n```\n\n # spec/support/api_macros.rb\n module ApiMacros\n def post_as_json(path, parameters = nil, headers_or_env = {})\n post path, parameters, headers_or_env.merge('CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json')\n end\n \n # 必要に応じてpost以外のバージョンも定義\n end\n \n # spec/rails_helper.rb\n Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }\n # ...\n RSpec.configure do |config|\n # ...\n config.include ApiMacros, type: :request\n end\n \n # spec/requests/users_spec.rb\n require 'rails_helper'\n describe 'Users', type: :request do\n describe 'POST /api/v1/users' do\n it 'creates a new user' do\n params = FactoryGirl.attributes_for(:user)\n \n expect {\n post_as_json '/api/v1/users', params.to_json\n }.to change { User.count }.from(0).to(1)\n \n expect(response.status).to eq(201)\n end\n end\n end\n \n```\n\n完全な自動化が無理な以上、落としどころはこんなところではないでしょうか。\n\n## 追記\n\nprependを使うともうちょっとスマートになるかもです。\n\n```\n\n # spec/support/api_macros.rb\n module ApiMacros\n def post(path, parameters = nil, headers_or_env = {})\n super path, parameters, headers_or_env.merge('CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json')\n end\n \n # 必要に応じてpost以外のバージョンも定義\n end\n \n # spec/rails_helper.rb\n Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }\n # ...\n RSpec.configure do |config|\n # ...\n config.prepend ApiMacros, type: :request\n end\n \n # spec/requests/users_spec.rb\n require 'rails_helper'\n describe 'Users', type: :request do\n describe 'POST /api/v1/users' do\n it 'creates a new user' do\n params = FactoryGirl.attributes_for(:user)\n \n expect {\n post '/api/v1/users', params.to_json\n }.to change { User.count }.from(0).to(1)\n \n expect(response.status).to eq(201)\n end\n end\n end\n \n```\n\n## 追記2\n\n`json: true`みたいなタグを付けて、jsonリクエストを使うかどうか制御するバージョンも作ってみました。\n\n```\n\n # spec/support/api_macros.rb\n module ApiMacros\n def post(path, parameters = nil, headers_or_env = {})\n headers_or_env = headers_or_env.merge('CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json') if @_json\n super path, parameters, headers_or_env\n end\n \n # 必要に応じてpost以外のバージョンも定義\n end\n \n # spec/rails_helper.rb\n Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }\n # ...\n RSpec.configure do |config|\n # ...\n config.prepend ApiMacros, type: :request\n \n config.before do |example|\n @_json = example.metadata[:type] == :request && example.metadata[:json]\n end\n end\n \n # spec/requests/users_spec.rb\n require 'rails_helper'\n \n # json: trueが付くと、jsonでリクエストを投げる\n describe 'Users', type: :request, json: true do\n describe 'POST /api/v1/users' do\n it 'creates a new user' do\n params = FactoryGirl.attributes_for(:user)\n \n expect {\n post '/api/v1/users', params.to_json\n }.to change { User.count }.from(0).to(1)\n \n expect(response.status).to eq(201)\n end\n end\n end\n \n```\n\n## 追記3\n\ngetやdeleteなど、post以外のメソッドも自動的にJSONでリクエストできる仕組みを考えてみました。 \nちょっと強引ですが、 ActionDispatch::Integration::Session#process と\nActionDispatch::Integration::Runner#reset! にモンキーパッチを当てています。 \n追記2と同様、spec側では `json: true` のタグでJSONリクエストを使うかどうか制御できます。\n\n```\n\n # spec/support/json_process.rb\n module JsonProcess\n def process(method, path, parameters = nil, headers_or_env = nil)\n headers_or_env = (headers_or_env || {}).merge('CONTENT_TYPE' => 'application/json', 'ACCEPT' => 'application/json') if @_json\n super method, path, parameters, headers_or_env\n end\n end\n \n # spec/rails_helper.rb\n Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }\n # ...\n RSpec.configure do |config|\n # ...\n config.before(:example, :json => true) do\n def reset!\n @integration_session = ActionDispatch::Integration::Session.new(app)\n @integration_session.instance_variable_set(\"@_json\", true)\n end\n end\n end\n ActionDispatch::Integration::Session.prepend JsonProcess\n \n # spec/requests/users_spec.rb\n require 'rails_helper'\n \n # json: trueが付くと、jsonでリクエストを投げる\n describe 'Users', type: :request, json: true do\n describe 'POST /api/v1/users' do\n it 'creates a new user' do\n params = FactoryGirl.attributes_for(:user)\n \n expect {\n post '/api/v1/users', params.to_json\n }.to change { User.count }.from(0).to(1)\n \n expect(response.status).to eq(201)\n end\n end\n end\n \n```\n\n動作確認時のバージョン\n\n * Rails 4.2.4\n * rspec-rails 3.3.3", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T10:21:12.090", "id": "17987", "last_activity_date": "2015-10-23T23:33:49.530", "last_edit_date": "2015-10-23T23:33:49.530", "last_editor_user_id": "85", "owner_user_id": "85", "parent_id": "17979", "post_type": "answer", "score": 2 } ]
17979
17987
17987
{ "accepted_answer_id": "18077", "answer_count": 1, "body": "Jqueryと[Handsontable](http://handsontable.com/)を使用したjsファイルをbrowserfiyとbrowserify-\nshimを使ってモジュール化しようとしています。 \n一応コマンドで`browserify app.js -d -o src/bundle.js`と打ってもエラーは出ないのですが、 \nブラウザで確認した時に\n\n```\n\n Uncaught Error: Cannot find module 'shims/classes'\n \n```\n\nとエラーが出てしまいテーブルが表示されない状態になります。 \nどなたか解決方法をご存じの方はいらっしゃいませんか?\n\nOSはOSX Yosemite\n\nライブラリのバージョン\n\n * browserify: 11.1.0 \n * browserify-shim: 3.8.10\n * jQuery: 2.1.4\n * Handsontable: 0.19.0\n\nソースコードですが\n\nhandsontable.html\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <title>Handsontable</title>\n <link rel=\"stylesheet\" href=\"../handsontable.full.css\" />\n </head>\n <body>\n <div id=\"example\"> </div>\n <script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-2.1.4.min.js\"></script>\n <script type=\"text/javascript\" src=\"bundle.js\"></script>\n </body>\n </html>\n \n```\n\napp.js\n\n```\n\n var $container;\n var data;\n require('Handsontable');\n \n data = [['Column A', 'Column B', 'Column C'], ['1', '2', '3']];\n \n $container = $('example');\n $container.handsontable({\n data: data\n });\n \n```\n\npackage.jsonのbrowserifyの設定\n\n```\n\n \"browserify\": {\n \"transform\": [\n \"browserify-shim\"\n ]\n },\n \"browser\": {\n \"Handsontable\": \"./src/vendor/handsontable.full.js\"\n },\n \"browserify-shim\": {\n \"jquery\": \"global:$\",\n \"Handsontable\": { \"exports\":\"Handsontable\", \"depends\": [ \"jquery\" ] }\n }\n \n```\n\n以上よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T09:00:51.070", "favorite_count": 0, "id": "17983", "last_activity_date": "2015-10-26T04:01:36.760", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12795", "post_type": "question", "score": 1, "tags": [ "javascript", "jquery", "browserify" ], "title": "browserfiy-shimでJqueryとHandsontableをbundleしたときに、ブラウザでUncaught Error: Cannot find module 'shims/classes'とエラーが出る", "view_count": 325 }
[ { "body": "自己解決しました。 \n対応としては、Handsontableをhtml側から読み込むようにし、package.jsonのbrowserifyの設定を\n\n```\n\n \"browserify\": {\n \"transform\": [\n \"browserify-shim\"\n ]\n },\n \"browserify-shim\": {\n \"jquery\": \"global:$\",\n \"handsontable\": \"global:handsontable\"\n }\n \n```\n\n上記のようにすることで動きました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T04:01:36.760", "id": "18077", "last_activity_date": "2015-10-26T04:01:36.760", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12795", "parent_id": "17983", "post_type": "answer", "score": 0 } ]
17983
18077
18077
{ "accepted_answer_id": null, "answer_count": 0, "body": "```\n\n value of optional type 'String?' not unwrapped; did you mean to use '!' or '?'?\n \n```\n\nというSwiftのOptional型に関してのエラーが生じました。\n\nOptional Value(「?」「!」が付随したコードで、「nil」を許容したコードか「nil」wo \n許容しないコードのいずれかを明示する)にする必要があるのはわかったのですが、具体的に\n\n```\n\n let text = searchBar.text.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())\n \n```\n\nのコードのどこに対して行えば良いのかがわからないため質問致します。\n\n以下コードなります。\n\n```\n\n import UIKit\n \n class ListViewController: UITableViewController {\n \n @IBOutlet weak var searchBar: UISearchBar!\n \n private var results: [NSDictionary]?\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n // Uncomment the following line to preserve selection between presentations\n // self.clearsSelectionOnViewWillAppear = false\n \n // Uncomment the following line to display an Edit button in the navigation bar for this view controller.\n // self.navigationItem.rightBarButtonItem = self.editButtonItem()\n }\n \n \n //中略\n \n \n extension ListViewController: UISearchBarDelegate {\n \n // searchBarのSearchボタンをタップしたときの処理\n func searchBarSearchButtonClicked(searchBar: UISearchBar) {\n searchBar.resignFirstResponder() // キーボードを閉じる\n \n // エラーはここから\n let text = searchBar.text.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())\n //ここまでです。\n if let text = text {\n AFHTTPSessionManager().GET(\n \"https://itunes.apple.com/search?term=\\(text)&country=JP&lang=ja_jp&media=music\",\n parameters: nil,\n success: { (task: NSURLSessionDataTask!, response: AnyObject!) -> Void in\n if let data = response as? NSDictionary, results = data[\"results\"] as? [NSDictionary] {\n self.results = results\n self.tableView.reloadData() // 再描画\n }\n },\n failure: nil)\n }\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T09:29:43.810", "favorite_count": 0, "id": "17984", "last_activity_date": "2015-10-23T09:29:43.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10491", "post_type": "question", "score": 1, "tags": [ "swift" ], "title": "value of optional type 'String?'の対処法に関して", "view_count": 548 }
[]
17984
null
null
{ "accepted_answer_id": "18123", "answer_count": 1, "body": "お世話になっております。 \nこのたびアプリをアップデートしようとしたのですが \n下記のエラーが赤字で発生しアップロードすることができません。\n\n```\n\n The u option must have a non-empty value\n The password option must have a non-empty value\n \n```\n\n昨日から発生しているので困っております。 \nどのように対処すればよろしいでしょうか? \nよろしくお願いいたします。\n\n環境 \nOS X El Capitan(10.11) \nXcode(7.0.1) \nApplication Loader(3.2) \n\n* * *\n\n \n**追記** \n今回申請しようとしているものはMonacaを使用してビルドしております。 \nリリース用のZIPファイルになっているものなのでXcodeから直接アップロードは考えておりません。 \n`Organizer`を使用してではなく`Application Loader`を使用してアップロード申請を行いたいです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T09:38:49.217", "favorite_count": 0, "id": "17985", "last_activity_date": "2015-10-27T07:02:26.110", "last_edit_date": "2015-10-27T06:31:49.960", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "ios", "monaca", "xcode", "macos" ], "title": "iOSの申請でエラー。[The u option must have a non-empty value]", "view_count": 427 }
[ { "body": "Appleのカスタマーサポートとやり取りしながら検証していたのですが、 \nその際に`Application Loaderのバージョン`に思い至りダウングレードしました。 \n[Application Loader\n3.0](https://itunesconnect.apple.com/apploader/ApplicationLoader_3.0.dmg)を使用してアップロードしたところすんなりアップロードが出来ました。 \n新しい3.2のApplicationLoaderだと何かしらの問題があるのかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T07:02:26.110", "id": "18123", "last_activity_date": "2015-10-27T07:02:26.110", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "17985", "post_type": "answer", "score": 0 } ]
17985
18123
18123
{ "accepted_answer_id": "17992", "answer_count": 1, "body": "SORACOMの[List Subscribers API\nリファレンス](https://dev.soracom.io/jp/docs/api/#!/Subscriber/list_subscribers)にてParamtersのstatus_filterおよびspeed_class_filterについて、それぞれ「指定可能な値の一覧はこちら」と記載されていますがリンクがないようです。\n\nこれらに指定可能な値の一覧が記載されている画面をご存じの方はいらっしゃいますでしょうか。\n\nおそらくResponse Bodyの該当する値と同じものだと思いますが、Responseに取りうる値の記載もないようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T11:21:30.137", "favorite_count": 0, "id": "17989", "last_activity_date": "2015-10-23T14:25:05.067", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12931", "post_type": "question", "score": 0, "tags": [ "soracom" ], "title": "List Subscribers APIのパラメーターについて", "view_count": 100 }
[ { "body": "API リファレンスを更新して、設定可能な値のリストを追記させていただきました。\n\nstatus_filter には `active` `inactive` `ready` `instock` `shipped` `suspended`\n`terminated` のいずれかの文字列、もしくはそれらのうち複数の文字列を `|` で接続して指定することができます。 \n(例: 'active|inactive|ready')\n\nspeed_class_filter には現時点では `s1.minimum` `s1.slow` `s1.standard` `s1.fast`\nのいずれかの文字列、もしくはそれらのうち複数の文字列を `|` で接続して指定することができます。 \n(例: 's1.standard|s1.fast')", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T14:25:05.067", "id": "17992", "last_activity_date": "2015-10-23T14:25:05.067", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12626", "parent_id": "17989", "post_type": "answer", "score": 0 } ]
17989
17992
17992
{ "accepted_answer_id": "18106", "answer_count": 1, "body": "API呼び出しにおいて、エラーが戻ってくることがあります。例えばパラメーターに指定したIMSIが間違っていた時には下記のようなエラーコードおよびエラーメッセージが戻ってくるかと思います。\n\n```\n\n {\"code\":\"SEM0001\",\"message\":\"No such resource found\"}\n \n```\n\nこれらのエラーコードおよび原因(メッセージ)の一覧はどこかに記載されていますでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T11:26:38.793", "favorite_count": 0, "id": "17990", "last_activity_date": "2015-10-27T02:55:53.823", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12931", "post_type": "question", "score": 0, "tags": [ "soracom" ], "title": "SORACOM APIレスポンスのエラー一覧について", "view_count": 198 }
[ { "body": "ご質問ありがとうございます。 \nエラーコードに関しては、3桁のコンポーネント文字列(SEMなど)と4桁の数値で構成しており、messageにはエラー内容が記載されております。messageに関しては、デフォルトでは英語文字を返しますが、リクエストヘッダーにX-\nSoracom-Lang:jaといれていただきますと、日本語対応文字がある場合は、日本語で内容を返します。\n\nエラーコードの一覧に関しては、現在ドキュメントを作成しておりますので、お待ち頂ければと思います。 \nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T02:55:53.823", "id": "18106", "last_activity_date": "2015-10-27T02:55:53.823", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12626", "parent_id": "17990", "post_type": "answer", "score": 1 } ]
17990
18106
18106
{ "accepted_answer_id": "18000", "answer_count": 4, "body": "```\n\n $ cat ~/tmp/test.txt\n banana 100 abc\n apple 200 xyz\n \n $ for i in `cat ~/tmp/test.txt`;do echo $i;done\n banana\n 100\n abc\n apple\n 200\n xyz\n \n $export IFS=\"\\n\"\n $for i in `cat ~/tmp/test.txt`;do echo $i; done\n ba\n a\n a 100 abc\n apple 200 xyz\n \n```\n\nタブ区切りのレコードを1行単位で取り出して処理したいのですが、見ての通りシェルのフィールドセパレータを`\"\\n\"`とするだけでは文字の`\"n\"`も区切り文字となってしまいます。 \n意図通りに改行のみで区切るにはどうしたらいいのでしょうか。 \n上記は`ubuntu\n15.04`で動作させたため`bash`を使ってますが、できればOS間で共通に動作するシェルスクリプトに応用したいので、`/bin/sh`でも扱える方法が分ると嬉しいです。\n\n利用環境: \nubuntu 15.04 \nfreebsd 10.2-stable \ncentos 6.7", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-23T22:36:14.923", "favorite_count": 0, "id": "17999", "last_activity_date": "2015-10-24T17:07:27.440", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9403", "post_type": "question", "score": 5, "tags": [ "sh", "shellscript" ], "title": "IFSに改行のみを指定したい", "view_count": 14182 }
[ { "body": "for ループで処理するのであれば、\n\n```\n\n $ IFS='\n '\n $ for i in `cat ~/tmp/test.txt`;do printf '%s\\n' \"$i\"; done\n \n```\n\nとします。`IFS` に改行(0x0a)を指定するには改行をそのままの形で入力します。なお、`bash` や `zsh` であれば `$'\\n'`\nといった記法が使用できます。\n\nここで、`echo` ではなく、`printf` を使う様に変更したのは理由があります。Debian 系 Linux の `/bin/sh`(実体は\n`/bin/dash`)に限らず、以下の様な問題があるからです。\n\n**test.txt**\n\n```\n\n banana \\100 abc\n -n\n apple 200 xyz\n \n```\n\n**echo による処理**\n\n```\n\n $ IFS='\n '\n $ for i in `cat ~/tmp/test.txt`;do echo \"$i\"; done\n banana \\100 abc\n apple 200 xyz\n \n```\n\n2行目の `-n` が抜け落ちてしまいました。これは、\n\n```\n\n echo \"$i\" => echo \"-n\" => echo -n\n \n```\n\nと解釈されたためです。`printf`(`bash/zsh/dash` では shell builtin\nfunction)の場合はこの様な問題は発生しません。\n\n※ 以下は削除 \n~~ \nただ、一部の sh ではバックスラッシュ文字が問題になります(例えば Ubuntu Linux の`/bin/sh`(実体は `/bin/dash`)。\n\n**test.txt**\n\n```\n\n banana \\100 abc\n apple 200 xyz\n \n```\n\n**/bin/dash on Ubuntu Linux**\n\n```\n\n $ IFS='\n '\n $ for i in `cat ~/tmp/test.txt`;do echo \"$i\"; done\n \n banana @ abc\n apple 200 xyz\n \n```\n\n**追記**\n\nTatz Sekine さんからのコメントで、`/bin/echo` を使うとバックスラッシュ文字はそのまま出力できます(`echo` は `builtin\nfunction`)。\n\n```\n\n $ IFS='\n '\n $ for i in `cat ~/tmp/test.txt`;do /bin/echo \"$i\"; done\n \n banana \\100 abc\n apple 200 xyz\n \n```\n\nなお、`dash` の `printf`(builtin function)ではバックスラッシュ文字の問題はありません。\n\n```\n\n printf '%s\\n' \"$i\"\n \n```\n\n~~", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T00:04:33.077", "id": "18000", "last_activity_date": "2015-10-24T17:07:27.440", "last_edit_date": "2015-10-24T17:07:27.440", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "17999", "post_type": "answer", "score": 2 }, { "body": "IFS='^M'\n\n^M = Ctrl+Vを押してからEnterKey \nとしてはダメですか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T00:11:52.640", "id": "18001", "last_activity_date": "2015-10-24T00:11:52.640", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12936", "parent_id": "17999", "post_type": "answer", "score": -1 }, { "body": "「IFSに改行のみを指定したい」への直接の回答ではないですが、もし入力が tsv なら\n\n```\n\n IFS=' \n ' # TAB (^I) と改行 $'\\t\\n'\n while read -r item price comment; do\n /bin/echo \"$item\" \"$price\" \"$comment\"\n done < ~/tmp/test.txt\n \n```\n\nという形で書いておけば、カラムごとにパースするのに IFS を戻す必要がありません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T00:39:42.270", "id": "18002", "last_activity_date": "2015-10-24T00:39:42.270", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2521", "parent_id": "17999", "post_type": "answer", "score": 1 }, { "body": "1行単位で処理するのであれば、for ではなく while と read を使った方がいいと思います。\n\n```\n\n (1行を変数に)\n export IFS=$(echo -en '\\t')\n while read -r line ; do echo \"$line\" ; done < test.txt\n \n (カラムごと変数に:その1)\n export IFS=$(echo -en '\\t')\n while read -r a b c others ; do echo \"$a\" ; echo \"$b\" ; echo \"$c\" ; done < test.txt\n \n (カラムごと変数に:その2)\n export IFS=$(echo -en '\\t')\n while read -r -a arg ; do echo \"${arg[0]}\" ; echo \"${arg[1]}\" ; echo ${arg[2]}\"; done < test.txt\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T00:53:07.963", "id": "18003", "last_activity_date": "2015-10-24T15:15:38.210", "last_edit_date": "2015-10-24T15:15:38.210", "last_editor_user_id": "4603", "owner_user_id": "4603", "parent_id": "17999", "post_type": "answer", "score": 1 } ]
17999
18000
18000
{ "accepted_answer_id": null, "answer_count": 1, "body": "Meteor 1.1で開発したパッケージで当時はテストが通っていたのですが、Meteor 1.2にアップデートしたところテストが通らなくなってしまいました。\n\n```\n\n meteor test-packages --release 1.1 ./\n \n```\n\nでは問題ないのですが、\n\n```\n\n meteor test-packages --release 1.2 ./\n \n```\n\nではエラーがでます。エラーメッセージは、\n\n```\n\n exception - message Template is not defined\n \n```\n\nです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T00:55:06.763", "favorite_count": 0, "id": "18004", "last_activity_date": "2016-04-21T04:20:36.457", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12937", "post_type": "question", "score": 0, "tags": [ "meteor" ], "title": "Meteor 1.2でのtest-packagesでエラー", "view_count": 39 }
[ { "body": "解決しました。\n\nMeteor 1.2の変更点に\n\n```\n\n test-packages no longer includes any packages globally (no changes needed)\n \n```\n\nがあるのですが、これが影響していました。\n\npackage.jsの`Package.onTest()`に\n\n```\n\n api.use('templating');\n \n```\n\nを追記したところ正常になりました。\n\n`Package.onUse()`には同じものが書いてあるのでをそれが引き継がれていると思っていたのですが、そういうものではなかったようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T01:10:00.867", "id": "18005", "last_activity_date": "2015-10-24T01:10:00.867", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12937", "parent_id": "18004", "post_type": "answer", "score": 1 } ]
18004
null
18005
{ "accepted_answer_id": "18009", "answer_count": 3, "body": "JavaのArrayListでは、「初期化時に確保するサイズを指定する」「ArrayList#ensureCapacityを使う」ことで、あらかじめ領域を確保できますよね?\n\n```\n\n ArrayList<Integer> hoge = new ArrayList<Integer>(100); //確保1\n hoge.ensureCapacity(100); //確保2\n \n```\n\nしかしどちらの書き方でも、C++でのstd::vectorにおけるreserve()のように「領域を確保する」だけであって、resize()のように「要素数が増える」わけじゃありませんよね。つまり、ArrayList#addで後ろに要素を追加はできるものの、ArrayList#setで特定位置に値を代入しようとするとIndexOutOfBoundsExceptionが生じてしまうのです。 \n現在ではArrayList#addとforループでとりあえず全要素に0を敷き詰めて対処していますが、もっと綺麗に書く方法は無いものでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T02:01:04.067", "favorite_count": 0, "id": "18006", "last_activity_date": "2015-10-28T16:18:10.390", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12939", "post_type": "question", "score": 6, "tags": [ "java", "arraylist" ], "title": "JavaのArrayListでの領域確保方法について", "view_count": 3425 }
[ { "body": "```\n\n List<Integer> l = Collections.nCopies(5, 123) // 123,123,123,123,123\n ArrayList<Integer> al = new ArrayList(l); // もしArrayListが良ければ\n \n```\n\n<http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#nCopies(int,%20T)>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T02:15:37.907", "id": "18007", "last_activity_date": "2015-10-24T02:15:37.907", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12940", "parent_id": "18006", "post_type": "answer", "score": 2 }, { "body": "`tai2` さんの回答と同じ事をしていますが、以下の様にも書けます。\n\n```\n\n ArrayList<Integer> hoge = new ArrayList<Integer>(Arrays.asList(new Integer[100]));\n \n```\n\nただ、`nCopies` と異なって初期化はされません。\n\n```\n\n hoge.set(0, 0);\n System.out.println(hoge);\n =>\n [0, null, null, ...\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T02:52:15.443", "id": "18009", "last_activity_date": "2015-10-24T02:52:15.443", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "18006", "post_type": "answer", "score": 1 }, { "body": "Stream が使える場合は、以下のように書けます。\n\n```\n\n List<Integer> list = Stream.generate(() -> 0).limit(100).collect(Collectors.toList());\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T16:18:10.390", "id": "18182", "last_activity_date": "2015-10-28T16:18:10.390", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12985", "parent_id": "18006", "post_type": "answer", "score": 1 } ]
18006
18009
18007
{ "accepted_answer_id": null, "answer_count": 1, "body": "Ruby言語の質問になります。 \nソースは以下になります。\n\n```\n\n x = [\"abc\",\"dejgk\",\"loqp\"]\n p x.sort{|a,b|a<=>b} #①処理\n p x.sort{|a,b|b<=>a} #②処理\n # [\"abc\", \"dejgk\", \"loqp\"]\n # [\"loqp\", \"dejgk\", \"abc\"]\n \n```\n\n<=>演算子の評価によって、sortメソッドはどのように処理をするのでしょうか。 \n私が考えている処理は以下になるのですが、実行結果と一致せず、 \n正しい処理が分かりません。\n\n①処理について \n\"abc\"<=>\"deigk\" 評価 -1 \"abc\"を配列[0]に格納。\"deigk\"を配列[1]に格納 \n\"deigk\"<=>\"loqp\" 評価 -1 \"deigk\"を配列[1]に格納。\"loqp\"を配列[2]に格納。 \n# [\"abc\", \"dejgk\", \"loqp\"]\n\n②処理について \n\"deigk\"<=>\"abc\" 評価 1 \"abc\" を配列[1]に格納。\"deigk\"を配列[0]に格納。 \n\"loqp\"<=>\"abc\" 評価 1 \"abc\"を配列[2]に格納。\"loqp\"を配列[1]に格納。 \n#[\"deigk\", \"loqp\", \"abc\"]\n\n質問初投稿のため至らない点があるかもしれませんがお願いいたします。\n\n以上です。 \nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T02:25:04.203", "favorite_count": 0, "id": "18008", "last_activity_date": "2015-10-24T03:13:32.643", "last_edit_date": "2015-10-24T02:30:30.357", "last_editor_user_id": "12912", "owner_user_id": "12912", "post_type": "question", "score": 1, "tags": [ "ruby" ], "title": "sortメソッドの処理が分かりません", "view_count": 419 }
[ { "body": "`Array#sort` は配列の要素をブロックで指定された評価規則にしたがって並べ替えるものです。 \n必ずしも配列の先頭から順番に比較が行われるわけではありません。今回の例では、手元で試したところ次のような順で比較が行われていました。\n\n① `\"dejgk\"<=>\"loqp\"`, `\"abc\"<=>\"dejgk\"` \n② `\"dejgk\"<=>\"loqp\"`, `\"abc\"<=>\"loqp\"`, `\"abc\"<=>\"dejgk\"`\n\n利用者は普通は sort メソッドの内部の並び替えのアルゴリズムについて知る必要はないです。 \n`Array#sort` で用いられているソートのアルゴリズムはクイックソートと呼ばれるものだと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T03:13:32.643", "id": "18011", "last_activity_date": "2015-10-24T03:13:32.643", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3249", "parent_id": "18008", "post_type": "answer", "score": 2 } ]
18008
null
18011
{ "accepted_answer_id": "18049", "answer_count": 1, "body": "下記のコードにて、APIの検索結果内容として[trackName]と[artistName]を記述したのですが、「as?\nString」のコード記述で「error: 'xxx' has no member named\n'yyy'」オブジェクトxxxのはyyyのというメンバーが存在しないというエラーが生じます。\n\n仮定\n\nasを用いた記述が現在の仕様と合致していないことが問題だと考えています。 \ngoogleで探してみたのですが、正しい仕様を見つけることができないため質問致します。\n\n```\n\n override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {\n let cell = tableView.dequeueReusableCellWithIdentifier(\"cell\", forIndexPath: indexPath) as! ListCell\n if let result = results?[indexPath.row] {\n if let artworkUrl = result[\"artworkUrl100\"] as? String {\n cell.artworkImageView.setImageWithURL(NSURL(string: artworkUrl))\n } else {\n cell.artworkImageView.image = nil\n }//ここから\n cell.trackLabel.text = result[\"trackName\"] as? String\n cell.artistLabel.text = result[\"artistName\"] as? String\n } //ここまででエラーが生じています。\n return cell\n }\n \n```", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T04:27:59.040", "favorite_count": 0, "id": "18014", "last_activity_date": "2015-10-25T06:40:17.980", "last_edit_date": "2015-10-25T06:40:17.980", "last_editor_user_id": "5337", "owner_user_id": "10491", "post_type": "question", "score": -1, "tags": [ "swift" ], "title": "TableViewCellの取得にて、error: 'xxx' has no member named 'yyy'エラー", "view_count": 2678 }
[ { "body": "artistNameをcustomクラスに設定していたのですが、正しく設定されていないためにエラーが生じていました。\n\n再度設定しなおしたらエラーが無くなりました。\n\n* * *\n\n_質問より転記_", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T06:39:35.463", "id": "18049", "last_activity_date": "2015-10-25T06:39:35.463", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5337", "parent_id": "18014", "post_type": "answer", "score": 0 } ]
18014
18049
18049
{ "accepted_answer_id": "18098", "answer_count": 2, "body": "現在WordpressをEC2とS3を合併して画像サイトを運営しているのですが、CloudFrontというのを使ったほうが良いのでしょうか? \n調べるとCDNはただ単に高速表示させるということなのですが、転送量が多ければ料金が高いということです。\n\nGETリクエスト数 平均ファイルサイズ データ転送量 転送料金 リクエスト料金 合計料金 \n3千万(100万/日) 100KB 2.8TB $574 .86 $11 .10 $585 .96 \nQiita <http://qiita.com/kawaz/items/07d67a851fd49c1c183e>\n\nWEBサイトを高速に表示させるのは当然大事なことですが、それだけで月額6万円もします。 \nS3とEC2だけでもさほど遅いとは感じないのですが、どこを調べてもCloudFrontを使ったやり方が書いてあるので、使ったほうが良いかと思いました。\n\n6万円払う価値があるほどの高速になるのでしょうか?\n\nまた、GETリクエスト数というのはそのサイトのPVではなく、一枚のファイルのアクセス数ですよね?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T07:42:51.240", "favorite_count": 0, "id": "18015", "last_activity_date": "2017-06-19T05:10:44.333", "last_edit_date": "2017-06-19T05:10:44.333", "last_editor_user_id": "5793", "owner_user_id": "7973", "post_type": "question", "score": 0, "tags": [ "aws", "amazon-s3" ], "title": "AWS EC2 S3 CloudFrontについて", "view_count": 2047 }
[ { "body": "CloudFrontの利用はメリットが多いですが、コンテンツをキャッシュしますので、構築されるWebサイトで問題が無いか十分確認された方が良いと思います。キャッシュされると不都合がある場合は、コンテンツ側でキャッシュヘッダを変更するか、CloudFront側で設定変更が必要です。\n\nその上で、CloudFrontはトータルで見るとそんなに高くないです。 \nコストはサービス単位ではなくAWS利用量全体を比較して考える必要があると思います。\n\n「CloudFront ->\nS3/EC2など」のトラフィック課金は1,2年前から無料になっています。ですので、2.8TBのデータ転送量に対する課金がCloudFrontに付くか、S3/EC2に付くか変わるだけで全体コストの違いは無いです。(全てのリージョンで確認していませんが、S3/EC2の東京リージョンとCloudFrontの日本では転送料単価も同じです。)\n\nリクエスト課金はキャッシュヒット率で変わります。極端な例でキャッシュヒット率0だとCloudFrontでもS3でも課金されるので、計算された方が良いですが、小規模なサイトだと大きな額にはならないです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T23:28:44.047", "id": "18098", "last_activity_date": "2015-10-26T23:28:44.047", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5959", "parent_id": "18015", "post_type": "answer", "score": 1 }, { "body": "「6万円払う価値があるほどの高速になるのでしょうか?」というのは主観的な質問で貴方にしか分かりません…。\n\nただ、その計算の価格は変更されてるのでもう少し安いです。 \n[Simple Monthly Calculator](http://calculator.s3.amazonaws.com/index.html)\nで計算したら $419.67 でした。(東京リージョン)\n\nまた、「転送量が多ければ料金が高い」というのは CloudFront に限らず S3 / EC2 どちらも 転送量に対して料金が発生します。\n\n仮に CloudFrontを使わず全て S3 からの インターネットへの送信するという場合、2.8TB、GETリクエストが3千万 で計算すると\n$410.40 でしたので CloudFrontが特別高い印象はありません。\n\nただ、独自ドメインでSSLを使う場合は注意が必要です。専用IP独自SSLは $600/月\nなので割高感があります。SNI独自SSLであれば別途料金はかかりませんが古いブラウザは対応していないようでアクセスできなくなります。\n\nあとは[CDP](http://aws.clouddesignpattern.org/index.php/%E3%82%AB%E3%83%86%E3%82%B4%E3%83%AA:CDP:%E9%9D%99%E7%9A%84%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84%E3%82%92%E5%87%A6%E7%90%86%E3%81%99%E3%82%8B%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3)\nなどを参考にしてCloudFrontに魅力を感じれば使えば良いのではと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T04:31:46.280", "id": "18112", "last_activity_date": "2015-10-27T04:31:46.280", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "18015", "post_type": "answer", "score": 1 } ]
18015
18098
18098
{ "accepted_answer_id": null, "answer_count": 1, "body": "変数\n\n```\n\n int f=0;\n \n```\n\nと置いたとして、\n\n```\n\n 2*f\n \n```\n\nと\n\n```\n\n 2f\n \n```\n\nの違いを教えていただきたいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T07:54:26.280", "favorite_count": 0, "id": "18016", "last_activity_date": "2015-11-23T12:50:19.877", "last_edit_date": "2015-10-24T12:49:42.757", "last_editor_user_id": "7290", "owner_user_id": "12818", "post_type": "question", "score": 0, "tags": [ "processing" ], "title": "数値の表記について", "view_count": 411 }
[ { "body": "```\n\n 2 * f\n \n```\n\nこれは`2`掛ける変数`f`の値(0)を意味し、実質 2×0 = 0 となります。\n\n```\n\n 2f\n \n```\n\nこちらの`f`は Java のリテラル表現で`float`(浮動小数点)を示すトークンです(変数の`f`とは関わりがありません)。 \nつまり`2`という数値が、`int`(整数)等の他の型の`2`ではなく`float`の`2`であるということです。\n\n[Processing の`float`は Java\nから継承している](https://processing.org/reference/float.html)ので詳細は Java\n関連の情報を当たるといいでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T11:43:27.240", "id": "18022", "last_activity_date": "2015-10-24T12:17:34.323", "last_edit_date": "2015-10-24T12:17:34.323", "last_editor_user_id": "7290", "owner_user_id": "7290", "parent_id": "18016", "post_type": "answer", "score": 2 } ]
18016
null
18022
{ "accepted_answer_id": "18018", "answer_count": 1, "body": "Meteor のコレクションプロパティ・メソッドの定義方法についての質問です。\n\n```\n\n // articles.js\n Articles = new Mongo.Collections('articles');\n \n```\n\n例えば、上記のように Articles コレクションを定義しているとして、この Articles\nコレクションに独自のプロパティやメソッドを定義したいのですが、どうすればよろしいでしょうか。\n\n独自で定義したプロパティやメソッドには以下のようにアクセスしたいと考えています。\n\n```\n\n // プロパティへのアクセス\n Articles.someProperty\n \n // メソッド呼び出し\n Articles.someMethod()\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T08:28:00.360", "favorite_count": 0, "id": "18017", "last_activity_date": "2015-10-24T08:53:38.913", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12938", "post_type": "question", "score": 0, "tags": [ "meteor" ], "title": "Meteor コレクションの static プロパティ, メソッドの定義方法について", "view_count": 32 }
[ { "body": "そのままできます。\n\n```\n\n Articles.someProperty = 'abc';\n Articles.someMethod = function() { return 'abc'; };\n \n```\n\nCollection2などでも独自プロパティを使っています。 \nこれがどの程度一般的に受け入られているのかはよく分かりません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T08:53:38.913", "id": "18018", "last_activity_date": "2015-10-24T08:53:38.913", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12937", "parent_id": "18017", "post_type": "answer", "score": 0 } ]
18017
18018
18018
{ "accepted_answer_id": "18027", "answer_count": 1, "body": "```\n\n //ボタンがタップされた時のメソッド\n func buttonTapped(sender:UIButton){\n var tappedButtonTitle:String = sender.currentTitle!\n println(\"\\(tappedButtonTitle)ボタンが押されました!\")\n \n //ボタンタイトルで条件分岐\n switch tappedButtonTitle {\n case \"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\":\n numberButtonTapped(tappedButtonTitle)\n case \"x\", \"-\", \"+\", \"÷\":\n operatorButtonTapped(tappedButtonTitle)\n case \"=\":\n equalButtonTapped(tappedButtonTitle)\n default:\n clearButtonTapped(tappedButtonTitle)\n }\n \n }\n \n func numberButtonTapped(tappedButtonTitle:String){\n println(\"数字ボタンタップ:\\(tappedButtonTitle)\")\n //タップされた数字タイトルを計算できるようにDouble型に変換\n var tappedButtonNum:NSDecimalNumber =\n NSDecimalNumber(string:tappedButtonTitle)\n \n //入力されていた値を10倍にして1桁大きくして、その変換した数値を加算\n number1 = number1.decimalNumberByMultiplyingBy(\n NSDecimalNumber(string: \"10\")).decimalNumberByAdding(tappedButtonNum)\n \n //計算結果ラベルに表示\n resultLabel.text = number1.stringValue\n }\n \n func operatorButtonTapped(tappedButtonTitle:String){\n println(\"演算子ボタンタップ:\\(tappedButtonTitle)\")\n operatorId = tappedButtonTitle\n number2 = number1\n number1 = NSDecimalNumber(string: \"0\")\n }\n \n```\n\n上記のような記述をしていて、ボタンがタップされた時に \nボタンによって、それぞれの関数を呼び出してきているのですが、\n\n```\n\n cannot capture 'numberButtonTapped'before it is declared\n \n```\n\nなどとエラー表示されてしまいます。\n\nかといって、タップされた時のメソッドを、それぞれのボタンの関数の後に記述すると \nまた、別のエラーが起きてしまいます。\n\nいまいち調べてもよくわからなかったのですが、解決策を教えていただけると幸いです。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T11:10:28.817", "favorite_count": 0, "id": "18020", "last_activity_date": "2015-10-24T16:17:09.190", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8415", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "Swiftでbefore it is declaredとエラーが出る", "view_count": 707 }
[ { "body": "Swift 1.xの制限ですね。Xcode 7.xにアップグレードしてSwift\n2.xで書き直すか、そうでなければ、各メソッドをローカルFunctionではなく、外側に出して普通のインスタンスメソッドとして実装すれば解決します。\n\nすべてのコードが掲載されていませんので、エラーの内容からの推測ですが、それぞれのメソッドを別のメソッドの中に書いていますよね?それが原因です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T16:17:09.190", "id": "18027", "last_activity_date": "2015-10-24T16:17:09.190", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "18020", "post_type": "answer", "score": 1 } ]
18020
18027
18027
{ "accepted_answer_id": null, "answer_count": 1, "body": "**経緯** \nmacbookproにEmacs-24.5の導入を試みました。 \nHomebrewを利用してインストール。しかし、いざEmacsを呼び出してみると,GNU\nEmacsの画面は立ち上がるものの、キーボード入力がターミナルに入力されてしまう現象が発生しました。\n\n**環境** \nOSX Yosemite 10.10.5 \nHomebrew 0.9.5 (git revision f211; last commit 2015-10-24)\n\n**やったこと** \n以下のサイト様を参考にしながら、順にコマンドを実行していきました。 \n[OSXにHomebrewでtmuxとEmacs 24.4をインストールする -\nQiita](http://qiita.com/masato/items/ef0ffa626ca8bf46bf8a\n\"OSXにHomebrewでtmuxとEmacs 24.4をインストールする - Qiita\")\n\ntmuxの導入は今回行っていません。\n\nまず、Homebrew installを実行してEmacsを導入しました。\n\n> $ brew install --with-cocoa emacs\n\n無事にWarningやErrorが特に発生することなく、インストール終了しました。 \nこの時点でEmacsの起動を試みます。\n\n> $ emacs\n\nすると、ターミナルのウィンドウの下にGNU Emacsが起動しました。ターミナルがアクティブのままです。 \nEmacsのウィンドウをクリックするとEmacsアクティブがアクティブになってくれたので、試しにC-x,C-fを入力しました。すると、Emacsではなくターミナル上に入力が表示されてしまいました。\n\n[![emacs起動中にターミナルへ入力される文字](https://i.stack.imgur.com/UApVT.png)](https://i.stack.imgur.com/UApVT.png)\n\nクリックやドラッグ操作によってツールバーからファイルを開いたり、文字列のコピーなどを行うことはできました。しかし、キーボード入力は依然としてターミナルに入力されてしまいます。\n\nこの状態でC-cを入力すると、emacsを終了することができました。 \nその際、ターミナル上に次のようなメッセージが出力されました。\n\n> 2015-10-24 19:55:03.462 emacs[91392:1443732] *** -[NSAutoreleasePool\n> release]: This pool has already been released, do not drain it (double\n> release).\n\nこのメッセージは、GNU Emacsのウィンドウにある閉じるボタンを押してEmacsを終了させた場合には表示されません。\n\nそして次に、Emacs.appが起動できるかを確かめるために、参考サイトに倣って/Applicationsへシムリンクを作成しました。\n\n> $ brew linkapps emacs \n> Linking /usr/local/Cellar/emacs/24.5/Emacs.app to /Applications.\n>\n> $ open /Applications/Emacs.app\n\nすると、無事にGNU Emacsが起動しました。しかし、依然としてターミナルからEmacsを呼びだしてもキーボード入力は通りませんでした。\n\n**知りたいこと**\n\n * ターミナルから立ち上げたemacsに文字を入力できない問題の解決策、または考えられる原因\n * 類似症例の報告。その症例の解決や対処に使った方法\n\n質問文に不足項目があれば対応させていただきます。よろしくお願いします。\n\n追記1:2015-10-24 21:57 \ncommand+tab\nで起動中のアプリケーションの一覧表示・切り替えができますが、その中にターミナルから立ち上げたEmacsは表示されていませんでした。起動中のアプリケーションとして認識されていないということでしょうか……", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T11:16:49.540", "favorite_count": 0, "id": "18021", "last_activity_date": "2018-04-05T09:34:15.410", "last_edit_date": "2015-10-24T12:56:56.927", "last_editor_user_id": "10421", "owner_user_id": "10421", "post_type": "question", "score": 0, "tags": [ "macos", "emacs" ], "title": "OSXに導入したEmacsへ文字の入力ができない問題", "view_count": 1856 }
[ { "body": "brewからemacsをインストール後、全く同じ問題に遭遇しました。 \n`/usr/local/bin/emacs-25.3` \nを実行していましたが、 \n`/usr/local/Cellar/emacs/25.3/Emacs.app/Contents/MacOS/Emacs` \nにすることで解決しました。自分への忘備録として投稿します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-04-05T09:34:15.410", "id": "42958", "last_activity_date": "2018-04-05T09:34:15.410", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "28028", "parent_id": "18021", "post_type": "answer", "score": 1 } ]
18021
null
42958
{ "accepted_answer_id": "18026", "answer_count": 5, "body": "例えば以下のクラスCでsayメソッドを使ったら \nインスタンス変数@dはnilで初期化されています.\n\nこのメソッドは3行にわたって書いており, \nもうすこしスマートに書けないかと悩んでいます.\n\nすでに機能的には充足されていますが, \nrubyらしく書くためにはどう工夫すればよいでしょうか\n\n```\n\n class C\n def initialize\n @d = \"hello\"\n end\n def say\n result = @d\n @d = nil\n result\n end\n end\n \n c = C.new\n c.say #=> hello\n c.say #=> nil\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T13:25:20.043", "favorite_count": 0, "id": "18025", "last_activity_date": "2015-10-26T02:13:50.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8722", "post_type": "question", "score": 7, "tags": [ "ruby" ], "title": "インスタンス変数を参照したら,また初期化したい", "view_count": 1200 }
[ { "body": "`tap`を使うと良いと思います。\n\n```\n\n def say\n @d.tap { @d = nil }\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T15:14:30.187", "id": "18026", "last_activity_date": "2015-10-24T15:14:30.187", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9575", "parent_id": "18025", "post_type": "answer", "score": 12 }, { "body": "どうしても `@d` は文字列じゃないといけない、という制約がないのであれば、配列を使うのもアリかもです。(外から見た動きは文字列の場合と同じになります)\n\n```\n\n class C\n def initialize\n @d = [\"hello\"]\n end\n def say\n @d.pop\n end\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T23:09:42.550", "id": "18034", "last_activity_date": "2015-10-24T23:09:42.550", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "85", "parent_id": "18025", "post_type": "answer", "score": 2 }, { "body": "インスタンス変数を取り除くメソッドを使用するという手もあります。\n\n```\n\n def say\n remove_instance_variable(:@d) if @d\n end\n \n```\n\n[Object#remove_instance_variable](http://docs.ruby-\nlang.org/ja/2.2.0/class/Object.html#I_REMOVE_INSTANCE_VARIABLE)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T01:52:46.547", "id": "18037", "last_activity_date": "2015-10-25T01:52:46.547", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9608", "parent_id": "18025", "post_type": "answer", "score": 3 }, { "body": "```\n\n class C\n def initialize\n @d = \"hello\"\n end\n \n def say\n @d\n ensure\n @d = nil\n end\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T02:11:51.113", "id": "18073", "last_activity_date": "2015-10-26T02:11:51.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2599", "parent_id": "18025", "post_type": "answer", "score": 1 }, { "body": "```\n\n class C\n def initialize\n @d = \"hello\"\n end\n \n def say\n result, @d = @d\n result\n end\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T02:13:50.253", "id": "18074", "last_activity_date": "2015-10-26T02:13:50.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2599", "parent_id": "18025", "post_type": "answer", "score": 0 } ]
18025
18026
18026
{ "accepted_answer_id": "18183", "answer_count": 1, "body": "laravel5でheroku-connectを利用するにあたって、 \n同期したPostgresにlaravel5で入力したデータをpostgresにinsertすることができません。\n\nデータの取得は問題なくできますがinsert時に失敗してしまいます。\n\nお手数ですが解決方法をご存知の方、よろしくお願いします。\n\nエラーメッセージはこちらです。\n\n> QueryException in Connection.php line 651: SQLSTATE[42883]: Undefined \n> function: 7 ERROR: function get_xmlbinary() does not exist LINE 1: \n> SELECT (get_xmlbinary() = 'base64') ^ HINT: No function matches the \n> given name and argument types. You might need to add explicit type \n> casts. QUERY: SELECT (get_xmlbinary() = 'base64') CONTEXT: PL/pgSQL \n> function hc_TABLENAME_status() line 3 at IF (SQL: insert into \n> TABLENAME (\"NAME\") values (VALUE) returning \"id\")\n\n> PDOException in Connection.php line 321: SQLSTATE[42883]: Undefined \n> function: 7 ERROR: function get_xmlbinary() does not exist LINE 1: \n> SELECT (get_xmlbinary() = 'base64') ^ HINT: No function matches the \n> given name and argument types. You might need to add explicit type \n> casts. QUERY: SELECT (get_xmlbinary() = 'base64') CONTEXT: PL/pgSQL \n> function hc_TABLENAME_status() line 3 at IF", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T17:54:10.433", "favorite_count": 0, "id": "18030", "last_activity_date": "2015-10-28T16:26:26.443", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12946", "post_type": "question", "score": 1, "tags": [ "php", "heroku", "laravel" ], "title": "heroku-connectと同期したpostgresにinsertできない。", "view_count": 715 }
[ { "body": "```\n\n $schema = array('salesforce', 'public');\n \n```\n\nスキーマに'public'を追加することで解決しました。 \nもともと指定されていて、取り除く必要がなかったようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T16:26:26.443", "id": "18183", "last_activity_date": "2015-10-28T16:26:26.443", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12946", "parent_id": "18030", "post_type": "answer", "score": 0 } ]
18030
18183
18183
{ "accepted_answer_id": "18169", "answer_count": 1, "body": "Unityにおいて、 \nMMD4Mecanimを使用し変換したモデルで、 Android に書き出すとアニメーションしません。 \nunity上のプレビューでは動きます。 \nまたアニメーション以外のプログラムは動いています\n\nUnityのバージョンは5.2 \nMMD4Mecanim 20150821\n\n試した事 \n・MMD4Mecanimを使わず、AndroidAPKにする→アニメーションする \n・Unityのバージョンを4.6まで落としてみる→アニメーションしない \n・PCへの書き出し→アニメーションする", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-24T20:12:41.473", "favorite_count": 0, "id": "18031", "last_activity_date": "2015-10-28T09:43:02.380", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12948", "post_type": "question", "score": 0, "tags": [ "unity3d" ], "title": "Unity:AndroidAPKに書き出すとアニメーションしない", "view_count": 377 }
[ { "body": "MMD4Mecanim が新しいバージョンよりモバイル書き出しに対応していないためでした\n\n過去のバージョンではモバイル書き出しに対応していたため、ネット上では「これでできる」という解説が行われたままのものが存在します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T09:43:02.380", "id": "18169", "last_activity_date": "2015-10-28T09:43:02.380", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12608", "parent_id": "18031", "post_type": "answer", "score": 1 } ]
18031
18169
18169
{ "accepted_answer_id": null, "answer_count": 0, "body": "Fragmentのタッチイベントを取得する方法を教えて下さい。\n\n詳細: \nお世話になっております。 \n現在、Fragmentに設置した「WebViewの履歴の有無」で「バックボタン」を指定のデザインで表示できる動作を実装しております。 \n「WebViewの履歴の無」→「バックボタン」非表示 \n「WebViewの履歴の有」→「バックボタン」表示\n\n表示動作は完成しております。 \n次に、この動作を「画面をタッチするごとに履歴の有無を判定」することで行おうと思っていたのですが、ここで難航しております。\n\n画面タッチイベントを取得したいのですが、Fragmentのタッチイベントはどのように実装するのでしょうか?\n\n以下のサイトやその他を参考に試したのですが取得出来ておりません。 \n<http://d.hatena.ne.jp/tetsu831/20111017/1318833874> \nコード上でエラーが発生していないため、何が問題なのか検討もつかない状況です。\n\nご存知の方がおられましたらアドバイスをいただけないでしょうか? \nよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T00:18:25.010", "favorite_count": 0, "id": "18035", "last_activity_date": "2015-10-25T01:07:37.990", "last_edit_date": "2015-10-25T01:07:37.990", "last_editor_user_id": "5778", "owner_user_id": "8670", "post_type": "question", "score": 1, "tags": [ "android", "android-fragments" ], "title": "Fragmentのタッチイベントを取得する方法を教えて下さい。", "view_count": 1067 }
[]
18035
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "AndroidのFragmentをaddToBackStackしたあとで、popBackStackと呼ぶとリプレースを取り消しできますが、popBackStack後のリプレースされたフラグメント、つまりリプレース前に表示されていたフラグメントのライフサイクルはどの状態になるのでしょうか。\n\n今作成しているアプリでpopBackStackを呼び出すとリプレースされえたフラグメントが何も表示されずに困っております。\n\nご教授ねがえますでしょうか。よろしくお願いします。\n\n追記 PagerAdapterをnewしている箇所\n\n```\n\n adapter = new ViewPagerAdapter(getChildFragmentManager());\n mViewPager.setOffscreenPageLimit(2);\n mViewPager.setAdapter(adapter);\n mViewPager.addOnPageChangeListener(this);\n \n```", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T00:41:31.880", "favorite_count": 0, "id": "18036", "last_activity_date": "2015-10-25T02:54:07.790", "last_edit_date": "2015-10-25T02:54:07.790", "last_editor_user_id": "7232", "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "android", "android-fragments" ], "title": "AndroidでpopBackStackした時のライフサイクル", "view_count": 1007 }
[]
18036
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "```\n\n UserName-no-MacBook:~ Junichi$ sudo gem install cocoapods\n ERROR: While executing gem ... (Errno::EPERM)\n Operation not permitted - /usr/bin/xcodeproj\n \n```\n\n上記のエラーが出てしまい、先に進めません。\n\n解決策わかる方、教えていただければ幸いです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T02:02:39.023", "favorite_count": 0, "id": "18038", "last_activity_date": "2015-10-25T05:45:21.183", "last_edit_date": "2015-10-25T05:45:21.183", "last_editor_user_id": "10845", "owner_user_id": "10845", "post_type": "question", "score": 1, "tags": [ "xcode", "cocoapods", "xcode7" ], "title": "XCODE7とOSX 10.11 El CapitanでCocoaPodsをインストール時エラー", "view_count": 192 }
[]
18038
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "electronでcasper.jsを使おうと考えています。 \nmain.jsにて\n\n```\n\n require ('casper');\n \n```\n\nと書いて実行すると\n\n> Cannot find module 'casper'\n\nと表示されてしまいます。 \nelectronでは外部のmoduleは使えないのでしょうか?\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-10-25T02:09:45.033", "favorite_count": 0, "id": "18039", "last_activity_date": "2019-07-10T08:04:12.340", "last_edit_date": "2019-07-10T08:04:12.340", "last_editor_user_id": "32986", "owner_user_id": "12951", "post_type": "question", "score": 1, "tags": [ "javascript", "html5", "node.js", "electron" ], "title": "electronで外部のmoduleを使う方法", "view_count": 977 }
[ { "body": "こんにちは、回答がなかったようなので。\n\nまずCasperJSはjsのモジュールではありません。 \nあとElectronはnode.jsで動いているため、node.jsから外部コマンドを実行するようにしてあげなければなりません。しかしnpmをみてみるとphantom.jsはnode-\nphantomと言ったようなモジュールがあります。\n\nそこで今回ご質問のcasperJSは調べたところ、SpookyJSというのがあるみたいです。 \n<https://github.com/SpookyJS/SpookyJS>\n\nこちらでいけると思います。\n\nもし外部から読み込む方式なら、child_processを呼び出して、exec関数を作ってあげるとよいと思われます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-12-19T23:46:10.317", "id": "20188", "last_activity_date": "2015-12-19T23:46:10.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13743", "parent_id": "18039", "post_type": "answer", "score": 1 } ]
18039
null
20188
{ "accepted_answer_id": "18048", "answer_count": 2, "body": "超初心者です。すみません。\n\n複数のimageViewのアニメーションを順番に一つずつ動くようにしたいです。 \n現時点では指定した数のimageViewは落ちてきますが、すべて同時に落ちてきます。 \n@\"アニメーション終了\"のログも同時に出ます。\n\nimageViewをfor文の中で配列に入れる必要があるのでしょうか。 \nよろしくお願いいたします。\n\n```\n\n -(IBAction)buttonPushed{\n \n for(i = 0;i < repeatCount;i++){\n image = [UIImage imageNamed:@\"img.png\"];\n imageView = [[UIImageView alloc]initWithImage:image];\n \n imageView.frame = CGRectMake(15+i*40, -150, 85, 150);\n [self.view addSubview:imageView];\n \n \n // アニメーション \n [UIView animateWithDuration:0.5f \n delay:0.1f\n options:UIViewAnimationOptionCurveEaseInOut\n animations:^{\n imageView.transform = CGAffineTransformMakeTranslation(0, 550);\n \n } completion:^(BOOL finished) {\n NSLog(@\"アニメーション終了\");\n \n }];\n \n usleep(500000);\n \n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T02:41:26.637", "favorite_count": 0, "id": "18040", "last_activity_date": "2015-10-25T06:49:47.150", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12952", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c" ], "title": "アニメーションを順番にしたい", "view_count": 977 }
[ { "body": "iOSとiPhone/iPadは、マルチスレッドで動いています。アニメーションが(見た目)同時に動いてしまうというのは、for文のくり返し処理と、UIViewのアニメーションが、別スレッドで処理されていると、判断できるでしょう。`repeatCount`がどのくらいの大きさかわかりませんが、`10000`であっても、0.1秒かからないでしょう。\n\n一定間隔で、アニメーションを開始するなら……`NSTimer`クラスを利用する。マルチスレッドを直接触る(`NSThread`クラス、GCD(Grand\nCentral Dispach)など)ということも考えられますが、それなりの勉強が必要です。\n\n```\n\n usleep(500000);\n \n```\n\nこれはなんでしょうか?「超初心者」の人が安心して使える関数なんでしょうか?いずれ、無視されてることは確実ですけど。\n\n* * *\n\nサンプルコードを載せておきます。 \nNSTimerを使った処理。\n\n```\n\n - (IBAction)startAnimation:(id)sender { // ボタンを押して開始。\n // タイマーを作って、開始。repeatsをYESにして、無限ループにする。\n [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self selector: @selector(moveImage:) userInfo: nil repeats: YES];\n }\n \n - (void)moveImage: (NSTimer *)timer { // NSTimerが呼ぶセレクタ。\n // staticオプションをつけて、メソッド内で有効な変数とする。\n static int count = 0; // 繰り返しのカウンタ。\n static CGPoint imageCenter = {70.0, 70.0}; // imageViewの位置。\n if (count > 4) {\n count = 0;\n imageCenter = CGPointMake(70.0, 70.0);\n [timer invalidate]; // 5回繰り返したらタイマー停止。\n return;\n }\n \n UIImageView *imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @\"image.png\"]];\n imageView.center = imageCenter;\n [self.view addSubview: imageView];\n [UIView animateWithDuration: 3.0 delay: 0.0 options: UIViewAnimationOptionCurveEaseInOut animations: ^ {\n imageView.center = CGPointMake(imageCenter.x, imageCenter.y + 200.0);\n } completion: NULL];\n count++; // カウンタ追加。\n imageCenter.x += 20.0; // imageViewの位置を右にずらす。\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T03:55:03.027", "id": "18044", "last_activity_date": "2015-10-25T06:49:47.150", "last_edit_date": "2015-10-25T06:49:47.150", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "18040", "post_type": "answer", "score": -3 }, { "body": "`delay:`を使うのが楽だと思います。\n\n```\n\n // アニメーション\n [UIView animateWithDuration:0.5f\n delay:0.1f + 0.5f * i\n options:UIViewAnimationOptionCurveEaseInOut\n animations:^{\n imageView.transform = CGAffineTransformMakeTranslation(0, 550);\n \n } completion:^(BOOL finished) {\n NSLog(@\"アニメーション終了\");\n \n }];\n \n //usleep(500000); 消しても良い\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T06:21:36.037", "id": "18048", "last_activity_date": "2015-10-25T06:21:36.037", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5337", "parent_id": "18040", "post_type": "answer", "score": 2 } ]
18040
18048
18048
{ "accepted_answer_id": null, "answer_count": 1, "body": "has_many + through\nで定義したmodelに紐づくデータを取得すると、データベース上は1件ずつしか存在しないのに、各データが重複して取得されてしまうケースが発生しました。\n\n具体的な内容としては、\n\n「apple」と「orange」というテーブルがあり、「apple_orange」という中間テーブルがあるとします。 \nそして、appleのmodelファイルに\n\n```\n\n has_many :oranges, :through => :apple_oranges\n \n```\n\nと定義した場合、\n\n```\n\n apple.oranges\n \n```\n\nでapple_orangeを経由して orange のデータが取得できるはずです。\n\nここで、仮に以下のようなデータ状態だったとします。\n\n```\n\n ・apple\n \n id|title\n --------\n 1|AA\n \n ・orange\n \n id|title\n --------\n 1|AA\n 2|BB\n 3|CC\n \n ・apple_orange\n \n id|apple_id|orange_id\n ---------------------\n 1| 1| 1\n 2| 1| 2\n 3| 1| 3\n \n```\n\nこの場合、Apple.find(1).oranges の結果件数は 3件 だと思います。\n\nこれがorangeのデータがそれぞれ重複され 6件 取得できてしまうケースがありました。\n\n今までにこのようなケースに遭ったことがなく、しかも、1回起こったものの、以降は発生していません。 \n発生時にたまたまデータが2件ずつ存在した、ということはありません。 \nRailsの内部的な問題でしょうか。 \nご存知でしたらご教示いただければと思います。\n\nなお、環境は以下になります。\n\nRuby 1.8.7 \nRails 2.3.5 \nCentOS 5.9", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T02:48:46.317", "favorite_count": 0, "id": "18041", "last_activity_date": "2016-06-14T09:35:54.627", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12953", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby" ], "title": "Railsでhas_manyで紐付いたデータがそれぞれ重複している", "view_count": 420 }
[ { "body": "偶然のタイミングで発生するバグとしては考えにくい挙動ですが、もし事例があるなら[古いRailsのIssue](https://rails.lighthouseapp.com/projects/8994-ruby-\non-rails/tickets)に残ってるかもしれません。\n\nそれよりも、RubyもRailsもあまりに古すぎるので、速やかにバージョンアップすることをおすすめします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-25T02:29:14.757", "id": "19267", "last_activity_date": "2015-11-25T02:29:14.757", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "18041", "post_type": "answer", "score": 1 } ]
18041
null
19267
{ "accepted_answer_id": null, "answer_count": 1, "body": "gem追加時に毎回このエラーが出て便利なgemを使用することに阻まれます。 \n今回は、jquery-mobile-railsを入れようとしました。 \nmmenuを追加しようとした時も、同様のエラーが出ます。\n\n```\n\n Sporckets::FileNotFound in Article#index\n couldn't find file 'jquery.mobile' with type text/css\n \n```\n\nsp/application.css\n\n```\n\n *\n *= require jquery.mobile\n *= require_tree .\n *= require_self\n */\n \n```\n\napplication.html+sp.erb\n\n```\n\n <%= stylesheet_link_tag 'sp/application', media: 'all', 'data-turbolinks-track' => true %>\n <%= javascript_include_tag 'sp/application' %>\n <%= csrf_meta_tags %>\n \n```\n\nGemfile\n\n```\n\n gem 'jquery_mobile_rails'\n \n```\n\nGemfile.lock\n\n```\n\n jquery_mobile_rails (1.4.5)\n \n```\n\nこれを追加したうえで、jqueryのファイルを落としてきてパス指定をhtml+sp.erbに書く必要があるのでしょうか。よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T02:56:39.847", "favorite_count": 0, "id": "18042", "last_activity_date": "2019-09-09T13:00:06.630", "last_edit_date": "2019-09-09T13:00:06.630", "last_editor_user_id": "32986", "owner_user_id": "11188", "post_type": "question", "score": 3, "tags": [ "ruby-on-rails", "jquery-mobile" ], "title": "gem追加時にSprockets::FileNotFound", "view_count": 7944 }
[ { "body": "Gemfileにgemを追加する前にRailsを立ち上げた場合、gem追加後に再起動しないと追加したgemが読み込まれず`Sprockets::FileNotFound`が出てしまうと思います。\n\ngemを追加したあと、`Sprockets::FileNotFound`が出た場合、Railsを再起動してみてはいかがでしょうか?\n\n以前にも似たような質問があったので参考になれば。\n\n[ruby - Railsのファイルの変更の自動読み込みについて -\nスタック・オーバーフロー](https://ja.stackoverflow.com/questions/8228/rails%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E5%A4%89%E6%9B%B4%E3%81%AE%E8%87%AA%E5%8B%95%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%81%BF%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T03:33:15.500", "id": "18076", "last_activity_date": "2015-10-26T03:33:15.500", "last_edit_date": "2017-04-13T12:52:39.113", "last_editor_user_id": "-1", "owner_user_id": "2599", "parent_id": "18042", "post_type": "answer", "score": 1 } ]
18042
null
18076
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在の状況\n\nAPIを通じてUITableViewで画像を表示しようとしたのですが、表示されません。\n\n解決策を現在探していますので、何か助言を頂ければと考え投稿しました。\n\n解決策1\n\n```\n\n cell.artworkUrl.text = result[\"artworkUrl100\"]と記述する、が画像は表示されず。。\n \n```\n\n解決策2\n\n```\n\n self.imageView.image = UIImage(contentsOfFile: imgPath)と記述 failed\n \n```\n\nSetImageWithURLでartworkUrlにあるAPIの情報をセットしたのちに、その情報を表示するコードが存在していなかったため追加した。\n\n```\n\n //tavleviewに対して引数内を継承している\n override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {\n \n //dequeueReusableCellWithIdentifierはcellに参照(使い回しが出来るよう)にする\n //as! ListCellは、ListCellがNilだとエラーが出るようにする \n let cell = tableView.dequeueReusableCellWithIdentifier(\"cell\", forIndexPath: indexPath) as! ListCell\n \n //定数resultsにcellが代入されたら、画像を表示する。 \n if let result = results?[indexPath.row] {\n if let artworkUrl = result[\"artworkUrl100\"] as? String {\n cell.artworkImageView.setImageWithURL(NSURL(string: artworkUrl)!)\n } else {\n cell.artworkImageView.image = nil\n }\n \n // 曲のtrackNameとartistNameを表示する\n \n cell.trackLabel.text = result[\"trackName\"] as? String\n cell.artistLabel.text = result[\"artistName\"] as? String\n }\n // cellの内容を戻り値として返す。 \n return cell\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T03:20:38.780", "favorite_count": 0, "id": "18043", "last_activity_date": "2015-10-25T07:14:23.397", "last_edit_date": "2015-10-25T07:14:23.397", "last_editor_user_id": "10491", "owner_user_id": "10491", "post_type": "question", "score": 1, "tags": [ "swift" ], "title": "UITableViewで表示ができない。", "view_count": 163 }
[]
18043
null
null
{ "accepted_answer_id": "18128", "answer_count": 1, "body": "昔は\n\n```\n\n git checkout BRANCH_NAME\n \n```\n\nだけで、fetchしたremote\nbranchのトラッキングブランチを自動で生成した上でそのトラッキングブランチにチェックアウトできていたと思うのですが、今では出来なくなっていて、以下のようなエラーが出ます。\n\n```\n\n error: pathspec 'BRANCH_NAME' did not match any file(s) known to git.\n \n```\n\nそのため現状では、\n\n```\n\n git checkout -b BRANCH_NAME origin/BRANCH_NAME\n \n```\n\nとしているのですが、より簡単な方法があれば教えて下さい \nversion2.6で`git checkout BRANCH_NAME`で問題ない方もいらっしゃる様なので、gitのバージョンの問題ではないようです。", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T05:48:18.157", "favorite_count": 0, "id": "18047", "last_activity_date": "2015-10-27T07:57:45.990", "last_edit_date": "2015-10-27T03:51:59.657", "last_editor_user_id": "4072", "owner_user_id": "4072", "post_type": "question", "score": 4, "tags": [ "git" ], "title": "fetchしたremoteブランチのトラッキングブランチがcheckout時に自動で生成されない", "view_count": 22396 }
[ { "body": "[Git\n1.6.6](https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/1.6.6.txt)\n以降現在に至るまで、 `git checkout <branch>` でトラッキングブランチを作成できます。\n\nただし、指定した名前のブランチが複数の remote に存在するとエラーになります。\n\n> If <branch> is not found but there does exist a tracking branch **in exactly\n> one remote** (call it <remote>) with a matching name, treat as equivalent to\n```\n\n> $ git checkout -b <branch> --track <remote>/<branch>\n> \n```\n\n>\n> \\--- <https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html>\n> より引用。強調は私によるものです。\n\nこの場合のエラーメッセージは、存在しないブランチ名を指定したときと同様のものです。\n\n```\n\n $ git branch -a\n * master\n remotes/origin/HEAD -> origin/master\n remotes/origin/some-branch\n remotes/hoge/some-branch\n remotes/hoge/some-branch\n \n $ git checkout some-branch\n error: pathspec 'some-branch' did not match any file(s) known to git.\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T07:57:45.990", "id": "18128", "last_activity_date": "2015-10-27T07:57:45.990", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "18047", "post_type": "answer", "score": 6 } ]
18047
18128
18128
{ "accepted_answer_id": "18054", "answer_count": 1, "body": "以下のような、ステータスとその順番等を管理するオブジェクトを定義したいのですが、 \nこの場合、AngularJSではどこにどのように定義するべきなのでしょうか? \nサービスとして定義するべきなのでしょうか?\n\n```\n\n status = [\n { waiting :{index:1, icon_img:'xxx1.png'} },\n { operating:{index:2, icon_img:'xxx2.png'}},\n { complate :{index:3, icon_img:'xxx3.png'}}\n ]\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T09:44:04.410", "favorite_count": 0, "id": "18053", "last_activity_date": "2015-10-25T10:03:07.437", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12961", "post_type": "question", "score": 2, "tags": [ "javascript", "angularjs" ], "title": "AngularJSで定数?っぽいオブジェクトを定義したい", "view_count": 1921 }
[ { "body": "Angular1.*系であれば、`module.constant`でconfigフェイズでも使用できるDIが定義できます。\n\n[DEMO](http://jsfiddle.net/59naga/mcj0bq1h/)\n\n```\n\n angular.element(document)\n .ready(function(){\n angular.bootstrap(document,['myApp']);\n });\n \n angular.module('myApp',[])\n .constant('ORDER_BY',['foo','bar','baz'])\n .config(function(ORDER_BY){\n console.log(ORDER_BY);// ['foo','bar','baz']\n })\n ;\n \n```\n\n> 参考: \n> [constant, value, service, factory, providerの使い分け - AngularJS -\n> angular.jsメモ -\n> Qiita](http://qiita.com/akkun_choi/items/618d2d9107029ab0422e#constant-\n> value-service-factory-provider%E3%81%AE%E4%BD%BF%E3%81%84%E5%88%86%E3%81%91)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T10:03:07.437", "id": "18054", "last_activity_date": "2015-10-25T10:03:07.437", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9834", "parent_id": "18053", "post_type": "answer", "score": 1 } ]
18053
18054
18054
{ "accepted_answer_id": "18060", "answer_count": 1, "body": "DatailViewControllerをsubclassにAVPlayerViewControllerを指定して、iOS Source > Cocoa\nTouch Classから作成しました。\n\nその段階で「Use of undeclared type\n\"AVPlayerViewController\"/宣言されていない型を使うな!!」というエラーが生じました。\n\n何かしら手助け頂ければ幸いです。\n\n現在行っている解決策\n\n1,Build PhasesからCompile\nSourcesでDetailViewController.swiftをaddすれば良いとググるとあったのですが、もう既にaddされている状態でした。\n\n2,Taget Membershipにチェックを入れろとあったのですが、それも既にチェックされていました。\n\n3,Cleanコマンド?を行う もしくはDerived Dataを消す 実行済み\n\n4,新しいUIkitをimportする。これはやり方がわかりません。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T10:30:52.970", "favorite_count": 0, "id": "18055", "last_activity_date": "2015-10-25T14:28:30.613", "last_edit_date": "2015-10-25T10:49:39.283", "last_editor_user_id": "7362", "owner_user_id": "10491", "post_type": "question", "score": -1, "tags": [ "swift" ], "title": "Use of undeclared type \"xxx\"エラーの解決に関して", "view_count": 13085 }
[ { "body": "今どきのプロジェクトではAutoLinkが働くのでリンカの設定はおそらく関係ないですね。単純に`import`文がないのではないかと思いますが、`import\nAVKit`は書いてますか?\n\n普通にプロジェクトを作成して、下記のように書けばビルドエラーにはならないと思います。下記と比べてみてください。\n\n```\n\n import UIKit\n import AVKit\n \n class ViewController: AVPlayerViewController {\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view, typically from a nib.\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n \n \n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T14:28:30.613", "id": "18060", "last_activity_date": "2015-10-25T14:28:30.613", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "18055", "post_type": "answer", "score": 1 } ]
18055
18060
18060
{ "accepted_answer_id": "18066", "answer_count": 3, "body": "pandasで日付の処理をしており、該当する日付がなければ新しい行を加えるという処理をしようとしています。 \nそこで次のようなコードを書きました。 \nリスト内には存在するのにin演算子には引っかからないという現象が起きてしまい、原因がさっぱりわかりません。もしよろしければ原因を教えてください。\n\n```\n\n def complement_date(self,pandas_arr):\n keys = pandas_arr.keys()\n dates = pandas_arr[keys[0]]# date info in first index\n dateidx = START# START = datetime.datitme(2013,8,1,0,0)\n while END>=dateidx:\n if not pd.to_datetime(dateidx) in dates:\n pdb.set_trace()\n tmp = pd.Series([dateidx,0],index=keys)\n pandas_arr = pandas_arr.append(tmp,ignore_index=True)\n dateidx = dateidx + DAY# DAY = datetime.timedelta(days=1)\n return pandas_arr\n \n```\n\n[![デバッグ画面](https://i.stack.imgur.com/xVs9w.png)](https://i.stack.imgur.com/xVs9w.png)", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T11:25:48.603", "favorite_count": 0, "id": "18056", "last_activity_date": "2015-10-27T13:03:58.263", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12962", "post_type": "question", "score": 3, "tags": [ "python", "pandas" ], "title": "python pandas による日付処理", "view_count": 2957 }
[ { "body": "自己解決しました。\n\n原因はいまだにわかりませんが \ndates = pandas_arr[keys[0]]# date info in first index \nの部分を \ndates = list(pandas_arr[keys[0]]) \nとしてやるとうまくいったようです。 \n元のコードだとlist型ではなく1列のpandasのDataFrame型ができるだけのようですね \n動作原理がわかる方いらっしゃればご教授下さいm(_ _)m", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T12:27:51.647", "id": "18057", "last_activity_date": "2015-10-25T12:27:51.647", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12962", "parent_id": "18056", "post_type": "answer", "score": 0 }, { "body": "`in` は `Index` との比較になるためです。\n\n```\n\n import pandas as pd\n dates = pd.Series(pd.date_range('2011-01-01', '2011-01-05', freq='D'))\n dates\n # 0 2011-01-01\n # 1 2011-01-02\n # 2 2011-01-03\n # 3 2011-01-04\n # 4 2011-01-05\n # dtype: datetime64[ns]\n \n t = pd.Timestamp('2011-01-01')\n t == dates[0]\n # True\n \n t in dates\n # False\n \n 0 in dates\n # True\n \n```\n\n値に含まれるかは以下で確認できます。\n\n```\n\n (t == dates).any()\n # True\n \n```\n\n* * *\n\nコメントに対する追記:\n\n> t in dates.values #False の解釈\n\nまず、`dates.values` は `numpy.ndarray` 型を返します。そのため、以下の記載は `pandas` ではなく `NumPy`\nの挙動に関する説明になります。\n\n```\n\n dates.values\n # array(['2011-01-01T09:00:00.000000000+0900',\n # '2011-01-02T09:00:00.000000000+0900',\n # '2011-01-03T09:00:00.000000000+0900',\n # '2011-01-04T09:00:00.000000000+0900',\n # '2011-01-05T09:00:00.000000000+0900'], dtype='datetime64[ns]')\n \n type(dates.values)\n # <type 'numpy.ndarray'>\n \n```\n\n`numpy.ndarray` は `in` 演算子をサポートしています。`NumPy` の日時型である\n`numpy.datetime64`を渡せば期待通り動きます。\n\n```\n\n import numpy as np\n \n np.datetime64('2011-01-01T09:00:00.000000000+0900') in dates.values\n # True\n \n```\n\n`pandas` の `Timestamp` 型から `numpy.datetime64` 型への変換は `asm8` プロパティで可能です。そのため、\n`in` を使う場合は下のようになります。\n\n```\n\n t.asm8\n # numpy.datetime64('2011-01-01T09:00:00.000000000+0900')\n \n t.asm8 in dates.values\n # True\n \n```", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T23:39:53.160", "id": "18066", "last_activity_date": "2015-10-26T11:29:29.103", "last_edit_date": "2015-10-26T11:29:29.103", "last_editor_user_id": "12966", "owner_user_id": "12966", "parent_id": "18056", "post_type": "answer", "score": 2 }, { "body": "> 私の権限では 下の回答にコメントできなかったためこちらに追記します。 **contains** の処理を変更すると pandas\n> の処理が壊れますので絶対に止めてください。影響範囲は調査する気にならないほど大きいです。※申し遅れましたが、私はpandas 開発チームのメンバーです。\n\n何だか怒られてしまいましたので、`in` 演算子の override ではなく、新たに演算子を作ってみました。\n\n# `dateidx in list(dates)` とすれば良いだけのことなのですが(苦笑)\n\nまず、`Infix` クラスを定義して `|in_df|` 演算子を作ります。\n\n```\n\n class Infix:\n def __init__(self, function):\n self.function = function\n def __call__(self, value1, value2):\n return self.function(value1, value2)\n def __or__(self, other):\n return self.function(other)\n def __ror__(self, other):\n return Infix(lambda x, self=self, other=other: self.function(other, x))\n \n in_df = Infix(lambda item, obj: item in obj.tolist())\n \n```\n\n実際に試してみます。\n\n```\n\n > dateidx = datetime.datetime(2013,8,1,0,0)\n > dateidx\n datetime.datetime(2013, 8, 1, 0, 0)\n \n > dates = pd.Series(pd.date_range('2013-08-01', '2013-08-05', freq='D'))\n > dates\n 0 2013-08-01\n 1 2013-08-02\n 2 2013-08-03\n 3 2013-08-04\n 4 2013-08-05\n dtype: datetime64[ns]\n \n > dateidx in dates\n False\n \n > dateidx |in_df| dates\n True\n \n```\n\n~~ \n`in` 演算子の実体である `__contains__`(special method)を再定義するという方法もあります。\n\n```\n\n > dateidx = datetime.datetime(2013,8,1,0,0)\n > dateidx\n datetime.datetime(2013, 8, 1, 0, 0)\n \n > dates = pd.Series(pd.date_range('2013-08-01', '2013-08-05', freq='D'))\n > dates\n 0 2013-08-01\n 1 2013-08-02\n 2 2013-08-03\n 3 2013-08-04\n 4 2013-08-05\n dtype: datetime64[ns]\n \n > dateidx in dates\n False\n \n > type(dates)\n pandas.core.series.Series\n \n > pd.core.series.Series.__contains__ = lambda self, item: item in self.tolist()\n > dateidx in dates\n True\n \n```\n\nただし、再定義をしてしまうと `pandas.core.series.Series` オブジェクトに対する `in` 演算子本来の使い方(data\nframe の index を対象)ができなくなります。\n\n```\n\n > 1 in dates\n False # 再定義していない場合は True となる\n \n```\n\n~~", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T02:03:55.243", "id": "18103", "last_activity_date": "2015-10-27T13:03:58.263", "last_edit_date": "2015-10-27T13:03:58.263", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "18056", "post_type": "answer", "score": 0 } ]
18056
18066
18066
{ "accepted_answer_id": null, "answer_count": 2, "body": "Youtube data api v3をJava用のクライアントをつかって使用しています。\n\n```\n\n YouTube.Channels.List channelRequest = youTube.channels().list(\"id, snippet, contentDetails\");\n channelRequest.setMine(true);\n channelRequest.setMaxResults(10L);\n channelRequest.setFields(\"items(id,snippet/title)\");\n channelRequest.setOauthToken(mToken);\n ChannelListResponse channels = channelRequest.execute();\n List<Channel> listOfChannels = channels.getItems();\n \n```\n\nこのようにして認証されたユーザーのチャンネルIDをリクエストしているのですが、ユーザーが複数のチャンネルを所持していても1つのレスポンスし返ってきません。 \n1アカウントで複数のチャンネルを所持している場合はどのようにリクエストすればいいのでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T13:09:24.263", "favorite_count": 0, "id": "18059", "last_activity_date": "2016-02-24T10:19:49.040", "last_edit_date": "2015-10-25T14:18:01.227", "last_editor_user_id": "7290", "owner_user_id": "12785", "post_type": "question", "score": 2, "tags": [ "android", "java", "youtube-data-api" ], "title": "Youtube data apiで1つのGoogleアカウントで複数のチャンネルを持ってる場合のリクエスト方法", "view_count": 1011 }
[ { "body": "<https://stackoverflow.com/questions/26515743/youtube-api-channel-selector> \n現在androidにビルドインされているOAuth2認証方法だとchannelは選べない仕様っぽいです。webviewで実装していきます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T11:44:53.250", "id": "18172", "last_activity_date": "2015-10-28T15:57:50.983", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "12785", "parent_id": "18059", "post_type": "answer", "score": -1 }, { "body": "アカウント(token)とチャンネルは1対1の関係になっているので、1つのtokenでは1つのチャンネルしか返ってきません。 \nユーザが複数のチャンネルを持っている時、2つ目以降のチャンネルに対しては仮想的なアカウントが生成されて紐付けられています。 \noAuth認証するときに、チャンネルを複数持っているユーザであれば「チャンネルセレクト」の画面が出て、選択されたチャンネルによって別のtokenが返ってきます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-02-24T10:19:49.040", "id": "22484", "last_activity_date": "2016-02-24T10:19:49.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7616", "parent_id": "18059", "post_type": "answer", "score": 1 } ]
18059
null
22484
{ "accepted_answer_id": null, "answer_count": 2, "body": "jQueryでスクロール位置によってコンテンツを表示させています。 \nその中で、表示後にその中の画像の位置を変更してアニメーションさせている部分があるのですが、スクロールごとに何度も動いてしまいます(1回だけで止めたい)\n\n```\n\n $(window).scroll(function() {\n var scroll = $(window).scrollTop();\n var windowHeight = $(window).height();\n $('#box1').each(function() {\n var boxPos = $(this).offset().top;\n if(scroll > boxPos - windowHeight + 300){\n $(this).find('.transparence').animate({\n 'opacity': '1'\n }, 600);\n $(this).find('.textarea').delay(400).animate({\n 'opacity': '1',\n }, 600, function() {\n $('#moveimg01').delay('200').animate({\n 'left': '270px',\n 'bottom': '20px'\n }, 300, function() {\n $('#moveimg01').animate({\n 'left': '250px',\n 'bottom': '0'\n }, 200);\n });\n });\n }\n });\n $('#box2').each(function() {\n var boxPos = $(this).offset().top;\n if(scroll > boxPos - windowHeight + 300){\n $(this).find('.transparence').animate({\n 'opacity': '1'\n }, 600, function() {\n $('#moveimg02').delay(200).animate({\n 'right': '-20px',\n 'top': '40px'\n }, 300, function() {\n $('#moveimg02').animate({\n 'right': '0',\n 'top': '60px'\n }, 200);\n });\n });\n $(this).find('.textarea').delay(400).animate({\n 'opacity': '1',\n }, 600);\n }\n }); ・・・続く\n \n```\n\nこの最後の\n\n```\n\n $('#moveimg01').animate({\n 'left': '250px',\n 'bottom': '0'\n }, 200);\n \n```\n\nの部分でそれぞれ止めたいのですが、スクロールするたびに何度も動いてしまいます。 \nこの部分で止める方法、もっとほかの書き方などありますでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-25T17:19:47.690", "favorite_count": 0, "id": "18063", "last_activity_date": "2015-10-30T13:17:10.510", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12964", "post_type": "question", "score": 0, "tags": [ "jquery" ], "title": "jQueryでのスクロールイベント中にanimateを止めたい", "view_count": 1868 }
[ { "body": "画面内の要素位置をスクロールするたびに記録しておき \n($(anim要素).offset().top + $(anim要素).outerHeight()) -\n$(window).scrollTop()がマイナス値 -> プラス値になったとき \nまたは \n$(anim要素).offset().top - ($(window).scrollTop() + $(window).height())がプラス値 -> \nマイナス値になったとき \nにアニメーションさせればいいんでないでしょうか。\n\n前の要素位置は$(anim要素).data('before', beforePos);で要素ごとにセットしておけばいいかと", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T03:26:04.090", "id": "18075", "last_activity_date": "2015-10-26T03:26:04.090", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12894", "parent_id": "18063", "post_type": "answer", "score": 1 }, { "body": "JSで各要素の状態を保持しておく方法もあると思いますが、 \n自分がよくとる方法は、htmlのclassで状態を管理してJSで判別するやり方です。\n\n`#moveimg01`要素に`.toAnimate`等のクラスをつけておいて、\n\n```\n\n $('#box1').hasClass('toAnimate').each(function() {\n var boxPos = $(this).offset().top;\n if(scroll > boxPos - windowHeight + 300){\n $('#box1').removeClass('toAnimate') // ここでクラスを消します\n // ... 省略 ...\n }, 300, function() {\n $('#moveimg01').animate({\n 'left': '250px',\n 'bottom': '0'\n }, 200);\n });\n });\n }\n });\n \n```\n\nなどと記述すれば、一度アニメーションした後はアニメーションしなくなるかと思います。\n\n```\n\n $('#box1.toAnimate').each(\n \n```\n\nでもよいですね。\n\n似たやり方で、動いた要素に`.isAnimated`などのクラスを付与して、 \nクラスを持っていたら処理をさせない、というやり方もあるかと思います。\n\n* * *\n\n質問とは関係ないですがコードに気になった点があったので書きます。\n\n 1. `$('#box1').each(...`など同IDのを持つ要素は存在しないはずなのに `.each()`を使っている\n\n=> この部分 each() である必要ありますか?確認してみてください。\n\n 2. `$('#moveimg01')`など同要素を複数回取得している\n\n=> 取得回数(要素の検索回数)が多くなる = 処理が遅くなる ですので、\n\n``` var $target = $('#moveimg01');\n\n $target.delay('200').animate({\n // ... 省略 ...\n }, 300, function() {\n $target.animate({\n // ... 省略 ...\n }, 200);\n });\n \n```\n\nみたいに書くといいですよ。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-30T12:01:54.287", "id": "18249", "last_activity_date": "2015-10-30T13:17:10.510", "last_edit_date": "2015-10-30T13:17:10.510", "last_editor_user_id": "8872", "owner_user_id": "8872", "parent_id": "18063", "post_type": "answer", "score": 0 } ]
18063
null
18075
{ "accepted_answer_id": "18072", "answer_count": 2, "body": "Spring bootで\n<http://blog.rakugakibox.net/entry/2014/11/23/java_spring_boot_rest>\nを参考にしてRest APIを作成しています。下記コントローラに対して、curlを使ってPOSTリクエストを送ると`Method now\nallowed`エラーが出てしまいます。\n\nコントローラ\n\n```\n\n package controllers;\n \n import java.util.ArrayList;\n import java.util.List;\n \n import org.springframework.http.HttpHeaders;\n import org.springframework.http.HttpStatus;\n import org.springframework.http.ResponseEntity;\n import org.springframework.web.bind.annotation.ModelAttribute;\n import org.springframework.web.bind.annotation.PathVariable;\n import org.springframework.web.bind.annotation.RequestMapping;\n import org.springframework.web.bind.annotation.RequestMethod;\n import org.springframework.web.bind.annotation.RestController;\n import org.springframework.web.util.UriComponentsBuilder;\n \n import models.HogeData;\n \n @RestController\n @RequestMapping(\"/hoges\")\n public class HogeController {\n private static List<HogeData> store = new ArrayList<HogeData>();\n \n @RequestMapping(method = RequestMethod.POST)\n public ResponseEntity<HogeData> post(@ModelAttribute HogeData hogeData, UriComponentsBuilder builder){\n store.add(hogeData);\n HttpHeaders headers = new HttpHeaders();\n headers.setLocation(builder.path(\"/hoges/{id}\").buildAndExpand(store.size()).toUri());\n return new ResponseEntity<>(hogeData, headers, HttpStatus.CREATED);\n }\n \n @RequestMapping(method = RequestMethod.GET)\n public List<HogeData> getter(){\n return store;\n }\n \n @RequestMapping(value = \"{id}\", method = RequestMethod.GET)\n public HogeData get(@PathVariable int id){\n return store.get(id - 1);\n }\n \n }\n \n```\n\ncurl\n\n```\n\n curl -i -H \"Accept: application/json\" -d \"integer=1\" -d \"string=aaa\" -d \"strings=AAA1\" -d \"strings=AAA2\" -d \"strings=AAA3\" http://localhost:8080/hoges\n \n```\n\nレスポンス\n\n```\n\n HTTP/1.1 405 Method Not Allowed\n Server: Apache-Coyote/1.1\n Allow: HEAD, GET\n Content-Type: application/json;charset=UTF-8\n Transfer-Encoding: chunked\n Date: Mon, 26 Oct 2015 00:13:44 GMT\n \n {\"timestamp\":1445818424033,\"status\":405,\"error\":\"Method Not Allowed\",\"exception\":\"org.springframework.web.HttpRequestMethodNotSupportedException\",\"message\":\"Request method 'POST' not supported\",\"path\":\"/hoges\"}\n \n```\n\n実行環境 \nOS: Mac OS X El Captan \nビルド: Gradleで`gradle bootRun`を実行\n\nコントローラでPOSTリクエストに対するメソッドは定義しているのでできるはずですがなぜかできません。なぜだかわかりますか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T00:22:27.883", "favorite_count": 0, "id": "18067", "last_activity_date": "2015-10-26T02:00:41.303", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "java", "spring" ], "title": "Spring boot でMethod not allowedエラー", "view_count": 8036 }
[ { "body": "curlのリクエストがGETになっています。\n\n```\n\n -X POST\n \n```\n\nオプションを付与して呼び出すことでPOSTリクエストになります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T00:33:10.467", "id": "18068", "last_activity_date": "2015-10-26T00:33:10.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10724", "parent_id": "18067", "post_type": "answer", "score": 0 }, { "body": "自己解決しました。\n\nプロジェクトのパッケージ構造が間違っていてコントローラのクラスはスターティングポイントであるApplicationクラスのあるパッケージ配下に置く必要がありましたがそれができていませんでした。\n\n```\n\n src\n ├── main\n │   └── java\n │   └── restexample\n │   └── app\n │   ├── Application.java\n │   ├── controllers\n │   │   └── HogeController.java\n │   └── models\n │   └── HogeData.java\n └── test\n └── java\n \n```\n\n上記のように構成を変更することで正しく呼び出せるようになりました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T02:00:41.303", "id": "18072", "last_activity_date": "2015-10-26T02:00:41.303", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "parent_id": "18067", "post_type": "answer", "score": 0 } ]
18067
18072
18068
{ "accepted_answer_id": "18070", "answer_count": 1, "body": "お世話になります。\n\nC#(.net 4.5)を使用してメールを送信するプログラムを勉強しています。\n\nとりあえず適当な文章でも送信してみようと、自分あてに簡単な文章を \n送ろうと、下記のサイト様のコードをそのまま引用したのですが、実行時に \n『追加情報:構文エラーです。コマンドが認識できません。サーバーの応答:Hello there』 \nとでてしまい、送れません。\n\n<http://dobon.net/vb/dotnet/internet/smtpclient.html#section2>\n\nSMTPサーバー名、ポート番号、それぞれ自分が今使っているものを入力して \n試しているので、多分問題はないとおもうのですが、原因が解りません。\n\n原因と対策をお教えいただけますでしょうか。\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T00:49:19.843", "favorite_count": 0, "id": "18069", "last_activity_date": "2015-10-26T00:58:52.423", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9374", "post_type": "question", "score": 0, "tags": [ "c#" ], "title": "C# メールを送信できない", "view_count": 1435 }
[ { "body": "暗号化の設定まで一致していますか? 例えば[SmtpClient.Portプロパティ](https://msdn.microsoft.com/ja-\njp/library/system.net.mail.smtpclient.port\\(v=vs.110\\).aspx)を既定値の25ではなく587とする場合は[SmtpClient.EnableSslプロパティ](https://msdn.microsoft.com/ja-\njp/library/system.net.mail.smtpclient.enablessl\\(v=vs.110\\).aspx)の設定が必要です。ポート465だと`SmtpClient`クラスでは無理かな…?", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T00:58:52.423", "id": "18070", "last_activity_date": "2015-10-26T00:58:52.423", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "18069", "post_type": "answer", "score": 2 } ]
18069
18070
18070
{ "accepted_answer_id": "22425", "answer_count": 1, "body": "GoogleAnalyticsの「ユーザー属性とインタレスト\nカテゴリに関するレポートの利用」のためIDFA(広告主識別子)を有効にしたいのですが、libAdIdAccess.aがcocoapod経由で取得したGoogleAnalytics内には存在しません。SDKを手動ダウンロードすれば、libAdIdAccess.aのファイルがあるのですが、それをプロジェクトに追加することでよいのでしょうか?\n\nよろしくお願い致します。\n\nXcode7.1 \nGoogleAnalytics (3.13.0) \niOS8以上をサポート", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T01:46:46.013", "favorite_count": 0, "id": "18071", "last_activity_date": "2016-02-23T06:19:19.483", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2772", "post_type": "question", "score": 1, "tags": [ "ios", "swift", "xcode" ], "title": "GoogleAnalytics iOS SDKをcocoapodで取得した場合のlibAdIdAccess.aはどのようにインストールしたらよいか?", "view_count": 268 }
[ { "body": "Podfileに下記を追加して、`pod install`し直すと入ります。\n\n```\n\n pod 'GoogleIDFASupport'\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-02-23T06:19:19.483", "id": "22425", "last_activity_date": "2016-02-23T06:19:19.483", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14511", "parent_id": "18071", "post_type": "answer", "score": 0 } ]
18071
22425
22425
{ "accepted_answer_id": null, "answer_count": 0, "body": "サーバーからソケット通信で受け取った800バイトの音源データ(PCM8bit8khz)を再生したいのですが、現在解決に至っておりません。 \nAVAudioPlayerのinitWithdataを使えば良いのではと思い以下のコードを動かしてみたのですが、\n\n```\n\n //関数の呼び出しaudioDataは受け取ったデータ\n [self prepareAudio:audioData];\n \n 〜\n \n \n //デリゲートメソッドなど\n -(void)prepareAudio:(NSData*)data\n {\n \n self.player.delegate = self;\n NSError *error = nil;\n \n player = [[AVAudioPlayer alloc] initWithData:data fileTypeHint:AVFileTypeCoreAudioFormat error:&error];\n \n if ( error != nil )\n {\n NSLog(@\"Error %@\", [error localizedDescription]);\n }\n [self.player prepareToPlay];\n \n \n }\n \n #pragma mark - AVAudioPlayerDelegate\n -(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag\n {\n if ( flag )\n {\n NSLog(@\"Done\");\n // [self.playButton setTitle:@\"Start\" forState:UIControlStateNormal];\n \n // Can start next audio?\n }\n }\n \n```\n\n**Error 操作を完了できませんでした。(OSStatus エラー 1954115647。)**\n\nと表示されてします。(どうやらAVAudioで読み込めない形式というエラー?) \nAVFileTypeCoreAudioFormatをいろいろ変更してもだめでした。\n\nAndroidでは以下のコードで動いているため、\n\n```\n\n bufSize = AudioTrack.getMinBufferSize(\n 8000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_8BIT);\n audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,\n 8000, //[Hz]\n AudioFormat.CHANNEL_OUT_MONO,\n AudioFormat.ENCODING_PCM_8BIT, //[bit]\n bufSize, //[byte]\n AudioTrack.MODE_STREAM);\n audioTrack.play();\n \n 〜〜〜\n \n // soundByteが音声データ\n audioTrack.write(soundByte, 0, soundByte.length);\n \n```\n\nこちら側で変換してやる必要があると思い、Core Audioを用いた変換を試していますが現在試行錯誤している段階です。\n\n<http://objective-audio.jp/2008/03/core-audio-audiostreambasicdes.html> \n<https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/AudioConverterServicesReference/#//apple_ref/c/func/AudioConverterNew>\n\n```\n\n AudioStreamBasicDescription wavFormat;\n wavFormat.mSampleRate = 8000.0;\n wavFormat.mFormatID = kAudioFormatLinearPCM;\n wavFormat.mFormatFlags = kAudioFormatFlagIsPacked; //WAVの8bitはunsigned\n wavFormat.mBitsPerChannel = 8;\n wavFormat.mChannelsPerFrame = 1;\n wavFormat.mFramesPerPacket = 1;\n wavFormat.mBytesPerFrame = 1;\n wavFormat.mBytesPerPacket = 1;\n wavFormat.mReserved = 0;\n \n```\n\n800k8hzなので、上記のようなAudioStreamBasicDescriptionかなと思ってますが、上記をどのように利用するのかでつまずいております。\n\nご教示いただければ幸いです。 \nよろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T04:31:43.597", "favorite_count": 0, "id": "18078", "last_activity_date": "2015-10-26T04:31:43.597", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12972", "post_type": "question", "score": 1, "tags": [ "objective-c" ], "title": "Objective-CでNSDataからPCM8bitへの変換方法について", "view_count": 327 }
[]
18078
null
null
{ "accepted_answer_id": "18081", "answer_count": 1, "body": "html2Canvasの\n[DOMを画像に書き出す方法](https://ja.stackoverflow.com/questions/5851/dom%E3%82%92%E7%94%BB%E5%83%8F%E3%81%AB%E6%9B%B8%E3%81%8D%E5%87%BA%E3%81%99%E6%96%B9%E6%B3%95/5862#5862)\nを参考にさせていただき、コードを書いたのですが、\n\nスクリーンショットを撮るボタンを押しても、空の画像ファイルが生成されるだけです。 \nクリアボタンも効きません...。 \n私が、ターゲットとなるdivの中で、img srcにphp変数を使用しているからなのでしょうか? \nしかしローカルファイルに置換してもダメでした。\n\n```\n\n <div id=\"target_screen\">\n <?php\n echo \"<img class=\\\"effectedImage\\\" src=\\\"$image\\\">\";\n ?>\n </div>\n \n```\n\nテストとして、この画面下部にスクリーンショットを表示しようとしていますが、 \n最終的には、取得した画像を別のphpへpostしたいと考えています。\n\nご教授願います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T04:46:13.157", "favorite_count": 0, "id": "18079", "last_activity_date": "2015-11-25T06:20:06.583", "last_edit_date": "2017-04-13T12:52:38.920", "last_editor_user_id": "-1", "owner_user_id": "12973", "post_type": "question", "score": 1, "tags": [ "javascript", "php", "html5", "html5-canvas" ], "title": "html2canvasでキャプチャした画像が空になる", "view_count": 4540 }
[ { "body": "HTMLページと同じオリジン(由来、大抵ドメインで決まります)の画像を使用していますか? \nCanvas要素に別オリジンの要素を描画した場合、そのCanvas要素の内容は取り出せなくなります。 \nセキュリティ上の制約です。 \nこの制約がないと、本人しか閲覧できないはずの写真をJavaScriptで盗む、といった事が可能になるからです。\n\n自分が所有しているサーバ同士であれば、同じオリジンとして扱う方法もあるようです。<https://developer.mozilla.org/ja/docs/Web/HTML/CORS_enabled_image>", "comment_count": 12, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T05:33:18.757", "id": "18081", "last_activity_date": "2015-10-26T05:33:18.757", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "18079", "post_type": "answer", "score": 0 } ]
18079
18081
18081
{ "accepted_answer_id": "18083", "answer_count": 2, "body": "Javaで毎分、0秒になったら処理を行いたいのですがどうすればいいのでしょうか?\n\n下の例のように`while`を使う方法もありますが、getInstanceを何度も呼び出しているので、あまりいい方法ではないように思います。\n\nTimerやscheduleを見ても、指定した秒数後に処理を実行することはできるようですが、指定秒になったら実行するようなものはありませんでした。\n\n何か他にいい方法はあるのでしょうか?\n\n```\n\n \n Calendar cal;\n while (true) {\n cal = Calendar.getInstance();\n if (cal.get(Calendar.SECOND) == 0) { // もし、calの秒が0秒なら\n // do something...\n }\n }\n \n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T06:16:27.577", "favorite_count": 0, "id": "18082", "last_activity_date": "2015-10-27T01:27:34.833", "last_edit_date": "2015-10-26T06:32:54.673", "last_editor_user_id": "5246", "owner_user_id": "5246", "post_type": "question", "score": 2, "tags": [ "java" ], "title": "Javaで毎分、0秒になったら処理を行う", "view_count": 2342 }
[ { "body": "Javaの標準機能であれば、`ScheduledExecutorService`というクラスがあります。 \nこのクラスを利用して下記のようなコードとした場合、60秒ごとにRunnableを継承したクラスの処理を実行することができます。\n\n```\n\n ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);\n scheduler.scheduleAtFixedRate(Runnableを継承したクラス, 0, 60, TimeUnit.SECONDS);\n \n```\n\n**2015/10/27追記** \n`ScheduledExecutorService`クラスを利用して指定秒に実行する方法ですが、 \n例えば下記のコードのように、処理を繰り返すためのサービスと、繰り返し処理を起動ためのサービスの2つを定義し、繰り返し処理起動後に起動サービスを停止してしまえば、あとは指定秒に実行されるようになります。\n\n```\n\n // 繰り返し処理用のサービス\n final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);\n // 繰り返し処理起動用のサービス\n final ScheduledExecutorService startScheduler = Executors.newScheduledThreadPool(1);\n // 繰り返し処理の内容\n final Runnable runner = () -> System.out.println(new Date());\n // 繰り返し処理の起動を行うためのRunnable\n final Runnable starter = () -> {\n final Calendar cal = Calendar.getInstance();\n if (0 == cal.get(Calendar.SECOND)) {\n scheduler.scheduleAtFixedRate(runner, 0, 60, TimeUnit.SECONDS);\n // 繰り返し処理が開始されたら起動サービスは停止\n startScheduler.shutdown();\n }\n };\n // 起動サービスをスタート\n startScheduler.scheduleAtFixedRate(starter, 0, 1, TimeUnit.SECONDS);\n \n```\n\nこのようにすることで、初回起動までは`Calendar.getInstance()`が複数回呼ばれてしまいますが、一度繰り返し処理起動した後は`Calendar.getInstance()`は呼ばれなくなります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T06:38:12.010", "id": "18083", "last_activity_date": "2015-10-27T01:27:34.833", "last_edit_date": "2015-10-27T01:27:34.833", "last_editor_user_id": "10724", "owner_user_id": "10724", "parent_id": "18082", "post_type": "answer", "score": 5 }, { "body": "ライブラリには疎いので、自前で作るならこんな感じでしょうか。 \ngetInstance を呼ぶ頻度を減らしてみました。\n\n```\n\n while (true) {\n Calendar cal = Calendar.getInstance();\n int sec = cal.get(Calendar.SECOND);\n if (sec == 0) { // もし、calの秒が0秒なら\n System.out.println(\"do something\");\n // 処理に1秒かからなかった場合の対処。\n Thread.sleep(1000);\n } else if (sec < 59) {\n Thread.sleep((59 - sec) * 1000);\n } else {\n // うるう秒対策込み\n Thread.sleep(1000);\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T13:36:11.710", "id": "18091", "last_activity_date": "2015-10-26T13:36:11.710", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5288", "parent_id": "18082", "post_type": "answer", "score": 1 } ]
18082
18083
18083
{ "accepted_answer_id": "18086", "answer_count": 1, "body": "プロトコルへの適合チェック(is,as)は、@objcで修飾したプロトコルものに限定されるみたいなのですが、@objcで修飾されていないプロトコルを適合したクラス、構造体は、プログラマが実装時に責任を持つことになるのですか?\n\n@objcで修飾されていないプロトコルはどうのように考えるべきなのですか。 \nなにかピンときません。\n\n教えてください", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T07:49:55.797", "favorite_count": 0, "id": "18084", "last_activity_date": "2015-10-26T09:14:48.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "11148", "post_type": "question", "score": 1, "tags": [ "swift" ], "title": "プロトコルについて", "view_count": 155 }
[ { "body": "それは昔のSwiftの制限ではないでしょうか。初期のSwiftはランタイムの制限により実行時にプロトコルの適合を判断できませんでしたが、現在は`@objc`の付いてないプロトコルに対しても、`is`、`as`でプロトコルに適合しているかどうかをチェックすることができます。\n\nより詳しくは下記のドキュメントの「Checking for Protocol Conformance」のところをご覧ください。\n\n> Checking for Protocol Conformance \n> You can use the is and as operators described in Type Casting to check for\n> protocol conformance, and to cast to a specific protocol. Checking for and\n> casting to a protocol follows exactly the same syntax as checking for and\n> casting to a type: \n>\n> <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html>", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T09:14:48.193", "id": "18086", "last_activity_date": "2015-10-26T09:14:48.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "18084", "post_type": "answer", "score": 5 } ]
18084
18086
18086
{ "accepted_answer_id": null, "answer_count": 0, "body": "いつもお世話になっております。\n\nCordovaとCrossWalkを用いてツールアプリを開発しております。\n\n今年2015年夏モデルのXperiaZ4やGalaxyS6_Edgがarm64-v8aだと知ったのですが、CrossWalkのHPから「Cordova\nAndroid」の[Stable]をDLしたところ、libsフォルダ内にはarmeabi-v7aに対応したsoファイルしかありませんでした。\n\nCrossWalkを扱った方で、XperiaZ4やGalaxyS6_Edgなどのarm64-v8aに対応させた方がいらっしゃいましたらご教示のほどよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T08:09:39.760", "favorite_count": 0, "id": "18085", "last_activity_date": "2015-10-26T08:09:39.760", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "11154", "post_type": "question", "score": 1, "tags": [ "android", "monaca", "cordova" ], "title": "CrossWalkのarm64-v8a対応に関して", "view_count": 163 }
[]
18085
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "playボタンを押すと指定した数のimageViewが順番にアニメーションします。それと同時にそれぞれのアニメーションに合わせて効果音が鳴るようにしたいです。 \nしかし、現時点では音がimageViewの個数分なってからアニメーションが順番に始まります。\n\n調べても分からなかったので質問させていただきました。 \nよろしくお願い致します。\n\n【ViewController.m】\n\n```\n\n -(IBAction)play:(id)sender {\n \n for(i = 0;i < repeatCount;i++){ //iは指定したimageViewの番号\n \n [self animation];\n [clapInstance repeatClap:repeatCount];\n }\n }\n \n \n -(void)animation{\n \n //ここまではUIImageviewのimageViewを生成(省略)\n \n // アニメーション\n [UIView animateWithDuration:0.5f\n delay:0.1f + 0.5f * i\n options:UIViewAnimationOptionCurveEaseInOut\n animations:^{\n imageView.transform = CGAffineTransformMakeTranslation(0, 550);\n \n } completion:^(BOOL finished) {\n }];\n }\n \n```\n\n【Clap.m】\n\n```\n\n -(void)repeatClap:(int)repeatCount {\n \n AudioServicesPlaySystemSound(soundID);\n usleep(500000);\n \n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T09:41:04.917", "favorite_count": 0, "id": "18087", "last_activity_date": "2015-10-26T09:41:04.917", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12952", "post_type": "question", "score": 1, "tags": [ "objective-c", "xcode" ], "title": "imageViewをアニメーションさせながら効果音を流したい", "view_count": 80 }
[]
18087
null
null
{ "accepted_answer_id": "18151", "answer_count": 1, "body": "IntelliJでライブラリを作っているのですが、 \nSDKにはJava8を使用して、コンパイルレベルはJava7で行いたいです。 \nですが、いくら設定をしても、絶対にJava8でコンパイルされてしまいます。\n\n設定は Project language level を 7 にしています。 \n(モジュールも)\n\nArtifact で jar を出力しています。 \n出力後の jar を分解して class をのぞいてもやはり major52(Java8) としてコンパイルされています。\n\nどうすれば Java8SDK を使用して Java7 の jar を出力できるのでしょうか?", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T10:36:23.290", "favorite_count": 0, "id": "18088", "last_activity_date": "2015-10-28T02:11:58.730", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10346", "post_type": "question", "score": 2, "tags": [ "java", "intellij-idea" ], "title": "IntelliJでコンパイルレベルの指定", "view_count": 1035 }
[ { "body": "Project bytecode versionに1.7を指定して、その下の Per-module bytecode version\nにモジュールを追加、そのモジュールのTarget bytecode versionを1.7に指定すればJava7のclassになると思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T02:11:58.730", "id": "18151", "last_activity_date": "2015-10-28T02:11:58.730", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10724", "parent_id": "18088", "post_type": "answer", "score": 2 } ]
18088
18151
18151
{ "accepted_answer_id": null, "answer_count": 1, "body": "プログラムのコードとエラー文を下記に示します。どうすればエラーが解消されるか教えてください。また、csvファイルを使用しているのでそのファイルも下記に示します。よろしくお願いします。\n\n以下のようなrubyのプログラムを書いています。\n\n```\n\n require 'csv'\n hash = Hash.new\n File.foreach('sample.csv') do |row|\n col = row.chomp.split(\",\")\n if col.length > 4\n for i in 3..col.length-1\n txt += col[i] + \",\"\n end\n end\n if hash{:col[2]} == nil\n hash{:col[2]} = 1\n else\n hash{:col[2]} += 1\n end\n end\n puts hash.keys\n \n```\n\n**エラーメッセージ**\n\n```\n\n prog$ ruby freq.rb\n freq.rb:12: syntax error, unexpected '=', expecting kEND\n hash{:col[2]} = 1\n ^\n freq.rb:14: syntax error, unexpected tOP_ASGN, expecting kEND\n hash{:col[2]} += 1\n ^\n prog$\n \n```\n\n**CSVファイル**\n\n```\n\n 6,2,4,\"<p>One option would be to clone your startup drive to an external disk using something like SuperDuper! or Carbon Copy Cloner. Then you can use System Preferences->Startup Disk to select that external drive as the boot drive. </p>\n \n <p>Once you've rebooted and are running the system off the external drive you can use Disk Utility to run the repair. After you're done, re-select the internal drive as the Startup Disk and reboot.</p>\"\n (省略)\n 27,2,12,\"<p>They aren't really \"\"in memory,\"\" more like cached to disk if and when necessary. Many apps don't even use the multitasking or aren't setup for it. When you switch it does actually close the app.</p>\n \n <p>Being in the task bar doesn't guarantee that it's actually in memory, actively running, or both. The OS manages that. </p>\"\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T14:52:48.093", "favorite_count": 0, "id": "18093", "last_activity_date": "2015-10-26T16:07:29.893", "last_edit_date": "2015-10-26T15:10:29.140", "last_editor_user_id": null, "owner_user_id": "9505", "post_type": "question", "score": -1, "tags": [ "ruby", "csv" ], "title": "rubyで数を数えるプログラムのエラーを解消する方法を教えてください。", "view_count": 201 }
[ { "body": "文法的な問題です。Hash の値の参照方法が間違っています。 \n`hash{:col[2]}` を `hash[col[2]]` とすればエラーは解消すると思います。\n\nそれより、`require 'csv'` しているのに、CSV の機能を一切使わずに自力で CSV 形式の解析をしているのが気になりました。 \nたとえば、次のようにすれば CSV ファイルから1レコードずつ読むことができます。\n\n```\n\n CSV.foreach('sample.csv') do |row|\n ...\n end\n \n```\n\n「\"」のエスケープもちゃんと処理されるので、簡単です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T16:07:29.893", "id": "18095", "last_activity_date": "2015-10-26T16:07:29.893", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3249", "parent_id": "18093", "post_type": "answer", "score": 3 } ]
18093
null
18095
{ "accepted_answer_id": "18096", "answer_count": 1, "body": "EC2のマシンタイプを誤って高額なものでWEBサイトを作ってしまいました。 \n無料と書いてあったのですが1時間$0.732、月額で固定費だけで6万円ほどかかり、さらに転送量などで倍近い12万円程になりそうです。\n\nしかし転送量は解決しました。CloudFrontを使うと一気に1/1000ほど値段が下がりました。また、CloudFrontの値段は2日で1ドルほどと格安で収まっています。\n\nマシンタイプを変えると、MariaDBやNginxのインストールなど全てのデータはどこに行ってしまうのでしょうか?\n\n◆ストレージは別で保管されていて、マシンタイプだけ変更すれば綺麗に移転できるのでしょうか?\n\n◆EC2インスタンス作成時にIPアドレスが付与されますが、これもVPC(?)で綺麗に維持できますか?\n\nインスタンスを停止すれば済む話ですが、SEO的に悪そうなので止められません。 \nAWS参考書を買ったのですが、慌ててるので文章がはっきり理解できません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T15:37:10.517", "favorite_count": 0, "id": "18094", "last_activity_date": "2017-06-19T05:11:12.253", "last_edit_date": "2017-06-19T05:11:12.253", "last_editor_user_id": "5793", "owner_user_id": "7973", "post_type": "question", "score": -1, "tags": [ "aws" ], "title": "AWS EC2 インスタンスタイプを変更した場合の影響について", "view_count": 3428 }
[ { "body": "仮想マシンのインスタンスサイズは任意に変更することができます。このとき仮想マシンの再起動を伴います。ストレージに格納された内容は維持されます。\n\n仮想マシンに標準で割り当てられているIPアドレスは、動的に割り当てられるもので、仮想マシンの再起動により異なるIPアドレスに変更される場合があります。ユーザーが操作しなくともAWS側のメンテナンスの都合で仮想マシンが移動する場合もあり、再起動しなければIPアドレスが維持されるものではありません。\n\nVPCで割り当てたIPアドレスはユーザー用に固定で確保されます。VPCで取得したIPアドレスは仮想マシンのインスタンスサイズを変更するなどしても、変わることはありません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-26T20:35:51.060", "id": "18096", "last_activity_date": "2015-10-26T20:35:51.060", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12774", "parent_id": "18094", "post_type": "answer", "score": 2 } ]
18094
18096
18096
{ "accepted_answer_id": null, "answer_count": 1, "body": "Monacaで開発しています。 \n`pageinit`時の`$(\"#id\").data(\"collapsed\",false)`は画面に反映されますが、 \n`pageshow`時の`$(\"#id\").data(\"collapsed\",false)`は画面に反映されていないように見えます。 \n原因と対処方法を教えていただきたいです。\n\n例えば`pageshow`時の`$(\"#id\").data(\"collapsed\",false)`の上下を \n`console.log($(\"#id\").data(\"collapsed\"))`で挟むと、\n\n```\n\n true\n false\n \n```\n\nとログに出るため確かにデータは変わっているのですが、画面のコラプシブルパネルは閉じたままです。 \n`pageinit`時は反映されるのに、`pageshow`時は反映されない原因が推測できません。 \n何かリロードのような作業が必要になるのでしょうか。\n\n`pageshow`の部分を`pagebeforeshow`に変更しても結果は変わりませんでした。 \n`data-collapsed`を書き換えるAPIを\n\n```\n\n $(\"#id\").attr(\"data-collapsed\",false);\n \n```\n\nとしても、やはり`pageinit`では反映されますが、`pageshow`では反映されませんでした。\n\n**■JavaScript**\n\n```\n\n $(document).on(\"pageinit\",\"#page1\",function(){\n $(\"#collap1\").data(\"collapsed\",true);\n $(\"#collap2\").data(\"collapsed\",false); //これは動く。\n //=collap2が開いた状態になる。\n //※特にcollap2が開いている必要は無いが検証のためfalseにした。\n $(\"#collap3\").data(\"collapsed\",true);\n \n $(document).on(\"pageshow\",\"#page2\",function(){\n //一旦全部閉じる\n $(\"#collap1\").data(\"collapsed\",true);\n $(\"#collap2\").data(\"collapsed\",true);\n $(\"#collap3\").data(\"collapsed\",true);\n //指定のコラプシブルパネルだけ開く。 ※反映されない\n $(\"#collap1\").data(\"collapsed\",false);\n //バインドされているのか確認\n console.log(\"動いてます\"); //これはログに表示されるから動いてはいるようだ。\n });\n });\n \n```\n\n**■HTML**\n\n```\n\n <div data-role=\"page\" id=\"page1\">\n <div data-role=\"content\">\n <a href=\"#page2>Link1</a>\n </div>\n </div\n <div data-role=\"page\" id=\"page2\">\n <div data-role=\"ui-content\">\n <div data-role=\"collapsible-set\">\n <div data-role=\"collapsible\" data-collapsed=\"true\" id=\"collap1\">\n <h3>Title1</h3>\n <ul data-role=\"listview\">\n <li><a href=\"#page1\">content1</a></li>\n <li><a href=\"#page1\">content2</a></li>\n <li><a href=\"#page1\">content3</a></li>\n </ul>\n </div>\n <div data-role=\"collapsible\" data-collapsed=\"true\" id=\"collap2\">\n <h3>Title2</h3>\n <ul data-role=\"listview\">\n <li><a href=\"#page1\">content4</a></li>\n <li><a href=\"#page1\">content5</a></li>\n <li><a href=\"#page1\">content6</a></li>\n </ul>\n </div>\n <div data-role=\"collapsible\" data-collapsed=\"true\" id=\"collap3\">\n <h3>Title3</h3>\n <ul data-role=\"listview\">\n <li><a href=\"#page1\">content7</a></li>\n <li><a href=\"#page1\">content8</a></li>\n <li><a href=\"#page1\">content9</a></li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-10-26T22:55:26.520", "favorite_count": 0, "id": "18097", "last_activity_date": "2019-09-09T15:02:39.860", "last_edit_date": "2019-09-09T15:02:39.860", "last_editor_user_id": "32986", "owner_user_id": "12766", "post_type": "question", "score": 1, "tags": [ "monaca", "jquery-mobile" ], "title": "pageshow時にコラプシブルパネルを開きたい", "view_count": 201 }
[ { "body": "解決策を見つけました。expandで開くことができました。 \n<http://demos.jquerymobile.com/1.2.0/docs/content/content-collapsible-\nmethods.html>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T23:52:44.987", "id": "18226", "last_activity_date": "2015-10-29T23:52:44.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12766", "parent_id": "18097", "post_type": "answer", "score": 1 } ]
18097
null
18226
{ "accepted_answer_id": "18164", "answer_count": 1, "body": "Railsの`form_for`ですが、\n\n```\n\n <%= form_for :hoge do |f| %>\n <% end %>\n \n```\n\nといったようにシンボルを渡せるようですが、基本的にオブジェクトを渡す例をネットでよく見かけます。シンボルを使う場面はどのようなときでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T00:05:14.800", "favorite_count": 0, "id": "18099", "last_activity_date": "2015-10-28T08:19:02.943", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "post_type": "question", "score": 4, "tags": [ "ruby-on-rails" ], "title": "Railsのform_forにシンボルを与えるときはどのようなときか?", "view_count": 2737 }
[ { "body": "シンボルを使うとよりシンプルなformタグが生成され、オブジェクトを渡すとそのオブジェクトに寄って良しなに出し分けてくれます。\n\n以下`form_for :post`とします。 \n具体的にはシンボルを使うと\n\n```\n\n <form action=\"/posts\" method=\"post\">\n \n```\n\n`@post = Post.new` したオブジェクトを使うと\n\n```\n\n <form action=\"/posts/create\" class=\"new_account\" id=\"new_account\" method=\"post\">\n \n```\n\n`@post = Post.find(1)` したオブジェクトを使うと\n\n```\n\n <form action=\"/posts/update\" class=\"edit_account\" id=\"edit_account_1\" method=\"post\">\n <input name=\"_method\" type=\"hidden\" value=\"put\">\n \n```\n\nがそれぞれ吐かれます。\n\n`new`や`edit`のviewを準備する時に、同じ`_form`部分テンプレートを利用した時、同じ書き方で出し分けてくれるのが便利。ということのようです。\n\nと以下を翻訳しただけです。 \n<https://stackoverflow.com/questions/957204/instance-variable-vs-symbol-in-\nruby-on-rails-form-for>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T08:19:02.943", "id": "18164", "last_activity_date": "2015-10-28T08:19:02.943", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "4072", "parent_id": "18099", "post_type": "answer", "score": 5 } ]
18099
18164
18164
{ "accepted_answer_id": null, "answer_count": 0, "body": "S3からRedShiftにデータを格納したいのですが、データが空の状態で格納されてしまいます。 \n(サーバー情報など一部データを伏せております)\n\n・S3に格納してあるデータ\n\n```\n\n {\"message\":\"unixtime:1445847958\\tdatetime:26/Oct/2015:17:25:58 +0900\\tx-forwaded-for:****\\thost:****\\tsize:0\\tresponse_time:606\\tstatus:200\\tserver:****\\tHost:****:GET\\tpath:****\\tprotocol:****\\treferer:-\\t}\n \n```\n\nredshift側ではcopyコマンドで `format as json 'auto' gzip` を指定しております。\n\nおそらくデータのフォーマットを変更してあげればいいと思うのですが、 \nどのように変更すればよろしいでしょうか?\n\nお手数ですがよろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2015-10-27T01:59:07.987", "favorite_count": 0, "id": "18101", "last_activity_date": "2020-04-07T05:58:37.983", "last_edit_date": "2020-04-07T05:58:37.983", "last_editor_user_id": "3060", "owner_user_id": "12918", "post_type": "question", "score": 1, "tags": [ "aws", "amazon-s3", "amazon-redshift" ], "title": "S3からRedShiftにcopyしてもデータが空になってしまう", "view_count": 84 }
[]
18101
null
null
{ "accepted_answer_id": "18110", "answer_count": 3, "body": "よろしくお願いします。\n\nc#とSQLiteでWindowsフォームアプリケーションを作成しています。 \nVisualStudio Community 2015, windows8.1を使用しています。\n\n複数あるボタンのうち1つをクリックすると、対応するTextBoxに「○」を出力させるという動きをさせたいと思っています。\n\nButton1をクリック → TextBox aaa,TextBox bbb に「○」が出力される \nButton2をクリック → TextBox aaa,TextBox ccc に「○」が出力される\n\nこのようなイメージです。\n\nボタンをクリックした時に○が出力されるTextBoxのnameはDBに入っており、 \nselect文で抽出する所までは出来ています。\n\n```\n\n using(SQLiteDaraReader reader = command.ExecuteReader())\n {\n while(reader.Read())\n {\n reader[\"TBox_name\"].Text = \"○\";\n }\n }\n \n```\n\n上記の形で試しましたが、失敗しました。\n\n私がやりたい事が上記のコードで伝わっているでしょうか?\n\n<http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1147000486> \nこちらが一番参考になりそうだと思ったのですが、 \nTextBoxの配列に直接書き込んでいるので私のやりたいこととは違いました。\n\n<http://oshiete.goo.ne.jp/qa/6273058.html> \nこちらも参考になるかと思いましたが、やはり直接書き込んでいます。\n\n私もTxtBoxの配列にnameを入れてみようと思って試しましたが、\n\n```\n\n using(SQLiteDaraReader reader = command.ExecuteReader())\n {\n while(reader.Read())\n {\n TextBox[] wTextBox = { reader[\"TBox_name\"] };\n }\n }\n \n```\n\nobjectやstringはTextBoxに変換できないとの事なので、困っています。\n\n参考になるサイトや意見など何でも良いので情報が欲しいです。 \nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T02:53:39.020", "favorite_count": 0, "id": "18105", "last_activity_date": "2015-10-27T06:41:44.633", "last_edit_date": "2015-10-27T05:40:54.953", "last_editor_user_id": "2383", "owner_user_id": "12797", "post_type": "question", "score": 1, "tags": [ "c#" ], "title": "c#フォームアプリでTextBoxのnameを動的に指定したい", "view_count": 6739 }
[ { "body": "[Controlsプロパテ](https://msdn.microsoft.com/ja-\njp/library/system.windows.forms.control.controls\\(v=vs.110\\).aspx)ィを使用することで動的にコントロールを選択することができます。\n\n```\n\n Controls[\"bbb\"].Text = \"○\";\n \n```\n\n* * *\n\nコメントに書かれたコードが無茶苦茶です。\n\n```\n\n string c = reader[\"koumoku_nm\"].ToString();\n if (c != null) {\n Controls[\"(reader['koumoku_nm'])\"].Text = \"○\";\n }\n \n```\n\nまず`null`かどうかを判定する前にToString()を呼び出してしまっていますので、「オブジェクト参照がオブジェクト\nインスタンスに設定されていません。」が発生する要因です。 \nまた動的にコントロールを選択するのではなく **\"(reader['koumoku_nm'])\"**\nという名前のコントロールを探そうとしています。そんな名前は存在するはずがありません。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T03:45:21.180", "id": "18109", "last_activity_date": "2015-10-27T06:41:44.633", "last_edit_date": "2015-10-27T06:41:44.633", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "18105", "post_type": "answer", "score": -1 }, { "body": "`Controls`プロパティのstringインデクサはあくまで`Controls`内しか検索しないため、フォーム直下に存在しない一般の場合では再帰的に処理を行う必要があります。\n\n実装例を挙げると以下のようになります。`Find`は指定したコントロール(=`parent`)の子孫にある`Name`が`name`のコントロールを探すメソッドです。\n\n```\n\n private static Control Find(Control parent, string name)\n {\n // まずparentの子コントロールでnameを検索します。\n var r = parent.Controls[name];\n \n // 子コントロールでnameが見つかった場合、該当コントロールを返します。\n if (r != null)\n {\n return r;\n }\n \n // parentの子コントロールでnameが見つからなかった場合、今度は子コントロールでFindを実行します。\n foreach (Control c in parent.Controls)\n {\n // TODO:必要ならcに対する条件を追加します。\n \n // 子コントロールcを起点にしてnameを検索します。\n r = Find(c, name);\n if (r != null)\n {\n // cの子孫にnameが見つかった場合、該当コントロールを返します。\n return r;\n }\n }\n \n // nameが見つからなかった場合、nullを返します。\n return null;\n }\n \n```\n\nまたリフレクションを用いてフィールドを探すこともできます。\n\n```\n\n typeof(Form1).GetField(textBox1.Name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this)\n \n```", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T04:08:25.020", "id": "18110", "last_activity_date": "2015-10-27T05:52:42.917", "last_edit_date": "2015-10-27T05:52:42.917", "last_editor_user_id": "5750", "owner_user_id": "5750", "parent_id": "18105", "post_type": "answer", "score": 0 }, { "body": "そもそも、DBから直接TextBoxを操作しようとしているのが間違っています。 \nドメイン(データベースなどへの操作)とビュー(表示)は、分離すべきです。\n\n代わりにINotifyPropertyChangedを実装したクラスを定義します。\n\n```\n\n class TextData : System.ComponentModel.INotifyPropertyChanged {\n public string Text {\n get{\n return this._Text;\n }\n set {\n if( this._Text == value )\n return;\n this._Text = value;\n this.PropertyChanged?.Invoke( this , new PropertyChangedEventArgs( nameof(Text) ) );\n }\n }\n private string _Text;\n \n public event PropertyChangedEventHandler PropertyChanged;\n }\n \n```\n\nドメイン(今回の場合DB)からの入出力は、このTextDataクラスに対して行います。\n\n**フォームの処理**\n\nフォームでは、TextBoxにTextDataオブジェクトをデータバインディングします。\n\n```\n\n textbox1.DataBindings( nameof( TextBox.Text ) ,\n textdata1 , nameof(TextData.Text) , true , \n DataSourceUpdateMode.Never );\n \n```\n\ntextdata1は、TextDataクラスのオブジェクトです。 \nこのようにすることで、textdata1オブジェクトのTextプロパティが変更されると、 \ntextbox1(TextBox)のTextプロパティが更新されるようになります。\n\n**データベースの処理**\n\nデータベースからは、TextBoxではなく、textdata1に対する操作に変更します。\n\n```\n\n using(SQLiteDaraReader reader = command.ExecuteReader()) {\n while(reader.Read()) {\n textdata1.Text = \"○\";\n }\n }\n \n```\n\n上記の例では、直接 textdata1 と指定していますがDictionaryなどを用いて管理しても構いません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T06:03:35.670", "id": "18121", "last_activity_date": "2015-10-27T06:03:35.670", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2207", "parent_id": "18105", "post_type": "answer", "score": 0 } ]
18105
18110
18110
{ "accepted_answer_id": "18115", "answer_count": 1, "body": "お世話になります。\n\nふと思いついて、こういうことはできるだろうかと思っての質問なのですが、 \nフォーム上ではなく、デスクトップの何もない場所でマウスのダブルクリックを \n拾って処理をさせたいと思ったのですが、C#でその方法があればお教えください。\n\n少しサイトで調べてみましたら、やはりAPIを使わないと無理だとかなんとか。 \nそれならそれでも仕方ないのですが、もしできるのであれば、C#のみでできる方法、 \n不可能ならばAPIを絡めた方法をお願いします。\n\n勿論、事前に非表示のC#で組んだプログラムが常駐のような形で動いているものとしてです。\n\n以上、よろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T04:14:23.123", "favorite_count": 0, "id": "18111", "last_activity_date": "2015-10-27T05:20:02.360", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9374", "post_type": "question", "score": 1, "tags": [ "c#" ], "title": "C# デスクトップの何もないところでのダブルクリックを拾いたい", "view_count": 1253 }
[ { "body": "デスクトップと言えど単なるウィンドウです。ウィンドウメッセージは`WindowProc`で処理されますが、これは[SetWindowLongPtr()](https://msdn.microsoft.com/en-\nus/library/ms644898\\(v=vs.85\\).aspx)を使うことでフックすることはできますが\n\n> An application can subclass a system class, but should not subclass a window\n> class created by another process.\n\nと記載されており外部からフックすべきではありません。 \nそれとは別に[SetWindowsHookEx()](https://msdn.microsoft.com/en-\nus/library/ms644990\\(v=vs.85\\).aspx)を使うことで外部からフックすることはできますが、[How to set a\nWindows hook in Visual C# .NET](https://support.microsoft.com/ja-\njp/kb/318804)でも\n\n> Global hooks are not supported in the .NET Framework\n\nと説明されているようにC#では実現できません。C/C++を使用したネイティブのDLLを作成する必要があります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T05:20:02.360", "id": "18115", "last_activity_date": "2015-10-27T05:20:02.360", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "18111", "post_type": "answer", "score": 1 } ]
18111
18115
18115
{ "accepted_answer_id": "18141", "answer_count": 2, "body": "[【Rails】fields_for と accepts_nested_attributes_for - kzy52's\nblog](http://kzy52.com/entry/2013/07/10/200144)\n\nにある通り\n\n> profile_attributes= と academics_attributes= メソッドが追加される\n\nといったような末尾が=のメソッド名はどのような利点があって、どのようなときに使うのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T05:13:20.793", "favorite_count": 0, "id": "18114", "last_activity_date": "2015-10-27T16:00:12.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "post_type": "question", "score": 5, "tags": [ "ruby-on-rails", "ruby" ], "title": "Rubyのメソッド名の末尾に = (イコール)", "view_count": 3196 }
[ { "body": "`hoge=` はいわゆるSetter です。 \n値をセットするときは `foo.hoge = bar` と書くことができます。 \n利点は メソッド名に「set..」「get..」を書かなくて良いという点でしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T09:28:41.443", "id": "18131", "last_activity_date": "2015-10-27T09:28:41.443", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "18114", "post_type": "answer", "score": 3 }, { "body": "通常のメソッドとの違いは、代入構文のように使用できる点です。\n\n`hoge=` メソッドを定義すると、`obj.hoge = value` のように `=` の前に空白があっても `hoge=` メソッドが呼び出せます。\n\nまた、メソッド内で戻り値を指定しても無視され、引数の値がそのまま返されます。 \nこれは、`foo = obj.hoge = value` のように使用した時に、ちゃんと foo に value が代入されるようにするためだと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T16:00:12.040", "id": "18141", "last_activity_date": "2015-10-27T16:00:12.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3249", "parent_id": "18114", "post_type": "answer", "score": 11 } ]
18114
18141
18141
{ "accepted_answer_id": null, "answer_count": 1, "body": "Monacaとnifty cloudで開発を行っております。 \nデータストアに保存したオブジェクトをdestroyで削除したいのですが、その場合にobjectIdを取得してきて削除すればよいのでしょうか? \nsample.get(\"objectId\");としてもobjectIdがundefinedで返って来てしまいます。 \nまた、そうでないのなら具体的な方法などをご教授お願い致します。\n\n```\n\n var Notice = NCMB.Object.extend(\"notice\");\n var noticeQuery = new NCMB.Query(\"notice\");\n \n var notice = new Notice();\n var array = new Array();\n \n noticeQuery.find({\n //成功時\n success: function(objects) {\n for(var i = 0; i < objects.length; i++) {\n array[i] = objects[i].get(\"objectId\");\n notice.set(\"objectId\", array[0]);\n notice.destroy();\n notice.save();\n }\n },\n \n //失敗時\n error: function(error) {\n //エラー表示\n alert('Failed to get object, with error code: ' + error.description);\n }\n });\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T05:33:57.503", "favorite_count": 0, "id": "18117", "last_activity_date": "2016-11-04T04:34:22.037", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12992", "post_type": "question", "score": 0, "tags": [ "monaca" ], "title": "NCMBのオブジェクトを削除したい。", "view_count": 606 }
[ { "body": "[http://mb.cloud.nifty.com/doc/current/datastore/basic_usage_javascript.html#オブジェクトの削除](http://mb.cloud.nifty.com/doc/current/datastore/basic_usage_javascript.html#%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%81%AE%E5%89%8A%E9%99%A4)\n\n1.2系はドキュメントもなくなってしまったので定かではありませんが…。\n\n` \nobjects[i].destroy({ \nsuccess: function() { \n// 削除完了 \n}, \nerror: function() { \n// 削除失敗 \n} \n}); \n`\n\nではうまくいかないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-03-02T01:06:19.693", "id": "22718", "last_activity_date": "2016-03-02T01:06:19.693", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "139", "parent_id": "18117", "post_type": "answer", "score": 1 } ]
18117
null
22718
{ "accepted_answer_id": "18190", "answer_count": 1, "body": "monacaにてアプリを作成しております \n既存のiosアプリをアップデートのためアップローダでアップロードしましたが \n以下のエラーメッセージでアップロードできませんでした \n何度もアップデートしているアプリですので初歩的な問題ではないように思われます \nアップローダーは3.0でだめだったため3.1にアップデートしましたがだめでした。 \n解決方法ご存知の方いらっしゃいましたらご教示いただけますでしょうか?\n\nERROR ITMS-90085: “No architectures in the binary. Lipo failed to detect any\narchitectures in the bundle executable.”", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T05:52:35.957", "favorite_count": 0, "id": "18119", "last_activity_date": "2015-10-29T03:50:34.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7987", "post_type": "question", "score": 1, "tags": [ "ios", "monaca" ], "title": "MONACAにて作成したiOSアプリがアップローダーでエラーのためアップロードできません", "view_count": 332 }
[ { "body": "xcodの最新版をインストールすることでアップローダも最新になり解決しました。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T03:50:34.473", "id": "18190", "last_activity_date": "2015-10-29T03:50:34.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7987", "parent_id": "18119", "post_type": "answer", "score": 0 } ]
18119
18190
18190
{ "accepted_answer_id": "18262", "answer_count": 1, "body": "Wappalyzerというwebサービスがありますが、使ってるサーバー、言語などがわかるというのはなんとなく理由が想像できるのですが、CMSなどなぜ分かってしまうのでしょうか?\n\nどのような仕組みで調べているのかご存知の方いましたら教えていただけるとありがたいです。 \nまた、Wordpressを使っていることを調べられたくないなど、情報を隠すことはどうすれば良いのでしょうか? \n時折、全く情報が出てこないサイトもあるので、何か対策をしているのかな? \nクローラーみたいな技術で調べ上げているとすると、まだ徘徊されてないので情報が表示されていないとか。。。\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T06:12:18.317", "favorite_count": 0, "id": "18122", "last_activity_date": "2015-10-30T22:04:22.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12907", "post_type": "question", "score": 2, "tags": [ "wordpress" ], "title": "Wappalyzerってどうしてわかるの?その他", "view_count": 1966 }
[ { "body": "[apps.json](https://github.com/AliasIO/Wappalyzer/blob/master/src/apps.json)\nにまとめられています。これの読み方は[wikiに説明](https://github.com/AliasIO/Wappalyzer/wiki/Specification)がありますが、ざっと見でも何となく分かりますね。 \nWordPressの判定部を下記に抜粋しましたが、JavaScriptのトップレベル変数、linkタグ、metaタグ、scriptタグあたりで判定しているようです。\n\n情報を隠すにはカスタマイズして、ここに挙げられているような`WordPress`や`wp-`、`wp.com`といったファイル名や変数名の類いを全て変更することになります。\n\n```\n\n \"WordPress\": {\n \"cats\": [\n 1,\n 11\n ],\n \"env\": \"^wp_username$\",\n \"html\": [\n \"<link rel=[\\\"']stylesheet[\\\"'] [^>]+wp-(?:content|includes)\",\n \"<link[^>]+s\\\\d+\\\\.wp\\\\.com\"\n ],\n \"implies\": \"PHP\",\n \"meta\": {\n \"generator\": \"WordPress( [\\\\d.]+)?\\\\;version:\\\\1\"\n },\n \"script\": \"/wp-includes/\",\n \"website\": \"wordpress.org\",\n \"icon\": \"WordPress.png\"\n },\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-30T22:04:22.277", "id": "18262", "last_activity_date": "2015-10-30T22:04:22.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "18122", "post_type": "answer", "score": 2 } ]
18122
18262
18262
{ "accepted_answer_id": null, "answer_count": 1, "body": "El capitanでRをインストールし直した。 \nCRANのミラーサイトに日本のリストが出ず、Chinaを選びました。 \ninstallはできたようですが、libraryを実行しません。何を修正すればいいでしょうか。\n\n```\n\n > install.packages(\"rafalib\")\n --- このセッションで使うために、CRAN のミラーサイトを選んでください --- \n URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/macosx/mavericks/contrib/3.2/rafalib_1.0.0.tgz' を試しています \n Content type 'application/octet-stream' length 39769 bytes (38 KB)\n ==================================================\n downloaded 38 KB\n \n ダウンロードされたパッケージは、以下にあります \n /var/folders/h1/ggcx_9t93jj_sl7pqjfnrz1c0000gn/T//RtmppBFupd/downloaded_packages \n > library(rafalib)\n > \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-10-27T07:17:19.930", "favorite_count": 0, "id": "18124", "last_activity_date": "2023-06-12T01:58:45.330", "last_edit_date": "2023-06-12T01:58:45.330", "last_editor_user_id": "3060", "owner_user_id": "12994", "post_type": "question", "score": 0, "tags": [ "r" ], "title": "Rインストールの不具合", "view_count": 156 }
[ { "body": "`rafalib/README.md` によると、\n\n```\n\n # installation\n \n install.packages(\"devtools\")\n library(devtools)\n install_github(\"ririzarr/rafalib\")\n \n```\n\nだそうです。\n\n※ `install.packages(\"devtools\")` でかなり時間がかかります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T07:30:07.547", "id": "18125", "last_activity_date": "2015-10-27T07:30:07.547", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "18124", "post_type": "answer", "score": 0 } ]
18124
null
18125
{ "accepted_answer_id": "18137", "answer_count": 1, "body": "`ocaml 4.02.3`において、以下のコマンドで`longident.ml`というファイルを \nコンパイルする際に下で示すエラーが表示されました。\n\n`longident.ml`の中身は`type t = int`のみで、他にファイルがないディレクトリでコンパイルしました。 \n`longident.ml`はコンパイラのコードで`parsing/longident.ml`が存在するため \n`ocamlcommon.cmxa`に含まれているからエラーになっていると思うのですが \nなぜ`compiler-libs`が以下のコンパイルコマンドで`ocamlfind`により認識されているのでしょうか?\n\nちなみに`-package`から`batteries`、`sexplib`のどちらかを外した時にも同様のエラーが発生しました。 \n`-package`を書かないで`ocamlfind opt`でコンパイルした時には通常通りコンパイルできました。 \n`.opam/package/`から`batteries`と`sexplib`の依存関係とその依存パッケージの依存関係を見ても`compiler-\nlibs`にdependしているという記述は見つけられませんでした。\n\n```\n\n ocamlfind opt -package batteries,sexplib.syntax -linkpkg -syntax camlp4o ./longident.ml \n findlib: [WARNING] Interface longident.cmi occurs in several directories: ., /home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs\n findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs, /home/tokuda/.opam/4.02.3/lib/ocaml\n File \"./longident.ml\", line 1:\n Error: Files ./longident.cmx\n and /home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs/ocamlcommon.cmxa\n both define a module named Longident\n \n```\n\n`-verbose`をつけた時の表示は以下のとおりです。\n\n```\n\n ocamlfind opt -package batteries,sexplib.syntax -linkpkg -syntax camlp4o -verbose ./longident.ml \n findlib: [WARNING] Interface longident.cmi occurs in several directories: ., /home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs\n findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs, /home/tokuda/.opam/4.02.3/lib/ocaml\n Effective set of preprocessor predicates: preprocessor,syntax,camlp4o\n Effective set of compiler predicates: pkg_unix,pkg_num.core,pkg_num,pkg_bigarray,pkg_str,pkg_bytes,pkg_batteries,pkg_camlp4,pkg_compiler-libs,pkg_compiler-libs.common,pkg_type_conv,pkg_sexplib,pkg_sexplib.syntax,syntax,autolink,native\n + ocamlopt.opt -verbose -I /home/tokuda/.opam/4.02.3/lib/num -I /home/tokuda/.opam/4.02.3/lib/bytes -I /home/tokuda/.opam/4.02.3/lib/batteries -I /home/tokuda/.opam/4.02.3/lib/ocaml/camlp4 -I /home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs -I /home/tokuda/.opam/4.02.3/lib/type_conv -I /home/tokuda/.opam/4.02.3/lib/sexplib -pp \"camlp4 '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml/camlp4' '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs' '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs' '-I' '/home/tokuda/.opam/4.02.3/lib/type_conv' '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml' '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml' '-I' '/home/tokuda/.opam/4.02.3/lib/sexplib' '-I' '/home/tokuda/.opam/4.02.3/lib/sexplib' '-parser' 'o' '-parser' 'op' '-printer' 'p' 'ocamlcommon.cma' 'pa_type_conv.cma' 'unix.cma' 'bigarray.cma' 'sexplib.cma' 'pa_sexp_conv.cma' \" /home/tokuda/.opam/4.02.3/lib/ocaml/unix.cmxa /home/tokuda/.opam/4.02.3/lib/ocaml/nums.cmxa /home/tokuda/.opam/4.02.3/lib/ocaml/bigarray.cmxa /home/tokuda/.opam/4.02.3/lib/ocaml/str.cmxa /home/tokuda/.opam/4.02.3/lib/batteries/batteries.cmxa /home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs/ocamlcommon.cmxa /home/tokuda/.opam/4.02.3/lib/sexplib/sexplib.cmxa ./longident.ml\n + camlp4 '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml/camlp4' '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs' '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs' '-I' '/home/tokuda/.opam/4.02.3/lib/type_conv' '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml' '-I' '/home/tokuda/.opam/4.02.3/lib/ocaml' '-I' '/home/tokuda/.opam/4.02.3/lib/sexplib' '-I' '/home/tokuda/.opam/4.02.3/lib/sexplib' '-parser' 'o' '-parser' 'op' '-printer' 'p' 'ocamlcommon.cma' 'pa_type_conv.cma' 'unix.cma' 'bigarray.cma' 'sexplib.cma' 'pa_sexp_conv.cma' './longident.ml' > /tmp/ocamlpp0f6ab1\n + as -o './longident.o' '/tmp/camlasmc75b90.s'\n File \"./longident.ml\", line 1:\n Error: Files ./longident.cmx\n and /home/tokuda/.opam/4.02.3/lib/ocaml/compiler-libs/ocamlcommon.cmxa\n both define a module named Longident\n ocamlopt.opt returned with exit code 2\n \n```", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T09:01:20.583", "favorite_count": 0, "id": "18130", "last_activity_date": "2015-10-27T12:47:41.533", "last_edit_date": "2015-10-27T09:30:54.000", "last_editor_user_id": "898", "owner_user_id": "7768", "post_type": "question", "score": 2, "tags": [ "ocaml" ], "title": "ocamlfindがcompiler-libsを認識して名前が被るモジュールがコンパイルできない", "view_count": 355 }
[ { "body": "解決したようで良かったです。いくつかポイントをあげておきます。\n\n`ocamlfind` コマンドが何をやっているか判らないときは `ocamlfind <command> -verbose ...`\nとして実際にどんなコマンドが起動されるか確認する\n\nOCamlFind パッケージと OPAM パッケージは違う。OCamlFind はライブラリの使用を助けるためのツールで、 OCamlFind\nパッケージはだいたいライブラリと一対一の関係にある。 OPAM\nはリリースされているソフトウェアパッケージと一対一の関係にありそのインストールを助ける。OPAM パッケージをインストールすると OCamlFind\nパッケージをインストールしないかもしれないし、するかもしれない。複数インストールすることもあり得る\n\nOCamlFind はライブラリのリンク依存関係を `META` というファイルを使って把握する。OPAM パッケージの `opam`\nファイルはソフトウェアパッケージとしてのインストール依存関係を表すもので、もちろん大体リンク依存関係と似てはいるが、同じではない。\n\n`compiler-libs` ライブラリは OCaml コンパイラをインストールすると一緒にインストールされるので、対応する OPAM パッケージはない。\nOCamlFind パッケージとしては存在する。OCaml コンパイラをインストールした時には OCamlFind は存在しないので、 `compiler-\nlibs` という OCamlFind パッケージが存在するのはちょっと不思議だが、OCamlFind インストール時に勝手に作ってくれる。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T12:47:41.533", "id": "18137", "last_activity_date": "2015-10-27T12:47:41.533", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "898", "parent_id": "18130", "post_type": "answer", "score": 2 } ]
18130
18137
18137
{ "accepted_answer_id": "18136", "answer_count": 4, "body": "よろしくお願いします。\n\n通常、Pythonでディレクトリの移動は\n\n```\n\n os.chdir('directory')\n \n```\n\nでできますが、pythonスクリプト内でディレクトリを移動しても、そのスクリプトを終了したらディレクトリはスクリプトを起動した時のままになります。\n\n```\n\n # pwd -> path/to/file\n os.chdir('foobar')\n # pwd -> path/to/file/foobar\n # この状態でスクリプトを終了すると、\n # pwd -> path/to/file のまま\n \n```\n\nこういうことになります。\n\nこれを、スクリプトを終了しても **ディレクトリを移動した状態を保つ** ことはできるのでしょうか?\n\nスクリプトを終了する時にあたらしくシェルを起動すれば、ディレクトリの移動は保たれますが、\n\n```\n\n os.chdir('foobar') # pwd -> path/to/file/foobar\n os.system(os.environ[\"SHELL\"]) \n # path/to/file/foobar の状態でシェルが起動するので、結果的には意図した事ができる\n \n```\n\nしかし設計的にこのシステムはよくないと思いますので(シェル変数が設定されていない場合もありますし)、何か解決術がありましたら、お教え頂けませんでしょうか。\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T10:53:52.090", "favorite_count": 0, "id": "18132", "last_activity_date": "2016-05-29T20:18:13.877", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "11178", "post_type": "question", "score": 10, "tags": [ "python" ], "title": "Pythonでディレクトリを移動した状態で終了したい", "view_count": 6590 }
[ { "body": "子プロセス(この場合は python\nプロセス)側から親プロセス(この場合はシェルプロセス)のカレントディレクトリを直接的に変更することはできないことになっています(環境によってはできなくもないのですが)。\n\nそこで、「 **ディレクトリを移動した状態を保つ** 」のではなく、「結果的にディレクトリを移動した状態にする」方法を以下に示します。\n\n**chdir.py**\n\n```\n\n #!/usr/bin/python\n \n import os\n import sys\n \n # :\n \n os.chdir('foobar')\n print(os.getcwd())\n \n sys.exit(0)\n \n```\n\n※ エラーチェックは省いています\n\n**シェル側**\n\n```\n\n $ pwd\n /home/nemo\n $ mkdir foobar\n \n $ cd \"`./chdir.py`\"\n \n $ pwd\n $ /home/nemo/foobar\n \n```\n\nPython スクリプトに移動先ディレクトリのパス名を表示させて、それを親プロセス(シェルプロセス)で cd の引数としています。したがって、Python\nスクリプトで標準出力や標準エラー出力に他の文字列を出力してしまうと、ディレクトリの移動に失敗することになります。\n\n**追記**\n\n親プロセスのカレントディレクトリを変更する方法について、Linux 系 OSで gdb がインストールされていれば可能かもしれません。\n\nまず、gdb を使うための準備をします。\n\n```\n\n $ sudo sh -c 'echo 0 > /proc/sys/kernel/yama/ptrace_scope'\n \n```\n\nこれで親プロセスに attach することができる様になります。\n\n**chdir.py**\n\n```\n\n os.chdir('foobar')\n \n cmd = \"gdb -p %d -ex 'call chdir(\\\"%s\\\")' -ex detach -ex quit >/dev/null 2>&1\" % \\\n (os.getppid(), os.getcwd())\n os.system(cmd)\n \n```\n\n親プロセスに attach して `chdir`(system call)\nを実行します。成功すれば親プロセス(ここではシェルプロセス)のカレントディレクトリが `./foobar` ディレクトリに変更されているはずです。\n\n```\n\n $ pwd\n /home/nemo\n $ touch ./foobar/here_is_foobar_dir\n \n $ ./chdir.py\n $ pwd ## shell function\n /home/nemo\n $ /bin/pwd\n /home/nemo/foobar\n $ realpath .\n /home/nemo/foobar\n $ ls\n here_is_foobar_dir\n \n```\n\nfoobar ディレクトリに移動していますが、pwd(bash の shell function)の結果は元のディレクトリのままです。\n\n以上は[本家でも取り上げられていて](https://stackoverflow.com/a/2375174)、\n\n> Don't do this. \n> : \n> It will probably work, though note that Bash's pwd command is cached and\n> won't notice.\n\nと書かれています。\n\n**追記その2**\n\nbash 4.3.30 の場合ですが、`cd_builtin`(bash の cd function の実体)を実行すると pwd の問題を回避できます。\n\n```\n\n cmd = (\"gdb -p %d -ex \" + \\\n \"'call cd_builtin(make_word_list(make_word(\\\"--\\\"),\" + \\\n \"make_word_list(make_word(\\\"%s\\\"), 0)))' \" + \\\n \"-ex detach -ex quit >/dev/null 2>&1\") % (os.getppid(), os.getcwd())\n \n $ ./chdir.py\n $ pwd\n /home/nemo/foobar\n $ ls\n here_is_foobar_dir\n \n```\n\nバージョンの異なる bash で動作するかは不明です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T11:45:53.680", "id": "18134", "last_activity_date": "2015-10-27T15:30:25.830", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": null, "parent_id": "18132", "post_type": "answer", "score": 3 }, { "body": "Unix系OSについて書きます。 \nUnixでは、親プロセスに限らず別プロセスのワーキングディレクトリを変更する一般的な方法はありません。 \nどうしても行ないたければ、外部プロセスにアタッチしてシステムコールを実行することになると思います。 \nOSによって方法が違うはずですが gdb などのツールを呼び出せば共通化出来るかも知れません。\n\nシェルでのディレクトリ移動を効率化するようなツールを作りたいのでしたら、シェルの alias を使うとよいです。 \n移動したいディレクトリを標準出力に出力する`python-script`というコマンドを作ったとすると \n\n```\n\n alias mycd='cd \"$(python-script)\"'\n \n```\n\nとしておけば、`mycd` の実行でシェルのワーキングディレクトリが変更されます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T11:53:56.350", "id": "18136", "last_activity_date": "2015-10-27T11:53:56.350", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "18132", "post_type": "answer", "score": 6 }, { "body": "私も同様の処理 ( python で curses を使い、グラフィカルに移動先ディレクトリを選択する )\nを行いたくて、似たようなスクリプトを作ったことがあるのですが、結局 python だけでは完結せずに bash の関数と連携させて実施しました。\n\nそのため、質問への回答とはなりませんが、ご参考になれば。\n\n```\n\n # .bashrcなど\n ccd(){\n /path/to/ccd.py\n cd \"`cat /tmp/_ccd_result`\"\n }\n \n```\n\nccd.py でパスを選択し、結果を /tmp/_ccd_result に記録して bash 上で cd します。 \n泥臭いのであまり人に見せられませんが、結果として有用なので使えています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-08T11:14:55.240", "id": "20751", "last_activity_date": "2016-01-08T11:14:55.240", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10001", "parent_id": "18132", "post_type": "answer", "score": 3 }, { "body": "sh限定になりますが、こんな方法もありますよ。\n\nmain.py\n\n```\n\n #!/bin/sh\n python - <<pass\n print(\"Hello!\")\n pass\n cd /some/where\n \n```\n\n呼出しは以下のようにする必要があります。aliasなどで隠蔽できるなら、それでも良いかと思います。\n\n```\n\n $ . main.py\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-05-29T18:45:48.243", "id": "25272", "last_activity_date": "2016-05-29T20:18:13.877", "last_edit_date": "2016-05-29T20:18:13.877", "last_editor_user_id": "3605", "owner_user_id": "10596", "parent_id": "18132", "post_type": "answer", "score": 0 } ]
18132
18136
18136
{ "accepted_answer_id": "18138", "answer_count": 1, "body": "1つの Shop のなかに複数の Shelf がありその中に Item が格納されているケースを想定しています。 \nngResourceを使ってjsonでレンダリングされた \"/api/shops/:shop_id/shelfs/:shelf_id/items/:id\"\nを呼び出して、データベースに item を追加しようとしています。\n\n《controller》shop_edit.coffee\n\n```\n\n angular.module(\"myApp\").controller \"shopEdit\", ($scope, Shop, Shelf, Item) ->\n \n $scope.init = ->\n # Rails側でパラメータを取得してng-initからshop_idを設定\n shop_id = $scope.shop_id\n # Shopを取得\n Article.get(id: shop_id).$promise.then (shop) ->\n $scope.shop = shop\n return\n \n $scope.saveItem = (shop, shelf) ->\n # 保存\n $scope.newItem = { name: shelf.item.name, shop_id: shop.id, shelf_id: shelf.id }\n Item.save($scope.newItem)\n $scope.newItem = newItem\n return\n \n```\n\n《view》edit.html.slim\n\n```\n\n (一部抜粋)\n .item\n input name=\"name\" ng-model=\"shelf.item.name\" ng-blur=\"saveItem(shop, shelf)\"\n \n```\n\n《service》shop.coffee\n\n```\n\n angular.module('myApp').factory 'Shop', ($resource) ->\n $resource('/api/shops/:id', { id: @id }, { update: { method: 'PUT' }})\n \n```\n\n《service》item.coffee\n\n```\n\n angular.module('myApp').factory 'Item', ($resource) ->\n $resource('/api/shops/:shop_id/shelfs/:shelf_id/items/:id',\n { shop_id: '13495' },\n { shelf_id: '93' },\n { update: { method: 'PUT' }})\n \n```\n\nこのとき、動的な値 shop_id と shelf_id をcontorollerから受け取れずに困っています。 \n$scope.newItem = { ... } の中で shop_id と item_id を指定し、Item.save($scope.newItem)\nで service 側に渡しているのですが正しく受け取れないようで困ってます(:shop_id, :shelf_id が空欄になり保存に失敗しています)。\n\nまた、なぜか、以下のように :shelf_id を :shop_id に置き換えないと正しく保存されません...\n\n```\n\n $resource('/api/shops/:shop_id/shelfs/:shop_id/items/:id',\n { shop_id: '13495' },\n { update: { method: 'PUT' }})\n \n```\n\n原因が検討もつかず困っています... どうかよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T11:13:55.897", "favorite_count": 0, "id": "18133", "last_activity_date": "2015-10-27T13:35:35.047", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10441", "post_type": "question", "score": 1, "tags": [ "javascript", "angularjs", "coffeescript" ], "title": "ngResourceでネストされたアイテムの追加ができず困っています", "view_count": 123 }
[ { "body": "`item.coffee`内での`$resource`の使い方が間違っています。 \n第一引数はURLテンプレート、第二引数はデフォルトパラメータ、第三引数はアクションです。\n\n```\n\n angular.module('myApp')\n .factory('Item', function($resource) {\n return $resource('', {}, {\n update: {\n url: '/api/shops/:shop_id/shelfs/:shelf_id/items/:id',\n method: 'PUT',\n params: {id: '@id', shop_id: '@shop_id', shelf_id: '@shelf_id'}\n }\n });\n })\n \n```\n\n`update`アクションを作るのでしたらこんな感じでしょうか。 \nこれでコントローラから`Item.update($scope.newItem)`すればOKです。\n\nPOST系のメソッドでデータをURLテンプレートに展開したい場合、上のように`@`付きの書式で`params`を指定する必要があります。\n\n公式ドキュメントをよくお読みください。 \n<https://docs.angularjs.org/api/ngResource/service/$resource>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T13:35:35.047", "id": "18138", "last_activity_date": "2015-10-27T13:35:35.047", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8532", "parent_id": "18133", "post_type": "answer", "score": 2 } ]
18133
18138
18138
{ "accepted_answer_id": "18336", "answer_count": 1, "body": "JDBC(MariaDB Java)で1つのコネクションで \n一度に多数のリクエストを送信した場合、同時にSQLの実行が行われるのでしょうか?\n\n複数のスレッドで同時に送信という状態でございます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T11:50:20.300", "favorite_count": 0, "id": "18135", "last_activity_date": "2015-11-03T02:59:33.580", "last_edit_date": "2015-10-28T04:00:53.300", "last_editor_user_id": "10346", "owner_user_id": "10346", "post_type": "question", "score": 4, "tags": [ "java", "sql", "jdbc" ], "title": "JDBCの1つのコネクションに同時にリクエストを送信したら", "view_count": 1116 }
[ { "body": "そもそもスレッドセーフでは無いのでは…と思い込んでいたのですが、どうも仕様ではスレッドセーフであることを要求しているようですね。古い(urlから察するにjdk1.2時代)&オフィシャルかどうかよくわからないドキュメントしか見つけられませんでしたが… \n<http://www.cs.mun.ca/~michael/java/jdk1.2-docs/guide/jdbc/spec/jdbc-\nspec.frame9.html>\n\n> 9.2 Multi-threading \n> We require that all operations on all the java.sql objects be multi-thread\n> safe and able to cope \n> correctly with having several threads simultaneously calling the same\n> object.\n\n(書いている最中に思ったのですが、現在の仕様ではスレッドセーフであることは要求されていない可能性もありますね。)\n\n仕様の話はおいておいて、実際のMariaDB実装はどうなっているのかというと…\n\n`java.sql.Connection` のMariaDB実装は\n[`org.mariadb.jdbc.MariaDbConnection`](https://github.com/MariaDB/mariadb-\nconnector-j/blob/6476064e9c9e488efde8ca179111ac3c7fe94bc2/src%2Fmain%2Fjava%2Forg%2Fmariadb%2Fjdbc%2FMariaDbConnection.java),\nそして [`crateStatement` メソッド](https://github.com/MariaDB/mariadb-\nconnector-j/blob/6476064e9c9e488efde8ca179111ac3c7fe94bc2/src%2Fmain%2Fjava%2Forg%2Fmariadb%2Fjdbc%2FMariaDbConnection.java#L149-L152)で取得できる\n`java.sql.Statement` の実装は\n[`org.mariadb.jdbc.MariaDbStatement`](https://github.com/MariaDB/mariadb-\nconnector-j/blob/6476064e9c9e488efde8ca179111ac3c7fe94bc2/src%2Fmain%2Fjava%2Forg%2Fmariadb%2Fjdbc%2FMariaDbStatement.java)\nのようです。 \nこのコードを見てみると、[`execute` メソッドの中](https://github.com/MariaDB/mariadb-\nconnector-j/blob/6476064e9c9e488efde8ca179111ac3c7fe94bc2/src%2Fmain%2Fjava%2Forg%2Fmariadb%2Fjdbc%2FMariaDbStatement.java#L275)で\n[`ReentrantLock#lock()`](https://docs.oracle.com/javase/jp/8/api/java/util/concurrent/locks/ReentrantLock.html#lock--)\nによって `Connection` インスタンス単位のロックを取得しているのがわかります。\n\n要するに、\n\n> 一度に多数のリクエストを送信した場合、同時にSQLの実行が行われるのでしょうか?\n\nの回答としては、 \n「\n**JDBCドライバが[逐次化](https://ja.wikipedia.org/wiki/%E3%82%B7%E3%83%AA%E3%82%A2%E3%83%A9%E3%82%A4%E3%82%BA#.E9.80.90.E6.AC.A1.E5.8C.96)するので同時には実行されません**」 \nということになります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-02T17:49:34.413", "id": "18336", "last_activity_date": "2015-11-03T02:59:33.580", "last_edit_date": "2015-11-03T02:59:33.580", "last_editor_user_id": "2808", "owner_user_id": "2808", "parent_id": "18135", "post_type": "answer", "score": 5 } ]
18135
18336
18336
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在、SwiftのSpriteKitを使いiOSアプリケーションを作っているのですが、円グラフを書く方法がわかりません。 \n調べてみてもUIKitを使う方法ばかり出てきてしまい、使うことができません。 \n誰かSwiftのSpriteKitで下のような円グラフを描く方法をご教授ください。\n\n[このリンク先のような円グラフを描きたいです](https://lh3.googleusercontent.com/-K2Us5zyEGJs/U4rt4SgHxVI/AAAAAAAACGo/IBfgQ2C1jxE/s800/ProgressCircle.png)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T14:14:20.067", "favorite_count": 0, "id": "18139", "last_activity_date": "2016-08-29T16:25:05.223", "last_edit_date": "2015-10-28T01:09:35.023", "last_editor_user_id": "7362", "owner_user_id": "12999", "post_type": "question", "score": 1, "tags": [ "ios", "swift", "spritekit" ], "title": "SwiftのSpritekitで円グラフを書く方法", "view_count": 496 }
[ { "body": "SpriteKitの話でなくて、WatchKitの話の引用ですが……\n\n[WatchKit のカスタムUI実現方法のまとめ](http://qiita.com/shu223/items/e704f70abc50da32ba38)\n\nAppleのプログラマが、予想外のローテクを使っているというお話です。\n\n連番の円グラフの画像を使うというのは、SpriteKitでも、有効なテクニックではないでしょうか? \n1%きざみで100枚画像を用意するのはたいへんですが、5%きざみ程度ですむなら、20枚くらい用意すればいいので、それほど苦労はいらないはず。\n\n「いやいや、ドロー(SKShapeNode)で円グラフを書きたいんだよ」ということでしたら、その旨コメントしていただくか、質問文に加筆していただくか、お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T05:40:34.787", "id": "18159", "last_activity_date": "2015-10-28T05:40:34.787", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "18139", "post_type": "answer", "score": 1 } ]
18139
null
18159
{ "accepted_answer_id": null, "answer_count": 1, "body": "Mac上で、OpenTKを利用して、描画を行おうとしています。\n\nサンプルを元に、背景を透明にしようとしているのですが、黒のまま変化が見られない状況です。 \n以下が、そのコードです。\n\n```\n\n gameWindow = new MonoMacGameView( new CoreGraphics.CGRect(x,y,width,height) );\n // Wire-up any required Game events\n gameWindow.Load += (sender, e) =>\n {\n // TODO: Initialize settings, load textures and sounds here\n };\n \n gameWindow.Resize += (sender, e) =>\n {\n // Adjust the GL view to be the same size as the window\n GL.Viewport(0, 0, gameWindow.Size.Width, gameWindow.Size.Height);\n };\n \n gameWindow.UpdateFrame += (sender, e) =>\n {\n // TODO: Add any game logic or physics\n };\n \n gameWindow.RenderFrame += (sender, e) =>\n {\n GL.Enable( EnableCap.AlphaTest );\n GL.Enable( EnableCap.Blend );\n \n GL.ClearColor( 0.0f,0.0f,0.0f,0.0f );\n \n // Setup buffer\n GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);\n \n GL.PushMatrix();\n \n GL.MatrixMode(MatrixMode.Projection);\n \n // Draw a simple triangle\n GL.LoadIdentity();\n GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);\n GL.Begin(BeginMode.Triangles);\n GL.Color3(Color.MidnightBlue);\n GL.Vertex2(-1.0f, 1.0f);\n GL.Color3(Color.SpringGreen);\n GL.Vertex2(0.0f, -1.0f);\n //GL.Color3(Color.Ivory);\n GL.Color4( 0.0f,0.5f,0.5f,0.1f);\n GL.Vertex2(1.0f, 1.0f);\n GL.End();\n \n GL.PopMatrix();\n };\n \n```\n\nNSView側の設定かもしれませんが、どのような処理を追加すればいいかがわからない状況です。 \n以下の様なコードも試してみましたが、そうすると、GLの描画が消えてしまいました。\n\n```\n\n CALayer viewLayer = CALayer.Create ();\n viewLayer.BackgroundColor = NSColor.Clear.CGColor;\n renderView.WantsLayer = false;\n renderView.Layer = viewLayer;\n ※renderViewが、GL描画を行っているNSViewです。\n \n```\n\nご助言をいただきたいと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T15:04:04.067", "favorite_count": 0, "id": "18140", "last_activity_date": "2015-12-16T18:21:38.393", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3766", "post_type": "question", "score": 1, "tags": [ "c#", "macos", "opengl" ], "title": "NSViewで描画しているOpenGLの背景を透明にしたい", "view_count": 1253 }
[ { "body": "OpenTKというのは使ったことないですが、OpenGLで背景色を透明にする場合は glColorMask というのを設定してから glClearします。\n\n通常の OpenGL での記述\n\n```\n\n glColorMask(true, true, true, true); // Alphaも描画する設定\n glClear(GL_COLOR_BUFFER_BIT);\n glColorMask(true, true, true, false); // 戻す\n \n```\n\n動くか分かりませんが、OpenTK ではこのように書くのでしょうか。GL.Clearの前後に1行ずつ足しました。\n\n```\n\n GL.ColorMask(true, true, true, true); // Alphaも描画する設定\n GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);\n GL.ColorMask(true, true, true, false); // 戻す\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-16T18:09:45.457", "id": "18913", "last_activity_date": "2015-11-16T18:09:45.457", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2079", "parent_id": "18140", "post_type": "answer", "score": 1 } ]
18140
null
18913
{ "accepted_answer_id": "18148", "answer_count": 1, "body": "以下の記載を含んだXHTMLをIEのドキュメントモードIE9で表示した場合、画面に表示されてしまいます。 \nドキュメントモードIE10,IE11,Edgeでは表示されず条件式として処理されているようです。どこに誤りがあるのかご教示をおねがいします。\n\n```\n\n <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and\n media queries -->\n <!--[if lt IE 9]>\n <h:outputScript name=\"html5shiv.min.js\" library=\"js\" />\n <h:outputScript name=\"respond.min.js\" library=\"js\" />\n <h:outputScript name=\"lte-ie7.js\" library=\"js\" />\n <![endif]-->\n \n```\n\n**更新** \nJavaEEの場合、Conditional\nCommentsはデフォルトではエスケープされてしまうようです。よって、IE9以下では画面に条件式が表示されます。解決策としては以下のようにエスケープを無効にするパラメタを設定することで解決しました。\n\n```\n\n <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and\n media queries -->\n <h:outputText\n value=\"&lt;!--[if lt IE 9]&gt;\n &lt;script type=&quot;text/javascript&quot;src=&quot;#{request.contextPath}/javax.faces.resource/html5shiv.min.js.xhtml?ln=js&quot;&gt;&lt;/script&gt;\n &lt;script type=&quot;text/javascript&quot;src=&quot;#{request.contextPath}/javax.faces.resource/respond.min.js.xhtml?ln=js&quot;&gt;&lt;/script&gt;\n &lt;script type=&quot;text/javascript&quot;src=&quot;#{request.contextPath}/javax.faces.resource/lte-ie7.js.xhtml?ln=js&quot;&gt;&lt;/script&gt;\n &lt;![endif]--&gt;\"\n escape=\"false\" />\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T17:15:52.633", "favorite_count": 0, "id": "18143", "last_activity_date": "2015-10-28T13:26:49.837", "last_edit_date": "2015-10-28T13:26:49.837", "last_editor_user_id": "9577", "owner_user_id": "9577", "post_type": "question", "score": 3, "tags": [ "html", "internet-explorer", "xhtml" ], "title": "IE条件式:[if lt IE 9]が画面に表示されてしまう", "view_count": 576 }
[ { "body": "`<!--[if lt IE 9]>~<![endif]-->`は[conditional\ncomments](https://msdn.microsoft.com/en-\nus/library/ms537512\\(v=vs.85\\).aspx)と呼ばれInternet Explorer独自の機能ですが\n\n> **Important** As of Internet Explorer 10, conditional comments are no longer\n> supported by standards mode.\n\nとあり、IE10以降の標準モードであれば条件式に関係なく `<!-- ~ -->` つまりHTMLコメントと見做されます。 \nIE9以前であれば条件式 `lt IE 9` に従って判断されます。\n\n> ドキュメントモードIE9で表示した場合、画面に表示されてしまいます。 \n> ドキュメントモードIE10,IE11,Edgeでは表示されず\n\nとのことですが、結果から推測するに\n\n * IE9ではブラウザーモードIE9で、質問文とは異なりドキュメントモードIE5 (Quirks)で動作している\n * IE10以降ではブラウザーモードIE10などで、質問文通りドキュメントモードIE10などで動作している\n\nとなっているのではないでしょうか? IE10からドキュメントモードの判定が変更されており\n\n```\n\n <!DOCTYPE HTML>\n \n```\n\n宣言が含まれていない場合がこれに該当します。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-27T20:22:21.363", "id": "18148", "last_activity_date": "2015-10-27T20:22:21.363", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "18143", "post_type": "answer", "score": 6 } ]
18143
18148
18148
{ "accepted_answer_id": "18238", "answer_count": 1, "body": "Spring dependency management\npluginを使用していますが、twitter4jをdependencyに追加しましたがエラーがでて、解決してくれません。下記にbuild.gradleの内容を示します。\n\n```\n\n build.gradle\n \n buildscript {\n ext {\n springBootVersion = '1.2.7.RELEASE'\n }\n repositories {\n mavenCentral()\n }\n dependencies {\n classpath(\"org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}\") \n classpath('io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE')\n }\n }\n \n apply plugin: 'java'\n apply plugin: 'eclipse'\n apply plugin: 'idea'\n apply plugin: 'spring-boot' \n apply plugin: 'io.spring.dependency-management' \n \n jar {\n baseName = 'sample'\n version = '0.0.1-SNAPSHOT'\n }\n sourceCompatibility = 1.8\n targetCompatibility = 1.8\n \n repositories {\n mavenCentral()\n }\n \n \n dependencies {\n compile('org.springframework.boot:spring-boot-starter-data-jpa')\n compile('org.springframework.boot:spring-boot-starter-redis')\n compile('org.springframework.boot:spring-boot-starter-social-twitter')\n compile('org.springframework.boot:spring-boot-starter-web')\n compile('org.twitter4j:twitter4j-core')\n runtime('org.postgresql:postgresql:9.4-1201-jdbc41')\n testCompile('org.springframework.boot:spring-boot-starter-test') \n }\n \n \n eclipse {\n classpath {\n containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')\n containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'\n }\n }\n \n task wrapper(type: Wrapper) {\n gradleVersion = '2.7'\n }\n \n```\n\nエラー\n\n```\n\n :compileJava\n \n FAILURE: Build failed with an exception.\n \n * What went wrong:\n Could not resolve all dependencies for configuration ':compile'.\n > Could not find org.twitter4j:twitter4j-core:.\n Required by:\n :sample:unspecified\n \n * Try:\n Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.\n \n BUILD FAILED\n \n Total time: 7.94 secs\n \n```\n\n以前に、twitter4jをバーション表記ありで追加してしまったことが原因かもしれませんが、どうすれば直りますでしょうか。Eclipse上でcleanやrefreshをしたり、`gradle\nclean`を実行しましたが直りませんでした。アドバイスをください。よろしくお願いします。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T01:22:19.823", "favorite_count": 0, "id": "18149", "last_activity_date": "2015-10-30T06:29:17.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "post_type": "question", "score": 3, "tags": [ "java", "spring", "gradle" ], "title": "Spring dependency management pluginで依存性解決できない", "view_count": 3450 }
[ { "body": "もう解決されているようですが、一応回答しておきます。\n\ndependency-managementプラグインは、MavenにおけるBOMを使ってバージョンを解決する仕組みをGradleに提供します。\n\n```\n\n dependencyManagement {\n imports {\n mavenBom 'io.spring.platform:platform-bom:1.1.4.RELEASE'\n }\n }\n \n```\n\nなどのようにBOMを指定して使います。 \n今回の場合はSpring Bootプラグインが提供するBOMが使われます。 \nSpring Boot 1.2.7であれば、以下から品揃えが確認できます。 \n<http://docs.spring.io/spring-boot/docs/1.2.7.RELEASE/reference/html/appendix-\ndependency-versions.html>\n\nこのBOMに含まれているプロダクトであれば、\n\n```\n\n compile('org.springframework.boot:spring-boot-starter-data-jpa')\n \n```\n\nなどのようにバージョンをあえて未指定にすることで、バージョンの解決をBOMに任せることができます。 \nこれによって、バージョン相性問題や更新時の手間が解消されます。\n\nTwitte4Jですが、このBOMに含まれていません。 \nこのためargus氏が指摘しているように、バージョンを明示指定する必要があります。\n\n```\n\n compile('org.twitter4j:twitter4j-core:X.Y.Z')\n \n```\n\n余談ですが、Spring Boot 1.3.0からはSpring BootのGradleプラグインがdependency-\nmanagementプラグインを自動的に適用するので、build.gradleにdependency-\nmanagementの設定を明記する必要がなくなるようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-30T06:29:17.317", "id": "18238", "last_activity_date": "2015-10-30T06:29:17.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2356", "parent_id": "18149", "post_type": "answer", "score": 2 } ]
18149
18238
18238
{ "accepted_answer_id": null, "answer_count": 2, "body": "WebサイトからInstagramAPIを利用してユーザのフォロー・フォロー解除を行うため、 \n<https://help.instagram.com/contact/185819881608116> \nから何度か申請を行ってみたのですが、 \n「・does not fall into the approved use cases.」 \nとの返信が返ってきて、どのようにシステムを修正、もしくは、申請をすればいいのかわかりませんでした。 \n本家のサイト以外でも、API申請の参考になるようなことやURLなどはないでしょうか?\n\nまた、フォームに「業務用サービスを提供するアプリ」に限定とありますが、「業務用サービスを提供するアプリ」とはどのようなアプリを指すのかがわかりませんでした。 \nこちらについても参考になることやURLなどありますでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T01:39:55.783", "favorite_count": 0, "id": "18150", "last_activity_date": "2016-03-27T10:01:52.183", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9128", "post_type": "question", "score": -1, "tags": [ "instagram" ], "title": "InstagramAPI利用の申請について", "view_count": 482 }
[ { "body": "こちらのサイトが大変参考になりますよ。 \nInstagram APIでwebサービスを作りたい全ての人に向けて書きました <https://syncer.jp/instagram-api-\nmatome#content-12-1>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T03:32:48.247", "id": "18155", "last_activity_date": "2015-10-28T03:32:48.247", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12973", "parent_id": "18150", "post_type": "answer", "score": -1 }, { "body": "差し支えない範囲で結構ですがどのようなアプリケーションを作成/申請中でしょうか?\n\n基本的には本家以外に参考になるリソースはありませんので、\n\n> * Media rights management: for example a platform for media publishers and\n> brands to request permission from the Instagram Community to use Instagram\n> content.\n>\n> * Social media management: for example, a platform to help businesses\n> integrate Instagram in their social media workflow.\n>\n>\n\nこの2つの例に合致するものを申請するしか無いかと。(基本的にB2Bですね\n\nまた、\n\n> At this time we are approving only applications that have a clearly\n> established portfolio of businesses. Please do not submit a request if you\n> are still in development or if you are not an established business.\n\n作成中のアプリケーションでは申請できないようです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T07:42:00.260", "id": "18196", "last_activity_date": "2015-10-29T07:42:00.260", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "13027", "parent_id": "18150", "post_type": "answer", "score": 1 } ]
18150
null
18196
{ "accepted_answer_id": null, "answer_count": 0, "body": "今現在、XAMPPを使ってターミナル上でcakephp3をインストールしようと思っています。\n\nいろいろ調べてみて、 \ncomposerをインストールして、cakephpをインストールするという手順で行いました。\n\nXAMPPのhtdocs内にcakephpというフォルダを作り、 \n現在は、「composer.phar」というプロジェクトと「bookmarker」というフォルダがあります。\n\nただ、ターミナル上で\n\n```\n\n php composer.phar create-project --prefer-dist -s dev cakephp/app bookmarker\n \n```\n\nと打ったら、\n\n```\n\n Your requirements could not be resolved to an installable set of packages.\n Problem 1\n - cakephp/cakephp 3.1.3 requires ext-intl * -> the requested PHP extension intl is missing from your system.\n - cakephp/cakephp 3.1.2 requires ext-intl * -> the requested PHP extension intl is missing from your system.\n - cakephp/cakephp 3.1.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.\n - cakephp/cakephp 3.1.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.\n - Installation request for cakephp/cakephp ~3.1 -> satisfiable by cakephp/cakephp[3.1.0, 3.1.1, 3.1.2, 3.1.3].\n \n```\n\nとエラーが表示されます。 \n調べてみて、php.intlが有効化されていないということで、 \nxamppfileのphp.intlを有効化したのですが、まだこのエラーが続いています。\n\nブラウザでは、\n\n```\n\n Warning: require(/Applications/XAMPP/xamppfiles/htdocs/cakephp_youtube/bookmarker/vendor/autoload.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/cakephp/bookmarker/config/bootstrap.php on line 23\n \n Fatal error: require(): Failed opening required '/Applications/XAMPP/xamppfiles/htdocs/cakephp/bookmarker/vendor/autoload.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/cakephp_youtube/bookmarker/config/bootstrap.php on line 23\n \n```\n\nこのように表示されていて、イマイチよく分かっていません。\n\nXAMPPをやり直しても、ターミナルでbookmarkerというフォルダを作り直しても同じエラーが起きるのですが、どうしたら良いでしょうか?\n\nよろしくお願いします。", "comment_count": 10, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T02:17:35.373", "favorite_count": 0, "id": "18152", "last_activity_date": "2015-10-28T02:17:35.373", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8415", "post_type": "question", "score": 1, "tags": [ "php", "cakephp" ], "title": "cakephp3をターミナルからインストールできない", "view_count": 868 }
[]
18152
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "VS2012ProにNsight5.0をインストールして新規プロジェクトを作成しました。 \nNVIDIA > CUDA 7.5 > CUDA 7.5 Runtime\n\nデフォルトで作成されるサンプルプログラムのカーネルの中にブレイクポイントを設定し、Start CUDA\nDebuggingを実行してもブレイクポイントで止まりません。\n\n```\n\n __global__ void addKernel(int *c, const int *a, const int *b)\n {\n int i = threadIdx.x;\n c[i] = a[i] + b[i]; // <ここにブレークポイントを設定\n }\n \n```\n\nなにか設定が足りてないのでしょうか?", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T02:18:56.363", "favorite_count": 0, "id": "18153", "last_activity_date": "2015-10-28T02:18:56.363", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13004", "post_type": "question", "score": 1, "tags": [ "c++", "visual-studio", "cuda" ], "title": "CUDA7.5+VS2012Pro+Nsight5.0のデバッグが止まらない", "view_count": 325 }
[]
18153
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "列が30個くらいあるテーブルがあると仮定して、レコードは膨大に日々増えるとします。 \n列は30個を当初固定しますが、35個等に増やす可能性があります。\n\nAAA,BBB,FFF\n\nAAA,CCC,DDD\n\nBBB,CCC,EEE\n\nというようなデータが入っている場合、\n\nAAAが組み合わせにある他の関連するデータを探すために、入力フォームに入力すると、 \nBBB,CCC,DDD,FFF \nが関連するデータとして表示され、\n\nCCCが組み合わせにある他の関連するデータを探すために、入力フォームに入力すると、 \nAAA,BBB,DDD,EEEが \n関連するデータとして表示される\n\nという仕組みを作る場合は、 \nデータの保存、検索の考え方、 \nRDBでのテーブルの設計の考え方は、 \nどのようにするのが定石でしょうか?\n\nよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T02:29:18.757", "favorite_count": 0, "id": "18154", "last_activity_date": "2015-10-31T11:43:23.403", "last_edit_date": "2015-10-28T11:05:07.013", "last_editor_user_id": "12907", "owner_user_id": "12907", "post_type": "question", "score": 1, "tags": [ "sql", "database" ], "title": "組み合わせでの関連するデータを管理する方法", "view_count": 285 }
[ { "body": "質問の意図を取り違えているかもしれませんが、 \n連想元(例えば'AAA')と連想先(例えば'BBB', 'CCC', 'DDD', 'FFF')の関係を関連テーブルで表すのはどうでしょうか。 \n以下、関連の方向は単方向(AAAの関連データにBBBが存在する場合でも、必ずしもBBBの関連データにAAAが存在するとは限らない)として記載しています。 \n(双方向の場合は、associationの登録時に少し考慮が必要になります(`key_content_id`の値と`value_content_id`の値が逆になっているだけのレコード登録を拒否する必要がある)。)\n\n[![ER図](https://i.stack.imgur.com/iJ8Q2.png)](https://i.stack.imgur.com/iJ8Q2.png)\n\ncontent:\n\n```\n\n +----+------+\n | id | data |\n +----+------+\n | 1 | AAA |\n | 2 | BBB |\n | 3 | CCC |\n | 4 | DDD |\n | 5 | EEE |\n | 6 | FFF |\n +----+------+\n \n```\n\nassociation(の一部):\n\n```\n\n +----+----------------+------------------+\n | id | key_content_id | value_content_id |\n +----+----------------+------------------+\n | 1 | 1 | 2 |\n | 2 | 1 | 3 |\n | 3 | 1 | 4 |\n | 4 | 1 | 6 |\n | 5 | 3 | 1 |\n | 6 | 3 | 2 |\n | 7 | 3 | 4 |\n | 8 | 3 | 5 |\n +----+----------------+------------------+\n \n```\n\n* * *\n\ncontentに新しく以下のレコードを登録する場合、\n\n```\n\n +----+------+\n | id | data |\n +----+------+\n | 7 | GGG |\n +----+------+\n \n```\n\n例えば'AAA'の連想先に'GGG'があり、'GGG'の連想先に'BBB','CCC'があるのであれば、associationテーブルに新しく登録すべきデータは以下のようになります。\n\n```\n\n +----+----------------+------------------+\n | id | key_content_id | value_content_id |\n +----+----------------+------------------+\n | 9 | 1 | 7 |\n | 10 | 7 | 3 |\n | 11 | 7 | 3 |\n +----+----------------+------------------+\n \n```\n\n関連をたどれば連想元から連想先を引いてくることができます。 \nSQL:\n\n```\n\n select v.data from content v where id in (\n select value_content_id from association \n inner join (\n select id from content where data = 'AAA'\n ) k\n on association.key_content_id = k.id\n );\n \n```\n\n`k`(keyの意),\n`v`(valueの意)は、`FROM`句に登場させているcontentテーブルの[別名](https://technet.microsoft.com/ja-\njp/library/ms187455\\(v=sql.105\\).aspx)です。文中、異なる意味で2回(連想元として、連想先として)出てきていますので、区別がつくように別の名前をつけています。\n\n実際にやりたいことを図で表してみると以下のようになると思います。\n\n[![処理概念](https://i.stack.imgur.com/3T9UN.png)](https://i.stack.imgur.com/3T9UN.png)\n\nこれを文章で表すと次の手順で所望のデータを取得する、ということになります。\n\n 1. associationに登録された関連を取得するためにcontentから'AAA'のIDを取得する\n 2. 取得したIDを用い、'AAA'の連想先IDをassociationから実際に取得する\n 3. 取得した連想先IDを用いcontentから連想先の実体を取得する\n\n以下、それぞれについて見ていきます。\n\n### associationに登録された関連を取得するためにcontentから'AAA'のIDを取得する\n\n前述のSQLのうち、以下の部分が該当します。\n\n```\n\n select id from content where data = 'AAA'\n \n```\n\n実際にはこれに別名`k`をつけていますので、次のようなテーブルができたと考えてください。\n\n[![kテーブル](https://i.stack.imgur.com/mrJ1V.png)](https://i.stack.imgur.com/mrJ1V.png)\n\n`id`というカラムを持ち、レコード数が1のテーブルです。\n\n### 取得したIDを用い、'AAA'の連想先IDをassociationから取得する\n\n前述のSQLのうち、次の部分が該当します。\n\n```\n\n select value_content_id from association \n inner join k\n on association.key_content_id = k.id\n \n```\n\n`association` と `k` を inner join したテーブルは以下のようなものになります。\n\n[![assosiationとkのjoin\ntable](https://i.stack.imgur.com/DPbjh.png)](https://i.stack.imgur.com/DPbjh.png)\n\n'AAA'のID`1`を`key_content_id`に持つレコードのみが存在します。 \nすなわち、このテーブルの`value_content_id`が'AAA'の連想先IDということになります。\n\n### 取得した連想先IDを用いcontentから連想先の実体を取得する\n\n```\n\n select v.data from content v where id in (2,3,4,6)\n \n```\n\n`content`から指定した`id`の`data`を取得します。これが連想先です。", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T05:08:09.673", "id": "18158", "last_activity_date": "2015-10-31T11:43:23.403", "last_edit_date": "2015-10-31T11:43:23.403", "last_editor_user_id": "2808", "owner_user_id": "2808", "parent_id": "18154", "post_type": "answer", "score": 1 } ]
18154
null
18158
{ "accepted_answer_id": null, "answer_count": 1, "body": "androidでffmpegで以下のコマンドを実行して動画に音声を結合しています。\n\n```\n\n ffmpeg -hide_banner -y -i movie.mp4 -i bgm.aac -vcodec copy -acodec copy -bsf:a aac_adtstoasc out.mp4\n \n```\n\nその際に、動画の先頭から3秒たってから音声がスタートするようにしたいのですが方法がわかりません。最初から音声の先頭に3秒無音を追加したものを準備すればよいのですが、条件によって、無音あり無しを切り替える為、2種類を準備するのは避けたいです。\n\nご教授をよろしくお願いいたします。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T06:37:04.430", "favorite_count": 0, "id": "18161", "last_activity_date": "2017-07-22T15:14:46.303", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7212", "post_type": "question", "score": 4, "tags": [ "android", "ffmpeg" ], "title": "ffmpegで動画と音声を結合するときに先頭に無音を追加するには", "view_count": 6040 }
[ { "body": "`-itsoffset` を使うと良いですが、これを `-acodec copy` と併用すると delay が効かないようです。そこで\n\n```\n\n ffmpeg -y -i movie.mp4 -itsoffset 00:00:03 -i bgm.aac -vcodec copy -bsf:a aac_adtstoasc -async 1 -strict -2 out.mp4\n \n```\n\nとしたところ、3秒後から音声の再生が開始される様になりました。`-async 1` で、audio stream の offset\nの値を記録してくれるのだそうです。また、AAC の場合は `-strict -2` を指定する必要があるとの事です。\n\n\\-- [user9156\nさんのコメントより](https://ja.stackoverflow.com/questions/18161/ffmpeg%E3%81%A7%E5%8B%95%E7%94%BB%E3%81%A8%E9%9F%B3%E5%A3%B0%E3%82%92%E7%B5%90%E5%90%88%E3%81%99%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AB%E5%85%88%E9%A0%AD%E3%81%AB%E7%84%A1%E9%9F%B3%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF#comment16805_18161)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-07-22T15:14:46.303", "id": "36596", "last_activity_date": "2017-07-22T15:14:46.303", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "18161", "post_type": "answer", "score": 2 } ]
18161
null
36596
{ "accepted_answer_id": "18163", "answer_count": 1, "body": "monacaのテンプレート「Onsen UI Sliding\nMenu」を編集しているのですが、[PAGE2.html]に埋め込みのjavascriptを記載したのですが動作しません。index.html内では動作しますので何が原因なのかわからない状態です。お助けお願い致します。\n\n```\n\n <script>\n alert(\"アラート\");\n </script>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T07:24:44.817", "favorite_count": 0, "id": "18162", "last_activity_date": "2015-10-28T07:55:23.790", "last_edit_date": "2015-10-28T07:55:23.790", "last_editor_user_id": "3054", "owner_user_id": "13011", "post_type": "question", "score": 1, "tags": [ "javascript", "monaca", "onsen-ui", "html5" ], "title": "monacaでテンプレート上でjavascriptが効かない", "view_count": 349 }
[ { "body": "PAGE2.htmlに移動するにあたって、アンカータグ(リンク)や、window.location.hrefを書き換えて移動するのであれば、PAGE2.htmlのscriptタグは動作すると思います。 \nけれども、Onsen\nUIでシングルページアプリケーション(SPA)として移動する場合は、index.htmlがPAGE2.htmlを「読み込んで」表示しているだけなので、PAGE2.htmlに記載したscriptタグは動作しません。pageinitイベントを検出して動作するように作り変えてはいかがでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T07:36:03.240", "id": "18163", "last_activity_date": "2015-10-28T07:36:03.240", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8848", "parent_id": "18162", "post_type": "answer", "score": 0 } ]
18162
18163
18163
{ "accepted_answer_id": "18167", "answer_count": 1, "body": "クリアまでのタイムを競うゲームでタイムを小数点2桁で表示しているのですが、そのタイムをNSUserDefaultsで保存して結果画面で表示させるまではできました。しかし、保存したタイムをツイートしようとしたら小数点の桁数が正確に出てしまい困っています。\n\n```\n\n let str = \"\".stringByAppendingFormat(\"%.2f\",cnt)\n time1.text = str\n \n```\n\nこのコードで小数点を2桁にしていて\n\n```\n\n func onPostToTwitter1(sender : AnyObject) {\n \n let ud1 = NSUserDefaults.standardUserDefaults()\n let cnt = ud1.floatForKey(\"time\") //cntは少数で表示したいタイムです。\n \n myComposeView1 = SLComposeViewController(forServiceType: SLServiceTypeTwitter)\n \n \n myComposeView1.setInitialText(\" ただいまのタイムは \\(cnt)秒です。 \" )\n \n self.presentViewController(myComposeView1, animated: true, completion: nil)\n }\n \n```\n\nこのコードでツイートを有効にしているのですがこのコードの中に小数点2桁にするコードを書いたらエラーが出ました。\n\n簡単に今回の質問の内容をまとめますと、保存した小数点2桁のタイムがツイートするときは正確に出すぎて(2桁以上)困っているということです。\n\n説明がわかりにくくてゴメンなさい。 \nご回答お待ちしています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T08:38:19.460", "favorite_count": 0, "id": "18165", "last_activity_date": "2016-03-26T20:52:46.030", "last_edit_date": "2015-10-28T08:40:07.043", "last_editor_user_id": "845", "owner_user_id": "11019", "post_type": "question", "score": 1, "tags": [ "ios", "swift", "xcode" ], "title": "NSUserDefaultsで保存した小数をツイートする方法", "view_count": 148 }
[ { "body": "Xcode 7、Swift 2.0を前提にして説明します。\n\n```\n\n let str = \"\".stringByAppendingFormat(\"%.2f\",cnt)\n time1.text = str\n \n```\n\n`String`型で、`NSString`のたくさんのメソッドがそのまま使えるようになりました。\n\n```\n\n let str = String(format: \"%.2f\", cnt)\n \n```\n\nこういうイニシアライザが使えます。\n\n```\n\n myComposeView1.setInitialText(\" ただいまのタイムは \\(cnt)秒です。 \" )\n \n```\n\nこれも、\n\n```\n\n let theText = String(format: \" ただいまのタイムは %.2f秒です。\", cnt)\n myComposeView1.setInitialText(theText)\n \n```\n\nとすれば、小数点以下2桁で表示できます。\n\n※`NSUserDefaults`に、いちいち浮動小数点数に変換しないで、Stringのまま保存していいんじゃないかという疑問は残りますけど……", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T09:13:12.887", "id": "18167", "last_activity_date": "2015-10-28T09:13:12.887", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "18165", "post_type": "answer", "score": 0 } ]
18165
18167
18167
{ "accepted_answer_id": null, "answer_count": 0, "body": "```\n\n // 左にあるサムネイル4も左にスライドさせる\n $('#slider_thumbnail_4').css({\n   'transform': 'translate3d(-204%, 0, 0)',\n   'transition-duration': '0.5s'\n }).on('transitionend', function() {// transition終了時処理\n   $('#slider_thumbnail_4').addClass('opacity_zero').css({\n     // すぐに右に移す\n     'transform': 'translate3d(204%, 0, 0)',\n     'transition-duration': '0.001s'\n   }).removeClass('opacity_zero').on('transitionend', function() {\n     // 右から左にスライド\n     $('#slider_thumbnail_4').css({\n       'transform': 'translate3d(102%, 0, 0)',\n       'transition-duration': '0.5s'\n     });\n   });\n });\n \n```\n\n2個目のonメソッドがすぐに右に移すの後におこなわれず、 \nすぐに右に移すをとばして、onメソッドの中の処理をおこなってしまうのを食い止めたいのですが、何か方法あるでしょうか? \nすぐに右に移すのあとに右から左にスライドをおこないたいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T11:35:01.053", "favorite_count": 0, "id": "18171", "last_activity_date": "2015-10-28T12:35:03.470", "last_edit_date": "2015-10-28T12:35:03.470", "last_editor_user_id": "8532", "owner_user_id": "13013", "post_type": "question", "score": 2, "tags": [ "jquery", "css" ], "title": "translate3d transition 終了時onメソッドについて", "view_count": 205 }
[]
18171
null
null
{ "accepted_answer_id": "18176", "answer_count": 1, "body": "次の8行だけのvimrcを書きました。\n\n```\n\n set expandtab\n set tabstop=4\n set shiftwidth=4\n set softtabstop=4\n function! F()\n >>\n endfunction\n nmap z :<C-u>call F()<CR>\n \n```\n\nzキーを押すと、半角スペース4個分インデントされる事を期待したいのですが、結果は2倍の8個分インデントされてしまいました。\n\nノーマルモードで>>やインサートモードでtabキーを押すと、半角スペース4個分インデントされました。 \nvimrcで定義したF関数の>>でインデントする時のみ、shiftwidthの2倍の幅でインデントされてしまいます。\n\nshiftwidthに設定した幅でインデントさせる方法を教えてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T12:22:59.413", "favorite_count": 0, "id": "18173", "last_activity_date": "2015-10-29T00:17:39.223", "last_edit_date": "2015-10-28T12:34:38.127", "last_editor_user_id": "10022", "owner_user_id": "10022", "post_type": "question", "score": 5, "tags": [ "vim" ], "title": "vim scriptでインデントがしたい", "view_count": 544 }
[ { "body": "`:h vimrc`すると以下の記述があります。\n\n```\n\n vimrcファイルは一行ずつExコマンドとして実行される。\n \n```\n\n`:h Ex`すると以下の記述があります。\n\n```\n\n このモードは \":\" コマンドを続けて入力するようなもの...\n \n```\n\nつまり`.vimrc`は各行に \":\" が暗黙的についていることになります。 \nこれを踏まえると `>>` という行は `:>`を2回おこなうという指示になります。(`:h :>`) \nですので'shiftwidth' 2個分右にズレるのです。 \nノーマルコマンドの`>>`とは異なります。(`:h >>`) \nノーマルコマンドを実行させたい場合は明示的に`normal!`を指定します。(`:h normal`) \n(`!`を付けているのは他でmapされた`>>`を使わず本来の`>>`を使うようにするためです)\n\n```\n\n normal! >>\n \n```\n\nこれで'shiftwidth' 1個分インデントされます。 \nもちろんExコマンドとして\n\n```\n\n >\n \n```\n\nでも構いません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T13:11:48.337", "id": "18176", "last_activity_date": "2015-10-29T00:17:39.223", "last_edit_date": "2015-10-29T00:17:39.223", "last_editor_user_id": "2687", "owner_user_id": "2687", "parent_id": "18173", "post_type": "answer", "score": 7 } ]
18173
18176
18176
{ "accepted_answer_id": null, "answer_count": 0, "body": "Spring bootでモデル定義を行い`gradle build`コマンドでビルドしようとしましたが下記エラーによりできません。\n\nエラー\n\n```\n\n > Building 81% > :testERROR: relation \"point\" does not exist\n STATEMENT: alter table point drop constraint FK_i94b2uy0ud0q6jrkb41sqjlrg\n ERROR: syntax error at or near \"user\" at character 13\n STATEMENT: alter table user drop constraint FK_1mcjtpxmwom9h9bf2q0k412e0\n ERROR: syntax error at or near \"group\" at character 22\n STATEMENT: drop table if exists group cascade\n ERROR: syntax error at or near \"user\" at character 22\n STATEMENT: drop table if exists user cascade\n ERROR: sequence \"hibernate_sequence\" does not exist\n STATEMENT: drop sequence hibernate_sequence\n ERROR: syntax error at or near \"group\" at character 14\n STATEMENT: create table group (id int8 not null, dominate_point int8, player_count int8, primary key (id))\n ERROR: syntax error at or near \"user\" at character 14\n STATEMENT: create table user (id int8 not null, consumer_key varchar(255) not null, provider int4 not null, uid varchar(255) not null, profile_id int8, primary key (id))\n ERROR: syntax error at or near \"user\" at character 13\n STATEMENT: alter table user add constraint UK_c77nknup654c0jv25o6if51vr unique (consumer_key)\n ERROR: syntax error at or near \"user\" at character 13\n STATEMENT: alter table user add constraint FK_1mcjtpxmwom9h9bf2q0k412e0 foreign key (profile_id) references profile\n :test\n 2015-10-28 21:14:50.121 INFO 3555 --- [ Thread-4] o.s.w.c.s.GenericWebApplicationContext : Closing org.springframework.web.context.support.GenericWebApplicationContext@457e0562: startup date [Wed Oct 28 21:14:45 JST 2015]; root of context hierarchy\n 2015-10-28 21:14:50.130 INFO 3555 --- [ Thread-4] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'\n 2015-10-28 21:14:50.130 INFO 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export\n Hibernate: alter table point drop constraint FK_i94b2uy0ud0q6jrkb41sqjlrg\n > Building 81% > :test > 1 test completedERROR: syntax error at or near \"user\" at character 13\n STATEMENT: alter table user drop constraint FK_1mcjtpxmwom9h9bf2q0k412e0\n Hibernate: alter table user drop constraint FK_1mcjtpxmwom9h9bf2q0k412e0\n 2015-10-28 21:14:50.134 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table user drop constraint FK_1mcjtpxmwom9h9bf2q0k412e0\n 2015-10-28 21:14:50.135 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: syntax error at or near \"user\"\n ポジション: 13\n Hibernate: drop table if exists group cascade\n > Building 81% > :test > 1 test completedERROR: syntax error at or near \"group\" at character 22\n STATEMENT: drop table if exists group cascade\n 2015-10-28 21:14:50.136 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: drop table if exists group cascade\n 2015-10-28 21:14:50.136 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: syntax error at or near \"group\"\n ポジション: 22\n Hibernate: drop table if exists point cascade\n Hibernate: drop table if exists profile cascade\n > Building 81% > :test > 1 test completedERROR: syntax error at or near \"user\" at character 22\n STATEMENT: drop table if exists user cascade\n Hibernate: drop table if exists user cascade\n 2015-10-28 21:14:50.147 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: drop table if exists user cascade\n 2015-10-28 21:14:50.147 ERROR 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: syntax error at or near \"user\"\n ポジション: 22\n Hibernate: drop sequence hibernate_sequence\n 2015-10-28 21:14:50.155 INFO 3555 --- [ Thread-4] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete\n \n```\n\nエラーが起きたモデルの定義は下記のとおりです。\n\nuserテーブル\n\n```\n\n import javax.persistence.CascadeType;\n import javax.persistence.Column;\n import javax.persistence.Entity;\n import javax.persistence.FetchType;\n import javax.persistence.GeneratedValue;\n import javax.persistence.GenerationType;\n import javax.persistence.Id;\n import javax.persistence.OneToOne;\n \n \n @Entity\n public class User {\n \n @Id\n @GeneratedValue(strategy = GenerationType.AUTO)\n @Column(name = \"id\", nullable = false)\n private Long id;\n \n @Column(name = \"uid\", nullable = false)\n private String uid;\n \n @Column(name = \"provider\", nullable = false)\n private Providers provider;\n \n @Column(name = \"consumer_key\", nullable = false, unique = true)\n private String consumerKey;\n \n @OneToOne(cascade = CascadeType.ALL, fetch=FetchType.LAZY)\n private Profile profile;\n \n public User() {\n super();\n }\n \n public String getConsumerKey() {\n return consumerKey;\n }\n \n public void setConsumerKey(String consumerKey) {\n this.consumerKey = consumerKey;\n }\n \n public User(Providers provider){\n this.provider=provider;\n }\n \n public Long getId() {\n return id;\n }\n \n public void setId(Long id) {\n this.id = id;\n }\n \n public String getUid() {\n return uid;\n }\n \n public void setUid(String uid) {\n this.uid = uid;\n }\n \n public Providers getProvider() {\n return provider;\n }\n \n public void setProvider(Providers provider) {\n this.provider = provider;\n }\n }\n \n```\n\ngroupテーブル\n\n```\n\n import javax.persistence.Column;\n import javax.persistence.Entity;\n import javax.persistence.GeneratedValue;\n import javax.persistence.GenerationType;\n import javax.persistence.Id;\n \n @Entity\n public class Group {\n \n @Id\n @GeneratedValue(strategy = GenerationType.AUTO)\n @Column(name = \"id\", nullable = false)\n private Long id;\n \n @Column(name = \"player_count\")\n private Long playerCount;\n \n @Column(name = \"dominate_point\")\n private Long dominatePoint;\n \n \n \n public Group() {\n super();\n }\n \n public Long getId() {\n return id;\n }\n \n public void setId(Long id) {\n this.id = id;\n }\n \n public Long getPlayerCount() {\n return playerCount;\n }\n \n public void setPlayerCount(Long playerCount) {\n this.playerCount = playerCount;\n }\n \n public Long getDominatePoint() {\n return dominatePoint;\n }\n \n public void setDominatePoint(Long dominatePoint) {\n this.dominatePoint = dominatePoint;\n }\n \n \n }\n \n```\n\npointテーブル\n\n```\n\n import java.sql.Date;\n \n import javax.persistence.Column;\n import javax.persistence.Entity;\n import javax.persistence.GeneratedValue;\n import javax.persistence.GenerationType;\n import javax.persistence.Id;\n import javax.persistence.ManyToOne;\n \n import org.springframework.data.annotation.CreatedDate;\n \n @Entity\n public class Point {\n \n @Id\n @GeneratedValue(strategy = GenerationType.AUTO)\n @Column(name = \"id\", unique = true)\n private Long id;\n \n @Column(name = \"latitude\")\n private float latitude;\n \n @Column(name = \"longtitude\")\n private float longtitude;\n \n @Column(name = \"group_id\")\n private Long groupId;\n \n @CreatedDate\n private Date createdAt;\n \n @ManyToOne\n private Profile profile;\n \n \n \n public Point() {\n super();\n }\n \n public Long getId() {\n return id;\n }\n \n public void setId(Long id) {\n this.id = id;\n }\n \n public float getLatitude() {\n return latitude;\n }\n \n public void setLatitude(float latitude) {\n this.latitude = latitude;\n }\n \n public float getLongtitude() {\n return longtitude;\n }\n \n public void setLongtitude(float longtitude) {\n this.longtitude = longtitude;\n }\n \n public Long getGroupId() {\n return groupId;\n }\n \n public void setGroupId(Long groupId) {\n this.groupId = groupId;\n }\n \n public Date getCreatedAt() {\n return createdAt;\n }\n \n public void setCreatedAt(Date createdAt) {\n this.createdAt = createdAt;\n }\n \n public Profile getProfile() {\n return profile;\n }\n \n public void setProfile(Profile profile) {\n this.profile = profile;\n }\n \n \n }\n \n```\n\nエラーを見るとマイグレーションに失敗しているように見えるのですが、何が間違っているのかわかりません。アドバイスをお願いします。 \nデータベースはPostgresqlを使っています。データベースは作成済みです。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T12:31:30.420", "favorite_count": 0, "id": "18174", "last_activity_date": "2015-10-28T12:31:30.420", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "post_type": "question", "score": 3, "tags": [ "java", "sql", "spring", "postgresql", "spring-boot" ], "title": "Spring boot でデータベースをマイグレーションできない", "view_count": 1529 }
[]
18174
null
null
{ "accepted_answer_id": "18280", "answer_count": 3, "body": "createHoge, createFuga, execPiyo の三つメソッドがあります。\n\n * createHoge, createFuga はとても大きなデータを生成する関数で、データを生成したらコールバックを呼び出すものです\n * execPiyo は、createHoge, createFuga で生成したデータを処理する関数で、データ処理が完了したらコールバックを呼び出すものです。\n\n```\n\n createHoge(function(hoge) {\n createFuga(function(fuga) {\n execPiyo(hoge, fuga, function() {\n console.log(\"1piyo done.\");\n // この時点で hoge, fuga を破棄したい\n createHoge(function(hoge) {\n createFuga(function(fuga) {\n execPiyo(hoge, fuga, function() {\n console.log(\"2piyo done.\");\n });\n });\n });\n });\n });\n });\n \n```\n\nこのようなコールバック呼び出しの連鎖で実行できるものとします。で、連続して execPiyo を何回も実行したい時にcreateHoge,\ncreateFugaで生成したhoge, fuga をメモリから解放できずに困っています。\n\nRxJSやPromiseやgeneratorを使ってcreateHoge, createFuga,\nexecPiyoの実行を複数回書いてみたんですが、どのやり方でもメモリを食いすぎて途中で落ちてしまいます。\n\n補足: createHoge, createFuga, execPiyo の一連の処理は一回実行するだけなら問題ないんですが、複数回実行したいけど\ncallback のチェインを続けると途中でメモリが足りなくなります。\n\n何か解決方法はありますか?", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T13:34:19.047", "favorite_count": 0, "id": "18177", "last_activity_date": "2015-11-01T09:56:14.147", "last_edit_date": "2015-10-29T11:35:50.847", "last_editor_user_id": "635", "owner_user_id": "635", "post_type": "question", "score": 4, "tags": [ "javascript", "node.js" ], "title": "Node.jsのコールバックの連鎖の中でメモリ解放を行う方法", "view_count": 3889 }
[ { "body": "hoge、fugaに直接値を入れず、 \nhoge.data、fuga.dataなどのプロパティを作ってそこに入れることにしたら、 \n呼び出し先でのクリアができるのでは? \n(dataという名称は適当です)\n\nもう少し詳細に書くと、\n\n```\n\n function createHoge(callback) {\n     // 大きなデータhogeを生成\n     var hoge = ...\n callback(hoge);\n }\n \n```\n\nのようにしていたのを、\n\n```\n\n function createHoge(callback) {\n     // 大きなデータhogeを生成\n     var hoge.data = ...\n     callback(hoge);\n }\n \n```\n\nとして、createFugaでも同様にし、\n\n```\n\n createHoge(function(hoge) {\n createFuga(function(fuga) {\n         execPiyo(hoge, fuga, function() {\n            console.log(\"1piyo done.\");\n // この時点で hoge, fuga を破棄したい\n           hoge.data = null;\n fuga.data = null;\n \n```\n\nとすればうまく参照が切れるのではということです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-30T00:39:43.230", "id": "18227", "last_activity_date": "2015-10-31T01:35:53.383", "last_edit_date": "2015-10-31T01:35:53.383", "last_editor_user_id": "10103", "owner_user_id": "10103", "parent_id": "18177", "post_type": "answer", "score": 1 }, { "body": "`createHoge`の実装によっては、`hoge`に`null`を代入しても参照を切れるとは限りません。以下のコードでは`hoge`に`null`を代入していますが、ページごと落ちます。\n\n```\n\n function createHoge(callback) {\r\n // createHogeを呼ぶたびに10MB確保する\r\n var buffer = new ArrayBuffer(10000000); \r\n callback(buffer);\r\n }\r\n \r\n function createFuga(callback) {\r\n var buffer = new ArrayBuffer(10000000);\r\n callback(buffer);\r\n }\r\n \r\n function execPiyo(a, b, callback) {\r\n callback();\r\n }\r\n \r\n \r\n function foo(i, n) {\r\n createHoge(function(hoge) {\r\n createFuga(function(fuga) {\r\n execPiyo(hoge, fuga, function() {\r\n console.log(i + \"piyo done.\");\r\n // この時点で hoge, fuga を破棄したい\r\n \r\n // 破棄しようとしてnull を代入しても無駄\r\n hoge = null;\r\n fuga = null;\r\n \r\n if (n < i) return;\r\n foo(i + 1, n);\r\n });\r\n });\r\n });\r\n }\r\n \r\n // 1000回再帰する\r\n foo(0, 1000);\n```\n\n以下のように`createHoge`でローカル変数に参照を持たないようにすると回避できそうですが、実験するとどうもうまく参照を切れていないようです。理由はよくわかりませんが、以下のコードも落ちます。\n\n```\n\n function createHoge(callback) {\r\n // ローカル変数からバッファを参照していない\r\n callback(new ArrayBuffer(10000000));\r\n }\r\n \r\n function createFuga(callback) {\r\n callback(new ArrayBuffer(10000000));\r\n }\r\n \r\n function execPiyo(a, b, callback) {\r\n callback();\r\n }\r\n \r\n \r\n function foo(i, n) {\r\n createHoge(function(hoge) {\r\n createFuga(function(fuga) {\r\n execPiyo(hoge, fuga, function() {\r\n console.log(i + \"piyo done.\");\r\n // この時点で hoge, fuga を破棄したい\r\n \r\n hoge = null;\r\n fuga = null;\r\n \r\n if (n < i) return;\r\n foo(i + 1, n);\r\n });\r\n });\r\n });\r\n }\r\n \r\n \r\n foo(0, 1000);\n```\n\n`createHoge`の修正が難しい場合もあるでしょうし、`createHoge`を呼び出している側からできるひとつの方法としては、以下のように`setTimeout`などの非同期な処理を挟むという方法があります。こうすると実際にはコールスタックが積まれていかないので、一見再帰呼び出しのように見えますが正常に完了できます。\n\n```\n\n function createHoge(callback) {\r\n var buffer = new ArrayBuffer(10000000);\r\n callback(buffer);\r\n }\r\n \r\n function createFuga(callback) {\r\n var buffer = new ArrayBuffer(10000000);\r\n callback(buffer);\r\n }\r\n \r\n function execPiyo(a, b, callback) {\r\n callback();\r\n }\r\n \r\n \r\n function foo(i, n) {\r\n createHoge(function(hoge) {\r\n createFuga(function(fuga) {\r\n execPiyo(hoge, fuga, function() {\r\n console.log(i + \"piyo done.\");\r\n // この時点で hoge, fuga を破棄したい\r\n \r\n if (n < i) return;\r\n setTimeout(function() {\r\n foo(i + 1, n);\r\n }, 0)\r\n });\r\n });\r\n });\r\n }\r\n \r\n \r\n foo(0, 1000);\n```\n\nなお、この方法では一度の呼び出しに最低でも数ミリ秒のウェイトがかかることになりますが、 \nもっと短い時間で非同期処理を繰り返す特殊なテクニックもあります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-31T15:30:17.393", "id": "18280", "last_activity_date": "2015-11-01T09:56:14.147", "last_edit_date": "2015-11-01T09:56:14.147", "last_editor_user_id": "10330", "owner_user_id": "10330", "parent_id": "18177", "post_type": "answer", "score": 3 }, { "body": "[Hibiya\nRyutoさんの書かれた最初のコード](https://ja.stackoverflow.com/a/18280)で言いますと、プログラム終了まで参照を保持し続けているのは`hoge`や`fuga`の他、`buffer`,\n`a`, `b`も同様です。\n\nこの参照を切るために、強いて形をなるべく変えずに修正すると次のようなコードになります(アプローチとしては[eripongさんの示されている回答](https://ja.stackoverflow.com/a/18227)と同じです)。\n\n```\n\n function createHoge(callback) {\r\n var buffer = [new ArrayBuffer(10000000)];\r\n callback(buffer);\r\n }\r\n \r\n function createFuga(callback) {\r\n var buffer = [new ArrayBuffer(10000000)];\r\n callback(buffer);\r\n }\r\n \r\n function execPiyo(a, b, callback) {\r\n callback();\r\n }\r\n \r\n \r\n function foo(i, n) {\r\n createHoge(function(hoge) {\r\n createFuga(function(fuga) {\r\n execPiyo(hoge, fuga, function() {\r\n console.log(i + \"piyo done.\");\r\n \r\n // この時点で buffer[0] を破棄したい\r\n hoge[0] = null;\r\n fuga[0] = null;\r\n \r\n if (n < i) return;\r\n foo(i + 1, n);\r\n });\r\n });\r\n });\r\n }\r\n \r\n \r\n foo(0, 1000);\n```\n\n`buffer`を要素数1の配列とし、この配列の第1要素に本来渡したいオブジェクト(大容量オブジェクト)をセットします。 \nこの配列を引数として渡せば、呼び出し先で大容量オブジェクトの参照を切ることができます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-01T08:55:10.080", "id": "18299", "last_activity_date": "2015-11-01T09:13:23.087", "last_edit_date": "2017-04-13T12:52:38.920", "last_editor_user_id": "-1", "owner_user_id": "2808", "parent_id": "18177", "post_type": "answer", "score": 1 } ]
18177
18280
18280
{ "accepted_answer_id": null, "answer_count": 0, "body": "現状は、Ruby on Railsを使って、アプリケーションを創っております。\n\nそのアプリケーションの機能で、ランキングを作成しようと考えています。\n\n現状は、今後user_id、categoryなどの属性を付ける可能性が高いので拡張性の高いfluentdを入れて、logを出力する所までは出来ている状態です。現状のlogは下記のような状態となっております。\n\n```\n\n 2015-10-28T21:38:05+09:00 rails.log {\"messages\":\"{\\\"method\\\":\\\"GET\\\",\\\"path\\\":\\\"/\\\",\\\"format\\\":\\\"html\\\",\\\"controller\\\":\\\"index\\\",\\\"action\\\":\\\"index\\\",\\\"status\\\":200,\\\"duration\\\":305.17,\\\"view\\\":291.93,\\\"db\\\":1.54}\",\"level\":\"INFO\"}\n \n```\n\nこのあと、fluent.confの書き方がわからず、CSV形式で1行毎に3つめの`messages:`の中身を下記の様なCSVの形に分けたいのですが、分けられない状態となっています。\n\n|path |action| \n/ index \nabout show \nposts/1 show\n\n```\n\n <source>\n type tail\n format csv\n </source>\n \n```\n\nこういったアクセスログは通常dbに保存しないと思うので、 \n出来ればlogを監視してアクセスランキングのような機能を作成したいと考えております。 \nまた、dbに保存して定期的に削除するという方法は考えておりません。\n\n何か良い方法がありましたら、ご教授頂ければ幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T13:56:38.520", "favorite_count": 0, "id": "18178", "last_activity_date": "2015-10-29T05:15:57.653", "last_edit_date": "2015-10-29T05:15:57.653", "last_editor_user_id": "3639", "owner_user_id": "5969", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails", "linux", "fluentd" ], "title": "Railsでfluentdを使ってログをCSV形式にする方法がわかりません。", "view_count": 265 }
[]
18178
null
null
{ "accepted_answer_id": "18232", "answer_count": 2, "body": "[【Rails】fields_for と accepts_nested_attributes_for - kzy52's\nblog](http://kzy52.com/entry/2013/07/10/200144)\n\n**引用:**\n\n> accepts_nested_attributes_forです。すごく便利。 \n> profile_attributes= と academics_attributes= メソッドが追加される\n>\n> **登録時** \n> params = { user: { name: 'Test', profile_attributes: { nickname: 'test' } }\n> } \n> user = User.create(params[:user]) \n> user.profile.id # => 1 \n> ser.profile.nickname # => 'test'\n>\n> **更新時** \n> params = { user: { profile_attributes: { id: '1', nickname: 'test2' } } } \n> user = User.find 1 \n> user.update params[:user] \n> user.profile.nickname # => 'test2'\n\n \n \n**入れ子のForm** で使う`accepts_nested_attributes_for`ですが、 \n**末尾が=のメソッド** ができることがわかりました。\n\nまた **末尾が=のメソッド** の意味は、 \n[ruby on rails - Rubyのメソッド名の末尾に = (イコール) -\nスタック・オーバーフロー](https://ja.stackoverflow.com/questions/18114/ruby%e3%81%ae%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e5%90%8d%e3%81%ae%e6%9c%ab%e5%b0%be%e3%81%ab-%e3%82%a4%e3%82%b3%e3%83%bc%e3%83%ab) \nに質問させていただきわかりました。\n\nさて、上記引用の`create`と`update`ですが、 **Hash**\nを与えているだけにすぎず、`accepts_nested_attributes_for`で生えた **末尾が=のメソッド**\nと関係性が頭の中でひも付きません。 **Hash** を与えているだけに過ぎないのに **新しくメソッドを生やす意味** とはなんでしょうか?\nまたこのようなテクニックが簡単にわかる簡単なサンプルソースを付けていただけるとうれしいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T15:08:18.027", "favorite_count": 0, "id": "18179", "last_activity_date": "2015-10-30T04:17:39.957", "last_edit_date": "2017-04-13T12:52:38.920", "last_editor_user_id": "-1", "owner_user_id": "9008", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails", "ruby" ], "title": "accepts_nested_attributes_forで生えたメソッドとcreateやupdateの関係性", "view_count": 998 }
[ { "body": "## RoRでの似たような該当部分\n\n`accepts_nested_attributes_for`とは若干ずれますが、 \n`*=`を使ったテクニックとしては下記が該当するでしょうか。 \n(ActiveModel::Modelの話なのでそう大きくはずれていない)\n\n[Method: ActiveModel::Model#initialize — Documentation for rails\n(4.0.0)](http://www.rubydoc.info/docs/rails/4.0.0/ActiveModel%2FModel%3Ainitialize)\n\n**File 'activemodel/lib/active_model/model.rb', line 78**\n\n```\n\n def initialize(params={})\n params.each do |attr, value|\n self.public_send(\"#{attr}=\", value)\n end if params\n \n super()\n end\n \n```\n\n \n\n## Hashでインスタンス変数をSETする例(自作する場合)\n\n```\n\n class Hoge\n attr_accessor :a, :b\n \n def initialize(params={})\n params.each do |attr, value|\n self.public_send(\"#{attr}=\", value)\n end if params\n end\n end\n \n hoge = Hoge.new(a: \"A\", b:\"B\")\n puts hoge.a\n puts hoge.b\n \n```\n\n### *=メソッドはないけどよいの?\n\n`attr_accessor`のソースを読みに行くと、\n\n```\n\n # attr_accessor(symbol, ...) -> nil\n # attr_accessor(string, ...) -> nil\n # \n # Defines a named attribute for this module, where the name is\n # <i>symbol.</i><code>id2name</code>, creating an instance variable\n # (<code>@name</code>) and a corresponding access method to read it.\n # Also creates a method called <code>name=</code> to set the attribute.\n # String arguments are converted to symbols.\n # \n # module Mod\n # attr_accessor(:one, :two)\n # end\n # Mod.instance_methods.sort #=> [:one, :one=, :two, :two=]\n def attr_accessor(*several_variants)\n #This is a stub, used for indexing\n end\n \n```\n\nとなっており\n\n**`Mod.instance_methods.sort #=> [:one, :one=, :two, :two=]`** \nの部分から、 \n`attr_accessor`が **末尾=メソッド** を生やしているから不要でしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-30T03:03:28.217", "id": "18232", "last_activity_date": "2015-10-30T04:17:39.957", "last_edit_date": "2015-10-30T04:17:39.957", "last_editor_user_id": "9008", "owner_user_id": "9008", "parent_id": "18179", "post_type": "answer", "score": 0 }, { "body": "```\n\n user = User.create({:name => 'hoge', :email => 'fuga'})\n \n```\n\nは\n\n```\n\n user = User.new\n user.name = 'hoge'\n user.email = 'fuga'\n user.save\n \n```\n\nなどとも書けますが、Nested Attributesを使う時は後者の形式は使えない、では困るでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-30T03:07:13.350", "id": "18233", "last_activity_date": "2015-10-30T03:07:13.350", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "18179", "post_type": "answer", "score": 0 } ]
18179
18232
18232
{ "accepted_answer_id": null, "answer_count": 1, "body": "Xcode7.1でSyphon.framework追加時にエラーが発生します。\n\n全然、意味不明ながら以下の手順に従ってやったつもりなんですが、\n\n1.Add the framework to your Xcode project. \nThe simplest way is to drag it to the Frameworks group in the project window. \nLink your application with Syphon at build time.\n\n2.Add the framework to the Link Binary With Libraries build phase of your\napplication's target. \nCopy the framework into your application's bundle.\n\n3.Add a new Copy Files build phase to your application's target. \nSelect Frameworks as the destination. \nDrag the Syphon framework into the build phase.\n\nエラーメッセージは以下、\n\nld: framework not found Syphon \nclang: error: linker command failed with exit code 1 (use -v to see\ninvocation) \n[![スクリーンショット1](https://i.stack.imgur.com/rOmeM.png)](https://i.stack.imgur.com/rOmeM.png)\n\n環境はOS10.10.5です。 \nどうしたらコンパイルが通って実行できるでしょうか。よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T15:44:29.823", "favorite_count": 0, "id": "18180", "last_activity_date": "2023-05-03T16:02:45.347", "last_edit_date": "2015-10-31T16:41:35.257", "last_editor_user_id": "13017", "owner_user_id": "13017", "post_type": "question", "score": 0, "tags": [ "objective-c", "xcode", "macos", "xcode7" ], "title": "Xcode7.1でプロジェクトにSyphon.framework追加時にエラーが発生します。", "view_count": 644 }
[ { "body": "おそらくFramework Search Pathsの設定が抜けているのでフレームワークを見つけることができていないのだと思います。\n\nプロジェクトのビルド設定の「Framework Search Paths」にフレームワークがある場所のディレクトリを指定します。\n\nただ、おそらくそれは難しいと思いますので、\n\n最初からやり直して、プロジェクトのターゲットを選択して、「Embedded\nBinaries」(下記のスクリーンショットの場所)にフレームワークをドラッグ&ドロップするのが最も簡単な方法です。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/M0WvQ.png)](https://i.stack.imgur.com/M0WvQ.png)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T08:09:55.803", "id": "18198", "last_activity_date": "2015-10-29T08:09:55.803", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "18180", "post_type": "answer", "score": 0 } ]
18180
null
18198
{ "accepted_answer_id": null, "answer_count": 2, "body": "会員制の学習支援サイトをcakephp2.7で作りたいのですが、具体的にどういうテーブル設計にすればよいかよくわかりません。\n\nまず会員制なので会員テーブル(usersテーブル)でusernameカラムとpasswordカラムを用意。 \ncookbookのチュートリアルにあるようにこの命名規則に従うと「ユーザーログインを 実装するにあたってほとんどのことを CalePHP\nが自動的に設定します」ということでチュートリアルを進めた結果確かにログイン機能はできました。\n\n次に、問題演習のための問題文テーブル(questionsテーブル)。 \nカラムは問題IDカラム、q_body(問題文)カラム。 \nこの問題文テーブルに10問(10行)データが入っているとします。\n\nやりたいことは、会員登録したユーザ毎の進捗度の管理です。\n\n今考えているのは、ユーザ毎に進捗度テーブルを作って管理する方法です。 \n進捗度テーブルには、問題IDカラム、1回目の結果を書き込むtry1カラム。2回目の結果を書き込むtry2カラム。…を用意するつもりです。 \nユーザーが、初めて問題1を解いたら進捗度テーブルの問題1の行のtry1カラムに結果を書き込む。 \nユーザーが、再び問題1を解いたら進捗度テーブルの問題1の行のtry2カラムに結果を書き込む。 \nというようなことを実現したいです。\n\nこの場合会員1人につき進捗度テーブルを一つ用意することになると思うのですが、具体的にやるとなるとどうしていいかよくわかりません。\n\n 1. 会員登録時にその人用の進捗度テーブルを作る方法。\n 2. ①ができない場合、あらかじめ進捗度テーブルを連番でいっぱい作っておいて、会員登録した順に会員番号と進捗度テーブルを結びつける。\n\nと、いうことも考えたのですが、いずれにしても会員番号とその人用の進捗度テーブルを結びつける方法が必要。 \nつまり会員Aは会員A用進捗度テーブルには書き込めるが、他の会員用の進捗度テーブルには書き込めないような仕組みが必要。 \nそのためには会員Aがログインした場合A用進捗度テーブルに書き込むためのフォーム(ページ)が表示されるようにする必要がある。 \nこれって会員制サイトのいわゆるマイページにあたるものだと思うのですが、どうすれば実現できるでしょうか?\n\nとりあえずテーブル設計の考え方は上記の方針で問題ないでしょうか(これでやりたいことが実現可能でしょうか?) \n上記の方法では無理あるいは著しく非効率なので普通はこうする、みたいなのがあればお願いします。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T16:39:47.203", "favorite_count": 0, "id": "18184", "last_activity_date": "2015-10-29T14:12:09.097", "last_edit_date": "2015-10-29T07:40:05.967", "last_editor_user_id": "7290", "owner_user_id": "13018", "post_type": "question", "score": 2, "tags": [ "cakephp", "データベース設計" ], "title": "会員制サイトのテーブル設計", "view_count": 1271 }
[ { "body": "進捗度テーブルは一つ作れば十分だと思います。私ならそうします。\n\n進捗度テーブルに、ユーザーid(username)を格納するカラムを用意すればいいのです。 \n(ユーザーidは会員テーブルの主キーだと思うので、進捗度テーブルからしたら、外部キーということになります。が、外部キーはデータベースエンジンによっては、必ずしも実装されているわけでもないので、それほどこだわる点ではないかもしれません。)\n\nカラム構造としては以下の4種\n\n```\n\n 年月日時分秒,ユーザーid,問題番号,結果\n \n```\n\n同じユーザーが同じ年月日時分秒で2問以上解けることは考えにくいので、年月日時分秒とユーザーidをセットにすれば、一意性のある primary key\nとして機能します。\n\n* * *\n\nリレーショナル・データベースでは、クエリー(検索)時に、テーブルの写像(部分集合)を取り出すことができるので、\n\n> つまり会員Aは会員A用進捗度テーブルには書き込めるが、他の会員用の進捗度テーブルには書き込めないような仕組みが必要。\n\nこのようなことも、一つの進捗度テーブルで実現できます。一般的に DBMS では\n\n```\n\n SELECT * FROM 進捗度テーブル WHERE username='ユーザー名';\n \n```\n\nといったような SQL を使うなりする形になります。これにより、特定のユーザー名をもったエントリーのみの集合を結果として得ることができます。\n\nSQL の`WHERE`句は CakePHP\nなら[`find`](http://book.cakephp.org/2.0/ja/models/retrieving-your-\ndata.html)メソッドで渡すパラメーターで、`conditions` を設定することに相当すると思います。\n\n* * *\n\nある問題を解いた回数も、同じユーザーの同じ問題に関するエントリーがいくつあるかをクエリーで調べることで足るので、特に、Try1〜TryNまでの項目を「カラムとして用意する」必要はありません。カラムにする設計だとむしろ柔軟性に欠けます。\n\n* * *\n\nCakePHP 自体は特に Web の UI\nの部分をフレームワークとして提供してくれていますが、データベースに関する理解は前提条件として求められていると思います。suzukisさんが既にコメントで言及されているように、まずは\nCakePHP\nといった特定のフレームワーク・実装を扱う以前に、一度、リレーショナル・データベースについてせめて初級程度の勉強は別途済ませておくことをお勧めします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T13:55:35.307", "id": "18211", "last_activity_date": "2015-10-29T13:55:35.307", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7290", "parent_id": "18184", "post_type": "answer", "score": 5 }, { "body": "cakeの問題ではなく、リレーショナルデータベース(RDB)の使い方のイメージが付いていないのだと思います。 \n想定されているのは、以下のようなイメージですよね?\n\n```\n\n UserA結果Table\n 問題ID 1回目結果 2回目結果 3回目結果 …\n 1 ng ng ok\n 2 ok\n 3 ng ok\n \n```\n\n```\n\n UserB結果Table\n 問題ID 1回目結果 2回目結果 3回目結果 …\n 1 ok\n 2 ok\n \n```\n\nまず、 \n・ユーザ毎にtableを作るのは現実的では有りません。 \n・n回目の結果のように回数が変わる可能性があるものをカラムとして用意するのも現実的ではありません。\n\nRDBでは、正規化を行ってデータを効率良く格納する必要があります。 \n※『DB 正規化』でググるとたくさん出てきます。\n\n以下は、あくまで1つの例ですので、こうしなければならないというものではありませんので、参考として受け取ってください。\n\n結果tableは以下のように定義します。\n\n```\n\n 結果テーブル\n ユーザID 問題ID 解いた回数 結果 実施日時\n A 1 2 ok 2015-10-29 12:59\n A 1 1 ng 2015-10-29 12:41\n B 10 1 ng 2015-10-29 12:01\n C 2 1 ok 2015-10-29 12:33\n A 2 1 ok 2015-10-29 13:15\n C 1 1 ok 2015-10-29 12:11\n C 3 1 ok 2015-10-29 12:41\n \n```\n\nこのようなtableを用意して、ユーザAの結果が知りたい場合は、ユーザIDが『A』のレコードだけ絞り込みます。※`where\nユーザID='A'`で以下のような結果が得られます。\n\n```\n\n 結果テーブル\n ユーザID 問題ID 解いた回数 結果 実施日時\n A 1 2 ok 2015-10-29 12:59\n A 1 1 ng 2015-10-29 12:41\n A 2 1 ok 2015-10-29 13:15\n \n```\n\n更に、ユーザAの問題1の結果が知りたい場合は、ユーザIDが『A』で問題IDが『1』のレコードだけ絞り込みます。※`where ユーザID='A' and\n問題ID='1'`で以下のような結果が得られます。\n\n```\n\n 結果テーブル\n ユーザID 問題ID 解いた回数 結果 実施日時\n A 1 2 ok 2015-10-29 12:59\n A 1 1 ng 2015-10-29 12:41\n \n```\n\n上記のような実行結果を利用してやるのがRDBの使い方です。 \n『RDB 選択』『RDB 射影』『RDB 結合』のようなキーワードでググッてみてください。\n\nこのようなRDBの使い方を理解してからcakePHPの勉強をしないと、どちらの勉強も進まないと思います。 \nがんばってみてください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T14:12:09.097", "id": "18212", "last_activity_date": "2015-10-29T14:12:09.097", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2383", "parent_id": "18184", "post_type": "answer", "score": 7 } ]
18184
null
18212
{ "accepted_answer_id": null, "answer_count": 1, "body": "ffmpegのコンパイルに失敗していてIllegal\ninstructionというエラーが起きていたんですが、以前このエラーについて質問した際に教えてくれた内容でコンパイルしなおしたところ上記のエラーがなくなりました!\n\nしかしIllegal instructionでとまっていた処理が進み処理を見ていたら途中で\n\n```\n\n Failed to open segment 'streamfiles/stream000.ts'\n \n```\n\nとでてその後に\n\n```\n\n Could not write header for output file #0 (incorrect codec parameters ?):\n No such file or directory\n \n```\n\nとでました。streamfilesの権限の問題かと思って777にしましたが改善しませんでした。 \nこのファイルの位置は `/usr/share/nginx/www/streamfiles` です。 \nこれは権限以外に原因があると思うのですが、どういったエラーなんでしょうか?\n\n機器はRaspberry Pi B+です。\n\n実行したコマンドはこれです。\n\n```\n\n ffmpeg -i test.mp4 -threads 2 -codec:v libx264 -s:v 1280x720\n -aspect:v 16:9 -b:v 256k -map 0 -f segment\n -segment_format mpegts -segment_time 10\n -segment_list stream.m3u8 streamfiles/stream%03d.ts\n \n```\n\n実行結果は次のようになりました。\n\n```\n\n ffmpeg version N-75926-gce0834b Copyright (c) 2000-2015 the FFmpeg developers\n built with gcc 4.6 (Debian 4.6.3-14+rpi1)\n configuration: --arch=armel --target-os=linux --enable-shared --enable-gpl --enable-libx264 --enable-nonfree\n libavutil 55. 3.100 / 55. 3.100\n libavcodec 57. 5.100 / 57. 5.100\n libavformat 57. 3.100 / 57. 3.100\n libavdevice 57. 0.100 / 57. 0.100\n libavfilter 6. 11.100 / 6. 11.100\n libswscale 4. 0.100 / 4. 0.100\n libswresample 2. 0.100 / 2. 0.100\n libpostproc 54. 0.100 / 54. 0.100\n Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':\n Metadata:\n major_brand : isom\n minor_version : 512\n compatible_brands: isomiso2avc1mp41\n encoder : Lavf56.40.100\n Duration: 00:00:03.28, start: 0.000000, bitrate: 10159 kb/s\n Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 10156 kb/s, 25 fps, 25 tbr, 1200k tbn, 2400k tbc (default)\n Metadata:\n handler_name : VideoHandler\n [libx264 @ 0xa4dd00] using SAR=1/1\n [libx264 @ 0xa4dd00] using cpu capabilities: none!\n [libx264 @ 0xa4dd00] profile High, level 3.1\n [libx264 @ 0xa4dd00] 264 - core 148 r2638 7599210 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=2 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=256 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00\n [segment @ 0xa4cd20] Failed to open segment 'streamfiles/stream000.ts'\n Output #0, segment, to 'streamfiles/stream%03d.ts':\n Metadata:\n major_brand : isom\n minor_version : 512\n compatible_brands: isomiso2avc1mp41\n encoder : Lavf57.3.100\n Stream #0:0(und): Video: h264 (libx264), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 256 kb/s, 25 fps, 25 tbn, 25 tbc (default)\n Metadata:\n handler_name : VideoHandler\n encoder : Lavc57.5.100 libx264\n Stream mapping:\n Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))\n Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory\n [libx264 @ 0xa4dd00] final ratefactor: 40.16\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-28T19:28:17.370", "favorite_count": 0, "id": "18186", "last_activity_date": "2019-09-25T02:44:05.677", "last_edit_date": "2015-10-29T03:32:32.453", "last_editor_user_id": null, "owner_user_id": "9349", "post_type": "question", "score": 2, "tags": [ "raspberry-pi", "ffmpeg", "raspbian" ], "title": "ffmpegのエンコード時に起こるエラーについて", "view_count": 10766 }
[ { "body": "コメントの情報を参考に、実行時に出力先のファイルを **絶対パス** で指定することで解決しました。\n\n```\n\n ffmpeg \\\n ...\n -segment_list stream.m3u8 \\\n /usr/share/nginx/www/streamfiles/stream%03d.ts\n \n```\n\n* * *\n\nこの回答は [@社畜根性\nさんのコメント](https://ja.stackoverflow.com/questions/18186/ffmpeg%e3%81%ae%e3%82%a8%e3%83%b3%e3%82%b3%e3%83%bc%e3%83%89%e6%99%82%e3%81%ab%e8%b5%b7%e3%81%93%e3%82%8b%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6#comment16923_18186)\nを元にコミュニティwikiとして投稿しています。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-09-25T02:44:05.677", "id": "59250", "last_activity_date": "2019-09-25T02:44:05.677", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "18186", "post_type": "answer", "score": 1 } ]
18186
null
59250
{ "accepted_answer_id": null, "answer_count": 1, "body": "SAStruts、Tomcat6で動作しているアプリケーションがあり、 \nTomcat7に移行することになりました。\n\nしかし、javax.servlet.ServletRequestWrapper.isAsyncStarted(ServletRequestWrapper.java:396) \nでAbstractMethodErrorが発生しております。 \nこのメソッドには「@since Servlet 3.0」と記載があり、 \nrequestの実体であるStruts1.2.9の「org.apache.struts.upload.MultipartRequestWrapper」には \n実装されておりません。 \n(Javadocには「Servlet 2.3」という記載がありました。)\n\nよって、Struts1.2.9を使用しているSAStrutsはServlet3.0に非対応で、 \nServlet3.0であるTomcat7は非対応と考えました。\n\nしかし、それならばWeb上でその情報があるかと思ったのですが全く見つからないため質問させて頂きました。\n\n### 実際のコード\n\n```\n\n RequestUtil.getRequest().getRequestDispatcher(input).forward(RequestUtil.getRequest(),ResponseUtil.getResponse());\n \n```\n\n### StackTrace\n\n```\n\n 10 29, 2015 10:11:13 午前 org.apache.catalina.core.ApplicationDispatcher invoke\n 重大: サーブレット action のServlet.service()が例外を投げました\n java.lang.AbstractMethodError\n at javax.servlet.ServletRequestWrapper.isAsyncSupported(ServletRequestWrapper.java:407)\n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:225)\n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)\n at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)\n at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)\n at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)\n \n```\n\n### その他環境\n\n * Eclipse 4.4.1\n * Java 1.7.0_67\n * コンパイラー準拠レベル 1.7\n * Tomcat 7.0.61\n * SAStruts 1.0.4-sp7\n\n* * *\n\n### 追記1\n\n今回の事象が発生した「MultipartRequestWrapper」はファイル送信時(htmlのformに「enctype=\"multipart/form-\ndata\"」が設定される場合)にStrutsがラップしてくれるクラスのようです。 \n(通常の場合はrequestの実体は「org.apache.catalina.core.ApplicationHttpRequest」クラスでした。) \nつまり、通常はStrutsがRequestをラップしないので、Tomcatが使用しているClassそのままなので特に問題なし。 \nファイル送信時にはStrutsがServlet2.3準拠?のクラスでラップしてしまうため、その後Tomcatが使用しているクラスからrequestインスタンスを使用しようとするとエラーが発生してしまうという流れかと思われます。\n\n* * *\n\n### 追記2\n\n本来ならばコメントに書くべきと思いますが、記載できないため本文に記載させて頂きます。 \nご指摘頂いた内容を試したことで、色々わかってきた気がします。ありがとうございます。 \nEclipse上ではWTPで、プロジェクトファセットの設定は2.5になります。 \nまた、mavenを使用しており、servlet-apiは以下のように指定しています。\n\n```\n\n <dependency>\n <groupId>javax.servlet</groupId>\n <artifactId>servlet-api</artifactId>\n <version>2.5</version>\n <scope>provided</scope>\n </dependency>\n \n```\n\nこのため、コンパイル時には2.5が使用され、ビルド、デプロイ後には含まれないため、動作時にはTomcat7に含まれる3.0.1?が使用されているかと思われます。\n\ntutorialでも動作確認をした所、A-pZさんのご指摘の通りアップロードのサンプルも動作致しました。(1.0.4-sp7で試しました。) \nチュートリアルで「/sa-struts-\ntutorial/src/main/java/tutorial/action/UploadAction#upload」に今回の問題が発生したコードを追加してみた所、\n\n```\n\n RequestUtil.getRequest().getRequestDispatcher(\"index.jsp\").forward(RequestUtil.getRequest(),ResponseUtil.getResponse());\n \n```\n\n「RequestUtil.getRequest()」で返ってくるHttpServletRequest(MultipartRequestWrapper)のgetRequestDispatcherメソッド呼び出しで呼ばれる実メソッドはlib内の「geronimo-\nservlet_2.4_spec-1.0.jar」が呼ばれているように見受けられます。 \n障害が発生している環境ではここで、Tomcat内の「servlet-\napi.jar」クラスが親となり3.0のメソッドが呼ばれている事が原因かと思われますがいかがでしょうか? \nこの場合、「servlet-api.jar」を含めて、Tomcatにもこちらを使ってもらうというのが対処になるのでしょうか?\n\n* * *\n\n### 追記3\n\n記載が漏れておりましたが、web.xmlは2.5を指定しております。 \nfilterも調査致しましたが、特に今回の問題と関係あるような処理は行っておりませんでした。\n\n* * *\n\n### 追記4\n\nRequestUtil は org.seasar.struts.util.RequestUtil になります。 \n確かにここで3.x系のRequestを取得してしまっています。 \ngetRequestの実装は以下の通りです。\n\n```\n\n public static HttpServletRequest getRequest() {\n return SingletonS2Container.getComponent(HttpServletRequest.class);\n }\n \n```\n\n* * *\n\n### 追記5\n\n現象の再現ありがとうございます! \n遥か昔からあるアプリケーションの保守のため、何故ここでforwardを行っているのかはわからないというのが正直な所です。(forward後にnullを返しています。) \nただ、jspのファイル名を指定した所、問題の現象が発生せず正しく動作することを確認できました。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T01:40:50.777", "favorite_count": 0, "id": "18187", "last_activity_date": "2015-11-04T10:42:21.363", "last_edit_date": "2015-11-04T10:42:21.363", "last_editor_user_id": "-1", "owner_user_id": "13020", "post_type": "question", "score": 3, "tags": [ "java", "tomcat", "sastruts" ], "title": "SAStrutsはTomcat7で動作しますか?", "view_count": 3542 }
[ { "body": "Tomcat7系でもSAStrutsは動作します。 \nまた、Tomcat7はServlet3.0\"でも\"動作しますが、Servlet2.x系も動作します。\n\n確認なのですが、web.xmlにてサーブレットバージョン3.0を指定してはいないでしょうか。 \nないしはservlet-api.jarの3.0をwarファイルの中へ独自で入れてはいないでしょうか。\n\n動作確認は以下の環境で行いました。\n\n * Preiades All in one Eclipse 4.5.0\n * jdk 1.7.0_71\n * コンパイラ準拠レベル 1.7\n * Tomcat 7.0.61\n * 動作アプリケーション : SA-Struts-tutorial 1.0.4-sp9\n\n* * *\n\n追記1\n\nWEB-INF/lib 内に配置されているjarファイルを列挙します。こちらはsa-struts-\ntutorialのものですので、過不足がないかご確認ください。\n\n * antlr.jar\n * aopalliance-1.0.jar\n * commons-beanutils-1.7.0.jar\n * commons-collections-3.1.jar\n * commons-digester-1.6.jar\n * commons-el-1.0.jar\n * commons-fileupload-1.2.jar\n * commons-io-1.3.2.jar\n * commons-logging-1.1.jar\n * commons-validator-1.2.0.jar\n * geronimo-annotation_1.0_spec-1.0.jar\n * geronimo-ejb_3.0_spec-1.0.jar\n * geronimo-interceptor_3.0_spec-1.0.jar\n * geronimo-jpa_3.0_spec-1.0.jar\n * geronimo-jta_1.1_spec-1.0-tsr.jar\n * geronimo-jta_1.1_spec-1.0.jar\n * jakarta-oro-2.0.8.jar\n * javassist-3.4.ga.jar\n * jstl-1.1.2.jar\n * log4j-1.2.13.jar\n * ognl-2.6.9-patch-20070908.jar\n * poi-3.0-FINAL.jar\n * s2-extension-2.4.44.jar\n * s2-framework-2.4.44.jar\n * s2-tiger-2.4.44.jar\n * sa-struts-1.0.4-sp9.jar\n * standard.jar\n * struts-1.2.9.jar\n\n* * *\n\n追記2\n\nWTPをお使いとのことでしたので、私もWTPを使って、念のためweb.xmlにてサーブレット3.0を指定しましたが動作に問題ありませんでした。\n\n他に考えられるとすれば、独自に追加されているjarファイルや、マルチパートリクエストを検知して動作するサーブレットフィルタがある場合は影響があるかもしれません。\n\n* * *\n\n追記3\n\n情報ありがとうございます。フィルタやjarファイルの過不足などには問題はなさそうですね。 \nそうなると新たに疑問点が1つありまして、元々のソースにありました\n\n```\n\n RequestUtil.getRequest()\n \n```\n\nですが、このRequestUtilはStruts1.2.9のものではなく、別のクラスでしょうか? \nというのも、Struts2のrequestUtilにはgetRequest()は存在しませんでした。\n\n(おそらくMultipartRequestWrapperのgetRequest()のことかと思いますが)\n\nここで取得しているサーブレットリクエスト(ServletRequest)の取得で、2.x系のサーブレットリクエストを取得できていないのではないか、と思います。\n\n* * *\n\n追記4\n\nこちらで現象を確認できました。RequestDispatcherを取得してforward()することで同様のエラーを検出しました。 \nひとつ気になるのが、SAStrutsではActionからreturnする値はjspのファイル名を指定するだけで良く(例えば、return\n\"index.jsp\")、Servlet+JSPを使った場合のようにフォワードをする必要はないのですが、フォワードしなければならない理由はありますか。\n\n参考になれば幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T01:58:28.103", "id": "18188", "last_activity_date": "2015-11-04T08:12:26.677", "last_edit_date": "2015-11-04T08:12:26.677", "last_editor_user_id": "5778", "owner_user_id": "5778", "parent_id": "18187", "post_type": "answer", "score": 1 } ]
18187
null
18188
{ "accepted_answer_id": "18243", "answer_count": 1, "body": "Bluemixでphpのランタイムから、以下のアプリケーションを作成してみました。 \n<http://phptest20151023.mybluemix.net/>\n\nこの環境に対して、httpdの設定を行いたい場合は、(例えばIP制限をかけようとしてみたのですが)どのようにすればよろしいでしょうか?\n\nダッシュボードの「ファイルとログ」から、httpd.confが見えるのですが、編集はできないようで、またsshで環境へのリモート接続を試みたのですが、通らないようでした。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T06:19:26.493", "favorite_count": 0, "id": "18191", "last_activity_date": "2015-10-30T11:12:58.307", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10629", "post_type": "question", "score": 0, "tags": [ "php", "bluemix" ], "title": "Bluemix phpアプリの httpd 設定方法は?", "view_count": 158 }
[ { "body": "[cloudfoundry/php-buildpack](https://github.com/cloudfoundry/php-\nbuildpack)を利用してみてはいかがでしょうか。\n\nサンプルアプリケーションとしてphpMyAdminがあり、この中`.bp-config`以下でデフォルトのhttpdの設定を上書きしています。\n\nもしBluemix上でphpMyAdminサンプルを試される場合は、manifest.ymlのdomainを`mybluemix.net`に書換える必要があります。\n\n設定の詳細は [HTTPD, Nginx and PHP\nconfiguration](https://github.com/cloudfoundry/php-\nbuildpack/blob/master/docs/config.md#httpd-nginx-and-php-configuration)\nを参照してみて下さい。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-30T11:12:58.307", "id": "18243", "last_activity_date": "2015-10-30T11:12:58.307", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "186", "parent_id": "18191", "post_type": "answer", "score": 0 } ]
18191
18243
18243
{ "accepted_answer_id": "18195", "answer_count": 1, "body": "中国語のピンインをEmacs上で打ちたくLispを書こうとしてるのですが、キーバインディングの変更程度しか書いたことがなく躓いています。\n\n```\n\n (defun make-tone-2 ()\n (interactive)\n (insert \"foo\"))\n \n (define-minor-mode pinyin-mode\n \"Input pinyin\"\n :lighter \" PinYin\"\n :keymap (let ((map (make-sparse-keymap)))\n (define-key map (kbd \"2\") 'make-tone-2)\n map))\n \n```\n\nとりあえずこのように minor-mode の定義を行い、`make-tone-2`で現在のカーソルの左方向にあるスペース以外の英文字を取得して auoi\nがあれば、それぞれáúóí に置換しようと考えています。(ただしカーソルに一番近い文字のみ)\n\nどの関数を使えばよいかも全くわからない状態で、どのように実装すれば良いかヒントを頂けないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T06:51:13.687", "favorite_count": 0, "id": "18193", "last_activity_date": "2015-10-29T07:44:50.783", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3271", "post_type": "question", "score": 3, "tags": [ "emacs", "elisp" ], "title": "Emacsでカーソルの位置から左方向に特定の文字を検索して置換する", "view_count": 113 }
[ { "body": "`make-tone-2` 関数を以下の様にしてみてはどうでしょうか。\n\n```\n\n (defun make-tone-2 ()\n (interactive)\n (save-excursion\n (let* ((tbl '((\"a\" \"á\") (\"u\" \"ú\") (\"o\" \"ó\") (\"i\" \"í\")))\n (regexp (concat \"[\" (mapconcat 'car tbl \"\") \"]\")))\n (and (re-search-backward regexp nil t 1)\n (replace-match (cadr (assoc (match-string 0) tbl)))))))\n \n```\n\n変換する文字を変更する場合は `tbl`(assoc-list) の内容を適宜変えて下さい。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T07:28:29.960", "id": "18195", "last_activity_date": "2015-10-29T07:44:50.783", "last_edit_date": "2015-10-29T07:44:50.783", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "18193", "post_type": "answer", "score": 1 } ]
18193
18195
18195
{ "accepted_answer_id": null, "answer_count": 2, "body": "iOS9以降から実装されているQuick Action(3D touch)を開発していますが \nAppdelegate内から指定したViewController(StoryBoard)の呼び出しはできましたが \nTabBarControllerの呼び出し方法がわかりません \nrootViewControllerにStoryBoardで作成したTabBarをどのようにして追加すればよろしいのでしょうか?\n\n```\n\n -(void)application:(UIApplication *)application\n performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem\n completionHandler:(void (^)(BOOL))completionHandler{\n if([shortcutItem.type compare:@\"info.plistのTypeコード\"] == NSOrderedSame) {\n \n self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];\n UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@\"Main\" bundle:nil];\n \n UIViewController *viewController;\n viewController = [storyboard instantiateViewControllerWithIdentifier:@\"ViewControllerID名\"];\n self.window.rootViewController = viewController;\n [self.window makeKeyAndVisible];\n }\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T07:10:29.383", "favorite_count": 0, "id": "18194", "last_activity_date": "2015-10-30T05:05:28.983", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13025", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c", "xcode", "iphone" ], "title": "iOS9 Quick Action 画面遷移", "view_count": 478 }
[ { "body": "解決しました\n\n```\n\n UIViewController *viewController;\n viewController = [storyboard instantiateViewControllerWithIdentifier:@\"ViewControllerID名\"];\n self.window.rootViewController = viewController;\n \n```\n\nから↓でUITabのIndex=1に割り当てているViewの表示ができました\n\n```\n\n UITabBarController *tabBarController = [storyboard instantiateViewControllerWithIdentifier:@\"tabBarControllerID名\"];\n tabBarController.selectedIndex=1;\n self.window.rootViewController = tabBarController;\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T13:40:39.967", "id": "18210", "last_activity_date": "2015-10-29T13:40:39.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13025", "parent_id": "18194", "post_type": "answer", "score": 1 }, { "body": "補足的な回答をします。「こういうこともできるよ」、「こうしたほうがいいんじゃないかなあ?」くらいの内容です。\n\n`UIStoryboard`のメソッド`- (UIViewController\n*)instantiateViewControllerWithIdentifier:(NSString *)identifier`の代わりに`-\n(UIViewController *)instantiateInitialViewController`を使うことを検討してください。 \n後者のメソッドは、Storyboard内の基底ViewControllerをインスタンス化して、返します。「基底」というのは、下図の矢印が付いているViewControllerのことで、Attributes\nInspectorで、「Is Initial View Controller」にチェックが入っています。\n\n```\n\n UITabBarController *tabBarController = (UITabBarController *)[storyboard instantiateInitialViewController];\n tabBarController.selectedIndex=1;\n self.window.rootViewController = tabBarController;\n \n```\n\nStoryboardの編集の意図に従ったインスタンス化をするというのが、このメソッドを使う意味です。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/pgWwl.png)](https://i.stack.imgur.com/pgWwl.png)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T23:20:25.693", "id": "18225", "last_activity_date": "2015-10-30T05:05:28.983", "last_edit_date": "2015-10-30T05:05:28.983", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "18194", "post_type": "answer", "score": 0 } ]
18194
null
18210
{ "accepted_answer_id": null, "answer_count": 1, "body": "jQuery Raty(<http://wbotelhos.com/raty>)\nを使用して、書籍のレビューを投稿するフォームに5段階評価をつけたいと思っています。\n\n```\n\n <form action=\"review.php\" method=\"post\">\n <label class=\"control-label\" for=\"title\">作品名</label>\n <input type=\"text\" name=\"title\" id=\"title\" class=\"form-control\">\n <label class=\"control-label\" for=\"author\">作者名</label>\n <input type=\"text\" name=\"author\" id=\"author\" class=\"form-control\">\n <label class=\"control-label\" for=\"review\">感想・意見</label>\n <textarea name=\"review\" class=\"form-control\" rows=\"6\"></textarea>\n <label class=\"control-label\" for=\"star\">評価(5段階)</label>\n <div id=\"star\"></div>\n <script type=\"text/javascript\">\n $.fn.raty.defaults.path = \"./images\";\n $('#star').raty();\n </script>\n </div>\n <div class=\"form-group\">\n <input type=\"submit\" class=\"btn btn-primary\" value=\"送信する\">\n </div>\n \n```\n\nこのとき、review.phpで$_POST['author']などと同様に投票された値を取得して、mysqli_queryなどでその値をDBに格納したいのです。\n\n調べてみたところ、JavascriptのonclickでPHPにデータを渡す方法はあったものの、フォームのsubmitを利用してデータを渡す方法はありませんでした。\n\n先日初めてPHPとMySQLをさわり(jQueryもほとんど経験の無い)初心者なので至らないところも多々あると存じますが何卒ご教示頂ければ幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T07:56:47.063", "favorite_count": 0, "id": "18197", "last_activity_date": "2016-10-13T03:58:52.417", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13028", "post_type": "question", "score": 1, "tags": [ "javascript", "php", "jquery", "mysql" ], "title": "jQuery Ratyの評価をsubmitボタンでPHPに渡す方法", "view_count": 733 }
[ { "body": "<http://wbotelhos.com/raty> には target の項目があります。 \n★が選択されたときに、input の value を変更する事ができるようです。\n\n```\n\n <input id=\"hint\" type=\"text\" />\n \n```\n\nこの type を hidden にすれば、form の submit 時に、データが渡されるようになると考えます。\n\n```\n\n <input id=\"hint\" type=\"hidden\" />\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-01T07:52:04.757", "id": "18298", "last_activity_date": "2015-11-01T07:52:04.757", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7471", "parent_id": "18197", "post_type": "answer", "score": 1 } ]
18197
null
18298
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在、SNS分析のためにPythonでPython-\ntwitterを使おうと考えています。oauth2,httplib2,simplejsonをそれぞれインストールし、Python‐twitterのインストールまでは行うことができました。(それぞれimportで確認済み) \nしかし以下のようなエラーが出てしました。\n\nPythonなどのプログラミング言語も全て今年の春から学習し始めた初心者です。 \ngoogleや本を読みながらなんとかここまで来ましたが先に進めません。どうぞよろしくお願いします。\n\n**エラー内容**\n\n※ユーザー名は伏字にしてあります\n\n```\n\n >>> api = twitter.Api()\n >>> statuses = api.GetUser('*********')\n \n Traceback (most recent call last):\n File `\"<pyshell#10>\",` line 1, in <module>\n statuses = api.GetUser('********')\n File \"build\\bdist.win32\\egg\\twitter\\api.py\", line 1847, in GetUser\n if not self.__auth:\n AttributeError: 'Api' object has no attribute '_Api__auth'\n \n```\n\n**環境** \npython2.7.8 \nhttplib2-0.9.2 \noauthlib-1.0.3 \nsimplejson-3.8.0 \npython-twitter-2.2", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2015-10-29T08:18:57.100", "favorite_count": 0, "id": "18199", "last_activity_date": "2022-12-27T04:42:10.267", "last_edit_date": "2022-12-27T04:42:10.267", "last_editor_user_id": "3060", "owner_user_id": "13026", "post_type": "question", "score": 0, "tags": [ "python", "api", "twitter" ], "title": "Python-twitter でエラー AttributeError: 'Api' object has no attribute '_Api__auth'", "view_count": 1119 }
[ { "body": "Githubに同じ質問がありました。 \n<https://github.com/bear/python-twitter/issues/119>\n\n`twitter.Api()`に認証用の4つの引数を与え、以下の形にすれば動くと思います。\n\n```\n\n api = twitter.Api(consumer_key='consumer_key',\n consumer_secret='consumer_secret',\n access_token_key='access_token',\n access_token_secret='access_token_secret')\n \n```\n\ntoken等の取得方法はドキュメントのAPIの項にあります。 \n<https://github.com/bear/python-twitter#api>\n\n日本語だと、少し古いですが例えば以下のブログ記事に説明がありました。 \n[Twitterアプリケーションの作成(Consumer key、Consumer secret、Access token、Access token\nsecretの確認方法)](http://website-\nplanner.com/twitter%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E4%BD%9C%E6%88%90%EF%BC%88consumer-\nkey%E3%80%81consumer-secret%E3%80%81access-token%E3%80%81access-token-secret/)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-30T07:51:36.170", "id": "18242", "last_activity_date": "2015-10-30T07:57:36.107", "last_edit_date": "2015-10-30T07:57:36.107", "last_editor_user_id": "3589", "owner_user_id": "3589", "parent_id": "18199", "post_type": "answer", "score": 2 } ]
18199
null
18242
{ "accepted_answer_id": "18205", "answer_count": 1, "body": "iPadアプリを開発しております。\n\nテキストフィールドのKeyboardTypeにUIKeyboardTypeASCIICapableでASCIIキーボードを指定しているのですが、iOS9.1のみ以下の画像のように、指定のキーボードタイプとは別のタイプのものが表示されてしまいます。\n\n確認した限りでは、iPad Retina, iPad2, iPad Airで発生しておりました。\n\n左下の地球のマークでキーボードを切り替えようとすると、以下のような「Alternate\nKeyboard」というダイアログが表示され切り替えが可能になります。\n\niOS9の場合にも、指定したキーボードタイプを表示するには、どのように指定すればよろしいでしょうか? \n現状は、StoryboardとViewController両方で指定をしておりますが、それでも指定のキーボードが表示されないという状況です。\n\nご教示いただけたらとおもいます。よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T08:31:05.197", "favorite_count": 0, "id": "18200", "last_activity_date": "2015-10-30T04:06:14.313", "last_edit_date": "2015-10-30T04:06:14.313", "last_editor_user_id": "8682", "owner_user_id": "8682", "post_type": "question", "score": 1, "tags": [ "ios", "objective-c" ], "title": "iOS9.1でiPadキーボードタイプの指定ができない問題について", "view_count": 2062 }
[ { "body": "スクリーンショットはシミュレーターだと思いますが、「日本語かな」キーボードが現在のキーボードになっています。 \nおそらくは、これが「日本語ローマ字」キーボード、あるいは「English\n(US)」キーボードに自動的に切り替わることを期待しているのかと思いますが、そういう動作はしません。\n\niOSでは(9.1に限らず)ユーザーが「設定」で追加してある複数のキーボードを切り替えられるようになっていますが、keyboardTypeはキーボードそのものを切り替えるのではなく、現在選ばれているキーボードの動作モードを指定するものです。 \nキーボードそのものを切り替える方法は、ユーザーが地球儀のキーを押す以外にはないと思います。\n\n「日本語かな」キーボードでUIKeyboardTypeASCIICapableを指定した場合は、「ABC」のモードが選択された状態になります。(スクリーンショットもそうなっているので正しく動いていると思います)\n\nその他のキーボードでも、個々のキーボードに応じた適切な動作になります。\n\niOS 9.1だけがこうなるというのは、iOS 8などの他の試した環境では、現在選ばれているキーボードが「日本語かな」ではなかっただけではないでしょうか。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-29T11:37:15.473", "id": "18205", "last_activity_date": "2015-10-29T11:37:15.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2851", "parent_id": "18200", "post_type": "answer", "score": 2 } ]
18200
18205
18205