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": "有効フラグ、削除フラグなどのフラグ項目に NOT NULL 制約を付与しないDB設計をよく見かけます。「仕様上は 0 と NULL\nは同じ意味で扱ってください」と指示されるのですが、NOT NULL 制約(とデフォルト値)を付与することに何らかのデメリットがあるのでしょうか。\n\nフラグ項目に限らず一般的に、 NULL を格納する必要のない項目に NOT NULL 制約を付与することで生じるデメリットは何かあるでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-03T07:44:01.637", "favorite_count": 0, "id": "51677", "last_activity_date": "2019-01-03T09:06:18.227", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3925", "post_type": "question", "score": 5, "tags": [ "database", "データベース設計" ], "title": "フラグ項目に NOT NULL 制約を付与しない理由", "view_count": 5358 }
[ { "body": "開発者の経験上、 **NULL を格納する必要のない項目には NOT NULL 制約を付与する方がメリットが多い** と感じています。\n\nご質問は[SQLアンチパターン](https://www.oreilly.co.jp/books/9784873115894/)で言う所の「フィア・オブ・ジ・アンノウン(恐怖のunknown)」に通じる内容ですね。\n\n(手元に資料がないのでうろ覚えですが)フィア・オブ・ジ・アンノウンでは、NULLが必要な項目にNOT\nNULL制約を入れるアンチパターンについて言及していたはずです。 \n例えば`男性=1` `女性=2`のカラムに`未入力=unknown`を設定していたところ、ある日入力欄に「不詳」が追加されて`不詳=unknown`\n`未入力=null`にする設計変更が入ったため、本番環境のデータ更新を余儀なくされるケースなど、ひと手間かかるアンチパターンです。\n\n別のアンチパターンとして、NOT NULL制約が必要なカラムに制約を設けていないことも挙げられます。 \n有効フラグが立っていないレコードを検索する際に、NULLと'0'が混在している場合は`ENABLE_FLG NOT in\n('1')`で正しい結果が取得できないアンチパターンもあります。\n\n上記資料の結論は、NULLの特性を理解して適切に使いなさい、必要ならNOT NULL制約でアンチパターンを回避しなさいというものだったと記憶しています。\n\nなおNOT NULL 制約を付与するデメリットについては、若干insertなどの操作が遅くなることを主張する人もいるかもしれません。 \n[検証記事](http://kagamihoge.hatenablog.com/entry/20130513/1368449162)によると、Oracleで100万件のデータをinsertした場合に約0.6%速度が低下するようです。 \n現実の運用では無視できる速度差でしょう。\n\n * NOT NULL制約なし - 172.411秒\n * NOT NULL制約あり - 173.474秒\n\nフラグ項目にNOT NULL 制約を付与しない設計をする主な理由は下記の例が多く感じます。\n\n * フレームワークの共通ファンクションでinsertすれば必ずフラグを登録するから制約は速度低下にしかならない\n * 有効フラグは`ENABLE_FLG = '1'`で検索するだけだから、それ以外は何でも良い \n * 正常系の処理では論理削除されたものを検索しないので事故にならないという発想\n * テストデータ作る時に制約は邪魔だから消したい \n * テストデータを論理削除するときに削除フラグをnullでupdateして放置という恐ろしいテスターも…\n * 単純に制約付け忘れ / 制約?なにそれおいしいの?\n\nいずれにせよ必要な制約を付与しないことは、テーブル設計の意図がテーブルの実体に反映されていない状態であり、作曲家がフォルテピアノなどの強弱記号を楽譜に書いていない状態に似ています。 \n開発者や演奏者が好き勝手に解釈をする環境よりも、制約によって不当な処理はできない環境の方が健全ではないでしょうか。\n\n※ 新人やインフラチームが「良く分からないから制約消しました!」という悲劇は防げませんが、これは情報共有や体制の話なので回答には含めません", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-03T09:06:18.227", "id": "51678", "last_activity_date": "2019-01-03T09:06:18.227", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "51677", "post_type": "answer", "score": 8 } ]
51677
null
51678
{ "accepted_answer_id": null, "answer_count": 2, "body": "はじめまして。 \nLaTeXでタイトルと概要を出力する際、\n\n```\n\n \\author{木下\\thanks{京都大学} \\and ベーテ\\thanks{東京大学} \\and ガモフ\\thanks{京都大学}}\n \n```\n\nとしたら、 \nタイトルの下に「木下*、ベーテ+、ガモフ¥」のように現れ、脚注に「*京都大学、+東京大学、¥京都大学」と現れます。 \nこれをタイトルの下に「木下*、ベーテ+、ガモフ*」、脚注に「*京都大学、+東京大学」と現すにはどうしたらよいでしょうか。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-03T09:08:51.800", "favorite_count": 0, "id": "51679", "last_activity_date": "2019-10-07T06:37:16.730", "last_edit_date": "2019-01-03T23:49:15.027", "last_editor_user_id": "19110", "owner_user_id": "31653", "post_type": "question", "score": 2, "tags": [ "latex" ], "title": "LaTeXタイトルで複数著者がいて、数人が同じ所属の場合の書き方", "view_count": 15430 }
[ { "body": "LaTeX\n文書クラスによっては(特に学会やジャーナル提供のものなど)複数人の所属組織を記述しやすくするコマンドがデフォルトで提供されている場合があるのですが,jsarticle\nクラスにはそのような機能はなさそうなので,外部パッケージを利用するのが早いと思います.\n\n例えば authblk パッケージは,ちょうど「複数著者のうち,数人が同じ組織に所属する」ようなケースにもうまく対応できるようです.\n\n```\n\n \\documentclass{jsarticle}\n \\usepackage{authblk}\n \n % タイトル\n \\title{テスト文書}\n \n % 著者名\n \\author[1]{国立太郎}\n \\author[2]{私立一郎}\n \\author[1]{国立次郎}\n \n % 所属\n \\affil[1]{某国立大学}\n \\affil[2]{某私立大学}\n \n % 日本語対応\n \\renewcommand\\Authsep{\\qquad}\n \\renewcommand\\Authand{\\qquad}\n \\renewcommand\\Authands{\\qquad}\n \n \\begin{document}\n \\maketitle\n \\end{document}\n \n```\n\nただし,デフォルト設定だと「国立太郎, 私立一郎, and 国立次郎」のような表示になってしまい,日本語文書にはそぐわないので,\n\n```\n\n % 日本語対応\n \\renewcommand\\Authsep{\\qquad}\n \\renewcommand\\Authand{\\qquad}\n \\renewcommand\\Authands{\\qquad}\n \n```\n\nの箇所でセパレータ(区切り)を変更しています.ここのあたりは,適宜変更してお使いになればよろしいかと思います.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T04:40:49.913", "id": "51747", "last_activity_date": "2019-01-06T04:40:49.913", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27047", "parent_id": "51679", "post_type": "answer", "score": 3 }, { "body": "同じ所属の著者が2人以上いる場合、2人目以降は\\thanksを使用せず、\\footnotemark[番号]で直接脚注番号を入力すれば可能だと思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-10-07T06:37:16.730", "id": "59527", "last_activity_date": "2019-10-07T06:37:16.730", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "36108", "parent_id": "51679", "post_type": "answer", "score": 0 } ]
51679
null
51747
{ "accepted_answer_id": null, "answer_count": 1, "body": "■前置き \nWPFにてButtonの外観をカスタマイズするため、ControlTemplateを以下のように書き換えました。 \n(コメント「<\\--コントロールテンプレートを書き換えたボタン -->」以下の部分です) \nまた、後述する問題を分かりやすくするため、Grid全体を覆うように背景色が真っ赤なBorderコントロールを配置し、その上にボタンを配置しています。\n\n```\n\n <Grid>\n <Grid.RowDefinitions>\n <RowDefinition/>\n <RowDefinition/>\n </Grid.RowDefinitions>\n <Grid.ColumnDefinitions>\n <ColumnDefinition/>\n <ColumnDefinition/>\n </Grid.ColumnDefinitions>\n \n <Border Background=\"Red\" Grid.ColumnSpan=\"2\" Grid.RowSpan=\"2\"/>\n \n <!--標準ボタン-->\n <Button Grid.Row=\"0\" Name=\"NormalLeft\">1</Button>\n <Button Grid.Row=\"0\" Grid.Column=\"1\" Name=\"NormalRight\">2</Button>\n \n <!--コントロールテンプレートを書き換えたボタン-->\n <Button Grid.Row=\"1\" Content=\"ひだりボタン\" Name=\"ArrangeLeft\">\n <Button.Template>\n <ControlTemplate TargetType=\"Button\">\n <Border Name=\"borderleft\"\n BorderThickness=\"1\"\n BorderBrush=\"Black\"\n Background=\"Green\">\n <ContentPresenter VerticalAlignment=\"Center\"\n HorizontalAlignment=\"Center\" />\n </Border>\n </ControlTemplate>\n </Button.Template>\n </Button>\n \n <Button Grid.Row=\"1\" Grid.Column=\"1\" Content=\"みぎボタン\" Name=\"ArrangeRight\">\n <Button.Template>\n <ControlTemplate TargetType=\"Button\">\n <Border Name=\"borderright\"\n BorderThickness=\"1\"\n BorderBrush=\"Black\"\n Background=\"Green\">\n <ContentPresenter VerticalAlignment=\"Center\"\n HorizontalAlignment=\"Center\" />\n </Border>\n </ControlTemplate>\n </Button.Template>\n </Button>\n </Grid>\n \n```\n\n■問題 \n書き換えたボタンを二つ並べた際に、ボタンとボタンに微妙に隙間が出来てしまうようです。 \n初期表示時は問題ないのですが、Windowの枠をドラッグしてぐいっと引き伸ばすと、なぜかボタンとボタンに隙間ができてしまい、後ろにあるボーダーコントロールの真っ赤な色が透けてしまいます。 \n(以下の添付画像を参照ください。)\n\n<初期表示> \n[![初期表示](https://i.stack.imgur.com/LV4Xp.png)](https://i.stack.imgur.com/LV4Xp.png)\n\n<Windowサイズ変更後> \n赤色が透けている \n[![サイズ調整後](https://i.stack.imgur.com/Cauw6.png)](https://i.stack.imgur.com/Cauw6.png)\n\n■聞きたいこと \nWPF標準のボタンのように、Windowを引き延ばしてもボタンとボタンの間が見えないようにしたいのですが、どのようにすればよいでしょうか。\n\n■動作環境 \n.NET Framework 4.6.1 \nVisual Studio Community 2017 \nWindows 8.1", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-03T13:29:40.860", "favorite_count": 0, "id": "51682", "last_activity_date": "2019-08-13T19:03:20.367", "last_edit_date": "2019-01-03T13:32:46.587", "last_editor_user_id": "2238", "owner_user_id": "31655", "post_type": "question", "score": 1, "tags": [ "c#", "visual-studio", ".net", "wpf" ], "title": "ButtonコントロールのControlTemplateを変更した際の画面のちらつきの原因が知りたい", "view_count": 267 }
[ { "body": "サイズ変更でコントロールの相対位置が変わり、サイズの丸め処理で1ピクセルの隙間ができることが原因と思われます。 \n[本家SOの類似質問](https://stackoverflow.com/q/1880506)\n\nその場合、LayoutRoot(一番外側のGrid)の[UseLayoutRounding](https://docs.microsoft.com/ja-\njp/dotnet/api/system.windows.frameworkelement.uselayoutrounding?view=netframework-4.8#System_Windows_FrameworkElement_UseLayoutRounding)を`true`にすると問題解決するでしょう。 \n`<Grid UseLayoutRounding=\"True\">`\n\n.Net\n4よりも前のバージョンには`UseLayoutRounding`がないので、[SnapsToDevicePixels](https://docs.microsoft.com/ja-\njp/dotnet/api/system.windows.uielement.snapstodevicepixels?view=netframework-4.8#System_Windows_UIElement_SnapsToDevicePixels)で代用します。\n\nどちらも描画をボケないように描画や配置するプロパティです。 \n使用例や違いは上記のリンクや[@ITの記事](http://www.atmarkit.co.jp/ait/articles/1602/17/news034.html)を参考にしてみてください。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T05:54:54.467", "id": "51690", "last_activity_date": "2019-01-04T05:54:54.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "51682", "post_type": "answer", "score": 1 } ]
51682
null
51690
{ "accepted_answer_id": null, "answer_count": 1, "body": "初心者のため,質問の仕方が判りにくかったら申し訳ありません.\n\nPython3で行列を作成し,inputの結果によって行列内の要素を置換するコードを書こうとしています.\n\n図中のbasic_matrixで任意の要素数の行列を作成するまでは出来たのですが,行列内の要素全てについてinputで「\"関係性がある(1)か,ない(0)か\"」を入力させ,その値をbasic_matrixに反映させるためには,どのようにコードを書けば良いでしょうか. \nとりあえず今は画像のように,入力値に応じて文書を返すようにしたのですが,それもうまくいっていません.\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/PGEIg.jpg)](https://i.stack.imgur.com/PGEIg.jpg)", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-03T15:07:36.750", "favorite_count": 0, "id": "51683", "last_activity_date": "2019-01-04T06:54:25.790", "last_edit_date": "2019-01-03T16:11:25.667", "last_editor_user_id": "3605", "owner_user_id": "31657", "post_type": "question", "score": 1, "tags": [ "python", "numpy" ], "title": "for文とif文を使ったリスト内の要素の書き換えについて", "view_count": 587 }
[ { "body": "inputは文字列(str)を受け取っているので、整数(int)と比較するとすべてNGになります。\n\n```\n\n if int(input(\"関係性がある場合…以下略\"))==1:\n \n```\n\nという風に整数に変換すれば入力値にちゃんと反応するようになります。\n\nもし配列(basic_matrix)の中身と比較したいのであれば、\n\n```\n\n print(basic_matrix ==1)\n \n```\n\n上記をfor文の外に書いてやれば配列の形のまま、合致するものをTrue、そうでないものをFalseで返します。↓\n\n```\n\n [[ True False False False False]\n [False True False False False]\n [False False True False False]\n [False False False True False]\n [False False False False True]]\n \n```\n\n参考になれば幸いです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T06:54:25.790", "id": "51693", "last_activity_date": "2019-01-04T06:54:25.790", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30590", "parent_id": "51683", "post_type": "answer", "score": 3 } ]
51683
null
51693
{ "accepted_answer_id": null, "answer_count": 0, "body": "初めて質問させていただきます。質問文に判りにくいところなど多いかもしれませんが、よろしくお願いいたします。\n\n現在JavaのサーブレットとJSPでログインフォーム付きの商品登録、検索、更新機能を備えたアプリケーションを制作しております。データベースはMySQLを使っています。\n\nひとまず機能そのものは完成しまして、データベースとの連携もできているんですが、JavaScriptでのポップアップ表示について困っております。\n\n悩んでいる点を挙げていきますと、\n\n①ログイン認証時のポップアップ表示\n\n・「no」と「pass」を入力するフォームがあり、どちらかの未入力チェックをした上でのポップアップ表示はできましたが、入力されたデータがDB内に存在するのかどうかを判定して照合した上でのポップアップ表示ができません。\n\n②商品登録時のポップアップ表示\n\n・「product_code」というものをキーに登録するんですが、これも未入力時はよいものの、DB登録済みデータと重複チェックした上での処理をJavaScriptに伝える術がわかりません。\n\n③商品検索時のポップアップ表示\n\n・②と同じような感じで、これも上述のキーを基にDB検索をかけるのですが、DB内に該当するデータがない場合ははじく。という処理がJavaScriptで書けません。\n\n以上、3つのポップアップ表示で苦戦しています。サーブレット側では機能実装できており、上の3つのケースでもチェックを実現できていますが、JavaScriptの方が想像もつきません。サーブレット&JSPだけでエラーメッセージ表示とかならできますが、どうしてもJavaScriptを使いたいため、よろしくお願いいたします。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-03T15:39:23.573", "favorite_count": 0, "id": "51684", "last_activity_date": "2019-01-03T15:39:23.573", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "javascript", "java" ], "title": "Java サーブレット&JSPとJavaScriptについて", "view_count": 429 }
[]
51684
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n subWin = new Array(0,10);\n \n var i=0;\n \n for (i; i<4; i++) {\n alert(\"イン ループ、OP windo  !=\"+ i);\n subWin[i] = window.open(\"tmp.txt\",'\"sample\"+i ', \"newwindow\" );\n alert(\"Get>=\"+ subWin[i].name+ \"==\" + \" XX\" + i );\n };\n \n```\n\nこの二回目の、アラートで、 二番目の、引数が、>\"sample\"+i< <このように表示されます。 シングルクォートを消しても、おなじです。 \n動作は、 sanpl1,,sampl2,,,,と、 名前が変わる、ように書きたいのです。\n\nなにか、書き方はありますか? どうぞよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-03T16:26:50.803", "favorite_count": 0, "id": "51685", "last_activity_date": "2019-01-08T08:16:36.703", "last_edit_date": "2019-01-04T03:17:18.987", "last_editor_user_id": "29826", "owner_user_id": "31648", "post_type": "question", "score": -2, "tags": [ "javascript" ], "title": "サブウィンド、が、一つしか開かない( 文字変数が、 評価されない、)", "view_count": 209 }
[ { "body": "シングルクォート、ダブルクォートで囲った文字列リテラルはバックスラッシュによるエスケープの解釈以外何もしません。変数を書くことはできません。ですので、文字列リテラル`'\"sample\"+i\n'`の値は`\"sample\"+i`です。\n\nこの場合、単に外側のシングルクォートを外せば期待どおりになるはずです。`window.open(\"tmp.txt\", \"sample\" + i, ...`\n\nまた、テンプレート文字列を使うこともできます。この場合は文字列の中で変数を使うことができます。バッククォートで文字列を囲み、評価したい式を `${〜}`\nで囲みます。\n\n`window.open(\"tmp.txt\", `sample${i}`, ...`", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T03:45:01.227", "id": "51814", "last_activity_date": "2019-01-08T08:16:36.703", "last_edit_date": "2019-01-08T08:16:36.703", "last_editor_user_id": "3475", "owner_user_id": "3475", "parent_id": "51685", "post_type": "answer", "score": 1 } ]
51685
null
51814
{ "accepted_answer_id": null, "answer_count": 1, "body": "ruby で、木構造で実装される Map データ構造が扱いたくなりました。以下の条件を満たすクラスはありますか?ないし、実装したライブラリなどはありますか?\n\n * `h.set(key, value)` で値を store でき、 `h.get(key)` にてそれを取得できる。それらは O(log(N)) 以下で実行できる\n * `h.find_sup(key)` にて、 `key` よりも大きな最小のキーと、それに対応する値のペアを取得できる。それが O(log(N)) で実行できる。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T04:38:25.947", "favorite_count": 0, "id": "51687", "last_activity_date": "2019-01-05T13:05:13.937", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 4, "tags": [ "ruby", "アルゴリズム", "データ構造" ], "title": "ruby で ordered hash 的なことがやりたい", "view_count": 128 }
[ { "body": "GemsのRBTreeを試してみてください。 \n<https://rubygems.org/gems/rbtree/versions/0.4.2>\n\nRBTreeのDocumentationはリンク先ページの右側から見ることができます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T07:53:05.493", "id": "51696", "last_activity_date": "2019-01-05T13:05:13.937", "last_edit_date": "2019-01-05T13:05:13.937", "last_editor_user_id": "31654", "owner_user_id": "31654", "parent_id": "51687", "post_type": "answer", "score": 2 } ]
51687
null
51696
{ "accepted_answer_id": null, "answer_count": 1, "body": "お世話になります。\n\n以前、とあるサイト様の情報を元に、C#で自作したDLLをVBAで使用するところまで \nたどり着きました。 \nそこで、他のPCでも使用できるよう、そのサイト様の下の方の情報をもとに、VBSで \n設定する方法を試してみたのですが、どうもうまくいきません。\n\n<http://excel.syogyoumujou.com/memorandum/dll_1.html>\n\n前回同様、こちらのサイト様の下の方に『別のパソコンでの設定』とあるのですが、 \nこの方法でVBSのファイルを作成し、ドラッグ&ドロップしても起動できません。\n\nドラッグ&ドロップをしてDOS窓が立ち上がればもうレジストリの設定は完了したと \nいうことなのでしょうか?それとも、この掲載されているVBSのコードが問題なのでしょうか?\n\nご教授ください。\n\nよろしくお願いいたし幕す。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T04:45:47.263", "favorite_count": 0, "id": "51688", "last_activity_date": "2019-01-04T20:47:30.080", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9374", "post_type": "question", "score": 0, "tags": [ "c#", "vbs", "dll" ], "title": "C#で自作したDLLを他のPCで設定する方法", "view_count": 431 }
[ { "body": "Windowsには32bitと64bitがあります。作成したDLLは32bitですか 64bitですか それともAnyCPUですか?\n使用したRegAsmコマンドは32bitですか 64bitですか? VBAすなわちExcelなどのアプリケーションは32bitですか 64bitですか?\nこれらが適切に一致しなければ使用できません。\n\nVBSは問題の一端ですが、根本的には開発者が動作環境を正しく理解する必要があります。そして正しく理解したあかつきにはそもそもVBSを使用せずとも自身で[RegAsm.exeコマンド](https://docs.microsoft.com/ja-\njp/dotnet/framework/tools/regasm-exe-assembly-registration-tool)を操作できるでしょう。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T06:08:07.273", "id": "51691", "last_activity_date": "2019-01-04T20:47:30.080", "last_edit_date": "2019-01-04T20:47:30.080", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "51688", "post_type": "answer", "score": 1 } ]
51688
null
51691
{ "accepted_answer_id": null, "answer_count": 0, "body": "初めて質問させていただきます。 \nRails5.2 を勉強中なのですが、 1 対多の複数モデルを update できずに困っています。\n\n転職サイトのような構造を持つデータベースで、親が仕事内容 (job) 、子が募集職種で多の関係の (employment)\nであるモデルは以下のように記載しています。\n\n```\n\n class Job < ApplicationRecord\n accepts_nested_attributes_for :employment\n end\n \n class Employment < ApplicationRecord\n belongs_to :job\n end\n \n```\n\nView を作り post されたデータを保存しようとすると、\n\n```\n\n Job.update(params[:job])\n \n```\n\n多の子モデル側を Select できないエラーが発生します。\n\n```\n\n Mysql2::Error: Unknown column 'employments.' in 'where clause': SELECT `employments`.* FROM `employments` WHERE `employments`.`job_id` = 1 AND `employments`.`` IN ('6', '9')\n \n```\n\n原因は上記の通り Where の `employments`.`` の部分の `` に id が入ってないからだと思いますが、この `` に id\nを指定する方法がわからず困っています。\n\n何か子モデルのカラム指定する部分が不足しているでしょうか。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T07:55:17.430", "favorite_count": 0, "id": "51697", "last_activity_date": "2019-05-05T06:31:04.910", "last_edit_date": "2019-05-05T06:31:04.910", "last_editor_user_id": "32986", "owner_user_id": "31664", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails" ], "title": "Rails5.2 accepts_nested_attributes_forの子モデルupdateに関して", "view_count": 180 }
[]
51697
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "今現在pythonのpandasでcsvを読み込ませ学習させようとしています。 \nそこで実行すると\n\n```\n\n ValueError:could not convert srtring to float'v -0.670323 0.017320 2.448769\\nv -0.248426 0.066855 2.655411\\nv -0.634120 0.159561 2.476978'\n \n```\n\nと出てしまい実行できません。 \nxの方にはcsvの列指定をし、yの方には3次元配列の画像データを2次元配列に変換し指定して入れています。\n\n```\n\n d_data_set = pd.read_csv(\"tes.csv\", encoding=\"utf-8\", dtype=\"object\")\n \n search_dir = './image'\n f = np.array([data.imread('{}/{}'.format(search_dir, path)) for path in os.listdir(search_dir)])\n f = f.reshape(len(f), -1).astype(np.float64)\n \n x = f\n y = df[:, \"don\"]\n \n```\n\n以下にcsvの内容を書きます。 \nこのcsvには1行目のdonと書いてあるheaderを除くと800セルあり各セルには以下のような1行に各数値の間にスペースが入った数値が改行され3行ずつ入っています。\n\n```\n\n don\n \"v 0.310527 0.015296 0.505581\n v 0.683512 -0.001598 0.216188\n v 0.370806 0.149291 0.478181\"\n \"v 0.313408 0.008205 0.505414\n v 0.685073 -0.006196 0.214194\n v 0.373934 0.142358 0.479367\"\n \"v 0.304531 0.004002 0.505210\n v 0.680174 -0.008961 0.219070\n v 0.365913 0.138171 0.481338\"\n \"v 0.297987 -0.006071 0.504920\n v 0.676619 -0.010223 0.222481\n v 0.357903 0.129184 0.483590\"\n \"v 0.305034 -0.011075 0.504809\n v 0.680596 -0.010772 0.218271\n v 0.468077 0.124864 0.479119\"\n \n```\n\n長すぎるため最初のdonを除く5セル分のデータを表示します。 \n私は最初のdonを除く800セルを800個分のデータとしてdeep learningで学習させたいのです。 \n回答お待ちしております。\n\n以下に私の実行環境を書きます \nwindows10 \npycharm \npython3.5", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T08:42:52.577", "favorite_count": 0, "id": "51698", "last_activity_date": "2019-01-05T02:27:11.270", "last_edit_date": "2019-01-05T02:27:11.270", "last_editor_user_id": "19110", "owner_user_id": "31665", "post_type": "question", "score": 0, "tags": [ "python", "pandas", "深層学習" ], "title": "pythonのdeep learningのcsv読み込みでconvert error", "view_count": 113 }
[ { "body": "以下の環境・コードで確認したところ、問題なくcsvファイルを読み込めました。\n\n * Ubuntu 18.04\n * Python 3.7.1\n * pandas 0.23.4\n\nload-csv.py\n\n```\n\n import pandas as pd\n d_data_set = pd.read_csv(\"tes.csv\", encoding=\"utf-8\", dtype=\"object\")\n \n```\n\ntes.csv\n\n```\n\n \"v 0.310527 0.015296 0.505581\n v 0.683512 -0.001598 0.216188\n v 0.370806 0.149291 0.478181\"\n \"v 0.313408 0.008205 0.505414\n v 0.685073 -0.006196 0.214194\n v 0.373934 0.142358 0.479367\"\n \"v 0.304531 0.004002 0.505210\n v 0.680174 -0.008961 0.219070\n v 0.365913 0.138171 0.481338\"\n \"v 0.297987 -0.006071 0.504920\n v 0.676619 -0.010223 0.222481\n v 0.357903 0.129184 0.483590\"\n \"v 0.305034 -0.011075 0.504809\n v 0.680596 -0.010772 0.218271\n v 0.468077 0.124864 0.479119\"\n \n```\n\n同様の環境で確認できてませんので、なんとも言えない部分もありますが、 \npandasの`read_csv`関数のdelimiterオプションで区切り文字を指定してみてはどうでしょうか。\n\nref: [pandas.read_csv — pandas 0.23.4\ndocumentation](https://pandas.pydata.org/pandas-\ndocs/stable/generated/pandas.read_csv.html)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T14:12:25.400", "id": "51705", "last_activity_date": "2019-01-04T23:41:55.010", "last_edit_date": "2019-01-04T23:41:55.010", "last_editor_user_id": "31669", "owner_user_id": "31669", "parent_id": "51698", "post_type": "answer", "score": 0 } ]
51698
null
51705
{ "accepted_answer_id": null, "answer_count": 1, "body": "kerasで2クラスの分類をCNNで行おうと思っています。以下がコードです\n\n```\n\n import random\n import pandas as pd\n from pandas import Series,DataFrame\n \n import numpy as np\n import matplotlib.pyplot as plt\n \n import keras\n from keras.datasets import fashion_mnist\n from keras.models import Sequential\n from keras.layers import Dense, Dropout,Activation ,Flatten, Dropout, \n Conv2D, MaxPooling2D, Reshape\n from keras.optimizers import RMSprop\n from keras.optimizers import Adam\n \n df_list = []\n for i in range(4): \n cl_data_set = pd.read_csv(\"./csv/cl_\" + str(i) +\".csv\",sep=\",\",header=0)\n cl_x = DataFrame(cl_data_set.drop(\"POINT\",axis=1))\n df_list.append(cl_x)\n op_data_set = pd.read_csv(\"./csv/op_\" + str(i) +\".csv\",sep=\",\",header=0)\n op_x = DataFrame(op_data_set.drop(\"POINT\",axis=1))\n df_list.append(op_x)\n \n close_1 = np.array(df_list[0])\n open_1 = np.array(df_list[1])\n close_2 = np.array(df_list[2])\n open_2 = np.array(df_list[3])\n close_3 = np.array(df_list[4])\n open_3 = np.array(df_list[5])\n close_4 = np.array(df_list[6])\n open_4 = np.array(df_list[7])\n train_dataset = []\n test_dataset = []\n for i in range(0,13000,100):\n if i >= 10400:\n test_dataset.append([close_1[i:i+100,:],1])\n test_dataset.append([close_2[i:i+100,:],1])\n test_dataset.append([open_1[i:i+100,:],0])\n test_dataset.append([open_2[i:i+100,:],0])\n \n else:\n train_dataset.append([close_1[i:i+100,:],1])\n train_dataset.append([close_2[i:i+100,:],1])\n train_dataset.append([open_1[i:i+100,:],0])\n train_dataset.append([open_2[i:i+100,:],0])\n \n random.shuffle(train_dataset)\n random.shuffle(test_dataset)\n \n x_train_list = []\n y_train_list = []\n x_test_list = []\n y_test_list = []\n for i in range(416):\n x_train_list.append(train_dataset[i][0])\n y_train_list.append(train_dataset[i][1])\n \n for i in range(104):\n x_test_list.append(test_dataset[i][0])\n y_test_list.append(test_dataset[i][1])\n \n x_train = np.array(x_train_list)\n x_test = np.array(x_test_list)\n y_train = np.array(y_train_list)\n y_test = np.array(y_test_list)\n model = Sequential()\n \n x_train = np.reshape(x_train,(-1,416,100,4))\n model.add(Conv2D(32, kernel_size=(3,3), activation='relu', input_shape=(416,100,4)))\n model.add(MaxPooling2D(pool_size=(1,2)))\n \n model.add(Dropout(0.4))\n model.add(Flatten())\n model.add(Dense(128, activation='sigmoid'))\n model.add(Dropout(0.4))\n model.add(Dense(1, activation='sigmoid'))\n \n model.summary()\n print(\"\\n\")\n model.compile(loss='binary_crossentropy',optimizer=\"Adam\",metrics=['accuracy'])\n \n \n \n history = model.fit(x_train, y_train,batch_size=200,epochs=2000,verbose=1,validation_data=(x_test, y_test))\n \n \n score = model.evaluate(x_test,y_test,verbose=1)\n print(\"\\n\")\n print(\"Test loss:\",score[0])\n print(\"Test accuracy:\",score[1])\n \n```\n\n次に、エラーの全リストを載せます\n\n```\n\n Using TensorFlow backend.\n x_train.shape\n (416, 100, 4)\n x_test.shape\n (104, 100, 4)\n y_train.shape\n (416,)\n y_test.shape\n (104,)\n \n Traceback (most recent call last):\n File \"CNN.py\", line 121, in <module>\n history = model.fit(x_train, y_train,batch_size=200,epochs=2000,verbose=1,validation_data=(x_test, y_test))\n File \"C:\\Anaconda3\\envs\\tensorflow\\lib\\site-packages\\keras\\engine\\training.py\", line 950, in fit\n batch_size=batch_size)\n File \"C:\\Anaconda3\\envs\\tensorflow\\lib\\site-packages\\keras\\engine\\training.py\", line 802, in _standardize_user_data\n check_array_length_consistency(x, y, sample_weights)\n File \"C:\\Anaconda3\\envs\\tensorflow\\lib\\site-packages\\keras\\engine\\training_utils.py\", line 236, in check_array_length_consistency\n 'and ' + str(list(set_y)[0]) + ' target samples.')\n ValueError: Input arrays should have the same number of samples as target arrays. Found 1 input samples and 416 target samples.\n \n```\n\nサンプル数は全体の520個をtrain:test=8:2で分割しており、 \nxは100pointずつ分割された4chのデータを、yはラベル(0か1)を持っています。 \nエラーの解決策と必要な修正のご協力をお願いします", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T08:54:18.590", "favorite_count": 0, "id": "51699", "last_activity_date": "2023-04-21T11:06:50.833", "last_edit_date": "2019-01-04T11:34:47.727", "last_editor_user_id": "31667", "owner_user_id": "31667", "post_type": "question", "score": 0, "tags": [ "python", "numpy", "array", "深層学習", "keras" ], "title": "kerasのCNNで入力配列とターゲット(教師)配列が一致しない", "view_count": 623 }
[ { "body": "x_train同様に、y_trainもデータ数の次元を作成すると直るのではないでしょうか。\n\n```\n\n x_train = np.reshape(x_train,(-1,416,100,4)) # => この行と同様の処理をy_trainにも実施する:\n y_train = np.reshape(y_train,(-1,416))\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T05:34:36.993", "id": "51750", "last_activity_date": "2019-01-06T05:34:36.993", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26558", "parent_id": "51699", "post_type": "answer", "score": 0 } ]
51699
null
51750
{ "accepted_answer_id": "51706", "answer_count": 2, "body": "64bit版Windows10にWindows Subsystem for LinuxとUbuntu\n18.04を導入して、MeCabとIPA辞書をインストールしようとしましたが、IPAの辞書インストール途中にエラーが出てうまくいきませんでした。\n\n<http://taku910.github.io/mecab/#install-unix>\n\n行った手順としては、mecab-0.996.tar.gzとmecab-\nipadic-2.7.0-20070801.tar.gzをコピーして、サイトの手順通りに進めました。\n\n```\n\n $ tar zxfv mecab-0.996.tar.gz\n $ cd mecab-X.X\n $ ./configure \n $ make\n $ make check\n $ sudo make install\n \n```\n\nmecabはインストールできました。\n\n```\n\n $ tar zxfv mecab-ipadic-2.7.0-20070801.tar.gz\n $ cd mecab-ipadic-2.7.0-20070801\n $ ./configure\n checking for a BSD-compatible install... /usr/bin/install -c\n checking whether build environment is sane... yes\n checking whether make sets $(MAKE)... yes\n checking for working aclocal-1.4... missing\n checking for working autoconf... found\n checking for working automake-1.4... missing\n checking for working autoheader... found\n checking for working makeinfo... missing\n checking for a BSD-compatible install... /usr/bin/install -c\n checking for mecab-config... /usr/local/bin/mecab-config\n configure: creating ./config.status\n config.status: creating Makefile\n $ make\n /usr/local/libexec/mecab/mecab-dict-index -d . -o . -f EUC-JP -t euc-jp\n /usr/local/libexec/mecab/mecab-dict-index: error while loading shared \n libraries: libmecab.so.2: cannot open shared object file: No such file or directory\n Makefile:253: recipe for target 'matrix.bin' failed\n make: *** [matrix.bin] Error 127\n \n```\n\nIPA辞書がインストールできませんでした。\n\naclocalとautomakeはautotools-devを使えばいいとaskUbuntuに書いてありましたが、apt-\ngetで配布しているバージョンが新しすぎてapt-\ngetだけではうまくいかないように思いました。私はLinuxアプリケーションのビルドに詳しくないのでここで詰まった感じです。\n\n<https://askubuntu.com/questions/45480/how-do-i-install-aclocal>\n\n解決法が分かる方がいらっしゃいましたらご教示のほどをよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T09:56:44.073", "favorite_count": 0, "id": "51701", "last_activity_date": "2019-01-04T14:31:34.090", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31654", "post_type": "question", "score": 1, "tags": [ "ubuntu", "mecab", "wsl" ], "title": "WSL(Ubuntu 18.04)にMeCabをインストールできない", "view_count": 2091 }
[ { "body": "mecab 本体を `make install` した際に、以下のようなメッセージが出ているはずです。\n\n```\n\n Libraries have been installed in:\n /usr/local/lib\n \n If you ever happen to want to link against installed libraries\n in a given directory, LIBDIR, you must either use libtool, and\n specify the full pathname of the library, or use the `-LLIBDIR'\n flag during linking and do at least one of the following:\n - add LIBDIR to the `LD_LIBRARY_PATH' environment variable\n during execution\n - add LIBDIR to the `LD_RUN_PATH' environment variable\n during linking\n - use the `-Wl,-rpath -Wl,LIBDIR' linker flag\n - have your system administrator add LIBDIR to `/etc/ld.so.conf'\n \n See any operating system documentation about shared libraries for\n more information, such as the ld(1) and ld.so(8) manual pages.\n \n```\n\nこの注意書きの通りで、要するに mecab のライブラリである libmecab.so.2\nがどこにあるのかソフトウェア側に教えてあげていないので見つからず、エラーになっています。\n\nデフォルトではライブラリは `/usr/local/lib` 下にインストールされるので、このパスを `LD_LIBRARY_PATH`\nに追加してあげると辞書の `make` も通るはずです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T10:32:46.350", "id": "51703", "last_activity_date": "2019-01-04T10:32:46.350", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "51701", "post_type": "answer", "score": 1 }, { "body": "すみません。MeCabの公式サイトの方法だと環境変数や文字コード等の設定が必要になり、難しいと判断したので「WSL\nmecab」で検索しました。そのときに見つけた記事がこちらになります。\n\n[NEologd 辞書 を Windows 用 MeCab に導入して Python\nで使う方法](https://qiita.com/ChenZheChina/items/42f1fcc763e88cb02cca)\n\nただ、上記の記事の中に、下記記事の紹介がありました。\n\n[ubuntu 18.04 に mecab\nをインストール](https://qiita.com/ekzemplaro/items/c98c7f6698f130b55d53)\n\nそのような経緯で、MeCabをソースコードからビルドするのではなくUbuntuのディストリビューションで配布されているバイナリを使うこととしました。この方法だと、環境変数やその他設定ファイルなどを設定しなくともインストールすることができます。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T14:14:04.400", "id": "51706", "last_activity_date": "2019-01-04T14:31:34.090", "last_edit_date": "2019-01-04T14:31:34.090", "last_editor_user_id": "31654", "owner_user_id": "31654", "parent_id": "51701", "post_type": "answer", "score": 0 } ]
51701
51706
51703
{ "accepted_answer_id": null, "answer_count": 1, "body": "世界的にWebシステムにはWordPressを取り入れているシステムが多いと知ったのですが \n新しいWebシステムを開発するときWordPressの使用可否の判断はどのような点にあるのでしょうか。 \nホームページを作成するときは大概WordPressを使用するなどあるのでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T15:41:05.167", "favorite_count": 0, "id": "51708", "last_activity_date": "2019-01-05T08:54:10.503", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17348", "post_type": "question", "score": 0, "tags": [ "wordpress" ], "title": "WordPressの使用可否の判断について。", "view_count": 85 }
[ { "body": "ホームページの更新は自分自身で行うのでしょうか? \nHTMLでホームページを作成した場合、更新のたびにFTPで送信する必要があります。 \nWordPressの場合、一度サイトを作成した後は、サイトにアドミニストレータ等でログインし、 \n文章を書き換えることができます。*できない部分もあります。 \n従いまして、更新を他の人にやってもらう場合や、外出先等で更新する場合はWordPressの方が楽です。 \nただ、最初の設定はデータベースの設定やPHP等が絡んでくるため、HTMLで書いた場合より面倒になります。 \nまた、WordPressを使う場合、サーバーが対応していなければいけません。 \n無料サーバー等では対応していない場合もあります。 \nこのメリット、デメリットを考慮して選択すればいいかと思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T08:54:10.503", "id": "51727", "last_activity_date": "2019-01-05T08:54:10.503", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24490", "parent_id": "51708", "post_type": "answer", "score": 1 } ]
51708
null
51727
{ "accepted_answer_id": "51840", "answer_count": 2, "body": "PHPがメインの開発言語でXAMPPを使用している現場の場合、デバッグツールは何を使用しているのが一般的ですか。コードにブレークポイントを張って変数の中を確かめるといったデバックツールを使用しているのか知りたいと思っています。 \nデバッグツールを使わない現場もあるのでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-04T15:46:19.753", "favorite_count": 0, "id": "51709", "last_activity_date": "2019-01-09T09:39:03.960", "last_edit_date": "2019-01-04T16:04:08.240", "last_editor_user_id": "17348", "owner_user_id": "17348", "post_type": "question", "score": 0, "tags": [ "php" ], "title": "PHPで使用するデバッグツールについて", "view_count": 272 }
[ { "body": "Xdebug + Visual Studio Code が軽くて使いやすいですね。\n\nEclipseを使っていましたが、動作が重いのが難点です。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T05:48:12.470", "id": "51832", "last_activity_date": "2019-01-09T05:48:12.470", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31724", "parent_id": "51709", "post_type": "answer", "score": 1 }, { "body": "経験則ですが、Xdebugなどブレークポイントデバッガは半数位の現場で使用されているイメージです。 \n意外とecho・ロギング・フレームワークのDebug機能のみで対処してる現場は多いです。\n\nXampp導入~Xdebug設定のための手順も記載しておきます。\n\n 1. Disable IIS \n 1. Control Panel\n 2. Programs and Features\n 3. Turn Windows features on or off\n 4. Internet Information Service\n 2. Download & unzip Xampp \n 1. e.g. <https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/7.2.3/>\n 3. Put it on C:\\\n 4. Download and setup php X Debug TS 32bit \n 1. e.g. <https://xdebug.org/files/php_xdebug-2.6.0-7.2-vc15.dll>\n 2. Put it on \\php\\ext\n 3. Add settings to \\php\\php.ini\n\n```\n\n [XDebug]\n zend_extension = \"C:\\xampp\\php\\ext\\php_xdebug-2.6.0-7.2-vc15.dll\"\n xdebug.profiler_append=0\n xdebug.profiler_enable=0\n xdebug.profiler_enable_trigger = 0\n xdebug.profiler_output_dir=\"c:\\xampp\\tmp\"\n xdebug.remote_autostart = 1\n xdebug.remote_cookie_expire_time = 36000\n xdebug.remote_enable=1\n xdebug.remote_handler=\"dbgp\"\n xdebug.remote_host=\"localhost\"\n xdebug.remote_port=9000\n \n```\n\n5\\. Run xampp-control.exe, and start Apache & MySQL\n\nConfirm versions by shell of xampp\n\n```\n\n httpd -v\n mysql -v\n php -v\n \n```\n\nSupplement\n\n 1. Web server's document-root is htdocs.\n 2. Web site url is localhost.\n\n↑ココまでがサーバ側(Xampp)の設定。\n\n↓以降はエディタ側の設定(例としてVisual Studio Codeで設定)\n\nInstall\n\n```\n\n 1. Visual Studio Code (by installer)\n 2. Add PHP Debug extension\n \n```\n\n 1. 市販ウイルス対策ソフト、Windows Defenderなどのファイアーウォールのポート9000を開ける\n 2. Visual Studio Codeで開く\n 3. デバッグ実行\n 4. どの環境で初期化するか聞かれる \n * 拡張で入れたPHPを選択\n * .vscode/launch.jsonが自動生成\n 5. launch.json書き換え\n\n```\n\n {\n // IntelliSense を使用して利用可能な属性を学べます。\n // 既存の属性の説明をホバーして表示します。\n // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387\n \"version\": \"0.2.0\",\n \"configurations\": [\n {\n \"name\": \"Listen for XDebug\",\n \"type\": \"php\",\n \"request\": \"launch\",\n \"port\": 9000,\n \"pathMappings\": {\n \"/var/www/html\": \"${workspaceRoot}\"\n }\n }\n ]\n }\n \n```\n\n※1 作業フォルダ(pathMappings)などの位置関係は、環境に応じて調整してください \n※2 なお個人的にはXamppは非推奨で、各個人がCentOSのVM立てた方が間違いが少ないかなーと思ってます", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T09:32:30.470", "id": "51840", "last_activity_date": "2019-01-09T09:39:03.960", "last_edit_date": "2019-01-09T09:39:03.960", "last_editor_user_id": "25396", "owner_user_id": "25396", "parent_id": "51709", "post_type": "answer", "score": 1 } ]
51709
51840
51832
{ "accepted_answer_id": "51712", "answer_count": 1, "body": "Ruby On\nRailsで運用していたstaging環境をAWSのEC2からインスタンスを再起動すると、chromeで該当のURLを開こうとしても「このページは動作していません」となり、開けません。safariなど他のブラウザで開いても同じようなメッセージが出ます。\n\n* * *\n\n**環境**\n\nmacOS High Sierra(バージョン10.13.6) \nruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin17] \nRails 4.2.6 \nchrome バージョン: 71.0.3578.98(Official Build) (64 ビット)\n\n* * *\n\n**試したこと**\n\n・ df -hでデータ容量を確認してみましたが空きは十分にありました。 \n・ redisを再起動してみましたが「ページが動作しません」は変わりません。 \n・ EC2のインスタンスを確認したところ、Elastic IPやIPv4 パブリック IPは変更されていませんでした。 \n(これはconfig/deploy/staging.rbやconfig/environments/staging.rbに設定されているIPアドレスと同じものです。)\n\n・ ログを確認してみたところ、 \n1\\. nginx.access.logとnginx.error.logは動作していませんでした \n2\\. unicorn.logとsidekiq.logとstaging.logはデプロイしたときログを吐いていますがエラーはありません。\n\n* * *\n\n**実現したいこと**\n\nstaging環境が開けなくなった原因を突き止めて、復旧したいです。 \nご教示いただけることがあれば何卒よろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T00:12:13.873", "favorite_count": 0, "id": "51711", "last_activity_date": "2019-01-05T02:26:35.910", "last_edit_date": "2019-01-05T02:26:35.910", "last_editor_user_id": "19110", "owner_user_id": "29589", "post_type": "question", "score": 2, "tags": [ "ruby-on-rails", "ruby", "aws", "nginx", "amazon-ec2" ], "title": "EC2(AWS)のインスタンスを再起動すると「ページが動作しません」", "view_count": 854 }
[ { "body": "まずはnginx, unicorn, sidekiqのプロセスが起動しているか確認してみてはどうでしょうか。\n\n以下はプロセス一覧からgrepをかけてunicornプロセスが起動しているかを確認する例です。\n\n`ps aux | grep -v grep | grep unicorn`\n\nこれで何も表示されなければunicornプロセスが起動されてないので、`bundle exec unicorn\n<必要なオプション>`で起動する必要があります。", "comment_count": 9, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T00:24:54.247", "id": "51712", "last_activity_date": "2019-01-05T00:24:54.247", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31669", "parent_id": "51711", "post_type": "answer", "score": 2 } ]
51711
51712
51712
{ "accepted_answer_id": null, "answer_count": 1, "body": "Swiftでバーコードリーダーを作成しており、カメラの起動は問題ないのですが、メタデータが取得できません。 \nビルドは成功しています。原因お分かりになりますでしょうか。 \nよろしくお願いいたします。\n\n```\n\n import UIKit\n import AVFoundation\n \n class ViewController: UIViewController, AVCapturePhotoCaptureDelegate {\n \n // Connect as outlet\n @IBOutlet weak var previewView: UIView!\n \n // Make instance\n var captureSession = AVCaptureSession()\n \n // Make notification\n let notification = NotificationCenter.default\n \n // Status for privacy and in-output\n var authStatus:AuthorizedStatus = .authorized\n var inOutStatus:InputOutputStatus = .ready\n \n // Authorization Status\n enum AuthorizedStatus {\n case authorized\n case notAuthorized\n case failed\n }\n // InOut Status\n enum InputOutputStatus {\n case ready\n case notReady\n case failed\n }\n \n let x: CGFloat = 0.1\n let y: CGFloat = 0.4\n let width: CGFloat = 0.8\n let height: CGFloat = 0.2\n \n override func viewDidLoad(){\n super.viewDidLoad()\n // interrupt if processing session\n guard !captureSession.isRunning else {\n return\n }\n // privacy authorization for camera\n cameraAuth()\n \n // Set InputOutput\n setupInputOutput()\n \n // Check camera is ready\n if (authStatus == .authorized)&&(inOutStatus == .ready) {\n // Set previewLayer\n setPreviewLayer()\n // Start session\n captureSession.startRunning()\n } else {\n // alert\n showAlert(appName: \"Camera\")\n }\n \n }\n \n override func viewWillAppear(_ animated: Bool) {\n super.viewWillAppear(animated)\n \n if (captureSession.isRunning == false) {\n captureSession.startRunning()\n }\n }\n \n override func viewWillDisappear(_ animated: Bool) {\n super.viewWillDisappear(animated)\n \n if (captureSession.isRunning == true) {\n captureSession.stopRunning()\n }\n }\n \n func cameraAuth(){\n let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)\n switch status {\n case .notDetermined:\n AVCaptureDevice.requestAccess(for: AVMediaType.video,\n completionHandler: { [unowned self] authorized in print(\"First Time\", authorized.description)\n if authorized {\n self.authStatus = .authorized\n } else {\n self.authStatus = .notAuthorized\n }})\n case .restricted, .denied:\n authStatus = .notAuthorized\n case .authorized:\n authStatus = .authorized\n }\n }\n \n func setupInputOutput(){\n // Set resolution\n // captureSession.sessionPreset = AVCaptureSession.Preset.\n \n // Set input\n do {\n // Obtain devise\n let devise = AVCaptureDevice.default(\n AVCaptureDevice.DeviceType.builtInWideAngleCamera,\n for: AVMediaType.video,\n position: AVCaptureDevice.Position.back\n )\n \n // where to input\n let input = try AVCaptureDeviceInput(device: devise!)\n if captureSession.canAddInput(input){\n captureSession.addInput(input)\n } else {\n print(\"Failed to add input to session\")\n return\n }\n } catch let err as NSError {\n print(\"Camera doesn't exist \\(err)\")\n return\n }\n \n // Set output\n let metadataOutput = AVCaptureMetadataOutput()\n if captureSession.canAddOutput(metadataOutput) {\n captureSession.addOutput(metadataOutput)\n metadataOutput.setMetadataObjectsDelegate((self as? AVCaptureMetadataOutputObjectsDelegate), queue: DispatchQueue.main)\n metadataOutput.metadataObjectTypes = [.ean13]\n metadataOutput.rectOfInterest = CGRect(x: y, y: 1 - x - width, width: height, height: width)\n } else {\n print(\"Failed to add output to session\")\n return\n }\n }\n \n func setPreviewLayer(){\n // Make previewLayer\n let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)\n previewLayer.frame = view.layer.bounds\n previewLayer.videoGravity = AVLayerVideoGravity.resizeAspect\n \n // Add preview\n previewView.layer.addSublayer(previewLayer)\n \n // Add red-frame\n // let detectionArea = UIView()\n // detectionArea.frame = CGRect(x: view.frame.size.width * x, y: view.frame.size.height * y, width: view.frame.size.width * width, height: view.frame.size.height * height)\n // detectionArea.layer.borderColor = UIColor.red.cgColor\n // detectionArea.layer.borderWidth = 3\n // view.addSubview(detectionArea)\n }\n \n func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection){\n for metadata in metadataObjects as! [AVMetadataMachineReadableCodeObject] {\n // check whether it's barcode\n if metadata.type == AVMetadataObject.ObjectType.ean13 {\n if metadata.stringValue != nil {\n print(metadata.stringValue!)\n }\n }\n print(\"metadataOutput called\")\n \n // metadata\n print(metadata.type)\n print(metadata.stringValue!)\n }\n }\n \n func showAlert(appName: String){\n let aTitle = \"privacy authorization for \" + appName\n let aMessage = \"Please authorize by Setting>Privacy> \" + appName\n let alert = UIAlertController(title: aTitle, message: aMessage, preferredStyle: .alert)\n \n // OK(nothing)\n alert.addAction(UIAlertAction(title: \"OK\", style: .default, handler: nil))\n \n // Open Setting\n alert.addAction(UIAlertAction(title: \"Open Setting\", style: .default, handler: { action in UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)}))\n \n // Display alert\n self.present(alert, animated: false, completion: nil)\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T02:05:48.750", "favorite_count": 0, "id": "51713", "last_activity_date": "2020-09-18T13:06:00.597", "last_edit_date": "2020-07-19T16:45:18.820", "last_editor_user_id": "3060", "owner_user_id": "31671", "post_type": "question", "score": 0, "tags": [ "swift", "swift4" ], "title": "Swift 4 バーコードリーダアプリのメタデータ取得について", "view_count": 278 }
[ { "body": "全部のコードをチェックできたわけではないのですが、少なくともここは直さないと動かないというのがあるのでそこだけ示させていただきます。\n\n**ダメ** な部分:\n\n```\n\n metadataOutput.setMetadataObjectsDelegate((self as? AVCaptureMetadataOutputObjectsDelegate), queue: DispatchQueue.main)\n \n```\n\ndelegateを設定する際に型に関するエラーが出た場合、`as?`でキャストしても、殆どの場合、期待される動作にはなりません。ちゃんと設定するインスタンスのクラス(今の場合`ViewController`)を必要なプロトコル(`AVCaptureMetadataOutputObjectsDelegate`)に適合させてください。\n\nクラスヘッダには`AVCaptureMetadataOutputObjectsDelegate`を追加:\n\n```\n\n class ViewController: UIViewController, AVCapturePhotoCaptureDelegate,\n AVCaptureMetadataOutputObjectsDelegate {\n \n```\n\n(`AVCapturePhotoCaptureDelegate`が必要かどうかわかりませんでしたが、とりあえずそのままにしておきました。)\n\ndelegateを設定する場合には、キャストはしない:\n\n```\n\n metadataOutput.setMetadataObjectsDelegate(self, queue: .main)\n \n```\n\n* * *\n\n本題には関係ありませんが、`cameraAuth()`の中で`unowned`を使っておられますが、`unowned`と`weak`の違い、どんな場合にそれらが必要になるかを十分理解しておられないのではないでしょうか。あなたのコードの場合、`unowned`も`weak`も必要ありません。十分理解できないまま「念のため」で付けるなら`[unowned\nself]`ではなく`[weak\nself]`を使用しておくことをお勧めします。(もちろんそれによりOptionalとしての取り扱いが必要。)`unowned`は使い方を間違えると簡単にクラッシュの原因になります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T02:40:59.083", "id": "51714", "last_activity_date": "2019-01-05T02:40:59.083", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "51713", "post_type": "answer", "score": 0 } ]
51713
null
51714
{ "accepted_answer_id": "51739", "answer_count": 2, "body": "MathJax において、`\\iff` の上に `\\overset` で文字列を置くとやや左側に寄って表示されます。LaTeX\nで同じことをしたときのように文字列の中心と矢印の中心を合わせたいのですが、どのように書けば良いのでしょうか?\n\n```\n\n <script type=\"math/tex; mode=display\">% <![CDATA[\r\n a \\sim b \\overset{\\text{def}}{\\iff} a - b \\equiv 0 \\pmod{p} %]]></script>\r\n <script type=\"text/javascript\" async src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"></script>\n```\n\n[![上のスニペットを実行したときのスクリーンショットです](https://i.stack.imgur.com/qpuYr.png)](https://i.stack.imgur.com/qpuYr.png)\n\n※黄色くマーカーを付けた「def」が少し左に寄っています。\n\n### 手元の実行環境\n\n * Windows 10\n * Google Chrome 71.0.3578.98", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T12:58:53.883", "favorite_count": 0, "id": "51735", "last_activity_date": "2019-01-18T12:11:57.370", "last_edit_date": "2019-01-06T03:28:21.313", "last_editor_user_id": "19110", "owner_user_id": "19110", "post_type": "question", "score": 1, "tags": [ "latex", "mathjax" ], "title": "MathJax で矢印上部のちょうど真ん中に文字列を配置したい", "view_count": 585 }
[ { "body": "試してみたところ,`\\mathrel{\\overset{\\text{def}}{\\iff}}` のように `\\mathrel{}` で囲むと def\nの出力位置(というより `\\iff` の出力位置)が次のように変わるようでした。\n\n上:`\\overset{\\text{def}}{\\iff}` \n下:`\\mathrel{\\overset{\\text{def}}{\\iff}}`\n\n[![比較](https://i.stack.imgur.com/Zomga.png)](https://i.stack.imgur.com/Zomga.png)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T14:55:56.997", "id": "51739", "last_activity_date": "2019-01-05T14:55:56.997", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2663", "parent_id": "51735", "post_type": "answer", "score": 1 }, { "body": "[@YusukeTerada\nさんの回答](https://ja.stackoverflow.com/a/51739/19110)と実質的に同じことをしているのですが、[`\\stackrel`](https://github.com/mathjax/MathJax/blob/419b0a6eee7eefc0f85e47f7d4f8227ec28b8e57/unpacked/jax/input/TeX/jax.js#L825)\nを使って解決することもできるようでした。\n\n```\n\n \\stackrel{\\text{def}}{\\iff}\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-18T12:11:57.370", "id": "52085", "last_activity_date": "2019-01-18T12:11:57.370", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "51735", "post_type": "answer", "score": 0 } ]
51735
51739
51739
{ "accepted_answer_id": null, "answer_count": 1, "body": "matlabについての質問です。 \nある領域において、 \n端末を(1,5)から(1,18)の辺の間にランダムに配置し、 \nその辺を上下に動かしたいです。\n\nそのため無線端末の位置を(xi,yi)とし、 \n1秒ごとにyの値を1ずつ増加さ \nせ、(1,18)に達したら今度はyの値を \n1ずつ減少させ、(1,5)に達したらまたyの値を1ずつ増加させるプログラムを作りたいです。\n\n```\n\n xi = 1;\n yi = obj.yi_;\n if(yi >= 18)\n yi = obj.yi_ - 1;\n elseif(yi <= 5)\n yi = obj.yi_ + 1;\n end\n \n```\n\nとプログラムを組みましたが、このプログラムでは、 \n(1,18)に達して以降ずっと(1,18)で止まってしまいます。\n\nどうプログラムを変えれば、上手く動きますか?", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T13:28:59.233", "favorite_count": 0, "id": "51736", "last_activity_date": "2019-01-05T20:36:56.927", "last_edit_date": "2019-01-05T20:36:56.927", "last_editor_user_id": "3605", "owner_user_id": "31674", "post_type": "question", "score": 0, "tags": [ "matlab" ], "title": "matlab 辺上を動かしある点で跳ね返るプログラム", "view_count": 99 }
[ { "body": "手元にMatlabの実行環境がないので、コードを読む限りで分かる問題について回答します。間違いがありましたら指摘をお願いします。\n\n# 現状の実装について\n\n```\n\n if(yi >= 18)\n yi = obj.yi_ - 1;\n elseif(yi <= 5)\n yi = obj.yi_ + 1;\n end\n \n```\n\nこの部分のコードを噛み砕くと、「 `obj.yi_`の値が18以上なら `y` を 1減少させ、`obj.yi_`の値が5以下なら `yi` を\n1増加させ、 **それ以外なら何もしない** 」というようになっています。\n\nこのため、記載されているコードを読む限り、以下のような問題点があります。\n\n * `6 <= obj.yi_ <= 17` の場合になにも起こらない\n * `obj` がどのように定義されているのか分からないため、正しい実装の示しようがない \n * `(1,18)に達して以降ずっと(1,18)で止まってしまいます` とのことですので、どこかで上下に動かしている実装があるのでしょうか?\n * 現在の移動方向が示されていない \n * 上2つについては、この質問に記載されていないだけでどこかに実装がある場合、問題ありません。しかし、主題である`(1,18)に達して以降ずっと(1,18)で止まってしまう`というのは、明らかに壁で跳ね返らずに現在の移動方向が正の方向のままであるのが原因です。\n\n# 正しい実装の例\n\n速度を表す`v`という変数を導入して、壁に跳ね返った時点でこれを逆方向に変換するのが良さそうです。今後、速度の変更や壁の弾性係数を指定することもできるでしょう。\n\n```\n\n v = 1;\n xi = 1;\n yi = obj.yi_;\n if(yi >= 18)\n yi = obj.yi_ - 1;\n v = -v;\n elseif(yi <= 5)\n yi = obj.yi_ + 1;\n v = -v;\n end\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T15:17:45.003", "id": "51741", "last_activity_date": "2019-01-05T15:17:45.003", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29826", "parent_id": "51736", "post_type": "answer", "score": 2 } ]
51736
null
51741
{ "accepted_answer_id": null, "answer_count": 0, "body": "## 発生している問題\n\n現在 rails tutorial の 11 章をやっているのですが、送信メールのプレビューのテストが、テキスト通りに書いたコードが、テストに通らず\nArgumentError を吐きだしてしまいます。\n\n唯一プレビューを完成させるに当たって、 `config/environments/development.rb` の host\nの部分だけは、コピペできる内容ではなかったので、自分で調べて記入したのですが、そういった感じのエラーでもなさそうな感じがしています。\n\nエラーの内容を見る限り `account_activation` メソッドの引数が期待値と異なっている為エラーを起こしているようなのですが、与えられた引数が\n1 に対して期待値が 0 だったので混乱してます。\n\nこれらが関係してそうなコードを見て、もし心当たりがありそうな点があれば教えていただけたらと思います。\n\nまた、 `development.rb` の host の部分の記入に誤りがあれば、正しい記述を教えていただけたらと思います。\n\n* * *\n\n## 環境\n\n * CentOS 6 \n(ip 指定しているので `localhost:3000` ではなく `ipアドレス:3000` で `rails s` 動かしてます)\n\n * rails 5.1.6\n\n* * *\n\n## エラーの内容\n\n```\n\n Running via Spring preloader in process 18311\n Started with run options --seed 18224\n \n ERROR[\"test_account_activation\", UserMailerTest, 1.4291797599980782]\n test_account_activation#UserMailerTest (1.43s)\n ArgumentError: ArgumentError: wrong number of arguments (given \n 1, expected 0)\n app/mailers/user_mailer.rb:8:in `account_activation'\n test/mailers/user_mailer_test.rb:8:in `block in \n <class:UserMailerTest>'\n \n 40/40: [=================================] 100% Time: 00:00:01, Time: \n 00:00:01\n \n Finished in 1.90915s\n 40 tests, 150 assertions, 0 failures, 1 errors, 0 skips\n \n```\n\n* * *\n\n## 該当のソースコード\n\n`test/mailers/user_mailer_test.rb`:\n\n```\n\n require 'test_helper'\n \n class UserMailerTest < ActionMailer::TestCase\n test \"account_activation\" do\n user = users(:michael)\n user.activation_token = User.new_token\n mail = UserMailer.account_activation(user)\n assert_equal \"Account activation\", mail.subject\n assert_equal [user.email], mail.to\n assert_equal [\"[email protected]\"], mail.from\n assert_match user.name, mail.body.encoded\n assert_match user.activation_token, mail.body.encoded\n assert_match CGI.escape(user.email), mail.body.encoded\n end\n \n # test \"password_reset\" do\n # mail = UserMailer.password_reset\n # assert_equal \"Password reset\", mail.subject\n # assert_equal [\"[email protected]\"], mail.to\n # assert_equal [\"[email protected]\"], mail.from\n # assert_match \"Hi\", mail.body.encoded\n # end\n \n end\n \n```\n\n`app/mailers/user_mailer.rb`:\n\n```\n\n class UserMailer < ApplicationMailer\n \n # Subject can be set in your I18n file at config/locales/en.yml\n # with the following lookup:\n #\n # en.user_mailer.account_activation.subject\n #\n def account_activation(user)\n @user = user\n mail to: user.email, subject: \"Account activation\"\n end\n \n # Subject can be set in your I18n file at config/locales/en.yml\n # with the following lookup:\n #\n # en.user_mailer.password_reset.subject\n #\n def password_reset\n @greeting = \"Hi\"\n \n mail to: \"[email protected]\"\n end\n end\n \n```\n\n`app/views/user_mailer/account_activation.html.erb`:\n\n```\n\n <h1>Sample App</h1>\n \n <p>Hi <%= @user.name %>,</p>\n \n <p>\n Welcome to the Sample App! Click on the link below to activate your \n account:\n </p>\n \n <%= link_to \"Activate\", edit_account_activation_url(@user.activation_token,\n email: @user.email) %>\n \n```\n\n`app/models/user.rb`:\n\n```\n\n class User < ApplicationRecord\n attr_accessor :remember_token, :activation_token\n before_create :create_activation_digest\n before_save :downcase_email\n \n # email属性を小文字に変換\n before_save { self.email = email.downcase }\n \n # nameに対してのバリデーション presence(存在性)、length(文字数制限)\n validates :name, presence: true, length: { maximum: 50 }\n \n \n # emailに対してのバリデーション presence(存在性)、length(文字数制限)、\n #                 format(テンプレート)、uniqueness(一意性)\n VALID_EMAIL_REGEX = /\\A[\\w+\\-.]+@[a-z\\d\\-]+(\\.[a-z\\d\\-]+)*\\.[a-z]+\\z/i\n \n \n validates :email, presence: true, length: { maximum: 255 },\n format: { with: VALID_EMAIL_REGEX },\n # メールアドレスの大小区別しない一意性の検証\n uniqueness: { case_sensitive: false }\n \n \n # paswordに対してのバリデーション presence(存在性)、length(文字数制限)\n has_secure_password\n validates :password, presence: true, length: { minimum: 6 }, allow_nil: true\n \n class << self\n \n # 渡された文字列のハッシュ値を返す\n def digest(string)\n cost = ActiveModel::SecurePassword.min_cost ? \n BCrypt::Engine::MIN_COST :\n BCrypt::Engine.cost\n BCrypt::Password.create(string, cost: cost)\n end\n \n # ランダムなトークンを返す\n def new_token\n SecureRandom.urlsafe_base64\n end\n end\n \n # 永続セッションのためにユーザーをデータベースに記憶する\n def remember\n self.remember_token = User.new_token\n update_attribute(:remember_digest, User.digest(remember_token))\n end\n \n # 渡されたトークンがダイジェストと一致したらtrueを返す\n def authenticated?(remember_token)\n return false if remember_digest.nil?\n BCrypt::Password.new(remember_digest).is_password?(remember_token)\n end\n \n # ユーザーのログイン情報を破棄する\n def forget\n update_attribute(:remember_digest, nil)\n end\n \n private\n \n # 有効化トークンと有効化ダイジェストを作成、代入する\n def create_activation_digest\n self.activation_token = User.new_token\n self.activation_digest = User.digest(activation_token)\n end\n \n # メールアドレスをすべて小文字にする\n def downcase_email\n email.downcase!\n end\n \n \n end\n \n```\n\n`db/seed`:\n\n```\n\n User.create!(name: \"Example User\",\n email: \"[email protected]\",\n password: \"foobar\",\n password_confirmation: \"foobar\",\n admin: true,\n activated: true,\n activated_at: Time.zone.now)\n \n 99.times do |n|\n name = Faker::Name.name\n email = \"example-#{n+1}@railstutorial.org\"\n password = \"password\"\n User.create!(name: name,\n email: email,\n password: password,\n password_confirmation: password,\n activated: true,\n activated_at: Time.zone.now)\n end\n \n```\n\n`test/fixtures/users.yml`:\n\n```\n\n michael:\n name: Michael Example\n email: [email protected]\n password_digest: <%= User.digest('password') %>\n admin: true\n activated: true\n activated_at: <%= Time.zone.now %>\n \n archer:\n name: Sterling Archer\n email: [email protected]\n password_digest: <%= User.digest('password') %>\n activated: true\n activated_at: <%= Time.zone.now %>\n \n lana:\n name: Lana Kane\n email: [email protected]\n password_digest: <%= User.digest('password') %>\n activated: true\n activated_at: <%= Time.zone.now %>\n \n malory:\n name: Malory Archer\n email: [email protected]\n password_digest: <%= User.digest('password') %>\n activated: true\n activated_at: <%= Time.zone.now %>\n \n <% 30.times do |n| %>\n user_<%= n %>:\n name: <%= \"User #{n}\" %>\n email: <%= \"user-#{n}@example.com\" %>\n password_digest: <%= User.digest('password') %>\n activated: true\n activated_at: <%= Time.zone.now %>\n <% end %>\n \n```\n\n`config/environments/development.rb`:\n\n```\n\n Rails.application.configure do\n \n config.cache_classes = false\n \n config.eager_load = false\n \n config.consider_all_requests_local = true\n \n if Rails.root.join('tmp/caching-dev.txt').exist?\n config.action_controller.perform_caching = true\n \n config.cache_store = :memory_store\n config.public_file_server.headers = {\n 'Cache-Control' => \"public, max-age=#{2.days.seconds.to_i}\"\n }\n else\n config.action_controller.perform_caching = false\n \n config.cache_store = :null_store\n end\n \n config.action_mailer.raise_delivery_errors = false\n \n config.action_mailer.perform_caching = false\n \n config.active_support.deprecation = :log\n \n config.active_record.migration_error = :page_load\n \n config.assets.debug = true\n \n config.assets.quiet = true\n \n config.file_watcher = ActiveSupport::EventedFileUpdateChecker\n \n config.action_mailer.raise_delivery_errors = true\n config.action_mailer.delivery_method = :test\n host = 'localhost.localdomain'\n config.action_mailer.default_url_options = { host: host, protocol: 'http' }\n config.action_mailer.default_url_options = { host: 'example.com' }\n end\n \n```\n\n以上です。\n\nなにか足りない情報などありましたら、追記していきます。 \nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T15:55:21.053", "favorite_count": 0, "id": "51742", "last_activity_date": "2019-05-05T06:57:23.477", "last_edit_date": "2019-05-05T06:57:23.477", "last_editor_user_id": "32986", "owner_user_id": "31218", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails" ], "title": "rails tutorial 11章 2.2 送信メールのプレビューのテストが通りません", "view_count": 262 }
[]
51742
null
null
{ "accepted_answer_id": "51746", "answer_count": 1, "body": "Railsで`link_to(\"○\",\"□\")`でurlの記入場所`□`に`params[:id]`は使用できないのですか? \nparamsはコントローラーでしか使用できないのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T01:46:02.483", "favorite_count": 0, "id": "51745", "last_activity_date": "2019-01-06T11:48:55.710", "last_edit_date": "2019-01-06T11:48:55.710", "last_editor_user_id": "3068", "owner_user_id": "31678", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails" ], "title": "paramsの使い方について", "view_count": 559 }
[ { "body": "viewで`link_to`の引数に`params`を用いることができないのか、という認識でおります。\n\nrailsではcontrollerからviewに変数を渡すには、controllerでインスタンス変数として定義する必要があります。\n\n`params[:id]`のみをviewに渡したいのであれば、以下のようにcontrollerで`params[:id]`を値に持つインスタンス変数を定義するとviewから使えるようになります。\n\ncontroller\n\n```\n\n ...\n def show\n @id = params[:id]\n end\n \n```\n\nview\n\n```\n\n <h1><%= @id %></h1>\n \n```\n\nただ、`link_to`に`params[:id]`を渡したいとのことですが、そのままidをviewに渡すのではなく\n\n 1. controllerで指定されたidを持つレコードを`find`\n 2. 返却されたオブジェクトをインスタンス変数として定義\n 3. viewで`<model>_path(@<instance_variable>)`でURLを生成\n\nというやり方が一般的かと思われます。\n\nrails tutorialsの例([Rails のルーティング | Rails\nガイド](https://railsguides.jp/routing.html#%E3%82%B3%E3%83%BC%E3%83%89%E3%81%8B%E3%82%89%E3%83%91%E3%82%B9%E3%82%84url%E3%82%92%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B))を参考にすると、\n\nroute\n\n```\n\n get '/patients/:id', to: 'patients#show', as: 'patient'\n \n```\n\ncontroller\n\n```\n\n @patient = Patient.find(params[:id])\n \n```\n\nview\n\n```\n\n <%= link_to 'Patient Record', patient_path(@patient) %>\n \n```\n\nという具合にですね。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T02:19:01.447", "id": "51746", "last_activity_date": "2019-01-06T02:19:01.447", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31669", "parent_id": "51745", "post_type": "answer", "score": 4 } ]
51745
51746
51746
{ "accepted_answer_id": null, "answer_count": 1, "body": "`find` で取得した長いファイルパスを `xargs` で取り扱いたいのですが、-Iオプションが機能しません。\n\nディレクトリ構造: \n[![パスの長いディレクトリ構造](https://i.stack.imgur.com/1Gwhb.png)](https://i.stack.imgur.com/1Gwhb.png)\n\n実行したコマンド\n\n```\n\n path=\"あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも\"\n echo \"path: ${path}\"\n find \"${path}\" -mindepth 1 -maxdepth 1 -print0 | xargs -0 -n1 -P10 echo\n find \"${path}\" -mindepth 1 -maxdepth 1 -print0 | xargs -0 -n1 -P10 -I {} bash -c \"echo {}\"\n \n```\n\n実行結果\n\n```\n\n $ bash ./test.sh\n path: あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも\n あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/.DS_Store\n あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも/あいうえおかきくけこさしすせそたちつてとなにぬねのまみむめも\n {}\n {}\n \n```\n\n上記のように置き換えが機能せず、なぜか `{}` がそのまま表示されてしまいます。 \nどうしてでしょうか?\n\n実行環境はmasOS Sierra 10.12.6です。 \nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T04:49:57.673", "favorite_count": 0, "id": "51748", "last_activity_date": "2019-01-06T08:40:43.530", "last_edit_date": "2019-01-06T08:15:38.480", "last_editor_user_id": "26110", "owner_user_id": "26110", "post_type": "question", "score": 2, "tags": [ "bash" ], "title": "xargsの-Iオプションが機能しなくなる時がある", "view_count": 192 }
[ { "body": "macOSのxargsでは、-Iオプションで置換した後の文字列は255bytesが上限のようです。 \n`man xargs` によれば以下の通り。\n\n```\n\n I replstr\n Execute utility for each input line, replacing one or more occurrences of replstr in up to replacements (or 5 if no -R flag is specified) arguments to utility with the entire line of input. The\n resulting arguments, after replacement is done, will not be allowed to grow beyond 255 bytes; this is implemented by concatenating as much of the argument containing replstr as possible, to the\n constructed arguments to utility, up to 255 bytes. The 255 byte limit does not apply to arguments to utility which do not contain replstr, and furthermore, no replacement will be done on utility\n itself. Implies -x.\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T08:21:24.927", "id": "51751", "last_activity_date": "2019-01-06T08:40:43.530", "last_edit_date": "2019-01-06T08:40:43.530", "last_editor_user_id": "26110", "owner_user_id": "26110", "parent_id": "51748", "post_type": "answer", "score": 5 } ]
51748
null
51751
{ "accepted_answer_id": null, "answer_count": 1, "body": "ターミナル上では実行できるのですが、VScode上で実行すると、メンバ参照の際に、エラーが出てしまいます。\n\n### 確認したこと\n\n * `python -m tkinter` でウィンドウが表示されること(バージョンは、8.6でした)\n * ターミナル上で以下のコードで正しく実行できること\n``` import tkinter\n\n \n root = tkinter.Tk()\n root.mainloop()\n \n```\n\n * 同じコードをVScodeで実行すると以下エラーがでること\n``` $ C:/Users/kento-\nhayakawa/AppData/Local/Programs/Python/Python37-32/python.exe\nc:/Git/cellautomata/cellautomata/tkinter.py\n\n Traceback (most recent call last):\n File \"cellautomata/tkinter.py\", line 4, in <module>\n import tkinter\n File \"C:\\Git\\cellautomata\\cellautomata\\tkinter.py\", line 6, in <module>\n root = tkinter.Tk()\n AttributeError: module 'tkinter' has no attribute 'Tk'\n \n```\n\n### 環境\n\n * Python3.7.2\n``` $ which python\n\n /c/Users/kento-hayakawa/AppData/Local/Programs/Python/Python37-32/python\n \n```\n\n * Windows\n\n似たような質問をいくつか探してみたのですが、解決出来ませんでした。。。 \nお手数をおかけしますが、解決方法を教えていただけると幸いです。 \nよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T05:02:46.007", "favorite_count": 0, "id": "51749", "last_activity_date": "2022-01-26T03:03:20.590", "last_edit_date": "2019-01-06T07:07:16.653", "last_editor_user_id": "3060", "owner_user_id": "31679", "post_type": "question", "score": 1, "tags": [ "python", "python3", "windows", "vscode", "tkinter" ], "title": "tkinterのメンバ参照に失敗する", "view_count": 770 }
[ { "body": "入力・編集している作業中のファイル名が tkinter.py ではないですか? \nそれならばそれを別の名前にしてみましょう。\n\n* * *\n\nこの投稿は @kunif\nさんの[コメント](https://ja.stackoverflow.com/questions/51749/#comment54023_51749)などを元に編集し、[コミュニティWiki](https://ja.meta.stackoverflow.com/q/1583)として投稿しました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2021-02-05T11:39:14.467", "id": "73817", "last_activity_date": "2021-02-05T11:39:14.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "51749", "post_type": "answer", "score": 1 } ]
51749
null
73817
{ "accepted_answer_id": "51755", "answer_count": 1, "body": "unityを用いてwindows10でゲームの開発を始めました。 \niosでの実機確認をするため手元のiphone SEにapp storeからunity rmeote 5というアプリをインストールしました。 \nしかしwindowsとiphoneをusbケーブルでつないで然る設定を行ってもiphone側は反応しません。\n\n主に参考にしたサイトは[こちら](https://qiita.com/cs1000/items/e7ce11b560c1113f32f5)です。\n\nどなたかわかる方やこうではないか、などありましたらよろしくお願いします。 \n一応参考のために自分が今まで行った設定などを箇条書きで記します。\n\n * iphoneとwindows PCをusbケーブルで接続(itunesがでるので正常に接続できていると思います。)\n * unity側で「Edit」「Project Settings」「Editor」を選択。\n * 「Device」を選択肢の「Any iOS Device」に設定。\n * Gameに切り替えて「Play」ボタンをクリック。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T09:02:30.837", "favorite_count": 0, "id": "51752", "last_activity_date": "2019-01-06T11:11:55.357", "last_edit_date": "2019-01-06T11:11:55.357", "last_editor_user_id": "3060", "owner_user_id": "29853", "post_type": "question", "score": 1, "tags": [ "ios", "c#", "unity3d" ], "title": "unity remote 5を用いたwindowsからiosへの実機検証", "view_count": 3789 }
[ { "body": "一応この [マニュアル](https://docs.unity3d.com/ja/2018.3/Manual/UnityRemote5.html)\nの記述を見ると条件は満たしていそうですね。\n\n> ノート: Unity Remoteを使用するには、開発マシンにAndroid SDKを実装する必要があります。\n>\n> Unity Remoteは現在Androidデバイス(WindowsやOSXとUSBで接続)とiOSデバイス(OS\n> XやiTUnesがインストールされたWindowsとUSBで接続した iPhone、iPad、iPod touch、Apple TV)\n> をサポートします。\n\n参考サイトで使われているであろう2018.1版でも上記のサポートされているという記述がある \nので、Macでないと使用できないという、参考サイトの注意事項と整合性が取れないですが、 \n何かまだ条件があるのかも。\n\nこんな記事もあるので、何か参考になれば。 \n[【Unity】Unity Remote 5\nが接続されているかどうか確認する方法](http://baba-s.hatenablog.com/entry/2018/05/07/103000)\n\n> Unity Remote 5 が接続されているかどうかは \n> UnityEditor.EditorApplication.isRemoteConnected \n> このプロパティで確認できます しかし、UnityEditor 名前空間を使用する関係で、 \n> そのまま使うとアプリのビルド時にエラーが発生してしまうので、...\n\n[【Unity】「Unity Remote\n5」の使い方](https://vracademy.jp/vrunner/2017/08/unityremote/)\n\n> 2-2. iOS (Windows) \n> 1\\. 【Unity】iOS Build Supportをインストール \n> 2\\. 【Unity】Edit > Project Settings > Editor > Remote:Deviceで「iPhone 〜」を選択 \n> 3\\. 【PC】iTuensをインストール (その中の Apple Mobile Device Support が必要)\n\nそして一連のQ&Aの最後に以下が書いてあります。\n\n> 上記を試してみても動作しない場合は、Android・iOS用でビルドを行える環境を用意しましょう。ビルドが成功していれば、Unity Remote 5\n> はほぼ確実に動作すると思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T10:03:34.847", "id": "51755", "last_activity_date": "2019-01-06T10:56:58.173", "last_edit_date": "2019-01-06T10:56:58.173", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "51752", "post_type": "answer", "score": 0 } ]
51752
51755
51755
{ "accepted_answer_id": "51781", "answer_count": 2, "body": "Googleでのページインデックスがおかしくなっていて、その解決のために301リダイレクトをしたい、という状況です。\n\n具体的には、本来 \n(A)`http://example.com/bbb/1.html` \nであるところ、 \n(B)`http://example.com/bbb//1.html` \nとインデックスしているページが100ページ位あります。\n\n`http://example.com/bbb/ccc/2.html`が、 \n`http://example.com/bbb//ccc/2.html` \nとなっているページもあります。\n\n(B)にアクセスされたら(A)に飛ばしたく、 \nhtaccessに以下を記述したのですがうまくいきません。\n\n```\n\n RewriteEngine on\n RewriteBase /\n RewriteRule ^bbb//(.*)$ /bbb/$1 [R=301,L]\n \n```\n\n※上記htaccessは`http://example.com/`に置いてます。\n\n適切な記述をご教示頂けましたら幸いです。 \nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T09:04:59.347", "favorite_count": 0, "id": "51753", "last_activity_date": "2019-01-07T23:40:53.803", "last_edit_date": "2019-01-07T00:12:39.817", "last_editor_user_id": "2238", "owner_user_id": "31681", "post_type": "question", "score": 3, "tags": [ ".htaccess" ], "title": "htaccessによる301リダイレクトの設定が動作していない", "view_count": 97 }
[ { "body": "<https://teratail.com/questions/148648> が参考になると思います。 \n`RedirectMatch` を試してみてください。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T05:27:19.190", "id": "51781", "last_activity_date": "2019-01-07T05:27:19.190", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4603", "parent_id": "51753", "post_type": "answer", "score": 0 }, { "body": "```\n\n RewriteRule ^bbb//(.*)$ /bbb/$1 [R=301,L]\n \n```\n\nこれは\n\n```\n\n RewriteRule ^bbb//(.*)$ bbb/$1 [R=301,L]\n \n```\n\nこれでも解決するのかなと思いました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T23:40:53.803", "id": "51807", "last_activity_date": "2019-01-07T23:40:53.803", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29216", "parent_id": "51753", "post_type": "answer", "score": 0 } ]
51753
51781
51781
{ "accepted_answer_id": null, "answer_count": 1, "body": "`short.sequ.txt`から`>YP`で始まる行をそのままprintし、その次の行から空白を認識するまでの文字数をカウントする。 \nこの作業を繰り返し行い、最大の文字数と最大の文字数の時の`>YP`の行を最終的にprintしたいと思ってます。 \n最大値が見つかるたびにmax_lenとmax_proteinを更新したいです。(最小値も同じく)\n\nglobal変数を用いて作成したのですが、できればglobal変数を使わずにこのようなコードを書きたいと思ってます。 \nその場合、global変数をどういったものに変えたらいいのかわからないので教えていただきたいです。 \n宜しくお願い致します。\n\n```\n\n with open(\"short.sequ.txt\") as f:\n \n max_len = 0\n max_protein = \"\"\n \n min_len = 10000000000000\n min_protein = \"\"\n \n def change(protein, seq):\n global max_len,max_protein,min_len,min_protein\n seq_len = len(seq)\n if seq_len == 0:\n return\n \n else:\n print([seq_len])\n \n if seq_len > max_len:\n max_len,max_protein,min_len,min_protein = seq_len,protein,seq_len,protein\n \n if seq_len < min_len:\n min_len,min_protein = seq_len,protein\n \n \n a_line = \"\"\n a_seq = \"\"\n \n for line in f:\n strip_line = line.rstrip()\n if strip_line.startswith(\">\"):\n a_line = strip_line\n change(a_line, a_seq)\n a_seq = \"\"\n print(strip_line+'\\n')\n else:\n #A = [len(a_seq+strip_line)]\n a_seq += strip_line\n msg1 = \"最大アミノ酸エントリ:\"\n msg2 = \"長さ:\"\n msg3 = \"最小アミノ酸エントリ:\"\n print(msg1,max_protein,msg2,max_len)\n print(msg3,min_protein,msg2,min_len)\n \n```\n\n**short.sequ.txt**\n\n```\n\n >YP_009518834.1 putative uncharacterized protein YjiT [Escherichia coli str. K-12 substr. MG1655]\n MGQSEYISWVKCTSWLSNFVNLRGLRQPDGRPLYEYHATNDEYTQLTQLLRAVGQSQSNICNRDFAACFV\n LFCSEWYRRDYERQCGWTWDPIYKKIGISFTATELGTIVPKGMEDYWLRPIRFYESERRNFLGTLFSEGG\n LPFRLLKESDSRFLAVFSRILGQYEQAKQSGFSALSLARAVIEKSALPTVFSEDTSVELISHMADNLNSL\n VLTHNLINHKEPVQQLEKVHPTWRSEFPIPLDDETGTHFLNGLLCAASVEAKPRLQKNKSTRCQFYWSEK\n HPDELRVIVSLPDEVSFPVTSEPSTTRFELAICEDGEEVSGLGPAYASLENRQATVRLRKSEVRFGRQNP\n SAGLSLVARAGGMIVGSIKLDDSEIAIGEVPLTFIVDADQWLLQGQASCSVRSSDVLIVLPRDNSNVAGF\n DGQSRAVNVLGLKALPVKGCQDVTVTANETYRIRTGREQISIGRFALNGKRASWVCHPDETFIGVPKVIS\n TLPDIQSIDVTRYTC\n \n >YP_009518833.1 uncharacterized protein YtiA [Escherichia coli str. K-12 substr. MG1655]\n MKEFLFLFHSTVGVIQTRKALQAAGMTFRVSDIPRDLRGGCGLCIWLTCPPGEEIQWVIPGLTESIYCQQ\n DGVWRCIAHYGVSPR\n \n >YP_009518832.1 iraD leader peptide [Escherichia coli str. K-12 substr. MG1655]\n MENEHQYSGARCSGQAAYVAKRQECAK\n \n >YP_009518831.1 protein YtiD [Escherichia coli str. K-12 substr. MG1655]\n MADYAEINNFPPELSSSGDKYFHLRNYSEYSEYTSGFFLSLMIFIKS\n \n >YP_009518830.1 protein YtiC [Escherichia coli str. K-12 substr. MG1655]\n MPVNGIFDVFDMLSIYIIYKLIVSNNTWLIMRK\n \n >YP_009518829.1 putative YjfA [Escherichia coli str. K-12 substr. MG1655]\n MHMVTYPCLTSRRFQLALIHRRVVDKRTSMHSRTASESTGARIHRPWCARHQVRPAWRCQYDKLHRVPFR\n SPELRLDSGPGYTTGSYRY\n \n```", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T09:25:42.580", "favorite_count": 0, "id": "51754", "last_activity_date": "2019-01-06T13:02:19.733", "last_edit_date": "2019-01-06T13:02:19.733", "last_editor_user_id": "3060", "owner_user_id": "31682", "post_type": "question", "score": 1, "tags": [ "python" ], "title": "global変数を使わずにコードを機能させたい", "view_count": 299 }
[ { "body": "以下では、`short.sequ.txt` の内容を空行(`\\n\\n`)で分割して、個々の protein sequence の長さでソートしています。\n\n```\n\n import re\n \n msg1 = \"最大アミノ酸エントリ:\"\n msg2 = \"長さ:\"\n msg3 = \"最小アミノ酸エントリ:\"\n \n with open(\"short.sequ.txt\") as f:\n assoc = {}\n for p in f.read().split(\"\\n\\n\"):\n if not re.match('^>YP_', p): continue\n arr = p.split(\"\\n\")\n assoc[arr[0]] = sum(map(len, arr[1:]))\n sa = sorted(assoc.items(), key=lambda x: x[1])\n \n print('{} {}\\n{} {}'.format(msg1, sa[-1][0], msg2, sa[-1][1]))\n print('{} {}\\n{} {}'.format(msg3, sa[0][0], msg2, sa[0][1]))\n \n =>\n 最大アミノ酸エントリ: >YP_009518834.1 putative uncharacterized protein YjiT [Escherichia coli str. K-12 substr. MG1655]\n 長さ: 505\n 最小アミノ酸エントリ: >YP_009518832.1 iraD leader peptide [Escherichia coli str. K-12 substr. MG1655]\n 長さ: 27\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T12:06:15.737", "id": "51758", "last_activity_date": "2019-01-06T12:39:13.063", "last_edit_date": "2019-01-06T12:39:13.063", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "51754", "post_type": "answer", "score": 2 } ]
51754
null
51758
{ "accepted_answer_id": "51793", "answer_count": 1, "body": "このようなjsonがあった時に、\n\n```\n\n {\n \"taro\": {\n \"favorite\": {\n \"fruits\": [\n \"orange\"\n ]\n }\n },\"jiro\": {\n \"favorite\": {\n \"fruits\": [\n \"apple\",\n \"banana\",\n \"orange\"\n ]\n }\n }\n }\n \n```\n\njqで以下のようなjson配列を作り直すには、どのようなコマンドを打てば良いでしょうか。\n\n```\n\n {\n \"name\": \"taro\",\n \"favorite_fruit\":[\n \"orange\"\n ]\n },{\n \"name\": \"jiro\",\n \"favorite_fruit\": [\n \"apple\",\n \"banana\",\n \"orange\"\n ]\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T12:57:29.530", "favorite_count": 0, "id": "51759", "last_activity_date": "2019-01-07T09:25:10.807", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13492", "post_type": "question", "score": 3, "tags": [ "jq" ], "title": "jqでjsonからjson配列を作り直す", "view_count": 506 }
[ { "body": "`to_entries`から`*`演算子で再起マージが使えるんでないかと。\n\n```\n\n $ <test.json jq '[to_entries[] | {name: .key} * {favorite_fruit: .value.favorite.fruits}]'\n [\n {\n \"name\": \"taro\",\n \"favorite_fruit\": [\n \"orange\"\n ]\n },\n {\n \"name\": \"jiro\",\n \"favorite_fruit\": [\n \"apple\",\n \"banana\",\n \"orange\"\n ]\n }\n ]\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T09:25:10.807", "id": "51793", "last_activity_date": "2019-01-07T09:25:10.807", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "62", "parent_id": "51759", "post_type": "answer", "score": 2 } ]
51759
51793
51793
{ "accepted_answer_id": null, "answer_count": 1, "body": "virtual box とvagrantをインストールした後、vagrant box add laravel/homestead \nと打ったがhomestead のインストールがうまくいきません。 \n5回くらい試しましたが、同じエラーが出ます。 \n通信速度が遅い環境にいるのでそれが原因かもですが、タイムアウトの際は errno60 が出る \nという情報もあり謎です。 \n/Users/apple/.vagrant.d/tmp 配下のファイルは毎回消してます。\n\n以下バージョン情報です。 \nmacOS:10.13.6 \nvagrant:2.2.2 \nopenSSL:LibreSSL 2.2.7\n\n他に思い当るものがなく手詰りしてしまってます \n参考情報でもなんでもかまいませんので、書込みいただけると助かります。 \n宜しくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T13:23:36.407", "favorite_count": 0, "id": "51760", "last_activity_date": "2019-01-07T00:30:13.570", "last_edit_date": "2019-01-06T15:02:27.927", "last_editor_user_id": "31691", "owner_user_id": "31691", "post_type": "question", "score": 0, "tags": [ "macos", "laravel", "vagrant", "openssl" ], "title": "Homestead をダウンロードするとOpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54と出る", "view_count": 226 }
[ { "body": "解決しました! \nおそらく原因は通信速度が遅いことによるタイムアウトか、 \nMacがスリープになってしまったことによる通信断でした。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T00:30:13.570", "id": "51769", "last_activity_date": "2019-01-07T00:30:13.570", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31691", "parent_id": "51760", "post_type": "answer", "score": 2 } ]
51760
null
51769
{ "accepted_answer_id": null, "answer_count": 2, "body": "はじめまして。 \n先月からUnityを勉強し始め、一通り終わったためにRPGの戦闘シーンを作ろうと試みているところです。\n\n以下、質問内容になります。\n\n<ゲームの仕様(質問における前提条件)> \n・味方キャラクターは3人(A、B、C)、敵キャラクターは1人(D)。 \n・攻撃の順番はA→B→C→D\n\n【質問内容】\n\n今回、if文、switch文、for文を用いて以下のプログラムを作りました。\n\n```\n\n void Update(){\n for(n=1;n<5;n++){\n switch(n){\n case 1:\n if(Input.GetKeyDown(KeyCode.P)){\n Debug.Log(\"A attack\");\n break;\n }\n case 2:\n if(Input.GetKeyDown(KeyCode.P)){\n Debug.Log(\"B attack\");\n break;\n }\n case 3:\n if(Input.GetKeyDown(KeyCode.P)){\n Debug.Log(\"C attack\");\n break;\n }\n case 4:\n if(Input.GetKeyDown(KeyCode.P)){\n Debug.Log(\"D attack\");\n break;\n }\n }\n }\n }\n \n```\n\n理想としては、まずAの戦闘ターンでPボタンを押すとAが攻撃。 \nその後Bの戦闘ターンでPボタンを押すとBが攻撃。CとDが後に続く・・・という流れです。\n\nしかしながら、実際にプログラムを実行すると、Pボタンを押すと、ABCD全てのcaseが実行されてしまい、Console画面には\"各キャラ\nattack\"が表示されてしまいました。\n\nこれを各キャラクターの処理を一つずつ実行したいのですが、どうかご教授いただけないでしょうか?\n\n【対処法?】\n\nこの対処法をネット上で調べた結果、Console.ReadKey();やConsoleKeyInfoを用いるとのことだったのですが、試したところエラーが出てしまい行き詰まってしまいました。 \n(エラー内容は\"All compiler errors have to be fixed before you can enter playmode!)\n\n以上、宜しくお願い致します。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T16:17:12.890", "favorite_count": 0, "id": "51763", "last_activity_date": "2022-05-03T14:08:50.783", "last_edit_date": "2019-01-06T23:15:30.903", "last_editor_user_id": "19110", "owner_user_id": "31693", "post_type": "question", "score": 1, "tags": [ "c#", "unity3d", "unity2d" ], "title": "RPGゲームの戦闘シーンにおいて、ターン制の攻撃を実現したいです。", "view_count": 2923 }
[ { "body": "とりあえず質問に記載されているスクリプトの動きについて説明します。 \n`Update()`は毎フレーム呼ばれる関数なので、この関数の中に書いた処理は毎フレーム実行されることになります。 \n質問者さんのスクリプトでは、`Update()`の中で`for`文を呼んでいるので、`switch(n)\n~`の全ての`case`は毎フレームで全て実行されることになります。 \n`Input.GetKeyDown()`はキーが押された瞬間の1フレームの間ずっと`true`なので、 \nこのスクリプトではA~Dの全てのケースが実行されてしまうわけです。\n\nまた、対処法についてですがUnityではConsole.ReadKey()という関数は用いません。 \nエラーが出ているのは存在しない関数(正確にはConsoleが存在しない)を呼び出そうとしているからでしょう。\n\n質問者さんが実現したいターン制のシステムには現在の形だと難しいかと思います。 \n「Unity ターン制バトル」などで検索していただくと、わかりやすい記事がいくつか見つかると思うので是非検討してみてください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T03:58:07.350", "id": "51815", "last_activity_date": "2019-01-08T03:58:07.350", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31396", "parent_id": "51763", "post_type": "answer", "score": 1 }, { "body": "メンバ変数で現在のアタックステータス(誰が攻撃しているのか)を保持して、pボタンを押すごとにステータスを変化させてみたらどうでしょうか?\n\n例えば、下記のようなコードでどうでしょうか。\n\n```\n\n private int n = 1;\n \n void Update(){\n if(Input.GetKeyDown(KeyCode.P)){\n switch(n){\n case 1:\n Debug.Log(\"A attack\");\n break;\n case 2:\n Debug.Log(\"B attack\");\n break;\n case 3:\n Debug.Log(\"C attack\");\n break;\n case 4:\n Debug.Log(\"D attack\");\n break;\n }\n n++;\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T10:09:50.810", "id": "51863", "last_activity_date": "2019-01-10T10:09:50.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29533", "parent_id": "51763", "post_type": "answer", "score": 1 } ]
51763
null
51815
{ "accepted_answer_id": "51768", "answer_count": 2, "body": "pythonでjsonファイルを読み込みたいのですが、複数のファイルを読み込む方法がわかりません。\n\n読み込みたいファイルが \n`right_000000000000_keypoints.json`から \n`right_000000000100_keypoints.json`まであるとしたら、 \nどのようにプログラムを組めばよろしいでしょうか。\n\nfor文と`str()`を使うというのを聞いたことがあるのですが、上手くいきません。 \n一応自分なりに考えたプログラムを貼っておきます。\n\n```\n\n import json\n \n i = 000000000000\n \n for i in range(100):\n # ファイルを開く\n str_count=str(i)\n json_file = open(\"right_\" + str_count + \"_keypoints.json\")\n \n # JSONとして読み込む\n json_obj = json.load(json_file)\n \n # 表示\n print(json_obj)\n \n```\n\n行き詰っているのでご教授お願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T17:34:33.900", "favorite_count": 0, "id": "51764", "last_activity_date": "2019-01-07T05:51:56.493", "last_edit_date": "2019-01-06T23:14:59.657", "last_editor_user_id": "19110", "owner_user_id": "31694", "post_type": "question", "score": 1, "tags": [ "python", "python3", "json" ], "title": "pythonで複数のjsonファイルを読み込む方法", "view_count": 1619 }
[ { "body": "str_count=str(i)に対してrjust()またはzfill()を適用しましょう。\n\n```\n\n str_count=str(i).rjust(12,'0')\n \n```\n\nまたは\n\n```\n\n str_count=str(i).zfill(12)\n \n```\n\n最初の引数は適用後の桁数、rjustの第二引数は付加する文字です。\n\nその他に、今の`for ... range`だと100が範囲に入りません。101にしましょう。\n\n```\n\n for i in range(101):\n \n```\n\nさらに、ファイルが無かった場合とか、読み込みでエラーが発生した場合の検出と対処が必要です。 \ntry except とか、with 等のキーワードで検索して対処してください。\n\n最後に、open したファイルは for ループの中で close しましょう。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-06T23:19:54.013", "id": "51768", "last_activity_date": "2019-01-06T23:19:54.013", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "51764", "post_type": "answer", "score": 1 }, { "body": "* `\"\".format()`を使う \n * 分かりやすくなる\n * `with` syntaxを使う \n * [@nekketsuuu♦](https://ja.stackoverflow.com/users/19110/nekketsuuu) 氏の指摘の通り、ファイルオープンをブロック化することで`close`などの考慮を楽に出来る\n\nという点を踏まえて、以下のようにやると良さそうです。\n\n```\n\n for file_name in [\"right_{:012d}_keypoints.json\".format(i) for i in range(101)]:\n with open(file_name) as f:\n # ...\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T02:06:52.753", "id": "51772", "last_activity_date": "2019-01-07T05:51:56.493", "last_edit_date": "2019-01-07T05:51:56.493", "last_editor_user_id": "29826", "owner_user_id": "29826", "parent_id": "51764", "post_type": "answer", "score": 1 } ]
51764
51768
51768
{ "accepted_answer_id": null, "answer_count": 1, "body": "ec2のインスタンスを再起動してから、以下のエラーが出ていました。\n\nMISCONF Redis is configured to save RDB snapshots, but is currently not able\nto persist on disk. Commands that may modify the data set are disabled. Please\ncheck Redis logs for details about the error.\n\nこれを解消するために様々なことを行いましたが、どの方法でも復旧できなかったため、一時的な対策として \nredis-cliから\n\nconfig set stop-writes-on-bgsave-error no\n\nを叩くと、すべてうまく行くようになりました。\n\nただこの方法はあくまでも一時的な方法というようにいくつかのサイトで書いてありました。\n\nこれを恒久的な設定に変えるには、どのようにすれば良いのでしょうか?お手数ですが、何かご教示いただけることがあれば何卒よろしくおねがいします。\n\n* * *\n\n環境 \nmacOS High Sierra(バージョン10.13.6) \nruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin17] \nRails 4.2.6 \nredis (4.0.1) \nredis (4.0.1) \nredis-actionpack (5.0.2) \nactionpack (>= 4.0, < 6) \nredis-rack (>= 1, < 3) \nredis-store (>= 1.1.0, < 2) \nredis-activesupport (5.0.4) \nactivesupport (>= 3, < 6) \nredis-store (>= 1.3, < 2) \nredis-namespace (1.6.0) \nredis (>= 3.0.4) \nredis-rack (2.0.4) \nrack (>= 1.5, < 3) \nredis-store (>= 1.2, < 2) \nredis-rails (5.0.2) \nredis-actionpack (>= 5.0, < 6) \nredis-activesupport (>= 5.0, < 6) \nredis-store (>= 1.2, < 2) \nredis-store (1.4.1) \nredis (>= 2.2, < 5) \ncapistrano (3.10.1) \ncapistrano-sidekiq (1.0.0) \ncapistrano-upload-config (0.8.2)\n\n* * *\n\n/usr/local/redis-3.2.5/redis.conf\n\nbind 127.0.0.1 \nprotected-mode yes \nport 6379 \ntcp-backlog 511 \ntimeout 0 \ntcp-keepalive 300 \ndaemonize no \nsupervised no \npidfile /var/run/redis_6379.pid \nloglevel notice \nlogfile \"\" \ndatabases 16 \nstop-writes-on-bgsave-error yes \nrdbcompression yes \nrdbchecksum yes \ndbfilename dump.rdb \ndir ./ \nslave-serve-stale-data yes \nslave-read-only yes \nrepl-diskless-sync no \nrepl-diskless-sync-delay 5 \nrepl-disable-tcp-nodelay no \nslave-priority 100 \nappendonly no \nappendfilename \"appendonly.aof\" \nappendfsync everysec \nno-appendfsync-on-rewrite no \nauto-aof-rewrite-percentage 100 \nauto-aof-rewrite-min-size 64mb \naof-load-truncated yes \nlua-time-limit 5000 \nslowlog-log-slower-than 10000 \nslowlog-max-len 128 \nlatency-monitor-threshold 0 \nnotify-keyspace-events \"\" \nhash-max-ziplist-entries 512 \nhash-max-ziplist-value 64 \nlist-max-ziplist-size -2 \nlist-compress-depth 0 \nset-max-intset-entries 512 \nzset-max-ziplist-entries 128 \nzset-max-ziplist-value 64 \nhll-sparse-max-bytes 3000 \nactiverehashing yes \nclient-output-buffer-limit normal 0 0 0 \nclient-output-buffer-limit slave 256mb 64mb 60 \nclient-output-buffer-limit pubsub 32mb 8mb 60 \naof-rewrite-incremental-fsync yes\n\n* * *\n\nredis-cliでinfo\n\nMemory \nused_memory:764200 \nused_memory_human:746.29K \nused_memory_rss:4902912 \nused_memory_rss_human:4.68M \nused_memory_peak:2360784 \nused_memory_peak_human:2.25M \ntotal_system_memory:4145164288 \ntotal_system_memory_human:3.86G \nused_memory_lua:37888 \nused_memory_lua_human:37.00K \nmaxmemory:0 \nmaxmemory_human:0B \nmaxmemory_policy:noeviction \nmem_fragmentation_ratio:6.42 \nmem_allocator:jemalloc-4.0.3\n\nPersistence \nloading:0 \nrdb_changes_since_last_save:618 \nrdb_bgsave_in_progress:0 \nrdb_last_save_time:1546658955 \nrdb_last_bgsave_status:err \nrdb_last_bgsave_time_sec:0 \nrdb_current_bgsave_time_sec:-1 \naof_enabled:0 \naof_rewrite_in_progress:0 \naof_rewrite_scheduled:0 \naof_last_rewrite_time_sec:-1 \naof_current_rewrite_time_sec:-1 \naof_last_bgrewrite_status:ok \naof_last_write_status:ok\n\nCPU \nused_cpu_sys:433.97 \nused_cpu_user:525.88 \nused_cpu_sys_children:0.00 \nused_cpu_user_children:0.00z\n\n* * *", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T00:49:44.637", "favorite_count": 0, "id": "51770", "last_activity_date": "2019-01-07T02:46:36.630", "last_edit_date": "2019-01-07T01:06:41.150", "last_editor_user_id": "2238", "owner_user_id": "29589", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "rubygems", "redis" ], "title": "一時的なconfig set stop-writes-on-bgsave-error noを恒久的な設定に変えたい", "view_count": 157 }
[ { "body": "まずredisのカレントワーキングディレクトリを調べる必要がありました。 \nPROCファイルシステムからredisのCWDを調べて、このディレクトリの権限をUID\n501による書き込みを可能にしてあげるとうまく機能を使えるようになりました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T02:46:36.630", "id": "51776", "last_activity_date": "2019-01-07T02:46:36.630", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29589", "parent_id": "51770", "post_type": "answer", "score": 0 } ]
51770
null
51776
{ "accepted_answer_id": null, "answer_count": 1, "body": "テーブルA, B, Cがあり、特定のCに関連するAを求めたい。\n\n```\n\n SELECT * \n FROM A a\n INNER JOIN B b\n ON b.id = a.b_id\n LEFT JOIN C c\n ON c.b_id = b.id AND c.type = 'hogehoge'\n WHERE c.id IS NULL\n \n```\n\nこのとき、 `c.type = 'hogehoge'` 以外の type も抽出されてしまいます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T01:59:54.820", "favorite_count": 0, "id": "51771", "last_activity_date": "2019-01-07T06:56:23.513", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12896", "post_type": "question", "score": 3, "tags": [ "mysql" ], "title": "mysqlでleft joinした後にid is null としたとき、join の条件が消えてしまう", "view_count": 871 }
[ { "body": "`type = 'hogehoge'`のレコードのみを抽出したいのであれば、`c.type =\n'hogehoge'`を結合条件ではなく抽出条件にしましょう。\n\n```\n\n SELECT * \n FROM A a\n INNER JOIN B b\n ON b.id = a.b_id\n LEFT JOIN C c\n ON c.b_id = b.id\n WHERE c.type = 'hogehoge'\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T02:47:13.117", "id": "51777", "last_activity_date": "2019-01-07T06:56:23.513", "last_edit_date": "2019-01-07T06:56:23.513", "last_editor_user_id": "2238", "owner_user_id": "2238", "parent_id": "51771", "post_type": "answer", "score": 3 } ]
51771
null
51777
{ "accepted_answer_id": null, "answer_count": 1, "body": "jsonファイルの中身が、\n\n```\n\n {\n \"version\": 1.2,\n \"people\": [\n {\n \"pose_keypoints_2d\": [\n 570.599,\n 272.875,\n ...,\n 292.453,\n 0.616146\n ],\n \"face_keypoints_2d\": [\n 416.352,\n 227.967,\n ...,\n 213.009,\n 0.822855\n ],\n \"hand_left_keypoints_2d\": [],\n \"hand_right_keypoints_2d\": [],\n \"pose_keypoints_3d\": [],\n \"face_keypoints_3d\": [],\n \"hand_left_keypoints_3d\": [],\n \"hand_right_keypoints_3d\": []\n }\n ]\n }\n \n```\n\nこのような中身の時にface_keypoints_2d\"を指定したいのですが、エラーになってしまいます。 \nおそらく原因は一番最初の[と一番最後の]だとおもい、その部分を削除したら上手く読み込めました。 \nなんとかこの部分を削除しないで中身を指定する方法はないでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T02:17:48.223", "favorite_count": 0, "id": "51774", "last_activity_date": "2019-01-07T04:42:27.750", "last_edit_date": "2019-01-07T02:41:36.467", "last_editor_user_id": "29826", "owner_user_id": "31694", "post_type": "question", "score": 0, "tags": [ "python", "python3", "json" ], "title": "jsonファイルの中身の指定", "view_count": 3855 }
[ { "body": "エラーが `TypeError: list indices must be integers or slices, not str` であれば、 \n一番最初の[と一番最後の]で\"people\"の中身が配列になっているのに、配列としてアクセスしていないことが原因と予想されます。\n\n下記のサンプルコードでjsonを書き換えずに\"face_keypoints_2d\"を取得できます。 \nサンプルコードのprint文では`j[\"people\"][0][\"face_keypoints_2d\"]`と記述して、\"people\"配列の先頭にアクセスしています。\n\n```\n\n import json\n # jsonの不要な項目は省略しています\n s = '''{\"version\":1.2,\"people\":[{\"pose_keypoints_2d\":[570.599,272.875,0.719388,0.616146],\n \"face_keypoints_2d\":[416.352,227.967,0.822855],\n \"hand_right_keypoints_3d\":[]}]}'''\n j = json.loads(s)\n print(j[\"people\"][0][\"face_keypoints_2d\"])\n # [416.352, ...] が出力される\n \n```\n\n* * *\n\n**コメントでの追加質問について**\n\nファイル読み込み時には[類似質問](https://ja.stackoverflow.com/q/51764)の回答を参考にして`json.loads`を`json.load`に読み替えてください。 \n`json.loads`は _json文字列_ を、`json.load`は _ファイルパス_ をそれぞれ引数として受け取ります。\n\n`read_data = f.read()`として`read`を使うと`read_data`には文字列(string)型が入ります。 \njson型でなくstring型に対して`read_data['people']`の記述をすると下記の例外が発生します。\n\n> TypeError: string indices must be integers\n\nファイル読込時のサンプルコード:\n\n```\n\n import json\n with open(\"test.json\", \"r\") as f:\n j = json.load(f)\n print(j['people'][0]['face_keypoints_2d'])\n \n```\n\nエラーを再現できるコードや具体的なエラーの内容を記述していただくと的確な回答を得やすいと思います。\n\nコメントで質問を追加すると、質問がページ内に散在する上にコードのインデントも崩れて読みにくくなります。 \nそしてコメントを受けた回答者以外は回答しにくい状況にもなりますので、追加質問は **質問文を編集** するか別の質問として **新規投稿**\nすることをお勧めします。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T02:42:24.990", "id": "51775", "last_activity_date": "2019-01-07T04:42:27.750", "last_edit_date": "2019-01-07T04:42:27.750", "last_editor_user_id": "9820", "owner_user_id": "9820", "parent_id": "51774", "post_type": "answer", "score": 1 } ]
51774
null
51775
{ "accepted_answer_id": null, "answer_count": 1, "body": "`yarn run production`を実行すると、 \n途中までgulpは動いているような・・しかしエラーも出てきます。 \nこれはどうしてでしょうか?\n\n```\n\n C:\\Users\\User\\Documents\\Git2>yarn run production\n yarn run v1.3.2\n (node:12924) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.\n $ gulp scss && NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js\n [10:46:00] Using gulpfile ~\\Documents\\Git2\\gulpfile.js\n [10:46:00] Starting 'scss:pc'...\n [10:46:00] Starting 'scss:sp'...\n [10:46:01] Finished 'scss:pc' after 1.41 s\n [10:46:01] Finished 'scss:sp' after 1.41 s\n [10:46:01] Starting 'scss'...\n [10:46:01] Finished 'scss' after 41 μs\n 'node_modules' は、内部コマンドまたは外部コマンド、\n 操作可能なプログラムまたはバッチ ファイルとして認識されていません。\n Note: This command was run via npm module 'win-node-env'\n error Command failed with exit code 1.\n info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n \n```\n\n● 解決のためやってみたことは2点です。\n\n①[DEP0005]... で検索してみる\n\nこれはエラーではありません。バッファを作成するこの方法は推奨されないことを警告するものです。と。 \n<https://stackoverflow.com/questions/52165333/deprecationwarning-buffer-is-\ndeprecated-due-to-security-and-usability-issues>\n\n②'node_modules' は、内部コマンドまたは外部コマンド、..で検索してみる \n \n・パスを通していないのが問題? \nここに倣ってパス末尾の\\を削除し、コマンドプロンプトを再起動して再度実行しても変わらず。 \n<http://webdev.jp.net/windows-nodejs-path/>\n\n・winなので、パスのセパレータをバックスラッシュにすれば動く? \npackage.jsonの \"scripts\": { 以下を下記サイトにならって修正するも別のエラーになったので、これが原因ではないようです。 \n<http://iakio.hatenablog.com/entry/2013/12/08/175457>\n\n● 各バージョンは下記のようになっています。\n\n```\n\n C:\\Users\\User\\Documents\\Git2>node -v\n v10.14.2\n \n C:\\Users\\User\\Documents\\Git2>npm -v\n 6.5.0\n \n C:\\Users\\User\\Documents\\Git2>yarn -v\n 1.3.2\n \n C:\\Users\\User\\Documents\\Git2>gulp -v\n [10:45:09] CLI version 3.9.1\n [10:45:09] Local version 3.9.1\n \n```\n\npcのOSはWin10 Proです。 \nnodeについてはまるっきり初心者ですので、言葉足らずなところがございましたらご指摘下さい。\n\nどうぞ宜しくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T03:03:37.327", "favorite_count": 0, "id": "51778", "last_activity_date": "2019-09-06T07:00:36.067", "last_edit_date": "2019-01-07T06:34:04.917", "last_editor_user_id": "23994", "owner_user_id": "31703", "post_type": "question", "score": 0, "tags": [ "node.js", "gulp" ], "title": "'node_modules' は、内部コマンドまたは外部コマンド、 操作可能なプログラムまたはバッチ ファイルとして認識されていません。", "view_count": 6355 }
[ { "body": "質問者です。すみません \n結局windows なのが原因だったようで、package.jsonのpathのところにある” を\\でエスケープしてみたところ解決したようです。 \n閲覧くださった方々、ありがとうございます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T06:50:05.453", "id": "51784", "last_activity_date": "2019-01-07T06:50:05.453", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31705", "parent_id": "51778", "post_type": "answer", "score": 4 } ]
51778
null
51784
{ "accepted_answer_id": "51800", "answer_count": 1, "body": "プロジェクトを管理するサンプルアプリケーションを題材にRSpecの勉強をしています。\n\nサンプルアプリケーションは、プロジェクトを登録することができ、そのプロジェクトは完了済みかどうかのステータス(boolean型のcompleted)を持っています。\n\nプロジェクトの詳細画面には、完了ボタンがあり、完了ボタンを押すと、ステータスが完了済みになります。\n\nこの完了ボタンを押すときの、完了処理が失敗したときのフィーチャースペックを書いています。\n\nmodels/project.rb\n\n```\n\n class Project < ApplicationRecord\n def complete_pj\n update_attributes(completed: true)\n end\n end\n \n```\n\ncontrollers/projects_controller.rb\n\n```\n\n class ProjectsController < ApplicationController\n def complete\n if @project.complete_pj\n redirect_to @project, notice: \"Congratulations, this project is complete!\"\n else\n redirect_to @project, alert: \"Unable to complete project.\"\n end\n end\n end\n \n```\n\nspec/features/projects_spec.rb\n\n```\n\n require 'rails_helper'\n RSpec.feature \"Projects\", type: :feature do\n scenario \"ユーザはプロジェクトを完了済みにする(しかし失敗する)\" do\n # 未完了プロジェクトを持ったユーザを準備する\n user = FactoryBot.create(:user)\n project = FactoryBot.create(:project, owner: user, completed: false)\n \n # ユーザはログインしている\n sign_in user\n \n # ユーザがプロジェクト詳細画面を開く。\n visit project_path(project)\n \n # 完了ボタンをクリックする。\n click_button \"Complete\" # → ここでProjectController#completeアクションが呼ばれる\n \n # 完了処理は失敗し、未完了のままとなる。\n expect(project.reload.completed).to eq false\n end\n end\n \n```\n\n完了ボタンを押すことによりProjectController#completeアクションが呼ばれ、その内部で@project.complete_pjが呼ばれます。この「@project.complete_pj」にfalseを返させたいです。\n\ncomplete_pjメソッドをスタブ化してfalseを返すようにしてやればいいのでは・・・というのは何となくわかるのですが、どうやってコードを書いたらいいかわかりません。\n\n`click_button \"Complete\"`の前に`allow(project).to\nreceive(:complete_pj).and_return(false)`を入れるとパスするのでOKかと思いきや、and_return(true)に変えてもパスするので、そもそもスタブ化がうまくできていないようでした。\n\n宜しくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T05:25:54.110", "favorite_count": 0, "id": "51780", "last_activity_date": "2019-01-07T13:11:27.480", "last_edit_date": "2019-01-07T05:52:02.947", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "rspec" ], "title": "RSpecのフィーチャースペックでメソッドのスタブ化ができない", "view_count": 171 }
[ { "body": "`project`オブジェクトの`complete_pj`メソッドに対してstubを適応しており、 \n`expect(project.reload.completed).to eq\nfalse`ではstubを未適応の`project.reload.completed`を呼び出しているからではないでしょうか。\n\n以下のような対処があるかと思われます。\n\n 1. `project.reload.completed`にもstubを適応 \nただし、これをするとそもそもテストの意味がなくなってしまうのでは…という懸念もあります\n\n 2. stubを用いるのではなく、fixture等のテストデータで`project.complete_pj`が`false`となるようなデータを用意する \nそこまで複雑なmodelでなければひとまずはこちらのほうが良いかと…", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T13:11:27.480", "id": "51800", "last_activity_date": "2019-01-07T13:11:27.480", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31669", "parent_id": "51780", "post_type": "answer", "score": 0 } ]
51780
51800
51800
{ "accepted_answer_id": "51808", "answer_count": 1, "body": "raspberry piでyoloを動かしたく\n\n```\n\n sudo pip install --upgrade git+https://github.com/Maratyszcza/PeachPy\n sudo pip install --upgrade git+https://github.com/Maratyszcza/confu\n \n git clone https://github.com/ninja-build/ninja.git\n cd ninja\n git checkout release\n ./configure.py --bootstrap\n export NINJA_PATH=$PWD\n \n sudo apt-get install clang\n \n git clone https://github.com/digitalbrain79/NNPACK-darknet.git\n cd NNPACK-darknet\n confu setup\n python ./configure.py --backend auto\n $NINJA_PATH/ninja\n sudo cp -a lib/* /usr/lib/\n sudo cp include/nnpack.h /usr/include/\n sudo cp deps/pthreadpool/include/pthreadpool.h /usr/include/\n \n git clone https://github.com/digitalbrain79/darknet-nnpack.git\n cd darknet-nnpack\n make\n \n```\n\nでサイトに書いてある通りにやってみた後に重みをDLして \n./darknet detector test cfg/coco.data cfg/yolo.cfg yolov2.weights\ndata/person.jpgで実行すると \nillegal insturuction \nと出てしまいます。 \nおそらくサイトではRaspberry Pi 3を用いているのですが自分はRaspberry Pi\n1Bを使っていることが原因だと思います。このエラーを直すにはどのようにすればよいでしょうか?教えてくれる人がいなくて困っています(´°̥̥̥̥̥̥̥̥ω°̥̥̥̥̥̥̥̥`)\nどうかよろしくおねがいします", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T06:44:41.507", "favorite_count": 0, "id": "51782", "last_activity_date": "2019-01-08T19:35:59.647", "last_edit_date": "2019-01-07T14:19:31.517", "last_editor_user_id": "31704", "owner_user_id": "31704", "post_type": "question", "score": 0, "tags": [ "raspberry-pi" ], "title": "raspberry pi illegal instruction", "view_count": 850 }
[ { "body": "<https://ja.wikipedia.org/wiki/Raspberry_Pi> \n`Raspberry Pi` はバージョンによって CPU が違い `armv8` `armv7` `armv6` といろいろです。あなたの\n`Raspberry Pi 1 model B` は `armv6` のようですね。そのため `armv8` `armv7` 固有命令は実行できなくて\n`illegal instruction` エラーが発生します。\n\n`armv8` 64bit なバイナリは `armv6` 上ではそもそも実行できないはずなので、実行中に `illegal instruction`\nが出るなら `armv7` 命令を実行しているということ。\n\n[Illegal instructionというエラーについて](https://ja.stackoverflow.com/questions/17639/) \n`armv7` 専用命令を使って高速化を図っているツールやライブラリは、参考リンクに挙げた `libx264` 以外にもあるはずなので、あなたの使いたい\n`darknet` 本体および `darknet` が中から呼び出しているライブラリ一式のすべてが `armv6`\nで動くようにコンパイルされていると問題解決です。どれが `armv7` 命令を使っているかは要調査っす(オイラの手元には `Raspberry Pi 2\nmodel B` しかないので、オイラでは調査できません)\n\nというわけでオイラならどうするか、ですが\n\n・野良ビルド(自分で `make` した)ツールを再ビルドしてみる \n\\- その際に `configure` なり `Makefile` なりを読んで \n\\--- `armv7` 固有のコンパイルオプションを指定しているか否か \n\\--- `armv7` 固有のアセンブラファイルを使っているか否か \nを調査してみる、あれば回避方法を探す\n\nってところでしょうか。\n\nそういう手間をかけられないのであれば参考サイトと同じ `Raspberry Pi 3`\nを買っちゃうとかも大いにアリです。やりたいことでないものに悩んでいる時間がもったいないです。金で解決できる時間は、金で買っちゃえ。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T00:05:44.700", "id": "51808", "last_activity_date": "2019-01-08T00:05:44.700", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8589", "parent_id": "51782", "post_type": "answer", "score": 2 } ]
51782
51808
51808
{ "accepted_answer_id": "66200", "answer_count": 3, "body": "オライリーの「ゼロから始めるディープラーニング」という本で、ディープラーニングを勉強しています。P.73でMNISTデータセット(手書き数字の画像セット)をGitHubから入手するのですが、やり方がわからず、止まっています。リンク先は\n<https://github.com/oreilly-japan/deep-learning-from-scratch>\nです。環境はwindowsでjupyter notebookを使っています。\n\n本には以下のように書いてあります。\n\n>\n> 本書では、MNISTデータセットのダウンロードから画像データのNumpy配列への変換までをサポートする便利なPythonスクリプトであるmnist.pyを提供しています(mnist.pyは、datasetディレクトリに存在します)。このmnist.pyの利用に際しては、カレントディレクトリがch01,ch02,ch03,....,ch08ディレクトリのいずれかである必要があります。このmnist.pyの関数load_mnist()を用いれば、MNISTデータを次のように簡単に読み込むことができます。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T06:47:16.703", "favorite_count": 0, "id": "51783", "last_activity_date": "2020-07-20T05:00:25.033", "last_edit_date": "2019-01-07T06:53:21.500", "last_editor_user_id": "3060", "owner_user_id": "30352", "post_type": "question", "score": 0, "tags": [ "github", "深層学習" ], "title": "MNISTデータセットを使いたい", "view_count": 2902 }
[ { "body": "書籍でどのような解説になっているかわかりませんが、GitHubから単にデータをダウンロードするだけであれば、リンク先(リポジトリ)をブラウザで開いて緑色の「\n**Clone or Download** 」をクリック、ポップアップ表示されたメニューで「 **Download ZIP**\n」をクリックすればデータをZIP形式でダウンロードできます。\n\nダウンロードしたファイルを適当なフォルダ(実行環境)で展開すれば`ch01, ch02, ...`の各フォルダ等が出てくるはずです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T06:58:41.033", "id": "51786", "last_activity_date": "2019-01-07T06:58:41.033", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "51783", "post_type": "answer", "score": 0 }, { "body": "[![ZIPダウンロード](https://i.stack.imgur.com/pBFdc.png)](https://i.stack.imgur.com/pBFdc.png)\n\ngithubのファイルダウンロードであれば、上の画像にある「DOWNLOAD ZIP」から行えますよ。 \n(ちなみにこちらの画像は、別のgithubページのものです) \n他にも、Scikit-learn経由で簡単にインポートする方法なども下のサイトで紹介されています。ご参考までに \n<https://www.codexa.net/cnn-mnist-keras-beginner/>", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-11-04T14:08:39.937", "id": "60248", "last_activity_date": "2019-11-04T14:08:39.937", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "36023", "parent_id": "51783", "post_type": "answer", "score": 0 }, { "body": "**回答** \ndatasetと同じ並びにフォルダを作成し、そのフォルダで実行するか、datasetの完全パスを`sys.path.append`で追加すればMNISTデータセットを取得できます。\n\n* * *\n\n> MNISTデータセット(手書き数字の画像セット)をGitHubから入手するのですが、やり方がわからず、止まっています。リンク先は\n> <https://github.com/oreilly-japan/deep-learning-from-scratch>\n> です。環境はwindowsでjupyter notebookを使っています。\n\n例えば`ch03`の`mnist_show.py`では以下のコードで`http://yann.lecun.com/exdb/mnist/`からMNISTデータセットを取得してくれます。\n\n```\n\n from dataset.mnist import load_mnist\n (x_train, t_train), (x_test, t_test) = load_mnist(flatten=True, normalize=False)\n \n```\n\n同じく`ch03`の`mnist_show.py`に以下のコードがあります。\n\n```\n\n import sys, os\n sys.path.append(os.pardir) # 親ディレクトリのファイルをインポートするための設定\n \n```\n\nこれは`dataset`が`ch03`と同じ並びにありますので、親ディレクトリをパスに追加しています。 \n注意書きにありますよう、`dataset`と同じ並びのディレクトリ下で実行すればMNISTデータセットを取得してくれるはずです。\n\n> このmnist.pyの利用に際しては、カレントディレクトリがch01,ch02,ch03,....,ch08ディレクトリのいずれかである必要があります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-05-02T06:55:35.540", "id": "66200", "last_activity_date": "2020-05-02T06:55:35.540", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "35558", "parent_id": "51783", "post_type": "answer", "score": 0 } ]
51783
66200
51786
{ "accepted_answer_id": "51799", "answer_count": 2, "body": "こんにちは。\n\n仮想マシンに割り当てるメモリの値の常識についての質問です。\n\n例えば物理マシンに128 GBのメモリを積んでいて \nVMware ハイパーバイザをインストールしている際、 \n20 GB の仮想マシン x6 \nのように(16 GB, 32 GB のような) 2のn乗数値でないメモリの値を割り当てても問題ないのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T06:58:08.930", "favorite_count": 0, "id": "51785", "last_activity_date": "2019-01-07T11:43:33.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29147", "post_type": "question", "score": 1, "tags": [ "vmware" ], "title": "仮想マシンに割り当てるメモリの値の常識", "view_count": 2975 }
[ { "body": "\"OSから見える\"物理メモリのサイズに2のべき乗であるべきという制限はありません。 \nなので、必要なだけメモリを割り当てればよいです。 \nたとえばご自分のPCに4x2 + 8Gのメモリを実装したりとかしませんか?<これすごく効率悪いんですけど、予算の都合上、こうなっちゃったとか。。。 \n気になるのは、その状態で全部使いきったとしてホストOSで8Gって大丈夫ですか?って話と、今後仮想マシンを増設しようとしても、同時起動できない状態がうまれそうということぐらいですかね。オーバーコミットしてやり過ごすという手もなくはないでしょうが。。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T10:34:46.550", "id": "51794", "last_activity_date": "2019-01-07T10:34:46.550", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10174", "parent_id": "51785", "post_type": "answer", "score": 2 }, { "body": "**物理**\nマシンでメモリを2のn乗で搭載することが多いのは、「デュアルチャネル」での動作を意識してのことでしょう(同容量・同規格のメモリを2枚組で構成することでデータ処理の高速化が見込める)。\n\n**仮想**\nマシンの場合、割り当てできるのはあくまで「合計のメモリ容量」なので、デュアルチャネルはおそらく関係なく2のn乗に特別こだわる必要もないと思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T11:43:33.143", "id": "51799", "last_activity_date": "2019-01-07T11:43:33.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "51785", "post_type": "answer", "score": 5 } ]
51785
51799
51799
{ "accepted_answer_id": null, "answer_count": 1, "body": "Sphinx1.8.2でアプリのマニュアルを作成しています。 \n1~10章までありますが、HTMLへは全章を、 \nPDFは2分割して、1~7章を「基本編」として、8~10章を「応用編」として、出力したいのです。\n\nまた、この時のtitleもそれぞれ「基本編」「応用編」として別々にしたいと思っています。\n\nこのような場合の設定方法をご教示ください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T07:11:11.347", "favorite_count": 0, "id": "51787", "last_activity_date": "2019-01-12T10:34:38.940", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 1, "tags": [ "sphinx" ], "title": "sphinxでPDFを作成するときに分割したい", "view_count": 112 }
[ { "body": "現在のところ、以下の方法で自己解決しています。\n\n 1. toctreeを持つ.rstを2つ作成する \n * 基本編用: source/index_latex1.rst\n * 応用編用: source/index_latex2.rst\n 2. source/conf_latex1 にconf.pyを作成し、`master_doc = 'index_latex1'`\n 3. source/conf_latex2 にconf.pyを作成し、`master_doc = 'index_latex2'`\n 4. 基本編のビルドを以下で実行\n\n> sphinx-build -a -b latex -c source/conf_latex1 source build/latex_basic \n> ./build/latex_basic/make\n\n 5. 同様に応用編のビルドを以下で実行\n\n> sphinx-build -a -b latex -c source/conf_latex2 source build/latex_advance \n> ./build/latex_advance/make\n\nただ、この状態だと、コンテンツの順番が変わったり、リリース番号が変わったときには、HTML用とlatex用×2の設定を変更しなければならず、ベストな方法とは思えません。 \n他に良い方法をご存知の方がいらっしゃいましたら、アドバイスをお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T10:34:38.940", "id": "51917", "last_activity_date": "2019-01-12T10:34:38.940", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "51787", "post_type": "answer", "score": 1 } ]
51787
null
51917
{ "accepted_answer_id": null, "answer_count": 1, "body": "Sphinx1.8.2を使用しています。 \n検索すると、下記のようにreStructuredTextがそのまま表示されてしまいます。 \nどのように設定すれば、文字列だけの表示になるのでしょうか?\n\n> 関わりのある情報をまとめてみる \n> .. include:: ./include_pagebreak.rst .. \n> _useful-dashboard-label:\n> *********************************************************** 関わりのある情報をまとめてみる \n> *********************************************************** メニューの\n> **ダッシュボード** をクリックして表示します。 .....\n\n▼元のreStructuredText\n\n```\n\n .. include:: ./include_pagebreak.rst\n \n .. _useful-dashboard-label:\n \n ***********************************************************\n 関わりのある情報をまとめてみる\n ***********************************************************\n \n メニューの **ダッシュボード** をクリックして表示します。\n \n .. figure:: ../screenshots/dashboard/dash002.png\n \n \n .. include:: ./ui_dashboard.rst\n \n```\n\nconf.py の内容(長くなりますが、クライアント名を伏せてすべてを貼り付けます)\n\n```\n\n # -*- coding: utf-8 -*-\n #\n # Configuration file for the Sphinx documentation builder.\n #\n # This file does only contain a selection of the most common options. For a\n # full list see the documentation:\n # http://www.sphinx-doc.org/en/master/config\n \n # -- Path setup --------------------------------------------------------------\n \n # If extensions (or modules to document with autodoc) are in another directory,\n # add these directories to sys.path here. If the directory is relative to the\n # documentation root, use os.path.abspath to make it absolute, like shown here.\n #\n # import os\n # import sys\n # sys.path.insert(0, os.path.abspath('.'))\n \n \n # -- Project information -----------------------------------------------------\n \n project = 'ユーザーマニュアル'\n copyright = '2018, XXX'\n author = 'YYY'\n \n # The short X.Y version\n version = '1.0.0'\n # The full version, including alpha/beta/rc tags\n release = '1.0.0'\n \n \n # -- General configuration ---------------------------------------------------\n \n # If your documentation needs a minimal Sphinx version, state it here.\n #\n # needs_sphinx = '1.0'\n \n # Add any Sphinx extension module names here, as strings. They can be\n # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\n # ones.\n extensions = [\n 'sphinx.ext.autodoc',\n ]\n \n # Add any paths that contain templates here, relative to this directory.\n templates_path = ['_templates']\n \n # The suffix(es) of source filenames.\n # You can specify multiple suffix as a list of string:\n #\n # source_suffix = ['.rst', '.md']\n source_suffix = '.rst'\n \n # The master toctree document.\n master_doc = 'index'\n \n # The language for content autogenerated by Sphinx. Refer to documentation\n # for a list of supported languages.\n #\n # This is also used if you do content translation via gettext catalogs.\n # Usually you set \"language\" from the command line for these cases.\n language = 'ja'\n \n # List of patterns, relative to source directory, that match files and\n # directories to ignore when looking for source files.\n # This pattern also affects html_static_path and html_extra_path.\n exclude_patterns = []\n \n # The name of the Pygments (syntax highlighting) style to use.\n pygments_style = None\n \n \n # -- Options for HTML output -------------------------------------------------\n \n # The theme to use for HTML and HTML Help pages. See the documentation for\n # a list of builtin themes.\n #\n html_theme = 'sphinx_rtd_theme'\n \n # Theme options are theme-specific and customize the look and feel of a theme\n # further. For a list of options available for each theme, see the\n # documentation.\n #\n # html_theme_options = {}\n \n # Add any paths that contain custom static files (such as style sheets) here,\n # relative to this directory. They are copied after the builtin static files,\n # so a file named \"default.css\" will overwrite the builtin \"default.css\".\n html_static_path = ['_static']\n \n # Custom sidebar templates, must be a dictionary that maps document names\n # to template names.\n #\n # The default sidebars (for documents that don't match any pattern) are\n # defined by theme itself. Builtin themes are using these templates by\n # default: ``['localtoc.html', 'relations.html', 'sourcelink.html',\n # 'searchbox.html']``.\n #\n # html_sidebars = {}\n \n html_search_language = 'ja'\n html_show_sourcelink = False\n html_scaled_image_link = False\n html_style = 'css/my_style.css'\n html_logo = '../../XXX_doc/logo/XXX_logow.png'\n html_favicon = '../../XXX_doc/logo/XXX_favicon.ico'\n html_show_sphinx = False\n \n # -- Options for HTMLHelp output ---------------------------------------------\n \n # Output file base name for HTML help builder.\n htmlhelp_basename = 'UserManualdoc'\n \n \n # -- Options for LaTeX output ------------------------------------------------\n \n latex_elements = {\n # The paper size ('letterpaper' or 'a4paper').\n #\n 'papersize': 'a4paper',\n \n # The font size ('10pt', '11pt' or '12pt').\n #\n # 'pointsize': '10pt',\n \n # Additional stuff for the LaTeX preamble.\n #\n 'preamble': r'''\n \\fancypagestyle{normal}{\n \\fancyhead[LE,RO]{XXX ユーザーマニュアル}\n \\fancyfoot[LE,RO]{\\thepage}\n \\fancyfoot[LO]{{\\rightmark}}\n \\fancyfoot[RE]{{\\leftmark}}\n \\renewcommand{\\headrulewidth}{0.4pt}\n \\renewcommand{\\footrulewidth}{0.4pt}\n }\n ''',\n \n # Latex figure (float) alignment\n #\n 'figure_align': 'H',\n }\n \n # Grouping the document tree into LaTeX files. List of tuples\n # (source start file, target name, title,\n # author, documentclass [howto, manual, or own class]).\n latex_documents = [\n (master_doc, 'UserManual.tex', 'XXX ユーザーマニュアル',\n 'XX', 'manual'),\n ]\n latex_docclass = {'manual': 'jsbook'}\n # latex_additional_files = []\n \n latex_show_pagerefs = True\n latex_logo = '../../kbic-kaigi_doc/logo/kbic_logo.png'\n \n # -- Options for manual page output ------------------------------------------\n \n # One entry per manual page. List of tuples\n # (source start file, name, description, authors, manual section).\n man_pages = [\n (master_doc, 'usermanual', 'User Manual Documentation',\n [author], 1)\n ]\n \n \n # -- Options for Texinfo output ----------------------------------------------\n \n # Grouping the document tree into Texinfo files. List of tuples\n # (source start file, target name, title, author,\n # dir menu entry, description, category)\n texinfo_documents = [\n (master_doc, 'UserManual', 'User Manual Documentation',\n author, 'UserManual', 'One line description of project.',\n 'Miscellaneous'),\n ]\n \n \n # -- Options for Epub output -------------------------------------------------\n \n # Bibliographic Dublin Core info.\n epub_title = project\n \n # The unique identifier of the text. This can be a ISBN number\n # or the project homepage.\n #\n # epub_identifier = ''\n \n # A unique identification for the text.\n #\n # epub_uid = ''\n \n # A list of files that should not be packed into the epub file.\n epub_exclude_files = ['search.html']\n \n \n # -- Extension configuration -------------------------------------------------\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T07:51:34.513", "favorite_count": 0, "id": "51789", "last_activity_date": "2019-01-13T17:50:44.913", "last_edit_date": "2019-01-09T00:46:23.847", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 1, "tags": [ "sphinx" ], "title": "sphinxの検索結果の表示にreStructuredTextがそのまま表示されます", "view_count": 188 }
[ { "body": "以下の記事を見つけ、自己解決しました。 \n<https://github.com/sphinx-doc/sphinx/issues/1618>\n\nreStructuredTextがそのまま表示されるのが普通のようです。 \nSphinxの2.0では上記記事の提案が反映されるようですが、現在pipでインストールできるのは1.8.3です。 \nそこで、上記記事のtextへ変換して置き換える方法を取りました。\n\n 1. conf.py に `text_sectionchars = ' '` を追加\n 2. `sphinx-build -a -b text source build/text` でtextに変換\n 3. textに変換した結果の`.doctrees`ディレクトリ以外の`.txt`ファイルだけ`build/html/_sources`へコピーする\n 4. `build/html/_sources`内のファイルの拡張子を`.txt`>`.rst.txt`へ変更する", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T17:50:44.913", "id": "51957", "last_activity_date": "2019-01-13T17:50:44.913", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "51789", "post_type": "answer", "score": 2 } ]
51789
null
51957
{ "accepted_answer_id": "51792", "answer_count": 1, "body": "Cプログラムまたは任意の言語のプログラムがどれだけのRAMとCPUを占有しているかを確認する方法はありますか?私はあなたがアプリケーションにアクティビティモニタを使用できることを知っています、しかしただ一つのCファイルをチェックする方法はありますか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T08:52:17.970", "favorite_count": 0, "id": "51791", "last_activity_date": "2019-01-07T09:10:10.633", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30795", "post_type": "question", "score": 0, "tags": [ "c" ], "title": "CプログラムのRAMとCPU使用率の確認", "view_count": 302 }
[ { "body": "# Unix系環境の場合\n\n`top -p\n<pid>`と、`top`に加えてプロセスIDを指定してあげることで、対応するプロセスだけのRAM/CPU使用率を表示し続けることができます。\n\nまた、 `top` を使わずに一度だけ表示することも可能です(`while`や`sleep`と組み合わせると良いでしょう。)。\n\n> `ps -p <pid> -o %cpu,%mem,cmd`\n>\n> [shell - Retrieve CPU usage and memory usage of a single process on Linux? -\n> Stack Overflow](https://stackoverflow.com/questions/1221555/retrieve-cpu-\n> usage-and-memory-usage-of-a-single-process-on-linux) \n> の [回答](https://stackoverflow.com/a/1221597/10216107) より", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T09:10:10.633", "id": "51792", "last_activity_date": "2019-01-07T09:10:10.633", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29826", "parent_id": "51791", "post_type": "answer", "score": 3 } ]
51791
51792
51792
{ "accepted_answer_id": null, "answer_count": 0, "body": "jsonファイルを読み込むときに複数読み込みたいのですが,キーポイントを指定すると読み込めなくなってしまいます. \n以下にプログラムコードをのせます\n\n```\n\n import json\n \n i = 000000000000\n \n for file_name in [\"right_{:012d}_keypoints.json\".format(i) for i in range(6)]:\n with open(file_name) as f:\n read_data = f.read()\n print(read_data['people'][0]['face_keypoints_2d'])\n \n```\n\nエラー\n\n```\n\n TypeError: string indices must be integers\n \n```\n\nまたjson.road()を使って読み込もうとしたら、\n\n```\n\n import json\n \n i = 000000000000\n \n for file_name in [\"right_{:012d}_keypoints.json\".format(i) for i in range(6)]:\n with open(file_name) as f:\n read_data = json.road(f)\n print(read_data['people'][0]['face_keypoints_2d'])\n \n```\n\nエラー\n\n```\n\n AttributeError: module 'json' has no attribute 'road'\n \n```\n\nとでてしまいました。 \n何とかキーポイントを指定して複数のjsonファイルを読み込む方法はないでしょうか? \nまた、コメント欄での失礼な書き込み、大変申し訳ありませんでした。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T11:24:08.873", "favorite_count": 0, "id": "51797", "last_activity_date": "2019-01-07T11:47:06.610", "last_edit_date": "2019-01-07T11:47:06.610", "last_editor_user_id": "3060", "owner_user_id": "31709", "post_type": "question", "score": 0, "tags": [ "python", "json" ], "title": "jsonファイル複数読み込みでキーポイントの取得", "view_count": 361 }
[]
51797
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "ボタンを押すと画像の動きはあるが、写真が表示されない状態になっています。 \n画像が表示されるようにしたいと思ってます。よろしくお願いします。\n\nエラー \n[![画像の説明をここに入力](https://i.stack.imgur.com/UTwrQ.png)](https://i.stack.imgur.com/UTwrQ.png)\n\n```\n\n document.addEventListener( 'DOMContentLoaded' , function( e ) {\r\n 'use strict';\r\n \r\n var files = [\r\n '<%= @plans.copy_image %>',\r\n '<%= @plans.copy_image %>',\r\n '<%= @plans.copy_image %>',\r\n '<%= @plans.copy_image %>',\r\n '<%= @plans.copy_image %>'\r\n ];\r\n \r\n var currentNum = 0;\r\n var prev = document.getElementById('prev');\r\n var next = document.getElementById('next');\r\n var target = document.getElementById('target');\r\n \r\n prev.addEventListener('click', function() {\r\n currentNum--;\r\n if (currentNum < 0) {\r\n currentNum = files.length - 1;\r\n }\r\n target.src = files[currentNum];\r\n });\r\n \r\n next.addEventListener('click', function() {\r\n currentNum++;\r\n if (currentNum > files.length - 1) {\r\n currentNum = 0;\r\n }\r\n target.src = files[currentNum];\r\n });\r\n \r\n }, false );\n```\n\n```\n\n <div class=\"main\">\r\n <i class=\"fas fa-chevron-circle-left\" aria-hidden=\"true\" id=\"prev\"></i>\r\n <img src=\"<%= @plan.image %>\" id=\"target\" style=\"width: 950px; height: 400px; padding-bottom: 15px; padding-top: 20px; \">\r\n <i class=\"fas fa-chevron-circle-right\" aria-hidden=\"true\" id=\"next\"></i>\r\n </div>\r\n <div class=\"king\">\r\n <ul class=\"example\">\r\n <li class=\"current\"><img src=\"<%= @plan.copy_image %>\"></li>\r\n <li><img src=\"<%= @plan.copy_image %>\"></li>\r\n <li><img src=\"<%= @plan.copy_image %>\"></li>\r\n <li><img src=\"<%= @plan.copy_image %>\"></li>\r\n <li><img src=\"<%= @plan.copy_image %>\"></li>\r\n </ul>\r\n </div>\r\n <script src=\"javascripts/main.js\"></script>\n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T15:02:09.543", "favorite_count": 0, "id": "51801", "last_activity_date": "2019-01-09T13:06:29.530", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30829", "post_type": "question", "score": 1, "tags": [ "javascript", "ruby-on-rails", "ruby", "html" ], "title": "javascriptでスライドショーを実装しようとしているが、画像が表示されない", "view_count": 869 }
[ { "body": "画像のパスが間違っていることは考えられませんか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T23:38:12.973", "id": "51806", "last_activity_date": "2019-01-07T23:38:12.973", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29216", "parent_id": "51801", "post_type": "answer", "score": 0 }, { "body": "`/plans/<%= @plans.copy_image %>` という名前のファイルを読み込もうとしてエラーになっています。\n\nJavaScript に直接Rubyの式を埋め込むことは出来ませんので、HTML (ERB) で、以下のようにJSONを埋め込みます。\n\n```\n\n <script type=\"application/json\" id=\"image-data\">\n <%= @some_array.to_json.html_safe %>\n </script>\n \n```\n\nスクリプト側で、\n\n```\n\n const files = JSON.parse(document.getElementById(\"image-data\").textContent);\n \n```\n\nのように読み込んでみてください。\n\n他にも\n\n 1. サーバ側で出力するJSON (等) をJavaScriptから読み込む (いわゆるAJAX)\n 2. サーバ側で動的にJavaScriptを生成して、それをscriptタグで読み込む\n 3. そもそもHTMLに含まれる画像のパスと同じであれば、わざわざJSONを読み込まずHTMLから取得するのも手です。\n\nなどの方法があります。\n\n**追記**\n\n> スクリプト側のコードは、どの位置に配置すればよろしいでしょうか?\n\nJSONのデータはView側の任意の位置に配置してください。(HTML内に出力されていればどこでも良いです)\n\n> HTMLから取得する方法とはどういう方法でしょうか?\n\nたとえば、対象となる `img` に `test` というクラス名を付けて、\n\n```\n\n const files = Array.prototype.map.call(document.getElementsByClassName(\"test\"), (e) => e.getAttribute(\"src\"))\n \n```\n\nとしてください。第2引数はアロー関数と呼ばれるもので、この場合は\n\n```\n\n const files = Array.prototype.map.call(document.getElementsByClassName(\"test\"), function(e) {return e.getAttribute(\"src\")})\n \n```\n\nと等価です。`Array.prototype.map.call` を呼んでいるのは、`getElementsByClassName` で得られるのが\n`Array` ではなく `HTMLCollection` のためです。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T12:29:57.950", "id": "51823", "last_activity_date": "2019-01-09T13:06:29.530", "last_edit_date": "2019-01-09T13:06:29.530", "last_editor_user_id": "76", "owner_user_id": "76", "parent_id": "51801", "post_type": "answer", "score": 2 } ]
51801
null
51823
{ "accepted_answer_id": "54065", "answer_count": 2, "body": "`Swift\n4`から`C`のインターフェースで提供される`framework`を呼び出すにあたって、ファイルから読み込んだバイナリーデーターのポインターを関数に渡す必要があります。\n\nバイナリーデーター自体はSwiftの\n\n```\n\n let data: Data = try Data(contentsOf: dataURL)\n \n```\n\nで読み込んだのは良いのですが、この`data`から`UnsafePointer<Int8>!`で、データー列の先頭アドレスを取得する一般的な方法はどの様になるのでしょうか?\n\n * `.withUnsafeBytes<Int8>`で愚直にコピーする\n * `Data`ではなく`NSData.bytes`をキャストする\n\nが考えられますが、もっと素直に変換または取得出来るような気がするため、こうするといいよという方法がありましたらお教え下さい。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T21:31:48.533", "favorite_count": 0, "id": "51803", "last_activity_date": "2019-04-11T09:23:01.093", "last_edit_date": "2019-04-11T09:23:01.093", "last_editor_user_id": "14745", "owner_user_id": "14745", "post_type": "question", "score": 0, "tags": [ "c", "swift4", "swift5" ], "title": "SwiftからCのライブラリーを呼び出す際のDataについて", "view_count": 313 }
[ { "body": "なぜ`withUnsafeBytes`を使う方法が「愚直」と感じられるのか理解に苦しみますが、Swiftの`Data`から内部のデータへのポインターを取得する唯一保証された方法が、`withUnsafeBytes`を使うことです。ただし「コピー」が必要かどうかは、場合によるのでなんとも言えませんが。\n\n`NSData.bytes`を使う方法は、現在の実装では「多分」動くでしょうが、Swift的には保証されたものではありません。実際`NSData.bytes`はObjective-\nC環境下でも最適化のレベル等によって動かないことがある(あった?)ことが報告されており、安全な方法とは言えません。\n\n現在のSwiftの標準ライブラリは「確実に動作することを保証する範囲を狭めることにより、(将来の)最適化の余地を確保する」と言う方針で作られており、内部へのポインタが`withUnsafeBytes`のように引数のブロッックの範囲でしか有効にならない、というのもその一環です。標準ライブラリの設計思想を理解し、それに従ったコーディングをするというのが正しく聡明な方法でしょう。何をもって「素直」と言いたいのかわかりませんが、標準ライブラリの設計者が提供する機能を素直に利用するのが「もっとも素直な」方法でしょう。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T22:59:52.070", "id": "51804", "last_activity_date": "2019-01-07T22:59:52.070", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "51803", "post_type": "answer", "score": 1 }, { "body": "`Swift`のwithUnsafeBytesには2種類のメソッド\n\n```\n\n func withUnsafeBytes<ResultType, ContentType>(_ body: (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType\n \n```\n\nと\n\n```\n\n func withUnsafeBytes<ResultType>(_ body: (UnsafeRawBufferPointer) throws -> ResultType) rethrows -> ResultType\n \n```\n\nがあり、前者はOS X\n10.14.4で`Deprecate`になるよという警告が出る様になったので、今後の`Swift`で使い続けるためには後者のメソッドを使い、\n\n```\n\n data.withUnsafeBytes({ (userDictionary: UnsafeRawBufferPointer) -> UnsafeMutableRawPointer? in\n if let ptr = userDictionary.baseAddress {\n // ptr にdataの先頭アドレスが入っているので、それをC関数への引数として処理を行う\n }// end optional binding check of userDictionary\n })// end withUnsafeBytes\n \n```\n\nとして上のソースの場合、変数`ptr`に代入された値を使う事で、OS X 10.14.4 & Xcode\n10.2で警告なくコンパイル、実行できるようになりました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-04-10T08:58:44.307", "id": "54065", "last_activity_date": "2019-04-10T08:58:44.307", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14745", "parent_id": "51803", "post_type": "answer", "score": 1 } ]
51803
54065
51804
{ "accepted_answer_id": null, "answer_count": 2, "body": "JavaScriptにて、\n\n```\n\n const array = \n {\n \"A\": 6,\n \"B\": 1,\n \"C\": 3\n }\n \n```\n\nといったオブジェクトの配列をキーごと数字順(大きい順番)に並べ替えたいです。 \nどうすれば良いでしょうか?\n\n# 理想\n\n```\n\n const array = \n {\n \"A\": 6,\n \"C\": 3,\n \"B\": 1\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-07T23:37:12.220", "favorite_count": 0, "id": "51805", "last_activity_date": "2019-01-14T15:07:10.270", "last_edit_date": "2019-01-08T21:18:12.677", "last_editor_user_id": "3475", "owner_user_id": "29216", "post_type": "question", "score": 0, "tags": [ "javascript", "json", "array" ], "title": "Javascriptオブジェクトのプロパティをソート", "view_count": 1262 }
[ { "body": "ちょうど類似の記事が以下にあります。constではなくvarで質問されていますが同等でしょう。 \n[Sorting JavaScript Object by property\nvalue](https://stackoverflow.com/q/1069666/9014308)\n\nで、@mok2pokさんのコメントと同様の内容がコメントに付いていて、高評価を受けています。 \ngoogle翻訳にかけた結果が以下になります。 \n**質問そのままの内容としては、答えは「出来ません」のようですね。**\n\n> 答えを読む前に:答えは「いいえ」です。ECMAScriptでは、オブジェクトプロパティの順序は標準的ではありません。\n> JavaScriptオブジェクトの要素の順序については絶対に想定しないでください。 オブジェクトは、順不同のプロパティの集まりです。\n> 以下の答えは、配列の助けを借りて、ソートされたプロパティを「使用」する方法を示していますが、オブジェクト自体のプロパティの順序を実際に変更することはありません。\n> それで、いいえ、それは不可能です。\n> 事前ソートされたプロパティを使用してオブジェクトを構築したとしても、将来それらが同じ順序で表示されることは保証されていません。\n\n上記の解決とマークされた内容では、定義されたオブジェクトをいったん別の配列変数にpushして、それをソートしています。\n\n類似の日本語の内容が以下の記事の最後にあります。 \n[【JavaScript】連想配列のキーを値でソートする](https://mell0w-5phere.net/jaded5phere/2018/03/16/hashmap-\nsort/)\n\n冒頭紹介した本家S.O.の記事にいろんな形の回答があるので、好みのもので代替出来るでしょう。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T07:50:58.553", "id": "51821", "last_activity_date": "2019-01-08T07:50:58.553", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "51805", "post_type": "answer", "score": 4 }, { "body": "オブジェクトのプロパティに順序性はありませんが、`new Map` のキーは順序性が保証されています。 \nただし、`Map` はソートする機構が標準で用意されていない為、自前でソートしてやる必要があります。\n\n * [map-prototype-sort.js: Array.prototype.sort 互換のメソッドを定義 · GitHub](https://gist.github.com/think49/daaf5ee0a4f12092862c81c54747bae5)\n\nRe: yoshi さん", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-14T15:07:10.270", "id": "51970", "last_activity_date": "2019-01-14T15:07:10.270", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20262", "parent_id": "51805", "post_type": "answer", "score": 1 } ]
51805
null
51821
{ "accepted_answer_id": "51817", "answer_count": 1, "body": "アプリケーションからページを出力する際にメモリが上がっているので調べたところ、 \nGetCellData関数の \nif(formula) data = range.GetFormula(); \nelse data = range.GetValue(vtMissing); \nで上がるのを確認しました。 \nですが初心者なので、どう直すか悩んでおります。 \nメモリ使用量を減らすには、どうしたらよいでしょうか。 \n内容につきましてはマルチポストです。 \n<https://teratail.com/questions/165797>\n\nGetCellData関数1\n\n```\n\n void CExcelCtrl::GetCellData(int cols,int rows,int cole,int rowe,CStringArray &dt,bool formula){\n CString sc,ec;\n sc.Format(\"%s%d\",Num2Col(cols),rows);\n ec.Format(\"%s%d\",Num2Col(cole),rowe);\n GetCellData(sc,ec,dt,formula);}\n \n```\n\nGetCellData関数2\n\n```\n\n void CExcelCtrl::GetCellData(LPCSTR sc,LPCSTR ec,CStringArray &dt,bool formula){\n try{\n //_Application m_excel;\n _Worksheet ws = m_excel.GetActiveSheet();\n Range range = ws.GetRange(COleVariant(sc),COleVariant(ec));\n \n COleVariant data;\n if(formula) data = range.GetFormula();\n else data = range.GetValue(vtMissing);\n \n COleSafeArray sa;\n sa.Attach(data);\n \n long rowmax,colmax;\n sa.GetUBound(1,&rowmax);\n sa.GetUBound(2,&colmax);\n \n CString str;\n VARIANT val;\n long idx[2];\n \n dt.RemoveAll();\n for(long row = 1;row <= rowmax;row++){\n idx[0] = row;\n for(long col = 1;col <= colmax;col++){\n idx[1] = col;\n sa.GetElement(idx,&val);\n switch(val.vt){\n case VT_R8:\n str.Format(\"%1.2f\", val.dblVal);\n break;\n case VT_BSTR:\n str.Format(\"%s\",(CString)val.bstrVal);\n ::SysFreeString(val.bstrVal);\n break;\n case VT_EMPTY:\n str.Empty();\n break;\n }\n dt.Add(str);\n }\n }\n }catch(COleDispatchException *e){\n AfxMessageBox(e->m_strDescription,MB_ICONEXCLAMATION);\n dt.RemoveAll();\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T01:37:11.957", "favorite_count": 0, "id": "51810", "last_activity_date": "2019-01-18T08:36:57.683", "last_edit_date": "2019-01-18T08:36:57.683", "last_editor_user_id": "31708", "owner_user_id": "31708", "post_type": "question", "score": 0, "tags": [ "c++", "mfc" ], "title": "GetCellData()でメモリの使用量が上がる", "view_count": 535 }
[ { "body": "<https://teratail.com/questions/165797> で解決済みとのことですが、あの回答は間違っています。なお、\n[マルチポスト](https://ja.meta.stackoverflow.com/q/2418/4236)と呼ばれ、両サイトの閲覧者・回答者に対して不誠実な行動です。\n\n`VARIANT val;` は生の[`VARIANT`構造体](https://docs.microsoft.com/en-\nus/windows/desktop/api/oaidl/ns-oaidl-\ntagvariant)を使用しているため、変数`val`に対しては`VariantInit()`や`VariantClear()`の呼び出しが必要です。これらを暗黙的に呼び出す[`COleVariant`クラス](https://docs.microsoft.com/en-\nus/cpp/mfc/reference/colevariant-\nclass?view=vs-2017)に切り替えるといいでしょう。その場合、`VariantInit()`や`VariantClear()`が不要になるほか`SysFreeString()`は呼び出してはいけません。\n\n```\n\n COleVariant val;\n \n```\n\n* * *\n\n> これってdataへの代入が悪かったということなのでしょうか。\n\n見逃していました。おっしゃる通り、代入に問題があります。`COleVariant`は設計が古く、使い方を誤ると適切に管理できません。\n\n>\n```\n\n> COleVariant data;\n> if(formula) data = range.GetFormula();\n> else data = range.GetValue(vtMissing);\n> \n```\n\nこの部分で、`data`への代入で`VARIANT`の新たなコピーが作成されます。その上で右辺値である`Range::GetFormula()`や`Range::GetValue()`の値は、何も処理されないまま捨てられます。これによってメモリ解放漏れとなります。正しくは[`COleVariant::Attach()`](https://docs.microsoft.com/ja-\njp/cpp/mfc/reference/colevariant-\nclass?view=vs-2017#attach)を使用することでコピーせず管理を引き継ぐ必要があります。\n\n```\n\n COleVariant data;\n if(formula) data.Attach(range.GetFormula());\n else data.Attach(range.GetValue(vtMissing));\n \n```\n\n「設計が古い」と指摘しましたが、C++11では[ムーブセマンティクス](https://cpprefjp.github.io/lang/cpp11/rvalue_ref_and_move_semantics.html)という概念が導入されています。これに対応していれば、`=`の代入によって値が解放漏れするようなミスを防ぐことができます。が、`COleVariant`(に限らずMFC全体)はこれに対応していないため漏れます。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T05:17:11.867", "id": "51817", "last_activity_date": "2019-01-11T03:32:55.657", "last_edit_date": "2019-01-11T03:32:55.657", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "51810", "post_type": "answer", "score": 5 } ]
51810
51817
51817
{ "accepted_answer_id": null, "answer_count": 1, "body": "GCPで「App Engine default service\naccount」(appspot.gserviceaccount.comドメインのアカウント)を「IAMと管理 > サービスアカウント」と「IAMと管理 >\nIAM」から誤って削除してしまいました。\n\nGAE絡みのサービスが何も利用できなくなってしまったため、同サービスアカウントを復元したいのですが、うまく復元できておりません。 \n復元までのご助言をいただけないでしょうか?\n\n以下に自分が試みた復元方法とその結果を示します。\n\n# 1\\. 参考にしたサイト\n\n以下のサイト等を参考に、2パターンの復元方法を試みました\n\n## 【REST API の repair API を用いた復元方法】\n\nGoogle Cloud のデフォルトサービスアカウントの復元? \n<https://qiita.com/v-o-v/items/cc036061d153aa1210cc>\n\nGoogle App Engine Deploy Error Code 9 \n<https://stackoverflow.com/questions/44676231/google-app-engine-deploy-error-\ncode-9> \n<https://cloud.google.com/appengine/docs/admin-\napi/reference/rest/v1/apps/repair>\n\n## 【gcloud コマンドを利用した復元方法】\n\n削除されたデフォルトのサービス アカウントの復元 \n<https://cloud.google.com/appengine/docs/flexible/python/access-\ncontrol?hl=JA#repair-service-account> \n<https://cloud.google.com/sdk/gcloud/reference/beta/app/repair?hl=JA>\n\n# 2\\. 実行結果\n\n【REST API の repair API を用いた復元方法】 \n[実行したコマンド]\n\n```\n\n gcloud auth application-default login\n gcloud auth application-default print-access-token\n curl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer ya2...YkZ\" https://appengine.googleapis.com/v1/apps/{project-id}:repair\n \n```\n\n[curlのレスポンス]\n\n```\n\n HTTP/2 200\n {\n \"name\": \"apps/{project-id}/operations/34b...845\",\n \"metadata\": {\n \"@type\": \"type.googleapis.com/google.appengine.v1.OperationMetadataV1\",\n \"method\": \"google.appengine.v1.Applications.RepairApplication\",\n \"insertTime\": \"2019-01-08T01:19:48.709Z\",\n \"user\": \"{email}\",\n \"target\": \"apps/{project-id}\"\n }\n }\n \n```\n\n[実行結果]\n\n```\n\n 「IAMと管理 > サービスアカウント」と「IAMと管理 > IAM」上では、「App Engine default service account」の作成を確認できず\n \n```\n\n【gcloud コマンドを利用した復元方法】 \n[実行したコマンド]\n\n```\n\n gcloud config set project {project-id}\n gcloud beta app repair\n \n```\n\n[最後のコマンドの実行結果]\n\n```\n\n Waiting for operation [apps/{project-id}/operations/047...3ad] to complete...failed.\n Repairing the app [{project-id}]...failed.\n ERROR: (gcloud.beta.app.repair) Error Response: [13] An internal error occurred while ensuring the default service account exists.\n \n```\n\n[実行結果]\n\n```\n\n 「IAMと管理 > サービスアカウント」と「IAMと管理 > IAM」上では、「App Engine default service account」の作成を確認できず\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T02:24:23.057", "favorite_count": 0, "id": "51811", "last_activity_date": "2019-01-30T03:40:47.307", "last_edit_date": "2019-01-08T02:28:19.380", "last_editor_user_id": "29826", "owner_user_id": "23560", "post_type": "question", "score": 1, "tags": [ "google-app-engine", "google-cloud" ], "title": "GCP「App Engine default service account」の復元方法を教えてください", "view_count": 792 }
[ { "body": "ちょうど同じ状態になっていたので回答しておきます。\n\n以下のissueにあるように、1/8時点でknown\nissueとして対応中とのことでしたが、現在1/30時点で進捗がなさそうなので、現状は新たにprojectを作成しなおすしかないと思います。\n\n> This is a known issue, and Engineering is already working towards a fix. No\n> estimated time to resolution has been set. Meanwhile, you may follow\n> developments in this thread.\n\nsee: <https://issuetracker.google.com/issues/122163562>\n\nF.Y.I. ちなみにgcpugのslackで質問したら親切な人達が秒で教えてくれました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-30T03:40:47.307", "id": "52412", "last_activity_date": "2019-01-30T03:40:47.307", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31982", "parent_id": "51811", "post_type": "answer", "score": 1 } ]
51811
null
52412
{ "accepted_answer_id": null, "answer_count": 1, "body": "マイ フィルターリストにコメント(メモ)を付ける方法を教えてください。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T02:27:26.957", "favorite_count": 0, "id": "51812", "last_activity_date": "2019-01-08T02:41:04.990", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31626", "post_type": "question", "score": 0, "tags": [ "google-chrome" ], "title": "Adblock Plus マイ フィルターリスト", "view_count": 125 }
[ { "body": "フィルタルールの追加時、`!`で行を始めればコメント扱いになります。\n\n[Writing Adblock Plus filters -\nComments](https://adblockplus.org/en/filters#comments)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T02:41:04.990", "id": "51813", "last_activity_date": "2019-01-08T02:41:04.990", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "51812", "post_type": "answer", "score": 0 } ]
51812
null
51813
{ "accepted_answer_id": "51826", "answer_count": 1, "body": "画像が変化しながら画像の表示座標を移動する、といった機能があるプログラムを作っているのですが、実行するとたまにラグっているように見えることがあります。\n\n```\n\n import tkinter as tk\n class App(object):\n def GUI(self):\n root=tk.Tk()\n root.geometry(\"600x600\")\n \n self.pic001=tk.PhotoImage(file=\"picture001.png\")\n self.pic002=tk.PhotoImage(file=\"picture002.png\")\n \n self.canvas = tk.Canvas(bg=\"black\", width=796, height=816)\n self.canvas.place(x=0, y=0)\n \n self.item=self.canvas.create_image(0, 0, image=self.pic001, anchor=tk.NW)\n \n self.canvas.move(self.item,-51,10)\n self.canvas.itemconfig(self.item, image = self.pic002) \n \n root.mainloop()\n app=App()\n app.GUI()\n \n```\n\n基本的にはこれで実行しても問題はないのですが \nしかしこのコードをもっと正確に言えば、画像表示位置を変えた後に画像を差し替える \nという事になります。\n\nそのため、処理が重くなる?と画像表示が思うようにいかず、ラグっているように見えるのだと思います。 \nこの問題を解決するには、画像差し替えと座標移動を同時に行う必要性があると思うのですが、どうすればそれを成すことができるでしょうか?\n\n一応今のところ、プログラムはこんな感じにラグっています \n[![ラグ](https://i.stack.imgur.com/1Lxc6.gif)](https://i.stack.imgur.com/1Lxc6.gif)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T05:12:15.677", "favorite_count": 0, "id": "51816", "last_activity_date": "2019-01-09T00:11:20.923", "last_edit_date": "2019-01-08T20:08:33.340", "last_editor_user_id": "31713", "owner_user_id": "31713", "post_type": "question", "score": 3, "tags": [ "python", "tkinter" ], "title": "Canvasの画像に対して、画像差し替えと場所移動を同時に行いたい", "view_count": 2166 }
[ { "body": "それは「モーフィング」と呼ばれる技術でしょう。 \nあまりtkinterだけで出来るとは思えないのですが。 \nむしろ動画作成・編集ソフトの範疇と考えられます。\n\n「動画作成 モーフィング」で検索すると、こんなのが関連しそうです。 \nPythonならOpenCVとかを使うようにすれば出来るのでは? \n[OpenCVで顔のモーフィングを実装する](https://blog.negativemind.com/2016/04/29/morphing-by-\nopencv/) \n[Face Morph Using OpenCV — C++ / Python](https://www.learnopencv.com/face-\nmorph-using-opencv-cpp-python/)\n\n単体のツールならこんなのがあります。 \n[【AviUtl】モーフィング動画の作り方【アハ体験みたいに画像を徐々に変化させる】](http://aviutl.info/morphing/) \n[モーフラッシュ](http://starmediasoft.com/application/morphrush/),\n[フェイスモーフ](http://starmediasoft.com/application/facemorph/) \n[複数画像からモーフィング動画が作成できるフリーソフト 『Sqirlz\nMorph』](https://pc.mogeringo.com/archives/40557)\n\n* * *\n\n**更新を受けて** \nなるほど、アニメーションとかゲーム的な何かですね。 \nだとすると、こちら辺りが参考になると思われます。 \n[Python Tkinter refresh canvas](https://stackoverflow.com/q/21357178/9014308) \n[Tkinter canvas animation\nflicker](https://stackoverflow.com/q/41308900/9014308) \n[Moving balls in Tkinter Canvas](https://stackoverflow.com/q/25430786/9014308)\n\nたぶん肝となるのは Python Tkinter refresh canvas 回答のこの部分でしょう。 \ngoogle翻訳したものを載せます。\n\n> キャンバスを更新する唯一の方法は、イベントループで「再描画」イベントを処理することです。\n> あなたのループでは、イベントループに更新の機会を与えることは決してないので、変更はありません。\n>\n> 簡単な解決策はself.canvas.update_idletasksを呼び出すことですが、それは単なるハックであり、適切な解決策ではありません。\n>\n> アニメーションを実行する適切な方法は、イベントループを使用して反復を実行することです。\n> これを行うには、作業をキュー(この場合はアイドルイベントキュー)に配置します。 afterコマンドでこのキューに物を置くことができます。\n>\n> あなたがすべきことはあなたのアニメーションの1回の反復を行う関数を書くことです。\n> 基本的に、whileループ内のすべてのものを受け取り、それを関数に移動します。\n> それから、やるべき仕事がある限り、その関数が継続的に呼び出されるように手配します。\n> その関数の中にafterを呼び出すことも、アニメーションを制御する別の関数を持つこともできます。\n\nそれから、こちらは pygame を使った場合のQ&Aですが、考え方は同等でしょう。 \n[Flickering dice image when i press my dice\nbutton.](https://www.reddit.com/r/pygame/comments/42rcbf/flickering_dice_image_when_i_press_my_dice_button/)\n\nご質問のソースがどれだけ実際と合っているか不明ですが、上記を元に考えると、スクリーンやキャンバスの設定・初期化およびメインループ等は別のクラスや関数に移動する。1つのフレームを更新する処理を1つにまとめて、それを定期的に呼び出す。といったあたりでしょうか。\n\n試してみてください。", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T16:56:48.707", "id": "51826", "last_activity_date": "2019-01-09T00:11:20.923", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "26370", "parent_id": "51816", "post_type": "answer", "score": 0 } ]
51816
51826
51826
{ "accepted_answer_id": null, "answer_count": 1, "body": "10000Byteあるレコードを1000Byte毎に分割すると、1000Byteのレコードが10個できますが最初の1つ目のレコードはそのままで以降の9個のレコードについては先頭から10Byteを削除し990Byteにして \nその後、分割したレコードを結合したいのですが、簡単でよい方法は御座いませんでしょうか。\n\nイメージ \n1234567890|1234567890|1234567890分割 \n1234567890| 234567890| 234567890先頭を削除 \n1234567890234567890234567890結合", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-08T06:05:37.373", "favorite_count": 0, "id": "51819", "last_activity_date": "2019-03-08T14:25:17.897", "last_edit_date": "2019-01-09T06:40:38.520", "last_editor_user_id": "3060", "owner_user_id": "30329", "post_type": "question", "score": 0, "tags": [ "python", "python3" ], "title": "レコードの分割と結合について", "view_count": 117 }
[ { "body": "以下のような感じでどうでしょうか。 \n質問文に記載のイメージを参考に、最初は10byte、それ以降は10byteのレコードの先頭1byteを除き、9byteを結合しています。\n\nnを1000, mを10に変えれば、もともとの質問のコードになるかと。\n\n```\n\n data = '123456789012345678901234567890'.encode('utf-8') # イメージのデータ\n \n n = 10 # レコードのバイト数(10byte)\n m = 1 # 先頭の不要なバイト数(1byte)\n \n #最初のnバイトは取り出しておく\n ret = data[0:n]\n \n #元データからのデータ取得と結果データへの結合\n for i in range(n, len(data), n):\n ret = ret + data[i+m:i+n]\n \n print(ret) # 結果をstdoutへ出力\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-03-08T14:25:17.897", "id": "53302", "last_activity_date": "2019-03-08T14:25:17.897", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12561", "parent_id": "51819", "post_type": "answer", "score": 0 } ]
51819
null
53302
{ "accepted_answer_id": null, "answer_count": 1, "body": "pythonのようなsen.heatmapを使う際、横軸に出力されるzの値を制限するときは\n\n```\n\n vmin=0.0,vmax=...\n \n```\n\nのように指定することでできますが、これに相当するJuliaの指定はあるのでしょうか?\n\nだいぶ調べたのですが、climなどを使っても制御はできなかったのですが、、、\n\nどなたか知っている方がを折りましたら、ご教授ください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T03:31:15.837", "favorite_count": 0, "id": "51828", "last_activity_date": "2019-01-10T07:56:50.993", "last_edit_date": "2019-01-10T04:43:59.407", "last_editor_user_id": "19110", "owner_user_id": "29111", "post_type": "question", "score": 0, "tags": [ "julia" ], "title": "colorbar の上限、下限を定めたい", "view_count": 231 }
[ { "body": "```\n\n plot(data,...,cbar_lims=(0,0.18))\n \n```\n\ncbar_lims以外にもclimなどもあります\n\nでできました", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T03:53:41.687", "id": "51829", "last_activity_date": "2019-01-10T07:56:50.993", "last_edit_date": "2019-01-10T07:56:50.993", "last_editor_user_id": "29111", "owner_user_id": "29111", "parent_id": "51828", "post_type": "answer", "score": 1 } ]
51828
null
51829
{ "accepted_answer_id": null, "answer_count": 2, "body": "```\n\n import csv\n \n with open('datas.csv', 'r') as csv_file:\n csv_reader = csv.reader(csv_file)\n \n for line in csv_reader:\n print(line)\n \n```\n\nこれでファイルを入れていますが、コードをRUNしたら\n\n```\n\n '2018\\x94N12\\x8c\\x8e30\\x93\\xfa(\\x93\\xfa)'\n \n```\n\nこれは出ています。CSVファイルをENCODE方法がありますか?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T04:19:27.247", "favorite_count": 0, "id": "51830", "last_activity_date": "2022-06-17T21:03:15.267", "last_edit_date": "2019-01-09T06:02:13.650", "last_editor_user_id": "2238", "owner_user_id": "30379", "post_type": "question", "score": 1, "tags": [ "python", "python2" ], "title": "Python 2.7 CSVファイルの日本語文字読み込み", "view_count": 2711 }
[ { "body": "ファイルを[open](https://docs.python.jp/2.7/library/csv.html#examples)する時にエンコーディングを指定してください。 \n指定しない場合はOSシステムのデフォルトエンコーディングになって文字化けします。\n\n```\n\n import csv\n import codecs\n \n # encodingを指定して読み込み\n with codecs.open('datas.csv', 'r', 'shift_jis') as csv_file:\n # 3.x以降ならば下記の記述も可能\n # with open('datas.csv', 'r', encoding=\"shift_jis\") as csv_file:\n csv_reader = csv.reader(csv_file)\n for line in csv_reader:\n print(line)\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T04:38:06.090", "id": "51831", "last_activity_date": "2019-01-09T05:19:53.543", "last_edit_date": "2019-01-09T05:19:53.543", "last_editor_user_id": "9820", "owner_user_id": "9820", "parent_id": "51830", "post_type": "answer", "score": 1 }, { "body": "読んだ行をshift_jisからdecodeする方法です。\n\n```\n\n import csv\n import codecs\n \n with open('datas.csv', 'r') as csv_file:\n csv_reader = csv.reader(csv_file)\n for line in csv_reader:\n line = [codecs.decode(s, 'shift_jis') for s in line] #読んだ行をshift_jisからデコード\n print(line)\n for s in line:\n print(s)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-11-01T00:33:38.280", "id": "71636", "last_activity_date": "2020-11-01T00:33:38.280", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "35558", "parent_id": "51830", "post_type": "answer", "score": 1 } ]
51830
null
51831
{ "accepted_answer_id": "51859", "answer_count": 1, "body": "現在下記Java(spring boot)コードにて、deeplearning4jのword2vec実現を試みております。\n\n```\n\n // Wikipediaの日本語コーパスファイル\n SentenceIterator iter = new BasicLineIterator(resourceLoader.getResource(\"classpath:static/corpus/corpus.txt\").getFile());\n \n TokenizerFactory t = new JapaneseTokenizerFactory();\n \n Word2Vec vec = new Word2Vec.Builder()\n .minWordFrequency(2)\n .layerSize(100)\n .seed(42)\n .windowSize(5)\n .iterate(iter)\n .tokenizerFactory(t)\n .workers(10)\n .build();\n \n // 実行\n vec.fit();\n \n System.out.println(vec.wordsNearest(\"ラテン\",1)); → []※空の配列が出力される \n \n```\n\n<pom.xml>\n\n```\n\n <!-- kuromoji \n <dependency>\n <groupId>com.atilika.kuromoji</groupId>\n <artifactId>kuromoji-ipadic</artifactId>\n <version>0.9.0</version>\n </dependency>\n -->\n <!-- nd4j -->\n <dependency>\n <groupId>org.nd4j</groupId>\n <artifactId>nd4j-native-platform</artifactId>\n <version>0.9.1</version>\n </dependency>\n \n <!-- woed2vec -->\n <dependency>\n <groupId>org.deeplearning4j</groupId>\n <artifactId>deeplearning4j-nlp-japanese</artifactId>\n <version>0.9.1</version>\n </dependency>\n \n <dependency>\n <groupId>org.deeplearning4j</groupId>\n <artifactId>deeplearning4j-core</artifactId>\n <version>0.9.1</version>\n </dependency>\n \n <dependency>\n <groupId>org.deeplearning4j</groupId>\n <artifactId>deeplearning4j-ui_2.10</artifactId>\n <version>0.9.1</version>\n </dependency>\n \n```\n\n`wordsNearest()`の引数に英単語を渡した場合は動作しているようですが、日本語を渡した場合は、`wordsNearest()`の実行結果が何もありません。 \nどのようにソースを修正すれば日本語が動作するか、分かる方がいましたらご教授をお願い致します。また、JapaneseTokenizerFactoryでないその他TokenizerFactoryでの実現方法があれば、そちらでも構いません。\n\n<corpus.txtの内容>\n\n```\n\n [[アンパサンド]]\n アンパサンド (&、英語名:ampersand) とは並立助詞「…と…」を意味する記号である。ラテン語の \"et\" の合字で、Trebuchet MSフォントでは、と表示され \"et\" の合字であることが容易にわかる。ampersa、すなわち \"and per se and\"、その意味は\"and [the symbol which] by itself [is] and\"である。\n == 歴史 ==\n その使用は1世紀に遡ることができ、5世紀中葉から現代に至るまでの変遷がわかる。 Z に続くラテン文字アルファベットの27字目とされた時期もある。\n アンパサンドと同じ役割を果たす文字に「{仮リンク|ティロ式記号|en|Tironian notes}のet」と呼ばれる、数字の「7」に似た記号があった(⁊, U+204A)。この記号は現在もゲール文字で使われている。\n 記号名の「アンパサンド」は、ラテン語まじりの英語「& はそれ自身 \"and\" を表す」(& per se and) のくずれた形である。英語以外の言語での名称は多様である。\n \n```\n\n\\---追記--- \ncorpus.txtのファイル形式をSJISにすることで、wordsNearest()の結果配列を取得することができましたが、corpus.txtがUTF8ですとwordsNearest()の結果配列が空になってしまう状況です。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T07:51:37.823", "favorite_count": 0, "id": "51835", "last_activity_date": "2019-01-11T06:18:28.363", "last_edit_date": "2019-01-11T06:18:28.363", "last_editor_user_id": "7626", "owner_user_id": "7626", "post_type": "question", "score": 0, "tags": [ "java", "word2vec" ], "title": "deeplearning4j のJapaneseTokenizerFactoryの使い方について", "view_count": 272 }
[ { "body": "以下のいずれかではないかと思います。\n\n * `corpus.txt`に「ゲーム」と言う単語が無い\n * 「ゲーム」と言う単語が無い別の`corpus.txt`を参照している\n\n私の環境で、同じ`pom.xml`とソースコードで確認してみましたが、`corpus.txt`に「ゲーム」と言う単語が含まれていれば、配列は空にはなりませんでした。\n\n英単語であれば動作するとのことなので、別のディレクトリにある英語版の`corpus.txt`を参照しているのではないでしょうか。", "comment_count": 8, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T06:42:37.403", "id": "51859", "last_activity_date": "2019-01-10T06:48:25.100", "last_edit_date": "2019-01-10T06:48:25.100", "last_editor_user_id": "21092", "owner_user_id": "21092", "parent_id": "51835", "post_type": "answer", "score": 2 } ]
51835
51859
51859
{ "accepted_answer_id": null, "answer_count": 1, "body": "画像に貼り付けたエラーの原因について教えてください。 \nエラーコードが検索しても出てきませんでした。 \n[![エラー文章のスクリーンショット](https://i.stack.imgur.com/IpsMp.png)](https://i.stack.imgur.com/IpsMp.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T07:52:45.520", "favorite_count": 0, "id": "51836", "last_activity_date": "2019-01-09T08:20:13.107", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31727", "post_type": "question", "score": 0, "tags": [ "xcode" ], "title": "xcodeのエラー", "view_count": 80 }
[ { "body": "文面からすると、その数値はエラーコードではなく、プロセスIDでしょう。 \nその数値を基に検索しても、何も出てこないだろうし、出てきたら間違った情報を得ることになるでしょう。\n\nそれよりも「System Integrity Protection」の文言の方で検索した方が良いでしょう。\n\nちなみに検索したらこんな記事がありました。 \n[iOS - Xcode Error: cannot attach to process due to System Integrity\nProtection](https://stackoverflow.com/q/39219678/9014308)\n\n[We Explain What System Integrity Protection on Mac is and How to Control\nIt](https://blog.macsales.com/45473-we-explain-what-system-integrity-\nprotection-on-mac-is-and-how-to-control-it)\n\n[Runtime\nProtections](https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html)\n\n[OS X 10.11 El CapitanのSystem Integrity Protection(SIP)\n(rootless)についてちょっと詳しく](https://rcmdnk.com/blog/2015/10/10/computer-mac/)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T08:10:41.863", "id": "51837", "last_activity_date": "2019-01-09T08:20:13.107", "last_edit_date": "2019-01-09T08:20:13.107", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "51836", "post_type": "answer", "score": 0 } ]
51836
null
51837
{ "accepted_answer_id": null, "answer_count": 0, "body": "私は畳み込みネットワークを用いて画像の識別をしています. \n実際にプログラムを動かしていくと,下の画像のように動作の開始直後はなかなか精度が上がらず,途中から急に精度が上昇し始めました.どういった原因が考えられるでしょうか. \n回答よろしくお願いします. \n[![左が精度グラフ,右が損失関数グラフ](https://i.stack.imgur.com/bfhjq.png)](https://i.stack.imgur.com/bfhjq.png)", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T08:50:17.087", "favorite_count": 0, "id": "51838", "last_activity_date": "2019-01-09T08:50:17.087", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31728", "post_type": "question", "score": 0, "tags": [ "python", "機械学習", "画像", "keras" ], "title": "Kerasで畳み込みネットワークの学習 精度の上がり方について", "view_count": 322 }
[]
51838
null
null
{ "accepted_answer_id": "51851", "answer_count": 1, "body": "こんにちは,お世話になります.\n\npandasの`interpolate()`メソッドで欠損値処理を行いたいと思っています. \nこのとき,欠損値がn個連続している場合は,その部分に関して補間をそもそも行わない,と指示したいのですが,どうすれば良いのでしょうか.\n\n例えば,n=3だとすると,\n\n```\n\n ...-5,NaN,NaN,6,10...\n \n```\n\nでは補間を行い,\n\n```\n\n ...-5,NaN,NaN,NaN,6,10,...\n \n```\n\nでは,補間処理を行わないようにしたいです.\n\n引数`limit`を使うと行いたい作業ができるか?と思い,調べてみました.しかし,こちら[pandasで欠損値NaNを前後の値から補間するinterpolate](https://note.nkmk.me/python-\npandas-interpolate/)を参照すると,欠損値が連続している場合に補完する個数の最大値を指定するものだったため,望みの処理は行えませんでした.\n\nご教授お願いいたします.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T09:47:41.510", "favorite_count": 0, "id": "51841", "last_activity_date": "2019-01-10T01:18:54.030", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27841", "post_type": "question", "score": 1, "tags": [ "python", "pandas" ], "title": "pandas 欠損値が連続しているときの補間について", "view_count": 1087 }
[ { "body": "> 欠損値がn個連続している場合は,その部分に関して補間をそもそも行わない,と指示したい\n\nであれば単純に、予め欠損値が何個連続しているかを求めておき、その数がn個の箇所をマスクした上で補間を行うとよいのではないでしょうか。\n\n```\n\n import pandas as pd\n import numpy as np\n \n df = pd.DataFrame({\n 'data':[1,2,3,np.nan,np.nan,np.nan,7,8,np.nan,10,np.nan,np.nan,13,14]\n })\n print(df.loc[:,['data']])\n # data\n #0 1.0\n #1 2.0\n #2 3.0\n #3 NaN\n #4 NaN\n #5 NaN\n #6 7.0\n #7 8.0\n #8 NaN\n #9 10.0\n #10 NaN\n #11 NaN\n #12 13.0\n #13 14.0\n \n # 欠損値が連続している箇所毎にグループ番号を振る\n df['nan_group'] = (df['data'].isna() & df['data'].shift(1).notna()).where(df['data'].isna()).cumsum()\n # 上記のグループ毎に欠損値が何個連続しているかを求める\n df['nan_count'] = df['nan_group'].map(df.groupby('nan_group').size())\n # 箇所毎にグループ番号はもう使わないので削除\n df = df.drop(columns=['nan_group'])\n \n # 欠損値がN個連続している箇所以外を補間\n N=3\n df['data'] = df.loc[df.nan_count != N, 'data'].interpolate()\n print(df.loc[:,['data']])\n # data\n #0 1.0\n #1 2.0\n #2 3.0\n #3 NaN\n #4 NaN\n #5 NaN\n #6 7.0\n #7 8.0\n #8 9.0\n #9 10.0\n #10 11.0\n #11 12.0\n #12 13.0\n #13 14.0\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T01:18:54.030", "id": "51851", "last_activity_date": "2019-01-10T01:18:54.030", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24801", "parent_id": "51841", "post_type": "answer", "score": 2 } ]
51841
51851
51851
{ "accepted_answer_id": null, "answer_count": 1, "body": "お世話になります。 \nこのように過去に自分が送信したメールの返事で、 \n自分の書いた文も書いてあるメールファイルがあり、\n\n```\n\n ≪^------------------ ××様へ------------------------ \n 〇月〇日の詳細:\n [場所]△△ホール\n [持ち物]特になし\n 備考\n 当日は公共機関をご利用ください。\n ---------------------------------------------------^≫\n 是非お越しください\n \n \n \n \n -----Original Message-----\n From:〇×\n Sent: Mondey\n To: ☆×\n Subject: 日程について\n \n こんにちは\n 下記のような形で日程を教えてください\n ≪^------------------ 〇〇へ------------------------\n 〇月〇日の詳細:\n [場所]××ホール\n [持ち物]特になし\n 備考\n 〇〇〇〇〇〇〇〇〇〇\n ---------------------------------------------------^≫\n \n```\n\n一番上の「××様へ」の中身である\n\n> △△ホール \n> 特になし \n> 当日は公共機関をご利用ください。\n\nのみをコマンドプロンプト上に出力させたいと思い、他の方が過去に質問された内容や、 \n自分が正規表現について質問した際に頂いた答えをもとにこのように書いてみたのですが、\n\n```\n\n import ExtractMsg\n import re\n from glob import glob\n import sys\n args = sys.argv\n \n for filename in glob(r\"{}/*.msg\".format(args[1])):\n msg = ExtractMsg.Message(filename)\n msg_message = msg.body\n m = re.search('(.*)(^≪^.*-)(.*)(^-.*^≫)(.*)', msg_message, flags \n (re.DOTALL | re.MULTILINE))\n if m :\n x = re.sub('\\[.*\\]', \"\", m.group())\n print(x)\n else:\n pass\n \n```\n\n何も出力されず、困っている状態です。下の\n\n「〇月〇日の詳細: \n[場所]××ホール \n[持ち物]特になし \n備考 \n〇〇〇〇〇〇〇〇〇〇 \nがメール内に書いてある場合にそれを出力しない」\n\nというコーディングができればよいなと思ったのですが、 \nいまいちどうやればよいかわかりません。 \nご教授頂ければ幸いです。", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T10:31:30.480", "favorite_count": 0, "id": "51842", "last_activity_date": "2020-03-25T04:03:40.603", "last_edit_date": "2019-01-11T11:50:21.863", "last_editor_user_id": "3060", "owner_user_id": "31729", "post_type": "question", "score": 1, "tags": [ "python", "python3", "正規表現" ], "title": "pythonでメールファイルから本文の指定部分のみを抽出したい", "view_count": 3126 }
[ { "body": "「正規表現を使わなければいけない」というのでなければ、愚直に実装するのもありかと。デバッグしてないので動作確認してないですが。\n\n```\n\n with open(file, \"r\") f:\n lines = f.readlines()\n \n stat = 0\n \n for line in lines:\n if stat == 0:\n if line.startwith(\"[場所]\"):\n print line.strip(\"[場所]\")\n stat = 1\n if stat == 1:\n print line.strip(\"[持ち物]\")\n stat = 2\n if stat == 2:\n # 「備考」を読み飛ばす\n stat = 3\n continue\n if stat == 3:\n print line\n stat = 0\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T09:30:43.987", "id": "51862", "last_activity_date": "2019-01-10T09:30:43.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9592", "parent_id": "51842", "post_type": "answer", "score": 1 } ]
51842
null
51862
{ "accepted_answer_id": null, "answer_count": 2, "body": "Unityでゲームを作りたいと思っています。 \nそこで質問ですが \n例えばキャラクターが1秒から10秒間画面上に居て \n5秒目から7秒目までの間にクリックしたら成功 \n5秒以前なら失敗 \n7秒以降でも失敗と言うプログラミングを \n作りた \nいです。\n\n何からすればいいかわかりません。\n\nよろしくお願いします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T12:28:33.350", "favorite_count": 0, "id": "51843", "last_activity_date": "2019-04-29T12:25:32.477", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31730", "post_type": "question", "score": 0, "tags": [ "unity3d" ], "title": "Unityの時間ゲーム", "view_count": 190 }
[ { "body": "Unity(に限らず広く使われている言語やフレームワーク)には、 **チュートリアル** という初心者が使い方を学ぶための教材が公開されています。\n\n以下は全て日本語の資料ですので、これらを利用してUnityの使い方を学んでから、詰まった部分があったらこちらで具体的な質問をするというのをおすすめします。\n\n * [Unity Learn Tutorials](https://unity3d.com/jp/learn/tutorials)\n * [はじめてのUnity](http://tutorial.unity3d.jp/)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T01:18:27.963", "id": "51850", "last_activity_date": "2019-01-10T01:18:27.963", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29826", "parent_id": "51843", "post_type": "answer", "score": 4 }, { "body": "```\n\n float count; // 時間を管理する小数値\n bool gameActive = false; //trueだったらゲーム中\n void Update()\n {\n if(Input.GetKeyDown(KeyCode.Space)) //スペースキーを押してゲームスタート\n {\n gameActive = true; // gameactiveをtrueにしてゲームをスタートさせる\n }\n \n if(gameActive == true) //gameactiveがtrueの間はゲームを実行する\n {\n count += Time.deltaTime; //一秒に1増やす\n if(Input.GetKeyDown(KeyCode.Enter)) //Enterを押すと実行\n {\n if(count >= 5 && count =< 7) //countが5~7の間の場合\n {\n Debug.Log(\"成功\");\n }\n else //countが5~7以外の場合\n {\n Debug.Log(\"失敗\");\n }\n }\n }\n }\n \n```\n\nもしこれでおかしかったら言ってください。 \n何せこちらもはじめたばっかりなので...", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-04-29T12:25:32.477", "id": "54573", "last_activity_date": "2019-04-29T12:25:32.477", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30727", "parent_id": "51843", "post_type": "answer", "score": 0 } ]
51843
null
51850
{ "accepted_answer_id": null, "answer_count": 1, "body": "下記のサイトを参考にdocker build .をしたいのですがうまくいきません \n<https://engineering.adwerx.com/rails-on-kubernetes-8cd4940eacbe>\n\n最初は \napp.conf \nconfig.ru \nDockerfile \nenv.conf \nGemfile \nGemfile.lock \nRakefile \nを作り、`docker build .`を実行したところ下記エラーが出ました。\n\n```\n\n rake aborted! Do not know how to build task 'assets: precompile'\n  (See full trace by running task with - trace) The command '/ bin / sh -c bundle  exec rake ass\n \n ets: precompile' returned a non-zero code: 1 I got an error saying.\n \n```\n\n次に \n<https://github.com/jbielick/rails-kube-demo> を`git clone`したのですが \n下記エラーがでました。\n\n```\n\n Gem::Ext::BuildError: ERROR: Failed to build gem native extension.\n current directory:\n /usr/local/rvm/gems/ruby-2.3.8/gems/puma-3.6.0/ext/puma_http11\n /usr/local/rvm/rubies/ruby-2.3.8/bin/ruby -r ./siteconf20190109-5-1ymcdr3.rb\n extconf.rb\n checking for BIO_read() in -lcrypto... yes\n checking for SSL_CTX_new() in -lssl... yes\n checking for openssl/bio.h... yes\n creating Makefile\n current directory:\n /usr/local/rvm/gems/ruby-2.3.8/gems/puma-3.6.0/ext/puma_http11\n make \"DESTDIR=\" clean\n current directory:\n /usr/local/rvm/gems/ruby-2.3.8/gems/puma-3.6.0/ext/puma_http11\n make \"DESTDIR=\"\n compiling http11_parser.c\n In file included from ext/puma_http11/http11_parser.rl:7:0:\n ext/puma_http11/http11_parser.rl: In function ‘puma_parser_execute’:\n ext/puma_http11/http11_parser.rl:111:17: warning: comparison between signed and\n unsigned integer expressions [-Wsign-compare]\n ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:39:1: note: here\n ext/puma_http11/http11_parser.rl:52:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:54:1: note: here\n ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:39:1: note: here\n ext/puma_http11/http11_parser.rl:55:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:57:1: note: here\n ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:39:1: note: here\n ext/puma_http11/http11_parser.c:244:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:246:1: note: here\n ext/puma_http11/http11_parser.c:251:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:253:1: note: here\n ext/puma_http11/http11_parser.c:258:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:260:1: note: here\n ext/puma_http11/http11_parser.c:265:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:267:1: note: here\n ext/puma_http11/http11_parser.c:272:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:274:1: note: here\n ext/puma_http11/http11_parser.c:281:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:283:1: note: here\n ext/puma_http11/http11_parser.c:288:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:290:1: note: here\n ext/puma_http11/http11_parser.rl:49:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:51:1: note: here\n ext/puma_http11/http11_parser.c:325:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:327:1: note: here\n ext/puma_http11/http11_parser.c:353:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:355:1: note: here\n ext/puma_http11/http11_parser.rl:41:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:43:1: note: here\n ext/puma_http11/http11_parser.rl:46:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:48:1: note: here\n ext/puma_http11/http11_parser.rl:46:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:48:1: note: here\n ext/puma_http11/http11_parser.rl:55:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:57:1: note: here\n ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:39:1: note: here\n ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:39:1: note: here\n ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:39:1: note: here\n ext/puma_http11/http11_parser.rl:37:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:39:1: note: here\n ext/puma_http11/http11_parser.rl:71:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:73:1: note: here\n ext/puma_http11/http11_parser.rl:71:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:73:1: note: here\n ext/puma_http11/http11_parser.rl:60:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.rl:62:1: note: here\n ext/puma_http11/http11_parser.c:653:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:655:1: note: here\n ext/puma_http11/http11_parser.c:671:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:673:1: note: here\n ext/puma_http11/http11_parser.c:689:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:691:1: note: here\n ext/puma_http11/http11_parser.c:707:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:709:1: note: here\n ext/puma_http11/http11_parser.c:725:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:727:1: note: here\n ext/puma_http11/http11_parser.c:743:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:745:1: note: here\n ext/puma_http11/http11_parser.c:761:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:763:1: note: here\n ext/puma_http11/http11_parser.c:779:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:781:1: note: here\n ext/puma_http11/http11_parser.c:797:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:799:1: note: here\n ext/puma_http11/http11_parser.c:815:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:817:1: note: here\n ext/puma_http11/http11_parser.c:833:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:835:1: note: here\n ext/puma_http11/http11_parser.c:851:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:853:1: note: here\n ext/puma_http11/http11_parser.c:869:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:871:1: note: here\n ext/puma_http11/http11_parser.c:887:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:889:1: note: here\n ext/puma_http11/http11_parser.c:905:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:907:1: note: here\n ext/puma_http11/http11_parser.c:923:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:925:1: note: here\n ext/puma_http11/http11_parser.c:941:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:943:1: note: here\n ext/puma_http11/http11_parser.c:959:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:961:1: note: here\n ext/puma_http11/http11_parser.c:977:5: warning: this statement may fall through\n [-Wimplicit-fallthrough=]\n ext/puma_http11/http11_parser.c:979:1: note: here\n compiling io_buffer.c\n compiling mini_ssl.c\n mini_ssl.c: In function ‘get_dh1024’:\n mini_ssl.c:90:5: error: dereferencing pointer to incomplete type ‘DH {aka struct\n dh_st}’\n dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);\n ^~\n mini_ssl.c: In function ‘engine_init_server’:\n mini_ssl.c:139:3: warning: ISO C90 forbids mixed declarations and code\n [-Wdeclaration-after-statement]\n ID sym_cert = rb_intern(\"cert\");\n ^~\n mini_ssl.c:144:3: warning: ISO C90 forbids mixed declarations and code\n [-Wdeclaration-after-statement]\n ID sym_ca = rb_intern(\"ca\");\n ^~\n mini_ssl.c:166:3: warning: ISO C90 forbids mixed declarations and code\n [-Wdeclaration-after-statement]\n DH *dh = get_dh1024();\n ^~\n mini_ssl.c:170:3: warning: ISO C90 forbids mixed declarations and code\n [-Wdeclaration-after-statement]\n EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_secp521r1);\n ^~~~~~\n mini_ssl.c: In function ‘engine_init_client’:\n mini_ssl.c:197:3: warning: ‘DTLSv1_method’ is deprecated\n [-Wdeprecated-declarations]\n conn->ctx = SSL_CTX_new(DTLSv1_method());\n ^~~~\n In file included from /usr/include/openssl/ct.h:13:0,\n from /usr/include/openssl/ssl.h:61,\n from mini_ssl.c:15:\n /usr/include/openssl/ssl.h:1642:1: note: declared here\n DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */\n ^\n Makefile:238: recipe for target 'mini_ssl.o' failed\n make: *** [mini_ssl.o] Error 1\n make failed, exit code 2\n Gem files will remain installed in\n /usr/local/rvm/gems/ruby-2.3.8/gems/puma-3.6.0 for inspection.\n Results logged to\n /usr/local/rvm/gems/ruby-2.3.8/extensions/x86_64-linux/2.3.0/puma-3.6.0/gem_make.out\n An error occurred while installing puma (3.6.0), and Bundler cannot continue.\n Make sure that `gem install puma -v '3.6.0' --source 'https://rubygems.org/'`\n succeeds before bundling.\n In Gemfile:\n puma\n The command '/bin/sh -c bundle install' returned a non-zero code: 5\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T13:06:39.843", "favorite_count": 0, "id": "51844", "last_activity_date": "2019-01-09T23:41:10.163", "last_edit_date": "2019-01-09T15:44:10.263", "last_editor_user_id": "3068", "owner_user_id": "19514", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "docker", "kubernetes", "google-kubernetes-engine" ], "title": "dockerbuildしたいです", "view_count": 389 }
[ { "body": "最終的に以下のようにするとbuildできました。\n\nref: <https://github.com/puma/puma/issues/1136>\n\n 1. Dockerfile以下のように修正\n\n23行目: `curl libssl-dev \\` -> `curl libssl1.0-dev \\`\n\n**Dockerfile** \n\n``` FROM phusion/passenger-ruby23\n\n \n # set some rails env vars\n ENV RAILS_ENV production\n ENV BUNDLE_PATH /bundle\n \n # set the app directory var\n ENV APP_HOME /home/app\n WORKDIR $APP_HOME\n \n # Enable nginx/passenger\n RUN rm -f /etc/service/nginx/down\n \n # Disable SSH\n # Some discussion on this: https://news.ycombinator.com/item?id=7950326\n RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh\n \n RUN apt-get update -qq\n \n # Install apt dependencies\n RUN apt-get install -y --no-install-recommends \\\n build-essential \\\n curl libssl1.0-dev \\\n git \\\n unzip \\\n zlib1g-dev \\\n libxslt-dev \\\n mysql-client \\\n sqlite3\n \n # install bundler\n RUN gem install bundler\n \n # Separate task from `add . .` as it will be\n # Skipped if gemfile.lock hasn't changed\n COPY Gemfile* ./\n \n # Install gems to /bundle\n RUN bundle install\n \n # place the nginx / passenger config\n RUN rm /etc/nginx/sites-enabled/default\n ADD nginx/env.conf /etc/nginx/main.d/env.conf\n ADD nginx/app.conf /etc/nginx/sites-enabled/app.conf\n \n ADD . .\n \n # compile assets!\n RUN bundle exec rake assets:precompile\n \n EXPOSE 3000\n \n CMD [\"/sbin/my_init\"]\n \n```\n\n 2. `Gemfile.lock`を削除\n\n 3. Gemfile以下のように修正 \n48行目: `gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]` ->\n`gem 'tzinfo-data'`\n\n``` source 'https://rubygems.org'\n\n \n \n # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\n gem 'rails', '~> 5.0.0', '>= 5.0.0.1'\n # Use mysql as the database for Active Record\n gem 'mysql2', '>= 0.3.18', '< 0.5'\n # Use Puma as the app server\n gem 'puma', '~> 3.0'\n # Use SCSS for stylesheets\n gem 'sass-rails', '~> 5.0'\n # Use Uglifier as compressor for JavaScript assets\n gem 'uglifier', '>= 1.3.0'\n # Use CoffeeScript for .coffee assets and views\n gem 'coffee-rails', '~> 4.2'\n # See https://github.com/rails/execjs#readme for more supported runtimes\n # gem 'therubyracer', platforms: :ruby\n \n # Use jquery as the JavaScript library\n gem 'jquery-rails'\n # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks\n gem 'turbolinks', '~> 5'\n # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\n gem 'jbuilder', '~> 2.5'\n # Use Redis adapter to run Action Cable in production\n # gem 'redis', '~> 3.0'\n # Use ActiveModel has_secure_password\n # gem 'bcrypt', '~> 3.1.7'\n \n # Use Capistrano for deployment\n # gem 'capistrano-rails', group: :development\n \n group :development, :test do\n # Call 'byebug' anywhere in the code to stop execution and get a debugger console\n gem 'byebug', platform: :mri\n end\n \n group :development do\n # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.\n gem 'web-console'\n gem 'listen', '~> 3.0.5'\n # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n gem 'spring'\n gem 'spring-watcher-listen', '~> 2.0.0'\n end\n \n # Windows does not include zoneinfo files, so bundle the tzinfo-data gem\n gem 'tzinfo-data'\n \n```\n\n2年前のもので依存パッケージのverが変わってしまい、エラーが起きていましたね… \n2年となるともう古いので、なるべく新し目のチュートリアルをお勧めします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T23:26:00.890", "id": "51846", "last_activity_date": "2019-01-09T23:41:10.163", "last_edit_date": "2019-01-09T23:41:10.163", "last_editor_user_id": "31669", "owner_user_id": "31669", "parent_id": "51844", "post_type": "answer", "score": 3 } ]
51844
null
51846
{ "accepted_answer_id": "51854", "answer_count": 1, "body": "スクレイピングの勉強で以下のようなコードを書きました。\n\n```\n\n from requests_html import HTMLSession\n \n base_url = 'https://www.example.com/xxx/yyy'\n qs = 'sort=desc&page='\n \n for page_num in range(5):\n session = HTMLSession()\n resp = session.get(f'{base_url}?{qs}{page_num}')\n \n elems = resp.html.find('.product_title')\n print([i.text for i in elems])\n \n```\n\nこちらの8行目で書かれている `session.get(f’{base_url}?{qs}{page_num}')`\nの`'f'`がどのような働きをしているものなのか、また何と呼ばれているものなのでしょうか...?\n\n大変初歩的な質問で恥ずかしい限りなのですが、ご教授いただきましたら幸いです。 \nどうぞよろしくお願い申し上げます!", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-09T23:48:14.830", "favorite_count": 0, "id": "51847", "last_activity_date": "2019-01-10T02:10:28.257", "last_edit_date": "2019-01-10T00:15:01.337", "last_editor_user_id": "2238", "owner_user_id": "27030", "post_type": "question", "score": 6, "tags": [ "python", "python3", "web-scraping" ], "title": "このfはどういう働きをしてるのでしょうか? → session.get(f’{base_url}?{qs}{page_num}')", "view_count": 130 }
[ { "body": "文字列中に変数や式を埋め込むためのもので、「フォーマット済み文字列リテラル(f-strings)」と呼ばれるものです。 \nPython 3.6 から導入された機能で、`str.format()` を使うよりも短く記述することがきます。\n\n```\n\n # 以下は同じ出力が得られます。\n \n # str.format() を使った場合\n print('{}?{}{}'.format(base_url, qs, page_num))\n # f-string を使った場合\n print(f'{base_url}?{qs}{page_num}')\n \n```\n\n詳しくはリファレンスをご確認ください。 \n[Python\n言語リファレンス](https://docs.python.jp/3/reference/lexical_analysis.html#f-strings)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T02:10:28.257", "id": "51854", "last_activity_date": "2019-01-10T02:10:28.257", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31716", "parent_id": "51847", "post_type": "answer", "score": 8 } ]
51847
51854
51854
{ "accepted_answer_id": null, "answer_count": 1, "body": "OpenCVの初心者です. OpenCVを使って画像の色の変換や二値化反転などの処理はできるのですが,\n車種(普通車やトラックなど)の判別の仕方が分かりません. 具体的にどのような手法があるのか教えてください.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T00:56:00.117", "favorite_count": 0, "id": "51849", "last_activity_date": "2019-01-10T04:09:24.890", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30000", "post_type": "question", "score": 0, "tags": [ "opencv", "raspberry-pi" ], "title": "OpenCVで車種を判別する方法について", "view_count": 576 }
[ { "body": "一般的には機械学習、ディープラーニング等を使って車種判別を行うと思います。 \n詳しくは下記を参照してください。 \n<https://qiita.com/icoxfog417/items/53e61496ad980c41a08e>", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T04:09:24.890", "id": "51855", "last_activity_date": "2019-01-10T04:09:24.890", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24490", "parent_id": "51849", "post_type": "answer", "score": 1 } ]
51849
null
51855
{ "accepted_answer_id": "51872", "answer_count": 1, "body": "Rubyの繰り返し処理において,以下のコードをより速く実行できるように書き直す方法はありますでしょうか.\n\n宜しくお願いいたします.\n\n```\n\n ※ resiSiPower.length == out.lengthである\n (0 ... out.length).each do |j|\n resiSiPower[j] += (out[j].abs)**2\n end\n \n```\n\n(追加の質問) \nRubyで実行が遅くなるのは繰り返し処理によるものであると私自身は考えているのですが(インタプリタ言語であるのは理解しています),その中でも繰り返し処理を速く記述するコツがあれば教えて頂きたいです.", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T02:08:45.170", "favorite_count": 0, "id": "51853", "last_activity_date": "2019-01-10T12:37:59.303", "last_edit_date": "2019-01-10T02:35:59.660", "last_editor_user_id": "30173", "owner_user_id": "30173", "post_type": "question", "score": 0, "tags": [ "ruby" ], "title": "Rubyの繰り返し処理について", "view_count": 145 }
[ { "body": "ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]で下記コードを実行し、速度を検証しました。\n\n```\n\n # frozen_string_literal: true\n \n require 'benchmark'\n require 'parallel'\n require 'numo/narray'\n require 'nmatrix'\n \n list_size = 1_000_000\n range = (-100.0..100.0)\n out = Array.new(list_size) do\n rand(range) + rand(range) * 1i\n end\n resiSiPower = Array.new(list_size) do\n rand(range)**2\n end\n \n # Numo::NArray\n out_na = Numo::DComplex.new(list_size)\n out_na.store(out)\n resiSiPower_na = Numo::DFloat.new(list_size)\n resiSiPower_na.store(resiSiPower)\n \n # NMatrix\n out_nm = N[out, dtype: :complex128]\n resiSiPower_nm = N[resiSiPower, dtype: :float64]\n \n Benchmark.bm(23) do |x|\n x.report('orginal') do\n (0...out.length).each do |j|\n resiSiPower[j] += out[j].abs**2\n end\n end\n x.report('r^2 + i^2') do\n (0...out.length).each do |j|\n resiSiPower[j] += out[j].real**2 + out[j].imag**2\n end\n end\n x.report('abs2') do\n (0...out.length).each do |j|\n resiSiPower[j] += out[j].abs2\n end\n end\n x.report('times abs2') do\n out.length.times do |j|\n resiSiPower[j] += out[j].abs2\n end\n end\n x.report('upto abs2') do\n 0.upto(out.length - 1) do |j|\n resiSiPower[j] += out[j].abs2\n end\n end\n x.report('zip map abs2 map sum') do\n resiSiPower = resiSiPower.zip(out.map(&:abs2)).map(&:sum)\n end\n x.report('map abs2 zip map sum') do\n resiSiPower = out.map(&:abs2).zip(resiSiPower).map(&:sum)\n end\n x.report('each_with_index map') do\n resiSiPower = resiSiPower.each_with_index.map do |r, i|\n r + out[i].abs2\n end\n end\n x.report('map! with i') do\n i = 0\n resiSiPower.map! do |r|\n r + out[i].abs2\n i += 1\n end\n end\n x.report('map with each') do\n out_e = out.each\n resiSiPower.map! do |r|\n r + out_e.next.abs2\n end\n end\n x.report('parallel') do\n resiSiPower = Parallel.map(0...out.length, in_threads: 4) do |j|\n resiSiPower[j] + out[j].abs2\n end\n end\n x.report('Numo::NArray') do\n resiSiPower_na += out_na.abs**2\n end\n x.report('NMatrix') do\n resiSiPower_nm += out_nm.abs**2\n end\n end\n \n```\n\n実行前に`gem install parallel numo-narray nmatrix`として必要なライブラリをインストールしておいてください。\n\n`out`を浮動小数点数複素数の配列、`resiSiPower`を浮動小数点数の配列という前提にしています。型が異なる場合は、違いが出るかも知れませんので、それに合わせて修正してください。また、OSやRubyのバージョンによる違いも出る場合があります。\n\n## 絶対値の2乗の求め方\n\n絶対値の2乗の場合は[Complex#abs2](https://docs.ruby-\nlang.org/ja/latest/method/Complex/i/abs2.html)が利用できます。と言っても、`x.real**2 +\nx.imag**2`と速度はほとんど変わりませんでした。どちらか好みを使うときでしょう。\n\n## ループの回し方\n\n`(0...n).each`は`n.times`や`0.upto(n-1)`とも書けます。これらも速度はほとんど変わりませんでしたので、好みを使うときでしょう。\n\n代入ではなく[Array#map!](https://docs.ruby-\nlang.org/ja/latest/method/Array/i/collect=21.html)を使う方法もありますが、インデックスを別途増加させる必要があります。こちらも`(0...n).each`とほとんど変わりませんでした。インデックスではなく`each`でEnumeratorを作る方法は逆に遅くなりました。\n\nその他、関数型プログラミング風に`zip`や`map`を組み合わせて使う方法は配列の生成があるため遅くなります。\n\n## 並列化\n\nCRubyにはGVLがあるため単純なマルチスレッドにしても遅くなるだけでした。ただ、JRubyではマルチスレッドが並列化するため、速くなる可能性はあります(未検証)。\n\nマルチプロセスはそれぞれのプロセスをまとめる処理があるせいか、遅すぎて計測できませんでした。ただ、配列を適当な数に分割してマルチプロセスで処理した場合は早くなる可能性はあります(未検証)。\n\n## 行列ライブラリの使用\n\nPythonでいうnumpyのようなライブラリとして、[Numo::NArray](https://github.com/ruby-numo/numo-\nnarray)と[NMatrix](https://github.com/SciRuby/nmatrix)があります。これらはマトリックス(ベクトル含む)をマトリックスのまま計算することが出来ます。内部処理はCレベルで実装されており、それぞれの要素に対して同じ処理を高速に行うことが出来ます。\n\nNumo::NArrayは大幅に速度が向上しました。高速を目指すのであれば、Numo::NArrayを使うのが一番いいかもしれません。\n\nNMatrixは逆に遅くなりました。何故かはわかりません。(私のコードの書き方が悪いのでしょうか?)\n\n* * *\n\n以上の事から、今のからあまり変えずに少しでも速くするなら`abs2`を使う。さらに速度の向上を目指すならNumo::NArrayを使うというのがいいのではないでしょうか。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T12:37:59.303", "id": "51872", "last_activity_date": "2019-01-10T12:37:59.303", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7347", "parent_id": "51853", "post_type": "answer", "score": 2 } ]
51853
51872
51872
{ "accepted_answer_id": "51966", "answer_count": 2, "body": "SPRESENSE SDKでのPWM生成に関する質問です。\n\n現在、examples/pwmを試しているのですが、PWMの最低周波数(動作周波数xカウンタ最大値?)で悩んでいます。50Hz周期のサーボモータを接続しようとしたところioctlでエラーとなってしまいました。125HzのPWMは正常に生成できました。\n\n本内容に関する、SPRESENSEの仕様書やコード等、ご存知の方いらっしゃいますでしょうか。\n\n```\n\n nsh> pwm -p /dev/pwm0 -f 125\n pwm_main: starting output with frequency: 125 duty: 00008000\n pwm_main: stopping output\n nsh> pwm -p /dev/pwm0 -f 50\n pwm_main: starting output with frequency: 50 duty: 00008000\n pwm_main: ioctl(PWMIOC_START) failed: 22\n \n```\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T04:37:14.127", "favorite_count": 0, "id": "51856", "last_activity_date": "2020-03-16T01:38:06.067", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 1, "tags": [ "spresense" ], "title": "Spresense SDKによるPWM出力周波数の下限について", "view_count": 170 }
[ { "body": "お世話になっております。自己解決しました、ありがとうございます。\n\n下記のifに捕まっていました。cxd56_get_pwm_baseclock(デフォルトではSCUと同じRCOSC)を基準として、16bit幅のカウンタを利用するため、最低125Hzということですね。理解しました。\n\n * ~/spresense/sdk/bsp/src/cxd56_pwm.c\n``` static int convert_freq2period(...)\n\n {\n ...\n pwmfreq = cxd56_get_pwm_baseclock();\n ...\n if ((freq > ((pwmfreq + 1) >> 1)) || (freq < (pwmfreq >> 16)))\n {\n pwmerr(\"Frequency out of range. %d [Effective range:%d - %d]\\n\",\n freq, pwmfreq >> 16, (pwmfreq + 1) >> 1);\n return -1;\n \n```\n\n今後ともよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-14T11:44:28.880", "id": "51966", "last_activity_date": "2019-01-14T12:34:30.727", "last_edit_date": "2019-01-14T12:34:30.727", "last_editor_user_id": "19110", "owner_user_id": null, "parent_id": "51856", "post_type": "answer", "score": 3 }, { "body": "ソニーのSPRESENSEサポート担当です。\n\nPWM出力周波数の下限についてですが、先週リリース致しました、 \nSDK v1.5.1において1Hzからに対応いたしました。 \n詳細については、[PWM\n周波数とデューティー比について](https://developer.sony.com/develop/spresense/docs/sdk_tutorials_ja.html#_pwm_%E5%91%A8%E6%B3%A2%E6%95%B0%E3%81%A8%E3%83%87%E3%83%A5%E3%83%BC%E3%83%86%E3%82%A3%E3%83%BC%E6%AF%94%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6)をご参照ください。\n\n今後ともSPRESENSEをどうぞよろしくお願いいたします。\n\nSPRESENSEサポートチーム", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-03-16T01:38:06.067", "id": "63875", "last_activity_date": "2020-03-16T01:38:06.067", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29520", "parent_id": "51856", "post_type": "answer", "score": 0 } ]
51856
51966
51966
{ "accepted_answer_id": null, "answer_count": 1, "body": "お世話になります。\n\n今までも過去に何度も出ている質問と思いますが、過去ログでも見つからなかったので \n質問いたします。\n\nデータベースの種類を問わず、ある既存のテーブルにCSVファイルをインポートする方法を \n検討しています。\n\n特定のフィールドにキーがあり、CSV側のデータがテーブル側のキーに該当しない場合は \n新しい項目としてデータを追加(Import)、該当するキーがある場合はレコードの内容を \n更新(UPDATE)させたいのですが、その方法を『全てのデータベースで \n共通する方法』で行えればと思うのですが、そういった方法はありますでしょうか?\n\n直接CSVと衝突させることができればベストなのですが、一度ダミーのテーブルにすべて \nインポートしてから比較して…という方法でも構いません。\n\nまだ知識も浅いもので、今のやり方だと、コード側で一行ずつデータを取り出してあるかどうかを \n比較してからINSERTなりUPDATEなりをして…といったことをCSVの行数分ループさせて \nいるのですが、これだとどうしても膨大な時間がかかってしまいます(15万件)。\n\nデータベースに依存しない、共通のSQLの範囲でこれらの作業を一つ二つのSQLで \n行いたいのですが、そういった方法がありましたらご教授いただけますでしょうか。\n\nよろしくお願いいたします。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T06:08:35.547", "favorite_count": 0, "id": "51857", "last_activity_date": "2019-01-11T13:15:40.570", "last_edit_date": "2019-01-10T07:11:47.090", "last_editor_user_id": "2238", "owner_user_id": "9374", "post_type": "question", "score": 1, "tags": [ "sql", "csv", "database" ], "title": "SQLでキーとなるデータがなければINSERTし、あれば該当キーのデータをUPDATEするような方法について", "view_count": 1343 }
[ { "body": "そもそも、CSV(などDB外のデータ)をDBに取り込む「標準的な方法」が存在しません。この時点でDB固有の機能を使わざるを得ないので、「標準的な方法」にこだわるのは意味がありません。\n\n・一行ずつ愚直に処理する \n・テンポラリテーブルに一括で読み込んだあと、既存の表を更新+挿入 \n・DB次第では一発でできる?\n\nのどれが効率的かは製品次第ですし、機能としては可能だとしても、運用上利用できない(例えば長時間テーブルロックがかかるのは都合が悪いとか)かもしれません。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T13:15:40.570", "id": "51899", "last_activity_date": "2019-01-11T13:15:40.570", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "51857", "post_type": "answer", "score": 4 } ]
51857
null
51899
{ "accepted_answer_id": "51864", "answer_count": 1, "body": "みていただきありがとうございます\n\nunityにて自作したプラグインを実行した際に以下のようなエラーが発生しました。\n\n```\n\n W/dalvikvm(11322): Unable to resolve superclass of Lcom/google/firebase/messaging/FirebaseMessagingService; (4817)\n W/dalvikvm(11322): Link of class 'Lcom/google/firebase/messaging/FirebaseMessagingService;' failed\n W/dalvikvm(11322): Unable to resolve superclass of Lcom/myplugin/fcm/CustomMessagingService; (4825)\n W/dalvikvm(11322): Link of class 'Lcom/myplugin/fcm/CustomMessagingService;' failed\n E/dalvikvm(11322): Could not find class 'com.myplugin.fcm.CustomMessagingService', referenced from method com.myplugin.fcm.Provider.initialize\n W/dalvikvm(11322): VFY: unable to resolve const-class 6000 (Lcom/myplugin/fcm/CustomMessagingService;) in Lcom/myplugin/fcm/Provider;\n W/ComponentDiscovery(11322): Application info not found.\n W/ComponentDiscovery(11322): Could not retrieve metadata, returning empty list of registrars.\n W/dalvikvm(11322): VFY: unable to resolve virtual method 584: Landroid/content/Context;.createDeviceProtectedStorageContext ()Landroid/content/Context;\n W/dalvikvm(11322): VFY: unable to resolve virtual method 592: Landroid/content/Context;.getCodeCacheDir ()Ljava/io/File;\n W/dalvikvm(11322): VFY: unable to resolve virtual method 593: Landroid/content/Context;.getColor (I)I\n W/dalvikvm(11322): VFY: unable to resolve virtual method 594: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;\n W/dalvikvm(11322): VFY: unable to resolve virtual method 596: Landroid/content/Context;.getDataDir ()Ljava/io/File;\n W/dalvikvm(11322): VFY: unable to resolve virtual method 597: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable;\n W/dalvikvm(11322): VFY: unable to resolve virtual method 604: Landroid/content/Context;.getNoBackupFilesDir ()Ljava/io/File;\n W/dalvikvm(11322): VFY: unable to resolve virtual method 617: Landroid/content/Context;.isDeviceProtectedStorage ()Z\n W/dalvikvm(11322): VFY: unable to resolve virtual method 634: Landroid/content/Context;.startForegroundService (Landroid/content/Intent;)Landroid/content/ComponentName;\n E/Unity (11322): AndroidJavaException: java.lang.NoClassDefFoundError: com.myplugin.fcm.CustomMessagingService\n E/Unity (11322): java.lang.NoClassDefFoundError: com.myplugin.fcm.CustomMessagingService\n E/Unity (11322): at com.myplugin.fcm.Provider.initialize(Provider.java:18)\n E/Unity (11322): at com.unity3d.player.UnityPlayer.nativeRender(Native Method)\n E/Unity (11322): at com.unity3d.player.UnityPlayer.c(Unknown Source)\n E/Unity (11322): at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source)\n E/Unity (11322): at android.os.Handler.dispatchMessage(Handler.java:98)\n E/Unity (11322): at android.os.Looper.loop(Looper.java:136)\n E/Unity (11322): at com.unity3d.player.UnityPlayer$c.run(Unknown Source)\n E/Unity (11322): at UnityEngine.AndroidJNISafe.CheckException () [0x0008c] in /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJNISafe.cs:24 \n E/Unity (11322): at UnityEngine.AndroidJNISafe.CallStaticVoidMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] args) [0x00011] in /Users/builduser/buildslave/unity/build/Runtime/Export/AndroidJNISafe.cs:202 \n E/Unity (11322): at UnityEngine.AndroidJavaObject._CallStatic (Sy\n \n```\n\n以下のようなクラスです\n\n```\n\n public class CustomMessagingService extends FirebaseMessagingService {\n ...\n }\n \n```\n\nFirebaseMessagingServiceがapkに含まれていないのではないかと思い、AndroidStudioでAnalyzeしてみましたが、含まれているようでした。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/GfSjh.png)](https://i.stack.imgur.com/GfSjh.png)\n\n原因に検討がつかず、質問させていただきます。 \nよろしくお願いします", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T07:46:54.123", "favorite_count": 0, "id": "51860", "last_activity_date": "2019-01-10T10:26:34.270", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31743", "post_type": "question", "score": 0, "tags": [ "android", "java", "unity3d" ], "title": "Unityで実行時にUnable to resolve superclassエラー", "view_count": 134 }
[ { "body": "自己解決しました。 \nsuperclass of FirebaseMessagingService \nなのでFirebaseMessagingServiceがあっても関係ありませんでした・・・\n\n```\n\n FirebaseMessagingService extends zzb\n \n```\n\nでしたのでzzbが含まれている com.google.firebase.iid を含むことで解決しました", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T10:26:34.270", "id": "51864", "last_activity_date": "2019-01-10T10:26:34.270", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31743", "parent_id": "51860", "post_type": "answer", "score": 1 } ]
51860
51864
51864
{ "accepted_answer_id": null, "answer_count": 2, "body": "```\n\n module.exports = {\n add : (value1, value2) =>\n return value1 + value2\n }\n \n```\n\nこのように書いたところエラーになりましたが原因がわかりません。\n\nreturn を消したら通りましたが、なぜreturnがあるとだめなのかがわかっていません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T10:43:34.090", "favorite_count": 0, "id": "51865", "last_activity_date": "2019-01-11T11:07:11.050", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12896", "post_type": "question", "score": 0, "tags": [ "javascript", "es6" ], "title": "es6 のreturn", "view_count": 81 }
[ { "body": "ref: [アロー関数 |\nMDN](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Syntax)\n\narrow関数のstatements部分にreturnを用いる場合は`{}`で囲む必要がありそうです。\n\n```\n\n module.exports = {\n add : (value1, value2) => {return value1 + value2}\n }\n \n```\n\nまた、returnを省略して以下のようにも書けますね。\n\n```\n\n module.exports = {\n add : (value1, value2) => value1 + value2\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T11:49:49.917", "id": "51870", "last_activity_date": "2019-01-10T11:49:49.917", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31669", "parent_id": "51865", "post_type": "answer", "score": 7 }, { "body": "`{}` を省略できるのは、書きたいコードが単一の「式」の場合だけです。代入文の右辺や関数のパラメータになれるのが式です。\n\n`return` を含め、「文」を書きたい場合は `{}`を書く必要があります。\n\nなぜこのような仕様になっているのかですが、[TC39 Wiki](http://tc39wiki.calculist.org/es6/arrow-\nfunctions/)を読むと単にC#のラムダ式の文法を真似たのではと思えます(はっきりとは書いていません)。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T11:07:11.050", "id": "51893", "last_activity_date": "2019-01-11T11:07:11.050", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3475", "parent_id": "51865", "post_type": "answer", "score": 5 } ]
51865
null
51870
{ "accepted_answer_id": null, "answer_count": 1, "body": "「次の時間が経過後、ディスプレイの電源を切る」で3分に設定後、3分後にディスプレイが消灯するが何分間か経つと復帰します。15分に設定した場合は問題ありませんでした。よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T10:52:10.873", "favorite_count": 0, "id": "51866", "last_activity_date": "2019-05-29T07:01:45.667", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31626", "post_type": "question", "score": -1, "tags": [ "windows-10" ], "title": "windows10pro 64bit モニターが勝手に復帰する", "view_count": 3610 }
[ { "body": "これらの記事に色々まとめられています。ご質問の症状に当てはまるようなものは無さそうですが。\n\n[Windows10がスリープから勝手に復帰する時に確認すべき項目まとめ](https://deaimobi.com/windows-sleep/) \n[Windows10スリープ移行後すぐ起動する。](https://answers.microsoft.com/ja-\njp/windows/forum/all/windows10%E3%82%B9%E3%83%AA%E3%83%BC%E3%83%97/5a3863f6-3f56-4dda-8e95-42434154aa20) \n[Windows10が夜中に勝手にスリープ復帰する場合の解決法](https://freesoft.tvbok.com/win10/tips/sleep_released_unintentionally.html#a02-1)\n\n記事の中にイベントログによる調査方法なども解説されているので、それで調べてみてください。 \nあと、OSだけでなく、BIOS(メインボード)による何かの設定があるかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T14:05:46.653", "id": "51874", "last_activity_date": "2019-01-10T14:05:46.653", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "51866", "post_type": "answer", "score": 0 } ]
51866
null
51874
{ "accepted_answer_id": null, "answer_count": 1, "body": "bundle install実行時に以下のエラーが返ってきます\n\n> Your Ruby version is 2.3.7, but your Gemfile specified 2.5.1\n\nrubyのバージョン等は以下の通りです\n\n```\n\n $ ruby -v\n ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]\n $ which bundler \n /usr/local/bin/bundler\n $ which ruby\n /Users/user/.rbenv/shims/ruby\n \n```\n\n原因わかりますでしょうか?\n\n**追記**\n\n`gem install bundler`を実行したところ、以下のエラーが出ました。\n\n```\n\n ERROR: While executing gem ... (Errno::EACCES)\n Permission denied @ rb_sysopen - /Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/CHANGELOG.md\n \n```\n\n原因を調べていますがハマっています。 \n解決策をご教示いただけると幸甚です。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T11:31:13.570", "favorite_count": 0, "id": "51867", "last_activity_date": "2019-11-09T11:01:35.237", "last_edit_date": "2019-01-11T12:01:26.543", "last_editor_user_id": "3068", "owner_user_id": "24345", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails" ], "title": "Rails でbundle install時に、Your Ruby version is 2.3.7, but your Gemfile specified 2.5.1 とエラー", "view_count": 8796 }
[ { "body": "[Ruby version is 2.3.7, but your Gemfile specified 2.5.0とエラーが出てしまう |\nteratail](https://teratail.com/questions/139925)\n\n恐らく↑と同じ現象が起こっているかと思われます。具体的には以下の通りです。\n\n * `which bundler`で`/usr/local/bin/bundler`と表示されるので、システムにインストールされているbundlerを呼び出している\n * `bundle install`時にシステムにインストールされているRuby(恐らくversion2.3.7)を呼び出してGemfileが必要としているversionと差異があるためエラー\n\n対策としては、\n\n`gem install bundler`\n\nとしてrbenvのruby gemにbundlerをインストール&そのbundlerを用いるようにすればよいかと思われます。\n\n* * *\n\n**2019/01/13 追記**\n\n`gem install bundler`で`Permissino\ndenied`と怒られていることから、bundlerをシステムの方へインストールしようとしているのではないかと思われます。\n\n一旦 \n`rbenv global 2.5.1` \nをしてから、再度`gem install bundler`を実行してみては如何でしょうか。\n\nそれでもうまくかない場合は…`rbenv`をインストールし直すことをお勧めします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T11:41:21.093", "id": "51868", "last_activity_date": "2019-01-13T03:01:08.397", "last_edit_date": "2019-01-13T03:01:08.397", "last_editor_user_id": "31669", "owner_user_id": "31669", "parent_id": "51867", "post_type": "answer", "score": 2 } ]
51867
null
51868
{ "accepted_answer_id": "51871", "answer_count": 2, "body": "**問題点** \n今tkinterのCanvasを使ってゲームを作っています。\n\nしかし1つ問題があり、canvasではオブジェクト同士が重なると、新しく作成されたオブジェクトのほうが上の様に来るようになります。\n\n例えば、ゲーム内の画面では、背景の上にキャラクターが来て、キャラクターの前に手前側オブジェクトが来る、といった仕組みになっているのでこれを作成しようと思えば・・・ \ncanvas=tk.Cancas..... \nゲームの背景=canvas.create_image..... \nキャラクター=canvas.create_image..... \n手前側オブジェクト=canvas.create_image..... \nといった順番で作成されます。\n\nしかし、ゲーム中で新しいキャラクターを登場させることになれば、それは手前側オブジェクトよりも新しく作成されることになるので、その新しいキャラクターとオブジェクトが重なったら、キャラクターが手前側に来てしまいます。\n\nつまり、 \n手前側オブジェクト=canvas.create_image..... \nの後で \nキャラクター2=canvas.create_image..... \nをすると、キャラクター2が手前側オブジェクトの前に来てしまう。\n\n**考えてみた対策方法** \nそこでこの問題を解決するには、1つのCanvas上に画像を生成するのではなく、ゲーム背景専用、キャラークター専用そして手前側オブジェクト専用のCanvasを作成して、Canvasを重ね合わせて、それぞれのオブジェクト(ゲーム背景、キャラクター、オブジェクト)をそれぞれの対応するCanvas(ゲーム背景専用、キャラークター専用そして手前側オブジェクト専用)で作成すれば問題は解決できると思うんです。\n\nBack_Ground_Layer=tk.Cancas..... \nCharacter_Layer=tk.Cancas..... \nObject_Layer=tk.Cancas.....\n\nゲームの背景=Back_Ground_Layer.create_image..... \nキャラクター=Character_Layer.create_image..... \n手前側オブジェクト=Object_Layer.create_image.....\n\nつまり、1つのCanvasの上にすべての画像を作成しようとすると、新しいもの順に表示されてしまうけど \nそれぞれのCanvasで新しい画像を生成しても、その上にはほかのCanvasがあるからしっかりと期待した順番に表示される という感じになると思うんです。\n\n[![イメージ図](https://i.stack.imgur.com/J9Tp8.png)](https://i.stack.imgur.com/J9Tp8.png)\n\nしかしそこで他の問題がありまして・・・ \n実は、Canvasを作成するときには、Canvasの地色も設定しないといけないのですが、この地色が問題なのです。 \n地色を透明に出来れば、下に来るCanvasのアイテムも見れるようになるのですが、透明になれなければ下のCanvasを覆いかぶさなってしまいます。\n\nそこで、Canvasの地色を透明にする方法を探しているのですが・・・どうすればいいでしょうか? \nまた、他の解決方法などはありますでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T11:45:19.200", "favorite_count": 0, "id": "51869", "last_activity_date": "2020-06-04T09:10:17.877", "last_edit_date": "2019-01-10T12:10:15.210", "last_editor_user_id": "31713", "owner_user_id": "31713", "post_type": "question", "score": 3, "tags": [ "python", "python3", "tkinter" ], "title": "地色が透明なCanvasを作成したい。", "view_count": 6755 }
[ { "body": "**近そうなものを見つけたので先頭に追記** \nCanvasのバックグラウンドカラーを 0 (無効な色?) に設定するらしいです。 \n[How to make a tkinter canvas background\ntransparent?](https://stackoverflow.com/q/53021603/9014308)\n\n> The only possible config(... option, to set the background to nothing\n>\n> `c.config(bg='')`\n>\n> results with: _tkinter.TclError: unknown color name \"\"\n>\n> you have to hold the chess board and figures within the same `.Canvas(....`\n```\n\n self.canvas = Canvas(self, width=500, height=200, bd=0, highlightthickness=0)\n self.canvas.create_rectangle(245,50,345,150, fill='white')\n \n self.image = tk.PhotoImage(file='chess.png')\n self.image_id = self.canvas.create_image(50,50, image=self.image)\n \n self.canvas.move(self.image_id, 245, 100)\n \n```\n\n* * *\n\n表示(描画が開始される時間的な)順番ではなくZオーダー(手前か奥か)の制御ならば、 \n`lift` と `lower` で制御出来るのでは? \n[Stacking Order Maintenance in\nTkinter](https://stackoverflow.com/q/9576063/9014308) \n[python tkinter grid_forget -\nTkinterでは、ウィジェットを見えないようにする方法はありますか?](https://code.i-harness.com/ja-\njp/q/3a475a)\n\n> 1つのオプションは、別の答えで説明されているように、 pack_forgetまたはgrid_forgetを使用すること 。 もう1つの選択肢は、\n> liftとlowerを使用することです。 ウィジェットの積み重ね順序が変更されます。\n> 正味の効果は、兄弟ウィジェット(または兄弟の子孫)の後ろにウィジェットを隠すことができることです。\n> あなたが目に見えるようにするには、あなたはそれらをlift 、目に見えないようにしたいときはlowerします\n\n* * *\n\n表示順番対策としてモノになるかは不明ですし、Canvasではありませんが、 \nウインドウの透明バックグラウンドの記事があります。応用できるかもしれません。\n\nただし「クロスプラットフォームな方法は無い」と回答が付いています。 \nmacOS と Windows のそれぞれ用の方法が提示されています。 \n[Transparent background in a Tkinter\nwindow](https://stackoverflow.com/q/19080499/9014308)\n\n> Here is a solution for macOS:\n```\n\n import tkinter as tk\n \n root = tk.Tk()\n # Hide the root window drag bar and close button\n root.overrideredirect(True)\n # Make the root window always on top\n root.wm_attributes(\"-topmost\", True)\n # Turn off the window shadow\n root.wm_attributes(\"-transparent\", True)\n # Set the root window background color to a transparent color\n root.config(bg='systemTransparent')\n \n root.geometry(\"+300+300\")\n \n # Store the PhotoImage to prevent early garbage collection\n root.image = tk.PhotoImage(file=\"photoshop-icon.gif\")\n # Display the image on a label\n label = tk.Label(root, image=root.image)\n # Set the label background color to a transparent color\n label.config(bg='systemTransparent')\n label.pack()\n \n root.mainloop()\n \n```\n\n> It is possible, but it's OS-dependent. This will work in Windows:\n```\n\n import Tkinter as tk # Python 2\n import tkinter as tk # Python 3\n root = tk.Tk()\n # The image must be stored to Tk or it will be garbage collected.\n root.image = tk.PhotoImage(file='startup.gif')\n label = tk.Label(root, image=root.image, bg='white')\n root.overrideredirect(True)\n root.geometry(\"+250+250\")\n root.lift()\n root.wm_attributes(\"-topmost\", True)\n root.wm_attributes(\"-disabled\", True)\n root.wm_attributes(\"-transparentcolor\", \"white\")\n label.pack()\n label.mainloop()\n \n```\n\n他に後から追記されてそうな簡単な回答がありましたが、上記を含めて動作確認はしていません。\n\n> You can do this: `window.attributes(\"-transparentcolor\", \"somecolor\")`\n\n他にゲームでは使え無さそうですが、こんな記事があります。 \n[Python tkinter\nで多角形(図形)を半透明に重ねる方法を教えてください。](https://teratail.com/questions/126353) \n[Tkinterを使って透明ウィジェットを作成するには?](https://stackoverrun.com/ja/q/4636845) \n[python - tkinter winfo_ -\nどのようにTkinterで形状のアルファを変えることができますか?](https://code.i-harness.com/ja-jp/q/ec0727)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T12:16:46.717", "id": "51871", "last_activity_date": "2019-01-10T13:00:01.240", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "26370", "parent_id": "51869", "post_type": "answer", "score": 0 }, { "body": "Canvasのオブジェクトの表示順序を変えるのならば以下のメソッドで可能だと思いますよ。 \n[tag_raise()](https://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.tag_raise-\nmethod) \n[tag_lower()](https://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.tag_lower-\nmethod)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-06-04T09:10:17.877", "id": "67281", "last_activity_date": "2020-06-04T09:10:17.877", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "40477", "parent_id": "51869", "post_type": "answer", "score": 0 } ]
51869
51871
51871
{ "accepted_answer_id": "51901", "answer_count": 1, "body": "現在、OS自作入門をベースにOSの開発、学習をしています。 \nマルチタスクを実装しようと試みているのですがうまくいきません。 \nOS自作本とは少し設計が違うせいか同じ実装では出来ませんでした。\n\nWeb上にあるOS開発のチュートリアルなども参考にしてますがチュートリアルごとに実装が異なるため余計に混乱しています。 \nページング機能が有効な場合とそうでない場合、ハードウェアコンテキストスイッチとソフトウェアコンテキストスイッチであったり...。\n\n私が望んでいるのはページングが有効でない場合のコンテキストスイッチです。 \nハードウェアコンテキストスイッチかソフトウェアコンテキストスイッチかはあまり気にしていませんが出来ればソフトウェアの方を教えていただきたいです。\n\n回答よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T12:38:13.130", "favorite_count": 0, "id": "51873", "last_activity_date": "2019-01-12T03:43:54.643", "last_edit_date": "2019-01-11T12:52:30.507", "last_editor_user_id": "24999", "owner_user_id": "24999", "post_type": "question", "score": 0, "tags": [ "c", "アセンブリ言語" ], "title": "IA-32でコンテキストスイッチをする方法", "view_count": 188 }
[ { "body": "「ページングが有効でない場合の」というのが難しいかと。 \nそれを外して、既知かもしれませんが、こんな記事がありますので参考に。\n\n[自作OSの紹介的なの](http://ac-mopp.blogspot.com/2014/12/os-advent-\ncalendar-2014-os.html) \n[自作OSでのプロセス実装について (1) ~初めてのユーザプロセス~](http://ac-\nmopp.blogspot.com/2014/12/os-1.html) \n[自作OSでのプロセス実装について (2) ~初めてのユーザプロセス~](http://ac-\nmopp.blogspot.com/2014/12/os-2.html) \n[mopp/Axel](https://github.com/mopp/Axel)\n\nあと断片的でしょうが何か参考になれば。 \n[自作OS Advent Calendar 2018 - Adventar](https://adventar.org/calendars/2915) \n[自作OS Advent Calendar 2017 - Adventar](https://adventar.org/calendars/2282) \n[自作OS Advent Calendar 2016 - Adventar](https://adventar.org/calendars/1666) \n[自作OS Advent Calendar 2014 - Adventar](https://adventar.org/calendars/511)\n\n[FreeDOS ( MS-DOS )\nをマルチタスク化](http://www.ne.jp/asahi/ajara/kojara/multitask.htm)\n\n* * *\n\nついでに、これも既知かもしれませんが、同じ本「OS自作入門」を基にした一連の記事です。 \n[0から作るOS開発](http://softwaretechnique.jp/OS_Development/index.html)\n\nこちらはLinuxカーネルを読み解いている記事です。 \n[Linux Kernel ~ コンテキストスイッチ x86編\n~](https://k-onishi.hatenablog.jp/entry/2018/09/23/145152)\n\n[Linux\nカーネルのコンテキストスイッチ処理を読み解く](http://d.hatena.ne.jp/naoya/20070924/1190653790) \n[x86 Linux\nのメモリモデル、プロセス空間切り替え、カーネルスタック](http://d.hatena.ne.jp/naoya/20071008/1191824562)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T16:22:37.990", "id": "51901", "last_activity_date": "2019-01-12T03:43:54.643", "last_edit_date": "2019-01-12T03:43:54.643", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "51873", "post_type": "answer", "score": 2 } ]
51873
51901
51901
{ "accepted_answer_id": null, "answer_count": 1, "body": "以下のようなプログラムを作ったのですが、人を動かそうとすると背景が消えたり、UFOが表示されなくなったりします。 \nほんとは人を動かしながらも、背景はそのままで、UFOは操作せずにずっと動き続けるようなものを作ろうとしています。\n\nなぜ消えたりするのか教えて欲しいです、後どうすればその様になるのか教えていただけると助かります。\n\n```\n\n #include <stdio.h>\n #include <handy.h>\n #include <time.h>\n #include <math.h>\n \n //人間を描く関数\n void humanA1(int x1,int x2);\n void humanA2(int x1,int x2);\n void humanB1(int x1,int x2);\n void humanB2(int x1,int x2);\n \n void UFO(int a);\n void view(void);\n \n //void plane1(int a, int gid1);\n //void plane2( int gid2);\n //void Flag(int a, int gid1, int gid2);\n \n int main(){\n int x1=0;\n int x2=0;\n int a=0;\n int v;\n int key;\n int count1=0;\n int count2=0;\n // int gid1=HgImageLoad(\"war_stealth_aircraft.png\");\n // int gid2=HgImageLoad(\"war_stealth_aircraft2.png\");\n \n HgOpen(600,600);\n //背景\n view();\n \n for(;;){\n \n key=HgGetChar();\n HgClear();\n //背景\n view();\n //UFO\n UFO(a);\n a=a-10;\n HgClear();\n \n if(a==-400){\n a=a+10;\n HgClear();\n UFO(a);\n HgSleep(0.05);\n }else if(a==540){\n a=a-10;\n HgClear();\n UFO(a);\n HgSleep(0.05);\n }\n \n //左に動く\n if(key=='a'){\n printf(\"%d\\n\",(500+a));\n count1++;\n \n if(count1%2==0){\n humanA2(x1,x2);\n x1=x1-10;\n }else{\n humanB2(x1,x2);\n x1=x1-10;\n }\n }\n \n //右に動く\n if(key=='d'){\n printf(\"%d\\n\",(500+a));\n count2++;\n \n if(count2%2==0){\n humanA1(x1,x2);\n x1=x1+10;\n }else{\n humanB1(x1,x2);\n x2=x2+10;\n } \n }\n }\n \n HgGetChar();\n HgClose();\n \n return 0;\n }\n \n void humanA1(int x1,int x2){//右向き\n HgSetFillColor(HG_ORANGE);\n HgCircleFill(300+x1+x2, 75, 25,0);//頭\n HgLine(300+x1+x2, 50, 300+x1+x2, 25);//胴体\n HgLine(275+x1+x2, 38, 325+x1+x2, 38);//肩から手首\n HgLine(275+x1+x2, 38, 275+x1+x2, 25);//左手\n HgLine(325+x1+x2, 38, 325+x1+x2, 50);//みぎ手\n HgLine(300+x1+x2, 25, 275+x1+x2,0);//左足\n HgLine(300+x1+x2, 25, 325+x1+x2, 25);//みぎ太もも\n HgLine(325+x1+x2, 25, 325+x1+x2, 0);//右足\n }\n void humanA2(int x1,int x2){//左向き\n HgSetFillColor(HG_ORANGE);\n HgCircleFill(300+x1+x2, 75, 25,0);//頭\n HgLine(300+x1+x2, 50, 300+x1+x2, 25);//胴体\n HgLine(275+x1+x2, 38, 325+x1+x2, 38);//肩から手首\n HgLine(275+x1+x2, 38, 275+x1+x2, 50);//左手\n HgLine(325+x1+x2, 38, 325+x1+x2, 25);//みぎ手\n HgLine(300+x1+x2, 25, 275+x1+x2, 25);//左足太もも\n HgLine(275+x1+x2, 25, 275+x1+x2, 0);//左足\n HgLine(300+x1+x2, 25, 325+x1+x2, 0);//右足\n }\n \n void humanB1(int x1,int x2){//右向き\n HgSetFillColor(HG_ORANGE);\n HgCircleFill(300+x1+x2, 75, 25,0);//頭\n HgLine(300+x1+x2, 50, 300+x1+x2, 25);//胴体\n HgLine(300+x1+x2, 38, 275+x1+x2, 30);//左手首\n HgLine(275+x1+x2, 30, 290+x1+x2, 25);//左手\n HgLine(300+x1+x2, 38, 325+x1+x2, 30);//みぎ手首\n HgLine(325+x1+x2, 30, 325+x1+x2, 35);//右手\n HgLine(300+x1+x2, 25, 290+x1+x2, 0);//左足\n HgLine(300+x1+x2, 25, 325+x1+x2, 13);//右足首\n HgLine(325+x1+x2, 13, 312+x1+x2, 0);//右足\n }\n \n void humanB2(int x1,int x2){//左向き\n HgSetFillColor(HG_ORANGE);\n HgCircleFill(300+x1+x2, 75, 25,0);//頭\n HgLine(300+x1+x2, 50, 300+x1+x2, 25);//胴体\n HgLine(300+x1+x2, 38, 275+x1+x2, 30);//左手首\n HgLine(275+x1+x2, 30, 290+x1+x2, 35);//左手\n HgLine(300+x1+x2, 38, 325+x1+x2, 30);//みぎ手首\n HgLine(325+x1+x2, 30, 310+x1+x2, 25);//右手\n HgLine(300+x1+x2, 25, 280+x1+x2, 13);//左足太もも\n HgLine(280+x1+x2, 13, 290+x1+x2, 0);//左足\n HgLine(300+x1+x2, 25, 310+x1+x2, 0);//右足\n }\n \n void UFO(int a){\n HgSetFillColor(HG_GRAY);\n HgFanFill(500+a, 550, 30, 0, M_PI, 1);\n HgOvalFill(500+a, 530, 50, 25, 0, 1);\n HgBoxFill(470+a, 465, 60, 40, 1);\n }\n \n void view(void){\n HgSetFillColor(HG_GREEN);\n HgFanFill(50, 200, 300, 1.25*M_PI, 1.75*M_PI,1);\n HgFanFill(300, 300, 500, 1.25*M_PI, 1.75*M_PI,1);\n HgFanFill(550, 200, 300, 1.25*M_PI, 1.75*M_PI,1);\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T16:02:29.520", "favorite_count": 0, "id": "51877", "last_activity_date": "2019-10-29T18:01:20.153", "last_edit_date": "2019-01-11T00:29:01.867", "last_editor_user_id": "3060", "owner_user_id": "31480", "post_type": "question", "score": 0, "tags": [ "c" ], "title": "プログラムがうまく起動しません。", "view_count": 364 }
[ { "body": "「Handy Graphic」でしょうか。あまり詳しくないのて、アルゴリズム的観点でのみ助言してみます。 \nユーザー入力に反応して描画更新を行う場合の一般的な疑似コードは次の様になります。\n\n```\n\n //-----------------------------------------\n 変数 位置変数; // UFO 人等のX/Y位置等\n \n for( 無限に繰り返す){ // (1)\n 全て消去();\n 全て描画( 位置変数); // 背景、UFO、人等を、毎回全て描画するのが最も簡単な方法\n \n  入力結果 = ユーザー入力待ち();\n \n switch( 入力結果){\n \n //・・・入力結果により「位置変数」を変更・・・(ここでは描画しない)\n \n }// (1)に戻る\n }\n //-----------------------------------------\n \n```\n\n上のアルゴリズムと異なり、掲載されたコードは \n「何らかのアクションのあった時にだけ描画」している様に見えます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T02:00:14.700", "id": "51879", "last_activity_date": "2019-01-11T02:00:14.700", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3793", "parent_id": "51877", "post_type": "answer", "score": 1 } ]
51877
null
51879
{ "accepted_answer_id": null, "answer_count": 1, "body": "Spresense購入してNeural Networkを動かしたいと考えている者です。 \n開発ガイド等を参照してどうしても分からない為、ご質問させて下さい。\n\nSpresense SDKにおいて、SDカード内に予め保存してあるJPGまたはPNG画像ファイルを読込み、DNN\nRuntimeを使って認識処理が出来ないかと考えております。 \n画像ファイルの読込みを行うAPI等はありますでしょうか?(自作するしかないでしょうか?)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-10T21:35:11.380", "favorite_count": 0, "id": "51878", "last_activity_date": "2019-01-16T15:10:49.917", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31748", "post_type": "question", "score": 0, "tags": [ "spresense" ], "title": "SDカードの画像ファイルを読み込む方法", "view_count": 305 }
[ { "body": "すでに解決されているかもしれませんが、スケッチ例の中にある **\"DNNRT\"** の **\"number_recognition\"**\nサンプルは、まさにSDカード内の画像を読み込んで認識する処理をしています。\n\nただ、このサンプルの中で使っている画像フォーマットは **\"PBM\"** です。SPRESENSEのライブラリの中を調べると **NetPBMライブラリ**\nがありましたのでPBMは公式サポートしているようです。\n\nですので、ちょっと不便ですが、 **\"IrfanView\"** などを使って、あらかじめ **PNG を PBM に変換**\nすれば所望の処理はできると思います。\n\n画像ライブラリをもう少し充実させてほしいですよね。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-16T15:10:49.917", "id": "52036", "last_activity_date": "2019-01-16T15:10:49.917", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27334", "parent_id": "51878", "post_type": "answer", "score": 1 } ]
51878
null
52036
{ "accepted_answer_id": null, "answer_count": 1, "body": "こんにちは。 \nxcode初心者です。 \n画面をタッチすると表示される?もの。離すと消えて、タッチし続けたらずっと丸が表示される。といったものを作りたいと思っています。 \nCocoapodsのサンプルとかでよく見るのですが、どのように作ればいいのでしょうか? \nまた、指一本ならひとつ、3本なら三つ指の置いた場所に丸やアニメーションが表示されるようにしたいです。 \nとりあえず今は、UIGestureRecognizerDelegateを使ってタッチしたらラベルにカウントされる。longタッチしたら押しはじめにstart\n終わったらendとラベルに表示させるということをやってみました。 \nグダグダですみません。何かアドバイスいただけたらと思います。 \nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T05:01:22.737", "favorite_count": 0, "id": "51882", "last_activity_date": "2019-02-12T12:00:28.800", "last_edit_date": "2019-01-11T15:00:39.417", "last_editor_user_id": "76", "owner_user_id": "31751", "post_type": "question", "score": 1, "tags": [ "swift", "cocoapods" ], "title": "cocoapodsのサンプルによくあるタッチが見えるやつの作り方", "view_count": 64 }
[ { "body": "OSSライブラリでよければこういったものがあります \n<https://github.com/morizotter/TouchVisualizer>", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-02-12T12:00:28.800", "id": "52731", "last_activity_date": "2019-02-12T12:00:28.800", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19889", "parent_id": "51882", "post_type": "answer", "score": 0 } ]
51882
null
52731
{ "accepted_answer_id": null, "answer_count": 2, "body": "社内のファイルサーバーからエクセルファイルをローカルに落とすことが頻繁にあります。 \nサーバー上のファイルを直接閲覧することは禁止されているため、見るだけであってもローカルに落とす必要があるのですが、毎回、サーバーを見に行きコピペする作業が面倒なので、プログラム実行して自動でダウンロードできたらと思いました。\n\n・サーバーのアドレスは`smb://`で始まる \n・DLしたいファイルは主にエクセルファイル \n・プログラム実行であらかじめ指定してあるファイルをサーバー上からデスクトップにコピー(上書き)\n\nこのようなことは可能でしょうか?また、どの言語が簡単でしょうか。 \nNode.jsやPythonでできれば新たに環境作る必要もないのでその方が良いですが、なんでもいいです。\n\nご回答のほど、よろしくお願いいたします。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T07:05:14.280", "favorite_count": 0, "id": "51885", "last_activity_date": "2023-05-20T08:05:25.643", "last_edit_date": "2020-02-20T13:12:35.677", "last_editor_user_id": "19110", "owner_user_id": "30065", "post_type": "question", "score": 0, "tags": [ "network", "smb" ], "title": "ファイルサーバー上にあるファイルをローカルにDLする", "view_count": 4058 }
[ { "body": "Windowsに標準で付いてくる PowerShell で出来るでしょう。\n\nリファレンスは英語ですが。 \n[Copy-Item](https://docs.microsoft.com/en-\nus/powershell/module/microsoft.powershell.management/copy-\nitem?view=powershell-6)\n\nこんな解説記事があります。 \n[PowerShell の Copy-Item コマンドレットを使用して WinRM\nでファイル転送する方法](https://blog.ipswitch.com/jp/use-powershell-copy-item-cmdlet-\ntransfer-files-winrm)\n\nオプションなので入っていない場合は「コントロールパネル」「プログラムのアンインストール」「Windowsの機能の有効化または無効化」で「Windows\nPowerShell\n2.0」を有効にするか、マイクロソフトのダウンロードセンター等から、もっと新しい版数のパッケージをダウンロードしてインストールすれば良いでしょう。\n\n使用OS版数によってインストール可能な版数が変わると思いますが、最新版は6.0のようです。\n\n検索すれば色々と使い方の記事が出てくると思います。\n\n* * *\n\nコメントを見たらmacのようですが、今ではmacやLinuxでもサポートしているので、 \nおそらく同様に使えるでしょう。使いたいかどうかは、まあお好みで。\n\n[macOS への PowerShell Core のインストール](https://docs.microsoft.com/ja-\njp/powershell/scripting/install/installing-powershell-core-on-\nmacos?view=powershell-6) \n[Linux への PowerShell Core のインストール](https://docs.microsoft.com/ja-\njp/powershell/scripting/install/installing-powershell-core-on-\nlinux?view=powershell-6)\n\n[【連載】PowerShell Core入門 -\n基本コマンドの使い方【第7回】ファイルやディレクトリの作成、削除、コピー、移動](https://news.mynavi.jp/itsearch/article/hardware/3734) \n[クロスプラットフォーム対応したPowerShellをMac OS Xで試してみた](https://dev.classmethod.jp/server-\nside/powershell-macosx/)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T07:31:39.257", "id": "51886", "last_activity_date": "2019-01-11T07:57:22.470", "last_edit_date": "2019-01-11T07:57:22.470", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "51885", "post_type": "answer", "score": 0 }, { "body": "> あらかじめ指定してあるファイル\n\nとのことなので、ファイル名は固定なのですね。\n\n仮に `smb://hoge-server/share/sample.xlsx` というパスに置かれているとします。\n\nこの場合、\n\n```\n\n copy \\\\hoge-server\\share\\sample.xlsx sample.xlsx\n \n```\n\nという1行だけのBATファイルを作り、デスクトップに `copy_xlsx.bat`\nみたいな名前で保存しておき、必要になるたびダブルクリックすれば良いと思います。\n\nこの方法ならば、PowerShellと違って初めて実行する際に、特別に権限を与える必要がありません。\n\n \nただ、もしファイルパスに日本語が含まれていたら、「コピー元ファイルが見つからない」扱いになるため、この方法は使えません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-09-17T09:31:03.083", "id": "70487", "last_activity_date": "2020-09-17T15:54:14.113", "last_edit_date": "2020-09-17T15:54:14.113", "last_editor_user_id": "3060", "owner_user_id": "41938", "parent_id": "51885", "post_type": "answer", "score": 0 } ]
51885
null
51886
{ "accepted_answer_id": "51891", "answer_count": 1, "body": "変数(数値)、a,b,cがあった際に、複数の固定の列を追加して縦持ちのDataFrameを作成したいです。 \nやりたいことは以下のような事になります。\n\nこのような3つの値(DataFrameではありません)があった場合に\n\n```\n\n a\n b\n c\n \n```\n\n以下のように先頭?に列毎に固定の値を設定した列を追加したい。\n\n```\n\n hoge huga a\n hoge huga b\n hoge huga c\n \n```\n\nコードですと以下のような形になります。\n\n```\n\n import pandas as pd\n # 実際にはa,b,cは集計値なので固定ではありません。\n a = 'a'\n b = 'b'\n c = 'c'\n \n # こういった形で、値が固定の列を複数先頭に追加して縦持ちでDataFrameを作成したい\n df = pd.DataFrame([['hoge', 'huga', a],['hoge', 'huga', b],['hoge', 'huga', c]])\n \n```\n\nこのままでも実現はできておりますが、固定値の設定が分散している事からもう少しスマートに実現できればと考えております。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T08:13:09.460", "favorite_count": 0, "id": "51888", "last_activity_date": "2019-01-11T09:53:59.827", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13022", "post_type": "question", "score": 1, "tags": [ "python", "pandas" ], "title": "pandasで固定値列を複数持つDataFrameを作成したい", "view_count": 234 }
[ { "body": "```\n\n import pandas as pd\n \n a = 'a'\n b = 'b'\n c = 'c'\n df = pd.DataFrame({\n 0: 'hoge',\n 1: 'huga',\n 2: [a,b,c]})\n \n```\n\nでどうでしょうか", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T09:53:59.827", "id": "51891", "last_activity_date": "2019-01-11T09:53:59.827", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24801", "parent_id": "51888", "post_type": "answer", "score": 3 } ]
51888
51891
51891
{ "accepted_answer_id": "51895", "answer_count": 2, "body": "どうしてローカルではアプリケーションサーバ(Flask)のみで動作するのにGAEやherokuにアップロードするとGunicornやApache、nginxが必要になるのですか? \n色々種類あるwebサーバは何が違うのですか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T09:00:25.867", "favorite_count": 0, "id": "51889", "last_activity_date": "2019-01-25T03:04:53.077", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22565", "post_type": "question", "score": 7, "tags": [ "python", "nginx", "heroku", "google-app-engine", "flask" ], "title": "アプリケーションサーバとwebサーバの違い。", "view_count": 7987 }
[ { "body": "> Apache、nginxが必要になるのですか?\n\nApacheやNginxなどのWebサーバをAPサーバのフロントに配置する主な目的は、以下のようなことだと思います。\n\n * 負荷分散\n * セキュリティの強化\n * 静的ファイルの処理の高速化\n * Webサーバにしかない機能の利用\n\nWebサーバが無くても要件を満たせるのであれば、APサーバだけでも問題無いです。\n\n> 色々種類あるwebサーバは何が違うのですか?\n\n機能やアーキテクチャなどいろいろ違います。「Apache vs Nginx」とか「Apache Nginx 比較」とかでググればたくさん情報が出てきます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T09:34:19.633", "id": "51890", "last_activity_date": "2019-01-25T03:04:53.077", "last_edit_date": "2019-01-25T03:04:53.077", "last_editor_user_id": "21092", "owner_user_id": "21092", "parent_id": "51889", "post_type": "answer", "score": 6 }, { "body": "Gunicorn → アプリケーションサーバー \nApahceやNGinx → Webサーバー \nFlask → PythonのWebアプリケーション フレームワーク \nになるかと思います。\n\nFlask\nには、サーバー機能が組み込まれてはいますが、開発やテストをすることを主眼に用意されており、性能、安定性、セキュリティなどは考慮されておらず、簡素な物です。\n\n本番運用する場合は Gunicorn などの アプリケーションサーバー(WSGI サーバー)を利用するのが推奨されています。\n\nGunicorn は Pythonで実装された WSGI サーバーで、Webサーバーとしての機能もあるので Gunicorn単体でも動きますが、Nginx\nと組み合わせるのが強く推奨されていて、外部からの攻撃に強くなるのが理由として挙げられてます。 \n<http://docs.gunicorn.org/en/latest/deploy.html>\n\nApacheと、Nginxは どちらも人気で実績の多いHTTPサーバーです。違いはとても書ききれませんが、超々ざっくり特徴を書くと\n\n * Apacheは歴史が古く 長い期間をかけて 拡張されてきた ど定番 Webサーバー。\n * Nginxは比較的新しくて設定がシンプルなので 今は これが一押し Webサーバー。\n\nこんな感じかと。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T11:36:32.767", "id": "51895", "last_activity_date": "2019-01-11T11:36:32.767", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "51889", "post_type": "answer", "score": 5 } ]
51889
51895
51890
{ "accepted_answer_id": "52013", "answer_count": 3, "body": "ネットワークの基礎を現在学習しており、不明点がありました為、質問させて頂きます。\n\n一対複数時の通信の時の挙動なのですが、 \nどの層の時点で、PCの数の把握、必用なデータの数のコピー(一対一の通信ならデータは一つで十分なはずだが、複数との通信では複数いるのだろうと現在理解しています。)を行っているのかが理解できていません。\n\n例として、(自分の考えている)ローカルブロードキャストの時の動きとしましては、\n\n送信側 \nネットワーク層でローカルブロードキャストのブロードアドレスをIPホストアドレスに指定 \n↓ \nネットワーク層にてARPをかける(ローカル領域の接続PCの数の確認) \n↓ \n応答(ARP?)が返ってくる。 \n↓ \nネットワーク層まで応答(ARP?)が上がってくる \n↓ \nデータリンク層、物理層を通って、ローカル領域の接続PCの数の分のデータを送信\n\nが一連の流れになると思うのですが、 \nこの時、PCの数分のデータのコピー(用意)はどこで行っているのでしょうか? \nまた、応答(ARP?)を送信側が受け取った後、「ネットワーク層までしか、連絡は来ない」という認識は正しいでしょうか? \nどなたか回答をお持ちの方がいらしたら、是非ともご教示頂きたいです。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T10:51:39.600", "favorite_count": 0, "id": "51892", "last_activity_date": "2019-01-22T08:30:47.840", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31383", "post_type": "question", "score": 2, "tags": [ "network", "tcp" ], "title": "TCP/IP通信によるブロードキャストの挙動", "view_count": 1580 }
[ { "body": "ブロードキャストIPアドレス宛のパケットは、LAN(Ethernet)であればブロードキャストMACアドレス宛に送信されます。MACアドレス解決の必要はないのでARPのやりとりは行われません。\n\nwiresharkなどパケットキャプチャソフトを使って実際の通信を観察してみるとよいでしょう。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T12:49:01.867", "id": "51897", "last_activity_date": "2019-01-11T12:49:01.867", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "51892", "post_type": "answer", "score": 2 }, { "body": "> 一対一の通信ならデータは一つで十分なはずだが、複数との通信では複数いるのだろうと現在理解しています。\n\nおそらくこの認識が誤りの元だと思われます。 \nブロードキャスト通信では複数の端末に別々にデータを送信するわけではありません。 \nブロードアドレスなどに宛てて送信したデータを、受信可能な端末が自分宛だと解釈して受信しています。 \n不特定多数向けのブロードキャストに応答(ARP)を期待するのも誤っています。\n\n極端な例ですが、地上波でもケーブルでもテレビ局がいちいちテレビの台数分データのコピーを取っているわけではありません。 \nアプリケーションレベルのデータのコピーと、物理的なレベルの拡散は混同すべきではありません。 \nネットワークの基礎の学習中ということでしたら不要な知識ですが、ケーブルや電波などのコピーしなくても拡散するイメージ程度は持っていた方がいいかもしれません。\n\n*追記 \nブロードキャストは受信側が自分宛だと解釈して受信と前述しましたが、自分宛でない通信もネットワーク上には流れてきています。 \nその中で自分宛のものを拾う際にブロードキャストアドレス(一例)も含めて受信しているという意味です。 \nブロードキャストだけが特別にネットワーク全体に伝番しているかのようなイメージを与えてしまっていたら訂正します。\n\n*再追記\n\n> @Yamaguchi Kohei \n>\n> 送信データは送信先アドレスがローカルでない以上全てWANに出ており、各受信先ルーターが自分のネットワークアドレスでない場合は破棄しているという解釈であっていますか?\n\nこちらについてですが、ブロードキャストは基本的に同一のデータリンク層かネットワーク層で行われています。 \nこのうちデータリンク層レベルであれば送信先のアドレスに関わらずネットワーク全体に伝番しています。こちらの意で追記しました。 \nネットワーク層レベルのブロードキャストであればルータによってブロードキャストが行われるので自然に伝播しているとは言い難いです。しかし、ネットワーク層を介した先のデータリンク層内で伝番するので、質問のような複数端末向けにデータのコピー(アプリケーションレベル)をするわけではありません。 \n”送信先アドレスがローカルでない”や”全てWANに出ており”という解釈については、質問のローカルブロードキャストの前提とは異なりますし、ブロードキャストを使用したからといって広域に広がってセキュリティ上問題があるようなことにはなりません。(ネットワーク層レベルでは、ブロードキャストであってもネットワークアドレスを指定するため) \nブロードキャストのデータのコピーの不必要性の説明のためにデータの拡散性について述べましたが、それはローカルのネットワークに限っての話です。 \nブロードキャスト通信はデータリンク層レベルであればローカルのネットワーク接続機器のみが、 \nネットワーク層レベルであれば指定されたネットワークアドレスのみが対象で限られた範囲の話です。 \nテレビ局の例はブロードキャストの例としては不適切ですので忘れてください。\n\n> 各受信先ルーターが自分のネットワークアドレスでない場合は破棄しているという解釈であっていますか? \n> ルータがという部分をローカルの接続機器に読み替えれば後半の解釈は概ね正しいです。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-16T05:48:10.687", "id": "52009", "last_activity_date": "2019-01-22T08:30:47.840", "last_edit_date": "2019-01-22T08:30:47.840", "last_editor_user_id": "31800", "owner_user_id": "31800", "parent_id": "51892", "post_type": "answer", "score": 1 }, { "body": "@suzukisさん@bluevioletさんの補足で、質問記述に対する内容を書くと以下になるでしょう。\n\n> どの層の時点で、PCの数の把握、必用なデータの数のコピーを行っているのかが理解できていません。\n\n**答:これらは送信側ホストの中では行っていません。**\n\n> 例として、(自分の考えている)ローカルブロードキャストの時の動きとしましては、\n>\n> 送信側 \n> ネットワーク層でローカルブロードキャストのブロードアドレスをIPホストアドレスに指定 \n> ↓ \n> ネットワーク層にてARPをかける(ローカル領域の接続PCの数の確認) \n> ↓ \n> 応答(ARP?)が返ってくる。 \n> ↓ \n> ネットワーク層まで応答(ARP?)が上がってくる \n> ↓ \n> データリンク層、物理層を通って、ローカル領域の接続PCの数の分のデータを送信\n>\n> が一連の流れになると思うのですが、\n\n**答:ARPは行われません。 \nまた送信側ホスト内での接続PC数把握やデータのコピーもありません。**\n\n```\n\n 送信側\n ネットワーク層でローカルブロードキャストのブロードアドレスを宛先IPホストアドレスに指定\n ↓\n 宛先MACアドレスは全てのbitが1のブロードキャストMACアドレスが設定されます。\n ↓\n データリンク層、物理層を通って、ネットワークにデータを送信\n \n```\n\nブロードキャストだからといって特別なコピーが行われるわけではなく、通常の通信と同様に \nハブ等のネットワーク機器が中継してネットワーク内の各ホストに送信します。\n\n**質問者さんの考える、「必要なデータの数のコピー」はそれら機器で行われているとも言えます。** \nただし、「必要」かどうかとか「台数」は低機能なハブ等では考慮されません。 \nポートの先に何かの装置が接続されて通信できているかどうかくらいですか。\n\nインテリジェントハブとか高機能な機器は、設定情報などにより中継する/しないを制御します。\n\nそしてブロードキャストを受信した側で、自分が処理すべき通信か(対応するサービスやプロセスが動作しているか)どうかを判断することになります。\n\n候補がいっぱいあるのですが、この辺の記事あたりが参考になるでしょう。\n\n[ブロードキャストアドレス・マルチキャストアドレス](http://www.n-study.com/network/broadcast.htm)\n\n[◆ブロードキャストアドレスの用途](http://atnetwork.info/ccent/ip21.html)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-16T08:06:32.407", "id": "52013", "last_activity_date": "2019-01-16T08:13:43.897", "last_edit_date": "2019-01-16T08:13:43.897", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "51892", "post_type": "answer", "score": 1 } ]
51892
52013
51897
{ "accepted_answer_id": "51904", "answer_count": 1, "body": "pythonを用いてcsvファイルをlist型として読み込み、pylabでplotしようと思ったら下のような結果となってしまいました(1枚目元のデータ、2枚目plot結果)\n\n[![元](https://i.stack.imgur.com/4PjJh.png)](https://i.stack.imgur.com/4PjJh.png) \n[![結果](https://i.stack.imgur.com/nIBFW.png)](https://i.stack.imgur.com/nIBFW.png)\n\nプログラムは下の様に記述しました\n\n```\n\n from matplotlib import pylab as pl\n import csv\n \n if __name__ == \"__main__\":\n \n data = []\n with open(\"data.csv\",\"r\") as f:\n reader = csv.reader(f)\n for row in reader:\n data.append(row[0])\n \n fig = pl.figure()\n fig.add_subplot(111)\n pl.plot(data)\n pl.xlim([0, len(data)])\n pl.show()\n \n```\n\n何が原因で元のファイルと同じように表示されないのかわかりません \n軸をyticksやylimで整えようとしたのですが何をやってもこの形になってしまいました \nご助言よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T11:33:11.500", "favorite_count": 0, "id": "51894", "last_activity_date": "2019-01-12T01:57:48.703", "last_edit_date": "2019-01-11T11:41:24.387", "last_editor_user_id": "3060", "owner_user_id": "31757", "post_type": "question", "score": 0, "tags": [ "python", "matplotlib", "csv" ], "title": "list型のplotについて", "view_count": 185 }
[ { "body": "CSV ファイルの形式がどうなっているか知りませんが、以下でできると思います\n\n```\n\n import pandas as pd\n import matplotlib.pyplot as plt\n \n if __name__ == \"__main__\":\n data = pd.read_csv(\"data.csv\", names=[\"x\", \"y\"])\n \n # print(data) # デバッグ用\n plt.plot(data[\"x\"], data[\"y\"])\n plt.show()\n \n```\n\n追記です \nもしうまくいかないようでしたら、CSV ファイルの中身をコメントで頂けたらなんとかできると思います(最初の数行だけでかまいません)", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T01:50:48.083", "id": "51904", "last_activity_date": "2019-01-12T01:57:48.703", "last_edit_date": "2019-01-12T01:57:48.703", "last_editor_user_id": "29776", "owner_user_id": "29776", "parent_id": "51894", "post_type": "answer", "score": 0 } ]
51894
51904
51904
{ "accepted_answer_id": null, "answer_count": 2, "body": "今、ruby on\nrailsで複合条件の検索を実装をしています。二つのカラムの項目があって、そのカラムに一致するレコードを表示されるようにしようとしています。viewとmodelを変えたのですが、まだ二つが重なる条件が出てきません。どうぞ教えていただけたら、嬉しいです。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/uwnrA.png)](https://i.stack.imgur.com/uwnrA.png)\n\n```\n\n Controller \r\n \r\n def index\r\n @plans = Plan.includes(:guider).page(params[:page]).per(5).order(\"created_at DESC\")\r\n @plans = Plan.page(params[:page]).per(5).order(\"created_at DESC\").search(params[:search])\r\n end\n```\n\n```\n\n Model\r\n \r\n def self.search(search) \r\n if search \r\n Plan.where(\"(datetimes like ?) AND (title like ?)\", \"%#{params[:search1]}%\", \"%#{params[:search2]}%\")\r\n else\r\n Plan.all\r\n end\r\n end\n```\n\n```\n\n <div class=\"david\">\r\n <%= form_tag plans_path, :method => 'get', :class => 'david' do %>\r\n <p><strong>Place: </strong></p>\r\n <div style=\"width: 250px;\" placeholder=\"date\" >\r\n <p><%= text_field_tag :datetimes, params[:search1] %></p>\r\n <p><%= text_field_tag :title, params[:search2] %></p>\r\n <%= submit_tag \"Search\", :name => nil %>\r\n </div>\r\n <% end %>\r\n </div>\n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T13:03:22.240", "favorite_count": 0, "id": "51898", "last_activity_date": "2019-01-12T00:25:32.167", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30829", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "html" ], "title": "複合条件での検索結果が出てこない状態になってます。", "view_count": 73 }
[ { "body": ">\n```\n\n> def self.search(search)\n> if search\n> Plan.where(\"(datetimes like ?) AND (title like ?)\",\n> \"%#{params[:search1]}%\", \"%#{params[:search2]}%\")\n> \n```\n\nモデルの中では`params`は参照できません。素直に書き換えるのであれば\n\n```\n\n def self.search(search1, search2) \n if search1 && search2 \n Plan.where(\"(datetimes like ?) AND (title like ?)\", \"%#{search1}%\", \"%#{search2}%\")\n \n```\n\nとして、呼び出す側も引数を2つ渡すように書き換えてください。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-11T13:30:55.787", "id": "51900", "last_activity_date": "2019-01-11T13:30:55.787", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "51898", "post_type": "answer", "score": 1 }, { "body": "# clientからserverへ値の渡し方\n\n@suzukis さんの回答の通りmodelでは`params`をそのまま用いることはできません。\n\nまた、viewで\n\n`<%= text_field_tag :datetimes, params[:search1] %>`\n\nとすると、`params[:search1]`が`nil`であった場合生成されるhtmlは\n\n`<input type=\"text\" name=\"datetimes\" id=\"datetimes\">`\n\nとなります。\n\n`params[:search1]`や`params[:search2]`のように`:datetimes`ではないkeyを用いて`params`を呼び出しているので、clientから送られてきたパラメータを適切に扱えてないように思えます。\n\n# controllerで`@plans`の複数定義\n\n```\n\n def index\n @plans = Plan.includes(:guider).page(params[:page]).per(5).order(\"created_at DESC\")\n @plans = Plan.page(params[:page]).per(5).order(\"created_at DESC\").search(params[:search])\n end\n \n```\n\nとありますが、2回目の`@plans = ...`で1回目の`@plans`を上書きしているので、冗長化と思われます。\n\n# その他\n\nどのようなスキーマなのかわからないので、ただしいクエリが発行されいているかどうかは現状なんとも言えません。\n\nそれを確認するにはリクエスト・レスポンス時の`rails\nserver`でどのようなSQLが発行されているのかを見ることと、controllerでの`@plans`をdumpして適切なデータを取得できているかを見ることをお勧めします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T00:25:32.167", "id": "51902", "last_activity_date": "2019-01-12T00:25:32.167", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31669", "parent_id": "51898", "post_type": "answer", "score": 0 } ]
51898
null
51900
{ "accepted_answer_id": "51905", "answer_count": 1, "body": "質問は2つあります \n1.\n\n```\n\n from matplotlib import pyplot as plt\n \n```\n\nではなく\n\n```\n\n import matplotlib.pyplot as plt\n \n```\n\nと書くのはなぜですか?\n\n2. \n2通りの書き方ができるなら普段はどちら(from を使う使わない)を使うべきですか?\n\n既に同じ質問がありましたら申し訳ございません", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T01:12:26.297", "favorite_count": 0, "id": "51903", "last_activity_date": "2019-01-12T02:43:39.457", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29776", "post_type": "question", "score": 0, "tags": [ "python", "matplotlib", "coding-style" ], "title": "python における import 文のスタイルに関して", "view_count": 304 }
[ { "body": "丁度こちらに同様の記事がありました。 \n[Is “from matplotlib import pyplot as plt” == “import matplotlib.pyplot as\nplt”?](https://stackoverflow.com/q/30558087/9014308)\n\n質問への回答としては、1.tutorialにそう書いてあるから。2.どちらでもお好みで。でしょう。 \n(回答者は下側の方が良いと考えています) google翻訳結果を載せておきます。\n\n> それらは同等ですが、pltとしての2番目の形式import\n> matplotlib.pyplotの方が客観的に読みやすいという、かなり良い議論があると思います。\n>\n> 1.一般的にはpltとしてimport\n> matplotlib.pyplotを使用し、matplotlibドキュメンテーション(<http://matplotlib.org/users/pyplot_tutorial.html>などを参照)で推奨されているので、これはほとんどの読者にとってより身近なものになるでしょう。\n>\n> 2.matplotlib.pyplotはpltが短いほどインポートされますが、それほど明確ではありません。\n>\n>\n> 3.pltとしてmatplotlib.pyplotをインポートすることは、なじみのない読者に、pyplotが最初の形式から誤って想定される可能性がある関数ではなくモジュールであるというヒントを与えます。\n>\n> コメント: matplotlibはパッケージで、本質的には関連モジュールの集合です。\n> 最も簡単に言うと、パッケージは空の__init__.pyファイルを持つモジュールファイルを含むディレクトリにすることができます。このファイルは、そのディレクトリをパッケージとして扱うことをpythonに指示します。\n> パッケージA内のモジュールB(つまり、ファイル構造A / B.py)は、インポートA.Bとしてインポートされます。\n\n日本語でimportの使い方の記事がありました。 \n[Python, importの使い方(from, as, PEP8の推奨スタイル,\n注意点など)](https://note.nkmk.me/python-import-usage/)\n\n開発元の推奨スタイルがあるようです。 \n[PEP 8 imports -- Style Guide for Python Code |\nPython.org](https://www.python.org/dev/peps/pep-0008/#imports)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T02:43:39.457", "id": "51905", "last_activity_date": "2019-01-12T02:43:39.457", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "26370", "parent_id": "51903", "post_type": "answer", "score": 1 } ]
51903
51905
51905
{ "accepted_answer_id": null, "answer_count": 1, "body": "AUTOCADでWMFファイルを作成することはできるのですが、IJCADで実装する方法がわかりません。 \nご教示いただけないでしょうか。 \nAUTOCADでWMFファイルを作成するプログラムは以下の通りです。\n\n```\n\n Function ImportWMF(FullPath As String, ptIns As Point3d, scale As Double) As String\n Dim doc As Autodesk.AutoCAD.ApplicationServices.Document = \n Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument\n \n Using doc.LockDocument()\n Dim acadDoc As Object = \n Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetAcadDocument(doc)\n Try\n Dim obj As Autodesk.AutoCAD.Interop.Common.AcadObject = acadDoc.Import(FullPath, ptIns.ToArray, scale)\n Return obj.Handle\n \n Catch ex As Exception\n Return String.Empty\n End Try\n End Using\n End Function\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T07:06:52.057", "favorite_count": 0, "id": "51909", "last_activity_date": "2019-01-15T02:41:09.103", "last_edit_date": "2019-01-12T10:34:20.743", "last_editor_user_id": "3060", "owner_user_id": "31055", "post_type": "question", "score": 0, "tags": [ ".net", "ijcad" ], "title": "IJCADでのWMFファイルの作成方法", "view_count": 158 }
[ { "body": "IJCADの.NET APIでは、Editor.CommandメソッドでWMFINコマンドを使用するとで、WMFを読み込めると思います。\n\n```\n\n Function ImportWMF(FullPath As String, ptIns As Point3d, scale As Double, rotated As Double) As String\n Dim doc As Document = Application.DocumentManager.MdiActiveDocument\n Dim ed As Editor = doc.Editor\n ed.Command(\"WMFIN\", FullPath, ptIns, scale, scale, rotated)\n Dim res As PromptSelectionResult = ed.SelectLast()\n If res.Status = PromptStatus.OK Then\n Return res.Value.GetObjectIds()(0).Handle.ToString()\n End If\n Return String.Empty\n End Function\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-15T02:41:09.103", "id": "51977", "last_activity_date": "2019-01-15T02:41:09.103", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "51909", "post_type": "answer", "score": 0 } ]
51909
null
51977
{ "accepted_answer_id": "51963", "answer_count": 2, "body": "当方オープンソースの開発には参加したことがありません。 \nあるレポジトリで自分が実装できそうもない機能の開発を依頼したいのですが \nこういうのって第三者が気軽に登録してもいいものなのでしょうか。 \n(アホな質問ですみません。)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T07:58:18.633", "favorite_count": 0, "id": "51910", "last_activity_date": "2019-01-14T05:36:38.543", "last_edit_date": "2019-01-12T08:46:30.917", "last_editor_user_id": "754", "owner_user_id": "19755", "post_type": "question", "score": 4, "tags": [ "github", "oss" ], "title": "GitHubで第三者が気軽にIssue登録しても大丈夫ですか?", "view_count": 439 }
[ { "body": "いいですよ。ただし、それを実装するかどうかはそのOSSの開発者次第なので、その機能が必要と思われなければ、そのままスルー(最終的にはクローズ)されると思いますが。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T08:33:05.770", "id": "51911", "last_activity_date": "2019-01-12T08:33:05.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21092", "parent_id": "51910", "post_type": "answer", "score": 6 }, { "body": "* いくつかのリポジトリでは `CONTRIBUTING` というファイルや `README` というファイルに、機能追加を要望したい場合のやり方が書いてあります。GitHub への issue 登録以外の方法をとっているソフトウェアもあるので、もしあればそちらを参考にすると良いです。\n * 何も書かれておらず、ソースコードが GitHub で管理されているのであれば、issue を登録するので良いでしょう。Issue を登録したからといってそれが必ずしも実装されることになるとは限りませんが、意見を募ることはできます。できれば「なぜその機能が必要なのか」が具体的に書かれているとありがたいかなと思います。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-14T05:36:38.543", "id": "51963", "last_activity_date": "2019-01-14T05:36:38.543", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "51910", "post_type": "answer", "score": 9 } ]
51910
51963
51963
{ "accepted_answer_id": "51945", "answer_count": 1, "body": "Linux Subsystem UbuntuのBashから`mecab`を起動すると正常:\n\n```\n\n nyck33@DESKTOP-9JIJ7R7:/mnt/c/Users/nick/Downloads$ mecab\n 面白い\n 面白い 形容詞,*,イ形容詞アウオ段,基本形,面白い,おもしろい,代表表記:面白い/おもしろい 反義:形容詞:つまらない/つまらない\n EOS\n \n```\n\nMINGW64では分からない漢字が表示される:\n\n```\n\n $ mecab\n 面白い\n 面白い 險伜捷,荳闊ャ,*,*,*,*,*\n EOS\n 馬鹿だな\n 險伜捷,荳闊ャ,*,*,*,*,*\n n 蜷崎ゥ・蝗コ譛牙錐隧・邨・ケ・*,*,*,*\n 鹿だな 險伜捷,荳闊ャ,*,*,*,*,*\n EOS\n \n```\n\nWindows Command Promptでも同じく:\n\n```\n\n C:\\Users\\nick>mecab\n 面白い\n 面白い 險伜捷,荳闊ャ,*,*,*,*,*\n EOS\n \n```\n\n先ほどまでWindows Command Promptでは正常に動いていたのに、以下の説明でLinux Bashで使えるようにしたらこうなってしまいました。\n\n[MecabをWindows Ubuntu\nBashで使う方法](https://qiita.com/yukinoi/items/6475285c00f90e802b4b)\n\n上記3つのShellで使える方法はありますか。それともWindows Linux\nBashで使えるようにしたら他が駄目になってしまうものですか。助言をお願いします。\n\nEdit:\n\nこちら[WindowsでMecab-\nPython](https://qiita.com/fu23/items/34f55f0b7aaa7e2205b8)を参考にしてインストールしなおそうとしましたが、`python\nsetup.py build`の時点で以下のエラーが発生しました:\n\n```\n\n running install\n running build\n running build_py\n running build_ext\n building '_MeCab' extension\n C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD \"-IC:\\Program Files (x86)\\MeCab\\sdk\" -IC:\\ProgramData\\Anaconda3\\include -IC:\\ProgramData\\Anaconda3\\include \"-IC:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\ATLMFC\\include\" \"-IC:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\include\" \"-IC:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\include\\um\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\shared\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\um\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\winrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\cppwinrt\" /EHsc /TpMeCab_wrap.cxx /Fobuild\\temp.win-amd64-3.6\\Release\\MeCab_wrap.obj\n MeCab_wrap.cxx\n MeCab_wrap.cxx(3052): fatal error C1083: Cannot open include file: 'mecab.h': No such file or directory\n error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2017\\\\Community\\\\VC\\\\Tools\\\\MSVC\\\\14.14.26428\\\\bin\\\\HostX86\\\\x64\\\\cl.exe' failed with exit status 2\n \n```\n\n確認したら問題の`mecab.h`はありました:\n\n[![ファイルの保存先](https://i.stack.imgur.com/jlGq6.png)](https://i.stack.imgur.com/jlGq6.png)\n\n`\\Anaconda3\\Lib\\site-package`には`MeCab.py`がありました:\n\n[![ファイルの保存先](https://i.stack.imgur.com/pPuXx.png)](https://i.stack.imgur.com/pPuXx.png)\n\n追加情報:\n\n上記の現状のまま、ファイルからは正常に動作します。\n\n```\n\n $ python mecab-test.py\n 安倍 アベ 安倍 名詞-固有名詞-人名-姓\n 晋 ススム 晋 名詞-固有名詞-人名-名\n 三 サン 三 名詞-数\n 首相 シュショウ 首相 名詞-一般\n は ハ は 助詞-係助詞\n 、 、 、 記号-読点\n 国会 コッカイ 国会 名詞-一般\n で デ で 助詞-格助詞-一般\n 施政 シセイ 施政 名詞-一般\n 方針 ホウシン 方針 名詞-一般\n 演説 エンゼツ 演説 名詞-サ変接続\n を ヲ を 助詞-格助詞-一般\n 行っ オコナッ 行う 動詞-自立 五段・ワ行促音便 連用タ接続\n た タ た 助動詞 特殊・タ 基本形\n 。 。 。 記号-句点\n EOS\n \n```\n\nコマンドラインからは相変わらず異常です:\n\n```\n\n $ mecab\n アイスクリーム\n 險伜捷,荳闊ャ,*,*,*,*,*\n A 蜷崎ゥ・蝗コ譛牙錐隧・邨・ケ・*,*,*,*\n 險伜捷,荳闊ャ,*,*,*,*,*\n C 蜷崎ゥ・蝗コ譛牙錐隧・邨・ケ・*,*,*,*\n 險伜捷,荳闊ャ,*,*,*,*,*\n X 蜷崎ゥ・蝗コ譛牙錐隧・邨・ケ・*,*,*,*\n 險伜捷,荳闊ャ,*,*,*,*,*\n N 蜷崎ゥ・蝗コ譛牙錐隧・邨・ケ・*,*,*,*\n リ 險伜捷,荳闊ャ,*,*,*,*,*\n [ 蜷崎ゥ・繧オ螟画磁邯・*,*,*,*,*\n ム 險伜捷,荳闊ャ,*,*,*,*,*\n EOS\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T08:33:37.017", "favorite_count": 0, "id": "51912", "last_activity_date": "2019-01-13T14:30:09.397", "last_edit_date": "2019-01-13T14:30:09.397", "last_editor_user_id": "29239", "owner_user_id": "29239", "post_type": "question", "score": 0, "tags": [ "linux", "ubuntu", "windows-10", "mecab", "mingw" ], "title": "MecabをWindows10にインストール後、コマンドラインから使うと漢字だけが表示される", "view_count": 745 }
[ { "body": "おそらく文字コードです。読み込みに利用しているファイルの文字コードと、実行時のLocaleのつじつまあっているか、確認してください。 \nWindowsコマンド環境では・・・・といいう話なので、ja_JP.UTF8でSJISのテキストを処理しようとしたりしてませんか?<読み込み時に指定していないと大抵、ご提示の雰囲気の文字列に化けます。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T09:03:20.770", "id": "51945", "last_activity_date": "2019-01-13T09:03:20.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10174", "parent_id": "51912", "post_type": "answer", "score": 1 } ]
51912
51945
51945
{ "accepted_answer_id": null, "answer_count": 0, "body": "初めまして. \npythonでスクレイピングをしています. \nしかし,大量に(数十~数百件)下記のようなプログラムでhtmlを得ていると, \n`browser.page_source`で処理が止まってしまいます. \nエラーが出るわけでもなく,数十分しても動き出しません.\n\n同じような状況の方はいらっしゃいますでしょうか. \nまた,解決した方がいらっしゃいましたら,その方法を教えてください.\n\nよろしくお願いいたします.\n\n```\n\n from selenium import webdriver\n from selenium.webdriver.chrome.options import Options\n # ブラウザーを起動\n options = Options()\n options.add_argument('--headless')\n # Chromeのドライバを得る\n browser = webdriver.Chrome(chrome_options=options)\n \n browser.set_script_timeout = 30\n browser.timeout = 30\n browser.implicitly_wait = 30\n browser.set_page_load_timeout = 30\n browser.get(url)\n # htmlを取得\n html = browser.page_source\n \n```\n\n**追記1** : \nコメントありがとうございます. \n大量に取得する部分ですが, \nurlのリスト`urls = [\"https://~~\", \"https://~~\", ...]`といったものを作成し,\n\n```\n\n for url in urls:\n scraping(url)\n \n```\n\nという風に記載しています. \nscraping(url)は上記のようなプログラムです.\n\n**追記2** : \nコメントありがとうございます.\n\n> scraping(url)は上記のようなプログラムです.\n\nこの書き方がよくありませんでした. \nすみません. \n最初に提示したプログラムがscraping(url)です. \nですので,\n\n```\n\n def scraping(url):\n # ブラウザーを起動\n options = Options()\n options.add_argument('--headless')\n # Chromeのドライバを得る\n browser = webdriver.Chrome(chrome_options=options)\n \n browser.set_script_timeout = 30\n browser.timeout = 30\n browser.implicitly_wait = 30\n browser.set_page_load_timeout = 30\n browser.get(url)\n # htmlを取得\n html = browser.page_source\n return (html)\n \n```\n\nこのようなプログラムです.\n\n運がいいときは,止まらずに数百件の処理を行いますが, \n悪いと,数件処理した後にhtml = の部分で止まります.", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T08:41:58.430", "favorite_count": 0, "id": "51913", "last_activity_date": "2019-01-12T11:48:37.010", "last_edit_date": "2019-01-12T11:48:37.010", "last_editor_user_id": "31767", "owner_user_id": "31767", "post_type": "question", "score": 0, "tags": [ "python", "selenium" ], "title": "python seleniumを使っていると処理が止まる?", "view_count": 1703 }
[]
51913
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "複数のjsonファイルの中の数字を読み込むときに345個のファイルを読み込みたいのに256個までしか読み取ることができません。 \n原因がわからないので理由と対処法を教えていただきたいです。\n\nプログラムコード\n\n```\n\n import json\n \n i = 000000000000\n \n for file_name in [\"rightleft_{:012d}_keypoints.json\".format(i) for i in range(345)]:\n with open(file_name) as f:\n read_data = json.load(f)\n print(read_data['people'][0]['face_keypoints_2d'][21])\n \n```\n\nエラーコード \n256個までファイルを読み込んだあとに\n\n```\n\n Traceback (most recent call last):\n \n```\n\nと出て\n\n```\n\n IndexError: list index out of range\n \n```\n\nというエラーが出る。\n\nプログラム初心者なので基礎的なことかもしれませんがお願いします。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T08:43:39.473", "favorite_count": 0, "id": "51914", "last_activity_date": "2021-02-08T06:57:17.933", "last_edit_date": "2019-01-12T10:04:10.323", "last_editor_user_id": "3060", "owner_user_id": "31694", "post_type": "question", "score": 0, "tags": [ "python", "python3", "json" ], "title": "Pythonでjsonファイル読み込み", "view_count": 253 }
[ { "body": "それぞれの行を`try except`で囲んでみては? \n該当のファイルが有効なjsonデータでないとか、 ['people'][0]['face_keypoints_2d'][21]\nに相当するデータが無いとか、どちらの行で、どんな状況でエラーになっていたのか、を確認してみてください。\n\n* * *\n\nこの投稿は @kunif\nさんの[コメント](https://ja.stackoverflow.com/questions/51914/#comment54220_51914)などを元に編集し、[コミュニティWiki](https://ja.meta.stackoverflow.com/q/1583)として投稿しました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2021-02-08T06:57:17.933", "id": "73861", "last_activity_date": "2021-02-08T06:57:17.933", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "51914", "post_type": "answer", "score": 0 } ]
51914
null
73861
{ "accepted_answer_id": null, "answer_count": 2, "body": "下記の使い方がわかりません。 \nサンプル例、ご教示頂けないでしょうか?\n\n```\n\n void attachTimerInterrupt(unsigned int (*isr)(void), unsigned int us);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T10:00:22.540", "favorite_count": 0, "id": "51916", "last_activity_date": "2019-01-15T15:43:36.120", "last_edit_date": "2019-01-12T10:10:04.850", "last_editor_user_id": "3060", "owner_user_id": "31768", "post_type": "question", "score": 0, "tags": [ "arduino", "spresense" ], "title": "spresense Arduino IDE タイマー割込み", "view_count": 808 }
[ { "body": "お疲れ様です。 \nあまりネット上にサンプルがころがっていない感じですね。 \nattachInterrupt \nならば、たくさんあるので、それを参考にして下さい。 \nおそらく、ISRとかお詳しくないんですよね。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T21:19:05.067", "id": "51927", "last_activity_date": "2019-01-12T21:19:05.067", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31548", "parent_id": "51916", "post_type": "answer", "score": 0 }, { "body": "Spresense の Arduino ライブラリのヘッダファイルを見てみたら、以下のように定義されていました。\n\n```\n\n void attachTimerInterrupt(unsigned int (*isr)(void), unsigned int us);\n // Parameter:\n // isr: the function to call when the timer interrupt occurs.\n // This function must return the next timer period [microseconds].\n // If this function returns 0, the timer stops and it behaves as oneshot timer.\n // us: microseconds.\n // The maximum value is about 26 seconds and if it exceeds, an error occurs.\n // Note:\n // This can not be used at the same time with tone().\n \n```\n\nコールバック関数の戻り値の扱いが少し分かりにくいですが、以下のようなコードを書いてみたら、なんとなく動きました。\n\n```\n\n #define INTERVAL 100\n \n static unsigned long counter = 0;\n \n unsigned int callback_func() {\n Serial.print(\"callback_func called \");\n Serial.print(++counter);\n Serial.println(\" times\");\n return INTERVAL;\n }\n \n void setup() {\n Serial.begin(115200);\n attachTimerInterrupt(callback_func, INTERVAL);\n }\n \n void loop() {\n \n }\n \n```\n\n以上、ご参考になれば。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-15T15:34:52.243", "id": "51995", "last_activity_date": "2019-01-15T15:43:36.120", "last_edit_date": "2019-01-15T15:43:36.120", "last_editor_user_id": "27334", "owner_user_id": "27334", "parent_id": "51916", "post_type": "answer", "score": 2 } ]
51916
null
51995
{ "accepted_answer_id": null, "answer_count": 0, "body": "LanchScreen.storyboardで質問です。\n\n現在AutoLayoutでLanchScreenのレイアウトを作成しています。 \niPhone5〜8とiPadのレイアウトに関しては、Size Classを使用して作成しました。 \n<https://dev.classmethod.jp/references/ios8-trait-collection/>\n\nここまでは問題ないのですが、問題はiPhone5〜8とiPhoneX系で別のレイアウトにしたい場合にどうしたらよいか分かりません。 \n※iPhone5〜8とiPhoneX系ではSize Classの指定方法が同じ為\n\nこの場合はどうしたら良いのでしょうか?\n\n単純にナビゲーションバーを描画したLanchScreenを作りたいだけなのですが。\n\nよろしくお願いします。", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T11:58:20.187", "favorite_count": 0, "id": "51919", "last_activity_date": "2019-01-12T11:58:20.187", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "16818", "post_type": "question", "score": 0, "tags": [ "swift", "xcode", "storyboard", "autolayout" ], "title": "Xcode LanchScreenでiPhoneX系とそれ以外でレイアウトを作りたい", "view_count": 106 }
[]
51919
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "動作環境 : Windows10 64bit, Eclipse4.8 Photon, Java1.8.0_191, MySQL8.0.13,\ncr4e_2.0.24\n\n実装したいこと : DB内データの印刷機能\n\n実現できたこと : 印刷機能実装(データ読み込み、プリンタ印刷)\n\n問題点(実現できていないこと) : 「CrystalReport1-viewer.jsp」を「サーバーで実行」するとエラー発生。\n\nエラー内容 :\n\n```\n\n HTTPステータス 500 - Internal Server Error\n \n \n Type Exception Report\n \n メッセージ javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/sap/security/core/server/csi/XSSEncoder\n \n 説明 The server encountered an unexpected condition that prevented it from fulfilling the request.\n \n 例外\n org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/sap/security/core/server/csi/XSSEncoder\n org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:606)\n org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:467)\n org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)\n org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)\n javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\n \n \n 原因\n javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/sap/security/core/server/csi/XSSEncoder\n org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:667)\n org.apache.jsp.CrystalReport1_002dviewer_jsp._jspService(CrystalReport1_002dviewer_jsp.java:141)\n org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)\n javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)\n org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)\n org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)\n javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\n \n \n 原因\n java.lang.NoClassDefFoundError: com/sap/security/core/server/csi/XSSEncoder\n com.businessobjects.report.web.f.for(SourceFile:112)\n com.businessobjects.report.web.e.byte(SourceFile:442)\n com.businessobjects.report.web.e.a(SourceFile:223)\n com.businessobjects.report.web.e.a(SourceFile:135)\n com.crystaldecisions.report.web.ServerControl.a(SourceFile:607)\n com.crystaldecisions.report.web.ServerControl.processHttpRequest(SourceFile:342)\n com.crystaldecisions.report.web.viewer.taglib.ServerControlTag.doEndTag(SourceFile:45)\n com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.doEndTag(SourceFile:74)\n com.crystaldecisions.report.web.viewer.taglib.ViewerTag.doEndTag(SourceFile:34)\n org.apache.jsp.CrystalReport1_002dviewer_jsp._jspx_meth_crviewer_005fviewer_005f0(CrystalReport1_002dviewer_jsp.java:188)\n org.apache.jsp.CrystalReport1_002dviewer_jsp._jspService(CrystalReport1_002dviewer_jsp.java:128)\n org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)\n javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)\n org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)\n org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)\n javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\n \n \n 原因\n java.lang.ClassNotFoundException: com.sap.security.core.server.csi.XSSEncoder\n org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1309)\n org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1138)\n com.businessobjects.report.web.f.for(SourceFile:112)\n com.businessobjects.report.web.e.byte(SourceFile:442)\n com.businessobjects.report.web.e.a(SourceFile:223)\n com.businessobjects.report.web.e.a(SourceFile:135)\n com.crystaldecisions.report.web.ServerControl.a(SourceFile:607)\n com.crystaldecisions.report.web.ServerControl.processHttpRequest(SourceFile:342)\n com.crystaldecisions.report.web.viewer.taglib.ServerControlTag.doEndTag(SourceFile:45)\n com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.doEndTag(SourceFile:74)\n com.crystaldecisions.report.web.viewer.taglib.ViewerTag.doEndTag(SourceFile:34)\n org.apache.jsp.CrystalReport1_002dviewer_jsp._jspx_meth_crviewer_005fviewer_005f0(CrystalReport1_002dviewer_jsp.java:188)\n org.apache.jsp.CrystalReport1_002dviewer_jsp._jspService(CrystalReport1_002dviewer_jsp.java:128)\n org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)\n javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)\n org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)\n org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)\n javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\n \n```\n\n注意 原因のすべてのスタックトレースは、のログに記録されています\n\nApache Tomcat/9.0.10\n\n以上\n\n質問本文 :\n上記の環境でJavaでCrystalReportsを利用したところ、一部エラーに悩まされています。印刷用のJSPは問題なく実行できるのに、ビューワー用JSPだけエラーが出る原因はどのようなことが考えられますでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T13:04:01.120", "favorite_count": 0, "id": "51920", "last_activity_date": "2019-01-13T04:08:11.777", "last_edit_date": "2019-01-13T00:46:51.557", "last_editor_user_id": "3068", "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "java" ], "title": "CrystalReports for Eclipseにおける不具合について", "view_count": 203 }
[ { "body": "直接の原因はservlet コンテナ(上で動作するservlet)から、「\ncom/sap/security/core/server/csi/XSSEncoder」を解決できないことです。該当のクラスを含むjarファイルを参照可能なクラスローダに載せる必要があります。 \n確認すべき項目は、 \n・/WEB-INF/libに該当のJarファイルが存在するか \n・環境変数CLASSPATHに該当のJarが存在するか \n→この場合、ローダの委譲関係によっては参照到達不可能なので、気を付けてください。\n\nあと、このあとのはまりポイントとしては、「移譲関係間違えていて参照到達不可能」とかですかね。 \n経験したケースでは、Warクラスローダ(移譲元)からEarクスローダー(委譲先)上のクラスを参照しようとしてはまったことがあります。そのほかいろいろなケースがあるので、こればかりはきちんと設計をするか、try&Errorで進むしかないかと。\n\n以上です", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T00:03:57.943", "id": "51928", "last_activity_date": "2019-01-13T00:03:57.943", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10174", "parent_id": "51920", "post_type": "answer", "score": 0 } ]
51920
null
51928
{ "accepted_answer_id": "51930", "answer_count": 1, "body": "```\n\n new class Kama\n {\n static String name = \"ああああ様\";\n static int yen; \n static int seki; \n \n public static void main( String[] args ) throws java.io.IOExcepion\n {\n int yes = System.in.read();\n \n if( yes = 1){\n System.out.println(\"ありがとう!!\" + name);\n }else{\n System.out.ptintln(\"キャンセルされました。\" +name);\n }\n System.out.println(\"yes is\" + yes );\n }\n }\n \n```", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T13:26:19.167", "favorite_count": 0, "id": "51921", "last_activity_date": "2019-01-13T01:19:15.100", "last_edit_date": "2019-01-12T13:27:43.853", "last_editor_user_id": "3060", "owner_user_id": "31770", "post_type": "question", "score": -1, "tags": [ "java" ], "title": "class、interfaceまたはenumがありません、と出てしまいます。どこが悪いでしょうか?教えてください。", "view_count": 2998 }
[ { "body": "ご質問へのコメントを参考に、下記を見直してみてください。\n\n * `class`の型を宣言する時は`new`を使わない \n * `new`は`Kama kama = new Kama();`のように[インスタンス](https://www.google.com/search?q=java+%E3%82%A4%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%B3%E3%82%B9)作成時に使用します\n * スペル修正 \n * `IOExcepion` → `IOException`\n * `ptintln` → `println`\n * `if`の中で代入演算子(`=`)ではなく比較演算子(`==`)を使う\n * `System.in.read()`は入力された **文字コード** を返すので`char型`と比較する\n\n修正後のコード例:\n\n```\n\n public class Kama {\n \n static String name = \"ああああ様\";\n static int yen;\n static int seki;\n \n public static void main(String[] args) throws java.io.IOException {\n int yes = System.in.read();\n \n if (yes == '1') {\n //if (yes == 49) { // '1'は文字コードの49(0x31)と同値\n System.out.println(\"ありがとう!!\" + name);\n } else {\n System.out.println(\"キャンセルされました。\" + name);\n }\n System.out.println(\"yes is\" + yes);\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T01:19:15.100", "id": "51930", "last_activity_date": "2019-01-13T01:19:15.100", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "51921", "post_type": "answer", "score": 1 } ]
51921
51930
51930
{ "accepted_answer_id": null, "answer_count": 1, "body": "ラズパイをCIFS互換アプリのsambaで、ファイル共有サーバーとして使おうとしていました。 \nそこまでは正常に動作をしていました。 \nそれから、起動時に自動でマウントをする方法を設定する箇所にて↓\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/YxvN5.png)](https://i.stack.imgur.com/YxvN5.png) \nfstabファイルのetx4の部分(一番下にあるUUDIの箇所のマウント先の後ろにあるLinuxのファイルシステム名の指定) \next4に書き違えました。 \nその後、ラズパイを起動できず、その後問題箇所を書き換え(ext4→etx4),reboot したのですがやはり起動しないようです。\n\nどなたかご教授よろしくお願いします\n\nちなみにラズパイ上のエラーはこちらです↓↓↓ \n[![画像の説明をここに入力](https://i.stack.imgur.com/JXJHP.png)](https://i.stack.imgur.com/JXJHP.png) \n. . . \n[![画像の説明をここに入力](https://i.stack.imgur.com/kWJxZ.png)](https://i.stack.imgur.com/kWJxZ.png)\n\nまた、自分のパソコンのバーチャル環境(centOS7)からマウントを試みたのですが、下記のようになるため手詰まりしてます。\n\nmount point does not exist\n\nまた、mtabが壊れているのでマウントできないのかと思うので、mtabを直す方法もよろしくお願いします。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/XYXnQ.png)](https://i.stack.imgur.com/XYXnQ.png) \nどなたかおたすけください。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T13:42:17.397", "favorite_count": 0, "id": "51922", "last_activity_date": "2022-10-29T03:08:30.820", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31543", "post_type": "question", "score": -1, "tags": [ "raspberry-pi" ], "title": "Raspberry pi のfstabの修正方法", "view_count": 892 }
[ { "body": "起動時に ファイルシステムがマウントが失敗するとデフォルトではエマージェンシーモードに移行してしまいます。 `/etc/fstab` の\n`defaults` の部分を `nofail` を設定するとどうでしょうか?\n\n```\n\n UUID=xxxxxxxxx /var/samba ext4 defaults,nofail 0 0\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-25T02:59:21.490", "id": "52303", "last_activity_date": "2019-01-25T02:59:21.490", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "51922", "post_type": "answer", "score": 0 } ]
51922
null
52303
{ "accepted_answer_id": null, "answer_count": 2, "body": "以下の様なコードで関数の戻り値を受け取ることが出来ません。イベントが発生したら関数を実行して戻り値を受け取りたいのですが、戻り値を受け取る方法が思い着きません。素人なので、発想自体が間違ってかもしれないです。ご教授お願いします。\n\n```\n\n <script>\n function test(e){\n var hoge = 1;\n return 1;\n }\n document.addEventListener(‘change’,test,false);\n </script>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T14:39:51.677", "favorite_count": 0, "id": "51923", "last_activity_date": "2022-05-15T05:00:05.063", "last_edit_date": "2019-01-12T16:55:41.650", "last_editor_user_id": "3060", "owner_user_id": "31772", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "addeventlistnerで指定した関数から戻り値を受けた取りたい。", "view_count": 1447 }
[ { "body": "残念ながら、おっしゃる通り、発想自体が間違っています。addEventListenerで指定した関数から戻り値を受け取ることはできません。 \naddEventListenerに指定した関数で戻り値を返す代わりに、その場で(今の例だと`test`内で)値を使用して処理を行ってしまう必要があります。\n\nどうすればいいか分からない場合、もっと具体的な状況を質問していただければ解決策が回答されるかもしれません。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T16:18:52.510", "id": "51924", "last_activity_date": "2019-01-12T16:18:52.510", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30079", "parent_id": "51923", "post_type": "answer", "score": 1 }, { "body": "listener関数は非同期関数なので、`return` 文を使っても返り値を受け取れません。 \nJavaScriptでは非同期処理の完了はコールバック関数で受け取る必要があります。\n\n```\n\n 'use strict';\r\n function handleChange (event) {\r\n foo(event.target.value);\r\n }\r\n \r\n function foo (v) {\r\n console.log(v);\r\n }\r\n \r\n document.addEventListener('change', handleChange, false);\n```\n\n```\n\n <select><option value=\"1\">1</option><option value=\"2\">2</option><option value=\"3\">3</option><option value=\"4\">4</option></select>\n```\n\nRe: Sogeking さん", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-14T15:22:54.543", "id": "51972", "last_activity_date": "2019-01-14T15:22:54.543", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20262", "parent_id": "51923", "post_type": "answer", "score": 1 } ]
51923
null
51924
{ "accepted_answer_id": null, "answer_count": 1, "body": "最近,大学でPythonの勉強を始めて本当に間もない者です. \n大学の講義で以下のようなプログラムがあり, \n実行しようとしてみたところエラーが出てしまいました. \n資料がかすれて見づらいこともあるのですが, \n自分では何が間違っているのか分からず困っています. \nまた,最終的にはグラフを表示させるプログラムであることはわかるのですが \n各行のコードの意味もよくわかっていません. \nできれば,そちらについても教えていただけると幸いです.\n\n・コード\n\n```\n\n # -*- coding: utf-8 -*-\n \n import numpy as np\n import matpoltlib.pyplot as plt\n def f(x):\n return 2*np.sin(x)-(x**2)/8.0\n \n print(\"x=0:\",f(0.0),\"x=4\",f(4.0))\n x_array=np.zeros(3)\n y_array=np.zeros(3)\n x_array(0)=0\n x_array(1)=1\n x_array(2)=2\n \n x=np.linspace(0,10,20)\n fig = plt.figure()\n plt.plot(x,f(x))\n plt.title(r'f(x)=2sin(x)-x*x/8')\n plt.xlabel(r'x')\n plt.ylabel(r'f(x)')\n plt.scatter(x_array,y_array)\n \n #plt.savefig('lec9.png')\n plt.show()\n \n```\n\n・エラー\n\n```\n\n 参考コード1.py\", line 11\n x_array(0)=0\n ^\n SyntaxError: can't assign to function call\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T19:13:44.257", "favorite_count": 0, "id": "51925", "last_activity_date": "2019-01-12T20:50:55.203", "last_edit_date": "2019-01-12T19:57:46.657", "last_editor_user_id": "3605", "owner_user_id": "31775", "post_type": "question", "score": 0, "tags": [ "python3" ], "title": "PythonでSyntaxError: can't assign to function callが出てしまい困っています。", "view_count": 13041 }
[ { "body": "お疲れ様です。 \n以下、3つコメントします。\n\n(1) \nx_array[0]( (0) が、まずい。)が正解かと思います。\n\n(2) \npythonのエラーメッセージは、適切だったと記憶しています。 \nfunctionじゃないと指摘しています。\n\n(3) \nmatplotのスペルが間違っています。 \n手元ではそこをそれも修正したら、実行できました。\n\n以上", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-12T20:50:55.203", "id": "51926", "last_activity_date": "2019-01-12T20:50:55.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31548", "parent_id": "51925", "post_type": "answer", "score": 1 } ]
51925
null
51926
{ "accepted_answer_id": "51937", "answer_count": 1, "body": "Linux において、スワップを行う設定にした場合、カーネルはどのようなアルゴリズムで、スワップアウトするべきページを決定していますか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T03:16:48.397", "favorite_count": 0, "id": "51933", "last_activity_date": "2019-01-13T06:04:44.707", "last_edit_date": "2019-01-13T06:02:12.170", "last_editor_user_id": "3060", "owner_user_id": "754", "post_type": "question", "score": 1, "tags": [ "linux", "スワップ" ], "title": "Linux において、 swapout するページはどのように決定される?", "view_count": 247 }
[ { "body": "外部サイトかつ古い版数の話なのでリンクとほんの少しの引用だけ。 \nいくつかあるので詳細は飛び先で確認してください。\n\n* * *\n\n[OSDN > ソフトウェアを探す > Linux Kernel Documents > Wiki > 0.6\nメモリ管理](https://ja.osdn.net/projects/linux-kernel-\ndocs/wiki/0.6%E3%80%80%E3%83%A1%E3%83%A2%E3%83%AA%E7%AE%A1%E7%90%86)\n\n> 0.6.2.2 ページアウトとスワップ\n\n[OSDN > ソフトウェアを探す > Linux Kernel Documents > Wiki >\ninternal22-198-メモリ確保アルゴリズム詳細](https://ja.osdn.net/projects/linux-kernel-\ndocs/wiki/internal22-198-%E3%83%A1%E3%83%A2%E3%83%AA%E7%A2%BA%E4%BF%9D%E3%82%A2%E3%83%AB%E3%82%B4%E3%83%AA%E3%82%BA%E3%83%A0%E8%A9%B3%E7%B4%B0)\n\n> swap_out関数は、もっともスワップすべきページを持っているプロセスを探し出し、そのプロセスにスワップアウトの要求を出す。 \n> `swap_out関数処理内容を疑似コードで解説` \n>\n> プロセスに出されたスワップアウト要求は以下のように分解され、最終的にはプロセス内のページに対するスワップ要求(try_to_swap_out関数)になる。 \n> swap_out_process関数 → swap_out_vma関数 → swap_out_pgd関数 → swap_out_pmd関数 →\n> try_to_swap_out関数 \n> `try_to_swap_out関数処理内容を疑似コードで解説`\n\n* * *\n\n上記よりもう少し新しく?て詳しいのがこちら。 \n[The Linux Kernel:メモリ管理](http://archive.linux.or.jp/JF/JFdocs/The-Linux-\nKernel-4.html)\n\n* * *\n\nもう少し新しめの記事。 \n[Linuxメモリ管理の最先端を探る](http://www.atmarkit.co.jp/flinux/rensai/watch2008/watchmemb.html)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T05:51:36.207", "id": "51937", "last_activity_date": "2019-01-13T06:04:44.707", "last_edit_date": "2019-01-13T06:04:44.707", "last_editor_user_id": "26370", "owner_user_id": "26370", "parent_id": "51933", "post_type": "answer", "score": 0 } ]
51933
51937
51937
{ "accepted_answer_id": "51943", "answer_count": 1, "body": "お世話になります。\n\nプログラミングとはあまり関係ないかもしれないのですが、アイデアをいただければと思い、質問させていただきました。 \nタイトルの通りなんですが、PHPで、よくバージョン情報の表記等で見かける\n\n1.2.3.4\n\nや\n\n1.2.3.5\n\nのように、ピリオドで区切られた数値の差を求めるにはどうすればよいでしょうか。\n\n例えば、\n\n```\n\n <?php\n echo 1.2.3.5-1.2.3.4;\n ?>\n \n```\n\nのようにしましたが、予想通りエラーになってしまいます。 \n何かよい方法があれば、教えていただけると幸いです。\n\n以上、よろしくお願いいたします。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T07:44:41.743", "favorite_count": 0, "id": "51939", "last_activity_date": "2019-01-13T08:12:05.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29034", "post_type": "question", "score": 0, "tags": [ "php" ], "title": "ピリオドで区切られた数値の差の計算方法", "view_count": 133 }
[ { "body": "数値で差分を取って意味があるのでしょうか?\n\n版数の上下同比較であれば、[version_compare](http://php.net/manual/ja/function.version-\ncompare.php) という関数があります。\n\n[PHP\nでバージョン番号の比較方法と確認方法(各種)](https://qiita.com/KEINOS/items/cf25f6ffe215ff44c901)\n\nどうしても数値として扱いたいなら、[explode](http://php.net/manual/ja/function.explode.php)\n関数でピリオドをデリミタにして配列を取得し、数値に変換して、インデックス毎の個々の差分を計算するという方法が考えられます。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T08:12:05.603", "id": "51943", "last_activity_date": "2019-01-13T08:12:05.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "51939", "post_type": "answer", "score": 4 } ]
51939
51943
51943
{ "accepted_answer_id": "51952", "answer_count": 3, "body": "はじめまして. \n私は今pythonでプログラミングの勉強をしております.\n\nタイトルのように, \nある処理が一定時間で終了しなければ,次の処理に移るようなコードを作成したいと思っております.\n\n```\n\n for value in values:\n # valueについて処理1\n # valueについて処理2\n # valueについて処理3\n \n```\n\nこの,valueについての処理が一定時間に終わらなければ再処理するにはどうしたらよいでしょうか?\n\nできれば高精度で処理を中断したいので,valueについての処理中にも監視したいです.\n\nそこで,スレッドを生成して監視すればよいかとも思ったのですが,処理が終了しているかどうかの監視や,再処理の仕方がわかりませんでした.\n\nなにか解決方法ありましたら,教えてください. \nよろしくお願いいたします.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T07:55:42.663", "favorite_count": 0, "id": "51940", "last_activity_date": "2019-01-14T13:10:12.867", "last_edit_date": "2019-01-14T13:10:12.867", "last_editor_user_id": "19110", "owner_user_id": "31767", "post_type": "question", "score": 3, "tags": [ "python" ], "title": "python 一定時間で処理が終了しなければ,次の処理に移るようなコード", "view_count": 14476 }
[ { "body": "まずは、こんな記事を見てください。 \n[ごく簡単な Python multiprocessing の使い方](https://librabuch.jp/blog/2015/01/python-\nmultiprocessing/)\n\nこの中で使っている `join` という関数でパラメータを指定すれば、タイムアウトを検出できます。 \n[join([timeout])](https://docs.python.org/ja/3.6/library/multiprocessing.html#multiprocessing.Process.join)\n\n> オプションの引数 timeout が None (デフォルト) の場合、 join() メソッドが呼ばれたプロセスは処理が終了するまでブロックします。\n> timeout が正の数である場合、最大 timeout 秒ブロックします。 プロセスが終了あるいはタイムアウトした場合、メソッドは None\n> を返すことに注意してください。 プロセスの `exitcode` を確認し終了したかどうかを判断してください。\n>\n> 1つのプロセスは何回も join されることができます。\n>\n> プロセスは自分自身を join することはできません。それはデッドロックを引き起こすことがあるからです。プロセスが start される前に join\n> しようとするとエラーが発生します。\n\n時間が掛かっている、未終了の処理はどうするか、 \nとか色々考えることは沢山ありますので、頑張ってください。\n\n直接は関係ありませんが、こんな記事も参考にしてください。 \n[マルチプロセスな処理を実装して、処理を高速化する](https://www.yoheim.net/blog.php?q=20170601)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T09:17:38.750", "id": "51947", "last_activity_date": "2019-01-13T09:17:38.750", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "26370", "parent_id": "51940", "post_type": "answer", "score": 0 }, { "body": "やり方はいろいろあると思うのです。マルチプロセスでもマルチスレッドでも \n水車の再発明は避けたいので、ありもののライブラリを利用するのはいかがでしょうか。 \n「タイムアウトさせたい処理」メソッドないしは関数で定義すれば、実現できそうですが。。。\n\n<https://qiita.com/toshitanian/items/133b42355b7867f5c458>[](https://qiita.com/toshitanian/items/133b42355b7867f5c458)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T13:26:47.290", "id": "51952", "last_activity_date": "2019-01-13T13:26:47.290", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10174", "parent_id": "51940", "post_type": "answer", "score": 0 }, { "body": "今回,コメントにあったtimeout-decoratorを参考にさせて頂きました. \n再処理にはretryというパッケージで実現いたしました. \n何かの参考になりますと幸いです.\n\n```\n\n import time\n import random\n from retry import retry\n from timeout_decorator import timeout, TimeoutError\n \n class Test():\n \n @retry(TimeoutError, tries=3, delay=1, backoff=2)\n @timeout(5)\n def worker(value):#valueの処理\n print (value),\n #1~10秒待つ.\n sleep_time = random.randrange(1, 10)\n print (\":sleep_time\", sleep_time)\n time.sleep(sleep_time)\n print(value, \":Done.\")\n \n if __name__ == \"__main__\":\n values = [1, 2, 3]\n \n for value in values:\n Time = time.time()\n try:\n worker(value)\n except TimeoutError as e:\n print (e)\n finally:\n print(\"掛った時間\", time.time() - Time)\n \n print (\"Finish\")\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-14T13:07:52.860", "id": "51968", "last_activity_date": "2019-01-14T13:07:52.860", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31767", "parent_id": "51940", "post_type": "answer", "score": 1 } ]
51940
51952
51968
{ "accepted_answer_id": "52175", "answer_count": 1, "body": "# 環境\n\n * python 3.6.6\n * pytest 4.0.0\n\n# 背景\n\nPythonの自作ライブラリをpytestでテストしたいです。 \n自作ライブラリはpip installできるようになっています。 \n`pip install git+https://github.com/sample/sampleapi`\n\n### フォルダ構成\n\n```\n\n project/\n │ pytest.ini\n │ setup.py\n │ \n ├─sampleapi/\n │ │ api.py\n │ │ \n │ \n │ \n └─tests/\n │ test.py\n │ \n \n```\n\n### setup.py\n\n```\n\n from setuptools import setup, find_packages\n \n setup(name='sampleapi',\n ...)\n \n```\n\n# 問題\n\n私の環境では自作ライブラリがインストールされています。 \nこの状態で`pytest tests`を実行すると、`pip install`した方のsampleapiが参照されます。 \nしたがって、テストの実行結果を元にsampleapiを修正した場合、再度pip installする必要があります。\n\n自作ライブラリがインストールされている状態で、ローカルのファイルを参照してpytestを実行するには、どうしたらよいでしょうか? \n自作ライブラリがインストールされていなければ、ローカルのファイルが参照されました。\n\n###", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T07:57:36.047", "favorite_count": 0, "id": "51941", "last_activity_date": "2019-01-21T12:34:06.053", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "19524", "post_type": "question", "score": 1, "tags": [ "python", "テスト" ], "title": "自作ライブラリがインストールされている状態(pip install)で、ローカルのファイルを参照してpytestを実行する方法", "view_count": 260 }
[ { "body": "2つの方法があります。\n\n 1. `PYTHONPATH` を設定する\n 2. `tox` を使ってテスト環境を分離する\n\n1は、以下のようにコマンドラインで実行します。\n\n```\n\n $ PYTHONPATH=. pytest tests\n \n```\n\nこのように毎回書きたくない場合のために、 <https://pypi.org/project/pytest-pythonpath/>\nというプラグインが提供されているので、これを使うのもよいでしょう。\n\n2は、 <https://pypi.org/project/tox/>\nを使うことでテスト環境をvirtualenv内に分離する方法です。virtualenvやvenvを手動でテスト用に作成するのでもよいですが、toxを使うのが一般的です。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-21T12:34:06.053", "id": "52175", "last_activity_date": "2019-01-21T12:34:06.053", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "51941", "post_type": "answer", "score": 1 } ]
51941
52175
52175
{ "accepted_answer_id": null, "answer_count": 1, "body": "swi-prolog上で'emacs.'と打つと'ERROR: Undefined procedure: emacs/0 (DWIM could not\ncorrect goal)'と表示されます。 \ncustomizeディレクトリにあるdotswiplrcに':- set_prolog_flag(editor,\npce_emacs).'を追加しましたが、PceEmacsは起動しません。どうすればPceEmacsを使うことができますか? \nMasOS High Sierra 10.13.6 上で swi-prolog 7.6.4 を使用しています。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T09:06:28.533", "favorite_count": 0, "id": "51946", "last_activity_date": "2019-01-15T05:53:53.160", "last_edit_date": "2019-01-15T01:19:41.077", "last_editor_user_id": "-1", "owner_user_id": "31254", "post_type": "question", "score": 0, "tags": [ "prolog" ], "title": "swi-prolog で PceEmacs を使いたい", "view_count": 122 }
[ { "body": "<https://swish.swi-prolog.org/pldoc/man?section=initfile>\n\n> After the system initialisation, the system consults (see\n> [consult/1](https://swish.swi-prolog.org/pldoc/man?predicate=consult/1)) the\n> user's startup file. The basename of this file follows conventions of the\n> operating system. On MS-Windows, it is the file `swipl.ini` and on Unix\n> systems `.swiplrc`.\n>\n> The installation provides a file `customize/dotswiplrc` with (commented)\n> commands that are often used to customize the behaviour of Prolog\n\n設定ファイルの書き方を間違えているのではないかと思います。SWI-Prolog の `customize/dotswiplrc`\nは典型的な設定が書かれているお手本のファイルというだけであり、そのファイルが初期化に使われているわけではありません。\n\n環境に応じて `.swiplrc` または `swipl.ini`\nを作成し、適切なパスに置いてください。置くパスの詳細も上のドキュメントに書かれています。macOS であれば大抵 `~/.swiplrc`\nを作成すれば良いでしょう。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T09:26:33.623", "id": "51948", "last_activity_date": "2019-01-15T05:53:53.160", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "19110", "parent_id": "51946", "post_type": "answer", "score": 1 } ]
51946
null
51948
{ "accepted_answer_id": "51987", "answer_count": 2, "body": "BeautifulSoup4とRequestsでスクレイピングを行いたいのですが、 \nsrcで検索をしてURLを取得してしまうと、想定よりも小さいサイズの画像ファイルがダウンロードされます。 \nこれはHTMLのimgタグにあるsrcsetの影響です。 \nおそらく、自身がウィンドウサイズを指定できていないのが原因と考えています。 \n以上の点を踏まえて、ヘッダーにウィンドウサイズの情報を追記する必要があると考えたのですが、その方法があればご教授ください。\n\n説明が乏しく例示した方がわかりやすいと感じたら、コメントをいただければ追記いたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T11:53:07.933", "favorite_count": 0, "id": "51949", "last_activity_date": "2020-04-06T06:28:07.257", "last_edit_date": "2020-04-06T06:28:07.257", "last_editor_user_id": "3060", "owner_user_id": "16877", "post_type": "question", "score": 0, "tags": [ "python3", "html5", "web-scraping", "beautifulsoup" ], "title": "Pythonのbs4とrequestsを用いたスクレイピングでsrcsetに対応したい", "view_count": 556 }
[ { "body": "おそらく、この記事が参考になると思います。 \n[Python using beautiful soup to extract attribute from\nhtml](https://stackoverflow.com/q/46582587/9014308)\n\nこちらはseleniumを使っているので少し違うかもしれませんが。 \n[I can't get all of image attributes using Beautiful Soup and\nSelenium](https://stackoverflow.com/q/46854971/9014308) \n[Scraping Instagram with\nBeautifulSoup](https://stackoverflow.com/q/49085421/9014308)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T12:21:57.880", "id": "51951", "last_activity_date": "2019-01-13T12:21:57.880", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26370", "parent_id": "51949", "post_type": "answer", "score": 0 }, { "body": "srcsetを検索する手法を試しました。 \n`foo = soup.findAll('img', attrs = {'srcset' : True})` \n以上で、`foo`にはそれらのリストが格納されます。 \n※`soup`はBeautifulSoupを用いてlxml形式へと変換させてものです。\n\nここからウェブサイトの記述規則などを判断し、`split`を用いて画像のURLを特定することができます。 \nこの際、先頭にある空白``などに留意することでコードチェックをスムーズにできます。\n\nURLさえ割り出せれば問題なくスクレイピングが可能でした。 \nなお、画像のサイズの順序はウェブサイト側に合わせるしかなく、柔軟に対応するためには、wxの値を評価することで最も大きいものを選ぶよう実装しました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-15T08:41:00.130", "id": "51987", "last_activity_date": "2019-01-15T08:41:00.130", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "16877", "parent_id": "51949", "post_type": "answer", "score": 1 } ]
51949
51987
51987
{ "accepted_answer_id": null, "answer_count": 3, "body": "以下のような2つのファイルtest1.txt(スペース区切り), test2.txtがあり、 \ntest2.txtの文字列が含まれるtest1.txtの行を抽出したファイル(test3.txt)を生成するためのシェルスクリプトのコードをご教示いただくことはできないでしょうか。\n\n■test1.txt \nAAA a b \nBBB b c \nCCC c d \nDDD d e \nEEE e f\n\n■test2.txt \nAAA \nCCC \nEEE\n\n■test3.txt \nAAA a b \nCCC c d \nEEE e f", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T15:28:52.057", "favorite_count": 0, "id": "51953", "last_activity_date": "2019-01-13T16:35:10.387", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31783", "post_type": "question", "score": 1, "tags": [ "grep" ], "title": "シェルスクリプト上でファイルに含まれる行を抽出", "view_count": 1024 }
[ { "body": "環境がLinux(GNU coreutils)であれば、joinコマンドが使えます。SQLの内部結合に相当します。\n\n```\n\n $ join test1.txt test2.txt\n AAA a b\n CCC c d\n EEE e f\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T16:09:28.503", "id": "51954", "last_activity_date": "2019-01-13T16:09:28.503", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4010", "parent_id": "51953", "post_type": "answer", "score": 1 }, { "body": "標準入力へリダイレクトを用いて,\n\n```\n\n #!/bin/bash\n \n while read line\n do\n grep $line ./test1.txt >> ./test3.txt\n done < ./test2.txt\n \n```\n\nというのはどうでしょうか.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T16:11:30.883", "id": "51955", "last_activity_date": "2019-01-13T16:11:30.883", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31767", "parent_id": "51953", "post_type": "answer", "score": 0 }, { "body": "grep の `-f` (`--file=FILE`) オプションを利用するのが良さそうです。\n\n> -f FILE, --file=FILE パターンを FILE から 1 行 1 パターンとして読み込みます。 このオプションを複数回使ったときや、\n> -e (--regexp) オプションと組み合わせたときは、与えられたすべてのパターンを検索します。 \n> 空のファイルはパターンを含まないので、何にもマッチしません。\n\n<https://linuxjm.osdn.jp/html/GNU_grep/man1/grep.1.html>\n\n実行例:\n\n```\n\n $ grep -f test2.txt test1.txt > test3.txt\n $ cat test3.txt\n AAA a b\n CCC c d\n EEE e f\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-13T16:35:10.387", "id": "51956", "last_activity_date": "2019-01-13T16:35:10.387", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2391", "parent_id": "51953", "post_type": "answer", "score": 2 } ]
51953
null
51956
{ "accepted_answer_id": "51959", "answer_count": 1, "body": "pyqt5でwmvの動画ファイルを再生する際、再生速度を変化させたいです。次は試しに書いたコードです。\n\n```\n\n from PyQt5.QtCore import QDir, Qt, QUrl\n from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer\n from PyQt5.QtMultimediaWidgets import QVideoWidget\n from PyQt5.QtWidgets import (QApplication, QFileDialog, QHBoxLayout, QLabel,\n QPushButton, QSizePolicy, QSlider, QStyle, QVBoxLayout, QWidget, QComboBox)\n \n \n class VideoPlayer(QWidget):\n \n def __init__(self, parent=None):\n super(VideoPlayer, self).__init__(parent)\n \n self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)\n \n videoWidget = QVideoWidget()\n \n openButton = QPushButton(\"Open...\")\n openButton.clicked.connect(self.openFile)\n \n self.playButton = QPushButton()\n self.playButton.setEnabled(False)\n self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))\n self.playButton.clicked.connect(self.play)\n \n self.rateBox = QComboBox(self)\n self.rateBox.addItem(\"0.5x\", 0.5)\n self.rateBox.addItem(\"1.0x\", 1.0)\n self.rateBox.addItem(\"2.0x\", 2.0)\n self.rateBox.setCurrentIndex(1)\n self.rateBox.activated[str].connect(self.changerate)\n \n self.positionSlider = QSlider(Qt.Horizontal)\n self.positionSlider.setRange(0, 0)\n self.positionSlider.sliderMoved.connect(self.setPosition)\n \n self.errorLabel = QLabel()\n self.errorLabel.setSizePolicy(QSizePolicy.Preferred,\n QSizePolicy.Maximum)\n \n controlLayout = QHBoxLayout()\n controlLayout.setContentsMargins(0, 0, 0, 0)\n controlLayout.addWidget(openButton)\n controlLayout.addWidget(self.playButton)\n controlLayout.addWidget(self.rateBox)\n controlLayout.addWidget(self.positionSlider)\n \n layout = QVBoxLayout()\n layout.addWidget(videoWidget)\n layout.addLayout(controlLayout)\n layout.addWidget(self.errorLabel)\n \n self.setLayout(layout)\n \n self.mediaPlayer.setVideoOutput(videoWidget)\n self.mediaPlayer.stateChanged.connect(self.mediaStateChanged)\n self.mediaPlayer.positionChanged.connect(self.positionChanged)\n self.mediaPlayer.durationChanged.connect(self.durationChanged)\n self.mediaPlayer.error.connect(self.handleError)\n \n def openFile(self):\n fileName, _ = QFileDialog.getOpenFileName(self, \"Open Movie\",\n QDir.homePath())\n \n if fileName != '':\n self.mediaPlayer.setMedia(\n QMediaContent(QUrl.fromLocalFile(fileName)))\n self.playButton.setEnabled(True)\n \n def play(self):\n if self.mediaPlayer.state() == QMediaPlayer.PlayingState:\n self.mediaPlayer.pause()\n else:\n self.mediaPlayer.play()\n \n def mediaStateChanged(self, state):\n if self.mediaPlayer.state() == QMediaPlayer.PlayingState:\n self.playButton.setIcon(\n self.style().standardIcon(QStyle.SP_MediaPause))\n else:\n self.playButton.setIcon(\n self.style().standardIcon(QStyle.SP_MediaPlay))\n \n def positionChanged(self, position):\n self.positionSlider.setValue(position)\n \n def durationChanged(self, duration):\n self.positionSlider.setRange(0, duration)\n \n def setPosition(self, position):\n self.mediaPlayer.setPosition(position)\n \n def handleError(self):\n self.playButton.setEnabled(False)\n self.errorLabel.setText(\"Error: \" + self.mediaPlayer.errorString())\n \n def changerate(self):\n rate=self.rateBox.itemData(self.rateBox.currentIndex())\n self.mediaPlayer.setPlaybackRate(rate)\n \n \n if __name__ == '__main__':\n \n import sys\n \n app = QApplication(sys.argv)\n \n player = VideoPlayer()\n player.resize(320, 240)\n player.show()\n \n sys.exit(app.exec_())\n \n```\n\nこれを実行すると次のようなGUIが作成されます。 \n[![画像](https://i.stack.imgur.com/uFseV.png)](https://i.stack.imgur.com/uFseV.png) \nここで、動画を開き、再生したときにコンボボックスで再生速度を変化させたいのですが。上のコードでは変化が見られませんでした。終始1倍速で再生が続いただけでした。どのように修正すればよいのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-14T01:50:22.227", "favorite_count": 0, "id": "51958", "last_activity_date": "2019-01-14T23:57:01.293", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26529", "post_type": "question", "score": 0, "tags": [ "python3", "pyqt5" ], "title": "pyqt5でwmv動画を再生させる時に、再生速度を変化させたい", "view_count": 486 }
[ { "body": "パラメータの型が PySide2.QtCore.qreal のようなので、 \n設定する前に明示的に型宣言・変換してみてはどうでしょうか?\n\n>\n> [PySide2.QtMultimedia.QMediaPlayer.setPlaybackRate(rate)](https://doc.qt.io/qtforpython/PySide2/QtMultimedia/QMediaPlayer.html#PySide2.QtMultimedia.PySide2.QtMultimedia.QMediaPlayer.setPlaybackRate) \n> Parameters: rate – PySide2.QtCore.qreal\n\n[How to use QVariant/ja](https://wiki.qt.io/How_to_use_QVariant/ja)\n\n一応、すべての再生サービスがサポートしているわけではない、という注意書きがありますが。 \n[playbackRate :\nqreal](https://code.i-harness.com/ja/docs/qt%7E5.11/qmediaplayer#playbackRate-\nprop)\n\n> このプロパティは、現在のメディアの再生レートを保持します。\n>\n> この値は、メディアの標準再生レートに適用される乗数です。 デフォルトでは、この値は1.0で、メディアが標準ペースで再生されていることを示します。\n> 値が1.0より大きい場合は再生レートが高くなります。 0より小さい値を設定することができ、標準ペースの乗数でメディアが巻き戻されることを示します。\n>\n> **すべての再生サービスが再生レートの変更をサポートしているわけではありません。**\n> 早送りまたは巻き戻しの間、オーディオおよびビデオの状態および品質に関して定義されたフレームワークである。\n\n注)強調は引用者による。\n\nちなみに `rate` 変数が `self.rate` で無いのは一時的な変数だからですかね?\n\n* * *\n\nC++で作った場合は、少し古い版数のQtでも動作しているようです。\n\n[Qt(キュート)プログラム実行まで[サンプル(後編)]](http://dorafop.my.coocan.jp/Qt/Qt006.html)\n\n> コンボで再生速度を選択した時の処理 \n> 再生速度を選択されたレートに変更しますが、環境に依存するので機能しないことがあります。\n```\n\n void MainWindow::activeRateCombo(int comboIx) {\n QComboBox *combo = static_cast<QComboBox *>(sender());\n qreal rate = combo->itemData(comboIx).toDouble();\n if (rate != player->playbackRate()) {\n player->setPlaybackRate(rate);\n }\n }\n \n```\n\n> ※0.5x:0.5倍速、1.0x:通常速度、2.0x:2倍速\n\n* * *\n\n**追記** \nちょっと調べたら、3カ月前に同様の質問があったけれど、回答が付いていません。 \n[python pyqt5 setPlaybackRate shows a black screen when changing video playing\nrate](https://stackoverflow.com/q/52736113/9014308)\n\nこちらは巻き戻し再生が出来ないという質問ですが、解決していないようです。 \n[QMediaPlayer negative playbackRate doesn't rewind\nvideo](https://stackoverflow.com/q/52155722/9014308)\n\nただし、下側の回答の方にキー押下(A,Z,Y)で `setPlaybackRate`\nを呼び出すコーディング例が付いているので、これをそのまま動かして試してみるのはどうでしょう?\n\n* * *\n\n**さらに追記** \n試しに動かしてみたら、Audio系が速度変更をサポートしていないと出ました。\n\n> DirectShowPlayerService::doSetRate: Audio device or filter does not support\n> rate: 0.50. Falling back to previous value.\n\nご質問のものも、紹介した本家S.O.サイトのものも、かつそれらのどの倍率でもエラーになりました。細かく確認すれば、どこかの倍率はサポートしているのかもしれませんが、望み薄ですね。\n\n* * *\n\n**見直し** \n上記を受けてソースを見ると、どちらのプログラムも `AudioRole` を設定していないですね。 \n何か適切な(あるいは単にデフォルト的な) `AudioRole` を設定することで動作する可能性が考えられます。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-14T02:51:43.723", "id": "51959", "last_activity_date": "2019-01-14T23:57:01.293", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "26370", "parent_id": "51958", "post_type": "answer", "score": 0 } ]
51958
51959
51959
{ "accepted_answer_id": null, "answer_count": 1, "body": "Pythonで作成したアプリをGAEにデプロイしたいのですが、エラーが吐き出されてうまく行きません。 \npython3 + Flaskで作成したアプリをGAEのPython37 スタンダード環境にデプロイしようとしている。\n\n**エラー内容**\n\n```\n\n Beginning deployment of service [default]...\n Created .gcloudignore file. See `gcloud topic gcloudignore` for details.\n ╔════════════════════════════════════════════════════════════╗\n ╠═ Uploading 7 files to Google Cloud Storage ═╣\n ╚════════════════════════════════════════════════════════════╝\n File upload done.\n Updating service [default]...failed. \n ERROR: (gcloud.app.deploy) Error Response: [7] Access Not Configured. Cloud Build has not been used in project xxxxx-xxxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudbuild.googleapis.com/overview?project=xxxxx-xxxx then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.\n \n```\n\n**cloudbuldは必要ですか?** \ncloudbuildというのを使用しないといけないみたいなのですが、他の記事などではそんなの出て来ません。これは本当に必要なのでしょうか?<https://qiita.com/kai_kou/items/775bcc058aaabbdff4e7>\n\n**appengine_config.pyとは** \nドキュメントに`appengine_config.py` をルート プロジェクト ディレクトリに置かないといけないと書いてあるのですがこれはpython37\nスタンダード環境でも必要なのでしょうか? \n<https://cloud.google.com/appengine/docs/standard/python/getting-\nstarted/python-standard-env?hl=ja>\n\n**App Engine SDK for python必要?** \nGoogle Cloud SDKはインストールしたと思うのですが、App Engine SDK for\npythonはインストールしたかどうか覚えていないのですが、確認する方法はありますか?そもそもこれはPythonで作成したアプリをGAEにデプロイする際に必要なものになりますか?\n\n**GAEのデプロイする前に請求の有効化は必要?**\n\n[![GAE開始](https://i.stack.imgur.com/bpXjZ.png)](https://i.stack.imgur.com/bpXjZ.png)\n\nApp Engine\nアプリケーションが作成されました。の下に`開始`ボタンあってそれを押してクレジットの登録を設定してからじゃないとデプロイできないのでしょうか? \n作成されたとあるのでGAEの設定みたいなのは済んでる気がするのですが初めて触るのでいまいち仕組みが分かりません。\n\n初心者で色々わからない事があり、GAEに作成したアプリをデプロイできません。 \nご教授頂けるとと幸いです。 \nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-14T03:55:55.040", "favorite_count": 0, "id": "51960", "last_activity_date": "2022-02-06T14:04:30.470", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "python", "python3", "google-app-engine", "google-cloud", "google-cloud-storage" ], "title": "GAEにアプリをデプロイしたい。", "view_count": 880 }
[ { "body": "確かクレジット設定してないと出来ないですよ", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T21:29:38.063", "id": "56306", "last_activity_date": "2019-07-01T21:29:38.063", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34917", "parent_id": "51960", "post_type": "answer", "score": 1 } ]
51960
null
56306