question
dict | answers
list | id
stringlengths 2
5
| accepted_answer_id
stringlengths 2
5
⌀ | popular_answer_id
stringlengths 2
5
⌀ |
---|---|---|---|---|
{
"accepted_answer_id": "44081",
"answer_count": 2,
"body": "コンパイルしたいのですが上手くいきません。できれば詳しめに解説をお願いします。\n\n[](https://i.stack.imgur.com/bW2WI.jpg)\n\nプログラム\n\n```\n\n #include \"pseudo97.h\"\n \n typedef struct PERSON* PtrPERSON;\n struct PERSON {\n char name[20];\n long year;\n PtrPERSON next;\n };\n \n int MakeLinkedList( PtrPERSON head)\n {\n PtrPERSON girl;\n New(girl);\n InputString( girl->name);\n InputInt(girl->year);\n \n while(girl->year >0){\n girl->next=head->next;head->next=girl;\n New(PtrPERSON , girl);\n InputString(girl->name);\n InputInt(girl->year);\n }\n \n return 0;\n }\n \n int main(void)\n {\n PtrPERSON head;\n New(PtrPERSON,head);\n head->next=NVLL;\n MakeLinkedList(head);\n // WriteLinkedList( head );\n \n return 0;\n }\n \n```\n\nコマンドの結果です。\n\n[](https://i.stack.imgur.com/cMIYu.jpg)",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T08:28:17.040",
"favorite_count": 0,
"id": "44078",
"last_activity_date": "2018-05-19T14:28:40.933",
"last_edit_date": "2018-05-19T14:28:40.933",
"last_editor_user_id": "3060",
"owner_user_id": "28572",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "コンパイルしたいのですが上手くいきません: pseudo97.h: No such file or directory",
"view_count": 21411
} | [
{
"body": "「pseudo97.h: No such file or directory」(直訳:pseudo97.hだって?\nそんなファイル見当たらない」というエラーですから、正しい場所にpseudo97.hを置けば解決します。\n\n1)pseudo97.h というファイルは、ありますか? \n質問に示されているコードは、自分で書いたものですか、それとも他人が書いたものですか。\n自分で書いたものならpseudo97.hがどこにあるか知っていらっしゃるでしょうが、他人が書いたもので、pseudo97.hがどこにある判らないのなら、コードの出典かコードの製作者に問い合わせるなどしてくだし。\n\n2)-I オプションは指定していますか? \nNo such file or directoryが出るという事は、標準的なincludeファイルの置き場所である /usr/include/\nにはpseudo97.hが置かれていないのだと思います。 \npseudo97.hの場所が判っているのなら、そのディレクトリを -Iオプションで指定することでコンパイルできるようになるはずです。 (-I\nオプションは、includeファイルの所在を探すパスを追加するものです)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T09:11:54.833",
"id": "44080",
"last_activity_date": "2018-05-19T09:11:54.833",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "44078",
"post_type": "answer",
"score": 0
},
{
"body": "まずエラーの内容を説明し、そのあとエラーの原因を推測した上で、解決法を書きます。\n\n### エラー内容\n\ngcc コマンドのエラー内容だけを取り出すと、以下のようになります。\n\n```\n\n print1.c:1:22: fatal error: pseudo97.h: No such file or directory\n \n```\n\nこのエラーは、おおまかに以下のことを言っています。\n\n * ファイル `print1.c` でエラーが起こっている。\n * `pseudo97.h` が必要とされているが、そのような名前のファイルやディレクトリは見つからない。\n\nつまり、`print1.c` の1行目で `#include` されているヘッダーファイル `pseudo97.h` が見つからない、というエラーです。\n\n### エラーの原因\n\nC\n言語の[標準ライブラリ](https://ja.wikipedia.org/wiki/%E6%A8%99%E6%BA%96C%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA)には\n`pseudo97.h` というヘッダーはないので、これは自前で用意されたヘッダーファイルです。おそらく書籍等で C\n言語を学習なさっていて、そちらから提供されているヘッダーファイルを上手く準備できていないのでしょう。\n\nまた質問者さんは1行目を `#include \"pseudo97.h\"` から `#include <pseudo97.h>`\nに変えて試されているようです。たしかに `#include` のあとを `\"ぴよぴよ\"` にするか `<ぴよぴよ>`\nにするかでは、意味が違います。今回の場合は `#include \"pseudo97.h\"` にすることになるでしょう。\n\n### 解決法\n\n参考になさっている書籍等を確認して、`pseudo97.h` というファイルが提供されていないか確認してください。\n\n今回は質問者さんのデスクトップ (`C:\\Users\\babachan\\Desktop`) 上で作業なさっているようですから、とりあえず\n`pseudo97.h` をデスクトップに置けば、gcc が `pseudo97.h` を見つけてくれるようになるので、このエラーは解決します。\n\n`No such file or directory` はでなくなったものの他のエラーが出た場合、追加でご質問頂ければと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T09:16:35.497",
"id": "44081",
"last_activity_date": "2018-05-19T09:16:35.497",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "44078",
"post_type": "answer",
"score": 0
}
] | 44078 | 44081 | 44080 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "[](https://i.stack.imgur.com/LIyKZ.jpg)\n\n```\n\n if(strlen($item->T03_PROMOTION_TITLE)>31) echo mb_substr( $item->T03_PROMOTION_TITLE, 0, 26,\"UTF8\"); else echo $item->T03_PROMOTION_TITLE;?></a></div>\n <div class=\"bs_font16 ellipsis\"><a class=\"\" href=\"<?php echo appSettings::strWebURL.'/newsdetail/index.php?P=0&ID='.$item->T03_PROMOTION_ID.'&CBR='.$item->T03_PROMOTION_CATEGORY.'#main'?>\"><?php if(mb_strlen($item->T03_PROMOTION_CONTENT, '8bit')>160) echo mb_substr( $item->T03_PROMOTION_CONTENT, 0, 51,\"UTF8\").'...'; else echo $item->T03_PROMOTION_CONTENT;?>\n \n```\n\n日本語場合、26文字を表示される。 \n英語場合、52文字を表示される。 \n日本語と英語を混じった文書は、どのようなコマンドを使用するでしょうか。 \n教えていただけませんか。 \nありがとうございます。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T09:03:38.937",
"favorite_count": 0,
"id": "44079",
"last_activity_date": "2018-06-08T08:18:18.310",
"last_edit_date": "2018-05-19T11:47:26.283",
"last_editor_user_id": "3068",
"owner_user_id": "27914",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"php"
],
"title": "ニュースのタイトル表示は、52バイト内に表示させたい",
"view_count": 169
} | [
{
"body": "2行分の文字を表示したいという場合は別のアプローチでの解決方法もあるかと思います。\n\n# cssで2列の範囲外を見えなくする\n\n単純にエリアに2も自分の領域のみ表示するようにしてそれ以降は見えなくしてしまう\n\n```\n\n .area {\n height: 2em;\n overflow: hidden;\n }\n \n```\n\n# 範囲外を3てんリーダーにする\n\nブラウザは限られてきそうですが、CSSで対応できるようです \n<https://tech.recruit-mp.co.jp/front-end/tips-ellipsis/>\n\n文字列で数えるなどの場合いろいろ考えることが多くなるため \ncssでの対応のが簡単かなと思ったのでご提案です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-29T07:15:47.530",
"id": "44357",
"last_activity_date": "2018-05-29T07:15:47.530",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7455",
"parent_id": "44079",
"post_type": "answer",
"score": 1
},
{
"body": "僕も CSS で解決したほうがいいと思うけど。 \n半角文字(ASCII)を `a` に置換し、全角文字(非ASCII)を `Aa` に置換し、 \n先頭から52文字中にある `a` の数が先頭から切り出すべき文字数の目安です。\n\n```\n\n <?php\n function abbreviate($title, $length)\n {\n $tmp = $title;\n $tmp = preg_replace('/[\\\\x20-\\\\x7E]/iu', 'a', $tmp);\n $tmp = preg_replace('/[^a]/iu', 'Aa', $tmp);\n $tmp = substr($tmp, 0, 52);\n $length = substr_count($tmp, 'a');\n return mb_substr($title, 0, $length, 'UTF-8');\n }\n \n $title = '確認テストtesttesttest確認テストtest確認テストtesttesttest';\n echo $title, PHP_EOL;\n echo abbreviate($title, 52), PHP_EOL, PHP_EOL;\n \n $title = 'testtesttesttesttesttesttesttesttesttesttesttesttesttest';\n echo $title, PHP_EOL;\n echo abbreviate($title, 52), PHP_EOL, PHP_EOL;\n \n $title = '確認テスト確認テスト確認テスト確認テスト確認テスト確認テスト';\n echo $title, PHP_EOL;\n echo abbreviate($title, 52), PHP_EOL, PHP_EOL;\n \n```\n\n結果\n\n```\n\n % php abbreviate.php\n 確認テストtesttesttest確認テストtest確認テストtesttesttest\n 確認テストtesttesttest確認テストtest確認テストtestte\n \n testtesttesttesttesttesttesttesttesttesttesttesttesttest\n testtesttesttesttesttesttesttesttesttesttesttesttest\n \n 確認テスト確認テスト確認テスト確認テスト確認テスト確認テスト\n 確認テスト確認テスト確認テスト確認テスト確認テスト確\n \n```\n\n非ASCII文字、かつ、文字幅が半角相当の文字が含まれる場合は意図した挙動になりません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-06-08T05:33:05.850",
"id": "44612",
"last_activity_date": "2018-06-08T08:18:18.310",
"last_edit_date": "2018-06-08T08:18:18.310",
"last_editor_user_id": "28832",
"owner_user_id": "28832",
"parent_id": "44079",
"post_type": "answer",
"score": 1
}
] | 44079 | null | 44357 |
{
"accepted_answer_id": "44083",
"answer_count": 1,
"body": "swiftで使えるcolorPickerのライブラリを探しています。 \n条件があり、 \n1\\. LandScapeで使える事 \n2\\. CocoaPodsに対応している事 \nです。Objective-Cのライブラリでも構いません。 \nご存知の方がいらっしゃいましたら、どうかご教示くださいませ。 \nよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T09:22:45.213",
"favorite_count": 0,
"id": "44082",
"last_activity_date": "2018-05-19T09:56:13.830",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28575",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"cocoapods"
],
"title": "swiftで使える色選択のライブラリについて",
"view_count": 169
} | [
{
"body": "はじめまして、[GitHub](https://github.com)をColor Picker\nSwiftで検索してみると、[ChromaColorPicker](https://github.com/joncardasis/ChromaColorPicker)というのが見つかりました。MITライセンスでCocoaPods対応のようです。 \n他にもGitHubを探せばたくさん見つかるので、合わないようであれば、より好みのものを探して見て下さい。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T09:56:13.830",
"id": "44083",
"last_activity_date": "2018-05-19T09:56:13.830",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "14745",
"parent_id": "44082",
"post_type": "answer",
"score": 1
}
] | 44082 | 44083 | 44083 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "strongparamaterをprivateメソッド以下に定義しているのですが、定義している値は存在しないとerrorが発生しています。\n\n自分なりに色々調べたのですが原因がわからない為、どなたかご教示お願い致します。\n\n[](https://i.stack.imgur.com/kOFBi.png)\n\nsession_controller.rb\n\n```\n\n class Staff::SessionsController < Staff::Base\n def new\n if current_staff_member\n redirect_to :staff_root\n else\n @form = Staff::LoginForm.new\n render action: 'new'\n end\n end\n \n def create\n @form = Staff::LoginForm.new(form)\n \n if @staff_login_form.email.present?\n staff_member = StaffMember.find_by(email_for_index: @staff_login_form.email.downcase)\n end\n if staff_member\n session[:staff_member_id] = staff_member.id\n redirect_to :staff_root\n else\n render action: 'new'\n end\n end\n end\n \n private\n \n def form\n params.require(:form).permit(:email, :password)\n end\n \n```\n\nnew.html.erb\n\n```\n\n <% @title = 'ログイン' %>\n \n <div id=\"login-form\">\n <h1><%= @tittle %></h1>\n \n <%= form_for @form, url: :staff_session do |f| %>\n <div>\n <%= f.label :email, 'メールアドレス' %>\n <%= f.text_field :email %>\n </div>\n <div>\n <%= f.label :password, 'パスワード' %>\n <%= f.password_field :password %>\n </div>\n <div>\n <%= f.submit 'ログイン' %>\n </div>\n <% end %>\n </div>\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T10:00:15.977",
"favorite_count": 0,
"id": "44084",
"last_activity_date": "2018-05-22T11:06:15.090",
"last_edit_date": "2018-05-21T15:46:10.153",
"last_editor_user_id": "19110",
"owner_user_id": "28576",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails"
],
"title": "ActionController::ParameterMissingが改善されない。",
"view_count": 2222
} | [
{
"body": "インデントを修正してみてください。\n\n```\n\n class Staff::SessionsController < Staff::Base\n # ...\n end\n \n private\n \n def form\n params.require(:form).permit(:email, :password)\n end\n \n```\n\nこんなコードになっています。`form` メソッドが class 定義の外にあるのが原因ではないでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T11:06:15.090",
"id": "44156",
"last_activity_date": "2018-05-22T11:06:15.090",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5288",
"parent_id": "44084",
"post_type": "answer",
"score": 1
}
] | 44084 | null | 44156 |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "モバイル回線経由でのRaspberry Piを遠隔操作するための構成で悩んでいます。 \nAndroidまたはiOSからモバイル回線経由でラズパイを遠隔操作したいのですが、携帯基地局等を跨いだ時にIPも変わるのでうまく接続できるものがないか探していますが、いまいちいいものが見つかりません。 \n下記のような構成で考えています。 \niOS・Android---携帯回線---基地局---インターネット---基地局---携帯回線---ラズパイ\n\nやはり下記の構成でプロトコルはwebsocket等を使うのが無難でしょうか。 \niOS・Android---携帯回線---基地局---インターネット---中継サーバ---基地局---携帯回線---ラズパイ",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T10:36:49.890",
"favorite_count": 0,
"id": "44085",
"last_activity_date": "2022-04-25T12:04:25.370",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26822",
"post_type": "question",
"score": 0,
"tags": [
"raspberry-pi"
],
"title": "モバイル回線経由でのRaspberry Piを遠隔操作するための構成",
"view_count": 611
} | [
{
"body": "仰られるように websocket を使う方法の他に reverse ssh tunnel もよく使われています\n\n後者では [remot3.it](https://www.remot3.it/web/index.html) というサービス(昔は weaved\nという名前でした)が RPi の出始めの頃からあり、よく使っていました\n\nremot3のサーバを中継して、モバイル回線の先の RPi に対してインターネットに接続されている別の端末から ssh で接続したり、httpd\nでコマンドを送ったりできます",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-12T22:54:34.063",
"id": "48335",
"last_activity_date": "2018-09-12T22:54:34.063",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30082",
"parent_id": "44085",
"post_type": "answer",
"score": 1
},
{
"body": "国内なら、SMS(ショートメッセージ)を使うのはどうでしょうか。\n\nシステムの構成は、以下のような感じです。\n\nスマートフォン(コントローラ側)== 携帯電話回線 == [Soracom Air] - Raspberry Pi\n\nスマートフォンとSoracom\nAirは、それぞれが決まった電話番号を持っていて、相手の電話番号にSMSを送受することで、動作を指示したり、状態を確認したりできるかと思います。 \nインターネットは使わないので、IPがどうのこうのとか、電話回線とインターネットの間の接続とかいった面倒を避けられて良いと思います。\n\n参考(この記事が発想の起点になっています):[Raspberry PiとSoracom AirでSMSの送受信](https://mag.switch-\nscience.com/2016/08/22/raspberry-pi-soracom-air-sms/)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-06-21T06:41:02.657",
"id": "55968",
"last_activity_date": "2019-06-21T06:41:02.657",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "44085",
"post_type": "answer",
"score": 1
},
{
"body": "ダイナミックDNSというのもありますね。 \n下記のサイトを参照してみてください。 \n<http://denshikousaku.net/raspberry-pi-domain-and-dynamic-dns>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-10-12T08:33:56.497",
"id": "83038",
"last_activity_date": "2021-10-12T08:33:56.497",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24490",
"parent_id": "44085",
"post_type": "answer",
"score": -1
}
] | 44085 | null | 48335 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "CentOS7とNginx(1.14.0)で静的ページを表示させています。 \nroot直下にある、`index.html`などは読み込まれるのですが、サブディレクトリ以降のファイルが読み込まれません。\n\n具体的には、`ドメイン.com`にアクセスすると正常に表示されますが、`ドメイン.com/about`にアクセスするとnginxの404エラーになってしまうのです。\n\nどのようにすれば、サブディレクトリ以降のファイルが読み込まれるでしょうか? \n教えていただけると助かります。\n\nnginx.confは以下のように設定しています。\n\n```\n\n user nginx;\n worker_processes 1;\n pid /var/run/nginx.pid;\n \n events {\n worker_connections 1024;\n }\n http {\n include /etc/nginx/mime.types;\n default_type application/octet-stream;\n \n root /var/www/html;\n \n log_format main '$remote_addr - $remote_user [$time_local] \"$request\" '\n '$status $body_bytes_sent \"$http_referer\" '\n '\"$http_user_agent\" \"$http_x_forwarded_for\"';\n \n access_log /var/log/nginx/access.log main;\n error_log /var/log/nginx/error.log debug;\n \n sendfile on;\n \n keepalive_timeout 65;\n \n # トップドメイン用の設定 \n include /etc/nginx/conf.d/top.conf;\n \n # サブドメイン用の設定\n include /etc/nginx/conf.d/サブドメイン名.conf;\n \n```\n\nトップドメイン用の設定`top.conf`は以下の通りに設定しています。\n\n```\n\n server {\n listen 80; \n server_name ドメイン.com;\n charset UTF-8;\n \n location / {\n root /var/www/html;\n index index.html index.html index.php;\n }\n \n error_page 500 502 503 504 /50x.html;\n \n location = /50x.html {\n root /usr/share/nginx/html;\n }\n \n location ~ \\.php$ {\n root /var/www/html;\n fastcgi_pass 127.0.0.1:9000;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n include fastcgi_params;\n }\n }\n \n```\n\nサブドメイン用`サブドメイン名.conf`の設定\n\n```\n\n error_log /var/www/サブドメイン用ディレクトリ名/current/log/nginx.error.log;\n access_log /var/www/サブドメイン用ディレクトリ名/current/log/nginx.access.log;\n \n client_max_body_size 2G;\n upstream app_server {\n # 連携するunicornのソケットのパス\n server unix:/var/www/サブドメイン用ディレクトリ名/current/tmp/sockets/.unicorn.sock;\n }\n \n server {\n listen 443 ssl;\n server_name サブドメイン名.ドメイン.com;\n keepalive_timeout 5;\n root /var/www/サブドメイン用ディレクトリ名/current/public;\n \n try_files $uri/index.html $uri.html $uri @app;\n location @app {\n # HTTP headers\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header Host $http_host;\n proxy_redirect off;\n #proxy_pass http://127.0.0.1:3000;\n proxy_pass http://app_server;\n }\n \n error_page 500 502 503 504 /500.html;\n location = /500.html {\n root /var/www/サブドメイン用ディレクトリ名/current/public;\n }\n }\n \n```",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T15:25:33.943",
"favorite_count": 0,
"id": "44087",
"last_activity_date": "2018-05-20T10:12:13.593",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25223",
"post_type": "question",
"score": 0,
"tags": [
"nginx"
],
"title": "Nignx 404エラーになる",
"view_count": 2373
} | [
{
"body": "サーバを一から再構築することにしました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T10:12:13.593",
"id": "44104",
"last_activity_date": "2018-05-20T10:12:13.593",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25223",
"parent_id": "44087",
"post_type": "answer",
"score": -1
}
] | 44087 | null | 44104 |
{
"accepted_answer_id": "44146",
"answer_count": 1,
"body": "すみません。ド素人で申し訳御座いません。個人的理由でみよう見まねで作ってみた人物の紹介の為のチェックボックスが効きません。何故かお解りでしょうか?宜しくお願い致します(m_m)。\n\n動かない事例 \n[](https://i.stack.imgur.com/32JPE.png)\n\n動く事例\n\n[](https://i.stack.imgur.com/gQlF8.jpg)\n\nhtml(動かない事例の)\n\n```\n\n <h4 class=\"teacher_h3\">ハイレベルプロの先生のご紹介</h4>\n <div class=\"notableTeachersText\">\n <h3>K.M先生</h3>\n </div>\n <figure><img src=\"../img/teacher018.png\" alt=\"K.M先生\"/></figure>\n <div class=\"menu\">\n <label for=\"menu_bar08\">自己紹介などはこちらから</label>\n <input type=\"checkbox\" id=\"menu_bar08\" class=\"accordion\" />\n \n```\n\nCSSのmenu_bar記述\n\n```\n\n #menu_bar01:checked ~ #links01 li,\n #menu_bar02:checked ~ #links02 li,\n #menu_bar03:checked ~ #links03 li,\n #menu_bar04:checked ~ #links04 li,\n #menu_bar05:checked ~ #links05 li,\n #menu_bar06:checked ~ #links06 li,\n #menu_bar07:checked ~ #links07 li,\n #menu_bar08:checked ~ #links08 li{\n max-height: 40000px;\n opacity: 1;\n -webkit-transition: all 0.5s;\n -moz-transition: all 0.5s;\n -ms-transition: all 0.5s;\n -o-transition: all 0.5s;\n transition: all 0.5s;\n \n```\n\n宜しくアドバイスを頂ければ幸いです(m_m)。\n\n## 追記1\n\n`#links01`~`#links08`は単独では存在していません。ですが、links01~links07は機能するのです。\n\nコメント有難う御座います。(m_m)\n\n## 追記2\n\nすいません、やはり解決していませんでした。K.M先生の図自体は下のN.I先生のものに近づいた \nものの、やはりチェックボックスが開閉しません。\n\nhtmlのdivに付されているID、クラス関係のcss記述は下記しか残りが有りません。\n\n```\n\n #content2>section section .notableTeachers input {\n display: none;\n }\n .menu li {\n max-height: 0;\n overflow-y: hidden;\n }\n .menu ul {\n margin: 0;\n padding: 0 15px;\n \n```\n\n* * *\n\n追記 クリックが動く事例のHTMLを書きます。(ID=\"menu_bar07\", links07)\n\n```\n\n <section class=\"notableTeachers clearfix\">\n <h4 class=\"teacher_h3\">スタンダードプロの先生のご紹介</h4>\n <div class=\"notableTeachersText\">\n <h3>N.I先生</h3>\n </div>\n <figure><img src=\"../img/teacher017.png\" alt=\"N.I先生\"/></figure>\n <div class=\"menu\">\n <label for=\"menu_bar07\">自己紹介などはこちらから </label>\n <input type=\"checkbox\" id=\"menu_bar07\" class=\"accordion\" />\n <ul id=\"links07\">\n <li>\n <dl>\n <dt>指導科目</dt>\n <dd><小学生>算数 国語 理科 社会 英語<br>\n <中学生>数学 国語 理科 英語 社会(基礎レベル)<br>\n <高校生>数学 国語(基礎レベル) 英語(基礎レベル) </dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>家庭教師等の指導歴</dt>\n <dd>家庭教師20年、塾15年、高等学校2年、大学2年</dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>保有資格</dt>\n <dd>教員免許 小学校、中学校(数学・理科)、高校(数学・理科)、養護教諭<br>\n 数学検定準一級</dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>指導例</dt>\n <dd>Aさん→指導教科は英語・国語・日本史です。高校2年生で学校・塾を辞めて、勉強をずっとしていない状態で高校3年生にあたる8月頃から家庭教師一本で受験勉強を始めました。最初は勉強することにも慣れていない様子でしたので、週に数日勉強時間を作ることから始め、徐々に毎日勉強することに慣らしていきました。毎週、日割りで学習計画を立て、毎回の授業で進度を確認しました。過去問は11月位から始め、志望校の受験問題の傾向に合わせた学習を進めました。12月は不安で勉強に手がつかない日もありましたが1月からは調子も良くなり、センター試験・私立大の受験と順調に受験でき、当初、チャレンジ校と言っていた難関大学にも合格できました。<br>\n Bさん→指導教科は算数で時々質問がある時は他の教科も教えていました。小学校6年生の11月の受験直前期からの指導です。算数が苦手で足をひっぱり、模試では第一志望校は合格圏外で偏差値はあとプラス10以上必要でした。過去問は合格点の半分以下の得点で非常に厳しい状況でした。また、塾にも通っていたため、宿題は出さず、授業だけで成績を伸ばしてほしいというご要望でした。ご家庭には10年分以上の過去問が用意されていたので、毎週、事前に解いていた過去問で間違えた問題の単元を徹底的に復習し、その問題の類題で練習をしました。練習を重ねるごとに解ける問題も増え、最終的には第一志望校に一発で合格できました。 </dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>自己紹介</dt>\n <dd>今まで小学生から社会人まで沢山の生徒さんの指導をしてきました。不登校の生徒さん、内部進学生、難関大学の受験を志望する生徒さん等幅広い指導を行っています。生徒さんの目標・レベルに合わせた指導を丁寧に行います。</dd>\n </dl>\n </li>\n </ul>\n </div>\n </section>\n \n```\n\n* * *\n\n動かない場合の事例のHTMLを追記させて頂きます。(上記K.M先生)\n\n```\n\n <section class=\"class\" id=\"highlevel-pro\">\n <h3 class=\"teacher_h3\">ハイレベルプロ</h3>\n <p>家庭教師、塾講師などの教育指導歴がおおよそ6~15年程度保有する講師。学歴の目安としておおよそ偏差値62程度以上の大学卒業者。学生は含まれません。以下は現役講師のご紹介の一部です。</p>\n <section class=\"notableTeachers clearfix\">\n <h4 class=\"teacher_h3\">ハイレベルプロの先生のご紹介</h4>\n <div class=\"notableTeachersText\">\n <h3>K.M先生</h3>\n </div>\n <figure><img src=\"../img/teacher018.png\" alt=\"K.M先生\"/></figure>\n <div class=\"menu\">\n <label for=\"menu_bar08\">自己紹介などはこちらから </label>\n <input type=\"checkbox\" id=\"menu_bar08\" class=\"accordion\" />\n <ul links=\"links08\">\n <li>\n <dl>\n <dt>指導科目</dt>\n <dd><小学生>算数 国語  <br>\n <中学生>英検 英検(5級~2級) 国語(現代文)<br>\n <高校生>英検 英検(5級~2級) 国語(現代文)</dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>合格実績</dt>\n <dd><中学校>明大中野中学 桐蔭中学 工学院中学 東京女学館中学 佼成学園 帝京八王子 日大3中 目黒学園<br>\n <高校>駒沢付属 神奈川県立高校多数<br>\n <大学>明治大学 日本大学 北里大学 駒澤大学 産業能率大学<br>\n <その他>英検は今まで担当した生徒は10名。1回目で全員合格。(準2級3人 3級5人 4級1人 5級1人)\n </dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>指導歴</dt>\n <dd>30年</dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>指導可能地域</dt>\n <dd>神奈川県(主に、小田急線)</dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>資格</dt>\n <dd>教員免許(英語) 小学校 英検準1級 カウンセリング勉強中</dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>自己PRその1</dt>\n <dd><大切にしていること><br>〇興味を持てるように働きかけます。進学塾や進学校であまりにも多くの課題をこなしていくうちに、その教科を学ぶ意味や本来の楽しさを見失ってしまうことがあります。せっかく力があるのに、味わったり、振り返ったりする時間がなくなってしまうのです。<br>例えば、英語の学習では、洋楽を聞いたり、実際の会話を聞きながら、声に出したりしながら、語学の楽しさを感じてもらうことから始めます。興味の入り口は一人一人違うので、探りながら、前向きに取り組める方法でアドバイスしていきます。</dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>自己PRその2</dt>\n <dd>〇自分の力で解決できるように<br>「好きこそものの上手なれ」とはよく言ったもので、興味を持つと、理解力も上がってきます。そのときがチャンスです。少し背中を押してあげると、自力でなんとか解決できるようになります。今までぎこちなく読んでいた英文が、滑らかに読めるようになってくるのです。意味が理解できるようになってくるのです。この仕事のやり甲斐を感じる瞬間です。生徒が課題に興味を持って、自分で前向きに取り組めるようになることがゴールだと思っています。家庭教師が自分の持ち時間の中で教えられることには、物理的に限界があるわけですから。ご縁が合って、ともに学んでいくうちに、生徒が前向きに学習できるようになり、自分の目標に近づくことができたなら、力になることができたなら、こんな嬉しいことはありません。</dd>\n </dl>\n </li>\n <li>\n <dl>\n <dt>自己PRその3</dt>\n <dd>〇保護者との連携<br>保護者の皆様との連携は密に取るようにしています。思春期の子どもたちにとっては、親御さんの意見を理解していても、素直に受け入れたくないときもあります。また、子どもの本当の気持ちに、ご両親も気づいていないこともときにあります。そんなとき、橋渡しをするのも仕事のうちだと考えています。最近では、交友関係や学習面で問題を抱えている生徒さんや、登校できなくなった生徒さんを見る機会が増えてまいりました。カウンセリングの手法を取り入れながら対応しています。</dd>\n </dl>\n </li>\n </ul>\n </div>\n </section>\n \n```\n\n* * *\n\nここまで書いてみて気づいたのですが、上手く開閉するN.I先生他は開くと\n\n[](https://i.stack.imgur.com/KsVjd.png)\n\nと開閉しても(他links01~07まで同じく)内容が違ってきてしまっているのですが、関係しているクラス\n\n```\n\n .menu li dl dt:after {\n content: \":\";\n \n```\n\nに関係してそもそもhtmlの書き込み自体が間違っているのでしょうか?それとも何か \n他に関係しそうなcssの動きの為でしょうか?\n\nアドバイスを頂けますと誠に幸いです(m_m)。\n\n* * *\n\n追記させて頂きます。関係しそうなcss一覧\n\n```\n\n #content2>section section .notableTeachers {\n padding: 0;\n margin: 20px 0 0;\n background-color: #fff;\n }\n #content2>section section .notableTeachers h4 {\n text-align: center;\n padding-top: 15px;\n }\n #content2>section section .notableTeachers h4:before,\n #content2>section section .notableTeachers h4:after {\n content: \"=\";\n }\n #content2>section section .notableTeachers>figure {\n width: 50%;\n float: left;\n padding: 0 0 0 10px;\n }\n #content2>section section .notableTeachers .notableTeachersText {\n width: 50%;\n float: right;\n padding: 0 10px 0 0;\n }\n #content2>section section .notableTeachers h5 {\n font-size: 1.5em;\n margin: 10px 0;\n }\n #content2>section section .notableTeachers h5 span {\n font-size: 14px;\n }\n #content2>section section .notableTeachers label {\n display: block;\n text-align: center;\n clear: both;\n background-color: #fabd00;\n margin: 0;\n line-height: 2em;\n }\n #content2>section section .notableTeachers label:after {\n content: \"+\";\n background-image: url(../img/icon_circle_white.png);\n background-size: 16px auto;\n background-repeat: no-repeat;\n background-position: 50% center;\n \n```\n\nお手数をおかけします(m_m)\n\n* * *\n\n皆さま、色々なコメント、解答、アドバイスを頂き有難う御座います! \n解決を致しました。失礼が御座いましたらお許し下さい(m_m)。",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T16:04:48.593",
"favorite_count": 0,
"id": "44088",
"last_activity_date": "2018-05-22T07:44:11.617",
"last_edit_date": "2018-05-22T07:44:11.617",
"last_editor_user_id": "19182",
"owner_user_id": "19182",
"post_type": "question",
"score": 0,
"tags": [
"css",
"html5"
],
"title": "チェックボックスに適用したCSS(ブロックの折り畳みを開閉)が機能しません",
"view_count": 546
} | [
{
"body": "> 動かない場合の事例のHTMLを追記させて頂きます。(上記K.M先生)\n\nに記載して頂いているコード内で、 `<ul links=\"links08\">` の属性名が `links` になっています。 \nこれを `<ul id=\"links08\">` にして頂くと動くかと思います。\n\n下記、修正したうえで少し簡略化しました。\n\n```\n\n .menu li {\r\n max-height: 0;\r\n overflow-y: hidden;\r\n }\r\n .menu ul {\r\n margin: 0;\r\n padding: 0 15px;\r\n }\r\n \r\n #menu_bar08:checked ~ #links08 li{\r\n max-height: 40000px;\r\n opacity: 1;\r\n -webkit-transition: all 0.5s;\r\n -moz-transition: all 0.5s;\r\n -ms-transition: all 0.5s;\r\n -o-transition: all 0.5s;\r\n transition: all 0.5s;\r\n }\n```\n\n```\n\n <section class=\"notableTeachers clearfix\">\r\n <h4 class=\"teacher_h3\">ハイレベルプロの先生のご紹介</h4>\r\n <div class=\"notableTeachersText\">\r\n <h3>K.M先生</h3>\r\n </div>\r\n <div class=\"menu\">\r\n <label for=\"menu_bar08\">自己紹介などはこちらから </label>\r\n <input type=\"checkbox\" id=\"menu_bar08\" class=\"accordion\" />\r\n <ul id=\"links08\">\r\n <li>\r\n <dl>\r\n <dt>指導科目</dt>\r\n <dd><小学生>算数 国語  <br>\r\n <中学生>英検 英検(5級~2級) 国語(現代文)<br>\r\n <高校生>英検 英検(5級~2級) 国語(現代文)\r\n </dd>\r\n </dl>\r\n </li>\r\n </ul>\r\n </div>\r\n </section>\n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T02:34:50.577",
"id": "44146",
"last_activity_date": "2018-05-22T02:34:50.577",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27930",
"parent_id": "44088",
"post_type": "answer",
"score": 4
}
] | 44088 | 44146 | 44146 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "python3におけるfor文の使い方で困っています。 \nある関数にfor文にリストを流し込み、算出された結果を別々のオブジェクトに \n保存をしたいのですが、上手くいきません。当方、エンジニアではないので、 \n質問の仕方が不適切かもしれず恐縮ですが、よろしくお願い致します。 \n下記がコードになります。\n\n```\n\n def test(x):\n x\n return x\n \n test_list=['1','2','3','4','5']\n x = test_list\n test_df = [df1,df2,df3,df4,df5]\n y = test_df\n \n for i1,i2 in zip(x,y):\n y = test(x)\n df1\n \n```\n\ndf1,df2,df3,df4,df5 にそれぞれ、'1','2','3','4','5'を格納したい",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T17:15:18.513",
"favorite_count": 0,
"id": "44089",
"last_activity_date": "2018-05-21T16:03:40.910",
"last_edit_date": "2018-05-20T01:58:23.967",
"last_editor_user_id": "3060",
"owner_user_id": "28578",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "python3のfor~zipの使い方と値のオブジェクトへの格納の仕方について",
"view_count": 149
} | [
{
"body": "以下のように書けば別々のオブジェクトに保存できます。\n\n```\n\n test_list=['1','2','3','4','5']\n test_df = ['df1','df2','df3','df4','df5']\n for x, y in zip(test_list, test_df):\n exec(y + \" = '\" + x + \"'\")\n \n```\n\nなお、そのままリストで使うか、辞書型を使って、次のように辞書を作成した方がわかりやすいと思います。\n\n```\n\n test_list=['1','2','3','4','5']\n test_df = [1, 2, 3, 4, 5]\n df = {}\n for x, y in zip(test_list, test_df):\n df[y] = x\n \n```\n\n使用する場合には、次のようにします。\n\n```\n\n df[1]\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T03:44:30.843",
"id": "44100",
"last_activity_date": "2018-05-20T03:44:30.843",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "44089",
"post_type": "answer",
"score": 2
},
{
"body": "```\n\n def square(num):\n return num*num;\n xs = [1,2,3,4,5]\n \n```\n\nとして\n\n```\n\n df1 = 1, df2 = 4, df3 = 9, df4 = 16, df5 = 25\n \n```\n\nという変数に代入された状態が得たいとする。 \nこの時pythonでもっとも簡潔に書くならば、以下のようなリスト内法表記と呼ばれるforの使い方をしたほうがよく、またリストを分解して一気に代入するというもテクニックがあるのでこの二つを使う。求める状態を得るにはこの一行だけでよい。今回はわかりやすい例としてsquare関数を定義したが、関数自体は自由に置き換え可能だ。(squareでなくても質問者の定義したtestでもok)\n\n```\n\n df1,df2,df3,df4,df5 = [square(x) for x in xs]\n \n```\n\nここで右辺のイメージは、xsというリスト[1,2,3,4,5]から要素を一つずつ取り出して関数を適用し、その返り値をリストに格納するという操作が行われる。よって右辺は[1,4,9,16,25]になる。 \n左辺は右辺のリストを左から順番に格納していくので求める結果が得られる。 \ntestdfを得るためには、\n\n```\n\n test_df =[df1,df2,df3,df4,df5] #または\n test_df = [square(x) for x in xs]\n \n```\n\npythonのふつうのfor文で同じことをやりたい場合は、下記の記述でも同じような結果が得られるので参考にしてください。(ただし上の書き方のほうが効率的で、かつインデントもなく短いのでおススメです。)\n\n```\n\n test_df = []\n for x in xs:\n test_df.append(square(x))\n df1,df2,df3,df4,df5 = test_df\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T16:03:40.910",
"id": "44140",
"last_activity_date": "2018-05-21T16:03:40.910",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25980",
"parent_id": "44089",
"post_type": "answer",
"score": 0
}
] | 44089 | null | 44100 |
{
"accepted_answer_id": "44091",
"answer_count": 1,
"body": "moreコマンドの仕様は、どこで確認出来るでしょうか?\n\n* * *\n\n**試したこと** \n・CentOS7\n\n```\n\n man more\n \n```\n\n> more は、 3.0BSD に登場した。 この man ページは 現在 Linux コミュニティで利用されている more バージョン \n> 5.19 (Berkeley 6/29/88)について書かれている。\n\n* * *\n\n**Q1.3.0BSDについて** \n・ここで記載されているBSDは、ライセンスではなくOSの意味ですか? \n・「CentOS」と「BSD」の関係性が分かりません \n・「BSD」内容を「CentOS」でも利用しているのでしょうか?\n\n* * *\n\n**Q2. Linux コミュニティで利用されている more バージョン 5.19 (Berkeley 6/29/88)** \n・more バージョン 5.19に関する情報はどこに掲載されているのでしょうか? \n・この場合のLinux コミュニティは何を指すのでしょうか? \n・Berkeleyは相性? \n・6/29/88は日付??",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T22:31:21.320",
"favorite_count": 0,
"id": "44090",
"last_activity_date": "2018-05-20T01:56:53.517",
"last_edit_date": "2018-05-20T01:56:53.517",
"last_editor_user_id": "3060",
"owner_user_id": "7886",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"centos"
],
"title": "moreコマンドの仕様について",
"view_count": 149
} | [
{
"body": "[BSD](https://ja.wikipedia.org/wiki/BSD)は\n\n> Berkeley Software Distribution の略語で、1977年から1995年までカリフォルニア大学バークレー校\n> (University of California, Berkeley, UCB) の Computer Systems Research Group\n> (CSRG) が開発・配布したソフトウェア群、およびUNIXオペレーティングシステム (OS)。\n\nです。ですのでBerkeleyはカリフォルニア大学バークレー校を指します。その上で3BSDは[BSD\nVAX版](https://ja.wikipedia.org/wiki/BSD#VAX%E7%89%88)より\n\n>\n> 32Vのカーネルをバークレーの学生達が大幅に書きかえて仮想記憶を実装し、2BSDのユーティリティ群をVAXに移植したものと32V由来のユーティリティ群をまとめて完全なOSとしたものが\n> **3BSD** として1979年末にリリースされた。\n\nのことかと。もちろんLinuxとは無関係です。また[4.3BSD](https://ja.wikipedia.org/wiki/BSD#4.3BSD)より\n\n> 4.3BSDリリース後、BSDのプラットフォームを古くなったVAXから新たなプラットフォームへ移行することが決まった。当初 Computer\n> Consoles Inc. の68kベースの Power 6/32(コード名 \"Tahoe\")が候補となったが、間もなく開発者らがそれをやめた。それでも\n> **4.3BSD-Tahoe**\n> という移植版(1988年6月)は貴重であり、BSDにおける機種依存コードと機種共通コードの分離をもたらし、将来の移植性向上に寄与した。\n\nですので、これが[util-linux](https://en.wikipedia.org/wiki/Util-\nlinux)に[移植](https://ja.wikipedia.org/wiki/%E7%A7%BB%E6%A4%8D_\\(%E3%82%BD%E3%83%95%E3%83%88%E3%82%A6%E3%82%A7%E3%82%A2\\))されたことを指すかと。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-19T23:00:54.613",
"id": "44091",
"last_activity_date": "2018-05-19T23:00:54.613",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "44090",
"post_type": "answer",
"score": 4
}
] | 44090 | 44091 | 44091 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "nodemonをinstallできません。どのようにしたらインストールできるようになるのでしょうか?\n\nちなみにnpmのversionは5.6.0です。\n\n```\n\n hattoriorunoMBP:~ hattoriakitsugu$ npm install nodemon -g\n npm WARN checkPermissons Missing write access to /Users/hattoriakitsugu/.npm-global/lib/node_modules/nodemon\n npm ERR! path /Users/hattoriakitsugu/.npm-global/lib/node_modules/nodemon\n npm ERR! code EACCES\n npm ERR! errno -13\n npm ERR! syscall access\n npm ERR! Error: EACCESS: permission denied, access '/Users/hattoriakitsugu/.npm-global/lib/node_modules/nodemon'\n npm ERR! { Error: EACCESS: permission denied, access '/Users/hattoriakitsugu/.npm-global/lib/node_modules/nodemon'\n npm ERR! stack: 'Error: EACCESS: permission denied, access \\'/Users/hattoriakitsugu/.npm-global/lib/node_modules/nodemon\\'',\n npm ERR! errno: -13,\n npm ERR! code: 'EACCESS',\n npm ERR! syscall: 'access',\n npm ERR! path: '/Users/hattoriakitsugu/.npm-global/lib/node_modules/nodemon' }\n npm ERR!\n npm ERR! Please try running this command again as root/Administrator.\n \n npm ERR! A complete log of this run can be found in:\n npm ERR! /Users/hattoriakitsugu/.npm/_logs\\2018-05-20T00_03_54_549Z-debug.log\n \n```\n\n[](https://i.stack.imgur.com/bxCNJ.png)\n\n## 追記\n\nさらに、sudoコマンドを使ってもできませんでした。\n\n```\n\n hattoriorunoMBP:~ hattoriakitsugu$ sudo npm install nodemon -g\n Password:\n /Users/hattoriakitsugu/.npm-global/bin/nodemon -> /Users/hattoriakitsugu/.npm-global/lib/node_modules/nodemon/bin/nodemon.js\n \n > [email protected] postinstall /Users/hattoriakitsugu/.npm-global/lib/node_modules/nodemon\n > node bin/postinstall || exit 0\n \n Love nodemon? You can now support the project via the open collective:\n > https://opencollective.com/nodemon/donate\n \n + [email protected]\n updated 1 package in 7.455s\n \n```\n\n[](https://i.stack.imgur.com/wsYX1.png)",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T00:17:10.003",
"favorite_count": 0,
"id": "44093",
"last_activity_date": "2023-08-02T02:08:11.097",
"last_edit_date": "2018-05-20T08:26:21.457",
"last_editor_user_id": "19110",
"owner_user_id": "28580",
"post_type": "question",
"score": 1,
"tags": [
"node.js"
],
"title": "nodemonをインストールできない: Error: EACCESS: permission denied",
"view_count": 1561
} | [
{
"body": "> Please try running this command again as root/Administrator.\n\nと表示されているように、管理者権限でインストールのコマンドを実行してみてください。\n\n```\n\n $ sudo npm install nodemon -g\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T02:06:54.640",
"id": "44096",
"last_activity_date": "2018-05-20T02:06:54.640",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "44093",
"post_type": "answer",
"score": 0
},
{
"body": "permission error や EACCESS が出ているので、問題自体は npm\nモジュールが保存されることになるディレクトリやファイルにアクセスできない、というエラーです。よってエラー・メッセージにもあるとおり、とりあえずのところは\n`sudo` をつけて管理者権限で実行すればエラーが出ない可能性が高いです。つまり `sudo npm install ~` ということです。\n\n* * *\n\nただし私個人的には、これだと根本的な解決にはなっていないと思います。というのも今回パーミッションのエラーが出ているのは自分のホームディレクトリ直下なので、できれば\n`sudo` 無しでアクセスできた方が望ましそうだからです。nodemon 特有の問題というよりか、npm\nをインストールした際の設定由来の問題だと思います。\n\n今後も `sudo` 無しでインストールできる方が望ましい場合、npm の公式ドキュメント [\"How to Prevent Permissions\nErrors\"](https://docs.npmjs.com/getting-started/fixing-npm-permissions)\nが参考になります。これによると、以下の選択肢があります。\n\n * 選択肢1: Node Version Manager (nvm) を使って npm を再インストールする\n * 選択肢2: npm のデフォルト・ディレクトリを変更する\n\nまた macOS の場合、`brew` を使って再インストールする選択肢もあるでしょう。とにかく `~/.npm-global/`\n以下のパーミッションを直したいだけなので、手動で `chown` などする方法でも上手くいくかもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T02:35:15.337",
"id": "44097",
"last_activity_date": "2018-05-20T02:35:15.337",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "44093",
"post_type": "answer",
"score": 0
}
] | 44093 | null | 44096 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "初めまして。私は現在、カレンダーを利用したスケジュールアプリを開発しています。\n\nそこで、下の画像(画面下半分、カレンダー部分の下)にあるように、viewの上端を上方向にスワイプすると、アニメーション付きで全画面表示に移行、下スワイプで元の表示に戻る、といった機能を実装するには、どうすれば良いのでしょうか?\n\n[](https://i.stack.imgur.com/Y8tDu.gif)\n\nご教授いただければ幸いです。ご回答よろしくお願いします。\n\n追記:\n\nアドバイスありがとうございます。 \n以下の画像のように、私は、下半分のviewの上端に上方向のUISwipeGestureRecognizerを追加し、全画面表示の別のView\nControllerへ画面遷移、そのView\nControllerの上端に下方向のUISwipeGestureRecognizerを追加して画面を閉じることで似たような動きを実装しました。\n\nしかし当然ですが、これは単なる画面遷移で、参考にしている機能とは根本的に異なる気がします。(参考の画像では、画面遷移するわけではなく、上方向にスワイプするとviewがそのまませり上がる感じです。)\n\n開発経験もまだ浅く、どのように実装すれば良いか全く検討もつかない状態です。\n\nご回答よろしくお願いいたします。\n\n[](https://i.stack.imgur.com/dTllM.gif)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T02:03:50.433",
"favorite_count": 0,
"id": "44095",
"last_activity_date": "2018-05-21T08:30:01.183",
"last_edit_date": "2018-05-21T04:07:58.743",
"last_editor_user_id": "13972",
"owner_user_id": "28582",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios"
],
"title": "iOSのコントロールセンターのようなUIを実現したいです。",
"view_count": 1921
} | [
{
"body": "アプローチは色々ありますけど、一番参考になれるものはアップルのデモと思います。\n\n下記のwwdcの動画を参考いただければ分かると思います。 \n[アップル社のWWDC動画 WWDC 2017 - Session 230 -\niOS](https://developer.apple.com/videos/play/wwdc2017/230/) \nまずは14分ごろのデモをチェックして確認してみてね。\n\nコードの方は、こちらはGithubでのリークをご参考ください。 \n[Githubでのデモでした](https://github.com/kane-liu/AdvancedAnimations)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T08:22:34.940",
"id": "44129",
"last_activity_date": "2018-05-21T08:30:01.183",
"last_edit_date": "2018-05-21T08:30:01.183",
"last_editor_user_id": "28597",
"owner_user_id": "28597",
"parent_id": "44095",
"post_type": "answer",
"score": 2
}
] | 44095 | null | 44129 |
{
"accepted_answer_id": "44107",
"answer_count": 1,
"body": "スクロールビューの下にimageViewを配置してあります。\n\n```\n\n @IBOutlet weak var scrollView: UIScrollView!\n @IBOutlet weak var canvasView: UIImageView!\n var saveImageArray = [UIImage]() //Undo/Redo用にUIImage保存用\n \n // タップされた座標にflowerを追加する(buttonをクリックした時の処理)\n let flower = UIImageView(image: UIImage(named: \"flower\"))\n flower.center = (sender as AnyObject).location(in: self.view)\n \n```\n\n**canvasViewの拡大を可能にしたい為、addSubView(flower)にしたら簡単にタップ位置にimageの大きさで表示されかつ拡大出来たので良かったのですが、結果としてSubViewとcanvasViewでは格納場所が違うようで以降のundo処理が出来ない状態です。 \n描いた線,画像の拡大,縮小が出来てundo,redo処理が出来る様に考えています。 \n現在の記述で描いた線,画像の拡大,縮小は出来るのだが,画像のredo,undoが出来ないです。 \n(この処理の中には線の記述はないです) \ncanvasView.addSubview(flower)\n\n```\n\n //配列にcanvasView.imageを保存\n currentDrawNumber += 1\n saveImageArray.append(canvasView.image!) \n \n //保存している直前のimageに置き換える (undoボタンをクリツクした時の処理)\n @IBAction func pressUndoButton(_ sender: Any) {\n if currentDrawNumber <= 0 {return} \n \n self.canvasView.image = saveImageArray[currentDrawNumber - 1] \n currentDrawNumber -= 1\n }\n \n```\n\nこの処理で画像を書き換えられるはずなのですが、上手くいきません。 \n教えて戴けませんか ?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T02:45:25.710",
"favorite_count": 0,
"id": "44099",
"last_activity_date": "2018-05-21T07:28:47.403",
"last_edit_date": "2018-05-21T07:28:47.403",
"last_editor_user_id": "26811",
"owner_user_id": "26811",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"swift4"
],
"title": "絵を描くアプリで線はundo,redoできるのですがimageviewがundo,redoできません。",
"view_count": 183
} | [
{
"body": "はじめまして。@OOPerさんが仰るとおり、クラス定義からクラス定義終了まで全てのコードが記述されていないので確実とは言えませんが、上のソースには\n\n> タップされた座標にflowerを追加する(buttonをクリックした時の処理)\n\nで、flowerという画像ファイルを`canvasView`に`addSubview`しています。 \nつまり、`canvasView`にオーバーレイしたViewを作成し、そこにflowerという名前の画像を表示している様に見えます。\n\nしかし、\n\n> 配列にcanvasView.imageを保存\n\nで`saveImageArray`にバックアップしている`canvasView.image`は、上に記述されたソース断片ではなにもセットしていないので、空のイメージの可能性が高く \n更に\n\n> 保存している直前のimageに置き換える (undoボタンをクリツクした時の処理)\n\n以降で保存された画像をセットし直しているのは、`canvasView`の`image`プロパティを操作しているように見えます。 \nそうすると、\n\n\\---- flowerという最初にセットした画像 --------------------- = addされたSubview \n\\----- バックアップした空のimageをUndoで再セットした画像 ----- = canvasView\n\nと言うことが起きているのではないでしょうか \nこのため、undoボタンをクリックしたときの処理は実際に行われていても、 \naddされたSubviewの下に隠れて見えていない事が予想されます。 \nなので、\n\na. タップされた座標に〜 の部分で、`addSubview`せず、`canvasView`の`image`に画像をセットする\n\n```\n\n let flower = UIImage(named: \"flower\")\n // センタリング処理省略\n canvasView.image = flower\n \n```\n\nb. Undoアクション\nの部分で、`addSubview`した`view`の`image`に画像をセットする(バックアップするイメージの取得元も`addSubview`した`view`の`image`プロパティにする)\n\n```\n\n // nはaddSubviewしたflowerのsubViewsから取得される順番\n self.canvasView.subViews[n].image = saveImageArray[currentDrawNumber - 1] \n \n```\n\nまたは\n\n```\n\n // flowerが例示されたソースの通り、クラスのメンバー変数であれば\n // イメージのバックアップも書き戻しもflowerに対して行えばよい\n // 配列にcanvasView.imageを保存の部分\n saveImageArray.append(flower.image!)\n // 保存している直前のimageに置き換えるの部分\n flower.image = saveImageArray[currentDrawNumber - 1]\n \n```\n\nただし、この場合、`let\nflower`は適切な変数名ではないので、クラス内全体を通して`flower`こそが実質的にキャンバスであると言うことが解る変数名に書き替えた方が間違いが少なくなると思います\n\n以上より、a,bで例示したどちらか片方に統一すれば良いような気がします。 \nbの例示は2つ示しましたが、どちらか片方だけが必要で、両方の修正を行うと、また挙動がわからなくなります。\n\nただしbの解決方法は、「ではIBOUtletで宣言しているcanvasViewというImageViewは何のために存在しているか?」がわからない、必要のないオブジェクトになってしまうので、勝手な予測ながら「よくわからないけど、こうすれば動いた」以上の意味は無いのでは無いかと思います。 \nこのため、a.で示した、IBOutlet宣言したcanvasViewに極力余計なViewをaddしない方針でプログラムの修正をし、どうしても質問に記述されていない部分が理由で`addSubview`する必要でない限り、b.の方針でプログラムを修正すべきではない様に思えます。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T12:19:07.587",
"id": "44107",
"last_activity_date": "2018-05-21T05:39:42.700",
"last_edit_date": "2018-05-21T05:39:42.700",
"last_editor_user_id": "14745",
"owner_user_id": "14745",
"parent_id": "44099",
"post_type": "answer",
"score": 1
}
] | 44099 | 44107 | 44107 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Laravel5でデータベースセッションを使いたいのですが \nartisanコマンドを使ってsessionsテーブルを作成しました。\n\n```\n\n php artisan session:table\n php artisan migrate\n \n```\n\n実行後、作られたテーブルの使い方がよく分かりません。 \nいつ、値がDBにセットされるのでしょうか? \n自分で値を決めてセットしたりなどもできるのでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T06:49:15.857",
"favorite_count": 0,
"id": "44102",
"last_activity_date": "2018-05-20T06:49:15.857",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25778",
"post_type": "question",
"score": 1,
"tags": [
"php",
"laravel"
],
"title": "Laravel5でデータベースセッションを使う",
"view_count": 278
} | [] | 44102 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Swiftの画面遷移について\n\n```\n\n let animator:UIViewControllerTransitioningDelegate = CustomAnimate(movePattern: animation)\n let storyboar: UIStoryboard = UIStoryboard(name: storyboardName, bundle: nil)\n let vs = storyboar.instantiateViewController(withIdentifier: idName)\n vs.transitioningDelegate = animator as UIViewControllerTransitioningDelegate\n self.present(vs, animated: animateBool, completion:nil)\n \n```\n\n現状ではこのような手法で画面遷移を行なっています。 \nまた、画面遷移時のアニメーションは以下のサイトを参考にしております。\n\n\"UIViewControllerAnimatedTransitioningを使って画面遷移アニメーションを作る\" \n<https://qiita.com/kitoko552/items/4c0e411ff6224090db87>\n\nしかし、この方法だけで行き来した場合、メモリが消去されないためメモリリークが発生することが分かっています。 \n普段であればdismissを使った画面遷移で対応するのですが、dismissを使った場合、画面遷移アニメーションをどこに挟めば良いのかが分かりません。\n\nCATransitionを使えばアニメーションは実装できましたが、UIViewControllerAnimatedTransitioningを使って画面遷移を行うにはどうしたら良いでしょうか。 \n以下はdismissとCATransitionを使った例になります。\n\n```\n\n let transition: CATransition = CATransition()\n transition.duration = 0.5\n transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)\n self.view.window!.layer.add(transition, forKey: nil) \n self.dismiss(animated: false, completion: nil)\n \n```\n\nメモリリークを解決することがミッションのため \n①presentを使って画面遷移前のメモリを消去する方法 \n②dismissを使ってカスタムアニメーションを実装する方法 \nのどちらかについてご回答して頂けましたら大変助かります。\n\n勿論、もっと良いやり方がありましたらご教授願います。よろしくお願いします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T09:43:52.217",
"favorite_count": 0,
"id": "44103",
"last_activity_date": "2018-05-20T09:43:52.217",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28583",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"swift4"
],
"title": "Swiftの画面遷移(コードのみ、アニメーションあり)とメモリリーク",
"view_count": 483
} | [] | 44103 | null | null |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "Laravelを使ってページネーションする場合 \npaginate()メソッドを使うのですが毎回 \n件数を取得するSQLと結果を取得するSQLの二つが実行されます。 \npaginate()メソッドはどんな仕組みになっているのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T12:08:14.643",
"favorite_count": 0,
"id": "44105",
"last_activity_date": "2018-05-31T07:01:11.683",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25778",
"post_type": "question",
"score": 2,
"tags": [
"php",
"laravel"
],
"title": "Laravelを使ったページネーション",
"view_count": 1572
} | [
{
"body": "<https://github.com/laravel/framework/blob/eddc5a1995e697f0d9fa703ca03776fdcee96c78/src/Illuminate/Database/Query/Builder.php#L1922>\n\n```\n\n public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null)\n {\n $page = $page ?: Paginator::resolveCurrentPage($pageName);\n $total = $this->getCountForPagination($columns);\n $results = $total ? $this->forPage($page, $perPage)->get($columns) : collect();\n return $this->paginator($results, $total, $perPage, $page, [\n 'path' => Paginator::resolveCurrentPath(),\n 'pageName' => $pageName,\n ]);\n }\n \n```\n\nまず、全レコード数`$total`を取得しています(件数を取得するSQL)。 \n1ページ当たりの行数`$perPage`が決まっているので、全ページ数が分かります。 \n今回表示しようとしているページ番号から、取得したい行が分かり、ページに表示するレコード一覧を取得しています。(ちょっと斜め読みしただけなので不正確かもしれません)\n\nこの仕組みはページネーションを実現しているフレームワークは共通しているはずです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T06:20:04.897",
"id": "44123",
"last_activity_date": "2018-05-21T06:20:04.897",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2238",
"parent_id": "44105",
"post_type": "answer",
"score": 3
},
{
"body": "@htb さんが回答されているとおり,基本的にはリクエストごとに毎回結構負荷のかかる処理が走っちゃいますね。\n\n * 件数の取得: `paginate` のみ\n * データの取得: `paginate` `simplePaginate` 共通\n\n`LIMIT ... OFFSET ...`\nクエリを毛嫌いしているので,カーソルベースのページネーションを実現するライブラリを自作しました。弊社業務でも採用しているのでよかったら使ってみてください。\n\n * [OFFSETを使わない高速ページネーションを任意のPHPフレームワークで超簡単に実現する - Qiita](https://qiita.com/mpyw/items/b94b7d69146777f7a407)\n * [lampager/lampager: Rapid pagination for various PHP frameworks](https://github.com/lampager/lampager)\n * [lampager/lampager-laravel: Rapid pagination for Laravel](https://github.com/lampager/lampager-laravel)\n\n注意点:\nLaravel標準のページネーションのように,`Request`オブジェクトに対して強引にグローバルアクセスをしているわけではないので,コントローラにて自分でパラメータ等を渡してあげる必要はあります。\n\n実際の使用例↓\n\n(IDEで補完を利かせるためにあえてマクロは使用しておりません)\n\n### `PostController.php`\n\n```\n\n <?php\n \n declare(strict_types=1);\n \n namespace App\\Http\\Controllers;\n \n use App\\Post;\n use Illuminate\\Http\\Request;\n use Lampager\\Laravel\\PaginationResult;\n use Lampager\\Laravel\\Paginator;\n \n class PostController extends Controller\n {\n /**\n * @param Request $request\n * @return PaginationResult\n */\n public function index(Request $request): PaginationResult\n {\n $query = Post::query();\n \n if ($types = array_intersect(config('app.post_types'), explode(',', $request->input('type', '')))) {\n $query->whereIn('type', $types);\n }\n \n return (new Paginator($query))\n ->orderByDesc('updated_at')\n ->orderByDesc('id')\n ->limit(20)\n ->paginate($this->replaceParameterNames($request->only('next_updated_at', 'next_id'), [\n 'next_updated_at' => 'updated_at',\n 'next_id' => 'id',\n ]));\n }\n }\n \n```\n\n### `ReplacesQueryParameterNames.php`\n\n基底 `Controller` でミックスインしておきます。\n\n```\n\n <?php\n \n declare(strict_types=1);\n \n namespace App\\Http\\Controllers\\Concerns;\n \n /**\n * Trait ReplacesQueryParameterNames\n */\n trait ReplacesQueryParameterNames\n {\n /**\n * 引数のキーを置換して返します。\n *\n * @param array $input\n * @param array $map\n * @return array\n */\n protected function replaceParameterNames(array $input, array $map): array\n {\n $output = [];\n foreach ($input as $key => $value) {\n $output[$map[$key] ?? $key] = $value;\n }\n return $output;\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-31T07:01:11.683",
"id": "44425",
"last_activity_date": "2018-05-31T07:01:11.683",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "940",
"parent_id": "44105",
"post_type": "answer",
"score": 1
}
] | 44105 | null | 44123 |
{
"accepted_answer_id": "44108",
"answer_count": 2,
"body": "リスト処理で下のプログラムのコメント部分の「//最後のデータを探す」というコードの意味がわかりませんprintfでどこで使われてるか検証しましたがわかりません。\nそもそも意味があるコードなのかもわかりません、自分的には意味ないコードだと思ってますがどうなのか知りたいです\n\n```\n\n #include \"stdio.h\"\n #include \"conio.h\"\n #include \"string.h\"\n #include \"stdlib.h\"\n \n #define NAMELEN 16\n \n struct list {\n \n char name[NAMELEN];\n int price;\n struct list *next;\n \n };\n \n struct list *start = NULL;\n \n int main() {\n \n struct list *p = NULL, *dt, *t;\n int n;\n char name[NAMELEN] = { '\\0' };\n \n do {\n do {\n printf(\"データの追加・削除[Add...0 / Delete... 9]:\");\n scanf_s(\"%d\", &n);\n if (n != 0 && n != 9) {\n printf(\"0もしくは9を入力してください\\n\");\n }\n } while (n != 0 && n != 9);\n \n /*追加*/\n if (n == 0) {\n dt = (struct list *)malloc(sizeof(struct list));\n dt->next = NULL;\n printf(\"名前:\"); scanf_s(\"%s\",dt->name,NAMELEN);\n printf(\"値段:\"); scanf_s(\"%d\", &dt->price);\n if (start == NULL) {\n start = dt;\n p = dt;\n }\n else {\n p->next = dt;\n p = dt;\n }\n }\n \n \n /*削除*/\n if (n == 9) {\n \n if (start == NULL) {\n printf(\"データがありません\\n\");\n }\n else {\n p = NULL;/*dtの一つ前のデータのポインタを入れる*/\n printf(\"名前:\"); scanf_s(\"%s\",name,NAMELEN);\n dt = start;\n do {\n if (strcmp(name, dt->name) == 0) {//同じ\n if (p == NULL) {//先頭のデータと同じだった時の削除\n printf(\"p\\n\");//確認\n start = dt->next;\n }\n else {\n p->next = dt->next;\n free(dt);\n dt = NULL;\n }\n \n break;\n }\n else {\n p = dt;\n dt = dt->next;\n }\n } while (dt != NULL);\n \n //最後のデータを探す\n p = start;\n if (p == NULL) {\n }\n else {\n \n do {\n \n if (p->next != NULL) {\n printf(\"最後のデータを探す\\n\");\n \n p = p->next;\n }\n else {\n break;\n }\n \n } while (p != NULL);\n }\n \n }\n \n }\n \n /*表示*/\n t = start;\n if (t != NULL) {\n n = 1;\n do {\n printf(\"No.%d: 名前 %s 値段 %d\\n\", n, t->name, t->price);\n t = t->next;\n n++;\n } while (t != NULL);\n }\n else {\n printf(\"データはありません\");\n }\n \n do {\n printf(\"もう一度? [YES・・・0 / NO・・・9]:\");\n scanf_s(\"%d\",&n);\n if (n != 0 && n != 9) {\n printf(\"0もしくは9を入力してください\\n\");\n }\n } while (n != 0 && n != 9);\n \n \n } while (n != 9);\n \n \n \n \n _getch();\n return 0;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T12:15:29.207",
"favorite_count": 0,
"id": "44106",
"last_activity_date": "2018-05-20T13:35:10.230",
"last_edit_date": "2018-05-20T13:35:10.230",
"last_editor_user_id": "76",
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "リスト処理でサンプルコードに用途不明なコードがある",
"view_count": 162
} | [
{
"body": "意味はあります。\n\nこのコードでは、`start`がリストの先頭の要素を指し、`p`が最後の要素を指すようになっています。こうすることで新しい要素を追加するときに、リスト全体を走査することなしに、`p`だけ見て追加することができます。\n\n一方、要素を削除するときには、削除する要素を探すため、`p`をリストを走査する目的に使っています。このため、削除した後に`p`が一番最後の要素を指しているとは限りません。このままでは、次に要素を追加することに問題が起きてしまいます。そこでもう一度`p`を最後の要素を指すようにするのが、該当のコード部分です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T13:14:54.123",
"id": "44108",
"last_activity_date": "2018-05-20T13:14:54.123",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3605",
"parent_id": "44106",
"post_type": "answer",
"score": 1
},
{
"body": "データを追加する際、`p` がリストの末尾を指していることを前提に、`p` の次へ追加しています。\n\n従って、データを削除した際には、`p` がちゃんと末尾を指すようにしておかないと、次に追加する時におかしなことになります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T13:31:04.447",
"id": "44109",
"last_activity_date": "2018-05-20T13:31:04.447",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5288",
"parent_id": "44106",
"post_type": "answer",
"score": 1
}
] | 44106 | 44108 | 44108 |
{
"accepted_answer_id": "44196",
"answer_count": 2,
"body": "root直下のファイル以外が読み込まれない状況です。 \n`http://ドメイン/.well-known/acme-\nchallenge`内にあるindex.htmlを表示させたいのですが、アクセスすると、404や301エラーになってしまいます。\n\n単純に静的ページの読み込みなんですが、どのように設定すれば良いか解決策を教えていただけると助かります。 \n環境は、CentOS7でNginx 1.12.2です。\n\n`curl -i`コマンドで確認すると、以下のように結果が変わっているのがわかりました。 \n[http://ドメイン/.well-known/acme-\nchallenge](http://%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3/.well-known/acme-\nchallenge)\n\n```\n\n HTTP/1.1 301 Moved Permanently\n Server: nginx\n Date: Sun, 20 May 2018 16:38:58 GMT\n Content-Type: text/html\n Content-Length: 178\n Connection: keep-alive\n Location: https://ドメイン/.well-known/acme-challenge\n \n <html>\n <head><title>301 Moved Permanently</title></head>\n <body bgcolor=\"white\">\n <center><h1>301 Moved Permanently</h1></center>\n <hr><center>nginx</center>\n </body>\n </html>\n \n```\n\n[http://ドメイン/.well-known/acme-\nchallenge/](http://%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3/.well-known/acme-\nchallenge/)\n\n```\n\n HTTP/1.1 404 Not Found\n Server: nginx\n Date: Sun, 20 May 2018 16:38:56 GMT\n Content-Type: text/html; charset=UTF-8\n Content-Length: 162\n Connection: keep-alive\n \n <html>\n <head><title>404 Not Found</title></head>\n <body bgcolor=\"white\">\n <center><h1>404 Not Found</h1></center>\n <hr><center>nginx</center>\n </body>\n </html>\n \n```\n\n[http://ドメイン/.well-known/acme-\nchallenge/index.html](http://%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3/.well-\nknown/acme-challenge/index.html)\n\n```\n\n HTTP/1.1 404 Not Found\n Server: nginx\n Date: Sun, 20 May 2018 16:39:04 GMT\n Content-Type: text/html; charset=UTF-8\n Content-Length: 162\n Connection: keep-alive\n \n <html>\n <head><title>404 Not Found</title></head>\n <body bgcolor=\"white\">\n <center><h1>404 Not Found</h1></center>\n <hr><center>nginx</center>\n </body>\n </html>\n \n```\n\ncurl -i <http://localhost:80/.well-known/acme-challenge/index.html>\n\n```\n\n HTTP/1.1 404 Not Found\n Server: nginx/1.12.2\n Date: Mon, 21 May 2018 14:27:40 GMT\n Content-Type: text/html\n Content-Length: 169\n Connection: keep-alive\n \n <html>\n <head><title>404 Not Found</title></head>\n <body bgcolor=\"white\">\n <center><h1>404 Not Found</h1></center>\n <hr><center>nginx/1.12.2</center>\n </body>\n </html>\n \n```\n\nnginx.confの設定は以下の通りです。 \n`/etc/nginx/conf.d/`以下に設定ファイルはありません。`/etc/nginx/nginx.conf`のみです。\n\n```\n\n user nginx;\n worker_processes 1;\n pid /var/run/nginx.pid;\n \n \n events {\n worker_connections 1024;\n }\n \n \n http {\n include /etc/nginx/mime.types;\n default_type application/octet-stream;\n index index.html index.htm index.php;\n \n server {\n listen 80;\n server_name ドメイン;\n root /var/www/html;\n }\n \n log_format main '$remote_addr - $remote_user [$time_local] \"$request\" '\n '$status $body_bytes_sent \"$http_referer\" '\n '\"$http_user_agent\" \"$http_x_forwarded_for\"';\n \n access_log /var/log/nginx/access.log main;\n \n sendfile on;\n keepalive_timeout 65; \n \n error_log /var/log/nginx/error.log debug;\n }\n \n```\n\n/etc/nginx/mime.types\n\n```\n\n types {\n text/html html htm shtml;\n text/css css;\n text/xml xml;\n image/gif gif;\n image/jpeg jpeg jpg;\n application/javascript js;\n application/atom+xml atom;\n application/rss+xml rss;\n \n text/mathml mml;\n text/plain txt;\n text/vnd.sun.j2me.app-descriptor jad;\n text/vnd.wap.wml wml;\n text/x-component htc;\n \n image/png png;\n image/tiff tif tiff;\n image/vnd.wap.wbmp wbmp;\n image/x-icon ico;\n image/x-jng jng;\n image/x-ms-bmp bmp;\n image/svg+xml svg svgz;\n image/webp webp;\n \n application/font-woff woff;\n application/java-archive jar war ear;\n application/json json;\n application/mac-binhex40 hqx;\n application/msword doc;\n application/pdf pdf;\n application/postscript ps eps ai;\n application/rtf rtf;\n application/vnd.apple.mpegurl m3u8;\n application/vnd.ms-excel xls;\n application/vnd.ms-fontobject eot;\n application/vnd.ms-powerpoint ppt;\n application/vnd.wap.wmlc wmlc;\n application/vnd.google-earth.kml+xml kml;\n application/vnd.google-earth.kmz kmz;\n application/x-7z-compressed 7z;\n application/x-cocoa cco;\n application/x-java-archive-diff jardiff;\n application/x-java-jnlp-file jnlp;\n application/x-makeself run;\n application/x-perl pl pm;\n application/x-pilot prc pdb;\n application/x-rar-compressed rar;\n application/x-redhat-package-manager rpm;\n application/x-sea sea;\n application/x-shockwave-flash swf;\n application/x-stuffit sit;\n application/x-tcl tcl tk;\n application/x-x509-ca-cert der pem crt;\n application/x-xpinstall xpi;\n application/xhtml+xml xhtml;\n application/xspf+xml xspf;\n application/zip zip;\n \n application/octet-stream bin exe dll;\n application/octet-stream deb;\n application/octet-stream dmg;\n application/octet-stream iso img;\n application/octet-stream msi msp msm;\n \n application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;\n application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;\n application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;\n \n audio/midi mid midi kar;\n audio/mpeg mp3;\n audio/ogg ogg;\n audio/x-m4a m4a;\n audio/x-realaudio ra;\n \n video/3gpp 3gpp 3gp;\n video/mp2t ts;\n video/mp4 mp4;\n video/mpeg mpeg mpg;\n video/quicktime mov;\n video/webm webm;\n video/x-flv flv;\n video/x-m4v m4v;\n video/x-mng mng;\n video/x-ms-asf asx asf;\n video/x-ms-wmv wmv;\n video/x-msvideo avi;\n }\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T17:00:29.670",
"favorite_count": 0,
"id": "44110",
"last_activity_date": "2018-05-23T16:29:15.150",
"last_edit_date": "2018-05-21T14:33:23.663",
"last_editor_user_id": "25223",
"owner_user_id": "25223",
"post_type": "question",
"score": 0,
"tags": [
"nginx"
],
"title": "Nginx 301や404になってしまう",
"view_count": 6826
} | [
{
"body": "301 redirectが起きるのは、そうなるようnginx.confファイルに書いたからです。\n\n301\nredirectのリダイレクトフラグは、\"permanent\"ですから、nginx.confでpermanentを含む行を探して削除(もしくはコメントアウト)してnginxを再起動すれば、301\nredirectが起きなくなるはずです。\n\n301\nredirectの情報は、Webブラウザ側でキャッシュされます(指定したURLで301が返ってくると、次回以降は指定されたURLではなく、redirect先(現状では404が返ってくる)に直にアクセスするようになります。) \nそのため、動作確認の前にWebブラウザのキャッシュを削除してください。\n\n=== \n使っていらしゃる\nnginx.confの内容と、どのようなリダイレクトがしたいのかを質問に追記すると、nginx.confの修正方法をアドバイスしてもらえると思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T23:49:09.523",
"id": "44112",
"last_activity_date": "2018-05-20T23:49:09.523",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "44110",
"post_type": "answer",
"score": 0
},
{
"body": "解決しました。DNSの設定に問題がありました。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T16:29:15.150",
"id": "44196",
"last_activity_date": "2018-05-23T16:29:15.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25223",
"parent_id": "44110",
"post_type": "answer",
"score": 1
}
] | 44110 | 44196 | 44196 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Nuxt.js (Vue) で Selection.js を使いたいのですが、どのように設定すれば使えるようになるのでしょうか?\n\n * [Simonwep / selection](https://github.com/Simonwep/selection#install)\n\n例えば、moment.js は以下のようにして使えるようになったのですが、selection.js はうまく行きませんでした。\n\n./nuxt.config.js\n\n```\n\n const webpack = require('webpack')\n \n module.exports = {\n build: {\n ...\n vendor: [\n 'moment'\n ],\n plugins: [\n new webpack.ProvidePlugin({\n 'moment': 'moment'\n })\n ]\n },\n ...\n }\n \n```\n\n* * *\n\n以下の方法を試した時の結果を追加します。\n\n./nuxt.config.js\n\n```\n\n module.exports = {\n (vue init で生成された時のまま...)\n ...\n mode: 'spa'\n }\n \n```\n\n./pages/index.vue\n\n```\n\n <template>\n <section class=\"container\">\n <ul>\n <li v-for=\"b in bs\" :key=\"b.name\">\n {{ b.name }}\n </li>\n </ul>\n </section>\n </template>\n \n <script>\n import Selection from '@simonwep/selection-js'\n \n export default {\n data () {\n return {\n bs: [...new Array(10)].map((b, i) => {\n return {\n name: `b${i}`,\n };\n })\n }\n },\n mounted () {\n const options = {\n containers: ['ul'],\n boundarys: ['ul'],\n };\n Selection.create(options)\n }\n }\n </script>\n \n```\n\nその結果が以下のようになっています。 \n[](https://i.stack.imgur.com/t7UJC.png)\n\n下記エラーメッセージを見ると、`selection.js` の 353行目 (①) で `Unexcepted token` と言っています。\n\n[](https://i.stack.imgur.com/hTHtx.png)\n\n353行目は「...options」(②) なので、spread syntax を解釈できないんだろうなと思い、selection.js の\npackage.json を以下のように書き換えてみました。\n\n./node_modules/@simonwep/selection-js/package.json\n\n```\n\n \"main\": \"selection.min.js\", ..................................... (1)\n ...\n \"scripts\": {\n \"build\": \"babel selection.js --out-file selection.min.js\" ..... (2)\n },\n \n```\n\n上記 (2) を見ると babel による transpile の結果が selection.min.js なので、上記 (1) に\nselection.min.js を指定し、再度 `npm run dev` すると、下図の通り、selection.js を使うことができました。\n\n[](https://i.stack.imgur.com/WMQkF.png)\n\nとなると、結局は selection.js の package.json をいじること無く、selection.min.js\nを使うように指定すればいいだけのようです。\n\nで、その指定方法は以下のようにするだけですが、\n\n./pages/index.vue\n\n```\n\n import Selection from '@simonwep/selection-js/selection.min.js'\n \n```\n\n他の .vue でも使いたいので、nuxt.config.js にどう記述したら良いのでしょう?\n\n* * *\n\n以下を参考に webpack.ProvidePlugin を書き直してたんですが、\n\n> webpack v4.8.3 / ProvidePlugin / Usage: Vue.js \n> <https://webpack.js.org/plugins/provide-plugin/#usage-vue-js>\n```\n\n new webpack.ProvidePlugin({\r\n Vue: ['vue/dist/vue.esm.js', 'default']\r\n })\n```\n\nどうしても動かないから、下記ソースコードを読んでいたらどうも上記サンプルが想定する動きと何か違う。\n\n> node_modules\\webpack\\lib\\ProvidePlugin.js\n\nこれ、webpack 4 のドキュメントなんですよね。 \nv3 のドキュメントが見つからない。\n\nソースコードに合わせて設定してみたところ、以下で動きました。\n\n./nuxt.config.js \n\n```\n\n build: {\r\n ...\r\n plugins: [\r\n new webpack.ProvidePlugin({\r\n 'Selection': '@simonwep/selection-js/selection.min.js'\r\n })\r\n ]\r\n },\r\n mode: 'spa'\n```\n\n[](https://i.stack.imgur.com/CoFCV.png)\n\n[](https://i.stack.imgur.com/tKH4d.png)\n\nnuxt v1.4.0 は webpack v3.12.0 を使ってるんですね。\n\n[](https://i.stack.imgur.com/rzNot.png)\n\nwebpack v3 のドキュメントは何処にあるんだろう?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-20T19:55:46.057",
"favorite_count": 0,
"id": "44111",
"last_activity_date": "2023-05-10T13:06:25.830",
"last_edit_date": "2018-05-21T13:20:08.180",
"last_editor_user_id": "13813",
"owner_user_id": "13813",
"post_type": "question",
"score": 0,
"tags": [
"nuxt.js"
],
"title": "Nuxt.js で selection.js を使えるようにするには?",
"view_count": 593
} | [
{
"body": "これを試してみてください。\n\n[can't compile object spread operator unexpected token error -\nGitHub](https://github.com/JeffreyWay/laravel-\nmix/issues/76#issuecomment-271920174)\n\n日本語で言うと、`transform-object-rest-spread`プラグインをインストールして、\n\n```\n\n npm install --save-dev babel-plugin-transform-object-rest-spread\n \n```\n\nプロジェクトのルートフォルダーに`.babelrc`を作成して、以下を入力してください。\n\n```\n\n {\n \"plugins\": [\"transform-object-rest-spread\"]\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T07:46:21.407",
"id": "44128",
"last_activity_date": "2018-05-21T07:46:21.407",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20206",
"parent_id": "44111",
"post_type": "answer",
"score": 0
}
] | 44111 | null | 44128 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "androidでチャットアプリを作りたいと考えています。 \nしかしながら、基本構成がわかりません。 \nFirebaseを使えばよさそうです。\n\nrealtime databaseと \nFirebase Cloud Messaging Android \nの2つでしょうか?\n\nrealtime\ndatabaseを使えば、2つのアンドロイド端末間で、同じチャット画面が表示されると思います。しかしながら、片方の端末を使っている人がactivityを閉じてしまった場合、その片方の人は、activityが更新されたかどうか、わからないので、Firebase\nCloud Messaging Android で、チャットが着ましたと通知する必要があると思うんです。\n\n2人でチャットしていて、片方の人が画面を閉じてしまった場合、相手に、簡単なメッセージを飛ばして、通知する方法を実現するやり方を知りたいです。当然、画面を閉じないでちゃんと表示された場合は、簡単なメッセージは通知しません。\n\nrealtime database \nFirebase Cloud Messaging Android\n\nどっちも、ちょっとだけ違うような気がします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T01:45:43.740",
"favorite_count": 0,
"id": "44115",
"last_activity_date": "2023-01-19T14:16:11.610",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28591",
"post_type": "question",
"score": 0,
"tags": [
"android",
"firebase"
],
"title": "androidでチャットアプリ",
"view_count": 217
} | [
{
"body": "どのあたりが違うような気がしているのでしょうか? \nRealtime Databaseでチャットのメイン部分を作り,通知はFirebase Cloud Messagingで送れば良いのではないでしょうか.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T01:52:18.600",
"id": "44116",
"last_activity_date": "2018-05-21T01:52:18.600",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5273",
"parent_id": "44115",
"post_type": "answer",
"score": 1
},
{
"body": "参考になるか分かりませんが、 \n私も同じようなアプリを作っています。 \nチャットアプリならYoutubeで、 \n「Chat app」と検索すると色々出てきますよ。 \n私が参考にしてるYoutube載せておきます。 \n<https://youtu.be/8Pv96bvBJL4>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2023-01-19T14:16:11.610",
"id": "93456",
"last_activity_date": "2023-01-19T14:16:11.610",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "56672",
"parent_id": "44115",
"post_type": "answer",
"score": 0
}
] | 44115 | null | 44116 |
{
"accepted_answer_id": "44118",
"answer_count": 1,
"body": "ブラウザで表示させようとすると`Property [id] does not exist on this collection\ninstance.`と表示されます。\n\nview\n\n```\n\n @section('content')\n \n @foreach($data as $row)\n <tr>\n <td>{{ $row->id }}</td>\n <td>{{ $row->title }}</td>\n </tr>\n @endforeach\n \n \n @endsection\n \n```\n\ncontroller\n\n```\n\n public function index()\n {\n \n $data['posts']=DB::table('posts')->get();\n var_dump($data);\n return View('post/index',['data' => $data]);\n \n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T01:55:14.790",
"favorite_count": 0,
"id": "44117",
"last_activity_date": "2018-05-21T03:24:42.177",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10088",
"post_type": "question",
"score": 0,
"tags": [
"laravel"
],
"title": "Laravel5 でviewにデータを受け渡す時にエラーが出る",
"view_count": 4100
} | [
{
"body": "$data['posts']にテーブルの抽出結果を入れているので、 \nforeachでループしながら参照するのではなく$dataでなく$data['posts']です。 \nそのため、$row(=$data['posts'])は配列(正確にはCollectionクラス)なのでidという属性はもっていないと言われています。\n\n修正箇所としてはコントローラー出直す場合、\n\n```\n\n $data=DB::table('posts')->get();\n \n```\n\nビューで直す場合、\n\n```\n\n @foreach($data['posts'] as $row)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T03:24:42.177",
"id": "44118",
"last_activity_date": "2018-05-21T03:24:42.177",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28593",
"parent_id": "44117",
"post_type": "answer",
"score": 0
}
] | 44117 | 44118 | 44118 |
{
"accepted_answer_id": "44121",
"answer_count": 1,
"body": "pyqtで表示する画像やサウンドを一つのファイルにまとめたいです。そこでそれらをpickle化しようと思い、次のようなコードを書いてみました。\n\n```\n\n import pickle\n from PyQt5 import QtWidgets,QtMultimedia\n from PyQt5.QtWidgets import *\n \n img=QPixmap(\"画像.png\")\n img2=QPixmap(\"画像2.jpg\")\n list_image=[img,img2]\n save_file=open(\"image_list.dat\",\"wb\")\n pickle.dump(list_image,save_file)\n save_file.close()\n \n sound=QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(\"サウンド.wav\"))\n sound2=QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(\"サウンド2.wav\"))\n sound_list=[sound,sound2]\n save_file2=open(\"sound_list.dat\",\"wb\")\n pickle.dump(sound_list,save_file2)\n save_file2.close()\n \n```\n\nしかし、これを実行すると\n\n```\n\n TypeError: can't pickle QMediaContent objects\n \n```\n\nや\n\n```\n\n TypeError: can't pickle QPixmap objects\n \n```\n\nと出力されます。QPixmapやQMediaはpickleに対応していないようです。これらの情報を一つのファイルにまとめるにはどうすればよいのでしょうか。pickle以外に対応しているものはあるのでしょうか。それともpickleでもうまくやれば十分カバーできるのでしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T04:42:02.680",
"favorite_count": 0,
"id": "44119",
"last_activity_date": "2018-10-07T07:11:13.683",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26529",
"post_type": "question",
"score": 1,
"tags": [
"python",
"pyqt"
],
"title": "QPixmapやQMediaの画像やサウンドをpickleのように一つにまとめたい",
"view_count": 250
} | [
{
"body": "**QPixmapオブジェクトを保存する方法について** \n既に解決されたようですが、既存の[pyqt](/questions/tagged/pyqt \"'pyqt'\nのタグが付いた質問を表示\")を使った方法を残しておきます。 \n[pyqt](/questions/tagged/pyqt \"'pyqt'\nのタグが付いた質問を表示\")では、以下の方法によって、簡単にセーブとロードを行うことが出来ます。\n\n```\n\n file = QtCore.QFile(anyfile)\n file.open(QtCore.QIODevice.ReadWrite)\n out = QtCore.QDataStream()\n image = QtGui.QPixmap()#An object you costomized.Please not use empty pixmap!\n image = image.toImage()\n out << image#C++でよくつかわれる記号\n \n```\n\n次に、取り出すときです。\n\n```\n\n file = QtCore.QFile(the same file)\n file.open(QtCore.QIODevice.ReadOnly)\n out = QtCore.QDataStream()\n image = QtGui.QPixmap()#Please prepare empty pixmap object\n image = image.toImage()\n out >> image#C++でよくつかわれる記号 記号が逆になっています。\n \n```\n\n**waveファイルの保存について** \n次に、[wave](/questions/tagged/wave \"'wave' のタグが付いた質問を表示\")ファイルについてです。\n\n質問者様は、`scipy.io.wave`で実装されたようですが、私は[python](/questions/tagged/python \"'python'\nのタグが付いた質問を表示\")標準の[wave](/questions/tagged/wave \"'wave'\nのタグが付いた質問を表示\")で実装してみました。既にご存知かもと思いますが、[wave](/questions/tagged/wave \"'wave'\nのタグが付いた質問を表示\")ファイルやほかの音声データファイルには、最初にたくさんの識別情報が含まれています。\n\n```\n\n import wave\n wave_data = wave.open(\"any_file.wav\",\"rb\")\n wave_read_data = wave_data.getfp().read()\n wave_data_nchannels = wave_data.getnchannels()\n wave_data_sampwidth = wave_data.getsampwidth()\n wave_data_framerate = wave_data.getframerate()\n wave_data_nframes = wave_data.getnframes()\n wave_data_comptype = wave_data.getcomptype()\n wave_data_compname = wave_data.getcompname()\n wave_byte_data = QtCore.QByteArray(wave_read_data)\n \n out.writeInt8(self.wave_data_nchannels)\n out.writeInt8(self.wave_data_sampwidth)\n out.writeInt64(self.wave_data_framerate)\n out.writeInt64(self.wave_data_nframes)\n out.writeQString(self.wave_data_comptype)\n out.writeQString(self.wave_data_compname)\n wave_data_byte = QtCore.QByteArray(self.wave_byte_data)\n out << wave_data_byte\n \n```\n\nそれらを、先ほどと同じ要領で、`QDataStream`に格納します。\n\nこれらを取り出す時には同じ要領でとりだします。\n\n```\n\n wave_data_nchannels = out.readInt8()\n wave_data_sampwidth = out.readInt8()\n wave_data_framerate = out.readInt64()\n wave_data_nframes = out.readInt64()\n wave_data_comptype = out.readQString()\n wave_data_compname = out.readQString()\n wave_byte_data = QtCore.QByteArray()\n out >> wave_byte_data\n \n```\n\nこの後、空のwaveファイルに入れ込みます。\n\n```\n\n p = wave.open(\"temporary.wav\",\"wb\")#一時的なwavファイルを作成する。 \n p.setnchannels(wave_data_nchannels) \n p.setsampwidth(wave_data_sampwidth)\n p.setframerate(wave_data_framerate)\n p.setnframes(wave_data_nframes)\n p.setcomptype(wave_data_comptype)\n p.writeframes(wave_byte_data.data())\n #音を発生させる。 \n QtGui.QSound().play(p)\n p.close()\n \n```\n\nこのように、扱うモジュールによっては、`QDataStream`がとる型や順番も異なります。 \n`scipy.io.wave`ファイルは、少し制限があるような書き込みがされていましたので、 \nもしこちらをご検討いただければ嬉しいです。\n\n自己解決された方法でも問題ないとは思いますが、このやり方でも、実体としての`wav`拡張子ファイルや、`png`,`JPEG`,`gif`,`svg`等の`image`ファイル自体がバイナリ化され、常にどこでも取り出し行う事ができるようになります。[qt](/questions/tagged/qt\n\"'qt' のタグが付いた質問を表示\")をお使いであれば、この方法もご検討ください。`temporary\nfile`は、音を再生するための、使いまわしのファイルです。\n\n`QImage`や、`QByteArray`、`QColor`,`QPoint`,`QSize`,`QRect`等、`Qt`独自の型で定義されているオブジェクトであり、[python](/questions/tagged/python\n\"'python' のタグが付いた質問を表示\")の通常のデータに直すのが、面倒なデータは、そのままバイナリ化できるようになっているです。\n\n逆に、`int`型や`str`型を、`<<`とか`>>`でデータに格納しようとすると、怒られますので,ちゃんとした`writeInt8~64`と`readInt8~64`メソッドを利用するようにしてください。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T06:08:09.473",
"id": "44121",
"last_activity_date": "2018-10-07T07:11:13.683",
"last_edit_date": "2018-10-07T07:11:13.683",
"last_editor_user_id": "24284",
"owner_user_id": "24284",
"parent_id": "44119",
"post_type": "answer",
"score": 0
}
] | 44119 | 44121 | 44121 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "最近MongoDBの環境に関して結構悩んでおります。 \n環境: \n・MongoDB Server 3.2.0 \n(*Microsoft AzureのCosmosDBにMongoDB API利用でデータベースを作成した) \n・mongo_php_driver 1.4.3 \n・mongo_php_library 1.3.2 \n・PHP 5.6.35 \n目的: \n・MongoDB\\Collection::mapReduce()を実行したい。 \n問題: \n・exception 'MongoDB\\Driver\\Exception\\RuntimeException' with message 'Command\nis not supported' (MongoDB\\Driver\\Server->executeReadCommand)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T06:03:12.280",
"favorite_count": 0,
"id": "44120",
"last_activity_date": "2018-05-21T08:48:14.163",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28594",
"post_type": "question",
"score": 0,
"tags": [
"mongodb"
],
"title": "MongoDB\\Collection::mapReduce()を実行の問題",
"view_count": 75
} | [
{
"body": "[リリースノート](https://github.com/mongodb/mongo-php-\ndriver/releases/tag/1.4.0)を見ると、`executeReadCommand`は1.4.0から追加されているようなので、実際にはmongo_php_driver\n1.4.0より前のバージョンが使用されているということはないですかね? \n`composer.json`を見直すことで解決しないでしょうか。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T08:48:14.163",
"id": "44130",
"last_activity_date": "2018-05-21T08:48:14.163",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "44120",
"post_type": "answer",
"score": 0
}
] | 44120 | null | 44130 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "以下のURLにあるように、スクロールしたらパーティクルが集合し、図形を表現する動きを実装しています。\n\n[リンク](http://penqe.com/temp/sample.html)\n\nコード内にもありますが、集合する図形の座標情報はstlの3dデータをblenderという3d編集ソフトを使用してjsonデータに変換したものを読み込んでいます。 \nしかし、こちらの座標情報だと頂点座標しか格納されていないために、パーティクルで表現するとパーティクルの密度がバラバラになってしまい、いまいちよくわからなくなってしまいます。 \n以下のサイトのようにパーティクルの間隔を均一に表現したいのですが何か方法はありますでしょうか。\n\n[参考サイト](http://www.recruit-mp.co.jp/recruit/)\n\nちなみに、スクロールして一番はじめに生成される図形は以下の画像にあります図形をよみこんでいます。\n\n[](https://i.stack.imgur.com/CSIJ8.png)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T06:26:32.003",
"favorite_count": 0,
"id": "44124",
"last_activity_date": "2018-05-21T06:26:32.003",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28595",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"jquery",
"three.js"
],
"title": "three.jsで表現したパーティクルの集合図形を整列させたい。",
"view_count": 238
} | [] | 44124 | null | null |
{
"accepted_answer_id": "44145",
"answer_count": 1,
"body": "お世話になります。\n\n私はいまCakePHPを学んでいるのですが、 \n紹介ページによって \nPOSTやGETの値を取得する方法が \n2種類あることに気づき、困惑しています。 \n・$this->data \n・$this->request->data \n中身をみたところ、同じ内容が入っているようなのですが \n何か違いがあるのでしょうか。\n\nよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T06:58:54.070",
"favorite_count": 0,
"id": "44125",
"last_activity_date": "2018-05-22T02:27:59.007",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9238",
"post_type": "question",
"score": 1,
"tags": [
"cakephp"
],
"title": "CakePHPのControllerにおいて$this->dataと$this->request->dataの意味は同じ?",
"view_count": 9366
} | [
{
"body": "`$this->data` はバージョン1系の古い記法であり非推奨です。\n\nCakePHP バージョン3.4以降であれば、 `$this->request->getData()` が推奨される書き方です。 \nバージョン2系やバージョン3系の3.3以前なら `$this->request->data()` で取得します。\n\nまた、`$this->request->data['User']['email']`\nのような呼び出しは、キーが存在しない場合にエラーが発生するので、`$this->request->data('User.email')`,\n`$this->request->getData('User.email')` のようにメソッドで取得すべきです。\n\nリクエストとレスポンスオブジェクト - 2.x <https://book.cakephp.org/2.0/ja/controllers/request-\nresponse.html#post>\n\nリクエストとレスポンスオブジェクト - 3.6 <https://book.cakephp.org/3.0/ja/controllers/request-\nresponse.html#id5>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T02:27:59.007",
"id": "44145",
"last_activity_date": "2018-05-22T02:27:59.007",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2668",
"parent_id": "44125",
"post_type": "answer",
"score": 2
}
] | 44125 | 44145 | 44145 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "調べても見つからないので質問させていただきます。 \nredirect_toの使い方なんですが、こちらページを指定するのはできるんですが、同じページに遷移というか、ページ更新といったことってできますでしょうか?\n\nやりたいことは、コントローラーにて、ある特定のアクションが起きた際にページ更新するということです。\n\n複数のページにまたがるアクションがあって、毎回ページが移動されると手間がかかるのでできたらページの移動はさせたくないのですが、そんな方法ってありますでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T08:48:59.837",
"favorite_count": 0,
"id": "44131",
"last_activity_date": "2019-09-11T03:03:50.437",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27359",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby"
],
"title": "redirect先を同じページにする",
"view_count": 5617
} | [
{
"body": "Rails 5 以降 \n`redirect_back(fallback_location: YOUR_PAGE)`\n\nRails 4 以前 \n`redirect_to :back`\n\nで可能です。 YOUR_PAGEにはページへのパスを入れてください",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T15:23:11.600",
"id": "44139",
"last_activity_date": "2018-05-21T15:23:11.600",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26960",
"parent_id": "44131",
"post_type": "answer",
"score": 1
}
] | 44131 | null | 44139 |
{
"accepted_answer_id": "44141",
"answer_count": 1,
"body": "XSL-FOではで文字に下線をひくことができますが、文字色と下線の色を異なる色にする方法はありますか?\n\nCSSには、text-decoration-color がありますが XSL-FOにそれは見つかりませんでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T10:00:54.933",
"favorite_count": 0,
"id": "44133",
"last_activity_date": "2018-05-21T22:17:23.790",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25399",
"post_type": "question",
"score": 1,
"tags": [
"xsl",
"xsl-fo",
"組版"
],
"title": "XSL-FOで下線の色を変更する",
"view_count": 100
} | [
{
"body": "XSL勧告で規定されていない場合、ベンダーの拡張で実現されている場合があります.\n\n例) AH Formatterの場合\n\n<http://www.antenna.co.jp/AHF/help/v65/ahf-ext.html#text-decoration>\n\nの `axf:text-line-color` が該当します.",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T22:17:23.790",
"id": "44141",
"last_activity_date": "2018-05-21T22:17:23.790",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9503",
"parent_id": "44133",
"post_type": "answer",
"score": 2
}
] | 44133 | 44141 | 44141 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "マックのローカル環境構築でVirtualBoxを使いたいのですが、初めにインストールした時はインストールはできたのですが仮想マシンを立ち上げることができなかったので、消してインストールし直そうとしたらできなくなりました。 \nドットインストールで学んでいるのでVirtualBoxをできればインストールして早く使いたいです。\n\n[](https://i.stack.imgur.com/F22EM.png)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T13:01:37.370",
"favorite_count": 0,
"id": "44136",
"last_activity_date": "2018-05-24T00:14:29.520",
"last_edit_date": "2018-05-23T17:06:36.497",
"last_editor_user_id": "3060",
"owner_user_id": "28155",
"post_type": "question",
"score": 0,
"tags": [
"virtualbox",
"macos"
],
"title": "VirtualBoxがエラーで再インストールできません",
"view_count": 876
} | [
{
"body": "コメントにも書きましたが、VirtualBoxのdmgファイルを開いた右下にある、 \n`VirtualBox_Uninstall.tool`というファイルをダブルクリックして実行してみてください。\n\n想像ですが、アプリケーションフォルダー内に作られたVitrualBoxだけをゴミ箱に入れて削除して、 \nアンインストールしたと思ってしまい、アプリケーションフォルダー以外に作られた環境設定ファイルなどが消えていないため上書きできずにエラーになっていると思われます。\n\n`VirtualBox_Uninstall.tool`は良く出来ていて、既に手動で削除されてしまったファイルがあっても、そこでエラーで止まらずに削除が必要で、残っているファイルだけを削除してくれるように作られていますので、一部ファイルを削除してしまったた後でも、動きますので安心して試してみてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T10:48:26.960",
"id": "44188",
"last_activity_date": "2018-05-24T00:14:29.520",
"last_edit_date": "2018-05-24T00:14:29.520",
"last_editor_user_id": "14745",
"owner_user_id": "14745",
"parent_id": "44136",
"post_type": "answer",
"score": 4
}
] | 44136 | null | 44188 |
{
"accepted_answer_id": "44138",
"answer_count": 1,
"body": "閲覧ありがとうございます。\n\nC言語でサーバプログラミングをしています。 \n実装したいことはサーバーのプログラムでマルチスレッドのスレッドプールというものです。\n\n実装したい内容としては\n\n「子スレッドを5つつくり、この5つで \nクライアントからの接続に対応する。」\n\n「5つまでしか接続できない」\n\n「小スレッドは終了させず、接続が切れたら次の接続を待つ」\n\nの3点となります。 \nマルチスレッドではなく、forkで実装したところ \nうまくいったのですが、マルチスレッドではタイトルのように \nbindエラーが出て困っているのでお力を貸して頂きたいです。\n\nコード内容は以下の通りです。\n\n```\n\n #define PRCS_LIMIT 5 /* 小スレッド数制限 */\n #define BUFSIZE 50 /* バッファサイズ */\n \n void * execute(void *arg);\n int init_tcpserver(in_port_t myport, int backlog);\n \n int main(int argc, char *argv[]) {\n int *port_number;\n int temp;\n pthread_t tid;\n \n temp = atoi(argv[1]);\n port_number = &temp;\n \n /* 子スレッドを5つ生成する */\n int i;\n for (i = 1; i <= PRCS_LIMIT; i++) {\n if (pthread_create(&tid, NULL, execute, (void *) port_number) != 0) {\n exit_errmesg(\"pthread_create()\");\n }\n }\n \n //親スレッドは終わらせない。\n while(1){\n \n }\n return 0;\n /* never reached */\n }\n \n /* スレッドの本体 */\n void * execute(void *arg) {\n int sock_accepted;\n int sock_listen;\n char buf[BUFSIZE];\n int strsize;\n \n /* サーバの初期化 */\n sock_listen = init_tcpserver(*(int *) arg, 5);\n \n /* クライアントの接続を受け付ける */\n sock_accepted = accept(sock_listen, NULL, NULL);\n \n pthread_detach(pthread_self()); /* スレッドの分離(終了を待たない) */\n \n close(sock_listen);\n \n while (1) {\n /* 文字列をクライアントから受信する */\n send(sock_accepted, \">\", 2, 0);\n if ((strsize = recv(sock_accepted, buf, BUFSIZE, 0)) == -1) {\n exit_errmesg(\"recv()\");\n }\n \n if (strstr(buf, \"end\") != NULL) {\n close(sock_accepted);\n \n /* サーバに接続する */\n sock_listen = init_tcpserver(*(int *) arg, 5);\n /* クライアントの接続を受け付ける */\n sock_accepted = accept(sock_listen, NULL, NULL);\n \n }\n /* 文字列をクライアントに送信する */\n if (send(sock_accepted, buf, strsize, 0) == -1) {\n exit_errmesg(\"send()\");\n }\n }\n \n return (NULL);\n }\n \n int init_tcpserver(in_port_t myport, int backlog)\n {\n struct sockaddr_in my_adrs;\n int sock_listen;\n int yes = 1;\n \n /* サーバ(自分自身)の情報をsockaddr_in構造体に格納する */\n memset(&my_adrs, 0, sizeof(my_adrs));\n my_adrs.sin_family = AF_INET;\n my_adrs.sin_port = htons(myport);\n my_adrs.sin_addr.s_addr = htonl(INADDR_ANY);\n \n /* 待ち受け用ソケットをSTREAMモードで作成する */\n if((sock_listen = socket(PF_INET, SOCK_STREAM, 0)) == -1){\n exit_errmesg(\"socket()\");\n }\n \n //TIME_WAIT状態でもbindできるようにする。\n setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR, (const char *)&yes, sizeof(yes));\n \n /* 待ち受け用のソケットに自分自身のアドレス情報を結びつける */\n if(bind(sock_listen, (struct sockaddr *)&my_adrs, sizeof(my_adrs)) == -1 ){\n exit_errmesg(\"bind()\");\n }\n \n /* クライアントからの接続を受け付ける準備をする */\n if(listen(sock_listen, backlog) == -1){\n exit_errmesg(\"listen()\");\n }\n \n return(sock_listen);\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T13:24:42.553",
"favorite_count": 0,
"id": "44137",
"last_activity_date": "2018-05-21T14:08:59.710",
"last_edit_date": "2018-05-21T14:08:59.710",
"last_editor_user_id": "26577",
"owner_user_id": "26577",
"post_type": "question",
"score": 1,
"tags": [
"linux",
"c",
"tcp",
"socket",
"マルチスレッド"
],
"title": "Linux C言語 ソケット通信 子スレッドで待ち受けするとbindエラーが出る",
"view_count": 2575
} | [
{
"body": "エラーの通りで`bind()`で指定する`address :\nport`のペアはシステム内で一意の必要があります。`fork()`でうまくいったのはよくわかりません。\n\nまた[`listen()`](https://linuxjm.osdn.jp/html/LDP_man-pages/man2/listen.2.html)は\n\n> sockfd が参照するソケットを接続待ちソケット (passive socket) として印をつける。\n\nだけです。実際に待ち受けるには`accept()`を使います。つまり、`socket()`、`bind()`、`listen()`までの処理はスレッドを作成する前に完了させておく必要があります。その上で各スレッドで`accept()`を実行すればよいでしょう。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-21T13:35:19.557",
"id": "44138",
"last_activity_date": "2018-05-21T13:35:19.557",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "44137",
"post_type": "answer",
"score": 1
}
] | 44137 | 44138 | 44138 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "正規表現(Ruby)で\n\n```\n\n ^ISBN[-]?[¥d|-]+\n \n```\n\nの場合\n\n```\n\n ^ISBN-?[¥d|-]+\n \n```\n\nでも同じ結果になると思うのですが \nこの場合の`[]`って、`[]`内に指定された文字のどれかにマッチするの意味の`[]`でクラスとかの`[]`とはまた違いますよね",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T01:49:46.317",
"favorite_count": 0,
"id": "44144",
"last_activity_date": "2018-05-22T04:24:38.080",
"last_edit_date": "2018-05-22T02:24:33.477",
"last_editor_user_id": "19110",
"owner_user_id": "28605",
"post_type": "question",
"score": 2,
"tags": [
"ruby",
"正規表現"
],
"title": "正規表現[-]?の[]の意味",
"view_count": 153
} | [
{
"body": "はい、Ruby の正規表現 `[-]` は `-` 1文字にマッチする表現であり、正規表現 `-` と同等です。\n\nRuby 2.5 のドキュメント ([これ](https://docs.ruby-\nlang.org/ja/latest/doc/spec=2fregexp.html)や[これ](https://ruby-\ndoc.org/core-2.5.1/doc/regexp_rdoc.html)) に明示的に書かれているわけではありませんが、`[ ]` の中のハイフンは\n`[a-z]`\nのように範囲を表すときのみメタ文字として扱われます。先頭にあるときなど、範囲を表さないときはバックスラッシュによるエスケープ無しでも非メタ文字として扱われます。\n\nたとえば `[-abc]` という正規表現は、`-`, `a`, `b`, `c` にマッチします (実行例:\n[Rubular](http://rubular.com/r/x1Zt59ULZy) /\n[Wandbox](https://wandbox.org/permlink/jrOb0pT4Kk6UszvV))。\n\n参考ブログ: [正規表現: 文字クラス [ ]\n内でエスケープしなくてもよい記号](https://techracho.bpsinc.jp/hachi8833/2017_05_30/40673) \\--\nTech Racho",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T04:24:38.080",
"id": "44148",
"last_activity_date": "2018-05-22T04:24:38.080",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "44144",
"post_type": "answer",
"score": 5
}
] | 44144 | null | 44148 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "初めまして現在パッケージimportの書き方について悩んでおります。 \n`__init__.py`の書き方が悪いのか \n`cmd.py` から `errors.py` のエラークラスを呼んでくる事が出来ません\n\nネットにて調べてみたのですがどうしても分からず質問させて頂きます \nどなたかわかる方がいらっしゃればご教授下さい\n\nmain.py\n\n```\n\n from Utilities.output import Logs\n \n```\n\nUtilities.__init__.py\n\n```\n\n #-*-coding:utf-8-*-\n \n from Utilities import errors\n from Utilities import cmd\n from Utilities import output\n from Utilities import outs\n \n \n from Utilities.errors import BaseError\n from Utilities.errors import UnusableError\n from Utilities.errors import UnExpectedError\n \n from Utilities.errors import InputError\n from Utilities.errors import StatusError\n \n from Utilities.output import Logs\n \n from Utilities.cmd import Command\n \n from Utilities.outs import trading\n from Utilities.outs import initialize\n \n```\n\nerrors.py\n\n```\n\n #-*-coding:utf-8-*-\n \n from Utilities.output import Logs\n \n log = Logs()\n \n # 全ての基本となるエラー\n class BaseError(Exception):\n def __init__(self,message):\n log.Error(message)\n \n # 使用出来ないエラー\n class UnusableError(BaseError): pass\n \n # 予期せぬエラー\n class UnExpectedError(BaseError): pass\n \n # 入力形式エラー\n class InputError(BaseError): pass\n 以下省略\n \n```\n\nTrackBack\n\n```\n\n Traceback (most recent call last):\n File \"c:\\user\\dev\\main.py\", line 1, in <module>\n from Utilities.output import Logs\n File \"c:\\user\\dev\\Utilities\\__init__.py\", line 3, in <module>\n from Utilities import errors\n File \"c:\\user\\dev\\Utilities\\errors.py\", line 3, in <module>\n from Utilities.output import Logs\n File \"c:\\user\\dev\\Utilities\\output.py\", line 7, in <module>\n from Utilities.cmd import Command\n File \"c:\\user\\dev\\Utilities\\cmd.py\", line 3, in <module>\n from Utilities.errors import UnExpectedError,InputError\n ImportError: cannot import name 'UnExpectedError'\n \n```\n\n[](https://i.stack.imgur.com/8Pjsc.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T05:44:34.020",
"favorite_count": 0,
"id": "44149",
"last_activity_date": "2019-04-20T16:03:25.717",
"last_edit_date": "2018-05-22T06:35:23.637",
"last_editor_user_id": "19110",
"owner_user_id": "28613",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3"
],
"title": "パッケージimportができない: ImportError: cannot import name 'UnExpectedError'",
"view_count": 8190
} | [
{
"body": "Pythonのマニュアルには「パッケージ」のことは殆ど何も書いてないので難しく考えない方がいいようです。\n\n`__init__.py`は、このファイルがあるディレクトリーをパッケージとして扱うので作る必要はありますが、中身は空でも構いません。一般的には、パッケージを初期化するためのコードを書きます。今回は、とりあえずは空のファイルでいいでしょう。\n\n`cmd.py`から`errors.py`のエラークラスを呼ぶのは次のように普通に`improt`文を書けば呼べます。\n\n```\n\n from Utilities.errors import BaseError, UnusableError, UnExpectedError\n \n class Command:\n def test():\n # 処理\n BaseError('message')\n # 処理\n UnusableError('massage')\n # 処理\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T13:44:14.370",
"id": "44162",
"last_activity_date": "2018-05-22T13:44:14.370",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "44149",
"post_type": "answer",
"score": 0
},
{
"body": "とりあえず __init__.py は今回はあまり関係なくて、errors, output,\ncmdの3つのモジュールが循環参照して三つ巴状態になっているのが原因です。\n\n * errors: outputに依存(output.Logsを使用)\n * output: cmdに依存(エラーメッセージからcmd.Commandを使用)\n * cmd: errorsに依存(エラーメッセージからerrors.UnExpectedErrorを使用)\n\n[](https://i.stack.imgur.com/QHxdR.png)\n\ncmdがerrorsをimportしようとした時にはまだerrorsのimportが完了していない状態であるため、UnExpectedErrorが参照できません。\n\n解決するには、この三つ巴の循環参照をどこかで断ち切らなければなりません。 \n例えばoutput.pyでcmd.Commandを使うのをやめればimportはできるようになります。 \n(モジュールをどう設計すればよいかの話になります)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T02:18:00.420",
"id": "44169",
"last_activity_date": "2018-05-23T02:18:00.420",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28626",
"parent_id": "44149",
"post_type": "answer",
"score": 2
}
] | 44149 | null | 44169 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "こんにちは。 \n現在、cordova-googlemaps-pluginでアプリ開発の練習をしています。\n\nとりあえず画面上に地図を表示させることはできました。 \nその地図なのですが、画面いっぱいに表示させるにはどうすれば良いのでしょうか?\n\nwidthは「px」「%」「auto」どれで指定してもちゃんと表示されるのですが、 \nheightは「%」「auto」では反応せず、「px」指定でしか表示されません。\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta http-equiv=\"Content-Security-Policy\"/>\n <script type=\"text/javascript\" src=\"cordova.js\"></script>\n <script type=\"text/javascript\">\n document.addEventListener(\"deviceready\", function() {\n var div = document.getElementById(\"map_canvas\");\n var map = plugin.google.maps.Map.getMap(div);\n }, false);\n \n </script>\n </head>\n <body>\n <div style=\"width:auto; height:500px;\" id=\"map_canvas\"></div>\n </box>\n </body>\n </html>\n \n```\n\nどうぞ宜しくお願いいたします。\n\n何が問題なのでしょう?それとも「px」でしか表示できないのでしょうか?\n\nなにとぞご教授くださいm(__)m",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T07:16:02.780",
"favorite_count": 0,
"id": "44150",
"last_activity_date": "2018-05-22T07:36:50.373",
"last_edit_date": "2018-05-22T07:25:10.267",
"last_editor_user_id": "3060",
"owner_user_id": "13364",
"post_type": "question",
"score": 0,
"tags": [
"html",
"cordova"
],
"title": "cordova-googlemaps-pluginで地図を画面いっぱいに表示させるには?",
"view_count": 66
} | [
{
"body": "基本的に高さにパーセントを用いる際は親要素の高さが決まってないといけません。 \n`html`にパーセントを用いると表示領域に対する割合の高さを指定できるため、 \n`html`と`body`に高さ`100%`を指定してはどうでしょうか?\n\n```\n\n html, body {\n height:100%;\n }\n \n```\n\n```\n\n .wrapper {\r\n width:240px;\r\n height:240px;\r\n }\r\n .target {\r\n background-color:#a0a0F0;\r\n width:100%;\r\n height:100%;\r\n }\n```\n\n```\n\n <div class=\"wrapper\">\r\n <div class=\"target\">\r\n 親に指定有り\r\n </div>\r\n </div>\r\n <hr/>\r\n <div>\r\n <div class=\"target\">\r\n 親に指定無し\r\n </div>\r\n </div>\n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T07:36:50.373",
"id": "44153",
"last_activity_date": "2018-05-22T07:36:50.373",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "44150",
"post_type": "answer",
"score": 0
}
] | 44150 | null | 44153 |
{
"accepted_answer_id": "44286",
"answer_count": 2,
"body": "ItemsControl にコンボボックスを配置した後、コンボボックスの ItemsSource と SelectedItem\nをほぼ同時に変化させると正常に反映されないという問題にあたっています。\n\n再現コードは以下の通りです。 \n最初はコンボボックスの内容はhogeのみで、それが選択されており、5秒後にfugaに変化してそれが自動的に選択されることを意図しています。 \nしかし、実際には5秒後にコンボボックスの項目はfugaに変化しますが、無選択状態になります。 \nさらに5秒後にfugaが選択されることから、十分に時間をおけばVMからも選択できるということがわかります。\n\n原因、回避方法はありますか。 \n再現コードでは INotifyPropertyChanged を自力で実装していますが、実際は ReactiveProperty を使用しています。 \nそれぞれのコンボボックスの項目は別のものである必要があります。\n\n// xaml\n\n```\n\n <Window ... >\n <Window.DataContext>\n <local:MainWindowContext/>\n </Window.DataContext>\n <ItemsControl ItemsSource=\"{Binding Path=DdlList}\">\n <ItemsControl.ItemTemplate>\n <DataTemplate>\n <ComboBox ItemsSource=\"{Binding Path=Items}\" SelectedItem=\"{Binding Path=Selected}\"/>\n </DataTemplate>\n </ItemsControl.ItemTemplate>\n </ItemsControl>\n </Window\n \n```\n\n// データコンテキスト\n\n```\n\n public class MainWindowContext\n {\n public List<DdlCtx> DdlList { get; private set; }\n \n public MainWindowContext()\n {\n DdlList = new List<DdlCtx>()\n {\n new DdlCtx()\n };\n \n _ = Task.Delay(TimeSpan.FromSeconds(5)).ContinueWith(t =>\n {\n DdlList.First().Update();\n });\n \n _ = Task.Delay(TimeSpan.FromSeconds(10)).ContinueWith(t =>\n {\n DdlList.First().Select();\n });\n }\n }\n \n public class DdlCtx : INotifyPropertyChanged\n {\n public List<string> Items { get; private set; }\n public string Selected { get; set; }\n \n public DdlCtx()\n {\n Items = new List<string>() { \"hoge\" };\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"Items\"));\n \n Selected = Items.First();\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"Selected\"));\n \n }\n \n public void Update()\n {\n Items = new List<string>() { \"fuga\" };\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"Items\"));\n \n Selected = Items.First();\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"Selected\"));\n }\n \n public void Select()\n {\n Selected = Items.First();\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"Selected\"));\n \n }\n \n public event PropertyChangedEventHandler PropertyChanged;\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T07:25:23.423",
"favorite_count": 0,
"id": "44151",
"last_activity_date": "2018-05-27T04:34:58.743",
"last_edit_date": "2018-05-27T04:34:58.743",
"last_editor_user_id": "20885",
"owner_user_id": "20885",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"wpf",
"reactivex"
],
"title": "ItemsControl のアイテムにコンボボックスを配置した際、VMからの変更通知がうまく働かない",
"view_count": 1020
} | [
{
"body": "Update()メソッドがTask.Delay()からUIスレッドと異なるスレッドで呼び出されることが原因ではないでしょうか? \n端的に書くと、下のようにDispatcherを噛ましてやれば正常に更新されます。 \nタイマーの入れ方やスレッドの同期に関しては他にもいろいろなアプローチがあると思いますが、分かりやすい例として。\n\n```\n\n public void Update()\n {\n Application.Current.Dispatcher.Invoke(new Action(() =>\n {\n Items = new List<string>() { \"fuga\" };\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"Items\"));\n \n Selected = Items.First();\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"Selected\"));\n }));\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T14:32:14.597",
"id": "44164",
"last_activity_date": "2018-05-22T14:32:14.597",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2947",
"parent_id": "44151",
"post_type": "answer",
"score": 1
},
{
"body": "解決しました。 \n実際のコードでは\n\n```\n\n // 初期化\n ReactiveProperty<List<string>> Source = ...;\n ReadOnlyReactiveProperty<List<string>> Items;\n Items = Source.ToReadOnlyReactiveProperty();\n \n // Update (UIスレッド)\n await 時間のかかる処理\n Source.Value = ...\n Selected.Value = ...\n \n```\n\nのようにしていました。 \nここで、何らかの理由でプロパティ変更通知がUpdateを抜けた後に発生するために、\n\nItemsの値変更 \n→Selectedの値変更 \n→Itemsの通知 \n→SelectedがItemsの中から見つからなくなったのでUI側からnullをセット \n→Itemsの通知\n\nという順序でnullがセットされたままになった、と考えられます。\n\nただItemsをReactivePropertyにして直接変更すると即座に通知してくれる様で、その辺の挙動がわかっていない...\n\n解決策としてはItemsとSelectedを初期化する際にImmediateSchedulerを指定し、値変更が必ずUIスレッドから行われるようにしました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T04:34:34.053",
"id": "44286",
"last_activity_date": "2018-05-27T04:34:34.053",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20885",
"parent_id": "44151",
"post_type": "answer",
"score": 0
}
] | 44151 | 44286 | 44164 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "ミラーパッディングを使いたいのですが、対象となるデータが3次元`[None,256,256]`の時, \n`tf.pad`におけるpaddingsはどのように設計してやればいいですか?ご教授ください。\n\n```\n\n X = tf.placeholder(tf.float32, [None, 256, 256])\n paddings = tf.constant([[2, 2,], [2, 2]])\n X_ = tf.pad(X, paddings, \"REFLECT\")\n \n```\n\n```\n\n ValueError: Shape must be rank 2 but is rank 3 for 'MirrorPad_5' (op: 'MirrorPad') with input shapes: [?,256,256], [2,2].\n \n```\n\n追記:今、Xを`[None,256,256]`から`[None,260,260]`へと変形したいです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T07:28:58.637",
"favorite_count": 0,
"id": "44152",
"last_activity_date": "2018-05-22T07:56:14.283",
"last_edit_date": "2018-05-22T07:56:14.283",
"last_editor_user_id": "19110",
"owner_user_id": "26075",
"post_type": "question",
"score": 1,
"tags": [
"tensorflow"
],
"title": "3次元データに対する tf.pad",
"view_count": 534
} | [] | 44152 | null | null |
{
"accepted_answer_id": "44155",
"answer_count": 1,
"body": "1. 「////////」となっている部分のコードの意味を知りたいです。\n 2. [自分自身だったら...]の場合はどのような場合か知りたりです。\n 3. この処理内容はどの場合に実行されるのか検証しましたがprintfで出力されないのでそのあたりを教えていただきたいです。\n\n```\n\n #ifndef ___IntArray\n #define ___IntArray\n #include <iostream>\n using namespace std;\n \n class IntArray {\n private:\n int nelem;\n int *vec;\n \n public:\n IntArray() {};\n \n explicit IntArray(int size) :nelem(size)\n {\n vec = new int[nelem];\n };\n \n int size()const {\n return nelem;\n }\n \n int& operator[](int i) {\n return vec[ i ];\n }\n \n ~IntArray() {\n delete[] vec;\n }\n \n /*コピーコンストラクタ*/\n IntArray(const IntArray& x)\n {\n if (&x == this) // もし自分自身だったら...\n {\n cout << \"同じ\";\n ////////////\n nelem = 0;\n vec = NULL;\n /////////////\n }\n else {\n nelem = x.nelem;\n vec = new int[nelem];\n \n int i = 0;\n for (i = 0; i < nelem; i++) {\n vec[i] = x.vec[i];\n }\n }\n }\n \n IntArray& operator = (const IntArray& x) {\n \n if (&x != this)\n {\n if (nelem != x.nelem)\n {\n delete[] vec;\n nelem = x.nelem;\n vec = new int[nelem];\n }\n \n int i = 0;\n for (i = 0; i < nelem; i++) {\n vec[i] = x.vec[i];\n }\n }\n else { cout << \"else\"; }\n \n return *this;\n }\n };\n \n #endif;\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T10:27:07.937",
"favorite_count": 0,
"id": "44154",
"last_activity_date": "2018-05-22T11:40:49.173",
"last_edit_date": "2018-05-22T11:40:49.173",
"last_editor_user_id": "3060",
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "記憶域の動的確保クラス",
"view_count": 119
} | [
{
"body": "> 1. 「////////」となっている部分のコードの意味を知りたいです。\n>\n\n普通にメンバー変数を初期化しているだけで特殊なことはありません。\n\n> 2. [自分自身だったら...]の場合はどのような場合か知りたりです。\n>\n\n通常はオブジェクトを作成する際にコンストラクターを実行します。 \nコピーコンストラクターではコピー元のオブジェクトを引数に渡します。 \nここまでは一般的です。\n\nそのうえで質問の状況、コピーコンストラクターの引数に自分自身が渡されるというのはかなり特殊な状況です。ただし不可能ではありません。\n\n```\n\n auto p = (IntArray*)malloc(sizeof(IntArray));\n new (p) IntArray(*p);\n \n```\n\n2行目は`placement\nnew`といって、指定したアドレスに対してコンストラクターを実行させることができます。`(p)`がコンストラクターを実行させるアドレスを指します。`(*p)`がコンストラクター引数です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T10:58:26.723",
"id": "44155",
"last_activity_date": "2018-05-22T10:58:26.723",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "44154",
"post_type": "answer",
"score": 3
}
] | 44154 | 44155 | 44155 |
{
"accepted_answer_id": "52951",
"answer_count": 1,
"body": "python3.5を使っています。pyqt5を使って作ったGUIをpyinstallerでexeファイルに直してみました。できたexeファイルを起動しようとすると、\n\n```\n\n This application failed to start because it could not find or load the Qt platform plugin \"windows\" in \"\". Reinstalling the applicaton may fix this problem.\n \n```\n\nと出力され、起動しません。どうすれば良いのでしょうか。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T12:25:34.240",
"favorite_count": 0,
"id": "44157",
"last_activity_date": "2020-07-11T16:57:13.867",
"last_edit_date": "2020-07-11T16:57:13.867",
"last_editor_user_id": "3060",
"owner_user_id": "26529",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pyqt",
"pyinstaller"
],
"title": "pyinstallerで作成したexeファイルが起動しない",
"view_count": 4136
} | [
{
"body": "必要なpluginが実行ファイルと同じフォルダ内に入っていないとダメなようです。pluginはpyinstallerでexe化する際にファイルを一つにまとめないように(--onefileをかかない)するとできるPyQt5というフォルダの中に入っていました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-22T17:10:55.327",
"id": "52951",
"last_activity_date": "2019-02-22T17:10:55.327",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26529",
"parent_id": "44157",
"post_type": "answer",
"score": 1
}
] | 44157 | 52951 | 52951 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "**やろうとしていること** \nVirtualBoxでUbnutuの64bitを動かす。\n\n**発生している問題** \nVTxとVTdを有効、hyper-vを無効にしているのに64bitの選択肢が出てきません。 \n32bitのままで、起動したらエラーが出ます。\n\n[](https://i.stack.imgur.com/THx4x.png)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T12:30:43.123",
"favorite_count": 0,
"id": "44158",
"last_activity_date": "2023-03-05T21:02:15.207",
"last_edit_date": "2018-05-23T00:46:22.807",
"last_editor_user_id": "3060",
"owner_user_id": "27981",
"post_type": "question",
"score": 0,
"tags": [
"virtualbox"
],
"title": "VirtualBoxのゲストOSでUbuntu 64bitが選択できない",
"view_count": 3598
} | [
{
"body": "ホストOS側のBIOS設定で「仮想化機能」をあらかじめ有効にしておく必要があるそうです。 \nお使いのPC/マザーボードのメーカーによって詳細は異なると思うので、ご自身の環境で確認してみてください。\n\n参考: \n[【仮想OS】virtualboxで64bitOSが選択できない場合](http://acball.hatenablog.com/entry/2013/11/05/205712) \n[VirtualBox:仮想マシンの作成で64bit\nOSを選択可能にする方法](http://did2memo.net/2015/07/10/virtualbox-64-bit-os/)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T16:51:41.040",
"id": "44166",
"last_activity_date": "2018-05-23T17:31:49.317",
"last_edit_date": "2018-05-23T17:31:49.317",
"last_editor_user_id": "3060",
"owner_user_id": "3060",
"parent_id": "44158",
"post_type": "answer",
"score": 0
},
{
"body": "WindowsでHyper-Vが有効になっているとvtxが使用できないようです。 \n[コントロールパネル]-[プログラム]の「Windows の機能の有効化または無効化」で、Hyper-Vにチェックがされていたりしませんか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-10-11T00:22:39.643",
"id": "49163",
"last_activity_date": "2018-10-11T00:22:39.643",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30468",
"parent_id": "44158",
"post_type": "answer",
"score": 0
}
] | 44158 | null | 44166 |
{
"accepted_answer_id": "44161",
"answer_count": 1,
"body": "### 前提・実現したいこと\n\nBMI値の表示\n\n### ここに質問の内容を詳しく書いてください。\n\n入門書に書かれているコードを書きました。 \nターミナル上で実行したところエラーが出ました。\n\n### 発生している問題・エラーメッセージ\n\n```\n\n File \"bmi.py\", line 1, in <module>\n while true:\n NameError: name 'true' is not defined\n \n```\n\n### ここに言語名を入力\n\npython 3.6\n\n### ソースコード\n\n```\n\n while true:\n height=input(\"身長(m)?:\")\n if len(height)==0:\n break\n height=float(height)\n weight=float(input(\"体重(kg)?:\"))\n bmi=weight/pow(height,2)\n print(\"BMI値は{:.1f}です。\".format(bmi))\n if bmi<18.5:\n print(\"Mr.ガリガリ君\")\n elif 18.5<=bmi<25.0:\n print(\"中肉中背THEふつう君\")\n elif 25.0<=bmi<30.0:\n print(\"デブ\")\n else:\n print(\"末期のデブ\")\n \n```\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T13:18:04.783",
"favorite_count": 0,
"id": "44160",
"last_activity_date": "2018-05-23T08:58:57.637",
"last_edit_date": "2018-05-23T08:58:57.637",
"last_editor_user_id": "3060",
"owner_user_id": "28620",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "pythonプログラム実行時に「NameError: name 'true' is not defined」とエラーになってしまう",
"view_count": 7395
} | [
{
"body": "`True`ですね。`true`じゃなくて。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T13:21:43.847",
"id": "44161",
"last_activity_date": "2018-05-22T13:21:43.847",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "44160",
"post_type": "answer",
"score": 3
}
] | 44160 | 44161 | 44161 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "私はsublimetextのプラグインを開発しています。 \nダブルクリックで日本語を単語レベルで分割可能にするプラグインです。 \n<https://github.com/ASHIJANKEN/JapaneseWordSeparator>\n\n現在このプラグインはPackage Controlに登録申請中で、管理者と色々やり取りをしています。 \n<https://github.com/wbond/package_control_channel/pull/6992#issuecomment-383399294> \nその中で、「この機能は日本語の文章の時のみ有効になるように、.sublime-\nkeymapや.sublime_mousemapの中で、以下のようにcontextを使ってキーバインディングにマスクをかけたほうがいい」と言われました。\n\n```\n\n {\n \"keys\": [\"ctrl+left\"],\n \"command\": \"key_select_jp\",\n \"args\": {\"key\": \"left\"},\n \"context\": [\n { \"key\": \"preceding_text\", \"operator\": \"regex_contains\", \"operand\": \"\\\\p{Jpan}$\" }\n ]\n }\n \n```\n\nこれを元に以下のようなcontextを作ってみたのですが、どうもうまく動きません。operandを色々いじっているのですが、どんな時でも(英語の文章でも)このプラグインが有効になってしまいます。\n\n```\n\n //パターン1\n \"context\": [\n { \"key\": \"preceding_text\", \"operator\": \"regex_contains\", \"operand\": \"[\\\\p{Katakana}\\\\p{Hiragana}\\\\p{Han}。、,.!? ・「」:”()ー゚゙]$\" }\n ]\n \n //パターン2\n \"context\": [\n { \"key\": \"preceding_text\", \"operator\": \"regex_contains\", \"operand\": \"[\\\\p{Katakana}\\\\p{Hiragana}\\\\p{Han}。、,.!? ・「」:”()ー゚゙]\" }\n ]\n \n //パターン3\n \"context\": [\n { \"key\": \"preceding_text\", \"operator\": \"regex_contains\", \"operand\": \"[あ-んア-ン一-龠ヴ。、,.!? ・「」:”()ー゚゙]\" }\n ]\n \n //など。regex_matchも試したが効果なし。\n \n```\n\n正規表現のやり方が悪いのだとは思うのですが、どう指定してやったら解決するのかわかりません。 \nどなたか何かヒントとなりそうな情報をお持ちの方はいらっしゃいませんか? \nよろしくお願いいたします。\n\nちなみにcontextについては、以下のサイトが分かりやすいかと思います。 \n<https://qiita.com/shibainurou/items/dc18f2dfc91e36adb208#%E3%82%B3%E3%83%B3%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%8C%E3%81%82%E3%82%8B%E5%A0%B4%E5%90%88>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-22T17:40:48.627",
"favorite_count": 0,
"id": "44167",
"last_activity_date": "2018-05-23T06:38:06.353",
"last_edit_date": "2018-05-22T17:51:47.367",
"last_editor_user_id": "25734",
"owner_user_id": "25734",
"post_type": "question",
"score": 0,
"tags": [
"正規表現",
"sublimetext"
],
"title": "sublimetextで、contextを用いて、日本語の時のみ有効になるキーバインディングを作成したい",
"view_count": 85
} | [
{
"body": "私も Sublime Text のパッケージをいくつか作って Package Control に登録しています。\n\nお作りになったパッケージを Sublime Text の `Packages` ディレクトリに入れて、パターン 1-3 で試してみたところ、パターン 1 2\nはうまく行きませんが、パターン 3 だと問題なく動作するようです。\n\nここで「問題なく動作する」というのは具体的には次のことを指しています。\n\n * カーソルがある行の、カーソルよりも前の部分に日本語があるときは `key_select_jp` コマンドが反応する\n * カーソルがある行の、カーソルよりも前の部分に日本語が無いときは `set_motion` コマンドが反応する(= Sublime Text のデフォルトの動き)\n\nちなみに、私が動作確認をしたときの `.sublime-keymap` の一部は次のとおりです。\n\n```\n\n {\n \"keys\": [\"super+left\"],\n \"command\": \"key_select_jp\",\n \"args\": {\"key\": \"left\"},\n \"context\": [\n {\n \"key\": \"preceding_text\",\n \"operator\": \"regex_contains\",\n \"operand\": \"[あ-んア-ン一-龠ヴ。、,.!? ・「」:”()ー゚゙]\"\n }\n ]\n },\n \n```\n\n私の環境は macOS です。\n\n以下、いくつかコメントです。\n\n * 確証はありませんが、パターン 1 2 の `\\\\p{Katakana}` といった表現はここでは使えないのではないかと思います。一度確認してみてください。\n * ご存知のとおり `context` のドキュメントはあまり無いようなので、他のパッケージを参考にされるのがよいかと思います。すでにパッケージをたくさんインストールされていれば、 `Packages` ディレクトリ以下で検索すると参考例を見ることができます。\n\nご参考になれば幸いです :)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T06:38:06.353",
"id": "44180",
"last_activity_date": "2018-05-23T06:38:06.353",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28632",
"parent_id": "44167",
"post_type": "answer",
"score": 1
}
] | 44167 | null | 44180 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "div要素をクリックしたらそのデータを送る。\n\n```\n\n <form action=“hogeAction” name=“form1”>\n <div onclick=“hoge()”>\n <input type =“hidden” name=“data” value=“1”>\n <h2>ありゃりゃ</h2>\n </form>\n \n <script>\n function hoge(){\n document.form1.submit();\n }\n </script>\n \n```\n\n疑問なのはこれで送れているどうか \nformで送れる値みたいなものはinputでしか指定できない \nほかに送るのに何かいい方法があればお願いします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T02:30:59.467",
"favorite_count": 0,
"id": "44170",
"last_activity_date": "2018-05-23T02:37:32.910",
"last_edit_date": "2018-05-23T02:37:32.910",
"last_editor_user_id": null,
"owner_user_id": "28615",
"post_type": "question",
"score": 0,
"tags": [
"html",
"jsp"
],
"title": "divで囲んだデータを送信する",
"view_count": 356
} | [] | 44170 | null | null |
{
"accepted_answer_id": "44556",
"answer_count": 1,
"body": "1週間程度連続で稼動させる前提のiOSアプリを開発しているのですが、 \n3日程度で落ちてしまいます。\n\n原因はメモリリークということは分かっており、 \n取り急ぎメモリ確保(ヒープ領域サイズ拡大)を行いたいのですが、 \nXamarin.iOSでも可能なのでしょうか?\n\nヒープサイズ(メモリ領域)は \n機種毎に異なる?(例えば新型iPadのほうが良い?) \nそもそも固定値?\n\nXamarin.Androidではプロジェクトの設定からヒープ領域のサイズを変更できるそうですが、 \niOSでも同じようなことができると非常に助かります。\n\n無知ですみませんが、 \n何卒、よろしくお願い致します。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T02:58:49.123",
"favorite_count": 0,
"id": "44171",
"last_activity_date": "2018-06-06T05:25:37.740",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28023",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"c#",
"iphone",
"xamarin"
],
"title": "Xamarin.iOSのメモリ確保について",
"view_count": 259
} | [
{
"body": "<https://stackoverflow.com/a/25369670/7258193>\n\niOS では基本的に OS がメモリを管理しているため、ヒープサイズの拡張などは不可能なようです。 \nただし、Xamarin の場合 C# を利用しているかと思いますので、`GC.Collect();`\nなどを利用することで未使用のメモリを開放することが可能かと思います。\n\nその他、即時必要のないメモリをストレージに移動させるなど、根本的な対処を行ったほうがよいかと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-06-06T05:25:37.740",
"id": "44556",
"last_activity_date": "2018-06-06T05:25:37.740",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28786",
"parent_id": "44171",
"post_type": "answer",
"score": 0
}
] | 44171 | 44556 | 44556 |
{
"accepted_answer_id": "44738",
"answer_count": 2,
"body": "ローカル内でのクローンは問題なくできるのですが、Gitプロトコルで接続しcloneしようとするとなぜか変な挙動を起こします。\n\n環境は・・・ \n≪リモートリポジトリの環境≫ \nOS:Windows Server (2007) \nGit:2.16.2.windows.1 \n≪クライアントの環境≫ \nGit:2.17.0.windows.1\n\nケース1:リポジトリを作成した状態(容量:56K) ← NG\n\n> $ git clone git://XXXXXX/sample2.git sample2222 \n> Cloning into 'sample2222'... \n> fatal: read error: Invalid argument \n> fatal: early EOF \n> fatal: index-pack failed\n\nケース2:5回pushした状態(容量:71K) ← OK(5回以上であればいける)\n\n> $ git clone git://XXXXXX/sample5.git sample555 \n> Cloning into 'sample555'... \n> remote: Counting objects: 14, done. \n> remote: Compressing objects: 100% (7/7), done. \n> remote: Total 14 (delta 0), reused 0 (delta 0) \n> Receiving objects: 100% (14/14), done.\n\nケース3:かなり操作をした状態(容量:17M) ← NG\n\n> $ git clone git://XXXXXX/copy.git copycopy \n> Cloning into 'copycopy'... \n> remote: Counting objects: 748, done. \n> remote: Compressing objects: 100% (412/412), done. \n> Receiving objects: 75% (561/748), 13.36 Mremote: Total 748 (delta 226),\n> reused 684 (delta 211) \n> fatal: read error: Invalid argument13.36 MiB | 5.34 MiB/s \n> Receiving objects: 100% (748/748), 15.79 MiB | 5.38 MiB/s, done. \n> fatal: early EOF \n> fatal: index-pack failed\n\nケース1に関しては、調べてみても原因や対策がわかっていません。 \nケース3に関しては、cloneする際に [--depth 1]をつければできましたが全ての履歴が欲しいときにどうすればいいかわからないです。\n\n※Git初心者 かつ CVSしか利用したことないので、知識が乏しいです・・・。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T03:22:33.787",
"favorite_count": 0,
"id": "44172",
"last_activity_date": "2018-06-13T04:11:09.647",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27196",
"post_type": "question",
"score": 2,
"tags": [
"git"
],
"title": "Git cloneの挙動がおかしい",
"view_count": 3628
} | [
{
"body": "gitは、Linuxを作った人が作成したものであるため、サーバー側のリモートリポジトリはLinuxの方が良いと思います。githubはプライベートだと有料ですので候補から外れていると推測します。可能であれば仮想環境としてLinuxを立ち上げ「gitlab」などで管理してみてはいかがでしょうか?",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T08:50:24.533",
"id": "44256",
"last_activity_date": "2018-05-28T02:22:49.203",
"last_edit_date": "2018-05-28T02:22:49.203",
"last_editor_user_id": "28656",
"owner_user_id": "28656",
"parent_id": "44172",
"post_type": "answer",
"score": -2
},
{
"body": "根本原因の解決とはなりませんでしたが、自分なりに結論付けました。\n\nGitLabで上記ケースの再現をしてみたところ・・・\n\nCASE1 ⇒ 問題なくクローンできる。 \n(GitLabではGitプロトコルではなくHTTP経由でのアクセスだからそれも影響している可能性がある?)\n\nCASE3 ⇒ 問題なくクローンできる。 \n(これに関しては設定な気がしています・・・。)\n\nGitでバージョン管理する場合、GitLabを利用するのが良いと判断しました。 \n(Gitサービスを利用することの方がユーザー管理やらメリットが増えますし・・・)\n\nWindowsサーバーにGitをインストールしても動作面の不安定さ、その原因を調査するための知識の無さで諦めました・・・。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-06-13T04:05:40.617",
"id": "44738",
"last_activity_date": "2018-06-13T04:11:09.647",
"last_edit_date": "2018-06-13T04:11:09.647",
"last_editor_user_id": "27196",
"owner_user_id": "27196",
"parent_id": "44172",
"post_type": "answer",
"score": 0
}
] | 44172 | 44738 | 44738 |
{
"accepted_answer_id": "44184",
"answer_count": 1,
"body": "このTwitterページの上部ログインフォームにて、アカウント名フィールドとパスワードフィールドの上辺の位置が揃っています。\n\nこれを再現しようとCSSを考えているのですが、参考にデベロッパーツールで確認してもどこにその指定があるのか分かりません。\n\n分かる方いらっしゃいますか?調べ方もご教示いただけたら助かります。 \n",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T04:16:28.843",
"favorite_count": 0,
"id": "44173",
"last_activity_date": "2020-01-25T02:42:58.013",
"last_edit_date": "2020-01-25T02:42:58.013",
"last_editor_user_id": "32986",
"owner_user_id": "28621",
"post_type": "question",
"score": 1,
"tags": [
"css",
"twitter-bootstrap"
],
"title": "HTMLテキストフィールドの高さを合わせる方法は?",
"view_count": 202
} | [
{
"body": "これはCSSのFlexboxというスタイルが使用されているようです。\n\n各inputフィールドは`<div>`でbox化されており、その親要素の`<form>`を見ると、`display:flex`というスタイルが適用されています。\n\n[](https://i.stack.imgur.com/Wnf8i.jpg)\n\nこれにより、`<form>`の子要素を横並びのレイアウトにすることができ、上辺の位置を合わせたようなスタイルになります。\n\n以下サンプルです。\n\n```\n\n input {\r\n margin: 5px 10px;\r\n }\r\n \r\n .LoginForm {\r\n display: flex;\r\n }\n```\n\n```\n\n <h4>Flexbox未指定</h4>\r\n <div>\r\n <form>\r\n <div>\r\n <input type=\"text\" placeholder=\"username\"/>\r\n </div>\r\n <div>\r\n <input type=\"password\" placeholder=\"password\"/>\r\n </div>\r\n </form>\r\n <div>\r\n \r\n <h4>Flexbox指定</h4>\r\n <div>\r\n <form class=\"LoginForm\">\r\n <div>\r\n <input type=\"text\" placeholder=\"username\"/>\r\n </div>\r\n <div>\r\n <input type=\"password\" placeholder=\"password\"/>\r\n </div>\r\n </form>\r\n <div>\n```\n\n参考 \n[要素を横並びにするならflex boxしかない! -\nQiita](https://qiita.com/HiromuMasuda0228/items/baf8015076d7d90b8fea)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T07:17:26.773",
"id": "44184",
"last_activity_date": "2018-05-23T07:17:26.773",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27930",
"parent_id": "44173",
"post_type": "answer",
"score": 1
}
] | 44173 | 44184 | 44184 |
{
"accepted_answer_id": "44207",
"answer_count": 1,
"body": "UIPanGestureRecognizerを使って画像を動かし、対象の画像の上に移動したら位置を固定して触れなくするという画面を作っています。\n\n<実装したいこと> \n(1)2つのImageView(image1, image2)を動かすことができる。 \n(2)移動先のImageView(target1, target2)が2つある。 \n(3)動かせる画像が移動先のどちらかのImageViewの上に重なったら、そこで場所を固定し、移動できなくする。 \n重なった移動先には2つ目の画像をのせられなくする。(target1flg, target2flgで判定) \n(4)2つ目の画像を動かして、空いている方の画像に重ねることができる。 \n重ねたあとは移動できなくする。\n\n<現在のコードの問題> \n(3)までは動かせます。 \n(4)で2つ目の画像を動かし始めると、1つ目の画像が元の場所に表示されてしまいます。\n\n初歩的なミスではないかと思いますが、解決法を思い浮かべられず、お助けいただきたいと思います。\n\n```\n\n import UIKit\n \n class sample: UIViewController {\n \n @IBOutlet weak var image1: UIImageView!\n @IBOutlet weak var image2: UIImageView!\n @IBOutlet weak var target1: UIImageView!\n @IBOutlet weak var target2: UIImageView!\n \n var target1flg: Bool!\n var target2flg: Bool!\n \n var imageViewOrigin: CGPoint!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n target1flg = true\n target2flg = true\n \n addPanGesture(v: image1)\n addPanGesture(v: image2)\n \n }\n \n func addPanGesture(v: UIView) {\n \n let pan = UIPanGestureRecognizer(target: self, action: #selector(sample.handlePan(sender:)))\n v.addGestureRecognizer(pan)\n }\n \n @objc func handlePan(sender: UIPanGestureRecognizer) {\n \n let pannedImageView = sender.view!\n \n switch sender.state {\n \n case .began:\n \n imageViewOrigin = pannedImageView.frame.origin\n view.bringSubview(toFront: pannedImageView)\n \n case .changed:\n \n moveViewWithPan(v: pannedImageView, sender: sender)\n \n case .ended:\n if pannedImageView.frame.intersects(target1.frame) && target1flg == true {\n snapView(v: pannedImageView, targetBox: target1)\n target1flg = false\n \n }\n else if pannedImageView.frame.intersects(target2.frame) && target2flg == true {\n snapView(v: pannedImageView, targetBox: target2)\n target2flg = false\n \n }\n else {\n returnViewToOrigin(v: pannedImageView, loc: imageViewOrigin)\n }\n \n default:\n break\n }\n }\n \n \n func moveViewWithPan(v: UIView, sender: UIPanGestureRecognizer) {\n \n let translation = sender.translation(in: view)\n \n v.center = CGPoint(x: v.center.x + translation.x, y: v.center.y + translation.y)\n sender.setTranslation(CGPoint.zero, in: view)\n }\n \n \n func returnViewToOrigin(v: UIView, loc: CGPoint) {\n \n UIView.animate(withDuration: 0.3, animations: {\n v.frame.origin = loc\n })\n }\n \n func snapView(v:UIView, targetBox:UIImageView){\n UIView.animate(withDuration: 0.3) {\n \n v.center = CGPoint(x:targetBox.center.x, y: targetBox.center.y)\n v.isUserInteractionEnabled = false\n } \n }\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T04:39:31.943",
"favorite_count": 0,
"id": "44175",
"last_activity_date": "2018-05-24T04:05:34.503",
"last_edit_date": "2018-05-23T05:26:53.677",
"last_editor_user_id": "19110",
"owner_user_id": "28628",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"xcode"
],
"title": "UIPanGestureRecognizer 画像を移動後に固定したい",
"view_count": 85
} | [
{
"body": "解決しました。\n\nimage1,\nimage2のAutoLayoutをやめて(constraints削除)、画像をViewの中に入れ、このViewにconstraintsでレイアウトを固定。\n\n画像はsize inspector>ViewのFrame Rectangleを設定して追加したViewの中のpositionを固定。\n\nこれで画像が元の位置に戻らなくなりました。 \nヒントをくださったOOPerさんありがとうございました。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T04:05:34.503",
"id": "44207",
"last_activity_date": "2018-05-24T04:05:34.503",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28628",
"parent_id": "44175",
"post_type": "answer",
"score": 1
}
] | 44175 | 44207 | 44207 |
{
"accepted_answer_id": "44177",
"answer_count": 1,
"body": "iOSアプリのアプリアイコンと同じ画像を、Apple Watch のpush通知に表示される画像にも設定するにはどうすれば良いでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T04:50:14.360",
"favorite_count": 0,
"id": "44176",
"last_activity_date": "2018-05-23T05:21:54.390",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28629",
"post_type": "question",
"score": 1,
"tags": [
"swift",
"ios",
"xcode",
"watchkit"
],
"title": "apple watch にアプリアイコンを表示する方法",
"view_count": 734
} | [
{
"body": "Xcode を起動して AppIcon asset から設定できます。\n\n[Notification icon missing on Apple Watch in iOS\n11](https://stackoverflow.com/questions/46383403/notification-icon-missing-on-\napple-watch-in-ios-11)\n\nが参考になるかと思います。\n\n[](https://i.stack.imgur.com/7cbSS.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T05:21:54.390",
"id": "44177",
"last_activity_date": "2018-05-23T05:21:54.390",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "369",
"parent_id": "44176",
"post_type": "answer",
"score": 2
}
] | 44176 | 44177 | 44177 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "pythonにてpptxをインストールして以下のサンプルを実行したところ\n\n```\n\n from pptx import Presentation\n \n prs = Presentation()\n title_slide_layout = prs.slide_layouts[0]\n slide = prs.slides.add_slide(title_slide_layout)\n title = slide.shapes.title\n subtitle = slide.placeholders[1]\n \n title.text = \"Hello, World!\"\n subtitle.text = \"python-pptx was here!\"\n \n prs.save('test.pptx')\n \n```\n\n以下のエラーが発生しました。\n\n```\n\n Traceback (most recent call last):\n File \"C:\\Users\\XXXX\\Desktop\\python\\pptx.py\", line 1, in <module>\n from pptx import Presentation\n File \"C:\\Users\\XXXX\\Desktop\\python\\pptx.py\", line 1, in <module>\n from pptx import Presentation\n ImportError: cannot import name 'Presentation'\n \n```\n\n(base) C:\\Users\\XXXX\\Downloads>`pip show python-pptx` \nにて確認しましたがインストールはされているようです。\n\n```\n\n Name: python-pptx\n Version: 0.6.9\n Summary: Generate and manipulate Open XML PowerPoint (.pptx) files\n Home-page: http://github.com/scanny/python-pptx\n Author: Steve Canny\n Author-email: [email protected]\n License: The MIT License (MIT)\n Location: c:\\users\\XXXX\\appdata\\local\\continuum\\anaconda3\\lib\\site-packages\n Requires: Pillow, lxml, XlsxWriter\n \n```\n\nフォルダも以下にありました。\n\n```\n\n C:\\Users\\XXXX\\AppData\\Local\\Continuum\\anaconda3\\Lib\\site-packages\\pptx\n \n```\n\nバージョンは \nPython 3.6 version \npython-pptx 0.6.9\n\nよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T06:21:47.350",
"favorite_count": 0,
"id": "44179",
"last_activity_date": "2018-12-17T02:37:22.047",
"last_edit_date": "2018-12-17T02:37:22.047",
"last_editor_user_id": "3060",
"owner_user_id": "28631",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3"
],
"title": "python にて「ImportError: cannot import name 'Presentation'」が発生する。",
"view_count": 6397
} | [
{
"body": "> Traceback (most recent call last): \n> File \"C:\\Users\\XXXX\\Desktop\\python\\pptx.py\", line 1, in \n> from pptx import Presentation \n> File \"C:\\Users\\XXXX\\Desktop\\python\\pptx.py\", line 1, in \n> from pptx import Presentation \n> ImportError: cannot import name 'Presentation'\n\nというエラーメッセージですから、\"C:\\Users\\XXXX\\Desktop\\python\\pptx.py\"に'Presentation'が含まれていないのでしょう。\n\n\"C:\\Users\\XXXX\\Desktop\\python\\pptx.py\"ではなく、インストールされている \n”c:\\users\\XXXX\\appdata\\local\\continuum\\anaconda3\\lib\\site-packages\\python-\npptx”からインポートするように設定すれば解決すると思います。 \n(\"C:\\Users\\XXXX\\Desktop\\python\\pptx.py\"というファイルを削除するだけで良いかもしれません)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T06:48:02.357",
"id": "44181",
"last_activity_date": "2018-05-23T06:48:02.357",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "44179",
"post_type": "answer",
"score": 0
},
{
"body": "もし実行しようとしているサンプルを `pptx.py` というファイル名で保存しているなら、それ以外の名前にして `Desktop\\pyhon\\` にある\n`pptpx.py` と `pptx.pyc` は削除してください。\n\n`from pptx import Presentation` の `from pptx`\nが、そのサンプルコード自身を指しているためエラーになっているのだと思われます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T02:14:46.770",
"id": "44238",
"last_activity_date": "2018-05-25T02:14:46.770",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3475",
"parent_id": "44179",
"post_type": "answer",
"score": 2
}
] | 44179 | null | 44238 |
{
"accepted_answer_id": "44189",
"answer_count": 1,
"body": "VScodeでnode.jsとMySQLを組み合わせて書く時に整形がうまくいきません。\n\n[](https://i.stack.imgur.com/EHBcq.png)\n\n上の図のように長いSQL文を書く時に改行を入れたいのですが、改行を入れると下の図のようにエラーになって動かなくなってしまいます。\n\n[](https://i.stack.imgur.com/S4osC.png)\n\nうまく整形するにはどのようにすればいいのでしょうか。 \nPHPとMySQLの組み合わせでは問題ないのですが。。。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T07:08:22.353",
"favorite_count": 0,
"id": "44182",
"last_activity_date": "2018-05-23T13:13:46.177",
"last_edit_date": "2018-05-23T11:58:20.590",
"last_editor_user_id": "19110",
"owner_user_id": "28633",
"post_type": "question",
"score": 1,
"tags": [
"mysql",
"node.js",
"vscode"
],
"title": "node.jsで複数行のSQLを書くとき、整形がうまくいかない",
"view_count": 1298
} | [
{
"body": "これはエディタの問題ではなく、文字列リテラルが複数行になるときの文法の問題です。ご提示のプログラムのような文字列リテラルの書き方は構文エラーであるため、エディタでの表示もご想定とは異なるものになっています。\n\nNode.js\nにおいて、シングルクォートで囲った文字列リテラルはその中で改行できません。改行が文字列リテラルより優先されます。プログラム中の改行を文字列中の改行として扱う場合は、バッククォートで囲います。\n\n具体的には、以下のようにすると複数行の文字列リテラルになります。\n\n```\n\n const str1 = `SELECT piyo\n FROM example\n WHERE pyon = 1`;\n \n // 以下は行内で文字列リテラルが終わっていないため、構文エラーです。\n /*\n const str2 = 'SELECT piyo\n FROM example\n WHERE pyon =1';\n */\n \n```\n\nPHP においてはダブルクォートで囲った文字列リテラルの中で改行ができるため、今までエラーが出なかったのでしょう。\n\n## 参考\n\n * [\"How do I do a multi-line string in node.js?\"](https://stackoverflow.com/q/6220420/5989200) \\-- Stack Overflow\n * [\"Multi-line strings in PHP\"](https://stackoverflow.com/q/9744192/5989200) \\-- Stack Overflow",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T11:50:49.373",
"id": "44189",
"last_activity_date": "2018-05-23T13:13:46.177",
"last_edit_date": "2018-05-23T13:13:46.177",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "44182",
"post_type": "answer",
"score": 2
}
] | 44182 | 44189 | 44189 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "railsアプリをデプロイしたいのですが最後の段階でプリコンパイルエラーが出て先に進めません。 \nこちらのコマンド入力しました\n\n```\n\n bundle exec rake assets:precompile RAILS_ENV=production\n \n```\n\nエラー内容は\n\n```\n\n /usr/bin/env: ruby2.3: そのようなファイルやディレクトリはありません\n \n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n \n rake aborted!\n Sass::SyntaxError: Invalid CSS after \" color: \": expected expression \n (e.g. 1px, bold), was \";\"\n (sass):1652\n \n```\n\nというのがみて取れました。\n\nそこで質問なのですが、このエラー箇所がどこなのか全く見当がつかないのでどこを修正すればよいでしょうか? \ncssの記述ミスなのだと思っているのですが(e.g. 1px, bold)なんて書いた記憶もありませんし、cssのファイルに1652行目もありません。\n\n何かお気付きになられた方いましたら教えていただけると助かります。 \nまた、問題箇所特定するために何をすればよいのかも助かります。 \n宜しくお願いしますm(._.)m",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T07:11:55.263",
"favorite_count": 0,
"id": "44183",
"last_activity_date": "2019-03-15T05:01:05.333",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27359",
"post_type": "question",
"score": 1,
"tags": [
"ruby",
"デプロイ"
],
"title": "デプロイ時のプリコンパイルエラー",
"view_count": 413
} | [
{
"body": "`(e.g. 1px, bold)`は「例えば」という意味なので、実際にそういう記載があるという意味ではなさそうです。\n\n> color: \": expected expression\n\nRails標準のSass(SCSS)を利用されているようなので、その記載が間違っていてコンパイルができていないようです。 \n`color`を使っている箇所に誤った記述がありそうなので、一度そのへんを見直すとなにか見つかるかもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-30T08:23:20.987",
"id": "44409",
"last_activity_date": "2018-05-30T08:23:20.987",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25085",
"parent_id": "44183",
"post_type": "answer",
"score": 1
}
] | 44183 | null | 44409 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "WindowsOSで使用するC++で作成したDLLを埋め込んだC#のラッパーDLLを作成したいと考えています。 \nできればひとつのDLLとしてまとめたいのですが、このようなことは可能ですか?",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T07:28:50.063",
"favorite_count": 0,
"id": "44185",
"last_activity_date": "2018-05-30T18:30:53.720",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28634",
"post_type": "question",
"score": -1,
"tags": [
"c#",
"c++",
"windows"
],
"title": "C++で作成したDLLをラップするDLLを作りたい",
"view_count": 3028
} | [
{
"body": "PE32 DLL 要するに unmanage DLL (C++) と \n.NET Assembly DLL 要するに manage DLL (C#) と \nではファイルフォーマットも違いますし1つにできると聞いた事ないです。できないと明示している資料は見つけていませんし悪魔の証明になっちゃいますが。\n\n仮にできたとしても \n\\- manage つまり .NET Assembly のほうは AnyCPU で 32/64bit 共通にできるのに \n\\- unmanage のほうは PE32 (32bit) と PE32+ (64bit) で別ものですし \n32bit/64bit 両方対応するためにはやはりファイルを2つ用意しないといけなくてあまりおいしくないんぢゃないかなと思います。\n\n1つにまとめたい理由が配布、つまりファイル2つをコピーしたくないと言う理由であるなら、生ファイルを配布するのでなくインストーラにお任せするのが一番簡単ですし、そっち方向に舵を切ったほうが建設的でしょう。オイラならそうする。\n\nClickOnce でなんとかできるならそれもありかと・・・",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-29T07:45:38.647",
"id": "44359",
"last_activity_date": "2018-05-29T07:45:38.647",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "44185",
"post_type": "answer",
"score": 0
},
{
"body": "質問をするときは最低限のマナーとして、開発環境およびターゲット環境(OS、IDE、.NET\nFrameworkのバージョン、プロジェクト種別など)に関する情報を詳しく記載するようにしてください。\n\nひとくちに「C++で作成したDLL」と言っても、様々な実装手法があります。\n\n * ネイティブDLLにエクスポートされたC言語関数形式のインターフェイスを、C#マネージコードから[P/Invoke](https://msdn.microsoft.com/ja-jp/library/fzhhdwae\\(v=vs.100\\).aspx) (DllImport) で利用していますか?\n * それともC++/CLIでマネージインターフェイスを作成して公開していますか?\n * それともC++/CXでWindows Runtimeインターフェイスを作成して公開していますか?\n * あるいはCOM相互運用ですか?\n\nいずれにせよ、(C/C++などで書かれた)ネイティブDLLを、単にC#(.NET言語)から利用するというだけであれば、わざわざマネージアセンブリに埋め込んでラップする必要はありません。DLL参照を解決できる場所(たとえばEXEと同じフォルダー階層など)にDLLを配置すれば、ローダーが探してくれます。\n\nなお、ネイティブDLL(アンマネージDLL)をリソースとしてマネージアセンブリに埋め込み、DllImport属性で指定する方法自体はあるとされています。 \n[DllImportAttribute Constructor (String) (System.Runtime.InteropServices) -\nMSDN](https://msdn.microsoft.com/en-\nus/library/system.runtime.interopservices.dllimportattribute.dllimportattribute.aspx)\n\nただし、うまく動作しないという事例報告もあります。 \n[Embedding unmanaged dll into a managed C# dll - Stack\nOverflow](https://stackoverflow.com/questions/666799/embedding-unmanaged-dll-\ninto-a-managed-c-sharp-dll)\n\nマネージコードの場合はアセンブリの数を減らすことがオーバーヘッドの削減につながるため、複数のアセンブリをまとめるというユースケースは考慮されており、ILMergeというツールが用意されています(ただしマージ対象のすべてがマネージアセンブリである必要があります)。\n\n一方で、仮にマネージアセンブリにネイティブDLLを埋め込んで利用することができたとしても、おそらく得られるメリットは労力や手間の対価として見合わないはずです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-29T17:06:02.910",
"id": "44379",
"last_activity_date": "2018-05-30T18:30:53.720",
"last_edit_date": "2018-05-30T18:30:53.720",
"last_editor_user_id": "15413",
"owner_user_id": "15413",
"parent_id": "44185",
"post_type": "answer",
"score": 1
}
] | 44185 | null | 44379 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "先日Eclipseを入手したばかりで一応にPHP Development Toolsのセットアップも終えている認識です。 \n<http://proengineer.internous.co.jp/content/columnfeature/5404> \nを参考に、自分が作成したphpのコーディングをPHP CLIアプリケーションという実行方法で無事動作させることもできました。 \nEclipseの下部コンソールに現れたのはHTMLでした。\n\n===質問=== \n①このHTMLソースを別途エディタに貼り付けて、ブラウザで確認しない限り、実際ブラウザで表示されるイメージは認識できない、ということでしょうか? \nブラウザイメージで確認できる方法があれば、(Webサーバとの関連付けなど事前に必要とのことであればそれも含め)ご教示をお願い致します。Eclipseから出来ればの話です。\n\n②デバッグという操作があるようですが、VBAみたいに行単位のステップ実行などができればと思っています。試しに虫マークのアイコンを押してデバッグ操作を試行したところ\"There\nis no PHP server specified in 'test(1)' launch configuration.\"というエラーを招きます。 \nこの点についても事前に必要な設定などがあればご教示をお願いいたします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T08:30:20.707",
"favorite_count": 0,
"id": "44186",
"last_activity_date": "2018-05-23T08:30:20.707",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25696",
"post_type": "question",
"score": 0,
"tags": [
"php",
"eclipse"
],
"title": "EclipseでのPHP構築:実行やデバッグの操作方法、事前必要設定を把握したい",
"view_count": 312
} | [] | 44186 | null | null |
{
"accepted_answer_id": "52950",
"answer_count": 1,
"body": "python3.5を使っています。pyqt5を使ってGUIを作りました。その中で、ボタンを押した時に音が出る仕組みを作りました。ここではQtMultimediaのQMediaPlayerを使ってwavファイルを再生しています。このGUIをpyinstallerでexe化しました。すると、ボタンを押しても音が再生されなくなりました。特にエラーは出ておりません。他の機能は問題なく動作します。どうすれば良いのでしょうか。osはwindows8.1の64bitです。音を出すコードとしましては、まず、次のコードのように、pickleファイルから読み取ったwavファイルをフォルダ内に出力します。sound.wavファイルは予めフォルダ内に一つ用意してあります。\n\n```\n\n os.remove(\"sound_tempo.wav\") \n \n global sound\n write(\"sound_tempo.wav\",loaded_sound_list[10][0],loaded_sound_list[10][1])\n sound=QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(\"sound_tempo.wav\"))\n \n```\n\nその後、次のコードのように音を出す関数を起動させています\n\n```\n\n def make_sound(self):\n self.mediaPlayer.setMedia(sound)\n self.mediaPlayer.play()\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T12:30:51.770",
"favorite_count": 0,
"id": "44190",
"last_activity_date": "2019-02-22T17:07:52.220",
"last_edit_date": "2018-05-24T13:39:39.033",
"last_editor_user_id": "26529",
"owner_user_id": "26529",
"post_type": "question",
"score": 1,
"tags": [
"python",
"pyqt"
],
"title": "pyinstallerでGUIをexe化したらwavファイルのサウンドが再生できなくなった",
"view_count": 360
} | [
{
"body": "exe化する際にファイルを一つにまとめないように実行すると(--onefileを書かないようにする)PyQT5というフォルダが出来ます。その中のpluginフォルダの中のフォルダ全てを実行exeファイルと同じフォルダに移したら解決しました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-02-22T17:07:52.220",
"id": "52950",
"last_activity_date": "2019-02-22T17:07:52.220",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26529",
"parent_id": "44190",
"post_type": "answer",
"score": 1
}
] | 44190 | 52950 | 52950 |
{
"accepted_answer_id": "44203",
"answer_count": 1,
"body": "1. `//???`の部分はコンストラクタですか?コピーコンストラクタですか?教えていただきたいです。\n 2. また、前の日と次の日を「void operator++();//次の日」、「void operator--();//前の日」で実装しようとすると`//???`の部分はどうしたらわかりやすいコードを書くことが出来るか教えていただきたいです。\n\n```\n\n #pragma once\n #ifndef ___IntArray\n #define ___IntArray\n #include <iostream>\n #include <ostream>\n #include <sstream>\n #include <time.h>\n using namespace std;\n \n #define LEAP 29\n #define NOT_LEAP 28\n \n class Date {\n private: //うるう年は29 そうじゃない場合は28\n /* 0 1 2 3 4 5 6 7 8 9 10 11 12*/\n int mon[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};\n \n int year;\n int month;\n int day;\n public:\n \n Date()//デフォルトコンストラクタ\n {\n /*現在時刻で初期化*/\n time_t timer;\n struct tm local_time;\n timer = time(NULL);\n localtime_s(&local_time, &timer);\n \n year = local_time.tm_year + 100;\n month = local_time.tm_mon + 1;\n day = local_time.tm_yday;\n }\n \n Date(int y, int m, int d)//???\n {\n year = y;\n month = m;\n day = d;\n \n /*月が12以上の時12月31日に変更*/\n if (month > 12)\n {\n month = 12;\n day = 31;\n }\n \n /*日数がその月の最大日数を超えてる時にうるう年の2月でうるう年かどうかを判定して数字を代入*/\n if (day > mon[month] && month == 2) {\n if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))\n {\n day = LEAP;\n }\n else\n {\n day = NOT_LEAP;\n }\n }\n else \n { \n if (day > mon[month]) {\n day = mon[month];//2月じゃないけど日数が超えてる場合にその月の最大日数を代入\n }\n }\n }\n \n string to_string()const\n {\n ostringstream s;\n s << year<<\"/\" << month << \"/\" << day<<\"\\n\";\n return s.str();\n }\n };\n \n inline ostream& operator<<(ostream& s, const Date& x)\n {\n return s << x.to_string();\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T12:34:07.923",
"favorite_count": 0,
"id": "44191",
"last_activity_date": "2018-05-24T02:07:50.953",
"last_edit_date": "2018-05-23T15:48:02.133",
"last_editor_user_id": "3060",
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "クラス作成で名称の意味が混乱しています",
"view_count": 211
} | [
{
"body": "1.については、複数の引数を持つ一般的なコンストラクタです。 \nコンストラクタは、クラス名と同じ名称で戻り値が無いので判別できます。 \nおおざっぱに言うと、 \n(A)引数を持たないものはデフォルトコントラクタ。 \n(B)自身の型を一つだけ引数に持つものをコピーコンストラクタと言います。 \n(C)引数の型や数が異なる複数のコンストラクタを実装できます。 \nコンストラクタは他の関数とは異なり、もっと色々な特別扱いが沢山ありますのでご自身でお調べになってみてはどうでしょう。\n\n次に、演算子のオーバーロードは高度な知識が必要な実装なので、一足飛びに挑戦しない方が無難です。 \nまずは同等機能を持つ一般メンバ関数として実装してみてはどうでしょう。 \nつまり、My_Decriment()関数やMy_Increment()関数などを実装してみるわけです。 \nこれらが確実に動作することを確認したら対象演算子をオーバーロードして、同じ処理を実装します。 \nまた、単項後置デクリメント演算子は自身の参照を戻すのが普通です。 \nそうでないと、コードによっては希望した動作とならない場合があります。\n\n最後に、クラス名に一般名詞を採用するのは他の実装とぶつかる確率が高くなり危険です。 \n意味を保ちつつなるべくユニークに命名すれば本筋でない問題の発生を避けることができ、学習が捗ると考えられます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T02:07:50.953",
"id": "44203",
"last_activity_date": "2018-05-24T02:07:50.953",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3793",
"parent_id": "44191",
"post_type": "answer",
"score": 1
}
] | 44191 | 44203 | 44203 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "# 環境\n\n * AWS EC2 ts.xlarge\n\n# 背景\n\nt2.xlargeインスタンスで、1日以上かかるバッチプログラムを実行しています。 \nプログラム開始してから数時間経った後の進捗率は、プログラム開始直後の約2~3倍でした。\n\n進捗率が低いときの、CPUCreditBalanceのグラフは、以下の通りです。 \n[](https://i.stack.imgur.com/EHFKv.png) \n\"25\"付近を上下しています。\"0\"にはなっていません。\n\nグラフの範囲を3日にしたのが、以下の図です。 \n[](https://i.stack.imgur.com/L21kQ.png) \nプログラムが遅くなったタイミングと、CPUCreditBalanceが\"1300\"から降下して\"25\"になったタイミングは、同じでした。\n\n以上のことから、「プログラムが遅くなった原因はCPUCreditBalanceだ」と判断しました。\n\n# 質問\n\nCPUCreditBalanceが\"0\"にならないのは、なぜでしょうか? \nまた、CPUCreditBalanceが\"25\"で遅くなるのは、なぜでしょうか?\n\n私は「CPUCreditBalanceが\"0\"になると、遅くなる」と考えていたので、上記の現象を疑問に思いました。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T13:38:10.943",
"favorite_count": 0,
"id": "44192",
"last_activity_date": "2022-12-21T02:01:30.230",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19524",
"post_type": "question",
"score": 4,
"tags": [
"aws",
"amazon-ec2"
],
"title": "AWS EC2のCPUCreditBalanceが25でも、遅くなるのですか?",
"view_count": 427
} | [
{
"body": "よくわからないので回答になってないですが・・・\n\n> CPUCreditBalanceが\"0\"にならないのは、なぜでしょうか? \n> また、CPUCreditBalanceが\"25\"で遅くなるのは、なぜでしょうか?\n\nt2.xlarge は 4vCPU なので、5分間で 最大20クレジット消費する事ができます。 \nなので グラフの 値が \"0\" にならなくても速度の低下は見られると思います。 \nしかしながら 下限が24以上あるので もう少し動いてくれても良い気がしますね・・・。\n\nこの程度は 誤差なのかもしれませんが、他にボトルネックがある可能性は排除できない気がします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T09:55:43.527",
"id": "44219",
"last_activity_date": "2018-05-24T09:55:43.527",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "44192",
"post_type": "answer",
"score": 0
}
] | 44192 | null | 44219 |
{
"accepted_answer_id": "44197",
"answer_count": 1,
"body": "(参考)SymPyにおいて関数を関数で置き換えて(≠代入)三角関数の加法定理を証明しよう \n<https://qiita.com/HigashinoSola/items/9fdff5c849445c5c1607>\n\n```\n\n from sympy import *\n var('u v w t')\n myFn1 = Function('myFn1')\n myFn2 = Function('myFn2')\n myFn3 = Function('myFn3')\n print('--------------------------------------------------')\n v=cos(u)\n print('v=',v)\n print('v=',expand(v.replace(cos,sin)))\n print('v=',expand(v.replace(u,w)))\n print('--------------------------------------------------')\n v=myFn1(u)\n print('v=',v)\n print('v=',expand(v.replace(myFn1,myFn2)))\n print('v=',expand(v.replace(u,w)))\n #v= cos(u)\n #v= sin(u)\n #v= cos(w)\n #v= myFn1(u)\n #v= myFn2(u)\n #v= myFn1(w)\n print('--------------------------------------------------')\n v=myFn1(u)\n print('v=',v)\n print('v=',expand(v.replace(myFn1,myFn3).replace(u,'u,t')))\n \n```\n\nエラー: \"given an expression, replace() expects \" \n出力したいもの \nmyFn3(u,t) \nーーーーーーーーーーーーーーーーーーーーーーーーーーーーー \n(2018-05-23) 1,2できました。ありがとうございました。 \nFullScript\n\n```\n\n from sympy import Function, Wild\n from sympy.abc import x, y\n print('------------------------------------------')\n f = Function('f')\n g = Function('g')\n v = f(x) + f(x + 1)\n print('v =',v)\n print('v1=',v.replace(f(x), g(x, y)))\n a =Wild('a')\n print('v2=',v.replace(f(a), lambda a: g(a, y)))\n v = f(x) + f(x + 1)\n v1= f(x + 1) + g(x, y)\n v2= g(x, y) + g(x + 1, y)\n print('------------------------------------------')\n myFn1 = Function('myFn1')\n myFn3 = Function('myFn3')\n v = myFn1(x)\n print('v =',v)\n b =Wild('b')\n print('v3b=',v.replace(myFn1(b), lambda b: myFn3(b, y)))\n # u = Wild('u')\n # print('v3u=',v.replace(myFn1(u), lambda a: myFn3(u, y)))\n # TypeError: <lambda>() got an unexpected keyword argument 'u'\n #\n # v = f(x) + f(x + 1)\n # v1= f(x + 1) + g(x, y)\n # v2= g(x, y) + g(x + 1, y)\n # v = myFn1(x)\n # v3b= myFn3(x, y)\n \n```\n\n使える文字と使えない文字の違いの原因は、わかりませんでした。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T14:13:37.690",
"favorite_count": 0,
"id": "44193",
"last_activity_date": "2018-05-24T13:15:38.963",
"last_edit_date": "2018-05-24T13:15:38.963",
"last_editor_user_id": "17199",
"owner_user_id": "17199",
"post_type": "question",
"score": 0,
"tags": [
"python",
"sympy"
],
"title": "SymPyにおいて関数を関数で置き換えて,replaceで「引数の数を増やす事」は可能ですか?",
"view_count": 415
} | [
{
"body": "目的にあわせて、ふたつのやり方を紹介します。1引数の関数 `f` と、2引数の関数 `g` があるとして説明します。\n\n```\n\n # つまり、こういう設定です。v 中の f を置換したいです。\n from sympy import Function, Wild\n from sympy.abc import x, y\n f = Function('f')\n g = Function('g')\n v = f(x) + f(x + 1)\n \n```\n\n 1. `f` に `x` が適用されている部分すべてを `g(x, y)` にしたい場合、直接 `f(x)` を `replace` すれば良いです。\n``` >>> v.replace(f(x), g(x, y))\n\n f(x + 1) + g(x, y)\n \n```\n\n 2. `f` に何か引数が適用されている部分すべてを、その引数を第一引数、`y` を第二引数として `g` に適用するようにしたい場合、パターンを利用して `replace` すれば良いです。\n``` >>> a = Wild('a')\n\n >>> v.replace(f(a), lambda a: g(a, y))\n g(x, y) + g(x + 1, y)\n \n```\n\n`replace`\n関数のより詳しい使い方については、[こちらの公式ドキュメント](http://docs.sympy.org/latest/modules/core.html#sympy.core.basic.Basic.replace)に載っています。特に下の方に載っている\nExamples をご参照ください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T16:47:58.900",
"id": "44197",
"last_activity_date": "2018-05-23T17:37:32.183",
"last_edit_date": "2018-05-23T17:37:32.183",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "44193",
"post_type": "answer",
"score": 1
}
] | 44193 | 44197 | 44197 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "# 環境\n\n * Scala 2.12.5\n * IntelliJ IDEA 2018.1 (Community Edition)\n * JRE: 1.8.0_152-release-1136-b20 amd64\n * JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o\n * Windows 10\n\n# 起こったこと\n\nfor式のジェネレータ部分に、リテラル識別子を使いました。\n\n```\n\n def sampleOpt(i: Int): Option[Int] = Some(i)\n \n val a = for (\n `type` <- sampleOpt(10)\n ) yield `type` * 2\n println(\"a=\" + a) //⇒ a=Sample(20)\n \n```\n\n * IntelliJ IDEAのエディタウィンドウでは、\"Cannot resolve symbol `type\"というエラーが表示されました。 \n[](https://i.stack.imgur.com/m3i5G.png)\n\n * ビルド&実行はできました。\n\n# 質問\n\n上記の現象は、何が起こっているのでしょうか?\n\n * IntelliJの構文チェックツールのバグでしょうか?\n * Scalaの構文ルールに違反しているのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T14:41:05.247",
"favorite_count": 0,
"id": "44194",
"last_activity_date": "2018-05-23T14:41:05.247",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19524",
"post_type": "question",
"score": 2,
"tags": [
"scala"
],
"title": "for式のジェネレータ部分にリテラル識別子を使うと、IntelliJの構文チェックツールではエラーだが、実行できる",
"view_count": 49
} | [] | 44194 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "今まで動いていたアプリを、新しいxcodeとsdkでコンパイルしたら、 \ngooglemaps apiで表示している地図上の現在地ボタンが稼働しなくなりました。 \n何か仕様変更があったのでしょうか?\n\n現在地ボタンの表示は、objective-c内で以下のコードで行なっています。\n\n```\n\n mapView_.settings.myLocationButton = YES;\n \n```\n\ngooglemaps sdk のバージョンは、2.7.0、 \nxcodeのバージョンは、9.3.1 です。\n\ngoogle map アプリでは現在地ボタンは機能しています。\n\nまた、アプリ内では、UITableView → UITableView → 地図\nと画面遷移させているのですが、テーブルビュー間の画面遷移がとても遅くなってしまいました。 \nこれにつきましても、何か思い当たるような原因をご存知でしたらご教授願いたいと思います。\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T16:07:56.307",
"favorite_count": 0,
"id": "44195",
"last_activity_date": "2018-05-24T16:21:39.520",
"last_edit_date": "2018-05-23T16:55:39.797",
"last_editor_user_id": "19110",
"owner_user_id": "28639",
"post_type": "question",
"score": 0,
"tags": [
"google-maps"
],
"title": "ios googlemaps apiで現在地ボタンが稼働しません。仕様変更がありましたか?",
"view_count": 280
} | [
{
"body": "単純なサンプルプログラムを作ってみて、アプリ名.plistにセキュリティ関連のキーを追加したら稼働しましたので、動かない古いPGMは細部を見直したり、プロジェクトから作り直すかしてみます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T16:21:39.520",
"id": "44233",
"last_activity_date": "2018-05-24T16:21:39.520",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28639",
"parent_id": "44195",
"post_type": "answer",
"score": -1
}
] | 44195 | null | 44233 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "以下から「Spring Boot CLI」というソフトウェアをダウンロードしました。 \n[10.2 Installing the Spring Boot CLI | Spring Boot Reference\nGuide](https://docs.spring.io/spring-\nboot/docs/current/reference/htmlsingle/#getting-started-installing-the-cli)\n\n環境変数を追加しました。 \nC:\\Users\\yoshi\\Desktop\\spring-2.0.2.RELEASE\\bin\n\n以下のファイルをデスクトップに置きました。\n\nファイル名:app.groovy\n\n```\n\n @RestController\n class App {\n \n @RequestMapping(\"/\")\n def home() {\n \"Hello!\"\n }\n }\n \n```\n\nコマンドプロンプトで「spring run app.groovy」と打ちました。\n\n以下のエラーが出ました。どうすればよいでしょうか。\n\n```\n\n C:\\Users\\yoshi>cd desktop\n \n C:\\Users\\yoshi\\Desktop>spring run app.groovy\n Resolving dependencies....\n ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...\n \n . ____ _ __ _ _\n /\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\\n ( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\\n \\\\/ ___)| |_)| | | | | || (_| | ) ) ) )\n ' |____| .__|_| |_|_| |_\\__, | / / / /\n =========|_|==============|___/=/_/_/_/\n :: Spring Boot :: (v2.0.0.BUILD-SNAPSHOT)\n \n ERROR DefaultListableBeanFactory Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception\n java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6c84aed8: startup date [Thu May 24 01:53:30 JST 2018]; root of context hierarchy\n at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:420)\n at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:95)\n at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:240)\n at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:576)\n at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:552)\n at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:953)\n at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:521)\n at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:227)\n at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:960)\n at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1035)\n at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:562)\n at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)\n at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)\n at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)\n at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:498)\n at org.springframework.boot.cli.app.SpringApplicationLauncher.launch(SpringApplicationLauncher.java:69)\n at org.springframework.boot.cli.command.run.SpringApplicationRunner$RunThread.run(SpringApplicationRunner.java:173)\n ERROR SpringApplication Application run failed\n org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ClockProvider\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)\n at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)\n at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)\n at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)\n at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)\n at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:203)\n at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:709)\n at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:534)\n at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)\n at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)\n at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)\n at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:498)\n at org.springframework.boot.cli.app.SpringApplicationLauncher.launch(SpringApplicationLauncher.java:69)\n at org.springframework.boot.cli.command.run.SpringApplicationRunner$RunThread.run(SpringApplicationRunner.java:173)\n Caused by: java.lang.NoClassDefFoundError: javax/validation/ClockProvider\n at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:33)\n at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276)\n at org.springframework.boot.validation.MessageInterpolatorFactory.getObject(MessageInterpolatorFactory.java:53)\n at org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator$Delegate.<init>(ConfigurationPropertiesJsr303Validator.java:71)\n at org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator.<init>(ConfigurationPropertiesJsr303Validator.java:43)\n at org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator.getIfJsr303Present(ConfigurationPropertiesJsr303Validator.java:64)\n at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.<init>(ConfigurationPropertiesBinder.java:69)\n at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.afterPropertiesSet(ConfigurationPropertiesBindingPostProcessor.java:78)\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1763)\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1700)\n ... 19 more\n Caused by: java.lang.ClassNotFoundException: javax.validation.ClockProvider\n at java.net.URLClassLoader.findClass(URLClassLoader.java:381)\n at org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader.findClass(ExtendedGroovyClassLoader.java:84)\n at java.lang.ClassLoader.loadClass(ClassLoader.java:424)\n at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:678)\n at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:788)\n at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:776)\n ... 29 more\n java.lang.reflect.InvocationTargetException\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:498)\n at org.springframework.boot.cli.app.SpringApplicationLauncher.launch(SpringApplicationLauncher.java:69)\n at org.springframework.boot.cli.command.run.SpringApplicationRunner$RunThread.run(SpringApplicationRunner.java:173)\n Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ClockProvider\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1704)\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)\n at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)\n at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)\n at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)\n at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)\n at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:203)\n at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:709)\n at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:534)\n at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)\n at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)\n at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)\n at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)\n ... 6 more\n Caused by: java.lang.NoClassDefFoundError: javax/validation/ClockProvider\n at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:33)\n at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276)\n at org.springframework.boot.validation.MessageInterpolatorFactory.getObject(MessageInterpolatorFactory.java:53)\n at org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator$Delegate.<init>(ConfigurationPropertiesJsr303Validator.java:71)\n at org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator.<init>(ConfigurationPropertiesJsr303Validator.java:43)\n at org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator.getIfJsr303Present(ConfigurationPropertiesJsr303Validator.java:64)\n at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.<init>(ConfigurationPropertiesBinder.java:69)\n at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.afterPropertiesSet(ConfigurationPropertiesBindingPostProcessor.java:78)\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1763)\n at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1700)\n ... 19 more\n Caused by: java.lang.ClassNotFoundException: javax.validation.ClockProvider\n at java.net.URLClassLoader.findClass(URLClassLoader.java:381)\n at org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader.findClass(ExtendedGroovyClassLoader.java:84)\n at java.lang.ClassLoader.loadClass(ClassLoader.java:424)\n at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:678)\n at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:788)\n at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:776)\n ... 29 more\n C:\\Users\\yoshi\\Desktop>\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T17:08:55.223",
"favorite_count": 0,
"id": "44198",
"last_activity_date": "2018-05-23T22:06:44.497",
"last_edit_date": "2018-05-23T17:29:07.453",
"last_editor_user_id": "3060",
"owner_user_id": "23122",
"post_type": "question",
"score": 4,
"tags": [
"spring",
"groovy"
],
"title": "Spring Boot groovyファイル実行でエラー Log4j2 ?",
"view_count": 915
} | [] | 44198 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "jspでiteratorを使ってセッションを値を取得したいんですが、\n\n```\n\n <s:form action=\"hogeAction\" > //hogeActionに送る\n <s:iterator value=\"session.data\"> //session.dataに入ってるデータをiteratorで \n 取得している\n <s:property value=\"name\" /> //session.dataの中のname\n <s:property value=\"id\" /> //session.dataの中のid\n \n <input type=\"hidden\" name=\"item\" value=' <s:property value=\"name\" />’>\n //↑ここでもsession.dataの中のnameを取得したいんだが、なぜか入っては、いるものの \n nameの値全部が入っている。 \n </s:iterator>\n </s:form>\n \n```\n\ninputの前でもiteratorしましたが思うように行かず、、、 \niteratorで取り出せるのは一回までなんですかね???\n\n追記: \nsession.dataのnameの値はapple,orange,peachが配列の中に入っており、イテレータを使ってJSPに一つずつ表示させます。クリックしたら買い物カゴにぶち込むという機能をつけるべく、formの中にdivタグでその中にそれぞれデータを入れます。クリックしたやつだけデータを送り、買い物カゴに入れたいんです。formで送る値はinputの中に書かなければいけないらしく、hidden属性にしました。んでクリックして確認のために表示させてみるとappleのところをクリックしたのに配列全部の値を取得してしまいました。なぜかtypeをcheckboxにしてみるとチェックしたやつだけ表示できました。が、そのdivタグ内に写真やら説明文やらを追加する予定でそれらどれでもいいのでクリックしたら買い物カゴに追加したいのでcheckboxだと、うーんという感じです。モヤモヤを消したいです。",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-23T21:57:39.620",
"favorite_count": 0,
"id": "44199",
"last_activity_date": "2019-09-09T09:00:44.147",
"last_edit_date": "2018-05-24T07:37:35.543",
"last_editor_user_id": "21092",
"owner_user_id": "28615",
"post_type": "question",
"score": 0,
"tags": [
"java",
"jsp",
"struts"
],
"title": "jspのiteratorについて",
"view_count": 1266
} | [
{
"body": "今のコードからは、`name`属性が同じ3つの`input`タグが出力されるので(以下)、リクエストパラメータ`item`の値はapple,orange,peachの3つになります。\n\n```\n\n <input type=\"hidden\" name=\"item\" value=\"apple\" />\n <input type=\"hidden\" name=\"item\" value=\"orange\" />\n <input type=\"hidden\" name=\"item\" value=\"peach\" />\n \n```\n\nクリックしたものだけデータを送りたいのであれば、それを識別できる簡単な仕組みを実装する必要があります。それに関してはググって調べて下さい。\n\n**追記**\n\n> ありがとうございます!グーグルさんに聞いたところよくわかりませんでした。\n\nググって最初に以下の記事が出てきました。参考になると思います。\n\n<https://stackoverflow.com/questions/13020727/how-to-submit-specific-iterator-\nentry-to-action-in-struts-2>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T03:03:40.063",
"id": "44205",
"last_activity_date": "2018-05-24T04:41:22.623",
"last_edit_date": "2018-05-24T04:41:22.623",
"last_editor_user_id": "21092",
"owner_user_id": "21092",
"parent_id": "44199",
"post_type": "answer",
"score": 1
}
] | 44199 | null | 44205 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Realmを使用したAndroidアプリの開発を始めたのですが、カラム名や型を変更するとアプリが落ちてしまいます。どちらか片方を変更しただけでもアプリが落ちます。\n\n### プログラムの構成\n\nMainActivity.kt \n・createメソッド(新しいレコードの追加) \n・readメソッド(値をとってくる) \n・TextViewにとってきた値を表示\n\nDataBase.kt \n・PrimaryKey:id(String) \n・カラム名 :name(String), price(Long)\n\n### やりたいこと\n\n[Kotlin + Android でRealmをつかってみた。 -\nQiita](https://qiita.com/Juju_62q/items/eaf55c7722b826156404)\n\n上記のサイトを中心にいろいろなサイトを見ながら、レコードを追加して値をとってくるところまではとりあえず上手くいったのですが、サイトに書いてあった通りにカラム名をつけていたので下記のように変更する必要がありました。\n\nname(String) → mName(String) price(Long) → mPhonetic(String)\n\n### 変更点\n\nDataBase.ktのカラム名と型 \nMainActivity.ktのcreateメソッドの引数と指定した項目に引数の値を入れる処理",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T02:20:47.520",
"favorite_count": 0,
"id": "44204",
"last_activity_date": "2021-03-07T04:33:25.320",
"last_edit_date": "2021-03-07T04:33:25.320",
"last_editor_user_id": "3060",
"owner_user_id": "28635",
"post_type": "question",
"score": 0,
"tags": [
"android",
"realm",
"kotlin"
],
"title": "Realmを使用したいのですがカラム名・型の変更ができません",
"view_count": 922
} | [
{
"body": "すでにRealmのファイルに保存されているオブジェクトのデータ構造とクラスの定義が異なるためです。\n\n解決方法としては2つあります。\n\nまだアプリが未リリースで、かつ既存のデータを消しても良いのであれば、Realmファイルを消す、または`RealmConfiguration`にデータ構造が異なる場合は自動的にファイルを消して再生成するという設定の`deleteIfMigrationNeeded()`を指定します。そうするとRealmが自動的に既存のファイルを消して新しいデータ構造で再生成してくれます。\n\n既存のデータが消せない場合、マイグレーションを記述します。これはRealmにデータ構造の変更が意図的なもので、どこが変わったのかを知らせる処理になります。\n\n詳しくは \n<https://realm.io/docs/java/latest#migrations> \nをみてください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T09:28:18.630",
"id": "44218",
"last_activity_date": "2018-05-24T09:28:18.630",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "44204",
"post_type": "answer",
"score": 1
}
] | 44204 | null | 44218 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "プログラム初心者です。 \nviewDidLoadにてgetFlagメソッドを呼び、非同期でサーバーから情報を取得し、その値をviewWillAppearで使用したいのですが、下記のようなコードですと「isFlag」に値がセットされる \nタイミングが遅く、viewWillAppearが実行されるタイミングに間に合いません。 \nこのような場合どのようにすれば良いでしょうか。\n\n```\n\n @interface hogeViewController(){\n BOOL isFlag; \n }\n \n - (void)viewDidLoad {\n [super viewDidLoad];\n \n [self getFlag];\n }\n \n -(void) viewWillAppear:(BOOL)animated{\n [super viewWillAppear:animated];\n \n if(isFlag){\n ...\n }else{\n ...\n }\n }\n \n -(void) getFlag{\n NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];\n \n NSString *serverInfo_ = nil;\n serverInfo_ = [NSString stringWithFormat:@\"https://%@\", WebServerInfo];\n NSString *mediaApi = [serverInfo_ stringByAppendingFormat:@\"/api/hoge/\"];\n \n NSURL *url_ = [NSURL URLWithString:mediaApi];\n [request setHTTPMethod:@\"GET\"];\n \n [NSURLConnection sendAsynchronousRequest:request\n queue:[NSOperationQueue mainQueue]\n completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {\n if(data){\n isFlag = true;\n }\n }];\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T04:03:51.027",
"favorite_count": 0,
"id": "44206",
"last_activity_date": "2020-08-07T05:01:50.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28641",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"xcode",
"objective-c"
],
"title": "iosでのhttpリクエスト(GET)のタイミングについて",
"view_count": 239
} | [
{
"body": "こんにちは!\n\n非同期、つまり、いつ返ってくるかわからないデータを `viewWillAppear`\nで利用する、というアプローチが間違っていると思います。御存知の通り、`viewWillAppear`\nはviewが表示される直前に呼ばれるメソッドですので、getFlag の処理が終わるのは待ってくれません。\n\nどうしても`viewWillAppear` で利用したいのであれば、非同期ではなく、同期でやるしかないと思いますよ!",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T04:30:36.377",
"id": "44208",
"last_activity_date": "2018-05-24T04:30:36.377",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "369",
"parent_id": "44206",
"post_type": "answer",
"score": 0
},
{
"body": "はじめまして。私も@小川\n航佑さんと同じく、`hogeView`を表示する前にデーターの取得を完了しているのが望ましいと思うのですが、`hogeView`がアプリケーションが起動した最初の`view`である場合など、ままならない場合もありますよね。 \nそこで、今のソースを極力変えずにサーバーからの値で挙動を変える方法を2つ程考えて見ました。\n\n * 一つ目は同期でデーターを取得する方法。\n\nこれは、`- (void) getFlag`を修正して、\n\n```\n\n - (void) getFlag\n {\n NSString *serverInfo_ = nil;\n serverInfo_ = [NSString stringWithFormat:@\"https://%@\", WebServerInfo];\n NSString *mediaApi = [serverInfo_ stringByAppendingFormat:@\"/api/hoge/\"];\n \n NSURL *url_ = [NSURL URLWithString:mediaApi];\n NSData *data = [NSData dataWithContentsOfURL:url];\n \n if (data)\n {\n // dataが空でないとき\n }\n else\n {\n // dataが空の時\n }// end if data\n }// end - (void) getFlag\n \n```\n\n * もう一つは同期処理の完了を待つ方法\n\nこちらは一つ目の方法でも待ち時間は同じなんだから非同期転送に慣れておこうという考え方です。 \n当然、前者より面倒くさくなります。\n\nまず、メンバー変数に転送が終わったかのフラグを用意し、初期化します。\n\n```\n\n @interface hogeViewController(){\n BOOL isFlag; \n BOOL getDataDone; // 転送完了を待つためのフラグ\n }\n \n - (void)viewDidLoad {\n [super viewDidLoad];\n \n getDataDone = NO; // データ取得前に転送完了フラグを初期化\n [self getFlag];\n }\n \n```\n\n次に、非同期通信のコンプリーションハンドラーでデータの取得が完了時にこのフラグを立てる様にします\n\n```\n\n [NSURLConnection sendAsynchronousRequest:request\n queue:[NSOperationQueue mainQueue]\n completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {\n if(data){\n isFlag = true;\n }\n getDataDone = YES; // コンプリーションハンドラーの最後で転送完了フラグを立てる\n }];\n \n```\n\nそして、`viewWillAppear`の中でコンプリーションハンドラーが終わるまで待ちます\n\n```\n\n -(void) viewWillAppear:(BOOL)animated{\n [super viewWillAppear:animated];\n \n // 転送完了を待つ処理\n while(!getDataDone)\n {\n [NSThread sleepTimeInterval:0.1];\n }//end while getDataDone become true\n // getDataDoneがYESになったら以降の行に進む\n if(isFlag){\n ...\n }else{\n ...\n }\n }\n \n```\n\n申し訳ありませんが動作確認をしていないので、必要に応じて 変数に `__block`宣言を追加するなどしてください",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T07:26:58.447",
"id": "44214",
"last_activity_date": "2018-05-24T07:57:36.790",
"last_edit_date": "2018-05-24T07:57:36.790",
"last_editor_user_id": "14745",
"owner_user_id": "14745",
"parent_id": "44206",
"post_type": "answer",
"score": 0
}
] | 44206 | null | 44208 |
{
"accepted_answer_id": "44211",
"answer_count": 2,
"body": "python3で\n\n```\n\n a = 0x00001234ABCD\n \n```\n\nのような変数を16進数で出力すると\n\n```\n\n 1234ABCD\n \n```\n\nとなってしまいます。 \n0を省略させずにそのまま表示するにはどうすればいいのでしょうか? \nそれともpython2でしかできないのでしょうか?\n\n```\n\n a = 0x00001234ABCD\n \n print(hex(a))\n 0x1234abcd\n \n print(format(a,\"x\"))\n 1234abcd\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T06:23:13.357",
"favorite_count": 0,
"id": "44210",
"last_activity_date": "2018-05-24T07:26:21.343",
"last_edit_date": "2018-05-24T07:11:26.180",
"last_editor_user_id": "19110",
"owner_user_id": "28644",
"post_type": "question",
"score": 3,
"tags": [
"python",
"python3"
],
"title": "python3における0の省略",
"view_count": 272
} | [
{
"body": "数を出力する際先頭にゼロを付けるには、[`str.format()`](https://docs.python.jp/3/library/stdtypes.html#str.format)\nなどのフォーマット関数を使う方法があります。\n\n```\n\n >>> a = 0x00001234ABCD\n >>> print(\"0x{:012x}\".format(a))\n 0x00001234abcd\n >>> print(\"0x{:012X}\".format(a))\n 0x00001234ABCD\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T06:48:24.783",
"id": "44211",
"last_activity_date": "2018-05-24T06:48:24.783",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "44210",
"post_type": "answer",
"score": 3
},
{
"body": "n進数の接頭辞(`0x`)を自動で付与させたい場合は`format`関数のフォーマット指定`{}`で`#`を含める方法がありますが、桁数は接頭辞も考慮して指定する必要があります。\n\n```\n\n print('HEX: {:012X}'.format(0x00001234ABCD))\n print('HEX: {:#014X}'.format(0x00001234ABCD))\n \n```\n\n結果\n\n```\n\n HEX: 00001234ABCD\n HEX: 0X00001234ABCD\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T07:26:21.343",
"id": "44213",
"last_activity_date": "2018-05-24T07:26:21.343",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "44210",
"post_type": "answer",
"score": 3
}
] | 44210 | 44211 | 44211 |
{
"accepted_answer_id": "44215",
"answer_count": 2,
"body": "以下の例では`-m`をrequired指定していますが、`--version`が指定されたときは、`-m`が未指定でも、バージョン情報を出力して終了する、ということをやりたいです。何か方法はないでしょうか?\n\n```\n\n #!/usr/bin/env python3\n # -*- coding: utf-8 -*-\n \n \n import pkg_resources\n import sys\n import argparse\n \n argparser = argparse.ArgumentParser(\n description='This tool will help local development of mbed',\n formatter_class=argparse.ArgumentDefaultsHelpFormatter\n )\n argparser.add_argument(\n '-m', '--target',\n required=True,\n help='Compile target MCU. @see https://github.com/ARMmbed/mbed-cli')\n \n argparser.add_argument(\n '--version',\n required=False,\n default=False,\n action='store_true',\n help='Print version info')\n \n args = argparser.parse_args()\n \n if args.version:\n print('xmbedinit {}'.format(\n pkg_resources.require('xmbedinit')[0].version))\n sys.exit()\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T06:52:35.447",
"favorite_count": 0,
"id": "44212",
"last_activity_date": "2018-05-25T03:38:20.857",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17238",
"post_type": "question",
"score": 4,
"tags": [
"python"
],
"title": "Pythonのargparseで特定のオプションが指定されている時はrequiredを抑制したい",
"view_count": 350
} | [
{
"body": "`--version` に関しては、ご所望の動作をするような action として `'version'` が用意されています。\n\n```\n\n argparser.add_argument('--version', action='version', version='%(prog)s 2.0')\n \n```\n\n参考: [argparse のドキュメントにおける action\nの節](https://docs.python.org/3/library/argparse.html#action)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T07:27:54.530",
"id": "44215",
"last_activity_date": "2018-05-24T07:31:40.950",
"last_edit_date": "2018-05-24T07:31:40.950",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "44212",
"post_type": "answer",
"score": 4
},
{
"body": "すでに承認回答がついてしまっていますが、[相互排他グループ](https://docs.python.org/ja/3/library/argparse.html#mutual-\nexclusion)を使うと`--version`以外の場合も対応できそうですね。`-m`と`--version`のORをとったオプションを作ってそれ自体を`required`にしてしまうという方法です。\n\n```\n\n group = argparser.add_mutually_exclusive_group(required=True)\n \n group.add_argument(\n '-m', '--target',\n help='Compile target MCU. @see https://github.com/ARMmbed/mbed-cli')\n \n group.add_argument(\n '--version',\n default=False,\n action='store_true',\n help='Print version info')\n \n```\n\n```\n\n % python3 test.py \n usage: test.py [-h] (-m TARGET | --version)\n test.py: error: one of the arguments -m/--target --version is required\n \n```\n\nただ、`--version`のような特殊なオプションの場合は、このようなメッセージは不親切な気もしますね。またmasmさんの指摘にもあるとおり、あくまでも相互排他であるため両方のオプションを同時に指定できません。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T09:58:43.060",
"id": "44220",
"last_activity_date": "2018-05-25T03:38:20.857",
"last_edit_date": "2018-05-25T03:38:20.857",
"last_editor_user_id": "13199",
"owner_user_id": "13199",
"parent_id": "44212",
"post_type": "answer",
"score": 2
}
] | 44212 | 44215 | 44215 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "awsでデプロイしたのですが、表示されたアプリのフォントがデプロイする前と変わっていて困っています。\n\n使っていたのは『うずらフォント』というものだったのですが、デプロイして、ブラウザをみてみると普通のフォントになっており、フォントが適用されていませんでした。\n\nブラウザ(クローム)の検証機能で、エラーが出ていました。\n\n```\n\n Failed to load resource: the server responded with a status of 404 (Not Found)\n \n```\n\nこちらのエラー調べたところ、読んでそのままで、ファイルが見つからない。パスが間違っているような問題みたいです。\n\nデプロイ前には問題なく使えていたのですが、困惑しております。\n\nこちらのフォントですが、cssに記述してあります。\n\n```\n\n @font-face {\n font-family: 'quizfont';\n src: url('nikumarufont.otf');\n font-weight: normal;\n font-style: normal;\n }\n @font-face {\n font-family: 'uzura';\n src: url('uzura.ttf');\n font-weight: normal;\n font-style: normal;\n }\n \n```\n\n2個入れてあって2個目のウズラしか使っておりません。\n\nこちらどのようにしたらフォント適用できるようになるでしょうか?\n\n後、重ねて質問なのですが、css変更した際にはまたアセットプリコンパイルのコマンドする必要があるのでしょうか?コマンドは以下\n\n```\n\n bundle exec rake assets:precompile RAILS_ENV=production\n \n```\n\n一応毎回変更した際には、こちらのコマンドとec2インスタンスの再起動、nginx再起動、unicorn起動としています。\n\n関係あるかわかりませんが、デプロイ時にアセットプリコンパイルのエラーが度々起こっていて、どうにも対処できなかったので、yui-\ncompressorというGemを導入して、configでこちら指定しました。するとうまく動いたのでこのままデプロイしております。\n\nDBはmysqlで、ブラウザはクロームです。PCはMacです。何かアドバイスなどいただけると助かります。 \n宜しくお願いします\n\n追記\n\ncssでパスの部分を一部変更しました\n\n```\n\n src: font-url('/assets/fonts/uzura.ttf');\n \n```\n\nこうすると、検証でのエラー表示は消えたのですが、フォント自体は反映されてません。またんなぞが増えてしまったのですが、引き続き宜しくお願いしますm(._.)m",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T09:08:47.560",
"favorite_count": 0,
"id": "44217",
"last_activity_date": "2019-12-17T04:03:10.850",
"last_edit_date": "2018-05-28T07:26:11.017",
"last_editor_user_id": "27359",
"owner_user_id": "27359",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"デプロイ"
],
"title": "デプロイしたrailsアプリのフォントについて",
"view_count": 285
} | [
{
"body": "> フォントが適用されていませんでした。\n\nフォントファイルはRailsアプリのどこに配置されていますか? \nRailsは基本的に静的資材(CSSやJS、フォントファイル、画像)などをAssets\nPipelineという機構で処理するのですが、まずその対象となっているかを知りたいです。\n\n> 後、重ねて質問なのですが、css変更した際にはまたアセットプリコンパイルのコマンドする必要があるのでしょうか?コマンドは以下\n\nあります。 \nRailsのAssets\nPipelineは資材をすべてコンパイルして別のファイルとして書き出すので、変更の有無にかかわらずデプロイのたびにコンパイルを実行するのが一般的かと思います。\n\n> 関係あるかわかりませんが、デプロイ時にアセットプリコンパイルのエラーが度々起こっていて\n\nどのようなエラーでしょうか?なにかファイルの配置にミスがあるのかもしれません。\n\n> こうすると、検証でのエラー表示は消えたのですが、フォント自体は反映されてません。\n\nこの指定だと、おそらくAssets Pipelineが吐き出したファイルへ向いていないと思われます。 \nエラーが消えたのが謎ですが、パット見正しい指定には見えないです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-30T08:21:11.587",
"id": "44406",
"last_activity_date": "2018-05-30T08:21:11.587",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25085",
"parent_id": "44217",
"post_type": "answer",
"score": 1
}
] | 44217 | null | 44406 |
{
"accepted_answer_id": "44234",
"answer_count": 2,
"body": "タイトルの件、ズバリ可能でしょうか?\n\nビルドやSetupProjectの出力対象としたときに、参照するライブラリだけ出力して \n自分自身のライブラリは、コードも1行も書いていない(*.csファイルがプロジェクトに無い)ので \n出力しないようにしたいです。\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T11:24:44.780",
"favorite_count": 0,
"id": "44222",
"last_activity_date": "2018-05-27T03:58:39.920",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9228",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"visual-studio"
],
"title": "C# アセンブリ出力無しのプロジェクトをVisual Studioで作成できますか?",
"view_count": 405
} | [
{
"body": ".csproj内部に`<Import Project=\"$(MSBuildBinPath)\\Microsoft.CSharp.targets\"\n/>`の記述がある場合はアセンブリ出力が記述されていないとコンパイルエラーになるため、おそらく出力しない.csprojを作成することは不可能ではないかと考えています。 \n[MSBuildプロパティ](https://msdn.microsoft.com/ja-\njp/library/bb629394.aspx)の`OutputPath`や`OutputType`を削除してもダメでした。\n\n疑似的にアセンブリを出力しないプロジェクトは、下記で作成できますがいかがでしょうか。\n\n 1. プロジェクトのプロパティ - アプリケーション - 出力の種類を「コンソール アプリケーション」に変える \n * これで.csファイルを含まないプロジェクトがコンパイルできる\n 2. プロジェクトのプロパティ - ビルドイベント - ビルド後イベントのコマンドラインにアセンブリを消すコマンドを追加する\n\ndel $(TargetFileName) \ndel $(TargetFileName).config \ndel $(TargetName).pdb",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T01:02:02.790",
"id": "44234",
"last_activity_date": "2018-05-25T01:02:02.790",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "44222",
"post_type": "answer",
"score": 2
},
{
"body": "csproj ファイルのProject要素の DefaultTargets\nに自分で定義したターゲットを指定することで、一応そういうことも可能ではあるかと思います。 \n私の場合、以下のような感じでクラスライブラリプロジェクトと同列にNuGetパッケージのビルド用プロジェクトを作って、使っていたりします。\n\n```\n\n <Project DefaultTargets=\"BuildNuPkg\" ・・・・・>\n ・・・・・\n <Target Name=\"BuildNuPkg\" Condition=\" '$(Configuration)' == 'Release' \">\n ・・パッケージ作成タスク・・\n </Target>\n </Project>\n \n```\n\nCopyタスクというものがあるので、それ使って以下のような感じも可能ではあります。\n\n```\n\n <Project DefaultTargets=\"MyTask\" ・・・・・>\n ・・・・・\n <Target Name=\"MyTask\">\n <Copy SourceFiles=\"..\\ClassLibrary1\\bin\\$(Configuration)\\ClassLibrary1.dll\" DestinationFolder=\"$(OutDir)\" />\n </Target>\n </Project>\n \n```\n\nただ、この方法だと参照を増やしたらこの定義も増やさないといけないのでメンテナンス面で微妙かもしれませんけども。 \nビルドタスクの自作もできるようですがそういった方法や、他のビルドタスクで有用なものがないかとかまではそこまで詳しく把握していないのでわかりませんが。 \n簡潔さや管理上は不要ファイルを削除するほうが良いかもしれませんね。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T03:58:39.920",
"id": "44284",
"last_activity_date": "2018-05-27T03:58:39.920",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "44222",
"post_type": "answer",
"score": 2
}
] | 44222 | 44234 | 44234 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "SwiftyJSONを使っています。\n\n```\n\n let request = Alamofire.request(url).response{\n response in\n var json = JSON.null;\n \n if response.error == nil && response.data != nil {\n json = try! SwiftyJSON.JSON(data: response.data!)\n }\n .......\n }\n \n```\n\nと書いています。しかしnullが返されるapiにリクエストを出してもresponse.data != nilに反応せず、結果エラーが出てしまいます。 \nどうすればいいでしょうか。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T11:29:02.273",
"favorite_count": 0,
"id": "44223",
"last_activity_date": "2018-05-24T11:50:34.593",
"last_edit_date": "2018-05-24T11:50:34.593",
"last_editor_user_id": "3060",
"owner_user_id": "26567",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"xcode",
"json",
"swift4"
],
"title": "SwiftyJSONでnullが返ってきた時の対応の仕方を教えてください",
"view_count": 455
} | [] | 44223 | null | null |
{
"accepted_answer_id": "44271",
"answer_count": 1,
"body": "EclipseでPHPのデバッグ操作ができる、という情報を入手しました。\n\n<http://keicode.com/cgi/introducing-xdebug.php> \nの記事を参考に設定を試みていますがphpinfo()へ「xdebug」の文字が現われず、のっけから躓いております。\n\nphp.iniの最後に、入手したdllの配置箇所を以下要領で追記、Apacheの再起動後にphpinfo()の確認を行っています。 \nzend_extension_ts = \"C:\\xampp\\php\\ext\\php_xdebug-2.7.0alpha1-7.0-vc14-nts.dll\"\n\n試行している開発端末はx86・PHPは7.0.28です。 \n正直申し上げてhttps://xdebug.org/download.phpから取得したdllが、自身の環境に見合っているのか定かではありません。\n\nやはりphpinfo()にxdebugが現われないのは 適合外のdllを入手している、ということでしょうか? \n何が問題なのでしょうか? \n皆様ご見解をお待ち申し上げております。\n\n===デバッグを開始すると以下エラーがブラウザに表示されます=== \n[](https://i.stack.imgur.com/zHkka.png)\n\n===Eclipseの画面を見た限りXdebugが起動てきるようになった、ということ?=== \n[](https://i.stack.imgur.com/Sd10M.png)",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T12:33:03.067",
"favorite_count": 0,
"id": "44226",
"last_activity_date": "2018-05-26T00:25:11.210",
"last_edit_date": "2018-05-25T09:36:42.103",
"last_editor_user_id": "25696",
"owner_user_id": "25696",
"post_type": "question",
"score": 0,
"tags": [
"php",
"eclipse"
],
"title": "EclipseでPHPのデバッグ操作を達成するためxdebugが利用できるよう設定したい",
"view_count": 860
} | [
{
"body": "皆様いつも大変お世話になっております。 \nkeitaro_soさんの手ほどきで、自分の開発端末にPHPのデバッグユーティリティをセットアップすることができました。phpinfo()へxdebugの文字が表示されない、というのが当初の問合せでしたので、これ自体は達成されたので本スレッドを解決と致します。\n\n-解決までの道のり- \n①<https://xdebug.org/download.php> \nへアクセスしてxdebugのdll入手を試みるも、沢山ありすぎて自分のphpにどのverが相応しいのか正直分からない状態だった。一応x86版の7系を入手して、php/extに格納、その後php.iniのその有効化(パス)を記述、Webサーバも再起動\n\n②phpinfo()にxdebugが表示されない\n\n③こちらに記事掲載して、keitaro_soさんからhttps://xdebug.org/wizard.phpの紹介を受ける。 \n大きなテキストボックスが配置されいるページで、自身の開発端末のphpinfo()まるまるを貼り付けて、分析用コマンドボタンを押下せよ、との内容と解釈。\n\n④半信半疑ながら上記実施。コマンドボタンを押下。すると自分のphp\n7.0.28に適合するxdebugのdll(ver)が、リンク表示された。これを押下するとダウンロードすることができ、extフォルダへの配置、iniファイルへの記述方法、Webサーバの再起動が必要とまで記載されており、まさにこれどおり従うと、見事自分のphpinfo()へxdebugの文字が現れるようになった。\n\nご報告まで",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-26T00:25:11.210",
"id": "44271",
"last_activity_date": "2018-05-26T00:25:11.210",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25696",
"parent_id": "44226",
"post_type": "answer",
"score": 0
}
] | 44226 | 44271 | 44271 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Win7 64bitでChocolateyでAnacondaを入れようと思いますが以下のエラーメッセージですすみません。 \nググっても原因がよくわからないのでわかる方よろしくおねがいいたします。\n\n```\n\n ERROR: You must provide a value expression on the right-hand side of the '-' operator.\n \n```\n\nが原因だと思いますが… \n下に全文を載せておきます。\n\n```\n\n PS C:\\Users\\username> cinst anaconda3\n Chocolatey v0.10.11\n Installing the following packages:\n anaconda3\n By installing you accept licenses for the packages.\n Progress: Downloading anaconda3 5.1.0... 100%\n \n anaconda3 v5.1.0 [Approved]\n anaconda3 package files install completed. Performing other installation steps.\n The package anaconda3 wants to run 'chocolateyinstall.ps1'.\n Note: If you don't run this script, the installation will fail.\n Note: To confirm automatically next time, use '-y' or consider:\n choco feature enable -n allowGlobalConfirmation\n Do you want to run the script?([Y]es/[N]o/[P]rint): Y\n \n ERROR: You must provide a value expression on the right-hand side of the '-' operator.\n The install of anaconda3 was NOT successful.\n Error while running 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\tools\\chocolateyinstall.ps1'.\n See log for details.\n \n Chocolatey installed 0/1 packages. 1 packages failed.\n See the log for details (C:\\ProgramData\\chocolatey\\logs\\chocolatey.log).\n \n Failures\n - anaconda3 (exited -1) - Error while running 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\tools\\chocolateyinstall.ps1'.\n See log for details.\n \n```\n\n**追記**\n\nログが膨大なのでエラーメッセージ周辺のみ載せてみます。 \nどうぞよろしくお願いいたします。\n\n```\n\n 2018-05-25 10:11:07,959 6148 [DEBUG] - Running 'ChocolateyScriptRunner' for anaconda3 v5.1.0 with packageScript 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\tools\\chocolateyinstall.ps1', packageFolder:'C:\\ProgramData\\chocolatey\\lib\\anaconda3', installArguments: '', packageParameters: '',\n 2018-05-25 10:11:07,965 6148 [DEBUG] - Running 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\tools\\chocolateyinstall.ps1'\n 2018-05-25 10:11:07,981 6148 [ERROR] - ERROR: You must provide a value expression on the right-hand side of the '-' operator.\n 2018-05-25 10:11:08,000 6148 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\\ProgramData\\chocolatey\\helpers\\chocolateyInstaller.psm1'; & 'C:\\ProgramData\\chocolatey\\helpers\\chocolateyScriptRunner.ps1' -packageScript 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\tools\\chocolateyinstall.ps1' -installArguments '' -packageParameters '''] exited with '-1'.\n 2018-05-25 10:11:08,008 6148 [DEBUG] - Calling command ['\"C:\\Windows\\System32\\shutdown.exe\" /a']\n 2018-05-25 10:11:08,049 6148 [DEBUG] - Command ['\"C:\\Windows\\System32\\shutdown.exe\" /a'] exited with '1116'\n 2018-05-25 10:11:08,135 6148 [DEBUG] - Capturing package files in 'C:\\ProgramData\\chocolatey\\lib\\anaconda3'\n 2018-05-25 10:11:08,147 6148 [DEBUG] - Found 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\anaconda3.nupkg'\n with checksum 'F230502247BE21E8E569EDA965FFDA7D'\n 2018-05-25 10:11:08,155 6148 [DEBUG] - Found 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\anaconda3.nuspec'\n with checksum 'D1D9708F26914A1D4EA9E3856A5F4CE7'\n 2018-05-25 10:11:08,160 6148 [DEBUG] - Found 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\tools\\chocolateyinstall.ps1'\n with checksum 'A3B03B1A82D971030E2732C652F7B287'\n 2018-05-25 10:11:08,180 6148 [DEBUG] - Attempting to delete file \"C:\\ProgramData\\chocolatey\\.chocolatey\\anaconda3.5.1.0\\.arguments\".\n 2018-05-25 10:11:08,185 6148 [DEBUG] - Attempting to delete file \"C:\\ProgramData\\chocolatey\\.chocolatey\\anaconda3.5.1.0\\.extra\".\n 2018-05-25 10:11:08,190 6148 [DEBUG] - Attempting to delete file \"C:\\ProgramData\\chocolatey\\.chocolatey\\anaconda3.5.1.0\\.version\".\n 2018-05-25 10:11:08,195 6148 [DEBUG] - Attempting to delete file \"C:\\ProgramData\\chocolatey\\.chocolatey\\anaconda3.5.1.0\\.sxs\".\n 2018-05-25 10:11:08,201 6148 [DEBUG] - Attempting to delete file \"C:\\ProgramData\\chocolatey\\.chocolatey\\anaconda3.5.1.0\\.pin\".\n 2018-05-25 10:11:08,210 6148 [DEBUG] - Attempting to delete directory \"C:\\ProgramData\\chocolatey\\lib-bad\\anaconda3\".\n 2018-05-25 10:11:08,280 6148 [DEBUG] - Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...\n 2018-05-25 10:11:08,287 6148 [ERROR] - The install of anaconda3 was NOT successful.\n 2018-05-25 10:11:08,296 6148 [ERROR] - Error while running 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\tools\\chocolateyinstall.ps1'.\n See log for details.\n 2018-05-25 10:11:08,305 6148 [DEBUG] - Moving 'C:\\ProgramData\\chocolatey\\lib\\anaconda3'\n to 'C:\\ProgramData\\chocolatey\\lib-bad\\anaconda3'\n 2018-05-25 10:11:10,314 6148 [DEBUG] - Attempting to delete file \"C:\\Users\\username\\AppData\\Local\\NuGet\\Cache\\anaconda3.5.1.0.nupkg\".\n 2018-05-25 10:11:10,330 6148 [WARN ] - \n Chocolatey installed 0/1 packages. 1 packages failed.\n See the log for details (C:\\ProgramData\\chocolatey\\logs\\chocolatey.log).\n 2018-05-25 10:11:10,339 6148 [INFO ] - \n 2018-05-25 10:11:10,346 6148 [ERROR] - Failures\n 2018-05-25 10:11:10,354 6148 [ERROR] - - anaconda3 (exited -1) - Error while running 'C:\\ProgramData\\chocolatey\\lib\\anaconda3\\tools\\chocolateyinstall.ps1'.\n See log for details.\n 2018-05-25 10:11:10,363 6148 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...\n 2018-05-25 10:11:10,391 6148 [DEBUG] - Exiting with -1\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T13:06:40.497",
"favorite_count": 0,
"id": "44227",
"last_activity_date": "2018-05-26T09:13:31.183",
"last_edit_date": "2018-05-26T09:13:31.183",
"last_editor_user_id": "12457",
"owner_user_id": "12457",
"post_type": "question",
"score": 1,
"tags": [
"powershell",
"anaconda",
"chocolatey"
],
"title": "Chocolateyでインストールがうまくいきません: You must provide a value expression on the right-hand side of the '-' operator",
"view_count": 1546
} | [] | 44227 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "```\n\n def conv_encoder(x, weigths, biases):\n x = tf.reshape(x, shape=[-1, 28, 28, 1])\n conv1 = conv2d(x, weigths['ew1'], biases['eb1'])\n pool1 = max_pool2d(conv1) \n conv2 = conv2d(pool1, weigths['ew2'], biases['eb2'])\n pool2 = max_pool2d(conv2)\n \n return pool2\n \n def conv_decoder(x, weights, biases):\n deconv1 = deconv2d(x, weights['dw1'], biases['db1'], [batch_size, 14, 14, 32], strides=2)\n deconv2 = deconv2d(deconv1, weights['dw2'], biases['db2'], [batch_size, 28, 28, 16], strides=2)\n output = deconv2d(deconv2, weights['out'], biases['out'], [batch_size, 28, 28, 1], strides=1)\n \n return output\n \n ew_conv = {\n 'ew1': tf.Variable(tf.random_normal([5, 5, 1, 32])),\n 'ew2': tf.Variable(tf.random_normal([5, 5, 32, 64]))\n }\n \n dw_conv = {\n 'dw1': tf.Variable(tf.random_normal([5, 5, 32, 64])),\n 'dw2': tf.Variable(tf.random_normal([5, 5, 16, 32])),\n 'out': tf.Variable(tf.random_normal([5, 5, 1, 16]))\n \n }\n \n eb_conv = {\n 'eb1': tf.Variable(tf.random_normal([32])),\n 'eb2': tf.Variable(tf.random_normal([64]))\n }\n db_conv = {\n 'db1': tf.Variable(tf.random_normal([32])),\n 'db2': tf.Variable(tf.random_normal([16])),\n 'out': tf.Variable(tf.random_normal([1]))\n }\n \n```\n\n現在,こんな感じでエンコーダとデコーダの定義をして、下記の設定で学習させているのですが, \ndecoderのoutput.shapeが(batch_size, 28, 28, 784)ってなってしまいます。\n\noutputの行列[256, 28, 28, 1]の形でデータを格納したいです。 \nしかし,出力結果は,[256, 28, 28, 28^2]と最後の配列に全ての値が格納されています\n\n```\n\n x = tf.placeholder(tf.float32, shape=([None, num_input]))\n encode_op = conv_encoder(x, ew_conv, eb_conv)\n decode_op = conv_decoder(encode_op, dw_conv, db_conv)\n \n y_pred = decode_op\n y_true = x\n \n loss = tf.reduce_mean(tf.pow(y_pred - y_true, 2))\n optimizer = tf.train.RMSPropOptimizer(learning_rate).minimize(loss)\n \n init = tf.global_variables_initializer()\n with tf.Session() as sess:\n sess.run(init)\n \n for step in range(1, num_steps+1):\n batch_xs, batch_ys = mnist.train.next_batch(batch_size)\n \n _, l = sess.run([optimizer, loss], feed_dict={x:batch_xs})\n \n if step % display_steps == 0 or step == 1:\n print('Step %i: Minibatch Loss: %f'%(step, l))\n \n```\n\nちなみに、エラー理由は下記のようです。mnistのデータが最後のtensorに全て格納されてしまったため、メモリ容量突破したみたいです\n\n```\n\n OOM when allocating tensor of shape [256,28,28,784] and type float\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T14:34:58.323",
"favorite_count": 0,
"id": "44228",
"last_activity_date": "2018-05-24T15:27:25.167",
"last_edit_date": "2018-05-24T15:27:25.167",
"last_editor_user_id": "19110",
"owner_user_id": "28652",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3",
"tensorflow"
],
"title": "tensorflowで畳み込みAE作成中、出力データの形がおかしい",
"view_count": 119
} | [] | 44228 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Angularを3日勉強しているものです。 \nプログラミンの基礎知識はあります。\n\nAngular5系 + ngrxを利用したサンプルアプリケーションを作成しています。 \nその際、ngrx-json-apiというライブラリを利用するのですが \n使い方がよくわかりません。 \n<https://github.com/abdulhaq-e/ngrx-json-api>\n\ngithubに載っている情報を元にコードを書いているのですが、 \nブラウザ上ではメソッドがないとうエラーなどを吐いてしまいます。\n\nGetting Started以下を \n1-5までやったのですが以下の部分でエラーを吐いています。\n\n```\n\n let zone = this.ngrxJsonApiService.getZone(NGRX_JSON_API_DEFAULT_ZONE);\n // => getZoneが定義されていない。\n // this.ngrxJsonApiServiceにそのメソッドはあるはずです。importが間違っているのか?\n \n \n this.queryResult = this.selectManyResults(newQuery.queryId, denormalise);\n // => newQueryは初めて出てきているので、なぜ変数などの定義もなしにいきなり出てきているのか理解ができない。\n \n const query: Query = {\n queryId: 'myQuery',\n type: 'projects',\n // id: '12' => add to query single item\n params: {\n fields: ['name'],\n include: ['tasks'],\n page: {\n offset: 20,\n limit: 10\n },\n sorting: {\n { api: 'name', direction: Direction.ASC }\n },\n filtering: {\n { path: 'name', operator: 'EQ', value: 'John' }\n }\n } \n };\n // => 型のQueryは初めて出てきてますよね・・・理解ができない\n \n```\n\n* * *\n\nモジュールのimport周りや、ngrxの仕組みを理解できておらず \nライブラリを正しく扱えていないと予想しておりますが \nライブラリをインストールできていない、ライブラリの依存性の問題、などなど \n他にも原因としてあげられることはあります。\n\n実は早急にサンプルアプリケーションを作成しなければならない状況にあり \nangular, ngrxの理解もかいつまみながらやっております。 \nそのため、理解していない部分が多くあるかもしれません。 \n情報は随時追記していきます。\n\nどなたか知見ある方がいらっしゃいましたら \nご教授いただけると幸いです。 \nよろしくお願いいたします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T15:08:05.973",
"favorite_count": 0,
"id": "44229",
"last_activity_date": "2018-05-24T15:08:05.973",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15373",
"post_type": "question",
"score": 0,
"tags": [
"angularjs",
"redux",
"angular5"
],
"title": "ngrx-json-apiの使い方",
"view_count": 67
} | [] | 44229 | null | null |
{
"accepted_answer_id": "44232",
"answer_count": 1,
"body": "以下のようなコードを作りたいと思っています \n?の部分をどうすればいいのか詰まっています。\n\n```\n\n type Image interface {\n Resize(width, height uint) error\n }\n \n type Png {\n }\n \n func(Png) Resize(width, height uint) error {\n //略\n }\n \n func New() (Image, error) {\n if err := hoge(); err != nil {\n return ?, err\n }\n return &Png{}, nil\n }\n \n```\n\n実際にコードを書いていて詰まった際のプルリク \n<https://github.com/mafuyuk/imageresize/pull/1/files#diff-\nda07f373046a0a24e67b18699dc15a70R16>",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T15:32:00.323",
"favorite_count": 0,
"id": "44230",
"last_activity_date": "2018-05-24T16:00:59.887",
"last_edit_date": "2018-05-24T15:41:22.490",
"last_editor_user_id": "5981",
"owner_user_id": "5981",
"post_type": "question",
"score": 0,
"tags": [
"go"
],
"title": "GoでIntefaceの実装を返り値とする場合の実装できなかったパターンって何を返せばいいのでしょうか?",
"view_count": 47
} | [
{
"body": "単にエラー時の無意味な値を返したいのであれば、`nil` で良いように見えます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T16:00:59.887",
"id": "44232",
"last_activity_date": "2018-05-24T16:00:59.887",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "44230",
"post_type": "answer",
"score": 1
}
] | 44230 | 44232 | 44232 |
{
"accepted_answer_id": "44237",
"answer_count": 1,
"body": "デスクトップに以下の内容のapp.groovyというファイルを置いています。\n\n```\n\n @Grab(\"thymeleaf-spring4\")\n @Controller\n class App {\n \n @RequestMapping(\"/\")\n @ResponseBody\n def home(ModelAndView mav) {\n mav.setViewName(\"home\")\n mav\n }\n }\n \n```\n\n同じくデスクトップ上で「templates」というフォルダを用意し、その中にhome.htmlという以下の内容のhtmlファイルを用意しています。\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv=\"Content-type\"\n content\"text/html; charset=utf-8\" />\n <title>Index Page</title>\n <style>\n h1 { font-size:18pt; font-weight:bold; color:gray; }\n body { font-size:13pt; color:gray; margin:5px 25px; }\n </style>\n </head>\n <body>\n <h1>Hello!</h1>\n <p>this is sample web page.</p>\n </body>\n </html>\n \n```\n\nコマンドプロンプトで `run app.groovy`\nを打ったとき、想定ではtemplatesフォルダ配下のhome.htmlを読み込み、localhost:8080で表示できるはずでした。が、以下のエラーが出てしまっています。どうすればよいでしょうか。。 \nなお、app.groovyに単純にhello worldを書くだけであれば `run app.groovy`\nでlocalhost:8080で表示できます。また、使用しているパソコンにはeclipseやSTSが入っています。\n\nコマンドプロンプトのエラー内容\n\n```\n\n C:\\Users\\yoshi\\Desktop>spring run app.groovy\n Resolving dependencies......\n startup failed:\n General error during conversion: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)\n \n org.springframework.boot.cli.compiler.grape.DependencyResolutionFailedException: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)\n at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:311)\n at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.grab(AetherGrapeEngine.java:119)\n at groovy.grape.Grape.grab(Grape.java:167)\n at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:376)\n at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:346)\n at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:966)\n at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:626)\n at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602)\n at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579)\n at org.springframework.boot.cli.compiler.GroovyCompiler.compile(GroovyCompiler.java:207)\n at org.springframework.boot.cli.command.run.SpringApplicationRunner.compile(SpringApplicationRunner.java:129)\n at org.springframework.boot.cli.command.run.SpringApplicationRunner.compileAndRun(SpringApplicationRunner.java:101)\n at org.springframework.boot.cli.command.run.RunCommand$RunOptionHandler.run(RunCommand.java:111)\n at org.springframework.boot.cli.command.options.OptionHandler.run(OptionHandler.java:84)\n at org.springframework.boot.cli.command.OptionParsingCommand.run(OptionParsingCommand.java:54)\n at org.springframework.boot.cli.command.CommandRunner.run(CommandRunner.java:219)\n at org.springframework.boot.cli.command.CommandRunner.runAndHandleErrors(CommandRunner.java:171)\n at org.springframework.boot.cli.SpringCli.main(SpringCli.java:63)\n at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n at java.lang.reflect.Method.invoke(Method.java:498)\n at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)\n at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)\n at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)\n at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)\n Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)\n at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)\n at org.springframework.boot.cli.compiler.grape.AetherGrapeEngine.resolve(AetherGrapeEngine.java:306)\n ... 25 more\n Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)\n at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)\n at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)\n at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)\n ... 26 more\n Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact :thymeleaf-spring4:jar: in local (file:/C:/Users/yoshi/Desktop/repository)\n at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)\n at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)\n at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)\n at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)\n at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)\n at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)\n at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)\n ... 28 more\n \n 1 error\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-24T15:34:22.813",
"favorite_count": 0,
"id": "44231",
"last_activity_date": "2018-05-25T02:11:23.893",
"last_edit_date": "2018-05-24T18:05:09.437",
"last_editor_user_id": "19110",
"owner_user_id": "23122",
"post_type": "question",
"score": 1,
"tags": [
"java",
"eclipse",
"spring",
"groovy"
],
"title": "Spring Boot CLIでgroovyというファイルを実行しようとするが、templatesフォルダを読み込みに行かずうまくいかない",
"view_count": 703
} | [
{
"body": "app.groovyの次の行を\n\n```\n\n @Grab(\"thymeleaf-spring4\")\n \n```\n\n以下のように変更してみて下さい。\n\n```\n\n @Grab(\"thymeleaf-spring5\")\n \n```\n\n[このページ](https://docs.spring.io/spring-\nboot/docs/current/reference/htmlsingle/#appendix-dependency-\nversions)を見ると、`thymeleaf-spring4`はありません。\n\n[ドキュメント](https://docs.spring.io/spring-\nboot/docs/current/reference/htmlsingle/#cli-default-grab-deduced-\ncoordinates)には、以下のように注意書きが書いてあります。\n\n> The default metadata is tied to the version of the CLI that you use. it\n> changes only when you move to a new version of the CLI, putting you in\n> control of when the versions of your dependencies may change. A table\n> showing the dependencies and their versions that are included in the default\n> metadata can be found in the appendix.",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T02:11:23.893",
"id": "44237",
"last_activity_date": "2018-05-25T02:11:23.893",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "44231",
"post_type": "answer",
"score": 1
}
] | 44231 | 44237 | 44237 |
{
"accepted_answer_id": "44242",
"answer_count": 2,
"body": "ログ監視コマンドに「tail -F」を使用しており、これを「less」へ移行できないか考えております。\n\n現在は、ログファイルがローテートしても完全にエラーを監視したいため、このようにsh化しております。\n\n```\n\n tail -F log.log |grep 'Error\\|ERROR\\|エラー\\|異常'\n \n```\n\nまた、エラーが多発した際はtmuxの検索機能を利用しているので、検索も使いたいです。\n\nこれらの機能をlessへ落とし込み、最終的にsh化を目指すと以下の実現可能な問題と、そうではない問題が挙げられると思います。\n\n**実現可能**\n\n 1. 「tail -F 」でlogファイルを流すことができる\n 2. 検索機能はlessにあるのでtmuxに依存する必要はない\n 3. 「tail -F 」は「less --follow-name」でローテートに対応できる\n 4. 「|grep 'Error\\|ERROR\\|エラー\\|異常'」のような機能は「&」を入力したらできそう??\n\n**問題点**\n\n 1. 「|grep 'Error\\|ERROR\\|エラー\\|異常'」ができたとしても、lessを起動してから叩かなければならない?\n 2. 最終的にsh化することができない?\n\n「tail -F|grep」の運用でも良いのですが、最近は「less」の方が良いと聞いたので、実現可能かどうか教えていただいたいです。",
"comment_count": 11,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T02:05:30.403",
"favorite_count": 0,
"id": "44236",
"last_activity_date": "2018-05-25T07:33:52.713",
"last_edit_date": "2018-05-25T02:43:03.707",
"last_editor_user_id": "19110",
"owner_user_id": "28656",
"post_type": "question",
"score": 2,
"tags": [
"linux"
],
"title": "tail -F & grepをlessへ移行できるか",
"view_count": 1282
} | [
{
"body": "grep に `--line-buffred` オプションをつけてフィルタした結果を `less` で表示してはどうでしょう。\n\n`tail -F log.log | egrep --line-buffered -e 'Error|ERROR|エラー|異常' | less`",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T03:13:39.947",
"id": "44242",
"last_activity_date": "2018-05-25T03:13:39.947",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "44236",
"post_type": "answer",
"score": 0
},
{
"body": "コマンドの追加インストールは必要ですが、代替案を紹介しておきます。\n\n* * *\n\n**multitail**\nというコマンドがあり、本来の使い方としては「複数のファイルに対して同時に`tail`出来る」のがウリですが、もちろん単一のファイルに対しても実行可能です。\n\n<https://www.vanheusden.com/multitail/>\n\nその他の特徴として、正規表現を使ったフィルタリングやハイライトも可能です。\n\n```\n\n $ multitail --retry -e \"error|Error\" -f tail.log\n \n```\n\nオプションについては`--retry`が`tail -F`相当、`-e \"パターン\"`で正規表現にマッチした行のみ表示されます。\n\nコマンドのインストールはソースコードから行うか、メジャーなディストリビューションであればパッケージが用意されている場合もあるようです(CentOSならepel経由)。\n\n* * *\n\nなお、コメント欄で環境再構築時の懸念をされていますが、`tail`や`grep`をシステムに入れないのは個人的にあり得ないと思います。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T07:33:52.713",
"id": "44252",
"last_activity_date": "2018-05-25T07:33:52.713",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "44236",
"post_type": "answer",
"score": 1
}
] | 44236 | 44242 | 44252 |
{
"accepted_answer_id": "44243",
"answer_count": 1,
"body": "GitHubを利用するために以下ページを参考に、`.ssh` フォルダのパーミッションを変更したいのですが、変更できずに困っています。\n\n[今日からはじめるGitHub - Gitのインストールと準備](https://employment.en-\njapan.com/engineerhub/entry/2017/01/31/110000#Git%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%A8%E6%BA%96%E5%82%99)\n\n> 生成された秘密鍵のパーミッションを `600` に変更します。\n```\n\n> $ chmod 600 ~/.ssh/id_rsa_github\n> \n```\n\n>\n> 「`-rw-------`」になっていれば正しいパーミッションに変更できています。\n\nここで同様の操作を行ってもパーミッションが変更されません。 \n`-c` オプションを使用して確認したところ、変更できている旨が表示されますが、 \n実際には変更できていないという状態です。\n\n解決方法を教えていただきたく投稿させていただきます。 \nよろしくお願いいたします。\n\nなお、実行環境は Windows 10 になります。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T02:21:39.183",
"favorite_count": 0,
"id": "44239",
"last_activity_date": "2020-07-24T12:04:51.153",
"last_edit_date": "2020-07-24T12:04:51.153",
"last_editor_user_id": "3060",
"owner_user_id": "28657",
"post_type": "question",
"score": 0,
"tags": [
"windows",
"ssh",
"git-bash"
],
"title": "chmod で パーミッション の変更が出来ない",
"view_count": 26112
} | [
{
"body": "もしWindowsの **git bash**\nを使用している場合、NTFS/FAT32等のファイルシステム上では`chmod`でアクセス権を変更することはできません。 \n(一見`chmod -c`で変更されたように表示されるのは確かに紛らわしいですね)\n\nまた、参考にされたページの手順で実行している「秘密鍵のパーミッション変更」ですが、こちらはシステム上の他のユーザから不用意にファイルを参照されないようにするためのものです。 \nWindowsで`chmod`は実行できないと書きましたが、元々Windowsでは他のユーザアカウントのデータは(管理者権限が無い限り)見えないようアクセス制御されていますので、「秘密鍵のパーミッション変更」は実行しないままで大丈夫です。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T03:39:33.857",
"id": "44243",
"last_activity_date": "2018-05-25T03:39:33.857",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "44239",
"post_type": "answer",
"score": 4
}
] | 44239 | 44243 | 44243 |
{
"accepted_answer_id": "44267",
"answer_count": 1,
"body": "XSLTで基本となるXMLを読み込んでrootから処理を行っている最中に、別のXMLファイルを読み込んで処理を行うことは可能でしょうか?可能であれば方法を教えて下さい。\n\n例としては、 \n基本となるXMLのP要素を処理する際に、別のXMLファイルのP要素を参照するといった処理を想定しています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T04:10:07.620",
"favorite_count": 0,
"id": "44246",
"last_activity_date": "2018-05-25T15:44:37.567",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25399",
"post_type": "question",
"score": 1,
"tags": [
"xslt"
],
"title": "XSLTでXMLの処理中に別のXMLを読み込んで処理する方法",
"view_count": 184
} | [
{
"body": "XML ファイルを読み込みたいだけでしたら、このあたりでできます:\n\n * [`collection()`](http://www.w3.org/TR/xpath-functions-31/#func-collection)\n * [`doc()`](http://www.w3.org/TR/xpath-functions-31/#func-doc)\n * [`document()`](http://www.w3.org/TR/xslt-30/#func-document)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T15:44:37.567",
"id": "44267",
"last_activity_date": "2018-05-25T15:44:37.567",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27452",
"parent_id": "44246",
"post_type": "answer",
"score": 2
}
] | 44246 | 44267 | 44267 |
{
"accepted_answer_id": "44255",
"answer_count": 1,
"body": "keijoのアンダースコアの隣にyear2のインプットを。net_worthのアンダースコアの隣にyear1とyear2をいれたいのですがエラーがでて計算できません。 \nどうすれば、うまく計算できるでしょうか?\n\n```\n\n net_worth_1 = 308009\n net_worth_2 = 233488\n net_worth_3 = 315739\n \n keijo_pro_1 = 8000\n keijo_pro_2 = 9000\n keijo_pro_3 = 10000\n \n year1 = input(\"Enter first year:\")\n year2 = input(\"Enter end year:\")\n \n roa = keijo_year2 / ((net_worth_year1 + net_worth_year2) / 2)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T05:05:15.273",
"favorite_count": 0,
"id": "44249",
"last_activity_date": "2018-05-25T08:25:48.110",
"last_edit_date": "2018-05-25T05:56:51.270",
"last_editor_user_id": "3060",
"owner_user_id": "27722",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "python inputを変数に入力する方法",
"view_count": 1161
} | [
{
"body": "やりたいことは使用する変数を数値入力して選択することでしょうか。\n\n`input`で取得した文字列をそのまま変数名に書き換えることはできませんので、`eval`や`exec`を使って動的に変数名を生成する必要があります。\n\n```\n\n net_worth_1 = 308009\n net_worth_2 = 233488\n net_worth_3 = 315739\n \n keijo_pro_1 = 8000\n keijo_pro_2 = 9000\n keijo_pro_3 = 10000\n \n year1 = input(\"Enter first year:\") #例えば「1」を入力\n year2 = input(\"Enter end year:\") #例えば「2」を入力\n \n cmd = 'keijo_pro_{1} / ((net_worth_{0} + net_worth_{1}) / 2)'.format(year1, year2)\n # 上記の例の通り入力した場合、cmdは \"keijo_pro_2 / ((net_worth_1 + net_worth_2) / 2)\" となる\n roa = eval(cmd) #evalで動的に式を実行して計算後の値を取得する\n print(roa) #0.033241181391586654\n \n```\n\n動的に式を変換して実行するよりも、リストを使う方が可読性が高く、後で機能変更することも容易になりますので、下記のように書き換えることをお勧めします。\n\n```\n\n net_worth = {} #1から始まるので辞書{}を使っていますが、0から始めるなら配列[]でも良いです\n net_worth['1'] = 308009\n net_worth['2'] = 233488\n net_worth['3'] = 315739\n keijo_pro = {'1':8000, '2':9000, '3':10000}\n \n year1 = input(\"Enter first year:\") #例えば「1」を入力\n year2 = input(\"Enter end year:\") #例えば「2」を入力\n \n roa = keijo_pro[year2] / ((net_worth[year1] + net_worth[year2]) / 2)\n print(roa) #0.033241181391586654\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T08:25:48.110",
"id": "44255",
"last_activity_date": "2018-05-25T08:25:48.110",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "44249",
"post_type": "answer",
"score": 2
}
] | 44249 | 44255 | 44255 |
{
"accepted_answer_id": "44320",
"answer_count": 1,
"body": "タイトル通りなのですが、デプロイしたアプリをブラウザ上からデータを登録する際に日本語の入力ができなってWe're sorry, but something\nwent wrong.のエラーページになってしまいます。英語ですと普通に登録ができます。\n\nやったことはaws(EC2)でRDSのパラメーターグループの確認とターミナルで直接mysqlに接続して確認し訂正しました。\n\n↓ターミナルでmysql接続した際の画面\n\n```\n\n | Variable_name | Value \n |\n +--------------------------+------------------------------------------- \n +\n | character_set_client | utf8 \n |\n | character_set_connection | utf8 \n |\n | character_set_database | utf8 \n |\n | character_set_filesystem | binary \n |\n | character_set_results | utf8 \n |\n | character_set_server | utf8 \n |\n | character_set_system | utf8 \n |\n | character_sets_dir | /rdsdbbin/mysql-5.6.39.R1/share/charsets/ \n |\n \n```\n\ndatabase.yml\n\n```\n\n default: &default\n adapter: mysql2\n pool: <%= ENV.fetch(\"RAILS_MAX_THREADS\") { 5 } %>\n username: root\n password: 11223344\n database: portfolio_production\n encoding: utf8\n \n development:\n <<: *default\n database: portfolio_production\n \n test:\n <<: *default\n database: portfolio_production\n \n production:\n <<: *default\n adapter: mysql2\n encoding: utf8\n database: portfolio_production\n username: root\n password: 11223344\n host: portfolio-mysql.cxputm26p9ho.ap-northeast-1.rds.amazonaws.com\n port: 3306\n \n```\n\n↓日本語入力した際のエラーログ\n\n```\n\n D, [2018-05-25T07:06:01.042200 #3172] DEBUG -- : [40b88ae2-9446- \n 4191-95e7-a1cdb3c3ca04] SQL (3.0ms) INSERT INTO `categories` \n (`c_name`, `created_at`, `updated_at`) VALUES ('あ', '2018-05-25 \n 07:06:01', '2018-05-25 07:06:01')\n D, [2018-05-25T07:06:01.045021 #3172] DEBUG -- : [40b88ae2-9446-4191- \n 95e7-a1cdb3c3ca04] (2.7ms) ROLLBACK\n I, [2018-05-25T07:06:01.045197 #3172] INFO -- : [40b88ae2-9446-4191- \n 95e7-a1cdb3c3ca04] Completed 500 Internal Server Error in 18ms \n (ActiveRecord: 12.5ms)\n F, [2018-05-25T07:06:01.046044 #3172] FATAL -- : [40b88ae2-9446-4191- \n 95e7-a1cdb3c3ca04] \n F, [2018-05-25T07:06:01.046087 #3172] FATAL -- : [40b88ae2-9446-4191- \n 95e7-a1cdb3c3ca04] ActiveRecord::StatementInvalid (Mysql2::Error: \n Incorrect string value: '\\xE3\\x81\\x82' for column 'c_name' at row 1: \n INSERT INTO `categories` (`c_name`, `created_at`, `updated_at`) VALUES \n ('あ', '2018-05-25 07:06:01', '2018-05-25 07:06:01')):\n F, [2018-05-25T07:06:01.046139 #3172] FATAL -- : [40b88ae2-9446-4191- \n 95e7-a1cdb3c3ca04] \n F, [2018-05-25T07:06:01.046161 #3172] FATAL -- : [40b88ae2-9446-4191- \n 95e7-a1cdb3c3ca04] app/controllers/categories_controller.rb:19:in \n `block in create'\n [40b88ae2-9446-4191-95e7-a1cdb3c3ca04] \n app/controllers/categories_controller.rb:18:in `create' \n \n```\n\nschema\n\n```\n\n +------------+--------------+------+-----+---------+----------------+\n | Field | Type | Null | Key | Default | Extra |\n +------------+--------------+------+-----+---------+----------------+\n | id | bigint(20) | NO | PRI | NULL | auto_increment |\n | c_name | varchar(255) | YES | | NULL | |\n | created_at | datetime | NO | | NULL | |\n | updated_at | datetime | NO | | NULL | |\n +------------+--------------+------+-----+---------+----------------+\n \n```\n\n以上なのですが他にどうしたらよいのかわからず困っています。もし何かお気付きのところなどございましたら教えていただきたいです。宜しくお願いしますm(._.)m",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T06:52:48.390",
"favorite_count": 0,
"id": "44251",
"last_activity_date": "2018-05-28T06:10:41.317",
"last_edit_date": "2018-05-28T05:59:06.867",
"last_editor_user_id": "27359",
"owner_user_id": "27359",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"aws",
"デプロイ"
],
"title": "デプロイしたアプリで日本語が使えないエラー",
"view_count": 178
} | [
{
"body": "自己解決できました!! \nおかしな点が見つからなかったのですが、エラーログからDB関連なのかな?と思い色々調べていたらDB全体ではなくて、テーブル指定して文字設定できるみたいなので使っているテーブル全てにutf8を当てまして、インスタンス再起動したらうまくいきました!\n\nターミナルでmysqlに接続してmysqlのコマンド以下入力です。\n\nALTER TABLE テーブル名 CONVERT TO CHARACTER SET UTF8;\n\n大文字じゃないといけないのかはわかりませんが、テーブル名のところは自分のテーブル名通り小文字で入力しました。\n\n以上です。ありがとうございましたm(._.)m",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T06:10:41.317",
"id": "44320",
"last_activity_date": "2018-05-28T06:10:41.317",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27359",
"parent_id": "44251",
"post_type": "answer",
"score": 1
}
] | 44251 | 44320 | 44320 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "## 前提・実現したいこと\n\n自社プロダクトで人力で行っているシナリオテストの工数・負荷を削減したく \nSelenium×Node.jsでテスト自動化を行おうとしていますが、調査の段階で詰まってしまっています。。。\n\n## 環境\n\n * Mac OS10.12.6\n * Node 8.11.1\n * Selenium Server 3.12.0\n * Selenium WebDriver 4.0.0\n * ChromeDriver 2.38\n\n## やったこと\n\n**1\\. Node.js のインストール**\n\n[公式サイトから](https://nodejs.org/en/)\n\n**2\\. selenium-webdriverのインストール**\n\nnpm経由でインストール\n\n```\n\n $ npm install selenium-webdriver\n \n```\n\n**3\\. selenium-serverのインストール**\n\nHomebrew経由でインストール\n\n**4\\. Chromeドライバのインストール**\n\n[ChromeDriver - WebDriver for\nChrome](https://sites.google.com/a/chromium.org/chromedriver/)\n\n→ドライバをダウンロードしたらファイルを移動\n\n```\n\n $ mv /Users/username/Downloads/chromedriver ./\n $ ls -la\n total 31920 \n drwxr-xr-x 7 username staff 238 5 24 17:42 . \n drwxr-xr-x+ 55 username staff 1870 5 24 17:42 .. \n -rwxr-xr-x@ 1 username staff 11917200 4 20 16:39 chromedriver \n drwxr-xr-x 41 username staff 1394 5 24 16:45 node_modules \n -rw-r--r-- 1 username staff 9367 5 24 16:45 package-lock.json\n \n```\n\n**5\\. Selenium Server の起動**\n\nバックグラウンドで起動\n\n```\n\n $ selenium-server -port 4444 &\n [1] 33415\n C02SY1XFGTFJ:selenium username$ 18:04:14.512 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.11.0', revision: 'e59cfb3'\n 18:04:14.513 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444\n 2018-05-24 18:04:14.624:INFO::main: Logging initialized @441ms to org.seleniumhq.jetty9.util.log.StdErrLog\n 18:04:14.882 INFO [SeleniumServer.boot] - Welcome to Selenium for Workgroups....\n 18:04:14.882 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444\n \n```\n\n## 発生している問題・エラーメッセージ\n\nサンプルとなるテストコードを書きます。\n\n```\n\n $ vim sample.js\n \n // WebDriver の初期化\n const webdriver = require('selenium-webdriver');\n // ブラウザの選択\n const browser = new webdriver.Builder().forBrowser('chrome').build();\n \n // ページタイトルの取得\n browser.get('http://example.selenium.jp/reserveApp/').then(()=>{\n browser.getTitle().then(title => console.log('ページタイトル:',title))\n });\n \n // ブラウザの終了\n browser.close();\n browser.quit();\n \n```\n\n上記コードを実行させると、、、\n\n```\n\n $ node sample.js \n (node:13216) UnhandledPromiseRejectionWarning: NoSuchSessionError: no such session\n (Driver info: chromedriver=2.38.552518 (183d19265345f54ce39cbb94cf81ba5f15905011),platform=Mac OS X 10.12.6 x86_64)\n at Object.checkLegacyResponse (/Users/ko-kamenashi/selenium/node_modules/selenium-webdriver/lib/error.js:585:15)\n at parseHttpResponse (/Users/ko-kamenashi/selenium/node_modules/selenium-webdriver/lib/http.js:533:13)\n at Executor.execute (/Users/ko-kamenashi/selenium/node_modules/selenium-webdriver/lib/http.js:468:26)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:188:7)\n (node:13216) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)\n (node:13216) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.\n \n```\n\nとエラーになります。 \nエラーメッセージ「NoSuchSessionError: no such session」等でググると記事は出てくるのですが、 \n本事象の解決とは至っていません。\n\n## 以上です\n\nお手数ですが皆様のお知恵を拝借できれば幸いです。宜しくお願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T08:25:28.350",
"favorite_count": 0,
"id": "44254",
"last_activity_date": "2018-05-25T08:25:28.350",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13771",
"post_type": "question",
"score": 1,
"tags": [
"node.js",
"google-chrome",
"selenium"
],
"title": "Selenium×Node.jsでテスト実行すると「NoSuchSessionError: no such session」となりうまくいかない",
"view_count": 434
} | [] | 44254 | null | null |
{
"accepted_answer_id": "44358",
"answer_count": 2,
"body": "`c++`で複数あるキャストの違いを教えてください。 \nどちらも使える場合はどちらを選べばいいかわかまりません。\n\n```\n\n static_cast<const char*>(x); // 静的キャスト(静的な普通の型変換を行うキャスト) \n (const char*)x; // キャスト的記法 () \n const char*(x); // 関数的記法\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T11:20:05.047",
"favorite_count": 0,
"id": "44260",
"last_activity_date": "2018-06-04T05:23:52.757",
"last_edit_date": "2018-05-25T17:49:08.937",
"last_editor_user_id": "3060",
"owner_user_id": null,
"post_type": "question",
"score": 9,
"tags": [
"c++"
],
"title": "複数あるキャスト記法をどのように使い分ければいいか教えてください",
"view_count": 5201
} | [
{
"body": "原則としては `static_cast` を使ってください。\n\nキャストにはいくつかの種類があって、何の問題もない安全なものも、正しく使えば安全なものも、何も保証されないものもあります。 しかし `(const\nchar*)` という記法は区別なくキャストしてしまうのです。 (関数風の書き方でも効果は同じです。)\n\n`static_cast` は `static_cast` の要件を満たす変換のみしか許されません。 そして `static_cast`\nが許す変換は比較的安全なものに限られています。 もしうっかり危険な変換をしようとしてしまったらエラーになってくれるので安心です。\n\n逆に、危険なキャストは危険なキャストとしてそれぞれの性質に応じて `dynamic_cast`, `const_cast`,\n`reinterpret_cast` を使い分けるべきです。 古いスタイルのキャストは C\nとの互換性のために残されていますが、どのような意図をもってキャストしているのか読み取り難く、バグの原因になりやすいので原則として避けるのが望ましいと考えられています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T14:14:29.547",
"id": "44263",
"last_activity_date": "2018-05-25T14:14:29.547",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3364",
"parent_id": "44260",
"post_type": "answer",
"score": 8
},
{
"body": "[c++](/questions/tagged/c%2b%2b \"'c++' のタグが付いた質問を表示\") ソースでも\n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") ソースでも共通に使うヘッダファイル等ではしかたないので\nc-style キャスト `(type)value` を使う必要があります。ですが [c++](/questions/tagged/c%2b%2b\n\"'c++' のタグが付いた質問を表示\") 限定の場合は常に [c++](/questions/tagged/c%2b%2b \"'c++'\nのタグが付いた質問を表示\") で新設されたキャストを使うようにするとソースコード自体にプログラマの意図を表現できて幸せになれます。\n\n言語仕様書的な厳密話はちょっとおいておいて実用上の話をすると\n\n * static_cast \n\n値を、違う型の「意味的に同じ」(内部表現が異なる)値にします。例えば \n`1` (`int` 型) `1L` (`long` 型) `1.0f` (`float` 型) `1.0` (`double` 型)\nは意味的には同じ数値ですが、コンピュータの中での内部表現は異なることが普通です。この種の変換には `static_cast`\nを使うと良いとされています。一般に安全な型変換です。\n\n```\n\n double average(int x, int y) {\n return (static_cast<double>(x) + static_cast<double>(y))/2.0;\n }\n \n```\n\n`static_cast` は型変換コンストラクタの起動であると知っている人は次のように書くかもしれません。特に `class`\n型に変換したい場合にはこっちの方が自然かも。\n\n```\n\n return (double(x)+double(y))/2.0;\n \n```\n\nオイラも今回調べていて初めて知ったのですが、この形式を関数型キャストとか関数スタイルキャストとか言う場合があるらしいです。少なくともオイラが\n[c++03](/questions/tagged/c%2b%2b03 \"'c++03' のタグが付いた質問を表示\")\n言語仕様書を読んだ範囲でそのような文言を見たことはありませんのでどこかの方言なのかもしれません。\n\n<https://www.ibm.com/support/knowledgecenter/ja/ssw_ibm_i_71/rzarg/cast_operator.htm>\n\n[c++03](/questions/tagged/c%2b%2b03 \"'c++03' のタグが付いた質問を表示\")\n仕様書的にはこれはあくまで一時オブジェクトを型変換コンストラクタを用いて直接初期化すると解釈されます。\n\n```\n\n double d=double(0); // OK コンストラクタの呼び出し(組み込み型でも可能)\n char* p=char *(0); // NG コンストラクタの呼び出しと解釈できない\n typedef void* vp_type; // 単純型指定子→括弧で囲まれた式並び、ならよいので\n vp_type q=vp_type(0); // typedef でつけた別名でも OK\n \n```\n\n(add) \nもう少し精読してみたところ 5.2 後置式の 5.2.3 明示的型変換(関数的記法) というのがあるのであながち方言でもないのでしょう。 5.2.3\nによると引数が1つのときはキャストと同等で、2つ以上の場合は適切なコンストラクタのあるクラスであって後略とあります。引数の数に関係なく既に書いたとおり一時オブジェクトの構築です。\n\n * reinterpret_cast\n\n値の内部表現を維持したまま、違う型と解釈します。型変換でなく型解釈変更というか、そういう場合に限定して使います。どういうことかというと、例えば組み込み系とかでよくあるのですが\n\nメモリ上 `0x00101280` 番地には周辺回路Aのレジスタがあって、この番地をアクセスすると回路Aを働かせることができる、といった場合に\n`*reinterpret_cast<volatile uint16_t*>(0x00101280)` などと記述します。長ったらしいので\n`#define` 等で別名をつけたりすることが多いです。\n\n```\n\n #define A_REG *reinterpret_cast<volatile uint16_t*>(0x00101280)\n \n```\n\nすると `A_REG=0x1234;` なり `uint16_t rxd=A_REG;` と書けて、これで周辺回路をアクセスすることができます。\n\nこの例では一つの値 `0x00101280`\nがあって、型解釈だけを整数型からポインタ型に変更していることになります。組み込み系以外で現れる例では無関係な(派生関係になくて互いに独立した、と言う意味)型\n`a_type` と `b_type` があるとき `a_type*` を `b_type*`\nに型解釈を変更することでしょう。このような変換は一般的にはできない危険な行為です。 `reinterpret_cast`\nを明示するということは、プログラマが(今のこの処理系においては)それができることを熟知していて、結果に責任を負う、というソースコード上の意思表明と読むことができます。\n\n * const_cast\n\nポインタまたは参照の cv-ness 脱着の目的にのみ使います。 `const`\nを追加する側は普通は安全であり、暗黙変換で可能なので明示しないことが多いです。 `const_cast` を書くことは、プログラマが constness\nを除去する(および引き続き非 const アクセスを行っている)つまり危険な行為をしているが、承知の上であることを明示する目的につかわれます。\n\n※オブジェクト自体の constness の脱着はできません。 \n※もともと `const` なオブジェクトを非 `const` アクセスするとバグるので注意が必要です。\n\n```\n\n void badexample(const int* p) {\n // ポインタの const を除去している\n *const_cast<int*>(p)=0;\n }\n void test() {\n int a;\n badexample(&a); // 文法上は妥当(良いコードとはいえないが)\n const int b= -1;\n badexample(&b); // 不当アクセス\n }\n \n```\n\nc-style キャスト `(type)value`\nは、ここまでの3つの機能を全て区別しないで行うので、プログラマの意思表明「危険なことは承知の上でやっている」と読めません。\n[c++](/questions/tagged/c%2b%2b \"'c++' のタグが付いた質問を表示\") では使わない方向で行きたいところです。\n\n* * *\n\n * dynamic_cast\n\nソースコード上は型変換に見えますが、実際は実行時の「動的型判別」です。 c-style キャストでは `dynamic_cast`\nと同じことができません。詳細解説は略。ライブラリやフレームワークの都合で使う場合はしかたないところがあります。ですが 100% 自作しているコード内で\n`dynamic_cast` を使う羽目になったら、設計か実装かどこかに瑕疵があります。 `dynamic_cast`\nを書く必要が生じたらリファクタリングしましょう。\n\n* * *\n\n`static_cast` と `reinterpret_cast`\nの振る舞いが異なる別例を挙げておきます。実行する前にどうなるのか脳内で検討してみましょう(結果および解説略)。\n\n```\n\n #include <iostream>\n struct a { virtual ~a() { } };\n struct b { virtual ~b() { } };\n struct d : a, b { };\n int main() {\n d x;\n std::cout << static_cast<a*>(&x) << std::endl;\n std::cout << static_cast<b*>(&x) << std::endl;\n std::cout << reinterpret_cast<a*>(&x) << std::endl;\n std::cout << reinterpret_cast<b*>(&x) << std::endl;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-29T07:23:02.697",
"id": "44358",
"last_activity_date": "2018-06-04T05:23:52.757",
"last_edit_date": "2018-06-04T05:23:52.757",
"last_editor_user_id": "8589",
"owner_user_id": "8589",
"parent_id": "44260",
"post_type": "answer",
"score": 9
}
] | 44260 | 44358 | 44358 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "サーブレット側\n\n```\n\n public class data{\n private String id;\n private String name;\n \n public data(String id, String name){\n this.id = id;\n this.name = name;\n } //コンストラクタ\n \n \n ArrayList<Object> list = new ArrayList<>();\n list.add(new data(\"1\",\"aiueo\"));\n list.add(new data(\"2\",\"kakikukeko\"));\n list.add(new data(\"3\",\"sasisuseso\"));\n session.put(\"data\",data);\n \n```\n\n```\n\n //jsp側\n <s:property value=\"session.data\" /> //取得できない。\n \n <s:property value=\"session.data\" >\n <s:property value=\"id\" />\n <s:property value=\"name\" />\n </s:property> //これもエラーが起きる\n \n```\n\n`<s:property >` タグを使い取得の仕方を教えてください",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T13:15:09.363",
"favorite_count": 0,
"id": "44261",
"last_activity_date": "2022-06-05T06:03:05.327",
"last_edit_date": "2018-05-25T14:43:01.193",
"last_editor_user_id": "19110",
"owner_user_id": "28615",
"post_type": "question",
"score": 0,
"tags": [
"jsp"
],
"title": "sessionに入れられた配列の中身をすべて取得したい",
"view_count": 1463
} | [
{
"body": "EL式で記述したいものと予想します。そうであれば、\n\n```\n\n <s:property value=\"${session.data}\" />\n \n```\n\nあるいは、`session`を省略して単に\n\n```\n\n <s:property value=\"${data}\" />\n \n```\n\nでどうでしょうか?\n\n#なお、この方法だと`ArrayList.toString()`と同じ結果になります。 \nですので、クラス`data`のメソッド`toString`をオーバーライドして、メンバ変数の値を文字列化する必要があります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T11:30:23.143",
"id": "44297",
"last_activity_date": "2018-05-27T11:30:23.143",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20098",
"parent_id": "44261",
"post_type": "answer",
"score": 1
}
] | 44261 | null | 44297 |
{
"accepted_answer_id": "44265",
"answer_count": 1,
"body": "Python初心者です。以下は参考書「独学プログラマー(コーリ・アリソフ著)」に記載されているWarというカードゲームのプログラムの一部です。その部分でわからないところがあるので質問させていただきます。\n\n```\n\n class Card:\n suits = [\"spades\", \"hearts\", \"diamonds\", \"clubs\"]\n \n values = [None, None, \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\",\n \"10\", \"Jack\", \"Queen\", \"King\", \"Ace\"]\n \n def __init__(self, v, s):\n \"\"\"スートも値も整数値です。\"\"\"\n self.value = v\n self.suit = s\n \n def __lt__(self, c2):\n if self.value < c2.value:\n return True\n \n if self.value == c2.value:\n if self.suit < c2.suit:\n return True\n else:\n return False\n \n return False\n \n```\n\n### 質問\n\n`def __lt__(self.\nc2)`の部分で`c2.value`や`c2.suit`というところがありますが。何の値が入っている変数なのかよくわかりません。どなたかよろしくお願いします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T14:11:39.640",
"favorite_count": 0,
"id": "44262",
"last_activity_date": "2018-05-25T15:06:31.310",
"last_edit_date": "2018-05-25T15:06:31.310",
"last_editor_user_id": "19110",
"owner_user_id": "28645",
"post_type": "question",
"score": 4,
"tags": [
"python"
],
"title": "クラスの関数で、self 以外の変数が何なのか分からない",
"view_count": 320
} | [
{
"body": "Python ではクラスに `__lt__` という名前のメソッドを定義することで、クラスのインスタンス同士を不等号 `<`\n等で比較できるようになります。メソッド `__lt__` には 2 つの引数が渡されることになりますが、一方が自分で、他方が比較される相手です。\n\n今回の `__lt__` にも 2 つの引数 `self` と `c2` があり、どちらも `Card`\nクラスのインスタンスであることが期待されています。第一引数の `self` は自分自身であり、第二引数の `c2` は比較相手です。ですから\n`c2.value` や `c2.suit` というのは、比較相手の番号やスートのことを指しています。\n\n試しに `Card` クラスのインスタンスを作って比較してみると分かりやすいです。\n\n```\n\n >>> c1 = Card(4, 1)\n >>> c2 = Card(5, 2)\n >>> c1 < c2\n True\n \n```\n\nより詳しくは、Python 3 の公式ドキュメントにおける [`object.__lt__(self, other)`\nの説明](https://docs.python.jp/3/reference/datamodel.html#object.__lt__)が参考になります。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T14:36:34.887",
"id": "44265",
"last_activity_date": "2018-05-25T14:36:34.887",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "44262",
"post_type": "answer",
"score": 5
}
] | 44262 | 44265 | 44265 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Rails アプリで GitHub から `git clone` をした後に、 `bundle exec rake db:create`\nを実行したら以下のエラーが発生しました。\n\n> Mysql2::Error::ConnectionError: Access denied for user 'takeshi'@'localhost'\n> (using password: YES)\n\n`config/database.yml` の内容:\n\n```\n\n default: &default\n adapter: mysql2\n encoding: utf8\n port: 3306\n pool: 5\n timeout: 5000\n url: <%= ENV['DATABASE_URL'] %>\n password: password\n \n```\n\n原因がわからずに困っております。 \nどうすれば、 `bundle exec rake db:create` を実行することができるでしょうか? \nアドバイスの程、宜しくお願いいたします。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T14:14:37.010",
"favorite_count": 0,
"id": "44264",
"last_activity_date": "2019-05-04T22:07:51.243",
"last_edit_date": "2019-05-04T22:07:51.243",
"last_editor_user_id": "32986",
"owner_user_id": "12323",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"mysql"
],
"title": "RailsのアプリでMysql2::Error::ConnectionError: Access denied for user 'takeshi'@'localhost' (using password: YES)、が発生してbundle exec rake db:createが実行できません。",
"view_count": 1269
} | [] | 44264 | null | null |
{
"accepted_answer_id": "44268",
"answer_count": 1,
"body": "私は現在関数で複数の変数を宣言しようとしています. \nその際に変数名を関数実装時に決め打ちで宣言することは後のことを考えると非常に良くないと思い工夫をしようと試みています. \nそこで、関数の引数を宣言する変数名を含ませることで解決できると考えました.しかし引数を変数内に用いる方法がわかりません. \nどうかお力添えをお願いしたく思います.\n\nやりたいことの例:\n\n```\n\n def new_variable(string_A, string_B):\n string_A + '_' + string_B = None #問題となっているところ\n \n```\n\nといったようにA_Bのような変数を宣言したいと考えています.\n\n調べましたところexacなどでは関数内でのみ有効なため呼び出した側には返せないようですが、関数内でPandasのDataFrameなどに追加してDataFrameを返すつもりですのでその辺りは問題ないと思われます.\n\n・追記 \n動的に変数を作りたい理由としてはPandasのDataFrame中のX列の値に'hoge'が含まれているならばX_hoge列を生成し含まれていた行を1としたためです. \n実際のコードで示させていただきますと\n\n```\n\n def new_columns(df, col, searchVal): #df=DataFrame,col=列名,searchVal=含まれているか調べたい文字列\n count = 0\n df.assign(col_searchVal : np.nan) #今回問題となっている箇所\n df[col_searchVal] = np.nan #もう一つの案\n for val in df[col]:\n if searchVal in val: #調べたい文字列が含まれていたならば\n df[col_searchVal][count] = 1\n count =+ 1\n df.drop(col, axis=1)\n return df\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T14:57:55.927",
"favorite_count": 0,
"id": "44266",
"last_activity_date": "2018-05-25T16:55:36.000",
"last_edit_date": "2018-05-25T16:00:54.880",
"last_editor_user_id": "28490",
"owner_user_id": "28490",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3",
"pandas"
],
"title": "Pythonにおける変数宣言時に異なる変数を用いる方法",
"view_count": 706
} | [
{
"body": "今回の用途のために変数を動的に作る必要はありません。\n\nたとえば [`df.apply()`](https://pandas.pydata.org/pandas-\ndocs/stable/generated/pandas.DataFrame.apply.html) 関数を使って以下のように書けます。\n\n```\n\n def new_columns(df, col, searchVal):\n name = str(col) + '_' + str(searchVal)\n df[name] = df.apply(lambda row: 1.0 if row[col] == searchVal else np.nan, axis=1)\n \n```\n\n`axis=1` があるため、それぞれの row について apply されていることに注意してください。\n\n以下、動作例です。\n\n```\n\n >>> # サンプルの Dataframe です\n ... df = pd.DataFrame({'a': [3, 1, 4, 1, 5],\n ... 'b': ['x', 'y', 'x', 'x', 'y']})\n >>> new_columns(df, 'a', 1)\n >>> df\n a b a_1\n 0 3 x NaN\n 1 1 y 1.0\n 2 4 x NaN\n 3 1 x 1.0\n 4 5 y NaN\n >>> new_columns(df, 'b', 'y')\n >>> df\n a b a_1 b_y\n 0 3 x NaN NaN\n 1 1 y 1.0 1.0\n 2 4 x NaN NaN\n 3 1 x 1.0 NaN\n 4 5 y NaN 1.0\n >>> \n \n```\n\nこちらの Q&A も参考になります: [\"pandas create new column based on values from other\ncolumns\"](https://stackoverflow.com/q/26886653/5989200) \\-- Stack Overflow\n\n## 別の方法\n\nもとの column が無くなってもよいのであれば、`searchVal` と等しいかどうかで二値化したあとに column\nの名前を変える方法もあります。用途によっては名前の付け替えは不要かもしれません。\n\n```\n\n def new_columns(df, col, searchVal):\n df[col] = (df[col] == searchVal).astype(int)\n newname = str(col) + '_' + str(searchVal)\n return df.rename(index=str, columns={col: newname})\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T16:26:16.983",
"id": "44268",
"last_activity_date": "2018-05-25T16:55:36.000",
"last_edit_date": "2018-05-25T16:55:36.000",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "44266",
"post_type": "answer",
"score": 0
}
] | 44266 | 44268 | 44268 |
{
"accepted_answer_id": "44282",
"answer_count": 1,
"body": "DockerでECSを使ってWebサービスの環境構築を行おうと考えています。 \nただDockerの中のOSを何にすれば良いかわからず困っています。\n\nと言いますのも、Dockerの一般的な構築はサービス毎にDockerを個別に立てるのが一般的と聞きました。 \nそうなるとまずDockerをまとめるDockerがおり、その中に役割毎のDocker(サーバ、DB...)を立てるのかと想像しました。 \nだとすると役割毎に立てるDockerのOSを一般的なLinuxOS(CentOSなど)にしてしまうと、OSの容量だけでもかなり増えてしまいそうです。 \nその問題を解決するためにCoreOSというOSが存在することを知りました。\n\nそうなると疑問点があります。 \nこのDockerをまとめるDockerもCoreOSにするべきなんでしょうか? \nまた今まで自分が書いた想定は一般的なのでしょうか?\n\nご回答いただけると助かります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-25T16:46:22.743",
"favorite_count": 0,
"id": "44269",
"last_activity_date": "2018-05-27T03:02:13.520",
"last_edit_date": "2018-05-25T16:57:57.223",
"last_editor_user_id": "15186",
"owner_user_id": "15186",
"post_type": "question",
"score": 1,
"tags": [
"docker"
],
"title": "Dockerの構成とそれに伴うOSの選定に関する質問",
"view_count": 99
} | [
{
"body": "おそらくですが、質問者様は、いわゆるマイクロサービスアーキテクチャを docker\nで実装する話をしているのだと思います。さらには、あるフロントエンド用のサービス(html\nのレンダリングなどは、ここでやる想定)があって、そのサービスがバックエンドサービスと通信を行い、ウェブアプリケーションとして動作させる形態を想像しているのだと思います。\n\nまたその際に、バックエンドの docker は、フロントエンドのサーバー (docker) の中で立ち上げることも想定しているのかなと思っています。\n\n仮にそうだったとした場合、一つ重要な点は、\nフロント用サービスと、バックエンドのサービスは、基本的に独立したサーバーとして運用する構成にするのが通常である、という点です。\n\ndocker でフロントとバックエンドのサーバーを分けた場合、それらは同じ階層の docker として運用し、一方(フロント) がもう一方(バックエンド)\nに通信を行いに行く、という構成になると思います。\n\nわかりやすいのは、 docker-compose にバックエンドとフロントエンド、それらをつなぐポート情報を記述するようなイメージでしょうか。\n\nこういった構成をとった場合、フロントとバックエンドのベースイメージは、基本的になんでもいいはずです。重要なのは、コンテナの expose\nしているポートに通信すると、正しく期待した動作をコンテナがしてくれることです。\n\nさらに注釈を加えると、 docker の中で docker を使うのは、やめたほうがいいと思います。docker の unix socket\nをコンテナの中に埋め込むような方法などで、コンテナの中からでも docker\nを使えるように設定できなくはないですが、マウントの解決がやたら面倒になった記憶があります。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T03:02:13.520",
"id": "44282",
"last_activity_date": "2018-05-27T03:02:13.520",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "44269",
"post_type": "answer",
"score": 1
}
] | 44269 | 44282 | 44282 |
{
"accepted_answer_id": "44325",
"answer_count": 1,
"body": "**ブラウザで使用する場合、pageYOffsetではなく、window.pageYOffsetと書いた方が良いケースはありますか?** \n・短く書けるのでpageYOffsetの方が良いかなと思ったのですが…",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-26T02:08:46.210",
"favorite_count": 0,
"id": "44272",
"last_activity_date": "2018-05-28T07:52:09.800",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7886",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "window.pageYOffsetについて",
"view_count": 154
} | [
{
"body": "`window.`を省略しても動作は変わりませんが、省略しない方が`window`のプロパティであることが明確になるので、可読性が高くなる(場合がある)ということだと思います。\n\n【参考】 \n[What's the purpose of referencing the window object in\nJavascript?](https://stackoverflow.com/questions/9041666/whats-the-purpose-of-\nreferencing-the-window-object-in-javascript)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T07:52:09.800",
"id": "44325",
"last_activity_date": "2018-05-28T07:52:09.800",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "44272",
"post_type": "answer",
"score": 3
}
] | 44272 | 44325 | 44325 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "1行ごとにエポックタイムが昇順に記載されているテキストファイルがあり、各行のエポックタイムが1分づつのように等間隔で増加しているかどうかを確認したいのですが、テキストファイルのデータが連続値かどうかを識別するpythonのライブラリはないでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-26T05:20:09.367",
"favorite_count": 0,
"id": "44273",
"last_activity_date": "2018-05-27T15:27:41.470",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "23485",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "pythonでデータが連続値かどうかを識別する",
"view_count": 2120
} | [
{
"body": "strptime()で日時をあらわす文字列から、datetimeに変換できます。例えば、以下のような感じで。\n\n```\n\n from datetime import datetime\n t = datetime.strptime('2014/01/01 00:01:02', '%Y/%m/%d %H:%M:%S')\n \n```\n\nstrptimeの第一引数('2014/01/01\n00:01:02'の部分)を、テキストファイルの1行から日時を抜き出したものに変え、第二引数('%Y/%m/%d\n%H:%M:%S'の部分)をテキストファイルで用いられている日時表記の形式に変えてください\n\n上下の行で、それぞれから取り出したdatetimeの差を求めて、どの行の間でも差が同じなら等間隔という事になります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-26T07:56:28.083",
"id": "44274",
"last_activity_date": "2018-05-26T07:56:28.083",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "44273",
"post_type": "answer",
"score": 2
},
{
"body": "エポックタイムが`1970年1月1日午前0時0分0秒から形式的な経過秒数`、いわゆる[UNIX\nTime](https://ja.wikipedia.org/wiki/UNIX%E6%99%82%E9%96%93)を指していると仮定します。これは精度が秒なので、各行毎に数字が`60`ずつ増加しているか確認すれば良い、ということになります。\n\n私の知る限りでは、少なくともそのようなライブラリは存在しません。\n\n扱うテキストファイルのフォーマットが不明ですが、仮に1カラムのみのファイルとすると、下記コードで目的が達成できそうです。\n\nt.py:\n\n```\n\n def validate(cur, prev):\n if prev is None: return None # default\n return cur == (prev + 60)\n \n with open('t.csv', 'r') as f:\n prev = None\n for n, l in enumerate(f, 1):\n epoch = int(l, 10)\n is_valid = validate(epoch, prev)\n print('{}\\t{}\\t{}'.format(n, epoch, is_valid))\n prev = epoch\n \n```\n\nt.csv:\n\n```\n\n 1527122450\n 1527122510\n 1527122550\n \n```\n\nexecute and result:\n\n`python t.py`\n\n> 1 1527122450 None \n> 2 1527122510 True \n> 3 1527122550 False",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T15:27:41.470",
"id": "44305",
"last_activity_date": "2018-05-27T15:27:41.470",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7936",
"parent_id": "44273",
"post_type": "answer",
"score": 0
}
] | 44273 | null | 44274 |
{
"accepted_answer_id": "44281",
"answer_count": 1,
"body": "下記のコードは、午前0時に日付が自動的に変わる\"(カレンダー機能つき)デジタル時計\"で、 \nその文字列がマウスポインターに付いて回ります。 \nここで、問題があります。 \nそれは、自動更新する箇所の\"drag = function(){}\"の中に表示文字を入れると \nその和暦の文字列の移動速度が重くなるため、コードを工夫したつもりですが、 \n機能しなくなりました。問題箇所は\"digi関数\"内ですが、うまく組み立てられる形は、 \n教えていただけないでしょうか。\n\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=Shift_JIS\">\n <meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\">\n <meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n <title>文字マウスストーカー</title>\n \n \n <style type=\"text/css\">\n \n #myText {\n font-style: italic;\n font-weight: bold;\n font-family: 'comic sans ms', verdana, arial;\n color: gold;\n \n position: absolute;top: 0;left: 0;z-index: 3000;cursor: default;}\n #myText div {position: relative;}\n #myText div div {position: absolute;top: 0;left: 0;text-align: center;}\n \n </style>\n \n \n <script type=\"text/javascript\">\n <!--\n \n \n var msg = \"\";\n \n \n var size = 24;\n \n var circleY = 0.75; var circleX = 2;\n \n var letter_spacing = 5;\n \n var diameter = 10;\n \n var rotation = 0.4;\n var speed = 0.3;\n \n if (!window.addEventListener\n && !window.attachEvent\n || !document.createElement)\n throw 'error';\n \n msg = msg.split('');\n var n = msg.length - 1, a = Math.round(size * diameter * 0.208333), currStep = 20,\n ymouse = a * circleY + 20, xmouse = a * circleX + 20, y = [], x = [], Y = [], X = [],\n o = document.createElement('div'), oi = document.createElement('div'),\n b = document.compatMode && document.compatMode != \"BackCompat\"? document.documentElement : document.body,\n \n mouse = function(e){\n e = e || window.event;\n ymouse = !isNaN(e.pageY)? e.pageY : e.clientY; // y-position\n xmouse = !isNaN(e.pageX)? e.pageX : e.clientX; // x-position\n },\n \n makecircle = function(){ // rotation/positioning\n \n if(init.nopy){\n o.style.top = (b || document.body).scrollTop + 'px';\n o.style.left = (b || document.body).scrollLeft + 'px';\n };\n currStep -= rotation;\n for (var d, i = n; i > -1; --i){ // makes the circle\n d = document.getElementById('iemsg' + i).style;\n d.top = Math.round(y[i] + a * Math.sin((currStep + i) / letter_spacing) * circleY - 15) + 'px';\n d.left = Math.round(x[i] + a * Math.cos((currStep + i) / letter_spacing) * circleX) + 'px';\n };\n },\n \n var tMsg = ' ';\n var lastTLocale = '';\n \n function digi(){\n \n var t = tMsg;\n \n var time = new Date();\n var Hour = time.getHours();\n \n if(Hour < 12){\n if(lastTLocale!= 'info1'){\n \n var date = new Date(),\n \n m = new Array(\"1月\", \"2月\", \"3月\", \"4月\", \"5月\", \"6月\", \"7月\", \"8月\", \"9月\", \"10月\", \"11月\", \"12月\"),\n w = new Array(\"㊐\", \"㊊\", \"㊋\", \"㊌\", \"㊍\", \"㊎\", \"㊏\"),\n Wareki = date.getFullYear(),\n month = m[date.getMonth()],\n day = date.getDate(),\n week = w[date.getDay()],\n Hour = date.getHours(),\n Min = date.getMinutes(),\n Sec = date.getSeconds();\n \n if(Hour <= 9) { \n Hour = \"0\" + Hour; \n } \n if(Min <= 9) { \n Min = \"0\" + Min; \n }\n if(Sec <= 9) { \n Sec = \"0\" + Sec; \n }\n \n var Eto = new Array(\"子\", \"丑\", \"寅\", \"卯\", \"辰\", \"巳\", \"午\", \"未\", \"申\", \"酉\", \"戌\", \"亥\"),\n EtoNum = (Wareki + 8) % 12;\n \n t = Eto[EtoNum] + \"◆\" + \" \" + month + day + \"日\" + \" \" + week + \" \" + \"★\" + \"★\" + \" \" + date.toLocaleDateString(\"ja-JP-u-ca-japanese\", { era: \"long\", year: \"numeric\" }).replace(/\\u200e/g, \"\").replace(\" \", \"\").replace(/(^|[^\\d])1(?=$|[^\\d])/, '$1元') + \" \" + \"◆\" + Hour + \":\" + Min + \":\" + Sec;\n lastTLocale = 'info1';\n \n }\n \n else{\n \n if(lastTLocale != 'info2'){\n \n var date = new Date(),\n m = new Array(\"1月\", \"2月\", \"3月\", \"4月\", \"5月\", \"6月\", \"7月\", \"8月\", \"9月\", \"10月\", \"11月\", \"12月\"),\n w = new Array(\"㊐\", \"㊊\", \"㊋\", \"㊌\", \"㊍\", \"㊎\", \"㊏\"),\n Wareki = date.getFullYear(),\n month = m[date.getMonth()],\n day = date.getDate(),\n week = w[date.getDay()],\n Hour = date.getHours(),\n Min = date.getMinutes(),\n Sec = date.getSeconds();\n \n var Eto = new Array(\"子\", \"丑\", \"寅\", \"卯\", \"辰\", \"巳\", \"午\", \"未\", \"申\", \"酉\", \"戌\", \"亥\"),\n EtoNum = (Wareki + 8) % 12;\n \n t = Eto[EtoNum] + \"◆\" + \" \" + month + day + \"日\" + \" \" + week + \" \" + \"★\" + \"★\" + \" \" + date.toLocaleDateString(\"ja-JP-u-ca-japanese\", { era: \"long\", year: \"numeric\" }).replace(/\\u200e/g, \"\").replace(\" \", \"\").replace(/(^|[^\\d])1(?=$|[^\\d])/, '$1元') + \" \" + \"◆\" + Hour + \":\" + Min + \":\" + Sec;\n lastTLocale = 'info2';\n }\n \n var currentLength = msg.length;\n \n if (t != tMsg) {\n tMsg=t;\n \n // 状態の変更\n msg = t.split('');\n n = msg.length - 1;\n \n // 文字要素の変更\n for (var i = Math.max(currentLength, msg.length) - 1; i > -1; --i)\n {\n var d = i < currentLength ? document.getElementById('iemsg' + i) : null;\n if (d)\n {\n if (i < t.length)\n {\n // 既存要素の内容変更\n d.innerHTML = msg[i];\n }\n else\n {\n // 不要になった要素の削除\n d.parentElement.removeChild(d);\n }\n }\n else\n {\n // 不足要素の追加\n d = document.createElement('div');\n d.id = 'iemsg' + i;\n d.style.height = d.style.width = a + 'px';\n d.appendChild(document.createTextNode(msg[i]));\n oi.appendChild(d); y[i] = x[i] = Y[i] = X[i] = 0;\n }\n }\n };\n \n drag = function(){\n y[0] = Y[0] += (ymouse - Y[0]) * speed;\n x[0] = X[0] += (xmouse - 20 - X[0]) * speed;\n for (var i = n; i > 0; --i){\n y[i] = Y[i] += (y[i-1] - Y[i]) * speed;\n x[i] = X[i] += (x[i-1] - X[i]) * speed;\n };\n makecircle();digi();\n },\n \n init = function(){\n if(!isNaN(window.pageYOffset)){\n ymouse += window.pageYOffset;\n xmouse += window.pageXOffset;\n } else init.nopy = true;\n for (var d, i = n; i > -1; --i){\n d = document.createElement('div'); d.id = 'iemsg' + i;\n d.style.height = d.style.width = a + 'px';\n d.appendChild(document.createTextNode(msg[i]));\n oi.appendChild(d); y[i] = x[i] = Y[i] = X[i] = 0;\n };\n o.appendChild(oi); document.body.appendChild(o);\n setInterval(drag, 25);\n },\n \n ascroll = function(){\n \n ymouse += window.pageYOffset;\n xmouse += window.pageXOffset;\n window.removeEventListener('scroll', ascroll, false);\n };\n \n o.id = 'myText'; o.style.fontSize = size + 'px';\n \n if (window.addEventListener){\n \n window.addEventListener('load', init, false);\n document.addEventListener('mouseover', mouse, false);\n document.addEventListener('mousemove', mouse, false);\n if (/Apple/.test(navigator.vendor))\n window.addEventListener('scroll', ascroll, false);\n }\n else if (window.attachEvent){\n window.attachEvent('onload', init);\n document.attachEvent('onmousemove', mouse);\n }\n \n // -->\n </script>\n \n </head>\n \n <body bgcolor=\"black\">\n \n </body>\n </html>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-26T09:35:56.307",
"favorite_count": 0,
"id": "44276",
"last_activity_date": "2018-05-27T13:29:19.120",
"last_edit_date": "2018-05-27T08:14:04.990",
"last_editor_user_id": "7936",
"owner_user_id": "28531",
"post_type": "question",
"score": 1,
"tags": [
"javascript"
],
"title": "変更により動作しなくなったJavaScriptのデバッグ・修正方法が知りたい",
"view_count": 223
} | [
{
"body": "* 102行目に全角スペースが含まれていたり、いくつかの構文エラーがあります。\n * イベントリスナ登録処理が呼び出さされるように、グローバルスコープに切り出す必要があります\n * `setInterval()` やイベントリスナから呼びだされる `init()`, `drag()` を適切なスコープに含める必要があります\n\nひとまず、最低限動作するように修正してみたものが下記です。 \n<https://gist.github.com/temmings/0f1a6a9eed6e60921f74b115f3c41563/8421e68fede9b09d5a59268ac770a665768521f2>\n\nどのような修正を加えたかは下記URLを参照ください。 \n<https://gist.github.com/temmings/0f1a6a9eed6e60921f74b115f3c41563/revisions?diff=split>\n\n構文エラーが多いため、ブラウザのコンソールのメッセージを確認されることをお勧めします。 \n例えば Google Chrome であれば、`F12` or `Ctrl + Shift + I`\nでデバッグコンソールを起動でき、下記のようなエラーメッセージが確認できます。\n\n> a.html:74 Uncaught SyntaxError: Unexpected token var\n\nJavaScript を JSLint などの Lint ツールでチェックするのもいいと思います。 \n\\- <https://www.jslint.com/>",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T02:44:54.970",
"id": "44281",
"last_activity_date": "2018-05-27T13:29:19.120",
"last_edit_date": "2018-05-27T13:29:19.120",
"last_editor_user_id": "7936",
"owner_user_id": "7936",
"parent_id": "44276",
"post_type": "answer",
"score": 1
}
] | 44276 | 44281 | 44281 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "S3で画像を管理しているのですが、IPを制限して自分のサーバーからのみアクセス許可をしたいのですが、設定のconditionの中にIPを入れると403が返ってきてアクセスできません。conditionを外すと表示されます。\n\n具体的に設定方法や確認すべき箇所、(あれば)必要なコマンドなどご教示いただけますでしょうか?\n\nよろしくお願い致します。\n\n```\n\n {\n \"Version\": \"2012-10-17\",\n \"Id\": \"Policy1527266936788\",\n \"Statement\": [\n {\n \"Sid\": \"Stmt11111111,\n \"Effect\": \"Allow\",\n \"Principal\": \"*\",\n \"Action\": \"s3:*\",\n \"Resource\": \"arn:aws:s3:::xxxxx/*\",\n \"Condition\": {\n \"IpAddress\": {\n \"aws:SourceIp\": \"xx.xx.xxx.xxx/24\"\n }\n }\n }\n ]\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-26T15:24:05.653",
"favorite_count": 0,
"id": "44277",
"last_activity_date": "2018-05-27T02:36:54.533",
"last_edit_date": "2018-05-26T16:15:36.833",
"last_editor_user_id": "3060",
"owner_user_id": "18982",
"post_type": "question",
"score": 2,
"tags": [
"aws",
"amazon-s3"
],
"title": "s3のIP制御について",
"view_count": 69
} | [
{
"body": "[特定の IP\nアドレスへのアクセスの制限](https://docs.aws.amazon.com/ja_jp/AmazonS3/latest/dev/example-\nbucket-policies.html#example-bucket-policies-use-\ncase-3)にも例がある通りであり、質問文に記載された範囲では問題なさそうです。1点、質問文に記載されていない範囲で気になりました。[IPアドレス条件演算子](https://docs.aws.amazon.com/ja_jp/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_IPAddress)の説明に\n\n> IP アドレス条件演算子では、キーと IPv4 または IPv6 アドレスまたは IP アドレス範囲の比較に基づいてアクセスを制限する\n> Condition 要素を構築できます。 これらを aws:SourceIp キーと合わせて使用します。値は、 **標準的な CIDR\n> 形式でなければいけません** (例 : 203.0.113.0/24 または 2001:DB8:1234:5678::/64)。\n\nとあります。`\"xx.xx.xxx.xxx/24\"` と値が伏せられていますが24bit CIDRであれば `\"xx.xx.xxx.0/24\"`\nとする必要があります。標準的な CIDR 形式を設定していますでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T02:36:54.533",
"id": "44280",
"last_activity_date": "2018-05-27T02:36:54.533",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "44277",
"post_type": "answer",
"score": 3
}
] | 44277 | null | 44280 |
{
"accepted_answer_id": "44279",
"answer_count": 2,
"body": "処理時間を調べたくて、実験的にネットでよく見かけるコードでテストをしてみたのですが、0秒となってうまくいきません。どう手直しすればよいのでしょうか?\n\n```\n\n import time\n \n def main():\n \n start = time.time()\n \n i = 0\n for i in range(100000):\n i = i * 2\n \n end = time.time()\n \n print (end-start)\n \n if __name__ == '__main__':\n main()\n \n```\n\n[出力結果]:0.0",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-26T16:44:28.847",
"favorite_count": 0,
"id": "44278",
"last_activity_date": "2018-05-27T03:43:51.943",
"last_edit_date": "2018-05-26T22:02:39.920",
"last_editor_user_id": "19110",
"owner_user_id": "28644",
"post_type": "question",
"score": 3,
"tags": [
"python",
"python3"
],
"title": "プログラムの処理時間表示が0.0になる",
"view_count": 836
} | [
{
"body": "処理がごく短時間で終わってしまうので、計測するには`time.time()`では精度が不十分なのかも知れません。 \n代わりに`time.perf_counter()`を使ってみてはどうでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-26T19:13:59.210",
"id": "44279",
"last_activity_date": "2018-05-26T19:13:59.210",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9464",
"parent_id": "44278",
"post_type": "answer",
"score": 2
},
{
"body": "time.time()は、システムによっては1秒より高い精度で時刻を提供するとは限らないとなっています。使用しているシステムでは、time.time()の精度が十分でないようです。\n\nPython には、コードの実行時間を計測するモジュールに`timeit`があるのでそれを使ってみたらどうですか。今回のコードであれば以下のようになります。\n\n```\n\n import timeit\n \n def main():\n i = 0\n for i in range(100000):\n i = i * 2\n \n if __name__ == '__main__':\n print(timeit.timeit('main()', number=1))\n \n```\n\nJupyter Notebook\nを使用すると`%timeit`というマジックコマンドが使えて便利です。複数行になる場合は、`%%timeit`を使って以下のようにして計測できるので手軽に使えます。\n\n```\n\n %%timeit\n i = 0\n for i in range(100000):\n i = i * 2\n \n```\n\nなお、Jupyter Notebook をインストールするのが面倒な場合は、[Google\nColab](https://colab.research.google.com/) が無料で使えます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T03:43:51.943",
"id": "44283",
"last_activity_date": "2018-05-27T03:43:51.943",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "44278",
"post_type": "answer",
"score": 4
}
] | 44278 | 44279 | 44283 |
{
"accepted_answer_id": "44289",
"answer_count": 2,
"body": "ruby ではスペースによって引数付きのメソッドコールを表すことができますが、これがどういうタイミングで可能なのかが分からないな、と思っています。\n\n例えば、以下ではメソッドコールは成功します。\n\n```\n\n [1] pry(main)> ([1].take 1).to_s\n => \"[1]\"\n \n```\n\nしかし、以下では成功しません。\n\n```\n\n [2] pry(main)> true ? [1] : [0].take 1\n SyntaxError: unexpected tINTEGER, expecting end-of-input\n true ? [1] : [0].take 1\n ^\n \n```\n\nこの失敗している例において、文法的な解釈として、 `[0].take 1`\nをひとつのメソッドコールとして解釈してくれてもいいかと思いましたが、(それ以外に正しい式の木を構築する方法がないはずなので)そうはなっていない様子です。\n\n### 質問\n\nruby においてスペースによってメソッドコールができる文脈は何ですか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T05:01:55.903",
"favorite_count": 0,
"id": "44287",
"last_activity_date": "2018-07-02T01:32:05.523",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"ruby"
],
"title": "ruby でスペースによるメソッドコールが可能な文脈は?",
"view_count": 82
} | [
{
"body": "[rubyの演算子順位表](https://docs.ruby-\nlang.org/ja/latest/doc/spec=2foperator.html)を見ればいいと思います。 \n`()`は演算順位が一番高く、`()`なしは演算順位が一番低い(`()`なしについては公式のドキュメントが見つけられませんでしたが)ので、\n\n```\n\n true ? [1] : [0].take 1\n \n```\n\nは演算順位が高い`?:(条件演算子)`が先に解釈されて\n\n```\n\n (true ? [1] : [0].take) 1\n \n```\n\nと同じ意味になり、\n\n```\n\n [1] 1\n \n```\n\nという意味になるので文法エラーになるのだと思います。\n\n> ruby においてスペースによってメソッドコールができる文脈は何ですか?\n\nこれについては、[rubyの演算子順位表](https://docs.ruby-\nlang.org/ja/latest/doc/spec=2foperator.html)を見ながら適宜確認するしかないと思います。 \n(普通はそれは面倒なので怪しいところには`()`をつけてしまいます。)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T05:34:09.437",
"id": "44289",
"last_activity_date": "2018-05-27T05:34:09.437",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28630",
"parent_id": "44287",
"post_type": "answer",
"score": 1
},
{
"body": "追記として、どうやら、 スペースによる関数適用の結合順序は、 `?:` より下で、 `=`(代入) より上の様子です。\n\n```\n\n result = some_method arg\n some_condition arg and return\n \n```\n\nこれらは、両方ともスペースによるメソッド適用がなされてから、代入なり and 移行の評価なりが行われている様子です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-07-02T01:32:05.523",
"id": "45226",
"last_activity_date": "2018-07-02T01:32:05.523",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "44287",
"post_type": "answer",
"score": 0
}
] | 44287 | 44289 | 44289 |
{
"accepted_answer_id": "44457",
"answer_count": 1,
"body": "以下のrubyのコードがrubyのバージョンによって挙動が違います。 \nこれについて、公式のドキュメントはありますでしょうか?\n\nまた、組み込みメソッドがスレッドセーフかどうかは何を参照すれば良いでしょうか?\n\n```\n\n THREAD_NUM = 3\n \n Array.new(THREAD_NUM) do\n Thread.new do\n 10.times do\n puts \"hoge\"\n end\n end\n end.each(&:join)\n \n puts \"-\"*5\n \n Array.new(THREAD_NUM) do\n Thread.new do\n 10.times do\n print \"hoge\\n\"\n end\n end\n end.each(&:join)\n \n```\n\n* * *\n```\n\n $ ruby -v\n ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]\n $ruby thread.rb\n hoge\n hoge\n hoge\n hoge\n hogehoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n \n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n -----\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n \n```\n\n* * *\n```\n\n $ ruby -v\n ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]\n $ ruby thread.rb\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n -----\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n hoge\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T05:10:58.293",
"favorite_count": 0,
"id": "44288",
"last_activity_date": "2018-06-02T07:00:02.450",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28630",
"post_type": "question",
"score": 9,
"tags": [
"ruby"
],
"title": "rubyの組み込みメソッドがスレッドセーフか否かについて",
"view_count": 649
} | [
{
"body": "この回答は公式のCでの実装であるCRubyについてです。JRuby等でも同じとは限らない事に注意してください。\n\n現在の所、CRubyの実装上のほとんどのメソッドはスレッドセーフに **見えます**\n。しかし、`Thread`や`Mutex`等のスレッド関係を除き、スレッドセーフであると期待してはいけません。 **スレッドセーフではない**\nという前提でコードを実装すべきです。\n\n現在のCRubyのスレッドに関する戦略は、個々のメソッドのCレベルでの実装でスレッドセーフであるかは考慮しないとしています。これは、\n\n * スレッドセーフのコードは複雑になり、バグ無く維持していくのが難しい\n * シングルスレッドでは余計なロック処理によって速度低下が発生する\n * Cライブラリのほんとんどがスレッドセーフではない\n\nなどが理由です。かといって、これをそのままマルチスレッドにした場合、segmentation\nfaultで落ちます。そのため、Rubyではグローバルインタープリンタロック(Global Interpreter Lock, 以下GIL,\nRubyではグローバルVMロックとも言われる)という仕組みを採用しています(CPythonも採用しています)。これは、マルチスレッドであっても(Cレベルでは)動いているコードは常に一つにするという制限をかけるものです。動いているスレッドは常に一つであるため、スレッドセーフではないコードであっても、その処理自体はスレッドセーフのように動作が保証できるというものです。これが冒頭で書いた「スレッドセーフに見えます」と言っているところです。\n\nただ、これはCレベルでの処理においてオブジェクトを保護するための機能に過ぎません。ブロックや他のメソッド呼び出しなどで一旦Rubyのコードに移ってしまえば、そこでスレッドの切り替えの発生があり得ます。また、Cレベルでスレッドセーフな部分があれば、GILを外してもいいため、その時は同時に別スレッドが動作している場合もあります。つまり、そのような場合に、そのメソッドの処理の途中で他のスレッドに割り込みされる可能性があるため、アトミックな操作であるという保証はなくなってしまうということです。\n\n参考: \n[マルチスレッド/プロセスまとめ(Ruby編)](https://qiita.com/masashi127/items/b186bbf20b4c9632cc86) \n[Rubyのスレッド周りの話](https://qiita.com/motsat/items/8c9b6bc56152444f50a0) \n[Rubyでスレッドセーフでないことを簡単に確認したい -\nもょもとの技術ノート](http://moyomot.hatenablog.com/entry/2014/05/04/232538)\n\n* * *\n\n今回のコードの`puts`がどうなっているかという話をしましょう。`puts`は最終的に`$stdout`に対して`IO#write`を呼び出すという形なっています。`IO#write`を上書きしたら、`puts`の動作も変わります。次のコードを見てください。\n\n```\n\n class IO\n alias :write_org :write\n def write(str)\n write_org(\"[+++]\")\n write_org(str)\n write_org(\"[---]\")\n end\n end\n \n puts \"hoge\"\n \n```\n\n実行すると\n\n```\n\n [+++]hoge[---][+++]\n [---]\n \n```\n\nとなります。つまり、`IO#write`を二回呼び出しています。この呼び出しは一旦Rubyの処理に戻りますので、この瞬間スレッドの切り替えが発生する可能性があります。もし、このタイミングで切り替えが発生した場合は、別の物に割り込まれる形になるでしょう。\n\nまた、`IO#write`のような処理では内部でのIO書き込み時にGILは外すように実装されています。IO処理は重いため、その間別のスレッドが走るようにするためです。そうなると、この外れている僅かな時間でもう一つのスレッドが走り、割り込むような形で入る可能性があります。\n\nスレッド切り替えはあくまで可能性であって、バージョン以外にも環境によっても左右されます。起きる場合もあれば全然起きない場合もあります。文字列をもっと長くすれば、発生する可能性が増えることでしょう。\n\n※\nスレッド切り替えはIO処理の他に時間経過による切り替えがありますが、それが発生するのはRubyレベルでの処理があった時になります。Cレベルでの処理中は切り替えは発生しません。\n\n参考: \n[第19章 スレッド](http://i.loveruby.net/ja/rhg/book/thread.html)\n\nその他にスレッドセーフではない例を一つ書いておきます。\n\n```\n\n class String\n alias :plus :+\n def +(other)\n Thread.pass\n self.plus(other)\n end\n end\n \n arr0 = [\"0\"] * 10\n arr1 = [\"1\"] * 10\n arr = []\n arr.replace(arr0)\n ths = []\n \n ths << Thread.new do\n 10.times do\n arr.replace(arr0)\n Thread.pass\n end\n end\n \n ths << Thread.new do\n 10.times do\n arr.replace(arr1)\n Thread.pass\n end\n end\n \n ths << Thread.new do\n 10.times do\n puts arr.sum(\"\")\n Thread.pass\n end\n end\n \n ths.each(&:join)\n \n```\n\nもし、`Array#sum`がスレッドセーフであれば、\"0000000000\"か\"1111111111\"が出力されますが、実際は0と1が混じった文字列が出力される場合があります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-06-01T12:57:59.020",
"id": "44457",
"last_activity_date": "2018-06-01T12:57:59.020",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7347",
"parent_id": "44288",
"post_type": "answer",
"score": 9
}
] | 44288 | 44457 | 44457 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Ubuntuでkompozerを実行しようとした際に以下のようなエラーが出てしまいます。\n\n```\n\n $ sh kompozer\n ./kompozer-bin: error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory\n \n```\n\nこの問題となっているファイルはどうすれば追加することができるのでしょうか。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T06:29:59.633",
"favorite_count": 0,
"id": "44290",
"last_activity_date": "2018-05-29T01:11:00.270",
"last_edit_date": "2018-05-29T01:11:00.270",
"last_editor_user_id": "3060",
"owner_user_id": "24965",
"post_type": "question",
"score": 0,
"tags": [
"ubuntu"
],
"title": "Ubuntuでlibgtk-x11-2.0.so.0を追加するには",
"view_count": 4033
} | [
{
"body": "多少環境は異なるかと思いますが、参考までに情報を共有しておきます。\n\n**実行環境** \nLinux Mint 17 Qiana 32bit (Ubuntu 14.04 Trusty Tahr 相当) \nKompoZer-0.8b3 (PPAリポジトリの追加ではうまくダウンロード出来なかったので、kompozer, kompozer-data\nパッケージを以下から入手)\n\n[kompozer_0.8~b3.dfsg.1-0.1ubuntu2_i386.deb](https://ubuntu.pkgs.org/12.04/ubuntu-\nuniverse-i386/kompozer_0.8~b3.dfsg.1-0.1ubuntu2_i386.deb.html) \n[kompozer-\ndata_0.8~b3.dfsg.1-0.1ubuntu2_all.deb](https://ubuntu.pkgs.org/12.04/ubuntu-\nuniverse-i386/kompozer-data_0.8~b3.dfsg.1-0.1ubuntu2_all.deb.html)\n\n* * *\n\n**確認手順** \n質問で`kompozer`実行時にエラーで表示されている`libgtk-x11-2.0.so.0`がどのパッケージに入っているかを`apt-\nfile`コマンドで調べます。`dpkg`コマンドを使用した場合は **インストール済み**\nファイルに対してのみ検索が可能。未インストールのパッケージも含めて検索したい場合は`apt-file`コマンドを使用します。\n\n```\n\n $ sudo apt-get install apt-file\n $ apt-file update\n $ apt-file search libgtk-x11-2.0.so.0\n libgtk2.0-0: /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0\n libgtk2.0-0: /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.23\n libgtk2.0-0-dbg: /usr/lib/debug/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.23\n \n```\n\n`libgtk2.0-0`パッケージに含まれていることが分かったので、こちらをインストールします。\n\n```\n\n $ sudo apt-get install libgtk2.0-0\n \n```\n\nインストールされたファイルの確認。\n\n```\n\n $ dpkg -L libgtk2.0-0 | grep \"so.0\"\n /usr/lib/i386-linux-gnu/libgdk-x11-2.0.so.0.2400.23\n /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0\n \n```\n\n* * *\n\nちなみに、`libgtk2.0-dev`のようにパッケージ名に **dev**\nが付くものは、大抵アプリケーション開発時に必要なヘッダファイル(`*.h`)をまとめたパッケージです。 \nアプリを動作させるのに必要なのは共有ライブラリ(`*.so`)の方なので、単にアプリを起動させるだけなら必ずしもヘッダファイルは必要ありません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T13:09:57.690",
"id": "44336",
"last_activity_date": "2018-05-28T13:09:57.690",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "44290",
"post_type": "answer",
"score": 2
}
] | 44290 | null | 44336 |
{
"accepted_answer_id": "44294",
"answer_count": 1,
"body": "以下のrubyのコードについて、`result1`は出力できるのに`result2`は出力できないのはなぜですか?\n\n```\n\n if result1 = 'hoge'\n puts \"result1 is #{result1}\"\n end\n \n puts \"result2 is #{result2}\" if result2 = 'hoge'\n \n```\n\n* * *\n```\n\n $ ruby -v\n ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]\n $ ruby sample.rb\n sample.rb:1: warning: found = in conditional, should be ==\n sample.rb:5: warning: found = in conditional, should be ==\n result1 is hoge\n Traceback (most recent call last):\n sample.rb:5:in `<main>': undefined local variable or method `result2' for main:Object (NameError)\n Did you mean? result1\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T06:30:49.260",
"favorite_count": 0,
"id": "44291",
"last_activity_date": "2018-05-27T08:38:48.153",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28630",
"post_type": "question",
"score": 1,
"tags": [
"ruby"
],
"title": "rubyのinline if のscopeについて",
"view_count": 111
} | [
{
"body": "[@metropolis さんが示してくれているリンク](https://ruby-\ndoc.org/core-2.5.1/doc/syntax/control_expressions_rdoc.html#label-\nModifier+if+and+unless)に、答えは書いてありますが、リンクは回答としてはあまり適切ではないので、まとめてみます。\n\n似たような if 文での処理を見てみると、次のようになっています。\n\n```\n\n result2 = :foo\n puts result2 if result2 = :hoge\n # => hoge\n \n 0 if result3 = :fuga\n puts result3\n # => fuga\n \n```\n\n結論として言えることは、今回問題になっている undefined local variable は、 if/unless modifier clause\nの中で初めて変数を定義し、かつ、その定義される変数を本文において利用していた場合に発生する様子です。\n\nこのことの説明は、上記のリンクから辿れますが、説明してみると、 ruby のインタプリタの動作として、 if/unless modifier clause\nを処理するときに、\n\n 1. 最初に変数が bind している変数メタデータストアを、(おそらくその1文で変数が表われた順に)特定し\n 2. 次に if の中身を評価し\n 3. 条件を見たしていることが分かれば本文を実行する\n\nという処理をしている様子です。\n\n問題は、上記のような処理を行った場合、 if/unless modifier clause\n付きの文であると、その条件式の中で変数が定義されることになったとしても、最初に本文 result2 の変数出現に対しては変数が存在しないとして 1\nのプロセスで処理されてしまっているため、本文が実行される段階になった際には、そんな名前の変数は存在しなかった例外を生成してしまう様子です。\n\n結論から言えるのは、 modifier if clause の中で代入は行わない方が無難だな、と思った次第です。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T08:38:48.153",
"id": "44294",
"last_activity_date": "2018-05-27T08:38:48.153",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "44291",
"post_type": "answer",
"score": 1
}
] | 44291 | 44294 | 44294 |
{
"accepted_answer_id": "44328",
"answer_count": 1,
"body": "タイトルの通りですが、まず1つのフォルダに複数のファイルが存在します。 \nそのフォルダ内全てのファイルを複数のサブディレクトリの全ての中にコピーしたいです。\n\n```\n\n フォルダA ┳ コピーしたい.txt\n ┣ コピーしたい.csv\n ┗ コピーしたい.csv\n \n フォルダB ┳ フォルダc ┳ フォルダi\n (コピー先) ┃ ┗ フォルダj\n ┣ フォルダd\n ...etc\n \n```\n\n環境はWindows10 64bit版です。 \nよろしくお願いいたします。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T10:36:29.833",
"favorite_count": 0,
"id": "44295",
"last_activity_date": "2018-05-28T09:24:02.640",
"last_edit_date": "2018-05-27T16:13:02.653",
"last_editor_user_id": "7936",
"owner_user_id": "28680",
"post_type": "question",
"score": 0,
"tags": [
"windows",
"batch-file"
],
"title": "1つのフォルダにまとめたファイル群を何回層もあるサブディレクトリ群にコピー",
"view_count": 583
} | [
{
"body": "フォルダAのサブフォルダはコピーせず、フォルダB自体を除いてサブフォルダにコピーする例です。\n\nバッチファイル(バッチファイルではなくコマンドラインの場合は`%%D`を`%D`に書き直してください)\n\n```\n\n SET SRC=C:\\test\\フォルダA\n CD /D C:\\test\\フォルダB\n FOR /D /R %%D IN (*) DO (ROBOCOPY \"%SRC%\" \"%%D\")\n \n```\n\nPowerShell\n\n```\n\n ls \"C:\\test\\フォルダB\" -Recurse | ?{ $_.PSIsContainer } | %{\n robocopy \"C:\\test\\フォルダA\" $_.FullName\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T09:24:02.640",
"id": "44328",
"last_activity_date": "2018-05-28T09:24:02.640",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "44295",
"post_type": "answer",
"score": 0
}
] | 44295 | 44328 | 44328 |
{
"accepted_answer_id": "44348",
"answer_count": 2,
"body": "c++の参考書で「friend関数はthisポインタを持たない、そのクラスに所属しているわけではない、非公開メンバにアクセスできる。 \nタイトル通り friend関数とfriendクラスの違いについて教えて欲しいです。\n\n```\n\n int main(){\n Date a(4),b(3);\n Date c = test(a,b);\n }\n \n class Date {\n \n private: \n //double d;\n int x;\n int z;\n static int prst;//静的記憶域期間\n \n public:\n Date();\n \n Date(int x);\n \n void print();\n //////////////////////////////////\n friend Date test(const Date& a, const Date& b)//friend関数\n {\n return Date(a.x + b.x);\n }\n //////////////////////////////////\n int y = 0;\n static int pust;//静的記憶域期間\n \n void pri(int x);\n static void pri_st(int x);\n };\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T11:47:18.337",
"favorite_count": 0,
"id": "44299",
"last_activity_date": "2018-05-29T02:35:31.627",
"last_edit_date": "2018-05-28T07:10:31.087",
"last_editor_user_id": "19110",
"owner_user_id": null,
"post_type": "question",
"score": -1,
"tags": [
"c++"
],
"title": "c++ friend関数とfriendクラスの違いを知りたいです。",
"view_count": 3963
} | [
{
"body": "まず、friend関数とfriendクラスの違いは関数とクラスの違いだけです。 \nところで、当初の質問内容はfriendの意味だったと思うのですが、それも一般的な回答は検索で見つかると思います。\n\nさて、大昔の自分もfriendの利用シーンがなかなか思いつかなかったのですが現在は下に述べる部分で使用しています。\n\n(1)friend関数の利用シーン \nOSないしシステム側がコールバック関数(C言語の関数)を要求する場合に、直接クラスメンバ関数を渡せないのでfriend関数に橋渡しをしてもらう場合等に使ってます。\n\n(2)friendクラスの利用シーン \n非公開のコンストラクタ(デストラクタ)しか持たないクラスAが、Aの配列クラス等に生殺与奪を任せたい場合等に使ってます。派生させればどこでも構築できてしまう場合もありますが、それをやってはいけませんという意味を表現しているつもりです。\n\n以上、具体的な事例もなんらかの役にたつかもしれませんので経験上の一例をあげてみました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-29T02:26:50.693",
"id": "44345",
"last_activity_date": "2018-05-29T02:32:03.523",
"last_edit_date": "2018-05-29T02:32:03.523",
"last_editor_user_id": "3793",
"owner_user_id": "3793",
"parent_id": "44299",
"post_type": "answer",
"score": 0
},
{
"body": "書かれているとおり `friend` 関数は「非メンバなのに `private` `protected`\nなメンバを直接使うことを認める」ためのものです。適切に OOAD (Object-Oriented Analysis and Design)\nができていればまず使うことは無い / 使う必要が無いものです。 \n使うとしたら「非メンバ関数」として実装するしか手が無い関数を使う場合とか。\n\n自作複素数クラス `class mycomplex` を実装して `double + mycomplex`\nができるような演算子を実装したくなったら、左辺が組み込み型なので非メンバ関数な `operator+` が必要となり\n\n```\n\n class mycomplex {\n double re; // real part\n double im; // imaginary part\n public:\n mycomplex(double r0=0.0, double i0=0.0) : re(r0), im(i0) { }\n mycomplex(const mycomplex& rh) : re(rh.re), im(rh.im) { }\n // double + mycomplex を行う非メンバ関数 (static メンバでもない)\n friend mycomplex operator+(double lh, const mycomplex& rh) {\n return mycomplex(lh+rh.re, rh.im);\n }\n // 普通に (non-static な) メンバ関数 mycomplex+mycomplex\n mycomplex operator+(const mycomplex& rh) const {\n return mycomplex(this->re+rh.re, this->im+rh.im);\n }\n };\n \n```\n\nこんな形で「非メンバな関数」の中で `private` なメンバを直に使うことができます(この `mycomplex` 中で `re` や `im` が\n`private` としていることが適切かどうかはまた別問題なのでいまはおいておく) \n# そうしている意図は、将来、内部実装を極座標表示にするかもってことなわけだけど\n\n`operator` 以外であっても、フレームワークやライブラリの実装上の都合で非メンバ関数を使わざるを得ないような場合に `friend`\n関数を使うことがあるでしょう。 \n[class メンバー関数をコールバックとして渡したい](https://ja.stackoverflow.com/questions/36847/)\n\n組み込み系だと、開発ツールが割り込みハンドラを [c](/questions/tagged/c \"'c' のタグが付いた質問を表示\")\n関数として自動生成してしまったりするので `friend` 関数の出番がままあったりします。\n\n`friend` クラスのほうは「使ったら設計ないしは実装に失敗している」レベルで使い道が無くて、オイラも実用したことはありません。\n\n`friend` は `class`\nが隠している内面をもろにさらけ出す(オイラは「臓物を晒す」と称しています)ので、必要の無いところで使うことは禁じ手です。逆に、必要ならためらい無く使いましょう。そういう機能があればより性能が出せるという場面では、あぶない機能でも使えるというのが\n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") や [c++](/questions/tagged/c%2b%2b\n\"'c++' のタグが付いた質問を表示\") の言語設計方針なので、取捨選択するのはユーザの責任です。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-29T02:35:31.627",
"id": "44348",
"last_activity_date": "2018-05-29T02:35:31.627",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "44299",
"post_type": "answer",
"score": 2
}
] | 44299 | 44348 | 44348 |
{
"accepted_answer_id": "44302",
"answer_count": 1,
"body": "本日学び始めた初学者です。\n\n```\n\n home=\"america\"\n if home ==\"america\":\n print(\"Hello,america!\")\n else:\n print(\"Hello,world\")\n \n```\n\nというコードを通したいのですが、 \n必ずエラーが返ってしまいます。 \n①そもそも、テキストエディタ(サクラエディタ)に作成したコードを、 \npython 3.6.5 Shellにコピペしてはいけないのでしょうか。\n\n②1行ずつコピペしても(打っても)else: を打ってエンターキーを押すと \n必ずエラーとなってしまいます。(invalid syntax)\n\n上記はどうしてなのでしょうか。 \n基本的なところで間違っているのかもしれませんが、どう調べてもわからず。。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T12:26:35.883",
"favorite_count": 0,
"id": "44300",
"last_activity_date": "2018-05-27T12:54:45.943",
"last_edit_date": "2018-05-27T12:54:45.943",
"last_editor_user_id": "3054",
"owner_user_id": "28682",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "ifelse文のエラーについて",
"view_count": 1597
} | [
{
"body": "Pythonにおいてはインデントが非常に重要です。書かれたコードの中だとif文(及びelse文)のブロックにインデントが足りないと思います。\n\n```\n\n home = \"america\"\n if home == \"america\":\n print(\"Hello, america!\")\n else:\n print(\"Hello, world\")\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T12:40:59.630",
"id": "44302",
"last_activity_date": "2018-05-27T12:40:59.630",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "44300",
"post_type": "answer",
"score": 0
}
] | 44300 | 44302 | 44302 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "### 前提・実現したいこと\n\n画像認識の機械学習のモデルを勉強したいため、Anacondaをインストールし、TensorflowやKerasを用いて自分なりに勉強したいと思っています。 \nそのため、Python 3.6 versionのmac用のAnaconda\n5.1をインストールし、コマンドプロンプトから実行しました。機械学習や環境構築を含むプログラミングに関しては初心者で、開発経験などもございません。\n\n### 発生している問題・エラーメッセージ\n\nどうも私のPCだと解凍処理やインストールで[permission denied]というエラーメッセージが多発し、コマンドを受け付けないことが多いです。 \nアナコンダをインストールしようと、シェル上で \nbash /Users/keisuke/Downloads/code/Anaconda3-5.1.0-MacOSX-x86_64.sh \nを打つと、インストールを開始しますが途中で解凍の許可が下りずに止まってしまいます。以下がエラー内容です。\n\n> installing: python-3.6.4-hc167b69_1 ... \n> Python 3.6.4 :: Anaconda, Inc. \n> installing: bzip2-1.0.6-hd86a083_4 ... \n> installing: ca-certificates-2017.08.26-ha1e5d58_0 ... \n> installing: conda-env-2.6.0-h36134e3_0 ... \n> installing: intel-openmp-2018.0.0-h8158457_8 ... \n> installing: jbig-2.1-h4d881f8_0 ... \n> installing: jpeg-9b-he5867d9_2 ... \n> installing: libcxxabi-4.0.1-hebd6815_0 ... \n> installing: libgfortran-3.0.1-h93005f0_2 ... \n> installing: libiconv-1.15-hdd342a3_7 ... \n> installing: libsodium-1.0.15-hd9e47c5_0 ... \n> installing: lzo-2.10-h362108e_2 ... \n> installing: pandoc-1.19.2.1-ha5e8f32_1 ... \n> **bunzip2: Can't open input file\n> /Users/keisuke/anaconda3/pkgs/pandoc-1.19.2.1-ha5e8f32_1.tar.bz2: Permission\n> denied.** \n> Traceback (most recent call last): \n> File \"/Users/keisuke/anaconda3/pkgs/.install.py\", line 618, in \n> main2() \n> File \"/Users/keisuke/anaconda3/pkgs/.install.py\", line 599, in main2 \n> link_dist(opts.link_dist) \n> File \"/Users/keisuke/anaconda3/pkgs/.install.py\", line 454, in link_dist \n> link(prefix, dist, linktype) \n> File \"/Users/keisuke/anaconda3/pkgs/.install.py\", line 328, in link \n> files = list(yield_lines(join(info_dir, 'files'))) \n> File \"/Users/keisuke/anaconda3/pkgs/.install.py\", line 96, in yield_lines \n> for line in open(path): \n> FileNotFoundError: [Errno 2] No such file or directory:\n> '/Users/keisuke/anaconda3/pkgs/pandoc-1.19.2.1-ha5e8f32_1/info/files'\n\nこのほかにもpip install tensorflowと打つと、\n\n> Collecting tensorflow \n> Using cached\n> <https://files.pythonhosted.org/packages/9b/1e/d89f1369b5b8045e5aedf43718b45d2396d3c61e9cc56123c24b7758dd9f/tensorflow-1.8.0-cp27-cp27m-macosx_10_11_x86_64.whl> \n> **Could not install packages due to an EnvironmentError: [Errno 13]\n> Permission denied:**\n> u'/private/var/folders/4y/z038tqx15jvfqptw0s_tmz8w0000gp/T/pip-unpack-\n> Sk9pwB/tensorflow-1.8.0-cp27-cp27m-macosx_10_11_x86_64.whl' \n> Consider using the `--user` option or check the permissions.\n\nのように[permission denied]と出ていずれにせよTensorflowをインストールできません。\n\n### 試したこと\n\nエラーメッセージを頼りに様々な解説サイトを参考にして以下のような方法を試しましたが全てダメでした。 \n・sudoや--userをつけたり、umaskを緩く設定してコードを実行 → 同じエラー \n・python関係の全てのフォルダ/ファイルを削除してanacondaを再インストール → 同じエラー \n・anaconda navigatorを使ってtensorflowをインストールしようとする →\nロードした後何も追加されずに終わる(おそらく裏でpermission deniedが起こってます) \n・(env)(tonsorflow)$ のように、tensorflowの仮想環境に入って同じことを実行 → 同じエラー\n\n### 補足情報(FW/ツールのバージョンなど)\n\n今の条件: \n・Macbook Pro 10.12.6(品質の良い中古品) \n・echo $PATH \n/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \n・.bash_profile \nexport PATH=\"/anaconda3/bin:$PATH\" \n・Python 2.7.15 \n・/Users/keisukeと、/Users/keisuke/Downloads/codeの下に「anaconda3」という同じファイルが入っています(中身は違う)。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T15:03:21.517",
"favorite_count": 0,
"id": "44304",
"last_activity_date": "2018-05-28T21:45:11.730",
"last_edit_date": "2018-05-28T04:47:11.767",
"last_editor_user_id": "28684",
"owner_user_id": "28684",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"tensorflow",
"anaconda"
],
"title": "Anacondaをインストールし、Tensorflowを使って機械学習をしたいのですが、Permission deniedとエラーが出てインストールできません。",
"view_count": 1834
} | [
{
"body": "質問については、以下のエラーが出ているので、 \n`bunzip2: Can't open input file\n/Users/keisuke/anaconda3/pkgs/pandoc-1.19.2.1-ha5e8f32_1.tar.bz2: Permission\ndenied.`\n\n次ののコマンドで該当ファイルの所有者とパーミッションを調べて、適正なものに修正してみてください。\n\n```\n\n ls -l ~/anaconda3/pkgs/pandoc-1.19.2.1-ha5e8f32_1.tar.bz2\n \n```\n\nまた、以下のコマンドで解凍できるか確認してみてください。\n\n```\n\n bunzip2 ~/anaconda3/pkgs/pandoc-1.19.2.1-ha5e8f32_1.tar.bz2\n \n```\n\n質問の後半の`pip install tensorflow`に対して、`Permission denied`のエラーが発生するのは正常です。Anaconda\nのインストールができていない状況なので、pip\nはMacのシステムでインストールされているpython2.7へのパッケージをインストールする操作になります。その場合は、root権限が必要になります。なお、`sudo\npip install tensorflow`とするのは、Macのシステムを変更することになるのであまり適切なことではありません。\n\n試したことに「sudoをつけてコードを実行してみた」とありますが、Anacondaをホームディレクトリにsudoでインストールするとホームディレクトリ内のドットファイルの方にもrootが所有者であるディレクトリやファイルができてしまいます。そうなると[permission\ndenied]というエラーメッセージが多発しても当然のことです。まず、どういう場合にsudoが必要になるのか、homeディレクトリ内のディレクトリやファイルの所有者を自分にするというシェルの基本から学習したらどうでしょうか。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T01:57:45.733",
"id": "44313",
"last_activity_date": "2018-05-28T21:45:11.730",
"last_edit_date": "2018-05-28T21:45:11.730",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "44304",
"post_type": "answer",
"score": 2
}
] | 44304 | null | 44313 |
{
"accepted_answer_id": "44366",
"answer_count": 1,
"body": "macOSでHomebrewを使ってPythonを入れ直したのですが`pip3`コマンドでPython3のpipを呼びだそうとしたのですが`command\nnot found`になってしまいます。\n\n前にHomebrewを使ってPython3を入れた際は \nインストールが終わると同時にpip3へのシンボリックリンクが作られていたため \nすぐにpipを使いはじめることができていました。\n\nどうすればpip3コマンドでpython3のpipを呼び出せるのでしょうか? \n自分でln -sを実行しなければいけないのでしょうか?\n\npython3.6.5 \nmacOS 10.13.4",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-27T17:14:31.923",
"favorite_count": 0,
"id": "44308",
"last_activity_date": "2018-05-30T01:48:11.287",
"last_edit_date": "2018-05-30T01:48:11.287",
"last_editor_user_id": "3060",
"owner_user_id": "5246",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3",
"macos",
"homebrew"
],
"title": "HomebrewでPython3をインストールするとpipが使えない",
"view_count": 4338
} | [
{
"body": "自分で解決できました。 \n`sudo chown -R $(whoami) $(brew --prefix)` \nとした後に`brew install python`を実行したところ`/usr/local`に`pip3`のシンボリックリンクができていました。\n\n/usr/localのownerがrootになっていたのではないかと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-29T12:45:06.607",
"id": "44366",
"last_activity_date": "2018-05-29T12:45:06.607",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5246",
"parent_id": "44308",
"post_type": "answer",
"score": 2
}
] | 44308 | 44366 | 44366 |
{
"accepted_answer_id": "44318",
"answer_count": 2,
"body": "`python`の画像処理系モジュールである`pillow`を使ってイメージから情報を取り出し、一旦`pickle`に保存して、 \n再度取り出した後、そのイメージをもとのイメージのように復元したい \nと考えています。保存とロードで同じものを取り出すところまではできたんですが、 \n再度そこから元と同じイメージを作り出すのに、`new`メソッドを用いて、 \nそれに読み込んだ情報を載せたいと思ったのですが、 \n`new`で作った`Image`クラスは、`fromarray`がないと言ってきます。 \n`asarray`で作った情報を保存しているので、`fromarray`出来るかなと思ったん \nですが、出来ませんでした。`Image.new()`で作ったオブジェクトは`Image`オブジェクトであり、`Image`オブジェクトはfromarrayメソッドを持っていると[公式](https://pillow.readthedocs.io/en/5.1.x/reference/Image.html)には書いてあるのですが。 \n`print(type(tumps)) \n<class 'numpy.ndarray'>`\n\n```\n\n re_im.fromarray(tumps)\n \n AttributeError: 'Image' object has no attribute 'fromarray'\n \n```\n\nこれがサンプルコードです。\n\n```\n\n from PIL import Image\n import numpy as np\n filename = 'any.png'\n import pickle\n im = Image.open(filename)\n data = np.asarray(im.getdata())\n f = open(\"test_file.dat\",\"wb\")\n \n dumps = pickle.dump(data,f)\n \n f = open(\"test_file.dat\",\"rb\")\n tumps = pickle.load(f)\n re_im = Image.new(im.mode, im.size)\n re_im.fromarray(tumps)\n re_im.show()\n \n \n python3.6.3 \n PIL.PILLOW_VERSION\n Out[10]: '5.1.0'\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T01:29:00.817",
"favorite_count": 0,
"id": "44312",
"last_activity_date": "2018-05-29T05:44:08.320",
"last_edit_date": "2018-05-29T05:43:04.983",
"last_editor_user_id": "24284",
"owner_user_id": "24284",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"pillow"
],
"title": "PIL(pillow)で新しく作ったイメージだと、一部のメソッドが欠如する原因と、イメージ情報の永続化と復元の方法について",
"view_count": 1414
} | [
{
"body": "`show()`のように`Image`クラス本体内で定義された関数(=メソッド)は、`re_im.show()`のように呼び出せますが、`fromarray()`のように`Image`クラス本体の外で定義された関数は、`re_im.fromarray()`のように呼び出せません。`Image.open()`と同様に`Image.fromarray()`で呼び出せば、少なくとも`AttributeError`は解消されます。\n\n詳細はソースコードを確認して下さい。\n\n<https://github.com/python-pillow/Pillow/blob/master/src/PIL/Image.py>",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T05:00:46.433",
"id": "44318",
"last_activity_date": "2018-05-28T05:13:19.633",
"last_edit_date": "2018-05-28T05:13:19.633",
"last_editor_user_id": "21092",
"owner_user_id": "21092",
"parent_id": "44312",
"post_type": "answer",
"score": 1
},
{
"body": "(解決しました。) \n永続化と復元の方は、Kohei TAMURAさんが解答いただいた後に追記し、それに対しての自己回答が見つかったのでここに追記します。\n\n`np.asarray(im.getdata())`が絶対必要だとなぜか思ってたんですが、むしろ余計な処理でした。これを消去し、`data =\nnp.array(im)`オープンしたイメージファイルをそのまま配列に載せるようにすればできました。\n\n```\n\n from PIL import Image\n import numpy as np\n filename = 'any_data.png'\n import pickle\n im = Image.open(filename)\n \n data = np.array(im)\n f = open(\"test_file.dat\",\"wb\")\n \n dumps = pickle.dump(data,f)\n \n f = open(\"test_file.dat\",\"rb\")\n tumps = pickle.load(f)\n \n array = Image.fromarray(tumps)\n \n array.show()\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-29T05:44:08.320",
"id": "44356",
"last_activity_date": "2018-05-29T05:44:08.320",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24284",
"parent_id": "44312",
"post_type": "answer",
"score": 0
}
] | 44312 | 44318 | 44318 |
{
"accepted_answer_id": "44317",
"answer_count": 1,
"body": "port forwardingを使って、リモートでMySQLにアクセスする方法について質問させていただきます。\n\n以下に簡単なdemo script(demo.sh)を作成しました。\n\n```\n\n echo $1;\n echo $2;\n echo \"$HOME/local/bin/mysql -u user -D WB -h$1 --port=$2\" (<-ここのコマンドは正常に動きます。)\n \n query() {\n $HOME/local/bin/mysql -u user -D WB -h$1 --port=$2\n }\n \n query \"begin;\\\n #some command for MySQL\n commit;\"\n \n```\n\nOSはubuntu16.04を使って、portの番号を13306に設定しております。\n\n```\n\n bash demo.sh xxxx 13306\n (xxxは実際のIP addressです。)\n \n```\n\nとタイプしますと、 \nmysql: [ERROR] /home/user/local/bin/mysql: Empty value for 'port' specified \nというエラーが出てきます。 \n自分の理解では、portの番号が指定されていないことがエラーの原因だと思います。\n\nしかし、3番目のechoの結果を、直接terminalにコピペしますと、正常にMySQLにアクセスできます。このことより、コマンド自体は問題ないと考えております。\n\n質問ですが、bash scriptではEmpty value for 'port'\nspecifiedとなってしまっている部分を、何とかport番号を指定する方法はありますでしょうか?\n\nーPオプションも試してみましたが、問題は解決しませんでした。\n\nもし何方かご存知でしたら、ご教授をお願いします。 \n何卒宜しくお願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T03:57:44.017",
"favorite_count": 0,
"id": "44315",
"last_activity_date": "2018-05-28T05:42:40.717",
"last_edit_date": "2018-05-28T05:42:40.717",
"last_editor_user_id": "3060",
"owner_user_id": "11048",
"post_type": "question",
"score": 0,
"tags": [
"mysql",
"ubuntu",
"bash"
],
"title": "MySQLのport番号をシェルスクリプトの関数内で指定する方法",
"view_count": 112
} | [
{
"body": "3行目のechoコマンドを query() の中に移動してみれば原因がわかると思います。 \n関数内の $1 $2 等は、関数外の値を引き継ぎません。関数呼び出し時に与えられた引数になります。\n\n今回のスクリプトの場合は $1 は \"begin;~\" の文字列になり、$2 は空になります。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T04:45:34.287",
"id": "44317",
"last_activity_date": "2018-05-28T04:45:34.287",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3249",
"parent_id": "44315",
"post_type": "answer",
"score": 4
}
] | 44315 | 44317 | 44317 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "Windows7にてBitnami Redmineを使用しているのですが、Redmine_Bunnerを導入した直後からInternal\nErrorが表示され、Redmineが使用できなくなってしまいました。Redmine_Bunnerが使用できなくても構わないので、Redmineを復元する方法を教えていただけないでしょうか。\n\n# 導入環境\n\n * Windows7(32bit)\n * Bitnami Redmine 3.4.4.stable\n\n# 実施手順\n\n下記エントリに記載させていただきました。 \n[Bitnami RedmineにRedmineBannerを導入したかった -\nQiita](https://qiita.com/asakura_0603/items/0571229b5c920c31b585)\n\n# 発生現象\n\nlocalhost/Redmineにアクセスすると、トップページが表示されず、\"Redmine 500\nerror\"というタイトルで下記エラーメッセージが表示されておりました。\n\n```\n\n Internal error\n \n An error occurred on the page you were trying to access.\n If you continue to experience problems please contact your Redmine administrator for assistance.\n \n If you are the Redmine administrator, check your log files for details about the error.\n \n```\n\nエラーログは下記のとおりです。\n\n```\n\n Started GET \"/redmine/\" for XXX.X.X.X at 2018-XX-XX XX:XX:XX +0900\n Processing by WelcomeController#index as HTML\n Current user: **** (id=1)\n Rendered welcome/index.html.erb within layouts/base (2.0ms)\n Missing template, responding with 404\n Rendered common/error.html.erb within layouts/base (0.0ms)\n Completed 500 Internal Server Error in 427ms (ActiveRecord: 236.0ms)\n \n ActionView::Template::Error (Missing partial banner/_project_body_bottom with {:locale=>[:ja, :en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :rsb]}. Searched in:\n * \"C:/Bitnami/redmine-3.4.4-3/apps/redmine/htdocs/plugins/redmine_work_time/app/views\"\n * \"C:/Bitnami/redmine-3.4.4-3/apps/redmine/htdocs/plugins/easy_gantt/app/views\"\n * \"C:/Bitnami/redmine-3.4.4-3/apps/redmine/htdocs/app/views\"\n * \"C:/Bitnami/redmine-3.4.4-3/ruby/lib/ruby/gems/2.3.0/gems/redmine_extensions-0.2.9/app/views\"\n ):\n 105: \n 106: \n 107: \n 108: \n 109: \n 110: \n 111: \n plugins/redmine_banner-master/lib/banner_application_hooks.rb:17:in `view_layouts_base_content'\n lib/redmine/hook.rb:61:in `block (2 levels) in call_hook'\n lib/redmine/hook.rb:61:in `each'\n lib/redmine/hook.rb:61:in `block in call_hook'\n lib/redmine/hook.rb:58:in `tap'\n lib/redmine/hook.rb:58:in `call_hook'\n lib/redmine/hook.rb:96:in `call_hook'\n app/views/layouts/base.html.erb:108:in `_app_views_layouts_base_html_erb___215493345_35494368'\n app/controllers/application_controller.rb:491:in `block (2 levels) in render_error'\n app/controllers/application_controller.rb:489:in `render_error'\n app/controllers/application_controller.rb:477:in `render_404'\n app/controllers/application_controller.rb:501:in `missing_template'\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T06:01:52.177",
"favorite_count": 0,
"id": "44319",
"last_activity_date": "2018-09-20T08:27:18.637",
"last_edit_date": "2018-05-28T06:27:19.953",
"last_editor_user_id": "3060",
"owner_user_id": "28692",
"post_type": "question",
"score": 1,
"tags": [
"redmine"
],
"title": "Bitnami RedmineにてRedmine_Bannerを導入するとInternal Error(505)が表示され使用不可になりました",
"view_count": 1285
} | [
{
"body": "[Readme](https://github.com/akiko-\npusu/redmine_banner/blob/master/README.md)に書いてる Unstall を実行してはいかがでしょうか。 \n事前にOSバックアップを取ることをオススメします。\n\n> Uninstall\n>\n> For Redmine 2.x, use the following command:\n```\n\n> rake redmine:plugins:migrate NAME=redmine_banner VERSION=0\n> RAILS_ENV=production\n> \n```\n\n>\n> For Redmine 1.x, use the following command:\n```\n\n> rake db:migrate_plugins NAME=redmine_banner VERSION=0\n> RAILS_ENV=production\n> \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T07:50:44.090",
"id": "44324",
"last_activity_date": "2018-05-28T07:50:44.090",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "44319",
"post_type": "answer",
"score": 0
},
{
"body": "こちらcentOS6.9ですが...\n\n * Redmine version 3.4.6.stable\n * redmine_banner 0.1.2\n\n同様にInternal errorとなり、ログも\"Missing template, responding with 404\"でほぼ同じです。 \npluginsディレクトリに解凍したplugin名は \"redmine_banner-master\"でしょうか。 \n当方はzip解凍したときに\"redmine_banner-master\"ができたためそのままインストールして症状が発生していました。 \nアンインストール後、\"redmine_banner\"にリネームして再インストールすることで無事Redmine Banner\npluginが利用できるようになりました。\n\n参考になれば幸いです",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T08:27:18.637",
"id": "48589",
"last_activity_date": "2018-09-20T08:27:18.637",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30187",
"parent_id": "44319",
"post_type": "answer",
"score": 1
}
] | 44319 | null | 48589 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Evernoteのようなツールを作成しています。Evernoteのように秘密にすべき情報を扱う場合、暗号化してデータベースに保存する必要があると思うのですが、暗号化した情報を全文検索エンジンで処理する方法が見つかりません、暗号化した情報を全文検索するにはどうすれば良いのでしょうか?(手がかりになるキーワードだけでも教えていただけると嬉しいです)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-05-28T06:11:32.630",
"favorite_count": 0,
"id": "44321",
"last_activity_date": "2022-05-31T06:07:04.403",
"last_edit_date": "2018-05-29T08:01:34.680",
"last_editor_user_id": "189",
"owner_user_id": "189",
"post_type": "question",
"score": 5,
"tags": [
"elasticsearch",
"lucene"
],
"title": "暗号化された情報の全文検索方法",
"view_count": 324
} | [] | 44321 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.