question dict | answers list | id stringlengths 2 5 | accepted_answer_id stringlengths 2 5 ⌀ | popular_answer_id stringlengths 2 5 ⌀ |
|---|---|---|---|---|
{
"accepted_answer_id": "52249",
"answer_count": 2,
"body": "どうかお教え願いませんでしょうか。以下のようにb.php内で計算された結果である変数$amountをa.phpへリアルタイムで渡したいのですがどうしてもできません。(a.phpとb.phpは異なる階層間にあります。)\n\nこの様な場合、何に問題があると考えられるのか、設定などをどのように変更すれば目的を達成できるか、あるいは全く異なる方法など、アドバイス、ご教授頂けませんでしょうか。\n\n:追記\n\nx.js\n\n```\n\n $.ajax({\n type:\"POST\",\n url:\"a.php\",\n data:\"type=price\",\n success:function($amount){\n $(\"#amount\").val($amount);\n }});\n \n```\n\na.php\n\n```\n\n case 'price': \n require_once(PATH.'/b.php');\n // 追記:$amount = \"232321\" 試しに左の様な設定にすると、問題が解決された結果になります。\n echo $amount;\n \n break;\n \n```\n\nb.php\n\n```\n\n 追記:\n // $amount = \"237272\"; 左記の様に値をfunction amount($db,$sum,$stay)の外に設定するとhtml上で237272が設定されますので、算出された実行結果である$amountの受け渡しは別として、php間、そしてjs、htmlでの値の受け渡しが確認されました。\n \n function amount($db,$sum,$stay){\n // 追記:global $amount; を試しましたが、$amountをa.phpで取得できていない様です。\n //global $amount;\n \n //諸々の計算\n $sub_total1 = sum1 + $tax;\n $sub_total2 = sum2 + $margin;\n $amount = $sub_total1 + $sub_total2;\n \n // echo $amount; この記述によって、$amountの値が上記の同じページの違う箇所に表示されます。 \n \n //追記 html上の表示箇所。\n \n if($type == 'html'){\n //諸々のhtml上の設定。\n $tem .= \"<td>\".number_format($sub_total1).\"円</td>\";\n $tem .= \"<td>\".number_format($sub_total2).\"円</td>\";\n $tem .= \"<td>\".number_format($amount).\"円</td>\";\n \n return $tem \n } \n \n }\n \n```\n\n * システムフロー上はa.phpに$amountが渡った後、js、そしてhtmlに渡りそこで設定されますが、以上のa.phpで$amountがb.phpから渡っていれば私が抱える問題は解決されます。\n\n * $_SESSIONも試しましたが、周回遅れ(前回)の計算結果が表示される様で、値の表示されるタイミングが合わないです。(リアルタイムに反映されない。)\n\n * 以下の様な設定にすると、html上でb.phpの全記述が表示されますのでパス自体には問題がないと思われます。\n\na.php\n\n```\n\n case 'price':\n $amount = file_get_contents(PATH.'/b.php');\n echo $amount; \n break;\n \n```\n\n * 追記: \na.phpを起動させる元のファイルは上記のx.jsです。data:\"type=price\",という形式でa.phpのcase\n'price':を呼び、結果が得られれば#amountをhtmlに渡します。\n\n * 追記: \nfunction\namount()内での計算は全てこのfunction内で情報を取得し、計算されたものになります。かなり長い計算の為、ここでは混乱を回避する為に簡略化させて頂きましたが、必要とされる情報は提示していると思われます。\n\n * 追記: \nb.php内のfunction\namount($db,$sum,$stay)内の実行結果である$amountをグローバル変数にする方法が分かりません。あるいは、上記にも記しましたが、この実行結果である$amountを算出直後にfunction\namount($db,$sum,$stay)の”外”に設定できれば、php,php,js,htmlと値が受け渡せると思われます。\n\n-最新-\n\n * 追記: \n最初に情報提供できなく申し訳ございません。function\namount内にhtml表示をする箇所がありreturn値はそのhtmlに返されます。このhtml用の戻り値(return $tem)を削除し、return\n$amountにすると、php,php,js,htmlと$amoutnが渡り、当初の目的が実現されますが、そのhtmlは削除できません。よって、return\n$amountを使用できないと思われますが、本件の様なhtmlを使用している場合、複数の戻り値を返す様なことはできるのでしょうか。\n\n * 追記: \nClassを使用すると、システムの他の記述が影響を受ける様でかなり大掛かりに変更をかけない限り機能しませんので、現時点では保留にした方が良さそうです。\n\n * 追記: \nグローバル変数がリスクが皆無で、本システムでも機能しているのであれば、一番簡単に実装できそうなのですが、現時点で機能させることができていない以上、同じことになるかもしれませんが、function\namount2の様な新たな$amount用のための関数を作成し、そこでfunction\namountの$amountを取得し、a.phpへ渡すなどっといった方法はありませんでしょうか。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T08:12:23.823",
"favorite_count": 0,
"id": "52204",
"last_activity_date": "2019-01-24T20:10:24.917",
"last_edit_date": "2019-01-24T20:10:24.917",
"last_editor_user_id": "19211",
"owner_user_id": "19211",
"post_type": "question",
"score": 2,
"tags": [
"php"
],
"title": "phpファイル間での関数内の実行結果の即時受渡し",
"view_count": 1273
} | [
{
"body": "まず原因ですが、require_onceはあくまで別のファイルを読み込んでいるのであって、実行しているわけではありません。\n\ncase文の中でb.phpを読み込んではいますが、ソース上は\n\n```\n\n case 'price':\n function amount($db,$sum,$stay){\n $amount = $sub_total1+$sub_total2;\n }\n echo $amount;\n break;\n \n```\n\nとなっているだけでfunction amountは呼ばれておらず、無... | 52204 | 52249 | 52249 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "DjangoのImageFieldを使ってGoogle Cloud Storageに画像をアップロードする際に、画像を圧縮したいです。 \npythonではgzipを使えばファイルの圧縮はできますが、どこに処理を書けばいいのでしょうか? \nまた、djangoで圧縮後のファイルサイズの制限やアップロードするファイルサイズの上限はどのように設定できますか?\n\n環境情報: \nDjango2.1.5, python3.7.0, django-storages1.7.1",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T09:01:18.260",
"favorite_count": 0,
"id": "52206",
"last_activity_date": "2019-01-22T09:01:18.260",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31876",
"post_type": "question",
"score": 0,
"tags": [
"django",
"google-cloud-storage"
],
"title": "DjangoのImageFieldから画像を圧縮してGoogle Cloud Storageに保存したい",
"view_count": 220
} | [] | 52206 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n float x = 400, y=100;\n int a=20,b=10;\n void setup() { size(800, 200); }\n void draw() {\n rect(x-10, y-5, a, b);\n }\n void keyPressed() {\n int k=' ';\n if (keyCode == RIGHT) {\n x++;\n } else if (keyCode == LEFT) {\n x--;\n } else if (keyCode == UP){\n y--;\n } else if (keyCode == DOWN){\n y++;\n }\n }\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T10:44:15.617",
"favorite_count": 0,
"id": "52210",
"last_activity_date": "2019-01-23T10:18:52.767",
"last_edit_date": "2019-01-22T12:11:15.747",
"last_editor_user_id": "19110",
"owner_user_id": "31878",
"post_type": "question",
"score": 0,
"tags": [
"java",
"processing"
],
"title": "スペースキーを押すごとに、四角形の大きさを2倍、1倍、2倍、1倍とトグします?",
"view_count": 1270
} | [
{
"body": "スペースキーを押すたびに`拡大中`かどうかを示す変数を書き換えることで、サイズをトグルして管理できます。 \n下記のサンプルコードではスペースを押すたびに`isExtended`変数を書き換えて、[三項演算子](https://processing.org/reference/conditional.html)で`a`と`b`の値を制御しています。\n\n```\n\n float x = 400, y = 100;\n int a = 20, b = 10;\n boolean isExtended = false;\n void setup() { size(800... | 52210 | null | 52258 |
{
"accepted_answer_id": "52359",
"answer_count": 1,
"body": "* **環境** \nOS:Windows10 \n言語:Python3 \nエディタ:Atom(1.34.0) \nAtom上でのデバッガパッケージ:atom-runner(2.7.1)\n\n * **やりたいこと** \nPythonをデバッグする際、一行ずつデバッグするステップ実行を行いたいのですが \n何かしらのデバッガパッケージ(atom-runnerなど)+ショートカットキーでステップ実行できないでしょうか。 \n(パッケージはatom-runnerにはこだわりません)\n\nなお、コード内の処理を止めたい箇所に以下のデバッグ用コードを記述するデバッグ方法は把握しています。\n\n`import pdb; pdb.set_trace()`",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T12:24:10.230",
"favorite_count": 0,
"id": "52214",
"last_activity_date": "2019-04-16T07:02:55.577",
"last_edit_date": "2019-01-23T00:44:50.707",
"last_editor_user_id": "3060",
"owner_user_id": "26841",
"post_type": "question",
"score": 1,
"tags": [
"python3",
"atom-editor"
],
"title": "AtomエディタでIDEの様にステップ実行によるデバッグを行うことは可能か",
"view_count": 2333
} | [
{
"body": "自分も同様の疑問にあたり、調べてみましたが \nよくあるデバッガのような動作をさせる方法は見つかりませんでした。\n\n簡単な操作でブレークポイントを設定してデバッグしたかったので、現在はVSCodeを使用しています。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-27T17:09:18.873",
"id": "52359",
"last_activity_date": "2019-01-27T17:09:18.873",
"... | 52214 | 52359 | 52359 |
{
"accepted_answer_id": "52274",
"answer_count": 2,
"body": "ブラウザで HTML/CSS を読み込んでページを描画した後、もし JavaScript によって動的に DOM\nが書き換わったら、ブラウザはページの再描画をしなくてはなりません。\n\n素朴に考えるとページの描画にかかるコストは無視できません。DOM\nがちょっと変わっただけで要素のレイアウトが変わりえますし、テキストの折り返しが変わって更にレイアウトが変わることもありそうです。\n\nしかし多くの場合、書き換えられる部分は HTML/CSS\nのコードで見るとごく一部です。したがって再描画時に全体を描き直すのではなく部分的に描き直すようなことをしていてもおかしくないと思うのですが、よく詳細を知りません。\n\nブラウザがページを再描画する際、どのようなアルゴリズムで行われているのでしょうか? どんな高速化があるのか箇条書きにする程度の粒度で教えて頂ければ幸いです。\n\n補足:個人的に何となくイメージが付いたので回答を承認しておりますが、更に回答を投稿して他の最適化やもっと詳しいお話を教えて頂くことも大歓迎です :)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T12:51:35.397",
"favorite_count": 0,
"id": "52215",
"last_activity_date": "2019-02-04T13:43:29.637",
"last_edit_date": "2019-02-04T13:43:29.637",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"post_type": "question",
"score": 8,
"tags": [
"javascript",
"html",
"css",
"アルゴリズム",
"browser"
],
"title": "DOMが書き換わった後ブラウザはどのように再描画していますか?",
"view_count": 3079
} | [
{
"body": "ブラウザの仕組み: 最新ウェブブラウザの内部構造\n<https://www.html5rocks.com/ja/tutorials/internals/howbrowserswork/#Dynamic_changes>\n\nの **”動的な変更”** に説明があります \n以下 ブラウザの仕組み: 最新ウェブブラウザの内部構造からの引用です。\n\n> 動的な変更 \n>\n> ブラウザでは、変更に対応して最小限の操作を実行しようとします。そのため、要素の色が変更された場合は、その要素の再描画のみを行います。要素の位置が変更された場合は、要素とその子や兄弟のレイアウトと再描画を行います。... | 52215 | 52274 | 52274 |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "すごく漠然となんですが質問させてください。「CDIを勉強しといて」だけ言われて、自分なりに奔走中なのですが、乱暴に?安直に言えばサーブレット&JSPの技術の延長線上にあるフレームワークのようなものと考えてよろしいのでしょうか?\n\nEclipseから「CDI Web\nプロジェクト」を選択し、とりあえずサーブレットとJSPで作成したプログラムをまるごと移しただけでも普通に動くんですが、ポイントはやはりアノテーションとxmlの活用でしょうか?また、JSPファイルをXHTMLに置き換えることでしょうか?\n\n個人的にこれまで触ったことのあるフレームワーク(Spring,\nStruts)と、サーブレットの技術から少しずつ色んな要素を取ってきて…でもどれにも似ていないような印象を受けました。\n\nすいません。質問を明確にさせて頂きますと、\n\n①JSPファイルでは「うまみ」が享受できないから、XHTMLファイルなのでしょうか?JSPではダメですか?\n\n②Servletクラスは存在し、MVCでいうModelがBeanと呼ばれるものになったという解釈で合っていますか?\n\n③要はサーブレット&JSPで事あるごとにスコープにせっせと入れて出してしてたものを、もっと簡単に扱えるようになるというのが(スコープ管理が)最大の利点でしょうか?\n\nどんな状況で、何をするために勉強するのかという点をお伝えできないぶん(あるいは私が無知過ぎて質問自体がおかしくて)お答えづらい部分もあるかもしれませんが、使われたことがおありの方がいらっしゃればお答え頂けますと幸いです。\n\nよろしくお願い致します。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T16:02:02.610",
"favorite_count": 0,
"id": "52217",
"last_activity_date": "2019-01-31T15:30:15.697",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"java"
],
"title": "CDI Web プロジェクトについて",
"view_count": 415
} | [
{
"body": "CDIは、Java EEフレームワークの機能の一部と言えると思います。\n\n「Context≒スコープ」を「Dependency\nInjection=コードで実装せずアノテーションで指定」するツールって感じでしょうか。(ぜんぜん違うかも・・・)\n\nxhtmlは関係ありません。 \nMVCでいうところのModelであってると思います。サーバーサイトJavaのアーキテクチャではビジネスロジック層です。ただ、CDIは利用範囲が広いのでプレゼンテーション層など他の領域にもつながってるらしいです。 \nご参考)<https://builder.japan.zdnet.com/sp_oracle... | 52217 | null | 52278 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "今研究で[TEPLA](http://www.cipher.risk.tsukuba.ac.jp/tepla/index.html)というオープンソースライブラリを利用して楕円曲線暗号を利用した署名の作成や検証を行うプログラムを書いています。 \n度々Segmentation Faultエラーが出るのですが、今回はソースコードの`//Segmentation\nFault`の部分でSegmentation Faultまたはエラーや警告なしで終了するのですが、その要因になっていそうなどの変数(calcpair,\ncontent.aggsig, g, ptmp)についても予期していない挙動は行っておりません。 \n解決法やご指摘、意見など聞かせていただけると幸いです。よろしくおねがいします。\n\ngdbを利用してデバッグした結果、該当の行での外部ライブラリ参照の際にGMPの関数?(`__gmpn_copyi`)を呼び出しているようなのですが、そこでSegmentation\nfaultを起こしているようです。 \naggregate.cを修正しました。ですが、エラーはそのままでした。\n\naggregate.c\n\n```\n\n #include\"integrated.h\"\n \n void aggregate(int auth)\n {\n extern mdata *mod;\n extern cdata content;\n extern EC_POINT g;\n extern EC_PAIRING p;\n extern EC_POINT publickey;\n \n int i, j;\n int mnmb;\n unsigned char aggstr[65536] = { 0 };\n unsigned char pair[1024] = { 0 };\n unsigned char strbuff[1024] = { 0 };\n unsigned char gbuf[512] = { 0 };\n FILE *aggregatefile;\n FILE *pairing1st;\n FILE *pairing2nd;\n FILE *pkey;\n Element calcpair;\n Element pairbuff;\n Element verify;\n \n //Evacuate parameter g\n point_get_str(gbuf, g);\n \n //Initialize\n mnmb = content.nummodel;\n pairing_clear(p);\n pairing_init(p, \"ECBN254a\");\n point_init(g, p->g1);\n point_set_str(g, gbuf);\n point_init(content.aggsig, p->g2);\n point_set_infinity(content.aggsig);\n point_init(publickey, p->g1);\n element_init(calcpair, p->g3);\n element_set_one(calcpair);\n element_init(pairbuff, p->g3);\n element_set_one(pairbuff);\n element_init(verify, p->g3);\n \n for (i = 0; i < mnmb; i++)\n {\n point_init(mod[i].signature, p->g2);\n point_set_str(mod[i].signature, mod[i].sigstr);\n point_init(mod[i].hash, p->g2);\n point_set_str(mod[i].hash, mod[i].hashstr);\n }\n \n if (auth == 1)\n {\n aggregatefile = fopen(\"slot/aggregate_sig.txt\", \"w\");\n pairing1st = fopen(\"slot/pairing1st.txt\", \"w\");\n }\n else {\n aggregatefile = fopen(\"slot'/aggregate_sig.txt\", \"w\");\n pairing1st = fopen(\"slot/pairing1st.txt\", \"r\");\n pairing2nd = fopen(\"slot'/pairing2nd.txt\", \"w\");\n pkey = fopen(\"slot/publickey.txt\", \"r\");\n \n if (pairing1st == NULL)\n {\n printf(\"Failed to open file.\\n\");\n exit(1);\n }\n \n if (pkey == NULL)\n {\n printf(\"Failed to open file.\\n\");\n exit(1);\n }\n }\n \n printf(\"Try to make aggregate signature.\\n\");\n for (i = 0; i < mnmb; i++)\n {\n point_add(content.aggsig, content.aggsig, mod[i].signature);\n }\n \n point_get_str(aggstr, content.aggsig);\n fputs(aggstr, aggregatefile);\n printf(\"Make aggregate signature!\\nSave to aggregate_sig.txt\\n\\n\");\n \n printf(\"g->\");\n point_print(g);\n printf(\"\\n\");\n printf(\"Aggregate signature->\");\n point_print(content.aggsig);\n printf(\"\\n\\n\");\n //printf(\"Element->\");\n //element_print(calcpair);\n //printf(\"\\n\");\n \n printf(\"Calculate pairing.\\n\");\n if (auth == 1)\n {\n pairing_map(calcpair, content.aggsig, g, p); //Segmentation fault\n element_get_str(pair, calcpair);\n fputs(pair, pairing1st);\n }\n else {\n fgets(strbuff, 1024, pkey);\n point_set_str(publickey, strbuff);\n fgets(strbuff, 1024, pairing1st);\n element_set_str(verify, strbuff);\n \n for (i = 0; i < mnmb; i++)\n {\n pairing_map(pairbuff, mod[i].hash, publickey, p);\n element_mul(calcpair, calcpair, pairbuff);\n }\n \n if (element_cmp(verify, calcpair) == 0)\n {\n printf(\"Signature is legal.\\n\");\n }\n else {\n printf(\"Signature is illegal.\\n\");\n }\n }\n \n fclose(aggregatefile);\n fclose(pairing1st);\n fclose(pairing2nd);\n fclose(pkey);\n \n printf(\"aggregate.c Finished.\\n\\n\");\n }\n \n```\n\nintegrated.h\n\n```\n\n #pragma once\n \n #include<stdio.h>\n #include<stdlib.h>\n #include<string.h>\n #include<time.h>\n #include<tepla/ec.h>\n \n //Path for various files\n #define KEYPATH \"slot/publickey.txt\"\n #define PMMDATA \"share/sample.pmm\"\n #define SETTINGPATH \"slot/control_settings.txt\"\n \n //model data structure\n typedef struct modeldata {\n int modelid; //Model ID in content\n char janame[32]; //Model's Japasese name\n char enname[32]; //Model's English name\n char filepath[256]; //File path to model data\n int modify; //Check flag for modification\n int change; //Check flag for changable\n int delete; //Check flag for deletable\n int add; //Check flag for addable\n unsigned int permit; //Permission for edit control\n EC_POINT hash; //Buffer for caliculating value of hash\n char hashstr[1024]; //For saving hash data\n EC_POINT signature; //Buffer for caliculating signature\n char sigstr[1024]; //For saving signature data\n } mdata;\n \n //content data structure\n typedef struct contentdata {\n int nummodel;\n EC_POINT aggsig;\n } cdata;\n \n extern void Init_tepla();\n extern void CLK_INIT();\n extern void CLK_START();\n extern void CLK_END();\n \n```\n\nmain.c\n\n```\n\n #include\"integrated.h\"\n \n //Define global variables\n clock_t clk[2] = { 0,0 };\n EC_PAIRING p;\n EC_POINT g;\n EC_POINT publickey;\n gmp_randstate_t state;\n mpz_t grx;\n cdata content;\n mdata *mod;\n \n //Define external function\n extern void keygen();\n extern void dataextract();\n extern void siggen(int auth);\n extern void aggregate(int auth);\n void Init_tepla();\n void CLK_INIT();\n void CLK_START();\n void CLK_END();\n \n //main\n int main()\n { \n unsigned int author = 0;\n \n //input\n scanf(\"%d\", &author);\n \n CLK_INIT();\n CLK_START();\n keygen();\n dataextract();\n siggen(author);\n aggregate(author);\n \n free(mod);\n \n printf(\"Program finished.\\n\");\n CLK_END();\n \n return 0;\n }\n \n //To initialize tepla\n void Init_tepla()\n {\n printf(\"Initialize tepla\\n\");\n pairing_init(p, \"ECBN254a\");\n point_init(g, p->g1);\n point_random(g);\n \n mpz_init(grx);\n gmp_randinit_default(state);\n gmp_randseed_ui(state, (unsigned)time(NULL));\n mpz_urandomb(grx, state, 256);\n }\n \n //Functions to measure elapsed time\n void CLK_INIT()\n {\n clk[0] = clock();\n clk[1] = clock();\n }\n \n void CLK_START()\n {\n clk[0] = clock();\n }\n \n void CLK_END()\n {\n clk[1] = clock();\n double elapsed_time = (double)(clk[1] - clk[0]) / (CLOCKS_PER_SEC)*1000;\n printf(\"Elapsed time is %.2lf [ms]\\n\", elapsed_time);\n }\n \n```",
"comment_count": 10,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T21:31:40.917",
"favorite_count": 0,
"id": "52218",
"last_activity_date": "2019-01-23T20:44:18.957",
"last_edit_date": "2019-01-23T20:44:18.957",
"last_editor_user_id": "31611",
"owner_user_id": "31611",
"post_type": "question",
"score": 0,
"tags": [
"c",
"gcc",
"cygwin"
],
"title": "Segmentation Faultエラーの要因について",
"view_count": 770
} | [] | 52218 | null | null |
{
"accepted_answer_id": "52427",
"answer_count": 1,
"body": "pyqy5でwmv動画を再生させるときに、brightness,contrast,hue,saturationを変化させたいです。下は試しに書いてみたコードです。\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)\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.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.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 print(videoWidget.brightness())\n videoWidget.setBrightness(50)\n videoWidget.setContrast(100)\n videoWidget.setHue(100)\n videoWidget.setSaturation(100)\n print(videoWidget.brightness())\n \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 \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これを実行することで、 \n[](https://i.stack.imgur.com/wheSl.png) \nの様なGUIが作成されます。ここで、再際される動画のbrightness,contrast,hue,saturationが変化したものが再生されるつもりでしたが、実行しても通常のままの動画が再生されました。また、このコードを描くときに参考にしたコードがしたのコードで(長いですが、そのまま載せます。申し訳ありません。)、そちらでは上記4つの変化を施すことが可能でした。私のコードをどのように直せばよいのでしょうか。\n\n```\n\n from PyQt5.QtCore import (pyqtSignal, pyqtSlot, Q_ARG, QAbstractItemModel,\n QFileInfo, qFuzzyCompare, QMetaObject, QModelIndex, QObject, Qt,\n QThread, QTime, QUrl)\n from PyQt5.QtGui import QColor, qGray, QImage, QPainter, QPalette\n from PyQt5.QtMultimedia import (QAbstractVideoBuffer, QMediaContent,\n QMediaMetaData, QMediaPlayer, QMediaPlaylist, QVideoFrame, QVideoProbe)\n from PyQt5.QtMultimediaWidgets import QVideoWidget\n from PyQt5.QtWidgets import (QApplication, QComboBox, QDialog, QFileDialog,\n QFormLayout, QHBoxLayout, QLabel, QListView, QMessageBox, QPushButton,\n QSizePolicy, QSlider, QStyle, QToolButton, QVBoxLayout, QWidget)\n \n \n class VideoWidget(QVideoWidget):\n \n def __init__(self, parent=None):\n super(VideoWidget, self).__init__(parent)\n \n self.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)\n \n p = self.palette()\n p.setColor(QPalette.Window, Qt.black)\n self.setPalette(p)\n \n self.setAttribute(Qt.WA_OpaquePaintEvent)\n \n def keyPressEvent(self, event):\n if event.key() == Qt.Key_Escape and self.isFullScreen():\n self.setFullScreen(False)\n event.accept()\n elif event.key() == Qt.Key_Enter and event.modifiers() & Qt.Key_Alt:\n self.setFullScreen(not self.isFullScreen())\n event.accept()\n else:\n super(VideoWidget, self).keyPressEvent(event)\n \n def mouseDoubleClickEvent(self, event):\n self.setFullScreen(not self.isFullScreen())\n event.accept()\n \n \n class PlaylistModel(QAbstractItemModel):\n \n Title, ColumnCount = range(2)\n \n def __init__(self, parent=None):\n super(PlaylistModel, self).__init__(parent)\n \n self.m_playlist = None\n \n def rowCount(self, parent=QModelIndex()):\n return self.m_playlist.mediaCount() if self.m_playlist is not None and not parent.isValid() else 0\n \n def columnCount(self, parent=QModelIndex()):\n return self.ColumnCount if not parent.isValid() else 0\n \n def index(self, row, column, parent=QModelIndex()):\n return self.createIndex(row, column) if self.m_playlist is not None and not parent.isValid() and row >= 0 and row < self.m_playlist.mediaCount() and column >= 0 and column < self.ColumnCount else QModelIndex()\n \n def parent(self, child):\n return QModelIndex()\n \n def data(self, index, role=Qt.DisplayRole):\n if index.isValid() and role == Qt.DisplayRole:\n if index.column() == self.Title:\n location = self.m_playlist.media(index.row()).canonicalUrl()\n return QFileInfo(location.path()).fileName()\n \n return self.m_data[index]\n \n return None\n \n def playlist(self):\n return self.m_playlist\n \n def setPlaylist(self, playlist):\n if self.m_playlist is not None:\n self.m_playlist.mediaAboutToBeInserted.disconnect(\n self.beginInsertItems)\n self.m_playlist.mediaInserted.disconnect(self.endInsertItems)\n self.m_playlist.mediaAboutToBeRemoved.disconnect(\n self.beginRemoveItems)\n self.m_playlist.mediaRemoved.disconnect(self.endRemoveItems)\n self.m_playlist.mediaChanged.disconnect(self.changeItems)\n \n self.beginResetModel()\n self.m_playlist = playlist\n \n if self.m_playlist is not None:\n self.m_playlist.mediaAboutToBeInserted.connect(\n self.beginInsertItems)\n self.m_playlist.mediaInserted.connect(self.endInsertItems)\n self.m_playlist.mediaAboutToBeRemoved.connect(\n self.beginRemoveItems)\n self.m_playlist.mediaRemoved.connect(self.endRemoveItems)\n self.m_playlist.mediaChanged.connect(self.changeItems)\n \n self.endResetModel()\n \n def beginInsertItems(self, start, end):\n self.beginInsertRows(QModelIndex(), start, end)\n \n def endInsertItems(self):\n self.endInsertRows()\n \n def beginRemoveItems(self, start, end):\n self.beginRemoveRows(QModelIndex(), start, end)\n \n def endRemoveItems(self):\n self.endRemoveRows()\n \n def changeItems(self, start, end):\n self.dataChanged.emit(self.index(start, 0),\n self.index(end, self.ColumnCount))\n \n \n class PlayerControls(QWidget):\n \n play = pyqtSignal()\n pause = pyqtSignal()\n stop = pyqtSignal()\n next = pyqtSignal()\n previous = pyqtSignal()\n changeVolume = pyqtSignal(int)\n changeMuting = pyqtSignal(bool)\n changeRate = pyqtSignal(float)\n \n def __init__(self, parent=None):\n super(PlayerControls, self).__init__(parent)\n \n self.playerState = QMediaPlayer.StoppedState\n self.playerMuted = False\n \n self.playButton = QToolButton(clicked=self.playClicked)\n self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))\n \n self.stopButton = QToolButton(clicked=self.stop)\n self.stopButton.setIcon(self.style().standardIcon(QStyle.SP_MediaStop))\n self.stopButton.setEnabled(False)\n \n self.nextButton = QToolButton(clicked=self.next)\n self.nextButton.setIcon(\n self.style().standardIcon(QStyle.SP_MediaSkipForward))\n \n self.previousButton = QToolButton(clicked=self.previous)\n self.previousButton.setIcon(\n self.style().standardIcon(QStyle.SP_MediaSkipBackward))\n \n self.muteButton = QToolButton(clicked=self.muteClicked)\n self.muteButton.setIcon(\n self.style().standardIcon(QStyle.SP_MediaVolume))\n \n self.volumeSlider = QSlider(Qt.Horizontal,\n sliderMoved=self.changeVolume)\n self.volumeSlider.setRange(0, 100)\n \n self.rateBox = QComboBox(activated=self.updateRate)\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 \n layout = QHBoxLayout()\n layout.setContentsMargins(0, 0, 0, 0)\n layout.addWidget(self.stopButton)\n layout.addWidget(self.previousButton)\n layout.addWidget(self.playButton)\n layout.addWidget(self.nextButton)\n layout.addWidget(self.muteButton)\n layout.addWidget(self.volumeSlider)\n layout.addWidget(self.rateBox)\n self.setLayout(layout)\n \n def state(self):\n return self.playerState\n \n def setState(self,state):\n if state != self.playerState:\n self.playerState = state\n \n if state == QMediaPlayer.StoppedState:\n self.stopButton.setEnabled(False)\n self.playButton.setIcon(\n self.style().standardIcon(QStyle.SP_MediaPlay))\n elif state == QMediaPlayer.PlayingState:\n self.stopButton.setEnabled(True)\n self.playButton.setIcon(\n self.style().standardIcon(QStyle.SP_MediaPause))\n elif state == QMediaPlayer.PausedState:\n self.stopButton.setEnabled(True)\n self.playButton.setIcon(\n self.style().standardIcon(QStyle.SP_MediaPlay))\n \n def volume(self):\n return self.volumeSlider.value()\n \n def setVolume(self, volume):\n self.volumeSlider.setValue(volume)\n \n def isMuted(self):\n return self.playerMuted\n \n def setMuted(self, muted):\n if muted != self.playerMuted:\n self.playerMuted = muted\n \n self.muteButton.setIcon(\n self.style().standardIcon(\n QStyle.SP_MediaVolumeMuted if muted else QStyle.SP_MediaVolume))\n \n def playClicked(self):\n if self.playerState in (QMediaPlayer.StoppedState, QMediaPlayer.PausedState):\n self.play.emit()\n elif self.playerState == QMediaPlayer.PlayingState:\n self.pause.emit()\n \n def muteClicked(self):\n self.changeMuting.emit(not self.playerMuted)\n \n def playbackRate(self):\n return self.rateBox.itemData(self.rateBox.currentIndex())\n \n def setPlaybackRate(self, rate):\n for i in range(self.rateBox.count()):\n if qFuzzyCompare(rate, self.rateBox.itemData(i)):\n self.rateBox.setCurrentIndex(i)\n return\n \n self.rateBox.addItem(\"%dx\" % rate, rate)\n self.rateBox.setCurrentIndex(self.rateBox.count() - 1)\n \n def updateRate(self):\n self.changeRate.emit(self.playbackRate())\n \n \n class FrameProcessor(QObject):\n \n histogramReady = pyqtSignal(list)\n \n @pyqtSlot(QVideoFrame, int)\n def processFrame(self, frame, levels):\n histogram = [0.0] * levels\n \n if levels and frame.map(QAbstractVideoBuffer.ReadOnly):\n pixelFormat = frame.pixelFormat()\n \n if pixelFormat == QVideoFrame.Format_YUV420P or pixelFormat == QVideoFrame.Format_NV12:\n # Process YUV data.\n bits = frame.bits()\n for idx in range(frame.height() * frame.width()):\n histogram[(bits[idx] * levels) >> 8] += 1.0\n else:\n imageFormat = QVideoFrame.imageFormatFromPixelFormat(pixelFormat)\n if imageFormat != QImage.Format_Invalid:\n # Process RGB data.\n image = QImage(frame.bits(), frame.width(), frame.height(), imageFormat)\n \n for y in range(image.height()):\n for x in range(image.width()):\n pixel = image.pixel(x, y)\n histogram[(qGray(pixel) * levels) >> 8] += 1.0\n \n # Find the maximum value.\n maxValue = 0.0\n for value in histogram:\n if value > maxValue:\n maxValue = value\n \n # Normalise the values between 0 and 1.\n if maxValue > 0.0:\n for i in range(len(histogram)):\n histogram[i] /= maxValue\n \n frame.unmap()\n \n self.histogramReady.emit(histogram)\n \n \n class HistogramWidget(QWidget):\n \n def __init__(self, parent=None):\n super(HistogramWidget, self).__init__(parent)\n \n self.m_levels = 128\n self.m_isBusy = False\n self.m_histogram = []\n self.m_processor = FrameProcessor()\n self.m_processorThread = QThread()\n \n self.m_processor.moveToThread(self.m_processorThread)\n self.m_processor.histogramReady.connect(self.setHistogram)\n \n def __del__(self):\n self.m_processorThread.quit()\n self.m_processorThread.wait(10000)\n \n def setLevels(self, levels):\n self.m_levels = levels\n \n def processFrame(self, frame):\n if self.m_isBusy:\n return\n \n self.m_isBusy = True\n QMetaObject.invokeMethod(self.m_processor, 'processFrame',\n Qt.QueuedConnection, Q_ARG(QVideoFrame, frame),\n Q_ARG(int, self.m_levels))\n \n @pyqtSlot(list)\n def setHistogram(self, histogram):\n self.m_isBusy = False\n self.m_histogram = list(histogram)\n self.update()\n \n def paintEvent(self, event):\n painter = QPainter(self)\n \n if len(self.m_histogram) == 0:\n painter.fillRect(0, 0, self.width(), self.height(),\n QColor.fromRgb(0, 0, 0))\n return\n \n barWidth = self.width() / float(len(self.m_histogram))\n \n for i, value in enumerate(self.m_histogram):\n h = value * self.height()\n # Draw the level.\n painter.fillRect(barWidth * i, self.height() - h,\n barWidth * (i + 1), self.height(), Qt.red)\n # Clear the rest of the control.\n painter.fillRect(barWidth * i, 0, barWidth * (i + 1),\n self.height() - h, Qt.black)\n \n \n class Player(QWidget):\n \n fullScreenChanged = pyqtSignal(bool)\n \n def __init__(self, playlist, parent=None):\n super(Player, self).__init__(parent)\n \n self.colorDialog = None\n self.trackInfo = \"\"\n self.statusInfo = \"\"\n self.duration = 0\n \n self.player = QMediaPlayer()\n self.playlist = QMediaPlaylist()\n self.player.setPlaylist(self.playlist)\n \n self.player.durationChanged.connect(self.durationChanged)\n self.player.positionChanged.connect(self.positionChanged)\n self.player.metaDataChanged.connect(self.metaDataChanged)\n self.playlist.currentIndexChanged.connect(self.playlistPositionChanged)\n self.player.mediaStatusChanged.connect(self.statusChanged)\n self.player.bufferStatusChanged.connect(self.bufferingProgress)\n self.player.videoAvailableChanged.connect(self.videoAvailableChanged)\n self.player.error.connect(self.displayErrorMessage)\n \n self.videoWidget = VideoWidget()\n self.player.setVideoOutput(self.videoWidget)\n \n self.playlistModel = PlaylistModel()\n self.playlistModel.setPlaylist(self.playlist)\n \n self.playlistView = QListView()\n self.playlistView.setModel(self.playlistModel)\n self.playlistView.setCurrentIndex(\n self.playlistModel.index(self.playlist.currentIndex(), 0))\n \n self.playlistView.activated.connect(self.jump)\n \n self.slider = QSlider(Qt.Horizontal)\n self.slider.setRange(0, self.player.duration() / 1000)\n \n self.labelDuration = QLabel()\n self.slider.sliderMoved.connect(self.seek)\n \n self.labelHistogram = QLabel()\n self.labelHistogram.setText(\"Histogram:\")\n self.histogram = HistogramWidget()\n histogramLayout = QHBoxLayout()\n histogramLayout.addWidget(self.labelHistogram)\n histogramLayout.addWidget(self.histogram, 1)\n \n self.probe = QVideoProbe()\n self.probe.videoFrameProbed.connect(self.histogram.processFrame)\n self.probe.setSource(self.player)\n \n openButton = QPushButton(\"Open\", clicked=self.open)\n \n controls = PlayerControls()\n controls.setState(self.player.state())\n controls.setVolume(self.player.volume())\n controls.setMuted(controls.isMuted())\n \n controls.play.connect(self.player.play)\n controls.pause.connect(self.player.pause)\n controls.stop.connect(self.player.stop)\n controls.next.connect(self.playlist.next)\n controls.previous.connect(self.previousClicked)\n controls.changeVolume.connect(self.player.setVolume)\n controls.changeMuting.connect(self.player.setMuted)\n controls.changeRate.connect(self.player.setPlaybackRate)\n controls.stop.connect(self.videoWidget.update)\n \n self.player.stateChanged.connect(controls.setState)\n self.player.volumeChanged.connect(controls.setVolume)\n self.player.mutedChanged.connect(controls.setMuted)\n \n self.fullScreenButton = QPushButton(\"FullScreen\")\n self.fullScreenButton.setCheckable(True)\n \n self.colorButton = QPushButton(\"Color Options...\")\n self.colorButton.setEnabled(False)\n self.colorButton.clicked.connect(self.showColorDialog)\n \n displayLayout = QHBoxLayout()\n displayLayout.addWidget(self.videoWidget, 2)\n displayLayout.addWidget(self.playlistView)\n \n controlLayout = QHBoxLayout()\n controlLayout.setContentsMargins(0, 0, 0, 0)\n controlLayout.addWidget(openButton)\n controlLayout.addStretch(1)\n controlLayout.addWidget(controls)\n controlLayout.addStretch(1)\n controlLayout.addWidget(self.fullScreenButton)\n controlLayout.addWidget(self.colorButton)\n \n layout = QVBoxLayout()\n layout.addLayout(displayLayout)\n hLayout = QHBoxLayout()\n hLayout.addWidget(self.slider)\n hLayout.addWidget(self.labelDuration)\n layout.addLayout(hLayout)\n layout.addLayout(controlLayout)\n layout.addLayout(histogramLayout)\n \n self.setLayout(layout)\n \n if not self.player.isAvailable():\n QMessageBox.warning(self, \"Service not available\",\n \"The QMediaPlayer object does not have a valid service.\\n\"\n \"Please check the media service plugins are installed.\")\n \n controls.setEnabled(False)\n self.playlistView.setEnabled(False)\n openButton.setEnabled(False)\n self.colorButton.setEnabled(False)\n self.fullScreenButton.setEnabled(False)\n \n self.metaDataChanged()\n \n self.addToPlaylist(playlist)\n \n def open(self):\n fileNames, _ = QFileDialog.getOpenFileNames(self, \"Open Files\")\n self.addToPlaylist(fileNames)\n \n def addToPlaylist(self, fileNames):\n for name in fileNames:\n fileInfo = QFileInfo(name)\n if fileInfo.exists():\n url = QUrl.fromLocalFile(fileInfo.absoluteFilePath())\n if fileInfo.suffix().lower() == 'm3u':\n self.playlist.load(url)\n else:\n self.playlist.addMedia(QMediaContent(url))\n else:\n url = QUrl(name)\n if url.isValid():\n self.playlist.addMedia(QMediaContent(url))\n \n def durationChanged(self, duration):\n duration /= 1000\n \n self.duration = duration\n self.slider.setMaximum(duration)\n \n def positionChanged(self, progress):\n progress /= 1000\n \n if not self.slider.isSliderDown():\n self.slider.setValue(progress)\n \n self.updateDurationInfo(progress)\n \n def metaDataChanged(self):\n if self.player.isMetaDataAvailable():\n self.setTrackInfo(\"%s - %s\" % (\n self.player.metaData(QMediaMetaData.AlbumArtist),\n self.player.metaData(QMediaMetaData.Title)))\n \n def previousClicked(self):\n # Go to the previous track if we are within the first 5 seconds of\n # playback. Otherwise, seek to the beginning.\n if self.player.position() <= 5000:\n self.playlist.previous()\n else:\n self.player.setPosition(0)\n \n def jump(self, index):\n if index.isValid():\n self.playlist.setCurrentIndex(index.row())\n self.player.play()\n \n def playlistPositionChanged(self, position):\n self.playlistView.setCurrentIndex(\n self.playlistModel.index(position, 0))\n \n def seek(self, seconds):\n self.player.setPosition(seconds * 1000)\n \n def statusChanged(self, status):\n self.handleCursor(status)\n \n if status == QMediaPlayer.LoadingMedia:\n self.setStatusInfo(\"Loading...\")\n elif status == QMediaPlayer.StalledMedia:\n self.setStatusInfo(\"Media Stalled\")\n elif status == QMediaPlayer.EndOfMedia:\n QApplication.alert(self)\n elif status == QMediaPlayer.InvalidMedia:\n self.displayErrorMessage()\n else:\n self.setStatusInfo(\"\")\n \n def handleCursor(self, status):\n if status in (QMediaPlayer.LoadingMedia, QMediaPlayer.BufferingMedia, QMediaPlayer.StalledMedia):\n self.setCursor(Qt.BusyCursor)\n else:\n self.unsetCursor()\n \n def bufferingProgress(self, progress):\n self.setStatusInfo(\"Buffering %d%\" % progress)\n \n def videoAvailableChanged(self, available):\n if available:\n self.fullScreenButton.clicked.connect(\n self.videoWidget.setFullScreen)\n self.videoWidget.fullScreenChanged.connect(\n self.fullScreenButton.setChecked)\n \n if self.fullScreenButton.isChecked():\n self.videoWidget.setFullScreen(True)\n else:\n self.fullScreenButton.clicked.disconnect(\n self.videoWidget.setFullScreen)\n self.videoWidget.fullScreenChanged.disconnect(\n self.fullScreenButton.setChecked)\n \n self.videoWidget.setFullScreen(False)\n \n self.colorButton.setEnabled(available)\n \n def setTrackInfo(self, info):\n self.trackInfo = info\n \n if self.statusInfo != \"\":\n self.setWindowTitle(\"%s | %s\" % (self.trackInfo, self.statusInfo))\n else:\n self.setWindowTitle(self.trackInfo)\n \n def setStatusInfo(self, info):\n self.statusInfo = info\n \n if self.statusInfo != \"\":\n self.setWindowTitle(\"%s | %s\" % (self.trackInfo, self.statusInfo))\n else:\n self.setWindowTitle(self.trackInfo)\n \n def displayErrorMessage(self):\n self.setStatusInfo(self.player.errorString())\n \n def updateDurationInfo(self, currentInfo):\n duration = self.duration\n if currentInfo or duration:\n currentTime = QTime((currentInfo/3600)%60, (currentInfo/60)%60,\n currentInfo%60, (currentInfo*1000)%1000)\n totalTime = QTime((duration/3600)%60, (duration/60)%60,\n duration%60, (duration*1000)%1000);\n \n format = 'hh:mm:ss' if duration > 3600 else 'mm:ss'\n tStr = currentTime.toString(format) + \" / \" + totalTime.toString(format)\n else:\n tStr = \"\"\n \n self.labelDuration.setText(tStr)\n \n def showColorDialog(self):\n if self.colorDialog is None:\n brightnessSlider = QSlider(Qt.Horizontal)\n brightnessSlider.setRange(-100, 100)\n brightnessSlider.setValue(self.videoWidget.brightness())\n brightnessSlider.sliderMoved.connect(\n self.videoWidget.setBrightness)\n self.videoWidget.brightnessChanged.connect(\n brightnessSlider.setValue)\n \n contrastSlider = QSlider(Qt.Horizontal)\n contrastSlider.setRange(-100, 100)\n contrastSlider.setValue(self.videoWidget.contrast())\n contrastSlider.sliderMoved.connect(self.videoWidget.setContrast)\n self.videoWidget.contrastChanged.connect(contrastSlider.setValue)\n \n hueSlider = QSlider(Qt.Horizontal)\n hueSlider.setRange(-100, 100)\n hueSlider.setValue(self.videoWidget.hue())\n hueSlider.sliderMoved.connect(self.videoWidget.setHue)\n self.videoWidget.hueChanged.connect(hueSlider.setValue)\n \n saturationSlider = QSlider(Qt.Horizontal)\n saturationSlider.setRange(-100, 100)\n saturationSlider.setValue(self.videoWidget.saturation())\n saturationSlider.sliderMoved.connect(\n self.videoWidget.setSaturation)\n self.videoWidget.saturationChanged.connect(\n saturationSlider.setValue)\n \n layout = QFormLayout()\n layout.addRow(\"Brightness\", brightnessSlider)\n layout.addRow(\"Contrast\", contrastSlider)\n layout.addRow(\"Hue\", hueSlider)\n layout.addRow(\"Saturation\", saturationSlider)\n \n button = QPushButton(\"Close\")\n layout.addRow(button)\n \n self.colorDialog = QDialog(self)\n self.colorDialog.setWindowTitle(\"Color Options\")\n self.colorDialog.setLayout(layout)\n \n button.clicked.connect(self.colorDialog.close)\n \n self.colorDialog.show()\n \n \n if __name__ == '__main__':\n \n import sys\n \n app = QApplication(sys.argv)\n \n player = Player(sys.argv[1:])\n player.show()\n \n sys.exit(app.exec_())\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T21:42:23.513",
"favorite_count": 0,
"id": "52219",
"last_activity_date": "2019-01-30T11:18:05.090",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26529",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"pyqt5"
],
"title": "pyqt5でwmvファイルの動画を再生するときにbrightnessなどを変化させたい",
"view_count": 127
} | [
{
"body": "いまいち原理がよく分かりませんが、見よう見まねで書いた下のコードでとりあえず希望道理の動作はしました。Sliderを介して変数を変更すると何故か動きました。\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, ... | 52219 | 52427 | 52427 |
{
"accepted_answer_id": "52260",
"answer_count": 1,
"body": "pyqt5で計算中は別のウィンドウを表示するように作ってみたいです。下は試しに書いてみたコードです。\n\n```\n\n import sys\n from PyQt5 import*\n from PyQt5.QtWidgets import *\n from PyQt5.QtGui import *\n from PyQt5.QtCore import *\n from PyQt5 import QtGui,QtCore, QtWidgets\n import time\n from time import sleep\n \n \n class Second(QtWidgets.QWidget):\n def __init__(self, parent=None):\n super(Second, self).__init__(parent)\n #Setting a title, locating and sizing the window\n self.title = 'My Second Window'\n self.left = 200\n self.top = 200\n self.width = 500\n self.height = 500\n self.setWindowTitle(self.title)\n self.setGeometry(self.left, self.top, self.width, self.height)\n lbl = QtWidgets.QLabel(\"計算中\")\n \n layout1=QHBoxLayout()\n layout1.addWidget(lbl)\n self.setLayout(layout1)\n \n \n class First(QtWidgets.QWidget):\n def __init__(self, parent=None):\n super(First, self).__init__(parent)\n self.title = 'My First Window'\n self.left = 100\n self.top = 100\n self.width = 500\n self.height = 500\n self.setWindowTitle(self.title)\n self.setGeometry(self.left, self.top, self.width, self.height)\n self.pushButton = QtWidgets.QPushButton(\"Open Me\", self)\n self.pushButton2 = QtWidgets.QPushButton(\"close\", self)\n self.pushButton.clicked.connect(self.on_pushButton_clicked)\n self.pushButton2.clicked.connect(self.on_pushButton2_clicked)\n self.newWindow = Second()\n #self.timer = QBasicTimer()\n #self.step=0\n #self.calctime=1000\n \n layout1=QHBoxLayout()\n layout1.addWidget(self.pushButton)\n layout1.addWidget(self.pushButton2)\n \n self.setLayout(layout1)\n \n \n def on_pushButton_clicked(self):\n self.newWindow.show()\n self.calc()\n self.newWindow.close()\n \n def calc(self):\n sleep(3)\n \n \n def on_pushButton2_clicked(self):\n self.newWindow.close()\n \n if __name__ == '__main__':\n app = QtWidgets.QApplication(sys.argv)\n main = First()\n main.show()\n sys.exit(app.exec_())\n \n```\n\nこれを実行することで、次のようなGUIが作成されます。 \n[](https://i.stack.imgur.com/wiIPd.png) \nここで、計算に3秒かかるとして、「Open\nMe」のボタンを押すとcalc関数を実行している間、「計算中」と書かれた別ウィンドウが表示されるように書いたつもりです。しかし、実際に実行すると計算の3秒間、真っ白な別ウィンドが表示されただけでした。どのように直せば計算中にSecondクラスで書いたウィンドウが表示されるのでしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-22T23:21:52.877",
"favorite_count": 0,
"id": "52221",
"last_activity_date": "2019-01-24T00:51:37.990",
"last_edit_date": "2019-01-23T01:37:08.060",
"last_editor_user_id": "19110",
"owner_user_id": "26529",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"pyqt5"
],
"title": "pyqt5で計算中に別のウィンドウを表示したい",
"view_count": 1014
} | [
{
"body": "**コメント後**\n\n`sleep(3)`を外せばいいかなと思ったのですが、適当な`for`文を`calc()`関数に入れて実行したら同じ現象が発生しました。恐らく私と同じように、`for`文かwhileループを実行し、PyQt5本来のイベントが取られているのだろうと思います。こういう時、`Qt`では別の計算を別のプロセスに任せて行う事ができる便利な方法が用意されています。\n\n以下のコードをご覧ください。 \nキーポイントは、`QtWidgets.QApplication.processEvents()`です。 \n本来プログラムは一つのプロセスで全てを行うため、計算をするためにルー... | 52221 | 52260 | 52260 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "# 症状\n\nPyOpenGL(3.1.1a1) +Python3.7で画像の上に四角形を表示したいが、挙動がおかしい。\n\n## 実現しようとしていること\n\nPNG画像をテクスチャ化し、その上に半透明の黒の四角形を表示する。 \n四角形は一回り小さくしてあります。\n\n## 発生する症状\n\n四角形の表示は正常にできるものの、マウスを左クリックすると、表示がおかしくなります。\n\n### 左クリック前\n\n[](https://i.stack.imgur.com/pn8qP.png)\n\n### 左クリック後\n\n[](https://i.stack.imgur.com/xrH7c.png)\n\n以下、ソースコード\n\n```\n\n import sys\n from OpenGL.GL import *\n from OpenGL.GLU import *\n from OpenGL.GLUT import *\n from win32api import GetSystemMetrics\n from PIL import Image\n \n def load_texture():\n img = Image.open(\"PIL_capture.png\")\n w, h = img.size\n glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.tobytes())\n \n def ScreenShort():\n glPushMatrix()\n glClearColor(1.0, 1.0, 0.0, 0.0)#背景の色##glの初期化\n glClear(GL_COLOR_BUFFER_BIT)\n \n \n glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)\n glEnable(GL_BLEND)##glの初期化#ブレンドの有効か\n \n glEnable(GL_TEXTURE_2D)##glの初期化##テクスチャを有効化\n \n glBegin(GL_QUADS)\n glTexCoord2d(0.0, 1.0)\n glVertex3d(-1.0, -1.0, 0.0)\n glTexCoord2d(1.0, 1.0)\n glVertex3d( 1.0, -1.0, 0.0)\n glTexCoord2d(1.0, 0.0)\n glVertex3d( 1.0, 1.0, 0.0)\n glTexCoord2d(0.0, 0.0)\n glVertex3d(-1.0, 1.0, 0.0)\n glEnd()\n glDisable(GL_TEXTURE_2D)\n glDisable(GL_BLEND)\n glFlush()\n glPopMatrix()\n \n def sikakukei(): \n ##四角形\n glutSwapBuffers() \n glPushMatrix()\n glColor4f(0.0,0.0,0.0,0.4)#テクスチャの色指定##黒##透過率##用調整\n glEnable(GL_BLEND)##ブレンド有効\n glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)\n glBegin(GL_POLYGON)\n glVertex2d(-0.9,-0.9)##テクスチャの頂点指定\n glVertex2d(0.9,-0.9)\n glVertex2d(0.9,0.9)\n glVertex2d(-0.9,0.9)\n glEnd()\n glPopMatrix()\n glFlush()##強制実行\n # def haikei():\n # glClearColor(1.0, 1.0, 1.0, 0.0)##背景の色##白\n ##バッファ削除\n def display():#図形描画\n #glClear(GL_COLOR_BUFFER_BIT)\n glPushMatrix()\n ScreenShort()\n glPopMatrix()\n glPushMatrix()##変換行列に保存l再描画イベント発生時に動かないようにする。glPopMatrix()とくみあわせる。\n #glRotated(1.0,1.0,1.0,1.0)\n sikakukei()\n glPopMatrix()#\n def main():##GLUTの設定 \n glutInit(sys.argv)##GLUT 初期化\n glutInitDisplayMode(GLUT_RGBA)##OpenGL の描画時に利用するモードを指定\n w = GetSystemMetrics(0)#横ピクセル数取得\n h = GetSystemMetrics(1)#縦ピクセル数取得\n glutGameModeString (str(w)+\"x\"+str(h)+\":32@60\")##ゲームモード時の画面設定\n # glutGameModeString (\"1920x1080:32@60\")##ゲームモード時の画面設定\n glutEnterGameMode()##glutEnterGameMode\n ##glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)\n glutSwapBuffers() \n load_texture()\n glutDisplayFunc(display)#描画処理 glutMainLoop()よりも前に書く\n \n ##テクスチャを拡大・縮小する方法の指定 */\n glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)\n glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)\n \n ##glutIdleFunc(glutPostRedisplay()) \n glutKeyboardFunc(keyboard)\n \n glutMainLoop()\n \n ##インポートされた際にプログラムが動かないようにするための文\n ##http://blog.pyq.jp/entry/Python_kaiketsu_180207\n if __name__ == '__main__':\n main()\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T00:44:10.310",
"favorite_count": 0,
"id": "52222",
"last_activity_date": "2020-07-03T08:07:15.597",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "31881",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"anaconda",
"opengl"
],
"title": "Python、OpenGLで四角形のブレンドが上手くできません。",
"view_count": 302
} | [
{
"body": "問題点は再現しませんでしたが、以下の修正ではいかがでしょうか?\n\n 1. `glutSwapBuffers()` を `display()` の最後の行に移動して、他をコメントアウトします。\n 2. `ScreenShort()` 内では、 Blend を行う必要がないので、コメントアウトします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2020-01-23T08:25:35.267",
"id": "62489",
"last_acti... | 52222 | null | 62489 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "GridDB python client (version 0.8)を使用していますが,2つトラブルに見舞われました. \n両方共store.multi_putに関することです.\n\n1.引数に存在しないコンテナ名をあたえるとcore dumpしてしまう. \n2.複数回のコールでメモリー使用量の増加が見られた. memory leakか?\n\n以上よろしくお願いします.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T01:40:46.893",
"favorite_count": 0,
"id": "52224",
"last_activity_date": "2019-01-30T23:17:44.187",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31883",
"post_type": "question",
"score": 1,
"tags": [
"python",
"database"
],
"title": "GridDB :python client multi_putのトラブル",
"view_count": 80
} | [
{
"body": "先日、Troubles in multi_put function のIssueがあり \n<https://github.com/griddb/python_client/issues/12> \nで解決済みのようです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T23:17:44.187",
"id": "52436",
"last_activity_date": "2019-01-30T23:17:44.187",
... | 52224 | null | 52436 |
{
"accepted_answer_id": "52231",
"answer_count": 1,
"body": "環境 \nOS:windows7 64bit \nVisualStudio2015 C# windowsアプリ\n\n上記環境でのwindowsアプリを作成しています。 \n質問させていただいている内容は、メイン画面にテキストやボタンのコントロールが貼り付けられたものがあったとして、OCX からのイベント受信するための\nUserControl を継承したカスタムコントロールも貼り付けられてたとします。 \n動作としては、\n\n * (1)メイン画面からユーザ操作でボタン押下すると、カスタムコントロールのAPIを呼び出し、OCXの先につながっているデバイスに要求を出します。\n * (2)OCXはその要求を受信すると、何かしら処理して応答(カスタムイベント)をカスタムコントールに返します。\n * (3)デバイスからは不定期に状態通知(カスタムイベント)がカスタムコントールに送信されてきます。\n\nそこで質問なのですが、(1)実施中に(2)または(3)が実行されることは無いのでしょうか? \n.net framework の仕組みとして、同一画面(Form?)上に配置したコントールは同時に動作することはないのでしょうか?\n\n具体的には、(1)は人間が押したタイミングで、メイン画面のコンテキストでカスタムコントールのAPIを呼び出しています。この(1)実行中に、(2)または(3)のイベントがカスタムコントールに通知された場合、カスタムコントールは、(1)\n実行中でもイベント実行されることはあるのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T02:11:48.600",
"favorite_count": 0,
"id": "52228",
"last_activity_date": "2019-01-23T05:12:31.093",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13909",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"windows"
],
"title": "windows C#.net アプリにて同一画面上に張り付けたボタンコントールとOCXイベントを受信するカスタムコントールは同時に動作しないか",
"view_count": 274
} | [
{
"body": "OCX内部やアプリケーションの作りによりますが、可能性はあります。\n\nアプリケーション内のそれぞれのイベント処理の中で DoEvents\nやそれに相当する処理を行っていると、あるイベント処理の中で別のイベント処理が入れ子になって始まり、同時に実行されているように見えるはずです。これは.NETではない昔のVBでも起こっていたと思います。\n\nアプリケーションやOLEコンテナ(この場合はカスタムコントロール?)から\n[IOleControl::FreezeEvents](https://docs.microsoft.com/ja-\njp/windows/desktop/api/ocidl... | 52228 | 52231 | 52231 |
{
"accepted_answer_id": "52230",
"answer_count": 1,
"body": "長さ n の配列をソートするには、最低でもオーダーで n log n の時間計算量が必要だと聞きました。しかし [Wikipedia\nのソートの記事](https://ja.wikipedia.org/wiki/%E3%82%BD%E3%83%BC%E3%83%88)を見ると、バケットソートやバイトニックソートの平均時間計算量は\nn log n を下回っているように見えます。何故でしょうか?",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T02:54:12.133",
"favorite_count": 0,
"id": "52229",
"last_activity_date": "2019-01-23T11:40:52.197",
"last_edit_date": "2019-01-23T03:15:14.940",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"post_type": "question",
"score": 1,
"tags": [
"アルゴリズム",
"sort",
"計算量"
],
"title": "ソートに必要な最低計算量は n log n ではないのか?",
"view_count": 566
} | [
{
"body": "バケットソートやバイトニックソートが逐次の「比較ソート」ではないからです。\n\n比較ソートとは、大雑把に言うと、ランダムアクセスによる読み書きができる配列に対して、操作として要素の比較と読み書きのみが許されている状況下でのソートアルゴリズムのことです。そしてこの比較ソートを逐次に行う場合の平均時間計算量が\nΩ(n log n) になります。\n\nそれ以外の場合、Ω(n log n)\nを下回ることがあります。バケットソートは配列の要素の種類が分かっていることが前提にあるため、比較ソートではありません。バイトニックソートは並列計算を使ったアルゴリズムであり、逐次のアルゴリズムではありません。... | 52229 | 52230 | 52230 |
{
"accepted_answer_id": "52620",
"answer_count": 1,
"body": "ランダムアクセスできる配列に対してソートを行うとき、量子アルゴリズムは逐次の古典的アルゴリズムより漸近的に速くなりえますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T03:15:01.980",
"favorite_count": 0,
"id": "52232",
"last_activity_date": "2020-02-07T04:56:55.073",
"last_edit_date": "2020-02-07T04:56:55.073",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"post_type": "question",
"score": 6,
"tags": [
"アルゴリズム",
"sort",
"計算量",
"量子コンピュータ"
],
"title": "量子コンピュータによってソートは速くなりますか?",
"view_count": 766
} | [
{
"body": "比較ソートに限定した場合、長さ n の配列に対する量子アルゴリズムの時間計算量は Ω(n log n)\nになる[1]ので、漸近的には古典アルゴリズムの場合と変わりません。\n\n「比較ソート以外の場合はどうなのか?」「他に制限を課した場合はどうなるのか?」についてはよく知りません。英語版 Wikipedia の [\"Quantum\nsort\"](https://en.wikipedia.org/wiki/Quantum_sort)\nによると空間が制限されたときに量子の方が有利になる場合があるようです。\n\n* * *\n\n 1. Høyer, P., Neerbek, J., S... | 52232 | 52620 | 52620 |
{
"accepted_answer_id": "52268",
"answer_count": 2,
"body": "Pythonでpassをフックすることはできますか?\n\n```\n\n try:\n ...\n except Exception:\n pass\n \n```\n\n上のようなエラー処理をしている部分が多いコードがありエラーを握りつぶしてしまっています。 \n一つ一つ書き換えてもいいのですが、数が多く大変です。消してしまっているエラーを取得する、なにかいい方法はありますか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T03:45:22.737",
"favorite_count": 0,
"id": "52233",
"last_activity_date": "2019-01-23T19:14:19.607",
"last_edit_date": "2019-01-23T03:51:48.750",
"last_editor_user_id": "5246",
"owner_user_id": "5246",
"post_type": "question",
"score": 5,
"tags": [
"python",
"python3",
"exception"
],
"title": "pythonでpass文でつぶしてあるエラーを取得する",
"view_count": 250
} | [
{
"body": "この記事が参考になりそうです。\n\n[pythonですべての例外をキャッチし、詳細を表示させたい。](https://ja.stackoverflow.com/q/6972/26370) \n[pythonのtry,exceptを用いる際にエラーごとに処理を分ける方法](https://ja.stackoverflow.com/q/23714/26370)\n\n変更は、複数行・複数ファイルの grep,置換 が行えるエディタで一気にやってしまうとか。 \n私は秀丸エディタでやってます。\n\n* * *\n\n参照先をまとめると以下になります。\n\n> `traceback`モジュール... | 52233 | 52268 | 52268 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Chrome上で動作するようにJavaScriptで以下のような実装をし、\n\n```\n\n var lines = text.split( \"\\n\" ); \n \n```\n\n行毎に分割しようとしたところ、空白文字が消えてしまいました。 \n段落下げ、インデントは残したいのですが、どのように修正すれば空白文字、スペース、タブ記号などを正しく扱えるのでしょうか。テキストは、C言語のソースコードです。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T04:15:53.380",
"favorite_count": 0,
"id": "52234",
"last_activity_date": "2019-01-23T04:52:46.347",
"last_edit_date": "2019-01-23T04:52:46.347",
"last_editor_user_id": "23994",
"owner_user_id": "31648",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "JavaScriptで、split()を使うと、空白が消える。インデント、段落下げを残したい。",
"view_count": 247
} | [] | 52234 | null | null |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "TeraTermからsshで各サーバーに接続しており、DB (PostgreSQL)に入っている日本語データは`sjis`となりますが、毎回`set\nclient_encoding to 'sjis'`を設定しないと日本語が表示されません。\n\nこれを`set client ...`としないで、自動的に設定されてログインしたらすぐに日本語が確認できるようにしたいのですが、設定方法を教えてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T04:29:02.250",
"favorite_count": 0,
"id": "52235",
"last_activity_date": "2019-05-03T07:24:20.533",
"last_edit_date": "2019-05-03T07:24:20.533",
"last_editor_user_id": "3060",
"owner_user_id": "20350",
"post_type": "question",
"score": 0,
"tags": [
"postgresql",
"teraterm"
],
"title": "Teratermの表示をデフォルトsjisにしたい",
"view_count": 459
} | [
{
"body": "Tera Termの質問ではなく、PostgreSQLの質問ですかね。\n\n[PostgreSQL 文書 - 第\n22章多言語対応](https://www.postgresql.jp/document/9.3/html/multibyte.html)の「22.3.3.\nサーバ・クライアント間の自動文字セット変換」に解説がありますね。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T04:56:12.743",
"id": "52237... | 52235 | null | 52237 |
{
"accepted_answer_id": "52245",
"answer_count": 2,
"body": "以下のようなコードでダウンロードフォルダーにファイルを作成しています。\n\n```\n\n var newFile = await DownloadsFolder.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName);\n \n```\n\nファイル名が重複したときには自動的に別名になるので良いのですが、その前にすでにファイルが存在するかをチェックして警告表示しようと思っています。\n\nどのようにすれば DownloadsFolder でのファイル存在チェックができるのでしょうか?\n\n * ターゲット: UWP (Windows10, version 1809)\n * 開発環境: VisualStudio 2017\n\n* * *\n\n(2019-02-03 追記)\n\n## System.IO.File.Exists() を使用した方法\n\nApplicationData.Current.LocalFolder\nでは成功しますが、DownloadsFolderは権限がないようで期待した結果になりません。\n\n * DownloadsFolder のパスを取得する方法がない (CreateFileしてそのパスを得ることはできる)\n * DownloadsFolder では System.IO.File.Exists() が常に false を返す。\n * DownloadsFolder では System.IO.Directory.GetFiles() はUnauthorizedAccessException例外になる\n\nDownloadsFolder は出力に特化したものということで、直接のファイル存在チェックは難しいように思えてきました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T06:18:48.037",
"favorite_count": 0,
"id": "52241",
"last_activity_date": "2019-02-03T13:25:26.643",
"last_edit_date": "2019-02-03T11:55:33.610",
"last_editor_user_id": "14817",
"owner_user_id": "14817",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"uwp"
],
"title": "DownloadsFolder でのファイル存在チェックの方法は?",
"view_count": 436
} | [
{
"body": "`CreationCollisionOption` パラメータに `GenerateUniqueName` の代りに `FailIfExists`\nを指定してみてはどうでしょう。 \n例外が発生したら、警告で選択肢表示し、選ばれた対処を行うとか。\n\n[CreationCollisionOption Enum](https://docs.microsoft.com/en-\nus/uwp/api/windows.storage.creationcollisionoption)\n\n> Fields \n> FailIfExists 2 \n> ファイルまたはフォルダがすでに存在す... | 52241 | 52245 | 52245 |
{
"accepted_answer_id": "52255",
"answer_count": 1,
"body": "前提となる文字コードやバイナリに関しての知識が怪しいので、間違っている点を指摘してもらえるとありがたいです。\n\nまず`fs.createReadStream(,\n{encoding})`はテキストファイルを読み込む場合に使用するオプションであり、読み込んだデータを指定した文字コードの文字列に変換する機能で、default値がnullなのはバイナリファイルを読み込むことを想定したものだと認識しています。\n\n次に`fs.createWriteStream(,\n{encoding})`は書き込むのがバイナリファイルならnullを、テキストファイルなら事前に変換する文字コードを指定する機能なのだと認識しています。\n\nここで疑問なのですが、`fs.createReadStream`のそれとは違いdefault値がnullではなく\"utf8\"になっています。\n\n標準で`fs.createReadStream`はバイナリファイル、`fs.createWriteStream`はテキストファイルを扱うよう分かれているのは混乱の元だと思うのですが、何故このような仕様になっているのでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T06:56:02.667",
"favorite_count": 0,
"id": "52247",
"last_activity_date": "2019-01-23T09:20:38.260",
"last_edit_date": "2019-01-23T07:01:56.497",
"last_editor_user_id": "3060",
"owner_user_id": "19069",
"post_type": "question",
"score": 2,
"tags": [
"javascript",
"node.js"
],
"title": "fs.createReadStream, fs.createWriteStreamのencodingについて",
"view_count": 1620
} | [
{
"body": "結論としては、`fs.createReadStream`と`fs.createWriteStream`では`encoding`オプションの意味が少し違います。\n\n前提として、`fs.createReadStream`や`fs.createWriteStream`については、 **ファイル**\nがバイナリかテキストかということではなく、それによって読み書きされる **データ** がバイナリかテキストかということを考えたほうがよいです。 \nどんなファイルであっても、結局中身はバイナリデータに過ぎません。そのバイナリデータがUTF-8などの文字エンコーディングに従っている場合に我々はそれがテ... | 52247 | 52255 | 52255 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、rails環境でvue.jsでfrontendを作成しています。 \n実は、添付ファイルのようにcomponentを作成して、cars要素の有無で使用するtemplateを区別しようとしています。 \nところが、何度やってもv-elseの方に行ってしまい、v-if=\"true\"のようになりません。 \ncars要素の有無は、どのようにして判別したらよろしいでしょうか。 \nよろしくお願いします。\n\n環境は、次のとおりです。 \nOS:utunbu16.04 \nruby:2.4.2 \nrails:3.3.3 \nresque:1.27.4 \nVue.js:不明 \n[](https://i.stack.imgur.com/wukls.png)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T07:10:07.727",
"favorite_count": 0,
"id": "52248",
"last_activity_date": "2019-01-24T03:22:57.950",
"last_edit_date": "2019-01-24T03:22:57.950",
"last_editor_user_id": "3060",
"owner_user_id": "29110",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"vue.js"
],
"title": "vue.jsでtemplateで要素の有無を知りたい",
"view_count": 78
} | [] | 52248 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "opencv C++ \n輪郭線までは出せているのですが、その輪郭線を円や四角で囲む方法がわかりません\n\n```\n\n #include\"stdafx.h\"\n #include<vector>\n #include<strstream>\n \n void run()\n {\n cv::Mat image;\n \n //メインループ\n \n \n while (1) {\n //グレースケール入力\n cv::Mat src = cv::imread(\"/*任意の2値画像*/\", cv::IMREAD_GRAYSCALE);\n \n // モルフォロジー処理\n cv::Mat opening;\n cv::Mat kernel(3, 3, CV_8U, cv::Scalar(1));\n cv::morphologyEx(thresh, opening, cv::MORPH_OPEN, kernel, cv::Point(-1, -1), 2);\n //cv::imshow(\"モルフォロジー処理化\", opening);\n \n // 背景領域抽出\n cv::Mat sure_bg;\n cv::dilate(opening, sure_bg, kernel, cv::Point(-1, -1), 3);\n \n // 前景領域抽出\n cv::Mat dist_transform;\n cv::distanceTransform(opening, dist_transform, CV_DIST_L2, 5); //輪郭から距離が離れるほど濃くする\n cv::Mat sure_fg;\n double minVal, maxVal;\n cv::Point minLoc, maxLoc;\n cv::minMaxLoc(dist_transform, &minVal, &maxVal, &minLoc, &maxLoc);\n cv::threshold(dist_transform, sure_fg, 0.2*maxVal, 255, 0);\n dist_transform = dist_transform / maxVal;\n \n // 不明領域抽出\n cv::Mat unknown, sure_fg_uc1;\n sure_fg.convertTo(sure_fg_uc1, CV_8UC1);\n cv::subtract(sure_bg, sure_fg_uc1, unknown);\n \n // 前景ラベリング\n using namespace std;\n \n int compCount = 0;\n vector<vector<cv::Point> > contours;\n vector<cv::Vec4i> hierarchy;\n sure_fg.convertTo(sure_fg, CV_32SC1, 1.0);\n cv::findContours(sure_fg, contours, hierarchy, cv::RETR_CCOMP, cv::CHAIN_APPROX_SIMPLE);\n if (contours.empty()) return;\n cv::Mat markers = cv::Mat::zeros(sure_fg.rows, sure_fg.cols, CV_32SC1);\n int idx = 0;\n for (; idx >= 0; idx = hierarchy[idx][0], compCount++)\n cv::drawContours(markers, contours, idx, cv::Scalar::all(compCount + 1), -1, 8, hierarchy, INT_MAX);\n markers = markers + 1;\n \n // 不明領域は今のところゼロ\n for (int i = 0; i<markers.rows; i++) {\n for (int j = 0; j<markers.cols; j++) {\n unsigned char &v = unknown.at<unsigned char>(i, j);\n if (v == 255) {\n markers.at<int>(i, j) = 0;\n }\n \n }\n \n }\n watershed(hsv, markers);\n cv::Mat wshed(markers.size(), CV_8UC3);\n vector<cv::Vec3b> colorTab;\n for (int i = 0; i < compCount; i++)\n {\n int b = cv::theRNG().uniform(0, 255);\n int g = cv::theRNG().uniform(0, 255);\n int r = cv::theRNG().uniform(0, 255);\n colorTab.push_back(cv::Vec3b((uchar)b, (uchar)g, (uchar)r));\n }\n \n // paint the watershed image\n for (int i = 0; i < markers.rows; i++) {\n for (int j = 0; j < markers.cols; j++)\n {\n int index = markers.at<int>(i, j);\n if (index == -1)\n wshed.at<cv::Vec3b>(i, j) = cv::Vec3b(255, 255, 255);\n else if (index <= 0 || index > compCount)\n wshed.at<cv::Vec3b>(i, j) = cv::Vec3b(0, 0, 0);\n else\n wshed.at<cv::Vec3b>(i, j) = colorTab[index - 1];\n }\n }\n cv::Mat imgG;\n cvtColor(gray, imgG, cv::COLOR_GRAY2BGR);\n wshed = wshed * 0.5 + imgG * 0.5;\n }\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T08:27:35.440",
"favorite_count": 0,
"id": "52252",
"last_activity_date": "2019-01-28T13:30:09.590",
"last_edit_date": "2019-01-28T13:30:09.590",
"last_editor_user_id": "30446",
"owner_user_id": "30446",
"post_type": "question",
"score": 0,
"tags": [
"c++",
"opencv"
],
"title": "出した輪郭線を円や四角で囲みたい",
"view_count": 1028
} | [
{
"body": "[`boundingRect`関数](http://opencv.jp/opencv-2svn/cpp/structural_analysis_and_shape_descriptors.html#cv-\nboundingrect)\nで外接矩形を、[`minEnclosingCircle`関数](http://opencv.jp/opencv-2svn/cpp/structural_analysis_and_shape_descriptors.html#cv-\nminenclosingcircle) で外接円を計算できます。\n\nOpenCVチュートリアルの [Creating Boun... | 52252 | null | 52304 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "陽に y = f(x) の形で表されている関数のグラフを (x, y) 平面上に描くことを考えます。ただし x_min ≦ x ≦ x_max\nの範囲に限定してプロットするとします。\n\n素朴には、x_min から x_max まで少しずつ x を変更しながら (x, f(x)) を計算して、それらの点を線分で繋ぐとグラフが描けそうです。\n\nしかしこの方法だと特異点があるグラフに対して上手く動きません。たとえば反比例のグラフ y = 1 / x は x = 0\nにおいて定義されていません。上の素朴なアルゴリズムを Scratch で実装して動かしてみると、y 軸付近に本来は存在しない縦線が引かれてしまいます\n(緑の太線がグラフです)。\n\n[](https://i.stack.imgur.com/GnGEX.png)\n\n(以下はこのグラフを描くためのスクリプトです。クリックすると拡大します)\n\n[](https://i.stack.imgur.com/t1JfA.png)\n\n対して [WolframAlpha\nにグラフを描かせてみると](https://www.wolframalpha.com/input/?i=y%20%3D%201%20%2F%20x)、上手く特異点付近を除いてプロットしています。\n\n[](https://i.stack.imgur.com/i52vR.png)\n\n実際 [Wolfram Mathematica の機能](https://www.wolfram.com/language/11/visualization\n--labels-scales-exclusions/detect-and-remove-singular-\npoints.html?product=mathematica)を見ると、特異点を検知して除去している模様です。\n\nまた、y = 1 / x 程度であれば手計算で x = 0 が特異点と分かるので手動でそこだけ除去すれば良いのですが、y = tan(x)\nなど特異点が複数現れると面倒です。\n\n## 質問\n\n関数 f の定義式は入力として与えられるとして、y = f(x)\nのグラフをプロットするときに上手く特異点の周りをプロットしないようにするアルゴリズムはありますか?\n数値的に解析するものでも、定義式から解析するものでも構いません。必要であれば f の形を制限して構いません。個人的には y = 1 / x や y =\ntan(x) 程度が描ければ満足です。ある程度汎用性を持たせたいので、特異点を手計算して除く以外の方法が知りたいです。\n\n※書きやすかったので上では Scratch で書きましたが、アルゴリズムが知りたいだけなので他のプログラミング言語でも疑似コードでも方針だけでも構いません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T08:34:12.883",
"favorite_count": 0,
"id": "52253",
"last_activity_date": "2019-03-27T14:23:39.197",
"last_edit_date": "2019-01-23T08:43:27.660",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"post_type": "question",
"score": 1,
"tags": [
"アルゴリズム"
],
"title": "関数のグラフをプロットする際に、特異点の周辺を取り除く方法",
"view_count": 331
} | [
{
"body": "描画するときに、1つ前のステップのf(x)の値を持っておき、前ステップとのf(x)の差の絶対値が一定値以上になったら線で結ばないようにしたらどうでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-03-27T14:23:39.197",
"id": "53769",
"last_activity_date": "2019-03-27T14:23:39.197",
"last_edit_date": null,
"last... | 52253 | null | 53769 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "unityのshaderをいろいろ学んでいるのですが、相談できる方もいなく、そして悪戦苦闘しており、ここに投稿させて頂きましたm(_ _)m\n\n■質問 \nシェーダーにて、ノイズ系のtexture情報を取得→そこからvertexを操作する方法を知りたいです、\n\nというのも、下記記事のように、ノイズ系のtextureをはりつけて、明度の違いからplaneを凹凸したくて…\n\nこの記事にあるhader graphでの作り方は理解できるのですが、pgだけだったらどう表現するのか1日かけてggってもわからず… \n<https://marunouchi-tech.i-studio.co.jp/5289/>\n\n誰かご教授いただけると本当に嬉しいですm(_ _)m",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T09:44:49.177",
"favorite_count": 0,
"id": "52257",
"last_activity_date": "2019-01-23T09:49:57.730",
"last_edit_date": "2019-01-23T09:49:57.730",
"last_editor_user_id": "19110",
"owner_user_id": "31891",
"post_type": "question",
"score": 0,
"tags": [
"unity3d"
],
"title": "シェーダーのtexture情報から頂点を動かす方法について",
"view_count": 39
} | [] | 52257 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "unity初学者です。\n\nunityのshaderをいろいろ学んでいるのですが、相談できる方もいなく、そして悪戦苦闘しており、ここに投稿させて頂きましたm(_ _)m\n\n公式のこちらの記事にあるサンプルをインストールして色々いじったのですが、3Dモデルに対し、シェーダーだけで完全に色分けできていて、衝撃を受けました \n(例えば、宝箱、枠は銀、鍵は金、他は面は木の色) \n<https://blogs.unity3d.com/jp/2018/10/05/art-that-moves-creating-animated-\nmaterials-with-shader-graph/>\n\nさらに、このシェーダーを使いまわし、木でできているモノや鍵などにもアタッチし、更には色分けもできています\n\nシェーダーをみてみても、トリガーがない、おそらく頂点カラーをとっているわけでもなさそうで、どのような原理で色分けされているか全くわからず、悶々としています\n\nこちら詳しい方がいらっしゃれば是非ともご教授いただきたいです。 \nお手数おかけしますが、何卒宜しくお願いいたしますm(_ _)m",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T10:32:51.593",
"favorite_count": 0,
"id": "52259",
"last_activity_date": "2019-01-25T03:24:57.423",
"last_edit_date": "2019-01-25T03:24:57.423",
"last_editor_user_id": "19110",
"owner_user_id": "31891",
"post_type": "question",
"score": 2,
"tags": [
"unity3d"
],
"title": "シェーダーだけでモデリングの色分けをする方法",
"view_count": 240
} | [
{
"body": "Unityが利用する3Dグラフィックエンジン(OpenGLやDirectX)のフラグメントシェーダは、本来論でいえばテクスチャの「表示色」を計算する機構です。ですので、シェーダから物体色を任意に変えられることは特段珍しい話ではありません。\n\nフラグメントシェーダはシェーディング言語という特殊なプログラミング言語で記述する必要がありますが、Unityのシェーダーグラフはこれを視覚的・インタラクティブに記述できる機能のようです。図(グラフ)を見る限りでは「[Splitノード](https://github.com/Unity-\nTechnologies/ShaderGraph/wiki/Spl... | 52259 | null | 52301 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Visual Studio\nのコードレンズではそのメソッド(等)への参照の数、および参照しているテストの数と結果が表示されます。しかし、テストコードで一度別の関数を呼び、さらにその関数の中で目的のコードを使用した場合、そのテストの結果は表示されません。 \nこれを解決する方法はあるのでしょうか。\n\n```\n\n public class App {\n // 全てのテストが成功したことが表示される\n public static int Add(int lhs, int rhs) {\n return lhs + rhs;\n }\n \n // テスト結果が表示されない\n public static int Sub(int lhs, int rhs) {\n return lhs - rhs;\n }\n }\n \n [TestClass]\n public class Tests {\n \n [TestMethod]\n void Test01(){\n Assert.AreEqual(3, App.Add(1,2));\n }\n \n [TestMethod]\n void Test02(){\n var domain = new TestDomain {\n Lhs = 1,\n Rhs = 2,\n Result = 3\n };\n domain.Run();\n }\n \n }\n \n class TestDomain {\n public int Lhs { get; set; }\n public int Rhs { get; set; }\n public int Result { get; set; }\n \n public void Run(){\n Assert.AreEqual(Result, App.Sub(Lhs, Rhs));\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T13:57:47.730",
"favorite_count": 0,
"id": "52263",
"last_activity_date": "2019-01-23T13:57:47.730",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20885",
"post_type": "question",
"score": 4,
"tags": [
"c#",
"visual-studio",
"テスト"
],
"title": "Visual Studio のコードレンズに間接的なテストからの参照を認識させる方法",
"view_count": 94
} | [] | 52263 | null | null |
{
"accepted_answer_id": "52272",
"answer_count": 1,
"body": "現在のcabalが提供するサブコマンドに new-* と v2-*\nというプレフィックスがついたものがあります。手元で試した限りでは同じ動作をするように見えますが、これらは同じものを指していますか? \nまたこれらが正式なサブコマンドになる(プレフィックスが外れる)予定はありますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T14:37:45.173",
"favorite_count": 0,
"id": "52264",
"last_activity_date": "2019-01-23T22:33:04.613",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8761",
"post_type": "question",
"score": 1,
"tags": [
"haskell"
],
"title": "cabalのサブコマンドのnew-*とv2-*は同じものを指していますか",
"view_count": 54
} | [
{
"body": "[cabalのドキュメントの該当するセクション](https://www.haskell.org/cabal/users-guide/nix-local-\nbuild-overview.html)の冒頭に書いてありました。\n\n> 手元で試した限りでは同じ動作をするように見えますが、これらは同じものを指していますか?\n\n下記の一節にありました。スクリプトやドキュメントではこちらを使った方がいいのかも知れません。\n\n> (前略)... there are also v2- prefixed versions that will reference the same\n> functio... | 52264 | 52272 | 52272 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "angular7 を使って blog サイトを作成しています。 \nいろんなコンポーネントを使ってブログの部品を作ってまして、最終的にブログを作成ってやった時の書き出すデータについてお聞きします。\n\n一つはHTMLとして書き出してそのHTMLを保存するやり方と、もう一つはブログを作成するjsonデータを保存するやり方です。\n\nHTML自体をデータとして保存した場合は、ページを見るときは innerHtml\nで表示すれば簡単かなと思っていまして、jsonデータをデータとした場合はcomponentから画面を生成して表示させる方法と2種類\n実現方法があるかと思っているのですが、 書き出したブログページは どちらで持たせた方が良いでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T16:17:39.120",
"favorite_count": 0,
"id": "52265",
"last_activity_date": "2020-10-08T12:02:20.340",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15499",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"angular6"
],
"title": "Angularでブログサイトを作っています。作成したブログページのデータの持たせ方について質問です。",
"view_count": 269
} | [
{
"body": "angularをご使用でしたらjson一択でしょう \nhtmlで持たした場合より保守が容易となるはずです",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-27T14:58:00.437",
"id": "52356",
"last_activity_date": "2019-01-27T14:58:00.437",
"last_edit_date": null,
"last_editor_user_id": null,
... | 52265 | null | 52356 |
{
"accepted_answer_id": "52953",
"answer_count": 1,
"body": "環境変数などを設定し、Powershellを普通に開いて「java -version」などを実行すると正常に動くのですが、「Powershell\nウインドウをここに開く」からPowershellを実行した場合、以下のようなエラーが出て実行できません。\n\n```\n\n Error: opening registry key 'Software\\JavaSoft\\Java Runtime Environment'\n Error: could not find java.dll\n Error: Could not find Java SE Runtime Environment.\n \n```\n\n原因はわからないでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T20:54:47.163",
"favorite_count": 0,
"id": "52269",
"last_activity_date": "2019-02-22T21:51:43.477",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "816",
"post_type": "question",
"score": 1,
"tags": [
"java",
"powershell"
],
"title": "「Powershell ウインドウをここに開く」からPowershellを実行した場合、javaコマンドが使えない",
"view_count": 191
} | [
{
"body": "回答が形式上存在しない状態になってるので転載します。 \npayanecoさんより: \n「Powershell ウインドウをここに開く」時はエクスプローラを全て閉じないと環境変数が反映されません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-22T21:51:43.477",
"id": "52953",
"last_activity_date": "2019-02-22T21:51:43.477",
"last_edit... | 52269 | 52953 | 52953 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "## 発生している問題・エラーメッセージ\n\nRails4 で DB に json のカラムを追加しようと考えています。しかし、 `bundle exec rake db:migrate`\nを実行しようとすると、エラーが出てしまい、それ以降進まなくなっています。\n\nもし、わかる方がいらしたら、嬉しいです。\n\n```\n\n == 20190123214656 AddPlansToImages: migrating =================================\n -- add_column(:images, :plans, :json)\n rake aborted!\n StandardError: An error has occurred, all later migrations canceled:\n \n Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'json' at line 1: ALTER TABLE `images` ADD `plans` json\n /Users/hiroshi/Desktop/sunny/db/migrate/20190123214656_add_plans_to_images.rb:3:in `change'\n \n Caused by:\n ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'json' at line 1: ALTER TABLE `images` ADD `plans` json\n /Users/hiroshi/Desktop/sunny/db/migrate/20190123214656_add_plans_to_images.rb:3:in `change'\n \n Caused by:\n Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'json' at line 1\n /Users/hiroshi/Desktop/sunny/db/migrate/20190123214656_add_plans_to_images.rb:3:in `change'\n Tasks: TOP => db:migrate\n (See full trace by running task with --trace)\n \n```\n\n* * *\n\n## 該当のソースコード\n\n### コンソール\n\n```\n\n $ rails generate migration AddPlansToImages plans:json\n \n rake db:migrate\n \n```\n\n### Gemfile\n\n```\n\n source 'https://rubygems.org'\n \n # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\n gem 'rails', '4.2.8'\n # Use mysql as the database for Active Record\n gem 'mysql2', '0.3.18'\n # Use SCSS for stylesheets\n gem 'sass-rails', '~> 4.0.2'\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.1.0'\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 following links in your web application faster. Read more: https://github.com/rails/turbolinks\n gem 'turbolinks'\n # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\n gem 'jbuilder', '~> 2.0'\n # bundle exec rake doc:rails generates the API under doc/api.\n gem 'sdoc', '~> 0.4.0', group: :doc\n \n # Use ActiveModel has_secure_password\n # gem 'bcrypt', '~> 3.1.7'\n \n # Use Unicorn as the app server\n # gem 'unicorn'\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'\n end\n \n group :development do\n # Access an IRB console on exception pages or by using <%= console %> in views\n gem 'web-console', '~> 2.0'\n \n # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n gem 'spring'\n end\n \n gem 'pry-rails'\n gem 'compass-rails','~> 2.0'\n gem 'sprockets', '2.11.0'\n #pagenation\n gem 'kaminari'\n #login_logout\n gem 'devise'\n gem 'paperclip'\n \n #chat\n gem 'websocket-rails'\n gem 'faye-websocket', '0.10.0'\n #image\n gem 'carrierwave'\n gem 'rmagick'\n #date\n gem 'momentjs-rails'\n gem 'bootstrap3-datetimepicker-rails'\n \n```\n\n### `db/migrate`\n\n```\n\n class AddPlansToImages < ActiveRecord::Migration\n def change\n add_column :images, :plans, :json\n end\n end\n \n```\n\n* * *\n\n## 補足情報 (OS, ツールのバージョンなど)\n\n * MySQL のバージョン \nmysql Ver 14.14 Distrib 5.7.19, for osx10.12 (x86_64) using EditLine wrapper",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-23T22:04:00.230",
"favorite_count": 0,
"id": "52271",
"last_activity_date": "2019-05-05T06:57:39.990",
"last_edit_date": "2019-05-05T06:57:39.990",
"last_editor_user_id": "32986",
"owner_user_id": "30829",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"mysql"
],
"title": "Rails4でDBにjsonのカラムを追加することができない",
"view_count": 189
} | [] | 52271 | null | null |
{
"accepted_answer_id": "52313",
"answer_count": 1,
"body": "SpamFilterプロジェクト(\n<https://github.com/lamrongol/JapaneseTwitterSpamFilter/blob/master/src/main/scala/lamrongol/twitter/spamfilter/SimpleSpamFilter.scala>\n)で`sbt assembly`を実行すると成功しjarファイルができるのですが、それを以下のようなコマンドで実行すると、\n\n```\n\n java -cp .\\SpamFilter-assembly-1.0.jar lamrongol.twitter.spamfilter.SimpleSpamFilter\n \n```\n\n以下のようなエラーが出て正常に動作しません。\n\n```\n\n Exception in thread \"main\" java.lang.ExceptionInInitializerError\n at lamrongol.twitter.spamfilter.SimpleSpamFilter.main(SimpleSpamFilter.scala)\n Caused by: java.nio.charset.MalformedInputException: Input length = 1\n at java.nio.charset.CoderResult.throwException(CoderResult.java:281)\n at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)\n at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)\n at java.io.InputStreamReader.read(InputStreamReader.java:184)\n at java.io.BufferedReader.fill(BufferedReader.java:161)\n at java.io.BufferedReader.readLine(BufferedReader.java:324)\n at java.io.BufferedReader.readLine(BufferedReader.java:389)\n at scala.io.BufferedSource$BufferedLineIterator.hasNext(BufferedSource.scala:72)\n at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:413)\n at scala.collection.Iterator$class.foreach(Iterator.scala:742)\n at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)\n at lamrongol.twitter.spamfilter.SimpleSpamFilter$.loadResource(SimpleSpamFilter.scala:64)\n at lamrongol.twitter.spamfilter.SimpleSpamFilter$.<init>(SimpleSpamFilter.scala:16)\n at lamrongol.twitter.spamfilter.SimpleSpamFilter$.<clinit>(SimpleSpamFilter.scala)\n ... 1 more\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T00:31:48.597",
"favorite_count": 0,
"id": "52273",
"last_activity_date": "2019-01-26T06:13:51.837",
"last_edit_date": "2019-01-24T23:59:34.200",
"last_editor_user_id": "816",
"owner_user_id": "816",
"post_type": "question",
"score": 0,
"tags": [
"scala",
"sbt"
],
"title": "sbt assemblyは成功するのに実行するとExceptionInInitializerErrorが出る",
"view_count": 262
} | [
{
"body": "調べたところExceptionInInitializerErrorが出るのはclass(object)の初期化に失敗したときであり、今回はjarではjava.nio.charset.MalformedInputExceptionが起きてしまうことが原因だとわかりました。\n\n`scala.io.Source.fromInputStream(stream)`を`scala.io.Source.fromInputStream(stream,\n\"UTF-8\")`と文字コードを追加することで解決しました。",
"comment_count": 0,
"content_licens... | 52273 | 52313 | 52313 |
{
"accepted_answer_id": "52520",
"answer_count": 1,
"body": "Sony SpresenseでMbed OSを動かすことはできますか? \nまた、今後開発ツールとしてMbedに対応するようなことはありますでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T02:05:55.860",
"favorite_count": 0,
"id": "52275",
"last_activity_date": "2019-02-04T01:49:17.593",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31894",
"post_type": "question",
"score": 0,
"tags": [
"spresense"
],
"title": "Sony Spresenseでmbed OSを動かすことはできますか?",
"view_count": 318
} | [
{
"body": "ソニーのSPRESENSEサポート担当です。 \nお問い合わせの件について、回答させていただきます。\n\n残念ながら、mbedOS 対応は今のところは予定がありません。 \n市場の状況を見ながら、今後判断をさせていただきたいと思っています。\n\n今後ともSpresenseをどうぞよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-04T01:49:17.593",
"id": "52520",
"last_act... | 52275 | 52520 | 52520 |
{
"accepted_answer_id": "52279",
"answer_count": 1,
"body": "**mb_send_mailでFromメールヘッダを追加してYahoo!メールへメール送信** \nYahoo!メールで見ると、なりすましメールの可能性があります、と表示されました\n\n・Q1.Fromメールヘッダを追加して、なりすましメールの可能性があります、と表示させないためには、どうすればよいですか?\n\n・Q2.そもそも、Fromメールヘッダは、どういう用途で使用するものですか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T02:34:39.960",
"favorite_count": 0,
"id": "52276",
"last_activity_date": "2019-02-27T17:37:24.637",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7886",
"post_type": "question",
"score": 0,
"tags": [
"php",
"postfix"
],
"title": "mb_send_mailでFromメールヘッダを追加すると、なりすましメールの可能性があります、と表示されてしまう",
"view_count": 434
} | [
{
"body": "Fromヘッダはメーラーでメールを開いた際に「差出人」や「送信元」として表示されるヘッダです。\n\nデスクトップクライアントでもwebメールサービスでも大抵は変更できるようになっていて、なぜ変更できるかというと、 \n「普段とは別の環境からメールを送信するけど、相手先にはいつもと同じアドレスを表示したい/返事はいつものアドレスにもらいたい」場合があるからです。\n\nLinuxのcrontabなどからメールを送ると、デフォルトでは「実行ユーザ@実行ホスト」になりますが、From欄を「普段人間が使っているアドレス」に設定しておくとお互いに便利です。\n\nまた、一部のwebメールサービスでは外... | 52276 | 52279 | 52279 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "スクレイピングを行う範囲を指定したいなと思っています。 \n私が考えているのは、findなどを用いて部分的にlxmlを切り取ってから、それでまたスープを作るみたいなあやふやなビジョンしか今のところ考えつかずにいます。\n\n```\n\n <div id=\"foo\">\n <a href=\"*1\">\n <img src=\"*1.jpg\" class=\"bar\"/>\n </a> \n <a href=\"*2\">\n <img src=\"*2.jpg\" class=\"bar\"/>\n </a> \n <a href=\"*3\">\n <img src=\"*3.jpg\" class=\"bar\"/>\n </a> \n </div>\n \n <img src=\"*4.jpg\" class=\"bar\"/>\n \n```\n\nHTMLの一部にこのようなレイヤーが存在するとして、そのレイヤーに含まれる画像(*1.jpg, *2.jpg, *3.jpg)のURLのみ取得したい。 \nしかし、このときレイヤー外にもclassが”bar\"に相当する画像もある。\n\nどのような解決策を講じることが私に可能でしょうか?\n\nなお、環境は \nPython 3.6.2 \nスクレイピングには \nBeautifulSoup4を利用し、現状Seleniumなどの導入を控えたいと思っています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T06:12:15.173",
"favorite_count": 0,
"id": "52280",
"last_activity_date": "2019-01-24T06:28:33.207",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "16877",
"post_type": "question",
"score": 0,
"tags": [
"python",
"html",
"web-scraping",
"beautifulsoup"
],
"title": "指定したレイヤーのみを範囲にスクレイピング",
"view_count": 546
} | [
{
"body": "`#foo > .bar` というように、子セレクタを利用することで `foo`というidの小要素だけを指定して取得することができます。 \n[子結合子 | MDN](https://developer.mozilla.org/ja/docs/Web/CSS/Child_combinator)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T06:28:33.207",
"id": "52281",
"last_activity_d... | 52280 | null | 52281 |
{
"accepted_answer_id": "52289",
"answer_count": 1,
"body": "markt_train_dfというデータフレームを扱っています。データ型は以下の通りとなっております。 \n今、一番上の”time\"という列のデータ型をobjectからdatetime64[ns,\nUTC]に変更しなければならないのですが、どのようにすれば\"time\"のデータ型のみを変更したdataframeを取得できるでしょうか。 \n初歩的な質問で大変恐縮ですがご教授いただきましたら幸いです。 \nどうぞよろしくお願い申し上げます。\n\n[](https://i.stack.imgur.com/WYSIa.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T09:50:25.653",
"favorite_count": 0,
"id": "52284",
"last_activity_date": "2019-01-24T11:25:46.910",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27030",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pandas"
],
"title": "object型の列をdatetime64型へ変換したい",
"view_count": 1222
} | [
{
"body": "**time列** にどのような形式のデータが入っているかにもよりますが、 \n通常であれば\n\n```\n\n market_train_df['time'] = pd.to_datetime(market_train_df['time'])\n \n```\n\nで変換できるかと思います\n\n一応サンプル\n\n```\n\n import pandas as pd\n df = pd.DataFrame({'time':['2019/01/24 18:00',\n '2019/01/24 19:00:... | 52284 | 52289 | 52289 |
{
"accepted_answer_id": "52288",
"answer_count": 1,
"body": "フォームタグの中にある`action=\"\"`とはどういう意味でしょうか? \n普段はここにURLやファイル名を入れていたのですが、例で`””`という記載を見つけて・・・。 \n検索しても見つけられなかったのでよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T10:59:50.950",
"favorite_count": 0,
"id": "52287",
"last_activity_date": "2019-01-24T11:23:17.337",
"last_edit_date": "2019-01-24T11:23:17.337",
"last_editor_user_id": "3060",
"owner_user_id": "31799",
"post_type": "question",
"score": 0,
"tags": [
"php",
"html"
],
"title": "action=\"\"とは",
"view_count": 101
} | [
{
"body": "通常は「フォームデータの送り先」を`action=`でURL(またはファイル名)を指定しますが、質問のように空欄になっているものは **自分自身**\n(=今現在表示しているページ)にデータを送る場合だと思います。\n\nよくあるフォームタグの使い方としては、FORMタグはHTMLページに記載してあり、データの送り先はPHPなどのプログラムに処理させる方法です。 \nここでPHP自身にFORMタグを記載してしまえば、自分自身を呼び出して表示を更新することができるはずです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.... | 52287 | 52288 | 52288 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "PythonでWebSocketサーバーを動かしているのですが、クライアントとの接続の確立がうまくいきません。\n\nクライアント(Google Chrome)からWebSocketで受け取ったデータをノンブロッキングなUDPを使って他のアドレスへ転送したいです。\n\nただ、WebSocketのサーバーとクライアント間の接続がうまくいっていないようで、Chromeを見ると\n\n```\n\n WebSocket connection to wss://localhost:4246/ failed: Error in connection establishment: net::ERR_SOCKET_NOT_CONNECTED\n \n```\n\nというエラーが発生しています。\n\nなぜ、接続がうまくいかないのでしょうか?\n\nサーバーは下記のようになっていて、データを受信するとhandleMessageが呼ばれてデータの内容がprintで表示された後、udpで送るようになっています。\n\nChromeは`-allow-insecure-localhost`が有効になっています。\n\nこのコードは[simple-websocket-server](https://github.com/dpallot/simple-websocket-\nserver) \nを使っています。\n\n```\n\n from SimpleWebSocketServer import WebSocket, SimpleSSLWebSocketServer, SimpleWebSocketServer\n import multiprocessing\n \n import ssl\n import signal\n import sys\n import socket\n import os.path\n \n \n \n class DataWebSocket(WebSocket):\n def __init__(self, server, sock, address, tcp_sock):\n super().__init__(server, sock, address)\n self.udp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n self.udp_sock.setblocking(False)\n self.udp_sock.bind((\"127.0.0.1\", 6666))\n def handleMessage(self):\n while True:\n self.udp_sock.sendto((\"127.0.0.1\", 7774), self.data)\n print(self.data)\n \n def handleClose(self):\n print(\"connection: closed \" + self.address)\n self.conn_sock.close()\n self.sendMessage(\"server exit\")\n sys.exit()\n \n def handleConnected(self):\n pass\n \n def f():\n def datawebsocketclasscaller(server, sock, address):\n return DataWebSocket(server, sock, address)\n return datasocketclasscaller\n \n def start_data_receiver():\n SSL = True\n p = f()\n if SSL:\n server = SimpleSSLWebSocketServer(\"127.0.0.1\", 4246, p, \"../certs/server.crt\", \"../certs/server.key\")\n else:\n server = SimpleWebSocketServer(\"127.0.0.1\", 4246, p)\n server.serveforever()\n \n```\n\nクライアント(Google Chrome):\n\n```\n\n const ws = new WebSocket(\"wss://localhost:4246\");\n const btn = document.querySelectorAll(\"button#btn1\")[0];\n btn.onclick = () => ws.send(\"Hello from button1\");\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T13:21:01.683",
"favorite_count": 0,
"id": "52293",
"last_activity_date": "2019-01-24T15:05:29.153",
"last_edit_date": "2019-01-24T15:05:29.153",
"last_editor_user_id": "5246",
"owner_user_id": "5246",
"post_type": "question",
"score": 0,
"tags": [
"python",
"javascript",
"python3",
"websocket",
"udp"
],
"title": "PythonでWebSocketサーバーへの接続が失敗する",
"view_count": 1508
} | [] | 52293 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "普通StoryboardからDragAndDropすると引数(sender: Any)ができてしまう。 \nこれを消して引数なしのfuncにしたい。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24T14:58:57.837",
"favorite_count": 0,
"id": "52295",
"last_activity_date": "2019-01-24T15:00:47.693",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "427",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"xcode",
"storyboard"
],
"title": "UIBarButtonItemのactionを引数無しにする方法",
"view_count": 83
} | [
{
"body": "先に引数なしのfuncをコーディングすれば可能\n\n 1. コードを書く\n\n```\n\n @IBAction func onXxxBarButtonDidTouch() {\n print(\"XxxBarButtonDidTouch!!\")\n }\n \n```\n\n 2. コードからStoryboardのUIBarButtonへと、outletの線を引く",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-24... | 52295 | null | 52296 |
{
"accepted_answer_id": "53150",
"answer_count": 1,
"body": "**DNS設定で、メール送受信する際、メールアドレスのドメイン指定したいのですが、 \n下記の違いを知りたい(何れが合っているか、それとも何れも間違っているか)**\n\n・2つある理由は、ドメインを違う所から取得していて、それぞれのフォーマットに沿って良くわからないまま入力した結果こうなっています\n\n* * *\n\n**現状1.example.com** \n・Aレコードを2つ書いた理由は、「MX指定する際予めAレコード指定が必要」とエラー表示されたため \n・Aレコード指定する際「*.example.com A」と「example.com A」は同じ意味ですか? \n・3600はデフォルト値で入力されていたので、そのままにしています \n・メールサーバのドメインを「mail.example.com」にしようと思っているのですが、ここは何でも良いですか?\n\n```\n\n *.example.com A 3600 IPアドレス \n mail.example.com A 3600 IPアドレス\n example.com MX 3600 mail.example.com /10\n example.com TXT 3600 v=spf1 include:mail.example.com ~all\n \n```\n\n* * *\n\n**現状2.example.net** \n・この書き方だと、メールアドレスのドメイン指定は出来ていない? \n・mxの10の書き方が、「現状1」と異なるのですが、「@ 10」と「/10」では何が違うのですか? \n・txtの @にはどんな意味がありますか・\n\n```\n\n example.net * IPアドレス\n mx @ 10\n txt @ v=spf1 example.net:0m ~all\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T00:00:07.740",
"favorite_count": 0,
"id": "52297",
"last_activity_date": "2019-06-21T17:02:05.197",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7886",
"post_type": "question",
"score": 0,
"tags": [
"dns",
"postfix"
],
"title": "DNS設定。メール送受信する際、メールアドレスのドメイン指定したい",
"view_count": 169
} | [
{
"body": "# example.com\n\n> ・Aレコード指定する際「*.example.com A」と「example.com A」は同じ意味ですか?\n\nおそらく違います。`*.example.com`は(他に明示的なレコードが無い限り)`任意の名前.example.com`にマッチします。`example.com`は`example.com`自体への指定だと思います。\n\n> メールサーバのドメインを「mail.example.com」にしようと思っているのですが、ここは何でも良いですか?\n\n好きに決めればよいです。\n\n> `example.com TXT 3600 v=spf1 in... | 52297 | 53150 | 53150 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "SPRESENSEにイメージセンサを接続し、撮影した画像をできればopencvを使って操作したいと考えておりますが、opencvをnuttxへ組み込んで動かすことは可能でしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T00:39:08.077",
"favorite_count": 0,
"id": "52298",
"last_activity_date": "2020-03-25T12:01:30.167",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31911",
"post_type": "question",
"score": 1,
"tags": [
"opencv",
"spresense"
],
"title": "SPRESENSEでの画像操作",
"view_count": 625
} | [
{
"body": "ソニーのSPRESENSEサポート担当です。 \nお問い合わせの件について、回答させていただきます。\n\nご存知だとは思いますが、OpenCV はかなり高度な機能が備わった Computer Vision 用ライブラリで、GPU\nなど多くの計算資源があることを前提したものとなっています。 \nSPRESENSE の計算能力をもってしても、OpenCV が規定している全ての機能をカバーすることはできません。 \nSPRESENSE では、NuttX Graphics Library を利用できますが、機能が十分とは言えませんので、今後拡充をしていく予定です。\n\n今後ともSpresen... | 52298 | null | 52521 |
{
"accepted_answer_id": "52334",
"answer_count": 1,
"body": "herokuを使って自作のアプリケーションをデプロイする際、作業リポジトリ(local)には自身のgitリポジトリと heroku のgit\nリポジトリの2つのリモートリポジトリが紐付けられており、同じ内容でpushすることは、現段階で可能なのですが、異なる内容(remote heroku\nのほうはすべてpushしたいが、remote originにはいくつかのファイルはpushしたくない)のpushを実現する方法はないのでしょうか. \n現在は内容の同じ2つのlocalリポジトリを作成し、それぞれにorigin,herokuのremote repo を紐づけて一時的に対応しています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T02:13:15.353",
"favorite_count": 0,
"id": "52302",
"last_activity_date": "2019-01-26T17:11:59.020",
"last_edit_date": "2019-01-26T17:11:59.020",
"last_editor_user_id": "31916",
"owner_user_id": "31916",
"post_type": "question",
"score": 0,
"tags": [
"git"
],
"title": ".gitignoreファイルをremote repoごとに設定したい",
"view_count": 547
} | [
{
"body": "複数のリモートリポジトリで除外したいファイルがあるということは、 \nそれぞれのリモートリポジトリにそれぞれのブランチがあるはずです。 \nそれぞれのブランチで、.gitignoreを管理する事により、実現できるはずです。\n\nたとえば、branch_aの.gitignoreでは\n\n```\n\n file_1\n dir/file_2\n \n```\n\nbranch_bの.gitignoreでは\n\n```\n\n file_1\n dir/file_2\n dir/file_3\n \n```\n\nなど",
"comment... | 52302 | 52334 | 52334 |
{
"accepted_answer_id": "52322",
"answer_count": 1,
"body": "以下のmain_nunchuck.pyを実行しました。`sudo python3 main_nunchuck.py`\n\n```\n\n from ..import_directory.Nunchuck.RaspberryPi import nunchuck\n from ..import_directory.python_sdk.milkcocoa import milkcocoa\n \n```\n\nすると、以下のエラーが発生しました。\n\n```\n\n Traceback (most recent call last):\n File \"main_nunchuck.py\", line 1,in <module>\n from ..import_directory.Nunchuck.RaspberryPi import nunchuck\n SystemError: Parent module '' not loaded, cannot perform relative import\n \n```\n\nファイル構造は以下の様にしています。\n\n```\n\n └─/pi\n └─/nunchuck_control\n │ main_nunchuck.py\n │\n └─/import_directory\n │ \n │\n ├─/Nunchuck\n │ |\n │ |__/RaspberryPi\n │ nunchuck.py\n |\n ├─/python_sdk\n |\n |\n ├─/milkcocoa\n | | milkcocoa.py\n | __int__.py\n |\n ├─/paho\n |\n ├─/mqtt\n \n```\n\nどのようにしてpythonのimportをすれば良いのでしょうか。 \nよろしくお願いします。\n\n========追伸1========== \n`__int__.py`を以下のように各フォルダに挿入しました。\n\n```\n\n └─/pi\n └─/nunchuck_control\n │ main_nunchuck.py\n │\n └─/import_directory\n │ __int__.py\n │\n ├─/Nunchuck\n │ | __int__.py\n | |\n │ ├─/RaspberryPi\n | | __int__.py\n │ nunchuck.py\n |\n ├─/python_sdk\n | __int__.py\n |\n ├─/milkcocoa\n | | milkcocoa.py\n | __int__.py\n |\n ├─/paho\n | __int__.py\n |\n ├─/mqtt\n | __int__.py\n client.py\n \n```\n\nそして、`main_nunchuck.py`を実行しました。\n\n```\n\n from import_directory.Nunchuck.RaspberryPi import nunchuck\n from import_directory.python_sdk.milkcocoa import milkcocoa as milkcocoa\n \n```\n\nmtb_beta様にお答え頂いたように`nunchuck.py`のimport\nerrorは発生しませんでした。ありがとうございます。ただ、`client.py`のimport errorが発生しました。\n\n```\n\n Traceback (most recent call last):\n File \"main_nunchuck.py\", line 2,in <module>\n from import_directory.python_sdk.milkcocoa import milkcocoa as milkcocoa\n File \"/home/pi/nunchuck_control/import_directory/python_sdk/milkcocoa/milkcocoa.py\", line 6, in <module>\n from paho.mqtt import client as mqtt\n ImportError:No module named 'paho'\n \n```\n\nと表示されました。度々、すみません。協力頂ければ幸いです。\n\n=====追伸2====== \n自己解決しました。`milkcocoa.py`の6行目を以下のように変更するとうまく行きました。\n\n```\n\n from import_directory.python_sdk.milkcocoa.paho.mqtt import client as mqtt\n \n```\n\n理由は分かりませんが、なんとなく絶対PATHを入力するとうまく動きました。なぜ、相対PATHではうまくいかず、絶対PATHではうまく動くのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T04:45:30.777",
"favorite_count": 0,
"id": "52305",
"last_activity_date": "2019-01-29T04:11:47.470",
"last_edit_date": "2019-01-29T04:11:47.470",
"last_editor_user_id": "26270",
"owner_user_id": "26270",
"post_type": "question",
"score": 1,
"tags": [
"python"
],
"title": "python 3.5.3のimportエラーについて",
"view_count": 492
} | [
{
"body": "まず、Pythonではパッケージとなるディレクトリには `__init__.py` が必要です。 \n[こちら](https://docs.python.jp/3/reference/import.html?highlight=%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8#regular-\npackages)が公式ドキュメントです。\n\n次のようなファイルは必要かと思いますので用意しましょう。 `__init__.py` はファイルがあれば良いので、中身は空で大丈夫です。\n\n`import_directory/__init__.py` \... | 52305 | 52322 | 52322 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "初歩的な質問で申し訳ございません。Land of\nLispを読みLispを学習しようと思ったのですが、CLISPを公式サイト(<http://clisp.cons.org>)\nからインストールしなさいと書かれており、やろうとしたのですがわからないです。なにをどうすればわからない状態なので詳しく教えていただけなでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T05:14:47.380",
"favorite_count": 0,
"id": "52307",
"last_activity_date": "2019-01-25T06:50:37.407",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31918",
"post_type": "question",
"score": 1,
"tags": [
"lisp"
],
"title": "common Lispをmacにインストールし開発する方法について",
"view_count": 766
} | [
{
"body": "複数の方法があります。\n\n## A. パッケージマネジャーを使う\n\nソフトウェアを簡単にインストールできるように、それぞれのソフトウェアをひとつのパッケージにまとめ、パッケージごとに管理できるようにする仕組みが[パッケージマネジャー](https://ja.wikipedia.org/wiki/%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E7%AE%A1%E7%90%86%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0)です。まずはパッケージマネジャーをインストールし、その後パッケージマネジャーからパッケージをインス... | 52307 | null | 52310 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "雑記ブログなのでクローラーにカテゴリーを伝えたいです。 \n自分で調べて下記のように認識したのですが正しいか教えていただければ幸いです。\n\nマイクロデータで行う方法を見つけたので、こちらで実装したいです。\n\n私のサイトの例 \n<http://example.com/index.html> \n[http://example.com/html/SEOクイズ1.html](http://example.com/html/SEO%E3%82%AF%E3%82%A4%E3%82%BA1.html)(1から10まで、ページがある) \n[http://example.com/html/アフィリエイトクイズ1.html](http://example.com/html/%E3%82%A2%E3%83%95%E3%82%A3%E3%83%AA%E3%82%A8%E3%82%A4%E3%83%88%E3%82%AF%E3%82%A4%E3%82%BA1.html)(1から10まで、ページがある)\n\nこのようになっているので、フォルダ名でカテゴリーを伝えることは難しいです。\n\nよって、下記のようにbody終了上あたりに記載すれば、フォルダ分けしなくても、 \nちゃんとクローラーにカテゴリーが伝わるか教えていただけますでしょうか? \n人間には無関係の情報なので、最後に記載したいと思っています。\n\nアフィリエイトクイズ2.htmlページに記載する情報 \n(トップ>クイズ>アフィリエイトクイズ>アフィリエイトクイズ2) \n(トップ>クイズ>アフィリエイトクイズ2の方が良いでしょうか?)\n\n```\n\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\":\n [\n {\n \"@type\": \"ListItem\",\n \"position\": 1,\n \"item\":\n {\n \"@id\": \"https://example.com/index.html\",\n \"name\": \"トップページ\"\n }\n },\n {\n \"@type\": \"ListItem\",\n \"position\": 2,\n \"item\":\n {\n \"@id\": \"https://example.com/html/SEOクイズ1.html\",\n \"name\": \"クイズ\"\n }\n },\n {\n \"@type\": \"ListItem\",\n \"position\": 3,\n \"item\":\n {\n \"@id\": \"https://example.com/html/アフィリエイトクイズ1.html\",\n \"name\": \"アフィリエイトクイズ\"\n }\n },\n {\n \"@type\": \"ListItem\",\n \"position\": 4,\n \"item\":\n {\n \"@id\": \"https://example.com/html/アフィリエイトクイズ2.html\",\n \"name\": \"アフィリエイトクイズ\"\n }\n }\n ]\n }\n </script>\n \n```\n\nSEOクイズ2.htmlページに記載する情報 \n(トップ>クイズ>SEOクイズ>SEOクイズ2) \n(トップ>クイズ>SEOクイズ2の方が良いでしょうか?)\n\n```\n\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\":\n [\n {\n \"@type\": \"ListItem\",\n \"position\": 1,\n \"item\":\n {\n \"@id\": \"https://example.com/index.html\",\n \"name\": \"トップページ\"\n }\n },\n {\n \"@type\": \"ListItem\",\n \"position\": 2,\n \"item\":\n {\n \"@id\": \"https://example.com/html/SEOクイズ1.html\",\n \"name\": \"クイズ\"\n }\n },\n {\n \"@type\": \"ListItem\",\n \"position\": 3,\n \"item\":\n {\n \"@id\": \"https://example.com/html/SEOクイズ2.html\",\n \"name\": \"SEOクイズ\"\n }\n }\n ]\n }\n </script>\n \n```\n\nこれで大丈夫でしょうか?\n\n最後にうまく認識されているかを確認する方法はおそらくないのですよね。 \nこれをやって数日後に順位が上がれば認識されたと判断するしかないでしょうね。\n\nプログラミングの質問か微妙ですが、seoというタグがないのでhtmlを付けました。\n\nお忙しいところ恐縮ですが教えていただければ幸いです。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T05:58:42.980",
"favorite_count": 0,
"id": "52309",
"last_activity_date": "2019-01-25T06:24:13.073",
"last_edit_date": "2019-01-25T06:24:13.073",
"last_editor_user_id": "3060",
"owner_user_id": "24247",
"post_type": "question",
"score": 2,
"tags": [
"javascript",
"html"
],
"title": "クローラーにブログのカテゴリーを伝えるには?",
"view_count": 117
} | [] | 52309 | null | null |
{
"accepted_answer_id": "52315",
"answer_count": 1,
"body": "エラーが表示され、画像ファイルを指定したフォルダに書き込むことができません。 \n指定フォルダを`C:\\\\Users\\\\???\\\\Desktop\\\\pics_directry`にするとファイルの書き込みはできます。フォルダ(pics_directry)にはたくさんフォルダがあり、この中に画像ファイルを書き込みたいです。\n\n<エラー文>\n\n```\n\n with open(savepath, mode=\"wb\") as f:\n PermissionError: [Errno 13] Permission denied:\n \n```\n\n<実行した内容>\n\n```\n\n url = \"https://......\"\n \n class AppURLopener(req.FancyURLopener):\n version = \"Mozilla/5.0\"\n opener = AppURLopener()\n res = opener.open(url) \n \n soup = BeautifulSoup(res, \"html.parser\")\n links = soup.div.center.find_all(\"a\") \n target_links = [link.get('href') for link in links] \n \n for img_links in target_links:\n o = urlparse(img_links)\n savepath = 'C:\\\\Users\\\\???\\\\Desktop\\\\pics_directry\\\\' + o.netloc + o.query\n if not os.path.exists(savepath):\n print(\"makedirs=\", savepath)\n os.makedirs(savepath)\n res = opener.open(img_links)\n soup = BeautifulSoup(res, \"html.parser\")\n img_links = soup.select(\" div > p > a > img\")\n img_target_links = [link.get('src') for link in img_links]\n print(img_target_links)\n for s in img_target_links:\n re = requests.get(s)\n print('Download:', s)\n with open(savepath, mode=\"wb\") as f:\n f.write(re.content)\n time.sleep(0.1)\n \n```\n\n※追記 \nやはり自分では作成したフォルダへ画像ファイルを直接書き込むことができませんでした。なので、画像ファイル書き込みを他のフォルダ上で行いその後\nglob()やshutil.move()などを使って指定のフォルダに移動しました。やりたかったことは一応達成できました。ありがとうございました。",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T07:35:45.107",
"favorite_count": 0,
"id": "52311",
"last_activity_date": "2019-01-27T01:04:04.907",
"last_edit_date": "2019-01-27T01:04:04.907",
"last_editor_user_id": "31922",
"owner_user_id": "31922",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "pythonで指定したフォルダにファイルの書き込みを行いたい",
"view_count": 7153
} | [
{
"body": "`os.makedirs`でフォルダを作り、その **フォルダパスをopenすると**`permission denied`エラーになります。 \n[本家SOの類似回答](https://stackoverflow.com/a/21786209/8248751)\n\n```\n\n #エラーサンプル\n import os\n os.makedirs(\"hoge\")\n with open(\"hoge\", \"w\") as f:\n f.write(\"fuga\")\n \n```\n\n> Traceback (most recent c... | 52311 | 52315 | 52315 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "ASP.NET MVC5 でcsv出力をしようとしています。\n\nパラメータの複数ある画面で、ボタンも複数あるためAjaxを使用してPostしています。 \nファイルのダウンロードがされず、またファイル作成もできず困っています。\n\n```\n\n //以下、抜粋\n $('#download').click(\n function () {\n var param= new Object();\n //param set\n if (parking != null) {\n $.ajax({\n type: \"POST\",\n url: \"@Url.Action(\"CreateCsv\", \"Csv\")\",\n data: JSON.stringify(param),\n contentType: \"application/json; charset=utf-8\",\n datatype:'json',\n success: function () {\n debugger\n alert(\"success\");\n },\n failure: function (data) {\n debugger\n alert(data.StatusMessage);\n },\n error: function (data) {\n debugger\n alert(data.StatusMessage);\n }\n })\n }\n }\n );\n \n \n [HttpPost]\n public ActionResult CreateCsv(Param Pram)\n {\n if (Request.IsAjaxRequest())\n {\n \n // DB からデータ取得\n \n // CSV 内容生成\n \n var fileName = string.Format(\"filename_{0}.csv\", DateTime.Now.ToString(\"yyyyMMddHHmmss\"));\n \n var data = Encoding.UTF8.GetBytes(csvString);\n \n var stream = new MemoryStream(data);\n var writer = new StreamWriter(stream);\n \n //var fileStreamResult = new FileStreamResult(stream, System.Net.Mime.MediaTypeNames .Text.Plain);\n //fileStreamResult.FileDownloadName = fileName;\n \n //return fileStreamResult;\n \n writer.Write(data);\n writer.Flush();\n stream.Position = 0;\n \n return File(stream, \"text/csv\", fileName);\n \n }\n return null ;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T09:42:36.760",
"favorite_count": 0,
"id": "52317",
"last_activity_date": "2019-01-26T12:22:46.180",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31925",
"post_type": "question",
"score": 0,
"tags": [
"asp.net",
"ajax",
"mvc"
],
"title": "ASP.NET MVC5 でcsvをpostでダウンロードするには",
"view_count": 3174
} | [
{
"body": "最後の `return` する部分。\n\n```\n\n return File(stream, \"text/csv\", fileName);\n \n```\n\nを、このようにしてみてはどうでしょう?\n\n```\n\n return File(stream.ToArray(), \"text/csv\", fileName);\n \n```\n\nこの辺の記事が、そんな風に `byte[]` に変換してから返しているので。\n\n[ASP.NET MVC\nファイルのダウンロード](http://haronoid.hatenablog.co... | 52317 | null | 52338 |
{
"accepted_answer_id": "52333",
"answer_count": 1,
"body": "プログラミング初心者でJavaでIteratorについて学んだのですが、\n\n・Iteratorには大まかに二つ役割があって、それはIteratorクラスとAggregateクラスの二つなのですが、実際にJavaで提供されているAPIはIteratorがjava.util.Iteratorクラス(Enumerationというのもありました)、AggregateがArrayListやMap、Setなどのことだと考えていいのですか?\n\n・デザインパターンの本を読んでいるとMainクラスを作る人とそれ以外のクラス(デザインパターンで作るクラス群)を作る人は別の人だと考えていいのですか?(つまり前者は仕様を読んでAPIを利用する側)\n\nいまいち理解が曖昧で確証が持てなくてもやもやしています。 \nどなたか御回答お願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T11:31:54.040",
"favorite_count": 0,
"id": "52319",
"last_activity_date": "2019-01-26T19:45:10.670",
"last_edit_date": "2019-01-26T19:45:10.670",
"last_editor_user_id": "19110",
"owner_user_id": "28320",
"post_type": "question",
"score": 5,
"tags": [
"java",
"アルゴリズム",
"デザインパターン"
],
"title": "デザインパターンのIteratorについて",
"view_count": 245
} | [
{
"body": "GoFデザインパターンによる「[Iteratorパターン](https://ja.wikipedia.org/wiki/Iterator_%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3)」と、Java標準ライブラリが提供する「[`Iterator`インタフェース](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Iterator.html)」とを区別して説明します。\n\n * Iteratorパターン:「データ集合の要素走査」を目的としたクラス設計構造に名前をつけたもの。\n * Iteratorインタ... | 52319 | 52333 | 52333 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "ChromeDriver で特定要素のタップイベント \ntouchstart \ntouchend \nをトリガーするにはどのようにコーディングすればよいでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T12:04:49.793",
"favorite_count": 0,
"id": "52320",
"last_activity_date": "2023-06-06T01:02:55.387",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3925",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"selenium",
"selenium-webdriver",
"chromedriver"
],
"title": "Selenium ChromeDriver でタップ(タッチ)イベントを発生させるには",
"view_count": 807
} | [
{
"body": "使ったことが無いので、検索結果からの推測ですが。 \n以下のようなものを使うことになるでしょう。これらを調べて試してみてください。\n\nタッチスクリーンインタフェースの取得 \n[selenium/dotnet/src/webdriver/IHasTouchScreen.cs](https://github.com/SeleniumHQ/selenium/blob/11c25d75bd7ed22e6172d6a2a795a1d195fb0875/dotnet/src/webdriver/IHasTouchScreen.cs) \n[selenium/dotnet/src/webdrive... | 52320 | null | 52510 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Tensorflowでプログラムを書いているのですが,\n\n> number of input channels does not match corresponding dimension of filter, 2\n> != 11\n\nというエラーが出ています. \nプログラムを以下に添付します.\n\n```\n\n def make_test(self):\n \n inputs = Input(shape=(28, 28, 11), name='label')\n x = Conv2D(64, (5, 5), padding='same')(inputs)\n x = LeakyReLU()(x)\n x = Conv2D(128, (5, 5), kernel_initializer='he_normal', strides=[2, 2])(x)\n x = LeakyReLU()(x)\n x = Conv2D(128, (5, 5), kernel_initializer='he_normal', padding='same', strides=[2, 2])(x)\n x = LeakyReLU()(x)\n x = Flatten()(x)\n x = Dense(1024, kernel_initializer='he_normal')(x)\n x = LeakyReLU()(x)\n x = Dense(1, kernel_initializer='he_normal')(x)\n model = Model(inputs=[inputs], outputs=[x])\n \n return model\n \n def make_hoge(self):\n \n noise_shape = (110,)\n \n inputs = Input(shape=noise_shape)\n x = Dense(1024)(inputs)\n x = LeakyReLU()(x)\n x = Dense(128 * 7 * 7)(x)\n x = BatchNormalization()(x)\n x = LeakyReLU()(x)\n if K.image_data_format() == 'channels_first':\n x = Reshape((128, 7, 7), input_shape=(128 * 7 * 7,))(x)\n bn_axis = 1\n else:\n x = Reshape((7, 7, 128), input_shape=(128 * 7 * 7,))(x)\n bn_axis = -1\n x = Conv2DTranspose(128, (5, 5), strides=2, padding='same')(x)\n x = BatchNormalization(axis=bn_axis)(x)\n x = LeakyReLU()(x)\n x = Conv2D(64, (5, 5), padding='same')(x)\n x = BatchNormalization(axis=bn_axis)(x)\n x = LeakyReLU()(x)\n x = Conv2DTranspose(64, (5, 5), strides=2, padding='same')(x)\n x = BatchNormalization(axis=bn_axis)(x)\n x = LeakyReLU()(x)\n x = Conv2D(1, (5, 5), padding='same', activation='tanh')(x)\n model = Model(inputs=[inputs], outputs=[x])\n \n return model\n \n def loss(self, y_true, y_pred):\n \n return K.mean(y_true * y_pred)\n \n def __init__():\n self.test = self.make_test()\n self.hoge = self.make_hoge()\n \n for layer in self.test.layers:\n layer.trainable = False\n self.test.trainable = False\n \n input_noise = Input(shape=(11,))\n generated_images = self.hoge(input_noise)\n input_label = Input(shape=(28, 28, 10,))\n inputs = concatenate([generated_images, input_label], axis=3)\n outputs = self.test(inputs)\n self.train_model = Model(inputs=[input_noise, input_label], outputs=[outputs])\n self.train_model.compile(optimizer=Adam(0.0001, beta_1=0.5, beta_2=0.9), loss=self.loss)\n \n```\n\nアルゴリズムの内容はGANです.変数名を短く書き直して上げたので間違っていたらすみません. \n環境はpython2.7, tensorflow1.12です. \nちなみにinputs, generated_images, input_labelはshapeを出力するとそれぞれ(?,28,28,11),\n(?,?,?,1), (?,28,28,10)になっています. \ngenerated_imagesをconcatenateせずにself.testに入れると動作することを確認しています.input_labelは動きませんでした. \nconv層を消してみると動きます.\n\nあと,エラー文が出ているのがtensorflowのnn_ops.pyの836行目付近なのですが,input_shape, filter_shape,\nnum_spatial_dimsを出力してみると(?, 28, 28, 2), (5, 5, 11, 64),\n2でした.filter_shape[num_spatial_dims]!=input_shape[num_spatial_dims+1]なのが問題のようです.\n\nよろしくお願いいたします.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T20:11:01.240",
"favorite_count": 0,
"id": "52324",
"last_activity_date": "2020-07-17T10:00:55.093",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31927",
"post_type": "question",
"score": 0,
"tags": [
"python",
"tensorflow",
"keras"
],
"title": "Tensorflowでnumber of input channels does not match corresponding dimension of filterのエラーが出ます",
"view_count": 220
} | [
{
"body": "質問者です. \nInputのshapeが間違っていました. \nお騒がせしてすみませんでした.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T00:16:02.487",
"id": "52327",
"last_activity_date": "2019-01-26T00:16:02.487",
"last_edit_date": null,
"last_editor_user_id": null,
... | 52324 | null | 52327 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "# 前提・実現したいこと\n\nPHP(CakePHP)でユーザー管理システムを作っています。 \n管理画面でユーザーを追加する入力フォームで、権限の入力箇所にセレクトボックスを使っております。フォームを送信すると、以下のエラーメッセージが発生しました。\n\n* * *\n\n# 発生している問題・エラーメッセージ\n\n```\n\n Error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'role' cannot be null\n \n```\n\n* * *\n\n# 該当のソースコード\n\nModel/Entity/User\n\n```\n\n <?php\n namespace App\\Model\\Entity;\n \n use Cake\\ORM\\Entity;\n \n /**\n * User Entity.\n *\n * @property int $id\n * @property string $name\n * @property string $password\n * @property string $role\n * @property \\Cake\\I18n\\Time $endlogined\n */\n class User extends Entity\n {\n \n /**\n * Fields that can be mass assigned using newEntity() or patchEntity().\n *\n * Note that when '*' is set to true, this allows all unspecified fields to\n * be mass assigned. For security purposes, it is advised to set '*' to false\n * (or remove it), and explicitly make individual fields accessible as needed.\n *\n * @var array\n */\n protected $_accessible = [\n '*' => true,\n 'id' => false,\n ];\n \n /**\n * Fields that are excluded from JSON an array versions of the entity.\n *\n * @var array\n */\n protected $_hidden = [\n 'password'\n ];\n }\n \n```\n\nModel/Table/UsersTable\n\n```\n\n <?php\n namespace App\\Model\\Table;\n \n use App\\Model\\Entity\\User;\n use Cake\\ORM\\Query;\n use Cake\\ORM\\RulesChecker;\n use Cake\\ORM\\Table;\n use Cake\\Validation\\Validator;\n \n /**\n * Users Model\n *\n */\n class UsersTable extends Table\n {\n \n /**\n * Initialize method\n *\n * @param array $config The configuration for the Table.\n * @return void\n */\n public function initialize(array $config)\n {\n parent::initialize($config);\n \n $this->table('users');\n $this->displayField('name');\n $this->primaryKey('id');\n \n $this->belongsTo('Roles', [\n 'foreignKey' => 'role',\n 'joinType' => 'INNER'\n ]);\n }\n \n /**\n * Default validation rules.\n *\n * @param \\Cake\\Validation\\Validator $validator Validator instance.\n * @return \\Cake\\Validation\\Validator\n */\n public function validationDefault(Validator $validator)\n {\n $validator\n ->add('id', 'valid', ['rule' => 'numeric'])\n ->allowEmpty('id', 'create');\n \n $validator\n ->requirePresence('name', 'create')\n ->notEmpty('name');\n \n $validator\n ->requirePresence('password', 'create')\n ->notEmpty('password');\n \n $validator\n ->requirePresence('role', 'create')\n ->notEmpty('role');\n \n $validator\n ->add('endlogined', 'valid', ['rule' => 'datetime'])\n ->allowEmpty('endlogined');\n \n return $validator;\n }\n }\n \n```\n\nController/Admin/UsersController\n\n```\n\n <?php\n namespace App\\Controller\\Admin;\n \n use App\\Controller\\AppController;\n use Cake\\Event\\Event;\n use Cake\\ORM\\Table;\n use Cake\\ORM\\TableRegistry;\n use Cake\\Error\\Debugger;\n \n class UsersController extends AppController\n {\n \n public function add()\n {\n $user = $this->Users->newEntity();\n if ($this->request->is('post')) {\n $user = $this->Users->patchEntity($user, $this->request->data);\n if ($this->Users->save($user)) {\n $this->Flash->success(__('The user has been saved.'));\n return $this->redirect(['action' => 'index']);\n } else {\n $this->Flash->error(__('The user could not be saved. Please, try again.'));\n }\n }\n $roles = $this->Users->Roles->find('list', ['limit' => 200]);\n $this->set(compact('user', 'roles'));\n $this->set('_serialize', ['user']);\n }\n \n }\n \n```\n\nTemplate/Admin/Users/add.ctp\n\n```\n\n <nav class=\"large-3 medium-4 columns\" id=\"actions-sidebar\">\n <ul class=\"side-nav\">\n <li class=\"heading\"><?= __('Actions') ?></li>\n <li><?= $this->Html->link(__('List Users'), ['action' => 'index']) ?></li>\n </ul>\n </nav>\n <div class=\"users form large-9 medium-8 columns content\">\n <?= $this->Form->create($user) ?>\n <fieldset>\n <legend><?= __('Add User') ?></legend>\n <?php\n echo $this->Form->input('name');\n echo $this->Form->input('password');\n echo $this->Form->input('role', ['options' => $roles]);\n ?>\n </fieldset>\n <?= $this->Form->button(__('Submit')) ?>\n <?= $this->Form->end() ?>\n </div>\n \n```\n\nテーブル構成\n\n```\n\n create table roles (\n role char(100) not null default 'admin',\n PRIMARY KEY (`role`)\n );\n \n create table users (\n id int unsigned not null auto_increment,\n name varchar(100) not null,\n password varchar(255) not null,\n role char(100) not null default 'admin',\n endlogined datetime default null,\n PRIMARY KEY (`id`),\n CONSTRAINT fk_role\n FOREIGN KEY (role)\n REFERENCES roles (role)\n ON UPDATE CASCADE ON DELETE RESTRICT\n );\n \n```\n\n* * *\n\n# 試したこと\n\nエラーメッセージは単純にroleカラムにNOT NULLを指定しているので、NULLを怒られているだけ。 \nアソシエーションで紐付けて、セレクトボックスの生成はできています。原因は、フォームで送信した値がpatchEntity()を通すとroleがNULLに変換されてしまうことだと思われます。つまり、validationDefault()に問題があるのかと思いきや、そういったおかしなバリデーションもしていないし、ということで、色々調べたりしたのですが、解決できませんでした。\n\nみなさんのお知恵をお貸しください。よろしくお願いいたします。\n\n* * *\n\n# 問題あると思われるpatchEntityの前後の出力結果\n\nController/Admin/UsersController\n\n```\n\n public function add()\n {\n $user = $this->Users->newEntity();\n if ($this->request->is('post')) {\n Debugger::dump($this->request->data);\n $user = $this->Users->patchEntity($user, $this->request->data);\n Debugger::dump($user);\n exit;\n =====上に同じなので、省略====\n }\n \n```\n\n```\n\n [\n 'name' => 'yamada',\n 'password' => 'ymymym',\n 'role' => 'admin'\n // セレクトボックスでちゃんとRolesの値が表示できていて、選択肢のうち、adminを選択して送信。\n // postで送信された値はadminなのでここまでは想定通り。\n ]\n object(App\\Model\\Entity\\User) {\n \n 'name' => 'yamada',\n 'password' => 'ymymym',\n 'role' => null, // nullに変換される!!!!!\n '[new]' => true,\n '[accessible]' => [\n '*' => true\n ],\n '[dirty]' => [\n 'name' => true,\n 'password' => true,\n 'role' => true\n ],\n '[original]' => [],\n '[virtual]' => [],\n '[errors]' => [],\n '[repository]' => 'Users'\n \n }\n \n```\n\n* * *\n\n# 補足情報(FW/ツールのバージョンなど)\n\nCakePHP3.1.14",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T22:06:17.460",
"favorite_count": 0,
"id": "52325",
"last_activity_date": "2019-07-13T05:00:55.080",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31909",
"post_type": "question",
"score": 0,
"tags": [
"php",
"mysql",
"cakephp"
],
"title": "patchEntity()を通すとNULLに変換されてしまう",
"view_count": 1278
} | [
{
"body": "CakePHPではアソシエーションで定義した関連は自動的にエンティティのフィールドと認識されます。\n\nUsersTableで\n\n```\n\n $this->belongsTo('Roles', [\n 'foreignKey' => 'role',\n 'joinType' => 'INNER'\n ]);\n \n```\n\nとしているので、User.role は Roleエンティティとして処理するようになっています。\n\nここで、User.roleは既にテキストフィールドとして... | 52325 | null | 52365 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "1つの選択ダイアログで、複数の写真をアップロードしたいと考えています。(今jsonが使える状態ではないので、stringのカラムで実装したいと考えています。)しかし、この場合でのcontrollerのカラムの保存の仕方がわからない状態です。 \nもしわかる方がいらしたら、どうぞ教えていただきたいです。\n\n```\n\n db\r\n \r\n add_column :plans, :image, :string\n```\n\n```\n\n controller\r\n \r\n def create\r\n Plan.create(image: params[:image])\r\n end\r\n \r\n private\r\n \r\n def plan_params\r\n params.permit(:image)\r\n end\n```\n\n```\n\n view new\r\n \r\n <%= file_field_tag 'image', :multiple => true %>\n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-25T23:50:29.450",
"favorite_count": 0,
"id": "52326",
"last_activity_date": "2019-01-26T02:52:21.807",
"last_edit_date": "2019-01-26T02:52:21.807",
"last_editor_user_id": "30829",
"owner_user_id": "30829",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"html"
],
"title": "jsonを使わず、stringで複数の画像を保存する方法がわかりません。",
"view_count": 116
} | [] | 52326 | null | null |
{
"accepted_answer_id": "52336",
"answer_count": 1,
"body": "spring-boot+spring-data-jpaで既存アプリの再構築を行おうと思っていますが \n既存DBのカラム名の先頭にアンダースコアが付いているカラムがあり \n生成されたSQLのカラムエイリアスでsqlエラーとなってしまいます。 \nカラム名自体は、@Column(name = \"[__id]\")とすることで \n出力されるSQLで\"__id\"に変換されることは確認していますが \nエイリアスを変更することは出来ないでしょうか?\n\nテーブル設計を見直すべきは重々承知していますが、 \nひとまず、既存テーブルを利用し再構築を行いたいと思っています。\n\nnative queryを利用すると正常に行きますが、 \n単純queryは出来るだけ記述せずにしたく \n対応の可否、可能な場合の方法などご存知でしたご教示ください。\n\nspring-data-jpaで利用されるhibernate-coreは5.3.7となります。\n\n以下、試してみたことです。\n\n**パターン1: JpaRepositoryを使用しfindAll(実行時SQLエラー発生)**\n\n```\n\n @Data\n @Entity\n @Table(name = \"sample\")\n public class sample {\n @Id\n @Column(name = \"[__id]\")\n private String id;\n \n @Column(name = \"[year]\")\n private Integer year;\n \n```\n\n出力されたSQL\n\n```\n\n select sample0_.\"__id\" as __id_1_7_, sample0_.\"year\" as year2_7_ from sample sample0_\n \n```\n\n**パターン2: @Queryを使用しnativequeryを記述(正常に動作)**\n\n```\n\n @Query(\"select \\\"__id\\\" as id, \\\"year\\\" from sample\", nativeQuery = true)\n \n```\n\n出力されたSQL\n\n```\n\n select \"__id\" as id, \"year\" from sample\n \n```\n\nよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T01:07:42.823",
"favorite_count": 0,
"id": "52328",
"last_activity_date": "2019-01-26T09:53:35.883",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31929",
"post_type": "question",
"score": 0,
"tags": [
"spring-boot",
"jpa",
"hibernate"
],
"title": "spring data jpaで自動生成されるSQLの変更方法",
"view_count": 731
} | [
{
"body": "自動生成されるエイリアス名がアンダースコア始まりになるが、利用しているDBMSでは命名違反になるのでなんとかしたい、ということだと理解しました。\n\n現行バージョンでは対処不能かなと考えます。\n\n* * *\n\n私も最近[エイリアス絡みの不具合](https://hibernate.atlassian.net/browse/HHH-5909)を踏んで似たような内容を調べていました。 \nエイリアス名を取得する実装は\n[`org.hibernate.mapping.Column#getAlias`](https://github.com/hibernate/hibernate-\nor... | 52328 | 52336 | 52336 |
{
"accepted_answer_id": "52450",
"answer_count": 4,
"body": "([QuickSort:GeeksforGeeks](https://www.geeksforgeeks.org/quick-sort/)を参照)\n\nQuickSortの大枠を、\n\n```\n\n /* low --> Starting index, high --> Ending index */\n quickSort(arr[], low, high) {\n if (low < high) {\n pi = partition(arr, low, high)\n \n quickSort(arr, low, pi - 1)\n quickSort(arr, pi + 1, high)\n }\n }\n \n```\n\nとしたとき、partition()には、先述GeeksforGeeksのような\n\n```\n\n /* 以下 p1 と表記 */\n partition (arr[], low, high) {\n pivot = arr[high]\n \n i = low - 1\n \n for (j = low; j <= high - 1; j++) {\n if (arr[j] <= pivot) { // ***\n i++\n swap arr[i] and arr[j]\n }\n }\n swap arr[i + 1] and arr[high]\n return (i + 1)\n }\n \n // GeeksforGeeks からまるまる引用\n // この *** 部分の比較を < に変更したものを p1' とする\n \n```\n\nというもの(iとjが共に前から後ろへ。[VisuAlgo](https://visualgo.net/ja/sorting)他いくつかのサイトで見かける)と、\n\n```\n\n /* 以下 p2 と表記 */\n partition (arr[], low, high) \n { \n pivot = arr[high]\n \n i = low\n j = high - 1\n \n for ( ; ; ) {\n while (arr[i] < pivot) i++\n while (i < j && pivot < arr[j]) j--\n if (i >= j) break\n swap arr[i] and arr[j]\n i++\n j--\n }\n swap arr[i] and arr[high]\n return i\n }\n \n```\n\nというもの(iは前から、jは後ろから)があるように見受けられます。\n\n当方の環境で実験したところ、1000万要素などになると露骨にp1の方が遅くなります(比較回数は少なめだが交換回数が多い)。 \nこれは前者のpartition()が間違って書かれているのでしょうか。 \n複数のサイトで誤りが放置されているとは考えにくいので実際は私に何か勘違いがあるのだと思います。ご指摘いただければ幸いです。\n\n* * *\n\n実験\n\n(Core2Duo E4600, g++ 8.2.0 最適化なし, vector<int>, 乱数, メモリは全2GBで余力は0.8GB程度)\n\n```\n\n | | 10^6 個 | 10^7 | 10^8 |\n +-----+-------- +------+-------+\n | p1' | 0.6 秒 | 14.6 | 953.3 |\n | p2 | 0.4 | 4.5 | 51.1 |\n \n なお p1 そのままを使うとさらに遅くなる\n | p1 | 1.0 | 52.9 | 未計測|\n \n```\n\n[使ったC++コード](https://ideone.com/ixuBOs)\n\n * 常駐ソフト等が悪さをしているのかと思いセーフモード起動で試したが同様\n * 最適化-O2を使っても同様。108件で208秒vs12秒\n * さらに化石PC(PentiumM 1.73GHz!)を引っぱり出して実験したが同様。107件で21秒vs6秒\n * コンパイラの違いかと思いVisual C++ 2010 Expressが入っていたので試したが同様。108件で270秒vs12秒\n * partition()呼び出し回数・swap回数をカウントしたところ異常な伸び方はしていない\n\n```\n\n | | 10^6 個 | 10^7 | 10^8 |\n +-----+-------------------------+-----------+-----------+\n | p1' | 0.01億calls, 0.1億swaps | 0.1 , 1.1 | 1.0, 12.0 |\n | p2 | 0.006 , 0.05 | 0.06, 0.7 | 0.6, 8.6 |\n \n```\n\n* * *\n\n実験2: ソート対象の要素の重複具合について\n\n[0..ARRAY_SIZE) をシャッフルしたユニークな配列の場合、定数倍っぽい差の出方に改善した(最適化-O2を使うとさらに差は縮まる)。\n\n```\n\n | |10^6 |10^7 | 10^8 |\n +-----+-----+-----+------+\n | p1' | 0.6 | 6.8 | 79.6 |\n | p2 | 0.4 | 4.5 | 51.5 |\n \n```\n\n[0..ARRAY_SIZE) の先頭何%かを同一要素にしてからシャッフルした配列の場合、重複を多くしていくとp1'の性能が劣化した\n\n```\n\n 10^7 件 において\n \n | | 0.1%| 0.4% | 0.5%\n +-----+-----+------+------\n | p1' | 7.4 | 11.6 | クラッシュ(スタック溢れ?)\n | p2 | 4.5 | 4.5 | 4.5\n \n```\n\n[使ったコード断片](https://ideone.com/eKTw0z)\n\n* * *\n\n解決事項\n\n * 複数人による検証によるとアルゴリズム、コードに致命的誤りはない (聞きたかったことは解決)\n * p1 は同一要素含みの配列に弱い",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T01:37:41.287",
"favorite_count": 0,
"id": "52329",
"last_activity_date": "2019-02-01T14:46:22.747",
"last_edit_date": "2019-02-01T14:46:22.747",
"last_editor_user_id": "31930",
"owner_user_id": "31930",
"post_type": "question",
"score": 12,
"tags": [
"アルゴリズム"
],
"title": "クイックソートの2種類の実装法で実行速度に顕著な違いが出る",
"view_count": 1643
} | [
{
"body": "当方の環境では要素数を1億にしても速度差はせいぜい10%前後でした。「下」の方が有意に早かったのですが、交換が発生する回数をカウントするためのコードを付け加えた場合など、「下」の方が遅くなることもありました。使用する言語やCPU、要素数や要素の分布によっても、結果は変動するだろうと思います。\n\n「上」の方では、配列全体を舐めて、pivotより小さな数に対して必ず交換が発生するのに対して、「下」の方では配列を前と後ろから舐めて、pivotより大きな数が前側/pivotより小さな数が後ろ側にあるときだけ交換が発生しします。\n\npivotがうまく中央値になったとして(常に「最後の要素」では、そ... | 52329 | 52450 | 52450 |
{
"accepted_answer_id": "52337",
"answer_count": 1,
"body": "すいません。\n\n件名の通りなのですが、 \npandas-Dataframeのcorr()で出した計算結果を、 \n画像やcsvなどに落としたりすることは可能でしょうか?\n\n(今まで計算して出された結果をコピー&ペーストして \n自分でエクセルで表を作り直して来たのですが、 \nもしかしたら簡単な方法があるのではないかと思いまして。。。)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T02:38:44.653",
"favorite_count": 0,
"id": "52330",
"last_activity_date": "2019-01-26T11:15:54.603",
"last_edit_date": "2019-01-26T02:47:12.400",
"last_editor_user_id": "76",
"owner_user_id": "31764",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pandas"
],
"title": "相関係数(corr)の出力方法について",
"view_count": 3473
} | [
{
"body": "pandas.DataFrame.corr() を使っているのであれば、結果はDataFrame型となっておりますので、CSVファイルに書き出す場合は単に\n`DataFrame.to_csv()` を使うとよいかと思います。\n\nこの結果を画像にするには seabornを使って、`seabor.heatmap()` に `annot=True`\nパラメータをつけて、ヒートマップを生成するのがよいかと思います。\n\n以下に簡単ではありますがサンプルを記述しましたので参考にしてみてください。\n\n```\n\n import pandas as pd\n import matp... | 52330 | 52337 | 52337 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Gitのリポジトリ管理について、お知恵を拝借したく存じます。 \n機能を100個持つような一つのシステムのプログラムを、一つのシステムで管理する方法について、良い方法はないでしょうか。 \n今想定しているのは下記2点です。 \n(1) 一リポジトリで100機能すべて管理 \n(2) 1機能ずつ別のリポジトリで管理 \n(3) その他(全く想像つきません)\n\n今まではSubversionで、機能1~100まで一つのリポジトリで管理していました。 \n開発者は20人程度で、全員機能1~100すべてにアクセス可能です。 \n必要な機能だけ随時Checkoutしてきて、その時不要な機能は随時ローカルから消していました。\n\nGitだと今必要な機能は1~10までなのに、不要な11~100までもローカルにある状況がどうにも怖いし、重くてPullに時間がかかりそうだと思いました。\n\nただ、別のリポジトリにすると100個ものリポジトリを管理できるのかが不安です。 \n一人ひとり、100個のディレクトリを作成し、それぞれにCloneしてくるのはあんまりにも現実的ではなく。 \nさらに10個の機能が必要な場合、10回Pullしてこないといけないのは結構な手間だと存じます。\n\nこのような場合、どうリポジトリを作り、管理していけば良いでしょうか。 \n是非、皆さまのお知恵をお貸しください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T12:26:13.387",
"favorite_count": 0,
"id": "52339",
"last_activity_date": "2019-01-27T02:28:05.103",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31937",
"post_type": "question",
"score": 5,
"tags": [
"git"
],
"title": "大量のサブ機能を持つ、一つのシステムをGitで一つのリポジトリとして管理すべきか",
"view_count": 490
} | [
{
"body": "# 全部を一つのリポジトリで管理する\n\n想定しているシステムの大きさがどのくらいなのかわからないのですが、コード全体で数GBを超えるような非常に巨大なものなのでしょうか。\n\nそうでもない場合、Gitは更新を差分で取得しているため、全機能を毎回取得していても問題にはならないかと考えます。\n\n# それでも別リポジトリで管理したい場合\n\nGitにはサブモジュールという機能があり、リポジトリから別のリポジトリを参照することができます。\n\nこの機能を利用することで、一度に全部の子リポジトリを最新版に更新したり、あるいは各親リポジトリの参照する子リポジトリをそれぞれのブランチ、あるいはコ... | 52339 | null | 52348 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "932GiBの外付けHDD(sdb2)に対して、\n\n`~$sudo shred -n 4 -z -v /dev/sdb2`\n\nを実行すると、30GiBぐらい書き込んだ辺りから、\n\n`shred: /dev/sdb2: オフセット 32444973056 で書き込みエラーが発生しました: Input/output error`\n\nが発生します。\n\n5年前にUSBに対してshredコマンドを実行した際には、このようなエラーは起こらなかったのですが、今回は何度やっても30GiBぐらい書き込んだ辺りから弾かれてしまいます。何が原因なのか調べても満足がいく情報が見つからなかったので質問させていただきました。\n\n追記)どうやら30GiBの乱数を書き込んだ辺りから、ゲストOS(ホストも?)へのマウントが解除されるようです。\n\nホストOS: Windows10 \nゲストOS: Fedora29 GNOME",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T14:23:33.310",
"favorite_count": 0,
"id": "52340",
"last_activity_date": "2019-01-28T12:50:17.680",
"last_edit_date": "2019-01-26T14:29:21.650",
"last_editor_user_id": "30493",
"owner_user_id": "30493",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"command-line"
],
"title": "仮想マシン上のFedoraからshredコマンドを実行すると途中から書き込みエラーに",
"view_count": 672
} | [
{
"body": "該当ディスクの破損を疑いましょう。`fsck`などのチェックが通るか念のため確認してみてください。\n\n私の場合はVirtualBox上のLinuxからホストOS(Windows10)に接続したSDカードに対して操作を行った際、破損したSDカードだと操作の途中でI/Oエラーが発生して接続状態も頻繁に解除されてしまうケースがありました。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-27T04:48:08.887",
"id": "52351",... | 52340 | null | 52378 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "ご教示お願い致します。質問が3つあります。\n\n【前提】 \n当方、 \n・自作のTwitter botと連携 \n・自GoogleアカウントのGmailアドレスから発信 \n・自GoogleアカウントのGoogle Drive上のファイルの読み書き \n等を行うGoogle Apps Scriptのプロジェクトを保持しております。\n\nGoogle Apps Developers から以下の内容のメールを受信しました。\n\n> Hi Google API Developer,\n>\n> We sent this email because you’re listed as a contact on the following \n> Google Cloud Project(s) using OAuth 2.0 to access Google APIs:\n>\n> project-id-xxxxxxxxxxxxxxxxxxx(固有のID①が入ります) \n> project-id-yyyyyyyyyyyyyyyyyyy(固有のID②が入ります) In October 2018, we \n> announced that, in January 2019, new Gmail API policies for restricted \n> scopes will go into effect. We want to let you know that, starting \n> today, you can submit your app(s) that use restricted scopes for \n> verification. Please review the full policy and OAuth FAQ for more \n> information including the secure handling requirement.\n>\n> What you need to do If you want to use one of the restricted scopes, \n> for verification through the Google API Console (On the left side menu \n> click Credentials, then click OAuth consent screen) between January \n> 16th and February 15th, 2019 for the project(s) listed above. Owners \n> and editors of the project will be able to submit for verification and \n> developers with internal apps for users in the same G Suite domain do \n> not need to do this.\n>\n> If you do not take action If you do not submit for verification by \n> February 15th, 2019, we’ll disable account access for new users on \n> February 22nd, 2019.\n>\n> If you do not submit for verification by March 31st, 2019, we’ll \n> revoke existing consumer grants.\n>\n> Thanks, Google Cloud Platform/API Trust & Safety\n\n案内に従って、Google Cloud Platformを開き、[認証情報]>[OAuth同意画面]を開き、[確認のため送信]を押すと、以下の画像の通り、 \n「[アプリケーション ホームページ]リンク」と「[アプリケーション プライバシー ポリシー]」が必須というエラーになりました。 \n[](https://i.stack.imgur.com/T7xLN.png)\n\n====================\n\n## 【質問①】\n\n現状、「[アプリケーション ホームページ]リンク」と「[アプリケーション プライバシー\nポリシー]」に該当するサイトを保持していないのですが、作成しないとGoogle Apps\nScriptのプロジェクトが停止してしまうという事になりますでしょうか。\n\n## 【質問②】\n\n作成する必要がある場合、Googleドライブ上の何らかのサービスを使用して作成できるのでしょうか。\n\n## 【質問③】\n\nサイトを作成した場合、Google Apps Scriptとどのように関連付ければ良いのでしょうか。\n\n初歩的な質問かもしれず、申し訳ありません。 \nご教示お願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T14:38:25.543",
"favorite_count": 0,
"id": "52341",
"last_activity_date": "2022-03-12T07:03:40.340",
"last_edit_date": "2019-01-27T02:34:01.887",
"last_editor_user_id": "29826",
"owner_user_id": "31938",
"post_type": "question",
"score": 0,
"tags": [
"google-apps-script"
],
"title": "プライバシーポリシー画面設置方法(Google Apps Developersからのメール)",
"view_count": 1309
} | [
{
"body": "<https://webapps.stackexchange.com/questions/124718/please-tell-me-about-how-\nto-implement-privacy-policy-site-for-my-google-apps-scr?answertab=votes#tab-\ntop> \n上記のサイトで回答してくださった方がいました。 \n感謝申し上げます。\n\n頂いた回答をGengoさんで翻訳して頂きました。 \n(翻訳して頂いた内容を載せる事は問題ないとの事です)\n\n* * *\n\n問題は、あなたのユーザーが許可を承認する際に、警告メッセー... | 52341 | null | 52449 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "WPFにて、TextBoxのPreviewMouseDownイベント内でShowDialog()をすると、TextBoxをクリックしてもカーソルが合わなくなってしまいます。 \nPreviewMouseDownイベント内でShowDialog()をした後はPreviewMouseUpイベントが発生しないことも確認しました。PreviewMouseDown後はTextBoxの動作が中断されているようです。\n\n私がやりたいことは、TextBox.Focus()を使ってカーソルを合わせるというようなことではなく、PreviewMouseDownイベント内でShowDialog()をした後も通常のようにTextBoxを動作させてカーソルを合わせることです。 \nつまり、通常のようにとは次のような動作です。\n\n 1. TextBoxをクリック\n 2. PreviewMoseDownイベントが発生し、ダイアログが開く\n 3. ダイアログを操作しDialogResultを発生させメインウィンドウに返ってくる\n 4. PreviewMouseUpイベントが発生する\n 5. TextBoxにカーソルが合う\n\n解決策が分かる方、どうかよろしくお願いいたします。\n\n* * *\n\nMainWindow.xaml\n\n```\n\n <Grid>\n <TextBox Height=\"30\" Width=\"200\" PreviewMouseDown=\"TextBox_PreviewMouseDown\"/>\n </Grid>\n \n```\n\nMainWindow.xaml.cs\n\n```\n\n namespace Sample\n {\n public partial class MainWindow : Window\n {\n public MainWindow()\n {\n InitializeComponent();\n }\n \n private void TextBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)\n {\n new Dialog().ShowDialog();\n }\n }\n }\n \n```\n\nDialog.xaml\n\n```\n\n <Grid>\n <Button Click=\"Button_Click\"/>\n </Grid>\n \n```\n\nDialog.xaml.cs\n\n```\n\n namespace Sample\n {\n public partial class Dialog : Window\n {\n public Dialog()\n {\n InitializeComponent();\n }\n \n private void Button_Click(object sender, RoutedEventArgs e)\n {\n DialogResult = true;\n }\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T15:11:15.873",
"favorite_count": 0,
"id": "52342",
"last_activity_date": "2022-05-25T11:01:55.323",
"last_edit_date": "2021-01-21T00:54:45.573",
"last_editor_user_id": "3060",
"owner_user_id": "31939",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"wpf"
],
"title": "TextBoxのPreviewMouseDownイベント内でShowDialog()をすると、TextBoxをクリックしてもカーソルが合わない",
"view_count": 925
} | [
{
"body": "コードを書いて確認することはしていませんが、 \nTextBox の PreviewMouseDown でダイアログを表示しているため \nPreviewMouseUp が発生する前に、ダイアログが表示されています。\n\nダイアログを閉じて元のフォームに戻った時点で \nマウスボタンは押されていない状態だと思うので \nPreviewMouseUp が発生しないのだと思います。\n\n解決策は、PreviewMouseDown のイベントを利用するのではなくて \nPreviewMouseUp で、ダイアログの表示からその結果の処理もしてしまうことです。 \n*PreviewMou... | 52342 | null | 52347 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "私は、consoleでfont_1_honokamin.ttfのエラーが発生しているが、解消することができない状態にいます。\n\n```\n\n style.scss\r\n \r\n @font-face {\r\n font-family: 'ほのか明朝';\r\n src: url('font_1_honokamin.ttf') format('truetype');\r\n font-weight: normal;\r\n font-style: normal;\r\n }\r\n \r\n View \r\n \r\n <link href=\" https://change_change.com/assets/font_1_honokamin.ttf\" rel=\"font\">\n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-26T16:10:38.587",
"favorite_count": 0,
"id": "52343",
"last_activity_date": "2019-09-18T04:03:59.863",
"last_edit_date": "2019-09-18T04:03:59.863",
"last_editor_user_id": "30829",
"owner_user_id": "30829",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"html"
],
"title": "consoleでnet::ERR_ABORTED 404 (Not Found)のエラーが発生してしまい、それが解消できない",
"view_count": 15489
} | [
{
"body": "[ほのか明朝](http://font.gloomy.jp/honoka-mincho-dl.html) フォントがサーバー上に無いので 404 (Not\nfound) というエラーになっています。console に出力されたURLで このフォントが参照できるようにサーバー上に配置してください。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-01T03:10:46.560",
"id": "52465",
"last_activity_... | 52343 | null | 52465 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "### 前提・実現したいこと\n\n<https://qiita.com/uedatakeshi/items/9712cd4632209389445a#heroku%E8%A8%AD%E5%AE%9A>\n\n上記のherokuの設定を参考にして作業していますが、なぜかアプリケーションを公開できません。 \nProcfileの作成からherokuプッシュまで、完全に同じ手順で設定しています。\n\n(まずはトップページを表示させたいと思っているので、データベースの設定はまだです)\n\nwebrootのindex.phpでcakeのサーバーが見つからないとありますが、どうしたらよいか... \nvendorが必要なのでは?と思い、vendorを入れたりもしてました。\n\n考えらえる原因は何でしょうか? \n完全に詰まってしまったので回答もらえると嬉しいです。\n\n### 発生している問題・エラーメッセージ\n\nHTTP ERROR 500\n\n### 以下、herokuのログ\n\n```\n\n 2019-01-26T10:47:18.293157+00:00 app[web.1]: [26-Jan-2019 10:47:18 UTC] PHP Fatal error: Uncaught Error: Class 'Cake\\Http\\Server' not found in /app/webroot/index.php:37\n 2019-01-26T10:47:18.293173+00:00 app[web.1]: Stack trace:\n 2019-01-26T10:47:18.293175+00:00 app[web.1]: #0 {main}\n 2019-01-26T10:47:18.293251+00:00 app[web.1]: thrown in /app/webroot/index.php on line 37\n 2019-01-26T10:47:18.293790+00:00 app[web.1]: 10.43.234.10 - - [26/Jan/2019:10:47:18 +0000] \"GET / HTTP/1.1\" 500 - \"https://dashboard.heroku.com/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36\n 2019-01-26T10:47:18.294450+00:00 heroku[router]: at=info method=GET path=\"/\" host=thawing-gorge-19673.herokuapp.com request_id=b62d8d05-e86f-4b0a-91da-9d433257ea88 fwd=\"49.106.188.51\" dyno=web.1 connect=1ms service=5ms status=500 bytes=169 protocol=https\n \n```\n\n### 試したこと\n\nconfig/bootstrap.phpに追加するコードの順番を変更 \ngitignoreでvendorを入れるよう設定変更\n\n### 補足情報(FW/ツールのバージョンなど)\n\ncakePHP3.6.12",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-27T07:42:14.427",
"favorite_count": 0,
"id": "52352",
"last_activity_date": "2019-01-27T12:23:43.657",
"last_edit_date": "2019-01-27T12:23:43.657",
"last_editor_user_id": "20098",
"owner_user_id": "31947",
"post_type": "question",
"score": 0,
"tags": [
"php",
"cakephp",
"heroku"
],
"title": "cakephp3で作ったアプリケーションをherokuに公開できない。HTTP ERROR 500が出る",
"view_count": 166
} | [] | 52352 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "論文執筆にあたりwindows64にrevtex4をインストールする必要があり、実際にAPSのHPからzip解凍し、Readmeを読んでいます。自分は今、texlive2018をインストールしており、システム変数のpathに\n\n```\n\n C:\\texlive\\2018\\bin\\win32\n \n```\n\nとして通しています。revtex4-2のzipファイルの中のrevtexをコピーしそのファイルの中と同じ場所にshitagaki.texを保存し、実行すると\n\n```\n\n \\documentclass{revtex4-2}\n \n```\n\nrevtex4-2.clsがないとでます。 \nしかしshitagaki.texと同じディレクトリにrevtex4-2.clsはあります。 \n何が原因なのでしょうか",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-27T07:53:30.773",
"favorite_count": 0,
"id": "52353",
"last_activity_date": "2019-07-02T09:02:20.383",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "29111",
"post_type": "question",
"score": 0,
"tags": [
"latex",
"tex"
],
"title": "revtex4の使い方がよくわかりません",
"view_count": 1377
} | [
{
"body": "TeX Live を使っているのであればパッケージの追加は `tlmgr install <package name>` で行います。 \n今回の件であれば `tlmgr install revtex4` となります。\n\nそれでもエラーが出るのであればエラーが出るソースコードやログの貼付けをすると回答がつきやすいでしょう。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T05:35:02.897",
"id": "52367",
... | 52353 | null | 52367 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "コマンドプロンプトでWindowsPCのカメラを立ち上げ指定場所に保管する方法を探しています。\n\n使用OS:Windows10 \n下記方法にてカメラの起動まではわかったのですが、保管場所やファイル名の指定がわかりません。\n\n## 何か良い方法はないでしょうか?\n\n試した方法\n\n```\n\n C:\\Windows\\System32\\cmd.exe /c start \"\" \"microsoft.windows.camera:\"\n \n```\n\nとコマンドプロンプトに打鍵するとカメラが立ち上がります。 \n↓ \n録画ボタンを押す \n↓ \n`C:\\Users\\ユーザ名\\Pictures\\Camera Roll`に動画ファイルが保管される\n\nこの方法では動画の保存場所もファイル名も指定ができません",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-27T12:23:29.543",
"favorite_count": 0,
"id": "52354",
"last_activity_date": "2020-01-20T13:23:48.037",
"last_edit_date": "2020-01-20T13:23:48.037",
"last_editor_user_id": "32986",
"owner_user_id": "8168",
"post_type": "question",
"score": 0,
"tags": [
"windows-10",
"camera"
],
"title": "コマンドプロンプトでWindowsPCのカメラを立ち上げ指定場所に保管する方法",
"view_count": 4478
} | [
{
"body": "解決策ではないし、自分で確認してもいないのですが、ちょっとした情報として。\n\n@WESUEKさんと同様の情報を解説されている記事がありますが、 \nこの記事にもフォルダを変更する情報は無いですね。 \n[Windows 10のMicrosoft\nStoreアプリをコマンドラインやバッチから起動する](http://www.atmarkit.co.jp/ait/articles/1810/19/news038.html)\n\n起動時に任意の場所を指定する方法は不明ですが、フォルダを変更したり追加することは可能なようです。 \nただし自分では確認していませんが。\n\nマイクロソフトの... | 52354 | null | 52357 |
{
"accepted_answer_id": "52361",
"answer_count": 1,
"body": "```\n\n <table id=\"tbl1\">\n <thead>\n <tr><th>列1</th><th>列2</th></tr>\n </thead>\n <tbody>\n <tr><td>A1</td><td>A2</td></tr>\n <tr><td>B1</td><td>B2</td></tr>\n <tr><td>C1</td><td>C2</td></tr>\n </tbody>\n <input type=\"submit\" value=\" ボタン\"/>\n </table>\n </body>\n </html>\n \n```\n\n事前にJS側で、let tmp = 2; と定義したものを使って \nB2を取得したい場合JSのコードはどのように描けばよろしいでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-27T13:34:37.680",
"favorite_count": 0,
"id": "52355",
"last_activity_date": "2019-01-28T01:46:30.700",
"last_edit_date": "2019-01-27T13:40:09.060",
"last_editor_user_id": "25422",
"owner_user_id": "25422",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery"
],
"title": "テーブルから指定した行の値を取得したい",
"view_count": 13408
} | [
{
"body": "`tr`のchildrenに対して`eq`を呼び出すことで行の値を取得できます。 \n下記のサンプルコードでは、`id=tbl1`の`tbody`要素から`tr`の2行目の子要素(`td`)の末尾から`text`を取得しています。\n\n```\n\n let tmp = 2;\n let text = $(\"#tbl1\").children(\"tbody\").children(\"tr\").eq(tmp - 1).children().last().text();\n \n```\n\n`eq`のインデックスは0から始まるので、\"B2\"を取得する場合は`eq(... | 52355 | 52361 | 52361 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Amazon\nLinuxでcrontabの設定をしてcronを実行すると作成されるファイルのパーミッションが644になります。作成されるファイルが664にしたいのですが、Linuxのどの設定を変更すればいいでしょうか。phpファイル内でパーミッション、umaskを指定すればできますがLinuxの設定で変更したいです。\n\ncron実行ユーザのumaskを002に変更しても、cron実行後に作成されるファイルがパーミッション644になってしまいます。\n\ncronを通してphpファイルが実行されて作成されるファイルが、なぜ最初に設定したumask002にならないのかがわかりません。\n\ncrontab\n\n```\n\n 27 01 * * * /usr/bin/php /aaa/index.php\n \n```\n\nindex.php\n\n```\n\n <?php\n $file = \"/data/bbb.txt\";\n $string = \"Hello, PHP\";\n file_put_contents($file, $string);\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-27T17:27:44.303",
"favorite_count": 0,
"id": "52360",
"last_activity_date": "2020-01-07T08:20:08.340",
"last_edit_date": "2020-01-07T08:20:08.340",
"last_editor_user_id": "3060",
"owner_user_id": "10088",
"post_type": "question",
"score": 1,
"tags": [
"linux",
"cron"
],
"title": "cronでphpファイルを実行すると作成されるファイルのパーミッションが644になる",
"view_count": 968
} | [
{
"body": "cron 実行時はログインシェルは動かないので cron実行ユーザの profile 等に設定した内容は読み込まれません。実行時の umask\nや必要な環境変数は、 crontab に明示的に書けば良いと思いますので試してみてください。\n\n```\n\n 27 01 * * * umask 0002; /usr/bin/php /aaa/index.php\n \n```\n\nもしくは、pam で cron実行時のデフォルトのumaskを設定しても効果があるかもです。 \nファイル `/etc/pam.d/crond`\n\n```\n\n session optio... | 52360 | null | 52463 |
{
"accepted_answer_id": "52368",
"answer_count": 1,
"body": "ブランチの切替について質問です。\n\neclipseで操作をしているのですが・・・\n\nローカルリポジトリでmasterブランチから作業ブランチを作成し、作業ブランチでAファイルを編集中、最新状態へ更新する必要が出てきました。(作業ブランチの変更内容は除いて)\n\nmasterブランチに切り替えたのですが \nこのとき、コミット、ステージングをしていないのに問題なく切り替えることができました。 \nその代わり、作業ブランチで変更した内容がmasterブランチに反映されていました。\n\n競合が発生しない場合は変更内容が維持されてブランチが切り替わるのでしょうか? \n≪理想≫ \n作業ブランチ ・・・ AファイルにZを追加中 \n↓切替 \nmasterブランチ・・・ AファイルにはZの内容はない\n\n≪現実≫ \n作業ブランチ ・・・ AファイルにZを追加中 \n↓切替 \nmasterブランチ・・・ AファイルにはZの内容がある \n\n現在この現象のせいで、作業ブランチでの編集中の内容を含めてmasterブランチにPUSHされてしまいました・・・。\n\nこの場合、`ブランチを切り替える際は必ずコミットをする`という運用にするしか回避する方法は無いのでしょうか?\n\n初歩的な質問となりますが、ご教授お願いします・・・。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T05:11:19.200",
"favorite_count": 0,
"id": "52366",
"last_activity_date": "2019-01-28T06:02:57.797",
"last_edit_date": "2019-01-28T05:19:54.673",
"last_editor_user_id": "2238",
"owner_user_id": "27196",
"post_type": "question",
"score": 2,
"tags": [
"git",
"eclipse"
],
"title": "ブランチの切替について",
"view_count": 3854
} | [
{
"body": "> 競合が発生しない場合は変更内容が維持されてブランチが切り替わるのでしょうか?\n\nその通りです。\n\n> この場合、ブランチを切り替える際は必ずコミットをするという運用にするしか回避する方法は無いのでしょうか?\n\ngit stashで一時的に変更を退避するというのが解決策になるかと思います。\n\nまた、今回の事象はブランチ切替時にリポジトリの状態を確認していれば防げた事だと思われますので、git\nstatusで状態を確認する癖をつけるというのが大事な気がします。",
"comment_count": 8,
"content_license": "CC BY-SA ... | 52366 | 52368 | 52368 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "UWPのWebViewにWebリンクをドラッグ&ドロップしてWebページを表示させたいです。\n\n以下のようなコードで実装したのですが、1回目は成功するのですがWebページが表示されたあとはドラッグを受け付けなくなります。\n\n2回目以降もドラッグ&ドロップを受け付けるようにしたいのですが、どのようにしたらよいのでしょうか?\n\n```\n\n <Page\n x:Class=\"Test.MainPage\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n xmlns:local=\"using:Test\"\n xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n mc:Ignorable=\"d\"\n Background=\"{ThemeResource ApplicationPageBackgroundThemeBrush}\">\n \n <Grid>\n <WebView x:Name=\"WebViewControl\" AllowDrop=\"True\" DragOver=\"WebView_DragOver\" Drop=\"WebView_Drop\"/>\n </Grid>\n \n </Page>\n \n```\n\n```\n\n using System;\n using Windows.ApplicationModel.DataTransfer;\n using Windows.UI.Xaml;\n using Windows.UI.Xaml.Controls;\n \n namespace Test\n {\n public sealed partial class MainPage : Page \n {\n public MainPage()\n {\n this.InitializeComponent();\n }\n \n private void WebView_DragOver(object sender, DragEventArgs e)\n {\n if (e.DataView.Contains(StandardDataFormats.WebLink))\n {\n e.AcceptedOperation = DataPackageOperation.Link;\n e.Handled = true;\n }\n }\n \n private async void WebView_Drop(object sender, DragEventArgs e)\n {\n if (e.DataView.Contains(StandardDataFormats.WebLink))\n {\n var uri = await e.DataView.GetWebLinkAsync();\n this.WebViewControl.Source = uri;\n e.Handled = true;\n }\n }\n }\n }\n \n```\n\nターゲット: UWP (Windows10, version 1809) \n開発環境: VisualStudio 2017\n\n* * *\n\n(2019-02-03追記)\n\n## Q. JavaScriptを使えば対応できる?\n\n[WebView Class | Remarks](https://docs.microsoft.com/en-\nus/uwp/api/windows.ui.xaml.controls.webview#remarks) に、次のような記述がありました。\n\n> As indicated in the Events table, WebView doesn’t support most of the \n> user input events inherited from UIElement, such as KeyDown, KeyUp, \n> and PointerPressed. A common workaround is to use InvokeScriptAsync \n> with the JavaScript eval function to use the HTML event handlers, and \n> to use window.external.notify from the HTML event handler to notify \n> the application using WebView.ScriptNotify.\n\nユーザー入力はJavaScriptを追加してそのイベントを活用する方法があると読めますが、ドラッグ&ドロップもこの方法で実現できるのでしょうか? \n当方JavaScriptの知識がほぼないため、例示していただけるとうれしいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T07:17:11.797",
"favorite_count": 0,
"id": "52369",
"last_activity_date": "2019-02-03T15:29:00.690",
"last_edit_date": "2019-02-03T04:28:03.147",
"last_editor_user_id": "14817",
"owner_user_id": "14817",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"c#",
"uwp"
],
"title": "UWPのWebViewにWebリンクをドラッグ&ドロップしてWebページを開けるようにしたい",
"view_count": 781
} | [
{
"body": "Windows10向けにビルドしてWindows10で動作させる限り、ご質問の動作は仕様と考えられます。 \nWebViewクラス説明に以下の記述があり、Windows10ではEdgeのエンジンで動作するとあります。\n\n[WebView Class | Remarks](https://docs.microsoft.com/en-\nus/uwp/api/windows.ui.xaml.controls.webview#remarks)\n\n> In apps compiled for Windows 10, WebView uses the Microsoft Edge renderi... | 52369 | null | 52505 |
{
"accepted_answer_id": "52376",
"answer_count": 1,
"body": "プログラミング初心者の者です。\n\nログイン画面と新規登録画面をPHPで実装しようとしているのですが、pdoとmysqliとは共存できないのでしょうか? \n少し書き方が違うもの、という認識で新規登録はmysqliで、ログイン画面はpdoの書き方をしたところ、後に作成したログイン画面が機能しません。 \nエディター上でのエラーは一切表示されずブラウザで、nullやundefinedのエラーがでます。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T07:42:06.080",
"favorite_count": 0,
"id": "52370",
"last_activity_date": "2019-01-29T02:42:16.420",
"last_edit_date": "2019-01-29T02:42:16.420",
"last_editor_user_id": "3060",
"owner_user_id": "31799",
"post_type": "question",
"score": 0,
"tags": [
"php"
],
"title": "pdoとmysqliは共存することができますか?",
"view_count": 494
} | [
{
"body": "この記事によると、FAQに「混在はできない」と書いてあるそうです。 \n[mysqli pdo - PHPでMySQL APIを混在させることはできますか?](https://code.i-harness.com/ja-\njp/q/10b0068)\n\nそのFAQはこちらですね。引用部分の最後の強調は私が入れました。 \n[PHP:データベースに関する問題 -\nManual](http://php.net/manual/ja/faq.databases.php#faq.databases.mysql.deprecated)\n\n> **10 年前からずーっと MySQL 拡張モジュー... | 52370 | 52376 | 52376 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "パスワードのハッシュ化時、ソルト値に何を使用してるのか知りたいです。\n\nソース追ってみたのですが、分かりませんでした。 \nsetting.pyのSECRET-KEYではなかろうかと思っているのですが…\n\nどなたか教えて下さい。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T07:52:56.720",
"favorite_count": 0,
"id": "52371",
"last_activity_date": "2019-02-05T04:47:58.210",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30436",
"post_type": "question",
"score": 0,
"tags": [
"django"
],
"title": "Djangoのソルト値について",
"view_count": 215
} | [
{
"body": "hasher次第だけどここらへんじゃないかな。 \n<https://github.com/django/django/blob/b9cf764be62e77b4777b3a75ec256f6209a57671/django/utils/crypto.py#L48-L69>\n\n乱数生成器の内部状態、時刻、SECRET_KEYの組み合わせから生成されたSHA256を種とする12桁のランダム英数。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-05T0... | 52371 | null | 52555 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "playframework2.6をazure上で使用したいのですが、利用可能でしょうか? \neclipseのazureツールキットを使って、playアプリケーションをデプロイしたいのですが、 \nデプロイしようとしても、デプロイボタンがアクティブになりません。 \nよろしくお願いいたします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T07:59:56.703",
"favorite_count": 0,
"id": "52372",
"last_activity_date": "2019-01-28T07:59:56.703",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20807",
"post_type": "question",
"score": 0,
"tags": [
"azure",
"playframework"
],
"title": "playframework2.6 on azure",
"view_count": 41
} | [] | 52372 | null | null |
{
"accepted_answer_id": "52594",
"answer_count": 1,
"body": "Raspberry Pi (Raspbian stretch) 上で稼働する Docker で で Mosquitto が直ぐ Exited してしまう。\n\n何度もトライ&エラーをしながら探ってきましたが何をすればいいか思いつきません。 \nなぜ Docker run で Exited となるのかがわかりません。 \n原因を探るための方法や場所、ファイルなど、何かのヒントでもよろしいのでご指摘いただけませんでしょうか。 \nよろしくお願いいたします。\n\n**【実現したいこと】** \nRaspberry Pi 上の Docker で Mosquitto Brokerを TLS で稼働させたい。\n\n**【今まで実行したこと】** \n**Docker インストール** \nRaspberry Pi 3 B+ に 2018-11-13-raspbian-stretch-lite をインストール。 \nDocker を公式を参考にインストール。 \nDocker で Hallo World 実行確認済。\n\n**Docker HUB の eclipse-mosquitto で実験** \nDocker HUB にあった \n[eclipse-mosquitto](https://hub.docker.com/_/eclipse-mosquitto) を手順通り進めると \nSystem error: exec format error が出た。\n\n**GitHub の Mosibi/mosquitto で実験** \nTLS を行いたかったので GitHub にあった\n[Mosibi/mosquitto](https://github.com/Mosibi/mosquitto) を手順通りに進めると \nSystem error: exec format error が出た。\n\nここで FROM で指定する OS を Raspbian にしないといけないことに気付く。\n\n**Docker HUB の[schachr/raspbian-\nstretch](https://hub.docker.com/r/schachr/raspbian-stretch/) で実験** \ndocker pull schachr/raspbian-stretch して \n手順通り進めると無事コンテナの中のbashが起動する。 \nその後 Hallo World の DockerFile を他から引用して実行すると無事表示。\n\n**[Mosibi/mosquitto](https://github.com/Mosibi/mosquitto) の FROM を変更して実験**\n\n```\n\n FROM schachr/raspbian-stretch:latest\n \n```\n\nと変更して docker run 実行\n\n```\n\n docker run -d --net=host \\\n -e \"FQDN=mqtt.example.com\" \\\n -e \"EMAIL=me@example.com\" \\\n -e \"DOMAIN=example.com\" \\\n -e \"IPLIST=172.16.16.16 192.168.1.254\" \\\n -e \"HOSTLIST=somehost.example.com docker.example.com\" \\\n -v /home/admin/mosquitto/conf.d:/etc/mosquitto/conf.d:z \\\n -t mosibi/mosquitto\n \n```\n\nすると\n\n```\n\n System error: exec format error\n \n```\n\nここからエラー探しやDockerFileの変更などをトライ&エラーで実行して現在に至る(長かった orz けど朧気ながら Docker\nの雰囲気がわかりました) \nここからが本題です。\n\n**【改変 DockerFile で実行したこと】** \nDockerFile\n\n```\n\n FROM schachr/raspbian-stretch:latest\n \n MAINTAINER admin <admind@example.com>\n \n ENV LC_ALL=\"C\" \\\n LANG=\"en_US.UTF-8\" \\\n TZ=\"Asia/Tokyo\"\n \n \n WORKDIR /tmp\n \n # Configure no init scripts to run on package updates.\n ADD files/policy-rc.d /usr/sbin/policy-rc.d\n RUN chmod 755 /usr/sbin/policy-rc.d && \\\n : dash を bash に変更 && \\\n ln -f /bin/bash /bin/sh && \\\n apt update && \\\n apt install -y rename openssl \\\n mosquitto mosquitto-clients && \\\n : mosquitto フォルダを空にする && \\\n rm -rf /etc/mosquitto && \\\n mkdir /etc/mosquitto\n \n # COPY files\n COPY volume /etc/mosquitto/\n COPY files/generate-CA.sh /usr/local/bin/generate-CA.sh\n COPY files/init /init\n RUN chmod 755 /usr/local/bin/generate-CA.sh && \\\n chmod 755 /init\n \n # generate-CA.sh 実行時のディレクトリ\n WORKDIR /etc/mosquitto/.ca\n \n # MQTT ports\n #EXPOSE 1883\n EXPOSE 8883\n EXPOSE 9001\n \n CMD [ \"/init\" ]\n \n```\n\nRaspberry Pi の tree\n\n```\n\n $HOME/SmartHome/\n ├─ README.md\n └─ docker\n └── mosquitto\n ├── Dockerfile\n ├── files\n │ ├── generate-CA.sh\n │ ├── init\n │ └── policy-rc.d\n └── volume\n ├── ca_certificates\n │ └── mqtt_ca.crt\n ├── certs\n │ ├── mqtt_srv.crt\n │ └── mqtt_srv.key\n ├── conf.d\n │ ├── mosquitto.conf\n │ └── websockets.conf\n ├── mosquitto.conf\n ├── mosquitto.conf.example\n └── password.txt\n \n```\n\n実行手順 \nDocker run したが直ぐに Exited となる。\n\n```\n\n $ cd SmartHome/docker/mosquitto\n $ docker build -t admin/mosquitto .\n $ docker run -it -d --name mosquitto --net=host \\\n -e \"FQDN=pi.example.us\" \\\n -e \"EMAIL=me@example.com\" \\\n -e \"DOMAIN=example.com\" \\\n -e \"IPLIST=192.168.0.220 172.20.10.220\" \\\n -e \"HOSTLIST=pi pi.local pi.example.us 192.168.0.220 172.20.10.220\" \\\n -v /home/admin/SmartHome/docker/mosquitto/volume:/etc/mosquitto \\\n -t admin/mosquitto\n $ docker ps -a\n ・・・ Exited (1) 10 seconds ago\n \n```\n\nDocker logs を見ると /init コマンドは実行されていることが分かった。\n\n```\n\n $ docker logs mosquitto\n /etc/mosquitto/.ca\n Generating a RSA private key\n ...............+++++\n ................................................+++++\n writing new private key to './ca.key'\n -----\n Created CA certificate in ./ca.crt\n subject=\n commonName = MQTT Broker example.com\n organizationName = example.com\n emailAddress = me@example.com\n Warning: the CA key is not encrypted; store it safely!\n --- Creating server key and signing request\n Generating RSA private key, 2048 bit long modulus\n ..+++++\n .....................................................................+++++\n e is 65537 (0x010001)\n --- Creating and signing server certificate\n Signature ok\n subject=CN = pi.example.us, O = example.com, emailAddress = me@example.com\n Getting CA Private Key\n total 28\n -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep\n -r--r--r-- 1 root root 1281 Jan 28 16:07 mqtt_ca.crt\n -r-------- 1 root root 1704 Jan 28 16:07 mqtt_ca.key\n -rw-r--r-- 1 root root 17 Jan 28 16:07 mqtt_ca.srl\n -r--r--r-- 1 root root 1891 Jan 28 16:07 mqtt_srv.crt\n -rw-r--r-- 1 root root 968 Jan 28 16:07 mqtt_srv.csr\n -r-------- 1 root root 1679 Jan 28 16:07 mqtt_srv.key\n /etc/mosquitto/\n total 60\n drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 .ca\n drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 ca_certificates\n drwxr-xr-x 2 1000 1000 4096 Jan 28 16:07 certs\n drwxr-xr-x 2 1000 1000 4096 Jan 28 16:00 conf.d\n -rw-r--r-- 1 1000 1000 750 Jan 28 16:00 mosquitto.conf\n -rw-r--r-- 1 1000 1000 33112 Jan 28 16:00 mosquitto.conf.example\n -rw-r--r-- 1 1000 1000 115 Jan 28 16:00 password.txt\n /etc/mosquitto/ca_certificates/\n total 8\n -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep\n -r--r--r-- 1 root root 1281 Jan 28 16:07 mqtt_ca.crt\n /etc/mosquitto/certs/\n total 12\n -rw-r--r-- 1 1000 1000 21 Jan 28 16:00 .gitkeep\n -r--r--r-- 1 root root 1891 Jan 28 16:07 mqtt_srv.crt\n -r-------- 1 root root 1679 Jan 28 16:07 mqtt_srv.key\n /etc/mosquitto/password.txt\n admin:$6$uXNbKcSuDpNZYcmHivYC1fg3neSmmsdLxlI5A==\n \n```\n\nマウントしたボリュームを見るとCA証明書類が作成されている。\n\n```\n\n $ ls -A SmartHome/docker/mosquitto/volume/.ca\n .gitkeep mqtt_ca.key mqtt_srv.crt mqtt_srv.key\n mqtt_ca.crt mqtt_ca.srl mqtt_srv.csr\n \n```\n\nコンテナをコミットして中に入る準備をする。\n\n```\n\n $ docker commit mosquitto debug\n $ docker run --rm -it debug /bin/bash\n \n```\n\n**ここから debug イメージの中** \ndebug イメージの中を確認するとCA証明書類はない(マウントのコマンドをしてないから多分)\n\n```\n\n $ pwd\n /etc/mosquitto/.ca\n $ ls -A\n .gitkeep\n \n```\n\nここで /init コマンドを実行してみる。\n\n```\n\n $ /init\n WARNING: Your kernel does not support memory swappiness capabilities, memory swappiness discarded.\n root@aba7a43aaeab:/etc/mosquitto/.ca# /init\n /etc/mosquitto/.ca\n Generating a RSA private key\n ..............................................................................+++++\n .................................................................................................................+++++\n writing new private key to './ca.key'\n -----\n Created CA certificate in ./ca.crt\n subject=\n commonName = MQTT Broker example.com\n organizationName = example.com\n emailAddress = me@example.com\n Warning: the CA key is not encrypted; store it safely!\n --- Creating server key and signing request\n Generating RSA private key, 2048 bit long modulus\n .................+++++\n ......+++++\n e is 65537 (0x010001)\n --- Creating and signing server certificate\n Signature ok\n subject=CN = pi.example.us, O = example.com, emailAddress = me@example.com\n Getting CA Private Key\n total 28\n -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep\n -r--r--r-- 1 root root 1281 Jan 28 16:40 mqtt_ca.crt\n -r-------- 1 root root 1708 Jan 28 16:40 mqtt_ca.key\n -rw-r--r-- 1 root root 17 Jan 28 16:40 mqtt_ca.srl\n -r--r--r-- 1 root root 1883 Jan 28 16:40 mqtt_srv.crt\n -rw-r--r-- 1 root root 968 Jan 28 16:40 mqtt_srv.csr\n -r-------- 1 root root 1675 Jan 28 16:40 mqtt_srv.key\n /etc/mosquitto/\n total 60\n drwxr-xr-x 1 root root 4096 Jan 28 16:40 .ca\n drwxr-xr-x 1 root root 4096 Jan 28 16:40 ca_certificates\n drwxr-xr-x 1 root root 4096 Jan 28 16:40 certs\n drwxr-xr-x 2 root root 4096 Jan 28 16:10 conf.d\n -rw-r--r-- 9 root root 750 Jan 28 16:00 mosquitto.conf\n -rw-r--r-- 9 root root 33112 Jan 28 16:00 mosquitto.conf.example\n -rw-r--r-- 9 root root 115 Jan 28 16:00 password.txt\n /etc/mosquitto/ca_certificates/\n total 8\n -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep\n -r--r--r-- 1 root root 1281 Jan 28 16:40 mqtt_ca.crt\n /etc/mosquitto/certs/\n total 12\n -rw-r--r-- 9 root root 21 Jan 28 16:00 .gitkeep\n -r--r--r-- 1 root root 1883 Jan 28 16:40 mqtt_srv.crt\n -r-------- 1 root root 1675 Jan 28 16:40 mqtt_srv.key\n /etc/mosquitto/password.txt\n admin:$6$uXNKcSuDpNZYWO9I$6FmqWeO==\n ▮\n \n```\n\nプロンプトが点滅している状態がずっと続いてる。Ctr-P,Ctr-Qで戻れない。\n\nここで違う端末のSSHで同じアカウントにログインして確認する。\n\n```\n\n $ docker ps\n CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n aba7a43aaeab debug \"/bin/bash\" 13 minutes ago Up 13 minutes 8883/tcp, 9001/tcp tender_poincare\n \n```\n\nExited にならずに Up になっている。\n\n以上が実行したことです。\n\nなぜ最初の Docker run で Exited となるのかがわかりません。 \n何かのヒントでもよろしいのでご指摘いただけませんでしょうか。 \nよろしくお願いいたします。\n\n【環境】 \nRaspberry Pi 3 B+ \n2018-11-13-Raspbian-Stretch-Lite \nDoccker version \nClient: \nVersion: 1.8.3 \nAPI version: 1.20 \nGo version: go1.4.3 \nGit commit: f4bf5c7 \nBuilt: \nOS/Arch: linux/arm \nServer: \nVersion: 1.8.3 \nAPI version: 1.20 \nGo version: go1.4.3 \nGit commit: f4bf5c7 \nBuilt: \nOS/Arch: linux/arm \n技量:初心者\n\n```\n\n /etc/mosquitto/mosquitto.conf はオリジナルのままです。\n \n $ cat /etc/mosquitto/conf.d/mosquitto.conf\n # 1883 はlocalhost 以外からは受け付けない\n listener 1883 localhost\n # TSL/SSL ポート\n listener 8883\n \n # 認証にパスワードファイルが必要になる\n #allow_anonymous false\n \n # パスワードファイル\n password_file /etc/mosquitto/password.txt\n \n # CA証明書\n cafile /etc/mosquitto/ca_certificates/mqtt_ca.crt\n \n # サーバー証明書\n certfile /etc/mosquitto/certs/mqtt_srv.crt\n \n # サーバーキー\n keyfile /etc/mosquitto/certs/mqtt_srv.key\n \n \n $ cat /etc/mosquitto/conf.d/websockets.conf\n listener 9001\n protocol websockets\n \n```\n\n/init です\n\n```\n\n #!/bin/bash\n \n if [[ \"new\" = \"$1\" ]] ||\n [[ ! -f /etc/mosquitto/ca_certificates/mqtt_ca.crt ]] ||\n [[ ! -f /etc/mosquitto/certs/mqtt_srv.key ]] ||\n [[ ! -f /etc/mosquitto/certs/mqtt_srv.crt ]]; then\n \n cd /etc/mosquitto/.ca\n pwd\n rm -rf *\n # CA証明書生成\n /usr/local/bin/generate-CA.sh ${FQDN}\n # ca.xxx ファイルをリネーム\n /usr/bin/rename s/ca./mqtt_ca./ *\n # pi.example.us.xxx ファイルをリネーム\n /usr/bin/rename s/${FQDN}/mqtt_srv/ *\n ls -Al\n # mosquitto に配置\n cp -rf mqtt_ca.crt /etc/mosquitto/ca_certificates/\n cp -rf mqtt_srv.crt /etc/mosquitto/certs/\n cp -rf mqtt_srv.key /etc/mosquitto/certs/\n echo /etc/mosquitto/\n ls -Al /etc/mosquitto/\n echo /etc/mosquitto/ca_certificates/\n ls -Al /etc/mosquitto/ca_certificates/\n echo /etc/mosquitto/certs/\n ls -Al /etc/mosquitto/certs/\n echo /etc/mosquitto/password.txt\n cat /etc/mosquitto/password.txt\n fi\n \n /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T08:14:17.897",
"favorite_count": 0,
"id": "52373",
"last_activity_date": "2019-02-06T10:06:58.750",
"last_edit_date": "2019-01-28T08:42:48.757",
"last_editor_user_id": "19605",
"owner_user_id": "19605",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"docker",
"raspberry-pi",
"raspbian",
"ssl"
],
"title": "Raspberry Pi (Raspbian stretch) 上の Docker で Mosquitto が直ぐ Exited してしまう。",
"view_count": 332
} | [
{
"body": "自己解決いたしました。 \n様々なOSイメージを取り換えながら実行してようやく実行できる環境に出会えました。 \nFROM arm32v7/buildpack-deps:stretch",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-06T10:06:58.750",
"id": "52594",
"last_activity_date": "2019-02-06T10:06:58.750",
"last_edit_date":... | 52373 | 52594 | 52594 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "URLのプログラムと同じです。 \n輪郭を長方形で囲むところまでは出来ています! \nそこから座標をだしたいのですがなかなか上手くいきません。 \nよろしくお願いいたします。 \n<https://docs.opencv.org/2.4/doc/tutorials/imgproc/shapedescriptors/bounding_rects_circles/bounding_rects_circles.html>\n\n```\n\n #include \"opencv2/highgui/highgui.hpp\"\n #include \"opencv2/imgproc/imgproc.hpp\"\n #include <iostream>\n #include <stdio.h>\n #include <stdlib.h>\n \n using namespace cv;\n using namespace std;\n \n Mat src; Mat src_gray;\n int thresh = 100;\n int max_thresh = 255;\n RNG rng(12345);\n \n /// Function header\n void thresh_callback(int, void* );\n \n /** @function main */\n int main( int argc, char** argv )\n {\n /// Load source image and convert it to gray\n src = imread( argv[1], 1 );\n \n /// Convert image to gray and blur it\n cvtColor( src, src_gray, CV_BGR2GRAY );\n blur( src_gray, src_gray, Size(3,3) );\n \n /// Create Window\n char* source_window = \"Source\";\n namedWindow( source_window, CV_WINDOW_AUTOSIZE );\n imshow( source_window, src );\n \n createTrackbar( \" Threshold:\", \"Source\", &thresh, max_thresh, thresh_callback );\n thresh_callback( 0, 0 );\n \n waitKey(0);\n return(0);\n }\n \n /** @function thresh_callback */\n void thresh_callback(int, void* )\n {\n Mat threshold_output;\n vector<vector<Point> > contours;\n vector<Vec4i> hierarchy;\n \n /// Detect edges using Threshold\n threshold( src_gray, threshold_output, thresh, 255, THRESH_BINARY );\n /// Find contours\n findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );\n \n /// Approximate contours to polygons + get bounding rects and circles\n vector<vector<Point> > contours_poly( contours.size() );\n vector<Rect> boundRect( contours.size() );\n vector<Point2f>center( contours.size() );\n vector<float>radius( contours.size() );\n \n for( int i = 0; i < contours.size(); i++ )\n { approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );\n boundRect[i] = boundingRect( Mat(contours_poly[i]) );\n minEnclosingCircle( (Mat)contours_poly[i], center[i], radius[i] );\n }\n \n \n /// Draw polygonal contour + bonding rects + circles\n Mat drawing = Mat::zeros( threshold_output.size(), CV_8UC3 );\n for( int i = 0; i< contours.size(); i++ )\n {\n Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );\n drawContours( drawing, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point() );\n rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0 );\n circle( drawing, center[i], (int)radius[i], color, 2, 8, 0 );\n }\n \n /// Show in a window\n namedWindow( \"Contours\", CV_WINDOW_AUTOSIZE );\n imshow( \"Contours\", drawing );\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T11:09:07.647",
"favorite_count": 0,
"id": "52375",
"last_activity_date": "2019-01-30T21:55:13.697",
"last_edit_date": "2019-01-29T07:26:23.577",
"last_editor_user_id": "30446",
"owner_user_id": "30446",
"post_type": "question",
"score": 0,
"tags": [
"c++",
"opencv"
],
"title": "opencv c++で輪郭を四角で囲んだ後の四角の座標を出力したいです",
"view_count": 2697
} | [
{
"body": "cygwin64 で次のようにコンパイル・実行できたので同じようにすればなんとかなりそう。\n\n```\n\n $ cat piyo.cpp\n #include <iostream>\n #include \"opencv2/highgui/highgui.hpp\"\n \n int main() {\n cv::Rect r;\n r.x = 10;\n r.y = 20;\n r.width = 30;\n r.height = 40;\n std::cout << r << std::endl;... | 52375 | null | 52425 |
{
"accepted_answer_id": "52382",
"answer_count": 1,
"body": "<https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/get>\n\n```\n\n var obj = {\n get hoge() {\n }\n }\n \n```\n\nとするのと、\n\n```\n\n var obj = {\n hoge: function hoge() {\n }\n }\n \n```\n\nとするのとでは、なにが違うのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-28T14:04:53.990",
"favorite_count": 0,
"id": "52380",
"last_activity_date": "2019-01-28T16:28:02.757",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12896",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "javascript で get と 関数定義の違いが分からない",
"view_count": 1013
} | [
{
"body": "定義したプロパティの使い方が異なります。\n\n`get`で定義したプロパティは、参照すると`get`関数が自動的に呼び出されます。関数の返り値が参照結果として得られます。\n\n```\n\n var obj = {\n get hoge() {\n return \"abc\";\n }\n }\n \n console.log(obj.hoge) // \"abc\"\n \n```\n\n上の例のように、`obj.hoge`の値を得ようとすると`get`で定義した関数が自動的に呼び出されます。\n\n* * *\n\n一方、... | 52380 | 52382 | 52382 |
{
"accepted_answer_id": "52384",
"answer_count": 1,
"body": "現在、手元のWindows\nPCから、リモートデスクトップ接続でLAN内のワークステーションに接続しているのですが、下記の内部エラーが頻発する様になり困っています。ワークステーション側のPCにログインするとまた使える様になるのですが、またしばらくすると同じエラーが発生してしまいます。\n\n[](https://i.stack.imgur.com/Ydh27.png)\n\nどなたか解決策が有ればご教示頂けないでしょうか?\n\nなお、使用しているPCは以下の通りです。 \nノートPC: \n[](https://i.stack.imgur.com/rMef8.png)\n\nワークステーションPC: \n[](https://i.stack.imgur.com/aSeFA.png)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T01:22:37.673",
"favorite_count": 0,
"id": "52383",
"last_activity_date": "2021-03-09T01:02:28.603",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19869",
"post_type": "question",
"score": 0,
"tags": [
"windows-10"
],
"title": "リモートデスクトップの内部エラーが頻発して困っています。",
"view_count": 25352
} | [
{
"body": "検索するとこんなのが出てきました。これらを参考に調べてみてください。 \n以下の記事のいくつかにありますが、イベントログを調べるのが早いでしょう。\n\n**サーバ側コンピュータの空きリソースの少なさ** \nSessionImageSize値で確保されるメモリ領域の不足 \nワークステーションPCのグラフィックスが高機能だと発生しやすい\n\n[リモートデスクトップ「内部エラーが発生しました。」エラーの対処法](https://blog.halpas.com/archives/12327) \n[Windowsのリモートデスクトップ接続に失敗する場合の対処方法(RDPDD.dll fa... | 52383 | 52384 | 52384 |
{
"accepted_answer_id": "52391",
"answer_count": 2,
"body": "ログイン画面をphpで作成している初心者です。 \n同じPHPファイル内のログイン画面のhtmlとログイン機能を記載したphpを記入しています。\n\n```\n\n $query = \"SELECT * FROM user WHERE user_name =$_POST['name']\";\n \n```\n\nと書くと`$_POST['name']`の部分にエラー`(expression expected)`が出てしまします。 \n事前に変数の値を`$name=$_POST[name]`とおいたところ、まだ未入力の段階だとエラー(undefined\nvariable←確かにその通りである)が表示されてしまいます。\n\nどう書けばいいでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T02:27:04.390",
"favorite_count": 0,
"id": "52385",
"last_activity_date": "2019-01-29T06:58:51.837",
"last_edit_date": "2019-01-29T03:03:42.507",
"last_editor_user_id": "31799",
"owner_user_id": "31799",
"post_type": "question",
"score": 0,
"tags": [
"php",
"mysql"
],
"title": "PHP内に記述したSQLクエリで 'expression expected' エラーが発生してしまう",
"view_count": 1358
} | [
{
"body": "「まだ未入力の段階だとエラーが表示」というのなら、前後の行を含めて関係しそうな部分をすべて質問に書いておきましょう。\n\nちなみに勉強中の身には逆効果かもしれませんが、これらの記事に色々と解説があります。 \n[【初心者向け】PHP5とMySQLでつくるログイン機能のサンプルアプリケーション](http://replication.hatenablog.com/entry/2014/06/30/005815)\n\n[PHPとMySQLで新規登録とログインを実装する(PDO使用)](https://qiita.com/KosukeQiita/items/b56b3004413c999b985... | 52385 | 52391 | 52386 |
{
"accepted_answer_id": "52394",
"answer_count": 1,
"body": "PythonでGoogleMapAPIを動かし、地図中の一定範囲内の賃貸物件を検索したいのです。\n\n指示内容としては、例えば広島駅周辺なら\n\n```\n\n self.gmaps = googlemaps.Client(key=APIkey)\n result = self.gmaps.places_nearby((34.396872, 132.487693),radius,type='',keyword='')\n \n```\n\nこのような形のコードを書いているのですが、区役所、病院やレストラン、ホテルなどが引っかかってしまいます。 \n検索結果を絞るために `keyword='アパート'`\nなどと入力すると今度は結果が全く返ってきません。賃貸物件だけを抽出することができないまでも、もう少し絞り込む方法はないものでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T03:25:25.540",
"favorite_count": 0,
"id": "52387",
"last_activity_date": "2019-01-29T06:56:47.943",
"last_edit_date": "2019-01-29T03:35:41.637",
"last_editor_user_id": "3060",
"owner_user_id": "31964",
"post_type": "question",
"score": 0,
"tags": [
"python",
"api",
"google-maps"
],
"title": "グーグルマップAPIのNearby_Searchで、指定した範囲内の賃貸物件だけを返すようにしたい。",
"view_count": 356
} | [
{
"body": "使用しているライブラリは \n<https://github.com/googlemaps/google-maps-services-\npython/blob/master/googlemaps/places.py> \nでしょうか?\n\nソースの説明によると、keywordは検索に使用される言葉のようです。ただし\"アパート\"と設定するとGoogleが検索しに行った際に\"アパート\"の言葉が登録されていないと検索されないようです。(物件名が\"○○アパート\"なら検索されると思います) \nそもそもplaces_nearbyのメソッドはショップの検索などには有効そうですが、賃貸物... | 52387 | 52394 | 52394 |
{
"accepted_answer_id": "52725",
"answer_count": 1,
"body": "1epochの実行結果です. \nこの中の ETA, loss, val_loss は何を意味しているのでしょうか.\n\n```\n\n Epoch 1/100\n 8/5010 [..............................] - ETA: 1:38 - loss: 0.5944\n 464/5010 [=>............................] - ETA: 2s - loss: 0.4590 \n 920/5010 [====>.........................] - ETA: 1s - loss: 0.4514\n 1392/5010 [=======>......................] - ETA: 0s - loss: 0.4461\n 1872/5010 [==========>...................] - ETA: 0s - loss: 0.4462\n 2344/5010 [=============>................] - ETA: 0s - loss: 0.4403\n 2816/5010 [===============>..............] - ETA: 0s - loss: 0.4398\n 3296/5010 [==================>...........] - ETA: 0s - loss: 0.4359\n 3776/5010 [=====================>........] - ETA: 0s - loss: 0.4355\n 4232/5010 [========================>.....] - ETA: 0s - loss: 0.4342\n 4712/5010 [===========================>..] - ETA: 0s - loss: 0.4323\n 5010/5010 [==============================] - 1s 174us/step - loss: 0.4327 - val_loss: 0.4254\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T03:41:10.683",
"favorite_count": 0,
"id": "52388",
"last_activity_date": "2019-02-12T06:47:09.160",
"last_edit_date": "2019-01-30T01:57:52.867",
"last_editor_user_id": "21092",
"owner_user_id": "31965",
"post_type": "question",
"score": 1,
"tags": [
"python",
"keras"
],
"title": "kerasの実行結果の表示の意味を教えてください",
"view_count": 4274
} | [
{
"body": "ETA は estimated time of arrival\nの略で、1エポックあたりのトレーニングにかかる時間の予測のことです。エポック内の処理の進捗と残りのデータ量を使ってkerasが自動で予測して出力します。\n\nlossは訓練データの各バッチの損失値の平均、val_lossはそのエポックの最後にテストデータに対して計算された損失値です。エポックを重ねるごとにこの値がそれぞれ小さくなっていくと、モデルの学習が進んでいることになります。しかし、lossだけが下がるようになると過学習の疑いがあります。",
"comment_count": 0,
"content_lice... | 52388 | 52725 | 52725 |
{
"accepted_answer_id": "52393",
"answer_count": 1,
"body": "プログラミング初心者で、現在phpを利用してログイン画面を作成しました。 \nしっかりとした本などは所持していないため、基本的に検索ベースで作業しています。\n\n初めてで、尚且つ不慣れた状態でしたので \n①とにかく具体例を参照 \n②分からない箇所は調べる(それでも理解しきれない箇所も有) \n③基本のフォーマットが分からないため、コピペ \n④自分の作成したいwebページの形に変形 \nという形で行いました。\n\nこの作業過程で分からないところがあったので質問させてください。 \n■質問\n\n> ?php \n> session_start();\n>\n> // ログイン状態チェック \n> if (!isset($_SESSION[\"ID\"])) { \n> header(\"Location: login.php\"); \n> exit; \n> } \n> ?\n\nこのようにログイン状態を表す際や、ログインの時にheaderのlocationとありますがこれは何をしめしているのでしょうか?\n\nログインの際はpassword_verifyのif節の中に格納したので、パスワードが認証されればlocation以下のファイルに飛ぶ、と認識していました。 \nしかしログイン状態の時は特にどこかのページに飛ぶ機能が備わっているわけではないので、理解できませんでした。\n\nご教授いただけますと幸いです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T04:36:20.813",
"favorite_count": 0,
"id": "52390",
"last_activity_date": "2019-01-29T05:04:58.573",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31799",
"post_type": "question",
"score": 0,
"tags": [
"php",
"mysql"
],
"title": "ログイン機能の header locationについて",
"view_count": 222
} | [
{
"body": "```\n\n if (!isset($_SESSION[\"ID\"])){\n \n```\n\n[$_SESSION[\"ID\"]が存在しない時。](http://php.net/manual/ja/function.isset.php)\n\n```\n\n header(\"Location: login.php\");\n \n```\n\nブラウザーに対して、login.phpへリダイレクトする様に、[生の HTTP\nヘッダを送信する。](http://php.net/manual/ja/function.header.php)\n\n```\n\n ... | 52390 | 52393 | 52393 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "SPRESENSEで測位間隔の5Hz指定は可能でしょうか。 \nSpresense SDKのGNSSのサンプルコード(gnss/gnss_main.c)では、\n\n```\n\n set_opemode.cycle = 1000; /* Position notify cycle(msec step). */\n \n```\n\nとしており、200msecが指定可能なように見えたのですが、struct cxd56_gnss_ope_mode_param_s のコメントを見ると、\n\n```\n\n /** Positioning cycle[ms]\\n\n * The cycle data is 1000msec aligned only and\n * cannot set 0msec.\\n\n * (Init value 1000) */\n \n```\n\nとあり、1000msec単位でしか指定できないように見えます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T05:44:10.347",
"favorite_count": 0,
"id": "52395",
"last_activity_date": "2019-03-11T01:27:43.677",
"last_edit_date": "2019-01-29T06:29:15.247",
"last_editor_user_id": "3060",
"owner_user_id": "31963",
"post_type": "question",
"score": 1,
"tags": [
"spresense"
],
"title": "GNSSの測位間隔について",
"view_count": 288
} | [
{
"body": "回答が待ちきれず、実際にボードを購入して、試してみました。 \n結果、5Hz出力はできました。 \nコメントの「1000msec aligned only」は何なのか、不明ですが。。。 \n精度に問題が出るとか、消費電力が上がるとかなのかも。 \nそう思うことにします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-04T03:14:41.843",
"id": "52524",
"last_activity_date": "20... | 52395 | null | 52524 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "IPアドレスを使用してデスクトップまたはラップトップのファイルシステムにSSHまたはFTPで転送できるのと同じ方法で、電話番号を使用して電話機のファイルシステムにSSHまたはFTPで転送することは可能ですか。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T08:34:59.830",
"favorite_count": 0,
"id": "52398",
"last_activity_date": "2019-01-30T10:30:28.990",
"last_edit_date": "2019-01-30T10:30:28.990",
"last_editor_user_id": "19110",
"owner_user_id": "30795",
"post_type": "question",
"score": 0,
"tags": [
"ssh",
"ftp"
],
"title": "IPアドレスと電話番号",
"view_count": 258
} | [
{
"body": "電話回線とインターネットは、ネットワーク構成も運用形態も異なりますから、「同じ方法」というのは一般的には実現不可能です。\n\n送信側でファイルをGoogleドライブにアップロードしておき、携帯電話の番号をつかってショートメッセージ(SMS)でアップロードした場所を知らせる。 \n受信側(携帯電話)では、SMSのメッセージを読み取ってGoogleドライブからファイルをダウンロードするアプリを稼働させておく(もしくは携帯電話の持ち主がSMSを読んで、ファイル転送アプリを操作する)。 \nというような仕掛けを作っておけばファイルの転送は可能だと思います。\n\nGoogleドライブとのやり取りに... | 52398 | null | 52421 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "OpenAMでAD連携してユーザーを取り込みました \nAD連携したユーザーでOpenAMにログインする \nユーザーごとに権限を付与する為にはどういった項目を設定すればよいでしょうか\n\n### 発生している問題・エラーメッセージ\n\nAD連携したユーザーでOpenAMにログインすると以下のメッセージが表示される \n「このユーザーはアクティブではありません」となる\n\nADで取り込んだユーザーに対して何をしたらよいのかわからない\n\n### 試したこと\n\nOpenAMのPolicyをAD連携で取り込んだユーザーに適用させた\n\nOpenAMにAD連携したユーザーと同じIDをOpenAMに作成するとユーザーに権限を付けることができ、 \nOpenAMにログインも可能となった\n\n### 補足情報\n\nOpenAM 13.5",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T11:09:09.427",
"favorite_count": 0,
"id": "52400",
"last_activity_date": "2019-01-30T03:17:02.153",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31974",
"post_type": "question",
"score": 0,
"tags": [
"apache",
"tomcat",
"openssl",
"openldap"
],
"title": "OpenAMのAD連携について",
"view_count": 158
} | [
{
"body": "「このユーザーはアクティブではありません」のメッセージが表示されるときは、ユーザーの属性「ユーザー状態」が「非アクティブ」になっている時です。まずは以下を試してみて下さい。\n\n 1. OpenAMの管理コンソールにamadminでログイン\n 2. アクセス制御 > (ユーザーが登録されているレルム) > 対象 のタブをクリックし、該当ユーザーのプロファイルページを表示\n 3. 「ユーザー状態」を「非アクティブ」から「アクティブ」に変更",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"crea... | 52400 | null | 52403 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "下記エラーで躓いてます。 \nどなたかエラー解決への道導を示して下さいませんか。\n\nしたい事\n\n```\n\n viewでforeachを利用し各レコードを抽出し、\n さらに抽出したレコードに対しアロー演算子でプロパティを指定して、\n 各カラムのデータを取り出したい。\n \n```\n\nエラー文\n\n```\n\n Trying to get property 'id' of non-object (View: /var/www/html/resources/views/某/詳細.blade.php)\n \n```\n\n存在しない変数のプロパティやnullの値を参照した時に発生するエラー。\n\n該当ファイル \n[詳細.blade.php]\n\n```\n\n <tbody>\n @foreach($某 as $★ ←テーブル■■■■esの単数形) \n <tr>\n <td>{{ $某->id }}</td>\n campactで指定されている某を$某として使用\n \n =>@foreach($某 as $★) の★部分にどの変数を使えばいいのかがわからなくて躓いている\n \n```\n\n[某Controller.php]\n\n```\n\n public function show某(int $某Id): View\n {\n $某 = $this->某Service->retrieve某($某Id);\n return view('某.詳細', compact('★★★★'));\n }\n \n```\n\n関連ファイル \n[CarInspectionHistory.php]\n\n```\n\n public function 某InspectionHistory(): BelongsTo\n {\n return $this->belongsTo(某::class);\n }\n \n```\n\n[web.php]\n\n```\n\n Route::get('/某/詳細/{某_id}', '\\App\\Http\\Controllers\\某Controller@show某');\n \n```\n\n[某InspectionHistoriesSeeder.php]\n\n```\n\n public function run()\n {\n factory(App\\Models\\某InspectionHistory::class, 2500)->create();\n }\n \n```\n\n試した事 \n[1]\n\n```\n\n @foreach($某 as $★)\n の$★の部分を\n ・$★\n ・$★_inspection_histories\n ・$★ID\n ・$★s\n に変えてみたけれど同じエラー\n \n```\n\n[2]\n\n```\n\n public function show某(int $某Id): View\n {\n $car = $this->某Service->retrieve某($某Id);\n return view('某.detail', compact('某'));\n }\n の$某を$garsに、compact('某')をcompact('gar')にして、\n @foreach($gars as $gar)で試すも同じエラー\n \n```\n\n環境\n\n```\n\n Laravel Framework 5.7.22\n docker 18.09.1\n \n```\n\n余裕ある方ご回答願います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T11:43:58.027",
"favorite_count": 0,
"id": "52401",
"last_activity_date": "2023-06-04T10:07:20.877",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31572",
"post_type": "question",
"score": 0,
"tags": [
"php",
"laravel",
"laravel-5"
],
"title": "Laravelでviewにデータを渡して、ブラウザに表示させたいが躓いています。",
"view_count": 2183
} | [
{
"body": "Laravel の view ファイルにおいては、 controller から渡された変数を展開することができます。 \n例えば、\n\n```\n\n //@controller : ID $id のデータを取得して view に渡す\n $data = YourDataClass::find($id);\n return view('data.show', compact('data'));\n \n```\n\nとした場合、 view ファイル(resorces/views/data/show.blade.php)では\n\n```\n\n //@view\... | 52401 | null | 56349 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "SQLServerのお勉強で躓いています。\n\nやろうとした事は no, timestamp の2列から成る'table_a'に、 no, datetime, value\nの3列から成る'table_b'を左外部結合するという事です(両テーブルとも no, datetime がプライマリキー)。 \n結合条件は下記の通りです。\n\n * no: '='比較\n * timestamp:'table_b'の timestamp の中で、'table_a'の timestamp 以下の最大の timestamp\n\nあまり上手い説明ではないので、具体例として下記コードをご覧下さい。\n\n```\n\n IF object_id('table_a') IS NOT NULL\n DROP TABLE table_a;\n \n CREATE TABLE table_a (\n no INTEGER not null\n ,timestamp DATE not null\n ,CONSTRAINT pk_table_a PRIMARY KEY CLUSTERED (no, timestamp)\n );\n \n IF object_id('table_b') IS NOT NULL\n DROP TABLE table_b;\n \n \n CREATE TABLE table_b (\n no INTEGER not null\n ,timestamp DATE not null\n ,value INTEGER not null\n ,CONSTRAINT pk_table_b PRIMARY KEY CLUSTERED (no, timestamp)\n );\n \n BEGIN TRANSACTION;\n \n INSERT INTO table_a (no, timestamp) \n VALUES (1, '2018-01-01')\n ,(1, '2018-01-04')\n ,(1, '2018-01-05')\n ,(2, '2018-01-01')\n ,(2, '2018-01-03')\n ,(2, '2018-01-09')\n ,(3, '2018-01-10')\n ,(3, '2018-01-11')\n ,(3, '2018-01-12')\n ;\n \n INSERT INTO table_b (no, timestamp, value) \n VALUES (1, '2018-01-01', 101)\n ,(1, '2018-01-02', 102)\n ,(2, '2018-01-02', 202)\n ,(3, '2017-01-01', 301)\n ,(3, '2018-01-12', 312)\n ;\n COMMIT;\n \n SELECT *\n FROM table_a\n ;\n \n SELECT *\n FROM table_b\n ;\n \n \n -- Query A: I can get what I want.\n SELECT A.no\n ,A.timestamp\n ,B.value\n FROM (\n SELECT A.no\n ,A.timestamp\n ,(SELECT MAX(B.timestamp) \n FROM table_b as B \n WHERE B.no = A.no\n AND B.timestamp <= A.timestamp) as a_b_timestamp\n FROM table_a AS A\n ) as A\n LEFT OUTER JOIN table_b AS B\n ON A.no = B.no\n AND A.a_b_timestamp = B.timestamp\n WHERE A.no in (1, 2)\n ;\n \n -- Query B: This query's result set is the same with A.\n SELECT A.no\n ,A.timestamp\n ,B.value\n FROM table_a AS A\n LEFT OUTER JOIN table_b AS B \n ON A.no = B.no\n AND B.timestamp = (SELECT MAX(B.timestamp) \n FROM table_b as B \n WHERE B.no = A.no\n AND B.timestamp <= A.timestamp)\n WHERE A.no in (1, 2)\n ;\n \n -- Query C: The result set is far from what I expected, but I do not know reason.\n SELECT A.no\n ,A.timestamp\n ,B.value\n FROM table_a AS A\n LEFT OUTER JOIN table_b AS B \n ON A.no = B.no\n AND A.timestamp = (SELECT MAX(B.timestamp) \n FROM table_b as B \n WHERE B.no = A.no\n AND B.timestamp <= A.timestamp)\n WHERE A.no in (1, 2)\n ;\n \n```\n\nテーブルに以下のデータが準備されます。\n\ntable_a: \nno timestamp \n1 2018-01-01 \n1 2018-01-04 \n1 2018-01-05 \n2 2018-01-01 \n2 2018-01-03 \n2 2018-01-09 \n3 2018-01-10 \n3 2018-01-11 \n3 2018-01-12\n\ntable_b: \nno timestamp value \n1 2018-01-01 101 \n1 2018-01-02 102 \n2 2018-01-02 202 \n3 2017-01-01 301 \n3 2018-01-12 312\n\nコード内にQuery A, B, C とコメントされたクエリがありますが、得られる結果セットは以下の通りです。私がほしかったのは A, B なのですが、 C\nだけが異なる結果セットを返しています。\n\nQuery A,B の結果セット(これが欲しかった!): \nno timestamp value \n1 2018-01-01 101 \n1 2018-01-04 102 \n1 2018-01-05 102 \n2 2018-01-01 NULL \n2 2018-01-03 202 \n2 2018-01-09 202\n\nQuery C の結果セット(ほしいもの違う): \nno timestamp value \n1 2018-01-01 101 \n1 2018-01-01 102 \n1 2018-01-04 NULL \n1 2018-01-05 NULL \n2 2018-01-01 NULL \n2 2018-01-03 NULL \n2 2018-01-09 NULL\n\n困っているのは C の結果がなぜ上のようになるのかが上手く説明出来ない点です。 \nどなたか、理由をクリアに説明して頂けないでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-29T16:01:50.787",
"favorite_count": 0,
"id": "52404",
"last_activity_date": "2019-01-30T13:09:52.160",
"last_edit_date": "2019-01-29T23:24:17.667",
"last_editor_user_id": "4236",
"owner_user_id": "31975",
"post_type": "question",
"score": 2,
"tags": [
"sql",
"sql-server"
],
"title": "外部結合の結果が想定と異なるが理由がピンとこない",
"view_count": 161
} | [
{
"body": "table_bを外部結合するのに、table_bに関する条件が十分書かれていないのでは、期待する結果は得難いと言うのを意識しておかれた方がいいでしょう。\n\nQuery Cのサブクエリーはtable_aに依存した相関サブクエリーですから、table_aの行ごとに異なる値となります。最終的に`A.no in (1,\n2)`で絞り込むのでそこ以外は省くとこんな感じ。\n\n```\n\n MAX(B.timestamp)\n (1) 1 2018-01-01 2018-01-01\n (2) 1 2018-01-04 2018-01-02... | 52404 | null | 52405 |
{
"accepted_answer_id": "52409",
"answer_count": 1,
"body": "独習Cの第三版で不明点があったので質問させていただきます。\n\n以下引用ソースコードです。引用に問題などありましたらご指摘ください。\n\n```\n\n #include <stdio.h>\n \n int main(void)\n {\n printf(\"このプログラムはコンパイルできません\");\n int i; /* これを先に書くこと */\n i = 10;\n printf(\"%d\", i);\n \n return 0;\n }\n \n```\n\n出力と同じく本文中でも「以下の例は誤りですから、コンパイルエラーとなります。」とあったのですが、手元のgccとclangでコンパイルが通り実行も可能でした。\n\n題目としてはローカル変数を扱う内容の部分で、ブロック内で変数宣言をする際はそのブロックの先頭にしなければならないとあり、私は「宣言よりもprintfがあるとダメなのか」と思いながら書き試してみたのですが動いてしまい、よくわからなくなりました。\n\nこれはどういったことなのでしょう…読みやすさを重視して変数宣言の前の出力はするべきでないといった意味なのか、それとも昔はダメでいつからか上記のようなものがエラーを起こさなくなったのか、またはwin版のコンパイラと何か違うのか…問題ないなら無視したいのですが気になってしまいました。\n\n回答よろしくお願いします。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T01:58:23.173",
"favorite_count": 0,
"id": "52408",
"last_activity_date": "2019-01-30T02:49:36.347",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31979",
"post_type": "question",
"score": 2,
"tags": [
"c"
],
"title": "C言語の基礎(ローカル変数)",
"view_count": 1660
} | [
{
"body": "C言語の仕様が拡張されて、そうした記述を許すことになっています。 \n書籍は、その前に書かれたか、以前の仕様を前提に書かれているのでしょう。\n\n総体的に書かれた記事 \n[C言語 - Wikipedia](https://ja.wikipedia.org/wiki/C%E8%A8%80%E8%AA%9E)\n\n具体例を含む解説は、この記事などを参照してください。 \n[連載:C言語の最新事情を知る(1)C99の仕様](https://www.buildinsider.net/language/clang/01)\n\n> 変数宣言(C99/C11:§6.8.2) \n> ANSI... | 52408 | 52409 | 52409 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "IJCAD2018でVB.NETを使用して開発をしています。\n\n下記のソースコードにて、現在のビューに対して、前方クリップをオンオフしたり、クリップの距離を設定する関数を作ったのですが、これを呼ぶとエラーは出ませんが、画面に変化がありません。 \n処理後にGCAD側のビュー管理のダイアログで、前方クリップと距離の設定を見ても、処理が反映されていなかったです。 \nこれの正しいやり方を教えていただけないでしょうか。\n\n一方で、上記と同じようにGetCurrentViewで現在ビューを取得して、ビュー(ビューの中心やカメラの目標点)を編集して画面に更新を掛けることはできていますので、全く見当違いの書き方でもないような気がします。\n\n* * *\n\nコード:\n\nカレントビューの前方クリップのオンオフや、クリップ距離の指定がうまくいきません。\n\n```\n\n Private Sub SetFrontClipOnOf(ByVal blnEnabled As Boolean)\n Dim icdDoc As Document = IJCADApplication.DocumentManager.MdiActiveDocument\n Using icdTrans As Transaction = icdDoc.TransactionManager.StartTransaction\n Using acView As ViewTableRecord = icdDoc.Editor.GetCurrentView\n \n acView.FrontClipEnabled = blnEnabled\n icdDoc.Editor.SetCurrentView(acView)\n \n End Using\n icdTrans.Commit()\n End Using\n icdDoc.Editor.UpdateScreen()\n End Sub\n \n Private Sub SetFrontClipDist(byval dblDist as Double)\n Dim icdDoc As Document = IJCADApplication.DocumentManager.MdiActiveDocument\n Using icdTrans As Transaction = icdDoc.TransactionManager.StartTransaction\n Using acView As ViewTableRecord = icdDoc.Editor.GetCurrentView\n \n acView.FrontClipDistance = dblDist\n icdDoc.Editor.SetCurrentView(acView)\n \n End Using\n icdTrans.Commit()\n End Using\n icdDoc.Editor.UpdateScreen()\n End Sub\n \n```\n\n一方、全く同じようにCurrentViewを取得して指定位置にズームし、カメラターゲットをズーム箇所に合わせる処理は、うまくできています。\n\n```\n\n Public Sub ZoomRangeByAcView(CenPnt As Point3d, icdDoc As Document, ByVal dblRad As Double)\n \n Using icdTrans As Transaction = icdDoc.TransactionManager.StartTransaction\n Using acView As ViewTableRecord = icdDoc.Editor.GetCurrentView\n \n acView.Target = CenPnt\n \n Dim matWCS2DCS As Matrix3d\n matWCS2DCS = Matrix3d.PlaneToWorld(acView.ViewDirection)\n matWCS2DCS = Matrix3d.Displacement(acView.Target - Point3d.Origin) * matWCS2DCS\n matWCS2DCS = Matrix3d.Rotation(-acView.ViewTwist, _\n acView.ViewDirection, _\n acView.Target) * matWCS2DCS\n matWCS2DCS = matWCS2DCS.Inverse()\n \n Dim CenPntConv As Point3d = CenPnt.TransformBy(matWCS2DCS)\n acView.CenterPoint = New Point2d(CenPntConv.X, CenPntConv.Y)\n \n acView.Height = dblRad * 2\n acView.Width = dblRad * 2\n \n icdDoc.Editor.SetCurrentView(acView)\n \n End Using\n icdTrans.Commit()\n End Using\n icdDoc.Editor.UpdateScreen()\n \n End Sub\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T02:33:38.287",
"favorite_count": 0,
"id": "52410",
"last_activity_date": "2019-02-01T07:17:18.720",
"last_edit_date": "2019-01-30T02:39:16.050",
"last_editor_user_id": "3060",
"owner_user_id": "31981",
"post_type": "question",
"score": 0,
"tags": [
".net",
"vb.net",
"ijcad"
],
"title": "IJCAD 2018でビューの前方クリップのオンオフ",
"view_count": 89
} | [
{
"body": "IJCADの.NET\nAPIではViewTableRecordオブジェクトのFrontClipDistanceプロパティやFrontClipEnabledプロパティを変更しても反映されないようです。 \nObjectARXのsetFrontClipDistanceメソッドを使用した場合は、問題なくクリップクリップ距離を変更することが出来たので、恐らく.NET\nAPIの不具合だと思われます。 \nIJCADのサポートに、APIの不具合として報告した方が良いと思われます。",
"comment_count": 0,
"content_license": "CC BY-SA 4... | 52410 | null | 52475 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "IJCAD 2018 STD Standaloneで、カスタマイズコマンドを開発しているものです。\n\n質問内容: \nPolylineの図芯の位置がプロパティから、あるいはマス・プロパティから取得できないのでしょうか? \nオブジェクト・スナップでは指示できるので、取得する方法があると期待しています。面積は取得できていますが、図芯が取得できないので、LineとArcに展開して、求めていますが、処理に数秒の時間が掛かっています。 \n以上、お願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T03:05:03.977",
"favorite_count": 0,
"id": "52411",
"last_activity_date": "2019-02-01T07:25:17.687",
"last_edit_date": "2019-01-30T04:05:59.683",
"last_editor_user_id": "3060",
"owner_user_id": "31983",
"post_type": "question",
"score": 0,
"tags": [
".net",
"ijcad"
],
"title": "Polylineの図芯の求め方について",
"view_count": 164
} | [
{
"body": "ポリラインをリージョンに変換して、AreaPropertiesメソッドを使用することで図心などの値を取得できますが、どうやらIJCADのReginクラスには上記のメソッドが実装されていないようです。 \n他の方法としては、GetObjectSnapPointsメソッドを使用して図心にスナップされた場合の座標を取得することも可能です。 \nただ、.NET APIのObjectSnapModes列挙型にはARXのAcDb::kOsModeCentroidにあたる値がありませんので、\n\n```\n\n pline.GetObjectSnapPoints((ObjectSnapModes)... | 52411 | null | 52476 |
{
"accepted_answer_id": "52461",
"answer_count": 2,
"body": "プログラミング初心者です。\n\nデータベースの更新ができず他の方のエラー解決策を拝見していたのですが、オートコミットが原因であったという声がありました。\n\n調べてみたのですがいまいちつかめず。 \nautocommitとうのを設定しておくと、どこからでもデータベースの書換が可能ということでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T04:50:37.020",
"favorite_count": 0,
"id": "52413",
"last_activity_date": "2019-02-01T02:09:48.090",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31799",
"post_type": "question",
"score": 0,
"tags": [
"php",
"mysql",
"database"
],
"title": "オートコミットについて",
"view_count": 197
} | [
{
"body": "違います。オートコミットとは、SQLを実行すると自動的にコミット(変更を確定)することです。\n\nデータベースの更新ができないのであれば、まずはアプリのログをみてください",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T05:32:23.910",
"id": "52415",
"last_activity_date": "2019-01-30T05:32:23.910",
"last_edit_date": null,
... | 52413 | 52461 | 52415 |
{
"accepted_answer_id": "52420",
"answer_count": 2,
"body": "PandasのDataframeで、特定条件の数値を統一したいです。 \n例えばこのようなdfがあります。\n\n```\n\n id label\n 0 a 1\n 1 a 2\n 2 a 1\n 3 b 2\n 4 b 2\n 5 c 2\n 6 a 1\n 7 b 1\n 8 b 2\n \n```\n\naとbは複数のラベルを持っているため、数の多いラベルをidのラベルにしたいです。 \nつまり、aのラベルを全て1に、bのラベルを全て2に統一したいです。 \nこの作業に対して2つの案を考えました。\n\n1.value_countsで集計してwhere, applyで置き換える\n\n```\n\n def change_label(old_l,new_l):\n return new_l\n \n ids = new_df['id'].unique()\n for i in trange(len(ids)):\n new_label = list(new_df[new_df['id']==ids[i]]['label'].value_counts().items())[0][0]\n new_df['label'].where(new_df['id'] != ids[i], \n new_df['label'].apply(lambda x:change_label(x,new_label)), \n inplace=True)\n \n```\n\n2.重複データは最終的に必要がないので、value_countsで集計したあとに辞書に入れる\n\n```\n\n ids = new_df['id'].unique()\n new_dict = {}\n for i in trange(len(ids)):\n if new_df[new_df['id']==ids[i]]['label'].nunique()>1:\n new_label = list(new_df[new_df['id']==ids[i]]['label'].value_counts().items())[0][0]\n new_dict.update({ids[i]:new_label})\n else:\n new_dict.update({ids[i]:new_df[new_df['id']==ids[i]]['label'].unique()[0]})\n \n```\n\n案2は案1より高速化できたが、実際大量なデータを扱うため、さらに高速化したいです。 \n他に知見がありましたら、ご教示願いたいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T05:31:53.247",
"favorite_count": 0,
"id": "52414",
"last_activity_date": "2019-01-30T08:07:42.093",
"last_edit_date": "2019-01-30T05:35:19.250",
"last_editor_user_id": "19110",
"owner_user_id": "31068",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"pandas"
],
"title": "Pandasでのデータ処理を高速化したい",
"view_count": 1557
} | [
{
"body": "df.loc[df[\"id\"] == \"a\", \"label\"] = 1",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T07:27:59.913",
"id": "52418",
"last_activity_date": "2019-01-30T07:27:59.913",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_u... | 52414 | 52420 | 52420 |
{
"accepted_answer_id": "52500",
"answer_count": 1,
"body": "```\n\n <div id=\"hoge\"></div>\n \n```\n\n上記のような中身が空の要素をCapybaraのfindで見つけたいのですが、ヒットしません。\n\n```\n\n find(\"#hoge\") # => Capybara::ElementNotFound Exception: Unable to find visible css \"#hoge\"\n \n```\n\nヒットさせる方法はありますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T05:51:47.933",
"favorite_count": 0,
"id": "52416",
"last_activity_date": "2019-02-02T06:19:36.020",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"capybara"
],
"title": "Capybaraのfindメソッドで中身が空の要素をヒットさせたい",
"view_count": 152
} | [
{
"body": "```\n\n find('#hoge', visible: :all)\n \n```\n\nとするとヒット出来ます。Capybaraはデフォルトではvisibleでないエレメントはfindしません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-02T06:19:36.020",
"id": "52500",
"last_activity_date": "2019-02-02T06:19:36.020",
"las... | 52416 | 52500 | 52500 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "`<input type=\"hidden\">`と同じ要領で`<select\ntype=\"hidden\">`にしたところ、受け取る際に`<input>`のValueでは表示できました。 \n同じように`<select type>`で既に一度選んだものの情報をvalueで表示するにはどうせればいいのでしょうか?\n\n[<input>のvalue値をプルダウンメニューから受け取りたいのです -\n教えて!goo](https://oshiete.goo.ne.jp/qa/6016233.html)\n\n参考にこちら拝見したのですがPHP,HTMLではなかったので適応させられませんでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T09:04:16.590",
"favorite_count": 0,
"id": "52424",
"last_activity_date": "2019-01-30T10:59:51.473",
"last_edit_date": "2019-01-30T10:59:51.473",
"last_editor_user_id": "3060",
"owner_user_id": "31799",
"post_type": "question",
"score": 0,
"tags": [
"php",
"html"
],
"title": "select typeのプルダウンの情報を、hiddenで次のページまでもって行きたい",
"view_count": 2606
} | [] | 52424 | null | null |
{
"accepted_answer_id": "52438",
"answer_count": 1,
"body": "入力画面と確認画面(入力した内容を確認する画面)があった場合、入力画面で入力した値のエラーチェックは入力画面のファイルでコードを書いてエラーチェックを行うのが適切なのでしょうか。あるいは確認画面のファイルでエラーチェックでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T10:44:53.610",
"favorite_count": 0,
"id": "52426",
"last_activity_date": "2019-01-31T01:41:38.990",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17348",
"post_type": "question",
"score": 1,
"tags": [
"php"
],
"title": "エラーチェック対応のコードを書くファイルについて。",
"view_count": 97
} | [
{
"body": "入力項目ごとに個別に行う入力エラーチェックは入力画面で即座に行うのが適切でしょう。\n\n> 入力画面でsubmitボタンを押す \n> →遷移先の確認画面に「パスワードは大文字、小文字、数字が必須です」と表示される \n> →「戻る」ボタンで入力画面に戻る \n> →パスワードのテキストボックスで再入力 \n> →入力画面でsubmitボタンを押す \n> →遷移先の確認画面に「パスワードは〇文字以上入力してください」と表示される\n\n上記のUXよりも、入力時にテキストチェンジイベントでバリデーションチェックする下記のエラーチェックの方がユーザ体験が優れています。 \n... | 52426 | 52438 | 52438 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Hibernate5.2.17.Finalをダウンロードしました。しかしどのJARファイルを選べばいいのかわかりません。\n\nインターネット上の日本語のサイトはバージョンが古いものが多く、私が落としたzipファイルにはないものばかりで困っています。\n\nとりあえずrequiredフォルダに含まれるものは全部必要でしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T12:42:48.377",
"favorite_count": 0,
"id": "52429",
"last_activity_date": "2019-01-30T15:41:29.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"java",
"hibernate"
],
"title": "Hibernateについて",
"view_count": 76
} | [
{
"body": "> とりあえずrequiredフォルダに含まれるものは全部必要でしょうか?\n\nその通りです。\n\n* * *\n\ndocumentationディレクトリにドキュメントが展開されていると思います。 \n同じものがwebでも参照できますが、 \nquickstartの[1.2. Release Bundle\nDownloads](http://docs.jboss.org/hibernate/orm/5.2/quickstart/html_single/#_release_bundle_downloads)節に説明があります。\n\n> The lib/required/ direct... | 52429 | null | 52433 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "下記のようなexcel-macroでxlwings経由でpython関数を実行しています。しかしどうあがいても、揮発性関数扱い(Open、Any-\ncell変化時に再計算)されています。 \nこれまで確認した内容としては、\n\n1) vba側でいきなり0などの値を返す。→これのみ非揮発性に変化\n\n```\n\n MLMprdct = 0 'Py.CallUDF(Tar_pyfile, \"MLMprdct\", Array(Model, Labels, Xn, OutRs, OutCs, enslst), ThisWorkbook, Application.Caller)\n \n```\n\n2) python側で、値をすぐ返す。 → 揮発性のまま\n\n```\n\n return(Xn[:,:2])#(MLMprd_calc(Mdlfile, Labels, OutRs, OutCs, lst, Xn))\n \n```\n\n3) XnがRange渡し(python側でvalue化)をValue渡しにしてpython側では一切excelを触らない → 揮発性のまま\n\n**vba:**\n\n```\n\n MLMprdct = Py.CallUDF(Tar_pyfile, \"MLMprdct\", Array(Model, Labels, Xn.value, OutRs, OutCs, enslst), ThisWorkbook, Application.Caller)\n \n```\n\n**python**\n\n```\n\n ♯♯@xw.arg('rXn', xw.Range)\n ♯♯def MLMprdct(Mdlfile, Labels, rXn='', OutRs=1, OutCs=2, lst=''): \n def MLMprdct(Mdlfile, Labels, Xn, OutRs=1, OutCs=2, lst=''): \n Xn = np.array(Xn) #rXn.resize(OutRs).expand('right').options(np.array).value\n \n```\n\n「私のxlwings‐UDF関数は非揮発性ですよ」という方いらっしゃいますか? いたら教えていただけないでしょうか?\n\n**vba:**\n\n```\n\n Public Function MLMprdct(Model As String, Labels As String, Xn As Range, Optional OutRs As Long = 1, Optional OutCs As Integer = 2, Optional enslst As String = \"\") 'Private\n Application.Volatile (False) 'don't work\n sta = Time()\n If TypeOf Application.Caller Is Range Then On Error GoTo failed\n MLMprdct = Py.CallUDF(Tar_pyfile, \"MLMprdct\", Array(Model, Labels, Xn, OutRs, OutCs, enslst), ThisWorkbook, Application.Caller)\n Debug.Print \"MLM:\", Application.Caller.Address(, , , True), Time() - sta\n Exit Function\n failed:\n MLMprdct = Err.Description\n End Function\n \n```\n\n**python:(最上層のみ)**\n\n```\n\n @xw.func\n @xw.arg('rXn', xw.Range)\n def MLMprdct(Mdlfile, Labels, rXn='', OutRs=1, OutCs=2, lst=''): \n Xn = rXn.resize(OutRs).expand('right').options(np.array).value\n return(MLMprd_calc(Mdlfile, Labels, OutRs, OutCs, lst, Xn))\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T14:57:40.717",
"favorite_count": 0,
"id": "52432",
"last_activity_date": "2019-07-07T13:02:35.343",
"last_edit_date": "2019-01-30T15:58:29.973",
"last_editor_user_id": "3060",
"owner_user_id": "31989",
"post_type": "question",
"score": 0,
"tags": [
"python",
"vba"
],
"title": "xlwingsのUDFは、エクセルでは必ず揮発性関数扱いになるのでしょうか?",
"view_count": 452
} | [
{
"body": "自己回答です。単純でした。pythonは関係ないです。最終的に、以下のようなvba\nFunctionで、他セルを参照した場合、参照先(の参照先...)に、Offset等揮発性関数があると、どんなCellを更新しようが再計算が伝達して結局再計算します。すなわち、Book中のとあるSheetを更新しただけで、OffsetがはいっているSheetはすべて再計算されることになります。やっと納得できました。 \n対策は、1)Offsetを使わない。か、2)Worksheets(\"Sheet1\").EnableCalculation = False\nで更新時の計算範囲を極力少なくするしかないようで... | 52432 | null | 52511 |
{
"accepted_answer_id": "52437",
"answer_count": 1,
"body": "[GKEにRailsをdeployしてみる](https://www.enisias.cloud/kubernetes/483/) \nを参考に今rubyonrails行っているのですが\n\nmyrails_deployment.yaml:\n\n```\n\n apiVersion: extensions/v1beta1\n kind: Deployment\n metadata:\n name: myrails\n spec:\n replicas: 1\n template:\n metadata:\n labels:\n app: myrails\n spec:\n containers:\n - name: myrails\n image: makotooishi/myrails:latest\n ports:\n - containerPort: 3000\n env:\n - name: MYSQL_ROOT_PASSWORD\n valueFrom: \n #secretを参照\n secretKeyRef:\n name: myrails-secret\n key: db_password\n - name: DB_HOST_NAME\n value: bold-monkey-mariadb\n command: [\"bundle\", \"exec\", \"rails\", \"server\", \"-p\", \"3000\", \"-b\", \"0.0.0.0\"]\n \n```\n\nのところでエラーがでます。\n\n```\n\n error: error parsing myrails_deployment.yaml: error converting YAML to JSON: yaml: line 23: did not find expected key\n \n```\n\n`create secret generic myrails-secret --from-literal=db_password=password` \nで再度作り直し\n\n`kubectl get secrets myrails-secret -o yaml`\n\n```\n\n apiVersion: v1\n data:\n db_password: cGFzc3dvcmQ=\n kind: Secret\n metadata:\n creationTimestamp: \"2019-01-31T09:15:28Z\"\n name: myrails-secret\n namespace: default\n resourceVersion: \"1199\"\n selfLink: /api/v1/namespaces/default/secrets/myrails-secret\n uid: c03d81cf-2538-11e9-b191-42010a920003\n type: Opaque\n \n```\n\nのように作成できました。 \nその後myrails_deployment.yaml: \nを行ったんですが次に下記のエラーがでましたので、\n\n```\n\n error: error validating \"myrails_deployment.yaml\": error validating data: [ValidationError(Deployment.spec): unknown field \"command\" in io.k8s.api.extensions.v1beta1.DeploymentSpec, ValidationError(Deployment.spec.template.spec.containers[0].env[0]): unknown field \"key\" in io.k8s.api.core.v1.EnvVar]; if you choose to ignore these errors, turn validation off with --validate=false\n \n```\n\nmyrails_deployment.yaml: \nを下記のように書き換えました\n\n```\n\n apiVersion: extensions/v1beta1\n kind: Deployment\n metadata:\n name: myrails\n spec:\n replicas: 1\n template:\n metadata:\n labels:\n app: myrails\n spec:\n containers:\n - name: myrails\n image: makotooishi/myrails:latest\n ports:\n - containerPort: 3000\n command: [\"bundle\", \"exec\", \"rails\", \"s\", \"-p\", \"3000\", \"-b\", \"0.0.0.0\"]\n env:\n - name: MYSQL_ROOT_PASSWORD\n valueFrom:\n secretKeyRef:\n name: myrails-secret\n key: db_password\n \n```\n\nで次に下記エラーがでました\n\n```\n\n error: error parsing myrails_deployment.yaml: error converting YAML to JSON: yaml: line 16: did not find expected key\n \n```\n\n何とか動かしたいのですが、誰か教えてください。お願いします",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-30T20:58:29.810",
"favorite_count": 0,
"id": "52435",
"last_activity_date": "2019-12-02T10:01:15.230",
"last_edit_date": "2019-01-31T09:48:25.167",
"last_editor_user_id": "19329",
"owner_user_id": "19329",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"kubernetes"
],
"title": "Google Kubernetes Engine(GKE)にデプロイできない",
"view_count": 237
} | [
{
"body": "23行目で指定しているkey\n\n>\n```\n\n> key: db_password\n> \n```\n\nが無い、というエラーなので、本来あるべき通りにSecretリソースが作成されていない、つまり、参照されているページで言うところの\n\n>\n```\n\n> kubectl create secret generic myrails-secret --from-\n> literal=db_password=password\n> \n```\n\nコマンドが正しく実行されていない(例えば `db_password` という文字列を打ち間違えているとか)が原... | 52435 | 52437 | 52437 |
{
"accepted_answer_id": "52444",
"answer_count": 1,
"body": "MySQLの複数のバックアップデータを一度にリカバリーする方法をお尋ねしたいです。\n\nmysqldumpコマンドを使って、いくつかのテーブルの保存をとりました。 \nここでは仮に以下のようにしておきます。\n\n```\n\n mysqldump -u root -pxxxxxxxxxx mytable > mytable.2019-01-30.sql\n \n```\n\nこの方法をつかって、定期的にバックアップをとっておりました。 \nただ途中でtableのサイズが大きくなりますので、バックアップをとった後は、drop tableを使って削除して、また新たにcreate table\nmytableを作っています。\n\n結果として、 \nmytable.2019-01-30.sql \nmytable.2019-01-23.sql \nmytable.2019-01-16.sql \nを作成したとしてください。\n\nリカバリーの方法としては、\n\n```\n\n mysql -u root -pxxxxxxxxxx DATABASE < mytable.2019-01-30.sql\n \n```\n\nでバックアップデータを回復させることは知っております。\n\n現在困っていることは、\n\n```\n\n mysql -u root -pxxxxxxxxxx DATABASE < mytable.2019-01-30.sql\n mysql -u root -pxxxxxxxxxx DATABASE < mytable.2019-01-23.sql\n mysql -u root -pxxxxxxxxxx DATABASE < mytable.2019-01-16.sql\n \n```\n\nと行ったときに、最後(?)のtableしかリカバリーされないことです。(他2つのtableは消去(?)されてしまいます。)\n\ntable名が同じで、中身のstructureも同じtableを「追加」でリカバリーして、3つのsqlファイルを1つのtableでリカバリーさせる方法はございますでしょうか?\n\n具体的には、 \nmytable.2019-01-30.sql \nmytable.2019-01-23.sql \nmytable.2019-01-16.sql \nのファイル内容をすべてmytableに再収納させたいです。\n\nファイルをリカバリーさせて、renameでtable名を変更しておき、最後に2つのmytableを結合させる方法はしっておりますが、復元させないといけないファイル数が多いため、別の方法を探しています。\n\nもしご存知の方がおられましたら、ご教授をお願いします。 \nよろしくお願いします。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T02:54:12.810",
"favorite_count": 0,
"id": "52440",
"last_activity_date": "2019-01-31T16:05:17.563",
"last_edit_date": "2019-01-31T16:05:17.563",
"last_editor_user_id": "11048",
"owner_user_id": "11048",
"post_type": "question",
"score": 2,
"tags": [
"mysql"
],
"title": "MySQLの複数のバックアップデータをリカバリーする方法",
"view_count": 413
} | [
{
"body": "ダンプ結果はテキスト形式でSQL文が書かれていますので、一度中身を覗いてみることをおすすめします。\n\n`mysqldump`をデフォルトで実行すると、ダンプしたSQLにはテーブル作成前に予め`drop\ntable`文が挿入されているので、複数回リストアを実行した場合にも最新分しか反映されないようになります。\n\n```\n\n DROP TABLE IF EXISTS `comments`;\n /*!40101 SET @saved_cs_client = @@character_set_client */;\n /*!40101 SET character_... | 52440 | 52444 | 52444 |
{
"accepted_answer_id": "52452",
"answer_count": 2,
"body": "やりたいこと: \n4byte文字と3byte文字が混在しているutf8の文字列の場合、4byte文字が混ざっていることを検出したい\n\n(文字コード等への理解が浅い者です) \n例えば「田直樹」という文字列があったとします。 \n一文字目が異体字で4byte、他の3文字はそれぞれ3byteです。こういった入力を許容できない文字として判別したいです。 \n一文字ずつループしてlen()などで見たらいいのかと思いきや、\n\n```\n\n s=\"田直樹\"\n for x in s.decode(\"utf8\"):print(x)\n ???\n ???\n 田\n 直\n 樹\n \n```\n\nこうなってしまい、一文字ずつ調べるといったことができずに困っています。\n\n文字列をunicodeに変換した際のことですが、下記のように問題の一文字目だけが\\Uで開始していることに気づきました。これを判別の材料にできないかと思っているのですが、どうするとこの記号を検出できるのかがわかっておりません。(この判別方法が正しいのかも自信がありません)\n\n```\n\n s.decode(\"utf8\")\n >>> u'\\U00020bb7\\u7530\\u76f4\\u6a39'\n \n```\n\n\\Uで始まる文字があったらそれは許容できない文字として判定しようとした場合、どのようにすると実現可能でしょうか。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T05:15:51.910",
"favorite_count": 0,
"id": "52443",
"last_activity_date": "2019-01-31T14:06:43.647",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25026",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python2"
],
"title": "Python2.7で、文字列の文字それぞれのバイト数を知りたい",
"view_count": 694
} | [
{
"body": "自己解決です。\n\n```\n\n t=\"田直樹\".decode(\"utf8\").encode(\"unicode_escape\")\n re.search(\"\\\\U\\w{8}\",t)\n <_sre.SRE_Match at 0x110c3dac0>\n \n```\n\nこの形で検索できそうです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T07:25:39.410",
"id": "52... | 52443 | 52452 | 52452 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "アコーディオンメニューでメニューを開閉の設定をしていますが、入力している項目だけ開いた状態にし、 \n他のメニューは閉じた状態にするにはどうすればいいでしょうか。\n\n<http://www.dataplan.jp/blog/css/3127> \nここのサイトを参考にして作りたいのですが、\n\n```\n\n <div id=\"accordion\" class=\"accordionbox\">\n <dl class=\"accordionlist\">\n <dt class=\"clearfix\">\n <div class=\"title\">\n <p>+、-切り替え</p>\n </div>\n <p class=\"accordion_icon\"><span></span><span></span></p>\n </dt>\n <dd>+、-切り替え</dd>\n <dt class=\"clearfix\">\n <div class=\"title\">\n <p>+、-切り替え</p>\n </div>\n <p class=\"accordion_icon\"><span></span><span></span></p>\n </dt>\n <dd>+、-切り替え</dd>\n </dl>\n </div>\n \n```\n\nJS\n\n```\n\n $(function(){\n $(\".accordionbox dt\").on(\"click\", function() {\n $(this).next().slideToggle(); \n // activeが存在する場合\n if ($(this).children(\".accordion_icon\").hasClass('active')) { \n // activeを削除\n $(this).children(\".accordion_icon\").removeClass('active'); \n }\n else {\n // activeを追加\n $(this).children(\".accordion_icon\").addClass('active'); \n } \n });\n });\n \n```\n\nCSS\n\n```\n\n .accordionbox{\n width: 50%;\n background:#FBDBC4;\n margin: 10px auto 40px;\n padding: 20px;\n }\n .accordionlist dt{\n display:block;\n background: #fff;\n padding: 20px 0 10px 5px;\n border-top: 1px solid #DFDFDF;\n }\n .accordionlist dt:first-child{\n border-top: none !important;\n }\n .accordionlist dt .title{\n padding-left: 10px;\n float: left;\n }\n .accordionlist dd{\n display:none;\n background: #fff;\n padding:0 0 20px 15px;\n }\n .accordion_icon,\n .accordion_icon span {\n display: inline-block;\n transition: all .4s;\n box-sizing: border-box;\n }\n .accordion_icon {\n position: relative;\n width: 30px;\n height: 30px;\n float: right;\n margin-right: 5px;\n }\n .accordion_icon span {\n position: absolute;\n left: 6px;\n width: 50%;\n height: 2px;\n background-color: #F88789;\n border-radius: 4px;\n -webkit-border-radius: 4px;\n -ms-border-radius: 4px;\n -moz-border-radius: 4px;\n -o-border-radius: 4px;\n }\n .accordion_icon span:nth-of-type(1) {\n top: 5px;\n transform: rotate(0deg);\n -webkit-transform: rotate(0deg);\n -moz-transform: rotate(0deg);\n -ms-transform: rotate(0deg);\n -o-transform: rotate(0deg);\n }\n .accordion_icon span:nth-of-type(2) {\n top: 5px;\n transform: rotate(90deg);\n -webkit-transform: rotate(90deg);\n -moz-transform: rotate(90deg);\n -ms-transform: rotate(90deg);\n -o-transform: rotate(90deg);\n }\n /*+、-切り替え*/\n .accordion_icon.active span:nth-of-type(1) {\n display:none;\n }\n .accordion_icon.active span:nth-of-type(2) {\n top: 5px;\n transform: rotate(180deg);\n -webkit-transform: rotate(180deg);\n -moz-transform: rotate(180deg);\n -ms-transform: rotate(180deg);\n -o-transform: rotate(180deg);\n }\n \n```\n\n```\n\n <dd>+、-切り替え</dd>\n \n```\n\nddで囲んだ部分に、 \nここの部分にcheckboxにチェック済みや \ninputの入力画面で入力済みの場合、 \nだと開いている状態にするにはどうすればよいのでしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T06:52:42.260",
"favorite_count": 0,
"id": "52446",
"last_activity_date": "2019-08-05T22:01:35.560",
"last_edit_date": "2019-01-31T14:58:44.013",
"last_editor_user_id": "2376",
"owner_user_id": "25636",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"html",
"css"
],
"title": "アコーディオンメニューで入力しているとき項目のみ開いた状態にする",
"view_count": 958
} | [
{
"body": "メニュー項目に対し開いた状態にしたい条件でフィルタをかけて、クリック時の表示制御と同様のことをする流れになると思います。\n\n以下は実装例です。\n\n```\n\n $(function() {\r\n // 初期開閉状態設定\r\n $(\".accordionbox dt\")\r\n .filter((i, e) => isActive($(e).next()))\r\n .each((i, e) => toggle($(e)));\r\n \r\n $(\".accordionbox dt\").on(\"clic... | 52446 | null | 52543 |
{
"accepted_answer_id": "52473",
"answer_count": 1,
"body": "サーバ上にクローンしたファイルを、エディターから開くには何をすればいいのでしょうか?\n\nWeb上で共有しているファイルを、tera termにcloneしました。 \nそのファイルの中身をローカルのAtomから、編集できるようにしたいです。 \nWindows10です。\n\nサーバ エディタ 連携 \nで検索かけたところ、FTPやSFTPというワードがてきてそれぞれ検索したのですが、まだリテラシーが低いため関係性が理解できませんでした。\n\nご教授ください。\n\n\\--追記-- \nFTP接続が有力そう...ですかね[FTP](https://wa3.i-3-i.info/word1137.html)\n\n\\--コメント受けての追記-- \nターミナルにcloneしただけだとviなどでファイルの編集は可能ですが、ローカルにあるatomだと編集できないという認識までは合っているのでしょうか? \nコマンドやpowershell上に落とせばローカルのファイルからGUIとして見れますよね? \nですが、今回はIPアドレスを打ち込んでSSH接続しているTeratermからなので、(cloneしたもの自体がまだサーバー上にありローカルではないから?、)Atomでは開けない\n\n初めて複数人で作業をするためgitを使用するの流れ自体曖昧で失礼します。 \n既に共有のブランチがブラウザ上にあり、それをIPアドレスでサーバに接続したTera term上にcloneしました。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T08:32:18.550",
"favorite_count": 0,
"id": "52448",
"last_activity_date": "2019-02-01T06:44:42.213",
"last_edit_date": "2019-02-01T06:18:18.360",
"last_editor_user_id": "31799",
"owner_user_id": "31799",
"post_type": "question",
"score": 0,
"tags": [
"atom-editor",
"teraterm"
],
"title": "エディタ(Atom)からTeratermにcloneしたデータを見る方法",
"view_count": 411
} | [
{
"body": "やりたいこと、質問の環境が\n\n・(gitでクローンした)編集したいファイルがリモートのサーバ上に置いてある \n・自身はローカルPC(Windows)上で作業をしている \n・ローカルPCのAtomエディタからリモートのファイルを編集したい\n\nだろうという前提で。いくつか方法が考えられます。私自身はAtomエディタを使用していないので、詳しい解説はできませんが、考えられる代わりの方法も含めてざっくりと紹介しておきます。\n\n### リモートとローカルでファイルの同期を行う\n\n既に調べられた方法がこちらになります。Atomエディタであれば「Remote-\nFTP」というパッケー... | 52448 | 52473 | 52473 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0 );\n \n```\n\nで、長方形の左上右下の座標はだせているのですが、それを利用しての重心の出し方がよくわからないです。brにx座標とy座標2つのデータ。同様にtlに2つのデータが入っています。 \nbrのx座標だけ、tlのx座標だけをそれぞれx1やx2などとして出せないでしょうか?\n\n```\n\n #include \"opencv2/highgui/highgui.hpp\"\n #include \"opencv2/imgproc/imgproc.hpp\"\n #include <iostream>\n #include <stdio.h>\n #include <stdlib.h>\n \n using namespace cv;\n using namespace std;\n \n Mat src; Mat src_gray;\n int thresh = 100;\n int max_thresh = 255;\n RNG rng(12345);\n \n /// Function header\n void thresh_callback(int, void* );\n \n /** @function main */\n int main( int argc, char** argv )\n {\n /// Load source image and convert it to gray\n src = imread( argv[1], 1 );\n \n /// Convert image to gray and blur it\n cvtColor( src, src_gray, CV_BGR2GRAY );\n blur( src_gray, src_gray, Size(3,3) );\n \n /// Create Window\n char* source_window = \"Source\";\n namedWindow( source_window, CV_WINDOW_AUTOSIZE );\n imshow( source_window, src );\n \n createTrackbar( \" Threshold:\", \"Source\", &thresh, max_thresh, thresh_callback );\n thresh_callback( 0, 0 );\n \n waitKey(0);\n return(0);\n }\n \n /** @function thresh_callback */\n void thresh_callback(int, void* )\n {\n Mat threshold_output;\n vector<vector<Point> > contours;\n vector<Vec4i> hierarchy;\n \n /// Detect edges using Threshold\n threshold( src_gray, threshold_output, thresh, 255, THRESH_BINARY );\n /// Find contours\n findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );\n \n /// Approximate contours to polygons + get bounding rects and circles\n vector<vector<Point> > contours_poly( contours.size() );\n vector<Rect> boundRect( contours.size() );\n vector<Point2f>center( contours.size() );\n vector<float>radius( contours.size() );\n \n for( int i = 0; i < contours.size(); i++ )\n { approxPolyDP( Mat(contours[i]), contours_poly[i], 3, true );\n boundRect[i] = boundingRect( Mat(contours_poly[i]) );\n minEnclosingCircle( (Mat)contours_poly[i], center[i], radius[i] );\n }\n \n \n /// Draw polygonal contour + bonding rects + circles\n Mat drawing = Mat::zeros( threshold_output.size(), CV_8UC3 );\n for( int i = 0; i< contours.size(); i++ )\n {\n Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );\n drawContours( drawing, contours_poly, i, color, 1, 8, vector<Vec4i>(), 0, Point() );\n rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0 );\n circle( drawing, center[i], (int)radius[i], color, 2, 8, 0 );\n }\n \n /// Show in a window\n namedWindow( \"Contours\", CV_WINDOW_AUTOSIZE );\n imshow( \"Contours\", drawing );\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T12:34:35.303",
"favorite_count": 0,
"id": "52451",
"last_activity_date": "2019-02-02T09:39:26.537",
"last_edit_date": "2019-02-01T10:11:43.117",
"last_editor_user_id": "30446",
"owner_user_id": "30446",
"post_type": "question",
"score": 0,
"tags": [
"c++",
"opencv"
],
"title": "opencv c++ 描いた長方形の重心と長方形の一番左のx座標一番右のy座標をだしたい",
"view_count": 1080
} | [
{
"body": "玉掛け試験受ける予定のオイラとしては「重心」の厳密定義が欲しいところですが、まあ普通には、一様な長方形の重心は対角線の交点ですし、それは単に中心ですよね。\n\n<http://opencv.jp/opencv-2svn/cpp/basic_structures.html> \nを見るに `Rect_` は、左上座標 `(x, y)` と大きさ `width, height` をメンバに持つクラステンプレートです。今使っている\n`Rect` (アンダースコアがないもの)は `typedef Rect_<int> Rect;` なので `int`\nで実体化したものであることがわかります。\n... | 52451 | null | 52458 |
{
"accepted_answer_id": "52455",
"answer_count": 1,
"body": "有線 LAN ⇔ 無線 LAN で TCP 通信すると、データが送信元と受信先で順番が相違する? 謎な現象が起こっています。\n\n無線 LAN, \n親機は BUFFALO WSR-300HP / WHR-G45S どちらでも発生 \n子機は Archer T2UH\n\n具体的には svn の使用中に気が付きました。数個ファイルを転送すると、つぎの 2 つのエラーが任意に発生します。\n\n```\n\n svn: E210004: Malformed network data\n \n svn: E140001: zlib (uncompress): corrupt data: Decompression of svndiff data failed\n \n```\n\nエラーが出るので仕方なく何回も `svn cleanup && svn up` をやっています。何回でもエラーが発生します。\n\nsvnserve (Windows Server 2012) は有線 LAN で、svn は無線 LAN 側 (Windows Server 2012)\nです。\n\nそこでテストプログラムを作り、相違が発生するかどうか検証しました。16 バイトの固定長文字列を延々と送信するプログラムです。\n\n`time is 0` \n`time is 1` \n`time is 2` \n`time is 3` \n...\n\n有線 LAN 側ではこのような内容を延々と送信し、無線 LAN 側はそれを受信して内容確認するプログラムです。\n\n結果、何回やっても異なる場所で順番の相違が発生しました。\n\n`Diff! [time is 2348 ] should be [time is 589 ]` \n`Diff! [time is 2431 ] should be [time is 469 ]` \n`Diff! [time is 2247 ] should be [time is 600 ]`\n\n無線 LAN 側でダイゼクタ… Wireshark を起動し、通信をキャプチャ。TCP Stream を追跡すると順番の相違はなく 0\nから順番にキレイに並んでいることを確認しました。\n\nTCP については詳しくないのですが、ウィンドウサイズ・シーケンス番号・ACK 番号とかそういったものの設定が関わってくるのでしょうか。\n\nこういった現象って一般に認知されていたり回避策があったりするのでしょうか…",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T13:17:57.243",
"favorite_count": 0,
"id": "52454",
"last_activity_date": "2019-01-31T14:20:09.527",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10036",
"post_type": "question",
"score": 0,
"tags": [
"windows",
"tcp",
"wifi"
],
"title": "無線 LAN 使用時の TCP データの順番の相違?",
"view_count": 265
} | [
{
"body": "[Transmission Control Protocol -\nデータ転送](https://ja.wikipedia.org/wiki/Transmission_Control_Protocol#%E3%83%87%E3%83%BC%E3%82%BF%E8%BB%A2%E9%80%81)で\n\n> TCP には以下のように User Datagram Protocol とは異なる重要な特徴がある。\n>\n> * データ転送時の順序を保証 - 受信側でシーケンス番号を使って並べ替えを行う。\n> * 喪失パケットの再送 - 確認応答のないセグメントは再送する。\n> * 誤り... | 52454 | 52455 | 52455 |
{
"accepted_answer_id": "52459",
"answer_count": 1,
"body": "こちら <https://www.komee.org/entry/2018/10/25/120000> のブログを参考に、\n\n```\n\n $ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash\n \n```\n\nを実行したら、次のように出力されました。\n\n> % Total % Received % Xferd Average Speed Time Time Time Current \n> Dload Upload Total Spent Left Speed \n> 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 \n> curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to\n> github.com:443\n\n\"curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to\ngithub.com:443\" \nと検索してみたのですが、よくわかりませんでした。 \nご教授のほど、よろしくおねがいします。\n\n* * *\n\n解決しました。 \nこちらの[リンク](https://qiita.com/cactanaka/items/190665cfaf3b927766da)を参考に、 \n設定 -> ネットワーク -> 暗号化された接続のスキャン を「暗号化された接続をスキャンしない」にすることで、コマンドが通るようになりました。 \nコメントを下さった皆様ありがとうございました。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T18:04:21.810",
"favorite_count": 0,
"id": "52457",
"last_activity_date": "2019-02-05T10:19:03.543",
"last_edit_date": "2019-02-05T10:19:03.543",
"last_editor_user_id": "30221",
"owner_user_id": "30221",
"post_type": "question",
"score": 1,
"tags": [
"ubuntu",
"windows-10",
"wsl",
"pyenv"
],
"title": "WSL(Ubuntu 18.04)でcurl -L (URL) | bashを実行するとエラーが出る",
"view_count": 6889
} | [
{
"body": "当てずっぽうですが…\n\n[Windows sybsystem for\nLinuxのSSL/TLSがKaspersky](https://qiita.com/cactanaka/items/190665cfaf3b927766da)に拒まれるといった話もあります。 \nウィルス対策ソフトを無効化することで改善する可能性があります。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-01-31T21:34:05.227",
"id": "52459",... | 52457 | 52459 | 52459 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "PCサイトとスマホサイトのURLが異なるため、リダイレクトさせようとして、`.htaccess`に以下のように記述しサーバーのルートドメインのみセットしました。\n\nスマホでPCトップページにアクセスするとうまく切り替わったのですが、PC下層ページが反映されません(スマホページに切り替わらない)。スマホサイトのトップページから下層ページに遷移すると(当然ですが)きちんとスマホサイトがでます。PC下層ページを直入力するとスマホ下層ページに切り替わりません。何が間違っているのか教えていただけませんでしょうか。\n\n`.htaccess`の記述は以下の通りです。\n\n```\n\n <IfModule mod_rewrite.c>\n RewriteEngine On\n RewriteCond %{HTTP_USER_AGENT} (iPhone|Android.*Mobile|Windows.*Phone) [NC]\n RewriteCond %{QUERY_STRING} !mode=pc\n RewriteRule ^$ /smt/ [R,L]\n </IfModule>\n \n```\n\nURLは以下の通りです。\n\n<TOP> \nPCサイト `http://www.〇〇〇.com/` もしくは `http://www.〇〇〇.com/index.html` \nスマホサイト `http://www.〇〇〇.com/smt`\n\n<下層> \nPCサイト `http://www.〇〇〇.com/△△△.html` \nスマホサイト `http://www.〇〇〇.com/smt/△△△.html`\n\nお手数になりますが、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-01T03:23:21.683",
"favorite_count": 0,
"id": "52466",
"last_activity_date": "2019-02-06T15:19:31.383",
"last_edit_date": "2019-02-01T07:16:42.993",
"last_editor_user_id": "7676",
"owner_user_id": "32003",
"post_type": "question",
"score": 0,
"tags": [
".htaccess"
],
"title": "PCとスマホをリダイレクトする.htaccesの設定について",
"view_count": 293
} | [
{
"body": ".htaccess の場合、パス「/a/b/c.html」の先頭の「/」が省かれた「a/b/c.html」が `RewriteRule` の対象となります。 \n現在の設定の `^$` だと、パス「/」のみを対象としていますので、トップページのみとなります。 \n正規表現、後方参照、あと、リダイレクトループにならないよう「/smt/」を除外するルールを考えてみてください。\n\n(追記) \n「/何らかのパス」→「/smt/何らかのパス」にするならば、以下の設定です。\n\n```\n\n RewriteRule ^(.*)$ /smt/$1 [R,L]\n \n```",
... | 52466 | null | 52504 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.