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": "macOSのzshでシェルススクリプトを書いているのですが、連想配列(declareコマンド)を使う時 `-A`\nオプションを使うというサンプルがインターネットには多く見られますが、実際に使用してみると、オプションが存在しないと言われます。\n\nさらに、1〜9までのキーは参照されるのですが、0やアルファベットのキーは参照されず、一番最後の要素が参照されてしまいます。\n\n以上を踏まえ、以下の2点が知りたいです。\n\n 1. `declare` の `-A` オプションはどのシェル (bashなど) で有効なオプションなのでしょうか?\n 2. 最後の要素が参照されるのはどうしてなのか\n\n実際のソースは以下の通りです。\n\n```\n\n declare sample=(\n ['1']=\"100 100\"\n ['2']=\"200 200\"\n ['3']=\"300 300\"\n ['4']=\"400 400\"\n ['5']=\"500 500\"\n ['6']=\"600 600\"\n ['0']=\"00000 00000\"\n ['A']=\"AAAAA AAAAA\"\n ['B']=\"BBBBB BBBBB\"\n )\n \n echo ${sample['1']}\n echo ${sample['2']}\n echo ${sample['3']}\n echo ${sample['4']}\n echo ${sample['5']}\n echo ${sample['6']}\n echo ${sample['0']}\n echo ${sample['A']}\n echo ${sample['B']}\n \n```\n\n実行結果\n\n```\n\n 100 100\n 200 200\n 300 300\n 400 400\n 500 500\n 600 600\n BBBBB BBBBB\n BBBBB BBBBB\n BBBBB BBBBB\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-15T21:22:52.627",
"favorite_count": 0,
"id": "73331",
"last_activity_date": "2023-01-15T17:08:26.143",
"last_edit_date": "2021-05-31T05:47:50.553",
"last_editor_user_id": "3060",
"owner_user_id": "43541",
"post_type": "question",
"score": 0,
"tags": [
"macos",
"shellscript",
"zsh"
],
"title": "zshで連想配列を使用したいのですが、うまくいきません。",
"view_count": 538
} | [
{
"body": "Macのbashはバージョンが低いのでbrewから5系をダウンロードしてインストールし \n`#!/usr/local/bin/bash` でシェルスクリプトを作る必要があります。 \nMacの3系の古いbashだと空白があると上手く動作しませんね。\n\nもしくはzshの `typeset -A` で連想配列を作る必要があります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-05-31T05:27:31.217",
"id": "76220",
"last_activity_date": "2021-05-31T08:31:41.720",
"last_edit_date": "2021-05-31T08:31:41.720",
"last_editor_user_id": "3060",
"owner_user_id": "45577",
"parent_id": "73331",
"post_type": "answer",
"score": 0
}
] | 73331 | null | 76220 |
{
"accepted_answer_id": "73335",
"answer_count": 1,
"body": "以下のプログラムで、ファイルを読み出そうとすると、コンパイルエラーが出ます。\n\n```\n\n import java.util.*; //米印必須。もしくはjava.util.Scanner\n import java.io.*;\n \n public class Hanyujiao {\n public static void main(String[] args) {\n String str;\n \n try {\n \n FileReader file = new FileReader(\"漢語角.txt\");\n BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), \"UTF-8\"));\n \n String data;\n while ((data = br.readLine()) != null) {\n boolean a=data.contains(\"小河大輔\");\n if(a){System.out.println(\"ファイルの中に小河大輔という文字はあります\");}\n System.out.print(data);\n \n \n }\n br.close();\n } catch (FileNotFoundException e) {\n System.out.println(e);\n } catch (IOException e) {\n System.out.println(e);\n }\n \n // finally{filereader.close();}\n \n }\n \n }\n \n```\n\nエラー内容は、以下の通りです。\n\n```\n\n エラー: FileInputStreamに適切なコンストラクタが見つかりません(FileReader)\n BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), \"UTF-8\"));\n ^\n コンストラクタ FileInputStream.FileInputStream(String)は使用できません\n (引数の不一致: FileReaderをStringに変換できません:)\n コンストラクタ FileInputStream.FileInputStream(File)は使用できません\n (引数の不一致: FileReaderをFileに変換できません:)\n コンストラクタ FileInputStream.FileInputStream(FileDescriptor)は使用できません\n (引数の不一致: FileReaderをFileDescriptorに変換できません:)\n \n \n```\n\nFileReaderクラスと、BufferedReaderクラスは併用できないというルールでもあるのでしょうか?\n\n**実行環境** \nopenjdk version \"15.0.1\" 2020-10-20 \nOpenJDK Runtime Environment AdoptOpenJDK (build 15.0.1+9) \nOpenJDK 64-Bit Server VM AdoptOpenJDK (build 15.0.1+9, mixed mode, sharing)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T00:51:59.117",
"favorite_count": 0,
"id": "73334",
"last_activity_date": "2021-01-16T04:25:57.240",
"last_edit_date": "2021-01-16T04:25:57.240",
"last_editor_user_id": "3060",
"owner_user_id": "39688",
"post_type": "question",
"score": 0,
"tags": [
"java"
],
"title": "ファイル読み込みの際にコンパイルエラーが出ます",
"view_count": 1030
} | [
{
"body": "FileInputStreamのコンストラクタはFile型かString型です。 \nご呈示のプログラムはFileReaderを渡しています。だからコンパイルエラーなのです。 \n明確にAPI仕様に沿っていない。それだけのことです。 \n<https://docs.oracle.com/javase/jp/8/docs/api/java/io/FileInputStream.html>\n\nご呈示の例では\n\n```\n\n FileReader file = new FileReader(\"漢語角.txt\");\n \n```\n\nを\n\n```\n\n File file = new File(\"漢語角.txt\");\n \n```\n\nとするなどで直接の原因は解決しそうです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T01:04:40.997",
"id": "73335",
"last_activity_date": "2021-01-16T01:09:58.013",
"last_edit_date": "2021-01-16T01:09:58.013",
"last_editor_user_id": "10174",
"owner_user_id": "10174",
"parent_id": "73334",
"post_type": "answer",
"score": 1
}
] | 73334 | 73335 | 73335 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Arduino nanoには「uという変数に格納されているだけの電圧を、pwmで送れ」というプログラムを書き込んでいます。そして、Jupiter\nnotebookのpythonで書いたプログラムで、シリアル通信によってAruduino nanoのuという変数を書き換えます。 \nこれによって、Jupiter notebookからモーターの制御が可能です。\n\n問題なのはここからです。uを書き換えて、モーターに目的の動作をさせて、制限時間をすぎると、プログラムは終了します。モーターもウィインと静かな音を立てて止まりかけます。\n\nすると、次の瞬間、モーターの電源電圧の最大までモーターに印加されて、モーターが猛スピードで正転します。止まることはないです。止める方法はArduino\nnanoの電源を奪うかArduino nanoのリセットボタンを押すかです。\n\nJupiter notebookの停止ボタンを押しても意味がありません。そもそもプログラム自体は実行されていないという判定になっているからです。\n\nこの現象は、10回実行すると7回くらいの割合で起きます。どなたか原因を策に心当たりありませんでしょうか\n\nプログラミングの問題ではないので(なぜならプログラムが終了した後におこる問題だから)、ソースコードは割愛します。もし、ソースコードに可能性がある場合はおっしゃってください。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T08:08:55.567",
"favorite_count": 0,
"id": "73341",
"last_activity_date": "2021-01-16T10:12:51.913",
"last_edit_date": "2021-01-16T10:12:51.913",
"last_editor_user_id": "3060",
"owner_user_id": "41334",
"post_type": "question",
"score": 0,
"tags": [
"arduino"
],
"title": "Arduino nano が勝手にモーターに電圧を入力する",
"view_count": 225
} | [] | 73341 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "`crontab`の設定をするときに開くテキストエディタをVS Code\nInsider版に変更したいので、下記のShellScriptを`./profile`に追記して実行したのですが、どうしてもGNU\nnanoが開いてしまいます。\n\n`crontab`の設定をするときに開くテキストエディタを変更する方法をご教授願います。\n\n```\n\n echo export EDITOR=code-insiders >> /home/pi/.profile\n source ~/.profile\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T12:53:11.540",
"favorite_count": 0,
"id": "73344",
"last_activity_date": "2021-01-16T15:19:44.303",
"last_edit_date": "2021-01-16T14:46:14.177",
"last_editor_user_id": "36906",
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"shellscript",
"cron"
],
"title": "crontabの設定をするときにGNU nanoが開くのですが、VS Codeに変更したいです。",
"view_count": 300
} | [
{
"body": "どんなシェルをお使いかわかりませんが、一般的なものなら `/profile` も `~/profile`\nも自動で実行されないでしょう。もし提示されているコードが `~/.profile` に書かれていたら、`source ~/.profile`\nにより無限再帰になります。\n\n`~/.profile` の中に、\n\n```\n\n export EDITOR=code-insiders\n \n```\n\nと書いてシェルを起動し直してください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T15:19:44.303",
"id": "73346",
"last_activity_date": "2021-01-16T15:19:44.303",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3475",
"parent_id": "73344",
"post_type": "answer",
"score": 0
}
] | 73344 | null | 73346 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "pythonのpandasで、ゼロ列目(行名)が日付になって、1列目以降は整数データのみのデータフレームなのですが、いままでは、 \ndf['加算結果'] = df.sum(axis=1) \nという具合に日にちごと(=行ごと)の加算値が計算できていました。\n\n最近、pandasをアップデートしたことが問題らしく、 \nTypeError: Addition/subtraction of integers and integer-arrays with Timestamp\nis no longer supported. Instead of adding/subtracting `n`, use `n * obj.freq` \nというエラーが出るようになってしまいました。\n\n計算対象のdfは、ゼロ列目が日付ですが、加算しようとしているのは2列目以降の整数値で、計算対象に日付データは含まれていません。このエラーは何が言いたいのでしょうか?「`n\n* obj.freq`」を使えと言っているようなのですが、意味が分かりません。\n\nよろしくお願いいたします。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T13:09:53.983",
"favorite_count": 0,
"id": "73345",
"last_activity_date": "2021-01-16T13:09:53.983",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43160",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pandas"
],
"title": "pandas 1.2.0 で、行ごとの加算値を求めたい",
"view_count": 224
} | [] | 73345 | null | null |
{
"accepted_answer_id": "73351",
"answer_count": 1,
"body": "**現象** \nVimを起動するたびに、下記のエラーが出る。\n\n```\n\n /home/hogehoge/.vimrc の処理中にエラーが検出されました:\n 行 10:\n E492: エディタのコマンドではありません: Plugin 'VundleVim/Vundle.vim'\n 行 13:\n E492: エディタのコマンドではありません: Plugin 'mattn/emmet-vim' \n 行 14:\n E492: エディタのコマンドではありません: Plugin 'hail2u/vim-css3-syntax'\n 行 15:\n E492: エディタのコマンドではありません: Plugin 'vim-javascript'\n 行 16:\n E492: エディタのコマンドではありません: Plugin 'turbio/bracey.vim' {'do': 'npm install --prefix server'}\n 行 18:\n E117: 未知の関数です: vundle#end\n \n```\n\n**期待値** \n上記のエラーを解消したい。\n\n**再現手順** \n`.vimrc`を下記のように記述してVimを起動する。\n\n```\n\n \"設定\n set number \"行番号を表示する\n set title \"編集中のファイル名を表示\n set showmatch \"括弧入力時の対応する括弧を表示\n syntax on \"コードの色分け\n set tabstop=4 \"インデントをスペース4つ分に設定\n set smartindent \"自動でインデントを挿れる\n set fenc=utf-8 \"文字コードをUTF-8に設定\n \n Plugin 'VundleVim/Vundle.vim'\n \"導入したいプラグインを以下に列挙する\n \"Plugin '[Github Author]/[Github repo]'の形式で記入\n Plugin 'mattn/emmet-vim' \n Plugin 'hail2u/vim-css3-syntax'\n Plugin 'vim-javascript'\n Plugin 'turbio/bracey.vim' {'do': 'npm install --prefix server'}\n \n call vundle#end()\n filetype plugin indent on\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T15:54:12.410",
"favorite_count": 0,
"id": "73347",
"last_activity_date": "2021-01-16T16:06:58.657",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"vim"
],
"title": "VimにVundleVimとその他のプラグインを.vimrcに記述したのですが、Vimを起動するたびにエラーが出ます。",
"view_count": 829
} | [
{
"body": "<https://github.com/VundleVim/Vundle.vim#quick-start> に記載されている手順より\n\n```\n\n \" set the runtime path to include Vundle and initialize\n set rtp+=~/.vim/bundle/Vundle.vim\n call vundle#begin()\n \n```\n\nが抜けているので記載した上でリンク先の手順に従えば動くと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T16:06:58.657",
"id": "73351",
"last_activity_date": "2021-01-16T16:06:58.657",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43552",
"parent_id": "73347",
"post_type": "answer",
"score": 2
}
] | 73347 | 73351 | 73351 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "以下のようなシステムを開発中です。\n\n 1. laravelアプリでsessionを保存 \n * `session()->put('key', 'value');`\n 2. 決済の外部サイトへ移動(いわゆるリンクタイプ)\n 3. 決済完了後、再度laravelアプリに戻る。\n 4. `session('key')`で取得しようとしても取得できない。\n\nSESSION_DRIVERはfileでファイルの中身を見ると書き込んだセッションの情報は記録されているのですが、取得ができません。 \n`storage/framework/sessions/TAwxSw9xdWqun3okjgfpuwgRjkZnZmXDIKUFDIn3`\n\n * 上記手順で「1」のあとlaravelアプリ内ですと別のページでもセッションの取得ができます。\n * 外部サイトに移動して戻るとセッションが取得できなくなってしまいます。うまく取得する方法はありますか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T15:56:39.297",
"favorite_count": 0,
"id": "73349",
"last_activity_date": "2021-01-16T15:56:39.297",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15167",
"post_type": "question",
"score": 0,
"tags": [
"laravel"
],
"title": "Laravel8で外部サイトに移動して戻るとsessionの取得ができない。",
"view_count": 825
} | [] | 73349 | null | null |
{
"accepted_answer_id": "73354",
"answer_count": 1,
"body": "python3にて、matplotlib (Ver.3.3.3)を使用してスペクトログラムを書こうとしています。 \n例えばカラーマップを指定し、信号`sig_1`のスペクトログラムを作成し保存したい場合、以下のように書いて動作することを確認しました。\n\n### コード1\n\n```\n\n fig = plt.figure()\n pxx, freq, bins, t = plt.specgram(sig_1 ,Fs = 48000, cmap = 'jet')\n plt.colorbar()\n fig.savefig('spectrogram_1.png')\n \n```\n\n一方、今行いたいのは、信号`sig_1`と信号`sig_2`のスペクトログラムを目で見て比較することです。そこでコード1を使って\n\n### コード2\n\n```\n\n fig_1 = plt.figure()\n pxx, freq, bins, t = plt.specgram(sig_1 ,Fs = 48000, cmap = 'jet')\n plt.colorbar()\n fig_1.savefig('spectrogram_1.png')\n \n fig_2 = plt.figure()\n pxx, freq, bins, t = plt.specgram(sig_2 ,Fs = 48000, cmap = 'jet')\n plt.colorbar()\n fig_2.savefig('spectrogram_2.png')\n \n```\n\nとしようと思ったのですが、カラーマップの色の縮尺が自動で調整されてしまうようで、`spectrogram_1.png`と`spectrogram_2.png`とで色合いを見て単純に比較することができません。例えばsig_2にsig_1\n*\n10を代入してみても、描画されるスペクトログラムの色合いは同じで、colorbarを表示させると、各色に対応する数値のほうがずれてしまいまっています[※]。これを、colorbarの各色に対応する数値は同じにして、描画の色合いが変わるようにしたい[※※]です。\n\nどのようにすれば良いか、方法をご存じの方教えてもらえないでしょうか? \n([※]もしくは[※※]を上手く言語化できず、上手く検索ができず、このような長文になってしまいました。読みにくくてすみません。)",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-16T16:01:12.653",
"favorite_count": 0,
"id": "73350",
"last_activity_date": "2021-01-17T02:23:55.853",
"last_edit_date": "2021-01-16T16:27:51.040",
"last_editor_user_id": "3060",
"owner_user_id": "30785",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"matplotlib"
],
"title": "matplotlibのcolormapの色を絶対的な値で決めたい",
"view_count": 1361
} | [
{
"body": "頂いたコメント(コメント1、[kunif](https://ja.stackoverflow.com/users/26370/kunif)さんより)で解決したため、解決済み扱いにするために自分でコメントを書いておきます。\n\n> 頂いたコメントの最後の[Set Colorbar Range in\n> matplotlib](https://stackoverflow.com/q/3373256/9014308)が上手く動きました! \n> `pxx, freq, bins, t = plt.specgram(sig_1 ,Fs = 48000, cmap = 'jet', vmin =\n> -40.0, vmax = 40.0)`のようにすることで指定することができました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T02:01:57.143",
"id": "73354",
"last_activity_date": "2021-01-17T02:23:55.853",
"last_edit_date": "2021-01-17T02:23:55.853",
"last_editor_user_id": "30785",
"owner_user_id": "30785",
"parent_id": "73350",
"post_type": "answer",
"score": 0
}
] | 73350 | 73354 | 73354 |
{
"accepted_answer_id": "73367",
"answer_count": 1,
"body": "今CSSを学んでいるのですが、素朴な疑問として、 **サイズにおける px の使用するタイミングが知りたい** です。\n\nデザイン・コーディングしてて思うのが、pxで指定するとよくレイアウト崩れや、ウインドウサイズを変えたときに縦横比を保ったまま伸縮されなくて困ったりします。 \nなので、pxより%で指定したほうがいいのかと思ったりします。 \n**pxの使用どころはどういったタイミングなのでしょうか?**\n\n特に具体的なシチュエーションとして、\n**レスポンシブデザインのデザイン・コードで既存のものでpxが使われていたりします。(margin,padding,border,heightなど) \nレスポンシブなので絶対値が設定されていると不具合が起きそうですが、それはどうなのでしょうか?**\n\n教えて頂けますと幸いです。\n\n* * *\n\n【追記】 \nこういった記事も見つけました。\n\n[ちゃんと使い分けてる?CSSのpx, em, rem, %,\nvw単位の違い](https://note.com/takamoso/n/nde1275183086)\n\n> メディアクエリ → em \n> font-size → em / rem \n> borderなど常に見た目が変わらない → px \n> それ以外 → em / rem\n\n一つの参考に致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T02:14:21.707",
"favorite_count": 0,
"id": "73355",
"last_activity_date": "2021-01-17T23:48:15.850",
"last_edit_date": "2021-01-17T06:20:49.663",
"last_editor_user_id": "3060",
"owner_user_id": "40231",
"post_type": "question",
"score": 1,
"tags": [
"html",
"css"
],
"title": "CSSにおけるpxの使い所を知りたい",
"view_count": 240
} | [
{
"body": "# まえおき\n\n>\n> デザイン・コーディングしてて思うのが、pxで指定するとよくレイアウト崩れや、ウインドウサイズを変えたときに縦横比を保ったまま伸縮されなくて困ったりします。\n\n困るのであれば、`px`は指定しないで、別のものを使う方がよいでしょう。\n\n> pxの使用どころはどういったタイミングなのでしょうか?\n\n固定しても困らないとき、つまり意図的に固定させたいときに使います。\n\n# 使いたい場面\n\n多くの場面で使いたい場面が考えられますが、例えば\n\n`ボタンのサイズ` や `聖杯レイアウトの左右のカラム幅` そして `パディング`等が考えられます。\n\nまたコレ以上でかくなっては大きすぎるみたいなときに最大値として設定することもできます。(本回答ではこのあたりは回答を省きますので `max-width` や\n`min-width` で検索するとより理解が深まるかもしれません)\n\n## ボタン\n\nボタンであれば、ボタンのサイズを画面のサイズに関わらず固定にしてしまっても違和感がないことが多いです。\n\nもしスマホサイズだとボタンが大きすぎるというときは、PCサイズ用の固定値、スマホサイズ用の固定値の2パターン作ってあげれば良く、すべての画面サイズに合わせるように\n`%`等で指定する必要はあまりありません。(あるいは タブレットサイズも含めて3パターン)\n\n## 聖杯レイアウト\n\nたまたま本回答のために検索して出てきた記事ですが、[Holy Grail Layout(聖杯レイアウト) を作る最短の HTML -\nQiita](https://qiita.com/Satachito/items/872a877b85b1ce613c97)\nの例でも左右のカラムは固定にして真ん中のカラムのみが伸び縮みするコードとなっていました。\n\n聖杯レイアウトでは、真ん中のカラムがメインコンテンツであり、そこに情報が集中するので、そこを1番見やすくするために伸縮し、左右の幅は常に固定にしておくというのはレイアウトの戦略として間違いではないと言えると思います。\n\nまた左右に置かれるのは通常メニューであり、メニューに置かれる要素が画面サイズに応じて大きくなる必要はないことも多いはずです。\nスマホサイズになった場合はそもそもこの左右のカラムがなくなって、ハンバーガーメニュー等に入ることも多いです。ですので、スマホのような小さな画面のときは画面に応じて小さくなるではなく、どこか別のところに収納されるという考え方になります(もしくはハンバーガーメニュー等を使用しない場合は、配置する場所が変わるという考え方もある)。\n\n## パディング\n\n`パディング`\nは文字を読みやすくするために、ここに間隔が欲しいみたいな場合であれば、これまた画面サイズに比例して大きくなる必要はなくそこに隙間があれば要件を満たせるので、固定の隙間を用意すれば、読みやすさは保たれます。このため、わざわざ画面サイズに応じて逐一変える必要がない場面が多いです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T13:36:04.077",
"id": "73367",
"last_activity_date": "2021-01-17T23:48:15.850",
"last_edit_date": "2021-01-17T23:48:15.850",
"last_editor_user_id": "9008",
"owner_user_id": "9008",
"parent_id": "73355",
"post_type": "answer",
"score": 2
}
] | 73355 | 73367 | 73367 |
{
"accepted_answer_id": "73360",
"answer_count": 1,
"body": "<http://www.rtpro.yamaha.co.jp/RT/FAQ/IP-Filter/apply-filter-to-\ninterface.html>\n\nyamaha のルーターについての資料を読んでいました。ここで、その処理のフローが以下に抜粋する通り、 ascii の diagram\nにて表現されていました。\n\n```\n\n :\n [BRI] : ISDN回線 or 専用線\n :\n +-----------------+-------------------+\n | | |\n | +-----------------------------+ |\n | | PPPやISDN回線の処理 | |\n | +-----------------------------+ |\n | | |\n | +-----------------------------+ |\n | | パケット・キュー | | …優先制御や帯域制御を使う/使える時\n | | (↓) +----(↑)----+ | | queue class filter ...\n | | | queue | | | pp queue type ...\n | | (↓) +----(↑)----+ | | pp queue class filter list ...\n | +-----------------------------+ | pp queue class property ...\n | | |\n | | <外側> |\n | +-----------------------------+ |\n | | NATディスクリプタ | | nat descriptor ...\n | | +-(1)-+-(2)-+-(3)-+-(4)-+ | | ip pp nat descriptor ...\n | | | ▲ | ▲ | ▲ | ▲ | | |\n | | +-----+-----+-----+-----+ | |\n | +-----------------------------+ |\n | | <内側> |\n | | |\n | +-----------------------------+ |\n | | IPフィルタ | |\n | | +----(↓)----+----(↑)----+ | | ip filter ...\n | | | in | out | | | ip pp secure filter in/out ....\n | | +----(↓)----+----(↑)----+ | | \n | +-----------------------------+ |\n | | |\n | (PP#n) | ip pp local address\n | | |\n | +-----------------------------+ |\n | | IPルーティング | |\n | +-----------------------------+ |\n | | |\n | (LAN) | ip lan address\n | | |\n | +-----------------------------+ |\n | | IPフィルタ | |\n | | +----(↑)----+----(↓)----+ | | ip filter ...\n | | | in | out | | | ip lan secure filter in/out ....\n | | +----(↑)----+----(↓)----+ | | \n | +-----------------------------+ |\n | | |\n | | <内側> |\n | +-----------------------------+ |\n | | NATディスクリプタ | | nat descriptor ...\n | | +-(1)-+-(2)-+-(3)-+-(4)-+ | | ip lan nat descriptor ...\n | | | ▼ | ▼ | ▼ | ▼ | | |\n | | +-----+-----+-----+-----+ | |\n | +-----------------------------+ |\n | | <外側> |\n | | |\n | +-----------------------------+ |\n | | パケット・キュー | | …優先制御や帯域制御を使う/使える時\n | | (↑) +----(↓)----+ | | queue class filter ...\n | | | queue | | | lan queue type ...\n | | (↑) +----(↓)----+ | | lan queue class filter list ...\n | +-----------------------------+ | lan queue class property ...\n | | |\n | +-----------------------------+ |\n | | イーサネットの処理 | |\n | +-----------------------------+ |\n | | |\n +-----------------+-------------------+\n |\n [LAN] |\n |\n ------------------+--------------------\n \n \n```\n\nもし、このような diagram が比較的簡単に作成できるのであれば、例えば複雑なソースコードにコメント上で注釈として、このような diagram\nを記しておくことで、以降の実装者がコードの理解がしやすくなり、なので有意義なのではないか、と思いました。\n\n# 質問\n\nunix cli の環境で、 ascii 図形を作成/編集を効率的に行なおうとする際に、定番のツール・ライブラリはありますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T03:45:41.217",
"favorite_count": 0,
"id": "73356",
"last_activity_date": "2021-01-17T04:49:55.510",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 2,
"tags": [
"unix"
],
"title": "unix 環境で、 ascii diagram を作成・編集したい",
"view_count": 78
} | [
{
"body": "Markdown(など)にシーケンス図やフローチャートを組み込む場合, [Graphviz (dot言語)](https://graphviz.org/),\n[PlantUML](https://plantuml.com/ja/), [Mermaid](https://mermaid-\njs.github.io/mermaid/#/) … などが有名です。\n\n一部は Ascii出力も可能なので, dot言語や PlantUMLを使ったことがあるのなら簡単なはず\n\n * PlantUML [ascii-art 出力](https://plantuml.com/ja/ascii-art)\n * Graphviz \n * [dot-to-ascii](https://github.com/ggerganov/dot-to-ascii)\n * stackoverflow.com: [Graphviz and ascii output](https://stackoverflow.com/questions/3211801/graphviz-and-ascii-output)\n * `Graph::Easy` package\n * その他 (未確認)\n\nその他に, Ascii図を直接描いて出力を得る方法もあります\n\n * 記事: [アスキーアートでフローのダイアグラムを作成できる「Asciiflow」 \n](https://gigazine.net/news/20140123-asciiflow/) => <http://asciiflow.com/>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T04:49:55.510",
"id": "73360",
"last_activity_date": "2021-01-17T04:49:55.510",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43025",
"parent_id": "73356",
"post_type": "answer",
"score": 2
}
] | 73356 | 73360 | 73360 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "以下のプログラムでXを指定したときのYの値を表示するようにしました.そこでこのYの値を1列に並べてcsvファイルに保存しようとしましたがa=np.array(f_CS(xnew))ではiが40の時の要素しか反映されず一列に並べる方法がわかりませんでした.\n\n```\n\n import pandas as pd\n from scipy.interpolate import interp1d\n import numpy as np\n import matplotlib.pyplot as plt\n date=\"1214\"\n x=np.array([0, 6, 11 , 20, 30, 40]) \n y=np.array([92, 105, 114 , 125, 148, 141]) \n \n \n f_line = interp1d(x, y)\n f_CS = interp1d(x, y, kind='cubic')\n \n time_list=np.array([0, 3, 11 , 20, 30, 40])\n \n #for plot\n xnew =np.linspace(0, 40, num=50)\n plt.plot(x, y, 'o')\n plt.plot(xnew, f_CS(xnew), '-')\n \n for i in time_list:\n print('X = ',i, 'の時の Yの値 = ', str(f_CS(i))) \n a=np.array(f_CS(xnew))\n np.savetxt(f\"{date}-target\",a, delimiter=\",\")\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T03:50:54.537",
"favorite_count": 0,
"id": "73357",
"last_activity_date": "2021-01-23T12:00:38.540",
"last_edit_date": "2021-01-23T12:00:38.540",
"last_editor_user_id": "3060",
"owner_user_id": "42568",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "for文で得た要素を1列目に並べて保存する方法",
"view_count": 449
} | [
{
"body": "[numpy.savetxt](https://numpy.org/doc/stable/reference/generated/numpy.savetxt.html)\nのパラメーター `fname` は, filename or file handle\n\nファイル名の指定は, (`numpy.savetxt` に限らず大体において)一度きりの使用を目的としているようです。 \n何回呼び出そうが, 新規にファイル作成・書き込む … ので結果的に最後の書き出ししか残りません。 \nファイルハンドルを使う必要があります。\n\n```\n\n with open(f\"{date}-target\", 'w') as fp:\n for i in time_list:\n print(f'X = {i:2} の時の Yの値 = {f_CS(i)}')\n a = np.array(f_CS(xnew))\n np.savetxt(fp, [a], delimiter=\",\")\n \n```\n\n* * *\n\n追記\n\n50等分ではなく`time_list`に基づいた値, ならば, 次のようにできます\n\n```\n\n for i in time_list:\n print(f'X = {i:2} の時の Yの値 = {f_CS(i)}')\n \n with open(f\"{date}-target\", 'w') as fp:\n np.savetxt(fp, f_CS(time_list), fmt='%s')\n \n```",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T06:04:56.183",
"id": "73362",
"last_activity_date": "2021-01-17T17:53:07.643",
"last_edit_date": "2021-01-17T17:53:07.643",
"last_editor_user_id": "43025",
"owner_user_id": "43025",
"parent_id": "73357",
"post_type": "answer",
"score": 1
},
{
"body": "組み込み関数open()を使用してテキストファイルを作成します。\n\n```\n\n import pandas as pd\n from scipy.interpolate import interp1d\n import numpy as np\n import matplotlib.pyplot as plt\n \n date=\"1214\"\n x=np.array([0, 6, 11 , 20, 30, 40]) \n y=np.array([92, 105, 114 , 125, 148, 141]) \n \n \n f_line = interp1d(x, y)\n f_CS = interp1d(x, y, kind='cubic')\n \n time_list=np.array([0, 3, 11 , 20, 30, 40])\n \n #for plot\n xnew =np.linspace(0, 40, num=50)\n plt.plot(x, y, 'o')\n plt.plot(xnew, f_CS(xnew), '-')\n \n with open(f\"{date}-target\", 'w') as f:\n for i in time_list:\n print('X = ',i, 'の時の Yの値 = ', str(f_CS(i))) \n f.write(str(f_CS(i)) + '\\n')\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T14:13:27.360",
"id": "73370",
"last_activity_date": "2021-01-17T14:13:27.360",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "39819",
"parent_id": "73357",
"post_type": "answer",
"score": 0
}
] | 73357 | null | 73362 |
{
"accepted_answer_id": "73368",
"answer_count": 1,
"body": "### やりたいこと\n\n配列の中に要素として配列が複数存在していて、 \n指定した要素(配列)があるかどうかをtrue, falseで返り値として取得したい。\n\n### 分からないこと\n\nincludesやsomeを使用して、試しにtrueが返ってくると思っていたコードを書いたのですが、 \nfalseが返ってきており、うまく検索できていない理由がわかりません。\n\n```\n\n // someを使用\n const winning_set = [\n ['グー', 'チョキ'],\n ['チョキ', 'パー'],\n ['パー', 'グー']\n ];\n \n const result = ['グー', 'チョキ'];\n \n const i = winning_set.some(\n set => set === result\n );\n console.log(i);\n // => false\n \n \n \n // includesを使用\n const winning_set = [\n ['グー', 'チョキ'],\n ['チョキ', 'パー'],\n ['パー', 'グー']\n ];\n \n const result = ['グー', 'チョキ'];\n \n const i = winning_set.includes(result);\n console.log(i);\n // => false\n \n```\n\nfalseになる原因がわかるかご存知でしたら、教えていただけると嬉しいです。 \nよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T04:24:39.543",
"favorite_count": 0,
"id": "73359",
"last_activity_date": "2021-01-17T13:38:27.697",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43337",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "配列の中にある要素が配列の場合、特定の要素(配列)があるかどうかを判定したい",
"view_count": 100
} | [
{
"body": "配列同士を直接比較する方法はないようです。 \n配列を文字列に変換してから比較すると「やりたいこと」に近いことはできます。\n\n```\n\n const winning_set = [\n ['グー', 'チョキ'],\n ['チョキ', 'パー'],\n ['パー', 'グー']\n ];\n \n const result = ['グー', 'チョキ'];\n \n const i = winning_set.some(\n item => item.toString() == result.toString()\n );\n console.log(i);\n // => true\n \n```\n\n区切り記号(,)と同じ値が含まれる場合、誤認する場合がありますので工夫が必要です。 \n汎用的な配列比較は難しいです。JSONに変換し、JSONのライブラリを使用するのも一案かと思います。 \n次の例では`[',', ',,']`と`[',,', ',']`を同一視してしまいます。\n\n```\n\n const winning_set = [\n [',', ',,'],\n ['グー', 'チョキ'],\n ['チョキ', 'パー'],\n ['パー', 'グー']\n ];\n \n const result = [',,', ','];\n \n const i = winning_set.some(\n item => item.toString() == result.toString()\n );\n console.log(i); //trueと誤認\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T13:38:27.697",
"id": "73368",
"last_activity_date": "2021-01-17T13:38:27.697",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35558",
"parent_id": "73359",
"post_type": "answer",
"score": 1
}
] | 73359 | 73368 | 73368 |
{
"accepted_answer_id": "73363",
"answer_count": 1,
"body": "下記のサイトで読んだコード内に記された。\n\n### 分からない事\n\n`this.products.push(...Array(amount).fill(product));` この部分がよくわかりません。\n\n配列にオブジェクトを代入しているのは何となく見てわかるのですが、 `0: Product {name: \"bread\", price: 1} 1:\nProduct {name: \"bread\", price: 1}`このようなオブジェクトが配列に格納されています。\n\n### 知りたい事\n\nこの `...Array()`に数値を引数で取ると`fill()`に渡した引数のコピーをその数だけしてくれるのでしょうか? \n`...`の付いたもの初めて見るので困惑しています。\n\n[JavaScriptとオブジェクト指向プログラミング](https://postd.cc/javascript-and-object-oriented-\nprogramming/)\n\n```\n\n class Product {\n constructor(name, price) {\n this.name = name;\n this.price = price;\n }\n }\n \n class Book extends Product {\n constructor(name, price, author) {\n super(name, price);\n this.author = author;\n }\n }\n \n class Basket {\n constructor() {\n this.products = [];\n }\n \n addProduct(amount, product) {\n this.products.push(...Array(amount).fill(product));\n console.log(this.products)\n }\n \n calcTotal() {\n return this.products\n .map(product => product.price)\n .reduce((a, b) => a + b, 0);\n }\n \n printShoppingInfo() {\n console.log('one has to pay in total: ' + this.calcTotal());\n }\n }\n \n const bread = new Product('bread', 1);\n const water = new Product('water', 0.25);\n const faust = new Book('faust', 12.5, 'Goethe');\n \n const basket = new Basket();\n basket.addProduct(2, bread);\n basket.addProduct(3, water);\n basket.addProduct(1, faust);\n basket.printShoppingInfo();\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T05:29:53.177",
"favorite_count": 0,
"id": "73361",
"last_activity_date": "2021-01-17T08:28:55.093",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22565",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "JavaScriptの...Array(amount).fill(product)の動作がよく分からない。",
"view_count": 84
} | [
{
"body": "> `this.products.push(...Array(amount).fill(product));`\n\nについて、`Array(amount)`, `fill(product)`, `...`と、3つに分けて説明させていただきます。\n\n### 1\\. `Array(amount)`\n\n> `Array()` コンストラクターは `Array` オブジェクトを生成するために使用します。\n> [Ref](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)\n\n表示されているスクリプトから、`amount`は整数値であることがわかります。これと上記の説明から、`Array(amount)`を実行すると、`amount`の数の要素を持った1次元配列が作成されます。ただし、この場合、各要素は初期化されていないため、`JSON.stringify(Array(amount))`を見ると、`[null,null,,,]`となります。\n\n### 2\\. `fill(product)`\n\n> `fill()` メソッドは、開始インデックス(デフォルトは `0`)から終了インデックス(デフォルトは\n> `array.length`)までのすべての要素を、静的な値に変更した配列を返します。\n> [Ref](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)\n\n表示されているスクリプトから、例えば`const bread = new Product('bread',\n1)`を実行すると、`bread`の値が、`fill(product)`の`product`に渡されます。例えば、`Array(3).fill(\"sample\")`を実行すると、`[\n'sample', 'sample', 'sample' ]`のような配列が返されます。\n\n### 3\\. `...`\n\n> `Array`の左側にある`...`は、スプレッド構文です。スプレッド構文 (`...`) を使うと、配列式や文字列などの反復可能オブジェクトを、0\n> 個以上の引数 (関数呼び出しの場合) や要素 (配列リテラルの場合) を期待された場所で展開したり、オブジェクト式を、0 個以上のキーと値のペア\n> (オブジェクトリテラルの場合) を期待された場所で展開したりすることができます。\n> [Ref](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Spread_syntax)\n\n上記の1,2の説明から、`Array(amount).fill(product)`は、`amount`の要素数を持つ`product`の値で初期化された配列であることがわかりました。そのため、例えば、`amount`,\n`product`がそれぞれ`3`, `sample`とすると、`Array(amount).fill(product)`は、`[ 'sample',\n'sample', 'sample' ]`です。これを配列`this.products = []`へプッシュすると、`this.products = [[\n'sample', 'sample', 'sample' ]]`のように2次元配列になります。\n\nここで、`...`を使用すると、`...Array(amount).fill(product)`は、`sample sample\nsample`となり、これを配列`this.products = []`へプッシュすると、`this.products = [ 'sample',\n'sample', 'sample' ]`のように1次元配列になります。この場合、`this.products.push('sample',\n'sample', 'sample')`のようにプッシュする配列が展開されてプッシュされます。\n\n追記として、表示されているスクリプトでは、3つの値`bread`, `water`, `faust`が初期化された`const basket = new\nBasket()`のメソッド`addProduct`へ渡されて、それぞれの値が順にプッシュされます。このとき、`...`を使用しない場合、`basket.addProduct(2,\nbread)`, `basket.addProduct(3, water)`, `basket.addProduct(1,\nfaust)`のそれぞれが配列としてプッシュされるため、結果は2次元配列になります。そこで、`...`を使用することで、1次元配列として出力されます。\n\nちなみに、`this.products.push(...Array(amount).fill(product))`は、`this.products =\nthis.products.concat(Array(amount).fill(product))`や`this.products =\n[...this.products, ...Array(amount).fill(product)]`などと同じ動作です。\n\n### References:\n\n * [Array() コンストラクター](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/Array)\n * [fill()](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/fill)\n * [スプレッド構文](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Spread_syntax)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T08:28:55.093",
"id": "73363",
"last_activity_date": "2021-01-17T08:28:55.093",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19460",
"parent_id": "73361",
"post_type": "answer",
"score": 1
}
] | 73361 | 73363 | 73363 |
{
"accepted_answer_id": "73365",
"answer_count": 1,
"body": "すみません、プログラミングの質問ではないです。しかしこのサイトでは工学系の質問もいくつか見受けられるので、質問させていただきます。\n\n本題\n\n通電していない時に、モーターの軸が回りません。モーターは、Pololu 172:1 金属ギヤードモータ 25Dx71L mm HP 6V\n48CPRエンコーダ付きです。 \n新品なうえに、Arduinoからの入力電圧でプログラムした通りには動いてくれるので、モーターそのもの故障ではないと思います。\n\nしかし、最初にも述べた通り通電していない時に、モーターの軸が全く回りません。指で回そうとしても動きませんし、モーターにタイヤをつけて手で回そうとすると、軸はビクともせず、タイヤの接続部が壊れました。軸をバイスで固定して回そうとしても、ビクともせず、さらに力をかけることも出来ましたが壊れそうなのでやめました。\n\nこんなに軸がかたいことってあるのでしょうか?また何が原因と考えられるでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T10:26:38.417",
"favorite_count": 0,
"id": "73364",
"last_activity_date": "2021-01-17T12:25:29.110",
"last_edit_date": "2021-01-17T12:25:29.110",
"last_editor_user_id": "3060",
"owner_user_id": "41334",
"post_type": "question",
"score": 0,
"tags": [
"ハードウェア"
],
"title": "通電していない時に、モーターの軸が回りません",
"view_count": 176
} | [
{
"body": "名前からして 172:1 の減速ギアが入っている様子。常識的に考えて軸側から手で回して回るわけがないです。手で回せたら故障ですので安心してください。\n\nこの手の減速ギア入りモーターを軸側から回すといろいろと危険です(発電機動作して感電したりとか)ダメ、絶対。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T11:14:02.983",
"id": "73365",
"last_activity_date": "2021-01-17T11:14:02.983",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "73364",
"post_type": "answer",
"score": 5
}
] | 73364 | 73365 | 73365 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "**現象** \nVimのbraceyというLive\nServerのようなプラグインをインストールした後に、Vimで`:Bracey`コマンドを実行してもブラウザが起動せずに、`E117: 未知の関数です:\nbracey#start`というエラーメッセージが表示された。\n\n**期待値** \nVimで`:Bracey`コマンドを実行すると、ブラウザが立ち上がり製作中のHPを見られるようにしたい。\n\n**再現手順**\n\n 1. `.vimrc`に下記の設定を書き込む。\n 2. その後、[vim-jp » Vimのユーザーと開発者を結ぶコミュニティサイト Linuxでのビルド方法](https://vim-jp.org/docs/build_linux.html)を参考に、Vimをビルドする。\n 3. Python3をBashで起動する。\n 4. Vimを起動し、:braceyコマンドを実行する。\n\n以下、`.vimrc`\n\n```\n\n set nocompatible\n filetype off\n \n set rtp+=~/.vim/bundle/Vundle.vim\n call vundle#begin()\n \n \"設定\n set number\n set title\n set showmatch\n syntax on\n set tabstop=4\n set smartindent\n set fenc=utf-8\n \n Plugin 'VundleVim/Vundle.vim'\n \n Plugin 'mattn/emmet-vim'\n Plugin 'hail2u/vim-css3-syntax'\n Plugin 'pangloss/vim-javascript'\n Plugin 'turbio/bracey.vim', {'do': 'npm install --prefix server'}\n \n call vundle#end()\n filetype plugin indent on\n \n```\n\n**参考リンク** \n[braceyのチュートリアル](https://github.com/turbio/bracey.vim/blob/master/README.md)",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T12:26:20.093",
"favorite_count": 0,
"id": "73366",
"last_activity_date": "2021-01-18T08:23:47.577",
"last_edit_date": "2021-01-18T08:23:47.577",
"last_editor_user_id": "36906",
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"vim"
],
"title": "Vim に bracey プラグインをインストールしたが、:Bracey コマンドを実行しても動作しない",
"view_count": 258
} | [
{
"body": "braceyではなくBracey、先頭を大文字にしても同じでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T15:09:54.520",
"id": "73372",
"last_activity_date": "2021-01-17T15:09:54.520",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22867",
"parent_id": "73366",
"post_type": "answer",
"score": 0
}
] | 73366 | null | 73372 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Android アプリでログイン機能を作成しました。 \nログインにはuseridとパスワードを使用しています。\n\nその後、2回目以降はログイン画面を介さずに自動ログインをしてメインページへ遷移させたいのですが、方法が見つかりません。\n\nfirebase\nAuthenticationを用いて自動ログインを実装しようとしたのですが、Authenticationではemailとpasswordでのログインになってしまいます。 \nそこで、useridとpasswordで自動ログインを実装するにはどうすれば良いですか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T13:44:22.627",
"favorite_count": 0,
"id": "73369",
"last_activity_date": "2021-01-18T00:02:49.650",
"last_edit_date": "2021-01-18T00:02:49.650",
"last_editor_user_id": "3060",
"owner_user_id": "41255",
"post_type": "question",
"score": 0,
"tags": [
"java",
"firebase",
"kotlin"
],
"title": "Firebase Authenticationでの自動ログインについて",
"view_count": 334
} | [
{
"body": "ログインフォームを表示する前に、onAuthStateChangedを使って既にログイン状態かを調べましょう。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-17T23:34:33.273",
"id": "73373",
"last_activity_date": "2021-01-17T23:34:33.273",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20906",
"parent_id": "73369",
"post_type": "answer",
"score": 1
}
] | 73369 | null | 73373 |
{
"accepted_answer_id": "77373",
"answer_count": 2,
"body": "`ssh-keygen` で rsa 鍵を生成すると、その公開鍵は以下のような形式になります。\n\n```\n\n ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC+spofrTV64o+qg+X3+zn9hNgQUgh1Q2STKLh9YIhQM72fdfVQfflnsgRUG38E/Bu3fymbJ6i8zIecqoRqVXYN7VBNXagZmx6jMkm90ccCuC8jiti5nEmIMpL8136Bf4xHXiTtYGwzzJoJQf2dTP2A0EwUXlNAFP0WMPDjPkBAOTI7miGrYrkR7E9lwpx3pb6KHsQx9kTiTbxx2nd+88EUNYUFKhNaXnF7O0ic0rHTNgJUISJ7fnwAvdbJUcPcwO5YBPNmKi0J3mu4VS/g9OP+2U1KbTzXmkZtKWXoi/EdivbvLhw6I82AEnwRyw/KSSAkbBV0i7xyxJMH/5IUnzdzWH7IQpfLXke0VRGwBtbQ0bsGSoS6zOe4wkiPEA64jxcKF5iaZGA8dHTZsPQSjduQovlEfwbnW2brIm7jEbJTZRZDLdbHeWXQEUY1aC6Mh8pKmVB8Oepsog7wJ/57rKospDgR6Fzejp3yfi8gZbcDdUardlvDvWRc9Rf1/ULwrvM= comment\n \n```\n\nssh の許可をアクセスする際には、この公開鍵を `authorized_keys`\nなどに登録していくことになりますが、ここで登録された鍵を眺めていると、この鍵はどの種類の rsa ssh 鍵なのか、というのを判定したくなったりします。\n\n具体的には、既に deprecated な rsa 鍵が authorized_keys に設定されていないか?を確認したいときなどです。\n\n# 質問\n\nopenssh の公開鍵の内容をパース、ないし、その鍵の種類の判定を行なう方法は、どのようなものがありますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T06:31:09.070",
"favorite_count": 0,
"id": "73378",
"last_activity_date": "2021-06-07T12:46:55.937",
"last_edit_date": "2021-01-18T07:33:02.830",
"last_editor_user_id": "3060",
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"ssh",
"openssh"
],
"title": "ssh-rsa な pubkey をパースないし、どのような鍵であるか判定したい",
"view_count": 569
} | [
{
"body": "`ssh-keygen` の `-l` オプションでフィンガープリントを表示できますが、この結果に鍵の種類や長さも表示されるようです。\n\n**CentOS 7.9 での実行結果:**\n\n```\n\n $ ssh-keygen -l -f ~/.ssh/authorized_keys\n 4096 SHA256:EFUmCXuF/+nrkRmaBDSch0+DjNuK20EfqPXnnl0bMZc comment (RSA)\n \n $ rpm -q openssh\n openssh-7.4p1-21.el7.x86_64\n \n```\n\nただし、OpenSSH のバージョンによって表示結果は異なるようです。\n\n**RHEL 5.11 での実行結果:**\n\n```\n\n $ ssh-keygen -l -f ~/.ssh/authorized_keys\n 2048 d7:ec:dd:68:28:6a:ff:93:80:8c:46:6f:66:2d:bf:fa /root/.ssh/authorized_keys\n \n $ rpm -q openssh\n openssh-4.3p2-82.el5\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T07:07:08.950",
"id": "73379",
"last_activity_date": "2021-01-18T07:07:08.950",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "73378",
"post_type": "answer",
"score": 0
},
{
"body": "まず最初に確認ですが「鍵の種類」というのは具体的には何を知りたいのですか?\n\nsshの鍵の種類というとまずは\"RSA鍵\"や\"Ed25519鍵\"というのが思い浮かびます。 \nOpenSSHの公開鍵は`鍵種別 鍵本体 コメント`というように空白で区切られた三つの部分に分かれ、この内の鍵種別が`ssh-\nrsa`ならばRSA鍵、`ssh-ed25519`ならばEd25519鍵というように簡単に判別が出来ます。\n\nまた、鍵本体部分でも判別が可能ですが([参考](https://twitter.com/ttdoda/status/1390990375246909445))、通常は使う必要が無いでしょうし、この部分だけで判断する事は推奨されていません。\n\n> この鍵はどの種類の rsa ssh 鍵なのか、というのを判定したくなったりします。\n\n鍵種別が`ssh-rsa`の鍵はすべてSSH v2用のRSA鍵(raw)であり、RSA鍵の中での種類というのは有りません。 \n厳密には公開鍵の形式として`pgp-sign-rsa`というのも有りますが、OpenSSHはこれに対応していないので特に考える必要は無いでしょう。 \nまた`ssh-rsa-\[email protected]`という証明書を使った認証方式も有りますが、これで使われるのはRSA公開鍵(id_rsa.pub)と認証局による鍵署名(id_rsa.pub.cert)というように二つのファイルに分かれていて、公開鍵ファイル自体は通常のRSA鍵と同じ物です。\n\n> 具体的には、既に deprecated な rsa 鍵が authorized_keys に設定されていないか?を確認したいときなどです。\n\n`deprecated な rsa 鍵`かを確認するには、まずdeprecatedとする基準を決める必要がありますよね。 \nRSA鍵の場合は通常は基準として鍵長が用いられますが、鍵長は`ssh-keygen -l`コマンドで表示出来ます。 \nまた公開鍵ファイルのサイズは鍵長とほぼ比例するので、簡易的でいいならば基準となる鍵長のRSA鍵を生成し、その公開鍵ファイルとサイズを比べるという方法も使えます。 \nもう少し厳密に行うならば公開鍵ファイルの鍵本体部分を抜き出す方がいいでしょう。\n\n## 鍵形式と認証方式\n\n質問を読んで感じたのですが、存在しないRSA鍵としての種類を気にしている事から、何か誤解をされているように思います。\n\nもしかしてOpenSSH 8.2以降のリリースノートに書かれている、「ssh-rsa認証(署名)方式(\"ssh-rsa\" public key\nsignature algorithm)の廃止予告」の事を気にされているのでしょうか?\n\n`ssh-rsa`という名前は、公開鍵形式と認証方式の二種類の事で使われています。 \nOpenSSHが廃止予告しているのは認証方式の方のみであり、公開鍵形式は廃止予告の対象ではありません。 \n代替方式として最初に挙げられている`rsa-sha2-256`/`rsa-sha2-512`認証方式で使うRSA鍵形式も`ssh-rsa`であり、`ssh-\nrsa`認証方式で使っていた鍵がそのまま使えます。(サーバ、およびクライアント共にOpenSSH\n7.2以降を使っているのならば、ユーザは意識していなくてもすでにRSA鍵認証では`rsa-sha2-512`認証方式が使われています)\n\n## ssh-rsa公開鍵のパース\n\n上記の事を踏まえた上で、それでも`ssh-rsa`公開鍵をパースしたいという事ならば、形式自体は単純なのでスクリプトが簡単に書けます。\n\nsshの公開鍵データの形式は[RFC4253](https://datatracker.ietf.org/doc/html/rfc4253)の[6.6.\nPublic Key\nAlgorithms](https://datatracker.ietf.org/doc/html/rfc4253#section-6.6)に以下のように書かれています。\n\n```\n\n string \"ssh-rsa\"\n mpint e\n mpint n\n \n```\n\nOpenSSHの公開鍵形式の鍵本体部分は、上記データをBase64エンコードした物です。 \n公開鍵本体部分には他の情報は含まれていません。 \n`string`および`mpint`がどのような形式かは、[RFC\n4251](https://datatracker.ietf.org/doc/html/rfc4251)の[5\\. Data Type\nRepresentations Used in the SSH\nProtocols](https://datatracker.ietf.org/doc/html/rfc4251#section-5)に書かれています。\n\n以下は、rubyで外部ライブラリを何も使わずに書いた例です。\n\n```\n\n class String\n def get_uint32!\n self.slice!(0,4).unpack1(\"N\")\n end\n \n def get_string!\n len = get_uint32!\n self.slice!(0, len)\n end\n \n def get_mpint!(len)\n self.slice!(0, len).unpack(\"C*\").inject do |r, v| (r << 8) + v end\n end\n end\n \n tag, b64key, comment = gets.split(/\\s+/, 3)\n \n puts \"tag: #{tag}\"\n puts \"key: #{b64key}\"\n puts \"comment: #{comment}\"\n \n key = b64key.unpack1(\"m\")\n ktag = key.get_string!\n \n puts \"pubkey tag: #{ktag}\"\n puts \"WARNING: tag and pubkey-tag differ\" if tag != ktag\n if ktag != \"ssh-rsa\"\n puts \"ERROR: not ssh-rsa key\"\n exit 1\n end\n \n elen = key.get_uint32!\n e = key.get_mpint!(elen)\n \n nlen = key.get_uint32!\n keylen = (key[0].ord == 0 ? nlen - 1 : nlen) * 8\n n = key.get_mpint!(nlen)\n \n puts \"key length: #{keylen}\"\n puts \"e: #{e}\"\n puts \"n: #{n}\"\n \n puts \"left data: #{key}\" unless key.empty?\n \n```\n\n実行例:\n\n```\n\n % ./parse-rsa-pubkey.rb testkey.pub\n tag: ssh-rsa\n key: AAAAB3NzaC1yc2EAAAADAQABAAABgQC+spofrTV64o+qg+X3+zn9hNgQUgh1Q2STKLh9YIhQM72fdfVQfflnsgRUG38E/Bu3fymbJ6i8zIecqoRqVXYN7VBNXagZmx6jMkm90ccCuC8jiti5nEmIMpL8136Bf4xHXiTtYGwzzJoJQf2dTP2A0EwUXlNAFP0WMPDjPkBAOTI7miGrYrkR7E9lwpx3pb6KHsQx9kTiTbxx2nd+88EUNYUFKhNaXnF7O0ic0rHTNgJUISJ7fnwAvdbJUcPcwO5YBPNmKi0J3mu4VS/g9OP+2U1KbTzXmkZtKWXoi/EdivbvLhw6I82AEnwRyw/KSSAkbBV0i7xyxJMH/5IUnzdzWH7IQpfLXke0VRGwBtbQ0bsGSoS6zOe4wkiPEA64jxcKF5iaZGA8dHTZsPQSjduQovlEfwbnW2brIm7jEbJTZRZDLdbHeWXQEUY1aC6Mh8pKmVB8Oepsog7wJ/57rKospDgR6Fzejp3yfi8gZbcDdUardlvDvWRc9Rf1/ULwrvM=\n comment: comment\n pubkey tag: ssh-rsa\n key length: 3072\n e: 65537\n n: 4327649583910065021093066394378349622703751517771966283936947382202453578096924014363834082410743933577887832365613732256889143589773614570855198533091428787691202680627513712669799711056798144776908764216417618025419754541295883860149320696601188391542414277071378007740998563573890816715772825721792861629120168905914026851492187603967486133142230182122886563163582466833650721388016726473679277978877655811527332508572613894440801906107651579977754315570612781101975662189796831535512865605736222833316158238719553666355973586756899997461824206420966641678235244389694556205797956129668235218541135398243157295606170063250946665246153910140628140995881528110934412117712819528529601830538115625298103018689126317924676582664729053804281479823154379323914768857746303210150634283208749020083767840352410211349028169020173052358083092122294127932425468490065451247010899507966998125381751141789245914984151508351340069826291\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-06-06T19:11:06.430",
"id": "77373",
"last_activity_date": "2021-06-06T19:11:06.430",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12203",
"parent_id": "73378",
"post_type": "answer",
"score": 3
}
] | 73378 | 77373 | 77373 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "画像をタップしてアルバムから画像を選択した時にエラーで止まります。 \n現状のコードは他のプロジェクトファイルにコピペして実行した所、問題なく動作しているので何が原因なのかが分からないです。\n\n以下、現状のソースです。\n\n```\n\n @IBAction func tapProfileImage(_ sender: Any) {\n showAlert()\n }\n \n \n \n func souceTypeImagePicker(souceType:UIImagePickerController.SourceType){\n \n let cameraPicker = UIImagePickerController()\n cameraPicker.sourceType = souceType\n cameraPicker.delegate = self\n cameraPicker.allowsEditing = true\n present(cameraPicker, animated: true, completion: nil)\n \n }\n \n \n func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {\n picker.dismiss(animated: true, completion: nil)\n }\n \n \n func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {\n \n if let pickerImage = info[.editedImage] as? UIImage{\n self.profileImage.image = pickerImage\n picker.dismiss(animated: true, completion: nil)\n \n }\n }\n \n \n func showAlert(){\n \n let alertController = UIAlertController(title: \"選択\", message: \"どちらを使用しますか?\", preferredStyle: .actionSheet)\n \n let action1 = UIAlertAction(title: \"カメラ\", style: .default) { (alert) in\n \n let souceType:UIImagePickerController.SourceType = .camera\n self.souceTypeImagePicker(souceType: souceType)\n \n }\n let action2 = UIAlertAction(title: \"アルバム\", style: .default) { (alert) in\n \n let souceType:UIImagePickerController.SourceType = .photoLibrary\n self.souceTypeImagePicker(souceType: souceType)\n \n }\n \n let action3 = UIAlertAction(title: \"キャンセル\", style: .cancel)\n \n \n alertController.addAction(action1)\n alertController.addAction(action2)\n alertController.addAction(action3)\n self.present(alertController, animated: true, completion: nil)\n \n }\n \n```\n\nセキュアについてはモデル化してインスタンス化し、Viewdidload内で実行しています。\n\n以下モデルです。\n\n```\n\n class checkPermission{\n \n init() {\n \n }\n \n func checkCamera(){\n PHPhotoLibrary.requestAuthorization { (status) in\n switch(status){\n \n \n case .notDetermined:\n print(\"notDetermined\")\n case .restricted:\n print(\"restricted\")\n case .denied:\n print(\"denied\")\n case .authorized:\n print(\"authorized\")\n case .limited:\n print(\"limited\")\n @unknown default:\n break\n }\n }\n }\n }\n \n```\n\n今回の問題になっているこれらのコードを別のプロジェクトファイルにてコピペで実行した際は正常に動作し、アルバムから画像を選択できている状態でした。 \n問題が発生しているプロジェクトとの違いはFirebaseがインストールされているかいないかの違いです。しかし、問題が発生しているプロジェクトで画像を選択してもまだFirebaseに対して何もデータを送信していないのであまり関係ないと思うのですが、Firebaseがインストールされていないプロジェクトでは正常に動作するのでよく分からないです。\n\n動作環境はM1のMacBook Proです。 \n画像を含めないFirebase通信ではarm64を使用しないに設定して正常に動作していました。\n\nアドバイスよろしくお願いします。\n\n[](https://i.stack.imgur.com/ZVUwD.jpg)",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T07:12:17.363",
"favorite_count": 0,
"id": "73380",
"last_activity_date": "2021-04-02T00:11:37.693",
"last_edit_date": "2021-04-02T00:11:37.693",
"last_editor_user_id": "3060",
"owner_user_id": "37890",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"firebase",
"uiimagepickercontroller"
],
"title": "UIImagePickerControllerでExceptioエラーがでますが、原因が分かりません。",
"view_count": 64
} | [
{
"body": "`URLByAppendingPathExtension`という場所(すなわち、`appendingPathExtension(_:)`関数 \n<https://developer.apple.com/documentation/foundation/url/1780122-appendingpathextension>\n)で例外エラーが発生していますね。\n\n<https://developer.apple.com/forums/thread/670640> \nにのっているエラー文が質問にのせてある画像に入っているエラー文に非常に似ていて、同じような場所で問題が発生しているのだと思います。\n\n* * *\n\n**どこでエラーが出ているかを書いて、画像ではなくエラー文をコピペしたほうが、回答する側としてもわかりやすく、回答されやすい**\nと思うので、今度から心がけましょう。\n\nExceptio → Exception",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-04-01T08:56:03.297",
"id": "75014",
"last_activity_date": "2021-04-01T23:26:39.593",
"last_edit_date": "2021-04-01T23:26:39.593",
"last_editor_user_id": "39579",
"owner_user_id": "39579",
"parent_id": "73380",
"post_type": "answer",
"score": 1
}
] | 73380 | null | 75014 |
{
"accepted_answer_id": "73385",
"answer_count": 1,
"body": "下記のブログでリストとイテレータについて書かれているのですが、理解表現があります。\n\n[Pythonのリストはイテレーターでない。わかりやすい(はずの)イテレーターとイテラブルの説明](https://blog.hirokiky.org/entry/2020/02/03/181938)\n\nなぜリスト自身がイテレータの場合一度ループしただけでリストはループ出来なくなってしまうのでしょうか? \nこの場合のループとは `for in` を指しているのでしょうか?その場合なぜループできなくなるのか分からないです。ブログでは `for in`\nの内部ではイテレータによる処理が行われているという説明までされています。\n\n> もしリスト自身がイテレーターであれば、1度ループしただけでリストはループできなくなってしまいます(ループの進行状況が管理されるので)。\n> そのために、リスト自身ではなくリストイテレーターさん(つまりイテレーター)にループの状況を管理してもらっています。Pythonってすごい!\n\n### 追記\n\nどうやら `for in` にイテレータは渡せるみたいです。\n\nループでは使用できないという表現がよく分からないです。\n\n> イテレーターは同時にイテラブルでもあります。 なので、イテレーターは for in ... に渡せます。この場合、イテレーターは\n> iter(my_iterator) をすると my_iterator 自身を返します。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T07:17:46.573",
"favorite_count": 0,
"id": "73381",
"last_activity_date": "2021-01-18T09:33:58.947",
"last_edit_date": "2021-01-18T09:33:58.947",
"last_editor_user_id": "22565",
"owner_user_id": "22565",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"array"
],
"title": "pythonリストとイテレータについて",
"view_count": 121
} | [
{
"body": "プログのリンクが不明で, たぶん[ここかな](https://blog.hirokiky.org/entry/2020/02/03/181938)?と\n\n言ってることは, (イテレーターだと) 使い切ってしまうと それ以上は使えない … ですね。 \nリストの場合\n\n```\n\n lst = [10,20,30]\n for i in lst:\n print(i)\n # 10\n # 20\n # 30\n \n for i in lst:\n print(i)\n # 10\n # 20\n # 30\n \n```\n\nジェネレーターの場合\n\n```\n\n def gen1():\n for n in [10,11,12]:\n yield n\n \n g1 = gen1()\n for i in g1:\n print(f'1度目 {i}')\n # 10\n # 11\n # 12\n \n for i in g1:\n print(f'2度目 {i}')\n # 出力なし\n \n```\n\nファイルの場合 (試してないけど)\n\n```\n\n with open('dummydata') as fp:\n for ln in fp:\n print(ln)\n for ln in fp:\n print(ln)\n \n```",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T08:44:37.330",
"id": "73385",
"last_activity_date": "2021-01-18T08:44:37.330",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43025",
"parent_id": "73381",
"post_type": "answer",
"score": 0
}
] | 73381 | 73385 | 73385 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "以下のコードを実行すると、エラーが出て詰まってしまいました。 \n前はちゃんとできていたのですが、学習させる画像を増やして実行したところこのようなエラーが出てきました。\n\nどのように対処すればよろしいでしょうか? \nよろしくお願いいたします。\n\n* * *\n\n**実行したコード:**\n\n```\n\n from keras.utils import np_utils\n import numpy as np\n \n categories = [\"L\",\"M\",\"S\"]\n nb_classes = len(categories)\n \n X_train, X_test, y_train, y_test = np.load(\"C:\", allow_pickle=True)\n \n X_train = X_train.astype(\"float\") / 255.0\n X_test = X_test.astype(\"float\") / 255.0\n \n y_train = np_utils.to_categorical(y_train, nb_classes)\n y_test = np_utils.to_categorical(y_test, nb_classes)\n \n model = model.fit(X_train,\n y_train,\n epochs=100,\n batch_size=6,\n validation_data=(X_test,y_test))\n \n```\n\n**エラーメッセージ:**\n\n```\n\n ValueError Traceback (most recent call last)\n <ipython-input-27-0f5758f6f275> in <module>\n ----> 1 model = model.fit(X_train,\n 2 y_train,\n 3 epochs=100,\n 4 batch_size=1000,\n 5 validation_data=(X_test,y_test))\n \n \n 1108 \n 1109 if logs is None:\n -> 1110 raise ValueError('Expect x to be a non-empty array or dataset.')\n 1111 epoch_logs = copy.copy(logs)\n 1112 \n \n ValueError: Expect x to be a non-empty array or dataset.\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T07:25:39.197",
"favorite_count": 0,
"id": "73382",
"last_activity_date": "2021-01-18T07:38:46.653",
"last_edit_date": "2021-01-18T07:38:46.653",
"last_editor_user_id": "3060",
"owner_user_id": "43567",
"post_type": "question",
"score": 0,
"tags": [
"python",
"keras"
],
"title": "Expect x to be a non-empty array or dataset",
"view_count": 932
} | [] | 73382 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "C/C++のパケットスニファライブラリlibpcapで使えるパケット送信用APIのpcap_sendpacketが全てのパケットにおいて正常に送信されない問題が起きており、困っております…\n\n### 実際に起きたこと:\n\n * tcpreplayでpcapファイルのトラフィック(パケット数14261個)をマシン1から流す(通信速度1Mbpsです)\n * マシン2がパケットをNIC1(デバイス名:enp2s0)で受け取り、NIC2(デバイス名:enp3s0) からpcap_sendpacket()でマシン3へ転送する\n * マシン3のNICをtcpdumpで観測し、パケット数を調べる\n\n上記のような実験を行ったのですが、結果として\n\n * マシン2: 受信パケット数 14261\n * マシン3: 受信パケット数 12700前後\n\n1500近くのパケットがロスしてしまいます。\n\n通信速度を0.247Mbpsの場合でも流してみたのですが同様にパケットロスが同じぐらいの数だけマシン3で生じてしまいます(そもそもこんなに遅くてもパケロスが発生しているのが謎です) \nこれは転送処理に問題があるのでしょうか?\n\n### 調べたこと:\n\npcap_sendpacketが失敗している(-1を返す)訳ではありませんでした。\n\nマシン2ではNIC1のパケットをpcap_loop()で監視しており、pcap_loop()のコールバック関数では、以下のようなコードを書いています↓\n\n```\n\n pcap_loop_callback(u_char *args, const struct pcap_pkthdr *header, const u_char *packet){\n \n //送信用にメモリを動的確保\n u_char* forward_packet;\n forward_packet = (u_char *)malloc(header->len);\n memcpy(forward_packet, packet, header->len);\n \n //args[0]には転送するNIC2(enp3s0)のハンドラを渡しています\n pcap_sendpacket((pcap_t *)&(args[0]), forward_packet, header->len);\n \n //送信用に確保したメモリの解放\n free(forward_packet);\n }\n \n```\n\nどなたか、pcap_sendpacket()で転送を行うとパケットロスが起きてしまう原因について教えていただけますと幸いでございます \nよろしくお願い申し上げます",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T09:30:33.230",
"favorite_count": 0,
"id": "73387",
"last_activity_date": "2021-01-18T12:43:16.330",
"last_edit_date": "2021-01-18T12:43:16.330",
"last_editor_user_id": "3060",
"owner_user_id": "43570",
"post_type": "question",
"score": 0,
"tags": [
"c++",
"c"
],
"title": "libpcapのpcap_sendpacket()でパケットロスが発生する原因について",
"view_count": 224
} | [] | 73387 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "使用ツール \n・Python 3.6 \n・OpenCV 4.5 (※最新版を入れました) \n・Anaconda 3.0\n\n初めて画像処理に触れました。最初は本当に楽しく出来そうだなぁと感じていたのですが、エラーが出てしまって、全くプログラムが動きません。\n\nOpenCVのバージョンが異なる為、動かないと言われたのですが、正直に言いますと、どこが違っているのか分かりません。\n\n出てきたエラー\n\n```\n\n AttributeError: module 'cv2.cv2' has no attribute 'cvtcolor'\n \n```\n\n動かしたいコード\n\n```\n\n import cv2\n image = cv2.imread(r\"C:\\library_cv\\sky_006.jpg)\n gray = cv2.cvtcolor(image, cv2.COLOR.BGR2GRAY)\n cv2.imwrite(r\"C:\\write_cv\\gray_006.jpg\")\n \n```\n\n上記のコードに `cv2.countNonZero` を使って、白の割合を出すのが目標です。 \n※画像名は仮想ですが、概ねこの通りです。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T10:29:18.183",
"favorite_count": 0,
"id": "73389",
"last_activity_date": "2021-01-18T12:52:43.173",
"last_edit_date": "2021-01-18T12:33:16.250",
"last_editor_user_id": "3060",
"owner_user_id": "43572",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"opencv"
],
"title": "Python & OpenCV でグレイスケール化をしたいのですが、AttributeError が出てしまう",
"view_count": 1122
} | [
{
"body": "質問のエラーも含めて幾つか typo があります。 \n以下のようにすれば動作するでしょう。\n\n```\n\n import cv2\n image = cv2.imread(r\"C:\\library_cv\\sky_006.jpg\")\n gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\n cv2.imwrite(r\"C:\\write_cv\\gray_006.jpg\", gray)\n \n```\n\n * `imread`のファイル名の`\"`が閉じていない(質問時の転記ミスでしょう)\n * `cvtcolor`の`color`は大文字で始まる`cvtColor`\n * `cv2.COLOR.BGR2GRAY`は`cv2.COLOR_BGR2GRAY`の間違い(`.`ではなく`_`で接続する)\n * `imwrite`は2つ目のパラメータにイメージのオブジェクトを指定する必要がある\n\n* * *\n\nコメントのリンク先は正しくはこちら \n[Python,OpenCVで二値画像から白と黒の面積比を算出](https://techtech-\nsorae.com/pythonopencv%E3%81%A7%E4%BA%8C%E5%80%A4%E7%94%BB%E5%83%8F%E3%81%8B%E3%82%89%E7%99%BD%E3%81%A8%E9%BB%92%E3%81%AE%E9%9D%A2%E7%A9%8D%E6%AF%94%E3%82%92%E7%AE%97%E5%87%BA/)\n\n上記記事の`bw_image`は2値化された画像データのオブジェクトです。 \n仕様はこちら。 \n[cv::threshold](http://opencv.jp/opencv-2svn/cpp/miscellaneous_image_transformations.html?highlight=threshold#cv-\nthreshold) \n[画像の閾値処理](http://whitewell.sakura.ne.jp/OpenCV/py_tutorials/py_imgproc/py_thresholding/py_thresholding.html) \n[Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval,\ndst](https://docs.opencv.org/3.0-beta/modules/imgproc/doc/miscellaneous_transformations.html?highlight=cv2.threshold#cv2.threshold)\n\n使い方などの記事はこちら。 \n[OpenCV – 画像処理の2値化の仕組みと cv2.threshold() の使い方](https://pystyle.info/opencv-\nimage-binarization/) \n[cv2.threshold()](https://pystyle.info/opencv-image-binarization/#outline__4)\n\n> * 返り値\n> * retval: 閾値 (cv2.THRESH_OTSU、cv2.THRESH_TRIANGLE\n> を使用した場合に自動的に決まった閾値を知るための返り値)\n> * dst: 2値画像\n>",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-18T11:36:40.387",
"id": "73390",
"last_activity_date": "2021-01-18T12:52:43.173",
"last_edit_date": "2021-01-18T12:52:43.173",
"last_editor_user_id": "26370",
"owner_user_id": "26370",
"parent_id": "73389",
"post_type": "answer",
"score": 3
}
] | 73389 | null | 73390 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "バックエンドのAPIを開発していて、APIによってはレスポンスのパラメータのうち値が無い(DB上nullなど)ものがあり、それがstringで返すパラメータの場合、そのままnullで返すか、型を合わせるために空文字で返すべきか、設計で悩んでいます。\n\n現状、統一されていないため呼び出し側で判定して吸収しているのですが、どちらに合わせるのがよりベターでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T03:00:56.417",
"favorite_count": 0,
"id": "73400",
"last_activity_date": "2021-01-19T12:00:09.473",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19727",
"post_type": "question",
"score": 0,
"tags": [
"api"
],
"title": "REST APIのレスポンスパラメータで値が無い場合にnullと空文字とどっちにするべきか?",
"view_count": 1505
} | [
{
"body": "回答というよりも意見です。\n\n * 空文字列が「あり得るデータ」であることに備えるなら、データが存在しない場合や意味を持たない場合はnullか0に統一するべきだと思います。\n * 現状、空文字列があり得ないのならば、統一することを優先し、修正量が少ない方で決めるのも現実解だと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T11:40:25.497",
"id": "73411",
"last_activity_date": "2021-01-19T12:00:09.473",
"last_edit_date": "2021-01-19T12:00:09.473",
"last_editor_user_id": null,
"owner_user_id": "35558",
"parent_id": "73400",
"post_type": "answer",
"score": 2
}
] | 73400 | null | 73411 |
{
"accepted_answer_id": "73413",
"answer_count": 1,
"body": "## 疑問点\n\nreactのReact.MouseEvent型を引数に持つイベントをeventListenerのリスナーに登録したいです。 \nしかしevenntListenerはmouseEvent型のリスナーを受け付けており、型が合わないためエラーが発生するようです。 \nエラーが発生する原因は分かったのですが、どのようにすれば型を合わせることができるのかわかりません。\n\n※any型を使うとエラーは出ませんが、使いたくないです。\n\n## サンプルコード\n\nbox内の領域でmouseDownしながらmouseMoveする(Box外の領域でもmouseMoveを検知したいのでdocument.addEventListenerを使っています)とコンソールにmoveと表示したいです。\n\nBoxは`import Box from '@material-\nui/core/Box';`をして使っています。onMouseDown、onMouseMoveは(JSX attribute) `onMouseDown?:\n((event: React.MouseEvent<HTMLElement, MouseEvent>) => void) | undefined`です。\n\n```\n\n const mouseSample: React.FC = () => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [flag, setFlag] = useState(false);\n const handleMouseDown = (): void => {\n setFlag(true);\n document.addEventListener('mousemove', handleMouseMove);//イベントの型が合わないからエラーになる\n document.addEventListener('mouseup', handleMouseUp);\n };\n \n const handleMouseMove = (event: React.MouseEvent<HTMLElement>): void => {\n if (flag) {\n // eslint-disable-next-line no-console\n console.log('move');\n }\n };\n \n const handleMouseUp = (): void => {\n setFlag(false);\n document.removeEventListener('mousemove', handleMouseMove);/イベントの型が合わないからエラーになる\n document.removeEventListener('mouseup', handleMouseUp);\n };\n \n return (\n <Box\n style={{\n height: '400px',\n width: '400px'\n }}\n onMouseDown={handleMouseDown}\n onMouseMove={handleMouseMove}\n onMouseUp={handleMouseUp}\n >\n moveBox\n </Box>\n );\n };\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T04:47:57.340",
"favorite_count": 0,
"id": "73401",
"last_activity_date": "2021-01-19T13:29:29.210",
"last_edit_date": "2021-01-19T06:50:36.203",
"last_editor_user_id": "3068",
"owner_user_id": "43562",
"post_type": "question",
"score": 0,
"tags": [
"reactjs",
"typescript"
],
"title": "addEventListenerのリスナーにreactのイベント処理を登録したい",
"view_count": 1472
} | [
{
"body": "`React.MouseEvent`は`BaseSyntheticEvent`を基底として持っており、document.addEventListenerで取得できるイベントは`nativeEvent`から取得できるので変換を行うことで型の整合性が合うと考えられます\n\n```\n\n import * as React from \"react\";\n import { useState } from \"react\";\n import { Box } from \"@material-ui/core\";\n \n export const MouseSample: React.FC = () => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [flag, setFlag] = useState(false);\n const handleNativeMouseMove = (event: MouseEvent) => {\n if (flag) {\n // eslint-disable-next-line no-console\n console.log(\"move\");\n }\n };\n const handleNativeMouseUp = (event: MouseEvent) => {\n document.removeEventListener(\"mousemove\", handleNativeMouseMove);\n document.removeEventListener(\"mouseup\", handleNativeMouseUp);\n setFlag(false);\n };\n const handleNativeMouseDown = (event: MouseEvent) => {\n document.addEventListener(\"mousemove\", handleNativeMouseMove); /\n document.addEventListener(\"mouseup\", handleNativeMouseMove);\n setFlag(true);\n };\n \n // 変換\n const handleMouseMove = (event: React.MouseEvent<HTMLElement>): void => {\n handleNativeMouseMove(event.nativeEvent);\n };\n const handleMouseDown = (event: React.MouseEvent<HTMLElement>): void => {\n handleNativeMouseDown(event.nativeEvent);\n };\n const handleMouseUp = (event: React.MouseEvent<HTMLElement>): void => {\n handleNativeMouseUp(event.nativeEvent);\n };\n \n return (\n <Box\n style={{\n height: \"400px\",\n width: \"400px\"\n }}\n onMouseDown={handleMouseDown}\n onMouseMove={handleMouseMove}\n onMouseUp={handleMouseUp}\n >\n moveBox\n </Box>\n );\n };\n \n```\n\n## 参考\n\n * [NativeMouseEventにMouseEventをAliasを張っている箇所](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/v16/index.d.ts#L47)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T13:29:29.210",
"id": "73413",
"last_activity_date": "2021-01-19T13:29:29.210",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7997",
"parent_id": "73401",
"post_type": "answer",
"score": 0
}
] | 73401 | 73413 | 73413 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "ステガノグラフィーなるものをドラマで知ったので使ってみたいと思いPythonをインストールして以下のコードをコピペして実行しました。choose\nfileでjpgの画像を選択しましたが読み込まれません。\n\nencript.py\n\n```\n\n from tkinter import *\n from PIL import Image, ImageTk\n from tkinter import filedialog\n import cv2\n import numpy as np\n import math\n \n global path_image\n \n image_display_size = 300, 300\n \n def on_click():\n # Step 1.5\n global path_image\n # use the tkinter filedialog library to open the file using a dialog box.\n # obtain the image of the path\n path_image = filedialog.askopenfilename()\n # load the image using the path\n load_image = Image.open(path_image)\n # set the image into the GUI using the thumbnail function from tkinter\n load_image.thumbnail(image_display_size, Image.ANTIALIAS)\n # load the image as a numpy array for efficient computation and change the type to unsigned integer\n np_load_image = np.asarray(load_image)\n np_load_image = Image.fromarray(np.uint8(np_load_image))\n render = ImageTk.PhotoImage(np_load_image)\n img = Label(app, image=render)\n img.image = render\n img.place(x=20, y=50)\n \n def encrypt_data_into_image():\n # Step 2\n global path_image\n data = txt.get(1.0, \"end-1c\")\n # load the image\n img = cv2.imread(path_image)\n # break the image into its character level. Represent the characyers in ASCII.\n data = [format(ord(i), '08b') for i in data]\n _, width, _ = img.shape\n # algorithm to encode the image\n PixReq = len(data) * 3\n \n RowReq = PixReq/width\n RowReq = math.ceil(RowReq)\n \n count = 0\n charCount = 0\n # Step 3\n for i in range(RowReq + 1):\n # Step 4\n while(count < width and charCount < len(data)):\n char = data[charCount]\n charCount += 1\n # Step 5\n for index_k, k in enumerate(char):\n if((k == '1' and img[i][count][index_k % 3] % 2 == 0) or (k == '0' and img[i][count][index_k % 3] % 2 == 1)):\n img[i][count][index_k % 3] -= 1\n if(index_k % 3 == 2):\n count += 1\n if(index_k == 7):\n if(charCount*3 < PixReq and img[i][count][2] % 2 == 1):\n img[i][count][2] -= 1\n if(charCount*3 >= PixReq and img[i][count][2] % 2 == 0):\n img[i][count][2] -= 1\n count += 1\n count = 0\n # Step 6\n # Write the encrypted image into a new file\n cv2.imwrite(\"encrypted_image.png\", img)\n # Display the success label.\n success_label = Label(app, text=\"Encryption Successful!\",\n bg='lavender', font=(\"Times New Roman\", 20))\n success_label.place(x=160, y=300)\n \n # Step 1\n # Defined the TKinter object app with background lavender, title Encrypt, and app size 600*600 pixels.\n app = Tk()\n app.configure(background='lavender')\n app.title(\"Encrypt\")\n app.geometry('600x600')\n # create a button for calling the function on_click\n on_click_button = Button(app, text=\"Choose Image\", bg='white', fg='black', command=on_click)\n on_click_button.place(x=250, y=10)\n # add a text box using tkinter's Text function and place it at (340,55). The text box is of height 165pixels.\n txt = Text(app, wrap=WORD, width=30)\n txt.place(x=340, y=55, height=165)\n \n encrypt_button = Button(app, text=\"Encode\", bg='white', fg='black', command=encrypt_data_into_image)\n encrypt_button.place(x=435, y=230)\n app.mainloop()\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T05:52:01.237",
"favorite_count": 0,
"id": "73403",
"last_activity_date": "2021-01-19T06:23:09.497",
"last_edit_date": "2021-01-19T06:23:09.497",
"last_editor_user_id": "3060",
"owner_user_id": "43582",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "Pythonでステガノグラフィーを試したいと思ったがエラーがでました。",
"view_count": 120
} | [] | 73403 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "I have purchased a [Griffin Technology USB\nPowermate](https://www.amazon.co.jp/Griffin-Technology-\nNA16029-PowerMate-%E3%80%90%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%BA%E5%8F%AF%E8%83%BD%E3%81%AAUSB%E3%83%9E%E3%83%AB%E3%83%81%E3%83%A1%E3%83%87%E3%82%A3%E3%82%A2%E3%82%B3%E3%83%B3%E3%83%88%E3%83%AD%E3%83%BC%E3%83%A9%E3%83%BC%E3%80%91/dp/B003VWU2WA)\nand want to use this to map to values on the program. Specifically, I would\nlike to be able to receive values in a format similar to OSC, in max/MSP, C++,\nNode.js, or Python. I use a Mac Catalina for development. (Windows 10 is also\navailable)\n\nPlease let me know if you have any insights. Thank you for your time.\n\n* * *\n\n[Griffin Technology USB Powermate](https://www.amazon.co.jp/Griffin-\nTechnology-\nNA16029-PowerMate-%E3%80%90%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%BA%E5%8F%AF%E8%83%BD%E3%81%AAUSB%E3%83%9E%E3%83%AB%E3%83%81%E3%83%A1%E3%83%87%E3%82%A3%E3%82%A2%E3%82%B3%E3%83%B3%E3%83%88%E3%83%AD%E3%83%BC%E3%83%A9%E3%83%BC%E3%80%91/dp/B003VWU2WA)を購入し、これをプログラムの外部USBコントローラーとして使用したいと思っています。Driver対応などについてもアップデートがされていないみたいでどのように使用すれば良いか分からない状態です。OSCと同じようなフォーマットで値をmax/MSPかC++、Node.js、Pythonのどれかに送ることができたら嬉しいです。現在私はMac\nCatalinaを使って開発をおこなっています。(Windows 10も可)\n\n何か知見などありましたらご教授よろしくお願い致します。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T06:42:57.393",
"favorite_count": 0,
"id": "73404",
"last_activity_date": "2021-01-19T11:11:35.427",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43082",
"post_type": "question",
"score": -1,
"tags": [
"macos",
"windows-10",
"usb"
],
"title": "Receive the value of Griffin Technology USB Powermate programmatically. (mac catalina / Windows 10)",
"view_count": 224
} | [
{
"body": "該当の製品はかなり古いもののようで (2015年~16年頃)、対応 OS も Windows XP や Vista 止まりで \n[公式サイト](https://griffintechnology.com/)\n上では検索しても見つからず、既にラインナップやサポートから外れているようです。\n\nそもそも想定しているような開発者向けの利用方法がサポートされているのかをまずは確認すべきではないでしょうか?\n(恐らくは製品のユーティリティ経由での利用しか対応していないような気がします)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T11:11:35.427",
"id": "73410",
"last_activity_date": "2021-01-19T11:11:35.427",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "73404",
"post_type": "answer",
"score": 1
}
] | 73404 | null | 73410 |
{
"accepted_answer_id": null,
"answer_count": 4,
"body": "例えばですが、以下のように \nアクションごとに変数名を変更しないのはなぜでしょうか?\n\n@a,@b,@c,@dのところがおなじ@messageという変数を使う \nメリットについて教えて下さい。\n\n```\n\n class MessagesController < ApplicationController\n def index\n @a= Message.all\n end\n \n def show\n @b = Message.find(params[:id]) \n end\n \n def new\n @c = Message.new\n end\n \n def create\n @d = Message.new(message_params)\n \n if @d.save\n flash[:success] = 'Messageが投稿されました'\n redirect_to @d\n else\n flash.now[:danger] = 'Messageが投稿されませんでした'\n render :new\n end\n end\n \n def edit\n end\n \n def update\n end\n \n def destroy\n end\n \n private\n \n def message_params\n params.require(:message).permit(:content)\n end\n end\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T08:39:56.263",
"favorite_count": 0,
"id": "73406",
"last_activity_date": "2021-02-14T08:51:12.450",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34234",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails",
"ruby"
],
"title": "Ruby on Rails アクションごとの変数名が同じ理由について",
"view_count": 654
} | [
{
"body": "自由な変数名を使って良いです。\n\nチーム開発をする場合はMessageクラスの変数名に別の名前をつけると他に意味があるか考えてしまったりするので中身を説明する変数名をつけることが良い習慣とされています\n\n```\n\n # 悪い例: 犬のクラスなのに猫?\n @cat = Dog.find(params[:id])\n \n```\n\nまた今回例示頂いたような短い変数名は小さな関数の中では読み間違うことはほぼないため、利用して良いと思います(RailsだとViewで利用するので見かけよりでかかったりしますが)\n\n```\n\n # Messageのインスタンス変数なので頭文字のm\n def show\n @m = Message.find(...)\n end\n \n```\n\nなぜ`@message`を使うかを書いてみます。\n\nRailsは規約に従うことコード量を少なくシンプルな記述で書けます。ルールに沿って書くことでコードを書く際に考えることが少なくできるわけです。つまりMessageモデルを扱うコントローラやビューでは`@message`や`@messages`の変数名とすることで考えることが減ります。プログラムを書くときに変数名を何とするか迷うことはとても多いので、パターンが決まってると時間短縮になり、あとあと自分で読む場合や他人が読む場合も変に疑うことがなくなります。\n\n思いついたままに書きましたが参考になれば幸いです\n\n* * *\n\n補足ですがコレクションを扱う `index` アクションでは一般的に複数形の @messages になります。\n\n```\n\n def index\n @messages = Message.all\n end\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T16:06:06.240",
"id": "73418",
"last_activity_date": "2021-01-21T15:40:22.657",
"last_edit_date": "2021-01-21T15:40:22.657",
"last_editor_user_id": "298",
"owner_user_id": "298",
"parent_id": "73406",
"post_type": "answer",
"score": 2
},
{
"body": "各actionで変数名を揃えている理由ですが、理由の1つとして各アクション間でviewテンプレートの共有が行われるからだと思います。\n\n例えばメッセージの表示をするテンプレートは`show`以外にも`create`や`edit`が成功した後に使われたりしますし、メッセージの編集フォームは`create`、`edit`で使われます。 \nここで、表示対象となるメッセージの変数がバラバラだと困ったことになります。 \nということで、このような処理がある場合はaction間で変数を統一しておくことがあります。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T10:22:45.470",
"id": "73441",
"last_activity_date": "2021-01-20T10:22:45.470",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "42137",
"parent_id": "73406",
"post_type": "answer",
"score": 0
},
{
"body": "@message を使う理由は、その方が分かりやすいし効率が良いからです。 \n結果的にプログラミングがとても楽になります。\n\n@message という名前ならこの変数で何を扱っているか分かりやすいですし、異なるアクションで同じ @message\nを使えば処理を共通化しやすくなります。\n\nこのMessageに関する処理をScaffoldを使って生成するとわかりやすいのではないかと思います。\n\n```\n\n $> rails g scaffold message body:text\n \n```\n\nMessagesController はこんな感じになると思います(Ralsのバージョンにより若干の差異があります)。\n\n```\n\n class MessagesController < ApplicationController\n before_action :set_message, only: [:show, :edit, :update, :destroy]\n \n # GET /messages\n def index\n @messages = Message.all\n end\n \n # GET /messages/1\n def show\n end\n \n # GET /messages/new\n def new\n @message = Message.new\n end\n \n # GET /messages/1/edit\n def edit\n end\n \n # POST /messages\n def create\n @message = Message.new(message_params)\n \n if @message.save\n redirect_to @message, notice: 'Message was successfully created.'\n else\n render :new\n end\n end\n \n # PATCH/PUT /messages/1\n def update\n if @message.update(message_params)\n redirect_to @message, notice: 'Message was successfully updated.'\n else\n render :edit\n end\n end\n \n # DELETE /messages/1\n def destroy\n @message.destroy\n redirect_to messages_url, notice: 'Message was successfully destroyed.'\n end\n \n private\n # Use callbacks to share common setup or constraints between actions.\n def set_message\n @message = Message.find(params[:id])\n end\n \n # Only allow a trusted parameter \"white list\" through.\n def message_params\n params.require(:message).permit(:body)\n end\n end\n \n```\n\nこのコントローラを見て分かるのは、同じ @message を使うことでメッセージをIDを元に取得する処理を `set_message`\nという形で共通化できることです。 \nアクションごとに処理は独立しているので、@message の値がアクション間で共有されることはありませんが、処理を共通化できるのは大きなメリットです。\n\nこの共通化はコントローラだけでなく、ビューでも行われます。 \nnewアクションとeditアクションではそれぞれメッセージの新規作成と更新を行うためのフォームを表示しますが、これを共通化することができます。 \n`_form.html.erb` というファイルがそれです。 \nこのフォームは当然ながらアクションから渡された @messageの内容を登録・更新するためのもので、`new.html.erb` や\n`edit.html.erb` から呼び出されるようになっています。 \nこの場合も異なる変数名を使うより、同じ変数名を使った方がスムーズに共通部品である `_form.html.erb`を利用できて便利です。\n\nScaffoldはあくまで基本的な処理を自動生成してくれるだけなんですが、このメッセージ機能を拡張していくとその後共通部品を作ることは増えてきて、同じ変数名を使うメリットはどんどん大きくなってきます。\n\nこう言った理由があるので、「敢えて異なる変数をアクションごとに使う必要がない」んですね。\n\nまとめると、\n\n * 変数名は扱うモノが何なのか見てすぐわかるもので命名した方がいい(Rubyだけでなくプログラミング全般に言われること)\n * 同じ変数名を使えば、共通部品を作った場合も同じ変数を使えるので便利(これもプログラミング全般に言われること)\n * Railsのコントローラに関しては割とに通った構造になりやすいので、Railsの流儀に従った方がコードを読む人にも意味が伝わりやすい。言語に関わらずプログラムは分かりやすい方がいいので、敢えて異なる構造にすると分かりにくくなり、不親切になってしまう。\n\nという理由です。すでに回答済みのお二方とほぼ同じことを言っているだけなのですが、うまく伝わるでしょうか。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T14:33:39.533",
"id": "73475",
"last_activity_date": "2021-01-21T14:33:39.533",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43354",
"parent_id": "73406",
"post_type": "answer",
"score": 0
},
{
"body": "Rails は、リクエストごとに Controller を new しています。\n\n参考:\n<https://github.com/rails/rails/blob/130c128eae233bf71231c73b9c3c3b3f3ede918b/actionpack/lib/action_controller/metal.rb#L254>\n\nなので、毎回呼ばれる controller instance\nは別ものなので、そのインスタンス変数がメソッド(リクエスト)を超えて被っていても、問題になることはありません。\n\n結果、インスタンス変数はリクエスト単位でユニークに人間に分かりやすいものであれば良く、そうすると必然、 CRUD\nの中で利用される変数名は似通ってきたりします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-02-14T08:44:40.933",
"id": "73987",
"last_activity_date": "2021-02-14T08:51:12.450",
"last_edit_date": "2021-02-14T08:51:12.450",
"last_editor_user_id": "754",
"owner_user_id": "754",
"parent_id": "73406",
"post_type": "answer",
"score": 0
}
] | 73406 | null | 73418 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "webにおけるサービスは基本的にメールアドレスとパスワードでのログインが必要です。 \nしかし、スマートフォンのソーシャルゲームなどはニックネームの入力くらいしか要求されず、その後のログインも自動で行われているようでした。\n\nflutterの場合、device_infoというもので一意のデバイスIDが取得できるようですが、 \nメールアドレスやパスワードやユーザー名の代わりに \nその一意のデバイスIDだけを頼りにデータベースを構成してるのでしょうか? \nまたは、デバイスにトークンのようなものを保存し、それでユーザーを特定しているのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T09:09:06.540",
"favorite_count": 0,
"id": "73407",
"last_activity_date": "2021-01-20T04:22:52.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43585",
"post_type": "question",
"score": 1,
"tags": [
"database",
"flutter"
],
"title": "ソーシャルゲームにおけるユーザーの特定とログイン方法",
"view_count": 510
} | [
{
"body": "特定する=プライバシー侵害に直結する結構シビアな問題なので回答が付きにくいのかと。\n\nあなたの言う「特定」の意図というか案件というかで答えは異なるでしょう。\n\n一人のユーザ (Google Account) が複数台の Android 端末を持っているとき、その端末は \n「同じ」アカウントとみなすのか \n「違う」アカウントとみなすのか \nなどなど \n...にゃんこ大戦争とかたいていの Android ゲームは 1 Google Account\nで複数台の端末にインストールできて、課金するお財布は同じでもゲーム上は異なるアカウントだったりする...\n\nよって課金システムから見ると、これらは特定の結果「同じ」アカウントであり \nゲームシステムから見ると、これらは特定の結果「違う」アカウントであるわけで\n\n# IOS は持っていないので知らん\n\nプライバシー侵害しても個人を特定したい広告元とされたくないユーザー(OS ベンダ)との駆け引きからこの手の ID\nはいろいろ変遷をたどってきた経緯があって、たとえばこんな解説とか\n\n[iOS/Androidで端末を識別するIDまとめ](https://iridge.jp/blog/201404/4836/)\n\nまあ普通のスマホゲームではインストール時に端末の記憶装置にデータを保存することを許可してもらったうえで、そのゲームの提供者が運営するサーバー上で作ったそのゲーム専用のアカウント\nID を端末の内蔵記憶装置に保存しておくのが一般的かと思います。そうしておかないと機種変更などの際にアカウントの引継ぎが困難になっちゃいます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T00:21:13.623",
"id": "73420",
"last_activity_date": "2021-01-20T04:22:52.563",
"last_edit_date": "2021-01-20T04:22:52.563",
"last_editor_user_id": "8589",
"owner_user_id": "8589",
"parent_id": "73407",
"post_type": "answer",
"score": 1
}
] | 73407 | null | 73420 |
{
"accepted_answer_id": "73451",
"answer_count": 1,
"body": "Oracleのバックアップの取り方について質問が3つございます。環境は以下の通りです。\n\nバージョン : 12cR2 \n高速リカバリ領域 : なし \nログモード : ARCHIVELOG\n\n以下、質問です。\n\n①アーカイブログモードで運用していると、オンラインREDOログファイルの容量がいっぱいになって上書きされてしまう前に自動的にアーカイブ化してくれるというという認識なのですが、自動でアーカイブREDOログファイルを生成してくれるなら敢えて個別にアーカイブREDOログのバックアップを取る必要性は何ですか。1時間おきにアーカイブREDOログファイルのバックアップを取っていて、その度に過去のアーカイブREDOログファイルのバックアップは削除する。つまりアーカイブREDOログファイルのバックアップは常に1つだけになるように(実際は自動生成分もありますが)スケジューリングしていて、もしかしたら何かあったときのために自動生成分をあてにしているのかオンラインバックアップが取りたいからアーカイブログモードを選んでいるのかわかりませんが…。要点が逸れましたがひとまず個別にアーカイブREDOログファイルのバックアップを取る意味がわかりません。\n\n②特に指定をしなければアーカイブREDOログファイルはdbsディレクトリ以下に取られ(高速リカバリ領域は使用していないので)、蓄積されていくという認識ですが、アーカイブREDOログファイルの出力先を手動で取っているアーカイブREDOログファイルのバックアップ分と同じディスクに指定しています。これはリスクしかない気がするのですが、せっかく手動で取ってる分と自動で生成してくれてる分があるなら取得先、出力先は分けたほうがいいのではないでしょうか。\n\n③12cR2からはデフォルトで制御ファイル及びSPFILEのバックアップが、何らかのbackupコマンド実行後に必ず走るという認識なのですが、アーカイブREDOログファイルは①で挙げたタイミングで自動生成されるという認識です。しかし動きを見ていると、個別にアーカイブREDOログファイルの「バックアップ」を取った時点でアーカイブREDOログファイルの「自動生成」も行われています。アーカイブREDOログファイルのバックアップを取ったらアーカイブREDOログファイルの自動生成も同時に行われるのですか。そうなると、アーカイブREDOログファイルを手動バックアップした時点でログスイッチが行われるのでしょうか。\n\n宜しくお願い致します。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T10:19:19.413",
"favorite_count": 0,
"id": "73409",
"last_activity_date": "2021-01-20T15:55:33.000",
"last_edit_date": "2021-01-19T23:41:38.540",
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"oracle"
],
"title": "Oracleのバックアップについて",
"view_count": 199
} | [
{
"body": "## ①アーカイブREDOログをバックアップする必要性\n\n回答 アーカイブREDOログにはすべての更新履歴が含まれていますが、REDOログはそうではないからです。 \n例えば毎日の正時00分にフルバックアップを取っていて、1時間毎のREDOログファイルのバックアップを取っているとします。 \n毎日の正時01分時点のREDOログファイルのバックアップには、00時から01時の間のすべての更新履歴が含まれていない可能性があります。1時間の間にREDOログのローテーションが一巡する可能性があります。 \n複数のアーカイブREDOログファイルには、アーカイブREDOログファイルが削除されるまでのすべての更新履歴が含まれています。\n\n## ②アーカイブREDOログをdbsディレクトリに指定してよいか?\n\n回答 通常は制御ファイル、REDOログファイル、アーカイブREDOログは多重化します。 \n多重化しているなら、どこを使用しても問題ないと思います。 \n故障や誤操作によるディスク破損に備えるならディスクをRAID構成にする方がよいです。\n\n## ③アーカイブREDOログファイルが作成されるタイミング\n\n回答\nあるREDOログファイルの内容がすべてデータファイルに反映されたタイミングでアーカイブREDOログファイルが作成されるとの認識ですが、正しい認識かちょっと自信がありません。\n\n* * *\n\n私はDBMSの開発者でも実務でデータベースを保守した経験もありません。Oracleデータベースのアプリケーションを開発したときの経験やそのとき勉強した知識からの回答です。 \n正確な情報はマニュアルやホワイトペーパにあたるべきですが、正確性を重視しているためか、詳しすぎてよくわからなかった経験があります。マニュアルを理解する助けになると思って回答しています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T15:55:33.000",
"id": "73451",
"last_activity_date": "2021-01-20T15:55:33.000",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35558",
"parent_id": "73409",
"post_type": "answer",
"score": 0
}
] | 73409 | 73451 | 73451 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "## 解決したいこと\n\ncssでコーディングをしているのですが、flexboxで要素の高さが揃わないです\n\n## 状況\n\n下記のコードがHTMLです。\n\n```\n\n <div class=\"plans-content\">\n <div class=\"plans-content-item\">\n <h3 class=\"plans-content-title\">タイトル1</h3>\n <div class=\"plans-content-detail\">\n <div class=\"plans-content-detail-title\">\n 詳細タイトル1\n </div>\n <div class=\"plans-content-detail-list\">\n <ul>\n <li class=\"content-detail-list-item\">アイテム1</li>\n <li class=\"plans-content-detail-list-item\">アイテム2</li>\n <li class=\"plans-content-detail-list-item\">アイテム3</li>\n <li class=\"plans-content-detail-list-item\">アイテム4</li>\n <li class=\"plans-content-detail-list-item\">アイテム5</li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n <div class=\"plans-content\">\n <div class=\"plans-content-item\">\n <h3 class=\"plans-content-title\">タイトル1</h3>\n <div class=\"plans-content-detail\">\n <div class=\"plans-content-detail-title\">\n 詳細タイトル1\n </div>\n <div class=\"plans-content-detail-list\">\n <ul>\n <li class=\"content-detail-list-item\">アイテム1</li>\n <li class=\"plans-content-detail-list-item\">アイテム2</li>\n <li class=\"plans-content-detail-list-item\">アイテム3</li>\n <li class=\"plans-content-detail-list-item\">アイテム4</li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n \n```\n\n上の要素を\n\n```\n\n <div class=\"plans-contents\"></div>\n \n```\n\nというHTMLで囲っています\n\nCSSは\n\n```\n\n .plans-contents {\n display: flex;\n }\n \n .plans-content {\n display: flex;\n }\n \n // リストを縦方向に並べる\n .plans-content-detail-list {\n display: flex;\n flex-direction: column;\n }\n \n```\n\nとしたのですが、 \n`<div class=\"plans-content-detail-list\">`\nで囲まれた領域がliタグの数によって伸び縮みしてしまいます。(下記の画像参照)\n\n[](https://i.stack.imgur.com/dB85H.png)\n\nflexboxを使っているので、 `<div class=\"plans-content-detail\">`\nで囲まれた領域の高さが同じになるのはわかるのですが、その中身の高さが揃わないので困っています。\n\n教えてください、",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T12:32:55.167",
"favorite_count": 0,
"id": "73412",
"last_activity_date": "2021-01-20T02:12:38.140",
"last_edit_date": "2021-01-19T12:55:23.203",
"last_editor_user_id": "3060",
"owner_user_id": "9542",
"post_type": "question",
"score": 0,
"tags": [
"html",
"css",
"sass"
],
"title": "flexboxで要素の高さが揃わない",
"view_count": 721
} | [
{
"body": "下記でどうでしょうか。\n\n```\n\n .plans-contents {\n display: flex;\n }\n \n .plans-content {\n display: flex;\n }\n \n .plans-content-item {\n display: flex;\n flex-direction: column;\n }\n .plans-content-detail {\n height: 100%;\n border-radius: 5px;\n overflow: hidden;\n }\n \n .plans-content-detail-list {\n background-color: lightgray;\n display: flex;\n flex-direction: column;\n height: 100%;\n border-radius: 5px;\n }\n \n```\n\n`.plans-content-detail-list`に`height: 100%;`として、親要素からはみ出した部分を`overflow:\nhidden;`で隠すという手法です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T02:12:38.140",
"id": "73423",
"last_activity_date": "2021-01-20T02:12:38.140",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "42240",
"parent_id": "73412",
"post_type": "answer",
"score": 1
}
] | 73412 | null | 73423 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "最終目的:プログラムが組みたい\n\n上の画像のような結果を得るにはどうプログラム組むと良いのでしょうか。\n\n現在の状態:Anacondaをインストールしたが、その先のプログラムの組み方・実行のさせ方が全く分からない。",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T14:00:47.743",
"favorite_count": 0,
"id": "73414",
"last_activity_date": "2021-01-24T20:59:37.603",
"last_edit_date": "2021-01-24T20:59:37.603",
"last_editor_user_id": "43590",
"owner_user_id": "43590",
"post_type": "question",
"score": -4,
"tags": [
"python",
"python3"
],
"title": "プログラムが組めない",
"view_count": 233
} | [
{
"body": "言語選択がPHPになっていたのが一つ問題だったみたいです! Python3に直したら起動することは出来ました!",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T05:52:45.347",
"id": "73430",
"last_activity_date": "2021-01-20T05:52:45.347",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43590",
"parent_id": "73414",
"post_type": "answer",
"score": 0
}
] | 73414 | null | 73430 |
{
"accepted_answer_id": "73416",
"answer_count": 1,
"body": "Web系ごく初心者ですので用語の誤り、説明行き届かない点などご指摘ください.\n\n## 背景(今までやったこと)\n\nLaravelを使用してPHPアプリを作っています.Modelを定義して、Viewを作って、Controllerを作ってと、一通り目的のページを出力するまでたどり着きました.`index.list.blade.php`がテンプレートファイルになるのですが、ここに山ほどJavaScriptのコードを書かねばなりません.しかし、そんなことをやり始めたらロジック(JavaScript)とスタイル(というか表示出力のHTML)がグッチャングッチャンになることは目に見えています.ならばJavaScriptは別ファイルに納めてと考えたのですが、いままでちょこちょこJavaScriptの小規模なプログラムを作ってきた経験はありますが、あまりに簡単に粗雑でトリッキーなコードが書けてしまうので、こういうのは精神衛生上よろしくないと考えてVSCode+Node.jsでTypeScriptに挑戦してみました.\n\n## 困っている点\n\nコードをTypeScriptで書く分については、型付けができるので大変気に入っております.ところが、作成した`index.list.blade.ts`をコンパイルして`index.list.blade.js`に落とした場合、最初は次のようなエラーが出てしまいました.\n\n```\n\n <!DOCTYPE html >\n <html>\n <head>\n <meta charset=\"UTF-8\"/>\n <title>Index List</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"{{ asset('css/bootstrap.min.css') }}\"/>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"{{ asset('css/datatables.min.css') }}\"/>\n <script type=\"text/javascript\" src=\"{{ asset('javascript/jquery-3.5.1.min.js') }}\"></script>\n <script type=\"text/javascript\" src=\"{{ asset('javascript/bootstrap.bundle.min.js') }}\"></script>\n <script type=\"text/javascript\" src=\"{{ asset('javascript/datatables.min.js') }}\"></script>\n <script type=\"text/javascript\" src=\"{{ asset('javascript/index.list.blade.js') }}\"></script>\n ...\n </head>\n \n```\n\nブラウザのエラーメッセージ:\n\n> Uncaught ReferenceError: define is not defined at index.list.blade.js:20\n\nこれはWebページを参照して、`require.js`が必要なようでしたので\n\n```\n\n <!DOCTYPE html >\n <html>\n <head>\n <meta charset=\"UTF-8\"/>\n <title>Index List</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"{{ asset('css/bootstrap.min.css') }}\"/>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"{{ asset('css/datatables.min.css') }}\"/>\n <script type=\"text/javascript\" src=\"{{ asset('javascript/jquery-3.5.1.min.js') }}\"></script>\n <script type=\"text/javascript\" src=\"{{ asset('javascript/bootstrap.bundle.min.js') }}\"></script>\n <script type=\"text/javascript\" src=\"{{ asset('javascript/datatables.min.js') }}\"></script>\n <!--script type=\"text/javascript\" src=\"{{ asset('javascript/index.list.blade.js') }}\"></script-->\n <script type=\"text/javascript\" data-main=\"{{ asset('javascript/index.list.blade.js') }}\" src=\"{{ asset('javascript/require.js') }}\"></script>\n ...\n </head>\n \n```\n\nで回避できました.\n\nところが、従来`index.list.blade.php`に書いておりました`$(function(){})`がTypeScriptの中だとfireしてくれません.\n\n[元のTypeScriptのコード:index.list.blade.ts]\n\n```\n\n /// <reference path=\"typings/index.d.ts\" />\n \n import * as dlg from \"./index.list.blade.dlg\";\n \n interface IndexKeyObj{\n no:string;\n brand:string;\n type:string;\n year:string;\n class:string;\n lang:string;\n indexExists:boolean;\n generateIndex:boolean;\n status:string;\n }\n \n let indexKeyTable:Array<IndexKeyObj>=[];\n /**\n * Document ready function\n */\n $(function () {\n console.log(\"Hello World!\");\n let index_rows = $(\"table#index-table tr.index-row\");\n // Construct index data structure\n index_rows.each(function () {\n let no: string = $(this).children(\".no\").text();\n let brand: string = $(this).children(\".brand\").text();\n let type: string = $(this).children(\".type\").text();\n let year: string = $(this).children(\".year\").text();\n let bclass: string = $(this).children(\".class\").text();\n let lang: string = $(this).children(\".lang\").text();\n let indexExists: boolean = $(this).children(\".index\").text() === \"-\" ? false : true;\n let indexKeyObj: IndexKeyObj = { \"no\": no, \"brand\": brand, \"type\": type, \"year\": year, \"class\": bclass, \"lang\": lang, \"indexExists\": indexExists, \"generateIndex\": false, \"status\": \"\" };\n //console.log(index_key_obj); \n indexKeyTable.push(indexKeyObj);\n });\n \n```\n\n[コンパイル後のJavaScript:index.list.blade.js]\n\n```\n\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n }) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n }));\n var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n }) : function(o, v) {\n o[\"default\"] = v;\n });\n var __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n };\n define(\"index.list.blade.dlg\", [\"require\", \"exports\"], function (require, exports) {\n \"use strict\";\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.dlgOk = void 0;\n function dlgOk(msg) {\n $(\"div#indexModal div.modal-header\").css(\"visibility\", \"hidden\");\n $(\"div#indexModal div.modal-footer button.btn-secondary\").html(\"OK\");\n $(\"div#indexModal div.modal-footer button.btn-primary\").css(\"visibility\", \"hidden\");\n $(\"div#indexModal div.modal-body\").html(msg);\n $(\"div#indexModal\").modal(\"show\");\n }\n exports.dlgOk = dlgOk;\n });\n /// <reference path=\"typings/index.d.ts\" />\n define(\"index.list.blade\", [\"require\", \"exports\", \"index.list.blade.dlg\"], function (require, exports, dlg) {\n \"use strict\";\n Object.defineProperty(exports, \"__esModule\", { value: true });\n dlg = __importStar(dlg);\n var indexKeyTable = [];\n /**\n * Document ready function\n */\n $(function () {\n console.log(\"Hello World!\");\n var index_rows = $(\"table#index-table tr.index-row\");\n // Construct index data structure\n index_rows.each(function () {\n var no = $(this).children(\".no\").text();\n var brand = $(this).children(\".brand\").text();\n var type = $(this).children(\".type\").text();\n var year = $(this).children(\".year\").text();\n var bclass = $(this).children(\".class\").text();\n var lang = $(this).children(\".lang\").text();\n var indexExists = $(this).children(\".index\").text() === \"-\" ? false : true;\n var indexKeyObj = { \"no\": no, \"brand\": brand, \"type\": type, \"year\": year, \"class\": bclass, \"lang\": lang, \"indexExists\": indexExists, \"generateIndex\": false, \"status\": \"\" };\n //console.log(index_key_obj); \n indexKeyTable.push(indexKeyObj);\n });\n \n```\n\n## 教えていただきたい点\n\nTypeScriptの中のコードで`$(function(){})`を起動することはできないのでしょうか?方法がありましたらご教授お願い致します.\n\n## 環境\n\nWindows10 64bit, VSCode+Node.js, ブラウザはChromeです.\n\n不足の情報がありましたらお知らせください.",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T14:05:50.640",
"favorite_count": 0,
"id": "73415",
"last_activity_date": "2021-01-19T15:36:30.513",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9503",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery",
"laravel",
"typescript"
],
"title": "TypeScriptでJQueryの$(function () {})を処理させるには?",
"view_count": 357
} | [
{
"body": "失礼いたしました.\n\n[Is there a Main()-like function in\nTypeScript?](https://stackoverflow.com/questions/25273366/is-there-a-main-\nlike-function-in-typescript)\n\nに書いてある通りでした.例えば\n\n```\n\n $(function () {});\n \n```\n\nを\n\n```\n\n function initWindow(){}\n \n```\n\nに書き換えて、コードの最後で\n\n```\n\n initWindow();\n \n```\n\nで呼び出すだけで事足りました.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-19T15:36:30.513",
"id": "73416",
"last_activity_date": "2021-01-19T15:36:30.513",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9503",
"parent_id": "73415",
"post_type": "answer",
"score": 1
}
] | 73415 | 73416 | 73416 |
{
"accepted_answer_id": "73515",
"answer_count": 1,
"body": "**行いたいこと** \nPython3で一時的にFuture Warning(`XX will be\ndeprecated`...という警告)を一時的に非表示にし、所定の作業が終わったら、手動でまた再表示させたいです。\n\n**現状** \n`warnings.simplefilter('ignore',\nFutureWarning)`を行えば非表示にできることはわかりましたが、再表示させるコマンドを検索で見つけることができていません。\n\n**現状の詳細**\n\n * 本警告が出るのが特定のライブラリ(`X`とします)をimportした時です。\n * 今行っている作業では「複数の.pyファイルを読み込んで、その中に定義されている関数を使う」ということをしています。その「複数の.py」のほぼ全てで、`import X`をしています。そのため各.pyを読み込むたびに警告メッセージが出力されてしまい、コマンド出力が警告メッセージで埋まってしまい必要な情報が見にくくなっています。\n * パッケージ`X`の方で将来のバージョンに対応した設定に切り替えれば良いかと思いましたが、一度python3を`> exit()`すると設定が戻ってしまいます。(`X`ライブラリにも問い合わせたところ「pythonをローンチするたびにデフォルトに戻る設定になってしまっている」とのことでした)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T01:15:05.230",
"favorite_count": 0,
"id": "73421",
"last_activity_date": "2021-01-23T02:53:52.490",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30785",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "Pythonで非表示にしたwarningを再表示させたい",
"view_count": 437
} | [
{
"body": "kunifさんより頂いた回答\n\n> この記事が参考になりそうです。[Enable all warnings in Python, after they were disabled by\n> an imported module](https://stackoverflow.com/q/43832981/9014308)\n\nが有効そうであるため、一度この質問を閉じるため自己回答します。 \nなお、動作を試したかったのですが、そもそも警告メッセージを非表示にできないという問題が新たに発生しており、ライブラリ作成者に問い合わせたところライブラリの都合によるかもしれないとのことでしたので、本質問は一度閉じたいと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T02:53:52.490",
"id": "73515",
"last_activity_date": "2021-01-23T02:53:52.490",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30785",
"parent_id": "73421",
"post_type": "answer",
"score": 0
}
] | 73421 | 73515 | 73515 |
{
"accepted_answer_id": "73427",
"answer_count": 2,
"body": "表題について質問があります。\n\n現在、windows10で通信アプリを作成しており、アプリを介して別のネットワークへマウントを試みております。\n\nc++のsystem関数を使用すれば、マウントができると思いますが、そこが上手くできておらずどのようにすれば良いか分かっておりません。以下はアプリ内に組み込んだ簡単な例です。\n\nsystem(\"mount 192.168.11.151:/home/Sample/root Q:\");\n\n上記のコマンドをコマンドプロンプト上で設定すれば正しくマウントできます。しかし、アプリ内でsystem関数を使用しても正しく動作しません。\n\nお手数ですが、もし何かしらアドバイスあれば教えていただきたいです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T02:00:52.953",
"favorite_count": 0,
"id": "73422",
"last_activity_date": "2021-01-20T04:18:07.060",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43586",
"post_type": "question",
"score": 1,
"tags": [
"c++",
"windows",
"cmd"
],
"title": "windows環境でC++関数systemを使って、他のネットワークへマウントする方法について",
"view_count": 426
} | [
{
"body": "回答ではないのでコメント欄でやりたいところですが長くなるので回答欄で\n\nLinux / Unix では、普通 `mount` を引数ナシで実行すると現在マウントされている一覧が表示されます。\n\n```\n\n $ mount\n / on /dev/vg00/lvol3 ...\n /home on /dev/dsk/c0t5d0 ....\n $ \n \n```\n\n同様に、まずはコマンドプロンプトから `mount` して一覧が出るようなら `system(\"mount\");`\nのみ実行して一覧が表示されるかどうかをまず確かめてみてください。 GUI プログラムであるなら **どこに**\n出力されるか、どうやって出力を受け取るかは調査のこと。それが面倒なら別途コンソールアプリで試してみましょう。\n\nあと `system()` の返却値と `errno` の値も確認しましょう。 [man 3\nsystem](https://linuxjm.osdn.jp/html/LDP_man-pages/man3/system.3.html)\n\n話の続きはそのあと(確認結果を元質問の編集の形で追記していただけると幸い)\n\n# パスワードの入力があり得るので `mount` の `stdin` つか `tty` がコンソールでない場合は `mount`\n自体が実動作をせずに即終了しているのではないかと妄想",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T04:16:27.193",
"id": "73426",
"last_activity_date": "2021-01-20T04:16:27.193",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "73422",
"post_type": "answer",
"score": 0
},
{
"body": "質問文にありませんが64bit OSと仮定します。\n\n * Client for NFSのmountコマンドは64bit版(`C:\\Windows\\System32\\mount.exe`)しか提供されません。\n * コマンドプロンプトも通常の起動方法であれば64bit版(`C:\\Windows\\System32\\cmd.exe`)が使われます。\n * `PATH`は一般的に`C:\\Windows\\system32`に通します。\n\nこの状況において、32bitアプリケーションでは[File System\nRedirector](https://docs.microsoft.com/en-us/windows/win32/winprog64/file-\nsystem-\nredirector)により`C:\\Windows\\System32`へのアクセスは`C:\\Windows\\SysWOW64`にリダイレクトされます。このため、\n\n>\n```\n\n> system(\"mount 192.168.11.151:/home/Sample/root Q:\");\n> \n```\n\nこの場合 `C:\\Windows\\SysWOW64\\mount.exe` を探しに行き、実行ファイルが見つからない、となります。 \n対策としてはWindows Vista以降であれば\n\n```\n\n system(\"%windir%\\Sysnative\\mount.exe 192.168.11.151:/home/Sample/root Q:\");\n \n```\n\nで動作すると思います。 \n32bit版コマンドプロンプト(`C:\\Windows\\SysWOW64\\cmd.exe`)を使用すれば状況を再現できます。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T04:18:07.060",
"id": "73427",
"last_activity_date": "2021-01-20T04:18:07.060",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "73422",
"post_type": "answer",
"score": 2
}
] | 73422 | 73427 | 73427 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "postモデルのレコードを削除した際に、それに紐づくcommentモデルのレコードを削除したいのですが、以下のエラーになります。 \n現状コメントがなければ正常に削除ができる状態です。\n\nわかる方がいましたらよろしくお願いします。\n\n**エラーメッセージ:**\n\n```\n\n Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`anipho_development`.`comments`, CONSTRAINT `fk_rails_2fd19c0db7` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`))\n \n```\n\n現状のコードはこんな感じです\n\nマイグレーションファイル\n\n```\n\n class CreateComments < ActiveRecord::Migration[6.0]\n def change\n create_table :comments do |t|\n t.references :user, foreign_key: true\n t.references :post, foreign_key: true\n t.string :content, null: false\n t.timestamps\n end\n end\n end\n \n```\n\ncomment.rb\n\n```\n\n class Comment < ApplicationRecord\n belongs_to :user\n belongs_to :post\n validates :content, presence: true\n end\n \n```\n\npost.rb\n\n```\n\n class Post < ApplicationRecord\n extend ActiveHash::Associations::ActiveRecordExtensions\n belongs_to_active_hash :category\n belongs_to :user\n has_one_attached :image\n has_many :comments, dependent: :destroy\n \n with_options presence: true do\n validates :image\n validates :title\n validates :category_id, numericality: { other_than: 1 , message: \"は--以外から選んでください\"} \n end\n end\n \n```\n\nuser.rb\n\n```\n\n class User < ApplicationRecord\n # Include default devise modules. Others available are:\n # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable\n devise :database_authenticatable, :registerable,\n :recoverable, :rememberable, :validatable\n \n has_many :posts\n has_many :comments\n \n PASSWORD_REGEX = /\\A(?=.*?[a-z])(?=.*?\\d)[a-z\\d]+\\z/i.freeze\n validates :nickname, presence: true\n validates :password, format: { with: PASSWORD_REGEX}\n \n end\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T04:52:57.720",
"favorite_count": 0,
"id": "73428",
"last_activity_date": "2023-07-02T08:04:50.563",
"last_edit_date": "2021-01-20T11:50:41.707",
"last_editor_user_id": "3060",
"owner_user_id": "43597",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"mysql"
],
"title": "外部キーを持つデータのdestroyがうまくいかず、dependentオプションを付けてもエラーになってしまいます。",
"view_count": 1564
} | [
{
"body": "見た感じちゃんと動きそうなコードですね。。 \npostモデルの削除はどうやって行っていますか?\n\nレコードの削除はいくつかの方法がありますが、RailsではおおむねActiveRecordの4つのメソッドのうちどれかを使うことになります。 \ndelete, delete_all, destroy, destroy_allです。 \n4つもあって混乱すると思いますが、そのエラーを出さないように削除するためには、\n\n```\n\n @post = Post.find(params[:id]\n @post.destory\n \n```\n\nという感じで消す必要があります。\n\n上に揚げた4つのメソッド、大別して delete系とdestory系の二つに分かれているんですが、\n\n * delete系...実行するとActiveRecordが該当するDELETE文のSQLを生成し、そのまま実行する。ヴァリデーションやコールバックなど、ActiveRecordが更新系処理に付随して実行する処理は全てスキップされる。\n * destroy系...上と違い、ActiveRecordが更新系処理に付随して実行する処理を実行後に削除処理が実行される。\n\nという違いがあります。\n\nPostモデルに定義されている\n\n```\n\n has_many :comments, dependent: :destroy\n \n```\n\nこれ。この依存関係の定義はコールバックに相当するので、delete系メソッドで削除した場合は実行されません。 \nなのでメソッド実行時にすぐ下記のSQLが発行されます。\n\n```\n\n DELETE FROM posts where id=xxxx\n \n```\n\nCreateComments のマイグレーションファイルにFKの定義がある通り、\n\n```\n\n t.references :post, foreign_key: true\n \n```\n\ncommentsテーブルのレコードは、常に親であるpostsテーブルのレコードのidを必ず持つように設定されています。 \nコメントが残った状態でpostsレコードを消してしまうとコメントが孤児状態で浮いてしまうので、それを防止するためのFKのエラーが発生している訳ですね。 \nこのエラーを発生させないように、先にcommentsのレコードを消す必要がある訳ですが、そのためには `dependent: :destroy`\nの定義だけでなく、destroyメソッドを使用する必要があります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T15:14:08.457",
"id": "73476",
"last_activity_date": "2021-01-21T15:14:08.457",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43354",
"parent_id": "73428",
"post_type": "answer",
"score": 0
}
] | 73428 | null | 73476 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "コードを実装すると、下記のエラーが発生してしまいます。 \nそこで、`pip install keras.backend` でインストールを行いましたが、上手く行きませんでした。 \nどのような手順で行えば、インストールが出来、解決できるでしょうか? \n大変お手数おかけしますが、ご回答お願い致します。\n\n```\n\n import keras\n from keras.applications.imagenet_utils import preprocess_input\n from keras.backend.tensorflow_backend import set_session\n from keras.models import Model\n from keras.preprocessing import image\n import matplotlib.pyplot as plt\n import numpy as np\n from scipy.misc import imread\n import tensorflow as tf\n \n```\n\n```\n\n ModuleNotFoundError Traceback (most recent call last)\n <ipython-input-3-8b6965f27c29> in <module>\n 1 import keras\n 2 from keras.applications.imagenet_utils import preprocess_input\n ----> 3 from keras.backend.tensorflow_backend import set_session\n 4 from keras.models import Model\n 5 from keras.preprocessing import image\n \n ModuleNotFoundError: No module named 'keras.backend.tensorflow_backend'; 'keras.backend' is not a package\n \n```\n\nちなみに、versionはkeras:2.4.3、tensorflow:2.4.0でございます。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T05:50:08.277",
"favorite_count": 0,
"id": "73429",
"last_activity_date": "2021-08-17T14:08:40.747",
"last_edit_date": "2021-01-20T06:20:29.040",
"last_editor_user_id": "3060",
"owner_user_id": "40847",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"keras"
],
"title": "keras,backendインストール方法",
"view_count": 399
} | [] | 73429 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "モバイルアプリのセキュリティについて調べていく過程で、 <https://stackoverflow.com/a/5557283/3090068>\nのような記事を何回か見掛けたりします。どういうことかというと、 iOS において、配布されているアプリは暗号化されている、という趣旨の記述です。\n\n# 質問\n\niOS\nアプリが仮に暗号化されているとして、それはどのタイミングで、誰が、何を、どのように暗号化しているのでしょうか?セキュリティについて考えるのであるならば、どのような全体的な仕組みでこれが実現されているのかを理解することが重要であると考えており、しかしこれが分かるように書かれているソースなどを発見できていないので、質問しています。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T06:10:54.583",
"favorite_count": 0,
"id": "73432",
"last_activity_date": "2021-01-20T06:10:54.583",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"ios",
"security"
],
"title": "iOS のアプリは暗号化されているらしいのですが、それはどのような機構で実現されているのでしょうか?",
"view_count": 89
} | [] | 73432 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "私は今、vue.jsでウェブアプリの開発をしています。 \n下記のように、assetsに配置しているpdfファイルをダウンロードできる画面作成したいのですがエラーとなってしまいます。 \n方法を教えてください。\n\n```\n\n <template>\n <a href=\"./../assets/sample.pdf\" download>sample.pdf download</a>\n </template>\n \n```\n\nエラーメッセージは以下の通りです。宜しくお願い致します。\n\n```\n\n Module parse failed: Unexpected token (1:0)\n You may need an appropriate loader to handle this file type, currently no lo ders are configured to process this file. See https://webpack.js.org/concept #loaders\n (Source code omitted for this binary file)\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T06:49:52.450",
"favorite_count": 0,
"id": "73433",
"last_activity_date": "2021-01-20T08:25:33.630",
"last_edit_date": "2021-01-20T08:25:33.630",
"last_editor_user_id": "3060",
"owner_user_id": "43599",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"vue.js"
],
"title": "vueでassetsのpdfを取得する方法",
"view_count": 845
} | [] | 73433 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "現在の状況:PCAのスクリプトをpaiza(beta)に打ち込んだが以下のようなエラーが出て実行が出来ない。\n\nFile \"Main.py\", line 6 \nd_pca <\\- prcomp(coil20[,-ncol(coil20)], scale=TRUE) \n^ \nSyntaxError: invalid syntax\n\n最終目的:以下のリンクにあるような実行結果を得たい。 ※この質問内にも目的の画像は載せています \n<https://blog.albert2005.co.jp/2015/12/02/tsne/>\n\n現在の状態を分かりやすいように画像で記しておきます \n[](https://i.stack.imgur.com/Tklcw.png)\n\n最終目的の画像は以下の画像になります \n[](https://i.stack.imgur.com/jZ9xW.png)\n\n環境:OS windows10 \npython3.8",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T07:14:27.780",
"favorite_count": 0,
"id": "73434",
"last_activity_date": "2021-01-23T12:46:29.073",
"last_edit_date": "2021-01-20T07:47:53.913",
"last_editor_user_id": "43590",
"owner_user_id": "43590",
"post_type": "question",
"score": -1,
"tags": [
"python",
"python3"
],
"title": "PCAとt-SNEを使って目的の結果になるようにしたいです!",
"view_count": 115
} | [
{
"body": "言語設定を変更したら実行できました。pythonのコードをR言語の基盤で書いてしまったことが問題だったみたいです",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T12:46:29.073",
"id": "73526",
"last_activity_date": "2021-01-23T12:46:29.073",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43590",
"parent_id": "73434",
"post_type": "answer",
"score": 0
}
] | 73434 | null | 73526 |
{
"accepted_answer_id": "73443",
"answer_count": 1,
"body": "sql文\n\n```\n\n SELECT STORE_DM ,AG_DM \n CASE WHEN rg_dm = store_dm \n THEN store_dm\n ELSE 'NULL' \n END \n FROM member; \n \n```\n\n上記を実行したら下記エラーが出ました。 \nどうしたら条件を実行できるか教えて頂きたいです。\n\n条件 \nCASE式でstore_dm項目について \nrg_dm = store_dmの場合store_dm、 \nそうでない場合はnullにしたい。\n\nエラー\n\n```\n\n SELECT STORE_DM ,AG_DM \n CASE WHEN rg_dm = store_dm \n THEN store_dm\n ELSE 'NULL' \n FROM member; \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T07:26:07.837",
"favorite_count": 0,
"id": "73435",
"last_activity_date": "2021-02-07T10:47:13.760",
"last_edit_date": "2021-02-07T10:47:13.760",
"last_editor_user_id": "3060",
"owner_user_id": "32774",
"post_type": "question",
"score": 0,
"tags": [
"sql",
"postgresql"
],
"title": "postgresql のcase文で値取得時エラーが出てしまいました。",
"view_count": 498
} | [
{
"body": "外部サイトの[もしかしてマルチポスト](https://teratail.com/questions/317272)の回答にあるように、`AG_DM`とcase文の間のカンマが抜けています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T10:58:17.697",
"id": "73443",
"last_activity_date": "2021-01-20T10:58:17.697",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "73435",
"post_type": "answer",
"score": 1
}
] | 73435 | 73443 | 73443 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "**実行環境:** \nWinodows 1p Pro (64bit) \nVagrant 2.2.14 \nUbuntu 16.04.6 LTS \nDocker 18.09.7 \nruby:ruby 2.7.2p137\n\nDocker のコンテ内でRubyのsinatraライブラリをインストールするために \n`bundle install` を実行したところ、以下のエラーが発生しました。\n\n```\n\n Fetching source index from https://rubygems.rog/\n \n Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.rog/\n \n Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.rog/\n \n Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.rog/\n \n Could not fetch specs from https://rubygems.rog/\n \n```\n\nコンテナを立ち上げた時のコマンドは以下を実行しました。\n\n```\n\n sudo docker container run -it -p 4567:4567 --name sinatra -v ${PWD}/src:/var/www sample/sinatra:latest\n \n```\n\n調べたら、コマンドを実行したら解決したという情報を入手したので\n\n```\n\n gem update --system\n \n```\n\nを実行して、再度インストールを実行。変化がありません。\n\n`wget https://api.rubygems.org/specs.4.8.gz` を実行してダウンロードできるか試しましたが、これは成功しました。\n\nドメインの IP アドレスを調べました。\n\n```\n\n root@dfed40fdb477:/var/www# host api.rubygems.org\n api.rubygems.org is an alias for rubygems.org.\n rubygems.org has address 151.101.2.132\n rubygems.org has address 151.101.130.132\n rubygems.org has address 151.101.194.132\n rubygems.org has address 151.101.66.132\n rubygems.org has IPv6 address 2a04:4e42::644\n rubygems.org has IPv6 address 2a04:4e42:200::644\n rubygems.org has IPv6 address 2a04:4e42:600::644\n rubygems.org has IPv6 address 2a04:4e42:400::644\n rubygems.org mail is handled by 10 mxb.mailgun.org.\n rubygems.org mail is handled by 10 mxa.mailgun.org.\n \n```\n\nhostファイルに記述しました。\n\n```\n\n 151.101.2.132 api.rubygems.org\n 151.101.130.132 api.rubygems.org\n 151.101.194.132 api.rubygems.org\n 151.101.66.132 api.rubygems.org\n \n 2a04:4e42::644 api.rubygems.org\n 2a04:4e42:200::644 api.rubygems.org\n 2a04:4e42:600::644 api.rubygems.org\n 2a04:4e42:400::644 api.rubygems.org\n \n```\n\n再度インストールを実行しましたが、変化がありません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T09:25:34.647",
"favorite_count": 0,
"id": "73438",
"last_activity_date": "2021-01-20T11:44:33.850",
"last_edit_date": "2021-01-20T11:41:46.640",
"last_editor_user_id": "3060",
"owner_user_id": "43098",
"post_type": "question",
"score": 0,
"tags": [
"ruby",
"docker"
],
"title": "bundle install エラーが表示されインストールできません",
"view_count": 1773
} | [
{
"body": "`bundle install` 実行時のエラーメッセージに表示されているドメイン名が `.rog` となっていますが、正しくは `.org`のはずです。 \nおそらく `Gemfile` の中にタイポがあるのでしょう。\n\n```\n\n Fetching source index from https://rubygems.rog/\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T09:56:03.897",
"id": "73439",
"last_activity_date": "2021-01-20T11:44:33.850",
"last_edit_date": "2021-01-20T11:44:33.850",
"last_editor_user_id": "3060",
"owner_user_id": "442",
"parent_id": "73438",
"post_type": "answer",
"score": 3
}
] | 73438 | null | 73439 |
{
"accepted_answer_id": "73450",
"answer_count": 1,
"body": "以下の内容についてお聞きしたいです。\n\n### 【実現したい内容】\n\nList表示でeditボタンを押した際に、こちらで指定した行だけ左側の削除ボタンが出て欲しいと思っています。 \n以下で言うと例えば0番目のtaroは削除ボタンがあって、hogeは削除ボタンがない状態にしたいです。 \n[](https://i.stack.imgur.com/TG0b0.png)\n\n### 【コード】\n\n上記の画像は以下のコードで作成しています。\n\n```\n\n struct Person: Identifiable, Hashable {\n var id: UUID = UUID()\n var name: String\n var age: Int\n }\n \n struct ContentView: View {\n @State var persons: [Person] = [Person(name: \"taro\", age: 10), Person(name: \"hoge\", age: 15)]\n \n var body: some View {\n NavigationView {\n List {\n ForEach(self.persons) { person in\n Text(person.name)\n }\n .onDelete(perform: { indexSet in\n self.persons.remove(at: indexSet.first!)\n })\n }\n .navigationBarItems(trailing: EditButton())\n }\n }\n }\n \n```\n\n### 【お聞きしたいこと】\n\n 1. 実現したい内容の実現方法\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T14:02:41.650",
"favorite_count": 0,
"id": "73448",
"last_activity_date": "2021-01-20T14:57:39.827",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24870",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"swiftui"
],
"title": "SwiftUI: Listの編集モードで削除できる対象を絞る",
"view_count": 274
} | [
{
"body": "[`deleteDisabled(_:Bool)`と言うview\nmodifier](https://developer.apple.com/documentation/swiftui/gaugestyleconfiguration/maximumvaluelabel-\nswift.struct/deletedisabled\\(_:\\))がちょうどご記載の機能を実現するためのもののようです。\n\n```\n\n struct Person: Identifiable, Hashable {\n var id: UUID = UUID()\n var name: String\n var age: Int\n var deletable: Bool\n }\n \n struct ContentView: View {\n @State var persons: [Person] = [\n Person(name: \"taro\", age: 10, deletable: true),\n Person(name: \"hoge\", age: 15, deletable: false),\n ]\n \n var body: some View {\n NavigationView {\n List {\n ForEach(self.persons) { person in\n Text(person.name)\n .deleteDisabled(!person.deletable)\n }\n .onDelete(perform: { indexSet in\n self.persons.remove(at: indexSet.first!)\n })\n }\n .navigationBarItems(trailing: EditButton())\n }\n }\n }\n \n```\n\nSwiftUIのドキュメントの[View\nModifiersのページ](https://developer.apple.com/documentation/swiftui/gaugestyleconfiguration-\nmaximumvaluelabel-view-\nmodifiers)を眺めていると、意外なことが簡単に実現できそうなものが見つかったりするので、お時間のある時には時々眺めて試してみるといいかもしれません。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-20T14:57:39.827",
"id": "73450",
"last_activity_date": "2021-01-20T14:57:39.827",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "73448",
"post_type": "answer",
"score": 1
}
] | 73448 | 73450 | 73450 |
{
"accepted_answer_id": "73457",
"answer_count": 2,
"body": "[Dnsmasq における複数の脆弱性 (DNSpooq)](https://jvn.jp/vu/JVNVU90340376/)\nに対応するため、バージョンを2.79から2.83にアップデートしようとしています。 \nしかし、RHEL8にて `dnf update` を行っても、2.83は含まれておらず、2.79が最新となっています。\n\nリソースが以下にある事はわかったのですが、RPMパッケージではないため、RHEL8環境下で以下を用いてどのようにアップデートをすればいいか、方法がわかりません。 \n<http://www.thekelleys.org.uk/dnsmasq/>\n\nご教授いただけますと幸いです。よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T01:48:53.487",
"favorite_count": 0,
"id": "73455",
"last_activity_date": "2021-01-22T00:17:11.143",
"last_edit_date": "2021-01-21T02:32:44.827",
"last_editor_user_id": "3060",
"owner_user_id": "43608",
"post_type": "question",
"score": 0,
"tags": [
"rhel"
],
"title": "dnsmasqの最新バージョン(2.83)へのアップデート方法について",
"view_count": 312
} | [
{
"body": "[RHSB-2021-001; DNSpooq - Multiple vulnerabilities within\ndnsmasq](https://access.redhat.com/security/vulnerabilities/RHSB-2021-001) および\n[RHSA-2021:0150](https://access.redhat.com/errata/RHSA-2021:0150)\nで説明されています。2.79にバックポートされているので、記載されているパッケージバージョンにあがっているかを確認しましょう。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T02:08:30.117",
"id": "73456",
"last_activity_date": "2021-01-21T02:08:30.117",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "73455",
"post_type": "answer",
"score": 0
},
{
"body": "RHEL 向けのパッケージとしては、少なくとも CVE-2020-25681, CVE-2020-25684, CVE-2020-25685\nに関しては「脆弱性へのパッチを古いバージョンに適用する」、 **バックポート** と呼ばれる方法で対応が取られています。\n\n[dnsmasq 2.79-13.el8_3.1 - RedHat\nカスタマーポータル](https://access.redhat.com/downloads/content/rhel---\n8/x86_64/7441/dnsmasq/2.79-13.el8_3.1/x86_64/fd431d51/package-changelog)\n\n> **2020-12-16 Petr Menšík [email protected] - 2.79-13.1**\n>\n> * Fix various issues in dnssec validation (CVE-2020-25681)\n> * Accept responses only on correct sockets (CVE-2020-25684)\n> * Use strong verification on queries (CVE-2020-25685)\n>\n\nソースコードから自分でコンパイルしてインストールすることも可能ですが、rpm パッケージと混在すると管理が煩雑になるためお勧めしません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T02:53:52.207",
"id": "73457",
"last_activity_date": "2021-01-22T00:17:11.143",
"last_edit_date": "2021-01-22T00:17:11.143",
"last_editor_user_id": "3060",
"owner_user_id": "3060",
"parent_id": "73455",
"post_type": "answer",
"score": 0
}
] | 73455 | 73457 | 73456 |
{
"accepted_answer_id": "74820",
"answer_count": 1,
"body": "## 環境\n\n * Windows 10\n * Firefox (Developer Edition)\n * php 7.4\n\n## 質問\n\n以下のサイトを参考に、PHPとJS(Svelte)を組み合わせて、WebPushの実装を行おうとしております。 \n[WEBアプリでプッシュ通知を実装する](https://zukucode.com/2020/05/webpush-javascript-php.html)\n\n上記サイトで出てきました、web-push-phpというライブラリを利用しようと \n<https://github.com/web-push-libs/web-push-php>\n\n```\n\n <?php\n require_once 'vendor/autoload.php';\n \n use Minishlink\\WebPush\\WebPush;\n use Minishlink\\WebPush\\Subscription;\n \n // ここのキーは https://web-push-codelab.glitch.me/ で取得したものを利用しています\n const PUBLIC_KEY = 'xxxxxxxxxxxxxxxx';\n const PRIVATE_KEY = 'yyyyyyyyyyyyyyy';\n \n $result = [DBから取得した値(JSのpushManager.subscribeで取得された、endpoint, p256dh, authが保存されています)]\n \n $auth = array(\n 'VAPID' => array(\n 'subject' => 'http://localhost:8080', // 自身のWEBサイトのURL('http://localhost'など)\n 'publicKey' => PUBLIC_KEY, // 取得したPublicKey\n 'privateKey' => PRIVATE_KEY, // 取得したPrivateKey\n ),\n );\n \n $webPush = new WebPush($auth);\n \n $webPush->sendNotification(\n $result['endpoint'], // 登録したendpoint\n 'プッシュ通知のテストです。', // プッシュ通知に表示する文言\n $result['p256dh'], // 登録したuserPublicKey\n $result['auth'] // 登録したuserAuthToken\n );\n \n $webPush->flush();\n \n```\n\nしかし、`sendNotification`というメソッドがない、とエラーが発生いたします。\n\nですので、以下のようにコードを書き換えました。\n\n```\n\n <?php\n require_once 'vendor/autoload.php';\n \n use Minishlink\\WebPush\\WebPush;\n use Minishlink\\WebPush\\Subscription;\n \n // ここのキーは https://web-push-codelab.glitch.me/ で取得したものを利用しています\n const PUBLIC_KEY = 'xxxxxxxxxxxxxxxx';\n const PRIVATE_KEY = 'yyyyyyyyyyyyyyy';\n \n $result = [DBから取得した値(JSのpushManager.subscribeで取得された、endpoint, p256dh, authが保存されています)]\n \n $auth = Subscription::create([\n 'endpoint' => $result['endpoint'],\n 'publicKey' => $result['p256dh'],\n 'authToken' => $result['auth']\n ]);\n \n $webPush = new WebPush();\n $webPush->queueNotification(\n $auth\n );\n \n $report = $webPush->flush();\n var_dump($report);\n \n```\n\nしかし、通知は送信されていないのか`var_dump($report);`で空のオブジェクトが返ってきます。\n\nこちらはどのようにして実装するのでしょうか? \nご存じの方がいらっしゃいましたら、ご教示頂けますと幸いです。\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T03:15:31.550",
"favorite_count": 0,
"id": "73458",
"last_activity_date": "2021-03-22T10:46:42.077",
"last_edit_date": "2021-01-21T04:35:29.493",
"last_editor_user_id": "3060",
"owner_user_id": "31257",
"post_type": "question",
"score": 0,
"tags": [
"php",
"push-notification"
],
"title": "PHPでWebPushを送信したい",
"view_count": 953
} | [
{
"body": "できましたので、記事を書きました。 \nそちらを共有しておきます。 \n<https://zenn.dev/nnahito/articles/fd2c8b0ad0d19a>",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-03-22T10:46:42.077",
"id": "74820",
"last_activity_date": "2021-03-22T10:46:42.077",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31257",
"parent_id": "73458",
"post_type": "answer",
"score": 1
}
] | 73458 | 74820 | 74820 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[binding.pry せずに、指定された行で pry したい](https://ja.stackoverflow.com/q/42976/754)\n\n^ こちらの質問で、 third party の gem の debug をしたい場合には、 byebug\nを利用すると良い、ということを学びました。ここで、 `bundle exec コマンド` で実行することになる ruby の executable を、\nbyebug の引数に与えて実行したい、と思っています。\n\nなので、この `bundle exec コマンド` で実行することになる ruby 実行ファイルを、プログラム的に取得したいと思いました。\n\n# 質問\n\n`bundle exec コマンド` で実行することになる、そのコマンドの executable\nのファイルパスを取得したいと思っています。これを実現する方法はありますでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T03:53:08.433",
"favorite_count": 0,
"id": "73460",
"last_activity_date": "2021-02-06T06:35:53.723",
"last_edit_date": "2021-01-21T04:48:32.497",
"last_editor_user_id": "754",
"owner_user_id": "754",
"post_type": "question",
"score": 0,
"tags": [
"ruby",
"bundler"
],
"title": "bundle exec で実行することになる ruby 実行ファイルのパスを取得したい",
"view_count": 224
} | [
{
"body": "拙作になりますが、こちらでやりたいことを満たせそうでしょうか? \n<https://rubygems.org/gems/process-path> \n<https://github.com/yagihiro/process-path>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-02-06T06:35:53.723",
"id": "73827",
"last_activity_date": "2021-02-06T06:35:53.723",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "16793",
"parent_id": "73460",
"post_type": "answer",
"score": 0
}
] | 73460 | null | 73827 |
{
"accepted_answer_id": "73467",
"answer_count": 1,
"body": "以下の画像のような選択をしたのと同等の状態でTeraTermを起動するショートカットを作成したいのですが、TeraTermのコマンドラインオプション指定する方法をご存じの方がいましたらご教示いただけないでしょうか?\n\nホスト名とポート番号は以下のように指定すればよいと思うのですが、\n\n> \"C:\\Program Files (x86)\\teraterm\\ttermpro.exe\" localhost:22\n\nそれ以外のオプション:\n\n * サービス=その他\n * プロトコル=UNSPEC\n\nの指定方法について本家マニュアルを見てもわかりませんでした。\n\n参照した本家マニュアル: \n<https://ttssh2.osdn.jp/manual/4/ja/commandline/teraterm.html>\n\n[](https://i.stack.imgur.com/42qEe.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T05:03:10.213",
"favorite_count": 0,
"id": "73461",
"last_activity_date": "2021-01-21T08:47:30.737",
"last_edit_date": "2021-01-21T05:37:12.487",
"last_editor_user_id": "15631",
"owner_user_id": "15631",
"post_type": "question",
"score": 0,
"tags": [
"teraterm"
],
"title": "TeraTermのコマンドラインオプションの指定方法について",
"view_count": 2741
} | [
{
"body": "### バージョン\n\nTera Termのバージョンは何ですか? `プロトコル: UNSPEC`\nになっているという事は最新のバージョンでは無いはずです。(最新版では`IPバージョン: AUTO`) \n以下に書く内容はかなり古めのバージョンでも通用するはずですが、うまく行かなかった場合は使っているバージョンを教えてください。\n\n### サービス: その他\n\nこれはちょっと判りづらいですね。TELNETで無い([/T=0](https://ttssh2.osdn.jp/manual/4/ja/commandline/teraterm.html#t))、かつSSHでない([/nossh](https://ttssh2.osdn.jp/manual/4/ja/commandline/ttssh.html#nossh))時にその他になります。 \nなので`/T=0`と`/nossh`の両方を指定すればいい事になるのですが、実は`/T=0`を指定すると[SSHも無効](https://ttssh2.osdn.jp/manual/4/ja/commandline/ttssh.html#t)になります。 \nつまり`/T=0`のみを追加すればOKです。\n\n### プロトコル: UNSPEC (IPバージョン: AUTO)\n\n`/4`や`/6`でIPv4やIPv6だけに限定していない場合にIPバージョンが`UNSPEC(AUTO)`になります。 \nなので、`/4`と`/6`の両方とも指定していなければ特別にオプションを追加しなくても`AUTO`になります。\n\nというわけで、最終的にはコマンドラインを以下のようにすれば大丈夫なはずです。\n\n```\n\n \"C:\\Program Files (x86)\\teraterm\\ttermpro.exe\" localhost:22 /T=0\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T08:47:30.737",
"id": "73467",
"last_activity_date": "2021-01-21T08:47:30.737",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12203",
"parent_id": "73461",
"post_type": "answer",
"score": 0
}
] | 73461 | 73467 | 73467 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "hoverしたときにspanタグにborderを出したいのですが上手くいきません。 \nどうすればうまくいきますか?\n\n```\n\n <ul class=\"nav\">\n <li class=\"nav-item\"><a class=\"navbar-link\" href=\"/xxx.html\"><span class=\"linear\">xxx</span></a></li>\n <li class=\"nav-item\"><a class=\"navbar-link\" href=\"/xxx.html\"><span class=\"linear\">xxx</span></a></li>\n </ul>\n \n \n \n $(\".nav-item\").hover(function(){\n $(\"this\").find('span').css('border-bottom', ' 1px solid #fff');\n }, function() {\n $(\"this\").find('span').css('border-bottom', ' 1px solid #ccc');\n });\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T06:35:31.827",
"favorite_count": 0,
"id": "73462",
"last_activity_date": "2021-01-22T00:19:20.303",
"last_edit_date": "2021-01-22T00:19:20.303",
"last_editor_user_id": "3060",
"owner_user_id": "43610",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"html",
"jquery"
],
"title": "jQuery でマウスホバー時に border を出したい",
"view_count": 100
} | [
{
"body": "ここで利用しているthisはテキストではなくて \n[thisキーワード](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/this)になります。 \nそのためダブルクォーテーションでくくってはだめです。\n\n```\n\n $(\".nav-item\").hover(function(){\n $(this).find('span').css('border-bottom', ' 1px solid #fff');\n }, function() {\n $(this).find('span').css('border-bottom', ' 1px solid #ccc');\n });\n```\n\n```\n\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>\n <ul class=\"nav\">\n <li class=\"nav-item\"><a class=\"navbar-link\" href=\"/xxx.html\"><span class=\"linear\">xxx</span></a></li>\n <li class=\"nav-item\"><a class=\"navbar-link\" href=\"/xxx.html\"><span class=\"linear\">xxx</span></a></li>\n </ul>\n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T07:24:05.840",
"id": "73464",
"last_activity_date": "2021-01-21T07:24:05.840",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22665",
"parent_id": "73462",
"post_type": "answer",
"score": 0
}
] | 73462 | null | 73464 |
{
"accepted_answer_id": "73471",
"answer_count": 2,
"body": "pythonのnetworkxを使って指定した座標でノードをプロットしようとしているのですが、うまくいきません。エッジを指定しないとうまくいかないのですが解決策はないでしょうか。\n\n```\n\n import networkx as nx\n n = 18\n G = nx.DiGraph()\n G.add_node(n-1)\n pos = { 0: (0, 8), \n 1: (0, 7), \n 2: (0, 6), \n 3: (0, 5), 9: (1, 5), 12: (2, 5), 15:(3, 5), \n 4: (0, 4), 10: (1, 4), 13: (2, 4), 16:(3, 4),\n 5: (0, 3), 11: (1, 3), 14: (2, 3), 17:(3, 3),\n 6: (0, 2),\n 7: (0, 1),\n 8: (0, 0), }\n nx.draw(G, pos)\n #nx.draw_networkx_nodes(G, pos)\n \n```\n\n[](https://i.stack.imgur.com/3KofT.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T07:45:02.540",
"favorite_count": 0,
"id": "73465",
"last_activity_date": "2021-02-10T02:10:37.847",
"last_edit_date": "2021-02-10T02:10:37.847",
"last_editor_user_id": "3060",
"owner_user_id": "29111",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"networkx"
],
"title": "networkxのノードが表示されない",
"view_count": 276
} | [
{
"body": "`G.add_node(n-1)`だけが行われていて、それでは`17`のノードが1つだけ存在する状態ではないでしょうか? \nそのために1個だけ表示されるのでしょう。\n\n例えば`G.add_node(n-1)`の代わりに以下のいずれかで18個のノードを作っておけば良いと思われます。\n\nループで順次作って登録する:\n\n```\n\n for i in range(n):\n G.add_node(i)\n \n```\n\nリストを作って登録する:\n\n```\n\n nodes = [i for i in range(n)]\n G.add_nodes_from(nodes)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T11:03:07.600",
"id": "73470",
"last_activity_date": "2021-01-21T11:03:07.600",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26370",
"parent_id": "73465",
"post_type": "answer",
"score": 1
},
{
"body": "辞書(dict)型インスタンスの `pos` からキーを拾ってグラフに追加すればよろしいのではないでしょうか。\n\n```\n\n import networkx as nx\n import matplotlib.pyplot as plt\n \n G = nx.DiGraph()\n pos = {\n 0: (0, 8), \n 1: (0, 7), \n 2: (0, 6), \n 3: (0, 5), 9: (1, 5), 12: (2, 5), 15:(3, 5), \n 4: (0, 4), 10: (1, 4), 13: (2, 4), 16:(3, 4),\n 5: (0, 3), 11: (1, 3), 14: (2, 3), 17:(3, 3),\n 6: (0, 2),\n 7: (0, 1),\n 8: (0, 0),\n }\n \n G.add_nodes_from(pos.keys())\n nx.draw(G, pos)\n plt.show()\n \n```\n\n[](https://i.stack.imgur.com/AUCnX.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T11:31:20.473",
"id": "73471",
"last_activity_date": "2021-01-21T11:31:20.473",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "73465",
"post_type": "answer",
"score": 1
}
] | 73465 | 73471 | 73470 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "### 追記\n\n二重ループで距離を出すことはできましたが、これを配列に詰めていく方法がわかりません。理想は行=会員番号、列=店舗名のクロス集計表のような形式にしたいです。 \nまた、会員数が約15万人程度いるためforループだと重く、他に何か良い方法があるようでしたら教えていただきたいです。\n\n```\n\n !pip install geopy\n from geopy.distance import geodesic\n \n customer_no1 = customer_master1.iloc[:,0] store_no = store_master.iloc[:,0] customer_list1 = customer_master1.iloc[:,3:] store_list = store_master.iloc[:,2:] \n \n for c in range(len(customer_list1)):\n for s in range(len(store_list)):\n dis = geodesic((customer_list1[\"Lat\"].loc[c,],customer_list1[\"Lon\"].loc[c,]), (store_list[\"緯度\"].loc[s,],store_list[\"経度\"].loc[s,])).km \n print(customer_no1[c],\",\",store_no[s],\",\",f\"{dis:.0f}\") \n \n```\n\n### 前提\n\n会員マスタと店舗マスタの緯度・経度情報から、会員ごとに各店舗までの距離を求めたいと思っております。\n\n会員マスタ、店舗マスタのデータの持ち方としては、それぞれ住所とそれに対応する緯度・経度が格納されているイメージです。(添付画像ご参照ください)\n\n[](https://i.stack.imgur.com/8OcQL.png)\n\n### 質問本題\n\n以下のように2地点間の緯度・経度から距離を求める関数を定義したのですが、この関数をもとにして行=各会員、列=各店舗として各セルに該当する距離が入るようなマスタを作成したいと思っております。\n\n色々とやり方を考えてみたのですが、良いやり方が思いつかず、どのような方法でやれば良いのかコード付きで教えていただけますと幸いです。\n\n```\n\n ##モジュールimport\n from math import sin, cos, acos, radians\n \n earth_rad = 6371\n \n ##関数定義\n def latlng_to_xyz(lat, lng):\n rlat, rlng = radians(lat), radians(lng)\n coslat = cos(rlat)\n return coslat*cos(rlng), coslat*sin(rlng), sin(rlat)\n \n def dist_on_sphere(pos0, pos1, radius=earth_rad):\n xyz0, xyz1 = latlng_to_xyz(*pos0), latlng_to_xyz(*pos1)\n return acos(sum(x * y for x, y in zip(xyz0, xyz1)))*radius\n \n```\n\n### アウトプットイメージ\n\n```\n\n 店舗A 店舗B 店舗C 店舗D ・ ・ ・\n 会員A 距離 距離 距離 距離\n 会員B 距離 距離 距離 距離\n ・\n ・\n ・\n ・\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T08:35:59.863",
"favorite_count": 0,
"id": "73466",
"last_activity_date": "2021-01-25T07:31:00.700",
"last_edit_date": "2021-01-25T07:31:00.700",
"last_editor_user_id": "42369",
"owner_user_id": "42369",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "店舗マスタと会員マスタの緯度経度情報から、総当たりで距離を求める方法について",
"view_count": 448
} | [] | 73466 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "FirefoxをPythonのSeleniumで起動する際、下の画像の様にproxyのusernameとpasswordの入力を要求されますが、 \nこちらをpythonのscriptから入力する方法を教えていただけないでしょうか。\n\n[](https://i.stack.imgur.com/YysXy.png)\n\n私の実行環境\n\n```\n\n Ubuntu 18.04.3 LTS\n Python 3.9.1\n selenium 3.141.0 py39h07f9747_1002 conda-forge\n geckodriver 0.29.0 (2021-01-14, cf6956a5ec8e)\n \n```\n\n私が実行したpythonのスクリプトは下記の通りです。\n\n```\n\n # proxyのユーザー名とパスワード\n USERNAME = \"suzuki\"\n PASSWORD = \"hoge\"\n \n from selenium import webdriver\n from time import sleep\n \n browser = webdriver.Firefox(executable_path=r'~/path_to_driver/geckodriver')\n sleep(5)\n \n # 下記2行でブラウザー立ち上げ後に、USERNAMEとTABキーとPASSWORDを入力し、OKボタンを押させているつもりですが、全く反応しません\n browser.switch_to.alert.send_keys(USERNAME + u'\\ue004' + PASSWORD) \n browser.switch_to.alert.accept()\n \n \n```\n\n上記のコードを実行すると、FIrefoxのブラウザは立ち上がってProxyのユーザー名とパスワードを要求されますが、何も入力されません。ターミナル上には下記のエラーメッセージが出力されます。 \n`selenium.common.exceptions.NoAlertPresentException message` \nProxy入力のポップアップがアラートとして認識されていないということでしょうか。\n\n最後の2行は下記の回答を参考に作りました。 \n<https://stackoverflow.com/a/57220686/10432875>\n\nタブの入力方法(u'\\ue004')は \n<https://qiita.com/KI1208/items/effe553d1ce9a9d04d76> \nを参考にしました。\n\nご回答、何卒宜しくお願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T10:35:03.780",
"favorite_count": 0,
"id": "73469",
"last_activity_date": "2022-09-15T14:03:25.360",
"last_edit_date": "2021-01-21T10:58:25.827",
"last_editor_user_id": "30280",
"owner_user_id": "30280",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"ubuntu",
"selenium",
"firefox",
"selenium-webdriver"
],
"title": "FirefoxをPythonのSeleniumで起動する時、proxyのusernameとpasswordを入力する方法",
"view_count": 1167
} | [
{
"body": "試す環境が無いのでキーワードで調べただけですが、英語版SOでの類似質問における回答の一つで、 \n以下のような方法が紹介されていました。\n\n[Using a http proxy with headless firefox in Selenium webdriver in Python -\nStack Overflow](https://stackoverflow.com/a/52514532)\n\n>\n```\n\n> from selenium.webdriver.common.proxy import Proxy, ProxyType\n> \n> myProxy = \"username:password@proxyDomain:proxyPort\"\n> \n> proxy = Proxy({\n> 'proxyType': ProxyType.MANUAL,\n> 'httpProxy': myProxy,\n> 'ftpProxy': myProxy,\n> 'sslProxy': myProxy,\n> 'noProxy': '' # set this value as desired\n> })\n> \n> driver = webdriver.Firefox(firefox_binary=binary, proxy=proxy)\n> \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T11:53:03.307",
"id": "73473",
"last_activity_date": "2021-01-21T11:53:03.307",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "73469",
"post_type": "answer",
"score": 0
}
] | 73469 | null | 73473 |
{
"accepted_answer_id": "73517",
"answer_count": 1,
"body": "Rustのhtml5everを使用して、HTMLをパースし、一部を削除した結果を出力したいです。 \n調べたところ、`remove_from_parent` という関数を使用出来るかと考えています。\n\n<https://docs.rs/markup5ever/0.10.0/markup5ever/interface/tree_builder/trait.TreeSink.html#tymethod.remove_from_parent>\n\n例として、`remove_from_parent` 関数を使い、span要素を全て削除するサンプルを作ろうとしています。 \n現在のコードの一部は以下です。 \n`// remove all span element here` のコメントの箇所で削除しようとしています。 \nどのように削除すれば良いでしょうか?\n\nlin.rs\n\n```\n\n extern crate html5ever;\n extern crate markup5ever;\n extern crate markup5ever_rcdom;\n \n use markup5ever_rcdom::{NodeData, RcDom, Handle, SerializableHandle};\n use html5ever::parse_document;\n use html5ever::serialize::{SerializeOpts, serialize};\n use html5ever::tendril::TendrilSink;\n \n use wasm_bindgen::prelude::*;\n use web_sys::console::log_1;\n \n #[wasm_bindgen]\n extern {\n pub fn alert(s: &str);\n }\n \n #[wasm_bindgen]\n pub fn convert() {\n let data = \"<html><body><span>should be removed</span></body></html>\";\n let dom: RcDom = parse_document(RcDom::default(), Default::default()).one(data);\n \n search_iter(&dom.document, &dom);\n \n let mut bytes = vec![];\n let document: SerializableHandle = dom.document.clone().into();\n serialize(&mut bytes, &document, SerializeOpts::default()).unwrap();\n let converted_html = String::from_utf8(bytes).unwrap();\n \n alert(&format!(\"{:?}\", converted_html));\n }\n \n fn search_iter(node: &Handle, dom: &RcDom) {\n match node.data {\n NodeData::Element { ref name, .. } => {\n if name.local.to_string().eq(\"span\") {\n log_1(&JsValue::from(\"This is span tag\"));\n // remove all span element here\n }\n },\n _ => {}\n };\n for child in node.children.borrow().iter() {\n search_iter(child, dom);\n }\n }\n \n```\n\nCargo.toml\n\n```\n\n [dependencies]\n wasm-bindgen = \"0.2\"\n html5ever = \"0.25.1\"\n markup5ever = \"0.10.0\"\n markup5ever_rcdom = \"0.1.0\"\n web-sys = {\"version\" = \"0.3.44\", features=['console']}\n \n```\n\nindex.html\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n </head>\n <body>\n <script type=\"module\">\n import * as mod from \"./hello_wasm.js\";\n (async () => {\n await mod.default();\n mod.convert();\n })();\n </script>\n </body>\n </html>\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T11:34:16.407",
"favorite_count": 0,
"id": "73472",
"last_activity_date": "2021-01-23T04:37:54.363",
"last_edit_date": "2021-01-21T22:27:02.820",
"last_editor_user_id": "17347",
"owner_user_id": "17347",
"post_type": "question",
"score": 0,
"tags": [
"rust"
],
"title": "Rustのhtml5everのremove_from_parent関数の使用方法を教えてください",
"view_count": 254
} | [
{
"body": "> 調べたところ、remove_from_parent という関数を使用出来るかと考えています\n\n私はhtml5everを使ったことがないので少し手こずりましたが、ご質問の答えはわかりました。以下のようにして調べました。\n\n 1. 質問で挙げられていたmarkup5everクレートのドキュメントを読んだ \n * `remove_from_parent`は`TreeSink`トレイトのメソッドであることがわかった\n * しかし、markup5everにはその`TreeSink`トレイトを実装している型がない\n 2. markup5everとhtml5everのGitHubリポジトリーで、examplesフォルダー内にあるサンプルを見てみた \n * 手がかりになりそうな情報はなかった\n 3. GitHubでコード検索した。(検索ワード:`remove_from_parent`、言語:Rust) \n * 検索結果:[https://github.com/search?l=Rust&q=remove_from_parent&type=Code](https://github.com/search?l=Rust&q=remove_from_parent&type=Code)\n * 参考になりそうなコードが見つかった:[brave/brave-core - scorer.rs#L192-L198](https://github.com/brave/brave-core/blob/612896e4b30cca7352dfe2aa1247e2995f97b580/components/speedreader/rust/lib/src/readability/src/scorer.rs#L192-L198)\n\n検索で見つかったコードから、`TreeSink`トレイトはご質問のコードで使われている`RcDom`が実装していることがわかりました。(`RcDom`はmarkup5ever_rcdomクレートにある)\n\nつまり、以下のように書けそうです。\n\n```\n\n if name.local.to_string().eq(\"span\") {\n log_1(&JsValue::from(\"This is span tag\"));\n // remove all span element here\n dom.remove_from_parent(&node); // ← この行を追加した\n }\n \n```\n\nしかしこれはコンパイルエラーになりました。\n\n```\n\n error[E0596]: cannot borrow `*dom` as mutable, as it is behind a `&` reference\n --> src/bin/main1.rs:33:13\n |\n 29 | fn search_iter(node: &Handle, dom: &RcDom, nodes_to_remove: &mut Vec<Handle>) {\n | ------ help: consider changing this to be a mutable reference: `&mut RcDom`\n ...\n 33 | dom.remove_from_parent(&node);\n | ^^^ `dom` is a `&` reference, so the data it refers to cannot be borrowed as mutable\n \n```\n\n`remove_from_parent`は`self`として`&mut\nRcDom`を取ろうとするのですが、`dom`は`&RcDom`なのでできないそうです。\n\nコンパイルエラーで勧められたとおりに何箇所か修正すると、最後はこのエラーで行き詰まりました。\n\n```\n\n error[E0502]: cannot borrow `dom` as mutable because it is also borrowed as immutable\n --> src/bin/main1.rs:14:32\n |\n 14 | search_iter(&dom.document, &mut dom, &mut nodes_to_remove);\n | ----------- ------------- ^^^^^^^^ mutable borrow occurs here\n | | |\n | | immutable borrow occurs here\n | immutable borrow later used by call\n \n```\n\n`dom`にはすでに不変借用があるので、可変借用を同時に作れないわけです。\n\n参考にしたコードをもう一度見てみると、処理を2つのステップに分けていることがわかりました。\n\n * **ステップ1** :domをトラバース(ツリー全体を移動)して、削除の対象となるノードを洗い出す。対象ノードは`Vec<RcDom>`に格納する\n * **ステップ2** :洗い出したノードを削除する\n\nこれにならってコードを修正したところ、コンパイルエラーが解消し、以下のような出力が得られました。\n\n**実行結果**\n\n```\n\n Found a span tag\n \"<html><head></head><body></body></html>\"\n \n```\n\n修正後のコードは以下のようになります。(wasmにコンパイルしなくて済むように、`log_1()`を`println!()`で置き換えています)\n\n```\n\n use html5ever::{\n local_name, parse_document, serialize, serialize::SerializeOpts, tendril::TendrilSink,\n tree_builder::TreeSink,\n };\n use markup5ever_rcdom::{Handle, NodeData, RcDom, SerializableHandle};\n use std::rc::Rc;\n \n pub fn convert() {\n let data = \"<html><body><span>should be removed</span></body></html>\";\n let mut dom: RcDom = parse_document(RcDom::default(), Default::default()).one(data);\n \n // spanノードを探してnodes_to_removeに入れる\n let mut nodes_to_remove = vec![];\n search_iter(&dom.document, &dom, &mut nodes_to_remove);\n \n // 見つかったspanノードを削除する\n for node in nodes_to_remove {\n dom.remove_from_parent(&node);\n }\n \n let mut bytes = vec![];\n let document: SerializableHandle = dom.document.into();\n serialize(&mut bytes, &document, SerializeOpts::default()).unwrap();\n let converted_html = String::from_utf8(bytes).unwrap();\n \n println!(\"{:?}\", converted_html);\n }\n \n fn search_iter(node: &Handle, dom: &RcDom, nodes_to_remove: &mut Vec<Handle>) {\n if let NodeData::Element { ref name, .. } = node.data {\n // Local値はlocal_name!マクロで作れる\n if name.local == local_name!(\"span\") {\n println!(\"Found a span tag\");\n // ノードをnodes_to_removeに入れる\n nodes_to_remove.push(Rc::clone(&node));\n }\n }\n \n for child in node.children.borrow().iter() {\n search_iter(child, dom, nodes_to_remove);\n }\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T04:30:49.233",
"id": "73517",
"last_activity_date": "2021-01-23T04:37:54.363",
"last_edit_date": "2021-01-23T04:37:54.363",
"last_editor_user_id": "14101",
"owner_user_id": "14101",
"parent_id": "73472",
"post_type": "answer",
"score": 1
}
] | 73472 | 73517 | 73517 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "すみません。どう考えて、書いても、答えが出ないので、ここで、みんなの力を借りさせていただきます。\n\n文字列の中から特定の文字を削除するプログラムを記述しなさい。 \n// 変数 str から、変数 code 代入された文字を削除する事。\n\n```\n\n #include <iostream>\n #include <iomanip>\n #include <conio.h>\n using namespace std;\n \n int main()\n {\n // 変数宣言\n char str[10] = \"\";\n char code = '\\0';\n \n \n // 削除する文字列と文字を入力\n cout << \"削除する対象:\";\n cin >> str;\n cout << \"削除する文字:\";\n cin >> code;\n \n // 入力された文字列の中から文字を削除\n \n // 結果を出力\n cout << \"削除後の文字列:\" << str;\n \n _getch();\n return 0;\n }\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T16:34:32.013",
"favorite_count": 0,
"id": "73477",
"last_activity_date": "2021-01-22T04:32:43.327",
"last_edit_date": "2021-01-21T16:39:36.613",
"last_editor_user_id": "3605",
"owner_user_id": "43618",
"post_type": "question",
"score": -1,
"tags": [
"c++"
],
"title": "文字列の特定文字を削除するプログラム",
"view_count": 1683
} | [
{
"body": "```\n\n #include<iostream>\n #include<iomanip>\n using namespace std;\n \n int main(){\n char str[10] = \"teeeeste\";\n char code = 'e';\n \n for(int i = 0; i < sizeof(str)/sizeof(*str); ++i){\n if(str[i] == code){\n for(int j = i; j < sizeof(str)/sizeof(*str)-1; ++j){\n str[j] = str[j+1];\n }\n --i;\n }\n }\n cout << str << endl;\n return 0;\n }\n \n```\n\n指摘されたので修正しました",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T03:50:32.120",
"id": "73488",
"last_activity_date": "2021-01-22T04:32:43.327",
"last_edit_date": "2021-01-22T04:32:43.327",
"last_editor_user_id": "43624",
"owner_user_id": "43624",
"parent_id": "73477",
"post_type": "answer",
"score": 0
},
{
"body": "[std::remove](https://en.cppreference.com/w/cpp/algorithm/remove)\nを使う方法はどうでしょうか。\n\n```\n\n #include <algorithm>\n #include <cstring>\n :\n \n // 入力された文字列の中から文字を削除\n *remove(str, str+strlen(str), code) = 0;\n \n // 結果を出力\n cout << \"削除後の文字列:\" << str << endl; // endl を追加\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T04:24:28.647",
"id": "73489",
"last_activity_date": "2021-01-22T04:24:28.647",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "73477",
"post_type": "answer",
"score": 1
}
] | 73477 | null | 73489 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "### エラー内容\n\n以下のエラーが発生しました。\n\n```\n\n Call to a member function tasks() on null\n \n```\n\n### 状況\n\nindex.blade.phpにアクセスしようとしたところ以下のようなエラーが発生しました。 \nindex.blade.phpにアクセスするためにこのエラーを解決し、アクセスできるように実装したいと考えております。\n\n今回のエラーに対して、調べてみて何個か仮説を立てたのですが、原因であろう箇所の対処がわからず解決の糸口が見つけられません。お手数ですが該当箇所に対するアプローチ等のアドバイスをお願いできたらと思い質問致しました。\n\n**実装環境** \nLaravel Framework 8.21.0 \nMariaDB 10.4.17 - mariadb.org binary distribution \nWindows 10\n\n### エラーファイルと該当箇所\n\n**TaskController.php**\n\n```\n\n use App\\Models\\Task; //なかったので追加\n use Illuminate\\Http\\Request;\n use App\\Http\\Requests\\CreateTask;//CreateTaskコントローラをインポート\n \n class TaskController extends Controller\n {\n \n public function index($id)\n {\n \n //全てのフォルダを取得する\n $folders = Folder::all();\n \n //選ばれたフォルダを取得する\n $current_folder = Folder::find($id);\n \n // 選ばれたフォルダに紐づくタスクを取得する\n $tasks = $current_folder->tasks()->get(); // *エラーの該当箇所\n \n return view('tasks/index',[\n 'folders' => $folders,\n 'current_folder_id' => $current_folder->id,\n 'tasks' => $tasks,\n ]);\n \n }\n \n```\n\n### 自分の中で立てた仮説と結果\n\n仮説⓵ \nそもそもtasks関数が存在していない\n\n`php artisan tinker` でデータベースの中身を調べたところ\n\n```\n\n >>>App\\Models\\Task::find(1)\n >>>null\n \n```\n\nしかし\n\n```\n\n >>> App\\Models\\Task::find(3)\n => App\\Models\\Task {#4085\n id: 3,\n folder_id: 1,\n title: \"サンプルタスク 1\",\n due_data: \"2021-01-14\",\n status: 1,\n created_at: \"2021-01-13 17:42:27\",\n updated_at: \"2021-01-13 17:42:27\",\n } \n \n```\n\nモデルファイルも確認でき、task関数がないという線はないと推定。\n\n仮説② \n$current_folderの値がNULLである\n\n→var_dumpの結果がNULLならオブジェクトの生成がうまくいっていない \nvar dump($folders)の時点では値が取得できており \n$folders = Folder::all();のコードには恐らくコードに問題はないと推定\n\nしかし `var_dump($current_folder);` してみたところ `$current_folder;` がNULLだった。 \n`php artisan tinker` では以下の通り値が取得できている。\n\n```\n\n >>> App\\Models\\Folder::find(1)\n => App\\Models\\Folder {#4087\n id: 1,\n title: \"プライベート\",\n created_at: \"2021-01-13 17:42:20\",\n updated_at: \"2021-01-13 17:42:20\",\n }\n \n```\n\n**$current_folder = Folder::find($id);** \n恐らくこのコードに問題がありそうだが、具体的にどこに問題があるのか分からず... \nfindメソッドで値が取れないのが疑問点です。\n\n### 参考ファイル\n\n**Folder.php**\n\n```\n\n <?php\n \n namespace App\\Models;\n \n use Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\n use Illuminate\\Database\\Eloquent\\Model;\n \n class Folder extends Model\n {\n public function tasks()\n {\n return $this->hasMany('App\\Models\\Task');\n }\n }\n \n```\n\n**Task.php**\n\n```\n\n <?php\n \n namespace App\\Models;\n \n use Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\n use Illuminate\\Database\\Eloquent\\Model;\n // この行を追加\n use Carbon\\Carbon;\n \n class Task extends Model\n {\n const STATUS = [\n \n 1 => [ 'label' => '未着手', 'class' => 'label-danger' ],\n 2 => [ 'label' => '着手中', 'class' => 'label-info' ],\n 3 => [ 'label' => '完了', 'class' => '' ],\n ];\n \n public function getStatusLabelAttribute()\n {\n //状態値\n $status = $this->attributes['status'];\n \n // 定義されていなければ空文字を返す\n if (!isset(self::STATUS[$status])) {\n return '';\n }\n \n return self::STATUS[$status]['class'];\n }\n \n public function getFormattedDueDateAttribute()\n {\n return Carbon::createFromFormat('Y-m-d', $this->attributes['due_date'])\n ->format('Y/m/d');\n }\n }\n \n```\n\n**web.php**\n\n```\n\n <?php\n \n use Illuminate\\Support\\Facades\\Route;\n \n /*\n |--------------------------------------------------------------------------\n | Web Routes\n |--------------------------------------------------------------------------\n |\n | Here is where you can register web routes for your application. These\n | routes are loaded by the RouteServiceProvider within a group which\n | contains the \"web\" middleware group. Now create something great!\n |\n */\n Route::get('/folders/{id}/tasks','TaskController@index')->name('tasks.index');\n \n Route::get('/folders/create', 'FolderController@showCreateForm')->name('folders.create');\n Route::post('/folders/create', 'FolderController@create');\n \n Route::get('/folders/{id}?tasks/create','TaskController@showCreateForm')->name('tasks.create');\n Route::post('/folders/{id}/tasks/create', 'TaskController@create');\n \n```\n\n[DB内容] \n⓵foldersテーブル \n[](https://i.stack.imgur.com/JPxsi.png) \n[foldersテーブル]\n\n[](https://i.stack.imgur.com/xL1Ix.png) \n[foldersテーブルデータ構造]\n\n⓶tasksテーブル \n[](https://i.stack.imgur.com/4EOEA.png) \n[tasksテーブル]\n\n[](https://i.stack.imgur.com/cpWB9.png) \n[tasksテーブルデータ構造]",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-21T23:19:43.753",
"favorite_count": 0,
"id": "73479",
"last_activity_date": "2021-01-22T02:41:12.013",
"last_edit_date": "2021-01-22T02:41:12.013",
"last_editor_user_id": "43620",
"owner_user_id": "43620",
"post_type": "question",
"score": 0,
"tags": [
"php",
"laravel",
"mariadb"
],
"title": "Call to a member function tasks() on null のエラーを解決したい",
"view_count": 1718
} | [] | 73479 | null | null |
{
"accepted_answer_id": "73553",
"answer_count": 1,
"body": "表題の件について、モニターの最上部にてフルスクリーンでの複数画像のスライドを行いたいのですが、 \njsの読み込みが原因なのか、複数画像の相対パスの表示方法が違うのか、うまくできない状況です。\n\n以下に、うまく表示されない原因ではないかと思われる箇所を3点表記しました。\n\n* * *\n\n 1. js読み込みとして、htmlのheadに`<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js\"></script>`を入力し、 \n/body 直前に`<script src=\"js/script.js\"></script>`を入力しました。\n\n 2. 「jQuery.BgSwitcher」をダウンロードし、jquery.bgswitcher.jsファイルを \nhtmlの /body 直前に`<script src=\"js/jquery.bgswitcher.js\"></script>`として表記しました。\n\n 3. jsコードの背景画像に記入した表示させたい画像の相対パスについて、 \nimages:\n['img/bg1.jpg','img/bg2.jpg','img/bg3.jpg'],と参考にしたサイトに記載のダミー画像をcssのbackground-\nimageでの相対パスでの表示のように、 \nimages:\n['../images/index/img01.jpg','../images/index/img02.jpg','../images/index/img03.jpg']に変更しましたが、モニターでうまく表示がされません。\n\n* * *\n\n下部にhtml, css, jqueryそれぞれのコードを添付いたしました。\n\njsの読み込みを変更させたり、色々と試してみたのですが、モニターで画像の表示が確認できません。 \njsなどのコードの書き方は、学習サービスの「プロゲート」を参考にして書いております。\n\n大変お手数ですが、解決策を教えていただける方がいらっしゃいましたら \nよろしくお願いいたします。\n\nhtml\n\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta charset=\"utf-8\">\n <title>タイトルタイトルタイトル</title>\n <link rel=\"stylesheet\" href=\"https://unpkg.com/ress/dist/ress.min.css\">\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\">\n <link href=\"https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&family=Roboto:wght@400;700&display=swap\" rel=\"stylesheet\">\n <link rel=\"stylesheet\" href=\"css/style.css\">\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js\"></script>\n </head>\n <body>\n <div class=\"bg-slider\">\n <h1 class=\"bg-slider__title\">BGSWITCHER DEMO PAGE</h1>\n </div>\n <script src=\"js/script.js\"></script>\n <script src=\"js/jquery.bgswitcher.js\"></script>\n </body>\n </html>\n \n \n```\n\ncss\n\n```\n\n @charset \"UTF-8\";\n body {\n font-family: 'Noto Sans JP', sans-serif;\n font-family: 'Roboto', sans-serif;\n }\n a {\n text-decoration: none;\n }\n .container {\n width: 1170px;\n padding: 0 15px;\n margin: 0 auto;\n }\n .bg-slider {\n width: 100vw;\n height: 100vh;\n background-position:center center;\n background-size: cover;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .bg-slider__title{\n color: #fff;\n font-size: 48px;\n line-height: 1.5;\n font-weight: bold;\n text-align:center;\n text-shadow: 1px 1px 1px #000;\n }\n \n```\n\njs\n\n```\n\n $(function(){\n <script src=\"//ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js\"></script>\n <script src=\"js/jquery.bgswitcher.js\"></script>\n <script>\n jQuery(function($) {\n $('.bg-slider').bgSwitcher({\n images: ['../images/index/img01.jpg','../images/index/img02.jpg','../images/index/img03.jpg'], // 背景画像\n });\n });\n </script>\n });\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T01:52:03.007",
"favorite_count": 0,
"id": "73483",
"last_activity_date": "2021-01-25T00:58:45.177",
"last_edit_date": "2021-01-22T05:03:07.267",
"last_editor_user_id": "43622",
"owner_user_id": "43622",
"post_type": "question",
"score": 0,
"tags": [
"html",
"jquery",
"css",
"adobe-brackets"
],
"title": "bracketsでjqueryによるbgSwitcherプラグインを使用したいのですが、うまく適用できません",
"view_count": 478
} | [
{
"body": "そもそものJavascriptの記述の仕方に勘違いをされているようです。 \n外部リソースとしてJavascriptを呼び出す場合はscriptタグは必要ないです。 \nそのままJavascriptを記述してください\n\n```\n\n jQuery(function($) {\n $('.bg-slider').bgSwitcher({\n images: ['../images/index/img01.jpg','../images/index/img02.jpg','../images/index/img03.jpg'], // 背景画像\n });\n });\n \n```\n\nまたその記述の仕方ですと以下のようにJavascriptのエラーが発生するはずです。\n\n```\n\n $(function(){\n <script src=\"//ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js\"></script>\n <script src=\"js/jquery.bgswitcher.js\"></script>\n <script>\n jQuery(function($) {\n $('.bg-slider').bgSwitcher({\n images: ['../images/index/img01.jpg','../images/index/img02.jpg','../images/index/img03.jpg'], // 背景画像\n });\n });\n </script>\n });\n```\n\nもっともシンプルな確認の仕方はブラウザでF12でコンソールを開いて確認できます。 \nそのほかの方法もいろいろなサイトで紹介されています。 \nまずはJavascirptのデバック方法を学んでもらってエラーがない状態になるようになることを目指しましょう。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T00:58:45.177",
"id": "73553",
"last_activity_date": "2021-01-25T00:58:45.177",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22665",
"parent_id": "73483",
"post_type": "answer",
"score": 0
}
] | 73483 | 73553 | 73553 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "検索順位チェックツールの「GRC」というソフトウェアの自動操作を行って、csvファイルのアップロードを自動で行えるようにしたいと思っています。\n\npythonの「pyautogui」と「pywinauto」ライブラリを使いました。これをタスクスケジューラーに登録して夜間等に定期的に実行をしたいです。\n\nPCの画面を開いている状態でしたら問題なく作動するのですが、画面を開いていない状態だと上手く作動しません。 \n自分が思うには、両ライブラリとも画面を認識する必要あるからだと思っています。\n\nPCを1日中起動させっぱなしにするなら上記の方法でも出来るのですが、現実的ではありません。\n\nPCが起動していなくても上記の動作を自動化させられる方法は他に何かありませんでしょうか? \npythonで無理そうでしたら、他の方法でも全然大丈夫です。\n\n宜しくお願い致します。\n\n(追記) \nAWS(Amazon Work\nSpaces)の仮想デスクトップサービスの中にWindowsのOSを入れて試してみたのですが、同じくAWSを開いている状態でないと上手く作動しませんでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T01:55:24.020",
"favorite_count": 0,
"id": "73484",
"last_activity_date": "2021-01-22T04:20:56.760",
"last_edit_date": "2021-01-22T04:20:56.760",
"last_editor_user_id": "43623",
"owner_user_id": "43623",
"post_type": "question",
"score": 0,
"tags": [
"python",
"rpa"
],
"title": "csvファイルのアップロードを自動化させたい(RPA)",
"view_count": 224
} | [
{
"body": "どんな方法であれ、PCが起動していない状態で動作させるのは無理です。\n\nクラウドなどで、サーバーを立てて、定期的に実行させるのが現実的だと思います。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T03:32:56.723",
"id": "73487",
"last_activity_date": "2021-01-22T03:32:56.723",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43624",
"parent_id": "73484",
"post_type": "answer",
"score": 1
}
] | 73484 | null | 73487 |
{
"accepted_answer_id": "73486",
"answer_count": 1,
"body": "C言語のソースコードでライブラリをインクルードしたときソースコードにはいったいどのような変化が起きているのですか?\n\nまた、インクルードしたときの記述と同等のコードはあるのでしょうか?\n\n```\n\n #include <stdio.h> // この行で何が起きている?\n \n int main(void){\n printf(...);\n return 0;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T02:22:38.263",
"favorite_count": 0,
"id": "73485",
"last_activity_date": "2021-01-22T12:04:01.143",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43413",
"post_type": "question",
"score": 2,
"tags": [
"c"
],
"title": "include したときソースコードには何が起きていますか?",
"view_count": 265
} | [
{
"body": "> C言語のソースコードでライブラリをインクルードしたときソースコードにはいったいどのような変化が起きているのですか?\n\nソースコードに\n`#include`で指定されたファイル(質問コードの場合`stdio.h`の内容が`#include`が指定されている部分にそのまま埋め込まれるような感じになります。このプリプロセス処理はCコンパイラがコンパイルに先立ってプロプロセッサを呼び出して行います。\n\nちなみにgccであれば`-E`オプションを付けると、プリプロセスだけを行った結果を出力出来るので興味があれば試してみると良いかと思います。(プリプロセスでは`#include`の展開以外に`#define`の展開や`#if`等の条件コンパイルの際のコンパイルされない部分の排除も行います。)\n\n> また、インクルードしたときの記述と同等のコードはあるのでしょうか?\n\n同等というのがどこまでのレベルを指しているかによりますが、インクルード対象ファイルの内容をそのまま埋め込めば(そのインクルードファイルの中に`#include`が指定されていればそれもすべて再帰的に埋め込みます)同等になると思います。\n\nもっとゆるい意味での同等ということならばインクルード対象ファイルに記述されている定義の中で自分が必要な部分だけを選択してソースコードにコピー&ペーストしていくという感じになると思います。\n\n※コメントの指摘を受けて追記\n\n`#include`の展開はイメージ的には以下のような感じになります。(コメントで指摘されている通り、実際には内部の`#`で始まるプリプロセッサ指示が展開されてしまうので、最終的な展開結果は元の`stdio.h`のファイル内容とは見た目が異なるものになります。)\n\n```\n\n //#include <stdio.h> // この行で何が起きている?\n \n ↑↑↑上のファイルの内容が↓↓↓下のようにそのまま展開される\n \n /* Define ISO C stdio on top of C++ iostreams.\n Copyright (C) 1991-2018 Free Software Foundation, Inc.\n This file is part of the GNU C Library.\n \n */(途中省略)\n \n The GNU C Library is free software; you can redistribute it and/or\n #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n # include <bits/stdio2.h>\n #endif\n #ifdef __LDBL_COMPAT\n # include <bits/stdio-ldbl.h>\n #endif\n \n __END_DECLS\n \n #endif /* <stdio.h> included. */\n \n int main(void){\n printf(...);\n return 0;\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T02:37:53.927",
"id": "73486",
"last_activity_date": "2021-01-22T12:04:01.143",
"last_edit_date": "2021-01-22T12:04:01.143",
"last_editor_user_id": "30745",
"owner_user_id": "30745",
"parent_id": "73485",
"post_type": "answer",
"score": 2
}
] | 73485 | 73486 | 73486 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Microsoft SQL ServerとPostgreSQLで下記の暗号化を検討しています \n(所謂アプリケーション層での暗号化/列レベル暗号化)\n\n * Microsoft SQL Server: ENCRYPTION BY XXでの暗号化\n * PostgreSQL:pgcryptoを使った暗号化\n\n**データを暗号化する際にどの組み合わせが一般的なのか教えていただけますでしょうか**\n\n 1. 共通鍵\n 2. 共通鍵+パスワードでの鍵保護\n 3. 共通鍵+証明書での鍵保護\n 4. 公開鍵+秘密鍵\n 5. その他\n\n**鍵は通常DBサーバーとは別のサーバーに置きますでしょうか?どのように鍵を管理するのが一番安全でしょうか**",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T04:38:18.283",
"favorite_count": 0,
"id": "73490",
"last_activity_date": "2021-01-22T05:46:57.913",
"last_edit_date": "2021-01-22T05:46:57.913",
"last_editor_user_id": "3060",
"owner_user_id": "29648",
"post_type": "question",
"score": 0,
"tags": [
"postgresql",
"database",
"sql-server",
"encryption"
],
"title": "データベースを暗号化する際の暗号鍵の管理",
"view_count": 172
} | [] | 73490 | null | null |
{
"accepted_answer_id": "73498",
"answer_count": 2,
"body": "`Ruby on Rails` や `Laravel`\nなどにおいて、投稿された質問や動画を識別したい場合、IDを`Base64`などの文字列で指定することのメリットはなんですか?\n\nたとえば、スタックーオーバーフローでは次のURLのように質問のIDを質問の識別子としています。\n\n`https://ja.stackoverflow.com/questions/230`\n\n`識別子: 230`\n\nしかし、YouTubeでは動画のIDに対して次のURLのように文字列を動画の識別子としています。\n\n`https://m.youtube.com/watch?v=8G_-WD7g1pE`\n\n`識別子: 8G_-WD7g1pE`\n\n質問や動画を識別する場合、IDではなく、文字列を使って識別するメリットを教えてください",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T05:10:47.197",
"favorite_count": 0,
"id": "73492",
"last_activity_date": "2021-01-22T10:28:55.073",
"last_edit_date": "2021-01-22T05:21:33.800",
"last_editor_user_id": "43413",
"owner_user_id": "43413",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"laravel",
"url"
],
"title": "質問や動画などを識別するときのIDに文字列が使われる場合があるのはなぜ?",
"view_count": 173
} | [
{
"body": "単純に **生成できるユニークな値** の数をどこまで扱うか、の違いではないでしょうか。\n\n数字のみだと「0~9 (10種類) * 桁」だけですが、例に挙げた YouTube の場合には「0~9 (10種類) + a-zA-z (52種類) +\n記号(-_など) * 桁数」で、生成できる値のバリエーションに違いが出てきます。\n\nStack Overflow (英語版) での最新質問IDは \"65840005\" でしたが、YouTube の例に揃えると以下のようになります。\n\n```\n\n 10^11 = 100,000,000,000 ## 0-9\n 64^11 = 73,786,976,294,838,206,464 ## 0-9,a-zA-Z,-_\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T06:10:01.757",
"id": "73493",
"last_activity_date": "2021-01-22T06:44:33.877",
"last_edit_date": "2021-01-22T06:44:33.877",
"last_editor_user_id": "3060",
"owner_user_id": "3060",
"parent_id": "73492",
"post_type": "answer",
"score": 0
},
{
"body": "識別子に文字列を指定するメリットは、\n\n * 現在発行済みの識別子の数が分からない(保持している動画の数を外部から知る手段が減る)。盛況なのか過疎状態なのかこれだけで分かりません。\n * 識別子から新旧の情報を知ることができない。数値だと若いものほど古いことがわかる。\n * 数値ではないので、カウントアップするなどして他の動画のURLを知ることがてきず、「URLを知っている人のみ公開」のような機能を実現しやすい\n\n最初の二つはデメリットと受け取る人もいるかもしれません。 \n最後の一つも、限定公開用のURLを生成する機能を別途開発すればいいだけなので数値を使うとできないわけではないですが、識別子が文字列だとより簡単です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T10:28:55.073",
"id": "73498",
"last_activity_date": "2021-01-22T10:28:55.073",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43354",
"parent_id": "73492",
"post_type": "answer",
"score": 0
}
] | 73492 | 73498 | 73493 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "タイトルの通りですが標準化,正規化,ロバストスケーリングがどういうものかは理解しているんですがそれぞれのメリット,デメリット,またどういうときにどの前処理がおすすめなのかを具体例で教えていただきたいです.",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T07:03:27.997",
"favorite_count": 0,
"id": "73494",
"last_activity_date": "2023-08-28T08:01:25.187",
"last_edit_date": "2021-01-25T05:06:18.797",
"last_editor_user_id": "3060",
"owner_user_id": "42568",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "標準化,正規化,ロバストスケーリングのメリット,デメリット",
"view_count": 1888
} | [
{
"body": "本家SOに類似質問があり、質問文にメリットやデメリットがまとまっていたので転載します。(日本語は回答者の訳です。項目が良くまとまっていますが真偽は保証できません) \n[Data Standardization vs Normalization vs Robust\nScaler](https://stackoverflow.com/q/51841506)\n\n> Advantages(メリット):\n>\n> * Standardization: scales features such that the distribution is centered\n> around 0, with a standard deviation of 1. \n> 標準化: 分布が0を中心とし、標準偏差が1になるように特徴量をスケーリングします。\n> * Normalization: shrinks the range such that the range is now between 0\n> and 1 (or -1 to 1 if there are negative values). \n> 正規化:範囲が0~1(負の値がある場合は-1~1)になるように範囲を縮小します。\n> * Robust Scaler: similar to normalization but it instead uses the\n> interquartile range, so that it is robust to outliers. \n> 正規化に似ていますが、外れ値が存在しても堅牢なように四分位範囲を用います。\n>\n\n>\n> Disadvantages(デメリット):\n>\n> * Standardization: not good if the data is not normally distributed (i.e.\n> no Gaussian Distribution). \n> データが正規分布していない(ガウス分布でないなど)場合は適しません。\n> * Normalization: get influenced heavily by outliers (i.e. extreme values). \n> 外れ値(極端な値など)の影響を強く受けます。\n> * Robust Scaler: doesn't take the median into account and only focuses on\n> the parts where the bulk data is. \n> 中央値を考慮せず、大量にデータが存在する部分のみに焦点を当てます。\n>\n\n類似質問では前処理の手法による影響に質問の主眼が置かれています。 \nそのため回答もそこにフォーカスが置かれていますが、[sci-kit-\nlearnを引用した回答](https://stackoverflow.com/a/51842540)にあるように、外れ値をどのように扱いたいのかによって最適な前処理が変わります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T01:18:09.867",
"id": "73554",
"last_activity_date": "2021-01-25T01:18:09.867",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "73494",
"post_type": "answer",
"score": 1
}
] | 73494 | null | 73554 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "データ数を読み込み、そのデーター分だけIDと名前を入力させ、IDで昇順にするか、または名前でアルファベット順にするかを入力させ、その結果を出力するプログラムを作成したいのですが、入力の仕方によって結果がおかしくなってしまいます。\n\nというのも、先に実行結果を示してしまいますが、例えば以下のような時は\n\n```\n\n $ ./a.out\n データ数: 3\n a[0]\n ID : 1\n 名前: suzuki\n a[1]\n ID : 2\n 名前: kato\n a[2]\n ID : 3\n 名前: sano\n 1) ID, 2) 名前: 2\n \n 要素 ID 名前\n a[0]: 2 kato \n a[1]: 3 sano \n a[2]: 1 suzuki \n 探索鍵(名前): sano\n 探索鍵(名前) sano, ID 3 が a[1] に見つかりました\n \n```\n\nこのように名前もアルファベット順になり、それが存在するIDも表示しますが、 \n以下のようなとき、\n\n```\n\n $ ./a.out\n データ数: 3\n a[0]\n ID : 2\n 名前: kato\n a[1]\n ID : 1\n 名前: sano\n a[2]\n ID : 4\n 名前: suzuki\n 1) ID, 2) 名前: 2\n \n 要素 ID 名前\n a[0]: 2 kato \n a[1]: 1 sano \n a[2]: 4 suzuki \n 探索鍵(名前): suzuki\n 探索鍵(名前) �U は見つかりませんでした\n \n```\n\n実行結果が変になってしまいます。\n\n自分は以下のようにプログラムを作成したのですが、どこがおかしいのかがわからなかったので \nよろしくお願いします。\n\n```\n\n #include <stdio.h>\n #include <string.h>\n #define MAX_SIZE 100\n \n struct student{\n int id;\n char name[20];\n };\n typedef struct student Student;\n \n /* 二つのポインタ引数で示される Student型の値を入れかえる */\n void swap_student( struct student *a,struct student *b )\n {\n struct student t=*a;\n *a=*b;\n *b=t;\n }\n \n /* 長さ size のStudent型配列 a[] の各要素を\n 選択ソートでid順(昇順)に並べかえる */\n void ssort_id( Student a[],int n )\n {\n int i,j;\n for(i=n-1;i>=1;i--){\n for(j=0;j<i;j++){\n if(a[j].id>a[j+1].id){\n swap_student(&a[j],&a[j+1]);\n }\n }\n }\n }\n \n /* 長さ size のStudent型配列 a[] の各要素を\n 選択ソートで名前順(昇順)に並べかえる */\n void ssort_name( Student a[],int size )\n {\n int i,j;\n for(i=0;i<size;i++){\n for(j=size-1;j>i;j--){\n if(strcmp(a[j-1].name,a[j].name)>0){\n swap_student(&a[j-1],&a[j]);\n }\n }\n } \n }\n \n /* 配列 a[] のメンバ id に探索鍵(ID) x があるかどうかを二分探索で判定する */\n int bsearch_id( Student a[],int p,int q,int x )\n {\n int t=(p+q)/2;\n if(p>q){\n return -1;\n }\n if(a[t].id==x){\n return t;\n }\n if(a[t].id>x){\n q=t-1;\n } else{\n p=q+1;\n }\n return bsearch_id(a,p,q,x);\n }\n \n /* 配列 a[] のメンバ name に探索鍵(名前) x があるかどうかを二分探索で判定する */\n int bsearch_name( Student a[],int p,int q,char x[] )\n {\n int t=(p+q)/2;\n if(p>q){\n return -1;\n }\n if (!strcmp(a[t].name,x)){\n return t;\n }\n if(strcmp(a[t].name,x)>0){\n q=t-1;\n } else{\n p=q+1;\n }\n return bsearch_name(a,p,q,x);\n }\n \n /* 長さ size の配列 a[] の各要素にユーザからの入力値を格納する */\n void get_students(Student a[], int size)\n {\n int i;\n for (i = 0; i < size; i++) {\n printf(\"a[%d]\\n\", i);\n printf(\" ID : \"); scanf(\"%d\", &a[i].id );\n printf(\" 名前: \"); scanf(\"%s\", a[i].name );\n }\n }\n \n /* 長さ size の配列 a[] を表示する */\n void put_students(Student a[], int size)\n {\n int i;\n \n printf(\"\\n要素 ID 名前\\n\");\n for (i = 0; i < size; i++) {\n printf(\"a[%d]: %2d %-15s\\n\", i, a[i].id, a[i].name);\n }\n }\n \n int main(void)\n {\n int size,horw,pos,key;\n char keystr[20];\n Student a[MAX_SIZE];\n \n printf(\"データ数: \"); scanf(\"%d\", &size);\n get_students(a, size);\n printf(\"1) ID, 2) 名前: \");\n scanf(\"%d\", &horw);\n \n switch (horw) {\n case 1:\n ssort_id( a,size ); /* ID番号で昇順に並べ替え */\n put_students(a, size);\n printf(\"探索鍵(ID): \"); scanf(\"%d\", &key);\n pos = bsearch_id(a,0,size-1,key);\n if (pos >= 0) {\n printf(\"探索鍵(ID) %d, 名前 %s が a[%d] に見つかりました\\n\", key,a[pos].name,pos );\n } else {\n printf(\"探索鍵(ID) %d は見つかりませんでした\\n\", key );\n }\n break;\n case 2:\n ssort_name(a,size); /* 名前で昇順に並べ替え */\n put_students(a, size);\n printf(\"探索鍵(名前): \"); scanf(\"%s\", keystr);\n pos = bsearch_name(a,0,size-1,keystr);\n if (pos >= 0) {\n printf(\"探索鍵(名前) %s, ID %d が a[%d] に見つかりました\\n\", keystr,a[pos].id,pos );\n } else {\n printf(\"探索鍵(名前) %s は見つかりませんでした\\n\", a[pos].name );\n }\n break;\n }\n \n return 0;\n }\n \n \n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T08:07:28.860",
"favorite_count": 0,
"id": "73495",
"last_activity_date": "2021-01-23T06:33:23.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "41837",
"post_type": "question",
"score": 1,
"tags": [
"c"
],
"title": "ID番号または名前を探索鍵として二分探索で調べて結果を表示するプログラム",
"view_count": 121
} | [
{
"body": "これなら、動くかもです。 \n未検証ですが\n\n```\n\n int bsearch_name( Student a[],int p,int q,char x[] )\n {\n int t=(p+q)/2;\n if(p>q){\n return -1;\n }\n if (!strcmp(a[t].name,x)){\n return t;\n }\n if(strcmp(a[t].name,x)>0){\n q=t;\n } else{\n p=t;\n }\n return bsearch_name(a,p,q,x);\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T21:47:22.690",
"id": "73507",
"last_activity_date": "2021-01-23T06:33:23.173",
"last_edit_date": "2021-01-23T06:33:23.173",
"last_editor_user_id": "3060",
"owner_user_id": "43624",
"parent_id": "73495",
"post_type": "answer",
"score": 0
}
] | 73495 | null | 73507 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Laravel 初心者の質問です.\n\n## 現象\n\n次のような簡単なLaravelのコマンドラインプログラムを作ってみたのですが、\n\nElasticIndexMaker.php\n\n```\n\n <?php\n \n namespace App\\Console\\Commands\\User;\n \n use Illuminate\\Console\\Command;\n \n class ElasticIndexMaker extends Command\n {\n /**\n * The name and signature of the console command.\n *\n * @var string\n */\n //protected $signature = 'elasticindexmaker {index: Index specified by the target S3 directry structure starting first character with slash}';\n protected $signature = \"elasticindexmaker {index: Index name}\";\n \n /**\n * The console command description.\n *\n * @var string\n */\n protected $description = 'Generate Elasticsearch index';\n \n /**\n * Create a new command instance.\n *\n * @return void\n */\n public function __construct()\n {\n parent::__construct();\n }\n \n /**\n * Execute the console command.\n *\n * @return int\n */\n public function handle()\n {\n $index = $this -> argument(\"index\");\n $verboseLog = $this -> option(\"verbose\");\n \n $this->info(\"Index: \" . $index);\n if ($this->confirm(\"Are you sure to generate index by this parameter?\")) {\n } else {\n return;\n }\n return 0;\n }\n }\n \n```\n\nkernel.php\n\n```\n\n <?php\n \n namespace App\\Console;\n \n use Illuminate\\Console\\Scheduling\\Schedule;\n use Illuminate\\Foundation\\Console\\Kernel as ConsoleKernel;\n \n class Kernel extends ConsoleKernel\n {\n /**\n * The Artisan commands provided by your application.\n *\n * @var array\n */\n protected $commands = [\n Commands\\User\\ElasticIndexMaker::class\n ];\n \n /**\n * Define the application's command schedule.\n *\n * @param \\Illuminate\\Console\\Scheduling\\Schedule $schedule\n * @return void\n */\n protected function schedule(Schedule $schedule)\n {\n // $schedule->command('inspire')->hourly();\n }\n \n /**\n * Register the commands for the application.\n *\n * @return void\n */\n protected function commands()\n {\n $this->load(__DIR__.'/Commands');\n \n require base_path('routes/console.php');\n }\n }\n \n```\n\n### 1\\. -h だとパラメータ index は認識されているみたいです\n\n```\n\n PS D:\\My_Documents\\proj\\Elasticsearch\\index-gen-laravel> php artisan elasticindexmaker -h \n Description:\n Generate Elasticsearch index\n \n Usage:\n elasticindexmaker <index: Index name>\n \n Arguments:\n index: Index name \n \n Options:\n -h, --help Display help for the given command. When no command is given display help for the list command \n -q, --quiet Do not output any message\n -V, --version Display this application version\n --ansi Force ANSI output\n --no-ansi Disable ANSI output\n -n, --no-interaction Do not ask any interactive question\n --env[=ENV] The environment the command should run under\n -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n PS D:\\My_Documents\\proj\\Elasticsearch\\index-gen-laravel> \n \n```\n\n### 2\\. 実際にパラメータを指定して動かすと例外になります.\n\nところが 実際にパラメータを指定して使ってみるとエラーで落ちてしまいます.(中で例外が起こっています.)\n\n```\n\n PS D:\\My_Documents\\proj\\Elasticsearch\\index-gen-laravel> php artisan elasticindexmaker aa/bb\n \n The \"index\" argument does not exist. \n \n PS D:\\My_Documents\\proj\\Elasticsearch\\index-gen-laravel>\n \n```\n\nVSCodeでデバッグしてみると以下で引っかかっているようです.(画像見れるでしょうか?)何かパラメータの`index`が認識されていないみたいです.\n\n```\n\n Exception has occurred.\n Symfony\\Component\\Console\\Exception\\RuntimeException: No arguments expected for \"elasticindexmaker\" command, got \"aa/bb\".\n \n```\n\n[](https://i.stack.imgur.com/3Ue7x.png)\n\nどこがまずいのか教示いただければ幸いです.\n\n## 環境\n\nWindows 10 + VSCodeでやっています.\n\n以下composer.jsonからの抜粋です.\n\n```\n\n \"require\": {\n \"php\": \"^7.3|^8.0\",\n \"aws/aws-sdk-php\": \"^3.171\",\n \"aws/aws-sdk-php-laravel\": \"^3.6\",\n \"elasticsearch/elasticsearch\": \"^7.10\",\n \"fideloper/proxy\": \"^4.4\",\n \"fruitcake/laravel-cors\": \"^2.0\",\n \"guzzlehttp/guzzle\": \"^7.0.1\",\n \"laravel/framework\": \"^8.12\",\n \"laravel/tinker\": \"^2.5\"\n },\n \n```\n\n不足情報ありましたらお知らせください.\n\n以上 よろしくお願いいたします.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T08:10:48.067",
"favorite_count": 0,
"id": "73496",
"last_activity_date": "2023-05-18T01:09:11.157",
"last_edit_date": "2021-01-22T08:24:21.343",
"last_editor_user_id": "9503",
"owner_user_id": "9503",
"post_type": "question",
"score": 0,
"tags": [
"laravel",
"command-line"
],
"title": "Laravelのコマンドラインプログラムでパラメータが認識されず落ちてしまいます.",
"view_count": 687
} | [
{
"body": "失礼しました.自己RESです.本家Stackoverflowに聞いたら30秒で解決しました.`index`の後のスペース1文字の問題でした.\n\napp/Console/Commands/User/ElasticIndexMaker.php (修正後)\n\n```\n\n protected $signature = \"elasticindexmaker {index : Index name}\";\n \n```\n\n実行画面\n\n[](https://i.stack.imgur.com/BbeAb.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T14:45:47.000",
"id": "73502",
"last_activity_date": "2021-01-22T14:45:47.000",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9503",
"parent_id": "73496",
"post_type": "answer",
"score": 0
}
] | 73496 | null | 73502 |
{
"accepted_answer_id": "73499",
"answer_count": 1,
"body": "リモートリポジトリ側が下記のようなフォルダ構成の際 \n「ghi」フォルダ配下の「jkl」や「mno」等の中身だけを取得したいです。\n\n```\n\n [origin/master]\n root/\n ├ abc/\n ├ def/\n ├ ghi/\n │ └ jkl/\n │ └ mno/\n └ pqr/\n \n```\n\nローカルのgitは設定済みで `.git/info/sparse-checkout` ファイル内には \n`jkl/` とのみ記載し、`git pull` したところ、次のようなフォルダ構成になります。 \n※「root」フォルダ名はリモートとローカルで異なります。\n\n```\n\n [master]\n root/\n └ ghi/\n └ jkl/\n └ mno/\n \n```\n\n希望としては、次のようなフォルダ構成にしたいのですが可能でしょうか。\n\n```\n\n [master]\n root/\n └ jkl/\n └ mno/\n \n```\n\n以上です。よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T08:23:52.693",
"favorite_count": 0,
"id": "73497",
"last_activity_date": "2021-01-22T11:42:01.313",
"last_edit_date": "2021-01-22T11:42:01.313",
"last_editor_user_id": "3060",
"owner_user_id": "43632",
"post_type": "question",
"score": 0,
"tags": [
"git"
],
"title": "gitのsparse-checkoutにてリモートリポジトリから特定のフォルダ配下の中身だけ取得したい",
"view_count": 778
} | [
{
"body": "おそらく`sparse-\ncheckout`できないと思います。`ghi`ディレクトリはもともとGitが管理しているディレクトリ構造であるため、それを変更すると変更履歴が生じます。 \nまた、`.git/info/sparse-checkout`に記述された内容はルートからのディレクトリ名などではなく、マッチするパターンになります。\n\n`sparse-\ncheckout`の使い所はモノレポなどの単一かつ同一のGitリポジトリ内にある複数のディレクトリの内、必要なディレクトリだけを取ってきて作業するために使うので、ディレクトリ構造そのものを変更するような場合に向いていないでしょう。\n\n単純にリモートのリポジトリから最新のディレクト/ファイルを取得したいだけであればsubmoduleなり、別の場所でsparse-\ncheckoutしてディレクトリ移動するなり、利用できるのであればgit-archiveを使うなりしたほうが良いと思います。\n\n**コマンド参考例**\n\n```\n\n git init \n git remote add origin [your-repo-url]\n git sparse-checkout init\n git sparse-checkout set jkl # jklにマッチするパターンをpull対象とする\n \n git pull origin master # ghi/jkl が降ってくる\n \n git log # ここでgit log叩くとわかりますが、履歴はoriginのもの\n \n mv ./ghi/jkl ./jkl # 移動してみる\n \n git status # 変更履歴が出てくるはず\n \n```\n\n## 参考\n\n * [CONE PATTERN SET](https://git-scm.com/docs/git-sparse-checkout#_cone_pattern_set)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T11:29:17.183",
"id": "73499",
"last_activity_date": "2021-01-22T11:29:17.183",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7997",
"parent_id": "73497",
"post_type": "answer",
"score": 0
}
] | 73497 | 73499 | 73499 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "JavaScriptを使ってコードを書いていますが、以下のエラーが出てきます。\n\n原因がよくわかりません。よろしくお願いします。\n\n```\n\n Error: write after end\n \n at write_ (_http_outgoing.js:620:15)\n at ServerResponse.write (_http_outgoing.js:615:10)\n at /Users/a.shota/node_modules/iroha-helpers/iroha-atk/web.js:212:17\n at tryToString (fs.js:514:3)\n at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:502:12)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T13:13:50.737",
"favorite_count": 0,
"id": "73500",
"last_activity_date": "2021-01-23T06:19:07.537",
"last_edit_date": "2021-01-23T06:19:07.537",
"last_editor_user_id": "3060",
"owner_user_id": "43639",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "Error: write after end について",
"view_count": 1355
} | [
{
"body": "エラーメッセージから、「Error: write after end」というエラーが、ファイル _http_outgoing.js の615行目にある\n\"ServerResponse.write\" のところで起きている事が判ります。\n\nそして、「Error: write after\nend」なので、上記の\"ServerResponse.write\"より前に\"ServerResponse.end\"というようなコードが実行されているのだと思われます。\n\nこれをヒントに、ファイル _http_outgoing.js を読み直してください。 \n読んでも判らない時には、そのプログラムを質問に追加して下さい。そうすれば、回答が得られるかもしれません。\n\n[助言] プログラムの内容が判らないのに、そのプログラムで起きるエラーの原因を推測することは無理です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T06:16:41.060",
"id": "73520",
"last_activity_date": "2021-01-23T06:16:41.060",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "73500",
"post_type": "answer",
"score": 1
}
] | 73500 | null | 73520 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "SpringBootにて簡単なJSPを表示させようと思っているのですが、画面が表示されず。 \n404エラーが表示され色々やっているのですが一向に変わりません。 \nどなたかアドバイス頂けないでしょうか? \n【手順】 \n1.STSのスタータープロジェクトで新規作成 \n2.pom.xmlに下記を追記\n\n```\n\n <dependency>\n <groupId>org.apache.tomcat.embed</groupId>\n <artifactId>tomcat-embed-jasper</artifactId>\n <scope>provided</scope>\n </dependency>\n \n```\n\n2.application.propertiesに下記を追記\n\n```\n\n spring.mvc.view.prefix: /WEB-INF/views/ \n spring.mvc.view.suffix: .jsp\n \n```\n\n3.プロジェクトフォルダの直下にフォルダを作成\n\n```\n\n src\\main\\webapp\\WEB-INF\\views\n \n```\n\n4.上記viewsフォルダに「login.jsp」を配置。 \nlogin.jspの中身\n\n```\n\n <%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\"\n pageEncoding=\"UTF-8\"%>\n <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n <html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n <title>Hello, World! JPS</title>\n </head>\n <body>\n <p>Hello, World! JSP</p>\n </body>\n </html>\n \n```\n\n5.Controllerクラスを作成\n\n```\n\n @Controller\n public class LoginAction { \n @RequestMapping(value = \"/\", method = RequestMethod.GET)\n public String index() {\n return \"login\";\n } \n \n```\n\n6.STS上で実行して、ブラウザで下記のURLにアクセス。\n\n```\n\n http://localhost:8081/\n \n```\n\n7.ブラウザには404エラーで表示され、JSPが表示されない。\n\n```\n\n **Whitelabel Error Page**\n This application has no explicit mapping for /error, so you are seeing this as a fallback.\n \n Thu Jan 21 21:15:23 GMT+09:00 2021\n There was an unexpected error (type=Not Found, status=404).\n \n```\n\nデバックモードで見ると、RequestMappingでメソッドは呼び出されていることは確認。 \n色々、試しているのですが一向に変わらず困っています。 \n何が設定が足りないのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T14:36:29.700",
"favorite_count": 0,
"id": "73501",
"last_activity_date": "2022-05-16T06:04:55.473",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34875",
"post_type": "question",
"score": 1,
"tags": [
"java",
"spring-boot"
],
"title": "SpringBootでJSPが表示されない",
"view_count": 1275
} | [
{
"body": "質問文に記載している内容が正しいとすると、\n\n```\n\n spring.mvc.view.prefix: /WEB-INF/views/ \n \n```\n\nの最後にスペースが入っていますので、これを削除する必要もあります。\n\n[実行可能コードサンプル](https://github.com/yukihane/stackoverflow-\nqa/tree/master/jaso73501) ([差分](https://github.com/yukihane/stackoverflow-\nqa/commit/e360276ef6f74f9d6a8f941b82ac89cf934d6712))",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T02:46:29.987",
"id": "73514",
"last_activity_date": "2021-01-23T02:46:29.987",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"parent_id": "73501",
"post_type": "answer",
"score": 1
}
] | 73501 | null | 73514 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "### 前提・実現したいこと\n\nSpring Boot を用いた開発において、application.propertyを環境ごとに動的に変更したい。 \n例) \nローカル環境:application-local.property \n開発環境:application-dev.property \n本番環境:application-prod.property\n\n### 環境\n\nmacOS \nIDE:STS \n言語:Java\n\n### 発生している問題\n\napplication-local.propertyに設定内容を記載し、環境変数を設定しても、本ファイルが読み込まれず、正常に起動しない。 \n→\napplication.propertyにリネームすると正常に起動して、APIも正常に動作するため、プロパティファイルの設定不備ではなく、プロパティファイルが読まれていないことが原因と考えています。 \n以下に詳細を記載いたします。 \n環境変数を読み込んで動的にapplication.propertyを切り替えて動作させるための設定を教えていただきたいです。\n\n### 設定したこと\n\n~./.bash_profileに、\n\n```\n\n export SPRING_PROFILES_ACTIVE=local\n \n```\n\nと記載し、\n\n```\n\n source ~/.bash_profile\n \n```\n\nで環境変数へ反映しています。printenvコマンドで\n\n```\n\n SPRING_PROFILES_ACTIVE=local\n \n```\n\nが表示されることは確認済みです。\n\n### 試したこと\n\nJavaプログラムから、\n\n```\n\n Map<String, String> env = System.getenv();\n Iterator<String> ite1 = env.keySet().iterator();\n Iterator<String> ite2 = env.values().iterator();\n while (ite1.hasNext()) {\n System.out.println(\"変数名:\" + ite1.next() + \"[\" + ite2.next() + \"]\");\n }\n System.out.println(\"---\");\n String profiles = System.getenv(\"SPRING_PROFILES_ACTIVE\");\n System.out.println(profiles);\n \n \n```\n\nとしていますが、\n\n```\n\n 変数名:****\n .\n .\n .\n 変数名:****\n ---\n null\n \n```\n\nとなり、環境変数を読み込めていないようでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T15:12:55.163",
"favorite_count": 0,
"id": "73503",
"last_activity_date": "2023-08-06T02:08:20.943",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43642",
"post_type": "question",
"score": 0,
"tags": [
"java",
"macos",
"spring-boot"
],
"title": "環境変数SPRING_PROFILES_ACTIVEを使用して、application.propertyを動的に切り替えたい。",
"view_count": 1512
} | [
{
"body": "STS上でSpring Bootを実行しようとしたときの事象かと察します。\n\n`~/.bash_profile` の設定が有効になるのは `bash` から起動した(つまりターミナルから起動した)アプリケーションだけです。 \nおそらく、DockなどからSTSを起動しているのではないでしょうか。\n\n採れる選択肢は3種類あるかなと思います。\n\n1つめは、ターミナルからSTSを起動する方法です。 \nこの方法であれば、`.bash_profile` で設定している環境変数は引き継がれます。\n\n2つめは、FinderやDock,\nSpotlightなどGUIから起動した場合も有効になるような環境変数の設定を実施する方法です([例](https://qiita.com/homu-\nkonamilk/items/5886f3e48ffa658f4f78))。 \nMacOS のバージョンによって設定方法が異なっているはずですので、質問にOSのバージョンを明記するのが良いかと考えます。 \n(なお、この方法については、私は現在Macを所有していないので回答できません。他の方の回答を期待して下さい。)\n\n3つめの選択肢は、STS上の起動オプションでprofileを指定してしまう方法です。 \nBoot Dashboard から鉛筆アイコンをクリックしてプロジェクトの設定ダイアログを開くと、 Spring Boot タブに\nprofileを設定する箇所がありますので、ここに `local` と設定することで有効化されます。 \n(ちなみに、この方法は環境変数に設定するわけではなく起動引数に `--spring.profiles.active` を設定するので、\n`System.getenv(\"SPRING_PROFILES_ACTIVE\");`\nでは拾えません。どうしても環境変数として設定したいのであれば、同ダイアログの Environment タブから設定することは可能です。)\n\n[](https://i.stack.imgur.com/IAkaZ.png)\n\n* * *\n\nまた、別の話になりますが、プロパティファイルの拡張子は(少なくともデフォルトでは)`.property` ではなく `.properties`\nです([参考: Profile Specific Files](https://docs.spring.io/spring-\nboot/docs/2.6.5/reference/htmlsingle/#features.external-config.files.profile-\nspecific))。 \n上記問題解消後はこちらも問題になるかもしれません。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T02:05:56.827",
"id": "73510",
"last_activity_date": "2022-03-28T15:54:33.080",
"last_edit_date": "2022-03-28T15:54:33.080",
"last_editor_user_id": "2808",
"owner_user_id": "2808",
"parent_id": "73503",
"post_type": "answer",
"score": 0
}
] | 73503 | null | 73510 |
{
"accepted_answer_id": "73518",
"answer_count": 2,
"body": "C言語において、`printf` と `puts` という2つの標準出力のための関数がありますが、この2つはどのように違うのでしょうか?\n\n```\n\n #include<stdio.h>\n \n int main(void){\n printf(\"hello world\");\n puts(\"hello world\");\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T15:59:27.280",
"favorite_count": 0,
"id": "73504",
"last_activity_date": "2021-01-23T05:39:55.553",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43413",
"post_type": "question",
"score": 3,
"tags": [
"c"
],
"title": "printf と puts の違いはなんですか?",
"view_count": 2821
} | [
{
"body": "puts()は、引数を持つことができません。 \nまた、出力末尾に改行を含みます。\n\nprintf()は、引数を持たせることができます。 \nex.) printf(\"%d\", a); \n出力末尾に改行は含みません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T21:30:28.147",
"id": "73506",
"last_activity_date": "2021-01-22T21:30:28.147",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43624",
"parent_id": "73504",
"post_type": "answer",
"score": 2
},
{
"body": "「文字列を出力する」という役割は同じですが、`printf` ではどのように出力するのかフォーマットを細かく指定できるのが特徴です。\n\nprintf では `%` 記号から始まる \"変換指定子\" と出力したい \"変数\" のペアを指定するのが一般的な使い方で、数値の桁数や文字列の出力幅、右寄せ\nor 左寄せなどを指定できます。\n\n<https://www.k-cube.co.jp/wakaba/server/func/fprintf.html>\n\n```\n\n #include <stdio.h>\n \n void main(){\n int i;\n printf(\"%d\\n\", 200); /* 200 */\n printf(\"%i\\n\", 200); /* 200 */\n printf(\"% d\\n\", 200); /* 200 */\n printf(\"% d\\n\", -200); /* -200 */\n printf(\"%+d\\n\", 200); /* +200 */\n printf(\"%+d\\n\", -200); /* -200 */\n printf(\"%o\\n\", 200); /* 310 */\n printf(\"%#o\\n\", 200); /* 0310 */\n printf(\"%x\", 200); /* c8 */\n printf(\"%#x\", 200); /* 0xc8 */\n printf(\"%#X\\n\", 200); /* 0XC8 */\n printf(\"%f\\n\", 123.456); /* 123.456000 */\n printf(\"%10.2f\\n\", 123.456); /* 123.46 */\n printf(\"%010.2f\\n\", 123.456); /* 0000123.46 */\n printf(\"%e\\n\", 123.456); /* 1.234500e+02 */\n printf(\"%E\\n\", 123.456); /* 1.234500E+02 */\n printf(\"%10.3e\\n\", 123.456); /* 1.235e+02 */\n printf(\"%g\\n\", 123.456); /* 123.456 */\n printf(\"%g\\n\", 0.0000123456); /* 1.23456e-05 */\n printf(\"[%c]\\n\", 'h'); /* [h] */\n printf(\"[%*c]\\n\", 5, 'h'); /* [ h] */\n printf(\"This is a %s.\\n\", \"string\"); /* This is a string. */\n printf(\"[%s]\\n\", \"overlength\"); /* [overlength] */\n printf(\"[%*s]\\n\", 5, \"overlength\"); /* [overlength] */\n printf(\"[%.*s]\\n\", 5, \"overlength\"); /* [overl] */\n printf(\"Address: %p\\n\", main); /* Address: 00401330 */\n printf(\"this many of chars are written so far:%n\", &i);\n printf(\"%d\\n\", i); /* this many of chars are written so far:38 */\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T05:39:55.553",
"id": "73518",
"last_activity_date": "2021-01-23T05:39:55.553",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "73504",
"post_type": "answer",
"score": 2
}
] | 73504 | 73518 | 73506 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "`rails server` で起動させようとしたところ、エラーが出ましてサイトの読み込みができません。 \nどのように解決すればよいでしょうか? \n回答いただけますと幸いです。\n\n~以下コード~\n\n```\n\n ec2-user:~/environment/kensaku (master) $ rails s\n => Booting Puma\n => Rails 5.2.4.4 application starting in development \n => Run `rails server -h` for more startup options\n Puma starting in single mode...\n * Version 3.12.6 (ruby 2.6.3-p62), codename: Llamas in Pajamas\n => Booting Puma\n => Rails 5.2.4.4 application starting in development \n => Run `rails server -h` for more startup options\n Puma starting in single mode...\n \n ec2-user:~/environment $ cd kensaku\n ec2-user:~/environment/kensaku (master) $ rails s\n => Booting Puma\n => Rails 5.2.4.4 application starting in development \n => Run `rails server -h` for more startup options\n Puma starting in single mode...\n \n ec2-user:~/environment/kensaku (master) $ rails s\n => Booting Puma\n => Rails 5.2.4.4 application starting in development \n => Run `rails server -h` for more startup options\n Puma starting in single mode...\n * Version 3.12.6 (ruby 2.6.3-p62), codename: Llamas in Pajamas\n * Min threads: 5, max threads: 5\n * Environment: development\n * Listening on tcp://localhost:8080\n Use Ctrl-C to stop\n ^[d^C- Gracefully stopping, waiting for requests to finish\n === puma shutdown: 2021-01-22 16:35:13 +0000 ===\n - Goodbye!\n Exiting\n ^[dec2-user:~/environment/kensaku (master) $ ^C\n ec2-user:~/environment/kensaku (master) $ ^C\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-22T16:44:48.680",
"favorite_count": 0,
"id": "73505",
"last_activity_date": "2021-01-23T06:27:57.157",
"last_edit_date": "2021-01-23T06:27:57.157",
"last_editor_user_id": "3060",
"owner_user_id": "43643",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails"
],
"title": "rails エラーの解決をお願いします。",
"view_count": 418
} | [
{
"body": "> Version 3.12.6 (ruby 2.6.3-p62), codename: Llamas in Pajamas Min \n> threads: 5, max threads: 5 Environment: development Listening on \n> tcp://localhost:8080 Use Ctrl-C to stop\n\nメッセージを見る限り、railsアプリ動いているようですが?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T06:23:58.650",
"id": "73521",
"last_activity_date": "2021-01-23T06:23:58.650",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43005",
"parent_id": "73505",
"post_type": "answer",
"score": 0
}
] | 73505 | null | 73521 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "MacOS11.1、Code1.52.1です。一応Unityで使用しています。 \nCodeでC#を使用していますが、入力しても、ファイルを保存しても、VisualStudioのようにエラー箇所に波線が出ません。 \nこれはおかしいのではないかと思いましたが、ひょっとしたらそれは皆さんも同じかもしれないと思い、\n\n・まずこれは正常な動作なのかどうか教えていただきたく思います。\n\n・そして正常であっても正常でなくても、C#のファイルでエラー箇所を表示できる方法があれば教えてほしいです。\n\n[](https://i.stack.imgur.com/TAoky.jpg)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T00:00:15.363",
"favorite_count": 0,
"id": "73508",
"last_activity_date": "2021-01-23T06:23:03.630",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43578",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"vscode"
],
"title": "VisualCodeのC#においてエラー箇所に波線が出ないのは正しい動作なのか?そしてどうやったら表示できるのか",
"view_count": 2905
} | [
{
"body": "コメント欄での kunif さんのアドバイスにより、以下の手順でエラー表示が動き出しました。\n\n<https://romly.com/blog/unity_mac_vscode_dotnet_fail/>\n\n・Mac用 Mono の Stable channel をインストール \n・VS Code の設定で Use Global Mono を always にする\n\nこれがインテリセンスという物だということも知らなかったので、どのように検索すればよいかが分からずにいました、ありがとうございます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T06:07:38.617",
"id": "73519",
"last_activity_date": "2021-01-23T06:23:03.630",
"last_edit_date": "2021-01-23T06:23:03.630",
"last_editor_user_id": "3060",
"owner_user_id": "43578",
"parent_id": "73508",
"post_type": "answer",
"score": 1
}
] | 73508 | null | 73519 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "pythonとtkinterを使ってGUIのプログラムを書いています。 \ncanvas内に静止した折れ線グラフを表示しました。 \nセンサからの情報で折れ線グラフが動く、モニタ画面を作りたいのですが、matlibplotを使わず、canvasだけでやるのは無理でしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T01:01:06.677",
"favorite_count": 0,
"id": "73509",
"last_activity_date": "2021-01-23T02:35:02.890",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36119",
"post_type": "question",
"score": 0,
"tags": [
"python",
"tkinter"
],
"title": "python,tkinter,canvasで動く折れ線グラフ(モニタ画面)を作れるでしょうか?",
"view_count": 279
} | [
{
"body": "この記事の応用で可能だと思われます。 \n[Live Plot in Python GUI](https://stackoverflow.com/q/15736393/9014308)\n\n回答記事に示されたスクリプトは Python 2.x系のようでしたが、回答に付いたコメントにあるように最初の`import Tkinter as\ntk`を`import tkinter as tk`と`Tkinter`の大文字/小文字を変更しただけで Python 3.x系\nで動作するようになりました。 \n回答での入力データは乱数でシミュレートしているようです。\n\n確認環境は Windows10 64bit Python 3.9.1 です。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T02:35:02.890",
"id": "73512",
"last_activity_date": "2021-01-23T02:35:02.890",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26370",
"parent_id": "73509",
"post_type": "answer",
"score": 0
}
] | 73509 | null | 73512 |
{
"accepted_answer_id": "73516",
"answer_count": 1,
"body": "SDKの関数に下記のコードを書いてみましたが、うまく動きません。 \nお力をお貸しいただけませんでしょうか。\n\n```\n\n let myBoundSize: CGSize = UIScreen.main.bounds.size\n var myView = UIView(frame: CGRect(x: 0, y: 0, width: myBoundSize.width, height: myBoundSize.height))\n myView.backgroundColor = UIColor.green\n myView.isHidden = true\n \n```\n\n(追記) \n呼び出し元はお客様なため、こちら側でなんとかViewを上から貼り付けて、処理が終わったら制御を戻すって動作をしたいです。\n\n```\n\n lass dummy: NSObject, WKUIDelegate, WKNavigationDelegate {\n \n func init(){\n }\n \n func login() {\n \n let myBoundSize: CGSize = UIScreen.main.bounds.size\n var myView = UIView(frame: CGRect(x: 0, y: 0, width: myBoundSize.width, height: myBoundSize.height))\n myView.backgroundColor = UIColor.green\n myView.isHidden = true\n }\n } \n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T02:46:12.773",
"favorite_count": 0,
"id": "73513",
"last_activity_date": "2021-01-23T06:32:07.003",
"last_edit_date": "2021-01-23T06:32:07.003",
"last_editor_user_id": "3060",
"owner_user_id": "43646",
"post_type": "question",
"score": 0,
"tags": [
"swift"
],
"title": "SwiftでSDKを作成してます。呼び出し元から引数をもらわずにViewを表示させて画面の制御をしたいです。",
"view_count": 82
} | [
{
"body": "端的に言うと「呼び出し元から引数をもらわずにViewを表示させ」「なんとかViewを上から貼り付けて、処理が終わったら制御を戻す」と言うのは、\n\n**事実上無理**\n\nです。\n\n(現在Apple以外からSDKと称して提供されているライブラリの中には「現在の」実装上の詳細に依存する裏技を駆使して、「事実上無理」なことを実現している場合があります。そう言った裏技で良いのであれば、もしかしたら実現する方法があるかもしれませんが、ほんの少しAppleがiOSの中身をいじると動かなくなるものが結構あって、SDKユーザの側はiOSのバージョンアップのたびに右往左往させられると言うことになっています。「そんな裏技でもいいから、可能性があるなら方法を知りたい」と言う場合は、他の方の回答をお待ちください。この回答の中ではそう言ったやり方には触れません。)\n\n現在の期待される動作が「画面を緑にしたい」とのことですが、あなたの現在のコードではせっかく作った背景が緑色のUIViewを`isHidden =\ntrue`で隠してしまっている上に、作ったUIViewを全く使わず(どこにも`addSubview`せず)に捨ててしまっていますので、それが表示されることは決してありません。\n\n「作ったUIViewをどこかに置く」と言う方法をとる限り、「どこに置くのか」を引数でもらわない限り、実現することは不可能でしょう。\n\n* * *\n\n呼び出し元に関する情報が一切いただけていませんが、例えば`UIViewController`のextensionとして機能提供することは考えておられないのでしょうか?\n\n```\n\n extension UIViewController {\n public func login() {\n let myBoundSize: CGSize = UIScreen.main.bounds.size\n let myView = UIView(frame: CGRect(x: 0, y: 0, width: myBoundSize.width, height: myBoundSize.height))\n myView.backgroundColor = UIColor.green\n myView.isHidden = false //<-???\n \n self.view.addSubview(myView)\n }\n }\n \n```\n\nSDKを使う側のコード:\n\n```\n\n class ViewController: UIViewController {\n \n //...\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view.\n self.login()\n }\n \n //...\n \n }\n \n```\n\nまた、このやり方なら、単にUIViewを追加するだけでなく、他のview controllerに遷移させると言ったことも可能になります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T04:12:58.020",
"id": "73516",
"last_activity_date": "2021-01-23T04:12:58.020",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "73513",
"post_type": "answer",
"score": 1
}
] | 73513 | 73516 | 73516 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "`Ruby on Rails`などのWebサービスでそれぞれのユーザーに重複しないUUIDを付与したいです。\n\n`SHA256`や`Base64`などでハッシュ値をUUIDとすればいいでしょうか?\n\nですが、ここで問題となるのが、ハッシュ値は衝突する可能性がゼロではないという事実です。\n\nそのため、UUID を生成するたびにデータベースに重複するUUID\nが存在しないか確かめる判断をコードとして書くことが必要になります。ですが、極めて重複が起こりにくいのに毎回重複を調べるのは手間だと思うんです、\n\nこの手間を省きたい。\n\nそのため、UUID として完全に重複しない値が得る方法が知りたいのですが、どのような関数が推奨されるのでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T07:01:18.140",
"favorite_count": 0,
"id": "73522",
"last_activity_date": "2021-01-23T07:01:18.140",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43413",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"database"
],
"title": "重複しないUUIDをデータベースに保存するには?",
"view_count": 258
} | [] | 73522 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Flutterを使ったiOSアプリ内でHTTPレスポンス(bodybyte)をUTF-8でデコードできない問題が発生しており、指導いただければ幸いです。 \nAndroidのPixel 2のエミュレータでは問題なくデコードできていたのでiOS特有の問題であると考えています。\n\n以下のコードをiOS Deployment Target=9.0でPhone12 Pro Maxのエミュレータで実行した結果になります。 \ndecoded_body_byteがnullになってしまう部分が問題になります。\n\n```\n\n import 'dart:async';\n import 'dart:typed_data';\n import 'package:flutter/material.dart';\n import 'package:flutter/services.dart';\n import 'package:html/dom.dart' as dom;\n import 'package:http/http.dart' as http;\n import 'package:charset_converter/charset_converter.dart';\n import 'package:flutter_user_agent/flutter_user_agent.dart';\n // skip\n \n String userAgent;\n try {\n userAgent = await FlutterUserAgent.getPropertyAsync('userAgent');\n print(\"userAgent: ${userAgent}\");\n } on PlatformException {\n userAgent = '<error>';\n }\n var response = await http.Client().get(Uri.parse(\"http://news4vip.livedoor.biz/archives/52385788.html\"), headers: {'User-Agent': userAgent});\n print(\"Response status: ${response.statusCode}\");\n print(\"response.headers: ${response.headers['content-type']}\");\n String decoded_body_byte = await CharsetConverter.decode(\"UTF-8\", response.bodyBytes);\n print(\"decoded_body_byte: ${decoded_body_byte}\"); // ここの結果がnullになってしまうことが問題になっています。\n Uint8List encoded = await CharsetConverter.encode(\"UTF-8\", \"【画像】中日「かっこいい」今季のユニホーム発表www\");\n print(\"encoded.length: ${encoded.length}\");\n String decoded_body_byte_only_title = await CharsetConverter.decode(\"UTF-8\", response.bodyBytes.sublist(71, 71 + 78));\n print(\"decoded_body_byte_only_title: ${decoded_body_byte_only_title}\");\n \n```\n\n以下は上コードの出力結果になります。\n\n```\n\n 2021-01-23 17:09:29.964984+0900 Runner[89036:14458916] flutter: userAgent: CFNetwork/1209 Darwin/20.2.0 (iPhone iOS/14.3)\n 2021-01-23 17:09:30.187131+0900 Runner[89036:14458916] flutter: Response status: 200\n 2021-01-23 17:09:30.190547+0900 Runner[89036:14458916] flutter: response.headers: text/html; charset=utf-8\n 2021-01-23 17:09:30.195755+0900 Runner[89036:14458916] flutter: decoded_body_byte: null\n 2021-01-23 17:09:30.197368+0900 Runner[89036:14458916] flutter: encoded.length: 78\n 2021-01-23 17:09:30.198128+0900 Runner[89036:14458916] flutter: decoded_body_byte_only_title: 【画像】中日「かっこいい」今季のユニホーム発表www\n \n```\n\n以下flutter doctorの出力結果になります。ご回答いただければ幸いです。\n\n```\n\n % flutter doctor\n Doctor summary (to see all details, run flutter doctor -v):\n [✓] Flutter (Channel stable, 1.22.5, on macOS 11.1 20C69 darwin-x64, locale ja-JP)\n \n [!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)\n ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses\n [✓] Xcode - develop for iOS and macOS (Xcode 12.3)\n [!] Android Studio (version 4.1)\n ✗ Flutter plugin not installed; this adds Flutter specific functionality.\n ✗ Dart plugin not installed; this adds Dart specific functionality.\n [✓] VS Code (version 1.52.1)\n [✓] Connected device (2 available)\n \n ! Doctor found issues in 2 categories.\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T08:45:54.987",
"favorite_count": 0,
"id": "73523",
"last_activity_date": "2021-01-24T10:29:30.543",
"last_edit_date": "2021-01-23T10:59:31.843",
"last_editor_user_id": "19110",
"owner_user_id": "16974",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"flutter"
],
"title": "iOSでFlutterのUTF-8をdecodeできない問題の解決方法",
"view_count": 1074
} | [
{
"body": "みなさまコメントありがとうございます。@OOPerさまの下記の推測が正しかったようです。\n\n> UTF-8としては不正なバイト列が含まれている\n\nCharsetConverterではSwiftのNSStringクラスを流用しているだけのようでした。\n\n<https://github.com/pr0gramista/charset_converter/blob/master/ios/Classes/SwiftCharsetConverterPlugin.swift#L49>\n\nそこでデコーダーを以下のPluginに変更した所、想定通りにデコードすることができました。\n\n<https://api.flutter.dev/flutter/dart-convert/Utf8Codec/decode.html>\n\n```\n\n String decoded = Utf8Decoder(allowMalformed: true).convert(response.bodyBytes);\n \n```\n\n※ `allowMalformed: true` がUTF8の不正文字を置換してくれるようです。\n\n大変助かりました、ありがとうございます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T09:59:29.310",
"id": "73545",
"last_activity_date": "2021-01-24T10:29:30.543",
"last_edit_date": "2021-01-24T10:29:30.543",
"last_editor_user_id": "3060",
"owner_user_id": "16974",
"parent_id": "73523",
"post_type": "answer",
"score": 2
}
] | 73523 | null | 73545 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "今まで二つのデータを以下のようなコードで列方向に連結させていました. \nそれぞれ行*列はdata1は2*32,data2は5*32,data3は8*32の形になっています. \ndata1とdata2のみのときは以下でできました.(7*32の形になる)\n\n```\n\n import numpy as np\n #index削除しているか確認\n data1 = np.loadtxt('210122-945and1200-del-stand-t-all.csv', delimiter = \",\")\n data2 = np.loadtxt('210123-945and1200-del-stand-t-pre.csv', delimiter = \",\")\n data = np.append(data1,data2,axis=0)\n print(data)\n \n```\n\n今回3つ以上のデータを以下のようなコードで連結させるとaxis=0のところでエラーが引っ掛かりました.目指しているのは15*32の形です.\n\n```\n\n import numpy as np\n #index削除しているか確認\n data1 = np.loadtxt('210122-945and1200-del-stand-t-all.csv', delimiter = \",\")\n data2 = np.loadtxt('210123-945and1200-del-stand-t-pre.csv', delimiter = \",\")\n data3 = np.loadtxt('210124-945and1200-del-stand-t-pre.csv', delimiter = \",\")\n data = np.append(data1,data2,data3,axis=0)\n print(data)\n \n```\n\nどうすればスムーズに行けるんでしょうか.そもそもappendを用いるのがだめなんですかね",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T10:58:55.170",
"favorite_count": 0,
"id": "73524",
"last_activity_date": "2021-01-25T05:27:01.417",
"last_edit_date": "2021-01-25T05:27:01.417",
"last_editor_user_id": "49",
"owner_user_id": "42568",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"numpy"
],
"title": "データの列方向への結合",
"view_count": 183
} | [
{
"body": "こちらの記事が参考になるでしょう。 \n[NumPy配列ndarrayを結合(concatenate, stack, blockなど)](https://note.nkmk.me/python-\nnumpy-concatenate-stack-block/) \n[How To Concatenate Arrays in NumPy?](https://cmdlinetips.com/2018/04/how-to-\nconcatenate-arrays-in-numpy/)\n\n[numpy.append(arr, values,\naxis=None)](https://numpy.org/doc/stable/reference/generated/numpy.append.html)\nは2つしか配列を指定できないので、\n\n> Parameters\n>\n> * arr : array_like \n> Values are appended to a copy of this array.\n> * values : array_like \n> These values are appended to a copy of arr. It must be of the correct shape\n> (the same shape as arr, excluding axis). If axis is not specified, values\n> can be any shape and will be flattened before use.\n> * axis : int, optional \n> The axis along which values are appended. If axis is not given, both arr\n> and values are flattened before use.\n>\n\nそれ以上を並列で連結するなら [numpy.concatenate((a1, a2, ...), axis=0,\nout=None)](https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html)\nを使えば良いでしょう。(2つの時でも使えます)\n\n> Parameters\n>\n> * a1, a2, … : sequence of array_like \n> The arrays must have the same shape, except in the dimension corresponding\n> to axis (the first, by default).\n> * axis : int, optional \n> The axis along which the arrays will be joined. If axis is None, arrays are\n> flattened before use. Default is 0.\n> * out : ndarray, optional \n> If provided, the destination to place the result. The shape must be\n> correct, matching that of what concatenate would have returned if no out\n> argument were specified.\n>\n\n質問のソースで言えば、以下の行を:\n\n```\n\n data = np.append(data1,data2,data3,axis=0)\n \n```\n\nこちらのようにリストやタプルで指定すれば出来るでしょう:\n\n```\n\n data = np.concatenate([data1,data2,data3], axis=1)\n \n```\n\nあるいは:\n\n```\n\n data = np.concatenate((data1,data2,data3), axis=1)\n \n```\n\n* * *\n\nまた\n[numpy.hstack(tup)](https://numpy.org/doc/stable/reference/generated/numpy.hstack.html)\nでも同様に出来て、こちらは`axis=`の指定が不要になります。\n\n> Parameters\n>\n> * tup : sequence of ndarrays \n> The arrays must have the same shape along all but the second axis, except\n> 1-D arrays which can be any length.\n>\n\n`concatenate`同様、以下になります:\n\n```\n\n data = np.hstack([data1,data2,data3])\n \n```\n\nあるいは:\n\n```\n\n data = np.hstack((data1,data2,data3))\n \n```\n\n* * *\n\nちなみに「列方向への結合」というのが誤解で、実は「行方向への結合」であるならば、`concatenate`の`axis=1`パラメータは`axis=0`にするかデフォルトと同じなので不要になり、あるいは`hstack`ではなく\n[numpy.vstack(tup)](https://numpy.org/doc/stable/reference/generated/numpy.vstack.html)\nを使用することになるでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T14:26:45.890",
"id": "73531",
"last_activity_date": "2021-01-24T00:32:08.587",
"last_edit_date": "2021-01-24T00:32:08.587",
"last_editor_user_id": "26370",
"owner_user_id": "26370",
"parent_id": "73524",
"post_type": "answer",
"score": 0
}
] | 73524 | null | 73531 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "SGDの引数にバッチサイズが無いのですが、どう指定すればいいですか? \n`optimizer = SGD(learning_rate=0.02) ` \nSGDのコードの中身を確認したのですが、Batchsizeを変更している箇所は無いように見えました \n<https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/optimizer_v2/gradient_descent.py#L30-L194>\n\n処理は勾配法のように見えます\n\nBatchはここで定義されているものが自動的に使われるのでしょうか\n\n```\n\n train_ds = tf.data.Dataset.from_tensor_slices((x_train, y_train)).shuffle(10000).batch(32)\n test_ds = tf.data.Dataset.from_tensor_slices((x_test, y_test)).batch(32)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T12:43:56.903",
"favorite_count": 0,
"id": "73525",
"last_activity_date": "2021-02-08T16:14:42.337",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43652",
"post_type": "question",
"score": 0,
"tags": [
"tensorflow",
"keras"
],
"title": "Tensorflow.keras のSGDのバッチについて",
"view_count": 70
} | [
{
"body": "バッチサイズはnay様が書かれている通り、そちらで定義されたものが使われていると思います。 \nTensorFlowのドキュメントでtf.keras.optimizers.SGDの項目を見ても、そのような引数はなさそうに見えます。 \n<https://www.tensorflow.org/api_docs/python/tf/keras/optimizers/SGD>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-02-08T16:14:42.337",
"id": "73873",
"last_activity_date": "2021-02-08T16:14:42.337",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30785",
"parent_id": "73525",
"post_type": "answer",
"score": 0
}
] | 73525 | null | 73873 |
{
"accepted_answer_id": "73556",
"answer_count": 4,
"body": "C言語で乱数を生成するプログラムをコーディングしているのですが、シード値を時間から指定しているため、1秒以内にプログラムを実行すると、同じシード値となり、同じ乱数が生成されてしまいます。\n\n```\n\n #include <stdio.h>\n #include <stdlib.h>\n #include <time.h>\n \n int main(void)\n {\n srand((unsigned int)time(NULL)); // 1秒以内に実行すると同じシード値になってしまいます\n \n // 最小値:0 取得個数:10個\n printf(\"%d\\n\", 0 + rand() % 10);\n \n return 0;\n }\n \n```\n\nプログラムを1秒以内に何度も実行するので、1秒以内に実行されても異なるシード値になるようにしたいのですが、なにかいい方法はありますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T13:14:47.520",
"favorite_count": 0,
"id": "73527",
"last_activity_date": "2021-02-20T06:17:46.703",
"last_edit_date": "2021-02-20T06:17:46.703",
"last_editor_user_id": "3060",
"owner_user_id": "43413",
"post_type": "question",
"score": 2,
"tags": [
"c",
"random"
],
"title": "1秒以内に実行をくりかえすと同じシード値になる問題を解決したい",
"view_count": 1618
} | [
{
"body": "プラットフォームがわかりませんが、[`getpid`](https://linuxjm.osdn.jp/html/LDP_man-\npages/man2/getpid.2.html) とかをXORしてはどうでしょう?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T14:17:28.627",
"id": "73530",
"last_activity_date": "2021-01-23T14:17:28.627",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "73527",
"post_type": "answer",
"score": 1
},
{
"body": "英語版での関連しそうな投稿から、いくつか使えそうなものを紹介しておきます。\n\nsayuri さんが回答している通り、`getpid` と組み合わせる方法。\n\n[srand(time(NULL)) doesn't change seed value quick enough - Stack\nOverflow](https://stackoverflow.com/a/17799756)\n\n>\n```\n\n> srand( (unsigned) time(NULL) * getpid());\n> \n```\n\nもしくは時間の精度をマイクロ秒まであげる方法などがあるようです。\n\n[srand() — why call it only once? - Stack\nOverflow](https://stackoverflow.com/a/7343909)\n\n>\n```\n\n> struct timeval t1;\n> gettimeofday(&t1, NULL);\n> srand(t1.tv_usec * t1.tv_sec);\n> \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T16:34:10.050",
"id": "73533",
"last_activity_date": "2021-01-23T16:34:10.050",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "73527",
"post_type": "answer",
"score": 1
},
{
"body": "乱数のシード値に、現在時刻のミリ秒を使ったらいいのでは無いでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T00:37:19.260",
"id": "73538",
"last_activity_date": "2021-01-24T00:37:19.260",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24490",
"parent_id": "73527",
"post_type": "answer",
"score": 0
},
{
"body": "Accept された後ではありますが\n\n`srand()` に渡す値が大差ないときには `rand()` の初回呼出しが返す値を下手な加工して使うと乱数にならない例が既に知られています。 \n[c言語での乱数生成](https://ja.stackoverflow.com/questions/12003) \n`time(NULL)` に `getpid()` の結果を **加える** 程度だと上記例のような環境だと明らかにまずいです。また `pid_t`\nの取る値の範囲が狭い処理系 (FreeBSD や HPUX) では **XOR**\nしてもたいした違いにならないのでやはりあまりよろしくないです。というわけで `srand(time(NULL))`\nはあまり良いプラクティスではありません。避けるべきでしょう。\n\nではどうすれば良いかは処理系によって異なります。とりあえず\n\n * `srand()` 直後の `rand()` は採用しない(数回~数十回読み捨てる)\n * もっとましな乱数種として `/dev/random` 乱数デバイスを使う (存在するなら)\n * もっとましな乱数列(と種)に乗り換える (MT とか)\n\nあたりが推奨でしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T02:57:31.983",
"id": "73556",
"last_activity_date": "2021-01-25T02:57:31.983",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "73527",
"post_type": "answer",
"score": 2
}
] | 73527 | 73556 | 73556 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "# やりたいこと\n\n最終目標としては、Ajaxを使って一覧表示の削除ボタンを押すと、非同期でUI上からもDBから削除するできる機能を目指しています。 \nその前段階として、jqueryのみでフロント側のみできる削除する機能を実装したいと考えています。 \nさらにこの機能を実装する手段として、まずはボタンをクリックするとjs側で、一覧リストそれぞれのidを取得する必要があるのですが、ここに苦戦しています。\n\n# 問題点\n\nhtmlのdata属性を作ってフロント側でidを取りたいのですが、クリックしても **リストの先頭のidしか取得することができません** \nどうすれば、laravel側で取ってきたリストのボタンにクリックするとそれぞれのidを取得することができるようになるでしょうか?アドバイスあればよろしくお願いします。\n\n# コード\n\nbladeファイル \n$songsはSongTableから十件取ってくるという処理です。フロント側の質問がメインになるのでこの変数のコードは割愛します。\n\n```\n\n <table class=\"table table-striped\">\n <thead>\n <tr>\n <th>タイトル</th>\n </tr>\n </thead>\n <tr>\n @foreach ($songs as $song)\n <div id=\"delete-item\">\n <td class=\"align-middle\">\n <a href=\"{{ route('admin.show',['id' => $song->id]) }}\">\n {{ $song->title }}\n </a>\n </td>\n <td class=\"align-middle\">\n // ここです\n <button id=\"delete-btn\" data-id=\"{{ $song->id }}\" class=\"btn btn-danger\">削除</button>\n </td>\n </tr>\n </div>\n @endforeach\n </table>\n \n```\n\n```\n\n $(function() {\n $('#delete-btn').on(\"click\", function() {\n console.log($('#delete-btn').data())\n });\n });\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T15:46:08.437",
"favorite_count": 0,
"id": "73532",
"last_activity_date": "2023-01-08T09:07:15.953",
"last_edit_date": "2021-01-24T00:49:41.980",
"last_editor_user_id": "36424",
"owner_user_id": "36424",
"post_type": "question",
"score": 0,
"tags": [
"jquery",
"laravel",
"ajax"
],
"title": "Laravel+jquery 一覧表示したデータのidをjsのコンソール側で取得できるようにしたい。",
"view_count": 532
} | [
{
"body": "[JavaScript /\njQueryでtableの行を「追加」「削除」「移動」「変更」させる方法](https://mae.chab.in/archives/2146)\n\nこの記事を参考にして、フロントのみを削除できました。そもそも個別にid(class)を指定する必要はなかったみたいです。\n\n```\n\n <button onclick=\"return confirm('本当に削除しますか?')\" class=\"btn btn-danger removeList\">削除</button>\n \n```\n\n```\n\n $(document).on('click', '.removeList', function() {\n $(this)\n .parent()\n .parent()\n .remove();\n });\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T01:28:31.790",
"id": "73540",
"last_activity_date": "2021-01-24T07:29:45.837",
"last_edit_date": "2021-01-24T07:29:45.837",
"last_editor_user_id": "3060",
"owner_user_id": "36424",
"parent_id": "73532",
"post_type": "answer",
"score": 0
}
] | 73532 | null | 73540 |
{
"accepted_answer_id": "73571",
"answer_count": 1,
"body": "目的は、平方数の判定を一行でできますか?よろしくお願いします。\n\nprint(factorint(9)) \n{3: 2} \nprint(factorint(81)) \n{3: 4}\n\n参考nが平方数かどうか調べる時 \n<https://teratail.com/questions/200122>\n\n参考:Wolfram|Alpha \n81は平方数ですか \n<https://ja.wolframalpha.com/input/?i=81%E3%81%AF%E5%B9%B3%E6%96%B9%E6%95%B0%E3%81%A7%E3%81%99%E3%81%8B>\n\n80は平方数ですか \n<https://ja.wolframalpha.com/input/?i=80%E3%81%AF%E5%B9%B3%E6%96%B9%E6%95%B0%E3%81%A7%E3%81%99%E3%81%8B>",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-23T22:22:48.013",
"favorite_count": 0,
"id": "73537",
"last_activity_date": "2021-01-25T20:27:53.423",
"last_edit_date": "2021-01-23T22:37:53.003",
"last_editor_user_id": "17199",
"owner_user_id": "17199",
"post_type": "question",
"score": 0,
"tags": [
"アルゴリズム",
"sympy"
],
"title": "平方数の判定を、sympyの素因数分解factorintでできますか?",
"view_count": 150
} | [
{
"body": "正の数 n に対して、n を素因数分解した結果すべての素因数の指数が偶数であることが n\nが平方数であることの必要十分条件ですから、素因数分解できているのであれば指数がすべて偶数であるかどうかをチェックすれば良いです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T20:27:53.423",
"id": "73571",
"last_activity_date": "2021-01-25T20:27:53.423",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "73537",
"post_type": "answer",
"score": 1
}
] | 73537 | 73571 | 73571 |
{
"accepted_answer_id": "73550",
"answer_count": 1,
"body": "倒立振子を作っているのですが、パラメタを4日もチューニングしているのに立ちません。トルクは足りているはずですが転びます。もしかすると、ギヤの減速比が大き過ぎて遅れが生じているのかなと思いました。 \npololu 172:1 メタルギアドモーター です。ギヤ比は関係ありますでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T01:20:56.493",
"favorite_count": 0,
"id": "73539",
"last_activity_date": "2021-01-24T23:09:42.387",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "41334",
"post_type": "question",
"score": 0,
"tags": [
"ハードウェア"
],
"title": "倒立振子のモーターのギヤ比",
"view_count": 164
} | [
{
"body": "ギヤの減速比が小さいと、力が不足してモータで振り子を動かせないように、振り子を固定できないようになりますよ。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T23:09:42.387",
"id": "73550",
"last_activity_date": "2021-01-24T23:09:42.387",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27481",
"parent_id": "73539",
"post_type": "answer",
"score": 0
}
] | 73539 | 73550 | 73550 |
{
"accepted_answer_id": "73558",
"answer_count": 1,
"body": "### 質問内容/困っていること\n\n<こちらでもマルチポストさせていただいております> \n<https://teratail.com/questions/317212>\n\nLPを制作しており『スクロールすると「ふわっと」スクロールするアニメーション』を実装しようとしましたが、稼働しません。\n\n### 発生している問題・エラーメッセージ\n\n⇒グーグルクロームの検証ツールにてConsoleを確認しましたが エラーは表示されていません。(表示は以下の通りです。)\n\n```\n\n Some messages have been moved to the Issues panel. \n \n```\n\nエラーメッセージはありませんが、稼働しません。\n\n### 該当のソースコード\n\n**HTML**\n\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Document</title>\n <link rel=\"stylesheet\" href=\"css/style.css\">\n <link rel=\"stylesheet\" type=\"text/css\" href=\"css/slick.css\" media=\"screen\" />\n <link rel=\"stylesheet\" type=\"text/css\" href=\"css/slick-theme.css\" media=\"screen\" />\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\">\n <link href=\"https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@300&display=swap\" rel=\"stylesheet\">\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\">\n <link href=\"https://fonts.googleapis.com/css2?family=Sawarabi+Gothic&display=swap\" rel=\"stylesheet\">\n <script type=\"text/javascript\"></script>\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js\"></script>\n <script src=\"js/slick.min.js\"></script>\n <script src=\"js/app.js\"></script>\n \n </head>\n \n <ul>\n <li class=\"fadein scrollin\"> \n テキストが入ります。 \n <p>テキストが入ります。<br><br> \n テキストが入ります。テキストが入ります。テキストが入ります。テキストが入ります。 \n </p> \n <figure> \n <img src=\"img/photo.jpg\"> \n <figcaption>テキストが入ります。</figcaption> \n </figure> \n </li> \n </ul>\n \n```\n\n**CSS**\n\n```\n\n .fadein {\n opacity : 0.1;\n transform : translate(0, 50px);\n transition : all 500ms;\n }\n \n .scrollin {\n opacity : 1;\n transform : translate(0, 0);\n }\n \n```\n\n**jQuery**\n\n```\n\n $(function(){\n $(window).scroll(function (){\n $('.fadein').each(function(){\n var elemPos = $(this).offset().top;\n var scroll = $(window).scrollTop();\n var windowHeight = $(window).height();\n if (scroll > elemPos - windowHeight + 200){\n $(this).addClass('.scrollin');\n }\n });\n });\n });\n \n```\n\n### 試したこと\n\njQuery自体は、他にもsliderを実装しておりますが、稼働しています。 \nその他、jQuery自体が稼働しているかの確認のために他の実装済みの要素をコメントアウトした上で、簡単に以下にて稼働の確認をしています。\n\n```\n\n $(function() {\n alert('OK!');\n });\n \n```\n\nアラートは稼働しています。\n\nこの部分のみ、別サイトを作って実装してみましたが、同じく稼働しません。 \n$をjQueryに変更して入力してみましたが、同じく稼働しません。 \naddClassをfadeInでも試しております。同じく稼働しません。 \nCSS単独では、稼働します。\n\nご回答いただければ助かります。よろしくお願いします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T04:02:33.630",
"favorite_count": 0,
"id": "73542",
"last_activity_date": "2021-01-25T05:28:17.100",
"last_edit_date": "2021-01-24T06:43:01.937",
"last_editor_user_id": "43659",
"owner_user_id": "43659",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery",
"css"
],
"title": "【スクロールすると「ふわっと」スクロールするアニメーション】の実装ができません",
"view_count": 480
} | [
{
"body": "参考にしているサイトのコードが正しくコピーされていないようです。 \nコードを正しくコピーしてから動きを見てみてください。\n\n(1)まずhtmlにはscrollinをデフォルトでつけていますが、参考サイトはscrollinはつけていません。\n\n質問のHTML\n\n```\n\n <li class=\"fadein scrollin\">\n \n```\n\n参考サイトのHTML\n\n```\n\n <section class=\"fadein\">\n \n```\n\nスクロールがされたら`<section class=\"fadein\nscrollin\">`になるべきであり、デフォルトでクラスをつけなさいとは記述していません。\n\n(2)JavascriptでaddClassしているところも記述が間違っています。\n\n質問のJavascrpt\n\n```\n\n $(this).addClass('.scrollin');\n \n```\n\n参考サイトのJavascript\n\n```\n\n $(this).addClass('scrollin');\n \n```\n\njQueryの[APIリファレンス](https://api.jquery.com/addClass/#addClass-\nclassName)を確認しましょう。\n\n(おまけ)CSSも正しくコピーされていません。※ \nしかしながらこれは影響がない可能性がありますが念のため記述しておきます。\n\n質問のCSS\n\n```\n\n .scrollin {\n \n```\n\n参考サイトのCSS\n\n```\n\n .fadein.scrollin {\n \n```\n\n【結論】 \nそれらを参考にしてサンプルコードを作ってみました。\n\n```\n\n $(function(){\n $(window).scroll(function (){\n $('.fadein').each(function(){\n var elemPos = $(this).offset().top;\n var scroll = $(window).scrollTop();\n var windowHeight = $(window).height();\n if (scroll > elemPos - windowHeight + 200){\n $(this).addClass('scrollin');\n }\n });\n });\n });\n```\n\n```\n\n .fadein {\n opacity : 0.1;\n transform : translate(0, 50px);\n transition : all 500ms;\n }\n \n .fadein.scrollin {\n opacity : 1;\n transform : translate(0, 0);\n }\n```\n\n```\n\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>\n 下にスクロールすることで表示する<br><br><br><br><br><br>\n \n \n <ul>\n <li class=\"fadein\"> \n テキストが入ります。<br> \n <p>テキストが入ります。<br>\n <br> \n テキストが入ります。<br>\n テキストが入ります。<br>\n テキストが入ります。<br>\n テキストが入ります <br>\n <br>\n <br>\n <br>\n <br>\n <br>\n <br>\n <br>\n <br>\n <br>\n <br>\n <br>\n </p>\n <figure>\n <img src=\"img/photo.jpg\"> \n <figcaption>テキストが入ります。</figcaption> \n </figure> \n </li> \n </ul>\n```\n\n【補足】 \n実際はスクロールが発生しないとフェードインできないので上部に相当のコンテンツ量が必要そうです。 \nまた参考サイトにもありますが画面にある程度表示してからアニメーションを実行していますが、 \nこのようなスニペットなどの小さな画面だと逆に200は大きすぎて数字を調整する必要がありそうです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T05:28:17.100",
"id": "73558",
"last_activity_date": "2021-01-25T05:28:17.100",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22665",
"parent_id": "73542",
"post_type": "answer",
"score": 0
}
] | 73542 | 73558 | 73558 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "例えば、以下データのように、分散は等しく、平均値が違う場合です。 \n1標本t検定(0.002111)と2標本t検定(0.001053)の検定結果から、単純に1標本t検定の結果の方が、2倍高いと考えてよいのでしょうか。 \nどなたかアドバイスをお願いしてもよろしいでしょうか。\n\n```\n\n x1<-c(1,2,3,4,5)\n x2<-c(6,7,8,9,10)\n (m1<-mean(x1)) # 3\n (m2<-mean(x2)) # 8\n (var1<-var(x1)) # 2.5\n (var2<-var(x2)) # 2.5\n \n t.test(x1,mu=8,alternative=\"two.sided\")\n # One Sample t-test\n #data: x1\n #t = -7.0711, df = 4, p-value = 0.002111\n \n t.test(x1,x2,alternative=\"two.sided\") \n # Welch Two Sample t-test\n #data: x1 and x2\n #t = -5, df = 8, p-value = 0.001053\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T07:42:55.613",
"favorite_count": 0,
"id": "73544",
"last_activity_date": "2021-01-24T07:42:55.613",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "37329",
"post_type": "question",
"score": 0,
"tags": [
"r"
],
"title": "分散が等しい時、1標本t検定と2標本t検定の違いについて",
"view_count": 72
} | [] | 73544 | null | null |
{
"accepted_answer_id": "73551",
"answer_count": 4,
"body": "C言語などのプログラミングにはGCCなどのコンパイラが必要ですよね。ですが、そもそもの話、コンパイラというプログラムを作るためにコンパイラが必要になるわけで、ここにパラドックスが生じてしまいます。\n\nコンパイラをコンパイルするためのコンパイラはどのようにして開発されたのですか?\nすべての源となるコンパイラはアセンブリ言語やマシン語で開発されたのでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T10:28:39.667",
"favorite_count": 0,
"id": "73546",
"last_activity_date": "2021-01-25T23:20:28.097",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43413",
"post_type": "question",
"score": 6,
"tags": [
"c++",
"c",
"gcc"
],
"title": "C言語などのコンパイラはどのようにしてコンパイルされたのですか?",
"view_count": 563
} | [
{
"body": "アセンブラで開発されます \nそして、その言語でコンパイラを作り、アセンブラで開発されたコンパイラに掛け、次のバージョンのコンパイラが生成されます。 \nそして、その言語でそのまた次のバージョンを組み、そのコンパイラにかけて、、、と繰り返していきます\n\nそうやっていまのGCCができました",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T23:08:02.053",
"id": "73549",
"last_activity_date": "2021-01-24T23:08:02.053",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27481",
"parent_id": "73546",
"post_type": "answer",
"score": 0
},
{
"body": "## GCCについて\n\nGCC登場以前からCコンパイラーは存在していました。そのため、GCCは既存のCコンパイラーを使ってコンパイルされることを前提に設計されています。例えばビルド方法も\n\n 1. stage1: 既存のCコンパイラーでGCCをビルドする \n既存のCコンパイラーがコード生成したGCC\n\n 2. stage2: stage1のGCCでGCCをビルドする \n既存のCコンパイラーがコード生成したGCCがコード生成したGCC\n\n 3. stage3: stage2のGCCでGCCをビルドする \n完全にGCCのみでコード生成したGCC\n\nと3回ビルドを行い、最終的にstage3のGCCが使われます。\n\n## クロスコンパイル\n\nそうはいっても既存のCコンパイラーが存在しない環境ではどう作るのかというと、クロスコンパイルという技術があります。別のプラットフォームのCコンパイラーでビルドを行いコード生成します。\n\n * ホスト: コンパイラーが動作する環境\n * ターゲット: 実行ファイルを作成したい環境\n\nと呼び、ホスト上でターゲット向け実行ファイルを生成できるクロスコンパイラーを用意します。\n\n## 最初の1つ\n\nC言語は[UNIX](https://ja.wikipedia.org/wiki/UNIX)を記述するために設計されました。\n\n> 当初はアセンブリ言語のみで開発されたが、1973年にほぼ全体をC言語で書き直した。\n\nとも説明されています。UNIXでは小さなツールを組み合わせて構築されますがCコンパイラーも例外ではなく`cc`は次のツールを呼び出すことで成り立っています。\n\n * `cpp`; Cプリプロセッサー。`.c`ソースファイルから`#include`、`#define`などのプリプロセッサディレクティブを処理し`.i`ファイルを生成する。\n * `cc1`; 狭義のCコンパイラー。`.i`ファイルをコンパイルし、`.s`アセンブリソースを生成する。\n * `as`; アセンブラー。`.s`ファイルから`.o`オブジェクトファイルを生成する。\n * `ar`; アーカイバー。複数の`.o`ファイルをまとめて`.a`ライブラリファイルを生成する。\n * `ld`; リンカー。複数の`.o`ファイルと`.a`ファイルをまとめて実行ファイルを生成する。\n\nUNIX OS全てをC言語で書き直すプロジェクトにおいて、Cコンパイラーもその一部でしかなく、一緒に書き直されたのかな、と想像しています。\n\n## C++\n\nC++コンパイラーも大きなものですが、C++コンパイラーの元祖[Cfront](https://ja.wikipedia.org/wiki/Cfront)はC++ソースからCソースへ変換するツールだったりします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T23:09:42.923",
"id": "73551",
"last_activity_date": "2021-01-24T23:09:42.923",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "73546",
"post_type": "answer",
"score": 6
},
{
"body": "C言語はベル研究所で開発されました。 \n以下のページにはその歴史がDennis M. Ritchie氏によって記述されています。\n\n<https://www.bell-labs.com/usr/dmr/www/chist.html>\n\nBCPL => B言語 => C言語 の順で作られたようですが、並走で使われていたようです。 \nそして、コンピューター側の発展も関連しているようです。つまり、ある言語が稼働するには、それが可能な性能を持つコンピュータが必要とのことでしょう。 \nあたりまえの事ですが、新しい物はすべからくその時あるものから生み出されるということです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-24T23:23:17.580",
"id": "73552",
"last_activity_date": "2021-01-24T23:23:17.580",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3793",
"parent_id": "73546",
"post_type": "answer",
"score": 0
},
{
"body": "この話題には、コンパイラの **ブートストラップ問題** という名前が付いています\n\n * [https://ja.wikipedia.org/wiki/ブートストラップ問題](https://ja.wikipedia.org/wiki/%E3%83%96%E3%83%BC%E3%83%88%E3%82%B9%E3%83%88%E3%83%A9%E3%83%83%E3%83%97%E5%95%8F%E9%A1%8C)\n\n本当の本当に最初にはその計算機が理解できる言葉、いわゆる **マシン語** で実装することになります。また、アセンブラが実装済みであれば **アセンブリ**\nで実装できます。\n\n別の計算機でコンパイラが実装済みであれば、クロスコンパイラも実装することによって実装できます。\n\nまた、その計算機において別の言語のコンパイラが実装済みであれば、その別の言語でコンパイラを実装することによって実装できます。\n\n更には、コンパイラが自分自身をコンパイルできるようにするところまで実装できる場合もあり、これをコンパイラの **セルフホスティング** と言います。\n\n * [https://ja.wikipedia.org/wiki/セルフホスティング](https://ja.wikipedia.org/wiki/%E3%82%BB%E3%83%AB%E3%83%95%E3%83%9B%E3%82%B9%E3%83%86%E3%82%A3%E3%83%B3%E3%82%B0)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T04:27:48.620",
"id": "73557",
"last_activity_date": "2021-01-25T23:20:28.097",
"last_edit_date": "2021-01-25T23:20:28.097",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "73546",
"post_type": "answer",
"score": 5
}
] | 73546 | 73551 | 73551 |
{
"accepted_answer_id": "73568",
"answer_count": 1,
"body": "RHEL5.6のサーバに対して新たにソフトを導入することになり、そのソフトの導入要件として「IPv6のループバックアドレスが有効であること」となっておりました。 \n一般的なループバックアドレスの設定として、hostsファイルへ下記を記入しましたがPingがエラーとなりました。 \nエラーを回避して、ループバックアドレスで応答するようにするためにはどのように設定すれば良いでしょうか?\n\n**hostsの記載内容**\n\n```\n\n ::1 localhost6.localdomain6 localhost6 (hostname)\n ※(hostname)は仮で表記しており、実際はサーバのホスト名が記入されています。\n \n```\n\n**実行したPingコマンド**\n\n```\n\n ping6 -c 3 ::1\n \n```\n\n**実行結果 (エラーメッセージ)**\n\n```\n\n socket: Address family not supported by protocol\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T05:53:47.990",
"favorite_count": 0,
"id": "73559",
"last_activity_date": "2021-01-26T09:15:29.520",
"last_edit_date": "2021-01-26T09:15:29.520",
"last_editor_user_id": "37458",
"owner_user_id": "37458",
"post_type": "question",
"score": 1,
"tags": [
"rhel",
"ipv6"
],
"title": "RHEL5.6でIPv6のループバックアドレスを設定したい",
"view_count": 145
} | [
{
"body": "OS で IPv6 が無効になっているのではないでしょうか? \n/etc/modprobe.conf や /etc/modprobe.d/ 以下のファイルで以下のような設定があれば、コメントアウトし、OS\nを再起動します。\n\n```\n\n alias net-pf-10 off\n blacklist ipv6\n install ipv6 /bin/true\n options ipv6 disable=1\n \n```\n\n再起動後、`ip addr show dev lo` で `inet6` が表示されることを確認ください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T14:30:54.263",
"id": "73568",
"last_activity_date": "2021-01-25T14:30:54.263",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4603",
"parent_id": "73559",
"post_type": "answer",
"score": 2
}
] | 73559 | 73568 | 73568 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "本当にやりたいことは「MacOSアプリで何度もパスワードを入力させたくない」なのですが、その解決策のために下記のページを発見しました。 \n[Bypass admin password when changing network\nconfiguration](https://developer.apple.com/forums/thread/52729)\n\nそこに \n[EvenBetterAuthorizationSample](https://developer.apple.com/library/archive/samplecode/EvenBetterAuthorizationSample/Introduction/Intro.html)\nへのリンクがありました。\n\n`Read Me About EvenBetterAuthorizationSample.txt` の `Building the\nSample`の項目にある通りplistを修正し実行しました(とは言うもののDevelop\nIDの確認方法がよくわからなかったため、https://developer.apple.com/ から `Membership\nDetails`の項目の`Team ID`の値で置き換えました)。\n\nスキームは下記のように設定して実行しましました。 \n[](https://i.stack.imgur.com/Z83Qj.png)\n\n実行結果は、下記です。 \n[](https://i.stack.imgur.com/Hggsp.png)\n\nInstall以外のどのボタンを押しても\n\n```\n\n error NSCocoaErrorDomain / 4099\n connection invalidated\n \n```\n\nというエラーになります。\n\nダメ元でInstallを押すと、パスワードを要求されるので入力すると\n\n`error CFErrorDomainLaunchd / 4`\n\nと表示されました。\n\n結局、このサンプルコードは何をインストールしようとしているのでしょうか? \nこのサンプルコードと \n[Bypass admin password when changing network\nconfiguration](https://developer.apple.com/forums/thread/52729) \nの質問タイトルであります、パスワードをバイパスするという関係性がいまいちピンと来ません。 \nこのサンプルコードは何をしようとしているのでしょうか?\n\nなんとなく \n[AuthorizationCreate](https://developer.apple.com/documentation/security/1397453-authorizationcreate?language=objc) \nに記載されている\n\n> You can also use this function to preauthorize rights by specifying the\n> kAuthorizationFlagPreAuthorize mask. Preauthorization is most useful when a\n> right has a zero timeout. For example, you can preauthorize in the\n> application and if it succeeds, call the helper tool and request\n> authorization. This eliminates calling the helper tool if the user cannot\n> later authorize the specified rights.\n\nの中に記載されている `the helper tool`\nと何か関係している気もしています(とはいえヘルパーツールとは?という感じで言葉以上の理解がいまいち進んでないですが)\n\n同ページの\n\n> In macOS 10.4 and later, you can also pass a user name and password in order\n> to authorize a user without user interaction. Possible values for this\n> parameter are listed in Security.framework/Headers/AuthorizationTags.h. \n> The data passed in this parameter is not stored in the authorization\n> reference; it is used only during authorization. If you are not passing any\n> data in this parameter, pass the constant kAuthorizationEmptyEnvironment.\n\nところも気になっており、これで本当にやりたかったパスワードを何度も入力させたくないを達成できないか別途調査中です。\n\n(本当はSwiftでコードを作成しているのですが、この手の権限の情報がObjective-Cでの情報ばかりがネットにあるので、仕方なくObjective-\nCで情報を集めています)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T07:16:24.627",
"favorite_count": 0,
"id": "73560",
"last_activity_date": "2021-01-25T08:08:42.157",
"last_edit_date": "2021-01-25T08:08:42.157",
"last_editor_user_id": "9008",
"owner_user_id": "9008",
"post_type": "question",
"score": 1,
"tags": [
"swift",
"xcode",
"objective-c"
],
"title": "EvenBetterAuthorizationSampleは、いったい何をするものをインストールするのでしょうか?",
"view_count": 90
} | [] | 73560 | null | null |
{
"accepted_answer_id": "73562",
"answer_count": 1,
"body": "np.matrixの全ての要素に対して(-1/2)乗したいのですが、簡単な方法はありますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T10:11:07.493",
"favorite_count": 0,
"id": "73561",
"last_activity_date": "2021-01-25T11:08:47.033",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43428",
"post_type": "question",
"score": 0,
"tags": [
"python",
"numpy"
],
"title": "Pythonのnp.matrixの全要素に対する操作",
"view_count": 90
} | [
{
"body": "[numpy.matrix](https://numpy.org/doc/stable/reference/generated/numpy.matrix.html)\nのページには「no longer recommended」とあります。使わないほうがよいでしょう。\n\n> It is no longer recommended to use this class, even for linear algebra.\n> Instead use regular arrays. The class may be removed in the future.\n\n* * *\n\n(とりあえず `numpy.matrix` 使うとして) \n`numpy.matrix` での `**` 演算子は matrix power ということなので, (`matrix` ではなく) 普通に\n[numpy.array](https://numpy.org/doc/stable/reference/generated/numpy.array.html)\n使えばできそうです。\n\n```\n\n mat = np.matrix('1 2 3 4; 5 6 7 8')\n arr = np.array(mat)\n print(np.matrix(arr **(-1/2)))\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T11:08:47.033",
"id": "73562",
"last_activity_date": "2021-01-25T11:08:47.033",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43025",
"parent_id": "73561",
"post_type": "answer",
"score": 1
}
] | 73561 | 73562 | 73562 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "docker上のvscodeでc++を用いて、[Qt for Beginners - Qt\nWiki](https://wiki.qt.io/Qt_for_Beginners) の'Hello World'を行おうとしました。 \nmain.cppは以下のとおりです。\n\n```\n\n #include <QApplication>\n #include <QPushButton>\n \n int main(int argv, char **args)\n {\n QApplication app(argv, args);\n \n QPushButton button (\"Hello world !\");\n button.show();\n \n return app.exec();\n } \n \n```\n\nmain.proファイルは次のようです。\n\n```\n\n TEMPLATE = app TARGET = name_of_the_app\n QT = core gui\n QT += widgets\n SOURCES += main.cpp\n \n```\n\nその後、ターミナル上で\n\n```\n\n qmake -project\n qmake\n make\n \n```\n\nを行ったところ\n\n```\n\n g++ -Wl,-O1 -o Culculation_cpp main.o -lQt5Gui -lQt5Core -lGL -lpthread \n /usr/bin/ld: main.o: in function `main.cold.0':\n main.cpp:(.text.unlikely+0xc): undefined reference to `QApplication::~QApplication()'\n /usr/bin/ld: main.cpp:(.text.unlikely+0x1f): undefined reference to `QPushButton::~QPushButton()'\n /usr/bin/ld: main.o: in function `main':\n main.cpp:(.text.startup+0x22): undefined reference to `QApplication::QApplication(int&, char**, int)'\n /usr/bin/ld: main.cpp:(.text.startup+0x4f): undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'\n /usr/bin/ld: main.cpp:(.text.startup+0x5f): undefined reference to `QWidget::show()'\n /usr/bin/ld: main.cpp:(.text.startup+0x64): undefined reference to `QApplication::exec()'\n /usr/bin/ld: main.cpp:(.text.startup+0x6f): undefined reference to `QPushButton::~QPushButton()'\n /usr/bin/ld: main.cpp:(.text.startup+0x77): undefined reference to `QApplication::~QApplication()'\n collect2: error: ld returned 1 exit status\n make: *** [Makefile:139: Culculation_cpp] Error 1\n \n```\n\nのように出力され、\n\n```\n\n cannot open source file \"QAplication\"\n cannot open source file \"QPushButton\"\n \n```\n\nとなってしまいました。 \nqt5-default, build-essential,apt-get install mesa-common-devはインストール済みです。 \nどのようにすればよいでしょうか。\n\n**追記** \n`QT += widgets` が書かれていることを確認し、qmake, make を実行したところ、下記のような出力がありました。\n\n```\n\n g++ -Wl,-O1 -o Culculation_cpp main.o -lQt5Gui -lQt5Core -lGL -lpthread \n /usr/bin/ld: main.o: in function `main.cold.0':\n main.cpp:(.text.unlikely+0xc): undefined reference to `QApplication::~QApplication()'\n /usr/bin/ld: main.cpp:(.text.unlikely+0x1f): undefined reference to `QPushButton::~QPushButton()'\n /usr/bin/ld: main.o: in function `main':\n main.cpp:(.text.startup+0x22): undefined reference to `QApplication::QApplication(int&, char**, int)'\n /usr/bin/ld: main.cpp:(.text.startup+0x4f): undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'\n /usr/bin/ld: main.cpp:(.text.startup+0x5f): undefined reference to `QWidget::show()'\n /usr/bin/ld: main.cpp:(.text.startup+0x64): undefined reference to `QApplication::exec()'\n /usr/bin/ld: main.cpp:(.text.startup+0x6f): undefined reference to `QPushButton::~QPushButton()'\n /usr/bin/ld: main.cpp:(.text.startup+0x77): undefined reference to `QApplication::~QApplication()'\n collect2: error: ld returned 1 exit status\n make: *** [Makefile:139: Culculation_cpp] Error 1\n \n```\n\nまた上と同じように\n\n```\n\n #include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/workspaces/Culculation_cpp/main.cpp).C/C++(1696)\n cannot open source file \"QApplication\"C/C++(1696)\n \n```\n\nのように書かれておりました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T13:51:52.577",
"favorite_count": 0,
"id": "73565",
"last_activity_date": "2021-01-25T16:37:12.267",
"last_edit_date": "2021-01-25T16:37:12.267",
"last_editor_user_id": "3060",
"owner_user_id": "30396",
"post_type": "question",
"score": 0,
"tags": [
"c++",
"ubuntu",
"qt",
"qt5"
],
"title": "qtでのコンパイルエラー",
"view_count": 322
} | [
{
"body": "qmake -project は .pro を(半)自動で生成するコマンドなので、main.pro\nを自分で書いた際には実行する必要がありません。(実行すると内容が上書きされます)\n\nmain.cpp と main.pro の内容は問題なさそうに見えます。\n\n> g++ -Wl,-O1 -o Culculation_cpp main.o -lQt5Gui -lQt5Core -lGL -lpthread\n\nを見る限り、-lQt5Widgets が不足しているため、undefined reference to … のエラーが発生しています。\n\n.pro ファイルに「QT += widgets」が記載されているか確認してみてください。\n\nただ、QT += widgets が無い場合には、リンクの前の main.cpp のコンパイル時に \nQApplication などの #include でエラーになるような気がします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T14:03:07.480",
"id": "73566",
"last_activity_date": "2021-01-25T14:03:07.480",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10245",
"parent_id": "73565",
"post_type": "answer",
"score": 0
}
] | 73565 | null | 73566 |
{
"accepted_answer_id": "73569",
"answer_count": 1,
"body": "PythonでWEBページをスクレイピングし、あるサイトから店名と住所情報を取得したいと考えています。 \nコラボラトリー環境で以下のコードを試してみたのですが、情報を取得できません。 \nコードのどこがいけないのかスクレイピングに詳しい方教えていただけませんでしょうか?\n\n```\n\n !pip install geocoder\n import requests\n import pandas as pd\n from bs4 import BeautifulSoup\n from google.colab import files\n import os\n import geocoder\n from time import sleep\n from google.colab import files\n \n url1 = \"https://www.aeon.com/store/list/%E7%B7%8F%E5%90%88%E3%82%B9%E3%83%BC%E3%83%91%E3%83%BC/%E3%82%A4%E3%82%AA%E3%83%B3%E3%83%BB%E3%82%A4%E3%82%AA%E3%83%B3%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB/p_\"\n url2 = \"/?q=aeoncom\"\n cols = ['store_name','address','latlon']\n df = pd.DataFrame(index=[],columns=cols)\n \n for i in range(1,22):\n response = requests.get(url1 + str(i) + url2).text\n soup = BeautifulSoup(response, 'html.parser')\n \n for tag in soup.find_all('div', class_=\"storeInfo\"):\n atag_stname = tag.find('a', class_=\"storeName\")\n atag_adname = tag.find('span', class_=\"address\")\n latlon = geocoder.arcgis(atag_adname)\n \n record = pd.Series([atag_stname.text,atag_adname.text,latlon.latlng],index=df.columns)\n df = df.append(record,ignore_index=True)\n sleep(2)\n df.to_csv(\"df_ion.csv\")\n files.download('df_ion.csv')\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T14:04:03.467",
"favorite_count": 0,
"id": "73567",
"last_activity_date": "2021-01-28T08:29:21.383",
"last_edit_date": "2021-01-28T08:29:21.383",
"last_editor_user_id": "42369",
"owner_user_id": "42369",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3",
"web-scraping"
],
"title": "WEBスクレイピングができない",
"view_count": 415
} | [
{
"body": "`User-Agent` を設定すると期待通りに動作する様です。\n\n```\n\n headers = {\n 'User-Agent':\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100'\n }\n :\n \n for i in range(1,22):\n response = requests.get(url1 + str(i) + url2, headers=headers).text\n :\n \n print(df)\n \n store_name address latlon\n 0 イオン札幌麻生店 北海道札幌市北区北39条西4-1-5 [43.10729026007806, 141.3397210097591]\n 1 イオン札幌琴似店 北海道札幌市西区琴似2条4-2-2 [43.07673248139989, 141.30288212620786]\n :\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-25T15:29:12.027",
"id": "73569",
"last_activity_date": "2021-01-25T16:38:28.133",
"last_edit_date": "2021-01-25T16:38:28.133",
"last_editor_user_id": "3060",
"owner_user_id": null,
"parent_id": "73567",
"post_type": "answer",
"score": 3
}
] | 73567 | 73569 | 73569 |
{
"accepted_answer_id": "73591",
"answer_count": 2,
"body": "# 質問\n\n添付画像のメニューを非表示にしたいです。 \nどの様にすればよいでしょうか?\n\n# 環境\n\n * EmEditor Professional(64Bit) Version 20.4.5\n * Windows 10 64 Bit 20H2(Build 19042.746)\n\n[](https://i.stack.imgur.com/n2sFw.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T02:38:35.263",
"favorite_count": 0,
"id": "73577",
"last_activity_date": "2021-01-26T15:36:19.110",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34546",
"post_type": "question",
"score": 0,
"tags": [
"emeditor"
],
"title": "Emeditor右クリックメニューを非表示にしたい",
"view_count": 351
} | [
{
"body": "以下レジストリを削除で解決しました。\n\n```\n\n HKEY_CLASSES_ROOT\\*\\shell\\EmEditor\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T02:42:05.800",
"id": "73578",
"last_activity_date": "2021-01-26T05:59:51.913",
"last_edit_date": "2021-01-26T05:59:51.913",
"last_editor_user_id": "34546",
"owner_user_id": "34546",
"parent_id": "73577",
"post_type": "answer",
"score": 0
},
{
"body": "EmEditor の [カスタマイズ] ダイアログ ボックスの [ショートカット] ページの [エクスプローラのコンテキスト\nメニューにショートカットを追加] チェック ボックスをクリアしてください。 \n[](https://i.stack.imgur.com/MTtPk.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T15:36:19.110",
"id": "73591",
"last_activity_date": "2021-01-26T15:36:19.110",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "40017",
"parent_id": "73577",
"post_type": "answer",
"score": 2
}
] | 73577 | 73591 | 73591 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "長さ`3575`のベクトルが`201`本ありそれを`numpy.ndarray`形式で保存しています.説明の簡単のため`x`とします. \nこの`x`の各行,つまり形が`(1,\n3575)`のベクトルに対して計算を行いたいのですが,各行ごとを取得する方法がわかりません.どなたかわかる方がいらっしゃいましたらご教授よろしくお願いします. \n以下にサイズを下げたminimal exampleを示します.\n\n```\n\n import numpy as np\n \n x = np.array([[22, 44, 66], [90, 80, 70], [1, 3, 2]])\n for _ in range(x.shape[0]):\n 各行のベクトル = 各行のベクトル / np.linalg.norm(各行のベクトル)\n print(各行のベクトル)\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T03:09:31.380",
"favorite_count": 0,
"id": "73579",
"last_activity_date": "2023-06-09T02:05:40.633",
"last_edit_date": "2021-01-26T04:20:00.533",
"last_editor_user_id": "3060",
"owner_user_id": "36750",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"numpy"
],
"title": "行列の各行をforループで計算する方法",
"view_count": 851
} | [
{
"body": "各行ごと取り出すのなら以下のようにできます\n\n```\n\n import numpy as np\n \n x = np.array([[22, 44, 66], [90, 80, 70], [1, 3, 2]])\n for vec in x:\n v = vec / np.linalg.norm(vec)\n print(v)\n \n```\n\n全体を一度に行う方法はコメントに紹介されています",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T04:21:22.663",
"id": "73583",
"last_activity_date": "2021-01-26T04:21:22.663",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43025",
"parent_id": "73579",
"post_type": "answer",
"score": 0
},
{
"body": "各行をごと取り出すなら\n\n```\n\n import numpy as np\n k\n x = np.array([[22, 44, 66], [90, 80, 70], [1, 3, 2]])\n for i in x:\n norm = vec / np.linalg.norm(vec)\n print(norm)\n \n```\n\nで計算することが可能です。\n\nまた特定の行だけを指定したいのならば\n\n```\n\n #空のnp.arrayのリストを作成\n list_x = np.array([])\n for i in x:\n list_x = np.append(list_x,i)\n print(list_x)\n \n```\n\nとやると、xに入っていたリストがリストごとに分解されてlist_xに挿入されるので、計算したいリストだけを取り出して計算することが可能です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-05-18T06:18:09.767",
"id": "75914",
"last_activity_date": "2021-05-18T06:18:09.767",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "45368",
"parent_id": "73579",
"post_type": "answer",
"score": 0
}
] | 73579 | null | 73583 |
{
"accepted_answer_id": "73586",
"answer_count": 1,
"body": "<https://github.com/google/macops-\nkeychainminder/blob/b6ab824321fc677aa80a217348023dcdf416b68a/Common/Common.m> \nや \n<https://github.com/bikram990/NoMADLogin-\nAD/blob/a8ff99b12335bbaa307052b4df27ca3163b8f663/Carthage/Checkouts/NoMAD-\nADAuth/NoMAD-ADAuth/KerbUtil.m> \nに記載されている `AuthorizationEnvironment`を生成するObjective-\nCのコードをSwiftで書くにはどうすればよいでしょうか?\n\n自分なりに、下記のように書きました\n\n```\n\n var authorizationRef: AuthorizationRef?\n let authorizationFlags: AuthorizationFlags = [\n .extendRights,\n .interactionAllowed,\n .preAuthorize\n ]\n \n var userName = NSUserName()\n var password = \"password\"\n \n let userNameItem = AuthorizationItem(\n name: kAuthorizationEnvironmentUsername,\n valueLength: userName.lengthOfBytes(using: .utf8),\n value: UnsafeMutableRawPointer(&userName),\n flags: 0\n )\n let passwordItem = AuthorizationItem(\n name: kAuthorizationEnvironmentPassword,\n valueLength: password.lengthOfBytes(using: .utf8),\n value: UnsafeMutableRawPointer(&password),\n flags: 0\n )\n var items = [\n userNameItem,\n passwordItem\n ]\n \n var authorizationEnvironment = AuthorizationEnvironment(\n count: 2,\n items: &items\n )\n \n let status = AuthorizationCreate(\n nil,\n &authorizationEnvironment,\n authorizationFlags,\n &authorizationRef\n )\n \n 以下略\n \n```\n\nところが下記の警告が出ています。\n\n```\n\n Passing 'String' to parameter, but argument 'name' should be a pointer that outlives the call to 'init(name:valueLength:value:flags:)'\n \n```\n\nや\n\n```\n\n Inout expression creates a temporary pointer, but argument 'items' should be a pointer that outlives the call to 'init(count:items:)'\n \n```\n\nや\n\n```\n\n Initialization of 'UnsafeMutableRawPointer' results in a dangling pointer\n \n```\n\nといったものです。\n\nまた作り出した`AuthorizationEnvironmentインスタンス`を`AuthorizationCreate`に渡した結果、Objective-\nCだとパスワードの要求をされなくなったのですが、Swiftで同様のコードを再現しようとすると、パスワードを要求されるので、おそらく`AuthorizationEnvironmentインスタンス`の生成がうまくできていないのだと推測しています。\n\n蛇足かもしれませんが、はじめ `userName`変数は`let`で宣言していたのですが、\n\n```\n\n Cannot pass immutable value as inout argument: 'userName' is a 'let' constant\n \n```\n\nというコンパイルエラーが出たので意味もわからず `var` で宣言しなおして、コンパイルエラーを解消しています。(その他 password変数も同様の理由で\n`var` で宣言しています)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T03:54:14.200",
"favorite_count": 0,
"id": "73580",
"last_activity_date": "2021-01-26T06:29:15.520",
"last_edit_date": "2021-01-26T04:34:03.740",
"last_editor_user_id": "9008",
"owner_user_id": "9008",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"objective-c",
"macos"
],
"title": "AuthorizationEnvironmentを生成するObjective-CのコードをSwiftで書く方法をおしえてください",
"view_count": 133
} | [
{
"body": "> Passing 'String' to parameter, but argument 'name' should be a pointer that\n> outlives the call to 'init(name:valueLength:value:flags:)'\n\nSwiftでは、String型の値を`UnsafePointer<Int8>`型の引数に渡すことができますが、その時に生成されるポインタは一時的なもので、「渡されたポインタを後で使うために保持する」ような構造体を作成する場合には、そのまま使用してはいけません。この使い方は残念ながらある特定の条件が揃ってしまうと動いているように見えることがあるため、例えば「本番環境でだけ現れる厄介なエラー」なんかの原因になったりすることがあります。\n\nできるだけ安全にそのようなポインタを作りたければ、書き換え可能な領域にメモリを割り当ててコピーを保持する必要があるでしょう。C標準関数の`strdup`なんかが使えます。\n\n> Inout expression creates a temporary pointer, but argument 'items' should be\n> a pointer that outlives the call to 'init(count:items:)'\n\n配列をポインタ型の変数に渡すときにも同様の「一時的なポインタ」が作られるので、上記と同じことが言えます。文字列と同様に安定な領域にメモリを割り当ててコピーを作るか、この場合ならポインタが使用される可能性のある範囲を`withUnsafeMutableBufferPointer`などで囲んで使ってやることになります。\n\n> Initialization of 'UnsafeMutableRawPointer' results in a dangling pointer\n\n`UnsafeMutableRawPointer(&userName)`のような使い方は非常によく見られる(そこそこ有名なライブラリでも使われていたことがあると記憶しています)誤った使い方の典型例です。`UnsafeMutableRawPointer.init`に文字列を指定すると、一時的な領域が作られ、その領域のアドレスが渡されるのですが、その領域のアドレスは`UnsafeMutableRawPointer.init`が終了すると、無効になります。\n\n先ほども書きましたが、この「誤った使い方」の厄介なところは、特定の状況ではそれが何度繰り返して実行しても動いているように見えてしまうことです。\n\n**Xcodeのポインタに関する警告は絶対に無視しないようにしましょう。**\n\n * テスト環境では動くのに、本番環境では動かない\n * 特定の(多くの場合「以前の」)バージョンのiOSでは動くのに、別のバージョン(例えば「最新の」)では動かない\n\nなんてことが起こると、「これはiOSのバグのせいに違いない」なんて書き込みをされる方がAppleのDevForumsなんかに時々現れるのですが、コードを見せてもらうと「ほら、こんなところで間違ったポインタの使い方をしています」なんてことになります。 \n(誤ったマルチスレッド処理でも同じような状況が発生しますが。)\n\n> Cannot pass immutable value as inout argument: 'userName' is a 'let'\n> constant\n\nこういったC言語ベースのAPIしか用意されていない場合、絶対に内容を書き換えないだろうポインタに`const`等の宣言がなされていないことがよくあって、その場合、mutableなポインタが必要になります。そのためにはその元になる変数をvarにする必要が出てくる、と言うわけで、この場合、「意味もわからず\n`var` で宣言しなおし」なんてことも必要になるでしょう。\n\n先に書いた「一時的ポインタをあとあと使用される場所に使おうとしている」のさえ気をつければ、そこらへんは「とにかく `var`\nにする」と言う対応にならざるを得ません。\n\n* * *\n\nと言うわけでざっくりと上記の状況を解決すると、以下のようなコードになります。\n\n```\n\n var authorizationRef: AuthorizationRef?\n let authorizationFlags: AuthorizationFlags = [\n .extendRights,\n .interactionAllowed,\n .preAuthorize\n ]\n \n let userName = NSUserName()\n let password = \"password\"\n \n let cAuthorizationEnvironmentUsername = strdup(kAuthorizationEnvironmentUsername)!\n defer {free(cAuthorizationEnvironmentUsername)}\n let cUserName = strdup(userName)!\n defer {free(cUserName)}\n \n let cAuthorizationEnvironmentPassword = strdup(kAuthorizationEnvironmentPassword)!\n defer {free(kAuthorizationEnvironmentPassword)}\n let cPassword = strdup(password)!\n defer {free(cPassword)}\n \n let userNameItem = AuthorizationItem(\n name: cAuthorizationEnvironmentUsername,\n valueLength: userName.utf8.count,\n value: cUserName,\n flags: 0\n )\n \n let passwordItem = AuthorizationItem(\n name: cAuthorizationEnvironmentPassword,\n valueLength: password.utf8.count,\n value: cPassword,\n flags: 0\n )\n var items = [\n userNameItem,\n passwordItem\n ]\n items.withUnsafeMutableBufferPointer {bufItems in\n var authorizationEnvironment = AuthorizationEnvironment(\n count: UInt32(bufItems.count),\n items: bufItems.baseAddress\n )\n let status = AuthorizationCreate(\n nil,\n &authorizationEnvironment,\n authorizationFlags,\n &authorizationRef\n )\n //`authorizationRef`はこのブロック内で使う必要がある?\n //...\n }\n \n```\n\nSwiftのポインタに関する警告を安全に黙らせることだけを考えて書いたので、実際に使う分には何か問題が出るかもしれません。その場合にはコメント等でお知らせください。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T05:43:28.057",
"id": "73586",
"last_activity_date": "2021-01-26T06:29:15.520",
"last_edit_date": "2021-01-26T06:29:15.520",
"last_editor_user_id": "13972",
"owner_user_id": "13972",
"parent_id": "73580",
"post_type": "answer",
"score": 1
}
] | 73580 | 73586 | 73586 |
{
"accepted_answer_id": "73587",
"answer_count": 1,
"body": "エディタに長い記述をしたので縮小して全体が見えるようにしたいと思います。 \nメニューの「表示」→「外観」→「ズームアウト」を選択したり、 \nショートカットの「Crtl」+「-」を押してみたのですが、\n\n【ユーザー設定に書き込めません。ユーザー設定を開いて、ファイル内のエラー/警告を修正してからもう一度お試しください】\n\nとエラーが出ます。エラー画面の「設定を開く」をクリックするとjsonの画面が出てきます。 \nそのjsonのファイルに\n\n\"editor.mouseWheelZoom\": true, // マウスホイール文字サイズ変更:Ctrl + ホイール\n\nと記述してやるとCtrlを押しながらマウスホイールで拡大、縮小は出来るようになりました。マウスホイールで拡大、縮小が出来ると作業中にいきなり画面が大きくなったり小さくなり面倒ですよね。4\n\nまたよくわからずに \n\"workbench.action.zoomIn\": \"true\", \n\"workbench.action.zoomOut\": \"true\",\n\nなども記述してみたのですが、何の変化もありませんでした。\n\nメニューやショートカットの「Ctrl」+「-」では縮小できません。\n\n前質問で教えていただいた \n「ファイル」→「ユーザー設定」→「キーボードショートカット」のファイルは以下の添付画像のようになっています。 \n<https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q11237812526>\n\n鉛筆印を押すと編集画面に変わり \n「任意のキーの組み合わせを押し、Enterキーを押します」という画面が出てくるので「Ctrl」 +\n「-」を押すと「2つの既存のコマンドがこのキーバインドを使用しています。」というようなメッセージが出てきます。 \n既に存在しているのに、拡大、縮小が効かない状態のようです。\n\nこれ以上、どうすれば良いのかわかりません。 \nわかる方いらっしゃいました教えてください。 \nよろしくお願いいたします。\n\n[](https://i.stack.imgur.com/pmrCU.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T04:59:52.790",
"favorite_count": 0,
"id": "73584",
"last_activity_date": "2021-01-27T01:49:02.590",
"last_edit_date": "2021-01-27T01:49:02.590",
"last_editor_user_id": "3060",
"owner_user_id": "42150",
"post_type": "question",
"score": 0,
"tags": [
"vscode"
],
"title": "Visual Studio Code の拡大縮小ができません。",
"view_count": 1074
} | [
{
"body": "下記のエラーは設定ファイルの[記述が間違っている](https://qiita.com/miriwo/items/4aab8e6ee4cd64faa48a)時に表示されます。\n\n`【ユーザー設定に書き込めません。ユーザー設定を開いて、ファイル内のエラー/警告を修正してからもう一度お試しください】`\n\n設定ファイルを俯瞰すると`\"editor.minimap.enabled\":false\"`の末尾に`,`が付いていないようです。 \n省略の都合で省いたのかもしれませんが、`settings.json`の記述に間違いがないか見直してみてください。\n\nまたキーバインドも`Zoom In`と`Zoom Out`に同一の`-`キーがバインドされている点が気になります。 \nまずは改修した点を元に戻して基本に立ち返ってから設定を見直すと、案外うまく行くかもしれません。\n\nなお、キーバインドをカスタマイズしていない私の環境で「Crtl」+「-」を試したところ、正常にズームアウトしました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T05:55:28.427",
"id": "73587",
"last_activity_date": "2021-01-26T05:55:28.427",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "73584",
"post_type": "answer",
"score": 1
}
] | 73584 | 73587 | 73587 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "プログラミング初心者です。 \nJAVA の勉強がてらマインクラフト JAVA 向けの mod をつくってみようと思い、 \n以下のサイトを参考に JDK などのインストールからやってみているのですが、 \n\"Minecraft の起動\" にて RunClient の実行中に下記のようなエラーが出てしまいます。\n\n少し前に VisualStudio でC#を触ったことがあるくらいで、 \nJAVA の IntelliJ の勝手がわからず全くエラーの内容がわかりません。\n\nこのエラーを解消して参考サイトに記載の通りマインクラフトを起動できるようにしたいのですが、どのようにすればよいのでしょうか?\n\n以下該当エラーコード\n\n```\n\n Execution failed for task ':runClient'.\n > Process 'command 'C:\\Users\\user\\.jdks\\corretto-1.8.0_282\\bin\\java.exe'' finished with non-zero exit value -1\n \n * Try:\n Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.\n \n```\n\n参考にしているサイト\n\n[Minecraft 1.12.2 Forge Modの作成 その1 【開発環境の準備 IntelliJ IDEA】 | プロジェクトの作成 -\nQiita](https://qiita.com/Hiroya_W/items/7ad9bad0387ef3688d1e#%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%81%AE%E4%BD%9C%E6%88%90)\n\n* * *\n\n**追記1**\n\n以下、 kunif 様のご提案で1.14.4にトライしてみた様子です。\n\nまず <https://qiita.com/Hiroya_W/items/f38089724d9358d1668d> の実行構成を作成の項で記載の通り\n\n```\n\n PS C:\\Users\\user\\IdeaProjects\\biwako_mod> .\\gradlew genIntellijRuns\n \n```\n\nと打ち込みましたが、以下のエラーが出ました。\n\n```\n\n Get-Process : 引数 '.\\gradlew' を受け入れる位置指定パラメーターが見つかりません。 発生場所 行:1 文字:1 + PS C:\\Users\\user\\IdeaProjects\\biwako_mod> .\\gradlew genIntellijRuns + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-Process]、ParameterBindingExcepti on + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands. GetProcessCommand –\n \n```\n\n* * *\n\n**追記2**\n\n<https://www.tntmodders.com/tutorial/env-1144/> \nの通りに 1.14.4 環境でトライしてみました。 \nしかし、Forge の項 10 で実行構成選択の候補欄に \"runClient\" が見当たりませんでした。\n\nその後、\"構成と編集\"で名前とタスクの欄に手書きで\"runClient\"と記入して実行したところ、 \n以下のエラーがでました。\n\n```\n\n Execution failed for task ':runClient'.\n > Process 'command 'C:\\Users\\user\\.jdks\\corretto-1.8.0_282\\bin\\java.exe'' finished with non-zero exit value -1\n \n * Try:\n Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.\n \n```\n\n* * *\n\n**追記3**\n\nmdk の zip ファイルを解凍したファイルを開く方法ではなく、 \nあらかじめ解凍したフォルダのなかから\n\n * build.gradle\n * gradlew.bat\n * gradlew\n * gradleフォルダ\n\nを取り出してプロジェクトフォルダへ移し、それを開いて実行すると追記2での \n実行構成選択欄に\"runClient\"がないという事態は収まりましたが、 \nそのまま実行すると\n\n```\n\n 'runClient' の実行中にエラーが発生しました: '1.8' is misconfigured\n \n```\n\nというシンプルなエラーが出て失敗してしまいます。\n\n* * *\n\n**追記4** \n回答いただいた通り実行すると、\n\n```\n\n [LWJGL] GLFW_API_UNAVAILABLE error\n (空白) \n Exception in thread \"main\"\n \n```\n\nというエラーコードと、数行にわたる緑色のログを挟んで\n\n```\n\n Process finished with exit code 1\n \n```\n\nという文が表れてマインクラフトは起動しないまま動作が止まってしまいました。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T05:18:37.077",
"favorite_count": 0,
"id": "73585",
"last_activity_date": "2022-02-01T10:05:35.600",
"last_edit_date": "2021-01-31T14:25:41.633",
"last_editor_user_id": "43447",
"owner_user_id": "43447",
"post_type": "question",
"score": 1,
"tags": [
"java",
"intellij-idea"
],
"title": "IntelliJ RunClient 実行時のエラー",
"view_count": 1800
} | [
{
"body": "取り敢えず以下の記事を参考にして出来ているようです。 \n[環境構築 (1.14.4)](https://www.tntmodders.com/tutorial/env-1144/)\n\nただし少し手順を変えて以下のようにしています。\n\n * OpenJDKはIntelliJ IDEA Community Edition からインストールするのではなく、別途ダウンロードして先にインストールしておきます。\n\n * [Prebuilt OpenJDK Binaries for Free!](https://adoptopenjdk.net/?variant=openjdk8&jvmVariant=hotspot)からOpenJDK 8 (LTS)のHotSpotを選択してダウンロード・インストール\n * その際には[AdoptOpenJDKのダウンロード及びインストール](https://www.javadrive.jp/start/install/index6.html)を参考に「Set JAVA_HOME variable」を有効にしてインストールします\n * IntelliJ IDEA Community Edition はリリース版で最新の 2020.3.2を使いました。\n\n * [スタンドアロンインストール](https://pleiades.io/help/idea/installation-guide.html#standalone)時のオプションで32bit関連オプション以外は以下のように全てチェックを入れています。 \n * 64-bit launcher\n * Add launchars dir to PATH\n * Add *Open Folder as Project*\n * Create Associations の拡張子4つ全て\n * [Forge](https://files.minecraftforge.net/)のFilesからは、最新の 1.16.5 の Download Latest の mdk を使いました。\n\n * .zipファイルはC:\\Develop\\forge-1.16.5-36.0.10-mdkに展開しました\n * IntelliJ IDEAで展開したプロジェクトのフォルダを指定してOpenすると、初回は環境設定のダウンロード等で20分程度時間がかかります。\n\n * 上記「環境構築 (1.14.4)」の「Forge」の 5. から 11. の手順で(ダウンロード中のログの一部に文字化けが発生しているように見える以外は)問題無く動作しています。\n * ちなみに`forge-1.16.4-35.1.4-mdk`とか`forge-1.14.4-28.2.0-mdk`だと`runClient`でゲームの画面は出て音とか表示は行われますが、IntelliJ IDEAのログ表示部分に`Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://myurl.me/`のエラーが表示されます。\n\n* * *\n\n上記からすると、環境変数の`JAVA_HOME`か`PATH`の設定有無や内容あたりが影響している可能性があります。 \n調べるか試してみるかしてみてください。\n\n* * *\n\n**追記4に関して**\n\nそのエラーメッセージは、OpenGLのAPIが無効であるという物でしょう。 \n本当にOpenGLが無いのは考えにくいので、版数が古いとか、何かミスマッチがあるとかでしょうか。\n\n検索するとこの辺が見つかりますが、これらにヒントがあるかは不明です。 \n[[1.15.2] GLFW_API_UNAVAILABLE error\n(intellij)](https://forums.minecraftforge.net/topic/86274-1152-glfw_api_unavailable-\nerror-intellij/) \n[Can't open a window in netbeans with\nLWJGL](https://stackoverflow.com/q/46635283/9014308) \n[some minecraft installs not working under windows 10\n#119](https://github.com/LWJGL/lwjgl/issues/119) \n[LWJGL 3 does not detect\nOpenGL](http://forum.lwjgl.org/index.php?topic=6296.0) \n[LWJGL won't work outside\nNetBeans](https://stackoverflow.com/q/33502482/9014308)\n\n言わずもがなですが、以下のようなことでドライバ等を最新に更新したか確認してみてください。\n\n * Windows UpdateでOS/デバイスドライバ/アプリケーション等が全て最新に更新されているか\n * PCのベンダーが提供しているBIOS/ファームウェア/デバイスドライバの更新が全て適用されているか\n * CPUがIntelならば、[インテル® ドライバー & サポート・アシスタント](https://downloadcenter.intel.com/ja/download/28425/-) でインテル関連ドライバが全て更新されているか\n * GPUがNVidia/AMDならば、それぞれのデバイスドライバが最新のものに更新されているか\n * Javaのランタイム環境が複数インストールされていないか(複数あったら、今回使う1つだけ残してあとはアンインストールしてみる&使うランタイムは修復インストールとか再インストールしてみる)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-30T10:15:03.343",
"id": "73698",
"last_activity_date": "2021-01-31T15:10:52.863",
"last_edit_date": "2021-01-31T15:10:52.863",
"last_editor_user_id": "26370",
"owner_user_id": "26370",
"parent_id": "73585",
"post_type": "answer",
"score": 1
}
] | 73585 | null | 73698 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "WordPress に \"Contact Form 7\" と \"CF7 Google Sheet Connector\" を入れ、Contact Form\n7からの入力をGoogleスプレッドシートの『シート1』の一番下へと追記するようにしております。\n\nここで、Contact Form 7のprefの項目へとユーザー様の都道府県を入力頂いて、それを『シート2』 \nの都道府県vs担当者メアド対応表についてVLOOKUPをつかって検索し、メールを投げたいと思って \nおります。 \nContact Form 7でadminに送られてきますメールではなく、各都道府県の担当者へ別途指示を出しますメールを作成したいです。\n\nそこで、以下のコードを書きましたが上手く動いてくれません。\n\nGoogleフォームを使用しておりませんので、トリガーを\n\nイベントのソースを選択 : スプレッドシートから \nイベントの種類を選択 : フォーム送信時\n\nとしておりますが、1回も実行されておりません。\n\nまた、トリガーと別にデバッグをしますと、以下のエラーが出ます。\n\n```\n\n TypeError: Cannot read property 'response' of undefined\n sendform @ コード.gs:4\n \n```\n\n'response'のスペルを何度も確認しましたがミスは無さそうで、フラグと合わせてダブルパンチで困っております。\n\nこの手のプログラムは初めてで、ネット検索しながらコピペで使用しておりますので、素人を助けてくださいますかたお願いいたします。\n\n* * *\n```\n\n // FormApp.getActiveForm()\n \n function sendform(e) {\n var items = e.response.getItemResponses();\n for (var i = 0; i < items.length; i++) {\n var item = items[i];\n var q = item.getItem().getTitle();\n if ( q === \"pref\" ) {\n var a = item.getResponse();\n var mail_address = VLOOKUP(a,importrange(\"https://docs.google.com/spreadsheets/d/xxxxxxxx-xx--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/\",\"シート2!$A$1:$D$48\"),3,FALSE) ;\n var message = VLOOKUP(a,importrange(\"https://docs.google.com/spreadsheets/d/xxxxxxxx-xx--xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/\",\"シート2!$A$1:$D$48\"),4,FALSE) + 'にお住まいのお客様からの依頼です\\n\\n' ;\n \n GmailApp.sendEmail(mail_address, 'お問い合わせがありました', message);\n \n }\n }\n }\n \n```\n\n**シート2**\n\n```\n\n A B C D\n 北海道 〇〇株式会社 [email protected] 北海道(←メッセージは後から変更しますが、取り敢えず都道府県を入れております)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T07:36:45.973",
"favorite_count": 0,
"id": "73588",
"last_activity_date": "2021-12-25T09:05:45.437",
"last_edit_date": "2021-01-26T12:05:00.707",
"last_editor_user_id": "3060",
"owner_user_id": "43684",
"post_type": "question",
"score": 0,
"tags": [
"google-apps-script"
],
"title": "Googleスプレッドシートにフォームから追記されたらメールを送信したい",
"view_count": 2279
} | [
{
"body": "自己レスですが、\n\n```\n\n function sendform(e) {\n \n```\n\nで持ってくることが出来なかったので\n\n```\n\n function sendform() {\n var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();\n var sheet = spreadsheet.getSheets()[0];\n var lastRow = sheet.getRange(sheet.getMaxRows(), 1).getNextDataCell(SpreadsheetApp.Direction.UP).getRow();\n \n var range = sheet.getRange(lastRow, 1, lastRow ,12);\n var currentRangeValues = range.getValues();\n \n```\n\nとして、トリガーを\n\nイベントのソースを選択: スプレッドシートから \nイベントの種類を選択 : 変更時\n\nとしましてなんとか…",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-28T06:29:11.223",
"id": "73632",
"last_activity_date": "2021-01-28T06:42:48.120",
"last_edit_date": "2021-01-28T06:42:48.120",
"last_editor_user_id": "3060",
"owner_user_id": "43684",
"parent_id": "73588",
"post_type": "answer",
"score": 1
}
] | 73588 | null | 73632 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Laravle7で、コンポーネントによる共通表示部分の出力において、 \nコンポーネント表示部分の前後に余分な空白が入ってしまいます。\n\napp/Views/Components/SiteTitle.php\n\n```\n\n class SiteTitle extends Component\n {\n \n public $title;\n \n /**\n * Create a new component instance.\n *\n * @return void\n */\n public function __construct()\n {\n $this->title = 'タイトル';\n }\n \n /**\n * Get the view / contents that represent the component.\n *\n * @return \\Illuminate\\View\\View|string\n */\n public function render()\n {\n return view('components.site-title');\n }\n }\n \n```\n\nresources/views/components/site-title.blade.php\n\n```\n\n {{$title}}\n \n```\n\n表示するblade\n\n```\n\n <title><x-site-title/></title>\n \n```\n\n簡略化していますが、このような構成でx-site-title部分に \nタイトルと表示してほしいのですが、\n\n```\n\n <title> タイトル </title>\n \n```\n\nのように、「タイトル」の前後に空白が表示されます。\n\nこの解決法を知っている方いらっしゃいますでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T11:07:38.250",
"favorite_count": 0,
"id": "73590",
"last_activity_date": "2021-02-05T03:12:51.110",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "14234",
"post_type": "question",
"score": 0,
"tags": [
"laravel"
],
"title": "Laravelのコンポーネントで空白が出力される",
"view_count": 204
} | [
{
"body": "解決しなかったので、同じような機能をヘルパーで実装できたのでそちらで対応しました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-02-05T03:12:51.110",
"id": "73811",
"last_activity_date": "2021-02-05T03:12:51.110",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "14234",
"parent_id": "73590",
"post_type": "answer",
"score": 0
}
] | 73590 | null | 73811 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "以下のような環境で作業をしております。 \n外付けGPUに接続しているディスプレイを変更したら、出力できなくなりました。 \n切り分け確認をしましたが、なにが原因かわからずにおります。。 \n具体的な方法をご存知の方がいれば、助言いただきたいです!\n\n* * *\n\n本体:mac mini(2018) \n外付けGPU:Razer Code XにRadeon RX580搭載 \nディスプレイ1:PHILIPS製1080p \nディスプレイ2:DMM.make製4K \nディスプレイ3,4:PHILIPS製1080p \n・Mac miniとeGPUは付属のthunderboltで接続 \n・Mac miniとディスプレイ1をHDMIで接続->使用可○ \n<変更前> \n・eGPUとディスプレイ3,4をHDMIでデュアル接続->使用可○ \n<変更後> \n・eGPUとディスプレイ2をHDMIで接続->使用不可× \n●eGPUはMacが推奨している組み合わせのものです。 \n●eGPUは4K出力に対応しています。\n\n* * *\n\n<確認したこと> \n・Mac miniとディスプレイ2をHDMIで接続->使用可○ \n・eGPUとディスプレイ1をHDMIで接続->使用可○ \n・ディスプレイ2のHDMIケーブルのポートを変更->使用不可×",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-26T20:54:32.503",
"favorite_count": 0,
"id": "73592",
"last_activity_date": "2021-01-26T20:54:32.503",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15491",
"post_type": "question",
"score": 0,
"tags": [
"gpu"
],
"title": "外付けGPU(eGPU)から出力できないディスプレイの解決方法",
"view_count": 194
} | [] | 73592 | null | null |
{
"accepted_answer_id": "73598",
"answer_count": 2,
"body": "数値データが格納されているリスト`l = [4, 8, 1, 2, 9, 0]`に対して,元のインデックスと紐付けた状態で小さい順にソートしたいです. \nインデックスを取得するためにenumerateを用いて以下のようにしました.\n\n```\n\n data=[]\n for idx, value in enumerate(l):\n data.append([idx, value]) # [[0, 4], [1, 8], [2, 1], [3, 2], [4, 9], [5, 0]]\n \n```\n\n`data[i][0]`にインデックス値,`data[i][1]`に数値データが入っている状態です.この状態から,数値データを小さい順にソートしたいのですが,どうすればいいかわからず困っています. \nこの例での期待する出力は,`[[5, 0], [2, 1], [3, 2], [0, 4], [1, 8], [4, 9]]`となります. \nどなたかわかる方がいらっしゃいましたらご回答よろしくお願いします",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T05:38:39.427",
"favorite_count": 0,
"id": "73595",
"last_activity_date": "2021-01-27T06:52:24.393",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36832",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3"
],
"title": "enumerateで取得した値でソートする方法",
"view_count": 390
} | [
{
"body": "Sort関数のキー情報にソート対象のインデックス値を指定するラムダ式を記述します。 \n[参考](https://note.nkmk.me/python-list-2d-sort/#2_1)\n\n```\n\n data = [[0, 4], [1, 8], [2, 1], [3, 2], [4, 9], [5, 0]]\n sorted(data, key=lambda x: x[1])\n # [[5, 0], [2, 1], [3, 2], [0, 4], [1, 8], [4, 9]]\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T05:54:35.253",
"id": "73596",
"last_activity_date": "2021-01-27T05:54:35.253",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "73595",
"post_type": "answer",
"score": 1
},
{
"body": "中身が tuple でもよいのであれば以下の様に、\n\n```\n\n l = [4, 8, 1, 2, 9, 0]\n list(sorted(enumerate(l), key=lambda x: x[1]))\n =>\n [(5, 0), (2, 1), (3, 2), (0, 4), (1, 8), (4, 9)]\n \n```\n\nどうしても list で、という場合には\n\n```\n\n list(map(list, sorted(enumerate(l), key=lambda x: x[1])))\n =>\n [[5, 0], [2, 1], [3, 2], [0, 4], [1, 8], [4, 9]]\n \n```\n\nとしてもよろしいかと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T06:52:24.393",
"id": "73598",
"last_activity_date": "2021-01-27T06:52:24.393",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "73595",
"post_type": "answer",
"score": 2
}
] | 73595 | 73598 | 73598 |
{
"accepted_answer_id": "73599",
"answer_count": 1,
"body": "<https://stackoverflow.com/a/56450675/1979953> を参考に\n\nコード参考サイトほぼそのまま:\n\n```\n\n import SwiftUI\n \n struct ContentView: View {\n @State var text: String = \"\"\n \n var body: some View {\n HStack {\n TextField($text,\n placeholder: Text(\"type something here...\"))\n Button(action: {\n // Closure will be called once user taps your button\n print(self.$text)\n }) {\n Text(\"SEND\")\n }\n }\n }\n }\n \n struct ContentView_Previews: PreviewProvider {\n static var previews: some View {\n ContentView()\n }\n }\n \n```\n\nとしました。\n\n```\n\n Initializer 'init(_:text:onEditingChanged:onCommit:)' requires that 'Binding<String>' conform to 'StringProtocol'\n \n```\n\nというエラーと\n\n```\n\n Extra argument 'placeholder' in call\n \n```\n\nが出ます。\n\nなにかSwiftのバージョンによる違いでしょうか? それとも何か他に設定しないといけないことがありますでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T06:18:18.100",
"favorite_count": 0,
"id": "73597",
"last_activity_date": "2021-01-27T07:04:36.057",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9008",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"swiftui"
],
"title": "Initializer 'init(_:text:onEditingChanged:onCommit:)' requires that 'Binding<String>' conform to 'StringProtocol' が起こる",
"view_count": 1018
} | [
{
"body": "> なにかSwiftのバージョンによる違いでしょうか?\n\n参考記事はタイムスタンプから見て、WWDC\n2019で最初のSwiftUIが発表された直後の記事、つまりβ版のSwiftUIを元に書かれたもののようです。おそらくβ版では`TextField`のイニシャライザの引数のデータ型や順番が正式版とは異なっていたのでしょう。\n\n現在のSwiftUIに基づいて書くと次のようになります。\n\n```\n\n struct ContentView: View {\n @State var text: String = \"\"\n \n var body: some View {\n HStack {\n //# Placeholder文字列が先、textへのBindingが後\n TextField(\"type something here...\", text: $text)\n Button(action: {\n // Closure will be called once user taps your button\n print(self.$text)\n }) {\n Text(\"SEND\")\n }\n }\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T07:04:36.057",
"id": "73599",
"last_activity_date": "2021-01-27T07:04:36.057",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "73597",
"post_type": "answer",
"score": 2
}
] | 73597 | 73599 | 73599 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "スパイダーでまわしているプログラムをGoogleColaboraturyで使おうと思ったのですが、エラーがでてしまいます。\n\n```\n\n import numpy as np\n import tensorflow as tf\n from tensorflow.keras.models import Sequential\n from keras.layers.core import Dense, Activation\n from keras.layers.recurrent import LSTM\n from tensorflow.keras.optimizers import Adam\n from sklearn.model_selection import train_test_split\n data = []\n data1 = []\n data2 = []\n target = []\n kairi = []\n jyousyou = []\n maxlen = 60\n day1 = []\n day2 = []\n day3 = []\n owarine = []\n ・\n ・\n ・\n ・\n ・\n \n '''\n モデル設定\n '''\n n_in = len(X[0][0]) \n n_hidden = 100\n n_out = len(Y[0]) \n def weight_variable(shape, name=None):\n return np.random.normal(scale=.01, size=shape)\n model = Sequential()\n model.add(LSTM(n_hidden,\n kernel_initializer=\"random_uniform\",\n input_shape=(maxlen, n_in)))\n model.add(Dense(n_hidden, kernel_initializer=\"random_uniform\"))\n model.add(Activation('sigmoid'))\n model.add(Dense(n_out, kernel_initializer=\"random_uniform\"))\n model.add(Activation('sigmoid'))\n optimizer = Adam(lr=0.001, beta_1=0.9, beta_2=0.999)\n model.compile(loss='mean_squared_error',\n optimizer=optimizer)\n \n \n '''\n モデル学習\n '''\n epochs = 500\n batch_size = 1000\n model.fit(X_train, Y_train,\n batch_size=batch_size,\n epochs=epochs,\n validation_split = 0.25)\n \n '''\n 学習はここまで\n ''' \n \n```\n\nこれのmodel.fitの部分のようです。 \nエラーメッセージは以下です。\n\nUnimplementedError Traceback (most recent call last) \nin () \n173 batch_size=batch_size, \n174 epochs=epochs, \n\\--> 175 validation_split = 0.25)\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T07:36:04.587",
"favorite_count": 0,
"id": "73600",
"last_activity_date": "2021-02-08T16:31:28.973",
"last_edit_date": "2021-01-27T08:03:42.017",
"last_editor_user_id": "43696",
"owner_user_id": "43696",
"post_type": "question",
"score": 0,
"tags": [
"python",
"tensorflow",
"keras",
"google-colaboratory"
],
"title": "kerasを用いた学習用プログラムをGoogle Colaboratory で使いたい",
"view_count": 216
} | [
{
"body": "以下で試したところ、Google colab(ランタイムタイプ:GPU, Python version 3.6.9, Keras version\n2.4.3)で動かすことができました。 \n以下のXとYのサイズは適当においてしまったのですが、正しいでしょうか?もし正しければ、私の環境では動いたので、開発環境によるものかもしれないと思いました。\n\n```\n\n '''\n モデル設定\n '''\n \n '''\n ※ 動作確認のため、以下2行 追加\n '''\n X = np.random.random([700,60,200])\n Y = np.random.random([700,100])\n \n n_in = len(X[0][0]) \n n_hidden = 100\n n_out = len(Y[0]) \n def weight_variable(shape, name=None):\n return np.random.normal(scale=.01, size=shape)\n \n model = Sequential()\n model.add(LSTM(n_hidden,\n kernel_initializer=\"random_uniform\",\n input_shape=(maxlen, n_in)))\n model.add(Dense(n_hidden, kernel_initializer=\"random_uniform\"))\n model.add(Activation('sigmoid'))\n model.add(Dense(n_out, kernel_initializer=\"random_uniform\"))\n model.add(Activation('sigmoid'))\n optimizer = Adam(lr=0.001, beta_1=0.9, beta_2=0.999)\n model.compile(loss='mean_squared_error',\n optimizer=optimizer)\n \n '''\n ※ 動作確認のため、以下2行 追加\n '''\n X_train = np.random.random([700,60,200])\n Y_train = np.random.random([700,100])\n \n '''\n モデル学習\n '''\n epochs = 500\n batch_size = 1000\n model.fit(X_train, Y_train,\n batch_size=batch_size,\n epochs=epochs,\n validation_split = 0.25)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-02-08T16:07:04.567",
"id": "73872",
"last_activity_date": "2021-02-08T16:31:28.973",
"last_edit_date": "2021-02-08T16:31:28.973",
"last_editor_user_id": "3060",
"owner_user_id": "30785",
"parent_id": "73600",
"post_type": "answer",
"score": 0
}
] | 73600 | null | 73872 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "プログラミング初心者です。 \nモーダルの画像にプラスマイナスのボタンをつけて拡大縮小したいです。 \n調べたところviewer.jsなどのプラグインを導入するとできそうなのですがやり方がわかりません。 \n教えていただける方いましたら \nよろしくお願いいたします。 \njquery3.3.1\n\n[html]\n\n```\n\n <div>\n <img class=\"img-thumbnail\" src=\"ThumbnailUri\" data-path=\"OriginalUri\" data-toggle=\"modal\" data-target=\"#image-modal\" id=\"image-x-y\" data-rotate=\"Lotate\" style=\"cursor: pointer;\"/>\n </div>\n \n \n <div class=\"modal fade\" id=\"image-modal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myLargeModalLabel\">\n <div class=\"modal-dialog modal-middle\" id=\"modal-style\">\n \n <div class=\"modal-content\">\n <div class=\"modal-body\">\n <img src=\"\" alt=\"\" class=\"img-responsive center-block\" id=\"modal-photo-box\" />\n <input type=\"hidden\" name=\"org-width\" id=\"org-width\" value=\"\" />\n <input type=\"hidden\" name=\"org-height\" id=\"org-height\" value=\"\" />\n </div>\n </div>\n </div>\n </div>\n \n```\n\n[jquery]\n\n```\n\n $(\".container\").on('click', '#image-modal', function (event) { })\n .on('show.bs.modal', function (event) {\n var target = event.relatedTarget.id;\n \n var rotate = $('#' + target).attr('data-rotate');\n if (rotate === \"0\") {\n $(\"#modal-style\").attr(\"style\", \"width:1000px;\");\n } else {\n $(\"#modal-style\").removeAttr(\"style\");\n }\n \n var val = $('#' + target).attr('data-path');\n \n if (val === \"\") return false;\n \n $(\"#modal-photo-box\").attr('src', val);\n \n \n }).on('hidden.bs.modal.bs.modal', function (event) {\n $(\"#modal-photo-box\").attr('src', \"\");\n });\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T07:45:14.487",
"favorite_count": 0,
"id": "73601",
"last_activity_date": "2021-01-27T08:34:45.707",
"last_edit_date": "2021-01-27T08:34:45.707",
"last_editor_user_id": "22665",
"owner_user_id": "42115",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery",
"bootstrap"
],
"title": "jquery3.3.1でのモーダル画像にプラスマイナスボタンをつけて拡大縮小を行いたい",
"view_count": 194
} | [] | 73601 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "WindowsFormアプリケーションのMonthCalendarの初期表示を \n下図のように月表示にし、月を選択しても日のカレンダーを表示しないようにしたいと考えています。\n\n[](https://i.stack.imgur.com/GCHwW.png)\n\nXAMLのCalendar.DisplayModeを「CalendarMode.Year」にしたような表示をイメージしています。\n\nよろしくお願いします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T08:05:04.287",
"favorite_count": 0,
"id": "73602",
"last_activity_date": "2021-01-27T08:05:04.287",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19580",
"post_type": "question",
"score": 0,
"tags": [
"c#"
],
"title": "MonthCalendarを年、月の表示のみで日を非表示にしたい",
"view_count": 999
} | [] | 73602 | null | null |
{
"accepted_answer_id": "73626",
"answer_count": 1,
"body": "フォームを作成しているんですが、送信ボタンが2回押された場合、2つ登録されないか見た方がよい。との記述をみたので、やってみたいと思っています。 \nf12押下→sources→でjsファイルを見てたんですが、何を基準にどこでブレークポイントを置けば多重確認ができますか? \n何をしてどの時点でどういう結果がかえってくるのがこのテストの内容なんでしょうか?\n\n追記 \n失礼しました。 \n実装内容は \n・リフレッシュトークンとPOSTトークンの照合チェックです。 \nその後最後にセッション削除しています。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-27T08:29:20.333",
"favorite_count": 0,
"id": "73603",
"last_activity_date": "2021-01-28T04:10:19.317",
"last_edit_date": "2021-01-27T09:19:06.483",
"last_editor_user_id": "41150",
"owner_user_id": "41150",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"php"
],
"title": "devtoolsで多重送信されてないか確認したい。",
"view_count": 58
} | [
{
"body": "フロントエンドの多重投稿テストの説明をしましたが、追記をみるとサーバサイド実装のテストのようです。 \nなのでフロントエンドでChromeブラウザの開発者ツールでテストは合わない可能性があります。 \nサーバサイドでのテストを改めて説明します。\n\nまずテスト項目の定義をしましょう。\n\nフォームのテスト項目を定義するとすれば \n「クリックの誤操作や何らかの原因でリクエストが多重に走ることに伴う多投稿ができないか?」\n\nサーバサイド側から書くならば \n「クライアントからのPOSTリクエストを多重かつ連続して受け入れることを拒否しているか?」\n\nさらに専門的にいうと \n「POSTリクエストが排他制御されているか?」 \nということになります。\n\nこれはなぜ問題かというと \n例えば、POSTによって決済を実行するような動作がある場合には \n間違ってクライアントがブラウザで2回ボタンを押してしまい、かつアプリケーションが2回連続で受け入れる可能性がある実装になっていた場合、通常は1回の決済処理が走るべきところが2回走ってしまいます。\n\nテスト項目について理解できたら \n次にテストの必要性を考えましょう。\n\n今回のアプリケーションについては排他制御の必要性はありますか?このPOSTリクエストは多重で走っても問題ないですか?もし多重で投稿されてもプロダクトやプロジェクトのリスクとして許容されるものですか?\n\nすべてのフォームに排他制御は入れる必要はないと思っています。 \n例えば、企業の問い合わせフォームは2回送信されたところで、データの削除すれば問題なしが多いと思います。 \n運用でカバーできるor運用でコストが支払えるという判断ができれば、このテストは必要ありません。 \nこれについては外部から提案できるものではなく、プロダクトオーナーやプロジェクトマネージャーによる判断が必要な場合もあります。よく検討してみてください。\n\nもし排他制御が必要で実装しあり、さらにテストしなければならないとなった時は、 \n全く同じ状態でPOSTを複数送信できるようにテストを組み立てる必要があります。 \nテスト方法の検討です。\n\n今回はセッションを利用しているようですので、同じブラウザ内(例えばタブ等)で複数フォームを開き、同じ条件で同時に送信ボタンを押してみるというのがテストの方法になります。\n\nここでいう「同じ条件」は定義が難しいのですが、 \nわかりやすい例としてECシステムにおける、カートを想像してみてください。 \nECの購入時のフォーム送信で排他制御のテストをする場合は、カートに商品を入れた状態で複数のタブを開き同時に購入ボタンを押すことになります。 \n同じ条件というのがカートに商品を入れた状態になります。 \n排他制御を入れている場合は同時に送信されてもどちらからのリクエストは必ず弾かれるはずです。\n\n「同じ条件」にするためには、アプリケーションによって方法が変わります。 \n仕様ごとにテスト方法を検討してみてください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-01-28T04:10:19.317",
"id": "73626",
"last_activity_date": "2021-01-28T04:10:19.317",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22665",
"parent_id": "73603",
"post_type": "answer",
"score": 0
}
] | 73603 | 73626 | 73626 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.