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": "sshの仮想環境で作業しています。 (sshを抜けた一番最初の環境では migrateもmakemigrationもできている状態です。) \npython 3.6.8 \npip 21.3.1 \nvirtualenvを使用しています。 \npostgresqlにて、roleとdetabaseもcreateしています。 \nDJANGO_SETTINGS_MODULES=microblog.settings.prod \nでモジュールも指定先としてsshに接続するたびに設定しています。\n\n学習サイトを用いたサイト作成でデプロイをしようとしています。 \n他のサイト検索では settings.py に全て記述していますが、settings.pyを settings\nという新しいフォルダを作成し、以下4つのファイルに分割している状態です。\n\n```\n\n dev.py\n heroku.py\n prod.py\n common.py\n \n```\n\n現在詰まっているのが、環境構築の部分で migrate できないという状態です。\n\nprod.py, common.py がデータベース設計の部分になっております。\n\nprod.py\n\n```\n\n from .common import *\n \n # SECURITY WARNING: don't run with debug turned on in production!\n DEBUG = False\n \n ALLOWED_HOSTS = ['*', ]\n \n INSTALLED_APPS += (\n 'gunicorn',\n )\n \n # Database\n # https://docs.djangoproject.com/en/3.2/ref/settings/#databases\n \n DATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.postgresql_psycopg2',\n 'NAME': 'データベース名',\n 'USER': 'データベース名と同じ',\n 'PASSWORD': 'データベース名と同じ',\n }\n }\n \n```\n\ncommon.py\n\n```\n\n \"\"\"\n Django settings for microblog project.\n \n Generated by 'django-admin startproject' using Django 3.2.8.\n \n For more information on this file, see\n https://docs.djangoproject.com/en/3.2/topics/settings/\n \n For the full list of settings and their values, see\n https://docs.djangoproject.com/en/3.2/ref/settings/\n \"\"\"\n \n import os\n \n # Build paths inside the project like this: BASE_DIR / 'subdir'.\n BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n print(BASE_DIR)\n \n \n # Quick-start development settings - unsuitable for production\n # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/\n \n # SECURITY WARNING: keep the secret key used in production secret!\n SECRET_KEY = シークレットなので日本語\n \n \n \n DATABASES = {}\n \n # Application definition\n \n INSTALLED_APPS = [\n 'django.contrib.admin',\n 'django.contrib.auth',\n 'django.contrib.contenttypes',\n 'django.contrib.sessions',\n 'django.contrib.messages',\n 'django.contrib.staticfiles',\n \n 'blog',\n ]\n \n MIDDLEWARE = [\n 'django.middleware.security.SecurityMiddleware',\n 'django.contrib.sessions.middleware.SessionMiddleware',\n 'django.middleware.common.CommonMiddleware',\n 'django.middleware.csrf.CsrfViewMiddleware',\n 'django.contrib.auth.middleware.AuthenticationMiddleware',\n 'django.contrib.messages.middleware.MessageMiddleware',\n 'django.middleware.clickjacking.XFrameOptionsMiddleware',\n ]\n \n ROOT_URLCONF = 'microblog.urls'\n \n TEMPLATES = [\n {\n 'BACKEND': 'django.template.backends.django.DjangoTemplates',\n 'DIRS': [\n os.path.normpath(os.path.join(BASE_DIR, \"templates\")),\n ],\n 'APP_DIRS': True, # False -> True\n 'OPTIONS': {\n 'context_processors': [\n 'django.template.context_processors.debug',\n 'django.template.context_processors.request',\n 'django.contrib.auth.context_processors.auth',\n 'django.contrib.messages.context_processors.messages',\n ],\n },\n },\n ]\n print(os.path.normpath(os.path.join(BASE_DIR, \"templates\")))\n \n WSGI_APPLICATION = 'microblog.wsgi.application'\n \n # Password validation\n # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators\n \n AUTH_PASSWORD_VALIDATORS = [\n {\n 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',\n },\n {\n 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',\n },\n {\n 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',\n },\n {\n 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',\n },\n ]\n \n \n # Internationalization\n # https://docs.djangoproject.com/en/2.0/topics/i18n/\n \n LANGUAGE_CODE = 'ja'\n \n TIME_ZONE = 'UTC'\n \n USE_I18N = True\n \n USE_L10N = True\n \n USE_TZ = True\n \n # Static files (CSS, JavaScript, Images)\n # https://docs.djangoproject.com/en/2.0/howto/static-files/\n \n STATIC_URL = '/static/'\n STATICFILES_DIRS = (\n # mac / : windows ¥\n os.path.normpath(os.path.join(BASE_DIR, \"assets\")),\n )\n STATIC_ROOT = os.path.normpath(os.path.join(BASE_DIR, \"static\"))\n \n LOGIN_REDIRECT_URL = '/'\n \n```\n\nこの二つは \n/opt/django/microblog/microblog0/microblog/settings/prod.py \nの階層にあり、 \nmanage.pyは、/opt/django/microblog/microblog0 \nの場所にある状態です。\n\nこの設定で `pip freeze` コマンドでは\n\n```\n\n asgiref==3.4.1\n Django==3.2.9\n psycopg2-binary==2.9.1\n pytz==2021.3\n sqlparse==0.4.2\n typing-extensions==3.10.0.2\n \n```\n\n以上の設定がinstallされています。\n\nその状態で `python3 manage.py migrate` をすると\n\n```\n\n raise ImproperlyConfigured(\"settings.DATABASES is improperly configured. \"\n django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.\n \n```\n\nというエラーが起き、一応\npsycopg2-binaryがちゃんとinstallできていないからではと提案されたのですが、uninstallし、installしなおしても同じ状態で詰まっています。\n\nもし同じような状況になったことがある方がいらっしゃいましたら教えていただきたいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-01T14:21:00.977",
"favorite_count": 0,
"id": "83380",
"last_activity_date": "2021-11-02T02:02:24.803",
"last_edit_date": "2021-11-01T16:29:18.097",
"last_editor_user_id": "3060",
"owner_user_id": "48908",
"post_type": "question",
"score": 0,
"tags": [
"python",
"django",
"デプロイ"
],
"title": "ssh環境での python manage.py migrateのエラー",
"view_count": 155
} | [
{
"body": "結論から言うと、python manage.py migrateは実行できましたが。なぜ行けたのかの理由がわかりません。\n\nCentOS7を一度保存状態で切ってsshが切断されます、再度CentOS7を起動し直しました。 \nその後、sshで入り、仮想環境にいき\n\npython manage.py migrateをすると\n\n```\n\n ModuleNotFoundError: No module named 'gunicorn'\n \n```\n\nが出ており、前回のエラーとは違います。 \n前回は\n\n```\n\n django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. \n \n```\n\nそして、VScodeでModuleNotFoundErrorとなっていた部分,prod.py\n\n```\n\n INSTALLED_APPS += (\n 'gunicorn',\n )\n \n```\n\nこちらを削除し、source treeで\n\n```\n\n commit\n \n push\n \n \n 以下ターミナルで\n \n git pull\n \n sudo systemctl restart postgresql\n \n python manage.py migrate\n \n```\n\nこれでmigrateが実行されました。\n\nしかし、prod.pyにgunicornの設定をしていない状態で、初めはやっており、その状態で\n\n```\n\n python manage.py migrateをすると\n \n django.core.exceptions 〜〜 のエラーが起き\n \n gunicornを足しても、\n django.core.exceptions ~~ のエラーが起きたため\n \n \n```\n\nなぜ、sshを接続し直し、exportを設定した後にmigrateをすると \nエラー内容が変わり、そこを修正するだけで、migrateが通ったのかの理由がわかりませんでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T02:02:24.803",
"id": "83383",
"last_activity_date": "2021-11-02T02:02:24.803",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48908",
"parent_id": "83380",
"post_type": "answer",
"score": 0
}
] | 83380 | null | 83383 |
{
"accepted_answer_id": "83450",
"answer_count": 2,
"body": "## やりたいこと\n\n* * *\n\nパスワードとパスワード確認の入力文字列をアイコンのクリックで表示非表示を切り替えたいです。 \n下記のサイトを参考にして試みているのですがうまくいきません。 \n[Login form with password show and hide button using\nJavaScript](https://bootstrapfriendly.com/blog/login-form-with-password-show-\nand-hide-button-using-javascript/) \n何がおかしいのかよくわからず、困っています。アドバイスいただければ有難いです。\n\n## 現状\n\n* * *\n\n`gemfile`です\n\n```\n\n source 'https://rubygems.org'\n git_source(:github) { |repo| \"https://github.com/#{repo}.git\" }\n \n ruby '2.7.4'\n \n gem 'active_storage_validations', '0.8.2'\n gem 'bcrypt', '3.1.13'\n gem 'bootsnap', '1.4.5', require: false\n gem 'bootstrap', '~> 4.6.0'\n \n gem 'faker'\n gem 'image_processing', '1.9.3'\n gem 'jbuilder', '2.9.1'\n gem 'jquery-rails'\n gem 'kaminari'\n gem 'mini_magick', '4.9.5'\n gem 'puma', '4.3.6'\n gem 'rails', '6.0.3'\n gem 'rails-i18n'\n gem 'sass-rails', '5.1.0'\n gem 'sprockets-rails', '~> 3.2.2'\n gem 'turbolinks', '5.2.0'\n gem 'uglifier'\n gem 'webpacker', '~> 5.0'\n \n group :development, :test do\n gem 'byebug', '11.0.1', platforms: [:mri, :mingw, :x64_mingw]\n gem 'factory_bot_rails'\n gem 'pry-byebug'\n gem 'pry-doc'\n gem 'pry-rails'\n gem 'rails-controller-testing', '1.0.4'\n gem 'rspec-rails'\n gem 'shoulda-matchers'\n gem 'spring-commands-rspec'\n gem 'sqlite3', '1.4.2'\n end\n \n group :development do\n gem 'better_errors'\n gem 'binding_of_caller'\n gem 'listen', '3.1.5'\n gem 'spring', '2.1.0'\n gem 'spring-watcher-listen', '2.0.1'\n gem 'web-console', '4.0.1'\n end\n \n group :test do\n gem 'capybara', '3.28.0'\n gem 'database_cleaner'\n gem 'launchy'\n gem 'selenium-webdriver', '3.142.4'\n gem 'webdrivers', '4.1.2'\n end\n \n```\n\nviewの`form.html.erb`の一部です\n\n```\n\n <%= f.label :password, \"パスワード\" %>\n <div class=\"input-group mb-3\">\n <div class=\"input-group-prepend\">\n <span class=\"input-group-text\" id=\"basic-addon1\"><i class=\"fas fa-lock\"></i></span>\n </div>\n <%= f.password_field :password, class: 'form-control' %>\n <div class=\"input-group-append\">\n <span class=\"input-group-text\" onclick=\"password_show_hide();\">\n <i class=\"far fa-lightbulb\" id=\"light_bulb\"></i>\n <i class=\"fas fa-lightbulb d-none\" id=\"unlight_bulb\"></i>\n </span>\n </div>\n </div>\n \n \n <%= f.label :password_confirmation, \"パスワード 確認\" %>\n <div class=\"input-group mb-3\">\n <div class=\"input-group-prepend\">\n <span class=\"input-group-text\" id=\"basic-addon1\"><i class=\"fas fa-lock\"></i></span>\n </div>\n <%= f.password_field :password_confirmation, class: 'form-control' %>\n <div class=\"input-group-append\">\n <span class=\"input-group-text\" onclick=\"password_confirmation_show_hide();\">\n <i class=\"far fa-lightbulb\" id=\"light_bulb2\"></i>\n <i class=\"fas fa-lightbulb d-none\" id=\"unlight_bulb2\"></i>\n </span>\n </div>\n </div> \n \n```\n\njavascriptファイルです。 \napp/javascript/packs/custom/password_show.js\n\n```\n\n $(function password_show_hide() {\n var x = document.getElementById(\"user_password\");\n var light_bulb = document.getElementById(\"light_bulb\");\n var unlight_bulb = document.getElementById(\"unlight_bulb\");\n unlight_bulb.classList.remove(\"d-none\");\n if (x.type === \"password\") {\n x.type = \"text\";\n light_bulb.style.display = \"none\";\n unlight_bulb.style.display = \"block\";\n } else {\n x.type = \"password\";\n light_bulb.style.display = \"block\";\n unlight_bulb.style.display = \"none\";\n }\n });\n \n $(function password_confirmation_show_hide() {\n var y = document.getElementById(\"user_password_confirmation\");\n var light_bulb2 = document.getElementById(\"light_bulb2\");\n var unlight_bulb2 = document.getElementById(\"unlight_bulb2\");\n unlight_bulb2.classList.remove(\"d-none\");\n if (y.type === \"password_confirmation\") {\n y.type = \"text\";\n light_bulb2.style.display = \"none\";\n unlight_bulb2.style.display = \"block\";\n } else {\n y.type = \"password\";\n light_bulb2.style.display = \"block\";\n unlight_bulb2.style.display = \"none\";\n }\n });\n \n```\n\n`app/javascript/packs/application.js`の中身です\n\n```\n\n require(\"@rails/ujs\").start();\n require(\"turbolinks\").start();\n require(\"@rails/activestorage\").start();\n require(\"channels\");\n require(\"jquery\");\n require(\"@fortawesome/fontawesome-free\");\n \n import \"./custom/password_show.js\";\n \n \n```\n\n何か足りない情報があればご連絡願います。 \nよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T02:51:57.520",
"favorite_count": 0,
"id": "83384",
"last_activity_date": "2021-11-06T05:56:46.273",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48234",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"ruby-on-rails",
"ruby"
],
"title": "rails6 passwordの表示/非表示切り替えについて",
"view_count": 289
} | [
{
"body": "ついこないだ似たような質問したんですが \nonclick= に packs で定義したメソッドを使おうとするとグローバルコンテキストにないとだめなようです\n\n```\n\n globalThis.$ = $; // やってなかったら\n globalThis.password_confirmation_show_hide = password_confirmation_show_hide;\n \n```\n\nみたいなのが必要になるかも\n\n参考: \n[Rails + webpacker における global と window と config/webpack/environment.js\nの違い](https://ja.stackoverflow.com/questions/83118/)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T07:02:04.600",
"id": "83392",
"last_activity_date": "2021-11-02T07:10:34.423",
"last_edit_date": "2021-11-02T07:10:34.423",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "83384",
"post_type": "answer",
"score": 1
},
{
"body": "JavaScriptの使い方自体が色々と間違っています。\n\nまず、関数分を`$( ... );`で囲っていますが、 **これが何をするためのコードであるかを説明できますか?** まずはそこからです。\n\nこの`$(関数)`という書き方はjQueryの機能の一つです。jQueryは`<script\nsrc='jqueyr.js'></script>`のようなに普通に読み込むと`jQuery`と`$`というグローバル変数が定義されます。この二つの変数は同じオブジェクトを指し示しており、それが、jQueryそのものです。jQueryは、それ自体を関数として使ったり、プロパティとして持っている`ajax`等を使ったりします。その使用方法の一つとして、関数を入れるという物があります。\n\n`$(関数)`という書き方は`$(document).ready(関数)`と同じです。これは何を意味しているのかというと、HTMLドキュメント全体の準備が終わった後、つまり、HTMLに直接書かれた全てのDOMにアクセスできるようになった後に、引数にある関数が呼び出されます。HTMLないで`script`タグを使ってJavaScriptを読み込む、または、その部分にそのままJavaScriptを書いて、特に属性をしていなかった場合、そのJavaScriptは書かれているタイミングで実行されます。この時点では、`script`タグの後に何らかのドキュメントが続いていても、そこに書かれているタグ等は読み込まれていません。もし、その後に書かれているタグによって作成されるDOMについて操作がJavaScirptに書かれていた場合、まだ、DOMの準備ができていないため、うまく動作しなくなります。それを防ぐには、DOMに関する操作はドキュメント全体の準備が終わって、必要なDOMが全て作成された後に実行する必要があります。それを簡単に実行できるように用意されたのが、`$(関数)`という書き方なのです。\n\nそれを踏まえて`$(function password_show_hide() { ...\n});`どうなるのかというと、jQueryがちゃんと動いている場合は、ドキュメント全体の準備が終わった後にこの関数の中身が実行されます。`$(function\npassword_confirmation_show_hide() { ...\n});`も同じです。そう、これらは中身が実行されるだけです。なぜなら、`function password_show_hide() { ... }`の部分は\n**関数定義** ではなく、 **関数式** だからです。決して`password_show_hide`という関数を宣言しているわけではありません。\n\n```\n\n function f() {console.log(\"f\");};\n !function g() {console.log(\"g\");};\n f();\n g();\n \n```\n\n上のコードで、`f()`は実行出来ますが、`g()`はエラーになります。なぜなら、1行目は関数宣言なので関数`f`が宣言されていますが、2行目は関数式であるため関数`g`というものは宣下されていないのです。この`g`は何かというと、関数式の名前ではあるのですが、それがコード全体に`g`という名前で関数がありますよと宣言はされていないので、あとから`g()`とやっても呼び出せないのです。JavaScriptの`function`は同じような書き方に見えても、関数宣言となる場合と関数式になる場合があり、それによって、動作が違うと言うことがあります。これはとても注意が必要です。\n\n必要なのは関数宣言でしょうか、関数式でしょうか?実際に参考にしたコードを見てみましょう。`funciton`の前に余計なものは付いていないはずです。実際のルールはもっと複雑なのですが、ほとんどの場合において、`function`の前に何も無ければ関数宣言、何かがあれば関数式です。ということで、`$(\n... )`という余計な物は付けずに、参考にしたコードのようにそのまま書きましょう。(ちょっと待ってください、ここでは終わりでは無いです)\n\nそれでも、うまく動かないはずです。なぜなら、webpackはそれぞねのJavaScriptをmoduleとして扱って名前空間をわけることで、明示的に定義しない限りグローバル変数が定義されなからです。\n\n実は、先程の`$( ...\n)`自体もうまく動いていなかったはずです。なぜなら、jQueryがモジュールとして読み込まれた場合はグローバル変数を定義しないからです。`application.js`ではjqueryを読み込んでいるようですが、これ自体は何もしていないのと同じです。jQueryを使いたいなら次のように書く必要があります。\n\n```\n\n var jQuery = require(\"jquery\");\n var $ = jQuery;\n \n```\n\nこれで`jQuery`や`$`が使えるようになるのですが、その有効範囲は`application.js`の中だけです。`password_show.js`で使いたい場合は、そのファイルに書く必要があります。\n\n話がずれました。結局`$( ...\n);`は必要なかったのでした。jQueryに関するコードは、ひとまず全部削除しておいた方がいいでしょう。余計なエラーを出さないようにするためにもです。\n\n話を戻しますが、関数`password_show_hide`がどこで使われているのかを確認する必要があります。その使われているところで呼び出されればいいわけです。関数は`onclick`の属性値の中のコードで使われていました。このコードで使えるJavaScriptの関数はグローバル変数として定義された関数だけです。つまり、この関数もグローバル変数にする必要があります。\n\nでは、グローバル変数にするにはどうすればいいのか?というと @chico\nさんの回答にあるリンク先を参照すればいいですね(といっても、そちらで回答しているのも私なのですが)。\n\n```\n\n globalThis.password_show_hide = password_show_hide;\n globalThis.password_confirmation_show_hide = password_confirmation_show_hide\n \n```\n\nたぶん、これでうまくいくかと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T05:56:46.273",
"id": "83450",
"last_activity_date": "2021-11-06T05:56:46.273",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7347",
"parent_id": "83384",
"post_type": "answer",
"score": 2
}
] | 83384 | 83450 | 83450 |
{
"accepted_answer_id": "83388",
"answer_count": 1,
"body": "# 環境\n\n * Python3.8\n\n# やりたいこと\n\ndatetimeオブジェクトをISO8601形式の文字列にしたいです。具体的には以下の要件を満たしたいです。\n\n * 末尾が\"Z\"\n * ミリ秒まで出力\n\n以下のように `strftime` 関数を用いて出力すると、マイクロ秒まで出力されてしまいます。\n\n```\n\n import datetime\n dt=datetime.datetime(2021,1,1,2,3,4,123456, tzinfo=datetime.timezone.utc)\n expected = \"2021-01-01T02:03:04.123Z\"\n actual = dt.strftime(\"%Y-%m-%dT%H:%M:%S.%fZ\")\n print(actual)\n # '2021-01-01T02:03:04.123456Z'\n \n```\n\n# 質問\n\n上記の要件を満たす文字列を生成するには、どのように書くのがシンプルでしょうか? \n以下のように書けば要件は満たせますが、文字列操作の部分が分かりづらいと感じています。\n\n```\n\n tmp = dt.isoformat(timespec=\"milliseconds\")\n print(tmp)\n # 2021-01-01T02:03:04.123+00:00\n actual = tmp[0:23] + \"Z\"\n print(actual)\n # 2021-01-01T02:03:04.123Z\n \n```\n\n便利な方法やライブラリがあれば教えていただきたいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T04:38:23.207",
"favorite_count": 0,
"id": "83386",
"last_activity_date": "2021-11-02T05:54:18.727",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19524",
"post_type": "question",
"score": 3,
"tags": [
"python"
],
"title": "datetimeオブジェクトを、ISO8601形式(末尾\"Z\"かつミリ秒まで)の文字列に変換したいです。どのように書くのがシンプルでしょうか?",
"view_count": 1903
} | [
{
"body": "簡単, かもしれない方法\n\n```\n\n print(dt.isoformat(timespec='milliseconds').replace('+00:00', 'Z'))\n \n```\n\n少し面倒かもしれない方法\n\n```\n\n from datetime import tzinfo, timedelta, datetime, timezone\n class TZ(tzinfo):\n def utcoffset(self, dt):\n pass\n def dst(self, dt):\n return timedelta(0)\n \n dt = datetime(2021,1,1,2,3,4,123456, tzinfo=TZ())\n \n \n print('{}Z'.format(dt.isoformat(timespec='milliseconds')))\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T05:54:18.727",
"id": "83388",
"last_activity_date": "2021-11-02T05:54:18.727",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43025",
"parent_id": "83386",
"post_type": "answer",
"score": 2
}
] | 83386 | 83388 | 83388 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "今までプログラミングの経験はなく、今回、pythonを導入しました。使用して1か月も経っていない全くの初心者です。\n\n実行環境は Windows 10, Python 3.9.7\nです。プリンターとして、を使用しています。このプリンターは試してみたところ、専用のアプリなどを入れていなくても、wordなどで書いた文字が印刷できるのは確認しました。\n\nやりたいことは、音声を文字にして紙に印刷するということです。 \n今、わかっている範囲での問題は、音声入力の終了の方法と、入ってきた文章を印刷する方法、そしてこれらの動作を繰り返して、行う方法です。\n\n可能であれば、これらの動作を一環として行えるようにしたいと思っています。 \n何かいい方法は、ないでしょうか。ご教授お願いします。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T06:05:31.493",
"favorite_count": 0,
"id": "83390",
"last_activity_date": "2021-11-03T06:20:59.840",
"last_edit_date": "2021-11-03T06:20:59.840",
"last_editor_user_id": "3060",
"owner_user_id": "48916",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "言葉で話したことがリアルタイムで文字として、印刷されるシステムを作りたい",
"view_count": 165
} | [] | 83390 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "【やりたいこと】 \nGoogle ドライブ <https://drive.google.com/> の左側 [共有ドライブ]\nを押し、そこに表示される共有ドライブの中から特定のドライブを右クリックで表示される [共有ドライブの設定] をAPIで変更したい。\n\n【試したこと】 \nリンクを参考にパラメータの\"DomainUsersOnly\"と”DriveMembersOnly\n\"にtrueとfalseを設定して共有ドライブを作成したが、GUIから確認するとチェックがついたままでかわらなかった。\n\nリンク:https://pkg.go.dev/google.golang.org/[email protected]/drive/v3#DriveRestrictions",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T11:34:53.863",
"favorite_count": 0,
"id": "83395",
"last_activity_date": "2021-11-09T07:26:53.113",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48920",
"post_type": "question",
"score": 0,
"tags": [
"go",
"google-drive-sdk"
],
"title": "golangでGoogleの共有ドライブをGoogle drive api v3でGUI上の「共有ドライブの設定」について変更したい",
"view_count": 112
} | [
{
"body": "update()でパラメータを指定したら変更できました。 \ncreate()時はパラメータが利用できないのかも",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T07:26:53.113",
"id": "83513",
"last_activity_date": "2021-11-09T07:26:53.113",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48920",
"parent_id": "83395",
"post_type": "answer",
"score": 0
}
] | 83395 | null | 83513 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Djangoでユーザーが入力したテキストをDB中に保存して、新規データ登録時にDBから選択肢を呼び出す機能の実装をしようと考えています。models.pyの設定、forms.pyの設定には問題がないと考えているのですが、実際にブラウザで新規登録をテストすると初期値が設定されていないこともありエラー「正しく選択してください。選択したものは候補にありません。」と表示されDBへのデータ保存が出来ません。どのように初期の選択肢をDBに渡しておけばよいでしょうか?\n\nmodels.py\n\n```\n\n import datetime\n from django.db import models\n from django.conf import settings\n \n ITEM_TYPE_CHOICES = [('jacket','上着'),('shirt','シャツ'),('pants','パンツ'),('underpants','下着(下)'),('undershirt','下着(上)'),('socks','靴下'),('others','その他')]\n ITEM_COLOR_CHOICES = [('red','赤'),('blue','青'),('green','緑'),('yellow','黄'),('purple','紫'),('orange','橙'),('black','黒'),('white','白'),('grey','灰'),('beige','ベージュ'),('navy','ネイビー'),('brown','茶'),('others','その他')]\n SEASON_CHOICES = [('spring','春'),('summer','夏'),('fall','秋'),('winter','冬')]\n OCCASION_CHOICES = [('daily_use','普段着'),('work_wear','仕事'),('active_wear','よそ行き'),('sports_wear','スポーツ'),('other_use','その他')]\n FAVORITE_LEVEL_CHOICES = [(1,'めちゃ低い'),(2,'低い'),(3,'普通'),(4,'高い'),(5,'めちゃ高い')]\n ITEM_IMPORTANCE_CHOICES = [(1,'捨てれる'),(2,'悩む'),(3,'普通'),(4,'まあ大事'),(5,'めっちゃ大事')]\n \n \n class ItemType(models.Model):\n user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='ユーザー', on_delete=models.CASCADE, null=True)\n create_date = models.DateTimeField(verbose_name='作成日', auto_now_add=True)\n item_type = models.CharField(verbose_name='アイテム種類', max_length=155, unique=True)\n \n \n class ItemColor(models.Model):\n user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='ユーザー', on_delete=models.CASCADE, null=True)\n create_date = models.DateTimeField(verbose_name='作成日', auto_now_add=True)\n item_color = models.CharField(verbose_name='アイテムカラー', max_length=100, unique=True)\n \n \n class ItemBrand(models.Model):\n user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='ユーザー', on_delete=models.CASCADE, null=True)\n create_date = models.DateTimeField(verbose_name='作成日', auto_now_add=True)\n item_brand = models.CharField(verbose_name='ブランド', max_length=155, unique=True)\n \n \n class PurchasePlace(models.Model):\n user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='ユーザー', on_delete=models.CASCADE, null=True)\n create_date = models.DateTimeField(verbose_name='作成日', auto_now_add=True)\n purchase_place = models.CharField(verbose_name='購入場所', max_length=155, unique=True)\n \n \n class Closet(models.Model):\n user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='ユーザー', on_delete=models.CASCADE, null=True)\n closet_name = models.CharField(verbose_name='クローゼット名', max_length=255)\n closet_memo = models.CharField(verbose_name='クローゼットメモ', max_length=325)\n create_date = models.DateTimeField(verbose_name='クローゼット作成日', auto_now_add=True)\n \n class Meta:\n ordering =['create_date']\n \n def __str_(self):\n return self.closet_name\n \n \n class Item(models.Model):\n user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='ユーザー', on_delete=models.CASCADE, null=True)\n item_type = models.ForeignKey(ItemType, verbose_name='アイテム種類', on_delete=models.CASCADE, null=True, blank=True, db_column='item_type')\n item_color = models.ForeignKey(ItemColor, verbose_name='アイテムカラー', on_delete=models.CASCADE, blank=True, null=True, db_column='item_color')\n item_brand = models.ForeignKey(ItemBrand, verbose_name='ブランド名称', on_delete=models.CASCADE, blank=True, null=True, db_column='item_brand')\n purchase_place = models.ForeignKey(PurchasePlace, verbose_name='購入場所', on_delete=models.CASCADE, blank=True, null=True, db_column='purchase_place')\n item_name = models.CharField(verbose_name='アイテム名称', max_length=300)\n purchase_date = models.DateTimeField(verbose_name='購入日', blank=True, null=True)\n pricing = models.IntegerField(verbose_name='購入価格(円)',)\n item_image = models.ImageField(verbose_name='アイテム画像', upload_to='', blank=True, null=True)\n memo = models.TextField(verbose_name='メモ', blank=True, null=True)\n create_date = models.DateTimeField(verbose_name='アイテム登録日', auto_now_add=True)\n update_date = models.DateTimeField(verbose_name='アイテム更新日', auto_now=True)\n closet = models.ForeignKey(Closet, on_delete=models.PROTECT, blank=True, null=True, default=None)\n season = models.CharField(verbose_name = '季節', max_length=10, choices = SEASON_CHOICES, default='spring')\n occasion = models.CharField(verbose_name = 'シーン', max_length=30, choices = OCCASION_CHOICES, default='daily_use')\n favorite_level = models.IntegerField(verbose_name = 'お気に入り度', choices = FAVORITE_LEVEL_CHOICES, blank=True, null=True, default='1')\n item_importance = models.IntegerField(verbose_name = '大事さ', choices = ITEM_IMPORTANCE_CHOICES, blank=True, null=True, default='1')\n \n class Meta:\n ordering = ['item_name']\n \n def __str__(self):\n return self.item_name\n \n```\n\nforms.py\n\n```\n\n from django import forms\n from django.conf import settings\n \n from .models import ItemType, ItemColor, ItemBrand, PurchasePlace, Closet, Item, FAVORITE_LEVEL_CHOICES, ITEM_IMPORTANCE_CHOICES, SEASON_CHOICES, OCCASION_CHOICES\n \n MONTHS = {\n 1: '1月', 2: '2月', 3: '3月', 4: '4月',\n 5: '5月', 6: '6月', 7: '7月', 8: '8月',\n 9: '9月', 10: '10月', 11: '11月', 12: '12月'\n }\n \n class ClosetForm(forms.ModelForm):\n \n class Meta:\n model = Closet\n fields = ('closet_name', 'closet_memo')\n labels = {'closet_name':'クローゼット名', 'closet_memo':'クローゼットメモ'}\n \n \n class ItemForm(forms.ModelForm):\n item_type = forms.ModelChoiceField(queryset=ItemType.objects.all(), label='アイテム種類', empty_label='選択してください', widget=forms.TextInput)\n item_color = forms.ModelChoiceField(queryset=ItemColor.objects.all(), label='アイテムカラー', empty_label='選択してください', initial='', widget=forms.TextInput)\n item_brand = forms.ModelChoiceField(queryset=ItemBrand.objects.all(), label='ブランド', empty_label='選択してください', initial='', widget=forms.TextInput)\n purchase_place = forms.ModelChoiceField(queryset=PurchasePlace.objects.all(), label='購入場所', empty_label='選択してください', initial='', widget=forms.TextInput)\n \n class Meta:\n model = Item\n \n fields = ('item_type', 'item_color', 'item_brand', 'purchase_place', 'item_name', 'purchase_date', 'pricing', 'item_image',\n 'memo', 'closet', 'season', 'occasion', 'favorite_level', 'item_importance')\n \n labels = {'item_type':'アイテム種類', 'item_color':'アイテムカラー', 'item_brand':'ブランド', 'purchase_place':'購入場所', 'item_name':'アイテム名称', \n 'purchase_date':'購入日', 'pricing':'購入価格(円)', 'item_image':'アイテム画像', 'memo':'メモ', 'closet':'クローゼット', 'season':'季節', 'occasion':'シーン', \n 'favorite_level':'お気に入り度', 'item_importance':'大事さ'}\n \n widget = {\n 'season': forms.RadioSelect(choices=SEASON_CHOICES),\n 'occasion': forms.RadioSelect(choices=OCCASION_CHOICES),\n 'purchase_date': forms.SelectDateWidget(years = [x for x in range(2000,2040)], months = MONTHS),\n 'favorite_level': forms.RadioSelect(choices = FAVORITE_LEVEL_CHOICES ),\n 'item_importance': forms.RadioSelect(choices = ITEM_IMPORTANCE_CHOICES),\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T13:48:57.097",
"favorite_count": 0,
"id": "83397",
"last_activity_date": "2021-11-04T02:56:57.457",
"last_edit_date": "2021-11-02T13:55:27.143",
"last_editor_user_id": "3060",
"owner_user_id": "48922",
"post_type": "question",
"score": 0,
"tags": [
"django"
],
"title": "Django ModelCohiceFieldのDB中への初期値設定の仕方が分かりません",
"view_count": 482
} | [
{
"body": "[Django choices. How to set default\noption?](https://stackoverflow.com/questions/12725720/django-choices-how-to-\nset-default-option)\n\nこれが似たような質問だと思います。 \ndefaultフィールドを使うとできるようですね。\n\n以下のようなキーワードで検索するとヒットしました。 \n「django choice model 初期値」あるいは \n「django choice model default」",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T02:56:57.457",
"id": "83419",
"last_activity_date": "2021-11-04T02:56:57.457",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48687",
"parent_id": "83397",
"post_type": "answer",
"score": 0
}
] | 83397 | null | 83419 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "以下のサイトに従ってGooglecolabでPytorchのCycleGANを実行したのですが1エポックに約30分も時間がかかってしまいます。このサイトでは1エポックに6分くらいかかると書いてありました。\n\n[CycleGAN で画像変換する。](https://qiita.com/nomunomu/items/9de4aa447f502293a2f7)\n\nほかのサイトでも1エポックに6分当たりかかると書かれており私の実行時間よりとても短いです。なぜ私が実行すると30分もかかってしまうのかが分からず困っております。 \nGPUも設定しましたし、上のサイトに忠実に実行したはずなのに実行時間だけ大きく異なります。 \n実行したときのパラメータは以下の通りです。 \n[](https://i.stack.imgur.com/tc30K.png) \n[](https://i.stack.imgur.com/7mlq0.png) \nバッチサイズは4にしてあり、バッチサイズを大きくしたら早くなるのではと思い32にしてみたのですが、バッチサイズを大きくするとRuntimeerror:cuda\nerror:outofMemoryとなりエラーになってしまいます。 \nまた、実行した出力画面は以下のとおりです。1エポックまで実行して中断しました。1エポックに1657秒かかってます。 \n[](https://i.stack.imgur.com/Q0OOo.png)\n\n機械学習の知識があまりないので原因が全く分からないのですが、誰か分かる方がいましたら教えていただけますか。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T16:35:27.817",
"favorite_count": 0,
"id": "83398",
"last_activity_date": "2021-11-03T06:23:29.720",
"last_edit_date": "2021-11-03T06:23:29.720",
"last_editor_user_id": "3060",
"owner_user_id": "48909",
"post_type": "question",
"score": 0,
"tags": [
"機械学習",
"pytorch",
"google-colaboratory",
"gpu"
],
"title": "GooglecolabでCycleGANを実行したのに1エポックの実行時間が長すぎます",
"view_count": 233
} | [] | 83398 | null | null |
{
"accepted_answer_id": "83401",
"answer_count": 2,
"body": "Sphinxの開発環境に慣れている方ならFAQかもしれません。 \n宜しくお願いします。\n\n### 質問\n\nforkしたSphinxをローカルのclone環境でpytestを実行する場合に、必要な準備について教えてください。\n\n### 現状\n\n次のエラーが発生します。(「=」「_」「!」は多いので削りました)\n\n```\n\n ======== ERRORS ==============================================\n ________ ERROR collecting tests/test_util_inspect.py ____________________________\n ImportError while importing test module '/home/naomasa/sphinx/devcore/tests/test_util_inspect.py'.\n Hint: make sure your test modules/packages have valid Python names.\n Traceback:\n /usr/lib/python3.8/importlib/__init__.py:127: in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n tests/test_util_inspect.py:19: in <module>\n import _testcapi\n E ModuleNotFoundError: No module named '_testcapi'\n ======== short test summary info ======================================\n ERROR tests/test_util_inspect.py\n !!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n ======== 1 error in 6.40s =========================================\n \n```\n\n### 環境\n\n * windows10/cygwin64\n * python3.8.10\n * Sphinx4.2.0/時々4.3.0+(cloneからsdistして直接pip installしたもの)\n\n### 確認したこと\n\n * circleci上ではエラーは発生しないでテストが終わります。\n * 「ModuleNotFoundError: No module named '_testcapi'」から分かった次のことは試しました。 \n * `pip install python-test` … インストール済み\n * `python -m pytest tests` … 同じエラー\n * `pip install -e .` and `python -m pytest tests` … 同じエラー\n * 同じ環境で `make test` … 同じエラー\n * 同じ環境で `python setup.py test` … setuptoolsのエラー。\n\n### 考察\n\n次の可能性を考えています。\n\n * インポートしていないパッケージがある。\n * 実行時に設定しておく環境変数がある。\n * その他、何らかの設定が必要。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T18:20:04.330",
"favorite_count": 0,
"id": "83399",
"last_activity_date": "2021-11-03T11:54:50.697",
"last_edit_date": "2021-11-02T21:36:17.297",
"last_editor_user_id": "48452",
"owner_user_id": "48452",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"sphinx",
"circleci"
],
"title": "forkしたSphinxをローカルのclone環境でpytestを実行すると「ModuleNotFoundError: No module named '_testcapi'」が発生",
"view_count": 130
} | [
{
"body": "Python本体のテスト用パッケージが不足している可能性があります。 \nCircleCIでテスト実行に使用している環境はこちらです。 \n<https://github.com/sphinx-doc/docker-ci/blob/master/Dockerfile>\n\nUbuntuであれば `apt install python3-dev` のインストールで解消する可能性がありそうです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T20:37:26.453",
"id": "83401",
"last_activity_date": "2021-11-02T20:37:26.453",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "806",
"parent_id": "83399",
"post_type": "answer",
"score": 2
},
{
"body": "いただいた回答がきっかけで解決しました。 \n回答として情報を追記しておきます。\n\n### 結論\n\ncygwinのパッケージが不足していた\n\n * cygwinパッケージ `python38-test` のイントールで解決。\n * `pip install python-test` はしていたので意識外でした。\n\n現状FAILが一つありますが、エラーではなくFAILなので追々調べます。 \n(「=」は削っています)\n\n```\n\n …\n -- Docs: https://docs.pytest.org/en/stable/warnings.html\n ==== short test summary info ======================================\n FAILED tests/test_ext_imgconverter.py::test_ext_imgconverter - sphinx.errors.ExtensionError: conv...\n ==== 1 failed, 1735 passed, 28 skipped, 9 warnings in 611.24s (0:10:11) =======\n \n```\n\n### 解決まで\n\n 1. 回答をもらう。\n 2. もらった情報から、確かに「python3-dev」辺りが怪しいと思う。\n 3. cygwinで該当しそうなものを確認する。\n 4. ここで「cygwinで検索」を思いつく。\n 5. 「_testcapi」で検索。\n 6. 候補は「python38-debuginfo」「python38-test」だが内容から後者と判断。\n 7. インストール。\n 8. pytestがエラーで止まらずに最後まで実施されたことを確認。\n\n※4が決め手といえば決め手なんですが、対象範囲を絞れたからこそなので…",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T21:47:31.293",
"id": "83402",
"last_activity_date": "2021-11-03T11:54:50.697",
"last_edit_date": "2021-11-03T11:54:50.697",
"last_editor_user_id": "3060",
"owner_user_id": "48452",
"parent_id": "83399",
"post_type": "answer",
"score": 0
}
] | 83399 | 83401 | 83401 |
{
"accepted_answer_id": "83404",
"answer_count": 1,
"body": "### 現象\n\nforkしたsphinxをローカルのclone環境でpytestを実行すると「tests/test_ext_imgconverter.py」がFAILする。「svgimg.svg」ないというエラー。\n\nメッセージを見てフォルダーを確認すると次の通り\n\n * /tmp/pytest-of-USERNAME/pytest-1/ext-imgconverter/svgimg.svg … あり\n * /tmp/pytest-of-USERNAME/pytest-1/ext-imgconverter/_build/doctrees/images/ … なし",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T22:12:28.613",
"favorite_count": 0,
"id": "83403",
"last_activity_date": "2021-11-04T11:38:59.753",
"last_edit_date": "2021-11-04T11:38:59.753",
"last_editor_user_id": "48452",
"owner_user_id": "48452",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"sphinx",
"imagemagick"
],
"title": "forkしたSphinxをローカルのclone環境でpytestを実行すると「tests/test_ext_imgconverter.py」がFAILする。",
"view_count": 47
} | [
{
"body": "### 原因\n\nImageMagickがないのが原因。これを追加インストールすることで解決。\n\n### 解決までの流れ\n\n 1. エラー内容+αから `sphinx.ext.imageconverter` のテストだと分かる。\n 2. 参考情報を特定し、ImageMagickが必要と分かる。 \n * <https://www.sphinx-doc.org/ja/master/usage/extensions/imgconverter.html>\n 3. これをインストールしてpytestを再実行。passを確認。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T22:12:28.613",
"id": "83404",
"last_activity_date": "2021-11-03T06:13:23.227",
"last_edit_date": "2021-11-03T06:13:23.227",
"last_editor_user_id": "3060",
"owner_user_id": "48452",
"parent_id": "83403",
"post_type": "answer",
"score": 0
}
] | 83403 | 83404 | 83404 |
{
"accepted_answer_id": "83406",
"answer_count": 1,
"body": "Windows 10 で複数ユーザーのログオン履歴を確認したいと思っています。\n\nローカルグループポリシーエディタでアカウントログオン イベントの監査、ログオンイベントの監査 \nを成功、失敗にしたところ、イベントビューア>Windowsログ>セキュリティ 内で 4624 Log onは記録されるようになりましたが、 \nユーザー(U):欄は N/A \n一覧表示欄の ログオンID欄は、0x3E7のような表示になっています。\n\nユーザー名を確認するには、どうしたら良いでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-02T23:44:04.290",
"favorite_count": 0,
"id": "83405",
"last_activity_date": "2021-11-03T01:55:10.840",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15090",
"post_type": "question",
"score": 0,
"tags": [
"windows-10"
],
"title": "Windows10でユーザのログオン履歴の確認",
"view_count": 3652
} | [
{
"body": "Logonのイベントは、ユーザーによる明示的なログオン以外にも、サービスなどバックグラウンドで動作するプログラムが資格情報を利用するためのログオンでも記録されます。そのようなログオンの場合、SYSETMという特殊なアカウントが使用されるため、ユーザー名が表示されない場合があります。そのようなSYSTEMによるログオン処理は大量に発生するため、イベントID\n4624を検索しただけは、通常ユーザーのログオンが見つけにくなっているだけの可能性はあります。\n\n手元の環境(Windows\n11ですが、たぶん同じでしょう)で試したところ、ユーザーのログイン処理があるとき、4648というログオン試行のイベントが発生するようです。ログオンに成功していれば、その直後に、4624のイベントがあり、新しいログオンのセキュリティIDやアカウント名などでユーザー名(Microsoftアカウントでログインしている場合はMicrosoftアカウント名も)が書かれているはずです。4648のイベントを目印に確認してみてください。(ログオン処理は、ユーザーの資格情報でバックグラウンドの処理をすることがあるため、一回のログオンでも、ログオンイベント自体は複数発生していることがありますので、ご注意ください。)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-03T01:55:10.840",
"id": "83406",
"last_activity_date": "2021-11-03T01:55:10.840",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7347",
"parent_id": "83405",
"post_type": "answer",
"score": 2
}
] | 83405 | 83406 | 83406 |
{
"accepted_answer_id": "83409",
"answer_count": 1,
"body": "Pythonのファイルをherokuにプッシュしたいのですが、以下のメッセージが表示されてしまいます。`runtime.txt`\nに書くべきバージョンが違うのでしょうか?\n\n[](https://i.stack.imgur.com/Ny3Xf.png)\n\n公式サイトには「Python 3.8.2 now available」とあるので使えるはずなのですが、うまくいきません。\n\nPCのPythonは以下の通りです。これがダメなのでしょうか?\n\n```\n\n $ python -V \n $ Python 2.7.16\n $ python3 -V\n $ Python 3.8.2\n \n```\n\n回答よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-03T07:07:16.773",
"favorite_count": 0,
"id": "83408",
"last_activity_date": "2021-11-04T02:47:38.450",
"last_edit_date": "2021-11-04T02:47:38.450",
"last_editor_user_id": "3060",
"owner_user_id": "48929",
"post_type": "question",
"score": 0,
"tags": [
"python",
"heroku"
],
"title": "heroku に push しようとするとエラー: runtime (python-3.8.2) is not available",
"view_count": 82
} | [
{
"body": "Python の **マイクロバージョン** にも注目してみてください。バージョン表記のうち、A.B. **C** の部分です。\n\nローカル環境では 3.8. **2** のようですが、push 時のメッセージに出ている URL を開いて確認すると、サポートするのは 3.8.\n**12** と記載されています。\n\n<https://devcenter.heroku.com/articles/python-support>\n\n> ### Supported runtimes\n>\n> * python-3.8.12 on all supported stacks\n>\n\n[3.8.12 は 2021-08-30\nにリリース](https://www.python.org/downloads/release/python-3812/)\nされた現時点での最新版ですが、[3.8.2 のリリースは\n2020-02-24](https://www.python.org/downloads/release/python-382/)\nで古いバージョンになります。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-03T07:27:26.513",
"id": "83409",
"last_activity_date": "2021-11-03T07:27:26.513",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "83408",
"post_type": "answer",
"score": 0
}
] | 83408 | 83409 | 83409 |
{
"accepted_answer_id": "83429",
"answer_count": 1,
"body": "# やりたいこと\n\ndiscordのOAuth2を使用してユーザーの情報を取得してみたい\n\n# 発生している問題\n\nコードを実行したら`{ message: '401: Unauthorized', code: 0 }`これがconsoleに表示される\n\n# コード\n\n```\n\n const fetch = require('node-fetch');\n const express = require('express');\n const router = express.Router();\n \n router.get('/', async ({ query }, response) => {\n const { code } = query;\n \n if (code) {\n try {\n const oauthResult = await fetch('https://discord.com/api/oauth2/token', {\n method: 'POST',\n body: new URLSearchParams({\n client_id: '',\n client_secret: '',\n code,\n grant_type: 'authorization_code',\n redirect_uri: `https://oauth.aiueominato1111.repl.co`,\n scope: 'identify',\n }),\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n });\n \n const oauthData = await oauthResult.json();\n \n const userResult = await fetch('https://discord.com/api/users/@me', {\n headers: {\n authorization: `${oauthData.token_type} ${oauthData.access_token}`,\n },\n });\n \n console.log(await userResult.json());\n } catch (error) {\n // NOTE: An unauthorized token will not throw an error;\n // it will return a 401 Unauthorized response in the try block above\n console.log(error);\n }\n }\n \n return response.render('login', { root: '.' });\n });\n module.exports = router;\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-03T12:11:45.573",
"favorite_count": 0,
"id": "83413",
"last_activity_date": "2021-11-04T12:50:27.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48118",
"post_type": "question",
"score": 0,
"tags": [
"node.js",
"oauth",
"discord"
],
"title": "discordのOAuth2で 401: Unauthorized とconsoleに表示される",
"view_count": 848
} | [
{
"body": "tokenエンドポイントへのリクエストで `401` が返るということはクライアント認証に失敗しているのだと思います。\n\n`client_id`, `client_secret` に設定している値を見直してみてください。 \n(他のパラメータが誤っている場合には(Discordサービスの実装にも依りますが、典型的には) `400` が返ると思われます)\n\n参考:\n\n * [The OAuth 2.0 Authorization Framework](https://openid-foundation-japan.github.io/rfc6749.ja.html)\n * [3.2.1. クライアント認証](https://openid-foundation-japan.github.io/rfc6749.ja.html#token-endpoint-auth)\n * [5.2. エラーレスポンス](https://openid-foundation-japan.github.io/rfc6749.ja.html#token-errors)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T12:50:27.550",
"id": "83429",
"last_activity_date": "2021-11-04T12:50:27.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"parent_id": "83413",
"post_type": "answer",
"score": 0
}
] | 83413 | 83429 | 83429 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、Xcode(Swift)でアプリ開発をしています。 \nSKviewから別のUIViewへ画面遷移をしたい為、以下のサイトを参考にコードを書いています。\n\n[SpriteKit で segue を使って別の UIView\nに遷移する方法](https://hawksnowlog.blogspot.com/2017/09/use-segue-on-spritekit.html)\n\nここで、下記のコードを入力した結果、エラーが出てしまいました。\n\n**ソースコード:**\n\n```\n\n //「戻る」ボタンの動作\n @objc func onClickBackButton(sender : UIButton){ \n if let view = self.view {\n let vc = view.window?.rootViewController;\n vc?.performSegue(withIdentifier: \"to_top\", sender: nil)\n }\n }\n \n```\n\n**エラーメッセージ:**\n\n```\n\n Receiver (<Smoquit.ViewController: 0x7f8eb3f0ed30>) has no segue with identifier 'to_top'\n \n```\n\nsegueの識別子は'to_top'に設定しております。 \n何故、上記のエラーが出るのかご教授いただけると幸いです。 \nまた、別のSKviewからUIviewへの遷移方法がございましたらご提案いただけるとありがたいです。 \n宜しくお願い致します。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-03T14:27:08.450",
"favorite_count": 0,
"id": "83414",
"last_activity_date": "2021-11-03T16:20:33.697",
"last_edit_date": "2021-11-03T16:20:33.697",
"last_editor_user_id": "3060",
"owner_user_id": "48937",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode",
"spritekit"
],
"title": "SKviewでのSegueを用いた画面遷移",
"view_count": 104
} | [] | 83414 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "VC++/MFCにて、ダイアログベースアプリの環境下で \nグラフ描画を高速に行うためにメモリDCを導入しています。 \nこのダイアログはサイズ変更枠でサイズを変更できるようにしています。 \n#考え方が間違っているのかもしれませんが... \nWM_SIZEメッセージにて、メモリDCを破棄後、再度、新しいウィンドウサイズに \n対して、メモリDCを取得することで、リサイズ対応をしています。\n\nが、アプリが稼働している中で、メモリDCの破棄部分で不正終了してしまう場合 \nがあり、困惑しております。 \nメモリDCは5枚分作成し、重ねて画面に転送しています。\n\nどなたか、ご指導をいただければ幸いです。 \nよろしくお願いします。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T00:55:40.933",
"favorite_count": 0,
"id": "83416",
"last_activity_date": "2021-11-04T08:36:10.937",
"last_edit_date": "2021-11-04T02:44:18.917",
"last_editor_user_id": "3060",
"owner_user_id": "48939",
"post_type": "question",
"score": 0,
"tags": [
"mfc",
"visual-c++"
],
"title": "VC++/MFC メモリDCの破棄時に不正終了してしまう場合がある",
"view_count": 197
} | [
{
"body": "まず、対象ソースコードを示した方が早期に解決できると考えられます。強く推薦します。\n\nさて、自分もメモリーDCを使用していますが、特に問題は出ていません。 \nWM_SIZEにも対応しており以下の仮想コードの様な手順で処理しています。 \nご自分のコードと比べれば瑕疵が発見できるかもしれません。 \n特に、選択中のビットマップを外さないと、破棄できないため色々とまずいことが起こります。\n\n```\n\n class MyMEMDC : public CDC\n {\n CBitMap m_BitMap; // メインのビットマップ\n CDC * m_OwnerDC; // 元になったDC\n short m_Bmp_dmmy_data[ 16]; // 選択外し用\n CBitmap m_Bmp_dmmy; // 選択外し用\n MyMEMDC()\n {\n //ダミーのビットマップ\n m_Bmp_dmmy.CreateBitmap( 1, 1, 1, 1, &m_Bmp_dmmy_data);\n }\n \n void ReSize(\n CWnd * ex_owner,\n const CRect & ex_rc)\n {\n CDC::SelectObject( m_Bmp_dmmy); // 現在選択中のメインのビットマップを外します。\n m_BitMap.DeleteObject(); // メインのビットマップを破棄します。\n DeleteDC(); // メモリーDCを破棄します\n m_OwnerDC = ex_owner->GetDC(); // オーナーHWNDのDCを取得します\n CreateCompatibleDC( m_OwnerDC); // メモリーDCを構築します\n m_BitMap.CreateCompatibleBitmap( m_OwnerDC, ex_rcの幅と高さ) // メインのビットマップを再作成します\n CDC::SelectObject( &m_BitMap); // 再構築したBitMapを選択しなおします。\n }\n };\n \n```\n\n尚、リサイズ時の排他処理(外部タイミングでの描画)などが必要な場合があるかと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T08:36:10.937",
"id": "83426",
"last_activity_date": "2021-11-04T08:36:10.937",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3793",
"parent_id": "83416",
"post_type": "answer",
"score": 1
}
] | 83416 | null | 83426 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "単純にTargetのSigning & CapabilitiesでCloudKitのチェックを外した。 \nアプリを立ち上げると直ぐに以下のメッセージがコンソールに表示される。\n\n```\n\n [error] fault: Store opened without NSPersistentHistoryTrackingKey but previously had been opened with NSPersistentHistoryTrackingKey - Forcing into Read Only mode\n \n```\n\nhistory tracking optionをONに戻せば良いらしいのだが、どこで設定するのか不明。 \n(そもそも明示的にOFFにした覚えはない) \nお分かりの方がいらっしゃいましたら、ご教授ください。 \nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T02:04:45.977",
"favorite_count": 0,
"id": "83417",
"last_activity_date": "2021-11-05T04:14:37.600",
"last_edit_date": "2021-11-04T04:55:10.663",
"last_editor_user_id": "3060",
"owner_user_id": "48690",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"xcode"
],
"title": "iOSアプリを作っており、CoreData + CloudKitとしていたが、CloudKitのチェックを外したところ、CoreDataのデータがRead Onlyとなってしまった",
"view_count": 105
} | [
{
"body": "このような現象を報告されるのであれば、ターゲットのiOSバージョン、Xcodeのバージョン、どのように元プロジェクトを作ったのか、など、あなたの現在のプロジェクトがどのようなものなのかがわかる情報を、可能な限り詳しく記述した方が回答が付きやすく、得られる回答もあなたのプロジェクトで即適用可能なものになりやすいでしょう。\n\n* * *\n\n「Core Data + CloudKitとしていた」がプロジェクト作成時に以下のようにしていたと仮定します。\n\n[](https://i.stack.imgur.com/Bdm6V.png)\n\nこの場合、プロジェクト作成時に生成されるコード自体がCore Dataのみを指定した場合とは異なっています。\n\n### AppDelegate.swift\n\n(Core Data + CloudKit、抜粋)\n\n```\n\n lazy var persistentContainer: NSPersistentCloudKitContainer = {\n /*\n The persistent container for the application. This implementation\n creates and returns a container, having loaded the store for the\n application to it. This property is optional since there are legitimate\n error conditions that could cause the creation of the store to fail.\n */\n let container = NSPersistentCloudKitContainer(name: \"CoreDataCloudKitSample\")\n container.loadPersistentStores(completionHandler: { (storeDescription, error) in\n if let error = error as NSError? {\n // Replace this implementation with code to handle the error appropriately.\n // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.\n \n /*\n Typical reasons for an error here include:\n * The parent directory does not exist, cannot be created, or disallows writing.\n * The persistent store is not accessible, due to permissions or data protection when the device is locked.\n * The device is out of space.\n * The store could not be migrated to the current model version.\n Check the error message to determine what the actual problem was.\n */\n fatalError(\"Unresolved error \\(error), \\(error.userInfo)\")\n }\n })\n return container\n }()\n \n```\n\n### AppDelegate.swift\n\n(Core Dataのみ、抜粋)\n\n```\n\n lazy var persistentContainer: NSPersistentContainer = {\n /*\n The persistent container for the application. This implementation\n creates and returns a container, having loaded the store for the\n application to it. This property is optional since there are legitimate\n error conditions that could cause the creation of the store to fail.\n */\n let container = NSPersistentContainer(name: \"CoreDataSample\")\n container.loadPersistentStores(completionHandler: { (storeDescription, error) in\n if let error = error as NSError? {\n // Replace this implementation with code to handle the error appropriately.\n // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.\n \n /*\n Typical reasons for an error here include:\n * The parent directory does not exist, cannot be created, or disallows writing.\n * The persistent store is not accessible, due to permissions or data protection when the device is locked.\n * The device is out of space.\n * The store could not be migrated to the current model version.\n Check the error message to determine what the actual problem was.\n */\n fatalError(\"Unresolved error \\(error), \\(error.userInfo)\")\n }\n })\n return container\n }()\n \n```\n\n* * *\n\nご自身でCore Data + CloudKitと、Core Dataのみのプロジェクトを作成してみて、違いがある部分を「Core\nDataのみのプロジェクト」に合わせて修正してみてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T04:14:37.600",
"id": "83437",
"last_activity_date": "2021-11-05T04:14:37.600",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "83417",
"post_type": "answer",
"score": 1
}
] | 83417 | null | 83437 |
{
"accepted_answer_id": "83421",
"answer_count": 2,
"body": "※Xcodeをインストールしています。\n\nVSCodeのターミナルから `gcc -o main main.c` でコンパイルしようとしましたが以下のエラーが出ました。\n\n```\n\n Undefined symbols for architecture x86_64:\n \"_avg\", referenced from:\n _main in main-d23be1.o\n ld: symbol(s) not found for architecture x86_64\n clang: error: linker command failed with exit code 1 (use -v to see invocation)\n \n```\n\nuse -v と書いてあるので `gcc -v main main.c` としたところ、以下のようになりました。エラーの解決方法を教えてください。\n\n```\n\n Apple clang version 13.0.0 (clang-1300.0.29.3)\n Target: x86_64-apple-darwin20.6.0\n Thread model: posix\n InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin\n clang: error: no such file or directory: 'main'\n \n```\n\n### ソースコード\n\nmain.c\n\n```\n\n #include <stdio.h>\n #include \"calc.h\"\n \n int main(){\n double d1,d2,d3;\n double a = 1.2,b = 3.4,c = 2.7;\n // 同じ計算が3回(関数を呼び出して計算)\n d1 = avg(a,b);\n d2 = avg(4.1,5.7);\n d3 = avg(c,2.8);\n printf(\"d1 = %f,d2 = %f,d3 = %f¥n\",d1,d2,d3);\n }\n \n```\n\ncalc.h\n\n```\n\n #ifndef _CALC_H_\n #define _CALC_H_\n \n // 関数avgのプロトタイプ宣言\n double avg(double,double);\n \n #endif // _CALC_H_\n \n```\n\ncalc.c\n\n```\n\n #include \"calc.h\"\n \n // 平均値を求める関数\n double avg(double l,double m){\n // 引数l,mの平均値を求め、rに代入する。\n double r = (l + m) / 2.0;\n return r;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T06:13:37.247",
"favorite_count": 0,
"id": "83420",
"last_activity_date": "2021-11-04T07:28:04.907",
"last_edit_date": "2021-11-04T07:28:04.907",
"last_editor_user_id": "3060",
"owner_user_id": "48943",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "gccでC言語のコンパイルができない",
"view_count": 2630
} | [
{
"body": "`gcc -o main main.c calc.c` のように、`calc.c` もコマンドラインに指定してください。関数 `avg()` が\n`calc.c` の中にあるからです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T06:28:56.583",
"id": "83421",
"last_activity_date": "2021-11-04T06:28:56.583",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3475",
"parent_id": "83420",
"post_type": "answer",
"score": 3
},
{
"body": "分割コンパイルの解説は検索すればすぐ見つかると思うのだけど、一番簡単で遅いコンパイル・リンク手順は\n\n```\n\n gcc -o main main.c calc.c\n \n```\n\nなぜこうしないといけないかは、やはり検索してみて、それでもわからなければ別質問にしてくれると幸い。\n\n他の方法だと `Makefile` を作って `make` するってことになるんだけど、全部解説すると分量が多いっス。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T06:29:31.917",
"id": "83422",
"last_activity_date": "2021-11-04T06:29:31.917",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "83420",
"post_type": "answer",
"score": 0
}
] | 83420 | 83421 | 83421 |
{
"accepted_answer_id": "83903",
"answer_count": 1,
"body": "こんにちは。wordpressでサイト制作をしていて、スライダーにはプラグインの\"slick slider\"を使用しています。\n\n### ***実現したいこと***\n\nスワイプ、またはスライドが切り替わるたびに表示させる画像の数を変更したいです。 \n表示させたい枚数の範囲は、1−2枚です。 \n例)スライド => 画像2枚表示, \n2回目スライド => 画像1枚表示、 \n3回目スライド => 画像1枚表示、 \n4回目スライド => 画像2枚表示,,,, etc\n\n### ***試したこと***\n\nスワイプ(画像が切り替わる)するたびにランダムに整数を生成して、その整数をslideToShowの値に代入しましたが、変な挙動をします。。\n\n例)画像1画像2、画像3画像4、画像5画像6、画像7画像8、画像9画像10、 \n現在、画像1と画像2が表示されてるとして、スライドさせると一瞬だけ画像3画像4が表示されますが、すぐに画像7画像8に飛んだりと順番通りに表示されません。 \n言葉での説明が難しいのですいません。\n\nbeforeChangeの箇所をafterChangeなどに変更して挙動を確認しましたが変わらず。。\n\n```\n\n /*main.js*/\n $('#slick').on('swipe', function () {\n const randomNum = 1 + Math.floor(Math.random() * 2);\n $(this).on('beforeChange', function () {\n $(this).slick('slickSetOption', {\n slidesToShow: randomNum,\n }, true);\n })\n console.log(randomNum)\n });\n \n $('#slick').slick({\n // slidesToShow: randomNum,\n slidesToScroll: 1,\n arrows: false,\n adaptiveHeight: true,\n });\n \n \n <!-- single-post.php -->\n <div id=\"slick\">\n <?php if ($portfolioGallery) : ?>\n <?php foreach ($portfolioGallery as $image) : ?>\n <div class=\"photo side-scroll-item\">\n <?php $size = ($image['width'] / $image['height'] > 1) ? 'landscape' : 'portrait';\n echo wp_get_attachment_image($image['ID'], $size, false, ['class' => 'gallery__image--' . ($index % 10) . ' ' . $size]);\n ?>\n </div>\n <?php endforeach; ?>\n <?php endif; ?>\n </div>\n \n```\n\nプラグインのサイトは[こちら](https://kenwheeler.github.io/slick/)です。 \nアドバイスやご指摘があればとても助かります。よろしくお願いいたします。\n\n[teratail](https://teratail.com/questions/367642)でも同じ質問をしています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T07:38:33.297",
"favorite_count": 0,
"id": "83425",
"last_activity_date": "2021-12-02T00:42:57.670",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29392",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"php",
"jquery"
],
"title": "slick sliderのslideToShowの値をスワイプする度にランダムに変更させたいです。",
"view_count": 223
} | [
{
"body": "```\n\n <ul class=\"slider\">\n <?php $args = array(\n 'posts_per_page' => 3, //表示する記事の数\n );\n $customPosts = get_posts($args);\n if($customPosts) : foreach($customPosts as $post) : setup_postdata( $post );\n ?>\n <li>\n <a href=\"<?php the_permalink(); ?>\">\n <?php the_title(); ?> <!--記事タイトルを表示-->\n </a>\n </li>\n <?php endforeach; ?>\n <?php else : //記事が無い場合 ?>\n <p>このカテゴリーにはまだ記事がありません</p>\n <?php endif; wp_reset_postdata(); //クエリのリセット ?>\n </ul>\n \n <script>\n $(function () {\n $(\".slider\").slick({\n autoplay: true,\n vertical: true,\n verticalSwiping: true,\n });\n });\n </script>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-12-01T06:08:26.457",
"id": "83903",
"last_activity_date": "2021-12-02T00:42:57.670",
"last_edit_date": "2021-12-02T00:42:57.670",
"last_editor_user_id": "3060",
"owner_user_id": "49302",
"parent_id": "83425",
"post_type": "answer",
"score": 1
}
] | 83425 | 83903 | 83903 |
{
"accepted_answer_id": "83431",
"answer_count": 1,
"body": "パスワード(pass)とパスワード再入力(reenter)が同じだった場合インサートが実行され、同じでない場合はエラーメッセージを表示してインサートしない、といったものを作っています。\n\nしかし現状では、同じ値なのにエラーメッセージが出たり \nお互い未入力なのにメッセージが出なかったり \nといった感じです。\n\nまた、値が同じでエラーメッセージが表示されず(成功かな?)と思いそのまま値を別(reenterとpassをバラバラの値)にして再度登録を押すと、本来エラーメッセージが出るはずなのに出なかったりと訳が分かりません。\n\n前提としてインサートは問題なく行えています。\n\n教授していただきたく思います。\n\n```\n\n import javax.validation.constraints.AssertTrue; \n @Getter\n @Setter\n public class CreateForm {\n @NotBlank\n private String id;\n @NotBlank\n private String pass;\n @NotBlank\n private String reenter;\n @AssertTrue(message = \"PASSが一致しません\")\n public boolean isCheck() {\n if (pass != reenter) return true;\n return false;\n }\n @NotBlank\n private String name;\n @NotBlank\n private String kana;\n @NotBlank\n private String birth;\n @NotBlank\n private String club;\n }\n \n```\n\n```\n\n <form action=\"#\" th:action=\"@{/create}\" th:object=\"${createForm}\" method=\"post\">\n <table>\n <tr>\n <th>id</th>\n <td><input type=\"text\" name=\"id\" th:field=\"*{id}\"><br>\n <span th:if=\"${#fields.hasErrors('id')}\" th:errors=\"*{id}\"></span></td>\n </tr>\n <tr>\n <th>pass</th>\n <!-- ポイント2 -->\n <td><input type=\"text\" name=\"pass\" th:field=\"*{pass}\"><br>\n <span th:if=\"${#fields.hasErrors('pass')}\" th:errors=\"*{pass}\"></span></td>\n </tr>\n <tr>\n <th>reenter</th>\n <td><input type=\"text\" name=\"reenter\" th:field=\"*{reenter}\"><br>\n <span th:if=\"${#fields.hasErrors('reenter')}\"\n th:errors=\"*{reenter}\"></span></td>\n </tr>\n <tr>\n <td><span th:if=\"${#fields.hasErrors('check')}\"\n th:errors=\"*{check}\"></span></td>\n </tr>\n <tr>\n <th>name</th>\n <td><input type=\"text\" name=\"name\" th:field=\"*{name}\"><br>\n <span th:if=\"${#fields.hasErrors('name')}\" th:errors=\"*{name}\"></span></td>\n </tr>\n <tr>\n <th>kana</th>\n <td><input type=\"text\" name=\"kana\" th:field=\"*{kana}\"><br>\n <span th:if=\"${#fields.hasErrors('kana')}\" th:errors=\"*{kana}\"></span></td>\n </tr>\n \n <tr>\n <th>birth</th>\n <td><input type=\"text\" name=\"birth\" th:field=\"*{birth}\"><br>\n <span th:if=\"${#fields.hasErrors('birth')}\" th:errors=\"*{birth}\"></span></td>\n </tr>\n <tr>\n <th>club</th>\n <td><input type=\"text\" name=\"club\" th:field=\"*{club}\"><br>\n <span th:if=\"${#fields.hasErrors('club')}\" th:errors=\"*{club}\"></span></td>\n </tr>\n \n </table>\n <input type=\"submit\" value=\"登録\">\n </form>\n </body>\n </html>\n \n```\n\n```\n\n @GetMapping(\"create\")\n String create(@ModelAttribute CreateForm customerForm) {\n return \"create\";\n }\n \n @PostMapping(\"create\")\n String regist(@Validated @ModelAttribute CreateForm createForm,\n BindingResult result,\n Model model) {\n if(result.hasErrors()) {\n return create(createForm);\n }\n User user = new User();\n Userdetail userdetail = new Userdetail();\n BeanUtils.copyProperties(createForm, user);\n BeanUtils.copyProperties(createForm, userdetail);\n sevi.insert(user);\n sevi.insert2(userdetail);\n \n return \"redirect:/create\";\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T12:45:04.633",
"favorite_count": 0,
"id": "83428",
"last_activity_date": "2021-11-05T00:51:30.940",
"last_edit_date": "2021-11-05T00:51:30.940",
"last_editor_user_id": "3060",
"owner_user_id": "48204",
"post_type": "question",
"score": 0,
"tags": [
"java",
"mysql",
"spring",
"spring-boot"
],
"title": "アノテーション @AssertTrue での入力値チェックが意図した通り動作しない",
"view_count": 1402
} | [
{
"body": "Java の文字列比較は `==`( や `!=` )でなく\n[`String#equals()`](https://docs.oracle.com/javase/jp/11/docs/api/java.base/java/lang/String.html#equals\\(java.lang.Object\\))\nメソッドや\n[`Objects.equals()`](https://docs.oracle.com/javase/jp/11/docs/api/java.base/java/util/Objects.html#equals\\(java.lang.Object,java.lang.Object\\))メソッドを用います。\n\nおそらく意図している実装は次のものではないでしょうか。\n\n```\n\n import java.util.Objects;\n // ...\n \n @AssertTrue(message = \"PASSが一致しません\")\n public boolean isCheck() {\n return Objects.equals(pass, reenter);\n }\n \n```\n\n関連:\n\n * [Javaの文字列の比較について](https://ja.stackoverflow.com/q/24297/2808)\n * [String型を==で比較したときの挙動が予想と違う](https://ja.stackoverflow.com/q/63088/2808)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T13:16:02.270",
"id": "83431",
"last_activity_date": "2021-11-04T13:22:35.900",
"last_edit_date": "2021-11-04T13:22:35.900",
"last_editor_user_id": "2808",
"owner_user_id": "2808",
"parent_id": "83428",
"post_type": "answer",
"score": 1
}
] | 83428 | 83431 | 83431 |
{
"accepted_answer_id": "83433",
"answer_count": 1,
"body": "気温データをDFに取り込んだところ、「11月」と「年の値」のコラムに「 ] 」が含まれた数値があります。 \nこの記号を削除したいのですが、どうすればいいでしょうか。\n\nデータタイプは、\n\nMiyagi_temp['年の値'].unique().tolist()\n\nで確認して記号付きはstrになっています。\n\nMiyagi_temp['年の値'].str.strip(' ]') \nを実行すると記号は消えますが、記号付きの数値以外はすべてnanになってしまいます。\n\nMiyagi_temp['年の値'].str.replace(' ]', '') \nを実行しても同じ結果です。\n\nすいませんがよろしくお願いします。\n\n[](https://i.stack.imgur.com/l0h2P.jpg)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T14:17:35.990",
"favorite_count": 0,
"id": "83432",
"last_activity_date": "2021-11-04T16:12:13.717",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48948",
"post_type": "question",
"score": 1,
"tags": [
"python",
"pandas"
],
"title": "DataFrame セル内の記号を消したい",
"view_count": 202
} | [
{
"body": "記号の削除と dtype を変更します。\n\n```\n\n # object type の列名を抽出\n cols = Miyagi_temp.select_dtypes('O').columns\n \n # 数字と負号(\"-\")と \".\" 以外を削除して dtype を object から float64 へ変更\n Miyagi_temp[cols] = (\n Miyagi_temp[cols].replace(r'[^\\d.-]', '', regex=True).astype('float64'))\n \n pd.set_option('display.unicode.east_asian_width', True)\n print(Miyagi_temp.dtypes)\n \n #\n 年 int64\n 1月 float64\n 2月 float64\n 3月 float64\n 4月 float64\n 5月 float64\n 6月 float64\n 7月 float64\n 8月 float64\n 9月 float64\n 10月 float64\n 11月 float64\n 12月 float64\n 年の値 float64\n \n print(Miyagi_temp.head().to_string(index=False))\n \n 年 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月 年の値\n 1926 NaN NaN NaN NaN NaN NaN NaN NaN NaN 11.8 6.8 1.7 6.8\n 1927 -0.6 -1.5 2.5 9.0 13.6 17.6 23.4 24.2 18.5 13.9 8.3 2.1 10.9\n 1928 0.4 0.1 2.9 8.8 13.7 16.9 21.1 22.4 21.6 14.2 8.8 1.4 11.0\n 1929 -1.3 -0.7 2.9 8.7 12.9 16.7 23.3 24.9 18.7 14.3 8.2 5.0 11.1\n 1930 -0.6 1.9 5.6 9.9 14.4 18.4 22.4 24.5 19.2 13.9 6.8 2.3 11.6\n \n print(Miyagi_temp.tail().to_string(index=False))\n \n 年 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月 年の値\n 2017 2.5 3.2 5.4 11.5 17.0 18.6 25.1 23.0 21.1 14.9 9.1 3.5 12.9\n 2018 1.4 1.4 7.5 12.5 17.0 20.3 25.5 24.9 20.8 16.5 10.7 4.3 13.6\n 2019 2.4 3.7 7.0 10.2 17.4 19.0 22.4 26.2 22.4 16.9 10.0 5.4 13.6\n 2020 4.0 4.4 7.5 10.1 16.8 21.2 21.3 26.6 22.5 15.6 10.8 3.9 13.7\n 2021 1.2 3.7 8.6 11.6 17.0 20.6 24.1 24.9 20.8 15.8 15.1 NaN 14.8\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-04T15:45:13.383",
"id": "83433",
"last_activity_date": "2021-11-04T16:12:13.717",
"last_edit_date": "2021-11-04T16:12:13.717",
"last_editor_user_id": "47127",
"owner_user_id": "47127",
"parent_id": "83432",
"post_type": "answer",
"score": 0
}
] | 83432 | 83433 | 83433 |
{
"accepted_answer_id": "83435",
"answer_count": 2,
"body": "以下のように、Floatの配列array1とarray2があった場合 \nそのまま引き算のように記述するとエラーになります。\n\n```\n\n var array1 = floatArrayOf(10.toFloat(), 8.toFloat(), 5.toFloat())\n var array2 = floatArrayOf(4.toFloat(), 3.toFloat(), 2.toFloat())\n \n var array3 = array1 - array2\n \n```\n\n得たい値(配列)は以下のようなものです。\n\n```\n\n [6.0,5.0,3.0]\n \n```\n\nKotlinでは、配列同士の引き算をどのように記述するのが良いですか?\n\nちなみに私はKotlin初心者なので、`10.toFloat()`のような書き方があまりスマートではないと感じています。 \nFloatの配列を作成する時にもっと良い方法があったらそれも知りたいです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T01:54:24.333",
"favorite_count": 0,
"id": "83434",
"last_activity_date": "2021-11-09T12:54:25.770",
"last_edit_date": "2021-11-05T03:54:35.390",
"last_editor_user_id": "7290",
"owner_user_id": "34471",
"post_type": "question",
"score": 2,
"tags": [
"java",
"android",
"kotlin"
],
"title": "Kotlin で配列同士の引き算をするには",
"view_count": 301
} | [
{
"body": "> そのまま引き算のように記述すると\n\nというのがどの言語を念頭に置いているのかわかりませんが、 _配列同士の引き算_ ということ自体が、例えば Java\nでは元々やらない発想ですね。あと、`.toFloat()` については、値に `f` を付ければいいのは Java と同じかと。\n\n```\n\n var array1 = floatArrayOf(10f, 8f, 5f)\n var array2 = floatArrayOf(4f, 3f, 2f)\n var array3 = Array(3){array1[it] - array2[it]}\n \n array3.forEach{f -> println(f)}\n \n```\n\nfor ループ的にやってみましたが、想定されているもの( _配列同士の引き算_ )とは違うかもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T03:54:03.223",
"id": "83435",
"last_activity_date": "2021-11-05T03:54:03.223",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7290",
"parent_id": "83434",
"post_type": "answer",
"score": 2
},
{
"body": "zipして、計算。\n\n```\n\n $ kotlinc\n >>> val array1 = floatArrayOf(10.toFloat(), 8.toFloat(), 5.toFloat())\n >>> val array2 = floatArrayOf(4.toFloat(), 3.toFloat(), 2.toFloat())\n \n >>> array1.zip(array2).map{(a, b) -> a - b}\n res12: kotlin.collections.List<kotlin.Float> = [6.0, 5.0, 3.0]\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T12:54:25.770",
"id": "83522",
"last_activity_date": "2021-11-09T12:54:25.770",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "46671",
"parent_id": "83434",
"post_type": "answer",
"score": 2
}
] | 83434 | 83435 | 83435 |
{
"accepted_answer_id": "83445",
"answer_count": 1,
"body": "insertの際にIDが重複しているかいないかの確認がしたいです。\n\n現在ソースは下のようになっておりますが、何故か重複していない値をいれても重複していますとHTMLで表示されてしまいます。\n\nこの画像の重複をクリックするとHTMLに遷移して、重複しています、または重複していませんが表示されます。\n\n[](https://i.stack.imgur.com/Hu4Zf.png)\n\n* * *\n\nサービスクラス\n\n```\n\n public User doubleCheck(String id) {\n \n User u = userRepository.getById(id);\n \n if (u.getId().equals(id)) {\n //if (null != u) {\n return u;\n }\n return null;\n }\n \n```\n\n```\n\n @Repository\n public interface UserRepository extends JpaRepository<User,String>{\n \n List<User> findBynameLike(String name);\n \n```\n\n```\n\n @PostMapping(\"double\")\n String DoubleCheck(@RequestParam String id,\n Model model) {\n \n User u = sevi.doubleCheck(id);\n //model.addAttribute(\"u\", u);\n if (null != u) {\n String msg = \"重複してるよ\";\n model.addAttribute(\"msg\", msg);\n return \"double\";\n }\n String msg2 = \"重複してないよ\";\n model.addAttribute(\"msg2\", msg2);\n return \"double\";\n }\n \n```\n\n```\n\n </head>\n <body>\n <span th:text=${msg}></span>\n <span th:text=${msg2}></span>\n </body>\n </html>\n \n```\n\nサービスクラスを以下の様にしましたら \nいけました。アドバイスありがとうございました。\n\n```\n\n public User doubleCheck(String id) {\n try {\n User u = userRepository.getById(id);\n u.getName();\n return u;\n } catch (Exception e) {\n return null;\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T03:59:14.813",
"favorite_count": 0,
"id": "83436",
"last_activity_date": "2021-11-05T22:47:44.480",
"last_edit_date": "2021-11-05T13:58:36.387",
"last_editor_user_id": "48204",
"owner_user_id": "48204",
"post_type": "question",
"score": 0,
"tags": [
"java",
"mysql",
"spring-boot"
],
"title": "IDの重複チェック",
"view_count": 1570
} | [
{
"body": "* 引数に指定した `id` を持つ `User` が既に登録されている場合はその `User` を返す\n * まだ登録されていない場合は `null` を返す\n\nという仕様ならば、次の実装で良いかと思います:\n\n```\n\n public User doubleCheck(String id) {\n return userRepository.getById(id);\n }\n \n```\n\n重複登録時に何か追加で処理をしようとしているのであれば、最初に `getById` の戻り値の `null` チェックを行うのが良いでしょう:\n\n```\n\n public User doubleCheck(String id) {\n User u = userRepository.getById(id);\n if (u == null) {\n return null;\n }\n \n // 追加の処理\n // ...\n \n return u;\n }\n \n```\n\n単に真偽値を返せばよいのなら `existsById` も利用できます:\n\n```\n\n public boolean doubleCheck(String id) {\n // id が既に存在しているのなら(つまり、重複登録しようとしているのなら) true\n return userRepository.existsById(id);\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T22:40:52.577",
"id": "83445",
"last_activity_date": "2021-11-05T22:47:44.480",
"last_edit_date": "2021-11-05T22:47:44.480",
"last_editor_user_id": "2808",
"owner_user_id": "2808",
"parent_id": "83436",
"post_type": "answer",
"score": 0
}
] | 83436 | 83445 | 83445 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "VirtualBox上にMX Linux21をインストールし仮想環境を構築しようと思っています。ホストOSはWindows11です。 \nVirtualBoxとMX\nLinux21の設定は完了しています。タイムゾーンやキーボード、パソコンの名前やパスワード、root管理者用のパスワード等設定が完了し、再起動をしました。\n\nお恥ずかしい話なのですが、そこへパスワードを打ち込んだのですがエラーが出ました。 \nちゃんと最初のパスワードと確認用のパスワードを設定しています。 \n急いでいたので入力をミスしたようです。少し前に試したときははroot管理者用のパスワードは設定していなかった気がします。\n\n[](https://i.stack.imgur.com/Xb0Y3.jpg)\n\n何回か再起動したり探してサイトに載っていたやり方を試したりしてみたのですがうまくいきません。\n\n現状、再起動しようが試しにキーボードを打ったりしてみたのですが添付画像から進めません。\n\nこういう場合、削除して再度インストールする必要がありますか?\n\n仮想環境やLinuxに関しては全くの初心者です。動画サイトを見ながら設定をしました。\n\nこのような状態からパスワード再設定する方法などわかる方いらっしゃいましたら教えて下さい。 \nまた以下の画面より設定がおかしいようでしたらご指摘願います。\n\nあとキーボードでレイアウトは日本語を選択してあるのですが、キーボードモデルは選択肢があまりにも多く、自分の使っているキーボードのモデルも検索してはみたのですが結局わかりませんでした。そこでとりあえずMicrosoft\nオフィスを選択して先に進みました。後から設定変更可能なのでしょうか?またここは何を選択したら良いのでしょうか?\n\n併せてよろしくお願いいたします。\n\n[](https://i.stack.imgur.com/AWEmq.png)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T07:14:14.350",
"favorite_count": 0,
"id": "83439",
"last_activity_date": "2021-11-05T08:16:28.657",
"last_edit_date": "2021-11-05T08:16:28.657",
"last_editor_user_id": "3060",
"owner_user_id": "42150",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"debian"
],
"title": "MX Linux のログインパスワードが分からなくなった",
"view_count": 737
} | [] | 83439 | null | null |
{
"accepted_answer_id": "83448",
"answer_count": 1,
"body": "discordのOAuth2を試しているのですがusernameの取り出し方がわからなく苦戦しています。 \nどなたか教えていただけませんか?\n\n### コード\n\n```\n\n const fetch = require('node-fetch');\n const express = require('express');\n \n const app = express();\n \n app.get('/', async ({ query }, response) => {\n const { code } = query;\n \n if (code) {\n try {\n const oauthResult = await fetch('https://discord.com/api/oauth2/token', {\n method: 'POST',\n body: new URLSearchParams({\n client_id: process.env['ci'],\n client_secret: process.env['cs'],\n code,\n grant_type: 'authorization_code',\n redirect_uri: `https://oauth.aiueominato1111.repl.co`,\n scope: 'identify',\n }),\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n });\n \n const oauthData = await oauthResult.json();\n \n const userResult = await fetch('https://discord.com/api/users/@me', {\n headers: {\n authorization: `${oauthData.token_type} ${oauthData.access_token}`,\n },\n });\n console.log( await userResult.json());\n } catch (error) {\n // NOTE: An unauthorized token will not throw an error;\n // it will return a 401 Unauthorized response in the try block above\n console.error(error);\n }\n }\n \n return response.sendFile('index.html', { root: '.' });\n });\n \n app.listen(port, () => console.log(`App listening at http://localhost:${port}`));\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T13:23:42.440",
"favorite_count": 0,
"id": "83440",
"last_activity_date": "2021-11-06T05:47:36.400",
"last_edit_date": "2021-11-06T05:47:36.400",
"last_editor_user_id": "3060",
"owner_user_id": "48118",
"post_type": "question",
"score": 0,
"tags": [
"node.js",
"oauth",
"discord",
"webapi"
],
"title": "node.jsのAPIデータから値を取りだす方法",
"view_count": 67
} | [
{
"body": "質問文中のコード\n\n```\n\n console.log( await userResult.json());\n \n```\n\nで、ユーザ情報が `node` を実行したコンソールに出力されていると思います。\n\n`userResult` から `username` だけ取り出すためのコードは次の通りです:\n\n```\n\n const resultJson = await userResult.json();\n console.log(resultJson.username);\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T04:28:41.083",
"id": "83448",
"last_activity_date": "2021-11-06T04:28:41.083",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"parent_id": "83440",
"post_type": "answer",
"score": 0
}
] | 83440 | 83448 | 83448 |
{
"accepted_answer_id": "83490",
"answer_count": 1,
"body": "SpressenseのArduinoIDE利用でのシリアル通信時のバッファサイズはArduinoと同じく64Byteなのでしょうか? \nまた、バッファサイズについて変更可能でしょうか。 \n大き目のデータのやり取りがしたく、溢れないようにバッファサイズを256Byteに拡張したいと考えています。\n\n通常のArduinoのボードでの設定は下記の記事の通り変更出来るようなのですが、\n\n[arduinoのbufferを64byteから256byteに増やす](https://qiita.com/showmeear/items/5d37e717b03a14dc74d8)\n\nSpressenseの以下の場所にある同様のファイルを確認してもバッファサイズの記載がありませんでした。\n\n```\n\n C:\\Users\\XXX\\AppData\\Local\\Arduino15\\packages\\SPRESENSE\\hardware\\spresense\\2.3.0\\cores\\spresense\n \n```\n\nバッファサイズや変更の可否についてご教授いただけますと幸いです。 \nよろしくお願いいたします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T13:44:37.003",
"favorite_count": 0,
"id": "83441",
"last_activity_date": "2021-11-08T10:15:38.480",
"last_edit_date": "2021-11-08T04:14:14.677",
"last_editor_user_id": "3060",
"owner_user_id": "48860",
"post_type": "question",
"score": 0,
"tags": [
"spresense"
],
"title": "SpressenseのArduinoIDEでのシリアル通信バッファサイズは変更可能か?",
"view_count": 307
} | [
{
"body": "SpresenseのSerial2のバッファサイズは既に256byteになっているようです。\n\nバッファサイズをそれ以上に大きくしたい場合、Spresense\nSDK側のコンフィグレーションを変更してArduino用パッケージを作り直せば対応できると思います。\n\n * 受信バッファ: CONFIG_UART2_RXBUFSIZE\n * 送信バッファ: CONFIG_UART2_TXBUFSIZE\n\nArduino用パッケージの作り方はマニュアルを参考にしてください。 \n[Spresense Arduino board package\nパッケージのローカルインストール](https://developer.sony.com/develop/spresense/docs/arduino_set_up_ja.html#_spresense_arduino_board_package_%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%81%AE%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB)\n\n[Spresense\nSDKのコンフィグレーションを変更する場合](https://developer.sony.com/develop/spresense/docs/arduino_set_up_ja.html#_spresense_sdk%E3%81%AE%E3%82%B3%E3%83%B3%E3%83%95%E3%82%A3%E3%82%B0%E3%83%AC%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%99%E3%82%8B%E5%A0%B4%E5%90%88)の方法で、`menuconfig`\nを開いて、`Receive buffer size` や `Transmit buffer size`を256から変更してみてください。\n\n```\n\n -> Device Drivers\n -> Serial Driver Support\n -> UART2 Configuration\n (256) Receive buffer size\n (256) Transmit buffer size\n \n```\n\nあとは手順通りにビルドしてローカルパッケージを作成して、そのパッケージをインストールすればバッファサイズを拡張できるようになると思います。\n\n私はマニュアルをみながらパッケージを作成できましたが、少々難易度が高めです。それと開発環境はLinuxかMac環境を使うことをオススメします。Windowsだと処理が遅すぎてパッケージ作成にかなり時間がかかってしまいます(自分がハマったので)。参考まで。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T10:15:38.480",
"id": "83490",
"last_activity_date": "2021-11-08T10:15:38.480",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31378",
"parent_id": "83441",
"post_type": "answer",
"score": 0
}
] | 83441 | 83490 | 83490 |
{
"accepted_answer_id": "83443",
"answer_count": 1,
"body": "# 環境\n\nPython3.9\n\n# やりたいこと\n\n文字列の集合体を受け取る関数を作りたいです。 \n関数内では、`len`と`for`文を使います。\n\n`len`と`for`文しかないので、list以外の要素も受け取れるようにしたいです。 \nたとえば、以下の型はすべてサポートしたいです。\n\n * list\n * set\n * numpy.ndarray\n\n# 質問\n\nこの場合、引数にはどのような型ヒントを付けるべきでしょうか? \n以下のように`Union`を使えば、複数の型を指定できますが、可読性があまりよろしくありません。\n\n```\n\n def foo(user_ids: Union[Set[str],List[str], numpy.ndarray]):\n print(f\"length{len(user_ids)})\n for user_id in user_ids:\n print(user_id)\n \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T14:34:58.977",
"favorite_count": 0,
"id": "83442",
"last_activity_date": "2021-11-05T15:43:36.570",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19524",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "`len`とfor文からしか使われな引数には、どんな型ヒントを付けるべきか?",
"view_count": 231
} | [
{
"body": "<https://docs.python.org/ja/3/library/collections.abc.html>\n\n`__iter__`と`__len__`をサポートする[collections.abc.Collection](https://docs.python.org/ja/3/library/collections.abc.html#collections.abc.Collection)\nでいいと思います。\n\n```\n\n from collections.abc import Collection\n \n def foo(user_ids: Collection[str]):\n ...\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T15:43:36.570",
"id": "83443",
"last_activity_date": "2021-11-05T15:43:36.570",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12274",
"parent_id": "83442",
"post_type": "answer",
"score": 2
}
] | 83442 | 83443 | 83443 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "htmlファイル上でphpを有効にしています。 \nしかし、includeでtxtファイルは呼び出せますがphpファイルが呼び出せません。\n\nレンタルサーバに問合せたところ、`.htaccess` 上で設定可能、回答範囲外とのこと。\n\n**実行環境:** \nphp 7.4\n\n.htaccessの記述(該当部分)\n\n```\n\n AddType application/x-httpd-php .php .html\n \n```\n\nhtmlファイルの記述(該当部分)\n\n 1. 動作するケース\n``` include 'sample.txt';\n\n \n```\n\n 2. 動作しないケース\n``` include 'sample.php';\n\n \n```\n\n(2)で動作させるにはどうすればよいでしょうか。 \n宜しくお願いします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-05T22:34:10.273",
"favorite_count": 0,
"id": "83444",
"last_activity_date": "2021-12-15T21:11:04.980",
"last_edit_date": "2021-11-06T05:59:34.617",
"last_editor_user_id": "3060",
"owner_user_id": "48965",
"post_type": "question",
"score": 0,
"tags": [
"php",
"html"
],
"title": "html ファイルから include で php ファイルの呼び出しが動作しません",
"view_count": 377
} | [
{
"body": "sample.txtがincludeできている時点で、.htaccessの設定はうまくいっています。 \nまずincludeしているPHPファイルに以下を追加してエラーを確認するべきです。\n\n```\n\n error_reporting(E_ALL);\n ini_set(\"display_errors\", 1);\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-12-15T17:39:54.327",
"id": "84156",
"last_activity_date": "2021-12-15T21:11:04.980",
"last_edit_date": "2021-12-15T21:11:04.980",
"last_editor_user_id": "38398",
"owner_user_id": "38398",
"parent_id": "83444",
"post_type": "answer",
"score": 0
}
] | 83444 | null | 84156 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "現在rubyの環境構築をwindows10を使って試しているのですが以下の手順をして文字コード関係のエラー?に手こずっていて質問致しました。\n\n以下の順にインストール\n\nruby3.0.0 \nnode.js \nyarn \nsqlite3 \nrails6.1.3\n\nその後、`rails new app` をしてディレクトリに移動後に `rails webpacker:install`\nを実行したのですが以下のエラーが発生してしまいました。\n\n```\n\n Ruby30-x64/lib/ruby/3.0.0/pathname.rb:50:in match? :invalid byte sequence in utf-8 (ArgumentError)\n \n```\n\n対処方法として以下のコードをcmdで試してみたのですが効果ありませんでした。\n\n```\n\n Encoding.default_external = 'UTFー8'\n \n```\n\nその他には使用しているwindows10のバージョンとインストールしたrubyのバージョンが違ってないかを確認しましたが合っていたので違いました。 \nどなたか分かる方がいましたらご教授よろしくお願い致します。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T04:24:34.400",
"favorite_count": 0,
"id": "83447",
"last_activity_date": "2021-11-08T13:06:38.760",
"last_edit_date": "2021-11-06T06:04:09.107",
"last_editor_user_id": "3060",
"owner_user_id": "44830",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"windows"
],
"title": "windows10でのrubyの環境構築の際の文字コードエラーの対処方法について",
"view_count": 404
} | [
{
"body": "Windowsの日本語版ではいわゆるCP932という文字コードをつかっており、ユーザー名などが日本語だと不整合が起きてエラーが発生します。 \n回避方法としては、システムの設定の地域ダイアログで「システムロケールの変更」で「ワールドワイド言語サポートでUnicode\nUTF-8を使用」にチェックを入れることです。 \nただし、Windows上の日本語アプリが文字化けするので推奨しません\n\n次善の策としては、WSL2(Windows Subsystem for Linux)上のUbubtuなどで環境を構築することです",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T13:06:38.760",
"id": "83493",
"last_activity_date": "2021-11-08T13:06:38.760",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "44341",
"parent_id": "83447",
"post_type": "answer",
"score": 0
}
] | 83447 | null | 83493 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "編集画面で更新したい内容に値を変え、実行ボタンを押すと \"No value present\"\nといったエラーが表示されてしまうため、こちらの改善を行いたいです。\n\n以下のサイトを参考にしてSpring bootでの更新を行おうと考えています。\n\n[SpringBoot入門 vol.14:編集と削除機能を追加しよう](https://learning-\ncollection.com/springboot%e5%85%a5%e9%96%80-vol-14%ef%bc%9a%e7%b7%a8%e9%9b%86%e3%81%a8%e5%89%8a%e9%99%a4%e6%a9%9f%e8%83%bd%e3%82%92%e8%bf%bd%e5%8a%a0%e3%81%97%e3%82%88%e3%81%86/)\n\nこちらのサイトはテーブルが一つの更新ですが、私が行いたいのは二つのテーブルを同時に更新できるものです。そこの違いでもしかしたらアクシデントが起きているのかもしれませんが、いまいち原因を突き止められません。 \nご教授いただけませんでしょうか。\n\n**コントロールクラス**\n\n```\n\n @PostMapping(\"search\")\n public String index(\n @RequestParam String id,\n @RequestParam String name,\n @RequestParam String kana,\n @ModelAttribute CreateForm createForm,\n @Validated @ModelAttribute SearchForm searchForm,\n BindingResult result,\n Model model,\n HttpServletRequest request) {\n List<Userdetail> search = equipmentRepository.find(id, name, kana);\n BeanUtils.copyProperties(createForm, search);\n HttpSession session = request.getSession();\n session.setAttribute(\"search\", search);\n model.addAttribute(\"search\", search);\n if (result.hasErrors()) {\n return \"search\";\n }\n return \"searchout\";\n }\n \n @PostMapping(path = \"update\", params = \"update\")\n String update(@RequestParam String id, @ModelAttribute CreateForm createForm) {\n Optional<User> opt = sevi.selectById(id);\n User u = opt.get();\n BeanUtils.copyProperties(u, createForm);\n return \"update\";\n }\n \n @PostMapping(path = \"update\", params = \"back\")\n String back() {\n return \"redirect:/\";\n }\n \n @PostMapping(path = \"update\", params = \"regist\")\n //ポイント2\n String regist(@RequestParam String id, @Validated @ModelAttribute CreateForm createForm, BindingResult result,Model model) {\n if (result.hasErrors()) {\n return update(id, createForm);\n }\n User user = new User();\n //Userdetail userdetail = new Userdetail();\n BeanUtils.copyProperties(createForm, user);\n // BeanUtils.copyProperties(createForm, userdetail);\n sevi.update(user);\n //sevi.updatee(userdetail);\n model.addAttribute(\"searchForm\", new SearchForm());\n return \"search\";\n }\n \n```\n\nメソッドindexあたりから自分は二つのテーブルを使いだしました。 \n下はリポジトリクラスに記載しているメソッドindexで使っている \nequipmentRepository.findの中身です。\n\n```\n\n @Query(\"SELECT DISTINCT e FROM Userdetail e INNER JOIN e.user WHERE e.user.id LIKE CONCAT(:id,'%') and e.user.name LIKE CONCAT(:name,'%') and e.user.kana LIKE CONCAT(:kana,'%') ORDER BY e.id\")\n List<Userdetail> find(@Param(\"id\") String id,\n @Param(\"name\") String name,\n @Param(\"kana\") String kana);\n \n```\n\n**テーブル**\n\n```\n\n @Entity\n @Table(name=\"user\")\n @Getter\n @Setter\n @AllArgsConstructor\n @NoArgsConstructor\n public class User implements Serializable {\n \n @Id\n @Column(name=\"id\")\n \n //@GeneratedValue(strategy=GenerationType.IDENTITY)\n private String id;\n \n @Column(name = \"pass\")\n private String pass;\n @Column(name = \"name\")\n private String name;\n @Column(name = \"kana\")\n private String kana;\n \n @OneToMany(mappedBy=\"user\", cascade=CascadeType.ALL)\n private List<Userdetail> userdetail;\n \n }\n \n```\n\n```\n\n @Entity\n @Table(name=\"userdetail\")\n @Getter\n @Setter\n @AllArgsConstructor\n @NoArgsConstructor\n public class Userdetail implements Serializable{\n @Id\n @GeneratedValue(strategy=GenerationType.AUTO)\n private int no;\n private String id;\n private String birth;\n private String club;\n @ManyToOne\n @JoinColumn(name = \"ID\",insertable = false, updatable = false)\n private User user;\n }\n \n```\n\n**編集画面(update.html)**\n\n```\n\n <!DOCTYPE html>\n <html xmlns:th=\"http://www.thymeleaf.org\">\n <head>\n <!-- scripts import -->\n <script th:src=\"@{/webjars/jquery/3.5.1/jquery.min.js}\"></script>\n <script\n th:src=\"@{/webjars/bootstrap/4.4.1-1/js/bootstrap.bundle.min.js}\"></script>\n <!-- style import -->\n <link th:href=\"@{/webjars/bootstrap/4.4.1-1/css/bootstrap.css}\"\n rel=\"stylesheet\" />\n <link th:href=\"@{/css/login.css}\" rel=\"stylesheet\" />\n <meta charset=\"UTF-8\">\n <title>Insert title here</title>\n </head>\n <body>\n <div class=\"col-sm-5\">\n <div class=\"page-header\">\n <h1>編集画面</h1>\n </div>\n <form th:action=\"@{/update}\" th:object=\"${createForm}\" method=\"post\">\n <table class=\"table table-bordered table-hover\">\n <!-- ユーザーID -->\n <tr>\n <th class=\"active col-sm-3\">ユーザID</th>\n <td><input type=\"text\" class=\"form-control\" name=\"id\"\n th:field=\"*{id}\"\n th:classappend=\"${#fields.hasErrors('id')} ? 'is-invalid'\">\n <span class=\"text-danger\" th:if=\"${#fields.hasErrors('id')}\"\n th:errors=\"*{id}\"></span></td>\n </tr>\n <!-- 名前 -->\n <tr>\n <th class=\"active\">名前</th>\n <td>\n <input type=\"text\" class=\"form-control\" name=\"name\"\n th:field=\"*{name}\"\n th:classappend=\"${#fields.hasErrors('name')} ? 'is-invalid'\">\n <span class=\"text-danger\" th:if=\"${#fields.hasErrors('name')}\"\n th:errors=\"*{name}\"></span>\n </td>\n </tr>\n <!-- カナ -->\n <tr>\n <th class=\"active\">カナ</th>\n <td>\n <input type=\"text\" class=\"form-control\" name=\"kana\"\n th:field=\"*{kana}\"\n th:classappend=\"${#fields.hasErrors('kana')} ? 'is-invalid'\">\n <span class=\"text-danger\" th:if=\"${#fields.hasErrors('kana')}\"\n th:errors=\"*{kana}\"></span>\n </td>\n </tr>\n <!-- 生年月日 -->\n <tr>\n <th class=\"active\">生年月日(yyyy/mm/dd)</th>\n <td>\n <input type=\"text\" class=\"form-control\" name=\"birth\"\n th:field=\"*{birth}\"\n th:classappend=\"${#fields.hasErrors('birth')} ? 'is-invalid'\">\n <span class=\"text-danger\" th:if=\"${#fields.hasErrors('birth')}\"\n th:errors=\"*{birth}\"></span>\n </td>\n </tr>\n <!-- 委員会 -->\n <tr>\n <th class=\"active\">委員会</th>\n <td>\n <input type=\"text\" class=\"form-control\" name=\"club\"\n th:field=\"*{club}\"\n th:classappend=\"${#fields.hasErrors('club')} ? 'is-invalid'\">\n <span class=\"text-danger\" th:if=\"${#fields.hasErrors('club')}\"\n th:errors=\"*{club}\"></span>\n </td>\n </tr>\n </table>\n <input type=\"submit\" class=\"btn btn-outline-dark mt-3\" name=\"back\" value=\"戻る\">\n <input type=\"submit\" class=\"btn btn-primary mt-3\" name=\"regist\" value=\"実行\">\n <input type=\"hidden\" name=\"id\" th:value=\"${param.id[0]}\">\n </form>\n </div>\n \n </body>\n </html>\n \n```\n\n**編集画面(update.html)に遷移するまえのsearchout.html**\n\n```\n\n <!DOCTYPE html>\n <html xmlns:th=\"http://www.thymeleaf.org\">\n <head>\n <meta charset=\"utf-8\" />\n <title>検索画面</title>\n </head>\n <body>\n <h2>社員情報検索</h2>\n <h3>※前方一致で検索します</h3>\n <form action=\"#\" th:action=\"@{/search}\" th:object=\"${searchForm}\"\n method=\"post\">\n <table>\n <tr>\n <td>id: <input type=\"text\" name=\"id\" th:field=\"*{id}\" /><br>\n <span th:if=\"${#fields.hasErrors('id')}\" th:errors=\"*{id}\"></span>\n </td>\n </tr>\n <tr>\n <td>名前:<input type=\"text\" name=\"name\" th:field=\"*{name}\" /><br>\n <span th:if=\"${#fields.hasErrors('name')}\" th:errors=\"*{name}\"></span>\n </td>\n </tr>\n <tr>\n <tr>\n <td>カナ:<input type=\"text\" name=\"kana\" th:field=\"*{kana}\" /><br>\n <span th:if=\"${#fields.hasErrors('kana')}\" th:errors=\"*{kana}\"></span>\n </td>\n </tr>\n <tr>\n <td><button type=\"submit\">検索</button></td>\n </tr>\n </table>\n </form>\n <button type=\"submit\" class=\"btn btn--blue\"\n onClick=\"location.href='http://localhost:8080/create'\">新規登録</button>\n \n <table>\n <tr>\n <th>ID</th>\n <th>名前</th>\n <th>カナ</th>\n <th>生年月日</th>\n <th>委員会</th>\n <th>操作</th>\n </tr>\n <tr th:each=\"search:${search}\">\n <td th:text=\"${search.user.id}\">\n <td th:text=\"${search.user.name}\">\n <td th:text=\"${search.user.kana}\">\n <td th:text=\"${search.birth}\">\n <td th:text=\"${search.club}\">\n <td>\n <form th:action=\"@{/update}\" method=\"post\">\n <input type=\"submit\" name=\"update\" value=\"編集\">\n <input type=\"hidden\" name=\"birth\" th:value=\"${search.birth}\"> <!-- ←これするとupdate.htmlに遷移したとき-->\n <input type=\"hidden\" name=\"club\" th:value=\"${search.club}\"> <!-- テキストボックスに文字はいる-->\n <input type=\"hidden\" name=\"id\" th:value=\"${search.user.id}\">\n </form>\n </td>\n <td>\n <form th:action=\"@{/delete}\" method=\"post\">\n <input type=\"submit\" name=\"delete\" value=\"削除\">\n <input type=\"hidden\" name=\"id\" th:value=\"${search.user.id}\">\n </form>\n </td>\n </table>\n </body>\n </html>\n \n```\n\n**サービスクラス**\n\n```\n\n public void update(User user) {\n userRepository.save(user);\n }\n public void updatee(Userdetail userdetail) {\n userdetailRepository.save(userdetail);\n }\n \n```\n\n**searchout.htmlからupdate.htmlに遷移したさいのupdate.html画面**\n\n値が初めから入っている仕様です\n\n[](https://i.stack.imgur.com/vnJgu.png) \n[![画像の説明をここに入力][2]][2]",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T04:40:27.660",
"favorite_count": 0,
"id": "83449",
"last_activity_date": "2021-11-06T16:22:30.033",
"last_edit_date": "2021-11-06T06:08:52.413",
"last_editor_user_id": "3060",
"owner_user_id": "48204",
"post_type": "question",
"score": 0,
"tags": [
"java",
"mysql",
"spring",
"spring-boot"
],
"title": "Springで更新を行った際にでてくるNo value presentといったエラーを改善したい",
"view_count": 3522
} | [
{
"body": "> \"No value present\" といったエラー\n\nこれは\n[`Optional#get()`](https://docs.oracle.com/javase/jp/11/docs/api/java.base/java/util/Optional.html#get\\(\\))\nメソッドを実行し、値が無かった場合に送出される `NoSuchElementException` のメッセージだと思います。\n\nこのメソッドを利用しているのは、質問コード中では1箇所なので、該当の例外はここで発生していると考えます(違うのであれば、その旨質問文に追記してください):\n\n```\n\n @PostMapping(path = \"update\", params = \"update\")\n String update(@RequestParam String id, @ModelAttribute CreateForm createForm) {\n Optional<User> opt = sevi.selectById(id);\n User u = opt.get();\n BeanUtils.copyProperties(u, createForm);\n return \"update\";\n }\n \n```\n\n`sevi.selectById(id)` は、おそらく、`id` をキーにした `User` 検索で、該当する `User`\nがいない場合に空になるのでしょう。\n\n該当する `User` がいた場合にだけ処理するには次のような実装になります:\n\n```\n\n Optional<User> opt = sevi.selectById(id);\n opt.ifPresent(u -> BeanUtils.copyProperties(u, createForm));\n return \"update\";\n \n```\n\n参考: [Java Optional (Google\n検索結果)](https://www.google.com/search?q=Java+Optional&lr=lang_ja)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T16:22:30.033",
"id": "83456",
"last_activity_date": "2021-11-06T16:22:30.033",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"parent_id": "83449",
"post_type": "answer",
"score": 1
}
] | 83449 | null | 83456 |
{
"accepted_answer_id": "83462",
"answer_count": 5,
"body": "C言語で以下のソースを実行したらtest1に0.80000000000000004と末尾に期待しない4が入っていて困っています。\n\n```\n\n int main()\n {\n double test1 = 80 * 0.01;\n return 0;\n }\n \n```\n\n環境は、Windows10、Visual Studio 2019です。\n\nfloatやdouble小数点以下の値には誤差が含まれる可能性があり、それによって誤差が含まれる可能性があることは分かりましたが、その誤差をどうやってなくすことができるかがわかりませんでした。\n\n解決のためのアドバイスを頂けましたら、よろしくお願いします。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T06:28:53.120",
"favorite_count": 0,
"id": "83451",
"last_activity_date": "2021-11-08T13:05:35.067",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21034",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "C言語でint型とdouble型のかけ算の結果がおかしい",
"view_count": 1928
} | [
{
"body": "double型では誤差をなくすことはできません。 \n10進数の計算の場合では1を3で割ると0.333333333....となりそれに3をかけても0.999999....となりますので誤差が出ることがわかりやすいのですが、コンピュータの内部では2進数に変換され計算されますので、10進数ではあり得ない誤差が発生します。 \nこれは精度を上げることはできても、完全になくすことはできません。 \n10進数での誤差が許容できるのであれば10進演算ライブラリを使えばいいと思います。 \n下記にいろいろな演算ライブラリの説明がありますので参考にしてみてください。 \n<https://ja.wikipedia.org/wiki/%E4%BB%BB%E6%84%8F%E7%B2%BE%E5%BA%A6%E6%BC%94%E7%AE%97#%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA>",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T07:31:23.540",
"id": "83452",
"last_activity_date": "2021-11-06T07:31:23.540",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24490",
"parent_id": "83451",
"post_type": "answer",
"score": 2
},
{
"body": "予め元の値の (小数点以下の) 桁数が分かっているなら、それに合わせて結果も `printf` 等で桁数を指定して参照するのが簡単な気がします。\n\n```\n\n printf(\"%.2f\", test1);\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T08:19:40.800",
"id": "83453",
"last_activity_date": "2021-11-06T08:19:40.800",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "83451",
"post_type": "answer",
"score": 0
},
{
"body": "他の方の回答にもあるように, 10進数では `10/3` や `10/7` などの循環小数があり, 無限の桁数がなければ正確な数値を保持できません(3倍,\n7倍しても元の数値には戻らない)。同様に(コンピューター内でよく使わている) 2進数も, `0.1`\nという浮動小数点数は循環小数になり正しい値を保持出ません。\n\n * 値の範囲が限定的であれば, 固定少数点数で扱う方法がある。例えば, 内部処理はずっと 100倍した値で扱い (`80 * 1`), アウトプット時に調整する, など。\n\n * 十進演算を行う方法 … 各種プログラミング言語で, 十進演算ライブラリーが用意されているはず。それらは計算精度が高い, もしくは計算精度を指定できることも多く, 誤差が出にくい \n参考:\n[https://ja.wikipedia.org/wiki/任意精度演算](https://ja.wikipedia.org/wiki/%E4%BB%BB%E6%84%8F%E7%B2%BE%E5%BA%A6%E6%BC%94%E7%AE%97)\n\n * 例えば Pythonには [fractions --- 有理数](https://docs.python.org/ja/3/library/fractions.html) モジュールがあり, 分数の形で持つことで(計算途中までは)正しく値を保持できる可能性が高い (アウトプット時 小数点数に変換する際に誤差が出てくるかもだが) … この様なライブラリーを探すか作るかする",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T09:30:39.287",
"id": "83454",
"last_activity_date": "2021-11-06T09:30:39.287",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43025",
"parent_id": "83451",
"post_type": "answer",
"score": 1
},
{
"body": "十進数の表現をそのまま計算したいと言うことであってますでしょうか?\n\nCの浮動小数点数の型である`float`、`double`、`long\ndouble`はその実装形式や基数がいくつであるかは言語仕様では決められていません。しかし、ほとんどの環境では、[IEEE\n754](https://ja.wikipedia.org/wiki/IEEE_754)の形式を採用しており、`float`はbinary32(単精度浮動小数点数)、`double`と`long\ndouble`はbinary64(倍精度浮動小数点数)になっています(`long\ndouble`が80ビットの拡張倍精度浮動小数点数になっている場合があります)。これらの浮動小数点数の形式は基数が2であるため、十進数の小数点数を正確に表現することはできません。つまり、`0.01`は0.01に極めて近い値であっても、正確に0.01では無いと言うことです。これは2の基数の浮動小数点数を使う限り、避ける方法がありません。(IEEE\n754のbinary32やbinary64を採用している理由は、多くのCPUでこれらの形式に対して四則演算等ができる浮動小数点数ユニットを持っているからです。)\n\nでは、どうするかです。先程書きましたが、Cの言語仕様としては、基数が2で無ければならないというわけはなく、基数が10の場合についても言語仕様では言及されています。つまり、浮動小数点数の基数が10になるような環境を探せばいいと言うことです。と、言いたいところですが、基数が10になるような環境は見つけられませんでした。\n\nもう標準で対応できる方法は無いのか…、というと、未来はあります。現在策定中の次のC言語規格であるC23(現在はC2xと言われている)では、基数が10の十進浮動小数点数の型である`_Decimal32`、`_Decimal64`、`_Decimal128`が規程される予定です。これらは既に出版済みのTS\n18661-3でC言語の拡張として載っており、一部のコンパイラ(GCCやIntel\nCompiler等)で部分的に実装されています。通常の`dobule`(binary64)では`0.1`と`0.2`を足しても`0.3`と等しくなりませんが、`_Decimal64`(decimal64)では、等しくなります。\n\n```\n\n #include <stdio.h>\n int main(void)\n {\n double a = 0.1 + 0.2;\n _Decimal64 b = 0.1dd + 0.2dd;\n printf(\"%d\\n\", a == 0.3); // not equal => 0\n printf(\"%d\\n\", b == 0.3dd); // equal => 1\n return 0;\n }\n \n```\n\n※最新のGCCやIntel Compiler等で試してください。古いバージョンやVisual\nC++等ではエラーになる場合があります。Clangもまだ対応はしていないようです。Visual\nStudioで試すとなると、[カスタムビルドでGCCを使う](https://stackoverflow.com/questions/14768073/how-\nto-use-gcc-with-microsoft-visual-studio)といった方法が必要になるようです。\n\nただ、`printf`等で十進浮動小数点数を表示する`%Da`といった表現はGCCではまだ実装されていないようで、実用的にどこまで使えるかわかりません。また、CPUが十進浮動小数点数に対応した計算ユニットや命令に対応していない場合、通常の浮動小数点数に比べて非常に計算が遅くなる場合があります。なお、十進浮動小数点数にも精度があります。精度を越えて正確な計算はできませんので、その点はご理解ください。\n\n`_Decimal64`等で対応していないコンパイラの場合は、Cの標準で直接扱う方法はありませんので、外部ライブラリを使うしかありません。軽く探してみましたが、[libdfp](https://github.com/libdfp/libdfp)というのがあるようです。任意精度が欲しい場合は[mpdecimal](https://www.bytereef.org/mpdecimal/)がいいかもしれません。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T00:16:21.870",
"id": "83462",
"last_activity_date": "2021-11-08T13:05:35.067",
"last_edit_date": "2021-11-08T13:05:35.067",
"last_editor_user_id": "7347",
"owner_user_id": "7347",
"parent_id": "83451",
"post_type": "answer",
"score": 5
},
{
"body": "質問の範囲から多少外れますが参考情報として。\n\nVisual Studio 2019とのことなので、[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\")\n言語ではありませんが [c++-cli](/questions/tagged/c%2b%2b-cli \"'c++-cli' のタグが付いた質問を表示\")\n言語が使えます。C++/CLI言語は.NET Framework上で動作するため、10進演算を行う\n[`System::Decimal`](https://docs.microsoft.com/ja-\njp/dotnet/api/system.decimal?view=netframework-4.8) が標準で使えます。\n\n```\n\n #include <stdio.h>\n #include <vcclr.h>\n \n static inline auto operator \"\"_m(const char* literal) {\n return System::Decimal::Parse(gcnew System::String(literal));\n }\n \n int main() {\n auto test1 = 80 * 0.01_m;\n pin_ptr<const wchar_t> str = PtrToStringChars(test1.ToString());\n wprintf(L\"%s\\n\", str);\n return 0;\n }\n \n```\n\nちなみに.NET Frameworkの `System::Decimal` は有効精度も保持しているので、 `0.80` が得られます(例えば\n`0.0100_m` に変更すると結果は `0.8000` になります)。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T06:30:03.790",
"id": "83469",
"last_activity_date": "2021-11-08T13:04:18.003",
"last_edit_date": "2021-11-08T13:04:18.003",
"last_editor_user_id": "4236",
"owner_user_id": "4236",
"parent_id": "83451",
"post_type": "answer",
"score": 1
}
] | 83451 | 83462 | 83462 |
{
"accepted_answer_id": "83459",
"answer_count": 2,
"body": "C#で、次のように文字列を分割すると、stArrayに5つの要素が入ります。\n\n```\n\n string testString = \"a,b,c,d,e\";\n string[] strArray = testString.Split(',');\n \n```\n\nこれを最初の','だけ分割して、\"a\"と\"b,c,d,e\"に分割して \n\"b,c,d,e\"の部分だけ取得するにはどうしたら良いですか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T21:52:54.200",
"favorite_count": 0,
"id": "83457",
"last_activity_date": "2021-11-07T01:13:57.907",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34471",
"post_type": "question",
"score": 1,
"tags": [
"c#"
],
"title": "C#で文字列を1つだけ分割する方法",
"view_count": 1607
} | [
{
"body": "[String.Split メソッド](https://docs.microsoft.com/ja-\njp/dotnet/api/system.string.split?view=net-5.0#System_String_Split_System_Char___System_Int32_)を見ればわかりますが、複数のオーバーロードが用意されています。必要な機能を持つバージョンを選択してください。具体的には\n[`Split(Char[], Int32)`](https://docs.microsoft.com/ja-\njp/dotnet/api/system.string.split?view=net-5.0#System_String_Split_System_Char___System_Int32_)\nが該当します。\n\n* * *\n\nなお、\n\n>\n```\n\n> testString.Split(',');\n> \n```\n\nとありますが、こちらは [`Split(Char[])`](https://docs.microsoft.com/ja-\njp/dotnet/api/system.string.split?view=net-5.0#System_String_Split_System_Char___)\nであり具体的には\n\n```\n\n public string[] Split (params char[]? separator);\n \n```\n\nという形式です。引数は `','` と記述していますが、C#コンパイラは [`params`](https://docs.microsoft.com/ja-\njp/dotnet/csharp/language-reference/keywords/params) 指定を受けて引数を `new Char[1] {\n',' }` と読み替えてコンパイルしています。\n\n対して、 `Split(Char[], Int32)` は\n\n```\n\n public string[] Split (char[]? separator, int count);\n \n```\n\nという形式でこちらは `params`\n指定がありません(`params`は最終引数にしか使えないため)。C#コンパイラは前述のような読み替えはありませんので、明示的に記述する必要があります。最終的には次のような記述になるかと思います。\n\n```\n\n var strArray = testString.Split(new []{ ',' }, 2);\n \n```\n\n* * *\n\n> \"b,c,d,e\"の部分だけ取得するには\n\nという質問に答えて `String.IndexOf` および `String.Substring`\nを組み合わせた回答が投稿されています。もちろんこれらも希望を満たす結果となっていますが、別アプローチも提案します。\n\n正規表現を使用することで、条件を満たした文字列を抽出することができます。例えば\n\n```\n\n var m1 = Regex.Match(testString, \"^(?:([^,]*),){1}(.*)\");\n \n```\n\nと書けます。`m1`は次のような値が格納されます。\n\n * `m1.Groups[1].Captures[0].Value` = `\"a\"`\n * `m1.Groups[2].Value` = `\"b,c,d,e\"`\n\nこの方法ですと分割数を変更したくなった場合も簡単です。\n\n```\n\n var m2 = Regex.Match(testString, \"^(?:([^,]*),){2}(.*)\");\n \n```\n\nと変更すると`m2`は次のような値が格納されます。\n\n * `m2.Groups[1].Captures[0].Value` = `\"a\"`\n * `m2.Groups[1].Captures[1].Value` = `\"b\"`\n * `m2.Groups[2].Value` = `\"c,d,e\"`\n\n`String.IndexOf` + `String.Substring` ではここまで柔軟な動作をさせることができません。\n\nなおこの正規表現は手抜きをしていて改行が含まれていると正しく動作しません。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T22:49:59.443",
"id": "83459",
"last_activity_date": "2021-11-07T01:13:57.907",
"last_edit_date": "2021-11-07T01:13:57.907",
"last_editor_user_id": "4236",
"owner_user_id": "4236",
"parent_id": "83457",
"post_type": "answer",
"score": 5
},
{
"body": "これでどうでしょうか?\n\n```\n\n string testString = \"a,b,c,d,e\";\n \n // 最初の','の位置\n int i = testString.IndexOf(',');\n \n // 最初の位置より後を切り出す\n string s = testString.Substring(i + 1);\n \n // b,c,d,e\n Console.WriteLine(s);\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T22:55:25.417",
"id": "83461",
"last_activity_date": "2021-11-06T22:55:25.417",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4982",
"parent_id": "83457",
"post_type": "answer",
"score": 0
}
] | 83457 | 83459 | 83459 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "使用するデータは多少簡略化していますが、以下のようなものです。\n\nname year ... \nA社 1999 ... \nA社 2000 ... \nA社 2001 ... \nA社 2002 ... \nB社 1999 ... \nB社 2000 ... \nC社 2001 ... \nC社 2002 ... \nD社 1999 ... \nD社 2000 ... \nD社 2001 ... \nE社 2002 ...\n\nこの中から1999年∼2001年のデータが'全て'揃っている企業のみを新しいデータフレームに保存したいです。目標は以下の形になります。 \nname year ... \nA社 1999 ... \nA社 2000 ... \nA社 2001 ... \nD社 1999 ... \nD社 2000 ... \nD社 2001 ...",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-06T22:16:03.447",
"favorite_count": 0,
"id": "83458",
"last_activity_date": "2021-11-08T18:17:23.433",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48973",
"post_type": "question",
"score": 0,
"tags": [
"r"
],
"title": "完全パネルデータの作成にあたり、観測期間(年次データ)のすべてが揃った個体のデータのみを、新しいデータフレームに保存したいです",
"view_count": 78
} | [
{
"body": "**標準関数**\n\n```\n\n dfx <- do.call('rbind',\n c(by(df, df$name, function(x) {\n f <- x$year %in% 1999:2001\n if (sum(f)==3) x[f,]\n }), make.row.names=F))\n \n print(dfx)\n #\n name year\n 1 A社 1999\n 2 A社 2000\n 3 A社 2001\n 5 D社 1999\n 6 D社 2000\n 7 D社 2001\n \n```\n\n**dplyr**\n\n```\n\n library(dplyr)\n \n dfx <-\n df %>%\n group_by(name) %>%\n filter({f=year %in% 1999:2001;sum(f)==3&f})\n \n print(dfx)\n #\n # A tibble: 6 x 2\n # Groups: name [2]\n name year\n <chr> <dbl>\n 1 A社 1999\n 2 A社 2000\n 3 A社 2001\n 4 D社 1999\n 5 D社 2000\n 6 D社 2001\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T01:23:40.500",
"id": "83464",
"last_activity_date": "2021-11-07T01:43:19.537",
"last_edit_date": "2021-11-07T01:43:19.537",
"last_editor_user_id": "47127",
"owner_user_id": "47127",
"parent_id": "83458",
"post_type": "answer",
"score": 1
},
{
"body": "パネルデータとして扱いたいということなら, たぶん plm パッケージを使っていると思います. よって一般に完全 (バランスド) パネルデータを作成する\n`make.pbalanced` を使えば良いと思います. ただし今回は1999-2001年に絞るという特殊な条件も課しているので,\nまず年インデックスで絞り込んでから適用することになります.\n\n```\n\n require(plm)\n d <- pdata.frame(d, index = c(\"name\", \"year\"), row.names = F)\n make.pbalanced(subset(d, year %in% 1999:2001), \"shared.individuals\")\n \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T18:17:23.433",
"id": "83494",
"last_activity_date": "2021-11-08T18:17:23.433",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "40575",
"parent_id": "83458",
"post_type": "answer",
"score": 1
}
] | 83458 | null | 83464 |
{
"accepted_answer_id": "83466",
"answer_count": 1,
"body": "Pyhonでimaplibのライブラリーを使って、Gmailを取得しています。 \nGMAILのボックスモデル(ボーダー)から本文を取得したいですが、下記のように本文のみ文字化けしてしまいます。 \n差出人、タイトルの取得は特に問題なく取得できます。\n\n文字コードを **iso-2022-jp** 、 **UTF-8** 、 **SHIFT JIS** 、 **ascii**\nへ変更しても同じ本文のみ文字化けします。\n\n文字化けしない方法ありますでしょうか。 \nもし分かる方がいましたら、教えて頂けると幸いです。\n\nCODE\n\n```\n\n import imaplib, re, email, six, dateutil.parser\n \n mail=imaplib.IMAP4_SSL('imap.gmail.com',993) #SMTPは993,POPは995\n mail.login('[email protected]','12134')\n mail.select() #メールボックスの選択\n \n #UNSEEN未読メールを読み込む\n # type,data=mail.search(None,'UNSEEN') #メールボックス内にあるすべてのデータを取得ALL\n \n #特定のメールUNSEEN未読メールを読み込む\n term = u\"【Test\".encode(\"utf-8\")\n mail.literal = term\n type,data=mail.search(\"utf-8\", \"UNSEEN SUBJECT\")\n \n for i in data[0].split(): #data分繰り返す\n ok,x=mail.fetch(i,'RFC822') #メールの情報を取得\n #mail文字コード指定\n ms=email.message_from_string(x[0][1].decode('iso-2022-jp')) #パースして取得\n \n #差出人を取得\n ad=email.header.decode_header(ms.get('From'))\n ms_code=ad[0][1]\n if(ms_code!=None):\n address=ad[0][0].decode(ms_code)\n address+=ad[1][0].decode(ms_code)\n else:\n address=ad[0][0]\n \n #タイトルを取得\n sb=email.header.decode_header(ms.get('Subject'))\n ms_code=sb[0][1]\n if(ms_code!=None):\n sbject=sb[0][0].decode(ms_code)\n else:\n ms_code=sb[1][1]\n sbject=sb[1][0].decode(ms_code)\n \n #本文を取得\n if ms.is_multipart():\n for payload in ms.get_payload():\n if payload.get_content_type() == \"text/plain\":\n body = payload.get_payload()\n \n else:\n if ms.get_content_type() == \"text/plain\":\n body = ms.get_payload()\n \n #メールの日時を取得\n time = dateutil.parser.parse(ms.get('Date')).strftime(\"%Y-%m-%d %H:%M\")[:-1]\n time_comment = dateutil.parser.parse(ms.get('Date')).strftime(\"%Y-%m-%d %H:%M\")\n \n print(time)\n \n #出力\n print(sbject)\n print(address)\n print(body)\n \n```\n\n出力結果\n\n```\n\n 2021-11-05 09:2\n Test\n [email protected]\n \n VEVTVOOAgA0KVEVTVOODgeOCseODg+ODiOOBp+OBmeOAgg==\n \n```\n\nお手数ですが、よろしくお願い致します。\n\n[](https://i.stack.imgur.com/No2rW.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T04:48:09.390",
"favorite_count": 0,
"id": "83465",
"last_activity_date": "2021-11-08T06:04:49.803",
"last_edit_date": "2021-11-08T06:04:49.803",
"last_editor_user_id": "18859",
"owner_user_id": "18859",
"post_type": "question",
"score": 1,
"tags": [
"python",
"gmail"
],
"title": "PythonでGMAILの本文を日本語で取得したい",
"view_count": 1049
} | [
{
"body": "Base64 エンコードされているだけです。得られたメッセージボディの文字列をデコードすれば完了です。\n\n簡単な例:\n\n```\n\n import base64\n \n print(base64.b64decode(\n b'VEVTVOOAgA0KVEVTVOODgeOCseODg+ODiOOBp+OBmeOAgg=='\n ).decode())\n \n```\n\n出力:\n\n```\n\n TEST \n TESTチケットです。\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T05:02:27.737",
"id": "83466",
"last_activity_date": "2021-11-08T05:49:20.330",
"last_edit_date": "2021-11-08T05:49:20.330",
"last_editor_user_id": "18859",
"owner_user_id": "7290",
"parent_id": "83465",
"post_type": "answer",
"score": 2
}
] | 83465 | 83466 | 83466 |
{
"accepted_answer_id": "83508",
"answer_count": 1,
"body": "```\n\n A\n \n B\n A\n \n B\n A\n \n```\n\nみたいに値が入ってたり空白になってる列があって\n\n```\n\n |2\n A|3\n B|2\n \n```\n\nみたいに空白を含めて値のカウントを表示したいです\n\n`=QUERY(B2:B, \"SELECT B, COUNT(B) GROUP BY B\")`\n\nみたいにかくと空のエントリはできるのにカウントは0になってしまいます \n空セルをカウントする方法ってないでしょうか",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T05:22:18.533",
"favorite_count": 0,
"id": "83468",
"last_activity_date": "2021-11-09T04:02:55.670",
"last_edit_date": "2021-11-08T01:57:19.777",
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"google-spreadsheet"
],
"title": "スプレッドシート group by で空白セルの数もカウントしたい",
"view_count": 233
} | [
{
"body": "コメントでいただいた通り[こちら](https://webapps.stackexchange.com/a/107305)の回答を参考にして、\n\n```\n\n =ARRAYFORMULA(QUERY({B2:B8,LEN(B2:B8)}, \"SELECT Col1, COUNT(Col2) GROUP BY Col1\"))\n \n```\n\nとすることで空白のカウントもできました\n\nただ下限行も指定しないと終わりがわからないので余分にカウントしてしまうようです",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T04:02:55.670",
"id": "83508",
"last_activity_date": "2021-11-09T04:02:55.670",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "83468",
"post_type": "answer",
"score": 0
}
] | 83468 | 83508 | 83508 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "題記のトライのため、\n\n 1. サンプルスケッチ : UsbMscAndFileOperationのLine 19 ~ Line 25を改造\n\n```\n\n #include <Audio.h>\n #include <SDHCI.h>\n SDClass SD;\n AudioClass *theAudio;\n \n void setup() {\n Serial.begin(115200);\n theAudio = AudioClass::getInstance();\n delay(100);\n theAudio->begin();\n \n```\n\n 2. 実行し、ターミナルに表示された\"Finish USB MSC? (y/n)\"に対して\"y\"を入力すると、以下のメッセージが出力\n\n```\n\n 21:52:44.492 -> up_assert: Assertion failed at file:components/capture/capture_component.cpp line: 801 task: capture0\n 21:52:44.492 -> up_registerdump: R0: 00000001 0d04e558 000000e0 0d050910 0d04e558 0d065108 0d051068 0d05be58\n 21:52:44.492 -> up_registerdump: R8: 0d0384df 00000321 0d0647c0 00000000 00000000 0d065108 0d01a395 0d01a958\n 21:52:44.492 -> up_registerdump: xPSR: 61000000 BASEPRI: 000000e0 CONTROL: 00000004\n 21:52:44.492 -> up_registerdump: EXC_RETURN: ffffffe9\n 21:52:44.531 -> up_dumpstate: sp: 0d065108\n \n```\n\n 3. 別のトライから、トリガーは`theAudio->begin()`以後の`SD.endUsbMsc()`のようだが、メッセージは\"capture\"で出ている\n\nこの様子からすると、Audio機能とMSC機能は相性が悪いようですが、うまく折り合い付けられるでしょうか?\n\n希望の機能は、USB2本をPCにつなげて、録音が終わって生成されたWAVファイルをPCからそのまま引きとりたいです。また録音機能は、コマンドでFFTの結果出力機能と切り替えられるようにしたいです(AS_CODECTYPE_PCM\n<-> AS_CODECTYPE_WAV) 。\n\nアドバイスいただけると助かります。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T13:21:36.963",
"favorite_count": 0,
"id": "83471",
"last_activity_date": "2021-11-12T08:43:18.637",
"last_edit_date": "2021-11-12T08:43:18.637",
"last_editor_user_id": "14101",
"owner_user_id": "48979",
"post_type": "question",
"score": 0,
"tags": [
"spresense",
"audio"
],
"title": "PCMサンプリング機能とSDHCI USB MSCを同時に機能させたい。",
"view_count": 150
} | [] | 83471 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "本を参考に、確率密度関数のコードを書き、\n\n```\n\n def normal_dist_pdf(x, mu, sigma): \n \n \"\"\"\n 正規分布\n : param x: x\n : param mu: 平均\n : param sigma: 標準偏差\n : return: 正規分布\n \"\"\"\n # expの部分\n exp = np.exp(-1 * ((x-mu)**2/(2*sigma**2)))\n \n # 残りの部分 xexpの部分\n return (1/(np.sqrt(2* math.pi*sigma**2))) * exp\n \n```\n\nこれを[仙台\n日平均気温の月平均値(℃)](http://www.data.jma.go.jp/obd/stats/etrn/view/monthly_s3.php?prec_no=34&block_no=47590&year=&month=&day=&elm=monthly&view=a1)の11月で使ってみようと思いました。\n\n```\n\n pd.DataFrame(Miyagi_temp['11月'].describe())\n \n 11月\n count 94.000000\n mean 8.896809\n std 1.165125\n min 6.500000\n 25% 8.100000\n 50% 8.800000\n 75% 9.700000\n max 11.800000\n \n```\n\n次に、実際にヒストグラムを描いて関数で線を引くために、下記のコードを試しました。\n\n```\n\n # 実際のデータのヒストグラム\n ax = Miyagi_temp['11月'].plot(kind = 'hist', bins=94)\n \n # 6.5 から 11.8 までを対象(今回のデータの範囲)\n x = range(6, 12)\n \n # 今回作った関数でラインを引く\n y = [normal_dist_pdf(x, mu, sigma) for i in x]\n \n ax2 = ax.twinx()\n ax2.plot(x, y, color = 'r', linewidth = 5.0)\n \n```\n\nしかし、エラーが発生。\n\n```\n\n <ipython-input-47-a5a5417f49ac> in normal_dist_pdf(x, mu, sigma)\n 10 \"\"\"\n 11 # expの部分\n ---> 12 exp = np.exp(-1 * ((x-mu)**2/(2*sigma**2)))\n 13 \n 14 # 残りの部分 xexpの部分\n \n TypeError: unsupported operand type(s) for -: 'range' and 'float'\n \n```\n\nrange()関数とfloat型の間に問題がありそうなんですが、どうも原因がつかめません。\n\n本の例ではうまくできていたのですが。 \n何かヒントあればありがたいです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T13:41:35.823",
"favorite_count": 0,
"id": "83472",
"last_activity_date": "2021-11-07T13:41:35.823",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48948",
"post_type": "question",
"score": 0,
"tags": [
"python",
"データの可視化"
],
"title": "unsupported operand type(s) for -: 'range' and 'float' エラーが出る。",
"view_count": 669
} | [] | 83472 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "JDKはJREを兼ねていますか?\n\nJava環境が必要なソフトを動かすのにJREが必要ですが、JDKをインストールするだけではだめなんですか? \nJDKはJava実行環境をもっているものとおもっていたのですが、あるフリーソフトを開こうとしたところ、JREがないというエラーがでました。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T14:07:04.753",
"favorite_count": 0,
"id": "83473",
"last_activity_date": "2021-11-08T02:17:30.727",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29370",
"post_type": "question",
"score": 0,
"tags": [
"java"
],
"title": "JDKはJREを兼ねていますか?",
"view_count": 156
} | [
{
"body": "JDKはJREを包含します。\n\nJava8以前のものであるなら、Sun/Oracleのインストーラでインストールしていることを前提にして、(Windows)なら特定のレジストリやインストールパスパターンを見たりしている可能性もあるのかなと思います。 \n原因が分からないのであれば、要求されているものをその通りインストールするのが無難ではないでしょうか。\n\n* * *\n\n[Java Platform Standard Edition\n8ドキュメント](https://docs.oracle.com/javase/jp/8/docs/):\n\n> JDK 8はJRE 8のスーパー・セットで、JRE\n> 8のすべての機能に加えて、アプレットやアプリケーションの開発に必要なコンパイラおよびデバッガなどのツールを備えています。\n\n[](https://i.stack.imgur.com/xYZ7M.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T02:17:30.727",
"id": "83484",
"last_activity_date": "2021-11-08T02:17:30.727",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"parent_id": "83473",
"post_type": "answer",
"score": 0
}
] | 83473 | null | 83484 |
{
"accepted_answer_id": "83476",
"answer_count": 1,
"body": "Virtualboxを入れMX Linux\n21をインストールし仮想環境を構築しました。ホストOSはWindows11です。PHPを扱いたくXamppを入れようと試みています。\n\nXamppのダウンロードページよりLinux向けのXamppをダウンロードしました。 \nダウンロードフォルダには\n\n「 **xampp-linux-x64-8.0.12-0-installer.run** 」\n\nというファイルが入っています。\n\n[](https://i.stack.imgur.com/eVHRD.png)\n\nLinuxのコマンドはほぼ分からないの「Linux Xampp インストール」のようなキーワード検索し比較的最近のサイトを見ながらそのままやってみました。\n\n(参考) \n<https://www.kkaneko.jp/tools/xampp/xamppinstalllinux.html> \n<https://dailylife.pman-bros.com/lampp_install/>\n\n上記のサイト等を参考にヴァージョンを変えて\n\n```\n\n chmod 755 xampp-linux-x64-8.0.12-0-installer.run\n \n```\n\nなどと打ってみたのですがうまく行きませんでした。\n\nそこでダウンロードしたファイルを直接クリックしてみると「推奨のアプリケーションが入っていない」と出ます。 \nWindowsOSでXamppは利用しています。インストールも手順通り進めば問題なく使えています。 \nLinux、仮想環境に関しては右も左もわからないレベルです。手順も動画がサイトなどを観ながらやっています。\n\n上記のような状況でどのようにすればXamppをインストールできますか? \nわかる方いらっしゃいましたら教えて下さい。よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T14:15:22.400",
"favorite_count": 0,
"id": "83474",
"last_activity_date": "2021-11-09T01:57:44.233",
"last_edit_date": "2021-11-09T01:57:44.233",
"last_editor_user_id": "3060",
"owner_user_id": "42150",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"xampp"
],
"title": "MX Linux に XAMPP をインストールしたい",
"view_count": 149
} | [
{
"body": "XAMPP 公式サイトの [FAQ](https://www.apachefriends.org/faq_linux.html)\nにインストール方法が記載されています。\n\nダウンロードしたインストーラに `chmod` コマンドで実行権限を付けた後、`sudo` に続けてインストーラを指定することで管理者権限で実行します。\n\n> ### How do I install XAMPP?\n>\n> Change the permissions to the installer\n```\n\n> chmod 755 xampp-linux-*-installer.run\n> \n```\n\n>\n> Run the installer\n```\n\n> sudo ./xampp-linux-*-installer.run\n> \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T16:31:12.537",
"id": "83476",
"last_activity_date": "2021-11-08T05:33:13.640",
"last_edit_date": "2021-11-08T05:33:13.640",
"last_editor_user_id": "3060",
"owner_user_id": "3060",
"parent_id": "83474",
"post_type": "answer",
"score": 1
}
] | 83474 | 83476 | 83476 |
{
"accepted_answer_id": "83477",
"answer_count": 1,
"body": "CSVセル選択モードでEnterキーを押すと、セルを1列右へ移動することはできますでしょうか。 \n(Excelではそれができます)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T15:22:04.260",
"favorite_count": 0,
"id": "83475",
"last_activity_date": "2021-11-07T20:29:50.000",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43123",
"post_type": "question",
"score": 0,
"tags": [
"emeditor"
],
"title": "Enterキーを押すと1列右へ移動させたい",
"view_count": 104
} | [
{
"body": "1. EmEditor はベータ版を含めて最新版 (v21.2.905 以上) に更新してください。\n\n 2. [ヘルプ] メニューより [キーボード マップ] を選択します。\n\n 3. [検索] ボックスに [次のセル] とタイプします。\n\n[](https://i.stack.imgur.com/q6ysx.png)\n\n 4. ↓ キーを押して、「次のセル (セル選択モードのみ)」を選択し、Enter を押します。\n\n 5. すべての設定のプロパティが表示され、「次のセル (セル選択モードのみ)」コマンドが選択されていることを確認します。\n\n[](https://i.stack.imgur.com/VVCle.png)\n\n 6. [追加するショートカット キー] テキスト ボックスをクリックしてから、Enter キーを押します。\n\n 7. 「Enter キーを割り当てますか?」というメッセージが表示されたら、OK をクリックします。\n\n 8. [割り当て] ボタンをクリックし、[OK] ボタンをクリックします。\n\n以上で、CSV セル選択モードでファイルを開いていれば、Enter キーで右のセルに移動します。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-07T20:29:50.000",
"id": "83477",
"last_activity_date": "2021-11-07T20:29:50.000",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "40017",
"parent_id": "83475",
"post_type": "answer",
"score": 0
}
] | 83475 | 83477 | 83477 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "以前、リサイズ可能なメモリDCでの不正終了について質問をしました。\n\n[VC++/MFC メモリDCの破棄時に不正終了してしまう場合がある](https://ja.stackoverflow.com/q/83416)\n\n申し訳ありません、登録したばかりで慣れておりません。 \nどうぞよろしくお願いします。\n\n①不正終了 DeleteMemDC()箇所 : map情報から \n②画面は5枚でなく2枚です。 \n③ワーカースレッドにてメモリDCに再描画 \n④OnPaint()にてスクリーンに転送してます。\n\n**質問1** \nDeleteMemDC()にてハンドルがNULLでもAPIを実行してしまうので、NULL以外で実行するようにした方が良いのでしょうか?\n\n**質問2** \nイベントビューアーでの終了レポートとVC++ map情報からDeleteMemDC()内で落ちているようですが、何が原因かまでは記録されません。 \nこういった時調べる手立てとしてどのような施策ができるのか、ご指導いただければ幸いです。\n\n以下がソースコードの抜粋になります。\n\n```\n\n #define WM_USER_UPDATE_GRAPH (WM_USER + 3)\n \n CRITICAL_SECTION csm;\n \n enum eLayer {\n L_Graph = 0,\n L_Splash,\n L_Max_Count,\n };\n \n // CFooDlg ダイアログ\n class CFooDlg : public CDialog\n {\n \n HANDLE hStartRedrawThread;\n HANDLE hKillRedrawThread;\n \n HANDLE hRedrawThreadStarted;\n HANDLE hRedrawThreadKilled;\n \n CWinThread* m_pRedrawThread;\n \n CStatic m_graphTemp; //ダイアログ上のグラフ描画域\n \n };\n \n \n CFooDlg::CFooDlg(CWnd* pParent /*=NULL*/)\n : CDialog(CFooDlg::IDD, pParent)\n {\n m_bSplash = TRUE;\n m_bResized = FALSE;\n :\n m_pRedrawThread = NULL;\n \n InitializeCriticalSection(&csm);\n \n \n }\n \n CFooDlg::~CFooDlg()\n {\n :\n DeleteCriticalSection(&csm);\n }\n \n BEGIN_MESSAGE_MAP(CFooDlg, CDialog)\n {\n :\n ON_MESSAGE(WM_USER_REDRAW, &CFooDlg::OnUserRedraw)\n :\n \n }\n \n BOOL CFooDlg::OnInitDialog()\n {\n \n CDialog::OnInitDialog();\n \n // \"バージョン情報...\" メニューをシステム メニューに追加します。\n \n // IDM_ABOUTBOX は、システム コマンドの範囲内になければなりません。\n ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);\n ASSERT(IDM_ABOUTBOX < 0xF000);\n \n g_hWnd = this->m_hWnd;\n SetHook();\n \n \n CMenu* pSysMenu = GetSystemMenu(FALSE);\n if (pSysMenu != NULL) {\n BOOL bNameValid;\n CString strAboutMenu;\n bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);\n ASSERT(bNameValid);\n if (!strAboutMenu.IsEmpty()) {\n pSysMenu->AppendMenu(MF_SEPARATOR);\n pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);\n }\n }\n \n // このダイアログのアイコンを設定します。アプリケーションのメイン ウィンドウがダイアログでない場合、\n // Framework は、この設定を自動的に行います。\n SetIcon(m_hIcon, TRUE); // 大きいアイコンの設定\n SetIcon(m_hIcon, FALSE); // 小さいアイコンの設定\n \n char vbuf[128];\n // タイトルバー表示(リソースより版数情報)\n CString ver = APP->GetVersionString();\n CString title;\n GetWindowText(title);\n \n RecalcLayout();\n \n CRect rect;\n m_graphTemp.GetClientRect(&rect);\n \n CDC* pDC = m_graphTemp.GetDC();\n \n for(int i=0;i<L_Max_Count;i++) {\n BOOL r = m_memDC[i].CreateCompatibleDC(pDC);\n r = m_bmp[i].CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());\n m_pOldBmp[i] = m_memDC[i].SelectObject(&m_bmp[i]);\n dbg_printf(\"OnInitDialog::m_pOldBmp[%d] = %p\\n\", i, m_pOldBmp[i]);\n m_memDC[i].BitBlt(0,0,rect.Width(),rect.Height(),NULL,-1,-1,WHITENESS);\n }\n \n m_graphTemp.ReleaseDC(pDC);\n \n // m_bSplash = TRUE;\n m_bSplash = ::GetPrivateProfileInt(\"Display\", \"Show_Splash\",1,APP->GetIniPath());\n :\n :\n hRedrawThreadStarted = CreateEvent(NULL,TRUE,FALSE,NULL);\n hRedrawThreadKilled = CreateEvent(NULL,TRUE,FALSE,NULL);\n \n if(m_pRedrawThread ==NULL) {\n m_pRedrawThread = AfxBeginThread(Redraw_Thread, this);\n m_pRedrawThread->m_bAutoDelete = FALSE;\n } else {\n AfxMessageBox(\"プログラム起動時に問題が発生しました。\");\n DestroyWindow();\n return FALSE;\n }\n SetEvent(hStartRedrawThread);\n if(WaitForSingleObject(hRedrawThreadStarted,5000L)==WAIT_TIMEOUT) {\n AfxMessageBox(\"画面更新スレッドが起動できませんでした\");\n DestroyWindow();\n return FALSE;\n }\n \n }\n \n BOOL CFooDlg::DestroyWindow()\n {\n // TODO: Add your specialized code here and/or call the base class\n ::EnumWindows(EnumWindowsProc, (LPARAM)this );\n \n PlaySound(NULL, NULL, 0);\n \n UnHook(); \n \n ReleaseCapture();\n \n for(int i=0;i<L_Max_Count;i++) {\n dbg_printf(\"m_pOldBmp[%d] = %p\\n\", i, m_pOldBmp[i]); //V1_6_8(408)\n m_memDC[i].SelectObject(m_pOldBmp[i]);\n m_bmp[i].DeleteObject();\n m_memDC[i].DeleteDC();\n }\n \n \n if(m_pRedrawThread) {\n SetEvent(hKillRedrawThread);\n Sleep(100L);\n WaitForSingleObject( m_pRedrawThread->m_hThread , INFINITE );\n delete m_pRedrawThread;\n }\n \n // PostQuitMessage();\n \n /// m_Graph.DestroyWindow();\n Sleep(500L);\n \n DeleteCriticalSection(&H8Ctl::cs);\n \n Sleep(50L);\n \n return CDialog::DestroyWindow();\n }\n \n void CFooDlg::OnSize(UINT nType, int cx, int cy)\n {\n CDialog::OnSize(nType, cx, cy);\n \n // TODO: Add your message handler code here\n \n AdjustLayout();\n \n // For Statusbar\n RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);\n \n m_bResized = TRUE;\n \n \n }\n \n void CFooDlg::OnPaint()\n {\n DWORD t = GetTickCount();\n \n \n if (IsIconic())\n {\n CPaintDC dc(this); // 描画のデバイス コンテキスト\n \n SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);\n \n // クライアントの四角形領域内の中央\n int cxIcon = GetSystemMetrics(SM_CXICON);\n int cyIcon = GetSystemMetrics(SM_CYICON);\n CRect rect;\n GetClientRect(&rect);\n int x = (rect.Width() - cxIcon + 1) / 2;\n int y = (rect.Height() - cyIcon + 1) / 2;\n \n // アイコンの描画\n dc.DrawIcon(x, y, m_hIcon);\n }\n else\n {\n \n DWORD tic = GetTickCount();\n \n if(!m_bSplash && m_bResized) { //起動時のスプラッシュ表示までは、メモリDCをリサイズしない\n dbg_printf(\"resized\\n\");\n EnterCriticalSection(&csm);\n DeleteMemDC();\n CreateMemDC();\n LeaveCriticalSection(&csm);\n m_bResized = FALSE;\n \n }\n \n CRect rect;\n m_graphTemp.GetClientRect(&rect);\n \n CDC* pDC = m_graphTemp.GetDC();\n \n if(m_bSplash)\n pDC->BitBlt(0,0,rect.right,rect.bottom,&m_memDC[L_Splash],0,0,SRCCOPY);\n else\n {\n pDC->BitBlt(0,0,rect.right,rect.bottom,&m_memDC[L_Graph],0,0,SRCCOPY);\n ers_t = -1;\n \n }\n \n m_graphTemp.ReleaseDC(pDC);\n \n CDialog::OnPaint();\n \n }\n \n }\n \n // ユーザーメッセージハンドラ\n // グラフをメモリDCに描画する\n LRESULT CFootDlg::OnUserUpdateChild(WPARAM wParam, LPARAM lParam)\n {\n DWORD t = GetTickCount();\n \n CRect rect;\n m_graphTemp.GetClientRect(&rect);\n drawGraph(&m_memDC[L_Graph],rect.Width(),rect.Height(),0,rect.Height());\n \n BYTE pv[20];\n memset(pv,0x00,sizeof(pv));\n for(int i=0;i<4;i++)\n pv[i] = H8Ctl::pv.vent_PV[i];\n for(int i=0;i<2;i++)\n pv[i+4] = H8Ctl::pv.curt_PV[i];\n \n if(pDispDlg)\n pDispDlg->UpdateLED(m_lamp, pv);\n \n if (pMainGraphSetupDlg)\n {\n if (!m_bCursor && !bLogvw /* == isToday()*/)\n {\n CTime today = CTime::GetCurrentTime();\n cur_t = today.GetHour() * 60 + today.GetMinute();\n }\n pMainGraphSetupDlg->m_DlgBar.UpdateCurrentValue(cur_t, bLogvw);\n }\n \n return 1L;\n }\n \n // *memDCにグラフを描画\n void CFooTestDlg::drawGraph(CDC* pDC, int devWidth, int devHeight,int vwOrgX,int vwOrgY, BOOL bPrint) \n {\n \n COLORREF col = DK_GREEN;\n \n CFont font,fontS;\n CFont* pOldFont;\n \n font.CreatePointFont(160,\"MS UI Gothic\");\n fontS.CreatePointFont(120,\"MS UI Gothic\");\n \n CRect rcw;\n CRect rect;\n m_graphTemp.GetClientRect(&rect);\n \n int map = pDC->SetMapMode(MM_ANISOTROPIC);//通常座標系\n \n CPoint ptOrg = CPoint(-LP_MX, -LP_MY); // 原点\n CSize szWind = CSize(LP_W, LP_H); // 仮想ウィンドウサイズ\n \n CSize szW = pDC->SetWindowExt(szWind); //仮想ウィンドウサイズ\n CPoint ptW = pDC->SetWindowOrg(ptOrg);\n \n CSize szV = pDC->SetViewportExt(devWidth, -devHeight);\n CPoint ptV = pDC->SetViewportOrg(vwOrgX, vwOrgY);\n CBrush* pOldBrsh = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);\n \n COLORREF bk = pDC->GetBkColor();\n pDC->SetBkMode(TRANSPARENT); // 背景透明\n \n pOldFont = pDC->SelectObject(&font);\n \n bk = RGB(255,255,255);\n rcw = CRect(ptOrg.x,ptOrg.y,ptOrg.x+szWind.cx,ptOrg.y+szWind.cy);\n \n pDC->FillSolidRect(&rcw, RGB(255,255,255));\n \n CPen pen(PS_DOT,0,LT_GRAY); //目盛\n CPen pen0(PS_SOLID,0,BLACK); //目盛\n CPen penTh(PS_SOLID,0,LT_GRAY);\n CPen penB(PS_SOLID,3,BLACK);\n CPen penBold(PS_SOLID,5,GRAY); //目盛\n \n CPen penT(PS_SOLID,1,col);\n CPen px(PS_SOLID,1,RGB(192,128,192));\n CPen penXX(PS_SOLID,1,RGB(0,0,255));\n CPen penXXX(PS_DOT,0,RGB(0,0,192));\n \n CRgn rgnG;\n CBrush brshS(RGB(255,255,192)); // 昼時間\n \n int w = LP_X;\n int hh = LP_Y;\n \n int rise = suntime[0]/100 * 60 + suntime[0]%100;\n int set = suntime[1]/100 * 60 + suntime[1]%100;\n int south = (set - rise) / 2 + rise;\n if(bLogvw) {\n rise = vLog_suntime[0]/100 * 60 + vLog_suntime[0]%100;\n set = vLog_suntime[1]/100 * 60 + vLog_suntime[1]%100;\n south = (set - rise) / 2 + rise;\n }\n ////// 昼時間の描画\n float xx = (float)LP_X/(float)(Tick[1] - Tick[0]); // スケールX\n \n int rr = (int)((rise-Tick[0]) * xx);\n int ss = (int)((set -Tick[0]) * xx);\n \n // グラフ域のみに描画制限\n CRect rcGrp(0,0,LP_X,LP_Y); //LP領域\n pDC->LPtoDP(&rcGrp);\n rgnG.CreateRectRgn(rcGrp.left,rcGrp.top,rcGrp.right,rcGrp.bottom);\n \n CRect rc(rr,0,ss,hh);\n pDC->FillRect(rc, &brshS);\n \n // 全面に制限変更\n \n CString str;\n int wh = w/24;\n \n CPen* pOldPen = pDC->SelectObject(&penB);\n \n // 時間軸描画\n int x;\n // 段階ズームおよび開始分(!=0)対応\n pDC->SelectObject(&penB); // THIN_SOLID\n x = (int)(0);\n pDC->MoveTo(x, 0); pDC->LineTo(x,hh);\n x = (int)(((float)(Tick[1]- Tick[0]) * xx)+0.5f);\n pDC->MoveTo(x, 0); pDC->LineTo(x,hh);\n \n for(int i=Tick[0];i<=Tick[1];i++) {\n if(!(i%180)) { //3時間\n x = (int)(((float)(i-Tick[0]) * xx)+0.5f);\n \n if(m_swTimeScale) {\n if(!(i%360))\n pDC->SelectObject(&penTh); //Thin_SOLID\n else\n pDC->SelectObject(&pen); //DOT\n \n pDC->MoveTo(x, 0); pDC->LineTo(x, hh);\n }\n \n pDC->SelectObject(&penB);\n pDC->MoveTo(x, -hh/100); pDC->LineTo(x,hh/100);\n } else if(!(i%60)) { //1時間\n x = (int)(((float)(i-Tick[0]) * xx)+0.5f);\n pDC->SelectObject(&pen0);\n pDC->MoveTo(x, -hh/200); pDC->LineTo(x,hh/200);\n }\n if(!(i%60)) { //1時間\n str.Format(\"%02d\",i/60); \n CSize sz = pDC->GetTextExtent(str);\n pDC->TextOut(x-sz.cx/2,-20,str);\n }\n }\n float temp = 0.f; //開始温度\n //m_nUnit : コンボボックスでの選択番号\n // =>tGraphRangeより選択番号を使って、MeasTypeを得る\n // =>得たmeastypeより、gInfoを参照して、単位、範囲などを得る.\n CSize szT;\n str = _T(\"XXXX\");\n szT = pDC->GetTextExtent(str);\n \n MeasureValue mt = (MeasureValue)m_nUnit[0];\n tGraphConfig* p = getMainGraphConfig(mt);\n if(p!=NULL) {\n temp = p->min;\n \n // 温度軸(縦軸)描画\n float r = p->max - p->min;\n float yy = ((temp-p->min) * hh)/r;\n \n pDC->SetTextColor(p->col);\n if(p->step) { // 0除算対策\n DWORD t = GetTickCount(); \n pDC->SelectObject(&pen);\n for(int i=(int)(p->min);i<=(int)(p->max);i+=(int)(p->step)){\n if(GetTickCount() - t > 100L)\n break;\n temp = (float)i;\n yy = ((temp-p->min)* hh)/r;\n \n if(m_swItemScale) {\n if(i==0)\n pDC->SelectObject(&penTh); //THIN_SOLID\n else\n pDC->SelectObject(&pen); //DOT\n \n pDC->MoveTo(0, (int)(yy+0.5f)); pDC->LineTo(LP_X,(int)(yy+0.5f));\n }\n \n pDC->MoveTo(-LP_X/200, (int)(yy+0.5f)); pDC->LineTo(LP_X/200,(int)(yy+0.5f));\n \n \n str.Format(\" %3hd \", (short)temp); // 前後空白マージン\n if(p->mt == MV_None) {\n str.Format(\" %u \", (UINT)temp); // 状況は符号なし\n }\n CSize szText = pDC->GetTextExtent(str);\n CPoint pt = CPoint(-szText.cx, (int)(yy+szText.cy/2));\n CRect rect(pt,CSize(szText.cx, (int)(-szText.cy)));\n //pDC->Rectangle(rect);\n if(p->mt != MV_None)\n pDC->DrawText(str,rect,DT_SINGLELINE | DT_RIGHT);\n }\n }\n \n yy = ((p->max-p->min)* hh)/r;\n \n szT = pDC->GetTextExtent(\"00%%\");\n str.Format(\"%s %s\", p->name, p->unit); // name追加\n pDC->TextOut(-szT.cx,(int)yy+szT.cy*3/2, str);\n }\n \n pDC->SelectObject(&penB); // THIN_SOLID\n pDC->MoveTo(0, 0);\n pDC->LineTo(1440, 0);\n pDC->LineTo(LP_X, 0);\n \n //右軸\n mt = (MeasureValue)m_nUnit[1];\n p = getMainGraphConfig(mt);\n if(p!=NULL) {\n temp = p->min;\n \n // 温度軸(縦軸)描画\n float r = p->max - p->min;\n float yy = ((temp-p->min) * hh)/r;\n \n pDC->SetTextColor(p->col);\n \n \n r = p->max - p->min;\n DWORD t = GetTickCount();\n for(int i=(int)(p->min);i<=(int)(p->max);i+=(int)(p->step)){\n if(GetTickCount() - t > 100L)\n break;\n temp = (float)i;\n yy = ((temp-p->min) * hh)/r;\n \n str.Format(\" %3hd \", (short)temp); // 前後空白はマージン\n if(p->mt == MV_None) {\n str.Format(\" %u \", (UINT)temp); // 状況は符号なし\n }\n CSize szText = pDC->GetTextExtent(str);\n CPoint pt = CPoint(LP_X, (int)(yy+szText.cy/2));\n CRect rect(pt,CSize(szText.cx,-szText.cy));\n //pDC->Rectangle(rect);\n pDC->DrawText(str,rect,DT_SINGLELINE | DT_RIGHT);\n \n }\n \n yy = ((p->max-p->min)* hh)/r;\n \n szT = pDC->GetTextExtent(\"00%%\");\n str.Format(\"%s %s\", p->name, p->unit); // name追加\n pDC->TextOut(LP_X-szT.cx, (int)(yy+szT.cy*3/2), str);\n }\n \n int h = m_u8time[4];\n int m = m_u8time[5];\n int x0 = h * wh;\n int xo = wh * m / 60;\n int tick = (h*60 + m)%TIME_RANGE;\n \n \n int tic = (int)( (tick-Tick[0]) * xx );\n \n ////////////////////\n // グラフ、目標温度をスケール内での描画に制限\n pDC->SelectClipRgn(&rgnG);\n \n // 設定1 or 設定2の 換気・暖房ライン(時間帯設定ライン)\n // 換気設定\n // 冷房設定\n // 暖房管理1\n // 暖房管理2 の設定ラインの描画\n if(!bLogvw) {\n if(m_swKankiSV[0])\n DrawSV(pDC, Kanki_Temp, timz[0], timz_N, 1440, hh );\n if(m_swHeatSV[0])\n DrawSV(pDC, Danbo_Temp_1, timz_h[0], timz_N, 1440, hh );\n if(m_swHeatSV[1])\n DrawSV(pDC, Danbo_Temp_2, timz_h[1], timz_N, 1440, hh );\n }\n \n pDC->SelectClipRgn(NULL);\n ////////////////////\n // クライアント座標(物理座標DP)\n // 以下の描画時、グラフ域外に項目名を書くため\n CFont* pF = pDC->SelectObject(&fontS);\n for(int b = 0; b < 16; b ++) {\n DrawStatusGraph(pDC, 1<<b, tick, LP_X, hh);\n }\n pDC->SelectObject(pF);\n pDC->SelectClipRgn(&rgnG);\n // グラフ描画 (gccでのmkr!=0の時のみ表示する。)\n for(int i=1;i<MV_Max_Count;i++) {\n MeasureValue mt = gcc[i].mt;\n if(mt == MV_Invalid_Item)\n break;\n if(mt < MV_None || mt >= MV_Max_Count)\n continue;\n DrawMeasGraph(pDC, mt, tick, LP_X, hh);\n }\n \n \n if(Pressed) {\n CPoint mk[4];\n mk[0] = ptSelectDP[0];\n mk[1] = CPoint(ptSelectDP[0].x, ptSelectDP[1].y);\n mk[2] = ptSelectDP[1];\n mk[3] = CPoint(ptSelectDP[1].x, ptSelectDP[0].y);\n pDC->SelectObject(penXX);\n for(int i=0;i<4;i++) {\n pDC->DPtoLP(&mk[i]);\n pDC->FillSolidRect(CRect(mk[i].x-10,mk[i].y-10,mk[i].x+10,mk[i].y+10),RGB(0,0,255));\n }\n CRect rcLP = CRect(ptSelectDP[0],ptSelectDP[1]);\n pDC->DPtoLP(&rcLP);\n pDC->SelectObject(&penXXX);\n pDC->SelectStockObject(NULL_BRUSH);\n pDC->Rectangle(&rcLP);\n }\n \n \n pDC->SelectObject(pOldFont);\n pDC->SelectObject(pOldBrsh);\n pDC->SelectObject(pOldPen);\n pDC->SelectClipRgn( NULL ); \n \n pDC->SetMapMode(map);//通常座標系\n pDC->SetWindowExt(szW);\n pDC->SetViewportExt(szV);\n \n pDC->SetWindowOrg(ptW);\n pDC->SetViewportOrg(ptV);\n \n pDC->SelectClipRgn(NULL);\n \n brshS.DeleteObject(); //B1.3 Added\n \n pen.DeleteObject();\n pen0.DeleteObject();\n penTh.DeleteObject();\n penB.DeleteObject();\n penBold.DeleteObject();\n \n penT.DeleteObject();\n px.DeleteObject();\n penXX.DeleteObject();\n penXXX.DeleteObject();\n \n rgnG.DeleteObject();\n \n fontS.DeleteObject();\n font.DeleteObject();\n \n }\n \n \n UINT Redraw_Thread(LPVOID ptr)\n {\n CFooDlg* p = (CFooDlg*)ptr;\n HWND hWnd =p->m_hWnd;\n \n DWORD tick = GetTickCount();\n DWORD tick2 = GetTickCount();\n DWORD tick3 = GetTickCount();\n UINT ret = 0;\n int th = 0;\n \n SetEvent(p->hRedrawThreadStarted);\n dbg_printf(\"****Redraw_Thread Started****\\n\");\n \n MSG message;\n \n while(1) {\n if(::PeekMessage(&message, NULL, 0, 0, PM_REMOVE)){ \n //ループ中のマウスメッセージ処理\n ::TranslateMessage(&message);\n ::DispatchMessage(&message);\n }\n \n Sleep(50L);\n if(WaitForSingleObject(p->hKillRedrawThread, 100L) == WAIT_OBJECT_0)\n break;\n if(WaitForSingleObject(p->hStartRedrawThread, 100L) == WAIT_TIMEOUT)\n continue;\n \n EnterCriticalSection(&csm);\n if((GetTickCount() - tick) > 500L) {\n tick = GetTickCount();\n ::PostMessage(hWnd,WM_USER_REDRAW, NULL, 0L);\n }\n LeaveCriticalSection(&csm);\n \n }\n SetEvent(p->hRedrawThreadKilled);\n dbg_printf(\"****Ended Redraw_Thread****\\n\");\n return 0;\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T00:32:27.467",
"favorite_count": 0,
"id": "83479",
"last_activity_date": "2021-11-08T23:26:53.753",
"last_edit_date": "2021-11-08T02:02:01.970",
"last_editor_user_id": "3060",
"owner_user_id": "48939",
"post_type": "question",
"score": -2,
"tags": [
"mfc",
"visual-c++"
],
"title": "VC++/MFC メモリDCの破棄時に不正終了してしまう場合がある (その2)",
"view_count": 222
} | [
{
"body": "とりあえず下記サイトを参考に、アプリ クラッシュ時のプロセス ダンプを採取する設定を行い、問題現象再現後に生成されたプロセス ダンプを解析してみては?\n\nWindowsエラー報告(WER)機能を使ってアプリケーションのクラッシュダンプ(ユーザーダンプ)を作成する方法 \n<https://support.citrix.com/article/CTX119302>",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T01:15:52.123",
"id": "83480",
"last_activity_date": "2021-11-08T01:15:52.123",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34652",
"parent_id": "83479",
"post_type": "answer",
"score": 0
}
] | 83479 | null | 83480 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "DCOMを使わないで、同じサーバ―内でVB6のCOMからCreateObjectで外部EXEの関数を呼び出すことはできるのでしょうか?\n\n現在は、DCOMの構成の「場所」で「次のコンピューター上でアプリケーションを実行する」にチェックを入れて、別EXEサーバ―のIPアドレスを指定しています。 \n別EXE用サーバ―に「Test.exe」が置いてあります。\n\n■現在のセットアップ方法 \n1.別EXEサーバ―で下記を実行 \nC:/TEST.exe /regserver\n\n2.APサーバーで下記を実行 \nCLIREG32.EXE .\\TEST.VBR -d -q -s 別EXE用サーバ―IPアドレス -t .\\TEST.TLB\n\n今は上記の設定を行ってTEST.EXEのCreateObjectが実行出来ている状態です。\n\nこれを同じAPサーバー上に、「C:/TEST.exe」を移動して、TEST.exeのCalc()というFunctionを呼び出したいです。 \nEXEはActiveXだと思います。\n\n(イメージ) \nSet test = CreateObject(\"TEST.clsCalc\") \nret = test.Calc()\n\nAPサーバーに「C:/TEST.exe」を配置して、下記の様にレジストリ登録しました。 \nC:/TEST.exe /regserver\n\nその上で、下記の部分を動かしてみましたが、TEST.exeは呼び出されていないように見えます。 \nSet test = CreateObject(\"TEST.clsCalc\") \nret = test.Calc()",
"comment_count": 12,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T01:20:54.120",
"favorite_count": 0,
"id": "83481",
"last_activity_date": "2021-11-08T05:07:15.733",
"last_edit_date": "2021-11-08T05:07:15.733",
"last_editor_user_id": "9183",
"owner_user_id": "9183",
"post_type": "question",
"score": 0,
"tags": [
"com",
"vb6"
],
"title": "DCOMを使わないで、同じサーバ―内でVB6のCOMからCreateObjectで外部EXEの関数を呼び出すことはできるのでしょうか?",
"view_count": 209
} | [] | 83481 | null | null |
{
"accepted_answer_id": "83557",
"answer_count": 3,
"body": "# やりたいこと\n\nCLIで動作するコマンドを作っています。 \n以下のコマンドラインオプションを用意しいたいです。\n\n * JSON文字列またはJSONファイルを受け取るオプション\n * スペース区切りの文字列、またはファイルを受け取るオプション\n\n### 文字列を渡す場合\n\n```\n\n $ cli --json '{\"foo\":1}'\n \n $ cli --user alice bob\n \n```\n\n### ファイルを渡す場合\n\n```\n\n $ cat foo.json\n {\"foo\":1}\n \n $ cli --json file://foo.json\n \n \n $ cat user.txt\n alice\n bob\n \n $ cli --user file://user.txt\n \n```\n\n# 悩んでいること\n\nawscliを参考にして、ファイルを指定するときは、`file://` というプレフィックスを利用しました。 \nただこのスキーマだと、`http://` など別のスキーマが使えることを期待してしましまいます。 \n今作っているコマンドは、ファイル以外のリソースを指定する予定はありません。 \nしたがって、ファイルを指定するときのプレフィックスに、`file://`を使うことは良くないと考えるようになりました。\n\n# 質問\n\nファイルパスを指定するときのプレフィックスは何がよいでしょうか? \nたとえば、curlは`@`をプレフィックスとしていますが、`@`がよいのでしょうか?\n\n# 補足\n\nCLIはPythonのargparseモジュールを使って、以下のように実装する予定でした。 \n<https://docs.python.org/ja/3/howto/argparse.html>\n\n```\n\n import argparse\n parser = argparse.ArgumentParser()\n parser.add_argument(\"--user\", nargs=\"+\", type=str)\n parser.add_argument(\"--json\", type=str)\n args = parser.parse_args()\n \n print(f\"{args.user=}\")\n print(f\"{args.json=}\")\n \n```\n\n```\n\n $ python --version\n Python 3.9.7\n \n $ python test.py --help\n usage: test.py [-h] [--user USER [USER ...]] [--json JSON]\n \n optional arguments:\n -h, --help show this help message and exit\n --user USER [USER ...]\n --json JSON\n \n $ python test.py --user alice bob --json '{\"foo\":1}'\n args.user=['alice', 'bob']\n args.json='{\"foo\":1}'\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T01:55:09.747",
"favorite_count": 0,
"id": "83483",
"last_activity_date": "2021-11-12T03:29:40.167",
"last_edit_date": "2021-11-11T14:55:35.767",
"last_editor_user_id": "19524",
"owner_user_id": "19524",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"command-line"
],
"title": "文字列またはファイルを受け取るコマンドを作りたいです。ファイルを受け取る際のプレフィックスは何がよいでしょうか?",
"view_count": 260
} | [
{
"body": "タグのlinuxで考えるなら、ファイルだけでなく標準入出力も考慮すると使い勝手が拡がります。 \nこの場合、プレフィクスはなしでファイル名指定だけでいいとおもいます\n\n標準のオプションだと\n\n`cli` 標準入力からjsonを入力 \n`cli <ファイル名>` ファイルからjsonを入力 \n`cli -- <ファイル名>` \\-- のあとはすべてファイルとして扱う\n\nだったと思います",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T12:52:02.260",
"id": "83492",
"last_activity_date": "2021-11-08T12:52:02.260",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "44341",
"parent_id": "83483",
"post_type": "answer",
"score": 0
},
{
"body": "もし「ファイルまたは文字列の入力」が1つだけだったら、\n\n * コマンドラインで指定するのはファイル名\n * ファイル名が `-` の場合は標準入力を用いる\n\nのような挙動をするコマンドが多いのですが、そういう入力が2つだとこの手は取れませんね。\n\n文字列指定のみサポートして、ファイル入力したいときはシェルのコマンド代入(バッククオートや `$(...)`)を使ってもらうのも手です。 \n逆に、bashやzshしか使わないという前提でも良いなら、ファイル名指定のみサポートして、文字列の場合はプロセス置換 `cli --user <(echo\nalice bob)` してもらうこともできます。\n\nどうしてもコマンドラインでファイルと文字列の両方のサポートしたいなら、私ならプレフィックスは使わずに、別のフラグにします。例: `--userfile\nファイル名` と `--user 文字列` \nプレフィックス方式だとシェルのファイル名補完が面倒になるからです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T00:32:46.140",
"id": "83499",
"last_activity_date": "2021-11-09T00:52:09.350",
"last_edit_date": "2021-11-09T00:52:09.350",
"last_editor_user_id": "3475",
"owner_user_id": "3475",
"parent_id": "83483",
"post_type": "answer",
"score": 0
},
{
"body": "「複数のファイル(および文字列)を、個別の形式を指定しつつ読み取る」ようなインターフェースを持つコマンドとして、例に挙げられているcurlや、ffmpeg/ffplay、ImageMagickなどがよく知られているように思います。 \nもちろん、これらのコマンドでの、複数形式の文字列・ファイルの同時指定の方法が最良のインターフェースであるとは限りませんが、とりあえずはこれらのオプション体系を参考にするのが、もっとも無難なやり方だと思われます。\n\ncurlでは、-dまたは--\ndataというオプションの引数について、その先頭が@である場合に、続く文字列をファイル名だとして処理します。ただしこのような実装の場合、「先頭に@があるが、文字列として扱う」ことを実現するために、適宜対応しなくてはなりません。curlでは、--data-\nrawというオプションを用意し、--data-rawオプションの引数は常に文字列とみなす、という仕様にすることでこの状況に対応しています。 \nデータの形式は、--data-ascii、--data-\nbinaryといったオプションを用いて明示できます。これらのオプションについても、「先頭に@があれば続く文字列をファイル名とみなす」という仕様が定められています。\n\ncurlのオプション体系に素直に従うなら、\n\n```\n\n $ cli --data-json string --data-json @file --data-json-raw @string\n # string, @stringはそのままJSON文字列として読み取り、\n # @fileはfileというファイル名のJSONファイルとして読み取る。\n $ cli \\\n --data-json '{\"foo\":1}' --data-user 'alice bob' \\\n --data-json @foo.txt --data-user @user.txt\n # 混合した例\n \n```\n\nのような仕様にするのがよいでしょう。\n\n参考: \n<https://curl.se/docs/manpage.html#-d>\n\n* * *\n\nffmpegでは、文字列とファイルをそれぞれ違うオプションで指定するのが基本です。たとえばメタデータ(作曲者やチャプターなどの情報)を指定する場合、メタデータを文字列で入力する際には\n--metadataというオプションの引数として指定し、ファイルで入力する際には`-f ffmetadata -i\nfile`というように、「入力するファイルの形式」と「入力するファイルの名前」を二つのオプションで指定します。\n\nffmepgのオプション体系に素直に従うなら、\n\n```\n\n $ cli --json string [-f|--format] json [-i|--input] file\n # stringはそのままJSON文字列として読み取り、\n # @fileはfileというファイル名のJSONファイルとして読み取る。\n $ cli \\\n --json '{\"foo\":1}' --user 'alice bob' \\\n -f json -i foo.txt -f user -i user.txt\n # 混合した例\n \n```\n\nのような仕様にするのがよいでしょう。\n\n参考: \n<http://ffmpeg.org/ffmpeg.html#Main-options> \n<http://ffmpeg.org/ffmpeg-formats.html#Metadata-1>\n\n* * *\n\nImageMagickでは、複数の入力をオプション引数ではなく非演算子として受け取り、それらの先頭に指定されている固有の書式に基づいて処理が行われます。 \n例えば「標準入力のgif形式とファイル記述子3のPNG形式」という入力なら、`gif:- png:fd:3`というように指定します。\n\nImageMagickのオプション体系に素直に従うなら、\n\n```\n\n $ cli json:str:string json:file\n # json:str:stringはstringというJSON文字列として読み取り、\n # json:fileはfileというファイル名のJSONファイルとして読み取る。\n $ cli \\\n json:str:'{\"foo\":1}' user:str:'alice bob' \\\n json:foo.txt user:user.txt\n # 混合した例\n \n```\n\nのような仕様にするのがよいでしょう。\n\n参考: \n<https://imagemagick.org/script/command-line-processing.php#input>\n\n* * *\n\nところで、質問で例示なさっているコマンドラインにおいて、空白を含むテキスト形式の文字列を、引用符や逆斜線などで空白をエスケープすることなくオプション引数に指定してありますが、一つのオプションに対して複数個のオプション引数を用意するのはあまり適切とは言えません。 \nUnix系OSの最低限の共通インターフェースを定めているPOSIXでも、そのような仕様のオプション体系は禁止されています。なお、LinuxはUnixではありませんが、[POSIXへの準拠と互換性向上を開発の一目的に据えている](https://www.kernel.org/doc/html/latest/admin-\nguide/README.html?highlight=posix%20compliance)ので、従っておくべきだと思います。\n\n```\n\n $ cli --user alice bob\n # ではなく\n $ cli --user 'alice bob'\n \n```\n\n参考 \n<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02>\n\n* * *\n\n【追記】\n\n[いただいたコメント](https://ja.stackoverflow.com/questions/83483/83557#comment94850_83557)をうけて追記します。\n\n> 補足に書きましたが、pythonのargparseモジュールを使ってCLIを作る予定でした。\n> argparseを使うと、1つのオプションに複数の値を指定できます。 POSIXに準拠するつもりはなかったです。\n\n 1. POSIXへの準拠について\n\n質問に「Linux」というタグをつけられていることから,このプログラムはLinux上の端末で動かすものだと想定しました。 \nまた,「プログラムのCLI設計について質問する」ということは,ある程度の利用性を持たせたいと思ってらっしゃるのではないですか。どのような場面で用いるプログラムかは分かりませんが,たとえば「同僚に使わせる」程度の利用性は確保したいのではないですか。\n\nそのような場面では,できるだけ現地の慣習に従うことで,無用な混乱を避けられるでしょう。\n\nまた,「Pythonのargparseライブラリは基本的に[POSIXでの慣習](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html)に倣う」というargparseライブラリ開発者(paul.j3氏)の[意見もあります](https://bugs.python.org/msg299609)。もちろん,これは一つの意見にすぎず,argparse開発陣の総意はまったく異なるものである可能性は多いにあります。しかしながら,オプション前置子の既定が-\nであることなどを鑑みると,argparseを用いる際にPOSIXへの準拠を考える,という指針はそれほど極端なものではないと言えるのではないでしょうか。\n\n 2. Pythonのargparseライブラリを使うことを前提した回答\n\nargparseライブラリのArgumentParser構築子にはfromfile_prefix_charsという属性があるようですね(私事ですが,この回答を書いていて知りました)。\n\n参考 \n<https://docs.python.org/3/library/argparse.html#fromfile-prefix-chars>\n\nおそらくですが,これを用いて「オプション引数の文字列をファイル名とみなして処理する」挙動を実装しようと考えてらしたのではないですか。\n\nfromfile_prefix_chars属性の解説には,例として「先頭に@がある場合にファイル名としてみなす」という,curlの仕様とそっくりなコード例が載っています。 \nそういう理由からも,curl風のオプション体系を採用するのがいいですね。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T05:29:49.143",
"id": "83557",
"last_activity_date": "2021-11-12T03:29:40.167",
"last_edit_date": "2021-11-12T03:29:40.167",
"last_editor_user_id": "19601",
"owner_user_id": "19601",
"parent_id": "83483",
"post_type": "answer",
"score": 2
}
] | 83483 | 83557 | 83557 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "質問:日本語に対してRMecCabをうまく動かせるようにしたい。\n\nRMeCabパッケージの関数を日本語のテキストデータに対して実行すると以下のようになり失敗します。 \n極楽not foundとなっていますが、実際には極楽は存在します。ちなみに英語のみのテキストデータに対してはうまく動きます。\n\n```\n\n > library(\"RMeCab\")\n > r <- collocate(\"kumo.txt\", node = \"極楽\",span = 3)\n file = kumo.txt \n 極楽 not found\n \n```\n\nkumo.txtを保存する時に文字コードUTF-8を確認。 \n[](https://i.stack.imgur.com/QpdKZ.png)\n\nR-studioの文字コードUTF-8を確認。 \n[](https://i.stack.imgur.com/WpQgn.png)\n\nNotepad++というソフトでエンコードを確認。 \n[](https://i.stack.imgur.com/5T0zW.png)",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T02:45:07.353",
"favorite_count": 0,
"id": "83485",
"last_activity_date": "2021-11-09T02:14:27.857",
"last_edit_date": "2021-11-08T05:38:15.350",
"last_editor_user_id": "32054",
"owner_user_id": "32054",
"post_type": "question",
"score": 1,
"tags": [
"r"
],
"title": "RMeCabが日本語ではうまくいきません。",
"view_count": 554
} | [
{
"body": "Windows上のRMeCabはUTF-8ではなくShift−JISを想定して作られています。 \n解析対象のテキストデータkumo.txtをUTF-8でなく、ANSIで保存し直すとうまくいきました。\n\n[](https://i.stack.imgur.com/ktO5A.png)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T02:14:27.857",
"id": "83505",
"last_activity_date": "2021-11-09T02:14:27.857",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "32054",
"parent_id": "83485",
"post_type": "answer",
"score": 1
}
] | 83485 | null | 83505 |
{
"accepted_answer_id": "83498",
"answer_count": 1,
"body": "SwiftにてMVVMの`Model`を`struct`で作成して、そのModelを`UserDefaults`で保存したいのですが、structは継承ができず、普通に実装するとModelをclassにしないといけません。そこで以下記事のようにstructの中に`HelperClass`を作成してそのHelperClassにNSObjectを継承させ、UserDefaultsで扱えるようにする方法があるようですが、これは賢い方法ですか?それとも普通にModelをclassにしたほうがいいのでしょうか?\n\n<https://swiftandpainless.com/nscoding-and-swift-structs/>",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T08:27:10.967",
"favorite_count": 0,
"id": "83488",
"last_activity_date": "2021-11-09T00:30:36.857",
"last_edit_date": "2021-11-08T08:36:00.223",
"last_editor_user_id": "40856",
"owner_user_id": "40856",
"post_type": "question",
"score": 0,
"tags": [
"swift"
],
"title": "SwiftにてModel(struct)をUserDefaultsで保存したい",
"view_count": 79
} | [
{
"body": "`struct`を保存するには`JSONEncoder`と`Codable`を使って`UserDefaults`に保存するのが一般的のようです。 \n<https://enmtknt.hateblo.jp/entry/2018/07/17/161915>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T00:30:36.857",
"id": "83498",
"last_activity_date": "2021-11-09T00:30:36.857",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "40856",
"parent_id": "83488",
"post_type": "answer",
"score": 0
}
] | 83488 | 83498 | 83498 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "`Drive.Drives.list({pageToken:pageToken, maxResults:100,\nuseDomainAdminAccess:true});` \nで取得される戻り値で、`id` や `name` の値は取得できたのですが、`restrictions` がどうしても取得できず設定もできません。 \nどのようにすれば取得や設定ができますでしょうか。\n\n* * *\n\nTanaike様、ご回答ありがとうございました。 \n取得はできました。 \nさらにお教えいただきたいことがありましたが、コメントでの返信では文字数足りなたかったため、こちらに記載させていただきます。\n\n同様に`restrictions`を設定したいんですが、下記のパターンでいくつか`Drives.update`を試してみましたがうまくいきません。 \n申し訳ありませんが設定方法も教えていただけますでしょうか。\n\n1の場合、以下のエラーになります。\n\n```\n\n GoogleJsonResponseException: 次のエラーが発生し、drive.drives.update の呼び出しに失敗しました: The requesting user does not have the administrator privilege required to manage the shared drive 0ADwtxWXOI0f9Uk9PVA.\n \n```\n\n2の場合、無視されたような状態です。\n\n試したコードは以下の通りです。\n\n```\n\n // 1\n var updateResources = {\n useDomainAdminAccess: true,\n name: \"新名称\",\n restrictions: {\n adminManagedRestrictions: true,\n domainUsersOnly: true,\n driveMembersOnly: true,\n copyRequiresWriterPermission : true\n },\n fields: \"items(name,restrictions)\"\n }; \n var res_update = Drive.Drives.update(updateResources, driveID);\n \n // 2\n var updateResources = {\n useDomainAdminAccess: true,\n name: \"新名称\",\n fields: \"items(name,restrictions)\"\n }; \n var updateOptions = {\n restrictions: {\n adminManagedRestrictions: true,\n domainUsersOnly: true,\n driveMembersOnly: true,\n copyRequiresWriterPermission: true\n }\n };\n var res_update = Drive.Drives.update(updateResources, driveID, updateOptions);\n \n```\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T10:11:27.393",
"favorite_count": 0,
"id": "83489",
"last_activity_date": "2021-11-12T08:37:06.597",
"last_edit_date": "2021-11-12T08:37:06.597",
"last_editor_user_id": "14101",
"owner_user_id": "48989",
"post_type": "question",
"score": 0,
"tags": [
"google-apps-script"
],
"title": "Drive.Drives.listでrestrictionsの値を取得または設定したい",
"view_count": 378
} | [
{
"body": "`Drive.Drives.list`では、デフォルトとして、`id, name,\nkind`のみが返されるようです。そのため、`restrictions`を取得するためには`fields`を使用する必要があります。今の場合、全てのプロパティを取得するか、特定のプロパティをを取得するか選択することができます。\n\n### 全てのプロパティを取得する場合\n\n```\n\n Drive.Drives.list({ pageToken: pageToken, maxResults: 100, useDomainAdminAccess: true, fields: \"*\" });\n \n```\n\n### 特定のプロパティをを取得する場合\n\n```\n\n Drive.Drives.list({ pageToken: pageToken, maxResults: 100, useDomainAdminAccess: true, fields: \"items(name,restrictions,id),nextPageToken\" });\n \n```\n\n * この場合、`name,restrictions,id,nextPageToken`が返されます。\n\n### Reference\n\n * [Drives: list](https://developers.google.com/drive/api/v2/reference/drives/list)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T00:56:34.097",
"id": "83502",
"last_activity_date": "2021-11-09T00:56:34.097",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19460",
"parent_id": "83489",
"post_type": "answer",
"score": 0
}
] | 83489 | null | 83502 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "ObjectARXを利用して、図面全体から指定長さ以下の線分を抽出する処理を作成しています。 \nイテレータを使用したループでは時間がかかるため、他の方法を探しています。 \nQSELECTで条件を指定すると短時間で抽出できるのですが、プログラムから実行することは可能でしょうか。 \nまた、acedSSGetに長さを条件に加えて検索することは可能でしょうか。 \nご回答いただけると非常に助かります。 \nどうぞよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-08T12:15:47.840",
"favorite_count": 0,
"id": "83491",
"last_activity_date": "2021-11-26T04:45:47.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31055",
"post_type": "question",
"score": 0,
"tags": [
"c++",
"ijcad"
],
"title": "IJCADのObjectARXで微小線分の抽出を高速にしたいです。",
"view_count": 117
} | [
{
"body": "> QSELECTで条件を指定すると短時間で抽出できるのですが、 \n> プログラムから実行することは可能でしょうか。\n\nCADのQSELECTコマンドのように、 \nプログラムで図形の種類やプロパティで条件指定して選択する事は可能です。 \nacedSSGet()関数の第4引数(リザルトバッファ)を使用して、 \nDXFのグループコードで条件を指定してフィルタリングする事ができます。\n\n以下が条件指定で図形選択するためのリザルトバッファを作成するサンプルです。\n\n```\n\n // (0,0)を始点に持つ線分でフィルタリングする例\n ads_point pt1;\n pt1[X] = pt1[Y] = pt1[Z] = 0.0;\n resbuf* prb;\n prb= acutBuildList(-4, _T(\"<AND\"), RTDXF0,_T(\"LINE\"), 10, pt1, -4, _T(\"AND>\"), RTNONE);\n \n```\n\n> acedSSGetに長さを条件に加えて検索することは可能でしょうか。\n\n線分の長さを示すDXFコードが存在しないため、acedSSGetの条件に加えるのはできないと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-26T04:45:47.550",
"id": "83810",
"last_activity_date": "2021-11-26T04:45:47.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "39778",
"parent_id": "83491",
"post_type": "answer",
"score": 0
}
] | 83491 | null | 83810 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "名前付きポイントカットを記述するとき、以下のような書式が説明されていました。\n\nここで、`()` の中に引数を書いたり、`{}` の中に具体的な処理を書いたりすることはできるのでしょうか。 \nいろいろ調べたのですが、いずれも以下のような書式しか説明が見当たりませんでした。\n\n```\n\n @Pointcut(\"execution(* * *.*test.*(..))\")\n public void myTest() {}\n \n```\n\n見落としもあると思いますので、どちらかに説明があればその場所を教えて頂けないでしょうか。 \nよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T00:56:11.897",
"favorite_count": 0,
"id": "83501",
"last_activity_date": "2021-11-09T04:13:23.740",
"last_edit_date": "2021-11-09T02:03:39.050",
"last_editor_user_id": "3060",
"owner_user_id": "48998",
"post_type": "question",
"score": 1,
"tags": [
"java",
"spring"
],
"title": "AOPの名前付きポイントカット式の記述方法について",
"view_count": 204
} | [
{
"body": "`public void myTest() {}`の`()` の中に引数を書いたり、`{}`\nの中に具体的な処理を書いたりすることができるかという質問ですね。そうでしたら、引数とメソッドの処理のどちらも、特定のポイントカット式を記述した場合のみ書くことができる、というのが答えになります。\n\nこの部分は(Springフレームワークを使っていても)AspectJというライブラリが処理しており、そのドキュメントに説明があります。 \n<https://www.eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-\npcadvice.html>\n\nまずメソッド引数について書きます。上記webページから抜粋します。\n\n> The parameters of the method correspond to the parameters of the pointcut.\n\n訳: メソッド引数はポイントカットの引数と一致する。\n\n言い換えますと、ポイントカット式に引数を書けばメソッドにも同じ引数を書きます。 \n上記webページに例があります。\n\n```\n\n @Pointcut(\"call(* *.*(int)) && args(i) && target(callee)\")\n void anyCall(int i, Foo callee) {}\n \n```\n\nまず、`args()`で引数`i`を書いているので、メソッド引数に`int\ni`を書いています。`args()`のような引数指定だけではなく、`target()`で呼び出された側のオブジェクトに対して`callee`という名前をつけて利用しようとしているため、メソッド引数に`Foo\ncallee`を定義しています。他に`this()`もあり、このような場合にメソッド引数を書きます。\n\n次にメソッドボディについてです。先ほどのページから抜粋します。\n\n> As a general rule, the @Pointcut annotated method must have an empty method\n> body and must not have any throws clause.\n\n訳: 原則として、@Pointcutを付与したメソッドはメソッドボディが空でなければならず、あらゆるthrows句を持つことができない。 \nよって通常メソッドボディに処理を書くことはできません。\n\nただし、`if()`というものがあり、これを使うときのみメソッドボディに処理を書きます。また抜粋します。\n\n```\n\n @Pointcut(\"call(* *.*(int)) && args(i) && if()\")\n public static boolean someCallWithIfTest(int i) {\n return i > 0;\n }\n \n```\n\nメソッドボディに`if()`の条件分岐処理を書きます。処理が書けるのはこのケースのみです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T04:13:23.740",
"id": "83509",
"last_activity_date": "2021-11-09T04:13:23.740",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4464",
"parent_id": "83501",
"post_type": "answer",
"score": 1
}
] | 83501 | null | 83509 |
{
"accepted_answer_id": "83529",
"answer_count": 1,
"body": "### 問題の要約\n\nAppSheetでDataをCSVを定期的に出力したいと考えています。 \nアプリ上のボタンを押して、CSVを出力させることはBehaviorタブのActionsからできました。 \nしかし、Automationを用いてActionsを実行することができませんでした。\n\n### これまでに試したこと\n\n * 公式ドキュメントの読み込み\n * AutomationタブのTasksからCSV出力の実行を試みる(Dataの設定が悪いらしく失敗)\n\nお手数をおかけしますが、Automationで、Actionsを実行する方法をご教示いただけないでしょうか。\n\n### 回答を基に行ったこと(追記)\n\n代替手段の案を基に、PDF作成を行ってみました。 \nとと-to10さんのおかげで、 \n実際にAutomationを用いてPDFが出力されるまでを行うことができました。 \n本当にありがとうございます。このままCSVも作成してみます。\n\n[](https://i.stack.imgur.com/UN38e.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T01:35:59.410",
"favorite_count": 0,
"id": "83503",
"last_activity_date": "2021-11-15T02:32:01.650",
"last_edit_date": "2021-11-15T02:32:01.650",
"last_editor_user_id": "48999",
"owner_user_id": "48999",
"post_type": "question",
"score": 0,
"tags": [
"google-apps-script"
],
"title": "AppSheetのAutomationで、BehaviorタブのActionsを実行する方法を教えてください。",
"view_count": 1110
} | [
{
"body": "> Automationを用いてActionsを実行することができませんでした。\n\n実行できるのはDataタイプ(※)のアクションだけだったと思うので、Appタイプは実行できないのではないかと思います。 \n※ActionsのDo Thisで選択できる各項目のセミコロン(:)の左にある文字列(Data,App,Externalなど)をタイプと呼んでいます。\n\nやりたいことは、定期的に実行してCSVをGoogleドライブに格納するなりメールで送るようなイメージかと思いました。代替手段の案を考えました。 \nデータ構造がわからないと思うのでどこまで伝わるかわかりませんがこの方法でCSV出力できました。 \nご参考まで。\n\n### やること\n\n指定したスケジュールで、GoogleドライブにCSVを出力\n\n### Bot設定概要\n\nEvents : 「Schedule」を使う \nTasks: 「Create a new file」を使う\n\n### Events設定\n\n[](https://i.stack.imgur.com/rEpLA.png)\n\n### Tasks設定\n\n[](https://i.stack.imgur.com/eGezN.png)\n\n●上記画像の「Template」で指定するテンプレートの中身\n\n```\n\n \"見積書ID\",\"商品ID\",\"個数\",\"小計\"\n <<Start: SELECT(見積明細[_ComputedKey],TRUE)>>\"<<[見積書ID]>>\",\"<<[商品ID]>>\",\"<<[個数]>>\",\"<<[小計]>>\"\n <<End>>\n \n```\n\nテンプレートの書き方は以下のページが参考になると思います。\n\n[Using CSV templates | AppSheet Help\nCenter](https://help.appsheet.com/en/articles/5297633-using-csv-\ntemplates#:%7E:text=on%20Google%20Drive.-,Manually%20creating%20a%20CSV%20template,-Manually%20create%20a)\n\n### 私の検証で得られた結果(CSVをUPできなかったので画像で)\n\n[](https://i.stack.imgur.com/53gHT.png)\n\n●GoogleドライブにCSVが溜まっていく様子 \n※画像の最終更新時間は気にしないでください。「修正->Botスケジュール設定->検証」を繰り返したため時間はバラバラです。動作確認できたのでちゃんとBotスケジュール設定すれば定期実行できると思います。\n\n[](https://i.stack.imgur.com/y1EDJ.png)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T17:02:48.683",
"id": "83529",
"last_activity_date": "2021-11-10T00:48:04.533",
"last_edit_date": "2021-11-10T00:48:04.533",
"last_editor_user_id": "3060",
"owner_user_id": "49014",
"parent_id": "83503",
"post_type": "answer",
"score": 0
}
] | 83503 | 83529 | 83529 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "検索ボックスでエンターキーを押した時に入力された値を元に検索をかけるという処理があります。 \n下記htmlをヘッダー内に2つ 記載しているのですが、menu-search-wrap-hdクラスの検索ボックスで値が取得できないという状況に陥っています。 \njavascriptは通っています。 \nクラスぐらいしか2つの際はないように感じるのですが、何が原因で値が取れないのかが不明です。 \nどなたかご教授いただけると幸いです。 \nよろしくお願いします。\n\n```\n\n <div class=\"menu-search-wrap\">\n <label>\n <input type=\"text\" data-id=\"<{$search_form.keyword_id}>\" value=\"<{$search.keyword}>\" placeholder=\"アイテムを検索\" class=\"search-keyword\">\n </label>\n <a href=\"<{$search_form.search_url}>\" class=\"menu-search-btn search-url\"><i class=\"material-icons\">search</i></a>\n </div>\n \n 中略\n \n <div class=\"menu-search-wrap-hd\">\n <label>\n <input type=\"text\" data-id=\"<{$search_form.keyword_id}>\" value=\"<{$search.keyword}>\" placeholder=\"アイテムを検索\" class=\"search-keyword\">\n </label>\n <a href=\"<{$search_form.search_url}>\" class=\"menu-search-btn-hd search-url\"> <img src=\"https://hogehoge.com\" class=\"sample3Img\"></a>\n </div>\n \n```\n\n```\n\n $(function(){\n $('.search-keyword').on('keypress', function(e) {\n if (e.keyCode == 13) {\n var index = $('.search-keyword').index(this);\n $('.search-url')[index].click();\n }\n });\n });\n \n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T01:47:07.183",
"favorite_count": 0,
"id": "83504",
"last_activity_date": "2021-11-09T02:18:00.567",
"last_edit_date": "2021-11-09T02:18:00.567",
"last_editor_user_id": "40597",
"owner_user_id": "40597",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"html"
],
"title": "inputのvalueが取得できない",
"view_count": 697
} | [] | 83504 | null | null |
{
"accepted_answer_id": "83547",
"answer_count": 1,
"body": "[jquery-ui](https://jqueryui.com/download/) と\n[jquery.validationEngine](https://github.com/posabsolute/jQuery-Validation-\nEngine) を同時に使いたいのですがうまくいきません\n\nどちらも $ っていう変数に対してメソッドを追加してるんだと思うんですが片方を使うともう片方が使えなくなります\n\n* * *\n\njquery-ui は公式サイトダウンロードビルダーから zip ダウンロードしたものを \napp/javascript/vendor/jquery-ui \nに展開\n\njquery.validationEngine は \napp/javascript/vendor/jquery.validationEngine \nに clone してあります\n\n* * *\n\n**config/webpack/environment.js をデフォルトのまま** \napplication.js に\n\n```\n\n globalThis.jQuery = globalThis.$ = require('jquery');\n import '../vendor/jquery-ui/jquery-ui.min.js'\n import '../vendor/jquery-ui/jquery-ui.min.css'\n import '../vendor/jquery-ui/jquery-ui.theme.min.css'\n \n```\n\nとかくと $.slider() が動きますが\n\n```\n\n import '../vendor/jQuery-Validation-Engine/js/jquery.validationEngine';\n \n```\n\nを追加すると\n\n```\n\n jquery.validationEngine.js:2163 Uncaught ReferenceError: jQuery is not defined\n at Object../app/javascript/vendor/jQuery-Validation-Engine/js/jquery.validationEngine.js (jquery.validationEngine.js:2163)\n at __webpack_require__ (bootstrap:19)\n at Module../app/javascript/packs/application.js (application.js:1)\n at __webpack_require__ (bootstrap:19)\n at bootstrap:83\n at bootstrap:83\n \n```\n\nと jQuery が見つからないというエラーになります\n\nglobalThis.jQuery = に代入しているにもかかわらず \nなぜそのあとの import で jQuery がみつからなくなるんでしょうか\n\n* * *\n\n一方で config/webpack/environment.js に\n\n```\n\n environment.plugins.prepend('Provide',\n new webpack.ProvidePlugin({\n $: 'jquery/src/jquery',\n jQuery: 'jquery/src/jquery'\n })\n );\n \n```\n\nをかくと application.js で\n\n```\n\n import '../vendor/jQuery-Validation-Engine/js/jquery.validationEngine';\n \n```\n\nをしてもエラーが出なくなるんですが\n\n```\n\n import '../vendor/jquery-ui/jquery-ui.min.js'\n import '../vendor/jquery-ui/jquery-ui.min.css'\n \n```\n\nもかいてるにもかかわらず $.slider(); で\n\n```\n\n Uncaught TypeError: $(...).slider is not a function\n \n```\n\nとなってしまいます\n\n* * *\n\n**追記:**\n\n[Rails6 webpacker から bootstrap js\nを使う方法](https://ja.stackoverflow.com/questions/83006/rails6-webpacker-%e3%81%8b%e3%82%89-bootstrap-\njs-%e3%82%92%e4%bd%bf%e3%81%86%e6%96%b9%e6%b3%95)\n\nProvidePlugin を記述するとこちらで教えていただいた bootstrap の JS も \njquery-ui に関係なく (jquery-ui関連のインポートを全部消しても)\n\n`$(...).modal is not a function`\n\nで動かなくなってしまいました\n\n* * *\n\n[Rails + webpacker における global と window と config/webpack/environment.js\nの違い](https://ja.stackoverflow.com/questions/83118/rails-\nwebpacker-%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8b-global-%e3%81%a8-window-%e3%81%a8-config-\nwebpack-environment-js-%e3%81%ae%e9%81%95%e3%81%84)\n\n最近こちらの質問をみかけたんですが \nglobalThis と ProvidePlugin でなぜ挙動がかわってしまうんでしょうか\n\nProvidePlugin があまり理解できてないなくてこれまではなしで動いていたので \nできれば ProvidePlugin を使わずに globalThis だけで \njQuery-Validation-Engine を動かしたいのですが方法はないでしょうか\n\n* * *\n\n今の application.js がこんな感じで \nここに validation engine を追加しようとしました\n\n```\n\n import Rails from '@rails/ujs'\n globalThis.Rails = Rails\n Rails.start()\n \n require(\"turbolinks\").start()\n require(\"@rails/activestorage\").start()\n require(\"channels\")\n \n import * as jquery from 'jquery'\n globalThis.jQuery = globalThis.$ = jquery;\n \n import * as bootstrap from 'bootstrap'\n globalThis.bootstrap = bootstrap\n \n // // jQuery-Validation-Engine\n // import '../vendor/jQuery-Validation-Engine/js/jquery.validationEngine';\n // // require('../vendor/jQuery-Validation-Engine/js/languages/jquery.validationEngine-ja');\n // import '../vendor/jQuery-Validation-Engine/js/languages/jquery.validationEngine-en';\n \n /* Validate form */\n // $(document).on('turbolinks:load', function () {\n // $(\"form\").validationEngine();\n // });\n \n import '@fortawesome/fontawesome-free/js/all';\n \n import '../vendor/jquery-ui/jquery-ui.min.js'\n import '../vendor/jquery-ui/jquery-ui.min.css'\n import '../vendor/jquery-ui/jquery-ui.theme.min.css'\n \n import * as moment from 'moment'\n globalThis.moment = moment\n \n import '../stylesheets/application.scss';\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T07:01:25.300",
"favorite_count": 0,
"id": "83510",
"last_activity_date": "2021-11-11T09:49:24.040",
"last_edit_date": "2021-11-09T10:00:41.707",
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"jquery",
"webpack"
],
"title": "webpack での jquery の $ 変数の扱いについて",
"view_count": 641
} | [
{
"body": "コードの順番に関係無く、`import`や`require`でモジュールのファイルを読み込む処理が最初に実行され、その後に地の文にある処理が実行されるからです。\n\nどういうことかというと、`import '../vendor/jQuery-Validation-\nEngine/js/jquery.validationEngine';`の方が、`globalThis.jQuery = globalThis.$ =\njquery;`での代入の処理より前に実行されてしまいます。そのため、jquery.validationEngineの中身が実行される時点ではグローバル変数`jQuery`が用意されておらず、変数が見つからないとして、実行に失敗するとなっています。逆に、ProvidePluginがうまくいくのは、`import`の処理の前にProvidePluginの処理が実行されるので、グローバル変数`jQuery`が用意されているというわけです。\n\njQuery UIが何故うまくいくというと、jQuery\nUIのコードにはAMDに対応する部分があり、webpackがそれを考慮して、jQueryがモジュールとして読み込まれていれば、そのjQueryに対して設定するという動きになっているからです。(詳しくは調べていませんが、ProvidePluginだとおかしくなるのは、このあたりが原因かもしれません。ProviderPluginで読み込まれたjQueryとimportされたjQueryが別の物扱いで、追加のメソッドが設定されないという物です。bootstrapもjQueryをimportすると言った動作だったはずなので、そちらもそれが原因でしょう。)\n\nでは、どうすればいいのかというと、ファイルを分けます。下記内容のjquery-validation-engine.jsを用意します。\n\n```\n\n import '../vendor/jQuery-Validation-Engine/js/jquery.validationEngine';\n \n```\n\nこれをapplicationの後に読む込むようにします。application.html.erbは次のようになるでしょう。\n\n```\n\n <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>\n <%= javascript_pack_tag 'jquery-validation-engine', 'data-turbolinks-track': 'reload' %>\n \n```\n\nこれで、うまくいくはずです。\n\n* * *\n\nこの方法には注意事項があります。まもなく正式リリースされるwebpacker\n6系では複数のJavaScirptに分割することをサポートしていません。全てのJavaScriptは`application.js`一つにまとめておく必要があり、この方法は使えなくなります。\n\n一つのファイルにまとめるにはどうするのかですが、[Upgrading from Webpacker 5 to\n6](https://github.com/rails/webpacker/blob/master/docs/v6_upgrade.md)に次のヒントが書いてありました。\n\n> If you expose jquery globally with `expose-loader`, by using `import $ from\n> \"expose-loader?exposes=$,jQuery!jquery\"` in your\n> `app/javascript/application.js`, pass the option `efer: false` to your\n> `javascript_pack_tag`.\n\nこの方法はwebpacker 5系でも使えます。実際に使ってみましょう。まずは、`yarn add expose-loader@1`として、expose-\nloaderをインストールします(webpacker 5系はwebpack 4系を使用するため、expose-\nloderは1系を使う必要があり、`@1`を付けるようにしてください)。そして、jQueryの部分を次のように書きます。(最新のexpose-loader\n3系とは書き方が異なるので注意してください。)\n\n```\n\n import $ from \"expose-loader?exposes[]=$&exposes[]=jQuery!jquery\";\n \n```\n\nこうすると、jQueryの`import`処理と同時にexpose-\nloaderがグローバル変数にセットしてくれるようです。`import`処理同士は順番に実行されるため、jquery.validationEngineが読み込まれるときには、グローバル変数`jQuery`が存在することになりうまくいくという仕組みです。\n\n* * *\n\nそもそもの問題はjQuery.validationEngineが現代的なモジュールベースに対応した物としてかかれていないと言うことです。jQuery\nUIの開発も終了しており、Bootstrapも5系からjQuery依存が無くなったと言うこともありますので、将来的にはjQueryには依存しない方向にシフトしていった方がいいかもしれません。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T13:00:01.027",
"id": "83547",
"last_activity_date": "2021-11-11T09:49:24.040",
"last_edit_date": "2021-11-11T09:49:24.040",
"last_editor_user_id": "7347",
"owner_user_id": "7347",
"parent_id": "83510",
"post_type": "answer",
"score": 3
}
] | 83510 | 83547 | 83547 |
{
"accepted_answer_id": "83514",
"answer_count": 1,
"body": "Webスクレイピングで取得したIDが複数で出力されるので、リスト化後、特定のIDを取得したいです。\n\n実現内容\n\n```\n\n [\"12345\",\"21234\",\"22456\"]\n \n```\n\n取得したいリストから `[1]` を指定して21234のIDを取得したいです。\n\n下記のコードで行いましたが、上手く出力結果の **21234** を取得できず、エラーします。\n\nどなたかご教授いただけると幸いです。\n\nよろしくお願いします。\n\ncode\n\n```\n\n # BeautifulSoupから取得するID WEBページにHOUSE用語が含んでいましたら、全てのID出力\n for i in soup.find_all(class_=['text-box']):\n if 'HOUSE' in i.text: \n find_id= [i.parent.parent.parent.get('id').split('-')[-1]]\n \n print(find_id)\n \n a=find_id[1]\n \n print(a)\n \n```\n\n`print(find_id)` の結果\n\n```\n\n ['12345']\n ['21234']\n ['22456']\n \n```\n\n変数aからIDを取得したプログラムを組みましたが、print(a)がエラーメッセージします。\n\n```\n\n a=find_id[1]\n IndexError: list index out of range\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T07:12:56.167",
"favorite_count": 0,
"id": "83511",
"last_activity_date": "2021-11-09T08:03:11.043",
"last_edit_date": "2021-11-09T07:59:12.730",
"last_editor_user_id": "18859",
"owner_user_id": "18859",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "Pythonで複数の出力結果から特定のIDを取得したい",
"view_count": 126
} | [
{
"body": "それはありえないですね。print(find_id)の結果からNameErrorが発生するはずです。\n\nprint(find_id) \nは、もしかしたらfind_id=...のすぐ下になっていないでしょうか?\n\n```\n\n ids = []\n for i in soup.find_all(class_=['text-box']):\n if 'HOUSE' in i.text: \n ids += [i.parent.parent.parent.get('id').split('-')[-1]]\n \n print(ids[1])\n \n```",
"comment_count": 10,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T07:40:55.613",
"id": "83514",
"last_activity_date": "2021-11-09T08:03:11.043",
"last_edit_date": "2021-11-09T08:03:11.043",
"last_editor_user_id": "49006",
"owner_user_id": "49006",
"parent_id": "83511",
"post_type": "answer",
"score": 2
}
] | 83511 | 83514 | 83514 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "今回の問題は配列ヒープがテストと異なった結果を返してしまうことです。うまくいくと、main.cppのテストと結果が一致するようになります。しかし、今の自分のプログラムは結果が一致しません。addItemメソッドは問題なさそうなのですが、おそらくgetItemメソッドに問題があると思われます。以下のプログラムを実行すると一回しか取り出されるはずの内60が3回も表示されてしまいます。教えていただきたいことはなぜ60が3回も表示されてしまうのかとどのようにコードを書けばテストと同じ結果が返ってくるのかが知りたいです。プログラムは以下の通りです。\n\n**main.cpp**\n\n```\n\n #include <iostream>\n #include \"Heap.h\"\n \n using namespace std;\n \n \n \n int main() {\n \n const int NUM_VALUES = 15;\n \n int heapVals[NUM_VALUES] = {10, 5, 30, 15, 20, 40, 60, 25, 50, 35, 45, 65, 70, 75, 55};\n \n cout << \"Creating heap of default size (10)\" << endl;\n Heap pile;\n \n // load the heap with values\n cout << \"Now filling it with 15 values, should cause doubling of size\" << endl << endl;\n for(int i = 0; i < NUM_VALUES; i++)\n pile.addItem(heapVals[i]);\n \n // remove values, should be in ascending order\n cout << \"Now removing values to see if properly ordered\" << endl;\n cout << \" In order s/b: 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75\" << endl;\n cout << \" Actual order: \";\n for(int i = 0; i < NUM_VALUES; i++)\n cout << pile.getItem() << \" \" ;\n cout << endl << endl;\n }\n \n```\n\n**Heap.cpp**\n\n```\n\n #include \"Heap.h\"\n \n #include <iostream>\n \n //default constructor\n Heap::Heap()\n {\n //the array size is STANDARD + 1\n arraySize = STANDARD + 1;\n //create an array it starts from 0 and ends at N(size+1)\n array = new int [arraySize];\n for(int i = 1; i < arraySize; i++)\n {\n array[i] = EMPTY;\n }\n }\n \n //overloaded constructor\n Heap::Heap(int size)\n {\n //the array size is size + 1\n arraySize = size + 1;\n //create an array it starts from 0 and ends at N(size+1)\n array = new int[arraySize];\n for(int i = 1; i < arraySize; i++)\n {\n array[i] = EMPTY;\n }\n }\n \n void Heap::addItem(int value)\n {\n bool done = false;\n int parentIndex;\n int childIndex;\n \n //preincrement\n counter++;\n \n //if the array will be full by adding new value, double the array size\n if(counter >= arraySize)\n {\n arraySize *= 2;\n resize(arraySize);\n }\n \n //save the first index\n childIndex = counter;\n \n //add value at the next available index (counter)\n array[counter] = value;\n \n //if it's the first added value, do nothing\n if(counter == 1)\n {\n return;\n }\n \n //if there're more than one value, place it correct position\n while(!done)\n {\n //get an index of parent\n parentIndex = childIndex / 2;\n \n //if child value >= parent value, finish the loop\n if(array[childIndex] >= array[parentIndex])\n {\n done = true;\n }\n \n //otherwise(child value < parent value)\n else\n {\n //save the parent value\n int temp = array[parentIndex];\n //store child value to parent\n array[parentIndex] = array[childIndex];\n //now, child shold have the saved parent value\n array[childIndex] = temp;\n \n //store parentIndex to childIndex for the next loop\n childIndex = parentIndex;\n \n //if the value became the root, stop the loop\n if(childIndex == 1)\n {\n done = true;\n }\n }\n \n }\n }\n \n void Heap::resize(int size)\n {\n //resize the array to the new size that is passed in\n \n //create new array to store previous values in it\n int *newArray = new int[size];\n \n for(int i = 1; i < arraySize; i++)\n {\n newArray[i] = EMPTY;\n }\n \n //move the previous values to new array\n for(int i = 1; i <= counter-1; i++)\n {\n newArray[i] = array[i];\n }\n \n //we don't need the old array anymore\n delete[] array;\n \n //array points to newArray so that the array gets new spaces\n array = newArray;\n }\n \n int Heap::getItem()\n {\n //if array is empty\n if(counter == 0)\n {\n return -1;\n }\n \n //save the smallest value in the array\n int smallest = array[1];\n \n //get the last added value\n int lastAdded = array[counter];\n //lastValue will be the root temporarily\n array[1] = lastAdded;\n //track the index of parent\n int parentIndex = 1;\n \n int done = false;\n \n //decrement counter\n counter--;\n \n //get the first index of the deepest level\n int height = getHeight(counter);\n int firstLeaf = getLeafFirst(height);\n \n \n //loop while done is true\n while(!done)\n {\n //get child index\n int childIndex = parentIndex * 2;\n \n //if both sides are empty, finish the loop\n if(array[childIndex] == EMPTY && array[parentIndex] == EMPTY)\n {\n done = true;\n }\n else\n {\n //if both sides have value, compare, and get an index whose value is smaller\n if(array[childIndex+1] != EMPTY )\n {\n //get an index that has smaller value\n if(array[childIndex] >= array[childIndex+1])\n {\n childIndex = childIndex + 1;\n }\n }\n \n //compare lastAdded and the value in the index\n //if the value in childIndex >= lastAdded, finish the loop\n if(array[childIndex] >= lastAdded)\n {\n done = true;\n }\n //otherwise(value < lastValue), swap the value\n else\n {\n //save the value\n int temp = array[childIndex];\n //array[childIndex] = lastAdded\n array[childIndex] = lastAdded;\n //array[parentIndex] = the saved value\n array[parentIndex] = temp;\n //parentIndex should be childIndex for the next loop\n parentIndex = childIndex;\n //if parent reaches leaf, finish the loop\n if(parentIndex >= firstLeaf )\n {\n done = true;\n }\n \n }\n }\n }\n //std::cout << std::endl << listElements() << \" height and first: \" << height << \" \" << firstLeaf << std::endl;\n //return the saved smallest value\n return smallest;\n }\n \n int Heap::getHeight(int value)\n {\n int height = log2(value) + 1;\n return height;\n }\n \n int Heap::getLeafLast(int height)\n {\n int num = 1;\n for(int i = 0; i < height-1; i++)\n {\n num = num * 2 + 1;\n }\n return num;\n }\n int Heap::getLeafFirst(int height)\n {\n int num = getLeafLast(height-1) + 1;\n return num;\n }\n \n```\n\n**Heap.h**\n\n```\n\n #include <iostream>\n \n const int STANDARD = 10;\n const int EMPTY = -1;\n \n class Heap {\n private:\n int arraySize;\n int counter = 0;\n int *array;\n public:\n Heap();\n Heap(int size);\n void addItem(int value);\n void resize(int value);\n int getItem();\n int getHeight(int value);\n int getLeafLast(int value);\n int getLeafFirst(int value);\n };\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T07:17:33.540",
"favorite_count": 0,
"id": "83512",
"last_activity_date": "2021-11-09T13:42:16.043",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "45177",
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "配列ヒープが期待(テスト)と異なった結果をかえす。",
"view_count": 106
} | [
{
"body": "**Heap.cpp**\nのgetItem()内のarray[parentIndex]がarray[childIndex+1]になっていないといけませんでした。\n\n```\n\n if(array[childIndex] >= array[parentIndex])\n {\n done = true;\n }\n \n```\n\nそしてさらに、`array[1] = lastAdded;`の下付近に`array[counter] = EMPTY`を入れれば解決しました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T11:01:48.770",
"id": "83518",
"last_activity_date": "2021-11-09T11:01:48.770",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "45177",
"parent_id": "83512",
"post_type": "answer",
"score": 0
},
{
"body": "`Heap::getItem()`のwhileループで\n\n```\n\n int childIndex = parentIndex * 2;\n \n```\n\nと`childIndex`を算出していますが、`childIndex`が`counter`(要素数)を超えるケースがあり、 \nデータ構造を破壊しているように見受けます。そのため、「60」が3回出力されていると思います。\n\n`childIndex`が`counter`を超える場合、ループを打ち切ってはどうでしょうか。 \n具体的には、上記処理に続けてif文で判定する感じです。\n\n```\n\n int childIndex = parentIndex * 2;\n if (childIndex > counter) {\n break;\n }\n \n```\n\n* * *\n\nなお、最後の1要素の状態で`getItem()`を呼び出した場合、`getHeight()`を引数「0」で \n呼び出すことになり、`getHeight()`内で呼び出している`log2()`がエラーになるので、 \n`counter`が「1」の場合は、`getHeight()`を呼び出す前に最初の要素を返すようにすべきと思います。\n\n### 追記\n\nコメントに回答します。\n\n 1. `counter`が1のときの対応ですが、コメント記載の内容でよいと思います。\n\nコメント抜粋:\n\n```\n\n int height;\n int firstLeaf;\n if(counter == 1)\n {\n height = 1;\n firstLeaf = 1;\n }\n else\n {\n height = getHeight(counter);\n firstLeaf = getLeafFirst(height);\n } \n \n```\n\n 2. \n\n> 確かに、最後の75以降を表示するのに時間がかかってしまいます。これはそれが問題なのでしょうか\n\n断定はできませんが、その可能性は高いと思います。 \n(`getLeafLast()`では`height`分ループしているので、意図しない大きな値になっている場合、時間がかかる)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T11:05:04.883",
"id": "83519",
"last_activity_date": "2021-11-09T13:42:16.043",
"last_edit_date": "2021-11-09T13:42:16.043",
"last_editor_user_id": "20098",
"owner_user_id": "20098",
"parent_id": "83512",
"post_type": "answer",
"score": 0
}
] | 83512 | null | 83518 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "私は5chのアニメ実況が好きで、異なる2つの実況板の書き込みを取得し、時系列順に並べなおし、一つにまとめることを考えた。\n\nところが、hawk.5ch.netでの書き込みのスクレイピングができなかった。 \nなぜ取得できないか、どうすれば取得できるのか教えていただきたい。\n\n例えば `himawari.5ch.net` のurlでコードを実行するとHTMLが表示されるが、\n\n```\n\n import requests\n from bs4 import BeautifulSoup\n res = requests.get('https://himawari.5ch.net/test/read.cgi/livetx/1523962661/')\n soup = BeautifulSoup(res.text, 'html.parser')\n print(soup)\n \n```\n\n`hawk.5ch.net` のurlで実行するとエラーが起きた。\n\n```\n\n import requests\n from bs4 import BeautifulSoup\n res = requests.get('https://hawk.5ch.net/test/read.cgi/livejupiter/1523982845/')\n soup = BeautifulSoup(res.text, 'html.parser')\n print(soup)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T09:12:34.730",
"favorite_count": 0,
"id": "83516",
"last_activity_date": "2021-11-09T14:46:37.740",
"last_edit_date": "2021-11-09T11:09:20.320",
"last_editor_user_id": "3060",
"owner_user_id": "49009",
"post_type": "question",
"score": 1,
"tags": [
"python",
"web-scraping",
"beautifulsoup"
],
"title": "スクレイピングで5chの書き込みを取得したいができない",
"view_count": 1161
} | [
{
"body": "`lxml` で行けました。あと文字化けについては、`response.encoding` の指定で直せます。\n\n```\n\n #res = requests.get('https://himawari.5ch.net/test/read.cgi/livetx/1523962661/')\n res = requests.get('https://hawk.5ch.net/test/read.cgi/livejupiter/1523982845/')\n res.encoding = res.apparent_encoding\n soup = BeautifulSoup(res.text, 'lxml')\n print(soup)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T11:11:24.253",
"id": "83520",
"last_activity_date": "2021-11-09T11:11:24.253",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7290",
"parent_id": "83516",
"post_type": "answer",
"score": 2
},
{
"body": "[Beautiful Soup Documentation](https://beautiful-\nsoup-4.readthedocs.io/en/latest/) を眺めてみると、[Installing a\nparser](https://beautiful-soup-4.readthedocs.io/en/latest/#installing-a-\nparser) という項目があります。\n\n> Another alternative is the pure-Python html5lib parser, which **parses HTML\n> the way a web browser does**. Depending on your setup, you might install\n> html5lib with one of these commands:\n>\n> $ apt-get install python-html5lib\n>\n> $ easy_install html5lib\n>\n> $ pip install html5lib\n\nHTML parser を使いたい場合は、こちらの `html5lib` も選択肢の一つに入るでしょう。\n\n```\n\n $ lsb_release -ir\n Distributor ID: Ubuntu\n Release: 21.04\n \n $ pip3 install html5lib\n \n```\n\nこれで読み込むと問題は発生しません。なお、発生している問題は malformed な HTML\nテキスト(クローズタグがないなど)のパースを無制限に行っているためです。\n\n```\n\n import requests\n from bs4 import BeautifulSoup\n \n res = requests.get('https://hawk.5ch.net/test/read.cgi/livejupiter/1523982845/')\n soup = BeautifulSoup(res.content, 'html5lib')\n \n print(soup)\n \n```\n\nここで `res.content` を指定しています。`res.text`\nはオリジナル・テキスト(エンコーディングはそのまま)ですが、`res.content` はバイト列になります。バイト列を指定して BeautifulSoup\nのインスタンスを初期化すると、内部で文字エンコーディングを推定して、`sys.getdefaultencoding()`\nで得られるエンコーディングへ自動的に変換してくれます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T14:46:37.740",
"id": "83527",
"last_activity_date": "2021-11-09T14:46:37.740",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "47127",
"parent_id": "83516",
"post_type": "answer",
"score": 1
}
] | 83516 | null | 83520 |
{
"accepted_answer_id": "83532",
"answer_count": 1,
"body": "VScodeを用いてssh接続を試みましたが,以下のようなエラーが出ました.\n\n`no such identity: C:user\\ユーザー名\\.ssh\\id_rsa: No such file or directory`\n\n私はWSLを使用しており,秘密鍵の場所がWSLの.sshの場所にあります.\n\nそこでVScodeの秘密鍵のアドレスをWindowsのユーザーからWSLの秘密鍵のアドレスに変更したいと思っているのですが,どなたか存じておりますでしょうか.\n\nご返信頂けましたら幸いです.何卒宜しくお願い致します.",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T10:13:28.900",
"favorite_count": 0,
"id": "83517",
"last_activity_date": "2021-11-10T01:30:15.970",
"last_edit_date": "2021-11-10T01:30:15.970",
"last_editor_user_id": "3060",
"owner_user_id": "49011",
"post_type": "question",
"score": 0,
"tags": [
"windows",
"vscode",
"ssh"
],
"title": "VScodeのssh秘密鍵のアドレス設定の変更ができるかどうか?",
"view_count": 343
} | [
{
"body": "VSCode は使用していないので、あくまで検索して出てきた情報を元に回答しています。\n\n* * *\n\n恐らく 拡張機能の Remote Development をインストールしているものと思われますが、コマンドパレットから「Remote -\nSSH:Editing Configuration Files」を選択して設定ファイルを開きます。\n\n以下のような書式でリモートホスト毎の設定が記述されていると思うので、`IdentityFile` で秘密鍵のパスを変更してみてください。\n\n```\n\n Host your-remote-server\n HostName your-remote-server.example.com\n User your.name\n IdentityFile C:\\Users\\your\\secret\\key\\path\\.ssh\\id_rsa\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T01:28:18.350",
"id": "83532",
"last_activity_date": "2021-11-10T01:28:18.350",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "83517",
"post_type": "answer",
"score": 0
}
] | 83517 | 83532 | 83532 |
{
"accepted_answer_id": "83525",
"answer_count": 1,
"body": "Pythonの関数の引数に対して、動的に値を紐付けたいです。\n\n以下のようなイメージです。\n\n```\n\n def sum(a,b):\n return a+b\n \n sum2=sumの引数bに1を紐付けた関数\n \n print(list(map(sum2,[1,2]))) #[2,3]\n \n```\n\nJavascriptだとbindで上記のことができたと記憶しておりますが、それのPython版が知りたいです。 \n以上、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T12:48:28.987",
"favorite_count": 0,
"id": "83521",
"last_activity_date": "2021-11-09T14:08:10.670",
"last_edit_date": "2021-11-09T14:08:10.670",
"last_editor_user_id": "3060",
"owner_user_id": "23065",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "Pythonの関数の引数に対して、動的に値を紐付けたい",
"view_count": 111
} | [
{
"body": "sumは[組み込み関数](https://docs.python.org/ja/3/library/functions.html?highlight=sum#sum)\nとしてすでに存在するので, 少し名前変えます\n\n```\n\n from functools import partial\n def sum2(a, b):\n return a+b\n \n plus1 = partial(sum2, 1)\n \n print(list(map(plus1,[1,2]))) #[2,3]\n \n \n```\n\n参考: [functools ---\n高階関数と呼び出し可能オブジェクトの操作](https://docs.python.org/ja/3/library/functools.html)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T13:44:15.277",
"id": "83525",
"last_activity_date": "2021-11-09T13:44:15.277",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43025",
"parent_id": "83521",
"post_type": "answer",
"score": 1
}
] | 83521 | 83525 | 83525 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "配列ヒープのプログラムを作りました。実際にテストしてみると期待どうりに動くのですが、なぜか最後の75だけ表示されるのに時間がかかります。何が原因かわかりますでしょうか。\n\n**main.cpp**\n\n```\n\n #include <iostream>\n #include \"Heap.h\"\n \n using namespace std;\n \n \n \n int main() {\n \n const int NUM_VALUES = 15;\n \n int heapVals[NUM_VALUES] = {10, 5, 30, 15, 20, 40, 60, 25, 50, 35, 45, 65, 70, 75, 55};\n \n cout << \"Creating heap of default size (10)\" << endl;\n Heap pile;\n \n // load the heap with values\n cout << \"Now filling it with 15 values, should cause doubling of size\" << endl << endl;\n for(int i = 0; i < NUM_VALUES; i++)\n pile.addItem(heapVals[i]);\n \n // remove values, should be in ascending order\n cout << \"Now removing values to see if properly ordered\" << endl;\n cout << \" In order s/b: 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75\" << endl;\n cout << \" Actual order: \";\n for(int i = 0; i < NUM_VALUES; i++)\n cout << pile.getItem() << \" \" ;\n cout << endl << endl;\n }\n \n \n```\n\n**Heap.cpp**\n\n```\n\n #include \"Heap.h\"\n \n #include <iostream>\n \n //default constructor\n Heap::Heap()\n {\n //the array size is STANDARD + 1\n arraySize = STANDARD + 1;\n //create an array it starts from 0 and ends at N(size+1)\n array = new int [arraySize];\n for(int i = 1; i < arraySize; i++)\n {\n array[i] = EMPTY;\n }\n }\n \n //overloaded constructor\n Heap::Heap(int size)\n {\n //the array size is size + 1\n arraySize = size + 1;\n //create an array it starts from 0 and ends at N(size+1)\n array = new int[arraySize];\n for(int i = 1; i < arraySize; i++)\n {\n array[i] = EMPTY;\n }\n }\n \n void Heap::addItem(int value)\n {\n bool done = false;\n int parentIndex;\n int childIndex;\n \n //preincrement\n counter++;\n \n //if the array will be full by adding new value, double the array size\n if(counter >= arraySize)\n {\n arraySize *= 2;\n resize(arraySize);\n }\n \n //save the first index\n childIndex = counter;\n \n //add value at the next available index (counter)\n array[counter] = value;\n \n //if it's the first added value, do nothing\n if(counter == 1)\n {\n return;\n }\n \n //if there're more than one value, place it correct position\n while(!done)\n {\n //get an index of parent\n parentIndex = childIndex / 2;\n \n //if child value >= parent value, finish the loop\n if(array[childIndex] >= array[parentIndex])\n {\n done = true;\n }\n \n //otherwise(child value < parent value)\n else\n {\n //save the parent value\n int temp = array[parentIndex];\n //store child value to parent\n array[parentIndex] = array[childIndex];\n //now, child shold have the saved parent value\n array[childIndex] = temp;\n \n //store parentIndex to childIndex for the next loop\n childIndex = parentIndex;\n \n //if the value became the root, stop the loop\n if(childIndex == 1)\n {\n done = true;\n }\n }\n \n }\n }\n \n void Heap::resize(int size)\n {\n //resize the array to the new size that is passed in\n \n //create new array to store previous values in it\n int *newArray = new int[size];\n \n for(int i = 1; i < arraySize; i++)\n {\n newArray[i] = EMPTY;\n }\n \n //move the previous values to new array\n for(int i = 1; i <= counter-1; i++)\n {\n newArray[i] = array[i];\n }\n \n //we don't need the old array anymore\n delete[] array;\n \n //array points to newArray so that the array gets new spaces\n array = newArray;\n }\n \n int Heap::getItem()\n {\n //if array is empty\n if(counter == 0)\n {\n return -1;\n }\n \n //save the smallest value in the array\n int smallest = array[1];\n \n //get the last added value\n int lastAdded = array[counter];\n //lastValue will be the root temporarily\n array[1] = lastAdded;\n array[counter] = EMPTY;\n //track the index of parent\n int parentIndex = 1;\n \n int done = false;\n \n //decrement counter\n counter--;\n \n //get the first index of the deepest level\n int height;\n int firstLeaf;\n if(counter == 1)\n {\n height = 1;\n firstLeaf = 1;\n }\n else\n {\n height = getHeight(counter);\n firstLeaf = getLeafFirst(height);\n }\n \n \n //loop while done is true\n while(!done)\n {\n //get child index\n int childIndex = parentIndex * 2;\n \n //if both sides are empty, finish the loop\n if(array[childIndex] == EMPTY && array[childIndex+1] == EMPTY)\n {\n done = true;\n }\n else\n {\n //if both sides have value, compare, and get an index whose value is smaller\n if(array[childIndex+1] != EMPTY )\n {\n //get an index that has smaller value\n if(array[childIndex] >= array[childIndex+1])\n {\n childIndex = childIndex + 1;\n }\n }\n \n //compare lastAdded and the value in the index\n //if the value in childIndex >= lastAdded, finish the loop\n if(array[childIndex] >= lastAdded)\n {\n done = true;\n }\n //otherwise(value < lastValue), swap the value\n else\n {\n //save the value\n int temp = array[childIndex];\n //array[childIndex] = lastAdded\n array[childIndex] = lastAdded;\n //array[parentIndex] = the saved value\n array[parentIndex] = temp;\n //parentIndex should be childIndex for the next loop\n parentIndex = childIndex;\n //if parent reaches leaf, finish the loop\n if(parentIndex >= firstLeaf )\n {\n done = true;\n }\n \n }\n }\n }\n //std::cout << std::endl << listElements() << \" height and first: \" << height << \" \" << firstLeaf << std::endl;\n //return the saved smallest value\n return smallest;\n }\n \n int Heap::getHeight(int value)\n {\n int height = log2(value) + 1;\n return height;\n }\n \n int Heap::getLeafLast(int height)\n {\n int num = 1;\n for(int i = 0; i < height-1; i++)\n {\n num = num * 2 + 1;\n }\n return num;\n }\n int Heap::getLeafFirst(int height)\n {\n int num = getLeafLast(height-1) + 1;\n return num;\n }\n \n \n```\n\n**Heap.h**\n\n```\n\n #include <iostream>\n \n const int STANDARD = 10;\n const int EMPTY = -1;\n \n class Heap {\n private:\n int arraySize;\n int counter = 0;\n int *array;\n public:\n Heap();\n Heap(int size);\n void addItem(int value);\n void resize(int value);\n int getItem();\n int getHeight(int value);\n int getLeafLast(int value);\n int getLeafFirst(int value);\n };\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T13:34:07.560",
"favorite_count": 0,
"id": "83523",
"last_activity_date": "2021-11-10T06:43:36.183",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "45177",
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "やりたいことはできているが、なぜかコンパイルに時間がかかる。",
"view_count": 172
} | [
{
"body": "Heap::getItem()でcounterが0になった場合に遅くなっていたみたいだったので以下の二つの変更を行ったところうまくいきました。if(counter\n!= 0)をheightとfirstLeafを求めるところに追加。while(!done)をwhile(!done && counter !=\n0)に変更し、0の時にこのループに入らないようにした。(※`while(!done && counter !=\n0)`)は変更しなくても問題ないとおもいます。)\n\n```\n\n if(counter != 0)\n {\n if(counter == 1)\n {\n height = 1;\n firstLeaf = 1;\n }\n else\n {\n height = getHeight(counter);\n firstLeaf = getLeafFirst(height);\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T06:43:36.183",
"id": "83539",
"last_activity_date": "2021-11-10T06:43:36.183",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "45177",
"parent_id": "83523",
"post_type": "answer",
"score": 0
}
] | 83523 | null | 83539 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "株の本にかいてあることを試しているのですが、こんな構文はないと言われました。 \n5行目が違うそうです。\n\n```\n\n import yahoo_fin.stock_info as si\n import pandas as pd\n import matplotlib.pyplot as plt\n from datetime import date\n from dateutil.relativedelta\n import relativedelta\n import polotly.express as px\n import numpy as np\n import seaborn as sns\n import plotly.figure_factory as ff\n import plotly.graph_objects as go\n plt.style.use('fivethirtyeight')\n plt.rcParams['figure.figsize']= [24,8]\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T13:37:47.290",
"favorite_count": 0,
"id": "83524",
"last_activity_date": "2021-11-10T05:29:08.370",
"last_edit_date": "2021-11-10T05:29:08.370",
"last_editor_user_id": "3060",
"owner_user_id": "49003",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"google-colaboratory"
],
"title": "モジュールをインポートしようとすると構文エラーになる",
"view_count": 287
} | [
{
"body": "改行しないで1行で。\n\n```\n\n from dateutil.relativedelta import relativedelta\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T13:53:45.000",
"id": "83526",
"last_activity_date": "2021-11-09T13:53:45.000",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "45045",
"parent_id": "83524",
"post_type": "answer",
"score": 3
}
] | 83524 | null | 83526 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Xcode12 \n \n初めてのプログラミング言語にswiftを勉強中です。swiftでお絵描きアプリを作っています。エラーの表示は出ていませんが、Textに記述した\"色\"や\"線幅\"の文字が表示されず困っています。また、resumeするとTextの文字以外は正しく表示されます。 \n \n**試したこと** \nWebで調べたり、参考書を見ながらコードを見直したりしましたが、Pickerの記述が間違っているのか、引数がおかしいのか特定できませんでした。widthやheightの値を変えてみたり、paddingやSpacerで間隔を空けてみたりしましたが、なぜエラーになっているのかわかりません。 \nお手数ですが、どなたかご回答いただけると幸いです。\n\n```\n\n import SwiftUI\n \n struct SettingView: View {\n @Environment(\\.presentationMode) var presentationMode\n @Binding var colorSel:Int\n @Binding var lineWidth:Int\n @Binding var colors:[Color]\n \n var body: some View {\n VStack{\n \n Picker(selection: $colorSel, label: Text(\"色\").frame(width: 40)) {\n ForEach(0..<colors.count){ value in\n if value == self.colors.count - 1 {\n Image(systemName: \"square\")\n } else {\n Image(systemName: \"paintbrush.fill\")\n .foregroundColor(self.colors[value])\n }\n }\n }\n \n Spacer()\n \n Picker(selection: $lineWidth, label: Text(\"線幅\").frame(width: 40)) {\n ForEach(1..<11){ value in\n Text(String(value))\n }\n }\n .frame(width: 30)\n \n Spacer()\n \n Button(action: {\n self.presentationMode.wrappedValue.dismiss()\n }){\n Text(\"閉じる\")\n }\n }.padding()\n }\n }\n \n struct SettingView_Previews: PreviewProvider {\n static var previews: some View {\n SettingView(colorSel: .constant(0), lineWidth: .constant(3), colors: .constant([.black, .red, .blue, .green, .white]))\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T15:17:55.597",
"favorite_count": 0,
"id": "83528",
"last_activity_date": "2021-11-10T01:31:48.160",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49015",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode12"
],
"title": "SwiftでPicker内にTextを表示したいがエラーになるので解決したいです",
"view_count": 196
} | [
{
"body": "Apple社はSwiftUIに含まれるコンポーネントのUIデザイン変更をちょくちょく行なっており、iOSのバージョンの問題か、Xcodeの問題かまではわかりませんが、少し前(Xcode\n12.2?)から「`Picker`の`label:`が表示されない」と言う話は出てきているようです。\n\n[SwiftUI (Xcode 12.2)\nのPickerのラベルが表示されない](https://www.o2-m.com/wordpress2/2020/12/01/swiftui-\nxcode-12-2-%E3%81%AEpicker%E3%81%AE%E3%83%A9%E3%83%99%E3%83%AB/)\n\n[Picker Label not showing\nanymore](https://developer.apple.com/forums/thread/688518)\n\n[SwiftUI (Xcode 12.2) Picker no longer shows\nlabel.](https://www.hackingwithswift.com/forums/swiftui/swiftui-\nxcode-12-2-picker-no-longer-shows-label/4809)\n\n残念ながらApple社製のフレームワーク(とりわけSwiftUI)ではUI部品の標準デザインが変更されると言うことは、ちょくちょく起こっていて、数ヶ月前に書かれたチュートリアルの画面がその通りには再現できなかったりします。\n\n今回の変更がApple社の意図的なものなのかどうか判るほどの記事は見つかりませんでしたので、ある日突然また動作が変えられる可能性もありますが、「SwiftUIではよくあること」くらいに捉えてチュートリアルの画面がそのまま再現されなくてもオッケー、くらいの感覚でいないといけないでしょう。\n\nどうしても「色」や「線幅」のような文言を画面に表示したければ、上記の記事のいくつかにあるように`VStack`や`HStack`などを使って`Picker`以外の場所に記述してやる必要があるでしょう。\n\n* * *\n\nこの辺り、Apple社の枠組みの中でプログラミングの勉強をしようと思うと、公式情報だけでなくネット上の情報を頼らないといけなくなることも多いですが、今回のように「コードを記述したのに意図した通り(あるいはテキストに書いてある通り)の結果にならない」ような状況を「エラーになる」と表現すると情報が得にくいと思います。\n\n「エラー」と言う言葉は一般的な広い意味でなく、\n\n * エラーメッセージとともにビルドが中断するビルド時(コンパイル時)エラー\n * ビルドが成功して実行が始まってからシステムがエラーを検出する実行時エラー\n\nだけに限定して(さらにそれらを区別して)使った方が、Q&Aサイトでは話が通じやすいと思います。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T01:31:48.160",
"id": "83533",
"last_activity_date": "2021-11-10T01:31:48.160",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "83528",
"post_type": "answer",
"score": 1
}
] | 83528 | null | 83533 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "jupyternotebookでpyaudioを\n\n!pip install pyaudio\n\nこのような形で入れたのですが \n実際に使用してみると\n\nModuleNotFoundError: No module named 'pyaudio'\n\nこのようになります。 \nバージョンが関係したりするのでしょうか。 \n解決方法を教えてほしいです。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-09T19:10:30.977",
"favorite_count": 0,
"id": "83530",
"last_activity_date": "2021-11-09T19:10:30.977",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48401",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"jupyter-notebook"
],
"title": "jupyternotebookでpyaudioを入れる方法について",
"view_count": 277
} | [] | 83530 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "# 環境\n\nRails 6.0.4 \nRuby 3.0.2 \nDocker\n\nRailsチュートリアルにDockerで環境構築をして開発を行っています \n現在10章まで進んでいるのですが、minitestでテストを行っており、機能実装前の受け入れテストコードを毎度書いていくのですが、テストコードを書くたびに必ず、「呼び出し側の引数の数」と「メソッド側の仮引数」ズレでエラーが起きてしまいます\n\n# エラー文\n\n▼ターミナル\n\n```\n\n $ docker-compose exec web bundle exec rails test\n Running via Spring preloader in process 2821\n Started with run options --seed 33308\n \n ERROR[\"test_should_redirect_update_when_not_logged_in\", #<Minitest::Reporters::Suite:0x0000aaab11031490 @name=\"UsersControllerTest\">, 0.3196210830064956]\n test_should_redirect_update_when_not_logged_in#UsersControllerTest (0.32s)\n Minitest::UnexpectedError: ArgumentError: wrong number of arguments (given 2, expected 1)\n test/controllers/users_controller_test.rb:22:in `block in <class:UsersControllerTest>'\n \n test/21: [============================================================================= ] 87% Time: 00:00:01, ETA: 00:00:00\n 24/24: [========================================================================================] 100% Time: 00:00:01, Time: 00:00:01\n \n Finished in 1.93922s\n 24 tests, 46 assertions, 0 failures, 1 errors, 0 skips\n \n```\n\n# エラーが出ているところのテストを記述している部分\n\n▼test/controllers/users_controller_test.rb\n\n```\n\n require 'test_helper'\n \n class UsersControllerTest < ActionDispatch::IntegrationTest\n \n def setup\n @user = users(:michael)\n @other_user = users(:archer)\n end\n \n test \"should get new\" do\n get signup_path\n assert_response :success\n end\n \n test \"should redirect edit when not logged in\" do\n get edit_user_path(@user)\n assert_not flash.empty?\n assert_redirected_to login_url\n end\n \n test \"should redirect update when not logged in\" do\n patch user_path(@user), params: { user: { name: @user.name, email: @user.email } } # 22行目\n assert_not flash.empty?\n assert_redirected_to login_url\n end\n \n # test \"should redirect edit when logged in as wrong user\" do\n # log_in_as(@other_user)\n # get edit_user_path(@user)\n # assert_flash.empty?\n # assert_redirected_to root_url\n # end\n \n # test \"should redirect update when logged in as wrong user\" do\n # log_in_as(@other_user)\n # patct user_path(@user), params: { user: { name: @user.name, email: @user.email } }\n # assert_flash.ematy?\n # assert_redirected_to root_url\n # end\n end\n \n```\n\n▼test/test_helper.rb\n\n```\n\n ENV['RAILS_ENV'] ||= 'test'\n require_relative '../config/environment'\n require 'rails/test_help'\n require \"minitest/reporters\"\n Minitest::Reporters.use!\n \n class ActiveSupport::TestCase\n fixtures :all\n include ApplicationHelper\n \n # テストユーザーがログイン中の場合にtrueを返す\n def is_logged_in?\n !session[:user_id].nil?\n end\n \n # テストユーザーとしてログインする\n def log_in_as(user)\n session[:user_id] = user.id\n end\n end\n \n class ActionDispatch::IntegrationTest\n \n # テストユーザーとしてログインする\n def log_in_as(user, password: 'password', remember_me: '1')\n post login_path, params: { session: { email: user.email, password: password, remember_me: remember_me } }\n end\n end\n \n```\n\n# これまでやったこと\n\nどうしてこのエラーが発生するのかは、色々ググってみて下記の記事を参考に知ることができましたが、実際自分のコードのどのようにあてはめたら良いのかわかりません。お力を貸してください!\n\n[ArgumentError: wrong number of arguments (given A, expected\nB)のA,Bの引数の判断方法](https://qiita.com/yo0917/items/20c165a3b06805bf2e37)\n\n[サンプルコードでわかる!Ruby 3.0の主な新機能と変更点 Part 2 -\n新機能と変更点の総まとめ](https://zenn.dev/jnchito/articles/24e0bd7fd1045d#hash%23each%E3%81%8C%E5%BF%85%E3%81%9A2%E8%A6%81%E7%B4%A0%E3%81%AE%E9%85%8D%E5%88%97%E3%82%92%E6%B8%A1%E3%81%99%E3%82%88%E3%81%86%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%9F)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T01:47:26.230",
"favorite_count": 0,
"id": "83534",
"last_activity_date": "2023-07-13T14:08:26.210",
"last_edit_date": "2021-11-10T09:46:29.313",
"last_editor_user_id": "36066",
"owner_user_id": "36066",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"テスト"
],
"title": "RailsテストのArgumentError: wrong number of arguments (given 2, expected 1)を解決したい",
"view_count": 1105
} | [
{
"body": "以下のように記述してparamsの前のカンマを削除してみるとどうでしょうか?\n\n```\n\n patch user_path(@user) params: { user: { name: @user.name, email: @user.email } }\n \n```\n\n参考記事 \n[Railsチュートリアル 第7章 リスト7.23のテストでArgumentError: wrong number of arguments (given\n2, expected 1)](https://qiita.com/syo19961113/items/c0c7f89a51954199fca0)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2022-08-18T16:33:31.157",
"id": "90620",
"last_activity_date": "2022-08-20T11:11:30.533",
"last_edit_date": "2022-08-20T11:11:30.533",
"last_editor_user_id": "3060",
"owner_user_id": "54050",
"parent_id": "83534",
"post_type": "answer",
"score": 0
}
] | 83534 | null | 90620 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "docker 上からホストのIPが知りたいです\n\n```\n\n Linux docker_mysqldb 5.10.47-linuxkit #1 SMP Sat Jul 3 21:51:47 UTC 2021 x86_64 GNU/Linux\n \n```\n\nuname はこれです\n\nhost には名前では host.docker.internal でアクセスできるんですが\n\n[ドキュメント](https://docs.docker.jp/docker-for-mac/networking.html)を見ると\n\n> ホストの IP アドレスは変動します(あるいは、ネットワークへの接続がありません)。18.03 よりも前は、特定の DNS 名\n> host.docker.internal での接続を推奨していました。これはホスト上で内部の IP アドレスで名前解決します。\n\nとなっていてアドレスが固定ではないようです\n\nping や nslookup とかも何もはいってないんですが何もインストールせずに知る方法はないでしょうか\n\n* * *\n```\n\n root@docker_mysqldb:/# ipconfig getifaddr en0\n bash: ipconfig: command not found\n root@docker_mysqldb:/# ifconfig\n bash: ifconfig: command not found\n root@docker_mysqldb:/# ip route\n bash: ip: command not found\n root@docker_mysqldb:/# /sbin/ip route\n bash: /sbin/ip: No such file or directory\n \n```\n\nこのあたりのコマンドがことごとく入っていません\n\nDockerfile も不明で昔作られた image だけがある状態です",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T03:48:06.860",
"favorite_count": 0,
"id": "83535",
"last_activity_date": "2021-11-10T09:41:04.710",
"last_edit_date": "2021-11-10T09:41:04.710",
"last_editor_user_id": "3060",
"owner_user_id": null,
"post_type": "question",
"score": 2,
"tags": [
"linux",
"docker"
],
"title": "ネットワーク関連のコマンドが使えない docker コンテナ内からホストのIPアドレスが知りたい",
"view_count": 356
} | [] | 83535 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "UPDATE文のWHERE句で日付の比較を行うとincorrect datetime valueが発生してしまいます。以下実行SQLです。\n\n```\n\n UPDATE SHAIN\n SET\n COLUMN1 = COLUMN2\n WHERE\n DATE_FORMAT(NOW(), '%Y%m%d') < DATE_FORMAT(LAST_DAY(TAISHABI), '%Y%m%d')\n \n```\n\nSELECT文で同じ条件で実行するとエラーが発生せず、実行されます。 \nエラーは、DATETIME型に正しい値を入れてくださいという意味だと思うのですが、 \nCOLUMN1とCOLUMN2はどちらもVARCHAR型となっており、DATETIME型はwhere句のTAISHABIだけとなります。 \nエラーを解消するにはどうすればよいでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T05:24:53.543",
"favorite_count": 0,
"id": "83538",
"last_activity_date": "2023-01-15T05:06:25.730",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49028",
"post_type": "question",
"score": 0,
"tags": [
"mysql"
],
"title": "mysqlでUPDATE文のWHERE句で日付比較を行うとincorrect datetime valueが発生する",
"view_count": 1228
} | [
{
"body": "`TAISHABI` が `'0000-00-00'` であるようなレコードが存在している状態で、 [`sql_mode` の\n`NO_ZERO_DATE`](https://dev.mysql.com/doc/refman/8.0/ja/sql-\nmode.html#sqlmode_no_zero_date) を有効化して `update`や`select`を行えば質問文のような状況になります。 \n(\"Incorrect datetime value\" のメッセージと共に、エラーとなっている値も出力されていないでしょうか)\n\nこの場合は、[`sql_mode` 設定](https://dev.mysql.com/doc/refman/8.0/ja/sql-\nmode.html#sql-mode-setting) で `NO_ZERO_DATE` を有効化しなければ `update` も通るでしょう。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T07:08:50.963",
"id": "83540",
"last_activity_date": "2021-11-10T07:08:50.963",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"parent_id": "83538",
"post_type": "answer",
"score": 1
}
] | 83538 | null | 83540 |
{
"accepted_answer_id": "83545",
"answer_count": 1,
"body": "Android Developersを参照すると `registerActivityLifecycleCallbacks` の引数は \n`Application.ActivityLifecycleCallbacks` となっているのですが \n実装例を見てみると `Application` クラスのインスタンスを渡しているようです。 \nこれはキャスト?のようなことが行われているのでしょうか? \n初歩的な質問で申し訳ありません。\n\nAndroid Developersの記述 \n`registerActivityLifecycleCallbacks(Application.ActivityLifecycleCallbacks\ncallback)`\n\n[Android\nDevelopersのページ](https://developer.android.com/reference/android/app/Application?hl=ja)\n\n実装の例\n\n```\n\n public class MainApplication extends Application\n implements Application.ActivityLifecycleCallbacks {\n \n @Override\n public void onCreate() {\n super.onCreate();\n \n registerActivityLifecycleCallbacks(this);\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T09:32:49.350",
"favorite_count": 0,
"id": "83542",
"last_activity_date": "2021-11-10T11:35:13.050",
"last_edit_date": "2021-11-10T11:18:54.313",
"last_editor_user_id": "7290",
"owner_user_id": "49031",
"post_type": "question",
"score": 1,
"tags": [
"java",
"android"
],
"title": "registerActivityLifecycleCallbacks の引数について",
"view_count": 188
} | [
{
"body": "```\n\n class MainApplication implements Application.ActivityLifecycleCallbacks\n \n```\n\nということで、その `MainApplication` は、`Application.ActivityLifecycleCallbacks`\nというインターフェースを継承しています。つまり、立派な `Application.ActivityLifecycleCallbacks` の一種です。\n\n[`registerActivityLifecycleCallbacks`](https://developer.android.com/reference/android/app/Application?hl=ja#registerActivityLifecycleCallbacks\\(android.app.Application.ActivityLifecycleCallbacks\\))\nは、`Application.ActivityLifecycleCallbacks` を引数に取るので、この `MainApplication`\n自体(`this`)を渡すことが `Application.ActivityLifecycleCallbacks` を渡すことに他ならないことになります。\n\nインターフェースなので、あくまでも、[`Application.ActivityLifecycleCallbacks`\nとして定義された各種のメソッド](https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks?hl=ja)を持つものとして扱われ、`Application`\nのサブクラス(`extended`)としての機能の部分は無視されます。ですから、`Application`\nとしてのインスタンスを渡していることにはならないと思います。\n\nつまりキャストのように、ある型から他の型へと **クラスを変換する** ようなこととは少し違うかなと。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T11:17:15.553",
"id": "83545",
"last_activity_date": "2021-11-10T11:35:13.050",
"last_edit_date": "2021-11-10T11:35:13.050",
"last_editor_user_id": "7290",
"owner_user_id": "7290",
"parent_id": "83542",
"post_type": "answer",
"score": 0
}
] | 83542 | 83545 | 83545 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "CSVセル選択モードで、あるセルに「あるく」と入力してから「歩く」に変換して確定すると、そのセルには「歩く」が入力され、次のセルには「あるく」が入力されるようにしたいのですが、そのようなことはできますか。\n\n(参考) \nふりがなを取り出す関数の使い方(PHONETIC関数):Excel関数 \n[http://www.eurus.dti.ne.jp/~yoneyama/Excel/kansu/phonetic.html](http://www.eurus.dti.ne.jp/%7Eyoneyama/Excel/kansu/phonetic.html)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-10T12:30:51.797",
"favorite_count": 0,
"id": "83546",
"last_activity_date": "2021-11-10T12:30:51.797",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43123",
"post_type": "question",
"score": 2,
"tags": [
"emeditor"
],
"title": "ExcelのPHONETIC関数に相当する機能はありますか",
"view_count": 93
} | [] | 83546 | null | null |
{
"accepted_answer_id": "83584",
"answer_count": 1,
"body": "現在JAvaScriptを利用してデリバリーのフォームを作成しています。DeliveryDateの日付指定の欄で、1.4.6.8.10.12月は31日まで表示、うるう年の2月は29日まで表示というような挙動をさせたいのですがどこのコードが間違えているのかがわかりません。要因及び解決法をご回答いただきたいです。また、このような問題の要因をどのように発見しているのかも併せて教えていただきたいです。以下がhtml及びJavaScriptのコードです。\n\n```\n\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=page-width, initial-scale=1.0\">\n <title>Snoot Flowers - Order</title>\n <link rel=\"stylesheet\" href=\"snoot.css\" />\n <link href='http://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css'>\n <script src=\"modernizr.custom.65897.js\"></script>\n </head>\n \n <body>\n <div class=\"container\">\n <header>\n <h1>\n Snoot Flowers\n </h1>\n </header>\n \n <nav>\n <ul>\n <li><a href=\"#\">Floral Arrangements</a></li>\n <li><a href=\"#\">Seasonal Bouquets</a></li>\n <li><a href=\"#\">Live Plants</a></li>\n <li><a href=\"#\">Shop by Price</a></li>\n </ul>\n </nav>\n </div>\n \n <article>\n <h2>Place an Order</h2>\n <div id=\"errorText\"></div>\n <form action=\"results.htm\">\n <fieldset id=\"message\" class=\"checks\">\n <legend>Message</legend>\n <input id=\"congrats\" name=\"Congratulations\" type=\"checkbox\" />\n <label for=\"congrats\">Congratulations!</label>\n <input id=\"bday\" name=\"HappyBirthday\" type=\"checkbox\" />\n <label for=\"bday\">Happy Birthday!</label>\n <input id=\"anniv\" name=\"HappyAnniversary\" type=\"checkbox\" />\n <label for=\"anniv\">Happy Anniversary!</label>\n <input id=\"love\" name=\"ILoveYou\" type=\"checkbox\" />\n <label for=\"love\">I love you!</label>\n <input id=\"custom\" name=\"CustomMessage\" type=\"checkbox\" />\n <label for=\"custom\">Custom message:</label>\n <textarea id=\"customText\" name=\"CustomText\" placeholder=\"Enter custom message here (max 250 characters)\"></textarea>\n <div class=\"errorMessage\"></div>\n </fieldset>\n <fieldset id=\"billingAddress\" class=\"text\">\n <legend>Billing Address</legend>\n <label for=\"billFName\">First Name</label>\n <input id=\"billFName\" name=\"BillingFirstName\" type=\"text\" required=\"required\" />\n <label for=\"billLName\">Last Name</label>\n <input id=\"billLName\" name=\"BillingLastName\" type=\"text\" required=\"required\" />\n <label for=\"billStreet\">Street Address</label>\n <input id=\"billStreet\" name=\"BillingStreet\" type=\"text\" required=\"required\" />\n <label for=\"billCity\">City</label>\n <input id=\"billCity\" name=\"BillingCity\" type=\"text\" required=\"required\" />\n <label for=\"billState\">State</label>\n <select id=\"billState\" name=\"BillingState\" required=\"required\">\n <option value=\"AL\">AL</option>\n <option value=\"AK\">AK</option>\n <option value=\"AZ\">AZ</option>\n <option value=\"AR\">AR</option>\n <option value=\"CA\">CA</option>\n <option value=\"CO\">CO</option>\n <option value=\"CT\">CT</option>\n <option value=\"DE\">DE</option>\n <option value=\"DC\">DC</option>\n <option value=\"FL\">FL</option>\n <option value=\"GA\">GA</option>\n <option value=\"HI\">HI</option>\n <option value=\"ID\">ID</option>\n <option value=\"IL\">IL</option>\n <option value=\"IN\">IN</option>\n <option value=\"IA\">IA</option>\n <option value=\"KS\">KS</option>\n <option value=\"KY\">KY</option>\n <option value=\"LA\">LA</option>\n <option value=\"ME\">ME</option>\n <option value=\"MD\">MD</option>\n <option value=\"MA\">MA</option>\n <option value=\"MI\">MI</option>\n <option value=\"MN\">MN</option>\n <option value=\"MS\">MS</option>\n <option value=\"MO\">MO</option>\n <option value=\"MT\">MT</option>\n <option value=\"NE\">NE</option>\n <option value=\"NV\">NV</option>\n <option value=\"NH\">NH</option>\n <option value=\"NJ\">NJ</option>\n <option value=\"NM\">NM</option>\n <option value=\"NY\">NY</option>\n <option value=\"NC\">NC</option>\n <option value=\"ND\">ND</option>\n <option value=\"OH\">OH</option>\n <option value=\"OK\">OK</option>\n <option value=\"OR\">OR</option>\n <option value=\"PA\">PA</option>\n <option value=\"RI\">RI</option>\n <option value=\"SC\">SC</option>\n <option value=\"SD\">SD</option>\n <option value=\"TN\">TN</option>\n <option value=\"TX\">TX</option>\n <option value=\"UT\">UT</option>\n <option value=\"VT\">VT</option>\n <option value=\"VA\">VA</option>\n <option value=\"WA\">WA</option>\n <option value=\"WV\">WV</option>\n <option value=\"WI\">WI</option>\n <option value=\"WY\">WY</option>\n </select>\n <label for=\"billZip\">Zip</label>\n <input id=\"billZip\" name=\"BillingZip\" type=\"number\" required=\"required\" />\n <label for=\"billPhone\">Phone</label>\n <input id=\"billPhone\" name=\"BillingPhone\" type=\"number\" required=\"required\" />\n <div class=\"errorMessage\"></div>\n </fieldset>\n <fieldset id=\"deliveryAddress\" class=\"text\">\n <legend>Delivery Address</legend>\n <div class=\"checks\">\n <input id=\"sameAddr\" name=\"SameAddress\" type=\"checkbox\" />\n <label for=\"sameAddr\">same as billing address</label>\n </div>\n <label for=\"delivFName\">First Name</label>\n <input id=\"delivFName\" name=\"DeliveryFirstName\" type=\"text\" required=\"required\" />\n <label for=\"delivLName\">Last Name</label>\n <input id=\"delivLName\" name=\"DeliveryLastName\" type=\"text\" required=\"required\" />\n <label for=\"delivStreet\">Street Address</label>\n <input id=\"delivStreet\" name=\"DeliveryStreet\" type=\"text\" required=\"required\" />\n <label for=\"delivCity\">City</label>\n <input id=\"delivCity\" name=\"DeliveryCity\" type=\"text\" required=\"required\" />\n <label for=\"delivState\">State</label>\n <select id=\"delivState\" name=\"DeliveryState\" required=\"required\">\n <option value=\"AL\">AL</option>\n <option value=\"AK\">AK</option>\n <option value=\"AZ\">AZ</option>\n <option value=\"AR\">AR</option>\n <option value=\"CA\">CA</option>\n <option value=\"CO\">CO</option>\n <option value=\"CT\">CT</option>\n <option value=\"DE\">DE</option>\n <option value=\"DC\">DC</option>\n <option value=\"FL\">FL</option>\n <option value=\"GA\">GA</option>\n <option value=\"HI\">HI</option>\n <option value=\"ID\">ID</option>\n <option value=\"IL\">IL</option>\n <option value=\"IN\">IN</option>\n <option value=\"IA\">IA</option>\n <option value=\"KS\">KS</option>\n <option value=\"KY\">KY</option>\n <option value=\"LA\">LA</option>\n <option value=\"ME\">ME</option>\n <option value=\"MD\">MD</option>\n <option value=\"MA\">MA</option>\n <option value=\"MI\">MI</option>\n <option value=\"MN\">MN</option>\n <option value=\"MS\">MS</option>\n <option value=\"MO\">MO</option>\n <option value=\"MT\">MT</option>\n <option value=\"NE\">NE</option>\n <option value=\"NV\">NV</option>\n <option value=\"NH\">NH</option>\n <option value=\"NJ\">NJ</option>\n <option value=\"NM\">NM</option>\n <option value=\"NY\">NY</option>\n <option value=\"NC\">NC</option>\n <option value=\"ND\">ND</option>\n <option value=\"OH\">OH</option>\n <option value=\"OK\">OK</option>\n <option value=\"OR\">OR</option>\n <option value=\"PA\">PA</option>\n <option value=\"RI\">RI</option>\n <option value=\"SC\">SC</option>\n <option value=\"SD\">SD</option>\n <option value=\"TN\">TN</option>\n <option value=\"TX\">TX</option>\n <option value=\"UT\">UT</option>\n <option value=\"VT\">VT</option>\n <option value=\"VA\">VA</option>\n <option value=\"WA\">WA</option>\n <option value=\"WV\">WV</option>\n <option value=\"WI\">WI</option>\n <option value=\"WY\">WY</option>\n </select>\n <label for=\"delivZip\">Zip</label>\n <input id=\"delivZip\" name=\"DeliveryZip\" type=\"number\" required=\"required\" />\n <label for=\"delivPhone\">Phone</label>\n <input id=\"delivPhone\" name=\"DeliveryPhone\" type=\"number\" required=\"required\" />\n <div class=\"errorMessage\"></div>\n </fieldset>\n <fieldset id=\"deliveryDate\" class=\"checks\">\n <legend>Delivery Date</legend>\n <div class=\"inline\" id=\"delivDate\">\n <select id=\"delivMo\" name=\"DelivMonth\" required=\"required\">\n <option value=\"1\">January</option>\n <option value=\"2\">February</option>\n <option value=\"3\">March</option>\n <option value=\"4\">April</option>\n <option value=\"5\">May</option>\n <option value=\"6\">June</option>\n <option value=\"7\">July</option>\n <option value=\"8\">August</option>\n <option value=\"9\">September</option>\n <option value=\"10\">October</option>\n <option value=\"11\">November</option>\n <option value=\"12\">December</option>\n </select>\n <select id=\"delivDy\" name=\"DelivDay\" required=\"required\">\n <option value=\"1\">1</option>\n <option value=\"2\">2</option>\n <option value=\"3\">3</option>\n <option value=\"4\">4</option>\n <option value=\"5\">5</option>\n <option value=\"6\">6</option>\n <option value=\"7\">7</option>\n <option value=\"8\">8</option>\n <option value=\"9\">9</option>\n <option value=\"10\">10</option>\n <option value=\"11\">11</option>\n <option value=\"12\">12</option>\n <option value=\"13\">13</option>\n <option value=\"14\">14</option>\n <option value=\"15\">15</option>\n <option value=\"16\">16</option>\n <option value=\"17\">17</option>\n <option value=\"18\">18</option>\n <option value=\"19\">19</option>\n <option value=\"20\">20</option>\n <option value=\"21\">21</option>\n <option value=\"22\">22</option>\n <option value=\"23\">23</option>\n <option value=\"24\">24</option>\n <option value=\"25\">25</option>\n <option value=\"26\">26</option>\n <option value=\"27\">27</option>\n <option value=\"28\">28</option>\n <option value=\"29\">29</option>\n <option value=\"30\">30</option>\n <option value=\"31\">31</option>\n </select>\n <select id=\"delivYr\" name=\"DelivYear\" required=\"required\">\n <option value=\"2017\">2017</option>\n <option value=\"2018\">2018</option>\n <option value=\"2019\">2019</option>\n <option value=\"2020\">2020</option>\n <option value=\"2021\">2021</option>\n <option value=\"2022\">2022</option>\n </select>\n </div>\n <div class=\"errorMessage\"></div>\n </fieldset>\n <fieldset id=\"paymentInfo\" class=\"text\">\n <legend>Payment</legend>\n <div id=\"cards\" class=\"inline\">\n <input id=\"visa\" name=\"PaymentType\" type=\"radio\" value=\"Visa\" />\n <label for=\"visa\">Visa</label>\n <input id=\"mc\" name=\"PaymentType\" type=\"radio\" value=\"MC\" />\n <label for=\"mc\">Master Card</label>\n <input id=\"discover\" name=\"PaymentType\" type=\"radio\" value=\"Discover\" />\n <label for=\"discover\">Discover</label>\n <input id=\"amex\" name=\"PaymentType\" type=\"radio\" value=\"AmEx\" />\n <label for=\"amex\">American Express</label>\n </div>\n <div>\n <label for=\"ccNum\">Card #</label>\n <input id=\"ccNum\" name=\"CardNumber\" type=\"number\" required=\"required\" />\n <div id=\"ccNumErrorMessage\"></div>\n </div>\n <div>\n <label>Expiration</label>\n <div class=\"inline\" id=\"exp\">\n <label for=\"expMo\" id=\"expMoLabel\">Expiration Month</label>\n <select id=\"expMo\" name=\"ExpMonth\" required=\"required\">\n <option value=\"01\">01</option>\n <option value=\"02\">02</option>\n <option value=\"03\">03</option>\n <option value=\"04\">04</option>\n <option value=\"05\">05</option>\n <option value=\"06\">06</option>\n <option value=\"07\">07</option>\n <option value=\"08\">08</option>\n <option value=\"09\">09</option>\n <option value=\"10\">10</option>\n <option value=\"11\">11</option>\n <option value=\"12\">12</option>\n </select>\n <label for=\"expYr\" id=\"expYrLabel\">Expiration Year</label>\n <select id=\"expYr\" name=\"ExpYear\" required=\"required\">\n <option value=\"2017\">2017</option>\n <option value=\"2018\">2018</option>\n <option value=\"2019\">2019</option>\n <option value=\"2020\">2020</option>\n <option value=\"2021\">2021</option>\n </select>\n </div>\n <label for=\"cvv\">CVV</label>\n <input id=\"cvv\" name=\"CVVValue\" type=\"number\" required=\"required\" />\n <div id=\"cvvErrorMessage\"></div>\n </div>\n <div class=\"errorMessage\"></div>\n </fieldset>\n <fieldset id=\"createAccount\" class=\"text\">\n <legend>Create Account?</legend>\n <p>To be able to access your purchase history and make changes to your order, enter a name and password to create an account.</p>\n <label for=\"username\">Username</label>\n <input id=\"username\" name=\"NewUsername\" type=\"text\" />\n <label for=\"pass1\">Password</label>\n <input id=\"pass1\" name=\"Password1\" type=\"password\" />\n <label for=\"pass2\">Password (verify)</label>\n <input id=\"pass2\" name=\"Password2\" type=\"password\" />\n <div class=\"errorMessage\"></div>\n </fieldset>\n <div id=\"buttonContainer\">\n <input type=\"submit\" value=\"Place Order\" id=\"orderButton\" />\n </div>\n </form>\n </article>\n <footer>Snoot Flowers <span>•</span> Davenport, Iowa</footer>\n <script src=\"snoot1.js\"></script>\n </body>\n </html>\n \n```\n\n```\n\n \"use strict\"; //interpret document contents in JavaScript strict mode\n \n /* global variables */\n var twentyNine = document.createDocumentFragment();\n var thirty = document.createDocumentFragment();\n var thirtyOne = document.createDocumentFragment();\n \n /* set up node building blocks for selection list of days */\n \n function setupDays() {\n \n var dates = document.getElementById(\"delivDy\").getElementsByTagName(\"option\");\n \n //default is 1..28, index 0..27\n twentyNine.appendChild(dates[28].cloneNode(true)); // add 29th\n \n thirty.appendChild(dates[28].cloneNode(true));\n thirty.appendChild(dates[29].cloneNode(true)); // add 29th & 30th\n \n thirtyOne.appendChild(dates[28].cloneNode(true));\n thirtyOne.appendChild(dates[29].cloneNode(true));\n thirtyOne.appendChild(dates[30].cloneNode(true)); // add 29th, 30th, 31st\n }\n \n function updateDays() {\n var deliveryDay = document.getElementById(\"delivDy\");\n var dates = deliveryDay.getElementsByTagName(\"option\");\n var deliveryMonth = document.getElementById(\"delivMo\");\n var deliveryYear = document.getElementById(\"delivYr\");\n var selectedMonth = deliveryMonth.options[deliveryMonth.selectedIndex].value;\n \n while (dates[28]) {\n // remove child with index of 28 until this index is empty\n deliveryDay.removeChild(dates[28]);\n }\n if (deliveryYear.selectedIndex === -1) {\n //if no year is selected, choose the first year\n deliveryYear.selectedIndex = 0;\n }\n }\n \n if (selectedMonth === \"2\" &&\n deliveryYear.options[deliveryYear.selectedIndex].value === \"2020\") {\n // if leap year, Feb has 29 days\n deliveryDay.appendChild(twentyNine.cloneNode(true));\n \n }\n \n //Thirty days have November, April, June, and September\n // 4 6, 9 and 11\n else if (selectedMonth === \"4\" || selectedMonth === \"6\" || selectedMonth === \"9\" || selectedMonth === \"11\") {\n // these months have 30 days\n deliveryDay.appendChild(thirty.cloneNode(true));\n } else if (selectedMonth === \"1\" || selectedMonth === \"3\" || selectedMonth === \"5\" || selectedMonth === \"7\" || selectedMonth === \"8\" || selectedMonth === \"10\" || selectedMonth === \"12\") {\n // these months have 31 days\n deliveryDay.appendChild(thirtyOne.cloneNode(true));\n } //switch looks good here\n \n /*remove default values and formatting from state and delivery date selection lists */\n function removeSelectDefaults() { /*state.deliveryの欄の初期値を削除*/\n var emptyBoxes = document.getElementsByTagName(\"select\");\n for (var i = 0; i < emptyBoxes.length; i++){\n emptyBoxes[i].selectedIndex = -1; /*select欄を埋めない限り動作が繰り返される*/\n }\n }\n \n /*create event Listeners*/\n function createEventListeners(){\n var deliveryMonth =document.getElementById(\"delivMo\");\n if(deliveryMonth.addEventListener){\n deliveryMonth.addEventListener(\"change\", updateDays, false);\n } else if (deliveryMonth.attachEvent) {\n deliveryMonth.attachEvent(\"onchange\", updateDays);\n }\n //we are doing same task more than once it should be a fucntion\n \n var deliveryYear = document.getElementById(\"delivYr\");\n if (deliveryYear.addEventListener) {\n deliveryYear.addEventListener(\"change\", updateDays, false);\n } else if (deliveryYear.attachEvent) {\n deliveryYear.attachEvent(\"onchange\", updateDays);\n }\n }\n \n /* run initial form configuration functions */\n function setupPage() {\n removeSelectDefaults();\n setUpDays();\n createEventListeners();\n }\n \n /*run setup function when page finishes loading. */\n if(window.addEventListener){\n window.addEventListener(\"load\",setUpPage, false);\n } else if (window.attachEvent){\n window.attachEvent(\"onload\", setUpPage);\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T00:07:48.140",
"favorite_count": 0,
"id": "83549",
"last_activity_date": "2021-11-12T10:18:05.390",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48605",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "JavaScriptを用いて日付の表示指定をしたいが機能しない",
"view_count": 82
} | [
{
"body": "# 解決法\n\nローカル変数 selectedMonth のスコープから考えて '}' の位置がずれてます、それに伴ってインデントも調整した方が良いでしょう。 \nfunction setupDays() で定義して setUpDays で呼んでいる (大文字小文字が違う) \nfunction setupPage() で定義して setUpPage で呼んでいる (大文字小文字が違う) \nこれでブラウザ上のエラーは無くなって日付の動作も出来ているように見えます。\n\n```\n\n --- snoot1_org.js\n +++ snoot1.js\n @@ -39,3 +39,2 @@\n }\n -}\n \n @@ -57,2 +56,3 @@\n } //switch looks good here\n +}\n \n @@ -87,3 +87,3 @@\n removeSelectDefaults();\n - setUpDays();\n + setupDays();\n createEventListeners();\n @@ -93,3 +93,3 @@\n if(window.addEventListener){\n - window.addEventListener(\"load\", setUpPage, false);\n + window.addEventListener(\"load\", setupPage, false);\n } else if (window.attachEvent){\n \n \n```\n\n# 発見方法\n\nブラウザの開発ツールからコンソールタブを開くとエラーメッセージが確認できます、 \n他に `console.log('Test point 001');` などと埋め込んで動作を確認するとか。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T09:15:27.953",
"id": "83584",
"last_activity_date": "2021-11-12T10:18:05.390",
"last_edit_date": "2021-11-12T10:18:05.390",
"last_editor_user_id": "40304",
"owner_user_id": "40304",
"parent_id": "83549",
"post_type": "answer",
"score": 1
}
] | 83549 | 83584 | 83584 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "GASプログラムを最近始めた者です。21/11/9に突然、スクリプトエディタ内のコード部分にロードマークが現れ、コードが表示されなくなってしまいました。いままでspreadsheet→スクリプトエディタにてコード画面を開いており、ネット上にあった、異なる現象(ファイルが開けない、権限がないなど)対応策もいくつか試してみましたが、一向に改善されません。また、いくら待っても応答なしやエラーなどは表示されずエラー?の検討もできておりません。\n\n以前のバージョンよりコードだけは救出いたしましたが、実行は不可能な状態です。googleの不具合や更新なども11月には起きていないようですが、同様の現象が起きている方や解決した方がいらっしゃいましたらご教授いただければと思います。よろしくお願い致します。\n\n**試したこと**\n\n * すべてのアカウントからログアウト\n * 別のブラウザの利用(普段利用:Google Chrome、検証ブラウザ:IE)\n * キャッシュの削除(全期間)\n * Google Chrome右上のアカウント同期及び削除\n * 他PC端末の利用\n * PCの再起動\n * 別spreadsheetを作成(同様の現象が起きます。このとき最初は、画面全体は灰色で上部に青色のバーが行ったり来たりしている状態。このまま待っても特に何も起きないため、ページロードをかけると、コード部分にロードマークが現れるという状態となる)\n * 組織PC(上記を行った)ものに、組織外のアカウントを利用しても同様の現象が見られた。\n * (予定)組織外の自機PCにて、組織外アカウントを利用し、同様の現象が起きるかの検証。\n\n**11/12追記**\n\n所属している組織でも同様の現象が確認できたため、googleに問い合わせ中との連絡がありました。原因が判明次第、再度追記致します。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T02:15:17.297",
"favorite_count": 0,
"id": "83552",
"last_activity_date": "2021-11-12T08:50:15.780",
"last_edit_date": "2021-11-12T08:50:15.780",
"last_editor_user_id": "14101",
"owner_user_id": "49040",
"post_type": "question",
"score": 0,
"tags": [
"google-apps-script"
],
"title": "Google Apps Script コード画面の無限ロードに関して",
"view_count": 362
} | [] | 83552 | null | null |
{
"accepted_answer_id": "83554",
"answer_count": 1,
"body": "C言語におけるコマンドライン引数の処理と \n<errno.h>を用いたエラー対処について聞きたいことがあります。 \n想定している仕様と実行環境はC99, C11あたりとPOSIX互換OSです。\n\nコマンドライン引数を検査して、それがプログラムの仕様を満たしていない場合、 \nエラーを表示してプログラムを停止させようとしています。\n\nこういう場合、たいていの教科書 \n(一例: 渡辺知恵美『システムプログラミング入門』)では、 \nprintf関数などを用いてエラーメッセージを出力するという実装を行っています。 \nまた、実用されるソフトウェアでは、 \n(一例: [musl libcのgetopt関数の(現時点での)実装](https://git.musl-\nlibc.org/cgit/musl/tree/src/misc/getopt.c?id=b76f37fd5625d038141b52184956fb4b7838e9a5#n16))では、 \n自前の関数のなかでfwrite関数などを用いてエラーメッセージを出力しています。\n\nそこで、 \n標準(例えば[The Open Group Base Specifications Issue 7, 2018\nedition](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html))で用意されているエラーコード \n(コンパイル中に実行環境に応じたエラー番号に展開されるマクロ文字列) \nの中から、 \n今のエラー状況を説明するのに適したものを選び、 \nそれをその場でerrno変数に設定してから、 \nperror関数でメッセージを出してもいいですか。 \n「いいですか」というのはかなり微妙な聞き方で申し訳ないのですが、 \n「実装もできてちゃんと動いている(ように見える)けど、 \nこのやり方ではマズいことが起こる」 \nあるいは \n「この設計はある理由から悪手である」 \nといったことを知りたいです。\n\n※「自分で考えた独自のエラーコードを設定する」ことではなく、 \n「(標準で定義されている)エラーコードから自分が適当であると判断した \nものを選び、それをその場でerrno変数に設定する」 \nことを想定しています。 \n「自分で設定する」のはerrno変数であり、 \nエラーコードは既存のものを使います。\n\n実装の例::\n\n```\n\n #include <stdio.h>\n #include <stdlib.h>\n #include <errno.h>\n \n /*\n * $ prog\n * → 引数がないので失敗\n * $ prog a\n * → 引数があるので成功(実際はこの後色々処理)\n */\n \n int main(\n int argc,\n char* argv[]\n ) {\n if (argc != 2) {\n /*\n * 問題の箇所。\n * この場所における「エラーの状況」は、\n * 「引数の個数が違う」という状況なので、\n * https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html\n * などを参考に、\n * 「引数が不正である」ことを意味する\n * EINVALというエラーコードをerrno変数に設定する。\n */\n errno = EINVAL;\n \n perror(\"Needs command line argument\");\n exit(EXIT_FAILURE);\n }\n \n printf(\"Argument is: %s.\\n\", argv[1]);\n \n exit(EXIT_SUCCESS);\n }\n \n```\n\n実演:: \n<https://wandbox.org/permlink/pH32RuTr0K4DLs3j>\n\nそもそも、どうしてerrno変数とperror関数とを使いたいかというと、 \nエラー対処の方法を「統一」したいなと思ったからです。 \n例示したプログラムは引数の個数のみを調べて終了していますが、 \n実際には、例えばstrtol関数によって引数文字列を数値として読むなど、 \nより複雑な引数処理が行われますよね。 \nそういう場面におけるエラー対処は、 \n(少なくともある教科書では)ほとんどがperror関数を用いて行われています。 \nこれは、そこでの処理に用いる関数が \nエラーコードをerrno変数に設定することによって \nエラーおよびその種別を報告するからなのですが、 \n逆に「実行する処理がerrno変数を設定しないという理由で、 \nperror関数を用いた統一的なエラー対処を行わないのはちょっと変じゃないか」 \nと感じたのです。 \nそこで、errno変数にエラーコードをその場で設定することで、 \nエラー対処方法を \n「errno変数とperror関数とを用いる」ことに統一しようとした次第です。\n\nエラーコードをerrno変数を設定しない処理でのエラー対処において、 \n自分でerrno変数を設定するという行為の危険性や、 \n反対に、業務プログラムやOSSなど実用プログラムにかかわるなかで、 \nそういった実装をした、あるいは出会った経験がありましたら \n教えていただきたいです。 \nまた、そもそも実用のプログラムではperror関数は使わないほうがいい、 \nというような暗黙の常識などがあれば、ぜひ知りたいです。\n\nよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T03:12:00.957",
"favorite_count": 0,
"id": "83553",
"last_activity_date": "2021-11-11T04:57:13.663",
"last_edit_date": "2021-11-11T04:29:24.067",
"last_editor_user_id": "19601",
"owner_user_id": "19601",
"post_type": "question",
"score": 2,
"tags": [
"c",
"command-line"
],
"title": "C言語において、自分で適当だと判断した標準のエラーコードを選んでerrno変数に設定し、コマンドライン引数のエラー対処を行っても問題ないですか",
"view_count": 243
} | [
{
"body": "[man errno](https://linuxjm.osdn.jp/html/LDP_man-pages/man3/errno.3.html)\nにも書かれていますが `errno` は「変更可能な左辺値」ですので「変更することは問題ない」です。マニュアルには `0`\nにするとよい状況が書かれています。かつ、エラーコード値は正の整数値であるとされています。説明がそれだけということはつまり、具体的なエラーコード値が何であるかは\nPOSIX では規定していません。実際、ウチの hpux11.11 と cygwin でエラー値は異なります。\n\ncygwin では `#define ENOTEMPTY 90` \nhpux11.11 では `#define ENOTEMPTY 247`\n\nということで、あなたが新しい `EHOGEPIYO`\nなるエラーコードを採用しようとしたとして、それに割り振るエラー値は既にシステムが用意している値とカブルかもしれません。かぶらせてしまうと誤動作します。\n\nまた当然ながら `perror()` もあなたの追加した `EHOGEPIYO` に対してエラーメッセージを持っていませんから、使い道がないです。\n\nなので `EHOGEPIYO` なるエラーコードをユーザーの一人が勝手に使おうとしても、それだけではシステム全体に追加することにはならない上に POSIX\nシステム間での互換性がなくなるので意味がない=誰もやらない、ということです。\n\n* * *\n\n質問が編集された結果内容が変わったので追記\n\nQ. `errno` に、標準のエラー値( `EINVAL` など)を自分で設定することは是か非か \nA. [man errno](https://linuxjm.osdn.jp/html/LDP_man-pages/man3/errno.3.html)\nには末端プログラマが `errno=0;` とすべき状況が書かれていますが非0値を代入することに関して良いとも悪いとも書かれていません。 `errno`\nが「変更可能な左辺値」である以上は非0値を代入することができます。あなたが POSIX ライブラリ関数(の拡張)の作者であるなら必要な時に `errno`\nに `EINVAL` を代入することは問題ないでしょう。ライブラリ関数が `errno=0;`\nにすることはないと解説されていますので、ライブラリ関数(の拡張)の作者としては `errno=0;`\nとすることはまずそうです。ライブラリ関数の作者でない一般プログラマがあっても「代入すること」自体は問題ないです。\n\n通常のプログラムで `errno=EINVAL;` のようなコードをあまり見ない理由は単純です。\n\n * `errno` を変更するのはライブラリ関数であるというコンセンサスが既にある\n * 関数の引数とプログラムの引数は使用者にとって違うものなので、「関数の引数が間違っている」をもって「プログラムの使い方が間違っている」の意味にしてしまうと混乱が生じるであろう\n * POSIX 仕様が決めているエラーコードとエラーメッセージでは「あなたのプログラム固有のエラー」を表現しきれないであろう(末端使用者にとってはエラーメッセージなど不要で usage の解説が出るほうが嬉しいかもしれない)\n * POSIX 仕様が定めていない各システム固有の拡張エラーコードとエラーメッセージを使うと移植性がなくなる\n\n使い手のことを考えない、プログラマだけの論理でコード書いても喜ばれないです。将来にわたって自分以外の人物が使うことは絶対ないと断言できるならお好きにどうぞ。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T03:41:33.507",
"id": "83554",
"last_activity_date": "2021-11-11T04:57:13.663",
"last_edit_date": "2021-11-11T04:57:13.663",
"last_editor_user_id": "8589",
"owner_user_id": "8589",
"parent_id": "83553",
"post_type": "answer",
"score": 3
}
] | 83553 | 83554 | 83554 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "VagrantとVirtualBoxを使用して仮想マシンを作成しようとしていますが、エラーが出てしまい先に進めません。\n\n**参考にした書籍:** \n「ビジネスサイトを作って学ぶWordPressの教科書」19ページ\n\nPCはマックを使用しており、著者の本の正誤表はすでに確認しております。\n\n以下の通りコマンドを実行しても poweroff (virtualbox)と表示されてしまいます。 \nrunning(virtualbox)と表示されるのが理想です。\n\n**実行時のログ (全体):**\n\n```\n\n Last login: Thu Nov 11 14:34:52 on ttys000\n \n The default interactive shell is now zsh.\n To update your account to use zsh, please run `chsh -s /bin/zsh`.\n For more details, please visit https://support.apple.com/kb/HT208050.\n kei-no-MacBook-Air:~ kei$ cd /Users/kei/Desktop/\n kei-no-MacBook-Air:Desktop kei$ mkdir pacificmall\n kei-no-MacBook-Air:Desktop kei$ cd pacificmall\n kei-no-MacBook-Air:pacificmall kei$ vagrant init prime-strategy/kusanagi-wp5 --box-version 1.0\n A `Vagrantfile` has been placed in this directory. You are now\n ready to `vagrant up` your first virtual environment! Please read\n the comments in the Vagrantfile as well as documentation on\n `vagrantup.com` for more information on using Vagrant.\n kei-no-MacBook-Air:pacificmall kei$ ls\n Vagrantfile\n kei-no-MacBook-Air:pacificmall kei$ vagrant up\n Bringing machine 'default' up with 'virtualbox' provider...\n ==> default: Importing base box 'prime-strategy/kusanagi-wp5'...\n ==> default: Matching MAC address for NAT networking...\n ==> default: Checking if box 'prime-strategy/kusanagi-wp5' version '1.0' is up to date...\n ==> default: There was a problem while downloading the metadata for your box\n ==> default: to check for updates. This is not an error, since it is usually due\n ==> default: to temporary network problems. This is just a warning. The problem\n ==> default: encountered was:\n ==> default: \n ==> default: SSL certificate problem: self signed certificate in certificate chain\n ==> default: \n ==> default: If you want to check for box updates, verify your network connection\n ==> default: is valid and try again.\n ==> default: Setting the name of the VM: pacificmall_default_1636615684491_31898\n ==> default: Clearing any previously set network interfaces...\n The IP address configured for the host-only network is not within the\n allowed ranges. Please update the address used to be within the allowed\n ranges and run the command again.\n \n Address: 192.168.33.10\n Ranges: 192.168.56.0/21\n \n Valid ranges can be modified in the /etc/vbox/networks.conf file. For\n more information including valid format see:\n \n https://www.virtualbox.org/manual/ch06.html#network_hostonly\n kei-no-MacBook-Air:pacificmall kei$ vagrant status\n Current machine states:\n \n default poweroff (virtualbox)\n \n The VM is powered off. To restart the VM, simply run `vagrant up`\n kei-no-MacBook-Air:pacificmall kei$ \n \n```\n\nVagrantfile\n\n```\n\n # -*- mode: ruby -*-\n # vi: set ft=ruby :\n \n # All Vagrant configuration is done below. The \"2\" in Vagrant.configure\n # configures the configuration version (we support older styles for\n # backwards compatibility). Please don't change it unless you know what\n # you're doing.\n Vagrant.configure(\"2\") do |config|\n # The most common configuration options are documented and commented below.\n # For a complete reference, please see the online documentation at\n # https://docs.vagrantup.com.\n \n # Every Vagrant development environment requires a box. You can search for\n # boxes at https://vagrantcloud.com/search.\n config.vm.box = \"prime-strategy/kusanagi-wp5\"\n config.vm.box_version = \"1.0\"\n \n # Disable automatic box update checking. If you disable this, then\n # boxes will only be checked for updates when the user runs\n # `vagrant box outdated`. This is not recommended.\n # config.vm.box_check_update = false\n \n # Create a forwarded port mapping which allows access to a specific port\n # within the machine from a port on the host machine. In the example below,\n # accessing \"localhost:8080\" will access port 80 on the guest machine.\n # NOTE: This will enable public access to the opened port\n # config.vm.network \"forwarded_port\", guest: 80, host: 8080\n \n # Create a forwarded port mapping which allows access to a specific port\n # within the machine from a port on the host machine and only allow access\n # via 127.0.0.1 to disable public access\n # config.vm.network \"forwarded_port\", guest: 80, host: 8080, host_ip: \"127.0.0.1\"\n \n # Create a private network, which allows host-only access to the machine\n # using a specific IP.\n config.vm.network \"private_network\", ip: \"192.168.33.10\"\n \n # Create a public network, which generally matched to bridged network.\n # Bridged networks make the machine appear as another physical device on\n # your network.\n # config.vm.network \"public_network\"\n \n # Share an additional folder to the guest VM. The first argument is\n # the path on the host to the actual folder. The second argument is\n # the path on the guest to mount the folder. And the optional third\n # argument is a set of non-required options.\n # config.vm.synced_folder \"../data\", \"/vagrant_data\"\n \n # Provider-specific configuration so you can fine-tune various\n # backing providers for Vagrant. These expose provider-specific options.\n # Example for VirtualBox:\n #\n # config.vm.provider \"virtualbox\" do |vb|\n # # Display the VirtualBox GUI when booting the machine\n # vb.gui = true\n #\n # # Customize the amount of memory on the VM:\n # vb.memory = \"1024\"\n # end\n #\n # View the documentation for the provider you are using for more\n # information on available options.\n \n # Enable provisioning with a shell script. Additional provisioners such as\n # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the\n # documentation for more information about their specific syntax and use.\n # config.vm.provision \"shell\", inline: <<-SHELL\n # apt-get update\n # apt-get install -y apache2\n # SHELL\n end\n \n```\n\nホストオンリーネットワークのために設定されたIPアドレスは、許された範囲内にない。 \n許された範囲内にあるように用いられたアドレスをアップデートし、再びコマンドを実行してください。\n\nアドレス:192.168.33.10 \n範囲:192.168.56.0/21\n\n有効な範囲は、/etc/vbox/networks.conf ファイルにおいて修正できる。 \n詳細については、有効なフォーマット見る。:\n\n<https://www.virtualbox.org/manual/ch06.html#network_hostonly>\n\nと出てきますが、方法がわかりません、どなたか分かる方はいらっしゃいますか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T03:57:09.663",
"favorite_count": 0,
"id": "83555",
"last_activity_date": "2022-01-24T03:04:40.753",
"last_edit_date": "2021-11-12T08:05:00.503",
"last_editor_user_id": "3060",
"owner_user_id": "49042",
"post_type": "question",
"score": 0,
"tags": [
"macos",
"vagrant",
"virtualbox"
],
"title": "VagrantとVirtualBoxでの仮想マシンの作成時に poweroff (virtualbox) と表示されてしまう",
"view_count": 3519
} | [
{
"body": "Vagrantfileのこの部分\n\n```\n\n config.vm.network \"private_network\", ip: \"192.168.33.10\"\n \n```\n\nを下記に変えたところ、うまく行くと教えていただきました。\n\n```\n\n config.vm.network \"private_network\", ip: \"192.168.56.10\"\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T14:28:37.783",
"id": "83588",
"last_activity_date": "2021-11-17T03:19:04.923",
"last_edit_date": "2021-11-17T03:19:04.923",
"last_editor_user_id": "14101",
"owner_user_id": "49042",
"parent_id": "83555",
"post_type": "answer",
"score": 2
}
] | 83555 | null | 83588 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "マージソートを行うプログラムを作りましたが、手を加えたはずの配列が何も変わらず帰ってきてしまいます。いろいろ調べた結果、mergeで並びを変えたはずの配列がrecMergeSortに戻ってくると変更前に戻ってしまっていました。配列の受けわたしがうまくいっていないのが原因だと思われますが、どこが間違っているのかがわかりません。\n\n**main.cpp**\n\n```\n\n #include <iostream>\n #include \"recFunc.h\"\n \n using namespace std;\n \n \n \n int main() {\n \n const int NUM_VALUES = 8;\n \n int mergeArray[NUM_VALUES] = {6, 3, 5, 1, 8, 2, 4, 8};\n \n // show starting array\n cout << \"Starting array is \" << endl;\n for(int i = 0; i < NUM_VALUES; i++)\n cout << mergeArray[i] << \" \";\n cout << endl;\n \n // now sort it\n mergeSort(mergeArray, NUM_VALUES);\n \n // show updated array, should be in ascending order\n cout << \"Now the array should be sorted\" << endl;\n cout << \" expected: 1 2 3 4 5 6 7 8\" << endl;\n cout << \" actually: \";\n for(int i = 0; i < NUM_VALUES; i++)\n cout << mergeArray[i] << \" \";\n cout << endl;\n \n cout << endl << \"Done with testing merge sort\" << endl << endl;\n return 0;\n }\n \n```\n\n**recFunc.cpp**\n\n```\n\n #include <iostream>\n #include \"recFunc.h\"\n \n void mergeSort(int* array, int size)\n {\n recMergeSort(array, size);\n }\n \n void recMergeSort(int* array, int size)\n {\n if(size <= 1)\n {\n return;\n }\n \n int middle = (size - 1) / 2;\n int* arrayLeft = new int [middle+1];\n int* arrayRight = new int [(size-1)-middle];\n for(int i = 0; i < middle+1; i++)\n {\n arrayLeft[i] = array[i];\n }\n for(int i = 0; i < (size-1)-middle; i++)\n {\n arrayRight[i] = array[(middle+1)+i];\n }\n \n recMergeSort(arrayLeft, middle+1);\n \n recMergeSort(arrayRight, (size-1)-middle);\n \n int* temp = merge(arrayLeft, middle+1, arrayRight, (size-1)-middle);\n \n array = temp;\n \n }\n \n int* merge(int* arrayLeft, int leftSize, int* arrayRight, int rightSize)\n {\n int left = 0;\n int right = 0;\n int leftEnd = leftSize-1;\n int rightEnd = rightSize -1;\n \n int* temp = new int [leftSize+rightSize];\n \n while(left <= leftEnd && right <= rightEnd)\n {\n //if left value is smaller, save the value to temp\n if(arrayLeft[left] <= arrayRight[right])\n {\n temp[left+right] = arrayLeft[left];\n left++;\n }\n //otherwise(right value is smaller), save it\n else\n {\n temp[left+right] = arrayRight[right];\n right++;\n }\n }\n \n while(left <= leftEnd)\n {\n temp[left+right] = arrayLeft[left];\n left++;\n }\n while(right <= rightEnd)\n {\n temp[left+right] = arrayRight[right];\n right++;\n }\n \n \n \n return temp;\n }\n \n```\n\n**recFunc.h**\n\n```\n\n int* merge(int* arrayLeft, int leftSize, int* arrayRight, int rightSize);\n void recMergeSort(int* array, int size);\n void mergeSort(int* array, int size);\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T08:43:43.020",
"favorite_count": 0,
"id": "83563",
"last_activity_date": "2021-11-11T09:17:42.317",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "45177",
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "マージソートを行うプログラムを作ったが、手を加えたはずの配列が何も変わらず帰ってきてしまう。",
"view_count": 150
} | [
{
"body": "```\n\n void recMergeSort(int* array, int size)\n {\n ...\n array = temp;\n \n```\n\n引数 `array` を変更しても、`array` が指す配列は変更されません。`temp` の内容を1要素ずつ `array`\nが指す先にコピーするか、`merge()` 関数に書き込み先として `array` を渡すとよさそうです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T09:17:42.317",
"id": "83565",
"last_activity_date": "2021-11-11T09:17:42.317",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3475",
"parent_id": "83563",
"post_type": "answer",
"score": 1
}
] | 83563 | null | 83565 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Object-Cで開発しております。 \n古いプロジェクトを現環境に合わせるための対応を行っております。\n\nUIWebViewを使用していた個所をWKWebViewに差し替え作業を行っております。\n\n// ViewController.h\n\n```\n\n #import <UIKit/UIKit.h>\n #import <WebKit/WebKit.h>\n #import \"MBProgressHUD.h\"\n \n @interface HoneyShopViewController : UIViewController<WKNavigationDelegate>\n {\n IBOutlet WKWebView *webView;\n }\n @property (strong, nonatomic) MBProgressHUD *hud;\n \n```\n\n// ViewController.m\n\n```\n\n #import \"ViewController.h\"\n #import <WebKit/WebKit.h>\n @import GoogleMobileAds;\n \n @interface ViewController ()\n @property (weak, nonatomic) IBOutlet GADBannerView *bannerView;\n @end\n \n @implementation ViewController\n \n - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil\n {\n self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];\n if (self) {\n // Custom initialization\n }\n return self;\n }\n \n - (void)viewDidLoad\n {\n [super viewDidLoad];\n \n self.view.backgroundColor = BODY_COLOR;\n \n webView.navigationDelegate = self;\n \n [webView.layer setBorderColor:LOG_COLOR.CGColor];\n [webView.layer setBorderWidth:2.0f];\n \n // Do any additional setup after loading the view from its nib.\n PBAppDelegate *appDelegate = (PBAppDelegate *)[UIApplication sharedApplication].delegate;\n _hud = [[MBProgressHUD alloc]initWithWindow:appDelegate.window];\n [appDelegate.window addSubview:_hud];\n \n // In this case, we instantiate the banner with desired ad size.\n self.bannerView = [[GADBannerView alloc]\n initWithAdSize:kGADAdSizeBanner];\n \n self.bannerView.adUnitID = @\"ca-app-pub-3940256099942544/2934735716\";\n //self.bannerView.adUnitID = @\"ca-app-pub-4057658985177158~5712178529\";\n self.bannerView.rootViewController = self;\n GADRequest *request = [GADRequest request];\n [self.bannerView loadRequest:request];\n [self addBannerViewToView:self.bannerView];\n }\n \n - (void)addBannerViewToView:(UIView *)bannerView {\n bannerView.translatesAutoresizingMaskIntoConstraints = NO;\n [self.view addSubview:bannerView];\n [self.view addConstraints:@[\n [NSLayoutConstraint constraintWithItem:bannerView\n attribute:NSLayoutAttributeBottom\n relatedBy:NSLayoutRelationEqual\n toItem:self.bottomLayoutGuide\n attribute:NSLayoutAttributeTop\n multiplier:1\n constant:0],\n [NSLayoutConstraint constraintWithItem:bannerView\n attribute:NSLayoutAttributeCenterX\n relatedBy:NSLayoutRelationEqual\n toItem:self.view\n attribute:NSLayoutAttributeCenterX\n multiplier:1\n constant:0]\n ]];\n }\n \n - (void)viewWillAppear:(BOOL)animated\n {\n [super viewWillAppear:animated];\n \n self.title = @\"タイトル\";\n self.hidesBottomBarWhenPushed = NO;\n PBDataManager *manager = [[[PBDataManager alloc]init]autorelease];\n NSDictionary *user = [manager getUserData];\n \n NSString *urlStr = HONEY_SHOP_URL;\n NSString *uid = [user valueForKey:@\"uid\"];\n NSString *platform = @\"ios\";\n NSString *version = [NSString stringWithFormat:@\"%@\",[[NSBundle mainBundle] objectForInfoDictionaryKey:@\"CFBundleVersion\"]];\n \n [_hud show:YES];\n NSDictionary *postParams = [[NSDictionary alloc] initWithObjectsAndKeys:uid, @\"uid\",\n [manager getToken],@\"token\",\n platform, @\"platform\",\n version, @\"version\",\n nil];\n \n AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:urlStr]];\n [httpClient setDefaultHeader:@\"x-appid\" value:@\"hogehoge\"];\n NSMutableURLRequest *request = [httpClient requestWithMethod:@\"POST\"\n path:urlStr\n parameters:postParams];\n AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];\n [httpClient registerHTTPOperationClass:[AFHTTPRequestOperation class]];\n [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {\n NSDictionary *dict =(NSDictionary *)[[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]JSONValue];\n [webView loadHTMLString:[dict objectForKey:@\"message\"] baseURL:[[NSBundle mainBundle] pathForResource:@\"html_template\" ofType:@\"html\"]];\n }failure:^(AFHTTPRequestOperation *operation, NSError *error) {\n NSLog(@\"Shop Error: %@\", error);\n [_hud hide:YES];\n }];\n \n [operation start];\n }\n \n - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler\n {\n if ([navigationAction.request.URL.scheme isEqualToString:@\"inapp\"]) {\n if ([[PBStoreManager sharedInstance] canMakePayment]) {\n [_hud show:YES];\n }\n decisionHandler(WKNavigationActionPolicyCancel);\n return;\n }\n decisionHandler(WKNavigationActionPolicyAllow);\n }\n - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(nonnull NSURLAuthenticationChallenge *)challenge completionHandler:(nonnull void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler {\n if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic] == YES){ \n NSLog(@\"didReceiveAuthenticationChallenge\");\n }else{\n completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil);\n }\n }\n - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation\n {\n [_hud hide:YES];\n }\n - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {\n [_hud hide:YES];\n }\n \n \n```\n\n上記のようなコードに修正したのですが、\n\n```\n\n webView.navigationDelegate = self;\n \n```\n\nで\n\n```\n\n Exception NSException * \"-[UIWebView setNavigationDelegate:]: unrecognized selector sent to instance 0x15ebe0d0\" 0x15e7b0c0\n \n```\n\nというエラーが出てクラッシュしてしまいます。 \nデリゲートの設定を行わなければクラッシュせず表示されるのですが、イベントの取得が出来ず、WebView内でのボタン反応が取れない状態です。\n\nこちら原因や修正方法を教えてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T09:04:27.810",
"favorite_count": 0,
"id": "83564",
"last_activity_date": "2021-11-11T10:16:20.620",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29606",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"xcode",
"objective-c"
],
"title": "WKWebViewのデリゲート設定でクラッシュ",
"view_count": 289
} | [
{
"body": "このエラーメッセージ:\n\n```\n\n -[UIWebView setNavigationDelegate:]: unrecognized selector sent to instance 0x15ebe0d0\" 0x15e7b0c0\n \n```\n\nは、iOSの実行時処理において、「 **`UIWebView`のインスタンス**\nに`setNavigationDelegate:`というセレクタを送ろうとした時に、そのセレクタがわからない」と言うエラーになったことを表しています。\n\nコード上では、`IBOutlet WKWebView\n*webView;`と、`webView`は`WKWebView`型であるかのように宣言されていますが、実際の実行時には`UIWebView`型のインスタンスが`webView`に入っている、と言う状態だと思われます。\n\nコードを`WKWebView`用のものに修正したものの、storyboard(またはxib)の方は変更できていないのではないでしょうか?\n\n##### UIWebViewの場合\n\n[](https://i.stack.imgur.com/aCmPa.png)\n\n##### WKWebViewの場合\n\n[](https://i.stack.imgur.com/3iAS6.png)\n\n該当のWebViewがstoryboard上でWKWebViewになっているかを確かめて、なっていなければいったん削除して「Web Kit\nView」をその位置に貼り付け直してください。\n\n(IBOutlet, IBActionの接続、制約の設定などが消えてしまう可能性があるので、それらも再確認してみてください。)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T10:16:20.620",
"id": "83566",
"last_activity_date": "2021-11-11T10:16:20.620",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "83564",
"post_type": "answer",
"score": 3
}
] | 83564 | null | 83566 |
{
"accepted_answer_id": "83568",
"answer_count": 1,
"body": "AndroidStudioのProjectツリーの下にdimens.xmlが見えないのですが原因が分かりません。 \n実際のフォルダ(上の画像)では確かにresフォルダにdimens.xmlは存在しています。 \nしかし、AndroidStudioから見たProjectのツリー(下の画像)にはdimens.xmlが表示されません。 \n(このdimens.xmlファイルはテンプレートを作成した際に自動的に作られたようです。)\n\nどこかのファイルで設定する必要がありますか? \n[](https://i.stack.imgur.com/3GZDt.png)\n\n[](https://i.stack.imgur.com/cBwnX.png)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T11:01:35.003",
"favorite_count": 0,
"id": "83567",
"last_activity_date": "2021-11-11T11:47:39.910",
"last_edit_date": "2021-11-11T11:18:43.857",
"last_editor_user_id": "7290",
"owner_user_id": "49031",
"post_type": "question",
"score": 0,
"tags": [
"android-studio"
],
"title": "AndroidStudioでdimens.xmlが見えない。",
"view_count": 261
} | [
{
"body": "File>Sync Project with Gradle FilesとFile> Invalidate Chaces /Restartを実行することで \nAndroidProject側から見ることができました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T11:47:39.910",
"id": "83568",
"last_activity_date": "2021-11-11T11:47:39.910",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49031",
"parent_id": "83567",
"post_type": "answer",
"score": 1
}
] | 83567 | 83568 | 83568 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Reactで子コンポーネントから親コンポーネントのuseState書き換え時の警告の修正方法がわかる方 \nご教示いただけますと幸いです。\n\n実行画面がエラーになりませんが、コンソールを開くと警告が出ていますこれを修正したいです。 \nコンソールの警告文\n\n```\n\n Warning: Cannot update a component (`App`) while rendering a different component (`Child`). To locate the bad setState() call inside `Child`, follow the stack trace as described (長いので以下略)\n \n```\n\nReact 17.0.2です。 \n下記コード \n親コンポーネント\n\n```\n\n import React, { useState } from 'react';\n import {Child} from './Child.js';\n \n const App = () => {\n const[child,setChild] = useState(\"\");\n return(\n <div>\n <Child test={setChild}/>\n {child}\n </div>\n );\n }\n export default App;\n \n```\n\n子コンポーネント\n\n```\n\n const Child = (props) => {\n const message = \"ハローワールド\"\n return(\n <p>{props.test(message)}</p>\n )\n }\n export default Child; \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T14:30:50.487",
"favorite_count": 0,
"id": "83569",
"last_activity_date": "2022-11-14T07:05:55.767",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49048",
"post_type": "question",
"score": 0,
"tags": [
"reactjs"
],
"title": "React 子コンポーネントから親コンポーネントのuseState書き換え時の警告",
"view_count": 1978
} | [
{
"body": "質問文中のコードからやりたいことが明確には分かりませんでしたが、エラーの原因と対応は公式blogに記載があります。\n\n * [レンダー中のいくつかの更新に関する警告](https://ja.reactjs.org/blog/2020/02/26/react-v16.13.0.html#warnings-for-some-updates-during-render)\n\n> React コンポーネントは、レンダー中に他のコンポーネントに副作用を起こしてはいけません。\n>\n> レンダー中に `setState` を呼び出すことはサポートされていますが同じコンポーネントに対してのみ可能です。 \n> (中略) \n> レンダーの結果として他のコンポーネントの状態を意図的に変更したいという稀なケースでは、`setState` 呼び出しを `useEffect`\n> にラップすることができます。\n\n[`useEffect`](https://ja.reactjs.org/docs/hooks-\nreference.html#useeffect)でラップ、とは、例えば次のような実装を言います:\n\n```\n\n import { useEffect } from \"react\";\n \n const Child = ({ test }) => {\n const message = \"ハローワールド\";\n useEffect(() => test(message), [test]);\n return <p></p>;\n };\n export default Child;\n \n```\n\n(\"稀なケース\" とある通り、このように実装しようとしていること自体が間違っているケースも多いと思います)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T00:42:37.287",
"id": "83573",
"last_activity_date": "2021-11-12T00:42:37.287",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"parent_id": "83569",
"post_type": "answer",
"score": 1
}
] | 83569 | null | 83573 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "[任意のSignal-to-\nNoise比の音声波形をPythonで作ろう!](https://engineering.linecorp.com/ja/blog/voice-\nwaveform-arbitrary-signal-to-noise-ratio-python/)\n\nこちらのサイトのプログラムをJupyter Notebookを利用してノイズ除去を試みているのですが、以下のエラーメッセージが起きてしまいます。\n\nこちらの解決方法を教えていただきたいです。\n\nエラーメッセージ\n\n```\n\n usage: ipykernel_launcher.py [-h] --clean_file CLEAN_FILE --noise_file NOISE_FILE\n [--output_clean_file OUTPUT_CLEAN_FILE] [--output_noise_file OUTPUT_NOISE_FILE]\n --output_noisy_file OUTPUT_NOISY_FILE --snr SNR\n ipykernel_launcher.py: error: the following arguments are required: --clean_file, --noise_file, --output_noisy_file, --snr\n An exception has occurred, use %tb to see the full traceback.\n \n SystemExit: 2\n \n```\n\nソースコード\n\n```\n\n import argparse\n import array\n import math\n import numpy as np\n import random\n import wave\n \n \n def get_args():\n parser = argparse.ArgumentParser()\n parser.add_argument('--clean_file', type=str, required=True)\n parser.add_argument('--noise_file', type=str, required=True)\n parser.add_argument('--output_clean_file', type=str, default='')\n parser.add_argument('--output_noise_file', type=str, default='')\n parser.add_argument('--output_noisy_file', type=str, default='', required=True)\n parser.add_argument('--snr', type=float, default='', required=True)\n args = parser.parse_args()\n return args\n \n if __name__ == '__main__':\n args = get_args()\n \n clean_file = args.clean_file\n noise_file = args.noise_file\n snr = args.snr\n \n clean_wav = wave.open(clean_file, \"r\")\n noise_wav = wave.open(noise_file, \"r\")\n \n```\n\n関連サイトやTeratailに載っていた質問等を試してみたのですが、思うような結果にならず同じようなエラーメッセージが出てしまいます。\n\n以下に参考サイトを添付しておきます。\n\n * [普通のpython実行ファイル(argparseを含むファイル)をJupyter notebookで実行するときのメモ書き](https://qiita.com/LittleWat/items/6e56857e1f97c842b261)\n * [Jupyter lab / notebookで argparseそのままで実行する方法](https://qiita.com/uenonuenon/items/09fa620426b4c5d4acf9)\n * [Python3 Jupyter notebook使用時のエラー(usage: ipykernel_launcher.py [-h] [-w WEIGHTS] [-m])について](https://teratail.com/questions/185053)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T14:55:35.007",
"favorite_count": 0,
"id": "83570",
"last_activity_date": "2021-11-12T01:12:32.000",
"last_edit_date": "2021-11-12T01:12:32.000",
"last_editor_user_id": "3060",
"owner_user_id": "48401",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"jupyter-notebook"
],
"title": "(usage: ipykernel_launcher.py [-h] [-w WEIGHTS] [-m])というエラーがJupyter Notebookの実行時に出てしまう",
"view_count": 830
} | [] | 83570 | null | null |
{
"accepted_answer_id": "83597",
"answer_count": 1,
"body": "以下のようなシンプルなコードを動かした場合、Labelの値がリアルタイムに更新されません。正確にはウィンドウを動かすと値が更新され、何も触らないでいると更新されません。描画更新が止まっているような、そんな感じがあります。また、async/await\nをやめると1秒は待ってくれませんが値の更新は高速に行われます。\n\nバックグラウンドで値を1秒ごとに更新するようなWPFアプリは作成できないのでしょうか?\n\n```\n\n // MainWindow.xaml\n /*\n <Window x:Class=\"WpfApp32.MainWindow\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n xmlns:local=\"clr-namespace:WpfApp32\"\n mc:Ignorable=\"d\"\n Title=\"MainWindow\" Height=\"450\" Width=\"800\">\n <DockPanel>\n <Label DockPanel.Dock=\"Top\" Content=\"{Binding Value}\" Height=\"40\" HorizontalContentAlignment=\"Center\" VerticalContentAlignment=\"Center\"/>\n </DockPanel>\n </Window>\n */\n \n // MainWindow.xaml.cs\n \n using System;\n using System.ComponentModel;\n using System.Runtime.CompilerServices;\n using System.Threading.Tasks;\n using System.Windows;\n \n namespace WpfApp32\n {\n public partial class MainWindow : Window\n {\n public MainWindow()\n {\n InitializeComponent();\n \n this.DataContext = new MainWindowVM();\n }\n }\n \n public class MainWindowVM : INotifyPropertyChanged\n {\n public event PropertyChangedEventHandler PropertyChanged;\n \n public int Value { get; set; } = 0;\n \n public MainWindowVM()\n {\n Task.Run(async () => {\n while (true)\n {\n Value++;\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(\"Value\"));\n await Task.Delay(1000);\n }\n });\n }\n }\n }\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T15:32:38.593",
"favorite_count": 0,
"id": "83571",
"last_activity_date": "2021-11-13T04:15:44.407",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "18863",
"post_type": "question",
"score": 1,
"tags": [
"c#"
],
"title": "Task.Delay使用時、WPFでプロパティの値がリアルタイムに更新されない",
"view_count": 427
} | [
{
"body": "この現象はデバッグ実行しているときのみ発生し、ホットリロードが設定されていることが原因でした。Visual Studio の [ツール(T)] →\n[オプション(O)] からオプションを開き、[デバッグ] → [XAMLホットリロード] の設定項目の [XAML ホットリロードを有効にする]\nをオフにすることで今回の問題は解決しました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T04:15:44.407",
"id": "83597",
"last_activity_date": "2021-11-13T04:15:44.407",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "18863",
"parent_id": "83571",
"post_type": "answer",
"score": 2
}
] | 83571 | 83597 | 83597 |
{
"accepted_answer_id": "83575",
"answer_count": 1,
"body": "WSL2のUbuntu 20.04 LTS にて以下の手順で実行したが、ブラウザが起動せずにエラーが表示される。\n\n`npx playwright codegen wikipedia.org` を実行したら、ブラウザが起動しコードを生成できるようにしたい。\n\n**再現手順:**\n\n```\n\n npm i -D @playwright/test\n npx playwright install\n npx playwright codegen wikipedia.org\n \n```\n\n**エラーメッセージ:**\n\n```\n\n browserType.launch: Browser closed.\n ==================== Browser output: ====================\n <launching> /home/yusuke/.cache/ms-playwright/chromium-930007/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-yVdHID --remote-debugging-pipe --no-startup-window\n <launched> pid=4232\n [pid=4232][err] [4232:4232:1112/033124.605300:FATAL:ozone_platform_x11.cc(238)] Check failed: x11::Connection::Get()->Ready(). Missing X server or $DISPLAY\n [pid=4232][err] #0 0x55d2f7921f99 base::debug::CollectStackTrace()\n [pid=4232][err] #1 0x55d2f788c513 base::debug::StackTrace::StackTrace()\n [pid=4232][err] #2 0x55d2f789ff10 logging::LogMessage::~LogMessage()\n [pid=4232][err] #3 0x55d2f78a0a5e logging::LogMessage::~LogMessage()\n [pid=4232][err] #4 0x55d2f4b27a29 ui::(anonymous namespace)::OzonePlatformX11::InitializeUI()\n [pid=4232][err] #5 0x55d2f4ac5067 ui::OzonePlatform::InitializeForUI()\n [pid=4232][err] #6 0x55d2f8ff7507 aura::Env::Init()\n [pid=4232][err] #7 0x55d2f8ff749a aura::Env::CreateInstance()\n [pid=4232][err] #8 0x55d2f54c109f content::BrowserMainLoop::InitializeToolkit()\n [pid=4232][err] #9 0x55d2f54c1a4d content::BrowserMainRunnerImpl::Initialize()\n [pid=4232][err] #10 0x55d2f54bddfb content::BrowserMain()\n [pid=4232][err] #11 0x55d2f7429692 content::ContentMainRunnerImpl::RunBrowser()\n [pid=4232][err] #12 0x55d2f7429157 content::ContentMainRunnerImpl::Run()\n [pid=4232][err] #13 0x55d2f74269c5 content::RunContentProcess()\n [pid=4232][err] #14 0x55d2f742749e content::ContentMain()\n [pid=4232][err] #15 0x55d2f41e7226 ChromeMain\n [pid=4232][err] #16 0x7f41010f30b3 __libc_start_main\n [pid=4232][err] #17 0x55d2f41e702a _start\n [pid=4232][err] Crash keys:\n [pid=4232][err] \"io_scheduler_async_stack\" = \"0x55D2F52A3FE4 0x0\"\n [pid=4232][err] \"variations\" = \"19ebe09a-4542122,23a898eb-fc93cf74,5f2c0f7c-3f4a17df,e4a357e9-3f4a17df,\"\n [pid=4232][err] \"num-experiments\" = \"4\"\n [pid=4232][err] \"switch-30\" = \"--enable-crashpad\"\n [pid=4232][err] \"switch-29\" = \"--no-startup-window\"\n [pid=4232][err] \"switch-28\" = \"--remote-debugging-pipe\"\n [pid=4232][err] \"switch-27\" = \"--user-data-dir=/tmp/playwright_chromiumdev_profile-yVdHID\"\n [pid=4232][err] \"switch-26\" = \"--no-sandbox\"\n [pid=4232][err] \"switch-25\" = \"--no-service-autorun\"\n [pid=4232][err] \"switch-24\" = \"--use-mock-keychain\"\n [pid=4232][err] \"switch-23\" = \"--password-store=basic\"\n [pid=4232][err] \"switch-22\" = \"--enable-automation\"\n [pid=4232][err] \"switch-21\" = \"--no-first-run\"\n [pid=4232][err] \"switch-20\" = \"--metrics-recording-only\"\n [pid=4232][err] \"switch-19\" = \"--force-color-profile=srgb\"\n [pid=4232][err] \"switch-18\" = \"--disable-sync\"\n [pid=4232][err] \"switch-17\" = \"--disable-renderer-backgrounding\"\n [pid=4232][err] \"switch-16\" = \"--disable-prompt-on-repost\"\n [pid=4232][err] \"switch-15\" = \"--disable-popup-blocking\"\n [pid=4232][err] \"switch-14\" = \"--disable-ipc-flooding-protection\"\n [pid=4232][err] \"switch-13\" = \"--disable-hang-monitor\"\n [pid=4232][err] \"switch-12\" = \"--allow-pre-commit-input\"\n [pid=4232][err] \"switch-11\" = \"--disable-features=ImprovedCookieControls,LazyFrameLoading,Globa\"\n [pid=4232][err] \"switch-10\" = \"--disable-extensions\"\n [pid=4232][err] \"switch-9\" = \"--disable-dev-shm-usage\"\n [pid=4232][err] \"switch-8\" = \"--disable-default-apps\"\n [pid=4232][err] \"switch-7\" = \"--disable-component-extensions-with-background-pages\"\n [pid=4232][err] \"switch-6\" = \"--disable-client-side-phishing-detection\"\n [pid=4232][err] \"switch-5\" = \"--disable-breakpad\"\n [pid=4232][err] \"switch-4\" = \"--disable-backgrounding-occluded-windows\"\n [pid=4232][err] \"switch-3\" = \"--disable-background-timer-throttling\"\n [pid=4232][err] \"switch-2\" = \"--enable-features=NetworkService,NetworkServiceInProcess\"\n [pid=4232][err] \"switch-1\" = \"--disable-background-networking\"\n [pid=4232][err] \"num-switches\" = \"30\"\n [pid=4232][err] \"osarch\" = \"x86_64\"\n [pid=4232][err] \"pid\" = \"4232\"\n [pid=4232][err] \"ptype\" = \"browser\"\n [pid=4232][err]\n [pid=4232][err] [1112/033124.650794:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)\n [pid=4232][err] [1112/033124.650846:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)\n [pid=4232][err] Received signal 6\n [pid=4232][err] #0 0x55d2f7921f99 base::debug::CollectStackTrace()\n [pid=4232][err] #1 0x55d2f788c513 base::debug::StackTrace::StackTrace()\n [pid=4232][err] #2 0x55d2f7921a71 base::debug::(anonymous namespace)::StackDumpSignalHandler()\n [pid=4232][err] #3 0x7f4101fc43c0 (/usr/lib/x86_64-linux-gnu/libpthread-2.31.so+0x153bf)\n [pid=4232][err] #4 0x7f410111218b gsignal\n [pid=4232][err] #5 0x7f41010f1859 abort\n [pid=4232][err] #6 0x55d2f7920d05 base::debug::BreakDebuggerAsyncSafe()\n [pid=4232][err] #7 0x55d2f78a033f logging::LogMessage::~LogMessage()\n [pid=4232][err] #8 0x55d2f78a0a5e logging::LogMessage::~LogMessage()\n [pid=4232][err] #9 0x55d2f4b27a29 ui::(anonymous namespace)::OzonePlatformX11::InitializeUI()\n [pid=4232][err] #10 0x55d2f4ac5067 ui::OzonePlatform::InitializeForUI()\n [pid=4232][err] #11 0x55d2f8ff7507 aura::Env::Init()\n [pid=4232][err] #12 0x55d2f8ff749a aura::Env::CreateInstance()\n [pid=4232][err] #13 0x55d2f54c109f content::BrowserMainLoop::InitializeToolkit()\n [pid=4232][err] #14 0x55d2f54c1a4d content::BrowserMainRunnerImpl::Initialize()\n [pid=4232][err] #15 0x55d2f54bddfb content::BrowserMain()\n [pid=4232][err] #16 0x55d2f7429692 content::ContentMainRunnerImpl::RunBrowser()\n [pid=4232][err] #17 0x55d2f7429157 content::ContentMainRunnerImpl::Run()\n [pid=4232][err] #18 0x55d2f74269c5 content::RunContentProcess()\n [pid=4232][err] #19 0x55d2f742749e content::ContentMain()\n [pid=4232][err] #20 0x55d2f41e7226 ChromeMain\n [pid=4232][err] #21 0x7f41010f30b3 __libc_start_main\n [pid=4232][err] #22 0x55d2f41e702a _start\n [pid=4232][err] r8: 0000000000000000 r9: 00007fff5da957c0 r10: 0000000000000008 r11: 0000000000000246\n [pid=4232][err] r12: 00000e62000c8b40 r13: 00007fff5da95a20 r14: 00000e62000c8b50 r15: aaaaaaaaaaaaaaaa\n [pid=4232][err] di: 0000000000000002 si: 00007fff5da957c0 bp: 00007fff5da95a10 bx: 00007f40fff30e40\n [pid=4232][err] dx: 0000000000000000 ax: 0000000000000000 cx: 00007f410111218b sp: 00007fff5da957c0\n [pid=4232][err] ip: 00007f410111218b efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000\n [pid=4232][err] trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000\n [pid=4232][err] [end of stack trace]\n =========================== logs ===========================\n <launching> /home/yusuke/.cache/ms-playwright/chromium-930007/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-yVdHID --remote-debugging-pipe --no-startup-window\n <launched> pid=4232\n [pid=4232][err] [4232:4232:1112/033124.605300:FATAL:ozone_platform_x11.cc(238)] Check failed: x11::Connection::Get()->Ready(). Missing X server or $DISPLAY\n [pid=4232][err] #0 0x55d2f7921f99 base::debug::CollectStackTrace()\n [pid=4232][err] #1 0x55d2f788c513 base::debug::StackTrace::StackTrace()\n [pid=4232][err] #2 0x55d2f789ff10 logging::LogMessage::~LogMessage()\n [pid=4232][err] #3 0x55d2f78a0a5e logging::LogMessage::~LogMessage()\n [pid=4232][err] #4 0x55d2f4b27a29 ui::(anonymous namespace)::OzonePlatformX11::InitializeUI()\n [pid=4232][err] #5 0x55d2f4ac5067 ui::OzonePlatform::InitializeForUI()\n [pid=4232][err] #6 0x55d2f8ff7507 aura::Env::Init()\n [pid=4232][err] #7 0x55d2f8ff749a aura::Env::CreateInstance()\n [pid=4232][err] #8 0x55d2f54c109f content::BrowserMainLoop::InitializeToolkit()\n [pid=4232][err] #9 0x55d2f54c1a4d content::BrowserMainRunnerImpl::Initialize()\n [pid=4232][err] #10 0x55d2f54bddfb content::BrowserMain()\n [pid=4232][err] #11 0x55d2f7429692 content::ContentMainRunnerImpl::RunBrowser()\n [pid=4232][err] #12 0x55d2f7429157 content::ContentMainRunnerImpl::Run()\n [pid=4232][err] #13 0x55d2f74269c5 content::RunContentProcess()\n [pid=4232][err] #14 0x55d2f742749e content::ContentMain()\n [pid=4232][err] #15 0x55d2f41e7226 ChromeMain\n [pid=4232][err] #16 0x7f41010f30b3 __libc_start_main\n [pid=4232][err] #17 0x55d2f41e702a _start\n [pid=4232][err] Crash keys:\n [pid=4232][err] \"io_scheduler_async_stack\" = \"0x55D2F52A3FE4 0x0\"\n [pid=4232][err] \"variations\" = \"19ebe09a-4542122,23a898eb-fc93cf74,5f2c0f7c-3f4a17df,e4a357e9-3f4a17df,\"\n [pid=4232][err] \"num-experiments\" = \"4\"\n [pid=4232][err] \"switch-30\" = \"--enable-crashpad\"\n [pid=4232][err] \"switch-29\" = \"--no-startup-window\"\n [pid=4232][err] \"switch-28\" = \"--remote-debugging-pipe\"\n [pid=4232][err] \"switch-27\" = \"--user-data-dir=/tmp/playwright_chromiumdev_profile-yVdHID\"\n [pid=4232][err] \"switch-26\" = \"--no-sandbox\"\n [pid=4232][err] \"switch-25\" = \"--no-service-autorun\"\n [pid=4232][err] \"switch-24\" = \"--use-mock-keychain\"\n [pid=4232][err] \"switch-23\" = \"--password-store=basic\"\n [pid=4232][err] \"switch-22\" = \"--enable-automation\"\n [pid=4232][err] \"switch-21\" = \"--no-first-run\"\n [pid=4232][err] \"switch-20\" = \"--metrics-recording-only\"\n [pid=4232][err] \"switch-19\" = \"--force-color-profile=srgb\"\n [pid=4232][err] \"switch-18\" = \"--disable-sync\"\n [pid=4232][err] \"switch-17\" = \"--disable-renderer-backgrounding\"\n [pid=4232][err] \"switch-16\" = \"--disable-prompt-on-repost\"\n [pid=4232][err] \"switch-15\" = \"--disable-popup-blocking\"\n [pid=4232][err] \"switch-14\" = \"--disable-ipc-flooding-protection\"\n [pid=4232][err] \"switch-13\" = \"--disable-hang-monitor\"\n [pid=4232][err] \"switch-12\" = \"--allow-pre-commit-input\"\n [pid=4232][err] \"switch-11\" = \"--disable-features=ImprovedCookieControls,LazyFrameLoading,Globa\"\n [pid=4232][err] \"switch-10\" = \"--disable-extensions\"\n [pid=4232][err] \"switch-9\" = \"--disable-dev-shm-usage\"\n [pid=4232][err] \"switch-8\" = \"--disable-default-apps\"\n [pid=4232][err] \"switch-7\" = \"--disable-component-extensions-with-background-pages\"\n [pid=4232][err] \"switch-6\" = \"--disable-client-side-phishing-detection\"\n [pid=4232][err] \"switch-5\" = \"--disable-breakpad\"\n [pid=4232][err] \"switch-4\" = \"--disable-backgrounding-occluded-windows\"\n [pid=4232][err] \"switch-3\" = \"--disable-background-timer-throttling\"\n [pid=4232][err] \"switch-2\" = \"--enable-features=NetworkService,NetworkServiceInProcess\"\n [pid=4232][err] \"switch-1\" = \"--disable-background-networking\"\n [pid=4232][err] \"num-switches\" = \"30\"\n [pid=4232][err] \"osarch\" = \"x86_64\"\n [pid=4232][err] \"pid\" = \"4232\"\n [pid=4232][err] \"ptype\" = \"browser\"\n [pid=4232][err]\n [pid=4232][err] [1112/033124.650794:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)\n [pid=4232][err] [1112/033124.650846:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)\n [pid=4232][err] Received signal 6\n [pid=4232][err] #0 0x55d2f7921f99 base::debug::CollectStackTrace()\n [pid=4232][err] #1 0x55d2f788c513 base::debug::StackTrace::StackTrace()\n [pid=4232][err] #2 0x55d2f7921a71 base::debug::(anonymous namespace)::StackDumpSignalHandler()\n [pid=4232][err] #3 0x7f4101fc43c0 (/usr/lib/x86_64-linux-gnu/libpthread-2.31.so+0x153bf)\n [pid=4232][err] #4 0x7f410111218b gsignal\n [pid=4232][err] #5 0x7f41010f1859 abort\n [pid=4232][err] #6 0x55d2f7920d05 base::debug::BreakDebuggerAsyncSafe()\n [pid=4232][err] #7 0x55d2f78a033f logging::LogMessage::~LogMessage()\n [pid=4232][err] #8 0x55d2f78a0a5e logging::LogMessage::~LogMessage()\n [pid=4232][err] #9 0x55d2f4b27a29 ui::(anonymous namespace)::OzonePlatformX11::InitializeUI()\n [pid=4232][err] #10 0x55d2f4ac5067 ui::OzonePlatform::InitializeForUI()\n [pid=4232][err] #11 0x55d2f8ff7507 aura::Env::Init()\n [pid=4232][err] #12 0x55d2f8ff749a aura::Env::CreateInstance()\n [pid=4232][err] #13 0x55d2f54c109f content::BrowserMainLoop::InitializeToolkit()\n [pid=4232][err] #14 0x55d2f54c1a4d content::BrowserMainRunnerImpl::Initialize()\n [pid=4232][err] #15 0x55d2f54bddfb content::BrowserMain()\n [pid=4232][err] #16 0x55d2f7429692 content::ContentMainRunnerImpl::RunBrowser()\n [pid=4232][err] #17 0x55d2f7429157 content::ContentMainRunnerImpl::Run()\n [pid=4232][err] #18 0x55d2f74269c5 content::RunContentProcess()\n [pid=4232][err] #19 0x55d2f742749e content::ContentMain()\n [pid=4232][err] #20 0x55d2f41e7226 ChromeMain\n [pid=4232][err] #21 0x7f41010f30b3 __libc_start_main\n [pid=4232][err] #22 0x55d2f41e702a _start\n [pid=4232][err] r8: 0000000000000000 r9: 00007fff5da957c0 r10: 0000000000000008 r11: 0000000000000246\n [pid=4232][err] r12: 00000e62000c8b40 r13: 00007fff5da95a20 r14: 00000e62000c8b50 r15: aaaaaaaaaaaaaaaa\n [pid=4232][err] di: 0000000000000002 si: 00007fff5da957c0 bp: 00007fff5da95a10 bx: 00007f40fff30e40\n [pid=4232][err] dx: 0000000000000000 ax: 0000000000000000 cx: 00007f410111218b sp: 00007fff5da957c0\n [pid=4232][err] ip: 00007f410111218b efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000\n [pid=4232][err] trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000\n [pid=4232][err] [end of stack trace]\n ============================================================\n at launchContext (/home/yusuke/develop/playwrightStudy/node_modules/@playwright/test/node_modules/playwright-core/lib/cli/cli.js:298:37)\n at Command.listener [as _actionHandler] (/home/yusuke/develop/playwrightStudy/node_modules/commander/lib/command.js:488:17)\n at /home/yusuke/develop/playwrightStudy/node_modules/commander/lib/command.js:1227:65\n at Command._chainOrCall (/home/yusuke/develop/playwrightStudy/node_modules/commander/lib/command.js:1144:12)\n at Command._parseCommand (/home/yusuke/develop/playwrightStudy/node_modules/commander/lib/command.js:1227:27)\n at Command._dispatchSubcommand (/home/yusuke/develop/playwrightStudy/node_modules/commander/lib/command.js:1050:25)\n at Command._parseCommand (/home/yusuke/develop/playwrightStudy/node_modules/commander/lib/command.js:1193:19)\n at Command.parse (/home/yusuke/develop/playwrightStudy/node_modules/commander/lib/command.js:897:10)\n at Object.<anonymous> (/home/yusuke/develop/playwrightStudy/node_modules/@playwright/test/cli.js:17:18) {\n name: 'Error'\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-11T18:37:07.713",
"favorite_count": 0,
"id": "83572",
"last_activity_date": "2022-11-24T03:10:38.603",
"last_edit_date": "2021-11-12T01:19:58.290",
"last_editor_user_id": "3060",
"owner_user_id": "36906",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "npx playwright codegen wikipedia.org を実行してもブラウザが開かない",
"view_count": 1458
} | [
{
"body": "更新: \n本文末で補足していたWSLgについて、Windows10でも利用可能になったようです。 \n(Microsoft\nStore版([参考記事](https://forest.watch.impress.co.jp/docs/news/1458044.html));\n[Pre-requisites節](https://github.com/microsoft/wslg/blob/main/README.md#pre-\nrequisites)参照)\n\nつまり、Microsoft Store版をインストールしたのであれば、ここに記載した手順でなくWSLgのREADMEを参照してください。\n\n* * *\n\n> Check failed: x11::Connection::Get()->Ready(). Missing X server or $DISPLAY\n\nとありますので、X server の設定、 `DISPLAY` 環境変数の設定が必要と思われます。\n\n * [Can't use X-Server in WSL 2 #4106](https://github.com/microsoft/WSL/issues/4106#issuecomment-917564903)\n\nに設定方法等が記載されています。\n\nWindows側の初期設定:\n\n 1. [VcXsrv](https://sourceforge.net/projects/vcxsrv/) をインストールします\n 2. `XLauncher`(`xlaunch.exe`) を起動し、次の設定を行います: \n 1. \"Multiple windows\" をチェック\n 2. \"Start no client\" をチェック\n 3. \"Native opengl\" のチェックを外す、 **\" Disable access control\" をチェック**(重要)\n 4. \"Save configuration\" で設定を保存\n 3. \"完了\" を押すと上記の設定で起動します\n 4. (`xlaunch.exe` のショートカットを作成して引数に `-ac -run <設定ファイル>` を設定しておくと、次回起動はこのショートカットから行えます([参考](https://sourceforge.net/p/vcxsrv/wiki/Using%20VcXsrv%20Windows%20X%20Server/)))\n\nUbuntu側の初期設定:\n\n 1. `~/.bashrc` に次を追記: \n``` export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk\n'{print $4}'):0.0\n\n```\n\n 2. `source ~/.bashrc` で上の設定を読み込み\n\n上記設定が完了すれば、`npx playwright codegen wikipedia.org` が実行できるようになります。\n\n* * *\n\n要件を満たしているのであれば(≒ Windows11 であれば) `VcXsrv` の代わりに\n[`WSLg`](https://github.com/microsoft/wslg) も利用できそうです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T02:33:36.627",
"id": "83575",
"last_activity_date": "2022-11-24T03:10:38.603",
"last_edit_date": "2022-11-24T03:10:38.603",
"last_editor_user_id": "2808",
"owner_user_id": "2808",
"parent_id": "83572",
"post_type": "answer",
"score": 1
}
] | 83572 | 83575 | 83575 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "embulkによりmysql内の特定カラムと同じ内容のカラムをコピーしたいのですが、 \nfilter プラグインの「embulk-filter-column」がうまく機能してくれずコピーできません。\n\nやりかたはこちらを参考にしました。 \n<https://qiita.com/sonots/items/1acb9c53f0566bf78a9e>\n\nログからも原因と解決策は抽出できませんでした。\n\n何が間違ってると思われるでしょうか? \n文法ミスの指摘お願い致します。\n\n```\n\n in:\n type: mysql\n host: {{ env.HOST }}\n user: {{ env.USER }}\n password: {{ env.PASS }}\n database: {{ env.DB }}\n \n filter:\n - type: column\n columns:\n - {name: DATA_COPY, src: DATE}\n \n out:\n type: bigquery\n mode: replace\n auth_method: json_key\n json_keyfile: '{{ env.CREDENTIAL }}'\n path_prefix: tmp\n allow_quoted_newlines: 1 #\n file_ext: .csv.gz\n source_format: CSV\n project: {{ env.PROJECT }}\n dataset: {{ env.DATASET }}\n auto_create_table: true\n table: {{ env.TABLE }}\n formatter: {type: csv, charset: UTF-8, delimiter: ',', header_line: false}\n encoders:\n - {type: gzip}\n \n```\n\nIN情報\n\n```\n\n ID,DATE\n 1,2021-11-12\n \n```\n\nOUT情報\n\n```\n\n ID,DATE\n 1,2021-11-12\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T02:53:55.403",
"favorite_count": 0,
"id": "83576",
"last_activity_date": "2021-11-12T13:12:08.777",
"last_edit_date": "2021-11-12T03:02:13.513",
"last_editor_user_id": "7290",
"owner_user_id": "36855",
"post_type": "question",
"score": 0,
"tags": [
"embulk"
],
"title": "「embulk-filter-column」でカラムをコピーできない",
"view_count": 71
} | [
{
"body": "indent miss\n\n```\n\n filters:\n - type: column\n add_columns:\n - {name: DATA_COPY, src: DATE}\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T13:12:08.777",
"id": "83586",
"last_activity_date": "2021-11-12T13:12:08.777",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36855",
"parent_id": "83576",
"post_type": "answer",
"score": 0
}
] | 83576 | null | 83586 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "seleniumをinstallした上で `from selenium import webdriver`\nを実行すると、以下のエラーが表示されてしまいます。\n\n```\n\n Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/__init__.py\", line 18, in <module>\n from .firefox.webdriver import WebDriver as Firefox # noqa\n File \"/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py\", line 36, in <module>\n from .service import Service\n File \"/opt/anaconda3/lib/python3.8/site-packages/selenium/webdriver/firefox/service.py\", line 21, in <module>\n class Service(service.Service):\n AttributeError: module 'selenium.webdriver.common.service' has no attribute 'Service'\n \n```\n\nどなたか解決策をご教授できませんでしょうか。 \nよろしくお願いいたします。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T04:19:47.877",
"favorite_count": 0,
"id": "83578",
"last_activity_date": "2021-11-18T10:57:45.327",
"last_edit_date": "2021-11-17T03:39:43.807",
"last_editor_user_id": "14101",
"owner_user_id": "48873",
"post_type": "question",
"score": 0,
"tags": [
"anaconda",
"selenium-webdriver",
"import"
],
"title": "seleniumでwebdriverをimportできません",
"view_count": 448
} | [
{
"body": "原因:pythonのモジュールinstallのやり方 \n対策:「conda install ~」でモジュールをインストールできなければ、「conda install -c conda-\nforge」で試してみる。その際には、新たにpython仮想環境を作成、アクティベートし、他の何らかの影響を受けない形で行う。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-18T10:57:45.327",
"id": "83697",
"last_activity_date": "2021-11-18T10:57:45.327",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48873",
"parent_id": "83578",
"post_type": "answer",
"score": 0
}
] | 83578 | null | 83697 |
{
"accepted_answer_id": "83582",
"answer_count": 1,
"body": "jqを使用してjsonファイルをcsvに変換したいです。 \n環境、インプットとなるjsonファイル、期待するアウトプット(csvファイル)を次に示します。\n\n_**〇環境**_ \ncentOS7.6 \njq-1.6\n\n_**〇インプットファイル(jsonファイル)**_\n\n```\n\n {\n \"count\":000,\n \"resultList\": {\n \"from\": 1,\n \"result\": [\n {\n \"IOs\": 0.0000,\n \"timestamp\": 1633359600000\n },\n {\n \"IOs\": 1.0000,\n \"timestamp\": 1633350000000\n }\n ],\n \"to\":000\n }\n }\n \n```\n\n_**〇期待するアウトプット(csvファイル)**_\n\n```\n\n IOs,timestamp\n 0.0000,1633359600000\n 1.0000,1633350000000\n \n```\n\n_**※補足**_ \nresult内の値をcsv化したいです。 \n1行目にkey名が表題としてほしいです。 \n2行目以降にvalueが羅列する形を期待しています。 \nkey名(IOs,timestamp)は、固定ではなく様々なkey名と数に対応するようにしたいです。\n\n_**〇試したこと**_ \n2回実行になってしまいますが、 \n1回目の実行:1行目のkey名の表題を出力(※1) \n2回目の実行:result配下の値を出力(※2) \nという形で実現できないか、と考えました。\n\n```\n\n // (※1)\n # jq -r '[.resultList.result|.[]|[keys]|.[]|.[]]|unique|@csv' test.json | tee -a ./out.csv\n \"IOs\",\"timestamp\"\n #\n // (※2)\n # jq '.resultList.result[] | [.IOs,.timestamp]|@csv' test.json | tee -a ./out.csv\n \"0,1633359600000\"\n \"1,1633350000000\"\n #\n # cat ./out.csv\n \"IOs\",\"timestamp\"\n \"0,1633359600000\"\n \"1,1633350000000\"\n #\n \n```\n\n_**〇問題**_ \n2回目の実行にてkey名([.IOs,.timestamp])を指定しての実行しか方法が分からずに困っております。 \n正規表現などで、key名を指定せずに実行する方法はないでしょうか。 \nその際、key数も可変的に対応できるようにできるのが理想となります。\n\nまた、上記のような2回実行しないでもよい方法がございましたらご教示いただけますと幸いです。 \nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T08:02:36.703",
"favorite_count": 0,
"id": "83581",
"last_activity_date": "2021-11-12T17:58:20.977",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49057",
"post_type": "question",
"score": 1,
"tags": [
"linux",
"json",
"jq"
],
"title": "jqを使用してjsonファイルをcsvに変換したい",
"view_count": 831
} | [
{
"body": "```\n\n $ cat test.json | jq -r '\n .resultList.result|[.[0]|keys], map([.[]])|.[]|@csv'\n \n #\n \"IOs\",\"timestamp\"\n 0,1633359600000\n 1,1633350000000\n \n```\n\n`@csv` を使っているので `-r`(raw output)\nオプションが無視されています。ヘッダ部のカラム名に付いているダブルクォートを除去したい場合は、ヘッダ部にだけ `join` を使うと良いかと思います。\n\n```\n\n $ cat test.json | jq -r '\n .resultList.result|(.[0]|keys|join(\",\")), (map([.[]])|.[]|@csv)'\n #\n IOs,timestamp\n 0,1633359600000\n 1,1633350000000\n \n```\n\n**余談**\n\n[pandas - Python Data Analysis Library](https://pandas.pydata.org/) を使うと、JSON\n形式のデータを簡単に CSV 形式へ変換することができます。\n\n```\n\n import json\n import pandas as pd\n \n json_file = 'test.json'\n \n with open(json_file) as f:\n json_data = json.load(f)\n \n df = pd.json_normalize(json_data['resultList']['result'])\n df.to_csv('out.csv', float_format='%.4f', index=False)\n \n```\n\n**out.csv**\n\n```\n\n IOs,timestamp\n 0.0000,1633359600000\n 1.0000,1633350000000\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T08:50:36.890",
"id": "83582",
"last_activity_date": "2021-11-12T17:58:20.977",
"last_edit_date": "2021-11-12T17:58:20.977",
"last_editor_user_id": "47127",
"owner_user_id": "47127",
"parent_id": "83581",
"post_type": "answer",
"score": 2
}
] | 83581 | 83582 | 83582 |
{
"accepted_answer_id": "83595",
"answer_count": 1,
"body": "pythonのgurobiにおいて,\n\n```\n\n g={(1,1):1,(1,2):1,(1,3):1,(1,4):1,\n (2,1):1,(2,2):1,(2,3):1,(2,4):1,\n (3,1):1,(3,2):1,(3,3):1,(3,4):1,\n (4,1):1,(4,2):1,(4,3):1,(4,4):1,\n (5,1):1,(5,2):1,(5,3):1,(5,4):1,\n }\n \n P,G=multidict({1:[1,2,3,4],2:[1,2,3,4],3:[1,2,3,4],4:[1,2,3,4],5:[1,2,3,4]})\n W,H=multidict({1:[1,2,3,4,5],2:[1,2,3,4,5],3:[1,2,3,4,5],4:[1,2,3,4,5]})\n \n```\n\ng(i,j)の行列の1の時を, G_iとして,iごとに,行列に格納し, H_jとして, jごとに格納しようとしました. \nするとエラーメッセージで,\n\n```\n\n too many values to unpack (expected 2)\n \n```\n\nP,GとW,Hをどう変更すればよいのかわかりません. \n教えてください.",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T11:03:56.723",
"favorite_count": 0,
"id": "83585",
"last_activity_date": "2021-11-13T02:03:12.890",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "48372",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"データ構造",
"情報理論"
],
"title": "pythonにおけるデータ型のエラー",
"view_count": 95
} | [
{
"body": "(解決してるようなので, 回答として記しておきます)\n\n質問の「g(i,j)の行列の」の文がよくわかりません。が,\n[`gurobipy.multidict()`](https://www.gurobi.com/documentation/9.1/refman/py_multidict.html)\nでは, キーとそれぞれの内容の項目が分解されるようです \nなので, 1つ目の multidict指定の行は keyと 4項目で 5つ分, 2つ目の行は 6つ分になり, 左辺の項目が足りません。\n\n * もしも `G` にすべての辞書を取り込むのなら `*G` と指定すれば OK\n * `G_1`, `G_2` … と指定したいなら, `G_4`まで, `H`は `H_5`まで記すと良いでしょう\n\n* * *\n\n値を取り出す場合: \n`*H` として 5つ分の辞書を取り込んだなら, `H`は listであり, 次のように指定すると一つずつ辞書を取り出せます\n\n```\n\n for d in H:\n print(d)\n \n```\n\n辞書の値を取り出すならこんな感じ\n\n```\n\n for j in W:\n print([d[j] for d in H])\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T01:55:56.640",
"id": "83595",
"last_activity_date": "2021-11-13T02:03:12.890",
"last_edit_date": "2021-11-13T02:03:12.890",
"last_editor_user_id": "43025",
"owner_user_id": "43025",
"parent_id": "83585",
"post_type": "answer",
"score": 1
}
] | 83585 | 83595 | 83595 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "VimでのDart開発環境を構築しようとしているのですがうまく行きません。 \n`vim-lsp`と`vim-lsp-settings`をインストールしています。(dart-vim-pluginはインストールしていません。) \n`vim-lsp-settings`のREADME.mdに記載されている例を参考に自分の環境に合うようにvimrcを変更しました。(下記)\n\nしかし、この設定をしてdartのファイルを開き、`:LspStatus`をしても`analysis-server-dart-snapshot:\nexited`と表示されてしまいます。 \nどうすればよいのでしょうか?\n\n```\n\n let g:lsp_settings = {\n \\ 'analysis-server-dart-snapshot': {\n \\ 'cmd': [\n \\ '/home/username/.flutter/bin/dart',\n \\ '/home/username/.flutter/bin/dart-sdk/cache/bin/snapshots/analysis_server.dart.snapshot',\n \\ '--lsp'\n \\ ],\n \\ },\n \\ }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T15:43:00.980",
"favorite_count": 0,
"id": "83589",
"last_activity_date": "2021-11-14T08:59:07.863",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5246",
"post_type": "question",
"score": 0,
"tags": [
"vim",
"dart"
],
"title": "vimでのdart環境のlspの設定方法",
"view_count": 302
} | [
{
"body": "DartのlspのREADME.mdを参考に、`lsp_settings`を下記のようにしたところ動作し、自己解決したので回答として記入しておきます。 \n<https://github.com/dart-\nlang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#running-the-\nserver>\n\n```\n\n let g:lsp_settings = {\n \\ 'analysis-server-dart-snapshot': {\n \\ 'cmd': [\n \\ '/home/username/.flutter/bin/dart',\n \\ 'language-server',\n \\ ],\n \\ 'initialization_options': {\n \\ 'onlyAnalyzeProjectsWithOpenFiles': v:true,\n \\ },\n \\ },\n \\ }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T08:46:21.617",
"id": "83613",
"last_activity_date": "2021-11-14T08:59:07.863",
"last_edit_date": "2021-11-14T08:59:07.863",
"last_editor_user_id": "5246",
"owner_user_id": "5246",
"parent_id": "83589",
"post_type": "answer",
"score": 1
}
] | 83589 | null | 83613 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "じゃんけんの対戦回数と勝敗の戦績を.txtファイルに記録して表示したいのですが、私が作成した下記のソースコードのままだと戦績がファイルに蓄積されません。どのように変更を加えれば戦績を蓄積させられるようになりますか? \nここでしばらく行き詰まっているので、わかる方がいらっしゃればご教示いただけると幸いです。よろしくお願いいたします。\n\n補足:読み込みは関数を定義していますが、書き込みはint main()内に入れてあります。分かりにくかったら申し訳ないです。\n\n```\n\n #include <stdio.h>\n #include <time.h>\n #include <stdlib.h>\n #include \"jankendata.txt\"\n \n void Read(const char *file) {\n FILE *fp;\n if ((fp = fopen(\"jankendata.txt\", \"r\"))==NULL){\n printf(\"初めての本プログラムの実行\\n\");\n }else {\n int battle=0, win=0, lose=0, draw=0;\n fscanf(fp, \"%d%d%d%d\", &battle, &win, &lose, &draw);\n printf(\"%d戦 %d勝 %d敗 %d引き分け\\n\", battle, win, lose, draw);\n fclose(fp);\n }\n }\n \n int main(void)\n { \n const char *file = \"jankendata.txt\";\n int battle=0, win=0, lose=0, draw=0;\n int me, npc, result;\n FILE *fp;\n Read(file);\n //自分が出す手の選択\n printf(\"あなたが出す手を選択->\\n【グー】:0【チョキ】:1【パー】:2終了する:3 \n \\n\");\n scanf(\"%d\", &me);\n \n if (me == 0 || me == 1 || me == 2 || me == 3){\n } else {\n printf(\"0〜3の数字を選択してください。\\n\");\n scanf(\"%d\", &me);\n }\n \n //npcが出す手の選択\n srand(time(NULL));\n npc = rand() % 3;\n printf(\"相手は%dを出した!\\n\", npc);\n \n //自分と相手との比較・結果表示\n result = (me - npc + 3) % 3;\n if (result == 2){\n printf(\"あなたの勝利\\n\");\n win ++;\n } else if (result == 1){\n printf(\"あなたの負け\\n\");\n lose ++;\n } else if (result == 0){\n printf(\"引き分け\\n\"); \n draw ++;\n }\n \n if ((fp = fopen(\"jankendata.txt\", \"w\"))==NULL){\n printf(\"\\aファイルを展開できません。\\n\");\n } else {\n battle = win + lose + draw;\n fprintf(fp, \"%d %d %d %d\\n\",battle, win, lose, draw);\n fclose(fp);\n }\n \n return EXIT_SUCCESS;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T16:40:36.890",
"favorite_count": 0,
"id": "83590",
"last_activity_date": "2021-11-12T16:55:35.773",
"last_edit_date": "2021-11-12T16:55:35.773",
"last_editor_user_id": "49063",
"owner_user_id": "49063",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "ファイルの読み込み/書き出し方法について教えてください",
"view_count": 90
} | [
{
"body": "結果を記録するためにファイルを `fopen` で開いている部分で、モードに `w` を指定していますが \nこれだと **ファイルを開くたびに元の内容を破棄** してしまいます。\n\n**元のコード:**\n\n```\n\n if ((fp = fopen(\"jankendata.txt\", \"w\"))==NULL){\n \n```\n\n元の内容を維持したまま追記したい場合には、代わりに `a` などを指定してみてください。\n\n**変更例:**\n\n```\n\n if ((fp = fopen(\"jankendata.txt\", \"a\"))==NULL){\n \n```\n\n参考: \n[C言語 ファイルの開き方・閉じ方【fopenとfcloseの使い方】](https://monozukuri-c.com/langc-file-open-\nclose/)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T16:54:04.087",
"id": "83591",
"last_activity_date": "2021-11-12T16:54:04.087",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "83590",
"post_type": "answer",
"score": 0
}
] | 83590 | null | 83591 |
{
"accepted_answer_id": "83598",
"answer_count": 1,
"body": "iOS 15.0.2 Xcode Version 13.1\n\nUIDocumentPickerViewControllerを使ってiCloudドキュメント内にあるファイルを取得しようと試みています。\nファイルのURLは取得できるのですが、 そのURLからファイルを取り出そうとすると\n\n```\n\n The file “example.txt” couldn’t be opened because you don’t have permission to view it.\n \n```\n\nというエラーが出ます。\n\n何かを許可すればできそうですが、何を許可すればいいのかなかなか調べてもわかりません。\n\n```\n\n import UIKit\n import UniformTypeIdentifiers\n \n class ViewController: UIViewController,UIDocumentPickerDelegate{\n \n @IBOutlet weak var tv: UITextView!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n }\n \n @IBAction func buttonAction(_ sender: Any) {\n var picker = UIDocumentPickerViewController(documentTypes: [\"public.data\"], in: .open)\n if #available(iOS 14.0, *) {\n picker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.text],asCopy: false)\n }\n picker.allowsMultipleSelection = true\n picker.delegate = self\n self.present(picker, animated: true, completion: nil)\n \n }\n \n func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {\n print(\"cancelled\")\n \n }\n \n func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {\n \n print(url)\n print(url.path)\n \n let urlString = url.path\n do {\n let t = try String(contentsOfFile: urlString)\n print(t)\n tv.text = t\n } catch{\n print(\"error \",error.localizedDescription)\n }\n }\n \n \n```\n\nInfo.Plistの画像 \n[](https://i.stack.imgur.com/9GDix.png)\n\nSigning & capabilities image \n[](https://i.stack.imgur.com/PJ6Zt.jpg)\n\nご回答いただけたら幸いですよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-12T23:08:53.477",
"favorite_count": 0,
"id": "83593",
"last_activity_date": "2021-11-13T07:22:45.053",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43457",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode",
"icloud"
],
"title": "UIDocumentPickerViewControllerでiCloudドキュメントにあるファイルが取得できない",
"view_count": 453
} | [
{
"body": "> 何かを許可すればできそうですが、何を許可すればいいのかなかなか調べてもわかりません。\n\nご記載されたエラー`The file “...” couldn’t be opened because you don’t have permission\nto view\nit.`は非常に様々な原因で発生するので、許可絡みの設定を見直す必要もあるかもしれませんが、その前にSandBox外のファイルをアクセスする場合のお約束を守らないといけません。\n\n[`UIDocumentPickerViewController`](https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller)\n\n> ### Working with External Documents\n>\n> ...\n>\n> * The open and move operations provide security-scoped URLs for all\n> external documents. Call the `startAccessingSecurityScopedResource()` method\n> to access or bookmark these documents, and the\n> `stopAccessingSecurityScopedResource()` method to release them. ...\n>\n\nざっくり書くとこんな感じのコードになるでしょう。\n\n(動作確認はしていませんので、必要に応じて細かい部分は描き直しが必要かもしれません。)\n\n```\n\n func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {\n \n print(url)\n \n if url.startAccessingSecurityScopedResource() {\n defer {url.stopAccessingSecurityScopedResource()}\n do {\n let t = try String(contentsOf: url) //*1 できるだけ`URL`型を直接使う\n print(t)\n tv.text = t\n } catch{\n print(\"error \", error) //*2 `error.localizedDescription`よりも、単に`error`の方が情報量が多い\n }\n } else {\n print(\"startAccessingSecurityScopedResource() failed\")\n //startAccessingSecurityScopedResource()が失敗した時の処理...\n }\n }\n \n```\n\nこのコード修正をしてもまだ何かしらのエラーが出るようでしたら、改めてInfo.plistの設定等調べてみる必要があるかもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T07:22:45.053",
"id": "83598",
"last_activity_date": "2021-11-13T07:22:45.053",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "83593",
"post_type": "answer",
"score": 0
}
] | 83593 | 83598 | 83598 |
{
"accepted_answer_id": "84140",
"answer_count": 1,
"body": "データベースに入力した文字に該当したユーザーの文章に対して紐付けた文章を返すアプリの作成について詳しい方に伺いたいのですが、ユーザーに入力してもらった文字列からあらかじめデータベースに設定した文字と該当したものがあればユーザーに回答を返すアプリを作りたく試行錯誤しております。\n\n例えばユーザーが「ケーキが好きです。」など自由に文章を入力したら、データベースに「好き」という文字に反応して、ユーザーに「スウィーツが好き」などとこちらが予め作成済みの文章を該当ユーザーに返す仕様のアプリを作りたいのですが、イメージとしては検索や占いアプリの応用になるのかなと思います。\n\nデータベースやPHPなどの知識も必要かと思いますが、まだ知識が及ばないので、ライブラリーや参考になるソースコードなどご教示願いますでしょうか。\n\nHTMLはできますが、PHPやJavaScriptはライブラリーを引用する程度の実力しかないので、グーグルのGlideやスプレッドシートを使って作成は可能なものでしょうか。もしくはほかのプラットホームなどオススメがあれば教えて頂けませんでしょうか。\n\nほかの方に教えて頂いたのですが、主要なロジックは大体次になるのではないかとのことでした。\n\n 1. ユーザー入力文字列を形態素解析\n 2. 1の結果から名詞や動詞の「見出し語」or「基本形の文字列」を抽出\n 3. 2で抽出した文字列をつかってDBを検索\n 4. 3の検索結果に対してこちらがDBに該当する検索結果に対してあらかじめ設定した文字列をユーザーに返す\n\nよろしくお願いいたします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T07:27:30.563",
"favorite_count": 0,
"id": "83599",
"last_activity_date": "2021-12-15T19:17:47.103",
"last_edit_date": "2021-11-17T04:47:12.227",
"last_editor_user_id": "3060",
"owner_user_id": "49069",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"php",
"html",
"データベース設計",
"検索"
],
"title": "入力された文章に対し紐付けた文章を返すアプリの作成",
"view_count": 142
} | [
{
"body": "以下のようなシンプルな仕組みでなんとかすることを検討してみてはいかがですか。\n\n```\n\n <?php\n $user_input = \"うまいといえばラーメン\"; //ユーザーが入力した文章\n \n //左が反応するキーワード。右が返す文章。\n $word = [\n \"好き\" => \"スイーツが好き\",\n \"嫌い\" => \"辛いものが嫌い\",\n \"うまい\" => \"芋けんぴうまい\",\n \"まずい\" => \"カエルのスープまずい\",\n ];\n \n //ユーザー入力にキーワードが含まれているか順に確認\n foreach ($word as $keyword => $answer) {\n if (strpos($user_input, $keyword) !== false) {\n echo $answer;\n exit;\n }\n }\n ?>\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-12-15T00:04:35.297",
"id": "84140",
"last_activity_date": "2021-12-15T19:17:47.103",
"last_edit_date": "2021-12-15T19:17:47.103",
"last_editor_user_id": "38398",
"owner_user_id": "38398",
"parent_id": "83599",
"post_type": "answer",
"score": 0
}
] | 83599 | 84140 | 84140 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "shファイルが保存してあるのとは別のディレクトリにあるcfgファイルの書き換えをshファイル内に記述したいのですがどのような方法が考えられるでしょうか。\n\n現状では \n`./usercreate.sh` \n`cd ~/airflow` \n`sed -i -e \"4c\\dags_folder = /home/test2/dags\" airflow.cfg`\n\nのような形で実行しているのですが、後ろの2行で行っている処理も \nusercreate.sh内に記述してしまいたいと考えています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T08:28:03.850",
"favorite_count": 0,
"id": "83600",
"last_activity_date": "2021-11-13T10:44:02.990",
"last_edit_date": "2021-11-13T08:39:49.237",
"last_editor_user_id": "49070",
"owner_user_id": "49070",
"post_type": "question",
"score": 0,
"tags": [
"ubuntu",
"shellscript"
],
"title": ".shファイルでcfgファイルの書き換え",
"view_count": 65
} | [
{
"body": "`./usercreate.sh`に\n\n```\n\n sed -i -e \"4c\\dags_folder = /home/test2/dags\" ~/airflow/airflow.cfg\n \n```\n\nを加えれば良いだけかと。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T08:42:19.813",
"id": "83601",
"last_activity_date": "2021-11-13T08:42:19.813",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "45045",
"parent_id": "83600",
"post_type": "answer",
"score": 0
}
] | 83600 | null | 83601 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "下記の多重配列がありまして\n\n```\n\n result_list = [[100, 100, 500], [200, 20, 20], [20, 20, 20], [20, 20, 20]]\n \n```\n\n上記の各配列の最大値要素を取得したいのですがどのように \n行えばよろしいでしょうか? \n補足で、配列数は毎回異なります。\n\n```\n\n # 求める出力結果\n result = [[500], [200], [20], [20]]\n \n```\n\nお分かりの方がいましたら、ご教示願います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T13:54:56.707",
"favorite_count": 0,
"id": "83605",
"last_activity_date": "2021-11-13T15:10:46.680",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "47752",
"post_type": "question",
"score": 0,
"tags": [
"python3"
],
"title": "各配列の要素の最大値取得",
"view_count": 71
} | [
{
"body": "[max()](https://docs.python.org/ja/3/library/functions.html#max)を使ってリスト内包表記と組み合わせれば出来るでしょう。\n\n```\n\n result = [[max(l)] for l in result_list]\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T14:16:05.433",
"id": "83606",
"last_activity_date": "2021-11-13T14:16:05.433",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26370",
"parent_id": "83605",
"post_type": "answer",
"score": 1
},
{
"body": "`numpy` を使っても良いのであれば以下になります。\n\n```\n\n >>> import numpy as np\n >>> result_list = [[100, 100, 500], [200, 20, 20], [20, 20, 20], [20, 20, 20]]\n >>> np.max(result_list, axis=1).reshape(-1, 1)\n array([[500],\n [200],\n [ 20],\n [ 20]])\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-13T15:10:46.680",
"id": "83607",
"last_activity_date": "2021-11-13T15:10:46.680",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "47127",
"parent_id": "83605",
"post_type": "answer",
"score": 0
}
] | 83605 | null | 83606 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "使用するデータフレームは以下のような形です。\n\n```\n\n name year price \n A社 1999 200 \n A社 2000 202 \n A社 2001 199 \n A社 2002 400 \n A社 2003 207 \n B社 1999 300 \n B社 2000 500 \n B社 2001 201\n \n```\n\n「あるベクトル」とは、`[1] 199 200 201 202 207` です。\n\n以上のデータフレームの変数priceの値が、ベクトルの要素と合致する行のみを残したいです。 \n目標は以下の形になります。\n\n```\n\n name year price \n A社 1999 200 \n A社 2000 202 \n A社 2001 199 \n A社 2003 207 \n B社 2001 201\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T02:20:12.550",
"favorite_count": 0,
"id": "83608",
"last_activity_date": "2021-11-14T05:28:05.570",
"last_edit_date": "2021-11-14T05:28:05.570",
"last_editor_user_id": "3060",
"owner_user_id": "48973",
"post_type": "question",
"score": 1,
"tags": [
"r"
],
"title": "データフレームからあるベクトルの要素を含む行だけを抜き出し、新しいデータフレームを作成したい",
"view_count": 84
} | [
{
"body": "**Base R**\n\n```\n\n df <- data.frame(\n \"name\" = c(rep(\"A社\", 5), rep(\"B社\", 3)),\n \"year\" = c(1999:2003, 1999:2001),\n \"price\" = c(200, 202, 199, 400, 207, 300, 500, 201)\n )\n \n select_price <- c(199, 200, 201, 202, 207)\n \n matched <- df[df$price %in% select_price,]\n \n print(matched)\n \n #\n name year price\n 1 A社 1999 200\n 2 A社 2000 202\n 3 A社 2001 199\n 5 A社 2003 207\n 8 B社 2001 201\n \n```\n\n**dplyr**\n\n```\n\n library(dplyr)\n \n matched <- df %>% filter(price %in% select_price)\n \n print(matched)\n \n #\n name year price\n 1 A社 1999 200\n 2 A社 2000 202\n 3 A社 2001 199\n 4 A社 2003 207\n 5 B社 2001 201\n \n```\n\n※ `dplyr` の場合、インデックスがリセットされます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T02:36:56.727",
"id": "83609",
"last_activity_date": "2021-11-14T02:36:56.727",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "47127",
"parent_id": "83608",
"post_type": "answer",
"score": 1
}
] | 83608 | null | 83609 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "下記の多重配列があります。\n\n```\n\n li = [['0', '0', '0', '0'], ['0', '0', '0', '0'], ['0', '0', '0', '1'], ['0', '0', '1', '1']]\n \n```\n\n\"1\"の値が最初あるのは何番目にあるか判定したいのですが、分かる方いらっしゃいますでしょうか? \n\"1\"がない場合は0とします。\n\n目的の出力結果\n\n```\n\n 0, 0, 3, 2\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T08:11:05.293",
"favorite_count": 0,
"id": "83611",
"last_activity_date": "2021-11-14T08:27:56.267",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "47752",
"post_type": "question",
"score": 0,
"tags": [
"python3"
],
"title": "多重配列の各配列の指定した値が最も初めにあるのは何番目にあるか判定",
"view_count": 41
} | [
{
"body": "```\n\n [i.index('1') if '1' in i else 0 for i in li]\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T08:27:56.267",
"id": "83612",
"last_activity_date": "2021-11-14T08:27:56.267",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "47127",
"parent_id": "83611",
"post_type": "answer",
"score": 0
}
] | 83611 | null | 83612 |
{
"accepted_answer_id": "83620",
"answer_count": 1,
"body": "VSCodeを使って、SpringbootのWEBアプリを作成しました。 \n<https://tech-lab.sios.jp/archives/19941>\n\nVSCodeのデバッグと実行で、 \nHelloController.javaでブレイクポイントがはれることを確認できたので \njarファイルを作成し、Window上でDockerで動くことを確認しました。\n\n次にDocker上の環境をデバッグできないものかと、調べていると \nVSCodeの拡張機能であるRemote Developmentを使えばよさそうでしたので、以下を参考に \ndevcontainer.jsonとDockerファイルを作成しました。 \n<https://speakerdeck.com/noriyukitakei/visual-studio-code-plus-docker-plus-\nremote-developmentdetomcatshang-falsewebapuriwochao-jian-dan-\nnidebatugu?slide=38>\n\nVSCodeのRemote Development拡張機能をインストールしたので \nVSCode左下に現れた「><」のようなボタンを押下し、 \nReopen in Containerを選択したのですが、VSCodeが再起動したのち以下のエラーが発生してしまいます。\n\n```\n\n an error occurred building the image\n \n```\n\n以下のファイルで足りていない設定や、誤りなどありますでしょうか? \nプロジェクトフォルダ.devcontainer \ndevcontainer.json\n\n```\n\n {\n \"name\": \"test\",\n \n \"dockerFile\": \"Dockerfile\",\n \n \"forwardPorts\": [8080],\n \n # コンテナに入ったときに最初にここで指定したものがカレントディレクトリになります。\n \"workspaceFolder\": \"/opt/project\",\n \n # ホストOSのVisual Studio Codeのプロジェクト直下のディレクトリをコンテナの/opt/projectディレクトリにマウント>します。\n \"mounts\": [\n \"source=${localWorkspaceFolder},target=/opt/project,type=bind,consistency=cached\"\n ]\n \n # コンテナが生成されたときに、コンテナ側にインストールする拡張機能です。\n # これを指定しないと、コンテナが再生成すると拡張機能が消えます。\n # 今回はJava Extension PackとTomcat for Javaをインストールします。\n \"extensions\": [\n \"adashen.vscode-tomcat\",\n \"vscjava.vscode-java-pack\"\n ]\n }\n \n```\n\nDockerfile\n\n```\n\n FROM openjdk:14.0.1\n \n #COPY target/demo-0.0.1-SNAPSHOT.jar demo-0.0.1.jar\n \n #ENTRYPOINT [\"java\",\"-jar\",\"/demo-0.0.1.jar\"]\n # ローカルのソースコードをマウントするためのディレクトリを作成します。 RUN mkdir /opt/project\n \n # Mavenをインストールします。 RUN apt-get update && \\\n apt-get -y install maven\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T12:06:53.897",
"favorite_count": 0,
"id": "83614",
"last_activity_date": "2021-11-16T01:27:39.163",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12842",
"post_type": "question",
"score": 0,
"tags": [
"docker",
"vscode",
"spring-boot"
],
"title": "springbootのWEBアプリをDocker上でデバッグしたい(VS CodeのRemote Development)",
"view_count": 911
} | [
{
"body": "質問文中からリンクされているスライドの説明は、少し古く、かつ Tomcat のものなので今回行おうとしていることの参考として適していないように思われます。\n\n * [Developing inside a Container using Visual Studio Code Remote Development](https://code.visualstudio.com/docs/remote/containers)\n\nをベースにして、 Spring Boot 向け機能拡張を追加インストールすれば良さそうです。\n\n* * *\n\nSpring Boot の Maven プロジェクト作成済み、 Docker Desktop for Windows セットアップ済みとします。\n\n 1. 機能拡張 [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) をローカルの VSCode にインストールします(補足: [質問文中のスライド](https://speakerdeck.com/noriyukitakei/visual-studio-code-plus-docker-plus-remote-developmentdetomcatshang-falsewebapuriwochao-jian-dan-nidebatugu?slide=32)に従って機能拡張 [Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) をインストール済みであれば、Remote - Containers も導入されているはずです)。\n 2. コマンドパレット(`Ctrl` \\+ `Shift` \\+ `P`)で \" **Remote-Containers: Add Development Container Configuration Files...** \" を選択します。ウィザードを進め、構築する環境を設定します。例えば Java 11 の Maven 環境であれば: \n * \"Java > 11 > None(Node をインストールしない) > Install Maven にチェック > (何もチェックしない) \"\n 3. ウィザードを完了させると、 `.devcontainer` ディレクトリに 2 ファイル `devcontainer.json`, `Dockerfile` が作成されます。 `devcontainer.json` を編集し、 機能拡張 [Spring Boot Extension Pack](https://marketplace.visualstudio.com/items?itemName=Pivotal.vscode-boot-dev-pack) をインストールするように次の通り `Pivotal.vscode-boot-dev-pack` を追加します: \n * \n``` \"extensions\": [\n\n \"vscjava.vscode-java-pack\",\n \"Pivotal.vscode-boot-dev-pack\"\n ],\n \n```\n\n 4. コマンドパレットで \" **Remote-Containers: Open Folder in Container...** \" を選択します。 Docker イメージが構築され、コンテナが起動します。\n\n* * *\n\n(コメントを受けて追記)\n\n上記の手順で作成した環境は、ホスト(Windows)のディレクトリをコンテナ側でマウントし、双方で共有した状態になっています。\n\n本文冒頭に記載したリンク先では、共有方式以外についても説明があります。\n\n> While using this approach to [bind\n> mount](https://docs.docker.com/storage/bind-mounts/) the local filesystem\n> into a container is convenient, it does have some performance overhead on\n> Windows and macOS. There are [some\n> techniques](https://code.visualstudio.com/remote/advancedcontainers/improve-\n> performance) that you can apply to improve disk performance, or **you\n> can[open a repository in a container using a isolated container\n> volume](https://code.visualstudio.com/docs/remote/containers#_quick-start-\n> open-a-git-repository-or-github-pr-in-an-isolated-container-volume)\n> instead**.",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T15:46:04.647",
"id": "83620",
"last_activity_date": "2021-11-16T01:27:39.163",
"last_edit_date": "2021-11-16T01:27:39.163",
"last_editor_user_id": "2808",
"owner_user_id": "2808",
"parent_id": "83614",
"post_type": "answer",
"score": 0
}
] | 83614 | 83620 | 83620 |
{
"accepted_answer_id": "83618",
"answer_count": 2,
"body": "以下のような期間を含むDataFrameで、指定した日付が期間内に含まれる行を抽出するには、どうしたらよいでしょうか? \n例えば、'2021/08/05'を検索条件としたとき、りんごの行を抽出することは可能でしょうか?(applyや行ループするしかないのでしょうか?) \nよろしくお願いします。\n\n```\n\n import pandas as pd\n df = pd.DataFrame(\n data={ '品名':[ 'りんご', 'バナナ', 'みかん' ] },\n index=[\n pd.Interval(pd.Timestamp('2021/08/01'), pd.Timestamp('2021/08/10')),\n pd.Interval(pd.Timestamp('2021/09/01'), pd.Timestamp('2021/09/10')),\n pd.Interval(pd.Timestamp('2021/10/01'), pd.Timestamp('2021/10/10')) ]\n )\n display(df)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T12:36:10.650",
"favorite_count": 0,
"id": "83615",
"last_activity_date": "2021-11-15T08:57:21.257",
"last_edit_date": "2021-11-14T13:01:34.000",
"last_editor_user_id": "7290",
"owner_user_id": "35267",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pandas"
],
"title": "期間を含むDataFrameの条件抽出",
"view_count": 181
} | [
{
"body": "[pandas.IntervalIndex.contains()](https://pandas.pydata.org/docs/reference/api/pandas.IntervalIndex.contains.html)あたりの応用で以下のように出来そうです。\n\n```\n\n selected = df[df.index.contains('2021/08/05')]\n \n```\n\n* * *\n\n何で`pd.Timestamp('2021/08/01\n00:01')`を使った回答されたか不思議だったのですが、上記方法だと'2021/08/01'の時に検出出来ないからですね。 \nこれはDataFrame作成時の指定方法が関係していると考えられます。\n\n```\n\n pd.Interval(pd.Timestamp('2021/08/01'), pd.Timestamp('2021/08/10'))\n \n```\n\n上記の方法で作成すると、`closed`パラメータが指定されていないためデフォルトの`right`になって、`left`パラメータに指定した値は`Interval`に含まれないことになります。 \n[pandas.Interval()](https://pandas.pydata.org/docs/reference/api/pandas.Interval.html)\n\n> closed : {‘right’, ‘left’, ‘both’, ‘neither’}, default ‘right’ \n> Whether the interval is closed on the left-side, right-side, both or\n> neither. See the Notes for more detailed explanation.\n\nnotes の記述に依れば期間は '2021/08/01' < Interval <= '2021/08/10' となります。 \nそうなると'2021/08/01'が含まれていないことになるため、`selected =\ndf[df.index.contains('2021/08/01')]`は空のDataFrameになります。\n\n'2021/08/01'を指定して'りんご'を含んだ行を抽出するためには、DataFrame作成時に以下のように`,\nclosed='both'`を追加しておけば良いでしょう。\n\n```\n\n df = pd.DataFrame(\n data={ '品名':[ 'りんご', 'バナナ', 'みかん' ] },\n index=[\n pd.Interval(pd.Timestamp('2021/08/01'), pd.Timestamp('2021/08/10'), closed='both'),\n pd.Interval(pd.Timestamp('2021/09/01'), pd.Timestamp('2021/09/10'), closed='both'),\n pd.Interval(pd.Timestamp('2021/10/01'), pd.Timestamp('2021/10/10'), closed='both') ]\n )\n \n```\n\n上記のようにDataFrameを作成することで、`pd.Timestamp('2021/08/01\n00:01')`と言う風に捻り技を使うことなく、`df_out =\ndf[df.index.contains('2021/08/01')]`で希望する行が抽出できるでしょう。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T13:51:34.777",
"id": "83618",
"last_activity_date": "2021-11-15T08:08:31.070",
"last_edit_date": "2021-11-15T08:08:31.070",
"last_editor_user_id": "26370",
"owner_user_id": "26370",
"parent_id": "83615",
"post_type": "answer",
"score": 0
},
{
"body": "ありがとうございます。 \n`index.contains()` を利用して抽出することで解決しました。\n\nPandasのindex系のAPIたくさんあるのですね。\n\n```\n\n import pandas as pd\n df = pd.DataFrame(\n data={ '品名':[ 'りんご', 'バナナ', 'みかん' ] },\n index=[\n pd.Interval(pd.Timestamp('2021/08/01'), pd.Timestamp('2021/08/10')),\n pd.Interval(pd.Timestamp('2021/09/01'), pd.Timestamp('2021/09/10')),\n pd.Interval(pd.Timestamp('2021/10/01'), pd.Timestamp('2021/10/10')) ]\n )\n display(df)\n \n df_out = df[df.index.contains(pd.Timestamp('2021/08/01 00:01'))]\n display(df_out)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T04:38:49.500",
"id": "83628",
"last_activity_date": "2021-11-15T08:57:21.257",
"last_edit_date": "2021-11-15T08:57:21.257",
"last_editor_user_id": "3060",
"owner_user_id": "35267",
"parent_id": "83615",
"post_type": "answer",
"score": 0
}
] | 83615 | 83618 | 83618 |
{
"accepted_answer_id": "83982",
"answer_count": 1,
"body": "実行環境: \ngoogle colabratory \npython 3.7.12\n\n[Twitch配信アーカイブのコメント流量を可視化してみた](https://qiita.com/kanekom/items/42ed3cd079fa5409ae58)\n\nを参考にして\n\n```\n\n import requests\n import json\n client_id='my_client_id'\n video_id='target_video_id'\n url = 'https://api.twitch.tv/v5/videos/' + video_id + '/comments?content_offset_seconds=0'\n headers = {'client-id': client_id}\n r = requests.get(url, headers=headers)\n row_data = r.json()\n print(row_data)\n \n```\n\nというコードを書きました。\n\n例えば↓の動画のコメントを取得したいとして \n<https://www.twitch.tv/videos/1114915638>\n\nvideo_idに1114915638を代入して実行してみても \n`{'error': 'Not Found', 'status': 404}` \nが返ってきてしまいます。\n\nこれが起こってしまう原因や対処法を知っている方いらっしゃったら教えていただけないでしょうか",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T13:50:25.093",
"favorite_count": 0,
"id": "83617",
"last_activity_date": "2021-12-06T18:16:28.027",
"last_edit_date": "2021-11-15T00:12:54.823",
"last_editor_user_id": "3060",
"owner_user_id": "49082",
"post_type": "question",
"score": 0,
"tags": [
"python",
"webapi"
],
"title": "twitch api を用いてアーカイブ動画のコメントを取得したい",
"view_count": 2455
} | [
{
"body": "私も配信アーカイブを取得しようとしましたが、同じく Not Found となりました。現時点で返ってくる json には以下の文章が含まれています。\n\n> The v5 API is deprecated and will be shutdown on February 28, 2022.\n> Applications \n> that have not accessed v5 before July 15, 2021 no longer have access to v5.\n> For more information on the v5 API shutdown plan, see\n> <https://blog.twitch.tv/2021/07/15/legacy-twitch-api-v5-shutdown-details-\n> and-timeline/> and the Twitch API documentation at\n> <https://dev.twitch.tv/docs/api>.\n\nTwitch API v5 (<https://api.twitch.tv/v5/*>)\nは2022年2月28日に利用不可になるようで、少なくとも2021年7月15日よりも後に作成されたデベロッパーアプリケーションでは既に v5 API\nは利用できなくなっています。\n\nまた、現時点で最新の Twitch API Helix (<https://api.twitch.tv/helix/*>)\nには残念ながら配信アーカイブのコメントの取得する機能はないようです。 \n<https://dev.twitch.tv/docs/api/reference#get-videos>\n\nただし、Twitch の Web サイトでは現在も v5 の API を利用してアーカイブのコメントを表示しており、現状 Twitch 自身の\nClient-ID (kimne78kx3...) を用いることでのみコメントは取得できるようです。\n\nグレーな手段になるので明言は避けますが、いくつか参考になるリンクを添付します。 \n<https://thomassen.sh/twitch-api-endpoints/> \n<https://github.com/streamlink/streamlink/issues/2680#issuecomment-552041482>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-12-06T18:16:28.027",
"id": "83982",
"last_activity_date": "2021-12-06T18:16:28.027",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49375",
"parent_id": "83617",
"post_type": "answer",
"score": 0
}
] | 83617 | 83982 | 83982 |
{
"accepted_answer_id": "83626",
"answer_count": 2,
"body": "現在のブランチがb1として、下記コマンド2つに違いはありますか?\n\n```\n\n git branch --copy b1 b2\n git checkout -b b2\n \n```\n\n前者はどこのブランチからでも行える、後者は移動を伴うというのはわかるのですが、上記b2は同じものだと考えて間違いないでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T17:47:01.870",
"favorite_count": 0,
"id": "83621",
"last_activity_date": "2021-11-15T14:30:21.880",
"last_edit_date": "2021-11-14T18:20:07.290",
"last_editor_user_id": "7300",
"owner_user_id": "7300",
"post_type": "question",
"score": 4,
"tags": [
"git"
],
"title": "git branch --copyとcheckoutの違いはありますか?",
"view_count": 1819
} | [
{
"body": "ちょっとやってみました。同じものです。 \n絶対にそうだと確認して、何らかのプログラムに使いたい場合はだめですけど \nちょっと知りたい程度ならやってみて確認でよいのでは。\n\n前者が欲しければ、一次情報あたるしかないですしね。。\n\n以下の確認結果では、★1と★2の値が同じで、copyもbranchも同じコミットをポイントしています。\n\n```\n\n <workdir>>git commit -m \"2st\"\n [master 076b1b6] 2st\n 1 file changed, 1 insertion(+)\n \n <workdir>>git checkout -b branch\n Switched to a new branch 'branch'\n \n <workdir>>git log\n commit 076b1b61511a85612e7b4f7e29c849ea5657a7f6 (HEAD -> branch, master)\n ★1\n \n Author: Some User <xxxxx@yyyyy>\n Date: Mon Nov 15 07:15:10 2021 +0900\n 2st\n \n ...\n \n <workdir>>git checkout master\n Switched to branch 'master'\n \n <workdir>>git branch --copy branch copy\n \n <workdir>>git checkout copy\n Switched to branch 'copy'\n \n <workdir>>git log\n commit 076b1b61511a85612e7b4f7e29c849ea5657a7f6 (HEAD -> copy, master, branch)\n ★2\n Author: Some User <xxxxx@yyyyy>\n Date: Mon Nov 15 07:15:10 2021 +0900\n \n 2st\n \n ....\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-14T22:28:39.707",
"id": "83623",
"last_activity_date": "2021-11-15T01:26:25.463",
"last_edit_date": "2021-11-15T01:26:25.463",
"last_editor_user_id": "3060",
"owner_user_id": "10174",
"parent_id": "83621",
"post_type": "answer",
"score": 1
},
{
"body": "`b1` が **非**[追跡ブランチ(tracking branch)](https://git-\nscm.com/book/ja/v2/Git-%E3%81%AE%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E6%A9%9F%E8%83%BD-%E3%83%AA%E3%83%A2%E3%83%BC%E3%83%88%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81#r_tracking_branches)の名前だとすると、質問文中に書かれている理解でも概ね問題ないかと思います。 \nですが、一般的な話で言うと違います。\n\n細かいものも含めて誤解を指摘すると:\n\n * `git checkout -b ...` を意味的に分解すると、 `HEAD` の操作(`git checkout`) のついでにローカルブランチ作成する(`-b`)、ということなので、 _\" 移動\"_ は付随的なものでなく主目的です。\n * `git checkout -b b2 b1` と指定することもできるので、`git checkout` も _\" どこのブランチからでも行え\"_ ると言えるでしょう。\n * `-b` オプションに相当するのは `git branch b2 b1` です。(`--copy` オプションはつかない; コピーでなく新規作成) \n * `--copy` はブランチの設定もコピーされます。[ユースケース](https://github.com/git/git/commit/52d59cc6452ed1aeec91f4c168a853ea8d9d5496): \n\n> This is useful for e.g. copying a topic branch to a new version, \n> e.g. work to work-2 after submitting the work topic to the list, while \n> **preserving all the tracking info and other configuration that goes \n> with the branch**, and unlike --move keeping the other already-submitted \n> branch around for reference.\n\n要は、\n\n```\n\n git branch b2 b1\n git checkout b2\n \n```\n\nを1つのコマンドにまとめたのが\n\n```\n\n git checkout -b b2 b1\n \n```\n\nです。\n\nちなみに、\n\n```\n\n git switch -c b2 b1\n \n```\n\nも同じ動作です。\n\n参考:\n\n * [`git-checkout`](https://git-scm.com/docs/git-checkout)\n * [`git-branch`](https://git-scm.com/docs/git-branch)\n * [`git-config`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-branchltnamegtmerge)(`branch.<name>.merge` など)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T02:23:28.777",
"id": "83626",
"last_activity_date": "2021-11-15T14:30:21.880",
"last_edit_date": "2021-11-15T14:30:21.880",
"last_editor_user_id": "2808",
"owner_user_id": "2808",
"parent_id": "83621",
"post_type": "answer",
"score": 2
}
] | 83621 | 83626 | 83626 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Edgeのコマンド引数(msedge ~~)で垂直タブで起動したいのですがコマンドは存在しますでしょうか? \n以下のサイトを拝見しましたが古い(?)ためか記載されていませんでした。 \n<https://answers.microsoft.com/en-us/microsoftedge/forum/all/get-list-of-edge-\ncommand-line-switches/519d9efd-03df-4815-9cc7-b8f51d1bc932>\n\nもしくは、Edgeのコマンド引数を確認する方法でも構いません。 \n上記サイトでOrcaを利用して確認するとの記載がありましたが、 \n理解できずご教授いただけますと幸いです。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T01:17:15.693",
"favorite_count": 0,
"id": "83624",
"last_activity_date": "2021-11-15T04:28:27.320",
"last_edit_date": "2021-11-15T04:28:27.320",
"last_editor_user_id": "49086",
"owner_user_id": "49086",
"post_type": "question",
"score": 0,
"tags": [
"windows",
"command-line"
],
"title": "Edgeを垂直タブで起動するコマンド",
"view_count": 86
} | [] | 83624 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "C言語でmemcpyを使った以下のような配列コピーのコードで \n**以下のコードではbufの先頭アドレスから一つずらしたところにコピーすることで、コピー先とコピー元をあえて重複させて未定義動作を引き起こそうと思ったのですが。**\n\n・これは適切な未定義動作の例になっているのか自分でもよくわかりません。またこれがなぜこのような結果になるのか簡単にでも教えていただきたいです。 \n・また見様見真似で書いたコードなのですがもっと簡単なコードがあればぜひ教えていただきたいです\n\n```\n\n #include <stdio.h>\n #include <string.h>\n \n void* memcpy(void *dst,const void *src,size_t n){\n size_t i;\n char *p1=dst;\n const char *p2=src;\n \n for(i=0;i<n;++i){\n *p1=*p2;\n ++p1;\n ++p2;\n }\n }\n \n int main(void){\n char buf[]={0,1,2,3,4};\n char buf2[5];\n \n memcpy(buf+1,buf,sizeof(buf));\n \n for(int i=0;i<sizeof(buf);++i){\n printf(\"%d\\n\",buf[i]);\n }\n \n return 0;\n }\n \n```\n\n結果は以下のようになりました。\n\n```\n\n 0\n 0\n 1\n 2\n 3\n *** stack smashing detected ***: <unknown> terminated\n Aborted (core dumped)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T04:42:50.527",
"favorite_count": 0,
"id": "83629",
"last_activity_date": "2021-11-15T21:02:39.650",
"last_edit_date": "2021-11-15T21:02:39.650",
"last_editor_user_id": "4236",
"owner_user_id": "48756",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "c言語の配列コピーの未定義動作",
"view_count": 385
} | [
{
"body": "提示コードに関しては立派な未定義動作を引き起こしています。\n\n * `buf[5]` に書き込んでいる\n * 標準組み込み関数 `memcpy` と同名の関数を自分で定義している\n\n専門用語「未定義の動作」に関しては例えば [C :\n配列の添字について](https://ja.stackoverflow.com/questions/15206/)\n参照。よって未定義動作をするプログラムはあなたの勝手な期待通りに動くとは限りません。実際 Visual Studio 2019 Version\n16.11.6 の [c++] x86 Debug Build では `0 0 0 0 0` 表示となってデバッガに `Run-Time Check\nFailure #2 - Stack around the variable 'buf' was corrupted.`\nとなりました。事後にメモリ破壊が検出されたということのようです。\n\n> 適切な未定義動作の例になっているのか自分でもよくわかりません\n\n未定義動作は不適切なプログラムが起こすものなので「適切な未定義動作」なんてものはないです。最近の賢いコンパイラなら\n\n```\n\n int main() {\n char buf[5];\n buf[5]='\\0';\n }\n \n```\n\nだけでも十分エラー検出してくれます。が、昔ながらの組み込み系コンパイラだとこの辺はコンパイル時にも実行時にも何の検出も行わずにただメモリ破壊を行うのみだったりします(上記コードはスタック上の未使用領域を壊すだけで無害だったりするので、検出が困難でたちが悪いっス。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T08:00:48.567",
"id": "83639",
"last_activity_date": "2021-11-15T08:00:48.567",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "83629",
"post_type": "answer",
"score": 1
}
] | 83629 | null | 83639 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "グリッドサーチを使ってチューニングを行っています。以下のコードで計算結果を得ました。\n\n```\n\n for i in range(1,7):\n param_grid = {'hidden_layer_sizes': [(i,),(i,i),(i,i,i)]}\n \n grid_search = GridSearchCV(MLPClassifier(random_state=0), param_grid, cv=5)\n grid_search.fit(X_train, y_train)\n cvres = grid_search.cv_results_\n for score, params in zip(cvres['mean_test_score'], cvres['params']):\n print(score,params)\n \n```\n\n以上より得られた結果を,さらにデータフレームしたく,以下のコードを実行しました。\n\n```\n\n df_bst_rs = pd.DataFrame({'rank_test_score':cvres['rank_test_score'],'mean_test_score':cvres['mean_test_score']})\n df_rs_cv_results = pd.DataFrame(cvres['params'])\n df_bst_rs = pd.concat([df_bst_rs, df_rs_cv_results], axis=1)\n df_bst_rs.sort_values('rank_test_score', inplace=True)\n \n pd.set_option(\"display.max_rows\",len(df_bst_rs))\n df_bst_rs\n \n```\n\nしかし,これではi=6のときの結果しかデータフレームで表示することができません。 \ni=1~6すべての結果を表示するためには,どのようにすればよいでしょうか。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T04:49:55.243",
"favorite_count": 0,
"id": "83630",
"last_activity_date": "2021-11-15T07:04:38.340",
"last_edit_date": "2021-11-15T07:04:38.340",
"last_editor_user_id": "26370",
"owner_user_id": "48917",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "for文を使った計算結果をすべてデータフレームに表示したいです。",
"view_count": 189
} | [] | 83630 | null | null |
{
"accepted_answer_id": "83635",
"answer_count": 1,
"body": "ドットインストールやudemyで学習している初心者です。\n\nVirtualboxにMX Linux21をインストールし仮想環境を構築してみました。 \nホストOSはWindows11です。Youtube動画を見ながらやってみました。\n\n今回、仮想環境のLinux OS上でPHPを利用してみたいと思っています。 \nテキストエディタはVSCode、ブラウザはGoogle ChromeをLinuxOSにインストールしました。\n\nPHPを利用出来るようにLinux OS内にLAMPの環境を構築しようと思っています。\n\nこちらのサイトをgoogleの翻訳機能を利用して進めています。\n\n<https://mxlinux.org/wiki/networking/lamp-setup/>\n\nApacheとPHPをインストールした後に「インストールをテストする」という項目があります。\n\n> インストールをテストする PHPが正しく機能していることを確認するには、次の内容のindex.phpファイルを/ var / www / \n> html /フォルダーに作成します。\n>\n> <?php phpinfo(); ?> 次に、ブラウザで「localhost \n> /index.php」を指定します。すべてのPHP設定が表示されたテーブルを含むページが表示されます。\n\nこれが出来ればPHPのバージョン等の情報ページが表示されるはずです。そこで/ var / www / html\n/フォルダーに移動し右クリックでドキュメントを作成からPHPファイルを作成しようと思ったのですが「ドキュメントの作成」が選択できないようになっています。\n\n[](https://i.stack.imgur.com/EL03J.png)\n\nまたデスクトップにindex.phpファイルを作成しドラッグアンドドロップしようとしたのですが何の反応もありません。 \nアクセス権にかかわる問題なのでしょうか?\n\nターミナルは開けるのでtouchコマンドでファイルを作成し、編集しようと思いまずファイルを作成したのですが\n\n```\n\n $ touch index.php\n touch: 'index.php' に touch できません: 許可がありません\n \n```\n\nと作成の許可がないようです。\n\nどのようにすれば /var/www/html/ フォルダーにPHPファイルを作成することが出来ますか?\n\n恥ずかしながらLinuxや仮想環境に関してはほぼ初めて触るという状態です。初心者でもわかるように教えていただけると助かります。 \nよろしくお願いいたします",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T05:26:52.777",
"favorite_count": 0,
"id": "83631",
"last_activity_date": "2021-11-15T06:24:29.380",
"last_edit_date": "2021-11-15T06:23:58.127",
"last_editor_user_id": "3060",
"owner_user_id": "42150",
"post_type": "question",
"score": 0,
"tags": [
"linux"
],
"title": "/var/www/html/ フォルダー内にPHPファイルを作成したい",
"view_count": 624
} | [
{
"body": "大抵のLinuxでは、/var/www/htmlはroot所有者になっているはずです。 \nその場合、一般ユーザーでは書き込み権限がありません。 \nsu - でrootになってから作業してください。\n\n```\n\n ubuntu:~$ ls -ld /var/www/\n drwxr-xr-x 3 root root 4096 Nov 13 11:42 /var/www/\n \n ubuntu:~$ ls -ld /var/www/html/\n drwxr-xr-x 2 root root 4096 Nov 13 11:53 /var/www/html/\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T06:15:12.853",
"id": "83635",
"last_activity_date": "2021-11-15T06:24:29.380",
"last_edit_date": "2021-11-15T06:24:29.380",
"last_editor_user_id": "3060",
"owner_user_id": "43005",
"parent_id": "83631",
"post_type": "answer",
"score": 0
}
] | 83631 | 83635 | 83635 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "例えば\n\n```\n\n !less \"book.csv\"\n \n```\n\nは実行可能ですが、\n\n```\n\n file = \"book.csv\"\n !less file\n \n```\n\nだとエラーになってしまいます。 \nこれは機能的に無理なのでしょうか。 \nその場合、ループして複数のファイルに対してコマンドを実行したいのですがそれも不可能ということになってしまうのでしょうか",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T07:45:38.247",
"favorite_count": 0,
"id": "83638",
"last_activity_date": "2021-11-15T08:15:27.200",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49094",
"post_type": "question",
"score": 0,
"tags": [
"python",
"command-line"
],
"title": "IPythonからシステムシェルのコマンド使用の際の引数について",
"view_count": 97
} | [
{
"body": "`$variable` あるいは `{variable}` の形式で変数を渡すことが可能です\n\n参考: IPython [Shell\nAssignment](https://ipython.readthedocs.io/en/stable/interactive/python-\nipython-diff.html#shell-assignment)\n\n```\n\n file = \"book.csv\"\n out = !cat $file\n print(out.l)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T08:15:27.200",
"id": "83640",
"last_activity_date": "2021-11-15T08:15:27.200",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "43025",
"parent_id": "83638",
"post_type": "answer",
"score": 2
}
] | 83638 | null | 83640 |
{
"accepted_answer_id": "83655",
"answer_count": 1,
"body": "以下の`Task.sleep(nanoseconds:)`以下の`print(\"Finish\")`が表示されない or エラーになってしまいます。\n\n時間を`1_000`などにすると表示されます。\n\n```\n\n Task {\n print(\"Start\")\n \n do {\n try await Task.sleep(nanoseconds: 1_000_000_000)\n }\n catch {\n print(\"Error\")\n }\n \n print(\"Finish\")\n }\n \n```\n\n```\n\n // output\n root@80270fb670dc:/usr/src# swift testSleep.swift\n Start\n root@80270fb670dc:/usr/src# \n \n```\n\n```\n\n Task {\n print(\"Start\")\n \n do {\n try await Task.sleep(nanoseconds: 1000000)\n }\n catch {\n print(\"Error\")\n }\n \n print(\"Finish\")\n }\n \n```\n\n```\n\n root@80270fb670dc:/usr/src# swift testSleep.swift\n Start\n Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.\n Segmentation fault\n root@80270fb670dc:/usr/src# \n \n```\n\n * Windows 10\n * Docker\n * Swift \n * Swift version 5.5.1 (swift-5.5.1-RELEASE)\n * Target: x86_64-unknown-linux-gnu",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T09:07:18.987",
"favorite_count": 0,
"id": "83642",
"last_activity_date": "2021-11-22T02:41:29.720",
"last_edit_date": "2021-11-15T10:51:50.717",
"last_editor_user_id": "40856",
"owner_user_id": "40856",
"post_type": "question",
"score": 0,
"tags": [
"swift"
],
"title": "await Task.sleep(nanoseconds:)をDockerで実行した際に、sleepする時間が長すぎると処理が実行されない",
"view_count": 248
} | [
{
"body": "## 解決方法1\n\n`RunLoop.main.run()`を最後の行に追加して、`exit(0)`をTask{}の最後に追加する。\n\n## 解決方法2\n\nコンパイルして、実行\n\n```\n\n swiftc taskSleep.swift\n ./taskSleep.\n \n```\n\n問題点: コンパイルしなきゃいけない\n\n## 解決法3\n\n`_runAsyncMain {}`内で実行する\n\n```\n\n _runAsyncMain {\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-16T09:03:35.003",
"id": "83655",
"last_activity_date": "2021-11-22T02:41:29.720",
"last_edit_date": "2021-11-22T02:41:29.720",
"last_editor_user_id": "40856",
"owner_user_id": "40856",
"parent_id": "83642",
"post_type": "answer",
"score": 0
}
] | 83642 | 83655 | 83655 |
{
"accepted_answer_id": "83646",
"answer_count": 1,
"body": "メールフォームの作成において二つのメールアドレスが一致しないときにエラーメッセージを表示させたいのですがJavaScriptが全く機能していません。どこのコードをまちがえているのか解決法とともに教えていただきたいです。\n\n```\n\n <!DOCTYPE html>\n <html lang=\"en\" dir=\"ltr\">\n <head>\n <meta charset=\"utf-8\">\n <title>mail form</title>\n </head>\n <body>\n <form action=\"https://cim.saddleback.edu/~jstudent0/formData.php\">\n Email 1<input type=\"text\" id=\"email1\" name=\"email1\"\n pattern=\"\\w+@\\w{1,63}\\.[a-z]{3}\"\n required=\"required\"\n title=\"Enter your email\"/> <br>\n Email 2<input type=\"text\" id=\"email2\" name=\"email2\"\n pattern=\"\\w+@\\w{1,63}\\.[a-z]{3}\"\n required=\"required\"\n title=\"Enter your email again\"/> <br>\n <script type=\"text/javascript\" src=\"https://code.jquery.com/jquery-2.1.4.min.js\">\n function checkMatch( ) {\n if( $(\"#email1\").val() != \"\" &&\n $(\"#email1\").val() == $(\"#email2\").val() )\n return true;\n \n var msg = \"Email2s not matching!\"\n + $(\"#email2\").val();\n \n console.log( msg );\n $(\"#prompt\").text( msg );\n $(\"#prompt\").css(\n { \"color\":\"lime\", \"background-color\":\"black\",\n \"font-weight\":\"bolder\" } );\n return false;\n }\n $(document).ready( function() {\n \n \n $(\"#email1\").focus( function() {\n $(\"#prompt\").text( \"Enter First Email\" );\n });\n \n $(\"#email1\").blur( function() {\n $(\"#prompt\").text( \"Email2 must match email1\");\n });\n \n $(\"#email2\").keydown( function() {\n checkMatch();\n return true;\n //continue processing\n });\n \n $(\"form\").submit( checkMatch );\n \n });\n </script>\n <input type=\"submit\" /><input type=\"reset\" />\n </body>\n </html>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-15T14:47:40.267",
"favorite_count": 0,
"id": "83643",
"last_activity_date": "2021-11-16T01:46:12.440",
"last_edit_date": "2021-11-16T01:20:05.477",
"last_editor_user_id": "3060",
"owner_user_id": "48605",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery",
"form"
],
"title": "フォームの入力内容が一致しないときにメッセージを表示させたい",
"view_count": 220
} | [
{
"body": "jQueryを読み込むscriptタグは、 `<head>` 内に書く必要があります。\n\n```\n\n <head>\n <script type=\"text/javascript\" src=\"https://code.jquery.com/jquery-2.1.4.min.js\"></script>\n </head>\n \n```\n\nそして、 `function checkMatch( ) {` 以下は `<body>` 内に `<script>` で囲って記載する必要があります。\n\n```\n\n <body>\n <script>\n console.log(\"hoge\");\n </script>\n </body>\n \n```\n\n試してみてください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-16T01:46:12.440",
"id": "83646",
"last_activity_date": "2021-11-16T01:46:12.440",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "40092",
"parent_id": "83643",
"post_type": "answer",
"score": 1
}
] | 83643 | 83646 | 83646 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "cron実行ユーザはrootでファイルの権限もrootです。\n\nファイルにはcron実行が可能なように権限付与の設定を行いました。\n\n```\n\n chmod u+x test.sh\n chmod 777 test.sh\n \n```\n\nしかしcronは実行されませんでした。\n\ncronはcrontab -eを開いて以下のように設定しています。15分おき実行が希望です。\n\n```\n\n */15 * * * * /root/test.sh\n \n```\n\n他に見直すべきところはあるでしょうか?",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-16T02:35:58.283",
"favorite_count": 0,
"id": "83647",
"last_activity_date": "2021-11-16T08:10:57.500",
"last_edit_date": "2021-11-16T08:10:57.500",
"last_editor_user_id": "3060",
"owner_user_id": "36855",
"post_type": "question",
"score": 0,
"tags": [
"shellscript",
"cron"
],
"title": "cronに設定したshファイルが実行されません。",
"view_count": 721
} | [] | 83647 | null | null |
{
"accepted_answer_id": "83657",
"answer_count": 1,
"body": "PandasのDataFrameのplotメソッドで、折れ線グラフに、追加で横棒グラフを表示させたいのですが、 \n表示順(zorder)の指定ができず困っています。(現状は棒グラフを半透明色にしてごまかしています。) \n棒グラフを最背面へ、凡例を最前面へ表示を指定することは可能でしょうか?\n\n```\n\n # zorderが効かない例(pd.DataFrameのplotメソッドを利用)\n import pandas as pd\n \n df = pd.DataFrame(data={ 'value':[ 100, 200, 300, 200 ] }, index=[ 10, 20, 30, 40 ])\n ax = df.plot(zorder=2)\n \n x = [ 100, 200, 300 ]\n y = [ 20, 25, 30 ]\n twin_ax = ax.twiny()\n twin_ax.barh(x, y, color='#00ff00', height=50, zorder=1) # 横棒グラフ\n plt.show() # 描画\n \n```\n\n[](https://i.stack.imgur.com/EmZHY.png)\n\n以下は、他サイトで調べたうまくいく例です。 \nmatplotlibを直接利用しないと表示順(zorder)は指定できないものなのでしょうか? \nよろしくお願いします。\n\n```\n\n # zorderが有効な例(matplotlibを直接利用)\n import pandas as pd\n import matplotlib.pyplot as plt\n x = [ 100, 200, 300 ]\n y = [ 20, 25, 30 ]\n plt.plot(x, y, zorder=2, color='r')\n plt.scatter(x, y, zorder=1, s=200)\n plt.show() # 描画\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-16T04:06:18.663",
"favorite_count": 0,
"id": "83648",
"last_activity_date": "2021-11-16T12:55:28.763",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35267",
"post_type": "question",
"score": 0,
"tags": [
"python",
"pandas",
"matplotlib"
],
"title": "PandasのDataFrameのplotメソッドで、同軸グラフの表示順を指定したい",
"view_count": 477
} | [
{
"body": "[matplotlib.axes.Axes.set_zorder](https://matplotlib.org/3.2.2/api/_as_gen/matplotlib.axes.Axes.set_zorder.html)\nで ax 自体の `z_order` を変更してみました。\n\n```\n\n import pandas as pd\n import matplotlib.pyplot as plt\n \n df = pd.DataFrame(data={ 'value':[ 100, 200, 300, 200 ] }, index=[ 10, 20, 30, 40 ])\n ax = df.plot()\n \n x = [ 100, 200, 300 ]\n y = [ 20, 25, 30 ]\n twin_ax = ax.twiny()\n twin_ax.barh(x, y, color='#00ff00', height=50) # 横棒グラフ\n \n ax.set_zorder(2)\n ax.patch.set_alpha(0)\n twin_ax.set_zorder(1)\n \n plt.show() # 描画\n \n```\n\n[](https://i.stack.imgur.com/3We3l.png)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-16T12:55:28.763",
"id": "83657",
"last_activity_date": "2021-11-16T12:55:28.763",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "47127",
"parent_id": "83648",
"post_type": "answer",
"score": 1
}
] | 83648 | 83657 | 83657 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "私は添付画像のようなスタイルのチートシートを作りたいです。ですが、チートシートを作成するサイトが少なく、困っています。皆さんがチートシートを作るときに使っているサイトはどんなサイトでしょうか??ちなみにhttps://cheatography.com/ \nは日本語対応してないので、私が作成したチートシートをダウンロードしようとすると日本語で記載した箇所だけ表記が消えてしまうため選択肢にありません。\n\n[](https://i.stack.imgur.com/tDIPI.jpg)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-11-16T05:12:06.097",
"favorite_count": 0,
"id": "83650",
"last_activity_date": "2021-11-16T05:12:06.097",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49107",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"vim",
"google-chrome"
],
"title": "チートシートを作成したいが、目当てのサイトが見当たらない",
"view_count": 172
} | [] | 83650 | null | null |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.