question
dict
answers
list
id
stringlengths
2
5
accepted_answer_id
stringlengths
2
5
popular_answer_id
stringlengths
2
5
{ "accepted_answer_id": "42201", "answer_count": 1, "body": "**両者の違いを知りたい**\n\n* * *\n\n**Q1.「location.href」よりも「window.location.href」と書いた方が良いケースはある?** \n・グローバルオブジェクトがwindowではない所からのリンクって例えばどんな時ですか? \n・スマホのブラウザからのアクセスも、グローバルオブジェクトはwindow?\n\n* * *\n\n**Q2.グローバルオブジェクト対象について** \n・例えば、「aサイトからbサイトへ遷移」した場合、「location.href」のグローバルオブジェクトは「aサイト」「bサイト」の何れが対象? \n・そもそも両者のグローバルオブジェクトが異なっていること自体が有り得ない??\n\n* * *\n\n**Q3.window以外のグローバルオブジェクトについて** \n・例えば、Node.js経由で表示しているブラウザのグローバルオブジェクトはwindowですか? \n・Node.jsの中のグローバルオブジェクトだけがglobal?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T02:40:57.947", "favorite_count": 0, "id": "42181", "last_activity_date": "2018-03-07T13:21:11.547", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 1, "tags": [ "javascript" ], "title": "「window.location.href」と「location.href」について", "view_count": 3116 }
[ { "body": "A1. あります。\n\nスコープ上に `window.location` 以外の変数 `location` が存在する場合があります。\n\n```\n\n function foo(...) {\n let location = 'Tokyo';\n // location と window.location は違う。\n ..\n }\n \n```\n\nまた、同名のローカル変数がない場合でも `window.location` と書いた場合と `location`\nと書いた場合でパフォーマンスが違うという話も聞いたことがあります。\n\n> グローバルオブジェクトがwindowではない所からのリンクって例えばどんな時ですか?\n\n質問の意味わかりません。\n\n> スマホのブラウザからのアクセスも、グローバルオブジェクトはwindow?\n\nスマートフォンかどうかに関わらず、ウェブブラウザ環境でのメインスレッドのグローバルオブジェクトは `window` です。\n\nただし、ブラウザ環境でもワーカー内は `self` がグローバルオブジェクトになります。\n\nA2. `window` グローバルオブジェクトは、ページ毎に異なるものが用意されます。ページA内のスクリプトから見える `window`\nと、ページB内のスクリプトから見える `window` は、別のものです。\n\n(厳密にはブラウジングコンテキスト毎で、IFRAMEを持っているドキュメントとそのIFRAME内のドキュメントは別の `window` を持ちます)\n\nA3. Node.js の JavaScript 実行環境とブラウザの JavaScript 実行環境は何も関係がありません。Node.js ではいつでも\n`global`、ブラウザ内ではいつでも `window` `self` などです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T13:21:11.547", "id": "42201", "last_activity_date": "2018-03-07T13:21:11.547", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3475", "parent_id": "42181", "post_type": "answer", "score": 2 } ]
42181
42201
42201
{ "accepted_answer_id": null, "answer_count": 1, "body": "いつもお世話になっております。 \n現在`git push heroku master`を実行した時のエラーについて思考しております。\n\n開発環境としては->Mac, AWSCloud9(Chromeがブラウザ), heroku です。\n\n`$ git push heroku master`を実行すると\n\n```\n\n (省略)\n To https://git.heroku.com/polar-hamlet-12140.git\n \n ! [remote rejected] master -> master (pre-receive hook declined)\n \n error: failed to push some refs to 'https://git.heroku.com/polar-hamlet-12140.git'\n \n```\n\nというエラーが出てしまうというものです。\n\n省略している部分は下に記しています(長くなります)。\n\n```\n\n ec2-user:~/environment/sample_app (master) $ git push heroku master\n Counting objects: 159, done.\n Compressing objects: 100% (152/152), done.\n Writing objects: 100% (159/159), 27.66 KiB | 944.00 KiB/s, done.\n Total 159 (delta 82), reused 0 (delta 0)\n remote: Compressing source files... done.\n remote: Building source:\n remote: \n remote: -----> Ruby app detected\n remote: -----> Compiling Ruby/Rails\n remote: -----> Using Ruby version: ruby-2.3.4\n remote: -----> Installing dependencies using bundler 1.15.2\n remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment\n remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.\n remote: Fetching gem metadata from https://rubygems.org/.......\n remote: Fetching version metadata from https://rubygems.org/..\n remote: Fetching dependency metadata from https://rubygems.org/.\n remote: Using rake 12.3.0\n remote: Fetching CFPropertyList 2.3.6\n remote: Using concurrent-ruby 1.0.5\n remote: Using minitest 5.11.3\n remote: Using thread_safe 0.3.6\n remote: Using builder 3.2.3\n remote: Using erubi 1.7.0\n remote: Using mini_portile2 2.3.0\n remote: Using crass 1.0.3\n remote: Using rack 2.0.4\n remote: Using nio4r 2.2.0\n remote: Using websocket-extensions 0.1.3\n remote: Using mini_mime 1.0.0\n remote: Using arel 8.0.0\n remote: Using execjs 2.7.0\n remote: Using bcrypt 3.1.11\n remote: Fetching rb-fsevent 0.10.3\n remote: Using ffi 1.9.23\n remote: Using will_paginate 3.1.6\n remote: Using bundler 1.15.2\n remote: Fetching mime-types-data 3.2016.0521\n remote: Installing CFPropertyList 2.3.6\n remote: Using coffee-script-source 1.12.2\n remote: Using method_source 0.9.0\n remote: Using thor 0.20.0\n remote: Fetching unf_ext 0.0.7.5\n remote: Installing rb-fsevent 0.10.3\n remote: Installing mime-types-data 3.2016.0521\n remote: Fetching excon 0.60.0\n remote: Fetching formatador 0.2.5\n remote: Installing unf_ext 0.0.7.5 with native extensions\n remote: Installing formatador 0.2.5\n remote: Using multi_json 1.13.1\n remote: Fetching ipaddress 0.8.3\n remote: Installing excon 0.60.0\n remote: Installing ipaddress 0.8.3\n remote: Fetching xml-simple 1.1.5\n remote: Installing xml-simple 1.1.5\n remote: Fetching inflecto 0.0.2\n remote: Installing inflecto 0.0.2\n remote: Fetching netrc 0.11.0\n remote: Fetching json 2.1.0\n remote: Installing netrc 0.11.0\n remote: Installing json 2.1.0 with native extensions\n remote: Fetching trollop 2.1.2\n remote: Installing trollop 2.1.2\n remote: Fetching mini_magick 4.7.0\n remote: Installing mini_magick 4.7.0\n remote: Fetching pg 0.20.0\n remote: Installing pg 0.20.0 with native extensions\n remote: Using puma 3.9.1\n remote: Using tilt 2.0.8\n remote: Using turbolinks-source 5.1.0\n remote: Using i18n 0.9.5\n remote: Using nokogiri 1.8.2\n remote: Using tzinfo 1.2.5\n remote: Fetching rack-test 0.8.3\n remote: Installing rack-test 0.8.3\n remote: Using sprockets 3.7.1\n remote: Using mail 2.7.0\n remote: Fetching autoprefixer-rails 8.1.0\n remote: Installing autoprefixer-rails 8.1.0\n remote: Using uglifier 3.2.0\n remote: Using websocket-driver 0.6.5\n remote: Using rb-inotify 0.9.10\n remote: Using bootstrap-will_paginate 1.0.0\n remote: Fetching fission 0.5.0\n remote: Installing fission 0.5.0\n remote: Using coffee-script 2.4.1\n remote: Fetching mime-types 3.1\n remote: Installing mime-types 3.1\n remote: Fetching fog-core 1.45.0\n remote: Installing fog-core 1.45.0\n remote: Fetching unf 0.1.4\n remote: Installing unf 0.1.4\n remote: Using turbolinks 5.0.1\n remote: Using faker 1.7.3\n remote: Using loofah 2.2.0\n remote: Using activesupport 5.1.4\n remote: Using sass-listen 4.0.0\n remote: Fetching fog-json 1.0.2\n remote: Installing fog-json 1.0.2\n remote: Fetching fog-xml 0.1.3\n remote: Installing fog-xml 0.1.3\n remote: Fetching fog-local 0.5.0\n remote: Installing fog-local 0.5.0\n remote: Fetching fog-vmfusion 0.1.0\n remote: Installing fog-vmfusion 0.1.0\n remote: Fetching domain_name 0.5.20170404\n remote: Installing domain_name 0.5.20170404\n remote: Using rails-html-sanitizer 1.0.3\n remote: Using rails-dom-testing 2.0.3\n remote: Using globalid 0.4.1\n remote: Using activemodel 5.1.4\n remote: Using jbuilder 2.7.0\n remote: Using sass 3.5.5\n remote: Fetching fog-aliyun 0.2.0\n remote: Installing fog-aliyun 0.2.0\n remote: Fetching fog-brightbox 0.14.0\n remote: Installing fog-brightbox 0.14.0\n remote: Fetching fog-dnsimple 1.0.0\n remote: Installing fog-dnsimple 1.0.0\n remote: Fetching fog-joyent 0.0.1\n remote: Installing fog-joyent 0.0.1\n remote: Fetching fog-openstack 0.1.24\n remote: Installing fog-openstack 0.1.24\n remote: Fetching fog-profitbricks 4.1.1\n remote: Installing fog-profitbricks 4.1.1\n remote: Fetching fog-sakuracloud 1.7.5\n remote: Installing fog-sakuracloud 1.7.5\n remote: Fetching fog-serverlove 0.1.2\n remote: Installing fog-serverlove 0.1.2\n remote: Fetching fog-softlayer 1.1.4\n remote: Installing fog-softlayer 1.1.4\n remote: Fetching fog-storm_on_demand 0.1.1\n remote: Installing fog-storm_on_demand 0.1.1\n remote: Fetching fog-atmos 0.1.0\n remote: Installing fog-atmos 0.1.0\n remote: Fetching fog-aws 2.0.1\n remote: Installing fog-aws 2.0.1\n remote: Fetching fog-cloudatcost 0.1.2\n remote: Installing fog-cloudatcost 0.1.2\n remote: Fetching fog-digitalocean 0.3.0\n remote: Installing fog-digitalocean 0.3.0\n remote: Fetching fog-dynect 0.0.3\n remote: Installing fog-dynect 0.0.3\n remote: Fetching fog-ecloud 0.3.0\n remote: Installing fog-ecloud 0.3.0\n remote: Fetching fog-google 0.1.0\n remote: Installing fog-google 0.1.0\n remote: Fetching fog-internet-archive 0.0.1\n remote: Installing fog-internet-archive 0.0.1\n remote: Fetching fog-powerdns 0.1.1\n remote: Installing fog-powerdns 0.1.1\n remote: Fetching fog-rackspace 0.1.5\n remote: Installing fog-rackspace 0.1.5\n remote: Fetching fog-radosgw 0.0.5\n remote: Installing fog-radosgw 0.0.5\n remote: Fetching fog-riakcs 0.1.0\n remote: Installing fog-riakcs 0.1.0\n remote: Fetching fog-terremark 0.1.0\n remote: Installing fog-terremark 0.1.0\n remote: Fetching fog-voxel 0.1.0\n remote: Installing fog-voxel 0.1.0\n remote: Fetching fog-xenserver 0.3.0\n remote: Installing fog-xenserver 0.3.0\n remote: Fetching http-cookie 1.0.3\n remote: Installing http-cookie 1.0.3\n remote: Using actionview 5.1.4\n remote: Using activejob 5.1.4\n remote: Using activerecord 5.1.4\n remote: Fetching carrierwave 1.2.2\n remote: Installing carrierwave 1.2.2\n remote: Using bootstrap-sass 3.3.7\n remote: Fetching rest-client 2.0.2\n remote: Installing rest-client 2.0.2\n remote: Using actionpack 5.1.4\n remote: Fetching rbovirt 0.1.5\n remote: Installing rbovirt 0.1.5\n remote: Using actioncable 5.1.4\n remote: Using actionmailer 5.1.4\n remote: Using railties 5.1.4\n remote: Using sprockets-rails 3.2.1\n remote: Fetching fog-ovirt 0.1.3\n remote: Installing fog-ovirt 0.1.3\n remote: Using coffee-rails 4.2.2\n remote: Using jquery-rails 4.3.1\n remote: Using rails 5.1.4\n remote: Using sass-rails 5.0.6\n remote: Fetching rbvmomi 1.11.7\n remote: Installing rbvmomi 1.11.7\n remote: Fetching fog-vsphere 2.0.0\n remote: Installing fog-vsphere 2.0.0\n remote: Fetching fog 1.42.0\n remote: Installing fog 1.42.0\n remote: Bundle complete! 28 Gemfile dependencies, 117 gems now installed.\n remote: Gems in the groups development and test were not installed.\n remote: Bundled gems are installed into ./vendor/bundle.\n remote: Post-install message from fog:\n remote: ------------------------------\n remote: Thank you for installing fog!\n remote: IMPORTANT NOTICE:\n remote: If there's a metagem available for your cloud provider, e.g. `fog-aws`,\n remote: you should be using it instead of requiring the full fog collection to avoid\n remote: unnecessary dependencies.\n remote: 'fog' should be required explicitly only if:\n remote: - The provider you use doesn't yet have a metagem available.\n remote: - You require Ruby 1.9.3 support.\n remote: ------------------------------\n remote: Bundle completed (21.27s)\n remote: Cleaning up the bundler cache.\n remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.\n remote: Removing autoprefixer-rails (8.0.0)\n remote: Removing rack-test (0.8.2)\n remote: Removing rb-fsevent (0.10.2)\n remote: Removing pg (0.18.4)\n remote: The latest bundler is 1.16.1, but you are currently running 1.15.2.\n remote: To update, run `gem install bundler`\n remote: -----> Installing node-v6.11.1-linux-x64\n remote: -----> Detecting rake tasks\n remote: -----> Preparing app for Rails asset pipeline\n remote: Running: rake assets:precompile\n remote: rake aborted!\n remote: ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/lib/fog/core/service.rb:244:in `validate_options'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/lib/fog/core/service.rb:268:in `handle_settings'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/lib/fog/core/service.rb:98:in `new'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:16:in `new'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/fog-core-1.45.0/lib/fog/storage.rb:27:in `new'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:124:in `eager_load_fog'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:137:in `fog_credentials='\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/config/initializers/carrier_wave.rb:3:in `block in <top (required)>'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:159:in `configure'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/carrierwave-1.2.2/lib/carrierwave.rb:14:in `configure'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/config/initializers/carrier_wave.rb:2:in `<top (required)>'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:655:in `block in load_config_initializer'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168:in `instrument'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:654:in `load_config_initializer'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:611:in `each'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:611:in `block in <class:Engine>'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `each'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `tsort_each_child'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/config/environment.rb:5:in `<top (required)>'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:329:in `require'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:329:in `require_environment!'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:445:in `block in run_tasks_blocks'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'\n remote: /tmp/build_7bcb295df064a3df64ebe28634ad9302/vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'\n remote: Tasks: TOP => environment\n remote: (See full trace by running task with --trace)\n remote: !\n remote: ! Precompiling assets failed.\n remote: !\n remote: ! Push rejected, failed to compile Ruby app.\n remote: \n remote: ! Push failed\n remote: Verifying deploy....\n remote: \n remote: ! Push rejected to polar-hamlet-12140.\n remote: \n To https://git.heroku.com/polar-hamlet-12140.git\n ! [remote rejected] master -> master (pre-receive hook declined)\n error: failed to push some refs to 'https://git.heroku.com/polar-hamlet-12140.git'\n ec2-user:~/environment/sample_app (master) $\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T04:05:31.200", "favorite_count": 0, "id": "42183", "last_activity_date": "2022-04-09T08:07:00.613", "last_edit_date": "2018-03-07T04:34:01.333", "last_editor_user_id": "3060", "owner_user_id": "25182", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "aws", "heroku" ], "title": "git push heroku master実行時のエラーについて", "view_count": 586 }
[ { "body": "fog-coreでは、awsリソースにアクセスするための`aws_access_key_id`,\n`aws_secret_access_key`が必要なのだと思われます。\n\n<https://stackoverflow.com/questions/27949158/heroku-missing-required-\narguments-aws-access-key-id-aws-secret-access-key-f>\n\nを参考にされたとのことですが、具体的には以下を実行されたという認識で間違いないでしょうか?\n\n 1. heroku環境変数に`aws_access_key_id`, `aws_secret_access_key`を設定\n 2. `config/initializers/carrierwave.rb`を修正し、fog-awsから設定された環境変数の`aws_access_key_id`, `aws_secret_access_key`を読み込むようにする", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-05T04:32:07.477", "id": "51716", "last_activity_date": "2019-01-05T04:32:07.477", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31669", "parent_id": "42183", "post_type": "answer", "score": 1 } ]
42183
null
51716
{ "accepted_answer_id": null, "answer_count": 1, "body": "症状がでてから、下記のチェックをしましたが、原因不明です。2日ほどたって、症状はなくなりました。\n\n1.マイクロソフト(office365) に問い合わせるが現象はでていないとの回答 \n2.ネットで調べても、現象がでているつぶやきなし。 \n3.セキュリティソフトを切っても変化なし。\n\nなお、pop3 pops (SSL通信です。)\n\nこれ以外にチェックする点はあるでしょうか? 症状が発生したPCは、20台弱です。windows7 windows10 が混在です。\n\nルータには、特定のPORTに制限かける機能はないです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T06:29:32.407", "favorite_count": 0, "id": "42190", "last_activity_date": "2018-03-08T08:14:06.323", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5922", "post_type": "question", "score": 0, "tags": [ "mail" ], "title": "office365 をメールサーバしたoutlook2013 の pop3 受信が間欠的ですが、異常に遅くなりました。原因究明はどうするといいのでしょうか?", "view_count": 76 }
[ { "body": "まず、現時点で現象が起きていないのであれば何が起きていたのかを事後的に調べるのはほぼ不可能です。\n\n質問に書かれている内容だけでは情報が少なすぎて調べる方向性すら示すことができません。初歩的に確認できるのはLANケーブルの接続間違えてループしていないか、ぐらいでしょうか。\n\nまぐれ当たりに期待するのでなければ、それなりの準備をしたうえで現象が起きるのを待ち切り分けをしていくしかありませんので、知識のある業者さんに依頼されることをおすすめします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T08:14:06.323", "id": "42224", "last_activity_date": "2018-03-08T08:14:06.323", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "42190", "post_type": "answer", "score": 1 } ]
42190
null
42224
{ "accepted_answer_id": null, "answer_count": 0, "body": "さくらドメインの設定反映までの表示画面についての質問\n\n現在、さくらドメインで取得した独自ドメインを使用し、さくらレンタルサーバーにマルチドメインで運用しています。しかし、一度、諸都合でマルチドメインを解除し、その後に再びマルチドメインの設定を行いました。すると、設定からおよそ2日ほど経過しているのですが、下のような画面から変更されません。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/6V8MC.png)](https://i.stack.imgur.com/6V8MC.png)\n\nいまだにDNS側の設定が更新されていないのか、そもそもマルチドメインの設定が間違っているのか判断がつかずに困っています。\n\nこの状態でしばらく待機するべきでしょうか。 \n設定がおかしい場合は、どの設定を確認したら良いでしょうか。 \n質問の情報が足りない場合はご指摘ください。 \nよろしくお願いします。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T06:30:10.730", "favorite_count": 0, "id": "42191", "last_activity_date": "2018-03-07T06:30:10.730", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27642", "post_type": "question", "score": 0, "tags": [ "dns", "network" ], "title": "さくらドメインの設定反映までの表示画面についての質問", "view_count": 144 }
[]
42191
null
null
{ "accepted_answer_id": "42197", "answer_count": 1, "body": "VideoViewを用いてネット上にある動画の再生を試みています。 \nしかし、実行したところ\"Can't this play video.\"と警告文が出て再生できません。 \nAndroidManifestにインターネット接続許可の文は付け加えています。\n\n以下、VideoViewにUrlをセットし、再生を試みている部分のコードです。\n\n```\n\n override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,\n savedInstanceState: Bundle?): View? {\n val view = inflater.inflate(R.layout.fragment_live_streaming, container, false)\n val afterGameLivestreaming: VideoView = view.findViewById(R.id.after_game_live)\n afterGameLivestreaming.setVideoURI(Uri.parse(\"https://www.youtube.com/watch?v=EaJHJK6Vzqg&t=1916s\"))\n afterGameLivestreaming.start()\n \n return view\n } \n \n```\n\nどうか、どなたかご教授よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T07:11:54.670", "favorite_count": 0, "id": "42192", "last_activity_date": "2018-03-07T08:41:20.397", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19267", "post_type": "question", "score": 0, "tags": [ "android", "kotlin", "videoview" ], "title": "VideoViewでCan't this play video", "view_count": 273 }
[ { "body": "指定しているURIが「動画ファイル」ではなく、YouTubeのサイト(Webページ)のURIであるからではないかと思います。 \nWeb上でのフリー素材などの動画ファイルのURIを指定すれば、再生されるのではないでしょうか?\n\n```\n\n afterGameLivestreaming.setVideoURI(Uri.parse(\"https://hogehoge/fugafuga.mp4\"))\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T08:41:20.397", "id": "42197", "last_activity_date": "2018-03-07T08:41:20.397", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "42192", "post_type": "answer", "score": 1 } ]
42192
42197
42197
{ "accepted_answer_id": null, "answer_count": 0, "body": "tensorforceという強化学習用のライブラリをいじっていて以下のエラーが出ております。 \nマイナーなライブラリだと思うので、ご回答は難しいかもしれないので、 \nエラーの見方だけでも教えていただけないでしょうか? \n(解決の糸口を探しています。)\n\n```\n\n Traceback (most recent call last):\n File \"run.py\", line 57, in \n main()\n File \"run.py\", line 43, in main\n **hydrated\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\agents\\ppo_agent.py\", line 151, in init\n entropy_regularization=entropy_regularization\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\agents\\learning_agent.py\", line 149, in init\n batching_capacity=batching_capacity\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\agents\\agent.py\", line 79, in init\n self.model = self.initialize_model()\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\agents\\ppo_agent.py\", line 179, in initialize_model\n likelihood_ratio_clipping=self.likelihood_ratio_clipping\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\models\\pg_prob_ratio_model.py\", line 88, in init\n gae_lambda=gae_lambda\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\models\\pg_model.py\", line 95, in init\n requires_deterministic=False\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\models\\distribution_model.py\", line 86, in init\n discount=discount\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\models\\memory_model.py\", line 106, in init\n reward_preprocessing=reward_preprocessing\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\models\\model.py\", line 200, in init\n self.setup()\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\models\\model.py\", line 307, in setup\n self.initialize(custom_getter=custom_getter)\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\models\\pg_model.py\", line 107, in initialize\n super(PGModel, self).initialize(custom_getter)\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\models\\distribution_model.py\", line 93, in initialize\n kwargs=dict(summary_labels=self.summary_labels)\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\core\\networks\\network.py\", line 180, in from_spec\n kwargs=kwargs\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\util.py\", line 159, in get_object\n return obj(*args, **kwargs)\n File \"C:\\Users\\Administrator\\RL\\tforce_btc_trader\\hypersearch.py\", line 155, in init\n super(CustomNet, self).init(layers_spec, **kwargs)\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\core\\networks\\network.py\", line 270, in init\n kwargs=dict(scope=scope, summary_labels=summary_labels)\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\core\\networks\\layer.py\", line 143, in from_spec\n kwargs=kwargs\n File \"c:\\users\\administrator\\rl\\tensorforce\\tensorforce\\util.py\", line 159, in get_object\n return obj(*args, **kwargs)\n TypeError: init() got an unexpected keyword argument 'cell_clip'\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T08:33:04.473", "favorite_count": 0, "id": "42196", "last_activity_date": "2018-03-07T08:42:48.397", "last_edit_date": "2018-03-07T08:42:48.397", "last_editor_user_id": "3060", "owner_user_id": "27645", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "TypeError: init() got an unexpected keyword argument 'XXX'", "view_count": 228 }
[]
42196
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "python3でTwitterAPIにリクエストを送り、返ってきた値を格納するというコードを書きました。 \n①ライブラリでOAuth認証をする \n②twitterAPIにリクエストを送る \n③APIのリクエスト上限をrequests_limitに格納する \nという内容になっています。 \nこの①のOAuth認証の例外処理の部分をメソッドにしたいのですがうまくかけません。例外処理でTwitterへのリクエストがうまくいかなかった時、OAuth認証をやり直し再度実行するメソッドを書きたいのです。\n\n```\n\n from requests_oauthlib import OAuth1Session\n CK = \"xxxxx\" #Consumer key\n CS = \"xxxxx\" #Consumer secret\n AT = \"xxxxx\" #Access token\n AS = \"xxxxx\" #Access token secret\n twitter = OAuth1Session(CK, CS, AT, AS)#認証処理\n request_status_url = \"https://api.twitter.com/1.1/statuses/retweets/:id.json\"#リクエストURL\n for i in range(3):#適当に3回\n #↓↓↓↓↓メソッドにしたいところ↓↓↓↓↓\n try:\n api_response = twitter.get(request_status_url )\n except:\n twitter = OAuth1Session(CK, CS, AT, AS)\n continue\n #↑↑↑↑↑メソッドにしたいところ↑↑↑↑↑\n requests_limit = api_response.headers['x-rate-limit-remaining']#リクエスト可能残数の取得\n print(str(i)+\":\"+str(requests_limit))\n \n```\n\n上記は正常に動作しますが下記のように認証部分メソッドにするとtry文が正常に動作しません。どのようにしたら正常に動くのか、書き方についてアドバイスをいただけたら幸いです。\n\n```\n\n from requests_oauthlib import OAuth1Session\n def request_authorization (request_status_url,CK,CS,AT,AS):\n try:\n api_response = twitter.get(request_status_url)\n except:\n twitter = OAuth1Session(CK,CS,AT,AS)\n api_response = request_authorization(request_status_url)\n return api_response\n CK = \"xxxxx\" #Consumer key\n CS = \"xxxxx\" #Consumer secret\n AT = \"xxxxx\" #Access token\n AS = \"xxxxx\" #Access token secret\n twitter = OAuth1Session(CK, CS, AT, AS)#認証処理\n request_status_url = \n \"https://api.twitter.com/1.1/statuses/retweets/:id.json\"#リクエストURL\n for i in range(3):#適当に3回\n api_response = request_authorization(request_status_url,CK, CS, AT, AS)\n requests_limit = api_response.headers['x-rate-limit-remaining']#リクエスト可能残数の取得\n print(str(i)+\":\"+str(requests_limit))\n \n```\n\n上記のコードを実行した時のエラーコード。\n\n* * *\n```\n\n UnboundLocalError Traceback (most recent call last)\n <ipython-input-7-25ff3a35d752> in request_authorization(request_status_url, CK, CS, AT, AS)\n 3 try:\n ----> 4 api_response = twitter.get(request_status_url)\n 5 except:\n \n UnboundLocalError: local variable 'twitter' referenced before assignment\n \n During handling of the above exception, another exception occurred:\n \n TypeError Traceback (most recent call last)\n <ipython-input-7-25ff3a35d752> in <module>()\n 15 for i in range(3):#適当に3回\n 16 #↓↓↓↓↓メソッドにしたいところ↓↓↓↓↓\n ---> 17 api_response = request_authorization(request_status_url,CK, CS, AT, AS)\n 18 #↑↑↑↑↑メソッドにしたいところ↑↑↑↑↑\n 19 requests_limit = api_response.headers['x-rate-limit-remaining']#リクエスト可能残数の取得\n \n <ipython-input-7-25ff3a35d752> in request_authorization(request_status_url, CK, CS, AT, AS)\n 5 except:\n 6 twitter = OAuth1Session(CK,CS,AT,AS)\n ----> 7 api_response = request_authorization(request_status_url)\n 8 return api_response\n 9 CK = \"yGWfCjVCS4uFHRA4q08RIWM2u\" #Consumer key\n \n TypeError: request_authorization() missing 4 required positional arguments: 'CK', 'CS', 'AT', and 'AS'\n \n```\n\n* * *\n\nちなみになぜOAuth認証が一回だけでないのかというと、APIからの大量の値の取得を行い、実行が数時間に及んだ時、OAuth認証が切れる時があるからです。認証が切れた時のエラーコードは以下です。\n\n```\n\n Traceback (most recent call last):\n 〜〜\n 〜〜\n ConnectionResetError: [Errno 54] Connection reset by peer\n During handling of the above exception, another exception occurred:\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T09:52:20.560", "favorite_count": 0, "id": "42198", "last_activity_date": "2018-03-19T14:25:17.957", "last_edit_date": "2018-03-07T20:57:34.480", "last_editor_user_id": "24284", "owner_user_id": "26843", "post_type": "question", "score": 1, "tags": [ "python", "python3", "twitter", "oauth" ], "title": "python メソッド内で例外処理を行う方法", "view_count": 1636 }
[ { "body": "なんでエラーになるかだけを回答します。\n\n```\n\n TypeError: request_authorization() missing 4 required positional arguments: 'CK', 'CS', 'AT', and 'AS'\n \n```\n\nこれは request_authorization関数に 引数 CK, CS, AT, ASが足りないという意味です。\n\n```\n\n def request_authorization (request_status_url,CK,CS,AT,AS):\n try:\n api_response = twitter.get(request_status_url)\n except:\n twitter = OAuth1Session(CK,CS,AT,AS) # <= ローカル変数twitterに代入してるだけ\n api_response = request_authorization(request_status_url) # <= 引数がない\n return api_response\n \n```\n\nこれで エラーは回避できますが、そもそもこのコードは `rate-limit に到達した時にTwitterのOAuthSessionを作り直す`\nをことを全くしてくれません。\n\nなので以下のようにすると良いかと思います。\n\n * TwitterのOAuthSession を作るのもrequest_authorizationの中でやる\n * except: ではなく rate_limit の場合の例外の場合だけ再帰的に request_authorizationを呼ぶ", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T14:25:17.957", "id": "42500", "last_activity_date": "2018-03-19T14:25:17.957", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2168", "parent_id": "42198", "post_type": "answer", "score": 2 } ]
42198
null
42500
{ "accepted_answer_id": "42208", "answer_count": 2, "body": "**「ネットワーク経由でadb実行」後、しばらく経って再度「ネットワーク経由でadb実行」する場合について** \n・[リンク先](https://qiita.com/hamup/items/d0757af393a5462b686a)内容は、常に最初にUSB接続が必要でしょうか? \n・再度USB接続が必要な要件を知りたいです\n\n・色々試してみたのですが、「adb disconnect」後「adb connect\nxxx.xxx.xxx.xxx」コマンドを打つだけで繋がる場合もあるし、再度USB接続しなければつながらない場合もあり、何によって挙動が変わるのかよく分かりません", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T10:54:24.127", "favorite_count": 0, "id": "42199", "last_activity_date": "2018-03-08T01:47:39.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "android", "network" ], "title": "ネットワーク経由でadb実行した後について", "view_count": 1198 }
[ { "body": "Android Studioのマニュアルを読む限り、「接続が切れた後で再接続できない場合は、USB接続の手順からやり直すように」と読めます。\n\n* * *\n\n[Android Debug Bridge | Android\nStudio](https://developer.android.com/studio/command-line/adb.html?hl=ja)\n\n**Wi-Fi を介した端末への接続**\n\nadb 接続が失われた場合は、次の手順を実行します。\n\n 1. Android 端末が接続されている Wi-Fi ネットワークと同じネットワークにホストが引き続き接続されていることを確認します。\n\n 2. adb connect のステップを再度実行して再接続します。\n\n 3. 上記の手順で接続できない場合は、adb ホストをリセットします。\n``` adb kill-server\n\n \n```\n\n 4. その後、最初からやり直します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T11:21:07.117", "id": "42200", "last_activity_date": "2018-03-07T11:21:07.117", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "3060", "parent_id": "42199", "post_type": "answer", "score": 0 }, { "body": "> ・リンク先内容は、常に最初にUSB接続が必要でしょうか?\n\n必要です。以下の実行でUSB接続している必要があります。\n\n```\n\n $adb tcpip 5555\n \n```\n\n補足するとadb接続では端末側のadbd(daemon)とホストPC側のadbd(daemon)が存在し、通常端末側のadbd(daemon)はUSB経由でのadb接続を待ち受けています。 \n上記のコマンドは、ホストPC側のadbdからUSB経由で端末側のadbdにWi-\nFi接続(WiFiだけとは限りませんが)での5555ポートでadb接続を待ち受けるように指示するコマンドです。\n\n```\n\n <ホストPC>adbd ---- USB ---> <端末>adbd\n \n```\n\nこのコマンド実行で端末側のadbdがUSBではなくipで待ち受けるようになり、Wi-Fiでのadb接続が可能になります。 \n(逆にUSBからのadb接続ができなくなるはずです。端末側の実装依存にはなりますが)\n\n* * *\n\n> ・再度USB接続が必要な要件を知りたいです \n> ・色々試してみたのですが、「adb disconnect」後「adb connect\n> xxx.xxx.xxx.xxx」コマンドを打つだけで繋がる場合もあるし、再度USB接続しなければつながらない場合もあり、何によって挙動が変わるのかよく分かりません\n\n端末側のadbdの待ち受けがUSBになっていたらUSB接続し、上記コマンドの実行からやり直す必要があります。 \n「adb disconnect」「adb connect xxx.xxx.xxx.xxx」のコマンドはWi-\nFi経由でのadbの接続/切断を指示するコマンドです。 \n端末側のadbdがUSBで待ち受けていたら、コマンド実行しても意味がありません。 \nコメントにもありますが、端末側のメーカー実装次第で再度USB接続が必要かどうかは、様々なケースがあり得るので明確な回答は難しいです。\n\n・USB抜き差しを検知して端末側のadbdの待ち受けがUSBに変わる(かもしれない) \n・ネットワークの変更を検知して端末側のadbdの待ち受けがUSBに変わる(かもしれない) \n・その他何かの変化を検知して端末側のadbdの待ち受けがUSBに変わる\n\n複合条件の可能性もありますし、必要な要件を確実に知りたいのであれば端末の製造メーカーに問い合わせた方が良いと思います。 \n1つだけ明確にわかる条件は端末を再起動するとadbdは初期状態のUSB待ち受けになると思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T01:38:03.437", "id": "42208", "last_activity_date": "2018-03-08T01:47:39.947", "last_edit_date": "2018-03-08T01:47:39.947", "last_editor_user_id": "20272", "owner_user_id": "20272", "parent_id": "42199", "post_type": "answer", "score": 1 } ]
42199
42208
42208
{ "accepted_answer_id": null, "answer_count": 1, "body": "Autoencoderの中間層ノードを増やして出力の再現精度を上げようとしたのですが、うまく行かなかったので質問させていただきます。\n\nAutoencoder は例えば、784 -> 32 -> 784\nな構造で組めば、32次元に圧縮された特徴情報が得られる、というような手法であると理解しています。\n\nそこで、784 -> 32 -> 784 な Autoencoder が32次元から784次元の情報を再現するのなら、784 -> 784 -> 784\nなネットワークはより上手く、というよりほぼ損失なく入力を復元する恒等写像を作るのでは?と考え、Fashion-\nMNISTデータセットを使ったコードを書いてみたのですが、出力される画像は期待するほど鮮明になりませんでした。(オリジナルのMNISTはそこそこ鮮明になりました)\n\n[![Fashion-\nMNIST](https://i.stack.imgur.com/dFvQa.png)](https://i.stack.imgur.com/dFvQa.png)\n\nもちろん、中間層のノードを入出力より少なく設定しなければ Autoencoder\nを使う意味はほぼ無いという事は理解しているのですが、中間層のノードを増やしても恒等写像を高精度に学習できない理由が何であるか知りたいのです。\n\n上記のFashion-\nMNISTの例のように恒等写像ですら高精度に出来ない=次元を減らさないネットワークを使っても上手く情報を残すとは言いがたい(壊してしまう?)状態であるなら、次元削減を目的に使った場合にも精度の悪い特徴を残してしまうだけではないのでしょうか?\n\n原理的には、784次元の情報を再現するには784次元以上の情報があれば十分じゃないのかと思うのですが、高精度にならない理由やより良い実装、参考となる資料などをご存じでしたらお答え頂けると有り難いです。\n\n**追記:上記画像を生成する際に使ったコード全文(Python3 & Keras)を追記しておきます。**\n\n```\n\n from keras.datasets import fashion_mnist\n from keras.layers import Input, Dense\n from keras.models import Model\n \n import matplotlib.pyplot as plt\n \n (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()\n \n x_train = x_train.reshape(60000, 784)\n x_test = x_test.reshape(10000, 784)\n x_train = x_train.astype(\"float32\")\n x_test = x_test.astype(\"float32\")\n x_train /= 255.0\n x_test /= 255.0\n \n input_img = Input(shape=(784,))\n encoded = Dense(784, activation=\"relu\")(input_img)\n decoded = Dense(784, activation=\"sigmoid\")(encoded)\n \n autoencoder = Model(inputs=input_img, outputs=decoded)\n autoencoder.compile(optimizer=\"adam\", loss=\"binary_crossentropy\")\n autoencoder.fit(x_train, x_train,\n epochs=5,\n batch_size=128,\n shuffle=True,\n validation_data=(x_test, x_test))\n \n # テスト画像を変換\n decoded_imgs = autoencoder.predict(x_test)\n \n # 何個表示するか\n n = 10\n plt.figure(figsize=(20, 4))\n for i in range(n):\n # オリジナルのテスト画像を表示\n ax = plt.subplot(2, n, i+1)\n plt.imshow(x_test[i].reshape(28, 28))\n plt.gray()\n ax.get_xaxis().set_visible(False)\n ax.get_yaxis().set_visible(False)\n \n # 変換された画像を表示\n ax = plt.subplot(2, n, i+1+n)\n plt.imshow(decoded_imgs[i].reshape(28, 28))\n plt.gray()\n ax.get_xaxis().set_visible(False)\n ax.get_yaxis().set_visible(False)\n plt.show()\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T17:36:01.347", "favorite_count": 0, "id": "42203", "last_activity_date": "2018-03-07T18:59:52.283", "last_edit_date": "2018-03-07T17:54:11.153", "last_editor_user_id": "27649", "owner_user_id": "27649", "post_type": "question", "score": 0, "tags": [ "python", "機械学習" ], "title": "Autoencoderの中間層ノードを増やしても再現精度に限界があるのは何故でしょうか?", "view_count": 2017 }
[ { "body": "すみません、自己解決しました。単に学習不足と、実数値の画像データ向きでない損失関数を設定してしまっていたようです。\n\n損失関数を適切なもの(msle等)に設定し直し、epochを十分に(少なくとも50くらい)回せばかなり高精度に再現できました。\n\n[![fashin-\nmnist-2](https://i.stack.imgur.com/0nkmR.png)](https://i.stack.imgur.com/0nkmR.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-07T18:51:39.050", "id": "42204", "last_activity_date": "2018-03-07T18:59:52.283", "last_edit_date": "2018-03-07T18:59:52.283", "last_editor_user_id": "27649", "owner_user_id": "27649", "parent_id": "42203", "post_type": "answer", "score": 1 } ]
42203
null
42204
{ "accepted_answer_id": null, "answer_count": 3, "body": "Emacsで、diredでディレクトリを開いた時に、`c-n`や`c-p`でファイルをひとつひとつ移動はできますが、 \nファイルの頭文字を打ったら、そのファイルの行まで移動する方法はないでしょうか?\n\n```\n\n .\n ..\n hello.html\n test.html\n \n```\n\n上記ディレクトリで、`t`とタイプしたら、test.htmlの行が選択されている状態になり、 \nenterを押すと開くというような操作ができる方法です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T00:38:13.273", "favorite_count": 0, "id": "42205", "last_activity_date": "2018-03-12T08:35:11.470", "last_edit_date": "2018-03-11T18:36:14.497", "last_editor_user_id": "27509", "owner_user_id": "14234", "post_type": "question", "score": 1, "tags": [ "emacs" ], "title": "Emacsのdiredでファイル名の頭文字で選択する方法", "view_count": 270 }
[ { "body": "自分がよくやるのは、 C-s でインクリメンタルサーチ起動して、それでファイル名をテキストとして検索、カーソルが選択したいファイルに移動したら enter\n連打、です。回答になってるかは、若干怪しいですが…", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T02:31:03.323", "id": "42210", "last_activity_date": "2018-03-08T02:31:03.323", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "42205", "post_type": "answer", "score": 0 }, { "body": "Yuki Inoueさんの回答の補足ですが、Diredのインクリメンタルサーチ `C-s`\nをファイル名マッチに限定する(ファイル所有者やパーミッションにマッチさせない)設定を有効にすると便利です。\n\n以下の設定を `.emacs` あるいは `~/.emacs.d/init.el` に追記して下さい。\n\n```\n\n ;; t - 常にファイル名にマッチさせる\n ;; dwim - カーソル位置がファイル名にある場合はファイル名マッチを有効にする\n (setq dired-isearch-filenames 'dwim)\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T12:03:00.347", "id": "42232", "last_activity_date": "2018-03-12T08:35:11.470", "last_edit_date": "2018-03-12T08:35:11.470", "last_editor_user_id": "2391", "owner_user_id": "2391", "parent_id": "42205", "post_type": "answer", "score": 2 }, { "body": "helm を用いるのも一つの方法かと思います \n興味があるなら [初心者〜初級者のためのEmacs-Helm事始め :\n前編](https://qiita.com/jabberwocky0139/items/86df1d3108e147c69e2c) の「コマンド:\nhelm-find-files」が参考になるでしょう", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T12:38:22.100", "id": "42235", "last_activity_date": "2018-03-08T12:38:22.100", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27509", "parent_id": "42205", "post_type": "answer", "score": 0 } ]
42205
null
42232
{ "accepted_answer_id": "42247", "answer_count": 1, "body": "お世話になります。何卒よろしくお願い致します。\n\n以下のサイトを参考にphpからMySQLに設定した(ルーチンタブ内に作成した)ストアドプロシージャを起動させようとしておりますが、エラーが出ないものの、起動もできません。\n\n[MySQLのストアドプロシージャを呼び出す](https://phpjpn.com/?MySQL%E3%81%AE%E3%82%B9%E3%83%88%E3%82%A2%E3%83%89%E3%83%97%E3%83%AD%E3%82%B7%E3%83%BC%E3%82%B8%E3%83%A3%E3%82%92%E5%91%BC%E3%81%B3%E5%87%BA%E3%81%99)\n\n以下はphpの記述と、MySQLの設定です。どこに問題があるかご指摘、ご教示等頂けませんでしょうか。\n\n*php側では、db接続に関する記述($connect_db、$connect_user、$connect_passwd)を異なるものにするとエラーが出ます。また、$stmt = $dbh->prepareをprepaなどと変更するとエラーになりますが、CALL get_image(:code)自体をCALL get_ima(:code)と変更してもエラーが出ないことを考えると、データベースに接続し、$stmtを実行しようとしているのは確かだけれど、ストアドプロシージャの呼び出し、'CALL get_image(:code)'をしていない、あるいは、ができていないと考えられます。\n\n*MySQLのストアドプロシージャのwhere句のcodeにテーブルtbl_productsに存在するproduct_id、例えば12を設定し、mySql上で”実行する”を押すと期待通りの結果になります。即ち設定したストアドプロシージャの内容、テーブル上でt1.main_image に t1.main_image_xを挿入致します。\n\nデータベース:MySQL5.0.77 \nPHP:5.0.22 \nWEBサーバ:apache2\n\n**phpの設定**\n\n```\n\n try {\n $connect_db = \"mysql:dbname=xxxxxxx;host=localhost\";\n $connect_user = 'xxxxxxx';\n $connect_passwd = 'xxxxxxx';\n \n //データベース接続\n $dbh = new PDO(\n $connect_db,\n $connect_user,\n $connect_passwd,\n array(PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\")\n );\n \n $stmt = $dbh->prepare('CALL get_image(:code)');\n $code = '12';// 最終的にはシステム的に変数を代入する設定にする\n $stmt->bindParam(':code', $code);\n // ストアドプロシージャをコールします\n $stmt->execute();\n \n while($row = $stmt->fetch(PDO::FETCH_ASSOC)){\n echo $row['t1.main_image'];\n }\n } catch(PDOException $e){\n var_dump($e->getMessage());\n }\n }\n // 切断\n $dbh = null;\n \n```\n\n**MySQL ストアドプロシージャの設定**\n\n```\n\n DELIMITER $$\n CREATE DEFINER=`xxxxxxx`@`%` PROCEDURE `get_image(IN code varchar(2))`()\n NO SQL\n BEGIN\n \n UPDATE tbl_products t1 SET t1.main_image = t1.main_image_x WHERE t1.product_id = code;\n \n End$$\n DELIMITER ;\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T00:55:39.317", "favorite_count": 0, "id": "42206", "last_activity_date": "2018-03-09T02:43:45.927", "last_edit_date": "2018-03-08T01:22:16.307", "last_editor_user_id": "27650", "owner_user_id": "27650", "post_type": "question", "score": 0, "tags": [ "php", "mysql", "pdo" ], "title": "phpからMySQLの(ルーチンタブ)ストアドプロシージャを呼び出すことができない件に関して。", "view_count": 770 }
[ { "body": "CALL get_image('12'); でエラーになるという時点で、そもそも期待通りにストアドプロシジャが作成できていないということです。\n\n「get_image」がストアドプロシジャ名であり続きの括弧の中「(IN code\nvarchar(2))」は引数の宣言ですよね?であれば以下のようになるのではないでしょうか?\n\n```\n\n DELIMITER $$\n CREATE DEFINER=`xxxxxxx`@`%` PROCEDURE `get_image`(IN code varchar(2))\n NO SQL\n BEGIN\n \n UPDATE tbl_products t1 SET t1.main_image = t1.main_image_x WHERE t1.product_id = code;\n \n End$$\n DELIMITER ;\n \n```\n\n質問にお書きになられたソースコードでは「get_image(IN code\nvarchar(2))」という名前で、引数がないストアドプロシジャを定義している状態です。\n\nご確認ください。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T02:43:45.927", "id": "42247", "last_activity_date": "2018-03-09T02:43:45.927", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27410", "parent_id": "42206", "post_type": "answer", "score": 0 } ]
42206
42247
42247
{ "accepted_answer_id": null, "answer_count": 1, "body": "NginxとApacheの設定ファイルは何言語で書かれているのでしょうか? \nNginxの設定ファイルを、$から始まる変数を使って書き換えている例を先日見かけました。 \nPerlかPHPですかね。\n\nというのも、あるHTTPヘッダーの動的に(UNIX時間が動的な要素)変更したく、どうしようかなとぐぐっていたところ、設定ファイル内で条件文書いて設定していいる例があり参考にできないかなと思っています。 \n(他にこういう方法でもできるよ、というものがあると助かります\n\nよろしくお願いします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T04:25:18.437", "favorite_count": 0, "id": "42211", "last_activity_date": "2018-03-08T06:21:42.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25065", "post_type": "question", "score": 0, "tags": [ "linux", "apache", "nginx" ], "title": "NginxとApacheの設定ファイルは何言語で書かれているのでしょうか?", "view_count": 152 }
[ { "body": "設定ファイルに書かれているのはいわゆるプログラミング言語ではありません。 \nNginxやApacheはそれぞれ独自の構文がありそれによって書かれています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T06:21:42.527", "id": "42214", "last_activity_date": "2018-03-08T06:21:42.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "42211", "post_type": "answer", "score": 2 } ]
42211
null
42214
{ "accepted_answer_id": null, "answer_count": 3, "body": "違うgitのURLにプロダクトをpushしたいです。 \n~/Downloads/app/ git remote add origin\n<https://github.com/myname/app_comp.git> とコマンドを打つと、 \nfatal: remote origin already exists. とエラーが出ました。 \ngit clone <https://github.com/myname/app.git>\nと違うURLからプロダクトをダウンロードしてきたので、そのアドレスが設定されているのだとは思いましたが、<https://github.com/myname/app_comp.git>\nのアドレスにpushするにはどうしたら良いのでしょうか?ブランチを切り替える訳でもないし・・・。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T06:51:37.487", "favorite_count": 0, "id": "42216", "last_activity_date": "2018-03-09T12:54:55.273", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27659", "post_type": "question", "score": 0, "tags": [ "git" ], "title": "違うgitのURLにプロダクトをpushしたい", "view_count": 5176 }
[ { "body": "先にcloneした`myname/app.git`が既に`origin`として登録されているのであれば、違うgitのリモートリポジトリ=`myname/app_comp.git`はorigin以外の\n**別名** で登録する必要があります。\n\n以下の例では`origin`の代わりに`mirror`としてリモートリポジトリを追加する実行方法です。\n\n```\n\n $ git remote add mirror https://github.com/myname/app_comp.git\n \n```\n\nもしくは既存の`origin`をいったん別名にリネームして、`myname/app_comp.git`を`origin`として登録し直すのもひとつの方法だと思います。\n\n複数のリモートリポジトリを登録した場合には、`git remote`で確認すると以下の様な表示になります。\n\n```\n\n $ git remote -v\n origin https://github.com/myname/app.git (fetch)\n origin https://github.com/myname/app.git (push)\n mirror https://github.com/myname/app_comp.git (fetch)\n mirror https://github.com/myname/app_comp.git (push)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T07:23:59.857", "id": "42219", "last_activity_date": "2018-03-08T07:23:59.857", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "42216", "post_type": "answer", "score": 3 }, { "body": "タイトルが「違うgitのURLにプロダクトをpushしたい」ということなので単純に以下の方法でも可能です。 \n※pushしようとしているブランチが何か不明なので仮にmasterとしています。\n\n```\n\n git push https://github.com/myname/app_comp.git master\n \n```\n\n* * *\n\n質問内容や別の方の回答にあるように \n`origin`は`https://github.com/myname/app.git`の別名として登録されています。 \n`git push`のコマンドでは以下のようにプッシュ先のリモートリポジトリを指定します。\n\n```\n\n git push <リモートリポジトリ> <プッシュするブランチ/コミットハッシュ>\n \n```\n\nですので`mirror`として`https://github.com/myname/app_comp.git`を登録されるのであれば\n\n```\n\n git push mirror master\n \n```\n\nのようにコマンドを実行する必要があります。 \n`<プッシュするブランチ/コミットハッシュ>`は省略可能ですが、個人的に **「どこ」** に **「どんな変更」**\nをプッシュしようとしているのかを意識した方が良いと思うので、省略しない方が好みです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T01:22:46.267", "id": "42244", "last_activity_date": "2018-03-09T01:22:46.267", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "42216", "post_type": "answer", "score": 0 }, { "body": "originを別のURLにしたいのであれば、\n\n```\n\n git remote set-url origin https://github.com/myname/app_comp.git\n \n```\n\nで書き換えられます。その後、\n\n```\n\n git remote -v\n \n```\n\nでoriginのURLが書き換えられているのが確認できると思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T12:54:55.273", "id": "42276", "last_activity_date": "2018-03-09T12:54:55.273", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7900", "parent_id": "42216", "post_type": "answer", "score": 0 } ]
42216
null
42219
{ "accepted_answer_id": null, "answer_count": 9, "body": "if文の場合分け時にelse ifをよく使うのを見ますが、偶にifの箇条書きのように場合分けをしているのを見ました。\n\n```\n\n if(){\n }else if(){\n }else if(){\n }\n \n```\n\nと\n\n```\n\n if(){}\n if(){}\n if(){}\n \n```\n\nの違いはどのようなものでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T07:15:55.783", "favorite_count": 0, "id": "42218", "last_activity_date": "2019-11-23T13:12:01.820", "last_edit_date": "2018-03-09T07:47:08.637", "last_editor_user_id": "3054", "owner_user_id": "27276", "post_type": "question", "score": 4, "tags": [ "c" ], "title": "else if と if の羅列の違い", "view_count": 22572 }
[ { "body": "```\n\n if(){}\n else if(){} \n \n```\n\nは、\n\n```\n\n if(){\n }else{\n if(){\n }\n }\n \n```\n\nということです。\n\n```\n\n if(){}\n if(){}\n \n```\n\nとはちょっとちがいますねー", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T08:07:58.730", "id": "42223", "last_activity_date": "2018-03-08T08:07:58.730", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27481", "parent_id": "42218", "post_type": "answer", "score": 2 }, { "body": "用途に応じて使い分ける必要があると思います。\n\n`else if`の方は3つの波括弧のうちいずれかしか処理されません。 \n箇条書きの方は3つ全ての波括弧の中が処理される可能性があります。\n\n* * *\n\n簡単な例を挙げると\n\n\"abc\"という文字列を、\n\n * (1)先頭が\"a\"で始まる\n * (2)最後が\"c\"で終わる\n * (3)\"abc\"という文字列である\n\nの3パターンで評価する場合\n\n`else if`では以下の場合は(1)の評価の括弧内の処理しか実行されません。\n\n```\n\n if((1)の評価){\n // \"a\"で始まる文字列\n }else if((2)の評価){\n // \"c\"で終わる文字列\n }else if((3)の評価){\n // \"abc\"という文字列\n }\n \n```\n\n一方、箇条書きの場合はすべての括弧内の処理が実行されます。\n\n```\n\n if((1)の評価){\n // \"a\"で始まる文字列\n }\n if((2)の評価){\n // \"c\"で終わる文字列\n }\n if((3)の評価){\n // \"abc\"という文字列\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T08:15:13.980", "id": "42225", "last_activity_date": "2018-03-08T08:15:13.980", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "42218", "post_type": "answer", "score": 6 }, { "body": "```\n\n if(A){\n }else if(B){\n }else if(C){\n }\n \n```\n\nは、`switch case文`とほぼ同じです。処理の優先順位があり(A>B>C)、Aの条件がtrue(真)の場合は、条件B,Cの処理は行われません。\n\n```\n\n if(A){}\n if(B){}\n if(C){}\n \n```\n\nは、A、B、Cの条件が一致した何れかの処理を順次実行して進みます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T08:16:31.360", "id": "42226", "last_activity_date": "2018-03-08T08:16:31.360", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22793", "parent_id": "42218", "post_type": "answer", "score": 1 }, { "body": "違いがわかるかもしれないコード例を考えてみました。\n\n```\n\n int a=0;\n if( a==0){\n a++; // ここに入りますが\n }\n else if( a == 1){// 一連のif()~else if()~elseについて、aはすでに「評価済み」なので\n a++; // 入らない\n }\n else if( a == 2){\n a++; // 入らない\n }\n // で、aは「1」になります。\n \n```\n\nと\n\n```\n\n int a=0;\n if( a==0){// 独立のif()です。\n a++; // 評価結果が真なのでここに入ります\n }\n if( a==1){// これも独立のif()です。\n a++; // なので、ここも入ります\n }\n if( a==2){// これも独立のif()です。\n a++; // なので、ここにも入ります\n }\n // で、aは「3」になります\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T09:02:13.137", "id": "42228", "last_activity_date": "2018-03-08T09:02:13.137", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3793", "parent_id": "42218", "post_type": "answer", "score": 1 }, { "body": "疑問に思ったのであればサンプルコードを書いて実行してみてください。 \na, b, c の true, false を切り替えて実行してみれば動作の違いが判るかと思います。\n\n```\n\n #include <stdio.h>\n #include <stdlib.h>\n #include <stdbool.h>\n \n int main(int argc, char *argv[])\n {\n bool a = false;\n bool b = true;\n bool c = true;\n \n if(a){\n printf(\"if-else : a is true.\\n\");\n }else if(b){\n printf(\"if-else : a is not ture, and b is true.\\n\");\n }else if(c){\n printf(\"if-else : a is not true, and b is not true, and c is true.\\n\");\n }\n \n if(a){\n printf(\"if : a is true.\\n\");\n }\n if(b){\n printf(\"if : b is true.\\n\");\n }\n if(c){\n printf(\"if : c is true.\\n\");\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T09:40:16.767", "id": "42230", "last_activity_date": "2018-03-08T11:09:10.757", "last_edit_date": "2018-03-08T11:09:10.757", "last_editor_user_id": "27410", "owner_user_id": "27410", "parent_id": "42218", "post_type": "answer", "score": 0 }, { "body": "例ー1\n\n```\n\n int a= 10;\n if( a < 10 ){\n // ここには入らない\n }else if( a < 20 ){\n // ここに入る\n }else if( a < 30 ){\n // ここには入らない\n }\n \n```\n\n例ー2\n\n```\n\n int a= 10;\n if( a < 10 ){\n // ここには入らない\n }\n if( a < 20 ){\n // ここに入る\n }\n if( a < 30 ){\n // ここに入る\n }\n \n```\n\n・・・全然別物になりますねd^^", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T12:17:42.313", "id": "42233", "last_activity_date": "2018-03-09T01:54:32.163", "last_edit_date": "2018-03-09T01:54:32.163", "last_editor_user_id": "49", "owner_user_id": "25438", "parent_id": "42218", "post_type": "answer", "score": 3 }, { "body": "他の方の回答でも良いかと思いますが、、、、\n\n[ _パターン A_ ]\n\n> if ( _条件1_ ) { _処理1_ } \n> else if ( _条件2_ ) { _処理2_ } \n> else if ( _条件3_ ) { _処理3_ }\n\n[ _パターン B_ ]\n\n> if ( _条件1_ ) { _処理1_ } \n> if ( _条件2_ ) { _処理2_ } \n> if ( _条件3_ ) { _処理3_ }\n\nの違いという事かと思います。\n\n[ _パターン A_ ] の場合、\" _条件1_ \" に合致すると、\" _処理1_ \" を実行しますが、\" _条件2_ \" に合致しても、 \" _処理2_\n\" は実行しません。 \n[ _パターン B_ ] の場合、\" _条件1_ \" に合致すると、\" _処理1_ \" を実行し、\" _条件2_ \" に合致すると、 \"処理2\"\nを実行します。 \n従って、 \" _条件1_ \" と\" _条件2_ \" が同時に成立しない場合、結果は同じとなります。 \" _条件3_ \" も同様。\n\nただし、[ _パターン B_ ]の場合、\" _条件1_ \" に合致した場合でも、\" _条件2_ \" の評価が行われます。 \n従って、\" _条件1_ \" と \" _条件2_ \" が同時に成立しない場合、\" _条件1_ \" に合致したでも\" _条件2_\n\"の評価が行われるため、処理が余分に掛ります。 \n具体的には、 _条件1_ : (A == 1)、 _条件2_ : (A == 2) のような場合、[ _パターン B_ ]の方が僅かですが **遅く**\nなります。 \n逆に、 _条件1_ : (A == 1)、 _条件2_ : (B == 1) のような場合、[ _パターン A_ ]と[ _パターン B_\n]では(多くの場合) **結果が異なり** ます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T13:04:50.753", "id": "42236", "last_activity_date": "2018-03-08T13:04:50.753", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "42218", "post_type": "answer", "score": 2 }, { "body": "箇条書きされた`if`文はあくまでソースコードを読み書きする人間が理解しやすいよう都合よく並べて書いているだけで、異なる`if(..)`が出てきた時点でロジック的には\n**別の**`if`文です。\n\n例えば「ある値が偶数か奇数か」はどちらか一方しか条件に当てはまらないので`if(..) else`を使う必要がありますが、\n\n```\n\n int num = 2;\n \n if (num % 2 == 0) {\n printf \"%d は偶数\\n\", num;\n }\n else {\n printf \"%d は奇数\\n\", num;\n ]\n \n```\n\n「ある値がx, yのそれぞれ倍数か調べたい」であればif文を箇条書きする形になると思います。\n\n```\n\n int num = 10;\n \n if (num % 2 == 0) {\n printf \"%d は2の倍数\\n\", num;\n }\n if (num % 5 == 0) {\n printf \"%d は5の倍数\\n\", num;\n }\n \n```\n\n* * *\n\n個人的には条件文の異なる`if`文は1行以上空けて見分けやすいように記述したり、もしくは他の人の回答にもありますが`switch\ncase`文の様な条件を書きたいなら素直に`switch case`を使うべきかと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T13:09:51.297", "id": "42237", "last_activity_date": "2018-03-08T13:09:51.297", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "42218", "post_type": "answer", "score": 0 }, { "body": "> if(A){} \n> if(B){} \n> if(C){}\n\nは3個の独立したif文です。\n\n* * *\n\n> if(A){ \n> }else if(B){ \n> }else if(C){ \n> }\n\nは1個のif文です。→ `if(A)` \n`if(A)`のelse節が別のif文である`if(B)`になっています。 \n同様に`if(B)`のelse節が別のif文である`if(C)`になっています。 \n次のように書き直して考えれば違いが理解しやすいと思います。\n\n```\n\n if(A)\n {\n ...\n }\n else\n {\n if(B){\n ...\n }\n else\n {\n if(C)\n {\n ...\n }\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-11-23T13:12:01.820", "id": "60790", "last_activity_date": "2019-11-23T13:12:01.820", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "35558", "parent_id": "42218", "post_type": "answer", "score": 0 } ]
42218
null
42225
{ "accepted_answer_id": null, "answer_count": 2, "body": "Win10でCaboCha0.69の実行の際以下のようなエラーが発生して実行ができません\n\n```\n\n morph.cpp(48) [g_mecab_handle != 0] LoadLibrary(\"C:\\Program Files \n (x86)\\MeCab\\etc\\..\\bin\\libmecab.dll\") failed\n \n```\n\nMeCab0.996がインストール済みでutf-8で辞書を構築済み、パスも通してあり実行可能。 \nCaboChaはexeファイルからutf-8の辞書でインストール。 \nCabocha0.53ではインストール後、実行可能ですがutf-8に対応していないので、最新のバージョンで実行したいです。 \n解決方法やアドバイス、確認すべき箇所等ございましたらお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T07:34:17.707", "favorite_count": 0, "id": "42220", "last_activity_date": "2020-06-10T10:45:40.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25245", "post_type": "question", "score": 0, "tags": [ "windows", "windows-10", "自然言語処理", "cabocha" ], "title": "Win10へのCaboChaインストールについて", "view_count": 2363 }
[ { "body": "64bit版のMeCabをインストールしていませんか? \n私も同じ症状が出たのですが、32bit版のMeCabを追加でインストールし解決しました。\n\n32bit版は公式サイトのBinary package for MS-Windowsからダウンロードできます。 \nインストーラーの指示通りにインストールしてください。\n\n(参考) \n公式サイト - <http://taku910.github.io/mecab/>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T09:43:19.600", "id": "42323", "last_activity_date": "2018-03-11T09:43:19.600", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27698", "parent_id": "42220", "post_type": "answer", "score": 1 }, { "body": "公式サイトからBinary package for MS-\nWindowsをアクセスできません。恐れ入りますが、ファイルを[email protected]に送って頂けないでしょうか。\n\nよろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2020-06-10T10:45:40.967", "id": "67505", "last_activity_date": "2020-06-10T10:45:40.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "40577", "parent_id": "42220", "post_type": "answer", "score": -2 } ]
42220
null
42323
{ "accepted_answer_id": "42239", "answer_count": 1, "body": "**最終的にやりたいこと** \n・[リンク先内容](http://coliss.com/articles/build-websites/operation/css/target-\npseudo-class-trick.html)で、「:target\n疑似クラス」のリンクから戻る際、URLに#を付与せず(かつページ再読込せず)画面遷移したい\n\n・[先日jsで処理する方法を質問した](https://ja.stackoverflow.com/questions/41980/%E3%83%9A%E3%83%BC%E3%82%B8%E5%86%85%E3%83%AA%E3%83%B3%E3%82%AF%E3%81%A7%E7%A7%BB%E5%8B%95%E3%81%97%E3%81%9F%E5%BE%8C-%E4%BB%98%E4%B8%8E%E3%81%9B%E3%81%9A%E7%94%BB%E9%9D%A2%E6%9B%B4%E6%96%B0%E3%81%9B%E3%81%9A-%E5%85%83%E3%81%AE%E7%8A%B6%E6%85%8B%E3%81%B8%E9%81%B7%E7%A7%BB%E3%81%95%E3%81%9B%E3%81%9F%E3%81%84)のですが、クリックした際、CSSの「:target\n疑似クラス」処理と「js」処理の両方を行う方法はあるでしょうか?\n\n* * *\n\n**試したこと** \n・下記では「return false」しているため、「:target 疑似クラス」内容が反映されません\n\n```\n\n function move0(){\n history.pushState(null,null,\"./test.html\");\n return false;\n }\n <a href=\"javascript:void(0);\" onclick=\"move0()\"> 1 </a>\n \n```\n\n・下記ではjsの後#で呼び出しているので「:target 疑似クラス」内容は反映されるけれども、URLに#は付与されたままになります\n\n```\n\n function move0(){\n history.pushState(null,null,\"./test.html\");\n }\n <a href=\"#\" onclick=\"move0()\"> 1 </a>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T07:49:35.260", "favorite_count": 0, "id": "42221", "last_activity_date": "2018-03-08T14:09:08.087", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "javascript", "css" ], "title": "「:target 疑似クラス」のリンクから戻る際、URLに#を付与せず画面遷移したい", "view_count": 174 }
[ { "body": "cssのtransition動作イベントを利用したサンプルを書いて見ました。参考になるでしょうか?\n\n```\n\n $(function(){\r\n $(\"#navi\").on(\"oTransitionStart mozTransitionStart webkitTransitionStart transitionstart\", function(){\r\n history.pushState(null, null, \"./test2.html\");\r\n });\r\n });\n```\n\n```\n\n #navi {\r\n position: fixed;\r\n top: 0;\r\n height: 100%;\r\n width: 80%;\r\n max-width: 400px;\r\n }\r\n \r\n #navi:not(:target) {\r\n right: -100%;\r\n transition: right 0.5s;\r\n }\r\n \r\n #navi:target {\r\n right: 0;\r\n transition: right 0.5s;\r\n }\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script>\r\n <a href=\"#navi\">test</a>\r\n \r\n <nav id=\"navi\">\r\n <a href=\"#\" aria-label=\"Close Navigation\"><i class=\"fa fa-times\"></i></a>\r\n \r\n <ul>\r\n <li><a href=\"#\">Link One</a></li>\r\n </ul>\r\n </nav>\n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T14:09:08.087", "id": "42239", "last_activity_date": "2018-03-08T14:09:08.087", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22793", "parent_id": "42221", "post_type": "answer", "score": 1 } ]
42221
42239
42239
{ "accepted_answer_id": null, "answer_count": 1, "body": "初めまして、ほぼ初心者です。\n\nナビゲーション・ドロワーによりメニューを開いて、例えばnav_cameraをクリックして別のActivityに切り替える方法はあるのでしょうか?\n\nbuttonのonClickにintentを使ったメソッドを登録して画面遷移する方法はある程度理解しているつもりなのですが、res.menu(?)のレイアウトファイルにbuttonが無いのでどうしたらいいかよくわかりません。\n\nアドバイスお願いします(><)\n\n追記:現状の具体的なコードは以下のようになります。 \n(ナビゲーション・ドロワーのテンプレートを作成し、その後でMainActivity2を作りました。)\n\nMainActiityは、\n\n```\n\n package com.wixsite.tobirayt.myapplication;\n \n import android.os.Bundle;\n import android.support.design.widget.FloatingActionButton;\n import android.support.design.widget.Snackbar;\n import android.view.View;\n import android.support.design.widget.NavigationView;\n import android.support.v4.view.GravityCompat;\n import android.support.v4.widget.DrawerLayout;\n import android.support.v7.app.ActionBarDrawerToggle;\n import android.support.v7.app.AppCompatActivity;\n import android.support.v7.widget.Toolbar;\n import android.view.Menu;\n import android.view.MenuItem;\n \n public class MainActivity extends AppCompatActivity\n implements NavigationView.OnNavigationItemSelectedListener {\n \n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n \n FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);\n fab.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View view) {\n Snackbar.make(view, \"Replace with your own action\", Snackbar.LENGTH_LONG)\n .setAction(\"Action\", null).show();\n }\n });\n \n DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);\n ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(\n this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);\n drawer.addDrawerListener(toggle);\n toggle.syncState();\n \n NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);\n navigationView.setNavigationItemSelectedListener(this);\n }\n \n @Override\n public void onBackPressed() {\n DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);\n if (drawer.isDrawerOpen(GravityCompat.START)) {\n drawer.closeDrawer(GravityCompat.START);\n } else {\n super.onBackPressed();\n }\n }\n \n @Override\n public boolean onCreateOptionsMenu(Menu menu) {\n // Inflate the menu; this adds items to the action bar if it is present.\n getMenuInflater().inflate(R.menu.main, menu);\n return true;\n }\n \n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n // Handle action bar item clicks here. The action bar will\n // automatically handle clicks on the Home/Up button, so long\n // as you specify a parent activity in AndroidManifest.xml.\n int id = item.getItemId();\n \n //noinspection SimplifiableIfStatement\n if (id == R.id.action_settings) {\n return true;\n }\n \n return super.onOptionsItemSelected(item);\n }\n \n @SuppressWarnings(\"StatementWithEmptyBody\")\n @Override\n public boolean onNavigationItemSelected(MenuItem item) {\n // Handle navigation view item clicks here.\n int id = item.getItemId();\n \n if (id == R.id.nav_camera) {\n // Handle the camera action\n } else if (id == R.id.nav_gallery) {\n \n } else if (id == R.id.nav_slideshow) {\n \n } else if (id == R.id.nav_manage) {\n \n } else if (id == R.id.nav_share) {\n \n } else if (id == R.id.nav_send) {\n \n }\n \n DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);\n drawer.closeDrawer(GravityCompat.START);\n return true;\n }\n }\n \n```\n\nMainActivity2は\n\n```\n\n package com.wixsite.tobirayt.myapplication;\n \n import android.support.v7.app.AppCompatActivity;\n import android.os.Bundle;\n \n public class Main2Activity extends AppCompatActivity {\n \n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main2);\n }\n }\n \n```\n\nです。レイアウトなどはまだテンプレートのままなのですが、一部重要だろうと思われる場所を記載すると\n\nres.layout.activity_main_xmlは、\n\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <android.support.v4.widget.DrawerLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n xmlns:tools=\"http://schemas.android.com/tools\"\n android:id=\"@+id/drawer_layout\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:fitsSystemWindows=\"true\"\n tools:openDrawer=\"start\">\n \n <include\n layout=\"@layout/app_bar_main\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\" />\n \n <android.support.design.widget.NavigationView\n android:id=\"@+id/nav_view\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"match_parent\"\n android:layout_gravity=\"start\"\n android:fitsSystemWindows=\"true\"\n app:headerLayout=\"@layout/nav_header_main\"\n app:menu=\"@menu/activity_main_drawer\" />\n \n </android.support.v4.widget.DrawerLayout>\n \n```\n\nとなっており、\n\nres.layout.menu.activity_main_drawer.xmlは\n\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/tools\"\n tools:showIn=\"navigation_view\">\n \n <group android:checkableBehavior=\"single\">\n <item\n android:id=\"@+id/nav_camera\"\n android:icon=\"@drawable/ic_menu_camera\"\n android:title=\"Import\" />\n <item\n android:id=\"@+id/nav_gallery\"\n android:icon=\"@drawable/ic_menu_gallery\"\n android:title=\"Gallery\" />\n <item\n android:id=\"@+id/nav_slideshow\"\n android:icon=\"@drawable/ic_menu_slideshow\"\n android:title=\"Slideshow\" />\n <item\n android:id=\"@+id/nav_manage\"\n android:icon=\"@drawable/ic_menu_manage\"\n android:title=\"Tools\" />\n </group>\n \n <item android:title=\"Communicate\">\n <menu>\n <item\n android:id=\"@+id/nav_share\"\n android:icon=\"@drawable/ic_menu_share\"\n android:title=\"Share\" />\n <item\n android:id=\"@+id/nav_send\"\n android:icon=\"@drawable/ic_menu_send\"\n android:title=\"Send\" />\n </menu>\n </item>\n \n </menu>\n \n```\n\nとなっており、まだナビゲーション・ドロワーのテンプレートから何も編集していない状態(Activity2を追加しただけ)です。 \n今、やりたいことは例えばitemのnav_cameraをクリックするとActiity2の画面へ遷移したいのです。 \nどこまでコードを書けばよいのかわからなかったので取りあえずこのあたりだけ書きました。もっと書いた方がいいのであれば書きますので、言ってくださると助かります。\n\nーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー \n↑ごめんなさい。上の追記解決したのですが、今私が考えているプログラムには適応できませんでした。正確なプログラムは次の通りです。\n\n二つのActivityがあり、MainActivityとEnglishShortSentenceというActivityです。先に起動するのはMainActivityです。EnglishShortSentenceの方はスワイプ機能とナビゲーションドロワーを同時に実装しています。MainActivityのボタンからはEnglishShortSentenceにいけるのですが、EnglishShortSentenceの方のナビゲーションドロワー内のitemをクリックしてもMainActivityにいけづ困っております。精確に質問しなかったことを後悔しております。ごめんなさい。\n\nMainActivity:\n\n```\n\n package com.wixsite.tobirayt.memorizationapplication;\n \n import android.content.Intent;\n import android.os.Bundle;\n import android.support.v7.app.AppCompatActivity;\n import android.view.View;\n \n public class MainActivity extends AppCompatActivity {\n \n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n }\n \n public void onButtonClick(View v){\n Intent intent =new Intent(this,EnglishShortSentence.class);\n startActivity(intent);\n \n }\n }\n \n```\n\nもう一つのActivityは\n\nEnglishShortSentence:\n\n```\n\n package com.wixsite.tobirayt.memorizationapplication;\n \n import android.content.Context;\n import android.content.Intent;\n import android.os.Bundle;\n import android.support.design.widget.FloatingActionButton;\n import android.support.design.widget.NavigationView;\n import android.support.design.widget.Snackbar;\n import android.support.v4.view.GravityCompat;\n import android.support.v4.view.PagerAdapter;\n import android.support.v4.view.ViewPager;\n import android.support.v4.widget.DrawerLayout;\n import android.support.v7.app.ActionBarDrawerToggle;\n import android.support.v7.app.AppCompatActivity;\n import android.support.v7.widget.Toolbar;\n import android.view.LayoutInflater;\n import android.view.Menu;\n import android.view.MenuItem;\n import android.view.View;\n import android.view.ViewGroup;\n \n public class EnglishShortSentence extends AppCompatActivity\n implements NavigationView.OnNavigationItemSelectedListener {\n \n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_english_short_sentence);\n Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);\n setSupportActionBar(toolbar);\n \n FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);\n fab.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View view) {\n Snackbar.make(view, \"Replace with your own action\", Snackbar.LENGTH_LONG)\n .setAction(\"Action\", null).show();\n }\n });\n \n DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);\n ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(\n this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);\n drawer.addDrawerListener(toggle);\n toggle.syncState();\n \n NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);\n navigationView.setNavigationItemSelectedListener(this);\n \n ViewPager mViewPager = (ViewPager)findViewById(R.id.viewpager);\n PagerAdapter mPagerAdapter = new MyPagerAdapter();\n mViewPager.setAdapter(mPagerAdapter);\n }\n \n @Override\n public void onBackPressed() {\n DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);\n if (drawer.isDrawerOpen(GravityCompat.START)) {\n drawer.closeDrawer(GravityCompat.START);\n } else {\n super.onBackPressed();\n }\n }\n \n @Override\n public boolean onCreateOptionsMenu(Menu menu) {\n // Inflate the menu; this adds items to the action bar if it is present.\n getMenuInflater().inflate(R.menu.english_short_sentence, menu);\n return true;\n }\n \n @Override\n public boolean onOptionsItemSelected(MenuItem item) {\n // Handle action bar item clicks here. The action bar will\n // automatically handle clicks on the Home/Up button, so long\n // as you specify a parent activity in AndroidManifest.xml.\n int id = item.getItemId();\n \n //noinspection SimplifiableIfStatement\n if (id == R.id.action_settings) {\n return true;\n }\n \n return super.onOptionsItemSelected(item);\n }\n \n @SuppressWarnings(\"StatementWithEmptyBody\")\n @Override\n public boolean onNavigationItemSelected(MenuItem item) {\n // Handle navigation view item clicks here.\n int id = item.getItemId();\n \n if (id == R.id.nav_camera) {\n //「ここがうまく行きません。」\n \n Intent intentt=new Intent(this, MainActivity.class);\n startActivity(intentt);\n \n // Handle the camera action\n } else if (id == R.id.nav_gallery) {\n \n } else if (id == R.id.nav_slideshow) {\n \n } else if (id == R.id.nav_manage) {\n \n } else if (id == R.id.nav_share) {\n \n } else if (id == R.id.nav_send) {\n \n }\n \n DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);\n drawer.closeDrawer(GravityCompat.START);\n return true;\n }\n \n public void onButtonClick(){\n Intent intent=new Intent(this,MainActivity.class);\n startActivity(intent);\n }\n \n \n private class MyPagerAdapter extends PagerAdapter {\n @Override\n public Object instantiateItem(ViewGroup container, int position) {\n // レイアウトファイル名を配列で指定します。\n int[] pages = {R.layout.english_short_sentence_configuration,\n R.layout.english_short_sentence_problem,\n R.layout.english_short_sentence_achievement};\n \n LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n \n View layout;\n layout = inflater.inflate(pages[position], null);\n ((ViewPager) container).addView(layout);\n return layout;\n }\n \n @Override\n public void destroyItem(ViewGroup container, int position, Object object) {\n ((ViewPager) container).removeView((View) object);\n }\n \n @Override\n public int getCount() {\n // ページ数を返します。\n return 3;\n }\n \n @Override\n public boolean isViewFromObject(View view, Object object) {\n return view.equals(object);\n }\n }\n }\n \n```\n\nです。強引にスワイプ機能とナビゲーション・ドロワーの機能をつけてみました。nav_cameraをクリックするとMainActivityに戻るプログラムを、入れているつもりなのですがこれが機能しません。\n\nmanifestsは\n\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"com.wixsite.tobirayt.memorizationapplication\">\n \n <application\n android:allowBackup=\"true\"\n android:icon=\"@mipmap/ic_launcher\"\n android:label=\"@string/app_name\"\n android:roundIcon=\"@mipmap/ic_launcher_round\"\n android:supportsRtl=\"true\"\n android:theme=\"@style/AppTheme\">\n <activity android:name=\".MainActivity\">\n <intent-filter>\n <action android:name=\"android.intent.action.MAIN\" />\n \n <category android:name=\"android.intent.category.LAUNCHER\" />\n </intent-filter>\n </activity>\n <activity\n android:name=\".EnglishShortSentence\"\n android:label=\"@string/title_activity_english_short_sentence\"\n android:theme=\"@style/AppTheme.NoActionBar\"></activity>\n </application>\n \n </manifest>\n \n```\n\nとなっております。レイアウトファイルは、結構あるので省略します。必要ならばもちろん、書かせていただきます。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T11:01:20.930", "favorite_count": 0, "id": "42231", "last_activity_date": "2022-05-11T02:08:35.820", "last_edit_date": "2021-03-07T04:46:21.290", "last_editor_user_id": "3060", "owner_user_id": "27664", "post_type": "question", "score": 0, "tags": [ "java", "android", "android-studio" ], "title": "ナビゲーション・ドロワーのメニューのitemをクリックして画面遷移(Activityを移る)方法", "view_count": 1702 }
[ { "body": "なんとか解決することができました。\n\n原因は activity.main.xml においてコードを書く順序がおかしかったようです。先に NavigationView を読み込むのではなく、まず\nViewPager を読み込ませるのが正解のようです。\n\nまさかコードの xml のコードの書く順序が大切だとは知りませんでした。\n\n* * *\n\n_この投稿は[@user27664\nさんのコメント](https://ja.stackoverflow.com/questions/42231/%e3%83%8a%e3%83%93%e3%82%b2%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3-%e3%83%89%e3%83%ad%e3%83%af%e3%83%bc%e3%81%ae%e3%83%a1%e3%83%8b%e3%83%a5%e3%83%bc%e3%81%aeitem%e3%82%92%e3%82%af%e3%83%aa%e3%83%83%e3%82%af%e3%81%97%e3%81%a6%e7%94%bb%e9%9d%a2%e9%81%b7%e7%a7%bb-\nactivity%e3%82%92%e7%a7%bb%e3%82%8b-%e6%96%b9%e6%b3%95#comment43647_42231)\nの内容を元に コミュニティwiki として投稿しました。_", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2021-03-07T04:53:27.150", "id": "74471", "last_activity_date": "2021-03-07T04:53:27.150", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "42231", "post_type": "answer", "score": 1 } ]
42231
null
74471
{ "accepted_answer_id": null, "answer_count": 1, "body": "Angularにて下記のようなHTMLとコンポーネントを用意しています。 \nIconInfoクラスではiconとicon名を持っています。\n\n画面からボタンを押されると、addIconInfoが呼ばれるようになっており、 \nボタンが押されるたびに画面にiconが追加されています。\n\nそこでなのですが、iconが追加される際にアイコンが表示される領域の \n一番下から徐々に上に上がっていくように(上にたまっていくように) \nしたいのですが、何か方法はありますでしょうか? \nngForだけでは難しいでしょうか?\n\n◆HTML\n\n```\n\n <div class=\"page\">\n <section class=\"card\">\n   <ng-container *ngFor=\"let icon of icons\">\n    <div class=\"media\">\n    <img src={{icon.img}}>\n    </div>\n   </ng-container>\n </section>\n </div>\n \n```\n\n◆コンポーネント.ts\n\n```\n\n addIconInfo(icon: string, name: string) {\n this.icons.push(new IconInfo(icon, name));\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T13:58:33.487", "favorite_count": 0, "id": "42238", "last_activity_date": "2018-03-09T01:32:40.617", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12842", "post_type": "question", "score": 2, "tags": [ "angular4" ], "title": "Angularで画面に追加したアイコンをスムーズに動かしたい", "view_count": 93 }
[ { "body": "`this.icons`がどういったものかわかりませんが、単純に`Array`であるならば`push`による末尾への追加ではなく、`unshift`で先頭に追加していくことで期待の動作になると思います。\n\n```\n\n this.icons.unshift(new IconInfo(icon, name));\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T01:32:40.617", "id": "42245", "last_activity_date": "2018-03-09T01:32:40.617", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "42238", "post_type": "answer", "score": 0 } ]
42238
null
42245
{ "accepted_answer_id": null, "answer_count": 2, "body": "下記リンク先は、ある投資用のアプリケーションの通信内容のバイナリのdumpです。\n\nここから意味のあるデータ(日経平均の値など)をparseしたいのですがどうすればいいのでしょうか? \nこのアプリケーションではリアルタイムで価格などの変動する様子が表示されています。\n\nおそらく、何かのフォーマット(msgpackやjsonbなど)にして送られていると思うのですが、何の形式なのか判別できません。\n\n何の形式であるかわかればparseできるのですが・・・\n\nfileコマンドも試してみましたがうまくいきませんでした。\n\n<https://gist.github.com/anonymous/81b083fce661838032de25ca774178c7>\n\n### 追記:\n\nこのdumpは日経平均先物データの表示をしているときのデータです。 \nこのアプリケーションではデータの種類は株価、先物、FX、海外の市場の指標などいろいろと取得することができます。 \nただ、株価から先物などに表示を切り替える際に、そこそこ時間がかかっているのでもしかしたら現在表示されているものだけが来ているのかもしれません。\n\nアプリから見える値ではありませんが、`0000004F`から`0000005F`にかけてasciiであらわすと \n`20180307.210053`となっており、このデータが送られた時間のようです。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-08T14:51:10.960", "favorite_count": 0, "id": "42241", "last_activity_date": "2018-03-14T13:54:41.697", "last_edit_date": "2018-03-14T13:54:41.697", "last_editor_user_id": "19110", "owner_user_id": "5246", "post_type": "question", "score": 3, "tags": [ "tcp", "binary" ], "title": "バイナリからデータをフォーマットを推測する", "view_count": 349 }
[ { "body": "推測するにはサンプルデータや手がかりとなる情報が少なすぎると思います。 \n\"投資用\"とは株価(国内のみor国外含め)?指数のみor個別銘柄?為替?仮想通貨?etc\n\n * データを複数回(時間をおいて)取得して「変化がある箇所」「変化のない箇所」などからアタリを付ける。\n * アプリから正規の手段で見える値がダンプに表れないか調べてみる。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T06:46:00.490", "id": "42257", "last_activity_date": "2018-03-09T06:46:00.490", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "42241", "post_type": "answer", "score": 5 }, { "body": "ほとんどの部分は0x11が区切りになっているテキストです。何らかの汎用フォーマットかもしれませんが、キーとなりそうな値が見えないので、パーサを通したところでどの部分が何の値かは結局自分で想像するしかありません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T01:43:02.160", "id": "42310", "last_activity_date": "2018-03-11T01:43:02.160", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "42241", "post_type": "answer", "score": 1 } ]
42241
null
42257
{ "accepted_answer_id": null, "answer_count": 4, "body": "bashを使って、1列目が同じ行の2列目を1つの行にまとめたいときどうすればよいですか? \n図で描くと\n\n```\n\n a 1\n a 2\n a 3\n b 4\n c 5\n c 6\n d 7\n d 8\n e 9\n \n```\n\nというテキストを\n\n```\n\n a 1 2 3\n b 4\n c 5 6\n d 7 8\n e 9\n \n```\n\nというふうに処理をしたいのです。お願いします。\n\n追記 \nテキストはすでにソートされたものです。結果はソートされていても、されていなくてもどちらで構いません。 \n使っているbashのバージョンはversion 3.2.57です。\n\n皆様の回答やコメントを受けて追記させていただきました。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T03:04:59.927", "favorite_count": 0, "id": "42249", "last_activity_date": "2018-03-09T07:45:03.087", "last_edit_date": "2018-03-09T07:45:03.087", "last_editor_user_id": "3054", "owner_user_id": "27669", "post_type": "question", "score": 1, "tags": [ "bash", "shellscript" ], "title": "bashでのテキスト処理で1列目が同じ行の2列目を1つの行にまとめたい", "view_count": 287 }
[ { "body": "質問通りbashで実装するのであれば対象のテキストが`a.txt`に格納されているとして\n\n```\n\n unset -v HASH\n declare -A HASH\n while read k v; do HASH[$k]=\"${HASH[$k]} $v\"; done < a.txt\n for k in ${!HASH[*]}; do echo $k ${HASH[$k]}; done\n \n```\n\nでしょうか。Perl等、他のツールを使うのであればまた違ってくるとは思いますが。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T03:26:23.253", "id": "42251", "last_activity_date": "2018-03-09T03:26:23.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "42249", "post_type": "answer", "score": 2 }, { "body": "入力が Field1 でソートされているとして、POSIX 互換 sh でごりおしするとこんな感じです。\n\n```\n\n input() {\n cat <<EOF\n a 1\n a 2\n a 3\n b 4\n c 5\n c 6\n d 7\n d 8\n e 9\n EOF\n }\n \n efficient_sh() (\n prev=\n while read -r k v\n do\n if [ \"$prev\" = \"\" ]; then\n printf '%s %s' $k \"$v\"\n prev=$k\n elif [ \"$prev\" = $k ]; then\n printf ' %s' \"$v\"\n else\n printf '\\n%s %s' $k \"$v\"\n prev=$k\n fi\n done\n echo\n )\n \n input | efficient_sh\n # a 1 2 3\n # b 4\n # c 5 6\n # d 7 8\n # e 9\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T05:48:50.700", "id": "42254", "last_activity_date": "2018-03-09T05:48:50.700", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "42249", "post_type": "answer", "score": 1 }, { "body": "[Yuki Inoue](https://ja.stackoverflow.com/users/754/yuki-inoue)さんの回答の亜種です。 \nソート済みのデータが同ディレクトリにdata.txtとして保存されていることを前提としています。\n\n```\n\n #!/bin/sh\n set -Cu\n #set -vx\n \n while read -r key val; do\n if test \"${current:-}\" != \"$key\"; then\n current=\"$key\"\n printf \"\\n%s\" \"$key\"\n fi\n printf \" %s\" \"$val\"\n done <data.txt\n echo\n \n exit 0\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T06:50:06.317", "id": "42258", "last_activity_date": "2018-03-09T07:11:39.957", "last_edit_date": "2018-03-09T07:11:39.957", "last_editor_user_id": "25936", "owner_user_id": "25936", "parent_id": "42249", "post_type": "answer", "score": 0 }, { "body": "外部コマンドを使う例です。Bashの拡張機能は使用していません。\n\n### awkの例\n\nAwkは標準的なコマンドです。基本的にインストールは不要です。\n\n```\n\n #!/bin/sh\n awk '\n BEGIN {\n ORS = \"\"\n pre = \"\"\n }\n {\n if ($1 != pre) {\n if (pre != \"\") {\n print \"\\n\"\n }\n print $1 \" \" $2\n pre = $1\n } else {\n print \" \" $2\n }\n }\n END { print \"\\n\" }\n ' in.txt\n \n```\n\n### datamashの例\n\n```\n\n #!/bin/sh\n datamash --field-separator=' ' --group=1 collapse 2 <in.txt \\\n |tr , ' '\n \n```\n\n[GNU\ndatamash](https://www.gnu.org/software/datamash/)は標準的なコマンドではありません。多くの場合、インストールが必要です。 \n上の例では、データがカンマ(`,`)を含まない事を前提としています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T07:40:30.933", "id": "42263", "last_activity_date": "2018-03-09T07:40:30.933", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "42249", "post_type": "answer", "score": 1 } ]
42249
null
42251
{ "accepted_answer_id": null, "answer_count": 1, "body": "<http://gihyo.jp/dev/serial/01/vuejs/0002> を参考にしてVue.jsを勉強しています。 \nその中で、\n\n```\n\n <div id=\"example\">\n <li v-for=\"item in items\" v-bind:key=\"item.name\">\n <p>{{ item.name }} は {{ item.price }}円</p>\n </li>\n </div>\n \n```\n\nとhtmlを書いてある時と、\n\n```\n\n <div id=\"example\">\n <li v-for=\"item in items\">\n <p>{{ item.name }} は {{ item.price }}円</p>\n </li>\n </div>\n \n```\n\nとhtmlを書いてある時の2種類があって、どちらもjsは同じコードでv-bind:key\nを使う時と使わない時の違いがわかりません。v-bind:keyがある時とない時ではどう違うのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T03:21:43.873", "favorite_count": 0, "id": "42250", "last_activity_date": "2018-08-15T12:00:44.200", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27670", "post_type": "question", "score": 0, "tags": [ "html", "vue.js" ], "title": "v-bind:key を使う時と使わない時の違い", "view_count": 9174 }
[ { "body": "まず、`key`を指定しないと警告が出ますし、なるべく指定することが推奨されています。\n\n公式ガイド \n[List Rendering - key (英語)](https://v2.vuejs.org/v2/guide/list.html#key),\n[(日本語)](https://jp.vuejs.org/v2/guide/list.html#key)\n\n> Vue が各ノードの識別情報を追跡できるヒントを与えるために、また、先ほど説明したような既存の要素の再利用と並び替えができるように、一意な key\n> 属性を全てのアイテムに与える必要があります。\n\n要はキーを指定すれば、リストの要素の順番が入れ替わったりしたときに、変更前と変更後でキーが同じ要素は同じものだとみなされて、適宜DOM要素の移動が起こります。\n\n逆に指定しなければ、DOM要素の移動は起こらず、その場で各要素を変更します。しかしこれは、List\nRenderingされる要素がフォーム要素などの「状態」を持つ(statefulな)要素である場合、意図しない動作になるのでやってはいけません。公式ガイドにもそうかいてあります。\n\n> この標準のモードは効率がいいです。しかしこれは、描画されたリストが子コンポーネントの状態や、一時的な DOM\n> の状態に依存していないときにだけ適しています (例: フォームのインプットの値)。\n\n * キーを指定しない場合 \n[DEMO1(JSFiddle)](https://jsfiddle.net/a7kgm989/7/) \n上で述べたやってはいけない例です。「シフト」ボタンを押すとリストが左にローテート(シフト)します。 \n適当にテキストボックスに入力してからボタンを押すと、テキストボックスが移動していないことが分かります。\n\n * キーを指定した場合 \n[DEMO2(JSFiddle)](https://jsfiddle.net/b20919t1/1/) \n今度はシフトするとテキストボックスも移動します。シフトの際、Vueはキーを元にしてシフト後の各要素がシフト前のどの要素と対応しているのかが分かるため、それに応じてDOM要素を移動します。\n\n* * *\n\n# 補足\n\n質問文の例では、`v-for`で表示されるDOM要素は状態を持たない要素なので、キーを指定してもしなくても外から見た動作に違いはありません(ただし、どのように変更が反映されるかという内部的な動作は変わります)。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T08:20:23.127", "id": "42266", "last_activity_date": "2018-03-09T08:26:42.547", "last_edit_date": "2022-09-27T22:35:34.400", "last_editor_user_id": "-1", "owner_user_id": "20206", "parent_id": "42250", "post_type": "answer", "score": 1 } ]
42250
null
42266
{ "accepted_answer_id": null, "answer_count": 1, "body": "nginxをプロキシとして使う際の設定で困っています。 \n現状1の構成のものを2のようにしたい場合、どのようにすればよいのでしょうか?\n\n 1. 今現在の構成 \nクライアント -> nginx -> proxy -> インターネット\n\nnginx.confからincludeしてる設定ファイル\n\n```\n\n upstream proxy_server {\n server 54.248.71.136:3009;\n }\n \n server {\n listen 80;\n \n location / {\n proxy_pass http://proxy_server;\n proxy_set_header x_custom_header_hoge \"hogehoge\";\n }\n }\n \n```\n\n2.こうしたい \nクライアント -> nginx -> インターネット\n\nこの場合、nginxの設定をどのように変えればよいのでしょうか?\n\nnginxはヘッダーを追加するためのプロキシという位置づけで、クライアントで明示的に指定予定です。 \n単純にヘッダーを追加する処理だけさせて、本来のリクエスト先にリクエストさせたいのですが、 \nproxy_passでプロキシ先を指定しないと行けない感じになっていて、どうしたらよいのかなと。 \n(リバースプロキシとして使う予定はないです)\n\nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T04:44:48.387", "favorite_count": 0, "id": "42252", "last_activity_date": "2018-03-10T10:07:33.460", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25065", "post_type": "question", "score": 1, "tags": [ "nginx" ], "title": "nginxをプロキシとして使う方法", "view_count": 3114 }
[ { "body": "```\n\n resolver 8.8.8.8;\n \n server {\n listen 80;\n \n location / {\n proxy_pass $scheme://$http_host$request_uri;\n proxy_set_header x_custom_header_hoge \"hogehoge\";\n }\n }\n \n```\n\n`resolver 8.8.8.8` の部分はお使いの環境に合わせてDNSサーバーのIPを設定してください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T10:07:33.460", "id": "42295", "last_activity_date": "2018-03-10T10:07:33.460", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "42252", "post_type": "answer", "score": 1 } ]
42252
null
42295
{ "accepted_answer_id": "42262", "answer_count": 3, "body": "初歩的な質問かと思いますが、\n\n```\n\n v = ['abcd', 'efgh', 'ijkl', 'mnop']\n \n aeim\n \n```\n\n上記リストvの頭文字のみをjoinしたいと考えています。 \nリストの要素をスライスして0文字目を取得すればよいとは思うのですが、どう処理していいのか悩んでいます。 \nなにか良い方法はありますでしょうか。 \nよろしくお願いします。 \npythonのバージョンは2.7.12を使用しています。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T06:42:57.673", "favorite_count": 0, "id": "42256", "last_activity_date": "2018-03-09T10:00:45.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22885", "post_type": "question", "score": 3, "tags": [ "python" ], "title": "リスト内の頭文字を結合したい", "view_count": 916 }
[ { "body": "一度 Python の入門書などを読んだ方がよいかと思われます。\n\nその1\n\n```\n\n v = ['abcd', 'efgh', 'ijkl', 'mnop']\n heads = \"\"\n for s in v:\n # print(\"s => \" + s)\n head = s[0]\n # print(\"head => \" + head)\n heads += head\n \n print(heads)\n \n```\n\nその2\n\n```\n\n v = ['abcd', 'efgh', 'ijkl', 'mnop']\n heads = \"\".join([ s[0] for s in v ])\n print(heads)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T07:31:21.173", "id": "42261", "last_activity_date": "2018-03-09T07:31:21.173", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27410", "parent_id": "42256", "post_type": "answer", "score": 0 }, { "body": "ジェネレータ式を使った例です。\n\n```\n\n v = ['abcd', 'efgh', 'ijkl', 'mnop']\n result = \"\".join(i[0] for i in v)\n # result は 'aeim'\n \n```\n\n参考:\n\n * [ジェネレータ式とリスト内包表記](https://docs.python.jp/3.6/howto/functional.html?highlight=comprehensions#generator-expressions-and-list-comprehensions)\n * [リストの内包表記](https://docs.python.jp/3/tutorial/datastructures.html#list-comprehensions)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T07:31:45.277", "id": "42262", "last_activity_date": "2018-03-09T07:31:45.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "42256", "post_type": "answer", "score": 5 }, { "body": "```\n\n s = \"\"\n v = ['abcd', 'efgh', 'ijkl', 'mnop']\n for line in v:\n s += v[0]\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T10:00:45.433", "id": "42273", "last_activity_date": "2018-03-09T10:00:45.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26311", "parent_id": "42256", "post_type": "answer", "score": 0 } ]
42256
42262
42262
{ "accepted_answer_id": "42309", "answer_count": 3, "body": "rubyの正規表現を扱う際の挙動についてよくわからないことがあります。 \nHTMLのパースをしているのですが、\n\n```\n\n Regexp.new(\"スタックオーバーフロー\")\n => /スタックオーバーフロー/\n Regexp.new(\"<h1>スタックオーバーフロー</h1>\")\n => /<h1>\\u30B9\\u30BF\\u30C3\\u30AF\\u30AA\\u30FC\\u30D0\\u30FC\\u30D5\\u30ED\\u30FC<\\/h1>/\n \n```\n\nというような、上はUTF-8そのままで正規表現化できるのですが下の場合はunicodeがそのまま出てきてしまうという動きになっており、なぜこのようになるのかわかりません。 \n理想としては\n\n```\n\n => /<h1>スタックオーバーフロー<\\/h1>/\n \n```\n\nという正規表現がほしいのですが、どのようにすればよいでしょうか? \nあまり文字コードや文字セットなどに詳しくないので見当ハズレなことを聞いているのかもしれませんが、よろしくお願いします。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T07:29:11.753", "favorite_count": 0, "id": "42260", "last_activity_date": "2018-03-11T09:23:12.423", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27675", "post_type": "question", "score": 2, "tags": [ "ruby", "正規表現" ], "title": "rubyの正規表現を扱う際の文字セットについて", "view_count": 170 }
[ { "body": "### 何がおきているか\n\n`ri Regexp#to_s` を見ると以下のように表示されます。\n\n```\n\n = Regexp#to_s\n \n (from ruby core)\n ------------------------------------------------------------------------------\n rxp.to_s -> str\n \n ------------------------------------------------------------------------------\n \n Returns a string containing the regular expression and its options (using the\n (?opts:source) notation. This string can be fed back in to Regexp::new to a\n regular expression with the same semantics as the original. (However,\n Regexp#== may not return true when comparing the two, as the source of the\n regular expression itself may differ, as the example shows). Regexp#inspect\n produces a generally more readable version of rxp.\n \n r1 = /ab+c/ix #=> /ab+c/ix\n s1 = r1.to_s #=> \"(?ix-m:ab+c)\"\n r2 = Regexp.new(s1) #=> /(?ix-m:ab+c)/\n r1 == r2 #=> false\n r1.source #=> \"ab+c\"\n r2.source #=> \"(?ix-m:ab+c)\"\n \n```\n\n特に、 `Regexp#== may not return true when comparing the two` が重要だと考えていて、`to_s`\nメソッドによって返されるのは、 `Regexp.new`\nに引数として与えた時に、同じ文字列セットに一致するような正規表現を返すような文字列である、以外に期待してはいけないと考えられます。\n\n### 今回ほしかったもの\n\nおそらく、今回欲しいのは `Regexp#source` だと思います。\n\n```\n\n regex = Regexp.new(\"スタックオーバーフロー\")\n puts regex.source\n # => スタックオーバーフロー\n \n regex = Regexp.new(\"<h1>スタックオーバーフロー</h1>\")\n puts regex.source\n # => <h1>スタックオーバーフロー</h1>\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T07:45:22.590", "id": "42291", "last_activity_date": "2018-03-10T07:45:22.590", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "42260", "post_type": "answer", "score": 1 }, { "body": ">\n```\n\n> Regexp.new(\"<h1>スタックオーバーフロー</h1>\")\n> =>\n> /<h1>\\u30B9\\u30BF\\u30C3\\u30AF\\u30AA\\u30FC\\u30D0\\u30FC\\u30D5\\u30ED\\u30FC<\\/h1>/\n> \n```\n\nこれはirbやpryで上記コードを実行した結果か`p`の類いで表示した結果だと思います。表現上\\uxxxx形式になっているだけで、渡した文字列に対する正しい正規表現オブジェクトが生成されてます。\n\n```\n\n Regexp.new(\"<h1>スタックオーバーフロー</h1>\") == /<h1>スタックオーバーフロー<\\/h1>/\n => true\n \n```\n\nこうなってしまう理由はよくわかりませんが、`/`を`/regexp/`形式に含めるにはエスケープが必要なので、巻き添えで非ASCII文字もエスケープされてるんではないかなと想像します。\n\nなおHTMLを正規表現でパースするのはたいていの場合よくない方法です。Nokogiriという定番のHTML/XMLパーサライブラリがあるので、そちらを使うことも検討した方がよいとおもいます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T01:18:43.527", "id": "42309", "last_activity_date": "2018-03-11T01:18:43.527", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "42260", "post_type": "answer", "score": 1 }, { "body": "irbは式の評価結果に対して`inspect`メソッドを呼び出して得た文字列を出力します。つまり、そのような表示になっているのは[`Regexp#inspect`](https://docs.ruby-\nlang.org/ja/latest/method/Regexp/i/inspect.html)の動作です。 \n※\nirbのコマンドオプションや`conf.inspect_mode`に代入することで`to_s`を使う等に変更できます。詳しくは[irbのドキュメント](https://docs.ruby-\nlang.org/ja/latest/library/irb.html)を確認して下さい。 \n※ `p`も同様に`inspect`を使用しますので、`p`を使った場合も同じになります。\n\nどうしてそうなるかはソースコードを見る必要があります。`Regexp#inspect`の通常処理で文字列の生成を行っているのは[rb_reg_expr_str()](https://github.com/ruby/ruby/blob/ruby_2_5/re.c#L357)になります。この関数では、\"/\"が含まれていない場合はそのまま出力します。しかし、\"/\"が含まれている場合は、前後を\"/\"で囲む関係上\"\\/\"とエスケープする必要があるため、分岐した別処理になります。問題はこの分岐した処理で、\"/\"以外の通常の文字は[rb_str_buf_cat_escaped_char](https://github.com/ruby/ruby/blob/ruby_2_5/string.c#L5721)で処理を行うと言うことです。rb_str_buf_cat_escaped_charではASCII文字以外は全てエスケープ(\\uや\\xを使う)するため、日本語の部分はエスケープされる事になります。 \n※ 実際はさらに細かい処理をしています。上はだいたいの動作概要ですので、ご注意下さい。\n\n注意して欲しいのは、Regexpの中に保存されている正規表現の文字列(`Regexp#source`で確認できる)では\"/\"が\"\\/\"にエスケープされていないと言うことです。このエスケープは`/.../`というリテラル表記のみで必要なものであるため、内部処理としてはエスケープしておく必要がありません。しかし、`Regexp#inspect`ではわかりやすいリテラル表記になるようにするため、出力時のエスケープ処理が必要になっており、その副作用で、ASCII以外は全てエスケープするとなったということです。\n\n\"/\"をエスケープするには、一旦文字列をバラバラに解釈していかなくてはいけないため、間違った分割をしないようにこのような処理になっているのかも知れません。ただ、エスケープせずに出す方法がないわけではないでしょうから、[Ruby\nIssue](https://bugs.ruby-lang.org/)に投げるなり、自分でパッチを作って送りつけるなりすると直してくれるかも知れません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T09:23:12.423", "id": "42321", "last_activity_date": "2018-03-11T09:23:12.423", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7347", "parent_id": "42260", "post_type": "answer", "score": 3 } ]
42260
42309
42321
{ "accepted_answer_id": "42271", "answer_count": 2, "body": "python、jsonともにあまり使ったことがないので基本的な理解が抜けている可能性が高いのですが。。。\n\ntest.json\n\n```\n\n {\n \"book1\":{\n \"title\":\"Python Beginners\",\n \"year\": 2005 ,\n \"page\": 399 \n }\n }\n \n```\n\ntest.py\n\n```\n\n #!/usr/bin/python3\n import json\n f = open(\"test.json\", 'r')\n json_data = json.load(f)\n json_str = str(json_data)\n jj = json.loads(json_str)\n print (jj)\n \n```\n\nとやってるんですが、 json.loads のところで以下のエラーが出ます。 \nなぜでしょうか?\n\n```\n\n json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)\n \n```\n\nググりまくったのですがもう疲れました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T08:39:53.420", "favorite_count": 0, "id": "42268", "last_activity_date": "2018-03-09T09:37:24.417", "last_edit_date": "2018-03-09T09:28:04.197", "last_editor_user_id": "3054", "owner_user_id": "27679", "post_type": "question", "score": 7, "tags": [ "python", "json" ], "title": "str() で文字列にした Python のオブジェクトが json.loads で戻せない", "view_count": 37536 }
[ { "body": "端的に言うと、JSON文字列にしたい場合は `str` ではなく、`json.dumps` を使えばよいです。以下詳細。\n\n### JSONのプロパティ名はダブルクォートで囲まれている必要がある\n\nまず、JSONの表記はPythonのリテラルのような柔軟性はないので、Pythonのリテラルが(あるいはJavaScriptのリテラルであっても)必ずしもJSONとして有効ではないということに注意してください。\n\n```\n\n >>> json.loads('{\"a\": 123}') # これはOK\n {'a': 123}\n >>> json.loads(\"{'a': 123}\") # これはエラー\n # 略\n json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)\n \n```\n\n上の例ではプロパティ名 `a` をシングルクォートで囲うとエラーになっています。\n\n### `json.load` はPythonのオブジェクト(辞書)を返す\n\n[`json.load`](https://docs.python.jp/3/library/json.html#json.load)の戻り値である\n`json_data` はPythonのオブジェクト(辞書)です。\n\n```\n\n >>> import json\n >>> f = open(\"test.json\", 'r')\n >>> json_data = json.load(f)\n >>> type(json_data)\n <class 'dict'>\n >>> json_data\n {'book1': {'title': 'Python Beginners', 'year': 2005, 'page': 399}}\n \n```\n\n### Pythonの辞書の `str` による文字列表現では、キー名がシングルクォートで囲われる\n\n辞書である `json_data` を\n[`str`](https://docs.python.jp/3/library/stdtypes.html#str)\nに与えると、辞書の文字列表現が得られます。\n\n```\n\n >>> str(json_data)\n \"{'book1': {'title': 'Python Beginners', 'year': 2005, 'page': 399}}\"\n \n```\n\nこの文字列はJSONとしては不正です。プロパティ名が `'book1'` のように、シングルクォートで囲まれているからです。 \nですから、これを `json.loads` に与えると、質問のようなエラーになります。\n\n### PythonのオブジェクトをJSON文字列にするには `json.dumps` などを使う\n\n上で見たように、`str` が返すのは必ずしもJSONとして有効な文字列ではありません。 \nですから、JSON文字列が必要な場合は[`json.dumps`](https://docs.python.jp/3/library/json.html#json.dumps)などを使用します。\n\n```\n\n >>> json_str = json.dumps(json_data)\n >>> jj = json.loads(json_str)\n >>> print (jj)\n {'book1': {'title': 'Python Beginners', 'year': 2005, 'page': 399}}\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T09:22:09.017", "id": "42271", "last_activity_date": "2018-03-09T09:22:09.017", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "42268", "post_type": "answer", "score": 9 }, { "body": "```\n\n # import json lib\n import json\n \n # load json\n data = json.load(open('data.json'))\n \n # print content\n print(data)\n \n # access a element\n print(data['book1'])\n \n # assess a element in a element\n print(data['book1']['title'])\n \n # looping over a list\n for x in data:\n print(data[x]['title'])\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T09:37:24.417", "id": "42272", "last_activity_date": "2018-03-09T09:37:24.417", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27681", "parent_id": "42268", "post_type": "answer", "score": -2 } ]
42268
42271
42271
{ "accepted_answer_id": null, "answer_count": 1, "body": "**【質問概要】** \nchromeなどブラウザで3本以上のマイク音声を取得したいのですが可能でしょうか?\n\n**【環境】** \n当方の環境は以下です。 \n・Windows 10 pro \n・Google Chromeのversion:64.0 \n・PCにオーディオインターフェース(入力が3本以上あるもの)を接続。 \nオーディオインターフェースにマイクを複数本接続。\n\n**【質問詳細】** \nブラウザ(Google Chrome)で音声をハンドリングしたく \njavascriptで実装しています。 \ngetUserMedia()とAudioContextを用いて2ch分の音声がブラウザに入ってきているのは確認できたのですが \n3ch以降がGoogle Chromeに入ってきません。\n\n音声が入ってきているかの確認は \ngetUserMedia()やAudioContextを用いてブラウザ上に波形表示をさせて \n波形が振れるかで確認しました。\n\nどうすれば3ch以上の音声をchromeでハンドリングできるでしょうか? \nWindowsのサウンド設定の「録音」タブで入力を見ても \n1ch,2chの音声に対してはメーターが振れますが \nオーディオインターフェースの3ch以降に繋いだ際には \nメーターが振れません。 \nWindowsのサウンドドライバー周りの制約かなとも思っているのですが \nなにかご存知の方がいらっしゃれば教えていただきたく思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T11:06:58.423", "favorite_count": 0, "id": "42274", "last_activity_date": "2020-08-23T01:01:20.160", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27682", "post_type": "question", "score": 0, "tags": [ "javascript", "windows", "google-chrome" ], "title": "WEBブラウザでの3本以上の音声ハンドリングについて", "view_count": 228 }
[ { "body": "> Windowsのサウンド設定の「録音」タブで入力を見ても \n> 1ch,2chの音声に対してはメーターが振れますが \n> オーディオインターフェースの3ch以降に繋いだ際には \n> メーターが振れません。\n\nデバイスとして音声を認識していないのであれば、Google Chrome等のアプリケーションは無関係です。 \nハードウェアの問題であり製造元に問い合わせるべきです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T22:23:38.917", "id": "42280", "last_activity_date": "2018-03-09T22:23:38.917", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "42274", "post_type": "answer", "score": 0 } ]
42274
null
42280
{ "accepted_answer_id": "42279", "answer_count": 1, "body": "USER_TAB_COLUMNSからカラムの型(CHARやNUMBER等)を取得して、 \nその型を基に動的にC#の型に変換する方法はありますでしょうか?\n\n個別に変換マップを作ってCHARならstring型にするという定義を \n持つしかないでしょうか?\n\n最終的には、OracleだけでなくSQLServer等にも対応したいと \n考えております。\n\nこのあたり、何かノウハウ等ありましたらご教示ください。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T11:29:12.507", "favorite_count": 0, "id": "42275", "last_activity_date": "2018-03-09T20:44:02.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9228", "post_type": "question", "score": 1, "tags": [ "c#" ], "title": "C# oracleのデータベースからカラムの型を取得して動的にC#の型に変換できますか?", "view_count": 2890 }
[ { "body": "SQLの型変換に関しては各RDBMS向けのプロバイダーが実装しているため、各製品固有のビューを参照する必要はありません。基本的には単に`DbDataReader`を使って`SELECT`ステートメントを実行すればよいです。\n\n```\n\n var command = connection.CreateCommand();\n command.CommandText = \"SELECT * FROM table1\";\n using (var reader = command.ExecuteReader())\n {\n for (var i = 0; i < reader.FieldCount; i++)\n {\n var name = reader.GetName(i);\n string sqlType = reader.GetDataTypeName(i);\n Type clrType = reader.GetFieldType(i);\n }\n }\n \n```\n\nまた`DbDataReader.GetSchemaTable()`を実行すれば空の`DataTable`を返しますので、`Columns[i].DataType`などからテーブルの構造を得ることができます。\n\nなおADO.NETでの標準的な手法は以上のとおりですが、ORM\n(データセットデザイナーを含む)を使用している場合はエンティティのプロパティ型を参照してください。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T20:44:02.113", "id": "42279", "last_activity_date": "2018-03-09T20:44:02.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "42275", "post_type": "answer", "score": 2 } ]
42275
42279
42279
{ "accepted_answer_id": null, "answer_count": 0, "body": "XMLからXSLTスタイルシートとantを使ってWord(.docx)を生成しようとしています.\n\nここでWord上に図形を挿入しなければならないのですが、例えばMicorosoft\nWordで一個の長方形を挿入し背景色をつけて、内部にテキストを入れて保存すると概略次のような構造のWordprocessingMLが生成されます.(余分なネームスペースは省いてあります)\n\n```\n\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n <w:document \n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n xmlns:v=\"urn:schemas-microsoft-com:vml\"\n xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\"\n xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"\n mc:Ignorable=\"w14 w15 wp14\">\n ....\n <w:r>\n <w:rPr>\n <w:noProof/>\n </w:rPr>\n <mc:AlternateContent>\n <mc:Choice Requires=\"wps\">\n <w:drawing>\n <wp:anchor distT=\"0\" distB=\"0\" distL=\"114300\" distR=\"114300\"\n simplePos=\"0\" relativeHeight=\"251659264\" behindDoc=\"0\" locked=\"0\"\n layoutInCell=\"1\" allowOverlap=\"1\">\n <!-- ここからはDrawingMLの世界:長いので省略-->\n </wp:anchor>\n </w:drawing>\n </mc:Choice>\n <mc:Fallback>\n <w:pict>\n <v:rect id=\"正方形/長方形 1\"\n style=\"position:absolute;left:0;text-align:left;margin-left:1.5pt;margin-top:-71.25pt;width:58.8pt;height:78.6pt;z-index:251659264;visibility:visible;mso-wrap-style:square;mso-width-percent:0;mso-height-percent:0;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;mso-width-percent:0;mso-height-percent:0;mso-width-relative:margin;mso-height-relative:margin;v-text-anchor:middle\"\n fillcolor=\"#001f76\" stroked=\"f\" strokeweight=\"1pt\">\n <!--ここはVMLの世界:長いので省略-->\n </v:rect>\n </w:pict>\n </mc:Fallback>\n </mc:AlternateContent>\n </w:r>\n \n```\n\nこれを見るとわかりますが、Wordは2つのフォーマット、DrawingMLとVMLを両方入れてくれます.ただしVMLはフォールバックの扱いのようです.\n\nちなみに手作業でDrawingMLの部分だけ、VMLの部分だけに編集してもWordはちゃんとその結果の.docxをエラーなしに読み込んでくれます.\n\nさて実際に中を見てみるとわかるのですが、複雑さの度合いは完全にDrawingML > VML\nです.DrawingMLは後発のためか山ほどのパラメータがあり、とてもXMLから自動生成するのは心がくじけてしまいます.これに対して、VMLは比較的単純で、かつCSSでスタイルが書けるのでXSLTスタイルシートによる変換はまだ対応できそうです.使用する機能は単に矩形に背景色をつけてテキストを内部に配置するだけなので、複雑なことはまったくしません.\n\nあまりこの世界の動向を知りませんが、今後システムとして使う場合、DrawingMLとVMLのどちらを採用すべきでしょうか?VMLは互換性のためだけに存在しているなどという話を耳にすることがあるので、はるかにプログラミングしやすいVMLへの変換にしたいのですが悩んでいます.\n\n助言をいただければ幸いです.\n\n以上 よろしくおねがいします.", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-09T14:34:10.223", "favorite_count": 0, "id": "42277", "last_activity_date": "2018-03-09T14:34:10.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9503", "post_type": "question", "score": 0, "tags": [ "xml", "xslt", "ms-word", "docx", "open-xml" ], "title": "XMLからWord(.docx)への変換、DrawingMLかVMLか?", "view_count": 916 }
[]
42277
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "<http://gihyo.jp/dev/serial/01/vuejs/0002?page=2> を参考にしながらVue.jsを勉強しています。 \nhtmlに\n\n```\n\n <div id=\"example\" v-bind:style=\"{'border': (isValid ? '' : '1px solid red')}\">\n <p>名前 {{ name }}</p>\n <p v-show=\"!isValid\">\n 名前を入力してください\n </p>\n </div>\n \n```\n\nと、jsに\n\n```\n\n var vm = new Vue({\n el: '#example',\n data: {\n name: '',\n },\n computed: {\n isValid: function () {\n return this.name.length > 0;\n }\n }\n });\n window.vm = vm;\n \n```\n\nとありますが、このisValid ? と\"!isValid\"\nの意味がわからないです。これらのコードを動かすと、赤い枠と名前を入力してくださいの文字がいつも表示されていますが、isValid ?\nと!isValidは合い判するものではと思っていまして、それなのにこの2つがいつも表示されているのが理解できませんでした。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T02:16:52.380", "favorite_count": 0, "id": "42282", "last_activity_date": "2018-03-10T02:37:56.343", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27687", "post_type": "question", "score": 1, "tags": [ "html", "vue.js" ], "title": "isValid ? と\"!isValid\" の意味がわからない", "view_count": 3221 }
[ { "body": "`isValid ? '' : '1px solid red'`は、`isValid`が`true`ならば`''`を、`false`ならば`'1px\nsolid red'`を返します。 \nつまり、`isValid == false`の場合に、赤枠が表示されます。 \n`!isValid`は、`true`と`false`の反転ですから、`isValid == false`の場合に、「名前を入力してください」が表示されます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T02:37:56.343", "id": "42283", "last_activity_date": "2018-03-10T02:37:56.343", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8078", "parent_id": "42282", "post_type": "answer", "score": 3 } ]
42282
null
42283
{ "accepted_answer_id": "42288", "answer_count": 2, "body": "[このページ](https://qiita.com/ik_miyabi/items/12d1127056cdf4f0eea5)を参考にしようと思ったのですが、コメントが気になったので質問します\n\n* * *\n\n**Q1.「文字」と「文字の集まり」という分け方はおかしいでしょうか?** \n・[ ] の仲間とは、具体的に何を意味しているのでしょうか?\n\n> 「文字を表すメタキャラクタ」「集合を表すメタキャラクタ」っていう分け方がよく分からないです。 \\d は文字クラスなので [ ] の仲間ですよね\n\n* * *\n\n**Q2.「文字クラス」のクラスについて** \n・以前から疑問に思っていたのですが、「文字クラス」のクラスってどういう意味ですか? \n・量指定子なら「演算子の仲間なのかな」と思うのですが\n\n・ \\d は、下記みたいなクラスがC言語か何かで定義されているのでしょうか? \n・それをインスタンス化せずに使っているということ??\n\n```\n\n class \\d {}\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T02:40:45.753", "favorite_count": 0, "id": "42284", "last_activity_date": "2018-03-10T09:12:33.443", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 1, "tags": [ "正規表現" ], "title": "正規表現の文字クラスについて", "view_count": 142 }
[ { "body": "> Q1.「文字」と「文字の集まり」という分け方はおかしいでしょうか? \n> ・[ ] の仲間とは、具体的に何を意味しているのでしょうか?\n\nメタキャラクタである`\\d`と`[0-9]`は同じです。が、`[0-9]`のうちメタキャラクタは`[`と`-`と`]`です。 \n`[`と`]`というメタキャラクタに挟まれている`0-9`は`0123456789`に展開され、いずれか一文字にマッチします。 \n`[`及び`]`とか`(`及び`)`はあくまでも集合/グループを作ることを意味するだけで、その中身はリテラルやメタキャラクタで指定します。 \nというような区別をつけているのだと思います。\n\n> Q2.「文字クラス」のクラスについて \n> ・以前から疑問に思っていたのですが、「文字クラス」のクラスってどういう意味ですか? \n> ・量指定子なら「演算子の仲間なのかな」と思うのですが\n\n定義された文字の区分というか、ある文字と一致する定義した文字のセットというか、そういう感じの意味合いのようです。 \n正規表現エンジンによって予め定義されたものもあれば、自分で定義するものもあります。\n\n参考文献 \n* [Wikipediaの正規表現の項](https://ja.wikipedia.org/wiki/%E6%AD%A3%E8%A6%8F%E8%A1%A8%E7%8F%BE) \n* [MSDNの正規表現での文字クラスのページ](https://docs.microsoft.com/ja-jp/dotnet/standard/base-types/character-classes-in-regular-expressions)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T04:30:28.233", "id": "42288", "last_activity_date": "2018-03-10T04:43:53.963", "last_edit_date": "2018-03-10T04:43:53.963", "last_editor_user_id": "25936", "owner_user_id": "25936", "parent_id": "42284", "post_type": "answer", "score": 5 }, { "body": "「メタキャラクタ」は英語の「Meta-\ncharacters」の直訳です。そして「[meta](https://ja.wikipedia.org/wiki/%E3%83%A1%E3%82%BF#%E7%8B%AD%E7%BE%A9%E3%81%AE%E3%83%A1%E3%82%BF)」は\n\n> ある対象を記述したものがあり、さらにそれを対象として記述するものを、メタな○○、あるいは単にメタ○○と呼ぶ。\n\nとあります。つまり「メタキャラクタ(文字)」は「文字を記述する文字」程度の意味です。例えば`\\d`だったり`[0-9]`という文字を記述した場合に正規表現としては`0`~`9`が該当する、という意味が与えられているということです。\n\n* * *\n\n「文字クラス」は英語の「Character\nClasses」の直訳です。そして「[class](https://ejje.weblio.jp/content/class.)」は\n\n> (共通の性質を有する)部類、種類、(学校の)クラス、学級、組、(クラスの)授業(時間)、(編物教室などの)講習、クラスの生徒たち、同期卒業生、同年兵\n\nとあります。つまり「文字クラス」とは「共通の性質を有する文字の種類」程度の意味です。例えば`\\d`とは数字という性質を持つ文字の種類なので`0`~`9`等が該当するわけです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T08:33:54.623", "id": "42292", "last_activity_date": "2018-03-10T09:12:33.443", "last_edit_date": "2018-03-10T09:12:33.443", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "42284", "post_type": "answer", "score": 4 } ]
42284
42288
42288
{ "accepted_answer_id": null, "answer_count": 1, "body": "処置の流れがわからないです。 \n<http://gihyo.jp/dev/serial/01/vuejs/0002?page=2> を参考にしながらvue.jsを勉強しています。 \nhtmlに\n\n```\n\n <div id=\"example\" v-bind:style=\"{'border': (isValid ? '' : '1px solid red')}\">\n <p>名前 {{ name }}</p>\n <p>\n <input type=\"text\" v-on:input=\"updateName($event)\">\n </p>\n <p v-show=\"!isValid\">\n 名前を入力してください\n </p>\n <p v-show=\"isValid\">\n <button v-on:click=\"sendData\">送信</button>\n </p>\n </div>\n \n```\n\nとあり、\n\n```\n\n var vm = new Vue({\n el: '#example',\n data: {\n name: '',\n },\n computed: {\n isValid: function () {\n return this.name.length > 0;\n }\n },\n methods: {\n updateName: function(event) {\n this.name = event.target.value;\n },\n sendData: function() {\n alert(this.name);\n }\n }\n });\n window.vm = vm;\n \n```\n\nとあります。わからないことは、\n\n①computed が呼び出されるときはいつか \n②\n\n```\n\n updateName: function(event) {\n this.name = event.target.value;\n }\n \n```\n\nのthis.nameのthisは何故いるのか? event.target.value はどこのことを指しているのか \nです。\n\n②に関してはさっぱりわからないのですが、①の方ではcomputedが呼び出されるときは、`v-bind:style=\"{'border': (isValid\n? '' : '1px solid red')}\"`のisValidが呼び出されたときでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T03:12:15.113", "favorite_count": 0, "id": "42285", "last_activity_date": "2018-03-12T06:50:36.997", "last_edit_date": "2018-03-12T06:50:36.997", "last_editor_user_id": "19110", "owner_user_id": "27689", "post_type": "question", "score": 1, "tags": [ "html", "vue.js" ], "title": "computed 中の関数が呼び出されるのはいつ?", "view_count": 8168 }
[ { "body": "①`computed`ではなく`isValid`関数が呼び出されるのはいつか?という意味だと思います。 \n呼び出されるのはざっくりいうとVueオブジェクトの初期化が完了した時と`name`の値が変更された時です。\n\n②`this`が必要なのはVue.jsが`this === vm`となるように`updateName`を呼び出すからです。 \n`event.target.value`はinput要素に入力された値です。\n\nVue.jsの勉強をするなら古い情報でなく公式ドキュメントを読んだ方が効率も正確性もよいと思います。\n\n例えば①に関しては [算出プロパティとウォッチャ —\nVue.js](https://jp.vuejs.org/v2/guide/computed.html) にほとんど答えが書いてあります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T03:33:06.287", "id": "42315", "last_activity_date": "2018-03-11T03:33:06.287", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4388", "parent_id": "42285", "post_type": "answer", "score": 2 } ]
42285
null
42315
{ "accepted_answer_id": "42293", "answer_count": 1, "body": "はじめまして、よろしくお願いします。\n\nblockdiagやplantUML拡張で生成される図のファイル名を固定する方法はありますか? \nblockdiag-03f29426fa631bca7b8304618538c8e37ce62f38.png \nのようなファイル名になり、記述を変えるごとに別の名前で生成されていきます。\n\n使用環境 \nWindows10 \nPython 3.6.4 \nSphinx 1.7.1", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T04:29:17.250", "favorite_count": 0, "id": "42287", "last_activity_date": "2018-03-10T08:57:25.377", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27690", "post_type": "question", "score": 2, "tags": [ "sphinx" ], "title": "生成される図のファイル名", "view_count": 61 }
[ { "body": "実装コードはこのあたりです。 \n[https://bitbucket.org/blockdiag/blockdiag/src/07f96892bfda92b84f624afab987015f26ff7ff0/src/blockdiag/utils/rst/nodes.py?at=default&fileviewer=file-\nview-\ndefault#nodes.py-49](https://bitbucket.org/blockdiag/blockdiag/src/07f96892bfda92b84f624afab987015f26ff7ff0/src/blockdiag/utils/rst/nodes.py?at=default&fileviewer=file-\nview-default#nodes.py-49)\n\n残念ながら、ファイル名を指定する方法は提供されていないようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T08:57:25.377", "id": "42293", "last_activity_date": "2018-03-10T08:57:25.377", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "42287", "post_type": "answer", "score": 2 } ]
42287
42293
42293
{ "accepted_answer_id": "42306", "answer_count": 2, "body": "ubuntu16.04 で gitkの日本語フォントがとても汚いです。 \nどうすれば設定変更できるのでしょうか? \n[![画像の説明をここに入力](https://i.stack.imgur.com/Q1Gl4.png)](https://i.stack.imgur.com/Q1Gl4.png)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T12:26:07.463", "favorite_count": 0, "id": "42296", "last_activity_date": "2018-09-22T05:00:11.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "704", "post_type": "question", "score": 2, "tags": [ "git" ], "title": "ubuntu16.04 で gitkの日本語フォントがとても汚い", "view_count": 877 }
[ { "body": "bashrcにてanaconda3/binにパスを通していたのが原因だったようです。 \nexportを無効にして再度試したところ、綺麗に表示されました。 \nとはいえanaconda3を弄りたい時にはデフォルトでパスが通っていたほうが便利です。\n\nanaconda3/binにパスを通して同様の症状が起きるか、起きる場合はどうすれば避けられるか知っている人がいたら教えてください。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T23:34:22.307", "id": "42306", "last_activity_date": "2018-03-10T23:34:22.307", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "704", "parent_id": "42296", "post_type": "answer", "score": 2 }, { "body": "私も `gitk` で同じ現象が起きました。 \n`wish` はシステム以外を呼んでいました。\n\n```\n\n $ which wish\n /home/username/.pyenv/shims/wish\n \n```\n\n`gitk` の起動時に `/usr/bin/wish8.x` を呼ぶようにして解決しました。\n\n```\n\n $ sudo vi /usr/bin/gitk\n \n ### 3行目 Before\n exec wish \"$0\" -- \"$@\"\n \n ### 3行目 After\n exec /usr/bin/wish8.6 \"$0\" -- \"$@\"\n \n```\n\nちなみに `wish8.6` を呼んでいるのは無印よりもフォントが奇麗だったからです。 \nご参考まで\n\n[![きれいなやつ](https://i.stack.imgur.com/pn8lo.png)](https://i.stack.imgur.com/pn8lo.png)", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2018-09-22T05:00:11.603", "id": "48635", "last_activity_date": "2018-09-22T05:00:11.603", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29146", "parent_id": "42296", "post_type": "answer", "score": 3 } ]
42296
42306
48635
{ "accepted_answer_id": "42326", "answer_count": 2, "body": "◎マウスホイールが一度回された時に、一度だけ処理し、 \n再度回すとまた処理するというものを作りたいです。\n\n「jquery.mousewheel.js」というプラグインを使っています。\n\n下のコードだと、大きくホイールを回すと、複数回'mousewheel'イベントが呼ばれてしまいます。\n\nmousewheelイベントが発生した直後に\n\n```\n\n .off(\"mousewheel\")\n \n```\n\nとしているのですが、mousewheelイベント自体の発生を止めるものではないのですかね。\n\n◎なぜtrue/falseのフラグたと処理をスルーできないのかの理由も教えていただけますと幸いです。\n\n```\n\n $(function(){\r\n \r\n var timer;\r\n var index = 0;\r\n var delay = 1000; //次のスクロールを許容する時間\r\n var boxes = $('.box');\r\n \r\n //ホイールイベントを検知\r\n $(document).on('mousewheel', function(eo, delta, deltaX, deltaY){\r\n console.log('mousewheel');\r\n count(eo, delta)\r\n });\r\n \r\n //関数の定義\r\n function count(eo, delta){\r\n if (delta === -1){\r\n $(document).off(\"mousewheel\")//ホイールの検知を中止\r\n console.log('下');\r\n index = index + 1\r\n if (index >= boxes.length-1) {\r\n index = boxes.length-1\r\n }\r\n changeBox(index);\r\n timer = setInterval(allowCount, delay);\r\n }\r\n \r\n if (delta === 1) {\r\n $(document).off(\"mousewheel\")//ホイールの検知を中止\r\n console.log('上');\r\n index = index - 1\r\n if (index < 0) {\r\n index = 0\r\n }\r\n changeBox(index);\r\n timer = setInterval(allowCount, delay);\r\n }\r\n \r\n function allowCount() {\r\n console.log('go!');\r\n \r\n //ホイールを検知の再登録\r\n $(document).on(\"mousewheel\",function(eo, delta, deltaX, deltaY){\r\n console.log('mousewheel');\r\n count(eo, delta)\r\n })\r\n clearInterval(timer)\r\n }\r\n }\r\n \r\n function changeBox(index) {\r\n var cur = $('.effect');\r\n cur.removeClass('effect');\r\n boxes.eq(index).addClass('effect');\r\n }\r\n });\n```\n\n```\n\n @charset \"UTF-8\";\r\n *{\r\n padding:0;\r\n margin:0;\r\n }\r\n \r\n html,body{\r\n width:100%;\r\n height:100%;\r\n overflow: hidden;\r\n }\r\n \r\n \r\n .container{\r\n height: 100%;\r\n display:grid;\r\n grid-auto-rows: 50px;\r\n grid-template-columns: 80%;\r\n justify-content: center;\r\n grid-gap: 5px;\r\n }\r\n \r\n .box{\r\n background: pink;\r\n }\r\n \r\n .effect{\r\n opacity: 0.5;\r\n }\n```\n\n```\n\n <!DOCTYPE html>\r\n <html>\r\n <head>\r\n <meta charset=\"utf-8\" />\r\n <title></title>\r\n <link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\" />\r\n <script src=\"https://code.jquery.com/jquery-3.2.1.min.js\"></script>\r\n <script type=\"text/javascript\" src=\"jquery.mousewheel.js\"></script>\r\n <script src=\"scripts.js\"></script>\r\n </head>\r\n <body>\r\n <div class=\"container\">\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n <div class=\"box\"></div>\r\n </div>\r\n </body>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T14:46:17.093", "favorite_count": 0, "id": "42297", "last_activity_date": "2018-03-11T13:26:43.443", "last_edit_date": "2018-03-11T13:26:43.443", "last_editor_user_id": "12297", "owner_user_id": "12297", "post_type": "question", "score": -1, "tags": [ "javascript", "jquery" ], "title": "jQueryで'mousewheel'イベントが複数呼ばれるのを中止するにはどうすればいいですか?", "view_count": 4340 }
[ { "body": "ホイールは回るものなので「一度だけ動かす」という考え方自体がおかしいのです。おそらくマウスホイールが一定角度で段階的に(カクカクと)回るタイプのマウスをお使いなのでしょうが、無段階に周り続けるホイールを持つマウスも存在しています。またタッチパッドのスクロールのようなものも無段階になっているかと思います。そのためそのようなUIを作成することは個人的にあまり推奨しません。\n\nしかしどうしてもやりたいのであれば、イベントを処理した時の時刻を記録しておいて次に発生したイベントが時の現在時間と比較して一定期間内ならばイベントを無視して処理をしないようにすればいいのではないでしょうか?\n\n追記) \n以下のようにしてもうまくいかないということでしょうか?\n\n```\n\n $(function(){\n \n var timer;\n var index = 0;\n var delay = 1000; //次のスクロールを許容する時間\n var last_time = 0;\n var boxes = $('.box');\n \n //ホイールイベントを検知\n $(document).on('mousewheel', function(eo, delta, deltaX, deltaY){\n console.log('mousewheel');\n var now = new Date().getTime()\n if (now - last_time >= delay) {\n last_time = now;\n count(eo, delta)\n }\n });\n \n //関数の定義\n function count(eo, delta){\n console.log('処理するよ');\n if (delta === -1){\n console.log('下');\n index = index + 1\n if (index >= boxes.length-1) {\n index = boxes.length-1\n }\n changeBox(index);\n }\n \n if (delta === 1) {\n console.log('上');\n index = index - 1\n if (index < 0) {\n index = 0\n }\n changeBox(index);\n }\n }\n \n function changeBox(index) {\n console.log('changeBox() : index => ' + index);\n var cur = $('.effect');\n cur.removeClass('effect');\n boxes.eq(index).addClass('effect');\n }\n });\n \n```", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T16:44:54.143", "id": "42304", "last_activity_date": "2018-03-10T18:29:19.810", "last_edit_date": "2018-03-10T18:29:19.810", "last_editor_user_id": "27410", "owner_user_id": "27410", "parent_id": "42297", "post_type": "answer", "score": 2 }, { "body": "イベントの間隔で判断すると良いかも\n\n```\n\n var timer;\n var index = 0;\n var interval = 100;\n var boxes = $('.box');\n var last_time = 0;\n \n //ホイールイベントを検知\n $(document).on('mousewheel', function(eo, delta, deltaX, deltaY){\n console.log('mousewheel');\n var now = new Date().getTime();\n if (now - last_time > interval){\n count(eo, delta)\n }\n last_time = now;\n });\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T12:22:33.680", "id": "42326", "last_activity_date": "2018-03-11T12:53:24.860", "last_edit_date": "2018-03-11T12:53:24.860", "last_editor_user_id": "22793", "owner_user_id": "22793", "parent_id": "42297", "post_type": "answer", "score": 2 } ]
42297
42326
42304
{ "accepted_answer_id": "42336", "answer_count": 1, "body": "現在、ユーザーの複数のSNSアカウントを管理するアプリを制作しています。 \nその中で、登録された複数のSNSアカウントの情報からユーザーが選択したアカウントだけを一つのListにまとめたいのですが、SNSアカウントの情報のをclassで定義しておりListを利用できません。何か良い解決方法があれば教えてください。よろしくお願いします。\n\n```\n\n import Foundation\n import RealmSwift\n \n class Twitter: Object {\n @objc dynamic var userID = \"\"\n @objc dynamic var screenName = \"\"\n @objc dynamic var userName = \"\"\n @objc dynamic var imageURL = \"\"\n }\n \n class Facebook: Object {\n @objc dynamic var userName = \"\"\n @objc dynamic var imageURL = \"\"\n }\n \n class UserProfile: Object {\n //このclass内で下のlistにTwitterクラスやFacebookクラスのインスタンスを追加したい\n //@objc dynamic var list\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T15:27:33.397", "favorite_count": 0, "id": "42299", "last_activity_date": "2018-03-12T03:40:27.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27694", "post_type": "question", "score": 1, "tags": [ "swift", "ios", "xcode", "realm", "swift4" ], "title": "RealmSwiftで複数のclassを一つのListで保存したい。", "view_count": 165 }
[ { "body": "できません。RealmおよびSwiftの制限によりListに格納できるのはそれぞれ1つの型のみです。共通に扱いたい場合は、TwitterクラスとFacebookクラスの共通のプロパティを持つスーパークラスのようなものを定義するか、あきらめてListとListをそれぞれ別の関連として持つかのどちらかになります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T03:40:27.120", "id": "42336", "last_activity_date": "2018-03-12T03:40:27.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "42299", "post_type": "answer", "score": 1 } ]
42299
42336
42336
{ "accepted_answer_id": "42311", "answer_count": 3, "body": "先日Qtの日本営業店に尋ねましたら、 \nQt等では、縦書きの実装などはかなり難しい(できない?) \nと言われました。\n\n一太郎とか、Wordソフトとかって何のプログラミング言語で \nかかれているのでしょうか?という質問を検索すると、 \nやはり企業秘密みたいで、C++とか、そこらへん?みたいな \nようです。例えばQtはC++なので、ならばQtでもできるはず \nですが、私もできそうな気がしません。(→この質問は \n確かに変でした。)\n\n自分で拡張していくしかないのか、先日からお尋ねしている \nサブクラス化が成功すれば、それなりに融通の利くレイアウトを \n実装できるのか、正直わかりません。ただこの辺のドキュメントは \n無いと言っていいくらい少なく、正直絶望的です。 \nこの際にお聞きしたいのですが、こういう質問はいいのかわからない \nのですが、テキストエディタ作成に強いプログラミング言語って \nご存知ですか?\n\n**追記** \n詳しい解説有難うございます。[[組版文字について:QTextEdit関連](https://ja.stackoverflow.com/questions/37110/%E7%B5%84%E7%89%88%E6%96%87%E5%AD%97%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6qtextedit%E9%96%A2%E9%80%A3\\]%E3%81%8B%E3%82%89%E7%B5%84%E7%89%88%E5%87%A6%E7%90%86%E3%81%AB%E8%88%88%E5%91%B3%E3%82%92%E6%8C%81%E3%81%A1%E5%A7%8B%E3%82%81)、ルビの表記、組立文字等は何とか`Qt`でも実装出来ました。こういうテキスト処理系の話は`Qt`から始めたため、`Qt`の中だけでもがいてきた感じです。今回は、`Qt`以外の方向へ眼を向けようとしたための質問でした。sayuriさんのご指摘の通り、組版処理の要件という無料公開の文書をネットで見て、その厳密さに驚いたことがありますが、Qtで何か方法はないかと手探りしてきました。自分はPythonに手を付ける前にPyQtの本を買ってしまったというぐらいの経歴を持っていて、(しかも英語のMarkSummerfield氏のやつです。)GUIというのも知りませんでした。そこからPythonスタートブックから地道にやってきたのですが、正直PyQtって何?という始まりでつまずいている可能性のある存在でした。まだQtでも触った事のないメソッドやクラスもあるため、組み合わせ次第ではできる可能性もあるのではないかという希望を持ちつつ色々やってきました。今の自分のスキルでは皆さんのご助力とともに、ルビや組立文字等、「組版が少しでも増やせた。」というところでも満足するものだと思うんですが、上でも述べたように、Qtでは縦書やらは難しいということだったので、(こう、Qt側から、初めてそれは無理です。と言われた感じなので、)じゃあ別の?という程度の切り替えを意識した質問でした。意図がわかりにくかったようで申し訳ありません。確かにエディタではなくて、ワードプロセッサの方が私の意図通りです。抽象的にテキストを扱うソフトっていうのかどういうべきなのかはわかりませんが、Qtを始めるまえは縦書に難があるとかいう限界自体を知らずに突き進んできたため、こんな質問になりました。Qt以外のライブラリだったらできるか?という感じです。少なくともテキスト処理系に強いプログラミング言語は?ライブラリは?という質問にすべきだったかどうかわかりませんが、とりあえずこの質問はいけないようだったので消そうかなと考えています。 \n皆さんの意見を自分なりに考えてみると、つまり、Qtは既にC++で書かれたライブラリなので、Qtで無理なら、C++でQtに変わる別のライブラリを構成し、リファレンス公開するレベルにならないといけないということですね。Qtを使ってどうこう言ってるんじゃなくて、Qtを作れるレベルには最低限なってないとだめだと。 \nLispですというお答えもいただきましたが、私が一番欲しい解答はこのようなものでした。でも何となくわかったことですが、言語自体を自分で作り、ライブラリを自分で生み出し、ほかの人が作ったライブラリに頼らずに、一から自分で作りなさいと、そういうことなのでしょうか。出来上がった結果としてのライブラリに頼ってたら、確かに根っこは変えられないですね。確かにこういう構造関係を知らないようではそんな事やったこともないため、スキル不足は否めません。 \nひょっとすると、Qtで公開されているライブラリのように、誰かが作ってくれたライブラリの中で、テキスト処理系に強いライブラリはありますか?と尋ねるべきだったでしょうか。ほんとこの辺の知識が曖昧なまま進んできたもので、お騒がせして申し訳ありませんでした。 \n(クローズされるか、この質問は近日中に消そうと思います。)", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T15:29:59.190", "favorite_count": 0, "id": "42300", "last_activity_date": "2018-03-13T02:14:03.437", "last_edit_date": "2018-03-13T01:31:29.567", "last_editor_user_id": "4236", "owner_user_id": "24284", "post_type": "question", "score": 1, "tags": [ "qt" ], "title": "テキストエディタ作成に強いプログラミング言語は?", "view_count": 2962 }
[ { "body": "質問文ではテキストエディタとされていますが、[Wikipedia](https://ja.wikipedia.org/wiki/%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%82%A8%E3%83%87%E3%82%A3%E3%82%BF)には\n\n> **テキストエディタ** (英語: text\n> editor)とはコンピュータで文字情報(テキスト)のみのファイル、すなわちテキストファイルを作成、編集、保存するためのソフトウェア(プログラム)である。\n\nと説明されています。\n\n他方「縦書きの実装」「一太郎とか、Wordソフトとか」とも言及されています。そもそも作成したいのはテキストエディタではなく[ワードプロセッサ](https://ja.wikipedia.org/wiki/%E3%83%AF%E3%83%BC%E3%83%97%E3%83%AD%E3%82%BD%E3%83%95%E3%83%88)ではありませんか?\n\n>\n> ワープロソフトは、手書きやタイプライタと異なり、文書をコンピュータ上で作成してデータの形で保存するため、後からの修正や再利用、電子メールなどでの添付、文書内の文字検索などが容易であり、印刷せずに画面で表示すればペーパーレス化も可能である。また、文字の装飾や文字間隔の調整、図表の挿入などの編集機能を備えている。主流といわれるワープロソフトには、DTPで使用できるほどの高度な編集機能や、グループで使う事を考慮した世代管理機能や校正機能を持つものもある。\n\n作ろうとしているアプリケーションのゴールを正しく認識しないことには、完成することはないと思います。\n\n* * *\n\n>\n> 一太郎とか、Wordソフトとかって何のプログラミング言語でかかれているのでしょうか?という質問を検索すると、やはり企業秘密みたいで、C++とか、そこらへん?みたいなようです。例えばQtはC++なので、ならばQtでもできるはずですが、私もできそうな気がしません。\n\n縦書き等、文字の厳密なレイアウトを実現するのであれば、フォントの解析はもちろんのこと、画面描画も1dotずつ全て制御する必要があることはわかるはずです。アプリケーションを作成するにはQtを利用していてはだめで、Qtのようなライブラリを作成できるスキルが求められるのではありませんか?\n\nなおWordに関しては実装について説明されており、DirectXやOpenGLなどを使用してグラフィックスカードを直接制御しています。[マイクロソフトは、C++でいかにしてMicrosoft\nOfficeのクロスプラットフォームを実現したのか](http://www.publickey1.jp/blog/14/cmicrosoft_office.html)\n\n* * *\n\n> テキスト処理系に強いプログラミング言語は?ライブラリは?\n\n縦書きなどテキスト処理を行うとなるとsoramimiさんが具体的な例を挙げてくださいましたが、実はただ単に並べればよいというわけではなく、例えば`「`(鍵括弧)は90°回転が必要ですし、[連綿体(合字)](http://www.morisawa.co.jp/support/faq/3693)はどうするのという問題も出てくるため「フォントの解析はもちろんのこと」と指摘しました。\n\n結局、1文字ずつレイアウトすることになると思いますが、効率よく行う必要があります。\n\n他の方から適切な言語・ライブラリが提示されない場合、最終的にはOfficeなどが採用しているようにDirectXやOpenGLなどを使用してグラフィックスカードを直接制御することになります。その場合、DirectXであれば[HLSL;\nHigh Level Shading\nLanguage](https://ja.wikipedia.org/wiki/High_Level_Shading_Language)、OpenGLであれば[GLSL;\nOpenGL Shading\nLanguage](https://ja.wikipedia.org/wiki/GLSL)といった言語で記述することになります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T02:16:05.987", "id": "42311", "last_activity_date": "2018-03-13T02:14:03.437", "last_edit_date": "2018-03-13T02:14:03.437", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "42300", "post_type": "answer", "score": 9 }, { "body": "C++とQtで縦書きワープロを作るという方針で検討してみます。\n\nまず、現時点において、Qtはテキストの縦書き描画をサポートしていなかったはずです。 \nサポートされていないなら自前でやる必要があります。\n\nまずは基本のテキスト描画から。これは横書きです。\n\n```\n\n void MyWidget::paintEvent(QPaintEvent *event)\n {\n QPainter pr(this);\n QString text = \"\\xe3\\x81\\x82\\xe3\\x81\\x84\\xe3\\x81\\x86\\xe3\\x81\\x88\\xe3\\x81\\x8a\"; // あいうえお\n pr.drawText(5, 15, text);\n }\n \n```\n\nテキスト描画の進行方向を縦にするには、QTransformクラスを使います。\n\n```\n\n void MyWidget::paintEvent(QPaintEvent *event)\n {\n QTransform tr;\n tr.translate(5, 5);\n tr.rotate(90);\n QPainter pr(this);\n pr.setTransform(tr);\n QString text = \"\\xe3\\x81\\x82\\xe3\\x81\\x84\\xe3\\x81\\x86\\xe3\\x81\\x88\\xe3\\x81\\x8a\"; // あいうえお\n pr.drawText(0, 0, text);\n }\n \n```\n\nrotateを指定して90度回転して描画しています。しかしこれでは、文字まで横倒しになってしまうので使えません。\n\nQTransformはあきらめて、1文字ずつ描画してみます。\n\n```\n\n void MyWidget::paintEvent(QPaintEvent *event)\n {\n QPainter pr(this);\n QFontMetrics fm = pr.fontMetrics(); // フォント情報を取得\n int line_height = fm.height(); // 文字の高さ\n int x = 5;\n int y = 5;\n y += line_height;\n pr.drawText(x, y, \"\\xe3\\x81\\x82\"); // あ\n y += line_height;\n pr.drawText(x, y, \"\\xe3\\x81\\x84\"); // い\n y += line_height;\n pr.drawText(x, y, \"\\xe3\\x81\\x86\"); // う\n y += line_height;\n pr.drawText(x, y, \"\\xe3\\x81\\x88\"); // え\n y += line_height;\n pr.drawText(x, y, \"\\xe3\\x81\\x8a\"); // お\n }\n \n```\n\n縦書き成功です。\n\nここから検討しなければいけないことがたくさんあります。\n\n文字毎に幅が異なる可能性があります。多くのフォントでは、全角文字に限れば全て同じ幅かもしれませんし、文字毎に微調整が施されていて、文字幅が全部異なるかもしれません。\n\n日本語の文と欧文が混在する場合どうするか。半角文字を描画する場合、水平方向に中央寄せして縦書きにするのか、英文として読めるように、横書きを回転した(上に挙げた2番目の例の)様にに描画したいのか、文字毎に座標と回転を自分で計算して描画することになるでしょう。日欧混在テキストの描画では、カーニングや合字をどう処理するかなど、悩ましい課題がたくさん出てきます。\n\n長いテキストをひとつの関数で一度で描画するなら高速ですが、一文字一文字描画すると、パフォーマンスの低下が懸念されます。実際に作ってみないとわかりませんが、遅すぎて実用にならないとなったときに、バックグラウンドで遅延描画するとか、レンダリングのキャッシュを実装するとか、かなり面倒くさいことを行う必要が出てくるかもしれません。\n\n<追記> \n日本語入力の対応も結構面倒です。IMEはQtでサポートされていますが、その扱いは自前実装になります。IME入力を受け付けたいウィジェットに対して`setAttribute`を呼んでIMEを有効にし、`inputMethodQuery`と`inputMethodEvent`をオーバーライドして、変換候補ウィンドウの表示位置を設定したり、変換文字列を取得したりする必要があります。イベントで渡される文字列には、preedit(変換中文字列)とcommit(確定文字列)があります。on-\nthe-spot方式(ワープロソフトの編集中文書内で変換中文字列をインライン的に描画する)か、over-the-\nspot方式(ポップアップウィンドウを作ってその中で変換中文字列を描画する)か、アプリケーションの要件に応じて、どちらを採用するか決めます。いずれにしても、一連のIME対応を自分で実装する必要があります。変換中文字列を縦書きで表示するアプリを私は見たことがありませんが、もし実現できれば、結構レアなアプリということになるので、意外と需要があるかもしれません。 \n</追記>\n\nやってできなくはないはずですが、相当の覚悟がないと、途中で挫折すること必至です。\n\np.s. \n記事タイトルは、「縦書きワープロアプリの実装に適した言語や手法は何か?」といったものがいいと思います。記事を削除したりクローズする必要はないと考えます。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T08:17:39.563", "id": "42320", "last_activity_date": "2018-03-12T03:24:05.283", "last_edit_date": "2018-03-12T03:24:05.283", "last_editor_user_id": "3337", "owner_user_id": "3337", "parent_id": "42300", "post_type": "answer", "score": 8 }, { "body": "最適かどうかは怪しいですが、一番簡単なのはブラウザ環境のJavaScriptかもしれません。とりあえず、下記のコードスニペットで最小限の縦書き編集はできますので、あとは色々と機能を付ければそれらしくなります。\n\n```\n\n document.querySelector('div').focus();\n```\n\n```\n\n div {\r\n writing-mode: vertical-rl;\r\n }\n```\n\n```\n\n <div contenteditable=true>縦書き</div>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T03:33:45.740", "id": "42335", "last_activity_date": "2018-03-12T03:33:45.740", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3475", "parent_id": "42300", "post_type": "answer", "score": 3 } ]
42300
42311
42311
{ "accepted_answer_id": "42312", "answer_count": 3, "body": "ファイルの同一性を確認するのにハッシュを使って行うことを考えています。 \nMD5, SHA-1, SHA-2, SHA-256, SHA-3, BLAKE, CRC, RIPEMD など \nありますが、 \n(質問1) 高速でかつ軽量(CPU負荷が軽い)のはどれなのでしょうか?\n\nまた一点疑問があります。 \nファイル名は異なりますが内容が同一だった場合、ハッシュ値が同じになるとWEB記事で見ていますが、ファイル名が異なればファイル名の部分はデータが違うので、同じハッシュ値にならないのでは?と考えてしまいます。 \n(質問2) これは何故いっしょのハッシュ値になるのでしょうか?\n\n質問に対しそれぞれ別にご回答いただいてもかまいません。ご存知の方、ご教示いただけると幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T15:44:23.790", "favorite_count": 0, "id": "42301", "last_activity_date": "2018-10-04T17:23:05.323", "last_edit_date": "2018-10-04T17:23:05.323", "last_editor_user_id": "19769", "owner_user_id": "8593", "post_type": "question", "score": 5, "tags": [ "ハッシュ" ], "title": "ファイルの同一性を確認するのに最適なハッシュ方法及び疑問", "view_count": 10635 }
[ { "body": "普通、ファイルのハッシュ値というのは、ファイル内容のハッシュ値を指します。 \nファイル名はハッシュには入りません。\n\nそのなかで一番軽量、高速なのはCRCですね。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T15:52:10.490", "id": "42302", "last_activity_date": "2018-03-10T15:52:10.490", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27481", "parent_id": "42301", "post_type": "answer", "score": 0 }, { "body": "まず第一に、CRCは誤り検出符号であってそのような用途に使ってはいけません。\n\n用途次第ですが、一般論としてMD5、SHA-1、RIPEMDはすでに使うべきでないとされています。BLAKEは一般的に使われていません。\n\nSHA-2、SHA-3には出力されるハッシュ値の長さにいくつかバリエーションがあり、それぞれでスループットが変わります。\n\nSHA-256はSHA-2のうちの一つです。\n\nということで比較できる選択肢がなくなりましたが、一般的にはSHA-256使っておけばよいです。\n\n「ファイルの同一判定」と書かれていますが、ハッシュ値で比較する場合一般には中身の「データ」だけです。ハッシュ値を計算するプログラムのほとんどはそのように作られています。ファイル名やタイムスタンプの同一性まで含めるのであれば、ハッシュ値を計算する際にそれらも含めるように考えるか、別途比較する必要があります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T02:16:12.650", "id": "42312", "last_activity_date": "2018-03-11T02:16:12.650", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "42301", "post_type": "answer", "score": 10 }, { "body": "ご質問の文面から、二つのファイルがどこに存在しているのか、わかりませんでした。\n\n比較したいファイルが、ひとつのコンピューター上に存在しているなら、ファイル全体を読み込んで、完全一致比較するのが最も高速で軽いです。\n\n比較したいファイルが、ネットワーク越しの離れた場所にある場合、SHA-256くらいが妥当だと思います。バージョン管理ツールのGitではSHA-1を採用しており、実用上それでも充分だという考えはあり得ます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T04:06:21.870", "id": "42316", "last_activity_date": "2018-03-11T04:06:21.870", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3337", "parent_id": "42301", "post_type": "answer", "score": 6 } ]
42301
42312
42312
{ "accepted_answer_id": "42305", "answer_count": 1, "body": "swiftプログラムで\n\n```\n\n func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) {\n \n```\n\nのような関数があります。 \nこの「!」ですが、暗黙的アンラップ型(Implicitly Unwrapped\nOptional)とのことですが、関数の呼び出しでは必ずnilではない値が入ってくるのになぜ必要なのでしょうか?\n\nご存知の方、ご教示お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T15:57:03.357", "favorite_count": 0, "id": "42303", "last_activity_date": "2018-03-11T00:35:08.397", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8593", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "swiftのfunc引数の中にある「!」について", "view_count": 98 }
[ { "body": "_**必ずnilではない値が入ってくるのになぜ必要なのでしょうか?**_\n\n必要ないですね。ですから、 **現在は**\n変更されています。(挙げていただいた例は複数のメソッドがミックスされてしまっているようですが、まぁ、言いたいことは伝わります。)\n\n[`captureOutput(_:didOutput:from:)`](https://developer.apple.com/documentation/avfoundation/avcapturevideodataoutputsamplebufferdelegate/1385775-captureoutput)\n\n> ## Declaration\n```\n\n> optional func captureOutput(_ output: AVCaptureOutput,\n> didOutput sampleBuffer: CMSampleBuffer,\n> from connection: AVCaptureConnection)\n> \n```\n\n[`metadataOutput(_:didOutput:from:)`](https://developer.apple.com/documentation/avfoundation/avcapturemetadataoutputobjectsdelegate/1389481-metadataoutput)\n\n> ## Declaration\n```\n\n> optional func metadataOutput(_ output: AVCaptureMetadataOutput,\n> didOutput metadataObjects: [AVMetadataObject],\n> from connection: AVCaptureConnection)\n> \n```\n\n* * *\n\nではなぜ「昔はImplicitly Unwrapped Optional型を使用していたのか?」という点ですが。\n\n * 当時のSwiftがiOS/macOS用のAPIを参照する場合には、Objective-Cのヘッダだけを元にしていた\n * 当時のObjective-Cには、参照型が`nil` (`NULL`)になりうるかどうかを示す方法がなかった\n\nそこでAppleのSwiftチームのメンバーはObjective-\nCのAPIを移入するにあたり、「NULLになりうるかどうかの査定が済んでいない参照型は全部Implicitly Unwrapped\nOptional型にする」と言う方針を採用しました。\n\nこの方針には異論もありましたが、「Implicitly Unwrapped\nOptional型は限られた状況以外では使用を非推奨にし、NULLになりうるかどうかの査定が済んだら非Optional型にするか、(明示的)Optional型に変更する」ことで、「NULLになりうるかどうかの査定が済んだ」かどうかがわかりやすくなる、と言うメリットがありました。\n\n* * *\n\nと言うわけで、現在でもImplicitly Unwrapped\nOptionalが使用されているApple製のAPIがあれば、そのAPIについては「NULLになりうるかどうかの査定」が済んでいないのか、なんらかの理由でImplicitly\nUnwrapped Optionalにしないといけないのだと思われます。\n\n(サードパーティがどう対応するかと言うのはまた別問題で、「そもそもSwift対応のためにObjective-\nCのヘッダーを書き換える気がない」と言う場合もあるでしょう。)\n\n* * *\n\nその他にも、SwiftがObjective-\nCのAPIを移入する方法はバージョンごとに少しずつ変化しており、引数ラベルやパラメータのデータ型が変わっていたりします。APIの情報については常に最新のものを参照するように心がけた方が良いでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-10T22:58:20.403", "id": "42305", "last_activity_date": "2018-03-11T00:35:08.397", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "13972", "parent_id": "42303", "post_type": "answer", "score": 2 } ]
42303
42305
42305
{ "accepted_answer_id": "42314", "answer_count": 1, "body": "Swift 4 で書かれた下記のコードでデータを取得していますが取得がうまくいきません。 \nほかのアドレスではデータの取得が出来ますが、下記のアドレスでは`data=nil`となりエラーになります。\n\n問題点は2点です(原因は1点かもしれませんが)。\n\n * dataがnilではないときに「データ抽出」部分が走るはずですが、dataにnilが入っており、正常なデータを取得出来ません。 \n(`if (data != nil && err ==\nnil)`としており、その下ではnilではないことが保証されると思うのですが実際にはnil入っている為、エラーになる)\n\n * `data=nil`になっており `https://trackings.post.japanpost.jp/m/services/srv/search/?requestNo1=123456789012&search=%8AJ%8En` とブラウザで打ち込んだときと同等の正しいデータが取得出来ない\n\n```\n\n //HTTPリクエスト作成\n let url = URL(string: \"https://trackings.post.japanpost.jp/m/services/srv/search/?\" +\n \"requestNo1=123456789012&search=%8AJ%8En\")\n let req = NSMutableURLRequest(url: url!)\n req.httpMethod = \"GET\"\n var waiting = true\n let task = URLSession.shared.dataTask(with: req as URLRequest , completionHandler: { data, res, err in\n if (data != nil && err == nil){\n let text = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)\n DispatchQueue.main.async(execute: {\n //データ抽出\n let arr = text!.components(separatedBy: \"お問い合わせ番号\")\n if arr.count == 1 {\n //有効なデータが帰ってこない場合\n result = \"エラー\"\n } else {\n result = text! as String\n }\n waiting = false\n })\n } else {\n DispatchQueue.main.async(execute: {\n })\n }\n \n })\n result = result.uppercased()\n task.resume()\n while (waiting) {\n RunLoop.current.run(mode: RunLoopMode.defaultRunLoopMode, before: Date())\n }\n \n //結果を出力\n print(result)\n \n```\n\nご指導のほど、よろしくお願いいたします。\n\n## 追記\n\n`let arr = text!.components(separatedBy: \"お問い合わせ番号\")`のところで、`Thread 1: Fatal\nerror: Unexpectedly found nil while unwrapping an Optional value`となる。\n\n[![このときの状態](https://i.stack.imgur.com/WNX1S.png)](https://i.stack.imgur.com/WNX1S.png)\n\n[![取得データ](https://i.stack.imgur.com/FJWVv.png)](https://i.stack.imgur.com/FJWVv.png)", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T00:34:54.353", "favorite_count": 0, "id": "42308", "last_activity_date": "2018-03-11T03:18:13.937", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "10845", "post_type": "question", "score": 0, "tags": [ "swift", "ios", "xcode" ], "title": "URLSession.shared.dataTaskでデータがうまく取得出来ない", "view_count": 3202 }
[ { "body": "ご掲載いただいた`data`の中身はやはりUTF-8ではないようです。並んでいる数値からしておそらくSJIS\n(Windows-31J)と思われます。返されているのはHTMLで`charset`を表す`meta`タグもありませんので、レスポンスヘッダーを確認しないといけないのですが、お示しいただいたサイトは`Content-\nType: text/html;\ncharset=windows-31j`と言うヘッダーを返しているようなので、以下はWindows-31Jとしてコードを書いてあります。\n\n以下のコードをコンパイルするにはクラス定義の外側に以下のようなextensionを定義しておく必要があります。\n\n```\n\n extension String.Encoding {\n static let windows31j = String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(CFStringEncodings.dosJapanese.rawValue)))\n }\n \n```\n\nコードの本題の部分ですが、呼び出し側がないと完了ハンドラーパターンの使い方がわかりにくいので、適当なViewController内のメソッドとすることを前提に記載しています。\n\n```\n\n class ViewController: UIViewController {\n \n //...\n \n //呼び出し側、何かのボタンが押されたらデータを取得するものとしている\n @IBAction func buttonPressed(_ sender: UIButton) {\n //`parseHtmlData`に自前のクロージャーを渡して呼び出す\n parseHtmlData(completion: {result in\n if let result = result {\n //結果を出力\n print(result)\n } else {\n print(\"通信エラー\")\n }\n })\n }\n \n //呼び出される側、自前の完了ハンドラーをパラメータの最後に含めておく\n func parseHtmlData(completion: @escaping (String?)->Void) {\n //HTTPリクエスト作成\n let url = URL(string: \"https://trackings.post.japanpost.jp/m/services/srv/search/?\" +\n \"requestNo1=123456789012&search=%8AJ%8En\")\n var req = URLRequest(url: url!) //可能な限り`NSMutableURLRequest`ではなく`URLRequest`を使う\n req.httpMethod = \"GET\"\n //waitingなんてフラグは使用しない\n let task = URLSession.shared.dataTask(with: req as URLRequest , completionHandler: { data, res, err in\n //非nilの値を後で利用するならif-letを使用した方が良い\n if let data = data, err == nil {\n print(data as NSData, res!.textEncodingName ?? \"encoding unknown\") //デバッグ用\n var text: String? = String(data: data, encoding: .utf8) //可能な限り`NSString`ではなく`String`を利用する\n //これだけだと元の`data`がUTF-8でない場合に`text`がnilになってしまう\n if text == nil {\n //UTF-8 でダメだったらSJIS(Windows-31J)を試す\n text = String(data: data, encoding: .windows31j)\n //Windows-31Jでもダメならエラーとする\n if text == nil {\n DispatchQueue.main.async(execute: {\n completion(nil)\n })\n }\n }\n DispatchQueue.main.async(execute: {\n //データ抽出\n let arr = text!.components(separatedBy: \"お問い合わせ番号\")\n var result: String\n if arr.count == 1 {\n //有効なデータが帰ってこない場合\n result = \"エラー\"\n } else {\n result = text!\n }\n //結果は必ず完了ハンドラーの中で使う\n result = result.uppercased()\n //完了ハンドラーの中で自前に完了ハンドラーを呼び出す\n completion(result)\n })\n } else {\n //エラーを黙って無視しない\n if let error = err {\n print(error)\n }\n if data == nil {\n print(\"data is nil\")\n }\n DispatchQueue.main.async(execute: {\n //何も書かれていなかったが、エラー時にはnilを完了ハンドラーに渡すことにする\n completion(nil)\n })\n }\n \n })\n task.resume()\n //フラグ成立まで待ち続けるなんてことはしない\n }\n \n }\n \n```\n\n今回の件で一番肝心な部分は、あなたのコードの\n\n```\n\n let text = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)\n \n```\n\nのところを、\n\n```\n\n var text: String? = String(data: data, encoding: .utf8) //可能な限り`NSString`ではなく`String`を利用する\n //これだけだと元の`data`がUTF-8でない場合に`text`がnilになってしまう\n if text == nil {\n //UTF-8 でダメだったらSJIS(Windows-31J)を試す\n text = String(data: data, encoding: .windows31j)\n //Windows-31Jでもダメならエラーとする\n if text == nil {\n DispatchQueue.main.async(execute: {\n completion(nil)\n })\n }\n }\n \n```\n\nのように書き換え、「UTF-8のデータじゃなかったらWindows-31Jとして試してみる」ようにした点です。(`String`か`NSString`かは本質的ではありませんが、できるだけ`String`を使った方が良いでしょう。)\n\n「ほかのアドレスではデータの取得が出来ます」と言うご記載があったので、UTF-8かWindows-31Jかだけをチェックしていますが、本当ならレスポンス(あなたのコードで`res`)からエンコーディング情報を取得して、その情報も利用するようにした方が良いでしょう。(古い日本語のサイトにはEUC-\nJPなんかを使用している場合もありますし。色々なケースを考えるとコードが複雑になるので今回は無視させてもらいました。例えばcharset=Shift_JISとか言っておいて、Windows-31Jの拡張文字を含む、なんて日本語サイトは山ほどあります。)\n\nあなたのアプリに組み込むにはあれこれ修正しないといけないでしょうが、完了ハンドラーパターンだけは崩さないようにすることを強くお勧めしておきます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T02:40:31.720", "id": "42314", "last_activity_date": "2018-03-11T02:40:31.720", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "42308", "post_type": "answer", "score": 1 } ]
42308
42314
42314
{ "accepted_answer_id": "42345", "answer_count": 1, "body": "Electronの勉強のため、 \n<https://github.com/szwacz/electron-boilerplate> \nをcloneし、読んだり変更したりしているのですが、 \nこのプロジェクトに含まれる、\n\n<https://github.com/szwacz/electron-boilerplate/blob/master/.babelrc>\n\n```\n\n {\n \"presets\": [\n [\n \"@babel/env\",\n {\n \"targets\": {\n \"browsers\": \"last 2 Chrome versions\",\n \"node\": \"current\"\n }\n }\n ]\n ],\n \"plugins\": [[\"transform-object-rest-spread\", { \"useBuiltIns\": true }]]\n }\n \n```\n\nの指している内容が分かりません。\n\n<https://babeljs.io/docs/usage/babelrc/> \nも見ましたがよく分かりませんでした。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T02:34:43.440", "favorite_count": 0, "id": "42313", "last_activity_date": "2018-09-28T22:32:47.917", "last_edit_date": "2018-09-28T22:32:47.917", "last_editor_user_id": "19110", "owner_user_id": "25876", "post_type": "question", "score": 1, "tags": [ "javascript", "node.js", "electron", "babeljs" ], "title": ".babelrcのpresets, pluginsが何を指しているか分かりません。", "view_count": 666 }
[ { "body": "babelの自体ではなく、個別のプラグインの設定なので[babel-preset-\nenv](https://babeljs.io/docs/plugins/preset-env/)と[transform-object-rest-\nspread](https://babeljs.io/docs/plugins/transform-object-rest-\nspread/)にそれぞれ解説があります。\n\n最新か1つ前のバージョンのChromeと今ビルドに使っているバージョンのNodeを対象にbabelで変換しています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T08:20:16.100", "id": "42345", "last_activity_date": "2018-03-12T08:20:16.100", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "241", "parent_id": "42313", "post_type": "answer", "score": 1 } ]
42313
42345
42345
{ "accepted_answer_id": "42322", "answer_count": 3, "body": "画像を添付する表記方法として \n`![alt用テキスト](画像URL)` \nとなっているようですがローカルに保存した画像を上記の表記方に沿って添付しようとすると代替テキストが表示されるだけとなってしまいます。\n\nどなたか、アドバイスして頂けたら幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T07:13:03.110", "favorite_count": 0, "id": "42318", "last_activity_date": "2018-03-13T03:25:26.617", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27697", "post_type": "question", "score": 1, "tags": [ "markdown" ], "title": "markdownでローカルに保存した画像を添付する方法がわかりません。", "view_count": 20125 }
[ { "body": "`file:///path/to/image.jpg`のように、`http://`の代わりに`file:///`を指定するとどうでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T07:35:19.813", "id": "42319", "last_activity_date": "2018-03-11T07:35:19.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "42318", "post_type": "answer", "score": 0 }, { "body": "Markdown は元々 HTML に変換されることを意図して作られたマークアップ言語ですので、HTML 同様、ローカルファイルへの URI\nを書いてやることでリンクは可能です(たとえば相対パスを直接書いたり、 `file:///path/to/file` を使ったり)。\n\nただし、整形後の Markdown を表示する際どのように表示しているかによって、ローカルの画像がどのように扱われるかが処理系依存になります。たとえば\nMarkdown を HTML に変換してブラウザで閲覧する場合、セキュリティへの懸念のため、ローカルファイルへの URI\nは開かれない設定になっていることが[多いです](https://stackoverflow.com/a/32575280/5989200)。エディタの簡易表示プラグインを使って表示している場合も同様の問題があります。\n\nこのため、ご自身の環境のみにおいて表示するワークアラウンドは上述の通りあるかもしれませんが、万人が同様に表示できるような方法は(あったとしても)採用しないことが望ましいでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T09:36:06.753", "id": "42322", "last_activity_date": "2018-03-11T09:36:06.753", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "42318", "post_type": "answer", "score": 0 }, { "body": "[`data:` URL](https://developer.mozilla.org/en-\nUS/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) を使ってみてはいかがでしょうか。 \n画像ファイルから `data:` URLを作成するのは 自分で base64 エンコードしてもいいですしジェネレータもいくつもあります。(例\n<http://dataurl.net/#dataurlmaker> ) \nこれでできた `data:image/` なんたら という文字列を `![代替テキスト](data:image/…)` のように通常の http(s)\nURLの代わりに入れます。\n\nVisual Studio Code 1.21 でプレビュー表示できました。\n\nただし\n\n * ブラウザによっては大きい画像は表示できない。\n * 文書としてはメンテナンスしづらい大変なものになる。受け取った人がここの画像をちょっと修正して差し替えようとか困難になる。\n\nといった問題はあります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T03:25:26.617", "id": "42365", "last_activity_date": "2018-03-13T03:25:26.617", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5469", "parent_id": "42318", "post_type": "answer", "score": 2 } ]
42318
42322
42365
{ "accepted_answer_id": "43097", "answer_count": 1, "body": "以下のようなスライダーの制作をしたいのですが、良いプラグインなどご存知の方はいらっしゃらないでしょうか。自作を試みたもののさっぱり出来上がりませんでした。\n\n * **スライドアウト** でスライドが入れ替わる\n * **若干ズームアウトしつつ** 画像が表示される\n\n参考サイト:[スライダー参考サイト](https://maquillage.shiseido.co.jp/)\n\n上記2点以外の要素の実装はしません。 \nスクラッチが難しそうなので可能であればプラグインを改変する程度で済ませたいと考えています。 \nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T09:54:56.557", "favorite_count": 0, "id": "42324", "last_activity_date": "2018-04-09T11:19:06.857", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27699", "post_type": "question", "score": 0, "tags": [ "html", "jquery", "css" ], "title": "スライドアウトでスライドが入れ替わり、若干ズームアウトしつつ画像が表示されるスライダーの制作", "view_count": 1297 }
[ { "body": "vegas.jsはどうでしょうか? \n<https://vegas.jaysalvat.com/>\n\nドキュメントにあるslideLeftなどのトランジションとkenburnsアニメーションを組み合わせると良いかと思います。 \n動きが気に入らなければ自分でcssアニメーションを書くこともできます(custom transitions, custom animations参照) \n<http://vegas.jaysalvat.com/documentation/transitions/>", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-04-09T11:19:06.857", "id": "43097", "last_activity_date": "2018-04-09T11:19:06.857", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25345", "parent_id": "42324", "post_type": "answer", "score": 0 } ]
42324
43097
43097
{ "accepted_answer_id": "42360", "answer_count": 1, "body": "◆(1) \n<https://plnkr.co/edit/QvG8I73sgQ5ox4LZhGwZ?p=preview> \nのtoggleFlyInOutのスライドするアニメーションと \n◆(2) \n<http://tsudoi.org/weblog/?p=2031> \nのようなng-viewを組み合わせて、ページのスライド遷移を考えているのですが、 \nAngular4で◆(2)のようなng-viewの切り替えはできないでしょうか?\n\n◆(2)のapp.jsは app-routing.module.tsのようになると思うのですが \ncontrollers.jsをどのようにAngular4で表現すればよいのでしょうか\n\n■JavaScript – app.js\n\n```\n\n var myApp = angular.module('app', ['ngRoute','ngAnimate']);\n \n myApp.config(['$routeProvider',\n function($routeProvider){\n $routeProvider.when('/photo0/', {\n templateUrl: 'templateA.html',\n controllerAs: 'CtrlA'\n });\n $routeProvider.when('/photo1/', {\n templateUrl: 'templateB.html',\n controllerAs: 'CtrlB'\n });\n $routeProvider.otherwise({\n redirectTo: '/photo0/'\n });\n }\n ]);\n \n```\n\n◆app-routing.module.ts\n\n```\n\n import { NgModule } from '@angular/core';\n import { Routes, RouterModule } from '@angular/router';\n \n import { Route1Component } from './route-1/route-1.component';\n import { Route2Component } from './route-2/route-2.component';\n \n const routes: Routes = [\n {\n path: 'photo0',\n component: Route1Component,\n },\n {\n path: 'photo1',\n component: Route2Component,\n }\n ];\n \n @NgModule({\n imports: [RouterModule.forRoot(routes)],\n exports: [RouterModule],\n providers: []\n })\n export class AppRoutingModule { }\n \n```\n\n■JavaScript – controllers.js\n\n```\n\n myApp.controller('MainCtrl', ['$scope', function($scope){\n $scope.msg = 'html = index.html, ng-controller = MainCtrl';\n }]);\n \n myApp.controller('CtrlA', ['$scope', function($scope){\n $scope.msg = 'html = templateA.html, ng-controller = CtrlA';\n }]);\n \n myApp.controller('CtrlB', ['$scope', function($scope){\n $scope.msg = 'html = templateB.html, ng-controller = CtrlB';\n }]);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T11:16:37.633", "favorite_count": 0, "id": "42325", "last_activity_date": "2018-03-13T01:46:33.897", "last_edit_date": "2018-03-11T13:35:01.547", "last_editor_user_id": "12842", "owner_user_id": "12842", "post_type": "question", "score": 0, "tags": [ "angular4" ], "title": "AngularJSをAngular4にするには", "view_count": 93 }
[ { "body": "Angularの公式ページに「[AngularJS to Angular Quick\nReference](https://angular.io/guide/ajs-quick-\nreference#modulescontrollerscomponents)」があります。 \nAngularJSからAngularへのマイグレーションは上記を参考にされると良いかと思います。\n\nAngularJSのControllerはModules/controllers/componentsの項で示されるようにAngularではComponentsとなります。\n\n 1. Controller registrationはComponent decoratorとなります。\n\n> AngularJS\n```\n\n> angular\n> .module(\"movieHunter\")\n> .controller(\"MovieListCtrl\",\n> [\"movieService\",\n> MovieListCtrl]);\n> \n```\n\n>\n> to Angular\n```\n\n> @Component({\n> selector: 'app-movie-list',\n> templateUrl: './movie-list.component.html',\n> styleUrls: [ './movie-list.component.css' ],\n> })\n> \n```\n\n 2. Controller functionはComponent classとなります。\n\n> AngularJS\n```\n\n> function MovieListCtrl(movieService) {}\n> \n```\n\n>\n> to Angular\n```\n\n> export class MovieListComponent {}\n> \n```\n\nつまり質問文にあるphoto0に対するRoute1Component、photo1に対するRoute2Componentがそれぞれコントローラーの役割を担います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T01:46:33.897", "id": "42360", "last_activity_date": "2018-03-13T01:46:33.897", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "42325", "post_type": "answer", "score": 0 } ]
42325
42360
42360
{ "accepted_answer_id": null, "answer_count": 1, "body": "相関行列の計算の流れが理解できないです。\n\n```\n\n # 相関行列を作成\n R = np.corrcoef(X.T)\n # 対角成分を0にする\n _R = R - np.identity(10)\n #最大相関係数をとるインデックスを取得\n index = np.where(_R == _R.max())[0]\n \n```\n\nという流れで相関行列の計算を行うと思うのですが、なぜ対角成分を0にして最大相関係数をとると相関行列がもとまるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-11T15:10:37.483", "favorite_count": 0, "id": "42328", "last_activity_date": "2018-12-19T16:02:10.580", "last_edit_date": "2018-03-12T06:38:39.327", "last_editor_user_id": "19110", "owner_user_id": "27700", "post_type": "question", "score": 0, "tags": [ "python", "機械学習", "numpy", "数学" ], "title": "相関行列の計算の流れが理解できない", "view_count": 468 }
[ { "body": "このソースコードは相関行列を求めているわけではありません。相関行列自体は、[`np.corrcoef`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.corrcoef.html)\n関数によって最初に求まっています。\n\n相関行列の非対角成分は相異なる 2 つのデータの相関係数ですが、[対角成分は必ず 1\nになります](https://mathtrain.jp/correlationmatrix)。「最大相関係数をとるインデックスを取得」の部分では、この対角成分を除いた上で相関係数を最大にするインデックスを求めています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T06:45:19.953", "id": "42342", "last_activity_date": "2018-03-12T06:45:19.953", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "42328", "post_type": "answer", "score": 1 } ]
42328
null
42342
{ "accepted_answer_id": "42356", "answer_count": 1, "body": "VPNの認証サーバーを構築しようとしています。 \n以下についてご教示頂けないでしょうか。\n\nFreeRADIUSとopenLDAPはyumでインストールしました。\n\n構成:\n\nPC(Windows7) → CiscoASAルータ → Freeradius(3.0.13) → OpenLDAP(2.4.44)\n\nできること:\n\nOpenLDAPで登録したユーザーとパスワードを使用して、PC(Windows7)からのVPN認証はOK\n\n困っていること:\n\nOpenLDAPの ppolicy でパスワードの有効期限(maxPwdage)を設定しているが、 \nパスワードの有効期限が切れた状態でもVPN認証ができてしまう。\n\n知りたいこと:\n\nFreeradiusからOpenLDAPへの接続では OpenLDAPの ppolicy は効かない(無視される)?\n\n→ldapsearchコマンドなどでは \"password expire\" となり、ppolicy が効いていることは確認済み。\n\nppolicy 以外で、パスワード有効期限切れの際にVPN認証できないようにする方法はありますか?\n\nFreeRADIUSの各設定ファイルの変更点を記載いたします。\n\n```\n\n ・/etc/raddb/radiusd.conf\n auth = yes \n auth_badpass = yes\n auth_goodpass = yes\n \n ・/etc/raddb/users\n #DEFAULT Framed-Protocol == PPP\n # Framed-Protocol = PPP,\n # Framed-Compression = Van-Jacobson-TCP-IP\n \n #DEFAULT Hint == \"CSLIP\"\n # Framed-Protocol = SLIP,\n # Framed-Compression = Van-Jacobson-TCP-IP\n \n #DEFAULT Hint == \"SLIP\"\n # Framed-Protocol = SLIP\n \n DEFAULT Auth-Type = LDAP\n Fall-Through = Yes\n \n ・/etc/raddb/dictionary\n VALUE Auth-Type LDAP 5\n \n ・/etc/raddb/sites-enabled/default\n ldap\n \n Auth-Type LDAP {\n ldap\n }\n \n ldap\n \n ・/etc/raddb/mods-enabled/ldap\n server = 'server01.radius.local'\n \n port = 389\n \n identity = 'cn=admin,dc=radius,dc=local'\n password = password\n \n base_dn = 'dc=radius,dc=local'\n \n```\n\n追加で必要な情報がありましたら取得しますので、言ってください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T02:21:13.610", "favorite_count": 0, "id": "42331", "last_activity_date": "2018-04-17T06:55:02.390", "last_edit_date": "2018-03-16T23:57:27.367", "last_editor_user_id": "27427", "owner_user_id": "27427", "post_type": "question", "score": 0, "tags": [ "openldap", "vpn" ], "title": "FreeRADIUS-OpenLDAPでのパスワード有効期限の設定について", "view_count": 951 }
[ { "body": "バージョンは freeradius-3.0.13, openldap-2.4.44 でしょうか。 \nradiusd と slapd はどのように連携していますでしょうか?\n\n(A) freeradius の ldap モジュールで slapd に LDAP bind で認証 \n(B) LDAPユーザーを sssd や nslcd などで OS ユーザーに見せて、radiusd から PAM 認証 \n(C) slapd から userPassword 属性値を引いて、radiusd で認証\n\n(A) の場合、ldapsearch と同様に ppolicy が効くはずです。 \nどこかでキャッシュが効いているのかもしれません。 \n認証の際、radiusd と slapd のログを確認すると毎回アクセスがあるかどうかわかると思います。\n\n(B) の場合も ppolicy が効くはずですが、sssd, nslcd 側でキャッシュしているかもしれません。\n\n(C) の場合、ppolicy は効きません。", "comment_count": 14, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T14:43:39.057", "id": "42356", "last_activity_date": "2018-03-12T14:43:39.057", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4603", "parent_id": "42331", "post_type": "answer", "score": 0 } ]
42331
42356
42356
{ "accepted_answer_id": "42338", "answer_count": 1, "body": "**環境** \nIntelliJ IDEA 2017.3.4 \nKotlin 1.2.30 \nWindows 10 64bit\n\n下記のようなBool値を反転させるコードを書くと、`Redundant 'if' statement`という提案が表示されます。\n\n```\n\n class Foo {\n private var boolVar = false\n \n fun doSomething() {\n if (boolVar) {\n boolVar = false\n } else {\n boolVar = true\n }\n }\n }\n \n```\n\n提案の詳細は下記の通りです。\n\n```\n\n Redundant 'if' statement\n Reports if statements which can be simplified to single statements.\n For example:\n if (foo()) {\n return true\n } else {\n return false\n }\n \n can be simplified to\n return foo()\n \n```\n\n提案の内容はわかるのですが、元コードとの関連がわかりません。 \nなぜこの提案がされるのかと、改善方法について、何かわかりませんか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T02:25:54.147", "favorite_count": 0, "id": "42332", "last_activity_date": "2018-03-12T04:03:54.023", "last_edit_date": "2018-03-12T02:50:23.247", "last_editor_user_id": "3060", "owner_user_id": "17238", "post_type": "question", "score": 2, "tags": [ "kotlin", "intellij-idea" ], "title": "IDEAでKotlinのBool変数を反転させるコードを書くと\"Redundant 'if' statement\"という提案が表示される", "view_count": 1657 }
[ { "body": "提案の例は「ifの評価式でtrue/falseが決まるなら、`if~else`はわざわざ書かず、直接評価式の結果を返せばいいのでは?」と読めます。\n\n実際のコードでは(元の)boolVarの反転を取ればいいようなので、`!`を使って以下の様に書き換えられるのではないでしょうか。\n\n```\n\n fun doSomething() {\n boolVar = !boolVar\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T04:03:54.023", "id": "42338", "last_activity_date": "2018-03-12T04:03:54.023", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "42332", "post_type": "answer", "score": 3 } ]
42332
42338
42338
{ "accepted_answer_id": null, "answer_count": 0, "body": "**/var/log/nginx/error.logのファイル内容のエラー項目日時は何に基づいているのでしょうか?** \n・合っているか確認するためにはどうしたら良いでしょうか?\n\n> 2018/03/10 18:19:08 [error] ×××××××××××××××××××××××××××××××××× \n> 2018/03/11 16:16:26 [error] ××××××××××××××××××××××××××××××××××\n\n**環境** \n・CentOS7 \n・Nginx\n\n* * *\n\n**追記分**\n\n確認日時 \n・2018/3/12\n\nファイル名 \n・error.log-20180312\n\nファイル最終更新日時 \n・2018/3/11 16:00:00\n\nファイルに記載された最新内容\n\n> 2018/03/11 16:00:00 [error] 10680#10680: *63 FastCGI sent in stderr: \n> \"Primary script unknown\" while reading response header from upstream, \n> client: 多分、何かのIPアドレス, server: localhost, request: \"GET \n> //MyAdmin/scripts/setup.php HTTP/1.1\", upstream: \n> \"fastcgi://unix:/var/run/php-fpm.sock:\", host: \"IPアドレス\"\n\n・質問主旨としては、ファイルの最終更新日時がOSのシステム日時に基づく?\nのだとしたら、Nginxエラー内容に記載されている時間は何に基づくのか知りたい、というものです \n・Nginxには、何か日時を合わせるような設定はあるでしょうか?", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T03:52:55.007", "favorite_count": 0, "id": "42337", "last_activity_date": "2018-03-12T10:07:04.030", "last_edit_date": "2018-03-12T10:07:04.030", "last_editor_user_id": "7886", "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "centos", "nginx" ], "title": "「/var/log/nginx/error.log」のファイル内容に記載されている日時が合っているか確認したい", "view_count": 653 }
[]
42337
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "Swiftについての質問です。\n\nXcodeを開き`Creat a new project, single view\napp`で作成し、TableViewを2つ作りました。そして、2つのTableViewをつなぎ、片方にSwitchを付けました。コードは何も書いていません(初期状態のままです)。\n\n写真の`Main.storyboard`の右側のTableViewでSwitchをoffにし、左のTableViewに移動。そして、また右のTableViewに戻ると、Switchがonの状態に戻っています。\n\nStepperで同様のことをしても戻ってしまいます。 \n原因がわかる方、ご回答をお願いします。\n\n[![Xcodeのスクリーンショット](https://i.stack.imgur.com/yqjrF.png)](https://i.stack.imgur.com/yqjrF.png)\n\n```\n\n import UIKit\n \n class ViewController: UIViewController {\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view, typically from a nib.\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n \n \n }\n \n```\n\n```\n\n #import <Foundation/Foundation.h>\n #import <UIKit/UIViewController.h>\n #import <UIKit/UITableView.h>\n #import <UIKit/UIKitDefines.h>\n \n // Creates a table view with the correct dimensions and autoresizing, setting the datasource and delegate to self.\n // In -viewWillAppear:, it reloads the table's data if it's empty. Otherwise, it deselects all rows (with or without animation) if clearsSelectionOnViewWillAppear is YES.\n // In -viewDidAppear:, it flashes the table's scroll indicators.\n // Implements -setEditing:animated: to toggle the editing state of the table.\n \n NS_ASSUME_NONNULL_BEGIN\n \n NS_CLASS_AVAILABLE_IOS(2_0) @interface UITableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>\n \n - (instancetype)initWithStyle:(UITableViewStyle)style NS_DESIGNATED_INITIALIZER;\n - (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil NS_DESIGNATED_INITIALIZER;\n - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;\n \n @property (nonatomic, strong, null_resettable) UITableView *tableView;\n @property (nonatomic) BOOL clearsSelectionOnViewWillAppear NS_AVAILABLE_IOS(3_2); // defaults to YES. If YES, any selection is cleared in viewWillAppear:\n \n @property (nonatomic, strong, nullable) UIRefreshControl *refreshControl NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;\n \n @end\n \n NS_ASSUME_NONNULL_END\n \n```\n\nアドバイスありがとうございます。自分でなんとか頑張ってやってみます。最近始めたばかりなので、Swiftもこのサイトの使い方も無知で申し訳ないです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T06:00:39.717", "favorite_count": 0, "id": "42340", "last_activity_date": "2018-03-12T19:37:08.837", "last_edit_date": "2018-03-12T19:37:08.837", "last_editor_user_id": "3068", "owner_user_id": "27705", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "Tableviewを移動して、また戻るとSwitchが初期化されてしまっている", "view_count": 271 }
[]
42340
null
null
{ "accepted_answer_id": "42348", "answer_count": 1, "body": "Nginxで管理しているすべてのバーチャルホストにBasic認証を掛け、特定のサイトのみ認証フローをスキップさせたいと考えております。\n\n当初HTTPブロックで上記を実現しようとしましたが、IfモジュールはHTTPブロックでは使用できませんでした(設定内容は後述)。各バーチャルホストのServerブロックに記述すれば、動作するとは思いますが、なるべく一カ所にまとめて記述することで見通しをよくし、一括で管理できればと考えております。\n\n何か良い解決策があればご教授いただければ幸いです。\n\n下記は、失敗時の設定サンプルです。(nginx.conf HTTPブロック内)\n\n```\n\n # Basic認証除外リスト \n map $http_host $skip_auth_host { \n default false;\n sample-AAA.com true;\n sample-BBB.com true;\n } \n # Basic認証 \n if ($skip_auth_host = true) { \n auth_basic \"basic authentication\"; \n auth_basic_user_file pathto/htpasswd; \n } \n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T06:58:08.663", "favorite_count": 0, "id": "42343", "last_activity_date": "2018-03-12T11:19:58.863", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26950", "post_type": "question", "score": 0, "tags": [ "nginx" ], "title": "Nginxの条件判定とBasic認証について", "view_count": 454 }
[ { "body": "これが適切な方法かはわかりませんが、map内で`auth_basic`の値を直接セットすることで`if`ディレクティブを用いずにそのような条件分岐が可能にはなるはずです。\n\n```\n\n map $http_host $auth_basic_attr { \n default false;\n sample-AAA.com \"basic authentication\";\n sample-BBB.com \"basic authentication\";\n }\n \n auth_basic $auth_basic_attr; \n auth_basic_user_file pathto/htpasswd; \n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T10:25:28.023", "id": "42348", "last_activity_date": "2018-03-12T10:25:28.023", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2376", "parent_id": "42343", "post_type": "answer", "score": 0 } ]
42343
42348
42348
{ "accepted_answer_id": "42347", "answer_count": 4, "body": "様々なstr要素が含まれるリストから、日本語(ひらがな、カタカナ、漢字)以外の物を削除するコードを書いたのですが、何度も実行しないと全て消えてくれません。どうやら数字、アルファベットは一括で消すことが出来ても、記号を一つ消すたびにbreak(?)してしまうように見えるのですが・・・どうしたらいいのでしょうか。\n\n```\n\n import re\n bag_of_things = [\"あいうえお\", \"546\", \"たぬき\", \"饅頭\", \"abdf\", \"#%&\", \"aodih\", \" \", \"hello\", \"こんにちは\"]\n nihongo = re.compile('[ぁ-んァ-ン一-龥]+')\n \n \n def clean(list):\n for item in list:\n if not nihongo.findall(item):\n print(item, \"is not japanese\")\n list.remove(item)\n \n```\n\n[![結果\\[1\\]](https://i.stack.imgur.com/bMocf.png)\n\n[![関数](https://i.stack.imgur.com/y8UhK.png)](https://i.stack.imgur.com/y8UhK.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T08:09:12.147", "favorite_count": 0, "id": "42344", "last_activity_date": "2018-03-14T00:53:47.097", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27710", "post_type": "question", "score": 3, "tags": [ "python", "正規表現" ], "title": "リストから日本語以外の要素を削除したい", "view_count": 3580 }
[ { "body": "申し訳ないです、自己解決しました。。。 \n日本語の要素だけを含む新しいリストを作りました。。。\n\n```\n\n nihongo = re.compile('[ぁ-んァ-ン一-龥]+') # used in def clean(list):\n \n \n def clean(list):\n new_list = []\n for item in list:\n if nihongo.findall(item):\n new_list.append(item)\n return new_list\n \n list = clean(list) # 日本語ワードだけを含むリストを作成。\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T08:43:44.917", "id": "42346", "last_activity_date": "2018-03-12T08:43:44.917", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27710", "parent_id": "42344", "post_type": "answer", "score": 2 }, { "body": "for文の途中で、forで回しているlistの要素を削除しているため、対象オブジェクトがずれてしまっているのが原因です。\n\n```\n\n >>> L = list(range(10))\n >>> L\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n >>> for l in L:\n ... print(l)\n ... L.remove(l)\n ... \n 0\n 2\n 4\n 6\n 8\n >>> L\n [1, 3, 5, 7, 9]\n \n```\n\n対処方法はいくつかあります。 \n1\\. すでに自己解決されているように、対象リストから`remove`するのではなく対象を抽出して別のリストにいれるか。 \n2\\. ループは対象リストのコピーに対して行うか。\n\n```\n\n >>> L = list(range(10))\n >>> for l in L[:]:\n ... print(l)\n ... L.remove(l)\n ... \n 0\n 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n >>> L\n []\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T08:51:10.757", "id": "42347", "last_activity_date": "2018-03-12T08:51:10.757", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "42344", "post_type": "answer", "score": 4 }, { "body": "既に解決済みとの事ですが、 reversed() 使っても良いのでは?\n\n```\n\n def clean(list):\n for item in reversed(list):\n if not nihongo.findall(item):\n print(item, \"is not japanese\")\n list.remove(item)\n \n```\n\n単に逆順からの検索を行うだけです。\n\n* * *\n\n追記\n\nもっと簡単な方法がある筈と思ったら、\n\n> **filter** (lambda item: nihongo.findall(item), list)\n\nで良いみたいですね。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T12:48:28.907", "id": "42355", "last_activity_date": "2018-03-12T14:19:45.967", "last_edit_date": "2018-03-12T14:19:45.967", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "42344", "post_type": "answer", "score": 3 }, { "body": "try this:\n\n```\n\n def clean(list):\n return [e for e in list if nihongo.findall(e)]\n \n bag_of_things = clean(bag_of_things)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T00:53:47.097", "id": "42377", "last_activity_date": "2018-03-14T00:53:47.097", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27732", "parent_id": "42344", "post_type": "answer", "score": 1 } ]
42344
42347
42347
{ "accepted_answer_id": "42353", "answer_count": 2, "body": "bashでの質問です。OSはCentOSです。\n\n仮に`/etc`のようなrootユーザ以外は書き込めない場所にファイルを書き込もうとしたところ、\n\n```\n\n sudo ls > /etc/test.txt\n \n```\n\nとすると、lsコマンドはrootで実行できますが、>以降のファイルはroot権限ではありません。 \nこのような場所でも書き込めるような方法はありますか? \n一応、suコマンドでrootになってから実行すると実行可能ですが、su以外でお願いしたく。\n\nご存知の方、ご教授お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T12:10:28.523", "favorite_count": 0, "id": "42352", "last_activity_date": "2020-07-25T06:46:13.343", "last_edit_date": "2020-07-25T06:46:13.343", "last_editor_user_id": "3060", "owner_user_id": "8593", "post_type": "question", "score": 7, "tags": [ "bash", "sudo" ], "title": "リダイレクトでrootユーザしか書き込めない場所にsudoで書き込むには", "view_count": 438 }
[ { "body": "```\n\n sudo ls | sudo tee /etc/test.txt\n \n```\n\nでいかがでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T12:20:25.583", "id": "42353", "last_activity_date": "2018-03-12T12:20:25.583", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17037", "parent_id": "42352", "post_type": "answer", "score": 6 }, { "body": "`man sudo`を眺めていると出て来る例を参考に、\n\n```\n\n sudo sh -c \"ls > /etc/test.txt\"\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T12:23:09.220", "id": "42354", "last_activity_date": "2018-03-12T12:23:09.220", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "42352", "post_type": "answer", "score": 9 } ]
42352
42353
42354
{ "accepted_answer_id": "42358", "answer_count": 1, "body": "PythonとFlaskを使ってwebアプリを制作しているのですが、python計算して出てきたデータをjavascriptに渡してそこでさらに計算をさせたいです。\n\n例えばPythonでプログラムを実行して以下のようなデータが出来たとします。 \ntime = [2018, 3, 15, 9, 18]\n\nそれをFlaskというpythonのフレームワークは\n\n```\n\n render_template(\n 'result.html',\n time=time)\n \n```\n\nのように記述することでhtmlの方にtimeのリスト変数を渡す事が出来ます。\n\nしかしその変数をjavascriptで使用したい場合jsonファイルに変換して渡す方法と \n<https://code.i-harness.com/ja/q/aa91ba>\n\ninputタグに隠しデータとして記述してjQueryで取り出す方法があるとわかりました。\n\n1番目の方法はjsonで配列を記述することはできるのか? \njsonはpythonで言う辞書型でデータが保存されているのをよく見かけるので配列で保存できるのか \nわかりません。 \n記述はflaskで使用しているテンプレートエンジンJinja2を使って \nhtmlファイルに以下のような記述をすることでPythonからテンプレートエンジンに渡った変数をjsonファイルに変換してjavascriptに渡せると言うものでした。\n\n```\n\n <script>\n var time = {{ time|tojson }};\n </script>\n \n```\n\nこれをみて思ったのですが、tojsonをなしにすればtimeをそのままjavascriptの変数にリストを代入する事ができると思うのですが現在、実行できる環境がないのでわかりません。2日後にはパソコンが届くので届いたら実行したいと思います。\n\n2番目の方法はinputタグのvalueに配列で保存してそれをjQueryで取り出す方法なのですが \n1番目に比べるとスッキリしない感じがするので何か他にいい方法はないでしょうか?\n\n教えて頂けると幸いです。 \nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T14:58:01.987", "favorite_count": 0, "id": "42357", "last_activity_date": "2018-03-12T15:31:07.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "javascript", "python", "python3", "json", "flask" ], "title": "pythonの変数をjavascriptで受け取るには?", "view_count": 8645 }
[ { "body": "flaskにはあまり詳しくないのですが・・・\n\nJSONで配列を扱うことは可能です。なので`time|tojson`でparseできるはずです。\n\n[JSON - JavaScript |\nMDN](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/JSON)\n\n以下は上記のリンク先からの引用です。\n\n> JSON は、オブジェクト、 **配列** 、数値、文字列、真偽値、そして null をシリアライズする構文です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T15:31:07.113", "id": "42358", "last_activity_date": "2018-03-12T15:31:07.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5246", "parent_id": "42357", "post_type": "answer", "score": 0 } ]
42357
42358
42358
{ "accepted_answer_id": null, "answer_count": 1, "body": "階層のマスタなどを選択して行って、最後の階層で選択を確定した場合に、複数画面戻る機能を実装したいと考えています。\n\nとりあえず今は下のように書いてしまっています。\n\n```\n\n // 3画面戻る\n Navigation.PopAsync(false).Wait(1);\n Navigation.PopAsync(false).Wait(1);\n Navigation.PopAsync(false).Wait(1);\n \n```\n\nもっとうまいやり方がありそうな気がしているのですが、、ご存知の方がいらっしゃれば教えてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-12T17:12:41.737", "favorite_count": 0, "id": "42359", "last_activity_date": "2018-03-13T02:13:29.803", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27715", "post_type": "question", "score": 1, "tags": [ "xamarin" ], "title": "Xamarinでボタンを押した時に複数画面戻る方法", "view_count": 944 }
[ { "body": "基本的には`Navigation.PopAsync()`3回で問題ありませんが、`Task.Wait(1)`では完了が保証されないため、単に`Wait()`とするか\n\n```\n\n async void SomeMethod() // asyncを付加する\n {\n await Navigation.PopAsync(false);\n await Navigation.PopAsync(false);\n await Navigation.PopAsync(false);\n }\n \n```\n\nのように非同期メソッド化すべきです。\n\nまた遷移対象がルートページであれば、`PopToRootAsync`が使用できます。\n\nもしくは事前に履歴を削除しておくこともできます。\n\n```\n\n void SomeMethod()\n {\n Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);\n Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);\n Navigation.PopAsync(false);\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T02:13:29.803", "id": "42361", "last_activity_date": "2018-03-13T02:13:29.803", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "42359", "post_type": "answer", "score": 1 } ]
42359
null
42361
{ "accepted_answer_id": null, "answer_count": 1, "body": "タイトルの通りですが、 Rails 5 + Puma + Nginx の構成で、メモリが決まった時間(毎時57分ごろ)に解放されるのは仕様でしょうか?\n\n主な利用バージョンは下記の通りです。\n\n * Ruby: 2.4.2\n * Ruby on Rails: 5.0.6\n * Puma: 3.11.2\n * Nginx: 1.12.2\n\nサーバーは 3 台あり、下記のような構成になっています。\n\n```\n\n A サーバー (Nginx) ┬ B サーバー (Puma)\n └ C サーバー (PUma)\n \n```\n\nおそらく Puma のメモリかなと思っていまして、 Puma\nにそのような機能があるか調べて見たのですが、そういった仕様を確認することができませんでした。(メモリが解放されるタイミングで、 Puma の worker\nのプロセス ID が変わっていたので、 Puma の worker が再起動されたように見受けられます。)\n\n下記は NewRelic の Memory Used % のグラフですが、青と赤の線が Puma\nの動いているサーバーで、前述の毎時57分ごろにメモリ使用量がガクッと下がっていることが確認できます。\n\n[![Memory Used\n%](https://i.stack.imgur.com/1WIHw.png)](https://i.stack.imgur.com/1WIHw.png)\n\nちなみに、 puma_worker_killer は使用していません。\n\nそこでお伺いしたのですが、これは Puma 、 Nginx (または Rails\n)の仕様でしょうか?仕様である場合、仕様が書かれたドキュメントがあればご教示いただきたいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T02:17:57.280", "favorite_count": 0, "id": "42362", "last_activity_date": "2019-07-23T06:39:49.057", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8160", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails", "nginx" ], "title": "Ruby on Rails 5 + Puma + Nginx の構成で、メモリが決まった時間に解放されるのは仕様でしょうか?", "view_count": 583 }
[ { "body": "本件ですが、 Linux OS の logrotate で Rails アプリケーションのログのローテーションしていたのですが、ログローテート時に puma\nを再起動していたためでしたmm (再起動しないと puma が新しい出力先にログを出力しないため。)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-23T06:39:49.057", "id": "56836", "last_activity_date": "2019-07-23T06:39:49.057", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8160", "parent_id": "42362", "post_type": "answer", "score": 2 } ]
42362
null
56836
{ "accepted_answer_id": "42412", "answer_count": 2, "body": "phpにおける動的変数と静的変数の概念は、C言語についての[知恵袋の回答](https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q13117262228)の\n\n> 値を格納する領域を動的変数では動的に確保し、静的変数では静的に確保する…のですが、これでは何のことかさっぱり判りませんね。\n>\n> 静的変数はプログラム実行開始時にメモリのどこかに変数の領域を確保し、そのプログラムが終了するまでその領域を使い続けます。\n>\n>\n> 例えば、関数hogeの中で静的変数sを定義したとします。そして関数hogeを呼び出して、静的変数sに何かしらの値を代入し、そこからリターンしても静的変数sの領域は確保されたままです。\n>\n>\n> このため、次に関数hogeを呼び出したときに静的変数sが保持している値は前回関数hogeからリターンしたときの静的変数sの値をそのまま保持しています。そしてプログラムが終了すると、静的変数sの領域は破棄されます。\n>\n>\n> なお、この静的変数sの値を関数hoge以外からも参照できるというわけではありませんので、誤解なきよう(ポインターを使って間接的に参照するのであれば別ですが)。\n>\n>\n> 動的変数は関数が呼び出されたときにメモリ上のどこかに領域が確保され、関数からリターンするとその領域は破棄されます。やはり関数hogeの中で動的変数dを定義したとします。この動的変数dの領域は関数hogeが呼び出されるまではメモリ上のどこにも存在しません。\n>\n>\n> 関数hogeが呼び出されると動的変数dの領域が確保され、何かしらの値を代入できるようになります。そして関数hogeからリターンすると、この動的変数dの領域は破棄されます。\n>\n>\n> このため、関数hogeが呼び出されるたびに動的変数dはメモリ上の違う領域(同じ領域である可能性もありますが、同じ領域が使われる保証はありません)が使用されます。\n>\n>\n> 以上の事が関数の動作にどのように関わってくるかですが、関数が内部情報を保持せず、また同時に複数の場所から呼び出されないなら、静的変数でも動的変数でも同じです。\n>\n>\n> しかし、関数が内部情報を保持するためには静的変数を使用しなければなりません。例えば、ある関数が何回呼び出されたかを数えて、10回呼び出されるごとに特別な処理を行いたいとします。\n>\n> この場合、呼び出された回数は静的変数に保持しなければなりません。動的変数だと関数からリターンするたびに変数の値は破棄されてしまいますから。\n\nと同じようなものなのでしょうか。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T02:46:48.453", "favorite_count": 0, "id": "42364", "last_activity_date": "2018-03-15T09:02:26.057", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "27720", "post_type": "question", "score": 2, "tags": [ "php" ], "title": "動的変数と静的変数の概念", "view_count": 3370 }
[ { "body": "おおむね、その知恵袋の回答で合っていると思います。\n\nPHPだとグローバル変数とstatic変数が静的変数で、その他は動的変数になると思います。 \n↑こちらコメントにご指摘により以下のように修正します。 \n動的変数は静的変数とグローバル変数を除いたものではないでしょうか。\n\n<http://php.net/manual/ja/language.variables.scope.php#language.variables.scope.static>", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T00:48:23.680", "id": "42376", "last_activity_date": "2018-03-14T01:40:08.703", "last_edit_date": "2018-03-14T01:40:08.703", "last_editor_user_id": "2232", "owner_user_id": "2232", "parent_id": "42364", "post_type": "answer", "score": 0 }, { "body": "「静的変数 (static variables)」についての説明は、ご提示のものが C 言語でも PHP でも概ね正しいです。\n\nただし細かいことを言うと、「静的変数」という言葉には 2 つの意味があります。\n\n 1. 静的な記憶域期間 (static storage duration) を持つ変数\n 2. `static` 指定子がついた変数\n\n前者の意味で「静的変数」と言うのであれば、グローバル変数は常に静的変数であり、C 言語でも PHP でもご提示の文章は正しいです。しかし PHP\nの[このマニュアル](http://php.net/manual/ja/language.variables.scope.php#language.variables.scope.static)で使われている「静的変数」については\n\n> 静的変数はローカル関数スコープのみに 存在します\n\nと書かれているため、グローバル変数を含んでおらず、どちらかというと後者の使い方です。後者の意味の場合、ご提示の文章は部分的に正しくないです。ここでは英語版\nWikipedia の [\"Static variable\"\nについての記事](https://en.wikipedia.org/wiki/Static_variable)が前者の意味で書かれていたので前者が一般的な用法であると判断しました。\n\n* * *\n\n「動的変数 (dynamic variables)」については議論が必要です。この単語は、少なくとも [PHP\nのマニュアル](http://php.net/manual/en/) には載っていません。PHP は C 言語と違って\n[GC](http://php.net/manual/ja/features.gc.php)\nのある動的型付けプログラミング言語ですので、スタック及びヒープの使い方が C\n言語と異なります(この点については、ブログ記事[「メモリとスタックとヒープとプログラミング言語」](http://keens.github.io/blog/2017/04/30/memoritosutakkutohi_puto/)が参考になります)。したがってどのような変数を「動的変数」と呼ぶべきなのか、私は知りません。\n\nまた C 言語においても、「動的変数」という言葉は曖昧だと **私は** 思います。類似概念である[「自動変数 (automatic\nvariables)」](https://en.wikipedia.org/wiki/Automatic_variable)には仕様レベルの定義があり、こちらの方がよく使われているように私は思います。ただし、周りの友人に聞いてみたところ「動的変数」を使っている方々もいらっしゃるようなので、この限りではありません。\n\n**補足** : 今回の「動的変数」とは別に、Common Lisp には「動的変数 (dynamic variables)」ないし「スペシャル変数\n(special variables)」という言葉が存在します。これは lexical scope / dynamic scope\nを区別するための言い方です。詳しくは [M. Hiroi\nさんの解説](http://www.geocities.jp/m_hiroi/xyzzy_lisp/abclisp10.html)や、\"Practical\nCommon Lisp\" の[第 6 章](http://www.gigamonkeys.com/book/variables.html)が参考になります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T08:56:55.870", "id": "42412", "last_activity_date": "2018-03-15T08:56:55.870", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "42364", "post_type": "answer", "score": 3 } ]
42364
42412
42412
{ "accepted_answer_id": null, "answer_count": 1, "body": "あるcomponentでcomponentWillUpdate()をし、 \nstate、またはpropsが更新されたタイミングで子のcomponentにpropsで親のcomponentのstateを渡したいのですがどうすればできますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T05:59:44.160", "favorite_count": 0, "id": "42369", "last_activity_date": "2018-03-15T19:47:17.650", "last_edit_date": "2018-03-13T13:02:06.910", "last_editor_user_id": "19110", "owner_user_id": "27707", "post_type": "question", "score": 0, "tags": [ "reactjs" ], "title": "componentWillUpdate()時に子のcomponentにpropsでstateを渡したい", "view_count": 61 }
[ { "body": "React単体でどうにかできなくもないですが,要件的にRedux使ったほうがいいんじゃないでしょうか?Reduxじゃないと今後複雑さに耐えられないにおいがプンプンします…\n\nReduxであればこの手の問題は簡単に解決できますね。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T19:47:17.650", "id": "42419", "last_activity_date": "2018-03-15T19:47:17.650", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "940", "parent_id": "42369", "post_type": "answer", "score": 1 } ]
42369
null
42419
{ "accepted_answer_id": null, "answer_count": 1, "body": "以下ASP.NET(VB.NET)で作成したあるWebページですが、イメージボタンが押下されたらセッション変数の値によってはまったく別のサイトのhtmlを開きたいです。(セッション変数が2でない時) \nwindow.openを起動するJSをどのようにして動かせばよろしいでしょうか? \n以下で画面が開きません\n\n```\n\n Protected Sub ImageButton2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)\n If Session(\"UserLevel\") <> \"2\" Then\n Dim startupScript As String = \"<script language='JavaScript'> window.open('http://XXXXXXXXXX/XXXXXXX/logon.html')</ Script > \"\n Page.RegisterStartupScript(\"startup\", startupScript)\n Else\n Server.Transfer(\"Menu2.aspx\")\n End If\n End Sub\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T08:11:05.017", "favorite_count": 0, "id": "42370", "last_activity_date": "2022-08-15T21:05:55.533", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25696", "post_type": "question", "score": 0, "tags": [ "javascript", "asp.net" ], "title": "aspx(ASP.NET4.0)のページから、htmlのページへ遷移したい。", "view_count": 617 }
[ { "body": "`UserLevel`がページを表示してからクリックされるまでの間に変化しない前提ですが、\n\nクリックされてからジャンプ先を判定するのではなく、`Page_Load`時にリンク先を設定してしまえばいいのでは?\n\n```\n\n <asp:HyperLink ID=\"hyperLink1\" NavigateUrl=\"Menu2.aspx\" runat=\"server\">\n <img src=\"something.png\" />\n </asp:HyperLink>\n \n Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load\n If Session(\"UserLevel\") <> \"2\" Then\n hyperLink1.NavigateUrl = \"http://XXXXXXXXXX/XXXXXXX/logon.html\"\n hyperLink1.Target = \"_blank\"\n End If\n End Sub\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T09:06:34.080", "id": "42371", "last_activity_date": "2018-03-13T09:06:34.080", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "42370", "post_type": "answer", "score": 1 } ]
42370
null
42371
{ "accepted_answer_id": null, "answer_count": 0, "body": "# 概要\n\nC#で、画面のスクリーンショットを使用するツールを制作しようと考えています。 \nここで言う「スクリーンショット」とは、ディスプレイ全体のスクショに限らず、例えば「左上座標(100,100)から640x480の大きさ」といった指定ができるものを指します。 \n元々はWPFで開発しており、その際は次のようなコードを書いていました。\n\n```\n\n // 切り取る左上座標を(left, top)、切り取る大きさを(width,height)とする\n var image = new System.Drawing.Bitmap(\n width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);\n using (var g = System.Drawing.Graphics.FromImage(image)) {\n g.CopyFromScreen(left, top, 0, 0, image.Size);\n }\n \n```\n\nここで、Windows以外でも動くように出来ないかと考えた私は、[Eto.Forms](https://www.nuget.org/packages/Eto.Forms/)をNugetで落として使おうと判断しました。Eto.FormsにもBitmapクラスやGraphicsクラスがあったので、簡単に移植できると考え次のようなコードを書きました。\n\n```\n\n // 切り取る左上座標を(left, top)、切り取る大きさを(width,height)とする\n var image = new Eto.Drawing.Bitmap(\n width, height, Eto.Drawing.PixelFormat.Format24bppRgb);\n using (var g = Eto.Drawing.Graphics(image)) {\n g.CopyFromScreen(left, top, 0, 0, image.Size); //問題の箇所\n }\n \n```\n\nところが、`Eto.Drawing.Graphics`には`CopyFromScreen`メソッドが存在しないということがここで判明しました。[APIリファレンス](http://api.etoforms.picoe.ca/html/T_Eto_Drawing_Graphics.htm)を見てもそのことに違いはありませんし、かといって`Eto.Forms.Screen`から直接`Eto.Drawing.Bitmap`を取り出す手段も存在しないようです。 \nWindowsだけを考えればよかった時と違い、「WinAPIを叩く」といった手段を取れないことから、スクリーンショットをどう取得すればいいのか分からず困っています。\n\n上手くメソッドを組み合わせれば、スクリーンショットを取得することができるのでしょうか、それとも現状の仕様ではできないのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-13T16:55:46.420", "favorite_count": 0, "id": "42374", "last_activity_date": "2018-03-13T16:55:46.420", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12939", "post_type": "question", "score": 1, "tags": [ "c#", "linux", "windows" ], "title": "Eto.Formsでスクリーンショットを取得したい", "view_count": 159 }
[]
42374
null
null
{ "accepted_answer_id": "42403", "answer_count": 1, "body": "google big queryでのSQLで、 \nグループ別の合計に対する比率を出す方法に悩んでおります。 \n(通常のsqlの回答でもうれしいです) \n用意しているテーブルは以下です。\n\n```\n\n score_data\n +--------+-------+------+\n | userID | score | age |\n +--------+-------+------+\n | 1 | 100 | 5 |\n | 2 | 113 | 14 |\n | 3 | 250 | 19 |\n | 4 | 300 | 35 |\n | 5 | 450 | 42 |\n | ... | ... | ... |\n +--------+-------+------+\n \n age_group(例: age:0~20の人はage_group_id が1)\n +--------------+-------+------+\n | age_group_id | min | max |\n +--------------+-------+------+\n | 1 | 0 | 20 |\n | 2 | 21 | 40 |\n | 3 | 41 | 60 |\n +--------------+-------+------+\n \n score_range(例: score:0~100の人はrange_idが1)\n +----------+----------------+------+------+\n | range_id | name | min | max |\n +----------+----------------+------+------+\n | 1 | bad luck | 0 | 100 |\n | 2 | uncertain luck | 101 | 200 |\n | 3 | fair luck | 201 | 300 |\n | 4 | good luck | 301 | 400 |\n | 5 | best luck | 401 | 500 |\n +----------+----------------+------+------+\n \n```\n\n欲しいテーブルは以下のような要素のテーブルです。\n\n```\n\n dist_data\n +----------------+-------------+---------------+--------------+\n | name | user_count | age_group_id | ratio_in_ag |\n +----------------+-------------+---------------+--------------+\n | bad luck | 10 | 1 | 10 |\n | bad luck | 0 | 2 | 0 |\n | bad luck | 20 | 3 | 20 |\n | uncertain luck | 20 | 1 | 20 |\n | uncertain luck | 0 | 2 | 0 |\n | uncertain luck | 10 | 3 | 10 |\n | fair luck | 30 | 1 | 30 |\n | fair luck | 70 | 2 | 70 |\n | fair luck | 20 | 3 | 20 |\n | good luck | 30 | 1 | 30 |\n | good luck | 30 | 2 | 30 |\n | good luck | 40 | 3 | 40 |\n | best luck | 10 | 1 | 10 |\n | best luck | 0 | 2 | 0 |\n | best luck | 10 | 3 | 10 |\n +----------------+-------------+---------------+--------------+\n \n```\n\nnameはscoreの範囲の名前、 \nage_group_idは、年齢の区分にあたるID、 \nuser_countは、その年齢区分でnameのスコア範囲に所属するユーザ数 \nratio_in_agは、同じage_group_idの全てのスコア範囲の合計人数に対するuser_countの割合 \nです。\n\n(例: age_group_id:1のユーザが10人、そのうちname:bad luckのユーザが1人だとすると以下のような行になります)\n\n```\n\n +----------------+-------------+---------------+--------------+\n | name | user_count | age_group_id | ratio_in_ag |\n +----------------+-------------+---------------+--------------+\n | bad luck | 1 | 1 | 10 |\n +----------------+-------------+---------------+--------------+\n \n```\n\n現在ratio_in_ag以外の値は以下のSQLで取得しています。\n\n```\n\n #standardSQL\n SELECT \n x.name, count(user_id) as user_count, age_group_id\n FROM\n (\n SELECT \n range_name, user_id, age_group_id\n FROM \n dataset.score_data\n JOIN \n dataset.age_group\n ON \n score_data.age BETWEEN age_group.min AND age_group.max\n JOIN \n dataset.score_range \n ON score_data.score BETWEEN score_range.min AND score_range.max\n ) as c \n RIGHT JOIN \n dataset.score_range as x \n ON \n c.name = x.name\n GROUP BY \n name, age_group_id\n \n```\n\nGROUP BYしたage_group_id毎のuser_countが分かれば可能だと思うのですが、 \nどう求めればよいのか、お分かりになる方ご教授お願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T02:22:55.280", "favorite_count": 0, "id": "42381", "last_activity_date": "2018-03-15T01:31:03.010", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24104", "post_type": "question", "score": 1, "tags": [ "sql", "google-bigquery" ], "title": "グループ別の合計に対する比率を出したい", "view_count": 8725 }
[ { "body": "SQL一般の話として回答します。\n\n```\n\n SELECT\n sr.name AS name\n , COUNT(*) AS user_count\n , ag.age_group_id AS age_group_id\n , (100 * COUNT(*) / sba.count_in_age_group) AS ratio_in_ag\n FROM\n score_data AS sd\n INNER JOIN age_group AS ag\n ON sd.age BETWEEN ag.min AND ag.max\n INNER JOIN score_range AS sr\n ON sd.score BETWEEN sr.min AND sr.max\n INNER JOIN\n (\n SELECT\n ag0.age_group_id\n , COUNT(*) AS count_in_age_group\n FROM\n score_data AS sd0\n INNER JOIN age_group AS ag0\n ON sd0.age BETWEEN ag0.min AND ag0.max\n GROUP BY\n ag0.age_group_id\n ) AS sba\n ON ag.age_group_id = sba.age_group_id\n GROUP BY\n sr.range_id, sr.name, ag.age_group_id\n ; \n \n```\n\nBigQuery での動作は確認していませんので参考までにどうぞ。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T01:31:03.010", "id": "42403", "last_activity_date": "2018-03-15T01:31:03.010", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27410", "parent_id": "42381", "post_type": "answer", "score": 2 } ]
42381
42403
42403
{ "accepted_answer_id": "42384", "answer_count": 2, "body": "webアプリを制作しているのですが、jQueryを使ってユーザがformで入力した値を以下のように取得しました。\n\n```\n\n <script>\n $('button').click(function () {\n \n // 選択ボックス\n m = $('#minute').val();\n console.log(m);\n });\n \n \n </script>\n \n```\n\nconsoleにちゃんと入力した値が表示されるところまではきたのですが、そのあとjQueryの関数から抜けてconsoleを実行しても値が表示されません。\n\n```\n\n <script>\n $('button').click(function () {\n \n // 選択ボックス\n m = $('#minute').val();//ここにvarを付けないとグローバルになると聞いた。\n console.log(m);\n });\n console.log(m);//mは定義されてないエラーが出る。\n \n </script>\n \n```\n\nreturn文などを使うと思うのですがJqueryを挟んでいるかで上手く代入出来ないです。 \n**試した事**\n\n```\n\n <script>\n var m = $('button').click(function () {\n \n // 選択ボックス\n var m = $('#minute').val();\n return m;\n });\n console.log(m);\n \n </script>\n \n```\n\n何かいい方法はないでしょうか?\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js\"></script>\n \n```\n\njQueryファイルは上記から読み込んでいます。 \nよろしくお願いします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T03:04:01.133", "favorite_count": 0, "id": "42382", "last_activity_date": "2018-03-14T10:51:54.423", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "jquery", "html5" ], "title": "jQueryでhtmlから取得した値をグローバル変数に代入して違うコードに渡すには??", "view_count": 10787 }
[ { "body": "Javascriptの変数スコープ \n<https://qiita.com/Kazuuuuuki/items/3c40bbe6e7bb7ff84e3e> \nはこちらを参考にしてもらうとしてソースとしてはグローバルなスコープにて変数を宣言してください。\n\n```\n\n <script>\n var m;\n $('button').click(function () {\n \n // 選択ボックス\n m = $('#minute').val();\n console.log(m);\n });\n console.log(m);\n \n </script>\n \n```\n\n===================== \n以下追記分\n\n```\n\n var m;\r\n $('button').click(function () {\r\n \r\n // 選択ボックス\r\n m = $('#minute').val();\r\n console.log(m);\r\n });\r\n console.log(m); //ここはJavascriptが読み込み時に実行されるから絶対undefined\r\n \r\n $('#console_check').click(function () {\r\n console.log(m);//ここはチェックリンクがクリックされたときに実行される。\r\n });\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script>\r\n \r\n <input id=\"minute\" type=\"text\" value=\"11\" />\r\n <button>クリック</button>\r\n \r\n <a id=\"console_check\" href=\"jacascript:void(0);\">チェック</a>\n```\n\n================ \n追記2 \nJqueryのイベントハンドラの規約になりますが、 \n通常returnに任意の値を返すことはできません。 \nreturn falseを返すと別の処理が入ります。 \n<https://qiita.com/r_abe01/items/2433caa6ce5257a440e7>", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T03:29:58.240", "id": "42384", "last_activity_date": "2018-03-14T04:41:41.397", "last_edit_date": "2018-03-14T04:41:41.397", "last_editor_user_id": "22665", "owner_user_id": "22665", "parent_id": "42382", "post_type": "answer", "score": 0 }, { "body": "```\n\n <script>\n $('button').click(function () { // --(1)\n \n var m = $('#minute').val(); // --(2)\n });\n console.log(m); // --(3)\n \n </script>\n \n```\n\n結論から言うと(3)の位置で(2)の値は取れません。 \n他の方もおっしゃるようにjsの実行タイミングが異なるからです。\n\n質問者さんはおそらくjsの実行タイミングを \n(1)→(2)→(3) \nで実行されるものと思ってらっしゃるようです。\n\n実際には \n(3)→(ボタンがクリックされる)→(1)→(2) \nとなります。\n\nそのため、ボタンが押された後で、その値を使って外側で何か処理をしたいのであれば、 \nその処理を別関数として定義しておき、その引数として実行されるべきだと思います。\n\n例えば、\n\n```\n\n <script>\n $('button').click(function () { // --(1)\n \n var m = $('#minute').val(); // --(2)\n outPutValue(m); // --(3)\n });\n function outPutValue(m) { // --(4)\n console.log(m); // --(5)\n }\n </script>\n \n```\n\nとすれば、 \n(ボタンが押される)→(1)→(2)→(3)→(4)→(5) \nの順に実行されるはずです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T10:51:54.423", "id": "42391", "last_activity_date": "2018-03-14T10:51:54.423", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "23695", "parent_id": "42382", "post_type": "answer", "score": 0 } ]
42382
42384
42384
{ "accepted_answer_id": null, "answer_count": 1, "body": "iOSでニュースアプリ制作しております。\n\n多くのニュースアプリで(おそらくアクセス数だと思われる)ランキングが24時間、一週間、一ヶ月とあります。\n\nこのようなシステムの実装方法はどのようになっているのでしょうか?", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T06:46:19.230", "favorite_count": 0, "id": "42386", "last_activity_date": "2018-03-15T07:25:57.447", "last_edit_date": "2018-03-14T08:12:17.487", "last_editor_user_id": "76", "owner_user_id": "27512", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "ニュースアプリのランキング機能", "view_count": 266 }
[ { "body": "ランキングの指標としては「記事が表示された回数」「記事をクリックして元サイトを開いた回数」などが考えられます。 \n仮に後者の「クリックされた回数」とするなら、一緒に「クリックされた日時」も記録しておけば、特定の期間ごとのランキングを集計・生成するのはそれほど難しい話ではないかと思います。\n\nコメント欄でも言及しましたが、アプリ内の閉じた環境で回数を記録してもそれはアプリ利用者個人に特化したデータになってしまうので、実際にはサーバも用意してデータを集計・配信する形になるのではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T12:15:25.100", "id": "42394", "last_activity_date": "2018-03-15T07:25:57.447", "last_edit_date": "2018-03-15T07:25:57.447", "last_editor_user_id": "3060", "owner_user_id": "3060", "parent_id": "42386", "post_type": "answer", "score": 2 } ]
42386
null
42394
{ "accepted_answer_id": "42392", "answer_count": 2, "body": "pythonで作ったリストデータをjavascriptのDate関数に送って処理させたいのですが、 \nd_train_timeには[2018, 9, 19, 8, 45]のようにデータが入っています。\n\n```\n\n var dt = new Date(d_train_time);\n var dt = new Date(2018, 9, 19, 8, 45);//本当はこうしないといけない。\n \n```\n\nなので以下の様にに配列から一個ずつ取り出して代入する方法を考えているのですが、他に良いやり方はないでしょうか?\n\n```\n\n var dt = new Date(year, month, day, hour, minute);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T10:08:26.563", "favorite_count": 0, "id": "42387", "last_activity_date": "2018-03-15T19:36:24.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "html5" ], "title": "javascriptで配列の値をきれいに代入するには??", "view_count": 157 }
[ { "body": "ECMAScript6 のスプレッド演算子をサポートしているような JavaScript\n処理系であれば、以下のようにして配列を展開して引数に渡すことが可能です。\n\n```\n\n var d_train_time = [2018, 9, 19, 8, 45];\n var dt = new Date(...d_train_time);\n \n```\n\n参考サイト\n\n * [ECMAScript6 compatible table](http://kangax.github.io/compat-table/es6/)\n * [Runtime Semantics: ArgumentListEvaluation](http://www.ecma-international.org/ecma-262/6.0/#sec-argument-lists-runtime-semantics-argumentlistevaluation)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T11:41:47.090", "id": "42392", "last_activity_date": "2018-03-14T11:41:47.090", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27410", "parent_id": "42387", "post_type": "answer", "score": 2 }, { "body": "もしBabelでトランスパイルするのであればいっそのこと`const`もつかって\n\n```\n\n const dateArgs = [2018, 9, 19, 8, 45];\n const date = new Date(...dateArgs);\n \n```\n\nのように書くことのほうが多いですが,トランスパイル無しでIE11対応もしたいときはこのシンタックスは使えませんね。\n\n```\n\n var dateArgs = [2018, 9, 19, 8, 45];\n var date = new (Date.bind.apply(Date, [null].concat(dateArgs)));\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T19:36:24.707", "id": "42418", "last_activity_date": "2018-03-15T19:36:24.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "940", "parent_id": "42387", "post_type": "answer", "score": 1 } ]
42387
42392
42392
{ "accepted_answer_id": "42397", "answer_count": 1, "body": "プログラミングにおいて、エンドポイントとはどういう意味なのでしょうか?", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T12:49:11.030", "favorite_count": 0, "id": "42395", "last_activity_date": "2018-03-14T14:37:51.227", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27691", "post_type": "question", "score": 2, "tags": [ "プログラミング言語" ], "title": "エンドポイントとは何か", "view_count": 2699 }
[ { "body": "一般的な英語の話として、「エンドポイント\n(endpoint)」とは「端点」という意味です。ここから転じて、通信ネットワークでの専門用語として、ネットワーク末端の端末(多くはクライアントのこと)を「エンドポイント」と呼びます。\n\n同様の発想で、ソフトウェア分野では、API にアクセスするための URI\nそのものや、公開されている機能を使うための識別子を「エンドポイント」と呼ぶことがあります。\n\n他にも、今回の例に関係あるか分かりませんが、認証や認可の文脈だと [OAuth 2.0 のドキュメント](https://openid-\nfoundation-japan.github.io/rfc6749.ja.html#anchor16)に「エンドポイント」という言葉が出てきます。\n\n### 参考\n\n * <https://en.wikipedia.org/wiki/Endpoint>\n * <https://en.wikipedia.org/wiki/Web_API#Endpoints>\n * [エンドポイントとは](http://e-words.jp/w/%E3%82%A8%E3%83%B3%E3%83%89%E3%83%9D%E3%82%A4%E3%83%B3%E3%83%88.html) \\-- e-words.jp", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T14:29:10.353", "id": "42397", "last_activity_date": "2018-03-14T14:37:51.227", "last_edit_date": "2018-03-14T14:37:51.227", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "42395", "post_type": "answer", "score": 5 } ]
42395
42397
42397
{ "accepted_answer_id": "42399", "answer_count": 1, "body": "テーブルビューのセルにテキストを表示する時は例えば\n\nlet cell = UITableViewCell() \ncell.textLabel.text = \"あああ\"\n\nと書くと思いますが、 \nこの時にcellはUITableViewCellクラスのインスタンスで、 \ntextLabelはそのプロパティであることは分かりますが、 \ntextはどういう位置付けなのでしょうか。\n\ntextLabel.textと書かれるということは \ntextLabel内のプロパティのように思いますが、 \ntextLabel自体がUITableViewCellクラスのプロパティであり、 \nプロパティ内のプロパティとはどういう状態でしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T20:26:57.160", "favorite_count": 0, "id": "42398", "last_activity_date": "2018-03-14T22:09:52.923", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27271", "post_type": "question", "score": 0, "tags": [ "swift", "uitableview" ], "title": "swiftのテーブルビューにおけるセル内のテキストの表示に関して", "view_count": 101 }
[ { "body": "不要な部分をざっくり省略すると、こう言うことです。\n\n```\n\n class UITableViewCell: ... {\n var textLabel: UILabel?\n \n //...\n }\n \n class UILabel: ... {\n var text: String?\n \n //...\n }\n \n```\n\n`UITableViewCell`には`textLabel`というプロパティがあり、そのデータ型である`UILabel`(実際は`UILabel?`ですが)には、`text`というプロパティがあります。\n\nプロパティ内のプロパティ、こんな風に何重にも重なることはあります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-14T22:09:52.923", "id": "42399", "last_activity_date": "2018-03-14T22:09:52.923", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "42398", "post_type": "answer", "score": 1 } ]
42398
42399
42399
{ "accepted_answer_id": "42405", "answer_count": 1, "body": "```\n\n import UIKit\n import RxSwift\n import RxCocoa\n \n class ViewController: UIViewController {\n @IBOutlet weak var buttonB: UIButton!\n @IBOutlet weak var labelB: UILabel!\n \n let disposeBag = DisposeBag()\n var countVariable = Variable(0)\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n countVariable.asObservable().map{ String($0) }.bind(to: labelB.rx.text).disposed(by: disposeBag)\n buttonB.rx.tap.subscribe(onNext: { [weak self] in\n guard let weakSelf = self else { return }\n \n weakSelf.countVariable.value = weakSelf.countVariable.value + 1\n }).disposed(by: disposeBag)\n }\n }\n \n```\n\n上記の処理のながれを\n\n`tap -> countVariableを1プラスする処理 -> String変換 -> ラベルのテキスト`\n\nというように流れるようにメソッドチェーンでつなげて書く方法はありませんでしょうか?\n\nソースからおわかりと思いますが、 \n今段階で掲載したソースでメソッドチェーンとして流れるようにつながっているのは、 \n`String変換 -> ラベルのテキスト`の部分のみです。 \n流れるようにプログラムが書けるともっとソースが読みやすくなると思っております。\n\n仮に \n`tap -> countVariableを1プラスする処理 -> String変換 -> ラベルのテキスト` \nの流れがRx的に不自然なのであれば、流れる順番を修正していただいてかまいません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T01:08:35.640", "favorite_count": 0, "id": "42402", "last_activity_date": "2019-06-29T04:42:31.260", "last_edit_date": "2019-06-29T04:42:31.260", "last_editor_user_id": "9008", "owner_user_id": "9008", "post_type": "question", "score": 1, "tags": [ "swift3", "reactive-programming", "rx-swift" ], "title": "tapされたあとの処理を流れるようにUILabel.textまでメソッドチェーンで書きたい", "view_count": 155 }
[ { "body": "RxSwiftの `Variable` は `BehaviorSubject` (RxSwift4では `BehaviorRelay`\n)のラッパーであり、ご質問のソースに書いていただいたような処理をしたい場合には2方向のバインディングを行うのが基本となります。なので、一つのメソッドチェーンでまとめて書くということはできません。\n\nVariableを挟まずに、直接ストリームをつなげるようにすれば一つのメソッドチェーンで書くことができます。\n\n```\n\n self.buttonB.rx.tap\n .scan(0) { count, _ in count + 1 } // 初期値0に対し、タップのたびに1を足していく\n .map { String($0) }\n .bind(to: self.labelB.rx.text)\n .disposed(by: self.disposeBag)\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T04:41:55.930", "id": "42405", "last_activity_date": "2018-03-15T04:49:18.050", "last_edit_date": "2018-03-15T04:49:18.050", "last_editor_user_id": "915", "owner_user_id": "915", "parent_id": "42402", "post_type": "answer", "score": 1 } ]
42402
42405
42405
{ "accepted_answer_id": "42460", "answer_count": 1, "body": "**環境** \n・CentOS7 \n・yumでインストールしたPHP7.0\n\n* * *\n\n**質問** \n・7.1へアップグレードするには?\n\n* * *\n\n**案1.yum update php --enablerepo=remi-php71** \n・上記は何をするコマンド? \n・php71のリポジトリを指定してyum updateするので、PHP7.1へアップグレードされる?\n\n**案2.yum install --enablerepo=remi-php71 php** \n・PHP7.0が動作している状態で、php71のリポジトリを指定してインストールしたら、PHP7.1へアップグレードされる?\n\n**案3.yum remove php-*した後、案2** \n・最初に既存のPHPは削除が必要ですか?", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T04:11:37.803", "favorite_count": 0, "id": "42404", "last_activity_date": "2020-07-25T06:47:37.113", "last_edit_date": "2020-07-25T06:47:37.113", "last_editor_user_id": "3060", "owner_user_id": "7886", "post_type": "question", "score": 1, "tags": [ "php", "centos", "yum" ], "title": "yumでインストールしたPHP7.0を7.1へアップグレードしたい", "view_count": 722 }
[ { "body": "以下はCentOS 6で確認した結果です。\n\nbaseリポジトリ、もしくはremi-php70リポジトリからphpを既にインストールした状態で \n`yum --enablerepo=remi-php71 install php`を実行した場合には、既存のパッケージを置き換える形で \n**上書きインストール** されました(`install`の代わりに`upgrade`指定でも同様)。 \n事前の削除は特に必要ないと思います。 \n`-y`オプションを使わない限り、インストール・アップグレード前に簡単なサマリーが表示されるので何が起きるのかは事前に確認ができるかと。\n\n`--enablerepo`オプションは`/etc/yum.repo.d/*.repo`で普段無効にされているリポジトリをコマンドラインから一時的に有効にするオプションです。`man\nyum`でオプションを確認しましょう。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-17T16:32:37.977", "id": "42460", "last_activity_date": "2018-03-17T16:32:37.977", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "42404", "post_type": "answer", "score": 2 } ]
42404
42460
42460
{ "accepted_answer_id": null, "answer_count": 1, "body": "<https://coinmarketcap.com/ja/api/> から値を取ってきたいのですが出来ません。 \n下のソースで 24h_volume_usd が数字から始まることで不都合が起きているのですが・・どこを修正すれば良いでしょうか?\n\n```\n\n function getCoin24h_volume_usd(currency) {\n //coinmarketcap API call \n var response = UrlFetchApp.fetch(\"https://api.coinmarketcap.com/v1/ticker/\" + currency + \"/\");\n var results = JSON.parse(response.getContentText()); \n var 24h_volume_usd = results[0].24h_volume_usd;\n return 24h_volume_usd;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T05:40:49.203", "favorite_count": 0, "id": "42406", "last_activity_date": "2018-03-15T06:13:47.437", "last_edit_date": "2018-03-15T05:51:54.763", "last_editor_user_id": "4236", "owner_user_id": "27749", "post_type": "question", "score": 2, "tags": [ "javascript", "google-apps-script" ], "title": "数字から始まる変数でエラーになる", "view_count": 752 }
[ { "body": "JavaScriptを含め、多くのプログラミング言語では **変数名の一文字目** に数字を使用することはできません(二文字目以降に含めるのは可)。\n\nJavaScriptの場合は\n\n> 一文字目:半角の英字、アンダースコア、ドル記号 \n> 二文字目以降:半角の英数字、アンダースコア、ドル記号", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T06:05:49.157", "id": "42409", "last_activity_date": "2018-03-15T06:13:47.437", "last_edit_date": "2018-03-15T06:13:47.437", "last_editor_user_id": "3060", "owner_user_id": "3060", "parent_id": "42406", "post_type": "answer", "score": 9 } ]
42406
null
42409
{ "accepted_answer_id": "42410", "answer_count": 1, "body": "**activity_main.xmlのTextView に android:text と tools:text\nがあるのですが、それぞれどういう役割ですか?** \n・デザインタブで表示される内容は、tools:text? \n・実際のアプリで表示される内容は、android:text? \n・デザインタブで、実際のアプリで表示される内容を表示させるためには、両方指定する必要がある?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T05:46:56.693", "favorite_count": 0, "id": "42407", "last_activity_date": "2018-03-15T06:28:02.660", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "android-studio" ], "title": "TextView の android:text と tools:text について", "view_count": 2904 }
[ { "body": "> ・デザインタブで表示される内容は、tools:text?\n\n`tools:text`で指定したテキストは、Android Studioのレイアウトエディタで表示されます。 \n実際のアプリでは表示されません。\n\n> ・実際のアプリで表示される内容は、android:text?\n\n`android:text`で指定したテキストは、Android Studioのレイアウトエディタでも実際のアプリでも表示されます。\n\n> ・デザインタブで、実際のアプリで表示される内容を表示させるためには、両方指定する必要がある?\n\nどちらでも表示するのであれば、`android:text`で指定すればOKです。\n\n* * *\n\n`tools:text`は動作時に表示内容が変わるなど、レイアウトの定義時には`android:text`に表示するものが決まらない場合に、レイアウトエディタで見た目を確認することに利用できます。\n\n例:回答の結果が正解か不正解か表示する`TextView`の場合\n\n```\n\n <TextView\n android:id=\"@+id/answer\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n tools:text=\"不正解\"/>\n \n```\n\n```\n\n private void answered(Question q, Answer a) {\n TextView answerView = findViewById(R.id.answer)\n if (q.isCorrect(a)) {\n answerView.setText(\"正解\");\n } else {\n answerView.setText(\"不正解\");\n }\n }\n \n```\n\n実動作時には、`answered()`の処理が実行されるまでは`TextView`には何も表示されていません。 \nレイアウトエディタ上では「不正解」が表示されていて、入力される文字によってレイアウト崩れが起きているかなどを動作させる前に確認することができます。\n\n参考:<https://developer.android.com/studio/write/tool-\nattributes.html#tools_instead_of_android>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T06:28:02.660", "id": "42410", "last_activity_date": "2018-03-15T06:28:02.660", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "42407", "post_type": "answer", "score": 2 } ]
42407
42410
42410
{ "accepted_answer_id": "42545", "answer_count": 1, "body": "`Qt`で開発をしているんですけれども、ダイアログ等のように、ポップアップするウィジェットを \n作成したり、ドックウィジェットのように、フローティングするウィジェットがある場合、それが表示されているときに、一番のメイン画面を消すことがあります。そういう時、出現中のウィジェットも同時に消すようにしたいのですが、その場合はどうすればいいでしょうか。長らく放っといた問題なんですが、表示される可能性のあるウィジェットをあらかじめどこかのコンテナに入れておいて、`closeEvent()`時に全てチェックするしかないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T06:39:29.167", "favorite_count": 0, "id": "42411", "last_activity_date": "2018-04-01T11:16:30.540", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24284", "post_type": "question", "score": 0, "tags": [ "qt", "pyside", "pyqt" ], "title": "メインウィジェットが消されれば、フローティング中のダイアログやウィジェット等も同時に消したい。", "view_count": 111 }
[ { "body": "自己解決\n\n質問に書いての通り、closeEventをオーバーライドし、フローティングする可能性のあるウィジェットを終了時に調べてしまうのが、一番いいと思います。\n\n```\n\n def closeEvent(self,event):\n if self.add_dialog.isVisible():\n self.add_dialog.close()\n \n```\n\n`dialog`は、一時的に表れる画面としてよく設定されますが、上のようにしていけば、あまりにも大量に出てくるようなアプリケーションでない限り、さほど労せずチェックできるはずです。 \nバグ取の問題だと思います。 \n(追記 2018/4/1) \nほかの方法を見付けました。\n\n```\n\n PySide.QtGui.QApplication.closeAllWindows()\n \n```\n\nこれを、`closeEvent`配下に入れてしまいましょう。もうクローズ残しは心配いりません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-21T11:24:16.493", "id": "42545", "last_activity_date": "2018-04-01T11:16:30.540", "last_edit_date": "2018-04-01T11:16:30.540", "last_editor_user_id": "24284", "owner_user_id": "24284", "parent_id": "42411", "post_type": "answer", "score": 0 } ]
42411
42545
42545
{ "accepted_answer_id": null, "answer_count": 2, "body": "Androidで、Play Billing Library 1.0を使用しています。 \nサンプルのTrivialDrive_v2を使用していてわかったのですが、 \n開発者アカウント(デベロッパーセンターのアカウント)では、「購入」ができません。 \n「消費」という概念がある以上、それは仕方がないと思うのですが、 \n自分で開発し、Playストアに公開したアプリを、Playストアからインストールした場合、 \nTrivialDrive_v2でいうところのPremiumの機能を購入できないため、フル機能を使うことができないと思います。 \nPlay Billing\nLibraryで、開発者(オーナー)であることを識別し、TrivialDrive_v2でisPremiumPurchased()がtrueを返すように改変する方法はありますでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T09:49:25.720", "favorite_count": 0, "id": "42414", "last_activity_date": "2018-03-20T07:16:45.103", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27755", "post_type": "question", "score": 1, "tags": [ "android", "java", "アプリ内課金", "google-play" ], "title": "開発者アカウントでアプリ内課金のアイテムを使用したい", "view_count": 246 }
[ { "body": "ヘルプを参照すると、「アプリ内課金をテストするにはアルファ版またはベータ版としてアプリを公開する必要がある」と書かれています。\n\n[アプリ内課金のテスト | Android\nDevelopers](https://developer.android.com/google/play/billing/billing_testing.html)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T10:05:53.083", "id": "42415", "last_activity_date": "2018-03-16T00:55:25.020", "last_edit_date": "2018-03-16T00:55:25.020", "last_editor_user_id": "3060", "owner_user_id": "3060", "parent_id": "42414", "post_type": "answer", "score": 1 }, { "body": "英語版stackoverflowに同様の質問を投げたところ、 \n1.アプリ内課金をもたずにフル機能を実装したアプリをアルファ版として公開し、自分だけで利用する。 \n2.Play Lecense Verification Libraryを利用し、userIDを取得し、そこにアプリ内課金と同様の機能を実装する。 \nとの回答がありました。 \nGoogle Play\nConsoleチャットサポートに問い合わせたところ、新規アカウントを端末に登録し、そのアカウントでインストールすることでアプリ内購入が可能である。との回答を得ました。 \nどれも面倒または実装が難しいかですが、要は普段使いのアカウントがデベロッパーコンソールのアカウントと別であればよいことと、デベロッパーアカウントは別のアカウントにすべてのアプリを委譲し、継続公開できることがわかったため、新規アカウントでデベロッパー登録し、アプリを委譲することで解決しました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-20T07:16:45.103", "id": "42515", "last_activity_date": "2018-03-20T07:16:45.103", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27755", "parent_id": "42414", "post_type": "answer", "score": 2 } ]
42414
null
42515
{ "accepted_answer_id": null, "answer_count": 1, "body": "SQLで各レコードの過去直近7日間のデータを集計したいです。 \n使用DBはSQLite3です。 \n具体例だと\n\n日付 | 歩数 \n\\----------------------- \n2018-01-01 | 6000 \n2018-01-02 | 5500 \n2018-01-03 | 200 \n2018-01-04 | 9700 \n2018-01-05 | 1100 \n2018-01-06 | 5000 \n2018-01-07 | 800 \n2018-01-08 | 3600 \n2018-01-09 | 6000 \n2018-01-10 | 0\n\nというデータに対して\n\n日付 | 過去1週間の平均歩数 \n\\-----------------------\n\n2018-01-08 | 3187 \n2018-01-09 | 3700 \n2018-01-10 | 3771\n\nのように集計がしたいです。(2018-01-01から2018-01-07の集計はできてもできなくてもよいです。)\n\nこの集計を1つのSQLで書けないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T18:32:27.997", "favorite_count": 0, "id": "42417", "last_activity_date": "2018-03-15T23:15:14.370", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27760", "post_type": "question", "score": 0, "tags": [ "sqlite" ], "title": "各レコードに対する過去直近7日間のデータ集計", "view_count": 958 }
[ { "body": "相関サブクエリを使えばわかりやすいでしょうか\n\n```\n\n SELECT\n 日付,\n (SELECT AVG(t2.歩数)\n FROM t AS t2\n WHERE date(t1.日付, '-7 days') <= t2.日付 AND t2.日付 < t1.日付) AS 過去1週間の平均歩数\n FROM t AS t1;\n \n```\n\n行数が多くパフォーマンスが問題になる場合は自己結合しつつ集計することでしょうか\n\n```\n\n SELECT t1.日付, AVG(t2.歩数) AS 過去1週間の平均歩数\n FROM t AS t1\n INNER JOIN t AS t2\n ON date(t1.日付, '-7 days') <= t2.日付 AND t2.日付 < t1.日付\n GROUP BY t1.日付;\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T23:15:14.370", "id": "42422", "last_activity_date": "2018-03-15T23:15:14.370", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "42417", "post_type": "answer", "score": 1 } ]
42417
null
42422
{ "accepted_answer_id": "42421", "answer_count": 1, "body": "<https://www.example.com/> \nというサイトで\n\n<https://www.example.com/blog/> \nというページがあったとして\n\n以下のようにjQueryでPOSTアクセスを投げると\n\n```\n\n function test()\n {\n $.post('/aaa',{},\n (data) => {\n \n });\n }\n \n```\n\n<https://www.example.com/blog/aaa> \nに対してのPOSTアクセス(?)になりますが\n\n<https://www.example.com/blog/edit> \nというページから \n同じtest()関数を使ってPOSTアクセスを投げると\n\n<https://www.example.com/blog/edit/aaa> \nに対してのPOSTになってしまいます。\n\n関数を使いまわしたいので、同じURLに対してPOSTを投げたいのですが \nどのような処理にするのが良いでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T20:46:07.983", "favorite_count": 0, "id": "42420", "last_activity_date": "2018-03-15T21:56:42.143", "last_edit_date": "2018-03-15T21:41:37.883", "last_editor_user_id": "4236", "owner_user_id": "22541", "post_type": "question", "score": 1, "tags": [ "javascript", "jquery" ], "title": "POSTアクセスを相対パスではなく絶対パスで行いたい", "view_count": 2562 }
[ { "body": "そもそも質問文が間違っていて`aaa`を指定した場合についてでしょうか、その場合 \n<https://www.example.com/blog/> → <https://www.example.com/blog/aaa> \n<https://www.example.com/blog/edit> → <https://www.example.com/blog/edit/aaa> \nと意図しないアドレスに移動します。\n\n質問文通り`/aaa`を指定した場合 \n<https://www.example.com/blog/> → <https://www.example.com/aaa> \n<https://www.example.com/blog/edit> → <https://www.example.com/aaa> \nとなります。\n\nつまりあと一歩足りなかっただけであり、結論としては`/blog/aaa`を指定すると期待通りの動作になります。 \n<https://www.example.com/blog/> → <https://www.example.com/blog/aaa> \n<https://www.example.com/blog/edit> → <https://www.example.com/blog/aaa>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-15T21:56:42.143", "id": "42421", "last_activity_date": "2018-03-15T21:56:42.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "42420", "post_type": "answer", "score": 4 } ]
42420
42421
42421
{ "accepted_answer_id": null, "answer_count": 0, "body": "スプレッドシートに、更新日時の自動入力する為に、スクリプトエディタに入力しています。 \n問題なく更新日時は入力されていますが、エラーメールが来ました。 \nエラーメッセージは `insertLastUpdated スクリプト関数が見つかりません: insertLastUpdated edit` という内容です。\n\n下記、どこか間違った記載があるかご教示願えますでしょうか?\n\n```\n\n var ss = SpreadsheetApp.getActiveSpreadsheet();\n var sh = ss.getActiveSheet();\n \n function onEdit(e) {\n if (sh.getSheetName() === \"シート名\") {\n var row = e.range.getRow();\n var col = e.range.getColumn();\n \n if ((row >=11) && (col === 6)) {\n sh.getRange(row,25).setValue(new Date());\n }\n }\n }\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T00:19:41.570", "favorite_count": 0, "id": "42423", "last_activity_date": "2018-03-16T03:07:40.350", "last_edit_date": "2018-03-16T03:07:40.350", "last_editor_user_id": "19110", "owner_user_id": "27761", "post_type": "question", "score": 0, "tags": [ "google-apps-script", "google-spreadsheet" ], "title": "googleのスプレッドシートのスクリプトエラーのメールが来た", "view_count": 970 }
[]
42423
null
null
{ "accepted_answer_id": "42425", "answer_count": 1, "body": "[この質問](https://ja.stackoverflow.com/questions/40133/nchar2-nvarchar2%E3%81%AE%E3%82%AB%E3%83%A9%E3%83%A0%E3%81%AB%E6%96%87%E5%AD%97%E5%8C%96%E3%81%91%E3%81%9B%E3%81%9A%E3%81%AB%E6%96%87%E5%AD%97%E5%88%97%E3%82%92%E6%A0%BC%E7%B4%8D%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95)に関連します。\n\n[この記事の「(2)\nJDBC接続のエンコーディングをUTF-8に設定」のところ](http://sakaisusie.hatenablog.com/entry/2014/07/02/001911)に、GlassfishでのJDBC接続のエンコーディング設定方法が説明されています。\n\nWildflyやJBossEAPで、上記設定に相当するものをやりたいのですが、どうやればいいのでしょうか?\n\n【追記】 \n使用しているDBは、SQLServer, Oracle, PostgreSQLです。 \n現状、Oracleのみ、SJIS(CP932)外の文字を保存しようとすると、文字化けが発生しています。 \nアプリケーション(JPA)を介さずに、直接SQLを流す場合、Nプレフィクスをつけていれば文字化けしないので、DB側の問題ではないと推測しています。", "comment_count": 7, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T00:24:54.193", "favorite_count": 0, "id": "42424", "last_activity_date": "2018-03-18T13:27:09.607", "last_edit_date": "2018-03-16T02:59:42.947", "last_editor_user_id": "8078", "owner_user_id": "8078", "post_type": "question", "score": 0, "tags": [ "java", "oracle", "jboss", "wildfly" ], "title": "JDBC接続のエンコーディング設定方法", "view_count": 5728 }
[ { "body": "MySQLやH2などのDBを使用している場合、Standalone.xmlのconnection-\nurlにパラメタを設定することで可能だと思います。(下記はmysqlの例)\n\n```\n\n <datasource ...>\n <connection-url>jdbc:mysql://localhost:3306/db?useUnicode=true&amp;characterEncoding=utf8</connection-url>\n .....\n </datasource>\n \n```\n\nまた、[こちらの回答](https://ja.stackoverflow.com/questions/40133/nchar2-nvarchar2%E3%81%AE%E3%82%AB%E3%83%A9%E3%83%A0%E3%81%AB%E6%96%87%E5%AD%97%E5%8C%96%E3%81%91%E3%81%9B%E3%81%9A%E3%81%AB%E6%96%87%E5%AD%97%E5%88%97%E3%82%92%E6%A0%BC%E7%B4%8D%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95)にもしましたが、oracleの場合、standalone.sh等の起動パラメタで\n\n> -Doracle.jdbc.defaultNChar=true\n\nをつけることでNCharを使うことができるようです。 \nOracleの場合connection-urlで設定可能かどうかは環境がないため試せないですが、しっかり動くようです。\n\n[Wildfly 10 datasource\nconfiguration](https://docs.jboss.org/author/display/WFLY10/DataSource+configuration)", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T02:24:08.980", "id": "42425", "last_activity_date": "2018-03-18T13:27:09.607", "last_edit_date": "2018-03-18T13:27:09.607", "last_editor_user_id": "24823", "owner_user_id": "24823", "parent_id": "42424", "post_type": "answer", "score": 0 } ]
42424
42425
42425
{ "accepted_answer_id": "42427", "answer_count": 1, "body": "**前提** \n・「Object.create」が使用できる環境\n\n* * *\n\n**オブジェクト作成する際、「Object.create」ではダメで「new Object()」でしか出来ないことはありますか?** \n・「Object.create」は、完全な上位互換ですか? \n・「Object.create」ではなく「new Object()」と書いた方が良いケースはある? \n・「new Object()」は古い書き方なので、敢えて使用する必要はない??", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T03:10:58.673", "favorite_count": 0, "id": "42426", "last_activity_date": "2018-03-16T04:36:06.347", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 6, "tags": [ "javascript" ], "title": "オブジェクト作成する際、「Object.create」ではなく「new Object()」と書いた方が良いケースはある?", "view_count": 223 }
[ { "body": "`Object.create`ではコンストラクターが実行されません。\n\n`new Test()`の動作\n\n```\n\n var obj = new Object();\n obj.__proto__ = Test.prototype;\n return Test.call(obj) || obj;\n \n```\n\n`Object.create(Test.prototype)`の動作\n\n```\n\n var obj = new Object();\n obj.__proto__ = Test.prototype;\n return obj;\n \n```\n\n例えば`new\nDate()`では現在時刻が得られますが`Object.create(Date.prototype)`では未初期化の`Date`オブジェクトが得られます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T04:36:06.347", "id": "42427", "last_activity_date": "2018-03-16T04:36:06.347", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "42426", "post_type": "answer", "score": 8 } ]
42426
42427
42427
{ "accepted_answer_id": null, "answer_count": 0, "body": "golangで以下のようなコードを書いて、\n\n```\n\n package main\n \n import \"fmt\"\n \n func main() {\n fmt.Println(\"hello\")\n }\n \n```\n\ndebian上で \nexport GOOS=linux \nexport GOARCH=mipsle \nexport GOMIPS=softfloat \ngo build -a hello.go \nとしてできたバイナリを手持ちのルータで実行することができました。\n\nHTTPのgetがしたかったので以下のようなコードを書いて\n\n```\n\n package main\n import (\n \"fmt\"\n \"io/ioutil\"\n \"log\"\n \"net/http\"\n )\n func main() {\n fmt.Println(\"hello\")\n url := \"http://example.com/\"\n resp, err := http.Get(url)\n if err != nil {\n log.Fatal(err)\n }\n defer resp.Body.Close()\n byteArray, _ := ioutil.ReadAll(resp.Body)\n fmt.Println(string(byteArray))\n }\n \n```\n\n同様にbuildしてルータ上で実行したところ以下のエラーがでました。\n\n```\n\n hello\n 2018/03/16 05:07:25 Get http://example.com/: dial tcp: lookup example.com on \n 202.215.242.209:53: dial udp 202.215.242.209:53: errno -89\n \n```\n\n多少ググったのですが、エラーの原因がさっぱり分からないので、ご存知のかた教えてください。\n\n追記1:DNSに8.8.8.8設定すると以下のようにエラーメッセージが変わりました。\n\n```\n\n hello\n 2018/03/16 06:51:01 Get http://example.com/: dial tcp: lookup example.com on \n 8.8.8.8:53: dial udp 8.8.8.8:53: errno -89\n \n```\n\n追記2:ルーター上でiptable -Lを実行してみました。結果の見方が分かりませんが。\n\n```\n\n # iptables -L\n Chain INPUT (policy ACCEPT)\n target prot opt source destination\n malicious_input_filter all -- anywhere anywhere\n \n Chain FORWARD (policy ACCEPT)\n target prot opt source destination\n web_filter all -- anywhere anywhere\n macipport_filter all -- anywhere anywhere\n malicious_filter all -- anywhere anywhere\n TCPMSS tcp -- anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU\n \n Chain OUTPUT (policy ACCEPT)\n target prot opt source destination\n \n Chain macipport_filter (1 references)\n target prot opt source destination\n \n Chain malicious_filter (1 references)\n target prot opt source destination\n synflood_filter tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN\n \n Chain malicious_input_filter (1 references)\n target prot opt source destination\n synflood_input_filter tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN\n DROP tcp -- anywhere anywhere tcp dpt:80\n DROP tcp -- anywhere anywhere tcp dpt:443\n DROP icmp -- anywhere anywhere icmp echo-request\n DROP tcp -- anywhere anywhere tcp dpt:53\n DROP udp -- anywhere anywhere udp dpt:53\n \n Chain synflood_filter (1 references)\n target prot opt source destination\n \n Chain synflood_input_filter (1 references)\n target prot opt source destination\n \n Chain web_filter (1 references)\n target prot opt source destination\n \n```\n\n追記3:iptable -flushしてみましたが、serviceコマンドが使えなくて再起動できないのですが \niptables -Lの結果は以下のようになりました。\n\n```\n\n # iptables -L\n Chain INPUT (policy ACCEPT)\n target prot opt source destination\n Chain FORWARD (policy ACCEPT)\n target prot opt source destination\n Chain OUTPUT (policy ACCEPT)\n target prot opt source destination\n Chain macipport_filter (0 references)\n target prot opt source destination\n Chain malicious_filter (0 references)\n target prot opt source destination\n Chain malicious_input_filter (0 references)\n target prot opt source destination\n Chain synflood_filter (0 references)\n target prot opt source destination\n Chain synflood_input_filter (0 references)\n target prot opt source destination\n Chain web_filter (0 references)\n target prot opt source destination\n \n```\n\nしかしプログラムの実行結果は変わりませんでした。\n\n```\n\n hello\n 2018/03/16 06:51:01 Get http://example.com/: dial tcp: lookup example.com on \n 8.8.8.8:53: dial udp 8.8.8.8:53: errno -89\n \n```", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T05:09:03.553", "favorite_count": 0, "id": "42428", "last_activity_date": "2018-03-19T03:28:42.373", "last_edit_date": "2018-03-19T03:28:42.373", "last_editor_user_id": "27763", "owner_user_id": "27763", "post_type": "question", "score": 1, "tags": [ "go" ], "title": "go言語でmips用にコンパイルしたバイナリでエラーがでます", "view_count": 139 }
[]
42428
null
null
{ "accepted_answer_id": "42432", "answer_count": 1, "body": "JavaEEアプリケーションの定期バッチ処理を実装するために、QuartzSchedulerを使っています。 \n[Cron Trigger Tutorial](http://www.quartz-\nscheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html)を見ているのですが、次のようなcronの組み方が分かりません。\n\n例1:毎日、12:30~14:30の間、5分毎に実行 \n例2:毎日、22:00~5:00までの間、5分毎に実行\n\nこれが12:00~14:00だったら、`* 0/5 12-14 * *\n?`と書けばできるのですが、時だけでなく分までを絡めたり、日をまたいだりした場合の範囲指定の方法が分かりません。\n\nトリガーを分割して登録するしかないのでしょうか? \n分割したとしても、まだ書き方が分からない部分がありますが・・・\n\n例1の場合:\n\n```\n\n 12:30-12:59 -> \"* 30/5 12 * * ?\"\n 13:00-13:59 -> \"* 0/5 13 * * ?\"\n 14:00-14:30 -> どうやって書く?\n \n```\n\n例2の場合:\n\n```\n\n 22:00-23:59 -> \"* 0/5 22-23 * * ?\"\n 00:00-05:00 -> \"* 0/5 0-5 * * ?\"\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T05:37:44.600", "favorite_count": 0, "id": "42430", "last_activity_date": "2018-03-16T06:30:06.573", "last_edit_date": "2018-03-16T05:46:10.077", "last_editor_user_id": "8078", "owner_user_id": "8078", "post_type": "question", "score": 1, "tags": [ "java" ], "title": "QuartzSchedulerである時間帯だけ5分毎に実行するcronを書きたい", "view_count": 825 }
[ { "body": "例1:毎日、12:30~14:30の間、5分毎に実行 \n12:30が1回目、14:30が25回目で計25回実行\n\nもし、 Quartz Job Schedulerで 一般的な crontab の記法が使えるならば以下のように書くことができるかと思います。\n\n```\n\n 12:30-12:59 -> \"0 30-59/5 12 * * ?\"\n 13:00-13:59 -> \"0 0/5 13 * * ?\"\n 14:00-14:30 -> \"0 0-30/5 14 * * ?\"\n \n```\n\nもしできないのであれば以下のように実行したい「分」を列挙すれば可能かと思います。 \n(意外とこちらの方が処理時間がわかりやすいかもしれません。)\n\n```\n\n 12:30-12:59 -> \"0 30,35,40,45,50,55 12 * * ?\"\n 13:00-13:59 -> \"0 0/5 13 * * ?\"\n 14:00-14:30 -> \"0 0,5,10,15,20,25,30 14 * * ?\"\n \n```\n\n例2:毎日、22:00~5:00までの間、5分毎に実行 \n22:00が1回目、05:00が85回目で合計85回実行\n\n質問文の書かれた記述だと 05:05 ~ 05:55 の11回余分に実行してしまうかと思われます。\n\n```\n\n 22:00-23:59 -> \"0 0/5 22-23 * * ?\"\n 00:00-04:59 -> \"0 0/5 0-4 * * ?\"\n 05:00 -> \"0 0 5 * * ?\"\n \n```\n\nQuartz Job Scheduler で確認したわけではないため、参考までにどうぞ。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T06:30:06.573", "id": "42432", "last_activity_date": "2018-03-16T06:30:06.573", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27410", "parent_id": "42430", "post_type": "answer", "score": 1 } ]
42430
42432
42432
{ "accepted_answer_id": null, "answer_count": 0, "body": "anacondaでpython3.6をインストールしました。しかし、今までのPCで使っていたIDLEがモジュールを読み込みません。具体的には、例えばnumpyをインポートしようとすると、\n\n```\n\n ModuleNotFoundError: No module named 'numpy'\n \n```\n\nと、エラーを吐きます。spyderでは正常に動作するので、モジュール自体はインストールされていると思います。PCはWindows\n10、64bitでインストールしました。前のPCではWindows\n8.1でpython3.5を使っていました。どなたか原因のわかる方いらっしゃいますか。また、他にお勧めの開発環境などあると教えていただけると幸いです。\n\n追記: \npycharmをインストールしてみましたが、こちらでもモジュールを読み込めませんでした。\n\n```\n\n import sys\n print(sys.version)\n \n```\n\nと入力したところ、spyder, idle, pycharm 全てで\n\n```\n\n 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]\n \n```\n\nと出力されました。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T06:37:02.543", "favorite_count": 0, "id": "42433", "last_activity_date": "2018-03-16T09:15:25.990", "last_edit_date": "2018-03-16T09:15:25.990", "last_editor_user_id": "19110", "owner_user_id": "26529", "post_type": "question", "score": 0, "tags": [ "python", "python3", "anaconda" ], "title": "anacondaでインストールしたIDLEがモジュールを認識しない", "view_count": 892 }
[]
42433
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "atomにOmniSharp-atomを正常にプラグイン出来る手順を教えていただきたいです。\n\n以下のサイトの手順に従って作業を行なっていました。\n\n<https://note.nkmk.me/c-sharp-mac-atom-omnisharp/>\n\nMONOのインストールは正常に完了しました。\n\n```\n\n YUTA-no-MacBook-Pro:~ YUTA$ mono\n Usage is: mono [options] program [program-options]\n \n Development:\n --aot[=<options>] Compiles the assembly to native code\n --debug[=<options>] Enable debugging support, use --help-debug for details\n --debugger-agent=options Enable the debugger agent\n --profile[=profiler] Runs in profiling mode with the specified profiler module\n --trace[=EXPR] Enable tracing, use --help-trace for details\n --jitmap Output a jit method map to /tmp/perf-PID.map\n --help-devel Shows more options available to developers\n \n Runtime:\n --config FILE Loads FILE as the Mono config\n --verbose, -v Increases the verbosity level\n --help, -h Show usage information\n --version, -V Show version information\n --runtime=VERSION Use the VERSION runtime, instead of autodetecting\n --optimize=OPT Turns on or off a specific optimization\n Use --list-opt to get a list of optimizations\n --security[=mode] Turns on the unsupported security manager (off by default)\n mode is one of cas, core-clr, verifiable or validil\n --attach=OPTIONS Pass OPTIONS to the attach agent in the runtime.\n Currently the only supported option is 'disable'.\n --llvm, --nollvm Controls whenever the runtime uses LLVM to compile code.\n --gc=[sgen,boehm] Select SGen or Boehm GC (runs mono or mono-sgen)\n --arch=[32,64] Select architecture (runs mono32 or mono64)\n --handlers Install custom handlers, use --help-handlers for details.\n --aot-path=PATH List of additional directories to search for AOT images.\n \n```\n\nしかし、問題が浮上しました。Homebrewからdnvmをインストールしようとしてる時です。\n\n```\n\n YUTA-no-MacBook-Pro:~ YUTA$ brew install dnvm\n Updating Homebrew...\n ==> Auto-updated Homebrew!\n Updated 1 tap (homebrew/core).\n ==> Updated Formulae\n rancher-cli telegraf traefik\n \n ==> Installing dnvm from aspnet/dnx\n ==> Cloning https://github.com/aspnet/Home.git\n Updating /Users/YUTA/Library/Caches/Homebrew/dnvm--git\n ==> Checking out branch dev\n Error: No such file or directory - dnvm.sh\n \n```\n\n問題発覚の時点からatomにOmniSharp-atomを正常にプラグイン出来るまでの手順を細かく教えてほしいです。\n\n## 追記1\n\n問題発覚後、以下のサイトを参考にしました。\n\n参考にした結果、\n\n①.NET Core SDK ver2.0をインストール。\n\n※以下インストールに使用したページ \n<https://www.microsoft.com/net/learn/get-started/macos#macos>\n\n②Omnisharp-atomのパッケージをatomにプラグイン。\n\n※atomエディタからインストールできるパッケージ。\n\n③一度atomを終了させ、数分後atomを起動した直後、以下の警告がホップアップされました。\n\n```\n\n Failed to activate the omnisharp-atom package\n \n \n atom.grammars.startIdForScope is not a function\n Hide Stack Trace\n \n TypeError: atom.grammars.startIdForScope is not a function\n at grammarCb (/Users/YUTA/.atom/packages/omnisharp-atom/dist/omnisharp-atom.js:145:35)\n at arrayEach (/Users/YUTA/.atom/packages/auto-encoding/node_modules/lodash/lodash.js:508:11)\n at forEach (/Users/YUTA/.atom/packages/auto-encoding/node_modules/lodash/lodash.js:9334:14)\n at OmniSharpAtom.activate (/Users/YUTA/.atom/packages/omnisharp-atom/dist/omnisharp-atom.js:153:30)\n at Package.activateNow (/Applications/Atom.app/Contents/Resources/app/src/package.js:230:33)\n at measure (/Applications/Atom.app/Contents/Resources/app/src/package.js:206:33)\n at Package.measure (/Applications/Atom.app/Contents/Resources/app/src/package.js:88:25)\n at activationPromise.Promise (/Applications/Atom.app/Contents/Resources/app/src/package.js:200:20)\n at Promise (<anonymous>)\n at Package.activate (/Applications/Atom.app/Contents/Resources/app/src/package.js:198:38)\n at PackageManager.activatePackage (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:695:42)\n at packagesToEnable.forEach.name (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:440:51)\n at Array.forEach (native)\n at disabledPackagesSubscription.config.onDidChange (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:440:30)\n at emitter.on (/Applications/Atom.app/Contents/Resources/app/src/config.js:1023:22)\n at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:20)\n at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:34)\n at Config.emitChangeEvent (/Applications/Atom.app/Contents/Resources/app/src/config.js:1175:62)\n at Config.setRawValue (/Applications/Atom.app/Contents/Resources/app/src/config.js:1008:23)\n at Config.set (/Applications/Atom.app/Contents/Resources/app/src/config.js:711:18)\n at Config.removeAtKeyPath (/Applications/Atom.app/Contents/Resources/app/src/config.js:901:16)\n at Package.enable (/Applications/Atom.app/Contents/Resources/app/src/package.js:75:30)\n at PackageManager.enablePackage (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:246:18)\n at HTMLButtonElement.enablementButtonClickHandler (/Applications/Atom.app/Contents/Resources/app/node_modules/settings-view/lib/package-card.js:362:31)\n \n The error was thrown from the omnisharp-atom package. This issue has already been reported.\n \n```\n\n## 追記2\n\n3/18-22:00現在以下のサイトを参考にし、下記の作業を実行しました。\n\n<https://github.com/OmniSharp/omnisharp-atom/issues/1020>\n\n「koxu1996 commented 5 days ago ~Simple solution~」より\n\n①Replace 140 line of omnisharp-atom.js from: \nvar grammars = atom.grammars; \nto \nvar grammars = atom.grammars.textmateRegistry || atom.grammars;\n\n②一度atomを終了させ、数分後atomを起動した直後、以下の2つ警告がホップアップされました。\n\nNo1.\n\n```\n\n Failed to load a language-csharp package grammar\n atom.grammars.startIdForScope is not a function in /Applications/Atom.app/Contents/Resources/app.asar/node_modules/language-csharp/grammars/csx.json\n Hide Stack Trace\n TypeError: atom.grammars.startIdForScope is not a function\n at grammarCb (/Users/YUTA/.atom/packages/omnisharp-atom/dist/omnisharp-atom.js:145:35)\n at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:20)\n at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:34)\n at GrammarRegistry.module.exports.GrammarRegistry.addGrammar (/Applications/Atom.app/Contents/Resources/app/node_modules/first-mate/lib/grammar-registry.js:80:26)\n at Grammar.module.exports.Grammar.activate (/Applications/Atom.app/Contents/Resources/app/node_modules/first-mate/lib/grammar.js:259:54)\n at grammarRegistry.readGrammar (/Applications/Atom.app/Contents/Resources/app/src/package.js:617:53)\n at CSON.readFile (/Applications/Atom.app/Contents/Resources/app/src/grammar-registry.js:468:15)\n at parseContents (/Applications/Atom.app/Contents/Resources/app/node_modules/season/lib/cson.js:123:13)\n at /Applications/Atom.app/Contents/Resources/app/node_modules/season/lib/cson.js:230:26\n at ELECTRON_ASAR.js:497:9\n at FSReqWrap.wrapper [as oncomplete] (fs.js:629:17)\n  at /Applications/Atom.app/Contents/Resources/app.asar/node_modules/language-csharp/grammars/csx.json:1:1\n The error was thrown from the language-csharp package. This issue has already been reported.\n View Issue\n \n```\n\nNo2.\n\n```\n\n Failed to load a language-csharp package grammar\n atom.grammars.startIdForScope is not a function in /Applications/Atom.app/Contents/Resources/app.asar/node_modules/language-csharp/grammars/csharp.json\n Hide Stack Trace\n TypeError: atom.grammars.startIdForScope is not a function\n at grammarCb (/Users/YUTA/.atom/packages/omnisharp-atom/dist/omnisharp-atom.js:145:35)\n at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:20)\n at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:34)\n at GrammarRegistry.module.exports.GrammarRegistry.addGrammar (/Applications/Atom.app/Contents/Resources/app/node_modules/first-mate/lib/grammar-registry.js:80:26)\n at Grammar.module.exports.Grammar.activate (/Applications/Atom.app/Contents/Resources/app/node_modules/first-mate/lib/grammar.js:259:54)\n at grammarRegistry.readGrammar (/Applications/Atom.app/Contents/Resources/app/src/package.js:617:53)\n at CSON.readFile (/Applications/Atom.app/Contents/Resources/app/src/grammar-registry.js:468:15)\n at parseContents (/Applications/Atom.app/Contents/Resources/app/node_modules/season/lib/cson.js:123:13)\n at /Applications/Atom.app/Contents/Resources/app/node_modules/season/lib/cson.js:230:26\n at ELECTRON_ASAR.js:497:9\n at FSReqWrap.wrapper [as oncomplete] (fs.js:629:17)\n at /Applications/Atom.app/Contents/Resources/app.asar/node_modules/language-csharp/grammars/csharp.json:1:1\n The error was thrown from the language-csharp package. This issue has already been reported.\n \n```\n\n## 使用機器・atomに関して\n\nPC:MacBook Pro (Retina, 13-inch, Early 2015) \nOS:macOS Sierra ver10.12.16\n\natom:Version 1.25.0 is the latest version.\n\n* * *\n\n編集作業に携わってくださっている皆様、ありがとうございます。お疲れの出ない範囲で協力をよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T07:11:23.550", "favorite_count": 0, "id": "42434", "last_activity_date": "2022-04-19T05:00:40.063", "last_edit_date": "2018-03-18T23:25:47.657", "last_editor_user_id": "19110", "owner_user_id": "27766", "post_type": "question", "score": 0, "tags": [ ".net", "atom-editor" ], "title": "atom-editorで Omnisharp-atom を使うために dnvm を導入しようとするとエラーが出る", "view_count": 1003 }
[ { "body": "<https://github.com/OmniSharp/omnisharp-\natom/issues/1037#issuecomment-487233117>\n\nomnisharp-atom.jsの2箇所を変更しまして正常動作を確認しました。 \nご参考になれば幸いです。\n\n```\n\n // var grammars = atom.grammars;\n var grammars = atom.grammars.textmateRegistry || atom.grammars;\n \n```\n\n```\n\n //atom.grammars.startIdForScope(grammar.scopeName);\n grammars.startIdForScope(grammar.scopeName);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-06-20T14:11:06.353", "id": "67838", "last_activity_date": "2020-06-21T04:22:43.430", "last_edit_date": "2020-06-21T04:22:43.430", "last_editor_user_id": "13199", "owner_user_id": "40749", "parent_id": "42434", "post_type": "answer", "score": 1 } ]
42434
null
67838
{ "accepted_answer_id": "42441", "answer_count": 1, "body": "python3.6を使っています。 \n<https://teratail.com/questions/81140> \nを参考にして、3次元の直方体を描こうと思ったのですが、できません。書いたコードは、上のurlのコードと全く同じで、次のようになります。\n\n```\n\n import numpy as np\n from mpl_toolkits.mplot3d import Axes3D\n import matplotlib.pyplot as plt\n \n x = [-1,1]\n y = [-1,1]\n X,Y = np.meshgrid(x,y)\n \n ax = plt.subplot(111, projection='3d')\n ax.plot_surface(X,Y,1,alpha=0.7)\n ax.plot_surface(X,Y,-1,alpha=0.7)\n ax.plot_surface(X,1,Y,alpha=0.7)\n ax.plot_surface(X,-1,Y,alpha=0.7)\n ax.plot_surface(-1,X,Y,alpha=0.7)\n ax.plot_surface(-1,X,Y,alpha=0.7)\n ax.set_xlim(-2, 2)\n ax.set_ylim(-2, 2)\n ax.set_zlim(-2, 2)\n plt.show()\n \n```\n\nしかし、spyderで打ち込むと、\n\n```\n\n in plot_surface\n if Z.ndim != 2:\n \n \n AttributeError: 'int' object has no attribute 'ndim'\n \n```\n\nとエラーを吐きます。 \nモジュールのバージョンは\n\nnumpy==1.14.0 \nmatplotlib==2.1.2\n\nです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T08:10:05.967", "favorite_count": 0, "id": "42435", "last_activity_date": "2018-03-16T15:16:50.657", "last_edit_date": "2018-03-16T11:18:41.877", "last_editor_user_id": "3054", "owner_user_id": "26529", "post_type": "question", "score": 3, "tags": [ "python", "python3", "matplotlib" ], "title": "matplotlib の plot_surface で 'int' object has no attribute 'ndim' というエラーが出る", "view_count": 3770 }
[ { "body": "引用元のコードは `plot_surface` へ渡す引数の内、1つを整数としています。 \nしかし現在、[`plot_surface`](https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#surface-\nplots)が受けとる引数は3つとも、「Data values as 2D arrays」とのことなので、ここでエラーになっています。 \n適当に、2次元のnumpy配列などを作って利用すればよさそうです。\n\n```\n\n # 例\n np.array([[1, 1], [1, 1]])\n \n```\n\nまた、タイポだと思いますが、引用元のコードでは `ax.plot_surface(-1,X,Y,alpha=0.7)`\nが繰り返されており、一面が欠けている気がします。\n\n上記2点を修正すると以下になります。\n\n```\n\n import numpy as np\n from mpl_toolkits.mplot3d import Axes3D\n import matplotlib.pyplot as plt\n \n x = [-1, 1]\n y = [-1, 1]\n X, Y = np.meshgrid(x, y)\n Z = np.array([[1, 1], [1, 1]])\n \n ax = plt.subplot(111, projection='3d')\n ax.plot_surface( X, Y, Z, alpha=0.7)\n ax.plot_surface( X, Y, -Z, alpha=0.7)\n ax.plot_surface( X, Z, Y, alpha=0.7)\n ax.plot_surface( X, -Z, Y, alpha=0.7)\n ax.plot_surface( Z, X, Y, alpha=0.7)\n ax.plot_surface(-Z, X, Y, alpha=0.7)\n ax.set_xlim(-2, 2)\n ax.set_ylim(-2, 2)\n ax.set_zlim(-2, 2)\n plt.show()\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T11:16:41.703", "id": "42441", "last_activity_date": "2018-03-16T15:16:50.657", "last_edit_date": "2018-03-16T15:16:50.657", "last_editor_user_id": "3054", "owner_user_id": "3054", "parent_id": "42435", "post_type": "answer", "score": 2 } ]
42435
42441
42441
{ "accepted_answer_id": "42440", "answer_count": 1, "body": "laravelでリダイレクト処理をした際にセッションが保持されません。 \nLaravel Framework 5.4.36 を利用しています。\n\n以下のようなスクリプトを用意しました。\n\n### test1.php\n\n```\n\n class test1 extends Controller\n {\n public function index()\n {\n Session::put('key','value');\n Session::save();\n header(\"Location: /test2\");\n exit;\n }\n }\n \n```\n\n### test2.php\n\n```\n\n class test2 extends Controller\n {\n public function index()\n {\n var_export(Session::all());\n }\n }\n \n```\n\nコードにある通り \ntest1.phpはセッションの保存とtest2へのリダイレクト処理 \ntest2.phpはセッションを表示する処理のスクリプトです。\n\nここから問題なのですが\n\n 1. 初回アクセス時に **test1.php** → **test2.php** と表示すると \nセッションが保持されておらず、 \ntest1.php で putしたセッションが **表示されません** 。\n\n 2. 一方で、初回アクセス時に **test2.php** を一旦表示した後、 \n**test1.php** → **test2.php** と表示すると、 \ntest1.php で putしたセッションが **表示されます** 。\n\n1のケースでもセッションを保持するためにはどのようにすればよいでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T08:51:11.743", "favorite_count": 0, "id": "42437", "last_activity_date": "2018-03-16T10:35:27.767", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "26236", "post_type": "question", "score": 0, "tags": [ "php", "laravel", "laravel-5" ], "title": "laravelの初回リダイレクト時にセッションの値が保持されない", "view_count": 7736 }
[ { "body": "端的に言えば\n\n```\n\n header(\"Location: /test2\");\n exit;\n \n```\n\nはLaravelにおいて書いてはいけないといっても過言ではない書き方です。少なくともController内で`exit`するのはやめましょう。(これがセッションの発行されない原因です。)\n\n代わりに\n\n```\n\n return redirect('/redirect/sample');\n \n```\n\nのように書くことでセッションを伴ったリダイレクトが可能です。\n\nとりあえず片方をコメントアウトしたものをサンプルとして用意したので、コメントを入替えながら`curl\n-v`やCookieを消したブラウザ等で試していただければ違いがわかるとは思います。\n\n```\n\n Route::get('/redirect/', function() {\n Session::put('key','value');\n Session::save();\n // header(\"Location: /redirect/sample\");\n // exit;\n return redirect('/redirect/sample');\n });\n Route::get('/redirect/sample', function () {\n var_dump(Session::all());\n });\n \n```\n\n* * *\n\n## なぜ?\n\nLaravel\nでは`\\Illuminate\\Session\\Middleware\\StartSession`というミドルウェアでセッションのCookieを発行していますが、実際にその発行を行っている部分は\n[ここ](https://github.com/illuminate/session/blob/v5.6.12/Middleware/StartSession.php#L71)であり、Controllerの処理よりも後です。(Controllerや以降のミドルウェアは[その直前](https://github.com/illuminate/session/blob/v5.6.12/Middleware/StartSession.php#L63)で呼び出されています)\n\n([Laravel 5 のタマネギ構造実装処理 - Web Application Security\nMemo](https://www.pupha.net/archives/3032/) なども参照)\n\nそのため、Controllerの途中でexitしてしまうとこのコードは実行されないためセッションのCookieは発行できないのです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T10:35:27.767", "id": "42440", "last_activity_date": "2018-03-16T10:35:27.767", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2376", "parent_id": "42437", "post_type": "answer", "score": 0 } ]
42437
42440
42440
{ "accepted_answer_id": null, "answer_count": 1, "body": "JFrameを透明にした状態でJTextAreaに日本語入力するとフレームが白くなります。 \n1度白くなると再表示しない限り白いままです。どなたかこの現象の回避方法知りませんか?\n\n```\n\n public static void main (String[] args) {\n JFrame frame =new JFrame();\n frame.setSize(670,500);\n frame.setLocation(600,420);\n frame.setUndecorated(true); \n frame.setBackground(new Color(0x00000000, true)); \n frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);\n \n JTextArea text=new JTextArea();\n text.setBackground(Color.RED);\n text.setBounds(85, 120, 265, 240);\n \n JPanel panel = new JPanel();\n panel.setOpaque(false);\n panel.setLayout(null);\n panel.add(text);\n Container content = frame.getContentPane();\n content.add(panel);\n frame.setVisible(true);\n }\n \n```\n\n環境:windows7 java8", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T09:57:58.030", "favorite_count": 0, "id": "42439", "last_activity_date": "2019-02-13T02:02:30.503", "last_edit_date": "2018-03-16T10:11:56.283", "last_editor_user_id": "27772", "owner_user_id": "27772", "post_type": "question", "score": 1, "tags": [ "java" ], "title": "透明なJFrameに日本語入力すると背景が白くなります。", "view_count": 233 }
[ { "body": "本家SOに類似質問と[回答](https://stackoverflow.com/a/15866690/8248751)がありました。\n\nその回答によるとSwingにおけるDirectDrawパイプラインのバグに起因する現象のようです。 \nDirectDrawレンダリングを無効化することで、質問の現象を回避できました。\n\n```\n\n public static void main (String[] args) {\n System.setProperty(\"sun.java2d.noddraw\", \"true\"); //この行を追加\n JFrame frame = new JFrame(); //以下同じ\n //省略\n }\n \n```\n\n上記は手っ取り早い解決方法です。 \n個別の`JTextArea`に対してDirectDrawを無効化したい場合は、`JTextArea`を継承して`paintComponent`をオーバーライドするコードが本家SOの回答を参照してください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-04-21T00:00:28.137", "id": "43444", "last_activity_date": "2018-04-21T00:00:28.137", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "42439", "post_type": "answer", "score": 2 } ]
42439
null
43444
{ "accepted_answer_id": "42444", "answer_count": 1, "body": "globals()メソッドは何の為に使うものでしょうか? \nコードの中に、\n\n```\n\n test = globals()\n \n```\n\nという行が出てきて、この行がどういう機能を持っているのかわからず苦戦しています・・・。 \n調べたところ、モジュールを返すものみたいですが、何のモジュールを返すのかわからないです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T12:51:12.330", "favorite_count": 0, "id": "42442", "last_activity_date": "2018-03-16T13:26:09.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27691", "post_type": "question", "score": 3, "tags": [ "python" ], "title": "globals()メソッドは何の為に使うものなのか", "view_count": 1097 }
[ { "body": "「モジュールを返す」ではなく、「モジュール内のグローバル変数を返す」です。\n\n頻繁に使うものではないので、そのコードが何のために使ってるのかは推測できませんが、グローバル変数の一覧を取得したかったのかもしれません。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T13:26:09.317", "id": "42444", "last_activity_date": "2018-03-16T13:26:09.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "42442", "post_type": "answer", "score": 2 } ]
42442
42444
42444
{ "accepted_answer_id": null, "answer_count": 0, "body": "Azure 上に作成した App Service について\n\nApp Service から国内の別サイトにアクセスしたいのですが、 \nリージョンが Japan East / West でもApp Serviceに割り当てられるグローバルIPアドレスの国籍が US と判定され、 \n海外からのアクセスを拒否しているサイトにアクセス出来ない場合があります。 \n何か対応方法はあるでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T13:19:14.420", "favorite_count": 0, "id": "42443", "last_activity_date": "2018-03-16T13:19:14.420", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3925", "post_type": "question", "score": 1, "tags": [ "azure" ], "title": "Azure App Service のグローバルIPアドレス", "view_count": 227 }
[]
42443
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "お世話になっております。何卒よろしくお願い申し上げます。\n\nphp、html、javascript、mysqlを利用した動画投稿アプリの作成を企画しております。\n\nそのアプリにスマートフォン(iOS、アンドロイド等)で縦向きに撮影した映像を投稿した際に、 \nphp、html、javascript、mySql、あるいはそのアプリに他のソフトウェアを組み込み、映像を横向きに設定し直す方法などはありますでしょうか。通常どのようにされているのでしょうか。\n\nどうかご教示よろしくお願い申し上げます。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T14:23:04.197", "favorite_count": 0, "id": "42446", "last_activity_date": "2018-03-16T22:41:10.863", "last_edit_date": "2018-03-16T22:41:10.863", "last_editor_user_id": "27240", "owner_user_id": "27240", "post_type": "question", "score": 0, "tags": [ "ios", "android", "php", "html", "video" ], "title": "スマートフォン(iOS、アンドロイド等)で縦向きに撮影した動画の横向きへの設定方法", "view_count": 132 }
[]
42446
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "Ruby の正規表現で、String\nの文字列中に特定の文字列(例では母音[aiueo])が含まれる毎に配列に格納するという判定をしたいです。どのように記述すればよいでしょうか。 \n以下に入力・出力例を記載します。\n\n```\n\n \"sayounara\"\n > [\"sa\",\"yo\",\"u\",\"na\",\"ra\"]\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T14:45:45.340", "favorite_count": 0, "id": "42447", "last_activity_date": "2018-03-16T15:10:33.627", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27773", "post_type": "question", "score": 4, "tags": [ "ruby", "正規表現" ], "title": "Rubyの正規表現で、特定の文字列を含まれる毎に配列に格納したい。", "view_count": 239 }
[ { "body": "文字列に[`scan` メソッド](https://docs.ruby-\nlang.org/ja/2.5.0/class/String.html#I_SCAN)があります。\n\n```\n\n result = \"sayounara\".scan /[^aeiou]*[aeiou]/\n # => [\"sa\", \"yo\", \"u\", \"na\", \"ra\"]\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-16T15:10:33.627", "id": "42448", "last_activity_date": "2018-03-16T15:10:33.627", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "42447", "post_type": "answer", "score": 3 } ]
42447
null
42448
{ "accepted_answer_id": "42457", "answer_count": 2, "body": "皆様いつも御世話になっております。 \nJQuery・JavaScriptのいづれかで、自画面が閉じられるイベントの察知方法を教えてくださいませんか? \nこの察知を行った中で\n\n```\n\n //親画面で無効化したイメージボタンを有効化\n window.opener.$(\".cdsrch\").prop(\"disabled\", false);\n \n```\n\nを達成したいです。\n\nあるデータ受付用の画面はTableの明細を有しており、その各々1列目にコード検索画面を開くためのボタンを配置しています。この押下をもって子画面イメージのコード検索画面をJSでwindow.openしています。 \nその際、元画面の全明細の例のボタンをdisableすることで、子画面が2つ以上呼ばれないような工夫を行っています。 \n子画面側である程度の動作(リストボックスからの選択)が行われれば、当該子画面を閉じると同時に元画面でdisableにしたボタンを再度有効化しているのが現況です。 \nこれ故... \n現況は、コード検索の子画面を右上×ボタンで閉じられてしまうと、親画面のdisableにしたボタンが有効に戻っていない!という状態です。\n\n**_PS_** \nそもそも親画面のJQueryで、子画面が閉じられたら?という察知を図るべきなのでしょうか? \nその察知方法も分かりませんが....\n\nご見解を頂けましたら幸いです、よろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-17T03:47:22.160", "favorite_count": 0, "id": "42452", "last_activity_date": "2018-03-18T13:35:58.040", "last_edit_date": "2018-03-17T07:46:57.833", "last_editor_user_id": "76", "owner_user_id": "25696", "post_type": "question", "score": 0, "tags": [ "javascript", "jquery" ], "title": "画面が閉じられるイベントの察知方法を教えてください。", "view_count": 15547 }
[ { "body": "`unload`イベントが使えると思います。 \n以下は実装サンプルです。\n\n```\n\n // 子画面\n $(window).on('unload', function() {\n window.opener.exports.onChildWindowClosed();\n });\n \n // 親画面\n window.exports = {\n onChildWindowClosed: function() {\n $('.cdsrch').prop('disabled', false);\n }\n };\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-17T07:28:26.407", "id": "42457", "last_activity_date": "2018-03-17T07:28:26.407", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9608", "parent_id": "42452", "post_type": "answer", "score": 1 }, { "body": "参考までに、window.open時に親側でイベント登録のサンプルコードを書いてみました。 \n(IEでは動作確認していませんので参考まで。)\n\n```\n\n <script type=\"text/javascript\">\n var co_window = window.open('test.html','test','width=600,height=600');\n co_window.addEventListener('load',function(event){\n console.log('open');\n co_window.addEventListener('unload',function(event){\n console.log('close');\n }, false);\n }, false);\n </script>\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T13:35:58.040", "id": "42474", "last_activity_date": "2018-03-18T13:35:58.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22793", "parent_id": "42452", "post_type": "answer", "score": 1 } ]
42452
42457
42457
{ "accepted_answer_id": null, "answer_count": 1, "body": "google formを使ってメールアドレスを取得したい。 \nしかし「設定」→「全般」→「メールアドレスを収集する」だと、 \nいちいちアドレスを入力しないといけないので避けたい。\n\nそこで、回答時はgoogleへのログインを必須とし、 \nログイン時の情報からメールアドレス(ログインID)を取得する方法を考えた。\n\nしかし、自分のアドレスは取得できるものの(※)、 \n自分以外のユーザのアドレスは取得できない。 \n自分以外のユーザのアドレスを取得する方法を教えて欲しい\n\n※以下のスクリプトでトリガー登録すれば自分のアドレスは取得可能。\n\n```\n\n function submitForm(e){\n Logger.log(Session.getEffectiveUser().getEmail());\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-17T08:34:03.953", "favorite_count": 0, "id": "42458", "last_activity_date": "2018-08-29T13:54:20.380", "last_edit_date": "2018-03-17T09:16:28.410", "last_editor_user_id": "19110", "owner_user_id": "27778", "post_type": "question", "score": 0, "tags": [ "google-apps-script" ], "title": "メールアドレスを取得したい", "view_count": 597 }
[ { "body": "「表示」→「マニフェストファイルを表示」で下記を記載していますか?\n\n```\n\n {\n ...\n \"oauthScopes\": [\n \"https://www.googleapis.com/auth/userinfo.email\"\n ],\n ...\n }\n \n```\n\n`getEffectiveUser()` を利用するには認可が必要で、スコープを追加する必要があるようです。\n\n[getEffectiveUser()のリファレンス](https://developers.google.com/apps-\nscript/reference/base/session#getEffectiveUser\\(\\)) \n[scopeの追加の方法](https://developers.google.com/apps-\nscript/concepts/scopes#setting_explicit_scopes)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2018-08-29T13:54:20.380", "id": "47920", "last_activity_date": "2018-08-29T13:54:20.380", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29914", "parent_id": "42458", "post_type": "answer", "score": 3 } ]
42458
null
47920
{ "accepted_answer_id": "42463", "answer_count": 1, "body": "モバイル端末とPC端末で表示が異なるWebサイトをWKWebViewを用いて開きましたが、アクセス元がモバイル端末なので当然モバイルサイトがでてきてしまいます \nこれをPC用のサイトを開くようなふるまいにしたいのです \nそこでUser-Agentを偽装しようと \nAppDelegateの didFinishLaunchingWithOptionsに\n\n```\n\n UserDefaults.standard.set(\"UserAgent\" , forKey:\"PC Agent\")\n \n```\n\n”PC Agent”はPCから取得したUser-Agentです\n\nとしてみましたが結果は変わらず、皆様のお力添えをお願いしたいと思い質問いたしました \nよろしくお願いします\n\n環境は \nXcode9.2 \nSwift4.0 \niOS11.1 \niPhone X \nです\n\n追記 \nコード中にあるUserAgentを調べるWebサイトをWKwebViewで開きcustomUserAgentが変更されているか否かを確認しています \n以下のコードでUserAgentの変更を確認しました\n\n```\n\n import UIKit\n import WebKit\n \n class ViewController: UIViewController {\n \n // adjust SafeArea top space\n // portrait のみを想定\n var topPadding:CGFloat = 0\n \n override func viewDidAppear(_ animated: Bool){\n \n print(\"viewDidAppear\")\n \n let screenWidth:CGFloat = view.frame.size.width\n let screenHeight:CGFloat = view.frame.size.height\n \n // iPhone X , X以外は0となる\n if #available(iOS 11.0, *) {\n let window = UIApplication.shared.keyWindow\n topPadding = window!.safeAreaInsets.top\n }\n \n // Webページの大きさを画面に合わせる,横画面\n let rect = CGRect(x: topPadding,\n y: 0,\n width: screenWidth - topPadding,\n height: screenHeight)\n \n let webConfiguration = WKWebViewConfiguration()\n var webView = WKWebView(frame: rect, configuration: webConfiguration)\n let userAgentStr = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146\"\n webView.customUserAgent = userAgentStr\n \n let webUrl = URL(string: \"https://www.baka-ke.com/lab/useragent.php\")!\n let myRequest = URLRequest(url: webUrl)\n webView.load(myRequest)\n \n // インスタンスをビューに追加する\n view.addSubview(webView)\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-17T17:25:32.030", "favorite_count": 0, "id": "42461", "last_activity_date": "2018-03-19T11:48:15.493", "last_edit_date": "2018-03-19T11:48:15.493", "last_editor_user_id": "27784", "owner_user_id": "27784", "post_type": "question", "score": 1, "tags": [ "swift", "xcode", "webview" ], "title": "WKWebViewのUser-Agent偽装方法について", "view_count": 4093 }
[ { "body": "ずいぶん古い記事を参考にされたのでしょうか?\n\niOS9以降であれば`WKWebView`に[`customUserAgent`というプロパティ](https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent)が追加されています。`WKWebView`のインスタンスを生成した直後に値を設定してください。\n\n```\n\n let webView = WKWebView()\n webView.customUserAgent = \"PC Agent\"\n \n```\n\n* * *\n\n(追記のコードについて)\n\nコメント中に書いた「リクエストを送信しているWKWebViewとcustomUserAgentを設定したWKWebViewが異なる」のパターンですね。あなたのコードでは、`WKWebView`のインスタンスを2回作っています。\n\n```\n\n class ViewController: UIViewController {\n \n var webView: WKWebView!\n \n // adjust SafeArea top space\n // portrait のみを想定\n var topPadding:CGFloat = 0\n \n override func viewDidAppear(_ animated: Bool){\n //↓ここで`WKWebView`のインスタンスを作って、`customUserAgent`を設定している\n webView = WKWebView()\n let userAgentStr = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146\"\n webView.customUserAgent = userAgentStr\n \n print(\"viewDidAppear\")\n \n //...\n \n let webConfiguration = WKWebViewConfiguration()\n //↓ここでもう一度`WKWebView`のインスタンスを作っている、さっき`customUserAgent`を設定した`WKWebView`は捨てられる\n webView = WKWebView(frame: rect, configuration: webConfiguration)\n \n let webUrl = URL(string: \"https://www.baka-ke.com/lab/useragent.php\")!\n let myRequest = URLRequest(url: webUrl)\n webView.load(myRequest)\n \n // インスタンスをビューに追加する\n view.addSubview(webView)\n }\n \n```\n\n例えば、あなたの`viewDidLoad()`を以下のように修正してみてください。\n\n```\n\n override func viewDidAppear(_ animated: Bool){\n print(\"viewDidAppear\")\n \n let screenWidth:CGFloat = view.frame.size.width\n let screenHeight:CGFloat = view.frame.size.height\n \n // iPhone X , X以外は0となる\n if #available(iOS 11.0, *) {\n let window = UIApplication.shared.keyWindow\n topPadding = window!.safeAreaInsets.top\n }\n \n // Webページの大きさを画面に合わせる,横画面\n let rect = CGRect(x: topPadding,\n y: 0,\n width: screenWidth - topPadding,\n height: screenHeight)\n \n let webConfiguration = WKWebViewConfiguration()\n webView = WKWebView(frame: rect, configuration: webConfiguration)\n //`WKWebView`のインスタンスを生成した直後に値を設定\n let userAgentStr = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146\"\n webView.customUserAgent = userAgentStr\n \n let webUrl = URL(string: \"https://www.baka-ke.com/lab/useragent.php\")!\n let myRequest = URLRequest(url: webUrl)\n webView.load(myRequest)\n \n // インスタンスをビューに追加する\n view.addSubview(webView)\n }\n \n```\n\n回答内容を自分のコードに合わせて読み替えるというのは少しハードルが高いのかもしれませんが、「`WKWebView`のインスタンスを生成した直後に値を設定してください。」という記述の後に`let\nwebView =\nWKWebView()`というコードをお示ししたのは、「この行をあなたのコードの中で`WKWebView`のインスタンスを生成している部分に置き換えて読んでください」という意味だったりします。(そう読めなければダメという意味ではありません。こんな表現なら意図がより伝わりやすくなると思う、と言ったご提案があればお教えください。)\n\nご提案についてはまた気が向いた時で結構ですので、修正版のコードの方、お試し下さい。", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T01:11:56.563", "id": "42463", "last_activity_date": "2018-03-19T11:45:25.427", "last_edit_date": "2018-03-19T11:45:25.427", "last_editor_user_id": "13972", "owner_user_id": "13972", "parent_id": "42461", "post_type": "answer", "score": 2 } ]
42461
42463
42463
{ "accepted_answer_id": "42489", "answer_count": 1, "body": "App Engine SE for Pythonを使用しており、Cloud Shell上で開発中なのですが、lxmlが入ってないので、 `sudo pip\ninstall lxml` でインストールしました。 \nしかし、数時間立ってCloud Shellを開くとlxmlがおなくなりになっていました。 \nCloud on Airでホームディレクトリ配下以外は消える可能性があるとは聞いていたのですが、本当だったのでしょうか?\n\n毎回、 pipでインストールするのは大変なので、\n\n```\n\n virtualenv env\n source env/bin/activate\n pip install lxml\n dev_appserver.py app.yaml\n \n```\n\nvirtualenvでやってみたのですが、 `No module named lxml` というエラーがでてしまいました。 \n自分の何が悪いのかよくわかりません。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T00:22:25.423", "favorite_count": 0, "id": "42462", "last_activity_date": "2018-03-19T07:45:34.197", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27785", "post_type": "question", "score": 1, "tags": [ "python", "google-app-engine", "google-cloud" ], "title": "Cloud Shellでインストールしたパッケージが消える", "view_count": 220 }
[ { "body": "自己解決しました。\n\n```\n\n libraries:\n - name: lxml\n version: latest\n \n```\n\nをapp.yamlに追加するのを忘れておりました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T07:45:34.197", "id": "42489", "last_activity_date": "2018-03-19T07:45:34.197", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27785", "parent_id": "42462", "post_type": "answer", "score": 1 } ]
42462
42489
42489
{ "accepted_answer_id": null, "answer_count": 1, "body": "下記のGoogleAppsScriptを使おうとすると,コピーの部分で失敗します。 \nIDがAAAというフォルダ以下の全フォルダ・ファイルをIDがBBBというフォルダにコピーし,コピー処理終了後にAAAというフォルダ以下のフォルダ・ファイルをすべてゴミ箱へ移動させるスクリプトになっています。\n\nIDがAAAというフォルダのファイル・フォルダをIDがBBBというフォルダにコピーしようとすると,途中で「上限を超えています: DriveApp(行\n19、ファイル「コード」)」というエラーが出て,一部のみコピーされて大部分はコピーに失敗します。\n\n行19は,「file.makeCopy(file.getName(), dest);」が該当します。\n\nコピー元ファイルは映像ファイルなので,1ファイル2Gbyte程度,一日100ファイル程度になります。 \n一日一度,GoogleDrive内で別フォルダに移動させようとしています。\n\nなお対象フォルダを変更して,小さなファイル(PDF等)では問題なくファイルコピー,その後の元ファイル削除ができることを確認しています。\n\nGoogleに申請して,EarlyAccessProgramには参加済みです。 \nまたG Suiteビジネスを契約しています。\n\nファイルサイズ等の問題でエラーが避けられない場合,別の方法でコピーをさせることはできるのでしょうか。 \nもしくは,エラーを回避する他の方法はあるのでしょうか。\n\nよろしくお願いします。\n\n```\n\n function myFunction() {\n var folders = DriveApp.getFoldersByName(\"映像\");\n var dest = DriveApp.getFolderById('BBB');\n while(folders.hasNext()) {\n var folder = folders.next();\n folderCopy(folder, dest);\n }\n listtrash();\n }\n \n function folderCopy(folder, dest) {\n var folders = folder.getFolders();\n var files = folder.getFiles();\n \n while(files.hasNext()) {\n var file = files.next();\n // file.makeCopy(dest);とすると、****のコピーというファイル名になるので…。\n file.makeCopy(file.getName(), dest);\n }\n \n while(folders.hasNext()) {\n var subFolder = folders.next();\n var folderName = subFolder.getName();\n var copyFolder = dest.createFolder(folderName);\n folderCopy(subFolder, copyFolder);\n } \n }\n \n function listtrash() {\n var removefolders = DriveApp.getFolderById('AAA');\n var removefolder = removefolders.next();\n var subfolders = removefolder.getFolders();\n while(subfolders.hasNext()) {\n var trashFolder = subfolders.next();\n trashFolder.setTrashed(true)\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T03:35:30.567", "favorite_count": 0, "id": "42464", "last_activity_date": "2020-10-15T06:06:45.690", "last_edit_date": "2018-03-21T12:39:58.687", "last_editor_user_id": "27786", "owner_user_id": "27786", "post_type": "question", "score": 0, "tags": [ "google-apps-script", "google-drive-sdk" ], "title": "GoogleDrive内でGoogleAppsScriptによる大きいファイルサイズのファイルコピーに失敗する", "view_count": 356 }
[ { "body": "GoogleDrive の無料プランは確か容量が5Gに制限されていますが、コピーの過程でそれに引っかかっているということはないでしょうか", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T07:53:15.817", "id": "42466", "last_activity_date": "2018-03-18T07:53:15.817", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27481", "parent_id": "42464", "post_type": "answer", "score": 0 } ]
42464
null
42466
{ "accepted_answer_id": null, "answer_count": 1, "body": "下記のC#コードにおけるメソッドの場合、returnで値を返してメソッドから戻る記述方法を教えていただきたいです。 \nこの場合のシーケンス図の書き方は画像のような表記で良いのでしょうか?\n\n```\n\n public class Sample\n {\n public bool IsZeroSecond()\n {\n if (DateTime.Now.Second == 0)\n {\n return true;\n }\n \n return false;\n }\n }\n \n```\n\n[![シーケンス図](https://i.stack.imgur.com/WXqdN.png)](https://i.stack.imgur.com/WXqdN.png)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T05:38:53.363", "favorite_count": 0, "id": "42465", "last_activity_date": "2018-03-19T12:02:06.560", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27788", "post_type": "question", "score": 0, "tags": [ "c#", "uml" ], "title": "UMLシーケンス図の表記についてです", "view_count": 769 }
[ { "body": "シーケンス図では呼び出し元のオブジェクトも一緒に書くのが普通だと思います。 \nreturn で呼び出し元に値を返すので、左向きの点線で表現し 終端マークの黒丸は不要です。\n\nopt の部分はあえて表現したいのかもしれませんが、このサンプルだと、無くても違和感無く感じます。省略する場合は、return の矢印を true と\nfalse でわけず 1本だけ引いて「return : bool」などの表現で十分伝わると思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T12:02:06.560", "id": "42495", "last_activity_date": "2018-03-19T12:02:06.560", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "42465", "post_type": "answer", "score": 1 } ]
42465
null
42495
{ "accepted_answer_id": "42469", "answer_count": 1, "body": "データに格納されているクラスごとに処理を分けたいです。今\n\n```\n\n class Test():\n def test(self, user_code):\n (question, answer_code, type) = ans()\n if user_code == ans_code:\n return True\n else:\n return False\n \n class Array(Test):\n def ans(self):\n \n question = \"TEST1\"\n answer_code =\"TEST1\"\n \n return (question,answer_code,\"Array\")\n \n class For(Test):\n def ans(self):\n \n question = \"TEST2\"\n ans_code =\"TEST2\"\n \n return (question,ans_code,\"For\")\n \n```\n\nのようにコードを書きました。user_dataのデータベースに \nquestion_id | user_id | ans | type \n1 1 TEST1 Array \n2 2 TEST3 For という風にデータが格納されています。 \nこのuser_dataのデータベースのtypeにArrayが入っているときは、class\nArrayのansメソッドを呼び出し、Forが入っているときはclass\nForのansメソッドを呼び出したいです。user_code引数にuser_dataのデータベースのansの中身が入っています。 \nそのようにデータベースの内容と呼び出したいクラスを紐づけるには上記のコードにどう追加すれば良いでしょうか? \nコードを実行すると、ans()メソッドが定義されていないと出ます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T08:20:11.387", "favorite_count": 0, "id": "42467", "last_activity_date": "2018-03-18T09:29:17.390", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27691", "post_type": "question", "score": 1, "tags": [ "python" ], "title": "データに格納されているクラスごとに処理を分けたい", "view_count": 129 }
[ { "body": "コードと説明を読んでもこれをどのように使うのか、何をやりたいのかはいまいちわかりませんので、とりあえずPythonの文法レベルでの回答となります。\n\nans() が見つからないのはそのような関数を定義していないからです。ans()メソッドを呼び出したいのでしたら、\n\n```\n\n (question, answer_code, type) = ans()\n \n```\n\nを以下のように修正してください。\n\n```\n\n (question, answer_code, type) = self.ans()\n \n```\n\nついでに次の行で参照している ans_code という変数も未定義です。\n\n```\n\n if user_code == ans_code:\n \n```\n\nself.ans()の戻り値と比較したいのではないかとと想像されるので、もしそうであれば以下のように修正してください。\n\n```\n\n if user_code == answer_code:\n \n```\n\n以上、ご確認ください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T09:29:17.390", "id": "42469", "last_activity_date": "2018-03-18T09:29:17.390", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27410", "parent_id": "42467", "post_type": "answer", "score": 1 } ]
42467
42469
42469
{ "accepted_answer_id": "42472", "answer_count": 2, "body": "**現在のMySQL5.7で作成したDBユーザーの全てを、新しいMySQL5.7へ移行したいのですがどうすれば良いでしょうか?** \n・ユーザ件数が多いので、1件1件指定する以外の方法があれば知りたいです\n\n**最終的にやりたいこと** \n・MySQL5.7から新しいMySQL5.7へデータ移行したい \n・データはdumpデータ取得しようと思っているが、DBユーザーの移行方法が分からない \n※「DBユーザーだけ移行する方法」ではなくて、「DBユーザーを含む全データを移行する方法」があれば、その方法でも良いです", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T10:07:24.983", "favorite_count": 0, "id": "42470", "last_activity_date": "2018-03-19T02:44:04.093", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": -1, "tags": [ "mysql" ], "title": "MySQL5.7からMySQL5.7へ、全DBユーザーを移行したい", "view_count": 3699 }
[ { "body": "userはmysql databaseに保存されているため、それもdumpしてしまえば移行可能なようです。\n\n本家stackoverflowに回答がありました。 \n<https://stackoverflow.com/questions/3982299/using-mysqldump-and-database-\nusers> \n上記URLから引用\n\nmysql tableのみ\n\n> mysqldump ... --routines --databases database_name mysql > backup.sql\n\nすべてのDB\n\n> mysqldump ... --routines --all-databases > backup.sql", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T13:09:07.873", "id": "42472", "last_activity_date": "2018-03-18T13:09:07.873", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24823", "parent_id": "42470", "post_type": "answer", "score": 3 }, { "body": "全DB、全ユーザーを、別ホストにコピーしたいということであれば、dumpすら使わず、 \n/var/db/mysql を丸ごとコピーしてはどうでしょうか? \nすべてが移行できます。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T02:44:04.093", "id": "42479", "last_activity_date": "2018-03-19T02:44:04.093", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27755", "parent_id": "42470", "post_type": "answer", "score": 1 } ]
42470
42472
42472
{ "accepted_answer_id": null, "answer_count": 2, "body": "document.変数 の役割がわかりません。 \n<http://cya.sakura.ne.jp/java/calc.htm> \nのサイトを見ながらjavascriptを勉強しています。\n\n```\n\n document.myForm.myLine.value = myInput;\n \n```\n\nの行が何をしているのかがわかりません。 \n説明には「現在入力している値表示」と書いてありますが、なぜdocument.変数・・・と書けば値がhtmlに表示されるのでしょうか?\n\ndocumentはWebページを構成しているHTML要素へプログラム上から簡単にアクセスできると調べた時に出てきたのですが、今回の場合だとどのようにアクセスしているのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T11:36:00.743", "favorite_count": 0, "id": "42471", "last_activity_date": "2018-03-19T01:29:32.340", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27691", "post_type": "question", "score": 2, "tags": [ "javascript" ], "title": "document.変数 の役割", "view_count": 401 }
[ { "body": "それは関数 `function myValue(myData)` の定義だけを見ていてもわかりません。 \n後ろの方に HTML のコードが書いてあると思いますが、そこに `name=myForm` および `name=myLine`\nというのを探すことができると思います。 \n`function myValue(myData)` における `myFrom` および `myLine` は HTML\nのコードのその部分のことを指し示しています。\n\nすなわち、`document.myForm.myLine.value` は HTML の `<form name=\"myForm\">...</form>`\n内にある `<input type=\"text\" size=\"12\" name=\"myLine\" value=\"0\">` の値(`value`)を表します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T13:13:02.210", "id": "42473", "last_activity_date": "2018-03-18T13:13:02.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27509", "parent_id": "42471", "post_type": "answer", "score": 3 }, { "body": "[`Document`オブジェクト](https://www.w3.org/TR/html/dom.html#the-document-\nobject)は[`named properties`](https://www.w3.org/TR/WebIDL-1/#idl-named-\nproperties)に対応しているため\n\n```\n\n <form name=\"myForm\" ...>\n \n```\n\nが存在する場合に`document.myForm`で当該要素にアクセス可能です。 \n同様に[`Form`要素](https://www.w3.org/TR/html/sec-forms.html#the-form-\nelement)も`named properties`に対応しているため\n\n```\n\n <form name=\"myForm\" ...>\n ...\n <input name=\"myLine\" ... />\n ...\n </form>\n \n```\n\nが存在する場合に`document.myForm.myLine`で当該要素にアクセス可能です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T01:29:32.340", "id": "42477", "last_activity_date": "2018-03-19T01:29:32.340", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "42471", "post_type": "answer", "score": 3 } ]
42471
null
42473
{ "accepted_answer_id": null, "answer_count": 1, "body": "こんにちは。現在アンドロイドの画像スライドショーのアプリケーションを作っております。概要を説明すると、実機上に保存された画像をcursorで取得し、画面上の再生・進む・戻るボタンで画像を切り替えていくもので、現在各ボタンごとにメソッドを用意して各種操作を行おうとしております。現在つまずいているところは、進む・戻るボタンを押しても画像が切り替わらないというところです。なお、エラーはおこっておりません。 \n以下がコードです。\n\n```\n\n package jp.oooooo.hojun.bun.autoslideshowapp;\n \n import android.Manifest;\n import android.content.ContentResolver;\n import android.content.ContentUris;\n import android.content.pm.PackageManager;\n import android.database.Cursor;\n import android.net.Uri;\n import android.os.Build;\n import android.provider.MediaStore;\n import android.support.v7.app.AppCompatActivity;\n import android.os.Bundle;\n import android.view.View;\n import android.widget.Button;\n import android.widget.ImageView;\n \n public class MainActivity extends AppCompatActivity {\n \n Button mStartPauseButton;\n Button mForwardButton;\n Button mBackButton;\n Cursor cursor;\n \n private static final int PERMISSIONS_REQUEST_CODE = 100;\n \n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n \n mStartPauseButton = findViewById(R.id.button1);\n mForwardButton = findViewById(R.id.button2);\n mBackButton = findViewById(R.id.button3);\n \n mForwardButton.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n getNextInfo();\n }\n });\n \n mBackButton.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View v) {\n getPreviousInfo();\n }\n });\n \n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {\n if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {\n getContentsInfo();\n } else {\n requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST_CODE);\n }\n } else {\n getContentsInfo();\n }\n }\n \n @Override\n public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {\n switch (requestCode) {\n case PERMISSIONS_REQUEST_CODE:\n if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {\n getContentsInfo();\n }\n break;\n default:\n break;\n }\n }\n \n private void getContentsInfo() {\n ContentResolver resolver = getContentResolver();\n cursor = resolver.query(\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI,\n null,\n null,\n null,\n null\n );\n \n cursor.moveToFirst();\n int fieldIndex = cursor.getColumnIndex(MediaStore.Images.Media._ID);\n Long id = cursor.getLong(fieldIndex);\n Uri imageUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);\n \n ImageView imageVIew = findViewById(R.id.imageView);\n imageVIew.setImageURI(imageUri);\n }\n private void getNextInfo() {\n ContentResolver resolver = getContentResolver();\n cursor = resolver.query(\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI,\n null,\n null,\n null,\n null\n );\n \n cursor.moveToFirst();\n int fieldIndex = cursor.getColumnIndex(MediaStore.Images.Media._ID);\n Long id = cursor.getLong(fieldIndex);\n Uri imageUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);\n \n ImageView imageVIew = findViewById(R.id.imageView);\n imageVIew.setImageURI(imageUri);\n }\n \n private void getPreviousInfo() {\n ContentResolver resolver = getContentResolver();\n cursor = resolver.query(\n MediaStore.Images.Media.EXTERNAL_CONTENT_URI,\n null,\n null,\n null,\n null\n );\n \n cursor.moveToFirst();\n int fieldIndex = cursor.getColumnIndex(MediaStore.Images.Media._ID);\n Long id = cursor.getLong(fieldIndex);\n Uri imageUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);\n \n ImageView imageVIew = findViewById(R.id.imageView);\n imageVIew.setImageURI(imageUri);\n }\n \n \n @Override\n protected void onStop() {\n super.onStop();\n cursor.close();\n }\n }\n \n```\n\nどのようにすれば次または前の画像を取得できるでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-18T14:56:19.893", "favorite_count": 0, "id": "42475", "last_activity_date": "2018-03-19T02:48:22.787", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27793", "post_type": "question", "score": -1, "tags": [ "android", "java" ], "title": "Androidアプリ。複数のメソッドでcursorを利用する方法。", "view_count": 653 }
[ { "body": "まず理解すべきポイントが大きく2つありそうです。\n\n 1. 変数のスコープと変数への代入の意味\n 2. AndroidのCursorの機能\n\n* * *\n\n1.についてはプログラミング言語において基本的な内容なので詳細な説明は割愛します。 \n`cursor`はインスタンス変数として宣言されているので、質問文のコードであればどのメソッドからでも参照可能です。 \n但し`getNextInfo()`/`getPreviousInfo`で再代入しているので異なるインスタンスを参照しています。\n\n* * *\n\n2.については`Cursor`をデータリストへの矢印とイメージすると理解しやすいかもしれません。\n\n```\n\n +-----+\n |data1| : moveToFirst()\n +-----+\n |data2| : moveToPrevious()\n +-----+\n |data3| ← Cursor(カーソル)のposition(位置)\n +-----+\n |data4| : moveToNext()\n +-----+\n |data5| : moveToLast()\n +-----+\n \n```\n\n`Cursor`が現在指しているのが`data3`の場合、`Next`/`Previous`はそれぞれ次と前を指すように矢印が移動します。 \n`First`と`Last`はそれぞれデータリストの先頭と末尾を指すように矢印が移動します。\n\n* * *\n\n質問文のコードでは、毎回`Cursor`のインスタンスを再取得し、`moveToFirst`で先頭を指すようにしているため、同じデータしか取得されません。 \nエラー処理を無視して単にコードを記載するなら以下のようになります。 \n(表示画像は最初と最後でループするようにしています。)\n\n```\n\n private void getNextInfo() {\n if (!cursor.moveToNext()) {\n cursor.moveToFirst();\n }\n \n int fieldIndex = cursor.getColumnIndex(MediaStore.Images.Media._ID);\n Long id = cursor.getLong(fieldIndex);\n Uri imageUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);\n \n ImageView imageVIew = findViewById(R.id.imageView);\n imageVIew.setImageURI(imageUri);\n }\n \n private void getPreviousInfo() {\n if (!cursor.moveToPrevious()) {\n cursor.moveToLast();\n }\n \n int fieldIndex = cursor.getColumnIndex(MediaStore.Images.Media._ID);\n Long id = cursor.getLong(fieldIndex);\n Uri imageUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);\n \n ImageView imageVIew = findViewById(R.id.imageView);\n imageVIew.setImageURI(imageUri);\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T02:48:22.787", "id": "42480", "last_activity_date": "2018-03-19T02:48:22.787", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "42475", "post_type": "answer", "score": 2 } ]
42475
null
42480
{ "accepted_answer_id": null, "answer_count": 1, "body": "Anaconda3をインストール。`pip install\nselenium`でseleniumをインストールしようと試みる、以下のようなエラーが吐き出される。修正方法をご教授いただきたい。\n\n```\n\n Cache entry deserialization failed, entry ignored\n Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000020EB71675F8>: Failed to establish a new connection: [WinError 10013] アクセス許可で禁じられた方法でソケットにアクセスしようとしました。',)': /simple/selenium/\n \n Could not find a version that satisfies the requirement selenium (from versions: )\n No matching distribution found for selenium\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T01:16:03.930", "favorite_count": 0, "id": "42476", "last_activity_date": "2023-01-10T22:08:10.960", "last_edit_date": "2018-03-19T01:31:03.747", "last_editor_user_id": "27798", "owner_user_id": "27798", "post_type": "question", "score": 0, "tags": [ "python", "anaconda" ], "title": "seleniumがインストールできない", "view_count": 4015 }
[ { "body": "[WinError 10013]はWindows側でソケットを開かないようにしていることで出るエラーのようです。\n\n調べてみると、以下の原因が考えられるようです。\n\n> 1. ソケットのオープンに管理者権限が必要\n> 2. 他のプログラムがすでに同じポートを利用している\n> 3. Firewallやアンチウイルスソフトによって制限されている\n>\n\n1の場合、管理者権限の場合は管理者権限を与えることで解決するかもしれません。 \n3の場合、Firewallやアンチウイルスソフトでの設定が必要になるとおもいます。\n\n[こちらを参考](https://ja.scribd.com/document/359539247/How-to-Fix-\nWinError-10013)にしました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T01:33:54.790", "id": "42478", "last_activity_date": "2018-03-19T01:33:54.790", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24823", "parent_id": "42476", "post_type": "answer", "score": 1 } ]
42476
null
42478
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在、javaでキャラクター育成ゲームの作成を行っています。コンパイルして\n\n 1. ミルクを与える\n 2. 寝る\n 3. あやす\n\nという選択肢を入力して、switchでその選択肢ごとにポイントが加算されるよう分岐させています。 \nそれぞれ選択No.を入力した段階で、その度にポイント加算されたステータスが表示されるようにしたいのですが(getYutoStatus()関数が表示)、現在は\n\n```\n\n $ java part01\n Yuto君、こんにちは!!\n Yuto君は今0才です\n 頑張って育てよう\n 1. ミルクを与える\n 2. 寝る\n 3. あやす\n 2\n 1. ミルクを与える\n 2. 寝る\n 3. あやす\n 3\n 1. ミルクを与える\n 2. 寝る\n 3. あやす\n 4\n Yuto君は育成ポイント17でマイナスポイント0\n Yuto君は育成ポイント17でマイナスポイント0\n \n```\n\nのようにそのまま次の選択の処理に入ってしまい、結果は最期に表示されています。 \nその都度「入力+結果表示」にする様にできる記述の方法を教えて欲しいです。 \nよろしくお願いします。\n\n```\n\n public class part01{\n static String name = \"Yuto\"; //キャラクターの名前\n static int age; //キャラクターの年齢\n static int good = 5; //キャラクターの育成ポイント\n static int wagamama = 0; //キャラクターのマイナスポイント\n \n public static void main (String[] args) throws java.io.IOException{\n putOpening();\n putCommand();\n putStageClear();\n }\n \n public static void putCommand() throws java.io.IOException{\n \n put(\"1. ミルクを与える\");\n put(\"2. 寝る\");\n put(\"3. あやす\");\n \n switch(inputCommand()){\n case '1':{\n good += 2;\n putCommand();\n getYutoStatus();\n break;\n }\n case '2':{\n good += 5;\n putCommand();\n getYutoStatus();\n break;\n }\n case '3':{\n good += 7;\n putCommand();\n getYutoStatus();\n break;\n }\n \n }\n \n }\n \n /**\n * オープニングを表示\n */\n public static void putOpening(){\n System.out.println(name + \"君、こんにちは!!\");\n System.out.println(name + \"君は今\" + age + \"才です\");\n System.out.println(\"頑張って育てよう\");\n }\n \n public static void getYutoStatus(){\n put(name + \"君は\" + \"育成ポイント\" + good + \"で\" + \"マイナスポイント\" + wagamama);\n }\n \n /**\n * ステージクリア画面を表示\n */\n public static void putStageClear(){\n \n if(good >= 20){\n age = 1;\n put(name + \"君は\" + age + \"才になりました!!\");\n }else if(good >= 30){\n age = 2;\n put(name + \"君は\" + age + \"才になりました!!\");\n }else if(good >= 40){\n age = 3;\n put(name + \"君は\" + age + \"才になりました!!\");\n }\n }\n \n /**\n * 育児を行う\n */\n /*\n static void ikuji(){\n //育児ポイントの上昇\n //わがまま・マイナスポイント\n int d = r.nextInt(8);\n wagamama -= d;\n \n }\n */\n \n public static int inputCommand() throws java.io.IOException{\n \n int c = System.in.read();\n if(c == 10 || c == 13){\n return(inputCommand());\n }\n return(c);\n }\n \n public static void put(String str){\n System.out.println(str);\n }\n \n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T02:51:32.643", "favorite_count": 0, "id": "42481", "last_activity_date": "2018-03-30T05:27:20.630", "last_edit_date": "2018-03-19T02:59:40.047", "last_editor_user_id": "3060", "owner_user_id": "9769", "post_type": "question", "score": 0, "tags": [ "java" ], "title": "switch文の中でのステータス表示を繰り返したい", "view_count": 297 }
[ { "body": "結論からいわせていただきますと、switch文の中のgetYutoStatus()をputCommand()の前にすればいいと思います。\n\n補足: \n1\\. switch文にdefault処理をいれましょう \n2\\. nameをprivate static finalにしましょう \n3\\.\ninputCommandメソッドのif文のところ、マジックナンバーように見えますが、10と13って何でしょうか?意味のある数字であれば、定数を定義して使ってみませんか", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-30T05:16:59.000", "id": "42773", "last_activity_date": "2018-03-30T05:27:20.630", "last_edit_date": "2018-03-30T05:27:20.630", "last_editor_user_id": "27732", "owner_user_id": "27732", "parent_id": "42481", "post_type": "answer", "score": 1 } ]
42481
null
42773
{ "accepted_answer_id": null, "answer_count": 0, "body": "お世話になっております。\n\nあるiOSのゲームでプレーヤーがある場面でどのくらいの時間を使ったかを調査したいと思っています(依頼されました)。\n\nやや特殊なところとして、これはゲームなので、UIViewControllerの滞在時間とは異なります。同一UIViewControllerの中にステージ1,\n2, 3, ...\nが表示されます。その各ステージにどのくらい時間を要したかを調査したいということです。例えば一般的にステージ12はかなり時間をかける傾向があるが、ステージ31はすぐに解けるようだ、と知りたいのです。\n\nできれば、Google\nAnalyticsやFirebaseのようなものでうまくイベントを記録していきたいと思っています。これはバックエンドを作るのにかなり手間がかかると予想されるからで、うまく代理してくれるツールがあればそれに頼りたいと思っています。\n\nこうした用途に適したツールをご存知でしたら紹介していただけると幸いです。指針だけでもいただけたら調査致します。\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T03:56:49.473", "favorite_count": 0, "id": "42482", "last_activity_date": "2018-03-19T03:56:49.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14631", "post_type": "question", "score": 1, "tags": [ "ios", "firebase", "google-analytics-api", "mixpanel", "logging" ], "title": "iOSでユーザがある画面にどのくらいの時間を使ったか計測する方法について", "view_count": 116 }
[]
42482
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "ClosedXMLでExcel1(book1.xlsx)のワークシートをExcel2(book2.xlsx)にコピーする処理を実装中です。\n\n```\n\n var copySheet = excel1._Workbook.WorkSheet(1);\n copySheet.CopyTo(excel2._Workbook, sheetName, nSheetNum);\n excel2._Workbook.Save();\n \n```\n\nbook1.xlsxにはセル参照等が入っており、上記のように行うとセル参照も一緒にコピーされてしまうため、値のみコピーしたいのですが、なにか方法はありますか?\n\n宜しくお願い致します。\n\nvisual studio 2017 / C#", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-03-19T04:34:21.007", "favorite_count": 0, "id": "42483", "last_activity_date": "2018-03-19T04:34:21.007", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19580", "post_type": "question", "score": 0, "tags": [ "c#", "visual-studio" ], "title": "ClosedXMLで別ブックにシートをコピーする際に値のみでコピーしたい", "view_count": 5892 }
[]
42483
null
null