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": "**質問1** \nレンタルサーバで環境変数の利用は一般的ではないのでしょうか? \n環境変数を使用したい場合、VPSやAWSなどのクラウドを使う方がセキュアに運用できそうでしょうか?\n\n**調査した事1** \n某レンタルサーバさんのサポートに問い合わせたところサポート対象外との回答をいただきました。\n\n**調査した事2** \n「レンタルサーバ 環境変数 設定」などのワードで検索してみたところ \nレンタルサーバで環境変数を設定する方法が公式で説明されているものはなく、解説記事も少なかったので今回の質問に至りました。\n\n**実現したいこと** \nGoogleのPlaces APIを使用してマップ内に動的にピンを複数打ちたいと考えています。 \nその際に使用するAPIキーの保存場所を検討しているところです。\n\n不足情報がありましたら可能な限り補足させていただきます。 \nよろしくお願い致します。\n\nまたもしレンタルサーバで環境変数を使用しながら \n運用しているという方もいらっしゃいましたらぜひその方法をご教授いただけましたら幸いです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T09:22:28.073", "favorite_count": 0, "id": "91256", "last_activity_date": "2022-09-24T03:25:03.920", "last_edit_date": "2022-09-24T03:25:03.920", "last_editor_user_id": "3060", "owner_user_id": "19992", "post_type": "question", "score": 0, "tags": [ "php", "linux" ], "title": "レンタルサーバで環境変数の利用は一般的ではないのでしょうか?", "view_count": 627 }
[ { "body": "いわゆるレンタルサーバー(Webホスティングサービスの一種であり、共有サーバーとも言われる)では、一つのWebサーバーアプリ(Apache HTTP\nServerやnginx)上で独立した複数のユーザーのサイトを動かしています。それぞれのユーザーのサイトはお互いに見えず、実行環境もsuEXEC等の技術でそのユーザーの権限に落とし込んだり、chrootで隔離されたりしていますが、もともとは一つのWebサーバーアプリからフォークして実行されます。\n\n通常、環境変数を渡すとなると、大本のプロセス、つまり、systemdのユニットファイルで`Environment`を設定する等でWebサーバーアプリに渡します。しかし、Webサーバーアプリは一つしか無いため、一人のユーザーのために環境変数を設定したら、それは全てのユーザーと共有されてしまいます。これは、ユーザー毎に独立した環境を提供するレンタルサーバーとしては、一種のセキュリティホールになってしまいます。また、ユーザー同士で設定したい環境変数が重複した場合、どちらを優先するかで揉めることになるでしょう。\n\nでは、どうやってもできないかというと、そうではありません。Apache HTTP\nServerであれば、[`SetEnv`ディレクティブ](https://httpd.apache.org/docs/2.4/ja/mod/mod_env.html#setenv)というのがあります。これは任意の環境変数を設定できるというもので、サーバー全体だけでは無く、ホスト毎やディレクトリ毎に設定できます。先程の問題はWebサーバーアプリに環境変数を設定すると全ユーザー共通になってしまうと言うことでした。ですが、これであれば、サイト(バーチャルホスト)毎やディレクトリ毎に任意の環境変数を設定できそうです。しかし、まだ問題があります。これらはApache\nHTTP Serverの設定になるのですが、それをユーザーに変更させるのは難しいですし、変更の度にサービス再起動する必要があるのも問題です。\n\nまだ、諦めないで下さい。なんと、`SetEnv`は`.htaccess`でも使用できます。`.htaccess`はユーザー毎、もっと正確に言えば、公開するディレクトリ毎に設定できます。プログラムが置いてあるところのディレクトリに`.htaccess`を置いて、そこに`SetEnv`を使えば、任意の環境変数を使えると言うことです。これなら、ユーザーは自分の領域で自由に設定できますし、サービス再起動などの面倒な事も不要になります。ただ一つ問題があるとすれば、`.htaccess`は使用できるディレクティブを制限している場合があると言うことです。(`.htaccess`で使用できるディレクティブはApache\nHTTP Serverの設定で制限できます)\n\n* * *\n\n前置きが長くなりました。次の条件を満たすレンタルサーバーであれば、環境変数は使えます。\n\n * `.htaccess`が使用できる。\n * `.htaccess`での`SetEnv`ディレクティブの使用が許可されている。\n\nこれがXserverや他のレンタルサーバーで使えるかどうかと言うとわかりません。Xserverは`.htaccess`を使用できるようですが、どのディレクティブが使えるかどうかの情報はありませんでした。実際に設定してみて試して見るしか無いと思われます。\n\n* * *\n\nここまで来て、一つ注意点があります。なぜ、APIキーは環境変数に設定すべきかと言うことです。プログラム全体をGitHubなどのレポジトリで管理している場合、コードの中にAPIキーを入れているとそれもレポジトリに上がってしまいます。それがもしパブリックなレポジトリであったら、APIキーを世界中に公開されてしまうということです。公開されたAPIキーはあっという間に悪用されます。そうなれば、良くてアカウントBAN、サービスによっては数百万円の使用料請求と洒落にならない事態に陥ります。\n\n先程、`.htaccess`を`SetEnv`を使用すればいいと書きました。ちょっと待ってください。その`.htaccess`は誰にも見られるような事になっていないでしょうか?ほとんどのサーバーでは`.htaccess`へのアクセスは制限がかかっていますが、必ずしもそうとは限りません。自分でちゃんとアクセスできないように設定する必要があるかも知れません。もう一つは、`.htaccess`はプログラムと同じ所に置かれるので、先程言ったレポジトリでの管理の場合、一緒に公開してしまう場合があるということです。`.htaccess`にrewrite等の設定を入れている場合、一緒に管理したくなるでしょう。そのような場合で、`.htaccess`の中にAPIキーを埋め込むのはいい方法とは言えません。\n\n何を言いたいかというと、「APIキーは環境変数に入れれば安全」と思考停止しないでください。\n**環境変数の設定場所が公開されれば環境変数であっても危険です。**\n大事なのは、APIキーが書かれている場所が絶対に公開されないようにすることです。一般に、プロセス自体の環境変数で設定する場合は、ソースツリーとは別の場所になるから、環境変数だと安全な場合が多いと言うだけです。レポジトリの除外対象になっている設定ファイルに書く、DBに保存する等、ソースツリー上には現れない物であれば十分だと言うことです。", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T13:22:57.860", "id": "91263", "last_activity_date": "2022-09-23T13:22:57.860", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7347", "parent_id": "91256", "post_type": "answer", "score": 5 }, { "body": "コメントにも書きましたが、そもそも環境変数を理解できていないと思われます。まずはWikipediaの[\n**環境変数**](https://ja.wikipedia.org/wiki/%E7%92%B0%E5%A2%83%E5%A4%89%E6%95%B0)や[\n**プロセス**](https://ja.wikipedia.org/wiki/%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9)を参照し理解することをお勧めします。\n\n> 環境変数はオペレーティングシステム\n> が提供するデータ共有機能の一つ。OS上で動作するプロセスがデータを共有するための仕組みである。特にタスクに対して外部からデータを与え、タスクの挙動・設定を変更するために用いる。\n\n> 環境は、親プロセスから子プロセスに複製されて継承される。\n> すなわち、子プロセスで環境を変更しない限り、子プロセスの環境は親プロセスのそれと同一の内容である。\n> また、子プロセスが自分の環境に対して行った変更は、親プロセスの環境に影響しない。\n\nつまり、 **環境変数はOS・プロセスで標準的に提供される機能** であり、 **レンタルサーバーで利用可否が変わるものではありません** 。\n\n検索しても見つけることができないのは、あまりに基本的過ぎる内容なため、そんなこと知っているわと読み飛ばしてしまっただけでしょう。上で引用したようにWikipedia等で調べればきちんと説明されており、見つけることができたはずです。\n\n* * *\n\n個々のプロセスに対して環境変数の設定方法はさまざまで、プロセスを実行しているプログラムに依存します。 \n例えばraccyさんの回答にもありますが、Apache Http\nServerであれば[`SetEnv`ディレクティブ](https://httpd.apache.org/docs/2.4/ja/mod/mod_env.html#setenv)で行えます。またタグ指定されているphpであれば[`putenv`関数](https://www.php.net/manual/ja/function.putenv.php)で行えます。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T23:04:42.070", "id": "91267", "last_activity_date": "2022-09-23T23:04:42.070", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "91256", "post_type": "answer", "score": 3 } ]
91256
null
91263
{ "accepted_answer_id": "91259", "answer_count": 2, "body": "YouTubeでGitの使い方を見ているのですが、その動画にはないポップアップがでてきます(赤い丸)。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/1XhpL.jpg)](https://i.stack.imgur.com/1XhpL.jpg)\n\nそれを検索したらこのサイトがでてきました。 \n<https://docs.github.com/ja/authentication/connecting-to-github-with-\nssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent>\n\n④で突っかかってしまい、そこからGit BashでEnter以外なにも入力できない状態です。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/pUnoj.jpg)](https://i.stack.imgur.com/pUnoj.jpg)\n\nどなたかご指導お願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T10:28:03.627", "favorite_count": 0, "id": "91258", "last_activity_date": "2022-09-23T12:10:09.397", "last_edit_date": "2022-09-23T12:08:57.570", "last_editor_user_id": "19110", "owner_user_id": "53823", "post_type": "question", "score": 1, "tags": [ "git", "github", "ssh", "git-bash" ], "title": "GitHub に SSH 鍵を登録したい", "view_count": 110 }
[ { "body": "英語でもメッセージをちゃんと読みましょう。 \nSSH Keyのパスフレーズを聞かれているので、(任意の)SSHに使うパスフレーズ(=パスワード)を入力してあげて下さい。 \nそれで次のステップに進めます", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T12:09:20.127", "id": "91259", "last_activity_date": "2022-09-23T12:09:20.127", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14745", "parent_id": "91258", "post_type": "answer", "score": 3 }, { "body": "パスフレーズを設定する手順ですが、(肩越しのセキュリティ対策として) プロンプトに文字が表示されないだけで、実際には入力したままが反映されているはずです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T12:10:09.397", "id": "91260", "last_activity_date": "2022-09-23T12:10:09.397", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "91258", "post_type": "answer", "score": 1 } ]
91258
91259
91259
{ "accepted_answer_id": "91293", "answer_count": 2, "body": "Python始めたばかりで初歩的な質問ですみません。\n\nテキストエディタに書いたプログラムからIDLEに出力する際に、\n\n```\n\n print(変数や文字列など)\n \n```\n\nとしないとIDLE側で出力できないと思っていましたが、 \nとある書籍のプログラム例(古くからあるハングマンというゲーム)で \nprintの記載がなくてもIDLEでプログラムを走らせることができました。\n\n具体的には、テキストエディタのプログラムの最後が\n\n```\n\n hangman(\"cat\")\n \n```\n\nとなっており、ゲームが終了するとIDLEのウィンドウに\n\n```\n\n >>> cat\n \n```\n\nと出力されます。\n\n`print(hangman(\"cat\"))` としても cat と出ますが、\n\n```\n\n >>> cat\n >>> None\n \n```\n\nと、’None'が一緒に出てきました。\n\nこれまで勉強してきたコードではテキストエディタでprintをつけないと、 \nIDLEでの出力がエラーは出ずに空白の出力になっていたので、 \nテキストエディタにprint〜と記載しないとダメだとおもっていましたが、 \n何が起こっているのでしょうか。教えてください。\n\n**対象のプログラム**\n\n```\n\n def hangman(word): \n wrong=0 \n stages=[\"\", \n \"________ \",\n \"| \", \n \"| | \", \n \"| O \", \n \"| /|\\ \", \n \"| / \\ \", \n \"| \" \n ] \n rletters=list(word) \n board=[\"_ \"]*len(word) \n win=False \n print(\"ハングマンへようこそ!!\")\n while wrong<len(stages)-1: \n print(\"\\n\") \n msg=\"文字を予想してね:\" \n char=input(msg) \n if char in rletters:\n cind=rletters.index(char) \n board[cind]=char \n rletters[cind]='$' \n else: \n wrong+=1 \n print(\"\".join(board)) \n e=wrong+1 \n print(\"\\n\".join(stages[0:e]))\n if \"_ \" not in board: \n print(\"あなたの勝ち!!\") \n print(\"\".join(board)) \n win=True \n break\n if not win:\n print(\"\\n\".join(stages[0:wrong+1])) \n print(\"あなたの負け!正解は{}。\".format(word)) \n \n hangman(\"cat\") \n \n```", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T12:23:19.033", "favorite_count": 0, "id": "91261", "last_activity_date": "2022-09-25T16:48:45.573", "last_edit_date": "2022-09-25T16:48:45.573", "last_editor_user_id": "3060", "owner_user_id": "54499", "post_type": "question", "score": 0, "tags": [ "python", "python3" ], "title": "IDLEに出力する際のテキストエディタに記載するprint()の件", "view_count": 122 }
[ { "body": "コマンドラインから `python` (もしくは環境によっては `py` など) で起動すると インタープリターが起動し,\n[対話モード(Interactive\nMode)](https://docs.python.org/ja/3/tutorial/interpreter.html#interactive-\nmode) になります \nいくつか指定した場合(一挙にコピペしたときなど), 最後に指定した分の結果が表示(print)されます \n(対話モードかどうかは 三つの「大なり記号」 (`>>>`) で判別可能)\n\n(Pythonに限らず)このようなモードは, REPL (Read-Eval-Print Loop) とも呼ばれます \n参考: <https://ja.wikipedia.org/wiki/REPL>\n\n`idle` はその tkinter GUI 版 (というだけ)\n\n```\n\n Python 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:36:39) [GCC 10.4.0] on linux\n Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n >>> 1+1\n 2\n >>> def fn(s):\n ... return 'hello ' + s\n ...\n >>> fn('world')\n 'hello world'\n \n```\n\n* * *\n\n【追記】\n\n組み込み関数 [`print`](https://docs.python.org/ja/3/library/functions.html#print)\nを呼び出しても表示されるし, 対話モードの「大なり記号」 (`>>>`) を使った(計算などの)結果も表示されます。 \nある関数(この場合 `hangman`)内で組み込み関数 `print`が利用されていれば, その場合も表示されるでしょう", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T13:03:12.040", "id": "91262", "last_activity_date": "2022-09-25T13:17:48.877", "last_edit_date": "2022-09-25T13:17:48.877", "last_editor_user_id": "43025", "owner_user_id": "43025", "parent_id": "91261", "post_type": "answer", "score": 2 }, { "body": "> hangman(\"cat\") \n> となっており、ゲームが終了するとIDLEのウィンドウに \n> >>>cat\n\n関数hangmanの中でprint()が呼ばれている(使われている)ためhangman()を呼ぶと`cat`が出力されます。\n\n> print(hangman(\"cat\"))としてもcatと出ますが、 \n> >>>cat \n> >>>None \n> と、’None'が一緒に出てきました。\n\nその`cat`は`hangman`の中で出力されているものです。また。`None`は`hangman`の戻り値が出力されているものです。(戻り値が設定されていない関数の場合`None`が返ります。)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T11:39:58.993", "id": "91293", "last_activity_date": "2022-09-25T11:39:58.993", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "39819", "parent_id": "91261", "post_type": "answer", "score": 0 } ]
91261
91293
91262
{ "accepted_answer_id": "91266", "answer_count": 1, "body": "```\n\n TextField(\"Placeholder\", text: $text).keyboardType(.numberPad)\n \n```\n\niOSの方では上記のコードでキーボードタイプを変更できたのですが、Watch Appではエラーになってしまいます。 \nどのようにすればキーボードタイプを変更できるのでしょうか?よろしくお願い致します。\n\nXcode14 \nSwift5", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T15:13:20.040", "favorite_count": 0, "id": "91265", "last_activity_date": "2022-09-23T16:50:23.560", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17048", "post_type": "question", "score": 0, "tags": [ "swift", "xcode", "swiftui", "swift5" ], "title": "WatchAppでキーボードを数字入力のみにしたい", "view_count": 80 }
[ { "body": "情報が古かったら申し訳ありませんが、Appleは公式に`SwiftUI`下で`watchOS`でのデシマルキーボードをサポートしていないようです。 \n代用として`GitHub`に[SwiftUI Apple Watch Decimal\nPad](https://github.com/ApplebaumIan/SwiftUI-Apple-Watch-Decimal-\nPad)というライブラリーがあるようです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-23T15:45:15.550", "id": "91266", "last_activity_date": "2022-09-23T16:50:23.560", "last_edit_date": "2022-09-23T16:50:23.560", "last_editor_user_id": "14745", "owner_user_id": "14745", "parent_id": "91265", "post_type": "answer", "score": 0 } ]
91265
91266
91266
{ "accepted_answer_id": null, "answer_count": 0, "body": "Opencvで処理した画像をGPUを使用して動画保存してようとしています。 \ngst-\nlaunch-1.0で確認すると、nvh264encでNegotiationErrorが発生し。OpenCVで実行しても、openはしますが、Writeで失敗します。 \n適切なPipelineの記述についてアドバイスもらえると助かります。 \n>gst-launch-1.0 filesrc location=test.bmp !nvvidconv !nvh264enc !h264parse\n!mp4mux !filesink location=test.mp4\"\n\n```\n\n cv::VideoWriter writer;\n cv::Mat cvImage, cvImageRgb;\n //ImageProcess//\n cv::cvtColor(cvImage, cvImageRgb, CV_BGR2RGB);\n src = \" appsrc !nvvidconv !nvh264enc !h264parse !mp4mux !filesink location=test.mp4\";\n writer.open(src.CStr8(),cv::CAP_GSTREAMER, 0, frametime, cv::Size(width, height),true);\n if (!writer.isOpened())\n throw atl::IoError(L\"Cannot connect to any file using given name : \" + inFile);\n writer.write(cvImageRgb);\n errorcode = writer.get(0);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T00:51:50.470", "favorite_count": 0, "id": "91269", "last_activity_date": "2022-09-24T00:51:50.470", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54505", "post_type": "question", "score": 0, "tags": [ "opencv" ], "title": "Gstreamer+Gpuによる動画保存のためのGstrea;merPipeline 記述について", "view_count": 142 }
[]
91269
null
null
{ "accepted_answer_id": "91271", "answer_count": 1, "body": "##### 目的\n\nC++のcreate_taskを使用しています。 \n外から渡すデータをcopyではなくmoveさせたい。\n\n##### 質問\n\ncreate_taskに渡す際に、コピーを発生させないようにstd::move動作させると、1回ムーブ後に、複数回コピーコンストラクタが実行されます。 \n別質問にて、create_taskのラムダがコピーされているのでコピーが発生していると教えていただいたのですが、しかし1回はともかく、複数回は多いです。これはどうしようもないでしょうか?\n\n```\n\n struct Test\n {\n std::unique_ptr<int[]> data; // データ\n int value;\n \n Test(std::unique_ptr<int[]>&& d)\n : data(std::forward<std::unique_ptr<int[]>>(d))\n , value(10)\n {\n }\n \n Test(const Test& _obj)\n {\n value = _obj.value;\n ::OutputDebugStringW(L\"コピー\\n\");\n }\n \n Test(Test&& _obj) noexcept\n : data(std::forward<std::unique_ptr<int[]>>(_obj.data))\n , value(_obj.value)\n {\n ::OutputDebugStringW(L\"ムーブ\\n\");\n }\n };\n \n int main()\n {\n std::unique_ptr<int[]> data = std::make_unique<int[]>(10);\n Test sample(std::move(data));\n std::vector<Test> List;\n List.emplace_back(std::move(sample));\n pplx::create_task([test_c = std::forward<std::vector<Test>>(List), 10]()\n { \n });\n List.clear();\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T02:21:15.200", "favorite_count": 0, "id": "91270", "last_activity_date": "2022-09-26T10:26:41.813", "last_edit_date": "2022-09-26T10:26:41.813", "last_editor_user_id": "54485", "owner_user_id": "54485", "post_type": "question", "score": -1, "tags": [ "c++" ], "title": "create_taskに変数を渡す際にコピーを発生させたくない。", "view_count": 88 }
[ { "body": "`pplx::create_task`を簡単に説明している [Programming with\nTasks](https://github.com/microsoft/cpprestsdk/wiki/Programming-with-Tasks)\nの末尾にちょろっとリンクがありますが、`pplx::create_task`の元ネタとなった [タスクの並列化 (コンカレンシー\nランタイム)](https://learn.microsoft.com/ja-jp/cpp/parallel/concrt/task-\nparallelism-concurrency-runtime?view=msvc-170) が参考になるかと思います。\n\n> 一般的なパターンは、継続のチェーンの 1 つのタスクが変数に割り当てられ、別のタスクがその変数を読み取る場合です。\n> 各継続タスクが変数のそれぞれのコピーを保持するため、値によるキャプチャができません。\n> スタック割り当て変数においても、変数が有効でなくなる場合があるため、参照によるキャプチャができません。\n>\n> この問題を解決するには、std::shared_ptr などのスマート ポインターを使用し、変数をラップして、スマート ポインターを値で渡します。\n> この方法を使用すると、基になるオブジェクトが割り当てられ、読み込むことができ、それを使用するタスクのために十分な有効期間となります。\n\nと`std::shared_ptr`の利用が提案されています。(`std::unique_ptr`でなく)`std::shared_ptr`でオブジェクトを保持した場合、`std::shared_ptr`そのものはコピーされますが、保持したオブジェクトはコピーもムーブもされないため、今回の要件を満たすかと思います。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T02:38:42.777", "id": "91271", "last_activity_date": "2022-09-24T02:38:42.777", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "91270", "post_type": "answer", "score": 1 } ]
91270
91271
91271
{ "accepted_answer_id": null, "answer_count": 0, "body": "こんにちは, \n研究で深層学習をやっているものです.早速なのですが,PytorchとPythonは数を異なった扱いで処理しているのでしょうか?(例えばfloat32,\ndouble64など)\n\nというのも,例えば非常に簡単なニューラルネット(ボールの重さmと発射角度theta,速度vを与えると落ちる位置を予測する)をPythonの自作のコードで定義した時と,Pytorchの既存のメソッドで定義するとします.\n\nm, v\nの桁が小さい時は問題なく同じような予測結果になるのですが,桁を大きくすると(例えば10倍,100倍),自作ニューラルネットはoverflowします.\n\n評価関数に誤差二乗和やあるいは活性化関数にシグモイドなど,累乗計算を要するものは,10倍のデータ値の違いであっても,指数関数的に計算の桁は増えますので,無理はない話だと思います.しかし,じゃあPytorchはどうやってそれを解消しているのでしょうか?単純に,データを最初にスケーリングして小さくして,吐き出すときに戻しているのでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T06:21:39.560", "favorite_count": 0, "id": "91273", "last_activity_date": "2022-09-24T06:21:39.560", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "41334", "post_type": "question", "score": 0, "tags": [ "python", "python3", "機械学習", "pytorch" ], "title": "PytorchとPythonの数の扱いの違いについて", "view_count": 91 }
[]
91273
null
null
{ "accepted_answer_id": "91276", "answer_count": 1, "body": "freeCodeCampのYouTube動画でGitを学んでいます。\n\n[Git and GitHub for Beginners - Crash Course\n(YouTube)](https://youtu.be/RGOj5yH7evk?t=1422)\n\n[23:40 頃](https://youtu.be/RGOj5yH7evk?t=1422) の pbcopy\nを実施している箇所まで来たのですが、画像のように表示されてしまいました。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/BpJ6U.jpg)](https://i.stack.imgur.com/BpJ6U.jpg)\n\n私はWindowsを使っているのでpbcopyは使えませんでした。なので代替としてcopyが使えるとわかりました。\n\n加えてVSCodeでは>が認識されない?ので書いていません。\n\nどれをどうやって変えれば良いのかわかりません。 \nアドバイスのご教示お願いします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T08:01:23.797", "favorite_count": 0, "id": "91274", "last_activity_date": "2022-09-24T09:22:39.057", "last_edit_date": "2022-09-24T09:22:39.057", "last_editor_user_id": "19110", "owner_user_id": "53823", "post_type": "question", "score": 0, "tags": [ "cmd" ], "title": "Windows の VS Code で起動するターミナルで Git のために公開鍵をコピーしたい", "view_count": 227 }
[ { "body": "前回と同じで、エラーメッセージが英語でもまずは (機械翻訳にかけてでも) 読みましょう。\n\n* * *\n\n#### 1点目\n\n`copy` で指定してるファイルが「存在しない」というエラーです。キャプチャ画面を見る限りは \n作業フォルダ直下に `testkey`, `testkey.pub` が存在するのではないでしょうか?\n\n```\n\n Copy-Item: Cannot find path 'C:\\Users\\FMV\\.ssh\\testkey'\n \n```\n\n#### 2点目\n\n`pbcopy` は Mac 向けのコマンドなので Windows\nでは使えません。また、このコマンドはあくまで「ファイルの内容をクリップボードに送る」ためのものなので、Windows で copy\nコマンドを使っても代わりになりません。\n\n`testkey` などが存在することを確認したら、VSCode やメモ帳等でファイルを開いて、中身をクリップボードにコピーすれば用は済みそうです。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T08:48:08.820", "id": "91276", "last_activity_date": "2022-09-24T08:48:08.820", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "91274", "post_type": "answer", "score": 3 } ]
91274
91276
91276
{ "accepted_answer_id": null, "answer_count": 0, "body": "機械学習・深層学習を勉強していると、データを「訓練データ」「検証データ」「テストデータ」に分けることが大事だというのを見かけます。\n\nそれぞれ「訓練データ」は学習を行うデータ、「検証データ」はSVMのカーネル関数の定数などのハイパーパラメータを決めるためのデータ、「テストデータ」が学習後のモデルを評価するためのデータ、という役割を持ちますが、ディープラーニングの実装(PyTorch)の学習をしていると(勉強不足かも知れませんが)、あまり検証データを使っている実装を見かけません。(訓練データとテストデータのみ)\n\nディープラーニングでの検証データの使い道はどのようなものがあるのでしょうか? \nまた、ディープラーニングにおけるニューラルネットワークでは”ハイパーパラメータ”にはどのようなものがあるのでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T08:14:54.090", "favorite_count": 0, "id": "91275", "last_activity_date": "2022-09-24T08:14:54.090", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "40034", "post_type": "question", "score": 0, "tags": [ "機械学習", "深層学習", "pytorch" ], "title": "ディープラーニングでの検証データの使いみち", "view_count": 82 }
[]
91275
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "私のこの一連のゴタゴタに親身になってコメントいただいている方には大変申し訳ないのですが、一度始めからやり直し、24:23頃(https://www.youtube.com/watch?v=RGOj5yH7evk&t=1511s) \nまできてまたわからなくなってしまいました。2点明確にしたいことがあります。 \n①$ eval \"$(ssh-agent -s)\"がvscodeだと画像のように認識されず、stackoverflowにはGit\nBashでやるといいと書いてあり、やってみたところAgent pidがきちんと表示されました。しかしその後Git\nBashかvscodeかどちらでやれば良いのでしょうか。\n\n②それから次の処理はどう行えば良いのでしょうか。これはid_ed25519をtestkeyに変えるべきでしょうか。 \n「Adding your SSH key to the ssh-agent ②Add your SSH private key to the ssh-\nagent. キーを別の名前で作成した場合、または別の名前の既存のキーを追加する場合は、コマンドの id_ed25519 を秘密キー\nファイルの名前に置き換えます。\n\n$ ssh-add ~/.ssh/id_ed25519」 \n<https://docs.github.com/ja/authentication/connecting-to-github-with-\nssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent>", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T10:23:10.173", "favorite_count": 0, "id": "91278", "last_activity_date": "2022-09-26T00:13:08.673", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "53823", "post_type": "question", "score": -2, "tags": [ "git", "vscode", "git-bash" ], "title": "git vscodeでのterminal操作、 evalの後の操作方法", "view_count": 153 }
[ { "body": "(YouTubeなどに挙がっている)非公式の解説を参照する必要はありません。 \n質問文中にもリンクされていますが、[公式の説明](https://docs.github.com/ja/authentication/connecting-\nto-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-\nagent)のみに従って手続きを進めてください。\n\n鍵を生成したのであれば、次のセクション[Add a new SSH key(GitHub アカウントへの新しい SSH\nキーの追加)](https://docs.github.com/ja/authentication/connecting-to-github-with-\nssh/adding-a-new-ssh-key-to-your-github-account)に書かれている手順でその鍵を登録します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T00:13:08.673", "id": "91301", "last_activity_date": "2022-09-26T00:13:08.673", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2808", "parent_id": "91278", "post_type": "answer", "score": 1 } ]
91278
null
91301
{ "accepted_answer_id": null, "answer_count": 1, "body": "Qt CreatorでC++で開発をしています. \nプロジェクションマッピング用の画像をQtで作成後すぐに接続したプロジェクタで投影したいのですが,自動化の方法が分かりません.作業用のデスクトップと投影用のデスクトップを分けたいので今は画像ウィンドウを作業用デスクトップに表示し,画面の右にドラッグして外部スクリーン上で最大化しています.\n\n```\n\n import tkinter as tk\n import cv2\n from PIL import Image, ImageTk\n import pyautogui as pag\n \n scr_w,scr_h= pag.size()\n \n root = tk.Tk()\n w = scr_w # 横の長さ\n h = scr_h # 縦の長さ\n x = scr_w # 座標軸x\n y = 0 # 座標軸y\n \n root.geometry('%dx%d+%d+%d' % (w,h, x, y))\n \n result = cv2.imread(\"/Users/hoge/Desktop/result_pmi.png\")\n height, width, ch = result.shape\n rgb_cv2_image = cv2.resize(result, dsize=(int(h/height*width),scr_h))\n rgb_cv2_image = cv2.cvtColor(rgb_cv2_image, cv2.COLOR_BGR2RGB)\n \n pil_image = Image.fromarray(rgb_cv2_image)\n tk_image = ImageTk.PhotoImage(pil_image)\n \n canvas = tk.Canvas(root, bg=\"white\", height=h, width=w)\n canvas.create_image((w-int(h/height*width))/2, 0, image=tk_image, anchor=tk.NW)\n canvas.place(x=0, y=0)\n root.attributes('-fullscreen', True)\n root.mainloop()\n \n```\n\nこのpythonプログラムを \n`std::system(\"/opt/anaconda3/bin/python ./test.py\")` \nで呼び出します\n\nここまでで外部スクリーンに表示することはできたのですが,scr_w,scr_h=\npag.size()が得るのは外部スクリーンのサイズではなく作業用デスクトップのサイズなので外部スクリーン上で画面いっぱいに画像を表示することができません.", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T12:40:57.553", "favorite_count": 0, "id": "91279", "last_activity_date": "2022-09-26T07:05:29.843", "last_edit_date": "2022-09-25T11:56:00.820", "last_editor_user_id": "54517", "owner_user_id": "54517", "post_type": "question", "score": 0, "tags": [ "opencv", "qt", "qt-creator" ], "title": "自動で画像を外部スクリーンにフルスクリーンで表示するには", "view_count": 425 }
[ { "body": "screeninfoでマルチモニターのサイズを取得し,画像サイズをフルスクリーンに適応させることができました\n\n```\n\n import tkinter as tk\n import cv2\n from PIL import Image, ImageTk\n import pyautogui as pag\n import screeninfo\n import re\n import sys\n \n \n m = screeninfo.get_monitors()\n print(m)\n m = str(m)\n scr_w = re.findall(\"width=\\d+\",m)\n scr_h = re.findall(\"height=\\d+\",m)\n scr_w = re.findall(\"\\d+\",scr_w[1])\n scr_h = re.findall(\"\\d+\",scr_h[1])\n \n scr_w,scr_h = int(scr_w[0]),int(scr_h[0])\n \n root = tk.Tk()\n def close(event): #escキーで閉じる\n root.withdraw() # if you want to bring it back\n sys.exit() # if you want to exit the entire thing\n \n root.bind('<Escape>', close)\n w = scr_w # 横の長さ\n h = scr_h # 縦の長さ\n x = scr_w # 座標軸x\n y = 0 # 座標軸y\n \n root.geometry('%dx%d+%d+%d' % (w, h, x, y))\n \n result = cv2.imread(\"/Users/hoge/Desktop/result_pmi.png\")\n height, width, ch = result.shape\n rgb_cv2_image = cv2.resize(result, dsize=(int(h/height*width),scr_h))\n rgb_cv2_image = cv2.cvtColor(rgb_cv2_image, cv2.COLOR_BGR2RGB)\n \n pil_image = Image.fromarray(rgb_cv2_image)\n tk_image = ImageTk.PhotoImage(pil_image)\n \n canvas = tk.Canvas(root, bg=\"black\", height=h, width=w)\n canvas.create_image((w-int(h/height*width))/2, 0, image=tk_image, anchor=tk.NW)\n canvas.place(x=0, y=0)\n root.attributes('-fullscreen', True)\n root.mainloop()\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T07:05:29.843", "id": "91307", "last_activity_date": "2022-09-26T07:05:29.843", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54517", "parent_id": "91279", "post_type": "answer", "score": 1 } ]
91279
null
91307
{ "accepted_answer_id": null, "answer_count": 0, "body": "以前FFmpegを使って動画を編集していましたが、本業が忙しく一年近く触っていませんでした。 \n本日久々に編集しようとしたら、どのコマンドを実行してもと赤文字で出ます。\n\n```\n\n (ファイル名).mp4: No such file or directory\n \n```\n\n勿論、該当ファイルはffmpeg.exeと同じ階層(フォルダ)に置いてあります。\n\nパスを通しなおしてみたり、一度ffmpeg自体を削除して入れなおしてみたりもしたのですが、ダメでした。 \n更にコマンドプロンプトを立ち上げて最初にffmpegに移動した際、version等の情報が表示された後、以下のような黄色い文字のメッセージも出ます。 \n以前はこんなのなかったような気がします。\n\n```\n\n Use -h to get full help or, even better, run 'man ffmpeg'\n \n```\n\n解決方法が分かる方おられましたら助けてください。 \n宜しくお願いいたします。", "comment_count": 18, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T12:41:59.517", "favorite_count": 0, "id": "91280", "last_activity_date": "2022-09-24T16:21:54.077", "last_edit_date": "2022-09-24T16:21:54.077", "last_editor_user_id": "3060", "owner_user_id": "54518", "post_type": "question", "score": 0, "tags": [ "ffmpeg" ], "title": "FFmpeg でエラー: No such file or directory", "view_count": 472 }
[]
91280
null
null
{ "accepted_answer_id": "91283", "answer_count": 1, "body": "### 実現したいこと\n\nこちらのサイトを参考にスクロールしたときに文字を浮かび上がらせたいです。 \n「1.【サンプル】フェードイン(ふわっと)」をまねしたいです。\n\n現状は表示させたい文字が現れません。\n\n[【jQuery】スクロールして表示領域に入ったら要素をアニメーション表示させる『inview.js』の実装サンプル集](https://125naroom.com/web/3532)\n\n### 解説をいただきたい部分\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/Sgsvj.jpg)](https://i.stack.imgur.com/Sgsvj.jpg)\n\n①なぜ最初に$(なのか\n\n②eventはここでのスクロール操作なのか\n\n③isInviewの役割\n\n④stop()の意味\n\nよろしくお願いいたします。\n\n```\n\n $(function() {\n $('.inview').on('inview', function (event, isInview) {\n if(isInview) {\n $(this).stop().addClass('is-show');\n }\n });\n \n });\n```\n\n```\n\n * {\n background-attachment: fixed;\n }\n \n \n /* aboutmeの余白をうまいことしたい */\n \n \n .navbar {}\n \n \n header {\n padding: 300px 0;\n background-image: url(images/top.jpg);\n height: 100px;\n }\n \n .fadeIn {\n color: #fff;\n opacity: 0;\n transition: 2s;\n \n }\n \n .fadeIn.is-show {\n opacity: 1;\n }\n```\n\n```\n\n <!DOCTYPE html>\n <html lang=\"en\">\n \n <head>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Iori's Website</title>\n \n <link href=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css\" rel=\"stylesheet\"\n integrity=\"sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC\" crossorigin=\"anonymous\">\n <script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js\"\n integrity=\"sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM\" crossorigin=\"anonymous\">\n </script>\n \n \n <!-- slick ‍headとbody終わりの直前-->\n <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.css\" />\n <link rel=\"stylesheet\" type=\"text/css\"\n href=\"https://cdn.jsdelivr.net/npm/[email protected]/slick/slick-theme.css\" />\n \n <script src=\"https://code.jquery.com/jquery-3.6.0.min.js\"></script>\n \n \n <!-- Font Awesome -->\n <script src=\"https://kit.fontawesome.com/3715e2b643.js\" crossorigin=\"anonymous\"></script>\n \n \n \n \n <link rel=\"stylesheet\" href=\"styles.css\">\n <!-- <link rel=\"stylesheet\" href=\"https://unpkg.com/ress/dist/ress.min.css\"> -->\n \n </head>\n \n \n \n \n <body class=\"text-center\">\n \n \n <!-- Nav Bar -->\n \n <nav class=\"navbar navbar-expand-lg navbar-light \">\n <a class=\"navbar-brand\" href=\"\">yoriss67</a>\n \n <button class=\"navbar-toggler\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#navbarTogglerDemo02\"\n aria-controls=\"navbarTogglerDemo02\" aria-expanded=\"false\" aria-label=\"Toggle navigation\">\n <span class=\"navbar-toggler-icon\"></span>\n </button>\n \n <div class=\"collapse navbar-collapse\" id=\"navbarTogglerDemo02\">\n \n <ul class=\"navbar-nav ms-auto\">\n <li class=\"nav-item\">\n <a class=\"nav-link\" href=\"\">Contact</a>\n </li>\n <li class=\"nav-item\">\n <a class=\"nav-link\" href=\"\">Pricing</a>\n </li>\n <li class=\"nav-item\">\n <a class=\"nav-link\" href=\"\">Download</a>\n </li>\n </ul>\n </div>\n </nav>\n \n \n <!-- Title -->\n \n \n <header id=\"header\">\n <div>\n <h1 class=\"fadeIn\">Thank you for visiting.</h1>\n </div>\n <div class=\"\">\n <p class=\"fadeIn\" data-test-daa=\"This is a test\">I'm Iori.</p>\n </div>\n </style>\n \n \n </header>\n \n <hr>\n \n <div class=\"aboutme\">\n <h2>About Me</h2>\n \n <div class=\"row\">\n <div class=\"col-md-6\">\n <img class=\"imgprofile\" src=\"images/8fdb71d0-e360-4b74-9761-7795784871bd-0-modified.png\" alt=\"my-profile\"\n width=\"200px\" height=\"200px\">\n </div>\n <div class=\"col-md-6\">\n <p>I'm a sophomore student at a university in Japan. My major is English and Social Science.\n <br><br>I have started studying programming out of mainly curiosity and a bit of hope to make use of it for my\n future career.</p>\n </div>\n </div>\n \n <!-- <a href=\"https://www.notion.so/396eca31a8f44b5c989ac4b8efa302f0?v=c3d6906ee5654da9a5534cfa7b0b79bc&p=d67a03c53bd949b0902f76774734cf57&pm=s\" target=\"_blank\">Here's my Notion.</a> -->\n \n </div>\n \n \n <hr>\n \n \n <div class=\"mywebdevelopmentpath\">\n <h2>My Web Development Path</h2>\n \n \n <!-- Web Dev Blog-->\n <button data-modal-id=\"modal-1\">Open Modal 1</button>\n <button data-modal-id=\"modal-2\">Open Modal 2</button>\n \n <div id=\"modal-1\">Modal 1</div>\n <div id=\"modal-2\">Modal 2</div>\n \n \n \n \n </div>\n \n \n <hr>\n \n \n <div class=\"whatilike\">\n <h2>What I like</h2>\n \n <div class=\"slider\">\n <div><img src=\"images/surfers.jpg\" alt=\"surfers\" /></div>\n <div><img src=\"images/circle.jpg\" alt=\"circle\" /></div>\n <div><img src=\"images/kelia.jpg\" alt=\"kelia\" /></div>\n <div><img src=\"images/sunset.jpg\" alt=\"sunset\" /></div>\n <div><img src=\"images/surfboy.jpg\" alt=\"surfboy\" /></div>\n <div><img src=\"images/yogurt.jpg\" alt=\"yogurt\" /></div>\n <div><img src=\"images/palmtree.jpg\" alt=\"palmtree\" /></div>\n <div><img src=\"images/yoga.jpg\" alt=\"yoga\" /></div>\n \n </div>\n \n \n </div>\n \n <hr>\n \n <h2>Works</h2>\n <div class=\"works\">\n \n <ul>\n <li id=\"Travel Blog\">\n <div>\n <a href=\"https://yoriss67.github.io/Travel-Blog/\" target=\"_blank\">\n <img src=\"./images/images06.jpg\" alt=\"images06\">\n <h5>Travel Blog</h5>\n </a>\n \n </div>\n <div>\n \n <small> Sep 2022 </small>\n <p>初めての模写です。</p>\n \n </div>\n \n </li>\n \n \n <li id=\"Travel Blog\">\n <a href=\"https://yoriss67.github.io/Travel-Blog/\" target=\"_blank\">\n <img src=\"./images/images06.jpg\" alt=\"images06\">\n <h5>Travel Blog</h5>\n </a>\n <span> Sep 2022 </span>\n </li>\n \n <li id=\"Travel Blog\">\n <a href=\"https://yoriss67.github.io/Travel-Blog/\" target=\"_blank\">\n <img src=\"./images/images06.jpg\" alt=\"images06\">\n <h5>Travel Blog</h5>\n </a>\n <span> Sep 2022 </span>\n </li>\n \n </ul>\n \n \n \n \n </div>\n \n \n \n <h2>Contact</h2>\n \n <div class=\"contact\">\n <div class=\"github\">\n <i class=\"fa-brands fa-github\"></i>\n <a href=\"https://github.com/yoriss67\">yoriss67</a>\n </div>\n \n <div class=\"twitter\">\n <i class=\"fa-brands fa-twitter\"></i>\n <a href=\"https://twitter.com/iori73wsy\">Iori67</a>\n </div>\n \n <div class=\"instagram\">\n <i class=\"fa-brands fa-instagram\"> </i>\n \n <a href=\"https://www.instagram.com/ioriiii_13/\">ioriii_13</a>\n </div>\n \n </div>\n \n \n \n \n \n \n \n \n \n \n \n \n <!-- inview CDN -->\n <script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script>\n <script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery.inview/1.0.0/jquery.inview.min.js\"></script>\n \n \n <!-- inview download -->\n \n <script src=\"./jquery.inview.min.js\"></script>\n \n <!-- slick -->\n <script type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.min.js\">\n </script>\n \n \n \n \n <script src=\"index.js\"></script>\n \n \n </body>\n \n </html>\n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T14:59:55.653", "favorite_count": 0, "id": "91281", "last_activity_date": "2022-09-24T22:15:03.780", "last_edit_date": "2022-09-24T22:15:03.780", "last_editor_user_id": "3054", "owner_user_id": "53823", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "css" ], "title": "inview.jsでスクロールした際に文字を浮かび上がらせたい", "view_count": 155 }
[ { "body": "### なぜ最初に `$(` なのか\n\njQuery というライブラリを使用しているので、`$` は `jQuery` を指します。\n\n> `jQuery(callback)`\n>\n> DOM Documentのロードが終わった際に、バインドしておいた関数が実行されるようになる。 \n> この関数は `$(document).ready()` と全く同様に動作する。 \n> —— [jQuery(callback)](http://semooh.jp/jquery/api/core/jQuery/callback/)\n\n例えば HTML の最後に JavaScript を書くなら、必要ありません。\n\n### `event` はここでのスクロール操作なのか\n\njQuery のプラグインである [inview](https://github.com/zuk/jquery.inview)\nを使用しているので、それによって追加された `inview` イベントです。スクロール操作により発生するという意味では、スクロール操作であると言えます。\n\n### `isInview` の役割\n\n> The event will only fire when the element comes in to view of the viewport,\n> and out of view. \n> ... \n> The variable after the event argument indicates the visible state in the\n> viewport. \n> —— [Usage](https://github.com/zuk/jquery.inview#usage)\n\nイベントはターゲットの要素が可視領域に入った時と出た時の両方で発生します。どちらなのか区別するのが2番目の引数 (質問のコードでは `isInview`\nとして利用) です。\n\n### `stop()` の意味\n\n> 指定した要素集合から、現在動作中のアニメーション処理を全て中止します。 \n> —— [`stop()`](http://semooh.jp/jquery/api/effects/stop/_/)\n\n他でアニメーションさせていないなら、必要ないと思います。\n\n### 「現状は表示させたい文字が現れません」\n\n現在の JavaScript では `$('.inview').on('inview' ` としていますね。対象の要素を `inview`\nというクラスで探しています。しかし、HTML には `inview` クラスが指定されていません。HTML で `class=\"inview\nfadeIn\"` のように `inview` クラスを追加する必要があります。\n\nもしくは、JavaScript 側を `$('.fadeIn').on('inview' ` のようにして `fadeIn`\nクラスで探すようにしてもよいでしょう。\n\n(その他にも、重複した JavaScript の読み込みや、 `color: #fff;` など気になる点はあります)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T21:32:14.770", "id": "91283", "last_activity_date": "2022-09-24T22:12:35.207", "last_edit_date": "2022-09-24T22:12:35.207", "last_editor_user_id": "3054", "owner_user_id": "3054", "parent_id": "91281", "post_type": "answer", "score": 2 } ]
91281
91283
91283
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在、tfjs-models/pose-\ndetectionのライブラリを用いて、ポーズ解析のモジュールを追加実装しているところです。下記コードで処理を行っていますが、下記エラーが出力して処理ができない状況です。原因が分からず困っています... \n実装コード(一部)\n\n```\n\n import '@tensorflow/tfjs-core';\n import '@tensorflow/tfjs-converter';\n import '@tensorflow/tfjs-backend-webgl';\n import '@mediapipe/pose';\n \n import * as poseDetection from '@tensorflow-models/pose-detection';\n \n async getData(data: WorkerPortObject) {\n this.video = document.getElementById(\"video-test\") as HTMLVideoElement;\n \n if (this.video !== null) {\n navigator.mediaDevices\n .getUserMedia({\n video: true,\n audio: false,\n })\n .then((stream) => {\n this.video.srcObject = stream;\n this.video.play();\n })\n .catch((e) => {\n console.log(e);\n });\n \n this.video.setAttribute(\"width\", \"640\");\n this.video.setAttribute(\"height\", \"480\");\n \n const model = await poseDetection.SupportedModels.MoveNet;\n const net = await poseDetection.createDetector(model);\n \n setInterval(() => {\n // detect(net, this.video);\n const pose = net.estimatePoses(this.video);\n console.log(pose);\n }, 100);\n }\n \n```\n\n出力エラー文\n\n```\n\n tf-core.esm.js:17 Uncaught (in promise) TypeError: t is not a function\n at tf-core.esm.js:17:43052\n at tf-core.esm.js:17:41139\n at t.scopedRun (tf-core.esm.js:17:41281)\n at t.tidy (tf-core.esm.js:17:41033)\n at f (tf-core.esm.js:17:43031)\n at tf-core.esm.js:17:43365\n at t.scopedRun (tf-core.esm.js:17:41281)\n at t.runKernelFunc (tf-core.esm.js:17:43174)\n at t.runKernel (tf-core.esm.js:17:41712)\n at expandDims_ (expand_dims.js:43:12)\n \n```\n\n使用しているnpm packageのバージョン\n\n```\n\n \"@tensorflow-models/pose-detection\": \"^2.0.0\",\n \"@tensorflow/tfjs-backend-webgl\": \"^3.20.0\",\n \"@tensorflow/tfjs-converter\": \"^3.20.0\",\n \"@tensorflow/tfjs-core\": \"^3.20.0\",\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-24T15:01:59.793", "favorite_count": 0, "id": "91282", "last_activity_date": "2022-09-24T15:01:59.793", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "53616", "post_type": "question", "score": 0, "tags": [ "typescript", "機械学習", "tensorflow", "webpack" ], "title": "tfjs-modelsのpose-detectionでポーズ解析を行っているが、「TypeError: t is not a function」というエラーが出力", "view_count": 112 }
[]
91282
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "freeCodeCampのYouTube Git and GitHub for Beginners - Crash Courseの25:45頃にgit\npush origin master(私の場合はmain)をしたいのですが、下記の通りPermission denied (publickey)\nと出てしまいました。\n\n```\n\n PS C:\\Users\\FMV\\git> git push origin main\n [email protected]: Permission denied (publickey).\n fatal: Could not read from remote repository.\n \n Please make sure you have the correct access rights\n and the repository exists.\n \n```\n\nそこでこちらのサイトを参考に直そうとしていました。 \n<https://ormcat.net/blog/20210509_github-denied-publickey/>\n\nGitHub との疎通テストを行う → NG パターン \nSSH コマンドのデバッグログで鍵を確認する → $ ssh -vT [email protected] \nまでやった結果が下の結果です。\n\n```\n\n PS C:\\Users\\FMV\\git> ssh -T [email protected]\n [email protected]: Permission denied (publickey).\n PS C:\\Users\\FMV\\git> ssh -vT [email protected]\n OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2\n debug1: Connecting to github.com [20.27.177.113] port 22.\n debug1: Connection established.\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_rsa type 0\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_rsa-cert type -1\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_dsa type -1\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_dsa-cert type -1\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_ecdsa type -1\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_ecdsa-cert type -1\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_ed25519 type 3\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_ed25519-cert type -1\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_xmss type -1\n debug1: identity file C:\\\\Users\\\\FMV/.ssh/id_xmss-cert type -1\n debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1\n debug1: Remote protocol version 2.0, remote software version babeld-98e6a628\n debug1: no match: babeld-98e6a628\n debug1: Authenticating to github.com:22 as 'git'\n debug1: SSH2_MSG_KEXINIT sent\n debug1: SSH2_MSG_KEXINIT received\n debug1: kex: algorithm: curve25519-sha256\n debug1: kex: host key algorithm: ecdsa-sha2-nistp256\n debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none\n debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none\n debug1: expecting SSH2_MSG_KEX_ECDH_REPLY\n debug1: Server host key: ecdsa-sha2-nistp256 SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM\n debug1: Host 'github.com' is known and matches the ECDSA host key.\n debug1: Found key in C:\\\\Users\\\\FMV/.ssh/known_hosts:3\n debug1: rekey out after 134217728 blocks\n debug1: SSH2_MSG_NEWKEYS sent\n debug1: expecting SSH2_MSG_NEWKEYS\n debug1: SSH2_MSG_NEWKEYS received\n debug1: rekey in after 134217728 blocks\n debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory\n debug1: Will attempt key: C:\\\\Users\\\\FMV/.ssh/id_rsa RSA SHA256:nz+XwOvg8KN+x4tgzz7eNc77ThGLQn3UOJKECkWjwK0\n debug1: Will attempt key: C:\\\\Users\\\\FMV/.ssh/id_dsa\n debug1: Will attempt key: C:\\\\Users\\\\FMV/.ssh/id_ecdsa\n debug1: Will attempt key: C:\\\\Users\\\\FMV/.ssh/id_ed25519 ED25519 SHA256:+fvNB2EJB6PpPULfb7cCEuS/9vR/Bq5409GjY62Pqq8\n debug1: Will attempt key: C:\\\\Users\\\\FMV/.ssh/id_xmss \n debug1: SSH2_MSG_EXT_INFO received\n debug1: kex_input_ext_info: server-sig-algs=<[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa>\n debug1: SSH2_MSG_SERVICE_ACCEPT received\n debug1: Authentications that can continue: publickey\n debug1: Next authentication method: publickey\n debug1: Offering public key: C:\\\\Users\\\\FMV/.ssh/id_rsa RSA SHA256:nz+XwOvg8KN+x4tgzz7eNc77ThGLQn3UOJKECkWjwK0\n debug1: Authentications that can continue: publickey\n debug1: Trying private key: C:\\\\Users\\\\FMV/.ssh/id_dsa\n debug1: Trying private key: C:\\\\Users\\\\FMV/.ssh/id_ecdsa\n debug1: Offering public key: C:\\\\Users\\\\FMV/.ssh/id_ed25519 ED25519 SHA256:+fvNB2EJB6PpPULfb7cCEuS/9vR/Bq5409GjY62Pqq8\n debug1: Authentications that can continue: publickey\n debug1: Trying private key: C:\\\\Users\\\\FMV/.ssh/id_xmss\n debug1: No more authentication methods to try.\n [email protected]: Permission denied (publickey).\n \n```\n\nその後、 \n秘密鍵がそこにあるか ? と 秘密鍵と公開鍵の組み合わせは正しいか ? \nをやった結果がこちらです。\n\n```\n\n PS C:\\Users\\FMV\\git> ls ~/.ssh\n \n Directory: C:\\Users\\FMV\\.ssh\n \n Mode LastWriteTime Length Name\n ---- ------------- ------ ----\n d---- 2022/09/24 18:45 demo-repo\n -a--- 2022/09/24 14:15 12288 .config.swp\n -a--- 2022/09/24 18:42 419 id_ed25519\n -a--- 2022/09/24 18:42 109 id_ed25519.pub\n -a--- 2022/09/24 18:29 2610 id_rsa\n -a--- 2022/09/24 18:29 574 id_rsa.pub\n -a--- 2022/09/24 13:18 832 known_hosts\n -a--- 2022/09/24 10:08 92 known_hosts.old\n \n PS C:\\Users\\FMV\\git> ssh-keygen -t rsa\n Generating public/private rsa key pair.\n Enter file in which to save the key (C:\\Users\\FMV/.ssh/id_rsa): \n \n```\n\n既にYouTubeでtestkeyというkeyを作ったのでここから進めて良いのか、またどう対処すれば良いのかわからず止まっています。\n\nアドバイスよろしくお願いいたします。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/9Zzn1.jpg)](https://i.stack.imgur.com/9Zzn1.jpg)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T01:32:08.010", "favorite_count": 0, "id": "91284", "last_activity_date": "2022-09-26T00:32:23.857", "last_edit_date": "2022-09-25T05:23:01.397", "last_editor_user_id": "53823", "owner_user_id": "53823", "post_type": "question", "score": 0, "tags": [ "git" ], "title": "git Permission denied (publickey)", "view_count": 467 }
[ { "body": "> Permission denied (publickey).\n\nってのは、接続鍵が間違っている、あるいは接続鍵の設定が間違っている、場合に出ます。 \nそこらへんみなおしてみては", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T13:02:02.967", "id": "91295", "last_activity_date": "2022-09-25T13:02:02.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27481", "parent_id": "91284", "post_type": "answer", "score": -1 }, { "body": "[こちら](https://ja.stackoverflow.com/a/91301/2808)でも回答しましたが、外部のサイトの説明は参考にせずに、公式サイトの手順に沿って作業してください。 \n余計な混乱を招くだけですし、他者(回答候補者)から見て質問者が実際に何をやったのかが把握できません。\n\n* * *\n\n[`id_ed25519.pub` を GitHub\nへ登録する](https://docs.github.com/ja/authentication/connecting-to-github-with-\nssh/adding-a-new-ssh-key-to-your-github-account#adding-a-new-ssh-key-to-your-\naccount)必要がありますが、この操作は行われたでしょうか。 \nその上でこの問題が出た場合、(説明文にもある通り)[トラブルシューティング](https://docs.github.com/ja/authentication/troubleshooting-\nssh/error-permission-denied-publickey)を参照し、それでも問題が解決しなかった場合、状況をこちらに記載してください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T00:24:27.747", "id": "91302", "last_activity_date": "2022-09-26T00:32:23.857", "last_edit_date": "2022-09-26T00:32:23.857", "last_editor_user_id": "2808", "owner_user_id": "2808", "parent_id": "91284", "post_type": "answer", "score": 1 } ]
91284
null
91302
{ "accepted_answer_id": "91286", "answer_count": 1, "body": "初心者です。\n\n```\n\n d = {\"a\":\"1\",\"b\":\"2\",\"c\":\"3\"}\n dic = list(d.keys())\n print(dic)\n \n```\n\nこれを出力すると\n\n```\n\n ['a', 'b', 'c']\n \n```\n\nとなるのですが、[]と ' そして , を消したものを変数化したいです。\n\nちなみに、\n\n```\n\n print(*dic)\n \n```\n\nとやってみた際、使用しているモジュール(discord.py)の影響でできませんでした。 \nつまり、\n\n```\n\n print(dic_after)\n \n```\n\nのみで\n\n```\n\n a b c\n \n```\n\nの出力がほしいということです。 \nわかりずらいかもですがご了承願います。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T01:52:27.383", "favorite_count": 0, "id": "91285", "last_activity_date": "2022-09-25T16:32:10.450", "last_edit_date": "2022-09-25T16:32:10.450", "last_editor_user_id": "19110", "owner_user_id": "54525", "post_type": "question", "score": 1, "tags": [ "python" ], "title": "pythonで辞書を出力した時のカッコを消したい。", "view_count": 153 }
[ { "body": "例えば `' '.join(dic)` は如何でしょう? \n以下のように出来るでしょう。\n\n```\n\n d = {\"a\":\"1\",\"b\":\"2\",\"c\":\"3\"}\n dic = list(d.keys())\n print(dic)\n dic_after = ' '.join(dic)\n print(dic_after)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T02:00:25.297", "id": "91286", "last_activity_date": "2022-09-25T02:00:25.297", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "91285", "post_type": "answer", "score": 1 } ]
91285
91286
91286
{ "accepted_answer_id": null, "answer_count": 1, "body": "# やりたいこと\n\n・多段プロキシ設定\n\n 1. 特定のIP郡(A)かつ、特定のURL(B)のみ、上位プロキシを経由させたい。\n 2. それ以外通信は、通信を遮断したい。\n\n特定のIP(A)は、B専用として利用したいです。 \n1の手順については、aclでIPをまとめて定義して、\n\n```\n\n cache_peer PROXY HOST TYPE HTTP PORT ICP PORT ICP OPTION\n \n```\n\n上記内容で、設定できる認識となります。 \nその他、通信を拒否したいのですが、 \n他のIP等が通信する際にも使用するため、拒否することで他に影響がないかを懸念しています。\n\n以下の内容を記載を想定しています。 \nsquidは、上からルールが適用されると聞いたので、 \n下の内容を記載して、一律拒否でも問題ない認識なのですが、 \nこちらの設定で問題ないかわかりますでしょうか。\n\n```\n\n http_access deny acl定義(A)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T03:22:59.413", "favorite_count": 0, "id": "91287", "last_activity_date": "2022-09-27T15:04:35.250", "last_edit_date": "2022-09-26T05:46:08.987", "last_editor_user_id": "29826", "owner_user_id": "35012", "post_type": "question", "score": 0, "tags": [ "linux", "squid" ], "title": "squid 多段プロキシ設定について", "view_count": 192 }
[ { "body": "アクセス制御と上位プロキシへの転送は別です。 \n`cache_peer` で設定しても自動的に許可されるわけではありません。\n\nまずはアクセス制御だけ動作を確認するといいと思います。\n\n```\n\n acl (A)の定義\n acl (B)の定義\n http_access allow (A) (B) # (A) かつ (B) を許可\n http_access deny (A) # それ以外の (A) を拒否\n \n http_access allow (他、許可する acl)\n :\n http_access deny all\n \n```\n\n上位プロキシへの転送は `cache_peer` で間違いないですが、(A) のみ転送し、それ以外は転送しないよう、`cache_peer_access`\n設定が必要です。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T15:04:35.250", "id": "91339", "last_activity_date": "2022-09-27T15:04:35.250", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4603", "parent_id": "91287", "post_type": "answer", "score": 1 } ]
91287
null
91339
{ "accepted_answer_id": "91292", "answer_count": 1, "body": "-実現したいこと-\n\n時間と分のみを設定してあとは現在時刻を表示させるようにしたいです。\n\n= latest access: 2022/9/25 23:25\n\n```\n\n <!doctype html>\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <title>テンプレート</title>\n <link href=\"../../_common/images/favicon.ico\" rel=\"shortcut icon\">\n <link href=\"https://fonts.googleapis.com/css?family=M+PLUS+1p:400,500\" rel=\"stylesheet\">\n <link href=\"../../_common/css/style.css\" rel=\"stylesheet\">\n </head>\n <body>\n <header>\n <div class=\"container\">\n <h1>タイトル</h1>\n <h2>サブタイトル</h2>\n </div><!-- /.container -->\n </header>\n <main>\n <div class=\"container\">\n <section>\n \n <p>latest access: <span id=\"time\"></span></p>\n \n </section>\n </div><!-- /.container -->\n </main>\n <footer>\n <div class=\"container\">\n <p>JavaScript Samples</p>\n </div><!-- /.container -->\n </footer>\n \n <script>\n \n const now = new Date();\n const year = now. getFullYear();\n const month = now.getMonth();\n const date = now.getDate();\n const hour = now.setHours(23);\n const min = now.setMinutes(25);\n \n \n \n let ampm = '';\n \n if (hour < 12) {\n ampm = 'a.m.';\n } else {\n ampm = 'p.m.';\n }\n \n const output = `${year}/${month + 1}/${date} ${hour % 12}:${min}${ampm}`;\n document.getElementById('time').textContent = output;\n \n \n \n </script>\n </body>\n </html>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T05:30:29.377", "favorite_count": 0, "id": "91288", "last_activity_date": "2022-09-25T10:42:59.530", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "53823", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "setHours() とsetMinutes()のみの指定", "view_count": 57 }
[ { "body": "`setHours` と `getHours` の機能を混同しているようです。`setMinutes` と `getMinutes` も同様。\n\n`setHours`は時間を設定します。返り値は日付/時刻になります。 \n`getHours`は日付/時刻から時間を数値として取得します。\n\n```\n\n const now = new Date();\n now.setHours(23);\n now.setMinutes(25);\n const year = now.getFullYear();\n const month = now.getMonth();\n const date = now.getDate();\n const hour = now.getHours();\n const min = now.getMinutes();\n \n let ampm = \"\";\n \n if (hour < 12) {\n ampm = \"a.m.\";\n } else {\n ampm = \"p.m.\";\n }\n \n const output = `${year}/${month + 1}/${date} ${hour % 12}:${min}${ampm}`;\n document.getElementById(\"time\").textContent = output;\n```\n\n```\n\n <header>\n <div class=\"container\">\n <h1>タイトル</h1>\n <h2>サブタイトル</h2>\n </div><!-- /.container -->\n </header>\n <main>\n <div class=\"container\">\n <section>\n \n <p>latest access: <span id=\"time\"></span></p>\n \n </section>\n </div><!-- /.container -->\n </main>\n <footer>\n <div class=\"container\">\n <p>JavaScript Samples</p>\n </div><!-- /.container -->\n </footer>\n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T07:49:00.430", "id": "91292", "last_activity_date": "2022-09-25T10:42:59.530", "last_edit_date": "2022-09-25T10:42:59.530", "last_editor_user_id": "19110", "owner_user_id": "42240", "parent_id": "91288", "post_type": "answer", "score": 4 } ]
91288
91292
91292
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在JavaでAndroidアプリからWi-Fiの接続状態の制御の検証を実施しています。\n\nやりたいこととしてはAndroid12以降のバージョンの端末でアプリ起動してボタン押下時にWi-\nFiの切断をしたいのですが、`WifiManager#setWifiEnabled` および `WifiManager#disconnect`\nはdeprecatedで廃止済みとなっており、代替案が見つかっていな状況です。 \n上記APIはAndroid8や9のバージョンにおいては正常に動作します(Wifiが切断される)。\n\n色々調べてみたところ、`setWifiEnabled`, `disconnect`\nについては見つけられたものの比較的新しいバージョンにおいてはdeprecatedの扱いのため別の方法を模索中ですが、どなたかご存じでしたらノウハウ等あればご教示いただけますでしょうか。 \nよろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T05:42:45.680", "favorite_count": 0, "id": "91289", "last_activity_date": "2022-10-05T13:06:31.080", "last_edit_date": "2022-09-27T04:20:21.583", "last_editor_user_id": "3060", "owner_user_id": "54527", "post_type": "question", "score": 3, "tags": [ "java", "android" ], "title": "Android 12 以降でアプリから Wi-Fi 接続を制御したい", "view_count": 1079 }
[ { "body": "android10以降、ユーザーのプライバシーの観点から、通常のアプリがwifi設定を直接操作できなくなっています。([公式](https://developer.android.com/about/versions/10/privacy/changes?hl=ja#enable-\ndisable-wifi))\n\n> Wi-Fi の有効化 / 無効化に関する制限 Android 10 以降をターゲットとするアプリは、Wi-Fiを有効または無効にすることはできません。 \n> WifiManager.setWifiEnabled() メソッドからは常に false が返されます。\n>\n> Wi-Fi の有効 / 無効を切り替えるようにユーザーに促す必要がある場合は、設定パネルを使用します。\n\nそのため、設定パネルを表示させ、ユーザーが自発的にwifiをONにする必要があります。\n\n例えば\n\n```\n\n Intent panelIntent = new Intent(Android.Provider.Settings.Panel.ActionWifi);\n StartActivityForResult(panelIntent,1);\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-05T13:06:31.080", "id": "91461", "last_activity_date": "2022-10-05T13:06:31.080", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "39410", "parent_id": "91289", "post_type": "answer", "score": 4 } ]
91289
null
91461
{ "accepted_answer_id": "91308", "answer_count": 2, "body": "## 実現したいこと\n\n * CupertinoIcons.配列[index]のような形で、実行するメソッドを動的に切り替えたいです。\n\n```\n\n class Menu extends StatelessWidget {\n const Menu({super.key});\n \n static const btnTitles = ['ランキング', '撮影', 'プロフィール'];\n static const icons = ['star_fill', 'clock_solid', 'circle_grid_3x3_fill'];\n \n @override\n Widget build(BuildContext context) {\n return CupertinoTabScaffold(\n tabBar: CupertinoTabBar(\n items: <BottomNavigationBarItem>[\n for(var i = 0; i < 3; i++)\n BottomNavigationBarItem(\n icon: Icon(CupertinoIcons.icons[i]), // 動的に切り替えたい\n label: btnTitles[i],\n ),\n ],\n ),\n ),\n },\n }\n \n```\n\n## 起きている問題\n\nコードの中で下記の配列を定義しています。\n\n```\n\n static const btnTitles = ['ランキング', '撮影', 'プロフィール'];\n static const icons = ['star_fill', 'clock_solid', 'circle_grid_3x3_fill'];\n \n```\n\nそして、配列の値をループさせて動的に切り替えたいです。\n\n```\n\n for(var i = 0; i < 3; i++)\n BottomNavigationBarItem(\n icon: Icon(CupertinoIcons.icons[i]), // 動的に切り替えたい\n label: btnTitles[i], // ここは狙い通りできている\n ),\n \n```\n\n```\n\n icon: Icon(CupertinoIcons.icons[i]),\n \n # こんな感じで展開させたい\n icon: Icon(CupertinoIcons.star_fill)\n icon: Icon(CupertinoIcons.clock_solid)\n icon: Icon(CupertinoIcons.circle_grid_3x3_fill)\n \n```\n\n## 問題\n\n当然ですが、今のコードだと下記のエラーが出て動きません\n\n```\n\n lib/main.dart:33:41: Error: Member not found: 'icons'.\n icon: Icon(CupertinoIcons.icons[i]),\n \n```\n\nicons[i]というメソッドを呼び出している形になってしまっていると思います。\n\nrubyのようなsendメソッドのようなものがflutterかdartに存在すればやりたいことは実現できると思うのですが、見つけられませんでした\n\n```\n\n irb(main):012:0> hoge = [:to_i, :to_s]\n => [:to_i, :to_s]\n irb(main):013:0> 1.send(hoge[0])\n => 1\n irb(main):014:0> 1.send(hoge[1])\n => \"1\"\n \n```\n\n該当するメソッドはあるのでしょうか?またやりたいことを実現するにはどのような解決策があるでしょうか?よろしくおねがいします。\n\n## 追記\n\n回答してくれたお二人のアドバイスを参考に試したら動作しました。ありがとうございました!\n\n```\n\n static const btnTitles = ['ランキング', '撮影', 'プロフィール'];\n static const icons = <IconData>[CupertinoIcons.star_fill, CupertinoIcons.clock_solid, CupertinoIcons.circle_grid_3x3_fill];\n \n @override\n Widget build(BuildContext context) {\n return CupertinoTabScaffold(\n tabBar: CupertinoTabBar(\n height: 65.0,\n             items: <BottomNavigationBarItem>[\n         for(var i = 0; i < 3; i++)\n       BottomNavigationBarItem(\n     icon: Icon(icons[i]),\n     label: btnTitles[i],\n   ),\n ・\n ・\n ・\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T05:43:18.500", "favorite_count": 0, "id": "91290", "last_activity_date": "2022-09-26T12:41:43.590", "last_edit_date": "2022-09-26T12:41:43.590", "last_editor_user_id": "53658", "owner_user_id": "53658", "post_type": "question", "score": 0, "tags": [ "flutter", "dart" ], "title": "Flutterで実行するメソッド名を動的に変化させたい", "view_count": 304 }
[ { "body": "Dart においても Ruby\nにおいても、通常のアプリケーションコードにおいて呼び出し側でメソッド名を動的に構築するのはセキュリティ面などいくつかの意味で扱いづらいコードになるため、特別な理由がない限り避けた方が無難です。\n\n今回の場合であれば、アイコンをその名前の文字列の配列として保持するのではなく、直接 `CupertinoIcons` から得られる `IconData`\nの配列として保持すれば良さそうです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T16:30:13.300", "id": "91299", "last_activity_date": "2022-09-26T09:00:11.483", "last_edit_date": "2022-09-26T09:00:11.483", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "91290", "post_type": "answer", "score": 1 }, { "body": "該当するアイコン名は、CupertinoIconsクラス内のstaticなメンバーでIconDataを返しているにすぎません。 \nアイコン名(文字列)->IconData変換というマッピング機能は保持していません。\n\nアイコン名が固定であれば、`static const icons = <IconData>[CupertinoIcons.star_fill,\nCupertinoIcons.clock_solid,\nCupertinoIcons.circle_grid_3x3_fill];`の様にIconDataを返すようにするのが無難です。\n\nもしアイコン名を文字列として扱いそれからIconDataを取り出したいのであれば、CupertinoIconsのソースの中身を取り出し、アイコン名とIconDataのmapを自作するという方法しかないでしょう。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T07:43:59.597", "id": "91308", "last_activity_date": "2022-09-26T07:43:59.597", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54446", "parent_id": "91290", "post_type": "answer", "score": 1 } ]
91290
91308
91299
{ "accepted_answer_id": null, "answer_count": 2, "body": "以下問題についてです。\n\natcorder 270 問題3 \n<https://atcoder.jp/contests/abc270/tasks/abc270_c>\n\n提出したところ10問のテストが時間切れとなってしまいます。\n\n現在pythonでatcorderに取り組んでいるのはpython力をつけたいという目的もあり、他の言語は使いたくないと考えています。\n\npythonでかつ再帰処理を使って時間切れとならずに解く方法はありますでしょうか?\n\n```\n\n import sys\n def trace(l,traced,x,y):\n # nodeが持つリンクを全て調査\n flg = 0\n for i in l[x]:\n # 追跡済みじゃなければ値を追加\n if i not in traced:\n traced.append(i)\n flg+=1\n # 目標に到達したら終了\n if i == y:\n return True\n # 終了以外は追跡を継続\n if not trace(l,traced,i,y):\n traced.pop()\n flg -= 1\n # ノードが次の接続先を持っていたかいなか\n return flg\n \n def resolve():\n input = sys.stdin.readline\n \n N,X,Y=map(int, input().split())\n \n l = [[] for _ in range(N+1)]\n \n for _ in [0]*(N-1):\n A,B = map(int,input().split())\n l[A].append(B)\n l[B].append(A)\n \n traced = [X]\n \n trace(l,traced,X,Y)\n \n print(' '.join([str(s) for s in traced]))\n resolve()\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T12:02:07.907", "favorite_count": 0, "id": "91294", "last_activity_date": "2022-09-25T19:35:42.537", "last_edit_date": "2022-09-25T16:53:03.977", "last_editor_user_id": "3060", "owner_user_id": "704", "post_type": "question", "score": 0, "tags": [ "python", "アルゴリズム" ], "title": "Python で再帰処理を高速化するには?", "view_count": 366 }
[ { "body": "コード **6** 行目`if i not in traced:`がボトルネックになっているものと思われます.\n\n参考: \n[Python -\nTimeComplexity](https://wiki.python.org/moin/TimeComplexity#:%7E:text=O\\(nk\\)-,x%20in%20s,O\\(n\\),-min\\(s\\)%2C%20max)\n\n* * *\n\n実装は単にDFSを行うだけですが,「このノードはどこのノードから遷移してきたのか」という情報を持つリストを用意し,遷移時にこのリストを更新します.探索終了後,逆順に(yから)辿っていくとxからyへのパスが得られます.\n\n以下実装例.\n\n```\n\n import sys\n sys.setrecursionlimit(10 ** 6)\n \n def dfs(now):\n visited[now] = True\n for nex in graph[now]:\n if visited[nex]:\n continue\n from_[nex] = now\n if nex == y:\n return\n dfs(nex)\n \n n, x, y = map(int, input().split())\n graph = [[] for _ in range(n + 1)]\n \n for _ in range(n - 1):\n u, v = map(int, input().split())\n graph[u].append(v)\n graph[v].append(u)\n \n visited = [False for _ in range(n + 1)]\n from_ = [None for _ in range(n + 1)]\n \n dfs(x)\n \n htap = []\n while y is not None:\n htap.append(y)\n y = from_[y]\n \n print(*reversed(htap))\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T15:54:55.870", "id": "91297", "last_activity_date": "2022-09-25T19:35:42.537", "last_edit_date": "2022-09-25T19:35:42.537", "last_editor_user_id": "51374", "owner_user_id": "51374", "parent_id": "91294", "post_type": "answer", "score": 1 }, { "body": "```\n\n # 追跡済みじゃなければ値を追加\n if i not in traced:\n \n```\n\nこの部分で、追跡済みかどうかを毎回線形探索しているのは効率が悪いです。今回 N が最大 200000\nまで達するので、この行で繰り返し行われている探索の時間が問題になります。追跡済みかどうかをすぐ判定できるようにフラグを配列で保持するのが良いでしょう。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T16:06:21.230", "id": "91298", "last_activity_date": "2022-09-25T16:06:21.230", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "91294", "post_type": "answer", "score": 2 } ]
91294
null
91298
{ "accepted_answer_id": null, "answer_count": 0, "body": "Windows 10 を使っていて、Pythonの最新バージョン (Python3.10.~) をインストールし、PATH\nも通したのですが、コマンドプロンプトで `python --version` を実行すると、\"Python 2.7.14\" と出てしまいます。\n\nいくつかのサイトで調べても解決法が分からないので、質問させていただきました。 \nよろしければ、ご教授いただけると幸いです。\n\n### 試したこと\n\n 1. 設定の「アプリ実行エイリアス」で、python.exe と python3.exe をオフにする\n\n 2. `python --version` を実行 \n\n実行結果\n\n``` 'python3' は、内部コマンドまたは外部コマンド、\n\n 操作可能なプログラムまたはバッチ ファイルとして認識されていません。\n \n```\n\n 3. 環境変数にpython3のPATHを入れる。", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T13:21:45.077", "favorite_count": 0, "id": "91296", "last_activity_date": "2022-09-26T00:47:53.730", "last_edit_date": "2022-09-26T00:47:53.730", "last_editor_user_id": "3060", "owner_user_id": "54522", "post_type": "question", "score": 0, "tags": [ "python", "python3", "windows" ], "title": "pythonをインストールしたけれど最新バージョンにならない", "view_count": 1315 }
[]
91296
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "お世話になります。遺伝的アルゴリズムで巡回セールスマン問題を解くプログラムを作っています。タイトルのようなエラーに対処できません。以下、コード全体とエラー文になります。\n\n```\n\n import math\n import csv\n import copy\n import random\n \n \n def read_tspfile():\n \"\"\"\n tspファイルを読み込み、都市の座標(float型)を\n [[都市番号,X,Y],[...],...] の形で返す\n \"\"\"\n def str2float(cities):\n data = [[0]]*len(cities)\n for i in range(len(cities)):\n city = [0]*len(cities[i])\n data[i] = city\n try:\n for j in range(len(cities[i])):\n data[i][j] = float(cities[i][j])\n except:\n data[i]*=0\n continue\n data2 = list(filter(None,data))\n return data2\n \n def remove_blank(cities):\n for i in range(len(cities)):\n for j in range(len(cities[i])):\n try:\n cities[i].remove('')\n except:\n continue\n \n with open(\"a280.tsp\",\"r\") as fin:\n data = [city.split(' ') for city in fin.read().splitlines()]\n remove_blank(data)\n cities_data = str2float(data)\n return cities_data\n \n \n \n cities_data = read_tspfile()\n population = [] # [[経路],[経路],[経路]...[経路]]\n cities = [] # Cityオブジェクトを入れるリスト\n CITIES_N = len(cities_data) # 都市数\n \n \n \n class City:\n def __init__(self,num,X,Y):\n self.num = num\n self.X = X\n self.Y = Y\n \n \n \n class Route:\n def __init__(self):\n self.distance = 0\n \n # 経路を作成(重複なしのランダム)\n self.citynums = random.sample(list(range(CITIES_N)),CITIES_N)\n \n \n def calc_distance(self):\n \"\"\" citynumsリストの各都市間の距離の総和を求める \"\"\"\n self.distance = 0\n for i,num in enumerate(self.citynums):\n \"\"\" \n 1つ前の都市との距離を計算\n i=0のとき、i-1は最後の都市(最後の都市からスタートへの距離)\n \"\"\"\n self.distance += math.dist((cities[num].X,\n cities[num].Y),\n (cities[self.citynums[i-1]].X,\n cities[self.citynums[i-1]].Y))\n return self.distance\n \n \n def copy_route(self,route):\n return copy.copy(route) # deepcopy?\n \n \n def crossover(self, p1, p2):\n # 子の遺伝子情報\n c1 = self.copy_gene(p1)\n c2 = self.copy_gene(p2)\n for i in range(len(c1)):\n if random.random() > 0.5:\n c1[i], c2[i] = c2[i], c1[i]\n \n mutated_c1, mutated_c2 = self.mutate(c1,c2)\n \n return mutated_c1,mutated_c2\n \n \n # 一様交叉\n def mutate(self,c1,c2,mutate_rate=0.05):\n if random.random() > mutate_rate:\n if random.random() > 0.5:\n select_num = [i for i in range(c1)]\n select_index = random.sample(select_num, 2)\n \n a = c1[select_index[0]]\n b = c1[select_index[1]]\n c1[select_index[1]] = a\n c1[select_index[0]] = b\n \n else:\n select_num = [i for i in range(c2)]\n select_index = random.sample(select_num, 2)\n \n a = c2[select_index[0]]\n b = c2[select_index[1]]\n c2[select_index[1]] = a\n c2[select_index[0]] = b\n \n return c1,c2\n \n \n def pfga():\n \n # 2未満なら追加。これだけだとランダムに2こ取り出す動作でエラー吐く。別途初期集団は作っておく\n if len(population) < 2:\n population.append(Route())\n \n # ランダムに2個取り出す\n p1 = population.pop(random.randint(0, len(population)-1))\n p2 = population.pop(random.randint(0, len(population)-1))\n \n # 子を作成\n c1, c2 = Route.crossover(p1,p2)\n \n if p1.calc_distance() < p2.calc_distance():\n p_min = p1\n p_max = p2\n else:\n p_min = p2\n p_max = p1\n if c1.calc_distance() < c2.calc_distance():\n c_min = c1\n c_max = c2\n else:\n c_min = c2\n c_max = c1\n \n if c_min.calc_distance() >= p_max.calc_distance():\n # 子2個体がともに親の2個体より良かった場合\n # 子2個体及び適応度の良かった方の親個体計3個体が局所集団に戻り、局所集団数は1増加する。\n population.append(c1)\n population.append(c2)\n population.append(p_max)\n elif p_min.calc_distance() >= c_max.calc_distsnce():\n # 子2個体がともに親の2個体より悪かった場合\n # 親2個体のうち良かった方のみが局所集団に戻り、局所集団数は1減少する。\n population.append(p_max)\n elif p_max.calc_distance() >= c_max.calc_distance() and p_min.calc_distance() <= c_max.calc_distance():\n # 親2個体のうちどちらか一方のみが子2個体より良かった場合\n # 親2個体のうち良かった方と子2個体のうち良かった方が局所集団に戻り、局所集団数は変化しない。\n population.append(c_max)\n population.append(p_max)\n elif c_max.calc_distance() >= p_max.calc_distance() and c_min.calc_distance() <= p_max.calc_distance():\n # 子2個体のうちどちらか一方のみが親2個体より良かった場合\n # 子2個体のうち良かった方のみが局所集団に戻り、全探索空間からランダムに1個体選んで局所集団に追加する。局所集団数は変化しない。\n population.append(c_max)\n population.append(Route())\n else:\n raise ValueError(\"not comming\")\n \n \n \n \n # citiesにCityオブジェクトを入れる\n for i in range(CITIES_N):\n cities.append(City(cities_data[i][0],\n cities_data[i][1],\n cities_data[i][2])) # num,X,Yの順\n \n \n # populationに個体を追加\n for i in range(2):\n population.append(Route())\n \n \n generation = 0\n best_route = random.choice(population) # 個体(経路)\n best_dist = best_route.calc_distance() # 距離\n first = best_dist # 1番優秀\n \n \n \n with open('PfGA_result.csv','w') as fout:\n \n csvout = csv.writer(fout)\n result = []\n \n while True:\n pfga()\n \n population.sort(key=Route.calc_distance)\n dist1 = population[0].calc_distance()\n \n if dist1 < best_dist:\n best_dist = dist1\n best_route = population[0]\n \n generation += 1\n \n if generation == 1 or generation%100 == 0:\n data = []\n data.extend([generation,best_dist])\n result.append(data)\n if generation == 500:\n csvout.writerows(result)\n print(best_route.citynums)\n break\n \n```\n\nエラー文\n\n```\n\n Traceback (most recent call last):\n \n File …, line 198, in <module>\n pfga()\n \n File ..., line 133, in pfga\n c1, c2 = Route.crossover(p1,p2)\n \n TypeError: crossover() missing 1 required positional argument: 'p2'\n \n```\n\n以上になります。汚いコードで恐縮ですが、よろしければ回答お願いします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-25T23:03:11.103", "favorite_count": 0, "id": "91300", "last_activity_date": "2022-09-25T23:21:05.433", "last_edit_date": "2022-09-25T23:21:05.433", "last_editor_user_id": "51374", "owner_user_id": "54540", "post_type": "question", "score": 0, "tags": [ "python", "python3" ], "title": "missing 1 required positional argumentエラーが直せない", "view_count": 3649 }
[]
91300
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "AndroidのアプリケーションにPlay Integrity APIを用いた完全性判定を導入しようとしています。 \n一通り実装を行い、[こちらの内容](https://qiita.com/yukiarrr/items/764adb88f5a485f714d8)を参考にバイナリ改変を行ったアプリからテストを行ってみたところ、レスポンスのアプリの完全性フィールドの\"appRecognitionVerdict\"の値が\"PLAY_RECOGNIZED\"となっており、不正を検知出来ていないようでした。 \n実際にPlay Integrity APIが\"PLAY_RECOGNIZED\"以外の値を返すのは、どのような不正を行った時なのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T02:57:07.640", "favorite_count": 0, "id": "91304", "last_activity_date": "2022-09-26T02:57:07.640", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54542", "post_type": "question", "score": 0, "tags": [ "android", "google-play" ], "title": "Google Play Integrity API で完全性判定をテストしたい", "view_count": 229 }
[]
91304
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "Anaconda Promptから「pyinstaller 【.pyファイルのフルパス】\n--onefile」の命令でexeファイルの作成ができるにはできるのですが、exeファイル作成完了後に再度同じ命令を行った場合に確立でexe作成を中断してしまうことがあります。\n\n.pyファイルのディレクトリに出現するbuildフォルダなどの処理時に生成されるファイル・ディレクトリをすべて削除すれば必ず出力成功するので別に困る事は無いのですが、毎回削除しなければならないのがpythonの基本ルールとなる認識で良いのでしょうか?\n\n3.6/3.7/3.8どれでも発生するのでおそらく共通で発生するんじゃないかという認識です。\n\ncubickさんに質問された内容を含む追記事項を書きます。 \n■1 \nexeを開いていない状態で再度生成命令を使用した際に上書きy/nの確認画面が表示されました。 \nYESを入力し、完了ログが表示されました。 \nファイルの状況を確認するとdistフォルダ内のデータは再生成された時刻表示となっています。 \nしかし、Buildフォルダ内のアイテムの生成時刻は「COLLECT-00.toc」というファイルが再生成されただけで他のファイルの上書きは行われませんでした。\n\n■2 \n再度別条件で実験 \nexeファイルをリネームし、同名ファイルが存在しない状態にしてみました。 \nexeファイルが再生されました。 \n他に \n「EXE-00.toc」 \n「COLLECT-00.toc」 \nの2件のファイルが再生成されたようです。\n\n▼ \nというところまで確認し、1点私の間違いの可能性を感じています。 \n.pyファイルから生成する一連の処理について、exeが格納されているディレクトリをbuildフォルダ側と認識しておりました。 \n上記の一切の記述はbuild側のディレクトリ内の説明になります。\n\nどうやらdistフォルダ内にも全く同じファイルサイズで生成されているようなのですが、もしかしてdist側が正でbuildフォルダ内のexeは誤でしょうか?\n\nとは言いつつも、distフォルダ内のexeもやはり上書きされず、distフォルダ側で上書きされたのは「●●●●●.exe.manifest」(●●●●●は元となった.pyファイル名)のみ上書きされているようです。\n\n▼生成ログをいかに添付しておきます。基本的に再生成した際のログは以下共通の内容です。\n\n```\n\n (base) ディレクトリパス>pyinstaller ディレクトリパス\\●●●●●.py --exclude pandas --exclude numpy\n 2796 INFO: PyInstaller: 4.5.1\n 2796 INFO: Python: 3.8.8 (conda)\n 2796 INFO: Platform: Windows-10-10.0.19041-SP0\n 2796 INFO: wrote ディレクトリパス\\●●●●●.spec\n 2796 INFO: UPX is not available.\n 2796 INFO: Extending PYTHONPATH with paths\n ['ディレクトリパス',\n 'ディレクトリパス']\n 4156 INFO: checking Analysis\n 4797 INFO: checking PYZ\n 4953 INFO: checking PKG\n 4953 INFO: Bootloader ディレクトリパス\\Anaconda3\\lib\\site-packages\\PyInstaller\\bootloader\\Windows-64bit\\run.exe\n 4953 INFO: checking EXE\n 4968 INFO: checking COLLECT\n WARNING: The output directory \"ディレクトリパス\\dist\\●●●●●\" and ALL ITS CONTENTS will be REMOVED! Continue? (y/N)y\n On your own risk, you can use the option `--noconfirm` to get rid of this question.\n 9609 INFO: Removing dir ディレクトリパス\\dist\\●●●●●\n 12672 INFO: Building COLLECT COLLECT-00.toc\n 37361 INFO: Building COLLECT COLLECT-00.toc completed successfully.\n \n```", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T05:46:59.577", "favorite_count": 0, "id": "91305", "last_activity_date": "2022-09-26T07:50:34.740", "last_edit_date": "2022-09-26T07:50:34.740", "last_editor_user_id": "51823", "owner_user_id": "51823", "post_type": "question", "score": 0, "tags": [ "python", "python3", "pyinstaller" ], "title": "pyinstallerを使用してpythonのexeファイルを作成する時、2度目の生成処理が失敗することがある", "view_count": 351 }
[]
91305
null
null
{ "accepted_answer_id": "91357", "answer_count": 4, "body": "表題の通りCGIに以下の記述でインポートしようとするとエラーになります。\n\n```\n\n import matplotlib.pyplot as plt \n \n```\n\n**環境** \nWindows Server 2012 \nPython 3.10.5 \nApache 2.4.41\n\n下記のCGIを動かすと Internal Server Error 500 になります。\n\nApacheのエラーログには RuntimeError: Could not determine home directory. となっています。\n\n```\n\n #!D:/Python/python.exe\n \n import os\n import mysql.connector as mydb\n import matplotlib.pyplot as plt\n \n print('Content-Type: text/html')\n print('')\n print('test')\n \n```\n\n上記CGIから `import matplotlib.pyplot as plt` を除くと正常に動きます。\n\nまた、コマンドプロンプト上では以下でグラフが正常に表示されます。\n\n```\n\n import matplotlib.pyplot as plt\n \n x=[1,2,3,4]\n y=[10,20,30,40]\n \n plt.bar(x,y)\n plt.show()\n \n```\n\nこれまでもxlwings等でエクセルにデータを出力しています。 \n今回グラフを挿入しようと思いmatplotlibをインストールしてみたのですが、 \n上記のようにエラーになっています。\n\n原因が分からなくて困っています。よろしくお願いいたします。\n\n**追記** \nこれまでxlwingsを使ってエクセルに出力出来ていたのですが、 \n`pip install matplotlib` とインストールしたら、`import xlwings as xw` で同じエラーになってしまいます。 \nmatplotlibをアンインストールすると、このエラーは解消されます。\n\n**追記2** \noririさん、kunifさん、quickquipさん \nありがとうございます。\n\nApacheはローカルのAdministrator(.\\Administrator)で実行しています。 \nサーバーにログインしているユーザーもローカルのAdministratorです。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/J6vAl.png)](https://i.stack.imgur.com/J6vAl.png) \nまた、仮想環境は構築していません。\n\nC:\\Users\\Administrator.matplotlib フォルダには、 \nfontlist-v330.json というファイルがありました。\n\n教えていただいたTracebackの結果ですが以下のようになりました。 \n(Apacheのエラーログと同じです)\n\n```\n\n Traceback (most recent call last):\n File \"D:\\WEB\\recent_py\\master\\M99_F01M.py\", line 9, in <module>\n import matplotlib.pyplot as plt\n File \"D:\\Python\\lib\\site-packages\\matplotlib\\__init__.py\", line 890, in <module>\n dict.update(rcParams, _rc_params_in_file(matplotlib_fname()))\n File \"D:\\Python\\lib\\site-packages\\matplotlib\\__init__.py\", line 567, in matplotlib_fname\n for fname in gen_candidates():\n File \"D:\\Python\\lib\\site-packages\\matplotlib\\__init__.py\", line 564, in gen_candidates\n yield os.path.join(get_configdir(), 'matplotlibrc')\n File \"D:\\Python\\lib\\site-packages\\matplotlib\\__init__.py\", line 273, in wrapper\n ret = func(**kwargs)\n File \"D:\\Python\\lib\\site-packages\\matplotlib\\__init__.py\", line 510, in get_configdir\n return _get_config_or_cache_dir(_get_xdg_config_dir)\n File \"D:\\Python\\lib\\site-packages\\matplotlib\\__init__.py\", line 471, in _get_config_or_cache_dir\n configdir = Path.home() / \".matplotlib\"\n File \"D:\\Python\\lib\\pathlib.py\", line 1000, in home\n return cls(\"~\").expanduser()\n File \"D:\\Python\\lib\\pathlib.py\", line 1440, in expanduser\n raise RuntimeError(\"Could not determine home directory.\")\n RuntimeError: Could not determine home directory.\n \n```\n\n皆さんがおっしゃるようにApacheの環境が影響しているのかと思いますが。。。 \n他に何か確認すべきところがありましらご教示下さい。\n\n**追記3** \nみなさんからアドバイスをいただきホームディレクトリが取得できていないことが原因かと思いCGI上で以下を試してみたら同様のエラーが出ました。 \n(matplotlibはアンインストールしています)\n\n```\n\n from pathlib import Path\n print(str(Path.home()))\n \n```\n\nエラー内容\n\n```\n\n Traceback (most recent call last):\n File \"D:\\WEB\\recent_py\\master\\M99_F01M.py\", line 25, in <module>\n import matplotlib.pyplot as plt\n ModuleNotFoundError: No module named 'matplotlib'\n Traceback (most recent call last):\n File \"D:\\WEB\\recent_py\\master\\M99_F01M.py\", line 40, in <module>\n home2 = str(Path.home())\n File \"D:\\Python\\lib\\pathlib.py\", line 1000, in home\n return cls(\"~\").expanduser()\n File \"D:\\Python\\lib\\pathlib.py\", line 1440, in expanduser\n raise RuntimeError(\"Could not determine home directory.\")\n RuntimeError: Could not determine home directory.\n \n```\n\nコマンドプロンプトから同様の事をやると正常にパスが表示されます。\n\n```\n\n from pathlib import Path\n print(str(Path.home()))\n C:\\Users\\Administrator\n \n```\n\nこのPath.home()が正常に取得、もしくは設定できれば問題が解決できそうなのですが、その方法が分からない状態です。", "comment_count": 9, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T07:55:13.817", "favorite_count": 0, "id": "91309", "last_activity_date": "2022-09-29T05:06:54.520", "last_edit_date": "2022-09-29T05:06:54.520", "last_editor_user_id": "3060", "owner_user_id": "54548", "post_type": "question", "score": 1, "tags": [ "python", "matplotlib", "import" ], "title": "CGIから import matplotlib.pyplot as plt をインポートするとエラーになる", "view_count": 648 }
[ { "body": "コードを書きたかったので回答欄に書きますが、Pythonの例外なら、以下のようなコードで完全なTracebackを保管して確認すると原因にせまれると思います。 \n保管場所は適宜変更してください。\n\nmatplotlibのバックエンドかfontの設定あたりをホームディレクトリから読み出そうとしているのかと想像しましたが探せなかったので、完全なTracebackが欲しいと思いました。\n\n```\n\n try:\n import matplotlib.pyplot as plt \n except Exception as e:\n import traceback\n with open(r'/somewhere/exception.log', 'a') as w:\n traceback.print_exception(e, file=w)\n \n```\n\n* * *\n\n追記 \n[https://github.com/matplotlib/matplotlib/blob/v3.5.2/lib/matplotlib/\n**init**.py#L551](https://github.com/matplotlib/matplotlib/blob/v3.5.2/lib/matplotlib/__init__.py#L551)\n\n```\n\n def gen_candidates():\n # rely on down-stream code to make absolute. This protects us\n # from having to directly get the current working directory\n # which can fail if the user has ended up with a cwd that is\n # non-existent.\n yield 'matplotlibrc'\n try:\n matplotlibrc = os.environ['MATPLOTLIBRC']\n except KeyError:\n pass\n else:\n yield matplotlibrc\n yield os.path.join(matplotlibrc, 'matplotlibrc')\n yield os.path.join(get_configdir(), 'matplotlibrc')\n yield os.path.join(get_data_path(), 'matplotlibrc')\n \n```\n\nこの順番でファイルmatplotlibrcの実在をチェックするようなので`get_configdir()`する前で返るように、「カレントディレクトリを調べてそこにmatplotlibrcをコピーしてくる」か「存在するmatplotlibrcを環境変数`MATPLOTLIBRC`に指定する」が近道な気はします。(Windows関連の設定は不明なのでこのくらいで)\n\nデフォルトのmatplotlibrcは、 \n`D:\\Python\\lib\\site-packages\\matplotlib\\mpl-data\\` \nの中にあると思います。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T02:02:39.773", "id": "91323", "last_activity_date": "2022-09-27T07:22:59.033", "last_edit_date": "2022-09-27T07:22:59.033", "last_editor_user_id": "12274", "owner_user_id": "12274", "parent_id": "91309", "post_type": "answer", "score": 0 }, { "body": "> RuntimeError: Could not determine home directory\n\nに関してはスクリプト先頭近くに環境変数設定するとよいかもです\n\n```\n\n import os\n \n os.environ['HOME'] = 'D:/Python'\n \n```\n\n* * *\n\n> `pip install matplotlib` とインストールしたら、`import xlwings as xw` で同じエラーになってしまいます。\n\nこちらは不明 \nというかどんなエラーでしょうか? 上記 \"RuntimeError 〜\" と同じ? \n\"Could not determine home directory\" であるなら直るかも", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T07:59:17.257", "id": "91332", "last_activity_date": "2022-09-27T07:59:17.257", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43025", "parent_id": "91309", "post_type": "answer", "score": 0 }, { "body": "情報を整理して原因と対処をまとめると以下になります。\n\nmatplotlibがimportの際の初期化処理で以下のディレクトリ・ファイルを探してフォントの情報を取得しますが、その中で実行しているユーザーのホームディレクトリの情報を環境変数から読み取ろうとして、それが無いためにエラーとなっているようです。\n\n[【Python】matplotlibで日本語フォントを使用する](https://izadori.net/python-matplotlib-\nfonts/)\n\n> Windowsの場合は...`C:\\Users\\(ユーザー名)\\.matplotlib`というディレクトリが作成されているはずです。\n\n>\n> .matplotlibディレクトリ内に`fontlist-v{バージョン}.json`というファイルがあり、この中に利用可能なフォントの一覧が記録されています。\n\nPythonのエラーメッセージ `configdir = Path.home() / \".matplotlib\"`と`return\ncls(\"~\").expanduser()` から、使われているメソッドと機能: \n[Path.home](https://docs.python.org/ja/3/library/pathlib.html#pathlib.Path.home)\n\n> ユーザーのホームディレクトリ\n> ([os.path.expanduser()](https://docs.python.org/ja/3/library/os.path.html#os.path.expanduser)での`~`の返り値)\n> を表す新しいパスオブジェクトを返します。ホームディレクトリが解決できない場合は、`RuntimeError`を送出します。\n\n[os.path.expanduser(path)](https://docs.python.org/ja/3/library/os.path.html#os.path.expanduser)\n\n> On Windows, USERPROFILE will be used if set, otherwise a combination of\n> HOMEPATH and HOMEDRIVE will be used. An initial ~user is handled by checking\n> that the last directory component of the current user's home directory\n> matches USERNAME, and replacing it if so. \n> Windows\n> では、設定されている場合は`USERPROFILE`が使用されます。設定されていない場合は、`HOMEPATH`と`HOMEDRIVE`の組み合わせが使用されます。\n> 最初の`~user`は、現在のユーザーのホーム ディレクトリの最後のディレクトリ\n> コンポーネントが`USERNAME`と一致するかどうかを確認し、一致する場合はそれを置き換えることによって処理されます。\n\nエラーメッセージに記録されているメソッドの呼び出しスタックと発生している`RuntimeError`の通知と上記説明が合っています。\n\nこれは Apache から CGI としてPythonスクリプトが実行される際に、Apacheの環境変数(USERPROFILE, HOMEDRIVE,\nHOMEPATH)が子プロセスのPythonに引き継がれないからでしょう。 \nなお、質問記事によるとApacheはサービスとして登録・自動起動され、`Administrator`ユーザーの権限で動作しているとのこと。\n\nちなみにxlwingsでも発生するのは、以下xlwingsのsetup.pyにmatplotlibの名前があるので、installされていなければ使わないが、あればimportを試みるといった動作をしているのでしょう。 \n[xlwings/setup.py](https://github.com/xlwings/xlwings/blob/main/setup.py)\n\n```\n\n ...\n extras_require = {\n ...\n \"matplotlib\",\n ...\n \n```\n\n* * *\n\n対策としては以下の2種類が考えられます。Apacheでの設定の方が正統的な感じがします。\n\n * ApacheでCGIのPython起動時に環境変数を引き継ぐよう(あるいは新規)に設定する。\n * CGIのPythonスクリプト側で補完して設定する。\n\n■Apache側での設定では、mod_envを有効にしたり、CGIへ渡す環境変数をhttpd.confか.htaccessの関連に設定する必要があるでしょう。 \n[Apache の環境変数](https://httpd.apache.org/docs/current/ja/env.html) \n[環境変数を設定する(あるいは取り除く)](https://l-w-i.net/t/apache/env_001.txt)\n\nPHPとかPerlの資料ですがPassEnvの記述があったので: \n[httpd.confへ設定](https://qiita.com/yuta_vamdemic/items/5ea69fd51c5870960917#httpdconf%E3%81%B8%E8%A8%AD%E5%AE%9A) \n[デスクトップCGIでWebとデスクトップを融合する 第1回](https://codezine.jp/article/detail/397)\n\n.htaccessでの設定も出来るもよう: \n[.htaccess -\nmod_env](https://murashun.jp/article/programming/htaccess/htaccess-\nmod_env.html)\n\n■Pythonスクリプト側での対処としては、matplotlibをimportする前に環境変数に`USERPROFILE`を設定してしまうことですね。 \nコメントでは直接的な値を無条件に設定するよう書きましたが、汎用的には既に存在するかを考慮して対応できるようにした方が良いでしょう。 \n[os.getenv(key,\ndefault=None)](https://docs.python.org/ja/3.9/library/os.html#os.getenv)\n\n> 環境変数 key が存在すればその値を返し、存在しなければ default を返します。key、default、および返り値は文字列です。\n\n出来れば、起動したユーザーは誰かも取得出来れば良いのですが、結局環境変数を使うようなので難しいですね。 \n[Is there a portable way to get the current username in\nPython?](https://stackoverflow.com/q/842059/9014308) \n[getpass.getuser()](https://docs.python.org/ja/3/library/getpass.html)\n\n> この関数は環境変数 LOGNAME USER LNAME USERNAME の順序でチェックして、最初の空ではない文字列が設定された値を返します。\n\n関連するモジュールと記述の順番は以下になります。他は適当に問題無い場所に置けば良いでしょう。:\n\n```\n\n import os\n \n if os.getenv('USERPROFILE') is None: #### 既に有ればそのまま使う、存在しない場合に以下で設定\n os.environ['USERPROFILE'] = r'C:\\Users\\Administrator'\n #### 可能ならばimport getpass; os.environ['USERPROFILE'] = 'C:\\\\Users\\\\' + getpass.getuser() に変更\n \n import matplotlib.pyplot as plt\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T11:36:09.080", "id": "91357", "last_activity_date": "2022-09-28T11:36:09.080", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "91309", "post_type": "answer", "score": 2 }, { "body": "最終的に以下の方法で動作を確認できました。\n\n**方法1** \nCGIの文頭に以下の1行を追加\n\n```\n\n os.environ['USERPROFILE'] = r'C:\\Users\\Administrator'\n \n```\n\n**方法2** \nApacheのhttpd.conf に以下の1行を追加\n\n```\n\n SetEnv USERPROFILE C:\\Users\\Administrator\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T04:48:38.190", "id": "91367", "last_activity_date": "2022-09-29T04:48:38.190", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54548", "parent_id": "91309", "post_type": "answer", "score": 0 } ]
91309
91357
91357
{ "accepted_answer_id": null, "answer_count": 2, "body": "DBにデータを登録する際に使うINSERT文やUPDATE文は1つのSQLで複数のデータを登録する書き方がありますが、対象のデータ量が多い場合はSQLをどう作ると処理が速いのでしょうか?\n\n私は1つのSQLで複数のデータをまとめて登録した方が速いのかなと思ったのですが友達は1つ1つSQL作る派らしくて、どっちが良いんだろうなぁと気になったので質問させていただきました。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T08:52:05.863", "favorite_count": 0, "id": "91311", "last_activity_date": "2022-09-27T00:44:57.460", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "28635", "post_type": "question", "score": 1, "tags": [ "mysql", "sql" ], "title": "大量のDBデータをより速く登録・更新するSQLの書き方について", "view_count": 768 }
[ { "body": "(特にデータベースのコンテキストにおいては)「大量」という語は個人差が激しく、1MB、1GB、1TB等、具体的な量を明示しないことには意味がありません。\n\n真に大量のデータを扱うのであれば、データベースエンジンが用意している専用の読み込み命令を使う必要があり、そのためには呼び出し側も事前にデータ加工することになるでしょう。例えばMySQLでは[`LOAD\nDATA INFILE`構文](https://dev.mysql.com/doc/refman/5.6/ja/load-\ndata.html)があるようです。\n\n* * *\n\n> 私は1つのSQLで複数のデータをまとめて登録した方が速いのかなと思ったのですが友達は1つ1つSQL作る派\n\nそこまでせず、簡易な高速化という意味であれば、当然一度にまとめた方が効率が良くなります。トランザクション数も減らせますし、メモリやディスクといったリソースの確保回数も削減されるためです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T20:16:42.590", "id": "91316", "last_activity_date": "2022-09-26T20:16:42.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "91311", "post_type": "answer", "score": 2 }, { "body": "公式のドキュメントに、下記のような記載があります。\n\n[8.2.5.1 INSERT ステートメントの最適化](https://dev.mysql.com/doc/refman/8.0/ja/insert-\noptimization.html)\n\n> 行の挿入に必要な時間は、次の要因によって決まります。ここでの数はおよその割合を示しています。 \n> 接続: (3) \n> サーバーへのクエリーの送信: (2) \n> クエリーの解析: (2) \n> 行の挿入: (1 ×行サイズ) \n> インデックスの挿入: (1 ×インデックス数) \n> クローズ: (1)\n\n> 同じクライアントから同時に多数の行を挿入する場合は、複数の VALUES リストで INSERT ステートメントを使用して、同時に複数の行を挿入します。\n> これは、個別の単一行の INSERT ステートメントを使用するより、大幅に (場合によっては数倍) 速くなります。\n> 空ではないテーブルにデータを追加する場合は、データの挿入をさらに速くするために、bulk_insert_buffer_size 変数を調整できます。\n> セクション5.1.8「サーバーシステム変数」を参照してください。\n\n> テキストファイルからテーブルをロードする場合は、LOAD DATA を使用します。 通常、これは INSERT ステートメントを使用する場合より、20\n> 倍速くなります。 セクション13.2.7「LOAD DATA ステートメント」を参照してください。\n\n実運用だと、他にも気にする事は色々ありますが、下記の記事が参考になるかもしれません。\n\n[データベースを遅くするための8つの方法](https://zenn.dev/koduki/articles/d3e8984f420b370681f9)\n\n[ソーシャルゲームのためのデータベース設計](https://next.rikunabi.com/tech/contents/ts_report/img/201101/001861/dena_matsunobu.pdf)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T00:44:57.460", "id": "91320", "last_activity_date": "2022-09-27T00:44:57.460", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "41943", "parent_id": "91311", "post_type": "answer", "score": 2 } ]
91311
null
91316
{ "accepted_answer_id": null, "answer_count": 1, "body": "SPRESENSEの仕様書を見ると、以下の3つに分かれています。\n\n * CXD5602ピンネーム\n * Ardirnoピンネーム\n * Functoinピンネーム\n\n外部接続に2つのUARTとGPIOが6つ必要で、UARTの1つはメインボードCN2のマイクロUSBを使用し、残りの1つとGPIOから接続したいと考えています。この場合、2,3ピンでUART通信をし、6-9ピンと12、13をGPIOとして利用したいと考えています。\n\nCXD5602ピンネームでは6-9と12、13ピンはI2S、SPI、IRQと書かれていますが、これを単なるGPIOとして利用することは可能でしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T08:52:47.883", "favorite_count": 0, "id": "91312", "last_activity_date": "2022-09-28T07:06:16.383", "last_edit_date": "2022-09-28T07:06:16.383", "last_editor_user_id": "32034", "owner_user_id": "54552", "post_type": "question", "score": 0, "tags": [ "spresense", "gpio" ], "title": "spresenseのメインボードのピンアサインで 6-9, 12,13 ピンを GPIO として利用可能か?", "view_count": 152 }
[ { "body": "質問内容を読み解いて2-13ピンが下の図のピンであるということを前提とすると、2,3ピン(D01,D00)をUARTとして利用しつつ、6-9,12ピンはGPIO(D26,D25,D24,D23,D22)として利用することが可能です。しかし、13ピンはアナログ入力(A2)なので、GPIOとして利用することはできません。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/AFZ9J.png)](https://i.stack.imgur.com/AFZ9J.png)", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T02:15:10.690", "id": "91325", "last_activity_date": "2022-09-27T02:36:46.667", "last_edit_date": "2022-09-27T02:36:46.667", "last_editor_user_id": "27334", "owner_user_id": "27334", "parent_id": "91312", "post_type": "answer", "score": 1 } ]
91312
null
91325
{ "accepted_answer_id": null, "answer_count": 0, "body": "ホストポートを指定しないことで動的にコンテナを起動しています。 \nその後、どのポートで起動したか取得しようとしています。\n\nただ、`[]` となり取得できていません。\n\n```\n\n fmt.Printf(\"Ports: %+v\\n\", c.NetworkSettings.Ports)\n fmt.Printf(\"Ports[newP]: %+v\\n\", c.NetworkSettings.Ports[newP])\n // Ports: map[3000/tcp:[] 3001/tcp:[]]\n // Ports[newP]: []\n \n```\n\n下記のソースコード実行後に `docker port container-name 3000`\nでホストポートの取得はできているため、起動まではうまくいっていると考えています。 \n<https://docs.docker.com/engine/reference/commandline/port/>\n\nDocker Python SDK でも同様のようですが、reload することで取得しているようです。 \n<https://stackoverflow.com/questions/69720234/retrieve-the-host-port-of-a-\ncontainer-launched-from-docker-sdk-for-python>\n\n[SDK リファレンス](https://pkg.go.dev/github.com/docker/docker/client)\nでの探し方が間違っているのか、reload は見つかりませんでした。 \nDocker Go SDK ではどのようにすればよいでしょうか。\n\n動的ポートで起動時のポート番号取得方法を教えていただきたいです。\n\n```\n\n containerName := \"container-name\"\n \n ctx := context.Background()\n cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())\n if err != nil {\n fmt.Println(err)\n return\n }\n \n // コンテナ作成\n resp, err := cli.ContainerCreate(ctx, &container.Config{\n Image: imageName,\n ExposedPorts: nat.PortSet{nat.Port(\"3000\"): struct{}{}},\n }, &container.HostConfig{\n PortBindings: nat.PortMap{\n // 動的ポート\n nat.Port(\"3000/tcp\"): []nat.PortBinding{{HostPort: \"\"}},\n },\n }, nil, nil, containerName)\n if err != nil {\n fmt.Println(err)\n return\n }\n \n // コンテナ起動\n if err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {\n fmt.Println(err)\n return\n }\n \n // ポート番号を取得\n c, err := cli.ContainerInspect(ctx, containerName)\n if err != nil {\n fmt.Println(err)\n return\n }\n \n newP, err := nat.NewPort(\"tcp\", \"3000\")\n if err != nil {\n fmt.Println(err)\n return\n }\n fmt.Printf(\"Ports: %+v\\n\", c.NetworkSettings.Ports)\n fmt.Printf(\"Ports[newP]: %+v\\n\", c.NetworkSettings.Ports[newP])\n // Ports: map[3000/tcp:[] 3001/tcp:[]]\n // Ports[newP]: []\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T09:07:08.673", "favorite_count": 0, "id": "91313", "last_activity_date": "2022-09-26T09:17:36.373", "last_edit_date": "2022-09-26T09:17:36.373", "last_editor_user_id": "54551", "owner_user_id": "54551", "post_type": "question", "score": 0, "tags": [ "docker", "go" ], "title": "動的ポートで起動後にホストポートを取得できない(Docker Go SDK)", "view_count": 36 }
[]
91313
null
null
{ "accepted_answer_id": null, "answer_count": 4, "body": "ソフトウェア開発、プログラミング初心者です。\n\nソフトウェアについての学習をしているのですが、コンピュータをハードウェアから理解したいと非常に強く思うようになりました。\n\nハードウェアの構成要素についてWEBで調べてみても、入力装置、出力装置、記憶装置、演算装置、制御装置が持つ役割とそれぞれの関連についての概要を説明したWEBサイトしか見つかりません。\n\n私はハードウェアの構成の概要ではなく、現代のコンピュータの動作に活用されている電気関連の技術と、現代のコンピュータを構成する装置や部品がどんな素材でどのように作られているかなどの知識から身につけたいと考えています。\n\nそこで、そのような知識を説明したWEBサイトをご存知の方はいらっしゃいませんか?\n\n追記:質問を編集する以前は「私はハードウェアの構成の概要ではなく『物理学的なレベル』の知識から身につけたいと考えています。」と、「物理学的なレベル」という曖昧な言葉を使ってしまい、回答してくださった方を混乱、困惑させてしまったことをとても反省しております。同時に回答してくださった方に深く感謝いたします。 \nまた、現在私が興味を示していることが、必ずソフトウェア開発に活かせるとは考えておりません。あくまで知りたいという思いがあるだけです!", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T11:08:21.117", "favorite_count": 0, "id": "91314", "last_activity_date": "2022-09-28T00:42:53.637", "last_edit_date": "2022-09-27T15:02:04.083", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "ハードウェア" ], "title": "ハードウェアの学習のためのWEBサイトを教えていただけませんか", "view_count": 299 }
[ { "body": "774RRさんのコメント通りですが、あえて答えるなら、Webサイトでは断片的な記述と広告まみれであり、まともに語られていないことでしょう。仮に見つかったとしても内容に誤りがないとも限りません(稀有な存在ですと誤りは訂正されにくいです)。系統立てて理解するのであれば、書籍を購入することをお勧めします。\n\n * コンピュータの構成と設計 \n通称「パタへネ本」\n\n * コンピュータアーキテクチャ 定量的アプローチ \n通称「ヘネパタ本」", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T20:34:06.410", "id": "91317", "last_activity_date": "2022-09-26T20:34:06.410", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "91314", "post_type": "answer", "score": 3 }, { "body": "# まだクローズ票もついていないので今のうち・・・\n\nたぶんあなたは自分の興味がどこにあるのかまだ自分自身で把握していない状況なのだと思われます。あれもやってみたいこれも知りたい。でも何もかもを学ぶには人生の余白は狭すぎるのかもしれない・・・\n\nおそらくジャンルが広すぎ内容が広すぎ深すぎで、これを専門にしていて生涯をかけている人が何人もいる中 Web サイトのブログ記事1個とか SO\nの質疑応答1個では分量的に断片的な話しかできないと予測されます。\n\n数年(あるいは一生)を懸けて学ぶ内容なので大学に行くことをお勧めします。あなたが中高生なら電気・電子・物性系の学科のあるところに進学しましょう。既に社会人になっているなら通信教育(放送大学など)もアリでしょう。放送大学おすすめっス。地上波\nTV をオイラがまだ持っていたときは流し聞きしているだけでも勉強になりました。(今は BS/ひかりTV しかやっていないんだっけ)\n\nまあ半導体物性をやってもコンピュータソフトウエアの設計作成にはまず絶対役に立たないでしょうし、電気電子回路をやれば基板上回路の設計計算できるようになると思いますが製品設計の役には立ってもソフトウエア実装の役に立つかというと疑問っス。自分の興味対象や範囲を一度見つめなおしてみるといいでしょう。\n\n* * *\n\n持論ですが\n\n * 勉強のための勉強は面白くないし続けられない\n * 興味のあることはテキトーにネットサーフィン(死語)しているだけで目に留まるし、そのうち覚えてしまう\n * 寝てる間などに脳内知識が整理されると突然「ああそういうことか」みたいに、一見無関係そうに見える事項が結びついて自分のものになる\n\nので ~~修行~~ 勉強するぞ、みたいに意気込まずに適宜広く浅くいろんな本や web page\nを見てるだけでもいいんです。現代最新技術は専門家でも自分の専門分野の外は全貌を把握できないくらいに先鋭化しています。オイラたちユーザーとしては似て非なるものの長所短所の違いを知っているくらいで十分です。\n\n * NOR FLASH と NAND FLASH の違いとか\n * CMR と SMR の違いとか (HDD)\n * `std::list` と `std::vector` と `std::deque` の違いとか ([c++](/questions/tagged/c%2b%2b \"'c++' のタグが付いた質問を表示\"))\n\nんで、理解が浅いことに物足りなさを感じたら、そこで初めて専門書なり通信教育なりを考えてみてもいいと思います(お値段も結構しますし)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T23:29:03.393", "id": "91319", "last_activity_date": "2022-09-28T00:42:53.637", "last_edit_date": "2022-09-28T00:42:53.637", "last_editor_user_id": "8589", "owner_user_id": "8589", "parent_id": "91314", "post_type": "answer", "score": 4 }, { "body": "コンピューターを構成する要素の説明は比較的情報量が多めの分野で、わりと簡単に見つかります。 \n見つからない理由はそれぞれの基盤技術の名称等の基本的情報が得られていないせいかもしれません。\n\nひょっとすると単に検索キーワードがいまいちな場合もあります。 \nあたりまえですが、検索にもそれなりの技術が必要なのです。 \n例えば「ハードディスク」や「HDD」で検索しても販売サイトが優位にヒットし、その数は数億件になってしまいます。 \nこの中から望む情報を得ることは困難でしょう。 \nでも、検索キーワードを「ハードディスク 原理」に変えるとヒットするのは数十万件になり販売サイトはリストされなくなります。 \nなおかつHDDの各部名称を示した図など、ちょっと技術寄りの情報があつまります。 \nこの様にして知識を少しづつ増やしていってはどうでしょう。\n\n自分たちは周りの限られた情報の中で生存することしかできませんが、その情報の質と量はある程度自分で選ぶことができます。 \n例えば「量子物理学」や「素粒子論」は物性の真に根源的原理ですが、一般的なビジネス用の「ソフトウエア開発」とは直接的には無関係です。 \n個人においてはこの世の全てのことを知ることはできないことは確定事項なので、必要のない情報はあきらめることも大事だと考えます。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T02:08:41.567", "id": "91324", "last_activity_date": "2022-09-27T02:08:41.567", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3793", "parent_id": "91314", "post_type": "answer", "score": 2 }, { "body": "こちらをぜひ。かなり良著です。\n\n[コンピュータシステムの理論と実装 (Amazon.co.jp)](https://www.amazon.co.jp/dp/4873117127/)\n\nOSを自作してみるというのも近道かもしれません。\n\n[30日でできる! OS自作入門 (Amazon.co.jp)](https://www.amazon.co.jp/dp/4839919844/)\n\nというのは結局ソフトの話になってしまいますが、 \nハードを動かす前になぜそのようなハードが必要か?が理解できると思います。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T08:44:20.370", "id": "91335", "last_activity_date": "2022-09-27T11:44:54.333", "last_edit_date": "2022-09-27T11:44:54.333", "last_editor_user_id": "3060", "owner_user_id": "36202", "parent_id": "91314", "post_type": "answer", "score": 2 } ]
91314
null
91319
{ "accepted_answer_id": null, "answer_count": 0, "body": "GetServerSidePropsを使用しているファイルをbuild → exportするにはどうすればいいのでしょうか?\n\n/ \n┗/test/[id].tsx \n┗/test/index.tsx\n\n/out/ \n┗/test/[id] \n┗index.html\n\nのようになってますが、[id]フォルダの中身は空です・・・", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-26T12:22:03.930", "favorite_count": 0, "id": "91315", "last_activity_date": "2022-09-26T12:22:03.930", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54549", "post_type": "question", "score": 0, "tags": [ "javascript", "reactjs", "typescript", "next.js" ], "title": "nextjs ssr GetServerSideProps サーバー", "view_count": 44 }
[]
91315
null
null
{ "accepted_answer_id": "91845", "answer_count": 1, "body": "## 概要\n\nAzureDevOpsでPushした新しいブランチをmasterブランチにマージしようとPRを発行すると、以下のメッセージが表示されるだけでPR作成処理に進みません\n\n> There are no changes to merge between the selected branches.\n\nどのようにすればmasterブランチにマージできるようになるでしょうか?\n\n## 詳細\n\nリポジトリAのmasterブランチに、リポジトリB(リポジトリAからフォークしたもの)のdevelopブランチの変更をマージしようとしました \nPRを作成しようとすると、上記のメッセージが表示されるだけで以降の処理を進められません \n両ブランチでコードに差があることは確認済みです\n\nやりたいこととしましては、developブランチをmasterブランチにマージすることです", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T00:54:31.353", "favorite_count": 0, "id": "91321", "last_activity_date": "2022-10-27T01:47:59.853", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19500", "post_type": "question", "score": 0, "tags": [ "windows", "git", "azure" ], "title": "Azure DevOpsでPullRequestを発行しようとするとブランチに差がないためマージできない", "view_count": 154 }
[ { "body": "リポジトリBのmasterブランチに先にマージすることで、リポジトリAのmasterブランチにマージできました", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-27T01:47:59.853", "id": "91845", "last_activity_date": "2022-10-27T01:47:59.853", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19500", "parent_id": "91321", "post_type": "answer", "score": 0 } ]
91321
91845
91845
{ "accepted_answer_id": null, "answer_count": 0, "body": "iOSアプリであれば、実機ビルド後も本体にアプリが残り続け、その後もアプリを使い続けることができます。 \nしかし、WatchAppでは実機ビルド後にしばらくするとアプリが削除されてしまいます。 \niOSアプリのようにアプリを使い続けたいのですが、どうしたら良いでしょうか?宜しくお願い致します。\n\nXCode14 \nWatchOS9", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T01:11:06.847", "favorite_count": 0, "id": "91322", "last_activity_date": "2022-09-27T01:11:06.847", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17048", "post_type": "question", "score": 0, "tags": [ "ios", "xcode", "swiftui", "swift5" ], "title": "WatchAppが実機ビルド後に削除されてしまう WatchOS9", "view_count": 39 }
[]
91322
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "サンプルを参考にNTPで時刻取得すると希にエラーが発生します。\n\n表示されるエラー\n\n```\n\n ERROR:LTEUDP:337 sendoto() error : 22\n \n```\n\nソースは単純で以下になります。\n\n```\n\n timeClient.begin();\n timeClient.update();\n now =timeClient.getEpochTime();\n tm_now = localtime(&now);\n timeClient.end();\n \n```\n\nこのエラーが出たとき、再度NTPで時刻を取得するように上記のソースを実行しても \n同じエラーが繰り返し出て、いつまでもNTPで時刻がとれません。 \nエラー出なければ、普通に時刻取得できて問題ありません。 \n頻度が少ないのでなかなか検証もできない状況です\n\n対処方法をご存じの方、ご教授いただけると助かります。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T02:47:06.333", "favorite_count": 0, "id": "91327", "last_activity_date": "2022-09-28T01:24:29.120", "last_edit_date": "2022-09-27T04:19:53.103", "last_editor_user_id": "3060", "owner_user_id": "53458", "post_type": "question", "score": 0, "tags": [ "spresense" ], "title": "spresenseとLTEボードでNTPで時刻取得すると、希にエラーになる", "view_count": 127 }
[ { "body": "> このエラーが出たとき、再度NTPで時刻を取得するように上記のソースを実行しても \n> 同じエラーが繰り返し出て、いつまでもNTPで時刻がとれません。\n\nエラーが発生した際、以下のようにNTPを再取得すると正しく時刻が取得できるかもしれません。(一旦 `end`を呼び出したうえで `begin`\nを呼び出しています。)\n\n```\n\n timeClient.end();\n timeClient.begin();\n timeClient.update();\n now =timeClient.getEpochTime();\n tm_now = localtime(&now);\n \n```\n\nもし、これでも取得できない場合はLTEの接続状態を確認してみるとよいかもしれません。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T01:24:29.120", "id": "91342", "last_activity_date": "2022-09-28T01:24:29.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32034", "parent_id": "91327", "post_type": "answer", "score": 0 } ]
91327
null
91342
{ "accepted_answer_id": null, "answer_count": 0, "body": "当方AWS未経験のため、間違った設定、言葉を使用している場合ご容赦ください。\n\n### やりたいこと\n\nAWS WorkMailとConoHaのサービスを利用し、2種類のメールを利用できるようにしたい。\n\n### 概要\n\n元々AWS SESのメールで2つのアカウントを使う設定で依頼していた。 \nSESだとメール受信ができないとのことでworkmailが追加された。 \nworkmailは費用がかかるため、一つはworkmail、一つは別のサービス(ConoHa)でメールアカウントを作ることにした。 \n下記のようにメールを作成\n\nメール \n・noreplyメール : WorkMail: メール自動送信のみ \n・supportメール :ConoHa : メール送受信できる\n\nRote53で管理し、現在 noreplyは正常にメール送信される。 \nしかし、supportメールのみメールの送受信が行われないといった問題が発生しています。\n\nRoute53側でMXレコードなどを割り当ててみたのですが動かないといった状況です。\n\n**補足情報**\n\n * workmail:リージョン アイルランド\n * Conoha :日本のレンタルサーバー\n\n詳細情報の記述が少なく申し訳ありません。 \nこちらの情報の中で推測できることなどがありましたらご教示いただけないでしょうか? \nよろしくお願いいたします。\n\n追記 \n下記の記事を確認しました。\n\n**1つのドメインに2つのメールサーバーを設定できない。** \n<https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/ResourceRecordTypes.html>\n\nつまり、下記のようにどちらかに寄せなければいけないということでしょうか?\n\n * noreplyもsupportもAWSWorkMailを使う\n * noreplyもsupportもConoHaを使う", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T02:59:15.463", "favorite_count": 0, "id": "91328", "last_activity_date": "2022-09-27T06:45:52.827", "last_edit_date": "2022-09-27T06:45:52.827", "last_editor_user_id": "54563", "owner_user_id": "54563", "post_type": "question", "score": 0, "tags": [ "aws", "conoha", "amazon-route53" ], "title": "AWS WorkMailとConoHaメールを利用したいが、設定が正しくできておらず原因がわからない", "view_count": 70 }
[]
91328
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "IntelliJを用いてJavaのコード開発を行おうとしているのですが、「◯◯をプロジェクトフォルダーから削除しますか」というダイヤログにOKを押したところ、実行ボタンやデバッグボタンなどがグレーアウトされ実行できなくなりました。カーソルを持っていくと「エディターのファイルが実行可能ではありません。」という表示です。\n\nなお、開いていたプロジェクトだけではなく、他のプロジェクトでも実行ができなくなりました。 \n初歩的な内容で恐縮ですが、こちら、原因と対処方法をお分かりの方がいらっしゃいましたらご教示頂けますと幸いです。 \nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T03:49:11.947", "favorite_count": 0, "id": "91329", "last_activity_date": "2022-09-27T03:49:11.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "47922", "post_type": "question", "score": 0, "tags": [ "java", "intellij-idea" ], "title": "IntelliJで実行ボタンが消えてビルドできない", "view_count": 561 }
[]
91329
null
null
{ "accepted_answer_id": "91340", "answer_count": 1, "body": "JavaScriptでパスワードの表示/非表示を切り替える機能(最近よく見かける目玉マークをクリックして切り替える機能)を作成中なのですが、ネットに出てくる実装方法だと表示中に全角文字が入力できてしまいます。\n\n```\n\n input.type = 'password'; //非表示にする場合\n input.type = 'text'; //表示する場合 ※これだと全角文字が入力できてしまう\n \n```\n\nそのため、質問内容としては「テキスト入力を半角文字だけにするには?」ということになるかもしれませんが、 \nぜひ普段実装されている方法を教えてください。よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T08:31:51.993", "favorite_count": 0, "id": "91333", "last_activity_date": "2022-09-27T23:36:24.880", "last_edit_date": "2022-09-27T23:36:24.880", "last_editor_user_id": "3054", "owner_user_id": "36202", "post_type": "question", "score": 2, "tags": [ "javascript", "html", "form" ], "title": "入力中のパスワードを表示させつつ半角文字だけに制限したい", "view_count": 226 }
[ { "body": "### 困難ですし、やらないで良いです\n\n現在、[input 要素](https://developer.mozilla.org/ja/docs/Web/HTML/Element/input)や\n[inputmode\n属性](https://developer.mozilla.org/ja/docs/Web/HTML/Global_attributes/inputmode)に入力を半角(Ascii\nの範囲内)に限定する機能は無いです。\n\nそもそも `type=\"password\"` の input 要素であっても、任意の文字が入力できます。一部のブラウザ(Blink系?)と OS\nの組合せでは、IM(インプットメソッド)が無効にされるようですが、その挙動を別の環境でも再現するのは、かえってアクセシビリティを損ねる可能性があります。過去には\nIM をコントロールする機能が一部ブラウザに有ったようですが、現在は非推奨となっています。\n\nどうしてもやる場合は、自前で入力方法を構築する(キーボードイベントを扱う、ソフトウェアキーボードを用意する、など)方法はあると思います。しかし、こういった作り込みは「いつもと違う」こと自体がユーザーに不親切となり、成功しない可能性が高いです。\n\n### 代替案: `type=\"password\"` のままで付近に入力内容を表示させる\n\n特にお勧めはしないですが、`type=\"password\"` の input\n要素の付近にユーザーが入力中のパスワードを表示させる手法があります。これは、[input\nイベント](https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/input_event)を用いて簡単に実装できます。ただし、入力欄は依然として伏せ字であるため、ユーザーがカーソルを移動しての編集や部分的な選択などを行なうのが難しいままなのがデメリットです。\n\n例: 下の画像は Amazon のモバイル向けサイトでパスワードに `ExamplePassword`\nと入力した場面です。パスワード入力欄の下に、`ExamplePassword` と出ているのが入力中の文字列です。\n\n>\n> [![Amazonのモバイル向けログインフォーム](https://i.stack.imgur.com/0Ds0K.png)](https://i.stack.imgur.com/0Ds0K.png)", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T23:09:56.830", "id": "91340", "last_activity_date": "2022-09-27T23:34:41.920", "last_edit_date": "2022-09-27T23:34:41.920", "last_editor_user_id": "3054", "owner_user_id": "3054", "parent_id": "91333", "post_type": "answer", "score": 3 } ]
91333
91340
91340
{ "accepted_answer_id": null, "answer_count": 0, "body": "create tableでテーブルを作成したのち、 \ninsertをしたのですがinnodb_index_statsが更新されないのですが \nどういう可能性があるでしょうか? \n何度insertしてもstat_valueが0のままで更新されません。\n\n最適化は自動でされるように設定はしています。 \ncreate table・・・selectだとinnodb_index_statsは更新されました。\n\nmariadbのバージョンは10.6.7です。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T08:35:07.823", "favorite_count": 0, "id": "91334", "last_activity_date": "2022-09-27T08:36:02.130", "last_edit_date": "2022-09-27T08:36:02.130", "last_editor_user_id": "53309", "owner_user_id": "53309", "post_type": "question", "score": 0, "tags": [ "mysql", "mariadb" ], "title": "insertしてもmysql.mysql.innodb_index_statsが更新されない。", "view_count": 45 }
[]
91334
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "windows10を使っており、kivyを用いて電卓のアプリを作り、これをexe化するためにpyinstallerを用いました。しかし、exe化はできたのですが、そのexeファイルを起動すると真っ黒な画面のウィンドウが出てきて、電卓の画面が表示されません。コマンドプロンプトからpythonファイルを直接実行すると、きちんと電卓の画面が出てきます。また、pyinstallerでのexe化については以下のサイトを参考にしました。\n\n[Python KivyのGUIアプリをExe化する方法](https://torimakujoukyou.com/python-kivy-exe/)\n\n以下にspecファイルのコードを示します。\n\n```\n\n # -*- mode: python ; coding: utf-8 -*-\n \n from kivy_deps import sdl2, glew\n block_cipher = None\n \n \n a = Analysis(\n ['calculator.py'],\n pathex=[],\n binaries=[],\n datas=[],\n hiddenimports=[],\n hookspath=[],\n hooksconfig={},\n runtime_hooks=[],\n excludes=[],\n win_no_prefer_redirects=False,\n win_private_assemblies=False,\n cipher=block_cipher,\n noarchive=False,\n )\n pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)\n \n exe = EXE(\n pyz,\n a.scripts,\n a.binaries,\n a.zipfiles,\n a.datas,\n *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],\n name='calculator',\n debug=False,\n bootloader_ignore_signals=False,\n strip=False,\n upx=True,\n upx_exclude=[],\n runtime_tmpdir=None,\n console=True,\n disable_windowed_traceback=False,\n argv_emulation=False,\n target_arch=None,\n codesign_identity=None,\n entitlements_file=None,\n )\n \n coll = COLLECT(exe, Tree('.'),\n a.binaries,\n a.zipfiles,\n a.datas,\n *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],\n strip=False,\n upx=True,\n name='calculator')\n \n```\n\nやはり上記のサイトにある通り、うまく起動しないことがあるものだとあきらめざるを得ないのでしょうか? \nどなたかこのことについてご教授いただけますと幸いです。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-27T08:52:25.123", "favorite_count": 0, "id": "91336", "last_activity_date": "2022-09-27T09:01:55.523", "last_edit_date": "2022-09-27T09:01:55.523", "last_editor_user_id": "3060", "owner_user_id": "54522", "post_type": "question", "score": 1, "tags": [ "python", "windows-10", "pyinstaller", "kivy" ], "title": "kivyファイルをpyinstallerでexe化したけど起動したら真っ黒な画面のウィンドウが出る", "view_count": 333 }
[]
91336
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在、laravelでContent Security Policyの脆弱性対応を行っております。\n\nscript-srcやstyle-srcを使用しまして、制限をかけましたが、インラインイベントハンドラー(`<button\nonclick=\"doSomething()\">`)やhtmlタグに直書きされたスタイル(`<p style=\"\">`)は、使用されている箇所、 \nまたは全て許可したいと考えております。\n\nそこでscript-src-attrやstyle-src-attrを使用したいのですが、firefoxは対応していないようです。 \nunsafe-inlineは使用したくなく、何かいい方法はございますでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T01:22:25.147", "favorite_count": 0, "id": "91341", "last_activity_date": "2022-09-28T01:22:25.147", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54583", "post_type": "question", "score": 0, "tags": [ "php", "laravel" ], "title": "firefoxのContent Security Policy対策について", "view_count": 52 }
[]
91341
null
null
{ "accepted_answer_id": null, "answer_count": 3, "body": "リソースからバージョンを取得するために以下リンク先のソースコードを使用してみたのですが、タイトルのようなエラーが発生しています。\n\n[C++でバージョン情報を取得する](https://araramistudio.jimdo.com/2017/05/19/c-%E3%81%A7%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E6%83%85%E5%A0%B1%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B/)\n\n色々なファイルのインクルードもしてみたり、他の似たようなサイトで調べたりもしましたが、解決できておりません。 \nご助力の程宜しくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T04:50:04.840", "favorite_count": 0, "id": "91343", "last_activity_date": "2022-09-28T07:07:13.330", "last_edit_date": "2022-09-28T05:02:56.397", "last_editor_user_id": "3060", "owner_user_id": "47970", "post_type": "question", "score": -1, "tags": [ "c++" ], "title": "visual studio 2019にて未解決の外部シンボル(VerQueryValueW)・(GetFileVersionInfoW)・(GetFileVersionInfoSizeW)の参照エラーを修正できない。", "view_count": 1114 }
[ { "body": ">\n> 未解決の外部シンボル(VerQueryValueW)・(GetFileVersionInfoW)・(GetFileVersionInfoSizeW)の参照エラー\n\n「未解決の外部シンボル~」といったエラーメッセージは、コンパイル時ではなくリンク時の問題を示しています。\n\n例えば[`GetFileVersionInfoW`関数の仕様](https://learn.microsoft.com/en-\nus/windows/win32/api/winver/nf-winver-\ngetfileversioninfow#requirements)をドキュメントで確認すると、ソースコードから#includeすべきヘッダファイルは`Windows.h`を、リンク時に追加指定するライブラリファイルは`Version.lib`が必要なことが分かります。\n\n> Header: winver.h (include Windows.h) \n> Library: Version.lib", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T05:36:58.530", "id": "91346", "last_activity_date": "2022-09-28T05:36:58.530", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49", "parent_id": "91343", "post_type": "answer", "score": 1 }, { "body": "こういう時は公式ページ (Microsoft MSDN) を見る癖をつけてください。 Google でも Bing でもいいので\n`VerQueryValue` を検索し Microsoft の解説ページを見つけます。 \n[VerQueryValueW](https://learn.microsoft.com/en-\nus/windows/win32/api/winver/nf-winver-verqueryvaluew) \nすると Requirement の欄に `Header` と `Library` の解説があります。\n\n(今回は該当しませんが)コンパイル時に未宣言シンボルというエラーが出るときは、ソースコード上 `Header` の追加が抜けています。適切なところに\n`#include` を追加します。この例の場合、解説ページの読み方が難しいのですが `#include <windows.h>`\nしろと書かれています(宣言自体は `winver.h` にあるのですが、直接 `#include <winver.h>` するのではなく `#include\n<windows.h>` しろと指定されています) \n# プリコンパイルヘッダを使っている場合などには「適切」がどこかは悩ましい\n\n(今回はこちらが該当)リンク時に未解決シンボルがあるエラーの場合は解説ページ上 `Library` を追加します。 `version.lib`\nを追加しろとの解説がありますね。ではどうやって追加するか、ですが VS2019 の IDE 画面上のメニューバー プロジェクト(P) → プロパティ (P)\nから追加します。プロパティページ画面が開くので左ペイン「リンカー→入力」を選ぶと右ペインに「追加の依存ファイル」がたくさん並んでいるはず。ここに\n`version.lib` が無いはずなので、適当な場所に追加します。よく見ると区切り記号は `;` なことがわかるので\n`version.lib;kernel32.lib;....`\nのように追加することでリンクが通るようになります(最初に追加するか末尾に追加するかで意味が違いますが、この例ではどちらでも可)\n\nところがこのプロパティページ、よく見ると上のほうに「構成」と「プラットフォーム」というのがあります。「構成」には `Debug` と `Release`\nが、「プラットフォーム」には `Win32` と `x64` があります( `x64`\nは出ない場合もあります)2種類x2種類で4つのプロパティページのすべてに追加変更を行っておくことをお勧めします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T05:41:15.337", "id": "91347", "last_activity_date": "2022-09-28T05:41:15.337", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8589", "parent_id": "91343", "post_type": "answer", "score": 1 }, { "body": "原因や対処については既に回答されている通りですが、対処については Visual C++ 限定で簡略化出来る方法があります。\n\nこちらの記事で解説されているもので、プリプロセッサへの指令でリンクするライブラリをソースコードに明記する方法です。 \n[comment pragma](https://learn.microsoft.com/ja-jp/cpp/preprocessor/comment-c-\ncpp?view=msvc-170) \n[lib](https://learn.microsoft.com/ja-jp/cpp/preprocessor/comment-c-\ncpp?view=msvc-170#lib)\n\n> オブジェクト ファイル内にライブラリ検索レコードを配置します。\n\n[例](https://learn.microsoft.com/ja-jp/cpp/preprocessor/comment-c-\ncpp?view=msvc-170#examples)\n\n> #pragma comment( lib, \"emapi\" )\n\n上記を適用して質問内容に合わせると、ソースコード上の`#include`等に続けて以下を記述しておけば、プロジェクトのプロパティに幾つのプラットフォーム(Win32/x86/x64/他)や構成(Debug/Release/他)の別が有るかを気にせずどのようなモードを選んでもビルド出来ます。\n\n```\n\n #pragma comment( lib, \"version\" )\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T07:01:17.757", "id": "91349", "last_activity_date": "2022-09-28T07:07:13.330", "last_edit_date": "2022-09-28T07:07:13.330", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "91343", "post_type": "answer", "score": 1 } ]
91343
null
91346
{ "accepted_answer_id": null, "answer_count": 0, "body": "以下のコードでsystemNavigationBarの色を変えているのですが、NavigationBarと色が合わず違和感があります。 \nMaterial 3のDynamic Colorを使用した環境のため、カラーコードを直接打つことができません。何かいい方法は無いでしょうか?\n\n```\n\n return AnnotatedRegion<SystemUiOverlayStyle>(\n value: SystemUiOverlayStyle(\n systemNavigationBarColor: Theme.of(context).colorScheme.tertiaryContainer\n ),\n child: ...\n )\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T04:50:39.520", "favorite_count": 0, "id": "91344", "last_activity_date": "2022-09-28T05:00:16.430", "last_edit_date": "2022-09-28T05:00:16.430", "last_editor_user_id": "3060", "owner_user_id": "54585", "post_type": "question", "score": 0, "tags": [ "android", "flutter", "dart" ], "title": "NavigationBarとsystemNavigationBarの色を合わせたい", "view_count": 51 }
[]
91344
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "laragonを利用して、ローカル環境でLaravelを動作させたいと考えています。 \n本番のLaravelにあわせてバージョンを指定した上でインストールしたいのですが \nバージョンを指定すると「Could not find package」と表示されてインストールに失敗します。 \nこれは何が原因でしょうか。\n\nPHPバージョンは 8.1.0 です。\n\nこちらがエラーがでるコードです。\n\n```\n\n composer create-project \"laravel/laravel=9.20.0\" %s --prefer-dist\n \n```\n\n下記のようなエラーが表示されます。\n\n```\n\n In CreateProjectCommand.php line 438:\n Could not find package laravel/laravel with version 9.20.0.\n \n```\n\nこちらは問題なくインストールされます。\n\n```\n\n composer create-project \"laravel/laravel=9.*\" %s --prefer-dist\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T05:19:55.847", "favorite_count": 0, "id": "91345", "last_activity_date": "2023-05-29T15:03:00.473", "last_edit_date": "2022-10-02T06:06:34.117", "last_editor_user_id": "3060", "owner_user_id": "26236", "post_type": "question", "score": 0, "tags": [ "laravel", "composer" ], "title": "laravelの指定バージョンのインストールに失敗する", "view_count": 1028 }
[ { "body": "自分の環境でも同様でした。 \n最新で入るのが9.3.8なので、それ以前のバージョンなら指定できそうですね。\n\n```\n\n $ composer create-project \"laravel/laravel=9.*\" %s --prefer-dist\n Creating a \"laravel/laravel=9.*\" project at \"./%s\"\n Installing laravel/laravel (v9.3.8)\n - Installing laravel/laravel (v9.3.8): Extracting archive\n \n```\n\nChangeLogでは確かに9.32.0まで出てますが \n<https://github.com/laravel/framework/blob/9.x/CHANGELOG.md>\n\ncomposerに対応バージョンの遅れがあるとか?\n\n```\n\n $ composer create-project \"laravel/laravel=9.3.7\" %s --prefer-dist\n Creating a \"laravel/laravel=9.3.7\" project at \"./%s\"\n Installing laravel/laravel (v9.3.7)\n - Downloading laravel/laravel (v9.3.7)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T03:39:27.493", "id": "91395", "last_activity_date": "2022-10-02T03:39:27.493", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "15380", "parent_id": "91345", "post_type": "answer", "score": 0 } ]
91345
null
91395
{ "accepted_answer_id": "91359", "answer_count": 2, "body": "```\n\n (function() { return; }());\n (function() { return; })();\n \n```\n\n[JavaScript: The Definitive Guide, 7th\nEdition](https://www.oreilly.com/library/view/javascript-the-\ndefinitive/9781491952016/)に,IIFEの例として前者のコードが挙げられていました(簡略化しております).\n\nしかしながら,[JavaScriptのIIFEを使うユースケース -\nQiita](https://qiita.com/snamiki1212/items/37152d0066c57eb60796#%E3%82%B0%E3%83%AD%E3%83%BC%E3%83%90%E3%83%AB%E9%A0%98%E5%9F%9F%E3%82%92%E6%B1%9A%E3%81%97%E3%81%9F%E3%81%8F%E3%81%AA%E3%81%84%E3%82%B1%E3%83%BC%E3%82%B9)や,[JavascriptのIIFEについて考える\n-\ntorikatsu.dev](https://torikatsu923.hatenablog.com/entry/2020/11/19/224003)等では,後者のような記述がされています.\n\nこれらの記述方法に何か違いはありますか.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T06:12:21.860", "favorite_count": 0, "id": "91348", "last_activity_date": "2022-09-30T07:00:05.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51374", "post_type": "question", "score": 6, "tags": [ "javascript" ], "title": "JSの即時関数実行式において,()の位置が変わると挙動にどう影響するか.", "view_count": 182 }
[ { "body": "[What is the (function() { } )() construct in JavaScript? - Stack\nOverflow](https://stackoverflow.com/questions/8228281/what-is-the-function-\nconstruct-in-javascript#comment10893497_8228281) からリンクされている[Immediately-\nInvoked Function Expression\n(IIFE)](https://benalman.com/news/2010/11/immediately-invoked-function-\nexpression/)\nというアーティクルや、[Wikipedia](https://en.wikipedia.org/wiki/Immediately_invoked_function_expression)の解説及び参照リンク先が参考になるのでは、と思いました。\n\n上記リンク先を見ていただくのが正確かと思いますが、私の理解を以下に記載してみます。\n\n関数を即時実行しているわかりやすい例として次のようなものが挙げられます: \n\n```\n\n var i = function(){ return 10; }();\n console.log(i)\n```\n\nここで、戻り値が不要なので代入を省略して次のように書こう、とするとシンタックスエラーになります: \n\n```\n\n function(){ return 10; }();\n```\n\nこれは、`function`キーワードが最初の例では[関数式](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/function)とみなされますが、次の例では[関数宣言](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Statements/function)とみなされてしまっているためです。 \n関数式とみなされるようにするためには(冒頭リンク先にある通り)いくつか方法がありますが、典型的なものとしては、最初の例の右辺全体をカッコで囲ってしまう方法\n\n```\n\n // var i = (function(){ return 10; }());\n // 戻り値は不要なので\n (function(){ return 10; }());\n```\n\nの他、関数式の部分だけカッコで囲っても問題を回避できます。\n\n```\n\n (function(){ return 10; })();\n```\n\nつまり、質問の回答としては **違いは無い** 、ということになります。\n\n* * *\n\n(追記) \n書籍 [JavaScriptテクニックバイブル](https://gihyo.jp/book/2012/978-4-7741-5243-1) ではまさに\n\"「(function(){}())」と「(function(){})()」の違い\" というセクションがありました(p.142, 4-12\nグローバルスコープの汚染を防ぐ)。\n\nここでは前者は1段階の実行\n\n> * 式としての「function(){}」を \"Function Calls\" で呼び出し、 \"The Group Operator\"\n> によって評価した値を返す\n>\n\n、後者は2段階の実行\n\n> * \"The Grouping Operator\" で「function(){}」を式として認識させ、\n> * \"Function Calls\" でその評価結果である関数を実行する\n>\n\nであると説明し、このため極わずかだが前者の方が実行コストは低い、としています。 \n(ただ、本当に差異があるとして、一般的にそれを理由として \"The Grouping Operator\"\nの使用を避けるような方針は採らないのでは、と個人的には考えます)\n\nまた、[JSLint](https://www.jslint.com/) は `(function(){})()`\nの書式に対して警告を出す([参考](http://linterrors.com/js/do-not-wrap-function-literals-in-\nparens))ということも同節で触れられていました。\n\n* * *\n\nどちらの書き方が望ましいか、という点については、2010年に書かれた[こちらの記事](https://benalman.com/news/2010/11/immediately-\ninvoked-function-expression/#iife)では\n\n>\n```\n\n> (function(){ /* code */ }()); // Crockford recommends this one\n> (function(){ /* code */ })(); // But this one works just as well\n> \n```\n\nとありますが(*1)、WikipediaからリンクされているES6時代に書かれた[こちらの記事](https://exploringjs.com/es6/ch_arrow-\nfunctions.html#_parenthesizing-arrow-function-with-block-bodies)では\n\n> (前略)\n```\n\n> (function () {\n> ···\n> }());\n> \n```\n\n>\n> Or just around the function expression:\n```\n\n> (function () {\n> ···\n> })();\n> \n```\n\n>\n> Given how arrow functions work, the latter way of parenthesizing should be\n> preferred from now on.\n\nとあります。\n\n*1) おそらく Douglas Crockford 氏の著書 [JavaScript: The Good Parts](https://www.oreilly.co.jp/books/9784873113913/) にそういう記述があるのではないかなと想像します([参考](https://www.publickey1.jp/blog/13/javascript_douglas_crockfordqcon_tokyo_2013_1.html))。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T13:02:55.283", "id": "91359", "last_activity_date": "2022-09-30T07:00:05.473", "last_edit_date": "2022-09-30T07:00:05.473", "last_editor_user_id": "2808", "owner_user_id": "2808", "parent_id": "91348", "post_type": "answer", "score": 5 }, { "body": "違いは無いです。ただし、アロー関数を用いる場合は、後者の記述しか使えません。\n\n```\n\n // おそらく現時点で最短の即時実行関数\n (_=>{ /*コード*/ })()\n \n```\n\n### 根拠\n\n[AST\nExplorer](https://astexplorer.net/#/gist/694b70ca29e7b3639e6bd1d515b67226/6afec204a6b2f4f828dfb73ba61ec8de85dc0984)\nなどで見てみると、殆どのパーサーで同じ AST\nになっています。当然、これらのパーサーを使うコード生成ツールにかけると、どちらの記述も同じコードに変換されます。\n\n * [Acorn + Astring](https://david.bonnet.cc/astring/demo/#%28function%28%29%20%7B%20return;%20%7D%28%29%29;%0A%0A%28function%28%29%20%7B%20return;%20%7D%29%28%29;)\n * [Babel](https://babeljs.io/repl#?browsers=defaults&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=BQMwrgdgxgLglgewsAlAAgN5oE4FMZjYQDcaAvqisQFDWiSyLLpZ4FGlkqrFA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env&prettier=false&targets=&version=7.19.3&externalPlugins=&assumptions=%7B%7D)\n\n上の2つのコード生成ツールでは、どちらの記述も\n\n```\n\n (function () {\n return;\n })();\n \n```\n\nとなりました。また、古めの書籍ですが『開眼! JavaScript』には「同じ結果を得られる」と書かれています。\n\n### 余談: グループ化演算子(丸括弧)を使う理由\n\n質問のリンク先の記事に、\n\n> グループ化演算子は静的なスコープをもっているようです。 \n> ... \n> 名前空間を切り分ける目的でグループ化演算子が用いられていると考えられます。\n\nとあります。これが正しいとすると、引数に渡す式が有った場合は、2つの記述には違いが有ることになります。\n\nしかし、これは誤りです。関数自体がスコープを持ちますので、グループ化演算子で囲まなくとも同じ結果となります。グループ化演算子はスコープを作りません。グループ化演算子を使うのは、単項演算子(`!`\nや `~`)を付ける方法と比べると、呪文めいておらず、多少は意図が解り易いからではないかと思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T13:27:22.680", "id": "91361", "last_activity_date": "2022-09-28T13:27:22.680", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "91348", "post_type": "answer", "score": 2 } ]
91348
91359
91359
{ "accepted_answer_id": "91363", "answer_count": 1, "body": "# 状況\n\nPCが複数台あり、メインの開発PCのプロジェクトをマスターとして、Gitリポジトリを作成し、別のPCではgit pullで同期しております。 \n各PCのプロジェクトフォルダには、venvで仮想環境を作り、共通してENVというフォルダ名にしております。 \n自作パッケージを各仮想環境にインストールするため、パッケージごとに以下のコマンドを実行します。\n\n```\n\n python -m pip install -e .\n \n```\n\n開発PCでは特に問題なくインストールできます。 \nしかし、もう一台のPC(以下PC1)では文字コードが原因でエラーとされてしまいます。 \n各パッケージに関する説明を書いた、マークダウンファイルが日本語で記述されていて、これがエラーの対象となっているようです。\n\n# 質問内容\n\nPC1を開発PCのように文字コードエラーなく、自作パッケージをインストールするためには、どのようにしたらよいでしょうか?\n\n# 開発環境\n\n開発PCおよびPC1ともに以下の環境です。 \nWindows 10 Pro \nPython 3.9.10\n\n# エラー出力内容\n\n```\n\n (ENV) PS C:\\Users\\(パッケージフォルダ) > python -m pip install -e .\n Obtaining file://C:\\Users\\(パッケージフォルダ)\n Preparing metadata (setup.py) ... error\n error: subprocess-exited-with-error\n \n × python setup.py egg_info did not run successfully.\n │ exit code: 1\n ╰─> [6 lines of output]\n Traceback (most recent call last):\n File \"<string>\", line 2, in <module>\n File \"<pip-setuptools-caller>\", line 34, in <module>\n File \"C:\\Users\\(パッケージフォルダ)\\setup.py\", line 13, in <module>\n long_description=open(\"README.md\").read(),\n UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 34: illegal multibyte sequence\n [end of output]\n \n note: This error originates from a subprocess, and is likely not a problem with pip.\n error: metadata-generation-failed\n \n × Encountered error while generating package metadata.\n ╰─> See above for output.\n \n note: This is an issue with the package mentioned above, not pip.\n hint: See above for details.\n \n```", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T07:29:51.270", "favorite_count": 0, "id": "91350", "last_activity_date": "2022-09-29T00:58:53.747", "last_edit_date": "2022-09-29T00:58:53.747", "last_editor_user_id": "3060", "owner_user_id": "32891", "post_type": "question", "score": 0, "tags": [ "python", "python3", "windows" ], "title": "自作パッケージをpipでインストールするとエラーとなってしまいます。", "view_count": 17828 }
[ { "body": "ご指摘のありました箇所を修正することで、解決しました。\n\n**修正前:**\n\n```\n\n long_description=open(\"README.md\").read(),\n \n```\n\n**修正後:**\n\n```\n\n long_description=open(\"README.md\", encoding='UTF-8').read(),\n \n```\n\n### setup.py\n\n```\n\n from setuptools import setup, find_packages\n \n version = \"1.0.0\"\n \n install_requires = [\n # 必要な依存ライブラリがあれば記述\n ]\n \n setup(\n name='app',\n version=nversion,\n description=\"***\",\n long_description=open(\"README.md\", encoding='UTF-8').read(),\n long_description_content_type='text/markdown',\n author='Imagenics.co.,ltd',\n license='***',\n keywords='***',\n python_requires='>=3.6',\n packages=find_packages(),\n install_requires=install_requires,\n )\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T00:19:26.943", "id": "91363", "last_activity_date": "2022-09-29T00:54:42.127", "last_edit_date": "2022-09-29T00:54:42.127", "last_editor_user_id": "3060", "owner_user_id": "32891", "parent_id": "91350", "post_type": "answer", "score": 0 } ]
91350
91363
91363
{ "accepted_answer_id": null, "answer_count": 0, "body": "React初学者です \nReactでコンポーネントを作成するときに下記の方法で作成可能だと知ったのですが、文法以外で違いがわからないです。 \nそれぞれに適した用途があるのでしょうか。\n\n```\n\n React.FC\n React.Component\n JSX.Element\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T08:35:32.180", "favorite_count": 0, "id": "91351", "last_activity_date": "2022-09-28T08:35:32.180", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30328", "post_type": "question", "score": 0, "tags": [ "javascript", "reactjs", "react-jsx" ], "title": "ReactのComponent作成時の質問", "view_count": 40 }
[]
91351
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在さくらVPSでDjangoのプロジェクトを運用しています。\n\nアップデートのためサーバー内のプロジェクトを最新にし、collectstaticを行ったあと、nginxなどをリスタートしたのですが、サイトを訪れディベロッパーツールで確認するとhtmlが更新されていないことがわかりました。\n\n解決するために行ったこと \n・スーパーリロードを行いキャッシュをクリア \n・サーバー内のプロジェクトを参照し、本当に更新されているかを確認\n\n上記の2つを行いましたが、キャッシュはクリアできず、サーバー内のプロジェクトはしっかり更新されていました。\n\nサーバー内のキャッシュが残っているのでしょうか? \nどなたか解決法をおしえてください。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T08:43:26.280", "favorite_count": 0, "id": "91352", "last_activity_date": "2022-09-28T08:43:26.280", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "41131", "post_type": "question", "score": 0, "tags": [ "html", "linux", "ubuntu", "django", "nginx" ], "title": "DjangoをUbuntuのサーバーにデプロイ後、サイトを開くとhtmlが更新されていない問題", "view_count": 68 }
[]
91352
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "UnityアプリからFirebase Authenticationを利用する上でFirebase Authentication Unity\nSDKを使用したアクセスをしたいと思っています。 \nFirebase Authentication Unity SDKはAndroid, iOSは利用対象と思いますが、MacOSでも利用可能なのでしょうか?\n\nまたWindowsのUnityアプリでFirebase Authenticationを利用する場合、Firebase Authentication\nUnity SDKは利用できないと思いますが、代替案としては、Firebase Auth REST APIを利用すればよいでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T09:04:25.130", "favorite_count": 0, "id": "91353", "last_activity_date": "2022-09-28T09:04:25.130", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54592", "post_type": "question", "score": 0, "tags": [ "firebase" ], "title": "Firebase Authentication Unity SDKのデスクトップOSでの利用について教えてください。", "view_count": 75 }
[]
91353
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "Firebase Authenticationを利用するにあたり、いくつかアクセス方法があると思いますが、Firebase Auth REST\nAPIとFirebase Authentication Unity\nSDKでアクセスする場合、セキュリティはどちらも安全でしょうか?またどちらかがセキュリティに優れているなどはありますか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T09:59:26.743", "favorite_count": 0, "id": "91354", "last_activity_date": "2022-09-28T09:59:26.743", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54592", "post_type": "question", "score": 0, "tags": [ "firebase" ], "title": "Firebase Auth REST APIのセキュリティについて", "view_count": 47 }
[]
91354
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "### 前提\n\nChart.js(バージョン2.8.0)で複合グラフを作っています。 \n横軸:日付(\"2022-07-01\"など) \n縦軸:整数と実数 \n※横軸の表示をすっきりさせるため、xAxes.type='time'にしています。 \n※xAxes.typeを設定しないとこの問題が生じないことは確認済みです。\n\n### 目標\n\nこのページのグラフのように、すべての棒グラフを完全に描画したい \n<https://stopcovid19.metro.tokyo.lg.jp/cards/monitoring-number-of-confirmed-\ncases> \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-09-28/121ca6da-11a5-4794-83b6-f3e8e0c9dc7b.png)\n\n### 現状\n\n両端の棒グラフが、半分切れてしまっている \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-09-28/297bd964-a5ec-4e38-9325-bc7ce23030db.png)\n\n### 問題だと思われること\n\n目標のグラフでは目盛りとグラフの両端の間に余裕があるが、現状のグラフでは目盛りがグラフの両端の上に乗っている。このために、両端の棒グラフが半分になっていると思われる。\n\n**両端の棒グラフが切れないためにはどうしたらよいでしょうか?**\n\n初歩的な質問かもしれないのですが、解決策を教えていただけると大変助かりますm(_ _;)m\n\n### 以下、ソースコード\n\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta charset=\"utf-8\">\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.js\"></script>\n </head>\n <body>\n <canvas class=\"element1\" id=\"myMixedChart\"></canvas>\n \n <script>\n ///////////////////////グラフに入れる変数///////////////////////\n var chartVal_datetime = [<?php echo $datetime ?>];\n var chartVal_viewinc = [<?php echo $viewinc ?>];\n var chartVal_incmov = [<?php echo $incmov ?>];\n ////////// display chart//////////\n function dischart(xdata,ydata,movdata,canvasid){\n var ctx = document.getElementById(canvasid);\n window.dailychart = new Chart(ctx, {\n type: 'bar',\n data: {\n labels: xdata,\n datasets: [\n {\n //折れ線グラフ\n type: 'line',\n data: movdata,\n borderColor: \"orange\",\n backgroundColor: \"rgba(0,0,0,0)\",\n pointRadius:0,\n lineTension: 0.5\n }, \n {\n //棒グラフ\n type: 'bar',\n data: ydata,\n backgroundColor: \"green\"\n }\n ]\n },\n options: {\n responsive: true,\n maintainAspectRatio: false,\n animation: false,\n scales: {\n xAxes: [\n {\n type: 'time',\n time:{\n unit: 'day'\n },\n gridLines:{\n display: false\n }\n }\n ],\n yAxes: [\n {\n ticks: {\n suggestedMin: 0,\n }\n }\n ]\n },\n tooltips: {\n mode: 'index'\n }\n },\n });\n }\n dischart(chartVal_datetime,chartVal_viewinc,chartVal_incmov,\"myMixedChart\");\n \n </script>\n </body>\n </html>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T10:52:51.207", "favorite_count": 0, "id": "91355", "last_activity_date": "2022-09-28T13:34:20.707", "last_edit_date": "2022-09-28T13:34:20.707", "last_editor_user_id": "3060", "owner_user_id": "53524", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "html5", "html5-canvas", "chart.js" ], "title": "Chart.js で描画した棒グラフの両端が切れてしまう", "view_count": 293 }
[]
91355
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "Firebase Authenticationを利用する上で以下のURL内に記述があるようにBlaze\nプランにて無料枠を超えた場合、料金が発生することはわかっております。 \n<https://firebase.google.com/docs/auth#pay_as_you_go_blaze>\n\nFirebase Auth REST APIを利用するとCloud Firestoreを利用することになるため、以下のURLに記載があるように \n読み取り、書き込み、削除などの料金が発生するのでしょうか? \n<https://firebase.google.com/docs/firestore/pricing#select-region>", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T11:06:41.857", "favorite_count": 0, "id": "91356", "last_activity_date": "2022-09-28T11:06:41.857", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54592", "post_type": "question", "score": 0, "tags": [ "firebase" ], "title": "Firebase Authentication SDKの代替案としてFirebase Auth REST APIを用いた際の料金について教えてください。", "view_count": 70 }
[]
91356
null
null
{ "accepted_answer_id": "91370", "answer_count": 1, "body": "シート1に\n\n```\n\n key\n 1\n 2\n 3\n 2\n 1\n \n```\n\nとキーがかいてあって\n\nシート2に\n\n```\n\n key val\n 1 abc\n 2 xyz\n \n```\n\nという感じでキーとうめたい文字列がかかれてるとして\n\nシート1の2列目にシート2のキーに対応する文字列を入れたいです\n\nLOOKUPメソッドを使えばできるみたいなんですが \n`=LOOKUP(A2,'シート2'!A:A, 'シート2'!B:B)` \nという計算式で2列目うめたところ\n\n```\n\n key val\n 1 abc\n 2 xyz\n 3 xyz\n 2 xyz\n 1 abc\n \n```\n\nとなぜか key=3 の存在しない値までうまってしまいます\n\n存在しない値は空白のままにしたいのですが可能でしょうか?", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T12:46:26.820", "favorite_count": 0, "id": "91358", "last_activity_date": "2022-09-30T01:33:23.507", "last_edit_date": "2022-09-28T12:52:32.467", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "google-spreadsheet" ], "title": "別シートを行検索して値を埋めたい", "view_count": 73 }
[ { "body": "vlookupを使えばうまくいくと思います。※こちらの環境ではうまくいきました。\n\n```\n\n =vlookup(A2, 'シート2'!A:B, 2, FALSE)\n \n```\n\nコードの重複が気になりますが、見つからなかったときに特定の文字列(今回はNG)とする場合は以下のように書けばよいです。\n\n```\n\n =if(isna(vlookup(A2, 'シート2'!A:B, 2, FALSE)), \"NG\", vlookup(A2, 'シート2'!A:B, 2, FALSE))\n \n```\n\n* * *\n\n以下追記です。 \n`iferror`を使うともっと簡潔に書けました。\n\n```\n\n =iferror(vlookup(A2, 'シート2'!A:B, 2, FALSE), \"NG\")\n \n```\n\n`filter`を使った別解です。\n\n```\n\n =iferror(index(filter('シート2'!B:B,'シート2'!A:A=A2),1), \"NG\")\n \n```\n\n簡単に説明すると、'シート2'!A:Aの範囲でA2と同じ値を検索し、見つかった行のB列の値を返します。 \n今回の質問では使う必要はありませんが、検索する列と値を返す列が連続していない場合にはこの方法が有効だと思います。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T08:15:23.007", "id": "91370", "last_activity_date": "2022-09-30T01:33:23.507", "last_edit_date": "2022-09-30T01:33:23.507", "last_editor_user_id": "35558", "owner_user_id": "35558", "parent_id": "91358", "post_type": "answer", "score": 1 } ]
91358
91370
91370
{ "accepted_answer_id": null, "answer_count": 1, "body": "Pythonでファイル名と同じフォルダ名に格納したい\n\nPyPDF2でPDFを分割をしました。分割処理までは出来たのですが、その先の分割したファイルを指定のフォルダに格納するやり方が分かりません。\nやりたいこととして、テストフォルダ内の「1」「2「3」へのフォルダ名に \n分割したファイル名の1.pdf ,2.pdf,3.pdfのファイルをそれぞれフォルダに格納させたいです。\n\nフォルダは先に新規で作成した状態です。\n\n1.pdf → 1のフォルダ \n2.pdf → 2のフォルダ \n3.pdf→ 3のフォルダ\n\n開発環境はWindowsで\n\nPythonか、Windowsコマンドのバッチなど処理で可能でしょうか? \nもし可能ならご教示願います。\n\n```\n\n import PyPDF2\n \n # プログラム2|フォルダ内のPDFを全て取得\n curdir = os.getcwd()\n files = list(pathlib.Path(curdir).glob('*.pdf'))\n  \n # プログラム3|フォルダ内の全てのPDFを処理\n for file in files:\n \n merger = PyPDF2.PdfFileMerger()\n merger.append('test1.pdf', pages=(1, 9))\n merger.write('test4.pdf')\n merger.close()\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-28T13:11:22.990", "favorite_count": 0, "id": "91360", "last_activity_date": "2022-09-29T05:58:18.717", "last_edit_date": "2022-09-28T13:51:05.117", "last_editor_user_id": "39819", "owner_user_id": "54596", "post_type": "question", "score": -1, "tags": [ "python", "windows" ], "title": "Pythonでファイル名と同じフォルダ名に保存がしたい", "view_count": 518 }
[ { "body": "フォルダ名とファイル名を`/`または`\\`のセパレータで区切って指定することで、フォルダ名とファイル名を指定できます。 \nPDFのページ番号はPyPDF2の[`numPages`](https://nanonets.com/blog/pypdf2-library-\nworking-with-pdf-files-in-python/#extracting-document-details-with-\npypdf2)プロパティで取得できるので、例えば1ページ目は`.\\1\\1.pdf`など、ページ番号ごとにループして保存したいならば、下記のようなコードで実現できます\n\n```\n\n pdf = PdfFileReader(src)\n for i in range(pdf.numPages):\n # 分割データ作成\n dest = PdfFileWriter()\n dest.addPage(pdf.getPage(i))\n with open(f\"./{i+1}/{i+1}.pdf\", \"wb\") as f:\n dest.write(f)\n \n```\n\nなおフォルダ内のpdfをglobで取得していますので、ファイル名を一律で`1.pdf`のように設定すると既存の同名ファイルを上書きしてしまいます。\n\n要件の推測を多分に含みますが、分割後のファイル名のプレフィックスに既存ファイル名を設定する(例えば `TEAMS_content_health.pdf`\nの1ページ目は `TEAMS_content_health_1.pdf` になる)場合は、下記のサンプルコードのようなコーティングで対応できます。\n\nご質問のコードではPDFの結合をしており分割処理が見当たらない点や、`for`文の中でページ番号を記載していない点から、ご質問の意図が汲み取りにくく感じました。 \nこの回答が的外れな場合は、コメントの指摘事項などを質問文に追記してみてください。\n\n**サンプルコード**\n\n```\n\n import urllib.request\n import os\n from pathlib import Path\n from PyPDF2 import PdfFileReader, PdfFileWriter\n \n # サンプルPDFをダウンロードして取得する(※ダウンロードできない場合は代替ファイルをご用意ください)\n urls = [\"https://x54cwjdqkdu7-so-docs.netlify.app/pdf/teams/b_b/general_information/TEAMS_content_health.pdf\",\n \"https://x54cwjdqkdu7-so-docs.netlify.app/pdf/teams/b_b/getting_started/TEAMS_ask_a_question.pdf\"]\n for url in urls:\n src = url.split(\"/\")[-1]\n urllib.request.urlretrieve(url, src)\n \n # フォルダ内のPDFをループしながら分割する\n for src in Path().glob('*.pdf'):\n # サンプルPDFのページを分割して保存する\n pdf = PdfFileReader(src)\n for i in range(pdf.numPages):\n # 分割データ作成\n dest = PdfFileWriter()\n dest.addPage(pdf.getPage(i))\n # 分割後のファイル名(例えば TEAMS_content_health.pdf の1ページ目は TEAMS_content_health_1.pdf になる)\n name = f\"{Path(src).stem}_{i+1}.pdf\" \n # ページ番号に該当する数字フォルダがなければ作成\n os.makedirs(str(i+1), exist_ok=True)\n # ファイル出力(数字フォルダ内に分割後のファイル名でファイルを保存する)\n with open(f\"./{i+1}/{name}.pdf\", \"wb\") as f:\n dest.write(f)\n \n```\n\n**実行結果**\n\n```\n\n > tree /F test\n フォルダー パスの一覧: ボリューム Windows \n ボリューム シリアル番号は FFFF-FFFF です\n {フルパス}\\TEST\n ├─1\n │ TEAMS_ask_a_question_1.pdf.pdf\n │ TEAMS_content_health_1.pdf.pdf\n │\n ├─2\n │ TEAMS_ask_a_question_2.pdf.pdf\n │ TEAMS_content_health_2.pdf.pdf\n │\n ├─3\n │ TEAMS_content_health_3.pdf.pdf\n │\n └─4\n TEAMS_content_health_4.pdf.pdf\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T05:58:18.717", "id": "91368", "last_activity_date": "2022-09-29T05:58:18.717", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "91360", "post_type": "answer", "score": 0 } ]
91360
null
91368
{ "accepted_answer_id": null, "answer_count": 1, "body": "visual studio 2019で作成したexeファイルのCRC値を \n例)Tool CRC: 0x12345678 \nのように表示したいのですが、調べても以下のリンク先のような \n<https://gist.github.com/timepp/1f678e200d9e0f2a043a9ec6b3690635> \nCRCの算出方法が記載されているだけで、分からないので質問させていただきました。 \nご助言の程宜しくお願い致します。", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T00:12:20.983", "favorite_count": 0, "id": "91362", "last_activity_date": "2022-09-29T00:41:40.293", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "47970", "post_type": "question", "score": -3, "tags": [ "c++" ], "title": "visual studio 2019で作成したexeファイルのCRC値(CRC32C)を表示したい。", "view_count": 274 }
[ { "body": "CRC値を算出アプリってのはぐぐってみるといくつかあるようです。 \nその実行ファイルをそのアプリにかければ、CRC値が出てきます", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T00:41:40.293", "id": "91364", "last_activity_date": "2022-09-29T00:41:40.293", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27481", "parent_id": "91362", "post_type": "answer", "score": 0 } ]
91362
null
91364
{ "accepted_answer_id": null, "answer_count": 2, "body": "超初学者です \nYouTubeの見過ぎ対策で、一定時間YouTubeを開き続けると自動的に落ちるツールを作ることは可能でしょうか \nまた仮に可能だとしてそれをpythonで実装することはできるでしょうか \nハードはiPhone,mac希望です\n\nプログラミング自体始めたてで、どんなことができるのかよく分かってないため質問させていただきました。 \nちなみに今の自分はif文for文などひよこレベルです!", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T04:34:29.043", "favorite_count": 0, "id": "91366", "last_activity_date": "2022-09-29T09:37:31.243", "last_edit_date": "2022-09-29T04:36:23.683", "last_editor_user_id": "54605", "owner_user_id": "54605", "post_type": "question", "score": -2, "tags": [ "python", "python3", "c#", "c", "youtube" ], "title": "YouTubeの見過ぎ対策で", "view_count": 319 }
[ { "body": "一定時間で自動的に落ちるようにするってことは、他のアプリを自動的に止めることになります。 \nこれはちょっと難しいかもしれません。 \n発想を変えて、一定時間で停止する機能を持った、YouTubeのビューアを作成するというのであれば、比較的簡単に作成できると思います。 \nただいずれにしましても、ある程度の知識が必要になりますので、まずは普通にアプリの作成方法を勉強するところからすすめた方がいいと思います。 \niPhone,Macのアプリはxcodeで作成します。 \nxcodeは無償でインストールできますので、簡単なプログラムから作ってみましょう。 \nmacのアプリは作ったものを簡単に配布できますが、iPhoneのアプリはいろいろ \n面倒なことがありますので、そのあたりも調べた方がいいと思います。 \niPhoneのアプリは、自分専用であればあんまり問題ありません。\n\n上記のソフトはpythonでも可能かもしれませんが、ある程度の規模以上のアプリを \n作りたい場合は、Swift等の方がいいかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T06:26:47.437", "id": "91369", "last_activity_date": "2022-09-29T06:42:13.070", "last_edit_date": "2022-09-29T06:42:13.070", "last_editor_user_id": "24490", "owner_user_id": "24490", "parent_id": "91366", "post_type": "answer", "score": 0 }, { "body": "iPhone での利用を制限したい場合、自作せずとも、Apple\nが標準で提供しているペアレンタルコントロールの機能である、スクリーンタイムを設定するのが早いです:\n<https://support.apple.com/ja-jp/guide/iphone/iph7f15d92dd/ios>\n\n> ファミリーメンバーのデバイスに休止時間とAppの制限を設定する\n>\n> 1. ファミリーメンバーのデバイスで、「設定」 >「スクリーンタイム」と選択します。\n> 2. 「スクリーンタイムをオンにする」>「続ける」>「これは子供用のiPhoneです」と選択します。\n> 3. ファミリーメンバーの休止時間(画面から離れる時間)を設定するには、開始時刻と終了時刻を入力してから、「休止時間を設定」をタップします。\n> 4. ファミリーメンバーのために管理したいAppのカテゴリ(ゲームやSNSなど)に制限を設けるには、そのカテゴリを選択します。 \n> すべてのカテゴリを表示するには、「すべてのカテゴリを表示」をタップします。\n> 5. 「設定」をタップしてから、時間を入力し、「App使用時間の制限を設定」をタップします。\n> 6. 「続ける」をタップしてから、ファミリーメンバーのスクリーンタイム設定を管理するスクリーンタイム用パスコードを入力します。\n>", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T09:37:31.243", "id": "91371", "last_activity_date": "2022-09-29T09:37:31.243", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "91366", "post_type": "answer", "score": 2 } ]
91366
null
91371
{ "accepted_answer_id": "91378", "answer_count": 1, "body": "テキストをA→Z順に並び替えたうえで、重複なしで文字列と個数を表示させるマクロはありますでしょうか。\n\nいうえ \nあ \nあい \nいうえ \nあ \nいうえ\n\nたとえば上記から、下記の結果を得たいのです。\n\nあ 2 \nあい 1 \nいうえ 3\n\nご教示のほどよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T10:13:24.383", "favorite_count": 0, "id": "91372", "last_activity_date": "2022-09-29T21:26:20.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43123", "post_type": "question", "score": 1, "tags": [ "emeditor" ], "title": "各行の文字列のユニークな個数をカウントする方法", "view_count": 65 }
[ { "body": "[検索] メニューの [頻出文字列を抽出] を選択して、既定のオプションのままで OK をクリックすれば可能です。出力結果は必要に応じて並べ替えてください。\n\nマクロだと、以下のようになります。\n\n```\n\n document.selection.ExtractFrequent(eeFreqTypeLines, eeFindReplaceCase, 1, 100, \"\");\n document.Sort(\"1>A+\",eeSortBinaryComparison | eeSortIgnorePrefix,\"\");\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T21:26:20.210", "id": "91378", "last_activity_date": "2022-09-29T21:26:20.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "40017", "parent_id": "91372", "post_type": "answer", "score": 1 } ]
91372
91378
91378
{ "accepted_answer_id": "91382", "answer_count": 2, "body": "Windows 10 Home上でSpresenseのSDK (IDE)環境を新規に構築しています。 \nデバッガとして公式ページに載っているLCP-Link2がほぼ入手不可能な様子なので、DAP-LinkコンパチなMCU-\nLinkが使えないか試すのが動機です(それができたら秋月のlPC11U35ボードも...)。単体OpenOCDで\"openocd -f\ninterface/cmsis-dap.cfg -f target/cxd5602.cfg\"でSpresenseに接続できることまでは確認しました。\n\n・やったこと \n[Spresense公式ページ](https://developer.sony.com/develop/spresense/docs/sdk_set_up_ide_ja.html)に添って新規にMSYS2(インストーラmsys2-x86_64-20220904.exe\nインストール後pacman -Syu実行済), Spresense SDK, VisualStudio\nCode(1.71.2)をインストールし、Cのソースコード(普通のHelloWorld)をコンパイル、Spresenseに転送して実行できることは確認しています。 \nVSCの拡張で関係ありそうなもののバージョンはこんなところです。 \nSpresense VSCode IDE V1.3.200 \nC/C++ V1.12.4 \nC/C++ Extension Pack V1.3.0\n\n・起こったこと \n続いて[実行とデバッグ]に入り、[デバッグの開始]をしようとしたところ、以下のエラーダイアログが表示されてデバッガに入れませんでした。 \n[![エラーダイアログ](https://i.stack.imgur.com/J6iZs.png)](https://i.stack.imgur.com/J6iZs.png)\n\nまた、デバッグコンソールには以下が表示されました。\n\n```\n\n Cortex-Debug: VSCode debugger extension version 1.6.5 git(ed64786). Usage info: https://github.com/Marus/cortex-debug#usage\n Reading symbols from c:/msys64/opt/spresenseenv/usr/bin/arm-none-eabi-objdump.exe --syms -C -h -w C:/msys64/home/User/spProjMsys1/out/spProjMsys1.nuttx \n Reading symbols from c:/msys64/opt/spresenseenv/usr/bin/arm-none-eabi-nm.exe --defined-only -S -l -C -p C:/msys64/home/User/spProjMsys1/out/spProjMsys1.nuttx \n Launching GDB: \"c:\\\\msys64\\\\opt\\\\spresenseenv\\\\usr\\\\bin\\\\arm-none-eabi-gdb.exe\" -q --interpreter=mi2 -ix .vscode/.gdbinit \n IMPORTANT: Set \"showDevDebugOutput\": \"raw\" in \"launch.json\" to see verbose GDB transactions here. Very helpful to debug issues or report problems \n Launching gdb-server: \"c:\\\\msys64\\\\opt\\\\spresenseenv\\\\usr\\\\bin\\\\openocd\" -c \"gdb_port 50000\" -c \"tcl_port 50001\" -c \"telnet_port 50002\" -s \"C:\\\\msys64\\\\home\\\\User\\\\spresense\\\\sdk\\\\tools\" -f \"c:/Users/User/.vscode/extensions/marus25.cortex-debug-1.6.5/support/openocd-helpers.tcl\" -f interface/cmsis-dap.cfg -f cxd5602.cfg \n Please check TERMINAL tab (gdb-server) for output from c:\\msys64\\opt\\spresenseenv\\usr\\bin\\openocd \n Finished reading symbols from objdump: Time: 141 ms \n c:\\msys64\\opt\\spresenseenv\\usr\\bin\\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory. \n ERROR: GDB major version should be >= 9, yours is 8 \n GDB could not start as expected. Bad installation or version mismatch. See if you can start gdb from a shell prompt and check its version (Must be >= 9)\n \n```\n\nこのとき、\n\n```\n\n arm-none-eabi-gdb -v\n GNU gdb (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 8.3.0.20190709-git\n \n```\n\nでした。\n\n・試したこと \nここで、[ARMツールチェーンの新しい版(Zip)](https://developer.arm.com/-/media/Files/downloads/gnu/12.2.mpacbti-\nbet1/binrel/arm-gnu-toolchain-12.2.mpacbti-bet1-mingw-w64-i686-arm-none-\neabi.zip)をダウンロード、解凍し、/opt/spresenseenv/usr/binのarm-none-eabi-\ngdb.exeをリネームして起動を止めてから新版のarm-none-eabi-gdb.exeからシンボリックリンクを張りました。この段階で、\n\n```\n\n $ arm-none-eabi-gdb --version\n GNU gdb (Arm GNU Toolchain 12.2.MPACBTI-Bet1 (Build arm-12-mpacbti.16)) 13.0.50.20220406-git\n \n```\n\nとなっています。 \nこの状態から[デバッグの開始]を試みたところ、とりあえずソースレベルデバッグができました(ステップ実行しか試していません)。\n\n・ちょっとだけ調査 \n同様の症例がないかと'vscode gdb major\nversion'でググるとNordicでも[こんなの(2022/8)](https://devzone.nordicsemi.com/f/nordic-\nq-a/91447/can-t-debug-ncs1-9-1-because-gdb-major-version-should-\nbe-9)とか[こんなの(2022/9)](https://devzone.nordicsemi.com/f/nordic-q-a/92010/gdb-\nand-vscode-windows-not-working-after-gdb-version-8-forced-upgrade-to-\nversion-9)も引っかかるので、VSCode本体かあるいは拡張のバージョンが上がってGDBバージョンの要求が厳しくなったということかと考えていますが...\n\nということで、 \n・公式サポートへの調査お願いと、 \n・とりあえずの対応として先のシンボリックリンクって有りなの? あるいは他の手段は? というあたりをご存じの方がいらっしゃれば伺いたく思います。\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T11:19:01.300", "favorite_count": 0, "id": "91373", "last_activity_date": "2023-04-19T00:45:48.800", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43952", "post_type": "question", "score": 1, "tags": [ "spresense", "vscode", "debugging" ], "title": "Spresense SDK(IDE)でデバッグを行おうとするとGDBがversionエラーになる", "view_count": 465 }
[ { "body": "こんにちは。 \n私も同様のエラーが発生してしまったので、Cortex-Debugのバージョンを下げて対応しています。 \nCortex-Debugのバージョンを1.4.4にするとデバッグできるようです。\n\n公式なコンパイラのバージョン更新までは thkana さんのような方法か、Cortex-Debugのバージョンを下げるかの方法をとる必要がありそうですね。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-30T03:28:58.363", "id": "91382", "last_activity_date": "2022-09-30T03:28:58.363", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32034", "parent_id": "91373", "post_type": "answer", "score": 0 }, { "body": "こんにちは。 \n最近公式のSpresenseSDKとSpresenseVSCodeIDEが更新され、GDB versionエラーが発生しなくなったので報告します。 \nSpresenseSDK\nv3.0.0とSpresenseVSCodeIDEのバージョン「v1.4.100」が、3月13日にリリースされたようで、そのバージョンのinstall-\ntools.shを使って下記リリースノートの手順でツールチェーンを更新すると \nGCCのクロスコンパイラのバージョンが10.3.1に更新されるようです。 \n[v3.0.0リリースノート](https://github.com/sonydevworld/spresense/releases/tag/v3.0.0) \nまた、SDKとIDE共にそのバージョンにアップデートするとGDBのバージョンエラーが起きなくなりました。 \nthkana さんもアップデートすると問題解決すると思います。\n\nご参考になれば幸いです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2023-04-19T00:45:48.800", "id": "94569", "last_activity_date": "2023-04-19T00:45:48.800", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32034", "parent_id": "91373", "post_type": "answer", "score": 1 } ]
91373
91382
94569
{ "accepted_answer_id": "91375", "answer_count": 1, "body": "ポインタの配列について学習していたところ、よくわからない結果となりました。 \nどなたかご教示いただけますと幸いです。\n\nポインタの配列の学習のため、以下コードを作成していました。\n\n```\n\n #include <stdio.h>\n static char *symbol0[] = { \"I\", \"W\", \"E\" } ;\n \n int main ( void )\n {\n char *symbol1[3] ;\n \n symbol1[0] = \"I\" ;\n symbol1[1] = \"W\" ;\n symbol1[2] = \"E\" ; \n \n printf( \" symbol0 ( %%p ) : %p\\n\", symbol0 ) ;\n printf( \" symbol1 ( %%p ) : %p\\n\", symbol1 ) ;\n printf( \" *symbol0 %%s : %s\\n\", *symbol0 ) ;\n printf( \" *symbol0[0] %%c : %c\\n\", *symbol0[0] ) ;\n printf( \" *symbol0 %%p : %p\\n\", *symbol0 ) ;\n printf( \" *symbol1 %%s : %s\\n\", *symbol1 ) ;\n printf( \" *symbol1[0] %%c : %c\\n\", *symbol1[0] ) ;\n printf( \" *symbol1 %%p : %p\\n\", *symbol1 ) ;\n \n return 0 ;\n }\n \n```\n\ngcc でコンパイル後にプログラムを実行したところ、以下のような出力となりました。\n\n```\n\n 出力例\n symbol0 ( %p ) : 0x55c47cc02010\n symbol1 ( %p ) : 0x7ffd368c6780\n *symbol0 %s : I\n *symbol0[0] %c : I\n *symbol0 %p : 0x55c47ca00b28\n *symbol1 %s : I\n *symbol1[0] %c : I\n *symbol1 %p : 0x55c47ca00b28\n \n```\n\n出力された結果について、私の疑問は全部で3つです。\n\n#### 1つ目\n\n`printf( \" *symbol0 %%p : %p\\n\", *symbol0 )` と `printf( \" *symbol1 %%p :\n%p\\n\", *symbol1 )` が同じ値を出力するのはなぜか?\n\n`symbol0[0]` と `symbol1[1]` には同じ文字列である \"I\"\nが格納されているため、格納されている値をポインタとして出力したためかと考えました。 \nしかし、別プログラムを実行したのちに再度このプログラムを実行すると、前度出力時の結果と再度出力時の結果に差異がありました。 \nそのため、この出力はポインタ値を返していると思ったのですが、仮にポインタ値を返していると考えた場合、2つのポインタが同じ値を返すのはおかしい、と判断しています。 \nなぜ同じ値が出力されるのか、ご教示ください。\n\n#### 2つ目\n\n`printf( \" *symbol0 %%p : %p\\n\", *symbol0 )` と `printf( \" *symbol1 %%p :\n%p\\n\", *symbol1 )` で出力される値は、何を意味しているのか?\n\nここで出力されている値は何でしょうか?(ポインタ値でしょうか?変数の値でしょうか?)\n\n#### 3つ目\n\n`printf(\"%p\",*symbol0) , printf(\"%p\", *symbol1)` は、そもそも出力が期待できる関数か?\n\n`symbol0`, `symbol1`\nともにポインタの配列として定義しているため、コンパイルでエラーが出ず、実行後になんらかの値が出力されることは個人的には期待していた結果でした。 \nただし、`*symbol0` と `*symbol1` で異なる値が出力されることを期待していたため、同じ値が出力されたのは期待した結果とはことなりました。 \nそのため、本来はコンパイル時にエラーになるはずの内容が、なんらかの理由によりコンパイルを通ってしまった可能性もあるのかな、と考えています。 \n2つの printf 関数は本来出力が期待できる関数であるのか、ご教示ください。\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T12:11:32.373", "favorite_count": 0, "id": "91374", "last_activity_date": "2022-09-30T02:57:28.177", "last_edit_date": "2022-09-30T02:57:28.177", "last_editor_user_id": "3060", "owner_user_id": "54619", "post_type": "question", "score": 1, "tags": [ "c", "ポインタ" ], "title": "printf( \"%p\", *ポインタの配列) で出力される結果は何を意味するのか", "view_count": 212 }
[ { "body": "① 文字列リテラルについては同じ内容のものを統合するような最適化が言語仕様上は許されています。\nどのように配置されるかは処理系に任されており、統合されることもされないこともあります。 \n② ポインタです。 `char *symbol1[3];` という宣言は `char*` がみっつという意味であり、配列の要素はポインタです。 \n③ 問題ありません。 仕様通りの結果です。\n\nポインタと配列まわりの事情に関しては\n\n * 配列の型は配列型\n * 式中に配列型が現れた場合には配列の先頭要素を指すポインタに暗黙に型変換される\n * ただし `sizeof` や単項 `&` のオペランドは暗黙に型変換されない\n\nというルールで勝手に型変換されるのがややこしさの根源だと考えられています。\n\nつまり、たとえば質問中にあるような `\"I\"` という文字列リテラルの型は `char[2]` (ヌル終端を含むので文字数よりひとつ多い)\nですが、この文字列はプログラムの最初から最後まで存在するどこかの領域にあって、暗黙の型変換ルールによって式の値としては `char*` 型が返されるのです。\n\n`*symbol0` という式の場合、まず `symbol0` の型は `char*[3]` ですが上述の型変換ルールによって `char**` となり、\n`*` 演算子を適用することで `char*` になります。 `*symbol0` の型は `char*` です。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T12:24:52.180", "id": "91375", "last_activity_date": "2022-09-29T13:11:45.460", "last_edit_date": "2022-09-29T13:11:45.460", "last_editor_user_id": "3364", "owner_user_id": "3364", "parent_id": "91374", "post_type": "answer", "score": 1 } ]
91374
91375
91375
{ "accepted_answer_id": null, "answer_count": 1, "body": "Spresense SDK チュートリアルの [10\\. Graphics\nチュートリアル](https://developer.sony.com/develop/spresense/docs/sdk_tutorials_ja.html#_graphics_%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB)\nに関して質問させてください。\n\n以下の記述がありますが、\"Arduino UNO LCD Connector board\" は具体的にどのボードになりますでしょうか。\n\n> このサンプルを動作させるには、以下のハードウェアを使う前提となっています。\n>\n> * Spresense Main Board\n> * Spresense Extension Board\n> * Arduino UNO LCD Connector board\n> * ILI9341 2.2inch LCD\n>\n\nコントローラー IC は ILI9341\nとあり、このチップはCMD/DATAのコントロールが必要だと思いますが、コンフィグメニューでその制御を有効にすると多分コンパイルが通りません。 \ncxd56_spi3cmddata、cxd56_spi4cmddata、cxd56_spi5cmddata の関数が無いエラー \n(エラーとなっているのは自分だけ?)\n\nArduino UNO LCD Connector boardというのを使えば C/Dのコントロールが必要なくなるのでしょうか。 \nすみませんがよろしくお願いします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T13:26:29.033", "favorite_count": 0, "id": "91376", "last_activity_date": "2022-09-30T04:00:45.747", "last_edit_date": "2022-09-30T01:32:19.177", "last_editor_user_id": "3060", "owner_user_id": "53145", "post_type": "question", "score": 1, "tags": [ "spresense" ], "title": "Spresense SDK でTFT LCDを動かす場合", "view_count": 159 }
[ { "body": "”Arduino UNO LCD Connector\nboard”が何を指しているのかわかりませんが、私はそのような特定?の基板は使用しないで動かせています。SDKは最新のv2.6.0でも確認してみました。\n\nnxdemoを例にしますが、以下のように標準のdefconfig(examples/nxdemo)を使用して、コンパイルエラーなく実行できています。\n\n```\n\n $tools/config.py examples/nxdemo \n $make\n \n```\n\nLCDとの結線情報は以下のページが参考になると思います。 \n[https://developer.sony.com/develop/spresense/docs/arduino_tutorials_ja.html#_lcd_と拡張ボードの接続](https://developer.sony.com/develop/spresense/docs/arduino_tutorials_ja.html#_lcd_%E3%81%A8%E6%8B%A1%E5%BC%B5%E3%83%9C%E3%83%BC%E3%83%89%E3%81%AE%E6%8E%A5%E7%B6%9A)\n\nただ現在、私はLCD(ILI9341\n2.2インチ)との接続に以下の基板(※1)を利用しています。当初はジャンパーワイヤーを利用していたので、それに比べたら簡単接続可能で重宝します。 \n[https://kunutest.jimdofree.com/lcdsp001基板/](https://kunutest.jimdofree.com/lcdsp001%E5%9F%BA%E6%9D%BF/)\n\n※1:LCDが2.2インチより大きいものだとそのままは使えないので注意", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-30T04:00:45.747", "id": "91383", "last_activity_date": "2022-09-30T04:00:45.747", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49022", "parent_id": "91376", "post_type": "answer", "score": 0 } ]
91376
null
91383
{ "accepted_answer_id": null, "answer_count": 0, "body": "## 前提・バージョン等\n\nexpress.jsとpassport-twitterを使用してwebサイトを作成しています。\n\nバージョンは \nnode.js:`14.19.1` \npassport-twitter:`1.0.4` \nexpress.js:`4.16.4`\n\n## やりたいこと\n\n現在`/auth/twitter/callback`がcallbackURLになっているのですが`/followers`などの別のURLに変えても`/auth/twitter/callback`が適用されてしまいます。 \nどうすればいいのかご教授願います。\n\n## 対象コード\n\n```\n\n //follower.js\n const express = require('express');\n const router = express.Router();\n const passport = require('passport');\n const TwitterStrategy = require('passport-twitter');\n const { TwitterApi } = require('twitter-api-v2');\n \n passport.serializeUser(function(user, done) {\n done(null, user);\n });\n \n passport.deserializeUser(function(user, done) {\n done(null, user);\n });\n \n // passport-twitterの初期化\n passport.use(new TwitterStrategy({\n consumerKey: require('../config.json').consumer_key,//TwitterのconsumerKey\n consumerSecret: require('../config.json').consumer_secret,//TwitterのconsumerSecret\n callbackURL: require('../config.json').BASE_URL+'/followers'//認証成功時の戻り先URL\n },\n async function(token, tokenSecret, profile, done) {\n // 認証が完了したtwitterIdを検証する\n // 例えばtwitteridがDBの中に存在するかということを確認する\n // 検証結果によってdoneの書き方を以下のように指定する\n // 検証成功 : return done(null,profile);\n // 検証失敗 : return done(null,false);\n // 例外発生 : return done(null);\n return done(null,profile);\n }\n ));\n \n router.get('/',\n passport.authenticate('twitter'));\n \n //認証した後のリダイレクト先を/followersに設定する\n router.get('/', passport.authenticate('twitter', { failureRedirect: '/' }),\n async function(req, res) {\n \n const api = new TwitterApi({\n appKey: require('../config.json').consumer_key,\n appSecret: require('../config.json').consumer_secret,\n accessToken: ,\n accessSecret: ,\n });\n const follower = await api.v2.followers(req.user.userid,{\"user.fields\":'name,profile_image_url,description'});\n console.log(follower);\n res.render('followers',{followers:follower});\n });\n \n \n module.exports = router;\n \n```\n\n```\n\n //auth.js\n const express = require('express');\n const router = express.Router();\n const passport = require('passport');\n const TwitterStrategy = require('passport-twitter');\n const { TwitterApi } = require('twitter-api-v2');\n \n passport.serializeUser(function(user, done) {\n done(null, user);\n });\n \n passport.deserializeUser(function(user, done) {\n done(null, user);\n });\n \n // passport-twitterの初期化\n passport.use(new TwitterStrategy({\n consumerKey: require('../config.json').consumer_key,//TwitterのconsumerKey\n consumerSecret: require('../config.json').consumer_secret,//TwitterのconsumerSecret\n callbackURL: require('../config.json').BASE_URL+'/auth/twitter/callback'//認証成功時の戻り先URL\n },\n async function(token, tokenSecret, profile, done) {\n // 認証が完了したtwitterIdを検証する\n // 例えばtwitteridがDBの中に存在するかということを確認する\n // 検証結果によってdoneの書き方を以下のように指定する\n // 検証成功 : return done(null,profile);\n // 検証失敗 : return done(null,false);\n // 例外発生 : return done(null);\n \n return done(null,profile);\n }\n ));\n \n //認証正常時の戻り先URLの設定をする\n router.get('/twitter/callback',\n passport.authenticate('twitter', {\n failureRedirect: '/' }),//認証失敗時のリダイレクト先を書く\n function(req, res) {\n // ここでは認証成功時のルーティング設定を書く\n // ちなみにreq.userでログインユーザの情報が取れる\n // 例) req.user.useridでユーザIDがとれます\n res.redirect('/');\n });\n \n \n module.exports = router;\n \n```\n\n```\n\n //index.js\n require('dotenv').config();\n \n const createError = require('http-errors');\n const express = require('express');\n const path = require('path');\n const logger = require('morgan');\n const passport = require('passport');\n const session = require('express-session');\n const cookieParser = require('cookie-parser');\n const TwitterStrategy = require('passport-twitter');\n const { config } = require('dotenv');\n \n \n const indexRouter = require('./routes/home');\n const followersRouter = require('./routes/followers');\n const followsRouter = require('./routes/follow');\n const loginRouter = require('./routes/login')\n const authRouter = require('./routes/auth');\n \n const app = express();\n const SQLiteStore = require('connect-sqlite3')(session);\n \n \n app.locals.pluralize = require('pluralize');\n \n // view engine setup\n app.set('views', path.join(__dirname, 'views'));\n app.set('view engine', 'ejs');\n \n \n app.use(logger('dev'));\n app.use(express.json());\n app.use(express.urlencoded({ extended: false }));\n app.use(cookieParser());\n app.use(express.static(path.join(__dirname, 'public')));\n app.use(session({\n secret: 'Xalyfi',\n resave: false,\n saveUninitialized: false,\n store: new SQLiteStore({ db: 'sessions.db', dir: './var/db' })\n }));\n //npmモジュールのロード\n //Expressでpassportが使えるようにする\n app.use(passport.session());\n \n \n app.use('/', indexRouter);\n app.use('/followers', followersRouter);\n app.use('/follows', followsRouter);\n app.use('/login',loginRouter)\n app.use('/auth', authRouter);\n \n // catch 404 and forward to error handler\n app.use(function(req, res, next) {\n next(createError(404));\n });\n \n // error handler\n app.use(function(err, req, res, next) {\n // set locals, only providing error in development\n res.locals.message = err.message;\n res.locals.error = req.app.get('env') === 'development' ? err : {};\n \n // render the error page\n res.status(err.status || 500);\n res.render('error');\n });\n \n \n app.listen(80, () => {\n console.log('Server is running on port 80');\n });\n \n```\n\n## 補足\n\nコードブロックだと見にくいと思いますので[リポジトリ](https://github.com/Xalyfi/twitter-\nbot)のURLを載せておきます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T13:31:12.047", "favorite_count": 0, "id": "91377", "last_activity_date": "2022-09-29T13:31:12.047", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "48118", "post_type": "question", "score": 0, "tags": [ "node.js", "twitter", "express.js" ], "title": "passport-twitterのcallbackURLが変更できないです", "view_count": 21 }
[]
91377
null
null
{ "accepted_answer_id": "91380", "answer_count": 1, "body": "[次を検索] コマンドでは、該当の文字列がそれより下にない場合、 \n「現在位置より下には~は見つかりませんでした」 \nと表示されて、その位置で終了します。 \nこれをファイルの先頭に戻って続行させる方法はありますでしょうか。\n\n秀丸では私は次の「一周する」のオプションにチェックを入れていて、これをデフォルトにしています。\n\n<http://htom.in.coocan.jp/hmfaq8/2_find.html> \n「一周する」チェックボックス 下検索の場合、ファイルの一番下まで検索し終わった場合、ファイルの先頭に戻って検索を続行します。上検索の場合は逆になります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-29T22:56:11.473", "favorite_count": 0, "id": "91379", "last_activity_date": "2022-09-30T00:22:06.297", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43123", "post_type": "question", "score": 0, "tags": [ "emeditor" ], "title": "[次を検索]でファイルの冒頭に戻るようにしたい", "view_count": 82 }
[ { "body": "[検索] ダイアログ ボックスで、[折り返しあり] に✔してください。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-30T00:22:06.297", "id": "91380", "last_activity_date": "2022-09-30T00:22:06.297", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "40017", "parent_id": "91379", "post_type": "answer", "score": 0 } ]
91379
91380
91380
{ "accepted_answer_id": null, "answer_count": 0, "body": "ある疾患の届出数の推移(2010~2021年)を患者の年齢階層別に100%積み上げグラフで作成したいと思っています。\n\n以下のコードでグラフを作成したのですが、X軸の年が2010から4年間隔で2022年まで表示されてしまいます(2010、2013、・・・2022)。この2022を消すか、最後のみ2021を表示させるためにはどうしたらよいでしょうか。\n\nよろしくお願いします。\n\n```\n\n Fig3dat<-(table(datnew10_21_activeTB$age_group5, datnew10_21_activeTB$reg_y))\n \n Fig3datmelt<-melt(Fig3dat, id.vars = \"Year\", variable.name = \"Age_group\", value.name = \"Case\")\n \n colnames(Fig3datmelt)<-c( \"Age_group\", \"Year\",\"Case\")\n \n ce<-ddply(Fig3datmelt, \"Year\", transform, percent_case=Case/sum(Case)*100)\n \n Fig3<-ggplot(ce, aes(x=Year, y=percent_case, fill=Age_group))+geom_bar(stat=\"identity\")+\n theme_classic()\n \n Fig3<-Fig3+ggtitle(\"Figure 3. Newly notified cases by age groups, 2010-2021\")+xlab(\"Year\")+ ylab(\"Number of cases\")\n +scale_fill_discrete(name=\"Age groups\")\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-30T02:24:12.893", "favorite_count": 0, "id": "91381", "last_activity_date": "2022-09-30T02:38:41.047", "last_edit_date": "2022-09-30T02:38:41.047", "last_editor_user_id": "3060", "owner_user_id": "54627", "post_type": "question", "score": 2, "tags": [ "r" ], "title": "R ggplot2で100%積み上げグラフ", "view_count": 76 }
[]
91381
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "こちらのサイトを参考に、16kHzサンプリングでのPCMキャプチャをしようと試みています。 \n<https://developer.sony.com/develop/spresense/docs/sdk_developer_guide_ja.html#_audio_recorder_functions>\n\nそのために、以下の設定を行いました。\n\n```\n\n \n //マイク設定    \n AudioCommand command;\n command.header.packet_length = LENGTH_INIT_MICFRONTEND;\n command.header.command_code = AUDCMD_INIT_MICFRONTEND;\n command.header.sub_code = 0x00;\n command.init_micfrontend_param.ch_num = 4;\n command.init_micfrontend_param.bit_length = 16;\n command.init_micfrontend_param.samples = 768;\n command.init_micfrontend_param.out_fs = 16000;\n command.init_micfrontend_param.preproc_type = AsMicFrontendPreProcSrc;\n snprintf(command.init_micfrontend_param.preprocess_dsp_path, AS_PREPROCESS_FILE_PATH_LEN, \"%s\", \"/mnt/sd0/BIN/SRC\");\n \n //録音設定    \n AudioCommand command;\n command.header.packet_length = LENGTH_INIT_RECORDER;\n command.header.command_code = AUDCMD_INITREC;\n command.header.sub_code = 0x00;\n \n command.recorder.init_param.sampling_rate = 16000;\n command.recorder.init_param.channel_number = 4;\n command.recorder.init_param.bit_length = 16;\n command.recorder.init_param.codec_type = AS_CODECTYPE_LPCM;\n command.recorder.init_param.computational_complexity = AS_INITREC_COMPLEXITY_0;\n \n snprintf(command.recorder.init_param.dsp_path, AS_AUDIO_DSP_PATH_LEN, \"%s\", \"/mnt/sd0/BIN\");\n \n```\n\nですが、取り込めるデータが期待した量の1/3ぐらいしかありません。\n\nどこか他にケアすべき箇所がありましたら、恐れ入りますがご指摘をお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-30T08:23:28.640", "favorite_count": 0, "id": "91384", "last_activity_date": "2022-10-05T04:01:31.983", "last_edit_date": "2022-10-05T03:52:41.870", "last_editor_user_id": "3060", "owner_user_id": "54630", "post_type": "question", "score": 0, "tags": [ "spresense", "audio" ], "title": "Spresense SDK における 16kHzサンプリングでのデータ取り込みについて教えてください", "view_count": 174 }
[ { "body": "取得したデータは所望のデータではないのでしょうか? \nその際、どのようにおかしいのか?を記述すると何かヒントを得られやすいです。\n\n・チャンネルのデータが正しくない。(チャンネルデータが混ざっているなど) \n・所望の音より早送りのような音になっている。\n\nなど、データの状況で起こっていることが想像できます。\n\nちなみに、1/3となると、Spresenseは48kHzでのキャプチャを1/3して16kHzにするので、そのあたりの認識のずれがあるのかもしれませんね。\n\nご参考になれば。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T01:48:17.260", "id": "91409", "last_activity_date": "2022-10-03T01:48:17.260", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32281", "parent_id": "91384", "post_type": "answer", "score": 0 }, { "body": "自己解決しました。\nどうやら、マイク設定と録音設定の両方で16kHz指定すると、今回のような動作になるようですね。音声ブロックのフローを見てまさかと思いましたが、どちらか片方だけにすると期待通りのデータが得られました。\nSONYの中の人からの回答が得られなくて残念でしたが。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-05T04:01:31.983", "id": "91456", "last_activity_date": "2022-10-05T04:01:31.983", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54630", "parent_id": "91384", "post_type": "answer", "score": 2 } ]
91384
null
91456
{ "accepted_answer_id": null, "answer_count": 0, "body": "よろしくお願いします。\n\nブラウザ(Firefox/Chromeなど)の拡張機能かproxyサーバで、 \nブラウザが事前に正規表現などで指定したアドレスにアクセスすると \nそのリソースを自動的にファイルとして保存する方法を探しています。\n\n```\n\n 条件: https://example.net/address/to/(image-\\d+.jpg)\n 保存: /path/to/file/\\1\n \n```\n\nと指定しておくと\n\n```\n\n https://example.net/address/to/image-001.jpg\n \n```\n\nなどにアクセスすると`image-001.jpg`が自動的に保存されるイメージです。\n\nmitmproxyと云うものを見つけて手動で保存はできそうなのですが自動化できると助かります。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-30T11:18:40.790", "favorite_count": 0, "id": "91385", "last_activity_date": "2022-09-30T11:18:40.790", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54634", "post_type": "question", "score": 2, "tags": [ "google-chrome", "http", "firefox", "https", "proxy" ], "title": "ブラウザのリクエストを監視して特定のリソースを自動保存したい", "view_count": 49 }
[]
91385
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "参考サイト \n<https://gurishunin.com/line_gas_beginner/>\n\n初心者です。 \n上記のサイト様のコードをコピペし、アクセストークンのところにチャネルアクセストークン(長期)を入れました。 \nwebnock設定もしてあり、URLも張りました(検証を押すと成功と表示されます)。 \nしかし、試しに友達登録してからメッセージを送ってもオウム返ししてくれません。 \n何が原因なのか教えていただけないでしょうか。\n\n[上記サイト様のソースコード]\n\n```\n\n // LINE developersのメッセージ送受信設定に記載のアクセストークン\n const ACCESS_TOKEN = '長期アクセストークン';\n function doPost(e) {\n // WebHookで受信した応答用Token\n var replyToken = JSON.parse(e.postData.contents).events[0].replyToken;\n // ユーザーのメッセージを取得\n var userMessage = JSON.parse(e.postData.contents).events[0].message.text;\n // 応答メッセージ用のAPI URL\n var url = 'https://api.line.me/v2/bot/message/reply';\n UrlFetchApp.fetch(url, {\n 'headers': {\n 'Content-Type': 'application/json; charset=UTF-8',\n 'Authorization': 'Bearer ' + ACCESS_TOKEN,\n },\n 'method': 'post',\n 'payload': JSON.stringify({\n 'replyToken': replyToken,\n 'messages': [{\n 'type': 'text',\n 'text': userMessage,\n }],\n }),\n });\n return ContentService.createTextOutput(JSON.stringify({'content': 'post ok'})).setMimeType(ContentService.MimeType.JSON);\n }\n \n```\n\n[設定] \nwebhook→on \n応答メッセージ→無効 \nあいさつメッセージ→有効 \nwebhookの利用→on", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-30T11:31:51.747", "favorite_count": 0, "id": "91386", "last_activity_date": "2022-10-01T13:03:30.493", "last_edit_date": "2022-09-30T12:39:02.827", "last_editor_user_id": "46953", "owner_user_id": "46953", "post_type": "question", "score": 0, "tags": [ "google-apps-script", "line", "bot" ], "title": "Lineでオウム返しBotを作りたいのに返ってこない", "view_count": 104 }
[ { "body": "無事にログを確認したところ、エラーが出ていることが判明しました!\n\nGCPを使用したログの確認方法 \n<https://qiita.com/sa9ra4ma/items/1acb459fcc713728c03e>\n\n新しく質問させていただきます! \nありがとうございました!", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-01T13:03:30.493", "id": "91393", "last_activity_date": "2022-10-01T13:03:30.493", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "46953", "parent_id": "91386", "post_type": "answer", "score": 0 } ]
91386
null
91393
{ "accepted_answer_id": null, "answer_count": 0, "body": "サイトにvimeoをiframeで埋め込み \n[player.js](https://github.com/vimeo/player.js)を利用して\n\n 1. 再生(イベント発火⇨視聴開始した現在時刻を保存)\n 2. 一時停止または動画終了(イベント発火⇨視聴終了した現在時刻を保存)」\n 3. [1]と[2]の差分をDBに保存\n\nで視聴時間を登録しているのですが、なぜか同じデータが複数作成されるケースがあります。 \nブラウザの問題の可能性も考え \nPC:Chrome・Safari \niOS(15.7):Chrome・Safari \nで色々操作してみましたが再現されません。 \nどなたか原因わかる方いないでしょうか。 \nしばらく調査しているのですが八方塞がり状態なので \nお力添えの程よろしくお願いします。\n\n### HTML\n\n```\n\n <iframe src=\"vimeoの動画url\" id=\"player\" frameborder=\"0\"></iframe>\n \n```\n\n### Javascript\n\n```\n\n <script src=\"https://unpkg.com/[email protected]/dayjs.min.js\"></script>\n <script src=\"https://unpkg.com/[email protected]/locale/ja.js\"></script>\n <script>dayjs.locale('ja')</script>\n <script src=\"https://player.vimeo.com/api/player.js\"></script>\n <script>\n $(function(){\n const player = new Vimeo.Player($(\"#player\"));\n let startOfTime = dayjs();\n \n player.on('play', function() {\n startOfTime = dayjs();\n });\n \n player.on('pause', function() {\n const watchedTime = diffTime(dayjs());\n save(watchedTime);\n });\n \n function diffTime(endOfTime) {\n const diff = endOfTime.diff(startOfTime);\n const second = Math.round(diff / 1000);\n return formatted(second);\n }\n \n function formatted(time) {\n const hour = Math.floor(time / 3600);\n const minute = Math.floor((time - hour * 3600) / 60);\n const second = Math.floor(time - hour * 3600 - minute * 60);\n \n // 時:分:秒形式\n let result = \"\";\n result += hour < 10 ? \"0\" + hour : hour;\n result += \":\";\n result += minute < 10 ? \"0\" + minute : minute;\n result += \":\";\n result += second < 10 ? \"0\" + second : second;\n \n return result;\n }\n \n function save(watchedTime)\n {\n startOfTime = dayjs();\n \n $.ajax({\n type: 'POST',\n url: '/watchedTime/create',\n data: {\n 'watchedTime': watchedTime,\n },\n headers: {\n 'X-CSRF-TOKEN': $('meta[name=\"csrf-token\"]').attr('content')\n }\n })\n }\n })\n </script>\n \n```\n\n### PHP(Controller(一部抜粋))\n\n```\n\n $table = new WatchedLog();\n $table->time = $request->watchedTime;\n $table->created_at = Carbon::now();\n $table->save();\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-09-30T12:39:50.213", "favorite_count": 0, "id": "91387", "last_activity_date": "2022-10-01T16:11:14.057", "last_edit_date": "2022-10-01T16:11:14.057", "last_editor_user_id": "53436", "owner_user_id": "53436", "post_type": "question", "score": 0, "tags": [ "javascript", "jquery" ], "title": "vimeo+player.jsでサイトに埋め込みした動画の視聴時間を計測したいが同じデータがいくつも作成されてしまう", "view_count": 298 }
[]
91387
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "JavaScriptのオブジェクトのソートで反転させることができずにおります。詳しい方いましたらご教授お願いします。 \n以下のようなオブジェクトが返ってくる関数がありまして、これらを反転させて降順にしたいと思っております。\n\n新しく追加されたデータは下に追加されてゆく感じになっているのですが、実際にsortをしようと思うと日付などのデータがなく新しい順にならないのと、reverse()などの関数は配列に対してのみ有効らしくオブジェクトには適用できませんでした。 \nこちらどのようにreverseすることができるでしょうか?\n\n**対象のオブジェクト:**\n\n```\n\n {\n \"0bf10e9f392d20bc5296df07c0087af8\": {\n \"discount\": \"0\",\n \"id\": \"xxxxx\",\n \"name\": \"nnnnn\",\n \"options\": \"\",\n \"price\": \"100\",\n \"qty\": \"2\",\n \"rowId\": \"0bf10e9f392d20bc5296df07c0087af8\",\n \"subtotal\": \"100\",\n \"tax\": \"0\"\n },\n \"0bf10e9f392d20b45464566df07c0087\": {\n \"discount\": \"0\",\n \"id\": \"xxxxx\",\n \"name\": \"nnnnn\",\n \"options\": \"\",\n \"price\": \"100\",\n \"qty\": \"2\",\n \"rowId\": \"0bf10e9f392d20b45464566df07c0087\",\n \"subtotal\": \"100\",\n \"tax\": \"0\"\n },\n ....\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-01T00:44:35.413", "favorite_count": 0, "id": "91388", "last_activity_date": "2022-10-01T11:22:01.243", "last_edit_date": "2022-10-01T11:22:01.243", "last_editor_user_id": "3060", "owner_user_id": "34391", "post_type": "question", "score": 1, "tags": [ "javascript", "array" ], "title": "JavaScriptのオブジェクトを逆順にソートしたい", "view_count": 283 }
[ { "body": "旧来、オブジェクトに順序はありませんでした。最近になって仕様に追加されていますが、あまり使い易い性質のものではありません。基本的にはオブジェクトの順序を利用するコードは書かない方が良いと思います。\n\n* * *\n\nそれでも行なう場合。\n\nまず、[`Object.keys()`](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)\nなどでキー(プロパティ名)の配列を取得し、それを反転させます。その結果の順に、オブジェクトに挿入します。\n\n**注: 数値として解釈できるプロパティ名は挿入順になりませんので、どうしようも無いです。**\n\n```\n\n for (const key of Object.keys(origObj).reverse()) {\n newObj[key] = origObj[key]\n }\n \n```\n\n対象のオブジェクトを直接変更する場合は、一度 `delete` で消した後に挿入し直します。ただし、IE では[`delete`\nした際の挙動が他と違う](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/delete#%E3%83%96%E3%83%A9%E3%82%A6%E3%82%B6%E3%83%BC%E3%81%AE%E4%BA%92%E6%8F%9B%E6%80%A7%E3%81%AE%E6%B3%A8%E6%84%8F)ようなので、これは出来ないはずです。\n\n```\n\n for (const key of Object.keys(obj).reverse()) {\n const val = obj[key]\n delete obj[key]\n obj[key] = val\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-01T02:51:44.030", "id": "91389", "last_activity_date": "2022-10-01T04:24:24.533", "last_edit_date": "2022-10-01T04:24:24.533", "last_editor_user_id": "3054", "owner_user_id": "3054", "parent_id": "91388", "post_type": "answer", "score": 3 } ]
91388
null
91389
{ "accepted_answer_id": null, "answer_count": 0, "body": "シミュレーターでは動作を確認することができましたが、実機ですと「Unable to install XXX」となり、動作しません。 \nサードパーティのFireBaseの問題かと思うのですが、一向に解決の兆しが見えません。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/BmZZa.png)](https://i.stack.imgur.com/BmZZa.png)\n\n端末を変更し(iphoneSE(第二世代)→iphone11)、再度実行するも、「Unable to install XXX」となります。 \nFireBaseのSDKの問題かなと考えるのですが、何か少しでも考えられる事がありましたら、ご教授頂ければ幸いでございます。\n\n利用しているサービス及び端末は以下です。\n\nXcode:Version 14.0.1 \nmacOS12.3 \niphoneSE(第二世代) \nMacmini2020 \nFireBase\n\n### 試した事\n\n**1.Windowでデバイスの削除して再実行する。** \nWindow>DeVices>「自分のiphone名」を右クリック>ShowProvisioninng Profilesをクリック \n→「−」ボタンを押下して自分の端末を削除してXcodeの再起動。\n\n**2.「Appプロジェクト名 >Build Settings>Signing>Other CodeSigning flags」を修正**\n\nDebag及び、Releseの「Any SDK:--generate-entitlement-der」とする。\n\n**エラー内容**\n\n[![Other Code Signing\nFlags](https://i.stack.imgur.com/2tl8g.png)](https://i.stack.imgur.com/2tl8g.png)\n\n```\n\n Unable to install \"philosophy\"\n Domain: com.apple.dt.MobileDeviceErrorDomain\n Code: -402620375\n User Info: {\n DVTErrorCreationDateKey = \"2022-10-01 02:52:16 +0000\";\n IDERunOperationFailingWorker = IDEInstalliPhoneLauncher;\n }\n --\n The code signature version is no longer supported.\n Domain: com.apple.dt.MobileDeviceErrorDomain\n Code: -402620375\n User Info: {\n DVTRadarComponentKey = 487925;\n MobileDeviceErrorCode = \"(0xE8008029)\";\n \"com.apple.dtdevicekit.stacktrace\" = (\n 0 DTDeviceKitBase 0x00000001123282bc DTDKCreateNSErrorFromAMDErrorCode + 300\n 1 DTDeviceKitBase 0x000000011235c3c0 __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 136\n 2 DVTFoundation 0x00000001031ca53c DVTInvokeWithStrongOwnership + 76\n 3 DTDeviceKitBase 0x000000011235c144 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1196\n 4 IDEiOSSupportCore 0x000000010e4dbd10 __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.147 + 2328\n 5 DVTFoundation 0x00000001032d4824 __DVT_CALLING_CLIENT_BLOCK__ + 16\n 6 DVTFoundation 0x00000001032d5290 __DVTDispatchAsync_block_invoke + 152\n 7 libdispatch.dylib 0x000000019144a5f0 _dispatch_call_block_and_release + 32\n 8 libdispatch.dylib 0x000000019144c1b4 _dispatch_client_callout + 20\n 9 libdispatch.dylib 0x00000001914538a8 _dispatch_lane_serial_drain + 668\n 10 libdispatch.dylib 0x0000000191454404 _dispatch_lane_invoke + 392\n 11 libdispatch.dylib 0x000000019145ec98 _dispatch_workloop_worker_thread + 648\n 12 libsystem_pthread.dylib 0x000000019160c360 _pthread_wqthread + 288\n 13 libsystem_pthread.dylib 0x000000019160b080 start_wqthread + 8\n );\n }\n --\n \n Analytics Event: com.apple.dt.IDERunOperationWorkerFinished : {\n \"device_model\" = \"iPhone12,8\";\n \"device_osBuild\" = \"15.6.1 (19G82)\";\n \"device_platform\" = \"com.apple.platform.iphoneos\";\n \"launchSession_schemeCommand\" = Run;\n \"launchSession_state\" = 1;\n \"launchSession_targetArch\" = arm64;\n \"operation_duration_ms\" = 5515;\n \"operation_errorCode\" = \"-402620375\";\n \"operation_errorDomain\" = \"com.apple.dt.MobileDeviceErrorDomain\";\n \"operation_errorWorker\" = IDEInstalliPhoneLauncher;\n \"operation_name\" = IDEiPhoneRunOperationWorkerGroup;\n \"param_consoleMode\" = 0;\n \"param_debugger_attachToExtensions\" = 0;\n \"param_debugger_attachToXPC\" = 1;\n \"param_debugger_type\" = 5;\n \"param_destination_isProxy\" = 0;\n \"param_destination_platform\" = \"com.apple.platform.iphoneos\";\n \"param_diag_MainThreadChecker_stopOnIssue\" = 0;\n \"param_diag_MallocStackLogging_enableDuringAttach\" = 0;\n \"param_diag_MallocStackLogging_enableForXPC\" = 1;\n \"param_diag_allowLocationSimulation\" = 1;\n \"param_diag_checker_tpc_enable\" = 1;\n \"param_diag_gpu_frameCapture_enable\" = 0;\n \"param_diag_gpu_shaderValidation_enable\" = 0;\n \"param_diag_gpu_validation_enable\" = 0;\n \"param_diag_memoryGraphOnResourceException\" = 0;\n \"param_diag_queueDebugging_enable\" = 1;\n \"param_diag_runtimeProfile_generate\" = 0;\n \"param_diag_sanitizer_asan_enable\" = 0;\n \"param_diag_sanitizer_tsan_enable\" = 0;\n \"param_diag_sanitizer_tsan_stopOnIssue\" = 0;\n \"param_diag_sanitizer_ubsan_stopOnIssue\" = 0;\n \"param_diag_showNonLocalizedStrings\" = 0;\n \"param_diag_viewDebugging_enabled\" = 1;\n \"param_diag_viewDebugging_insertDylibOnLaunch\" = 1;\n \"param_install_style\" = 0;\n \"param_launcher_UID\" = 2;\n \"param_launcher_allowDeviceSensorReplayData\" = 0;\n \"param_launcher_kind\" = 0;\n \"param_launcher_style\" = 0;\n \"param_launcher_substyle\" = 0;\n \"param_runnable_appExtensionHostRunMode\" = 0;\n \"param_runnable_productType\" = \"com.apple.product-type.application\";\n \"param_runnable_type\" = 2;\n \"param_testing_launchedForTesting\" = 0;\n \"param_testing_suppressSimulatorApp\" = 0;\n \"param_testing_usingCLI\" = 0;\n \"sdk_canonicalName\" = \"iphoneos16.0\";\n \"sdk_osVersion\" = \"16.0\";\n \"sdk_variant\" = iphoneos;\n }\n --\n \n \n System Information\n \n macOS Version 12.6 (Build 21G115)\n Xcode 14.0.1 (21336) (Build 14A400)\n Timestamp: 2022-10-01T11:52:16+09:00\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-01T03:51:45.873", "favorite_count": 0, "id": "91390", "last_activity_date": "2022-10-01T04:02:10.487", "last_edit_date": "2022-10-01T04:02:10.487", "last_editor_user_id": "3060", "owner_user_id": "43365", "post_type": "question", "score": 0, "tags": [ "swift", "ios", "firebase" ], "title": "Unable to install XXX", "view_count": 96 }
[]
91390
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "### 知りたいこと\n\n作成したプログラムをある一つのフォルダで完結するようにまとめるにはどのようにしたら良いでしょうか?\n\n### 背景\n\n先日Pythonでスクレイピングを行うコードを作成しました。 \nこのプログラムをある特定の人にも使ってもらえるようにするにはどのようにしたら良いのかが気になりました。 \nちなみに、不特定多数の人に使ってもらう必要はなく、ある特定の1人に使ってもらうことを想定しております。 \nその際に以下の点が気になりました。\n\n * プログラムでライブラリを使っている際に、そのコードのみを渡してもライブラリをインストールしていないと使用できないため、その人の環境でライブラリをインストールしてもらう必要があるのではないか。\n\nライブラリも含めてプログラムが一つのフォルダで完結するようにすれば、そのフォルダを渡すだけで使ってもらえると思ったため質問させていただきました。 \n恐れ入りますがご教授いただけると幸いです。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-01T04:47:31.260", "favorite_count": 0, "id": "91391", "last_activity_date": "2022-10-03T05:35:38.793", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54640", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "プログラムをパッケージ化する方法", "view_count": 194 }
[ { "body": "アナコンダがインストールされている前提でなら自分が使用している方法をトレースすることができると思いますので以下に書き残します。 \n使えそうならやってみてください。\n\npyinstallerを使用してコマンドライン(プロンプト)から書き出す場合にファイルがとてつもなく大きくなる傾向があるのでPython仮想環境を用意して、そこでパッケージング処理を行い、exe化する流れになります。\n\n基本的にパッケージングするだけであれば、アナコンダプロンプトなどのコマンドプロンプト画面から\n\n```\n\n pyinstaller c:\\******\\コンパイルしたいファイル.pyのフルパス --onefile\n \n```\n\nでパッケージングできるはずです。このコマンドを入力してしばらくするとpyファイルのフォルダ階層内にdistなどのフォルダ名の構造が生成され、dist内にexeファイルが生成されるはずです。 \nこのexeは.pyファイルと同じ挙動をするので.pyファイル以外にフォルダ構成などが準備されている必要がある場合は.pyと同じ階層関係に設置してみてください。\n\nで、実行してみて(めちゃくちゃ起動が重いですが)同じ挙動をする場合は以下の手順で軽量なファイルを生成することを推奨します。\n\n同じくコマンドプロンプト画面で\n\n```\n\n cd ******* ←pyと同じディレクトリを入力するか、作業用フォルダを作ってそこを指定しつつ、pyファイルを複製して格納\n conda create -n minimam python=3.8 ←自分の使用しているバージョン数を指定\n y ←※1行目コマンド時、y/nを質問されたらyを入力してenter\n activate minimam\n pip install pyinstaller pypiwin32 ←仮想環境を作成する時にexeファイルをコンパイルするのに絶対に必要になるライブラリをとりあえずインストール\n \n```\n\nと1行ずつ入力するかまとめて入力してもらってもいいです。\n\n```\n\n pip install pillow opencv-python ←追加でexeファイルをコンパイルするのに必要なライブラリとして確定でわかっているライブラリがあれば突っ込む(ここで認識できていないライブラリがあってもとりあえずOK)\n pyinstaller .pyファイルのフルパス --onefile --exclude pandas ←exeを実際に生成指示するコード部分。--excludeの部分はexe作るのに除外したいライブラリがある場合に--exclude ●● で連結して1行で記述\n \n```\n\nしばらくすると前述のように新しく生成されたフォルダの中にexeファイルが生成されるのでもとのpyファイルと同じファイル構成に設置してみて正常に起動できるか確認する。\n\nここでエラー(●行目、cv2がインポートされてないから使えないよ、とかの英語記述)が出たらライブラリを追加でインストールしていくのをexeが正常に出力されるまで何回か繰り返すことになると思う。\n\nexeが正常に出力されたら(動作が期待通りになったら)とりあえず相手のパソコン環境に依存しないexeファイルが生成されたことになるのでこれを相手のPCに渡す。exe以外に関連するフォルダやファイルがある場合は階層構造をpyファイルの時と同じようにしてzipにするなりすればいいと思います。\n\n```\n\n conda.bat deactivate\n conda remove -n minimam --all\n y ←※2行目コマンド時、y/nを質問されたらyを入力してenter\n \n```\n\n最後にpython仮想環境を削除して完了(今回の例文だと仮想環境名はminimamです) \n一応仮想環境に必要なライブラリだけインストールしてexeファイルをコンパイルすることで8分の1とかかなりサイズダウンします。これやらなかった場合、print('hello')1行のpyファイルですら400MBくらいの巨大なexeファイルが生成されるので注意(とりあえず動くけど)\n\nあと、仮想環境作るのは面倒だからとりあえずコンパイルしてexeが実際に動作するかだけ確認したい場合、以下の書式を.batファイルと拡張子を変更したテキストファイル内にコピペして保存、コンパイルしたいpyファイルを.batファイルへドラッグアンドドロップするとコマンドプロンプト画面が自動で立ち上がって勝手にビルドしてくれる。(前述の大容量化はするのでテスト動作検証程度にしかならないが)\n\n```\n\n pyinstaller %~f1 --onefile ←前述の--excludeを使用してライブラリ除外も可能だが、汎用性を求めると未記述のほうが汎用(激重)\n PAUSE ←実行完了したあと、キー入力があるまでコマンドプロンプト画面を残す場合に記述\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T04:29:20.003", "id": "91412", "last_activity_date": "2022-10-03T04:29:20.003", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51823", "parent_id": "91391", "post_type": "answer", "score": 0 }, { "body": "#### Linuxなど最新の UNIX系統の OS\n\nOS自体に Pythonが含まれ, OSの機能の一部として利用されている \nこれらの OSでは, OS側の Pythonや パッケージと被ることがないようにしなければならない \n(被ると OSを不安定にさせてしまう, 最悪破壊してしまう)\n\nよく Web記事で見かける pip などは利用を控え(というか使わないようにし) \npipenv、poetry もしくは [venv](https://docs.python.org/ja/3/library/venv.html)\nなどを利用する \n(Anaconda の conda でも可)\n\n※ \nPyInstallerは Linuxでは使ったことがないので, 正直不明です\n\n#### Windows の場合\n\nPyInstaller以外として … \n[4.4. 埋め込み可能なパッケージ (The embeddable\npackage)](https://docs.python.org/ja/3/using/windows.html#windows-embeddable)\nに記されているパッケージは, サイズもコンパクトです \nダウンロード: (embeddable package) <https://www.python.org/downloads/windows/>\n\n持ち運ぶのは, このパッケージと(実行する)ユーザースクリプト。 \n実行する準備として, パッケージをフォルダーに展開する必要がある (展開した中にも zipがあるがそれは展開不要) \n不必要になれば, そのフォルダーを削除するとよい。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T05:35:38.793", "id": "91416", "last_activity_date": "2022-10-03T05:35:38.793", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43025", "parent_id": "91391", "post_type": "answer", "score": 0 } ]
91391
null
91412
{ "accepted_answer_id": null, "answer_count": 0, "body": "unityバイブルのNo08_CanKickersをダウンロードしてるのですが、エラーに困っています。 \n色々調べたのですがわかりません。\n\n<https://www.borndigital.co.jp/book/6633.html>\n\nバージョンはwindows10です。unity2019.4.0f1\n\nエラー内容はこれです。他にもエラーあるのですが非常に困っています。\n\n```\n\n Error: Could not load signature of UnityEngine.SpatialTracking.TrackedPoseDriver:TryGetTangoPose due to: Could not resolve type with token 0100000a (from typeref, class/assembly UnityEngine.XR.Tango.CoordinateFrame, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null) assembly:UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null type:UnityEngine.XR.Tango.CoordinateFrame member:(null) signature:<none>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-01T06:15:08.057", "favorite_count": 0, "id": "91392", "last_activity_date": "2022-10-01T06:38:55.420", "last_edit_date": "2022-10-01T06:38:55.420", "last_editor_user_id": "3060", "owner_user_id": "54642", "post_type": "question", "score": 0, "tags": [ "c#", "unity3d" ], "title": "unityバイブルのNo08_CanKickersエラーに困ってます", "view_count": 59 }
[]
91392
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "Ray tune上でGPUを用いてハイパーパラメータ最適化を試みましたが、以下のようなエラーに頭を抱えています。\n\n```\n\n RuntimeError: No CUDA GPUs are available\n (main pid=4099) *** SIGSEGV received at time=1664685800 on cpu 0 ***\n (main pid=4099) PC: @ 0x7f7999651050 (unknown) (unknown)\n 2022-10-02 04:43:20,455 WARNING worker.py:1829 -- A worker died or was killed while executing a task by an unexpected system error. To troubleshoot the problem, check the logs for the dead worker. RayTask ID: ffffffffffffffff7e397495e9840bc1819f011601000000 Worker ID: e9371df84e6c8ca09a2cf2da974ba9e78e9e125beb9488b22dc5a74f Node ID: a898df022b143e3de733f832dfee96aef8385bc6402e8a94da61e9ea Worker IP address: 172.28.0.2 Worker port: 41737 Worker PID: 4099 Worker exit type: SYSTEM_ERROR Worker exit detail: Worker unexpectedly exits with a connection error code 2. End of file. There are some potential root causes. (1) The process is killed by SIGKILL by OOM killer due to high memory usage. (2) ray stop --force is called. (3) The worker is crashed unexpectedly due to SIGSEGV or other unexpected errors.\n 2022-10-02 04:43:20,456 ERROR trial_runner.py:980 -- Trial main_b7e58_00000: Error processing event.\n ray.tune.error._TuneNoNextExecutorEventError: Traceback (most recent call last):\n File \"/usr/local/lib/python3.7/dist-packages/ray/tune/execution/ray_trial_executor.py\", line 989, in get_next_executor_event\n future_result = ray.get(ready_future)\n File \"/usr/local/lib/python3.7/dist-packages/ray/_private/client_mode_hook.py\", line 105, in wrapper\n return func(*args, **kwargs)\n File \"/usr/local/lib/python3.7/dist-packages/ray/_private/worker.py\", line 2277, in get\n raise value\n ray.exceptions.RayActorError: The actor died unexpectedly before finishing this task.\n class_name: wrap_function.<locals>.ImplicitFunc\n actor_id: 7e397495e9840bc1819f011601000000\n pid: 4099\n namespace: 8c989dd0-b724-425a-96f7-f4bb2992fe5a\n ip: 172.28.0.2\n The actor is dead because its worker process has died. Worker exit type: SYSTEM_ERROR Worker exit detail: Worker unexpectedly exits with a connection error code 2. End of file. There are some potential root causes. (1) The process is killed by SIGKILL by OOM killer due to high memory usage. (2) ray stop --force is called. (3) The worker is crashed unexpectedly due to SIGSEGV or other unexpected errors.\n \n```\n\ntune.run()ではgpu_per_trialの指定を行なっていて、以下のようにコードを書いています。\n\n```\n\n def run_search():\n \n for i in range(len(subj_list)):\n output_dir = '/content/drive/MyDrive/_Results___es_patience20__train_counts1_batch32_lr5e-06_w-decay0.00025'\n subj_dir = output_dir + '/' + subj_list[i]\n \n config = {\n 'lr_init':tune.quniform(1e-8,1e-3,5e-9),\n 'weight_decay':tune.qloguniform(1e-4,1e-2,5e-5)\n }\n \n scheduler = ASHAScheduler(\n metric = 'clip_corr',\n mode = 'max',\n max_t = 5000,\n grace_period = 1 , #学習がうまくいかなくても、1 epochは回す\n reduction_factor = 2\n )\n \n reporter = CLIReporter(\n metric_columns = ['train_loss','train_clip_corr','val_loss','val_clip_corr']\n )\n \n result = tune.run(main,\n config = config,\n num_samples = 1,\n resources_per_trial = {'cpu':8,'gpu':1},\n verbose = 3,\n scheduler = scheduler,\n local_dir = subj_dir,\n keep_checkpoints_num = 1, #val_clip_corrの最大化が目標\n checkpoint_score_attr = 'val_clip_corr',\n progress_reporter = reporter\n )\n \n ### extract the best trial run from the search ###\n best_trial = result.get_best_trial(\n 'val_clip_corr','max','last'\n )\n \n print('Best trial config :{}'.format(best_trial.config))\n print('Best trial final val_loss : {}'.format(best_trial.last_result['val_loss']))\n print('Best trial final val_clip_corr : {}'.format(best_trial.last_result['val_clip_corr']))\n \n if __name__ == '__main__':\n run_search()\n \n```\n\nそして以下に表示します、main()では`model.cuda(gpu_id)`として、gpuの指定を行いました。main()に登場します、transfer_model()という関数では、同じモデルでの以前の学習で得られたパラメータをロードしています。 \ntransfer_model()のセルをmain()の下に添付いたします。ご確認ください。\n\nなぜ、GPUが使用できないか、アイデアがあれば教えていただきたく思います。よろしくお願いします。\n\n```\n\n def main(config,\n gpu_id = 0,\n num_epochs = 5000,\n pretrained_type = 'IO',\n pretrained_model = '',\n train_counts =1,\n freeze_layer = ['cnn'],\n overfitting = False,\n early_stopping = False\n ):\n \n \n seeder(seed)\n \n output_dir = '/content/drive/MyDrive/_Results___es_patience20__train_counts1_batch32_lr5e-06_w-decay0.00025' \n print(output_dir)\n \n for i in range(len(subj_list)):\n \n pretrained_model = output_dir \n subj_dir = output_dir + '/' + subj_list[i]\n \n # get data loader\n train_loader = load_data(scaling = False,\n downscale_median = True,\n augmentation = True,\n train_loader = True)\n \n val_loader = load_data(scaling = False,\n downscale_median = True,\n augmentation = True,\n val_loader = True)\n \n test_loader = load_data(scaling = False,\n downscale_median = True,\n augmentation = True,\n test_loader = True)\n \n \n \n \n if pretrained_type == \"FT\":\n sub_pretrained_model = pretrained_model\n \n if pretrained_type == \"IO\":\n sub_pretrained_model = pretrained_model + '/' + subj_list[i]\n \n \n model = transfer_model(train_counts = 1,\n pre_model_path = sub_pretrained_model,\n verbose = True,\n gpu_id = 0)\n \n #device = os.environ['CUDA_VISIBLE_DEVICES'] = '0'\n model.cuda(gpu_id) \n \n for param in model.parameters():\n param.requires_grad = True\n \n if 'cnn' in freeze_layer:\n for param in model.cnn.parameters():\n param.requires_grad = False\n \n if 'tdm' in freeze_layer:\n for param in model.tdm.parameters():\n param.requires_grad = False\n \n if 'u_cnn_5' in freeze_layer:\n for idx, param in enumerate(model.cnn.parameters()):\n if idx < 34:\n param.requires_grad = False\n \n if 'rnn' in freeze_layer:\n for param in model.rnn.parameters():\n param.requires_grad = False\n \n \n criterion = nn.MSELoss()\n optimizer = optim.Adam(filter(lambda p:p.requires_grad, model.parameters()),\n lr = config['lr_init'],\n weight_decay = config['weight_decay'])\n \n \n if not overfitting:\n es = EarlyStopping(patience=20)\n \n \n for epoch in range(num_epochs):\n \n if epoch == 0:\n pass\n \n else:\n train_loss, train_clip_corr = train1(train_loader,\n model,\n criterion,\n optimizer,\n gpu_id = 0\n )\n \n val_loss, val_clip_corr = validate1(val_loader,\n model,\n gpu_id,\n criterion,\n corr_w=1.0,\n loss_type='MSE&Cosine',\n score_metric=\"spearmanr\",\n gpu_id = 0)\n \n print('train_loss : {}'.format(train_loss))\n print('train_clip_corr:{}'.format(train_clip_corr))\n print('val_loss :{}'.format(val_loss))\n print('val_clip_corr :{}'.format(val_clip_corr))\n \n with tune.checkpoint_dir(epoch) as checkpoint_dir:\n path = os.path.join(checkpoint_dir, 'checkpoint')\n torch.save((model.state_dict(), optimizer.state_dict()), path)\n \n tune.report(\n train_loss = train_loss,\n train_clip_corr = np.mean(train_clip_corr),\n val_loss = val_loss, \n val_clip_corr = np.mean(val_clip_corr)\n )\n \n \n def transfer_model(train_counts,\n pre_model_path,\n verbose=False,\n gpu_id = 0):\n \"\"\"\"\"\"\n \n if train_counts != 0:\n model = CRNN_VGG_BN_3FC_MaxPool(verbose=verbose, \n gpu_id = 1, \n train_counts=train_counts-1)\n model = add_tdm_layer(model, train_counts)\n \n if train_counts != 1:\n model = add_t_out(model, train_counts-1)\n model.cnn = model.cnn[:-1]\n \n if torch.cuda.is_available():\n model.load_state_dict(torch.load(pre_model_path + '/best_weight.pkl'), \n strict = False)\n else:\n model.load_state_dict(torch.load(pre_model_path + '/best_weight.pkl',\n map_location = 'cpu')\n ,strict = False)\n \n \n \n \n if train_counts == 0:\n model = CRNN_VGG_BN_3FC_MaxPool(verbose=verbose,\n gpu_id = 1,\n train_counts=train_counts)\n \n model.load_state_dict(torch.load(pre_model_path + '/best_weight.pkl'), \n strict = False)\n if verbose:\n print(model)\n \n model.cuda(gpu_id)\n \n return model\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T06:03:06.427", "favorite_count": 0, "id": "91396", "last_activity_date": "2022-10-02T06:03:06.427", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54391", "post_type": "question", "score": 0, "tags": [ "python", "深層学習", "google-colaboratory", "pytorch", "deeplearning4j" ], "title": "Ray tuneでのGPU の使い方を教えてほしいです。", "view_count": 199 }
[]
91396
null
null
{ "accepted_answer_id": "91398", "answer_count": 2, "body": "### 実現したいこと\n\n`result.xml`という名のxmlファイルの **`<passage>`** の中のabstractの **`<text>`** の抽出をしたい. \n**`<text>`** の部分は, `Neurologic complications of COVID-19, ~ encephalopathy.`\nの文と `The rapid evolution~replication.` の文を抽出したい.\n\nファイル: result.xml\n\n```\n\n <collection>\n <document>\n <passage>\n <infon key=\"authors\">Gupta NA, Lien C, Iv M, </infon>\n <offset>0</offset>\n <text>Critical illness-associated cerebral microbleeds in severe COVID-19 infection </text>\n <annotation id=\"5\">\n <location offset=\"68\" length=\"9\" />\n <text>infection</text>\n </annotation>\n </passage>\n <passage>\n <infon key=\"section_type\">ABSTRACT</infon>\n <infon key=\"type\">abstract</infon>\n <offset>81</offset>\n <text>Neurologic complications of COVID-19 infection have been recently described and include dizziness, headache, loss of taste and smell, stroke, and encephalopathy.</text>\n </passage>\n <passage>\n <infon key=\"section_type\">ABSTRACT</infon>\n <infon key=\"type\">abstract_title_1</infon>\n <offset>584</offset>\n <text>Highlights</text>\n </passage>\n </document>\n <document>\n <passage>\n <infon key=\"name_4\">surname:Ansari;given-names:M. Azim</infon>\n <offset>0</offset>\n <text>Extensive C->U transition biases in the genomes of a wide range of mammalian RNA viruses; potential associations with transcriptional mutations, damage- or host-mediated editing of viral RNA</text>\n <annotation id=\"1\">\n <infon key=\"identifier\">9606</infon>\n <infon key=\"type\">Species</infon>\n <location offset=\"67\" length=\"9\" />\n <text>mammalian</text>\n </annotation>\n </passage>\n <passage>\n <infon key=\"type\">abstract</infon>\n <offset>191</offset>\n <text>The rapid evolution of RNA viruses SARS-CoV-2 has been long considered to result from a combination of high copying error frequencies during RNA replication. </text>\n </passage>\n <passage>\n <infon key=\"section_type\">ABSTRACT</infon>\n <infon key=\"type\">abstract_title_1</infon>\n <offset>2033</offset>\n <text>Author summary</text>\n </passage>\n </document>\n </collection>\n \n```\n\nスクリプト: 1.py\n\n```\n\n from bs4 import BeautifulSoup\n with open('result.xml') as xml:\n soup = BeautifulSoup(xml, 'xml')\n \n result = []\n \n for passage in soup.find_all('passage'):\n text = passage.text\n if text and ('COVID-19' in text or 'SARS-CoV-2' in text):\n for line in text.splitlines():\n if line.strip().endswith('.'):\n result3.append(line)\n \n print(*result,sep='^\\n')\n \n```", "comment_count": 9, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T06:44:27.993", "favorite_count": 0, "id": "91397", "last_activity_date": "2022-10-04T08:18:47.800", "last_edit_date": "2022-10-04T08:18:47.800", "last_editor_user_id": "3060", "owner_user_id": "54656", "post_type": "question", "score": 0, "tags": [ "python", "python3", "xml" ], "title": "pythonでxmlファイルの一部分の情報を抽出したい", "view_count": 459 }
[ { "body": "BeautifulSoupを利用します.\n\n```\n\n from bs4 import BeautifulSoup\n soup = BeautifulSoup(xml, 'xml')\n \n result = []\n \n for passage in soup.find_all('passage'):\n text = passage.text\n if text and ('COVID-19' in text or 'SARS-CoV-2' in text):\n for line in text.splitlines():\n if line.strip().endswith('.'):\n result.append(line)\n \n print(*result, sep='\\n')\n \n # Neurologic complications of COVID-19 infection have been recently described and include dizziness, headache, loss of taste and smell, stroke, and encephalopathy.\n # The rapid evolution of RNA viruses SARS-CoV-2 has been long considered to result from a combination of high copying error frequencies during RNA replication. \n \n```\n\n### 補足\n\n * 行末がピリオドで終わるものを文としました(その際前後の空白を除去しています).\n * (追記)`if text and (...`について,textがNoneの場合(passageにtextタグが含まれていなかった場合)に次の`test in ...`でエラーを吐くことを防ぐ目的で,短絡評価を利用しています.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T07:31:19.033", "id": "91398", "last_activity_date": "2022-10-02T10:41:18.873", "last_edit_date": "2022-10-02T10:41:18.873", "last_editor_user_id": "51374", "owner_user_id": "51374", "parent_id": "91397", "post_type": "answer", "score": 0 }, { "body": "BeautifulSoup で CSS セレクタを使う場合。\n\n```\n\n from bs4 import BeautifulSoup\n \n with open('result.xml') as xml:\n soup = BeautifulSoup(xml, 'xml')\n \n texts = soup.select('''\n passage >\n infon[key=\"type\"]:-soup-contains(\"abstract\"):not(:-soup-contains(\"_title\")) ~\n text:-soup-contains(\"COVID-19\", \"SARS-CoV-2\")\n ''')\n text = [t.text for t in texts]\n \n print('\\n'.join(text))\n \n #\n Neurologic complications of COVID-19 infection have been recently described and include dizziness, headache, loss of taste and smell, stroke, and encephalopathy.\n The rapid evolution of RNA viruses SARS-CoV-2 has been long considered to result from a combination of high copying error frequencies during RNA replication. \n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T15:28:13.600", "id": "91404", "last_activity_date": "2022-10-02T15:28:13.600", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "47127", "parent_id": "91397", "post_type": "answer", "score": 1 } ]
91397
91398
91404
{ "accepted_answer_id": null, "answer_count": 1, "body": "create-react-appで作成されたReactのアプリに `localhost:3000` と `app.hoge.hoge:3000`\nというホスト名で同じページに接続出来ます。 \nreactアプリの環境変数HOSTやpacakege.json\nにホスト名を変更するような記述が見られないのにどうしてこのような動作をするのか不思議でたまりません。\n\nアプリはフロントがReactでバックエンドがrails APIでAPIにリクエストを投げる際に同じ `app.hoge.hoge:8080/api/v1`\nみたいな感じで投げています。\n\nおそらく React側でhost名が設定されたのではなく docker-\ncompose側でホスト名がバックエンドと同じになっていると思うのですが、どうのような設定をしたらこのようになるのか分からないです。 `docker\nnetworl create hoge` で作成されたネットワークにフロントとバックエンドのコンテナが接続してるような構成にはなっているのですが、\n`app.hoge.hoge` を指定してる箇所が見つけられなくて根拠が見当たらないです。\n\nお手隙の際に、ネットワーク周りに詳しい方教えて頂けないでしょうか。 \n宜しくお願い致します。他に必要な情報があれば教えて下さい。追記します。\n\nReactアプリが動作しているコンテナ内の `cat /etc/hosts` を確認しても `app.hoge.hoge` の記載は見られなかったです。 \nやはりdockerでもなく react router dom 等 react側で制御されているのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T09:16:39.527", "favorite_count": 0, "id": "91399", "last_activity_date": "2022-10-03T14:38:12.987", "last_edit_date": "2022-10-02T14:08:36.560", "last_editor_user_id": "22565", "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "docker", "reactjs", "network", "docker-compose" ], "title": "docker-composeで作成したReactアプリがlocalhost以外の任意のホスト名から接続できる。", "view_count": 148 }
[ { "body": "外部に建てたDNSサーバ(`app.hoge.hoge`)にアクセスして、それが `localhost`\nに接続を促してるためでした。そのため開発環境のパソコンのWifiを切断したら `app.hoge.hoge:3000` で接続できなくなりました。\n\ndig app.hoge.hoge でDNSのサーバが動作してるか確認できるそうです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T12:04:24.083", "id": "91423", "last_activity_date": "2022-10-03T14:38:12.987", "last_edit_date": "2022-10-03T14:38:12.987", "last_editor_user_id": "22565", "owner_user_id": "22565", "parent_id": "91399", "post_type": "answer", "score": 0 } ]
91399
null
91423
{ "accepted_answer_id": null, "answer_count": 0, "body": "SwiftUIとFirebaseの初学者です。\n\nFirestoreでは以下のように `.document()` でドキュメントIDを自動設定してくれますが、その取得がうまく行きません。 \n取得自体はできていますが、リスト表示にしているためか、最新のものだけに上書きされてしまいます。\n\n自動で設定したドキュメントIDを持ってきてそのIDを指定し、選択したリストを削除したいです。\n\n```\n\n db.collection(\"posts\").document().setData([\n \"post\" : postText,\n \"date\" : Date(),\n \"user\" : Auth.auth().currentUser!.uid,\n \"id\": db.collection(\"posts\").document().documentID\n ])\n \n```\n\n下記は関係する部分のコードです。よろしくお願いします。\n\n```\n\n func gepo() {\n let userID = Auth.auth().currentUser!.uid\n db.collection(\"posts\").whereField(\"user\", isEqualTo: userID)\n .getDocuments(){(QuerySnapshot, err) in\n if let err = err{\n print(\"Error getting documents: \\(err)\")\n }else{\n for document in QuerySnapshot!.documents{\n post = document.get(\"post\") as! String\n // date = document.get(\"date\") as! Timestamp\n postLists.append(post)\n documentId = document.documentID\n docIdList.append(documentId)\n }\n }\n }\n }\n \n var body: some View{\n let newID = db.collection(\"posts\").document().documentID\n let userID = Auth.auth().currentUser!.uid\n NavigationView {\n ZStack{\n HStack{\n switch bottomBarKubun{\n case 0:\n Text(userID).foregroundColor(Color.red)\n case 1:\n List{\n ForEach(postLists, id: \\.self){item in\n HStack{\n Text(item)\n Text(documentId)\n .frame(maxWidth: .infinity, alignment: .trailing)\n }\n .swipeActions(edge: .trailing){\n Button {\n db.collection(\"posts\").document(documentId).delete()\n postLists = []\n gepo()\n }label: {\n Image(systemName: \"trash.fill\")\n }.tint(.red)\n }\n }\n }\n case 2:\n Text(\"tomo\")\n case 3:\n Text(\"sette\")\n default:\n Text(\"\")\n }\n }\n .navigationTitle(topName)\n .navigationBarTitleDisplayMode(.inline)\n if(bottomBarKubun == 1){\n floatingButton\n }\n }\n .toolbar{\n ToolbarItemGroup(placement: .bottomBar){\n Button(\"行きたい店\") {\n self.topName = \"行きたい店\"\n bottomBarKubun = 1\n postLists = []\n gepo()\n }\n Spacer()\n Button(\"友達\") {\n topName = \"友達\"\n bottomBarKubun = 2\n }\n Spacer()\n Button(\"設定\") {\n topName = \"設定\"\n bottomBarKubun = 3\n }\n }\n }\n }\n }\n var floatingButton: some View {\n \n VStack {\n // 2. ButtonをViewの下方に配置\n Spacer()\n HStack {\n TextField(\"行きたいところを入力してください\\n\", text: $new)\n .textFieldStyle(RoundedBorderTextFieldStyle())\n // 3. Viewの右方に配置\n Spacer()\n Button(action: {\n // ボタンを押した時のアクションを記載\n if(new == \"\"){\n errorMessage = \"入力は必須です\"\n }else{\n self.postText = self.new\n db.collection(\"posts\").document().setData([\n \"post\" : postText,\n \"date\" : Date(),\n \"user\" : Auth.auth().currentUser!.uid,\n \"id\": db.collection(\"posts\").document().documentID\n ])\n postLists = []\n self.new = \"\"\n gepo()\n }\n }) {\n // 4. Buttonのデザインを作成。記号の\"+\"を配置。\n Image(systemName: \"plus.circle.fill\")\n // Fontサイズ\n .font(.system(size: 24))\n // Buttonの文字色\n .foregroundColor(.white)\n // Buttonのサイズ\n .frame(width: 60, height: 60)\n // Buttonの色\n .background(Color.blue)\n // Buttonの角の丸み\n .cornerRadius(30.0)\n // Buttonの陰\n .shadow(color: .gray, radius: 3, x: 3, y: 3)\n // Buttonの端からの距離\n .padding(EdgeInsets(top: 0, leading: 0, bottom: 16.0, trailing: 20))\n }\n }\n Text(errorMessage)\n }\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T14:27:20.177", "favorite_count": 0, "id": "91402", "last_activity_date": "2022-10-04T04:19:39.517", "last_edit_date": "2022-10-04T04:19:39.517", "last_editor_user_id": "3060", "owner_user_id": "52037", "post_type": "question", "score": 0, "tags": [ "swift", "firebase", "swiftui" ], "title": "SwiftUIとFirebase使用時の自動ドキュメントIDの取得が上書きされる", "view_count": 128 }
[]
91402
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "**環境:** \nXcode 14.0 \nSwift 5.7\n\n円の画像がある部分だけをタップして反応できるようにしたいのですが、いい実装方法が思いつきません。なぜそのような実装にしたいからというと、円を配置するときに並べるときに透明な部分がかぶってしまって予期せぬ不具合が発生してしまうからです。\n\n下記のURLを参考にしたんですが、ダメでした。よろしくお願いいたします。 \n<https://stackoverflow.com/questions/57667515/swift-how-to-make-uibutton-tap-\ninteraction-only-on-the-image-attached-and-igno>\n\nダメな理由 \nalpha値が透明な部分をタップしても255になってしまう\n\n[![透明な部分を押したくない画像](https://i.stack.imgur.com/TiACH.png)](https://i.stack.imgur.com/TiACH.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T15:02:14.590", "favorite_count": 0, "id": "91403", "last_activity_date": "2022-10-03T02:03:15.547", "last_edit_date": "2022-10-03T02:03:15.547", "last_editor_user_id": "3060", "owner_user_id": "42008", "post_type": "question", "score": 0, "tags": [ "swift", "xcode" ], "title": "UIButtonで画像を挿入したときに、透明な部分はタップされないようにしたい", "view_count": 61 }
[]
91403
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "Henon写像のESN学習を行なっているのですが上記のエラーが起こってしまいます。 \nエラーの箇所は予測性能評価の部分で起こっていると思うのですが原因がわかりません。 \nよろしければ回答の程をお願いします。\n\n```\n\n import numpy as np\n import matplotlib.pyplot as plt\n from model import ESN, Tikhonov\n \n \n np.random.seed(seed=0)\n \n # Henon写像によるデータ生成\n class Henon:\n # パラメータの指定\n def __init__(self, a, b):\n self.a = a\n self.b = b\n \n def f1(self, t, x, y):\n return 1 - self.a*x**2 + y\n \n def f2(self, t, x, y):\n return self.b*x\n \n \n def Henon(self, t, X):\n '''\n :param t: 時間\n :param X: 2次元ベクトル\n :return: 2次元ベクトル\n '''\n next_X = [self.f1(t, X[0], X[1]), \n self.f2(t, X[0], X[1])]\n return np.array(next_X)\n \n \n def Date_Henon(self, x0, T, dt):\n '''\n :param x0: 初期値\n :param T: 時間\n :param dt: ステップ幅\n :return: Henon写像\n '''\n X = x0\n t = 0\n data = []\n \n while t < T:\n next_X = self.Henon(t,X)\n data.append(next_X)\n X = next_X\n t = t + dt\n \n return np.array(data)\n \n if __name__ == '__main__':\n \n # Lorenz方程式から時系列データ生成\n T_train = 1000 # 学習データの長さ\n T_test = 100# テストデータの長さ\n dt = 1.0\n x0 = np.array([1, 1]) # 初期値\n \n dynamics = Henon(1.4, 0.3)\n data = dynamics.Date_Henon(x0, T_train + T_test, dt)\n \n # 訓練・検証用情報\n train_U = data[:T_train]\n train_D = data[1:T_train+1]\n \n test_U = data[T_train:T_train + T_test]\n test_D = data[1 + T_train:T_train + T_test + 1]\n \n N_x = 1000 # リザバーのノード数\n model = ESN(train_U.shape[1], train_D.shape[1], N_x, \\\n density=0.1, input_scale=0.1, rho=0.95)\n \n # 学習(リッジ回帰)\n train_Y = model.train(train_U, train_D, \n Tikhonov(N_x, train_D.shape[1], 1e-4))\n \n # モデル出力(自律系のフリーラン)\n test_Y = model.predict(test_U)\n T0 = test_D[:, 0]\n T1 = test_Y[:, 0]\n plt.plot(T0,label= 'テストデータ')\n plt.plot(T1)\n \n \n # 予測性能評価(valid time)\n eps = 1 # 許容誤差\n for n in range(int(T_test/dt)):\n dif = np.sqrt(((test_D[n,:] - test_Y[n,:]) ** 2).mean())\n if dif > eps:\n valid_time = float(n)*dt\n break\n \n print('valid time = ', valid_time)\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T19:17:30.770", "favorite_count": 0, "id": "91405", "last_activity_date": "2022-10-23T14:48:19.557", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54665", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "index 99 is out of bounds for axis 0 with size 99", "view_count": 435 }
[ { "body": "既に解決済みかもしれませんが,念のため回答いたします。 \nコメント欄のアドバイスに従い,68行目\n\n```\n\n test_D = data[1 + T_train:T_train + T_test + 1]\n \n```\n\nの直後に\n\n```\n\n print(test_D.shape, data.shape)\n \n```\n\nを挿入して調べてみると\n\n```\n\n (99, 2) (1100, 2)\n \n```\n\nが得られるので, test_D の( axis 0 の)サイズが 99 であり,これがエラーの原因と考えられます。 \nなお,68行目の記述を実際の数値( T_train=1000, T_test=100 )で置き換えてみると\n\n```\n\n test_D = data[1001:1101]\n \n```\n\nなので, test_D のサイズを 100 にするには,data のサイズが 1101 必要です。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-16T05:56:45.107", "id": "91626", "last_activity_date": "2022-10-23T14:48:19.557", "last_edit_date": "2022-10-23T14:48:19.557", "last_editor_user_id": "54588", "owner_user_id": "54588", "parent_id": "91405", "post_type": "answer", "score": 1 } ]
91405
null
91626
{ "accepted_answer_id": "91408", "answer_count": 1, "body": "```\n\n import pandas as pd\n import numpy as np\n df1 = pd.DataFrame({'生物':['しろくま','ねこ','うさぎ','ラッコ','モモンガ','シーサー','オデ','鎧'],\n 'HP':[2,50,100,600,60,72,1000,np.nan]})\n df1\n \n```\n\n上記のようなdf1から「うさぎ」の「HP」の100という値だけ取得したい場合、感覚的には\n\n```\n\n # 行を指定せずに値を取得しようするとSeriesが取得されてしまう。\n a = df1[df1['生物'] =='うさぎ'].loc[:, 'HP']\n a\n \n```\n\nこんな感じで「生物」列から「うさぎ」で1行に絞り込んだ値からHP列だけ取り出せば良いように感じるのですが、実際にはSeriesが取得されてしまいます。 \n値だけを取得したい場合は、以下のように行のインデックスを指定する形にしないと100という値だけを取り出せないですよね。\n\n```\n\n b = df1[df1['生物'] =='うさぎ'].iloc[0,1]\n b\n \n```\n\nルールは分かったのですが、a に代入した値がSeriesになってしまう理由がいまいち納得できません。どうしてなのか、ヒントをいただけないでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-02T23:54:01.237", "favorite_count": 0, "id": "91406", "last_activity_date": "2022-10-03T02:05:24.077", "last_edit_date": "2022-10-03T02:05:24.077", "last_editor_user_id": "3060", "owner_user_id": "54631", "post_type": "question", "score": 0, "tags": [ "python", "pandas" ], "title": "PandasのDataFrameのデータの抽出について(Seriesが返されるケースと値が取得できるケースの違い)", "view_count": 325 }
[ { "body": "こんな記事が参考になるでしょう。 \n[【Python】Pandas loc と ilocの違いとは?\n初心者向けにわかりやすく解説](https://aiacademy.jp/media/?p=1551) \n[【Python】Pandasメモ:ilocとlocの違い、データの抽出方法](https://kojimanotech.com/2019/08/08/174/)\n\n質問のソースコードに書いてある通り、locやilocの行部分パラメータの指定方法による違いでしょう。\n\n`iloc`でも`[:,1]`と書けばSeriesが返りますし、`loc`で`[2,\n'HP']`(`2`は`うさぎ`のIndex値)と書けば一つの値になります。\n\n@metropolis さんのコメントにあるように、`df1.loc[df1['生物'] =='うさぎ',\n'HP'].values[0]`とか、あるいは`df1[df1['生物']\n=='うさぎ'].values[0][1]`という風に`values`と配列のIndexを使うという手もあります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T01:30:13.470", "id": "91408", "last_activity_date": "2022-10-03T01:39:05.657", "last_edit_date": "2022-10-03T01:39:05.657", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "91406", "post_type": "answer", "score": 0 } ]
91406
91408
91408
{ "accepted_answer_id": null, "answer_count": 1, "body": "## 実行したいこと\n\n検索条件にはテーブルteiki.teiki_oyaprod_cdのteikioya1を使って理想実行結果のようなデータを取得したいです。 \n追記: \nteiki.teiki_oyaprod_cdに加えてteikimeisai.teikiprod_cd(wa,wbs,wc)も検索時の条件に加えられるようになりました。自分なりにも解決できるかも知れませんがアドバイス等頂けたら幸いです。\n\n * 理想実行結果のmeisaiにはteikimeisai.meisai_noでセット子情報の場合はNULL\n * prod_cdには定期明細のteikiprod_cdもしくはteikiprod_cdの値がテーブルsetのset_oyaprod_cdに存在していればsetdetailのセット子情報set_prod_cdの値も取得してくる。セット子情報の並び順はsetdetailのseq昇順。\n * prod_nmにはテーブルprod.prod_nameの値\n * prod_priceにはテーブルprod.prod_priceの値でセット子情報のレコードの場合NULL\n * ソート順はteikimeisai.meisai_no,setdetail.seq\n\n## 詰まった点\n\nセット親の商品コードとセット子の商品コードを別レコードの同じカラムprod_cdで取得する方法が分からず詰まってしまいました。\n\nまだSQL経験も浅く、質問も初なので不明瞭な点、申し訳ありません。分かる方、ご教授頂きたいです。 \nPostgreSQLを利用しています。\n\n### テーブル名:prod\n\nprod_cd | prod_name | prod_price \n---|---|--- \nwa | 定期1子A | 1000 \nwbs | 定期1子Bセット親 | 2000 \nwb1 | セット子B1 | 1000 \nwb2 | セット子B2 | 1000 \nwc | 定期1子C | 1000 \nwds | 定期2子Dセット親 | 1000 \nwd1 | セット子D1 | 1000 \nteikioya1 | 定期親1 | 3000 \nteikioya2 | 定期親2 | 3000 \n \n### テーブル名:teiki\n\nteiki_cd | teiki_oyaprod_cd \n---|--- \nteiki1 | teikioya1 \nteiki2 | teikioya2 \n \n### テーブル名:teikimeisai\n\nteiki_cd | meisai_no | teikiprod_cd \n---|---|--- \nteiki1 | 1 | wa \nteiki1 | 2 | wbs \nteiki1 | 3 | wc \nteiki2 | 1 | wds \n \n### テーブル名:setprod\n\nset_oyaprod_cd \n--- \nwbs \nwds \n \n### テーブル名:setdetail\n\nset_oyaprod_cd | seq | set_prod_cd \n---|---|--- \nwbs | 1 | wb1 \nwbs | 2 | wb2 \nwds | 1 | wd1 \n \n## 理想実行結果A\n\nmeisai | prod_cd | prod_nm | prod_price \n---|---|---|--- \n1 | wa | 定期1子A1000 | \n2 | wbs | 定期1子Bセット親 | 2000 \n| wb1 | セット子B1 | \n| wb2 | セット子B2 | \n3 | wc | 定期1子C | 1000 \n \n## 理想実行結果B (Aの代わりにこちらでも構わない)\n\nmeisai | prod_cd | set_prod_cd | prod_nm | prod_price \n---|---|---|---|--- \n1 | wa | | 定期1子A | 1000 \n2 | wbs | | 定期1子Bセット親 | 2000 \n| | wb1 | セット子B1 | \n| | wb2 | セット子B2 | \n3 | wc | | 定期1子C | 1000 \n \n* * *\n\n# 追記:\n\n以下はかなり理想実行結果Aに近くなりましたが、teikimeisai.teikiprod_cdの重複データがあるなど不完全で、これ以上の改善策が分からない状態です。\n\n## 現状コード\n\n```\n\n select tm.meisai_no meisai,\n \n p.prod_cd,\n \n p.prod_name prod_nm,\n \n case when ssd.set_oyaprod_cd is null\n \n then p.prod_price\n \n else null\n \n end prod_price\n \n from prod p\n \n left join teikimeisai tm\n \n on p.prod_cd = tm.teikiprod_cd\n \n left join setdetail sd\n \n on p.prod_cd = sd.set_prod_cd\n \n left join (select tm2.meisai_no,\n \n tm2.set_oyaprod_cd,\n \n sd2.set_prod_cd\n \n from teiki tk\n \n join teikimeisai tm2\n \n on tk.teiki_cd = tm2.teiki_cd\n \n left join setprod sp\n \n on tm2.teiki_prod_cd = sp.set_oyaprod_cd\n \n left join setdetail sd2\n \n on sp.set_oyaprod_cd = sd2.set_oyaprod_cd\n \n where tk.teiki_cd = 'teikioya1') as ssd\n \n on p.prod_cd = ssd.sed_prod_cd\n \n on p.prod_cd = ssd.prod_cd\n \n order by coalesce(tm.meisai_no, ssd.meisai_no),\n \n ssd.seq nulls first\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T02:22:27.420", "favorite_count": 0, "id": "91410", "last_activity_date": "2022-10-04T06:19:12.017", "last_edit_date": "2022-10-04T06:19:12.017", "last_editor_user_id": "54667", "owner_user_id": "54667", "post_type": "question", "score": 0, "tags": [ "sql", "postgresql" ], "title": "同じカラムに二種類のデータを取得する方法", "view_count": 557 }
[ { "body": "`prod.prod_cd`が`teikimeisai.teikiprod_cd`に存在するレコードを「セット親」と推測します。 \nセット親とセット子は別テーブルを参照するため左外部結合を使うのが通常の解法です。 \nさらにセット子は複数のテーブルを結合するため、`join`文の中で副問い合わせを併用することになります。\n\n下記のサンプルコードを参考にしてみてください。\n\n**サンプルコード**\n\n**Schema (PostgreSQL v14)**\n\n```\n\n CREATE TABLE prod (\n \"prod_cd\" VARCHAR(100),\n \"prod_name\" VARCHAR(100),\n \"prod_price\" INTEGER\n );\n \n INSERT INTO prod\n (\"prod_cd\", \"prod_name\", \"prod_price\")\n VALUES\n ('wa', '商品A', '1000'),\n ('wbs', '商品Bセット', '2000'),\n ('wb1', '商品B1', '1000'),\n ('wb2', '商品B2', '1000'),\n ('wc', '商品C', '1000');\n \n CREATE TABLE teiki (\n \"teiki_cd\" VARCHAR(100),\n \"teiki_oyaprod_cd\" VARCHAR(100)\n );\n \n INSERT INTO teiki\n (\"teiki_cd\", \"teiki_oyaprod_cd\")\n VALUES\n ('teikia', 'teikioya');\n \n CREATE TABLE teikimeisai (\n \"teiki_cd\" VARCHAR(100),\n \"meisai_no\" INTEGER,\n \"teikiprod_cd\" VARCHAR(100)\n );\n \n INSERT INTO teikimeisai\n (\"teiki_cd\", \"meisai_no\", \"teikiprod_cd\")\n VALUES\n ('teikia', '1', 'wa'),\n ('teikia', '2', 'wbs'),\n ('teikia', '3', 'wc');\n \n CREATE TABLE \"set\" (\n \"set_oyaprod_cd\" VARCHAR(100)\n );\n \n INSERT INTO set\n (\"set_oyaprod_cd\")\n VALUES\n ('wbs');\n \n CREATE TABLE setdetail (\n \"set_oyaprod_cd\" VARCHAR(100),\n \"seq\" INTEGER,\n \"sed_prod_cd\" VARCHAR(100)\n );\n \n INSERT INTO setdetail\n (\"set_oyaprod_cd\", \"seq\", \"sed_prod_cd\")\n VALUES\n ('wbs', '1', 'wb1'),\n ('wbs', '2', 'wb2');\n \n```\n\n* * *\n\n**Query #1**\n\n```\n\n select tm.meisai_no meisai,\n p.prod_cd,\n p.prod_name prod_nm,\n case when ssd.set_oyaprod_cd is null\n then p.prod_price\n else null\n end prod_price\n from prod p\n left join teikimeisai tm\n on p.prod_cd = tm.teikiprod_cd\n left join (select tm2.meisai_no,\n s.set_oyaprod_cd,\n sd.seq,\n sd.sed_prod_cd\n from \"set\" s\n join teikimeisai tm2\n on s.set_oyaprod_cd = tm2.teikiprod_cd\n join setdetail sd\n on s.set_oyaprod_cd = sd.set_oyaprod_cd) as ssd\n on p.prod_cd = ssd.sed_prod_cd\n order by coalesce(tm.meisai_no, ssd.meisai_no),\n ssd.seq nulls first;\n \n```\n\nmeisai | prod_cd | prod_nm | prod_price \n---|---|---|--- \n1 | wa | 商品A | 1000 \n2 | wbs | 商品Bセット | 2000 \n| wb1 | 商品B1 | \n| wb2 | 商品B2 | \n3 | wc | 商品C | 1000 \n \n* * *\n\n[View on DB Fiddle](https://www.db-fiddle.com/f/h1zs9rZ6HV7VNaWAZLcJnS/0)\n\n**注記**\n\nテーブル`teiki`の`teiki_oyaprod_cd`の必要性が読み取れなかったので使っていません。 \n`prod`テーブル`wc`レコードの`prod_price`が1000ですので、理想実行結果の1500とは異なります。 \n本テーブルは別名と思いますが、`set`のようにSQL文の構文そのものの単語は使わない方が可読性や保守性が上がります。\n\nさて、スタックオーバーフローへようこそ! \n仕様を詳細に書いていただくことは必要かつありがたいのですが、どちらかというと詰まった点や試行錯誤した痕跡に重点をおいて記載していただくと適切な回答がつきやすくなります。 \n※仕様と希望する動作のみ書かれた質問は、俗に「丸投げ」といわれる印象を与えてしまいます。\n\n動かないSQL文であっても、SQLのコメントに `-- ここが分からない`\nなどの注釈付きで載せた方が回答者の解説が実態に即したものになりますので、この回答が不適切な場合や今後の質問で意識していただければ幸いです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T05:33:27.983", "id": "91415", "last_activity_date": "2022-10-03T05:33:27.983", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "91410", "post_type": "answer", "score": 0 } ]
91410
null
91415
{ "accepted_answer_id": null, "answer_count": 1, "body": "①ExpandableListView(id:test1) \n②ExpandableListView(id:test2)\n\n②が表示されません。 \n①と②を同じxmlファイルに記載すると問題なく表示されます。\n\n①の中に②を入れると、\n\n> val test1 = requireView().findViewById(R.id.test1)\n\n→問題なく取得可能\n\n> val test2 = requireView().findViewById(R.id.test2)\n\n→デバッグモードで見るとViewがnullになっていて取得不可能", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T04:29:04.270", "favorite_count": 0, "id": "91411", "last_activity_date": "2022-10-03T14:35:57.680", "last_edit_date": "2022-10-03T04:37:16.453", "last_editor_user_id": "3060", "owner_user_id": "51637", "post_type": "question", "score": 0, "tags": [ "android", "kotlin" ], "title": "ExpandableListViewの中にExpandableListViewを入れる方法", "view_count": 31 }
[ { "body": "自己解決。 \n処理を記載するファイル(.kt)を間違えていました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T14:35:57.680", "id": "91427", "last_activity_date": "2022-10-03T14:35:57.680", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51637", "parent_id": "91411", "post_type": "answer", "score": 1 } ]
91411
null
91427
{ "accepted_answer_id": null, "answer_count": 2, "body": "RHEL8で以下のコマンドを実行\n\n```\n\n python -c ’import yum, pprint; yb =yum.YumBase(); pprint.pprint(yb.conf.yumbar,width=1)’\n \n```\n\n実行結果(エラー)\n\n```\n\n Traceback (most recent call last):\n File \"<string>, line 1, in<module>\"\n ImportError: No module named yum\n \n```", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T05:09:35.250", "favorite_count": 0, "id": "91413", "last_activity_date": "2022-10-08T04:13:31.230", "last_edit_date": "2022-10-03T07:33:25.380", "last_editor_user_id": "3060", "owner_user_id": "54672", "post_type": "question", "score": 0, "tags": [ "python", "yum", "rhel" ], "title": "RHEL8でImportError: No module named yumを解決したい", "view_count": 123 }
[ { "body": "まずバージョンを指定しないpythonコマンドをPython3.6に設定する。\n\n```\n\n alternatives --set python /usr/bin/python3\n \n```\n\nその後以下のコマンドを実行する。\n\n```\n\n python -c 'import dnf, pprint; db = dnf.dnf.Base(); pprint.pprint(db.conf.substitutions,width=1)'\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-08T03:19:28.947", "id": "91493", "last_activity_date": "2022-10-08T04:13:31.230", "last_edit_date": "2022-10-08T04:13:31.230", "last_editor_user_id": "54672", "owner_user_id": "54672", "parent_id": "91413", "post_type": "answer", "score": 0 }, { "body": "[RHEL 8 の導入における検討事項 - API の可用性](https://access.redhat.com/documentation/ja-\njp/red_hat_enterprise_linux/8/html-\nsingle/considerations_in_adopting_rhel_8/index#_availability_of_apis)に\n\n> **YUM v3** が提供する以前の Python API は利用できなくなりました。 **YUM v4** (DNF Python API)\n> が提供する安定し、完全に対応する新しい API に、使用しているプラグインおよびスクリプトを移行することが推奨されます。新しい DNF Python\n> API のドキュメントは、「DNF API Reference」により提供されます。\n\nと説明されているように、`import yum`は使えなくなり`import dnf`とした上で、DNF APIを使用する必要があります。\n\nなお、RHEL7のYUM Python APIはyumパッケージに含まれますし、RHEL8のDNF Python\nAPIもpython3-dnfパッケージに含まれます。そのため、「個別にインストールしたpython2.7.18」では扱うことができません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-08T03:58:55.737", "id": "91494", "last_activity_date": "2022-10-08T03:58:55.737", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "91413", "post_type": "answer", "score": 0 } ]
91413
null
91493
{ "accepted_answer_id": "91417", "answer_count": 1, "body": "ほぼ初心者なので、見当違いのこと言ってるかもしれませんがご教授よろしくお願いします。\n\n添付した画像上部のように、約4万行×1列に約100~200個(各行によって個数はまちまち)の0、1、2のいずれかが並んだデータがあります。 \nこれを、約100~200個の0、1、2の並びを分割して約4万行×100~200列(欠測の要素は#N/Aや-などで表現したいです)のデータに変換したいです。 \n文字列の並びを1つずつ分割するのに、list()関数が便利そうだったので、以下のようなコードを書きました。\n\n```\n\n import pandas as pd\n seg = pd.read_table('segments.txt')\n \n def seg_split(x):\n   return(list(x))\n \n seg_list = seg['segments'].apply(seg_split)\n print(seg_list)\n \n```\n\nこれによってできたのが、画像下部のようなデータで、データフレームの各要素がリストになっています。 \n初心者なりに色々調べてみたのですが、この後、リストではなく約4万行×100~200列に変換する手段がわからず困っています。 \nそもそもリスト化する段取りがよくないのかもしれませんが。[![添付ファイル](https://i.stack.imgur.com/Fnm1J.jpg)](https://i.stack.imgur.com/Fnm1J.jpg)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T05:11:27.630", "favorite_count": 0, "id": "91414", "last_activity_date": "2022-10-03T06:14:04.880", "last_edit_date": "2022-10-03T05:12:43.880", "last_editor_user_id": "54671", "owner_user_id": "54671", "post_type": "question", "score": 0, "tags": [ "python", "pandas" ], "title": "python pandas データフレームにおける各要素をリストではなくしたい", "view_count": 205 }
[ { "body": "`NaN` をどうするかはお好みで。\n\n```\n\n seg_list = seg['segments'].apply(lambda i: pd.Series([*i]))\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T06:14:04.880", "id": "91417", "last_activity_date": "2022-10-03T06:14:04.880", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "47127", "parent_id": "91414", "post_type": "answer", "score": 1 } ]
91414
91417
91417
{ "accepted_answer_id": null, "answer_count": 1, "body": "EventBridgeで検知した内容をSNSトピックでメール通知をしたいです。 \nSNSトピックはCMKで暗号化されていて、以下のキーポリシーを登録しましたがうまくいきません。\n\nやりたいことはCMKを利用するAWSアカウントを制限したいです。 \nご回答をよろしくお願いいたします。\n\nit works\n\n```\n\n {\n \"Sid\": \"Enable cross account events\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"Service\": \"events.amazonaws.com\"\n },\n \"Action\": [\n \"kms:Decrypt\",\n \"kms:GenerateDataKey\"\n ],\n \"Resource\": \"*\"\n }\n \n```\n\n以下はうまくいきません。\n\n```\n\n {\n \"Sid\": \"Enable cross account events\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"Service\": \"events.amazonaws.com\"\n },\n \"Action\": [\n \"kms:Decrypt\",\n \"kms:GenerateDataKey\"\n ],\n \"Resource\": \"*\",\n \"Condition\": {\n \"StringEquals\": {\n \"kms:CallerAccount\": \"xxxxxxxxxxxx\"\n }\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T08:33:07.723", "favorite_count": 0, "id": "91418", "last_activity_date": "2022-10-04T13:03:18.623", "last_edit_date": "2022-10-04T04:17:37.847", "last_editor_user_id": "3060", "owner_user_id": "54675", "post_type": "question", "score": 0, "tags": [ "aws" ], "title": "AWS KMSのキーポリシーがうまく動作しない", "view_count": 165 }
[ { "body": "現状では無理っぽいです。SNSトピックに投げるのはユーザーアカウントではなくサービスなのでAccountID情報が付かないです。\n\n最近、サービスにリンクされたロールが導入されつつあり、例えばAuto Scaling Groupであればこれが使えます。具体的にはAuto Scaling\nGroupが(ユーザーに代わって)EC2インスタンスを作成するため、EBS暗号化の処理などに`kms:Decrypt`などのアクションが必要になります。ここでサービスにリンクされたロールにこれらの許可を与えておくことができるわけです。\n\nしかし、CloudWatch Eventsにはまだサービスにリンクされたロールが導入されていないため、同様の指定はできません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T13:03:18.623", "id": "91448", "last_activity_date": "2022-10-04T13:03:18.623", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "91418", "post_type": "answer", "score": 0 } ]
91418
null
91448
{ "accepted_answer_id": null, "answer_count": 0, "body": "GridDBで50000ぐらいの列数が多いデータを扱いたいとおもいます。その場合における最適なスキーマ構成の考え方について教えてください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T08:39:26.677", "favorite_count": 0, "id": "91419", "last_activity_date": "2022-10-03T08:39:26.677", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "48491", "post_type": "question", "score": 0, "tags": [ "データベース設計" ], "title": "GridDBで列数が多いデータを扱う場合における最適なスキーマ構成の考え方について教えてください。", "view_count": 26 }
[]
91419
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "以前も同様の質問をしましたが、コマンドを乗せたほうが良いというアドバイスを受け、再投稿です。\n\nffmpegでmp4を圧縮し、最終的にはVOBに変換したいと考えていますが、以下のようなエラーになります。 \n元ファイル名は便宜上original.mp4としています。\n\nどこがおかしいのかお分かりになる有識者の方のご教授お待ちしております。\n\n```\n\n C:\\Users\\USER> ffmpeg\\ffmpeg.exe\n ffmpeg version N-108306-ge7a987d7c9-20220923 Copyright (c) 2000-2022 the FFmpeg developers\n built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)\n configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220923\n libavutil 57. 36.102 / 57. 36.102\n libavcodec 59. 44.101 / 59. 44.101\n libavformat 59. 32.101 / 59. 32.101\n libavdevice 59. 8.101 / 59. 8.101\n libavfilter 8. 49.100 / 8. 49.100\n libswscale 6. 8.112 / 6. 8.112\n libswresample 4. 9.100 / 4. 9.100\n libpostproc 56. 7.100 / 56. 7.100\n Hyper fast Audio and Video encoder\n usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...\n \n Use -h to get full help or, even better, run 'man ffmpeg'\n \n```\n\n```\n\n C:\\Users\\USER> ffmpeg -i original.mp4 -crf 10 compressed.mp4\n ffmpeg version N-108306-ge7a987d7c9-20220923 Copyright (c) 2000-2022 the FFmpeg developers\n built with gcc 12.1.0 (crosstool-NG 1.25.0.55_3defb7b)\n configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220923\n libavutil 57. 36.102 / 57. 36.102\n libavcodec 59. 44.101 / 59. 44.101\n libavformat 59. 32.101 / 59. 32.101\n libavdevice 59. 8.101 / 59. 8.101\n libavfilter 8. 49.100 / 8. 49.100\n libswscale 6. 8.112 / 6. 8.112\n libswresample 4. 9.100 / 4. 9.100\n libpostproc 56. 7.100 / 56. 7.100\n original.mp4: No such file or directory\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T10:51:30.863", "favorite_count": 0, "id": "91420", "last_activity_date": "2022-10-04T01:08:45.637", "last_edit_date": "2022-10-04T01:08:45.637", "last_editor_user_id": "3060", "owner_user_id": "54518", "post_type": "question", "score": 0, "tags": [ "windows", "ffmpeg" ], "title": "ffmpegでエラーが出る: No such file or directory", "view_count": 2032 }
[ { "body": "\"original.mp4: No such file or directory\" は指定したファイルが見つからないというエラーです。\n\n手っ取り早くは対象の動画ファイルを ffmpeg.exe と同じフォルダに移動してから実行するか、 \nもしくは以下の通り「動画ファイルのあるフォルダに移動」してから「FFmpeg をフルパスで呼び出す」方法を試してください。\n\n```\n\n C:\\> cd 動画のあるフォルダ\n \n C:\\動画のあるフォルダ> C:\\Users\\USER\\ffmpeg\\ffmpeg.exe -i original.mp4 -crf 10 compressed.mp4\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T11:13:43.467", "id": "91421", "last_activity_date": "2022-10-03T11:13:43.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "91420", "post_type": "answer", "score": 1 }, { "body": "[windows10](/questions/tagged/windows10 \"'windows10' のタグが付いた質問を表示\") ならば\n`original.mp4` があるフォルダを explorer で表示させた状態で、フォルダパスのバー [PC>ボリューム(D:)>mp4]\n部分をクリックして任意のコマンド(EXE名)を入力すると、そのフォルダ(ディレクトリ)を「カレントディレクトリ」にして当該プログラムが起動します。\n`cmd` と入力すればコマンドプロンプトが、 `powershell` と入力すればパワーシェルが起動します。\n\nそののちは @cubick さんの手続きで `ffmpeg.exe` を起動してみてください。\n\n本来は システムの詳細設定→環境変数→ユーザー環境変数 で、環境変数 `PATH` に `ffmpeg.exe`\nを配置しているディレクトリを追加するのが面倒無くて良いのですが・・・", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T01:03:29.053", "id": "91437", "last_activity_date": "2022-10-04T01:03:29.053", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8589", "parent_id": "91420", "post_type": "answer", "score": 0 } ]
91420
null
91421
{ "accepted_answer_id": null, "answer_count": 1, "body": "Pythonにて Seleniumで、あるURLのアクセスをThreadPoolExecutorにて並列4\ntaskで実行するscriptを組んでいるのですが、実行時から約1時間ほどは期待通りのタスクが次々に完了していくのですが、macの画面がscreen\nsaverに切り替わった時、あるいはmacをある1時間ほど放置しているとThreadPoolExecutorのタスクが急激に遅くなり目的のtaskが時間内に完了できません。下記にThreadPoolExecutorを使った、実行の行をコピーしました。ThreadPoolExecutorを使ってタスクの優先度をscreen\nsaverなどに影響されないようにできないものでしょうか?\n\n追加でテストした結果、 max_worker = 4, max_worker = 3いずれも\n2668個のtask後に停止していました。(全taskは約3500)\n\n```\n\n with ThreadPoolExecutor(max_workers = 4) as executor:\n futures = [executor.submit(selenium_wo_head,url_u, t, url_l) for t in code_key_list]\n result = [selenium_drive_without_head.result() for selenium_wo_head in futures]\n \n```\n\n**実行環境:** \nMacBook Pro \nmacOS Monterey", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T11:23:36.070", "favorite_count": 0, "id": "91422", "last_activity_date": "2022-10-16T16:23:30.317", "last_edit_date": "2022-10-16T16:23:30.317", "last_editor_user_id": "3060", "owner_user_id": "54679", "post_type": "question", "score": 0, "tags": [ "python", "macos", "selenium" ], "title": "Selenium と concurrent.futures を使ったタスク実行が、スクリーンセーバーで停止してしまう", "view_count": 172 }
[ { "body": "皆様返信ありがとうございました。一部のデータにエラーがあり、そのエラー処理が抜けていてそれが途中で終了していたことが原因でした。\n\nthreadで処理を行う際に、一旦Seriesで処理が正しく通るかを先に確認して実行するべきでした。動作前に `os.system(\"caffeinate\n-u -t 12000 &\")` にて見積もり処理時間中にsleepさせないことを実行させれば、問題が解決できました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-16T15:05:45.407", "id": "91636", "last_activity_date": "2022-10-16T16:22:36.530", "last_edit_date": "2022-10-16T16:22:36.530", "last_editor_user_id": "3060", "owner_user_id": "54679", "parent_id": "91422", "post_type": "answer", "score": 0 } ]
91422
null
91636
{ "accepted_answer_id": null, "answer_count": 3, "body": "Python 3.10.7 で下記のコードを動かしたところ警告が表示されます。\n\n**実行時の警告:**\n\n```\n\n numpy_test.py:5: RuntimeWarning: divide by zero encountered in log\n np_ret = np.where(np_val <= 0.5, np.sqrt(np_val), np.log(np_val))\n [0.]\n \n```\n\n`print(ret_val)` の表示は `[0.]` ですので、`np_func()` は `np.sqrt(0)` の値を返していると考えています。 \nその為、おそらく `np_func()` に `np.zeros(1)` が渡された際に、条件を満たす `np.sqrt(np_val)`\nだけでなく、条件を満たさない `np.log(np_val)` も計算することで警告が出ているのだと思うのですが、認識はあっていますでしょうか?\n\nできれば、今回のような実際には使用されない計算における警告は無視したいのですが、何か方法はありますでしょうか?\n\n**ソースコード:**\n\n```\n\n import numpy as np\n \n \n def np_func(np_val):\n np_ret = np.where(np_val <= 0.5, np.sqrt(np_val), np.log(np_val))\n return np_ret\n \n \n def test_numpy():\n np_val = np.zeros(1)\n ret_val = np_func(np_val)\n print(ret_val)\n \n \n if __name__ == \"__main__\":\n test_numpy()\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T13:23:20.463", "favorite_count": 0, "id": "91424", "last_activity_date": "2022-10-03T16:45:19.633", "last_edit_date": "2022-10-03T16:12:45.380", "last_editor_user_id": "3060", "owner_user_id": "4260", "post_type": "question", "score": 0, "tags": [ "python", "python3", "numpy" ], "title": "numpyにおける\"RuntimeWarning: divide by zero encountered in log\"の対処方法", "view_count": 906 }
[ { "body": "warningsモジュールを利用するのは如何でしょうか. \n(追記) コンテキストマネージャが利用できます.\n\n```\n\n import warnings\n \n import numpy as np\n \n \n def np_func(np_val):\n with warnings.catch_warnings():\n warnings.simplefilter('ignore')\n np_ret = np.where(np_val <= 0.5, np.sqrt(np_val), np.log(np_val))\n return np_ret\n \n def test_numpy():\n np_val = np.zeros(1)\n ret_val = np_func(np_val)\n print(ret_val)\n \n \n if __name__ == \"__main__\":\n test_numpy()\n \n \n```\n\n参考: [warnings --- 警告の制御 / Python3.10.6\ndocument](https://docs.python.org/ja/3/library/warnings.html#warnings.simplefilter)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T13:42:40.300", "id": "91426", "last_activity_date": "2022-10-03T14:41:44.893", "last_edit_date": "2022-10-03T14:41:44.893", "last_editor_user_id": "51374", "owner_user_id": "51374", "parent_id": "91424", "post_type": "answer", "score": 1 }, { "body": "一時的に無視する方法\n\n```\n\n def np_func(np_val):\n with np.errstate(divide='ignore'):\n np_ret = np.where(np_val <= 0.5, np.sqrt(np_val), np.log(np_val))\n return np_ret\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T14:39:38.300", "id": "91428", "last_activity_date": "2022-10-03T14:39:38.300", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43025", "parent_id": "91424", "post_type": "answer", "score": 2 }, { "body": "`numpy.log()` の `where` キーワードを使う方法もあります。\n\n```\n\n def np_func(np_val):\n np_ret = np.where(np_val <= 0.5, np.sqrt(np_val), np.log(np_val, where=(np_val!=0)))\n return np_ret\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T16:45:19.633", "id": "91430", "last_activity_date": "2022-10-03T16:45:19.633", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "47127", "parent_id": "91424", "post_type": "answer", "score": 1 } ]
91424
null
91428
{ "accepted_answer_id": null, "answer_count": 1, "body": "Chrome拡張機能を作っているのですが,HTML要素を取得して,chrome.storageへ保存したいと考えています.\n\nh1タグのみのページに対して,以下のJavaScriptを実行すると\n\n```\n\n > Value is set to <h1>Hello, world</h1>\n > Value currently {key: [[Prototype]]: Object}\n \n```\n\nといった出力になり,反映されていません.\n\nどなたかご教示を宜しくお願い致します.\n\n```\n\n const h1 = document.querySelector('h1')\n \n chrome.storage.local.set({\n \"key\": h1,\n }, function () {\n console.log('Value is set to ', h1)\n })\n \n chrome.storage.local.get(['key'], function (result) {\n console.log('Value currently is ', result)\n })\n```\n\n```\n\n <body>\n <h1>Hello, world</h1>\n </body>\n```\n\nmanifest.json\n\n```\n\n {\n \"manifest_version\": 3,\n \"name\": \"要素の取得\",\n \"description\": \"要素を取得してストレージへ保存\",\n \"version\": \"1.0\",\n \"action\": {\n \"default_popup\": \"popup.html\"\n },\n \"content_scripts\": [\n {\n \"matches\": [\"<all_urls>\"],\n \"js\": [\n \"content-script.js\"\n ],\n \"run_at\": \"document_end\",\n \"all_frames\": true\n }\n ],\n \"commands\": {\n \"_execute_action\": {\n \"suggested_key\": {\n \"default\": \"Ctrl+Shift+H\",\n \"mac\": \"MacCtrl+Shift+H\"\n },\n \"description\": \"Run extension.\"\n }\n },\n \"permissions\": [\n \"activeTab\",\n \"contextMenus\",\n \"clipboardWrite\",\n \"scripting\",\n \"tabs\",\n \"storage\"\n ],\n \"options_page\": \"options.html\"\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T15:56:55.637", "favorite_count": 0, "id": "91429", "last_activity_date": "2022-10-03T16:57:21.447", "last_edit_date": "2022-10-03T16:13:26.003", "last_editor_user_id": "3060", "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "javascript", "google-chrome", "chrome-extension" ], "title": "Chrome拡張機能にて,取得したHTML要素の値をchrome.storageへセットできない.", "view_count": 310 }
[ { "body": "storageに保存する際、オブジェクトをそのまま保存することは出来ないのでシリアライズが行われます。(データとしてはバイト列としてしか保持できないので)\n\n[https://developer.chrome.com/docs/extensions/reference/storage/#:~:text=Primitive%20values%20such%20as%20numbers%20will%20serialize%20as%20expected.%20Values%20with%20a%20typeof%20%22object%22%20and%20%22function%22%20will%20typically%20serialize%20to%20%7B%7D%2C%20with%20the%20exception%20of%20Array%20(serializes%20as%20expected)%2C%20Date%2C%20and%20Regex%20(serialize%20using%20their%20String%20representation)](https://developer.chrome.com/docs/extensions/reference/storage/#:%7E:text=Primitive%20values%20such%20as%20numbers%20will%20serialize%20as%20expected.%20Values%20with%20a%20typeof%20%22object%22%20and%20%22function%22%20will%20typically%20serialize%20to%20%7B%7D%2C%20with%20the%20exception%20of%20Array%20\\(serializes%20as%20expected\\)%2C%20Date%2C%20and%20Regex%20\\(serialize%20using%20their%20String%20representation\\)).\n\nプリミティブ値のほか配列、`Date`、`Regex`は例外として期待するシリアライズがなされるようですが、DOMを含めその他のオブジェクトは基本的にそのまま保持することはできないと考えてください。\n\nどのような挙動を期待されているのかはわかりませんが、HTMLとして保持したいのであれば[Element.outerHTML](https://developer.mozilla.org/ja/docs/Web/API/Element/outerHTML)でHTMLをテキストとして取り出す、などが有効でしょうか。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T16:57:21.447", "id": "91431", "last_activity_date": "2022-10-03T16:57:21.447", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2376", "parent_id": "91429", "post_type": "answer", "score": 1 } ]
91429
null
91431
{ "accepted_answer_id": null, "answer_count": 1, "body": "複数データソースをGridDBに取り込む場合の、GridDB上でのデータベース管理方法を教えてください。 \nできれば、GridDBのDBを複数に分けたいと思います。可能なんでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T21:56:09.417", "favorite_count": 0, "id": "91433", "last_activity_date": "2022-10-06T09:45:09.993", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "48491", "post_type": "question", "score": 0, "tags": [ "データベース設計" ], "title": "GridDB上でのデータベース管理方法を教えてください", "view_count": 58 }
[ { "body": "DBを複数に分けるようなことは可能です。 \nなお、DBを分けても、データのフォルダーは1つです(すなわち、フォルダーは分けることはできません)。 \nまた、ユーザは複数のDBにアクセス可能です。ただし、SQLでDBまたがった検索はできません。 \n詳細は、GridDB 機能リファレンス「7.2.4 データベースユーザ」を参照願います。 \n[www.toshiba-sol.co.jp/pro/griddb/docs-\njp/v5_1/GridDB_FeaturesReference.html#section-66](http://www.toshiba-\nsol.co.jp/pro/griddb/docs-jp/v5_1/GridDB_FeaturesReference.html#section-66)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-06T09:45:09.993", "id": "91470", "last_activity_date": "2022-10-06T09:45:09.993", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30548", "parent_id": "91433", "post_type": "answer", "score": 1 } ]
91433
null
91470
{ "accepted_answer_id": null, "answer_count": 0, "body": "以下のようなテーブルを想定しています。\n\n```\n\n CREATE TABLE `users` (\n `id` bigint unsigned NOT NULL AUTO_INCREMENT,\n PRIMARY KEY (`id`)\n )\n \n```\n\n```\n\n CREATE TABLE `logs` (\n `id` bigint unsigned NOT NULL AUTO_INCREMENT,\n `user_id` bigint unsigned NOT NULL,\n `date` datetime DEFAULT NULL\n PRIMARY KEY (`id`)\n )\n \n```\n\n * users1件に対して、logsが0〜複数件紐づいています\n * logsのdateはnullを許容しています\n\nusersを取得するとき、以下の条件で絞り込みたいです。\n\n * logsが紐づいていない、あるいはlogsが紐づいているが最新のログのdateがnullである\n\nご存知の方、ご教示いただけますと幸いです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-03T22:13:59.647", "favorite_count": 0, "id": "91434", "last_activity_date": "2022-10-03T22:18:08.733", "last_edit_date": "2022-10-03T22:18:08.733", "last_editor_user_id": "25845", "owner_user_id": "25845", "post_type": "question", "score": 0, "tags": [ "mysql", "laravel" ], "title": "LaravelクエリビルダーMySQLで最新の1件とLEFT OUTER JOINして、そのJOINしたテーブルのカラムで絞り込みたい", "view_count": 121 }
[]
91434
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "### 前提\n\nWebアプリケーションを構築しています。 \nJavaScriptを使用し、ブラウザでPDFを表示する機能が必要になったため \nJavaScriptでPDFを表示可能なPDF.jsを使用し、技術調査を行っています。\n\nPDF.jsでは以下の2通りの描画形式があることを認識しております。\n\n 1. PDF.jsに搭載されているビューワ(viewer.html)を利用しiframeにて描画\n 2. pdfjs を埋め込んで、PDF を SVG や canvas 要素に変換する\n\nビューワに備えられているズームやしおり、印刷機能をそのまま流用したいため \n1の方法にて対応することを考えております。\n\n通常のPDFファイルに関しては、問題なく描画出来ることは確認しました。\n\nしかし、描画を行いたいと思っているPDFはパスワードにて暗号化されたファイルになります。 \n暗号化されたファイルをそのまま描画した場合、パスワードを入力するモーダルが表示されます。\n\n### 実現したいこと\n\n暗号化されたPDFファイルを上記の1の方法で描画する際に、JavaScriptサイドでパスワードを指定し、パスワードの入力するモーダルを表示させないで、描画を行いと思っております。 \n⇒同一アプリで発行したパスワードでPDFを作成しているので、そのままシステム側でパスワードの解除を行いたい\n\n2の方法においては、PDF.jsのメソッドでgetDocument()の引数にパスワードを指定することで暗号化されたPDFファイルを描画可能なことは確認したのですが、PDFビューワ機能を利用したいので、1の方法でどうにかパスワードを指定しPDFを開くことは出来ないかと考えております。\n\nどなたかご教示いただけますと幸いです。\n\n### 補足情報(FW/ツールのバージョンなど)\n\nPDF.js Stable (v2.16.105)\n\n※ [teratail](https://teratail.com/questions/401g93p9ak93xf)\nでも同様の質問をさせて頂いております。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T00:25:00.507", "favorite_count": 0, "id": "91435", "last_activity_date": "2022-10-04T11:17:23.440", "last_edit_date": "2022-10-04T11:17:23.440", "last_editor_user_id": "3060", "owner_user_id": "24731", "post_type": "question", "score": 0, "tags": [ "javascript", "pdf", "svg", "html5-canvas" ], "title": "PDF.jsで暗号化PDFを描画したい", "view_count": 359 }
[]
91435
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "truffle testを行なったのですが、ひとつだけ、どうしてもパスしません。 \n(address型は2つあり、address payable public beneficiaryはパスし、 \nもうひとつのaddress public custodianがパスしません)。 \nアドバイスいただけると助かります。\n\nFundraiser.sol(スマートコントラクトのコード)\n\n```\n\n pragma solidity >0.4.23 <0.7.0;\n \n contract Fundraiser{\n string public name;\n string public url;\n string public imageURL;\n string public description;\n address payable public beneficiary;\n //これだけパスしない\n address public custodian;  \n \n constructor(\n string memory _name,\n string memory _url,\n string memory _imageURL,\n string memory _description,\n address payable _beneficiary,\n address _custodian\n )\n \n public\n {\n name = _name;\n url = _url;\n imageURL = _imageURL;\n description = _description;\n beneficiary= _beneficiary;\n custodian = _custodian;\n \n \n }\n }\n \n```\n\ntest/fundraiser_test.js(テストのコード)\n\n```\n\n const FundraiserContract = artifacts.require(\"Fundraiser\");\n contract(\"Fundraiser\", accounts => {\n let fundraiser;\n const name = \"Beneficiary Name\";\n const url = \"beneficiaryname.org\";\n const imageURL=\"https://placeKitten.com/600/350\";\n const description = \"Beneficiary description\";\n \n const beneficiary = accounts[1];\n const cunstodian = accounts[0];\n \n \n beforeEach(async () => {\n fundraiser = await FundraiserContract.new(\n name,\n url,\n imageURL,\n description,\n beneficiary,\n cunstodian\n )\n });\n \n describe(\"initialization\", () => {\n \n it(\"gets the beneficiary name\", async () => {\n const actual = await fundraiser.name();\n assert.equal(actual, name, \"names should match\");\n });\n \n it(\"gets the beneficiary url\", async () => {\n const actual = await fundraiser.imageURL();\n assert.equal(actual, imageURL, \"imageURL should match\");\n });\n \n it(\"gets the beneficiary image url\", async () => {\n const actual = await fundraiser.name();\n assert.equal(actual, name, \"names should match\");\n });\n \n it(\"gets the beneficiary description\", async () => {\n const actual = await fundraiser.description();\n assert.equal(actual, description, \"description should match\");\n });\n \n it(\"gets the beneficiary\", async () => {\n const actual = await fundraiser.beneficiary();\n assert.equal(actual, beneficiary, \"beneficiary should match\");\n });\n \n it(\"gets the cunstodian\", async () => {\n const actual = await fundraiser.cunstodian();\n assert.equal(actual, cunstodian, \"cunstodian should match\");\n });\n \n });\n });;\n \n```\n\ntruffle testの結果\n\n> Compiled successfully using:\n>\n> * solc: 0.5.16+commit.9c3226ce.Emscripten.clang\n>\n\n>\n> Contract: Fundraiser \n> initialization \n> ✔ gets the beneficiary name \n> ✔ gets the beneficiary url \n> ✔ gets the beneficiary image url \n> ✔ gets the beneficiary description \n> ✔ gets the beneficiary \n> 1) gets the cunstodian \n> No events were emitted\n>\n> 5 passing (191ms) \n> 1 failing\n>\n> 1. Contract: Fundraiser \n> initialization \n> gets the cunstodian: \n> TypeError: fundraiser.cunstodian is not a function \n> at Context. (test/fundraiser_test.js:54:38) \n> at processImmediate (node:internal/timers:466:21)\n>", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T00:40:11.813", "favorite_count": 0, "id": "91436", "last_activity_date": "2022-10-04T00:40:11.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "47148", "post_type": "question", "score": 0, "tags": [ "solidity" ], "title": "address型がtruffle testを通らない。", "view_count": 18 }
[]
91436
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "下記のコードで、オブジェクトは 'undefined' である可能性があります。ts(2532) \nと、test[i].vの部分でエラーになってしまうのですが、原因がさっぱりわかりません。 \nコードの書き方で回避する方法はありますでしょうか?\n\n```\n\n // test.ts\n type TestArray = {\n v: string;\n }\n let test: TestArray[] = [];\n for (let i = 0; i < test.length; i++) {\n if (test[i] && \"1.1\" == test[i].v) {\n console.log(test);\n }\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T01:12:28.250", "favorite_count": 0, "id": "91438", "last_activity_date": "2022-10-04T04:13:40.810", "last_edit_date": "2022-10-04T04:11:39.680", "last_editor_user_id": "3054", "owner_user_id": "54688", "post_type": "question", "score": 2, "tags": [ "typescript" ], "title": "TypeScriptでインデックスアクセス時のundefinedを回避したい", "view_count": 3754 }
[ { "body": "(`tsconfig.json` などで `\"noUncheckedIndexedAccess\": true`\nとしていることを前提とします。そうでなければ、質問のエラーは出ないことでしょう)\n\n[型の絞り込み\n(Narrowing)](https://www.typescriptlang.org/docs/handbook/2/narrowing.html)\nが行なわれる対象は変数です。`test[i]` のような式の型は絞り込めません。\n\n### 変数に代入する\n\nよって、変数に代入してから扱うことが考えられます。\n\n```\n\n for (let i = 0; i < test.length; i++) {\n // ここで代入\n const val = test[i]\n \n // 左でチェックしたので、右の val は 非undefined に絞り込まれる\n if (val && \"1.1\" == val.v) {\n console.log(val)\n }\n }\n \n```\n\n### オプショナルチェーン\n\n[オプショナルチェーン](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Optional_chaining)\nを使うとチェックがコンパクトに書け、TypeScript の型も問題ないです。\n\n```\n\n for (let i = 0; i < test.length; i++) {\n // `test[i]?.v` の結果は undefined かも知れませんが、\n // この場合、\"1.1\" との比較で false になるので問題無いです。\n if (\"1.1\" == test[i]?.v) {\n console.log(test[i])\n }\n }\n \n```\n\n### 非 null アサーション演算子 (`!`)\n\n`undefined` では無いことが確実であるならば、[非 null アサーション演算子 (Non-Null Assertion\nOperator)](https://www.typescriptlang.org/docs/handbook/2/everyday-\ntypes.html#non-null-assertion-operator-postfix-) を使ってチェックを省略できます。\n\n(自作のコードの場合は大丈夫でしょうが、JavaScript\nの世界ではプロパティーを読むだけで内容が変わるオブジェクトも存在しますので、コードのこの部分だけ見ても、確実なことは言えません)\n\n```\n\n for (let i = 0; i < test.length; i++) {\n // test[i] は undefined では無いことを知っているので、\n // TypeScript に伝える。間違っていたら ランタイムエラー。\n if (\"1.1\" == test[i]!.v) {\n console.log(test[i])\n }\n }\n \n```\n\n### 別のループ方法\n\n構文によっては自分でチェックする必要が無いです。\n\n```\n\n // 「for of」ループ\n for (const val of test) {\n if (\"1.1\" == val.v) {\n console.log(val)\n }\n }\n \n // forEach\n test.forEach((val) => {\n if (\"1.1\" == val.v) {\n console.log(val)\n }\n })\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T04:06:23.953", "id": "91440", "last_activity_date": "2022-10-04T04:13:40.810", "last_edit_date": "2022-10-04T04:13:40.810", "last_editor_user_id": "3054", "owner_user_id": "3054", "parent_id": "91438", "post_type": "answer", "score": 2 } ]
91438
null
91440
{ "accepted_answer_id": "91508", "answer_count": 1, "body": "GitHubでログインをしたあとに自分のアプリケーションサーバー(以下Appサーバー)とSPAのフロントエンド(以下SPA)でセッションを作りたいです。 \nしかしGitHubでログイン後にAppサーバーに飛んでくるコールバックの中でセッションを作成して、その後のSPAからのリクエストに対してセッションを確認することができません。 \nそもそもリダイレクトからだとセッションが作れなかったりするのでしょうか。 \nよろしくおねがいします。\n\n#### 処理の流れ\n\n 1. SPA ユーザーがログインボタンをクリックする。\n 2. APPサーバー Stateを作成しセッションに保存し、リクエストに付与しつつGitHubのログインにリダイレクト。\n 3. GitHub ユーザーがログインや情報アクセスの許可をする。\n 4. Appサーバー GitHubログイン後のコールバックを受け取りStateをセッション内のものと検証し、ログイン状態としアクセストークンなどが含まれるセッションを作成する。\n 5. SPA ログイン状態のチェックや、情報のリクエストを行う。\n 6. APPサーバー セッションからアクセストークンなどが読み込めない。\n\n#### コード\n\nAppサーバーはlocalhost:3000をngrokでアクセスする形にしたもの、SPAはlocalhost:8080を利用しています。 \nAppサーバーはginを使いセッションにはgin-contrib/sessionsとgin-contrib/sessions/cookieを利用しています。\n\nAPPサーバーのセッション設定\n\n```\n\n router := gin.Default()\n store := cookie.NewStore([]byte(os.Getenv(\"secret\")))\n store.Options(sessions.Options{\n Path: \"/\",\n })\n router.Use(sessions.Sessions(\"mysession\", store))\n \n```\n\n1\n\n```\n\n <a href=\"2のコードをハンドラーとするAPPサーバーのURL\">Login Github</a>\n \n```\n\n2\n\n```\n\n func (h *LoginHandler) LoginGithub(c *gin.Context) {\n session := sessions.Default(c)\n state := randomString(24)\n session.Set(\"state\", state)\n session.Save()\n url := buildLoginUrl(state)\n c.Redirect(http.StatusMovedPermanently, url)\n }\n \n```\n\n4\n\n```\n\n func (h *LoginHandler) CallbackLoginGithub(c *gin.Context) {\n code := c.Query(\"code\")\n state := c.Query(\"state\")\n if code == \"\" || state == \"\" {\n log.Println(c.Query(\"error_description\"))\n c.Status(http.StatusBadRequest)\n return\n }\n session := sessions.Default(c)\n if session.Get(\"state\") != state {\n c.Status(http.StatusBadRequest)\n return\n }\n session.Clear()\n session.Set(\"token\", \"トークン\")\n session.Save()\n c.Redirect(http.StatusMovedPermanently, \"http://localhost:8080/\")\n }\n \n```\n\n6\n\n```\n\n func (h *LoginHandler) GetLoginStatus(c *gin.Context) {\n session := sessions.Default(c)\n // 読み込めない\n token := session.Get(\"token\")\n if token == nil {\n c.JSON(http.StatusOK, LoginStateResponse{\n LoggedIn: false,\n })\n return\n }\n c.JSON(http.StatusOK, LoginStateResponse{\n LoggedIn: true,\n })\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T04:23:07.420", "favorite_count": 0, "id": "91441", "last_activity_date": "2022-10-09T10:05:54.707", "last_edit_date": "2022-10-04T05:22:12.427", "last_editor_user_id": "3060", "owner_user_id": "14222", "post_type": "question", "score": 0, "tags": [ "go", "oauth", "cookie" ], "title": "OAuthでログイン後にセッションを作成したい", "view_count": 113 }
[ { "body": "「処理の流れ」の5番にあたるSPAからAPIサーバーへのリクエストにfetchを使っていたのですが `credentials: 'include'`\nのオプションが抜けていました。 \nこれによってAPIサーバーへCookieが送られていませんでした。\n\nCookieを送信するリクエストの例\n\n```\n\n fetch(APIサーバーのアドレス, {\n method: 'GET',\n mode: 'cors',\n credentials: 'include', // ←これが大事\n headers: {\n 'Accept': 'application/json',\n 'X-Requested-With': 'Fetch',\n },\n })\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-09T10:05:54.707", "id": "91508", "last_activity_date": "2022-10-09T10:05:54.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14222", "parent_id": "91441", "post_type": "answer", "score": 0 } ]
91441
91508
91508
{ "accepted_answer_id": null, "answer_count": 2, "body": "matplotlib + jupyter以外の方法でグラフを画面に表示することが可能な方法はありますか?\n\n元のやり方の場合でも同様に質問ですが、pyinstaller等でexe化しようとする.pyファイル内での記述で完結可能ですか?", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T06:08:08.513", "favorite_count": 0, "id": "91442", "last_activity_date": "2022-11-05T12:38:55.017", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51823", "post_type": "question", "score": 0, "tags": [ "python", "jupyter-notebook" ], "title": "python【 matplotlib + jupyter 】以外の方法でグラフ表示を行う方法はありますか?", "view_count": 272 }
[ { "body": "### Matplotlib の場合\n\n[Backends](https://matplotlib.org/stable/users/explain/backends.html) に UI\nのバックエンドに関して述べられています。PyQt/PySide、PyGObject、Tkinter、wxPython、macOS/Cocoa\nなどが有るようです。\n\nそもそも、 Jupyter\nを用いる方法がオプションというか、発展的な利用方法だと思います。[チュートリアル](https://matplotlib.org/stable/tutorials/index.html)や\n[Quick start\nguide](https://matplotlib.org/stable/tutorials/introductory/quick_start.html)\nに従うと、デフォルトのバックエンドとして Qt や Tk などが使われると思います。\n\n自作の UI に組込む場合は、[Embedding Matplotlib in graphical user\ninterfaces](https://matplotlib.org/stable/gallery/user_interfaces/index.html)\nで解説されています。\n\nPyInstaller での exe 化のやり易さは、UI ライブラリにより様々と思いますが、メジャーなツールキットであれば、それぞれ解説が見つかります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T10:12:59.743", "id": "91444", "last_activity_date": "2022-10-04T10:12:59.743", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "91442", "post_type": "answer", "score": 3 }, { "body": "### GUI 環境を利用する方法\n\n[GUI Programming in Python](https://wiki.python.org/moin/GuiProgramming)\nにクロスプラットホーム・フレームワークやプラットフォーム固有のフレームワークが載ってます\n\nグラフの描画なら, UI としてではなく描画のみで, 結局 Matplotlib で行うことになるでしょう \n(ユーザースクリプトで線を引くなどは可能だが, グラフになるとそれなり大変になるので) \nその場合の GUI環境としては Qt, Tkinter などが候補に上がるはず\n\nその辺りは別解で記されているとおりで, \n付け加えるなら表示の際 **別ウィンドウ** が立ち上がる … くらい\n\n### Webブラウザーを利用する方法\n\n(実行環境に Webブラウザーが用意されてるなら …)\n\ncanvas や SVG などの機能で描画を行う はずで制御は JavaScript 経由, \nmatplotlib以外に次のようなグラフ・ライブラリーがあります\n\n * [Bokeh](https://docs.bokeh.org/en/latest/)\n * [Plotly](https://plotly.com/python/)\n\nPython側は [Flask](https://flask.palletsprojects.com/en/latest/) など。 \n必要に応じて [webbrowser ---\n便利なウェブブラウザコントローラー](https://docs.python.org/ja/3/library/webbrowser.html)\nなど使用するとよいかも\n\n(Flask and (Bokeh or Plotly) など検索すると記事が見つかる)\n\n### Matplotlib で UIなしの方法\n\nMatplotlibのバックエンドには 2 つの種類, UI バックエンド, (画像ファイルを作成するための)ハードコピー・バックエンドがあります\n\n> There are two types of backends: user interface backends (for use in\n> PyQt/PySide, PyGObject, Tkinter, wxPython, or macOS/Cocoa); also referred to\n> as \"interactive backends\") and hardcopy backends to make image files (PNG,\n> SVG, PDF, PS; also referred to as \"non-interactive backends\").\n\n後者の中で, `Agg` レンダラー ([Agg which uses the Anti-Grain\nGeometry](https://agg.sourceforge.net/antigrain.com/) ライブラリー) を使用すると, 手軽に(\n**小さいフットプリントで** ) ファイル作成が可能\n\n[![imgcat\nで画像表示](https://i.stack.imgur.com/gU4jv.png)](https://i.stack.imgur.com/gU4jv.png)\n\n* * *\n\nまた, sixelに対応しているターミナルエミュレーターがあるなら以下を利用し直接描画も可能です\n\n * matplotlib-sixel (backend) (複数見つかったのでオリジナル不明なためリンクは省く)\n * [sixelplot](https://github.com/kktk-KO/sixelplot)\n * [sixel-gnuplot](https://github.com/csdvrx/sixel-gnuplot)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-11-05T12:38:55.017", "id": "92015", "last_activity_date": "2022-11-05T12:38:55.017", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43025", "parent_id": "91442", "post_type": "answer", "score": 2 } ]
91442
null
91444
{ "accepted_answer_id": null, "answer_count": 0, "body": "VScodeでDQNを行うために、前段階として[Qiitaの記事](https://qiita.com/ohtaman/items/edcb3b0a2ff9d48a7def)に掲載されているものを実行してみたところ、エラーが出てしまいます。 \nエラーが出るのは以下コードの\" **dqn = DQNAgent(model=model,...** \"の箇所です。\n\n```\n\n model = tf.keras.Sequential()\n model.add(tf.keras.layers.Flatten(input_shape=(1,) + env.observation_space.shape))\n model.add(tf.keras.layers.Dense(16, kernel_initializer='he_normal', activation='relu',kernel_regularizer=tf.keras.regularizers.l2(0.01)))\n model.add(tf.keras.layers.Dense(16, kernel_initializer='he_normal', activation='relu',kernel_regularizer=tf.keras.regularizers.l2(0.01)))\n model.add(tf.keras.layers.Dense(16, kernel_initializer='he_normal', activation='relu',kernel_regularizer=tf.keras.regularizers.l2(0.01)))\n model.add(tf.keras.layers.Dense(nb_actions, activation='linear'))\n print(model.summary())\n memory = SequentialMemory(limit=50000, window_length=1)\n policy = EpsGreedyQPolicy(eps = 0.1)\n dqn = DQNAgent(model=model, nb_actions=nb_actions, memory=memory, nb_steps_warmup=10,\n target_model_update=1e-2, policy=policy)\n dqn.compile(tf.keras.optimizers.Adam(learning_rate=1e-3), metrics=['mae'])\n \n```\n\n[この記事](https://ja.stackoverflow.com/questions/65209/tensorflow-keras-keras-\nrl%E3%81%A7%E8%B5%B7%E3%81%93%E3%82%8B%E3%82%A8%E3%83%A9%E3%83%BC%E3%81%AE%E5%AF%BE%E5%87%A6%E3%81%8C%E3%82%8F%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93-typeerror-\nlen-is-not-well-\ndefined-f?newreg=87f4ba8dcafb4b418154c97b95b80d7c)や[この記事](https://qiita.com/somethingwonderful/items/e94f6d5a57052b8076c9)、[この記事](https://stackoverflow.com/questions/71978756/keras-\nsymbolic-inputs-outputs-do-not-implement-len-\nerror)を参考に手直ししてみたのですが、どうにも以下に示すようなエラーが出続けます。\n\n```\n\n TypeError: Keras symbolic inputs/outputs do not implement `__len__`. \n You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching,\n preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. \n This error will also get raised if you try asserting a symbolic input/output directly.\n \n```\n\n関係のありそうなライブラリのバージョンは、 \n**tensorflow→2.10.0 \nkeras→2.10.0 \nkeras-rl2→1.0.5 \ngym→0.26.1** \nとなっております。 \nどなたかご助力いただけると幸いです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T07:15:00.090", "favorite_count": 0, "id": "91443", "last_activity_date": "2022-10-04T07:15:00.090", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54692", "post_type": "question", "score": 0, "tags": [ "python", "tensorflow", "keras" ], "title": "TensorFlowとKeras、Keras-rl2を用いたAIの開発で起こったエラー[TypeError: Keras symbolic inputs/outputs do not implement `__len__`. ]の解決方法が知りたいです.", "view_count": 163 }
[]
91443
null
null
{ "accepted_answer_id": "91447", "answer_count": 1, "body": "openglでゲーム制作を行っているのですが,以下のようなエラーが出てしまい実行できません. \nPlaySoundはWindows固有の関数なので使えないのでしょうか?また,ほかにopenglでwavファイルを流す方法があれば教えていただきたいです.\n\n```\n\n /cygdrive/c/Users/nimon/AppData/Local/Temp/cch6fo9W.o:shadowHunter.c:(.text+0x1080): `_imp__PlaySoundA@12' に対する定義されていない参照です\n collect2: エラー: ld はステータス 1 で終了しました\n make: *** [Makefile:31: ShadowHunter.exe] エラー 1\n \n```\n\n実行したプログラムのソースコードは以下です.\n\n```\n\n #include <stdio.h>\n #include <Windows.h>\n #pragma comment(lib, \"winmm.lib\")\n int main(){\n PlaySound(TEXT(\"sample.wav\"), NULL, SND_FILENAME | SND_LOOP | SND_ASYNC);\n return 0;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T11:51:41.440", "favorite_count": 0, "id": "91445", "last_activity_date": "2022-10-04T12:47:22.527", "last_edit_date": "2022-10-04T12:06:26.773", "last_editor_user_id": "3060", "owner_user_id": "54696", "post_type": "question", "score": 0, "tags": [ "opengl", "cygwin" ], "title": "Cygwin 環境の OpenGL において音声ファイルを再生したい", "view_count": 132 }
[ { "body": ">\n```\n\n> #pragma comment(lib, \"winmm.lib\")\n> \n```\n\nこの記述はMicrosoft Visual\nC++独自の書式であり、他の環境では使えません。Windowsで資料を参照しながら開発を行うなら、素直に標準コンパイラであるVisual\nC++を使用することをお勧めします。Cygwinを利用するのは標準コンパイラを理解してからの方が混乱が少ないでしょう。\n\nなお、gccでは`-lwinmm`と指定することになりそうです。\n\n* * *\n\n> openglでwavファイルを流す方法があれば教えていただきたいです.\n\n[OpenGL](https://ja.wikipedia.org/wiki/OpenGL)はグラフィックスライブラリであり、音声は扱えないはずです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T12:47:22.527", "id": "91447", "last_activity_date": "2022-10-04T12:47:22.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "91445", "post_type": "answer", "score": 1 } ]
91445
91447
91447
{ "accepted_answer_id": null, "answer_count": 0, "body": "知りたいこと:通信をして、データをpublsihした際、具体的にソースコードのどの部分でデータが送信されているのか。\n\nやったこと:VScodeにて、ROS2のデモのtalker.cppのpublish()の定義へ移動、publishの定義から、通信を行っていそうなところから定義へ移動…と繰り返し、探した。定義が複数参照された場合、Ubuntu\n18.04でbuildしたROS2eloquentのソースコードにprint文などを加え、talkerを動かしたときに変化するか確認した。\n\n現在:上記の方法で行き詰まり、VScodeでUDPと検索し、UDPTransportInterface.cppのUDPTransportInterface::send()を見つけ、ソースコードを書き換え確認したが、talker.cppのpublsih()の部分を消してもUDPTransportInterface::sendは走っているようで、publishするタイミングで動いているわけではないので、データを送っている部分ではないと推測した。\n\n通信をしている部分を知っている方、正しい探し方を知っている方、ご教授ください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T12:17:00.173", "favorite_count": 0, "id": "91446", "last_activity_date": "2022-10-05T10:54:06.410", "last_edit_date": "2022-10-05T10:54:06.410", "last_editor_user_id": "3060", "owner_user_id": "54697", "post_type": "question", "score": 0, "tags": [ "c++" ], "title": "ROS2のソースコードのうち、通信を行っている部分を知りたい", "view_count": 98 }
[]
91446
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "Windows11 Unity2021.3.11f.1 \nTPSのゲームでエルデンリングみたいなゲームを作っていて、RigidBody.Addforceでプレイヤーを移動させています。カメラの向きに対してWASDで移動し、RigidbodyのVelocityのXとZのsqrMagnitudeで速度の制限をします。\n\nですがRigidbodyのVelocityが5,6フレーム毎に0になり、思っているような動作にならないです。 \nVelocityの値で走るのと歩くアニメーションを切り替えているのでアニメーションがカクカクします。 \nまた、移動速度が想定道理にいかないです。\n\nネットでいろいろ解決策を調べましたが、求めている情報がなく解決しませんでした。 \nまた、2020.3.1f1のバージョンで作っていた同じゲームでは、まったく同じプログラムでRigidbodyの値も同じにしてもこの問題は起こりませんでした。 \n変わったこととしては、URPのプロジェクトでUnityChanSpringBoneとUniversalToonShaderforURPっていうPackageを使って(?)ます。 \nあとisSleeping()は常にFalseでした。\n\n↓多分必要そうなの\n\n```\n\n void Update()\n {\n var horizontal = Input.GetAxis(\"Horizontal\");\n var vertical = Input.GetAxis(\"Vertical\");\n var cameraRotation = Quaternion.AngleAxis(cameraTransform.eulerAngles.y, Vector3.up); //Cameraの角度\n var playerVector = cameraRotation * new Vector3(horizontal, 0, vertical).normalized;//進む方向\n var velocity = new Vector2(rb.velocity.x, rb.velocity.z).sqrMagnitude; //Playerの速度\n var speed = runSpeed;\n var speedLimit = runSpeedLimit;\n animator.SetFloat(\"Velocity\", velocity);\n Debug.Log(velocity);\n \n //↓移動させてる\n if (velocity < speedLimit)\n {\n rb.AddForce(playerVector * speed, ForceMode.Accelaration); \n }\n \n```\n\n↓全文\n\n```\n\n using System.Collections;\n using System.Collections.Generic;\n using UnityEngine;\n using UnityEngine.UI;\n using UnityEngine.SceneManagement;\n \n public class PlayerController : MonoBehaviour\n {\n int health = 1000, stamina = 1000, mana = 1000;\n Transform playerTransform, cameraTransform;\n Rigidbody rb;\n Animator animator;\n Quaternion targetRotation;\n float runSpeed = 100, sprintSpeed = 200, runSpeedLimit = 15, sprintSpeedLimit = 30;\n bool moveable = true, staminable = true;\n enum playerState\n {\n LOCOMOTION,\n ATTACK,\n }\n playerState state = playerState.LOCOMOTION;\n \n void Awake()\n {\n Application.targetFrameRate = 60;\n }\n void Start()\n {\n playerTransform = gameObject.transform;\n cameraTransform = Camera.main.transform;\n rb = gameObject.GetComponent<Rigidbody>();\n animator = gameObject.GetComponent<Animator>();\n }\n \n void Update()\n {\n PlayerDead();\n Move();\n Attack();\n }\n \n void Move()\n {\n var horizontal = Input.GetAxis(\"Horizontal\");\n var vertical = Input.GetAxis(\"Vertical\");\n var cameraRotation = Quaternion.AngleAxis(cameraTransform.eulerAngles.y, Vector3.up); //Cameraの角度\n var playerVector = cameraRotation * new Vector3(horizontal, 0, vertical).normalized;//進む方向\n var velocity = new Vector2(rb.velocity.x, rb.velocity.z).sqrMagnitude; //Playerの速度\n var speed = runSpeed;\n var speedLimit = runSpeedLimit;\n animator.SetFloat(\"Velocity\", velocity);\n Debug.Log(velocity);\n Debug.Log(rb.IsSleeping());\n \n //回転\n if (playerVector.sqrMagnitude >= 0.25f)\n {\n targetRotation = Quaternion.LookRotation(playerVector, Vector3.up);\n }\n transform.rotation = Quaternion.RotateTowards(playerTransform.rotation, targetRotation, 25.0f);\n \n //スタミナ\n if (stamina <= 1)\n {\n staminable = false;\n }\n else if (stamina >= 100)\n {\n staminable = true;\n }\n \n //移動速度\n if (Input.GetKey(KeyCode.LeftShift) && staminable)\n {\n speed = sprintSpeed;\n speedLimit = sprintSpeedLimit;\n stamina--;\n }\n else\n {\n if (stamina < 1000)\n {\n stamina++;\n }\n }\n \n //移動\n if (velocity < speedLimit)\n {\n rb.AddForce(playerVector * speed, ForceMode.Acceleration); ;\n }\n }\n \n void Attack()\n {\n \n }\n \n void PlayerDead()\n {\n \n }\n }\n \n \n```\n\n↓Console \n3.402671 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402681 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n0 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n14.47523 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402697 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.40266 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402671 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n0 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n14.47524 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n0 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n14.47524 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\nFalse \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:53) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)\n\n3.402676 \nUnityEngine.Debug:Log (object) \nPlayerController:Move () (at Assets/Scripts/PlayerController.cs:52) \nPlayerController:Update () (at Assets/Scripts/PlayerController.cs:38)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T13:27:47.193", "favorite_count": 0, "id": "91449", "last_activity_date": "2022-10-04T13:27:47.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54699", "post_type": "question", "score": 0, "tags": [ "c#", "unity3d" ], "title": "RigidBodyのSpeedが数フレームごとに0になる", "view_count": 163 }
[]
91449
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "UnityでProBuilderを使用して作ったステージ内に、複数のモデルを配置したものを作っています。 \nライトは「Realtime」のものと「Baked」のものがそれぞれ複数あり、ベイクしています。 \nWebGLにビルドし、ブラウザでプレイします。\n\nエディタ上でプレイする分には全く問題なく動いています(画像①) \nしかし、ビルドしてブラウザで実行すると、一部の壁や天井が真っ黒になり、反対の壁が余計に明るくなってしまいます。(画像②)\n\nまた、ビルドした直後もエディタ上で同様に暗く表示されます。(画像③) \nエディタ上のどこかをクリック(Unityをアクティブにする)と戻ります。(画像④)\n\n・数日前まではブラウザでも問題なく動いていました。 \n・ライトをベイクしない状態でビルドすると、エディタ上でもブラウザでも同じように表示されます。 \n・暗くなってる面はXYZそれぞれマイナス方向を向いてる面のような気がします。 \n・ライトのベイクのやり直しや、Unity、PCの再起動は何度かしてます。 \n・同様の作りになってる別シーン(以前ライトのベイク済み)をビルドすると問題無く動くので、ビルドに問題は無いと思います。 \n・しかし、同様の作りになってる別シーンに対し、改めてライティングのビルドを行うと、今回の暗くなる問題が起きました。(おそらくライトのビルドの問題?) \n・Unityのバージョンは2021.1.1f1です。\n\n①エディタ上では問題なし \n[![①エディタ上では問題なし](https://i.stack.imgur.com/m0FpH.jpg)](https://i.stack.imgur.com/m0FpH.jpg)\n\n②ブラウザだと壁が暗い \n[![②ブラウザだと壁が暗い](https://i.stack.imgur.com/CLKiL.jpg)](https://i.stack.imgur.com/CLKiL.jpg)\n\n③ビルド直後も暗い \n[![③ビルド直後も暗い](https://i.stack.imgur.com/UgW2d.png)](https://i.stack.imgur.com/UgW2d.png)\n\n④クリックすると治る \n[![④クリックすると治る](https://i.stack.imgur.com/EYJzm.png)](https://i.stack.imgur.com/EYJzm.png)\n\nライトの設定 \n[![ライトの設定](https://i.stack.imgur.com/WgITL.png)](https://i.stack.imgur.com/WgITL.png) \n[![ライトの設定](https://i.stack.imgur.com/nf2mn.png)](https://i.stack.imgur.com/nf2mn.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-04T15:00:35.160", "favorite_count": 0, "id": "91450", "last_activity_date": "2023-05-31T11:01:20.173", "last_edit_date": "2022-10-04T23:07:35.600", "last_editor_user_id": "54701", "owner_user_id": "54701", "post_type": "question", "score": 0, "tags": [ "unity3d" ], "title": "Unityでベイクしたライトが一部真っ黒になる", "view_count": 1115 }
[ { "body": "Lightingの設定の「DirectionalMode」を「Non-Directional」に変更したところ解決いたしました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-06T06:33:59.547", "id": "91468", "last_activity_date": "2022-10-06T06:33:59.547", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "54701", "parent_id": "91450", "post_type": "answer", "score": 0 } ]
91450
null
91468
{ "accepted_answer_id": null, "answer_count": 0, "body": "Pythonを使って、OpenCVのVideo Stabilization処理を実施したいと思います。\n\n<https://docs.opencv.org/4.6.0/d5/d50/group__videostab.html>\n\n上記のAPIリファレンスには、C++のリファレンスなのでPythonからどのように上記機能を呼び出してよいのかわからないのですが、pythonのAPIリファレンスがないということはサポートされていない機能なのでしょうか?\n\nそれとも、C++のAPIリファレンスとPythonのAPIには、何かしらの関連性があり、C++のAPIからPythonのAPIが類推できるようになっているのでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-10-05T01:44:19.960", "favorite_count": 0, "id": "91454", "last_activity_date": "2022-10-05T05:04:15.843", "last_edit_date": "2022-10-05T05:04:15.843", "last_editor_user_id": "3060", "owner_user_id": "4260", "post_type": "question", "score": 0, "tags": [ "python", "opencv" ], "title": "Python から OpenCV の Video Stabilization を呼び出すには?", "view_count": 167 }
[]
91454
null
null