question dict | answers list | id stringlengths 2 5 | accepted_answer_id stringlengths 2 5 ⌀ | popular_answer_id stringlengths 2 5 ⌀ |
|---|---|---|---|---|
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "dockerにCentOSのイメージを立てて \nその中で,rails,mysql等をインストールしています(dockerfileでrailsやmysqlを設定しているわけではありません。あくまでvmwareみたいな使い方をしています。)\n\nそのさい\n\n> ruby -v \n> ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]\n\nとなっていたものが\n\ndocker抜けて(ctrl+p ctrl+q)をして \nもう一度dockerを立ち上げ(docker restart) \n先ほどの\n\n> ruby -v \n> bash: ruby: command not found\n\nとなります。なぜ変更が反映されないのでしょうか?ご教示お願いいたします。\n\n(fileとかが消えているということはありません)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T02:50:18.280",
"favorite_count": 0,
"id": "61121",
"last_activity_date": "2020-02-02T05:58:37.420",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36929",
"post_type": "question",
"score": 0,
"tags": [
"docker"
],
"title": "dockerのコンテナに変更されていない問題について",
"view_count": 112
} | [
{
"body": "> dockerfileでrailsやmysqlを設定しているわけではありません。あくまでvmwareみたいな使い方をしています。\n\nまさにコレが原因です。 \nDockerコンテナは一度再起動すると変更内容が揮発してしまいますので、Dockerfileでやるのが良いと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2020-02-02T05:39:45.540",
"id": "62714",
"last_activity_date":... | 61121 | null | 62714 |
{
"accepted_answer_id": "61130",
"answer_count": 1,
"body": "現在、RAD Studio 10.3でプログラミングを行っています。\n\n```\n\n class TfrmMain : public TForm\n {\n -------------(中略)-------------------\n public:\n TTrayIcon *pTray;\n -------------(中略)-------------------\n }\n \n \n id __fastcall TfrmMain::FormCloseQuery(TObject *Sender, bool &CanClose)\n {\n -------------(中略)-------------------\n pTray->Minimize();\n -------------(中略)-------------------\n }\n \n```\n\npTray->Minimize();行で次のようなエラーができてきます。\n\n> [bcc32c エラー] Main.cpp(1708): no member named 'Minimize' in\n> 'Vcl::Extctrls::TTrayIcon'\n\nこのMinimize()というメソッドや\n\n```\n\n pTray->BiMaximize;\n pTray->Hide = true;\n pTray->Minimize();\n pTray->Restore(); \n \n```\n\nこれらのメソッドやプロパティアクセスでエラーが出ます。 \nTTrayIconのドキュメントでも最新のものではなくなってしまったようなのですが、同等の機能のものはありますでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T05:41:21.593",
"favorite_count": 0,
"id": "61125",
"last_activity_date": "2019-12-05T07:19:31.357",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35993",
"post_type": "question",
"score": 0,
"tags": [
"rad-studio"
],
"title": "タスクトレイのメソッドやプロパティなどでエラー",
"view_count": 46
} | [
{
"body": "Minimize()は\n\n```\n\n Application->Minimize();\n ShowWindow(Application->Handle, SW_HIDE);\n \n```\n\nRestore()は\n\n```\n\n Application->Restore();\n ShowWindow(Application->Handle, SW_RESTORE);\n SetForegroundWindow(Application->Handle);\n \n```\n\nC++Builder6のTT... | 61125 | 61130 | 61130 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "openxlsxをインストールした後、サイトにあったので `read.xlsx(book1.xlsx)` を実行したのですが \"ファイルが見つからない\"\nと出ました。 \nbook1は存在するのですが原因が分かりません。教えていただければ幸いです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T06:28:36.563",
"favorite_count": 0,
"id": "61126",
"last_activity_date": "2019-12-05T16:59:37.240",
"last_edit_date": "2019-12-05T16:59:37.240",
"last_editor_user_id": "3060",
"owner_user_id": "36934",
"post_type": "question",
"score": 0,
"tags": [
"r"
],
"title": "R で Excel ファイルを読み込もうとすると「ファイルが見つからない」エラーになってしまう",
"view_count": 4268
} | [
{
"body": "2点考えられます。 \n①ファイル名に\"\"を入れていない \n`read.xlsx(book1.xlsx)`ではなく`read.xlsx(\"book1.xlsx\")`となります。 \nエラーを見ていると実際には\"\"入れてるかもしれませんが...\n\n②保存したデータが作業ディレクトリに入っていない。 \nまずRで`getwd()`と入力するとフォルダの場所が出てきます。 \nRはそのフォルダの位置を基準にしています。\n\nまだRに慣れてなければそのフォルダにデータを入れて試してみてください。 \nもし「相対パス」や「絶対パス」という意味がわかれば他のフォルダに入ってい... | 61126 | null | 61148 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、Borland C++ Builder 6で作成されたソースコードをRAD-Studio10.3でもビルドできるように移行作業を行っております。\n\n取り掛かり始めの時は、とりあえずすべてのソースコードを新規プロジェクトに追加させてビルドエラー内容からコード修正などを実施してなるべく元のソースコードの形を大きく変更することなく修正作業を行っていました。 \nしかし、エラー内容から明確な原因がわからないことが多く、一旦諦めてしまいました。\n\nその後、新規プロジェクトからコンポーネントを1個ずつ追加して、エラーが出たらその都度修正を実施して、エラーがないことを確認しながら作業を進めています。\n\n作業がかなり進んできたのですが、コンポーネントを追加してその時にメソッドのコーディングもしていった結果、移行元のソースコードのメソッドの場所がバラバラになってしまっている状態です。\n\nとりあえず一旦整理や、差分ソフトで元ソースとの違いなどを確認するため、元のソースとなるべく場所を同じにしてくれるようなエディタソフトや機能などを教えて下さい。 \nよろしくお願い致します。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T07:55:25.937",
"favorite_count": 0,
"id": "61131",
"last_activity_date": "2019-12-05T13:59:44.320",
"last_edit_date": "2019-12-05T13:59:44.320",
"last_editor_user_id": "3060",
"owner_user_id": "35993",
"post_type": "question",
"score": 0,
"tags": [
"atom-editor",
"sublimetext"
],
"title": "元のソースコードのメソッドの場所をなるべく同じにしてくれるようなテキストエディタ",
"view_count": 83
} | [] | 61131 | null | null |
{
"accepted_answer_id": "61138",
"answer_count": 2,
"body": "以下のようにPythonを使って、一定間隔でUDP通信するプログラムを書いています。\n\nGUIの右上の閉じるボタンを押してプログラムを終了させた場合、スレッドは \n`self.thread.setDaemon(True)` によって終了するのですが、socketは `close()`\nされないまま終わってしまっています。(Stopボタンを押した場合はsocketはclose()されます)\n\n[](https://i.stack.imgur.com/O5ZPk.jpg)\n\nこのように `close()` されずにプログラムが終了した場合、どのような問題がありますか? \nまた、右上の閉じるボタンでプログラムを終了した場合でもsocketを `close()` するにはどうしたらよいですか?\n\n* * *\n\n**ソースコード**\n\n```\n\n import tkinter as tk\n import threading\n import time\n from socket import socket, AF_INET,SOCK_DGRAM,SOL_SOCKET,SO_BROADCAST,SOCK_STREAM\n \n class threading_and_sleepGUI():\n def __init__(self):\n self.stop_flag=False\n self.thread=None\n self.s = None\n \n def worker(self):\n msg = \"test\"\n self.s.sendto(msg.encode(), (\"127.0.0.1\", 8888))\n time.sleep(8)\n \n def scheduler(self,interval, f, wait = True):\n base_time = time.time()\n next_time = 0\n while not self.stop_flag:\n t = threading.Thread(target = f)\n t.start()\n if wait:\n t.join()\n next_time = ((base_time - time.time()) % interval) or interval\n time.sleep(next_time)\n \n def start(self):\n if not self.thread:\n self.s = socket(AF_INET, SOCK_DGRAM)\n self.s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)\n \n self.thread = threading.Thread(target=self.scheduler, args=(1, self.worker, False))\n self.thread.setDaemon(True)\n self.stop_flag=False\n self.thread.start()\n \n def stop(self):\n if self.thread:\n self.s.close()\n self.stop_flag=True\n self.thread.join()\n self.thread=None\n \n def GUI_start(self):\n root=tk.Tk()\n Button001=tk.Button(root,text=\"Start\",command=self.start)\n Button001.pack()\n Button002=tk.Button(root,text=\"Stop\",command=self.stop)\n Button002.pack()\n root.mainloop()\n \n t = threading_and_sleepGUI()\n t.GUI_start()\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T08:07:53.860",
"favorite_count": 0,
"id": "61132",
"last_activity_date": "2019-12-05T17:11:36.287",
"last_edit_date": "2019-12-05T17:11:36.287",
"last_editor_user_id": "3060",
"owner_user_id": "34471",
"post_type": "question",
"score": 3,
"tags": [
"python",
"network",
"socket",
"udp"
],
"title": "プログラムが意図しない終了方法をした時の、socketのclose()について",
"view_count": 1049
} | [
{
"body": "プログラム(プロセス)が終了したら、そこで使われていたソケットなどはcloseされますから、心配いりません。 \nパケットが届かない可能性があるUDP通信ですから、受信側にも影響ないです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T09:18:11.130",
"id": "61138",
"last_activity_date": "2019-12-05T09:18:11.130",
"last_edit_date"... | 61132 | 61138 | 61138 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "VirtualboxのUbuntuにおいて \nPythonの対話モードで\n\n```\n\n import tensorflow\n \n```\n\nと入力したところ\n\n```\n\n AttributeError : module 'numpy' has no attribute 'bool_'\n \n```\n\nというエラーが出てきます。\n\n\"import numpy\"と入力した際には何もエラーが出てきませんでした。 \nどのようにしたらエラーを防げるか教えていただきたいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T09:08:54.413",
"favorite_count": 0,
"id": "61136",
"last_activity_date": "2023-04-17T05:04:25.477",
"last_edit_date": "2019-12-05T12:03:31.050",
"last_editor_user_id": "13199",
"owner_user_id": "36938",
"post_type": "question",
"score": 0,
"tags": [
"python",
"tensorflow",
"numpy"
],
"title": "AttributeError : module 'numpy' has no attribute 'bool_'",
"view_count": 3479
} | [
{
"body": "以下の記事の様に良くある間違いでしょう。\n\nカレントフォルダとか、Pythonのimport対象フォルダパスのどこか、本物のnumpyがあるよりも先に検索されるフォルダのどこかに、`numpy.py`というファイルを作ってしまったのだと思われます。 \nそれがimportされているので、質問のエラーが発生しているのでしょう。 \n紹介記事の中にもあるように、よく使われそうな名前でファイルを作るのは止めましょう。\n\n[Pythonで module 'XXX' has no attribute 'XXX'\nが出た時の解決方法](https://qiita.com/tonosamart/... | 61136 | null | 61152 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "DockerでCentOS6を立ててその中に入り、MySQLをインストール \n(決してMySQLのコンテナを立てていません。※そのため,Dockerfileとdocker-compose.ymlがない状態です)\n\nこのとき,ローカルの外部SQLWorkBenchから接続するにはどうしたらいいのでしょうか?\n\nMySQLのコンテナをdockerで立てたものから,mysqlworkbenchとの接続の記事はたくさんあるのですが、上のケースは見当たりません。\n\nfirewallのポートを開ければつながるという記事も見て、iptablesをインストールしてport3306を開けたのですが、接続できませんでした。\n\nご存知の方ご教示お願いいたします。\n\n**実行環境** \nDocker version 19.03.5, build 633a0ea \nMySQL Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline\n5.1 \nCentOS 6.10 \nMySQLWorkBench:8.0.18\n\n* * *\n```\n\n > docker ps\n CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n 17ab93fdf500 38596547d8dd \"/bin/bash --login\" 3 minutes ago Up 3 minutes 0.0.0.0:3000->3000/tcp, 0.0.0.0:3306->3306/tcp rails_main\n \n```\n\nとportは3000,3306を開けております。(よって、rails s して時,licalhost:3000でブラウザに写っています)\n\nDocker内のCent0S6\n\n```\n\n >vi /etc/my.cnf\n \n [mysqld]\n datadir=/var/lib/mysql\n socket=/var/lib/mysql/mysql.sock\n user=mysql\n # Disabling symbolic-links is recommended to prevent assorted security risks\n symbolic-links=0\n default-character-set=utf8\n bind-address=127.0.0.1 # これを追加して、localhostからのを許可\n \n [mysqld_safe]\n log-error=/var/log/mysqld.log\n pid-file=/var/run/mysqld/mysqld.pid\n \n [client]\n default-character-set=utf8\n \n```\n\n```\n\n vi /etc/hosts.allow\n \n mysqld: ALL: allow # 追加\n \n```\n\n```\n\n >iptables --list \n (docker runの時に--cap-add=NET_ADMIN をつけ,firewallが起動できるようにしている)\n \n Chain INPUT (policy DROP)\n target prot opt source destination \n ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:http \n ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ftp-data \n ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh \n ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:hbci \n ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:mysql ## ここsqlを全て受け付ける\n \n Chain FORWARD (policy DROP)\n target prot opt source destination \n \n Chain OUTPUT (policy ACCEPT)\n target prot opt source destination \n \n Chain RH-Firewall-1-INPUT (0 references)\n target prot opt source destination \n \n Chain SERVICE (0 references)\n target prot opt source destination \n \n```\n\nMySQL Workbench の接続は以下の通りです。\n\n * Conection Method: Standard(TCP/IP)\n * host:127.0.0.1\n * port:3306\n * name:root\n * password:123456\n\nこれで接続を行っています。エラー内容は以下です\n\n```\n\n Failed to Connect to MySQL at 127.0.0.1:3306 with user root\n Lost connection to MySQL server at 'reading initial communication packet', system error: 0\n \n```\n\nちなみに\n\n> select host,user ,password from mysql.user;\n```\n\n +--------------+----------+-------------------------------------------+\n | Host | User | Password |\n +--------------+----------+-------------------------------------------+\n | localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |\n | 0087ea0ee65d | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |\n | 127.0.0.1 | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |\n | localhost | | |\n | 0087ea0ee65d | | |\n | % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |\n +--------------+----------+-------------------------------------------+\n \n```\n\n*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 これが123456のhashされたものかな?",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T09:39:53.897",
"favorite_count": 0,
"id": "61140",
"last_activity_date": "2019-12-10T00:39:06.197",
"last_edit_date": "2019-12-10T00:39:06.197",
"last_editor_user_id": "3060",
"owner_user_id": "36929",
"post_type": "question",
"score": 1,
"tags": [
"mysql",
"docker",
"mysql-workbench"
],
"title": "Docker コンテナ上の MySQLにホストOSから MySQL Workbenchで接続するには?",
"view_count": 947
} | [] | 61140 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[Dockerで立ち上げた開発環境をVS Codeで開く! -\nQiita](https://qiita.com/yoskeoka/items/01c52c069123e0298660)\n\nこの記事の通りで、Dockerの環境をvscodeで開きたいのですが、うまく行きません。\n\n```\n\n docker run -td --name centos6.8 docker.io/centos:centos6.8\n \n```\n\nこれで作られたイメージにvscodeで接続すると以下のようなエラーが出ます\n\nローカル環境はmacOS Catalia 10.15.1 \nvscode に Remote -Container 0.83.1 をインストール済み \ndocker -v \nDocker version 19.03.5, build 633a0ea \ndocker-composeを作らないとダメなのでしょうか? \nそれともCentOSはそもそもダメなのでしょうか?\n\n調べても出てこなかったので、ご存知の方はご教示お願いいたいします。\n\n```\n\n Setting up container with fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3\n Run: docker exec fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3 /bin/sh -c (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null\n Run: docker cp fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3:/etc/passwd -\n Run: docker exec fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3 test -d /root/.vscode-server\n Run: docker exec fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3 test -d /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520\n Run: docker exec fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3 test -d /root/.vscode-server/extensions\n Run: docker exec -w /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520 -e VSCODE_AGENT_FOLDER=/root/.vscode-server fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3 /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/server.sh --install-extension MS-CEINTL.vscode-language-pack-ja --force\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n Run: docker exec -w / -u 0 fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3 /bin/sh -c command -v git >/dev/null 2>&1 && git config --system credential.helper '!f() { command -v code >/dev/null 2>&1 && code --gitCredential $*; }; f' || true\n Run: docker exec -w /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520 -e SHELL=/bin/bash -e VSCODE_AGENT_FOLDER=/root/.vscode-server fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3 /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/server.sh --disable-user-env-probe --port 0\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/node)\n Command failed: docker exec -w /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520 -e SHELL=/bin/bash -e VSCODE_AGENT_FOLDER=/root/.vscode-server fe3c8b4390541e9a90775920c6ee567088bc6ec70f1ae08c9a78dc96c4c9a4f3 /root/.vscode-server/bin/f359dd69833dd8800b54d458f6d37ab7c78df520/server.sh --disable-user-env-probe --port 0\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T10:20:35.850",
"favorite_count": 0,
"id": "61143",
"last_activity_date": "2019-12-05T11:41:21.433",
"last_edit_date": "2019-12-05T11:41:21.433",
"last_editor_user_id": "3060",
"owner_user_id": "36929",
"post_type": "question",
"score": 1,
"tags": [
"docker",
"vscode"
],
"title": "Dockerの開発環境をvscodeで開くには",
"view_count": 548
} | [
{
"body": "[Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-\nvscode-remote.remote-containers) の動作要件を見ると、コンテナ側で CentOS を使う場合は `7`\n以上が必要なようです。\n\n> **System Requirements** \n> **Containers:** x86_64 Debian 8+, Ubuntu 16.04+, CentOS / RHEL 7+, Alpine\n> Linux based containers.\n\nエラ... | 61143 | null | 61149 |
{
"accepted_answer_id": "61180",
"answer_count": 1,
"body": "Herokuでフラスコアプリケーションをデプロイしようとしているのですが、 \n動作時にエラーが発生してしまいます。 \nアプリは、画像をOpenCVによって分析するものですが、その際にエラーが発生します。\n\nheroku logでエラーを確認すると\n\n```\n\n recognizer = cv2.face.LBPHFaceRecognizer_create()\n AttributeError: module 'cv2.cv2' has no attribute 'face'\n \n```\n\nと表示されています。 \nローカル環境では、問題なく動作するので、 \nopenCVをHerokuに正しく導入できていないと思ったので、以下のコードをheroku.ymlに追加しpushしました。\n\n```\n\n build:\n languages:\n - python\n packages:\n - libopencv-dev\n run:\n web: gunicorn server:app --log-file -\n \n```\n\nこれでも、同じエラーが発生してしまいます... \nopencv_contrib_pythonやopencv-pythonを再インストールしても状況は変わりません。 \n今の所、Herokuでopencv_contrib_pythonをインポートする必要があると考えているのですが \nどのようにすべきかわかりません。\n\nご教示いただけますと幸いです。\n\n以下、こちらが実際のコードになります。 \n何卒よろしくお願いいたします。\n\n```\n\n def load_model():\n global recognizer\n print(\" * Loading pre-trained model ...\")\n cascadePath = './haarcascade_frontalface_alt.xml'\n faceCascade = cv2.CascadeClassifier(cascadePath)\n recognizer = cv2.face.LBPHFaceRecognizer_create()\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T10:58:10.507",
"favorite_count": 0,
"id": "61146",
"last_activity_date": "2019-12-06T15:11:47.753",
"last_edit_date": "2019-12-06T01:14:12.063",
"last_editor_user_id": "36940",
"owner_user_id": "36940",
"post_type": "question",
"score": 0,
"tags": [
"python",
"opencv",
"heroku",
"flask"
],
"title": "Heroku上でのエラー\"AttributeError: module 'cv2.cv2' has no attribute 'face'\"",
"view_count": 9341
} | [
{
"body": "Herokuで当てはまるかどうか分かりませんが、以下のいくつかの記事を見ると、\n\n`opencv-python`と`opencv-contrib-python`の両方をインストールしてはいけない。 \nどちらか片方のみをインストールすること、そして`face`を使うなら`opencv-contrib-python`らしいです。\n\nただし未承認ですが、逆に両方インストールで解決したという回答もあります。\n\n[AttributeError: module 'cv2.cv2' has no attribute 'faces' in\nOpenCV](https://stackoverfl... | 61146 | 61180 | 61180 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[GithubPage](https://defineprogram.github.io/)\n\n手元だと、\"記事一覧\"が2つ出たりしない上に、数式も正しく表示されます。 \nしかし、リモート上だと違う結果になってしまいます。 \njekyllは最新版を使っています。 \n何が問題なんでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T11:40:34.937",
"favorite_count": 0,
"id": "61150",
"last_activity_date": "2019-12-05T12:32:15.777",
"last_edit_date": "2019-12-05T11:47:41.280",
"last_editor_user_id": "19110",
"owner_user_id": "36487",
"post_type": "question",
"score": 0,
"tags": [
"github-pages",
"jekyll"
],
"title": "GitHub Pageのjekyllが手元と違う出力をします",
"view_count": 103
} | [
{
"body": "トップページで記事一覧がふたつ表示されているのは、ページの `layout` が `post` になっているからかもしれません。今回使っているテーマの\n[minima](https://github.com/jekyll/minima) では `home` が index.html\n用のレイアウトのようです。\n\n[この記事](https://defineprogram.github.io/jekyll/2019/12/05/welcome-to-\njekyll.html)で数式が表示されてないのは、MathJax を HTTP でロードしようとしているので Mixed Content\... | 61150 | null | 61151 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "こんばんは。夜分遅くに失礼いたします。 \nお世話になります。 \nDebian 10のbashシェルで`sudo add-apt-repository ppa:fingerprint/fingerprint-\ngui`を実行しますと、下記のメッセージが出てきます。\n\n```\n\n $ sudo add-apt-repository ppa:fingerprint/fingerprint-gui\n gpg: keybox '/tmp/tmpaa42a0x0/pubring.gpg' created\n gpg: /tmp/tmpaa42a0x0/trustdb.gpg: trustdb created\n gpg: key EFD5FA852F20733F: public key \"Launchpad fprint\" imported\n gpg: Total number processed: 1\n gpg: imported: 1\n gpg: no valid OpenPGP data found.\n Exception in thread Thread-1:\n Traceback (most recent call last):\n File \"/usr/lib/python3.7/threading.py\", line 917, in _bootstrap_inner\n self.run()\n File \"/usr/lib/python3.7/threading.py\", line 865, in run\n self._target(*self._args, **self._kwargs)\n File \"/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py\", line 688, in addkey_func\n func(**kwargs)\n File \"/usr/lib/python3/dist-packages/softwareproperties/ppa.py\", line 386, in add_key\n return apsk.add_ppa_signing_key()\n File \"/usr/lib/python3/dist-packages/softwareproperties/ppa.py\", line 273, in add_ppa_signing_key\n cleanup(tmp_keyring_dir)\n File \"/usr/lib/python3/dist-packages/softwareproperties/ppa.py\", line 234, in cleanup\n shutil.rmtree(tmp_keyring_dir)\n File \"/usr/lib/python3.7/shutil.py\", line 491, in rmtree\n _rmtree_safe_fd(fd, path, onerror)\n File \"/usr/lib/python3.7/shutil.py\", line 449, in _rmtree_safe_fd\n onerror(os.unlink, fullname, sys.exc_info())\n File \"/usr/lib/python3.7/shutil.py\", line 447, in _rmtree_safe_fd\n os.unlink(entry.name, dir_fd=topfd)\n FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.extra'\n \n```\n\n`Traceback (most recent call last):`に続くエラーメッセージと、 \n`FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-\nagent.extra'`の解決法をご教授願ます。\n\n追記1\n\n[How to enable fingerprint scanner support on\nLinux](https://www.addictivetips.com/ubuntu-linux-tips/enable-fingerprint-\nscanner-support-on-linux/)\n\n上記リンクを参考にしたのですが、、 \n間違えて下記のコマンドを実行しましたら、`sudo apt-get update`を実行しました際に大量のエラーが出てまいりました。 \n`sudo apt-key adv --keyserver keyserver.ubuntu.com --recv EFD5FA852F20733F`\n\n下記がエラーの内容です。\n\n```\n\n Hit:1 http://security.debian.org/debian-security buster/updates InReleaseHit:2 http://ftp.jaist.ac.jp/debian buster InRelease Err:1 http://security.debian.org/debian-security buster/updates InRelease yusuke@debian:~$ sudo apt-get update\n Hit:1 http://ftp.jaist.ac.jp/debian buster InRelease\n Hit:2 http://security.debian.org/debian-security buster/updates InRelease \n Ign:3 http://ftp.jp.d\n \n (長い空行)\n \n W: Failed to fetch http://ftp.jaist.ac.jp/debian/dists/buster/InRelease Splitting up /var/lib/apt/lists/ftp.jaist.ac.jp_debian_dists_buster_InRelease into data and signature failed\n W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Splitting up /var/lib/apt/lists/security.debian.org_debian-security_dists_buster_updates_InRelease into data and signature failed\n W: Failed to fetch http://ftp.jaist.ac.jp/debian/dists/buster-updates/InRelease Error writing to output file - write (28: No space left on device) [IP: 150.65.7.130 80]\n W: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/InRelease Splitting up /var/lib/apt/lists/security.debian.org_debian-security_dists_stretch_updates_InRelease into data and signature failed\n W: Failed to fetch http://ftp.jp.debian.org/debian/dists/stretch-updates/InRelease Error writing to output file - write (28: No space left on device) [IP: 133.5.166.3 80]\n W: Failed to fetch http://ppa.launchpad.net/fingerprint/fingerprint-gui/ubuntu/dists/bionic/InRelease Error writing to output file - write (28: No space left on device) [IP: 91.189.95.83 80]\n W: Failed to fetch http://ppa.launchpad.net/fingerprint/fingerprint-gui/ubuntu/dists/focal/InRelease Splitting up /var/lib/apt/lists/ppa.launchpad.net_fingerprint_fingerprint-gui_ubuntu_dists_focal_InRelease into data and signature failed\n W: Failed to fetch https://packagecloud.io/slacktechnologies/slack/debian/dists/jessie/InRelease Splitting up /var/lib/apt/lists/packagecloud.io_slacktechnologies_slack_debian_dists_jessie_InRelease into data and signature failed\n W: Failed to fetch http://ftp.jp.debian.org/debian/dists/stretch/Release.gpg At least one invalid signature was encountered.\n W: Failed to fetch http://repo.vivaldi.com/stable/deb/dists/stable/Release.gpg At least one invalid signature was encountered.\n W: Some index files failed to download. They have been ignored, or old ones used instead.\n \n \n```\n\n解決法をご教授願います。\n\n追記2 \n`No space left on device`というエラーメッセージが出ておりましたので、@metropolis 様のおっしゃるように`sudo apt\nclean`を実行致しました。\n\nその後、`sudo apt update`を実行しますと、下記のエラー?が出てきました。\n\n```\n\n $ sudo apt-get update\n Hit:1 http://ftp.jaist.ac.jp/debian buster InRelease\n Hit:2 http://ftp.jaist.ac.jp/debian buster-updates InRelease \n Hit:3 http://security.debian.org/debian-security buster/updates InRelease \n Hit:4 http://security.debian.org/debian-security stretch/updates InRelease \n Ign:5 http://ftp.jp.debian.org/debian stretch InRelease \n Hit:6 http://ftp.jp.debian.org/debian stretch-updates InRelease \n Hit:7 http://ftp.jp.debian.org/debian stretch Release \n Hit:8 http://ppa.launchpad.net/fingerprint/fingerprint-gui/ubuntu bionic InRelease \n Ign:9 http://repo.vivaldi.com/stable/deb stable InRelease \n Hit:10 http://repo.vivaldi.com/stable/deb stable Release \n Hit:13 http://ppa.launchpad.net/fingerprint/fingerprint-gui/ubuntu focal InRelease \n Hit:11 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease \n Reading package lists... Done\n \n```\n\nIgn(無視)と出てきておりますが、`/etc/apt/sources.list`と`/etc/apt/sources.list.d/vivaldi.list`と \n`/etc/apt/sources.list.d/vivaldi.list.d`を見ましても、\n\n`http://ftp.jp.debian.org/debian stretch InRelease` \n`http://repo.vivaldi.com/stable/deb stable InRelease`\n\n上記の2つの行は見当たりませんでした。どのようにすれば解決できるのでしょうか。 \nご教授願ます。\n\n[teratail](https://teratail.com/questions/227636?modal=q-comp)にもマルチポストさせていただきますのでご容赦願います。",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T14:32:29.737",
"favorite_count": 0,
"id": "61155",
"last_activity_date": "2019-12-05T22:09:25.727",
"last_edit_date": "2019-12-05T22:09:25.727",
"last_editor_user_id": "36906",
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"debian",
"apt"
],
"title": "$ sudo add-apt-repository ppa:fingerprint/fingerprint-guiを実行すると、gpg: no valid OpenPGP data found.と出て、Traceback (most recent call last):と出ます。",
"view_count": 621
} | [
{
"body": "<https://launchpad.net/~fingerprint/+archive/ubuntu/fingerprint-gui> という PPA は\nUbuntu 向けに作られているので、Debian で無理矢理使おうとしてエラーに繋がっていそうです。\n\n<https://wiki.debian.org/DontBreakDebian> より引用:\n\n> Repositories that can create a FrankenDebian if used with Debian Stable:\n>\n> * Debian _testing_ release (curr... | 61155 | null | 61156 |
{
"accepted_answer_id": "61167",
"answer_count": 1,
"body": "おはようございます。お世話になります。\n\nActivityWatchというManicTimeと同等の機能のOSSをDebian 10にインストールしようとしておりますが、`make\nbuild`を実行しますと下記のメッセージが出てきました。\n\n```\n\n 省略\n Images and other types of assets omitted.\n \n DONE Build complete. The dist directory is ready to be deployed.\n INFO Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html\n \n make[2]: Leaving directory '/home/yusuke/activitywatch/aw-server/aw-webui'\n cp -r aw-webui/dist/* aw_server/static/\n rm -rf aw-webui/node_modules/.cache # Needed for https://github.com/ActivityWatch/activitywatch/pull/274, works around https://github.com/pypa/pip/issues/6279\n pip3 install . -r requirements.txt\n Processing /home/yusuke/activitywatch/aw-server\n Requirement already satisfied: aniso8601==8.0.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (8.0.0)\n Requirement already satisfied: appdirs==1.4.3 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (1.4.3)\n Requirement already satisfied: attrs==19.3.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (19.3.0)\n Requirement already satisfied: click==7.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (7.0)\n Requirement already satisfied: flask-cors==3.0.8 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (3.0.8)\n Requirement already satisfied: flask-restplus==0.13.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 7)) (0.13.0)\n Requirement already satisfied: flask==1.1.1 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (1.1.1)\n Requirement already satisfied: aw-core from git+https://github.com/ActivityWatch/aw-core.git@ef604753fed1aa972ab211314779c042d8180b64#egg=aw-core in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 9)) (0.4.1)\n Requirement already satisfied: importlib-metadata==0.23 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 10)) (0.23)\n Requirement already satisfied: itsdangerous==1.1.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 11)) (1.1.0)\n Requirement already satisfied: jinja2==2.10.3 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 12)) (2.10.3)\n Requirement already satisfied: jsonschema==3.1.1 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 13)) (3.1.1)\n Requirement already satisfied: markupsafe==1.1.1 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 14)) (1.1.1)\n Requirement already satisfied: more-itertools==7.2.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 15)) (7.2.0)\n Requirement already satisfied: pyrsistent==0.15.5 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 16)) (0.15.5)\n Requirement already satisfied: python-json-logger==0.1.11 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 17)) (0.1.11)\n Requirement already satisfied: pytz==2019.3 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 18)) (2019.3)\n Requirement already satisfied: six==1.13.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 19)) (1.13.0)\n Requirement already satisfied: werkzeug==0.16.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 20)) (0.16.0)\n Requirement already satisfied: zipp==0.6.0 in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 21)) (0.6.0)\n Requirement already satisfied: strict-rfc3339==0.7 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 9)) (0.7)\n Requirement already satisfied: peewee==3.11.2 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 9)) (3.11.2)\n Requirement already satisfied: iso8601==0.1.12 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 9)) (0.1.12)\n Requirement already satisfied: takethetime==0.3.1 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 9)) (0.3.1)\n Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from jsonschema==3.1.1->-r requirements.txt (line 13)) (40.8.0)\n Building wheels for collected packages: aw-server\n Running setup.py bdist_wheel for aw-server ... done\n Stored in directory: /home/yusuke/.cache/pip/wheels/ac/70/65/307cb1a325c39e099640dfb2db0354f6cab057f1c33113dff5\n Successfully built aw-server\n Installing collected packages: aw-server\n Found existing installation: aw-server 0.8.dev0+c6433ea\n Uninstalling aw-server-0.8.dev0+c6433ea:\n Successfully uninstalled aw-server-0.8.dev0+c6433ea\n The script aw-server is installed in '/home/yusuke/.local/bin' which is not on PATH.\n Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. \n Successfully installed aw-server-0.8.dev0+c6433ea\n make[1]: Leaving directory '/home/yusuke/activitywatch/aw-server'\n make --directory=aw-watcher-afk build DEV=\n make[1]: Entering directory '/home/yusuke/activitywatch/aw-watcher-afk'\n pip3 install . -r requirements.txt\n Ignoring pyobjc-framework-Quartz: markers 'sys_platform == \"darwin\"' don't match your environment\n Processing /home/yusuke/activitywatch/aw-watcher-afk\n Requirement already satisfied: aw-core from git+https://github.com/ActivityWatch/aw-core.git@master#egg=aw-core in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (0.4.1)\n Requirement already satisfied: aw-client from git+https://github.com/ActivityWatch/aw-client.git@master#egg=aw-client in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (0.3)\n Requirement already satisfied: python-xlib from git+https://github.com/python-xlib/python-xlib.git@master#egg=python-xlib in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (0.25)\n Requirement already satisfied: pyuserinput from git+https://github.com/PyUserInput/PyUserInput.git@ac2d4c7a7f4b1a72e70b1a2ef8925d5312fb12bc#egg=pyuserinput in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (0.1.12)\n Requirement already satisfied: six==1.13.0 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (1.13.0)\n Requirement already satisfied: jsonschema==3.1.1 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (3.1.1)\n Requirement already satisfied: peewee==3.11.2 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (3.11.2)\n Requirement already satisfied: importlib-metadata==0.23 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.23)\n Requirement already satisfied: attrs==19.3.0 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (19.3.0)\n Requirement already satisfied: appdirs==1.4.3 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (1.4.3)\n Requirement already satisfied: python-json-logger==0.1.11 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.1.11)\n Requirement already satisfied: pyrsistent==0.15.5 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.15.5)\n Requirement already satisfied: strict-rfc3339==0.7 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.7)\n Requirement already satisfied: zipp==0.6.0 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.6.0)\n Requirement already satisfied: more-itertools==7.2.0 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (7.2.0)\n Requirement already satisfied: iso8601==0.1.12 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.1.12)\n Requirement already satisfied: takethetime==0.3.1 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.3.1)\n Requirement already satisfied: persist-queue in /home/yusuke/.local/lib/python3.7/site-packages (from aw-client->-r requirements.txt (line 2)) (0.3.5)\n Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from aw-client->-r requirements.txt (line 2)) (2.21.0)\n Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from jsonschema==3.1.1->aw-core->-r requirements.txt (line 1)) (40.8.0)\n Building wheels for collected packages: aw-watcher-afk\n Running setup.py bdist_wheel for aw-watcher-afk ... done\n Stored in directory: /home/yusuke/.cache/pip/wheels/c8/07/87/d1071a2e48fee0885f193552e115f2d5eba9e93cfa0ac95fe7\n Successfully built aw-watcher-afk\n Installing collected packages: aw-watcher-afk\n Found existing installation: aw-watcher-afk 0.2\n Uninstalling aw-watcher-afk-0.2:\n Successfully uninstalled aw-watcher-afk-0.2\n The script aw-watcher-afk is installed in '/home/yusuke/.local/bin' which is not on PATH.\n Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. \n Successfully installed aw-watcher-afk-0.2\n make[1]: Leaving directory '/home/yusuke/activitywatch/aw-watcher-afk'\n make --directory=aw-watcher-window build DEV=\n make[1]: Entering directory '/home/yusuke/activitywatch/aw-watcher-window'\n pip3 install . -r requirements.txt\n Ignoring wmi: markers 'sys_platform == \"win32\"' don't match your environment\n Ignoring pypiwin32: markers 'sys_platform == \"win32\"' don't match your environment\n Processing /home/yusuke/activitywatch/aw-watcher-window\n Requirement already satisfied: aw-core from git+https://github.com/ActivityWatch/aw-core.git@master#egg=aw-core in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (0.4.1)\n Requirement already satisfied: aw-client from git+https://github.com/ActivityWatch/aw-client.git@master#egg=aw-client in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (0.3)\n Requirement already satisfied: python-xlib in /home/yusuke/.local/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (0.25)\n Requirement already satisfied: pyrsistent==0.15.5 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.15.5)\n Requirement already satisfied: takethetime==0.3.1 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.3.1)\n Requirement already satisfied: iso8601==0.1.12 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.1.12)\n Requirement already satisfied: strict-rfc3339==0.7 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.7)\n Requirement already satisfied: jsonschema==3.1.1 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (3.1.1)\n Requirement already satisfied: more-itertools==7.2.0 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (7.2.0)\n Requirement already satisfied: peewee==3.11.2 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (3.11.2)\n Requirement already satisfied: zipp==0.6.0 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.6.0)\n Requirement already satisfied: python-json-logger==0.1.11 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.1.11)\n Requirement already satisfied: six==1.13.0 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (1.13.0)\n Requirement already satisfied: appdirs==1.4.3 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (1.4.3)\n Requirement already satisfied: attrs==19.3.0 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (19.3.0)\n Requirement already satisfied: importlib-metadata==0.23 in /home/yusuke/.local/lib/python3.7/site-packages (from aw-core->-r requirements.txt (line 1)) (0.23)\n Requirement already satisfied: persist-queue in /home/yusuke/.local/lib/python3.7/site-packages (from aw-client->-r requirements.txt (line 2)) (0.3.5)\n Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from aw-client->-r requirements.txt (line 2)) (2.21.0)\n Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from jsonschema==3.1.1->aw-core->-r requirements.txt (line 1)) (40.8.0)\n Building wheels for collected packages: aw-watcher-window\n Running setup.py bdist_wheel for aw-watcher-window ... done\n Stored in directory: /home/yusuke/.cache/pip/wheels/48/df/28/2ba39fe69caabc088eef815f7c1c669a10f4c0b2ffcf478b62\n Successfully built aw-watcher-window\n Installing collected packages: aw-watcher-window\n Found existing installation: aw-watcher-window 0.2\n Uninstalling aw-watcher-window-0.2:\n Successfully uninstalled aw-watcher-window-0.2\n The script aw-watcher-window is installed in '/home/yusuke/.local/bin' which is not on PATH.\n Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. \n Successfully installed aw-watcher-window-0.2\n make[1]: Leaving directory '/home/yusuke/activitywatch/aw-watcher-window'\n make --directory=aw-qt build DEV=\n make[1]: Entering directory '/home/yusuke/activitywatch/aw-qt'\n pip3 install 'pyqt5<5.11'\n Requirement already satisfied: pyqt5<5.11 in /home/yusuke/.local/lib/python3.7/site-packages (5.10.1)\n Requirement already satisfied: sip<4.20,>=4.19.4 in /home/yusuke/.local/lib/python3.7/site-packages (from pyqt5<5.11) (4.19.8)\n pyrcc5 -o aw_qt/resources.py aw_qt/resources.qrc\n make[1]: pyrcc5: Command not found\n make[1]: *** [Makefile:39: aw_qt/resources.py] Error 127\n make[1]: Leaving directory '/home/yusuke/activitywatch/aw-qt'\n make: *** [Makefile:38: build] Error 2\n \n```\n\nそして、上記のメッセージの中にパスがどれかわからない、という内容のメッセージが出てきたのですが、下記のようにパスを通してもエラーメッセージが出てきます。\n\n```\n\n export PATH=$aw-server:/home/yusuke/.local/bin\n export PATH=$aw-watcher-afk:/home/yusuke/.local/bin\n export PATH=$aw-watcher-window:/home/yusuke/.local/bin\n \n```\n\n```\n\n The script aw-server is installed in '/home/yusuke/.local/bin' which is not on PATH.\n Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\n \n```\n\n```\n\n The script aw-watcher-afk is installed in '/home/yusuke/.local/bin' which is not on PATH.\n Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\n \n```\n\n```\n\n The script aw-watcher-window is installed in '/home/yusuke/.local/bin' which is not on PATH.\n Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\n \n```\n\nどのようにすればエラーメッセージをなくせるのでしょうか。ご教授願ます。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-05T22:56:21.870",
"favorite_count": 0,
"id": "61157",
"last_activity_date": "2019-12-06T08:51:16.543",
"last_edit_date": "2019-12-06T02:39:17.650",
"last_editor_user_id": "3060",
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"bash",
"debian"
],
"title": "Debian 10で`make build`を実行しますと`WARNING Compiled with 2 warnings`と出ます。",
"view_count": 131
} | [
{
"body": "PATH云々は警告なので 気にしなくてよいです。インストール先が `/home/yusuke/.local/bin` なので\n必要に応じて、PATHに含めて使ってねと言うくらいのニュアンスだと思います。\n\nビルドエラーの内容は `pyrcc5: Command not found` です。\n\n> pyrcc5 -o aw_qt/resources.py aw_qt/resources.qrc \n> make[1]: pyrcc5: Command not found\n\n[ドキュメント](https://activitywatch.readthedocs.io/en/lates... | 61157 | 61167 | 61167 |
{
"accepted_answer_id": "61161",
"answer_count": 1,
"body": "## 実装したいこと\n\n 1. リストを5個刻みで改行したい。\n 2. 今は画像の借り入れだが、本来はeachforでデータを取得し必要分をリストに入れたい。\n\n## 現在の状況\n\n 1. 10個のliタグがある。\n 2. それぞれはラジオボタンにlabelされている。\n 3. liタグはflexboxにより横並びしている。\n\n## 試したこと\n\n 1. 5個刻みでulタグを生成していたが、foreachでデータベースにある分だけ、 \nリストを作る際に、自動で改行を入れれるようにしたいため一旦ボツとした。\n\nphp.laravel初学者になります。 \n至らない点等ございましたら、コメントで指摘していただけると幸いです。 \nよろしくお願いいたします。\n\n[](https://i.stack.imgur.com/59y0q.jpg)\n\n```\n\n <div class='select_seed'>\n <div class='seed_header'> \n <img src=\"{{ asset('/assets/images/size-large.png') }}\" alt='size-icon' class=size_icon ><h1>犬を選ぶ</h1>\n </div>\n <ul>\n <li>\n <div class=\"pad\">\n <input id=\"test46\" name=\"seed\" type=\"radio\" class=\"selectbox \" value=\"46\" checked=\"\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test46\"><img class='photo' src=\"{{ asset('/assets/images/1irish-wolfhound-.jpg') }}\" alt='アイリッシュウルフハウンド'>アイリッシュウルフハウンド</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test47\" name=\"seed\" type=\"radio\" class=\"selectbox\" value=\"47\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test47\"><img class='photo' src=\"{{ asset('/assets/images/2irish-setter.jpg') }}\" alt='アイリッシュセッター'>アイリッシュセッター</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test48\" name=\"seed\" type=\"radio\" class=\"selectbox\" value=\"48\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test48\"><img class='photo' src=\"{{ asset('/assets/images/4Afghan hound.jpg') }}\" alt='アフガンハウンド'>アフガンハウンド</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test49\" name=\"seed\" type=\"radio\" class=\"selectbox\" value=\"49\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test49\"><img class='photo' src=\"{{ asset('/assets/images/5alaskan-malamute.jpg') }}\" alt='アラスカンマラミュート'>アラスカンマラミュート</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test50\" name=\"seed\" type=\"radio\" class=\"selectbox \" value=\"50\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test50\"><img class='photo' src=\"{{ asset('/assets/images/7pointer.jpg') }}\" alt='イングリッシュポインター'>イングリッシュポインター</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test51\" name=\"seed\" type=\"radio\" class=\"selectbox \" value=\"51\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test51\"><img class='photo' src=\"{{ asset('/assets/images/8old-sheepdog.jpg') }}\" alt='オールドイングリッシュシープドッグ'>オールドイングリッシュシープドッグ</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test52\" name=\"seed\" type=\"radio\" class=\"selectbox \" value=\"52\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test52\"><img class='photo' src=\"{{ asset('/assets/images/9Curly retriever.jpg') }}\" alt='カーリーコーテッドレトリバー<'>カーリーコーテッドレトリバー</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test53\" name=\"seed\" type=\"radio\" class=\"selectbox \" value=\"53\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test53\"><img class='photo' src=\"{{ asset('/assets/images/10great-dane.jpg') }}\" alt='グレーデン'>グレーデン</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test54\" name=\"seed\" type=\"radio\" class=\"selectbox \" value=\"54\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test54\"><img class='photo' src=\"{{ asset('/assets/images/11great-p.jpg') }}\" alt='グレートピレニーズ'>グレートピレニーズ</label>\n </div>\n </li>\n <li>\n <div class=\"pad\">\n <input id=\"test55\" name=\"seed\" type=\"radio\" class=\"selectbox \" value=\"55\" required=\"\">\n <label class=\"selectlabel coolrdio\" for=\"test55\"><img class='photo' src=\"{{ asset('/assets/images/13gorlden.jpg') }}\" alt='ゴールデンレトリバー<'>ゴールデンレトリバー</label>\n </div>\n </li>\n </ul>\n </div>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T01:46:28.633",
"favorite_count": 0,
"id": "61158",
"last_activity_date": "2019-12-06T04:24:12.450",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "36914",
"post_type": "question",
"score": 1,
"tags": [
"php",
"html",
"css",
"laravel"
],
"title": "flexbox で整列しているリストを5個刻みで改行したい",
"view_count": 201
} | [
{
"body": "`flex-wrap` プロパティの初期値は `nowrap` であり、この状態では flex アイテムは単一行に配置され、行内に収まらない場合には\nflex コンテナからはみ出すこともあります[[1]](https://drafts.csswg.org/css-flexbox-1/#flex-wrap-\nproperty), [[2]](https://drafts.csswg.org/css-flexbox-1/#single-line-flex-\ncontainer)。恐らく、質問者さんが直面されている状況は前述のケースに合致します。\n\n```\n\n ul {\r\n ... | 61158 | 61161 | 61161 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "例えば \nf(x) = x * x (x = 1..10) \nの表を作りたいときに 1...10 の部分をどうやって作ればいいんでしょうか\n\n```\n\n CREATE TEMPORARY TABLE x (\n x bigint(20)\n );\n \n INSERT x VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);\n \n SELECT x, x * x FROM x\n \n```\n\nこんな感じでテーブルを作るしかないんでしょうか\n\n```\n\n SELECT x, x * x FROM \n VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)\n \n```\n\nみたいな書き方はできませんか?\n\n補足: \nMySQL 5.7 です",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T03:27:21.413",
"favorite_count": 0,
"id": "61160",
"last_activity_date": "2019-12-09T03:38:54.180",
"last_edit_date": "2019-12-09T03:38:54.180",
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"mysql"
],
"title": "固定値配列をテーブルとして扱う方法",
"view_count": 293
} | [
{
"body": "MySQL 8.0 だとこんな風に書けたりします。\n\n```\n\n WITH RECURSIVE t AS (\n SELECT 1 AS x, 1 AS xx UNION ALL SELECT x+1, (x+1)*(x+1) FROM t WHERE x<10\n )\n SELECT * FROM t;\n +------+------+\n | x | xx |\n +------+------+\n | 1 | 1 |\n | 2 | 4 |\n | 3 | 9 |\n ... | 61160 | null | 61220 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "この度Djangoでアプリの作成をしているのですが、 \nクライアントに応じてサブドメインにて運用を考えておりますが、 \nシステム上同じアプリを設置するのも効率が悪いので、以下のような構成を考えております。\n\n<考えている構成> \n一つのアプリに対して、複数のsettingsファイルにてサブドメインごとに使い分けを行いたい。\n\nINSTALLED_APPSのアプリの設定をアプリのおいてある場所のパスにすればいいのかと思っていたのですが、なかなか一筋縄にいかずお手上げしました><。\n\nこのような設定を運用を行うことは可能なのでしょうか? \nまた可能である場合、どのような設定が必要になるのでしょうか?\n\nお忙しいところ大変申し訳ございませんが、 \nご教授いただけますと幸いです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T04:20:42.153",
"favorite_count": 0,
"id": "61162",
"last_activity_date": "2019-12-12T02:32:23.330",
"last_edit_date": "2019-12-06T04:29:13.427",
"last_editor_user_id": "32986",
"owner_user_id": "26333",
"post_type": "question",
"score": 0,
"tags": [
"django"
],
"title": "Djangoで1つのアプリでsettingsで使い分けたい",
"view_count": 135
} | [
{
"body": "記事が2010年と古いので今のDjangoに適用できるかどうか不明ですが、ApacheとWSGIで可能なようです。\n\n[How to run multiple websites from one Django\nproject](http://michal.karzynski.pl/blog/2010/10/19/run-multiple-websites-one-\ndjango-project/)\n\n>\n> 単一のDjangoコードベースから2つ以上のWebサイトまたはサイトのサブドメインを実行すると便利な場合があります。プロジェクト内の各Djangoアプリは、異なるドメインのWe... | 61162 | null | 61360 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "最終的にやりたいのは \n正規分布累積関数の表を作りたいです\n\nそのために[誤差関数](https://ja.wikipedia.org/wiki/%E8%AA%A4%E5%B7%AE%E9%96%A2%E6%95%B0)というのを計算する必要があって \nその中に階乗の計算があるのですが MySQL の数学関数にはありません\n\nプログラムであれば\n\n```\n\n retval = 1\n for i in 1..n\n retval *= i\n \n```\n\nと簡単に書けると思うのですが MySQL ではどのように書くのが(速度的にもソース的にも)早いでしょうか\n\n1〜N のテーブルを生成してから \nexp(sum(log(n))) \nを取るみたいな記事も見かけたのですが log や exp は整数演算に比べたら遥かに重そうなので無駄な気がします\n\nこういうのは1度プログラム側にデータを取得してプログラム側で計算するしかないのでしょうか\n\n### 補足:\n\nMySQL 5.7 です\n\n### 追記\n\nやりたいことの詳細を書くと \n平均と分散カラムを持ってる数万件の正規分布レコードに対して \n現在時刻がどの累積分布の位置にあるかを計算して \n特定の位置にあるレコードだけを取得するという処理を Lambda で行いたいです\n\nwiki の「これを反復的に計算するには、以下のように定式化するのが扱い易い。」の式を使おうと思っています。(SVG なので貼れない)\n\n外側は sum なんですが内側のループが実質階乗なのでどう書けばいいか質問した次第です。\n\n近似式も書いてあるのですが「実軸付近の誤差関数の値について、少なくとも十進で1桁の精度」の意味がよくわからなかったのと、\n級数展開でも「最初の方の幾つかの項だけでよい近似が得られ、テイラー展開よりも収束が早い」 とあるので眼福計算を採用しました。\n\n必要な精度は横軸が1日の分布で精度は秒あれば十分なので 1 / 24 x 3600 程度です \n近似式の方でもこの精度は満たせるものなのでしょうか?\n\n式自体は複雑ですが上記精度要件から実際は四則演算100回もない程度の軽い処理で、 \n取得データは毎回数件になるというケースなので、 \nネットワークオーバーヘッドを使うより MySQL 側でやる方がメリットが大きいかなと考えました",
"comment_count": 10,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T04:58:51.477",
"favorite_count": 0,
"id": "61163",
"last_activity_date": "2021-01-07T00:04:50.473",
"last_edit_date": "2019-12-09T04:23:40.623",
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 1,
"tags": [
"mysql"
],
"title": "階乗を計算する方法",
"view_count": 430
} | [
{
"body": "階乗を求めるSQLです。試したのは、mysql 8.0.18.0 32bit版です。 \nmetropolisさんのコメントにあるとおり21はエラーとなりました。\n\n# SQL\n\n```\n\n set @n := 20;\n select f\n from (\n with recursive rc(f, i) as(\n select 1, @n\n union all\n select f * i, i-1\n from rc\n where i-1 >= 0)\n ... | 61163 | null | 61345 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "シェルをbashからzshに変更したのですがanacondaのコンソールが使えなくなりました。 \nコンソールを起動すると\n\n```\n\n ❯ /Users/username/.anaconda/navigator/a.tool ; exit;\n /Users/username/.anaconda/navigator/a.tool: line 1: syntax error near unexpected token `('\n /Users/username/.anaconda/navigator/a.tool: line 1: `bash --init-file <(echo \"source activate /Users/username/opt/anaconda3;\")'\n \n [プロセスが完了しました]\n \n```\n\nと出力されます。\n\n**試したこと** \n<https://ts-engine.net/wp/archives/1068>に従い、パスを通しました。 \ncondaコマンドは使えるようになりましたが依然として出力は変わりません。\n\nよろしくお願いします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T07:43:58.153",
"favorite_count": 0,
"id": "61166",
"last_activity_date": "2019-12-19T16:57:27.037",
"last_edit_date": "2019-12-06T14:29:09.950",
"last_editor_user_id": "32986",
"owner_user_id": "36954",
"post_type": "question",
"score": 1,
"tags": [
"macos",
"anaconda",
"zsh"
],
"title": "zsh環境によるanacondaコンソール起動に失敗する",
"view_count": 637
} | [
{
"body": "ありがとうございました。解決しました。\n\nコメント欄で示していただいたサイトを参考にして、以下の通り実行するとうまく行きました。\n\n```\n\n conda init zsh\n conda update conda\n conda update jupyter\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-19T12:47:24.213",
"id": "61588",
"last_ac... | 61166 | null | 61588 |
{
"accepted_answer_id": "61174",
"answer_count": 1,
"body": "MySQL をみにいく Lambda が増えてきたので MySQL 接続までの共通コードと \n接続設定ファイルを Layer 化したいです\n\n```\n\n /python/mysql.py\n /mysql.ini\n /pymysql\n \n```\n\nという構成の Layer を作って \nmysql.py の中はこんな感じで mysql.ini を読むようにしたいのですが\n\n```\n\n import pymysql\n \n import configparser\n config = configparser.ConfigParser()\n config.read('mysql.ini', encoding='utf-8')\n config = config['DEFAULT']\n \n def connect():\n return pymysql.connect(host =config['db_host'],\n user =config['db_username'],\n password=config['db_password'],\n db =config['db_name'],\n charset =config['db_charset'])\n \n```\n\nこれをメインの Lambda から\n\n```\n\n from mysql import connect\n \n def lambda_handler(event, context):\n mysql = connect()\n :\n \n```\n\nという感じで読んでみたら layer 自体は呼べてるみたいなのですが layer 内で\n\n```\n\n raise KeyError(key)\n KeyError: 'db_host'\n \n```\n\nとなってどうも mysql.ini の読み込みがうまくいってないみたいです \nメインの Lambda 内で同じコード同じファイルをおいたときは読めてたので \n設定ファイルが間違っているということはないはずです\n\nlayer 内においたファイルを configparser で読むことはできないのでしょうか\n\npython は 3.7 です",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T10:04:32.087",
"favorite_count": 0,
"id": "61168",
"last_activity_date": "2021-03-18T18:03:55.673",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"python",
"aws-lambda"
],
"title": "Lambda Layer 内の config を読む方法",
"view_count": 1045
} | [
{
"body": "Layer は AWS 上では /opt/ に配置されるみたいで \n/opt/python/mysql.ini を指定すれば読めました\n\nただローカルでテスト実行するときに毎回このパスを変更するか \n設定ファイルと /opt に配置しないといけなくなるので \nLayer 内での相対パスで読める方法があったら教えていただきたいです",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T11:54:20.383",
"id": "611... | 61168 | 61174 | 61174 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "**現在の状況**\n\n 1. Eloquentでの記述の場合に『user_idがnull』とエラーが出る。\n 2. ログイン自体は成功しており、同ページで@if (Auth::check)を用いた文も正常に機能 \n3.コメントアウトしている記述ならば問題なくテーブルに保存が行える。\n\nなぜ現状のコードでは[user_id]が取得出来ないのでしょうか。 \nどなたかご教授いただければ幸いです。\n\nまた、追記必要なファイルがあればコメントで指摘していただければ幸いです。\n\n[](https://i.stack.imgur.com/8mQNq.png)\n\n```\n\n <?php\n \n namespace App\\Http\\Controllers;\n \n use Illuminate\\Http\\Request;\n use Illuminate\\Support\\Facades\\DB;\n use Illuminate\\Support\\Facades\\Auth;\n use App\\Lost;\n \n class LostsController extends Controller\n {\n public function add(){\n $user = Auth::user();\n \n return view('lost.size_small',['user' => $user]);\n }\n \n public function store(Request $request) {\n \n $lost = new Lost;\n $form = $request->all();\n unset($form['_token']);\n $lost->fill($form)->save();\n return redirect('/');\n \n /*\n $lost = new Lost;\n $lost->user_id = $request->user()->id;\n $lost->pref = $request->pref;\n $lost->seed = $request->seed;\n $lost->image = $request->image;\n $lost->body = $request->body;\n $lost->save();\n return redirect('/select');\n */\n }\n }\n \n```",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T10:04:42.830",
"favorite_count": 0,
"id": "61169",
"last_activity_date": "2019-12-06T16:26:11.810",
"last_edit_date": "2019-12-06T16:26:11.810",
"last_editor_user_id": "3060",
"owner_user_id": "36914",
"post_type": "question",
"score": 0,
"tags": [
"php",
"laravel"
],
"title": "Laravel Eloquentでuser_idが取得できない",
"view_count": 1672
} | [
{
"body": "コメントでも少し書きましたが、当然ながら`Request`はモデルではありません。 \n`$request->all()`はリクエストのクエリとリクエスト本文のパラメータをまとめて返します。\n\nとりあえず当該部分は以下に抜粋してみます。\n\n<https://github.com/laravel/framework/blob/9abc0896070176fd6987d95f0d1b50de947db82c/src/Illuminate/Http/Concerns/InteractsWithInput.php#L179-L210>\n\n```\n\n /**\n ... | 61169 | null | 61184 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n # iptables -L\n FATAL: Could not load /lib/modules/4.9.184-linuxkit/modules.dep: No such file or directory\n iptables v1.4.7: can't initialize iptables table `filter': Permission denied (you must be root)\n Perhaps iptables or your kernel needs to be upgraded.\n \n```\n\nこのようなエラーがでます。 \niptablesをアンインストール後、再度インストールしましたが、ダメでした。\n\n環境 docker内にcentos6を立てています\n\n```\n\n >docker -v\n Docker version 19.03.5, build 633a0ea\n \n >cat /etc/redhat-release \n CentOS release 6.10 (Final)\n \n cat /proc/version \n Linux version 4.9.184-linuxkit (root@a8c33e955a82) (gcc version 8.3.0 (Alpine 8.3.0) ) #1 SMP Tue Jul 2 22:58:16 UTC 2019\n \n iptables --version\n iptables v1.4.7\n \n```\n\niptablesの設定です\n\n```\n\n >vi /etc/sysconfig/iptables\n *filter\n :INPUT DROP [0:0]\n :FORWARD DROP [0:0]\n :OUTPUT ACCEPT [388:275634]\n :RH-Firewall-1-INPUT - [0:0]\n :SERVICE - [0:0]\n -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT\n -A INPUT -m state --state NEW -m tcp -p tcp --dport 20 -j ACCEPT\n -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT\n -A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT\n COMMIT\n \n```\n\nなぜ、firewallが設定できないのでしょうか? \nご教示お願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T11:18:35.300",
"favorite_count": 0,
"id": "61170",
"last_activity_date": "2020-07-24T05:57:17.790",
"last_edit_date": "2020-07-24T05:57:17.790",
"last_editor_user_id": "3060",
"owner_user_id": "36929",
"post_type": "question",
"score": 0,
"tags": [
"centos",
"docker",
"iptables"
],
"title": "Docker コンテナ上の CentOS で iptables を実行するとエラーが発生する",
"view_count": 534
} | [
{
"body": "docker run に `--cap-add=NET_ADMIN` オプションを付けてみてください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T15:19:31.657",
"id": "61181",
"last_activity_date": "2019-12-06T15:19:31.657",
"last_edit_date": null,
"last_editor_user_id": null,
... | 61170 | null | 61181 |
{
"accepted_answer_id": "61218",
"answer_count": 1,
"body": "ストアドプロシジャーを作成する SQL を AWS Lambda python で実行したいのですが\n\nストアドプロシジャーを初めて使うので \n後述のような最低限のテストコードを書いてローカルで実行してみると文法エラーがでます \n(Lambda 上でも同じエラーになります)\n\n```\n\n sql ='''\n create temporary table test (\n x int\n )\n '''\n \n```\n\nだと動くので接続情報や実行環境は問題ないと思われますし \n同じ MySQL をみてる workbench に SQL の中だけ \n貼り付けると動くので SQL の中も問題ないはずなのですが\n\n何が悪いのでしょうか\n\n```\n\n #-*- using:utf-8 -*-\n \n import pymysql\n import configparser\n config = configparser.ConfigParser()\n config.read('mysql.ini', encoding='utf-8')\n config = config['DEFAULT']\n \n mysql = pymysql.connect(host =config['db_host'],\n user =config['db_username'],\n password=config['db_password'],\n db =config['db_name'],\n charset =config['db_charset'])\n \n with mysql.cursor() as cursor:\n sql ='''\n DELIMITER //\n CREATE FUNCTION echo(n int)\n RETURNS int\n BEGIN\n RETURN n;\n END//\n DELIMITER ;\n '''\n cursor.execute(sql)\n \n```\n\nエラーメッセージ\n\n```\n\n pymysql.err.ProgrammingError: (1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER //\\nCREATE FUNCTION echo(n int)\\nRETURNS int\\nBEGIN\\n RETURN n;\\nEND//\\nDEL' at line 1\")\n \n```\n\npython 3.7 です",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T11:51:20.480",
"favorite_count": 0,
"id": "61172",
"last_activity_date": "2019-12-07T12:54:57.723",
"last_edit_date": "2019-12-06T11:56:52.863",
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"python",
"mysql",
"pymysql"
],
"title": "ストアドプロシジャーを PyMySQL から実行できない",
"view_count": 179
} | [
{
"body": "ややこしいのですが、DELIMITER はクエリではなくて mysql クライアントのコマンドなのです。 \nmysql コマンドが `;` をクエリの区切りと認識してしまうため、それを別の文字列に置き換えるのが DELIMITER です。\n\nなので、DELIMITER を書かずに、そのまま\n\n```\n\n CREATE FUNCTION echo(n int)\n RETURNS int\n BEGIN\n RETURN n;\n END\n \n```\n\nとだけ書けばいいと思います。",
"comment_count": 0,
... | 61172 | 61218 | 61218 |
{
"accepted_answer_id": "61191",
"answer_count": 2,
"body": "現在、Gitで実装中のソフトを複数環境で運用したいと考えております。その際、環境毎にデータの保存先や参照するパスの情報が変わって来るので、Gitの管理対象からは外して運用したいと考えています。\n\nこの場合、.gitignoreにそのファイルを加えてしまうと、ファイル自体が消えてしまったのですが、今までのコミットの情報は残しつつ、今後のGitの管理からはそのファイルを管理対象から外すという事は出来ないのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T11:53:59.287",
"favorite_count": 0,
"id": "61173",
"last_activity_date": "2019-12-07T02:33:03.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19869",
"post_type": "question",
"score": 0,
"tags": [
"git"
],
"title": "Gitで環境毎の設定ファイルだけ、途中から管理対象外(ファイルを残す)とする方法",
"view_count": 1776
} | [
{
"body": "以下の通り `--cached` オプションを付けて `git rm` を実行してみてください。\n\n```\n\n $ git rm --cached FILE\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T12:16:23.713",
"id": "61175",
"last_activity_date": "2019-12-06T12:16:23.713",
"last_edit_date... | 61173 | 61191 | 61175 |
{
"accepted_answer_id": "61178",
"answer_count": 1,
"body": "夜分遅くに失礼いたします。お世話になります。\n\nDebian 10にActivityWatchというManicTimeのようなOSSのインストールを行っておりますが、 \nインストールをしたあとに`aw-qt`を実行しますと、下記のWARNINGが出ます。 \n`WARNING: This is a development server. Do not use it in a production\ndeployment.`\n\nbashの履歴は下記となります。\n\n```\n\n ~/activitywatch$ aw-qt\n 2019-12-06 23:38:40 [INFO ]: Starting module aw-server (aw_qt.manager:49)\n 2019-12-06 23:38:40 [INFO ]: Trying to start aw-server using PATH (executable not found in: ['/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw_qt/aw-server', '/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw-server', '/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw-server/aw-server']) (aw_qt.manager:36)\n 2019-12-06 23:38:40 [INFO ]: Starting module aw-watcher-afk (aw_qt.manager:49)\n 2019-12-06 23:38:40 [INFO ]: Trying to start aw-watcher-afk using PATH (executable not found in: ['/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw_qt/aw-watcher-afk', '/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw-watcher-afk', '/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw-watcher-afk/aw-watcher-afk']) (aw_qt.manager:36)\n 2019-12-06 23:38:40 [INFO ]: Starting module aw-watcher-window (aw_qt.manager:49)\n 2019-12-06 23:38:40 [INFO ]: Trying to start aw-watcher-window using PATH (executable not found in: ['/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw_qt/aw-watcher-window', '/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw-watcher-window', '/home/yusuke/activitywatch/venv/lib/python3.7/site-packages/aw-watcher-window/aw-watcher-window']) (aw_qt.manager:36)\n 2019-12-06 23:38:40 [INFO ]: Creating trayicon... (aw_qt.trayicon:150)\n 2019-12-06 23:38:40 [INFO ]: aw-watcher-afk started (aw_watcher_afk.afk:53)\n 2019-12-06 23:38:40 [INFO ]: aw-watcher-window started (aw_watcher_window.main:42)\n 2019-12-06 23:38:41 [INFO ]: Using storage method: peewee (aw_server.main:26)\n 2019-12-06 23:38:41 [INFO ]: Starting up... (aw_server.main:31)\n 2019-12-06 23:38:41 [INFO ]: Using database file: /home/yusuke/.local/share/activitywatch/aw-server/peewee-sqlite.v2.db (aw_datastore.storages.peewee:90)\n * Serving Flask app \"aw-server\" (lazy loading)\n * Environment: production\n WARNING: This is a development server. Do not use it in a production deployment.\n Use a production WSGI server instead.\n * Debug mode: off\n 2019-12-06 23:38:41 [INFO ]: * Running on http://localhost:5600/ (Press CTRL+C to quit) (werkzeug:122)\n 2019-12-06 23:38:41 [INFO ]: Connection to aw-server established by aw-watcher-afk (aw_client.client:348)\n 2019-12-06 23:38:41 [INFO ]: Connection to aw-server established by aw-watcher-window (aw_client.client:348)\n \n```\n\nWARNINGが出ない方法をご教授願ます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T14:47:17.723",
"favorite_count": 0,
"id": "61177",
"last_activity_date": "2019-12-06T15:04:54.440",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"debian"
],
"title": "WARNING: This is a development server. Do not use it in a production deployment.と出ますが、解決法をご教授願ます。",
"view_count": 2276
} | [
{
"body": "> WARNING: This is a development server. Do not use it in a production\n> deployment. \n> Use a production WSGI server instead.\n\n動かすだけなら、ワーニングは無視していいと思います。 \n試してませんが、ワーニングを消すには gunicorn などの WSGI サーバーを使えばいいと思います。\n\nPython に組み込まれた Web サーバー機能は、機能的に貧弱で、セキュリティ対策も行われてないので、本番環境で使うのは非推奨です。HTTPサーバ &\nWS... | 61177 | 61178 | 61178 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Debian 10の bashシェルですべてのコマンドが`command not found`と出るようになりました…。\n\nどうすれば解決できるでしょうか。再インストールしかないのでしょうか。 \nご教授願ます。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-06T15:45:22.917",
"favorite_count": 0,
"id": "61182",
"last_activity_date": "2019-12-09T09:19:06.800",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"bash",
"debian"
],
"title": "Debian 10の bashシェルですべてのコマンドが`command not found`と出るようになりました…。",
"view_count": 546
} | [
{
"body": "質問者さんの[別の質問](https://ja.stackoverflow.com/q/61157/19110)において次のような操作をされていますが、これのせいで既存の\nPATH がすべて喪失していそうです。\n\n```\n\n export PATH=$aw-server:/home/yusuke/.local/bin\n export PATH=$aw-watcher-afk:/home/yusuke/.local/bin\n export PATH=$aw-watcher-window:/home/yusuke/.local/bin\n \n```\n\nつま... | 61182 | null | 61185 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "<https://www.gnu.org/software/global/globaldoc_toc.html#Vim-editor> \nの \n3.5.3 Usage \nに\n\n```\n\n map <C-\\>^] :GtagsCursor<CR>\n \n```\n\nと記述があります。\n\n`<C-\\>^]` の部分の解説をお願いいたします。\n\nコントロールキーを押しながらバックスラッシュを押下するのだろうとは思ったのですが、その先がわかりません。\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T00:35:38.933",
"favorite_count": 0,
"id": "61187",
"last_activity_date": "2019-12-07T09:42:17.360",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36962",
"post_type": "question",
"score": 0,
"tags": [
"vim"
],
"title": "map <C-\\>^] の意味",
"view_count": 102
} | [
{
"body": "`<C-\\>` の部分は、ご推察の通りコントロールキーを押しながらバックスラッシュを押下であっています。\n\n`^]` はコントロールキーを押しながら `]` を押すと入力できます。このコントロール文字をスクリプトに直接書くには、Vim では挿入モードで\n`<C-v><C-]>` の順にキーを押せば入力できます。 \n実際に設定したい場合は、以下のように `<>` 記法で設定した方がわかりやすいでしょう。\n\n```\n\n nnoremap <C-\\><C-]> :GtagsCursor<CR>\n \n```\n\n** 回答当初、`<C-[>` と見間違えてエスケー... | 61187 | null | 61188 |
{
"accepted_answer_id": "61193",
"answer_count": 1,
"body": "spresenseのMultiCore\nMPライブラリ内のサンプルスケッチ「AudioFFT」についてですがピーク周波数とは具体的にどういったものでしょうか。またシリアルプロッタに表示される線が基準の青線+4本の計5本なのはなぜでしょうか。初歩的な質問で申し訳ありませんがよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T01:35:26.817",
"favorite_count": 0,
"id": "61189",
"last_activity_date": "2019-12-07T03:42:11.013",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36963",
"post_type": "question",
"score": 0,
"tags": [
"spresense"
],
"title": "spresenseのFFTスケッチについて",
"view_count": 400
} | [
{
"body": "マイクから入力された音をFFTで周波数成分に分解したときにパワーが最大となる周波数のことですね。\n\n参考) 例えば10kHzのsin波+ランダムノイズのデータにFFTをかけて周波数成分でみると10kHzのところにピークが現れます \n<https://www.keil.com/pack/doc/CMSIS/DSP/html/group__FrequencyBin.html>\n\nプロットが5本あるのは[マニュアル](https://developer.sony.com/develop/spresense/docs/arduino_developer_guide_ja.html#_mp_s... | 61189 | 61193 | 61193 |
{
"accepted_answer_id": "61192",
"answer_count": 1,
"body": "お世話になります。\n\nC#にて、DataGridの勉強中です。\n\nフォームにDataGridViewをDock = Fillで貼り付けた後、フォーム側のサイズ変更に合わせて \nDataGridViewのサイズも自動変更されるので、そのタイミング(Resizeイベント)で \n指定のColumnだけの幅を残り空間分だけ広げようとしています。\n\n全てのColumnを伸縮するには、AutoSizeColumnModeというのがあるらしいのですが、 \n五列のうちの4,5列目だけを伸縮させたいのです。\n\n方法として、DataGridViewの幅から、伸縮する必要のないColumnの合計を引き、それを \n二で割って4,5列のWidthに入れました。\n\nある程度はうまくいったのですが、見落としていた点があり、左側のレコードセレクタ部分の \n幅を取得できずにいました。\n\nそれを計算で取得しようとしたのですが、うまくいかなかったため、質問いたしました。\n\n[](https://i.stack.imgur.com/V0GdB.jpg)\n\nこの部分の幅を取得する方法はありますでしょうか。\n\nまた、もっと簡単に行える方法がありましたら、ご教授いただければ幸いです。\n\n下記が試してみた計算部分です。\n\n```\n\n private void dataGridView1_Resize(object sender, EventArgs e)\n {\n int space = this.dataGridView1.Width -\n (this.dataGridView1.Columns[0].Width + this.dataGridView1.Columns[1].Width + this.dataGridView1.Columns[2].Width);\n this.dataGridView1.Columns[3].Width = space / 2;\n this.dataGridView1.Columns[4].Width = space / 2;\n }\n \n```\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T01:56:14.117",
"favorite_count": 0,
"id": "61190",
"last_activity_date": "2019-12-07T04:12:28.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9374",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"form",
"datagridview"
],
"title": "C# DataGridViewの指定の列だけフォームのサイズに合わせて自動調整したい",
"view_count": 1716
} | [
{
"body": "その部分の列全体というわけではないですが、左上隅のセルの幅ならば、`this.dataGridView1.TopLeftHeaderCell.Size.Width`で読み取れます。\n\n図の緑で囲んだ部分ですね。\n\n[](https://i.stack.imgur.com/cFUJ4.jpg)\n\n参考: \n[DataGridViewのヘッダーセルを取得する](https://dobon.net/vb/dotnet/datagridview/headercell.htm... | 61190 | 61192 | 61192 |
{
"accepted_answer_id": "61197",
"answer_count": 1,
"body": "今までRPAソフトウェアを使用し、テキストボックスからのテキストの抽出を行っていましたが、 \nタイトルのような必要性が発生しました。\n\nテキストを抽出したいソフトウェアは、独自のコントロールを使用しているようで、 \nVisual StudioのSpy++で調べるとクラスはCustomと表示されます。 \nただ、リアルタイムで表示テキストの内容は変わるため、 \nそれをイベントとして、更新テキストをキャッチするようなことが \nC++またはC#で可能でしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T05:11:20.227",
"favorite_count": 0,
"id": "61196",
"last_activity_date": "2019-12-07T06:53:20.947",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27065",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"c++",
"windows"
],
"title": "テキストボックスではないウィンドウのコントロールからテキストを抽出したい",
"view_count": 678
} | [
{
"body": "出来るようですね。[SetWinEventHook function](https://docs.microsoft.com/en-\nus/windows/win32/api/winuser/nf-winuser-setwineventhook?redirectedfrom=MSDN)\nと、[WinEvents](https://docs.microsoft.com/en-\nus/windows/win32/winauto/winevents-collision169?redirectedfrom=MSDN)\nというのを使うようです。\n\n使えるイベント [Event Constant... | 61196 | 61197 | 61197 |
{
"accepted_answer_id": "61204",
"answer_count": 1,
"body": "下記チュートリアルを行っています。 \n<https://developer.apple.com/tutorials/swiftui/drawing-paths-and-shapes>\n\nライブラリから追加した場合はinitが実行されているので意味がわかるのですが\n\n```\n\n Path(ellipseIn: CGRect(x: 0, y: 0, width: 50, height: 100))\n \n```\n\nチュートリアルにある下記の初期化の仕方がどうやっているのか意味が分かりません。 \n右クリックして Jump to Definition しても Struct の定義へしか飛べず何が呼ばれているのかも確認できなくて。\n\n```\n\n Path { path in\n var width: CGFloat = 100.0\n let height = width\n path.move(to: CGPoint(x: width * 0.95, y: height * 0.20))\n ...\n }\n \n```\n\n初心者すぎる質問かもしれませんが、調べ方もわからず教えて頂けると助かります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T05:51:24.997",
"favorite_count": 0,
"id": "61198",
"last_activity_date": "2019-12-07T07:20:36.770",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36965",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode"
],
"title": "SwiftUIチュートリアル Drawing Paths and Shapes にある Path の初期化について",
"view_count": 88
} | [
{
"body": "解決しました。下記の init ですね。 \n空のオブジェクトが生成されて、そのオブジェクトに対してクロージャーが実行(inout だし &self が引数)されているであってるかな。。。 \n呼び出しの記述も Trailing Closure だからかな。なかなか難しいですね。\n\n```\n\n /// Initializes to an empty path then calls `callback` to add\n /// the initial elements.\n public init(_ callback: (inout Path) -> ())\n ... | 61198 | 61204 | 61204 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "[F - ヘビの JOI\n君](https://atcoder.jp/contests/joi2017yo/tasks/joi2017yo_f)に挑戦したのですがTLEになります。 \nしかし、なぜ自分のコードが非効率なのかがわかりません。コードの問題点などを教えていただけないでしょうか。下が自分のコードです。\n\n```\n\n int N, M,X,T[10000];\n \n struct edge{\n int to,cost;\n };\n \n struct situ {\n int cost,v,dist,type;\n \n bool operator<(const situ& rhs) const\n {\n return cost < rhs.cost;\n }\n };\n \n vector<edge>G[10005];\n \n int d[10005][205][3];\n \n void dijkstra(int s) {\n \n d[0][0][0] = 0;\n priority_queue<situ> que;\n que.push({ 0, s, 0,0 });\n while (!que.empty()) {\n situ p = que.top(); que.pop();\n int cost = p.cost, v = p.v;\n if (d[v][p.dist][p.type] < cost)continue;\n for (edge u : G[v]) {\n \n if (abs(p.type - T[u.to]) > 1 && p.dist+u.cost < X) {\n continue;\n }\n int type = p.type,dist = min(p.dist + u.cost,X);\n if (T[u.to] != 1) {\n type = T[u.to];\n dist = 0;\n }\n \n if (d[u.to][dist][type] > d[v][p.dist][p.type] + u.cost) {\n d[u.to][dist][type] = d[v][p.dist][p.type] + u.cost;\n que.push({ d[u.to][dist][type],u.to,dist,type });\n \n }\n }\n }\n }\n int main()\n {\n cin >> N >> M >> X;\n rep(i, N) {\n cin >> T[i];\n }\n rep(i, M) {\n int a, b,d;\n cin >> a >> b >> d;\n a--; b--;\n G[a].push_back({ b,d });\n G[b].push_back({ a,d });\n }\n rep(i, N) {\n rep(j, X + 1) {\n fill_n(d[i][j], 3, INF);\n }\n }\n dijkstra(0);\n N--;\n int ans = INF;\n rep(i, X+1) {\n rep(j, 3) {\n ans = min(ans, d[N][i][j]);\n }\n }\n cout << ans << endl;\n \n }\n \n```\n\n次にサンプルコード\n\n```\n\n #include<cstdio>\n #include<vector>\n #include<utility>\n #include<queue>\n \n using namespace std;\n \n const int MAX_N = 10000;\n const int MAX_X = 200;\n \n const int inf = 1e9;\n struct Edge{\n int to, cost;\n Edge(){}\n Edge(int to, int cost):to(to), cost(cost){}\n };\n \n vector<Edge> G[MAX_N];\n int color[MAX_N]; //temperature (0/1/2)\n \n int N, X;\n \n int dis[MAX_N][2][MAX_X + 1];\n \n typedef pair<int, int> P; //<temperature of the nearest non-comfortable room (0 or 2), distance from there>\n typedef pair<int, P> P2; //<vertex, P>\n typedef pair<int, P2> P3; //<distance from s, P2>\n \n P update_state(P p, Edge e){\n if(color[e.to] == 0){\n if(p.first == 2 && p.second + e.cost < X){\n return P(-1, -1);\n }else{\n return P(0, 0);\n }\n }else if(color[e.to] == 1){\n int d = min(X, p.second + e.cost);\n return P(p.first, d);\n }else{\n if(p.first == 0 && p.second + e.cost < X){\n return P(-1, -1);\n }else{\n return P(2, 0);\n }\n }\n }\n \n void dijkstra(){\n priority_queue<P3, vector<P3>, greater<P3> > que;\n for(int i = 0; i < N; ++i){\n for(int j = 0; j < 3; ++j){\n for(int k = 0; k < MAX_X + 1; ++k){\n dis[i][j][k] = inf;\n }\n }\n }\n \n dis[0][0][0] = 0;\n que.push(P3(0, P2(0, P(0, 0))));\n \n while(!que.empty()){\n P3 p3 = que.top();\n que.pop();\n int d = p3.first;\n int v = p3.second.first;\n P prv_state = p3.second.second;\n if(dis[v][prv_state.first / 2][prv_state.second] < d) continue;\n for(int i = 0; i < G[v].size(); ++i){\n P np = update_state(prv_state, G[v][i]);\n if(np == P(-1, -1)) continue;\n int nd = d + G[v][i].cost;\n int nv = G[v][i].to;\n if(dis[nv][np.first / 2][np.second] <= nd) continue;\n dis[nv][np.first / 2][np.second] = nd;\n que.push(P3(nd, P2(nv, np)));\n }\n }\n }\n \n int solve(){\n dijkstra();\n int ans = inf;\n for(int c = 0; c < 2; ++c){\n for(int d = 0; d <= X; ++d){\n ans = min(ans, dis[N - 1][c][d]);\n }\n }\n for(int v = 0; v < N; ++v){\n int tmp = inf;\n for(int c = 0; c < 2; ++c){\n for(int d = 0; d <= X; ++d){\n tmp = min(tmp, dis[v][c][d]);\n }\n }\n }\n return ans;\n }\n \n void input(){\n int M;\n scanf(\"%d%d%d\", &N, &M, &X);\n for(int i = 0; i < N; ++i){\n scanf(\"%d\", color + i);\n }\n for(int i = 0; i < M; ++i){\n int u, v, d;\n scanf(\"%d%d%d\", &u, &v, &d);\n u--;\n v--;\n G[u].push_back(Edge(v, d));\n G[v].push_back(Edge(u, d));\n }\n }\n \n int main(){\n input();\n int ans = solve();\n printf(\"%d\\n\", ans);\n return 0;\n }\n \n```\n\nちなみにサンプルコードは最悪でも実行時間60msです。 \n制約などは最初のURLに載っています。 \n追記: \n自分のコードの省略した部分です\n\n```\n\n #define _USE_MATH_DEFINES\n #include<math.h>\n \n //#include<cmath>\n \n #include<deque>\n #include<queue>\n #include<vector>\n #include<algorithm>\n #include<iostream>\n #include<set>\n #include<cmath>\n #include<tuple>\n #include<string>\n #include<chrono>\n #include<functional>\n #include<iterator>\n #include<random>\n #include<unordered_set>\n #include<array>\n #include<map>\n #include<iomanip>\n #include<assert.h>\n #include<bitset>\n #include<stack>\n #include<memory>\n \n \n \n //#include \"Ants.h\"\n using namespace std;\n typedef long long ll;\n #define rad_to_deg(rad) (((rad)/2/M_PI)*360)\n #define EPS (1e-7)\n #define INF (1e9)\n #define PI (acos(-1))\n #define rep(i,n) for(int i=0;i<n;i++)\n #define show(s) cout<<s<<endl\n #define chmin(x,y) x=min(x,y)\n #define chmax(x,y) x=max(x,y)\n #define LINF (1000000000000000000ll)\n typedef pair<int, int> P;\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T06:00:57.170",
"favorite_count": 0,
"id": "61199",
"last_activity_date": "2021-07-06T12:00:50.140",
"last_edit_date": "2019-12-07T08:00:17.903",
"last_editor_user_id": "4236",
"owner_user_id": "24617",
"post_type": "question",
"score": -1,
"tags": [
"c++",
"アルゴリズム"
],
"title": "なぜこのコードは非効率なのか?",
"view_count": 487
} | [
{
"body": "問題の解説サイトを読みましたか? \n<https://www.ioi-\njp.org/joi/2016/2017-yo/2017-yo-t6/review/2017-yo-t6-review.html>\n\nまず、質問者のプログラムは ダイクストラ法になっていません。 \nwhile 分で取り出した1つの部屋について すべての訪問可能な部屋の情報を調べて計算し \n少しでも効率がいい経路を queue に入れていますが、再帰的にすべてのルートを計算しているのとそれほど変わりがありません。\n\nまず、ダイクストラ法を使って計算するロジックを書く練習をしてください。 \nダイクストラ... | 61199 | null | 61206 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "vue create を入れると下記エラーがでます。\n\n```\n\n mac:vue-nuxt hogehoge$ vue create my-app\n /Users/hogehoge/.nodebrew/node/v12.13.1/lib/node_modules/@vue/cli/node_modules/vue-template-compiler/index.js:10\n throw new Error(\n ^\n \n Error: \n \n Vue packages version mismatch:\n \n - vue@2.5.17 (/Users/hogehoge/node_modules/vue/dist/vue.runtime.common.js)\n - vue-template-compiler@2.6.10 (/Users/hogehoge/.nodebrew/node/v12.13.1/lib/node_modules/@vue/cli/node_modules/vue-template-compiler/package.json)\n \n This may cause things to work incorrectly. Make sure to use the same version for both.\n If you are using vue-loader@>=10.0, simply update vue-template-compiler.\n If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.\n \n at Object.<anonymous> (/Users/hogehoge/.nodebrew/node/v12.13.1/lib/node_modules/@vue/cli/node_modules/vue-template-compiler/index.js:10:9)\n at Module._compile (internal/modules/cjs/loader.js:959:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)\n at Module.load (internal/modules/cjs/loader.js:815:32)\n at Function.Module._load (internal/modules/cjs/loader.js:727:14)\n at Module.require (internal/modules/cjs/loader.js:852:19)\n at require (internal/modules/cjs/helpers.js:74:18)\n at Object.<anonymous> (/Users/hogehoge/.nodebrew/node/v12.13.1/lib/node_modules/@vue/cli/node_modules/vue-jscodeshift-adapter/src/parse-sfc.js:1:18)\n at Module._compile (internal/modules/cjs/loader.js:959:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)\n \n```\n\nvue-template-compilerのアップデートnodeのバージョンアップなど色々行ったのですが毎回ここのエラーが変わりません。\n\nなにか解決方はないでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T06:30:31.363",
"favorite_count": 0,
"id": "61200",
"last_activity_date": "2020-01-18T07:01:30.180",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36967",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"vue.js",
"npm"
],
"title": "vue create でVue packages version mismatchのエラーがでる",
"view_count": 1432
} | [
{
"body": "プロジェクト外で`npm install`等をしているように見えます。\n\nもし、`/Users/hogehoge/` がプロジェクトディレクトリ **ではなく** 、そこで-gなどを付けないnpm\nisntallを行ったなどの過去がありその直下に`node_modules`ディレクトリが **あるのであれば** それを **削除** または\n**名前の変更** をしてみてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T07:38:... | 61200 | null | 61208 |
{
"accepted_answer_id": "63123",
"answer_count": 1,
"body": "こんばんは。お世話になります。\n\nDebian 10で`bash`を起動しました際に、`bash: dircolors: command not\nfound`と出てすべてのコマンドを使えなくなり、`bash.bashrc`を書き換えることも不可能になってしまいました。\n\n[別質問](https://ja.stackoverflow.com/questions/61182/debian-10%E3%81%AE-\nbash%E3%82%B7%E3%82%A7%E3%83%AB%E3%81%A7%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%8Ccommand-\nnot-\nfound%E3%81%A8%E5%87%BA%E3%82%8B%E3%82%88%E3%81%86%E3%81%AB%E3%81%AA%E3%82%8A%E3%81%BE%E3%81%97%E3%81%9F/61185#61185)でお尋ねした際に、「`~/.profile`等の設定ファイルなどを特に上書きしていなければ、シェルを立ち上げ直せば復活するはずです。上書きしてしまった場合は、`env\n-i bash --norc\n--noprofile`で既存の`.profile`等を読み込まずに`Bash`を起動してその上で作業して設定ファイルを直すことができます。」という内容をご教授いただきましたが、 \n`env -i bash --norc --noprofile`ですら実行できないのです…。\n\nDebian 10での設定ファイルは`bash.bashrc`ですので、 \n`bash.bashrc`を起動せずにbashを動かす方法をご教授願います。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T08:38:00.253",
"favorite_count": 0,
"id": "61207",
"last_activity_date": "2020-02-17T13:49:45.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"bash",
"debian"
],
"title": "Debian 10でbashを起動したときに、bash: dircolors: command not foundと出ます。",
"view_count": 240
} | [
{
"body": "(コメントより)\n\n絶対パスで指定するか、`/usr/bin/env -i /bin/bash --norc --noprofile` もしくは `source\n/etc/environment` として system の PATH 設定を使うのも良いかと。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2020-02-17T13:49:45.173",
"id": "63123",
"last_activity_date": "2020-02-1... | 61207 | 63123 | 63123 |
{
"accepted_answer_id": "61225",
"answer_count": 1,
"body": "配列の中に条件を満たすものが1個でもあるかどうかを、見つかった時点でループを打ち切るように判定したいです。\n\n以下の様に書くしかないですか?Lambda を使って1行で書く方法はないでしょうか。\n\n環境: \nUbuntu \nPython 3.7.5\n\n```\n\n flag = false\n for x in range(10):\n if x == 5:\n flag = true\n break\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T09:14:47.017",
"favorite_count": 0,
"id": "61209",
"last_activity_date": "2019-12-09T00:50:30.847",
"last_edit_date": "2019-12-09T00:50:30.847",
"last_editor_user_id": "3060",
"owner_user_id": null,
"post_type": "question",
"score": 1,
"tags": [
"python"
],
"title": "配列に条件を満たすものがあるか判定する一番かっこいい書き方",
"view_count": 203
} | [
{
"body": "`any`を使ったらこんな感じですね.\n\n```\n\n >>> any(i == 5 for i in range(10))\n True\n >>> any(i == 11 for i in range(10))\n False\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T14:01:36.400",
"id": "61225",
"last_activity_date": "... | 61209 | 61225 | 61225 |
{
"accepted_answer_id": "61211",
"answer_count": 1,
"body": "こんばんは。お世話になります。\n\n私は発達障害持ちです。発達障害の症状で興味のあることに対しては集中しすぎる症状(過集中と呼びます)があります。12時間以上水もろくに飲まずトイレにもほとんど行かずに集中しすぎてしまいます。\n\nまた、Debianに夢中になりすぎるあまり、お風呂にも何日も入れなくなってしまいます。夜も眠れなくなってしまいます。\n\nそれを防ぐために、Debianを強制シャットダウンするOSSを作りたいです。 \n今所属しているスタートアップではJavaScriptを覚えるように言われておりますので、JavaScriptでできたら作りたいのですが、、\n\n機能は、安全にシャットダウンするために5分だけ延長する機能と、 \nシャットダウンまであとX分とかをGUIに表示する機能がほしいです。\n\nまた、緊急時のために、夜中1時にシャットダウンしたら5分後には再起動できるようにしたいです。\n\nどの言語でどのフレームワークで作ればよいのでしょうか。ご教授願ます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T09:27:40.397",
"favorite_count": 0,
"id": "61210",
"last_activity_date": "2019-12-07T16:07:18.087",
"last_edit_date": "2019-12-07T16:07:18.087",
"last_editor_user_id": "3060",
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"debian",
"oss"
],
"title": "指定の時刻になったらDebianを強制的にシャットダウンするOSSを作りたい",
"view_count": 139
} | [
{
"body": "Javascript言語でDebian上でGUIが使えてシェルコマンドを発行できるとなると \n有名なフレームワークにElectronがあります。 \n<https://electronjs.org/>\n\n私も過集中するときがあるので分かります。 \nしかし仕組みをうまく考えないと人間の意志との勝負なのでなかなか難しいと思います。 \nがんばってください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T10:02:49.307",
... | 61210 | 61211 | 61211 |
{
"accepted_answer_id": "61217",
"answer_count": 1,
"body": "現在、RAD Studio 10.3でプログラミングを行っています。 \nプログラムをデバッグ機能を実行中。必ず次のプログラムで”デバッガ例外通知”というのが出てきてしまい、デバッグ実行が続行できなくなってしまいます。\n\n```\n\n void __fastcall TfrmMain::ServerConnect(TIdContext *AContext)\n {\n ------------(中略)---------------------\n if(m_pDevList->Count >= 999){\n ------------(中略)---------------------\n }\n \n```\n\nこのm_pDevListという変数はMain.hファイルでこのように宣言されています。\n\n```\n\n class TfrmMain : public TForm\n {\n ------------(中略)---------------------\n private: // ユーザー宣言\n TList * m_pDevList;\n ------------(中略)---------------------\n }\n \n```\n\nこのm_pDevListというポインタ変数は、デバッグが停止した際にNULLの状態となっていることを確認しました。このNULLの状態だとif文などでアクセスした場合ダメなのでしょうか? \nm_pDevList->Countには”0”としておかないといけないということでしょうか?\n\nこのエラーの回避方法を教えて下さい。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T10:38:22.170",
"favorite_count": 0,
"id": "61212",
"last_activity_date": "2019-12-07T12:54:10.147",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35993",
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "デバッガ例外通知がでてデバッガ続行が不能になる。リスト変数がNULLだから?",
"view_count": 116
} | [
{
"body": "`m_pDevList`はポインタ変数ですので、`NULL`の場合、`->`によるメンバ変数の参照はできません。 \nプログラムは、そのため、異常終了しようとしてデバッガで捕捉されているように見受けます。\n\n#`NULL`は実体を指していない、の意味です。\n\nこれ自体がエラーですので、`m_pDevList`に正しい値を指定することで、事象は解消するはずです。 \n例えば、実体が定義されている場合、そのポインタで初期化すればよいでしょう。\n\n```\n\n class TfrmMain : public TForm\n {\n private:\n ... | 61212 | 61217 | 61217 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "`npm run serveコマンドを入力してプロジェクトを起動させるつもりがエラーがでてしましました。\n\n```\n\n > hello_app2@0.1.0 serve /Users/hogehoge/Mypage/vue-nuxt/ch01/hello_app2\n > vue-cli-service serve\n \n /Users/hogehoge/Mypage/vue-nuxt/ch01/hello_app2/node_modules/open/index.js:16\n const wslToWindowsPath = async path => {\n ^^^^\n SyntaxError: Unexpected identifier\n at createScript (vm.js:56:10)\n at Object.runInThisContext (vm.js:97:10)\n at Module._compile (module.js:542:28)\n at Object.Module._extensions..js (module.js:579:10)\n at Module.load (module.js:487:32)\n at tryModuleLoad (module.js:446:12)\n at Function.Module._load (module.js:438:3)\n at Module.require (module.js:497:17)\n at require (internal/module.js:20:19)\n at Object.<anonymous> (/Users/hogehoge/Mypage/vue-nuxt/ch01/hello_app2/node_modules/@vue/cli-shared-utils/lib/openBrowser.js:9:14)\n npm ERR! code ELIFECYCLE\n npm ERR! errno 1\n npm ERR! hello_app2@0.1.0 serve: `vue-cli-service serve`\n npm ERR! Exit status 1\n npm ERR! \n npm ERR! Failed at the hello_app2@0.1.0 serve script.\n npm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n \n npm ERR! A complete log of this run can be found in:\n npm ERR! /Users/hogehoge/.npm/_logs/2019-12-07T11_56_17_151Z-debug.log\n \n```\n\nこちら \n試してみたこと \n<https://teratail.com/questions/219324> \nnodeモジュールを再インストール\n\n```\n\n rm -rf node_modules package-lock.json && npm install \n \n```\n\n変わらず詰まっています。\n\n他にどういう解決法があるでしょうか?",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T12:18:03.693",
"favorite_count": 0,
"id": "61215",
"last_activity_date": "2019-12-07T13:14:57.683",
"last_edit_date": "2019-12-07T13:14:57.683",
"last_editor_user_id": "2376",
"owner_user_id": "36967",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"vue.js",
"npm"
],
"title": "vue-cliでnpm run serveしたらエラーがでました。",
"view_count": 1339
} | [] | 61215 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Laravelでテーブル、カラムがあるのに、`php artisan migrate`でカラム追加しようとすると、 \n`already exist`となってしまいます。\n\n`php artisan migrate` で `table already exist`\nとなり、しかし、マイグレーションに入れた一部のカラムしか反映されず。 \n↓ \nそのため、`fresh`して、テーブルごと消して、作り直すことにした。 \n↓ \n`php artisan make:migration ●●●‗table` (テーブルを作成) \n↓ \nしかし、`A Create●●●tabel already exists`(●●●はテーブル名)となりテーブルが作成されない。\n\n想定されること。 \n★手動でMySQLのテーブルを削除した。コマンドの履歴ではテーブルを削除した履歴がないため、 \n`already exists`となるのか?\n\nどなたかご教示いただけましたら幸いです。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T12:21:14.107",
"favorite_count": 0,
"id": "61216",
"last_activity_date": "2019-12-17T08:35:43.023",
"last_edit_date": "2019-12-07T13:45:10.963",
"last_editor_user_id": "2376",
"owner_user_id": "35794",
"post_type": "question",
"score": 0,
"tags": [
"mysql",
"laravel"
],
"title": "Laravel migrattionで、already exist",
"view_count": 343
} | [] | 61216 | null | null |
{
"accepted_answer_id": "61224",
"answer_count": 1,
"body": "現在、Gitを用いてローカルリポジトリを中央リポジトリに同期させる練習をしているのですが、作成したファイルをステージ状態にするところで苦戦をしております。\n\nIDLEを用いて作成したhangman.pyというファイルを、コマンドプロンプトのhangmanディレクトリに移動させたのですが(ただ、私がそう認識しているだけであり本当は移動できていないかもしれません)、そこからどうやってステージ状態にするかが分かりません。ぜひプロフェッショナルの皆様からお力を貸していただきたいです。\n\n「独学プログラマー」の本によれば、ステージング状態にするには、コマンドプロンプトにおいて \n`git status` と実行すれば以下のように表示されて成功するはずなのです。\n\n```\n\n On branch master\n Your branch is up-to-date with...(省略)\n \n```\n\nしかし実際には以下のメッセージが表示されてしまいます。どうすればよいのでしょうか?\n\n```\n\n On branch master\n No commits yet\n nothing to commit(create/copy files and use \"git add\" to track)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T12:54:58.100",
"favorite_count": 0,
"id": "61219",
"last_activity_date": "2019-12-18T17:26:16.750",
"last_edit_date": "2019-12-18T17:26:16.750",
"last_editor_user_id": "3060",
"owner_user_id": "36669",
"post_type": "question",
"score": 0,
"tags": [
"git"
],
"title": "ファイルをステージ状態にしたいのですができません",
"view_count": 163
} | [
{
"body": "`git status` はリポジトリの「状態」を確認するコマンドです。ファイルをステージング状態にするにはメッセージにも出ている通り \n`git add FILENAME` を実行してください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T14:00:43.740",
"id": "61224",
"last_activity_date": "2019-12-07T14:00:43.740",
"last_edit_... | 61219 | 61224 | 61224 |
{
"accepted_answer_id": "61385",
"answer_count": 2,
"body": "タイトルのとおりです。 \nRubyで連番の配列を作る最も効率のよい方法はどれでしょうか?\n\n```\n\n [*1..100]\n Array.new(100){|i| i} # 0 … 99\n (1..100).to_a\n \n```\n\nパッと思いつくのは上のような感じですが、ほかにもっと良い方法とかありますでしょうか。 \n配列が大きくなってきた時のパフォーマンスの違いはどうでしょう?\n\n自分でベンチマークとればいいのかも知れませんが、やっぱり質問すると知見が集まることが多いのでみなさまよろしくおねがいします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T13:25:19.687",
"favorite_count": 0,
"id": "61221",
"last_activity_date": "2019-12-12T12:12:58.940",
"last_edit_date": "2019-12-07T23:58:51.447",
"last_editor_user_id": "32772",
"owner_user_id": "32772",
"post_type": "question",
"score": 4,
"tags": [
"ruby"
],
"title": "Rubyで連番の配列を作る最も効率のよい方法はどれでしょうか?",
"view_count": 1275
} | [
{
"body": "恐ろしいことに、ここでRubyの質問をすると、ruby-jpというslackに転送される仕組みになっていたのです。\n\nそこでRubyのコミッターの@n0kadaさんからベンチマークと回答頂きました。ips=instruction/secondsなので数値が大きいほうが速いとのことです。to_aの方がちょっと速いということになりそうです。\n\n```\n\n $ ruby -rbenchmark/ips -e 'Benchmark.ips{|x|x.report(\"splat\") {[*1..100]}; x.report(\"to_a\") {(1..100).to_a}}'\n... | 61221 | 61385 | 61385 |
{
"accepted_answer_id": "61228",
"answer_count": 1,
"body": "お世話になります。 \nC#での文字列検索を行いたいと考えています。 \n下記のようなリストを想定しています。\n\n```\n\n List<string> file_list = new List<string>();\n file_list.Add(\"data/test01.txt\");\n file_list.Add(\"data/test02.txt\");\n file_list(\"data/test03.dat\");\n file_list.Add(\"data/test04.dat\");\n \n```\n\nとりあえず、FindAll等で文字列を指定して検索できることはわかったんですが、ファイル名のワイルドカード(「data/*.txt」のようなもの)にマッチする要素を取り出すにはどうしたらいいでしょうか。 \nちなみに、マッチする要素1つだけではなく、マッチするすべての要素を取得したいと考えています。 \n何かアドバイスをいただけると幸いです。\n\n以上、よろしくお願いいたします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T13:25:47.163",
"favorite_count": 0,
"id": "61222",
"last_activity_date": "2019-12-08T04:51:38.343",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29034",
"post_type": "question",
"score": 0,
"tags": [
"c#"
],
"title": "C#のリストでの文字列検索について",
"view_count": 1796
} | [
{
"body": "コメントで紹介した3つのうち、最初の記事は色々と変なので忘れてください。\n\n3つ目の英語版StackOverflowの記事が短くて良さそうです。 \n[ Need to perform Wildcard (*,?, etc) search on a string using\nRegex](https://stackoverflow.com/q/6907720/9014308) \nさらにオリジナルはこちらのようですが。 \n[Converting Wildcards to\nRegexes](https://www.codeproject.com/Articles/11556/Con... | 61222 | 61228 | 61228 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "シェルスクリプトで現在の時刻(hh:mm)を取得してif文で12:00~13:00の間かそうでないかで条件分岐するプログラムを書きたいです。\n\nこの場合、\n\n```\n\n seccion_time=date '+%h'\n start_time=12:00\n finish_time=13:00\n \n if [ $seccion_time -gt $finish_time]; then\n if [ $seccion_time -lt $finish_time ]; then\n echo 処理開始\n fi\n fi\n \n```\n\nこれだとdate型のフォーマットが正しくなくて動かないので、正しいフォーマットやより良い書き方あればご指南お願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T13:31:10.880",
"favorite_count": 0,
"id": "61223",
"last_activity_date": "2021-10-11T08:08:45.757",
"last_edit_date": "2020-11-19T08:08:38.060",
"last_editor_user_id": "3060",
"owner_user_id": "36290",
"post_type": "question",
"score": 2,
"tags": [
"shellscript"
],
"title": "シェルスクリプトで現在の時刻(hh:mm)を取得してif文で分岐",
"view_count": 4395
} | [
{
"body": "この回答は[metropolis](https://ja.stackoverflow.com/users/16894/metropolis)さんのコメントを元にしたものです。\n\n13:00を含まないなら\n\n```\n\n if [ $(date '+%H') -eq 12 ]; then\n echo '処理開始'\n fi\n \n```\n\nで良いかと。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T0... | 61223 | null | 61252 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "LINEdevelopersにて、 **Webhookの検証** を実行すると、\n**ボットサーバーから200以外のHTTPステータスコードが返されました** というエラーになる問題で困っています。 \n原因または解決策をご存知の方はいらっしゃいませんか。\n\n## 私の行った手順は以下です。\n\n 1. [LINEのBot開発 超入門(前編) ゼロから応答ができるまで](https://qiita.com/nkjm/items/38808bbc97d6927837cd#channel%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B)を参考に、Channelを作成する。\n 2. [Google Apps ScriptでLINE BOTつくったら30分で動かせた件](https://qiita.com/hakshu/items/55c2584cf82718f47464#gas%E3%81%A7%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0)のコードをコピペ。\n 3. 2と同じ記事の内容にしたがってGASでサービスの公開\n 4. LINE developper でWebhookの設定まで行う、[検証](https://gyazo.com/aca1b3aeabfef86f4881354a206eaabb)を実行\n\nすると、以下のような結果になりました。\n\n**エラー**\n\nボットサーバーから200以外のHTTPステータスコードが返されました\n\n\n\nちなみに、エラーのステータスコードは **401** でした。\n\n\n\n私は検証が上手くいくと思いました。 \nなぜなら、『Google Apps ScriptでLINE BOTつくったら30分で動かせた件』の手順通りに行ってみたからです。\n\n原因を確かめるため、以下のような手順を行ってみました\n\n(a) [Messaging API\nのドキュメント](https://developers.line.biz/ja/reference/messaging-api/#status-\ncodes)を確認\n\n> **”有効なチャンネルアクセストークンが指定されていません”**\n\n(b) LINE Devaloppers でチャネルアクセストークンを確認\n\n> Messaging\n> APIを呼び出すときに使用するチャネルアクセストークンです。このチャネルアクセストークンは期限切れになりません。新しいチャネルアクセストークンを発行したり、既存のチャネルアクセストークンを置き換える場合は、「発行」をクリックします。\n\n上記の表記があるが、再発行をしてもう一度GASでWebhookの設定, \n更新→公開URLを LINE Devaloppers に貼り付け\n\n結果に変化はありませんでした。\n\n## 聞きたいこと\n\nLINE側で他にするべき認証の手続きのようなものがあるのでしょうか? \n[https://developer.mozilla.org/](https://developer.mozilla.org/ja/docs/Web/HTTP/Status#Client_error_responses)\n\nまた、考えられる原因として\n\n * LINEdevelopersにおいて、何か設定をしていない\n * GASのコードに問題がある\n\nなどあると思いますが、 **401エラーがどこの部分ででいるのか** 知りたいです。\n\n## GASのコード\n\n(Google Apps ScriptでLINE BOTつくったら30分で動かせた件より)\n\n```\n\n // LINE developersのメッセージ送受信設定に記載のアクセストークン\n var ACCESS_TOKEN = '----------------------------------------------------;\n \n function doPost(e) {\n // WebHookで受信した応答用Token\n var replyToken = JSON.parse(e.postData.contents).events[0].replyToken;\n // ユーザーのメッセージを取得\n var userMessage = JSON.parse(e.postData.contents).events[0].message.text;\n // 応答メッセージ用のAPI URL\n var url = 'https://api.line.me/v2/bot/message/reply';\n \n UrlFetchApp.fetch(url, {\n 'headers': {\n 'Content-Type': 'application/json; charset=UTF-8',\n 'Authorization': 'Bearer ' + ACCESS_TOKEN,\n },\n 'method': 'post',\n 'payload': JSON.stringify({\n 'replyToken': replyToken,\n 'messages': [{\n 'type': 'text',\n 'text': userMessage + 'ンゴ',\n }],\n }),\n });\n return ContentService.createTextOutput(JSON.stringify({'content': 'post ok'})).setMimeType(ContentService.MimeType.JSON);\n }\n \n \n```\n\nなお、私の環境は以下の通りです。 \nmacOS Mojave 10.14.5",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T15:24:06.950",
"favorite_count": 0,
"id": "61226",
"last_activity_date": "2022-03-07T06:04:30.557",
"last_edit_date": "2019-12-07T15:44:57.973",
"last_editor_user_id": "32986",
"owner_user_id": "36971",
"post_type": "question",
"score": 0,
"tags": [
"api",
"google-apps-script",
"line"
],
"title": "GASでLINE MessagingAPIを使った際に出る401エラーの対処法を知りたい",
"view_count": 3802
} | [
{
"body": "[Google Apps\nScript側の設定でパブリックアクセス可能にする](https://teratail.com/questions/227966)必要があります。\n\n* * *\n\nこれで問題は解消しますが、LINE以外からのメッセージも受信してしまうので、実際のbot実装ではLINEが送信したものかの判定が必要なります。\n\n * [署名を検証する](https://developers.line.biz/ja/reference/messaging-api/#signature-validation) \\- Messaging APIリファレンス\n * 公式SDK... | 61226 | null | 61253 |
{
"accepted_answer_id": "61229",
"answer_count": 1,
"body": "初めて質問いたします。\n\n```\n\n A =[[a,b,c],[d,e,f],[g,h,i]]\n \n```\n\n上記のようなリストがあります。 \nそれぞれのリスト内リストの0番目(aとdとg)を削除したいのですが、どのような処理をすればよいのでしょうか。\n\n```\n\n del A[?][0]\n \n```\n\nのように書いたら可能なのでしょうか。\n\n勉強不足で至らないところも多いですが、何卒よろしくお願い致します。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-07T22:37:10.330",
"favorite_count": 0,
"id": "61227",
"last_activity_date": "2019-12-07T23:53:29.710",
"last_edit_date": "2019-12-07T22:52:26.893",
"last_editor_user_id": "32986",
"owner_user_id": "36978",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "リスト内リストの要素を削除したい",
"view_count": 116
} | [
{
"body": "この記事を参考に: \n[Pythonのスライスによるリストや文字列の部分選択・代入](https://note.nkmk.me/python-slice-usage/)\n\nこんな風に出来ます。 \nA自身を変えたいならAに代入。 \n変えたものをAとは別にしたいならその別の物(例えばB)に代入。\n\n```\n\n A = [row[1:] for row in A]\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12... | 61227 | 61229 | 61229 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Excel VBAのADODBでSheetの情報をSELECT文で取得しています。\n\nもとのデータは以下の通りです。 \n[TableA] \n\n\n[TableB] \n\n\nそしてコードは以下のとおりです。\n\n```\n\n Dim myCon As Object\n Dim myRS As Object\n Set myCon = CreateObject(\"ADODB.Connection\")\n Set myRS = CreateObject(\"ADODB.Recordset\")\n \n \n With myCon\n .Provider = \"Microsoft.ACE.OLEDB.12.0\"\n .Properties(\"Extended Properties\") = \"Excel 12.0;HDR=YES;IMEX=1\"\n .Open ThisWorkbook.FullName\n End With\n myRS.Open \"SELECT A.ID, A.Name, B.CountryName FROM ([TableA$A1:C10] AS A LEFT JOIN [TableB$A1:B10] AS B ON A.CountryID = B.CountryID)\", myCon, 1, 1\n Dim myVar As Variant\n 'myVar = myRS.GetRows\n 'myVar = WorksheetFunction.Transpose(myVar)\n Worksheets(\"Result\").Cells.Clear\n Worksheets(\"Result\").Range(\"A1\").CopyFromRecordset myRS\n \n```\n\nここでご質問したいことは \n実行しているSELECT分の結果にFROM句で指定しているもとのデータの行番号を表示したいです。 \n以下の結果で「TableAの行番号」、「TableBの行番号」と記載されている列に行番号がほしいです。\n\nどのようにするか、またそもそも実現できるのかご教授ください。 \nSQL ServerではROW_NUMBER()を使うことができますが、VBAのADODBではどうやるか…\n\nまた用途としては、内容に不備があった場合に「どの行」に不備があるかを通知したいためです。 \nよろしくおねがいします。\n\n[](https://i.stack.imgur.com/FbUxF.png)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-08T00:32:34.590",
"favorite_count": 0,
"id": "61230",
"last_activity_date": "2019-12-10T06:58:52.287",
"last_edit_date": "2019-12-08T07:02:35.577",
"last_editor_user_id": "12388",
"owner_user_id": "12388",
"post_type": "question",
"score": 0,
"tags": [
"vba"
],
"title": "ADODBによるSelect文で行番号も取得したい",
"view_count": 1608
} | [
{
"body": "SQLの中にTABLE AとBそれぞれサブクエリをかませて仮に行番号用のIDを振る形はいかがでしょうか \nAccessなどRow_Number()を使用できないDBでもサブクエリを作成して行番号を取得するためのSQLなどはサンプルが検索できます。 \nただ、サブクエリ乱発は可読性は落ちると思います。\n\n自分ならば 一旦 バッファ用のシートにSelect * from で全件出してdictionaryなどで結合すると思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_da... | 61230 | null | 61294 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "現在、android studioでセンサ取得のアプリを開発しています。\n\nそこでは、サービスを用いてバックグラウンドでもセンサ値を取得できるようにしたいのですが、スリープモードにすると1分ほどで取得が不可能になってしまいました。\n\n解決策を知っている方がいましたら回答よろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-08T06:30:32.413",
"favorite_count": 0,
"id": "61232",
"last_activity_date": "2022-09-01T00:55:32.257",
"last_edit_date": "2022-09-01T00:55:32.257",
"last_editor_user_id": "3060",
"owner_user_id": "36981",
"post_type": "question",
"score": 0,
"tags": [
"android"
],
"title": "スリープ時も加速度センサの値を取得できるようにしたい",
"view_count": 672
} | [
{
"body": "下記が参考になりませんか?\n\nスリープ時にもBroadcastを処理する方法 \n<https://qiita.com/nein37/items/52523e39932323ebc654>",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-08T08:35:41.310",
"id": "61235",
"last_activity_date": "2019-12-08T08:35:41.310",
"last_edit_dat... | 61232 | null | 61235 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "ビルドしたAndroidOSイメージを実機(Pixel3a)に入れたいです。 \nバージョンはAndroid9.0で、タグ(ブランチ)はandroid-9.0.0_r47です。Pixel3aがサポートされています([参考](https://source.android.com/setup/start/build-\nnumbers.html#source-code-tags-and-builds)) \n[ドキュメント](https://source.android.com/setup/build/running)通りに行い、fastboot(fastbootd)モードで`fastboot\nflashall -w`とコマンドを叩くと\n\n```\n\n yamakentoc:/home/yamakentoc/:~$ fastboot flashall -w\n --------------------------------------------\n Bootloader Version...: b4s4-0.2-5736883\n Baseband Version.....: g670-00030-191028-B-5972069\n Serial Number........: 94LAY0R0QK\n --------------------------------------------\n Checking 'product' OKAY [ 0.000s]\n Setting current slot to 'b' OKAY [ 0.081s]\n Sending 'boot_b' (65536 KB) OKAY [ 1.690s]\n Writing 'boot_b' OKAY [ 0.434s]\n Sending 'dtbo_b' (8192 KB) OKAY [ 0.211s]\n Writing 'dtbo_b' OKAY [ 0.113s]\n Sending 'vbmeta_b' (4 KB) OKAY [ 0.001s]\n Writing 'vbmeta_b' OKAY [ 0.002s]\n Resizing 'product_b' OKAY [ 0.005s]\n Resizing 'system_b' OKAY [ 0.004s]\n Resizing 'vendor_b' OKAY [ 0.004s]\n Resizing 'system_b' OKAY [ 0.005s]\n Sending sparse 'system_b' 1/3 (524284 KB) OKAY [ 13.756s]\n Writing 'system_b' OKAY [ 3.394s]\n Sending sparse 'system_b' 2/3 (524284 KB) OKAY [ 13.701s]\n Writing 'system_b' OKAY [ 3.619s]\n Sending sparse 'system_b' 3/3 (133160 KB) OKAY [ 3.476s]\n Writing 'system_b' OKAY [ 1.217s]\n Sending 'system_a' (91744 KB) OKAY [ 2.375s]\n Writing 'system_a' OKAY [ 0.615s]\n Erasing 'userdata' OKAY [ 0.062s]\n Erase successful, but not automatically formatting.\n File system type raw not supported.\n Erasing 'metadata' OKAY [ 0.005s]\n Erase successful, but not automatically formatting.\n File system type raw not supported.\n Rebooting OKAY [ 0.000s]\n Finished. Total time: 44.881s\n yamakentoc:/home/yamakentoc/:~$ \n \n```\n\nこのようにエラーは出ず、しっかりと入った(多分)と思います。これで起動するはずですが... \n[](https://i.stack.imgur.com/D1idH.jpg) \nfastbootモードが起動し、画面には`Enter reazon: failed to load/verify boot images`と出ます。\n\n何がいけないのでしょうか? \n画像でわかると思いますが、ブートローダーのアンロックはしています。 \n`ANDROID_PRODUCT_OUT=/home/yamakentoc/AOSP/out/target/product/sargo/`と指定もしてます。\n\nご教授よろしくお願い致します。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-08T08:19:30.273",
"favorite_count": 0,
"id": "61233",
"last_activity_date": "2023-05-31T13:02:10.347",
"last_edit_date": "2019-12-08T11:54:06.620",
"last_editor_user_id": "2238",
"owner_user_id": "30542",
"post_type": "question",
"score": 0,
"tags": [
"android"
],
"title": "ビルドしたAndroidのOSイメージを実機に入れたい (failed to load/verify boot images)",
"view_count": 616
} | [
{
"body": "自己解決しました! \n↓のサイトからバイナリハードウェアサポートファイルをルートディレクトリにDLする必要がありました! \n<https://developers.google.com/android/drivers>\n\n詳しいことはQiitaにまとめました \n<https://qiita.com/yamakentoc/items/564108cd5ad207193f0e>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-19T10:54:... | 61233 | null | 61586 |
{
"accepted_answer_id": "61237",
"answer_count": 3,
"body": "python初心者です。\n\n```\n\n A = [[a,0,0,0,0],[b,1,0,0,0],[c,0,1,0,0],[a,0,0,0,1]]\n \n```\n\n以下がAというリストに対して行いたい処理です。\n\n①それぞれの要素の0番目(a,b,c)を照合 \n②重複するものがあれば(例ではaが重複)、今度は1番目~4番目の要素を照合 \n③0番目は同じだが、1~4番目が完全一致しないものをリスト化して抽出する\n\n以下のようなリストを作りたいです。\n\n```\n\n result = [[a,0,0,0,0,],[a,0,0,0,1]]\n \n```\n\n知識不足ながらプログラム案を考えてみました。\n\n```\n\n A = [[a,0,0,0,0],[b,1,0,0,0],[c,0,1,0,0],[a,0,0,0,1]]\n result = []\n for i in A[?][1]:\n if i==A[?][1]:\n result.append(i)\n \n```\n\nこれにどのような変更を加えたら良いのか分かりません。 \nご教示お願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-08T08:19:56.987",
"favorite_count": 0,
"id": "61234",
"last_activity_date": "2019-12-09T17:46:50.133",
"last_edit_date": "2019-12-08T08:38:20.853",
"last_editor_user_id": "36978",
"owner_user_id": "36978",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "リスト内の要素を照合して抽出したい",
"view_count": 917
} | [
{
"body": "これらの記事を参考に: \n[Pythonで2次元配列の重複行を一発で削除する](https://qiita.com/uuuno/items/b714d84ca2edbf16ea19) \n[Pythonのスライスによるリストや文字列の部分選択・代入](https://note.nkmk.me/python-slice-usage/) \n[Pythonでリスト(配列)から重複した要素を削除・抽出](https://note.nkmk.me/python-list-unique-\nduplicate/) \n[PythonのCounterでリストの各要素の出現個数をカウント](http... | 61234 | 61237 | 61238 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "こんばんは、最近Pythonを勉強しはじめた学生です。pythonを用いてGoogleニュースのスクレイピングをしようとしているのですが、思う通りに動かないので、プロフェッショナルの皆様からお力を貸していただきたいです。 \n今現在、「独学プログラマーの本」を読みながら勉強しているのですが、この本に書いてある通り、\n\n```\n\n >>>import urllib.request\n >>> from bs4 import BeautifulSoup\n >>> class Scraper:\n def __init__(self, site):\n self.site = site\n def scrape(self):\n r = urllib.request.urlopen(self.site)\n html = r.read()\n parser = \"html.parser\"\n sp = BeautifulSoup(html, parser)\n for tag in sp.find_all(\"a\"):\n url = tag.get(\"href\")\n if url is None:\n continue\n if \"html\" in url:\n print(\"\\n\" + url)\n \n \n >>> news = \"https://news.google.com/\"\n >>> Scraper(news).scrape()\n \n```\n\nとコードを書いたのですが、何も表示されません(本来だとgoogleニュースのヘッドライン記事のURLが出てくるようです)。ちなみに、エラーも表示されません。どうすればよいのでしょうか?",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-08T13:02:33.013",
"favorite_count": 0,
"id": "61240",
"last_activity_date": "2019-12-09T00:04:27.527",
"last_edit_date": "2019-12-09T00:04:27.527",
"last_editor_user_id": "32986",
"owner_user_id": "36669",
"post_type": "question",
"score": 1,
"tags": [
"python"
],
"title": "googleニュースのスクレイピングのやり方",
"view_count": 544
} | [] | 61240 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Raspberry Pi 4にUbuntu Server\n19.10をインストールした際のデフォルトのユーザー名を変更したいのですがどうすればよいのでしょうか?\n\nデフォルトではユーザー名が`ubuntu`、パスワードも`ubuntu`になっており、これを例えば(ユーザー名:helloman\nパスワード:0123456789)というようなものに変更したいのですがどうすればいいのでしょうか?\n\nどうやらSDカードにraspi用のimageを焼いた後、`user-\ndata`というファイルを編集すればよいらしく、下記の例を参考にやってみたのですがうまくいきません。なぜでしょうか?\n\n<https://cloudinit.readthedocs.io/en/stable/topics/examples.html>\n\nパスワードは数字だけのものに変更したいです。(弱いパスワードなのは承知していますがやってみたいです)\n\n自分で編集したuser-data:\n\n```\n\n #cloud-config\n \n # This is the user-data configuration file for cloud-init. By default this sets\n # up an initial user called \"ubuntu\" with password \"ubuntu\", which must be\n # changed at first login. However, many additional actions can be initiated on\n # first boot from this file. The cloud-init documentation has more details:\n #\n # https://cloudinit.readthedocs.io/\n #\n # Some additional examples are provided in comments below the default\n # configuration.\n \n # Enable password authentication with the SSH daemon\n ssh_pwauth: true\n #### this section created by KiYugadgeter\n #\n #\n system_info:\n default_user:\n name: helloman\n plain_text_passwd: '0123456789'\n home: /home/helloman\n shell: /bin/bash\n lock_passwd: true\n gecos: helloman\n grops: [adm, audio, cdrom, dialout, floppy, video, plugdev, netdev]\n \n #\n #\n #\n ######## end of section\n # On first boot, set the (default) ubuntu user's password to \"ubuntu\" and\n # expire user passwords\n chpasswd:\n expire: false\n list:\n - helloman:'0123456789'\n \n ## Add users and groups to the system, and import keys with the ssh-import-id\n ## utility\n #groups:\n #- robot: [robot]\n #- robotics: [robot]\n #- pi\n #\n users:\n - default\n #- name: robot\n # gecos: Mr. Robot\n # primary_group: robot\n # groups: users\n # ssh_import_id: foobar\n # lock_passwd: false\n # passwd: $5$hkui88$nvZgIle31cNpryjRfO9uArF7DYiBcWEnjqq7L1AQNN3\n \n ## Update apt database and upgrade packages on first boot\n #package_update: true\n #package_upgrade: true\n \n ## Install additional packages on first boot\n #packages:\n #- pwgen\n #- pastebinit\n #- [libpython2.7, 2.7.3-0ubuntu3.1]\n \n ## Write arbitrary files to the file-system (including binaries!)\n #write_files:\n #- path: /etc/default/keyboard\n # content: |\n # # KEYBOARD configuration file\n # # Consult the keyboard(5) manual page.\n # XKBMODEL=\"pc105\"\n # XKBLAYOUT=\"gb\"\n # XKBVARIANT=\"\"\n # XKBOPTIONS=\"ctrl: nocaps\"\n # permissions: '0644'\n # owner: root:root\n #- encoding: gzip\n # path: /usr/bin/hello\n # content: !!binary |\n # H4sIAIDb/U8C/1NW1E/KzNMvzuBKTc7IV8hIzcnJVyjPL8pJ4QIA6N+MVxsAAAA=\n # owner: root:root\n # permissions: '0755'\n \n ## Run arbitrary commands at rc.local like time\n #runcmd:\n #- [ ls, -l, / ]\n #- [ sh, -xc, \"echo $(date) ': hello world!'\" ]\n #- [ wget, \"http://ubuntu.com\", -O, /run/mydir/index.html ]\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-08T14:41:48.120",
"favorite_count": 0,
"id": "61241",
"last_activity_date": "2020-06-24T17:06:15.707",
"last_edit_date": "2019-12-08T16:39:34.720",
"last_editor_user_id": "3060",
"owner_user_id": "5246",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"ubuntu",
"raspberry-pi"
],
"title": "Raspberry Pi 4にUbuntu Server 19.10をインストールした際のデフォルトユーザー名を変更する",
"view_count": 1587
} | [
{
"body": "user-data だと変更できないです。user-data が処理される前に /etc/cloud/cloud.cfg に書かれた内容で\n作成されています。\n\nいったん 別の Linux 環境で MicroSD の ext4 パーティションをマウントして、etc/cloud/cloud.cfg\nをエディタで編集してユーザー名を変更してください。 そのあとで、user-data でパスワード設定するようにしてみてください。\n\nもしくは、普通にインストールして、userdel ubuntu してから useradd helloman してみても良いかもしれません。\n\n 1. ub... | 61241 | null | 61281 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Npmでパッケージ管理をしています。 \n使っているパッケージが推移的に依存しているパッケージを、まだリリースされていないプルリクを含んだ状態で使いたいです。 \npackage.jsonをどのように書けば良いでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T00:49:34.247",
"favorite_count": 0,
"id": "61245",
"last_activity_date": "2019-12-09T00:49:34.247",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13492",
"post_type": "question",
"score": 3,
"tags": [
"npm"
],
"title": "Npmで推移的依存パッケージをプルリクを含んだ状態で使用",
"view_count": 23
} | [] | 61245 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、画像処理の分野で研究をしてるのですが、「Learning correspondence from the cycle consistency of\ntime」という論文でわからないことがあったため質問させてもらいます。 \n<https://arxiv.org/abs/1903.07593>\n\nこの論文は動画像中の物体を教師なし学習で追跡するような機構で、時刻t→t-1への物体追跡では、時刻t-1の画像と時刻tの画像中から切り出されたパッチが入力となり、出力には時刻tのパッチが時刻がt-1の画像上のどこともっとも対応してるかを出力します。 \nその際、画像中のどこと対応しているかを画像中心を座標中心とし、[-1,1]に正規化された空間でのアフィン変換によって表されます(具体的には回転、並進) \n<https://i.stack.imgur.com/rhNVe.png>\n\nここで質問なのですが、論文ではこのアフィン変換のパラメータを特徴マップ空間での対応としているのですが(p4のFigure4の最後から2行目の文)、実際のコードではそのまま画像空間にアフィン変換のパラメータを適用しています。\n\nこれは特徴マップ空間での回転、並進(もっとも似ている場所はどこかのマッチング)といった幾何変換が画像空間での幾何変換と同じものを表してると暗に示していると思いますが、そうなのでしょうか?\n\n参考となる論文は \n「spatial transformer networks」 \n<https://arxiv.org/abs/1506.02025> \nと \n「Convolutional neural network architecture for geometric matching」 \n<https://arxiv.org/abs/1703.05593> \nの二つです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T02:02:55.220",
"favorite_count": 0,
"id": "61247",
"last_activity_date": "2019-12-09T02:02:55.220",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20613",
"post_type": "question",
"score": 1,
"tags": [
"画像",
"ニューラルネットワーク"
],
"title": "特徴空間での幾何変換のパラメータを画像空間での幾何変換にそのまま適用していいのか",
"view_count": 37
} | [] | 61247 | null | null |
{
"accepted_answer_id": "61250",
"answer_count": 1,
"body": "プログラミング、開発環境構築の初心者です。\n\nUbuntu,nginx,gunicorn,DjangoでPythonのwebシステムを開発しています。\n\nローカルで作ったサイトを、Ubuntu,ncinx,gunicorn,Djangoを使用したサーバーにデプロイし、独自ドメインでのアクセスが可能な状況まで開発しました。 \nその後、SSL化に対応させるために、Let's\nEncryptを利用してnginxのファイルを設定しているのですが、ファイルの編集を行った後、nginxが起動できない状況です。\n\n解決策について、ご教授していただきないでしょうか?\n\n**エラーログ**\n\n```\n\n * nginx.service - A high performance web server and a reverse proxy server\n Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)\n Active: failed (Result: exit-code) since Mon 2019-12-09 10:20:34 JST; 9min ago\n Docs: man:nginx(8)\n Process: 1882 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)\n \n Dec 09 10:20:34 ik1-305-12685 systemd[1]: Starting A high performance web server and a reverse proxy server...\n Dec 09 10:20:34 ik1-305-12685 nginx[1882]: nginx: [warn] the \"ssl\" directive is deprecated, use the \"listen ... ssl\" directive instead in /etc/nginx/sites-enabled/myblogapp:47\n Dec 09 10:20:34 ik1-305-12685 nginx[1882]: nginx: [emerg] cannot load certificate \"/etc/letsencrypt/live/www.harvest-timer.com/fullchain.pem\": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No s\n Dec 09 10:20:34 ik1-305-12685 nginx[1882]: nginx: configuration file /etc/nginx/nginx.conf test failed\n Dec 09 10:20:34 ik1-305-12685 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE\n Dec 09 10:20:34 ik1-305-12685 systemd[1]: nginx.service: Failed with result 'exit-code'.\n Dec 09 10:20:34 ik1-305-12685 systemd[1]: Failed to start A high performance web server and a reverse proxy server.\n \n```\n\n**nginx設定ファイル**\n\n```\n\n #httpリダイレクト\n server {\n listen 80;\n listen [::]:80;\n server_name harvest-timer.com;\n return 301 https://$host$request_uri;\n }\n \n #wwwリダイレクト\n server {\n listen 80;\n listen 443 ssl;\n server_name www.harvest-timer.com;\n ssl_certificate /etc/letsencrypt/live/www.harvest-timer.com/fullchain.pem;\n ssl_certificate_key /etc/letsencrypt/live/www.harvest-timer.com/privkey.pem;\n return 301 https://harvest-timer.com$request_uri;\n }\n \n #リダイレクト先設定\n server {\n listen 443 ssl default_server;\n server_name harvest-timer.com;\n ssl on;\n ssl_certificate /etc/letsencrypt/live/harvest-timer.com/fullchain.pem;\n ssl_certificate_key /etc/letsencrypt/live/harvest-timer.com/privkey.pem;\n \n location = /favicon.ico {access_log off; log_not_found off;}\n \n location /static/ {\n alias /home/username/myblogapp;\n }\n \n location /static/admin {\n alias /home/username/dj2/lib/python3.7/site-packages/django/contrib/admin/static/admin;\n }\n \n location / {\n include proxy_params;\n proxy_pass http://unix:/home/username/myblogapp/myblogapp.sock;\n }\n \n }\n 75,1 Bot\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T02:05:53.890",
"favorite_count": 0,
"id": "61249",
"last_activity_date": "2019-12-18T17:19:48.987",
"last_edit_date": "2019-12-18T17:19:48.987",
"last_editor_user_id": "3060",
"owner_user_id": "36988",
"post_type": "question",
"score": 0,
"tags": [
"ubuntu",
"nginx",
"ssl",
"letsencrypt"
],
"title": "SSLの設定をした後nginxが起動できない",
"view_count": 6528
} | [
{
"body": "エラーメッセージ「Dec 09 10:20:34 ik1-305-12685 nginx[1882]: nginx: [emerg] cannot load\ncertificate \"/etc/letsencrypt/live/www.harvest-timer.com/fullchain.pem\":\nBIO_new_file() failed (SSL: error:02001002:system library:fopen:No s」[直訳](証明書\n\"/etc/letsencrypt/live/www.harvest-\ntimer.com/fullchain.pem\"が読み... | 61249 | 61250 | 61250 |
{
"accepted_answer_id": "61270",
"answer_count": 1,
"body": "<https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Issue_with_plain_JSON.stringify_for_use_as_JavaScript>\n\n上記 javascript の、 `JSON.stringify` を見ていたのですが、そこで以下のような記述がありました。\n\n>\n> 配列以外のオブジェクトのプロパティでは、特定の順番で文字列化されることは保証されていません。文字列化された同じオブジェクトの中でプロパティの順番に依存しないようにしてください。\n\n例えば、 stringify の結果を KVS のキーにしたいような場合、この性質はあまりいいものではありません。\n\n### 質問\n\n * 同じ構造的な値を表す2つのオブジェクトが、同一の JSON 文字列に変換されるような stringify を実現するライブラリや手法などには、どのようなものがありますか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T02:57:45.907",
"favorite_count": 0,
"id": "61251",
"last_activity_date": "2019-12-09T11:44:49.383",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"node.js",
"json"
],
"title": "javascript で、同じ値のオブジェクトならば必ず同じ文字列になる stringify はどうやったら記述できる?",
"view_count": 160
} | [
{
"body": "`json-stable-stringify` をお探しではありませんか?\n\n<https://www.npmjs.com/package/json-stable-stringify>\n\n```\n\n > var stringify = require('json-stable-stringify');\n undefined\n > var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };\n undefined\n > stringify(obj);\n '{\"a\":3,\"b\":[{\"x\":4,\... | 61251 | 61270 | 61270 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "C言語初心者です.以下はバグのあったコードです.\n\n```\n\n #include <stdio.h>\n int main(void){\n int repeat;\n \n int value1 = 0;\n int value2 = 0;\n \n int v;\n int add;\n char command[10];\n \n char str[3];\n scanf(\"%d\", &repeat);\n \n int i;\n for (i=0; i<repeat; i=i+1){\n scanf(\"%s %d %d\",&command, &v, &add);\n if (command == \"SET\"){\n if (v == 1){\n value1 += add;\n printf(\"%s %d %d\\n\", command, value1, value2);\n //ここで,addが例えば,SET 1 10と入力するとadd==1となる.しかも,value1==-1となる.(value1+=addのはずが,逆に引き算される.)\n }\n else{\n printf(\"%d\", v);\n value2 += add;\n printf(\"%s %d %d\\n\", command, value1, value2);\n //ここで,例えば,SET 2 20と入力するとvalue1にadd==2が引き算されてvalue1==-3になる.\n }\n }\n else if (command == \"ADD\"){\n ここから下は省略.\n \n```\n\nこれらのバグが起きる原因が分かりません. \nこの一連のバグの原因はaddにあると思われるのですが,詳しく教えていただけないでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T05:50:06.320",
"favorite_count": 0,
"id": "61256",
"last_activity_date": "2019-12-09T06:07:59.860",
"last_edit_date": "2019-12-09T05:53:42.943",
"last_editor_user_id": "3060",
"owner_user_id": "36992",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "C言語の基本的なコードのバグ",
"view_count": 304
} | [
{
"body": "とりあえずchar [] の比較を==でしているのは気になる。 \nC言語ならstrcmpとかでは?\n\nデバッガでちゃんと問題の箇所を実行しているか確認してみるのがいいかと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T06:02:06.377",
"id": "61257",
"last_activity_date": "2019-12-09T06:02:06.377",
"last_edit_date":... | 61256 | null | 61257 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "初めて質問します! \n他人が作成したNuxtプロジェクトを引き継いで開発をしている新米エンジニアです。 \nJestのスナップショットテストでエラーが出て、どうしようもないのでどなたかヒントをお与えください....!!\n\n# 困っていること\n\nコマンドラインにて`$jest --coverage`ののち、テスト結果でエラーが出ています。 \n上位コマンド実行後の出力結果のうち、エラーに関係がある最後の部分のみ書きます。\n\n### コマンドライン\n\n```\n\n Summary of all failing tests\n FAIL spec/components/ActivityWritingModal.spec.js\n ● components/ActivityWritingModal.vue › スナップショット\n \n expect(received).toMatchSnapshot()\n \n Snapshot name: `components/ActivityWritingModal.vue スナップショット 1`\n \n - Snapshot\n + Received\n \n @@ -58,11 +58,21 @@\n hint=\"カレンダーアイコンをクリックすると、今日の日付が入ります\"\n label=\"タイトル\"\n loaderheight=\"2\"\n messages=\"\"\n required=\"\"\n - rules=\"v => !!v || 'タイトルは必須です'\"\n + rules=\"v => {\n + /* istanbul ignore next */\n + cov_2l6sjua4gi.f[2]++;\n + cov_2l6sjua4gi.s[12]++;\n + return (\n + /* istanbul ignore next */\n + (cov_2l6sjua4gi.b[3][0]++, !!v) ||\n + /* istanbul ignore next */\n + (cov_2l6sjua4gi.b[3][1]++, 'タイトルは必須です')\n + );\n + }\"\n successmessages=\"\"\n type=\"text\"\n value=\"\"\n />\n </v-flex-stub>\n \n 49 | })\n 50 | \n > 51 | expect(wrapper.element).toMatchSnapshot()\n | ^\n 52 | })\n 53 | \n 54 | it('mountされる', () => {\n \n at Object.toMatchSnapshot (spec/components/ActivityWritingModal.spec.js:51:29)\n \n \n Snapshot Summary\n › 1 snapshot failed from 1 test suite. Inspect your code changes or run `yarn test -u` to update them.\n \n Test Suites: 1 failed, 23 passed, 24 total\n Tests: 1 failed, 63 passed, 64 total\n Snapshots: 1 failed, 14 passed, 15 total\n Time: 8.269s\n Ran all test suites.\n error Command failed with exit code 1.\n info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n husky > pre-push hook failed (add --no-verify to bypass)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T06:09:17.767",
"favorite_count": 0,
"id": "61259",
"last_activity_date": "2020-02-15T14:40:23.330",
"last_edit_date": "2020-02-15T14:40:23.330",
"last_editor_user_id": "32986",
"owner_user_id": "36288",
"post_type": "question",
"score": 3,
"tags": [
"vue.js",
"nuxt.js",
"jestjs"
],
"title": "NuxtプロジェクトでのJest スナップショットテストエラー",
"view_count": 147
} | [] | 61259 | null | null |
{
"accepted_answer_id": "61266",
"answer_count": 1,
"body": "pyqt5で画像全体を徐々に透明化させたいです。下は試しに書いてみたコードです。\n\n```\n\n import sys\n from PyQt5.QtWidgets import *\n from PyQt5.QtGui import *\n from PyQt5.QtCore import *\n from PyQt5 import QtGui,QtCore, QtWidgets\n import os.path\n from PIL import Image, ImageOps, ImageFilter\n from PIL.ImageQt import ImageQt\n \n \n \n class Example(QtWidgets.QDialog):\n def __init__(self, parent=None):\n super().__init__(parent)\n \n self.button1 = QtWidgets.QPushButton('実行',self)\n self.button1.clicked.connect(self.calc)\n self.count=255\n \n self.button2 = QtWidgets.QPushButton(self)\n global img\n img = \"./image/star.png\"\n self.button2.setIcon(QIcon(img))\n self.button2.setIconSize(QSize(400,300))\n \n layout=QtWidgets.QVBoxLayout()\n layout.addWidget(self.button1)\n layout.addWidget(self.button2)\n \n self.setLayout(layout)\n \n \n def calc(self):\n image = Image.open(img)\n image=image.copy()\n self.count=self.count-10\n if self.count<0:\n self.count=0\n else:\n pass\n image.putalpha(self.count)#0~255まで\n \n qim = ImageQt(image)\n qim2=QPixmap.fromImage(qim)\n self.button2.setIcon(QIcon(qim2))\n \n if __name__ == '__main__':\n app = QApplication(sys.argv)\n ex = Example()\n ex.show()\n app.exec_()\n \n```\n\nこれを実行すると次のようなGUIが作成されます。 \n[](https://i.stack.imgur.com/jgebR.png) \n星の画像はパワーポイントで保存した図形で、背景が透明になっています。ここで、実行ボタンを押すと、その度に星の画像が徐々に透明化されていくようにコードを書いたつもりです。しかし、実際に実行ボタンを押すと、次のように星の背景が黒い画像となりました。 \n[](https://i.stack.imgur.com/3e4Ao.png) \n何故こんなことが起こってしまうのでしょうか。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T07:56:07.853",
"favorite_count": 0,
"id": "61262",
"last_activity_date": "2019-12-09T11:29:14.360",
"last_edit_date": "2019-12-09T11:29:14.360",
"last_editor_user_id": "19110",
"owner_user_id": "26529",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"pyqt5"
],
"title": "pyqt5で画像全体を透明化させようとすると背景に色がつく",
"view_count": 403
} | [
{
"body": "画像の背景を透過させても元の色はそのまま情報として残っているみたいですね。そしてputalpha関数では画像全体を透過させる際、元の背景の色が復活してしまうようです。一応、下の画像のように予め背景の色をいらない色に編集しておけば、画像を透過させたのち、改めてその色を完全に透過させることで実行は可能のようです。ここでは背景色を青色にしています。 \n[](https://i.stack.imgur.com/2Aua3.png) \n次は実際のコードです。\n\n```\n\n import sys\n ... | 61262 | 61266 | 61266 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "C#のasp.netの複数のWebプログラム上で、設定ファイルをカレントフォルダからの相対パスで読込したいと考えております。\n\nフォルダ構成例は以下でAアプリのイベントからはAアプリのaaa.xmlを参照できる、BアプリのイベントからはBアプリのaaa.xmlが参照できるようにしたいです。\n\nIISルートフォルダ¥ \n¥Aアプリ¥Properties¥aaa.xml \n¥Bアプリ¥Properties¥aaa.xml\n\n実現できる方式はありますでしょうか?\n\n.NET は4.6.2 \nIISの動作サーバは、Windows Server 2016となります。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T09:58:22.153",
"favorite_count": 0,
"id": "61265",
"last_activity_date": "2019-12-09T19:44:04.500",
"last_edit_date": "2019-12-09T16:22:48.370",
"last_editor_user_id": "9228",
"owner_user_id": "9228",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"asp.net"
],
"title": "IIS ワーカープロセスの複数のアプリから相対パス指定で設定ファイルを読み込む方法はありますか?",
"view_count": 608
} | [
{
"body": "IIS + .NET Framework の場合は [MapPath](https://docs.microsoft.com/ja-\njp/dotnet/api/system.web.httprequest.mappath?view=netframework-4.8) を使います。\n\n`カレントフォルダからの相対パス` ではなくて Web ルートからの相対パスで指定します。\n\n```\n\n string fullpath = Request.MapPath(\"~/config/aaa.config\");\n \n```\n\n`~/` が アプリケーションの TOP ... | 61265 | null | 61280 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "画像内で指定した領域に平均フィルタをかけて、フィルタをかける前の画像との誤差を画素ごとの画素値の差で求め、それが最大になる場合と最小になる場合の領域の位置と処理後の画像を求めようとしています。 \n誤差は処理前後の画像のrgb値の差の二乗を求め、それらの合計によって定義します。\n\n以下のように誤差計算の動作確認を行ったところ、動作が非常に重く作業が進行しません。 \n問題点や解決法をご教示いただけると幸いです。\n\n```\n\n from PIL import Image\n import numpy as np\n import cv2\n import matplotlib.pyplot as plt\n import math\n \n \n def main():\n F = cv2.imread(\"gazou.jpg\")\n m, n, c = F.shape\n h = 30\n M = math.floor(m/h)\n N = math.floor(n/h)\n im = F[1:M*h, 1:N*h]\n list = []\n for i in range(h):\n for j in range(h):\n D = im[i:(i+(M-1)*h-1), j:(j+(N-1)*h-1)]\n P = cv2.blur(D, (h, h))\n List = []\n for x in range((M-1)*h-1):\n for y in range((N-1)*h-1):\n Db,Dg,Dr = D[x,y]\n Pb,Pg,Pr = P[x,y]\n e = pow(int(Dr)-int(Pr), 2)+pow(int(Dg)-int(Pg), 2)+pow(int(Db)-int(Pb), 2)\n List.append(e)\n E = sum(List)\n list.append(E)\n Emin = min(list)\n Emax = max(list)\n print(Emin)\n print(Emax)\n \n \n if __name__ == '__main__':\n main()\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T10:32:18.033",
"favorite_count": 0,
"id": "61268",
"last_activity_date": "2019-12-10T01:06:50.553",
"last_edit_date": "2019-12-09T11:28:58.063",
"last_editor_user_id": "19110",
"owner_user_id": "36996",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "python 2枚の画像の誤差計算について",
"view_count": 757
} | [
{
"body": "やはり四重ループが気になりますね.NumPy自体はC言語等で実装されているため,ある程度速いはずなのですが,for文を書いてしまうとその性能を発揮できず,どうして遅くなってしまいます.\n\nとりあえず,内側のfor文2つは簡単に無くせるので書き換えると以下のようになりました.\n\n```\n\n def main2():\n F = cv2.imread(\"gazou.jpg\")\n m, n, c = F.shape\n h = 30\n M = math.floor(m/h)\n N = math.floor... | 61268 | null | 61274 |
{
"accepted_answer_id": "61273",
"answer_count": 1,
"body": "ディレクトリは以下のように構成されています。\n\n```\n\n .\n ├── mod_a\n │ └── main.py\n └── mod_b\n ├── __init__.py\n └── cls_b.py\n \n```\n\nまた各ファイルの中身は以下のようになっています。\n\nmain.py\n\n```\n\n import sys\n sys.path.append('../')\n \n from mod_b import ClsB\n \n print(ClsB.hello())\n \n```\n\nmod_b/__init__.py\n\n```\n\n from .cls_b import ClsB\n \n```\n\nmod_b/cls_b.py\n\n```\n\n class ClsB:\n @staticmethod\n def hello():\n return 'Hello Cls B'\n \n```\n\nこの状態でmain.pyを実行すると、mod_bが見つからないという旨のエラーが発生します。\n\n```\n\n > py mod_a/main.py \n Traceback (most recent call last):\n File \"mod_a/main.py\", line 4, in <module>\n from mod_b import ClsB\n ModuleNotFoundError: No module named 'mod_b'\n Error in sys.excepthook:\n Traceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/apport_python_hook.py\", line 63, in apport_excepthook\n from apport.fileutils import likely_packaged, get_recent_crashes\n File \"/usr/lib/python3/dist-packages/apport/__init__.py\", line 5, in <module>\n from apport.report import Report\n File \"/usr/lib/python3/dist-packages/apport/report.py\", line 30, in <module>\n import apport.fileutils\n File \"/usr/lib/python3/dist-packages/apport/fileutils.py\", line 23, in <module>\n from apport.packaging_impl import impl as packaging\n File \"/usr/lib/python3/dist-packages/apport/packaging_impl.py\", line 24, in <module>\n import apt\n File \"/usr/lib/python3/dist-packages/apt/__init__.py\", line 23, in <module>\n import apt_pkg\n ModuleNotFoundError: No module named 'apt_pkg'\n \n Original exception was:\n Traceback (most recent call last):\n File \"mod_a/main.py\", line 4, in <module>\n from mod_b import ClsB\n ModuleNotFoundError: No module named 'mod_b'\n \n```\n\n`sys.path.append('../')`によってmod_bはimportの検索対象に入っていると思うのですが、なぜうまくimport出来ていないのかが分かりません。\n\nmain.pyからmod_bパッケージを読み込む方法を教えて下さい。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T12:42:38.097",
"favorite_count": 0,
"id": "61272",
"last_activity_date": "2019-12-09T13:21:47.350",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9616",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "親ディレクトリに存在するパッケージのimportに失敗する",
"view_count": 2492
} | [
{
"body": "`> py\nmod_a/main.py`ということで、起動時のディレクトリが、まさにその親ディレクトリだから、それを起点にさらに親ディレクトリに探しに行っているようです。\n\n以下のどれかのパターンで出来るでしょう。 \nもっと良いやり方はあるでしょうが、それは他の人に。\n\n * `mod_a`ディレクトリに降りて`py main.py`と実行する\n * `sys.path.append('../')`を`sys.path.append('./')`に変更する\n * `import os`して、`sys.path.append('../')`を`sys.path.append... | 61272 | 61273 | 61273 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "以下のようなディレクトリ構成で、 \n`main.py`から`cls_a.py`を呼び出そうと考えています。\n\n```\n\n pkg_a\n ├── __init__.py\n ├── cls_a.py\n └── main.py\n \n```\n\n各ファイルの中身は以下の通りです。\n\n * __init__.py\n\n```\n\n from .cls_a import ClsA\n \n```\n\n * cls_a.py\n\n```\n\n class ClsA:\n @staticmethod\n def hello():\n return 'Hello Cls A'\n \n```\n\n * main.py\n\n```\n\n from pkg_a import ClsA\n print(ClsA.hello())\n \n```\n\npkg_aディレクトリから`main.py`を実行すると、pkg_aモジュールが見つからないという旨のエラーが出てしまうのですが、正常にモジュールの読み込みを行うにはどうすれば良いですか?\n\n```\n\n > py main.py \n Traceback (most recent call last):\n File \"main.py\", line 1, in <module>\n from pkg_a import ClsA\n ModuleNotFoundError: No module named 'pkg_a'\n Error in sys.excepthook:\n Traceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/apport_python_hook.py\", line 63, in apport_excepthook\n from apport.fileutils import likely_packaged, get_recent_crashes\n File \"/usr/lib/python3/dist-packages/apport/__init__.py\", line 5, in <module>\n from apport.report import Report\n File \"/usr/lib/python3/dist-packages/apport/report.py\", line 30, in <module>\n import apport.fileutils\n File \"/usr/lib/python3/dist-packages/apport/fileutils.py\", line 23, in <module>\n from apport.packaging_impl import impl as packaging\n File \"/usr/lib/python3/dist-packages/apport/packaging_impl.py\", line 24, in <module>\n import apt\n File \"/usr/lib/python3/dist-packages/apt/__init__.py\", line 23, in <module>\n import apt_pkg\n ModuleNotFoundError: No module named 'apt_pkg'\n \n Original exception was:\n Traceback (most recent call last):\n File \"main.py\", line 1, in <module>\n from pkg_a import ClsA\n ModuleNotFoundError: No module named 'pkg_a'\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T17:23:45.533",
"favorite_count": 0,
"id": "61276",
"last_activity_date": "2019-12-09T17:23:45.533",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9616",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "同じパッケージ内のimport",
"view_count": 42
} | [] | 61276 | null | null |
{
"accepted_answer_id": "61279",
"answer_count": 1,
"body": "[一つ前の質問](https://ja.stackoverflow.com/q/61234/19110)の前提に変更点があったので新しく質問させて頂きます。 \n前回のリストAの0番目に要素を追加しました。\n\n```\n\n A = [\n [1,'c', 0, 1, 0, 0],\n [0,'d', 1, 1, 0, 1],\n [0,'a', 0, 0, 0, 0],\n [0,'b', 1, 0, 0, 0],\n [0,'c', 0, 1, 0, 0],\n [0,'a', 0, 0, 0, 1],\n [0,'b', 1, 0, 0, 0],\n [0,'d', 1, 0, 0, 1],\n ]\n \n```\n\n以下がAというリストに対して行いたい処理です。 \n「1番目(アルファベット)は同じだが、0番目または2~5番目(数字)が一致しなければリスト化して抽出する」\n\n最終的に下のようなリストを作りたいです。\n\n```\n\n result = [\n [0,'a', 0, 0, 0, 0],\n [0,'a', 0, 0, 0, 1],\n [0,'c', 0, 1, 0, 0],\n [1,'c', 0, 1, 0, 0],\n [0,'d', 1, 1, 0, 1],\n [0,'d', 1, 0, 0, 1],\n ]\n \n```\n\n前の質問でkunifさんから頂いた回答である、以下のプログラムは理解しました。 \nこれにリストAの0番目の要素も2-5番目の要素も両方参照するという指示を加えるには、どのような変更をしたら良いのでしょうか。\n\n```\n\n A = list(map(list, set(map(tuple, A)))) # 先に重複除去\n A.sort()\n \n result = []\n work = []\n prev = A[0] # あらかじめ1つ取得・格納\n work.append(prev) #\n \n for i in range(1,len(A)): # 2つ目から始める\n row = A[i]\n if prev[0] != row[0]: # 先頭データが変わった時\n if len(work) > 1: # 2つ以上のデータがある時\n result.extend(work) # 結果に追加\n \n work = [] # 作業用配列クリア\n \n prev = row # 直前データ更新\n work.append(row) # 作業用配列に追加\n \n if len(work) > 1: # 2つ以上の未処理データがある時\n result.extend(work) # 結果に追加\n \n```\n\nご教授お願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T18:15:00.420",
"favorite_count": 0,
"id": "61277",
"last_activity_date": "2019-12-09T22:57:42.413",
"last_edit_date": "2019-12-09T22:25:26.417",
"last_editor_user_id": "19110",
"owner_user_id": "36978",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "リスト内の要素を照合し、抽出したい(改訂版)",
"view_count": 102
} | [
{
"body": "こちらを参考に、ソートのキーを各行の2つ目のデータに指定します。 \n[python sorted\nのkeyってなんぞ](https://qiita.com/inon3135/items/70b1ed6706579bd48edf) \n[ソート HOW TO](https://docs.python.org/ja/3/howto/sorting.html)\n\n変更した部分にコメントを入れています。\n\n```\n\n A = list(map(list, set(map(tuple, A))))\n A.sort(key=lambda x:x[1]) # ソートのキーを各... | 61277 | 61279 | 61279 |
{
"accepted_answer_id": "61286",
"answer_count": 1,
"body": "以下のようなディレクトリ構成\n\n```\n\n model\n ├── __init__.py\n ├── supplement.py\n ├── supplement_name.py\n ├── supplement_property.py\n └── vitamin.py\n \n```\n\nで、`supplement.py`から他のディレクトリ\n\n * supplement_name.py\n * supplement_property.py\n * vitamin.py\n\nを以下のように **model** パッケージとして呼び出したいと考えています。\n\n```\n\n from model import Vitamin, SupplementProperty, SupplementName\n \n```\n\nしかし、この呼び出し方だと以下のようなエラーが出てimportに失敗します。\n\n```\n\n > py model/supplement.py \n Traceback (most recent call last):\n File \"model/supplement.py\", line 3, in <module>\n from model import Vitamin, SupplementProperty, SupplementName\n ModuleNotFoundError: No module named 'model'\n Error in sys.excepthook:\n Traceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/apport_python_hook.py\", line 63, in apport_excepthook\n from apport.fileutils import likely_packaged, get_recent_crashes\n File \"/usr/lib/python3/dist-packages/apport/__init__.py\", line 5, in <module>\n from apport.report import Report\n File \"/usr/lib/python3/dist-packages/apport/report.py\", line 30, in <module>\n import apport.fileutils\n File \"/usr/lib/python3/dist-packages/apport/fileutils.py\", line 23, in <module>\n from apport.packaging_impl import impl as packaging\n File \"/usr/lib/python3/dist-packages/apport/packaging_impl.py\", line 24, in <module>\n import apt\n File \"/usr/lib/python3/dist-packages/apt/__init__.py\", line 23, in <module>\n import apt_pkg\n ModuleNotFoundError: No module named 'apt_pkg'\n \n Original exception was:\n Traceback (most recent call last):\n File \"model/supplement.py\", line 3, in <module>\n from model import Vitamin, SupplementProperty, SupplementName\n ModuleNotFoundError: No module named 'model'\n \n```\n\nimport方法を以下のような方式で行えばエラーは発生しません。\n\n```\n\n from supplement_name import SupplementName\n from supplement_property import SupplementProperty\n from vitamin import Vitamin\n \n```\n\nsupplement.pyの内容は以下のようになっています。\n\n```\n\n from dataclasses import dataclass\n \n from model import Vitamin, SupplementProperty, SupplementName\n # from supplement_name import SupplementName\n # from supplement_property import SupplementProperty\n # from vitamin import Vitamin\n \n \n @dataclass(frozen=True)\n class Supplement:\n id: str\n name: SupplementName\n prop: SupplementProperty\n vitamin: Vitamin\n \n \n if __name__ == '__main__':\n s = Supplement(\n id='test',\n name=SupplementName(code='test', detail='test-detail'),\n prop=SupplementProperty(price=100, tablet_num=100, manufacture='test-mn'),\n vitamin=Vitamin(va=1000)\n )\n print(s)\n \n \n```\n\n__init__.pyの内容\n\n```\n\n from .supplement import Supplement\n from .vitamin import Vitamin\n from .supplement_property import SupplementProperty\n from .supplement_name import SupplementName\n \n```\n\n`python -m model.supplement`と実行した場合、以下のようなエラーが出ます。\n\n```\n\n /usr/bin/python3.7: Error while finding module specification for 'model.supplement' (ImportError: cannot import name 'Vitamin' from 'model' (/home/tan/repositories/healthcare/backend/model/__init__.py))\n \n```\n\n**model** というパッケージ単位でのimport方法があれば教えて下さい。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T18:26:01.447",
"favorite_count": 0,
"id": "61278",
"last_activity_date": "2019-12-10T02:12:50.910",
"last_edit_date": "2019-12-09T19:56:58.077",
"last_editor_user_id": "9616",
"owner_user_id": "9616",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "パッケージ単位でのインポート方法について",
"view_count": 481
} | [
{
"body": "※ 以下、回答ではなく、コメントでのやり取りの補足になります\n\n`__init__.py` の最後に `from .supplement import Supplement` を置いて `python3 -m\nmodel.supplement` を実行しますと、\n\n```\n\n from .vitamin import Vitamin\n from .supplement_property import SupplementProperty\n from .supplement_name import SupplementName\n from .supple... | 61278 | 61286 | 61286 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "チャットbotを作るにはどんな言語が最適ですか?やっぱりjavascriptですか? \nその言語を勉強してbotを作りたいので教えてください。 \n追記: \nたとえば、チャットで何か文字を受信したら、自動的に文字を送信する機能が欲しいです。javascriptで作りたいのですが、初心者なので関数など教えてください。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T21:21:14.563",
"favorite_count": 0,
"id": "61282",
"last_activity_date": "2019-12-12T22:00:00.767",
"last_edit_date": "2019-12-12T22:00:00.767",
"last_editor_user_id": "36447",
"owner_user_id": "36447",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "チャットbotについて",
"view_count": 178
} | [
{
"body": "チャットbotは、入出力ができるプログラミング言語であれば大抵作れます。どんなチャットbotを想定されているかも、どういうことができればより最適なのかも、一般的な基準が存在しないため質問文に書いてくださらないと「大体どんな言語でもOKです」より客観的なことを言うのは難しそうです。まずは質問者さんが気になる言語でとりあえずそのチャットbotを作ってみて、その上で具体的にどういうことがしたいのかを考えるところからかな、と思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date":... | 61282 | null | 61283 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "参考書「rails5速習演習ガイド」に沿ってtaskleafというタスク管理アプリケーションを作成しているのですが、Rspec実行時にFailure/Errorエラーが出て解決法がわからないので質問させてください。\n\nルートディレクトリの Users/user/rails/taskleaf にて \n`$ bundle exec rspec spec/system/tasks_spec.rb` を実行後、以下のようなエラー文が出ます。\n\n補足 \n`('../config/environment', __dir__)` が書かれているfileは spec/rails_helper.rb です。\n\nよろしくお願いします。\n\n**環境** \nRails 5.2.4 \nRuby 2.6.3\n\n* * *\n\n↓以下エラー全文です。\n\n```\n\n An error occurred while loading ./spec/system/tasks_spec.rb.\n Failure/Error: require File.expand_path('../config/environment', __dir__)\n \n \n NameError:\n uninitialized constant BetterErrors\n # ./vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `block in load_missing_constant'\n # ./vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'\n # ./vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `rescue in load_missing_constant'\n # ./vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `load_missing_constant'\n # ./config/initializers/better_errors.rb:1:in `<main>'\n # ./vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'\n # ./vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/engine.rb:663:in `block in load_config_initializer'\n # ./vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.4/lib/active_support/notifications.rb:170:in `instrument'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/engine.rb:662:in `load_config_initializer'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/engine.rb:619:in `each'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/engine.rb:619:in `block in <class:Engine>'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/initializable.rb:32:in `instance_exec'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/initializable.rb:32:in `run'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/initializable.rb:61:in `block in run_initializers'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/initializable.rb:50:in `each'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/initializable.rb:50:in `tsort_each_child'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/initializable.rb:60:in `run_initializers'\n # ./vendor/bundle/ruby/2.6.0/gems/railties-5.2.4/lib/rails/application.rb:361:in `initialize!'\n # ./config/environment.rb:5:in `<top (required)>'\n # ./spec/rails_helper.rb:5:in `require'\n # ./spec/rails_helper.rb:5:in `<top (required)>'\n # ./spec/system/tasks_spec.rb:1:in `require'\n # ./spec/system/tasks_spec.rb:1:in `<top (required)>'\n # ------------------\n # --- Caused by: ---\n # NameError:\n # uninitialized constant BetterErrors\n # ./vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:60:in `block in load_missing_constant'\n No examples found.\n \n \n Finished in 0.00005 seconds (files took 4.78 seconds to load)\n 0 examples, 0 failures, 1 error occurred outside of examples\n \n```\n\n* * *\n\ntasks_spec.rb\n\n```\n\n require 'rails_helper'\n \n describe 'タスク管理機能', type: :system do\n let(:user_a) { FactoryBot.create(:user, name: 'ユーザーA', email: 'a@example.com') }\n let(:user_b) { FactoryBot.create(:user, name: 'ユーザーB', email: 'b@example.com') }\n let!(:task_a) { FactoryBot.create(:task, name: '最初のタスク', user: user_a) }\n \n before do\n visit login_path\n fill_in 'メールアドレス', with: login_user.email\n fill_in 'パスワード', with: login_user.password\n click_button 'ログインする'\n end\n \n shared_examples_for 'ユーザーAが作成したタスクが表示される' do\n it { expect(page).to have_content '最初のタスク' }\n end\n \n describe '一覧表示機能' do\n context 'ユーザーAがログインしているとき' do\n let(:login_user) { user_a }\n \n it_behaves_like 'ユーザーAが作成したタスクが表示される'\n end\n \n context 'ユーザーBがログインしているとき' do\n let(:login_user) { user_b }\n \n it 'ユーザーAが作成したタスクが表示されない' do\n expect(page).to have_no_content '最初のタスク'\n end\n end\n end\n \n describe '詳細表示機能' do\n context 'ユーザーAがログインしているとき' do\n let(:login_user) { user_a }\n \n before do\n visit task_path(task_a)\n end\n \n it_behaves_like 'ユーザーAが作成したタスクが表示される'\n end\n end\n \n describe '新規作成機能' do\n let(:login_user) { user_a }\n let(:task_name) { '新規作成のテストを書く' } # デフォルトとして設定\n \n before do\n visit new_task_path\n fill_in '名称', with: task_name\n click_button '登録する'\n end\n \n context '新規作成画面で名称を入力したとき' do\n it '正常に登録される' do\n expect(page).to have_selector '.alert-success', text: '新規作成のテストを書く'\n end\n end\n \n context '新規作成画面で名称を入力しなかったとき' do\n let(:task_name) { '' }\n \n it 'エラーとなる' do\n within '#error_explanation' do\n expect(page).to have_content '名称を入力してください'\n end\n end\n end\n end\n end\n \n \n```\n\n* * *\n\nrails_helper.rb\n\n```\n\n # This file is copied to spec/ when you run 'rails generate rspec:install'\n require 'spec_helper'\n ENV['RAILS_ENV'] ||= 'test'\n \n require File.expand_path('../config/environment', __dir__)\n \n # Prevent database truncation if the environment is production\n abort(\"The Rails environment is running in production mode!\") if Rails.env.production?\n require 'rspec/rails'\n # Add additional requires below this line. Rails is not loaded until this point!\n \n # Requires supporting ruby files with custom matchers and macros, etc, in\n # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are\n # run as spec files by default. This means that files in spec/support that end\n # in _spec.rb will both be required and run as specs, causing the specs to be\n # run twice. It is recommended that you do not name files matching this glob to\n # end with _spec.rb. You can configure this pattern with the --pattern\n # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.\n #\n # The following line is provided for convenience purposes. It has the downside\n # of increasing the boot-up time by auto-requiring all files in the support\n # directory. Alternatively, in the individual `*_spec.rb` files, manually\n # require only the support files necessary.\n #\n # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }\n \n # Checks for pending migrations and applies them before tests are run.\n # If you are not using ActiveRecord, you can remove these lines.\n begin\n ActiveRecord::Migration.maintain_test_schema!\n rescue ActiveRecord::PendingMigrationError => e\n puts e.to_s.strip\n exit 1\n end\n RSpec.configure do |config|\n # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures\n config.fixture_path = \"#{::Rails.root}/spec/fixtures\"\n \n # If you're not using ActiveRecord, or you'd prefer not to run each of your\n # examples within a transaction, remove the following line or assign false\n # instead of true.\n config.use_transactional_fixtures = true\n \n # RSpec Rails can automatically mix in different behaviours to your tests\n # based on their file location, for example enabling you to call `get` and\n # `post` in specs under `spec/controllers`.\n #\n # You can disable this behaviour by removing the line below, and instead\n # explicitly tag your specs with their type, e.g.:\n #\n # RSpec.describe UsersController, :type => :controller do\n # # ...\n # end\n #\n # The different available types are documented in the features, such as in\n # https://relishapp.com/rspec/rspec-rails/docs\n config.infer_spec_type_from_file_location!\n \n # Filter lines from Rails gems in backtraces.\n config.filter_rails_from_backtrace!\n # arbitrary gems may also be filtered via:\n # config.filter_gems_from_backtrace(\"gem name\")\n end\n \n \n```\n\n* * *\n\nspec_helper.rb\n\n```\n\n # This file was generated by the `rails generate rspec:install` command. Conventionally, all\n # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.\n # The generated `.rspec` file contains `--require spec_helper` which will cause\n # this file to always be loaded, without a need to explicitly require it in any\n # files.\n #\n # Given that it is always loaded, you are encouraged to keep this file as\n # light-weight as possible. Requiring heavyweight dependencies from this file\n # will add to the boot time of your test suite on EVERY test run, even for an\n # individual file that may not need all of that loaded. Instead, consider making\n # a separate helper file that requires the additional dependencies and performs\n # the additional setup, and require it from the spec files that actually need\n # it.\n #\n # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration\n \n require 'capybara/rspec'\n \n RSpec.configure do |config|\n config.before(:each, type: :system) do\n driven_by :selenium_chrome_headless\n end\n \n # rspec-expectations config goes here. You can use an alternate\n # assertion/expectation library such as wrong or the stdlib/minitest\n # assertions if you prefer.\n config.expect_with :rspec do |expectations|\n # This option will default to `true` in RSpec 4. It makes the `description`\n # and `failure_message` of custom matchers include text for helper methods\n # defined using `chain`, e.g.:\n # be_bigger_than(2).and_smaller_than(4).description\n # # => \"be bigger than 2 and smaller than 4\"\n # ...rather than:\n # # => \"be bigger than 2\"\n expectations.include_chain_clauses_in_custom_matcher_descriptions = true\n end\n \n # rspec-mocks config goes here. You can use an alternate test double\n # library (such as bogus or mocha) by changing the `mock_with` option here.\n config.mock_with :rspec do |mocks|\n # Prevents you from mocking or stubbing a method that does not exist on\n # a real object. This is generally recommended, and will default to\n # `true` in RSpec 4.\n mocks.verify_partial_doubles = true\n end\n \n # This option will default to `:apply_to_host_groups` in RSpec 4 (and will\n # have no way to turn it off -- the option exists only for backwards\n # compatibility in RSpec 3). It causes shared context metadata to be\n # inherited by the metadata hash of host groups and examples, rather than\n # triggering implicit auto-inclusion in groups with matching metadata.\n config.shared_context_metadata_behavior = :apply_to_host_groups\n \n # The settings below are suggested to provide a good initial experience\n # with RSpec, but feel free to customize to your heart's content.\n =begin\n # This allows you to limit a spec run to individual examples or groups\n # you care about by tagging them with `:focus` metadata. When nothing\n # is tagged with `:focus`, all examples get run. RSpec also provides\n # aliases for `it`, `describe`, and `context` that include `:focus`\n # metadata: `fit`, `fdescribe` and `fcontext`, respectively.\n config.filter_run_when_matching :focus\n \n # Allows RSpec to persist some state between runs in order to support\n # the `--only-failures` and `--next-failure` CLI options. We recommend\n # you configure your source control system to ignore this file.\n config.example_status_persistence_file_path = \"spec/examples.txt\"\n \n # Limits the available syntax to the non-monkey patched syntax that is\n # recommended. For more details, see:\n # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/\n # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/\n # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode\n config.disable_monkey_patching!\n \n # Many RSpec users commonly either run the entire suite or an individual\n # file, and it's useful to allow more verbose output when running an\n # individual spec file.\n if config.files_to_run.one?\n # Use the documentation formatter for detailed output,\n # unless a formatter has already been configured\n # (e.g. via a command-line flag).\n config.default_formatter = \"doc\"\n end\n \n # Print the 10 slowest examples and example groups at the\n # end of the spec run, to help surface which specs are running\n # particularly slow.\n config.profile_examples = 10\n \n # Run specs in random order to surface order dependencies. If you find an\n # order dependency and want to debug it, you can fix the order by providing\n # the seed, which is printed after each run.\n # --seed 1234\n config.order = :random\n \n # Seed global randomization in this process using the `--seed` CLI option.\n # Setting this allows you to use `--seed` to deterministically reproduce\n # test failures related to randomization by passing the same `--seed` value\n # as the one that triggered the failure.\n Kernel.srand config.seed\n =end\n end\n \n \n```\n\n* * *\n\nGemfile\n\n```\n\n source 'https://rubygems.org'\n git_source(:github) { |repo| \"https://github.com/#{repo}.git\" }\n \n ruby '2.6.3'\n \n # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\n gem 'rails', '~> 5.2.3'\n # Use postgresql as the database for Active Record\n gem 'sqlite3'\n # Use Puma as the app server\n gem 'puma', '~> 3.11'\n # Use SCSS for stylesheets\n gem 'sass-rails', '~> 5.0'\n # Use Uglifier as compressor for JavaScript assets\n gem 'uglifier', '>= 1.3.0'\n # See https://github.com/rails/execjs#readme for more supported runtimes\n # gem 'mini_racer', platforms: :ruby\n \n # Use CoffeeScript for .coffee assets and views\n gem 'coffee-rails', '~> 4.2'\n # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks\n gem 'turbolinks', '~> 5'\n # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\n gem 'jbuilder', '~> 2.5'\n # Use Redis adapter to run Action Cable in production\n # gem 'redis', '~> 4.0'\n #Use ActiveModel has_secure_password\n gem 'bcrypt', '>= 3.1.10'\n \n # Use ActiveStorage variant\n # gem 'mini_magick', '~> 4.8'\n \n # Use Capistrano for deployment\n # gem 'capistrano-rails', group: :development\n \n # Reduces boot times through caching; required in config/boot.rb\n gem 'bootsnap', '>= 1.1.0', require: false\n \n group :development, :test do\n # Call 'byebug' anywhere in the code to stop execution and get a debugger console\n gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]\n gem 'factory_bot_rails', '~> 5.1', '>= 5.1.1'\n end\n \n group :development do\n # Access an interactive console on exception pages or by calling 'console' anywhere in the code.\n gem 'web-console', '>= 3.3.0'\n gem 'listen', '>= 3.0.5', '< 3.2'\n # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n gem 'spring'\n gem 'spring-watcher-listen', '~> 2.0.0'\n \n gem 'better_errors'\n gem 'binding_of_caller'\n gem 'pry-rails'\n \n end\n \n group :test do\n # Adds support for Capybara system testing and selenium driver\n gem 'capybara', '>= 2.15'\n gem 'selenium-webdriver'\n # Easy installation and use of chromedriver to run system tests with Chrome\n gem 'webdrivers', '~> 3.0'\n gem 'rspec-rails', '~> 3.9'\n gem 'factory_bot_rails', '~> 5.1', '>= 5.1.1'\n end\n \n # Windows does not include zoneinfo files, so bundle the tzinfo-data gem\n gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n \n gem 'slim-rails'\n gem 'html2slim'\n \n gem 'bootstrap'\n gem 'nokogiri', '~> 1.10', '>= 1.10.5'\n gem 'rails_autolink'\n \n gem 'pry-byebug', group: :development\n gem 'pry-doc'\n \n \n```\n\n* * *\n\n__dir___spec.rb\n\n```\n\n require_relative '../../spec_helper'\n \n describe \"Kernel#__dir__\" do\n it \"returns the real name of the directory containing the currently-executing file\" do\n __dir__.should == File.realpath(File.dirname(__FILE__))\n end\n \n context \"when used in eval with a given filename\" do\n it \"returns File.dirname(filename)\" do\n eval(\"__dir__\", nil, \"foo.rb\").should == \".\"\n eval(\"__dir__\", nil, \"foo/bar.rb\").should == \"foo\"\n end\n end\n \n context \"when used in eval with top level binding\" do\n it \"returns the real name of the directory containing the currently-executing file\" do\n eval(\"__dir__\", binding).should == File.realpath(File.dirname(__FILE__))\n end\n end\n end\n \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-09T23:03:42.520",
"favorite_count": 0,
"id": "61284",
"last_activity_date": "2022-10-14T06:03:25.113",
"last_edit_date": "2019-12-10T00:17:16.223",
"last_editor_user_id": "3060",
"owner_user_id": "36775",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"rspec"
],
"title": "rails5でRspec実行時にFailure/Errorエラーが出ます",
"view_count": 9629
} | [
{
"body": "`./config/initializers/better_errors.rb` \nが未定義のBetterErrorsを参照しているようです。 \n[BetterErrors](https://github.com/BetterErrors/better_errors/wiki/Link-to-\nyour-editor)に記載のとおり、`if defined?(BetterErrors)`で定義済みかチェックする必要があります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_d... | 61284 | null | 61468 |
{
"accepted_answer_id": "61322",
"answer_count": 1,
"body": "Android(O)の環境にiptablesのシェルスクリプトを置いて \ninit.rcで実行させるようにしたいです。 \n以下では効いていませんでした・・・ \nご存じの方教えてもらえないでしょうか? \ninit.rcには以下を追加しています。 \nファイルなどは存在しています\n\n```\n\n on property:sys.boot_completed=1\n exec - root root -- /system/bin/sh /vendor/bin/iptables.sh\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T02:58:55.107",
"favorite_count": 0,
"id": "61287",
"last_activity_date": "2019-12-11T01:32:19.407",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36599",
"post_type": "question",
"score": 0,
"tags": [
"android",
"iptables"
],
"title": "Androidのinit.rcにてスクリプトを実行させたい",
"view_count": 976
} | [
{
"body": "自己解決しました。 \nSELinuxのコンテキストを省略すると実行できていませんでした。 \n× exec - root root -- /system/bin/sh /vendor/bin/iptables.sh \n〇 exec (SELinuxのコンテキスト) root root -- /system/bin/sh /vendor/bin/iptables.sh",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T01:32:19.407"... | 61287 | 61322 | 61322 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "ValidationTechnicalProfilesについてですが、TechnicalProfileのProtocolが \nセルフアサート以外で使用できないかどうか知りたく思います。\n\n本来やりたいことはREST APIが参照できずに500のinternal server errorとなった場合は、 \nエラーが発生せずに次のステップへ処理が進むようにしたいです。 \nそれでエラーを回避する方法はValidationTechnicalProfilesぐらいしか検討がつかず、 \nかといってClaimsTransformationProtocolProviderでは \nValidationTechnicalProfilesが反応しないので、セルフアサート以外ではできないのか知りたいです。\n\nまたValidationTechnicalProfiles以外で、ポリシー内で500のinternal server errorを \n回避する方法があればご教授いただけたらと思います。\n\n**〇UserJourneyから呼んでいるOrchestrationStepの一部**\n\n```\n\n <OrchestrationStep Order=\"1\" Type=\"CombinedSignInAndSignUp\" ContentDefinitionReferenceId=\"api.signuporsignin\">\n <!-- check existing session -->\n <Preconditions>\n <Precondition Type=\"ClaimsExist\" ExecuteActionsIf=\"true\">\n <Value>AlternativeSecurityId</Value>\n <Action>SkipThisOrchestrationStep</Action>\n </Precondition>\n <Precondition Type=\"ClaimsExist\" ExecuteActionsIf=\"true\">\n <Value>objectId</Value>\n <Action>SkipThisOrchestrationStep</Action>\n </Precondition>\n </Preconditions>\n <ClaimsProviderSelections>\n <ClaimsProviderSelection TargetClaimsExchangeId=\"FacebookExchange\" />\n <ClaimsProviderSelection ValidationClaimsExchangeId=\"LocalAccountSigninEmailExchange\" />\n </ClaimsProviderSelections>\n <ClaimsExchanges>\n <ClaimsExchange Id=\"LocalAccountSigninEmailExchange\" TechnicalProfileReferenceId=\"SelfAsserted-LocalAccountSignin-Email\" />\n </ClaimsExchanges>\n </OrchestrationStep>\n \n <OrchestrationStep Order=\"2\" Type=\"ClaimsExchange\">\n <Preconditions>\n <Precondition Type=\"ClaimsExist\" ExecuteActionsIf=\"true\">\n <Value>AlternativeSecurityId</Value>\n <Action>SkipThisOrchestrationStep</Action>\n </Precondition>\n <Precondition Type=\"ClaimsExist\" ExecuteActionsIf=\"true\">\n <Value>objectId</Value>\n <Action>SkipThisOrchestrationStep</Action>\n </Precondition>\n </Preconditions>\n <ClaimsExchanges>\n <ClaimsExchange Id=\"FacebookExchange\" TechnicalProfileReferenceId=\"Facebook-OAUTH\" />\n <!-- ダミー用 -->\n <ClaimsExchange Id=\"SignUpWithLogonEmailExchange\" TechnicalProfileReferenceId=\"LocalAccountSignUpWithLogonEmailDummy\" />\n </ClaimsExchanges>\n </OrchestrationStep>\n \n```\n\n**〇OrchestrationStep Order=\"2\"のClaimsExchangeでダミーとして作成しているTechnicalProfile**\n\n```\n\n <TechnicalProfile Id=\"LocalAccountSignUpWithLogonEmailDummy\">\n <DisplayName>dummy</DisplayName>\n <Protocol Name=\"Proprietary\" Handler=\"Web.TPEngine.Providers.ClaimsTransformationProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\" />\n <InputClaims/>\n <InputClaim ClaimTypeReferenceId=\"dummyVal2\" DefaultValue=\"false\" />\n </InputClaims> -->\n <OutputClaims>\n <!-- consent result -->\n <OutputClaim ClaimTypeReferenceId=\"dummyVal1\" DefaultValue=\"dummy\" />\n <OutputClaim ClaimTypeReferenceId=\"dummyVal2\" DefaultValue=\"false\" />\n <OutputClaim ClaimTypeReferenceId=\"status\" PartnerClaimType=\"status\"/>\n <OutputClaim ClaimTypeReferenceId=\"status\" PartnerClaimType=\"userMessage\"/>\n </OutputClaims>\n <OutputClaimsTransformations>\n <OutputClaimsTransformation ReferenceId=\"IsDummy\" />\n </OutputClaimsTransformations>\n <ValidationTechnicalProfiles>\n <ValidationTechnicalProfile ReferenceId=\"VAL-TECHNICAL\" ContinueOnError=\"true\"/>\n </ValidationTechnicalProfiles>\n <UseTechnicalProfileForSessionManagement ReferenceId=\"XXXX\" />\n </TechnicalProfile>\n \n```\n\n**〇ダミーとして作成しているTechnicalProfileのValidationTechnicalProfilesから呼んでいるRESTのTechnicalProfile**\n\n```\n\n <TechnicalProfile Id=\"VAL-TECHNICAL\">\n <DisplayName>VAL-TECHNICAL</DisplayName>\n <Protocol Name=\"Proprietary\" Handler=\"Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\" />\n <Metadata>\n <Item Key=\"AllowInsecureAuthInProduction\">true</Item>\n <Item Key=\"AuthenticationType\">None</Item>\n <Item Key=\"SendClaimsIn\">Body</Item>\n <Item Key=\"ServiceUrl\">https://XXXXXXXX.azurewebsites.net/api/XXXXXXXXXXXXXX?code=XXXXXXXXXXXXXXXXXXXXXXXXXX</Item>\n </Metadata>\n <IncludeInSso>false</IncludeInSso>\n <InputClaims> \n </InputClaims>\n <OutputClaims>\n <OutputClaim ClaimTypeReferenceId=\"status\" PartnerClaimType=\"status\" DefaultValue=\"500\" />\n <OutputClaim ClaimTypeReferenceId=\"userMessage\" PartnerClaimType=\"userMessage\" DefaultValue=\"NG\" />\n </OutputClaims>\n <UseTechnicalProfileForSessionManagement ReferenceId=\"XXXXXXX\" /> \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T05:30:48.730",
"favorite_count": 0,
"id": "61291",
"last_activity_date": "2019-12-10T06:58:31.873",
"last_edit_date": "2019-12-10T06:58:31.873",
"last_editor_user_id": "3060",
"owner_user_id": "37004",
"post_type": "question",
"score": 3,
"tags": [
"azure"
],
"title": "Azure Active Directory B2C のポリシー内にあるTechnicalProfileのValidationTechnicalProfilesについて",
"view_count": 86
} | [] | 61291 | null | null |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "入力されたアルファベットのランダムな文字列を、アスキーコードの昇順で並び替えて出力したいです。\n\n**例** \n元の文字列: `bfGageGaheifhalenbcuafuhneixlDbfuhflfi0` \n並べ替え後: `DGGaaaaabbbceeeeffffffghhhhiiilllnnuuux`\n\n数字が入力された時に入力を終了して出力します。\n\n以下、自分で書いてみたのですが出力に最後の改行しか表示されません。 \nコードの訂正お願いします。\n\n追記 \n現時点での明白なミスは修正しました。\n\nhead.next = &tail;の初期化によってうまくいかないとご意見をいただきましたが、具体的にどのように修正すればよいでしょうか。\n\n```\n\n #include <stdio.h>\n #include <stdlib.h>\n \n struct ascii{\n int num;\n struct ascii *next;\n };\n \n \n int main(){\n int i;\n char c;\n struct ascii head, tail;\n head.next = &tail;\n tail.num=10000;\n for(;(i=getchar())<48 || i>57;){\n if(i==10){\n continue;\n }else{\n struct ascii *p=(struct ascii *)malloc(sizeof(struct ascii));\n p->num=i;\n struct ascii *w;\n for (w = &head; w->next != &tail;){\n if(w->next->num < p->num){\n w = w->next;\n if(w->next->num >= p->num){\n p->next=w->next;\n w->next=p;\n break;\n }\n }else{\n p->next=w->next;\n w->next=p;\n break;\n }\n }\n }\n }\n struct ascii *q;\n for(q=&head;q->next!=&tail;q=q->next){\n c=q->num;\n printf(\"%c\", c);\n }\n printf(\"\\n\");\n return 0;\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T05:55:48.990",
"favorite_count": 0,
"id": "61292",
"last_activity_date": "2019-12-10T18:51:04.567",
"last_edit_date": "2019-12-10T16:30:31.777",
"last_editor_user_id": "3060",
"owner_user_id": "36484",
"post_type": "question",
"score": 0,
"tags": [
"c",
"ポインタ"
],
"title": "ポインタを用いて入力されたアルファベットをアスキーコード昇順で並び替えるコード",
"view_count": 737
} | [
{
"body": "ぱっと見 `if(i=10)` は限りなく誤りっす。 [c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") では、等号1つ\n`=` は代入で、比較が欲しいのなら等号2つ `==` っす。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T06:21:48.433",
"id": "61293",
"last_activity_date": "2019-12-10T06:21:48.433",
... | 61292 | null | 61293 |
{
"accepted_answer_id": "61296",
"answer_count": 1,
"body": "R上で以下のようなエラーが出て先に進むことができません。 \n分かる方がいらっしゃれば教えてください。\n\n```\n\n macro2Ans<-data.frame(macro2$ym,macro2$time_id,macro2$sociotropic_bd,macro2$sociotropic_gd,macro2$liv_gd,\n + macro2$liv_bd,macro2$approve,macro2$dis,macro2$cpi,macro2$unemp,macro2$ruling,\n + macro2$nav_ini,macro2$slap,macro2$corruption,macro2$synthesis)\n Error in data.frame(macro2$ym, macro2$time_id, macro2$sociotropic_bd, : \n 引数に異なる列数のデータフレームが含まれています: 698, 0 \n macro2Ans<-na.omit(macro2Ans)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T07:27:19.847",
"favorite_count": 0,
"id": "61295",
"last_activity_date": "2019-12-10T08:35:31.947",
"last_edit_date": "2019-12-10T08:35:31.947",
"last_editor_user_id": "3060",
"owner_user_id": "37007",
"post_type": "question",
"score": 0,
"tags": [
"r"
],
"title": "Rのエラー「 引数に異なる列数のデータフレームが含まれています」について",
"view_count": 5205
} | [
{
"body": "変数の名前を間違っているのが理由かと思います。 \n`macro2$xxxxx`の`xxxxx`の部分、どれかが間違っていませんか? \n正しい名前は `names(macro2)` で確認できるので、一致しない部分がないか確認してみてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T08:31:30.153",
"id": "61296",
"last_activity_date": "2019-12-10T08:31... | 61295 | 61296 | 61296 |
{
"accepted_answer_id": "61302",
"answer_count": 3,
"body": "私はコンピュータについて勉強中で、スタックが低いアドレスに向かって積まれることを学びました。 \nそして、実験的にこのようなコードを書きました\n\n```\n\n alignas(long) int k = 0xcafecafe;\n k++;\n uint8_t buf[] = {0,1,2,3,4,5,6,7};\n alignas(16) uint8_t x,y,z;\n x = 1;\n y = 2;\n z = 3;\n \n```\n\nlldbでメモリを見てみると、確かにx,y,zは上にむかって積まれていましたが、0xcafecafe+1は配列の`0x7ffeefbff880: 0x00\n0x01 0x02 0x03 0x04 0x05 0x06 0x07`より上に積まれています。 \nこれはなぜですか?\n\n```\n\n (lldb) x/128xb &z\n 0x7ffeefbff840: 0x03 0xf8 0xbf 0xef 0xfe 0x7f 0x00 0x00\n 0x7ffeefbff848: 0xa0 0xf8 0xbf 0xef 0xfe 0x7f 0x00 0x00\n 0x7ffeefbff850: 0x02 0x00 0x00 0x00 0x01 0x00 0x00 0x00\n 0x7ffeefbff858: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00\n 0x7ffeefbff860: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00\n 0x7ffeefbff868: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00\n 0x7ffeefbff870: 0xff 0xca 0xfe 0xca 0x00 0x00 0x00 0x00\n 0x7ffeefbff878: 0x00 0x00 0xff 0xff 0x00 0x00 0x00 0x00\n 0x7ffeefbff880: 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07\n 0x7ffeefbff888: 0xc8 0x00 0x9a 0x1c 0xb6 0x13 0x7a 0x6c\n 0x7ffeefbff890: 0xa8 0xf8 0xbf 0xef 0xfe 0x7f 0x00 0x00\n 0x7ffeefbff898: 0xe5 0x82 0xec 0x69 0xff 0x7f 0x00 0x00\n 0x7ffeefbff8a0: 0xe5 0x82 0xec 0x69 0xff 0x7f 0x00 0x00\n 0x7ffeefbff8a8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00\n 0x7ffeefbff8b0: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00\n 0x7ffeefbff8b8: 0x78 0xfa 0xbf 0xef 0xfe 0x7f 0x00 0x00\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T10:03:36.530",
"favorite_count": 0,
"id": "61298",
"last_activity_date": "2019-12-12T01:26:52.030",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "37013",
"post_type": "question",
"score": 2,
"tags": [
"c++",
"c",
"debugging"
],
"title": "スタックが低いアドレスに向かって積まれない場合はありますか?",
"view_count": 595
} | [
{
"body": "コードが断片的過ぎて、提示コードが自動変数なのか静的変数なのかすらわからないんだけど、読者のほうで再現できる程度のソースコードを提示してもらえると幸い。\n\nで、提示コードが真に自動変数に展開されるコードであるとして:\n\n> これはなぜですか?\n\n自動変数が宣言順にスタックに配置される保証は何一つない、が回答。 [c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") /\n[c++](/questions/tagged/c%2b%2b \"'c++' のタグが付いた質問を表示\")\nコンパイラは(自動)変数をメモリ上どんな配置をしても構わないので。... | 61298 | 61302 | 61356 |
{
"accepted_answer_id": "61300",
"answer_count": 1,
"body": "プログラミング、環境構築の初心者です。\n\nMac, python3, django, postgresqlを利用して、ローカルの環境でWEBアプリを開発しています。\n\nローカルホストで、開発しているdjangoのプログラムをサーバーで起動すると、psycoog2がないとエラーが出るので、macのローカル環境にpsycopg2のインストールを試しているのですが、エラーが消えずこの先に進めない状況です。\n\n関係しそうなエラーのキーワードで、色々ググっているのですが、解決できない状況で困っています。 \n解決の方法について、ご教授いただきないでしょうか?\n\nこれまでに行った事は、 \n① brewのインストール \n② $ brew install postgresql でpostgresqlのインストール\n\n関係するバージョンは、 \nMac: mojave 10.14.6 \nPython: 3.7.5 \nDjango: 3.0.0 \nPostgresql:12.1\n\n以下にエラーの内容を載せます\n\n・Djangoのプログラムをローカルでサーバー起動時のエラー\n\n```\n\n django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named ‘psycopg2'\n \n```\n\n・sudo pip3 install psycopg2 実行時エラー\n\n```\n\n WARNING: The directory '/Users/apple/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.\n WARNING: The directory '/Users/apple/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.\n Collecting psycopg2\n Downloading https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)\n |████████████████████████████████| 378kB 706kB/s \n Installing collected packages: psycopg2\n Running setup.py install for psycopg2 ... error\n ERROR: Command errored out with exit status 1:\n command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'/private/tmp/pip-install-o7hidoik/psycopg2/setup.py'\"'\"'; __file__='\"'\"'/private/tmp/pip-install-o7hidoik/psycopg2/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' install --record /private/tmp/pip-record-yxgv9_lq/install-record.txt --single-version-externally-managed --compile\n cwd: /private/tmp/pip-install-o7hidoik/psycopg2/\n Complete output (144 lines):\n running install\n running build\n running build_py\n creating build\n creating build/lib.macosx-10.9-x86_64-3.7\n creating build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/_json.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/extras.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/compat.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/errorcodes.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/tz.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/_range.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/_ipaddress.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/_lru_cache.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/extensions.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/errors.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/sql.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/pool.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n running build_ext\n building 'psycopg2._psycopg' extension\n creating build/temp.macosx-10.9-x86_64-3.7\n creating build/temp.macosx-10.9-x86_64-3.7/psycopg\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/psycopgmodule.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/green.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/green.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/pqpath.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/pqpath.o\n psycopg/pqpath.c:135:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]\n PQstatus(conn->pgconn) : PQresultStatus(*pgres)));\n ^~~~~~~~~~~~~~~~~~~~~~\n psycopg/pqpath.c:1714:11: warning: code will never be executed [-Wunreachable-code]\n ret = 1;\n ^\n psycopg/pqpath.c:1819:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]\n PQstatus(curs->conn->pgconn) : PQresultStatus(curs->pgres)));\n ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n 3 warnings generated.\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/utils.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/utils.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/bytes_format.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/bytes_format.o\n In file included from psycopg/bytes_format.c:81:\n In file included from ./psycopg/psycopg.h:37:\n ./psycopg/config.h:81:13: warning: unused function 'Dprintf' [-Wunused-function]\n static void Dprintf(const char *fmt, ...) {}\n ^\n \n 〜中略〜\n \n 1 warning generated.\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/typecast.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/typecast.o\n gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.7/psycopg/psycopgmodule.o build/temp.macosx-10.9-x86_64-3.7/psycopg/green.o build/temp.macosx-10.9-x86_64-3.7/psycopg/pqpath.o build/temp.macosx-10.9-x86_64-3.7/psycopg/utils.o build/temp.macosx-10.9-x86_64-3.7/psycopg/bytes_format.o build/temp.macosx-10.9-x86_64-3.7/psycopg/libpq_support.o build/temp.macosx-10.9-x86_64-3.7/psycopg/win32_support.o build/temp.macosx-10.9-x86_64-3.7/psycopg/solaris_support.o build/temp.macosx-10.9-x86_64-3.7/psycopg/connection_int.o build/temp.macosx-10.9-x86_64-3.7/psycopg/connection_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/cursor_int.o build/temp.macosx-10.9-x86_64-3.7/psycopg/cursor_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/column_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/replication_connection_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/replication_cursor_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/replication_message_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/diagnostics_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/error_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/conninfo_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/lobject_int.o build/temp.macosx-10.9-x86_64-3.7/psycopg/lobject_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/notify_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/xid_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_asis.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_binary.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_datetime.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_list.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pboolean.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pdecimal.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pint.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pfloat.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_qstring.o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols.o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols_proto.o build/temp.macosx-10.9-x86_64-3.7/psycopg/typecast.o -L/usr/local/lib -lpq -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.7/psycopg2/_psycopg.cpython-37m-darwin.so\n ld: library not found for -lssl\n clang: error: linker command failed with exit code 1 (use -v to see invocation)\n error: command 'gcc' failed with exit status 1\n ----------------------------------------\n ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'/private/tmp/pip-install-o7hidoik/psycopg2/setup.py'\"'\"'; __file__='\"'\"'/private/tmp/pip-install-o7hidoik/psycopg2/setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' install --record /private/tmp/pip-record-yxgv9_lq/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.\n WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.\n You should consider upgrading via the 'pip install --upgrade pip' command.\n \n```\n\n## 追記\n\n```\n\n $ openssl version\n LibreSSL 2.6.5\n $ type openssl\n openssl is hashed (/usr/bin/openssl)\n \n```\n\n## 追記\n\nxcode-select --installを行いましたが、インストール済みでした\n\n```\n\n (venv) ApplenoMBP:harvest_timer apple$ xcode-select --install\n xcode-select: error: command line tools are already installed, use \"Software Update\" to install updates\n \n```\n\n## 追記\n\n「pip --no-cache install psycopg2 のように -no-cache\nオプションを使うとキャッシュを無視できるので試してみてください。」 \nを行った後のエラーの内容は以下のとおりです。\n\n```\n\n (venv) ApplenoMBP:harvest_timer apple$ sudo pip3 --no-cache install psycopg2\n Password:\n Sorry, try again.\n Password:\n Collecting psycopg2\n Downloading https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)\n 100% |████████████████████████████████| 378kB 2.9MB/s \n Installing collected packages: psycopg2\n Running setup.py install for psycopg2 ... error\n Complete output from command /Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/bin/python -u -c \"import setuptools, tokenize;__file__='/private/tmp/pip-install-plxviv83/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record /private/tmp/pip-record-xd6k1r8g/install-record.txt --single-version-externally-managed --compile --install-headers /Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include/site/python3.7/psycopg2:\n running install\n running build\n running build_py\n creating build\n creating build/lib.macosx-10.9-x86_64-3.7\n creating build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/_json.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/extras.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/compat.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/errorcodes.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/tz.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/_range.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/_ipaddress.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/_lru_cache.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/extensions.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/errors.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/sql.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n copying lib/pool.py -> build/lib.macosx-10.9-x86_64-3.7/psycopg2\n running build_ext\n building 'psycopg2._psycopg' extension\n creating build/temp.macosx-10.9-x86_64-3.7\n creating build/temp.macosx-10.9-x86_64-3.7/psycopg\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/psycopgmodule.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/green.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/green.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/pqpath.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/pqpath.o\n psycopg/pqpath.c:135:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]\n PQstatus(conn->pgconn) : PQresultStatus(*pgres)));\n ^~~~~~~~~~~~~~~~~~~~~~\n psycopg/pqpath.c:1714:11: warning: code will never be executed [-Wunreachable-code]\n ret = 1;\n ^\n psycopg/pqpath.c:1819:17: warning: implicit conversion from enumeration type 'ConnStatusType' to different enumeration type 'ExecStatusType' [-Wenum-conversion]\n PQstatus(curs->conn->pgconn) : PQresultStatus(curs->pgres)));\n ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n 3 warnings generated.\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/utils.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/utils.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/bytes_format.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/bytes_format.o\n In file included from psycopg/bytes_format.c:81:\n In file included from ./psycopg/psycopg.h:37:\n ./psycopg/config.h:81:13: warning: unused function 'Dprintf' [-Wunused-function]\n static void Dprintf(const char *fmt, ...) {}\n ^\n \n 1 warning generated.\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/connection_int.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/connection_int.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/connection_type.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/connection_type.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/cursor_int.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/cursor_int.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/cursor_type.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/cursor_type.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/column_type.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/column_type.o\n In file included from psycopg/column_type.c:27:\n In file included from ./psycopg/psycopg.h:37:\n ./psycopg/config.h:81:13: warning: unused function 'Dprintf' [-Wunused-function]\n static void Dprintf(const char *fmt, ...) {}\n ^\n 〜中略〜\n \n 1 warning generated.\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/xid_type.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/xid_type.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_asis.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_asis.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_binary.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_binary.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_datetime.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_datetime.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_list.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_list.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_pboolean.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pboolean.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_pdecimal.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pdecimal.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_pint.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pint.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_pfloat.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pfloat.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/adapter_qstring.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_qstring.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/microprotocols.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols.o\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/microprotocols_proto.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols_proto.o\n In file included from psycopg/microprotocols_proto.c:27:\n In file included from ./psycopg/psycopg.h:37:\n ./psycopg/config.h:81:13: warning: unused function 'Dprintf' [-Wunused-function]\n static void Dprintf(const char *fmt, ...) {}\n ^\n 1 warning generated.\n gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPSYCOPG_VERSION=2.8.4 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120001 -DHAVE_LO64=1 -I/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I. -I/usr/local/include -I/usr/local/include/postgresql/server -c psycopg/typecast.c -o build/temp.macosx-10.9-x86_64-3.7/psycopg/typecast.o\n gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.7/psycopg/psycopgmodule.o build/temp.macosx-10.9-x86_64-3.7/psycopg/green.o build/temp.macosx-10.9-x86_64-3.7/psycopg/pqpath.o build/temp.macosx-10.9-x86_64-3.7/psycopg/utils.o build/temp.macosx-10.9-x86_64-3.7/psycopg/bytes_format.o build/temp.macosx-10.9-x86_64-3.7/psycopg/libpq_support.o build/temp.macosx-10.9-x86_64-3.7/psycopg/win32_support.o build/temp.macosx-10.9-x86_64-3.7/psycopg/solaris_support.o build/temp.macosx-10.9-x86_64-3.7/psycopg/connection_int.o build/temp.macosx-10.9-x86_64-3.7/psycopg/connection_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/cursor_int.o build/temp.macosx-10.9-x86_64-3.7/psycopg/cursor_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/column_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/replication_connection_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/replication_cursor_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/replication_message_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/diagnostics_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/error_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/conninfo_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/lobject_int.o build/temp.macosx-10.9-x86_64-3.7/psycopg/lobject_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/notify_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/xid_type.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_asis.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_binary.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_datetime.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_list.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pboolean.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pdecimal.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pint.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_pfloat.o build/temp.macosx-10.9-x86_64-3.7/psycopg/adapter_qstring.o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols.o build/temp.macosx-10.9-x86_64-3.7/psycopg/microprotocols_proto.o build/temp.macosx-10.9-x86_64-3.7/psycopg/typecast.o -L/usr/local/lib -lpq -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.7/psycopg2/_psycopg.cpython-37m-darwin.so\n ld: library not found for -lssl\n clang: error: linker command failed with exit code 1 (use -v to see invocation)\n error: command 'gcc' failed with exit status 1\n \n ----------------------------------------\n Command \"/Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/bin/python -u -c \"import setuptools, tokenize;__file__='/private/tmp/pip-install-plxviv83/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record /private/tmp/pip-record-xd6k1r8g/install-record.txt --single-version-externally-managed --compile --install-headers /Users/apple/GoogleDrive/harvest_timer/harvest_timer/venv/include/site/python3.7/psycopg2\" failed with error code 1 in /private/tmp/pip-install-plxviv83/psycopg2/\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T10:19:21.390",
"favorite_count": 0,
"id": "61299",
"last_activity_date": "2019-12-10T13:26:49.743",
"last_edit_date": "2019-12-10T13:13:35.483",
"last_editor_user_id": "36988",
"owner_user_id": "36988",
"post_type": "question",
"score": 1,
"tags": [
"macos",
"django",
"postgresql"
],
"title": "macのローカル環境にpsycopg2のインストールができない",
"view_count": 2356
} | [
{
"body": "一番重要そうなのはこのエラーメッセージです。このメッセージはライブラリのインストール時に libssl が見つかっていないことを示しています。\n\n```\n\n ld: library not found for -lssl\n \n```\n\n[metropolis\nさんのコメント](https://ja.stackoverflow.com/questions/61299/mac%E3%81%AE%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E7%92%B0%E5%A2%83%E3%81%ABpsycopg2%E3%81%AE%E3%82%A4%... | 61299 | 61300 | 61300 |
{
"accepted_answer_id": "61305",
"answer_count": 1,
"body": "Emacs の M-x コマンドを起動時に実行するように設定ファイル(.emacs)に書くにはどうすればいいでしょうか?\n\n例えば、M-x speedbar として実行しているコマンドを起動時に実行するようにするには、設定ファイルにどう書けばいでしょうか?\n\nご教授お願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T11:31:14.717",
"favorite_count": 0,
"id": "61303",
"last_activity_date": "2019-12-10T12:30:36.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "37014",
"post_type": "question",
"score": 0,
"tags": [
"emacs"
],
"title": "Emacs で 起動時に M-x コマンドを実行するには",
"view_count": 138
} | [
{
"body": "`loaddefs.el` には以下の様に定義されています。\n\n**emacs/27.0.50/lisp/loaddefs.el**\n\n```\n\n (defalias 'speedbar 'speedbar-frame-mode)\n (autoload 'speedbar-frame-mode \"speedbar\" ...\n \n```\n\n`speedbar-frame-mode` の定義は以下の通り。\n\n**emacs/27.0.50/lisp/speedbar.el**\n\n```\n\n (defun speedbar-frame-mo... | 61303 | 61305 | 61305 |
{
"accepted_answer_id": "61657",
"answer_count": 1,
"body": "ナル文字を使って、数字文字の出現回数を出力するプログラムを書きたいのですがうまくいきません。自分の見解では、間違っているところが見つけられないのですが、どこが間違っているのでしょうか。\n\nちなみに、自分は以下のようにプログラムしました。\n\n```\n\n void str_dcount(const char s[],int cnt[])\n {\n int i;\n i=0;\n while(s[i]!='\\0'){\n if('0'<=s[i] && s[i]<='9'){\n cnt[s[i]-'0']++;\n }\n i++;\n }\n }\n \n int main(void)\n {\n char str[128];\n int dcnt[10]={0};\n int i;\n printf(\"文字列? \");\n scanf(\"%s\",str);\n str_dcount(str,dcnt);\n puts(\"数字文字の出現回数\");\n for(i=0;i<10;i++){\n putchar('\\'');\n putchar('0'+i);\n putchar('\\'');\n putchar(\":%d\\n\",dcnt[i]);\n }\n return 0;\n }\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T11:38:06.373",
"favorite_count": 0,
"id": "61304",
"last_activity_date": "2019-12-21T17:13:00.753",
"last_edit_date": "2019-12-10T12:40:32.280",
"last_editor_user_id": "3060",
"owner_user_id": "36412",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "文字列(数字文字の出現回数)",
"view_count": 318
} | [
{
"body": "[3つの文字列を連結するプログラムの書き方。](https://ja.stackoverflow.com/q/61651/26370)\nの方で使い方に理解が不足しているように見えたので、こちらの対処方法も回答しておきます。\n\n元の`scanf`でも良いのですが、新しいコンパイラでエラー、警告の出ないこちら\n[scanf_s、_scanf_s_l、wscanf_s、_wscanf_s_l](https://docs.microsoft.com/ja-\njp/cpp/c-runtime-library/reference/scanf-s-scanf-s-l-wscanf-s-wscanf-... | 61304 | 61657 | 61657 |
{
"accepted_answer_id": "61351",
"answer_count": 1,
"body": "javascript初心者です。\n\nUnix系のファイルシステムではファイル・パス名の大文字・小文字は区別されますが、javascriptで以下のような関数はどのような方法で実現できるでしょうか?\n\n引数:ファイル名を示す文字列\n\n処理内容:サーバー上に引数で示した名前のファイルが存在するか判定する。ただし、大文字・小文字の違いがあっても同じファイルとみなして判定する。\n\n返り値:指定したファイルが存在しない場合は空文字列を返す。ファイルが存在する場合はそのファイルの(大文字・小文字の区別が)正しいファイル名を返す。\n\n以上、よろしくお願いします。\n\n追記:コメントで確認いただいた項目について回答します。 \n>らっしー様 \nそのケースがありましたね。該当するファイルが複数存在する場合はそれら全てを配列で返すという方向で。(実際は大文字・小文字だけ異なるファイルが複数存在するケースは用途的に想定していません)\n\n>nekketsuuu様 \nWindows環境から画像ファイルおよび画像ファイルのファイル名を記述したテキストファイルがサーバーにアップロードされていて、テキストファイルに記述された画像をjavascriptのプログラムで読み込みたいが記述されているファイル名の大文字・小文字がいい加減である…といった状況を想定しています。\n\n>supa様 \nNode.jsではなくクライアントのブラウザ上で処理が実行されることを想定しています。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T13:04:01.380",
"favorite_count": 0,
"id": "61307",
"last_activity_date": "2019-12-11T15:43:56.017",
"last_edit_date": "2019-12-11T12:55:26.510",
"last_editor_user_id": "37015",
"owner_user_id": "37015",
"post_type": "question",
"score": 1,
"tags": [
"javascript"
],
"title": "javascriptで大文字・小文字の違いを踏まえたファイルの存在確認",
"view_count": 492
} | [
{
"body": "**サーバー側で**\n探すのなら、ファイル名のリストを取得し、各ファイル名の子文字を大文字に変換した上で、検索したいファイル名(を大文字にしたもの)を使って検索すると良いです。\n\nただ「クライアントのブラウザ上で処理が実行されることを想定しています」とのことなので、実際にこういうことができるかはサーバー側のファイル情報をどのような\nAPI で知れるのかに依りそうです。\n\nまた今回の話は case insensitive な環境から case sensitive\nな環境にアップロードされた場合を考えているので、きちんとファイル名を保存していれば情報は欠損せず、何も困らないはずです。そ... | 61307 | 61351 | 61351 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "以下データの列統一しようとするできない。なぜでしょうか。\n\n以下df3データ\n\n```\n\n array([list([-1, 0, 1, 2, 1, 1, 3, 4, 5, 6, 3, 3, 7, 8, 9]),\n list([-1, 10, 11, 10, 12, 13, 14, 13, 15, 13, 16, 13, 17, 13, 18]),dtype=object)\n \n```\n\n上記データの列をそろえようと以下コートです。\n\nコードpython\n\n```\n\n X = sum(df3.tolist(), [])\n ## Max size\n l = max(map(len, X))\n ## Padding\n B = np.array(map(lambda x: x + [0]*(l-len(x)), X))\n \n```\n\n以下エラー内容\n\n```\n\n AttributeError Traceback (most recent call last)\n <ipython-input-13-d279312ff4d1> in <module>\n ----> 1 X = sum(df3.tolist(), [])\n 2 ## Max size\n 3 l = max(map(len, X))\n 4 ## Padding\n 5 B = np.array(map(lambda x: x + [0]*(l-len(x)), X))\n \n AttributeError: 'list' object has no attribute 'tolist'\n \n```\n\nよろしくお願いします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T13:29:49.747",
"favorite_count": 0,
"id": "61308",
"last_activity_date": "2022-02-14T00:04:55.453",
"last_edit_date": "2019-12-10T13:32:57.810",
"last_editor_user_id": "32986",
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"python",
"numpy"
],
"title": "配列arrayの列を統一できない",
"view_count": 1425
} | [
{
"body": "こちら解決しました。 \n勘違いして配列かと思ってました。リストでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T14:00:33.457",
"id": "61310",
"last_activity_date": "2019-12-10T14:00:33.457",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_i... | 61308 | null | 61310 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "自分の環境のみで起こる現象か確認したいコードがあります。\n\nVisual Studio 2019 Community Ver16.4\n\n```\n\n #include <iostream>\n \n struct Test {\n constexpr Test() : elements{ 1,2,3 } {\n }\n constexpr Test& operator+=(double s) {\n for (auto&& p : elements)\n p += s;\n return *this;\n }\n double elements[3];\n };\n \n int main(){\n constexpr auto res1 = Test{} += 3.0;\n std::cout << \"res1(constexpr)\" << std::endl;\n for (auto&& p : res1.elements)\n std::cout << p << std::endl;\n \n auto res2 = Test{} += 3.0;\n std::cout << \"res2\" << std::endl;\n for (auto&& p : res2.elements)\n std::cout << p << std::endl;\n }\n \n```\n\nwandboxのclangやGCC、visual studioでもclang-clの場合は期待通りに動きます。 \nプラットフォームをVisual Studio 2019\n(v142)にしたときのみconstexprのoperator内のforループが動いてないような結果がでるのです。\n\nVisual Studioでの結果(res1の結果がおかしい)\n\n```\n\n res1(constexpr)\n 1\n 2\n 3\n res2\n 4\n 5\n 6\n \n```\n\n[wandbox](https://wandbox.org/permlink/8aghr4S9mqKFIUpu)での結果(期待した結果)\n\n```\n\n res1(constexpr)\n 4\n 5\n 6\n res2\n 4\n 5\n 6\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T13:45:39.520",
"favorite_count": 0,
"id": "61309",
"last_activity_date": "2019-12-10T14:03:57.473",
"last_edit_date": "2019-12-10T14:03:57.473",
"last_editor_user_id": "19110",
"owner_user_id": "37016",
"post_type": "question",
"score": 4,
"tags": [
"c++",
"visual-c++"
],
"title": "VC++においてconstexprのoperatorの中で範囲for文が動かない",
"view_count": 200
} | [] | 61309 | null | null |
{
"accepted_answer_id": "61314",
"answer_count": 4,
"body": "末尾の0でない0を削除したいのですが、`/[^0$]0/` こうすると0と直前の文字を削除してしまいます。`/^(?!0$)0/`\nこちらも試しましたが、マッチしませんでした。\n\n```\n\n '12/09'.replace(/[^0$]0/, '') // この場合は0を削除したい\n '12/10'.replace(/[^0$]0/, '') // この場合はしたくない\n \n replace(/^(?!0$)0/, '')\n \n```\n\nご教示いただければ幸いです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T14:22:44.350",
"favorite_count": 0,
"id": "61311",
"last_activity_date": "2019-12-18T17:17:45.733",
"last_edit_date": "2019-12-18T17:17:45.733",
"last_editor_user_id": "3060",
"owner_user_id": "32180",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"正規表現"
],
"title": "正規表現で \"月日\" を表す文字列から末尾以外の0を削除したい",
"view_count": 2406
} | [
{
"body": "こういうこと?\n\n```\n\n '12/01'.replace(/\\b0+/, '')\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T14:44:22.737",
"id": "61312",
"last_activity_date": "2019-12-10T14:44:22.737",
"last_edit_date": null,
"last_editor_user_id":... | 61311 | 61314 | 61312 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "CentOS6 サーバにて、送信速度の制限を行いたいと思っています。\n\n現在、IPアドレス 192.0.2.1 への送信速度を、次の方法で 1Mbps に制限しています。\n\n```\n\n tc qdisc add dev eth0 root handle 1:0 htb\n tc class add dev eth0 parent 1:0 classid 1:1 htb rate 1mbps burst 1500\n tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dst 192.0.2.1 flowid 1:1\n \n```\n\nそれに加えて、192.0.2.1 以外への送信速度を 500Kbps に制限したいのですが、どのようなコマンドで実現可能か教えて頂けますでしょうか。\n\n試しに以下を実行してみましたが制限されませんでした。\n\n```\n\n tc class add dev eth0 parent 1:0 classid 1:2 htb rate 500kbps burst 1500\n tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dst * flowid 1:2\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-10T18:44:54.090",
"favorite_count": 0,
"id": "61318",
"last_activity_date": "2019-12-11T00:53:00.407",
"last_edit_date": "2019-12-11T00:53:00.407",
"last_editor_user_id": "3060",
"owner_user_id": "691",
"post_type": "question",
"score": 3,
"tags": [
"centos",
"network"
],
"title": "tcコマンドで送信速度を制限したい",
"view_count": 373
} | [] | 61318 | null | null |
{
"accepted_answer_id": "61326",
"answer_count": 1,
"body": "# 疑問\n\npythonでは従兄弟のパッケージをインポートしようとするならば、\n\n```\n\n import sys\n sys.path.append('..')\n \n```\n\nのような形で親階層のパスを通してやる必要がありますが、パスの追加無しに親階層パッケージのインポートが出来ているような例が見つかったので質問しました。\n\n# ディレクトリ構成\n\n```\n\n .\n ├── pkg_a\n │ ├── __init__.py\n │ └── cls_a.py\n ├── pkg_b\n │ ├── __init__.py\n │ └── cls_b.py\n └── run.py\n \n```\n\n# ファイル内容\n\npkg_a/__init__.py\n\n```\n\n from .cls_a import ClsA\n \n```\n\npkg_a/cls_a.py\n\n```\n\n class ClsA:\n @staticmethod\n def hello():\n print('Hello Cls A')\n \n```\n\npkg_b/__init__.py\n\n```\n\n from .cls_b import ClsB\n \n```\n\n**pkg_b/cls_b.py**\n\n```\n\n from pkg_a import ClsA\n \n class ClsB:\n @staticmethod\n def hello():\n ClsA.hello()\n print('Hello Cls B')\n \n```\n\nrun.py\n\n```\n\n from pkg_b import ClsB\n \n ClsB.hello()\n \n```\n\n# 説明\n\n**cls_b.py**\nはcls_a.pyをインポートしていますが、階層的に言えばcls_b.pyはcls_a.pyが存在している親階層のパッケージを参照していることになり、本来不可能なことだと思います。\n\nしかし、run.pyを実行すると以下のような結果となり、cls_a.pyは参照されています。\n\n```\n\n > python run.py \n Hello Cls A\n Hello Cls B\n \n```\n\ncls_b.pyからcls_a.pyへの参照が成功している理由を教えて下さい。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T02:19:42.957",
"favorite_count": 0,
"id": "61324",
"last_activity_date": "2019-12-11T02:58:10.720",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9616",
"post_type": "question",
"score": 3,
"tags": [
"python",
"python3"
],
"title": "親階層のパッケージをパス追加無しでimport出来てしまう",
"view_count": 428
} | [
{
"body": "[`sys.path`](https://docs.python.org/ja/3/library/sys.html#sys.path)は現在実行しているモジュールではなく、Python\nインタプリタを起動したスクリプトのあるディレクトリが重要です。\n\nもし`run.py`を`pkg_b`の下にこのように移動して実行すると、`ModuleNotFoundError`とエラーが発生する。\n\n```\n\n $ cat pkg_b/run.py \n from cls_b import ClsB\n \n ClsB.hello()\n \n $ tree... | 61324 | 61326 | 61326 |
{
"accepted_answer_id": "61519",
"answer_count": 1,
"body": "`numpy.matrix`型の行列データがあります.これを行列の画像として出力したいのですが調べてもなかなか出てきません.`numpy.array`型なら色々方法はあるみたいですが,`numpy.matrix`型のデータに対して画像として出力,保存する方法はありますか?\n\n以下がサンプルデータの一部です\n\n```\n\n A = np.matrix([\n [0, 1, 1],\n [1, 0, 1],\n [1, 1, 0]\n ])\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T02:32:54.590",
"favorite_count": 0,
"id": "61325",
"last_activity_date": "2019-12-17T15:19:58.263",
"last_edit_date": "2019-12-11T03:15:18.260",
"last_editor_user_id": "36856",
"owner_user_id": "36856",
"post_type": "question",
"score": 3,
"tags": [
"python",
"python3",
"numpy"
],
"title": "numpyのmatrix型のデータを画像として出力したい",
"view_count": 183
} | [
{
"body": "`pandas`に`to_latex()`というメソッドがあって、`PyLaTeX`と(さらにLaTexのコンパイラと)組み合わせると、目的のものが出来そうです。こちらの記事に出ていました。 \n[how to print a data frame from pandas using\npylatex](https://tex.stackexchange.com/q/340349) \n上記記事で承認後にもっと簡単に出来るよ、と付いた回答の方ですね。\n\n> It might be noted, that pandas DataFrames already have a quite\n> ... | 61325 | 61519 | 61519 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "### 質問\n\nBIOSパスワードは代表的にはどのようなものがあって、それぞれどんな安全性を担保していますか?\n\n### 経緯\n\n[他の方の質問](https://ja.stackoverflow.com/q/61031/19110)を読んでいて、「BIOSパスワード」と呼ばれるものが複数あると気付きました。[英語版Wikipedia](https://en.wikipedia.org/wiki/BIOS)を見ると、次のようにBIOSのパスワードにも色々あると書かれています。\n\n> Setting various passwords, such as a password for securing access to the\n> BIOS user interface functions itself and preventing malicious users from\n> booting the system from unauthorized portable storage devices, a password\n> for booting the system, or a hard disk drive password that limits access to\n> it and stays assigned even if the hard disk drive is moved to another\n> computer\n\nつまり、少なくとも以下の3種類があります。\n\n 1. BIOSのUIを立ち上げる際に要求するパスワード。\n 2. システムをブートする際に要求するパスワード。\n 3. ハードディスクにアクセスする前に要求するパスワード。\n\nこの仕組みについて考えていると、いくつかよく知らない点があることに気付きました。\n\n * 1番目のパスワードは具体的にBIOS設定の何を守りたいのでしょうか。ブート順を不用意に変えられないようにしたいということでしょうか。しかし繋がっているストレージそのものを入れ替えられるとブート順を変えずに別のストレージから起動できてしまったりしないのでしょうか(そういうことができないための仕組みがある?)。\n * 2番目のパスワードはOSが立ち上がる前にパスワードを要求することで、たとえばネットワーク越しにシステムを立ち上げた後OSやその他ソフトウェアの不具合を突くなどして不正ログインされないためのものだと理解しているのですが、逆に言えばシステムごと物理的に盗まれた場合はマザーボードを入れ替えるなどすればこのパスワードは意味が無くなるということでしょうか。\n * 3番目のパスワードはそもそもどこにパスワードが保存されるのでしょうか。ハードディスクを守ろうとしてもハードディスクだけ取り出して別のシステムで起動すれば立ち上がってしまうような気がするのですが、そういうこともできないようになっているのでしょうか。\n\n全体的に、BIOSがどのように実装されているのかの理解が足りず、各々のパスワードが何を守っていて、かつそれが本当に意味のあるものなのか判定ができないというものです。\n\n**そこで、質問です** :BIOSパスワードは代表的にはどのようなものがあって、それぞれどんな安全性を担保していますか?\nつまり、各々のパスワードはどういう仮定のもとで何を守っていますか? どういうシチュエーションならパスワードを設定した意味がなくなりますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T04:00:10.073",
"favorite_count": 0,
"id": "61328",
"last_activity_date": "2019-12-12T15:36:22.977",
"last_edit_date": "2019-12-12T13:29:39.627",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"post_type": "question",
"score": 5,
"tags": [
"security",
"bios"
],
"title": "BIOSパスワードはどんな安全性を担保していますか?",
"view_count": 447
} | [
{
"body": "メーカーによって対応は違ってくると思いますが、[Dellの例](https://www.dell.com/community/%E4%B8%80%E8%88%AC-%E3%83%8E%E3%83%BC%E3%83%88%E3%83%91%E3%82%BD%E3%82%B3%E3%83%B3/BIOS%E3%81%A7%E8%A8%AD%E5%AE%9A%E3%81%A7%E3%81%8D%E3%82%8B%E3%83%91%E3%82%B9%E3%83%AF%E3%83%BC%E3%83%89%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6/td-p/6225663)\n... | 61328 | null | 61333 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "昨日は問題なかったのですが、今日デプロイするとエラーになってしまい、起動できませんでした。 \nソースへの変更等はしていません。 \nまた別のRailsアプリケーション(別プロジェクトですが以前まではGAE上で動いていたもの)をデプロイしても同様のエラーとなってしまいました。\n\nbeta版なので変更が入ったのかな?と思いますが、どなたか解決方法をご存知でしたら教えてください。\n\nログはこちらです。\n\n```\n\n 2019-12-11T03:50:36.531824Z bundler: failed to load command: rails (/srv/vendor/bundle/ruby/2.5.0/bin/rails) A \n 2019-12-11T03:50:36.531878Z Bundler::GemNotFound: Could not find nokogiri-1.10.7 in any of the sources A \n 2019-12-11T03:50:36.531897Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/spec_set.rb:87:in `block in materialize' A \n 2019-12-11T03:50:36.531913Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/spec_set.rb:81:in `map!' A \n 2019-12-11T03:50:36.531928Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/spec_set.rb:81:in `materialize' A \n 2019-12-11T03:50:36.531950Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/definition.rb:170:in `specs' A \n 2019-12-11T03:50:36.531968Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/definition.rb:237:in `specs_for' A \n 2019-12-11T03:50:36.531985Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/definition.rb:226:in `requested_specs' A \n 2019-12-11T03:50:36.532001Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/runtime.rb:108:in `block in definition_method' A \n 2019-12-11T03:50:36.532015Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/runtime.rb:20:in `setup' A \n 2019-12-11T03:50:36.532029Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler.rb:107:in `setup' A \n 2019-12-11T03:50:36.532047Z /opt/ruby/lib/ruby/gems/2.5.0/gems/bundler-2.0.2/lib/bundler/setup.rb:20:in `<top (required)>' A \n 2019-12-11T03:50:36.532063Z /opt/ruby/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require' A \n 2019-12-11T03:50:36.532080Z /opt/ruby/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:54:in `require' A \n \n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T04:07:46.187",
"favorite_count": 0,
"id": "61330",
"last_activity_date": "2019-12-11T04:48:02.797",
"last_edit_date": "2019-12-11T04:48:02.797",
"last_editor_user_id": "3060",
"owner_user_id": "25616",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails",
"ruby",
"google-cloud",
"google-app-engine"
],
"title": "Google App Engine Standard の Ruby (beta) でデプロイができなくなった",
"view_count": 250
} | [] | 61330 | null | null |
{
"accepted_answer_id": "61340",
"answer_count": 1,
"body": "Tkで準備されているmessageboxではなく、カスタムメッセージボックスを作りたいと考えています。\n\n要件としては、\n\n 1. 常にTopLevelであること \nアプリケーションのコアとなるTkオブジェクトよりも、メッセージボックスが表示されている間は、メッセージボックスが前面にしたいです。\n\n 2. メッセージボックス以外の操作が不可(モーダル) \nメッセージボックスが押されるまで、他のTKオブジェクトは操作できないようにしたい。\n\n 3. メッセージボックスの戻り値を待つ \nメッセージボックスの入力を待ってから次のアクション(ウィジットの表示/非表示等)に移りたい。\n\n 4. アプリケーションの処理は継続したい \nアプリケーションのコアとなるTkオブジェクトは、afterメソッドにより定期的な処理は継続したい。\n\n 5. カスタムメッセージボックスには標準のタイトルバーはつけたくない。 \n\nこのようなメッセージボックスをカスタムで作成したいのですが、うまくいきません。\n\n**実行結果** \nメッセージボックスは、モーダルにならず、閉じると以下のエラーになります。\n\n```\n\n invalid command name \"1469565913800dialog_mouse_release\"\n while executing\n \"1469565913800dialog_mouse_release 138 1 ?? ?? ?? 264 98160984 ?? 19 21 ?? 0 ?? ?? .!frame3.!button2 5 543 480 ??\"\n invoked from within\n \"if {\"[1469565913800dialog_mouse_release 138 1 ?? ?? ?? 264 98160984 ?? 19 21 ?? 0 ?? ?? .!frame3.!button2 5 543 480 ??]\" == \"break\"} break\"\n (command bound to event)\n \n```\n\n**ソースコード**\n\n```\n\n #! /usr/bin/env python3\n # -*- coding: utf-8 -*-\n \n import tkinter as tk\n from tkinter import ttk\n \n from tkinter import messagebox\n \n from PIL import Image,ImageTk,ImageDraw,ImageFont\n \n import datetime\n \n class CustomDialog(object):\n def __init__(self):\n \n self.title_bar_color = '#8FAADC'\n self.item_ground_color = 'whitesmoke'\n self.background_color = '#D9D9D9'\n self.select_bar_color = '#BDD7EE'\n \n self.isDrag_DlgMotion = False\n self.drag_dx = 0\n self.drag_dy = 0\n \n def dialog_left_click(self,event):\n dialog_x=self.dev_dialog.winfo_rootx()\n dialog_y=self.dev_dialog.winfo_rooty()\n point_x=self.dev_dialog.winfo_pointerx()\n point_y=self.dev_dialog.winfo_pointery()\n \n dx = point_x - dialog_x\n dy = point_y - dialog_y\n \n if (dx >= 0 and dx <= self.title_bar_width) and (dy >= 0 and dy <= self.title_bar_height):\n self.drag_dx = dx\n self.drag_dy = dy\n self.isDrag_DlgMotion = True\n return\n \n def dialog_mouse_move_on(self,event):\n if self.isDrag_DlgMotion:\n X = event.x_root - self.drag_dx\n Y = event.y_root - self.drag_dy\n self.dev_dialog.geometry('+{0}+{1}'.format(X, Y))\n pass\n return\n \n def dialog_mouse_release(self,event):\n if self.isDrag_DlgMotion:\n self.isDrag_DlgMotion = False\n return\n \n class CommonMessageBoxDialog(CustomDialog):\n def __init__(self,title,message,state,parent = None):\n self.return_state = None\n \n if not isinstance(title,str) or not isinstance(message,str) or not isinstance(state,int):\n return\n if state < 1 or state > 3 :\n return\n \n root = ttk.tkinter.Tk()\n \n #root = tk.Toplevel(parent)\n \n super().__init__()\n \n self.box_state = state\n self.box_message = message\n self.box_title = title\n \n W = 0\n H = 1\n \n self.dlg_size = [400,200]\n \n self.title_bar_width = self.dlg_size[W]\n self.title_bar_height = 40\n \n self.btn_bar_height = 42\n \n self.btn_32x32_size = 42\n \n self.row_height = 28\n self.btn_row_height = 32\n \n self.frm_space = 10\n \n self.parent = parent\n self.CreateDialog(root)\n \n root.mainloop()\n \n def CreateDialog(self,root):\n \n W = 0\n H = 1\n \n if self.parent != None:\n self.parent.update_idletasks()\n ww=self.parent.winfo_screenwidth()\n wh=self.parent.winfo_screenheight()\n x=self.parent.winfo_rootx()\n y=self.parent.winfo_rooty()\n \n parent_w = self.parent.winfo_width()\n parent_h = self.parent.winfo_height()\n parent_x = self.parent.winfo_x()\n parent_y = self.parent.winfo_y()\n else:\n root.update_idletasks()\n ww=root.winfo_screenwidth()\n wh=root.winfo_screenheight()\n x=root.winfo_rootx()\n y=root.winfo_rooty()\n \n parent_w = root.winfo_width()\n parent_h = root.winfo_height()\n parent_x = root.winfo_x()\n parent_y = root.winfo_y()\n \n \n self.dev_dialog = root\n dialog = self.dev_dialog\n dialog.overrideredirect(True)\n \n dlg_x = int((parent_x+parent_w) - (self.dlg_size[W]/2))\n dlg_y = int((parent_y+parent_h) - (self.dlg_size[H]/2))\n \n if dlg_x < 0 : dlg_x = 0 \n if dlg_y < 0 : dlg_y = 0 \n \n dialog.geometry('{}x{}+{}+{}'.format(self.dlg_size[W],self.dlg_size[H],dlg_x,dlg_y))\n \n \n self.Title_Bar = tk.Frame(\n dialog, \n relief='flat',\n bg = self.title_bar_color ,\n )\n self.Title_Label = tk.Label(\n self.Title_Bar,\n bg = self.title_bar_color ,\n text = self.box_title,\n )\n \n dialog.bind('<Button-1>', self.dialog_left_click)\n dialog.bind('<B1-Motion>', self.dialog_mouse_move_on)\n dialog.bind('<ButtonRelease-1>',self.dialog_mouse_release)\n \n self.MsgArea_frame = tk.Frame(\n dialog, \n relief='flat',\n bg = self.select_bar_color,\n )\n self.message_frame = tk.Frame(\n self.MsgArea_frame,\n relief='flat',\n bg = self.item_ground_color ,\n )\n self.label_message = tk.Label(\n self.message_frame,\n bg = self.item_ground_color ,\n text = self.box_message,\n )\n \n self.BtnArea_frame = tk.Frame(\n dialog, \n relief='flat',\n bg = self.item_ground_color,\n )\n \n self.btn_ok = tk.Button(\n self.BtnArea_frame, \n bg = self.item_ground_color,\n text = 'OK',\n command = lambda:self.btn_msgbox_clicked(1),\n )\n \n self.btn_yes = tk.Button(\n self.BtnArea_frame, \n bg = self.item_ground_color,\n text = 'YES',\n command = lambda:self.btn_msgbox_clicked(1),\n )\n \n self.btn_no = tk.Button(\n self.BtnArea_frame, \n bg = self.item_ground_color,\n text = 'NO',\n command = lambda:self.btn_msgbox_clicked(2),\n )\n \n self.btn_cancel = tk.Button(\n self.BtnArea_frame, \n bg = self.item_ground_color,\n text = 'CANCEL',\n command = lambda:self.btn_msgbox_clicked(3),\n )\n \n frm_space = self.frm_space\n msg_frm_w = 4\n btn_fram_h = 36\n \n message_area_h = self.dlg_size[H] - self.title_bar_height - frm_space *2 - btn_fram_h\n \n # Frame\n self.Title_Bar.place(\n x = 0, y = 0, \n width = self.title_bar_width, height = self.title_bar_height\n )\n self.MsgArea_frame.place(\n x = frm_space, y = self.title_bar_height + frm_space, \n width = self.title_bar_width - frm_space*2, height = message_area_h\n )\n self.BtnArea_frame.place(\n x = 0, y = self.title_bar_height + frm_space + message_area_h, \n width = self.title_bar_width, height = btn_fram_h\n )\n \n self.Title_Label.grid(row = 0, column = 1,sticky = tk.W+tk.N+tk.S)\n self.Title_Bar.columnconfigure(0,minsize = self.frm_space)\n self.Title_Bar.rowconfigure(0,minsize = self.title_bar_height)\n \n self.MsgArea_frame.columnconfigure(0,minsize = self.frm_space)\n self.MsgArea_frame.rowconfigure(0,minsize = message_area_h)\n \n self.BtnArea_frame.rowconfigure(0,minsize = btn_fram_h)\n \n self.message_frame.place(\n x = msg_frm_w, y = msg_frm_w,\n width = self.title_bar_width - frm_space*2 - msg_frm_w*2, height = message_area_h - msg_frm_w*2,\n )\n \n # self.message_frame\n self.label_message.grid(row = 0, column = 1,sticky = tk.W+tk.N+tk.S)\n \n if self.box_state == 1:\n self.btn_ok.place(\n x = (self.title_bar_width/2) - 80/2 , y = btn_fram_h/2 - 24/2,\n ) \n if self.box_state == 2:\n self.btn_yes.place(\n x = (self.title_bar_width/2) - (80 + frm_space) , y = btn_fram_h/2 - 24/2,\n ) \n self.btn_no.place(\n x = (self.title_bar_width/2) + frm_space , y = btn_fram_h/2 - 24/2,\n ) \n if self.box_state == 3:\n self.btn_yes.place(\n x = (self.title_bar_width/2) - (80*1.5 + frm_space*2) , y = btn_fram_h/2 - 24/2,\n ) \n self.btn_no.place(\n x = (self.title_bar_width/2) - 80/2 , y = btn_fram_h/2 - 24/2,\n ) \n self.btn_cancel.place(\n x = (self.title_bar_width/2) + 80/2 + frm_space*2 , y = btn_fram_h/2 - 24/2,\n )\n \n dialog.grab_set_global()\n \n def btn_msgbox_clicked(self,state):\n self.return_state = state\n self.dev_dialog.destroy()\n \n def get_return_state(self):\n return self.return_state\n \n class CreateScreen(object):\n def __init__(self):\n self.cnt = 0\n W = 0\n H = 1\n self.dlg_size = [400,200]\n \n geo_string = '{}x{}'.format(self.dlg_size[W],self.dlg_size[H])\n \n self.MainWindow_obj = ttk.tkinter.Tk()\n self.MainWindow_obj.geometry(geo_string) \n \n self.CntSting = tk.StringVar()\n self.CntSting.set('...')\n \n Label_Conter_text = tk.Label(\n self.MainWindow_obj,\n textvariable = self.CntSting,\n )\n \n self.MsgSting = tk.StringVar()\n self.MsgSting.set(str(self.cnt))\n \n Label_Message_text = tk.Label(\n self.MainWindow_obj,\n textvariable = self.MsgSting,\n )\n \n Btn_Messagebox = tk.Button(\n self.MainWindow_obj,\n text = 'Push',\n command = self.Btn_Messagebox_clicked\n )\n Label_Conter_text.pack()\n Label_Message_text.pack()\n Btn_Messagebox.pack()\n \n self.MainWindow_obj.after(1000,self.loop_msg)\n \n self.MainWindow_obj.mainloop()\n \n def Btn_Messagebox_clicked(self):\n self.dlg = CommonMessageBoxDialog(title='Test',message='Do you remember ?',state=3,parent =self.MainWindow_obj) \n ret = self.dlg.get_return_state()\n \n if ret == 1:\n self.MsgSting.set('Yes')\n if ret == 2:\n self.MsgSting.set('No')\n if ret == 3:\n self.MsgSting.set('Cancel')\n \n return\n \n def loop_msg(self):\n self.cnt += 1\n self.MsgSting.set(str(self.cnt))\n \n self.MainWindow_obj.after(1000,self.loop_msg)\n \n if __name__ == '__main__':\n screen_obj = CreateScreen()\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T04:22:41.250",
"favorite_count": 0,
"id": "61331",
"last_activity_date": "2022-01-23T03:07:45.927",
"last_edit_date": "2020-09-15T00:41:53.123",
"last_editor_user_id": "3060",
"owner_user_id": "32891",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"tkinter"
],
"title": "Python Tkでカスタムメッセージボックスを作りたい",
"view_count": 1161
} | [
{
"body": "どうやら自己解決できたようです。 \nエラーのメッセージdialog_mouse_releaseから、マウスのリリースイベントを通知したいのに、ダイアログが破棄されてしまっていることが原因と推定しました。\n\nCreateDialogメソッドにおいて、Button-1、B1-Motion、ButtonRelease-1をバインドしています。これは、タイトルバーに代えてself.Title_Barをドラッグするとボックスを移動させるためにバインドしています。\n\nそこで、 \nbtn_msgbox_clickedメソッドにおいては、フラグ変数:self.isDestroyを用いて、 \n... | 61331 | 61340 | 61340 |
{
"accepted_answer_id": "61336",
"answer_count": 1,
"body": "Pythonを勉強して間もない者です。参考書やネット等で調べたのですが、理解が及ばなかった為、こちらで質問させていただきます。\n\nこのプログラムは初期値(V,E)を元に関数IDISTで計算した値を、default_valueとしています。またV=(0,1,2,3,4)を置換したものをpi[]とし120通りの置換したpi[]を元に、新たにnew_Eというエッジを作成し、置換した一つ一つのVを元に、関数IDISTでnew_Eを計算しています。計算したnew_EのIDISTとdefault_valueの値を比較し、小さい方を出力するというのがこのプログラムです。\n\nこのプログラムの出力結果として\n\n```\n\n (0,1,2,3,4)\n 12\n (0,1,2,4,3)\n 10\n (0,1,3,4,2)\n 11\n \n```\n\nと全通り出力されていくのですが、私はこのプログラムを120通りの中でIDISTが最も最小なものと、その時の置換pi[]のみを出力したいのです。ですがそのようにする上手い方法が思いつきません。拙い文章ではありますが、どなたかアドバイスを頂けたら幸いです。\n\n**目標となる出力**\n\n```\n\n 最小コスト 2\n その時の置換 (1,4,0,3,2)\n (1,4,2,0,3)\n (1,4,2,3,0)\n (2,0,1,4,3)\n (2,0,3,1,4)\n (2,0,3,4,1)\n \n```\n\n**ソースコード**\n\n```\n\n class Edge():\n def __init__(self,a,b,c):\n self.u = a\n self.v = b\n self.weight = c\n def __str__(self):\n return '(' + str(self.u) + ',' + str(self.v) + ',' + str(self.weight) + ')'\n \n class Graph():\n def __init__(self,d,e):\n self.V = d\n self.E = e\n \n import itertools\n \n V = tuple(range(0, 5)) # tuple of integers\n E = (Edge(0,3,1), Edge(0,2,3), Edge(0,4,2), Edge(2,4,1))\n G = Graph(V, E)\n \n def iDist(V,E):\n value = 0\n for e in E:\n value += e.weight * abs(abs(e.u - e.v)-1)\n return value\n \n default_value = iDist(V,E)\n min_sum = []\n \n for pi in itertools.permutations(V):\n new_E = (Edge(pi[0],pi[3],1), Edge(pi[0],pi[2],3), Edge(pi[0],pi[4],2), Edge(pi[2],pi[4],1))\n min_sum = min(default_value, iDist(pi,new_E))\n print(pi)\n print(min_sum)\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T05:10:51.037",
"favorite_count": 0,
"id": "61335",
"last_activity_date": "2019-12-11T09:55:42.590",
"last_edit_date": "2019-12-11T09:55:42.590",
"last_editor_user_id": "19110",
"owner_user_id": "34359",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "最小値とその時の状態を出力したいが、どのようにプログラミングすればよいかわからない。",
"view_count": 165
} | [
{
"body": "現状は for 文の中に `print(min_sum)`\nが入っているため、すべての繰り返しで出力されてしまっています。最小値は繰り返しきった後に確定するため、for の外側に出す必要があります。\n\n```\n\n for pi in itertools.permutations(V):\n (... コード ...)\n print(min_sum) # インデントを下げて for の外に出す。\n \n```\n\nまた、出力したいのは「最小値とそのときの `pi`」なので、`min_sum` の他に `min_pi`\nも覚えておく必要があります。... | 61335 | 61336 | 61336 |
{
"accepted_answer_id": "61341",
"answer_count": 1,
"body": "tensorflowでスパーステンソルのプレースホルダーに関して以下のように定義しました\n\n```\n\n ph = {\n 'adj_norm': tf.sparse_placeholder(tf.float32, name=\"adj_mat\"),\n 'x': tf.sparse_placeholder(tf.float32, name=\"x\")}\n \n```\n\nしかし,以下のようなエラーが出ます.\n\n> 'adj_norm': tf.sparse_placeholder(tf.float32, name=\"adj_mat\"), \n> AttributeError: module 'tensorflow' has no attribute 'sparse_placeholder'\n\n色々調べた結果,tensorflowのバージョンの違いが原因と考えられるのですが,そういう場合はどうすればこのエラーを解決することができますか? \nこちらのtensorflowとpythonのバージョンは`tensorflow=2.0.0`,`python=3.6.1`です.",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T06:03:08.273",
"favorite_count": 0,
"id": "61337",
"last_activity_date": "2019-12-11T08:46:15.147",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36856",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"機械学習",
"tensorflow"
],
"title": "tensorflowのsparse_placeholderのAttributeError",
"view_count": 145
} | [
{
"body": "TensorFlow 1のコードをTensorFlow 2で動かしてエラーになっているので、以下のいずれかで解決すると思います。\n\n * TensorFlow 2の文法で書き直す\n * TensorFlow 1互換モードで動かす\n * TensorFlow 1にダウングレードする\n\n参考) \n<https://www.tensorflow.org/guide/migrate>\n\n簡単そうなところで、\n\n```\n\n import tensorflow as tf\n \n```\n\nを\n\n```\n\n import tensorflow.... | 61337 | 61341 | 61341 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "今、json形式のpropertiesファイルを読むのを勉強しているものです。 \nそこで一つ詰まったところがありました。\n\n```\n\n {\n \"banana\":{\"type\":\"fruits\", \"color\":\"yellow\"}\n \"carrot\":{\"type\":\"vegetables\", \"color\":\"red\"}\n \"lemon\":{\"type\":\"fruits\", \"color\":\"yellow\"}\n \"apple\":{\"type\":\"fruits\", \"color\":\"red\"}\n }\n \n```\n\nこのとき \"banana\" と \"lemon\" は中身が同じなので纏めて書きたいのですが、どのように書けばいいんでしょうか?",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T11:08:21.813",
"favorite_count": 0,
"id": "61343",
"last_activity_date": "2019-12-11T11:08:21.813",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "37032",
"post_type": "question",
"score": 0,
"tags": [
"java",
"json"
],
"title": "jsonでグルーピングのようなことをしたい",
"view_count": 81
} | [] | 61343 | null | null |
{
"accepted_answer_id": "61354",
"answer_count": 1,
"body": "django, Python共に初心者です。\n\n現在djangoで作ったWebサイト内で表示したタスクリストの書き出しをCSVで対応したいと考えております。 \nCSVでの書き出しはいけるのですが、これをExcelで開くとutf-8のため、文字化けしてしまいます。 \n下記のどこかに(推測では [writer =\ncsv.writer(response)]の部分あたりで文字コードを指定するのかと思っていますが、うまくいきませんでした。\n\nまた、それとは別に書き出したデータを見ていると、一部空欄のデータを認識せずエクセルで列ずれが発生しています。\n\n<相談事項> \n1.Excelで書き出したCSVデータを開いたときに、文字化けせずに開けるようにする方法をご指導いただきたい \n2.DBが空欄だった場合も列を認識し、各項目をそろえて書き出しできる方法をご指導いただきたい\n\n環境 \n・OS : CentOS7 \n・Python : 3.6.7 \n・Django : 2.1 \n・DB : MariaDB\n\nお手数ですがアドバイスいただけると幸いです。 \nよろしくお願いいたします。\n\n```\n\n from django.shortcuts import render, redirect, get_object_or_404\n from django.http import HttpResponseRedirect\n from django.http import HttpResponse\n from .forms import PostForm\n from .models import Task\n import csv\n \n def task_export(request):\n response = HttpResponse(content_type='text/csv')\n response['Content-Disposition'] = 'attachment; filename = task_list.csv'\n writer = csv.writer(response)\n model = Task\n for task in Task.objects.all().order_by('id').reverse():\n writer.writerow([\n task.id,\n task.pic,\n task.issued_date,\n task.area,\n task.user,\n task.category1,\n task.category2,\n task.category3,\n task.task_content,\n task.details,\n task.duration,\n task.status,\n task.closed_date])\n return response\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T11:52:07.933",
"favorite_count": 0,
"id": "61344",
"last_activity_date": "2019-12-11T23:40:38.743",
"last_edit_date": "2019-12-11T12:12:36.230",
"last_editor_user_id": "34615",
"owner_user_id": "34615",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"django",
"csv",
"array",
"文字化け"
],
"title": "django / csvでのデータ書き出しの文字化け&列ずれ対策",
"view_count": 2644
} | [
{
"body": "> **1.Excelで書き出したCSVデータを開いたときに、文字化けせずに開けるようにする方法をご指導いただきたい**\n\nに関しては、ファイルの先頭にUTF-8のBOMを書き込めば良いでしょう。 \n[CSVファイルにUTF-8のBOMをつける -\nExcelで開くと文字化けするUTF-8のCSVを文字コードを変換せずに開く方法](https://primarytext.jp/blog/1275#CSVUTF-8BOM)\n\n>\n> CSVファイルの文字コードはUTF-8のままで、BOMをつけるだけです。BOMをつけると、ExcelがUTF-8だと判断してくれてShift_JISじ... | 61344 | 61354 | 61354 |
{
"accepted_answer_id": "61350",
"answer_count": 1,
"body": "「RAW」「JPEG」それぞれの仕様はどこで確認できますか? \nどこが決定している?\n\n特にExifについて確認したい \nExifは独立した仕様ですか。RAWのExifとJPEGのExifの違いなど \nExifをどうやって記録している? ヘッダー? メタデータ? 添付ファイル?\n\n* * *\n\n**疑問に思ったきっかけ** \nこれまで彩度は、JPEGへ対して後からソフトウェアで調整するものだと思っていました。しかし、Wikipediaでは下記のように記載されています\n\n> RAW画像を撮影できるカメラは、それらの設定をRAW画像に出力するが、実際の計算はパソコンで行われる\n\nこの意味が分かりませんでした。 \n「カメラで彩度設定した場合その設定をRAW画像に出力する、とはどういうことなのか」「(F値などの)他パラメーターと彩度におけるRAWでの取り扱われ方の違い」「そもそもRAWは画像なのか」など、色々疑問に思ったので質問しました",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T13:49:43.813",
"favorite_count": 0,
"id": "61346",
"last_activity_date": "2019-12-12T01:43:26.113",
"last_edit_date": "2019-12-12T01:08:54.057",
"last_editor_user_id": "7886",
"owner_user_id": "7886",
"post_type": "question",
"score": -1,
"tags": [
"画像"
],
"title": "RAWとJPEGの違い",
"view_count": 270
} | [
{
"body": "Wikipediaの記事だけでも結構な情報があるようです。\n\n[JPEG - Wikipedia](https://ja.wikipedia.org/wiki/JPEG) \n決定しているのはここでしょう。[Overview of JPEG](https://jpeg.org/jpeg/)\n\n> 規格書 \n> 規格は、合同のグループで作られたため国際標準化機構 (ISO)、国際電気標準会議 (IEC) と国際電気通信連合 (ITU)\n> の双方から出されている。それにならい、日本産業規格 (JIS) でも規格化されている。\n>\n> * ITU-T勧告 T.81\n> ... | 61346 | 61350 | 61350 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Pythonの初心者です。 \nAzureのFace APIを使って、人物画像から感情を数値化するサンプルプログラムを実行しているのですが、エラーが出てしまっています。\n\n以下がエラーの抜粋となります。\n\n```\n\n File \"emotion_2.py\", line 65, in <module>\n top = x['faceRectangle']['top']\n TypeError: string indices must be integers\n \n```\n\nソースコード(抜粋)\n\n```\n\n def emotion(image):\n headers = {\n # Request headers\n 'Content-Type': 'application/octet-stream',\n 'Ocp-Apim-Subscription-Key': 'apiの取得Key',\n }\n \n params = urllib.parse.urlencode({\n })\n \n```\n\n```\n\n img = '人物画像のパス' \n \n data = open(img,'br')\n a = emotion(data)\n json_dict = json.loads(a)\n print(json.dumps(json_dict, sort_keys=True, indent=1))\n print(\"main Start!!\")\n for x in json_dict:\n top = x['faceRectangle']['top']\n left = x['faceRectangle']['left']\n width = x['faceRectangle']['width']\n height = x['faceRectangle']['height']\n \n anger = x['scores']['anger']\n contempt = x['scores']['contempt']\n disgust = x['scores']['disgust']\n fear = x['scores']['fear']\n happiness = x['scores']['happiness']\n neutral = x['scores']['neutral']\n sadness = x['scores']['sadness']\n surprise = x['scores']['surprise']\n \n```\n\n幾らか同様のエラーについて検索したのですが、文字列に変更? \nしてしまっていると。 \nしかしそれらを見ても自分ではあまり理解できておりません。 \nどうかご教示いただきますよう、お願いいたします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T14:46:08.113",
"favorite_count": 0,
"id": "61348",
"last_activity_date": "2019-12-11T14:48:42.710",
"last_edit_date": "2019-12-11T14:48:42.710",
"last_editor_user_id": "19110",
"owner_user_id": "37034",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"json",
"api",
"windows-10"
],
"title": "Python TypeError: string indices must be integers エラーについて",
"view_count": 5466
} | [] | 61348 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Python pandasでテーブル解析しましたが、どのサイトでも行数がサイト通りに解析できません。\n\n以下、コードです。\n\n```\n\n import pandas as pd\n url = 'https://weather.time-j.net/'\n dfs = pd.read_html(url)\n print(dfs[1].head())\n \n```\n\n結果です。\n\n都市名 今日の最高気温 最高気温の平年値 今季の昨日までの記録 \n都市名 今日の最高気温 最高気温の平年値 日最高気温の最低 起日 真冬日の日数 \n0 札幌 8.8℃ 2.5℃ -3.0℃ 12月4日 5日 \n1 仙台 16.2℃ 8.9℃ 5.3℃ 12月5日 0日 \n2 東京 15.3℃ 12.5℃ 7.1℃ 12月7日 0日 \n3 名古屋 15.7℃ 12.2℃ 8.0℃ 12月7日 0日 \n4 新潟 14.8℃ 9.3℃ 6.2℃ 12月6日 0日",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T15:14:58.743",
"favorite_count": 0,
"id": "61349",
"last_activity_date": "2019-12-12T02:35:18.973",
"last_edit_date": "2019-12-12T02:35:18.973",
"last_editor_user_id": "19110",
"owner_user_id": "37033",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pandas"
],
"title": "python Pandasで、テーブル解析後、行数が足りません。",
"view_count": 174
} | [
{
"body": "```\n\n df = dfs[1].loc[2:,:]\n df.columns = ['都市名', '昨日の最高気温', '最高気温の平年値','日最高気温の最低', '起日','真冬日の日数']\n \n```\n\nでいかがでしょうか。 \n一行目のプログラムでデータフレームのデータ部分(3行目以降)のみ抽出、 \n二行目のプログラムで列名を再定義しております。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-11T17:2... | 61349 | null | 61352 |
{
"accepted_answer_id": "61358",
"answer_count": 1,
"body": "他のURLを見て自己解決したのですが、知識共有のため投稿します。\n\n私自身の以下リンクの質問内容に関連しています。 \n親のダイアログから新しくTK()インスタンスを生成してカスタムメッセージボックスを作っています。 \nこのダイアログにPILモジュールのPhotoImageメソッドで任意の画像を扱おうとすると、このようなエラーが表示されます。\n\n```\n\n _tkinter.TclError: image \"pyimage##\" doesn't exist\n \n```\n\n[Python\nTkでカスタムメッセージボックスを作りたい](https://ja.stackoverflow.com/questions/61331/python-\ntk%E3%81%A7%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%E3%83%9C%E3%83%83%E3%82%AF%E3%82%B9%E3%82%92%E4%BD%9C%E3%82%8A%E3%81%9F%E3%81%84/61340#61340)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T02:05:06.543",
"favorite_count": 0,
"id": "61357",
"last_activity_date": "2019-12-12T02:05:06.543",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "32891",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"画像",
"tkinter"
],
"title": "Python tk 複数のTK()インスタンスで画像を扱う方法",
"view_count": 1428
} | [
{
"body": "この問題は、参考URLに記載のある通りですが、 \nPhotoImageメソッドが最初に生成されたTk()インスタンスに対して、画像を生成するために発生するということです。 \nPhotoImageメソッドのmsaterオプションで、インタンスを明示的に指定することで解決しました。\n\n```\n\n root = Tk()\n img = PhotoImage(temp_img,master = root)\n \n```\n\n参考のURLはこちら \n[Python+Tkinterの複数ウィンドウ生成時エラー](https://teratail.com/quest... | 61357 | 61358 | 61358 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "緊急で人が書いたHTMLを修正しなければならないのですが、私は仕様も技術的背景も知りません。 \nこの時点で褒められた仕事のやり方ではないと思いますが、そこはとりあえずスルーでお願いします。\n\nHTMLには\n\n```\n\n <button>foo</button>\n \n```\n\nというボタンがあり、このボタンが何もしていないというのが問題になっています。 \nとりあえずgoogle.comというサイトに飛べばいいとして、\n\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta charset=\"utf-8\">\n <title>テスト</title>\n </HEAD> \n <BODY>\n <button type=\"button\" onclick=\"location.href='https://google.com'\">ボタンテスト</button>\n </BODY>\n </HTML>\n \n```\n\nというHTMLを作り、これは同じサーバー、同じディレクトリ、同じブラウザーできちんと動作することを確認しました。 \nしかし、動かないボタンがあるHTMLに\n\n```\n\n <button type=\"button\" onclick=\"location.href='https://google.com'\">ボタンテスト</button>\n \n```\n\nを追加すると、ボタン[ボタンテスト]は表示し、マウスをホバーするとカーソルが指の形になるのですが、クリックしてもジャンプが起こりません。\n\ncssをbutton、btnという文字列で検索しましたがはかばかしいヒントは得られませんでした。 \nどこかでonclickが抑制されていると思うのですが、どこをどう変えれば動作するでしょうか。 \n(私が変更したボタンの部分だけでその制限が解除されるとかだと最もうれしいです)\n\nよろしくお願いします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T02:37:01.607",
"favorite_count": 0,
"id": "61361",
"last_activity_date": "2021-02-23T10:04:20.443",
"last_edit_date": "2019-12-12T11:24:05.847",
"last_editor_user_id": "32986",
"owner_user_id": "26673",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"html"
],
"title": "HTMLのbuttonタグでonclick属性が効かない",
"view_count": 10346
} | [
{
"body": "お世話になります。こういうことだったらしいです。 \n問題の画面は、以下のような構成でした。\n\n```\n\n 【表題】\n 文章・・・\n 文章・・・\n <ボタン>\n \n```\n\nこの表題および文章は、HTMLの別の場所にあるUIによって切り替わり、長さも可変です。\n\n```\n\n 【表題】\n 文章・・・\n 文章・・・\n 文章・・・\n 文章・・・\n <ボタン>\n \n```\n\nで、表題/文章の部分は、すべて重ね合わせて表示されており、切り替えのUIによってアクティブなものは... | 61361 | null | 61500 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "[](https://i.stack.imgur.com/8s0cH.png)\n\n## 実現したいこと\n\n画像を投稿できる機能を実装しているのですが、 \nそのフォームに対して添付写真のエラーが出てしまいます。\n\n## 発生している問題\n\n画像なしでの投稿時にエラーが発生。 \ngetClientOriginalName()on nul\n\n## 試したこと\n\ngetClientOriginalName()on nulがエラーの原因のため、 \n一度削除してみたがその場合、テーブルにランダムな文字列で画像が保存されてしまうようになった。 \ngetClientOriginalNameがnullでも通る方法を検索したが、解決できず。\n\n足りないファイル等ございましたら、ご指摘いただけると幸いです。 \nご教授宜しくお願いいたします",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T03:46:23.780",
"favorite_count": 0,
"id": "61362",
"last_activity_date": "2019-12-12T03:46:23.780",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36914",
"post_type": "question",
"score": 0,
"tags": [
"php",
"laravel"
],
"title": "laravelのバリデーションにてエラーが発生",
"view_count": 130
} | [] | 61362 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "下記のサイトを参考にIBMQiskitのチュートリアルを動かしています。 \nソース自体は何も変更していません。 \n<https://github.com/qulacs/quantum-native-\ndojo/blob/933f701ecf07ee2d3360be2af70fe7a7c46926c1/notebooks/3.2_Qiskit_IBMQ.ipynb>\n\nGoogle colabで実行しているのですが、実行後に下記の部分でエラーが出ます。\n\n**ソースコード**\n\n```\n\n #least busyだったbackendを選ぶ\n backend_sim = backend_lb\n \n #量子回路qcを指定したバックエンド(backend_sim)で4096回実行する。\n result = execute(qc, backend_sim, shots=4096).result()\n \n```\n\n**エラーメッセージ**\n\n```\n\n TranspilerError: 'Number of qubits (2) in circuit0 is greater than maximum (1) in the coupling_map'\n \n```\n\nこのエラーの解決方法が分かりません、教えていただけないでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T05:48:22.290",
"favorite_count": 0,
"id": "61365",
"last_activity_date": "2020-11-03T10:26:18.080",
"last_edit_date": "2020-11-03T10:26:18.080",
"last_editor_user_id": null,
"owner_user_id": "37042",
"post_type": "question",
"score": 0,
"tags": [
"python",
"quantum-computing"
],
"title": "IBM、Qiskitに関して",
"view_count": 218
} | [
{
"body": "こちらで試してみると、同じエラーが発生します。その際の `backend_lb` は `ibmq_armonk` になります。\n\n```\n\n >>> backend_lb = least_busy(provider.backends(simulator=False, operational=True))\n >>> backend_lb\n <IBMQBackend('ibmq_armonk') from IBMQ(hub='ibm-q', group='open', project='main')>\n \n```\n\n`ibmq_armonk` の qubi... | 61365 | null | 61381 |
{
"accepted_answer_id": "61369",
"answer_count": 1,
"body": "jsファイルで、\n\n```\n\n //= require some.js\n \n```\n\nのようにjsファイルをrequireしているのを見つけたのですが、\n\n```\n\n var a = require('some.js') \n \n```\n\nの違いがわかりません。\n\n`//= require` でググっても記事が出てこないので困っています。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T05:58:22.693",
"favorite_count": 0,
"id": "61366",
"last_activity_date": "2019-12-12T09:38:28.637",
"last_edit_date": "2019-12-12T09:38:28.637",
"last_editor_user_id": "32986",
"owner_user_id": "36541",
"post_type": "question",
"score": 2,
"tags": [
"javascript",
"ruby-on-rails"
],
"title": "//= require と requireの違いがわかりません",
"view_count": 126
} | [
{
"body": "コメントアウトの方は Rails のアセットパイプラインの記法ですね。\n\n設定次第ですがデフォルトだと\n\n本番環境で1ファイルに結合してくれる \n本番環境で難読化してくれる \n他のファイルで同じものを require しても重複しない\n\nと言った違いがあります",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T06:42:55.050",
"id": "61369",
"last_activity_date": "2... | 61366 | 61369 | 61369 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "### 行いたいこと\n\njavaを用いて動画データ(.MOV)を画像ファイルに分けたいです. \nIDEはEclipseを使っています.\n\nお願いします.",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T06:04:44.553",
"favorite_count": 0,
"id": "61368",
"last_activity_date": "2019-12-13T03:10:18.527",
"last_edit_date": "2019-12-13T03:10:18.527",
"last_editor_user_id": "3060",
"owner_user_id": "36671",
"post_type": "question",
"score": 0,
"tags": [
"java",
"opencv"
],
"title": "javaプログラムで動画を画像データに分けたい",
"view_count": 276
} | [] | 61368 | null | null |
{
"accepted_answer_id": null,
"answer_count": 4,
"body": "テキストファイルの内容を読み込み、フォーマットを変更して別のファイルに出力したいです。\n\n下記のコードで全文の読み込みと新しいテキストファイルへの書き込みまではできるようになったのですが、フォーマットを変えるにはどのようなコードを書けばいいのでしょうか?\n\n* * *\n\n**元のテキストファイル**\n\n```\n\n 116\n 11/2/2012 18:22\n N9 45.483 E10 30.495\n 416 m\n 117\n 11/2/2012 18:22\n N9 45.483 E10 30.495\n 415 m\n \n```\n\n**書き換え後のテキストファイル**\n\n```\n\n 116,11/2/2012 18:22,N9 45.483 E10 30.495,416 m\n 117,11/2/2012 18:22,N9 45.483 E10 30.495,415 m\n \n```\n\n**ソースコード**\n\n```\n\n using System;\n using System.Collections.Generic;\n using System.Linq;\n using System.Text;\n using System.Threading.Tasks;\n using System.IO;\n \n namespace Reading_textfile\n {\n class Program\n {\n static void Main(string[] args)\n {\n string filePath = @\"C:\\Users\\ryuma\\Downloads\\Elephantread.txt\";\n \n //string[] Lines = File.ReadAllLines(filePath);\n \n List<string> lines = new List<string>();\n lines = File.ReadAllLines(filePath).ToList();\n \n foreach (String line in lines)\n {\n Console.WriteLine(line);\n }\n \n string filePath2 = @\"C:\\Users\\ryuma\\OneDrive\\Desktop\\WriteFile.txt\";\n File.WriteAllLines(filePath2, lines);\n Console.ReadLine();\n }\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T07:03:01.277",
"favorite_count": 0,
"id": "61370",
"last_activity_date": "2020-02-29T05:01:10.093",
"last_edit_date": "2019-12-12T08:30:17.013",
"last_editor_user_id": "76",
"owner_user_id": "37030",
"post_type": "question",
"score": 0,
"tags": [
"c#"
],
"title": "テキストファイルの読み込みと書き込み",
"view_count": 720
} | [
{
"body": "単に変換するだけなら、`List<string>`よりも`string[]`を使った方がメソッド呼び出しが減って良さそうです。 \nこれを:\n\n```\n\n List<string> lines = new List<string>();\n lines = File.ReadAllLines(filePath).ToList();\n \n```\n\nこうします:\n\n```\n\n string[] lines = File.ReadAllLines(filePath);\n char[] nl = { '\\n' };\n lines = s... | 61370 | null | 61372 |
{
"accepted_answer_id": "63085",
"answer_count": 1,
"body": "Macでsqlite3の勉強をしている者です。\n\niTerm2でsqlite3を使っている時にselect文で条件として日本語を入力しようとしたらエンターキーを押すと消えてしまいます。原因に心当たりがある方、教えて頂きたいです。\n\nちなみにiTerm2でsqlite3を使っていない時は日本語も入力できます。\n\niTerm2でのlocaleの出力結果は以下です。\n\n```\n\n LANG=\"ja_JP.UTF-8\"\n LC_COLLATE=\"ja_JP.UTF-8\"\n LC_CTYPE=\"ja_JP.UTF-8\"\n LC_MESSAGES=\"ja_JP.UTF-8\"\n LC_MONETARY=\"ja_JP.UTF-8\"\n LC_NUMERIC=\"ja_JP.UTF-8\"\n LC_TIME=\"ja_JP.UTF-8\"\n LC_ALL=\n \n```\n\nよろしくお願いします。\n\n実行環境は以下です。\n\nProductName: Mac OS X \nProductVersion: 10.15.1 \nBuildVersion: 19B88",
"comment_count": 12,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T09:15:31.073",
"favorite_count": 0,
"id": "61376",
"last_activity_date": "2020-02-16T06:52:01.037",
"last_edit_date": "2019-12-12T11:24:50.483",
"last_editor_user_id": "36888",
"owner_user_id": "36888",
"post_type": "question",
"score": 1,
"tags": [
"macos",
"sqlite",
"日本語"
],
"title": "Macでのsqlite3の操作時に日本語入力ができない。",
"view_count": 911
} | [
{
"body": "Mac にanaconda をインストールされていませんでしょうか? コマンドパスが anaconda のsqlite3\nになっている場合、日本語入力ができないようです。私の場合、パス設定を/usr/bin/sqlite3 に変えることで、MacOS 10.14\nでも日本語入力ができました。下記のサイトを参考にしました。 \n<https://www.u.tsukuba.ac.jp/ufaqs/sqlite3/>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "20... | 61376 | 63085 | 63085 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、私はインタフェース2019年1月号を元にultra96でハードウェアアクセラレーションを試しています。ultra96にvivadohlsで作成した行列演算IPを組み込みYOLOv3を実行しました。すると、bus\nerrorが起こりました。書いてある通りの手順でやっていたので出来ずに困っています。また、行列乗算をPLで実行するテストプログラムは動きました。\n\n```\n\n ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg\n layer filters size input output\n 0 conv 32 3 x 3 / 1 608 x 608 x 3 -> 608 x 608 x 32 0.639 BFLOPs\n 1 conv 64 3 x 3 / 2 608 x 608 x 32 -> 304 x 304 x 64 3.407 BFLOPs\n 2 conv 32 1 x 1 / 1 304 x 304 x 64 -> 304 x 304 x 32 0.379 BFLOPs\n 3 conv 64 3 x 3 / 1 304 x 304 x 32 -> 304 x 304 x 64 3.407 BFLOPs\n 中略\n 104 conv 256 3 x 3 / 1 76 x 76 x 128 -> 76 x 76 x 256 3.407 BFLOPs\n 105 conv 255 1 x 1 / 1 76 x 76 x 256 -> 76 x 76 x 255 0.754 BFLOPs\n 106 yolo\n Loading weights from yolov3.weights...Done!\n Bus error\n \n```\n\nフロー \n1.xilinxアプリケーションノートXAPP1170にあるソースコード(行列演算)をultra96用に編集しVivadoHLSでロジック回路を生成。\n\n2.作成したロジック回路をvivadoでArm FPGA(Zynq UltraScale+MPSoC)に組み込み、GenerateBitstream →\nExportHardware \n[](https://i.stack.imgur.com/95LCa.png) \n3.Vivadoから出たファイルをpetalinuxツールでビルド。その際にultra96上から作成した回路にUIOでアクセスするためにデバイスツリー定義ファイルにgeneric-\nuioを記述。また、AXIDMAはシンプルDMAモードにしているおり、LinuxからDMA転送するためにDMAバッファのデバイスドライバudmabufを利用した。petalinuxツールでc記述テンプレートを作成し、githubからダウンロードしたudmabuf.cと差し替えた。\n\n4.ultra96を起動すると/dev/uio1とuio2が生成されている。uio1が行列乗算IP,uio2がAXIDMAが割り当てられている。insmod\nudmabuf.ko udmabuf0=1048576 udmabuf1=1048576でバッファサイズの指定をする。\n\n5.darknetのソースコードとyolov3学習済みデータをダウンロードし、コンパイル。画像認識の実行をすると成功しました。\n\n6.シンプルDMAプログラムのヘッダファイル(dma_simple.h),シンプルDMAプログラム本体(dma_simple.c)、行列乗算IPの動作プログラム(matrix.c)をgccでコンパイルして実行するとソフトウェアで実行した結果と行列乗算IPで処理した結果は一致した。\n\n7.yolov3で行列乗算IPを使用するため、src/convolutional_layer.c ,\nexample/detector.c,include/darknet.hを変更した。またMakeFileを変更してdma_simple.h,dma_simple.cを追加してコンパイルする。 \n8.yolov3を実行すると上記のbus errorが出る。\n\nといった流れになります。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T09:29:30.067",
"favorite_count": 0,
"id": "61377",
"last_activity_date": "2019-12-13T04:47:55.737",
"last_edit_date": "2019-12-13T04:47:55.737",
"last_editor_user_id": "31304",
"owner_user_id": "31304",
"post_type": "question",
"score": 1,
"tags": [
"fpga",
"vivado"
],
"title": "YOLOv3でのbus error",
"view_count": 276
} | [] | 61377 | null | null |
{
"accepted_answer_id": "61380",
"answer_count": 1,
"body": "こちらの文章で文字の一部だけ黒く塗りつぶしておきたいのですが、何か方法はありますでしょうか。 \njqueryをつかった方法はありましたが、できればcssだけでやりたいと思っています。\n\n```\n\n <p>アリスは川辺でおねえさんのよこにすわって、なんにもすることがないのでとても退屈(たいくつ)しはじめていました。一、二回はおねえさんの読んでいる本をのぞいてみたけれど、そこには絵も会話もないのです。</p>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T09:56:03.950",
"favorite_count": 0,
"id": "61378",
"last_activity_date": "2019-12-12T10:41:14.510",
"last_edit_date": "2019-12-12T10:01:14.480",
"last_editor_user_id": "32986",
"owner_user_id": "37046",
"post_type": "question",
"score": 3,
"tags": [
"css"
],
"title": "文章の一部を黒く塗りつぶしたい",
"view_count": 129
} | [
{
"body": "テキストの任意の箇所を選択するセレクタは、 CSS に用意されていません。そのため、装飾を適用したい箇所へ適当な要素へ入れておく必要があります。\n\n文字色が黒の場合、単純に `background` プロパティと `user-select` プロパティを指定することで実現出来ます。\n\n```\n\n .marker {\r\n user-select: none;\r\n background: #000;\r\n }\n```\n\n```\n\n <p>アリスは川辺でおねえさんの<span class=\"marker\">よこ</span>にすわっ... | 61378 | 61380 | 61380 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "複数のメソッドからプロパティを操作したいのですがappendメソッドで値を追加するとメモリリークが発生します。\n\n以下は簡素化したコードです。\n\n```\n\n import Cocoa\n \n class ViewController: NSViewController {\n private var values: [Int] = []\n \n private func calc(count: Int) {\n for i in 0 ..< count {\n values.append(i)\n print(\"i = \\(values[i])\")\n }\n }\n \n override func viewDidLoad() {\n super.viewDidLoad()\n calc(count: 5)\n }\n \n override var representedObject: Any? {\n didSet {\n // Update the view, if already loaded.\n }\n }\n }\n \n```\n\nこれでメモリリークが発生する理由がわかりません。 \n何かコードが間違っているのでしょうか?\n\nXcode11.3です。バージョンアップ以前から同じところで悩んでいます。\n\nどなたかお教え願えないでしょうか?\n\n[](https://i.stack.imgur.com/J71VQ.png) \n[](https://i.stack.imgur.com/6d7aq.png)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-12T11:00:50.353",
"favorite_count": 0,
"id": "61382",
"last_activity_date": "2019-12-12T11:00:50.353",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31612",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"macos"
],
"title": "プロパティで初期化した配列にメソッドから値を追加するとメモリリークが発生する",
"view_count": 123
} | [] | 61382 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.