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": 1, "body": "### 目標\n\nhtmlの74~87行の部分をスクロールして見えてきた時にフェードインさせることです。 \n・Our Serviceが下に \n・image/black.png が上に \n・image/educure01.jp DXを推進するエンジニア育成 \nIT事業参入をご検討中の事業者様向けのサービスです。 が上に \nfaideinさせたいです。\n\n### 問題点\n\n一部設定してみました。cssは機能しているがjavascriptで止まっています。 \n今回のfadeinの設定しているのが30-42列目にあたります。 \n一部ずつ変更してみたりして改善していますが機能しません。\n\nエラーは出ていません。 \nご意見よろしくお願いします。\n\nHTML\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <title>株式会社LiNew</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\">\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n <link href=\"https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@700&display=swap\" rel=\"stylesheet\">\n <script src=\"jsscript.js\"></script>\n <script src=\"https://code.jquery.com/jquery-1.12.4.js\"></script>\n \n <script src=\"https://code.jquery.com/jquery-2.2.4.js\" integrity=\"sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=\" crossorigin=\"anonymous\"></script>\n <script>\n $(function(){\n $(window).scroll(function(){\n $(\".fadeIn\").each(function(){\n var targetElement = $(this).offset().top;\n var scroll = $(window).scrollTop();\n var windowHeight = $(window).height();\n if (scroll > targetElement - windowHeight) {\n $(this).addClass(\"is-show\");\n } else {\n $(this).removeClass(\"is-show\");\n }\n });\n });\n });\n </script>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n </head>\n <body>\n <section>\n <div class=our-service>\n <div id=\"content1\" class=\"show\">\n <div class=\"Our-Service fadeIn_down fadeIn\">\n <h1>Our Service</h1>\n </div>\n <div class=\"content1-wrp\">\n <li class=\"fadeIn_up fadeIn\">\n <div class=\"content1-imgs1\">\n <img src=\"image/educure01.jpg\">\n </div>\n <div class=\"servis-text\">\n <img class=img1 src=\"./image/black.png\" alt=\"\">\n <p class=first-text>DXを推進するエンジニア育成</p>\n <p class=second-text>IT事業参入をご検討中の事業者様向けのサービスです。</p>\n </div>\n </li>\n </div>\n </div>\n </div>\n </section>\n </body>\n </html>\n \n```\n\ncss\n\n```\n\n #content1{\n margin: auto;\n padding-top: 125px;\n }\n \n .content1-wrp{\n display: flex;\n }\n \n h1{\n font-size: 28px;\n font-family: 'Noto Sans JP', sans-serif;\n border-top: solid 2px #2da690;\n max-width: 200px;\n margin: 0 auto;\n font-weight: 500px;\n text-decoration: none;\n padding-top: 4px;\n text-align:center;\n white-space: nowrap;\n }\n \n \n .fadeIn_down {\n opacity: 0;\n transform: translateY(-20%);\n transition: 1s;\n }\n \n .fadeIn_Down.is-show {\n transform: translate(0, 0);\n opacity: 1;\n }\n \n \n .content1-imgs1 img{\n height:665px;\n width: 665px;\n object-fit: contain;\n right: 42vw;\n bottom: -37vw;\n }\n \n .servis-text{\n height: 340.5px;\n width: 672px;\n position: absolute;\n right: 9vw;\n bottom: -50vw;\n background-color: #fff;\n opacity: 0.9;\n font-family: 'Noto Sans JP', sans-serif;\n \n }\n \n .img1{\n display: flex;\n height:100px;\n width: 200px;\n object-fit: contain;\n position: relative;\n margin:40px;\n margin-top: 10px;\n }\n \n .first-text{\n font-size: 32px;\n margin: -20px 0 20px 45px;\n }\n \n .second-text{\n margin:0 0 20px 45px;\n opacity: 0.5;\n }\n \n .fadeIn_up {\n opacity: 0;\n transform: translate(0, 20px);\n }\n \n .fadeIn_up.is-show {\n transform: translate(0, 0);\n opacity: 1;\n transition: all 1s ease-out;\n }\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T08:42:58.277", "favorite_count": 0, "id": "86268", "last_activity_date": "2022-02-11T09:59:34.113", "last_edit_date": "2022-02-11T09:59:34.113", "last_editor_user_id": "51050", "owner_user_id": "51050", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "css" ], "title": "javascriptでフェードインさせたい", "view_count": 104 }
[ { "body": "要件をすべて修正しているわけではありませんが動かない原因を述べます\n\nまずスクリプトですが、 `.fadeIn`\nというfadeInクラスがついたdomを取得しにいっていますが、HTML上fadeInクラスがついたタグはありません\n\n```\n\n $(function(){\n $(window).scroll(function(){\n $(\".fadeIn\").each(function(){\n var targetElement = $(this).offset().top;\n var scroll = $(window).scrollTop();\n var windowHeight = $(window).height();\n if (scroll > targetElement - windowHeight) {\n $(this).addClass(\"scrollin\");\n } else {\n $(this).removeClass(\"scrollin\");\n }\n });\n });\n });\n \n```\n\n`fadeIn_up` と `fadeIn_down`\nが既存のHTMLにあるため恐らくこれらの要素だと推測します。このため以下のようにfadeInクラスを追加するようにを修正します\n\n```\n\n <div class=\"Our-Service fadeIn_down fadeIn\">\n <h1>Our Service</h1>\n </div>\n <!-- 省略 -->\n <div class=\"content1-wrp\">\n <div class=\"fadeIn_up fadeIn\">\n <!-- 省略 -->\n </div>\n </div>\n \n```\n\n次にスクリプトでクラスの付け外しをしている処理です。以下の箇所で表示要素が画面内 \nなら `scrollin` クラスを付加し画面外なら `scrollin` クラスを削除するスクリプトだと推測します\n\n```\n\n if (scroll > targetElement - windowHeight) {\n $(this).addClass(\"scrollin\");\n } else {\n $(this).removeClass(\"scrollin\");\n }\n \n```\n\ncssを見ると `scrollin` クラスではなく `is-show` クラスの付け外しを考えてるように推測できるためそちらに変更します\n\n```\n\n if (scroll > targetElement - windowHeight) {\n $(this).addClass(\"is-show\");\n } else {\n $(this).removeClass(\"is-show\");\n }\n \n```\n\n以上の2点の修正で表示ができるのではないでしょうか\n\n余談ですがsectionタグ閉じ忘れになっています", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T09:27:48.197", "id": "86271", "last_activity_date": "2022-02-11T09:27:48.197", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "298", "parent_id": "86268", "post_type": "answer", "score": 0 } ]
86268
null
86271
{ "accepted_answer_id": "86272", "answer_count": 2, "body": "このようなcsvファイルに対して、9列目=1.00 のときは3列目を出力し、9列目=0.00 のときは0またはスキップという処理を行いたいです。 \nexcelで行うと `=IF(J2=1,D2,\"\")` という処理になります。 \nfor文の中でif文を使う部分で躓いております。\n\n[![csv](https://i.stack.imgur.com/DTgdh.png)](https://i.stack.imgur.com/DTgdh.png)\n\n```\n\n import csv\n \n with open('/Users/abc/Desktop/sample.csv', \"r\") as df1:\n csv.reader(df1)\n for row in csv.reader(df1):\n if row[9] == 1:\n con.append(row[3])\n elif row[9] == 0:\n con.append(0)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T08:51:29.007", "favorite_count": 0, "id": "86269", "last_activity_date": "2022-03-15T11:40:35.597", "last_edit_date": "2022-02-12T05:12:29.633", "last_editor_user_id": "3060", "owner_user_id": "51382", "post_type": "question", "score": 0, "tags": [ "python", "csv" ], "title": "CSV から条件を満たした数値だけを抽出したい", "view_count": 2920 }
[ { "body": "[csv.reader](https://docs.python.org/ja/3/library/csv.html#csv.reader)は文字列(str)として値を読み込むのが原因だと思います。(下記はリンク先抜粋)\n\n> csv ファイルから読み込まれた各行は、文字列のリストとして返されます。QUOTE_NONNUMERIC\n> フォーマットオプションが指定された場合を除き、データ型の変換が自動的に行われることはありません\n> (このオプションが指定された場合、クォートされていないフィールドは浮動小数点数に変換されます)。\n\n文字列と数値をそのまま比較すると正しく比較できず常に`False`となるので、適切にキャストをしてください。\n\n```\n\n import csv\n \n with open('sample.csv', \"r\") as df1:\n con = []\n csv.reader(df1)\n for row in csv.reader(df1):\n if int(row[9]) == 1:\n con.append(row[3])\n elif int(row[9]) == 0:\n con.append(0)\n print(con)\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T09:07:15.280", "id": "86270", "last_activity_date": "2022-02-11T09:07:15.280", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "86269", "post_type": "answer", "score": 1 }, { "body": "pandas 使う方法もあります \nたいていは数値化してくれるけど, 時々 型指定の必要がある場合も。 \nまた, pandasは 全体的に 素の Pythonとは異なる部分もあり, 人によってはオススメだけど, 合わない人には合わない\n\n(処理の前半は CSVの生成)\n\n```\n\n import pandas as pd\n import numpy as np\n import io\n cnt = 10\n rng = np.random.default_rng()\n with io.StringIO() as fp:\n pd.DataFrame({\n 'A': rng.integers(150, size=cnt),\n 'B': rng.random(size=cnt) *20,\n 'C': np.zeros(cnt),\n 'D': rng.choice(a=[0,1], size=cnt),\n }).to_csv(fp, index=False)\n \n fp.seek(0)\n df = pd.read_csv(fp) # CSV読み込み, ヘッダー付き\n \n df['val'] = df[df['D'] == 1]['B'] # 該当する項目 'D'が 1の場合は, 'B'の項目をセット\n df.style.hide(axis='index').highlight_null(null_color='yellow')\n \n```\n\n[![結果](https://i.stack.imgur.com/neSao.png)](https://i.stack.imgur.com/neSao.png)\n\n* * *\n\n#### 追記\n\n別解(?)として記したけれど, pandas使うのなら, 読んでおくとよいかもなドキュメントあります。\n\n * Cookbook: <https://pandas.pydata.org/pandas-docs/stable/user_guide/cookbook.html>\n * Cheat Sheet: <https://github.com/pandas-dev/pandas/tree/main/doc/cheatsheet>\n\n`IF()` の処理について …\n\n```\n\n excelで行うと =IF(J2=1,D2,\"\") という処理になります。\n \n```\n\n(上記 Cookbook内に記載あり)\n\n```\n\n # pandasで同様な処理は, if-then…\n df.loc[df.AAA >= 5, \"BBB\"] = -1\n \n # if-then-else 形式の処理は, NumPyで指定可能\n df[\"logic\"] = np.where(df[\"AAA\"] > 5, \"high\", \"low\")\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T12:42:36.893", "id": "86272", "last_activity_date": "2022-03-15T11:40:35.597", "last_edit_date": "2022-03-15T11:40:35.597", "last_editor_user_id": "43025", "owner_user_id": "43025", "parent_id": "86269", "post_type": "answer", "score": 1 } ]
86269
86272
86270
{ "accepted_answer_id": "86275", "answer_count": 2, "body": "興味がありC言語について勉強中です。\n\nstrlen()関数がカウントできる(戻り値としてリターンできる)最大文字数はいくつになりますか?\n\n戻り値の型は確か`size_t`\nだったと思いますが、実行環境やコンパイラによって最大値が変わる場合、何を見れば/どこを調べれば、戻り値の最大文字数がいくつであると分かるでしょうか。\n\nちなみにmacOS 10.14.6 利用しており、プロセッサは `3.1 GHz Intel Core i7` と表示があるので 64bit\nPCなのかなと思いますがこちらが関係しそうでしょうか(Core i7だったらどのような場合でも絶対に64bitになりますか?)\n\n下記のようなサンプルコードで何文字までカウントできるか試してみましたが、840万文字付近でエラー = segmentation fault\nとなりました。`int` としている箇所の型をすべて `size_t`\nとしても同様です。最大値とそれを超える値の境目(しきい値)を実際に目で確認したかったのですが、もし他に良い検証方法があればそちらもご教授いただけたら嬉しいです。\n\n```\n\n int main(void)\n {\n // int num = INT_MAX; // segmentation fault\n // int num = 8400000; // segmentation fault\n int num = 8350000; // OK\n char str[num];\n int i = 0;\n int j = num - 1;\n \n while (i < j) {\n str[i] = '1';\n i++;\n }\n str[i] = '\\0';\n printf(\"%zu\\n\", strlen(str)); // 出力: 8349999\n return (0);\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T14:30:04.710", "favorite_count": 0, "id": "86274", "last_activity_date": "2022-02-13T05:57:58.333", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43186", "post_type": "question", "score": 3, "tags": [ "c" ], "title": "C言語で strlen() 関数がカウントできる最大文字数はいくつでしょうか?", "view_count": 651 }
[ { "body": "`strlen()`自体に制限はありません。戻り値は`size_t`なのでこの最大値まで可能です。 \nあとはどれだけ長い文字列を用意できるかの問題であり、そこは`strlen()`とは無関係です。\n\n> 840万文字付近でエラー = segmentation fault となりました。\n\n>\n```\n\n> int num = 8350000; // OK\n> char str[num];\n> \n```\n\nこのコードはスタック領域上に変数を確保するものであり、スタックサイズを超えることはできません。840万文字付近が限界なら、それがその環境のスタックサイズの限界なのでしょう。`malloc()`等を使用するとスタック領域ではなくより広いヒープ領域上にメモリ確保できます。\n\n* * *\n\n> 最大値とそれを超える値の境目(しきい値)を実際に目で確認したかったのですが、もし他に良い検証方法があればそちらもご教授いただけたら嬉しいです。\n\n`strlen()`のソースコードを読んでみるのはどうでしょうか?\n\n * glibc: <https://github.com/bminor/glibc/blob/master/string/strlen.c>\n * newlib: <https://github.com/bminor/newlib/blob/master/newlib/libc/string/strlen.c>\n\n最適化されていて複雑ですが、newlibで最適化部分を排除すれば簡単に読めるかもしれません。\n\n```\n\n size_t\n strlen (const char *str)\n {\n const char *start = str;\n while (*str)\n str++;\n return str - start;\n }\n \n```\n\nとなっていて、文字列長に依存しない実装であることは簡単に読み取れるかと思います。\n\n追記:\nあくまでglibcやnewlibの実装をあげたものですが、macOSにおいても同様の実装がされているはずですので、必要であれば実際のソースコードを確認してください。\n\n* * *\n\noririさんの回答はいろいろと問題があるので、指摘しておきます。\n\n> macOS での C-Compilerは gccのようです\n\nコメントにも書きましたが、実行ファイル名を取り上げることに意味はありません。gccという名前から[GNU Compiler\nCollection](https://ja.wikipedia.org/wiki/GNU%E3%82%B3%E3%83%B3%E3%83%91%E3%82%A4%E3%83%A9%E3%82%B3%E3%83%AC%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3)が連想されますが、実際には[Clang](https://ja.wikipedia.org/wiki/Clang)のはずです。ちなみにClangを作ったのはAppleです。\n\nまた、macOSの質問なのでLinuxのman pageを見ることに意味はありません。素直にmacOSのman\npageを見るべきです。[`strlen(3)`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/strlen.3.html)も用意されています。\n\n> OSというか CPUが 32bitモードか 64bitモード(で動いてる)かで `size_t` (`__SIZE_TYPE__`)\n> のサイズは変わります。\n\n前指摘とも関係しますが、CPUのサイズに意味はありません。質問のIntelプロセッサーなら16bitモードも存在します。ハードウェア(CPU)にそのような機能があるとしても、プラットフォーム(OS)としてハードウェアのモードを設定し、併せて`size_t`が何ビットなのかを規定しています。その意味でLinuxのman\npageを読むのも適切ではありません。\n\n同様にコンパイラーもあくまでプラットフォームの規定に従っているだけであり、コンパイラーがビット数を定めているわけではありません。余談ですが、Windowsプラットフォームにおいて`long\ndouble`は64bitと定められていますが、[MinGWのgccはこの規定に従わず`long\ndouble`を96bitとして扱っているため`printf`が正しく動作しない問題](https://ja.stackoverflow.com/a/34023/4236)が発生していたりします。その意味でコンパイラーが何であるかを意識するのも適切ではありません。\n\nもちろん、質問のmacOSではなくLinuxについての情報を参考として載せるのは構いませんが、全体としてmacOSの情報であるかのようにミスリーディングしている印象を受けます。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T14:51:28.077", "id": "86275", "last_activity_date": "2022-02-12T21:30:27.723", "last_edit_date": "2022-02-12T21:30:27.723", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "86274", "post_type": "answer", "score": 6 }, { "body": "macOS での C-Compilerは ~~gcc LLVM-gcc~~ 「Xcodeの gccを呼び出すとclangが呼び出される」のようです。 \nLinuxの man pageだけど, GCCフロントエンドとして簡単に探したもの (他意はありません)\n\n * [size_t strlen(const char *s)](https://linuxjm.osdn.jp/html/LDP_man-pages/man3/strlen.3.html) … `strlen()` は `size_t` を返す\n * [void *malloc(size_t size )](https://linuxjm.osdn.jp/html/LDP_man-pages/man3/malloc.3.html)\n\n`size_t` の大きさは環境依存で, ユーザー空間での gccでの場合は (カーネル空間の場合は話は別)\n\n```\n\n typedef __SIZE_TYPE__ size_t;\n \n```\n\n参考 (stackoverflow.com):\n\n * (Linuxだけど) [Where is c++ size_t defined in linux](https://stackoverflow.com/questions/12490622/where-is-c-size-t-defined-in-linux)\n * (ちょっと昔だけど) [Why is there ambiguity between uint32_t and uint64_t when using size_t on Mac OS X?](https://stackoverflow.com/questions/11603818/why-is-there-ambiguity-between-uint32-t-and-uint64-t-when-using-size-t-on-mac-os)\n\n* * *\n\nOSというか CPUが 32bitモードか 64bitモード(で動いてる)かで `size_t` (`__SIZE_TYPE__`) のサイズは変わります。 \nx86系 CPUの最近のものや, あるいは ARM系のパワフル方面のは, 32bitモードでも 64bitモードでもどちらでも稼働可能,\nなはず。64bitモードで稼働していれば `__SIZE_TYPE__` は 8 Bytesです (`unsigned long int`)\n\n* * *\n\n#### (追記)\n\n(macOS としてだけではなくモダンな) C言語での記述方法として, 以下の記事があります\n\n * [2016年、C言語はどう書くべきか (前編)](https://postd.cc/how-to-c-in-2016-1/)\n * [2016年、C言語はどう書くべきか (後編)](https://postd.cc/how-to-c-in-2016-2/)\n\n内容そのままでは長いけれど, 下手に抜粋すると正しく伝わらないかもなので「システム依存の型」「その他の型」ついて引用します\n\n> システム依存の型\n>\n> まだ「32 bitのプラットフォームでは32 bitのlong型、64 bitのプラットフォームでは64\n> bitのlong型がいい」という不満があるようですね。\n>\n> プラットフォームに依存する2つの異なるサイズを使うため、 故意に コードを難しくすることを考えたくなければ、システム依存の型のために `long`\n> を使おうとは思わないでしょう。\n>\n> この状況では、プラットフォームのためにポインタ値を保持する整数型、`intptr_t` を使うべきです。\n>\n> モダン32-bitプラットフォームでは、`intptr_t` は `int32_t` です。\n>\n> モダン64-bitプラットフォームでは、`intptr_t` は `int64_t` です。\n>\n> `intptr_t` は `uintptr_t` の形でもあります。\n>\n> ポインタのオフセットを保持するためには、名が体を表す通りの `ptrdiff_t` を使います。これは、ポインタの差分の値を格納するのに適した型です。\n\n> その他の型\n>\n> 最も頻繁に使われるシステム依存の型は、`size_t`\n> で、[stddef.h](http://pubs.opengroup.org/onlinepubs/7908799/xsh/stddef.h.html)\n> に定義されています。\n>\n> `size_t` は基本的に「最大の配列インデックスを保持できる整数」ですが、プログラム内の最大のメモリオフセットを保持が可能という意味もあります。\n>\n> 実際の用途としては、`size_t` は `sizeof` オペレータの戻り値の型です。\n>\n> いずれにしても、`size_t` は全てのモダンプラットフォーム上の `uintptr_t` と同様になるよう、 実用的に\n> 定義されます。そのため、32-bitプラットフォームでは、`size_t` は `uint32_t`\n> であり、64-bitプラットフォームでは、`size_t` は `uint64_t` です。\n>\n> 他にも、`ssize_t` があり、これはライブラリ関数からの返り値として使われる符号付きの `size_t` で、エラーの際に `-1`\n> を返します(注: `ssize_t` はPOSIXであり、Windowsインターフェースには適用されません)。\n>\n> では、あなたの関数パラメータ内で、任意のシステム依存型のサイズのための `size_t` を使うべきでしょうか。技術的には、`size_t` は\n> `sizeof` の戻り値の型なので、バイト数を表したサイズ値を受け取る関数は全て `size_t` に変換できます。\n>\n> 他の用法には次のものが含まれます。: `size_t` はmallocに渡される引数の型であり、`ssize_t` は `read()` と\n> `write()` の戻り値の型です(`ssize_t` が存在せず、戻り値がただの `int` であるWindowsの場合を除きます)。", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T15:35:54.460", "id": "86276", "last_activity_date": "2022-02-13T05:57:58.333", "last_edit_date": "2022-02-13T05:57:58.333", "last_editor_user_id": "3060", "owner_user_id": "43025", "parent_id": "86274", "post_type": "answer", "score": -1 } ]
86274
86275
86275
{ "accepted_answer_id": null, "answer_count": 1, "body": "いろんな記事をみていると、ActiveRecordの、allやwhereは、ActiveRecord::Relationのオブジェクトを返すメソッドで実際にDBにアクセスしていないって話なんですが、 \n試しに自分のrails consoleで試したところ普通にDBにアクセスして取得できているんですよね。\n\n```\n\n Recruiter.all \n => Recruiter Load (1.7ms) SELECT \"recruiters\".* FROM \"recruiters\"\n [#<Recruiter:0x000055e9db560f48\n id: \"0abf31a2-e39f-472a-bb8f-fcb3016d62f8\",\n last_name: \"foo\",\n first_name: \"bar\",\n email: \"[email protected]\",\n created_at: Wed, 09 Feb 2022 17:57:33 JST +09:00,\n updated_at: Wed, 09 Feb 2022 17:57:33 JST +09:00,\n phone_number: \"0010002000\">]\n \n```\n\nログをみても、普通にSQLが発行されています。\n\n```\n\n Recruiter Load (2.4ms) SELECT \"recruiters\".* FROM \"recruiters\"\n \n```\n\nですが、一方でloaded?を実行するとfalseがかえるんですよね。\n\n```\n\n Recruiter.all.loaded?\n => false\n \n```\n\n自分が期待する動きは、Recruiter.allをしてもDBにアクセスせずSQLも発行しないはずなんですが、間違っていますか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-11T22:02:41.980", "favorite_count": 0, "id": "86277", "last_activity_date": "2022-02-12T05:04:18.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "40650", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails" ], "title": "rails consoleにて、モデル名.allはActiveRecord Relationを返すメソッドなのにDBアクセスしている、これは正しい?", "view_count": 282 }
[ { "body": ">\n> ActiveRecordの、allやwhereは、ActiveRecord::Relationのオブジェクトを返すメソッドで実際にDBにアクセスしていないって話なんですが、 \n> : \n> 自分が期待する動きは、Recruiter.allをしてもDBにアクセスせずSQLも発行しないはずなんですが、間違っていますか?\n\nその認識が誤ってるわけではありません。`ActiveRecord::Relation`オブジェクトは実際に評価されるタイミングで初めてDBにアクセスします。\n\nではなぜそう見えないかというと、\n\n 1. コンソールで`Recruiter.all`を実行\n 2. `ActiveRecord::Relation`オブジェクトが帰ってくる\n 3. コンソールはオブジェクトを画面に表示するため\"#inspect\"を呼ぶ\n 4. `ActiveRecord::Relation`オブジェクトはDBにアクセスしにいく\n\nとなっているからです。一方で`Recruiter.all.loaded?`の場合は、コンソールが表示するのは`Recruiter.all.loaded?`の結果なので、DBにはアクセスしません。\n\n`result=Recruiter.all`してから`result`を呼ぶとそのタイミングでDBにアクセスしてるのがわかると思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T05:04:18.253", "id": "86283", "last_activity_date": "2022-02-12T05:04:18.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "86277", "post_type": "answer", "score": 2 } ]
86277
null
86283
{ "accepted_answer_id": null, "answer_count": 1, "body": "ワードプレスでブログを作成していますが、突然、記事の編集や新規投稿ができなくなり、以下のようなエラーメッセージが出てきました。記事が編集&新規投稿できるようリカバリーしたいです。\n\n```\n\n Notice: fread(): read of 8192 bytes failed with errno=21 Is a directory in/home/c7006248/public_html/ondine199918.com/wp-includes/functions.php on line 6574\n \n```\n\nサーバーはConoHa WING 、ブログテーマは、Affinger6を使用しています。 \n記事自体は閲覧することができます。 \n<https://ondine199918.com/>\n\nエラーの住所にある通り、ConoHa WINGのファイルマネージャーでディレクトリ、ファイルをみてみました。\n\nエラー行6574の表示は、\n\n```\n\n $file_data = fread( $fp, 8 * KB_IN_BYTES );\n \n```\n\nで、周辺コードは、\n\n```\n\n */\n function get_file_data( $file, $default_headers, $context = '' ) {\n // We don't need to write to the file, so just open for reading.\n $fp = fopen( $file, 'r' );\n \n if ( $fp ) {\n // Pull only the first 8 KB of the file in.\n $file_data = fread( $fp, 8 * KB_IN_BYTES );\n \n \n // PHP will close file handle, but we are good citizens.\n fclose( $fp );\n } else {\n $file_data = '';\n }\n \n```\n\nとなっています。\n\nどなたかお力添えいただけますと、幸いです。 \nよろしくお願いいたします。\n\n追記: \n現在のワードプレスのバージョンは5.9で、これがエラー発生前なのか後なのかは分からないです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T00:59:02.353", "favorite_count": 0, "id": "86280", "last_activity_date": "2022-02-24T11:29:03.763", "last_edit_date": "2022-02-12T08:55:24.573", "last_editor_user_id": "51389", "owner_user_id": "51389", "post_type": "question", "score": 0, "tags": [ "php", "wordpress" ], "title": "WordPressエラーについて Notice: fread(): read of 8192 bytes failed with errno=21 Is a directory in", "view_count": 383 }
[ { "body": "@yyz さんの言っているように、ファイル(画像など)を指定しているのに、ディレクトリ(/で終わるURLとか)を指定してしまっていませんか? \n**Notice** なので「致命的でないので今はとりあえずよしとする」という場合は、 \n一番最初のディレクトリにあるファイルwp-config.phpにある\n\n```\n\n define('WP_DEBUG', true);\n \n```\n\nを\n\n```\n\n define('WP_DEBUG', false);\n \n```\n\nにするととりあえず表示されなくなります。 \n解決方法が見つかったら直すとよいですね。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-24T11:29:03.763", "id": "86556", "last_activity_date": "2022-02-24T11:29:03.763", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51589", "parent_id": "86280", "post_type": "answer", "score": 0 } ]
86280
null
86556
{ "accepted_answer_id": "86282", "answer_count": 1, "body": "特別ツールバー内のそれぞれのアイコンの並び順を変更するにはどうすればいいでしょうか。\n\n例えば「検索」では赤丸で囲んだ「正規表現を使用する」のボタンを一番左(=検索窓のすぐ右)に持っていきたいです。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/0gEBW.png)](https://i.stack.imgur.com/0gEBW.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T02:55:41.470", "favorite_count": 0, "id": "86281", "last_activity_date": "2022-02-12T03:47:14.230", "last_edit_date": "2022-02-12T03:47:14.230", "last_editor_user_id": "3060", "owner_user_id": "43123", "post_type": "question", "score": 0, "tags": [ "emeditor" ], "title": "特別ツールバー内の並び順を変更したい", "view_count": 56 }
[ { "body": "特別ツール バーの場合には、ボタンの並べ替えは、残念ながら、できないです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T03:44:34.077", "id": "86282", "last_activity_date": "2022-02-12T03:44:34.077", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "40017", "parent_id": "86281", "post_type": "answer", "score": 0 } ]
86281
86282
86282
{ "accepted_answer_id": null, "answer_count": 1, "body": "こんにちは。 \nwordpressを使用してホテルのウェブサイトを制作しています。\n\n***実現したいこと*** \nホテルの検索ページでドロップダウンを使用して目的地と旅行テーマでフィルターをかけられるページを作成しています。 \nカテゴリー”ホテル”の投稿記事に、カテゴリー”旅行テーマ”が登録されているか確認して、その登録されている旅行テーマ又は目的地のみを表示したいです。\n\n例としてカテゴリーは以下です。 \nカテゴリー ホテル(id=18) \nカテゴリー 目的地(id=15) => 子カテゴリー ”日本=>東京”、”イギリス=>ロンドン”、”フランス=>パリ” \nカテゴリー 旅行テーマ(id=2) => 子カテゴリー ”ショッピング”、”食べ歩き”、”ロマンティック”\n\n記事Aは、ホテル、旅行テーマの食べ歩き、目的地は日本=>東京 \n記事Bは、ホテル、旅行テーマのロマンティック、目的地はフランス=>パリ\n\nこの場合、旅行テーマのドロップダウンの選択肢には、食べ歩きとロマンティックのみを表示させ、目的地の選択肢には日本とフランスのみを表示させたいのですが、どうやってcategory.php上でそれぞれのカテゴリーを取得したらいいのか全く分からず手が動かない状態です。目的地と旅行テーマの子カテゴリーには、たくさん他にも登録されています。\n\n***現状** \n下記のコードだと全てのカテゴリーが表示され、フィルターできていない状態です。\n\n```\n\n <!--category-18.php-->\n <!--目的地のカテゴリー取得-->\n $destinations = get_categories(array(\n 'parent' => 15,\n 'hide_empty' => 1,\n 'hierarchical' => 0\n ));\n foreach ($destinations as $dest) : ?>\n <option class=\"category__filter__dropdown\" value=\"<?php echo $dest->term_id; ?>\" data-destination=\"<?php echo $dest->term_id; ?>\">\n <?php echo $dest->name;>\n </option>\n <?php endforeach; ?>\n \n <!--旅行テーマのカテゴリー取得-->\n $travel_topics = get_categories(array(\n 'parent' => 2,\n 'hide_empty' => 1,\n 'hierarchical' => 0\n ));\n foreach ($travel_topics as $cat) : ?>\n <option class=\"category__filter__dropdown\" value=\"<?php echo $cat->term_id; ?>\" data-reisethema=\"<?php echo $cat->term_id; ?>\">\n <?php echo $cat->name;>\n </option>\n <?php endforeach; ?>\n \n```\n\nもしアドバイスいただけたらとても助かります。よろしくお願いします。 \n[teratail](https://teratail.com/questions/mro8siju16njae)にも同じ質問をしましたが、まだコメントをもらっていないのでここでも質問を投稿しました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T07:26:09.563", "favorite_count": 0, "id": "86284", "last_activity_date": "2022-02-24T13:25:37.950", "last_edit_date": "2022-02-14T07:22:32.083", "last_editor_user_id": "29392", "owner_user_id": "29392", "post_type": "question", "score": 0, "tags": [ "php", "wordpress" ], "title": "カテゴリーのホテル一覧ページで、カテゴリーAがカテゴリーのホテルに属しているか確認して表示したいです。", "view_count": 72 }
[ { "body": "ちょっと質問の内容が把握しきれなかったのですが、なんとなくですみませんが投稿してみます。 \n検索って、いろいろ関わってくるので大変ですよね。 \n`get_categories`で取得するカテゴリーで、'include'で必要なものだけにするか、不要なものを`exclude`で除外するといいんじゃないでしょうか? \n<https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/get_categories>\n\n無数にカテゴリーを作ってあるようですので、一旦は`get_categories`で全部カテゴリー情報を取得して、そいつから「これに含まれているカテゴリなのでいらない、これもいらない」とか不要なものを引っこ抜いたりしていくのかな。\n\nとにかく、必要なカテゴリーのIDを配列で作れたらいいですね。 \nそしたら'include'で指定してあげれば自由に取り出せると思います。 \n工夫してやってみるといいんじゃないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-24T13:25:37.950", "id": "86562", "last_activity_date": "2022-02-24T13:25:37.950", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51589", "parent_id": "86284", "post_type": "answer", "score": 0 } ]
86284
null
86562
{ "accepted_answer_id": "86289", "answer_count": 3, "body": "ヤフーから株価をCSVで取り込むプログラム(下記)を走らせる前に「※\n実行前にcsvの保存用の”./data/stock_price_data”というフォルダを作成しておく必要があります。」と書いてあったので作ろうと思いましたがスラッシュが使えないようで同じ名前のフォルダが作れません。どの様にしたらいいでしょうか?\n\n```\n\n start = datetime.date(2010,1,1)\n end = datetime.date.today()\n \n for index, row in df_data_j.iterrows():\n try:\n df = web.DataReader(f'{row[\"コード\"]}.T', 'yahoo', start, end)\n except:\n print(\"error\")\n \n df.to_csv(\"./data/stocks_price_data/stock_price_data_{}.csv\".format(row[\"コード\"]))\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T12:01:13.787", "favorite_count": 0, "id": "86288", "last_activity_date": "2022-02-20T13:05:49.283", "last_edit_date": "2022-02-13T03:57:46.560", "last_editor_user_id": "3060", "owner_user_id": "51310", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "スラッシュ / を含むフォルダは作れないらしいのですがどうしたらよいでしょうか?", "view_count": 229 }
[ { "body": "> ”./data/stock_price_data”というフォルダ\n\nこれは `.` (現在のフォルダ)の中に `data` というフォルダを作り、その `data` というフォルダの中に `stock_price_data`\nというフォルダを作る、という意味です。\n\n「フォルダの階層構造」を学んでください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T12:05:06.483", "id": "86289", "last_activity_date": "2022-02-12T12:05:06.483", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "45045", "parent_id": "86288", "post_type": "answer", "score": 3 }, { "body": "質問には明記されていませんが、恐らく実行環境が Windows なのだろうと推測されます。\n\nWindows ではファイル・フォルダ名に `/` スラッシュを含める事ができませんが、OS によってフォルダ (ディレクトリ)\nの区切り文字の表現方法が異なるだけなので、(別の回答にもある通り) 以下のような階層構造でフォルダを用意すればよいはずです。\n\n```\n\n ┌ プログラム\n └ data/\n └ stocks_price_data/\n └ stock_price_data_*.csv\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T04:04:06.777", "id": "86304", "last_activity_date": "2022-02-13T04:04:06.777", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "86288", "post_type": "answer", "score": 0 }, { "body": "「/」はファイル名の一部ではなく、階層構造を表す文字です。\n\n> ”./data/stock_price_data”\n\n他の方の回答にあるとおり、「.」は現在いるフォルダ(を省略した表現)です。 \n実際は「/XXX/YYY/ZZZ」みたいになっています。 \n= XXXフォルダの中のYYYフォルダの中のZZZフォルダにいる。\n\nフォルダの作り方ですが、 \npythonではなく、GUI上(MacならFinder、windowsならエクスプローラー)でフォルダを作成する方法をおすすめします。\n\n参考: \n現在のフォルダ「.」はpythonコマンドを実行する場所であることがデフォルトです。 \nコンソール上で「pwd」と打ったら「.」が省略しない形で見えると思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T13:05:49.283", "id": "86483", "last_activity_date": "2022-02-20T13:05:49.283", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51522", "parent_id": "86288", "post_type": "answer", "score": 0 } ]
86288
86289
86289
{ "accepted_answer_id": "86296", "answer_count": 2, "body": "C# の Windows Forms アプリケーションにおいて、Windows Forms のイベントで async メソッドを await\nで待機した場合は、async メソッド内の await 前後でスレッドIDが変化しませんが、Main メソッドで async メソッドを await\nで待機した場合は、async メソッド内の await 前後でスレッドIDが変化します。\n\nMain メソッドから async メソッドを実行した場合も async メソッド内の await\n前後でスレッドIDを変化させないようにするにはどのようにすればよいでしょうか?\n\n尚、Main メソッド内で `task.Wait()` を使用した場合はスレッドIDが変化しないことが確認できました。 \nそもそも Main メソッド内で await で async メソッドを待つという考え自体が間違っているのでしょうか? \n説明を頂ければありがたいです。\n\n### 例\n\n#### Program.cs\n\n```\n\n using System;\n using System.Threading;\n using System.Threading.Tasks;\n using System.Windows.Forms;\n \n namespace WindowsFormsAppTestAwait\n {\n internal static class Program\n {\n [STAThread]\n private static async Task Main()\n {\n // スレッドID変化あり\n await HeavyMethodAsync(\"Main\");\n \n // スレッドID変化なし\n HeavyMethodAsync(\"Main\").Wait();\n \n Application.EnableVisualStyles();\n Application.SetCompatibleTextRenderingDefault(false);\n Application.Run(new Form1());\n }\n \n internal static Task HeavyMethodAsync(string name)\n {\n return Task.Run(async () =>\n {\n Console.WriteLine($\"{name}#{Thread.CurrentThread.ManagedThreadId}: before\");\n await Task.Delay(1000);\n Console.WriteLine($\"{name}#{Thread.CurrentThread.ManagedThreadId}: after\");\n });\n }\n }\n }\n \n```\n\n#### Form1.cs\n\n※Form1 の Load イベントで `HeavyMethodAsync` を呼んでいます\n\n```\n\n using System;\n using System.Windows.Forms;\n \n namespace WindowsFormsAppTestAwait\n {\n public partial class Form1 : Form\n {\n public Form1()\n {\n InitializeComponent();\n }\n \n private async void Form1_Load(object sender, EventArgs e)\n {\n // スレッドID変化なし\n await Program.HeavyMethodAsync(\"Form\");\n }\n }\n }\n \n```\n\n### 結果\n\n```\n\n Main#3: before\n Main#4: after\n Main#3: before\n Main#3: after\n Form#3: before\n Form#3: after\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T16:04:22.663", "favorite_count": 0, "id": "86291", "last_activity_date": "2022-02-13T01:13:23.693", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26573", "post_type": "question", "score": 0, "tags": [ "c#" ], "title": "C# の Windows Forms アプリケーションにおいて await 前後でスレッドIDを固定したい", "view_count": 265 }
[ { "body": "はい、 Main メソッド内で await で async\nメソッドを待つという考え自体が間違っています。このアプローチでは、`HeavyMethodAsync`が完了してからしか、Mainメソッドの後続行は実行されません。本当に実現したいのは、\n\n * 重い処理(`HeavyMethodAsync`)を起動時に開始し\n * 並行してGUI(`Form1`)の表示も開始したい\n\nではありませんか? \nそうであれば行うべきは\n\n * `HeavyMethodAsync`を別スレッドで実行し\n * メインスレッドはGUI(`Form1`)の表示も開始する\n\n必要があります。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T20:39:08.497", "id": "86294", "last_activity_date": "2022-02-12T20:39:08.497", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "86291", "post_type": "answer", "score": 3 }, { "body": "質問者さんのコードで確認したわけではないですが、Main メソッドと Form1_Load メソッドでは使われる\nSynchronizationContext が違うのが期待(await 前後でスレッドIDを変化させない)と違った理由ではないかと思います。\n\nアプリによりどのように違うかは以下の記事の 5, 6, 8 を見てください。\n\nSynchronizationContext とは? \n<http://surferonwww.info/BlogEngine/post/2020/09/30/what-is-\nsynchronizationcontext.aspx>\n\nSynchronizationContext.Current プロパティで確認できるので自分のコードで確認してみてください。\n\nたぶん、Main メソッドの方は上の記事で言うコンソールアプリと同じ、Form1_Load メソッドは Application.Run メソッド\n(現在のスレッドで標準のアプリケーション メッセージ ループの実行を開始し、指定したフォームを表示) で起動される Windows Forms\nということで、 SynchronizationContext が違うと思われます。\n\n**【追記】**\n\nちなみに、Main メソッドで HeavyMethodAsync(\"Main\").Wait(); とした部分ですが、Windows Forms のような\nGUI アプリでそのようなことをするとデッドロックになるはずです。詳しくは以下の記事の「すべて非同期にする」のセクションを見てください。\n\n非同期プログラミングのベスト プラクティス \n<https://docs.microsoft.com/ja-jp/archive/msdn-magazine/2013/march/async-\nawait-best-practices-in-asynchronous-programming>\n\nそうならないようですので、そこはコンソールアプリと同じになっていると思います。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T01:04:26.293", "id": "86296", "last_activity_date": "2022-02-13T01:13:23.693", "last_edit_date": "2022-02-13T01:13:23.693", "last_editor_user_id": "43387", "owner_user_id": "43387", "parent_id": "86291", "post_type": "answer", "score": 1 } ]
86291
86296
86294
{ "accepted_answer_id": null, "answer_count": 1, "body": "インテルプロセッサーからメモリー初期化したいけど仕様書が無いです。 \nどこにありますか?\n\n<https://www.intel.co.jp/content/dam/www/public/ijkk/jp/ja/documents/developer/IA32_Arh_Dev_Man_Vol3_i.pdf#page=363>\n\nIBMはあったのですが。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-12T19:44:38.947", "favorite_count": 0, "id": "86293", "last_activity_date": "2022-02-23T05:33:39.807", "last_edit_date": "2022-02-23T05:33:39.807", "last_editor_user_id": "3060", "owner_user_id": "51165", "post_type": "question", "score": 0, "tags": [ "memory" ], "title": "インテルプロセッサーからメモリー初期化したい", "view_count": 168 }
[ { "body": "こちらにあるものではありませんか? \nこの辺の資料・記事やそれらに示されている紹介資料を調べてみてはどうでしょう?\n\n[Minimum Steps Necessary to Boot an Intel® Architecture\nPlatform](https://www.intel.co.jp/content/www/jp/ja/intelligent-systems/intel-\nboot-loader-development-kit/minimal-intel-architecture-boot-loader-paper.html) \n[Minimal Intel Architecture Boot\nLoader](https://www.intel.co.jp/content/dam/www/public/us/en/documents/white-\npapers/minimal-intel-architecture-boot-loader-paper.pdf) \nちょっと表記はズレますが、目次にこんなものが示されています。\n\n> * Preparation for Memory Initialization\n> ........................................................ 8\n> * Processor Microcode Update\n> .......................................................... 8\n> * Processor Initialization\n> .................................................................. 8\n> * Chipset Initialization\n> ..................................................................... 9\n> * Memory Initialization\n> ..............................................................................\n> 9\n> * Technical Resources\n> ..................................................................... 9\n> * MRC Dependencies\n> ..................................................................... 10\n> * Post Memory Initialization\n> ..................................................................... 10\n> * Memory Test\n> .............................................................................\n> 11\n> * Firmware Shadow\n> ...................................................................... 11\n> * Memory Transaction Re-Direction\n> ................................................. 11\n> * Stack Setup\n> ..............................................................................\n> 12\n> * Transfer to DRAM\n> ....................................................................... 12\n>\n\nそれからStackOverflowの記事にこんなものがあります。 \nもしかしたら、あなたの疑問の大本に近いかもしれません。 \n[How Does BIOS initialize DRAM?](https://stackoverflow.com/q/63159663/9014308)\n\nその回答の中に該当資料は _BIOS Writer Guide_ と呼ばれ機密情報であり漏洩していないとあります。\n\n> The document you (and also I) are looking for is called the _BIOS Writer\n> Guide_ and, unfortunately, is confidential and has not leaked so far\n> (AFAIK).\n\nただし続けてFirmware Support Packageというのがリリースされていて、そこに解説と(バイナリ)コードも含まれていると書かれています。 \nオープンソース開発者やNDA(機密保持契約)を結ぶ余裕のない開発者はそれを使えるでしょうとあるので、関連する情報が書かれているのではないですか?\n\n> In order to promote their product in the Open Source community, Intel\n> released the [Firmware Support\n> Package](https://software.intel.com/content/www/us/en/develop/articles/intel-\n> firmware-support-package.html). This is to be considered akin to a library\n> for the firmware writers and contains (binary) code to initialize the memory\n> controller, the PCH (Peripheral Controller Hub, informally known as \"the\n> chipset\"), and the CPU1. \n> An open source developer, or in general any developer that cannot afford to\n> sign an NDA with Intel, can use the FSP to writes their own firmware.\n\n回答には続けて詳細な内容が記述されているので、それだけでもある程度知りたいことが分かるかもしれません。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T00:14:34.353", "id": "86295", "last_activity_date": "2022-02-13T00:14:34.353", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86293", "post_type": "answer", "score": 2 } ]
86293
null
86295
{ "accepted_answer_id": null, "answer_count": 1, "body": "pythonで自動ログインしようとしているんですが、一番最初にChromeのwebドライバーを使ってchromeを立ち上げるところにつまづいています。実装はgoogleコラボで行っています。osはwindows10です。chromeのバージョンは98.0.4758.82ですが、ダウンロードページにはピッタリのバージョンがないため、98.0.4758.80ものをダウンロードしました。コード書き方やexeファイルの配置場所変更を試したんですが、エラーを解消することができませんでした。どうすればよろしいでしょうか\n\n```\n\n !pip install selenium\n from selenium import webdriver\n from time import sleep\n \n # ここでエラー\n browser = webdriver.Chrome(executable_path=\"/content/drive/MyDrive/chromedriver.exe\")\n \n```\n\nエラー\n\n```\n\n /usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:1: DeprecationWarning: executable_path has been deprecated, please pass in a Service object\n \"\"\"Entry point for launching an IPython kernel.\n ---------------------------------------------------------------------------\n PermissionError Traceback (most recent call last)\n /usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py in start(self)\n 75 stdin=PIPE,\n ---> 76 creationflags=self.creationflags)\n 77 except TypeError:\n \n 5 frames\n PermissionError: [Errno 13] Permission denied: '/content/drive/MyDrive/chromedriver.exe'\n \n During handling of the above exception, another exception occurred:\n \n WebDriverException Traceback (most recent call last)\n /usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py in start(self)\n 86 raise WebDriverException(\n 87 \"'%s' executable may have wrong permissions. %s\" % (\n ---> 88 os.path.basename(self.path), self.start_error_message)\n 89 )\n 90 else:\n \n WebDriverException: Message: 'chromedriver.exe' executable may have wrong permissions. Please see https://chromedriver.chromium.org/home\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T01:47:01.617", "favorite_count": 0, "id": "86298", "last_activity_date": "2022-02-13T08:38:47.537", "last_edit_date": "2022-02-13T02:37:13.180", "last_editor_user_id": "26370", "owner_user_id": "29442", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "Chromeのwebドライバーについて", "view_count": 248 }
[ { "body": "Google Colaboratoryで動作させるのなら、その環境であるUbuntuでのChromeDriverをインストールして使う必要があるでしょう。\n\nこの辺の記事で方法が示されています。 \n[【Python】Google\nColaboratoryでSelenium実行](https://yuyuublog.com/colaboratoryselenium/) \n[Google Colaboratoryでwebスクレイピング](https://kimudiary.com/colab/google-\ncolaboratory%e3%81%a7web%e3%82%b9%e3%82%af%e3%83%ac%e3%82%a4%e3%83%94%e3%83%b3%e3%82%b0-2/) \n[GoogleColaboratoryでchromedriverを利用する(2021年9月版)](https://i-doctor.sakura.ne.jp/font/?p=46745)\n\nいずれも基本は以下コマンドでChromeDriverをインストールすることらしいですね。 \nこれでインストールすればパーミッションも自動的に設定されるのでしょう。\n\n```\n\n !apt install chromium-chromedriver\n \n```\n\n上記の中にはその前にパッケージ情報を更新したり、インストールされたChromeDriverをコピーしたりする作業を書いた記事もありますが、必要なら行えば良いのでは?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T08:38:47.537", "id": "86312", "last_activity_date": "2022-02-13T08:38:47.537", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86298", "post_type": "answer", "score": 1 } ]
86298
null
86312
{ "accepted_answer_id": "86302", "answer_count": 1, "body": "当方macbookでwgetコマンドについて学ぶ機会がありました。\n\n引数にURLを指定するとそのコンテンツがダンロードすることができるとあり、実際にいくつかのサイトをスクレイピングしましたが\n**特に保存先のディレクトリを指定しない場合、ダンロードしたデータについてはどこに保存される** のでしょうか。\n\nまた、 **ダウンロードしたデータを一括で削除する方法** がありましたらそちらも合わせてご教示いただければ幸いです。\n\n伺いたい2つの項目を体系的に説明しているサイトを見つけることができませんでした。\n\n非常に常識的な質問かもしれませんが、お答えいただきたいです。 \nどうぞよろしくおねがいします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T02:40:56.970", "favorite_count": 0, "id": "86301", "last_activity_date": "2022-02-13T03:45:43.603", "last_edit_date": "2022-02-13T03:35:24.797", "last_editor_user_id": "3060", "owner_user_id": "50698", "post_type": "question", "score": 0, "tags": [ "macos", "wget" ], "title": "wgetでダンロードしたデータはどこに保存される?", "view_count": 2883 }
[ { "body": "保存先を指定しなければ、コマンドを実行したカレントディレクトリにファイルが保存されるはずです。\n\nまた、\"wgetで保存したファイル\"\nのような履歴情報は残らないので、判別可能なように保存先を分けてダウンロードするか、予めダウンロードリストを作成しておきダウンロード・削除を実行するなどの工夫が必要かと思います。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T03:45:43.603", "id": "86302", "last_activity_date": "2022-02-13T03:45:43.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "86301", "post_type": "answer", "score": 1 } ]
86301
86302
86302
{ "accepted_answer_id": "86307", "answer_count": 1, "body": "下記のコードを実行することで行いたい処理は次のとおりです。\n\n 1. フォルダ内にあるcsvファイルを全取得する\n 2. ファイル構成(カラム名や行数)は同じなので最初に開いたcsvファイル(data_r)の列名から抽出したいカラム番号を選択する\n 3. data_rからilocで欲しい列を全行取得(data_c)する(このとき欲しい列は選択したカラム番号になる)\n 4. カラム名はどのファイルでも同名のため、カラム名をファイル名にrenameする\n 5. 事前に作成しておいたDataFrame(data_p)にdata_cをappendする\n 6. 以後、3に戻り選択したカラム番号をilocで抽出し、data_pにappendを繰り返す\n\n私の想定している出力結果は、例えばファイル数が5つあり、1つのファイルに1000行のデータがあるとすればindexが1000行で、columnsがカラム1~カラム5でした。 \nしかし実際に得られた出力は、indexが5000行で、columnsがカラム1~カラム5でした。\n\nindexがないことが原因なのかはわかりませんが、すべて別物として扱われているようです。 \nそのためどの列も4000行分はNaN値となっていました。 \n行数が同じなので、全て1行として横にappendしていってほしいのですがどのように修正すればよろしいでしょうか。\n\n```\n\n files = natsorted(glob.glob('*.csv'))\n \n firstLoop = True\n data_p = pd.DataFrame([])\n for f in files:\n n = os.path.splitext(os.path.basename(f))[0]\n data_r = pd.read_csv(f, encoding='SHIFT_JIS')\n if firstLoop:\n print(f'カラム名は以下となっています \\n {data_r.keys()} \\n Y軸に使うカラム番号を1つ選択して入力してください')\n yaxis = input('カラム番号(0始まり):')\n data_c = data_r.iloc[:, [int(yaxis)]].copy()\n data_c.rename(columns={data_c.columns.values[0]:n}, inplace=True)\n firstLoop = False\n else:\n data_c = data_r.iloc[:, [int(yaxis)]].copy()\n data_c.rename(columns={data_c.columns.values[0]:n}, inplace=True)\n \n data_p = data_p.append(data_c)\n data_p\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T05:58:53.950", "favorite_count": 0, "id": "86306", "last_activity_date": "2022-02-18T15:41:49.010", "last_edit_date": "2022-02-18T15:41:49.010", "last_editor_user_id": "3060", "owner_user_id": "48769", "post_type": "question", "score": 0, "tags": [ "python", "pandas" ], "title": "最終的に、ilocで取得した列を新しいDataFrameへ横にappendする処理を繰り返したい", "view_count": 362 }
[ { "body": "そもそもappendは行(縦方向)を追加するものであって、横方向(列)に追加するにはconcat等でaxis=1(あるいはcolumns)を指定するものでしょう。 \nそれからv1.4.0から非推奨になって、代替手段がconcatになっているので、2重の意味でそちらを使うことになるでしょう。(rowsの太字は引用者)\n\n[pandas.DataFrame.append](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.append.html)\n\n> Append **rows** of _other_ to the end of caller, returning a new object.\n\n> _**Deprecated since version 1.4.0:**_ Use\n> [concat()](https://pandas.pydata.org/docs/reference/api/pandas.concat.html#pandas.concat)\n> instead. For further details see [Deprecated DataFrame.append and\n> Series.append](https://pandas.pydata.org/docs/whatsnew/v1.4.0.html#whatsnew-140-deprecations-\n> frame-series-append)\n\ncsvを読み取ってDataFrameを作った時にindexが指定されていなくて全て0からの連番になっているのであれば、同じ行番号の位置に追加されるでしょう。\n\nこの行を:\n\n```\n\n data_p = data_p.append(data_c)\n \n```\n\nこのようにしてみれば良いのでは?\n\n```\n\n data_p = pd.concat([data_p, data_c], axis=1)\n \n```\n\n試してみてください。\n\n参考記事: \n[結合の方向を指定する -\n指定した軸の方向にDataFrameを結合するPandasのconcat関数の使い方](https://deepage.net/features/pandas-\nconcat.html#%E7%B5%90%E5%90%88%E3%81%AE%E6%96%B9%E5%90%91%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B) \n[pandas.DataFrame, Seriesを連結するconcat](https://note.nkmk.me/python-pandas-\nconcat/) \n[列名をキーにして横方向に結合(axis=1 or axis='columns') -\n【TIPS】Pandasのconcat関数でDataFrameを結合する方法まとめ](https://engineer-lifestyle-\nblog.com/code/python/pandas-dataframe-concat-\nusage/#axis1_or_axis8217columns8217)\n\n* * *\n\nちなみに質問最後の方の「行数が同じなので、全て`1行`として」は「行数が同じなので、全て`1列`として」のtypoでしょうね。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T06:53:24.607", "id": "86307", "last_activity_date": "2022-02-13T07:07:37.270", "last_edit_date": "2022-02-13T07:07:37.270", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "86306", "post_type": "answer", "score": 0 } ]
86306
86307
86307
{ "accepted_answer_id": "86309", "answer_count": 1, "body": "windows PowerShell 上で node コマンドを実行すると \n`[90m` というのがついて非常に見づらいです\n\nbash 上だと色が変わったり太字になったりするコードだと思うんですが消す方法はないでしょうか \n色が変わってくれれば理想なんですが\n\n```\n\n PS D:\\js\\network-test> node test.js\n node:internal/modules/cjs/loader:936\n throw err;\n ^\n \n Error: Cannot find module 'puppeteer'\n Require stack:\n - D:\\js\\network-test\\test.js\n [90m at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)[39m\n [90m at Function.Module._load (node:internal/modules/cjs/loader:778:27)[39m\n [90m at Module.require (node:internal/modules/cjs/loader:999:19)[39m\n [90m at require (node:internal/modules/cjs/helpers:102:18)[39m\n at Object.<anonymous> (D:\\js\\network-test\\test.js:1:19)\n [90m at Module._compile (node:internal/modules/cjs/loader:1095:14)[39m\n [90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)[39m\n [90m at Module.load (node:internal/modules/cjs/loader:975:32)[39m\n [90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)[39m\n [90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)[39m {\n code: [32m'MODULE_NOT_FOUND'[39m,\n requireStack: [ [32m'D:\\\\js\\\\network-test\\\\test.js'[39m ]\n }\n \n Node.js v17.0.1\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T07:22:27.630", "favorite_count": 0, "id": "86308", "last_activity_date": "2022-04-05T08:34:33.493", "last_edit_date": "2022-04-05T08:34:33.493", "last_editor_user_id": "2238", "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "node.js", "powershell" ], "title": "PowerShell 上の node コマンドのメッセージのカラーコードを消したい", "view_count": 147 }
[ { "body": "それはANSI/VT100エスケープシーケンスで、ちょっと前の記事ではデフォルトではオフになっているとあります。 \n[Colored text output in PowerShell console using ANSI / VT100\ncodes](https://stackoverflow.com/q/51680709/9014308) \n回答から\n\n> While **console windows in Windows 10 do support VT (Virtual Terminal) /\n> ANSI escape sequences** _in principle_ , **support is turned _OFF by\n> default_**. \n> You have three options:\n\nということで以下3つのオプションがあるようです。\n\n * レジストリを書き変える\n * 処理の中で`SetConsoleMode()`APIを呼ぶ\n * 出力結果を`Out-Host`スクリプトで表示する\n\n詳細は上記記事&回答を参照してください。\n\nただ、PowerShellの最近の版(7.2とか?)やWindows\nTerminalあたりを使うとデフォルトで有効になっている可能性も考えられるので、そちらを試してみるのが良いかもしれません。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T07:46:35.647", "id": "86309", "last_activity_date": "2022-02-13T07:46:35.647", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86308", "post_type": "answer", "score": 1 } ]
86308
86309
86309
{ "accepted_answer_id": null, "answer_count": 1, "body": "それぞれある周期で循環する0と1の数列があります。\n\n例: \n010101010101...(周期2) \n001100110011...(周期4) \n000111000111...(周期6)\n\nここで、縦列が全て1になる最初の列番号やその割合を求めたいです。 \n上の例では最初に4列目(次に12列目)で1が揃い、無限数列全体の1/6が揃っています。\n\n最初の列番号を求める方法は今のところ、各数列で周期内の何番目の1を選ぶかの組み合わせを全て試し、それぞれの組み合わせに対して連立合同式を解いて最小の列数を求め、全体の最小値を更新していくバックトラック法しか思いつきません。 \n割合を求める方法は、全周期の最小公倍数の列数までに1が揃う列を1つずつ数える方法しか思いつきません。\n\n・これは名前のついた問題ですか? \n・この問題はNP困難ですか?数列の数が増えても速く計算する方法はありますか? \n・0、1が続く区間や循環する周期の長さを有理数や無理数に拡張した場合はどう計算しますか?", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T07:50:46.880", "favorite_count": 0, "id": "86310", "last_activity_date": "2022-02-18T07:48:11.230", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51403", "post_type": "question", "score": 0, "tags": [ "アルゴリズム" ], "title": "区間が重なるタイミング", "view_count": 302 }
[ { "body": "> ・この問題はNP困難ですか?\n\nいいえ。多項式時間で解ける問題と思います。\n\nPythonによるアルゴリズム実装例です:<https://wandbox.org/permlink/8R5tfdstFdRV4NTG>\n\n```\n\n import math\n from fractions import Fraction\n \n def solve(q):\n period = math.lcm(*[e[0] + e[1] for e in q])\n acc = (1 << period) - 1\n for e in q:\n dist = sum([1 << m for m in range(0, period, e[0] + e[1])]) \n bits = ((1 << e[1]) - 1) * dist\n acc &= bits\n print('{}+{} {:0{}b}'.format(*e, bits, period))\n print('acc {:0{}b}'.format(acc, period))\n msb = 1 + period - acc.bit_length()\n ratio = Fraction(bin(acc).count('1'), period) # acc.bit_count() since Python3.10\n return (msb, ratio)\n \n # 問題を(1個の0, 1個の1), ... と定義\n q = [(1,1), (2,2), (3,3)]\n ans = solve(q)\n print(ans)\n # 答え=(4, Fraction(1, 6))\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T07:48:11.230", "id": "86434", "last_activity_date": "2022-02-18T07:48:11.230", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49", "parent_id": "86310", "post_type": "answer", "score": 0 } ]
86310
null
86434
{ "accepted_answer_id": null, "answer_count": 1, "body": "プログラミングを始めたばかりの初心者です。 \n画像診断のプログラムを組みたいのですが、下記のようなエラーが出てしまいます。 \ngoogle colaboratoryを使用しており、kaggleのChest X-Ray Images\n(Pneumonia)というデータセットから何枚かgoogleドライブにアップロードして使おうとしています。 \n他の方の質問も見てみましたが、理解が追い付かず... \n解決方法を教えていただければ幸いです。 \n(appendの代わりにnp.appendを入れたりしましたが、そちらでもエラーが出てしまいました。)\n\n```\n\n import numpy as np\n import tensorflow as tf\n from tensorflow import keras\n import glob\n \n x_train = []\n y_train = []\n x_test = []\n y_test = []\n \n for f in glob.glob(\"/content/drive/MyDrive/kaggle/image/*/*/*.jpeg\"):\n img_data = tf.io.read_file(f)\n img_data = tf.io.decode_jpeg(img_data)\n img_data = tf.image.resize(img_data,(100,100))\n \n if f.split(\"/\")[6]==\"train\":\n x_train.append(img_data)\n y_train.append(int(f.split(\"/\")[7].split(\"_\")[0]))\n elif f.split(\"/\")[6]==\"test\":\n x_test.append(img_data)\n y_test.append(int(f.split(\"/\")[7].split(\"_\")[0]))\n \n x_train = np.array(x_train) / 255.0\n y_train = np.array(y_train)\n x_test = np.array(x_test) / 255.0\n y_test = np.array(y_test)\n \n```\n\n```\n\n AttributeError Traceback (most recent call last)\n <ipython-input-75-44f0c41d960e> in <module>()\n 18 y_train.append(int(f.split(\"/\")[7].split(\"_\")[0]))\n 19 elif f.split(\"/\")[6]==\"test\":\n ---> 20 x_test.append(img_data)\n 21 y_test.append(int(f.split(\"/\")[7].split(\"_\")[0]))\n 22 \n \n AttributeError: 'numpy.ndarray' object has no attribute 'append'\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T08:01:42.800", "favorite_count": 0, "id": "86311", "last_activity_date": "2022-02-13T09:56:58.623", "last_edit_date": "2022-02-13T08:14:44.827", "last_editor_user_id": "26370", "owner_user_id": "51404", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "'numpy.ndarray' object has no attribute 'append'のエラーが出てしまいます。", "view_count": 1648 }
[ { "body": "紹介された動画のコーディング作業画像を良く見ると、ほんの一瞬ですが該当部分のインデントを減らして`for`ループの外に移動させていました。 \n`19:00`・`20:26`付近や`21:52`以後など\n\nなので、以下の部分のインデントを解除して`for`ループの外に移動すれば動作するでしょう。\n\n```\n\n x_train = np.array(x_train) / 255.0\n y_train = np.array(y_train)\n x_test = np.array(x_test) / 255.0\n y_test = np.array(y_test)\n \n```\n\n単純にこちらのようにする。\n\n```\n\n x_train = np.array(x_train) / 255.0\n y_train = np.array(y_train)\n x_test = np.array(x_test) / 255.0\n y_test = np.array(y_test)\n \n```\n\n* * *\n\n以下は動画が紹介される前のソースコードだけで推測した内容です。 \n一応何か別の現象が起こった時などのための注意事項として残しておきます。\n\n* * *\n\nお手本の記事へのリンクとかソースコードの情報が追加されるかどうか分かりませんが、今のソースコードからすると、問題の原因は以下のコードによりPythonの基本的なリストとして定義された変数がnumpy.ndarrayに変換されてしまったことですね。 \n例えばこちらの記事と類似の現象です。 \n['numpy.ndarray' object has no attribute\n'append'のエラーについて](https://ja.stackoverflow.com/q/69976/26370)\n\nリストとしての宣言と初期化\n\n```\n\n x_train = []\n y_train = []\n x_test = []\n y_test = []\n \n```\n\nforループでの処理でndarrayに変換される\n\n```\n\n x_train = np.array(x_train) / 255.0\n y_train = np.array(y_train)\n x_test = np.array(x_test) / 255.0\n y_test = np.array(y_test)\n \n```\n\nなので、forループの初回は以下の処理は正常に動作しますが、2回目以後はリストでは無くndarrayになっているのでエラーになります。\n\n```\n\n if f.split(\"/\")[6]==\"train\":\n x_train.append(img_data)\n y_train.append(int(f.split(\"/\")[7].split(\"_\")[0]))\n elif f.split(\"/\")[6]==\"test\":\n x_test.append(img_data)\n y_test.append(int(f.split(\"/\")[7].split(\"_\")[0]))\n \n```\n\n最初からndarrayとして宣言・初期化しnp.appendを使うか、ループ後半のリスト全体をndarrayに変換してしまう処理を見直して必要なデータだけndarrayに変換するよう書き変えるか、のどちらかになると思われます。", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T09:10:52.290", "id": "86314", "last_activity_date": "2022-02-13T09:56:58.623", "last_edit_date": "2022-02-13T09:56:58.623", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "86311", "post_type": "answer", "score": 1 } ]
86311
null
86314
{ "accepted_answer_id": "87945", "answer_count": 2, "body": "JupyterLab上で、BeautifulSoapを利用するために、以下のpip3コマンドを実行したところ、\n\n```\n\n !pip3 install beautifulsoup4\n \n```\n\n次のような警告メッセージが表示されました。\n\n```\n\n WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\n \n```\n\nvirtual environmentを利用するよう勧められているようなのですが、具体的には何をすればよいのでしょうか? \n(virtual environmentとは何のことでしょうか?)\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/iVs97.png)](https://i.stack.imgur.com/iVs97.png)", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T08:58:58.610", "favorite_count": 0, "id": "86313", "last_activity_date": "2022-03-24T13:40:37.080", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "35267", "post_type": "question", "score": 1, "tags": [ "python", "pip" ], "title": "pipコマンドからの警告(to use a virtual environment)の対処方法", "view_count": 14816 }
[ { "body": "使用している OSが何かが問題で\n\n例えばシステム内の Pythonを置き換えてしまうと, ある種の OSでは動作に支障をきたします \nOS側で提供してる各種コマンドの一部に Python製があり, バージョンが変わると動作が変化する あるいは動作しない可能性が出てくるため\n\nそれは Pythonパッケージも同じで, 同名のパッケージあるいは「あるパッケージが存在すればそれを使う」ようなパターンなど,\nいつの間にか各種ツールの動作がおかしくなってた, などがあり得る\n\nその手の心配がない(最初から Python入ってなかったなど)場合は無視してよいし \nOSと Pythonが密接している環境では, システム側とユーザー側で環境切り分けるなど対処する方法があります\n\n仮に問題がなくとも, 仮想環境があればいくつかの環境を切り替えて使う・別のバージョンのパッケージを利用するなど利点は多々あるので,\n仮想環境利用してみるのもよいでしょう\n\n * (docs.python.org) [venv --- 仮想環境の作成](https://docs.python.org/ja/3/library/venv.html) \nそれまでは virtualenv と呼ばれていたツール。現在は標準機能。\n\n * [Anaconda](https://www.anaconda.com/) \n科学計算(データサイエンス、機械学習アプリケーション、大規模データ処理、予測分析など)のためのPythonおよびR言語の無料のオープンソースディストリビューション \n[https://ja.wikipedia.org/wiki/Anaconda_(Pythonディストリビューション)](https://ja.wikipedia.org/wiki/Anaconda_\\(Python%E3%83%87%E3%82%A3%E3%82%B9%E3%83%88%E3%83%AA%E3%83%93%E3%83%A5%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3\\))\nより\n\n * pipenv, poetry \n次世代の仮想環境\n\n * [pyenv](https://github.com/pyenv/pyenv) \nPython Version Management\n\n* * *\n\nAnacondaはそれ自体で完結しているため 他のを使う必要はない。他のを混ぜると環境が壊れることも\n\n * 各種 Pythonパッケージには, Anaconda, venv, pipenv, poetry など\n * Python自体のバージョン管理には, Anacondaか, pyenv\n\n#### pip について\n\npip については, Anaconda利用するなら pip使用禁止 (壊れて再インストールの話 それなり上る) \npipenvなど次世代仮想環境では, 通常は pipenv コマンドで行う (ので使わなくてよい)\n\npip コマンドを(どうしても?)使用する場合は, \"user install\" を利用するとよいでしょう \n`--user` オプションを付けるかどうかでインストールされる場所が異なる (ことがある)(自動で付く環境も存在する)\n\n参考: pip documentation: User Guide [User\nInstalls](https://pip.pypa.io/en/stable/user_guide/#user-installs)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-03-21T06:15:10.917", "id": "87945", "last_activity_date": "2022-03-21T06:15:10.917", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43025", "parent_id": "86313", "post_type": "answer", "score": 1 }, { "body": "venvについて、おおむね理解できました。ありがとうございます。 \n[Python3系のアップロード pip installをするとRunning pip as root will break packages and\npermissions.](https://teratail.com/questions/358301)の、3つの条件に当てはまらないから、警告が発生したと理解できました。今回はDockerを利用しているので、この警告は無視できると判断しまた。\n\nちなみに、WSL Dockerコンテナ内のUbuntu 20.04.4 LTSの、 \nPython 3.8.10 \npip 22.0.4 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8) \nを利用していました。root権限で実行されていました。 \n(コメント欄は改行できないため、ここに記載します。)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-03-24T13:33:36.160", "id": "88007", "last_activity_date": "2022-03-24T13:40:37.080", "last_edit_date": "2022-03-24T13:40:37.080", "last_editor_user_id": "35267", "owner_user_id": "35267", "parent_id": "86313", "post_type": "answer", "score": 0 } ]
86313
87945
87945
{ "accepted_answer_id": null, "answer_count": 1, "body": "画像診断のプログラムを組みたいのですが、下記のようなエラーが出てしまいます。 \ngoogle colaboratoryを使用しており、kaggleのChest X-Ray Images\n(Pneumonia)というデータセットから何枚かgoogleドライブにアップロードして使おうとしています。 \n画像はグレースケールです。\n\n参考にした動画ではカラー画像を使っていたので、それが関係しているのかもしれませんが、直し方が分かりません。どなたか教えていただけるとありがたいです。\n\n[Pythonによるディープラーニングの作り方〜画像認識〜【Python機械学習入門#10】](https://www.youtube.com/watch?v=ThKRS7B5GFY&t=1666s)\n\n**エラーメッセージ**\n\n```\n\n ---------------------------------------------------------------------------\n ValueError Traceback (most recent call last)\n <ipython-input-97-c83072b43715> in <module>()\n 24 \n 25 \n ---> 26 x_train = np.array(x_train) / 255.0\n 27 y_train = np.array(y_train)\n 28 x_test = np.array(x_test) / 255.0\n \n ValueError: could not broadcast input array from shape (100,100,1) into shape (100,100)\n \n```\n\n**ソースコード**\n\n```\n\n import numpy as np\n import tensorflow as tf\n from tensorflow import keras\n import glob\n \n x_train = []\n y_train = []\n x_test = []\n y_test = []\n \n \n \n for f in glob.glob(\"/content/drive/MyDrive/kaggle/image/*/*/*.jpeg\"):\n img_data = tf.io.read_file(f)\n img_data = tf.io.decode_jpeg(img_data)\n img_data = tf.image.resize(img_data,(100,100))\n \n if f.split(\"/\")[6]==\"train\":\n x_train.append(img_data)\n y_train.append(int(f.split(\"/\")[7].split(\"_\")[0]))\n elif f.split(\"/\")[6]==\"test\":\n x_test.append(img_data)\n y_test.append(int(f.split(\"/\")[7].split(\"_\")[0]))\n \n \n x_train = np.array(x_train) / 255.0\n y_train = np.array(y_train)\n x_test = np.array(x_test) / 255.0\n y_test = np.array(y_test)\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T10:48:07.310", "favorite_count": 0, "id": "86315", "last_activity_date": "2022-02-14T01:06:15.247", "last_edit_date": "2022-02-13T13:38:31.543", "last_editor_user_id": "3060", "owner_user_id": "51404", "post_type": "question", "score": 0, "tags": [ "python", "numpy" ], "title": "could not broadcastと表示される", "view_count": 1749 }
[ { "body": "似たような事例を見つけました。\n\n[ValueError: could not broadcast input array from shape (224,224,3) into shape\n(224,224)](https://stackoverflow.com/q/43977463)\n\n以下のようにした際に、同じエラーが見られます。\n\n```\n\n a=np.random.rand(100,100,1)\n b=np.random.rand(100,100)\n c=[a,b]\n c=np.array(c)\n \n```\n\n元のファイルを使って調べてみないと断言はできませんが、違うサイズのimg_dataが混ざっているのではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T11:55:33.060", "id": "86317", "last_activity_date": "2022-02-14T01:06:15.247", "last_edit_date": "2022-02-14T01:06:15.247", "last_editor_user_id": "3060", "owner_user_id": "36057", "parent_id": "86315", "post_type": "answer", "score": 1 } ]
86315
null
86317
{ "accepted_answer_id": "86320", "answer_count": 1, "body": "iterm2のキーバインドでのcmd+Cが現状、文字選択時のみにクリップボードへのコピーを行う機能となっています。 \nVSCode等のエディタではcmd+Cにより、選択時は選択箇所を、非選択時にはカーソル行をコピーするような機能があると思います。\n\nこの機能をiterm2上でなおかつcmd+Cのキーで実装したいと考えております。 \nshellにfishを用いているのでfishにてコマンドライン行のコピーコマンドを作り、そのキーバインドをiterm2上で割り当ててみたところ、当然のごとく、選択時のコピー機能を失ってしまいました。\n\nfishコマンドに選択箇所の読み取りコマンドのようなものがあれば実現可能と考えているのですが、割り当てるキーを変える以外に何か同様の機能を実装する手段はないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T11:25:48.807", "favorite_count": 0, "id": "86316", "last_activity_date": "2022-02-17T13:52:59.820", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "36057", "post_type": "question", "score": 2, "tags": [ "macos", "command-line", "shell", "iterm" ], "title": "iterm2で非選択時、コマンドライン行コピーを行うキーバインドを実装したいです。", "view_count": 64 }
[ { "body": "iterm2 python APIにて実現できそうなので試してみます。 \nありがとうございました。\n\n<<<追記 \npython\nAPIを用いた際、文字選択をする機能を用いることができ、コピー機能はコマンド実行により実行することで文字選択できたか否かで条件分岐をすることで実現しました。\n\n以下のスクリプトをデーモンとして動かし、キーバインドしました。参考までに。 \n<https://github.com/s0ran/copy_with_line>", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T15:20:36.023", "id": "86320", "last_activity_date": "2022-02-17T13:52:59.820", "last_edit_date": "2022-02-17T13:52:59.820", "last_editor_user_id": "36057", "owner_user_id": "36057", "parent_id": "86316", "post_type": "answer", "score": 1 } ]
86316
86320
86320
{ "accepted_answer_id": "86412", "answer_count": 1, "body": "`Room`に保存した`isValid`フラグ(`Boolean`)の値を見て \n`true`だったら青の`Text`を表示して \n`false`だったら赤の`Text`を表示するような場合を考えます。\n\n`Room`に`isValid`フラグを`true`で保存して再度アプリを立ち上げると \n`observeAsState`の`initial値`である`false`を`isValidState`は \n取得してその後から`Flow`で流れてきた`true`を取得します。 \nそのため、一瞬`false`のときの赤の`Text`が出てきてから消えて青の`Text`が \n表示されます。 \nこのような場合に、最初から`DB`の値に対応した青の`Text`だけを表示させる方法は \n皆さまどのようにされておりますでしょうか?ご存じもしくはアイデアのある方が \nいらっしゃられましたら、何卒お知恵を頂けますでしょうか。 \nよろしくお願い致します。\n\n```\n\n // Composable\n val isValidState by viewModel.isValid.observeAsState(initial = false)\n \n if (isValidState) {\n Text(text = \"青\", color = Color.Blue)\n } else {\n Text(text = \"赤\", color = Color.Red)\n }\n \n // Viewmodel\n val isValid: LiveData<Boolean> = repository.isValid.asLiveData()\n \n // Repository\n val isValid: Flow<Boolean> = dao.isValid()\n \n // Dao\n @Query(\"SELECT isValid FROM hoge WHERE id = 0\")\n fun isValid(): Flow<Boolean>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T12:16:48.127", "favorite_count": 0, "id": "86318", "last_activity_date": "2022-02-17T07:06:05.830", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51408", "post_type": "question", "score": 0, "tags": [ "android", "kotlin" ], "title": "RoomのデータをFlow経由でLiveDataに渡して初期値の表示を挟まずにComposeに値を反映させたい", "view_count": 183 }
[ { "body": "`observeAsState`の初期値を無くすと`nullable`型になりました。 \n初回コンポーズ時は、`DB`からまだ値が取れていませんので`null`が入り \nその後に値が流れてきます。 \nよって、以下のコードで最初から`DB`の保存値である`true`の場合だけ表示できました。\n\n```\n\n val isValidState: Boolean? by viewModel.isValid.observeAsState()\n \n isValidState?.let {\n if (it) {\n Text(text = \"青\", color = Color.Blue)\n } else {\n Text(text = \"赤\", color = Color.Red)\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T07:06:05.830", "id": "86412", "last_activity_date": "2022-02-17T07:06:05.830", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51408", "parent_id": "86318", "post_type": "answer", "score": 0 } ]
86318
86412
86412
{ "accepted_answer_id": "86446", "answer_count": 1, "body": "以下の環境でPHPを8.0.14->8.1.2に変更しました。 \nその後composer dump-autoloadを実施したところ、以下の非推奨が表示されました。 \nこれらの表示はどのように対応すればよろしいのでしょうか。 \nフレームワークで問題が発生しているようなので、フレームワークが解決するまで \nPHP8.1は使用しない方がよいのでしょうか。\n\n【変更前の環境】 \n・Windows11 \n・PHP8.0.14 \n・Laravel9.0.2\n\n【変更後の環境】 \n・Windows11 \n・PHP8.1.2 \n・Laravel9.0.2\n\n【composer dump-autoloadの結果】\n\n```\n\n C:\\work\\base_Apri>composer dump-autoload\n PHP Deprecated: Return type of Symfony\\Component\\Console\\Helper\\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Helper/HelperSet.php on line 112\n Deprecated: Return type of Symfony\\Component\\Console\\Helper\\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Helper/HelperSet.php on line 112\n Deprecation Notice: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php:48\n Deprecation Notice: Return type of Composer\\Repository\\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ArrayRepository.php:277\n Deprecation Notice: Return type of Composer\\Repository\\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ArrayRepository.php:277\n Deprecation Notice: Return type of Composer\\Repository\\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ArrayRepository.php:277\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Finder::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Finder.php:675\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Finder::count() should either be compatible with Countable::count(): int, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Finder.php:732\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\FilterIterator::rewind() should either be compatible with FilterIterator::rewind(): void, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/FilterIterator.php:30Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\FileTypeFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/FileTypeFilterIterator.php:42\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator::getChildren() should either be compatible with RecursiveDirectoryIterator::getChildren(): RecursiveDirectoryIterator, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php:85\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator::rewind() should either be compatible with FilesystemIterator::rewind(): void, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php:113\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator::current() should either be compatible with FilesystemIterator::current(): SplFileInfo|FilesystemIterator|string, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php:65\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\ExcludeDirectoryFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php:55\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\ExcludeDirectoryFilterIterator::hasChildren() should either be compatible with RecursiveIterator::hasChildren(): bool, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php:71\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\ExcludeDirectoryFilterIterator::getChildren() should either be compatible with RecursiveIterator::getChildren(): ?RecursiveIterator, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php:76\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\FilterIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/FilterIterator.php:30\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\DateRangeFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/DateRangeFilterIterator.php:41\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\PathFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/PathFilterIterator.php:27\n Generating optimized autoload files\n Deprecation Notice: Return type of Symfony\\Component\\Finder\\Iterator\\FilenameFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/finder/Iterator/FilenameFilterIterator.php:28\n Deprecation Notice: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:251\n > Illuminate\\Foundation\\ComposerScripts::postAutoloadDump\n > @php artisan package:discover --ansi\n Discovered Package: barryvdh/laravel-ide-helper\n Discovered Package: fruitcake/laravel-cors\n Discovered Package: kreait/laravel-firebase\n Discovered Package: laravel/sail\n Discovered Package: laravel/tinker\n Discovered Package: laravel/ui\n Discovered Package: maatwebsite/excel\n Discovered Package: nesbot/carbon\n Discovered Package: nunomaduro/collision\n Discovered Package: spatie/laravel-ignition\n Discovered Package: yajra/laravel-oci8\n Package manifest generated successfully.\n Generated optimized autoload files containing 7033 classes\n \n \n```\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T13:33:02.623", "favorite_count": 0, "id": "86319", "last_activity_date": "2022-02-19T00:57:35.690", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "37340", "post_type": "question", "score": 0, "tags": [ "php", "laravel" ], "title": "PHP8.1を使用して発生するcomposer dump-autoloadのエラーについて", "view_count": 1421 }
[ { "body": "composerを再インストールしたところ、問題が解決しました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T00:57:35.690", "id": "86446", "last_activity_date": "2022-02-19T00:57:35.690", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "37340", "parent_id": "86319", "post_type": "answer", "score": 0 } ]
86319
86446
86446
{ "accepted_answer_id": null, "answer_count": 0, "body": "あるYouTubeの動画を参考にpyxelを使用してテトリスを作ろうとしていたところ、エラーが出ました。解決策があれば教えてください。よろしくお願いします。 \n以下は使用したコードとエラーです。\n\n実行環境はwindows11、python3.9.0、pyxel1.6.9、jupyter notebookで実行\n\n```\n\n from random import randint\n import pyxel\n \n TILE_SIZE = 8\n MAP_WIDTH = 14\n MAP_HEIGHT = 25\n WAIT = 60\n \n \n class Tetris:\n def __init__(self):\n self.mGameOver = False\n self.mNext = randint(0,6)\n self.mX = 0\n self.mY = 0\n self.mA = 0\n self.mT = 0\n self.mWait = 0\n \n pyxel.init(MAP_WIDTH*TILE_SIZE , \n MAP_HEIGHT*TILE_SIZE ,fps = 10)\n pyxel.load('tetris.pyxres')\n \n self.next()\n \n pyxel.run(self.update , self.draw)\n \n def update(self):\n pass\n \n def draw(self):\n pyxel.bltm(0,0,0,0,0,MAP_WIDTH,MAP_HEIGHT)\n \n \n def put(self,x,y,t,a,s,test):\n for j in range(4):\n for i in range(4):\n p = [i,3-j,3-i,j]\n q = [j,i,3-j,3-i]\n if pyxel.tilemap(0).get(16+t*4+p[a],q[a]) == 7:\n continue\n \n v=t\n if s == False:\n v=7\n elif pyxel.tilemap(0).get(x+i , y+j) != 7:\n return False\n if test == False:\n pyxel.tilemap(0).set(x+i , y+j , v)\n \n return True\n \n def next(self):\n self.mX = 5\n self.mY = 2\n self.mT = self.mNext\n self.mWait = WAIT\n \n self.mA = 0\n if pyxel.btn(pyxel.KEY_X):\n self.mA = 3\n if pyxel.btn(pyxel.KEY_Z):\n self.mA = 1\n \n if self.put(self.mX , self.mY , self.mT , self.mA , True , False) == False:\n self.mGameOver = True\n \n self.put(5,-1,self.mNext,0,False,False)\n self.mNext = randint(0,6)\n self.put(5,-1,self.mNext,0,True,False)\n \n Tetris()\n \n```\n\n**エラーメッセージ**\n\n```\n\n AttributeError Traceback (most recent call last)\n <ipython-input-1-c5ae4bd3c03b> in <module>\n 69 self.put(5,-1,self.mNext,0,True,False)\n 70 \n ---> 71 Tetris()\n \n <ipython-input-1-c5ae4bd3c03b> in __init__(self)\n 21 pyxel.load('tetris.pyxres')\n 22 \n ---> 23 self.next()\n 24 \n 25 pyxel.run(self.update , self.draw)\n \n <ipython-input-1-c5ae4bd3c03b> in next(self)\n 62 self.mA = 1\n 63 \n ---> 64 if self.put(self.mX , self.mY , self.mT , self.mA , True , False) == False:\n 65 self.mGameOver = True\n 66 \n \n <ipython-input-1-c5ae4bd3c03b> in put(self, x, y, t, a, s, test)\n 37 p = [i,3-j,3-i,j]\n 38 q = [j,i,3-j,3-i]\n ---> 39 if pyxel.tilemap(0).get(16+t*4+p[a],q[a]) == 7:\n 40 continue\n 41 \n \n AttributeError: 'builtins.Tilemap' object has no attribute 'get'\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T18:41:50.847", "favorite_count": 0, "id": "86322", "last_activity_date": "2022-02-14T10:50:40.263", "last_edit_date": "2022-02-13T23:58:34.470", "last_editor_user_id": "3060", "owner_user_id": "51412", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "python , pyxelでのエラーについて", "view_count": 367 }
[]
86322
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "/etc/modprobe.d/blacklist.conf に backlist snd_hda_intel\nを入れて再起動しましたが、スピーカーとマイクが無効になってしまいます。 \nこういう問題が結構あるはずなんだけど見つからない。 \nどうすればいけるでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-13T19:49:58.620", "favorite_count": 0, "id": "86323", "last_activity_date": "2022-02-14T00:14:52.143", "last_edit_date": "2022-02-13T23:04:16.973", "last_editor_user_id": "3060", "owner_user_id": "51165", "post_type": "question", "score": 0, "tags": [ "ubuntu" ], "title": "Ubuntu でマイクだけを無効にしたい", "view_count": 220 }
[ { "body": "ドライバ snd_hda_intel 自体を無効にすると入力(マイク)、出力(スピーカー)とも無効になるのでしょう。 \nGNOME などのデスクトップ環境ならば、パネルから入出力それぞれの音量やミュートができませんでしょうか? \nあるいは、オーディオ管理プログラムが PulseAudio ならば、 \nPulseAudio 音量調節 (pavucontrol) などの GUI アプリや、pactl, pacmd などのコマンドで。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T00:14:52.143", "id": "86325", "last_activity_date": "2022-02-14T00:14:52.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4603", "parent_id": "86323", "post_type": "answer", "score": 1 } ]
86323
null
86325
{ "accepted_answer_id": null, "answer_count": 0, "body": "下記のエラーが解決できないです。 \nご教示の程よろしくお願いいたします。\n\n**エラーメッセージ**\n\n```\n\n Exception: 無効な引数: parent.mimeType\n \n```\n\n**ソースコード**\n\n```\n\n var folder = DriveApp.getFolderById(getid);\n var url = 'https://docs.google.com/spreadsheets/d/'+ getid +'/export?';\n var opts = {\n exportFormat: 'xlsx', // ファイル形式の指定 pdf / csv / xls / xlsx\n format: 'xlsx', // ファイル形式の指定 pdf / csv / xls / xlsx\n size: 'A4', // 用紙サイズの指定 legal / letter / A4\n portrait: 'true', // true → 縦向き、false → 横向き\n fitw: 'true', // 幅を用紙に合わせるか\n  sheetnames: 'false', // シート名を PDF 上部に表示するか\n printtitle: 'false', // スプレッドシート名を PDF 上部に表示するか\n pagenumbers: 'false', // ページ番号の有無\n gridlines: 'false', // グリッドラインの表示有無\n fzr: 'false' // 固定行の表示有無\n //range : 'A1%3AA1', // 対象範囲「%3A」 = :, A1:A1 \n //gid: shId // シート ID を指定 (指定のない場合、スプレッドシート全体をダウンロード)\n };\n \n   var urlExt = [];\n for(optName in opts){\n urlExt.push(optName + '=' + opts[optName]);\n }\n \n var options = urlExt.join('&');\n var token = ScriptApp.getOAuthToken();\n var response = UrlFetchApp.fetch(url + options, {\n headers: {\n 'Authorization': 'Bearer ' + token\n },\n 'muteHttpExceptions' : true\n });\n \n var blob = response.getBlob().setName(ss + '.xlsx');\n Logger.log(blob.getContentType());\n folder.createFile(blob);\n \n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T00:02:47.607", "favorite_count": 0, "id": "86324", "last_activity_date": "2022-02-14T02:50:01.983", "last_edit_date": "2022-02-14T02:50:01.983", "last_editor_user_id": "51242", "owner_user_id": "51242", "post_type": "question", "score": 0, "tags": [ "google-apps-script" ], "title": "「Exception: 無効な引数: parent.mimeTypeのException: 無効な引数: parent.mimeType」の解決方法", "view_count": 511 }
[]
86324
null
null
{ "accepted_answer_id": "88042", "answer_count": 1, "body": "Vercelの公式ドキュメントの記述についてですが、 \nDBに接続する際のIPブロックについて違和感を感じる記述があったので、妥当な内容なのか教えてもらえないでしょうか。\n\n<https://vercel.com/docs/concepts/solutions/databases> \nこちらのページの「Allowing & Blocking IP Addresses」の項目です。\n\n下記のような記述があります。(Google翻訳)\n\n① Vercelは動的IPであるため、接続先のIP許可リストについては「0.0.0.0」ですべてを許可する設定が必要\n\n② セキュリティのためにIP許可リストのみに依存することは一般に効果がなく、不十分なセキュリティ慣行につながる\n\n③\nデータベースを適切に保護するには、環境変数として保存された、少なくとも32文字の長さのランダムに生成されたパスワードを使用し、このパスワードを定期的にローテーションすることをお勧めします。\n\n特に②について意外に感じ、逆にIP制限さえしていれば問題ないと思っていたのですが、IP制限だけでは不十分なのでしょうか?\n\nVercelはIP制限せずに③のパスワード設定の対策だけやれば良いと書いていますが、逆に③の対策だけだと不十分で不安に感じるのですが、どうなんでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T01:36:00.123", "favorite_count": 0, "id": "86326", "last_activity_date": "2022-03-27T04:00:10.957", "last_edit_date": "2022-02-14T01:41:27.050", "last_editor_user_id": "50588", "owner_user_id": "50588", "post_type": "question", "score": 0, "tags": [ "database", "security" ], "title": "DBサーバーへ接続する際のIPブロックについて", "view_count": 346 }
[ { "body": "この質問もそうなのですが、IPアドレスによる接続制御の効能を過大に捉える誤解が割と広まっています。Vercelのドキュメントもそういう問い合わせが多いために用意されたのだと想像します。この誤解が何に由来するのかわからないのですが、誤解してるほうはそれが正しいと思ってるのでその誤解を覆して納得してもらえるような説明をするのはなかなか難しいです。\n\n> 特に②について意外に感じ、逆にIP制限さえしていれば問題ないと思っていたのですが、IP制限だけでは不十分なのでしょうか?\n\n「不十分」とすら言えません。\n\n仮にVercelのIPアドレスが特定できたとします。そのアドレスはVercelのユーザーが共用しているのですから、DBへのアクセスが誰(のアプリ)からのものかを特定することはできません。Vercelに悪意があるユーザーがいる可能性は排除できないので、適切な認証は必要です。\n\n> 逆に③の対策だけだと不十分で不安に感じるのですが、どうなんでしょうか?\n\n「不安」はわからないでもありませんが、それをを解消する手段として「IPブロック」が適切かどうかは検討する必要があります。そして多くの場合誤った手法です。\n\n「認証」と「IPブロック」がそれぞれ何に対して保護を提供するのかについての理解も不十分なようです。業務データを取りあつかうとのことなので、事故が起きる前に知識のある業者さんに相談されることをお勧めします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-03-27T04:00:10.957", "id": "88042", "last_activity_date": "2022-03-27T04:00:10.957", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "86326", "post_type": "answer", "score": 2 } ]
86326
88042
88042
{ "accepted_answer_id": "86329", "answer_count": 1, "body": "初歩的な質問ですいません。if文での表現においてどのようにしたら良いかわからず質問いたします。また、説明も分かりにくいと思われます、どうかよろしくお願い致します。\n\n```\n\n let test = 12.0\n let test2 = 340.99\n var test3 = 時間で変化するような変数が入ります\n \n```\n\nの時に変数(test3)が340.99から突然12.0になってしまった場合はfalseで340.99から340.98...339.12....0というように0に向かって数値が減っていき12.0になった場合にtrueとしたいのですが、そのような場合はどのようにプログラムを組むのでしょうか。 \n通常の<、==でもなくこのような少々複雑な条件がある場合、一つ一つif分を書いていくものなのか一気に解決するような方法があるものなのかよくわからず右往左往しております。ご教授いただけましたら幸いです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T01:55:09.130", "favorite_count": 0, "id": "86327", "last_activity_date": "2022-02-14T03:30:25.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14780", "post_type": "question", "score": 0, "tags": [ "swift", "ios" ], "title": "if文のコードの複雑な記述方法について", "view_count": 142 }
[ { "body": "まずは、許容できる変化量を決めます。 \n次に、直前のtest3を保存しておく変数(ex: test4)を作ります。 \nあとは、test3が更新されるたびに、test3とtext4の差が、許容できる変化量以下かどうかを調べます。 \n継続するときは、test4にtest3を代入します。継続しないときは、trueまたはfalseを返します。 \n全体像が見えないので全くの想像で書きますが、下記は、突然値が小さくなったらfalseを返す関数の例です。\n\n```\n\n function x -> Bool {\n let delta = 0.1\n var test3 = 340.99\n var test4 = test3\n while test3 > 12.0 {\n // \n // ここに、test3を更新する処理を入れる\n //\n if test4 - test3 > delta {\n return false\n }\n test4 = test3\n }\n return true\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T03:30:25.040", "id": "86329", "last_activity_date": "2022-02-14T03:30:25.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8077", "parent_id": "86327", "post_type": "answer", "score": 1 } ]
86327
86329
86329
{ "accepted_answer_id": "86333", "answer_count": 1, "body": "VirtualBox を使ってCentOSやUbuntuを学習しようとしています。\n\n学習の前段としてIntel Virtualization Technologyを「有効」にするように記述されています。\n\n[![text 指示 virtual\nbox](https://i.stack.imgur.com/6ITmz.png)](https://i.stack.imgur.com/6ITmz.png)\n\n私の端末はNECの「LAVIE VEGA LV750/RAL PC-LV750RAL」です。 \n端末の起動時に「F2」を押しBIOS設定画面のAdvanceタグを見ると \n\"Virtualization Technology”を有効化する項目が出来ません。\n\n[![BIOS](https://i.stack.imgur.com/n5YNP.gif)](https://i.stack.imgur.com/n5YNP.gif)\n\n念のためVirtual Checkerを起動させてみると、サポートされていないようです。\n\n[![Virtual\nChecker](https://i.stack.imgur.com/zkLPX.png)](https://i.stack.imgur.com/zkLPX.png)\n\n以前、この項目の事は知らず仮想環境でLinux OSを試した事があるのですが、挙動がおかしかったのはこのせいなのでしょうか?\n\nこのような場合、この端末ではあきらめるしかないのでしょうか? 何か方法をご存じの方いらっしゃいましたら教えてください。よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T04:09:06.283", "favorite_count": 0, "id": "86332", "last_activity_date": "2022-02-14T05:25:14.920", "last_edit_date": "2022-02-14T04:21:58.590", "last_editor_user_id": "3060", "owner_user_id": "42150", "post_type": "question", "score": 0, "tags": [ "linux", "virtualbox", "bios" ], "title": "Intel Virtualization Technologyを「有効」に出来ない", "view_count": 363 }
[ { "body": "[LAVIE LV750](https://www.nec-\nlavie.jp/navigate/products/pc/201q/01/lavie/lv/spec/) 仕様書によると CPU は\n[i7-9750H](https://www.intel.co.jp/content/www/jp/ja/products/sku/191045/intel-\ncore-i79750h-processor-12m-cache-up-to-4-50-ghz/specifications.html) であり CPU\n仕様としては `vt-x` には対応済みなわけですが、ビジネス向けモデルは `vt-x` や `vt-d` を BIOS/UEFI setup\n画面から有効化したり無効化したりできないものがあります。たぶん当該 LAVIE LV750 もそういう仕様なのだと思われます。\n\nメーカー(この場合は NEC ですが)としては PC アセンブリ(完成品)として `vt-x` 等の動作を保証していないということと思われます。\n\nあとはあなたがどう考えるか次第なわけですが\n\n * 別マシンに乗り換えてもよいし(その分の費用は当然発生)\n * 当該マシンの `vt-x` を無理やり有効化してもよいし(改造相当に扱われメーカー保証がなくなるかも)\n\nお好きなほうで。後者なら検索すれば例えば \n[LL750 で Intel VT\nを有効化](https://pontapapa.hatenablog.com/entry/20110417/1303029391) \n[LL750/T の Intel VT-x を有効化](https://assimane.blog.ss-blog.jp/2012-02-08) \nみたいなものは見つかります(がオイラはこのマシン持っていませんしリンク先内容が正しいかどうかなどは一切保証しません)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T05:25:14.920", "id": "86333", "last_activity_date": "2022-02-14T05:25:14.920", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8589", "parent_id": "86332", "post_type": "answer", "score": 3 } ]
86332
86333
86333
{ "accepted_answer_id": null, "answer_count": 0, "body": "MAMPを使ってローカル環境を作り、ワードプレスで作られたサイトを修正しています。 \nMysqlのデータベースやサイトの情報をサーバーからダウンロードして、ローカル環境でページを表示する事ができましたが、wp-admin(もしくはwp-\nlogin.php)にアクセスするとローカルサーバーに繋がらなくなります。\n\nwp-configファイルや.htaccessの記載などに問題があるのでしょうか? \n何かお気づきの点などあれば、助けて頂けると幸いです。\n\n作業環境 \nmac book pro \nmacos monterey", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T07:01:18.647", "favorite_count": 0, "id": "86335", "last_activity_date": "2022-02-14T07:01:18.647", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51417", "post_type": "question", "score": 0, "tags": [ "php", "wordpress", "mamp" ], "title": "ローカル環境でwordpressの管理画面に繋がらない", "view_count": 373 }
[]
86335
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "オブジェクト指向について質問です。\n\n以下の記事から引用いたします。\n\n[Railsモデルのメソッドの命名について](https://qiita.com/qpSHiNqp/items/7bcb0492c777a488ceba#%E4%BD%9C%E7%94%A8%E3%82%92%E4%BC%B4%E3%81%86%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89)\n\nいい例として、レシーバとインスタンスメソッドは、他動詞と目的語の関係であるとあります。 \nそして、悪い例として、レシーバとインスタンスメソッドは、主語と動詞の関係とあります。\n\nいい例\n\n```\n\n cow.grow # <= I grow up the cow. その結果 cow.age はインクリメントされる、などの作用が起こる。\n file.delete # <= I delete the file. その結果、(プログラムにとっては)外部のファイルシステム上でファイルが消える作用を起こす。\n job.perform # <= I perform the job.\n \n```\n\n悪い例\n\n```\n\n manager.evaluate(member) # <= 語順そのまま A manager evaluates his member.\n \n```\n\nしかし、railsチュートリアルだと以下のようなメソッドを実装しているんですよね。 \nこれは、user follow other user、なので悪い例にあてはまるケースですよね。\n\n```\n\n # app/models/user.rb\n \n # ユーザーをフォローする\n def follow(other_user)\n active_relationships.create(followed_id: other_user.id)\n end\n \n # ユーザーをアンフォローする\n def unfollow(other_user)\n active_relationships.find_by(followed_id: other_user.id).destroy\n end\n \n```\n\n[railsチュートリアル12章](https://railstutorial.jp/chapters/following_users?version=4.2#:%7E:text=%23%20%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC%E3%82%92%E3%83%95%E3%82%A9%E3%83%AD%E3%83%BC,include%3F\\(other_user\\)%0A%20%20end)\n\nこれはこの記事の主張が間違っているのか、チュートリアルがオブジェクト指向の原則から外れているのかでいうとどちらでしょう?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T10:51:30.270", "favorite_count": 0, "id": "86336", "last_activity_date": "2022-02-17T22:14:21.070", "last_edit_date": "2022-02-17T22:14:21.070", "last_editor_user_id": "40650", "owner_user_id": "40650", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby" ], "title": "オブジェクト指向的に書く場合、レシーバは主語ではなく目的語? railsチュートリアルとどちらが正しい??", "view_count": 292 }
[ { "body": "命名規則は、言語毎にある程度の決まりはありますが、それ以上はプロジェクトチームごとに統一するとか、場合によってはプロジェクト毎に決めれば良いだけで、絶対的な物は無いと思います。\n\nそれはさておき、Smalltalkというオブジェクト指向言語を広めた言語では、 \n・オブジェクトにはメッセージを送る。そのメッセージをどのように解釈するかは、受け取ったオブジェクト次第。 \nという考え方があります。その考えを採用するなら、メソッドの「悪い例」のほうがオブジェクト指向的だと思います。 \n「良い例」は、「私」が主語になっているので、オブジェクトの動作を決めるのは呼び出し側であり、オブジェクトはその結果を与えられるという思想になっています。一方、「悪い例」では、オブジェクトに動作を決める権限を与えています。\n\nまた、「良い例」は、主語を「I」、目的語をオブジェクトにしようとしてバランスが崩れている気もします。 \ncow.grow は(結果的に)cowが主語になっていますし、 \nfile.deleteは主張どおり目的語・述語になっていますが、英語の語順としておかしくなっています。 \n単純に、 \nfileManager.delete(file) \nのように、オブジェクトを目的語らしく使った方が自然です。\n\nとはいえ、最初に書いたとおり、命名規則はプロジェクトチームやプロジェクト毎に決めれば良い物なので、どちらにするかを「決めること」が大事です。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T00:03:53.270", "id": "86341", "last_activity_date": "2022-02-15T00:03:53.270", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8077", "parent_id": "86336", "post_type": "answer", "score": 4 }, { "body": "元のメソッドの命名についての記事はさすがに英語の文法(語順)に引っ張られすぎで、そのために何か変な話になってしまっているんではないでしょうか。\n\n```\n\n cow.grow\n file.delete\n \n```\n\nといった例自体は悪くないかと思います。が、これは英語の語順によるものというよりは、`cow`や`file`といったオブジェクトにロジックを寄せるべきで、なんとかmanagerみたいなものにロジックを寄せると`cow`や`file`が単なるデータ置き場になる、いわゆる[ドメインモデル貧血症](https://bliki-\nja.github.io/AnemicDomainModel/)になってしまいます。こういったことを避けるためではないでしょうか。\n\nそれでいくと、ユーザーをフォローする・アンフォローするといったロジックであれば、普通にuserのメソッドとして実装することは自然で特に問題なさそうです。\n\nというわけで、コードの良し悪しについては元の記事もRailsチュートリアルのサンプルもどちらも正しそうです。ただし、その正しさの基準について、英語の語順を根拠として持ち出すことは正しくないのではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T16:41:49.640", "id": "86422", "last_activity_date": "2022-02-17T16:41:49.640", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12678", "parent_id": "86336", "post_type": "answer", "score": 2 } ]
86336
null
86341
{ "accepted_answer_id": "86343", "answer_count": 1, "body": "初心者です。 \n今現在、ワードプレスでホームページを作ってます、 \nカスタムフィールドで登録した画像をトップ・ページで表示する方法を試していますが、上手くいきません、\n\n今現在は、single.phpで作成したもの、をトップページに持って来るようにPHPを書いています。 \n画像と文章をカスタムフィールドに設定していて、 \n文章はうまく表示されていますが画像は写真の通り表示できません。\n\n固定ページのID は2です。 \nまた画像の名前は、participant-photo3です。 \n返り値はURLにしてます。\n\nHTMLを検証ツールで確認したところ、\n\nとなりました。 プラグイン Advanced Custom Fields を使用、\n\nトップページ\n\nファイル名 front-page-php トップページ用のファイル\n\nPHP\n\n```\n\n <div class=\"list-content-third\">\n <div class=\"list-inner\">\n <div class=\"list-area\">\n <div class=\"list-area-title\">\n <p class=\"area-txt\">早稲田大学国際教育学部AO入試合格!TOEFLiBT109点</p>\n </div>\n ーーーー画像ーーーーーーー\n <div class=\"list-img\">\n <div class=\"person-img\">\n <?php if (get_field('participant-photo3','2')) : ?>\n <img class=\"test-image\" src=\"<?php the_field('participant-photo3'); ?>\" />\n <?php endif; ?>\n </div>\n </div>\n ーーーーーーここまでーーーーーー\n <div class=\"list-area-txt\">\n <div class=\"txt-item\">\n <?php the_field('participant7', '2'); ?>\n </div>\n <div class=\"txt-item-second\">\n <?php the_field('participant8', '2'); ?>\n </div>\n </div>\n <div class=\"txt-item-third\">\n <?php the_field('participant9', '2'); ?>\n </div>\n </div>\n </div>\n \n```\n\n固定ページ用のファイル \nファイル名 single.php\n\nPHP\n\n```\n\n <div class=\"list-content-third\">\n <div class=\"list-inner\">\n <div class=\"list-area\">\n <div class=\"list-area-title\">\n <p class=\"area-txt\">早稲田大学国際教育学部AO入試合格!TOEFLiBT109点</p>\n </div>\n ーーーー画像ーーーーーーー\n <div class=\"list-img\">\n <div class=\"person-img-third\">\n <?php if (get_field('participant-photo3')) : ?>\n <img class=\"test-image\" src=\"<?php the_field('participant-photo3'); ?>\" />\n <?php endif; ?>\n </div>\n </div>\n ーーーーーーここまでーーーーーー\n <div class=\"list-area-txt\">\n <div class=\"txt-item\">\n <p class=\"txt-item-area\"><?php echo get_post_meta($post->ID, 'participant7', true); ?></p>\n </div>\n <div class=\"txt-item-second\">\n <p class=\"txt-item-area-second\"><?php echo get_post_meta($post->ID, 'participant8', true); ?></p>\n </div>\n </div>\n <div class=\"txt-item-third\">\n <p class=\"txt-item-area-third\"><?php echo get_post_meta($post->ID, 'participant9', true); ?></p>\n </div>\n </div>\n </div>\n </div> \n \n```\n\n画像のように3つ並んだ空白に画像を入れ、下の3つの白い枠に文字を入れます。 \nこういった繰り返しの処理(ループ)をするのが一般的で、そういうコードにするべきでしょうか?\n\n[![ページトップ](https://i.stack.imgur.com/3G5tF.png)](https://i.stack.imgur.com/3G5tF.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-14T13:47:31.633", "favorite_count": 0, "id": "86339", "last_activity_date": "2022-02-15T01:48:08.717", "last_edit_date": "2022-02-15T01:48:08.717", "last_editor_user_id": "49042", "owner_user_id": "49042", "post_type": "question", "score": 0, "tags": [ "php", "wordpress" ], "title": "ワードプレスのカスタムフィールドで、画像を入れようとしてますが表示できません。", "view_count": 149 }
[ { "body": "get_fieldでは第2引数にpostのidの2を指定して参照していますが、 \nimgのsrcでは第2引数にpostのidを指定してません。\n\n[the_field](https://www.advancedcustomfields.com/resources/the_field/)も[get_field](https://www.advancedcustomfields.com/resources/get_field/)もデフォルトは今のpostのidが利用されるようです。 \n同様にpostのIDを指定すればいいと思います。 \n正しいpostのIDはわからないので調査して同じpostのIDを設定してみてください。 \n仮に2だとすれば以下のようなソースになると思います。\n\n```\n\n <?php if (get_field('participant-photo3', 2)) : ?>\n <img class=\"test-image\" src=\"<?php the_field('participant-photo3', 2); ?>\" />\n <?php endif; ?>\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T01:38:57.317", "id": "86343", "last_activity_date": "2022-02-15T01:38:57.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22665", "parent_id": "86339", "post_type": "answer", "score": 1 } ]
86339
86343
86343
{ "accepted_answer_id": "86362", "answer_count": 1, "body": "CentOS で `sudo yum install nodejs -y` を実行したところ、 \n\"問題を回避するために --skip-broken を用いることができます。\" \nと出てきます。どすればいいのでしょうか?\n\n```\n\n 読み込んだプラグイン:fastestmirror, langpacks\n Loading mirror speeds from cached hostfile\n * base: ftp.jaist.ac.jp\n * epel: ftp.jaist.ac.jp\n * extras: ftp.jaist.ac.jp\n * updates: ftp.riken.jp\n 依存性の解決をしています\n --> トランザクションの確認を実行しています。\n ---> パッケージ nodejs.x86_64 1:6.17.1-1.el7 を 更新\n --> 依存性の処理をしています: nodejs = 1:6.17.1-1.el7 のパッケージ: 1:npm-3.10.10-1.6.17.1.1.el7.x86_64\n ---> パッケージ nodejs.x86_64 2:8.17.0-1nodesource を アップデート\n --> トランザクションの確認を実行しています。\n ---> パッケージ npm.x86_64 1:3.10.10-1.6.17.1.1.el7 を 更新\n ---> パッケージ npm.x86_64 1:8.1.2-1.16.13.2.7.el7 を アップデート\n --> 依存性の処理をしています: nodejs = 1:16.13.2-7.el7 のパッケージ: 1:npm-8.1.2-1.16.13.2.7.el7.x86_64\n --> 依存性解決を終了しました。\n エラー: パッケージ: 1:npm-8.1.2-1.16.13.2.7.el7.x86_64 (epel)\n 要求: nodejs = 1:16.13.2-7.el7\n 削除中: 1:nodejs-6.17.1-1.el7.x86_64 (@epel)\n nodejs = 1:6.17.1-1.el7\n 次のものにより更新された: : 2:nodejs-8.17.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.17.0-1nodesource\n 利用可能: 1:nodejs-16.13.2-7.el7.x86_64 (epel)\n nodejs = 1:16.13.2-7.el7\n 利用可能: 2:nodejs-8.0.0-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.0.0-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.1.0-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.1.0-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.1.1-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.1.1-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.1.2-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.1.2-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.1.3-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.1.3-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.1.4-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.1.4-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.2.0-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.2.0-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.2.1-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.2.1-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.3.0-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.3.0-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.4.0-1nodesource.el7.centos.x86_64 (nodesource)\n nodejs = 2:8.4.0-1nodesource.el7.centos\n 利用可能: 2:nodejs-8.5.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.5.0-1nodesource\n 利用可能: 2:nodejs-8.6.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.6.0-1nodesource\n 利用可能: 2:nodejs-8.7.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.7.0-1nodesource\n 利用可能: 2:nodejs-8.8.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.8.0-1nodesource\n 利用可能: 2:nodejs-8.8.1-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.8.1-1nodesource\n 利用可能: 2:nodejs-8.9.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.9.0-1nodesource\n 利用可能: 2:nodejs-8.9.1-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.9.1-1nodesource\n 利用可能: 2:nodejs-8.9.2-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.9.2-1nodesource\n 利用可能: 2:nodejs-8.9.3-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.9.3-1nodesource\n 利用可能: 2:nodejs-8.9.4-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.9.4-1nodesource\n 利用可能: 2:nodejs-8.10.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.10.0-1nodesource\n 利用可能: 2:nodejs-8.11.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.11.0-1nodesource\n 利用可能: 2:nodejs-8.11.1-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.11.1-1nodesource\n 利用可能: 2:nodejs-8.11.2-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.11.2-1nodesource\n 利用可能: 2:nodejs-8.11.3-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.11.3-1nodesource\n 利用可能: 2:nodejs-8.11.4-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.11.4-1nodesource\n 利用可能: 2:nodejs-8.12.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.12.0-1nodesource\n 利用可能: 2:nodejs-8.13.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.13.0-1nodesource\n 利用可能: 2:nodejs-8.14.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.14.0-1nodesource\n 利用可能: 2:nodejs-8.14.1-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.14.1-1nodesource\n 利用可能: 2:nodejs-8.15.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.15.0-1nodesource\n 利用可能: 2:nodejs-8.15.1-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.15.1-1nodesource\n 利用可能: 2:nodejs-8.16.0-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.16.0-1nodesource\n 利用可能: 2:nodejs-8.16.1-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.16.1-1nodesource\n 利用可能: 2:nodejs-8.16.2-1nodesource.x86_64 (nodesource)\n nodejs = 2:8.16.2-1nodesource\n 問題を回避するために --skip-broken を用いることができます。\n \n```\n\n* * *\n\n追記 \n`yum list nodejs` \nの実行結果\n\n```\n\n $ yum list nodejs\n 読み込んだプラグイン:fastestmirror, langpacks\n Determining fastest mirrors\n * base: ftp.jaist.ac.jp\n * epel: ftp.jaist.ac.jp\n * extras: ftp.jaist.ac.jp\n * updates: ftp.riken.jp\n google-chrome 3/3\n slack 81/81\n インストール済みパッケージ\n nodejs.x86_64 1:6.17.1-1.el7 @epel \n 利用可能なパッケージ\n nodejs.x86_64 2:8.17.0-1nodesource nodesource\n \n```\n\n`yum repolist`の実行結果\n\n```\n\n yum repolist\n 読み込んだプラグイン:fastestmirror, langpacks\n Loading mirror speeds from cached hostfile\n * base: ftp.jaist.ac.jp\n * epel: ftp.jaist.ac.jp\n * extras: ftp.jaist.ac.jp\n * updates: ftp.riken.jp\n リポジトリー ID リポジトリー名 状態\n base/7/x86_64 CentOS-7 - Base 10,072\n code Visual Studio Code 1,911\n epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,728\n extras/7/x86_64 CentOS-7 - Extras 500\n google-chrome google-chrome 3\n nodesource/x86_64 Node.js Packages for Enterprise Linux 7 - x86_64 119\n slack slack 81\n updates/7/x86_64 CentOS-7 - Updates 3,411\n virtualbox/7/x86_64 Oracle Linux / RHEL / CentOS-7 / x86_64 - VirtualBox 100\n repolist: 29,925\n \n \n```\n\n<https://parashuto.com/rriver/tools/updating-node-js-and-npm> \nこのサイトの書いてある通りに実行してもエラーが発生しました。\n\n```\n\n npm audit\n npm ERR! code ENOLOCK\n npm ERR! audit This command requires an existing lockfile.\n npm ERR! audit Try creating one first with: npm i --package-lock-only\n npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file\n \n npm ERR! A complete log of this run can be found in:\n npm ERR! /root/.npm/_logs/2022-02-15T04_26_48_418Z-debug.log\n \n \n```\n\n* * *\n\n追記 \n`sudo yum remove nodejs npm` \nを実行したところ、\n\n```\n\n 読み込んだプラグイン:fastestmirror, langpacks\n 引数に一致しません: nodejs\n 引数に一致しません: npm\n 削除対象とマークされたパッケージはありません。\n \n```\n\nと出てきましたが、 \nnode.jsを入れ直すとなぜか上手く?インストール出来たようです。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T02:12:16.567", "favorite_count": 0, "id": "86344", "last_activity_date": "2022-02-16T06:40:02.133", "last_edit_date": "2022-02-16T06:40:02.133", "last_editor_user_id": "50834", "owner_user_id": "50834", "post_type": "question", "score": 0, "tags": [ "linux", "node.js", "centos" ], "title": "node.js のインストールがうまくできない", "view_count": 2643 }
[ { "body": "nodesource のリポジトリを追加した際に恐らく何らかの警告が表示されていたかと思いますが、 \n既に別のリポジトリ (EPEL) から node.js / npm パッケージがインストールされているのが原因です。\n\nまずは既存のインストール済みパッケージをアンインストールしてください。 \n(必要に応じてバックアップ等を事前に実施してください)\n\n```\n\n $ sudo yum remove nodejs npm\n \n```\n\nその後、改めて nodejs パッケージをインストールします。\n\n```\n\n $ sudo yum install nodejs\n \n```\n\n場合によっては EPEL リポジトリを一時的に無効にした方がよいかもしれません。\n\n```\n\n $ sudo yum --disablerepo=epel install nodejs\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T07:24:56.873", "id": "86362", "last_activity_date": "2022-02-15T07:24:56.873", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "86344", "post_type": "answer", "score": 1 } ]
86344
86362
86362
{ "accepted_answer_id": "86363", "answer_count": 1, "body": "Python selenium でダウンロードしてきたファイルを指定したディレクトリに保存したいです. \n↓サイトを参考にしましたが“Downloads”フォルダに入ってしまいます. \n<https://qiita.com/KWS_0901/items/33ae052e2e4694a6b4f1> \n↓サイトの方法を試しましたが解決しませんでした. \n[https://ja.stackoverflow.com/questions/61642/seleniumでダウンロードしてきたファイルをデスクトップに保存したい](https://ja.stackoverflow.com/questions/61642/selenium%E3%81%A7%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89%E3%81%97%E3%81%A6%E3%81%8D%E3%81%9F%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E3%83%87%E3%82%B9%E3%82%AF%E3%83%88%E3%83%83%E3%83%97%E3%81%AB%E4%BF%9D%E5%AD%98%E3%81%97%E3%81%9F%E3%81%84)\n\n具体的な目標:\nGoogle検索でfiletype:pdfを使ってPDFのURLを収集して,requestsで直接ダウンロードして,requestsでダウンロードできなかったファイルをseleniumでダウンロードする\n\n気づいたこと: PDFのURLは少なくとも2種類に分けられます. \n1\\. クリックした瞬間ダウンロードのポップアップが出るもの \n2\\. 印刷しないとダウンロードが始まらないもの \n1.のURLの末尾には“php?”が含まれていることが多いです.下記スクリプトで1.をダウンロードするときは指定したディレクトリにダウンロードされますが,同じスクリプトで2.をダウンロードすると“Downloads”に保存されます.1.のダウンロードの際にChromeの左下にダウンロードバーが表示されますが2.ではダウンロードバーは表示されません.\n\nparamsの設定が部分的に適応されていることから—kiosk-printingに問題があるように感じます.\n\n環境: \nmacOS 12.3 Beta \nPython 3.9.9 \nselenium 4.1.0 \nGoogle Chrome 98.0.4758.102 (Official Build) (x86_64) \nchromedriver 98.0.4758.80 (webdriver_manager)\n\n以下スクリプト\n\n```\n\n # https://qiita.com/KWS_0901/items/33ae052e2e4694a6b4f1\n from selenium import webdriver\n from selenium.webdriver.support.ui import WebDriverWait\n from selenium.webdriver.support import expected_conditions as EC\n from webdriver_manager.chrome import ChromeDriverManager\n from selenium.webdriver.chrome import service as fs\n from selenium.webdriver.chrome.options import Options\n #from pathlib import Path\n import os\n import time\n import json\n \n # 保存対象URL一覧取得\n urls = []\n with open('urls.txt', mode='rt', encoding='utf-8') as f:\n urls = f.readlines()\n \n # Chrome の印刷機能でPDFとして保存\n #options = webdriver.ChromeOptions()\n options = Options()\n \n # PDF印刷設定\n appState = {\n \"recentDestinations\": [\n {\n \"id\": \"Save as PDF\",\n \"origin\": \"local\",\n \"account\": \"\"\n }\n ],\n \"selectedDestinationId\": \"Save as PDF\",\n \"version\": 2,\n \"pageSize\": 'A4'\n }\n \n downloadsFilePath = ''\n \n # ドライバへのPDF印刷設定の適用\n \"\"\"\n options.add_experimental_option(\"prefs\", {\n \"printing.print_preview_sticky_settings.appState\": json.dumps(appState),\n \"download.default_directory\": downloadsFilePath,\n 'download.prompt_for_download': False,\n \"download.directory_upgrade\": True,\n 'safebrowsing.enabled': True\n })\n \"\"\"\n \n prefs = {}\n prefs['download.default_directory'] = os.path.abspath(downloadsFilePath)# + r\"/\"\n prefs['printing.print_preview_sticky_settings.appState'] = json.dumps(appState)\n #prefs['download.prompt_for_download'] = False\n prefs['download.directory_upgrade'] = True\n #prefs['safebrowsing.enabled'] = True\n options.add_experimental_option('prefs', prefs)\n options.add_argument('--kiosk-printing')\n \n #with webdriver.Chrome(\"./chromedriver\", options=options) as driver:\n with webdriver.Chrome(service=fs.Service(executable_path=ChromeDriverManager().install()),options=options) as driver:\n # 任意のHTMLの要素が特定の状態になるまで待つ\n wait = WebDriverWait(driver, 15)\n for url in urls:\n driver.implicitly_wait(10)\n driver.get(url)\n # ページ上のすべての要素が読み込まれるまで待機\n wait.until(EC.presence_of_all_elements_located)\n # PDFとして印刷\n driver.execute_script('return window.print()')\n # 待機\n time.sleep(10)\n driver.quit()\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T03:13:19.050", "favorite_count": 0, "id": "86347", "last_activity_date": "2022-02-15T08:06:53.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "50898", "post_type": "question", "score": 1, "tags": [ "python", "google-chrome", "selenium", "pdf" ], "title": "Python seleniumでPDFを好きなディレクトリに保存したい", "view_count": 2448 }
[ { "body": "Windows10の環境では、コメントで紹介した以下の記事にあった`savefile.default_directory`を設定することで指定したディレクトリにPDFファイルを保存することが出来ました。 \n[how to make headless chrome support\nwindow.print?](https://stackoverflow.com/q/60463587/9014308) \n[Save as PDF using Selenium and\nChrome](https://stackoverflow.com/q/61798725/9014308)\n\n質問の紹介記事に掲載されていたプログラムで`chromedriver.exe`のパスを自分の環境に合わせたのと、 \n[[Python]Seleniumを利用したWebページのPDF保存方法\nメモ](https://qiita.com/KWS_0901/items/33ae052e2e4694a6b4f1)\n\n以下の部分の`download.default_directory`の行を\n\n```\n\n # ドライバへのPDF印刷設定の適用\n options.add_experimental_option(\"prefs\", {\n \"printing.print_preview_sticky_settings.appState\":\n json.dumps(appState),\n \"download.default_directory\": '~/Downloads'\n })\n \n```\n\nこんな風に`savefile.default_directory`と指定のディレクトリに変えただけです。\n\n```\n\n # ドライバへのPDF印刷設定の適用\n options.add_experimental_option(\"prefs\", {\n \"printing.print_preview_sticky_settings.appState\":\n json.dumps(appState),\n \"savefile.default_directory\": r'C:\\WebSiteLog'\n })\n \n```\n\n試してみてください。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T08:06:53.223", "id": "86363", "last_activity_date": "2022-02-15T08:06:53.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86347", "post_type": "answer", "score": 1 } ]
86347
86363
86363
{ "accepted_answer_id": "86353", "answer_count": 1, "body": "実現したいこと \n以下の対象辞書イメージのkey(Data_x[xx])で[xx]の数字が同じ場合、そのvalueを合成後、新しい辞書を作成したいです\n\n対象辞書イメージ\n\n```\n\n Test=\n {'Data_1[1]': 'test','Data_1[2]': 'call','Data_1[5]': 'pkup','Data_2[1]': 'direct','Data_2[5]': 'all','Data_3[2]': 'direct','Data_3[5]': 'all',}\n \n```\n\n※ 例[1]の場合\n\n```\n\n 'Data_1[1]': 'test'\n 'Data_2[1]': 'direct'\n ⇒'FData_1':'test direct'\n \n```\n\n最終結果イメージ\n\n```\n\n FTest ={'FData_1':'test direct','FData_2':'call direct','FData_5':'pkup all all'}\n \n```\n\n何卒よろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T03:40:05.267", "favorite_count": 0, "id": "86348", "last_activity_date": "2022-02-15T04:40:27.973", "last_edit_date": "2022-02-15T03:45:33.543", "last_editor_user_id": "9820", "owner_user_id": "51133", "post_type": "question", "score": 1, "tags": [ "python" ], "title": "辞書内の値を合わせたい", "view_count": 54 }
[ { "body": "```\n\n import re\n \n Test = {\n 'Data_1[1]': 'test', 'Data_1[2]': 'call',\n 'Data_1[5]': 'pkup', 'Data_2[1]': 'direct',\n 'Data_2[5]': 'all', 'Data_3[2]': 'direct',\n 'Data_3[5]': 'all',\n }\n \n FTest = {}\n for k, v in Test.items():\n idx = 'FData_' + re.findall(r'\\[(\\d+)\\]', k)[0]\n if idx not in FTest:\n FTest[idx] = v\n else:\n FTest[idx] += ' ' + v\n \n print(FTest)\n \n #\n {'FData_1': 'test direct', 'FData_2': 'call direct', 'FData_5': 'pkup all all'}\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T04:31:49.510", "id": "86353", "last_activity_date": "2022-02-15T04:40:27.973", "last_edit_date": "2022-02-15T04:40:27.973", "last_editor_user_id": "47127", "owner_user_id": "47127", "parent_id": "86348", "post_type": "answer", "score": 0 } ]
86348
86353
86353
{ "accepted_answer_id": null, "answer_count": 2, "body": "PICとpySerialを利用してシリアル通信を行うプログラムを作成しています。 \n以下のようなプログラムを実行したところ、”IndexError: index out of range”というエラーが発生しています。 \n解決方法を教えていただきたいです。\n\n```\n\n #import sys\n import serial\n from serial import SerialException\n import datetime\n \n # 秒数を時分秒に分解\n def get_hms(td):\n m,s = divmod(td.seconds, 60)\n h,m = divmod(m,60)\n return (h,m,s)\n \n # datetimeの英語フォーマット変換\n def get_endate(dt):\n weekList = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' 'Sun']\n monthList = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\n weekNo = dt.weekday()\n monthNo = dt.month\n \n s = '{0} {1} {2}\\n'.format(\n weekList[weekNo],\n monthList[monthNo - 1],\n dt.strftime(\"%d %H:%M:%S %Y\"))\n return s\n \n \n # プログラム開始\n N_Smpl = 10000\n N_data = 20000\n \n #argv = sys.argv;\n #######exit()\n \n fname_out = \"data1.txt\" # 保存先ファイル\n portName = \"COM3 \" # COMポートの番号を保存する変数\n BaudRate = int(115200) # baud rateを保存する変数\n flowcontrol = \"CTSRTS\" # フロー制御の種類を保存する変数\n \n if(flowcontrol != \"CTSRTS\" and flowcontrol != \"none\"):\n print(\"フロー制御の種類が不正です.CTSRTS,noneのいずれかを指定してください\")\n print(\"\\n\\n\")\n #print(\"%s max min step blk fname1 fname2 comN baud flow\\n\\n\", argv[0])\n print(\" max Eb/Noの最大値\\n\")\n print(\" min Eb/Noの最小値\\n\")\n print(\" step Eb/Noのステップ値\\n\")\n print(\" blk 送信ブロック数\\n\")\n print(\" fname1 出力ファイル名\\n\")\n print(\" fname2 出力ファイル名(PICから)\\n\")\n print(\" comN 使用するCOMポートの番号 例:COM1\\n\")\n print(\" baud ボーレートの値\\n\")\n print(\" flow 使用するフロー制御の種類 CTSRTS,noneのいずれか\\n\")\n exit()\n \n ByteSize = serial.EIGHTBITS # ストップビット長\n Parity = serial.PARITY_NONE # パリティ\n StopBits = serial.STOPBITS_ONE # ストップビット\n RtsCts = False # RTSCTS 有効/無効\n if(flowcontrol == \"CTSRTS\"):\n RtsCts = True\n \n #COMポート設定を適用\n ser = serial.Serial(\"COM3\",baudrate = 115200,parity = serial.PARITY_NONE,timeout=None)\n \n #バッファのクリア\n ser.reset_input_buffer()\n \n # 追記モードでファイルオープン\n fp = open(fname_out, 'a')\n #現在時刻の取得\n starttime = datetime.datetime.now()\n s = '# プログラム開始時刻: {0}\\n'.format(get_endate(starttime))\n fp.write(s)\n #s = '# 実行コマンド:{0} {1} {2} {3} {4}\\n'.format(argv[0], argv[1], argv[2], argv[3], argv[4])\n fp.write(s)\n \n # ポートのオープン処理\n if(ser.is_open == False):\n \n try:\n ser.open()\n except SerialException:\n print(\"output file open error !!\")\n exit()\n \n print(\"PICと通信開始\")\n \n TXstarttime = datetime.datetime.now()\n \n j = 0\n \n while(True):\n #if (j%1000) == 0: print(\"{}\").format(j)\n # データ受信開始\n toReadBytes = N_data\n D_PIC = ser.read(toReadBytes)\n \n #ファイル追加処理\n \n for k in range(1,N_Smpl):\n flag = 0\n if ((D_PIC[2*k] & 128)==128):\n flag = 1\n d = (3 & D_PIC[2*k]) * 256 + D_PIC[2*k+1]\n c = j * N_Smpl + k\n s = '{0} {1}\\n'.format(d, c)\n fp.write(s)\n \n #経過時間を表示\n td = datetime.datetime.now() - TXstarttime\n s = '#{0} 経過時間:{1:d}[sec]\\n'.format(j, td.seconds)\n fp.write(s)\n \n if(flag == 1): \n break\n j += 1\n \n \n # COMポートをクローズ\n ser.close()\n \n # 終了時刻を表示\n endtime = datetime.datetime.now()\n s = '# プログラム終了時刻: {0}\\n'.format(get_endate(endtime))\n fp.write(s)\n \n # 経過時間を表示\n day = td.days\n (hour, min , sec) = get_hms(td)\n \n s = '# 処理時間: {0}日{1}時間{2}分{3}秒\\n'.format(day, hour, min, sec)\n fp.write(s)\n s = '= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\\n'\n fp.write(s)\n fp.close()\n \n print(\"データ取得を終了します:(リターンキーで終了)\")\n input()\n \n```\n\n#### エラーメッセージ\n\n```\n\n C:\\python>python LogPIC32Py2.py\n PICと通信開始\n Traceback (most recent call last):\n File \"C:\\python\\LogPIC32Py2.py\", line 103, in <module>\n if ((D_PIC[2*k] & 128)==128):\n IndexError: index out of range\n \n```\n\nプログラム上のファイル追加処理を以下の通り変更しました。\n\n##### ファイル追加処理\n\n```\n\n for k in range(1,N_Smpl):\n flag = 0\n try:\n if ((D_PIC[2*k] & 128)==128):\n flag = 1\n d = (3 & D_PIC[2*k]) * 256 + D_PIC[2*k+1]\n c = j * N_Smpl + k\n s = '{0} {1}\\n'.format(d, c)\n fp.write(s)\n except IndexError:\n print('Error')\n print(len(D_PIC))\n print(2*k)\n os.system('PAUSE')\n \n```\n\n#### 結果\n\n```\n\n C:\\python>python LogPIC32Py2.py\n PICと通信開始\n Error\n 0\n 2\n 続行するには何かキーを押してください . . .\n Error\n 0\n 4\n 続行するには何かキーを押してください . . .\n Error\n 0\n 6\n 続行するには何かキーを押してください . . .\n \n```", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T03:55:43.413", "favorite_count": 0, "id": "86350", "last_activity_date": "2023-05-30T10:01:15.137", "last_edit_date": "2022-02-15T06:47:48.217", "last_editor_user_id": "3060", "owner_user_id": "51433", "post_type": "question", "score": 0, "tags": [ "python", "シリアル通信" ], "title": "pySerial を用いたシリアル通信プログラムのエラー解決", "view_count": 1604 }
[ { "body": "そのエラーは配列やリストの要素の個数を超えてアクセスしようとしたときに出ます \nそのエラーが出たところで実行を止め、リストの要素数とアクセスするインデックスの数値をチェックしてみよう", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T04:54:31.400", "id": "86355", "last_activity_date": "2022-02-15T04:54:31.400", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27481", "parent_id": "86350", "post_type": "answer", "score": 0 }, { "body": "その調査結果では、`len(D_PIC)`が 0 なのでシリアルポートからのデータ読み込み結果が 0 バイトという状態になります。 \nデータの存在しないbytesオブジェクトということなので、何処を読み取ろうとしてもエラーでしょう。\n\n`D_PIC =\nser.read(toReadBytes)`の結果で正常にデータが読み込まれているか、あるいはその前に[in_waiting](https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.in_waiting)で十分なデータがバッファに入っているか、等をチェックした方が良いでしょう。\n\n他の装置で動作した実績のあるプログラムならば、その動作した装置との違いを調べてみてください。\n\n初めてプログラムして初めて発生した現象であるならば、そもそもPICと通信出来ているか等、Pythonでは無いツールなどで確かめてみるとかしてみてください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T06:56:14.960", "id": "86360", "last_activity_date": "2022-02-15T06:56:14.960", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86350", "post_type": "answer", "score": 0 } ]
86350
null
86355
{ "accepted_answer_id": null, "answer_count": 1, "body": "消したい要素の上で右クリックして「検証」を選びます。 \nHTMLの要素が青枠で示され、さらにStylusに消したい要素を記述します。 \n`.entry-card-content {display: none;}`\n\nその要素はdivに設定されているclass「entry-card-content」らしいですが、なぜ、`entry-card-content`\nとなるのでしょうか。 \n`.entry-card-content` の代わりに他のコードを記述するとどうなるのでしょうか\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/mLvEe.jpg)](https://i.stack.imgur.com/mLvEe.jpg)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T04:11:39.167", "favorite_count": 0, "id": "86351", "last_activity_date": "2022-02-15T12:40:44.013", "last_edit_date": "2022-02-15T12:40:44.013", "last_editor_user_id": "3060", "owner_user_id": "28812", "post_type": "question", "score": 0, "tags": [ "css" ], "title": "要素のclassはどのようにして決めるか", "view_count": 124 }
[ { "body": "> その要素はdivに設定されているclass「entry-card-content」らしいですが、なぜ、`entry-card-content`\n> となるのでしょうか。\n\n`class` 属性の値は、その **文書を作成した人物が決定** します。つまり、文書の作成者が「この要素には `entry-card-content`\nというクラス名を割り当てる」と決めています。\n\n> `.entry-card-content` の代わりに他のコードを記述するとどうなるのでしょうか\n\n他のクラス名を指定すると、もしそのクラス名を付与されている要素が存在するならば、それらの要素に対して stylus\nによる装飾が適用されます。一方でそういった要素が存在しない場合は、何も起きません。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T12:37:28.873", "id": "86370", "last_activity_date": "2022-02-15T12:37:28.873", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32986", "parent_id": "86351", "post_type": "answer", "score": 2 } ]
86351
null
86370
{ "accepted_answer_id": "86354", "answer_count": 1, "body": "今まで使ったことあるAPIはリクエストを送ったら、レポートの結果が取得できるAPIを扱ってきました。\n\n現在、使用を検討している \n1.APIはリクエストを送ったら、そのリクエストのレポートIDが発行され、 \n2.発行されたIDを元にリクエストを出し、結果を取得できるAPIとなっています。\n\n前者は処理にかかる時間も単に待っていたらいいのですが、 \n後者は最初の1.リクエストでレポートIDが発行されて、処理が完了される前に2を行うと、準備中のエラーが返ってきます。特に完了までの時間などもレスポンスがないため、完了時間がわかりません。 \nこういった場合は完了するまで定期的に2を行うのが一般的なのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T04:14:43.163", "favorite_count": 0, "id": "86352", "last_activity_date": "2022-02-15T04:51:16.283", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21256", "post_type": "question", "score": 1, "tags": [ "api" ], "title": "apiの処理待ちの考え方", "view_count": 210 }
[ { "body": "はい、2を繰り返し行います。ポーリングといわれる手法になります\n\n提供サービス(またはライブラリ等)によってはレポートの処理終了後にコールバックしてくれる場合もありますが、そういう仕組みがない場合はポーリングでリクエストし処理完了を待つことになります", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T04:51:16.283", "id": "86354", "last_activity_date": "2022-02-15T04:51:16.283", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "298", "parent_id": "86352", "post_type": "answer", "score": 5 } ]
86352
86354
86354
{ "accepted_answer_id": "86394", "answer_count": 1, "body": "リフレクションで自分のプロジェクトのアセンブリの型を取得し、メンバを追加するT4テキストテンプレートを作成しました。 \n実際、それはアセンブリさえあれば動作します。 \n問題は、ビルドしないとアセンブリがないのでそれは動作しません。\n\n一般的に自身の型にメンバを追加するコードを生成したい場合はどのようにするのでしょうか?\n\n追記します。わかりづらくてすみません。 \n以下のようなプロジェクトがあります。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/dlf3w.png)](https://i.stack.imgur.com/dlf3w.png)\n\nConsoleApp5のTextTemplate1.ttはConsoleApp5.exeから以下のようなコードを生成します。\n\n```\n\n namespace ConsoleApp5.PartialClasses\n {\n public partial class Class1\n {\n // 中身\n }\n public partial class Class2\n {\n // 中身\n }\n }\n \n```\n\nこのテキストテンプレートはビルドされたConsoleApp5.exeがある場合に限り動作します。\n\n**問題点** \n他のアセンブリ情報からコードを生成する場合は自動でコード生成をすることができます。 \n例えばConsoleApp5にTextTemplate2.ttがあったとします。 \nTextTemplate2.ttは同じソリューション内のプロジェクトのClassLibrary1.dllからコードを生成します。 \nClassLibrary1のビルド後イベントでTextTemplate2.ttのコードを生成することでテンプレートを手動で実行する必要がなくなります。\n\n対して、TextTemplate1.ttは実行するためにConsoleApp5.exeが必要なため、自動で実行することができません。\n\n実際にこれを運用する場合、以下のようなルールを設定する必要があると思っています。 \n・TextTemplate1.ttは必要なときに手動で実行する \n・TextTemplate1.csをGitHubなどのソース管理に含める \n・コード生成に失敗した場合はTextTemplate1.csを手動で元に戻す\n\nこの認識は正しいですか? \n後、めんどくさいのでできれば自動で生成したいと思っているのですが、なにかわかることはありますでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T04:57:38.847", "favorite_count": 0, "id": "86356", "last_activity_date": "2022-02-16T11:34:01.687", "last_edit_date": "2022-02-16T11:06:23.870", "last_editor_user_id": "21330", "owner_user_id": "21330", "post_type": "question", "score": 0, "tags": [ "c#" ], "title": "自分のプロジェクトのpartial classにメンバを追加するコードを生成したい", "view_count": 235 }
[ { "body": "T4でアセンブリ自身にメンバーを追加することはできません。アプローチを変える必要があります。\n\n一応、直接的な回答としては、[ソース ジェネレーター](https://docs.microsoft.com/ja-\njp/dotnet/csharp/roslyn-sdk/source-generators-\noverview)というものが登場していて、コンパイル時にコード生成できるようになっています。\n\n* * *\n\nただし、`Class1.cs`、`Class2.cs`を工夫してそもそもコード生成せずに実装するアプローチもあるかもしれません。例えば、[既定のインターフェイスメソッド](https://docs.microsoft.com/ja-\njp/dotnet/csharp/language-reference/proposals/csharp-8.0/default-interface-\nmethods)が使えるかもしれません。実装したいpartialメソッドをインターフェースメンバーとして、更に既定のインターフェイスメソッドを持たせておけば、`Class1`側はそのインターフェースの実装を宣言するだけでpartialメソッドが提供されることになります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T11:34:01.687", "id": "86394", "last_activity_date": "2022-02-16T11:34:01.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "86356", "post_type": "answer", "score": 2 } ]
86356
86394
86394
{ "accepted_answer_id": null, "answer_count": 1, "body": "**目標** \nテーブルから値を取得→表示→別のテーブルにその値を登録ということを不定期な時間繰り返したい\n\n**出てしまうエラー** \nエラーコード:403 Forbidden \n内容:POST <https://mbaas.api.nifcloud.com/2013-09-01/classes/timeline> 403\n(Forbidden)\n\n**試してみたこと** \n1.setする内容を減らしてみる。 \n2.await/asyncを付けた場合と消した場合でどちらかがエラーが出ないなどあるかの確認。 \n3.登録できるまでTL関数を呼び出してみる。\n\n結果、全てダメでした。\n\n**備考** \nasyncとawaitに関しては他のサイトで聞き、その通りに入れたので間違いはないと思います(まだ勉強中でその辺りは未学習のため)。 \nDevToolのネットワークタブで確認したところ、TimeLineという項目は弐つありました。 \n片方はエラーなしでもう片方はエラーとなっていました。 \n要求方法はOPTIONS(エラーなし)とPOST(エラー有り)となっていたのでこの辺りが原因かとも思いましたが、同じ関数を呼び出しているのに最初の一回だけ成功する理由にはなりません。 \nご教授いただければ幸いです。\n\n**問題のソースコード**\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, maximum-scale=1, user-scalable=no, viewport-fit=cover\">\n <meta http-equiv=\"Content-Security-Policy\" content=\"default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'\">\n <script src=\"components/loader.js\"></script>\n <script src=\"lib/onsenui/js/onsenui.min.js\"></script>\n \n <link rel=\"stylesheet\" href=\"components/loader.css\">\n <link rel=\"stylesheet\" href=\"lib/onsenui/css/onsenui.css\">\n <link rel=\"stylesheet\" href=\"lib/onsenui/css/onsen-css-components.css\">\n <link rel=\"stylesheet\" href=\"css/style.css\">\n \n \n </head>\n <body>\n <ons-page>\n <ons-toolbar>\n <div class=\"center\" id=\"toolbar-title\">\n </div>\n </ons-toolbar>\n <ons-tabbar position=\"auto\">\n <ons-tab label=\"TOP\" page=\"tab1.html\" active>\n </ons-tab>\n <ons-tab label=\"DM\" page=\"tab2.html\">\n </ons-tab>\n </ons-tabbar>\n </ons-page>\n \n <ons-template id=\"tab1.html\">\n <ons-page id=\"first-page\">\n <span id=\"contents\"></span>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"tab2.html\">\n <ons-page id=\"second-page\">\n <span id=\"name_list\"></span>\n </ons-page>\n </ons-template>\n \n <script>\n \n const applicationKey = '正しいアプリケーションキー';\n const clientKey = '正しいクライアントキー';\n const ncmb = new NCMB(applicationKey, clientKey);\n \n const Task = ncmb.DataStore(\"chat\");\n const task = new Task();\n let array = [];\n \n const Task_2 = ncmb.DataStore(\"Ids\");\n const task_2 = new Task_2();\n \n const Dm_name = ncmb.DataStore(\"dm\");\n const dm_name = new Dm_name();\n \n const Time_Line = ncmb.DataStore(\"timeline\");\n const time_line = new Time_Line;\n \n let date = new Date();\n let y = date.getFullYear();\n let m = date.getMonth() + 1;\n let d = date.getDate();\n let h = date.getHours()\n let minute = date.getMinutes();\n let num = (Math.floor(Math.random()*3) + 2) * 60 * 1000;\n let num_tweet = 1;\n let ids_name = {};\n let name_real = {};\n let html;\n //エラーになった値を入れる変数群\n let err_name = [];\n let err_id = [];\n let err_contents = [];\n let err_num = 0;\n let err_dt = [];\n let err_uniqueId = [];\n //ユニークキー\n let name_twitter, id, contents, dt, unique_id;\n \n ons.ready(function() {\n console.log(\"Onsen UI is ready!\");\n });\n \n \n document.addEventListener('show', function(event) {\n let page = event.target;\n let titleElement = document.querySelector('#toolbar-title');\n if (page.matches('#first-page')) {\n titleElement.innerHTML = 'TOP<img src=\"img/reload.png\" class=\"reload\" onclick=\"reload()\">';\n } else if (page.matches('#second-page')) {\n titleElement.innerHTML = 'DM<img src=\"img/reload.png\" class=\"reload\" onclick=\"reload()\">';\n }\n });\n \n const event = window.cordova ? 'deviceready' : 'DOMContentLoaded';\n \n //numミリ秒に一回処理を走らせる\n document.addEventListener(event, function() {\n html = \"\";\n //タイムラインが存在しているかどうかの確認\n Time_Line.fetchAll()\n .then(function(results){\n //存在していた場合\n if(results.length > 0){\n for(let i=0; i<results.length; i++){\n let tl = results[i];\n unique_id = tl[\"unique_key\"];\n //htmlが空白であれば=で入れる\n if(html == \"\"){\n if(tl[\"nice\"] == \"true\"){\n html = temp_nice(tl[\"name\"], tl[\"id\"], tl[\"contents\"], tl[\"date\"]);\n }else{\n html = temp(tl[\"name\"], tl[\"id\"], tl[\"contents\"], tl[\"date\"]);\n }\n \n document.getElementById(\"contents\").innerHTML = html;\n }else{//空白でなければ前にくっつけていく\n if(tl[\"nice\"] == \"true\"){\n html = temp_nice(tl[\"name\"], tl[\"id\"], tl[\"contents\"], tl[\"date\"]) + html;\n }else{\n html = temp(tl[\"name\"], tl[\"id\"], tl[\"contents\"], tl[\"date\"]) + html;\n }\n \n \n document.getElementById(\"contents\").innerHTML = html;\n }\n num++;\n }\n }\n })\n .catch(function(err){\n console.log(\"【エラー:\" + err.code + \"】\" + err);\n });\n \n //dm_title();\n setInterval(\"tweet()\", num);\n \n });\n \n if (ons.platform.isIPhoneX()) {\n document.documentElement.setAttribute('onsflag-iphonex-portrait', '');\n document.documentElement.setAttribute('onsflag-iphonex-landscape', '');\n }\n \n //ハートのクリックイベント\n function heart(event){\n let e = event || window.event;\n let elem = e.target || e.srcElement;\n let elemId = elem.id;\n \n document.getElementById(elemId).classList.toggle(\"active_icon\");\n html = document.getElementById(\"contents\").innerHTML;\n \n let tf = document.getElementById(elemId).classList.contains(\"active_icon\");\n \n unique_key = elemId.replace(\"heart_\", \"\");\n \n //検索\n Time_Line.equalTo(\"unique_key\",unique_key).fetch()\n .then(function(object){\n if(tf == true){\n object.set(\"nice\", \"true\");\n return object.update();\n }else{\n object.set(\"nice\", \"false\");\n return object.update();\n }\n })\n .then(function(result){\n console.log(\"成功!\");\n })\n .catch(function(error){\n console.log(\"【取得or更新失敗】\" + error.message);\n document.getElementById(elemId).classList.toggle(\"active_icon\");\n });\n \n }\n \n //リロード\n async function reload(){\n document.getElementById(\"contents\").innerHTML = html;\n //err_*の配列の一つのサイズを取得\n let err_len = err_name.length;\n console.log(\"エラーになった数:\" + err_len);\n let err_i, err_c, err_n, err_d, err_ui;\n for(let i=0; i<err_len; i++){\n //変数にi番目の値を入れる\n err_i = err_id[i];\n err_c = err_contents[i];\n err_n = err_name[i];\n err_d = err_dt[i];\n err_ui = err_uniqueId[i];\n await console.debug(\"【\" + err_n + \", \" + err_i + \", \" + err_c + \", \" + err_d + \", \" + err_ui + \"】\");\n \n //セットする\n try {\n const nemui = await time_line\n .set(\"name\", err_n)\n .set(\"date\", err_d)\n .set(\"unique_key\", err_ui)\n .set(\"contents\", err_c)\n .save();\n console.log(\"【成功】\" + name_tweet + \", \" + id + \", \" + dt + \", \" + contents);\n // 保存後の処理\n num_tweet++;\n unque_id = new Date().getTime().toString();\n } catch (err) {\n console.log(\"【エラー:\" + err.code + \"】\" + err);\n TL(err_n, err_d, err_c, err_ui, err_i);\n }\n }\n }\n \n //呼び出し\n function tweet(){\n date = new Date();\n y = date.getFullYear();\n m = (date.getMonth() + 1).toString().padStart(2, '0');\n d = date.getDate().toString().padStart(2, '0');\n h = date.getHours().toString().padStart(2, '0');\n minute = date.getMinutes().toString().padStart(2, '0');\n let h_moji;\n dt = y + \"-\" + m + \"-\" + d + \" \" + h + \":\" + minute;\n if(html == \"\"){\n name_twitter = \"テスト\";\n id = \"test_plactice\";\n contents = \"このツイートは練習です!\";\n html = temp(\"テスト\", \"test_plactice\", \"このツイートは練習です!\", dt);\n TL(name_tweet, dt, contents, unique_id, id);\n }else{\n Task.fetchAll()\n .then(function(results){\n \n //ランダムに値を取得\n let rand = Math.floor(Math.random()*results.length);\n let moji = results[rand];\n unique_id = new Date().getTime().toString();\n contents = moji[\"contents\"];\n Task_2.equalTo(\"name\", moji[\"name\"])\n .fetch()\n .then(function(result){\n id = result[\"id\"];\n name_tweet = result[\"name_twitter\"];\n h_moji = temp(name_tweet, id, contents, dt);\n console.log(name_tweet + \", \" + id + \", \" + contents);\n html = temp(name_tweet, id, contents, dt) + html;\n TL(name_tweet, dt, contents, unique_id, id);\n });\n \n \n document.getElementById(\"contents\").innerHTML = html;\n num = Math.floor(Math.random()*3) + 2;\n num = num * 60 * 1000;\n });\n }\n \n /*\n time_line.set(\"name\", name_tweet)\n .set(\"id\", id)\n .set(\"date\", dt)\n .set(\"unique_key\", unique_id)\n .set(\"contents\", contents)\n .save()\n .then(function(nemui){\n console.log(\"【成功】\" + name_tweet + \", \" + id + \", \" + dt + \", \" + contents);\n // 保存後の処理\n num_tweet++;\n unque_id = new Date().getTime().toString();\n })\n .catch(function(err){\n console.log(\"エラーです!\");\n });\n */\n }\n function temp(name, id, contents, date){\n let moji;\n moji = \"<div class='row' id = '\" + unique_id + \"'><span class='name'>\" + name + \"</span><span class='id'>\" + id + \"</span><span class='date_tweet'>\" + date + \"</span><div class='contents'>\" + contents + \"</div><img class='icon heart' id='heart_\" + unique_id + \"' src='img/nice.png' onClick='heart()'><img class='icon reply' id='reply' src='img/reply.png'></div>\";\n \n return moji;\n \n }\n \n function temp_nice(name, id, contents, date){\n let moji;\n moji = \"<div class='row'><span class='name'>\" + name + \"</span><span class='id'>\" + id + \"</span><span class='date_tweet'>\" + date + \"</span><div class='contents'>\" + contents + \"</div><img class='icon heart active_icon' id='heart_\" + unique_id + \"' src='img/nice.png' onClick='heart()'><img class='icon reply' id='reply' src='img/reply.png'></div>\";\n \n return moji;\n \n }\n \n async function TL(name_tweet, dt, contents, unique_id, id){\n time_line\n .set(\"name\", name_tweet)\n .set(\"date\", dt)\n .set(\"contents\", contents)\n .set(\"id\", id)\n .set(\"unique_key\", unique_id);\n try {\n const gameScore = await time_line.save();\n console.log(\"【保存成功!】ID:\" + id + \", name:\" + name_tweet + \", date:\" + dt + \", contents:\" + contents);\n unque_id = new Date().getTime().toString();\n } catch (err) {\n console.log(\"【エラー:\" + err.code + \"】\" + err);\n console.log(\"【エラーになったコンテンツ】 \" + name_tweet + \", \" + contents + \", \" + dt);\n err_contents[err_num] = contents;\n err_dt[err_num] = dt;\n err_name[err_num] = name_tweet;\n err_id[err_num] = id;\n err_uniqueId[err_num] = unique_id;\n err_num++;\n }\n }\n \n function registry_timeline(){\n \n }\n \n </script>\n </body>\n </html>\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T05:25:40.880", "favorite_count": 0, "id": "86358", "last_activity_date": "2022-02-15T10:32:09.897", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "46953", "post_type": "question", "score": 0, "tags": [ "javascript", "monaca" ], "title": "monacaとニフクラ mobile backendで403エラーになってしまい登録できなくなってしまいます。", "view_count": 103 }
[ { "body": "自己解決しました。\n\n`const` を`let` にし、`set` を呼び出しているところで上書きすることでエラーが出なくなりました。\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, maximum-scale=1, user-scalable=no, viewport-fit=cover\">\n <meta http-equiv=\"Content-Security-Policy\" content=\"default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'\">\n <script src=\"components/loader.js\"></script>\n <script src=\"lib/onsenui/js/onsenui.min.js\"></script>\n \n <link rel=\"stylesheet\" href=\"components/loader.css\">\n <link rel=\"stylesheet\" href=\"lib/onsenui/css/onsenui.css\">\n <link rel=\"stylesheet\" href=\"lib/onsenui/css/onsen-css-components.css\">\n <link rel=\"stylesheet\" href=\"css/style.css\">\n \n \n </head>\n <body>\n <ons-page>\n <ons-toolbar>\n <div class=\"center\" id=\"toolbar-title\">\n </div>\n </ons-toolbar>\n <ons-tabbar position=\"auto\">\n <ons-tab label=\"TOP\" page=\"tab1.html\" active>\n </ons-tab>\n <ons-tab label=\"DM\" page=\"tab2.html\">\n </ons-tab>\n </ons-tabbar>\n </ons-page>\n \n <ons-template id=\"tab1.html\">\n <ons-page id=\"first-page\">\n <span id=\"contents\"></span>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"tab2.html\">\n <ons-page id=\"second-page\">\n <span id=\"name_list\"></span>\n </ons-page>\n </ons-template>\n \n <script>\n \n let applicationKey = 'アプリケーションキー';\n let clientKey = 'クライアントキー';\n let ncmb = new NCMB(applicationKey, clientKey);\n \n let Task = ncmb.DataStore(\"chat\");\n let task = new Task();\n let array = [];\n \n let Task_2 = ncmb.DataStore(\"Ids\");\n let task_2 = new Task_2();\n \n let Dm_name = ncmb.DataStore(\"dm\");\n let dm_name = new Dm_name();\n \n let Time_Line = ncmb.DataStore(\"timeline\");\n let time_line = new Time_Line;\n \n let date = new Date();\n let y = date.getFullYear();\n let m = date.getMonth() + 1;\n let d = date.getDate();\n let h = date.getHours()\n let minute = date.getMinutes();\n let num = (Math.floor(Math.random()*3) + 2) * 60 * 1000;\n let num_tweet = 1;\n let ids_name = {};\n let name_real = {};\n let html;\n //エラーになった値を入れる変数群\n let err_name = [];\n let err_id = [];\n let err_contents = [];\n let err_num = 0;\n let err_dt = [];\n let err_uniqueId = [];\n //ユニークキー\n let name_twitter, id, contents, dt, unique_id;\n \n ons.ready(function() {\n console.log(\"Onsen UI is ready!\");\n });\n \n \n document.addEventListener('show', function(event) {\n let page = event.target;\n let titleElement = document.querySelector('#toolbar-title');\n if (page.matches('#first-page')) {\n titleElement.innerHTML = 'TOP<img src=\"img/reload.png\" class=\"reload\" onclick=\"reload()\">';\n } else if (page.matches('#second-page')) {\n titleElement.innerHTML = 'DM<img src=\"img/reload.png\" class=\"reload\" onclick=\"reload()\">';\n }\n });\n \n let event = window.cordova ? 'deviceready' : 'DOMContentLoaded';\n \n //numミリ秒に一回処理を走らせる\n document.addEventListener(event, function() {\n html = \"\";\n //タイムラインが存在しているかどうかの確認\n Time_Line.fetchAll()\n .then(function(results){\n //存在していた場合\n if(results.length > 0){\n for(let i=0; i<results.length; i++){\n let tl = results[i];\n unique_id = tl[\"unique_key\"];\n //htmlが空白であれば=で入れる\n if(html == \"\"){\n if(tl[\"nice\"] == \"true\"){\n html = temp_nice(tl[\"name\"], tl[\"id\"], tl[\"contents\"], tl[\"date\"]);\n }else{\n html = temp(tl[\"name\"], tl[\"id\"], tl[\"contents\"], tl[\"date\"]);\n }\n \n document.getElementById(\"contents\").innerHTML = html;\n }else{//空白でなければ前にくっつけていく\n if(tl[\"nice\"] == \"true\"){\n html = temp_nice(tl[\"name\"], tl[\"id\"], tl[\"contents\"], tl[\"date\"]) + html;\n }else{\n html = temp(tl[\"name\"], tl[\"id\"], tl[\"contents\"], tl[\"date\"]) + html;\n }\n \n \n document.getElementById(\"contents\").innerHTML = html;\n }\n num++;\n }\n }\n })\n .catch(function(err){\n console.log(\"【エラー:\" + err.code + \"】\" + err);\n });\n \n //dm_title();\n setInterval(\"tweet()\", num);\n \n });\n \n if (ons.platform.isIPhoneX()) {\n document.documentElement.setAttribute('onsflag-iphonex-portrait', '');\n document.documentElement.setAttribute('onsflag-iphonex-landscape', '');\n }\n \n //ハートのクリックイベント\n function heart(event){\n let e = event || window.event;\n let elem = e.target || e.srcElement;\n let elemId = elem.id;\n \n document.getElementById(elemId).classList.toggle(\"active_icon\");\n html = document.getElementById(\"contents\").innerHTML;\n \n let tf = document.getElementById(elemId).classList.contains(\"active_icon\");\n \n unique_key = elemId.replace(\"heart_\", \"\");\n \n //検索\n Time_Line.equalTo(\"unique_key\",unique_key).fetch()\n .then(function(object){\n if(tf == true){\n object.set(\"nice\", \"true\");\n return object.update();\n }else{\n object.set(\"nice\", \"false\");\n return object.update();\n }\n })\n .then(function(result){\n console.log(\"成功!\");\n })\n .catch(function(error){\n console.log(\"【取得or更新失敗】\" + error.message);\n document.getElementById(elemId).classList.toggle(\"active_icon\");\n });\n \n }\n \n //リロード\n async function reload(){\n document.getElementById(\"contents\").innerHTML = html;\n //err_*の配列の一つのサイズを取得\n let err_len = err_name.length;\n console.log(\"エラーになった数:\" + err_len);\n let err_i, err_c, err_n, err_d, err_ui;\n for(let i=0; i<err_len; i++){\n //変数にi番目の値を入れる\n err_i = err_id[i];\n err_c = err_contents[i];\n err_n = err_name[i];\n err_d = err_dt[i];\n err_ui = err_uniqueId[i];\n await console.debug(\"【\" + err_n + \", \" + err_i + \", \" + err_c + \", \" + err_d + \", \" + err_ui + \"】\");\n \n //セットする\n try {\n let nemui = await time_line\n .set(\"name\", err_n)\n .set(\"date\", err_d)\n .set(\"unique_key\", err_ui)\n .set(\"contents\", err_c)\n .save();\n console.log(\"【成功】\" + name_tweet + \", \" + id + \", \" + dt + \", \" + contents);\n // 保存後の処理\n num_tweet++;\n unque_id = new Date().getTime().toString();\n } catch (err) {\n console.log(\"【エラー:\" + err.code + \"】\" + err);\n TL(err_n, err_d, err_c, err_ui, err_i);\n }\n }\n }\n \n //呼び出し\n function tweet(){\n date = new Date();\n y = date.getFullYear();\n m = (date.getMonth() + 1).toString().padStart(2, '0');\n d = date.getDate().toString().padStart(2, '0');\n h = date.getHours().toString().padStart(2, '0');\n minute = date.getMinutes().toString().padStart(2, '0');\n let h_moji;\n dt = y + \"-\" + m + \"-\" + d + \" \" + h + \":\" + minute;\n if(html == \"\"){\n name_twitter = \"テスト\";\n id = \"test_plactice\";\n contents = \"このツイートは練習です!\";\n html = temp(\"テスト\", \"test_plactice\", \"このツイートは練習です!\", dt);\n TL(name_tweet, dt, contents, unique_id, id);\n }else{\n Task.fetchAll()\n .then(function(results){\n \n //ランダムに値を取得\n let rand = Math.floor(Math.random()*results.length);\n let moji = results[rand];\n unique_id = new Date().getTime().toString();\n contents = moji[\"contents\"];\n Task_2.equalTo(\"name\", moji[\"name\"])\n .fetch()\n .then(function(result){\n id = result[\"id\"];\n name_tweet = result[\"name_twitter\"];\n h_moji = temp(name_tweet, id, contents, dt);\n console.log(name_tweet + \", \" + id + \", \" + contents);\n html = temp(name_tweet, id, contents, dt) + html;\n \n TL(name_tweet, dt, contents, unique_id, id);\n });\n \n \n document.getElementById(\"contents\").innerHTML = html;\n num = Math.floor(Math.random()*3) + 2;\n num = num * 60 * 1000;\n document.getElementById(\"contents\").innerHTML = html;\n });\n reload();\n }\n \n /*\n time_line.set(\"name\", name_tweet)\n .set(\"id\", id)\n .set(\"date\", dt)\n .set(\"unique_key\", unique_id)\n .set(\"contents\", contents)\n .save()\n .then(function(nemui){\n console.log(\"【成功】\" + name_tweet + \", \" + id + \", \" + dt + \", \" + contents);\n // 保存後の処理\n num_tweet++;\n unque_id = new Date().getTime().toString();\n })\n .catch(function(err){\n console.log(\"エラーです!\");\n });\n */\n console.log(\"【HTML】\" + html);\n document.getElementById(\"contents\").innerHTML = html;\n }\n function temp(name, id, contents, date){\n let moji;\n moji = \"<div class='row' id = '\" + unique_id + \"'><span class='name'>\" + name + \"</span><span class='id'>\" + id + \"</span><span class='date_tweet'>\" + date + \"</span><div class='contents'>\" + contents + \"</div><img class='icon heart' id='heart_\" + unique_id + \"' src='img/nice.png' onClick='heart()'><img class='icon reply' id='reply' src='img/reply.png'></div>\";\n \n return moji;\n \n }\n \n function temp_nice(name, id, contents, date){\n let moji;\n moji = \"<div class='row'><span class='name'>\" + name + \"</span><span class='id'>\" + id + \"</span><span class='date_tweet'>\" + date + \"</span><div class='contents'>\" + contents + \"</div><img class='icon heart active_icon' id='heart_\" + unique_id + \"' src='img/nice.png' onClick='heart()'><img class='icon reply' id='reply' src='img/reply.png'></div>\";\n \n return moji;\n \n }\n \n async function TL(name_tweet, dt, contents, unique_id, id){\n Task = ncmb.DataStore(\"chat\");\n task = new Task();\n array = [];\n \n Task_2 = ncmb.DataStore(\"Ids\");\n task_2 = new Task_2();\n \n Dm_name = ncmb.DataStore(\"dm\");\n dm_name = new Dm_name();\n \n Time_Line = ncmb.DataStore(\"timeline\");\n time_line = new Time_Line;\n \n time_line\n .set(\"name\", name_tweet)\n .set(\"date\", dt)\n .set(\"contents\", contents)\n .set(\"id\", id)\n .set(\"unique_key\", unique_id);\n try {\n let gameScore = await time_line.save();\n console.log(\"【保存成功!】ID:\" + id + \", name:\" + name_tweet + \", date:\" + dt + \", contents:\" + contents);\n unque_id = new Date().getTime().toString();\n } catch (err) {\n console.log(\"【エラー:\" + err.code + \"】\" + err);\n console.log(\"【エラーになったコンテンツ】 \" + name_tweet + \", \" + contents + \", \" + dt);\n err_contents[err_num] = contents;\n err_dt[err_num] = dt;\n err_name[err_num] = name_tweet;\n err_id[err_num] = id;\n err_uniqueId[err_num] = unique_id;\n err_num++;\n }\n }\n \n function registry_timeline(){\n \n }\n \n </script>\n </body>\n </html>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T07:10:42.663", "id": "86361", "last_activity_date": "2022-02-15T10:32:09.897", "last_edit_date": "2022-02-15T10:32:09.897", "last_editor_user_id": "3060", "owner_user_id": "46953", "parent_id": "86358", "post_type": "answer", "score": 0 } ]
86358
null
86361
{ "accepted_answer_id": "86374", "answer_count": 2, "body": "spresense+LTE拡張ボードにて, \nサンプルプログラム「LteHttpsSecureClient」を実行したところ, \n下記のエラーが発生しました.\n\n```\n\n Starting secure HTTP client.\n attach succeeded.\n 2022/02/15 17:10:05\n making GET request\n ERROR: mbedtls_x509_crt_parse() error : -0x2800\n ERROR:LTETLSClient:216 not available\n ERROR:LTETLSClient:216 not available\n ...\n \n ERROR:LTETLSClient:216 not available\n ERROR:LTETLSClient:216 not available\n Status code: -2\n Response: \n Wait five seconds\n making POST request\n ERROR: mbedtls_x509_crt_parse() error : -0x2800\n \n```\n\nCAの取得につきましては,公式サイト(下記URL)を参考にしております. \n<https://developer.sony.com/develop/spresense/docs/arduino_tutorials_ja.html#lte_howtoexport_cert>\n\nエラーの原因・解決方法等ご教授いただければ幸いです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T08:16:43.343", "favorite_count": 0, "id": "86364", "last_activity_date": "2022-02-21T01:56:23.227", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "48658", "post_type": "question", "score": 0, "tags": [ "spresense" ], "title": "spresenseのsecure通信(https)サンプルでエラーが発生する.", "view_count": 292 }
[ { "body": "ご提示のエラーログを見る限り証明書(CA)ファイルのParseに失敗しているようですね。 \nおそらく、証明書のダウンロードの際「Amazon Root CA」の証明書をダウンロードできていないと思われます。\n\n私も一回間違って \"httpbin.org\" タブの中の証明書をダウンロードしてしまい、全く同じエラーに遭遇しました。 \n証明書のダウンロードの際 \"Amazon Root CA 1\" タブの中の証明書をダウンロードしてみてはいかがでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T01:22:05.403", "id": "86374", "last_activity_date": "2022-02-16T01:22:05.403", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32034", "parent_id": "86364", "post_type": "answer", "score": 1 }, { "body": "私も調べたことがありますので、参考までに補足したいと思います。\n\n参照されているガイドの例はfirefoxのケースでの説明だと思います。 \n<https://developer.sony.com/develop/spresense/docs/arduino_tutorials_ja.html#lte_howtoexport_cert>\n\nWindowsの他のブラウザ(Chrome,Edge)ケースだと、ブラウザで証明書をエクスポートする場合は、Wizardの選択時にPEM形式である\"Base\n64 encoded X.509 (.CER)(S)\"の形式で落とす必要があります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T02:19:38.713", "id": "86427", "last_activity_date": "2022-02-21T01:56:23.227", "last_edit_date": "2022-02-21T01:56:23.227", "last_editor_user_id": "49022", "owner_user_id": "49022", "parent_id": "86364", "post_type": "answer", "score": 0 } ]
86364
86374
86374
{ "accepted_answer_id": null, "answer_count": 1, "body": "python のclassの書き方について質問させてください。\n\n顧客の購入金額を集計し、その金額も基づいてランクを付与したく、クラスを作成(メソッドを2つ定義)してみました。メソッド1は想定通り動作しましたが、メソッド2の方が、どのように記述すればメソッドが実行できるか分からずにおります。(そもそもメソッドを分けない方がよいのか・・?)\n\n※メソッド2では、メソッド1で返ってきた結果の”rev” 列に対して、適用したいと考えています。 \n(結果は新しい列を作成して代入したい)\n\nお気づきの点がありましたらアドバイスいただけますと幸いです。 \nよろしくお願いいたします。\n\n```\n\n # クラス定義\n class GetRank:\n   # 初期化メソッドを定義\n def __init__(self, transaction_data, mst_customer): \n self.transaction_data = transaction_data\n self.mst_customer = mst_customer\n \n # メソッド1:金額集計\n def summary(self):\n summary = self.transaction_data.groupby('cst_no', as_index=False).agg({'rev': 'sum'})\n return summary\n \n # メソッド2: 金額(rev)によって顧客ランク付与\n def rank(self, x):\n if 1 <= x <= 4999:\n return 'low'\n elif 5000 <= x <= 9999:\n return 'middle'\n elif x <= 10000:\n return 'high'\n \n cat_ord = ['low', 'middle', 'high']\n \n \n # クラスのインスタンス作成\n thisY = GetRank(trn_thisY, mst_cst_thisY)\n \n # メソッド1を実行\n s_thisY = thisY.summary()\n \n # メソッド2を実行\n ????\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T08:25:15.680", "favorite_count": 0, "id": "86365", "last_activity_date": "2022-02-15T10:06:07.180", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "47038", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "pythonのclassの書き方", "view_count": 127 }
[ { "body": "質問に示されたソースコードでは、`int`や`float`のパラメータを指定して呼び出すと、パラメータの値によって `low`, `middle`,\n`high` の文字列または `None` を返す単純な関数です。 \n例えば以下のように:\n\n```\n\n result = thisY.rank(1)\n print(result)\n # low が表示される\n \n```\n\n質問のメソッド1を実行した結果が整数または浮動小数点数ならば、以下のように呼び出せば結果が得られるでしょう。\n\n```\n\n result = thisY.rank(s_thisY)\n print(result)\n # s_thisY の値に応じたlow,middle,high,Noneのいずれかが表示される\n \n```\n\nしかし文字列とか何かのオブジェクトをパラメータとして渡すとエラーになります。 \nまた、何の数値をパラメータとして渡しても、また何回呼び出しても、`thisY`オブジェクトには影響や変化はありません。\n\n`(結果は新しい列を作成して代入したい)`ということの意味は、`thisY`オブジェクトは pandas の DataFrame\n等を含んだ何かであり、`rank()`メソッドを呼び出すことでそのオブジェクトに列を増やしたいということでしょうか?\n\n現在のソースコードにはそのような処理はありません。 \nまた何かそういう機能を追加しようとしても、どんなものをどのように処理してどのような結果を得たいか、についての情報が無いので助言や回答を得ることは難しいでしょう。 \nそれらの助言や回答が欲しいのならば、別の質問として新規に起こす方が良いでしょう。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T10:06:07.180", "id": "86368", "last_activity_date": "2022-02-15T10:06:07.180", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86365", "post_type": "answer", "score": 0 } ]
86365
null
86368
{ "accepted_answer_id": null, "answer_count": 1, "body": "pythonを使用しExcelファイルのセルを一つ一つコピーして、特定のwebサイトの項目に自動で貼り付けることは可能でしょうか。 \nまた、どのようにすればいいかも共有いただけたら幸いです。 \nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T10:00:09.223", "favorite_count": 0, "id": "86367", "last_activity_date": "2022-02-15T10:27:42.503", "last_edit_date": "2022-02-15T10:12:20.750", "last_editor_user_id": "3060", "owner_user_id": "51437", "post_type": "question", "score": 0, "tags": [ "python", "python3" ], "title": "Excelからセルをコピーしてwebサイトの指定の項目に自動で貼り付けることはpythonで可能でしょうか。", "view_count": 460 }
[ { "body": "**pythonを使用しExcelファイルのセルを一つ一つコピーして、特定のwebサイトの項目に自動で貼り付けることは可能でしょうか。**\n\n→ **可能です** \n例えばこんな質問がそのような処理を行った関連のものです。 \n[ExcelからTwitter(selenium)で特定の条件がある場合、繰り返し処理を行う方法について](https://ja.stackoverflow.com/q/80783/26370)\n\n* * *\n\n**どのようにすればいいかも共有いただけたら幸いです。**\n\n→ それは漠然とし過ぎていて、範囲がとても広いので、簡単に答えられるものでは無く、このサイトの対象トピックからは外れます。\n\n「特定のwebサイト」というからには、想定するWebサイトがあるでしょうからそれを明示して、また使用するExcelファイルも提示して、どのような処理を行いたいか自分である程度プログラムを作成してから上手くいかないところを質問してください。\n\nこれらのヘルプ記事を参考に。 \n[ここではどのようなトピックについて質問できますか?](https://ja.stackoverflow.com/help/on-topic) \n[どのような質問は避けるべきですか?](https://ja.stackoverflow.com/help/dont-ask) \n[良い質問をするには?](https://ja.stackoverflow.com/help/how-to-ask) \n[再現可能な短いサンプルコードの書き方](https://ja.stackoverflow.com/help/minimal-reproducible-\nexample)\n\nそうしたことの前提知識も無いのでしたら、Pythonを使ったWebサイト操作の自動化の書籍やWeb記事を調べて勉強してください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T10:27:42.503", "id": "86369", "last_activity_date": "2022-02-15T10:27:42.503", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86367", "post_type": "answer", "score": 2 } ]
86367
null
86369
{ "accepted_answer_id": null, "answer_count": 0, "body": "Google Cloud Platform(GCP)でwebアプリを作っています。 \nwebアプリからGCP Storageに画像をアップロードするようなものを作りたく、 \n[Node.jsからCloud\nStorageを利用(入門)](https://qiita.com/NOGU626/items/1af991b1757988b6cee6)などを参考にしているのですが、\n\n```\n\n const {Storage} = require('@google-cloud/storage');\n \n```\n\nこの一文で下記のエラーが出てしまいます。\n\n```\n\n #### Uncaught TypeError: The \"original\" argument must be of type Function\n at promisify (util.js:601:1)\n at Object../node_modules/@google-cloud/storage/node_modules/get-stream/index.js (index.js:7:1)\n at __ webpack_require __ (bootstrap:851:1)\n at fn (bootstrap:150:1)\n at Object.< anonymous > (file.js:20:1)\n at Object../node_modules/@google-cloud/storage/build/src/file.js (file.js:3264:1)\n at __ webpack_require __ (bootstrap:851:1)\n at fn (bootstrap:150:1)\n at Object.< anonymous > (bucket.js:31:1)\n at Object../node_modules/@google-cloud/storage/build/src/bucket.js (bucket.js:3323:1)\n at __ webpack_require __ (bootstrap:851:1)\n at fn (bootstrap:150:1)\n at Object../node_modules/@google-cloud/storage/build/src/index.js (index.js:16:1)\n at __ webpack_require __ (bootstrap:851:1)\n at fn (bootstrap:150:1)\n at Module.< anonymous > (Game.jsx:163:1)\n at Module../src/Home/Home.jsx (Home.jsx:184:1)\n at __ webpack_require __ (bootstrap:851:1)\n at fn (bootstrap:150:1)\n at Module.<anonymous> (useChat.js:109:1)\n at Module../src/index.jsx (index.jsx:108:1)\n at __ webpack_require __ (bootstrap:851:1)\n at fn (bootstrap:150:1)\n at Object.1 (index.jsx:108:1)\n at __ webpack_require __ (bootstrap:851:1)\n at checkDeferredModules (bootstrap:45:1)\n at Array.webpackJsonpCallback [as push] (bootstrap:32:1)\n at main.chunk.js:1:77\n \n```\n\nすでに、dockerfileのnode versionを変えたり、nodeのversionを変更して試しました。\n\nまた、requireに代わり\n\n```\n\n import {Storage} from '@google-cloud/storage';\n import * as Storage from '@google-cloud/storage';\n \n```\n\nを試してみましたが、これらも同じエラーが出ます。\n\n具体的にどのようなエラーか、何が原因なのかを教えていただけないでしょうか?\n\n追記2022/2/18 \n行ったことは下記2点で、2でエラーが出ています。\n\n 1. yarn add '@google-cloud/storage'\n 2. yarn start でブラウザーで動かしています。\n\n環境: \nwindows10 \nnode:v15.14.0 \nnpm:7.7.6 \nreact:17.0.2 \n@google-cloud/storage:^5.18.1", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T15:39:14.187", "favorite_count": 0, "id": "86371", "last_activity_date": "2022-02-17T23:28:22.590", "last_edit_date": "2022-02-17T23:28:22.590", "last_editor_user_id": "51445", "owner_user_id": "51445", "post_type": "question", "score": 0, "tags": [ "node.js", "webpack", "react-native", "google-cloud-storage" ], "title": "Reactでエラー TypeError: The \"original\" argument must be of type Function", "view_count": 270 }
[]
86371
null
null
{ "accepted_answer_id": "86376", "answer_count": 1, "body": "書籍「すっきりわかるC言語入門」の練習問題の解答例について質問です。\n\n要素3のint型配列 answer の各要素に0〜9のランダムな1桁の数を重複しないように格納するコードの解答例です。 \nbool型で check を定義した後の check = false; が何を意味しているのかが理解できません。 \n変数 check に false を代入しただけで for(answer[i] == answer[j]) がどうして実行されるようになるのでしょうか。\n\n```\n\n int answer[3];\n int input[3];\n bool check;\n for (int i = 0; i < 3; i++){\n do{\n answer[i] = rand()% 10;\n for(int j = 0; j < i; j++){\n check = false;\n if(answer[i] == answer[j]){\n break;\n }\n check = true;\n }\n }while (i > 0 && check == false);\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T01:35:22.883", "favorite_count": 0, "id": "86375", "last_activity_date": "2022-02-16T02:13:51.013", "last_edit_date": "2022-02-16T01:43:20.287", "last_editor_user_id": "3060", "owner_user_id": "51450", "post_type": "question", "score": 1, "tags": [ "c" ], "title": "解答例のコードがどのように動くのかわかりません", "view_count": 162 }
[ { "body": "do-whileや計算を少なくする工夫に富んでいますが、変則的で欲張りな解答例ですね。 \n下記にコメントをつけておきました。\n\n```\n\n int answer[3]; //要素は全て0となる前提\n int input[3];\n bool check;\n for (int i = 0; i < 3; i++)\n {\n do\n {\n // ランダムな数を生成\n answer[i] = rand()% 10;\n \n // 今までの数を確認する\n // iが2なら、jは0と1を確認)\n for(int j = 0; j < i; j++)\n {\n //ここで未チェック(初期状態)とする\n check = false;\n \n //もし重複があったらanswer[i]を作り直すためにforループを抜ける\n //このときdo-whileは抜けないので、iは変わらない\n if(answer[i] == answer[j])\n {\n break;\n }\n // ここでチェック済みとする\n // whileの条件を満たさないためdo-whileを抜けて次のiのforループから続ける\n check = true;\n }\n }while (i > 0 && check == false);// ここでループ条件を設定して確認(checkがtrueになるまで繰り返す)\n }\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T01:54:10.917", "id": "86376", "last_activity_date": "2022-02-16T02:13:51.013", "last_edit_date": "2022-02-16T02:13:51.013", "last_editor_user_id": "51317", "owner_user_id": "51317", "parent_id": "86375", "post_type": "answer", "score": 1 } ]
86375
86376
86376
{ "accepted_answer_id": "86384", "answer_count": 1, "body": "Windows 10 Pro 21H2 日本語版の環境で [StraceNT](https://github.com/ipankajg/stracent)\nというツールについて調べています。\n\n不可解なエラーに遭遇したのですが解決方法がわかりませんでしたのでアドバイスをいただけないでしょうか。\n\n### 手順\n\n簡単なトレース対象のプログラムとして次の内容のファイル hello.cs を作る\n\n```\n\n using System;\n class Hello\n {\n public static void Main() {\n Console.WriteLine(\"hello, world\");\n }\n }\n \n```\n\nOS同梱のC#コンパイラでコンパイルして実行ファイル hello.exe を作り、動作確認する\n\n```\n\n PS C:\\tmp> C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\csc.exe .\\hello.cs\n Microsoft (R) Visual C# Compiler version 4.8.4084.0\n for C# 5\n Copyright (C) Microsoft Corporation. All rights reserved.\n \n This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240\n \n PS C:\\tmp> .\\hello.exe\n hello, world\n \n```\n\nstracent.exe でトレースを実行する\n\n```\n\n PS C:\\tmp> .\\stracent.exe .\\hello.exe\n \n System Call Tracer for Windows XP - Windows 10. (Version: 0.9.3.0)\n Copyright (c): Pankaj Garg <[email protected]>. \n All rights reserved.\n \n Tracing command: [\".\\hello.exe\"]\n \n Error: ?????????????????\n \n```\n\n### 質問\n\nなぜ hello.exe のトレースができないのでしょうか。\n\n`stracent.exe notepad` では正しく notepad.exe のトレースができました。\n\n`stracent.exe C:\\Windows\\notepad.exe` では同じエラーによりトレースできませんでした。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T02:01:02.737", "favorite_count": 0, "id": "86377", "last_activity_date": "2022-02-16T12:24:25.333", "last_edit_date": "2022-02-16T12:24:25.333", "last_editor_user_id": "9873", "owner_user_id": "9873", "post_type": "question", "score": 1, "tags": [ "c#", "windows", "debugging" ], "title": "StraceNTの不可解なエラー", "view_count": 215 }
[ { "body": "そのプロジェクトの info.txt の Supported platforms に 32bit OS または 64bit OS でも wow64\nの中で動作する 32bit process だけトレース出来ると記述されています。 \n[Supported platforms: -\nstracent/hlp/info.txt](https://github.com/ipankajg/stracent/blob/master/hlp/info.txt#L55)\n\n> Windows 2000 \n> Windows XP (32-bit) \n> Windows 2003 (32-bit) \n> Windows XP (64-bit) - For tracing 32bit process *only* running inside wow64 \n> Windows 2003 (64-bit) - For tracing 32bit process *only* running inside\n> wow64\n\nつまり正常に動作する、パスを指定しない`stracent.exe\nnotepad`だと、32bitアプリの`C:\\Windows\\SysWOW64\\notepad.exe`が起動していると思われます。\n\nC#のHello.exeは特に何も指定しなければ AnyCPU モードで作成され、64bit OSでは64bitモードで動作するのでしょう。\n\nパスを指定した`stracent.exe\nC:\\Windows\\notepad.exe`では、指定された`C:\\Windows\\notepad.exe`は64bitモードで動作するプログラムと言うことなのでしょう。\n\nそうして64bitアプリのトレースは出来ないのでエラーになっていると思われます。文字化けはそういう未対応であることの副産物でしょうか。\n\nC#のHello.exeを32bitアプリに特化した形でビルドするオプションがあれば、それを指定して試してみてはどうでしょう?", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T07:35:05.270", "id": "86384", "last_activity_date": "2022-02-16T07:35:05.270", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86377", "post_type": "answer", "score": 2 } ]
86377
86384
86384
{ "accepted_answer_id": null, "answer_count": 0, "body": "google app scriptのトリガーのオーナーを特定する手段があるかどうかの質問となります。\n\n編集者、オーナーを含め複数名で利用、編集しているGASのトリガーですが、所有者不明のトリガーがあります。 \nトリガーの設定者を特定したいのですが、我々のアカウントからは、オーナーが他のユーザーとしか表示されず困っている状態です。 \nそのトリガーを設定した方に、トリガーを削除して貰う必要があるのですが、何か、トリガーのオーナーを特定する手段などありますでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T03:43:01.563", "favorite_count": 0, "id": "86378", "last_activity_date": "2022-02-16T04:45:23.463", "last_edit_date": "2022-02-16T04:45:23.463", "last_editor_user_id": "3060", "owner_user_id": "51451", "post_type": "question", "score": 0, "tags": [ "google-apps-script" ], "title": "google app script のトリガーのオーナーを特定する手段は?", "view_count": 1197 }
[]
86378
null
null
{ "accepted_answer_id": "86386", "answer_count": 3, "body": "次の例のような,各数値がスペースで区切られているデータからなる.txtファイルがあります.\n\n```\n\n 3 0.6 0.8 0.2\n 12 0.9 0.8 0.4\n 11 0.1 0.4 0.5\n \n```\n\nそして,最初の列の数値(この例では3,12,11)をkey,それ以降の数値をlistに変換してそのkeyに対応するvalueからなるdictionaryを作りたいです.\n\nつまり,この例に対応する期待する出力は次の様になります.\n\n```\n\n {3:[0.6, 0.8, 0.2],12: [0.9, 0.8, 0.4], 11: [0.1, 0.4, 0.5]}\n \n```\n\nやり方が思いつかないので,どなたか力を貸していただけないでしょうか. \nよろしくお願いします.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T07:28:03.207", "favorite_count": 0, "id": "86383", "last_activity_date": "2022-02-16T11:47:52.420", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "36856", "post_type": "question", "score": 1, "tags": [ "python", "python3" ], "title": ".txtファイルに保存されているデータをdict型に変換する方法", "view_count": 1221 }
[ { "body": "`split`を使用してスペースごとに項目を区切り、スライスすることで最初の項目`[0]`をキーに、それ以降すべて`[1:]`を値にした辞書を作ることができます。\n\n```\n\n s = \"\"\"3 0.6 0.8 0.2\n 12 0.9 0.8 0.4\n 11 0.1 0.4 0.5\"\"\" \n # スペース区切りの配列をスライスしてキーと値に分ける\n d = { l.split(\" \")[0] : l.split(\" \")[1:] for l in s.split(\"\\n\") }\n print(d)\n # {'3': ['0.6', '0.8', '0.2'], '12': ['0.9', '0.8', '0.4'], '11': ['0.1', '0.4', '0.5']}\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T08:02:42.760", "id": "86385", "last_activity_date": "2022-02-16T08:02:42.760", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "86383", "post_type": "answer", "score": 2 }, { "body": "文字列のままで良いのなら、@payanecoさんの回答が正解だと思いますが、 \n期待する出力の提示内容を見ると、数値(keyがint、valueがfloatのlist)に見えるので、こんな感じになるのでは?\n\n```\n\n with open('data.txt', 'r') as f:\n data = [l.split() for l in f.read().splitlines()]\n \n d = {}\n for x in data:\n k = int(x[0])\n v = [float(s) for s in x[1:]]\n d[k] = v\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T08:06:57.863", "id": "86386", "last_activity_date": "2022-02-16T08:06:57.863", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86383", "post_type": "answer", "score": 3 }, { "body": "別解として(Pandas を使う場合)。\n\n```\n\n import pandas as pd\n \n df = pd.read_table('data.txt', header=None, sep=r'\\s', engine='python', index_col=0)\n dic = df.T.to_dict('list')\n \n print(dic)\n \n #\n {3: [0.6, 0.8, 0.2], 12: [0.9, 0.8, 0.4], 11: [0.1, 0.4, 0.5]}\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T11:34:23.653", "id": "86395", "last_activity_date": "2022-02-16T11:47:52.420", "last_edit_date": "2022-02-16T11:47:52.420", "last_editor_user_id": "47127", "owner_user_id": "47127", "parent_id": "86383", "post_type": "answer", "score": 2 } ]
86383
86386
86386
{ "accepted_answer_id": "86392", "answer_count": 2, "body": "grepでディレクトリ内のマッチするファイルの一覧取り出したいけど正規表現が上手く効かないです\n\n```\n\n grep -rnE '<SoundBox [\\s\\S]*?label=\\\\\"\"' frontend\n \n # マッチさせたい文字列\n <SoundBox name={'Hoge'} checked={Hoge} label=\"\" />\n <SoundBox label=\"\" name={'Hoge'} checked={Hoge} onChange={Hoge} />\n <SoundBox\n label=\"\"\n name={'Hoge'}\n checked={Hoge}\n onChange={Hoge}\n />\n \n```\n\n詳しい方教えて頂けないでしょうか? \n改行のパターンにもマッチしたいのですが、こちらだと上手くいかないです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T08:27:50.713", "favorite_count": 0, "id": "86387", "last_activity_date": "2022-02-16T14:15:53.760", "last_edit_date": "2022-02-16T14:15:53.760", "last_editor_user_id": "22565", "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "linux", "正規表現", "grep" ], "title": "grepで正規表現を使用してパターンにマッチするファイル一覧を出力したい", "view_count": 443 }
[ { "body": "```\n\n grep -rnE '<SoundBox\\s.*?label=\"\"'\n \n```\n\nでいかがでしょうか?", "comment_count": 10, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T08:45:58.697", "id": "86389", "last_activity_date": "2022-02-16T08:45:58.697", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14745", "parent_id": "86387", "post_type": "answer", "score": 1 }, { "body": "`GNU grep` であれば `-P` オプション(`PCRE` engine)を使うと1, 2行目全てがマッチします。\n\n```\n\n $ grep --version\n grep (GNU grep) 3.7\n \n $ grep -nE '<SoundBox [\\s\\S]*?label=\"\"' frontend\n 2:<SoundBox label=\"\" name={'Hoge'} checked={Hoge} onChange={Hoge} />\n \n $ grep -nP '<SoundBox [\\s\\S]*?label=\\\"\\\"' frontend\n 1:<SoundBox name={'Hoge'} checked={Hoge} label=\"\" />\n 2:<SoundBox label=\"\" name={'Hoge'} checked={Hoge} onChange={Hoge} />\n \n```\n\nちなみに、`(\\s|\\S)*?` では両方にマッチします。\n\n```\n\n $ grep -nE '<SoundBox (\\S|\\s)*?label=\"\"' frontend\n 1:<SoundBox name={'Hoge'} checked={Hoge} label=\"\" />\n 2:<SoundBox label=\"\" name={'Hoge'} checked={Hoge} onChange={Hoge} />\n \n```", "comment_count": 12, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T11:08:19.360", "id": "86392", "last_activity_date": "2022-02-16T11:13:50.370", "last_edit_date": "2022-02-16T11:13:50.370", "last_editor_user_id": "47127", "owner_user_id": "47127", "parent_id": "86387", "post_type": "answer", "score": 0 } ]
86387
86392
86389
{ "accepted_answer_id": "86415", "answer_count": 1, "body": "## 質問\n\n以下のような二次元配列(CSVなどから取得)から、JSON形式に変換するコードを書いたのですが、車輪の再発明のような気がしてならず、質問しました。\n\n## 期待する回答\n\n多くの方が既に取り組まれているコードかと思っておりまして、わざわざ自分で作らなくても、既に便利な関数なりライブラリがあるんじゃないかと思います。 \nこれをご存じであればご教示いただきたいです。 \n(なければないで構いません)\n\n想像しているのは、たとえばpythonだと`zip`があるので(多少頑張る必要はありましたが)あまり気にしなかったんですが、JavaScriptで相応の関数なりライブラリがあればと思いました。\n\n## 期待していない回答\n\n泥臭い方法での解答コードは不要です。 \nmapやfilterを使うケースについては、既に動くものが手元に存在しています。\n\nこの泥臭いコードを作成していて、ふと疑問に思ったので質問させていただいているという経緯です。\n\n**対象の二次元配列:**\n\n```\n\n let data = [\n [\"header1\", \"header2\", ...],\n [\"content1\", \"content2\", ...],\n [\"content1\", \"content2\", ...],\n ...\n ]\n \n```\n\n**CSVデータから変換後の(期待する)JSONデータ:**\n\n```\n\n let data = [\n {\n [data[0][0]]: data[1][0],\n [data[0][1]]: data[1][1],\n [data[0][2]]: data[1][2],\n ...\n }, {\n {\n [data[0][0]]: data[2][0],\n [data[0][1]]: data[2][1],\n [data[0][2]]: data[2][2],\n ...\n }, \n ...\n ]\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T08:27:51.843", "favorite_count": 0, "id": "86388", "last_activity_date": "2022-02-17T13:00:04.883", "last_edit_date": "2022-02-16T11:10:32.750", "last_editor_user_id": "3060", "owner_user_id": "27817", "post_type": "question", "score": 1, "tags": [ "javascript", "json" ], "title": "JavaScriptでCSVデータが入った二次元配列をJSONにしたい", "view_count": 425 }
[ { "body": "[lodashの `zipObject`](https://lodash.com/docs/4.17.15#zipObject)\nを使えば、最小限の頑張りで実現できそうです。\n\n```\n\n const { zipObject } = require(\"lodash\");\n // const zipObject = require(\"lodash.zipobject\");\n // import { zipObject } from \"lodash\";\n // import zipObject from \"lodash.zipobject\";\n \n const data = [\n [\"header1\", \"header2\"],\n [\"content1.1\", \"content1.2\"],\n [\"content2.1\", \"content2.2\"],\n [\"content3.1\", \"content3.2\"],\n ];\n \n const [header, ...values] = data;\n const output = values.map(value => zipObject(header, value));\n console.log(output);\n // [\n // { header1: 'content1.1', header2: 'content1.2' },\n // { header1: 'content2.1', header2: 'content2.2' },\n // { header1: 'content3.1', header2: 'content3.2' }\n // ]\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T13:00:04.883", "id": "86415", "last_activity_date": "2022-02-17T13:00:04.883", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51277", "parent_id": "86388", "post_type": "answer", "score": 1 } ]
86388
86415
86415
{ "accepted_answer_id": null, "answer_count": 1, "body": "画像を参照してください。\n\nここで質問ですが\n\n 1. 左の枠で囲ったコードに対応するのは右の青枠で囲んであるDOMの事か \nこれが記述されていれば、下にStylesがあり、その中から変更すべきCSSを変える\n\n 2. Stylusに記述するコードは下記の事ですが、\n``` .myblocks p {\n\n font-size: 1.1em;\n line-height: 2;\n color: #111111;\n }\n \n```\n\n`.myblocks p` の箇所は下記の赤の横線の箇所でないとだめか\n\n識者からの回答をお待ちしています。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/WZIT2.jpg)](https://i.stack.imgur.com/WZIT2.jpg)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T08:51:37.843", "favorite_count": 0, "id": "86390", "last_activity_date": "2022-02-16T13:03:23.467", "last_edit_date": "2022-02-16T11:05:01.887", "last_editor_user_id": "3060", "owner_user_id": "28812", "post_type": "question", "score": 0, "tags": [ "css" ], "title": "Stylusに記述するまでの流れ", "view_count": 98 }
[ { "body": "> 左の枠で囲ったコードに対応するのは右の青枠で囲んであるDOMの事か\n\nスクリーンショットを見る限り、そのようです。\n\n> `.myblocks p` の箇所は下記の赤の横線の箇所でないとだめか\n\nビューポートが 992px\n以上であるときのみ質問文のカスタムスタイルシートを適用したいのであれば、赤横線のようにメディアクエリ内にそのルールセットを書く必要があります。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T13:03:23.467", "id": "86398", "last_activity_date": "2022-02-16T13:03:23.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32986", "parent_id": "86390", "post_type": "answer", "score": 1 } ]
86390
null
86398
{ "accepted_answer_id": null, "answer_count": 1, "body": "## 背景\n\n実務で開発をしていると、たくさんのプロジェクトを同時にvscodeで開いて、それぞれのプロジェクトでサーバをたてる(docker-compose\nupやnpm run devやrails sなど)事が結構多いと思います。 \n2コとかならいいんですが最近はマイクロサービスの流行もあって、開発時にたくさんのサーバーを同時にたてる事も多くなりました。\n\n## 問題点\n\nMacを再起動するとvscodeは全部とじてしまいますし、当然サーバーも全部終了していまいます。 \n現状は、全部GUIから各プロジェクトをvscodeで開いて、vscodeが5コくらい立ち上がるので、それぞれのターミナル上でdocker-compose\nupとか、npm run devとかを実行しています。\n\nただこれがあまりに大変なので、シェルスクリプトかなにかでうまいこと、一発で5コのプロジェクトをvscodeでひらいて、それぞれのvscode上でサーバーをたてられないかなーと考えています。\n\nとりあえず、vscodeをコマンド上から立ち上げる手段は発見しました。\n\n[ターミナルからVisual Studio\nCodeを起動する方法【公式の方法】](https://qiita.com/naru0504/items/c2ed8869ffbf7682cf5c)\n\n>\n```\n\n> code <プロジェクトのpath>\n> \n```\n\nしかし、コマンド一発で各vscode上でうまいことサーバーを立ち上げる方法がなかなか見つからず、苦戦しています。 \nなにかアイデア、解決策等あればご教示おねがいしたく存じます。\n\nどうぞよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T09:28:02.620", "favorite_count": 0, "id": "86391", "last_activity_date": "2022-02-17T02:35:45.627", "last_edit_date": "2022-02-17T01:09:54.160", "last_editor_user_id": "3060", "owner_user_id": "40650", "post_type": "question", "score": 0, "tags": [ "vscode", "docker-compose" ], "title": "コマンドひとつで複数のvscodeを開いて、それぞれのvscodeでdocker-compose upや、npm run devのようにサーバをたてるコマンドを実行したい", "view_count": 183 }
[ { "body": "VSCode\nはあくまでエディタです。確かにターミナルの機能も呼び出すことができますが、「VSCodeを自動で起動して、その中のターミナルで各サーバを立ち上げて…」に拘らなければ、シェルスクリプトの中で\ndocker-compose や npm コマンド等を記述して起動すれば事足りそうです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T11:45:06.437", "id": "86396", "last_activity_date": "2022-02-16T11:45:06.437", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "86391", "post_type": "answer", "score": 3 } ]
86391
null
86396
{ "accepted_answer_id": "86397", "answer_count": 1, "body": "[以前解決とした質問](https://ja.stackoverflow.com/a/86384/9873)の一部なのですが、海外の方が作ったツールを日本語のWindowsで動かすと、次のようにエラーメッセージの文字がすべてクエスチョンマークに化けてしまい、いったい何のエラーなのかわからないことがよくあります。\n\n```\n\n PS C:\\tmp> .\\stracent.exe .\\hello.exe\n \n System Call Tracer for Windows XP - Windows 10. (Version: 0.9.3.0)\n Copyright (c): Pankaj Garg <[email protected]>. \n All rights reserved.\n \n Tracing command: [\".\\hello.exe\"]\n \n Error: ?????????????????\n \n```\n\nこの `?????????????????` は実際にはWindows\nOSに含まれる標準のエラーメッセージの日本語で、`この要求はサポートされていません。`のようです。どちらも文字数が17で長さが一致しています。\n\nWindowsにおいて、このような文字化けはなぜ発生するのでしょうか。\n\nまた、このような文字化けを起こすプログラムの実行ファイルのみがあって再コンパイルなどは不可能な場合に、人間が理解できるエラーメッセージ(英語でも日本語でもよい)を得る一般的な方法はありますでしょうか。\n\nかつて試した別のコンソールアプリでは `chcp 437` や `chcp 65001`\nなどでコードページを変更することで英語のエラーメッセージにすることができた場合がありましたが、この `stracent.exe` にそれは効きませんでした。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T11:33:03.473", "favorite_count": 0, "id": "86393", "last_activity_date": "2022-02-16T23:26:33.870", "last_edit_date": "2022-02-16T22:03:37.383", "last_editor_user_id": "4236", "owner_user_id": "9873", "post_type": "question", "score": 3, "tags": [ "windows", "文字化け" ], "title": "日本語Windowsの文字化けの原因と回避方法", "view_count": 319 }
[ { "body": "「文字化け」はある特定の一つの要因で発生するものではありません。文字化けを引き起こす原因は複数あり、それぞれの事象を個別に調査し、原因を特定する必要があります。 \nですので、このスレッドでは一般論ではなく `stracent.exe` に限定した話題と考えてください。\n\n原因の切り分けとしては\n\n * PowerShellではなくコマンドプロンプトで実行した場合はどうか?\n * コマンドプロンプトで更に出力結果をファイルにリダイレクトした場合はどうか? \n(PowerShellのリダイレクトはこれはこれでまた特殊な挙動をし文字化けの一因足ります)\n\n辺りは試してほしいです。\n\n* * *\n\nStraceNTのソースコードを追いかけたところ、未初期化の状態で[`vwprintf`が使われて](https://github.com/ipankajg/stracent/blob/v0.9.3/src/app/cli/stcliview.cpp#L71)おり、どうにも日本語が表示できないことが判明しました。[Windowsのwprintf関数はUnicodeを出力できない?](https://blogs.osdn.jp/2020/04/24/wprintf.html)などが参考になりますが、`setlocale`を実行する必要があります。 \nメッセージを作成している部分も[`LANG_NEUTRAL`が指定されて](https://github.com/ipankajg/stracent/blob/v0.9.3/src/app/strace.cpp#L236-L243)おり、日本語Windowsである限り日本語メッセージが取得されてしまいます。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T11:55:22.913", "id": "86397", "last_activity_date": "2022-02-16T23:26:33.870", "last_edit_date": "2022-02-16T23:26:33.870", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "86393", "post_type": "answer", "score": 4 } ]
86393
86397
86397
{ "accepted_answer_id": "86401", "answer_count": 1, "body": "昔勉強のためにたてた ubuntu LINUX のPCがあるんですが \n最近使ってなくてスペックもしょぼいので home にあるファイルだけバックアップして止めようと思ってます\n\n* * *\n\nssh は windows => linux にだけできる状態です\n\nまず Winscp っていうGUI から ssh 接続できるアプリで \nhome directory ごとフォルダをドラッグ&ドロップしてみたんですが \n途中で固まってしまいました\n\n* * *\n\nwindows terminal 上で \n`scp -r xxx:. .` \nとやるとやはり途中で固まってしまいます \nファイルに ? がはいってるところでとまるのでそのせいかなと思ってます\n\n* * *\n\n次に Linux 内に入って \n`tar cvjf /tmp/home.tar.bz2 *` \nでアーカイブにして\n\n`scp xxx:/tmp/home.tar.bz2 .` \nでコピーまではできました\n\nwindows 上には bzip2 がないので lhaz っていうソフトで解凍したんですが \n進捗ゲージ半分ぐらいのところで特にエラーもなく終わって \nファイル数が 1700 ぐらいあるはずなのに find してみると 800 ぐらいしかファイルが見つかりません \nしかも日本語ファイルが文字化けて全然違うファイル名になってしまいます\n\nファイル名が大文字小文字で別ファイルがあったら windows 上で同じファイルになっちゃうのでしょうがないんですがどうもそうではないようです\n\nどうにかして windows にディレクトリまるごと持ってくる方法ってありませんか?\n\n* * *\n\nLinux は 4.4.0-211-generic #243-Ubuntu SMP \nWindows は 10 です", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T18:21:54.507", "favorite_count": 0, "id": "86400", "last_activity_date": "2022-02-21T05:55:01.780", "last_edit_date": "2022-02-21T05:55:01.780", "last_editor_user_id": "3060", "owner_user_id": null, "post_type": "question", "score": 3, "tags": [ "linux", "windows", "文字化け" ], "title": "UNIX上のフォルダをWindows上にコピーしたい", "view_count": 952 }
[ { "body": "> 日本語ファイルが文字化けて全然違うファイル名になってしまいます\n\nLinuxを含むUNIXのファイルシステムには日本語ファイル名という概念がありません。`\\0`と`/`以外の任意のバイト列でファイル名を構成することができ、その解釈は実行する個々のプログラムに任せられています。しかも昔は\n**EUC-JP** というエンコーディングが使われていましたが、最近は **UTF-8** が使われているようです。 \nこの前提があるため、ファイルを扱う`tar`や`scp`なども特にファイル名を解釈することなく任意のバイト列として右から左に受け流しています。\n\n対してWindowsは違います。Unicode(UTF-16)で管理されており、Unicodeでないバイト列についての解釈もコントロールパネルで指定するようになっていて、日本語の場合、\n**Shift-JIS** が使用されます。\n\nこのような事情があるため、ファイル名について意識しないUNIX系のツールを使用してWindowsにファイルを持ち込むと文字化けします。\n\n* * *\n\n例えば転送にzip形式を使うのはどうでしょうか? zip形式はファイル名にUnicodeを使用することができます。\n\n[zip(1)](https://linux.die.net/man/1/zip)によりますと\n\n```\n\n zip archive dir -r -UN=UTF8\n \n```\n\n等で、ファイル名をUTF-8として扱い格納できるようです。\n\n* * *\n\n> windows 上には bzip2 がないので lhaz っていうソフト\n\n~~外部ツールは必要ありません。Windowsに標準搭載されている`tar`でもbzip2形式を扱えます。~~ \nまた、tarには複数のファイル形式があり、 **POSIX 1003.1-2001 (pax) format** はファイル名としてUTF-8を扱えます。 \nzipと異なりtarの場合、パイプラインで処理可能です。Windows側で次の1行で転送可能かもしれません。\n\n```\n\n ssh hoge@server \"tar cjf - --posix -C /home/hoge/dir .\" | tar xjf - -C C:/Users/fuga/dir\n \n```\n\n(なお、PowerShellの場合、パイプラインにバイナリデータを通せないため、コマンドプロンプトを使う必要があります)\n\n追記: 失礼しました。Windows付属の`tar`は\n\n```\n\n bsdtar 3.5.2 - libarchive 3.5.2 zlib/1.2.5.f-ipp\n \n```\n\nとのことで、zlibは組み込まれていますが、bzip2/xz/lzmaはライブラリが組み込まれておらず、直接は扱えませんでした。圧縮するならzlibを使い次のようになります。\n\n```\n\n ssh hoge@server \"tar czf - --posix -C /home/hoge/dir .\" | tar xzf - -C C:/Users/fuga/dir\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T21:16:30.657", "id": "86401", "last_activity_date": "2022-02-17T20:54:33.310", "last_edit_date": "2022-02-17T20:54:33.310", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "86400", "post_type": "answer", "score": 9 } ]
86400
86401
86401
{ "accepted_answer_id": "86459", "answer_count": 1, "body": "技術的に不可能な話をしていたら申し訳ありません。\n\nローカルのWindowsファイルサーバー(共有フォルダ)にHTMLを置くことでアクセスできるドキュメントサイトを作成したいです。 \nサイトのコンテンツはmarkdownで記載したいです。 \nそこでSSGにたどり着いたのですが、殆どがホスティングサーバー必須のものと見受けられます。 \n中でも、mkdocsやmkwikiは要件を満たしているとは思うのですが、他の選択肢もあれば検討したいです。\n\n必須ではないですが、他に満たしていたら嬉しい要件としては \n・ページをPDF出力できるプラグインがある事 \n・ページをDocx出力できるプラグインがある事 \n・ページ内検索ができる事 \nがあります。\n\nビルド不要なdocsifyがこの運用で動けば1番嬉しかったのですがホスティング必須のようで諦めています。\n\n複数の質問を含むような内容になってしまいましたが、ご教授いただければ幸いです。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-16T23:40:28.733", "favorite_count": 0, "id": "86402", "last_activity_date": "2022-02-19T15:52:00.750", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51461", "post_type": "question", "score": 0, "tags": [ "html", "windows", "markdown" ], "title": "ホスティングサーバー不要のSSGってありませんか?", "view_count": 200 }
[ { "body": "SSGというのは事前に静的コンテンツを生成しておく仕組み(を提供するツール)なので、本質的には\n\n * ホスティングしなくても、直接ブラウザで開ける(ように作ることは可能)\n * 事前ビルドは必要\n\nです。 \n他方、SSGツールにはプレビュー機能も搭載されている(ことが多い)ので、この機能を使うことで\n\n * 事前ビルドなしにオンデマンドでコンテンツを生成する\n\nこともできます。 \nただし、 `file://` で開くためには(現代のブラウザでは) CORS チェックを無効化する必要があります。\n\n* * *\n\n具体的な手順は次の通りです:\n\n 1. Firefox の設定画面で [`security.fileuri.strict_origin_policy`](http://kb.mozillazine.org/Security.fileuri.strict_origin_policy) を `false` に設定する。\n 2. [Docsify のドキュメント](https://docsify.js.org/#/quickstart?id=manual-initialization)に従って `index.html` を作成する。このときプロトコル `https://` を明示する。 \n``` <!-- index.html -->\n\n \n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n <meta charset=\"UTF-8\">\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/docsify@4/themes/vue.css\" />\n </head>\n <body>\n <div id=\"app\"></div>\n <script>\n window.$docsify = {\n }\n </script>\n <script src=\"https://cdn.jsdelivr.net/npm/docsify@4\"></script>\n </body>\n </html>\n \n```\n\n 3. 上記で作成した `index.html` と同じディレクトリ階層に [`README.md`](https://docsify.js.org/#/configuration?id=homepage) を作成する。例: \n``` cat > README.md <<EOF\n\n # タイトル\n 本文\n EOF\n \n```\n\n 4. `index.html` を Firefox で開く\n\n* * *\n\nコンテンツを(プレビュー機能を利用して)動的生成する場合、JSでローカルファイルにアクセスする必要がありますが、それを実現するためには次のいずれかを行う必要があります。\n\n * CORSチェックを無視してローカルファイルにアクセスできるようにする \n * 前述のブラウザ設定変更を行う\n * Same-Origin で提供する \n * http サーバでホストする\n\nどちらも許容できないのであれば、SSG本来の使い方、すなわち事前ビルドして静的コンテンツを生成する、を選択することになるかと思います。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T13:58:05.653", "id": "86459", "last_activity_date": "2022-02-19T15:52:00.750", "last_edit_date": "2022-02-19T15:52:00.750", "last_editor_user_id": "2808", "owner_user_id": "2808", "parent_id": "86402", "post_type": "answer", "score": 0 } ]
86402
86459
86459
{ "accepted_answer_id": "86423", "answer_count": 1, "body": "djangoでstripeが実行されません。 \nページを開いたときに読みこずhome.htmlのボタンを押してもfetchを読み込みません。 \nなぜ、プロジェクト直下のurlが読み込まれているかわかりません。 \njsのルーティングがおかしいのか見当がつかず質問させていただきました。\n\n#### ターミナルのエラー\n\n```\n\n \"GET /subscription/ HTTP/1.1\" 200 1496\n Not Found: /config/\n \n```\n\nChrome拡張のNetworkを開くと以下の内容が表示されます。\n\n```\n\n Page not found (404)\n Request Method: GET\n Request URL: http://127.0.0.1:8000/config/\n Using the URLconf defined in sample_app.urls, Django tried these URL patterns, in this order:\n \n admin/\n accounts/\n signup/ [name='signup']\n activate/<uidb64>/<token>/ [name='activate']\n subscription/\n The current path, config/, didn't match any of these.\n \n```\n\nプロジェクト直下のurls.pyは下記です。\n\n#### project/urls.py\n\n```\n\n from django.contrib import admin\n from django.urls import path, include\n from django.contrib.auth.decorators import login_required\n \n from django.views.generic import TemplateView\n from sample import views \n \n \n urlpatterns = [\n path('admin/', admin.site.urls),\n path('accounts/', include('django.contrib.auth.urls')),\n path('', login_required(TemplateView.as_view(template_name='registration/index.html'))),\n path(\"signup/\", views.SignUpView.as_view(), name=\"signup\"),\n path('activate/<uidb64>/<token>/', views.ActivateView.as_view(), name='activate'),\n path('subscription/', include('subscription.urls')),\n \n```\n\n```\n\n {% load static %}\n <!doctype HTML>\n <html>\n <head>\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css\" integrity=\"sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm\" crossorigin=\"anonymous\">\n <script src=\"https://code.jquery.com/jquery-3.2.1.slim.min.js\" integrity=\"sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN\" crossorigin=\"anonymous\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js\" integrity=\"sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q\" crossorigin=\"anonymous\"></script>\n <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js\" integrity=\"sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl\" crossorigin=\"anonymous\"></script>\n <script src=\"https://js.stripe.com/v3/\"></script> <!-- new -->\n <script src=\"{% static 'main.js' %}\"></script> <!-- new -->\n \n </head>\n <body>\n <nav class=\"navbar navbar-expand-lg navbar-dark bg-dark\">\n <a class=\"navbar-brand\" href=\"/\">サブスク</a>\n </nav>\n <div class=\"container mt-4\">\n {% block main %}\n <p>※{{user }}ようこそ</p>\n {% endblock %}\n \n </div>\n </body>\n </html>\n \n```\n\n#### home.html\n\n```\n\n {% extends \"subscription/base.html\" %}\n \n {% block main %}\n <p>{{ user }}様</p>\n \n <div class=\"container mt-5\">\n <button type=\"submit\" class=\"btn btn-primary\" id=\"submitBtn\">会員</button>\n \n </div>\n {% endblock %}\n \n```\n\n#### views.py\n\n```\n\n from django.shortcuts import render\n from django.views.generic import TemplateView\n \n from sample_app.settings import AUTH_USER_MODEL\n from subscription.models import Stripe_Customer\n \n User = AUTH_USER_MODEL\n \n \n from django.contrib.auth.decorators import login_required\n from django.utils.decorators import method_decorator\n \n \n from django.http.response import JsonResponse, HttpResponse \n from django.views.decorators.csrf import csrf_exempt \n from django.conf import settings \n import stripe \n \n \n @csrf_exempt\n def create_checkout_session(request):\n if request.method == 'GET':\n domain_url = 'http://localhost:8000/'\n stripe.api_key = settings.STRIPE_SECRET_KEY\n try:\n checkout_session = stripe.checkout.Session.create(\n client_reference_id=request.user.id if request.user.is_authenticated else None,\n success_url=domain_url + 'success?session_id={CHECKOUT_SESSION_ID}',\n cancel_url=domain_url + 'cancel/',\n payment_method_types=['card'],\n mode='subscription',\n line_items=[\n {\n 'price': settings.STRIPE_PRICE_ID,\n 'quantity': 1,\n }\n ]\n )\n return JsonResponse({'sessionId': checkout_session['id']})\n except Exception as e:\n return JsonResponse({'error': str(e)})\n \n @csrf_exempt\n def stripe_config(request):\n if request.method == 'GET':\n stripe_config = {'publicKey': settings.STRIPE_PUBLISHABLE_KEY}\n return JsonResponse(stripe_config, safe=False)\n \n \n @csrf_exempt\n def stripe_webhook(request):\n stripe.api_key = settings.STRIPE_SECRET_KEY\n endpoint_secret = settings.STRIPE_ENDPOINT_SECRET\n payload = request.body\n sig_header = request.META['HTTP_STRIPE_SIGNATURE']\n event = None\n \n try:\n event = stripe.Webhook.construct_event(\n payload, sig_header, endpoint_secret\n )\n except ValueError as e:\n # Invalid payload\n return HttpResponse(status=400)\n except stripe.error.SignatureVerificationError as e:\n # Invalid signature\n return HttpResponse(status=400)\n \n # Handle the checkout.session.completed event\n if event['type'] == 'checkout.session.completed':\n session = event['data']['object']\n \n # Fetch all the required data from session\n client_reference_id = session.get('client_reference_id')\n stripe_customer_id = session.get('customer')\n stripe_subscription_id = session.get('subscription')\n \n # Get the user and create a new StripeCustomer\n user = User.objects.get(id=client_reference_id)\n Stripe_Customer.objects.create(\n user=user,\n stripeCustomerId=stripe_customer_id,\n stripeSubscriptionId=stripe_subscription_id,\n )\n print(user.username + ' just subscribed.')\n \n return HttpResponse(status=200)\n \n #--------------------------------\n \n \n \n #-------index_view-----------\n @method_decorator(login_required,name=\"dispatch\")\n class IndexView(TemplateView):\n template_name = \"subscription/home.html\"\n model = Stripe_Customer\n \n \n #-------Success_view-----------\n \n class SuccessView(TemplateView):\n template_name = \"subscription/success.html\"\n \n #-------Cancel_view-----------\n class CancelView(TemplateView):\n template_name = \"subscription/cancel.html\"\n \n```\n\n#### urls.py\n\n```\n\n from django.urls import path\n from . import views\n \n from django.views.generic import TemplateView\n from subscription import views \n \n app_name =\"subscription\"\n \n urlpatterns = [\n path('', views.IndexView.as_view(), name='home'),\n path('config/', views.stripe_config),\n path('create-checkout-session/', views.create_checkout_session),\n path('success/', views.SuccessView.as_view(), name='success'),\n path('cancel/', views.CancelView.as_view(), name='cancel'),\n \n ]\n \n```\n\n#### static/main.js\n\n```\n\n console.log(\"Sanity check!\");\n \n // Get Stripe publishable key\n fetch(\"config/\")\n .then((result) => { return result.json(); })\n .then((data) => {\n // Initialize Stripe.js\n const stripe = Stripe(data.publicKey);\n \n // new\n // Event handler\n let submitBtn = document.querySelector(\"#submitBtn\");\n if (submitBtn !== null) {\n submitBtn.addEventListener(\"click\", () => {\n // Get Checkout Session ID\n fetch(\"/create-checkout-session/\")\n .then((result) => { return result.json(); })\n .then((data) => {\n console.log(data);\n // Redirect to Stripe Checkout\n return stripe.redirectToCheckout({sessionId: data.sessionId})\n })\n .then((res) => {\n console.log(res);\n });\n });\n }\n });\n \n```\n\n参考URL \n<https://testdriven.io/blog/django-stripe-subscriptions/>", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T02:11:35.617", "favorite_count": 0, "id": "86404", "last_activity_date": "2022-03-17T00:37:23.837", "last_edit_date": "2022-03-17T00:37:23.837", "last_editor_user_id": "34545", "owner_user_id": "34545", "post_type": "question", "score": 0, "tags": [ "python", "html", "django" ], "title": "Djangoでstripeのcheck_out_sessionが開かれない", "view_count": 139 }
[ { "body": "まず、js側の`fetch`でリクエストしようとしている`\"config/\"`は`urls.py`に見当たりません。\n\n`main.js`でやろうとしていることを踏まえると、リクエスト先は`/subscription/config/`が正しいように見えます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T16:44:02.983", "id": "86423", "last_activity_date": "2022-02-17T16:44:02.983", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2784", "parent_id": "86404", "post_type": "answer", "score": 1 } ]
86404
86423
86423
{ "accepted_answer_id": null, "answer_count": 1, "body": "asp.net(VB)で作成した画面をiPhoneのsafariで開いているのですが、 \n\"終了する\"ボタンを押したらタブを消したいと考えています。 \nボタンを押すとウィンドウが現れて\"終了します\"とは表示されるのですが、 \n\"閉じる\"を押してもタブは消えず元の画面に戻るだけという状態です。\n\nデザイナー側のプログラム\n\n```\n\n <div>\n <asp:Button ID=\"btn_terminate\" runat=\"server\" Text=\"終了する\" CssClass=\"button_shared_preference\" />\n </div>\n \n```\n\nコード側のプログラム\n\n```\n\n Protected Sub btn_terminate_Click(sender As Object, e As EventArgs) Handles btn_terminate.Click\n ClientScript.RegisterClientScriptBlock(Me.GetType(), \"key\", \"window.alert('終了します');window.close()\", True)\n End Sub\n \n```\n\n補足 2022-02-18 \n大まかな作業の流れはこちらになります。 \n1.URLの記載されたQRをiPhoneのカメラで読み込んでサイトにアクセスする \nサイトロード時に特別な処理は行っていません \n2.サイト内でチェックや入力などを行う \n※重要なことではないので詳細は割愛します \n3.”終了する”ボタンを押すと内容をサーバ内に書き出して表示されているウィンドウを閉じる \n表示されているウィンドウとは\"1\"でアクセスして\"2\"で色々と突いたサイトの事です \n困っている部分は、\"ウィンドウを閉じる\"部分です。 \nサーバ内への書き出しは実装済みです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T03:13:33.373", "favorite_count": 0, "id": "86406", "last_activity_date": "2022-02-18T01:49:28.137", "last_edit_date": "2022-02-18T01:49:28.137", "last_editor_user_id": "49304", "owner_user_id": "49304", "post_type": "question", "score": 0, "tags": [ "asp.net" ], "title": "asp.net(VB)でボタンを押したら画面を閉じるようにしたい", "view_count": 1725 }
[ { "body": "iPhone の Safari とかでどうなるか不明ですか、普通ブラウザでそういうスクリプトでは閉じないのでは?\nJavaScriptで閉じることができるウィンドウは、JavaScriptで開かれたウィンドウのみのはずです。\n\n**【追記 2022/2/18 10:35】**\n\n質問欄に「補足 2022-02-18」を追記されたようですので、それに対するレスを以下に追記します。\n\n> 1.URLの記載されたQRをiPhoneのカメラで読み込んでサイトにアクセスする \n> サイトロード時に特別な処理は行っていません\n\nそれは多分ブラウザのアドレスバーに問題のページの URL を入力して GET 要求をかけたことと同じと理解します。そうであれば、kunif\nさんが質問欄で紹介された記事にある、\n\n```\n\n window.open('about:blank','_self').close();\n \n```\n\n以外に手はなさそうですが、それで期待通りにクローズできるか否かはブラウザ依存です。iPhone の Safari\nでどうなるか自分にはその環境はないので不明です。試してみてはいかがですか?\n\nちなみに、自分の環境で試した限りですが、それでクローズできたブラウザは IE11, Firefox 97.0.1 のみです。\n\nChrome 98.0.4758.102, Edge 98.0.1108.56, Opera 84.0.4316.14 は close\nは無視されるようで、open した about:blank が残ってしまいます。\n\niPhone の Safari\nで上のスクリプトを使ってもダメなら、そのような裏技的な手段は諦めて、ユーザーが自ら操作してクローズしてもらえるように正攻法で考えることをお勧めします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T03:55:51.417", "id": "86408", "last_activity_date": "2022-02-18T01:35:29.753", "last_edit_date": "2022-02-18T01:35:29.753", "last_editor_user_id": "43387", "owner_user_id": "43387", "parent_id": "86406", "post_type": "answer", "score": 1 } ]
86406
null
86408
{ "accepted_answer_id": null, "answer_count": 1, "body": "### 発生しているエラー\n\n`rails c` でスクリプトを流す場合、helpers.strip_tagsが使えない。 \ngsubと正規表現でhtmlタグを取り除こうとすると ”/n” の改行コードも含まれてしまう\n\n### 期待する動作\n\n以下の真ん中にある `/n` を含めずにhtmlタグを消したい\n\n```\n\n <p>山田 /n 太郎</p>\n \n```\n\n### エラーの内容\n\nこちらの正規表現を記述するとhtmlタグ(pタグ)を除去できるが、”/n”もまとめて除去されてしまう。\n\n```\n\n User.first.User_name.gsub(/<(\"[^\"]*\"|'[^']*'|[^'\">])*>/, \"\")\n \n```\n\n### 試したこと\n\nhtmlタグを指定する前に”/n”を除く記述を試した。 \nうまく除去ができない。\n\n```\n\n User.first.User_name.gsub(^(?!.*/n).$/<(\"[^\"]*\"|'[^']*'|[^'\">])*>/, \"\")\n \n```\n\n* * *\n\n条件としては\n\n * タグを除去する \n * /nの改行コードは除く\n\n正規表現がうまくできず、困ってます。 \n知見のある方お手数ですがご教授頂ければ幸いです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T03:32:51.073", "favorite_count": 0, "id": "86407", "last_activity_date": "2022-02-17T16:22:59.220", "last_edit_date": "2022-02-17T04:49:54.627", "last_editor_user_id": "3060", "owner_user_id": "51464", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "html" ], "title": "rubyの正規表現で/nを含まずhtmlタグを削除する方法", "view_count": 187 }
[ { "body": "実は、\n\n> rails c でスクリプトを流す場合、helpers.strip_tagsが使えない。\n\nということはなくて、コンソール内部で\n\n```\n\n include ActionView::Helpers::SanitizeHelper\n \n```\n\nとすると、`strip_tags`メソッドが呼べるようになります。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T16:22:59.220", "id": "86420", "last_activity_date": "2022-02-17T16:22:59.220", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "442", "parent_id": "86407", "post_type": "answer", "score": 0 } ]
86407
null
86420
{ "accepted_answer_id": null, "answer_count": 1, "body": "WordPressプラグインの「CustomFieldSuite」を使用したサイトを構築しています。\n\nカスタム投稿はCPTUIを使用し「merchandise」としていまして \nそこにCFSを適用して、「num」というフィールドを作成したのですが、そのnumフィールドに設定した値をスラッグにしたいのです。\n\n例)https://xxx.com/merchandise/numの値\n\nいろいろと調べてみたのですが \n類似プラグインのAdvanceCustomFieldの例しか掲載されておらず困っております。\n\nアクションフックを使用するのかなと思いfunction.phpにて \n<https://mgibbs189.github.io/custom-field-suite/api/save.html> \nこちらに掲載されているように値の保存などを試したみたのですがなかなかうまくいかず、、\n\nもしご存知の方がいましたらお力添えをお願いできればと思います。 \nよろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T06:04:07.323", "favorite_count": 0, "id": "86410", "last_activity_date": "2022-02-26T07:15:24.097", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51468", "post_type": "question", "score": 0, "tags": [ "php", "html", "css", "wordpress" ], "title": "WordPressプラグインの「CustomFieldSuite」に挿入した値をパーマリンクに設定したい", "view_count": 159 }
[ { "body": "おそらくこれが参考になるかと思います。\n\n[ワードプレス 投稿スラッグをカスタムフィールドの値で置き換える方法](https://ja-ja.jp/archives/449)\n\n紹介されているのは以下のような仕組みだと思います。\n\n * カスタムフィールドの値で\n * 記事の保存をするときにスラッグを書き換えてから保存する\n\nなので、カスタムフィールドを使わなくてもスラッグを使うといいんじゃないでしょうかね? \nカスタムフィールドを使いたいという強い理由があるのかもしれませんが。\n\nまたパーマリンクはpostnameで設定しておかないと反映されないと思いますので合わせてご確認ください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-24T11:18:38.067", "id": "86555", "last_activity_date": "2022-02-26T07:15:24.097", "last_edit_date": "2022-02-26T07:15:24.097", "last_editor_user_id": "3060", "owner_user_id": "51589", "parent_id": "86410", "post_type": "answer", "score": 0 } ]
86410
null
86555
{ "accepted_answer_id": null, "answer_count": 1, "body": "centos で、`sudo yum remove python`を実行してしまいました。 \ncentosの一部の機能が使えない状態になりました。 \n`sudo yum install python`を実行してもcentosの一部の機能が使えないです。 \nどうすれば、もとの状態に戻すことができるのでしょうか\n\n* * *\n\n追記 \nCentOSのバージョンは、 \n`CentOS Linux release 7.9.2009 (Core)`\n\n恐らく、ライブラリーではなく、依存パッケージも削除してしまった状態だと思います。 \n`sudo yum remove python`を実行すると、大量に削除されました。\n\n* * *\n\n追記 \n`sudo rpm -Uvh --replacepkgs *.rpm`を実行しますと、\n\n```\n\n エラー: 依存性の欠如:\n python-rpm-macros > 3-30 は python-devel-2.7.5-89.el7.x86_64 に必要とされています\n python2-rpm-macros > 3-30 は python-devel-2.7.5-89.el7.x86_64 に必要とされています\n \n \n```\n\nと出力されました。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T07:05:35.617", "favorite_count": 0, "id": "86411", "last_activity_date": "2022-02-17T08:33:43.800", "last_edit_date": "2022-02-17T08:26:42.207", "last_editor_user_id": "50834", "owner_user_id": "50834", "post_type": "question", "score": 1, "tags": [ "python", "linux", "centos" ], "title": "sudo yum remove pythonを誤ってしたのですが、もとに戻し方が分かりません", "view_count": 844 }
[ { "body": "以下は [Reinstalling python on CentOS to be able to use yum - Server\nFault](https://serverfault.com/q/410075) での\n[回答の一つ](https://serverfault.com/a/611048) を参考にしたもので、私自身が実際に試したものではない点はご了承ください。\n\n* * *\n\nCentOS において Python は OS の動作に関わるパッケージなので、削除時に依存パッケージとして yum\nコマンド等も削除されている可能性があります。\n\nまずは以下の手順で必要最低限なパッケージの再インストールを試してみてください。\n\n```\n\n ### 作業用のディレクトリに移動\n $ cd /tmp\n \n ### 必要なパッケージファイルをダウンロード\n $ wget http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm\n $ wget http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm\n $ wget http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/os/x86_64/Packages/python-devel-2.7.5-89.el7.x86_64.rpm\n $ wget http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm\n \n ### rpm コマンドでパッケージをインストール\n $ sudo rpm -Uvh --replacepkgs *.rpm\n \n```\n\nまた、yum コマンドでのパッケージ操作のログが `/var/log/yum.log*`\nに記録されている可能性があるので、誤って削除したパッケージを確認する際のヒントになるかもしれません。\n\n```\n\n $ sudo less /var/log/yum.log\n \n```\n\n#### 追記\n\nrpm\nコマンド実行時に足りないパッケージが表示されるようであれば、[ミラーサイトのディレクトリ](http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/os/x86_64/Packages/)\nから都度パッケージを確認してダウンロードしてください。\n\n```\n\n $ wget http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/os/x86_64/Packages/python-rpm-macros-3-34.el7.noarch.rpm\n $ wget http://ftp.iij.ad.jp/pub/linux/centos/7.9.2009/os/x86_64/Packages/python2-rpm-macros-3-34.el7.noarch.rpm\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T07:44:02.307", "id": "86413", "last_activity_date": "2022-02-17T08:33:43.800", "last_edit_date": "2022-02-17T08:33:43.800", "last_editor_user_id": "3060", "owner_user_id": "3060", "parent_id": "86411", "post_type": "answer", "score": 1 } ]
86411
null
86413
{ "accepted_answer_id": "86429", "answer_count": 2, "body": "あるフォルダに縦80ピクセル、横100ピクセルにリサイズされた4000枚の画像ファイルが置いてあります。これを読み込んでListViewコントロールに画像の一覧を表示します。\n\n問題は時間がかかる事です。読み込み処理の時、最初の1000枚は約30秒かかるのですが、次の1000枚は約56秒、次の1000枚は約79秒、次の1000枚は約105秒かかります。だんだんと読み込み速度が遅くなってるようなのです。これを最初の読み込み速度を維持したまま全部読み込めば、約2分で全部読み込み終わります。\n\n```\n\n Imports System\n Imports System.IO\n \n Public Class Form1\n Dim imgList As New ImageList\n Dim sec As Double = 0\n \n Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click\n Dim sw As New System.Diagnostics.Stopwatch()\n sw.Start()\n Dim oldsec As Integer = 0\n \n For Each path As Object In Directory.GetFiles(Application.StartupPath & \"\\cache\\\", \"*\", SearchOption.TopDirectoryOnly)\n Dim fs As FileStream = File.OpenRead(path)\n imgList.Images.Add(Image.FromStream(fs, False, False))\n \n ListView1.Items.Add(path, imgList.Images.Count)\n \n If imgList.Images.Count = 1000 Then\n Debug.WriteLine(\"1 sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n oldsec = Double.Parse(sw.Elapsed.TotalSeconds.ToString)\n ElseIf imgList.Images.Count = 2000 Then\n Debug.WriteLine(\"2 sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n oldsec = Double.Parse(sw.Elapsed.TotalSeconds.ToString)\n ElseIf imgList.Images.Count = 3000 Then\n Debug.WriteLine(\"3 sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n oldsec = Double.Parse(sw.Elapsed.TotalSeconds.ToString)\n ElseIf imgList.Images.Count = 4000 Then\n Debug.WriteLine(\"4 sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n oldsec = Double.Parse(sw.Elapsed.TotalSeconds.ToString)\n End If\n Next\n \n sw.Stop()\n End Sub\n \n Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load\n imgList.ImageSize = New Size(100, 80)\n ListView1.LargeImageList = imgList\n End Sub\n \n```\n\n出力ウィンドウに出力された文字列\n\n```\n\n 1 sec = 31.8310536 diff = 31.8310804\n 2 sec = 88.7196354 diff = 56.7196397\n 3 sec = 168.8318207 diff = 79.831824\n 4 sec = 274.2561862 diff = 105.256191\n \n```\n\nどのようにすれば最初の読み込み速度を維持したまま全部読み込み終えるでしょうか?あるいはもっと早く読み込み終えられるでしょうか? \n条件としては、ListViewの仮想モードを使わない、基本的にはマルチスレッドを使わない、です。", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T09:33:27.427", "favorite_count": 0, "id": "86414", "last_activity_date": "2022-02-18T06:07:51.127", "last_edit_date": "2022-02-18T05:41:19.247", "last_editor_user_id": "4236", "owner_user_id": "51020", "post_type": "question", "score": 0, "tags": [ "vb.net", "winforms" ], "title": "大量の画像ファイルを読み込む時、読み込み速度が次第に遅くなる", "view_count": 663 }
[ { "body": "コメントして頂いた方のアドバイスに従ってListViewへの追加を最後らへんに行うようにしたところ、かなり早くなりました。\n\n出力ウィンドウに出力された文字列\n\n```\n\n 1 sec = 1.7978672 diff = 1.7978888\n 2 sec = 4.0005821 diff = 2.0005857\n 3 sec = 6.5848129 diff = 2.5848188\n 4 sec = 9.9223631 diff = 2.9223676\n sec = 32.1548404 diff = 22.1548443\n \n```\n\n変更後のコード\n\n```\n\n Imports System\n Imports System.IO\n \n Public Class Form1\n Dim imgList As New ImageList\n Dim sec As Double = 0\n Dim strArr(4001) As String\n \n Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click\n Dim sw As New System.Diagnostics.Stopwatch()\n sw.Start()\n Dim oldsec As Integer = 0\n Dim index As Integer = 0\n \n For Each path As Object In Directory.GetFiles(Application.StartupPath & \"\\cache\\\", \"*\", SearchOption.TopDirectoryOnly)\n Dim fs As FileStream = File.OpenRead(path)\n imgList.Images.Add(Image.FromStream(fs, False, False))\n \n strArr(index) = path\n index += 1\n \n If imgList.Images.Count = 1000 Then\n Debug.WriteLine(\"1 sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n oldsec = Double.Parse(sw.Elapsed.TotalSeconds.ToString)\n ElseIf imgList.Images.Count = 2000 Then\n Debug.WriteLine(\"2 sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n oldsec = Double.Parse(sw.Elapsed.TotalSeconds.ToString)\n ElseIf imgList.Images.Count = 3000 Then\n Debug.WriteLine(\"3 sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n oldsec = Double.Parse(sw.Elapsed.TotalSeconds.ToString)\n ElseIf imgList.Images.Count = 4000 Then\n Debug.WriteLine(\"4 sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n oldsec = Double.Parse(sw.Elapsed.TotalSeconds.ToString)\n End If\n Next\n \n For i As Integer = 0 To 3999\n ListView1.Items.Add(strArr(i), i)\n Next\n Debug.WriteLine(\"sec = \" & sw.Elapsed.TotalSeconds.ToString & \" diff = \" & Math.Abs(oldsec - Double.Parse(sw.Elapsed.TotalSeconds.ToString)))\n sw.Stop()\n End Sub\n \n Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load\n imgList.ImageSize = New Size(100, 80)\n ListView1.LargeImageList = imgList\n End Sub\n \n```\n\nありがとうございました。\n\n**\\--------------------------追記---------------------------**\n\nsayuri様の回答を参考に試してみたらさらに少し早くなりました。\n\n出力ウィンドウに出力された文字列\n\n```\n\n sec = 1.0324989\n sec = 10.7114742\n sec = 17.5112929\n \n```\n\nコード\n\n```\n\n Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click\n Dim sw As New System.Diagnostics.Stopwatch()\n sw.Start()\n \n Dim images As New List(Of Image)\n Dim items As New List(Of ListViewItem)\n \n For Each path In Directory.GetFiles(Application.StartupPath & \"\\cache\\\", \"*\", SearchOption.TopDirectoryOnly)\n Dim fs As FileStream = File.OpenRead(path)\n images.Add(Image.FromStream(fs, False, False))\n items.Add(New ListViewItem(path, images.Count))\n Next\n \n Debug.WriteLine(\"sec = \" & sw.Elapsed.TotalSeconds.ToString)\n imgList.Images.AddRange(images.ToArray())\n \n Debug.WriteLine(\"sec = \" & sw.Elapsed.TotalSeconds.ToString)\n ListView1.Items.AddRange(items.ToArray())\n \n Debug.WriteLine(\"sec = \" & sw.Elapsed.TotalSeconds.ToString) \n sw.Stop()\n End Sub\n \n```\n\nListView.ListViewItemCollection.AddRangeの使い方などを教えていただきありがとうございました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T13:32:56.287", "id": "86417", "last_activity_date": "2022-02-18T06:07:51.127", "last_edit_date": "2022-02-18T06:07:51.127", "last_editor_user_id": "51020", "owner_user_id": "51020", "parent_id": "86414", "post_type": "answer", "score": 1 }, { "body": "処理の開始時に[`ListView.BeginUpdate()`](https://docs.microsoft.com/ja-\njp/dotnet/api/system.windows.forms.listview.beginupdate?view=windowsdesktop-6.0)、終了後に[`ListView.EndUpdate()`](https://docs.microsoft.com/ja-\njp/dotnet/api/system.windows.forms.listview.endupdate?view=windowsdesktop-6.0)を呼ぶことで、項目操作毎の画面更新を抑止できるため、処理を高速化できます。\n\n* * *\n\nただし、`ListView.BeginUpdate()`の項目でも説明されていますが、[`ListView.AddRange`](https://docs.microsoft.com/ja-\njp/dotnet/api/system.windows.forms.listview.listviewitemcollection.addrange?view=windowsdesktop-6.0)を使用した方が効果的です。しかも`ImageList`側には`BeginUpdate`\n/ `EndUpdate`が存在せず[`AddRange()`](https://docs.microsoft.com/ja-\njp/dotnet/api/system.windows.forms.imagelist.imagecollection.addrange?view=windowsdesktop-6.0)のみですのでなおさらです。\n\nC#でしか書けないのですが次のような流れになります。\n\n```\n\n var sw = System.Diagnostics.Stopwatch.StartNew();\n \n var images = new List<Image>();\n var items = new List<ListViewItem>();\n \n foreach (var path in Directory.GetFiles(Application.StartupPath + \"/cache\")) {\n var fs = File.OpenRead(path);\n images.Add(Image.FromStream(fs, false, false));\n items.Add(new ListViewItem(path, images.Count));\n }\n \n imgList.Images.AddRange(images.ToArray());\n ListView1.Items.AddRange(items.ToArray());\n \n Debug.WriteLine(\"sec = {0}\", sw.Elapsed.TotalSeconds);\n \n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T04:27:53.710", "id": "86429", "last_activity_date": "2022-02-18T04:27:53.710", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "86414", "post_type": "answer", "score": 0 } ]
86414
86429
86417
{ "accepted_answer_id": null, "answer_count": 1, "body": "ワードプレスで1からサイトを制作しています。 \nアイキャッチ画像を固定ページで設定しようとしていますが、表示がありません。 \n検索をかけたところ表示オプションにある資格にチェックを入れると表示されるとありますが、見当たりません。\n\nまた、functions.phpに問題があるのかもしれないと知り、様々なネットのコードを記入しましたが効果がありません、\n\nfunctions.php\n\n```\n\n <?PHP\n add_theme_support('post-thumbnails');\n ?>\n \n```\n\nプラグインを無効化したりしていますが、それでもアイキャッチ画像の項目が出ません。 \n一体どうすればいいでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T14:07:32.553", "favorite_count": 0, "id": "86418", "last_activity_date": "2022-02-18T06:28:54.057", "last_edit_date": "2022-02-18T06:28:15.863", "last_editor_user_id": "3060", "owner_user_id": "49042", "post_type": "question", "score": 0, "tags": [ "php", "wordpress" ], "title": "アイキャッチ画像が表示されません", "view_count": 78 }
[ { "body": "CSS一番上の記述を修正したら治りました。\n\n```\n\n /*\n Theme Name: test\n Version: 1.00\n */\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T05:48:10.903", "id": "86432", "last_activity_date": "2022-02-18T06:28:54.057", "last_edit_date": "2022-02-18T06:28:54.057", "last_editor_user_id": "3060", "owner_user_id": "49042", "parent_id": "86418", "post_type": "answer", "score": 1 } ]
86418
null
86432
{ "accepted_answer_id": "86421", "answer_count": 1, "body": "※他のサイトでも同様の質問を行っています。解決後はそれぞれ更新致します。よろしくお願いします。 \n<https://teratail.com/questions/av2uvajgpeg8dy>\n\n### 前提・実現したいこと\n\n投稿された質問(post)に対して回答したコメント(comment)に非同期通信でいいね(good)を押す機能を実装したいです。\n\n### 発生している問題・エラーメッセージ\n\n設置したいいねリンクでcreateアクションが実行されません。 \nビューは表示されており、検証ツールで以下のエラーが生じています。 \n画面のハートを押すとこのような挙動になります。\n\nrails-ujs.js:216 POST http://localhost:3000/posts/1/comments/8/goods 404 (Not\nFound) \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-02-17/1dd2de2a-d961-4209-8fb2-e94f094d1df3.png)\n\n### 自分で調べたことや試したこと\n\n質問に対してのいいねは以下記事を参考にし、実行できました。 \n<https://qiita.com/max_3252/items/ca8f623563e26b6a8630>\n\n次はそのコードを流用する形でコメントへのいいねを実装しようとしましたが、このようなエラーが生じています。\n\n404 not foundについて調べたところ、リンク切れやリダイレクトの設定ミスとありました。 \nリンク切れは無いとして、リダイレクトの設定ミスかと模索しました。\n\nエラー内容にて、http://localhost:3000/posts/1/comments/8/goods とあり、 \npost_idやcomment_idの取得、methodの指定も行なっているので問題ないのでは...と思い、原因を掴めていません。\n\n### 使っているツールのバージョンなど補足情報\n\nruby: 3.0.2 \nrails: 6.0.4 \njquery-rails: 4.4.0\n\n* * *\n\n### 該当のソースコード\n\nルーティング\n\n```\n\n routes.rb\n \n Rails.application.routes.draw do\n (省略)\n resources :posts do\n resources :favorites, only: %i[create destroy]\n resources :comments, only: %i[create destroy] do\n resources :goods, only: %i[create destroy]\n end\n end\n end\n \n```\n\nビュー関連\n\n```\n\n app/views/goods/create.js.erb\n \n $('#goods_buttons<%= @comment.id %>').html(\"<%= j(render partial: 'goods/good', locals: {post: @post, comment: @comment}) %>\");\n \n```\n\n```\n\n app/views/goods/destroy.js.erb\n \n $('#goods_buttons<%= @comment.id %>').html(\"<%= j(render partial: 'goods/good', locals: {post: @post, comment: @comment}) %>\");\n \n```\n\n```\n\n app/views/goods/_good.html.erb\n \n <% unless @comment.good_user(@current_user.id).blank? %>\n <%= link_to post_comment_good_path(post_id: @post.id, comment_id: comment.id), method: :delete, remote: true do %>\n <div class=\"vertical_good\">\n <%= image_tag \"icon_red_heart.png\", size: '20x20' %>\n </div>\n <% end %>\n <% else %>\n <%= link_to post_comment_goods_path(@post, comment), method: :post, remote: true do %>\n <div class=\"vertical_good\">\n <%= image_tag \"icon_heart.png\", size: '20x20' %>\n </div>\n <% end %>\n <% end %>\n \n```\n\n```\n\n app/views/comments/_comment.html.erb\n \n <div class=\"p-comment__item\">\n <p><%= simple_format(comment.comment) %></p>\n <div class=\"p-comment__bottomLine\">\n <div id=\"goods_buttons<%= comment.id %>\">\n <%= render partial: 'goods/good', locals: { post: @post, comment: comment } %>\n </div>\n <span><%= comment.created_at.to_s(:datetime_jp) %></span>\n <span><%= link_to '削除', post_comment_path(@post, comment), method: :delete, data: { confirm: '削除してよろしいですか?' } %></span>\n </div>\n </div>\n \n```\n\n```\n\n app/views/posts/show.html.erb\n \n (一部省略)\n <div class=\"p-comment__list\">\n <div class=\"p-comment_listTitle\">コメント</div>\n <%= render @post.comments %>\n </div>\n \n <%= render partial: 'comments/form', locals: { comment: @comment } %>\n \n```\n\nコントローラ\n\n```\n\n goods_controller.rb\n \n class GoodsController < ApplicationController\n before_action :set_comment, only: %i[create destroy]\n \n def create\n @good = Good.create(user_id: current.user_id, post_id: @post.id, comment_id: @comment.id)\n end\n \n def destroy\n good = Good.find_by(user_id: current.user_id, comment_id: comment.id)\n good.destroy\n end\n \n private\n \n def set_comment\n @post = Post.find(params[:id])\n @comment = Comment.find(comment_id: @post.id)\n end\n end\n \n```\n\n```\n\n comments_controller.rb\n \n class CommentsController < ApplicationController\n def create\n comment = Comment.new(comment_params)\n if comment.save\n flash[:notice] = 'コメントを投稿しました'\n redirect_to comment.post\n else\n flash[:comment] = comment\n flash[:error_messages] = comment.errors.full_messages\n redirect_back fallback_location: comment.post\n end\n end\n \n def destroy\n comment = Comment.find(params[:id])\n comment.delete\n redirect_to comment.post, flash: { notice: 'コメントが削除されました' }\n end\n \n private\n \n def comment_params\n params.require(:comment).permit(:post_id, :comment)\n end\n end\n \n```\n\n```\n\n posts_controller.rb\n \n class PostsController < ApplicationController\n before_action :set_target_post, only: %i[show edit update destroy]\n \n (省略)\n \n def show\n @comment = Comment.new(post_id: @post.id)\n end\n \n (省略)\n \n private\n \n (省略)\n \n def set_target_post\n @post = Post.find(params[:id])\n end\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T14:34:22.430", "favorite_count": 0, "id": "86419", "last_activity_date": "2022-02-18T01:17:32.903", "last_edit_date": "2022-02-18T01:17:32.903", "last_editor_user_id": "3060", "owner_user_id": "51475", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "jquery", "ajax" ], "title": "Rails でいいねの create アクションが実行されない", "view_count": 456 }
[ { "body": "`goods_controller.rb`にある、\n\n```\n\n @comment = Comment.find(comment_id: @post.id)\n \n```\n\nですが、`find`メソッドは引数にIDを取ります。ハッシュを渡しても動作しません。 \n<https://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-\nfind> \nこの際、`Comment`レコードが見つからないため、Railsは「リソースが見つからなかった」際に出すべき404のステータスコードを返します。\n\nここではコメントのIDがすでに分かっており(今ならば`8`)、それを使ってコメントの取得ができます。\n\n```\n\n @comment = Comment.find(params[:comment_id])\n \n```\n\nと、ここまで書いていて気づいたのですが、Postを取得している\n\n```\n\n @post = Post.find(params[:id])\n \n```\n\nも、\n\n```\n\n @post = Post.find(params[:post_id])\n \n```\n\nに変更したほうがよいかもしれません。Railsの`params`に渡ってくる`id`関係の値がどのようなキーで取得できるかは`resources`の書き方によって変わってくるためです。\n\nなお、\n\n> 404 not foundについて調べたところ、リンク切れやリダイレクトの設定ミスとありました。 \n> リンク切れは無いとして、リダイレクトの設定ミスかと模索しました。\n\nというのは一般的な理解ではあるのですが、Railsはデータベースからレコードを発見できなかったときに404を返すのは覚えておいてください。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T16:35:31.963", "id": "86421", "last_activity_date": "2022-02-17T16:35:31.963", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "442", "parent_id": "86419", "post_type": "answer", "score": 0 } ]
86419
86421
86421
{ "accepted_answer_id": null, "answer_count": 1, "body": "railsの名前空間について調べると、名前の衝突(同名での定義)を防ぐというのが目的という情報しか出てきません。\n\n```\n\n module Admin\n class User\n #メソッドなど\n end\n end\n \n module Guest\n class User\n #メソッドなど\n end\n end\n \n```\n\nしかし、例えばパソコンでファイルを整理するさいに同系統のものを同じフォルダに整理したりするのと同じ感じで、同系統のファイルを整理する目的で使ってもよいのでしょうか?\n\n例えば以下のような感じです。 \nAという機能に関係したservice一覧と、Bという機能に関係したservice一覧には一切、名前の重複はありません。\n\n```\n\n app/service/機能A/Aという機能に関係したservice一覧\n app/service/機能B/Bという機能に関係したservice一覧\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-17T22:54:11.077", "favorite_count": 0, "id": "86424", "last_activity_date": "2022-02-19T01:32:22.643", "last_edit_date": "2022-02-18T11:35:45.240", "last_editor_user_id": "40650", "owner_user_id": "40650", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails" ], "title": "railsの名前空間の目的についての疑問", "view_count": 523 }
[ { "body": "RubyとRailsでの話がごっちゃになっているように思います。まずはそれらを整理してから話していきます。\n\n## プログラミング言語における「名前空間」\n\n「名前空間」というのはプログラミング言語一般で使用される機能で、主な目的はお調べしたとおり「名前の衝突を防ぐ」と言うものです。Cのような古い言語では名前空間という機能を言語として実装していなかったため、二つの既存のプログラムをくっつけて一つのプログラムに使用としたとき、関数名等が被ってしまい既存のプログラムのコードの修正が必要になったと言うことがありました。その反省を踏まえ、その後に開発された言語、例えばC++では`namespace`というキーワードを使って「名前空間」を作成することで、関数名等の衝突などを防ぐようにしました。他の言語でも同じように「名前空間」の機能を搭載していきますが、どのようにして提供するかは言語によって異なります。例えば、JavaのパッケージやJavaScriptのモジュールと言った機能も「名前空間」の機能を提供する実装の一つです。\n\n## Rubyのおける「名前空間」とモジュールの関係\n\nRuby自体には「名前空間」という名前の機能がありません。しかし、「名前空間」を実現出来ないというわけではありません。モジュールが「名前空間」の機能を提供するとなっています。\n\nまず、勘違いしてはいけないのは、モジュールは「名前空間」のため **だけ** の機能ではないことです。他のクラスやモジュールにMix-\ninしたり、オブジェクトそのものの拡張(`extend`)したり、再定義(`refine`)の機能を使うために`using`したりします。それら多くの機能の一つとして、「名前空間」の機能があると言うことです。なお、クラスもモジュールを拡張しているため、同じように「名前空間」に使用することができます。\n\n名前空間を作るかどうか、どのように使うかは、そのプログラムは何か、また、設計指針はどうなっているかによります。例えば、gemで提供されるライブラリは、一番トップでライブラリ名の名前空間で分けて、他のライブラリと被らないようにするのが通例です。これはライブラリが他のプログラムと一緒になる可能性があるため、適切な名前空間を設けていないと名前衝突が発生してしまうからです。逆に言うと、ライブラリでも無く、他のプログラムと一緒になるようなことも無いような、それこそ書き捨てなプログラムなら、わざわざ名前空間を作る必要は無いと言えます。\n\n## RailsにおけるRubyの「名前空間」\n\n前節まではRuby一般の話でRailsの話ではありませんでした。これがRailsになると自由に何でもしていいのかというわけではなくなります。なぜなら、Railsには流儀というか設計指針というか、名前空間の分け方の指針みたいな物があるからです。\n\n`User`モデルの一覧を読み込む\"/users\"というアクセスを考えています。\"/users\"へのアクセスは\"/app/controllers/users_controller.rb\"にある`UsersContoroller`コントローラーの`index`メソッドを呼び出します。この`UsersContoroller`はどこかのモジュールの中ではなく、トップレベルに定義されている必要があります。一覧はいいが、作成や編集は管理者だけなので、わかりやすいように\"/admin/users/new\"で新規作成画面を出すとします。\"/admin/users/new\"へのアクセスは、\"/app/controllers/admin/users_controller.rb\"にある`Admin::UsersContoroller`コントローラーの`new`メソッドが呼び出します。こちらの`Admin::UsersContoroller`は`Admin`モジュールに名前空間にあります。クラス名は一緒でも先程の`UsersContoroller`とは別物です。このように同じクラス名でも全く別のクラスとして定義できるようになります。\n\nもちろん、各パスを全く別のコントローラに紐付けるもできます。ただ、その場合は\"config/routes.rb\"で追加のオプションを設定する必要があります。必要に迫られない限り、やるできではないでしょう。\n\nこのように、Railsではモデルやコントローラー等をどこに置くのか、その時はモジュールの中か、それともトップレベルにするのかが決まっています。通常のモデルやコントローラーのクラスはトップレベルですが、`ralis\ngenerate`の時に\"親の名前/モデル名\"と言うような形で作成すると、モジュールで名前空間を形成して、同じ名前でも別々のモデルやコントローラを作ることができます。\n\n## Railsの「コントローラーの名前空間」\n\n上記の話とは別にRailsには「コントローラーの名前空間」というものがあります。実は先程でてきた\"/admin/users/new\"は\"contfig/routes.rb\"でどうなるかと言うと、`rails\ngenerate controller admin/users new`と実行して作ってみるとわかりますが、\n\n```\n\n Rails.application.routes.draw do\n # ...\n namespace :admin do\n get 'users/new'\n end\n # ..\n end\n \n```\n\nといった形になります(ほかに`create`等もあれば、`resources`に書き替えても言いでしょう)。この`namespace`メソッドが実現するのが「コントローラーの名前空間」です。似たような機能として、`scope`を使う方法もありますが、こちらはパスだけが変わるだけで、名前空間は作られず、モジュールもトップのままです。\n\n## 最後の質問への回答について\n\n最後の機能のservice一覧についてです。\n\n`Service`モデル(サービス)と`Mechanism`モデル(機能)があるという話でいいでしょうか?そして、機能によって提供するサービスが異なる、つまり、機能はサービスを`has_many`している、逆に、サービスを提供する機能は一つだけ、つまり、サービスは機能に`belongs_to`していると言う関係でしょうか?\n\n上記の前提で、機能毎にサービス一覧を出すコントローラーの話という場合は次のように[ネストしたリソース](https://railsguides.jp/routing.html#%E3%83%8D%E3%82%B9%E3%83%88%E3%81%97%E3%81%9F%E3%83%AA%E3%82%BD%E3%83%BC%E3%82%B9)を使うのがいいかと思います。\n\n```\n\n Rails.application.routes.draw do\n # ...\n resources :mechanisms do\n resources :services\n end\n # ..\n end\n \n```\n\n\"/mechanisms/:mechanism_id/services\"と言うパスで`ServicesController`コントローラーを呼び出します。これは名前空間ではないので、`Mechanisms::ServicesController`\n**にはならない** ことに注意してください。\n\nコントローラーの話ではなく、単にライブラリ的なクラスやモジュールを作るという話であれば、名前空間をどうするかは自由です。作っても良いですし、作らなくても良いです。ただ、将来その部分をgemとして独立したライブラリにするなどの予定であれば、その時のライブラリ名になるであろう名前のモジュールをトップにおいて名前空間を分けた方がいいでしょう。ほかにも、関連する物毎にまとまっていれば、どこにあるかがわかりやすくなるという場合もあります。\n\nなお、\"app\"にはモデル、コントローラー、ヘルパー等の決まった物以外は置かない方がいいです。\"app\"内のパス構成は、Railsで決められた通りであることが前提となっているため、将来のバージョンアップで予期せぬ衝突が発生する可能性があります。それらではない自作のクラスやモジュールは\"lib\"内に置く方が良いでしょう。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T01:32:22.643", "id": "86448", "last_activity_date": "2022-02-19T01:32:22.643", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7347", "parent_id": "86424", "post_type": "answer", "score": 4 } ]
86424
null
86448
{ "accepted_answer_id": null, "answer_count": 1, "body": "spresenseの録音サンプルプログラム \n「Audio>application>recorder_wav」ファイルにて、 \n10秒間録音をループさせ、連続して録音するプログラムに修正してみたのですが、 \n15回ほど録音したところで、audio libraryの初期化が出来ずエラーが発生しました。 \nエラーの原因・対策についてご教授いただければ幸いです。\n\n【追記】 \nまた、エラーが発生しない場合でも、3時間ほどでプログラムがフリーズしてしまいます。その理由などについても心当たりがあればご教授いただけないでしょうか?\n\n```\n\n initialization Audio Library\n up_assert: Assertion failed at file:dma_controller/audio_dma_drv.cpp line: 975 task: capture0\n up_registerdump: R0: 00000001 0d06ed1c 000000e0 0d06f5b4 0d06ed1c 0d093b70 0d06f56c 00000000\n up_registerdump: R8: 0d04ea24 000003cf 0d08b720 00000000 00000000 0d093b70 0d0398f1 0d039fbc\n up_registerdump: xPSR: 61000000 BASEPRI: 000000e0 CONTROL: 00000004\n up_registerdump: EXC_RETURN: ffffffe9\n up_dumpstate: sp: 0d093b70\n up_dumpstate: IRQ stack:\n up_dumpstate: base: 0d06a988\n up_dumpstate: size: 00000800\n up_dumpstate: used: 000000f8\n up_dumpstate: User stack:\n up_dumpstate: base: 0d093c58\n up_dumpstate: size: 00000800\n up_dumpstate: used: 00000284\n up_stackdump: 0d093b60: 0d093b70 0d06f56c 0d093c58 0d039a2b 000000e0 00000004 00000000 00000000\n up_stackdump: 0d093b80: 0d093b70 0d0398f1 0d039fbc 0d02fbcf 0d070180 0d0bbc70 00000000 00000000\n up_stackdump: 0d093ba0: 00000000 00000000 00000000 00000000 00000000 0d01f4bd 00000001 0d0075cd\n up_stackdump: 0d093bc0: 0d0bbc70 0d007209 0d0674a0 00000001 0d0914c0 0d00724f 0d0914c0 0d006c75\n up_stackdump: 0d093be0: 0d08ea20 0d02fbc3 000fd400 0100604d 00000000 000fe7d8 0d093c00 0d00653b\n up_stackdump: 0d093c00: 00000000 000d0000 0d04f2dc 0d067720 0d079d44 0d0914c0 0d08ea20 0d079d30\n up_stackdump: 0d093c20: 0d079d44 0d006fd7 000fd400 000fe7d8 0d08b720 0d007025 0d007003 0d02f003\n up_stackdump: 0d093c40: 00000000 00000000 00000000 00000000 00000000 00000000 00028010 80000820\n up_taskdump: Idle Task: PID=0 Stack Used=468 of 1024\n up_taskdump: hpwork: PID=1 Stack Used=596 of 2008\n up_taskdump: lpwork: PID=2 Stack Used=332 of 2008\n up_taskdump: lpwork: PID=3 Stack Used=332 of 2008\n up_taskdump: lpwork: PID=4 Stack Used=332 of 2008\n up_taskdump: cxd56_pm_task: PID=6 Stack Used=400 of 976\n up_taskdump: gnss_receiver: PID=7 Stack Used=284 of 976\n up_taskdump: init: PID=8 Stack Used=3076 of 8152\n up_taskdump: alt1250: PID=9 Stack Used=852 of 1992\n up_taskdump: lteevt_task: PID=10 Stack Used=628 of 2000\n up_taskdump: altcom_recvthread: PID=11 Stack Used=588 of 2048\n up_taskdump: audio_manager: PID=620 Stack Used=716 of 2048\n up_taskdump: media_player0: PID=621 Stack Used=348 of 3072\n up_taskdump: media_player1: PID=622 Stack Used=348 of 3072\n up_taskdump: out_mixer: PID=623 Stack Used=340 of 3072\n up_taskdump: renderer0: PID=624 Stack Used=340 of 2048\n up_taskdump: renderer1: PID=625 Stack Used=340 of 2048\n up_taskdump: front_end: PID=626 Stack Used=500 of 2048\n up_taskdump: media_recorder: PID=627 Stack Used=332 of 2048\n up_taskdump: capture0: PID=628 Stack Used=700 of 2048\n \n initialization Audio Library\n up_assert: Assertion failed at file:dma_controller/audio_dma_drv.cpp line: 975 task: capture0\n up_registerdump: R0: 00000001 0d06ed1c 000000e0 0d06f5b4 0d06ed1c 0d093b70 0d06f56c 00000000\n up_registerdump: R8: 0d04ea24 000003cf 0d08b720 00000000 00000000 0d093b70 0d0398f1 0d039fbc\n up_registerdump: xPSR: 61000000 BASEPRI: 000000e0 CONTROL: 00000004\n up_registerdump: EXC_RETURN: ffffffe9\n up_dumpstate: sp: 0d093b70\n up_dumpstate: IRQ stack:\n up_dumpstate: base: 0d06a988\n up_dumpstate: size: 00000800\n up_dumpstate: used: 000000f8\n up_dumpstate: User stack:\n up_dumpstate: base: 0d093c58\n up_dumpstate: size: 00000800\n up_dumpstate: used: 00000284\n up_stackdump: 0d093b60: 0d093b70 0d06f56c 0d093c58 0d039a2b 000000e0 00000004 00000000 00000000\n up_stackdump: 0d093b80: 0d093b70 0d0398f1 0d039fbc 0d02fbcf 0d070180 0d0bbc70 00000000 00000000\n up_stackdump: 0d093ba0: 00000000 00000000 00000000 00000000 00000000 0d01f4bd 00000001 0d0075cd\n up_stackdump: 0d093bc0: 0d0bbc70 0d007209 0d0674a0 00000001 0d0914c0 0d00724f 0d0914c0 0d006c75\n up_stackdump: 0d093be0: 0d08ea20 0d02fbc3 000fd400 0100604d 00000000 000fe7d8 0d093c00 0d00653b\n up_stackdump: 0d093c00: 00000000 000d0000 0d04f2dc 0d067720 0d079d44 0d0914c0 0d08ea20 0d079d30\n up_stackdump: 0d093c20: 0d079d44 0d006fd7 000fd400 000fe7d8 0d08b720 0d007025 0d007003 0d02f003\n up_stackdump: 0d093c40: 00000000 00000000 00000000 00000000 00000000 00000000 00028010 80000820\n up_taskdump: Idle Task: PID=0 Stack Used=468 of 1024\n up_taskdump: hpwork: PID=1 Stack Used=596 of 2008\n up_taskdump: lpwork: PID=2 Stack Used=332 of 2008\n up_taskdump: lpwork: PID=3 Stack Used=332 of 2008\n up_taskdump: lpwork: PID=4 Stack Used=332 of 2008\n up_taskdump: cxd56_pm_task: PID=6 Stack Used=400 of 976\n up_taskdump: gnss_receiver: PID=7 Stack Used=284 of 976\n up_taskdump: init: PID=8 Stack Used=3076 of 8152\n up_taskdump: alt1250: PID=9 Stack Used=852 of 1992\n up_taskdump: lteevt_task: PID=10 Stack Used=628 of 2000\n up_taskdump: altcom_recvthread: PID=11 Stack Used=588 of 2048\n up_taskdump: audio_manager: PID=620 Stack Used=716 of 2048\n up_taskdump: media_player0: PID=621 Stack Used=348 of 3072\n up_taskdump: media_player1: PID=622 Stack Used=348 of 3072\n up_taskdump: out_mixer: PID=623 Stack Used=340 of 3072\n up_taskdump: renderer0: PID=624 Stack Used=340 of 2048\n up_taskdump: renderer1: PID=625 Stack Used=340 of 2048\n up_taskdump: front_end: PID=626 Stack Used=500 of 2048\n up_taskdump: media_recorder: PID=627 Stack Used=332 of 2048\n up_taskdump: capture0: PID=628 Stack Used=700 of 2048\n initialization Audio Library\n up_assert: Assertion failed at file:dma_controller/audio_dma_drv.cpp line: 975 task: capture0\n up_registerdump: R0: 00000001 0d06ed1c 000000e0 0d06f5b4 0d06ed1c 0d093b70 0d06f56c 00000000\n up_registerdump: R8: 0d04ea24 000003cf 0d08b720 00000000 00000000 0d093b70 0d0398f1 0d039fbc\n up_registerdump: xPSR: 61000000 BASEPRI: 000000e0 CONTROL: 00000004\n up_registerdump: EXC_RETURN: ffffffe9\n up_dumpstate: sp: 0d093b70\n up_dumpstate: IRQ stack:\n up_dumpstate: base: 0d06a988\n up_dumpstate: size: 00000800\n up_dumpstate: used: 000000f8\n up_dumpstate: User stack:\n up_dumpstate: base: 0d093c58\n up_dumpstate: size: 00000800\n up_dumpstate: used: 00000284\n up_stackdump: 0d093b60: 0d093b70 0d06f56c 0d093c58 0d039a2b 000000e0 00000004 00000000 00000000\n up_stackdump: 0d093b80: 0d093b70 0d0398f1 0d039fbc 0d02fbcf 0d070180 0d0bbc70 00000000 00000000\n up_stackdump: 0d093ba0: 00000000 00000000 00000000 00000000 00000000 0d01f4bd 00000001 0d0075cd\n up_stackdump: 0d093bc0: 0d0bbc70 0d007209 0d0674a0 00000001 0d0914c0 0d00724f 0d0914c0 0d006c75\n up_stackdump: 0d093be0: 0d08ea20 0d02fbc3 000fd400 0100604d 00000000 000fe7d8 0d093c00 0d00653b\n up_stackdump: 0d093c00: 00000000 000d0000 0d04f2dc 0d067720 0d079d44 0d0914c0 0d08ea20 0d079d30\n up_stackdump: 0d093c20: 0d079d44 0d006fd7 000fd400 000fe7d8 0d08b720 0d007025 0d007003 0d02f003\n up_stackdump: 0d093c40: 00000000 00000000 00000000 00000000 00000000 00000000 00028010 80000820\n up_taskdump: Idle Task: PID=0 Stack Used=468 of 1024\n up_taskdump: hpwork: PID=1 Stack Used=596 of 2008\n up_taskdump: lpwork: PID=2 Stack Used=332 of 2008\n up_taskdump: lpwork: PID=3 Stack Used=332 of 2008\n up_taskdump: lpwork: PID=4 Stack Used=332 of 2008\n up_taskdump: cxd56_pm_task: PID=6 Stack Used=400 of 976\n up_taskdump: gnss_receiver: PID=7 Stack Used=284 of 976\n up_taskdump: init: PID=8 Stack Used=3076 of 8152\n up_taskdump: alt1250: PID=9 Stack Used=852 of 1992\n up_taskdump: lteevt_task: PID=10 Stack Used=628 of 2000\n up_taskdump: altcom_recvthread: PID=11 Stack Used=588 of 2048\n up_taskdump: audio_manager: PID=620 Stack Used=716 of 2048\n up_taskdump: media_player0: PID=621 Stack Used=348 of 3072\n up_taskdump: media_player1: PID=622 Stack Used=348 of 3072\n up_taskdump: out_mixer: PID=623 Stack Used=340 of 3072\n up_taskdump: renderer0: PID=624 Stack Used=340 of 2048\n up_taskdump: renderer1: PID=625 Stack Used=340 of 2048\n up_taskdump: front_end: PID=626 Stack Used=500 of 2048\n up_taskdump: media_recorder: PID=627 Stack Used=332 of 2048\n up_taskdump: capture0: PID=628 Stack Used=700 of 2048\n initialization Audio Library\n up_assert: Assertion failed at file:dma_controller/audio_dma_drv.cpp line: 975 task: capture0\n up_registerdump: R0: 00000001 0d06ed1c 000000e0 0d06f5b4 0d06ed1c 0d093b70 0d06f56c 00000000\n up_registerdump: R8: 0d04ea24 000003cf 0d08b720 00000000 00000000 0d093b70 0d0398f1 0d039fbc\n up_registerdump: xPSR: 61000000 BASEPRI: 000000e0 CONTROL: 00000004\n up_registerdump: EXC_RETURN: ffffffe9\n up_dumpstate: sp: 0d093b70\n up_dumpstate: IRQ stack:\n up_dumpstate: base: 0d06a988\n up_dumpstate: size: 00000800\n up_dumpstate: used: 000000f8\n up_dumpstate: User stack:\n up_dumpstate: base: 0d093c58\n up_dumpstate: size: 00000800\n up_dumpstate: used: 00000284\n up_stackdump: 0d093b60: 0d093b70 0d06f56c 0d093c58 0d039a2b 000000e0 00000004 00000000 00000000\n up_stackdump: 0d093b80: 0d093b70 0d0398f1 0d039fbc 0d02fbcf 0d070180 0d0bbc70 00000000 00000000\n up_stackdump: 0d093ba0: 00000000 00000000 00000000 00000000 00000000 0d01f4bd 00000001 0d0075cd\n up_stackdump: 0d093bc0: 0d0bbc70 0d007209 0d0674a0 00000001 0d0914c0 0d00724f 0d0914c0 0d006c75\n up_stackdump: 0d093be0: 0d08ea20 0d02fbc3 000fd400 0100604d 00000000 000fe7d8 0d093c00 0d00653b\n up_stackdump: 0d093c00: 00000000 000d0000 0d04f2dc 0d067720 0d079d44 0d0914c0 0d08ea20 0d079d30\n up_stackdump: 0d093c20: 0d079d44 0d006fd7 000fd400 000fe7d8 0d08b720 0d007025 0d007003 0d02f003\n up_stackdump: 0d093c40: 00000000 00000000 00000000 00000000 00000000 00000000 00028010 80000820\n up_taskdump: Idle Task: PID=0 Stack Used=468 of 1024\n up_taskdump: hpwork: PID=1 Stack Used=596 of 2008\n up_taskdump: lpwork: PID=2 Stack Used=332 of 2008\n up_taskdump: lpwork: PID=3 Stack Used=332 of 2008\n up_taskdump: lpwork: PID=4 Stack Used=332 of 2008\n up_taskdump: cxd56_pm_task: PID=6 Stack Used=400 of 976\n up_taskdump: gnss_receiver: PID=7 Stack Used=284 of 976\n up_taskdump: init: PID=8 Stack Used=3076 of 8152\n up_taskdump: alt1250: PID=9 Stack Used=852 of 1992\n up_taskdump: lteevt_task: PID=10 Stack Used=628 of 2000\n up_taskdump: altcom_recvthread: PID=11 Stack Used=588 of 2048\n up_taskdump: audio_manager: PID=620 Stack Used=716 of 2048\n up_taskdump: media_player0: PID=621 Stack Used=348 of 3072\n up_taskdump: media_player1: PID=622 Stack Used=348 of 3072\n up_taskdump: out_mixer: PID=623 Stack Used=340 of 3072\n up_taskdump: renderer0: PID=624 Stack Used=340 of 2048\n up_taskdump: renderer1: PID=625 Stack Used=340 of 2048\n up_taskdump: front_end: PID=626 Stack Used=500 of 2048\n up_taskdump: media_recorder: PID=627 Stack Used=332 of 2048\n up_taskdump: capture0: PID=628 Stack Used=700 of 2048\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T00:17:47.217", "favorite_count": 0, "id": "86425", "last_activity_date": "2022-04-11T00:54:51.647", "last_edit_date": "2022-02-20T23:40:14.040", "last_editor_user_id": "48658", "owner_user_id": "48658", "post_type": "question", "score": 0, "tags": [ "spresense" ], "title": "spresense連続録音での初期化エラーについて", "view_count": 193 }
[ { "body": "最新版の v2.5.0で、\n\n<https://developer.sony.com/develop/spresense/docs/release_arduino_ja.html#_v2_5_0_20220401>\n\nで、下記のこのようにコードを変更して動作させたところ、特に問題なく連続動作していました。\n\n`exitRecording` のラベル中の `exit` を `setup()` に置き換える。 \n※`SDClass` には、`end()` がないので。\n\n```\n\n puts(\"End Recording\");\n \n ErrEnd = false;\n setup();\n // exit(1);\n \n```\n\nご参考まで。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-04-11T00:29:12.043", "id": "88255", "last_activity_date": "2022-04-11T00:54:51.647", "last_edit_date": "2022-04-11T00:54:51.647", "last_editor_user_id": "32281", "owner_user_id": "32281", "parent_id": "86425", "post_type": "answer", "score": 0 } ]
86425
null
88255
{ "accepted_answer_id": "86436", "answer_count": 2, "body": "Swift5で、ある特定の処理の終了後に次の処理を行いたいです。 \n以下の例だと、myFunction内部のprint(\"A\")を実行したあとに、print(\"success\")を実行しています。\n\n```\n\n import Foundation\n \n @objc func myFunction(completion:@escaping (Bool) -> () ) {\n print(\"A\")\n completion(true)\n }\n \n func testA_Func()\n {\n myFunction { (status) in\n if status {\n print(\"success\")\n }\n }\n }\n \n testA_Func()\n \n```\n\n以下のように、myFunctionに引数を追加したところtestFuncAから呼び出す方法がわかりません。\n\n```\n\n import Foundation\n \n @objc func myFunction(argA:String,argB:String,completion:@escaping (Bool) -> () ) {\n print(\"A\")\n print(\"argA = \" + argA)\n print(\"argB = \" + argB)\n completion(true)\n }\n \n func testA_Func()\n {\n let argAstring = \"testA\"\n let argBstring = \"testB\"\n myFunction { (argAstring,argBstring,status) in\n if status {\n print(\"success\")\n }\n }\n }\n \n testA_Func()\n \n```\n\nどのように、testA_Func()内部からmyFunctionに引数を渡してあげれば良いのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T04:35:54.523", "favorite_count": 0, "id": "86430", "last_activity_date": "2022-02-18T11:21:52.153", "last_edit_date": "2022-02-18T04:47:50.577", "last_editor_user_id": "3060", "owner_user_id": "36446", "post_type": "question", "score": 0, "tags": [ "swift", "swift5" ], "title": "completion:@escaping (Bool) -> ()と他の引数を組み合わせる場合", "view_count": 224 }
[ { "body": "今手元に開発環境がないので動作チェックしていませんが、下記のとおりでどうでしょうか。\n\n```\n\n myFunction(argA: argAstring, argB: argBstring) { (status) in\n if status {\n print(\"success\")\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T04:48:00.007", "id": "86431", "last_activity_date": "2022-02-18T04:48:00.007", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8077", "parent_id": "86430", "post_type": "answer", "score": 1 }, { "body": "質問文を拝見した範囲で推察したところ、どうも質問者さんは、Swiftの **Trailing Closure** をご存じないのではないかと見受けられます。\n\n[The Swift Programming Language - Closures](https://docs.swift.org/swift-\nbook/LanguageGuide/Closures.html)\n\nネット検索すれば、日本語のTrailing Closuresに関する情報が複数見つかりますので、それらで学習するといいでしょう。\n\nTrailing Closureは、SwiftのSugar\nSyntax(糖衣構文)のひとつで、文法通りに記述すると、文字数が多くなったり、プログラマ(人間)が読解しにくくなるコードを、簡潔にかつ理解しやすいように置き換えた構文です。 \nTrailing Closureを使わずに、関数`myFunction`(後者の、引数が3つある方)を呼び出すコードを書くと、こうなります。\n\n```\n\n myFunction(argA: argAstring, argB: argBstring, completion: { (status) in\n if status {\n print(\"success\")\n }\n })\n \n```\n\n関数の引数をリストするかっこ(())のうちの閉じかっこ())が、遠く離れたところに位置するので、みおとしがちになりますね。引数の中の、後置するクロージャは、かっこの後ろに書くようにしましょう、そうすれば閉じかっこを忘れずにすむというのが、Tailing\nClosureです。 \nここまで学習すれば、正しい関数の呼び出し方は、別回答者さんの示したコードになることが、理解していただけると思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T10:45:17.550", "id": "86436", "last_activity_date": "2022-02-18T11:21:52.153", "last_edit_date": "2022-02-18T11:21:52.153", "last_editor_user_id": "18540", "owner_user_id": "18540", "parent_id": "86430", "post_type": "answer", "score": 2 } ]
86430
86436
86436
{ "accepted_answer_id": "86487", "answer_count": 2, "body": "※[他質問サイト](https://teratail.com/questions/2qxw4a2ewuhk5b)でも同様の質問をしています。解決した場合はそちらも更新します。よろしくお願いします。\n\n### 前提・実現したいこと\n\n投稿された質問(post)に対して回答したコメント(comment)に非同期通信でいいね(good)を押す機能を実装したいです。\n\n空のハートマークを押すと赤いハートに切り替わり、赤いハートを押すと空のハートマークに切り替わります。\n\nDBは以下のように設計しています。 \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-02-18/825a1978-a1e5-412e-b7cd-769208dc5add.png)\n\n### 発生している問題・エラーメッセージ\n\nいいねを押した後にリロードすると空のハートマークになってしまいます。 \nそのまま赤いハートに残っていて欲しいです。\n\n**①いいね(空のハート)を押す前** \nテーブルは空の状態です。 \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-02-18/94138b0c-19cf-465d-b891-cd96b1e88eb9.png)\n\n**②いいねを押した後** \nテーブルに作成され、赤いハートに切り替わります。 \nid:20, comment_id: 8, user_id: 1 \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-02-18/8a4d571a-d713-4713-ad21-fe4702178552.png)\n\n**③リロードした後(問題がある点)** \nテーブルには作成されたままですが、空のハートになってしまいます。 \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-02-18/5e16fdc0-769c-404e-b14e-45553d488ebc.png)\n\n**④もう一度いいねを押す** \nテーブルの中身は変わらず、赤いハートに切り替わります。 \nid:20, comment_id: 8, user_id: 1 \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-02-18/5b055312-10b2-4aa9-be69-2a885fc78fcb.png)\n\n**⑤赤いハートを押す** \nテーブルの中身は空になり、空のハートに切り替わります。 \n![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-02-18/38ba0425-2d97-4204-bd12-a19d6db42d48.png)\n\n### 該当のソースコード\n\nビュー関連\n\n```\n\n app/views/goods/_good.html.erb\n \n <% unless @comment.good_user(@current_user.id).blank? %>\n <%= link_to post_comment_good_path(post_id: @post.id, id: comment.goods[0].id), method: :delete, remote: true do %>\n <div class=\"vertical_good\">\n <%= image_tag \"icon_red_heart.png\", size: '20x20' %>\n </div>\n <% end %>\n <% else %>\n <%= link_to post_comment_goods_path(@post, comment), method: :post, remote: true do %>\n <div class=\"vertical_good\">\n <%= image_tag \"icon_heart.png\", size: '20x20' %>\n </div>\n <% end %>\n <% end %>\n \n```\n\n```\n\n app/views/comments/_comment.html.erb\n \n <div class=\"p-comment__item\">\n <p><%= simple_format(comment.comment) %></p>\n <div class=\"p-comment__bottomLine\">\n <div id=\"goods_buttons<%= comment.id %>\">\n <%= render partial: 'goods/good', locals: { post: @post, comment: comment } %>\n </div>\n <span><%= comment.created_at.to_s(:datetime_jp) %></span>\n <span><%= link_to '削除', post_comment_path(@post, comment), method: :delete, data: { confirm: '削除してよろしいですか?' } %></span>\n </div>\n </div>\n \n```\n\n```\n\n app/views/posts/show.html.erb\n \n (省略)\n \n <div class=\"p-comment__list\">\n <div class=\"p-comment_listTitle\">コメント</div>\n <%= render @post.comments %>\n </div>\n \n <%= render partial: 'comments/form', locals: { comment: @comment } %>\n \n```\n\n```\n\n app/views/goods/create.js.erb\n \n $('#goods_buttons<%= @comment.id %>').html(\"<%= j(render partial: 'goods/good', locals: {comment: @comment}) %>\");\n \n```\n\n```\n\n app/views/goods/destroy.js.erb\n \n $('#goods_buttons<%= @comment.id %>').html(\"<%= j(render partial: 'goods/good', locals: {comment: @comment}) %>\");\n \n```\n\nコントローラ\n\n```\n\n goods_controller.rb\n \n class GoodsController < ApplicationController\n before_action :set_comment, only: %i[create destroy]\n \n def create\n @good = Good.create(user_id: current_user.id, comment_id: @comment.id)\n end\n \n def destroy\n good = Good.find_by(user_id: current_user.id, comment_id: @comment.id)\n good.destroy\n end\n \n private\n \n def set_comment\n @post = Post.find(params[:post_id])\n @comment = Comment.find(params[:comment_id])\n end\n end\n \n```\n\nモデル関連\n\n```\n\n comment.rb\n \n class Comment < ApplicationRecord\n belongs_to :post\n has_many :goods, dependent: :destroy\n \n validates :comment, presence: true, length: { maximum: 1000 }\n \n def good_user(user_id)\n goods.find_by(user_id: user_id)\n end\n end\n \n```\n\n```\n\n good.rb\n \n class Good < ApplicationRecord\n belongs_to :comment\n belongs_to :user\n \n validates_uniqueness_of :comment_id, scope: :user_id\n end\n \n```\n\n```\n\n user.rb\n \n class User < ApplicationRecord\n (省略)\n has_many :favorites\n has_many :goods\n \n (省略)\n end\n \n```\n\n### 自分で調べたことや試したこと\n\nテーブルには保存されているので、comment.rbのgood_user(user_id)メソッドがおかしいかと思いましたが、特に間違いは見つけられず \nそのメソッドを使用している_good.html.erbに問題があるのかと模索しましたが、わかりませんでした。\n\nエラーメッセージが表示されているわけではないため原因の検討がつかず、知恵をお借りしたいです。\n\n### 使っているツールのバージョンなど補足情報\n\nruby: 3.0.2 \nrails: 6.0.4 \njquery-rails: 4.4.0", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T10:05:05.290", "favorite_count": 0, "id": "86435", "last_activity_date": "2022-03-09T02:31:31.207", "last_edit_date": "2022-02-21T05:03:16.033", "last_editor_user_id": "3060", "owner_user_id": "51475", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "ajax" ], "title": "テーブルに保存されているのに、リロードするとビューがリセットされる", "view_count": 206 }
[ { "body": "`app/views/goods/_good.html.erb`にある`<% unless\[email protected]_user(@current_user.id).blank?\n%>`ですが、`@comment`や`@current_user`の中身を確認したほうがよいでしょう。`@comment`のidが8で`@current_user.id`が1なら動作しているはずですので、どちらかが期待通りになっていない可能性があります。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T14:34:29.057", "id": "86440", "last_activity_date": "2022-02-18T14:34:29.057", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "442", "parent_id": "86435", "post_type": "answer", "score": 0 }, { "body": "[他の質問サイト](https://teratail.com/questions/2qxw4a2ewuhk5b#reply-\nar3strfbg4weoz)にて解決しました。ご協力ありがとうございました。\n\n<追記> \n`unless comment.good_user(@current_user.id).blank?`と`link_to\npost_comment_good_path(post_id: @post.id, comment_id: comment.id, id:\n@current_user), method: :delete, remote: true do`に修正したところ実装できました。 \n条件分岐の読みにくさは別途修正します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T02:37:03.190", "id": "86487", "last_activity_date": "2022-03-09T02:31:31.207", "last_edit_date": "2022-03-09T02:31:31.207", "last_editor_user_id": "51475", "owner_user_id": "51475", "parent_id": "86435", "post_type": "answer", "score": 0 } ]
86435
86487
86440
{ "accepted_answer_id": null, "answer_count": 0, "body": "以前: version 2019.3 \nアップデート: version 2021.2\n\n以前はunity WebGLで普通にビルドできていましたが \nunityのバージョンアップを行うと下記エラーが出てくるようになりました。\n\nUnicodeDecodeError: 'cp932' codec can't decode byte 0x97 in position 70264:\nillegal multibyte sequence \nUnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)\n\n検索をかけてみてもpythonに関すること等や文字コードの違い? \nのような内容記事があったのですが \n具体的にどう直せばよいのかわからず。 \n教えて頂けると有難いです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-18T20:25:28.087", "favorite_count": 0, "id": "86445", "last_activity_date": "2022-02-18T20:25:28.087", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51502", "post_type": "question", "score": 0, "tags": [ "unity3d", "webgl" ], "title": "Unityをバージョンアップしたら webGLビルドできなくなってしまいました。", "view_count": 271 }
[]
86445
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "ロジスティック回帰分析の勉強をしているのですが、下記についてアドバイスいただけることがありましたらお願いできますと幸いです。\n\n↓ ↓\n\nロジスティック回帰分析の説明変数で、一般的に、発生(1)・非発生(0)\nに対して説明変数が線形的に変化する(例えば煙草をたくさん喫うほど肺がんが発生しやすい等)と思いますが、説明変数が発生(1)に対して非線形に変化する場合(例えば、年収と軽自動車購入・非購入など、年収100万円では軽自動車は買わないが、年収1000万円でも軽自動車は買わず、年収500万円で最も軽自動車購入の推定値が1に近づくような場合)は、単純にロジスティック回帰分析を実施し結果得られる標準偏回帰係数には意味があるのでしょうか?そして、その場合の標準偏回帰係数の解釈の仕方などあるのでしょうか? \nまた、発生・非発生の目的変数に対して、複数の説明変数が、上記のように非線形の場合、最も推定値が1に近づく説明変数の値を探索(年収がどれくらいなら最も軽自動車を購入する確率が高いか)したり、標準偏回帰係数のような各説明変数に重みづけを与えたりする方法はあるのでしょうか・・?\n\n以上、お気づきの点がある方いらっしゃいましたら、コメントいただけますと幸いです。 \nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T01:09:23.117", "favorite_count": 0, "id": "86447", "last_activity_date": "2022-02-19T01:09:23.117", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "47038", "post_type": "question", "score": 2, "tags": [ "機械学習" ], "title": "ロジスティック回帰分析の考え方について", "view_count": 57 }
[]
86447
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "scalaの開発環境を整え、以下のコードを実行したところ、 \nエラーが出てうまく実行することが出来ません。 \nどうすれば、うまく起動できるのでしょうか?\n\n```\n\n object Hello {\n def main(args: Array[String]): Unit = {\n println(\"Hello, World!\")\n }\n }\n \n```\n\n```\n\n \"C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\bin\\java.exe\" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51940,suspend=y,server=n -javaagent:C:\\Users\\Owner\\AppData\\Local\\JetBrains\\IdeaIC2021.3\\captureAgent\\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath \"C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\charsets.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\access-bridge-64.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\cldrdata.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\dnsns.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\jaccess.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\localedata.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\nashorn.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\sunec.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\sunjce_provider.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\sunmscapi.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\sunpkcs11.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\ext\\zipfs.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\jce.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\jfr.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\jsse.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\management-agent.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\resources.jar;C:\\Program Files\\Eclipse Adoptium\\jdk-8.0.322.6-hotspot\\jre\\lib\\rt.jar;C:\\Users\\Owner\\AppData\\Local\\Coursier\\cache\\v1\\https\\repo1.maven.org\\maven2\\org\\scala-lang\\scala-library\\2.13.8\\scala-library-2.13.8.jar;C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2021.3.2\\lib\\idea_rt.jar\" Hello\n ターゲット VM に接続しました。アドレス : '127.0.0.1:51940'、トランスポート: 'ソケット'\n エラー: メイン・クラスHelloが見つからなかったかロードできませんでした\n ターゲット VM から切断されました。アドレス: '127.0.0.1:51940'、トランスポート: 'ソケット'\n \n プロセスは終了コード 1 で終了しました\n \n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T08:05:53.720", "favorite_count": 0, "id": "86449", "last_activity_date": "2022-02-19T10:57:48.610", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "42741", "post_type": "question", "score": 0, "tags": [ "scala" ], "title": "scalaでうまくコードが実行できない。", "view_count": 115 }
[ { "body": "main/scalaのディレクトリ内にscalaのコードを入れていなかったことが問題だったようです。 \nmain/scala内にscalaのコードを入れるとうまく実行できました。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/jH0wL.png)](https://i.stack.imgur.com/jH0wL.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T10:57:48.610", "id": "86451", "last_activity_date": "2022-02-19T10:57:48.610", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "42741", "parent_id": "86449", "post_type": "answer", "score": 2 } ]
86449
null
86451
{ "accepted_answer_id": null, "answer_count": 2, "body": "背景:\n\nラズパイにUbuntu18.04をインストールしてその中にdockerでwordpressをインストールしました。\n\ndockerでwordpressをインストールした参考サイト \n<https://docs.docker.com/samples/wordpress/>\n\nインストールして家のwifiではうまくつながってます、cssもちゃんとロードできています。\n\n次にNginxでドメインとリンクしました、しかしドメインから訪問する時に下記エラーが出て来ました:\n\n```\n\n /wp-admin/install.php?step=1:8 GET http://localhost:8111/wp-includes/css/dashicons.min.css?ver=5.9 net::ERR_CONNECTION_REFUSED\n /wp-admin/install.php?step=1:9 GET http://localhost:8111/wp-includes/css/buttons.min.css?ver=5.9 net::ERR_CONNECTION_REFUSED\n \n```\n\nつまり`localhost`を探してると分かります。\n\nNginxの設定が原因かもしれません。 \n簡単な設定ですが、下記になります:\n\n```\n\n server {\n listen 80;\n listen [::]:80;\n \n server_name my.domain.com;\n \n location / {\n proxy_pass http://localhost:8111;\n }\n }\n \n \n```\n\nどうしたら直せるでしょうか。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T10:43:24.333", "favorite_count": 0, "id": "86450", "last_activity_date": "2022-02-24T11:11:23.867", "last_edit_date": "2022-02-19T11:10:14.503", "last_editor_user_id": "41314", "owner_user_id": "41314", "post_type": "question", "score": 0, "tags": [ "ubuntu", "docker", "wordpress", "nginx" ], "title": "dockerでインストールしたwordpressがドメインで訪問した時にcssが読み込めない", "view_count": 168 }
[ { "body": "以下の記述で localhost を指定しているのが原因に見えます。\n\n>\n```\n\n> location / {\n> proxy_pass http://localhost:8111;\n> }\n> \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T11:10:48.260", "id": "86452", "last_activity_date": "2022-02-19T11:10:48.260", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "86450", "post_type": "answer", "score": 0 }, { "body": "質問文のメッセージより,インストールページにいると仮定します.\n\nnginxで`proxy_pass`を使用する場合,別回答でも指摘されている通り, **proxy_passで使用したホスト名でリクエストが上書き**\nされます.\n\nただしく元のリクエストからHostヘッダーを引き続きたい場合,`proxy_set_header`で本来のリクエストヘッダーを引き渡します.\n\n```\n\n proxy_set_header Host $proxy_host;\n \n```\n\n * [リバースプロキシ化したnginxでHostヘッダを素通しする設定 -- ぺけみさお](https://www.xmisao.com/2013/10/17/nginx-proxy-host-header.html)\n * [Module ngx_http_proxy_module](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header)\n\nなお,`wordpress:latest`はApache HTTPDでPHPを動作させていますが,多くの場合nginxと併用する際はphp-\nfpmが好まれます(お好みで) .", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T15:30:28.193", "id": "86462", "last_activity_date": "2022-02-19T15:37:42.280", "last_edit_date": "2022-02-19T15:37:42.280", "last_editor_user_id": "2376", "owner_user_id": "2376", "parent_id": "86450", "post_type": "answer", "score": 1 } ]
86450
null
86462
{ "accepted_answer_id": null, "answer_count": 1, "body": "spresenseのLTEボードを用いて通信をしていると、 \n時々、\n\n```\n\n ERROR:LTEClient:137 connect() error : 113\n \n```\n\nのエラーが発生し、プログラムが停止してします。 \n当エラーへの対応はどうしたらよいのかご教授いただければ幸いです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T11:31:14.503", "favorite_count": 0, "id": "86453", "last_activity_date": "2022-03-04T01:09:10.470", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "48658", "post_type": "question", "score": 0, "tags": [ "spresense" ], "title": "spresenseのLTE通信エラー時の対応について", "view_count": 261 }
[ { "body": "`ECONNABORTED` は `\"Software caused connection abort\"`\nなのでIPスタックから接続を中断されているようです。 \nなので、 `lteAccess.getStatus();` を使って状態を確認し、 `LTE_ERROR` ならもう一度\n`lteAccess.attach` を実施するとよいと思います。\n\nまた、古いファームウェアだとModemリセットが発生するようなので、同様のエラーが出てくるのかなと思います。 \n以下のページを参照してファームウェアアップデートを行ってみるといかがでしょうか? \n[Updateツール(RK_02_01_01_10_41_15 ->\nRK_02_01_02_10_108_54)](https://developer.sony.com/ja/develop/spresense/downloads/lte_downloads/lte_fwuptool/)\n\n参考 \n[SDK Ver2.3.0 Example\nlte_awsiotを長時間実行したら、エラーとリセットが発生する](https://ja.stackoverflow.com/questions/82861/sdk-\nver2-3-0-example-lte-\nawsiot%e3%82%92%e9%95%b7%e6%99%82%e9%96%93%e5%ae%9f%e8%a1%8c%e3%81%97%e3%81%9f%e3%82%89-%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%a8%e3%83%aa%e3%82%bb%e3%83%83%e3%83%88%e3%81%8c%e7%99%ba%e7%94%9f%e3%81%99%e3%82%8b)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-03-04T01:09:10.470", "id": "86678", "last_activity_date": "2022-03-04T01:09:10.470", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32034", "parent_id": "86453", "post_type": "answer", "score": 0 } ]
86453
null
86678
{ "accepted_answer_id": null, "answer_count": 1, "body": "win32apiのcreateProcessとcreatePipeを使って子プロセスとやり取りしたいと思っています。 \nしかしサンプルコードなどをググって調べてみても複雑すぎて理解が追いつきません。 \nもうギブアップしかけています。 \ncreateProcessやcreatePipeをもっと使いやすいようにラッパークラスを用意してくれている方はいらっしゃらないでしょうか。\n\nkunifさんに教えていただいたサンプルを改造したものがこちらになります。 \n子プロセスで起動するプログラム名はchild.exeになります。\n\nエラー処理などはかなり適当です。 \nまた、子プロセスからの応答が遅いとバグってしまうようです。 \nWaitForSingleObjectなども試してみたのですがうまくいかず \nとりあえず、私の本当に使いたかったプログラム上ではSleepでごまかしています。\n\n```\n\n #include <windows.h> \n #include <tchar.h>\n #include <stdio.h> \n #include <strsafe.h>\n \n #define BUFSIZE 4096 \n \n HANDLE g_hChildStd_IN_Rd = NULL;\n HANDLE g_hChildStd_IN_Wr = NULL;\n HANDLE g_hChildStd_OUT_Rd = NULL;\n HANDLE g_hChildStd_OUT_Wr = NULL;\n \n HANDLE g_hInputFile = NULL;\n \n void CreateChildProcess(void); \n void WriteToPipe(void); \n void ReadFromPipe(void); \n void ErrorExit(PTSTR); \n \n int _tmain(int argc, TCHAR *argv[]) \n { \n SECURITY_ATTRIBUTES saAttr; \n \n printf(\"\\n->Start of parent execution.\\n\");\n \n // Set the bInheritHandle flag so pipe handles are inherited. \n \n saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); \n saAttr.bInheritHandle = TRUE; \n saAttr.lpSecurityDescriptor = NULL; \n \n // Create a pipe for the child process's STDOUT. \n \n if ( ! CreatePipe(&g_hChildStd_OUT_Rd, &g_hChildStd_OUT_Wr, &saAttr, 0) ) \n ErrorExit(TEXT(\"StdoutRd CreatePipe\")); \n \n // Ensure the read handle to the pipe for STDOUT is not inherited.\n \n if ( ! SetHandleInformation(g_hChildStd_OUT_Rd, HANDLE_FLAG_INHERIT, 0) )\n ErrorExit(TEXT(\"Stdout SetHandleInformation\")); \n \n // Create a pipe for the child process's STDIN. \n \n if (! CreatePipe(&g_hChildStd_IN_Rd, &g_hChildStd_IN_Wr, &saAttr, 0)) \n ErrorExit(TEXT(\"Stdin CreatePipe\")); \n \n // Ensure the write handle to the pipe for STDIN is not inherited. \n \n if ( ! SetHandleInformation(g_hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0) )\n ErrorExit(TEXT(\"Stdin SetHandleInformation\")); \n \n // Create the child process. \n \n CreateChildProcess();\n \n // Get a handle to an input file for the parent. \n // This example assumes a plain text file and uses string output to verify data flow. \n \n // if (argc == 1) \n // ErrorExit(TEXT(\"Please specify an input file.\\n\")); \n \n /*\n g_hInputFile = CreateFile(\n argv[1], \n GENERIC_READ, \n 0, \n NULL, \n OPEN_EXISTING, \n FILE_ATTRIBUTE_READONLY, \n NULL); \n */\n g_hInputFile = GetStdHandle(STD_INPUT_HANDLE);\n \n \n if ( g_hInputFile == INVALID_HANDLE_VALUE ) \n ErrorExit(TEXT(\"CreateFile\")); \n \n // Write to the pipe that is the standard input for a child process. \n // Data is written to the pipe's buffers, so it is not necessary to wait\n // until the child process is running before writing data.\n \n while(true)\n {\n WriteToPipe(); \n printf( \"\\n->Contents of %s written to child STDIN pipe.\\n\", argv[1]);\n \n // Read from pipe that is the standard output for child process. \n \n printf( \"\\n->Contents of child process STDOUT:\\n\\n\");\n ReadFromPipe(); \n }\n printf(\"\\n->End of parent execution.\\n\");\n \n // The remaining open handles are cleaned up when this process terminates. \n // To avoid resource leaks in a larger application, close handles explicitly. \n \n return 0; \n } \n \n void CreateChildProcess()\n // Create a child process that uses the previously created pipes for STDIN and STDOUT.\n { \n TCHAR szCmdline[]=TEXT(\"child\");\n PROCESS_INFORMATION piProcInfo; \n STARTUPINFO siStartInfo;\n BOOL bSuccess = FALSE; \n \n // Set up members of the PROCESS_INFORMATION structure. \n \n ZeroMemory( &piProcInfo, sizeof(PROCESS_INFORMATION) );\n \n // Set up members of the STARTUPINFO structure. \n // This structure specifies the STDIN and STDOUT handles for redirection.\n \n ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );\n siStartInfo.cb = sizeof(STARTUPINFO); \n siStartInfo.hStdError = g_hChildStd_OUT_Wr;\n siStartInfo.hStdOutput = g_hChildStd_OUT_Wr;\n siStartInfo.hStdInput = g_hChildStd_IN_Rd;\n siStartInfo.dwFlags |= STARTF_USESTDHANDLES;\n \n // Create the child process. \n \n bSuccess = CreateProcess(NULL, \n szCmdline, // command line \n NULL, // process security attributes \n NULL, // primary thread security attributes \n TRUE, // handles are inherited \n 0, // creation flags \n NULL, // use parent's environment \n NULL, // use parent's current directory \n &siStartInfo, // STARTUPINFO pointer \n &piProcInfo); // receives PROCESS_INFORMATION \n \n // If an error occurs, exit the application. \n if ( ! bSuccess ) \n ErrorExit(TEXT(\"CreateProcess\"));\n else \n {\n // Close handles to the child process and its primary thread.\n // Some applications might keep these handles to monitor the status\n // of the child process, for example. \n \n CloseHandle(piProcInfo.hProcess);\n CloseHandle(piProcInfo.hThread);\n \n // Close handles to the stdin and stdout pipes no longer needed by the child process.\n // If they are not explicitly closed, there is no way to recognize that the child process has ended.\n \n CloseHandle(g_hChildStd_OUT_Wr);\n CloseHandle(g_hChildStd_IN_Rd);\n }\n }\n \n void WriteToPipe(void) \n \n // Read from a file and write its contents to the pipe for the child's STDIN.\n // Stop when there is no more data. \n { \n DWORD dwRead, dwWritten; \n CHAR chBuf[BUFSIZE];\n BOOL bSuccess = FALSE;\n \n // for (;;) \n // { \n bSuccess = ReadFile(g_hInputFile, chBuf, BUFSIZE, &dwRead, NULL);\n // if ( ! bSuccess || dwRead == 0 ) break; \n \n bSuccess = WriteFile(g_hChildStd_IN_Wr, chBuf, dwRead, &dwWritten, NULL);\n // if ( ! bSuccess ) break; \n // } \n \n // Close the pipe handle so the child process stops reading. \n \n // if ( ! CloseHandle(g_hChildStd_IN_Wr) ) \n // ErrorExit(TEXT(\"StdInWr CloseHandle\")); \n } \n \n void ReadFromPipe(void) \n \n // Read output from the child process's pipe for STDOUT\n // and write to the parent process's pipe for STDOUT. \n // Stop when there is no more data. \n { \n DWORD dwRead, dwWritten;\n CHAR chBuf[BUFSIZE]; \n BOOL bSuccess = FALSE;\n HANDLE hParentStdOut = GetStdHandle(STD_OUTPUT_HANDLE);\n \n // for (;;) \n // { \n bSuccess = ReadFile( g_hChildStd_OUT_Rd, chBuf, BUFSIZE, &dwRead, NULL);\n // if( ! bSuccess || dwRead == 0 ) break; \n \n bSuccess = WriteFile(hParentStdOut, chBuf, \n dwRead, &dwWritten, NULL);\n // if (! bSuccess ) break; \n //} \n } \n \n void ErrorExit(PTSTR lpszFunction) \n \n // Format a readable error message, display a message box, \n // and exit from the application.\n { \n LPVOID lpMsgBuf;\n LPVOID lpDisplayBuf;\n DWORD dw = GetLastError(); \n \n FormatMessage(\n FORMAT_MESSAGE_ALLOCATE_BUFFER | \n FORMAT_MESSAGE_FROM_SYSTEM |\n FORMAT_MESSAGE_IGNORE_INSERTS,\n NULL,\n dw,\n MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n (LPTSTR) &lpMsgBuf,\n 0, NULL );\n \n lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, \n (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR)); \n StringCchPrintf((LPTSTR)lpDisplayBuf, \n LocalSize(lpDisplayBuf) / sizeof(TCHAR),\n TEXT(\"%s failed with error %d: %s\"), \n lpszFunction, dw, lpMsgBuf); \n MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT(\"Error\"), MB_OK); \n \n LocalFree(lpMsgBuf);\n LocalFree(lpDisplayBuf);\n ExitProcess(1);\n }\n \n```", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T11:42:16.627", "favorite_count": 0, "id": "86454", "last_activity_date": "2022-02-23T03:59:31.477", "last_edit_date": "2022-02-23T03:59:31.477", "last_editor_user_id": "18637", "owner_user_id": "18637", "post_type": "question", "score": 2, "tags": [ "c", "windows", "winapi", "visual-c++" ], "title": "createProcess createPipeを使いやすくしたラッパークラスのようなものはないでしょうか", "view_count": 270 }
[ { "body": "希望を満たすかはわかりませんが、CRT;\nCランタイムライブラリに含まれている[プロセス制御と環境制御](https://docs.microsoft.com/ja-\njp/cpp/c-runtime-library/process-and-environment-\ncontrol?view=msvc-170)が用意されています。\n\n * `system`や`_spawn*`などのプロセス起動\n * `_pipe`や`_popen`などのパイプ\n\nがあり、これらは`_`の付かない同名の関数がUNIX系OSにもあり、似たような動きをします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T12:17:40.063", "id": "86455", "last_activity_date": "2022-02-19T12:17:40.063", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "86454", "post_type": "answer", "score": 0 } ]
86454
null
86455
{ "accepted_answer_id": null, "answer_count": 0, "body": "XDのデザインカンプから、サイトを作成しています。 \n数字を、デザインと同じにしても、ずれます、主に、 line-height:がです。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/ZzzS6.png)](https://i.stack.imgur.com/ZzzS6.png)\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/OHwSV.png)](https://i.stack.imgur.com/OHwSV.png)\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/5edGs.png)](https://i.stack.imgur.com/5edGs.png)\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/gYZKx.png)](https://i.stack.imgur.com/gYZKx.png)\n\nこのように、TOEFL対策はEngressの部分などが、実際のXDと同じ数字にしても、文字の上下の感覚が、ずれます。\n\nこの場合の対処法は、リセットCSSが悪いのでしょうか? \nそれとも他の何かが悪いのでしょうか、どなたかお願いいたします。 \nリセットCSS\n\n```\n\n ========================================\n リセットcss\n ========================================= */\n html, body, div, span, applet, object, iframe,\n h1, h2, h3, h4, h5, h6, p, blockquote, pre,\n a, abbr, acronym, address, big, cite, code,\n del, dfn, em, img, ins, kbd, q, s, samp,\n small, strike, strong, sub, sup, tt, var,\n b, u, i, center,\n dl, dt, dd, ol, ul, li,\n fieldset, form, label, legend,\n table, caption, tbody, tfoot, thead, tr, th, td,\n article, aside, canvas, details, embed,\n figure, figcaption, footer, header, hgroup,\n menu, nav, output, ruby, section, summary,\n time, mark, audio, video {\n margin: 0;\n padding: 0;\n border: 0;\n font-style: normal;\n font-weight: normal;\n font-size: 100%;\n vertical-align: baseline;\n }\n \n article, aside, details, figcaption, figure,\n footer, header, hgroup, menu, nav, section {\n display: block;\n }\n \n html {\n overflow-y: scroll;\n }\n \n blockquote, q {\n quotes: none;\n }\n \n blockquote:before, blockquote:after, q:before, q:after {\n content: \"\";\n content: none;\n }\n \n input, textarea {\n margin: 0;\n padding: 0;\n }\n \n ol, ul {\n list-style: none;\n }\n \n table {\n border-collapse: collapse;\n border-spacing: 0;\n }\n \n caption, th {\n text-align: left;\n }\n \n a:focus {\n outline: none;\n }\n \n \n```\n\n```\n\n .Fv {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .Fv-section .Fv .Fv-img {\n background: url(images/fv.png); \n background-size: cover;\n height: 476px;\n width: 100%;\n text-align: center;\n background-position: center;\n }\n \n .Fv-img-container {\n height: 476px;\n }\n \n .Fv .Fv-img div div .Fv-title {\n padding-top: 116px;\n font-size: 48px;\n font-weight: bold;\n line-height: 1.3541;\n color: #fff;\n height: 53px;\n text-shadow: 0 3px 6px rgb(0 0 0 / 16%);\n }\n \n .Fv .Fv-img div .Fv-txt-wrapper {\n font-size: 18px;\n padding-top: 23px;\n color: #fff;\n padding-bottom: 49px;\n height: 51px;\n line-height: 1.222;\n }\n \n \n \n .Fv .Fv-img div .Fv-outer {\n padding-bottom: 22px;\n }\n \n \n \n .Fv .Fv-img div .Fv-outer a .Fv-outer-btn {\n width: 260px;\n height: 60px;\n border-radius: 31px;\n background-color: #F5A623;\n margin: 0 auto;\n color: #fff;\n line-height: 60px;\n }\n \n .Fv-outer-btn-second{\n line-height: 29px;\n }\n \n .Fv .Fv-img div div .contact-link {\n color: #fff;\n }\n \n \n```\n\n```\n\n <section class=\"Fv-section\">\n <div class=\"Fv\">\n <div class=\"Fv-img\">\n <div class=\"Fv-img-container\">\n <div class=\"Fv-title-wrapper\">\n <h2 class=\"Fv-title\">TOEFL対策はEngress</h2>\n </div>\n <div class=\"Fv-title-wrapper-second\">\n <p class=\"Fv-txt-wrapper\">日本へのTOEFL指導歴豊かな講師陣の<br>\n コーチング型TOEFLスクール\n </p>\n </div>\n <div class=\"Fv-outer\">\n <a href=\"#\" style=\"text-decoration: none;\">\n <div class=\"Fv-outer-btn\">\n <p class=\"Fv-outer-btn-second\">資料請求</p>\n </div>\n </a>\n </div>\n <div class=\"contact-link-second\">\n <a class=\"contact-link\" href=\"#\">\n <p class=\"contact-link-second\">お問い合わせ</p>\n </a>\n </div>\n </div>\n </div> \n </div>\n </div>\n </section>\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T12:33:18.220", "favorite_count": 0, "id": "86456", "last_activity_date": "2022-02-19T15:32:08.850", "last_edit_date": "2022-02-19T15:32:08.850", "last_editor_user_id": "26370", "owner_user_id": "49042", "post_type": "question", "score": 0, "tags": [ "php", "wordpress" ], "title": "XDカンプと同じコードを入力しても、XD通りのデザインになりません、", "view_count": 89 }
[]
86456
null
null
{ "accepted_answer_id": "86472", "answer_count": 1, "body": "「クックパッド」 では、サーバサイドの開発に\n\nプログラミング言語 | Ruby, Go, Python, Java, Rust \n---|--- \n \nフレームワーク | Ruby on Rails, Spring Boot \n---|--- \n \nを採用しているそうなのですが、なぜ複数の言語(フレームワーク)を使用しているのでしょうか?\n\n一つの言語(フレームワーク)で事足りないのでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T13:30:28.867", "favorite_count": 0, "id": "86457", "last_activity_date": "2022-02-21T00:58:10.480", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49254", "post_type": "question", "score": 4, "tags": [ "ruby-on-rails", "spring-boot", "framework" ], "title": "Webサービスにサーバサイド言語を複数使うのはなぜですか?", "view_count": 283 }
[ { "body": "おことわり:私はこの回答の最初の投稿時点においてクックパッド株式会社で働いています。ただしあくまでいち開発者に過ぎず、この回答も個人の見解として投稿しています。この回答は会社の意見ではありません。\n\nまず、クックパッドに限らない一般的な話をします。\n\nひとつのサービスを開発・運用するときに、そのサービスを構成するサーバー側のアプリケーションが複数になることがあります。典型的な例としてマイクロサービス・アーキテクチャを採用している場合が考えられます。\n\nこのとき、複数存在するアプリケーションをすべて同じプログラミング言語で書くのか、異なるプログラミング言語で書くことを許すのかには選択の余地があります。たとえば殆どのアプリケーションを\nRuby で書きつつも、機械学習を使っている API アプリケーションは開発の都合で Python\nで書きたい、といった要望が生まれることは想像しやすいでしょう。他にも、殆どは Node.js で賄えるが、一部の処理が重いところを Rust\nで処理する、のような状況も考えられます。\n\nライブラリの潤沢さ、得意な処理、開発速度、サービスの成長段階、などなど、様々な事情に応じて様々な選定理由がありえます。もちろん全てのアプリケーションの実装言語をひとつに統一するという選択肢もありますが、それがいつも最適であるとは限らないということです。\n\nこのような事情から、あるサービスに使われているプログラミング言語やフレームワーク全体を見渡したときに、複数存在することがありえるのです。\n\n続いて、理解を深めるためにクックパッドに限った具体的な話を書いてみます。いわゆるレシピ投稿プラットフォームの「クックパッド」は、実際に複数のアプリケーションが協調して動いています。それらのアプリケーションたちの多くは\nRuby で実装されている一方で、一部のアプリケーションは別の言語で実装されています。たとえば 2019 年時点で Backends for\nFrontends (BFF) パターンのためのアプリケーションが Java を使って実装されており、ブログ記事\n<https://techlife.cookpad.com/entry/2019-orcha-bff>\nに当時の選定理由が書かれています。大雑把に要約すると非同期 I/O をがっつり利用するためです。\n\nまた、本筋とは離れる少しややこしい事情として、クックパッド株式会社は[「クックパッド」以外にもサービスを展開している](https://info.cookpad.com/service_product/japan)ため、場合によってはそれらに使われている技術も一緒に載っていることがあります。質問者さんが閲覧されたページに載っていたものがどれを指しているのかは、このコピペを見るだけだと判断できませんでした。\n\nという訳でまとめると、あるサービスを提供するときにそれを構成するアプリケーション群をいくつかのプログラミング言語で実装することはでき、また状況に応じてそうしたくなる理由もある、ということでした。\n\n以下、参考記事です。\n\n * Java を使ったアプリについての記事です:[モダンBFFを活用した既存APIサーバーの再構築](https://techlife.cookpad.com/entry/2019-orcha-bff) (2019-06-21)\n * マイクロサービス・アーキテクチャについて、2021 年夏時点での議論です:[Cookpad Lounge #7 世界最大級のモノリスcookpad_allどうする会議](https://www.youtube.com/watch?v=c_yBVmq-VcA) (2021/07/20)\n * 翻ってこちらは昔の議論です:[クックパッドとマイクロサービス](https://techlife.cookpad.com/entry/2014/09/08/093000) (2014/09/08)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T09:53:12.403", "id": "86472", "last_activity_date": "2022-02-21T00:58:10.480", "last_edit_date": "2022-02-21T00:58:10.480", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "86457", "post_type": "answer", "score": 11 } ]
86457
86472
86472
{ "accepted_answer_id": null, "answer_count": 0, "body": "ウェブデザイナー(コーディングもできる)を目指しています。\n\nピクセルパーフェクトが重要だと聞き、やり方を調べると、 \nXDやフォトショップの見本のデザインをスクショで撮り、拡張機能のパーフェクトピクセル、で当てはめて調節するやり方と、 \nXDやフォトショップの数値通りにデザインするだけでもピクセルパーフェクトというようだとわかりました。\n\nどっちがほんとうのピクセルパーフェクトのやり方なのでしょうか?\n\nプロのウェブデザイナーまたはコーダーの方は、どのようにピクセルパーフェクトをやってますか?", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T13:50:04.203", "favorite_count": 0, "id": "86458", "last_activity_date": "2022-02-19T13:50:04.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49042", "post_type": "question", "score": 0, "tags": [ "html", "css" ], "title": "ピクセルパーフェクトの正しいやり方がわかりません。", "view_count": 268 }
[]
86458
null
null
{ "accepted_answer_id": "86461", "answer_count": 1, "body": "### 問題\n\n今回の課題として、other-service➡の部分を下のour visionとを余白空けるためにmarginで設定してありますができていません。\n\n### 目標\n\n前者の画像が現在の画像です。 \n結果として、後者の画像のようにしたいです。\n\n現在、自分でも問題の追及していますが解決出来ていません。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/mZlgh.jpg)](https://i.stack.imgur.com/mZlgh.jpg)\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/i2nqS.jpg)](https://i.stack.imgur.com/i2nqS.jpg)\n\n```\n\n #our-service{\n z-index: 9;\n }\n \n .content1{\n margin: auto;\n padding-top: 125px;\n }\n \n .content1-wrp{\n display: flex;\n }\n \n h1{\n font-size: 28px;\n font-family: 'Noto Sans JP', sans-serif;\n border-top: solid 2px #2da690;\n max-width: 200px;\n margin: 0 auto;\n font-weight: 500px;\n text-decoration: none;\n padding-top: 4px;\n text-align:center;\n white-space: nowrap;\n }\n \n .content1-imgs1 img{\n height:665px;\n width: 665px;\n object-fit: contain;\n right: 42vw;\n bottom: -37vw;\n }\n \n .servis-text{\n height: 340.5px;\n width: 672px;\n position: absolute;\n background-color: #fff;\n right: 13vh;\n bottom: 20vh;\n opacity: 0.9;\n font-family: 'Noto Sans JP', sans-serif;\n }\n \n .service-text2{\n position: absolute;\n background-color: #fff;\n font-family: 'Noto Sans JP', sans-serif;\n opacity: 0.9;\n height: 373px;\n width: 672px;\n margin-left: 15vh;\n z-index: 2;\n }\n \n .service-text3{\n height: 340.5px;\n width: 672px;\n position: absolute;\n background-color: #fff;\n right: 13vh;\n bottom: 20vh;\n opacity: 0.9;\n font-family: 'Noto Sans JP', sans-serif;\n z-index: 2;\n bottom: 13vh;\n }\n \n .service-text3 img{\n height: 64px;\n width: 76px;\n max-height: 64px;\n max-width: 100%;\n margin-top: 2rem;\n }\n \n .img1{\n display: flex;\n height:100px;\n width: 200px;\n object-fit: contain;\n position: relative;\n margin:40px;\n margin-top: 10px;\n }\n \n .img2{\n display: flex;\n height:100px;\n width: 200px;\n object-fit: contain;\n position: relative;\n margin:40px;\n margin-top: 10px;\n }\n \n .img3{\n display: flex;\n height:100px;\n width: 200px;\n object-fit: contain;\n position: relative;\n margin:40px;\n margin-top: 10px;\n }\n \n .first-text{\n font-size: 32px;\n margin: -20px 0 20px 45px;\n }\n \n .second-text{\n margin:0 0 20px 45px;\n opacity: 0.5;\n }\n \n #content2{\n height: 457px;\n width: 1120px;\n \n }\n \n #content3{\n line-height: 5rem;\n height: 399px;\n width: 100%;\n }\n \n .content-imgs2 img{\n height: 457px;\n width: 684px;\n max-height: 500px;\n max-width: 100%;\n margin:0 0 0 80vh;\n position: relative;\n bottom:10vh;\n z-index: 1;\n }\n \n .content-imgs3 img{\n height: 399px;\n width: 684px;\n max-height: 500px;\n max-width: 100%;\n margin:0 0 0 0vh;\n position: relative;\n bottom:10vh;\n z-index: 1;\n }\n \n .other-service {\n text-align: right;\n margin-bottom: 5rem;\n font-weight: bold;\n padding-right: 2rem;\n }\n \n .other-service a {\n color: black;\n }\n \n .our-divsion{\n padding: 5rem 0 7rem 0;\n background-image: url(./image/bg01.jpg);\n background-size: 100% auto;\n line-height: 5rem;\n }\n \n .vision-service li {\n width: 33.3%;\n }\n \n .vision-title h3 {\n font-size: 2.6rem;\n font-weight: 400;\n margin: 0 auto;\n text-align: center;\n margin-bottom: 4rem;\n }\n \n .vision-service {\n display: flex;\n }\n \n \n .vision-text1 {\n font-size: 2rem;\n font-weight: 700;\n line-height: 2.5rem;\n color: #2da690;\n margin: 0 0 1.5rem;\n text-align: center;\n }\n \n .vision-text2 {\n margin: 0;\n font-size: 1rem;\n line-height: 1.5rem;\n font-weight: 400;\n color: #808080;\n text-align: center;\n }\n```\n\n```\n\n <section>\n <div class=our-service>\n <div class=\"content1\">\n <div class=\"Our-Service fadeIn_down fadeIn\">\n <h1>Our Service</h1>\n </div>\n <li class=\"fadeIn_up fadeIn\">\n <div class=\"content1-wrp\">\n <div class=\"content1-imgs1\">\n <img src=\"image/educure01.jpg\">\n </div>\n <div class=\"servis-text\">\n <img class=img1 src=\"./image/black.png\" alt=\"\">\n <p class=first-text>DXを推進するエンジニア育成</p>\n <p class=second-text>IT事業参入をご検討中の事業者様向けのサービスです。</p>\n </div>\n </div>\n </li>\n </div>\n <div id=\"content2\">\n <li class=\"fadeIn_up fadeIn\">\n <div class=\"service-text2\">\n <img class=img2 src=\"./image/logo.png\" alt=\"\">\n <p class=first-text>未経験から</br>本気でエンジニアへ</p>\n <p class=second-text>「未経験から本気でエンジニア」を目指すプログラミングスクールです。</p>\n  </div>\n   <div class=content-imgs2>\n <img src=\"./image/techpassion01.jpg\" alt=\"\">\n </div>\n </li>\n </div>\n <div id=\"content3\">\n <li class=\"fadeIn_up fadeIn\">\n   <div class=content-imgs3>\n <img src=\"./image/6c40ac7b707e13491fda6a6b4f02d82d.jpg\" alt=\"\">\n </div>\n <div class=\"service-text3\">\n <img class=img3 src=\"./image/abb886337b510d088a858a59a12bf114.png\" alt=\"\">\n <p class=first-text>人生を変える英会話アプリ</p>\n <p class=second-text>登録者25万人!YouTuber講師ジョージ監修!オンライン英会話アプリ!</p>\n  </div>\n </li>\n <div class=\"other-service fadeIn_right fadeIn\">\n <a href=\"#\">Other-service ➡</a>\n </div>\n </div>\n </div>\n \n <div class=\"our-divsion\">\n <li class=\"fadeIn_down fadeIn\">\n <div class=\"vision-menu\">\n <div class=\"our-vision fadeIn_down fadeIn\">\n <h1>our-vision</h1>\n </div>\n </li>\n <div class=\"vision-title fadeIn_up fadeIn\">\n <h3>世界の課題をITで解決して、</br>関わった<strong>世界中の人たちを幸せにする<strong></h3>\n </div>\n <ul class=\"vision-service\">\n <li class=\"fadeIn_up fadeIn\">\n <p class=\"vision-text1\">ITを通じて</br>人々の可能性を広げる</p>\n <p class=\"vision-text2\">イノベーションを起こし新たな価値を創造する</p>\n </li>\n <li class=\"fadeIn_up fadeIn\">\n <p class=\"vision-text1\">世界を代表する</br>自社サービスを作る</br>人々の可能性を広げる</p>\n <p class=\"vision-text2\">世の中にインパクトを与える</p>\n </li>\n <li class=\"fadeIn_up fadeIn\">\n <p class=\"vision-text1\">世界から選ばれる企業へ</p>\n <p class=\"vision-text2\">常に最高のパフォーマンスを発揮します</p>\n </li>\n </ul>\n </div>\n </div>\n </div>\n \n <div class=news>\n <li class=\"fadeIn_down fadeIn\">\n <div class=\"news-menu\">\n <div class=\"news fadeIn_down fadeIn\">\n <h1>News</h1>\n </li>\n </div>\n \n </section>\n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T14:02:38.053", "favorite_count": 0, "id": "86460", "last_activity_date": "2022-02-20T05:28:17.573", "last_edit_date": "2022-02-20T05:28:17.573", "last_editor_user_id": "3060", "owner_user_id": "51050", "post_type": "question", "score": 2, "tags": [ "html", "css" ], "title": "cssの設定を行っているがmarginで間が出来ていない", "view_count": 84 }
[ { "body": "見たところ,当該箇所の親である`#content3`が固定の高さ(`height:\n399px`を指定されているため,そこからオーバーフロー(はみ出て)してしまっているように見えます.\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/jORD5.png)](https://i.stack.imgur.com/jORD5.png)\n\nCSSのボックスモデルを考える際,仮お気の段階ではあっても構いませんが,こういったブロックごとに高さを決め打ちしてしまうべきではないことが多いです.(特にレスポンシブ対応で顕著になるかもしれません)\n\nなお,marginといえば[margin同士は重なる](https://yan-note.blogspot.com/2014/07/html-\ncssmargin.html)ので,注意が必要です.(この問題とセットで遭遇するかもしれません)", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T15:10:44.503", "id": "86461", "last_activity_date": "2022-02-19T15:10:44.503", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2376", "parent_id": "86460", "post_type": "answer", "score": 0 } ]
86460
86461
86461
{ "accepted_answer_id": null, "answer_count": 0, "body": "画像診断のプログラムを組みたいのですが、下記のようなエラーが出てしまいます。 \nJupyer Notebookを使用しており、kaggleのChest X-Ray Images\n(Pneumonia)というデータセットから何枚かダウンロードして使おうとしています。\n\n解決方法を教えていただければ幸いです。\n\nこちらがテストデータの一つです。 \n[胸部のX線画像](https://i.stack.imgur.com/BFJbe.jpg)\n\nこちらの動画を参考にしました。 \n[Pythonによるディープラーニングの作り方〜画像認識〜【Python機械学習入門#10】](https://www.youtube.com/watch?v=ThKRS7B5GFY&list=PL_tQOEJCWOE7JQpuiwuM2BHmz3fQkXRFD&index=5)\n\nソースコード\n\n```\n\n import numpy as np\n import tensorflow as tf\n import glob\n \n \n X_train = []\n y_train = []\n X_test = []\n y_test = []\n \n img_data=tf.io.read_file(\"image/train/0_normal/IM-0133-0001.jpeg\")\n \n for f in glob.glob(\"/image/*/*/*.jpeg\"):\n img_data = tf.io.read_file(f)\n img_data = tf.io.decode_jpeg(img_data)\n img_data = tf.image.resize(img_data,[100,100])\n \n if f.split(\"/\")[1]==\"train\":\n X_train.append(img_data)\n y_train.append(int(f.split(\"/\")[2].split(\"_\")[0]))\n elif f.split(\"/\")[1]==\"test\":\n X_test.append(img_data)\n y_test.append(int(f.split(\"/\")[2].split(\"_\")[0]))\n \n \n X_train = np.array(X_train) / 255.0\n y_train = np.array(y_train)\n X_test = np.array(X_test) / 255.0\n y_test = np.array(y_test)\n \n```\n\n```\n\n model=tf.keras.models.Sequential([\n tf.keras.layers.Flatten(input_shape=(100,100,3)),\n tf.keras.layers.Dense(64,activation=\"relu\"),\n tf.keras.layers.Dropout(0.2),\n tf.keras.layers.Dense(2,activation=\"softmax\")\n ])\n \n```\n\n```\n\n model.compile(optimizer=\"adam\",loss=\"sparse_categorical_crossentropy\",metrics=[\"accuracy\"])\n \n model.fit(X_train, y_train, epochs=10)\n \n```\n\nエラーメッセージ\n\n```\n\n Epoch 1/10\n ---------------------------------------------------------------------------\n ValueError Traceback (most recent call last)\n ~\\AppData\\Local\\Temp/ipykernel_17544/1266188578.py in <module>\n 1 model.compile(optimizer=\"adam\",loss=\"sparse_categorical_crossentropy\",metrics=[\"accuracy\"])\n 2 \n ----> 3 model.fit(X_train, y_train, epochs=10)\n \n ~\\anaconda3\\envs\\tensorflow16\\lib\\site-packages\\keras\\utils\\traceback_utils.py in error_handler(*args, **kwargs)\n 65 except Exception as e: # pylint: disable=broad-except\n 66 filtered_tb = _process_traceback_frames(e.__traceback__)\n ---> 67 raise e.with_traceback(filtered_tb) from None\n 68 finally:\n 69 del filtered_tb\n \n ~\\anaconda3\\envs\\tensorflow16\\lib\\site-packages\\keras\\engine\\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)\n 1393 logs = tf_utils.sync_to_numpy_or_python_type(logs)\n 1394 if logs is None:\n -> 1395 raise ValueError('Unexpected result of `train_function` '\n 1396 '(Empty logs). Please use '\n 1397 '`Model.compile(..., run_eagerly=True)`, or '\n \n ValueError: Unexpected result of `train_function` (Empty logs). Please use `Model.compile(..., run_eagerly=True)`, or `tf.config.run_functions_eagerly(True)` for more information of where went wrong, or file a issue/bug to `tf.keras`.\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-19T15:51:08.587", "favorite_count": 0, "id": "86463", "last_activity_date": "2022-02-20T07:24:35.660", "last_edit_date": "2022-02-20T07:24:35.660", "last_editor_user_id": "3060", "owner_user_id": "51404", "post_type": "question", "score": 0, "tags": [ "python", "tensorflow" ], "title": "Unexpected result of `train_function`の解決法", "view_count": 1052 }
[]
86463
null
null
{ "accepted_answer_id": "86468", "answer_count": 1, "body": "[Windowsでssh-copy-\nidっぽいことをしたい](https://qiita.com/tabu_ichi2/items/446722c15e6b5678ccad)\nの記事に従い、Windows 10 の端末からSSHキーをコピーしてみました。\n\n```\n\n cat ~/.ssh/Example-HomePage.pub | ssh [email protected] ` \n \" ` \n mkdir -p ~/.ssh && chmod 700 ~/.ssh && ` \n cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys ` \n \"\n \n```\n\n実行すると「ssh-rsaコマンドが見つかりません」(-bash: line 1: ssh-rsa: command not found)と表示されました。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/kk1qT.png)](https://i.stack.imgur.com/kk1qT.png)\n\n修正方法と、全部正常に終わった事を確認する方法を教えていただいても宜しいでしょうか。 \nVPSに導入してあるのは Ubuntu 20.04 です。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T03:37:15.337", "favorite_count": 0, "id": "86466", "last_activity_date": "2022-02-20T04:58:55.323", "last_edit_date": "2022-02-20T04:58:55.323", "last_editor_user_id": "3060", "owner_user_id": "16876", "post_type": "question", "score": 0, "tags": [ "windows", "ssh", "powershell" ], "title": "Windows 10 の PowerShell でSSHキーをコピーする時 ssh-rsa: command not found エラーが発生する", "view_count": 266 }
[ { "body": "`ssh-rsa` とは `~/.ssh/Example-HomePage.pub` の先頭部分と思われます。それとは別に\n\n```\n\n mkdir -p ~/.ssh && chmod 700 ~/.ssh &&\n cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys\n \n```\n\nが実行されずに画面に表示されている点も気になります。Qiitaの記事通りに正しくコマンドを入力できていないと思われます。 \n例えば質問文に記載のコマンドですと、PowerShellエスケープ文字```の後ろが **改行** ではなく **空白**\nになっていて行継続できていないようにも見えます。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T04:36:28.807", "id": "86468", "last_activity_date": "2022-02-20T04:36:28.807", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "86466", "post_type": "answer", "score": 1 } ]
86466
86468
86468
{ "accepted_answer_id": "86469", "answer_count": 1, "body": "ウエブサイト・ウエブアプリを **/var/www** の下に置いた方が良いと言われていますが、見つけた例の中には **/var/www/html/**\nぐらいしかありませんでした。仮に一つのサーバは複数のウエブサイト・アプリ(例えば、example.com、yourtube.com、headbook.com)を含めているとしら、\n**/var/www** 以下構造はどうなりますでしょうか?\n\n論理上は以下のようであるべきでしょうか?\n\n```\n\n var\n www\n example.com\n yourtube.com\n headbook.com\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T04:15:24.653", "favorite_count": 0, "id": "86467", "last_activity_date": "2022-02-20T05:24:50.320", "last_edit_date": "2022-02-20T05:24:50.320", "last_editor_user_id": "3060", "owner_user_id": "16876", "post_type": "question", "score": 1, "tags": [ "linux" ], "title": "一つの web サーバーに複数のサイトが含まれる場合、/var/www 以下のディレクトリの構成はどうなりますか?", "view_count": 592 }
[ { "body": "一つの web サーバで複数のサイトを運用することを **バーチャルホスト** と呼びます。\n\nドキュメントルートもそれぞれのサイトごとに分ける必要がありますが、ドキュメントルート自体は外部に見えるわけではないので、管理しやすい任意の名前で構いません。\n\n設定ファイルとの整合が取れていればいいので、想定されているようなドメイン名ごとに分ける例もありますし、単純にサイト名で分ける方法でも構いません。\n\n参考までに、以下は Apache のドキュメントで示されているバーチャルホストの設定例 (抜粋) です。\n\n[バーチャルホストの例 | Apache HTTP\nサーバ](https://httpd.apache.org/docs/2.4/ja/vhosts/examples.html)\n\n```\n\n <VirtualHost *:80>\n DocumentRoot /www/example1\n ServerName www.example.com\n \n # Other directives here\n \n </VirtualHost>\n \n <VirtualHost *:80>\n DocumentRoot /www/example2\n ServerName www.example.org\n \n # Other directives here\n \n </VirtualHost>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T05:23:23.687", "id": "86469", "last_activity_date": "2022-02-20T05:23:23.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "86467", "post_type": "answer", "score": 1 } ]
86467
86469
86469
{ "accepted_answer_id": "86473", "answer_count": 1, "body": "### 問題\n\n指している所にmarginが反映されていない\n\n###目 標 \nmarginを反映させる \nnews other-service➡の部分\n\n### 目標画像\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/Q2MoV.png)](https://i.stack.imgur.com/Q2MoV.png) \n[![画像の説明をここに入力](https://i.stack.imgur.com/szXOm.png)](https://i.stack.imgur.com/szXOm.png)\n\n### 現在\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/73Q1Q.jpg)](https://i.stack.imgur.com/73Q1Q.jpg) \n[![画像の説明をここに入力](https://i.stack.imgur.com/Ov5Tq.png)](https://i.stack.imgur.com/Ov5Tq.png)\n\n```\n\n HTML\n <section>\n <div class=our-service>\n <div class=\"content1\">\n <div class=\"Our-Service fadeIn_down fadeIn\">\n <h1>Our Service</h1>\n </div>\n <li class=\"fadeIn_up fadeIn\">\n <div class=\"content1-wrp\">\n <div class=\"content1-imgs1\">\n <img src=\"image/educure01.jpg\">\n </div>\n <div class=\"servis-text\">\n <img class=img1 src=\"./image/black.png\" alt=\"\">\n <p class=first-text>DXを推進するエンジニア育成</p>\n <p class=second-text>IT事業参入をご検討中の事業者様向けのサービスです。</p>\n </div>\n </div>\n </li>\n </div>\n <div id=\"content2\">\n <li class=\"fadeIn_up fadeIn\">\n <div class=\"service-text2\">\n <img class=img2 src=\"./image/logo.png\" alt=\"\">\n <p class=first-text>未経験から</br>本気でエンジニアへ</p>\n <p class=second-text>「未経験から本気でエンジニア」を目指すプログラミングスクールです。</p>\n  </div>\n   <div class=content-imgs2>\n <img src=\"./image/techpassion01.jpg\" alt=\"\">\n </div>\n </li>\n </div>\n <div id=\"content3\">\n <li class=\"fadeIn_up fadeIn\">\n   <div class=content-imgs3>\n <img src=\"./image/6c40ac7b707e13491fda6a6b4f02d82d.jpg\" alt=\"\">\n </div>\n <div class=\"service-text3\">\n <img class=img3 src=\"./image/abb886337b510d088a858a59a12bf114.png\" alt=\"\">\n <p class=first-text>人生を変える英会話アプリ</p>\n <p class=second-text>登録者25万人!YouTuber講師ジョージ監修!オンライン英会話アプリ!</p>\n  </div>\n </li>\n <div class=\"other-service fadeIn_right fadeIn\">\n <a href=\"#\">Other-service ➡</a>\n </div>\n </div>\n </div>\n <div class=\"our-divsion\">\n <li class=\"fadeIn_down fadeIn\">\n <div class=\"vision-menu\">\n <div class=\"our-vision fadeIn_down fadeIn\">\n <h1>our-vision</h1>\n </div>\n </li>\n <div class=\"vision-title fadeIn_up fadeIn\">\n <h3>世界の課題をITで解決して、</br>関わった<strong>世界中の人たちを幸せにする<strong></h3>\n </div>\n <ul class=\"vision-service\">\n <li class=\"fadeIn_up fadeIn\">\n <p class=\"vision-text1\">ITを通じて</br>人々の可能性を広げる</p>\n <p class=\"vision-text2\">イノベーションを起こし新たな価値を創造する</p>\n </li>\n <li class=\"fadeIn_up fadeIn\">\n <p class=\"vision-text1\">世界を代表する</br>自社サービスを作る</br>人々の可能性を広げる</p>\n <p class=\"vision-text2\">世の中にインパクトを与える</p>\n </li>\n <li class=\"fadeIn_up fadeIn\">\n <p class=\"vision-text1\">世界から選ばれる企業へ</p>\n <p class=\"vision-text2\">常に最高のパフォーマンスを発揮します</p>\n </li>\n </ul>\n </div>\n </div>\n \n <div class=news>\n <li class=\"fadeIn_down fadeIn\">\n <div class=\"news-menu\">\n <div class=\"news fadeIn_down fadeIn\">\n <h1>News</h1>\n </li>\n </div>\n <div class=\"news-topics\">\n <div class=\"news-topic\">\n <div class=\"news-list fadeIn_up fadeIn\">\n <img width=\"170\" height=\"90\" src=\"/image/prtimes.png\">\n <div class=\"news-text\">\n <p>2022-01-14 <a href=\"#\">プレスリリース メディア<a/> <a href=\"#\">自社サービス</a> </p>\n <a href=\"#\">【プレリリース】DXを促進するリスキング(再教育)サービス</br>「EDUcare(エドゥキュア)」</a>\n </div>\n </div>\n <div class=\"news-list fadeIn_up fadeIn\">\n <img width=\"170\" height=\"90\" src=\"/image/prtimes.png\">\n <div class=\"news-text\">\n <p>2022-10-29 <a href=\"#\">プレスリリース メディア<a/> <a href=\"#\">自社サービス</a> </p>\n <a href=\"#\">【プレリリース】【プレスリリース】IT人材教育システム「educure」”Cross Education Lab.”\n 芝浦工大 新熊亮一教授監修により更にデータドリブンな教育プログラムが提供可能に!</a>\n </div>\n </div>\n <div class=\"news-list fadeIn_up fadeIn\">\n <img width=\"170\" height=\"90\" src=\"/image/IMG_0218-4-125x125.jpeg\">\n <div class=\"news-text\">\n <p>2021-05-01 <a href=\"#\">会社情報<a/> </p>\n <a href=\"#\">本社オフィス移転のお知らせ</a>\n </div>\n </div>\n <div class=\"news-list fadeIn_up fadeIn\">\n <img width=\"170\" height=\"90\" src=\"/image/prtimes.png\">\n <div class=\"news-text\">\n <p>2021-04-01 <a href=\"#\">プレスリリース メディア<a/> <a href=\"#\">自社サービス</a> </p>\n <a href=\"#\">【プレスリリース】人材派遣の勤怠管理から請求書作成、従業員の給与明細まで\n 一元化できる管理システム「kint」をリリース</a>\n </div>\n </div>\n <div class=\"news-list fadeIn_up fadeIn\">\n <img width=\"170\" height=\"90\" src=\"/image/prtimes.png\">\n <div class=\"news-text\">\n <p>2021-03-01 <a href=\"#\">プレスリリース メディア<a/> <a href=\"#\">自社サービス</a> </p>\n <a href=\"#\">【プレスリリース】未経験からエンジニアになれる、IT人材教育プログラミングスクール「Tech Passion」開講</a>\n </div>\n </div>\n <div class=\"other-service2 fadeIn_right fadeIn\">\n <a href=\"#\">other-service ➡</a>\n </div>\n </div>\n </div>\n \n </section>\n <html>\n \n```\n\ncss\n\n```\n\n #our-service{\n z-index: 9;\n }\n \n .content1{\n margin: auto;\n padding-top: 125px;\n }\n \n .content1-wrp{\n display: flex;\n }\n \n h1{\n font-size: 28px;\n font-family: 'Noto Sans JP', sans-serif;\n border-top: solid 2px #2da690;\n max-width: 200px;\n margin: 0 auto;\n font-weight: 500px;\n text-decoration: none;\n padding-top: 4px;\n text-align:center;\n white-space: nowrap;\n }\n \n \n .content1-imgs1 img{\n height:665px;\n width: 665px;\n object-fit: contain;\n right: 42vw;\n bottom: -37vw;\n }\n \n .servis-text{\n height: 340.5px;\n width: 672px;\n position: absolute;\n background-color: #fff;\n right: 13vh;\n bottom: 20vh;\n opacity: 0.9;\n font-family: 'Noto Sans JP', sans-serif;\n }\n \n .service-text2{\n position: absolute;\n background-color: #fff;\n font-family: 'Noto Sans JP', sans-serif;\n opacity: 0.9;\n height: 373px;\n width: 672px;\n margin-left: 15vh;\n z-index: 2;\n }\n \n .service-text3{\n height: 340.5px;\n width: 672px;\n position: absolute;\n background-color: #fff;\n right: 13vh;\n bottom: 20vh;\n opacity: 0.9;\n font-family: 'Noto Sans JP', sans-serif;\n z-index: 2;\n bottom: 13vh;\n }\n \n .service-text3 img{\n height: 64px;\n width: 76px;\n max-height: 64px;\n max-width: 100%;\n margin-top: 2rem;\n }\n \n .img1{\n display: flex;\n height:100px;\n width: 200px;\n object-fit: contain;\n position: relative;\n margin:40px;\n margin-top: 10px;\n }\n \n .img2{\n display: flex;\n height:100px;\n width: 200px;\n object-fit: contain;\n position: relative;\n margin:40px;\n margin-top: 10px;\n }\n \n .img3{\n display: flex;\n height:100px;\n width: 200px;\n object-fit: contain;\n position: relative;\n margin:40px;\n margin-top: 10px;\n }\n \n .first-text{\n font-size: 32px;\n margin: -20px 0 20px 45px;\n }\n \n .second-text{\n margin:0 0 20px 45px;\n opacity: 0.5;\n }\n \n #content2{\n width: 1120px;\n }\n \n #content3{\n line-height: 5rem;\n width: 100%;\n }\n \n .content-imgs2 img{\n height: 457px;\n width: 684px;\n max-height: 500px;\n max-width: 100%;\n margin:0 0 0 80vh;\n position: relative;\n bottom:10vh;\n z-index: 1;\n }\n \n .content-imgs3 img{\n height: 399px;\n width: 684px;\n max-height: 500px;\n max-width: 100%;\n margin:0 0 0 0vh;\n position: relative;\n bottom:10vh;\n z-index: 1;\n }\n \n .other-service {\n text-align: right;\n margin-bottom: 5rem;\n font-weight: bold;\n padding-right: 2rem;\n }\n \n .other-service a {\n color: black;\n }\n \n .our-divsion{\n padding: 5rem 0 7rem 0;\n background-image: url(./image/bg01.jpg);\n background-size: 100% auto;\n }\n \n .vision-service li {\n width: 33.3%;\n }\n \n .vision-title h3 {\n font-size: 2.6rem;\n font-weight: 400;\n margin: 0 auto;\n text-align: center;\n margin-bottom: 4rem;\n }\n \n .vision-service {\n display: flex;\n }\n \n \n .vision-text1 {\n font-size: 2rem;\n font-weight: 700;\n line-height: 2.5rem;\n color: #2da690;\n margin: 0 0 1.5rem;\n text-align: center;\n }\n \n .vision-text2 {\n margin: 0;\n font-size: 1rem;\n line-height: 1.5rem;\n font-weight: 400;\n color: #808080;\n text-align: center;\n }\n \n .news-topics{\n margin: 0 auto;\n padding-left: 2.5rem;\n padding-right: 2.5rem;\n width: 100%;\n max-width: calc( 1120px + 2.5rem * 2);\n }\n \n .news-list{\n display: flex;\n padding: 1rem 0 1rem 0;\n border-bottom: 1px solid rgba(0,0,0,0.12);\n }\n \n .news-list img{\n object-fit: cover;\n }\n \n .news-text {\n padding-left: 1rem;\n }\n \n .news-text a {\n color: gray;\n }\n \n .news-text p a {\n color: black;\n }\n \n .news-text p a {\n color:#C0C0C0;\n }\n \n .other-service2{\n text-align: right;\n margin-bottom: 5rem;\n font-weight: bold;\n padding-right: 2rem;\n }\n \n .other-service2 a {\n color: black;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T08:37:44.320", "favorite_count": 0, "id": "86471", "last_activity_date": "2022-02-20T11:27:50.377", "last_edit_date": "2022-02-20T11:27:50.377", "last_editor_user_id": "19110", "owner_user_id": "51050", "post_type": "question", "score": 0, "tags": [ "html", "css" ], "title": "cssのmarginが効いていない", "view_count": 76 }
[ { "body": "`.other-service2`には`margin-bottom`しか設定されていないようです。 \n`margin-top`を設定すれば良いのでは。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T10:35:16.413", "id": "86473", "last_activity_date": "2022-02-20T10:35:16.413", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "45045", "parent_id": "86471", "post_type": "answer", "score": 1 } ]
86471
86473
86473
{ "accepted_answer_id": "86494", "answer_count": 1, "body": "■概要 \nDirectWriteのDrawTextを使って文字だけを描画させてレンダリング対象の背景は透明化したい。\n\n■質問内容 \nDrawTextを使って文字列を描画させていますが、文字を描画したときに描画範囲の背景が黒(RGBA=0, 0, 0, 0)や白(RGBA=1, 1, 1,\n0)になって文字以外の背景が見えなくなってしまいます。 \n期待としては背景は透明化して、文字だけを描画したいのですがどのようにアプローチしたら良いでしょうか?\n\nたとえばCreateWindowでSTATICコントロール生成+サブクラス化で背景を透過する。 \nなどが解決案として浮かびますが、Direct2Dによるレンダリングでそれができるのかという懸念と \n単純にコストがかかるので既存のDirect2Dの機能を使ってよりスマートなやり方がないかと考えています。\n\n■サンプルコード\n\n```\n\n #include <windows.h>\n #include <d2d1.h>\n #include <dwrite.h>\n \n #pragma comment(lib, \"d2d1.lib\")\n #pragma comment(lib, \"dwrite.lib\")\n \n \n typedef struct tagDWRITE_CONTEXT // DirectWriteコンテキスト\n {\n ID2D1Factory* pD2DFactory;\n IDWriteFactory* pDWriteFactory;\n ID2D1HwndRenderTarget* pRT;\n ID2D1SolidColorBrush* pBrush;\n IDWriteTextFormat* pTextFormat;\n } DWRITE_CONTEXT, * PDWRITE_CONTEXT;\n \n extern HWND g_hWnd;\n \n static void CALLBACK DirectWriteCallback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)\n {\n CONST D2D1_COLOR_F stBKColor = { 0.0f, 0.0F, 0.0f, 0.0f };\n PDWRITE_CONTEXT pContext;\n D2D1_SIZE_F stTargetSize;\n WCHAR chWork[256];\n static int inC;\n \n pContext = (PDWRITE_CONTEXT)dwUser;\n \n // 描画開始(Direct2D)\n pContext->pRT->BeginDraw();\n \n // 背景クリア\n pContext->pRT->Clear(stBKColor);\n \n wsprintfW(chWork, L\"テスト%d\", inC++);\n \n stTargetSize = pContext->pRT->GetSize();\n pContext->pRT->DrawText(chWork,\n wcslen(chWork),\n pContext->pTextFormat,\n &D2D1::RectF(0, 0, 167, 155),\n pContext->pBrush);\n \n // 描画終了(Direct2D)\n pContext->pRT->EndDraw();\n }\n \n DWORD WINAPI DirectWriteThreadProc(LPVOID lpParameter)\n {\n DWRITE_CONTEXT stDWriteContext;\n \n RECT rc;\n D2D1_SIZE_U stPixelSize;\n \n UINT uTimerID;\n HRESULT hr;\n \n MSG stMsg;\n BOOL bRinf;\n \n \n //-------------------------------------------------------------------------\n // 変数初期化\n //-------------------------------------------------------------------------\n memset(&stDWriteContext, 0, sizeof(stDWriteContext));\n uTimerID = 0U;\n \n //-------------------------------------------------------------------------\n // D2Dインタフェース生成\n //-------------------------------------------------------------------------\n hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &stDWriteContext.pD2DFactory);\n \n //-------------------------------------------------------------------------\n // DirectWriteインタフェース生成\n //-------------------------------------------------------------------------\n hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown **)&stDWriteContext.pDWriteFactory);\n \n //-------------------------------------------------------------------------\n // ID2D1HwndRenderTarget生成\n //-------------------------------------------------------------------------\n GetClientRect(g_hWnd, &rc);\n stPixelSize = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top);\n hr = stDWriteContext.pD2DFactory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT,\n D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_UNKNOWN)),\n D2D1::HwndRenderTargetProperties(g_hWnd, stPixelSize, D2D1_PRESENT_OPTIONS_IMMEDIATELY),\n &stDWriteContext.pRT);\n \n //-------------------------------------------------------------------------\n // テキストフォーマット作成\n //-------------------------------------------------------------------------\n hr = stDWriteContext.pDWriteFactory->CreateTextFormat(L\"Arial\",\n NULL,\n DWRITE_FONT_WEIGHT_BOLD,\n DWRITE_FONT_STYLE_NORMAL,\n DWRITE_FONT_STRETCH_ULTRA_EXPANDED,\n 72.0f,\n L\"ja-jp\",\n &stDWriteContext.pTextFormat);\n \n //-------------------------------------------------------------------------\n // ブラシ作成\n //-------------------------------------------------------------------------\n hr = stDWriteContext.pRT->CreateSolidColorBrush(D2D1::ColorF(0xFF0094C8, 1.0F), &stDWriteContext.pBrush);\n \n //-------------------------------------------------------------------------\n // 描画タイマー起動(30fps)\n //-------------------------------------------------------------------------\n uTimerID = timeSetEvent(33, 1, DirectWriteCallback, (DWORD_PTR)&stDWriteContext, TIME_PERIODIC);\n \n //-------------------------------------------------------------------------\n // イベントメッセージループ\n //-------------------------------------------------------------------------\n while (1)\n {\n bRinf = GetMessage(&stMsg, NULL, 0, 0);\n switch (bRinf)\n {\n case 0: // プログラム終了\n \n break;\n \n case -1: // イベントメッセージ取得エラー\n \n break;\n \n default:\n \n break;\n }\n \n // メッセージループ処理終了判定\n if (bRinf == 0 || bRinf == -1) break;\n }\n \n //-------------------------------------------------------------------------\n // 描画タイマー終了\n //-------------------------------------------------------------------------\n if (uTimerID != 0U)\n {\n timeKillEvent(uTimerID);\n }\n \n //-------------------------------------------------------------------------\n // タイマーコールバックが終了するまで待つ\n //-------------------------------------------------------------------------\n Sleep(500);\n \n //-------------------------------------------------------------------------\n // D2Dリソース解放\n //-------------------------------------------------------------------------\n if (stDWriteContext.pBrush != NULL)\n {\n stDWriteContext.pBrush->Release();\n }\n \n if (stDWriteContext.pRT != NULL)\n {\n stDWriteContext.pRT->Release();\n }\n \n if (stDWriteContext.pTextFormat != NULL)\n {\n stDWriteContext.pTextFormat->Release();\n }\n \n if (stDWriteContext.pDWriteFactory != NULL)\n {\n stDWriteContext.pDWriteFactory->Release();\n }\n \n #if 0\n if (stDWriteContext.pD2DFactory != NULL)\n {\n stDWriteContext.pD2DFactory->Release();\n }\n #endif\n \n ExitThread(0UL);\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T10:46:10.923", "favorite_count": 0, "id": "86474", "last_activity_date": "2022-02-21T10:44:04.677", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20931", "post_type": "question", "score": 0, "tags": [ "c++", "directx" ], "title": "DirectWriteによる文字列描画で背景色が透明化できない", "view_count": 233 }
[ { "body": "古典的なやり方ですが、ダイアログまたはCreateWindowで作成したコントロールにWS_EX_LAYEREDを設定してSetLayeredWindowAttributesを使用して \n特定のピクセルのRGBのときに透明化する方法でひとまず課題を解決することができました。 \nしかし、SetLayeredWindowAttributesによる透過処理は負荷が高いらしいのでより負荷がかからない方法を将来的に探していきたいと思います。\n\n■解決時のコード\n\n```\n\n INT_PTR CALLBACK DirectWriteDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\n {\n // DirectWrite関連\n const D2D1_COLOR_F stBKColor = D2D1::ColorF(0x002B2B2B, 1.0F); // R=43, G=43, B=43, Alpha=1.0F\n static ID2D1Factory *pD2DFactory;\n static IDWriteFactory *pDWriteFactory;\n static ID2D1HwndRenderTarget *pRT;\n static ID2D1SolidColorBrush *pDWBrush;\n static IDWriteTextFormat *pTextFormat;\n \n RECT rc;\n D2D1_SIZE_U stPixelSize;\n D2D1_SIZE_F stTargetSize;\n HRESULT hr;\n \n // デバコン関連\n HDC hdc;\n PAINTSTRUCT ps;\n static HBRUSH hBrush;\n \n // タイマー関連\n const UINT uiTimer = 9876;\n static UINT_PTR uiTimerID;\n DWORD dwExStyle;\n \n // ワーク領域関連\n WCHAR chWork[256];\n INT_PTR inRet;\n \n //-------------------------------------------------------------------------\n // 変数初期化\n //-------------------------------------------------------------------------\n inRet = 0;\n \n //-------------------------------------------------------------------------\n // メッセージ処理開始\n //-------------------------------------------------------------------------\n switch (uMsg)\n {\n case WM_INITDIALOG:\n {\n //-----------------------------------------------------------------\n // タスクバーのウィンドウ非表示設定\n //-----------------------------------------------------------------\n dwExStyle = (DWORD)GetWindowLong(hwndDlg, GWL_EXSTYLE);\n SetWindowLong(hwndDlg, GWL_EXSTYLE, dwExStyle | WS_EX_TOOLWINDOW);\n \n //-----------------------------------------------------------------\n // 定期描画タイマー作成(30fps)\n //-----------------------------------------------------------------\n uiTimerID = SetTimer(hwndDlg, uiTimer, 32, (TIMERPROC)DirectWriteDlgProc);\n \n //-----------------------------------------------------------------\n // ウィンドウ半透明化設定(R=43, G=43, B=43に対して透明化させる)\n //-----------------------------------------------------------------\n SetLayeredWindowAttributes(hwndDlg, RGB(43, 43, 43), 0, LWA_COLORKEY);\n \n //-----------------------------------------------------------------\n // 背景ブラシ(半透明化のため)\n //-----------------------------------------------------------------\n hBrush = CreateSolidBrush(RGB(43, 43, 43));\n \n //-----------------------------------------------------------------\n // D2Dインタフェース生成\n //-----------------------------------------------------------------\n hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pD2DFactory);\n \n //-----------------------------------------------------------------\n // DirectWriteインタフェース生成\n //-----------------------------------------------------------------\n hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown **)&pDWriteFactory);\n \n //-----------------------------------------------------------------\n // ID2D1HwndRenderTarget生成\n //-----------------------------------------------------------------\n GetClientRect(hwndDlg, &rc);\n stPixelSize = D2D1::SizeU(rc.right - rc.left, rc.bottom - rc.top);\n hr = pD2DFactory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT,\n D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_UNKNOWN)),\n D2D1::HwndRenderTargetProperties(hwndDlg, stPixelSize),\n &pRT);\n \n //-----------------------------------------------------------------\n // テキストフォーマット作成\n //-----------------------------------------------------------------\n hr = pDWriteFactory->CreateTextFormat(L\"Arial\",\n NULL,\n DWRITE_FONT_WEIGHT_BOLD,\n DWRITE_FONT_STYLE_NORMAL,\n DWRITE_FONT_STRETCH_NORMAL,\n 72.0f,\n L\"ja-jp\",\n &pTextFormat);\n \n //-----------------------------------------------------------------\n // ブラシ作成\n //-----------------------------------------------------------------\n hr = pRT->CreateSolidColorBrush(D2D1::ColorF(0xFF0094C8, 1.0F), &pDWBrush);\n \n //-----------------------------------------------------------------\n // 描画文字のアンチエイリアスモード\n //-----------------------------------------------------------------\n pRT->SetTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE);\n \n inRet = 1;\n \n break;\n }\n \n case WM_TIMER: // タイマー通知\n {\n //-----------------------------------------------------------------\n // 再描画要求\n //-----------------------------------------------------------------\n InvalidateRect(hwndDlg, NULL, TRUE);\n \n break;\n }\n \n case WM_ERASEBKGND: // ウィンドウ背景消去\n {\n //-----------------------------------------------------------------\n // チラツキを防止するため、システム側で背景消去を行わない\n //-----------------------------------------------------------------\n inRet = 1;\n \n break;\n }\n \n case WM_PAINT:\n {\n hdc = BeginPaint(hwndDlg, &ps);\n \n //-----------------------------------------------------------------\n // 描画開始(Direct2D)\n //-----------------------------------------------------------------\n pRT->BeginDraw();\n \n //-----------------------------------------------------------------\n // 背景クリア(R=43, G=43, B=43, Alpha=1.0の場合は透明化される)\n //-----------------------------------------------------------------\n pRT->Clear(stBKColor);\n \n stTargetSize = pRT->GetSize();\n \n //-----------------------------------------------------------------\n // DirectWriteによる文字列描画\n //-----------------------------------------------------------------\n wsprintfW(&chWork[0], L\"テスト\");\n \n pRT->DrawText(chWork,\n wcslen(chWork),\n pTextFormat,\n &D2D1::RectF(0, 90, stTargetSize.width, stTargetSize.height),\n pDWBrush);\n \n //-----------------------------------------------------------------\n // 描画終了(Direct2D)\n //-----------------------------------------------------------------\n pRT->EndDraw();\n \n EndPaint(hwndDlg, &ps);\n \n break;\n }\n \n case WM_CTLCOLORDLG: // ダイアログの背景色\n {\n return (LRESULT)hBrush;\n }\n \n case WM_CLOSE:\n {\n if (uiTimerID != 0)\n {\n KillTimer(hwndDlg, uiTimerID);\n uiTimerID = 0;\n }\n \n if (pDWBrush != NULL)\n {\n pDWBrush->Release();\n }\n \n // クラッシュする\n //if (pRT != NULL)\n //{\n // pRT->Release();\n //}\n \n if (pTextFormat != NULL)\n {\n pTextFormat->Release();\n }\n \n if (pDWriteFactory != NULL)\n {\n pDWriteFactory->Release();\n }\n \n if (pD2DFactory != NULL)\n {\n pD2DFactory->Release();\n }\n \n EndDialog(hwndDlg, 0);\n // ダイアログを制御しているスレッドにWM_QUITをポスト\n PostQuitMessage(0);\n \n break;\n }\n \n default:;\n }\n \n \n return inRet;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T10:44:04.677", "id": "86494", "last_activity_date": "2022-02-21T10:44:04.677", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20931", "parent_id": "86474", "post_type": "answer", "score": 0 } ]
86474
86494
86494
{ "accepted_answer_id": "86476", "answer_count": 1, "body": "vscodeのターミナルに`docker-compose up -d`というコマンドを入力し実行すると、 \n`no configuration file provided: not found`というエラーが出てしまいます。 \nこちらの解消方法をご教授頂きたいです。 \n宜しくお願い致します。\n\n状況の説明が不足しており申し訳ございません。 \n下記、フォルダの中身の内容で御座います。\n\nフォルダA \n●php \n・Dockerfile \n・php.ini-development \n●work \n・css \n・img \n・favicon.ico \n・index.html \n●docker-compose.yml \n●license.txt\n\nフォルダAの中に●と・が同じ階層という意\n\n・Dockerfileのコード\n\n```\n\n FROM php:7.3-alpine\n \n RUN apk --update add tzdata && \\\n cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \\\n apk del tzdata && \\\n rm -rf /var/cache/apk/*\n \n RUN docker-php-ext-install mbstring\n \n COPY php.ini-development /usr/local/etc/php/php.ini\n \n WORKDIR /work\n \n CMD [\"php\", \"-S\", \"0.0.0.0:8000\", \"-t\", \"/work\"]\n \n```\n\n●docker-compose.ymlのコード\n\n```\n\n version: '3.7'\n services:\n php:\n #build: ./php-fpm\n build: ./php\n ports:\n - 8080:8000\n volumes:\n - ./work:/work\n \n```\n\ndockerをインストール \nWSL2をインストール \nubuntuをインストール \nLinuxコマンドをwindows、vs codeで使用可能になってます\n\nlsコマンドの実行結果\n\n```\n\n ディレクトリ: D:\\デスクトップ\\basic_php_v3-master\n \n \n Mode LastWriteTime Length Name\n ---- ------------- ------ ----\n d----- 2022/02/20 13:49 basic_php_v3-master\n \n \n```\n\n※basic_php_v3-master = フォルダ名", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T10:51:04.480", "favorite_count": 0, "id": "86475", "last_activity_date": "2022-02-20T16:34:05.643", "last_edit_date": "2022-02-20T16:34:05.643", "last_editor_user_id": "3060", "owner_user_id": "42859", "post_type": "question", "score": 1, "tags": [ "docker", "docker-compose" ], "title": "docker-compose up を実行するとエラー no configuration file provided: not found", "view_count": 17438 }
[ { "body": "docker-compose を使う際には設定ファイルとして docker-compose.yml\nが必要ですが、それが見つかっていないというエラーと思われます。カレントディレクトリに docker-compose.yml が存在するかを確かめてください。\n\n`ls` コマンドの出力を見る限り、今お手元ではこのようなディレクトリ構造になっていて、\n\n```\n\n 何かしらのフォルダ\n └── basic_php_v3-master\n ├── php\n │ ├── Dockerfile\n │ └── php.ini-development\n ├── work\n │ ├── css\n │ ├── img\n │ ├── favicon.ico\n │ └── index.html\n ├── docker-compose.yml\n └── license.txt\n \n```\n\n本当は `basic_php_v3-master` の中で `docker-compose`\nコマンドを実行したかったのに、それよりひとつ上の何かしらのフォルダの中で `docker-compose` コマンドを実行しているようです。したがって\n`docker-compose.yml` も存在せず、エラーに繋がっていそうです。\n\n```\n\n 何かしらのフォルダ # ←ここで実行されてしまっていそうです\n └── basic_php_v3-master # ←本当はここで実行したいです\n ├── php\n :\n \n```\n\nたとえば、`basic_php_v3-master` という名前のフォルダの中に更に `basic_php_v3-master`\nという同じ名前のフォルダができているかもしれません。\n\n`ls` コマンドの出力を使って、今いるディレクトリにあるファイル一覧を確認できます。この出力の中に `docker-compose.yml`\nが無ければ何かがおかしいので、ディレクトリを移動して確かめてみてください。\n\n* * *\n\nところで、`ls` コマンドの出力形式を見るに、VS Code 上でお使いになっているターミナルが WSL2 の Ubuntu ではなくて\nPowerShell になっていそうです。したがって実行される `docker-compose` コマンドも Linux\n側にインストールされたものではなくて Windows 側にインストールされたものになる疑いがあるので、こちらも合わせてご確認ください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T11:17:59.770", "id": "86476", "last_activity_date": "2022-02-20T12:59:28.370", "last_edit_date": "2022-02-20T12:59:28.370", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "86475", "post_type": "answer", "score": 2 } ]
86475
86476
86476
{ "accepted_answer_id": "86479", "answer_count": 1, "body": "以下のシェルスクリプトを実行すると、gitのcheckoutまではうまくいくんですけど、以降のcdとechoがうまくいきません。DirectoryNameが空文字で何も表示されません。なぜでしょうか?\n\n```\n\n #! /bin/bash\n \n echo \"put the directory name :\"\n read DirectoryName\n cp -r base \"./$DirectoryName\"\n git checkout -b $DirectoryName\n cd \"`pwd`/$DirectoryName\" # ここから$DirectoryNameが空になってる\n echo \"`ls | grep $DirectoryName` directory and branch is created!\"\n \n```", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T11:45:43.007", "favorite_count": 0, "id": "86477", "last_activity_date": "2022-02-20T15:33:03.543", "last_edit_date": "2022-02-20T15:33:03.543", "last_editor_user_id": "19110", "owner_user_id": "36091", "post_type": "question", "score": 0, "tags": [ "bash" ], "title": "変数の中身が勝手に空になる", "view_count": 567 }
[ { "body": "* 変数は空になっていません。何かしらの挙動を見て変数が空になっていると勘違いなさっているようです。\n * `cd` コマンドによって `./$DirectoryName` に移動した上で `ls | grep $DirectoryName` をなさっているので、この結果は殆どの場合空になり、空文字が出力されそうです。\n * もしこのシェルスクリプトを `test.sh` みたいなファイルに保存してシェルから `./test.sh` みたいに実行してもカレントディレクトリが `./$DirectoryName` にならないことをもって「`cd` がうまくいかない」と表現されているのであれば、これは間違いです。`./test.sh` のように実行したときにはシェルの上で新しくシェルが立ち上がっており、その中で `cd` され、新しい方のシェルが終了することによって元のシェルに戻ってきます。したがって元のシェルでは `cd` されません。元のシェルで `cd` されるようにするには、実行側でシェルビルトインコマンドの `source` もしくは `.` を使う必要があります: <https://atmarkit.itmedia.co.jp/ait/articles/1712/21/news015.html>\n * あるいはファイルにシェルスクリプトを保存することに拘らないのであれば、`~/.bashrc` で関数として定義してしまうというやり方もあります。\n\nついでに、`echo \"`ls | grep $DirectoryName` directory and branch is created!\"`\nの部分は単に `echo \"$DirectoryName directory and branch is created!\"` で良さそうですね。`cd`\nの部分も `pwd` を使う必要は無さそうでした。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T12:44:46.897", "id": "86479", "last_activity_date": "2022-02-20T12:58:32.487", "last_edit_date": "2022-02-20T12:58:32.487", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "86477", "post_type": "answer", "score": 1 } ]
86477
86479
86479
{ "accepted_answer_id": "86484", "answer_count": 1, "body": "stripeのサンプルコードをTypeScript化しようとしているのですが、なぜかストリングリテラルが当たる場所でちゃんと文字列を渡しているのにエラーを起こします。\n\nエラー内容 - `options` の箇所で出てきます。\n\n```\n\n Optional Elements configuration options. Once the stripe prop has been set, these options cannot be changed.\n \n Type '{ clientSecret: string; appearance: { theme: string; }; }' is not assignable to type 'StripeElementsOptions'.\n The types of 'appearance.theme' are incompatible between these types.\n Type 'string' is not assignable to type '\"stripe\" | \"night\" | \"flat\" | \"none\" | undefined'.ts(2322)\n react-stripe.d.ts(445, 5): The expected type comes from property 'options' which is declared here on type 'IntrinsicAttributes & ElementsProps & { children?: ReactNode; }'\n \n```\n\nコード\n\n```\n\n import React, { useState, useEffect } from \"react\";\n import { loadStripe } from \"@stripe/stripe-js\";\n import { Elements } from \"@stripe/react-stripe-js\";\n \n import CheckoutForm from \"./CheckOutForm\";\n import \"./App.css\";\n \n // Make sure to call loadStripe outside of a component’s render to avoid\n // recreating the Stripe object on every render.\n // loadStripe is initialized with a fake API key.\n // Sign in to see examples pre-filled with your key.\n const stripePromise = loadStripe('pk_test_46zswMCbz39W2KAqKj43vDRu')\n \n export default function App() {\n const [clientSecret, setClientSecret] = useState(\"\");\n \n useEffect(() => {\n // Create PaymentIntent as soon as the page loads\n fetch(\"/create-payment-intent\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ items: [{ id: \"xl-tshirt\" }] }),\n })\n .then((res) => res.json())\n .then((data) => setClientSecret(data.clientSecret));\n }, []);\n \n const appearance = {\n theme: \"stripe\",\n };\n const options = {\n clientSecret,\n appearance,\n };\n \n return (\n <div className=\"App\">\n {clientSecret && (\n <Elements stripe={stripePromise} options={options}>\n <CheckoutForm />\n </Elements>\n )}\n </div>\n )\n }\n \n \n```\n\n### 追記\n\n型注釈とは下記のように明示的に型を指定してあげるという事でしょうか?\n\n```\n\n type Options = {\n clientSecret: string;\n appearance: {\n theme: 'stripe' | 'night' | 'flat' | 'none';\n }\n }\n \n // 一部抜粋...\n \n const appearance = {\n theme: 'stripe',\n };\n const options : Options = {\n clientSecret,\n appearance,\n };\n \n return (\n <div className=\"App\">\n {clientSecret && (\n <Elements stripe={stripePromise} options={options}>\n <CheckoutForm />\n </Elements>\n )}\n </div>\n )\n \n```\n\n追記2 \nこういう事ですね!\n\n```\n\n import React, { useState, useEffect } from \"react\";\n import { loadStripe, StripeElementsOptions, Appearance } from \"@stripe/stripe-js\";\n import { Elements} from \"@stripe/react-stripe-js\";\n \n \n import CheckoutForm from \"./CheckOutForm\";\n import \"./App.css\";\n \n // Make sure to call loadStripe outside of a component’s render to avoid\n // recreating the Stripe object on every render.\n // loadStripe is initialized with a fake API key.\n // Sign in to see examples pre-filled with your key.\n const stripePromise = loadStripe('pk_test_46zswMCbz39W2KAqKj43vDRu')\n \n export default function App() {\n const [clientSecret, setClientSecret] = useState(\"\");\n \n useEffect(() => {\n // Create PaymentIntent as soon as the page loads\n fetch(\"/create-payment-intent\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ items: [{ id: \"xl-tshirt\" }] }),\n })\n .then((res) => res.json())\n .then((data) => setClientSecret(data.clientSecret));\n }, []);\n \n const appearance: Appearance = {\n theme: 'stripe',\n };\n const options : StripeElementsOptions = {\n clientSecret,\n appearance,\n };\n \n return (\n <div className=\"App\">\n {clientSecret && (\n <Elements stripe={stripePromise} options={options}>\n <CheckoutForm />\n </Elements>\n )}\n </div>\n )\n }\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T12:59:39.173", "favorite_count": 0, "id": "86480", "last_activity_date": "2022-02-20T14:47:03.947", "last_edit_date": "2022-02-20T14:47:03.947", "last_editor_user_id": "22565", "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "javascript", "reactjs", "typescript" ], "title": "@stripe/react-stripe-jsで特定の文字列を渡しているが、ストリングリテラルでエラーになる", "view_count": 165 }
[ { "body": "`options.appearance.theme` につく型の説明として、\n\n * `\"stripe\" | \"night\" | \"flat\" | \"none\" | undefined`:書かれている文字列リテラルのどれかか `undefined` かが期待されている\n * `string`:何かしら文字列が期待されている\n\nとなっているところ、前者の型がつく場所に後者の型がつく値を代入しようとしているのでエラーになっていそうです。後者の型は任意の文字列を許している一方、前者はそうではないからです。\n\nで、前者の型は `Elements` を提供している `@stripe/react-stripe-js` から来ていて後者の型は引数に渡している変数\n`options` から来ているので、自分で用意している `options`\nの型を明示的に詳細に付けてあげると良さそうです。文字列リテラルを渡している箇所でも、そこで型注釈なしに推論される型は `string`\nであることに注意してください。後から変更されうるからです。簡単には、`StripeElementsOptions` で型注釈してあげると良さそうです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-20T13:28:22.103", "id": "86484", "last_activity_date": "2022-02-20T14:24:26.563", "last_edit_date": "2022-02-20T14:24:26.563", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "86480", "post_type": "answer", "score": 0 } ]
86480
86484
86484
{ "accepted_answer_id": null, "answer_count": 1, "body": "CloudFront + Wordpress で管理画面にログインしようとすると403エラーが発生します。 \nwp-login.phpは正しく表示されているのですが、ユーザ名、パスワードを入力しログインボタンを押すと403エラーとなり、ログインすることができません。\n\nどのような解決方法があるのでしょうか? \n不足している情報などがありましたら、ご指摘願います。\n\nよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T02:26:47.557", "favorite_count": 0, "id": "86486", "last_activity_date": "2022-02-25T00:44:50.973", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "48889", "post_type": "question", "score": 0, "tags": [ "wordpress" ], "title": "CloudFront + Wordpress で管理画面にログインしようとすると403エラーが発生する", "view_count": 438 }
[ { "body": "管理画面に入れなくなった経験はいくつかあります。よく真っ白になったりとか昔はありました。 \n今回は403ということなので、管理画面への接続がサーバーによって遮断されたような感じを受けます。 \nlolipopサーバーなどは、Wordpressの管理画面へのアクセスはIP制限しています。またさくらサーバーでは海外からのアクセスを制限する設定がデフォルトでされています。 \nCloudFrontということなのでよくわかりませんが、AmazonであるばWAF設定を確認してみるといいかもしれません。一度ファイアウォールをすべて切ってみて、入れるようになったら、1つずつオンにしていって、原因を突き止める、とか。 \nまた、/wp-\nadmin/にある.htaccessでもIPなどで制限している場合があります。これはsiteguardなどのプラグインで設定したりしますね。一度覗いてみるといいかもしれません。\n\nちなみに今回は関係ないかもですが、万が一のため。 \n管理画面でリダイレクトループのエラーが出たときは、たいがいはDBに記載されているURLとアクセスしているURLが違ったりすると起こります。 \n・SSLのhttpsになっていない \n・wwwをつけ忘れた \nなどです。DBのURLを確認してみるといいと思います。ただ、直に治すのは危険です。バックアップをとったり、シリアライズに気を付けてください。 \nリダイレクトループの場合はこちらが参考になります。 \n<https://wordpress.stackexchange.com/questions/175728/redirect-loop-only-for-\nmultisite-network-admin>", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-25T00:44:50.973", "id": "86567", "last_activity_date": "2022-02-25T00:44:50.973", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51589", "parent_id": "86486", "post_type": "answer", "score": 0 } ]
86486
null
86567
{ "accepted_answer_id": null, "answer_count": 1, "body": "azure Docsに rest apiでの操作方法があります。 \n(<https://docs.microsoft.com/ja-jp/rest/api/appservice/web-apps>)\n\n「Create or Update」ではアプリの作成・更新が可能とありますが、 \n(<https://docs.microsoft.com/ja-jp/rest/api/appservice/web-apps/create-or-\nupdate>)\n\n```\n\n PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}?api-version=2021-02-01\n \n```\n\nクイックスタートのようにPHPのruntime等をを指定する方法がわかりません。 \n(<https://docs.microsoft.com/ja-jp/azure/app-service/quickstart-php>)\n\n```\n\n az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app-name> --runtime 'PHP|7.4' --deployment-local-git\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T05:59:43.150", "favorite_count": 0, "id": "86488", "last_activity_date": "2022-04-03T03:21:03.733", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51536", "post_type": "question", "score": 0, "tags": [ "azure", "rest" ], "title": "Azure web-apps へのrest操作", "view_count": 68 }
[ { "body": "こんにちは。\n\n以下のように、App ServiceのsiteConfigで指定が可能です。\n\n<https://dev.classmethod.jp/articles/azure-rest-api-app-service/>", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-04-03T03:21:03.733", "id": "88146", "last_activity_date": "2022-04-03T03:21:03.733", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7740", "parent_id": "86488", "post_type": "answer", "score": 1 } ]
86488
null
88146
{ "accepted_answer_id": null, "answer_count": 1, "body": "next.jsでページネーションを実装しています。 \n「{page}ページ目/{max_page}ページ中」と表示したい箇所があります。 \nmax_pageはSWRでデータ件数をフェッチしてきた後に Math.floor(データ件数/1ページあたりの表示件数)という風に計算しています。\n\nmax_pageについてはページネーション遷移しても値は変わらないので、固定化したいところですが、swrでフェッチしたタイミングで再計算するため、ページ番号をクリックするたび、max_pageがいったん0になって再計算されるため、表示がチラついてしまいます。\n\n逆にuseMemoを使ってmax_pageの部分を固定値化しようとすると、useSWRのフェッチ取得のタイミングで初期値が計算されるので、初期値がうまく入りません(フェッチ取得前の0の値で固定されてしまう)。\n\nuseSWRでデータ件数を取得し、そのデータ件数から計算されたmax_pageを初期値に設定し、キャッシュ化したいのですが、うまい書き方はないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T06:04:49.477", "favorite_count": 0, "id": "86489", "last_activity_date": "2022-02-22T10:14:44.230", "last_edit_date": "2022-02-22T10:14:44.230", "last_editor_user_id": "50588", "owner_user_id": "50588", "post_type": "question", "score": 2, "tags": [ "reactjs", "next.js" ], "title": "useSWRとuseMemoを組み合わせたい", "view_count": 257 }
[ { "body": "キャッシュ化したいのであれば、`useRef` と `useEffect` を使ってみてはどうでしょうか。\n\n```\n\n const previousMaxPage = useRef(maxPage);\n \n useEffect(() => {\n previousMaxPage.current = maxPage;\n }, [maxPage]);\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T15:33:54.903", "id": "86500", "last_activity_date": "2022-02-21T15:33:54.903", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51277", "parent_id": "86489", "post_type": "answer", "score": 0 } ]
86489
null
86500
{ "accepted_answer_id": null, "answer_count": 2, "body": "表題の通りですが、以下のような感じで特定のフォルダだけ削除を実施したくないのですが \n上手くいきません。\n\nなにか方法はないでしょうか?\n\n```\n\n $filePath = 'C:\\temp\\'  # 削除対象フォルダ\n $excludeItem = '処理済' # 削除対象内で除外したいフォルダ\n \n Get-ChildItem -Path $filePath -Exclude $excludeItem -Recurse | Where-Object{$_.LastWriteTime -lt (Get-Date).AddDays(-2)} | Remove-Item -Force -WhatIf\n \n```", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T06:45:08.103", "favorite_count": 0, "id": "86490", "last_activity_date": "2022-02-21T23:10:23.813", "last_edit_date": "2022-02-21T11:02:11.367", "last_editor_user_id": "3060", "owner_user_id": "51539", "post_type": "question", "score": 1, "tags": [ "powershell" ], "title": "Powershellでフォルダ内のファイル削除を実施時に、特定のフォルダだけ除外したい", "view_count": 1271 }
[ { "body": "下記のスクリプトでできます。\n\n```\n\n ls -Path $filePath -Recurse | ?{if($_.PSIsContainer){$_.Name -ne $excludeItem -and (ls $_.FullName -Directory -Filter $excludeItem).Count -eq 0}else{$_.FullName -notmatch $excludeItem}} | rm -Recurse -Force -WhatIf\n \n```\n\n**解説**\n\nご質問の通りフォルダの`-Exclude`はできないので、とりあえず全ファイルを再帰的に取得します。\n\n```\n\n ls -Path $filePath -Recurse\n \n```\n\n単純に次のWhere-Object(エイリアスは`?{}`)でできそうと思いますが、サブフォルダの`$excludeItem`を考慮してくれません。 \nつまり`C:\\temp\\hoge\\処理済\\`が存在する場合でも、`C:\\temp\\hoge\\`を削除しようとするためNGです。\n\n```\n\n ls -Path $filePath -Recurse | ?{ $_.fullname -notmatch $excludeItem }\n \n```\n\nこれを回避するために、Where-Objectの中でフォルダとファイルに対する処理を分けました。\n\n```\n\n ?{\n if($_.PSIsContainer){\n # フォルダの場合、フォルダ名が $excludeItem ではない、かつ子フォルダに $excludeItem が一つも存在しない\n $_.Name -ne $excludeItem -and\n (ls $_.FullName -Directory -Filter $excludeItem).Count -eq 0\n }else{\n # ファイルの場合、フルパスに $excludeItem を含まない\n $_.FullName -notmatch $excludeItem\n }\n }\n \n```\n\n後は該当のファイルフォルダを削除します。(もちろん`-WhatIf`オプションがあるので実際には消えません)\n\n```\n\n | rm -Recurse -Force -WhatIf\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T12:13:14.823", "id": "86496", "last_activity_date": "2022-02-21T12:48:19.143", "last_edit_date": "2022-02-21T12:48:19.143", "last_editor_user_id": "9820", "owner_user_id": "9820", "parent_id": "86490", "post_type": "answer", "score": 1 }, { "body": "質問の内容を整理すると、\n\n```\n\n $filePath = 'C:\\temp\\'  # 削除対象フォルダ\n $excludeItem = '処理済' # 削除対象内で除外したいフォルダ\n \n```\n\nを前提に\n\n * `$filePath` 配下を再帰的に削除を行いたい\n * ただし、`$filePath` 直下にある `$excludeItem` 配下は削除から除外したい\n\nでしょうか。\n\n[`Get-ChildItem`](https://docs.microsoft.com/en-\nus/powershell/module/microsoft.powershell.management/get-\nchilditem?view=powershell-5.1) の `-Exclude` は 除外する名前を指定するもので、例えば `*.txt`\nは削除しない、など個々のファイル名に対する除外指定に使えます。今回のように特定のディレクトリ以下全てを除外する機能は持ちません。\n\n* * *\n\n「`$filePath` 配下を再帰的に削除」という発想を転換して\n\n * `$filePath` 直下のディレクトリ(ただし`$excludeItem`を除く)を再帰的に削除\n * `$filePath` 直下のファイルを削除\n\nと分けて考えれば、シンプルな記述ができそうです。具体的には\n\n```\n\n Get-ChildItem $filePath -Directory -Exclude $excludeItem | Remove-Item -Recurse\n Get-ChildItem $filePath -File | Remove-Item\n \n```\n\nでどうでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T23:10:23.813", "id": "86502", "last_activity_date": "2022-02-21T23:10:23.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "86490", "post_type": "answer", "score": 1 } ]
86490
null
86496
{ "accepted_answer_id": "86501", "answer_count": 1, "body": "オンプレミス版GitLabを導入したのですが、デフォルトで\"Name\"と\"Username\"が併記された状態になっています。 \n**\" Username\"のみを表示する設定は可能でしょうか?** \nよろしくお願いします。\n\n[![MyGitLab](https://i.stack.imgur.com/70CQ8.png)](https://i.stack.imgur.com/70CQ8.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T07:28:57.763", "favorite_count": 0, "id": "86492", "last_activity_date": "2022-02-21T15:51:39.677", "last_edit_date": "2022-02-21T07:42:14.353", "last_editor_user_id": "51541", "owner_user_id": "51541", "post_type": "question", "score": 0, "tags": [ "gitlab" ], "title": "オンプレミス版GitLabでUsernameのみを表示する方法はありますか?", "view_count": 66 }
[ { "body": "Username, Nameのどちらかを選択的に表示する機能は現在GitLabに存在せず、追加の要望が出ているとTwitterで教えていただきました。 \nこの場をお借りして感謝申し上げます。\n\n・GitLab Issue『Ability to show real names instead of username』 \n<https://gitlab.com/gitlab-org/gitlab/-/issues/17607>", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T15:51:39.677", "id": "86501", "last_activity_date": "2022-02-21T15:51:39.677", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51541", "parent_id": "86492", "post_type": "answer", "score": 1 } ]
86492
86501
86501
{ "accepted_answer_id": null, "answer_count": 1, "body": "Rx64 4.1.2でSteel-Dwass検定をする際、 \n「パッケージ」→「パッケージのインストール」→「Japan(Tokyo)」→「NSM3」 \nの指示通りにするが、Japanを選択以降、以下のメッセージが表示されてしまい、NSM3を選択出来ません。\n\n```\n\n utils:::menuInstallPkgs()\n --- このセッションで使うために、CRAN のミラーサイトを選んでください --- \n 警告: unable to access index for repository https://cran.ism.ac.jp/src/contrib:\n URL 'https://cran.ism.ac.jp/src/contrib/PACKAGES' を開けません \n install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) でエラー: \n 引数 \"pkgs\" がありませんし、省略時既定値もありません\n \n```\n\nファイアウォールの設定を見直したりしましたが、設定がうまく出来ていないのか進みません。\n\n```\n\n R version 4.1.2 (2021-11-01) -- \"Bird Hippie\"\n Copyright (C) 2021 The R Foundation for Statistical Computing\n Platform: x86_64-w64-mingw32/x64 (64-bit)\n \n```\n\n```\n\n > utils:::menuInstallPkgs()\n --- このセッションで使うために、CRAN のミラーサイトを選んでください --- \n 警告: unable to access index for repository https://cran.ism.ac.jp/src/contrib:\n URL 'https://cran.ism.ac.jp/src/contrib/PACKAGES' を開けません \n install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) でエラー: \n 引数 \"pkgs\" がありませんし、省略時既定値もありません \n > \n \n```\n\n#### スクリプト\n\n```\n\n # 以下のサイトを参考に作成した\n # https://jojoshin.hatenablog.com/entry/2016/05/29/222528\n # https://biolab.sakura.ne.jp/steel-dwass.html\n # 事前にNSM3パッケージをインストールすること\n # 「パッケージ」→「パッケージのインストール」→「Japan(Tokyo)」→「NSM3」\n # 一回だけやれば、次からはやる必要ありません\n \n rm(list=ls(all=TRUE))\n library(NSM3)\n # データの読み込み\n # データを入力したファイル名に応じて、下の行の「Kruskal-Wallis_data.csv」の部分を書き換えること\n data <- read.csv(\"Kruskal-Wallis_data.csv\", header=T)\n data\n summary(data)\n \n # Steel-Dwassの方法による多重比較\n # 3群以上を多重比較するノンパラメトリック検定です\n # 結果が表示されるまでに数分程度かかる場合があります\n # データを入力したファイルの1行目の内容を変えた場合、それに応じて下の行の「Y」と「X」を書き換えること\n # もしエラーが出るようなら、下の行の「method=\"Monte Carlo\"」を「method=\"Asymptotic\"」にする\n XX <- as.factor(data$X)\n pSDCFlig(data$Y, XX, method=\"Asymptotic\")\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T14:28:57.373", "favorite_count": 0, "id": "86498", "last_activity_date": "2023-06-22T11:03:10.423", "last_edit_date": "2022-02-21T16:16:52.737", "last_editor_user_id": "3060", "owner_user_id": "51545", "post_type": "question", "score": 0, "tags": [ "r" ], "title": "Rでパッケージのインストールでエラーが表示されてしまう", "view_count": 718 }
[ { "body": "CRAN のミラーサイトを「0-Cloud」で試してみてはいかがでしょうか? \n(試しにやってみましたがインストールできました)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T00:08:54.833", "id": "86504", "last_activity_date": "2022-02-22T00:08:54.833", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "50575", "parent_id": "86498", "post_type": "answer", "score": 0 } ]
86498
null
86504
{ "accepted_answer_id": null, "answer_count": 1, "body": "stripeの公式サンプルコードに型を当てているのですが、エラーが出力される。 \n型注釈は使用しているのですが、こちらはどのように型を当てたら良いのでしょうか?\n\nエラー内容\n\n```\n\n (parameter) paymentIntent: any\n Argument of type '({ paymentIntent }: PaymentIntent) => void' is not assignable to parameter of type '(value: PaymentIntentResult) => void | PromiseLike<void>'.\n Types of parameters '__0' and 'value' are incompatible.\n Type 'PaymentIntentResult' is not assignable to type 'PaymentIntent'.\n Type '{ paymentIntent: PaymentIntent; error?: undefined; }' is missing the following properties from type 'PaymentIntent': id, object, amount, canceled_at, and 16 more.ts(2345)\n Property 'paymentIntent' does not exist on type 'PaymentIntent'.ts(2339)\n \n```\n\nコード\n\n```\n\n import React, { useState, useEffect } from \"react\";\n // stripeのコンポーネントを読み込んでる\n import {\n PaymentElement,\n useStripe,\n useElements\n } from \"@stripe/react-stripe-js\";\n \n import { PaymentIntent } from \"@stripe/stripe-js\";\n \n \n // import { CardElementType } from './types/stripe'\n \n export default function CheckoutForm() {\n // 第一配列がデフォルトの値, 第二配列がそれを変更する関数が入る\n \n const stripe = useStripe();\n const elements = useElements();\n \n const [message, setMessage] = useState<string | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n \n type = Payme\n \n useEffect(() => {\n if (!stripe) {\n return;\n }\n \n //URLのクエリから値を取得する\n const clientSecret = new URLSearchParams(window.location.search).get(\n \"payment_intent_client_secret\"\n );\n \n // リダイレクト時にここに値が入る\n if (!clientSecret) {\n return;\n }\n \n stripe.retrievePaymentIntent(clientSecret).then(({ paymentIntent }: PaymentIntent) => {\n switch (paymentIntent.status) {\n case \"succeeded\":\n setMessage(\"Payment succeeded!\");\n break;\n case \"processing\":\n setMessage(\"Your payment is processing.\");\n break;\n case \"requires_payment_method\":\n setMessage(\"Your payment was not successful, please try again.\");\n break;\n default:\n setMessage(\"Something went wrong.\");\n break;\n }\n });\n }, [stripe]);\n \n const handleSubmit = async (e: { preventDefault: () => void; }) => {\n e.preventDefault();\n \n if (!stripe || !elements) {\n // Stripe.js has not yet loaded.\n // Make sure to disable form submission until Stripe.js has loaded.\n return;\n }\n \n setIsLoading(true);\n \n const { error } = await stripe.confirmPayment({\n elements,\n confirmParams: {\n // Make sure to change this to your payment completion page\n return_url: \"http://localhost:3000\",\n },\n });\n \n // This point will only be reached if there is an immediate error when\n // confirming the payment. Otherwise, your customer will be redirected to\n // your `return_url`. For some payment methods like iDEAL, your customer will\n // be redirected to an intermediate site first to authorize the payment, then\n // redirected to the `return_url`.\n if (error.type === \"card_error\" || error.type === \"validation_error\") {\n setMessage(error.message);\n } else {\n setMessage(\"An unexpected error occured.\");\n }\n \n setIsLoading(false);\n };\n \n return (\n <form id=\"payment-form\" onSubmit={handleSubmit}>\n <PaymentElement id=\"payment-element\" />\n <button disabled={isLoading || !stripe || !elements} id=\"submit\">\n <span id=\"button-text\">\n {isLoading ? <div className=\"spinner\" id=\"spinner\"></div> : \"Pay now\"}\n </span>\n </button>\n {/* Show any error or success messages */}\n {message && <div id=\"payment-message\">{message}</div>}\n </form>\n );\n }\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T14:49:26.840", "favorite_count": 0, "id": "86499", "last_activity_date": "2022-02-23T04:06:21.363", "last_edit_date": "2022-02-21T15:22:40.747", "last_editor_user_id": "22565", "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "javascript", "reactjs", "typescript" ], "title": "stripeのpaymentIntent.statusに上手く型が当てられない。", "view_count": 139 }
[ { "body": "渡されないパターンもあるってのを書いたらエラーは取れました。\n\n```\n\n useEffect(() => {\n if (!stripe) {\n return;\n }\n \n //URLのクエリから値を取得する\n const clientSecret = new URLSearchParams(window.location.search).get(\n \"payment_intent_client_secret\"\n );\n \n // リダイレクト時にここに値が入る\n if (!clientSecret) {\n return;\n }\n \n stripe.retrievePaymentIntent(clientSecret).then(({ paymentIntent }: PaymentIntentResult) => {\n switch (paymentIntent?.status) {\n case \"succeeded\":\n setMessage(\"Payment succeeded!\");\n break;\n case \"processing\":\n setMessage(\"Your payment is processing.\");\n break;\n case \"requires_payment_method\":\n setMessage(\"Your payment was not successful, please try again.\");\n break;\n default:\n setMessage(\"Something went wrong.\");\n break;\n }\n });\n }, [stripe]);\n \n```\n\n### 参照\n\n[Cannot invoke an object which is possibly ‘undefined’.](https://omkz.net/en-\nerror-typescript-cannot-invoke/)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-23T04:06:21.363", "id": "86526", "last_activity_date": "2022-02-23T04:06:21.363", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22565", "parent_id": "86499", "post_type": "answer", "score": 0 } ]
86499
null
86526
{ "accepted_answer_id": null, "answer_count": 1, "body": "Spresenseのドキュメントに \n「Sleep 中の消費電力に関して、拡張ボードに SD カードが挿入されていると SD カードの電源消費分により 約 5 mA ほど消費電流が増加します。」 \nとあります。\n\nSleep時の消費電流を減らすために、SDカードへの給電をON,OFFできるArduinoのコードがありましたら教えてください。\n\n宜しくお願い致します。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-21T23:32:44.093", "favorite_count": 0, "id": "86503", "last_activity_date": "2022-02-23T06:40:32.583", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "50575", "post_type": "question", "score": 0, "tags": [ "spresense" ], "title": "拡張ボードのSDカードへの給電のオン、オフ", "view_count": 141 }
[ { "body": "あまり参考になるか分かりませんが、速度を気にしないならSPIでSDカードに記録する方法もあります。昔、メインボード用のアドオンボードをユニバーサル基板で自作したことがあります。一応ライブラリも用意しています(ライブラリは個人利用のために作ったものですので、デバッグが不十分な可能性があります。ご使用は自己責任にてお願いします。)\n\n<https://github.com/YoshinoTaro/SPISD-for-SpresenseMainboard>\n\nsleep中の消費電力は、SDカードへの電源供給ラインの間にスイッチ用のFET等を追加して、GPIOで電源制御すれば抑えられると思います。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-23T06:40:32.583", "id": "86529", "last_activity_date": "2022-02-23T06:40:32.583", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27334", "parent_id": "86503", "post_type": "answer", "score": 0 } ]
86503
null
86529
{ "accepted_answer_id": null, "answer_count": 0, "body": "Unityで開発しております。 \nJsonファイルを使用してデータの保存・読み込みを行っております。\n\nこちらデータ量がかなり多くなり、ファイルサイズが110MBほどになっており、 \nこれを\n\n```\n\n data = new HogeData();\n JsonUtility.FromJsonOverwrite( jsonFile, data );\n \n```\n\nといったUnityの基本的な形での変換処理で読み込みを行っております。 \nファイルサイズが大きいためこの処理だけで2.7秒ほどかかっており、 \n読み込み時間を早くしたいと考えております。 \nIDによって参照先のJsonファイルを切り替えていくプロジェクトなため読み込み処理を呼び出すタイミングが多く、 \n部分読み込みや非同期による読み込みが出来ればと考えております。\n\n何か方法などありますでしょうか。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T00:10:58.643", "favorite_count": 0, "id": "86505", "last_activity_date": "2022-02-22T00:10:58.643", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29606", "post_type": "question", "score": 0, "tags": [ "json", "unity2d" ], "title": "JsonUtility.FromJsonOverwriteの高速化を行いたい", "view_count": 143 }
[]
86505
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "日本語訳すると「パラメーター \"MoveSpeed\"\nは存在しません。」ということだと思いますが、似たようなエラーでよくあるスクリプトのタイプミスなどは確認しました。 \n移動スピードをanimatorに反映させるためのスクリプトです。何卒よろしくお願いします。\n\n**エラー本文**\n\n```\n\n Parameter 'MoveSpeed' does not exist.\n UnityEngine.Animator:SetFloat (string,single)\n PlayerController:Update () (at Assets/iigeemu/script/PlayerController.cs:51)\n \n```\n\n**ソースコード**\n\n```\n\n using System.Collections;\n using System.Collections.Generic;\n using UnityEngine;\n \n public class PlayerController : MonoBehaviour\n {\n [SerializeField] private Animator animator;\n [SerializeField] private float moveSpeed = 10;\n [SerializeField] private float jumpPower = 3;\n private CharacterController _characterController;\n \n private Transform _transform;\n private Vector3 _moveVelocity;\n private Transform _transform;\n private Vector3 _moveVelocity;\n \n // Start is called before the first frame update\n void Start()\n {\n _characterController = GetComponent<CharacterController>();\n \n _transform = transform;\n }\n \n // Update is called once per frame\n void Update() {\n {\n Debug.Log(_characterController.isGrounded ? \"地上にいます\" : \"空中です\");\n \n \n _moveVelocity.x = Input.GetAxis(\"Horizontal\") * moveSpeed;\n _moveVelocity.z = Input.GetAxis(\"Vertical\") * moveSpeed;\n \n _transform.LookAt(_transform.position + new Vector3(_moveVelocity.x, 0, _moveVelocity.z));\n if (_characterController.isGrounded)\n {\n if (Input.GetButtonDown(\"Jump\"))\n {\n \n Debug.Log(\"ジャンプ!\");\n _moveVelocity.y = jumpPower;\n }\n }\n else\n {\n \n _moveVelocity.y += Physics.gravity.y * Time.deltaTime;\n }\n \n _characterController.Move(_moveVelocity * Time.deltaTime);\n }\n \n animator.SetFloat(\"MoveSpeed\", new Vector3(_moveVelocity.x, 0,_moveVelocity.z).magnitude);\n }\n } \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T02:24:50.037", "favorite_count": 0, "id": "86506", "last_activity_date": "2022-02-23T03:26:58.090", "last_edit_date": "2022-02-22T02:52:12.230", "last_editor_user_id": "3060", "owner_user_id": "51552", "post_type": "question", "score": 0, "tags": [ "unity3d" ], "title": "unityで Parameter 'MoveSpeed' does not exist. というエラーが出ます!", "view_count": 1818 }
[ { "body": "Animaor.SetFloat() メソッドは Animator コンポーネントを通じて(Animator\nコンポーネントにアサインされている)Animator Controller アセットにパラメーターを渡すメソッドです。\n\n該当のエラーによってわかることは、現在対象となっている Animator Controller に該当のパラメーターが存在していない、ということです。\n\nあとは、パラメーター名を間違えたならそれを直すなり、Animator Controller のパラメーターを追加するなり適宜修正すればよいです。\n\n### 参照\n\n * [Unity ユーザーマニュアル - アニメーションパラメーター](https://docs.unity3d.com/ja/2020.3/Manual/AnimationParameters.html)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T16:47:00.770", "id": "86518", "last_activity_date": "2022-02-22T17:21:29.877", "last_edit_date": "2022-02-22T17:21:29.877", "last_editor_user_id": "48297", "owner_user_id": "48297", "parent_id": "86506", "post_type": "answer", "score": 2 }, { "body": "animator.SetFloat(\"MoveSpeed\" のSpeed→speedに小文字変換したらどうでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-23T03:26:58.090", "id": "86525", "last_activity_date": "2022-02-23T03:26:58.090", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51570", "parent_id": "86506", "post_type": "answer", "score": 0 } ]
86506
null
86518
{ "accepted_answer_id": null, "answer_count": 1, "body": "動画を参考に、Pythonを用いたtodolistのwebアプリ開発講座において、以下のコード (app.py) を作成し、\n\n```\n\n >>> from app import db\n >>> db.create_all()\n \n```\n\nのコマンドを打つことでデータベースの作成を行いたいのですが、何度やってもうまくいきません。(動画では18分目ぐらいからの内容)\n\n**参考にした動画:** \n[Python(Flask)×Webアプリ開発入門コース\n(YouTube)](https://www.youtube.com/watch?v=jP7p2okKdJA)\n\n### 気になる点\n\n以下に示すapp.pyにおいて「Column」「Integer」「String」「DateTime」において\n\n**クラス 'SQLAlchemy' の未解決の属性参照 'Column' **\n\nが警告文として出ている点が原因かなと思いました。\n\n### 試したこと\n\n * 警告文の検索\n * SQLAlchemyのバージョンを下げて再インストール(1.3.20よりバージョンが上では通らないことがあるため)\n\n### バージョン\n\neditor:pycharm \ninterpreter:3.8 \nOS:windows10 \nSQLAlchemy:1.3.20\n\nどうぞよろしくお願いいたします。\n\n* * *\n\n### ソースコード\n\n**app.py**\n\n```\n\n from flask import Flask, render_template\n from flask_sqlalchemy import SQLAlchemy\n \n app = Flask(__name__)\n app.config[\"SQLALCHEMY_DATABASE_URI\"] = \"sqlite:///todo.db\"\n db = SQLAlchemy(app)\n \n \n class Post(db.Model):\n id = db.Column(db.Integer, primary_key=True)\n title = db.Column(db.String(30), nullable=False)\n detail = db.Column(db.String(100))\n due = db.Column(db.DateTime, nullable=False)\n \n \n @app.route(\"/\")\n def index():\n return render_template(\"index.html\")\n \n \n if __name__ == \"__main__\":\n app.run(debug=True)\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T04:40:03.960", "favorite_count": 0, "id": "86508", "last_activity_date": "2023-05-04T06:02:35.370", "last_edit_date": "2022-02-22T08:18:21.060", "last_editor_user_id": "3060", "owner_user_id": "51554", "post_type": "question", "score": 0, "tags": [ "python", "sql", "database", "flask", "sqlalchemy" ], "title": "db.create_all()を用いたデータベースの作成が出来ない", "view_count": 1133 }
[ { "body": "質問に書かれているYouTube動画と同等の、コメントで紹介した以下の記事に従って作業しましたが、質問に書かれた段階(5-2|データベースの項目定義のターミナル:Python対話型シェルによるデータベースの作成)の作業は正常に出来ています。 \n[【保存版】30分でFlask入門!Webアプリの作り方をPythonエンジニアが解説](https://tech-diary.net/flask-\nintroduction/)\n\n質問との環境の違いは以下の物になるでしょう。\n\nPyCharm: 使っていない \nPython版数: 3.10.2 \nOS: 同じもの \nSQLAlchemy: 1.4.31\n\n`app.py`の違いは文字列を示すのが`'`で囲むか`\"`で囲むかの違いだけです。試しに質問のソースコードと同じものに変えてみましたが、そちらも正常に動作しました。\n\nその他も含めたモジュール一覧が以下になります。\n\n```\n\n Package Version\n ---------------- -------\n click 8.0.4\n colorama 0.4.4\n Flask 2.0.3\n Flask-SQLAlchemy 2.5.1\n greenlet 1.1.2\n itsdangerous 2.1.0\n Jinja2 3.0.3\n MarkupSafe 2.1.0\n pip 22.0.3\n setuptools 60.9.3\n SQLAlchemy 1.4.31\n Werkzeug 2.0.3\n wheel 0.37.1\n \n```\n\n作業時に出ていた`app.py`から`db`をimportした時の警告は以下になり、質問の「気になる点」や紹介記事での表示とも違ったものになっています。しかし`db.create_all()`は正常に終了しています。\n\n```\n\n C:\\Develop\\Python\\vFLSK\\lib\\site-packages\\flask_sqlalchemy\\__init__.py:872: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.\n warnings.warn(FSADeprecationWarning(\n \n```\n\n他にはPyCharm使用有無くらいでしょうか。 \nPython版数の違いは記事のPythonが3.7.3であることを考えると特に問題とは思えません。\n\nここまでの作業では、「SQLAlchemyのバージョンを下げて再インストール(1.3.20よりバージョンが上では通らないことがあるため)」というのが何かの誤解なのかもしれません。\n\n試しに`SQLAlchemy`の版数を最新のものに変えてみてはどうでしょう?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-23T10:44:13.157", "id": "86534", "last_activity_date": "2022-02-23T10:44:13.157", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "86508", "post_type": "answer", "score": 0 } ]
86508
null
86534
{ "accepted_answer_id": null, "answer_count": 1, "body": "Flutterでアプリ開発をするのにAndroid Studioを使用しています。 \nAndroid StudioのUpdateを行ったところ、新規プロジェクトを作成する際や、既存のプロジェクトを開いた際など、 \n今まで、Project内のlibフォルダがデフォルトで表示されていたのですが、Androidがデフォルトの設定になってしまい困っています。 \nProjectに変更することはできるのですが、いちいち変更を直すのが嫌です。 \nProjectをデフォルトにする方法がありましたら、お教えください。よろしくお願いします。[![画像の説明をここに入力](https://i.stack.imgur.com/mNWgO.png)](https://i.stack.imgur.com/mNWgO.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T05:39:54.550", "favorite_count": 0, "id": "86509", "last_activity_date": "2023-01-19T14:28:17.360", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "39681", "post_type": "question", "score": 2, "tags": [ "android-studio", "flutter" ], "title": "Android Studioで初めに表示させるファイルがAndroidになってしまったのを、Projectに直したい。", "view_count": 220 }
[ { "body": "AndroidStudioを、前回のプロジェクトを開くにしておくと、 \nAndroidStudioを閉じる際に一番最後に保存した内容で次回開かれるので、 \n初期設定にもよりますが、 \n閉じる時にprojectにした状態で保存して閉じたらいかがでしょう?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2023-01-19T14:28:17.360", "id": "93460", "last_activity_date": "2023-01-19T14:28:17.360", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "56672", "parent_id": "86509", "post_type": "answer", "score": 0 } ]
86509
null
93460
{ "accepted_answer_id": null, "answer_count": 1, "body": "左下の「削除」を消したいのですが方法がわかりません。 \nまた、カレンダーの祝日を赤文字で表示もわかりません。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/f5IED.png)](https://i.stack.imgur.com/f5IED.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T07:35:45.493", "favorite_count": 0, "id": "86512", "last_activity_date": "2022-02-22T08:11:37.913", "last_edit_date": "2022-02-22T08:11:37.913", "last_editor_user_id": "3060", "owner_user_id": "51556", "post_type": "question", "score": 0, "tags": [ "html", "css" ], "title": "input date の日付ピッカーの表示をカスタマイズしたい", "view_count": 3467 }
[ { "body": "残念ながら`<input type=\"date\">`の質問中にあるようなものも含めてカスタマイズはほとんどできません。\n\n[ input\ntype=\"date\"](https://developer.mozilla.org/ja/docs/Web/HTML/Element/input/date)\n\n[HTMLStandard 4.10.5.1.7 Date state\n(type=date)](https://html.spec.whatwg.org/multipage/input.html#date-\nstate-\\(type=date\\)) \nできることは参考のリンクを確認してください。\n\nこれ自体はHTMLの規格であるもの、カレンダーや入力のUIとしてこうあるべきであるという制約はなく、それぞれのブラウザで開発されておりUIもそろっていません。また見た目やレイアウトの変更も残念ながらできないものになっています。\n\nそのため日付の入力補助のためにJavascriptライブラリを導入することが一般的で \n「datepicker」と呼ばれるものがたくさん世の中にあります。 \n※例えば[Datepciker|jQueryUI](https://jqueryui.com/datepicker/)といったものがあります \nライブラリの日付入力はカスタマイズが可能なことも多く、できることがおおいです。 \nご自身の要件にあったライブラリを探してみるとよいでしょう。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T07:54:39.110", "id": "86513", "last_activity_date": "2022-02-22T07:54:39.110", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22665", "parent_id": "86512", "post_type": "answer", "score": 2 } ]
86512
null
86513
{ "accepted_answer_id": null, "answer_count": 0, "body": "raspberry pi zeroにtensorflow liteを入れて画像分類をしたいです.ラズパイのOSはRaspian\nBullseyeで,アーキテクチャがarmv6lです.\n\nこのtensorflow/examplesの中の[リポジトリ](https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/raspberry_pi)のclassify.pyを実行できるようにしたいです.\n\nその準備として[このページ](https://github.com/tensorflow/tensorflow/issues/38642#issuecomment-988572129)にあるtflite_runtime-2.7.0-cp39-cp39-linux_armv6l.whlをラズパイにインストールしました.\n\nそして,`setup.sh`を実行しました. \nしかし,以下の点で詰まってしまっています.解決方法があれば教えていただきたいです.\n\nrequirements.txtにあるtflite_support>=0.3.1のarmv6lに対応するものがpipからインストールできない\n\n```\n\n ERROR: Could not find a version that satisfies the requirement tflite-support>=0.3.1 (from versions: 0.1.0a0.dev3, 0.1.0a0.dev4, 0.1.0a0.dev5, 0.1.0a0, 0.1.0a1)\n ERROR: No matching distribution found for tflite-support>=0.3.1\n \n```\n\nそのため,次のようなエラーが出てしまいます\n\n```\n\n pi@raspberrypi:~/tf_examples/lite/examples/image_classification/raspberry_pi $ python classify.py \n Traceback (most recent call last):\n File \"/home/pi/tf_examples/lite/examples/image_classification/raspberry_pi/classify.py\", line 149, in <module>\n main()\n File \"/home/pi/tf_examples/lite/examples/image_classification/raspberry_pi/classify.py\", line 143, in main\n run(args.model, int(args.maxResults), int(args.numThreads),\n File \"/home/pi/tf_examples/lite/examples/image_classification/raspberry_pi/classify.py\", line 52, in run\n classifier = ImageClassifier(model, options)\n File \"/home/pi/tf_examples/lite/examples/image_classification/raspberry_pi/image_classifier.py\", line 113, in __init__\n label_map_file = displayer.get_associated_file_buffer(file_name).decode()\n AttributeError: 'MetadataDisplayer' object has no attribute 'get_associated_file_buffer'\n \n```\n\nこのエラーが出た時の諸々のバージョンは以下の通りです\n\n```\n\n >>> import tflite_support as tls\n >>> tls.__version__\n '0.1.0a1'\n >>> import numpy as np\n >>> np.__version__\n '1.22.2'\n >>> import tflite_runtime as tf\n >>> tf.__version__\n '2.7.0'\n >>> import cv2\n >>> cv2.__version__\n '4.5.3'\n \n```\n\n(以下補足) \nまた,tensorflow\nliteのビルドは[こちら](https://www.tensorflow.org/lite/guide/build_cmake_pip#arm_cross_compilation)の手順で,ローカル(M1mac上)でdockerのplatformの指定をlinux/amd64に指定したのと,x86のマシン(AWSのEC2)でも行ったことがありますが,どちらも\n\n```\n\n [ 10%] Linking CXX static library libruy_apply_multiplier.a\n \n```\n\nというステップで止まってしまいます([ソースコード](https://github.com/tensorflow/tensorflow/blob/d5757d0923f95c8f9371320cfbdf5a925701fdcb/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh#L125)の125行目を実行している最中です).ソースコードでは,numpy~=1.19.2が指定されているみたいです.\n\n最新版でなくても画像分類が動けばなんでもいいので,過去のものから動くバージョンを探すのが一番いいのでしょうか.膨大なコミットの中からどうやって探せばいいのかわからないですが…\n\n同じようなことをしている方がネット上にいましたが,こんなに上手くいかないです... \n<https://zenn.dev/kenichiro90/articles/9ec36d57609068> \n<https://qiita.com/moritalous/items/bcc49610843968674731> \n<https://scrapbox.io/koudenpa/Raspberry_Pi_Zero%2F%E7%89%A9%E4%BD%93%E8%AA%8D%E8%AD%98> \n<https://asukiaaa.blogspot.com/2018/03/raspberry-pizeropicamera096lcd.html>", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T08:36:19.393", "favorite_count": 0, "id": "86514", "last_activity_date": "2022-02-22T08:36:19.393", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "51557", "post_type": "question", "score": 2, "tags": [ "opencv", "tensorflow", "raspberry-pi", "cmake" ], "title": "Rapberry pi zeroにtensorflow liteをインストールし,物体認識をしたい", "view_count": 326 }
[]
86514
null
null
{ "accepted_answer_id": "86521", "answer_count": 2, "body": "matplotlibでグラフを作っているとxlim, ylim, xticks,\ngridなどなど色々な設定を加えているためaxisの数が増えれば増えるほどコード量が長くなります。例えば\n\n```\n\n fig = plt.figure(figsize=(11.69, 8.27), tight_layout=True)\n ax1 = fig.add_subplot(4, 2, 1)\n ax2 = fig.add_subplot(4, 2, 2)\n ax3 = fig.add_subplot(4, 2, 3)\n ax4 = fig.add_subplot(4, 2, 4)\n ax5 = fig.add_subplot(4, 2, 5)\n ax6 = fig.add_subplot(4, 2, 6)\n ax7 = fig.add_subplot(4, 2, 7)\n ax8 = fig.add_subplot(4, 2, 8)\n x = df.index\n \n ax1.scatter(x[0:2], df.iloc[0:2, [0]])\n ax1.scatter(x[0:2], df.iloc[0:2, [0]])\n ax1.set_ylim(9, 15, 3)\n ax1.set_xlim(-0.3, 0.3)\n ax1.set_xticks([0, 1])\n ax1.set_xticklabels(x[0:2])\n ax1.grid(which='major', axis='y', linestyle='--')\n ax1.grid(which='major', axis='x', linestyle='--')\n \n ax2.scatter(x[1:3], df.iloc[1:3, [0]])\n ax2.scatter(x[1:3], df.iloc[1:3, [0]])\n ax2.set_ylim(9, 15, 3)\n ax2.set_xlim(-0.3, 0.3)\n ax2.set_xticks([0, 1])\n ax2.set_xticklabels(x[1:3])\n ax2.grid(which='major', axis='y', linestyle='--')\n ax2.grid(which='major', axis='x', linestyle='--')\n 以下略\n \n```\n\nといったように一つグラフを作るだけでかなりの行数となり汚いなあと感じております。 \nこうしたら書きやすいよ、ここは改善できそうなどご意見ありましたらお願いいたします。\n\n補足ですが、dfのx軸にあたるところは時系列ではなく文字列です。 \n何もせずにx軸に設定すると初めと終わりの目盛りが端によってしまうので、xlim, xticks, xticklabelsをつかって気持ち中央に寄せています。\n\nよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T09:01:57.130", "favorite_count": 0, "id": "86515", "last_activity_date": "2022-02-25T04:20:44.873", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "48769", "post_type": "question", "score": 0, "tags": [ "python", "matplotlib" ], "title": "matplotlibのコード量は減らせないのか?アドバイスを頂きたいです", "view_count": 164 }
[ { "body": "これは matplotlib\nに限った話ではなく一般的な話として、複数の規則的なデータを扱うときには配列と繰り返しが便利です。また、似たような処理を繰り返すときには関数が便利です。\n\n`ax1` から `ax8` までは `add_subplot` に渡す引数が規則的に異なっているだけなので、`axes`\nみたいな名前の配列にまとめることができるでしょう。\n\nまたそれぞれの軸に対する微調整も、同じ処理をしている部分については関数にまとめれば簡潔になりそうです。軸個別に微調整を加えている部分があるので、すべてを関数にまとめるのではなく一部に留めた方が便利でしょう。\n\nただまあ、見た目の調整というのは得てして 1\n回しか動かさないアドホックなスクリプトになりがちなので、そんなにメンテナンスしないコードであれば今のようなベタ書きでも個人的にはそこまで気になりません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T23:55:17.473", "id": "86521", "last_activity_date": "2022-02-22T23:55:17.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "86515", "post_type": "answer", "score": 3 }, { "body": "例えば\n\n```\n\n fig, axes = plt.subplots(4, 2, figsize=(11.69, 8.27), tight_layout=True)\n \n for i, ax in enumerate(axes):\n # 共通の処理\n slicer = slice(i+0, i+2)\n ax.scatter(x[slicer], df.iloc[slicer, [0]])\n ax.set_ylim(9, 15, 3)\n ax.set_xlim(-0.3, 0.3)\n # ……\n \n # 個別の処理\n if i == 0:\n # ……\n elif i == 1:\n # ……\n \n```\n\nみたいな感じですかね?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-25T04:20:44.873", "id": "86568", "last_activity_date": "2022-02-25T04:20:44.873", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "37167", "parent_id": "86515", "post_type": "answer", "score": 0 } ]
86515
86521
86521
{ "accepted_answer_id": null, "answer_count": 2, "body": "KeyCode.Wを押してから徐々にAudioSource.volumeを `3f` まで上げて行きたいのですが \n現状のコードではフリーズしてしまいます。\n\nどのようにすればよいでしょうか?\n\n```\n\n using System.Collections;\n using System.Collections.Generic;\n using UnityEngine;\n \n public class PlayerManager : MonoBehaviour\n {\n private AudioSource audioSource;\n private float volumeWhile = 3f;\n \n void Start()\n {\n \n audioSource = GetComponent<AudioSource>();\n }\n // Update is called once per frame\n void Update()\n { \n if (Input.GetKey(KeyCode.W))\n {\n if (!audioSource.isPlaying)\n {\n while (audioSource.volume < volumeWhile)\n {\n audioSource.Play();\n audioSource.volume += 0.5f;\n \n if (audioSource.volume == volumeWhile) break;\n }\n }\n }\n if (Input.GetKeyUp(KeyCode.W))\n {\n audioSource.Stop();\n }\n }\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T11:14:26.627", "favorite_count": 0, "id": "86516", "last_activity_date": "2022-02-22T17:18:35.977", "last_edit_date": "2022-02-22T12:30:48.570", "last_editor_user_id": "3060", "owner_user_id": "51562", "post_type": "question", "score": 0, "tags": [ "c#", "unity3d" ], "title": "キーを押してから徐々にボリュームを上げていく方法がわかりません", "view_count": 114 }
[ { "body": "`while` 文が `break` する条件で「目標の値になったら」ということで `==` での比較を行っていますが、浮動小数点同士の比較なので演算\n(ここではインクリメント) をしていく過程で **誤差** が発生している可能性があります。\n\n代わりに「目標の値を超えたら」にしてみると良いかもしれません。\n\n```\n\n if (audioSource.volume >= volumeWhile) break;\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T12:37:12.153", "id": "86517", "last_activity_date": "2022-02-22T12:37:12.153", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "86516", "post_type": "answer", "score": 0 }, { "body": "[【Unity】キーを押してから徐々にボリュームを上げていく方法がわかりません。](https://teratail.com/questions/e32vuboauda7xj)\nではコルーチンでないものを使って問題がクローズされているので、こちらに書いておきます。なお、[AudioSource.volume の最大値は\n1](https://docs.unity3d.com/ja/2019.4/ScriptReference/AudioSource-volume.html)\nです。\n\n```\n\n using System.Collections;\n using UnityEngine;\n \n public class PlayerManager : MonoBehaviour\n {\n [SerializeField] float _changeVolumeDelta = 0.001f;\n [SerializeField] float _changeVolumeIntervalSecond = 0.1f;\n [SerializeField] float _maxVolume = 1;\n AudioSource _audio = default;\n Coroutine _coroutine = default;\n \n void Start()\n {\n _audio = GetComponent<AudioSource>();\n }\n \n void Update()\n {\n if (Input.GetKeyDown(KeyCode.W))\n {\n // 音が「流れていない」時\n if (!_audio.isPlaying)\n {\n if (_coroutine != null)\n {\n _coroutine = StartCoroutine(IncreaseVolume(_maxVolume));\n }\n }\n }\n \n // ↓を押している間、ボリュームを下げる\n if (Input.GetKeyDown(KeyCode.DownArrow))\n {\n _coroutine = StartCoroutine(DecreaseVolume());\n }\n else if (Input.GetKeyUp(KeyCode.DownArrow))\n {\n StopCoroutine(_coroutine);\n }\n }\n \n IEnumerator IncreaseVolume(float target)\n {\n while (_audio.volume < target)\n {\n _audio.volume += _changeVolumeDelta;\n yield return new WaitForSeconds(_changeVolumeIntervalSecond);\n }\n }\n \n IEnumerator DecreaseVolume()\n {\n while (_audio.volume > 0)\n {\n _audio.volume -= _changeVolumeDelta;\n yield return new WaitForSeconds(_changeVolumeIntervalSecond);\n }\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T17:18:35.977", "id": "86519", "last_activity_date": "2022-02-22T17:18:35.977", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "48297", "parent_id": "86516", "post_type": "answer", "score": 0 } ]
86516
null
86517
{ "accepted_answer_id": null, "answer_count": 1, "body": "このエラーの対処が分からず、困っています。 \n教えて欲しいです。\n\n【エラー】\n\n```\n\n 0%| | 0/2 [00:00<?, ?it/s]0\n 0%| | 0/2 [00:06<?, ?it/s]\n ---------------------------------------------------------------------------\n LookupError Traceback (most recent call last)\n /usr/local/lib/python3.7/dist-packages/sumy/nlp/tokenizers.py in _get_sentence_tokenizer(self, language)\n 126 path = to_string(\"tokenizers/punkt/%s.pickle\") % to_string(language)\n --> 127 return nltk.data.load(path)\n 128 except (LookupError, zipfile.BadZipfile) as e:\n \n 5 frames\n LookupError: \n **********************************************************************\n Resource punkt not found.\n Please use the NLTK Downloader to obtain the resource:\n \n >>> import nltk\n >>> nltk.download('punkt')\n \n Searched in:\n - '/root/nltk_data'\n - '/usr/share/nltk_data'\n - '/usr/local/share/nltk_data'\n - '/usr/lib/nltk_data'\n - '/usr/local/lib/nltk_data'\n - '/usr/nltk_data'\n - '/usr/lib/nltk_data'\n - ''\n **********************************************************************\n \n \n During handling of the above exception, another exception occurred:\n \n LookupError Traceback (most recent call last)\n /usr/local/lib/python3.7/dist-packages/sumy/nlp/tokenizers.py in _get_sentence_tokenizer(self, language)\n 130 \"NLTK tokenizers are missing or the language is not supported.\\n\"\n 131 \"\"\"Download them by following command: python -c \"import nltk; nltk.download('punkt')\"\\n\"\"\"\n --> 132 \"Original error was:\\n\" + str(e)\n 133 )\n 134 \n \n LookupError: NLTK tokenizers are missing or the language is not supported.\n Download them by following command: python -c \"import nltk; nltk.download('punkt')\"\n Original error was:\n \n **********************************************************************\n Resource punkt not found.\n Please use the NLTK Downloader to obtain the resource:\n \n >>> import nltk\n >>> nltk.download('punkt')\n \n Searched in:\n - '/root/nltk_data'\n - '/usr/share/nltk_data'\n - '/usr/local/share/nltk_data'\n - '/usr/lib/nltk_data'\n - '/usr/local/lib/nltk_data'\n - '/usr/nltk_data'\n - '/usr/lib/nltk_data'\n - ''\n **********************************************************************\n \n```\n\n【コード】\n\n```\n\n #@title\n import requests\n import json\n import csv\n import pytz\n import datetime\n import tqdm\n import numpy as np\n \n from selenium import webdriver\n from selenium.webdriver.common.keys import Keys\n from selenium.webdriver.common.by import By\n from time import sleep\n \n from google.colab import files\n \n ##############\n ### DEFINE ###\n ##############\n #KEYWORD = \"福祉\"\n #SLEEP_TIME = 0.5\n \n url = 'https://api.jgrants-portal.go.jp/exp/v1/public/subsidies?keyword=' + keyword + '&sort=created_date&order=DESC&acceptance=1'\n req = requests.get(url)\n reqJSON = json.loads(req.text)\n \n # resultデータのループ\n csvList = []\n ID = []\n for i in tqdm.tqdm(range(len(reqJSON[\"result\"]))):\n # tqdm\n np.pi*np.pi\n if i % 1e6 == 0:\n print(i)\n \n # csv書き込み用リストにヘッダー行を追加\n resultData=reqJSON[\"result\"][i]\n csvRow = []\n csvRow.append(resultData[\"title\"])\n csvRow.append(resultData[\"id\"])\n csvRow.append(resultData[\"acceptance_start_datetime\"])\n csvRow.append(resultData[\"acceptance_end_datetime\"])\n csvRow.append(resultData[\"subsidy_max_limit\"])\n csvRow.append(resultData[\"target_area_search\"])\n csvRow.append(resultData[\"target_number_of_employees\"])\n \n # selenium,Chromedriverの定義\n options = webdriver.ChromeOptions()\n options.add_argument('--headless')\n options.add_argument('--no-sandbox')\n options.add_argument('--disable-dev-shm-usage')\n wd = webdriver.Chrome('chromedriver',options=options)\n \n # IDに格納したIDリストをもとにHPを開けてスクレイピング\n tURL = \"https://www.jgrants-portal.go.jp/subsidy/\" + resultData[\"id\"]\n wd.get(tURL)\n sleep(sleep_time)\n detail = wd.find_element(by=By.TAG_NAME, value=\"table\").text\n \n # Load Packages\n from sumy.parsers.plaintext import PlaintextParser\n from sumy.nlp.tokenizers import Tokenizer\n # For Strings\n parser = PlaintextParser.from_string(detail,Tokenizer(\"english\"))\n from sumy.summarizers.text_rank import TextRankSummarizer\n # Summarize using sumy TextRank\n summarizer = TextRankSummarizer()\n summary =summarizer_4(parser.document,2)\n text_summary=\"\"\n for sentence in summary:\n text_summary+=str(sentence)\n print(text_summary)\n \n # csv書き込み用リストに詳細を追加\n csvRow.append(detail)\n csvRow.append(text_summary)\n \n # tURLを追加\n csvRow.append(tURL)\n \n # 1行を1要素として配列に保存\n csvList.append(csvRow)\n \n wd.close()\n \n # 新規CSVファイルの作成\n csv_date = datetime.datetime.now(pytz.timezone('Asia/Tokyo')).strftime(\"%Y%m%d\")\n csv_file_name = ( keyword + \"jGrants\" + csv_date + \".csv\")\n f = open(csv_file_name, \"w\", encoding=\"Shift-jis\", errors=\"ignore\")#windowsの場合encoding=Shift-js\n \n # csvファイルへの書き込み\n writer = csv.writer(f, lineterminator=\"\\n\") \n csv_header = [\"タイトル\",\"ID\",\"開始日\",\"終了日\",\"金額の上限\",\"対象地域\",\"対象となる従業員数\",\"詳細\",\"要約\",\"URL\"]\n writer.writerow(csv_header)\n for csvData in csvList:\n writer.writerow(csvData)\n f.close()\n \n # csvファイル出力\n files.download(csv_file_name)\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-22T21:36:22.987", "favorite_count": 0, "id": "86520", "last_activity_date": "2022-02-23T17:47:37.337", "last_edit_date": "2022-02-22T23:56:33.413", "last_editor_user_id": "19110", "owner_user_id": "50721", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "pythonにおける要約のプログラムのエラー: Resource punkt not found", "view_count": 602 }
[ { "body": "@payaneco\nさんがコメントされたように、[NLTK環境を構築する](https://qiita.com/ldap2017/items/158a9aa5ec330e907197)で解説されている`python\n-c \"import nltk; nltk.download()\"`を実行することで質問のエラーは発生しなくなるようです。 \nWindows10の環境で確認しました。\n\nちなみにWindows10なので`from google.colab import\nfiles`と`files.download(csv_file_name)`はコメントアウトしています。\n\n* * *\n\nそして他にはコメントアウトされていた以下2行のコメントを外し、変数名を小文字にする必要がありました。こちらを:\n\n```\n\n #KEYWORD = \"福祉\"\n #SLEEP_TIME = 0.5\n \n```\n\nこちらに変更しました。\n\n```\n\n keyword = \"福祉\"\n sleep_time = 0.5\n \n```\n\n* * *\n\nさらに、以下に抜粋した下の行の`summarizer_4`は質問時の転記ミスか何かの様で、そのような名前は無いとエラーになったので`summarizer`としたら動作しました。\n\n```\n\n summarizer = TextRankSummarizer()\n summary =summarizer_4(parser.document,2)\n \n```\n\n* * *\n\nなお、プログラムの途中で import している`sumy`というパッケージが更に内部で import しているパッケージの機能(`from\ncollections import Sequence`だったか)が原因で、Python 3.8 以後では動作しないようです。(少なくともPython\n3.10では動きませんでした。それ以前では警告で済むのかもしれませんね)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-23T17:42:12.157", "id": "86541", "last_activity_date": "2022-02-23T17:47:37.337", "last_edit_date": "2022-02-23T17:47:37.337", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "86520", "post_type": "answer", "score": 1 } ]
86520
null
86541