question
dict | answers
list | id
stringlengths 2
5
| accepted_answer_id
stringlengths 2
5
⌀ | popular_answer_id
stringlengths 2
5
⌀ |
---|---|---|---|---|
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "jsonでリストを取り出し変数に複数の値が入っているとします。\n\nA = [1,2,3,4,5]\n\nB = [-1,-2,-3,-4,-5]\n\nこの時にA + B をしたいのですがうまくいきません\n\nAの1とBの-1を+した値をABに代入 \nAの2とBの-2を+した値をABに代入 \nAの3とBの-3を+した値をABに代入 \nAの4とBの-4を+した値をABに代入 \nAの5とBの-5を+した値をABに代入\n\nと動かしたいです。ABは最終的に5つの値をもつ変数にしたいです。\n\n```\n\n A = [1,2,3,4,5]\n B = [-1,-2,-3,-4,-5]\n \n A + B = AB\n print(AB)\n \n```\n\nエラーコード\n\n```\n\n SyntaxError: can't assign to operator\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T05:47:19.577",
"favorite_count": 0,
"id": "45413",
"last_activity_date": "2018-07-08T23:26:36.283",
"last_edit_date": "2018-07-08T13:36:38.080",
"last_editor_user_id": "19110",
"owner_user_id": "24756",
"post_type": "question",
"score": -1,
"tags": [
"python"
],
"title": "jsonで値を取り出した複数の変数の演算子について",
"view_count": 284
} | [
{
"body": "## エラーの意味\n\n> `SyntaxError: can't assign to operator` : 構文エラーです. operator には assign できないよ!\n\nここでいう operator は + のことで,要するに `A+B = AB` は `A+B` に `AB`\nをいわば代入していると解釈されて,それは無理,となるわけです. `AB` を `A+B` で定義したいなら書き方はこう\n\n```\n\n AB = A+B\n \n```\n\n(ちなみにここまでについては,やはり一旦入門書というか文法の基礎をおさらいなさることをおすすめします.)\n\n## 正しい書き方\n\nやってみるとわかりますが上の書き方では `AB` はこうなります\n\n```\n\n [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]\n \n```\n\nこれは [list](https://docs.python.org/3/library/stdtypes.html#list) に対しては `+`\nは2つのリストをくっつける,というように[定義されている](https://docs.python.org/3/library/stdtypes.html#typesseq-\ncommon)ためです.(Numpy とかだと事情が変わりますが)リストについて element-wise に和を取るのは普通に書くしかなくて,\n[@metropolis](https://ja.stackoverflow.com/users/16894/metropolis)\nさんの[仰る](https://ja.stackoverflow.com/questions/45413#comment47295_45413)ように\n\n```\n\n AB = map(sum, zip(A, B))\n \n```\n\nか,\n\n```\n\n from operator import add\n AB = map(add, A,B)\n \n```\n\nあたりかと思います.\n\n(リストとか行列とかそういう複数の要素をもつものに対して,要素ごとに演算することを [element-\nwise](https://en.wiktionary.org/wiki/elementwise) に,といいます.上の `A+B`\nは逆にリスト全体としての演算で,行列積なんかも同じ扱いに入ります)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T14:58:10.603",
"id": "45430",
"last_activity_date": "2018-07-08T15:09:13.307",
"last_edit_date": "2018-07-08T15:09:13.307",
"last_editor_user_id": "2901",
"owner_user_id": "2901",
"parent_id": "45413",
"post_type": "answer",
"score": 1
},
{
"body": "Pythonでデータを扱いたいのであれば、PandasとNumPyも勉強しましょう。ベクトル演算ができ多くのデータを扱うための機能があります。今回の問題も次のように簡単に記述することができます。\n\n```\n\n import numpy as np\n \n a = np.array([1, 2, 3, 4, 5])\n b = np.array([-1, -2, -3, -4, -5])\n ab = a + b\n print(ab)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T23:26:36.283",
"id": "45434",
"last_activity_date": "2018-07-08T23:26:36.283",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "45413",
"post_type": "answer",
"score": 0
}
] | 45413 | null | 45430 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "cloudformation で作成したリソースは、作成された後は、 cloudformation とは無関係に操作することができます。\n\nなにかしら急ぎの対応が必要だったので、その場に限り(後で戻す前提で)一時的にリソースの状態を変更することは、運用していく中で発生しうるかと思っています。\n\nそのように行ったリソースに対する変更、ないしそれを元に戻す操作を行った後に、対象のリソースが cloudformation template\nの状態に戻っているかどうか確認したいな、と思いました。\n\n### 質問\n\n * aws cloudformation の stack に対して、そのリソースたちが stack の template から乖離しているかどうかの検知を行うための方法/ツールなどはありますでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T08:23:05.040",
"favorite_count": 0,
"id": "45417",
"last_activity_date": "2018-07-20T13:31:20.553",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 2,
"tags": [
"aws",
"aws-cloudformation"
],
"title": "cloudformation で、実リソースの template からの乖離の検知",
"view_count": 327
} | [
{
"body": "そのものズバリのツールなどは確認できませんが、アイデアとしては構成可視化ツールを使って CloudFormation\nのデザイナーと比較するという方法が考えられるかと思います。\n\n * Cloudcraft – Draw AWS diagrams \n<https://cloudcraft.co/>\n\n * duo-labs/cloudmapper: CloudMapper helps you analyze your Amazon Web \nServices (AWS) environments. \n<https://github.com/duo-labs/cloudmapper>\n\n * AWS CloudFormation デザイナー とは - AWS CloudFormation \n<https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/working-\nwith-templates-cfn-designer.html>\n\n他には API でスタックのリソース一覧を取得して差分を確認するという方法もあるかもしれません。\n\n * describe-stack-resources — AWS CLI 1.15.59 Command Reference <https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-stack-resources.html>\n\n補足ですが CloudFormation\nは[ベストプラクティス](https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/best-\npractices.html#donttouch)にもあるように手動変更をオススメしないようです。\n\n> スタックを起動した後、AWS CloudFormation コンソール、API、または AWS CLI\n> を使用して、スタック内のリソースを更新します。スタックのリソースを AWS CloudFormation\n> 以外の方法で変更しないでください。変更するとスタックのテンプレートとスタックリソースの現在の状態の間で不一致が起こり、スタックの更新または削除でエラーが発生する場合があります。\n\n実質的な dry-run\nである変更セットもありますし、個人的にはスタックの更新/削除エラーの可能性を考えると小さな変更でもテンプレート経由の方がリスクが低くていいのかなと考えています。\n\n * 変更セットの作成 - AWS CloudFormation \n<https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/using-\ncfn-updating-stacks-changesets-create.html>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T21:30:02.867",
"id": "46643",
"last_activity_date": "2018-07-15T21:30:02.867",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24793",
"parent_id": "45417",
"post_type": "answer",
"score": 1
},
{
"body": "AWS Config でしたら リソースが変更された場合に SNS を使って 通知したり、管理コンソール上から履歴を参照することが出来るので\nお望みのものに近い気がします。また、CloudFormation template の中で、AWS Config の設定を記述することも出来ます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-20T13:31:20.553",
"id": "46793",
"last_activity_date": "2018-07-20T13:31:20.553",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "45417",
"post_type": "answer",
"score": 0
}
] | 45417 | null | 46643 |
{
"accepted_answer_id": "45423",
"answer_count": 1,
"body": "たとえば、以下のようなモデルがあります。\n\n```\n\n class Post\n has_many :favorites\n end\n \n class User\n has_many :favorites\n end\n \n class Favorite\n belongs_to :user\n belongs_to :post\n end\n \n```\n\nこのとき、記事(Post) を、ユーザーによるお気に入り (Favorite) の数でソートしたいです。これは、どうやったら実現できるでしょうか?\nFavorite は、 (user, post) にたいしてユニークです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T10:06:05.243",
"favorite_count": 0,
"id": "45422",
"last_activity_date": "2018-07-08T11:10:01.503",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"rails-activerecord"
],
"title": "rails で、 has_many しているレコードの個数でソートしたい",
"view_count": 1452
} | [
{
"body": "rails 5 以上であれば、以下のように、 select, group, left_join を組み合わせることで実現可能です。\n\n```\n\n Post.select('posts.*', 'count(favorites.id) AS favs')\n .left_joins(:favorites)\n .group('posts.id')\n .order('favs desc')\n # SELECT posts.*, count(favorites.id) AS favs FROM `posts`\n # LEFT OUTER JOIN `favorites` ON `favorites`.`post_id` = `posts`.`id`\n # GROUP BY posts.id\n # ORDER BY favs desc LIMIT 10\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T10:06:05.243",
"id": "45423",
"last_activity_date": "2018-07-08T11:10:01.503",
"last_edit_date": "2018-07-08T11:10:01.503",
"last_editor_user_id": "754",
"owner_user_id": "754",
"parent_id": "45422",
"post_type": "answer",
"score": 2
}
] | 45422 | 45423 | 45423 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "unityとvuforiaで簡単なARのプログラムを作ろうとしています。しかし、実行させようとすると、パソコンのwebカメラは起動するのですが、画面は真っ暗なままで何も写りません(画像1)。ARCameraの設定は画像のとおりにしてあります(画像2)(特に何もいじっていません)。また、Vuforia\nBehavior内でvuforiaを無効にしているわけでもありません。別のアプリではwebカメラがちゃんと使えるのでたぶんunityの設定とかだと思っているのですが、どうすればカメラが写るようになりますか? \n追記 使用PCはacerのAspire\nR3-131T、OSはWindows10、カメラはHDWebCam、unityはPersonalでバージョンは2018.1.6f1、vuforiaのバージョンは7.1.35です。[](https://i.stack.imgur.com/p58fH.png)[](https://i.stack.imgur.com/Pm2ZP.png)",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T12:29:56.960",
"favorite_count": 0,
"id": "45424",
"last_activity_date": "2018-07-09T00:32:41.423",
"last_edit_date": "2018-07-09T00:32:41.423",
"last_editor_user_id": "29223",
"owner_user_id": "29223",
"post_type": "question",
"score": 2,
"tags": [
"unity3d",
"camera"
],
"title": "unityでwebカメラの映像が写りません",
"view_count": 2055
} | [] | 45424 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "aという変数の値には[1,2,3,4,5]という値が入っていて前から三番目まで足して割る.いわゆる平均の値表示(b)させたいのですがうまくいきません。\n\n```\n\n if __name__ == \"__main__\":\n \n a = [1,2,3,4,5]\n for i in range(len(a)):\n a.append(a[i] + a[i]/3)\n x = a.arange(0, len(dates[0])) \n \n print(b)\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T12:43:46.323",
"favorite_count": 0,
"id": "45425",
"last_activity_date": "2018-07-08T13:34:15.157",
"last_edit_date": "2018-07-08T13:19:06.413",
"last_editor_user_id": "24756",
"owner_user_id": "24756",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "python 変数 for i inの計算",
"view_count": 113
} | [
{
"body": "こんなんどうでしょうか。\n\n```\n\n if __name__ == \"__main__\":\n a = [1,2,3,4,5]\n target = a[:3] #=> [1, 2, 3]\n s = sum(target)\n l = len(target)\n b = s / l\n \n print(b)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T13:34:15.157",
"id": "45427",
"last_activity_date": "2018-07-08T13:34:15.157",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45425",
"post_type": "answer",
"score": 1
}
] | 45425 | null | 45427 |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "htmlページをブラウザ標準の印刷機能で印刷する場合、縦向きのA4用紙に入る横幅は最大何ピクセルになるでしょうか?\n\ncss\n\n```\n\n * {\n box-sizing: border-box;\n }\n .test1 {\n width: 1366px;\n border: 10px solid red;\n }\n .test2 {\n width: 1280px;\n border: 10px solid green;\n }\n .test3 {\n width: 1024px;\n border: 10px solid blue;\n }\n \n```\n\nhtml\n\n```\n\n <body>\n <div class=\"test1\">test1 1366px</div>\n <div class=\"test2\">test2 1280px</div>\n <div class=\"test3\">test3 1024px</div>\n </body>\n \n```\n\n上記のようなページでプレビューを試したところ、Chrome と IE11、Edge では \n1366px → 用紙からはみ出る \n1280px → 用紙からはみ出る \n1024px → 用紙内に収まる \nという結果になりました。 \nFireFoxでのみ、すべてのサイズが用紙内に収まりました。\n\n1024px程度の幅でページを作成すれば、すべてのブラウザの標準の印刷機能でA4縦の幅に収まると考えてよいのでしょうか? \nそれとも、これらのサイズは端末の環境(ディスプレイなど)に依存するものなのでしょうか? \nA4用紙に該当するピクセル数を算出する方法がありましたら教えてください。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T13:16:29.350",
"favorite_count": 0,
"id": "45426",
"last_activity_date": "2019-12-13T20:01:24.177",
"last_edit_date": "2018-07-08T14:00:26.387",
"last_editor_user_id": "3925",
"owner_user_id": "3925",
"post_type": "question",
"score": 8,
"tags": [
"html",
"css",
"html5",
"印刷"
],
"title": "A4用紙に印刷可能なピクセル数は?",
"view_count": 10460
} | [
{
"body": "単位`px`はCSS 2.1で定義が変更されています。\n\n[CSS 2.0](https://www.w3.org/TR/1998/REC-CSS2-19980512/syndata.html#length-\nunits)までは相対長さ単位\n\n> Relative units are: \n> - **px** : pixels, relative to the viewing device\n\n[CSS 2.1](https://www.w3.org/TR/CSS2/syndata.html#length-units)からは絶対長さ単位\n\n> The absolute units consist of the physical units (in, cm, mm, pt, pc) and\n> the px unit: \n> - **px** : pixel units — 1px is equal to 0.75pt.\n\nとは言え、CSS 2.1以降でも\n\n> The _reference pixel_ is the visual angle of one pixel on a device with a\n> pixel density of 96dpi and a distance from the reader of an arm's length.\n\nと`px`は物理的な長さではなく視野角を基準とした長さでもあると定められています。つまり、目からの距離で長さも異なります。また各ブラウザーは歴史的経緯もあり仕様通りというわけでもないと思います。そのためCSS\n2.1にも\n\n> For lower-resolution devices, and devices with unusual viewing distances, it\n> is recommended instead that the anchor unit be the pixel unit. For such\n> devices it is recommended that the pixel unit refer to the whole number of\n> device pixels that best approximates the reference pixel.\n\nとモニタのような低解像度デバイスには`px`を使用し、プリンターのような高解像度デバイスには他の絶対長さ単位を使用することを推奨しています。\n\nというわけで、印刷を考慮するのであれば、`px`でなく、`in`、`cm`、`mm`、`pt`、`pc`などの単位を使用してください。CSSでは[メディアタイプを指定](https://developer.mozilla.org/ja/docs/Web/CSS/Media_Queries/Using_media_queries#Targeting_media_types)することで`screen`と`print`と分けて指定することができます。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T21:42:55.640",
"id": "45433",
"last_activity_date": "2018-07-08T21:42:55.640",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "45426",
"post_type": "answer",
"score": 4
},
{
"body": "`px`は視野角を基準として決められていますが、プリンターの場合は標準の`1px = 1/96th of 1in`が適用されます([W3C\nCSS3](https://drafts.csswg.org/css-\nvalues-3/#lengths))。A4の横幅が`8.27`インチなので、`8.27 x 96 = 794px`です。\n\nそれでは1024px程度の幅でページを作成すれば、ブラウザの印刷機能の方でA4縦の幅に収まるかというと、FireFox、IE11、Edgeでは「縮小して全体を印刷する」がデフォルトとなっているため、またChromeの方は「縮小して全体を印刷する」という設定はないのですが自動的にその程度までは「縮小して全体を印刷する」仕様になっているためです。なお、linux版のChromeは勝手に「縮小して全体を印刷する」機能はなく1024pxの幅でもはみ出して印刷されます。\n\nまた、IE11、Edge が「縮小して全体を印刷する」にしても1280pxでは用紙からはみ出るようになるのは、規格とかに関係するものではなくて\nIE11、Edge の仕様だと思います。\n\n印刷に関して`px`を使用することに関しては、W3Cの['CSS: em, px, pt, cm,\nin…'というページ](https://www.w3.org/Style/Examples/007/units.en.html)で以下のようになっていて、推奨はされていませんが使うなとはなっていません。Webの開発の場合、画面がメインで印刷はそれほど重視されません。画面レイアウトでは`px`を使う必要があるので、印刷でも使いたいというのが普通です。そういう要望に沿うため、`px`を\nCSS 2.0までは相対長さ単位であったものを、`1px = 1/96\ninch`に決めたわけです。歴史が浅いためブラウザーの対応が十分でないので注意して使う必要があるので推奨はされていないですが、最近のブラウザーを使うという前提であれば印刷に`px`を使っても問題はないと思われます。\n\n[](https://i.stack.imgur.com/YG2Wm.png)",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T02:27:25.287",
"id": "45437",
"last_activity_date": "2018-07-09T22:32:41.280",
"last_edit_date": "2018-07-09T22:32:41.280",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "45426",
"post_type": "answer",
"score": 9
},
{
"body": "> 1024px程度の幅でページを作成すれば、すべてのブラウザの標準の印刷機能でA4縦の幅に収まると考えてよいのでしょうか? \n> それとも、これらのサイズは端末の環境(ディスプレイなど)に依存するものなのでしょうか?\n\nプリンタの印刷可能領域もありますし、ブラウザが拡縮する仕様の影響もあると推測します。\n\n各メーカーのプリンタドライバとブラウザの仕様に詳しい方がいれば分かるかも知れませんが、この点についてはハッキリ分かりません。 \n現実解として970px幅にコンテンツを収めている帳票デザインを見たことはあります。\n\n> A4用紙に該当するピクセル数を算出する方法がありましたら教えてください。\n\nCSS で A4幅 210mm を指定すると、794px にマッピングされます。\n\n<https://codepen.io/DriftwoodJP/pen/pZvJOv>\n\n```\n\n * {\r\n box-sizing: border-box;\r\n }\r\n \r\n // .test1 {\r\n // width: 1366px;\r\n // border: 10px solid red;\r\n // }\r\n // .test2 {\r\n // width: 1280px;\r\n // border: 10px solid green;\r\n // }\r\n // .test3 {\r\n // width: 1024px;\r\n // border: 10px solid blue;\r\n // }\r\n @page {\r\n size: A4;\r\n margin: 0;\r\n }\r\n \r\n @media print {\r\n html,\r\n body {\r\n width: 210mm;\r\n height: 297mm;\r\n }\r\n }\r\n \r\n .mm {\r\n width: 210mm;\r\n border: 10px solid gray;\r\n }\r\n \r\n .pixel {\r\n width: 794px;\r\n border: 10px solid gray;\r\n }\n```\n\n```\n\n <div class='test1'>\r\n test1 1366px\r\n </div>\r\n <div class='test2'>\r\n test2 1280px\r\n </div>\r\n <div class='test3'>\r\n test3 1024px\r\n </div>\r\n <div class='mm'>\r\n mm 210mm\r\n </div>\r\n <div class='pixel'>\r\n Pixel 794px\r\n </div>\n```\n\n物理的な長さがどのようにピクセル換算されるかについては、下記が参考になりました。\n\n * [length - CSS: カスケーディングスタイルシート | MDN](https://developer.mozilla.org/ja/docs/Web/CSS/Length)\n * [The Lengths of CSS | CSS-Tricks](https://css-tricks.com/the-lengths-of-css/)\n\nまた、用紙サイズについては下記のサイトを参考にしています(96PPI)。\n\n * [A Paper Sizes - A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10](https://www.papersizes.org/a-paper-sizes.htm)\n\n**A4(794px * 1123px) で考えるとレイアウトしやすい** のではないでしょうか。\n\n私自身は幅可変の文章や表くらいしか扱ったことが無いので、このトピックの充実が楽しみです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T08:33:27.823",
"id": "45507",
"last_activity_date": "2019-12-13T20:01:24.177",
"last_edit_date": "2019-12-13T20:01:24.177",
"last_editor_user_id": "32986",
"owner_user_id": "7457",
"parent_id": "45426",
"post_type": "answer",
"score": 1
}
] | 45426 | null | 45437 |
{
"accepted_answer_id": "45429",
"answer_count": 1,
"body": "Spring tool suiteでMaven install時にエラーが出てしまい、ビルドできず、どうすればよいのかわかりません。どうかお助けください。\n\n```\n\n [INFO] Scanning for projects...\n [INFO] \n [INFO] ------------------------------------------------------------------------\n [INFO] Building MyBootApp 0.0.1-SNAPSHOT\n [INFO] ------------------------------------------------------------------------\n [WARNING] The POM for com.zaxxer:HikariCP:jar:2.7.9 is invalid, transitive dependencies (if any) will not be ava ilable, enable debug logging for more details\n [INFO] \n [INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ MyBootApp ---\n [INFO] Using 'UTF-8' encoding to copy filtered resources.\n [INFO] Copying 1 resource\n [INFO] Copying 4 resources\n [INFO] \n [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ MyBootApp ---\n [INFO] Changes detected - recompiling the module!\n [INFO] Compiling 4 source files to C:\\Users\\yoshi\\Documents\\workspace-sts-3.9.2.RELEASE\\MyBootApp\\target\\classes \n [ERROR] C:\\Users\\yoshi\\.m2\\repository\\org\\springframework\\spring-jdbc\\5.0.6.RELEASE\\spring-jdbc-5.0.6.RELEASE.ja rの読込みエラーです。invalid LOC header (bad signature)\n [ERROR] C:\\Users\\yoshi\\.m2\\repository\\org\\hibernate\\hibernate-core\\5.2.17.Final\\hibernate-core-5.2.17.Final.jar の読込みエラーです。invalid LOC header (bad signature)\n [INFO] \n [INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ MyBootApp ---\n [INFO] Using 'UTF-8' encoding to copy filtered resources.\n [INFO] skip non existing resourceDirectory C:\\Users\\yoshi\\Documents\\workspace-sts-3.9.2.RELEASE\\MyBootApp\\src\\te st\\resources\n [INFO] \n [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ MyBootApp ---\n [INFO] Changes detected - recompiling the module!\n [INFO] Compiling 1 source file to C:\\Users\\yoshi\\Documents\\workspace-sts-3.9.2.RELEASE\\MyBootApp\\target\\test-cla sses\n [ERROR] C:\\Users\\yoshi\\.m2\\repository\\org\\springframework\\spring-jdbc\\5.0.6.RELEASE\\spring-jdbc-5.0.6.RELEASE.ja rの読込みエラーです。invalid LOC header (bad signature)\n [ERROR] C:\\Users\\yoshi\\.m2\\repository\\org\\hibernate\\hibernate-core\\5.2.17.Final\\hibernate-core-5.2.17.Final.jar の読込みエラーです。invalid LOC header (bad signature)\n [INFO] \n [INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ MyBootApp ---\n [INFO] \n [INFO] -------------------------------------------------------\n [INFO] T E S T S\n [INFO] -------------------------------------------------------\n [INFO] Running com.kuwa.springboot.MyBootAppApplicationTests\n 23:00:52.136 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRun ner constructor called with [class com.kuwa.springboot.MyBootAppApplicationTests]\n (省略)\n \n . ____ _ __ _ _\n /\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\\n ( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\\n \\\\/ ___)| |_)| | | | | || (_| | ) ) ) )\n ' |____| .__|_| |_|_| |_\\__, | / / / /\n =========|_|==============|___/=/_/_/_/\n :: Spring Boot :: (v2.0.2.RELEASE)\n \n 2018-07-08 23:00:55.375 INFO 24768 --- [ main] c.k.s.MyBootAppApplicationTests : Starting My BootAppApplicationTests on DESKTOP-2H6JNOI with PID 24768 (started by yoshi in C:\\Users\\yoshi\\Documents\\workspac e-sts-3.9.2.RELEASE\\MyBootApp)\n 2018-07-08 23:00:55.380 INFO 24768 --- [ main] c.k.s.MyBootAppApplicationTests : No active p rofile set, falling back to default profiles: default\n 2018-07-08 23:00:55.565 INFO 24768 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Refreshing org.springframework.web.context.support.GenericWebApplicationContext@496bc455: startup date [Sun Jul 08 23:00:55 JST 2018]; root of context hierarchy\n 2018-07-08 23:01:00.981 WARN 24768 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception e ncountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.Unsatis fiedDependencyException: Error creating bean with name 'heloController': Unsatisfied dependency expressed throug h field 'repository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qu alifying bean of type 'com.kuwa.springboot.repositories.MyDataRepository' available: expected at least 1 bean wh ich qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Auto wired(required=true)}\n 2018-07-08 23:01:01.013 INFO 24768 --- [ main] ConditionEvaluationReportLoggingListener : \n \n Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled .\n 2018-07-08 23:01:01.599 ERROR 24768 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : \n \n ***************************\n APPLICATION FAILED TO START\n ***************************\n \n Description:\n \n Field repository in com.kuwa.springboot.HeloController required a bean of type 'com.kuwa.springboot.repositories .MyDataRepository' that could not be found.\n \n \n Action:\n \n Consider defining a bean of type 'com.kuwa.springboot.repositories.MyDataRepository' in your configuration.\n \n 2018-07-08 23:01:01.622 ERROR 24768 --- [ main] o.s.test.context.TestContextManager : Caught exce ption while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@7d c0f706] to prepare test instance [com.kuwa.springboot.MyBootAppApplicationTests@69e308c6]\n \n java.lang.IllegalStateException: Failed to load ApplicationContext\n at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwa reContextLoaderDelegate.java:125) ~[spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java :108) ~[spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletT estExecutionListener.java:190) ~[spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutio nListener.java:132) ~[spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246) ~[sp ring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:2 27) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunn er.java:289) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12] \n at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java: 291) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246 ) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]\n at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]\n at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]\n at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]\n at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]\n at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClas sCallbacks.java:61) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassC allbacks.java:70) [spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]\n at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) [sp ring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365) [surefire-junit4-2.21.0. jar:2.21.0]\n at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273) [surefire-junit 4-2.21.0.jar:2.21.0]\n at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238) [surefire-junit4- 2.21.0.jar:2.21.0]\n at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) [surefire-junit4-2.21.0.j ar:2.21.0]\n at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:379) [sur efire-booter-2.21.0.jar:2.21.0]\n at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:340) [surefire-booter- 2.21.0.jar:2.21.0]\n at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:125) [surefire-booter-2.21.0.jar: 2.21.0]\n at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:413) [surefire-booter-2.21.0.jar:2.2 1.0]\n Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helo Controller': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframewor k.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.kuwa.springboot.repositories.MyDa taRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}\n at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.i nject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring -beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValu es(AutowiredAnnotationBeanPostProcessor.java:373) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowir eCapableBeanFactory.java:1348) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowir eCapableBeanFactory.java:578) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireC apableBeanFactory.java:501) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java :317) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanR egistry.java:228) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[s pring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spr ing-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultList ableBeanFactory.java:760) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractAp plicationContext.java:869) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:55 0) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.0.2.RELEAS E.jar:2.0.2.RELEASE]\n at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) ~[spring-boot-2.0.2 .RELEASE.jar:2.0.2.RELEASE]\n at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.2.RELEASE.ja r:2.0.2.RELEASE]\n at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:13 9) ~[spring-boot-test-2.0.2.RELEASE.jar:2.0.2.RELEASE]\n at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(Default CacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwa reContextLoaderDelegate.java:117) ~[spring-test-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n ... 27 common frames omitted\n Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.kuwa .springboot.repositories.MyDataRepository' available: expected at least 1 bean which qualifies as autowire candi date. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}\n at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultList ableBeanFactory.java:1509) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableB eanFactory.java:1104) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBea nFactory.java:1065) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.i nject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]\n ... 45 common frames omitted\n \n [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.708 s <<< FAILURE! - in com.kuwa.spri ngboot.MyBootAppApplicationTests\n [ERROR] contextLoads(com.kuwa.springboot.MyBootAppApplicationTests) Time elapsed: 0.044 s <<< ERROR!\n java.lang.IllegalStateException: Failed to load ApplicationContext\n Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helo Controller': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframewor k.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.kuwa.springboot.repositories.MyDa taRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}\n Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.kuwa .springboot.repositories.MyDataRepository' available: expected at least 1 bean which qualifies as autowire candi date. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}\n \n [INFO] \n [INFO] Results:\n [INFO] \n [ERROR] Errors: \n [ERROR] MyBootAppApplicationTests.contextLoads ≫ IllegalState Failed to load Applicati...\n [INFO] \n [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0\n [INFO] \n [INFO] ------------------------------------------------------------------------\n [INFO] BUILD FAILURE\n [INFO] ------------------------------------------------------------------------\n [INFO] Total time: 25.612 s\n [INFO] Finished at: 2018-07-08T23:01:02+09:00\n [INFO] Final Memory: 34M/210M\n [INFO] ------------------------------------------------------------------------\n [WARNING] The requested profile \"pom.xml\" could not be activated because it does not exist.\n [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on proj ect MyBootApp: There are test failures.\n [ERROR] \n [ERROR] Please refer to C:\\Users\\yoshi\\Documents\\workspace-sts-3.9.2.RELEASE\\MyBootApp\\target\\surefire-reports f or the individual test results.\n [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N]. dumpstream.\n [ERROR] -> [Help 1]\n [ERROR] \n \n```\n\npom.xml \n \nxsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0\n<http://maven.apache.org/xsd/maven-4.0.0.xsd>\"> \n4.0.0\n\n```\n\n <groupId>com.kuwa.springboot</groupId>\n <artifactId>MyBootApp</artifactId>\n <version>0.0.1-SNAPSHOT</version>\n <packaging>jar</packaging>\n \n <name>MyBootApp</name>\n <description>Demo project for Spring Boot</description>\n \n <parent>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-parent</artifactId>\n <version>2.0.2.RELEASE</version>\n <relativePath/> <!-- lookup parent from repository -->\n </parent>\n \n <properties>\n <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n <java.version>1.8</java.version>\n </properties>\n \n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-web</artifactId>\n </dependency>\n \n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-test</artifactId>\n <scope>test</scope>\n </dependency>\n \n <!-- dependency>\n <groupId>org.apache.tomcat.embed</groupId>\n <artifactId>tomcat-embed-jasper</artifactId>\n </dependency -->\n \n <!-- dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-groovy-templates</artifactId>\n </dependency-->\n \n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-thymeleaf</artifactId>\n </dependency>\n \n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-data-jpa</artifactId>\n </dependency>\n <dependency>\n <groupId>org.hsqldb</groupId>\n <artifactId>hsqldb</artifactId>\n <scope>runtime</scope>\n </dependency>\n \n \n \n </dependencies>\n \n <build>\n <plugins>\n <plugin>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-maven-plugin</artifactId>\n </plugin>\n </plugins>\n </build>\n \n \n </project>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T14:23:52.783",
"favorite_count": 0,
"id": "45428",
"last_activity_date": "2018-07-08T15:49:46.217",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "23122",
"post_type": "question",
"score": 0,
"tags": [
"java",
"spring",
"spring-boot",
"maven"
],
"title": "Spring tool suiteでMaven installエラー (Spring boot)",
"view_count": 3638
} | [
{
"body": "すみません。こっちのエラーですね。\n\n```\n\n > [ERROR]\n > C:\\Users\\yoshi\\.m2\\repository\\org\\springframework\\spring-jdbc\\5.0.6.RELEASE\\spring-jdbc-5.0.6.RELEASE.jarの読込みエラーです。invalid\n > LOC header (bad signature) [ERROR]\n > C:\\Users\\yoshi\\.m2\\repository\\org\\hibernate\\hibernate-core\\5.2.17.Final\\hibernate-core-5.2.17.Final.jarの読込みエラーです。invalid\n > LOC header (bad signature)\n \n```\n\n[Mavenリポジトリのローカルキャッシュを削除で解決](https://qiita.com/ASHITSUBO/items/0d30c1ddf476d2ec96b7)\nするという記事がありました。 \n以下をお試しください。\n\n> C:\\Users\\yoshi\\.m2\\repository 配下のフォルダを全て削除し、 \n> Mavenプロジェクト右クリック → Maven → Update Maven Project... からpom.xmlを反映し直す。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-08T14:36:50.227",
"id": "45429",
"last_activity_date": "2018-07-08T15:49:46.217",
"last_edit_date": "2018-07-08T15:49:46.217",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45428",
"post_type": "answer",
"score": 1
}
] | 45428 | 45429 | 45429 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "■実現したいこと(概要): \nクエリパラメター無しのURLにアクセスしたら、自動的にクエリパラメタを付加したURLに飛ばしたい。\n\n■実現したいこと(詳細): \n1.現在、クエリパラメターを使って、DB連携で表示させるようなプログラムを \n作成している。\n\n2.具体的には、 \nhttp://◎◎◎.php?lan=en\n\nであり、この場合、\n\n◎◎◎.phpのプログラムの中で、\n\nDBから、「lan=en、即ち言語がenglish」のものを抽出して、 \n表示させています。\n\n3.当然のことながら、 \n単純に、クエリパラメター無しの \nhttp://◎◎◎.phpにアクセスした場合には、 \n正常な表示がなされません。\n\n4.やりたいこと:\n\n具体的には、 \nhttp://◎◎◎.phpへのアクセスがあった場合に、\n\n自動的に、 \nhttp://◎◎◎.php&lan=en \n \nという具合に、クエリパラメターを付加して表示させたい。 \n.htaccessへ記載すればいいのでしょうか?\n\n(追加の質問) \n・.htaccessに記載する方法の場合、SEO対策的には有効な方法と考えられるの \nでしょうか? \n \n以上、よろしくお願いいたします。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T00:48:32.943",
"favorite_count": 0,
"id": "45435",
"last_activity_date": "2019-09-09T08:13:44.523",
"last_edit_date": "2018-07-09T06:57:37.933",
"last_editor_user_id": "5008",
"owner_user_id": "16826",
"post_type": "question",
"score": 0,
"tags": [
"php",
"mysql",
"apache",
".htaccess"
],
"title": "クエリパラメター無しのURLにアクセスしたら、自動的にクエリパラメタを付加したURLに飛ばしたい。",
"view_count": 87
} | [
{
"body": "解決しました! \n.htaccessファイルを使うことはせず、isset関数を使うことで解決しました\n\n■結論 \nphpファイルの最初の行で以下のように記載。\n\n```\n\n <?php \n $lan = isset($_GET['lan']) ? $_GET['lan'] : 'en';\n ?>\n \n```\n\n■コードの説明 \n・isset関数を使うことによってクエリパラメターチェック \n・三項演算子を使ってすっきりしたコードに\n\n■PHP動作の流れ \n◎パターン1 \n`http://example.com/XXX.php?lan=en`\n\nでアクセスされた場合は、isset関数を使うことによってクエリパラメターをチェックし、`$_GET['lan']`があるので、`$lan=$_GET['lan']`として処理が進む。 \nつまり、これまで通り`http://example.com/XXX.php?lan=en`のURLとして表示\n\n◎パターン2\n\n`http://example.com/XXX.php` \nでアクセスされた場合は、isset関数を使うことによって、クエリパラメターをチェックし、`$_GET['lan']`がないので、内部的に、`$lan='en';`として値を代入\n\nこの場合、URLとして表示されるのは`http://example.com/XXX.php`ですが、 \n内部的には、`http://example.com/XXX.php?lan=en`にアクセスされた場合と同じ処理\n\n* * *\n\nこの投稿は [@きむちゃん\nさんのコメント](https://ja.stackoverflow.com/questions/45435/%e3%82%af%e3%82%a8%e3%83%aa%e3%83%91%e3%83%a9%e3%83%a1%e3%82%bf%e3%83%bc%e7%84%a1%e3%81%97%e3%81%aeurl%e3%81%ab%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9%e3%81%97%e3%81%9f%e3%82%89-%e8%87%aa%e5%8b%95%e7%9a%84%e3%81%ab%e3%82%af%e3%82%a8%e3%83%aa%e3%83%91%e3%83%a9%e3%83%a1%e3%82%bf%e3%82%92%e4%bb%98%e5%8a%a0%e3%81%97%e3%81%9furl%e3%81%ab%e9%a3%9b%e3%81%b0%e3%81%97%e3%81%9f%e3%81%84#comment47570_45435)\nを元にコミュニティwikiとして投稿しました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-09T08:13:44.523",
"id": "57948",
"last_activity_date": "2019-09-09T08:13:44.523",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "45435",
"post_type": "answer",
"score": 0
}
] | 45435 | null | 57948 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "**現状** \n・cron実行されるがメールを受信できない\n\n* * *\n\n**試したこと1**\n\n```\n\n /etc/cron.d/hoge\n \n```\n\n> MAILTO=\"メールアドレス\"\n```\n\n systemctl restart crond\n \n```\n\n* * *\n\n**試したこと2** \n・/etc/crontabはデフォルトのままですが、ここに書かなければいけないのかと思い、下記へ変更したのですが、メール受信できません\n\n> MAILTO=\"メールアドレス\"\n```\n\n systemctl restart crond\n \n```\n\n* * *\n\n**試したこと3** \n/var/spool/mail/を見たのですが、メールは溜まっていないと思います(見方が良くわからない)\n\n* * *\n\n**Q** \n・cronメールを受信できない場合はどこを確認するのですか?\n\n* * *\n\n**環境** \n・CentOS7\n\n* * *\n\n**追記** \n・cron内容は/etc/cron.d/hogeファイルに記載しています \n・phpファイルを実行させ、結果としてhtmlを出力させています\n\n```\n\n 2 6 * * * root /usr/bin/php /var/www/中略/hoge.php\n \n```",
"comment_count": 11,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T01:12:48.907",
"favorite_count": 0,
"id": "45436",
"last_activity_date": "2018-07-09T11:17:15.510",
"last_edit_date": "2018-07-09T11:17:15.510",
"last_editor_user_id": "7886",
"owner_user_id": "7886",
"post_type": "question",
"score": 0,
"tags": [
"centos",
"cron"
],
"title": "cron実行したらメールを受け取りたい",
"view_count": 2730
} | [] | 45436 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "JavaScriptのチャイムを実装したいです。 \nコード量が多いので、コードの量を減らしたいと思いました。\n\n```\n\n //setInterval(String,mmS) 1000mms = 1s\n setInterval(clock, 1000); //1秒ごとに結果を反映\n \n function clock() {\n var weeks = new Array(\"Sun\", \"Mon\", \"Thu\", \"Wed\", \"Thr\", \"Fri\", \"Sat\");\n //曜日を出力\n var now = new Date();\n var y = now.getFullYear();\n var mo = now.getMonth() + 1;\n var d = now.getDate();\n var w = weeks[now.getDay()];\n var h = now.getHours();\n var mi = now.getMinutes();\n var s = now.getSeconds();\n \n if (mo < 10) {\n mo = \"0\" + mo\n };\n if (d < 10) {\n d = \"0\" + d;\n }\n if (mi < 10) {\n mi = \"0\" + mi;\n }\n if (s < 10) {\n s = \"0\" + s;\n }\n \n var date = y + \"/\" + mo + \"/\" + d + \" (\" + w + \")\";\n var time = h + \":\" + mi + \":\" + s;\n \n document.getElementById(\"clock_date\").innerHTML = y + \"/\" + mo + \"/\" + d + \" (\" + w + \")\";\n document.getElementById(\"clock_time\").innerHTML = h + \":\" + mi + \":\" + s;\n //document.getElementById(\"clock_date\").innerHTML = date;\n //document.getElementById(\"clock_time\").innerHTML = time;\n document.getElementById(\"clock_frame\").style.fontSize = window.innerWidth / 10 + \"px\";\n \n //var get_time = document.getElementById('clock_time'); // HTML要素オブジェクトを取得\n // console.log(get_time); //[object HTMLParagraphElement] 要素全てをログ出力?\n var get_date = document.getElementById('clock_date').innerHTML;\n console.log(get_date); //日数のみ出力\n \n var get_time = document.getElementById('clock_time').innerHTML;\n console.log(get_time); //時間のみ出力\n \n console.log(w);\n \n if (w === \"Sun\" || w === \"Sat\") { // もし土曜日もしくは日曜日でないなら\n console.log(\"休日\");\n \n // チャイムを作動させない\n } else {\n console.log(\"平日\");\n \n switch (time) {\n case \"09:30:00\": //0限START\n document.getElementById(\"Sound\").play();\n alert(\"0限目が始まりました。\");\n break;\n \n case \"09:45:00\": //0限END・1限START\n document.getElementById(\"Sound\").play();\n alert(\"1限目が始まりました。\");\n break;\n \n case \"10:35:00\": //1限END・休み時間START\n document.getElementById(\"Sound\").play();\n alert(\"1限目が終わりました。\");\n break;\n \n case \"10:45:00\": //休み時間END・2限START\n document.getElementById(\"Sound\").play();\n alert(\"2限目が始まりました。\");\n break;\n \n case \"11:35:00\": //2限END・休み時間START\n document.getElementById(\"Sound\").play();\n alert(\"2限目が終わりました。\");\n break;\n \n case \"11:45:00\": //休み時間END・3限START\n document.getElementById(\"Sound\").play();\n alert(\"3限目が始まりました。\");\n break;\n \n case \"12:35:00\": //3限END・昼休みSTART\n document.getElementById(\"Sound\").play();\n alert(\"3限目が終わりました。\");\n break;\n \n case \"13:15:00\": //昼休みEND・4限START\n document.getElementById(\"Sound\").play();\n alert(\"4限目が始まりました。\");\n break;\n \n case \"14:05:00\": //4限END・休み時間START\n document.getElementById(\"Sound\").play();\n alert(\"4限目が終わりました。\");\n break;\n \n case \"14:15:00\": //休み時間END・5限START\n document.getElementById(\"Sound\").play();\n alert(\"5限目が始まりました。\");\n break;\n \n case \"15:05:00\": //5限END・休み時間START\n document.getElementById(\"Sound\").play();\n alert(\"5限目が終わりました。\");\n break;\n \n case \"15:15:00\": //休み時間END・6限START\n document.getElementById(\"Sound\").play();\n alert(\"6限目が始まりました。\");\n break;\n \n case \"16:05:00\": //6限END・終礼など\n document.getElementById(\"Sound\").play();\n alert(\"6限目が終わりました。\");\n break;\n \n case \"16:15:00\": //休み時間END・7限START\n document.getElementById(\"Sound\").play();\n alert(\"7限目が始まりました。\");\n break;\n \n case \"17:05:00\": //7限END\n document.getElementById(\"Sound\").play();\n alert(\"7限目が終わりました。\");\n break;\n \n case \"17:50:00\": //下校の促し \n document.getElementById(\"Sound\").play();\n alert(\"下校する時間の10分前になりました。\");\n break;\n \n case \"18:00:00\": //完全下校\n document.getElementById(\"Sound\").play();\n alert(\"下校する時間になりました。\");\n //音楽を再生する\n break;\n \n default:\n break;\n \n }\n }\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T03:29:13.183",
"favorite_count": 0,
"id": "45438",
"last_activity_date": "2018-07-09T12:47:29.213",
"last_edit_date": "2018-07-09T08:40:04.390",
"last_editor_user_id": "3060",
"owner_user_id": "29216",
"post_type": "question",
"score": 1,
"tags": [
"javascript"
],
"title": "このコードの量を減らしたい!",
"view_count": 286
} | [
{
"body": "JavaScriptオブジェクト(連想配列)を使って、\n\n```\n\n const data = {\n \"09:30:00\":{lesson: 0, message: \"始まり\"},\n \"09:45:00\":{lesson: 1, message: \"始まり\"},\n \"10:35:00\":{lesson: 1, message: \"終わり\"},\n \"10:45:00\":{lesson: 2, message: \"始まり\"},\n \"11:35:00\":{lesson: 2, message: \"終わり\"},\n \"11:45:00\":{lesson: 3, message: \"始まり\"},\n \"12:35:00\":{lesson: 3, message: \"終わり\"},\n \"13:15:00\":{lesson: 4, message: \"始まり\"},\n \"14:05:00\":{lesson: 4, message: \"終わり\"},\n \"14:15:00\":{lesson: 5, message: \"始まり\"},\n \"15:05:00\":{lesson: 5, message: \"終わり\"},\n \"15:15:00\":{lesson: 6, message: \"始まり\"},\n \"16:05:00\":{lesson: 6, message: \"終わり\"},\n \"16:15:00\":{lesson: 7, message: \"始まり\"},\n \"17:05:00\":{lesson: 7, message: \"終わり\"},\n \"17:50:00\":{lesson: 8, message: \"下校する時間の10分前になりました。\"},\n \"18:00:00\":{lesson: 9, message: \"下校する時間になりました。\"}\n };\n \n```\n\nとしておいて、`switch (time)`以下を次のようにするとかなりすっきりします。\n\n```\n\n if (time in data) {\n document.getElementById(\"Sound\").play();\n if (data[time].lesson < 8)\n alert(`${data[time].lesson}時限目が${data[time].message}ました。`);\n else {\n alert(data[time].message);\n if (data[time].lesson === 9) {\n //音楽を再生する\n }\n }\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T12:47:29.213",
"id": "45454",
"last_activity_date": "2018-07-09T12:47:29.213",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "45438",
"post_type": "answer",
"score": 8
}
] | 45438 | null | 45454 |
{
"accepted_answer_id": "45442",
"answer_count": 1,
"body": "EthereumのGethから取得したTxNo.をjsonに変換しするとエラーになります\n\n```\n\n _res_list = []\n _res = {}\n _tx = 〜.transact({'from': 〜})\n _res['tx'] = _tx\n _res_list.append(_res.copy())\n _res = {}\n return json.dumps(_res_list)\n \n \n \"errorMessage\": \"Object of type 'HexBytes' is not JSON serializable\"\n \n```\n\nHexBytes型の処理がわかるような情報が見つけられず質問しました\n\n0xで始まっているものをjsonに変換するにはどうすると良いでしょうか\n\n0xを外した文字列として戻すというのでも良いですが、可能であれば0xが付いたままの文字列としてjsonにセットできればと思います\n\nお願いします",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T04:00:02.560",
"favorite_count": 0,
"id": "45439",
"last_activity_date": "2018-07-09T05:35:17.407",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27721",
"post_type": "question",
"score": 0,
"tags": [
"python",
"ethereum"
],
"title": "HexBytesをjsonにセットする方法に付いて",
"view_count": 146
} | [
{
"body": "自己解決しました\n\nWeb3.toHexを使えば良いだけでした\n\nすみません",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T05:35:17.407",
"id": "45442",
"last_activity_date": "2018-07-09T05:35:17.407",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27721",
"parent_id": "45439",
"post_type": "answer",
"score": 0
}
] | 45439 | 45442 | 45442 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "OpenCVのカメラ機能を使ってアプリケーション開発をしようと考えています。 \nそこで、Windows10にOpenCVをインストールしてVisual\nStudioにOpenCVの環境を設定したところ、Webカメラからの画像が出たりでなかったりとなりました。 \n特に、release版で画像が表示されないので、困ったことだと思っています。 \nそこで、OpenCVを安定して利用できる環境について教えて頂けないでしょうか。 \n例えば、次のように。\n\nOS: ubuntu16.04 \nOpenCV Version: 3.4.1 \n言語: C++\n\nよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T08:14:00.163",
"favorite_count": 0,
"id": "45447",
"last_activity_date": "2018-07-09T11:25:32.477",
"last_edit_date": "2018-07-09T11:25:32.477",
"last_editor_user_id": null,
"owner_user_id": "29110",
"post_type": "question",
"score": 0,
"tags": [
"c++",
"ubuntu",
"opencv",
"windows-10"
],
"title": "OpenCVの開発環境",
"view_count": 242
} | [
{
"body": "**注意: この回答は、ご質問に直接は答えていません。**\n\n2018 年現在の OpenCV はカメラ画像の処理に FFmpeg や DirectShow\nなど多くのバックエンドが使えるようになっており、そのどれかで認識できれば後は `cv::VideoCapture`\nとして抽象化して利用できるようになっています (参考: [Video I/O with OpenCV\nOverview](https://docs.opencv.org/3.3.0/d0/da7/videoio_overview.html))。\n\nこのため、バックエンド側で認識できる多くのカメラは OpenCV でも同様に使えることが期待されています。実際 OpenCV\nは多くの環境で動作したことが報告されており、それらを全列挙することは現実的でないように思います。\n\n一応、2013 年時点の古い OpenCV Wiki には、[OpenCV\nの動作が確認できた環境の一覧](https://web.archive.org/web/20120815172655/http://opencv.willowgarage.com/wiki/Welcome/OS/)があったようです。しかし現在このページは無く、また私が検索した限りでは類似の公式ページは存在しないようでした。\n\nまた、ご自身の環境で OpenCV と互換するカメラが欲しいということであれば、たとえば返品制度を使って互換するものをお探しになるのは如何でしょうか。\n\n### 参考: 類似質問\n\n * [openCV compatible webcams](https://stackoverflow.com/q/21679461/5989200) -- Stack Overflow\n * [Good and compatible webcam to do image processing/computer vision?](https://stackoverflow.com/q/19873832/5989200) -- Stack Overflow\n * [Does exists a list of compatibles cameras with OpenCV](http://answers.opencv.org/question/118688/does-exists-a-list-of-compatibles-cameras-with-opencv/) -- OpenCV Q&A Forum\n * [Camera suggestion](http://answers.opencv.org/question/26192/camera-suggestion/) -- OpenCV Q&A Forum",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T09:24:20.747",
"id": "45448",
"last_activity_date": "2018-07-09T09:24:20.747",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "45447",
"post_type": "answer",
"score": 2
}
] | 45447 | null | 45448 |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "Google Cloud Platform > Cloud SQL > MySQL 第 2 世代インスタンス \nを作成しました。\n\nこのインスタンスにある DB に、私の Mac から、 \nMicrosoft Access (MacOS 版がありません) や \nLibreOffice Base (Mac 版はありますが不安定なところがあり、日本語フォーラム等も充実しているとは言いづらいです) \nなどのような、日本語 & GUI ベースのアプリケーションで接続したいです。\n\n特に、下記の事を 日本語 & GUI で行いたいです (要するに何でもじゃないか、と言われそうですが)。\n\n 1. 下記の事を日本語で質問したい \n 1. 技術文書を閲覧する\n 2. 行き詰まった時にフォーラム等で質問する\n 2. 下記の事を GUI で行いたい \n 1. フィールドのプロパティの設定\n 2. クエリの作成\n 3. フォームの作成\n 4. リレーション図の閲覧\n\nつきましては、上記の 2 つのアプリケーション以外で、 \nおすすめのアプリケーションや開発環境がありましたらお教え願います。\n\n月に何万円も支払わなければならないアプリケーションや、 \n買い切りでも 15 万円を超えるようなものは \n選択の対象外とさせてください。\n\nGoogle App Maker も選択肢に入れておりますが、 まだ使い始めで、 \n使い勝手の把握はおろか、当該 DB への接続もできておりません。 \nしかし、App Maker がおすすめという事でしたらその旨おっしゃっていただきたく思います。\n\n(不案内のため意味不明の部分があればご指摘願います)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T09:48:11.333",
"favorite_count": 0,
"id": "45450",
"last_activity_date": "2020-11-24T03:32:31.107",
"last_edit_date": "2020-11-24T03:32:31.107",
"last_editor_user_id": "32986",
"owner_user_id": "29236",
"post_type": "question",
"score": 0,
"tags": [
"mysql",
"google-apps-script",
"google-cloud",
"google-app-engine",
"libreoffice"
],
"title": "Google Cloud SQL に最適な GUI アプリケーションは?",
"view_count": 1100
} | [
{
"body": "MS Accessのようなフォームを作成したい場合、選択肢が減りそうです。\n\n> 3. フォームの作成\n>\n\nVMWareなどの仮想化ソフトとWindows+MS Accessの利用が一番便利かもしれません。 \n(CPUは食いますが、Macでもシームレスに操作できると思います。)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T13:00:23.723",
"id": "45455",
"last_activity_date": "2018-07-09T13:20:24.083",
"last_edit_date": "2018-07-09T13:20:24.083",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45450",
"post_type": "answer",
"score": 1
},
{
"body": "データベースの管理は、通常のMySQLと変わりはないので、`MySQL\nWorkbench`又は`phpMyAdmin`を使えばGUIで管理ができます。ただし、`phpMyAdmin`の場合Macにインストールしてリモートでアクセスする必要があります。\n\n`Access`及び`LibreOffice\nBase`の他に`Excel`からも接続が可能です。`Excel`の場合MySQLからデータを取ってきて処理をするのはODBCドライバをインストールすればウィザードで可能なので簡単にできます。Mac版も有料ですがODBCドライバがあるようです。一方、`Excel`からMySQLにデータを入れるのは結構難しいので、自分は、`Python`の`Pandas`で`Excel`のファイルを読み込んでから`Python`で処理をしています。これもMacで動作するのですがGUIでないので条件を満たさないです。`Excel`に`Python`が搭載されると嬉しいのですが何時になるかわかりません。\n\nMacには、`Access`に近いソフトとして`FileMaker Pro\nAdvanced`があります。MySQLに対応しているし評価版があるので一度試してみたらどうでしょうか。ただし、業務用のソフトに関しては、Windowsが圧倒的に強いので、Windowsで`Access`を使うようなサポートは期待できないと思います。\n\nまた、`LAMP`といわれたPHP製のWebアプリケーションがMySQLを使用しています。例えば、ブログを作る場合に使用する`WordPress`がMySQLを使っています。`WordPress`にはプラグインが豊富にあるので、フォームを作ろうという場合に用途によっては意外と使えるかもしれません。また、Web系には多くのアプリケーションがあるのでもう少し目的をはっきりさせれば使えるものが結構あると思います。ただし、HTMLとCSS\nでデザインをしていくので`MS\nAccess`に慣れている場合は難しいかもしれませんが、最近は多くのアプリがWebになってきているのは、Webの方が結構作りやすいということもあるので検討してみたらと思います。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T14:06:36.103",
"id": "45457",
"last_activity_date": "2018-07-10T02:03:11.100",
"last_edit_date": "2018-07-10T02:03:11.100",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "45450",
"post_type": "answer",
"score": 0
},
{
"body": "だいぶ以前のスレッドに反応させていただき恐れ入りますが……\n\n> FileMaker Pro Advanced\n> だがコミュニティのサポートは期待できないとのこと。残念です。コミュニティ等のサポートは私にとって必須ですので…。\n\nこちらについては、決してそんなことはありません、ということだけ補足させてください。 \n公式でのサポートはありますし、また、長年のユーザーが多いのでコミュニティも存在しています。\n\nたとえば以下は、私の主催している Discord でのコミュニティになります。 \nチャット上で気軽に質問することも可能になっていますので、ご参考まで。\n\n * FileMaker Casual ( 招待リンク <https://discord.gg/PWWcYK8> )\n\nなお、最初のご要望について FileMaker Pro で対応できるのは以下の通りです。\n\n * フィールドのプロパティの設定\n\n⇒こちらは限定的に可能です。\n\n * クエリの作成\n\n⇒こちらは独自のスクリプト等を作成することでおこなえます。\n\n * フォームの作成\n\n⇒こちらは可能です。\n\n * リレーション図の閲覧\n\n⇒こちらは FileMaker Pro 上で描き直すことで可能となります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2020-10-20T10:54:54.410",
"id": "71353",
"last_activity_date": "2020-10-20T10:54:54.410",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "42401",
"parent_id": "45450",
"post_type": "answer",
"score": 0
}
] | 45450 | null | 45455 |
{
"accepted_answer_id": "56207",
"answer_count": 1,
"body": "以下のGo言語コードを`yellow.exe`という名前で保存していたとします\n\n```\n\n package main\n \n import (\n \"fmt\"\n \n \"github.com/fatih/color\"\n )\n \n func main() {\n yellow := color.New(color.FgYellow).SprintFunc()\n fmt.Fprintf(color.Output, \"< %s >\\n\", yellow(\"yellow\"))\n }\n \n```\n\nそれを以下のようなコードで外部プログラム実行した場合、io.MultiWriter だと色が出力されません。\n\n```\n\n package main\n \n import (\n \"io\"\n \"os\"\n \"os/exec\"\n )\n \n func main() {\n var cmd *exec.Cmd\n \n cmd = exec.Command(`yellow.exe`)\n cmd.Stdout = os.Stdout\n cmd.Run()\n \n cmd = exec.Command(`yellow.exe`)\n cmd.Stdout = io.MultiWriter(os.Stdout)\n cmd.Run()\n }\n \n```\n\nこの例では`os.Stdout`のみを`io.MultiWriter`に入れていますが、本来はファイルへの出力と同時に標準出力にも出力したいと考えていて、ファイルには色なしで出力し、標準出力には色付きで出力したいと考えています。また、外部プログラム実行をするプログラムはgo言語とは限らず、C#で作成したプログラムの場合もあり、外部プログラム側のコードはいじれない場合もあります。その場合にどのようにすれば、標準出力に色付きの出力をしつつ、ファイルにも同じ文字列を落とせるでしょうか?\n\n======== \n**追記(2018/07/10)**\n\n@metropolis さんのコメントを受けて、さらなる調査を行ったところ、一定条件下での解決策は出たと思います。以下にそれを記しておきます。\n\n`io.MultiWriter`を標準出力に設定すると、ターミナルではないという判定になり、`mattn/colorable`\nが色設定をスキップするようなので、`fatih/color` 側の\n`NoColor`をチェックし`true`ならエスケープ情報をそのまま標準出力に流し、親側に色情報を提供するようにしました。もし`false`なら生のターミナルにそのまま色情報を出力します。\n\n```\n\n package main\n \n import (\n \"fmt\"\n \"io\"\n \"os\"\n \n \"github.com/fatih/color\"\n )\n \n func main() {\n c := color.New(color.FgYellow)\n var output io.Writer\n if color.NoColor {\n c.EnableColor()\n output = os.Stdout\n } else {\n output = color.Output\n }\n yellow := c.SprintFunc()\n fmt.Fprintf(output, \"< %s >\\n\", yellow(\"yellow\"))\n }\n \n```\n\n親側はそれを受けて、標準出力は`colorable.NewColorable()`で受けて、ファイルへの出力は`colorable.NewNonColorable()`で受けてやることで、io.MultiWriterでも色設定をできるようにしました。\n\n```\n\n package main\n \n import (\n \"flag\"\n \"io\"\n \"os\"\n \"os/exec\"\n \n colorable \"github.com/mattn/go-colorable\"\n )\n \n var c = flag.String(\"c\", \"yellow.exe\", \"\")\n \n func main() {\n flag.Parse()\n var cmd *exec.Cmd\n \n cmd = exec.Command(*c)\n cmd.Stdout = colorable.NewColorable(os.Stdout)\n cmd.Run()\n \n f, _ := os.Create(\"yellow.txt\")\n defer f.Close()\n \n cmd = exec.Command(*c)\n cmd.Stdout = io.MultiWriter(colorable.NewNonColorable(f), colorable.NewColorable(os.Stdout))\n cmd.Run()\n }\n \n```\n\n`親子がGo言語で書ける` 且つ `子のコードを編集可能`\nである場合に限り、この対応で問題ないと思いますが、これ以外の場合においては、いまだ解決策がない状態です。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T11:15:45.813",
"favorite_count": 0,
"id": "45451",
"last_activity_date": "2019-06-29T00:43:46.980",
"last_edit_date": "2018-07-10T13:00:04.780",
"last_editor_user_id": "18863",
"owner_user_id": "18863",
"post_type": "question",
"score": 1,
"tags": [
"windows",
"go"
],
"title": "色付き文字列をio.MultiWriterで出力するには",
"view_count": 100
} | [
{
"body": "質問にある追記の通り、条件付きで色付き表示ができるようになりました。現状では条件以外の解決策はないと判断し、この質問自体は解決済みにマークさせていただきます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-06-29T00:43:46.980",
"id": "56207",
"last_activity_date": "2019-06-29T00:43:46.980",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "18863",
"parent_id": "45451",
"post_type": "answer",
"score": 0
}
] | 45451 | 56207 | 56207 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Django2.0でブログのプロジェクトを作成しています。データベースはデフォルトのSQlite3からPostgreSQLに変更し,Herokuにデプロイしました。 \nHerokuサイト上の管理画面からログインできなくなったため、解消方法をご教示いただきたく投稿させていただきました。\n\n行った作業ですが、サイトを色々調べ、settings.pyの\n\n```\n\n DATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.sqlite3',\n 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),\n }\n }\n \n```\n\nこれを\n\n```\n\n import dj_database_url\n PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))\n db_from_env = dj_database_url.config()\n DATABASES = {\n 'default': dj_database_url.config()\n }\n ALLOWED_HOSTS = ['*']\n \n```\n\nこのように置き換えデプロイしたところ,`$ heroku open`で正常にサイトが表示されました。 \nデプロイする前に`$ python manage.py createsuperuser`でスーパーユーザーの \nアカウントを作成し、パスワードも設定しました。 \nローカル環境ではこのログイン情報が有効で、管理画面からログインしてブログ投稿もできます。\n\nところがhttps:*****.herokuapp.com/admin \nから管理画面でログインしようとしたところ、ローカルで有効だったユーザー情報ではログインできません。 \n再び色々と調べ、改めてスーパーユーザーアカウントを作る必要があるとたどり着きました。 \nそしてまた`$ python manage.py createsuperuser`を実行したところ、\n\n> settings.DATABASES is improperly configured. Please supply the ENGINE value.\n\n↑このエラーが出てきました。\n\nまだ試していないのですが、DATABASESの記述を以下にすれば,再び \ncreate superuserが実行でき、Herokuサイトから管理画面でログインできるのでしょうか。\n\n```\n\n import dj_database_url\n PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))\n db_from_env = dj_database_url.config()\n DATABASES = {\n 'default':{ \n 'ENGINE':'django.db.backends.postgresql'\n 'NAME': dj_database_url.config()\n }\n }\n ALLOWED_HOSTS = ['*']\n \n```\n\nあるいは、他の原因や方法があればご教示頂けますと幸いです。 \nHerokuのダッシュボードから PostgreSQLの設定が何か必要なのでしょうか。 \nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T11:30:18.117",
"favorite_count": 0,
"id": "45452",
"last_activity_date": "2018-07-11T11:29:02.563",
"last_edit_date": "2018-07-09T14:12:34.993",
"last_editor_user_id": "23994",
"owner_user_id": "28573",
"post_type": "question",
"score": 0,
"tags": [
"django",
"heroku",
"postgresql"
],
"title": "Django2のデータベース設定(ENGINE VALUE)とHeroku管理画面ログイン",
"view_count": 90
} | [
{
"body": "自己解決しました。初歩的なコマンドミスによりcreatesuperuserができていませんでした。\n\n正しくは \n$ heroku run python manage.py createsuperuser \nでしたが、うっかり heroku runをつけ忘れ、 \n$ python manage.py createsupseuser \nを何度も実行していました。\n\n無事にheroku.app/adminからログインできるようになりました。 \n大変お騒がせいたしました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T11:29:02.563",
"id": "45512",
"last_activity_date": "2018-07-11T11:29:02.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28573",
"parent_id": "45452",
"post_type": "answer",
"score": 0
}
] | 45452 | null | 45512 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "ラズパイ3 model Bで、I2CでのIDmの読み出しを検証しようとしています。\n\n```\n\n root@xxx:/home/xxx# i2cdetect -y 1\n 0 1 2 3 4 5 6 7 8 9 a b c d e f\n 00: -- -- -- -- -- -- -- -- -- -- -- -- -- \n 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \n 20: -- -- -- -- 24 -- -- -- -- -- -- -- -- -- -- -- \n 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \n 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \n 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \n 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- \n 70: -- -- -- -- -- -- -- -- \n \n```\n\nUSBタイプのNFCではなく、GPIOでラズパイに認識させることはできたのですが、 \nCLIからSuicaやAndroidのIDmを読み込むことはできるのでしょうか?\n\nnfcpyなどは試したのですが、USBで接続したNFCモジュールしか扱えない?ようでした。\n\nまた、i2cgetで取得したデータはなんのデータなのでしょうか?\n\n```\n\n root@xxx:/home/xxx# i2cget 1 0x24\n WARNING! This program can confuse your I2C bus, cause data loss and worse!\n I will read from device file /dev/i2c-1, chip address 0x24, current data\n address, using read byte.\n Continue? [Y/n] y\n 0x80\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T13:43:53.807",
"favorite_count": 0,
"id": "45456",
"last_activity_date": "2018-07-09T13:55:46.983",
"last_edit_date": "2018-07-09T13:55:46.983",
"last_editor_user_id": "8396",
"owner_user_id": "8396",
"post_type": "question",
"score": 2,
"tags": [
"raspberry-pi"
],
"title": "ラズパイ×I2CでNFCの読み込みを検証したい",
"view_count": 134
} | [] | 45456 | null | null |
{
"accepted_answer_id": "45463",
"answer_count": 1,
"body": "参考書内で”戦争”と呼ばれるゲームのコードを作っていた際の質問です。 \n該当ページ、辞書として用いている参考書、ネットの情報を参照しても不明点が解決せず、これ以上考えるのはあまりよくないと思い質問させていただきます。 \n初歩的な質問だとは思いますが、これを機にクラスへの理解を深めたいです。\n\nコードが長いため、下に掲載します。\n\n①Cardクラスのスイート、2・3番目のメソッド \n`__lt__`,`__gt__`の引数である`c2`がどこでこのメソッドに渡されているのかわかりません。 \nなので、ここのif文にあるc2.valueがどこから引っ張ってこられているのか全く分かりません。\n\n②,③(おそらく同類の質問) \nGameクラスのスイート、4番目のメソッド \nwhileループの中2番目のif文の`self.p1.wins`の参照の仕方について \n☆☆☆を参照する際にwinsにselfをつけなくてもいいのですか?\n\n同クラス、5番目のメソッド \nここでの2つのif文returnに渡す変数はselfをつけてもつけなくてもよいのですか? \n書いているようにselfつけてもつけなくても正常に動きはしました。\n\n参考書では、参照する際にはselfをつけるように記載されていたので少々混乱しています。\n\nコードです。\n\n```\n\n class Card:\n suits=[\"spades\",\"hearts\",\"diamonds\",\"clubs\"]\n \n values=[None,None,\n \"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\n \"10\",\"Jack\",\"Queen\",\"King\",\"Ace\"]\n \n \n def __init__(self,v,s):\n \"\"\"スート・マークはともにint型オブジェクトで扱います\"\"\"\n self.value=v\n self.suit=s\n \n def __lt__(self,c2): #__lt__は比較用の特殊メソッドです(より小さい)\n #c2がどこで作られるオブジェクトなのかわかってません。\n #でも、__lt__ or __gt__メソッドが呼ばれればその時の引数に渡せばいい。え、でもそれもどこ?ww\n if self.value<c2.value:\n return True\n if self.value==c2.value:\n if self.suit<c2.suit:\n return True\n else:\n return False\n \n return False\n \n def __gt__(self,c2): #__gt__は比較用の特殊メソッドです(より大きい)\n if self.value>c2.value:\n return True\n if self.value==c2.suit:\n return True\n if self.suit>c2.suit:\n return True\n else:\n return False\n \n def __repr__(self):\n v=self.values[self.value]+\" of \"+self.suits[self.suit]\n return v\n \n from random import shuffle #意味をきちんと言えるようにしましょう。\n \n class Deck:\n def __init__(self):\n self.cards=[]\n for i in range(2,15): #トランプの52枚のカードを用意しています。\n for j in range(4):\n self.cards.append(Card(i,j))\n shuffle(self.cards)\n \n def rm_card(self):\n if len(self.cards)==0: #カードの枚数が0になると終わりです。\n return\n return self.cards.pop() #引くカードの被りを避けています。\n \n \"\"\"\n deck=Deck()\n for card in deck.cards: #参照の仕方をきちんと覚えましょう。\n print(card)\n \n このコードによりトランプが正確に出力されるか確認しました。\n また、ここまでのエラーに直結する要素は全て解決されています。\n \"\"\"\n \n class Player: #後で使うための下準備です。\n def __init__(self,name):\n self.wins=0 #☆☆☆\n self.card=None\n self.name=name\n \n class Game: #これ、”ここ”でDeck呼び出してるけど、継承した時との違いは?\n def __init__(self):\n name1=input(\"プレイヤー1の名前 \")\n name2=input(\"プレイヤー2の名前 \")\n self.deck=Deck() #ここ\n #上はDeckクラスのオブジェクトとしてカードをdeckのセルフ変数に参照しています。\n self.p1=Player(name1)\n self.p2=Player(name2)\n \n def wins(self,winner):\n w=\"このラウンドは{}が勝ちました\"\n w=w.format(winner) #winsメソッドの引数winnerが上の{}に追加されます。\n print(w)\n \n def draw(self,p1n,p1c,p2n,p2c): #それぞれのプレイヤーが引いたカードをコールします。\n d=\"{}は{}、{}は{}を引きました。\"\n d=d.format(p1n,p1c,p2n,p2c)\n print(d)\n \n def play_game(self):\n cards=self.deck.cards #Deckクラスのself.deckオブジェクトを引数としてDeckクラス内のcardsメソッドに渡します。\n print(\"Let's begin the game called war!\")\n while len(cards)>=2:\n m=\"qで終了、それ以外のキーでPlay:\"\n response=input(m)\n if response==\"q\":\n break\n p1c=self.deck.rm_card()\n p2c=self.deck.rm_card()\n p1n=self.p1.name\n p2n=self.p2.name\n self.draw(p1n,p1c,p2n,p2c)\n if p1c>p2c:\n self.p1.wins+=1 #これ、☆☆☆を参照しているのだろうけどwinsにselfはいらない?\n self.wins(self.p1.name)\n else:\n self.p2.wins+=1\n self.wins(self.p2.name)\n \n win=self.winner(self.p1,self.p2)\n print(\"ゲーム終了、{}の勝利です!\".format(win))\n def winner(self,p1,p2):\n if p1.wins>p2.wins:\n return self.p1.name #元はp1.nameだったけど、self変数にしなくていいのか迷ったのでいったんself変数で書いてます。\n if p1.wins<p2.wins:\n return p2.name\n return \"引き分け\" #elseの処理これでもできるんだっけ、覚えてないです。\n \n \n game=Game()\n game.play_game()\n \n```\n\nP.S. \n#は自分がコードを書いている際に思ったことなどを書いています。 \n質問したところ以外にも疑問点を書いていますが、自分でまだ十分にしらべられてないので \nもし、調べてわからなければもう一度追加質問させていただきます。 \nまた、どこが原因なのかわからないため、全体を掲載します。ご容赦ください。 \n質問該当箇所はわかりやすく記したつもりではありますが、わかりにくい点があればご指摘ください。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T15:15:26.660",
"favorite_count": 0,
"id": "45461",
"last_activity_date": "2018-07-09T15:48:29.153",
"last_edit_date": "2018-07-09T15:28:58.927",
"last_editor_user_id": "19110",
"owner_user_id": "29238",
"post_type": "question",
"score": 2,
"tags": [
"python"
],
"title": "クラスの引数・変数・変数の参照についての質問です。",
"view_count": 136
} | [
{
"body": "### ① `__lt__(self, c2)` の `c2` とは何か?\n\n`<` で比較するときの右側の引数です。こちらの別質問をご覧ください: [「クラスの関数で、self\n以外の変数が何なのか分からない」](https://ja.stackoverflow.com/q/44262/19110)\n\n### ② `self.p1.wins += 1` の `wins` に `self` はつけなくて良い?\n\nつけません。\n\n`self` は自分自身のことを示す特別なオブジェクトなのでした。また、`self.p1` もオブジェクトであり、`Game` クラスのインスタンス変数\n`p1` のことを指しています。\n\nつまりこの行では「`Game` クラスのインスタンス変数 `p1`」のインスタンス変数 `wins` を操作しようとしているのです。`self.p1`\nの時点でどのオブジェクトの `wins` を操作しようとしているのか明らかです。\n\nまた、`self` という名前は同じですが、`Game` クラスのメソッドの中で使われる `self` は `Game`\nクラスのオブジェクトそのものを指しており、`Player` クラスのオブジェクトを指しているわけではないことにも注意してください。\n\n### ③ 関数 `winner(self, p1, p2)` において `self.p1` と `p1` に差はある?\n\n少なくとも `self.p1` と `p1` に差はあります。\n\n`self.p1` は自分自身がインスタンス変数として持っている `p1` を指す一方、`p1` は関数 `winner` の引数として与えられた `p1`\nを指します。\n\n「`self` をつけてもつけなくても同じように動作した」とのことですが、これは `play_game()` 関数の中で `winner`\n関数を呼び出す際に以下のようにしているからです。\n\n```\n\n win = self.winner(self.p1, self.p2)\n \n```\n\n上のように使う限りは、`p1` と `self.p1` が一致するため、`self` があってもなくても同じ動作になります。(蛇足:\nこのような使い方しかしないのであれば、`winner` 関数の引数 `p1`, `p2`\nは不要だと思われます。書籍中の別の箇所で違う使い方をするのかもしれません。)",
"comment_count": 17,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T15:48:29.153",
"id": "45463",
"last_activity_date": "2018-07-09T15:48:29.153",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "45461",
"post_type": "answer",
"score": 2
}
] | 45461 | 45463 | 45463 |
{
"accepted_answer_id": "45464",
"answer_count": 1,
"body": "JavaScriptでascii85encoderを作っているのですが、encode後の値がすこし違うものになってしまいます。 \nなぜなのでしょうか?\n\n例えば、ascii85 Python\nencoder(base64.a85encode)に\"Hello\"のバイト列を渡すと`87cURDZ`となりますが、この関数(ascii85encode)では`87cURDZBb;`となってしまいます。\n\n```\n\n function ascii85encode(arr) {\n let str = \"\";\n let a = [];\n for (let i = 0; i < arr.length; i++) {\n a.push(arr[i]);\n if (a.length === 4) {\n let res = ascii85_str(a);\n str += res;\n a = [];\n }\n }\n if (a.length > 0) {\n for (let t = 0; t < 4 - a.length; t++) {\n //足りないところを0で埋める。\n a.push(0);\n }\n str += ascii85_str(a, true);\n }\n return str\n };\n \n function ascii85_str(nums, last=false) {\n const uint32 = createUInt32(nums);\n const str = base85_num(uint32, last);\n if (str === \"!!!!!\") {\n str = \"z\";\n }\n return str;\n };\n \n function createUInt32(a) {\n if (a.length > 4) {\n throw new Error(\"createUInt32 argument must be a four elements list of UInt8\");\n }\n return (a[0] << 24 | a[1] << 16 | a[2] << 8 | a[3]);\n };\n \n function base85_num(n, l = false) {\n //引数としてわたってきたブロックの値(32bit値)を85進数の値(0~84)に変換\n n = Math.abs(n);\n let res = [];\n for (let p = 0; p < 5; p++) {\n let s = String.fromCodePoint((n%85) + 33)\n res.unshift(s);\n n = parseInt(n / 85);\n if (l && n === 0) { //与えられた値が最後のブロックでかつ、nがゼロ(これ以上余りが出ない)ならそこで終了\n break;\n }\n }\n return res.join(\"\");\n };\n \n \n export { ascii85encode };\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T15:25:33.293",
"favorite_count": 0,
"id": "45462",
"last_activity_date": "2018-07-09T18:03:03.217",
"last_edit_date": "2018-07-09T15:30:48.250",
"last_editor_user_id": "5246",
"owner_user_id": "5246",
"post_type": "question",
"score": 1,
"tags": [
"javascript"
],
"title": "JavaScriptで書いたascii85 Encoderがうまく動かない",
"view_count": 106
} | [
{
"body": "最終ブロックの処理が間違っています。\n\n```\n\n if (l && n === 0) { //与えられた値が最後のブロックでかつ、nがゼロ(これ以上余りが出ない)ならそこで終了\n \n```\n\n`n`は余りではなく商であり、あなたのコードは下位桁から処理していっているので、上位桁の情報を持っています。たとえ`n`がたまたま`0`になっても途中で終了してはいけません。\n\nバイト数が4の倍数にならずに(256進数の意味で)`0`埋めした分は、解読時に影響しない範囲で省略します。\n\n(256進で)`0`3個 => 85^3 < 256^3 < 85^4\n\nと言うわけで、85進数と言える結果の文字数を4つ無視すると、下位3バイト分以上の差になってしまうので、`0`埋めを3バイト分行なった時に無視して良い85進側の文字数は3と言うことになります。\n\n理屈をこねると難しくなりますが、`0`埋め2個なら85進側でも2文字、1個なら1文字という結果が出ます。\n\nつまり`0`埋めした個数の分だけ結果の下位文字を削らないといけません。\n\n以下の2関数を変更する必要があるでしょう。\n\n```\n\n function ascii85encode(arr) {\n let str = \"\";\n let a = [];\n for (let i = 0; i < arr.length; i++) {\n a.push(arr[i]);\n if (a.length === 4) {\n let res = ascii85_str(a);\n str += res;\n a = [];\n }\n }\n if (a.length > 0) {\n let padding = 4 - a.length;\n for (let t = 0; t < padding; t++) {\n //足りないところを0で埋める。\n a.push(0);\n }\n str += ascii85_str(a, padding); //<-最終ブロックのpaddingバイト数を覚えておく\n }\n return str\n };\n \n function base85_num(n, padding = 0) {\n //引数としてわたってきたブロックの値(32bit値)を85進数の値(0~84)に変換\n n = Math.abs(n);\n let res = [];\n for (let p = 0; p < 5; p++) {\n let s = String.fromCodePoint((n%85) + 33)\n res.unshift(s);\n n = parseInt(n / 85);\n }\n res = res.slice(0, 5-padding); //<- paddingバイト数の分後ろを削る\n return res.join(\"\");\n };\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-09T18:03:03.217",
"id": "45464",
"last_activity_date": "2018-07-09T18:03:03.217",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "45462",
"post_type": "answer",
"score": 2
}
] | 45462 | 45464 | 45464 |
{
"accepted_answer_id": "45496",
"answer_count": 2,
"body": "OS:Ubuntu 16.04 LTS、Mecabバージョン0.996にての質問です。\n\n最初にここの説明通りにインストールしました:<http://taku910.github.io/mecab/#install-unix>\n\nしかし、上記の問題が発生したためにここの説明を参考にしてやり直しました: \n<https://qiita.com/junpooooow/items/0a7d13addc0acad10606>\n\n`./configure --with-charset=utf8`の手順で以下”Missing\"が発生します。\n\n```\n\n checking for a BSD-compatible install... /usr/bin/install -c\n checking whether build environment is sane... yes\n checking whether make sets $(MAKE)... yes\n checking for working aclocal-1.4... missing\n checking for working autoconf... found\n checking for working automake-1.4... missing\n checking for working autoheader... found\n checking for working makeinfo... missing\n checking for a BSD-compatible install... /usr/bin/install -c\n checking for mecab-config... /usr/local/bin/mecab-config\n configure: creating ./config.status\n config.status: creating Makefile\n \n```\n\nそのまま\n\n```\n\n $ make\n $ sudo make install\n \n```\n\nしても上記の問題が発生し続けています(多分当たり前の話ですが)。 \n解決法を知っている方アドバイスをお願いします。\n\n**追記:** \n<http://q.hatena.ne.jp/1343137403> を参考にして辞書を以下のように指定すると、文字化けが無くなります。\n\n```\n\n mecab -d /var/lib/mecab/dic/ipadic-utf8\n \n```\n\nうれしいのですが、毎回入力せずに済む方法(辞書の指定を固定させる)はありますか。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T00:29:31.007",
"favorite_count": 0,
"id": "45465",
"last_activity_date": "2018-07-11T04:56:06.130",
"last_edit_date": "2018-07-11T04:50:24.500",
"last_editor_user_id": "3060",
"owner_user_id": "29239",
"post_type": "question",
"score": 0,
"tags": [
"mecab"
],
"title": "Mecabが文字化けとUnicodeDecodeErrorが発生",
"view_count": 213
} | [
{
"body": "`./configure`実行時には、これからコンパイル・インストールしようとしているソフトウェアに必要なものが揃っているかを確認しており、`missing`と出ている場合は足りないものを確認しつつ事前にインストールしなければいけません。\n\n質問の環境で足りていないのは以下のパッケージになると思うので、お使いの環境に合わせて確認、インストールしてみてください。\n\n * **automake** (aclocal, automake)\n * **texinfo** (makeinfo)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T00:50:23.437",
"id": "45466",
"last_activity_date": "2018-07-10T00:50:23.437",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "45465",
"post_type": "answer",
"score": 1
},
{
"body": "> うれしいのですが、毎回入力せずに済む方法(辞書の指定を固定させる)はありますか。\n\n[Mecabのシステム辞書・ユーザ辞書の利用方法について](https://qiita.com/hiro0217/items/cfcf801023c0b5e8b1c6)\nによると、 \n`/usr/local/etc/mecabrc`に以下のように設定することで、システム辞書の場所を指定できるようです。\n\n```\n\n dicdir = /var/lib/mecab/dic/ipadic-utf8\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T04:56:06.130",
"id": "45496",
"last_activity_date": "2018-07-11T04:56:06.130",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45465",
"post_type": "answer",
"score": 0
}
] | 45465 | 45496 | 45466 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "jsp+サーブレットでWebアプリ開発を勉強しているのですが \ntextareaから長い文章(18万字、500kB程)を2つ送信したときに \nformからPostしたデータがサーブレット側で受け取れないことがありました。 \nプログラム側でエラーも発生せずに、textareaから受け取った値はnullとなっています。\n\nアプリケーションサーバーはtomcatを使用しており、maxPostSizeを変更しても結果は変わりませんでした。\n\ntextareaに入力する文字数を減らすと問題なく動きます。\n\n原因がわかる方がいらっしゃいましたら、ご回答のほどよろしくお願いします。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T00:51:23.987",
"favorite_count": 0,
"id": "45467",
"last_activity_date": "2020-03-16T09:55:36.963",
"last_edit_date": "2020-03-16T09:55:36.963",
"last_editor_user_id": "19110",
"owner_user_id": "29195",
"post_type": "question",
"score": 0,
"tags": [
"java",
"http",
"tomcat"
],
"title": "Postする際の文字数上限",
"view_count": 1732
} | [] | 45467 | null | null |
{
"accepted_answer_id": "45469",
"answer_count": 1,
"body": "# 環境\n\n * Python 3.6.5\n * Bokeh 0.13.0\n\n# やりたいこと\n\nBokehを使ってグラフを表示しています。 \n凡例をグラフ外に表示したいです。\n\n凡例は、`line`メソッドの`legend`オプションで指定しています。\n\n```\n\n import pandas as pd\n \n from bokeh.palettes import Spectral4\n from bokeh.plotting import figure, output_file, show\n from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG\n \n p = figure(plot_width=800, plot_height=250, x_axis_type=\"datetime\")\n p.title.text = 'Click on legend entries to hide the corresponding lines'\n \n for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [\"AAPL\", \"IBM\", \"MSFT\", \"GOOG\"], Spectral4):\n df = pd.DataFrame(data)\n df['date'] = pd.to_datetime(df['date'])\n p.line(df['date'], df['close'], line_width=2, color=color, alpha=0.8, legend=name)\n \n p.legend.location = \"top_left\"\n p.legend.click_policy=\"hide\"\n \n output_file(\"interactive_legend.html\", title=\"interactive_legend.py example\")\n \n show(p)\n \n```\n\n<https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/legends.html>\n引用\n\n# 質問\n\n凡例をグラフ外に表示するには、どのように記述すればよろしいでしょうか?\n\n以下のサイトには、凡例を外に表示する方法が記載されていました。 \n<https://bokeh.pydata.org/en/latest/docs/user_guide/styling.html>\n\n```\n\n legend = Legend(items=[\n (\"sin(x)\" , [r0, r1]),\n (\"2*sin(x)\" , [r2]),\n (\"3*sin(x)\" , [r3, r4]),\n ], location=(0, -30))\n \n p.add_layout(legend, 'right')\n \n```\n\nしかし、今の私のコードで、`legend`オブジェクトを、どのように取得すればよいかが、分かりませんでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T01:12:53.503",
"favorite_count": 0,
"id": "45468",
"last_activity_date": "2018-07-10T17:47:03.827",
"last_edit_date": "2018-07-10T06:04:17.783",
"last_editor_user_id": "19110",
"owner_user_id": "19524",
"post_type": "question",
"score": 1,
"tags": [
"python",
"bokeh"
],
"title": "データ可視化ライブラリBokehで、凡例をグラフの外に表示する方法",
"view_count": 1511
} | [
{
"body": "> わざわざlegend_it.append((name, [c]))というコードを書くのは、スマートでないと感じております。\n> この方法しかないのでしょうか?\n\nスマートかどうかはわかりませんが、[bokeh/bokeh](https://github.com/bokeh/bokeh)のリポジトリを検索すると、以下のサンプルソースがありました。\n\n[custom_tooltip.py](https://github.com/bokeh/bokeh/blob/422a437f2079290384d9a0a496379e7b492d996d/examples/plotting/file/custom_tooltip.py)\n\n`Legend`オブジェクトの`plot`属性を`None`にすると再度、`add_layout`できるようです。\n\n```\n\n import pandas as pd\n \n from bokeh.palettes import Spectral4\n from bokeh.plotting import figure, output_file, show\n from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG\n \n p = figure(plot_width=800, plot_height=250, x_axis_type=\"datetime\")\n p.title.text = 'Click on legend entries to hide the corresponding lines'\n \n for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [\"AAPL\", \"IBM\", \"MSFT\", \"GOOG\"], Spectral4):\n df = pd.DataFrame(data)\n df['date'] = pd.to_datetime(df['date'])\n p.line(df['date'], df['close'], line_width=2, color=color, alpha=0.8, legend=name)\n \n #p.legend.location = \"top_left\"\n p.legend.click_policy=\"hide\"\n p.legend[0].plot = None\n p.add_layout(p.legend[0], 'right')\n \n output_file(\"03.html\", title=\"interactive_legend.py example\")\n \n show(p)\n \n```\n\n以下、以前の回答。\n\n本家のstackoverflowに類似の質問と回答がありました。\n\n[Position the legend outside the plot area with\nBokeh](https://stackoverflow.com/questions/46730609/position-the-legend-\noutside-the-plot-area-with-bokeh?answertab=active#tab-top)\n\n以下のコメントに記載していますが、凡例用に値と名前の対応をlegend_itに保存してLegendを作成しています。 \n凡例クリック時のmute用に`p.line`に`muted_color`,`muted_alpha`を明示的に指定する必要があるようです。\n\n```\n\n import pandas as pd\n from bokeh.palettes import Spectral4\n from bokeh.plotting import figure, output_file, show\n from bokeh.sampledata.stocks import AAPL, IBM, MSFT, GOOG\n from bokeh.models import Legend\n \n p = figure(plot_width=800, plot_height=250, x_axis_type=\"datetime\")\n p.title.text = 'Click on legend entries to hide the corresponding lines'\n \n legend_it = []\n \n for data, name, color in zip([AAPL, IBM, MSFT, GOOG], [\"AAPL\", \"IBM\", \"MSFT\", \"GOOG\"], Spectral4):\n df = pd.DataFrame(data)\n df['date'] = pd.to_datetime(df['date'])\n \n # 凡例の値として設定できるように変数に設定\n # mute時の色を設定\n c = p.line(df['date'], df['close'], line_width=2, color=color, alpha=0.8, muted_color=color, muted_alpha=0.2)\n # 凡例用に名前と値の対応を設定\n legend_it.append((name, [c]))\n \n # 凡例作成\n legend = Legend(items=legend_it, location=(0, 0))\n legend.click_policy=\"mute\"\n \n p.add_layout(legend, 'right')\n \n output_file(\"interactive_legend2.html\", title=\"interactive_legend.py example\")\n show(p)\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T02:33:47.877",
"id": "45469",
"last_activity_date": "2018-07-10T17:47:03.827",
"last_edit_date": "2018-07-10T17:47:03.827",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45468",
"post_type": "answer",
"score": 1
}
] | 45468 | 45469 | 45469 |
{
"accepted_answer_id": "45472",
"answer_count": 1,
"body": "**前提** \n・cronを毎日実行しています \n・phpを実行させ複数のhtmlファイルを出力させています \n・(出力指定順番が最後ではない)ある特定のhtmlファイルだけが最近になって出力されなくなり原因を調べています\n\n* * *\n\n**Q1** \n・/var/log/cronを確認したら、下記のような感じになっていたのですが、毎日実行しているのに、特定の日しかログが出ないのはなぜだと考えられますか? \n・この日しかエラーは出なかったということ?\n\n> cron \n> cron-20180702 \n> cron-20180708\n\n* * *\n\n**Q2.cronのログ出力設定するやり方とかありますか?** \n・cronのログ出力レベルを設定したりは出来ない??\n\n* * *\n\n**Q3.cronメールについて** \n・cron実行時に受信できるメール内容と、/var/log/cronの内容は同じですか? \n・/var/log/cronの内容を確認するなら、わざわざcronメールを受信する必要はない??\n\n* * *\n\n**環境** \n・CentOS7",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T03:18:32.380",
"favorite_count": 0,
"id": "45470",
"last_activity_date": "2018-07-10T06:55:32.980",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7886",
"post_type": "question",
"score": 1,
"tags": [
"centos",
"cron"
],
"title": "cronのログについて",
"view_count": 1239
} | [
{
"body": "実際に動いているかどうかは、/var/log/cron ログの中身を確認して タイムスタンプを確認すると良いと思います。\n\n◆ログの例\n\n```\n\n Jul 8 06:00:01 hoge CROND[28126]: (root) CMD (/usr/share/clamav/freshclam-sleep)\n Jul 8 06:01:01 hoge CROND[28158]: (root) CMD (run-parts /etc/cron.hourly)\n \n```\n\n日付つきの2つのファイルは おそらく logroate によって ローテーションされたものです。\n\ncron (cronie) は rsyslog の設定で ログレベルを制御することができます。 \nただ、デフォルトでは、すべてを出力しているので、ログの量を減らすことは出来ても、追加の情報を得ることはできないと思います。 \n※有用かどうかはわかりませんが crond の `-x` オプションでデバッグ情報を出力できるようです。\n\ncron実行結果のメールは、実行されたコマンドが出力した 標準出力と標準エラー出力の内容です。 \n/var/log/cron に書かれているのは crond が出力したもので 内容は異なります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T06:55:32.980",
"id": "45472",
"last_activity_date": "2018-07-10T06:55:32.980",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "45470",
"post_type": "answer",
"score": 3
}
] | 45470 | 45472 | 45472 |
{
"accepted_answer_id": "45474",
"answer_count": 3,
"body": "* wordで`1行目,2行目,3行目, ...`と文字を入力してテキストファイル(`phptanaka.txt`)を作成\n * viエディタで下記コードを入力してphpファイル(`aaa.php`)を作成\n\nターミナルで`php aaa.php`と実行するとエラーは出ませんが`?P?s??`と文字化けして表示されてしまいます。 \nあともう少しのところまで来ているような気がするのですが、時間だけが経過してしまいます。 \nどなたかご助言下れば幸いです。宜しくお願いします。\n\n```\n\n <?php\n \n $fp= fopen(\"/Users/tanakaakio/Desktop/phptanaka.txt\",\"r\");\n \n $line = fgets($fp);\n \n fclose($fp);\n \n $hoge = file(\"/Users/tanakaakio/Desktop/phptanaka.txt\");\n \n print $hoge[0];\n \n ?>\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T06:42:27.213",
"favorite_count": 0,
"id": "45471",
"last_activity_date": "2018-07-11T01:57:54.907",
"last_edit_date": "2018-07-11T01:57:54.907",
"last_editor_user_id": "3060",
"owner_user_id": "29244",
"post_type": "question",
"score": 0,
"tags": [
"php"
],
"title": "テキストファイルの中に記述されている1行目を取得し、画面に表示したい",
"view_count": 633
} | [
{
"body": "文字に?が出ているということは、UTF8の文字をShift-Jisで表現しようとして文字化けしたのかと思います。 \nコンソールの文字コードを確認してみて、Shit-Jisになっていれば、UTF8にしてみてはどうでしょうか?\n\n<http://okguide.okwave.jp/guides/590>\n\n以下参考URLからの引用です(半角の#をつけるとBoldになるので、全角にしています)\n\n> * 現在の文字コード確認 \n> # echo $LANG\n>\n> * 文字コード変更 \n> # LANG=ja_JP.UTF-8\n>\n>",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T07:10:46.760",
"id": "45474",
"last_activity_date": "2018-07-10T07:17:09.693",
"last_edit_date": "2018-07-10T07:17:09.693",
"last_editor_user_id": "17014",
"owner_user_id": "17014",
"parent_id": "45471",
"post_type": "answer",
"score": 0
},
{
"body": "テキストデータを作成する際は文字コードを気にした方がいいかと思います。 \n対処方法としては、 \n1.Webサーバ内で作成する(vimなど) \nWebサーバに設定していなければ普通サーバのデフォルト文字コードが使われるので、 \n同一サーバ内で作成したテキストファイルは同じ文字コードで表示されるはずです。 \n2.作成した環境の文字コードからWebサーバ環境の文字コードに変換する。 \nWindowsでテキストデータを作成した場合、大抵ShiftJISです。\n\n```\n\n <?php\n $path=\"/Users/tanakaakio/Desktop/phptanaka.txt\";\n $fp= fopen($path,\"r\");\n $line = fgets($fp);\n fclose($fp);\n //文字コードを変換して表示\n print mb_convert_encoding($line, 'UTF-8', 'sjis-win');\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T08:03:21.277",
"id": "45477",
"last_activity_date": "2018-07-10T08:03:21.277",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45471",
"post_type": "answer",
"score": 1
},
{
"body": "プログラム(ソースコード)やプログラムで扱うテキストデータの作成にWordの使用はおすすめしません。 \nviエディタが使用できるなら、対象のテキストファイルもviで作成する方が余計なトラブルを避けられます。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T16:19:54.387",
"id": "45488",
"last_activity_date": "2018-07-10T16:19:54.387",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "45471",
"post_type": "answer",
"score": 1
}
] | 45471 | 45474 | 45477 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Windows の GVim を利用しています。 \n例えば 源真ゴシック等幅 の Medium を利用したい場合、\n\n```\n\n set guifont=*\n \n```\n\nとして、一覧からフォント名「源真ゴシック」スタイル「中」サイズ「11」と選ぶと、きちんと Medium 幅で表示されます。 \nこのとき guifont には `源真ゴシック等幅_Medium:h11:cSHIFTJIS:qDRAFT` と設定されていました。\n\nところが、直接この文字列を\n\n```\n\n set guifont=源真ゴシック等幅_Medium:h11:cSHIFTJIS:qDRAFT\n \n```\n\nとして設定しても、なぜか Medium にならず、 Regular 幅で表示されます。\n\nどのように設定すれば Medium 幅のフォントを利用できますか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T07:24:22.143",
"favorite_count": 0,
"id": "45475",
"last_activity_date": "2020-07-24T07:41:33.313",
"last_edit_date": "2018-07-10T07:40:12.817",
"last_editor_user_id": "3060",
"owner_user_id": "29245",
"post_type": "question",
"score": 3,
"tags": [
"windows",
"vim"
],
"title": "Windows の GVim で Medium 幅のフォントを使用したい",
"view_count": 218
} | [
{
"body": "問題の発生していたバージョンは分かりませんが、該当の GitHub リポジトリ上でこの問題が [Issue](https://github.com/vim-\njp/issues/issues/1177)\nとして登録された後、[8.1.1224](https://github.com/vim/vim/commit/f720d0a77e393990b2171a77210565bdc82064f2)\nのリリースで `:W400` などのようにウェイトを指定できるようになりました。\n\n* * *\n\n_この投稿は[@KoRoN\nさんのコメント](https://ja.stackoverflow.com/questions/45475/windows-%e3%81%ae-\ngvim-%e3%81%a7-medium-%e5%b9%85%e3%81%ae%e3%83%95%e3%82%a9%e3%83%b3%e3%83%88%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e3%81%84#comment47415_45475)\nと [@statiolake\nさんのコメント](https://ja.stackoverflow.com/questions/45475/windows-%e3%81%ae-\ngvim-%e3%81%a7-medium-%e5%b9%85%e3%81%ae%e3%83%95%e3%82%a9%e3%83%b3%e3%83%88%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e3%81%84#comment47442_45475)\nの内容を元に コミュニティwiki として投稿しました。_",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2020-07-24T07:41:33.313",
"id": "68904",
"last_activity_date": "2020-07-24T07:41:33.313",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "45475",
"post_type": "answer",
"score": 2
}
] | 45475 | null | 68904 |
{
"accepted_answer_id": "45503",
"answer_count": 2,
"body": "CentOS7にtomcatをインストールするため、以下のようにコマンドを実行しました。\n\n```\n\n yum install java-1.8.0-openjdk.x86_64\n yum install -y tomcat\n wget -p /usr/share/tomcat/webapps/ https://github.com/gitbucket/gitbucket/releases/download/4.26.0/gitbucket.war\n \n```\n\ntomcatを起動させようとするとエラーがでましたが、原因がわかりません。\n\n```\n\n [root@localhost ~]# systemctl start tomcat\n [root@localhost ~]# systemctl status tomcat\n ● tomcat.service - Apache Tomcat Web Application Container\n Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor \n preset: disabled)\n Active: failed (Result: exit-code) since 火 2018-07-10 17:54:19 JST; 1s \n ago\n Process: 26576 ExecStart=/usr/libexec/tomcat/server start (code=exited, \n status=1/FAILURE)\n Main PID: 26576 (code=exited, status=1/FAILURE)\n \n 7月 10 17:54:19 localhost.localdomain server[26576]: options used: - \n Dcatalina.base=/usr/share/tomcat -Dcatalina.home=/usr/share/tomcat - \n Djava.en...gManager\n 7月 10 17:54:19 localhost.localdomain server[26576]: arguments used: start\n 7月 10 17:54:19 localhost.localdomain server[26576]: Exception in thread \n \"main\" java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory\n 7月 10 17:54:19 localhost.localdomain server[26576]: at \n org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:49)\n 7月 10 17:54:19 localhost.localdomain server[26576]: Caused by: \n java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory\n 7月 10 17:54:19 localhost.localdomain server[26576]: at \n java.net.URLClassLoader.findClass(URLClassLoader.java:381)\n 7月 10 17:54:19 localhost.localdomain server[26576]: at \n java.lang.ClassLoader.loadClass(ClassLoader.java:424)\n 7月 10 17:54:19 localhost.localdomain systemd[1]: tomcat.service: main \n process exited, code=exited, status=1/FAILURE\n 7月 10 17:54:19 localhost.localdomain systemd[1]: Unit tomcat.service \n entered failed state.\n 7月 10 17:54:19 localhost.localdomain systemd[1]: tomcat.service failed.\n Hint: Some lines were ellipsized, use -l to show in full.\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T08:57:36.183",
"favorite_count": 0,
"id": "45478",
"last_activity_date": "2018-07-11T05:49:02.510",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28019",
"post_type": "question",
"score": 1,
"tags": [
"tomcat"
],
"title": "tomcatが起動しない",
"view_count": 6924
} | [
{
"body": "java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory \nの行にある通り、org.apache.juli.logging.LogFactoryというクラスが見つからないと言っています。\n\norg.apache.juli.logging.LogFactoryについて調べて、不足しているライブラリをインストールしてみてください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T09:12:25.077",
"id": "45481",
"last_activity_date": "2018-07-10T09:12:25.077",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17014",
"parent_id": "45478",
"post_type": "answer",
"score": 1
},
{
"body": "Tomcatの設定ファイルや起動スクリプトを変更していることが原因で、`CLASSPATH`に`tomcat-\njuli.jar`が指定されていないのではないかと思います。\n\n通常、`tomcat-\njuli.jar`(や`bootstrap.jar`)は`${CATALINA_HOME}/lib/`ではなく`${CATALINA_HOME}/bin/`にあり、起動スクリプトの中で`CLASSPATH`に設定されます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T05:41:19.093",
"id": "45503",
"last_activity_date": "2018-07-11T05:49:02.510",
"last_edit_date": "2018-07-11T05:49:02.510",
"last_editor_user_id": "21092",
"owner_user_id": "21092",
"parent_id": "45478",
"post_type": "answer",
"score": 1
}
] | 45478 | 45503 | 45481 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n #define MV_GRID_LENGTH 1\n #define MV_GRID_WIDTH 2\n \n @interface ViewController (){\n UIImageView *imageView[ MV_GRID_LENGTH * MV_GRID_WIDTH ];\n }\n \n - (void)viewDidLoad {\n int cnt = 0;\n \n for(int i=0; i<MV_GRID_LENGTH; i++){\n for(int j=0; i<MV_GRID_WIDTH;j++){\n imageView[cnt] = [UIImageView new];\n //処理中略\n \n [self.view addSubview:imageView[cnt]];\n cnt++;\n }\n }\n }\n \n```\n\n上記のようにimageViewを同時に複数生成するような処理において、imageViewの配列要素数が可変長になる場合、c言語では「UIImageView\n*imageView[];」のように表現すればよかったかと思いますが、objctive-\ncではどのように表現するのがよりよいのでしょうか。初歩的な質問で恐縮ですがよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T09:08:54.320",
"favorite_count": 0,
"id": "45480",
"last_activity_date": "2018-07-10T09:30:50.357",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28641",
"post_type": "question",
"score": 1,
"tags": [
"xcode",
"objective-c"
],
"title": "objective-cでの可変長配列について",
"view_count": 199
} | [
{
"body": "NSMutableArrayというオブジェクトを追加、削除できるクラスが標準で備わっています。 \nコードの動作は確認していませんが、 \n以下のような感じになります。\n\n```\n\n NSMutableArray<UIImageView*> *imageViewArray = [NSMutableArray<UIImageView*> array];\n \n for(int i=0; i<MV_GRID_LENGTH; i++)\n {\n for(int j=0; i<MV_GRID_WIDTH;j++)\n {\n [imageViewArray addObject:[UIImageView new]];\n //処理中略\n \n [self.view addSubview:[imageViewArray objectAtIndex:cnt];\n cnt++;\n }\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T09:30:50.357",
"id": "45482",
"last_activity_date": "2018-07-10T09:30:50.357",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17014",
"parent_id": "45480",
"post_type": "answer",
"score": 1
}
] | 45480 | null | 45482 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "アプリケーションから画像ファイルを保存するためには、Viewerを起動しなければなりません。 \nしかし、dockerの中からViewerを起動しても、出力先がないので、次のようにエラーになります。\n\nvtkXOpenGLRenderWindow (0xd7e860): bad X server connection.\nDISPLAY=/usr/local/bin/********: line 86: 30 Aborted (core dumped)\n\nエラーを起こさないためにはどうしたらよろしいでしょうか。 \n環境は、ローカル、Docker ともにubuntuです。\n\nよろしくお願いします。",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T10:05:06.940",
"favorite_count": 0,
"id": "45483",
"last_activity_date": "2018-07-12T16:00:38.813",
"last_edit_date": "2018-07-12T16:00:38.813",
"last_editor_user_id": "19110",
"owner_user_id": "29110",
"post_type": "question",
"score": 0,
"tags": [
"docker"
],
"title": "X serverにconnectionしないようにしたい",
"view_count": 559
} | [
{
"body": "アプリケーションがGUIであるなら、環境変数DISPLAYにはXサーバが起動しているマシンのIPアドレス(またはホスト名)を正しく設定する必要があります。 \nエラーメッセージに出ている`DISPLAY=/usr/local/bin/***`はなんらかのファイルのパスなので、明らかに間違っています。\n\n> vtkXOpenGLRenderWindow (0xd7e860): bad X server connection.\n> DISPLAY=/usr/local/bin/********: line 86: 30 Aborted (core dumped)\n\n具体的なアプリ名が出ていないので的外れになるかもしれませんが、エラーメッセージの一部でweb検索してみると以下の様なページが見つかりましたので参考までに。\n\n[[vtkusers] Rendering to images without X\n(Linux)?](https://www.vtk.org/pipermail/vtkusers/2010-August/062257.html) \n[VTK/Examples/Cxx/Utilities/OffScreenRendering -\nKitwarePublic](https://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/OffScreenRendering)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T06:10:04.590",
"id": "45504",
"last_activity_date": "2018-07-11T06:10:04.590",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "45483",
"post_type": "answer",
"score": 1
},
{
"body": "Viewerについては情報がないので、X Server に Connection しないようにする方法はわかりませんが、Docker ホストの\nX.orgサーバー上に表示されば良いんじゃないでしょうか。\n\nコンテナ実行時に 環境変数DISPLAYを指定して、ホストのX11プロトコルのソケットを -v オプションで指定してみてください。\n\n例)\n\n```\n\n # docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix viewer\n \n```\n\n上手く行けば XクライアントであるViewerが起動すると、Dockerホスト上のX.orgサーバーに接続され、GUIが Dockerホストの\n画面に表示されると思います。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T06:16:24.563",
"id": "45505",
"last_activity_date": "2018-07-11T06:16:24.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "45483",
"post_type": "answer",
"score": 1
}
] | 45483 | null | 45504 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Web画面にACCESSからSQL文で構成されたプルダウンリストが2つと、べた打ちで構成されたプルダウンリストを1つ作りました。そのプルダウンリストで選択したものを、データベースへ登録したいのですが、期待通りに動きません。 \n・ACCESSにある情報からSQLによってプルダウンリストを構成しているので、ACCESSの接続はできています。 \n・選択された3つを変数pstrItem1,pstrItem2,pstrItem3に入れています。それはプルダウンリストの3つを選択後、登録ボタンを押した後、「本当に以下の情報で登録しますか?」という画面で出力が確認できています。 \n例えですが、テーブル名が個人情報、フィールド3つが性別(pstrItem1)、年齢(pstrItem2)、住んでいる県(pstrItem3)とします。 \nテーブル名はTABLENAMEにほかの箇所で代入しています。 \nそれを踏まえて、以下のプログラムを見てください。\n\n```\n\n Sub Setsql_Insert()\n DbCon_SQL = \"INSERT INTO\" & TABLENAME & \"(\"\n DbCon_SQL = DbCon_SQL & \"性別,年齢,住んでいる県\"\n DbCon_SQL = DbCon_SQL & \")VALUES(\"\n DbCon_SQL = DbCon_SQL & com.Ex_SQLDecode(com.chrRep(pstrItem1))\n DbCon_SQL = DbCon_SQL & \",\" com.Ex_SQLDecode(com.chrRep(pstrItem2))\n DbCon_SQL = DbCon_SQL & \",\" com.Ex_SQLDecode(com.chrRep(pstrItem3))\n DbCon_SQL = DbCon_SQL & )\"\n \n```\n\nというSQLのインサート文を用いたものです。 \nこれを\n\n```\n\n Call Setsql_Insert()\n \n```\n\nで呼び出して登録させようとしていましたが、データベース(ACCESS)へは一向に登録できず。。。\n\n元々他の人が作ったプログラムを改善、アップデートという形で改良していて、私自身まだASPやSQLに関してあまり知識がない状態で作っているので、質問の内容も分からないかもしれませんが、宜しくお願いいたします。追加の説明など必要な情報があれば随時追加していくので、コメントの方宜しくお願いいたします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T15:01:48.320",
"favorite_count": 0,
"id": "45486",
"last_activity_date": "2018-07-10T15:57:14.773",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29247",
"post_type": "question",
"score": 0,
"tags": [
"untagged"
],
"title": "入力情報をデータベース(ACCESS)へ登録したい",
"view_count": 63
} | [
{
"body": "コードが正確ではないとのことですので、検討違いかもしれませんが、 \nDbCon_SQLの連結部分(5,6行目)は以下のように修正しないと、文字列の連結できません。 \n現在のSQLでエラーが発生していないか確認したほうが良いと思います。\n\n```\n\n DbCon_SQL = \"INSERT INTO\" & TABLENAME & \"(\"\n DbCon_SQL = DbCon_SQL & \"性別,年齢,住んでいる県\"\n DbCon_SQL = DbCon_SQL & \")VALUES(\"\n DbCon_SQL = DbCon_SQL & com.Ex_SQLDecode(com.chrRep(pstrItem1))\n DbCon_SQL = DbCon_SQL & \",\" & com.Ex_SQLDecode(com.chrRep(pstrItem2))\n DbCon_SQL = DbCon_SQL & \",\" & com.Ex_SQLDecode(com.chrRep(pstrItem3))\n DbCon_SQL = DbCon_SQL & )\"\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-10T15:57:14.773",
"id": "45487",
"last_activity_date": "2018-07-10T15:57:14.773",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45486",
"post_type": "answer",
"score": 0
}
] | 45486 | null | 45487 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[ニフティクラウドmobile backend レベルアップセミナー\nクーポン配信アプリを作ろう【Monaca編】の「お気に入り登録」](https://qiita.com/thuydg@github/items/caf3b3cb988bf76459ae#%E3%81%8A%E6%B0%97%E3%81%AB%E5%85%A5%E3%82%8A%E7%99%BB%E9%8C%B2%E6%A9%9F%E8%83%BD%E3%81%AE%E4%BD%9C%E6%88%90-1)で、Shop情報を以下のコードで取得しています。\n\n```\n\n //mBaaSにお気に入り登録されているShop情報を取得してリストに表示する\n function showFavorite() {\n \n //リストをリセットします。\n $(\"#listFavoriteShop\").empty();\n \n //表示名を指定します。\n $(\"#favorite_nickName\").text(currentLoginUser.nickname + \"のお気に入りショップ\");\n \n //お気に入り登録した値を取得\n var fav_shops = currentLoginUser.favorite;\n \n //ショップ一覧を表示\n for (var i = 0; i < shopArray.length; i++) {\n var shop = shopArray[i];\n var selectStr = \"selected='true'\";\n \n //ショップのお気に入りが登録された場合の表示\n var tmpStrOff = \"<div class='ui-field-contain'><label for='\" + shop.objectId + \"'>\" + shop.name + \"</label><select name='favorite_shop' id='\" + shop.objectId + \"' data-role='slider' data-theme='e' ><option value='off' \" + selectStr+ \">Off</option><option value='\" + shop.objectId + \"'>On</option></select></div>\";\n \n // //ショップのお気に入りが登録されていない場合の表示\n var tmpStrOn = \"<div class='ui-field-contain'><label for='\" + shop.objectId + \"'>\" + shop.name + \"</label><select name='favorite_shop' id='\" + shop.objectId + \"' data-role='slider' data-theme='e' ><option value='off'>Off</option><option value='\" + shop.objectId + \"' \" + selectStr+ \" >On</option></select></div>\";\n \n if ($.inArray(shop.objectId, fav_shops) == -1 ){\n $(\"#listFavoriteShop\").append(tmpStrOff);\n }else{\n $(\"#listFavoriteShop\").append(tmpStrOn);\n }\n }\n \n //Switchスライダーを更新\n $( \"select[name=favorite_shop]\" ).slider({\n defaults: true\n });\n $('select[name=favorite_shop]').slider('refresh');\n \n //画面遷移\n $.mobile.changePage('#FavoritePage');\n }\n \n```\n\n``` \nこのコードのままだと、nameの並び順を指定していないため、毎回、並び順が異なってしまいます。 \nついては、ショップの名前順で昇順に表示したいのですが、どのように記述すればよろしいしょうか。\n\nデータストアの表示画面 \n[](https://i.stack.imgur.com/0Z6uK.png)\n\n並び替えるコードとしてorderで指定することは公式ドキュメントに記載がありますが、どのように指定すればいいのかわからず、質問させていただきました。 \nよろしくお願いいたします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T02:22:36.517",
"favorite_count": 0,
"id": "45490",
"last_activity_date": "2020-08-05T12:00:30.063",
"last_edit_date": "2018-07-11T05:59:35.697",
"last_editor_user_id": null,
"owner_user_id": "29249",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"monaca"
],
"title": "monacaからmBaaSの値を取得した値を並び替える方法",
"view_count": 171
} | [
{
"body": "> ついては、ショップの名前順で昇順に表示したいのですが、どのように記述すればよろしいしょうか。\n\n## データストアの機能を利用する場合\n\nMonacaのデータストアは、`order`メソッドでソートできるようです。\n\n[app.js:211行目](https://github.com/ncmbadmin/MonacaAdvancePush/blob/full_version/www/js/app.js#L211)を以下に変更すればソートできると思います。\n\n```\n\n ShopClass.order(\"name\").fetchAll()\n \n```\n\n## JavaScriptの標準機能を使う場合\n\nオブジェクト配列は以下のようにソートできます。([参考:\nArray.prototype.sort()](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/sort))\n\n```\n\n shopArray = [{name: 'shopC'}, {name: 'shopB'}, {name: 'shopA'}];\n var sortedShopArray = shopArray.sort(function(a, b){\n if (a.name > b.name) {\n return 1;\n } else if (a.name === b.name) {\n return 0;\n } else {\n return -1;\n }\n })\n \n console.log(sorttedShopArray); // => [ { name: 'shopA' }, { name: 'shopB' }, { name: 'shopC' } ]\n \n```\n\nそのため、以下のように先にショップ一覧をソートしてから処理すれば良いと思います。\n\n```\n\n // ショップ一覧をソート\n var sortedShopArray = shopArray.sort(function(a, b){\n if (a.name > b.name) {\n return 1;\n } else if (a.name === b.name) {\n return 0;\n } else {\n return -1;\n }\n });\n // ショップ一覧を表示\n for (var i = 0; i < sortedShopArray.length; i++) {\n var shop = sortedShopArray[i];\n // 以下、略\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T04:39:46.133",
"id": "45493",
"last_activity_date": "2018-07-11T07:36:27.633",
"last_edit_date": "2018-07-11T07:36:27.633",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45490",
"post_type": "answer",
"score": 0
}
] | 45490 | null | 45493 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、Windows上でRuby on\nRailsを起動しようとしているのですが、以下の様なエラーが出てしまいました。どなたか同じエラーに遭遇した方で対処方法をご存知の方はお教え頂けないでしょうか?\n\n実行した環境は以下のとおりです。\n\nOS: Windows 10 Pro \nRuby:ruby 2.2.6p396 (2016-11-15 revision 56800) \nRails:Rails 5.0.7\n\n```\n\n Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`>\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.7/lib/rails/application.rb:513:in `validate_secret_key_config!'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.7/lib/rails/application.rb:246:in `env_config'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.7/lib/rails/engine.rb:693:in `build_request'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.7/lib/rails/application.rb:521:in `build_request'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/railties-5.0.7/lib/rails/engine.rb:521:in `call'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/puma-3.11.4/lib/puma/configuration.rb:225:in `call'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/puma-3.11.4/lib/puma/server.rb:632:in `handle_request'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/puma-3.11.4/lib/puma/server.rb:446:in `process_client'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/puma-3.11.4/lib/puma/server.rb:306:in `block in run'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/puma-3.11.4/lib/puma/thread_pool.rb:120:in `call'\n C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/puma-3.11.4/lib/puma/thread_pool.rb:120:in `block in spawn_thread'\n \n```\n\nちなみに、以下の事はトライしましたが上手く行きませんでした。\n\n・config/secrets.ymlのproductionの部分の\"secret_key_base\"に、\"bundle exec rake\nsecret\"で表示された英数字の列を記載して再実行。\n\n追記: \n'rail s -e production'実行後にページリロードした後のproduction.logの内容:\n\n```\n\n I, [2018-07-14T07:37:40.076104 #11580] INFO -- : [77252a09-038f-4973-8812-a486d9664c2b] Started GET \"/\" for 127.0.0.1 at 2018-07-14 07:37:40 +0900\n F, [2018-07-14T07:37:40.078138 #11580] FATAL -- : [77252a09-038f-4973-8812-a486d9664c2b] \n F, [2018-07-14T07:37:40.078138 #11580] FATAL -- : [77252a09-038f-4973-8812-a486d9664c2b] ActionController::RoutingError (No route matches [GET] \"/\"):\n F, [2018-07-14T07:37:40.078138 #11580] FATAL -- : [77252a09-038f-4973-8812-a486d9664c2b] \n F, [2018-07-14T07:37:40.079125 #11580] FATAL -- : [77252a09-038f-4973-8812-a486d9664c2b] actionpack (5.0.7) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] actionpack (5.0.7) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] railties (5.0.7) lib/rails/rack/logger.rb:36:in `call_app'\n [77252a09-038f-4973-8812-a486d9664c2b] railties (5.0.7) lib/rails/rack/logger.rb:24:in `block in call'\n [77252a09-038f-4973-8812-a486d9664c2b] activesupport (5.0.7) lib/active_support/tagged_logging.rb:69:in `block in tagged'\n [77252a09-038f-4973-8812-a486d9664c2b] activesupport (5.0.7) lib/active_support/tagged_logging.rb:26:in `tagged'\n [77252a09-038f-4973-8812-a486d9664c2b] activesupport (5.0.7) lib/active_support/tagged_logging.rb:69:in `tagged'\n [77252a09-038f-4973-8812-a486d9664c2b] railties (5.0.7) lib/rails/rack/logger.rb:24:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] actionpack (5.0.7) lib/action_dispatch/middleware/request_id.rb:24:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] rack (2.0.5) lib/rack/method_override.rb:22:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] rack (2.0.5) lib/rack/runtime.rb:22:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] activesupport (5.0.7) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] actionpack (5.0.7) lib/action_dispatch/middleware/executor.rb:12:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] rack (2.0.5) lib/rack/sendfile.rb:111:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] railties (5.0.7) lib/rails/engine.rb:522:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] puma (3.11.4) lib/puma/configuration.rb:225:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] puma (3.11.4) lib/puma/server.rb:632:in `handle_request'\n [77252a09-038f-4973-8812-a486d9664c2b] puma (3.11.4) lib/puma/server.rb:446:in `process_client'\n [77252a09-038f-4973-8812-a486d9664c2b] puma (3.11.4) lib/puma/server.rb:306:in `block in run'\n [77252a09-038f-4973-8812-a486d9664c2b] puma (3.11.4) lib/puma/thread_pool.rb:120:in `call'\n [77252a09-038f-4973-8812-a486d9664c2b] puma (3.11.4) lib/puma/thread_pool.rb:120:in `block in spawn_thread'\n \n```\n\n・'rails routes'の実行結果\n\n```\n\n You don't have any routes defined!\n \n Please add some routes in config/routes.rb.\n \n For more information about routes, see the Rails guide: http://guides.rubyonrails.org/routing.html.\n \n```",
"comment_count": 12,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T02:38:41.870",
"favorite_count": 0,
"id": "45491",
"last_activity_date": "2018-07-16T01:14:54.653",
"last_edit_date": "2018-07-16T01:14:54.653",
"last_editor_user_id": "19869",
"owner_user_id": "19869",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails"
],
"title": "Ruby on Railsの起動でsecret_key_baseの設定が上手く行かず悩んでいます",
"view_count": 559
} | [] | 45491 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "現在、 Python 環境上で次のようにして Axes3D を利用しています。\n\n```\n\n from mpl_toolkits.mplot3d import Axes3D\n import matplotlib.pyplot as plt\n \n```\n\nところが、この Axes3D は座標軸の座標目盛間隔を自動的に決めてしまうので、表示されたものの形が変わってしまいます。\n\nそこで、 Axes3D は座標軸の座標目盛間隔を等間隔にしたいと思っています。 \nどうすればよろしいでしょうか。\n\nよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T02:39:18.767",
"favorite_count": 0,
"id": "45492",
"last_activity_date": "2022-10-19T11:04:05.470",
"last_edit_date": "2019-05-04T22:05:09.457",
"last_editor_user_id": "32986",
"owner_user_id": "27992",
"post_type": "question",
"score": 1,
"tags": [
"python",
"matplotlib"
],
"title": "Axes3Dの座標軸を等間隔にしたい",
"view_count": 1280
} | [
{
"body": "Qiitaの\n[matplotlibで3次元プロットする際に3軸のスケールを揃える](https://qiita.com/ae14watanabe/items/71f678755525d8088849)\nの記事が参考にしてはどうでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-05-05T00:46:13.460",
"id": "54727",
"last_activity_date": "2019-05-05T00:46:13.460",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "45492",
"post_type": "answer",
"score": 1
}
] | 45492 | null | 54727 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "2つのエクセルファイルがあり、入っている値は以下の通り。\n\n1) パーツ番号、 Yes/No、 Exemption番号 \n2) パーツ番号\n\n2)のパーツ番号と、1)のパーツ番号が一致したら、2)のファイルに、 Yes/No, \nExemption 番号を記入するということをPython で行おうとしています。\n\n作業 \n1)のファイルから辞書を作り、pyファイルとして保存. \nこのファイルの中身と 2)のパーツ番号が一致するものがあったら、Yes/No, Exemption番号を2)の \n指定セルに記入する。\n\nそもそもこのようなことが可能なのか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T04:39:48.573",
"favorite_count": 0,
"id": "45494",
"last_activity_date": "2018-07-11T05:27:33.740",
"last_edit_date": "2018-07-11T05:27:33.740",
"last_editor_user_id": "3060",
"owner_user_id": "29242",
"post_type": "question",
"score": 0,
"tags": [
"python",
"excel"
],
"title": "Pythonからエクセルシートの値を参照、編集したい",
"view_count": 274
} | [
{
"body": "> そもそもこのようなことが可能なのか?\n\n可能だと思います。\n\n[openpyxl](https://openpyxl.readthedocs.io/en/stable/)\nなど、Excel操作用のパッケージがあるので、それらを利用すればできると思います。(参考: [Python\nopenpyxlでExcelを操作](https://qiita.com/tftf/items/07e4332293c2c59799d1))",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T04:47:23.883",
"id": "45495",
"last_activity_date": "2018-07-11T04:47:23.883",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45494",
"post_type": "answer",
"score": 3
}
] | 45494 | null | 45495 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "interface を 使用 した class を取得したい\n\n```\n\n public interface IExtension {\n String getName();\n \n String getVersion();\n }\n \n public class AExtension implements IExtension {\n \n @Override\n public String getName() {\n return \"A\";\n }\n \n @Override\n public String getVersion() {\n return \"1.0.0\";\n }\n }\n \n public class BExtension implements IExtension {\n \n @Override\n public String getName() {\n return \"B\";\n }\n \n @Override\n public String getVersion() {\n return \"1.0.0\";\n }\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T05:06:53.673",
"favorite_count": 0,
"id": "45497",
"last_activity_date": "2018-07-11T05:36:16.960",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29254",
"post_type": "question",
"score": 1,
"tags": [
"java"
],
"title": "Java: interface を implements した class を 探す方法",
"view_count": 2519
} | [
{
"body": "`implements IExtension`のキーワードでソースディレクトリをgrepするか、IDEの検索機能(Type\nHierarchyなど)を利用すればいいと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T05:27:59.797",
"id": "45499",
"last_activity_date": "2018-07-11T05:27:59.797",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "45497",
"post_type": "answer",
"score": 0
},
{
"body": "Javaの実行時に\nという意味だと、[reflections](https://github.com/ronmamo/reflections)のgetSubTypesOfメソッドを使って取得する方法があります。\n\n```\n\n package com.detect.subclasses;\n \n import org.reflections.Reflections;\n import org.testng.annotations.Test;\n \n import java.util.Set;\n \n public class DetectSubClassesTest {\n \n @Test\n public void getSubclasses() {\n Set<Class<? extends IExtension>> subTypes =\n new Reflections(\"com.detect.subclasses\").getSubTypesOf(IExtension.class);\n \n assert subTypes.size() == 2;\n \n subTypes.forEach(System.out::println);\n }\n \n public interface IExtension {\n String getName();\n \n String getVersion();\n }\n \n public static class AExtension implements IExtension {\n \n @Override\n public String getName() {\n return \"A\";\n }\n \n @Override\n public String getVersion() {\n return \"1.0.0\";\n }\n }\n \n public static class BExtension implements IExtension {\n \n @Override\n public String getName() {\n return \"B\";\n }\n \n @Override\n public String getVersion() {\n return \"1.0.0\";\n }\n }\n }\n \n```\n\nResult:\n\n```\n\n class com.detect.subclasses.DetectSubClassesTest$AExtension\n class com.detect.subclasses.DetectSubClassesTest$BExtension\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T05:30:16.550",
"id": "45501",
"last_activity_date": "2018-07-11T05:30:16.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24823",
"parent_id": "45497",
"post_type": "answer",
"score": 2
}
] | 45497 | null | 45501 |
{
"accepted_answer_id": "45500",
"answer_count": 2,
"body": "[](https://i.stack.imgur.com/b82Se.jpg)Javaを使ってMicrosoftのAzureでComputer\nVision\nAPIを利用したいと思っています。eclipseで書いているのですが、一つだけ解決できないエラーがあります。Azureのページに載っているクイックスタートのサンプルコードです。\n\nどなたかご教授願います。 \n[](https://i.stack.imgur.com/kvIVB.jpg)\n\n```\n\n // - Apache HTTP client (org.apache.httpcomponents:httpclient:4.5.5)\n // - Apache HTTP core (org.apache.httpcomponents:httpccore:4.4.9)\n // - JSON library (org.json:json:20180130).\n \n import java.net.URI;\n \n import org.apache.http.HttpEntity;\n import org.apache.http.HttpResponse;\n import org.apache.http.client.methods.HttpPost;\n import org.apache.http.client.utils.URIBuilder;\n import org.apache.http.entity.StringEntity;\n import org.apache.http.impl.client.CloseableHttpClient;\n import org.apache.http.impl.client.HttpClientBuilder;\n import org.apache.http.util.EntityUtils;\n import org.json.JSONObject;\n \n public class Main {\n // **********************************************\n // *** Update or verify the following values. ***\n // **********************************************\n \n // Replace <Subscription Key> with your valid subscription key.\n private static final String subscriptionKey = \"******************************\";\n \n // You must use the same region in your REST call as you used to get your\n // subscription keys. For example, if you got your subscription keys from\n // westus, replace \"westcentralus\" in the URI below with \"westus\".\n //\n // Free trial subscription keys are generated in the westcentralus region. If you\n // use a free trial subscription key, you shouldn't need to change this region.\n private static final String uriBase =\n \"https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/analyze\";\n \n private static final String imageToAnalyze =\n \"https://upload.wikimedia.org/wikipedia/commons/\" +\n \"1/12/Broadway_and_Times_Square_by_night.jpg\";\n \n public static void main(String[] args) {\n CloseableHttpClient httpClient = HttpClientBuilder.create().build();\n \n try {\n URIBuilder builder = new URIBuilder(uriBase);\n \n // Request parameters. All of them are optional.\n builder.setParameter(\"visualFeatures\", \"Categories,Description,Color\");\n builder.setParameter(\"language\", \"en\");\n \n // Prepare the URI for the REST API call.\n URI uri = builder.build();\n HttpPost request = new HttpPost(uri);\n \n // Request headers.\n request.setHeader(\"Content-Type\", \"application/json\");\n request.setHeader(\"Ocp-Apim-Subscription-Key\", subscriptionKey);\n \n // Request body.\n StringEntity requestEntity =\n new StringEntity(\"{\\\"url\\\":\\\"\" + imageToAnalyze + \"\\\"}\");\n request.setEntity(requestEntity);\n \n // Make the REST API call and get the response entity.\n HttpResponse response = httpClient.execute(request);\n HttpEntity entity = response.getEntity();\n \n if (entity != null) {\n // Format and display the JSON response.\n String jsonString = EntityUtils.toString(entity);\n JSONObject json = new JSONObject(jsonString);\n System.out.println(\"REST Response:\\n\");\n System.out.println(json.toString(2));\n }\n } catch (Exception e) {\n // Display error message.\n System.out.println(e.getMessage());\n }\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T05:07:41.953",
"favorite_count": 0,
"id": "45498",
"last_activity_date": "2018-07-11T11:03:59.867",
"last_edit_date": "2018-07-11T05:53:56.547",
"last_editor_user_id": "29253",
"owner_user_id": "29253",
"post_type": "question",
"score": 1,
"tags": [
"java",
"eclipse",
"api",
"azure"
],
"title": "Java AzureのAPIを利用したプログラムのエラー",
"view_count": 278
} | [
{
"body": "以下のライブラリーをビルドパスに含めていないのでは。\n\n * Apache HTTP client (org.apache.httpcomponents:httpclient:4.5.5)\n * Apache HTTP core (org.apache.httpcomponents:httpccore:4.4.9)\n * JSON library (org.json:json:20180130).",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T05:29:56.787",
"id": "45500",
"last_activity_date": "2018-07-11T05:42:30.750",
"last_edit_date": "2018-07-11T05:42:30.750",
"last_editor_user_id": "21092",
"owner_user_id": "21092",
"parent_id": "45498",
"post_type": "answer",
"score": 0
},
{
"body": "環境は違いますが、僕の環境では動きました。 \nですが、\n\n> org.apache.httpcomponents:httpclient:4.5.5 \n> org.apache.httpcomponents:httpccore:4.4.9 \n> org.json:json:20180130\n\nの他に \n[commons-logging](https://mvnrepository.com/artifact/commons-logging/commons-\nlogging/1.1.1)をclass passに含める必要がありました。(僕は1.1.1を使いました)\n\ncommons-loggingがない場合は僕の環境では以下のエラーがありました。\n\n> Exception in thread \"main\" java.lang.NoClassDefFoundError:\n> org/apache/commons/logging/LogFactory \n> at\n> org.apache.http.conn.ssl.DefaultHostnameVerifier.(DefaultHostnameVerifier.java:82) \n> at\n> org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:955) \n> at Main.main(Main.java:35) \n> Caused by: java.lang.ClassNotFoundException:\n> org.apache.commons.logging.LogFactory \n> at java.net.URLClassLoader.findClass(URLClassLoader.java:381) \n> at java.lang.ClassLoader.loadClass(ClassLoader.java:424) \n> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) \n> at java.lang.ClassLoader.loadClass(ClassLoader.java:357) \n> ... 3 more",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T11:03:59.867",
"id": "45510",
"last_activity_date": "2018-07-11T11:03:59.867",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24823",
"parent_id": "45498",
"post_type": "answer",
"score": 0
}
] | 45498 | 45500 | 45500 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "深層学習においてRGB値などで画像を入力した場合、色情報に関する特徴抽出は第1層でしか行われないと思います。しかし、白黒画像から色画像の生成などができています。この点について知見がある方いましたら、教えていただけると幸いです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T08:25:43.200",
"favorite_count": 0,
"id": "45506",
"last_activity_date": "2019-02-07T03:01:50.213",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29259",
"post_type": "question",
"score": 0,
"tags": [
"python",
"深層学習"
],
"title": "深層学習における色の学習はされているのでしょうか?",
"view_count": 455
} | [
{
"body": "深層学習モデルはただ入力された数字のみを見て積和演算を行なっています。 \n白黒(1チャンネル)をRGB(3チャンネル)に拡張する際、どのチャンネルのどの位置ににどれだけの数値を配置すれば正解との乖離が少なくなるかを突き詰めていきます。ですので、第何層でどのような特徴量を抽出しているかはブラックボックスです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-08-27T02:03:53.960",
"id": "47834",
"last_activity_date": "2018-08-27T02:03:53.960",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29873",
"parent_id": "45506",
"post_type": "answer",
"score": 1
}
] | 45506 | null | 47834 |
{
"accepted_answer_id": "45513",
"answer_count": 1,
"body": "Firebase Hostingでサイトをデプロイした後で、\n\n * 公開してはならないファイルをデプロイしていないかどうか確認したい\n * 手元にあるプロジェクトファイルとデプロイ済みのファイルが一致するか確認したい\n\nなどの理由で、現在ホスティングされているファイルを確認したいことがあると思うのですが、どのようにすればよいでしょうか。 \nHostingのダッシュボード画面を見ても、デプロイしたファイル数しか分からないように見えるのですが……",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T10:54:02.040",
"favorite_count": 0,
"id": "45509",
"last_activity_date": "2018-07-11T11:33:22.403",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29263",
"post_type": "question",
"score": 0,
"tags": [
"firebase"
],
"title": "Firebase Hostingでデプロイしたファイルを確認したい",
"view_count": 2270
} | [
{
"body": "確認する機能はないかと思います. \n現状を再度デプロイしちゃうのが一番確実かと. \n \nどうしても確認したいのであれば,ファイル数を数えるか,あるいは, \n前もって `firebase deploy -m 'hogehoge'`\nでgitなどと合わせたコメントを入れておくと,ウェブコンソールからも確認できていいかもしれません. \n \nまた,公開してはならないファイルは,前もって除外を( `firebase.json` で指定)しておきましょう. \n<https://firebase.google.com/docs/hosting/deploying#section-firebase-json>",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T11:33:22.403",
"id": "45513",
"last_activity_date": "2018-07-11T11:33:22.403",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5273",
"parent_id": "45509",
"post_type": "answer",
"score": 0
}
] | 45509 | 45513 | 45513 |
{
"accepted_answer_id": "45541",
"answer_count": 2,
"body": "aaaとbbbという2つのリポジトリがあり,これらを統合して1つの新しいリポジトリとして下記のように管理したいと考えています.\n\n```\n\n new-repo\n ├.git\n ├aaa\n └bbb\n \n```\n\naaaとbbbの歴史も残しつつ,new-repoとして新しく統合したリポジトリを作る方法として,どういう方法があるでしょうか? \n歴史を残すというのは,例えばnew-repoの直下で `git log` したときにaaaとbbbの歴史が同時に見れるようにしたい,ということです.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T11:16:43.747",
"favorite_count": 0,
"id": "45511",
"last_activity_date": "2018-07-12T03:16:47.793",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29260",
"post_type": "question",
"score": 2,
"tags": [
"git"
],
"title": "2つのrepositoryを新しいrepositoryのサブディレクトリにして管理したい",
"view_count": 954
} | [
{
"body": "こんな感じでできると思います。\n\nnew-repo を作成:\n\n```\n\n % mkdir new-repo\n % cd new-repo\n % git init\n % git commit -m 'Initial commit' --allow-empty\n \n```\n\naaa リポジトリをリモートリポジトリとして追加して、ブランチとして作成、ディレクトリに移動:\n\n```\n\n % git remote add aaa <aaaリポジトリ>\n % git fetch aaa\n % git checkout -b aaa aaa/master\n % mkdir aaa\n % mv * aaa\n % git add .\n % git commit -m 'directory aaa'\n \n```\n\nbbb リポジトリも同様にして、その後 aaa と bbb を master にマージ:\n\n```\n\n % git checkout master\n % git merge --allow-unrelated-histories aaa\n % git merge --allow-unrelated-histories bbb\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T15:03:47.067",
"id": "45520",
"last_activity_date": "2018-07-11T15:03:47.067",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3249",
"parent_id": "45511",
"post_type": "answer",
"score": 0
},
{
"body": "git subtree を使うと他のリポジトリの歴史を保ったまま、サブディレクトリとしてマージできます。 新しくリポジトリを作成し、そこで aaa と\nbbb をそれぞれ subtree add してやればできると思います。\n\ngit subtree add は、 <https://ja.stackoverflow.com/a/44470/754> などを参考するといいかもです。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T03:16:47.793",
"id": "45541",
"last_activity_date": "2018-07-12T03:16:47.793",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "45511",
"post_type": "answer",
"score": 3
}
] | 45511 | 45541 | 45541 |
{
"accepted_answer_id": "45530",
"answer_count": 2,
"body": "現在、`target`というlist型データの中に、50個のstr型データが格納されています。 \nこの50個のデータにそれぞれ `data1, data2...` と名前をつけていきたいのですが、 \n皆様でしたらどのようにされるでしょうか? \n初歩的な質問で大変恐縮ですが、ご教示いただけましたら幸いです。\n\nご回答いただきありがとうございます。 \n何故そうしたいかというと、list内のテキストのcos類似度をそれぞれ比較した表を作成したいからです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T11:35:15.580",
"favorite_count": 0,
"id": "45514",
"last_activity_date": "2018-07-14T05:44:59.717",
"last_edit_date": "2018-07-14T05:44:59.717",
"last_editor_user_id": "27030",
"owner_user_id": "27030",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "pythonでリストの要素にそれぞれ変数をつけたい",
"view_count": 3174
} | [
{
"body": "配列のまま使うのが通常は便利ですが、特に必要があればグローバル変数を`globals()`を使って次のように作成できます。\n\n```\n\n g = globals()\n for i, v in enumerate(target):\n g[\"data\" + str(i+1)] = v\n \n```\n\nローカル変数の場合は同じように`locals()`があって、値の取得には使えるのですが、変数の作成や変更することには使えません。ローカル変数をどうしても作成する必要があるのであれば次のようにして変数を作成できます。\n\n```\n\n for i, v in enumerate(target):\n exec('data' + str(i+1) + ' = \"' + v + '\"')\n \n```\n\nデータサイエンスで使用するのであれば、Pandasを使ったほうが便利です。例えば、次のようにインデックスに名前をつけておけばいいです。`sr['data1']`又は`sr.data1`でアクセスできるし、Pandasの機能も`sr[3:4]`のようにすべて使えるので後の処理で活用しやすいです。\n\n```\n\n sr = pd.Series(target)\n sr.index = ['data' + str(i + 1) for i in range(len(target))]\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T01:11:25.963",
"id": "45530",
"last_activity_date": "2018-07-12T02:28:55.233",
"last_edit_date": "2018-07-12T02:28:55.233",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "45514",
"post_type": "answer",
"score": 2
},
{
"body": "> 何故そうしたいかというと、list内のテキストのcos類似度をそれぞれ比較した表を作成したいからです。\n\nこれは、二次元配列を作って実現する方が見通しが良いと思います。\n\n`target` という一次元配列に 50 個のテキストが入っているとのことですので、テキスト 2\nつ同士の組み合わせを表す二次元配列を作れば良いです。二次元配列なので 2 つ添字が与えられるわけですが、1 つ目の添字に対応するテキストと 2\nつ目の添字に対応するテキストのコサイン類似度を保存していく、というわけです。\n\nこの仕組みはご自身で実装なさっても良いですし、Pandas をお使いなのであれば\n`sklearn.metrics.pairwise.cosine_similarity`\nを使うと[一発でできます。](https://stackoverflow.com/a/45393239/5989200)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T15:55:26.787",
"id": "45561",
"last_activity_date": "2018-07-12T15:55:26.787",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "45514",
"post_type": "answer",
"score": 2
}
] | 45514 | 45530 | 45530 |
{
"accepted_answer_id": "45516",
"answer_count": 1,
"body": "databaseデータベースに登録されているデータを配列にする方法を教えてください。\n\n適当に作った配列は問題なく動作します。\n\n```\n\n String[] array = {\"abc_1\",\"abc_2\",\"abc_3\",\"abc_1\",\"abc_5\",\"abc_4\"};\n for(int i = 0; i<6; i++){\n .....array[i]....\n }\n \n```\n\n<https://stackoverflow.com/questions/4042434/converting-arrayliststring-to-\nstring-in-java> \nを参考に下を試しましたがデータは反映されません。\n\n```\n\n ArrayList<String> list = new ArrayList<String>();\n Cursor cursor= database.rawQuery(\"select * from tbl_abc\", null);\n while (cursor.moveToNext()) {\n abc_num = cursor.getString(4);\n list.add(abc_num);\n }\n \n String[] array = list.toArray(new String[list.size()]);\n for (int i = 0; i < array.length; i++) {\n array[i] = list.get(i);\n .....array[i]....\n }\n \n```\n\n対処法、お願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T11:38:46.723",
"favorite_count": 0,
"id": "45515",
"last_activity_date": "2018-07-12T08:28:02.360",
"last_edit_date": "2018-07-12T08:28:02.360",
"last_editor_user_id": "29281",
"owner_user_id": "29165",
"post_type": "question",
"score": 1,
"tags": [
"android",
"java",
"database",
"array"
],
"title": "データベースに登録されているデータを配列にする",
"view_count": 1023
} | [
{
"body": "問題の切り分けのために、 \n以下のコードの直前に、`list.size()`をログ出力してはどうでしょうか? \nこの時点で`list`の要素が0件であれば、以降の操作が行なわれません。\n\n```\n\n String[] array = list.toArray(new String[list.size()]);\n \n```\n\nまた、`list`の要素に`\"a\", \"b\", \"c\"`と設定されている場合、上記のコードの結果、取得される`array`の内容も`\"a\", \"b\",\n\"c\"`となっているはずです。 \nそのため、for文の中で、再度、`array[i] = list.get(i)`する必要はありません。\n\n```\n\n for (int i = 0; i < array.length; i++) {\n array[i] = list.get(i);\n \n .....array[i]....\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T11:57:37.723",
"id": "45516",
"last_activity_date": "2018-07-11T11:57:37.723",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45515",
"post_type": "answer",
"score": 0
}
] | 45515 | 45516 | 45516 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "Windows C#で次のようなコードを書いた場合に、以下の点がわかりません。\n\n```\n\n System.IO.DriveInfo drive = new System.IO.DriveInfo(\"Z\");\n if (drive.IsReady)\n {\n string s;\n s = string.Format(\"{0:f1} GB/{1:f1} GB\", drive.TotalFreeSpace/1024 / 1024 / 1024, drive.TotalSize / 1024 / 1024 / 1024);\n // 以下略\n }\n \n```\n\nこれを1秒おきに実行した際\n\n 1. どのようにして情報が取得されるのか(ディスクに都度アクセスするのか)\n 2. アクセスするとした場合、寿命に影響があるのか\n 3. 実際にどのようにして値を取得しているかを調べる方法があるのか\n 4. 1秒おきに取得する方法以外の手段はあるのか\n 5. このコードの問題点があれば教えてください",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T12:38:34.040",
"favorite_count": 0,
"id": "45517",
"last_activity_date": "2018-07-12T00:03:37.627",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29124",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"windows"
],
"title": "System.IO.DriveInfoでの値の取得について",
"view_count": 751
} | [
{
"body": "> 実際にどのようにして値を取得しているかを調べる方法があるのか\n\nSystem.IO.DriveInfoの実装については、[driveinfo.cs](https://referencesource.microsoft.com/#mscorlib/system/io/driveinfo.cs,167)でわかります。 \n`TotalFreeSpace`や`TotalSize`はWindows\nAPIの[GetDiskFreeSpaceEx](https://msdn.microsoft.com/ja-\njp/library/cc429308.aspx)を仕様しているようです。\n\n`GetDiskFreeSpaceEx`がどのように情報を取得しているかは、APIのドキュメントからはわかりませんでした。詳細は\nMicrosoftのサポートに問いあわせると回答が得れるかもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T12:55:22.557",
"id": "45519",
"last_activity_date": "2018-07-11T12:55:22.557",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45517",
"post_type": "answer",
"score": 1
},
{
"body": "> 1秒おきに取得する方法以外の手段はあるのか\n\n取得する目的は何でしょう? USB メモリや SD\nカードの着脱検出?ネットワークドライブの接続切断検出?ディスク容量の残量チェック?それ次第で別の提案ができるかもしれません。\n\n接続済み USB メモリの容量チェックを1秒おきに行うってことは「安全に取り外し」メニューも満足に使えませんし UX\n面では最低です。オイラならこういうコードを書くことは絶対にしないと思います。\n\nドライブ名自体の着脱検出なら `WM_DEVICECHANGE` をハンドルしてそのときのドライブ情報を得れば十分。 \n<http://d.hatena.ne.jp/ohyajapan/20081123/p1>\n\nドライブ内に CD/DVD/BLURAY メディアが着脱されたかも `WM_DEVICECHANGE` で可能 \n<https://support.microsoft.com/ja-jp/help/163503/how-to-receive-notification-\nof-cd-rom-insertion-or-removal>\n\nその他なら「なぜ、なにをやりたい」のかを元質問の編集で付け加えてもらうと別回答が付くかもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T00:03:37.627",
"id": "45527",
"last_activity_date": "2018-07-12T00:03:37.627",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "45517",
"post_type": "answer",
"score": 0
}
] | 45517 | null | 45519 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "PythonにてOHLC形式でリサンプリングしたく、以下のコードを記述しましたが、AttributeErrorとなってしまいます。 \n何が悪いかわかる方はいらっしゃいますでしょうか。\n\nなお実行環境はAzureMLのPythonScriptです。\n\nソース:\n\n```\n\n import pandas as pd\n \n dataframe1['Time'] = pd.to_datetime(dataframe1['Time'], unit='s')\n dataframe1.index = dataframe1['Time']\n x = dataframe1.resample('H').ohlc()\n \n```\n\ndataframe1:\n\n```\n\n Time Open High Low Close \n 20170102 020100 116.875 116.915 116.875 116.901 \n 20170102 020200 116.901 116.901 116.901 116.901 \n 20170102 020300 116.901 116.906 116.897 116.900 \n \n```\n\nエラーメッセージ:\n\n```\n\n Error 0085: The following error occurred during script evaluation, please view the output log for more information:\n ---------- Start of error message from Python interpreter ----------\n Caught exception while executing function: Traceback (most recent call last):\n File \"C:\\server\\invokepy.py\", line 199, in batch\n odfs = mod.azureml_main(*idfs)\n File \"C:\\temp\\16dad51ce7994c25aa02a0a388e26709.py\", line 44, in azureml_main\n x = dataframe1.resample('H').ohlc()\n File \"C:\\pyhome\\lib\\site-packages\\pandas\\core\\generic.py\", line 1843, in __getattr__\n (type(self).__name__, name))\n AttributeError: 'DataFrame' object has no attribute 'ohlc'\n Process returned with non-zero exit code 1\n \n ---------- End of error message from Python interpreter ----------\n \n```\n\n以上です。 \nよろしくお願いします。\n\n### 7/17追記\n\nmagichanさんご回答ありがとうございます。 \nおっしゃる通り、すでにOHLC形式になっていますね... \n目的の説明が間違っておりました。正しくは「OHLC形式のデータをリサンプリングしたい」です。 \n教えていただいたソースを以下のように試してみましたが、同じようなエラーが出てしまいます。\n\n```\n\n import pandas as pd\n \n dataframe1['Time'] = pd.to_datetime(dataframe1['Time'], unit='s')\n dataframe1.index = dataframe1['Time']\n x = dataframe1.resample('H').ohlc()\n \n```\n\n```\n\n Error 0085: The following error occurred during script evaluation, please view the output log for more information:\n ---------- Start of error message from Python interpreter ----------\n Caught exception while executing function: Traceback (most recent call last):\n File \"C:\\server\\invokepy.py\", line 199, in batch\n odfs = mod.azureml_main(*idfs)\n File \"C:\\temp\\4cf09401e1994ec1a2112e2d81ef4ff3.py\", line 49, in azureml_main\n x = dataframe1.resample('H').agg({\n File \"C:\\pyhome\\lib\\site-packages\\pandas\\core\\generic.py\", line 1843, in __getattr__\n (type(self).__name__, name))\n AttributeError: 'DataFrame' object has no attribute 'agg'\n Process returned with non-zero exit code 1\n \n```\n\nもしかして文法うんぬんというより実行環境が悪いのでしょうか...",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T12:47:55.490",
"favorite_count": 0,
"id": "45518",
"last_activity_date": "2019-03-22T04:57:04.977",
"last_edit_date": "2018-07-17T14:46:33.623",
"last_editor_user_id": "19110",
"owner_user_id": "29264",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pandas",
"azure"
],
"title": "resample('H').ohlc()でAttributeError",
"view_count": 269
} | [
{
"body": "dataframe1は既に **OHLC形式** になっているように見えますが・・。\n\n既に **OHLC形式** のデータを _Resample_ したいというのであれば、\n\n```\n\n x = dataframe1.resample('H').agg({\n 'Open': 'first',\n 'High': 'max',\n 'Low': 'min',\n 'Close': 'last'})\n \n```\n\nのようになるのではないでしょうか。\n\n* * *\n\n**【追記】** \nそのままで動作する動作サンプルコードをあげておきます。 \n動作を確認してみてください。\n\n```\n\n import pandas as pd\n import io\n \n data = \"\"\"\n Time,Open,High,Low,Close\n 20170102 020100,116.875,116.915,116.875,116.901\n 20170102 020200,116.901,116.901,116.901,116.901\n 20170102 020300,116.901,116.906,116.897,116.900\n \"\"\"\n \n dataframe1 = pd.read_csv(io.StringIO(data), parse_dates=['Time'], index_col='Time')\n res = dataframe1.resample('H').agg({\n 'Open': 'first',\n 'High': 'max',\n 'Low': 'min',\n 'Close': 'last'})\n \n print(res)\n # Low High Open Close\n #Time\n #2017-01-02 02:00:00 116.875 116.915 116.875 116.9\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T01:45:34.437",
"id": "45533",
"last_activity_date": "2018-07-18T02:18:19.647",
"last_edit_date": "2018-07-18T02:18:19.647",
"last_editor_user_id": "24801",
"owner_user_id": "24801",
"parent_id": "45518",
"post_type": "answer",
"score": 1
}
] | 45518 | null | 45533 |
{
"accepted_answer_id": "45523",
"answer_count": 2,
"body": "あるコードを実行したくて、変数の取得方法がわからなかったのでので簡易化したコードで質問します。 \n参考書を見て、「global変数を使うことで、関数内からグローバル変数にアクセスできる」」ということは理解しているのですが、\n\n```\n\n def f(x):\n global y\n y=x+2\n return x+2\n \n x=2\n print(y)\n >>4\n #誤ったコードです。実行されません。(イメージ的にこうなってほしい、みたいな・・?)\n \n```\n\nのように、逆に関数内部の変数をグローバル変数として関数外部から取り出すことは不可能ですか?\n\nP.S.)本当にしたかったこと\n\n```\n\n class Queue:#練習用にQueueの一部機能を手書きしています。\n def __init__(self):\n self.items=[]\n \n def is_empty(self):\n return self.items==[]\n \n def enqueue(self,item):\n self.items.insert(0,item)#enqueuメソッドの引数itemをキューの一番最初(インデックス値=0)の要素として追加します。\n #insertメソッドは、\".insert(index値,要素)\"によってリストにオブジェクトを追加します。\n \n def dequeue(self):\n return self.items.pop()\n \n def size(self):\n return len(self.items)\n \n import time\n import random\n \n def simulate_line(till_show,max_time):\n pq=Queue()\n tix_sold=[]\n \n for i in range(100):\n pq.enqueue(\"person\" + str(i))\n \n t_end=time.time()+till_show\n now=time.time()\n while now<t_end and not pq.is_empty():\n now=time.time()\n r=random.randint(0,max_time)\n time.sleep(r)\n person=pq.dequeue()\n print(person)\n tix_sold.append(person)\n \n return tix_sold\n \n sold=simulate_line(5,1)\n print(tix_sold)\n \n```\n\nのコードにおいて、tix_soldのリストの個数が10個を超えるまで関数を繰り返し実行するようにしたかったです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T15:54:24.367",
"favorite_count": 0,
"id": "45521",
"last_activity_date": "2018-07-12T07:28:44.840",
"last_edit_date": "2018-07-11T16:05:38.523",
"last_editor_user_id": "29238",
"owner_user_id": "29238",
"post_type": "question",
"score": 1,
"tags": [
"python"
],
"title": "global変数の使い方について",
"view_count": 1317
} | [
{
"body": "> 逆に関数内部の変数をグローバル変数として関数外部から取り出すことは不可能ですか?\n\nその関数を実行すれば、グローバル変数にアクセスすることは可能です。\n\n`global y`は、`f(x)`を実行しないと定義されないため、 \n以下のように`f(x)`を実行する必要があります。\n\n```\n\n x=2\n f(2)\n print(y) #=> 4\n \n```\n\nそのため、`simulate_line`の場合、`simulate_line`自体を実行しているので、 \n以下のように`global tix_sold`としておけば、エラーなく実行できるはずです。\n\n```\n\n def simulate_line(till_show,max_time):\n pq=Queue()\n global tix_sold\n tix_sold=[]\n # 略\n \n```\n\nただし、バグを減らすためには、極力グローバル変数は避けたほうが良いため、今回の場合は、`simulate_line`の戻り値をそのまま利用したほうが良いと思います。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T16:12:39.410",
"id": "45523",
"last_activity_date": "2018-07-11T16:42:29.557",
"last_edit_date": "2018-07-11T16:42:29.557",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45521",
"post_type": "answer",
"score": 0
},
{
"body": "関数内部の変数をグローバル変数として関数外部から取り出すことは可能です。 \nしかし、以下のようにしてしまうと、関数を繰り返し実行する毎に`tix_sold`が初期化されてしまいます。それで`if`を使って初期化されていない場合だけ初期化するようにするとかという複雑なことになります。\n\n```\n\n def simulate_line(till_show,max_time):\n pq=Queue()\n global tix_sold\n tix_sold=[]\n \n```\n\nクラスの勉強をしているようなので、ここはクラスの出番です。クラスを使って`tix_sold`をインスタンス変数にすると、初期化が簡単にでき、関数を繰り返し実行して`tix_sold`のリストに追加していく処理もでき、関数外部からも取り出すことができます。\n\n```\n\n class simulate:\n def __init__(self):\n self.tix_sold=[]\n \n def simulate_line(self, till_show, max_time):\n pq=Queue()\n ----中略---\n self.tix_sold.append(person)\n \n sold = simulate() \n sold.simulate_line(5,1)\n sold.simulate_line(6,1)\n print(sold.tix_sold)\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T03:09:09.563",
"id": "45538",
"last_activity_date": "2018-07-12T07:28:44.840",
"last_edit_date": "2018-07-12T07:28:44.840",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "45521",
"post_type": "answer",
"score": 2
}
] | 45521 | 45523 | 45538 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[TremaでOpenFlowプログラミング](https://yasuhito.github.io/trema-book/)\n\n上記サイトを参考にTremaのインストールを終え、実行すると以下のようなエラーが出ました。 \n`command.rb`を色々いじってみても結果は変わらず分かりません。お助け頂けると嬉しいです。 \n環境は、CentOS 7です。\n\n```\n\n [root@localhost hello_trema]# ./bin/trema run ./lib/hello_trema.rb -c trema.conf\n /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/trema-0.10.1/lib/trema/command.rb:153:in `create_pid_file': HelloTrema is already running. (RuntimeError)\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/trema-0.10.1/lib/trema/command.rb:29:in `run'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/trema-0.10.1/bin/trema:68:in `block (2 levels) in <module:App>'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gli-2.13.4/lib/gli/command_support.rb:126:in `call'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gli-2.13.4/lib/gli/command_support.rb:126:in `execute'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gli-2.13.4/lib/gli/app_support.rb:296:in `block in call_command'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gli-2.13.4/lib/gli/app_support.rb:309:in `call'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gli-2.13.4/lib/gli/app_support.rb:309:in `call_command'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/gli-2.13.4/lib/gli/app_support.rb:83:in `run'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/trema-0.10.1/bin/trema:291:in `<module:App>'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/trema-0.10.1/bin/trema:14:in `<module:Trema>'\n from /opt/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/trema-0.10.1/bin/trema:11:in `<top (required)>'\n from ./bin/trema:29:in `load'\n from ./bin/trema:29:in `<main>'\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T17:13:34.093",
"favorite_count": 0,
"id": "45524",
"last_activity_date": "2018-07-11T17:54:47.703",
"last_edit_date": "2018-07-11T17:21:56.350",
"last_editor_user_id": "3060",
"owner_user_id": "29265",
"post_type": "question",
"score": 0,
"tags": [
"ruby",
"centos"
],
"title": "CentOSでのTrema(0.10.1)の実行時のエラーについて",
"view_count": 385
} | [
{
"body": "[terma/command.rb](https://github.com/trema/trema/blob/0.10.1/lib/trema/command.rb#L153)\nのソースを見るかぎり、`FileTest.exists? pid_file`が `true`のため、例外が発生しているようです。 \n`command.rb`を直接触れるのであれば、例えば、153行目を以下のように修正して実行してください。\n\n```\n\n puts \"DEBUG: #{pid_file}\"\n raise \"#{name} is already running.\" if running?\n \n```\n\n実行すると、ターミナルに、`pid_file`のパスが出力されると思いますので、 \npid_fileが存在しないか確認してください。存在するようであれば、削除してから再実行してください。\n\nただ、`pid_file`は一時ディレクトリ内にあるはずなので、通常は、起動毎に変るはずなのですが。いずれにしても、デバッグプリントを入れてみることで切り分けができると思います。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-11T17:54:47.703",
"id": "45525",
"last_activity_date": "2018-07-11T17:54:47.703",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45524",
"post_type": "answer",
"score": 2
}
] | 45524 | null | 45525 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "iPhoneの写真アプリ内の写真を自作アプリ内に自動で同期することはできますか?\n\n例えば写真アプリ内につくった特定のアルバムの写真だけを同期するということをしたいのですが。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T00:04:45.357",
"favorite_count": 0,
"id": "45528",
"last_activity_date": "2018-07-12T00:04:45.357",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12297",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode",
"iphone"
],
"title": "iPhoneの写真アプリ内の写真を自作アプリ内に自動で同期することはできますか?",
"view_count": 66
} | [] | 45528 | null | null |
{
"accepted_answer_id": null,
"answer_count": 4,
"body": "C++において、int型とlong型とlong long型の違いについて教えていただきたいです。 \n特に表現できる上限値について知りたくて、調べてみると下記な認識です。\n\nint -> 2^31 - 1 \nlong -> 2^31 - 1 \nlong long -> 2^63 - 1\n\nintとlong longの違いはわかるのですが、longの位置付けがよくわからないです。 \nlongもlong longも2^63 - 1ですし。Atcoderの解説の動画で、intで足りない場合はlong\nlongを使うといった内容を解説されたのですが、え、intの次っていったらlongじゃないのかな? \nなどと疑問に思って調べてみたらなおさらよくわからなくなったという背景です。\n\nlongとlong longの違いについて、上限値の観点で説明いただけますと助かります。 \nバージョンによるかもしれないので、c++11使ってることも共有しておきます。\n\nよろしくおねがいします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T00:23:35.913",
"favorite_count": 0,
"id": "45529",
"last_activity_date": "2018-07-13T00:13:51.827",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29267",
"post_type": "question",
"score": 4,
"tags": [
"c++",
"c++11"
],
"title": "C++言語でのint型とlong型とlong long型の違いについて",
"view_count": 45878
} | [
{
"body": "int型とlong型とlong long型は、limits.h で定義されていますので、お使いのC++コンパイラのヘッダファイルを確認してください。 \n特殊な整数型が \"stdint.h\" で定義されている場合もあるので、念のため確認してください。\n\nint型とlong型とlong long型の違いは、計算機環境(CPUのビット数)に依存します。 \nint型はCPUのビット数と同じビット数の整数、longは32ビットの整数、long\nlongは64ビットの整数となっている場合が多いように思います。(\"整数\"との表記は、整数と符号なし整数の両方を含むものという意味で使っています。) \n表にすると、CPUの種類(ビット数)と、それぞれのint,long, long longのビット数は以下のような感じ。\n\n>\n```\n\n> int long long long\n> 16bit CPU 16 32 64\n> 32bit CPU 32 32 64\n> 64bit CPU 64 64 64\n> \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T01:23:26.047",
"id": "45531",
"last_activity_date": "2018-07-12T01:23:26.047",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "45529",
"post_type": "answer",
"score": 0
},
{
"body": "[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") は太古からある言語です。\n[c++](/questions/tagged/c%2b%2b \"'c++' のタグが付いた質問を表示\") は\n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") との互換性を重要視している言語なので、この件に関しては事情は\n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") と同じです。というあたりを知ってもらった上で\n\n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") は 8bit マイコンでも 16bit\nマイコンでも使える言語です。そして `int` は「その処理系で自然な大きさ」を選べるよう、言語規格書上は大きさ(ビット数)を厳密に定めていません。\n\n[c99](/questions/tagged/c99 \"'c99' のタグが付いた質問を表示\") 言語規格書 ISO/IEC 9899:1999\nが定めているのは\n\n * `char` は 8bit 以上 `int` 以下のサイズであること\n * `int` は 16bit 以上のサイズであること\n * `long` は 32bit 以上 `long long` 以下のサイズであること\n * `long long` は 64bit 以上のサイズであること\n\n今でも組み込み系で当然のように使っている 8/16bit マイコンで先の条件を満たすには\n\n * `char` 8bit\n * `int` 16bit\n * `long` 32bit\n\n32bit マイコンあるいは x86 等の高級 32bit プロセッサでは同様\n\n * `char` 8bit\n * `short` 16bit\n * `int` 32bit\n\nでは `long` や `long long` を具体的にどの大きさにするかはプロセッサ自体の設計者やコンパイラの設計者や OS\n自体の仕様策定者の判断にゆだねられるところです。この判断の基準には\n\n * よりハードウエアの性能を引き出しやすい (32bit 専用ソースを書きたい)\n * より既存のソフトウエアを移植しやすい (16bit 時代のソースに手を入れたくない)\n\nという相反する面があって、紆余曲折の末、多くの 32bit プロセッサ用コンパイラでは\n\n * `long` 32bit (16bit 時代のソースコードとの互換性確保のため)\n * `long long` 64bit (`long` より大きい型が必要になったため)\n\nに落ち着いています(ご質問の中に書かれているとおり)。\n\nなのでご質問に対する回答は「昔のソースコードを移植しやすい型サイズを選んだ結果、このサイズが採用されている」となるでしょう。\n\n64bit プロセッサの場合は「既存のソフトウエアとの互換」面が特に重要視されており、型の大きさに関しては異なる仕様が並存しているのが現状です。 LP64\nとか LLP64 とか。 \n<https://project-\nflora.net/2015/07/21/cc%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B%E6%95%B4%E6%95%B0%E5%9E%8B%E3%81%AB%E3%81%AF%E6%B0%97%E3%82%92%E3%81%A4%E3%81%91%E3%82%88/>\n\nそして型の大きさがコンパイラによって異なるのはすごく不便と言うことで [c99](/questions/tagged/c99 \"'c99'\nのタグが付いた質問を表示\") や [c++11](/questions/tagged/c%2b%2b11 \"'c++11' のタグが付いた質問を表示\")\nでは大きさを厳密に定めた型とかが追加されています(上記ページでも解説されています)。移植性を重視するなど型の大きさを気にする必要がある場合は `int` や\n`long` といった処理系ごとに大きさが違う可能性のある型を使わずに `int16_t` などを使うことが推奨されています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T01:36:17.320",
"id": "45532",
"last_activity_date": "2018-07-12T05:45:01.627",
"last_edit_date": "2018-07-12T05:45:01.627",
"last_editor_user_id": "8589",
"owner_user_id": "8589",
"parent_id": "45529",
"post_type": "answer",
"score": 7
},
{
"body": "C/C++の各整数型が持つ上限値(ビット幅)というのはシステムによって異なります。(もちろん、システムごとに`sizeof(int) <=\nsizeof(long) <= sizeof(long long)`は常に成立)\n\n[基本的な型 -\ncppreference.com](https://ja.cppreference.com/w/cpp/language/types)によれば、具体的には\n\n * `int` 16ビットもしくは32ビット\n * `long` 32ビットもしくは64ビット\n * `long long` 64ビット\n\nの幅を持つ可能性があります。従って、`long`は常に`int`より大きいとは限らないということが分かります。一方`long\nlong`は64ビット幅を持つことが保証されているので、必ず`int`より大きく「intで足りない場合はlong\nlongを使う」という方針が常に有効であることが分かります。\n\n少なくともAtCoderに関する限りは、`int`=32ビット, `long\nlong`=64ビットと考えて差し支えないと思います。もし心配なら`int32_t`や`int64_t`のようなビット幅を明示した型を使うとよいでしょう。\n\nところでAtCoderはGCCが使われていますが、GCCでは[`__int128`](https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html)という128ビット幅を持つ整数が定義されており、64ビットでも不足する場合に対応することができます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T02:36:45.260",
"id": "45535",
"last_activity_date": "2018-07-12T02:36:45.260",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13199",
"parent_id": "45529",
"post_type": "answer",
"score": 3
},
{
"body": "みなさんが回答されているようにC言語およびC++言語では`int`、`long`、`long long`のサイズは指定されておらず実装依存です。\n\n例えば[Visual C++およびWindows](https://docs.microsoft.com/ja-\njp/cpp/cpp/fundamental-types-cpp#sizes-of-fundamental-types)では\n\n> `int` 32bit \n> `long` 32bit \n> `long long` 64bit\n\nと定められています。 \nAtCorderについてググって見つけた範囲では[Language Test](https://language-\ntest-201603.contest.atcoder.jp/)のページに\n\n> 注意:AtCoderのジャッジサーバーに関する情報は以下を参照してください\n```\n\n> $ uname -a\n> Linux ip-***-***-***-*** 3.13.0-74-generic #118-Ubuntu SMP Thu Dec 17\n> 22:52:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux\n> $ cat /etc/lsb-release\n> DISTRIB_ID=Ubuntu\n> DISTRIB_RELEASE=14.04\n> DISTRIB_CODENAME=trusty\n> DISTRIB_DESCRIPTION=\"Ubuntu 14.04.4 LTS\"\n> \n```\n\nとありLinux x86_64を使用しているようです。Linuxでは[Linux Standard\nBase](http://refspecs.linuxfoundation.org/lsb.shtml)が定められていて[Linux Standard\nBase Core Specification for X86-64 / Chapter 7. Low Level System Information /\n7.1. Machine Interface / 7.1.2. Data Representation / 7.1.2.3. Fundamental\nTypes](http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-AMD64/LSB-Core-\nAMD64/lowlevel.html#FUNDAMENTALTYES)では\n\n> LSB-conforming applications shall use only the fundamental types described\n> in Section 3.1.2 of System V Application Binary Interface AMD64 Architecture\n> Processor Supplement.\n\nと定められており、[System V Application Binary Interface AMD64 Architecture Processor\nSupplement / Chapter 3 Low Level System Information / 3.1.2 Data\nRepresentation / Fundamental Types](http://refspecs.linux-\nfoundation.org/elf/x86_64-abi-0.95.pdf#page=13)では\n\n> `int` 32bit \n> `long` 64bit \n> `long long` 64bit\n\nと定められています。同様に調べるとわかりますがLinux\nx86では`long`が32bitと定められているため、`long`はx86とx86_64とでサイズが異なります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T00:13:51.827",
"id": "45566",
"last_activity_date": "2018-07-13T00:13:51.827",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "45529",
"post_type": "answer",
"score": 4
}
] | 45529 | null | 45532 |
{
"accepted_answer_id": "50420",
"answer_count": 1,
"body": "PrivateNetで開発しています \n特定(自分だったりコントラクトであったり)のアドレスから送った履歴を一覧にする方法について\n\nBlock No.を順に検索し、Transaction\nNo.が含まれていたらそのTransactionのFromだったりToだったり、場合によってはInputを参照すると考えて実装しました \n4000Block中5件のTransactionを見つけるだけで40分ぐらいかかりました \n他に高速にできる方法・ライブラリがあれば情報いただけないでしょうか \nGethのコマンドは確認しましたが、前述の方法以外思いつかない状況です \n検索のプログラムはAWS LambdaでPythonを使って開発しています\n\n直接携わっていないのですが、Bitcoinで開発した際の類似機能ですと、`RPCOperations.listtransactions`に近いかと思います",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T01:51:11.643",
"favorite_count": 0,
"id": "45534",
"last_activity_date": "2018-11-18T16:50:36.583",
"last_edit_date": "2018-07-12T02:40:06.587",
"last_editor_user_id": "27721",
"owner_user_id": "27721",
"post_type": "question",
"score": 0,
"tags": [
"ethereum"
],
"title": "Transactionの検索について",
"view_count": 67
} | [
{
"body": "外部データベースにインデックスを作成しておく方法が考えられます。 \nあらかじめ外部データベースに特定のアドレスが関連するトランザクションのトランザクションIDを保存しておき、参照する場合はデータベースに保存されているIDを利用することで高速化することができます。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-11-18T16:50:36.583",
"id": "50420",
"last_activity_date": "2018-11-18T16:50:36.583",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31044",
"parent_id": "45534",
"post_type": "answer",
"score": 0
}
] | 45534 | 50420 | 50420 |
{
"accepted_answer_id": "45542",
"answer_count": 3,
"body": "**Q1.CentOS 7 には Postfix がデフォルトでインストールされていますか?**\n\n* * *\n\n**Q2.今現在、下記状態なのですがどういう意味ですか?** \n・yumではインストールされていないけれども、Postfix は存在している? \n・/etcに postfixがあるからと言ってインストールされているとは限らない??\n\n```\n\n # yum list installed | grep postfix\n \n```\n\n・何も表示されない\n\n```\n\n # ls /etc\n \n```\n\n> postfix\n\n* * *\n\n**環境** \n・CentOS 7",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T02:38:29.210",
"favorite_count": 0,
"id": "45536",
"last_activity_date": "2018-07-12T05:47:19.847",
"last_edit_date": "2018-07-12T04:05:27.957",
"last_editor_user_id": "2238",
"owner_user_id": "7886",
"post_type": "question",
"score": 1,
"tags": [
"centos",
"postfix"
],
"title": "CentOSにPostfixがインストールされているか確認したい",
"view_count": 3035
} | [
{
"body": "> Q1.CentOS 7 には Postfix がデフォルトでインストールされていますか?\n\n以下によると、`最小限のインストール`のパッケージに`postfix`は入っているようですので、デフォルトでインストールされると思います。\n\n[CentOS\n7インストーラの「ソフトウェアの選択」の中身を調べてみた](https://qiita.com/yunano/items/5a3687c5cd2007b3e720)\n\n> Q2.今現在、下記状態なのですがどういう意味ですか?\n\n`postfix`のパッケージがインストールされていないということだと思います。(他のMTAパッケージをインストールした等の理由により削除された。)\n\nパッケージは削除されたが、`postfix`の設定ファイル格納用ディレクトリ(`/etc/postfix/`)が残ってしまった状態ということだと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T03:14:04.083",
"id": "45540",
"last_activity_date": "2018-07-12T03:14:04.083",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45536",
"post_type": "answer",
"score": 1
},
{
"body": "CentOSは配布形態がいくつかあるので(通常版, netinstall, minimal,\netc...)、どの手段を使ってインストールしたかにもよると思います。\n\n完全なパッケージ名が分かっているなら`rpm -q <PACKAGE>`や`yum list <PACKAGE>`で確認する方法もあります。\n\n```\n\n $ rpm -q postfix\n postfix-2.10.1-6.el7.x86_64\n \n $ yum list postfix\n インストール済みパッケージ\n postfix.x86_64 2:2.10.1-6.el7 @anaconda\n \n # 未インストールの場合は以下の様な表示\n 利用可能なパッケージ\n postfix.x86_64 2:2.10.1-6.el7 @anaconda\n \n```\n\n`etc/postfix`が存在するのは\n[tanalab2](https://ja.stackoverflow.com/users/28902/tanalab2)\nさんも言及している通り、過去にパッケージがインストールされていたが手動、または自動でパッケージが削除され、設定ファイルのみ残っている可能性があります。 \nこの辺りの挙動は過去質問でも[回答](https://ja.stackoverflow.com/a/41994/3060)しています。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T03:20:37.847",
"id": "45542",
"last_activity_date": "2018-07-12T03:47:39.277",
"last_edit_date": "2018-07-12T03:47:39.277",
"last_editor_user_id": "3060",
"owner_user_id": "3060",
"parent_id": "45536",
"post_type": "answer",
"score": 2
},
{
"body": "```\n\n # rpm -qf /etc/postfix\n ファイル /etc/postfix はどのパッケージにも属していません。\n \n```\n\nこのように表示されれば、インストールされていません。\n\n`yum history package-info postfix` を実行すると過去にインストールされていたかなど、わかるかもしれません。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T05:47:19.847",
"id": "45548",
"last_activity_date": "2018-07-12T05:47:19.847",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "45536",
"post_type": "answer",
"score": 1
}
] | 45536 | 45542 | 45542 |
{
"accepted_answer_id": "45553",
"answer_count": 1,
"body": "毎分バッチのパフォーマンス検証のため、batch.logへscheduleへ開始ログを仕込みたいと思っています。 \n以下のようにすると、ログ出力についてもスケジューリングされバッチ実行時に以下のように毎回ログが出力されてしまいました。 \nコンストラクタで出力しようとするとterminalでエラーとなりそもそも実行できませんでした。 \nオーバーライドしたhandleメソッドでログ出力すると、schedule : startが2行となってしまいました。 \nログ出力処理についてもバッチ化する以外になにか方法がありましたらご教授のほどお願いいたします。\n\n```\n\n protected function schedule(Schedule $schedule)\n {\n $this->logger = app('batch.log');\n $this->logger->info('****************** schedule : start ******************');\n \n $schedule->command('aaa')->cron('* * * * * *')->withoutOverlapping();\n $schedule->command('bbb')->cron('* * * * * *')->withoutOverlapping();\n $schedule->command('ccc')->cron('* * * * * *')->withoutOverlapping();\n $schedule->command('ddd')->cron('* * * * * *')->withoutOverlapping();\n //他バッチは省略\n }\n \n```\n\n↑で出力されるログ\n\n[2018-07-12 02:57:00] batch.log.INFO: ****************** schedule : start\n****************** \n[2018-07-12 02:57:00] batch.log.INFO: aaa : start \n[2018-07-12 02:57:01] batch.log.INFO: aaa : end : elapsed time : 0.061 \n[2018-07-12 02:57:01] batch.log.INFO: ****************** schedule : start\n****************** \n[2018-07-12 02:57:01] batch.log.INFO: bbb : start \n[2018-07-12 02:57:02] batch.log.INFO: bbb : end : elapsed time : 0.058 \n[2018-07-12 02:57:02] batch.log.INFO: ****************** schedule : start\n****************** \n[2018-07-12 02:57:02] batch.log.INFO: ccc : start \n[2018-07-12 02:57:03] batch.log.INFO: ccc : end : elapsed time : 0.179 \n[2018-07-12 02:57:03] batch.log.INFO: ****************** schedule : start\n****************** \n[2018-07-12 02:57:03] batch.log.INFO: ddd : start \n[2018-07-12 02:57:04] batch.log.INFO: ddd : end : elapsed time : 0.157\n\n出力したいログ\n\n[2018-07-12 02:57:00] batch.log.INFO: ****************** schedule : start\n****************** \n[2018-07-12 02:57:00] batch.log.INFO: aaa : start \n[2018-07-12 02:57:01] batch.log.INFO: aaa : end : elapsed time : 0.061 \n[2018-07-12 02:57:01] batch.log.INFO: bbb : start \n[2018-07-12 02:57:02] batch.log.INFO: bbb : end : elapsed time : 0.058 \n[2018-07-12 02:57:02] batch.log.INFO: ccc : start \n[2018-07-12 02:57:03] batch.log.INFO: ccc : end : elapsed time : 0.179 \n[2018-07-12 02:57:03] batch.log.INFO: ddd : start \n[2018-07-12 02:57:04] batch.log.INFO: ddd : end : elapsed time : 0.157\n\n<環境> \nphp 7.0 \nLaravel 5.3",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T03:23:43.663",
"favorite_count": 0,
"id": "45544",
"last_activity_date": "2018-07-12T09:37:32.090",
"last_edit_date": "2018-07-12T03:59:18.690",
"last_editor_user_id": "29271",
"owner_user_id": "29271",
"post_type": "question",
"score": 0,
"tags": [
"laravel"
],
"title": "laravelのKernel::scheduleメソッドに登録された毎分バッチのパフォーマンス検証するために毎分バッチの開始時にログ出力したい",
"view_count": 417
} | [
{
"body": "すみません。自己解決しました。 \nログ出力メソッドを作り、scheduleの先頭へ以下のように追加することで対処しました。\n\n```\n\n $schedule->call(function(){ $this->logging('****************** schedule evertMinute : start ******************'); })->everyMinute();\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T09:37:32.090",
"id": "45553",
"last_activity_date": "2018-07-12T09:37:32.090",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29271",
"parent_id": "45544",
"post_type": "answer",
"score": 1
}
] | 45544 | 45553 | 45553 |
{
"accepted_answer_id": "45563",
"answer_count": 2,
"body": "Ruby on Rails でWebサイトの開発をしています。 \n/config/environments/development.rbで下記のコードを記述するとエラーが発生します。\n\n```\n\n config.aciton_mailer.smtp_settings = {\n address: 'smtp.gmail.com',\n port: 587,\n authentication: :plain,\n user_name: Rails.application.secrets.SMTP_EMAIL,\n password: Rails.application.secrets.SMTP_PASSWORD\n }\n \n```\n\nエラーメッセージは次の通りです。\n\n```\n\n >`method_missing': undefined method` aciton_mailer' \n \n```\n\n使用用途としては、Devise\nGemを使用した認証システムを構築しており、メールアドレス・ユーザ名の簡易なユーザ認証をしたのちにメールを飛ばし、本登録するというシステム設計の予定です。\n\n現状は、何かしらの原因でaction_mailerが起動しなかったことがわかるのですが、Google検索にかけてもRubyやRailsのバージョンの違いじゃないかという指摘しか見つけられず何が原因かわかりません。\n\nこんな観点で考えてみたら解決に繋がるのでは?というアイデアでも構いませんので、ご教示お願いします。\n\n次の通り、Gemfileを作成しています。\n\n```\n\n source 'https://rubygems.org'\n git_source(:github) { |repo| \"https://github.com/#{repo}.git\" }\n \n ruby '2.5.1'\n \n # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\n gem 'rails', '~> 5.2.0'\n # Use mysql as the database for Active Record\n gem 'mysql2', '>= 0.4.4', '< 0.6.0'\n # Use Puma as the app server\n gem 'puma', '~> 3.11'\n # Use bootstrap\n gem 'bootstrap-sass', '~> 3.3.7'\n # Use SCSS for stylesheets\n gem 'sass-rails', '~> 5.0'\n # Use Uglifier as compressor for JavaScript assets\n gem 'uglifier', '>= 1.3.0'\n # See https://github.com/rails/execjs#readme for more supported runtimes\n # gem 'mini_racer', platforms: :ruby\n \n # Use CoffeeScript for .coffee assets and views\n gem 'coffee-rails', '~> 4.2'\n # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\n gem 'jbuilder', '~> 2.5'\n # Use Redis adapter to run Action Cable in production\n # gem 'redis', '~> 4.0'\n # Use ActiveModel has_secure_password\n # gem 'bcrypt', '~> 3.1.7'\n \n # Use ActiveStorage variant\n # gem 'mini_magick', '~> 4.8'\n \n # Use Capistrano for deployment\n # gem 'capistrano-rails', group: :development\n \n # Reduces boot times through caching; required in config/boot.rb\n gem 'bootsnap', '>= 1.1.0', require: false\n \n group :development, :test do\n # Call 'byebug' anywhere in the code to stop execution and get a debugger console\n gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]\n end\n \n group :development do\n # Access an interactive console on exception pages or by calling 'console' anywhere in the code.\n gem 'web-console', '>= 3.3.0'\n gem 'listen', '>= 3.0.5', '< 3.2'\n # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n gem 'spring'\n gem 'spring-watcher-listen', '~> 2.0.0'\n gem 'better_errors'\n gem 'binding_of_caller'\n gem 'pry-byebug'\n gem 'pry-rails'\n gem 'overcommit'\n \n gem 'annotate'\n end\n \n group :test do\n # Adds support for Capybara system testing and selenium driver\n gem 'capybara', '>= 2.15', '< 4.0'\n gem 'selenium-webdriver'\n # Easy installation and use of chromedriver to run system tests with Chrome\n gem 'chromedriver-helper'\n end\n \n #Use user configration framework\n gem 'devise'\n \n gem 'bootstrap'\n gem 'jquery-rails'\n gem 'popper_js'\n gem 'tether-rails'\n \n # Windows does not include zoneinfo files, so bundle the tzinfo-data gem\n gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n \n```\n\n### バージョン情報\n\nRuby 2.5.1 \nRails 5.2.0",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T03:27:07.920",
"favorite_count": 0,
"id": "45545",
"last_activity_date": "2018-07-12T16:50:11.810",
"last_edit_date": "2018-07-12T15:42:46.503",
"last_editor_user_id": "19110",
"owner_user_id": "29272",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails"
],
"title": "Ruby on Rails 5 Action Mailerのエラー",
"view_count": 664
} | [
{
"body": "> `method_missing': undefined method` aciton_mailer'\n\n本来あるはずの`action_mailer`というメソッドが定義されていないというエラーであるため、 \n[`method_missing': undefined method`action_mailer' for\n...](https://stackoverflow.com/questions/21894467/method-missing-undefined-\nmethod-action-mailer-for-\nrailsapplicationcon)の回答にあるように、gemの再インストールを試してはいかがでしょうか?\n\n手順\n\n 1. Gemfile.lock を削除\n 2. bundle install",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T03:49:02.463",
"id": "45546",
"last_activity_date": "2018-07-12T03:49:02.463",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45545",
"post_type": "answer",
"score": 0
},
{
"body": "aciton_mailer がスペルミスです。 action_mailer で解決すると思います。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T16:50:11.810",
"id": "45563",
"last_activity_date": "2018-07-12T16:50:11.810",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "45545",
"post_type": "answer",
"score": 0
}
] | 45545 | 45563 | 45546 |
{
"accepted_answer_id": "45550",
"answer_count": 1,
"body": "# 環境\n\n * Python 3.6\n * bokeh 0.13.0\n\n# やりたいこと\n\nBokehというライブラリで、グラフを表示しています。\n\n```\n\n from bokeh.plotting import figure, output_file, show\n output_file(\"test.html\")\n p = figure()\n p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)\n show(p)\n \n```\n\n<https://bokeh.pydata.org/en/latest/docs/installation.html>\n\n# 質問\n\nshow関数を実行すると、ブラウザが起動してそこにグラフが表示されます。 \nHTMLファイルは生成したいけど、ブラウザを起動させたくないときは、どのように設定すればよいでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T05:02:56.217",
"favorite_count": 0,
"id": "45547",
"last_activity_date": "2018-07-12T10:20:23.003",
"last_edit_date": "2018-07-12T10:20:23.003",
"last_editor_user_id": null,
"owner_user_id": "19524",
"post_type": "question",
"score": 1,
"tags": [
"python",
"bokeh"
],
"title": "Python Bokehでブラウザに表示せずに、グラフの保存だけしたい",
"view_count": 1750
} | [
{
"body": "`save(p)`だと思います。\n\n```\n\n from bokeh.plotting import figure, output_file, save\n output_file(\"test.html\")\n p = figure()\n p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)\n save(p)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T06:44:57.363",
"id": "45550",
"last_activity_date": "2018-07-12T06:44:57.363",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45547",
"post_type": "answer",
"score": 1
}
] | 45547 | 45550 | 45550 |
{
"accepted_answer_id": "45551",
"answer_count": 1,
"body": "Ubuntu 16.04にて以下をターミナルから実行すると画像がすぐ消えてしまいます:\n\n```\n\n import gym\n env = gym.make('MsPacman-v0')\n env.reset()\n for _ in range(1000):\n env.render()\n time.sleep(0.1) #他のサイトでこれを入れれば消えないと言ってましたが\n env.step(env.action_space.sample()) # take a random action\n \n```\n\nMountainCar、MsPacmanも同じく一瞬で消えます。 \n因みにOpenAI自体の説明はこちらからもらいました:<https://gym.openai.com/docs/>",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T05:47:33.083",
"favorite_count": 0,
"id": "45549",
"last_activity_date": "2018-07-12T07:05:41.507",
"last_edit_date": "2018-07-12T07:05:41.507",
"last_editor_user_id": "29239",
"owner_user_id": "29239",
"post_type": "question",
"score": 1,
"tags": [
"python"
],
"title": "OpenAI GymのCartpoleのデモがすぐ消えてしまいます",
"view_count": 684
} | [
{
"body": "```\n\n import gym\n import time #追加のコード\n env = gym.make('MsPacman-v0')\n env.reset()\n for _ in range(1000):\n env.render()\n time.sleep(0.1) #他のサイトでこれを入れれば消えないと言ってましたが\n env.step(env.action_space.sample()) # take a random action\n \n```\n\n2行目で改善されました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T07:04:49.403",
"id": "45551",
"last_activity_date": "2018-07-12T07:04:49.403",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29239",
"parent_id": "45549",
"post_type": "answer",
"score": 2
}
] | 45549 | 45551 | 45551 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "いつもお世話になります。\n\n標記の件ですが、下記サイトを参考にコーディングしてみました。\n\nLaravelの認証機能でユーザ情報の論理削除(ソフトデリート)を実装する\n\n・・・が、ソフトデリートしたユーザのメールアドレス、パスワードを \nログイン画面で入力するとログインできてしまいます。\n\nそもそも論でお聞きしたいのですが、ソフトデリートしたユーザであっても \nログイン可能なのは仕様なのでしょうか?\n\nちなみに環境は以下の通りです。\n\n> Laravel 5.5 \n> PHP 7.2.7 \n> MySQL 5.7.22\n\n以上、よろしくお願い致します。\n\n※以下、コーディングした内容です。 \nマイグレーションファイルの作成、マイグレートの実行\n\n```\n\n $ php artisan make:migration add_column_softDeletes_users_table --table=users\n \n```\n\n> $ view 2018_07_12_045301_add_column_soft_deletes_users_table.php\n```\n\n <?php\n \n use Illuminate\\Support\\Facades\\Schema;\n use Illuminate\\Database\\Schema\\Blueprint;\n use Illuminate\\Database\\Migrations\\Migration;\n \n class AddColumnSoftDeletesUsersTable extends Migration\n {\n /**\n * Run the migrations.\n *\n * @return void\n */\n public function up()\n {\n Schema::table('users', function (Blueprint $table) {\n $table->softDeletes();\n });\n }\n \n /**\n * Reverse the migrations.\n *\n * @return void\n */\n public function down()\n {\n Schema::table('users', function (Blueprint $table) {\n $table->dropColumn('deleted_at');\n });\n }\n }\n \n```\n\nモデルの作成\n\n```\n\n $ php artisan make:model Models/Users\n \n```\n\n> $ view Users.php\n```\n\n <?php\n \n namespace App\\Models;\n \n use Illuminate\\Database\\Eloquent\\Model;\n use Illuminate\\Database\\Eloquent\\SoftDeletes;\n \n class Users extends Model\n {\n use SoftDeletes;\n \n protected $table = 'users';\n protected $dates = ['deleted_at'];\n }\n \n```\n\n下記SQL文にて、ユーザをソフトデリートしました。\n\n```\n\n update users set deleted_at = '2018-07-12 01:03:26' where id = 1;\n \n```\n\n前項でソフトデリートしたユーザでログインを試みるとログインできてしまいます。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T07:26:51.437",
"favorite_count": 0,
"id": "45552",
"last_activity_date": "2018-07-17T11:05:05.853",
"last_edit_date": "2018-07-12T08:28:57.950",
"last_editor_user_id": "2238",
"owner_user_id": "29282",
"post_type": "question",
"score": 2,
"tags": [
"php",
"laravel-5"
],
"title": "論理削除(ソフトデリート)したユーザをログイン不可にしたい",
"view_count": 1120
} | [
{
"body": "そもそも論でいえば、Laravel (Eloquent ORM) の `SoftDeletes` トレイトは、自身が適用された `users`\nテーブルが、ユーザ認証に使われているかどうかについて関知しないので、`SoftDeletes`\nトレイトを用いて論理削除を設定したテーブルで、認証処理を実現するのは(つまりソフトデリートされたユーザを実際にログイン不可能にするのは)実装者の責任になります。\n\na. とは言え、例えば\n\n```\n\n $user = App\\Models\\Users::where(['name' => 'admin', 'password' => 'P@ssw0rd'])->first();\n \n```\n\nの様に、`SoftDeletes` トレイトを適用した `Users`\nモデルを経由してログイン処理を実装していれば、そのような仕様は自然に実現できると思うので、そのように実装したつもりなら実際の認証処理周りのコードを確認しないと何とも言えません。\n\nb. しかし、もし\n\n```\n\n $user = DB::table('users')->where(['name' => 'admin', 'password' => 'P@ssw0rd'])->first();\n \n```\n\nの用なコードでログイン処理を実装していた場合、こちらは `SoftDeletes` トレイトを適用した `Users`\nモデルを経由しないので、`deleted_at`\nカラムの値に関わらず、論理削除されたレコードも返却されます(本題の仕様的に言えばログイン可能になってしまいます)。\n\nc. もちろん PDO やその他の MySQL ドライバを用いて SQL を発行した場合も同様に(`SoftDeletes`\nトレイトが提供する)`deleted_at` カラムを用いた論理削除は考慮されません。\n\nとにかく今一度ログイン認証処理まわりが `Users` モデルを利用して実装されていること、つまり「Eloquent ORM\nを通さずにユーザ認証にかかわるクエリを発行していないか」をご確認ください(実際の認証処理まわりのコードの添付も合わせてご検討ください)。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T11:05:05.853",
"id": "46679",
"last_activity_date": "2018-07-17T11:05:05.853",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28832",
"parent_id": "45552",
"post_type": "answer",
"score": 1
}
] | 45552 | null | 46679 |
{
"accepted_answer_id": "45557",
"answer_count": 2,
"body": "都合によりImageMagickは使用できません。C言語で実装する必要があります。\n\n<https://stackoverflow.com/questions/11834243/rotate-and-save-png-image-using-\ncairo>\n\n本家の方で似た質問があったので試してみたのですが、回転後の画像はなぜか回転前と全く同じでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T09:56:39.313",
"favorite_count": 0,
"id": "45554",
"last_activity_date": "2018-07-13T23:32:26.897",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17238",
"post_type": "question",
"score": 1,
"tags": [
"linux",
"c"
],
"title": "cairoでPNG画像を90, 180, 270度回転して保存したい",
"view_count": 291
} | [
{
"body": "参考にされている質問・応答に足りていない点といえば、 **cairo_surface_write_to_pngにtgtを渡す**\n点だと思いますが、それを忘れているのでは。 \n(質問文そのままだとソースイメージを書き出しているので、結果は変わりません)\n\n念の為、こんな感じでできます。\n\n```\n\n #include <cairo.h>\n \n int main()\n {\n cairo_surface_t *source;\n cairo_surface_t *dest;\n cairo_t *cr;\n int width, height;\n \n source = cairo_image_surface_create_from_png(\"source.png\");\n width = cairo_image_surface_get_width(source);\n height = cairo_image_surface_get_height(source);\n dest = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);\n cr = cairo_create(dest);\n cairo_translate(cr, width / 2.0, height / 2.0);\n cairo_rotate(cr, 3.14159 / 180.0 * 90.0);\n cairo_translate(cr, -width / 2.0, -height / 2.0);\n cairo_set_source_surface(cr, source, 0, 0);\n cairo_paint(cr);\n \n cairo_surface_write_to_png(dest, \"result.png\");\n cairo_destroy(cr);\n cairo_surface_destroy(dest);\n cairo_surface_destroy(source);\n return 0;\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T11:07:43.183",
"id": "45555",
"last_activity_date": "2018-07-12T11:07:43.183",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15473",
"parent_id": "45554",
"post_type": "answer",
"score": 2
},
{
"body": "コメントより:\n\n> ただ、このサンプルは縦横の解像度が同じ場合しか期待通りにならないですね。ペイントアプリで90度回転させたような見た目にするのは難しいでしょうか?\n```\n\n dest = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);\n \n```\n\nなので、回転前とサイズが変わっていない場合にしか対応できていないのでしょう。\n\n「ペイントアプリ」を知りませんが、以下でいかがでしょうか? \nkatsuko さんの回答を元に手を加えてみました。\n\n```\n\n #include <cairo.h>\n \n /* 90, 180, 270 */\n #define DEGREE 270\n \n int main()\n {\n cairo_surface_t *source;\n cairo_surface_t *dest;\n cairo_t *cr;\n int width, height;\n \n source = cairo_image_surface_create_from_png(\"source.png\");\n width = cairo_image_surface_get_width(source);\n height = cairo_image_surface_get_height(source);\n #if DEGREE == 180\n dest = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);\n #else\n dest = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, height, width);\n #endif\n cr = cairo_create(dest);\n #if DEGREE == 90\n cairo_translate(cr, height, 0);\n cairo_rotate(cr, 3.14159 / 2.0);\n #elif DEGREE == 180\n cairo_translate(cr, width, height);\n cairo_rotate(cr, 3.14159);\n #else\n cairo_translate(cr, 0, width);\n cairo_rotate(cr, 3.14159 / -2.0);\n #endif\n cairo_set_source_surface(cr, source, 0, 0);\n cairo_paint(cr);\n \n cairo_surface_write_to_png(dest, \"result.png\");\n cairo_destroy(cr);\n cairo_surface_destroy(dest);\n cairo_surface_destroy(source);\n return 0;\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T13:50:07.147",
"id": "45557",
"last_activity_date": "2018-07-13T23:32:26.897",
"last_edit_date": "2018-07-13T23:32:26.897",
"last_editor_user_id": "5288",
"owner_user_id": "5288",
"parent_id": "45554",
"post_type": "answer",
"score": 1
}
] | 45554 | 45557 | 45555 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "Sandboxを有効にしたとき、OpenPanelから選択したrealmファイルを開くと\n[realmファイル].realm.managementフォルダの作成時に例外が起きます。 \n回避する方法を教えてください。 \nrealmファイルはユーザがOpenPanelで選択可能な場所に存在することを想定しています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T12:29:48.117",
"favorite_count": 0,
"id": "45556",
"last_activity_date": "2018-08-18T03:30:26.027",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20521",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"macos",
"realm"
],
"title": "Sandboxを有効にしたときのrealmファイルの開き方について教えてください",
"view_count": 74
} | [
{
"body": "プロジェクト設定の、`Capabilities`タブの`App Sandboxing`の下の方に`File\nAccess`という蘭が有ると思うのですが、そこの`User Selected File`を`Read/Write`にするとどうなりますか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T20:29:04.703",
"id": "45595",
"last_activity_date": "2018-07-13T20:29:04.703",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "14745",
"parent_id": "45556",
"post_type": "answer",
"score": 0
},
{
"body": "Open Panelから選択したrealmファイルを更新モードで使用することは諦めました。 \nその代わり、まず読み書きの許可を与えるためOpen\nPanelでディレクトリを選択し、それからそのディレクトリ下のrealmファイルを選択するUIに変更することにしました。 \nあと、アプリ終了時にはrealm関連ファイル(lock, note, management)を削除することにしました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-08-18T01:05:07.483",
"id": "47594",
"last_activity_date": "2018-08-18T03:30:26.027",
"last_edit_date": "2018-08-18T03:30:26.027",
"last_editor_user_id": "20521",
"owner_user_id": "20521",
"parent_id": "45556",
"post_type": "answer",
"score": 0
}
] | 45556 | null | 45595 |
{
"accepted_answer_id": "45560",
"answer_count": 1,
"body": "やりたいことは[リンクHP](http://163.49.30.82/cgi-\nbin/DspDamData.exe?KIND=1&ID=1368030375180&BGNDATE=20180705&ENDDATE=20180711&KAWABOU=NO)(下のpythonコードのurlと同じです)の背景がグレーの部分のデータをDataframeに格納することです. \n背景がグレーの部分はリンク先のページに埋め込まれたhtmlファイルとなっていまして,リンクHPのソースを見ると\n\n```\n\n html\n </TABLE>\n <IFRAME src=\"/html/frm/DamFreeData2018071116325029223.html\" \n scrolling=\"AUTO\" width=\"840\" height=\"65%\" align=\"center\" frameborder=\"0\" \n style=\"border-width : 0px 0px 0px 0px;\"></IFRAME>\n </CENTER>\n \n```\n\nの「/html/frm/DamFreeData2018071116325029223.html」にデータのリンクが張られています.直接pandas.read_html(/html/frm/DamFreeData2018071116325029223.html)するのも1つの解決策なのですが,事情により最初に冒頭のHPに接続して,ソースのhtmlから'/html/frm/DamFreeData2018071116325029223.html'を取得したいのです.\n\n現状は\n\n```\n\n #!/usr/bin/python\n import pandas as pd\n import numpy as np\n \n url='http://163.49.30.82/cgi-bin/DspDamData.exeKIND=1&ID=609061289920060&BGNDATE=20120701&ENDDATE=20120731&KAWABOU=NO'\n dfs = pd.read_html(url)\n #dfs = pd.read_html(url, header=0,index_col=0)#htmlを読み込む\n print(dfs)\n \n```\n\nとするとほしいデータの部分がNaNと表示されてしまいます.どなたか解決策を教えていただけないでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T13:52:02.217",
"favorite_count": 0,
"id": "45558",
"last_activity_date": "2018-11-13T12:33:27.947",
"last_edit_date": "2018-11-13T12:33:27.947",
"last_editor_user_id": "26604",
"owner_user_id": "26604",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pandas",
"web-scraping"
],
"title": "webページのソースに貼られたリンク先のhtmlファイルを取得する",
"view_count": 1758
} | [
{
"body": "以下の段階にわけて処理する必要があると思います。\n\n 1. 任意期間ダム諸量検索結果 ページへのアクセス\n 2. iframeのsrc取得\n 3. iframeのsrcからデータ読み込み\n\n`python scraping`をキーワードに見付けた、以下の記事を参考に記載しています。\n\n[PythonでWebスクレイピングする時の知見をまとめておく](https://vaaaaaanquish.hatenablog.com/entry/2017/06/25/202924)\n\n## 事前インストール\n\n```\n\n $ pip install requests beautifulsoup4 lxml\n \n```\n\n## コード\n\n```\n\n import pandas as pd\n import numpy as np\n import requests\n from bs4 import BeautifulSoup\n import urllib.parse\n \n # 任意期間ダム諸量検索結果 ページへのアクセス\n page_url = \"http://163.49.30.82/cgi-bin/DspDamData.exe?KIND=1&ID=1368030375180&BGNDATE=20180705&ENDDATE=20180711&KAWABOU=NO\" \n res = requests.get(page_url)\n soup = BeautifulSoup(res.text, \"lxml\")\n \n # iframeのsrc取得\n data_src = soup.iframe['src'] #=> /html/frm/DamFreeData2018071300300727273.html\n data_url = urllib.parse.urljoin(page_url, data_src) #=> http://163.49.30.82/html/frm/DamFreeData2018071300194826006.html\n \n # iframeのsrcからデータ読み込み\n dfs = pd.read_html(data_url)\n print(dfs)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T15:41:43.633",
"id": "45560",
"last_activity_date": "2018-07-12T16:24:52.657",
"last_edit_date": "2018-07-12T16:24:52.657",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45558",
"post_type": "answer",
"score": 1
}
] | 45558 | 45560 | 45560 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "画面に支払日というコンボボックスがあり、その値はDB処理から取得した値で設定しています。設定後、初期値としてはサーバーサイド側で処理した値を表示するようにしています。 \nそして、その支払日コンボボックスのchangeイベント発生でchangeイベントの受け取るパラメタとして初期値として表示したサーバーサイド側で処理した値が渡ってくると思いきやDBから取得した値が何度も渡ってchangeイベントの処理が繰り返し実行されているため画面の表示が意図したものと違う形になってしまいます。 \nどういったことが原因であると考えられますでしょうか。初期値として表示したサーバーサイド側で処理した値のみをchangeイベントへのパラメタとして渡ってchangeイベントが行われるのが理想です。\n\nコードの例:\n\n```\n\n 支払日コンボボックス.change(function(event){\n // ここでvalメソッドで取得した値がDB処理から取得した値になってしまう。\n \n```\n\n●処理の流れ \n・画面の初期表示時、Ajaxを使用しDBから取得した値をJSで受け取り支払日コンボボックスに設定し、初期表示の値にサーバーサイド側で処理した値を表示 \n・支払日コンボボックスのchangeイベント処理発生",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T14:23:40.297",
"favorite_count": 0,
"id": "45559",
"last_activity_date": "2020-01-06T11:01:10.160",
"last_edit_date": "2019-07-25T02:38:38.310",
"last_editor_user_id": "32986",
"owner_user_id": "17348",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery"
],
"title": "changeイベントへのパラメタが意図しないデータを受け取っているエラー。",
"view_count": 287
} | [
{
"body": ">\n> changeイベント発生でchangeイベントの受け取るパラメタとして初期値として表示したサーバーサイド側で処理した値が渡ってくると思いきやDBから取得した値が何度も渡って\n\n`サーバーサイド側で処理した値`と`DBから取得した値`というところの意味がわかっていませんが、どちらの値でも一度\nHTML上で`<select></select>`にしてしまえば、\n\n以下のように、`change`の関数内で、`$(\"option:selected\",\nthis)`の値(text()やval())を取得すれば変更された`<option/>`の値を取得できると思います。\n\n```\n\n $(\"select\").change(function () {\r\n var str = $(\"option:selected\", this).text() + \":\" + $(\"option:selected\", this).val()\r\n $( \"div\" ).text( str );\r\n })\n```\n\n```\n\n <script src=\"https://code.jquery.com/jquery-1.10.2.js\"></script>\r\n \r\n <select name=\"sweets\" >\r\n <option value=\"1\">Chocolate</option>\r\n <option value=\"2\">Candy</option>\r\n <option value=\"3\">Taffy</option>\r\n <option value=\"4\">Caramel</option>\r\n <option value=\"5\">Fudge</option>\r\n <option value=\"6\">Cookie</option>\r\n </select>\r\n \r\n <h2>選択結果</h2>\r\n <div></div>\n```\n\n[参考: jquery select change event get selected\noption](https://stackoverflow.com/questions/12750307/jquery-select-change-\nevent-get-selected-option?answertab=active#tab-top)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T16:12:24.950",
"id": "45562",
"last_activity_date": "2018-07-12T16:12:24.950",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45559",
"post_type": "answer",
"score": 1
}
] | 45559 | null | 45562 |
{
"accepted_answer_id": "45567",
"answer_count": 1,
"body": "rubyの勉強がてらherokuに触ろうとしています。\n\ngem install herokuを実行し、 \n<https://devcenter.heroku.com/articles/getting-started-with-ruby#introduction> \nからherokuに登録してheroku CLIをインストールしました。\n\nherokuコマンドを実行すると \nInstall the Heroku CLI from <http://cli.heroku.com> \nと表示されるだけで終了してしまいます。\n\nスペックは以下の通りです。 \nOS:Windows7 \nRuby:2.4.4 \ngit:2.18.0 \nheroku:公式サイトから落とした最新のもの(バージョン不明)\n\nネット上で少し調べてみましたが、同様の症状は見つかっていません。 \nこちら、解決方法をご存知の方がいらっしゃいましたら教えて頂きたいです。 \n宜しくお願い致します。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T20:15:24.937",
"favorite_count": 0,
"id": "45564",
"last_activity_date": "2018-07-13T00:22:33.380",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29288",
"post_type": "question",
"score": 1,
"tags": [
"ruby",
"git",
"heroku"
],
"title": "heroku CLIをインストールしているにもかかわらず、インストールを要求されます",
"view_count": 193
} | [
{
"body": "`heroku`コマンドは昔はgemの形でインストールされていましたが、今は提供されていません。\n\n```\n\n gem uninstall heroku\n \n```\n\nでgem経由でインストールしたものを削除してから試して見てください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T00:22:33.380",
"id": "45567",
"last_activity_date": "2018-07-13T00:22:33.380",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3271",
"parent_id": "45564",
"post_type": "answer",
"score": 1
}
] | 45564 | 45567 | 45567 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "実DOMを操作するよりも仮想DOMを使ったほうが速いという話をききますが、 \n実際に早くなる理由がいまいちよくわかりません。\n\n変更前と変更後を比較して差分を変更するから、という説明を聞くと納得しそうになりますが、 \nDOM全体でなく、DOMの一部を再レンダリングするブラウザの機能ををうまいこと使うという意味なのでしょうか。\n\nそういった場合にどういったjavascriptの関数が実行されるのかなど、教えていただけると助かります。\n\nよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-12T22:46:04.627",
"favorite_count": 0,
"id": "45565",
"last_activity_date": "2018-07-14T23:49:38.410",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29289",
"post_type": "question",
"score": 8,
"tags": [
"javascript",
"reactjs",
"dom"
],
"title": "仮想DOMを使うと早くなる理由がいまいちわかりません",
"view_count": 4269
} | [
{
"body": "ぐぐってみると、この言葉の出所としては「[リアルな DOM\nはなぜ遅いのか](http://steps.dodgson.org/b/2014/12/11/why-is-real-dom-\nslow/)」という記事あたりではないかと思います。\n\n仮想DOMを使っても、仮想DOMから実DOMを操作しているわけで、最適化されたJavaScriptを使って実DOMを操作するよりも速くなることはありません。\n\nこの言葉の意味は、仮想DOMを使った場合は、フロント実装者が気にしなくても差分のみをレンダリングしてくれるので高速になる。使わない場合は、実装者がDomの差分を考えて、コードを組む必要があるが最適なコード書くのは難しいということです。\n\n詳しくは、記事を読んでもらうのが一番いいと思いますが、正確ではないですが要約すると次のようになります。\n\nレンダリングは、次のような処理をしていて、ブラウザーの表示では一番重い処理になる。\n\n * スタイルの引き当てを含むレンダリングツリーの構築\n * レンダリングツリー上でのレイアウト計算\n * そしてレイアウト結果に基づく画面のペイント\n\nそれで、ブラウザーの表示を速くしようと思えば無駄なレンダリングの処理を減らすのが一番効果的で、「仮想DOM」を使うことで、差分アルゴリズムを使って実際のDOMに必要な変更のみ適用することでそれを実現している。\n\nJavaScriptは結構速いので、「仮想DOM」を作成するのにはそれほど時間を必要としない。また、「仮想DOM」を最初に使ったのが`React.js`で、`React.js`は頑張って「仮想DOM」に多くの工夫をして高速な処理ができるようにしたことから「仮想DOM」は速いという評価になった。ただし、ブラウザ側も「実DOM」の高速化の努力をしているので、現在では当時ほどの違いはなくなっている。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T23:20:43.380",
"id": "45597",
"last_activity_date": "2018-07-14T23:49:38.410",
"last_edit_date": "2018-07-14T23:49:38.410",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "45565",
"post_type": "answer",
"score": 6
}
] | 45565 | null | 45597 |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "windows 10 pro \nvscode バージョン 1.25.1\n\nvscodeのターミナルで日本語が文字化けします。ユーザー設定で `\"files.autoGuessEncoding\": true`\nとしたのですが直りません。どうすればいいのでしょうか。 \nプログラミング初心者なので変なこと言ってたらすみません。\n\n## 追記\n\n`\"files.encoding\": \"shiftjis\"`を追記してみたらエディタもターミナルも文字化けしました。\n\n[](https://i.stack.imgur.com/ho4pb.png)\n\n`\"terminal.integrated.shellArgs.windows\": [\"-NoExit\",\"chcp\n65001\"]`を設定に追加すると文字が出力されませんでした。\n\n[](https://i.stack.imgur.com/b5md1.png)\n\nちゃんと動くプログラムと動かないプログラムがあります。 \n[](https://i.stack.imgur.com/TF1uQ.png)\n\n3枚目の画像の\"\\n\"をendlに変えても大丈夫です。 \n[](https://i.stack.imgur.com/WgbXZ.png)\n\nまた、ついさっきから新しくプログラムを書こうとしたら、iostream file not\nfoundというような表示が出されます。それでも正しくコンパイルされて実行されます。英字は出力されますが日本語は出力されません。 \n[](https://i.stack.imgur.com/JUrL6.png)\n\n[](https://i.stack.imgur.com/Q1erZ.png)\n\n[](https://i.stack.imgur.com/XVGWy.png)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T00:46:34.190",
"favorite_count": 0,
"id": "45568",
"last_activity_date": "2018-07-13T21:55:28.557",
"last_edit_date": "2018-07-13T05:14:29.600",
"last_editor_user_id": "29291",
"owner_user_id": "29291",
"post_type": "question",
"score": 2,
"tags": [
"文字化け",
"vscode"
],
"title": "vscodeのターミナルが文字化けする",
"view_count": 58894
} | [
{
"body": "ユーザー設定で、デフォールトの文字エンコードを utf-8 から、お使いのファイルで使っている文字エンコードに変更してみてください。\n\n例えば、デフォールトを Shift-JIS にしたければ、「\"files.autoGuessEncoding\":\ntrue」の行の後に以下の行を追加してください。\n\n> \"files.encoding\": \"shiftjis\",",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T01:02:55.800",
"id": "45569",
"last_activity_date": "2018-07-13T01:02:55.800",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "45568",
"post_type": "answer",
"score": 0
},
{
"body": "\"files.autoGuessEncoding\"・\"files.encoding\" の設定はファイルのエンコードを決定するもので、 \nターミナルのエンコードを設定するものではありません。\n\n * 解決策1 \nターミナルのPowershellの文字コードを変更します。 \n文字コードを変更するにはchcpコマンドを使用します。 \nUTF-8に変更するには`chcp 65001`を実行します。 \nsjisに変更するには`chcp 932`を実行します。 \n各文字コードの割り当て番号については[マイクロソフトのドキュメント](https://docs.microsoft.com/ja-\njp/windows/desktop/Intl/code-page-identifiers)を確認してください。 \n`chcp`コマンドを手で入力せずに、起動時に自動的に実行されるようにするには \n設定ファイルに`\"terminal.integrated.shellArgs.windows\": [\"-NoExit\",\"chcp\n65001\"]`と記載してください。\n\n * 解決策2 \nPowershellはSJIS・UTF-8BOM・UTF-16のファイルであれば設定を変更せずに読み込めます。 \n読み込むファイルのエンコードを変更します。\n\n[](https://i.stack.imgur.com/j0yNB.png) \n下のバーの文字コードの部分をクリックし、エンコード付きで保存→保存したい文字コードを選択",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T01:47:28.820",
"id": "45570",
"last_activity_date": "2018-07-13T01:47:28.820",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12195",
"parent_id": "45568",
"post_type": "answer",
"score": 2
},
{
"body": "MinGW64 GCCを使用しているという前提で話します。Visual Studio (Visual C++)の場合はまた事情が異なります。\n\n* * *\n\n混乱しないように`\"files.encoding\"`、 `\"terminal.integrated.shellArgs.windows\"`、\n`\"files.autoGuessEncoding\"`の設定は全て削除し、Visual Studio Codeを再起動しておいてください。\n\nソースコードは **UTF-8** にしてください(Visual C++でもコンパイルしたい、PowerShell上でソースコードを見たいと言った場合は、\n**UTF-8 with BOM** にしてください)。あとはコンパイル時に`-fexec-\ncharset=CP932`オプションを付けることでうまくいきます(gccとg++ともに)。\n\n```\n\n g++ -fexec-charset=CP932 hello.cpp\n \n```\n\n* * *\n\n以下、解説です。\n\nC/C++には標準の文字コードと言ったものは存在しません。そのため、コンパイル時に正しい文字コードを指定しないとうまく動作しない場合があります。ややこしいのが、三つの文字コードが別々に使われると言うことです。それらは次の通りです。\n\n 1. ソースコード自身の文字コード\n 2. コンパイルされたバイナリ上での文字列リテラル(`\"...\"`)の文字コード\n 3. コンパイルされたバイナリ上でのワイド文字列リテラル(`L\"...\"`)の文字コード\n\n1.から2.や3へはコンパイラが文字コードを自動的に変換します。これらの文字コードが何であるかは環境やコンパイラによって違います。\n\nMinGW64 GCCの場合\n\n 1. UTF-8 (BOM付きの場合も可)\n 2. UTF-8\n 3. UTF-16LE\n\nVisual C++の場合\n\n 1. ファイルの先頭にBOMがない場合はロケール依存(日本語ならCP932) \nファイルの先頭にBOMがある場合はBOMによる自動判別(UTF-8、UTF-16LE、UTF-16BE)\n\n 2. ロケール依存(日本語ならCP932)\n 3. UTF-16LE\n\nもう一つ注意すべき事は`printf`や`iostream`等の動作です。これらは文字列(`char\n*`)を扱いますが、ロケールによって文字コード変換するという動作はおこなわず、データをそのまま出力します。そのため、文字列自体の文字コードと出力先の文字コードが合っていなければ、文字化けなどが発生することになります。(ワイド文字列の出力はロケールに合わせて文字コード変換等が行われる場合があります)\n\nそして、Visual Studio\nCodeの統合ターミナルでのPowerShellも文字コードをもっており、デフォルトはロケール依存(日本語ならCP932)となっています。つまり、文字化けの原因は、2.のコンパイルされたバイナリ上での文字列リテラルの文字コードとターミナルでの文字コードが一致していないと言うことです。\n\nGCCではコンパイル時にこの三つの文字コードを指定できます。問題になっている2.の文字コードを日本語のPoweShellの文字コードであるCP932に指定するのが、`-fexec-\ncharset=CP932`になります。\n\n【補足】\n\n * CP932はWindowsで使われるShfit_JISの亜種です。MS932やWindows-31Jという別名で言われることもあります。\n * PowerShell側をUTF-8にするという方法もあります。`chcp 65001`がそのコマンドです。\n * ソースコードがShift_JISでもコンパイルできることがありますが、壊れたUTF-8として扱っているだけに過ぎません。特に`'表'`のような2バイト目が`\\`である文字があるとコンパイルエラーになったりします。\n * C11/C++11から追加された`u8\"...\"`リテラルは上記の指定と関係無くUTF-8のリテラルになります。文字列リテラルを環境に依存せずにUTF-8に強制させたいときに便利です。\n * `char *`そのものには文字コード情報という物が存在しない事に注意してください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T21:55:28.557",
"id": "45596",
"last_activity_date": "2018-07-13T21:55:28.557",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7347",
"parent_id": "45568",
"post_type": "answer",
"score": 2
}
] | 45568 | null | 45570 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "* 環境\n\n * Node.js:8.9.4\n * typescript:2.9.2\n * やりたいこと\n\n * 名前空間内のクラスをjestやmochaでテストしたい\n * tsconfig.jsonのtargetはES5\n * ソース側は変更したくない\n * 現状の例\n``` // src/main.ts\n\n namespace base {\n export class Foo {\n constructor() { console.log(\"Called Foo Constructor!\"); }\n public answerToTheUltimateQuestion(): number { return 42; }\n public callHello() { return new Bar().say() }\n }\n }\n \n // src/Hello.ts\n namespace base {\n export class Bar {\n constructor() { console.log(\"Called Bar Constructor!\"); };\n say(): string { return \"hello!\"; }\n getFoo() { return new base.Foo(); }\n }\n }\n \n // \\__tests__/main.test.ts\n const foo = new base.Foo(); // ReferenceError: base is not defined\n \n test(\"someMethod\", () => {\n expect(foo.answerToTheUltimateQuestion()).toBe(42);\n });\n \n```\n\nモジュール形式に書き直すのが一番良いとはわかっているのですが、ファイル数が多く、 \n変更しづらい状況なため、どうにかしてまずテストで \n壊れてもわかる状況を確保してから書き直していきたいのです。 \nd.tsファイル、tsconfig.jsonのtarget以外の変更、あるいは他の手段で解決することはできるのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T02:28:16.067",
"favorite_count": 0,
"id": "45571",
"last_activity_date": "2018-07-13T14:29:18.870",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12195",
"post_type": "question",
"score": 0,
"tags": [
"node.js",
"typescript"
],
"title": "namespaceを維持したまま外部モジュールとして他のファイルから読み込むには",
"view_count": 243
} | [
{
"body": "本家のstackoverflowに同様の質問がありました。ただし、本家の質問は解決にいたっていません。\n\n[How would I test Typescript code that uses namespaces in\nNode.js?](https://stackoverflow.com/questions/43952139/how-would-i-test-\ntypescript-code-that-uses-namespaces-in-node-js?answertab=active#tab-top)\n\nただその中で、TypeScriptの`\\--outFile` オプションを使う方式が紹介されていました。\n\n以下のようにテストコードに`/// <reference />`で依存関係のあるファイルパスを記載し、 \n`outFile`オプションに`main.test.js`などと指定して、 \nテストコードと依存コードを1つまとめれば、テストコードの修正と、 \nビルドツールの工夫だけで対応できるかもしれません。\n\n```\n\n // \\__tests__/main.test.ts\n /// <reference path=\"main.ts\" />\n /// <reference path=\"Hello.ts\" />\n const foo = new base.Foo(); // ReferenceError: base is not defined\n \n test(\"someMethod\", () => {\n expect(foo.answerToTheUltimateQuestion()).toBe(42);\n });\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T14:29:18.870",
"id": "45587",
"last_activity_date": "2018-07-13T14:29:18.870",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45571",
"post_type": "answer",
"score": 1
}
] | 45571 | null | 45587 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "IJCAD 2017のVBAで開発をしています。 \n長さ寸法(GcadDimRotated)について聞きたいことがあります。\n\nIJCADで図面上にある長さ寸法を選択した後、寸法の始点と終点(座標値)を知りたいのですが、ヘルプでGcadDimRotateやGcadDimensionクラスをいくら調べても、それらしいプロパティが見つかりませんでした。\n\n平行寸法(GcadIimAligned)クラスにはExtLine1Point、ExtLine2Pointのプロパティがあってこちらでは簡単に取得できるようです。\n\n始点・終点を知る方法がわかれば教えてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T02:43:45.343",
"favorite_count": 0,
"id": "45572",
"last_activity_date": "2023-04-10T06:01:05.137",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29128",
"post_type": "question",
"score": 2,
"tags": [
"vba",
"ijcad"
],
"title": "IJCADのVBAで長さ寸法の始点・終点を取り出したい",
"view_count": 998
} | [
{
"body": "残念ながら、IJCADのVBAではGcadDimRotateの始点と終点を取得することはできません。AutoCADのAcadDimRotateでも取得できないので仕様としか言えないです。\n\n回避策としては、VBAではなくVB.NetやGRXで開発を進めるとか、取得するだけのモジュールを.Net\nAPIやGRXで作ってVBAから呼び出して使うとか、一時的に長さ寸法を分解(Explode)して得られたLineから始点終点を求めるなどの方法が考えられます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T04:18:31.477",
"id": "45575",
"last_activity_date": "2018-07-13T04:18:31.477",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29030",
"parent_id": "45572",
"post_type": "answer",
"score": 0
},
{
"body": "回転寸法オブジェクトに ExtLine1Point と ExtLine2Point プロパティがないのはおかしいと思います。\n\n回転寸法の始点と終点の座標値は図形リストの13と14で取得できます。\n\n```\n\n (setq el (entget (car (entsel))))\n \n```\n\n座標値を文字列化する関数を用意して\n\n```\n\n (defun ptos ( p ) \n (strcat (rtos (car p)) \",\" (rtos (cadr p)) \",\" (rtos (caddr p))))\n \n```\n\nシステム変数 USERS1 に文字列化した座標値を保存して\n\n```\n\n (setvar \"USERS1\" (ptos (cdr (assoc 13 el))))\n \n```\n\nVBAでそれを取得することも可能です。\n\n```\n\n Dim text As String\n text = ThisDrawing.GetVariable(\"USERS1\")\n \n```\n\nまた図面に拡張データか拡張レコード(XRECORD)を用意すれば、座標値をLISPとVBAの間で受け渡すことも可能です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T06:32:54.030",
"id": "59474",
"last_activity_date": "2019-10-05T06:37:31.057",
"last_edit_date": "2019-10-05T06:37:31.057",
"last_editor_user_id": "32986",
"owner_user_id": "36080",
"parent_id": "45572",
"post_type": "answer",
"score": 0
}
] | 45572 | null | 45575 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n #データフレーム作成\n q1 <- c(\"1\",\"3\",\"2\",\"4\",\"5\")\n q2 <- c(\"1 2\",\"1 12\",\"2 11\",\"1 2 11 12\",\"3 12 13\")\n q3 <- c(\"1 2 3 4 5\", \"2 12 13\",\"*\",\"11 12\",\"1 2 3 4 5 6 7 8 9 10 11 12 13\")\n q4 <- c(\"5\",\"4\",\"3\",\"2\",\"*\")\n a <- data.frame(Q1=q1, Q2=q2,Q3=q3,Q4=q4)\n \n```\n\nマークカードで読み取った上記のデータフレーム。Q2とQ3のみ複数回答項目で要素がスペース区切りの文字列になっています。\n\n結果としては\"Q2_1\",\"Q2_2....Q3_12,Q3_13のように、0 or 1のダミー変数を作成したいのですが、うまくいきません・・。\n\n(separateとmakedummiesを使いました)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T03:23:40.657",
"favorite_count": 0,
"id": "45573",
"last_activity_date": "2018-08-14T06:01:16.063",
"last_edit_date": "2018-07-13T04:34:09.317",
"last_editor_user_id": "19110",
"owner_user_id": "29294",
"post_type": "question",
"score": 0,
"tags": [
"r"
],
"title": "スペースで区切られた複数回答項目をダミー変数にする。",
"view_count": 600
} | [
{
"body": "以下、実装例を載せますが、'*' の扱いが良く分からないので、そのままにしてあります。\n\n```\n\n make_answer_table <- function(q, tag) {\n x <- as.numeric(unlist(strsplit(q[q!='*'], \" \")))\n vmin <- min(x); vmax <- max(x)\n setNames(data.frame(t(sapply(q, function(item) {\n if (item == '*') return(rep('*', vmax-vmin+1))\n x <- as.numeric(unlist(strsplit(item, \" \")))\n sapply(vmin:vmax, function(i){ ifelse(i %in% x, 1, 0) })\n })), row.names=1:length(q)), c(paste(tag, vmin:vmax, sep='_')))\n }\n \n q1 <- c(\"1\",\"3\",\"2\",\"4\",\"5\")\n q2 <- c(\"1 2\",\"1 12\",\"2 11\",\"1 2 11 12\",\"3 12 13\")\n q3 <- c(\"1 2 3 4 5\", \"2 12 13\",\"*\",\"11 12\",\"1 2 3 4 5 6 7 8 9 10 11 12 13\")\n q4 <- c(\"5\",\"4\",\"3\",\"2\",\"*\")\n \n a <- cbind(\n Q1=q1,\n make_answer_table(q2, \"Q2\"),\n make_answer_table(q3, \"Q3\"),\n Q4=q4\n )\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T07:46:23.643",
"id": "45583",
"last_activity_date": "2018-07-13T07:46:23.643",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45573",
"post_type": "answer",
"score": 1
}
] | 45573 | null | 45583 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "phpを使ってphpmyadminのテーブルにデータを追加する方法ですが、 \n細かくは回答して頂かなくて結構なのですが、全体的な流れだけを \nご回答下さいませんか。\n\n■mampでphpmyadminに接続してデータベース\"personal\"とテーブル\"friend\"を作成しましたので、PHPを使ってテーブル\"friend\"にデータを追加したいです。 \nPDOってものを使うのでしょうか。\n\nお手すきの際で結構ですので、ご確認頂けると幸いです。\n\n宜しくお願いします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T04:19:05.893",
"favorite_count": 0,
"id": "45576",
"last_activity_date": "2018-07-13T05:34:49.493",
"last_edit_date": "2018-07-13T05:34:49.493",
"last_editor_user_id": "29244",
"owner_user_id": "29244",
"post_type": "question",
"score": 0,
"tags": [
"php",
"phpmyadmin",
"mamp"
],
"title": "PHPを使ってテーブルにデータを追加する",
"view_count": 139
} | [
{
"body": "ここで質問する前に、まず以下のURL等のチュートリアルを最初から最後までやってみるべきだと思います。\n\n<https://www.phpbook.jp/tutorial/mysql/>\n\nこの質問では範囲が広すぎて、ここでは回答しきれないと思います。 \nチュートリアルをやってみて、わからないところがあれば、ピンポイントで質問してください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T05:29:19.460",
"id": "45578",
"last_activity_date": "2018-07-13T05:29:19.460",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17014",
"parent_id": "45576",
"post_type": "answer",
"score": 1
}
] | 45576 | null | 45578 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Trema( <https://yasuhito.github.io/trema-book/>\n)のサイトを参考に6章までできたのですが、gitコマンドでclone( <https://github.com/trema/patch_panel.git>\n)して、bundle installをしたあとに実行してみるとhost関係の以下のようなエラーが発生します。\n\n```\n\n [root@localhost patch_panel]# ./bin/trema run ./lib/patch_panel.rb -c patch_panel.conf\n RTNETLINK answers: File exists\n /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/phut-0.7.5/lib/phut/shell_runner.rb:5:in `sh': sudo ip link add name patch_panel_1 type veth peer name host1 failed. (RuntimeError)\n from /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/phut-0.7.5/lib/phut/virtual_link.rb:99:in `add'\n from /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/phut-0.7.5/lib/phut/virtual_link.rb:67:in `run'\n from /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/phut-0.7.5/lib/phut/virtual_link.rb:15:in `each'\n from /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/phut-0.7.5/lib/phut/virtual_link.rb:15:in `each'\n from /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/phut-0.7.5/lib/phut/configuration.rb:44:in `block in run'\n from /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/phut-0.7.5/lib/phut/configuration.rb:43:in `each'\n from /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/phut-0.7.5/lib/phut/configuration.rb:43:in `run'\n from /opt/rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/trema-0.9.0/lib/trema/command.rb:110:in `block in start_phut'\n \n```\n\n環境はCentOS 7です。よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T05:53:16.910",
"favorite_count": 0,
"id": "45579",
"last_activity_date": "2019-12-29T17:02:25.330",
"last_edit_date": "2018-07-13T11:05:17.567",
"last_editor_user_id": null,
"owner_user_id": "29265",
"post_type": "question",
"score": 0,
"tags": [
"ruby",
"centos"
],
"title": "Trema(ruby)で仮想hostの作成時のエラー",
"view_count": 171
} | [
{
"body": "```\n\n sh': sudo ip link add name patch_panel_1 type veth peer name host1 failed. (RuntimeError)\n \n```\n\n上記エラーは、シェルコマンドの実行エラーと思います。 \n試しに、ターミナルから手動でエラーのあったコマンドを実行し、表示されるエラーメッセージを確認してください。\n\n```\n\n sudo ip link add name patch_panel_1 type veth peer name host1\n \n```\n\n表示されるエラー内容によって対応がかわると思いますが、もし、すでに`patch_panel_1`が存在するという意味のエラーであれば、`sudo ip\nlink delete ...`などにより手動で削除してから`trema`を実行すると良いと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T07:29:56.590",
"id": "45581",
"last_activity_date": "2018-07-13T07:29:56.590",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45579",
"post_type": "answer",
"score": 1
}
] | 45579 | null | 45581 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "PrivateNetで開発しています \n`eth.pendingTransactions`を実行すると、`to`に覚えのないアドレスが設定されたtransactionが多数発生します \n`to`に設定されるアドレスは複数種類ありますが、`value`は同じ値が入っています \n覚えのないアドレスに対し`getTransaction`を実行するとEthを保有しています \n覚えがないだけにパスワードも不明ですが、'sendTransction'で抜いてみようとすると\n\n```\n\n Error: unknown account\n \n```\n\n現状coinbaseから流出しているようでまいっています\n\nchaindata,lightchaindataフォルダを削除しgenesisi.jsonでinitからやり直しても同じ事象が起きます \n何かご存知の方いらっしゃらないでしょうか\n\n類似情報見つけました \n<https://github.com/ethereum/go-ethereum/issues/17127> \n対処は今の所ポートの変更しか思いつかないです",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T07:39:34.923",
"favorite_count": 0,
"id": "45582",
"last_activity_date": "2018-07-23T03:32:01.260",
"last_edit_date": "2018-07-23T03:32:01.260",
"last_editor_user_id": "27721",
"owner_user_id": "27721",
"post_type": "question",
"score": 0,
"tags": [
"ethereum"
],
"title": "pendingTransactionsに滞留している謎のtransactionについて",
"view_count": 186
} | [] | 45582 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "proxy環境にてXcodeからGitHubへのpushで以下のエラーとなりました。\n\n```\n\n curl error: Failed to connect to github.com port 443: Operation timed out (-1)\n \n```\n\n原因、解決方法を教えてください。よろしくお願いします。\n\n**動作環境** \nXcode 9.2 \nmacOS 10.12.6\n\n * macのネットワーク環境設定のプロキシは設定しています。\n * XcodeのSource Control navigatorのRemotesは設定しています。 \n * Xcodeにてpull, cloneは実行できます。\n * .gitconfigは以下のような感じで設定しています。\n``` $ cat ~/.gitconfig\n\n [https]\n proxy = http://{proxy server}:{port}\n [http]\n proxy = http://{proxy server}:{port}\n [user]\n name = {user}\n \n```\n\n * GitHub Desktop, Atomでは、pull, pushは問題なく動作しているので、gitconfigは効いていると思います。\n\n * .curlrcは以下のような感じで設定しています。\n``` $ cat ~/.curlrc\n\n proxy = http://{proxy server}:{port}\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T12:25:36.243",
"favorite_count": 0,
"id": "45585",
"last_activity_date": "2020-01-21T03:02:55.527",
"last_edit_date": "2019-12-12T08:18:00.647",
"last_editor_user_id": "3060",
"owner_user_id": "20521",
"post_type": "question",
"score": 1,
"tags": [
"xcode",
"macos",
"github"
],
"title": "proxy環境にてXcodeからGitHubへのpushでエラー",
"view_count": 930
} | [
{
"body": ".gitconfigにはuser情報がありますが、.curlrcにはありません。どちらの設定が正しいでしょうか? \nまた、443ですので証明書関連などはないでしょうか?そもそもアクセスできないのなら、 \nほかのエラーがでそうです。\n\n以上",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T22:04:18.500",
"id": "46645",
"last_activity_date": "2018-07-15T22:04:18.500",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10174",
"parent_id": "45585",
"post_type": "answer",
"score": 1
}
] | 45585 | null | 46645 |
{
"accepted_answer_id": "45599",
"answer_count": 1,
"body": "`github.com/moby/moby/client`のEventsメソッドを使ったDockerのイベントを取得するソフトウェアを作成しています。 \n以下のdockerコマンドを実行した場合はDockerのイベントを取得できますが、docker-composeで指定した場合に`Error response\nfrom daemon: {\"message\":\"page not found\"}`というエラーがでて失敗します。\n\n```\n\n docker run -d -v /var/run/docker.sock:/var/run/docker.sock -e API_VERSION=1.37 docker-app /app/binary\n \n```\n\ndocker-compose.yml\n\n```\n\n version: \"3.5\"\n services:\n app:\n build: .\n command: /app/binary\n volumes:\n - /var/run/docker.sock:/var/run/docker.sock\n env_file:\n - docker.env\n \n```\n\nなぜdocker-composeで実行したときだけエラーがでるのでしょうか。またどのように修正すればdocker-\ncomposeでもdockerコマンドを実行したときと同じ状況を再現できるのでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T16:52:08.010",
"favorite_count": 0,
"id": "45590",
"last_activity_date": "2018-07-14T00:35:25.593",
"last_edit_date": "2018-07-14T00:35:25.593",
"last_editor_user_id": "20098",
"owner_user_id": "7232",
"post_type": "question",
"score": 0,
"tags": [
"go",
"docker"
],
"title": "docker-composeで実行したときdocker.sockから情報を取得できない",
"view_count": 225
} | [
{
"body": "`docker.env`内の`API_VERSION=\"1.37\"`を`API_VERSION=1.37`に変えると動きました。 \n`env_file`を使うときは`\"`を使えないようです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T00:03:14.323",
"id": "45599",
"last_activity_date": "2018-07-14T00:18:17.423",
"last_edit_date": "2018-07-14T00:18:17.423",
"last_editor_user_id": "7232",
"owner_user_id": "7232",
"parent_id": "45590",
"post_type": "answer",
"score": 0
}
] | 45590 | 45599 | 45599 |
{
"accepted_answer_id": "45602",
"answer_count": 2,
"body": "はじめまして。週末に趣味でプログラミングをしている日曜プログラマーなのですが、pythonに慣れており、djangoを使って下記のような生徒向けの問題管理ページを作成したいと考えております。\n\nひととおりdjango公式のチュートリアルの内容や、一通り作成と動作確認や、シェルを使ってdjangoのモデルの概念やpythonに関してはある程度概念がわかっているつもりなのですが、下記のような仕組みを作るにあたって、どのようなモデルをデザインすれば良いか悩んでおり、質問させていただきます。\n\nデータベースに関しても、一通り一般的なsqlは理解しており、正規化に関しても独学で勉強しました。\n\n一応flaskでは簡単な従業員の日報管理フォームを作成して、さくらサーバーでデプロイするぐらいのことはできたレベルです。\n\n不勉強なところも多いですが、助言いただけると幸いです。\n\n作成するview:\n\n 1. ログインユーザー(生徒)のページ\n 2. 数学問題の一覧ページ\n 3. 数学問題の詳細ページ\n 4. 3の詳細ページを開く前に、本当にこのページを開くかどうか確認するページ\n 5. 1のログインページに、解いた(詳細ぺーじを開いたかどうか)ページの一覧を確認できる表示\n\n■ 実現したいこと: \nログインしたユーザー(1.の生徒)が、2の数学の問題一覧(簡単なタイトルなど)をみて、自分(生徒自身)で解きたいページを開いて(3.の詳細ページを確認)回答する。\n\n毎回、ログインした時に、なんの問題を解いたか(5のように一覧ページを設ける?)のと、2の一覧ページにアクセスするたびに、解いたページはわかるように、リストの下に回すなど。のわかりやすいように表示をしたい。\n\n■ 質問について: \n最終的に実現したいのは上記なのですが、最初は、フィルターを作成して、2.の一覧ページでは、未回答のチェックを入れて、リロードするような感じで一覧ページを再表示させて作成できるかな?と考えていますが、ユーザーの情報のモデルと、数学問題のモデルをどのように管理すれば良いかが悩んでおり、質問になります。\n\nもしかしたらタイトルの意味合いが違うかもしれないですがご指摘いただければと思います。どのようなモデルを作成するのが、管理と表示が簡単にできるかご教示してくださる方がいらっしゃいましたら何卒宜しくお願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T19:25:59.650",
"favorite_count": 0,
"id": "45593",
"last_activity_date": "2018-07-14T04:06:15.363",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29307",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"django"
],
"title": "django の閲覧権限を細かく設定し集計したい。",
"view_count": 371
} | [
{
"body": "> 生徒向けの問題管理ページを作成したい\n\n上記のようなシステムは、 **LMS(学習管理システム)** に分類されると思います。 \nオープンソースのLMSとして以下のものがあるようです。\n\n * [Moodle](https://github.com/moodle/moodle)(PHP)\n * [Canvas](https://github.com/instructure/canvas-lms/wiki)(Ruby)\n * [RELATE](https://github.com/inducer/relate) (Python Django)\n\nDjangoでLMSを作成したいのであれば、まずは、 **RELATE** のモデルを参考にされてはいかかがでしょうか?\n\n参考: [まだ Moodle で消耗してるの? オープンソースの Python製\nLMS「RELATE」が圧倒的にカスタマイズしやくてヤバイぞ!](http://akiyoko.hatenablog.jp/entry/2017/12/19/235108)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-13T23:54:17.920",
"id": "45598",
"last_activity_date": "2018-07-13T23:54:17.920",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45593",
"post_type": "answer",
"score": 1
},
{
"body": "数学の問題を表示するシステムを作る場合に問題になるのが、数式の表示をどうするかということです。PythonではJupyter\nNotebookで数式が簡単にかけるのでPythonを選択したのは正解です。しかしながら、Jupyter\nNotebookを管理するのも結構手間になる場合があるので、ブラウザーでTexを表示できるJavaScriptのライブラリ`KaTeX`や`MathJax`を使う方がもっと便利です。\n\n`KaTeX`や`MathJax`を今すぐにではなくても将来的に使うと言うことであれば、クライアント側でレンタリングすることを考えておいた方がいいし、時代の流れとしても、ブラウザーのJavaScriptの処理が速くなっているので、クライアントレンダリングを意識しておいた方がいいでしょう。Djangoの機能の殆どはサーバーサイドレンダリングの機能なので、Djangoの機能をあまり使わずに設計した方がいいと思います。\n\nまず、ユーザー管理については、認証はdjangoの付属のものを使ってもいいのですが、JavaScriptを使う場合は`Firebase\nAuthentication`のようなサービスを使った方が楽な場合が多いです。それで、認証用のデータベースをカスタマイズするよりは不足する分は別にユーザー情報のデーターベースを作っておいた方がいいと思います。\n\n質問のメインの内容になりますが、Webはステートレスなのでアクセスがある毎にデータベースにデータを取りに行くのが基本になります。それで生徒からの回答のデータベースを下のように作っておいて\n\n```\n\n from sqlalchemy import Column, Integer, String\n class 回答(Base):\n __tablename__ = 'users'\n \n id = Column(Integer, primary_key=True)\n ユーザーID = Column(String)\n 問題ID = Column(String)\n 回答 = Column(String)\n \n def __repr__(self):\n return \"<回答(ユーザーID='%s', 問題ID='%s', 回答='%s')>\" % (\n self.ユーザーID, self.問題ID, self.回答)\n \n```\n\nDjangoでログインしているユーザーの情報は取得できるので、アクセスがある毎に次のような感じでユーザーの回答済みの問題の一覧を取得します。\n\n```\n\n 回答済 = conn.execute('SELECT 問題ID FROM 回答 WHERE ユーザーID = :user', user=user).fetchall() \n \n```\n\nログインした時に、なんの問題を解いたかを表示するのは、その「回答済」を表示すればいいし、未回答のチェックを入れたいときはデータベース側で`LEFT\nJOIN`を使ってもいいし、Pythonで計算して処理をしても可能です。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T03:25:03.930",
"id": "45602",
"last_activity_date": "2018-07-14T04:06:15.363",
"last_edit_date": "2018-07-14T04:06:15.363",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "45593",
"post_type": "answer",
"score": 0
}
] | 45593 | 45602 | 45598 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "# 質問\n\n 1. WKWebViewは、『生成⇒ロード⇒表示開始⇒表示完了』で数秒かかる処理はありますか?(約1~2.5秒)\n 2. WKWebViewは、『生成~表示~破棄』を繰り返す場合、初回生成のWKWebViewを再利用が『表示速度が速く・適切な方法』ですか?\n 3. ネット上で、WKWebViewの生成が遅い/WKWebViewのページロードが遅い等の情報がない。生成もロードも体感で一瞬が普通ですか? \n※表示するページの複雑さ・サイズに影響されるが\n\n# 補足\n\n## 条件・状態\n\n * iOSのWKWebViewを使用した「ガワネイティブ/ハイブリッド」のアプリ開発。\n * Objective-C(Swift)でWKWebViewを使用。\n * ネイティブのボタンタップで、WKWebViewでHTML(WEBページ)を表示/クローズ。\n * Yahooページ/\"Hellow World!!\"シンプルページ の表示速度を確認。\n * 表示完了までに1.?秒~2.5秒かかる。\n * 同じURLでも『アプリの起動繰り返し/操作繰り返し』で表示速度(表示時間)は毎回バラつく。\n * どのURLでも表示速度(表示時間)がバラつく。\n * 表示のされかたは、真っ白な状態の上記時間後、パッと瞬間で表示され読み込んだ部分から表示されない。\n * アプリ内で、アプリ画面の画面遷移は一瞬でできており、WKWebViewの表示だけ1.?秒~2.5秒くらいかかる。\n\n## 上記から、テストアプリ開発その1『ブラウザ アプリ』\n\n * ブラウザアプリを作った。\n * URLを入力 ⇒ 表示ボタンタップ ⇒ 一瞬でHTMLページが表示される。\n * その状態で何度やっても一瞬で表示される。 \n※一瞬とは目視で測定不可能なほど速いこと。\n\n## 上記から、予想。\n\n * WKWebViewは生成に1.?秒~2.5秒の時間がかかるのでは? \n※時間にバラつきがある理由はライブラリ内部で生成時に何かが?\n\n## 上記から、テストアプリ開発その2『WKWebView再利用 アプリ』\n\n * 生成したWKWebViewを再利用する為、生成処理は初回のみ。\n * 初回のみ1.?秒~2.5秒の時間がかかるようになった。\n * 二回目以降の表示は一瞬。=ブラウザと同じ速度。\n\n## 上記から、疑問。\n\n * WKWebViewの生成・表示が遅いという情報が見つからない理由は? \n(表示は速いとの情報多数あり。生成が速いや遅いとの情報なし。)\n\n * WKWebViewのプログラム/使用方法が違っている場合、生成/表示に『1.?秒~2.5秒の時間がかかる』が『正常に表示される』といったケースもあるのか?",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T02:16:06.770",
"favorite_count": 0,
"id": "45600",
"last_activity_date": "2018-07-25T05:29:04.220",
"last_edit_date": "2018-07-25T05:29:04.220",
"last_editor_user_id": "29309",
"owner_user_id": "29309",
"post_type": "question",
"score": 1,
"tags": [
"swift",
"ios",
"objective-c",
"wkwebview"
],
"title": "iOS/Objective-C(Swift)でWKWebViewの初期表示が遅い原因は?( ガワネイティブ、ハイブリッド)",
"view_count": 1130
} | [
{
"body": "自己回答です。\n\n# 本件の調査・質問の結果\n\nWKWebViewの生成には数秒かかる(例:1.5~2.5秒 ※タイミング、端末により時間は異なる)。\n\n# 根拠・理由\n\n1.\"生成に時間はかからない/時間がかかる\"や\"時間がかかるのは仕様\"、\"生成を速くする方法/遅い原因\"などの文章や情報が見つからず決定的な判断はできないですが。 \n2.本検証用にテストアプリを別途作成したが、やはり生成が遅い。 \n3.ネット上でSwiftやObjective-C、色々な国の人達の開発アプリの動作動画からも『生成は数秒かかる』ことがわかる(一部予測を含む)。 \n4.単なる補足ですが。Appleに問い合わせしていましたが、『\"回答できない\"という回答』でした。※注:Appleへの問合せ自体が問題で回答をもらえなかった可能性あり。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-25T05:26:54.717",
"id": "46935",
"last_activity_date": "2018-07-25T05:26:54.717",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29309",
"parent_id": "45600",
"post_type": "answer",
"score": 1
}
] | 45600 | null | 46935 |
{
"accepted_answer_id": "45605",
"answer_count": 2,
"body": "回答ありがとうございます。\n\n```\n\n $(document).ready(function(){\r\n $('.tabs > .c').trigger('click');\r\n });\r\n \r\n $(function(){\r\n // タブをクリック時\r\n $('.tabs > div').click(function(){\r\n $('.tabs > div,.tab_content').removeClass('active');\r\n \r\n var tabClass = $(this).attr('class');\r\n \r\n $(this).addClass('active');\r\n \r\n $('.tab_content').each(function(){\r\n // indexOfだと、'a', 'b', 'c'の場合に常にtrueとなるため、classの最後のみ比較するように修正\r\n //if($(this).attr('class').indexOf(tabClass) != -1){\r\n if($(this).attr('class').split(' ')[1] === tabClass){\r\n $(this).addClass('active').fadeIn();\r\n \r\n }else{\r\n $(this).hide();\r\n }\r\n });\r\n });\r\n });\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\r\n \r\n <div class=\"tabs\">\r\n <div class=\"a\">タブ1</div>\r\n <div class=\"b\">タブ2</div>\r\n <div class=\"c\">タブ3</div>\r\n <div class=\"d\">タブ4</div>\r\n </div>\r\n \r\n <div class=\"tab_content a active\">\r\n <p>aaaaa</p>\r\n </div>\r\n \r\n <div class=\"tab_content b\">\r\n <p>bbbbb</p>\r\n </div>\r\n \r\n <div class=\"tab_content c\">\r\n <p>ccccc</p>\r\n </div>\r\n \r\n <div class=\"tab_content d\">\r\n <p>ddddd</p>\r\n </div>\n```\n\n上記教えていただいた通り実行しますと読み込み時、全てのtab_contentが表示されております。 \nご教授願いいたします^^;",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T03:28:54.830",
"favorite_count": 0,
"id": "45603",
"last_activity_date": "2018-07-14T07:46:24.553",
"last_edit_date": "2018-07-14T06:08:04.527",
"last_editor_user_id": "29310",
"owner_user_id": "29310",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery"
],
"title": "ページ読み込み時にタブ切り替え",
"view_count": 290
} | [
{
"body": "```\n\n $(document).ready(function(){\n $('.tabs > .c').trigger('click');\n });\n \n```\n\nと以下は同じ意味になります。\n\n```\n\n $(function() {\n $('.tabs > .c').trigger('click');\n });\n \n```\n\nまた、ページ読み込み時に`click`するためには、`click`前にタブにイベントハンドラが設定されている必要があります。\n\nそのため、以下のようにタブのイベントハンドラ設定後に、同じ`$(function(){`内でイベント発行すれば良いと思います。\n\n```\n\n $(function(){\n // タブをクリック時のイベントハンドラ設定\n // ...省略...\n \n // タブのクリックイベントを発行\n $('.tabs > .c').trigger('click');\n });\n \n```\n\n以下は、初回に'c'タブをクリックする場合の例になります。\n\n```\n\n $(function(){\r\n // タブをクリック時のイベントハンドラ設定\r\n $('.tabs > div').click(function(){\r\n $('.tabs > div,.tab_content').removeClass('active');\r\n \r\n var tabClass = $(this).attr('class');\r\n \r\n $(this).addClass('active');\r\n \r\n $('.tab_content').each(function(){\r\n // indexOfだと、'a', 'b', 'c'の場合に常にtrueとなるため、classの最後のみ比較するように修正\r\n //if($(this).attr('class').indexOf(tabClass) != -1){\r\n if($(this).attr('class').split(' ')[1] === tabClass){\r\n $(this).addClass('active').fadeIn();\r\n \r\n }else{\r\n $(this).hide();\r\n }\r\n });\r\n });\r\n \r\n // タブのクリックイベントを発行\r\n $('.tabs > .c').trigger('click');\r\n });\n```\n\n```\n\n .tabs > div {\r\n display: inline-block;\r\n padding: 0 0.5rem;\r\n }\r\n \r\n .tabs > .active {\r\n background-color: lightgreen;\r\n }\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\r\n \r\n <div class=\"tabs\">\r\n <div class=\"a\">タブ1</div>\r\n <div class=\"b\">タブ2</div>\r\n <div class=\"c\">タブ3</div>\r\n <div class=\"d\">タブ4</div>\r\n </div>\r\n \r\n <div class=\"tab_content a active\">\r\n <p>aaaaa</p>\r\n </div>\r\n \r\n <div class=\"tab_content b\">\r\n <p>bbbbb</p>\r\n </div>\r\n \r\n <div class=\"tab_content c\">\r\n <p>ccccc</p>\r\n </div>\r\n \r\n <div class=\"tab_content d\">\r\n <p>ddddd</p>\r\n </div>\n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T05:03:08.917",
"id": "45605",
"last_activity_date": "2018-07-14T07:46:24.553",
"last_edit_date": "2018-07-14T07:46:24.553",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45603",
"post_type": "answer",
"score": 0
},
{
"body": "回答ありがとうございます。 \n下記のコードに変更して見ました。\n\n```\n\n $(document).ready(function(){\r\n $('.tabs > .c').trigger('click');\r\n });\r\n \r\n $(function(){\r\n // タブをクリック時\r\n $('.tabs > div').click(function(){\r\n $('.tabs > div,.tab_content').removeClass('active');\r\n \r\n var tabClass = $(this).attr('class');\r\n \r\n $(this).addClass('active');\r\n \r\n $('.tab_content').each(function(){\r\n \r\n if($(this).attr('class').indexOf(tabClass) != -1){\r\n \r\n $(this).addClass('active').fadeIn();\r\n \r\n }else{\r\n $(this).hide();\r\n }\r\n });\r\n });\r\n });\n```\n\n再度ご教授願いできますでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T05:37:50.237",
"id": "45606",
"last_activity_date": "2018-07-14T05:37:50.237",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29310",
"parent_id": "45603",
"post_type": "answer",
"score": 0
}
] | 45603 | 45605 | 45605 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "postgres SQL で複雑な select 文を投げていて、そのパフォーマンスがでていなかったとします。\n\nその select 文を explain してみると、どのように postgres が select\nを実行するかは説明されますが、なぜそのような実行計画がたてられたのかがよくわからない場合、これはどのようにデバッグされるのでしょうか。\n\nMySQL では optimizer trace があるので、それを眺めているとなんとなく、オプティマイザがどう動いたのかが理解できるのですが、\npostgres ではどうなのだろと思い、質問しています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T04:45:14.293",
"favorite_count": 0,
"id": "45604",
"last_activity_date": "2018-07-14T15:40:02.627",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 0,
"tags": [
"postgresql"
],
"title": "postgres の select 実行計画のデバッグをするには",
"view_count": 153
} | [
{
"body": "PostgreSQLのマニュアルでいうと、[プランナで使用される統計情報](https://www.postgresql.jp/document/10/html/planner-\nstats.html)に実行計画の決定条件が記載されています。これを読んで出てきた実行計画が期待のものか判断することができると思います。\n\n#ただ、実行計画を「チューニング」することはあっても「デバッグ」することはほとんどないかと思います。(SQL文に対し静的に決まるものではなく、テーブルデータ数等で動的に変化するものなので) \n実行計画を制御するなら、hint句(要 `pg_hint_plan`パッケージ)を使用する方法もあります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T15:40:02.627",
"id": "46615",
"last_activity_date": "2018-07-14T15:40:02.627",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20098",
"parent_id": "45604",
"post_type": "answer",
"score": 0
}
] | 45604 | null | 46615 |
{
"accepted_answer_id": "45611",
"answer_count": 2,
"body": "[Basic HTTP auth with Scotty](https://ro-che.info/articles/2016-04-14-scotty-\nhttp-basic-auth)を読んで、`Data.SecureMem`というモジュールを使うと、タイミング攻撃を防止(軽減?)できることを知りました。\n\nその後SecureMemについて調査してみたのですが、あまり情報がなく、唯一参考になりそうなのが[`Data.SecureMem`のドキュメント](http://hackage.haskell.org/package/securemem-0.1.10/docs/Data-\nSecureMem.html)の次の記述でした。\n\n> SecureMem is a memory chunk which have the properties of: \n> ● Being scrubbed after its goes out of scope. \n> ● A Show instance that doesn't actually show any content \n> ● A Eq instance that is constant time\n\nそこで質問なのですが、これら3つの性質が一般的にはどのようなセキュリティ上の利点をもたらしてくれるのか、特にタイミング攻撃に対してなぜ有効なのか、そして「定数時間での比較」とは何を意味するのかを教えてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T05:53:41.600",
"favorite_count": 0,
"id": "45608",
"last_activity_date": "2018-07-14T13:41:48.667",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13199",
"post_type": "question",
"score": 3,
"tags": [
"security",
"haskell"
],
"title": "SecureMemを使用することのセキュリティ上の利点について",
"view_count": 89
} | [
{
"body": "> * Being scrubbed after its goes out of scope.\n>\n\n上記は、不要になったスコープ外の変数をクリアすることで、プログラム実行時のメモリイメージから機密データが漏洩するのを防止しているのだと思います。\n\n> * A Show instance that doesn't actually show any content\n>\n\n上記は、インスタンスの文字列変換時に`<scrubbed-\nbytes>`といった固定の文字列に変換することで、デバッグやログ出力時などに、機密データが漏洩するのを防止しているのだと思います。\n\n> * A Eq instance that is constant time\n>\n\nタイミング攻撃は、データ比較時などの処理時間の差を分析して機密データを検出する攻撃です。 \nそのため、データ比較時間が常に一定であれば防ぐことができます。 \n(参考: [実装の隙を突く「タイミング攻撃」とは?](https://corgi-lab.com/programming/timing-attack/) )\n\n[hs-securemem/cbits/utils.c#L73](https://github.com/vincenthz/hs-\nsecuremem/blob/master/cbits/utils.c#L73)にあるように、配列の全ての要素を常に比較することにより、データ比較時間を一定にし、タイミング攻撃を防止しているのだと思います。\n\n```\n\n for (i = 0; i < size; i++)\n acc &= (p1[i] == p2[i]);\n return acc;\n \n```\n\n一方、以下のような比較処理の場合、データ内容によりループ回数が変わるため、処理時間の差を利用したタイミング攻撃の対象となります。\n\n```\n\n for (i = 0; i < size; i++) {\n if (p1[i] != p2[i])\n return 0; // 不一致を返却\n }\n return 1; // 一致を返却\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T12:14:15.923",
"id": "45611",
"last_activity_date": "2018-07-14T13:41:48.667",
"last_edit_date": "2018-07-14T13:41:48.667",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45608",
"post_type": "answer",
"score": 3
},
{
"body": "あまり自信がないのですが、\n\n> ● Being scrubbed after its goes out of scope.\n\n変数のスコープを抜けたとき、つまりその変数が不要になったときにそのセキュアなデータの乗ったメモリーの領域を別のデータ(ランダム値など)で上書きすることだと思います。そうすることで例えば別のプログラムなどがその領域を利用した場合にデータが漏れることが防げます。\n\n> ● A Show instance that doesn't actually show any content\n\nこれはうっかり `show` してしまっても大丈夫なようにということでしょうか。(あまり分かりません。)\n\n> ● A Eq instance that is constant time\n\ntrue もしくは false\nが返るまでにかかる時間によって比較対象の隠されてる値が推測できるので「定数時間での比較」をすることでそれを防げるということだと思います。例えば文字列の比較などで単純な先頭からの比較の場合、“abc”\nに対して “a” と “b” では結果の返る時間に差ができてしまいます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T12:14:39.707",
"id": "45612",
"last_activity_date": "2018-07-14T12:14:39.707",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "153",
"parent_id": "45608",
"post_type": "answer",
"score": 1
}
] | 45608 | 45611 | 45611 |
{
"accepted_answer_id": "46613",
"answer_count": 1,
"body": "自分のソフト外の適当なウェブサイトなどから、文章をコピペして、 \nそれをテキストエディタで保存して、再度復元したいと思っています。 \n例えばなのですが、このサイトからタイトル部分をコピペしてきました。 \n[Matahari Wikipedia](https://id.wikipedia.org/wiki/Matahari)\n\n[](https://i.stack.imgur.com/6F7kx.png)\n\nすると、こんな感じになります。 \n[](https://i.stack.imgur.com/cDELS.png)\n\nKey_1を押して、その内容をセーブしました。\n\nその後、再起動を行い、前のデータを復元してみました。\n\n[](https://i.stack.imgur.com/GbIA1.png)\n\nすると、常に、ロードしたテキストは真っ暗になります。\n\nmimedata.html()を調べてみますと、\n\n```\n\n <!--StartFragment--><span style=\"display: inline !important; float: none; background-color: transparent; color: rgb(0, 0, 0); font-family: "Linux Libertine","Georgia","Times",serif; font-size: 28.8px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 37.44px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;\">Matahari</span><!--EndFragment-->\n \n```\n\n色のところが、 (0,0,0). つまり、黒色がデフォルトで指定されています。 \nだから、この部分を書き換えればいいじゃないかと思ったんで、\n\n```\n\n clipboard = QtGui.QApplication.clipboard() \n html = clipboard.mimeData().html()\n print(html)\n html = html.replace(\"color: rgb(0, 0, 0);\",\"color: rgb(255, 255, 255);\")\n clipboard.mimeData().setHtml(html)\n \n \n \n \n <!--StartFragment--><span style=\"display: inline !important; float: none; background-color: transparent; color: rgb(255, 255, 255); font-family: "Linux Libertine","Georgia","Times",serif; font-size: 28.8px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 37.44px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;\">Matahari</span><!--EndFragment-->\n \n```\n\nプリント文で打ちだしたら、確かに(255,255,255)になり、 \n白になっているはずなのですが、こうして、再度書き換えたhtmlの内容をセットして、再度ロードしてみましたが、結果は相変らずでした。\n\n背景が真っ黒にならないようにしたいのですが、どうすればいいんでしょうか?\n\nこちらが、実行可能なサンプルコードです。\n\n```\n\n from PySide import QtGui\n \n from PySide import QtCore\n import sys\n import os\n class TextEdit(QtGui.QTextEdit):\n def __init__(self,parent=None):\n super(TextEdit,self).__init__(parent=None)\n def keyPressEvent(self,event):\n if event.key() == QtCore.Qt.Key_1:\n self.save()\n return\n elif event.key() == QtCore.Qt.Key_2:\n self.load()\n return\n elif event.key() == QtCore.Qt.Key_V:\n self.copy_paste()\n return\n return QtGui.QTextEdit.keyPressEvent(self,event)\n def save(self):\n print(os.getcwd()+\"copy_paste_test.dat\")\n file = QtCore.QFile(os.getcwd()+\"copy_paste_test.dat\")\n file.open(QtCore.QFile.ReadWrite)\n out = QtCore.QDataStream(file)\n out.writeQString(self.toHtml())\n file.close()\n def load(self):\n file = QtCore.QFile(os.getcwd()+\"copy_paste_test.dat\")\n file.open(QtCore.QFile.ReadOnly)\n out = QtCore.QDataStream(file)\n self.insertHtml(out.readQString())\n file.close()\n def copy_paste(self):\n \n clipboard = QtGui.QApplication.clipboard()\n self.insertFromMimeData(clipboard.mimeData()) \n \n def main():\n try:\n QtGui.QApplication([])\n except Exception as e:\n print(e)\n textedit = TextEdit()\n textedit.show()\n sys.exit(QtGui.QApplication.exec_())\n if __name__ == \"__main__\":\n main()\n \n```\n\n実行環境;PySide 1.2.4 Python 3.6.5 Windows10",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T12:58:08.323",
"favorite_count": 0,
"id": "45613",
"last_activity_date": "2018-07-14T14:02:19.863",
"last_edit_date": "2018-07-14T14:02:19.863",
"last_editor_user_id": "24284",
"owner_user_id": "24284",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pyqt",
"pyside"
],
"title": "QApplication,QClipboard,mimedataで、貼り付けをした後にデータを復元すると、必ずテキストが黒くなる。",
"view_count": 172
} | [
{
"body": "以下が関係しているかもしれません。\n\n[QTextEdit doesn't respect transparency of textBackgroundColor in toHtml()\nmethod](https://bugreports.qt.io/browse/QTBUG-21522)\n\nQt5で修正されているようです。\n\nそのため、無理矢理対応するのであれば、以下のように`background-color`の`transparent`を白に置換してやる必要があると思います。\n\n```\n\n html = html.replace(\"background-color: transparent;\",\"background-color: rgb(255, 255, 255);\")\n \n```\n\n一方、CSSの`color`のカラープロパティは文字色を意味するため、背景色を白にする場合は、置換不要です。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T13:33:29.477",
"id": "46613",
"last_activity_date": "2018-07-14T13:33:29.477",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "45613",
"post_type": "answer",
"score": 1
}
] | 45613 | 46613 | 46613 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "私は現在Pandasのデータフレームにおきまして、全ての行を繰り返して値の変更を行おうとしています。(今回は値から%を取り除こうとしています。)\n\nその際に、下記のような警告文が出てしまいます。また、この警告文が出ると処理に大きな時間がかかります。 \n下記の警告文のサイトへと移動し、dataframe._setitem_with_indexerを使用したのですが、エラーや同様の警告文となり変更することができません。\n\ndf.ilocなどを使用し同じ列名に代入するときの正しい文法を教えていただければ幸いです。 \n左辺と右辺が異なる場合はエラーや警告文は出ませんでした。\n\n> SettingWithCopyWarning: \n> A value is trying to be set on a copy of a slice from a DataFrame \n> See the caveats in the documentation: <http://pandas.pydata.org/pandas-\n> docs/stable/indexing.html#indexing-view-versus-copy>\n\n・変更前のコード\n\n```\n\n for i in range(len(df)):\n df['column'].iloc[i] = (df['column'].iloc[i].split('%'))[0]\n \n```\n\n・変更後のコード\n\n```\n\n for i in range(len(df)):\n df['column'].iloc._setitem_with_indexer(i, (df['column'].iloc[i].split('%'))[0])\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T14:34:01.020",
"favorite_count": 0,
"id": "46614",
"last_activity_date": "2018-07-15T01:13:41.950",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28490",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"pandas"
],
"title": "Pandasの繰り返し文での代入について",
"view_count": 2578
} | [
{
"body": "```\n\n import pandas as pd\n df = pd.DataFrame([[\"abc%def\",15],[\"efg%ghi\",22]],columns =[\"column\",\"num\"])\n \n```\n\nをサンプルデータとします。 \n目的を満たす簡便な方法としては次のような記述が挙げられます。\n\n```\n\n df[\"column\"]=df[\"column\"].apply(lambda s:s.split(\"%\")[0])\n \n```\n\nおおよそギガバイト級のデータを扱わない限り上記の記述で十分だと思います。 \nもう少しテクニカルな記述としては、numpyのvectorizeを使う手段があります。 \nこっちのほうが上記よりちょっと早いです。\n\n```\n\n import numpy as np\n f = np.vectorize(lambda s:s.split(\"%\")[0])\n df[\"column\"] = f(df[\"column\"])\n \n```\n\nもっと早くする方法としては、cythonやnumbaといったライブラリを使用して静的型付けを行い、コンパイルを行う方法がありますが、numbaのほうはstring型を最適化できないようなので特殊な処理が必要となるようです。cythonについては私も理解が不十分なので紹介に留めます。\n\n下記に参考にしたサイトを記述します。 \n<https://pandas.pydata.org/pandas-docs/stable/enhancingperf.html>",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T00:13:57.280",
"id": "46622",
"last_activity_date": "2018-07-15T00:13:57.280",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25980",
"parent_id": "46614",
"post_type": "answer",
"score": 1
},
{
"body": "`SettingWithCopyWarning`というのは、次のようにすると、まず`df['column']`を計算して、それを使って`iloc[i]`を計算するので、処理に大きな時間がかかるという警告です。\n\n```\n\n df['column'].iloc[i]\n \n```\n\n次のように書くと計算が1回で済むから早くなります。\n\n```\n\n df.loc[i, 'column'] \n \n```\n\n今回の問題はそれだけではないですね。Pandasを使うときに`for`を使うと計算が非常に遅くなります。この場合だと次のように`str`アクセサを使うことで、データの各要素に対して文字列メソッドを適用することができるので、簡単にかけて高速に処理できます。\n\n```\n\n df['column'] = df['column'].str.split('%')[0]\n \n```\n\nまた、%が右側についているので数値にできないという場合がよくあるのですが、その場合は`rstrip`が使えるので簡単にかけて処理も速いです。\n\n```\n\n df['column'] = df['column'].str.rstrip('%')\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T01:06:13.360",
"id": "46623",
"last_activity_date": "2018-07-15T01:13:41.950",
"last_edit_date": "2018-07-15T01:13:41.950",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "46614",
"post_type": "answer",
"score": 2
}
] | 46614 | null | 46623 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n ZeroDivisionError: integer division or modulo by zero\n \n```\n\n以下がコードです.\n\n```\n\n def Euclidean_algo(m, n):\n \n while m%n != 0:\n m = n\n n = m%n\n else:\n return n\n \n \n m = int(input('the bigger int is :'))\n n = int(input('the smaller int is :'))\n print(Euclidean_algo(m, n))\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T16:53:40.383",
"favorite_count": 0,
"id": "46616",
"last_activity_date": "2018-07-15T01:15:03.003",
"last_edit_date": "2018-07-15T01:15:03.003",
"last_editor_user_id": null,
"owner_user_id": "29315",
"post_type": "question",
"score": 1,
"tags": [
"python",
"アルゴリズム"
],
"title": "ユークリッドの互除法でZeroDivisionErrorが発生する原因について",
"view_count": 376
} | [
{
"body": "私も一瞬ユークリッドの互除法を正しく実装しているように見えたのですが、実行してみてやっと気づきました。\n\nこの2行\n\n```\n\n m = n\n n = m%n\n \n```\n\n最初に`m`へ現在の`n`の値が代入されるので、2行目の`n =\nm%n`が実行される時には`m`と`n`の値が同じになっています。よって、`m%n`の結果は必ず`0`になってしまいますから、ループの次の条件判定`m%n\n!= 0`の中で`n`が`0`なのでゼロ除算例外が発生してしまうわけです。\n\n単純に2行の順番を入れ替えると今度は`m`に入れるべき古い方の`n`の値が失われてしまいます。pythonなら同時に代入してしまえば良いでしょう。\n\n```\n\n def Euclidean_algo(m, n):\n while m % n != 0:\n m, n = n, m % n\n return n\n \n```\n\nこんな定義にして試してみてください。ちなみにユークリッドの互除法は二数の大小関係に関わらず働くので、`m`が大きい方の数、なんて指定は不要です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T17:28:04.970",
"id": "46618",
"last_activity_date": "2018-07-14T17:28:04.970",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "46616",
"post_type": "answer",
"score": 4
}
] | 46616 | null | 46618 |
{
"accepted_answer_id": "46621",
"answer_count": 1,
"body": "初心者です。ご助力お願いいたします。 \nupdate_attributeの実行方法がわかりません。 \nfindを使ってupdate_attributeをしようとしたところ以下のエラーが出ました。\n\n```\n\n irb(main):034:0> @user = User.find(1)\n \n irb(main):035:0> @user.update_attribute(name: \"ABC\")\n Traceback (most recent call last):\n 1: from (irb):35\n ArgumentError (wrong number of arguments (given 1, expected 2))\n \n irb(main):036:0> @user.update_attributes(name: \"ABC\")\n (0.2ms) BEGIN\n (0.2ms) COMMIT\n => true\n \n```\n\nなぜupdate_attributesではエラーが出ずにupdate_attributeではエラーがでるのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T17:43:45.427",
"favorite_count": 0,
"id": "46620",
"last_activity_date": "2018-07-15T09:06:33.077",
"last_edit_date": "2018-07-15T09:06:33.077",
"last_editor_user_id": null,
"owner_user_id": "29317",
"post_type": "question",
"score": 2,
"tags": [
"ruby-on-rails"
],
"title": "update_attributeの実行方法について",
"view_count": 2280
} | [
{
"body": "> なぜupdate_attributesではエラーが出ずにupdate_attributeではエラーがでるのでしょうか?\n\n`update_attribute`の呼び出し方が間違っていることが原因です。 \n以下のように呼び出すと実行できると思います。\n\n```\n\n @user.update_attribute(:name, \"ABC\")\n \n```\n\n* * *\n\n## update_attribute\n\n`update_attribute`は1つの属性のみを更新・保存するメソッドになります。 \n以下のように、属性名とその値を指定し使用します。(参考:\n[update_attribute](https://apidock.com/rails/ActiveRecord/Persistence/update_attribute))\n\n```\n\n # 引数が2つ\n update_attribute(name, value)\n \n```\n\nそのため、以下で実行できると思います。\n\n```\n\n @user.update_attribute(:name, \"ABC\")\n \n```\n\n## update_attributes\n\n一方、`update_attributes`は複数の属性をまとめて更新・保存するメソッドになります。 \n以下のように使用します。([参考:\nupdate_attributes](https://apidock.com/rails/ActiveRecord/Persistence/update_attributes))\n\n```\n\n # 引数がハッシュ\n update_attributes(attributes)\n \n```\n\n引数の`attributes`部分にはハッシュを渡すことができます。 \n引数にハッシュを渡すことで複数の属性をまとめて更新・保存できます。\n\n```\n\n # 引数がハッシュ {name: \"ABC\", age: 10}部分がハッシュ\n @user.update_attributes({name: \"ABC\", age: 10})\n # rubyでは、メソッドの末尾の引数のハッシュは`{, }`を省略できるので\n # 以下も同じ意味になります。\n @user.update_attributes(name: \"ABC\", age: 10)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-14T17:52:40.320",
"id": "46621",
"last_activity_date": "2018-07-14T18:31:38.193",
"last_edit_date": "2018-07-14T18:31:38.193",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46620",
"post_type": "answer",
"score": 2
}
] | 46620 | 46621 | 46621 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "rails で、 pdf ダウンロードを実装しようとしています。\n\nこの pdf は、以下の処理によって生成される想定です。\n\n 1. テンプレート pdf0\n 2. prawn によって生成される pdf1\n 3. [combine_pdf](https://github.com/boazsegev/combine_pdf) で生成される pdf2 == pdf0 + pdf1\n 4. pdf2 を send_file\n\nこのように実装をするとき、おそらく、 pdf1 と pdf2 は動的にファイルを生成する必要がありそうだ、と思っています。\n\npdf ファイルを動的に生成するということは、 rails はウェブアプリケーションなので、同期(排他制御)の問題がでてくるかと思っています。\n\n### 質問\n\n * pdf ダウンロード機能実現のために、生成される中間・最終 pdf ファイルをサーバーのどこかに保存しておきたいと思っています。これは、ダウンロードが完了すればそれ以上必要のないファイルです。このようなファイルは、どこに生成しておくのが、 rails 的には良いのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T04:58:51.973",
"favorite_count": 0,
"id": "46624",
"last_activity_date": "2018-07-16T08:05:32.647",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails"
],
"title": "rails で、 send_file するための一時的な pdf ファイルの置き場",
"view_count": 974
} | [
{
"body": "> ダウンロードが完了すればそれ以上必要のないファイルです。このようなファイルは、どこに生成しておくのが、 rails 的には良いのでしょうか?\n\n1つの物理サーバーにrailsアプリを載せるようなシンプルな構成であれば、`Rails.root`直下の`tmp`で良いと思います。\n\nただ、railsアプリの新しいバージョンのdeploy後(`Rails.root`全体が切り替わった場合)も生成済のファイルをダウンロード可能としたいのであれば、OS側の容量の許すディレクトリ(linuxの場合`/tmp`や`/var/tmp`、または、railsアプリ専用ディレクトリ)に生成すれば良いと思います。\n\nまた、複数の物理サーバーにrailsアプリを載せるような構成の場合は、物理サーバー間で共有できるディレクトリに生成する必要があると思います。(クラウドであれば、`S3`などに格納し、`send_data`を使ってダウンロードする)\n\nいずれにしても、非同期にファイルを生成する方式に何を採用するかは不明ですが、生成したファイルのパスが一意になるようにする必要があると思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T09:35:10.817",
"id": "46629",
"last_activity_date": "2018-07-16T08:05:32.647",
"last_edit_date": "2018-07-16T08:05:32.647",
"last_editor_user_id": "3271",
"owner_user_id": null,
"parent_id": "46624",
"post_type": "answer",
"score": 1
}
] | 46624 | null | 46629 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[類似の質問](https://ja.stackoverflow.com/questions/40200/heroku%E3%81%ABmecab%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84)がありましたが、回答がありませんでしたので質問させていただきます。\n\nタイトルの通り、MeCabを用いたSinatraアプリをHerokuにデプロイしようとしています。\n\n# 環境\n\nローカルPC:Mac OSX\n\n```\n\n $heroku -v\n heroku/7.6.0 darwin-x64 node-v10.6.0 # homebrewで入れました\n \n $ruby -v\n ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]\n \n $gem list | grep sinatra\n sinatra (2.0.3, 2.0.2)\n \n $mecab -v\n mecab of 0.996 # homebrewで入れました\n \n```\n\nherokuのOS:Ubuntu\n\n```\n\n $heroku run bash\n $ cat /etc/lsb-release \n DISTRIB_ID=Ubuntu\n DISTRIB_RELEASE=16.04\n DISTRIB_CODENAME=xenial\n DISTRIB_DESCRIPTION=\"Ubuntu 16.04.4 LTS\"\n \n```\n\n# 私のGemfile\n\n```\n\n source \"https://rubygems.org\"\n gem \"sinatra\"\n gem \"sinatra-contrib\"\n gem \"mecab\", \"0.996\"\n gem \"natto\"\n gem \"pry\"\n \n```\n\n# heroku buildpacks\n\n```\n\n $heroku buildpacks\n === mecab-on-sinatra Buildpack URLs\n 1. https://github.com/heroku/heroku-buildpack-ruby.git\n 2. https://github.com/diasks2/heroku-buildpack-mecab.git\n \n```\n\n# エラー\n\n```\n\n extconf.rb:12:in ``': No such file or directory - mecab-config (Errno::ENOENT)\n from extconf.rb:12:in `<main>'\n An error occurred while installing mecab (0.996), and Bundler cannot continue.\n Make sure that `gem install mecab -v '0.996'` succeeds before bundling.\n \n In Gemfile:\n mecab\n \n```\n\n# 試したこと\n\n```\n\n $ heroku run bash\n \n```\n\nでherokuのbashに入って`gem install mecab -v '0.996'`しようとしたところパーミッションがなく、 \nsudoをつけたらsudoコマンドがnot foundでした…。\n\nどうすればこれらを解決してアプリをデプロイできるでしょうか。ご教示ください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T07:34:21.940",
"favorite_count": 0,
"id": "46625",
"last_activity_date": "2018-07-19T21:40:57.863",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29320",
"post_type": "question",
"score": 2,
"tags": [
"ruby",
"ubuntu",
"heroku",
"mecab",
"sinatra"
],
"title": "MeCabを用いたSinatraアプリをHerokuにデプロイする方法をご教示ください。",
"view_count": 428
} | [
{
"body": "長文失礼します。\n\n質問者さんの環境とは異なりますが、以下の組み合わせが最小構成だと思われれます。ご参考になれば。\n\n## ファイル構成\n\n```\n\n mecab_on_heroku // 任意のディレクトリ名\n ├── .gitignore\n ├── Gemfile\n ├── Gemfile.lock\n ├── Procfile\n └── app.rb\n \n```\n\n### .gitignore\n\n```\n\n /vendor\n \n```\n\n### Gemfile\n\n```\n\n ruby \"2.3.7\"\n source 'https://rubygems.org'\n gem 'sinatra'\n gem 'mecab', '0.996'\n \n```\n\n### Procfile\n\n```\n\n web: ruby app.rb\n \n```\n\n### app.rb\n\n```\n\n require 'sinatra'\n require 'mecab'\n \n get '/' do\n str = \"我々宇宙人は地球を侵略しに来ました。\"\n tagger = MeCab::Tagger.new\n \"#{tagger.parse(str)}\"\n end\n \n```\n\nGemfile.lock は Gemfile を保存してから以下のコマンドを実行すると作成されます。\n\n### Gemfile.lock 生成のためのコマンド実行\n\n```\n\n $ bundle install --path vendor/bundle\n \n```\n\n## heroku のデプロイ\n\n```\n\n $ cd mecab_on_heroku # 任意の作業ディレクトリ\n $ heroku create -a heroku_app_name --buildpack \\\n https://github.com/diasks2/heroku-buildpack-mecab.git\n $ heroku config:set LD_LIBRARY_PATH=/app/vendor/mecab/lib\n \n```\n\n上記 5つのファイルを作成したのち、下記のコマンドを実行してデプロイします。\n\n```\n\n $ git add .\n $ git commit -m \"first commit.\"\n $ git push heroku master\n \n```\n\n## 動作確認\n\n以下のコマンドを実行すると、自動でデフォルトブラウザが開いて Sinatra アプリにアクセスします。\n\n```\n\n $ heroku open\n \n```\n\n[heroku](/questions/tagged/heroku \"'heroku' のタグが付いた質問を表示\")\n[sinatra](/questions/tagged/sinatra \"'sinatra' のタグが付いた質問を表示\")\n[ruby](/questions/tagged/ruby \"'ruby' のタグが付いた質問を表示\")\n[mecab](/questions/tagged/mecab \"'mecab' のタグが付いた質問を表示\")",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-19T14:31:12.660",
"id": "46733",
"last_activity_date": "2018-07-19T21:40:57.863",
"last_edit_date": "2018-07-19T21:40:57.863",
"last_editor_user_id": "29378",
"owner_user_id": "29378",
"parent_id": "46625",
"post_type": "answer",
"score": 1
}
] | 46625 | null | 46733 |
{
"accepted_answer_id": "46627",
"answer_count": 1,
"body": "現在、Javaでvncのような画面共有ソフトを開発したいと考えています \nパソコンをモニターにつなぐとモニターの大小関係なくきれいに表示されると思いますが小さいモニターで撮ったスクリーンショットを大きなモニターで大画面で表示しようとすると荒く表示されると思います。 \nスクリーンショットとは別の方法でOSから出力される画面の情報を入手しモニターの大小関係なくきれいに表示したいです。Javaのライブラリやgithubなどを見ましたがまだ調べる能力が足りずこの問題を解決する方法を得ることはできませんでした。どこに自分が必要としている情報があるのかわかりません。 \nvncなどはこれをどうやって解決しているのでしょうか \nこの問題を解決するJavaのライブラリはあるのでしょうか \n回答よろしくお願いします",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T08:27:56.917",
"favorite_count": 0,
"id": "46626",
"last_activity_date": "2018-07-15T09:19:20.453",
"last_edit_date": "2018-07-15T09:19:20.453",
"last_editor_user_id": "24999",
"owner_user_id": "24999",
"post_type": "question",
"score": 1,
"tags": [
"java"
],
"title": "javaで画面共有を行うライブラリについて(スクリーンショット以外の方法)",
"view_count": 261
} | [
{
"body": "本家のstackoverflowに関連しそうな質問がありました。\n\n[Java VNC Libraries](https://stackoverflow.com/questions/66504/java-vnc-\nlibraries)\n\nこの回答にあるように、[Download\nTightVNC](http://www.tightvnc.com/download.html)の`TightVNC source\ncode`にC++ですがサーバー側のソースがあり、 \n同様に、`TightVNC Java Viewer source code`にJavaのビューア(クライアント)側のソースがあります。\n\nこれらのソースが参考になると思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T08:56:37.010",
"id": "46627",
"last_activity_date": "2018-07-15T08:56:37.010",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46626",
"post_type": "answer",
"score": 0
}
] | 46626 | 46627 | 46627 |
{
"accepted_answer_id": "46655",
"answer_count": 1,
"body": "お世話になっております。ノベルゲームを作っているものです。 \nタイトル通り画像表示について困っています。\n\n私はキャラをベースの体、腕、目、口に分けていて、それらを重ねて表示し、ボタンを押したときに画像を変える処理を書きました。しかし、実機で試したところボキャラを表示する動作がUXにかかわるくらい遅いのです。 \nなぜ、普通のノベルゲームのようにサクサク動かないのでしょうか?これを改善するにはどうすればいいのでしょうか? \n下に記すコードはキャラを表示するactivityのメソッドです。\n\n```\n\n public void message(View view) {\n //メッセージのビューに名前テキストを入れるメソッド\n mes();\n //名前のビューに名前テキストを入れるメソッド\n name();\n //キャラのビューにキャラを入れるメソッド\n chara();\n \n int num = Integer.parseInt(number);\n num++;\n number = String.valueOf(num);\n }\n \n private void mes(){\n Resources res = getResources();\n Button message = findViewById(R.id.message);//メッセージボタンのidを取得。\n int strId = getResources().getIdentifier(\"message\" + number, \"string\", getPackageName());//numberを使い動的にIdを取得。\n message.setText(res.getString(strId));\n }\n \n private void name() {\n Resources res = getResources();\n TextView name=findViewById(R.id.name);//名前テキストビューのIDを取得。\n int nameId = getResources().getIdentifier(\"name\" + number, \"string\", getPackageName());//numberを使い動的にIdを取得。\n name.setText(res.getString(nameId));\n }\n private void chara() {\n ImageView base = (ImageView) findViewById(R.id.base);\n int baseId = getResources().getIdentifier(\"base\" + number, \"string\", getPackageName());\n base.setImageResource(baseId);/\n \n ImageView ude = (ImageView) findViewById(R.id.ude);得。\n int udeId = getResources().getIdentifier(\"ude\" + number, \"string\", getPackageName());\n ude.setImageResource(udeId);\n \n ImageView me = (ImageView) findViewById(R.id.me);\n int meId = getResources().getIdentifier(\"me\" + number, \"string\", getPackageName());\n me.setImageResource(meId);\n \n ImageView kuchi = (ImageView) findViewById(R.id.kuchi);\n int kuchiId = getResources().getIdentifier(\"kuchi\" + number, \"string\", getPackageName());。\n kuchi.setImageResource(kuchiId);\n \n }\n \n```\n\n一応、自分で考えた解決策で、解像度を下げること、キャラを一枚にまとめること、この二つを出しました。 \n前者は、試したところ画像の質が許容できないくらい下がってしまい、却下となりました。 \n後者はまだ試していません。やはり細やかな表情を出すために、部分分けはしたいです。それに部分分けしたほうがアプリが重くならないと思うのです。(実際に、ほかのノベルゲーム製作エンジンでは部分分けをしていました。)\n\nこの他にどんな対策が考えられるでしょうか? \nはっきりいって今、私は深い森の中で道を見失ってしまっているような状態です。 \nこの森を抜けだす、方角だけでも、指針だけでも教えていただけると助かります。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T09:09:05.243",
"favorite_count": 0,
"id": "46628",
"last_activity_date": "2018-07-17T00:58:31.470",
"last_edit_date": "2018-07-17T00:58:31.470",
"last_editor_user_id": "3060",
"owner_user_id": "29321",
"post_type": "question",
"score": 1,
"tags": [
"android",
"java"
],
"title": "Androidアプリで画像切り替えの遅さを改善するには",
"view_count": 789
} | [
{
"body": "androidのことは詳しくないですが参考までに思ったことを記述します。 \ngetResources()が呼ばれすぎだと思います。 \nデータリソース(画像類)は別に動的に追加するつもりはないですよね? \n動的に組み合わせたいだけでデータ自体は静的なものだと思います。 \nそれならばActivityのフィールドに\n\n```\n\n Resources res;\n \n```\n\nを宣言してOnCreate()にてres=getResources()を一度だけ代入すればよさそうに思えます。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T08:51:32.827",
"id": "46655",
"last_activity_date": "2018-07-16T08:51:32.827",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25980",
"parent_id": "46628",
"post_type": "answer",
"score": 2
}
] | 46628 | 46655 | 46655 |
{
"accepted_answer_id": "46632",
"answer_count": 1,
"body": "下記のコードのコードを実行すると、ブラウザ側ではこのように表示されてしまいます。 \n[](https://i.stack.imgur.com/SGvLW.png) \n下記のコードのdivを文字列ではなく、HTMLとして読み込ませるにはどうしたら良いのでしょうか。\n\nご回答頂けますと、幸いです。\n\n```\n\n # 以上略\n @app.route('/')\n def index():\n \n div = '<div>test</div>'\n \n return render_template('index.html', div=div)\n # 以下略\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T10:17:54.937",
"favorite_count": 0,
"id": "46630",
"last_activity_date": "2018-07-15T10:48:59.920",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29108",
"post_type": "question",
"score": 3,
"tags": [
"python",
"flask"
],
"title": "Flaskで変数を文字列ではなくHTMLのタグとして読み込ませたい",
"view_count": 5008
} | [
{
"body": "[Passing HTML to template using\nFlask/Jinja2](https://stackoverflow.com/questions/3206344/passing-html-to-\ntemplate-using-flask-jinja2)に同様の質問がありました。 \nまた、[Flask\nメモ](https://qiita.com/Prismo/items/7bfd6cd3b4b651b6094f)に参考となるコードがありました。\n\n方法は2つあるそうです。\n\n 1. MarkupSafe.Markupを使い変数をsafeにする\n 2. テンプレート内で `|safe`フィルターを使い変数をsafeにする\n\n## 1. MarkupSafe.Markupを使い変数をsafeにする\n\n```\n\n from flask import Markup\n # 略\n \n @app.route('/')\n def index():\n div = Markup('<div>test</div>') # divはエスケープ不要なsafeとして扱われる\n return render_template('index.html', div=div)\n \n```\n\n## テンプレート内で |safeフィルターを使い変数をsafeにする\n\nテンプレート内で、div変数を `|safe`フィルターを使いsafeにする。\n\n```\n\n <body>\n {{ div | safe }}\n </body>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T10:48:59.920",
"id": "46632",
"last_activity_date": "2018-07-15T10:48:59.920",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46630",
"post_type": "answer",
"score": 1
}
] | 46630 | 46632 | 46632 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "```\n\n import cv2\n \n file=\"face_01.jpg\"\n img=cv2.imread(file)\n imgray=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n h,w=imgray.shape\n print(imgray[60][39])\n \n```\n\nこれを実行すると`IndexError: index 60 is out of bounds for axis 0 with size\n40`とエラーが出ます。imgrayの座標[60][39]が白か黒かを調べたいのでこのような実行をしました。ちなみにh=40,w=67です。解決策を教えてほしいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T10:26:51.540",
"favorite_count": 0,
"id": "46631",
"last_activity_date": "2018-07-16T03:05:59.050",
"last_edit_date": "2018-07-15T11:04:30.100",
"last_editor_user_id": "19110",
"owner_user_id": "29322",
"post_type": "question",
"score": 5,
"tags": [
"python",
"opencv"
],
"title": "python opencv エラー 画像処理 index",
"view_count": 546
} | [
{
"body": "[Accessing and Modifying pixel\nvalues](https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.html#accessing-\nand-modifying-pixel-values)によると、 \n以下でpixel値を取得できるようです。\n\n```\n\n px = img[100,100]\n \n```\n\n環境がないため確認できませんが、 \n以下で解決するかもしれません。\n\n```\n\n import cv2\n \n file=\"face_01.jpg\"\n img=cv2.imread(file)\n imgray=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\n h,w=imgray.shape\n print(imgray[39,60])\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T11:04:00.330",
"id": "46633",
"last_activity_date": "2018-07-15T11:04:00.330",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46631",
"post_type": "answer",
"score": 0
},
{
"body": "OpenCVでは、配列(ndarray)の添字の順番は(x,y(,c))ではなく、(y,x(,c))になっています。 \nこれは恐らく、メモリの連続性を考えた時に、普通画像はx方向にメモリを連続に確保するためにyが先になっています。 \nご質問のコードは添字のxとyが逆になっているために、画像の範囲外へのアクセスになり、エラーになっているので、添字の順番を変えて、\n\n```\n\n print(imgray[39][60])\n \n```\n\nとすればいいかと。\n\n参考文献: \n<https://stackoverflow.com/questions/19098104/python-opencv2-cv2-wrapper-get-\nimage-size> \nnumpyはC言語と同じ順番でメモリにデータが格納されているので、array[i,j]とした時には添字jについてメモリは連続になります(Fortranとかだと逆なので注意) \n<http://kaisk.hatenadiary.com/entry/2015/02/19/224531>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T02:54:36.293",
"id": "46646",
"last_activity_date": "2018-07-16T03:05:59.050",
"last_edit_date": "2018-07-16T03:05:59.050",
"last_editor_user_id": "18595",
"owner_user_id": "18595",
"parent_id": "46631",
"post_type": "answer",
"score": 4
}
] | 46631 | null | 46646 |
{
"accepted_answer_id": "46635",
"answer_count": 1,
"body": "はじめまして! \nHTML、Javascript、jQueryの初心者です。 \n以下のプログラムで、 \n最初にimage/1.jpgが表示され \nマウスをクリックすると \nimage/2-1.jpgが表示されるようにしたいのですが \n最初の画面から変わりません…\n\n3時間ほどサイトを見てあれこれ試したのですがだめでした。。 \nどうぞよろしくお願いいたします。\n\n```\n\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <title></title>\n <style type=\"text/css\">\n </style>\n <meta name=\"description\" content=\"\"/>\n <link rel=\"stylesheet\" href=\"css/style.css\">\n <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"></script>\n \n </head>\n \n <body>\n <!--ボタンの画像表示-->\n <p class=\"button\">\n <img style=\"width: 100%;\" src=\"image/1.jpg\" alt=\"ボタン\" >\n </p>\n \n <pp class=\"note\">\n <img style=\"width: 100%;\" src=\"image/2-1.jpg\" alt=\"ノート\" >\n </pp>\n \n <!--ボタンを押したら選択画面-->\n <script type=\"text/javascript\">\n $(function()\n {\n $('p').click(function(){\n $('pp').show();\n });\n }); \n </script>\n \n </body>\n </html>\n \n```",
"comment_count": 11,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T11:26:30.273",
"favorite_count": 0,
"id": "46634",
"last_activity_date": "2018-07-15T13:20:26.470",
"last_edit_date": "2018-07-15T13:20:26.470",
"last_editor_user_id": null,
"owner_user_id": "29323",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"html",
"jquery"
],
"title": "jQueryで画像の表示・非表示を切り替える方法について",
"view_count": 834
} | [
{
"body": "> 最初にimage/1.jpgが表示され \n> マウスをクリックすると \n> image/2-1.jpgが表示されるようにしたいのですが\n\n上記を以下のように解釈しました。\n\n 1. 画面初回表示時、`image/1.jpg`は表示、`image/2-1.jpg`は非表示\n 2. `image/1.jpg`をクリック時、`image/1.jpg`は非表示、`image/2-1.jpg`は表示\n 3. `image/2-1.jpg`をクリック時、`image/1.jpg`は表示、`image/2-1.jpg`は非表示\n\njqueryのみで対応するのであれば、以下の実装はいかがでしょうか。\n\n```\n\n $(function() {\r\n // 画面初回表示時\r\n $('p.note').hide();\r\n \r\n // image/1.jpgをクリック時の処理\r\n $('p.button').click(function(){\r\n // 'p.note'を表示\r\n $('p.note').show();\r\n // 'p.button'を非表示\r\n $(this).hide();\r\n });\r\n \r\n // image/2-1.jpgをクリック時の処理\r\n $('p.note').click(function() {\r\n // 'p.button'を表示\r\n $('p.button').show();\r\n // 'p.note'を非表示\r\n $(this).hide();\r\n });\r\n });\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"></script>\r\n <!--ボタンの画像表示-->\r\n <p class=\"button\">\r\n <img style=\"width: 100%;\" src=\"http://placehold.it/600x100/333/ffffff&text=image/1.jpg\" alt=\"ボタン\" >\r\n </p>\r\n \r\n <p class=\"note\">\r\n <img style=\"width: 100%;\" src=\"http://placehold.it/600x100/006600/ffffff&text=image/2-1.jpg\" alt=\"ノート\" >\r\n </p>\n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T12:07:09.113",
"id": "46635",
"last_activity_date": "2018-07-15T13:13:01.707",
"last_edit_date": "2018-07-15T13:13:01.707",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46634",
"post_type": "answer",
"score": 1
}
] | 46634 | 46635 | 46635 |
{
"accepted_answer_id": null,
"answer_count": 4,
"body": "```\n\n def LinearSearch(N, a):\n n = len(N)\n for i in range(n):\n if N[i] == a:\n return True\n \n else:\n return False\n \n N = [13, 16, 23, 45, 54, 58, 76, 91]\n a = 76\n \n ans = LinearSearch(N, a)\n print(ans)\n \n```\n\n結果が何故かfalseになってしまいます、 \nfor文とif文の組み合わせが良くないのでしょうか。 \nよろしくお願いします。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T13:31:44.653",
"favorite_count": 0,
"id": "46636",
"last_activity_date": "2018-07-16T05:35:29.713",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29315",
"post_type": "question",
"score": 0,
"tags": [
"python",
"xcode",
"visual-studio"
],
"title": "線分探索でエラーが出る原因",
"view_count": 102
} | [
{
"body": "> for文とif文の組み合わせが良くないのでしょうか。\n\nそう思います。for文内の最初の`13`を比較する際に、偽となるため、`False`がリターンされ、for文を抜けています。1つの要素しか比較されていません。\n\n例えば、以下のように、for文内は、真の場合のみ`True`を返却し、for文を終了した場合は、`False`を返却するば良いと思います。\n\nいずれにしても、お使いの開発環境で、Pythonをデバッグできるようになると、ご自身で現象の把握とバグの修正ができると思います。\n\n```\n\n def LinearSearch(N, a):\n n = len(N)\n for i in range(n):\n if N[i] == a:\n return True\n return False\n \n \n N = [13, 16, 23, 45, 54, 58, 76, 91]\n a = 76\n \n ans = LinearSearch(N, a)\n print(ans)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T13:44:55.350",
"id": "46637",
"last_activity_date": "2018-07-15T13:44:55.350",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46636",
"post_type": "answer",
"score": 0
},
{
"body": "`LinearSearch` 関数内のループでは、まず最初の要素 `N[0]` と `a` とを比較することになりますが、ここで `N[0]` と `a`\nが等しくなかったら即座に `return False` してしまいます。これがバグの原因です。\n\n実際にはそうではなく、全ての要素と比較した上でどれとも等しくなかったら `return False` する、というようになるはずです。\n\n以下にサンプルコードを書きましたので、必要に応じてご利用ください(マウスカーソルを重ねると表示されます)。\n\n> def LinearSearch(N, a): \n> n = len(N) \n> for i in range(n): \n> if N[i] == a: \n> return True \n> return False",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T13:45:00.280",
"id": "46638",
"last_activity_date": "2018-07-15T13:45:00.280",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "46636",
"post_type": "answer",
"score": 0
},
{
"body": "推測ですが、wakewakameman さんは、以下の様に書こうと思ったのではないでしょうか。\n\n```\n\n def LinearSearch(N, a):\n n = len(N)\n for i in range(n):\n if N[i] == a:\n return True\n else:\n return False\n \n```\n\n# この書き方が間違いというわけでもありませんけれども",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T14:38:46.727",
"id": "46639",
"last_activity_date": "2018-07-15T14:38:46.727",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46636",
"post_type": "answer",
"score": 2
},
{
"body": "おそらくpythonをアルゴリズム学習に使用していると推察されますが、python的な書き方を提示しておきます。\n\n```\n\n N = [13, 16, 23, 45, 54, 58, 76, 91] #Nは自然数を示すのが通例なので、この名付けは推奨しない\n a = 76\n \n```\n\nとして\n\n```\n\n a in N\n \n```\n\nと記述すれば、求める結果が得られます。 \n設問者が提示したコードの流れは、 \nN[0]=13は76ではないのでN[0]==76はFalse、よってelse句以降の文が実行される。 \nreturn Falseで関数LinearSearchを抜けるためforループからも脱出し、そのままFalseとなる。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T05:35:29.713",
"id": "46650",
"last_activity_date": "2018-07-16T05:35:29.713",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25980",
"parent_id": "46636",
"post_type": "answer",
"score": 1
}
] | 46636 | null | 46639 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": ":w !command とする時に、バッファではなくレジスタの内容を渡す方法はありますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T14:58:08.607",
"favorite_count": 0,
"id": "46640",
"last_activity_date": "2018-07-15T16:08:21.060",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29324",
"post_type": "question",
"score": 2,
"tags": [
"vim"
],
"title": "VIMでレジスタの内容をパイプしたい。",
"view_count": 160
} | [
{
"body": "system() の第二引数にコマンドに渡す標準入力を設定できます。\n\n```\n\n :call system(\"my-command\", @/)\n \n```\n\nこの例ではコマンド my-command の標準入力に検索レジスタの内容を書き込んでいます。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T16:08:21.060",
"id": "46642",
"last_activity_date": "2018-07-15T16:08:21.060",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "440",
"parent_id": "46640",
"post_type": "answer",
"score": 4
}
] | 46640 | null | 46642 |
{
"accepted_answer_id": null,
"answer_count": 5,
"body": "現在私の会社ではAPIの名前はapi1,api2,api3というような名前でapiを書いています。 \napiを呼ぶ時、api/v1/api1みたいな感じです。 \nこれだと何の何をするapiかわからないのです。\n\nなぜこういう名前にしたかというと理由は二つあります。 \n・昔apiの数が膨大になった頃、一つ一つに適切な名前をつけることが困難になったから \n・更新するプログラムで子テーブルの要素まで更新する場合、適切な名前が思いつかなくなった。\n\n上記二つの理由から私の会社ではapi{n}という名前でapiを作ることが文化になりました。\n\nまた、APIを作る上で制約等がないためメンバーは、本来getメソッドが正しいところでもpostを使用したりと作る人によってバラバラです。\n\nだから私はどうにかメンテナビリティが高くできないかということやRESTfulなAPIを作るにはどうしたらよいかを考えていて、 \n上司に相談すると、考えた結果api{n}という名前でapiを作ることを決断したとのことでした。\n\n色々調べましたが、私たちと同じように作成している事例を聞いたことないし調べても出てきませんでした。\n\n実際私たちのサービスよりも大きいサービスでAPIの数も私たちのサービスよりも多いサービスはいっぱいあると思います。 \n「apiの数が膨大になり、一つ一つに適切な名前をつけることが困難」という問題も当然あるとと思います。\n\nどう解決しているのかの質問と、どのようにAPIを設計すれば上記のような問題を回避できるのか、RESTfulなAPIで構築できるのか教えていただきたいです。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T16:05:35.473",
"favorite_count": 0,
"id": "46641",
"last_activity_date": "2018-08-12T05:02:52.150",
"last_edit_date": "2018-08-12T05:02:52.150",
"last_editor_user_id": "754",
"owner_user_id": "29325",
"post_type": "question",
"score": 6,
"tags": [
"ruby-on-rails",
"api",
"rest"
],
"title": "APIの数が膨大になった時のAPI名の付け方について質問",
"view_count": 2611
} | [
{
"body": "名前の付け方って難しいですよね。 \nAPIと直接ではなくて申し訳ありませんが、ご指定のような<頭文字>+連番5桁のような名前つけは \n古いシステムではよく採用されているようです。名前空間が狭くて、ユニークな名前を付けづらかった時の名残ではないかと思います。 \nなので、「名前として存在するか」という意味では普通に存在します。 \nそういったシステムをお使いの場合、頭文字+連番で完全に機能を把握している人がいたりして、なかなかモダンな名前つけに変更できないといったことが起きたりもします。\n\n以上、ご参考まで",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-15T21:49:35.733",
"id": "46644",
"last_activity_date": "2018-07-15T21:56:52.283",
"last_edit_date": "2018-07-15T21:56:52.283",
"last_editor_user_id": "10174",
"owner_user_id": "10174",
"parent_id": "46641",
"post_type": "answer",
"score": 0
},
{
"body": "まず大前提として名付けよりもドキュメントやソースコードがしっかりしているほうが遥かに重要だと思います。最低限ドキュメントがあれば機能や動作についての詳述を取得することができるので。 \n設計・開発を行うということは全体像が見えているわけでもない環境下で機能を作り上げていくということなので、そうした状況下で(α,β版)で適切な名づけに拘泥することは無駄だと思います。 \nもしデータベースの管理を行ったことがあるならばよく考えて下さい。APIにおける名前とはデータベースでいうところのIDに相当します、IDは自動連番かハッシュ値を用いますよね?IDにある人為的な値を指定するということに躊躇するでしょう。(それはIDの管理を機械が行うのではなく手動で行うことを意味するから) \nもしもラムダ関数というものをご存知でしたらよく考えてください。ラムダ関数は何故便利なのでしょうか?名前を付ける必要がなく、人間が管理する必要がないからです。 \nAPIの名づけといっても使用できる文字は多くても十数文字ぐらいでしょう。それで機能を詳述しきることは不可能です。 \n名づけに求められることとしては誰がAPIを使用して、その使用者がどのような暗黙的な(前提)知識を保有していて、だからどのような情報を記述せずに済むかという観点が第一。 \n第二にAPIの全体像の中において各APIがどのような立ち位置(階層構造)にあって、どのように部分を為すのか、あるいはAPI同士がどのような差異を持っているのかを明確にし、検索を容易にすること。 \n第三はAPIの名前が極力不変となるように言葉を援用すること。 \nAPIにおける名づけというのは機械的管理を放棄してでも人間的なインターフェースを構築するということだと思いますので、最低限この3要件を満たさないならば名づけの意味がないと思います。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T06:42:12.550",
"id": "46652",
"last_activity_date": "2018-07-16T06:42:12.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25980",
"parent_id": "46641",
"post_type": "answer",
"score": -1
},
{
"body": "日本の会社では、命名規則によって名前をつけるの難しいですよね。事務処理や帳票に英語名がついているケースはあまりないので、プログラムをする時に英語名をつけるのに結構苦労します。\n\nWikipediaの[「命名規則\n(プログラミング)」のページ](https://ja.wikipedia.org/wiki/%E5%91%BD%E5%90%8D%E8%A6%8F%E5%89%87_\\(%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0\\))には、命名規則のビジネス上の価値として次のように書かれています。\n\n>\n> エンドユーザーが識別子の良否を意識することはほとんどないが、システムを引継いでゆくアナリストや開発者にとっては、識別子が適切に選定されていることで、システムが何をしているかを理解したり、さらには新たなビジネス所要に応じてソースコードをどのように修正・拡張すればよいかを判断することが極めて容易となる。\n>\n> 例えば、\n>\n> `a = b * c`\n>\n> コードは文法的に間違っているわけではないが、その意図・意味は見当もつかない。\n>\n> これに対して、\n>\n> `weekly_pay = hours_worked * pay_rate`\n>\n> というコードでは、少なくともアプリケーションの基本的な前後関係を理解している人には意味・意図がよくわかる(weekly_pay =\n> 週給、hours_worked = 勤務時間、pay_rate = 時給)。\n\nこの趣旨は、よく理解できるのですが、命名規則では漢字を使うことは良くないこととされているため、どうしても無理やり英語に翻訳して命名する必要があります。ローマ字で書くという方法もあるのですが漢字と違ってすぐに意味がわからないし長ったらしくなります。そのため、「識別子」を見ても普段使っている言葉でないため理解の助けになるというメリットも減少するし、英語がよくわからない人間が翻訳すると意味不明な英語にすることも多くなってしまいます。\n\n今回は、`API`の命名規則の問題なのですが、CMSやブログでURLをどうするかという問題も同じです。海外ではタイトル名をURLの最後につけるケースが多いのですが、日本語のサイトでそれをやると日本語URLになってしまいます。日本語URLを使うのが嫌な場合には、英語のタイトルを考えるの手間だしユーザーが英語で検索してくれる訳ではないので効果もないので`id`を使うケースは多いです。\n\n結局、英語圏で作られた命名規則をそのまま日本に持ってくるのが問題で、会社や担当者のインターナショナル度を考慮してどうするか判断するしかないように思います。純日本の会社では、レガシーな`<頭文字>+連番`という命名を残した方が結構わかりやすいというケースは多いと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T03:33:51.293",
"id": "46667",
"last_activity_date": "2018-07-17T05:11:53.470",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "15171",
"parent_id": "46641",
"post_type": "answer",
"score": 3
},
{
"body": "メンテナンス性を上げるために略語や造語、記号などは使うべきではないと考えています。 \ncamelCase, snake_case, kebab-caseなど単語で区切って命名したいですが、 \n今のルールを完全に崩壊させると困るということでしたら接頭辞はどうでしょうか? \n接頭辞+命名で何とか管理できませんか?\n\nAPI名を見て機能の概要が分からないのはどうなんでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-18T04:17:41.673",
"id": "46686",
"last_activity_date": "2018-07-18T04:17:41.673",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46641",
"post_type": "answer",
"score": 1
},
{
"body": "すべてにユニークな名前を付けるのは難しくても、大まかな機能のくくりなどで分類してみて \n`接頭辞`+`連番`、などにしてみるとか。 \n過去の名前は残しつつ、可能であれば別名でアクセスする手段も用意して少しずつ整理する…という手もありじゃないでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-18T12:24:51.680",
"id": "46702",
"last_activity_date": "2018-07-18T12:24:51.680",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "46641",
"post_type": "answer",
"score": 1
}
] | 46641 | null | 46667 |
{
"accepted_answer_id": "46651",
"answer_count": 1,
"body": "以下プログラム内の、p.noteの画面いっぱいに表示されている画像の上に \n#flipbookというページがめくれる効果をもつノートを中央に表示させたいのです。 \nいろいろと調べ試してみたのですが、p.noteの下にめくりたいページが12個並んで表示されるだけです…\n\nお手数をおかけし申し訳ございませんが、どうぞよろしくお願いいたします。\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <title></title>\n <style type=\"text/css\">\n </style>\n <meta name=\"description\" content=\"\"/>\n <link rel=\"stylesheet\" href=\"css/style.css\">\n \n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"></script>\n \n <script>\n $(function() {\n // 画面初回表示時\n $('p.note').hide();\n \n // image/1.jpgをクリック時の処理\n $('p.button').click(function(){\n // 'p.note'を表示\n $('p.note').show();\n // 'p.button'を非表示\n $(this).hide();\n });\n });\n </script>\n </head>\n \n <body>\n <!--ボタンの画像表示-->\n <p class=\"button\">\n <img style=\"width: 100%;\" src=\"image/1.jpg\" alt=\"ボタン\" >\n </p>\n \n <!--ノートの画像表示-->\n <p class=\"note\">\n <img style=\"width: 100%;\" src=\"image/2-1.jpg\" alt=\"ノート\" >\n </p>\n \n <!--ノートの切り替え-->\n <div id=\"flipbook\">\n <div><img src=\"image/note_1.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_2_1.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_2_2.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_2_3.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_2_4.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_2_5.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_2_6.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_2_7.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_3_1.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_3_2.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_4_1.jpg\" alt=\"\"></div>\n <div><img src=\"image/note_5_1.jpg\" alt=\"\"></div>\n </div>\n \n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js\"></script>\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/turn.min.js\"></script>\n \n <script type=\"text/javascript\">\n $(function(){\n $('#flipbook').turn({\n width:1000,\n height:600,\n autoCenter: true\n });\n });\n \n </body>\n </html>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T03:23:02.917",
"favorite_count": 0,
"id": "46647",
"last_activity_date": "2018-07-16T11:05:35.800",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29323",
"post_type": "question",
"score": 0,
"tags": [
"html",
"jquery"
],
"title": "本のようにページをパラパラめくる事ができるjQueryプラグイン「turn.js」を使いたいです",
"view_count": 1075
} | [
{
"body": "jQueryプラグインの`turn.js`を使いたいとのことですが、以下のURLには公開されていません。 \nそのため、`turn.js`が利用できずエラーが発生していたのだと思います。\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/turn.min.js\"></script>\n \n```\n\nそのため、実際の公開されている以下のURLから読み込むように修正すると利用できると思います。\n\n```\n\n <script type=\"text/javascript\" src=\"//cdn.jsdelivr.net/turn.js/3/turn.min.js\"></script>\n \n```\n\nまた、[turn.js](https://github.com/blasten/turn.js#turnjs-3rd-\nrelease)には`3rd`と`4th`があるようですが、`4th`は有料です。(上記のURLは`3rd`になります。)\n\n`3rd`版には、`autoCenter: true`といった機能はないようです。 \nそのため、`4th`版の機能が必要な場合は、購入する必要があります。\n\n以下に、改善案のコードを記載します。\n\n```\n\n <!DOCTYPE html>\r\n <html>\r\n <head>\r\n <meta charset=\"UTF-8\">\r\n <title></title>\r\n <style type=\"text/css\">\r\n </style>\r\n <meta name=\"description\" content=\"\"/>\r\n \r\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js\"></script>\r\n <script type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/turn.js/3/turn.min.js\"></script>\r\n <script>\r\n \r\n </script>\r\n </head>\r\n \r\n <body>\r\n <!--ボタンの画像表示-->\r\n <p class=\"button\">\r\n <img style=\"width: 100%;\" src=\"http://placehold.it/100x60/333/ffffff&text=image/1.jpg\" alt=\"ボタン\" >\r\n </p>\r\n \r\n <!--ノートの画像表示-->\r\n <p class=\"note\">\r\n <img style=\"width: 100%;\" src=\"http://placehold.it/100x60/333/ffffff&text=image/2-1.jpg\" alt=\"ノート\" >\r\n </p>\r\n \r\n <!--ノートの切り替え-->\r\n <div id=\"flipbook\">\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_1.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_2_1.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_2_2.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_2_3.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_2_4.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_2_5.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_2_6.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_2_7.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_3_1.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_3_2.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_4_1.jpg\" alt=\"\"></div>\r\n <div><img src=\"http://placehold.it/500x300/333/ffffff&text=image/note_5_1.jpg\" alt=\"\"></div>\r\n </div>\r\n \r\n <script>\r\n $(function(){\r\n // 画面初回表示時\r\n $('p.note').hide();\r\n \r\n // image/1.jpgをクリック時の処理\r\n $('p.button').click(function(){\r\n // 'p.note'を表示\r\n $('p.note').show();\r\n // 'p.button'を非表示\r\n $(this).hide();\r\n });\r\n \r\n // turn.js 3rd\r\n $('#flipbook').turn({\r\n width:1000,\r\n height:600,\r\n });\r\n });\r\n </script>\r\n \r\n </body>\r\n </html>\n```",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T06:03:21.970",
"id": "46651",
"last_activity_date": "2018-07-16T11:05:35.800",
"last_edit_date": "2018-07-16T11:05:35.800",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46647",
"post_type": "answer",
"score": 1
}
] | 46647 | 46651 | 46651 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[Raspberry\nPiに接続したLCD(ACM1602NI)をPythonで動かす](http://yura2.hateblo.jp/entry/2016/02/13/Raspberry_Pi%E3%81%AB%E6%8E%A5%E7%B6%9A%E3%81%97%E3%81%9FLCD%28ACM1602NI%29%E3%82%92Python%E3%81%A7%E5%8B%95%E3%81%8B%E3%81%99)\n\n上のサイトを参考にしてlcdディスプレイ(ACM1602N1)を接続しようとしたのですが、 \nカーネルモジュール、i2c-bcm2708、i2c-devをロードするように設定したのち、ページにある\n\n```\n\n dmesg | grep i2c\n \n```\n\nを実行してもbcm2708_i2cの記述を見つけることができません。\n\n代わりにi2c-bcm2835が実行されていたためそのままi2csetを実行しようとしましたが、 \n書き込みに失敗したため、lcdディスプレイとの相性が悪いのではないかと考えています。\n\n配線不良は確認済みですが、bcm2708_i2cはどうすれば有効になりますか? \nあるいはbcm2708とbcm2835の違いは関係ありませんか?\n\n宜しくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T05:30:05.883",
"favorite_count": 0,
"id": "46649",
"last_activity_date": "2022-05-18T02:03:00.310",
"last_edit_date": "2020-11-04T16:41:41.407",
"last_editor_user_id": "3060",
"owner_user_id": "29331",
"post_type": "question",
"score": 0,
"tags": [
"raspberry-pi"
],
"title": "LCDディスプレイ (ACM1602N1) が Raspberry Pi 2 (modelB) で認識されない",
"view_count": 582
} | [
{
"body": "お使いのRapsberry piのバージョンを確認してください。\n\nbcm2708は、Raspberry Pi Model B(Kernel 4.4系列)で使われているCPUで、Raspberry Pi 2 Model\nBでは使われていません。\n\n参考: [メモ:Raspberry\nPiのボードリビジョンを判別する方法](https://qiita.com/spicemanjp/items/d702f5f89c59cc68e3b0)\n\nまた、bcm2835も、初代Raspberry Piに搭載されている、BroadcomのSoCチップ「BCM2835」と関連していると思われます。 \nRaspberry Pi 2 Model Bでは「BCM2836」が使われています。\n\n== \nこうした事から、参考にされているサイトの情報が古いために混乱が生じているように思われます。\n\nrapsbianを最新版に更新する。そして、下記の記事を参考にしてI2Cを有効にすれば良いのではないでしょうか。\n\n[advanced options I2C not\nshowing(本家(英語版)StackExchangeの記事)](https://raspberrypi.stackexchange.com/questions/63076/advanced-\noptions-i2c-not-showing/63078?noredirect=1#68036)",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T02:21:56.453",
"id": "46665",
"last_activity_date": "2018-07-17T02:21:56.453",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "46649",
"post_type": "answer",
"score": 1
}
] | 46649 | null | 46665 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Devise Gemを利用したユーザ認証システムを作成しています。 \nトップページから /user/sign_in へアクセスしようとすると、タイトルのようなエラーメッセージが出ます。 \n詳細は、下記の画像の通りです。\n\n[](https://i.stack.imgur.com/rkxiP.png)\n\nStackoverflowの英語版サイトで調べ、autoloadingが問題であるという指摘を発見しましたが、該当するファイルがなく、異なるところに原因があるように思えます。 \n何が問題か検討がつかないので、ご教示願いたいです。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T07:03:50.790",
"favorite_count": 0,
"id": "46653",
"last_activity_date": "2018-07-16T07:03:50.790",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29272",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"rubygems"
],
"title": "Circular dependency detected while autoloading constant DeviseController",
"view_count": 221
} | [] | 46653 | null | null |
{
"accepted_answer_id": "46657",
"answer_count": 1,
"body": "**JavaScriptオブジェクトは、仕様ではキーの順序を保証しなかったと思うのですが、値だとどうなるのですか?**\n\n・下記で試してみた限りは期待した結果を得られたのですが、仕様的には問題ないですか? \n・下記は、そもそも配列をソートしているだけなので、オブジェクトの順序とは無関係??\n\n```\n\n let hoge = [\n {a: \"あ\", b: 1},\n {a: \"い\", b: 2}\n ];\n hoge.sort(function(value1, value2) {\n return value2.b - value1.b;\n });\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T13:16:54.783",
"favorite_count": 0,
"id": "46656",
"last_activity_date": "2018-07-16T14:58:19.540",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7886",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "JavaScriptオブジェクトは値でソートできる?",
"view_count": 249
} | [
{
"body": "> ・下記は、そもそも配列をソートしているだけなので、オブジェクトの順序とは無関係??\n\nそう思います。配列を`各要素.b`でソートしているだけです。\n\n> 仕様ではキーの順序を保証しなかったと思うのですが、値だとどうなるのですか?\n\n上記の意味があまり理解できていませんが、 \nオブジェクトのキー一覧やオブジェクトの値一覧は以下のように取得でき、 \n[MDN](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/values)によると、いずれも`for...in`\nループによる順序と同じで、順不同(注)となるようです。\n\n```\n\n Object.keys(hoge[0]) //=> [ 'a', 'b' ]\n Object.values(hoge[0]) //=> [ 'い', 2 ]\n \n```\n\n### 注) 順不同について\n\n[Javascriptにおけるオブジェクトの順序](https://qiita.com/suguru03/items/bf48610225fefcb0f45e)に検証された記事があります。 \nJavaScriptのエンジンにより挙動が違うようです。詳細は前述の記事などを参照ください。\n\n以下はnodejs(v9.3.0)での実行例です。\n\n```\n\n obj = {a: \"あ\", b: 1}\n console.log(Object.keys(obj)) //=> ['a', 'b']\n \n obj.d = 2\n obj.c = 3\n console.log(Object.keys(obj)) //=> [ 'a', 'b', 'd', 'c' ]\n \n obj[2] = \"a\"\n obj[1] = \"b\"\n console.log(Object.keys(obj)) //=> [ '1', '2', 'a', 'b', 'd', 'c' ]\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-16T13:47:58.520",
"id": "46657",
"last_activity_date": "2018-07-16T14:58:19.540",
"last_edit_date": "2018-07-16T14:58:19.540",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46656",
"post_type": "answer",
"score": 1
}
] | 46656 | 46657 | 46657 |
{
"accepted_answer_id": "46668",
"answer_count": 1,
"body": "```\n\n import openpyxl as opx\n from openpyxl.styles import Border, Side\n \n wb = opx.Workbook()\n ws = wb.active\n \n side_medium = Side(border_style='medium', color='ff000000')\n side_dotted = Side(border_style='dotted', color='ff000000')\n side_thin = Side(border_style='thin', color='ff000000')\n \n cl = ws.cell(2,2)\n cl.border = cl.border + Border(top=side_medium, left=side_dotted, right=side_dotted, bottom=side_medium)\n cl.border = cl.border + Border(left=side_thin)\n \n wb.save(r'C:\\Users\\....\\test.xlsx')\n \n```\n\n上記コードが期待通りに動きません。 \n1回目の\"cl.border= \" で、cell(2,2) の4辺はそれぞれ期待した罫線になりますが、 \n2回目の\"cl.border= \" では、左辺が thin に上書きされるはずが、dotted のままです。 \n2回目の上書きを期待通りに反映させるにはどうすればいいのでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T01:11:10.677",
"favorite_count": 0,
"id": "46660",
"last_activity_date": "2018-07-17T03:55:04.223",
"last_edit_date": "2018-07-17T02:12:18.390",
"last_editor_user_id": "19110",
"owner_user_id": "10536",
"post_type": "question",
"score": 0,
"tags": [
"python",
"openpyxl"
],
"title": "Border で上書きしても反映されない?",
"view_count": 301
} | [
{
"body": "デバッガで動作を追ってみました。\n\nBorderの`+`演算で、各Sideオブジェクトの値をマージする際に、 \n左側(`cl.border`)、右側(`Border(left=side_thin)`)の対応するSideオブジェクトを比較するのですが、 \n両方に`boder_style`に値が設定されている場合、左側(`cl.border`)が採用されるようです。\n\n```\n\n cl.border + Border(left=side_thin) # 両方オペランドのSideにsytleがある場合、左を採用\n \n```\n\nそのため、左右入れ替えると意図通りになります。\n\n```\n\n Border(left=side_thin) + cl.border\n \n```\n\nただし、`cl.border`は、`StyleProxy`型になっているため、 \nそのまま`+`するとエラーとなりますので、`copy`して`Border`型に変換してから \n`+`すると上手く行くと思います。\n\n```\n\n from copy import copy\n # ...略...\n cl.border = Border(left=side_thin) + copy(cl.border)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T03:47:11.947",
"id": "46668",
"last_activity_date": "2018-07-17T03:55:04.223",
"last_edit_date": "2018-07-17T03:55:04.223",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46660",
"post_type": "answer",
"score": 0
}
] | 46660 | 46668 | 46668 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "callというのはどういった関数でしょうか?検索してみてもいきなり専門用語だらけで理解できませんでした。プログラムをよく知らない人に分かる感じでおおまかな内容を教えてください。お願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T02:17:16.520",
"favorite_count": 0,
"id": "46664",
"last_activity_date": "2018-07-17T13:34:56.317",
"last_edit_date": "2018-07-17T13:34:56.317",
"last_editor_user_id": "24823",
"owner_user_id": "29336",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"node.js"
],
"title": "callというのはどういった関数でしょうか",
"view_count": 192
} | [
{
"body": "[JavaScript の call( )\nメソッドを雑に説明](https://qiita.com/Chrowa3/items/b3e2961c4930abc1369b) を読んでみてください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T03:03:58.050",
"id": "46666",
"last_activity_date": "2018-07-17T03:03:58.050",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "46664",
"post_type": "answer",
"score": -3
}
] | 46664 | null | 46666 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "LinkedInのFollow Plugin Generatorで生成されるFollowボタンを \n(<https://developer.linkedin.com/plugins/follow-company>) \n自社のオウンドメディアであるGlobal Career Siteに埋め込もうと考えています。\n\nPlugin\nGeneratorのサービス上で生成されるボタンは3つのパターン(カウントあり(縦)、カウントあり(横)、カウントなし)でありますが、こちらのFollowボタンのデザインに準拠する必要はあるのでしょうか。Generatorで生成されたFollowボタン以外を利用することはできるのでしょうか。\n\nデザイン変更にあたって何らかの制約条件があるのであれば把握をしたうえで開発要否を判断したいという目的です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T06:21:06.507",
"favorite_count": 0,
"id": "46669",
"last_activity_date": "2019-12-01T18:33:54.577",
"last_edit_date": "2019-12-01T18:33:54.577",
"last_editor_user_id": "32986",
"owner_user_id": "29340",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"html",
"css"
],
"title": "Follow Plugin Generatorで生成されるFollowボタンのデザインを変更したい",
"view_count": 58
} | [
{
"body": "**注意: この回答は 2018 年 7\n月現在の情報に基づくものです。現在も正しいとは限りません。また、利用規約の解釈が間違っている可能性もあります。より厳密には、LinkedIn\n社に問い合わせる方が良いでしょう。**\n\nプラグインの [Terms of Use](https://developer.linkedin.com/legal/plugin-terms-of-\nuse) の \"Restrictions on Use\" (ご利用にあたっての制限事項) には、以下のように書かれています。\n\n> The Plugin license is subject to the following restrictions on use: (中略) (b)\n> you may not obscure or disable any element of the Plugins; (中略). Subject to\n> the limited license granted to you above, the Plugins and the Plugin Content\n> may not be copied, modified, deleted, reproduced, republished, posted,\n> transmitted, sold, offered for sale, or redistributed without LinkedIn’s\n> prior written approval in each instance. (後略)\n\n(LinkedIn Plugin Terms of Use, revised on April 23, 2018 より引用)\n\nつまりこのプラグインを使うにあたって、生成された要素を削除したり改変したりすることは特別の許可が無い限り利用規約違反となります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T07:12:57.513",
"id": "46673",
"last_activity_date": "2018-07-17T07:12:57.513",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "46669",
"post_type": "answer",
"score": 1
}
] | 46669 | null | 46673 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "weexでアプリを作成しています。 \niOSで日本語のテキストを表示すると、テキストの下に余白ができてしまいます。 \nWebやAndroidでの表示では問題ありません。 \n下記のデモをiOSのweex playgroundで見るとキャプチャのようにテキストの下に余白ができ、 \n英語と日本語のテキストを併記した場合にunderlineもずれてしまいます。(キャプチャ参照)\n\nデモ: \n<http://dotwe.org/vue/8180c47f84522b0466e3e78d412283b0>\n\nどなたか解決策をご存知の方はいませんでしょうか。\n\n",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T07:22:16.540",
"favorite_count": 0,
"id": "46674",
"last_activity_date": "2018-10-10T12:14:52.710",
"last_edit_date": "2018-07-17T08:04:45.440",
"last_editor_user_id": "19110",
"owner_user_id": "29343",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"vue.js"
],
"title": "weexのiOSで日本語のテキストを表示すると、テキストの下に余白ができる",
"view_count": 121
} | [
{
"body": "デフォルトのweexの指定fontだと中国語フォントになっているようです。 \nなのでiOSの場合、元からiPhoneに入っているフォントである「Hiragino Kaku Gothic ProN」を \ncssのfont-familyで指定してあげるとうまく表示されました。\n\n以下サンプルコードです。\n\n```\n\n .クラス名 {\n font-family: Hiragino Kaku Gothic ProN;\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-10-10T12:14:52.710",
"id": "49145",
"last_activity_date": "2018-10-10T12:14:52.710",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30456",
"parent_id": "46674",
"post_type": "answer",
"score": 1
}
] | 46674 | null | 49145 |
{
"accepted_answer_id": "46692",
"answer_count": 1,
"body": "現在開発しているAPIサービスの認証をOAuth2.0で行っているのですが、 \nアクセスできるスコープによって2種類のgrant_typeを使い分けるのはOAuth2.0仕様上問題ないでしょうか。 \n使用したいgrant_typeは\"password\"と\"client_credentials\"です。\n\nRFC 6749は一通り見たのですが、読み取ることができませんでした。 \nご存知の方がいましたら、ご教示願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T08:11:59.453",
"favorite_count": 0,
"id": "46675",
"last_activity_date": "2018-07-18T08:29:51.427",
"last_edit_date": "2018-07-17T11:32:41.303",
"last_editor_user_id": "29344",
"owner_user_id": "29344",
"post_type": "question",
"score": 1,
"tags": [
"python",
"api",
"oauth"
],
"title": "OAuth2.0を使用しているAPIでgrant_typeを使い分ける",
"view_count": 228
} | [
{
"body": "`grant_type`は、grant(認可)の方法の話なので、複数の`grant_type`を実装して動作させても問題になるようなことはないと思います。現にGoogleのAPIにOAuth2を使ってアクセスする場合、サーバーからの場合は\"client_credentials\"が使えるし、ブラウザーからの場は\"Authorization\nCode\"を使って`grant`できます。\n\nPythonでOAuth2を実装する場合、自分で一から書くのは大変なので、[`authlib`というライブラリー](https://github.com/lepture/authlib)を使う場合が多いと思うのですが、`authlib`は、`ResourceOwnerPasswordGrant`にも`ClientCredentialsGrant`にも対応しています。後は、両方が問題無く動作するようにサーバーとクライアント側を実装したらいいだけのことだと思います。そうはいっても結構手間がかかるので「Firebase\nAuthentication」のようなサービスを使う場合も多いのですが。。。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-18T08:29:51.427",
"id": "46692",
"last_activity_date": "2018-07-18T08:29:51.427",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "46675",
"post_type": "answer",
"score": 0
}
] | 46675 | 46692 | 46692 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "IJCAD 2015の起動・作図・終了をCOM(C#)を使って外部アプリケーションから操作しています。\n\nところが、以下のイベントが取れないのですが、どこか間違っているのでしょうか?\n\n```\n\n private void button_Click(object sender, EventArgs e)\n { \n app = new GcadApplication();\n app.Visible = true;\n app.ActiveDocument.BeginSave += new _DGcadDocumentEvents_BeginSaveEventHandler(this.Save);\n }\n \n private void Save(string fileName) \n {\n // イベント処理\n //(省略)\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T09:26:54.893",
"favorite_count": 0,
"id": "46676",
"last_activity_date": "2018-07-17T23:34:04.560",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29128",
"post_type": "question",
"score": 0,
"tags": [
".net",
"ijcad"
],
"title": "IJCADでActiveDocument.BeginSaveイベントが発生しない",
"view_count": 84
} | [
{
"body": "この件、昔開発元に聞いたところ、IJCADの不具合との回答がありました。\n\n.NET APIであれば回避できるとのことでしたので、.NET APIを利用して解決しました。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T23:34:04.560",
"id": "46683",
"last_activity_date": "2018-07-17T23:34:04.560",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29030",
"parent_id": "46676",
"post_type": "answer",
"score": 0
}
] | 46676 | null | 46683 |
{
"accepted_answer_id": "46829",
"answer_count": 2,
"body": "[AIZU ONLINE\nJUDGE](http://judge.u-aizu.ac.jp/onlinejudge/)の0009の問題を解くために以下のようなコードを提出したのですが、「[Runtime\nError](http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3036169#1)」が出てしまいます。簡単な問題かもしれませんが原因がわかる方、お答えください。\n\n```\n\n import math\n import sys\n \n def prime_calc(n):\n rootN = math.floor(math.sqrt(n))\n prime = [2]\n data = [i + 1 for i in range(2,n,2)]\n while True:\n p = data[0]\n if rootN <= p:\n return len(prime + data)\n prime.append(p)\n data = [e for e in data if e % p != 0]\n \n def main():\n l = []\n \n for line in sys.stdin:\n l.append(int(line)) \n \n for line in l:\n print(prime_calc(line))\n \n if __name__ == \"__main__\":\n main()\n \n```\n\n追記:tanalab2 さんの解答のとおりにしたのですが、なぜか「[Runtime\nError](http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3036328#1)」が出てしまいます。原因は何でしょうか?\n\n追記:tanalab2さんのご指摘の通りのコードにしました。\n\n追記:以下の入力を試しましたが問題はありませんでした。\n\n```\n\n 10\n 3\n 11\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T10:16:56.460",
"favorite_count": 0,
"id": "46677",
"last_activity_date": "2018-07-22T09:11:37.400",
"last_edit_date": "2018-07-22T08:25:52.837",
"last_editor_user_id": "26886",
"owner_user_id": "26886",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "AIZU ONLINE ジャッジでRuntime Errorが発生した",
"view_count": 996
} | [
{
"body": "問題を提出する前に、ご自分の開発環境で動作確認を行う必要があります。\n\nご質問のコードを動作確認のため実行したところ、 \n以下のエラーが発生しました。\n\n```\n\n Traceback (most recent call last):\n File \"hoge4.py\", line 25, in <module>\n main()\n File \"hoge4.py\", line 22, in main\n print(prime_calc(line))\n File \"hoge4.py\", line 5, in prime_calc\n rootN = math.floor(math.sqrt(n))\n TypeError: must be real number, not str\n \n```\n\n標準入力から読み取った文字列を数値に変換していないことが原因と思います。\n\n```\n\n for line in sys.stdin:\n l.append(int(line)) # 文字列を整数に変換 \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T10:38:42.583",
"id": "46678",
"last_activity_date": "2018-07-17T10:38:42.583",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "46677",
"post_type": "answer",
"score": 1
},
{
"body": "自分で皆様が指摘した部分のソースコードを確認をしたところ、 \n`1`以下のときには素数がないので`0`を返し、 \nちょうど`2`のときは素数は一つだけなので`1`を返すようにしました。 \nご回答ありがとうございました。\n\n```\n\n import math\n import sys\n \n def prime_calc(n):\n if n <= 1:\n return 0\n elif n == 2:\n return 1\n else:\n rootN = math.floor(math.sqrt(n))\n prime = [2]\n data = [i + 1 for i in range(2,n,2)]\n while True:\n p = data[0]\n if rootN < p:\n return len(prime + data)\n prime.append(p)\n data = [e for e in data if e % p != 0]\n \n def main():\n l = []\n \n for line in sys.stdin:\n l.append(int(line))\n \n for line in l:\n print(prime_calc(line))\n \n if __name__ == \"__main__\":\n main()\n \n```\n\n追記:でも、今使ったアルゴリズムはAIZU ONLINE JUDGE的にはTime Limit\nExceedなので、別な(高速)のアルゴリズムを使うといいです。でも、アルゴリズムを提供してくれたFantm21さんありがとうございました。\n\n元記事:[Pythonで作るエラトステネスのふるい](https://qiita.com/fantm21/items/5e270dce9f4f1d963c1e)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-22T08:32:11.000",
"id": "46829",
"last_activity_date": "2018-07-22T09:11:37.400",
"last_edit_date": "2018-07-22T09:11:37.400",
"last_editor_user_id": "26886",
"owner_user_id": "26886",
"parent_id": "46677",
"post_type": "answer",
"score": 1
}
] | 46677 | 46829 | 46678 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "今現在、Swift4を使用しているのですが、端末のスリープ回数を得たいと考えております。アプリのスリープ時や、起動時はAppDelegate.swiftでコードを書くということはわかりました。アプリではなく、端末のスリープ回数を得るにはどのようなコードを使用すればよいのでしょうか。よければ教えていただきたいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T13:18:30.007",
"favorite_count": 0,
"id": "46681",
"last_activity_date": "2018-07-17T14:35:09.663",
"last_edit_date": "2018-07-17T13:33:16.323",
"last_editor_user_id": "19110",
"owner_user_id": "29104",
"post_type": "question",
"score": 1,
"tags": [
"swift",
"swift4"
],
"title": "Swift 4 端末のスリープ回数",
"view_count": 101
} | [
{
"body": "通常は不可能です。iOSアプリが動作していられるのは基本的にはアプリケーションがフォアグラウンドにあるときだけで、バックグラウンドの動作は非常に限定的な時間しか動作できません。\n\n一部の目的のアプリにだけ例外的に長時間バックグラウンドの動作が可能ですが、その場合でもデバイスのスリープのタイミングを取得するといったAPIは基本的にありません。\n\nよって、そのようなアプリを作ることは通常は不可能になります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-17T14:35:09.663",
"id": "46682",
"last_activity_date": "2018-07-17T14:35:09.663",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "46681",
"post_type": "answer",
"score": 2
}
] | 46681 | null | 46682 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "jupyterで右上のuploadボタンをクリックし、アップロードしたいcsvファイルを選択しても何も反応がありません。解決策はないでしょうか?\n\n現在は、csvファイルをMoveボタンで目的のフォルダに直接置くことで対応しています。 \nただし、元のファイル自体が移動してしまい不便な状態です。",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-18T02:55:14.203",
"favorite_count": 0,
"id": "46684",
"last_activity_date": "2020-04-07T06:01:50.473",
"last_edit_date": "2018-07-18T08:31:07.753",
"last_editor_user_id": null,
"owner_user_id": "29357",
"post_type": "question",
"score": 0,
"tags": [
"csv",
"jupyter-notebook"
],
"title": "jupyterにおいてcsvがuploadできない",
"view_count": 3762
} | [
{
"body": "`Jupyter Notebook`の対応ブラウザーは、`Chrome`, `Safari`,`FireFox`です\n([参照](https://jupyter-notebook.readthedocs.io/en/stable/notebook.html#browser-\ncompatibility))。それ以外の`IE`や`Edge`を使っている場合は、ブラウザーを対応ブラウザーに変更してみましょう。\n\n`Jupyter\nNotebook`は、デフォルトブラウザーを起動するようになっていますが、会社ではデフォルトブラウザーを好きなように設定できない場合があります。その場合には、`jupyter_notebook_config.py`で設定する必要があります([Windowsの場合の参考](https://qiita.com/acknpop/items/4e5b57e38780068a9155))。\n\nブラウザーを変更しても改善しない場合は、直接的な解決策ではありませんが、Jupyterではシェルコマンドが使えるのでシェルコマンドでコピーする方法があります。\n\n```\n\n # Linux, Macの場合\n !cp path_to_csv/*.csv .\n # Windowsの場合\n !copy path_to_csv\\*.csv .\n \n```\n\nまた、Pythonで、次のようにデータをコピするルーチンまで書いておくと最初は少し手間ですが、以後は自動化できます。\n\n```\n\n from pathlib import Path\n import shutil\n \n files = Path('path_to_csv').glob('*.csv')\n for f in files:\n print(f)\n shutil.copy(f, '.' )\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-18T23:03:35.687",
"id": "46707",
"last_activity_date": "2018-07-19T04:04:23.710",
"last_edit_date": "2018-07-19T04:04:23.710",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "46684",
"post_type": "answer",
"score": 1
}
] | 46684 | null | 46707 |
{
"accepted_answer_id": "46697",
"answer_count": 2,
"body": "# 環境\n\n * Python3.6.5\n * Bokeh 0.13.0 \n<https://bokeh.pydata.org/en/latest/docs/gallery.html>\n\n# やりたいこと\n\nデータ可視化ライブラリBokehを用いて、以下のような「積み上げ面グラフ」を作成したいです。\n\n[](https://i.stack.imgur.com/f7jUC.png)\n\n<https://jp.cybozu.help/ja/k/user/graph_type> 引用\n\nBokeh 0.12のときは、`bokeh.charts.Area`を使って、簡単に書くことができます。\n\n```\n\n from bokeh.charts import Area, show, output_file, defaults\n from bokeh.layouts import row\n \n defaults.width = 400\n defaults.height = 400\n \n # create some example data\n data = dict(\n python=[2, 3, 7, 5, 26, 221, 44, 233, 254, 265, 266, 267, 120, 111],\n pypy=[12, 33, 47, 15, 126, 121, 144, 233, 254, 225, 226, 267, 110, 130],\n jython=[22, 43, 10, 25, 26, 101, 114, 203, 194, 215, 201, 227, 139, 160],\n )\n \n area1 = Area(data, title=\"Area Chart\", legend=\"top_left\",\n xlabel='time', ylabel='memory')\n \n area2 = Area(data, title=\"Stacked Area Chart\", legend=\"top_left\",\n stack=True, xlabel='time', ylabel='memory')\n \n output_file(\"area.html\", title=\"area.py example\")\n \n show(row(area1, area2))\n \n```\n\n<https://bokeh.pydata.org/en/0.12.5/docs/gallery/area_chart.html> 引用\n\nしかし、Bokeh0.13.0では、`bokeh.charts.Area`クラスがなくなっていました。\n\n# 質問\n\nBokeh 0.13で、「積み上げ面グラフ」用を作成するのには、どのクラスを使えばよろしいでしょうか? \n`patches`メソッドを使って、「積み上げ面グラフ」を作成しているサンプルはありましたが、自分でstack値を計算していて、`Area`より不便です。 \nもう少し便利なクラスやメソッドがありましたら、教えてください。\n\n```\n\n import numpy as np\n import pandas as pd\n \n from bokeh.plotting import figure, show, output_file\n from bokeh.palettes import brewer\n \n N = 20\n cats = 10\n df = pd.DataFrame(np.random.randint(10, 100, size=(N, cats))).add_prefix('y')\n \n def stacked(df):\n df_top = df.cumsum(axis=1)\n df_bottom = df_top.shift(axis=1).fillna({'y0': 0})[::-1]\n df_stack = pd.concat([df_bottom, df_top], ignore_index=True)\n return df_stack\n \n areas = stacked(df)\n colors = brewer['Spectral'][areas.shape[1]]\n x2 = np.hstack((df.index[::-1], df.index))\n \n p = figure(x_range=(0, N-1), y_range=(0, 800))\n p.grid.minor_grid_line_color = '#eeeeee'\n \n p.patches([x2] * areas.shape[1], [areas[c].values for c in areas],\n color=colors, alpha=0.8, line_color=None)\n \n output_file('brewer.html', title='brewer.py example')\n \n show(p)\n \n```\n\n<https://bokeh.pydata.org/en/latest/docs/gallery/brewer.html> 引用",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-18T04:05:08.623",
"favorite_count": 0,
"id": "46685",
"last_activity_date": "2022-02-18T13:12:48.280",
"last_edit_date": "2018-07-18T05:05:23.113",
"last_editor_user_id": "19110",
"owner_user_id": "19524",
"post_type": "question",
"score": 3,
"tags": [
"python",
"bokeh"
],
"title": "Bokeh 0.13で、積み上げ面グラフを書く方法",
"view_count": 724
} | [
{
"body": "`Bokeh`の`bkcharts`の後継は`HoloViews`です。`HoloViews`は、`Bokeh`をバックエンドにして簡潔な記述でグラフを描くことができます。\n\n`HoloViews`の面グラフのドキュメントとサンプルへのリンクは、次のとおりです。\n\nドキュメント: <http://holoviews.org/reference/elements/bokeh/Area.html> \nサンプル: <http://holoviews.org/gallery/demos/bokeh/area_chart.html>\n\nサンプルのコードは、次のとおりで、質問にあるBokeh 0.12のときの、`bokeh.charts.Area`を使って書くのと同じグラフになっています。\n\n```\n\n import numpy as np\n import holoviews as hv\n hv.extension('bokeh')\n \n # create some example data\n python=np.array([2, 3, 7, 5, 26, 221, 44, 233, 254, 265, 266, 267, 120, 111])\n pypy=np.array([12, 33, 47, 15, 126, 121, 144, 233, 254, 225, 226, 267, 110, 130])\n jython=np.array([22, 43, 10, 25, 26, 101, 114, 203, 194, 215, 201, 227, 139, 160])\n \n dims = dict(kdims='time', vdims='memory')\n python = hv.Area(python, label='python', **dims)\n pypy = hv.Area(pypy, label='pypy', **dims)\n jython = hv.Area(jython, label='jython', **dims)\n \n overlay = (python * pypy * jython).options('Area', fill_alpha=0.5)\n overlay.relabel(\"Area Chart\") + hv.Area.stack(overlay).relabel(\"Stacked Area Chart\")\n \n```\n\nなお、Plotするところで、`+`と`*`の演算子がありますが、`+`は、グラフを並べる演算子で、`*`はグラフを重ねる演算子です。`HoloViews`では、`+`と`*`の演算子を組み合わせることで簡単にグラフを並べたり重ねたりできます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-18T10:45:45.613",
"id": "46697",
"last_activity_date": "2018-07-19T00:34:41.827",
"last_edit_date": "2018-07-19T00:34:41.827",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "46685",
"post_type": "answer",
"score": 2
},
{
"body": "bokeh 2.4の場合、`bokeh.plotting.Figure.varea_stack`関数で、積み上げ面グラフを作ることができました。\n\n<https://docs.bokeh.org/en/latest/docs/reference/plotting/figure.html#bokeh.plotting.Figure.varea_stack>\n\n<https://docs.bokeh.org/en/latest/docs/gallery/stacked_area.html>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2022-02-18T13:12:48.280",
"id": "86438",
"last_activity_date": "2022-02-18T13:12:48.280",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19524",
"parent_id": "46685",
"post_type": "answer",
"score": 0
}
] | 46685 | 46697 | 46697 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.