question
dict | answers
list | id
stringlengths 2
5
| accepted_answer_id
stringlengths 2
5
⌀ | popular_answer_id
stringlengths 2
5
⌀ |
---|---|---|---|---|
{
"accepted_answer_id": "59428",
"answer_count": 1,
"body": "checkboxが複数選択された場合と単体の場合で表示されるボタンを変えたいのですが、 \nどのようにしたらよいかわからず困っています。\n\nスニペットに記載したもので、 \ncheckboxにチェックをいれると`tab1`のボタンを表示させることができました。 \n(こちらのスニペットでは、うまくボタンが表示させることができませんでした。。)\n\nただ、複数選択した場合は`tab2`のボタンを表示させたいのですが、 \nどのようにしたらよいかご教授いただけますと大変助かります。\n\n何卒よろしくお願いいたします。\n\n**参考にしたページ** \n[iCheckを利用時のチェックの有る無しで表示を切り替える](https://hacknote.jp/archives/16905/)\n\n下記のように修正してみたことにより、 \n単体チェック、複数チェックによってボタンの表示内容を変えることはできました。\n\n```\n\n $('input').on('ifChecked', function(event){\n var check_count = $('.check :checked').length;\n \n if (check_count == 1) {\n $('#tab1').show().addClass('active');\n } else if (check_count > 1 ) {\n $('#tab2').show().addClass('active');\n $('#tab1').hide().removeClass('active');\n }\n });\n \n $('input').on('ifUnchecked', function(event){\n $('#tab1').hide().removeClass('active');\n $('#tab2').hide().removeClass('active');\n });\n \n```\n\nただ、チェックを外した時にボタンの表示内容をかえるのがうまくできません。 \n今はチェックを外すと、tab1/tab2のボタンがすべて消えてしまいます。\n\nやりたいことは、 \n▼複数チェックされていたとき、 \nすべてのチェックが外された時は、tab1/tab2非表示。 \nチェックが外されて1個のみチェックされている時は、tab1表示。 \nチェックが外されても2個以上チェックされている時は、tab2表示。\n\n▼単体チェックされていたとき、 \nすべてのチェックが外された時は、tab1/tab2が非表示。\n\n```\n\n /*!\r\n * iCheck v1.0.1, http://git.io/arlzeA\r\n * =================================\r\n * Powerful jQuery and Zepto plugin for checkboxes and radio buttons customization\r\n *\r\n * (c) 2013 Damir Sultanov, http://fronteed.com\r\n * MIT Licensed\r\n */\r\n \r\n (function($) {\r\n \r\n // Cached vars\r\n var _iCheck = 'iCheck',\r\n _iCheckHelper = _iCheck + '-helper',\r\n _checkbox = 'checkbox',\r\n _radio = 'radio',\r\n _checked = 'checked',\r\n _unchecked = 'un' + _checked,\r\n _disabled = 'disabled',\r\n _determinate = 'determinate',\r\n _indeterminate = 'in' + _determinate,\r\n _update = 'update',\r\n _type = 'type',\r\n _click = 'click',\r\n _touch = 'touchbegin.i touchend.i',\r\n _add = 'addClass',\r\n _remove = 'removeClass',\r\n _callback = 'trigger',\r\n _label = 'label',\r\n _cursor = 'cursor',\r\n _mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);\r\n \r\n // Plugin init\r\n $.fn[_iCheck] = function(options, fire) {\r\n \r\n // Walker\r\n var handle = 'input[type=\"' + _checkbox + '\"], input[type=\"' + _radio + '\"]',\r\n stack = $(),\r\n walker = function(object) {\r\n object.each(function() {\r\n var self = $(this);\r\n \r\n if (self.is(handle)) {\r\n stack = stack.add(self);\r\n } else {\r\n stack = stack.add(self.find(handle));\r\n }\r\n });\r\n };\r\n \r\n // Check if we should operate with some method\r\n if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {\r\n \r\n // Normalize method's name\r\n options = options.toLowerCase();\r\n \r\n // Find checkboxes and radio buttons\r\n walker(this);\r\n \r\n return stack.each(function() {\r\n var self = $(this);\r\n \r\n if (options == 'destroy') {\r\n tidy(self, 'ifDestroyed');\r\n } else {\r\n operate(self, true, options);\r\n }\r\n // Fire method's callback\r\n if ($.isFunction(fire)) {\r\n fire();\r\n }\r\n });\r\n \r\n // Customization\r\n } else if (typeof options == 'object' || !options) {\r\n \r\n // Check if any options were passed\r\n var settings = $.extend({\r\n checkedClass: _checked,\r\n disabledClass: _disabled,\r\n indeterminateClass: _indeterminate,\r\n labelHover: true,\r\n aria: false\r\n }, options),\r\n \r\n selector = settings.handle,\r\n hoverClass = settings.hoverClass || 'hover',\r\n focusClass = settings.focusClass || 'focus',\r\n activeClass = settings.activeClass || 'active',\r\n labelHover = !!settings.labelHover,\r\n labelHoverClass = settings.labelHoverClass || 'hover',\r\n \r\n // Setup clickable area\r\n area = ('' + settings.increaseArea).replace('%', '') | 0;\r\n \r\n // Selector limit\r\n if (selector == _checkbox || selector == _radio) {\r\n handle = 'input[type=\"' + selector + '\"]';\r\n }\r\n // Clickable area limit\r\n if (area < -50) {\r\n area = -50;\r\n }\r\n // Walk around the selector\r\n walker(this);\r\n \r\n return stack.each(function() {\r\n var self = $(this);\r\n \r\n // If already customized\r\n tidy(self);\r\n \r\n var node = this,\r\n id = node.id,\r\n \r\n // Layer styles\r\n offset = -area + '%',\r\n size = 100 + (area * 2) + '%',\r\n layer = {\r\n position: 'absolute',\r\n top: offset,\r\n left: offset,\r\n display: 'block',\r\n width: size,\r\n height: size,\r\n margin: 0,\r\n padding: 0,\r\n background: '#fff',\r\n border: 0,\r\n opacity: 0\r\n },\r\n \r\n // Choose how to hide input\r\n hide = _mobile ? {\r\n position: 'absolute',\r\n visibility: 'hidden'\r\n } : area ? layer : {\r\n position: 'absolute',\r\n opacity: 0\r\n },\r\n \r\n // Get proper class\r\n className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox : settings.radioClass || 'i' + _radio,\r\n \r\n // Find assigned labels\r\n label = $(_label + '[for=\"' + id + '\"]').add(self.closest(_label)),\r\n \r\n // Check ARIA option\r\n aria = !!settings.aria,\r\n \r\n // Set ARIA placeholder\r\n ariaID = _iCheck + '-' + Math.random().toString(36).replace('0.', ''),\r\n \r\n // Parent & helper\r\n parent = '<div class=\"' + className + '\" ' + (aria ? 'role=\"' + node[_type] + '\" ' : ''),\r\n helper;\r\n \r\n // Set ARIA \"labelledby\"\r\n if (label.length && aria) {\r\n label.each(function() {\r\n parent += 'aria-labelledby=\"';\r\n \r\n if (this.id) {\r\n parent += this.id;\r\n } else {\r\n this.id = ariaID;\r\n parent += ariaID;\r\n }\r\n \r\n parent += '\"';\r\n });\r\n }\r\n // Wrap input\r\n parent = self.wrap(parent + '/>')[_callback]('ifCreated').parent().append(settings.insert);\r\n \r\n // Layer addition\r\n helper = $('<ins class=\"' + _iCheckHelper + '\"/>').css(layer).appendTo(parent);\r\n \r\n // Finalize customization\r\n self.data(_iCheck, {o: settings, s: self.attr('style')}).css(hide);\r\n !!settings.inheritClass && parent[_add](node.className || '');\r\n !!settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);\r\n parent.css('position') == 'static' && parent.css('position', 'relative');\r\n operate(self, true, _update);\r\n \r\n // Label events\r\n if (label.length) {\r\n label.on(_click + '.i mouseover.i mouseout.i ' + _touch, function(event) {\r\n var type = event[_type],\r\n item = $(this);\r\n \r\n // Do nothing if input is disabled\r\n if (!node[_disabled]) {\r\n \r\n // Click\r\n if (type == _click) {\r\n if ($(event.target).is('a')) {\r\n return;\r\n }\r\n operate(self, false, true);\r\n \r\n // Hover state\r\n } else if (labelHover) {\r\n \r\n // mouseout|touchend\r\n if (/ut|nd/.test(type)) {\r\n parent[_remove](hoverClass);\r\n item[_remove](labelHoverClass);\r\n } else {\r\n parent[_add](hoverClass);\r\n item[_add](labelHoverClass);\r\n }\r\n }\r\n if (_mobile) {\r\n event.stopPropagation();\r\n } else {\r\n return false;\r\n }\r\n }\r\n });\r\n }\r\n // Input events\r\n self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) {\r\n var type = event[_type],\r\n key = event.keyCode;\r\n \r\n // Click\r\n if (type == _click) {\r\n return false;\r\n \r\n // Keydown\r\n } else if (type == 'keydown' && key == 32) {\r\n if (!(node[_type] == _radio && node[_checked])) {\r\n if (node[_checked]) {\r\n off(self, _checked);\r\n } else {\r\n on(self, _checked);\r\n }\r\n }\r\n return false;\r\n \r\n // Keyup\r\n } else if (type == 'keyup' && node[_type] == _radio) {\r\n !node[_checked] && on(self, _checked);\r\n \r\n // Focus/blur\r\n } else if (/us|ur/.test(type)) {\r\n parent[type == 'blur' ? _remove : _add](focusClass);\r\n }\r\n });\r\n \r\n // Helper events\r\n helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch, function(event) {\r\n var type = event[_type],\r\n \r\n // mousedown|mouseup\r\n toggle = /wn|up/.test(type) ? activeClass : hoverClass;\r\n \r\n // Do nothing if input is disabled\r\n if (!node[_disabled]) {\r\n \r\n // Click\r\n if (type == _click) {\r\n operate(self, false, true);\r\n \r\n // Active and hover states\r\n } else {\r\n \r\n // State is on\r\n if (/wn|er|in/.test(type)) {\r\n \r\n // mousedown|mouseover|touchbegin\r\n parent[_add](toggle);\r\n \r\n // State is off\r\n } else {\r\n parent[_remove](toggle + ' ' + activeClass);\r\n }\r\n // Label hover\r\n if (label.length && labelHover && toggle == hoverClass) {\r\n \r\n // mouseout|touchend\r\n label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass);\r\n }\r\n }\r\n if (_mobile) {\r\n event.stopPropagation();\r\n } else {\r\n return false;\r\n }\r\n }\r\n });\r\n });\r\n } else {\r\n return this;\r\n }\r\n };\r\n \r\n // Do something with inputs\r\n function operate(input, direct, method) {\r\n var node = input[0],\r\n state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked,\r\n active = method == _update ? {\r\n checked: node[_checked],\r\n disabled: node[_disabled],\r\n indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'\r\n } : node[state];\r\n \r\n // Check, disable or indeterminate\r\n if (/^(ch|di|in)/.test(method) && !active) {\r\n on(input, state);\r\n \r\n // Uncheck, enable or determinate\r\n } else if (/^(un|en|de)/.test(method) && active) {\r\n off(input, state);\r\n \r\n // Update\r\n } else if (method == _update) {\r\n \r\n // Handle states\r\n for (var state in active) {\r\n if (active[state]) {\r\n on(input, state, true);\r\n } else {\r\n off(input, state, true);\r\n }\r\n }\r\n } else if (!direct || method == 'toggle') {\r\n \r\n // Helper or label was clicked\r\n if (!direct) {\r\n input[_callback]('ifClicked');\r\n }\r\n // Toggle checked state\r\n if (active) {\r\n if (node[_type] !== _radio) {\r\n off(input, state);\r\n }\r\n } else {\r\n on(input, state);\r\n }\r\n }\r\n }\r\n // Add checked, disabled or indeterminate state\r\n function on(input, state, keep) {\r\n var node = input[0],\r\n parent = input.parent(),\r\n checked = state == _checked,\r\n indeterminate = state == _indeterminate,\r\n disabled = state == _disabled,\r\n callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',\r\n regular = option(input, callback + capitalize(node[_type])),\r\n specific = option(input, state + capitalize(node[_type]));\r\n \r\n // Prevent unnecessary actions\r\n if (node[state] !== true) {\r\n \r\n // Toggle assigned radio buttons\r\n if (!keep && state == _checked && node[_type] == _radio && node.name) {\r\n var form = input.closest('form'),\r\n inputs = 'input[name=\"' + node.name + '\"]';\r\n \r\n inputs = form.length ? form.find(inputs) : $(inputs);\r\n \r\n inputs.each(function() {\r\n if (this !== node && $(this).data(_iCheck)) {\r\n off($(this), state);\r\n }\r\n });\r\n }\r\n // Indeterminate state\r\n if (indeterminate) {\r\n \r\n // Add indeterminate state\r\n node[state] = true;\r\n \r\n // Remove checked state\r\n if (node[_checked]) {\r\n off(input, _checked, 'force');\r\n }\r\n // Checked or disabled state\r\n } else {\r\n \r\n // Add checked or disabled state\r\n if (!keep) {\r\n node[state] = true;\r\n }\r\n // Remove indeterminate state\r\n if (checked && node[_indeterminate]) {\r\n off(input, _indeterminate, false);\r\n }\r\n }\r\n // Trigger callbacks\r\n callbacks(input, checked, state, keep);\r\n }\r\n // Add proper cursor\r\n if (node[_disabled] && !!option(input, _cursor, true)) {\r\n parent.find('.' + _iCheckHelper).css(_cursor, 'default');\r\n }\r\n // Add state class\r\n parent[_add](specific || option(input, state) || '');\r\n \r\n // Set ARIA attribute\r\n disabled ? parent.attr('aria-disabled', 'true') : parent.attr('aria-checked', indeterminate ? 'mixed' : 'true');\r\n \r\n // Remove regular state class\r\n parent[_remove](regular || option(input, callback) || '');\r\n }\r\n // Remove checked, disabled or indeterminate state\r\n function off(input, state, keep) {\r\n var node = input[0],\r\n parent = input.parent(),\r\n checked = state == _checked,\r\n indeterminate = state == _indeterminate,\r\n disabled = state == _disabled,\r\n callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',\r\n regular = option(input, callback + capitalize(node[_type])),\r\n specific = option(input, state + capitalize(node[_type]));\r\n \r\n // Prevent unnecessary actions\r\n if (node[state] !== false) {\r\n \r\n // Toggle state\r\n if (indeterminate || !keep || keep == 'force') {\r\n node[state] = false;\r\n }\r\n // Trigger callbacks\r\n callbacks(input, checked, callback, keep);\r\n }\r\n // Add proper cursor\r\n if (!node[_disabled] && !!option(input, _cursor, true)) {\r\n parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');\r\n }\r\n // Remove state class\r\n parent[_remove](specific || option(input, state) || '');\r\n \r\n // Set ARIA attribute\r\n disabled ? parent.attr('aria-disabled', 'false') : parent.attr('aria-checked', 'false');\r\n \r\n // Add regular state class\r\n parent[_add](regular || option(input, callback) || '');\r\n }\r\n // Remove all traces\r\n function tidy(input, callback) {\r\n if (input.data(_iCheck)) {\r\n \r\n // Remove everything except input\r\n input.parent().html(input.attr('style', input.data(_iCheck).s || ''));\r\n \r\n // Callback\r\n if (callback) {\r\n input[_callback](callback);\r\n }\r\n // Unbind events\r\n input.off('.i').unwrap();\r\n $(_label + '[for=\"' + input[0].id + '\"]').add(input.closest(_label)).off('.i');\r\n }\r\n }\r\n // Get some option\r\n function option(input, state, regular) {\r\n if (input.data(_iCheck)) {\r\n return input.data(_iCheck).o[state + (regular ? '' : 'Class')];\r\n }\r\n }\r\n // Capitalize some string\r\n function capitalize(string) {\r\n return string.charAt(0).toUpperCase() + string.slice(1);\r\n }\r\n // Executable handlers\r\n function callbacks(input, checked, callback, keep) {\r\n if (!keep) {\r\n if (checked) {\r\n input[_callback]('ifToggled');\r\n }\r\n input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));\r\n }\r\n }\r\n })(window.jQuery || window.Zepto);\r\n \r\n \r\n // checkboの状態によってボタンを表示・非表示\r\n $('input').on('ifChecked', function(event){\r\n var check_count = $('.check :checked').length;\r\n \r\n if (check_count == 1) {\r\n $('#tab1').show().addClass('active');\r\n } else if (check_count > 1 ) {\r\n $('#tab2').show().addClass('active');\r\n $('#tab1').hide().removeClass('active');\r\n }\r\n });\r\n \r\n $('input').on('ifUnchecked', function(event){\r\n $('#tab1').hide().removeClass('active');\r\n $('#tab2').hide().removeClass('active');\r\n });\n```\n\n```\n\n #tab1 {\r\n display: none;\r\n }\r\n #tab2 {\r\n display: none;\r\n }\n```\n\n```\n\n <script src=\"http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js\"></script>\r\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js\"></script>\r\n <script type=\"text/javascript\" charset=\"utf8\" src=\"http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js\"></script>\r\n <!-- DataTables -->\r\n <script type=\"text/javascript\" charset=\"utf8\" src=\"http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js\"></script>\r\n \r\n <section class=\"content container-fluid\">\r\n <div class=\"box box-primary\">\r\n <div class=\"box-header\">\r\n <div id=\"tab1\">\r\n <button>B</button>\r\n <button>C</button>\r\n </div>\r\n <div id=\"tab2\">\r\n <button>D</button>\r\n <button>E</button>\r\n </div> \r\n </div>\r\n </div>\r\n <div class=\"box-body\">\r\n <div class=\"table-responsive\">\r\n <table class=\"table table-bordered dataTable\">\r\n <thead>\r\n <tr>\r\n <th></th>\r\n <th>id</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <tr>\r\n <td>\r\n <input type=\"checkbox\" class=\"check\">\r\n </td>\r\n <td>1</td>\r\n </tr>\r\n <tr>\r\n <td>\r\n <input type=\"checkbox\" class=\"check\">\r\n </td>\r\n <td>2</td>\r\n </tr>\r\n <tr>\r\n <td>\r\n <input type=\"checkbox\" class=\"check\">\r\n </td>\r\n <td>3</td>\r\n </tr> \r\n </tbody>\r\n </table>\r\n </div>\r\n </div>\r\n </section>\n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T00:23:32.470",
"favorite_count": 0,
"id": "59309",
"last_activity_date": "2019-10-03T05:42:43.483",
"last_edit_date": "2019-09-27T06:41:45.313",
"last_editor_user_id": "35901",
"owner_user_id": "35901",
"post_type": "question",
"score": -1,
"tags": [
"jquery"
],
"title": "checkboxが複数選択された場合と単体の場合で表示されるボタンをかえたい",
"view_count": 371
} | [
{
"body": "```\n\n $('input').on('ifChecked', updateButtons);\n $('input').on('ifUnchecked', updateButtons);\n \n function updateButtons(event) {\n var check_count = $('.icheckbox_flat-blue :checked').length;\n if (check_count == 0) {\n $('#tab1').hide().removeClass('active');\n $('#tab2').hide().removeClass('active');\n } else if (check_count == 1) {\n $('#tab1').show().addClass('active');\n $('#tab2').hide().removeClass('active');\n } else {\n $('#tab1').hide().removeClass('active');\n $('#tab2').show().addClass('active');\n }\n }\n \n```\n\n上記のようにしたら、希望の動作になった。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T05:42:43.483",
"id": "59428",
"last_activity_date": "2019-10-03T05:42:43.483",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35901",
"parent_id": "59309",
"post_type": "answer",
"score": -1
}
] | 59309 | 59428 | 59428 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "パスワードが一致しなかった場合にはアラートを表示します。 \nアラートのOKをクリックすると入力した内容が全て消えてしまうのですが、消えずにそのまま残すにはどうしたらいいのか教えていただきたいです。\n\najaxを使うと複雑になるとおもうのですが、どのようにするのか教えて頂きたいです。\n\n**Javascript**\n\n```\n\n function passwordCheckFunction() {\n var loginPass1= document.getElementById(\"loginPass1\").value;\n var loginPass2= document.getElementById(\"loginPass2\").value;\n \n if(loginPass1 !== loginPass2){\n alert(\"パスワードが一致していません。\")\n }\n }\n \n```\n\n**HTML**\n\n```\n\n <tr>\n <th>パスワード</th>\n <td>\n <input type=\"password\" class=\"form-control\" id = \"loginPass1\" th:field=\"*{loginPass}\">\n </td>\n </tr>\n <tr>\n <th>パスワード確認</th>\n <td>\n <input type=\"password\" class=\"form-control\" id = \"loginPass2\" th:field=\"*{loginPass}\">\n </td>\n </tr>\n <button type=\"button\" class=\"passwordCheck\" onclick=\"passwordCheckFunction()\">Click Me!</button>\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T02:52:26.353",
"favorite_count": 0,
"id": "59313",
"last_activity_date": "2019-09-27T05:39:22.327",
"last_edit_date": "2019-09-27T05:39:22.327",
"last_editor_user_id": "3060",
"owner_user_id": "35696",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"thymeleaf"
],
"title": "アラートのOKをクリック後も、フォームに入力した値を残す方法",
"view_count": 329
} | [] | 59313 | null | null |
{
"accepted_answer_id": "59439",
"answer_count": 2,
"body": "C#でAES暗号化していた処理をC++でも利用するために変換を試みているのですが、Crypto++ライブラリを使っての実装ができません。 \n暗号化はできているようなのですが、結果が異なってしまいます。\n\nブロックサイズとキーサイズの指定が怪しいと考えているのですが、どこが要因かわかる方ご教授願えますでしょうか。\n\nC# Code\n\n```\n\n const string AesIV = @\"1234567890123456\";\n const string AesKey = @\"ABCDEFGHIJKLMNOP\";\n string strText = \"暗号化テスト\";\n \n AesCryptoServiceProvider aes = new AesCryptoServiceProvider();\n aes.BlockSize = 128;\n aes.KeySize = 128;\n aes.IV = Encoding.UTF8.GetBytes(AesIV);\n aes.Key = Encoding.UTF8.GetBytes(AesKey);\n aes.Mode = CipherMode.CBC;\n aes.Padding = PaddingMode.PKCS7;\n byte[] byteText = Encoding.UTF8.GetBytes(strText);\n \n byte[] encryptText = aes.CreateEncryptor().TransformFinalBlock(byteText, 0, byteText.Length);\n \n```\n\nC++ Code (Crypto++利用)\n\n```\n\n std::string strKey(\"1234567890123456\");\n std::string strIV(\"ABCDEFGHIJKLMNOP\");\n std::string strText = \"暗号化テスト\";\n \n std::string stEncryptText;\n \n CryptoPP::AES::Encryption aesEncryption((CryptoPP::byte*)strKey.c_str(), CryptoPP::AES::DEFAULT_KEYLENGTH);\n CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption, (CryptoPP::byte*)strIV.c_str());\n \n CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink(stEncryptText), CryptoPP::BlockPaddingSchemeDef::PKCS_PADDING);\n stfEncryptor.Put(reinterpret_cast<const unsigned char*>(strText.c_str()), strText.length());\n stfEncryptor.MessageEnd();\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T03:23:17.590",
"favorite_count": 0,
"id": "59314",
"last_activity_date": "2023-05-07T03:34:44.173",
"last_edit_date": "2023-05-07T03:34:44.173",
"last_editor_user_id": "4236",
"owner_user_id": "35986",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"c++",
"encoding",
"encryption"
],
"title": "AES暗号化処理をC#からC++に変換したい",
"view_count": 1715
} | [
{
"body": "コメントでの指摘の通り、平文データに相違があることが考えられます。\n\nさらに、鍵とIVに文字列を使っているのが2つの点でまずいです。\n\n# セキュリティ的に問題\n\n安全に暗号を運用するには、鍵やIVは乱数かパスワードをPBKDF2のような鍵導出関数に通して取り出した値を使わなければなりません。その点で、文字列を使っているサンプルコードは参考にしないほうがよいです。\n\n# バイト表現に変換するときに意図しない変換が混入する\n\n例えば`c_str()`で変換すると、末尾に`\\0`が含まれるとか、逆に元のデータに`\\0`が含まれているとそこで文字列が千切れるということが起きます。\n\n> CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption,\n> (CryptoPP::byte*)strIV.c_str());\n\nこのコードで渡しているのは、`\"ABCDEFGHIJKLMNOP\"`ではなく`\"ABCDEFGHIJKLMNOP**\\0**\"`(へのポインタ)ですが、きちんと理解されてますか。内部的にはIVの長さ分しか参照しないでしょうからこれ自体が直接問題を引き起こすことはない気がしますが、バグの種ではあります。\n\n動作を理解する段階であれば、平文も含めて文字列ではなくバイト配列を用いて検証するのがよいでしょう。それであれば平文のエンコードの違いで引っかかることもありません。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T21:48:59.543",
"id": "59438",
"last_activity_date": "2019-10-03T21:48:59.543",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5793",
"parent_id": "59314",
"post_type": "answer",
"score": 0
},
{
"body": ">\n```\n\n> // C#\n> byte[] byteText = Encoding.UTF8.GetBytes(strText);\n> \n> // C++\n> std::string strText = \"暗号化テスト\";\n> \n```\n\nC#は見ての通りUTF-8エンコーディングのバイト列となります。Visual\nStudioのC++とのことですが、こちらはコントロールパネルの「Unicode\n対応ではないプログラムの言語」の設定値で日本語環境ではShift_JISエンコーディングとなります。このため、入力バイト列がそもそも異なります。\n\nUTF-8で一致させるには[UTF-8文字列リテラル](https://cpprefjp.github.io/lang/cpp11/utf8_string_literals.html)が簡単ですがお使いのVisual\nStudio 2013では未対応です。Visual Studio\n2015以降を使用されるか、[wctomb](https://docs.microsoft.com/ja-jp/cpp/c-runtime-\nlibrary/reference/wctomb-wctomb-l?view=vs-2019)等で変換することになります。\n\n```\n\n // C#\n byte[] byteText = Encoding.UTF8.GetBytes(strText);\n // C++\n std::string strText = u8\"暗号化テスト\";\n \n```\n\n「Unicode\n対応ではないプログラムの言語」で一致させるには[Encoding.Default](https://docs.microsoft.com/ja-\njp/dotnet/api/system.text.encoding.default?view=netframework-4.8)を使用します。\n\n```\n\n // C#\n byte[] byteText = Encoding.Default.GetBytes(strText);\n // C++\n std::string strText = \"暗号化テスト\";\n \n```\n\n* * *\n\n> ソースコードのエンコーディングをUTF-8(プロパティのC++コマンドラインで指定)にしてみましたが変わらずでした。\n\n補足しますと、Visual\nC++ではソースコードを解釈し一旦Unicodeに変換しています。その上で、指定されたエンコーディングのバイト列に変換してコード生成しています。そのため、ソースコードがUTF-8エンコーディングであっても\n`\"\"` 文字列は **コンパイル環境** の「Unicode\n対応ではないプログラムの言語」に沿ったバイト列(すなわち日本語環境においてはShift_JIS)となります。\n\n一方、C#の`Encoding.Default`は **実行環境** の「Unicode\n対応ではないプログラムの言語」に沿ったバイト列となります。同じ設定でも参照するタイミングが異なる点には気を付ける必要があります。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T23:06:01.343",
"id": "59439",
"last_activity_date": "2019-10-07T06:51:18.423",
"last_edit_date": "2019-10-07T06:51:18.423",
"last_editor_user_id": "4236",
"owner_user_id": "4236",
"parent_id": "59314",
"post_type": "answer",
"score": 2
}
] | 59314 | 59439 | 59439 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Jenkinsを.msiでインストールすると、他のツールへのキックに失敗します。 \n.warでインストールすると、同じパイプラインで他のツールへのキックが問題なく動作します。\n\nJenkinsのバージョン違いとか、Javaのバージョン違いなど、出来る範囲で入れ替えてみたのですが、.msiは失敗、.warは成功という状態から抜け出せません。\n\n最新のJenkinsは.msiで提供されるので、.msiでキックできるようにしたいのですが、.msiと.warでは、インストールフォルダが違う事やフォルダ名が違う事以外にどのような差異があるのでしょうか?\n\n何か、ヒントになることがあれば、是非ご教授ください。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T09:23:49.327",
"favorite_count": 0,
"id": "59322",
"last_activity_date": "2019-09-27T09:23:49.327",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35995",
"post_type": "question",
"score": 0,
"tags": [
"jenkins"
],
"title": "Jenkinsのインストールについて(.msiと.war)の違い",
"view_count": 208
} | [] | 59322 | null | null |
{
"accepted_answer_id": "59332",
"answer_count": 1,
"body": "Guile\nSchemeで以下のようなニュートン法のコードを実行しようとしているのですが、エラーが出て実行できません。エラーの原因が分からず、改善ができないのでどなたか改善方法が分かれば教えていただけると助かります。\n\n```\n\n (define (deriv f dx)\n ;;;導関数\n (lambda (x)(exact->inexact(/ (- (f (+ x dx)) (f x)) dx))))\n (define (good-enough? g guess)\n ;;;guessが十分良い値かを確かめる。\n (< (abs (g guess)) 0.0000001))\n (define (improve g guess)\n ;;;guessの値を改善する。\n (- guess (exact->inexact(/ (g guess) ((deriv g 0.0001) guess)))))\n (define (newton-iter2 g guess)\n ;;;ニュートン法\n (if (good-enough? g guess)\n guess\n (newton-iter2 g (improve g guess))))\n (define (square x) (* x x))\n (define (sqrt-base x)\n ;;;誤差を返す関数\n (lambda (t) (- (square t) x)))\n \n```\n\n上のような関数をEmacsのスクリプト内で定義しguileに読み込ませた上で、以下のコードをguileに実行させたいのですがエラーが直せません...。 \n(2の平方根を求めたい。)\n\n```\n\n (define (sqrt3 x) (newton-iter2 (sqrt-base x) 1.0))\n (sqrt3 2)\n \n```\n\n以下のようなエラーが出続けています...。\n\n```\n\n <unnamed port>:11:0: In procedure sqrt3:\n In procedure module-lookup: Unbound variable: newton-iter2\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T10:15:06.777",
"favorite_count": 0,
"id": "59323",
"last_activity_date": "2019-09-28T17:46:36.217",
"last_edit_date": "2019-09-28T17:46:36.217",
"last_editor_user_id": "3510",
"owner_user_id": "31249",
"post_type": "question",
"score": 1,
"tags": [
"scheme"
],
"title": "Guile Schemeでニュートン法を実行しようとしたが、エラーが出て実行できない。",
"view_count": 251
} | [
{
"body": "Guileにはモジュールシステムがありますが、`load`した定義ファイルにモジュール指定の記述がないため、REPLのモジュールとは別のモジュールに定義されたのが原因だと思います。\n\n定義時のモジュールと呼び出し時のモジュールを一致させるか、モジュールを指定して呼び出す必要があります。\n\n(なお、`load`でモジュールを何も指定しないと`(ice-9 popen)`モジュールが設定されるようです。)\n\n## REPLのデフォルト`guile-user`モジュールに定義を合わせる\n\n```\n\n ;; 定義ファイル\n (use-modules (guile-user))\n \n (define (deriv f dx) ...\n \n```\n\n```\n\n ;; REPL\n scheme@(guile-user)> (load \"file.scm\")\n scheme@(guile-user)> (define (sqrt3 x) (newton-iter2 (sqrt-base x) 1.0))\n scheme@(guile-user)> (sqrt3 2)\n $1 = 1.4142135624530596\n \n```\n\n## ロードするファイルにモジュールを定義し、モジュールの外から呼び出す\n\n```\n\n ;; 定義ファイル\n (define-module (ja.stackoverflow.com/questions/59323)\n #:export (newton-iter2 sqrt-base)) ; newton-iter2 と sqrt-baseを公開\n \n (define (deriv f dx) ...\n \n```\n\n```\n\n ;; REPL\n (load \"file.scm\")\n \n (define (sqrt3 x)\n ((@ (ja.stackoverflow.com/questions/59323) newton-iter2) ;ja.stackoverflow.com/questions/59323モジュールで公開されているnewton-iter2を指定\n ((@ (ja.stackoverflow.com/questions/59323) sqrt-base) x) 1.0))\n scheme@(guile-user)> (sqrt3 2)\n $1 = 1.4142135624530596\n \n```\n\n## 参考\n\n * <https://www.gnu.org/software/guile/manual/html_node/Modules.html>",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-28T13:37:14.517",
"id": "59332",
"last_activity_date": "2019-09-28T13:37:14.517",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3510",
"parent_id": "59323",
"post_type": "answer",
"score": 1
}
] | 59323 | 59332 | 59332 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "Rubyの配列において,配列の要素を範囲指定して削除したいです. \n以下のURLを参考にしても全く同じ結果にはならないです. \n<https://uxmilk.jp/24060>\n\nRubyのバージョンは`ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin16]`です.\n\n```\n\n target = [1, 2, 3, 4, 5, 6, 7]\n aaa = target.slice!(1, 3)\n p aaa\n \n \n a = [\"a\", \"b\", \"c\", \"d\", \"e\"]\n p a.slice!(1, 3)\n \n```\n\n上記の実行結果は以下になります.\n\n```\n\n [2, 3, 4] # => [1, 5, 6, 7]にならない\n [\"b\", \"c\", \"d\"] # => [\"a\", \"e\"]にならない\n \n```\n\n期待した動作をしなく,原因がわかりません. \n期待した動作をするようにするにはどのようにしたら良いでしょうか. \nご教授宜しくお願いします.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T10:59:52.470",
"favorite_count": 0,
"id": "59324",
"last_activity_date": "2019-09-29T05:03:42.327",
"last_edit_date": "2019-09-27T11:30:00.047",
"last_editor_user_id": "30173",
"owner_user_id": "30173",
"post_type": "question",
"score": 2,
"tags": [
"ruby"
],
"title": "配列の要素を範囲指定で削除したいけどできない",
"view_count": 194
} | [
{
"body": "`slice(1, 3)` のようにコールすると、第一引数のインデックスから第二引数の文字数の部分文字列を返します。 \nつまり、 `1, 3` の場合は2(0始まりなので1+1)文字目から3文字を取り出すことになります。 \n<https://docs.ruby-lang.org/ja/latest/class/Array.html#I_SLICE>\n\n`slice!(1, 3)` のようにコールすると、第一引数のインデックスから第二引数の文字数の部分文字列をレシーバーから削除します。 \nそして、戻り値は `slice` と違ってレシーバー(削除済みの配列)ではなく、削除した要素が返されます。 \n<https://docs.ruby-lang.org/ja/latest/class/Array.html#I_SLICE--21>\n\nつまり、そちらのコードの目的は `a.slice!(1, 3)` で達成されていて、返り値は気にせずに \n再度 `a` にアクセスすると `['a', 'e']` が出来上がっています。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T11:36:57.767",
"id": "59325",
"last_activity_date": "2019-09-29T05:03:42.327",
"last_edit_date": "2019-09-29T05:03:42.327",
"last_editor_user_id": "5793",
"owner_user_id": "29695",
"parent_id": "59324",
"post_type": "answer",
"score": 5
},
{
"body": "Rubyの標準ライブラリのメソッドには\n\n * レシーバのオブジェクトのコピーに何らかの操作を加えた結果を返すもの\n * レシーバのオブジェクト自体を変更するもの\n\nがあり、前者を「非破壊的」メソッド、後者を「破壊的」メソッドと言います。同様の処理をする非破壊的メソッドと破壊的メソッドがある場合、破壊的メソッドの方のメソッド名に\"!\"をつけるのが慣習となっています。\n\n(あくまで同機能のメソッドがある場合でしかも慣習なので、一般的に「\"!\"がついていれば破壊的メソッド」ではないことに注意してください)\n\n`slice`/`slice!`もこのパターンで、前者は配列をスライスした結果を返し(元のオブジェクトはそのまま)、後者は呼び出したオブジェクト自体を変更します。\n\n破壊的メソッドの戻り値が何になるかはメソッド次第なので注意が必要です。`slice!`は削除した要素を返すのですが、「処理が行われれば`self`、行わなければ`niL`」を返すものもあります。\n\n例えば\n\n```\n\n str2 = str.sub(/hoge/, 'fuga') \n #以後str2を操作してstrは触らない\n \n```\n\nこういうコードで誤って`sub!`を使ったとすると、変換が行われればどちらも同じ動きをしますが、変換が行われないと`str2`は`str`のコピーが入っているつもりが実際には`nil`になります。変換がまれにしか行われない場合、これはかなりわかりにくいバグになります。\n\nなので、非破壊的メソッドと破壊的メソッドの使い分けには十分注意してください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-29T01:26:00.263",
"id": "59335",
"last_activity_date": "2019-09-29T04:59:43.887",
"last_edit_date": "2019-09-29T04:59:43.887",
"last_editor_user_id": "5793",
"owner_user_id": "5793",
"parent_id": "59324",
"post_type": "answer",
"score": 0
}
] | 59324 | null | 59325 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n import * as dt from 'date-utils'\n \n```\n\n単に上記のような形でimportを行った時に発生します。\n\nエラーの内容から、tsconfig.jsonに問題があるように思えないのですが、何が原因なのでしょうか?\n\n```\n\n Error:(1, 21) TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the ‘esModuleInterop’ flag and referencing its default export.\n \n```\n\n以下tsconfig.jsonの内容\n\n```\n\n {\n \"compilerOptions\": {\n \"moduleResolution\": \"node\",\n \"skipLibCheck\": false,\n \"target\": \"es5\",\n \"module\": \"commonjs\",\n \"lib\": [\"es2017\", \"dom\"],\n \"experimentalDecorators\": true,\n \"allowJs\": false,\n \"jsx\": \"react\",\n \"sourceMap\": true,\n \"strict\": true,\n \"noImplicitReturns\": true,\n \"noUnusedLocals\": true,\n \"noUnusedParameters\": true,\n \"noFallthroughCasesInSwitch\": true,\n \"esModuleInterop\": true,\n \"removeComments\": true,\n \"newLine\": \"LF\",\n \"downlevelIteration\": true,\n \"resolveJsonModule\": true,\n \"allowSyntheticDefaultImports\": false\n },\n \"exclude\": [\"node_modules\"]\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T12:35:58.837",
"favorite_count": 0,
"id": "59326",
"last_activity_date": "2019-10-03T15:08:57.297",
"last_edit_date": "2019-09-27T13:05:40.747",
"last_editor_user_id": "3060",
"owner_user_id": "35997",
"post_type": "question",
"score": 2,
"tags": [
"node.js",
"typescript"
],
"title": "typescriptでdate-utilsモジュールのimportができない",
"view_count": 3973
} | [
{
"body": "このエラーメッセージは、`default export`をインポートする構文を用いて`date-\nutils`をインポートしなければならないと指摘しています。つまり、次のようにすればエラーが消えると思われます。\n\n```\n\n import dt from 'date-utils'\n \n```\n\n## 追記\n\n上記に加えて、さらに`tsconfig.json`から`\"allowSyntheticDefaultImports\":\nfalse`の設定を削除しないとエラーが消えませんでした。\n\n`esModuleInterop`とこの`allowSyntheticDefaultImports`はどちらもcommonjsモジュールをESModuleとして扱う場合に関係するオプションで、前者がランタイムのサポート、後者が型システム上のみのサポートという違いがあります。\n\n`esModuleInterop`をオンにした場合は自動的に`allowSyntheticDefaultImports`もオンになりますが、今回の設定では明示的に`allowSyntheticDefaultImports`をオフにしていたために型システム上のエラーが発生したようです。\n\ncommonjsモジュールを読み込むという目的に沿うならば`allowSyntheticDefaultImports`をオフにする理由はありませんので、これをオンにすれば解決となります。\n\n> request-promiseモジュールも同じように型定義ファイル上にdefault exportがなく、export文が複数あるわけではないのに、\n> import * from 'request-promise'で問題なく使用できている点とどこに差があるのかわからないというところです。\n\nこれについては、どちらのモジュールも`export =`でオブジェクトをエクスポートしている点は変わらないののの、`date-\nutils`は関数をエクスポートしているのに対して`request-promise`はただのオブジェクトをエクスポートしているという違いが影響しています。 \nESモジュールの`import * as dt from 'date-\nutils'`という構文では`dt`が関数などではないただのオブジェクト(正確にはmodule namespace exotic\nobject)になるため、`date-utils`がエクスポートするものと不整合がありエラーが発生しています。 \n対して`request-promise`を`import * as rp from 'request-\npromise'`のように読み込んだ場合、`rp`をモジュールからエクスポートされている(ただの)オブジェクトとすれば型システム上の不整合はないためラーが発生しません。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-27T13:31:02.260",
"id": "59327",
"last_activity_date": "2019-10-03T15:08:57.297",
"last_edit_date": "2019-10-03T15:08:57.297",
"last_editor_user_id": "30079",
"owner_user_id": "30079",
"parent_id": "59326",
"post_type": "answer",
"score": 2
}
] | 59326 | null | 59327 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "お世話になります。CakePHP3で投稿サイトを制作中です。あるキーワードを元に検索した内容をrankingページに表示させようと考えています。その表示させた記事に対し、他ユーザーのコメントした内容とあわせ、コメント投稿者のニックネームも表示させたいと考えていますが、ニックネームの情報取得ができず、困っています。\n\n▽環境▽ \nAWS Cloud9:無料枠 \nMySQL:ver5.7.26 \nCakePHP:ver3.8.2 \nPHP:ver7.2.19\n\n▽現在のMySQLのテーブル構造です▽\n\n```\n\n mysql> show create table users\\G\n *************************** 1. row ***************************\n Table: users\n Create Table: CREATE TABLE `users` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `email` varchar(255) NOT NULL,\n `password` varchar(255) NOT NULL,\n `nickname` varchar(30) NOT NULL,\n `profiel_comment` varchar(100) NOT NULL,\n `created` datetime DEFAULT NULL,\n `modified` datetime DEFAULT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4\n 1 row in set (0.00 sec) mysql> show create table ices \\G\n \n *************************** 1. row ***************************\n Table: ices\n Create Table: CREATE TABLE `ices` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `user_id` int(11) NOT NULL,\n `manufacturer` varchar(50) NOT NULL,\n `ice_name` varchar(50) NOT NULL,\n `ice_fraver` varchar(50) NOT NULL,\n `price_no_tax` int(5) unsigned NOT NULL,\n `buy_year` int(4) unsigned NOT NULL,\n `buy_month` int(2) unsigned NOT NULL,\n `image_file` varchar(255) DEFAULT NULL,\n `created` datetime DEFAULT NULL,\n `modified` datetime DEFAULT NULL,\n `simple_comment` varchar(20) NOT NULL,\n `desc_comment` varchar(100) NOT NULL,\n `repeat_rate` int(11) DEFAULT NULL,\n `stock_rate` int(11) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `ice_fk` (`user_id`),\n CONSTRAINT `ice_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4\n 1 row in set (0.00 sec)\n \n mysql> show create table comments \\G\n *************************** 1. row ***************************\n Table: comments\n Create Table: CREATE TABLE `comments` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `ice_id` int(11) NOT NULL,\n `user_id` int(11) NOT NULL,\n `comment` varchar(100) NOT NULL,\n `repeat_rate` int(11) DEFAULT NULL,\n `stock_rate` int(11) DEFAULT NULL,\n `created` datetime DEFAULT NULL,\n `modified` datetime DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `comments_fk` (`user_id`),\n KEY `comments_ices_fk` (`ice_id`),\n CONSTRAINT `comments_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,\n CONSTRAINT `comments_ices_fk` FOREIGN KEY (`ice_id`) REFERENCES `ices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n ) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8mb4\n 1 row in set (0.00 sec)\n \n```\n\n▽/src/Controller/IcesController.php▽\n\n```\n\n class IcesController extends AppController\n {\n public function initialize()\n {\n parent::initialize();\n $this->Auth->allow(['index','view','search']);\n $this->loadModel('Comments');\n $this->loadModel('Users');\n \n }\n ~一部省略~\n public function search()\n {\n $ices = $this->Ices->find('all');\n $manufacturer = isset($this->request->query['manufacturer']) ? $this->request->query['manufacturer'] : null;\n $keyword = isset($this->request->query['keyword']) ? $this->request->query['keyword'] : null;\n \n if($manufacturer){\n $where = ['Ices.manufacturer' => $manufacturer];\n if ($keyword) {\n $where['OR']['Ices.ice_fraver LIKE'] = \"%$keyword%\";\n $where['OR']['Ices.simple_comment LIKE'] = \"%$keyword%\";\n } \n $ices->where($where)\n ->contain(['Users','Comments'])\n ->all();\n $this->set('manufacturer', $manufacturer);\n $this->set('keyword', $keyword);\n $this->set('ices', $ices);\n $this->render('ranking');\n }\n }\n \n```\n\n上記の内容で現在、記述しています。\n\nIcesテーブルの、manufacturer、もしくはmanufacturerとice_fraver、manufacturerとsimple_commentのいずれかの組み合わせで検索をし、 \nrankingに該当するIcesテーブルの情報+紐づくCommentsテーブルの情報、 \nさらにそのコメントをしたComementsテーブルのuser_idにひもづくUsersテーブルのnicknameの取得が目的です。\n\n既にアソシエーション関連の記述の変更が必要と思い、 \n[https://book.cakephp.org/3.0/ja/orm/associations.htm](https://book.cakephp.org/3.0/ja/orm/associations.html)l \n<https://book.cakephp.org/3.0/ja/orm/retrieving-data-and-\nresultsets.html#eager-loading-associations> \n↑の内容は確認しましたが、要望に対しての記述方法について、 \n現在記載済みのコードのどこをどう変更すればよいか、わからない状況が続いています。\n\n現在の状態から、どう記述を変更していけばよいか。 \nご教示をお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-28T02:07:52.423",
"favorite_count": 0,
"id": "59329",
"last_activity_date": "2019-09-29T11:02:23.207",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36000",
"post_type": "question",
"score": 0,
"tags": [
"php",
"mysql",
"cakephp"
],
"title": "CakePHP3 他テーブルの特定レコードを紐付け抽出ができない",
"view_count": 178
} | [
{
"body": "自己解決できました。\n\n/src/Model/Table/CommentsTable.php\n\n```\n\n $this->belongsTo('Users', [\n //'foreignKey' => 'id',//☆1\n 'joinType' => 'INNER'\n ]);\n \n```\n\n☆1の部分を消し、 \n/my_pt_lesson/src/Template/Ices/ranking.ctpに\n\n```\n\n <p>BY<?= $this->Html->link( h($ice->comments[0]->user->nickname),\n ['controller' => 'Users', 'action' => 'view', \n $ice->comments[0]->user['id']]) ?></p>\n \n```\n\n...のように記述し、コメントに紐づくユーザー名の取得ができました \n回答はいただけませんでしたが、一度でもご覧いただいた皆様、 \nお騒がせいたしました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-29T11:02:23.207",
"id": "59341",
"last_activity_date": "2019-09-29T11:02:23.207",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36000",
"parent_id": "59329",
"post_type": "answer",
"score": 1
}
] | 59329 | null | 59341 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Unity、およびプログラミング初心者です。 \nカメラがキャラクターを一定の範囲で追跡するようにしたいと思っています。 \n「Unity入門」というサイトでは、 \nCM vcam1についているChinemachine Virtual CameraのAdd Extensionをクリックし、Chinemachine\nCofinerを追加すると「Confine Screen Edges」という名前のチェックボックスが出ると記載されています。 \nしかし、私のPC上ではこのチェックボックスが出て来ません。Chinemachine Cofinerを追加するところまでは出来ています。 \nどうすればConfine Screen Edgesを出すことが出来るでしょうか。 \nよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-28T02:50:48.833",
"favorite_count": 0,
"id": "59330",
"last_activity_date": "2019-11-27T15:57:06.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36003",
"post_type": "question",
"score": 0,
"tags": [
"unity3d"
],
"title": "unityでConfine Screen Edgesが出てこない",
"view_count": 233
} | [
{
"body": "私も同じサイトを見て全く同じ状況でしたが、Main\nCameraのProjectionってところをPerspectiveからOrthographicに切り替えたらConfine Screen\nEdges出てきました!",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-11-27T15:57:06.563",
"id": "60895",
"last_activity_date": "2019-11-27T15:57:06.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36816",
"parent_id": "59330",
"post_type": "answer",
"score": 0
}
] | 59330 | null | 60895 |
{
"accepted_answer_id": "59781",
"answer_count": 1,
"body": "下記でカメラボードの3Dデータ(STL)をダウンロードしました。\n\n<https://developer.sony.com/develop/spresense/docs/hw_docs_ja.html>\n\nCAD(Rhinoceros6)でみると、肝心のカメラの部品(レンズと胴体の黒いもの)がついていないです。\n\n小さなIC、コンデンサ等はついています。\n\nCADによる問題なのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-29T01:36:39.427",
"favorite_count": 0,
"id": "59336",
"last_activity_date": "2019-10-18T05:26:51.913",
"last_edit_date": "2019-09-29T04:32:31.810",
"last_editor_user_id": "3060",
"owner_user_id": "35541",
"post_type": "question",
"score": 0,
"tags": [
"spresense"
],
"title": "カメラボードの3D-CADデータにカメラ本体の部品がない",
"view_count": 172
} | [
{
"body": "ソニーのSPRESENSEサポート担当です。\n\nご指摘ありがとうございます。\n\n早速、3D CADファイルにカメラモジュール部分を追加いたしました。 \n[3D CADデータ(STEP) (stp)](https://github.com/sonydevworld/spresense-hw-design-\nfiles/raw/master/CXD5602PWBCAM1/stp/CXD5602PWBCAM1.stp)\n\nこの度はドキュメントの不備によってご不便をお掛け致しました。\n\n今後ともSPRESENSEをどうぞよろしくお願いいたします。 \nSPRESENSEサポートチーム",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-18T05:26:51.913",
"id": "59781",
"last_activity_date": "2019-10-18T05:26:51.913",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29520",
"parent_id": "59336",
"post_type": "answer",
"score": 1
}
] | 59336 | 59781 | 59781 |
{
"accepted_answer_id": "59338",
"answer_count": 1,
"body": "下記の方法で`lan=`のみを削除できましたが、`lon=`を削除するにはどのように設定すればよろしいでしょうか?\n\n```\n\n print(a.text [4:])\n \n lan= 1.287806 Lon=103.854935 \n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-29T02:54:32.640",
"favorite_count": 0,
"id": "59337",
"last_activity_date": "2019-09-29T06:23:56.777",
"last_edit_date": "2019-09-29T03:29:45.480",
"last_editor_user_id": "32986",
"owner_user_id": "18859",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "python 特定の文字を削除",
"view_count": 125
} | [
{
"body": "正規表現を使うのが簡単でしょう。\n\n```\n\n import re\n \n str = \"Lat=1.287806 Lon=103.854935\"\n m = re.search(r\"^Lat=([0-9.]+)\\s*Lon=([0-9.]+)\", str)\n if m:\n print(m.group(1)+' '+m.group(2))\n \n```\n\n結果\n\n```\n\n 1.287806 103.854935\n \n```\n\n「単に固定文字列を取り除くだけ」と言うことがわかっているなら、`replace`でも良いでしょうが。\n\n```\n\n print(str.replace(\"Lat=\", \"\").replace(\"Lon=\", \"\"))\n \n```",
"comment_count": 19,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-29T03:19:23.893",
"id": "59338",
"last_activity_date": "2019-09-29T06:23:56.777",
"last_edit_date": "2019-09-29T06:23:56.777",
"last_editor_user_id": "13972",
"owner_user_id": "13972",
"parent_id": "59337",
"post_type": "answer",
"score": 1
}
] | 59337 | 59338 | 59338 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現状svprogressHudでindicatorを出しているのですが \n画像を用意してそれをつなぎ合わせてアニメーションのように表示し \nindicatorが表示される部分のアニメーションを独自のものにしたいのですが \n方法がわかりません、教えて頂けると幸いです。\n\nやってみたこととしてはクラス化をしてどこからでも使えるようにしたい為 \nxibとswiftファイルを作成し、クラス化をしてみました。 \nしかし、呼び出す際呼び出し側のviewと繋がりを認識できない為fatal errorが発生してしまいます。\n\nsvprogressHudをカスタマイズして画像を入れたりはできるのでしょうか?",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-29T04:36:33.180",
"favorite_count": 0,
"id": "59339",
"last_activity_date": "2019-10-01T11:20:06.440",
"last_edit_date": "2019-10-01T11:20:06.440",
"last_editor_user_id": "32195",
"owner_user_id": "32195",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios"
],
"title": "swift indicator 自作",
"view_count": 109
} | [] | 59339 | null | null |
{
"accepted_answer_id": "59343",
"answer_count": 1,
"body": "別のページから取得したテキストをdriver.getを使って特定ウェブサイトを開きたいです。\n\n```\n\n a=driver.find_element_by_xpath('//*[@id=\"gsm\"]/center[1]/a') \n print(a.text.replace(\"Lat=\", \"\").replace(\"Lon=\", \"\").replace(\" \",\",\"))\n \n```\n\n別のページから取得した情報:`a=60.208511,24.752884`\n\n情報を取得後、下記の方法で特定のページを開きたいですが、実行しても何も開きません。 \n変数を使って開く場合、どのように設定すれば良いでしょうか。\n\n```\n\n link='https://www.google.com/maps/search/'+a\n print(link)\n \n```\n\n実行結果:なし\n\n```\n\n driver.get(link)\n \n```\n\n`link='https://www.google.com/maps/search/'`のみで実行するとウェブサイトが開きます。 \n変数`a`を追加すると開きません。\n\n実行結果:`https://www.google.com/maps/search/`\n\nお手数ですが、ご教授願いします。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-29T10:14:03.167",
"favorite_count": 0,
"id": "59340",
"last_activity_date": "2019-09-29T15:18:05.663",
"last_edit_date": "2019-09-29T12:46:51.730",
"last_editor_user_id": "3060",
"owner_user_id": "18859",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "python 特定のページを開く",
"view_count": 121
} | [
{
"body": "間に説明が入ってしまっているので少しわかりにくいのですが、現在のコードはこのような状態というところでよろしいでしょうか?\n\n```\n\n a=driver.find_element_by_xpath('//*[@id=\"gsm\"]/center[1]/a') \n print(a.text.replace(\"Lat=\", \"\").replace(\"Lon=\", \"\").replace(\" \",\",\"))\n # (1)->60.208511,24.752884\n link='https://www.google.com/maps/search/'+a\n print(link)\n # (2)(何も表示されない)\n driver.get(link)\n \n```\n\n(2)の`print`文の結果が表示されていないのであれば、その前の行\n\n```\n\n link='https://www.google.com/maps/search/'+a\n \n```\n\nでエラーが発生しているので、`print`文が実行されていない、と推定できます。\n\n* * *\n\n[別質問](https://ja.stackoverflow.com/a/59338/13972)のコメント中で「`a.text`は文字列だが、`a`は文字列ではない」というのを確認していただいたのを覚えておいででしょうか。\n\n1つ目の`print`文は、`a.text.replace(\"Lat=\", \"\").replace(\"Lon=\", \"\").replace(\"\n\",\",\")`という式の **計算結果(文字列)を表示しているだけ** であり、`a`の中身を書き換えるものではありません。従って\n**`a`は文字列ではない** ままです。\n\n文字列(`'https://www.google.com/maps/search/'`)と文字列ではないもの(`a`)を`+`で結合しようとしているのが、エラーの原因と考えられます。\n\n* * *\n\n上記の **計算結果** を表示するだけで捨ててしまわずに、何かの変数にでも入れて利用すれば良いでしょう。\n\n```\n\n a=driver.find_element_by_xpath('//*[@id=\"gsm\"]/center[1]/a') \n coord = a.text.replace(\"Lat=\", \"\").replace(\"Lon=\", \"\").replace(\" \",\",\")\n print(coord) # (1)\n link='https://www.google.com/maps/search/'+coord\n print(link) # (2)\n driver.get(link)\n \n```\n\n少なくともこれで、上記のエラーは解消されるので、(1)(2)とも`print`文の結果が表示されるはずで、その結果`link`の値が所望のものになっていれば、そのページが開くはずです。お試しください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-29T15:18:05.663",
"id": "59343",
"last_activity_date": "2019-09-29T15:18:05.663",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "59340",
"post_type": "answer",
"score": 1
}
] | 59340 | 59343 | 59343 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Vtuberの動きを記録して再生したいのですがなにか参考になるものはあるのでしょうか? \n下記を参考にキャラクターにFinalIKを充てて頭、手、胴体のpositionとrotateを記録して再生してみたのですが動きませんでした。 \n<https://gametukurikata.com/program/ghost>",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T01:08:40.937",
"favorite_count": 0,
"id": "59345",
"last_activity_date": "2019-09-30T01:08:40.937",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"c#",
"unity3d"
],
"title": "Vtuberの動きを記録して再生したい",
"view_count": 110
} | [] | 59345 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Ajaxで検査した結果を表示したいのですが、サーバーからの結果からさらにJavaScriptの`switch`文の条件を当てはめたいのですが、その`switch`文は`done`の中に書くのでしょうか? \nどのようにしてサーバからの結果と`switch`文をつなげるのか分からないです。\n\n**ソースコード**\n\n```\n\n $(function(){\n // ajax button click\n $('#ajax').on('click',function(){\n $.ajax({\n url:'/home',\n type:'GET',\n data:{ \n }\n })\n // ajaxリクエストが成功した時発動\n .done( (data) => {\n console.log(\"成功\");\n console.log(\"formList:\" + data);\n $('result').html(data);\n console.log(data);\n })\n .fail( (data) => {\n });\n });\n });\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T03:58:10.487",
"favorite_count": 0,
"id": "59349",
"last_activity_date": "2020-09-10T07:23:39.240",
"last_edit_date": "2020-09-10T07:23:39.240",
"last_editor_user_id": "32986",
"owner_user_id": "35696",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery",
"ajax"
],
"title": "Ajax の結果を用いた条件分岐は done の中に書けば良い?",
"view_count": 2274
} | [
{
"body": "はい、doneの中に書きます。 \ndoneに渡した処理は、ajaxリクエストが成功した時、 \nfailに渡した処理は、ajaxリクエストが失敗した時、 \nalwaysに渡した処理は、ajaxリクエストが成功しても失敗しても実行されます。 \najaxの場合、dataにレスポンス内容が入っています。\n\n```\n\n $.ajax({\n url: 'http://example.com/api/v1/event/?' + queryString,\n type: 'GET',\n dataType: 'jsonp',\n jsonp: 'callback'\n })\n .done((data, textStatus, xhr) => {\n // success\n // 例えば、サーバが下記のような文字列を返す時\n // {\n // \"fooBars\": [\n // { \"id\": 1, \"name\":\"alice\" },\n // { \"id\": 2, \"name\":\"bob\" }\n // ]\n // }\n let name = data.fooBars[0].name; // alice\n })\n .fail((xhr, textStatus, errorThrown) => {\n // error\n })\n .always((arg1, textStatus, arg3) => {\n // complete\n });\n \n```\n\n補足\n\n 1. Ajaxはxhr規格のヘルパー関数です。\n 2. リンク押下とxhrの違いは、細かい差異を除けば、ブラウザが読み直すか、js上で受け取るかだけです。\n 3. xhrのhttpレスポンスbodyは、htmlの代わりにjson文字列などを返します。\n 4. 歴史的な理由でxhrという名称ですが、通常はxml形式ではなくjson形式で返します。\n 5. うまく値がサーバから帰ってこない場合は、jsonp、CORS辺りが原因かもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T08:13:53.927",
"id": "59355",
"last_activity_date": "2019-09-30T08:13:53.927",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25396",
"parent_id": "59349",
"post_type": "answer",
"score": 1
}
] | 59349 | null | 59355 |
{
"accepted_answer_id": "59998",
"answer_count": 1,
"body": "GoのライブラリEchoを使用して、まずは下記参考サイトと全く同じソースを作成し、動作することを確認しました。 \nその後、下記参考サイトの「ServiceInfo」構造体を別のパッケージ(ここでは例でtestパッケージとします)に分割したところ、Internal\nServer Errorとなってしまいました。\n\nテンプレートから別パッケージの構造体を参照するにはどのように指定することとなるのでしょうか。\n\n参考サイト \n<http://kimagureneet.hatenablog.com/entry/2017/01/12/210553>\n\nGo バージョン1.11.2",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T04:42:05.033",
"favorite_count": 0,
"id": "59350",
"last_activity_date": "2019-10-26T14:40:55.687",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "32741",
"post_type": "question",
"score": 0,
"tags": [
"go"
],
"title": "GoのEchoでテンプレートから別パッケージの構造体を参照",
"view_count": 138
} | [
{
"body": "```\n\n package test\n \n type ServiceInfo struct {\n Title string\n }\n \n```\n\n↑ のように test パッケージに serviceinfo.go を追加し、 \n↓ のように service.go で import して test package を指定すれば問題なさそうでした。\n\n```\n\n import (\n ・・・\n \n \"github.com/hoge/test\"\n \n ・・・\n )\n \n ・・・\n \n var serviceInfo = test.ServiceInfo{\n \"サイトのタイトル\",\n }\n \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-26T14:40:55.687",
"id": "59998",
"last_activity_date": "2019-10-26T14:40:55.687",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31238",
"parent_id": "59350",
"post_type": "answer",
"score": 1
}
] | 59350 | 59998 | 59998 |
{
"accepted_answer_id": "59363",
"answer_count": 1,
"body": "pingのオプションについて\n\n```\n\n ping\n Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]\n [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]\n [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]\n [-w deadline] [-W timeout] [hop1 ...] destination\n \n```\n\n上記から `-W timeout` のオプションをつけることでpingのタイムアウトの時間を変更できると考えています。\n\n```\n\n ping -c 1 -W 10 IPアドレス\n \n```\n\n上記でpingが通る場合は以下の結果がすぐ戻ってくるので良いのですが、\n\n```\n\n 1 packets transmitted, 1 received, 0% packet loss, time 0ms\n \n```\n\npingが通らない場合、以下の結果が10秒後に戻ってくる認識だったのですが、2秒~3秒で以下の結果が戻ってきます。 \nWコマンドはタイムアウトの値ではないのでしょうか?(使用方法が異なりますか?)\n\n```\n\n 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms\n \n```\n\nまた `-W` のオプションを10→3とすると、結果が異なるのですが、何か理由があるのでしょうか?\n\n**`-W 10` の場合**\n\n```\n\n 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms\n \n```\n\n**`-W 3` の場合**\n\n```\n\n 1 packets transmitted, 0 received, 100% packet loss, time 0ms\n \n```\n\n■追記 \nwakuwakuさまのコメントを受け以下を試してみました。 \n●成功\n\n```\n\n date;/bin/ping -c 1 -W 60 192.168.xxx.xxx;date★適当なIPアドレス\n 2019年 9月 30日 月曜日 16:16:44 JST\n PING 192.168.xxx.xxx (192.168.xxx.xxx) 56(84) bytes of data.\n \n --- 192.168.xxx.xxx ping statistics ---\n 1 packets transmitted, 0 received, 100% packet loss, time 0ms\n \n 2019年 9月 30日 月曜日 16:17:44 JST★60秒後にタイムアウトしている\n \n```\n\n●失敗\n\n```\n\n date;/bin/ping -c 1 -W 60 172.16.yyy.yyy ;date★実際に存在する機器のケーブルを抜いた\n 2019年 9月 30日 月曜日 16:17:53 JST\n PING 172.16.yyy.yyy (172.16.yyy.yyy) 56(84) bytes of data.\n From 172.16.zzz.zzz icmp_seq=1 Destination Host Unreachable★前者には出ていなかったログ\n \n --- 172.16.zzz.zzz ping statistics ---\n 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms\n \n 2019年 9月 30日 月曜日 16:17:56 JST★3秒後にタイムアウトとなっている\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T06:20:09.247",
"favorite_count": 0,
"id": "59352",
"last_activity_date": "2019-09-30T12:56:04.557",
"last_edit_date": "2019-09-30T07:13:30.813",
"last_editor_user_id": "12842",
"owner_user_id": "12842",
"post_type": "question",
"score": 2,
"tags": [
"linux",
"network"
],
"title": "pingのタイムアウトオプション",
"view_count": 2085
} | [
{
"body": "pingの送信先が同一セグメントにある場合、送信元マシンでarpリクエストのタイムアウトが先に検出されるため、送信エラーになる可能性があります。(※3秒だとこの可能性が高いと予想します)\n\n#この場合、ICMP ECHO Requestパケットは送出されないはずです。\n\nまた、pingの送信先が異なるセグメントにある場合でも、NW装置が「Destination Host\nUnreachable」等のICMPエラーを返してきても、pingの応答タイムアウト前にエラー判定されると思います。\n\n詳しく調べるのであれば、パケットキャプチャして、ICMP ECHO Requestが創出されているか、エラーが返ってきてないか調べるのがよいと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T11:26:22.103",
"id": "59363",
"last_activity_date": "2019-09-30T12:56:04.557",
"last_edit_date": "2019-09-30T12:56:04.557",
"last_editor_user_id": "20098",
"owner_user_id": "20098",
"parent_id": "59352",
"post_type": "answer",
"score": 2
}
] | 59352 | 59363 | 59363 |
{
"accepted_answer_id": "59356",
"answer_count": 1,
"body": "djangoでHTML上でログインユーザ名の取得を行いたいのですが、 \nカスタムユーザで認証をユーザ名からメールアドレスに変更した影響で \nHTML上で`'user.username'`ないし`'user.get_username'`で取得される値はメールアドレスになってしまいます。\n\n```\n\n class UserManager(BaseUserManager):\n \n use_in_migrations = True\n \n def _create_user(self, email, password, **extra_fields):\n if not email:\n raise ValueError('The given email must be set')\n email = self.normalize_email(email)\n user = self.model(email=email, **extra_fields)\n user.set_password(password)\n user.save(using=self._db)\n return user\n \n def create_user(self, email, password=None, **extra_fields):\n extra_fields.setdefault('is_staff', False)\n extra_fields.setdefault('is_superuser', False)\n return self._create_user(email, password, **extra_fields)\n \n def create_superuser(self, email, password, **extra_fields):\n extra_fields.setdefault('is_staff', True)\n extra_fields.setdefault('is_superuser', True)\n \n if extra_fields.get('is_staff') is not True:\n raise ValueError('Superuser must have is_staff=True.')\n if extra_fields.get('is_superuser') is not True:\n raise ValueError('Superuser must have is_superuser=True.')\n \n return self._create_user(email, password, **extra_fields)\n \n```\n\nコードはこのままの場合、ユーザ名を取得する方法はあるのでしょうか?\n\n@追記 \nuserモデルの定義(一部抜粋)\n\n```\n\n class CustomUser(AbstractBaseUser, PermissionsMixin):\n \"\"\"カスタムユーザーモデル.\"\"\"\n \n nick_name = models.CharField(_('ニックネーム'), max_length=20)\n \n def get_full_name(self):\n full_name = '%s' % (self.nick_name)\n return full_name.strip()\n \n def get_short_name(self):\n \"\"\"Return the short name for the user.\"\"\"\n return self.nick_name\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T06:47:08.380",
"favorite_count": 0,
"id": "59353",
"last_activity_date": "2019-09-30T11:45:33.037",
"last_edit_date": "2019-09-30T11:45:33.037",
"last_editor_user_id": "36021",
"owner_user_id": "36021",
"post_type": "question",
"score": 0,
"tags": [
"python",
"django"
],
"title": "ログインユーザの名前を取得",
"view_count": 1171
} | [
{
"body": "ユーザ名はどのフィールドに保存していますか?そのままアクセスすれば、値が表示されます。 \nたとえば、テンプレートに以下のコードでfirst_nameとlast_nameの値が表示されます。\n\n```\n\n request.user.first_name\n request.user.last_name\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T08:43:53.210",
"id": "59356",
"last_activity_date": "2019-09-30T08:51:31.643",
"last_edit_date": "2019-09-30T08:51:31.643",
"last_editor_user_id": "32986",
"owner_user_id": "35698",
"parent_id": "59353",
"post_type": "answer",
"score": 0
}
] | 59353 | 59356 | 59356 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "GitHubで、あるOSSに対してプルリクエストを行った結果、レビュー指摘を受けた場合の適切な指摘反映方法を教えていただきたいです。ただし、最終的にプルリクエストは1コミットにまとめないといけないとします(おそらく、どのOSSでもそうだと思いますが)。\n\n私の方法では指摘をローカルのソースコードに反映して、以下を実施しています。\n\n```\n\n $ git commit -am \"レビュー指摘の反映\"\n $ git rebase -i HEAD~2\n ・・・squashで2つのコミットをまとめる(上記コミットメッセージは削除)・・・\n $ git push -f origin [プルリクのためにつくったブランチ]\n \n```\n\nこの場合、プルリクエストは1コミットにまとめられますが、レビュー指摘前のソースコードが完全になくなってしまうので、レビュアーは適切にレビュー指摘を反映したのか判断しづらいと思います。\n\nレビュー指摘前後の変更内容が確認できて、かつ最終的なプルリクエストを1コミットにまとめることはできるのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T08:53:44.333",
"favorite_count": 0,
"id": "59357",
"last_activity_date": "2019-10-01T02:11:14.193",
"last_edit_date": "2019-10-01T02:11:14.193",
"last_editor_user_id": "3060",
"owner_user_id": "23994",
"post_type": "question",
"score": 1,
"tags": [
"git",
"github"
],
"title": "GitHubのプルリクエストでレビューを受けた後の適切なコミット反映方法は?",
"view_count": 2983
} | [
{
"body": "> おそらく、どのOSSでもそうだと思いますが\n\n果たしてそうなのでしょうか、確かに複数コミットに分かれているとリベースを強要されたプロジェクトの話は聞いたことはありますが、懸念されている通りこの時点でコミットを纏めてしまうのは私は適切とは思いません。\n\nGitHubのプルリクエストのマージは単純なツリーのマージ以外にもRebase,Squashの選択肢が用意されています。squashは1つのコミットとしてマージされるのでメンテナがこれを使っているのであればコントリビューターは意識する必要ありません。(それ以外においてもプルリク段階でsquashする必要があるのは稀な気はします。)\n\n当然ながらこの辺りはプロジェクトの方針次第ですが……",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T10:11:42.010",
"id": "59359",
"last_activity_date": "2019-09-30T10:11:42.010",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2376",
"parent_id": "59357",
"post_type": "answer",
"score": 3
},
{
"body": "指摘事項が単純なタイプミスなど、変更点が軽微なものであれば `rebase`\nでまとめてしまうのもありかもしれませんが、そうでなければ「プルリクエストは必ず1コミットにまとめる」は必ずしも正しいとは言えません。\n\n最終的にマージでどう取り込むかはオーナー次第ですが、コミットは \"意味のある\" 単位で分けるべきです。(今回の例なら、レビュー\"前\"と\"後\")\n\n* * *\n\nなお、GitHubのヘルプページには以下のような注意書きがありました。\n\n<https://help.github.com/ja/articles/about-pull-requests>\n\n> プルリクエストにコミットをプッシュする場合、フォースプッシュはしないでください。 フォースプッシュをすると、プルリクエストが壊れることがあります。\n\n`rebase` を行うと新しいコミットハッシュが生成されるためでしょう。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T01:26:32.673",
"id": "59374",
"last_activity_date": "2019-10-01T01:26:32.673",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "59357",
"post_type": "answer",
"score": 0
}
] | 59357 | null | 59359 |
{
"accepted_answer_id": "59360",
"answer_count": 1,
"body": "tkinterを使って1秒毎に数値をprintするプログラムを作っています。 \nWeb上に、以下のようなコードがありました。\n\n**・GUItest1.py**\n\n```\n\n import tkinter as tk\n import threading\n import time\n \n def time_count():\n global frame\n global stop_flag\n \n while not stop_flag:\n print(frame)\n frame=frame+1\n time.sleep(1)\n \n def start():\n global stop_flag\n global thread\n \n # スレッドが無いなら生成してstart()する\n if not thread:\n thread = threading.Thread(target=time_count)\n stop_flag=False\n thread.start()\n \n def stop():\n global stop_flag\n global thread\n \n # スレッドがある場合停止してjoin()する\n if thread:\n stop_flag=True\n thread.join()\n thread=None\n \n frame=1\n stop_flag=False\n thread=None\n root=tk.Tk()\n Button001=tk.Button(root,text=\"Start\",command=start)\n Button001.pack()\n Button002=tk.Button(root,text=\"Stop\",command=stop)\n Button002.pack()\n root.mainloop()\n # 終了時にスレッドを停止する処理\n stop_flag=True\n thread.join()\n \n```\n\n上記のコードを実行すると、GUIが立ち上がり \nstartボタンを押すと数値がprintされ、stopボタンを押すとprintが止まります。 \nまた、再度startボタンを押すと数値のprintが再開されます。\n\n私は、これと同様のことをクラスを使って実装しようとしました。 \n書いたコードは以下の通りです。\n\n**・GUItest2.py**\n\n```\n\n import tkinter as tk\n import threading\n import time\n \n class threadingGUI():\n def __init__(self):\n self.frame=1\n self.stop_flag=False\n self.thread=None\n \n def time_count(self):\n while not self.stop_flag:\n print(self.frame)\n self.frame=self.frame+1\n time.sleep(1)\n \n def start(self):\n if not self.thread:\n self.thread = threading.Thread(target=self.time_count)\n stop_flag=False\n self.thread.start()\n \n def stop(self):\n if self.thread:\n self.stop_flag=True\n self.thread.join()\n self.thread=None\n \n def GUI_start(self):\n root=tk.Tk()\n Button001=tk.Button(root,text=\"Start\",command=self.start)\n Button001.pack()\n Button002=tk.Button(root,text=\"Stop\",command=self.stop)\n Button002.pack()\n root.mainloop()\n \n self.stop_flag=True\n self.thread.join()\n \n t = threadingGUI()\n t.GUI_start()\n \n```\n\n私の書き直したコード(GUItest2.py)でも、GUIが立ち上がり \nstartボタンを押すと数値がprintされ、stopボタンを押すと停止します。 \nしかし、再度startボタンを押すと、printが再開されません。\n\n私の書いたコードだと、何がおかしいのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T09:12:38.170",
"favorite_count": 0,
"id": "59358",
"last_activity_date": "2019-09-30T10:18:18.373",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34471",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "PythonのGUIのスレッド化とクラスについて",
"view_count": 1289
} | [
{
"body": "`def start(self):`のところの`stop_flag=False`の前に`self.`を付け忘れているためでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T10:18:18.373",
"id": "59360",
"last_activity_date": "2019-09-30T10:18:18.373",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26370",
"parent_id": "59358",
"post_type": "answer",
"score": 1
}
] | 59358 | 59360 | 59360 |
{
"accepted_answer_id": "59365",
"answer_count": 1,
"body": "一つのページをスクレイピングして、タイトルなどを取得するコードがあります。\n\n```\n\n url = \"https://xxxxxxxx\"\n html = urllib.request.urlopen(url)\n soup = BeautifulSoup(html, \"html.parser\")\n title = soup.find(\"h1\").get_text()\n \n print(title)\n \n```\n\n別に、URLが記載されたCSV(URLが1列に縦に並んでいます)があります。\n\nこの時、下記のurlの部分にCSVからURLを順に取得していけば良いのはわかるのですが、\n\n```\n\n url = \"https:xxxxxx\"\n \n```\n\nどのようなコードを書けば良いのかわからず困っております。 \nアドバイスを頂けませんでしょうか。\n\nコードの全体は以下のようになっております。\n\n```\n\n from bs4 import BeautifulSoup\n import urllib.request\n from pathlib import Path\n import csv\n \n with open('check_URL.csv',encoding=\"utf-8\") as csv_file :\n a_test = [] \n for row in csv.reader(csv_file):\n a_test.append(row[3]) \n \n del a_test[0]\n \n ## ここに何かのコードが必要?\n \n url = \"https://xxxxxxxx\"\n html = urllib.request.urlopen(url)\n soup = BeautifulSoup(html, \"html.parser\")\n title = soup.find(\"h1\").get_text()\n \n print(title)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T12:03:22.267",
"favorite_count": 0,
"id": "59364",
"last_activity_date": "2019-09-30T12:22:01.940",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "23420",
"post_type": "question",
"score": 0,
"tags": [
"python",
"web-scraping"
],
"title": "Python 複数のURLが記載されたCSVファイルから、順にURLを取得してタイトルなどをスクレイピングする方法",
"view_count": 3152
} | [
{
"body": "ここは単純に`for`ループで良いのでは? \n以下の様な感じですね。\n\n```\n\n urltitlelist = []\n for url in a_test:\n html = urllib.request.urlopen(url)\n soup = BeautifulSoup(html, \"html.parser\")\n title = soup.find(\"h1\").get_text()\n print(title)\n urltitlelist.append([url,title])\n \n print(urltitlelist)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T12:22:01.940",
"id": "59365",
"last_activity_date": "2019-09-30T12:22:01.940",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26370",
"parent_id": "59364",
"post_type": "answer",
"score": 0
}
] | 59364 | 59365 | 59365 |
{
"accepted_answer_id": "59377",
"answer_count": 2,
"body": "Djangoでブログ投稿アプリの制作をしています。 \nログインユーザのアカウントに準じて投稿者を既定したいです。\n\nその中でどのように定義してよいのか判らず困っております。 \n思い浮かぶ案 \n・HTMLでログインユーザを取得して、setするのか \n・viewやformで定義すべきなのか\n\n以下はHTML定義で、備考程度に査閲をお願いいたします\n\n```\n\n {% extends \"base.html\" %}\n \n {% block title %}Blog Create{% endblock %}\n {% block content %}\n \n <h2>ブログを投稿する</h2>\n <form method=\"POST\" class=\"post-form\">{% csrf_token %}\n <div class=\"form-group col-md-11\">\n <label for=\"id_title\">タイトル</label>\n {{ form.title }}\n </div>\n <div class=\"form-group col-md-11\">\n <label for=\"id_text\">本文</label>\n {{ form.text }}\n </div>\n <div class=\"form-group col-md-11\">\n <label for=\"id_category\">カテゴリ</label>\n {{ form.category }}\n </div>\n {# <div class=\"form-group col-md-11\">#}\n {# <label for=\"id_author\">著者</label>#}\n {# {{ form.author}}#}\n {# </div>#}\n <button type=\"submit\" class=\"save btn btn-default\">投稿</button>\n </form>\n \n {% endblock %}\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T12:41:25.893",
"favorite_count": 0,
"id": "59366",
"last_activity_date": "2019-10-01T01:48:59.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36021",
"post_type": "question",
"score": 0,
"tags": [
"python",
"django"
],
"title": "投稿画面でformにログインユーザを既定したい",
"view_count": 168
} | [
{
"body": "「既定したい」という日本語はあまり聞いたことがありませんが、ログインユーザーを投稿者に設定したいということですかね?\n\n[公式ドキュメント](https://docs.djangoproject.com/en/dev/topics/auth/default/#authentication-\ndata-in-templates)を見ると、`{{ user.username }}`で取得できそうですが、どうでしょう?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T00:51:14.120",
"id": "59372",
"last_activity_date": "2019-10-01T00:51:14.120",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "59366",
"post_type": "answer",
"score": 1
},
{
"body": "htmlテンプレートにて{{ request.user.username }} は投稿者のアカウントです。 \nユーザーのほかのattributeの値を参照したい場合、{{ request.user.attribute }}となります。\n\n投稿formのauthorをログインしているユーザーのアカウントにしますかね。\n\n```\n\n <div class=\"form-group col-md-11\">\n <label for=\"id_author\">著者</label>\n <input type=\"text\" name=\"{{ form.author.name }}\" id=\"{{ form.author.id_for_label }}\" value=\"{{ request.user.username }}\" >\n </div>\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T01:39:11.833",
"id": "59377",
"last_activity_date": "2019-10-01T01:48:59.173",
"last_edit_date": "2019-10-01T01:48:59.173",
"last_editor_user_id": "35698",
"owner_user_id": "35698",
"parent_id": "59366",
"post_type": "answer",
"score": 0
}
] | 59366 | 59377 | 59372 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "現在、15年ほど前にBorland C++ Builder6で作成されたプロジェクトファイルの内容を、最近のembarcaderoのC++ Builder\n10.3 Communityにソースコードを移してビルドしたいと思っています。\n\nただ、やはりエラーが多数でてこれからいろいろと手を付けていこうとおもっております。\n\nあまりC++ BuiderなどのIDEを使ったことがないため、色々な点で不明な点・疑問が出ていますが、\n\n[](https://i.stack.imgur.com/KfpmR.jpg)\n\n渡されているプロジェクトファイルを眺めていると\n\n・Debug.cpp \n・DevInfo.cpp \n・Main.cpp \n・ServerSetup.cpp \n・Trace.cpp\n\nだいたいこの5つの種類のcppファイルとそれに関連するhファイルやdfmファイルであることに気づきました。\n\nこれは単純に、Cpp\nBuilderのからのフォームプロジェクトを作成した時のUnit.cppができている時のように、フォーム画面が5つあるものをこのプロジェクトに属していると考えれば良いのでしょうか? \nどうぞ、ご教示の程よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T13:44:38.003",
"favorite_count": 0,
"id": "59367",
"last_activity_date": "2019-10-04T04:29:26.543",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35993",
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "C++ builderのプロジェクトファイル構成について",
"view_count": 932
} | [
{
"body": "C++Builderはあんまり触ってないので外してるかもですが、 \n同名のdfm、cpp、hの3ファイルで1個のフォーム \n同名のcpp、hの2ファイルで1個のユニットになっていると思います。 \ndrcファイルは多言語設定時の翻訳データ \nbprはプロジェクトファイルになるかと思います。 \n(但し、C++Builderはプロジェクトの移行を行うとトラブル事が多い印象があるので新規プロジェクトに上記のファイルを追加する形で移行する方が良い気がします。)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T04:41:45.127",
"id": "59384",
"last_activity_date": "2019-10-01T04:41:45.127",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3524",
"parent_id": "59367",
"post_type": "answer",
"score": 1
},
{
"body": "Borland C++ Builder6からC++ Builder 10.3 Communityですと文字列(string)の扱いが変わっていると思います。 \nBuilder6ではAnsiStringを使っていたと思いますが、Builder 10.3ではUnicodeStringがデフォルトになっていると思います。 \nこのあたりで、コンパイルエラーになることがあります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T04:22:54.270",
"id": "59452",
"last_activity_date": "2019-10-04T04:29:26.543",
"last_edit_date": "2019-10-04T04:29:26.543",
"last_editor_user_id": "24490",
"owner_user_id": "24490",
"parent_id": "59367",
"post_type": "answer",
"score": 0
}
] | 59367 | null | 59384 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Virtualbox上のUbuntuのvimでVisual\nModeで選択後に`\"``+``y`を押してクリップボードに選択内容をコピーしようとしているのですが、うまくコピーされません。\n\nまた、`\"``*``y`も試してみましたがうまくいきませんでした。\n\n`vim\n--version`を確認したところ`+clipboard`と`+xterm_clipboard`となっており、クリップボードとの連携は有効でした。\n\nどうすればよいのでしょうか?\n\n環境: \nUbuntu 19.10 \nvim: 8.1 patch 1-320 \nVirtualbox: 6.0.12",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T14:11:18.943",
"favorite_count": 0,
"id": "59368",
"last_activity_date": "2019-09-30T14:11:18.943",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5246",
"post_type": "question",
"score": 1,
"tags": [
"linux",
"ubuntu",
"vim"
],
"title": "Ubuntu上のVimでクリップボードにコピーしたものが貼り付けできない",
"view_count": 270
} | [] | 59368 | null | null |
{
"accepted_answer_id": "59371",
"answer_count": 1,
"body": "2つのスレッド処理を組み合わせてプログラムを組みたいのですが \nエラーが出てしまい、うまく行きません。\n\n1つ目が、1秒ごとにGUIをprintを行うプログラム(threadingGUI.py)です。 \ntkinterというライブラリでGUIを作っているのですが、普通にwhileループを回すとGUIがフリーズします。 \nwhileループを回してもGUIがフリーズしないように、threading処理をしてあります。 \n(参考記事:<https://teratail.com/questions/147384>)\n\n**threadingGUI.py**\n\n```\n\n import tkinter as tk\n import threading\n import time\n \n class threadingGUI():\n def __init__(self):\n self.frame=1\n self.stop_flag=False\n self.thread=None\n \n def time_count(self):\n while not self.stop_flag:\n print(self.frame)\n self.frame=self.frame+1\n time.sleep(1)\n \n def start(self):\n if not self.thread:\n self.thread = threading.Thread(target=self.time_count)\n self.stop_flag=False\n self.thread.start()\n \n def stop(self):\n if self.thread:\n self.stop_flag=True\n self.thread.join()\n self.thread=None\n \n def GUI_start(self):\n root=tk.Tk()\n Button001=tk.Button(root,text=\"Start\",command=self.start)\n Button001.pack()\n Button002=tk.Button(root,text=\"Stop\",command=self.stop)\n Button002.pack()\n root.mainloop()\n \n self.stop_flag=True\n self.thread.join()\n \n t = threadingGUI()\n t.GUI_start()\n \n```\n\n2つ目が、一定周期でプログラムを実行するためのプログラムです。 \n単純にsleepをするだけだと、プログラムの実行時間分のズレが発生するようなので \nsleepとthreadingを組み合わせています。 \n(参考記事:<https://qiita.com/montblanc18/items/05715730d99d450fd0d3>)\n\n**threading_and_sleep.py**\n\n```\n\n import time\n import threading\n \n def worker():\n print(time.time())\n time.sleep(8)\n \n def scheduler(interval, f, wait = True):\n base_time = time.time()\n next_time = 0\n while True:\n t = threading.Thread(target = f)\n t.start()\n if wait:\n t.join()\n next_time = ((base_time - time.time()) % interval) or interval\n time.sleep(next_time)\n \n scheduler(1, worker, False)\n \n```\n\nthreadingGUI.pyと、threading_and_sleep.pyを組み合わせて \n以下のように、なるべく正確に一定間隔でprintするプログラム(threading_and_sleepGUI.py)を書いてみようとしたのですが、実行すると、startボタン実行時にGUIがフリーズしてしまいます。\n\n**threading_and_sleepGUI.py**\n\n```\n\n import tkinter as tk\n import threading\n import time\n \n class threading_and_sleepGUI():\n def __init__(self):\n self.stop_flag=False\n self.thread=None\n \n def worker(self):\n print(time.time())\n time.sleep(8)\n \n def scheduler(self,interval, f, wait = True):\n base_time = time.time()\n next_time = 0\n while not self.stop_flag:\n t = threading.Thread(target = f)\n t.start()\n if wait:\n t.join()\n next_time = ((base_time - time.time()) % interval) or interval\n time.sleep(next_time)\n \n def start(self):\n if not self.thread:\n self.thread = threading.Thread(target=self.scheduler(1, self.worker, False))\n self.stop_flag=False\n self.thread.start()\n \n def stop(self):\n if self.thread:\n self.stop_flag=True\n self.thread.join()\n self.thread=None\n \n def GUI_start(self):\n root=tk.Tk()\n Button001=tk.Button(root,text=\"Start\",command=self.start)\n Button001.pack()\n Button002=tk.Button(root,text=\"Stop\",command=self.stop)\n Button002.pack()\n root.mainloop()\n \n self.stop_flag=True\n self.thread.join()\n \n t = threading_and_sleepGUI()\n t.GUI_start()\n \n```\n\nスレッド処理の最中にスレッド処理が含まれていると不具合が起きてしまうのでしょうか? \nどうしたらGUIをフリーズさせず、一定間隔でprintを行うように出来ますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T14:29:28.143",
"favorite_count": 0,
"id": "59369",
"last_activity_date": "2019-09-30T18:15:53.900",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34471",
"post_type": "question",
"score": 1,
"tags": [
"python"
],
"title": "Python スレッド処理の記述の中にもう1つスレッド処理を作りたい",
"view_count": 960
} | [
{
"body": "`self.thread = threading.Thread(target=self.scheduler(1, self.worker,\nFalse))`でtargetの引数指定の方法が間違いです。\n\n[class threading.Thread(group=None, target=None, name=None, args=(),\nkwargs={}, *,\ndaemon=None)](https://docs.python.org/ja/3/library/threading.html#threading.Thread)\n\n> args は target を呼び出すときの引数タプルです。デフォルトは () です。\n\n正しくは、`self.thread = threading.Thread(target=self.scheduler, args=(1,\nself.worker, False))`になります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T18:15:53.900",
"id": "59371",
"last_activity_date": "2019-09-30T18:15:53.900",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26370",
"parent_id": "59369",
"post_type": "answer",
"score": 1
}
] | 59369 | 59371 | 59371 |
{
"accepted_answer_id": "59380",
"answer_count": 1,
"body": "お世話になっております。初歩的な様で恐縮ですがご教授頂けませんでしょうか。\n\nユーザーに常にオープンにしているウェブサイトではシステム的に年間絶え間なく(24/7/365)でユーザーからのメッセージ等に対応しなければならない場合があると思います。\n\n例えばユーザーから何らかのメッセージを受信用のサイト(www.xxxx.php)を立ち上げることによりシステム的に即時に受信し、自動的にデータベースに保存する様な作業などがあると思います。(前提としてそのサイトがメッセージを受信する為にはそのサイトが常に立ち上がっていなけばなりません。)\n\nクライアント側でデスクトップを使用する側はその様なサイトを四六時中(24/7/365)で稼動できない場合があると思うのですが、その様な場合、サイト構築に使用した常に稼動しているサーバー会社のLinuxサーバーで対応できるものなのでしょうか。\n\nつまり、Linuxサーバーの何らかの機能で上述のサイト(www.xxxx.php)を四六時中(24/7/365)開いている状態にし、ユーザーからのメッセージを常に受信することは可能でしょうか?(サーバーの一時的なシャットダウン等には対応できるものとして)\n\nもし可能であれば、具体的なLinuxでの設定作業等、あるいは上述の目的実現のための他の方法等をお教え願いませんでしょうか。\n\n環境: \nPlesk バージョン: 17.0.17 \n構成名: Plesk 12 Web Admin for Linux \nPHP: 5.3.3 \nOS: CentOS 6.9",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-09-30T14:41:12.063",
"favorite_count": 0,
"id": "59370",
"last_activity_date": "2019-10-01T01:59:26.397",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19211",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"centos"
],
"title": "Linuxサーバー上の機能でサイトを常時開き、メッセージを受信したいです。",
"view_count": 155
} | [
{
"body": "サイトというのがWebサイト(もしくはWebページ)を指しているのであれば、クライアントからの要求に応じてブラウザに表示するページを随時返すのが\n**Webサーバ** です。\n\nWebサーバのプロセスを稼働させておけばそれ自身が \"窓口\"\nとなって適切な処理を行ってくれるので、「サイトやページを常時開いておく」という表現はあまり正しくありません。\n\n(用意したページをお店の看板の様に出しっぱなしにしているわけではなく、注文があったらそのページだけを出前で届けてあげるイメージ)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T01:59:26.397",
"id": "59380",
"last_activity_date": "2019-10-01T01:59:26.397",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "59370",
"post_type": "answer",
"score": 1
}
] | 59370 | 59380 | 59380 |
{
"accepted_answer_id": "59379",
"answer_count": 1,
"body": "# 背景\n\nDockerHubの`python:latest`イメージを使おうとしています。 \n<https://hub.docker.com/_/python>\n\nこのイメージについて、 \n* OSは何か? \n* pythonコマンド以外にどんなコマンドを使えるか \nなどを知りたいです。\n\nそのため、このイメージがどんなDockerfileでビルドされているかを確認したいです。 \nどこで確認すればよいでしょうか?\n\n`tags`のページから遷移した以下のページには、Dockerfileのような情報が記載されていました. \n`RUN`コマンドは記載されていませんでしたが、これはDockerfileに相当する情報でしょうか? \n<https://hub.docker.com/layers/python/library/python/latest/images/sha256-23d760aa4a5f2d46b12f439d113a8ffe5bf520c555b9c3aedb4765f9c8943024>\n\n[](https://i.stack.imgur.com/wSaMD.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T01:17:40.687",
"favorite_count": 0,
"id": "59373",
"last_activity_date": "2019-10-01T01:46:20.020",
"last_edit_date": "2019-10-01T01:46:20.020",
"last_editor_user_id": "3060",
"owner_user_id": "19524",
"post_type": "question",
"score": 3,
"tags": [
"docker"
],
"title": "DockerHubにあるDockerイメージのDockerfileを確認したい",
"view_count": 4031
} | [
{
"body": "Description タブを開くと \"Supported tags and respective Dockerfile links\" にタグの一覧があり、 \nそれぞれが Dockerfile にリンクされています。\n\nlatest については 現時点では [Debian 10 (buster)](https://github.com/docker-\nlibrary/python/blob/c3233a936f58bee7c6899d3e381f23ed12cfc7a8/3.7/buster/Dockerfile)\nとなるようです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T01:45:39.590",
"id": "59379",
"last_activity_date": "2019-10-01T01:45:39.590",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "59373",
"post_type": "answer",
"score": 3
}
] | 59373 | 59379 | 59379 |
{
"accepted_answer_id": "59376",
"answer_count": 1,
"body": "単純な興味による質問です。\n\nDockerHubの`ubuntu:18.04`と`ubuntu:bionic`に違いはありますか? \nbionicは18.04と同義だという認識です。 \nImage Historyはどちらも同じでした。\n\n<https://hub.docker.com/layers/ubuntu/library/ubuntu/18.04/images/sha256-1bbdea4846231d91cce6c7ff3907d26fca444fd6b7e3c282b90c7fe4251f9f86>\n\n<https://hub.docker.com/layers/ubuntu/library/ubuntu/bionic/images/sha256-1bbdea4846231d91cce6c7ff3907d26fca444fd6b7e3c282b90c7fe4251f9f86>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T01:27:39.960",
"favorite_count": 0,
"id": "59375",
"last_activity_date": "2019-10-01T01:38:43.823",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19524",
"post_type": "question",
"score": 1,
"tags": [
"docker"
],
"title": "DockerHubの`ubuntu:18.04`と`ubuntu:bionic`に違いはありますか?",
"view_count": 102
} | [
{
"body": "両者は同じものです。\n\n<https://hub.docker.com/_/ubuntu/> に、`18.04` と `bionic` が同じ Dockerfile\nから作られたイメージだと書かれています。\n\n> Supported tags and respective Dockerfile links\n>\n> * [18.04, bionic-20190912.1, bionic,\n> latest](https://github.com/tianon/docker-brew-ubuntu-\n> core/blob/30f325d6526a6dd5ff9f5663a80dcc56db363e2a/bionic/Dockerfile)\n> * [18.10, cosmic-20190719, cosmic](https://github.com/tianon/docker-brew-\n> ubuntu-core/blob/30f325d6526a6dd5ff9f5663a80dcc56db363e2a/cosmic/Dockerfile)\n> * [19.04, disco-20190913, disco,\n> rolling](https://github.com/tianon/docker-brew-ubuntu-\n> core/blob/30f325d6526a6dd5ff9f5663a80dcc56db363e2a/disco/Dockerfile)\n> * [19.10, eoan-20190916, eoan, devel](https://github.com/tianon/docker-\n> brew-ubuntu-\n> core/blob/30f325d6526a6dd5ff9f5663a80dcc56db363e2a/eoan/Dockerfile)\n> * [16.04, xenial-20190904, xenial](https://github.com/tianon/docker-brew-\n> ubuntu-core/blob/30f325d6526a6dd5ff9f5663a80dcc56db363e2a/xenial/Dockerfile)\n>\n\n(2019年10月1日時点での記述を引用)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T01:38:43.823",
"id": "59376",
"last_activity_date": "2019-10-01T01:38:43.823",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "59375",
"post_type": "answer",
"score": 1
}
] | 59375 | 59376 | 59376 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "皆様のお力をおかしください。\n\nvba操作でwebページを丸ごと保存したい。 \n(htmだけの保存ではない。)\n\n完全保存できる方法はありますか?(htmのファイルとfilesのフォルダができるようにです)",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T01:43:29.857",
"favorite_count": 0,
"id": "59378",
"last_activity_date": "2019-10-01T03:18:39.160",
"last_edit_date": "2019-10-01T03:18:39.160",
"last_editor_user_id": "32986",
"owner_user_id": "36030",
"post_type": "question",
"score": 0,
"tags": [
"vba"
],
"title": "webページを完全保存",
"view_count": 595
} | [] | 59378 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、Borland C++ Builder6で作成されたプロジェクトをembarcadero c++ builder10.3\ncommunityでビルドができないかを探っています。\n\nMain.cppというファイルがあるのですが、まずこのcppファイル内で使用されているC++\nBuilderのコンポーネントファイルを知りたくMain.hファイルというのを見ていくと、その一覧のようなところを見つけました。\n\n```\n\n ------(中略)------------------------------------------------------\n class TfrmMain : public TForm\n {\n __published: // IDE-managed Components\n TAdvDockPanel *AdvDockPanel1;\n TAdvToolBar *AdvToolBar1;\n TAdvToolBarButton *tbtnServerStart;\n TAdvToolBarButton *tbtnServerStop;\n TPopupMenu *TryMenu;\n TMenuItem *Close1;\n TMenuItem *Show1;\n TPopupMenu *ListItemMenu;\n TMenuItem *MenuItem1;\n TMenuItem *DeleteList;\n TIdTCPServer *Server;\n TIdThreadMgrDefault *IdThreadMgrDefault1;\n TAdvToolBarSeparator *AdvToolBarSeparator1;\n TAdvToolBarButton *tbtnSetup;\n TImageList *ImageList1;\n TComPort *Serial;\n TTimer *AliveTimer;\n TMediaPlayer *MPlay;\n TSaveDialog *SaveDialog;\n TAdvListView *DevListView;\n TAdvToolBarSeparator *AdvToolBarSeparator2;\n TAdvToolBarButton *tbtnMute;\n TTimer *AudioTimer;\n TIdMessage *IdMsg;\n TIdSMTP *IdSMTP1;\n TAdvMemo *memMsg;\n TStatusBar *StatusBar1;\n TMenuItem *StopAction;\n TMenuItem *StartAction;\n TMenuItem *AudioStop;\n TMenuItem *N1;\n TMenuItem *N2;\n TIdTCPServer *M06Config;\n TIdThreadMgrDefault *IdThreadMgrDefault2;\n TAdvToolBarSeparator *AdvToolBarSeparator3;\n TAdvToolBarButton *tbtnOpen;\n TAdvToolBarButton *tbtnSave;\n TOpenDialog *OpenDialog;\n ------(中略)------------------------------------------------------\n \n```\n\nc++ builder10.3 communityのIDEで\n\nTPopupMenuやTIdTCPServerなどは、パレットの検索ボックスで検索ができるのですが、いくつかのコンポーネントは検索できませんでした。\n\n例えば、”TAdvToolBarSeparator”というものなどが検索できなかったのですが、 \nこの検索できないコンポーネントというのは、どこかのサードパーティーから購入したコンポーネントということでしょうか? \nまた、TAdvToolBarSeparatorというコンポーネントはどのようなコンポーネントなのでしょうか? \nまた、購入方法などをご教示よろしくお願い致します。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T02:39:31.223",
"favorite_count": 0,
"id": "59381",
"last_activity_date": "2019-10-01T02:39:31.223",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35993",
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "TAdvToolBarSeparatorというコンポーネント",
"view_count": 75
} | [] | 59381 | null | null |
{
"accepted_answer_id": "59386",
"answer_count": 1,
"body": "Pythonのfromとimportの使い方について質問です。\n\n```\n\n from socket import socket\n socket.gethostbyname(socket.gethostname())\n \n```\n\nだとエラーになって \nAttributeError: type object 'socket' has no attribute 'gethostbyname' \nというメッセージが出ます。\n\n```\n\n import socket\n socket.gethostbyname(socket.gethostname())\n \n```\n\nだとエラーにならないのは何故でしょうか? \n`from socket import socket`の部分を残したまま、エラーを出さないコードにするにはどうすれば良いですか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T04:37:22.183",
"favorite_count": 0,
"id": "59383",
"last_activity_date": "2019-10-01T05:10:06.417",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34471",
"post_type": "question",
"score": 0,
"tags": [
"python",
"socket"
],
"title": "Pythonのsocket通信のfromとimportについて",
"view_count": 760
} | [
{
"body": "```\n\n from socket import socket\n \n```\n\nこれは、socketモジュールにあるsocketオブジェクト(この場合は関数オブジェクト)を現在の名前空間に取り込んでいます。 \n以下と同義です\n\n```\n\n import socket\n socket = socket.socket\n \n```\n\n`socket.gethostbyname()` は socketモジュールにある `gethostbyname`\n関数オブジェクトを呼び出すことを意図したコードです。このため、 `from socket import socket`\nと書いてしまうと、現在の名前空間にあるのは\nsocketモジュールではなく、socket関数オブジェクトのため、「socket関数オブジェクトにgethostbyname属性がない」というエラーになります。\n\n```\n\n AttributeError: type object 'socket' has no attribute 'gethostbyname'\n \n```\n\nそれがこのエラーです。\n\n> `from socket import socket` の部分を残したまま、エラーを出さないコードにするにはどうすれば良いですか?\n\n以下の様に書くことが出来ます\n\n```\n\n from socket import gethostbyname, gethostname\n gethostbyname(gethostname())\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T05:10:06.417",
"id": "59386",
"last_activity_date": "2019-10-01T05:10:06.417",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "806",
"parent_id": "59383",
"post_type": "answer",
"score": 1
}
] | 59383 | 59386 | 59386 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "今、私はCloud\nStorageに画像データがアップロードされたらAutoMLを動かしアップロードした画像を予測させて結果を出力するということをPythonで行おうとしています。\n\nコチラのURLの記事を参考にして作っていました。\n\n[Cloud Functions を使って、AutoML Vision API を呼び出してみた。 -\nQiita](https://qiita.com/pyru89kwmr/items/93915a0bb7e958288c35)\n\nしかし、このようなエラーが出てしまいました。\n\n```\n\n Build failed: {\n \"error\": {\n \"canonicalCode\": \"INVALID_ARGUMENT\",\n \"errorMessage\": \"`pip_download_wheels` had stderr output:\\nCommand \\\"python setup.py egg_info\\\" failed with error code 1 in /tmp/pip-wheel-ht8988nt/functools32/\\n\\nerror: `pip_download_wheels` returned code: 1\",\n \"errorType\": \"InternalError\",\n \"errorId\": \"1CCAE325\"\n }\n }\n \n```\n\nCloud Functionsのソースに何を書くとエラーなくAutoMLで予測を行えるのか教えていただきたく思います。\n\nよろしくお願いいたします。\n\nちなみに以下が実際に使用中のプログラムです。 \nPythonやGCPは初めて間もないので不足や間違いが多々あるかもしれませんがお助けいただけますと幸いです。\n\n* * *\n\n**サービスアカウントキー** \n省略\n\n**main.py**\n\n```\n\n # -*- coding: utf-8 -*-\n import json\n from automl_vision1 import get_prediction\n \n \n def hello_gcs(event, context):\n \"\"\"Triggered by a change to a Cloud Storage bucket.\n Args:\n event (dict): Event payload.\n context (google.cloud.functions.Context): Metadata for the event.\n \"\"\"\n file = event\n print(f\"Processing file: {file['name']}.\")\n \n # result = get_prediction(content=image.read())\n \n```\n\n**requirements.txt**\n\n```\n\n absl-py==0.8.0\n astor==0.8.0\n attrs==19.1.0\n autopep8==1.4.4\n backports.functools-lru-cache==1.5\n backports.shutil-get-terminal-size==1.0.0\n backports.weakref==1.0.post1\n cachetools==3.1.1\n certifi==2019.9.11\n chardet==3.0.4\n configparser==4.0.2\n contextlib2==0.5.5\n crcmod==1.7\n decorator==4.4.0\n enum34==1.1.6\n funcsigs==1.0.2\n functools32==3.2.3.post2\n future==0.17.1\n futures==3.3.0\n gast==0.3.2\n google-api-core==1.14.2\n google-api-python-client==1.7.11\n google-auth==1.6.3\n google-auth-httplib2==0.0.3\n google-cloud-bigquery==1.20.0\n google-cloud-core==1.0.3\n google-cloud-datastore==1.9.0\n google-cloud-language==1.3.0\n google-cloud-logging==1.12.1\n google-cloud-spanner==1.10.0\n google-cloud-storage==1.19.0\n google-cloud-translate==1.6.0\n google-cloud-videointelligence==1.11.0\n google-cloud-vision==0.39.0\n google-pasta==0.1.7\n google-resumable-media==0.4.1\n googleapis-common-protos==1.6.0\n grpc-google-iam-v1==0.12.3\n grpcio==1.23.0\n h5py==2.10.0\n httplib2==0.13.1\n idna==2.8\n importlib-metadata==0.23\n ipaddr==2.2.0\n ipython==5.8.0\n ipython-genutils==0.2.0\n jedi==0.14.1\n jsonschema==3.0.2\n Keras-Applications==1.0.8\n Keras-Preprocessing==1.1.0\n Markdown==3.1.1\n mccabe==0.6.1\n meld3==1.0.2\n mercurial==4.0\n mock==3.0.5\n more-itertools==5.0.0\n numpy==1.16.5\n oauth2==1.9.0.post1\n oauth2client==4.1.3\n parso==0.5.1\n pathlib2==2.3.4\n pexpect==4.7.0\n pickleshare==0.7.5\n pluggy==0.13.0\n prompt-toolkit==1.0.16\n protobuf==3.9.1\n ptyprocess==0.6.0\n pyasn1==0.4.7\n pyasn1-modules==0.2.6\n pycodestyle==2.5.0\n pydocstyle==3.0.0\n pyflakes==2.1.1\n Pygments==2.4.2\n pyrsistent==0.15.4\n python-jsonrpc-server==0.2.0\n python-language-server==0.28.3\n pytz==2019.2\n requests==2.22.0\n rope==0.14.0\n rsa==4.0\n scandir==1.10.0\n simplegeneric==0.8.1\n six==1.12.0\n snowballstemmer==1.9.1\n supervisor==3.3.1\n tensorboard==1.14.0\n tensorflow==1.14.0\n tensorflow-estimator==1.14.0\n termcolor==1.1.0\n traitlets==4.3.2\n uritemplate==3.0.0\n urllib3==1.25.3\n virtualenv==16.7.5\n wcwidth==0.1.7\n Werkzeug==0.15.6\n wrapt==1.11.2\n yapf==0.28.0\n zipp==0.6.0\n click==6.7\n Flask==1.0.2\n itsdangerous==0.24\n Jinja2==2.10\n MarkupSafe==1.0\n pip==18.0\n setuptools==40.2.0\n \n```\n\n**automl_vision1.py**\n\n```\n\n # -*- coding: utf-8 -*-\n from google.cloud import automl_v1beta1\n from google.cloud.automl_v1beta1.gapic import enums\n from google.cloud.automl_v1beta1.proto import service_pb2\n \n try:\n \n client = automl_v1beta1.AutoMlClient.from_service_account_json('*****')\n prediction_client = automl_v1beta1.PredictionServiceClient.from_service_account_json('*****')\n \n project_id = '*********'\n compute_region = 'us-central1'\n model_id = '*********'\n \n def get_prediction(content):\n payload = {\n 'image': {\n 'image_bytes': content\n }\n }\n \n ### 閾値\n params = {\n \"score_threshold\": bytes(b'0.1')\n }\n \n model_full_id = client.model_path(\n project_id, compute_region, model_id\n )\n \n ### predict\n request = prediction_client.predict(\n model_full_id, payload, params\n )\n \n ### 結果をパース -> [\"person\", 0.8235]\n result_list = [[result.display_name, result.classification.score]for result in request.payload]\n \n return result_list\n end\n except:\n pass\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T04:54:59.270",
"favorite_count": 0,
"id": "59385",
"last_activity_date": "2019-10-02T00:59:07.353",
"last_edit_date": "2019-10-02T00:59:07.353",
"last_editor_user_id": "36031",
"owner_user_id": "36031",
"post_type": "question",
"score": 0,
"tags": [
"python",
"google-cloud-storage"
],
"title": "Cloud Functionsのソースの部分にPython でCloud Storageにある画像をAutoMLの中のモデルで予測するにはどんなコードを書けば良いでしょうか?",
"view_count": 218
} | [] | 59385 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "python初心者です。 \n画像tweetしようと以下.pyを作成しました。\n\n```\n\n #!/usr/bin/env python\n # coding: utf-8\n \n import json\n from requests_oauthlib import OAuth1Session\n \n CK = '# Consumer Key' # Consumer Key\n CS = '# Consumer Secret' # Consumer Secret\n AT = '# Access Token' # Access Token\n AS = '# Accesss Token' # Accesss Token Secert\n \n # 画像とテキストのURL\n url_media = \"https://upload.twitter.com/1.1/media/upload.json\"\n url_text = \"https://api.twitter.com/1.1/statuses/update.json\"\n \n # 認証\n twitter = OAuth1Session(CK, CS, AT, AS)\n \n # 画像投稿\n path = \"# 画像ファイルのパス\" # 画像ファイルのパス\n files = {\"media\" : open(path, 'rb')}\n req_media = twitter.post(url_media, files = files)\n \n # レスポンスを確認\n if req_media.status_code != 200:\n print (\"Upload image is Failed: %s\", req_media.text)\n exit()\n \n # IDを取得\n media_id = json.loads(req_media.text)['media_id']\n print (\"Media ID: %d\" % media_id)\n \n # IDを付加してテキストを投稿\n params = {'status': '#splatoon2 #NintendoSwitch', \"media_ids\": [media_id]}\n req_media = twitter.post(url_text, params = params)\n \n # レスポンスを確認\n if req_media.status_code != 200:\n print (\"Upload text is Failed: %s\", req_text.text)\n exit()\n \n print (\"OK\")\n \n```\n\n上記を実行すると以下のエラーが表示されます。 \nCドライブ-デスクトップ配下に画像フォルダがあり、読み取り専用も解除しているのですが、どうしたらよいか分からず。 \nご教示頂けますと幸いです。\n\n```\n\n Traceback (most recent call last):\n File \"imagetweet.py\", line 21, in <module>\n files = {\"media\" : open(path, 'rb')}\n PermissionError: [Errno 13] Permission denied: '# 画像ファイルのパス'\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T05:44:09.713",
"favorite_count": 0,
"id": "59387",
"last_activity_date": "2022-05-05T13:04:05.460",
"last_edit_date": "2021-04-15T23:04:39.997",
"last_editor_user_id": "3060",
"owner_user_id": "36032",
"post_type": "question",
"score": -1,
"tags": [
"python",
"windows",
"twitter"
],
"title": "画像読み込み時の Permission denied に関して",
"view_count": 832
} | [
{
"body": "Pythonを実行するユーザーに適切なアクセス許可が与えられていないのではないでしょうか?\n\n画像ファイルを右クリックし、「プロパティ」を選択して、「セキュリティ」タブをクリックすると、その画像ファイルへのアクセス許可の状態が確認できます。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T10:32:52.190",
"id": "59398",
"last_activity_date": "2019-10-01T11:09:52.623",
"last_edit_date": "2019-10-01T11:09:52.623",
"last_editor_user_id": "21092",
"owner_user_id": "21092",
"parent_id": "59387",
"post_type": "answer",
"score": 1
}
] | 59387 | null | 59398 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Borland C++ Builder6で作成したプロジェクトファイルをC++ Builder\n10.3の新規プロジェクトに一部ずつ加えてビルドできるかやっています。\n\nプロジェクトにMain.cpp,Main.h,Main.dfmの3つのファイルを加えてビルドしてみたところ、次のようなエラーが発生しました。\n\n> [bcc32c 致命的エラー] Main.h(13): 'AdvToolBar.hpp' file not found\n\nこのエラー内容は、\n\n```\n\n #include \"AdvToolBar.hpp\"\n \n```\n\nこのAdvToolBar.hppというファイルがPC上になくてインクルードできないということでしょうか? \nこのファイルがあるかどうか確認したり、エラーの回避方法をご教示頂きますよう、よろしくお願い致します。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T07:02:56.267",
"favorite_count": 0,
"id": "59388",
"last_activity_date": "2020-07-31T06:02:25.383",
"last_edit_date": "2019-10-01T07:12:07.433",
"last_editor_user_id": "35993",
"owner_user_id": "35993",
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "ビルドすると'AdvToolBar.hpp' file not foundというエラーが発生",
"view_count": 316
} | [
{
"body": "今回のエラー\n\n> [bcc32c 致命的エラー] Main.h(13): 'AdvToolBar.hpp' file not found\n\nこれが回避できた時のスクリーンキャプチャです。忘れないように自分用に画像投稿させて頂きます。\n\n[](https://i.stack.imgur.com/siCBc.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T08:49:26.207",
"id": "59392",
"last_activity_date": "2019-10-01T08:49:26.207",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35993",
"parent_id": "59388",
"post_type": "answer",
"score": 0
}
] | 59388 | null | 59392 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "タイトルの通りiPhoneなどの標準のMapアプリなどで行える地図をドラッグして表示範囲を移動する処理を実装したいです.\n\nなにか参考になるようなコードのリンクや公式のAPIドキュメントなどがあれば教えていただけると幸いです.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T07:30:09.703",
"favorite_count": 0,
"id": "59389",
"last_activity_date": "2019-10-01T15:05:02.887",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12757",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"mapkit"
],
"title": "SwiftのMapKitで地図をドラッグして移動する方法",
"view_count": 145
} | [
{
"body": "どのように作っているかわかりませんが、 \nstoryboardの場合、 \n1) 普通にプロジェクトを作成し、viewにMKMapViewを配置。 \n2) constraintsをつけ、viewcontrollerに@IBOutletでmapViewをつなげる。 \n3) import MapKitを記述\n\nこの3つだけで、ドラッグ、指二本による拡大・縮小、回転など基本動作は全部できますよ?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T15:05:02.887",
"id": "59402",
"last_activity_date": "2019-10-01T15:05:02.887",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19202",
"parent_id": "59389",
"post_type": "answer",
"score": 2
}
] | 59389 | null | 59402 |
{
"accepted_answer_id": "59397",
"answer_count": 1,
"body": "以下のコードはなぜコンパイルエラーになるのですか?\n\n```\n\n short s = 10;\n s = s + 1;\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T09:10:34.277",
"favorite_count": 0,
"id": "59393",
"last_activity_date": "2019-10-01T11:44:50.393",
"last_edit_date": "2019-10-01T11:44:50.393",
"last_editor_user_id": "3060",
"owner_user_id": "34988",
"post_type": "question",
"score": 3,
"tags": [
"java"
],
"title": "javaの基本データ型について",
"view_count": 156
} | [
{
"body": "いったんint型に変換されてから演算が行われるからですね。\n\n```\n\n s = (short)(s + 1);\n \n```\n\nとか\n\n```\n\n s += 1;\n \n```\n\nとか\n\n```\n\n s++;\n \n```\n\nであれば、コンパイルは通りますね\n\n参考: \n<https://www.javadrive.jp/start/cast/index5.html>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T10:08:48.853",
"id": "59397",
"last_activity_date": "2019-10-01T10:08:48.853",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "59393",
"post_type": "answer",
"score": 1
}
] | 59393 | 59397 | 59397 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "C++ Builder 10.3でビルドを実施した時に次のようなエラーが出ました。\n\n> [bcc32c 致命的エラー] Main.h(14): 'TntComCtrls.hpp' file not found\n\nこのTntComCtrls.hppというヘッダファイルをエクスプローラーでCドライブ全体を検索をかけてみたのですが、全く引っ掛かりませんでした。 \nこのTntComCtrls.hppというヘッダファイルはどのような機能のコンポーネントなのでしょうか? \nまた、入手や購入できるサイトなどはありますでしょうか? \nどうぞ、ご教示の程よろしくお願い致します。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T09:40:17.860",
"favorite_count": 0,
"id": "59394",
"last_activity_date": "2020-07-05T17:05:05.580",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35993",
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "TntComCtrls.hppファイルはどのような機能のコンポーネントですか?",
"view_count": 247
} | [
{
"body": "TntUnicodeControls_2.3.0.zip内のCBuilderフォルダ内のTntLibR.bpkを先にコンパイルし、TntLibD.bpkをインストールしたらいけるのでは無いでしょうか?\n\nコンパイルエラーで上手く行かない場合は、新規でパッケージを作成しなおしてファイルを追加していく方が良いかもしれません。\n\n追記 \nちなみにTntUniCodeControlsはCBuilder2007/Delphi2009以前の非Unicode対応の環境でUnicode対応する為のコントロールなので10.3では基本的に不要かと思います。",
"comment_count": 10,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T05:53:13.247",
"id": "59410",
"last_activity_date": "2019-10-02T05:58:48.567",
"last_edit_date": "2019-10-02T05:58:48.567",
"last_editor_user_id": "3524",
"owner_user_id": "3524",
"parent_id": "59394",
"post_type": "answer",
"score": 0
}
] | 59394 | null | 59410 |
{
"accepted_answer_id": "59404",
"answer_count": 1,
"body": "Class App\\Http\\Controllers\\title does not exist \nとうエラーが出てしまいます。\n\n考えられる原因はどちらになるのでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T12:40:17.617",
"favorite_count": 0,
"id": "59399",
"last_activity_date": "2019-10-11T14:15:01.967",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35794",
"post_type": "question",
"score": -1,
"tags": [
"laravel"
],
"title": "Laravelでエラー(Class App\\Http\\Controllers\\title does not exist)",
"view_count": 995
} | [
{
"body": "文字のタイプミス \nuseで宣言してない \nファイルをLaravelが認識してない \nとそのエラーの文からは推測出来ます",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T00:10:43.033",
"id": "59404",
"last_activity_date": "2019-10-02T00:10:43.033",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35461",
"parent_id": "59399",
"post_type": "answer",
"score": 0
}
] | 59399 | 59404 | 59404 |
{
"accepted_answer_id": "59401",
"answer_count": 1,
"body": "Webブラウザを作っています。 \n読み込み中に画面下に配置したツールバーに表示されるはずのactivityIndicatorが表示されません。おそらくWebViewのdeligateができていないせいだと思いますが…。\n\nXcode8対応の参考書を元にしているので、UIWebViewでの記述しか載っておらず、WKWebViewでの記述がわかりません。調べてみたものの、解決できませんでした。どなたか知恵をお貸しください。\n\n以下は実行はできるが、Indicatorが表示されないコードです。\n\n```\n\n import UIKit\n import WebKit\n \n class ViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {\n \n @IBOutlet weak var webView: WKWebView!\n \n @IBOutlet weak var searchBar: UISearchBar!\n \n @IBOutlet weak var backButton: UIBarButtonItem!\n \n @IBOutlet weak var reloadButton: UIBarButtonItem!\n \n @IBOutlet weak var stopButton: UIBarButtonItem!\n \n @IBOutlet weak var activityIndicator: UIActivityIndicatorView!\n \n let homeUrlString = \"https://google.com\"\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view.\n open(urlString: homeUrlString)\n }\n \n func open(urlString: String){\n let url = URL(string: urlString)\n let urlRequest = URLRequest(url: url!)\n webView.load(urlRequest)\n }\n \n //MARK:- UIWebViewDelegate\n \n func webViewDidStartLoad(_ webView: UIWebView){\n activityIndicator.alpha = 1\n activityIndicator.startAnimating()\n backButton.isEnabled = false\n reloadButton.isEnabled = false\n stopButton.isEnabled = true\n }\n \n func webViewDidFinishLoad(_ webView: UIWebView)\n {\n activityIndicator.alpha = 0\n activityIndicator.stopAnimating()\n backButton.isEnabled = webView.canGoBack\n reloadButton.isEnabled = true\n stopButton.isEnabled = false\n \n }\n //MARK:- IBAction\n \n @IBAction func backButtonTapped(_ sender: UIBarButtonItem) {\n webView.goBack()\n }\n \n @IBAction func reloadButtonTapped(_ sender: UIBarButtonItem) {\n webView.reload()\n }\n \n @IBAction func stopButtonTapped(_ sender: UIBarButtonItem) {\n webView.stopLoading()\n }\n \n }\n \n```\n\n[](https://i.stack.imgur.com/D0ilv.png)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T13:01:13.343",
"favorite_count": 0,
"id": "59400",
"last_activity_date": "2019-10-01T16:47:12.097",
"last_edit_date": "2019-10-01T16:47:12.097",
"last_editor_user_id": "3060",
"owner_user_id": "36035",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode"
],
"title": "Swiftのdelegateについて",
"view_count": 462
} | [
{
"body": "まず最初に… \n**_Xcode8対応の参考書を元にしている_**\n\n正直、変化の早いSwiftや最近のiOSのことを考えると、あまりにも古すぎると言えるでしょう。可能な限り自身が今お使いのXcodeのバージョンに即したもの、さすがにXcode\n11は出たばかりですが、せめて、Xcode 10用の参考書(あるいはネット記事)を参考にしてください。\n\nあなたがどのような動機でプログラミングを始められたのかわかりませんが、そのような超古い参考書ですと、iOSプログラミングではなく、「iOSの歴史」「Swift変遷史」の方に多くの時間を取られることになるでしょう。\n\n* * *\n\nさて、本題に戻ると、あなたのコードの問題点は大きく2つあります。\n\n * `webView`のdelegateを設定しているコードが見つからない\n * `UIWebView`用のdelegateメソッドを定義してあるだけ(それらは当然呼ばれない)で、`WKWebView`用のメソッドを定義していない。\n\n1点目についてはそれほど難しくありません。`UIWebView`用の解説記事にも似たようなコードが示されているはずです。\n\n```\n\n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view.\n webView.uiDelegate = self\n webView.navigationDelegate = self //###\n \n open(urlString: homeUrlString)\n }\n \n```\n\n`uiDelegate`については、今のところ不要のようですが、念のため設定しておきましょう。\n\n* * *\n\n2点目についてですが、`UIWebView`用のdelegateメソッドと`WKWebView`用のdelegateメソッドでは、いつでも対応するものが存在するわけではありません。ですが、「ほぼ同じ働きをする」程度でよければ、簡単に置き換えられる場合もあります。\n\n\"webViewDidStartLoad wkwebview\"あたりのキーワードで検索してみると、私の環境では日本語の解説記事も見つかりました。\n\nとりあえず、[英語版の本家stackoverflowの記事](https://stackoverflow.com/a/37513449/6541007)から拾ってきたのがこちら:\n\n```\n\n webViewDidFinishLoad => didFinishNavigation\n webViewDidStartLoad => didStartProvisionalNavigation\n \n```\n\n`didStartProvisionalNavigation`と`didFinishNavigation`と言うのは、どちらも`WKNavigationDelegate`のメソッドを表しています。あなたが示されたコードの`webViewDidStartLoad(_:)`と`webViewDidFinishLoad(_:)`の代わりに以下の2つのメソッドを`ViewController`クラスに追加してみてください。\n\n```\n\n //MARK:- WKNavigationDelegate\n \n func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {\n activityIndicator.alpha = 1\n activityIndicator.startAnimating()\n backButton.isEnabled = false\n reloadButton.isEnabled = false\n stopButton.isEnabled = true\n }\n \n func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {\n activityIndicator.alpha = 0\n activityIndicator.stopAnimating()\n backButton.isEnabled = webView.canGoBack\n reloadButton.isEnabled = true\n stopButton.isEnabled = false\n }\n \n```\n\nもしかしたら、storyboardの設定等に問題があれば、うまく表示されないかもしれませんが、少なくともこちらのテスト用プロジェクトでは、このコードでご所望の位置に`UIActivityIndicatorView`が表示されます。(ローディングが完了すると消えるので、ネットの状況が良すぎると見逃してしまいますが。)\n\nお試しの上、何かありましたらコメント等でお知らせください。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-01T14:14:01.067",
"id": "59401",
"last_activity_date": "2019-10-01T14:14:01.067",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "59400",
"post_type": "answer",
"score": 1
}
] | 59400 | 59401 | 59401 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "SQL Server Management Studio\nのとあるログインユーザーでストアドプロシージャの実行はできるが、変更や、プロシージャのソースコードの閲覧はできないように設定を行いたいのですがどのロールの設定、変更を行えばいいでしょうか。 \nご教示お願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T02:00:00.770",
"favorite_count": 0,
"id": "59405",
"last_activity_date": "2019-10-02T07:48:48.683",
"last_edit_date": "2019-10-02T07:48:48.683",
"last_editor_user_id": "2238",
"owner_user_id": "19580",
"post_type": "question",
"score": 0,
"tags": [
"sql-server"
],
"title": "SQLServerManagementStudioのユーザ権限の設定",
"view_count": 304
} | [
{
"body": "特定のストアドプロシージャの実行権限をユーザーに与える場合。\n\n```\n\n GRANT EXECUTE ON dbo.procname TO username;\n \n```\n\n実行権限を持つロールを作る場合。\n\n```\n\n CREATE ROLE rolename;\n GRANT EXECUTE TO rolename;\n ALTER ROLE rolename ADD MEMBER username;\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T02:16:47.050",
"id": "59406",
"last_activity_date": "2019-10-02T02:16:47.050",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2238",
"parent_id": "59405",
"post_type": "answer",
"score": 0
}
] | 59405 | null | 59406 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Golangの学習しております。 \nGoModulesを利用したバージョン管理について学んでいるのですが、以下のような構成の場合 \n一度github上に反映した後、ローカルのhello-world.goを修正してもリモート上のパッケージを参照してしまい、動作の確認ができません。\n\n対応として以下の方法があるようなのですが、どの方法を取るのが良いのでしょうか。\n\n * vendorディレクトリを使う\n * GOPROXY経由で参照する\n * replaceディレクティブを使う\n\n```\n\n ├── main.go\n └── pkg\n └── hello-world\n └── hello-world.go\n \n```\n\n```\n\n package main\n \n import (\n \"github.com/repo/project/pkg/hello-world\"\n )\n \n func main() {\n helloworld.HelloWorld()\n }\n \n```\n\nまた replaceディレクティブを使う を試しているのですが \n以下の通りgo.modを修正してビルドすると以下のエラーが発生するのですが \n解消方法をご教示いただけないでしょうか。\n\n```\n\n module github.com/repo/project\n \n go 1.13\n \n require github.com/repo/project v0.0.0\n \n replace github.com/repo/project => ./\n \n \n```\n\n```\n\n ▸ go build\n go: finding github.com/repo/project latest\n build github.com/repo/project: cannot load github.com/repo/project/pkg/hello-world: module github.com/repo/project@latest (v0.0.0) found, but does not contain package github.com/repo/project/pkg/hello-world\n \n```\n\nよろしくお願いいたします",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T03:01:51.573",
"favorite_count": 0,
"id": "59407",
"last_activity_date": "2019-10-02T03:01:51.573",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34605",
"post_type": "question",
"score": 2,
"tags": [
"go"
],
"title": "Go Modulesでローカルパッケージを修正する場合",
"view_count": 663
} | [] | 59407 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "### 前提・実現したいこと\n\nVisual Studio\nCode(VSCode)でJavaScriptのファイルを保存した時に[Prettier](https://prettier.io/)のみを走らせたい。\n\n### 発生している問題・エラーメッセージ\n\nファイル保存時にPretterでフォーマットしたく、VSCodeの[Prettierの拡張](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-\nvscode)を入れ、`\"editor.formatOnSave\": true`に設定しています。\n\nこれで一応ファイルのフォーマットは行われるようになったのですが、リポジトリ内のESLintのAutoFixも同時に行われてしまい困っています。\n\n[ESLintの拡張](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-\neslint)が悪さをしているのかと思い、`\"eslint.autoFixOnSave\": false`を設定しても効きません。\n\n### 該当のソースコード\n\n該当のリポジトリがこちらです <https://github.com/pvcresin/es>\n\n### 試したこと\n\n現状は[ファイルを保存した時に任意のコマンドを走らせる拡張](https://marketplace.visualstudio.com/items?itemName=wk-j.save-\nand-run)を使って、`prettier --write`を走らせて凌いでいます。\n\nが、formatOnSaveから拡張経由でPrettierを動かすよりワンテンポ遅れて整形が走るので、できればPrettierとESLint以外の拡張に頼らずにできないかなと模索しています。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T04:30:19.167",
"favorite_count": 0,
"id": "59408",
"last_activity_date": "2019-10-02T04:30:19.167",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36038",
"post_type": "question",
"score": 2,
"tags": [
"javascript",
"vscode"
],
"title": "VSCodeでファイル保存時にPrettierのみを走らせたい",
"view_count": 179
} | [] | 59408 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "LAMP環境が構築されている「さくらのVPS」にBitnami Redmineのインストールをしましたが、 \nBitnami付属のMySQLと、元々入っていたMySQLの同時起動は不可能な事を確認しました。\n\nApacheはRedmine側のポートを8081に変更することで同時起動ができたのですが、MySQLはポート変更では無くRedmineから参照しているDBを「RedmineのMySQL\n-> 元々入っていたMySQL」に変更したいと思っています。\n\n検索エンジン等で探してみたりドキュメントを漁ったりしたのですが中々良い方法が見つからず困っています。 \n恐れながらご教授頂きたく存じます。\n\n環境は以下の構成です。 \nCentOS 6.6 \nBitnami Redmine 3.3 \nApache 2.2.15 \nMySQL 14.14 \nPHP 5.5",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T05:55:41.400",
"favorite_count": 0,
"id": "59411",
"last_activity_date": "2022-03-04T11:04:05.417",
"last_edit_date": "2019-10-03T03:55:23.707",
"last_editor_user_id": "3060",
"owner_user_id": "36040",
"post_type": "question",
"score": 0,
"tags": [
"mysql",
"redmine",
"bitnami"
],
"title": "Bitnami Redmineで参照先のDBを変更したい",
"view_count": 2920
} | [
{
"body": "RedmineでDBの接続先はインストールディレクトリ以下にある `config/database.yml`\nという設定ファイルで管理されているはずなので、この記述を適切な情報に書き換えてみてください。\n\n**/opt/bitnami/apps/redmine/htdocs/config/database.yml**\n\n```\n\n production:\n adapter: mysql2\n database: bitnami_redmine\n host: localhost\n username: bitnami\n password: xxxxxxxx\n xxxxxx\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T06:44:55.597",
"id": "59413",
"last_activity_date": "2019-10-02T06:44:55.597",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "59411",
"post_type": "answer",
"score": 1
}
] | 59411 | null | 59413 |
{
"accepted_answer_id": "59418",
"answer_count": 1,
"body": "Chrome拡張で公式のサンプルを見たところ不明点がありました。 \n自分では気がつけてないメリットがあるかもしれないので解説をお願いしたく質問します。\n\n## 質問\n\n後述のコードでchrome.bookmarks.getTreeをvar bookmarkTreeNodesでうけている理由はなんでしょうか? \n別にchrome.bookmarks.getTreeのコールバックでfunction(bookmarkTreeNodes){}が実行されれば特に問題は無い認識です。 \nそれにも関わらずなんのために戻り値を変数でうけているのでしょうか?\n\n## 公式のサンプルの場所\n\n * 下記URLのMy Bookmarks \n<https://developer.chrome.com/extensions/samples>\n\n## popup.js内の該当のコード\n\n```\n\n function dumpBookmarks(query) {\n var bookmarkTreeNodes = chrome.bookmarks.getTree(\n function(bookmarkTreeNodes) {\n $('#bookmarks').append(dumpTreeNodes(bookmarkTreeNodes, query));\n });\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T09:26:58.000",
"favorite_count": 0,
"id": "59417",
"last_activity_date": "2019-10-02T11:15:28.140",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "32428",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"chrome-extension"
],
"title": "Chrome拡張の公式サンプルでのjavascriptに関する不明点の質問",
"view_count": 75
} | [
{
"body": "コードの作者ではないので意図は理解できませんが、代入しなくても全く同じ動作となるので代入が無い方が混乱を招きにくいとは思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T11:15:28.140",
"id": "59418",
"last_activity_date": "2019-10-02T11:15:28.140",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4388",
"parent_id": "59417",
"post_type": "answer",
"score": 0
}
] | 59417 | 59418 | 59418 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "LINEbotの中でぐるなびAPIを使用して情報を所得したく、rubyのcontrollerファイルにコードを記述しているのですが、下記エラーが発生して困っています。お力添えいただけると幸いです。\n\n# エラー文\n\n```\n\n I, [2019-10-03T00:56:21.711041 #4] INFO -- : [eb3f8fb8-27c3-413a-93cf-c2b167063968] Completed 500 Internal Server Error in 922ms\n 2019-10-03T00:56:21.711691+00:00 app[web.1]: F, [2019-10-03T00:56:21.711621 #4] FATAL -- : [eb3f8fb8-27c3-413a-93cf-c2b167063968]\n 2019-10-03T00:56:21.711762+00:00 app[web.1]: F, [2019-10-03T00:56:21.711705 #4] FATAL -- : [eb3f8fb8-27c3-413a-93cf-c2b167063968] NoMethodError (undefined method `sample' for nil:NilClass):\n 2019-10-03T00:56:21.711817+00:00 app[web.1]: F, [2019-10-03T00:56:21.711765 #4] FATAL -- : [eb3f8fb8-27c3-413a-93cf-c2b167063968]\n 2019-10-03T00:56:21.711880+00:00 app[web.1]: F, [2019-10-03T00:56:21.711829 #4] FATAL -- : [eb3f8fb8-27c3-413a-93cf-c2b167063968] app/controllers/linebot_controller.rb:48:in `block in callback'\n 2019-10-03T00:56:21.711881+00:00 app[web.1]: [eb3f8fb8-27c3-413a-93cf-c2b167063968] app/controllers/linebot_controller.rb:28:in `each'\n 2019-10-03T00:56:21.711883+00:00 app[web.1]: [eb3f8fb8-27c3-413a-93cf-c2b167063968] app/controllers/linebot_controller.rb:28:in `callback'\n \n```\n\n# 該当箇所のコード\n\n**linebot_controller.rb**\n\n```\n\n events.each { |event|\n if event.message['text'] != nil\n place = event.message['text'] #ここでLINEで送った文章を取得\n result = `curl -X GET https://api.gnavi.co.jp/RestSearchAPI/v3/?keyid=78d2d49f3aa8747a6cc03da01cf41bdd&category_s=RSFST08008&category_s=RSFST08009&#{place}`#ここでぐるなびAPIを叩く#{place}\n else\n latitude = event.message['latitude']\n longitude = event.message['longitude']\n \n result = `curl -X GET https://api.gnavi.co.jp/RestSearchAPI/v3/?keyid=78d2d49f3aa8747a6cc03da01cf41bdd&category_s=RSFST08008category_s=RSFST08009&latitude=#{latitude}longitude=#{longitude}` #ここでぐるなびAPIを叩く\n end\n \n hash_result = JSON.parse result #レスポンスが文字列なのでhashにパースする\n shops = hash_result[\"rest\"] #ここでお店情報が入った配列となる\n shop = shops.sample #任意のものを一個選ぶ\n \n #店の情報\n url = shop[\"url_mobile\"] #サイトのURLを送る\n shop_name = shop[\"name\"] #店の名前\n category = shop[\"category\"] #カテゴリー\n open_time = shop[\"opentime\"] #空いている時間\n holiday = shop[\"holiday\"] #定休日\n \n```\n\n# 全体のコード\n\n```\n\n class LinebotController < ApplicationController\n require 'line/bot' # gem 'line-bot-api'\n \n # callbackアクションのCSRFトークン認証を無効\n protect_from_forgery :except => [:callback]\n \n def client\n @client ||= Line::Bot::Client.new { |config|\n config.channel_secret = ENV[\"LINE_CHANNEL_SECRET\"]\n config.channel_token = ENV[\"LINE_CHANNEL_TOKEN\"]\n }\n end\n \n def callback\n body = request.body.read\n \n signature = request.env['HTTP_X_LINE_SIGNATURE']\n unless client.validate_signature(body, signature)\n error 400 do 'Bad Request' end\n end\n \n events = client.parse_events_from(body)\n \n #ここでlineに送られたイベントを検出している\n # messageのtext: に指定すると、返信する文字を決定することができる\n #event.message['text']で送られたメッセージを取得することができる\n events.each { |event|\n if event.message['text'] != nil\n place = event.message['text'] #ここでLINEで送った文章を取得\n result = `curl -X GET https://api.gnavi.co.jp/RestSearchAPI/v3/?keyid=78d2d49f3aa8747a6cc03da01cf41bdd&category_s=RSFST08008&category_s=RSFST08009&#{place}`#ここでぐるなびAPIを叩く#{place}\n else\n latitude = event.message['latitude']\n longitude = event.message['longitude']\n puts event.message['latitude']\n puts event.message['longitude']\n puts event.message['latitude'].class\n result = `curl -X GET https://api.gnavi.co.jp/RestSearchAPI/v3/?keyid=78d2d49f3aa8747a6cc03da01cf41bdd&category_s=RSFST08008&category_s=RSFST08009&latitude=#{latitude}&longitude=#{longitude}`#ここでぐるなびAPIを叩くlatitude=#{latitude}longitude=#{longitude}\n end\n hash_result = JSON.parse(result) #レスポンスが文字列なのでhashにパースする\n shops = hash_result[\"rest\"] #ここでお店情報が入った配列となる\n shop = shops.sample #任意のものを一個選ぶ\n puts shop\n \n 店の情報\n url = shop[\"url_mobile\"] #サイトのURLを送る\n shop_name = shop[\"name\"] #店の名前\n category = shop[\"category\"] #カテゴリー\n open_time = shop[\"opentime\"] #空いている時間\n holiday = shop[\"holiday\"] #定休日\n \n if open_time.class != String #空いている時間と定休日の二つは空白の時にHashで返ってくるので、文字列に直そうとするとエラーになる。そのため、クラスによる場合分け。\n open_time = \"\"\n end\n if holiday.class != String\n holiday = \"\"\n end\n \n response = \"【店名】\" + shop_name + \"\\n\" + \"【カテゴリー】\" + category + \"\\n\" + \"【営業時間と定休日】\" + open_time + \"\\n\" + holiday + \"\\n\" + url\n case event #case文 caseの値がwhenと一致する時にwhenの中の文章が実行される(switch文みたいなもの)\n when Line::Bot::Event::Message\n case event.type\n when Line::Bot::Event::MessageType::Text,Line::Bot::Event::MessageType::Location\n message = {\n type: 'text',\n text: response\n }\n client.reply_message(event['replyToken'], message)\n end\n \n end\n } \n \n head :ok\n end\n end\n \n```\n\n`hash_result = JSON.parse result` のところまで値を所得出来ているのですが、 \n`shops = hash_result[\"rest\"]` のところで値が `nil` になりエラーが発生してしまいます。 \n構文ミス等探したのですが、見つけることが出来ず困ってます。 \nもしよろしければご回答いただけると幸いです。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T12:09:42.390",
"favorite_count": 0,
"id": "59419",
"last_activity_date": "2019-11-08T01:01:50.203",
"last_edit_date": "2019-10-03T01:01:02.833",
"last_editor_user_id": "36043",
"owner_user_id": "36043",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"api",
"line"
],
"title": "Rubyでぐるなびapiを叩く際に出るNoMethodErrorを解決したい。",
"view_count": 362
} | [
{
"body": "```\n\n result = `curl -X GET https://api.gnavi.co.jp/RestSearchAPI/v3/?keyid=78d2d49f3aa8747a6cc03da01cf41bdd&category_s=RSFST08008&category_s=RSFST08009&#{place}`#ここでぐるなびAPIを叩く#{place}\n \n```\n\n外部コマンドに不備があります。 `&` を `\\\\&` に変更すれば動くのではないでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T00:32:00.137",
"id": "59444",
"last_activity_date": "2019-10-04T00:32:00.137",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36061",
"parent_id": "59419",
"post_type": "answer",
"score": 1
}
] | 59419 | null | 59444 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Xcodeでコレクションビューを使ったTODOアプリを作っています。 \ncollectionViewのセルをロングタップすると入力画面に遷移し、次画面にて入力された内容をセル上のラベルにそれぞれ表示したいのですが値が渡らず困っています・・・。 \nNavigationControllerは使っておらず、segueにはpresentModallyを使っています。エラー等も出ていません。 \n何か解る方がいましたらご教授お願いしたいです。よろしくお願いします。\n\n```\n\n import UIKit\n \n struct MyTodoItem {\n var title: String\n var dateString: String? \n }\n \n \n class ViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource,UIGestureRecognizerDelegate,nextViewControllerDelegate {\n \n \n \n @IBOutlet weak var todoCollection: UICollectionView!\n \n let toDos = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]\n \n var todos: [MyTodoItem] = [\n MyTodoItem(title: \"1\", dateString: nil),\n MyTodoItem(title: \"2\", dateString: nil),\n MyTodoItem(title: \"3\", dateString: nil),\n MyTodoItem(title: \"4\", dateString: nil),\n MyTodoItem(title: \"5\", dateString: nil),\n MyTodoItem(title: \"6\", dateString: nil),\n ]\n \n \n \n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n let layout = UICollectionViewFlowLayout()\n layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)\n layout.itemSize = CGSize(width: 100,height: 100)\n todoCollection.collectionViewLayout = layout\n \n let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(cellLongPressed))\n longPressGestureRecognizer.delegate = self\n longPressGestureRecognizer.allowableMovement = 15\n longPressGestureRecognizer.minimumPressDuration = 0.6\n todoCollection.addGestureRecognizer(longPressGestureRecognizer)\n \n }\n \n \n func nextViewController(_ nextVC: NextViewController, didFinishText text: String?) {\n \n if let editingItem = self.editingItem {\n \n todos[editingItem].dateString = text\n \n todoCollection.reloadItems(at: [IndexPath(item: editingItem, section: 0)])\n }\n \n \n }\n \n \n \n //表示するセルの数\n func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {\n return 6\n }\n \n func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {\n \n let cell = collectionView.dequeueReusableCell(withReuseIdentifier: \"cell\", for: indexPath)\n cell.backgroundColor = .systemPink\n \n let item = todos[indexPath.row]\n \n \n let todoLabel = cell.contentView.viewWithTag(1) as! UILabel\n todoLabel.text = item.title \n let dateLabel = cell.contentView.viewWithTag(2) as! UILabel\n dateLabel.text = item.dateString \n \n return cell\n \n \n }\n func collectionview(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {\n let horizontalSpace : CGFloat = 20\n let cellSize : CGFloat = self.view.bounds.width / 3 - horizontalSpace\n return CGSize(width: cellSize, height: cellSize)\n }\n \n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n }\n \n @objc func cellLongPressed(sender: UILongPressGestureRecognizer){\n \n if sender.state == UIGestureRecognizer.State.began{\n \n performSegue(withIdentifier: \"next\", sender: nil)\n \n }\n \n \n \n }\n \n \n \n var editingItem: Int?\n \n \n \n \n override func prepare(for segue: UIStoryboardSegue, sender: Any?) {\n \n \n let nextVC = segue.destination as! NextViewController\n nextVC.delegate = self\n \n }\n \n \n \n }\n \n \n \n```\n\n```\n\n import UIKit\n \n \n \n protocol nextViewControllerDelegate {\n \n func nextViewController(_ nextVC:NextViewController,didFinishText text: String?)\n }\n \n \n class NextViewController: UIViewController,UITextFieldDelegate {\n \n //デートピッカー\n var datePicker :UIDatePicker = UIDatePicker()\n \n \n @IBOutlet weak var dayTextField: UITextField!\n \n \n var delegate: nextViewControllerDelegate?\n \n \n \n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n //デートピッカー\n datePicker.datePickerMode = UIDatePicker.Mode.date\n datePicker.timeZone = NSTimeZone.local\n datePicker.locale = Locale(identifier: \"ja\")\n dayTextField.inputView = datePicker\n //デートピッカーのツールバー関係\n let toolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 35))\n let spaceItem = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: #selector(done))\n let doneItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(done)); toolBar.setItems([spaceItem,doneItem],animated: true)\n \n dayTextField.inputView = datePicker\n dayTextField.inputAccessoryView = toolBar\n \n }\n //デートピッカーを閉じるメソッド\n func textFieldShouldReturn(_ textField: UITextField) -> Bool {\n \n textField.resignFirstResponder()\n \n return true\n }\n //デートピッカーにdoneボタン\n \n @ objc func done(){\n dayTextField.endEditing(true)\n \n let formatter = DateFormatter()\n \n formatter.dateFormat = \"yyyy年MM月dd日\"\n \n dayTextField.text = \"\\(formatter.string(from: datePicker.date))\"\n \n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n \n }\n \n \n @IBAction func addButton(_ sender: Any) {\n \n \n delegate?.nextViewController(self, didFinishText: dayTextField.text)\n \n self.dismiss(animated: true, completion: nil)\n \n \n \n \n \n }\n \n \n }\n \n```\n\n```\n\n swift\n \n import UIKit\n \n \n \n struct MyTodoItem {\n var title: String\n var dateString: String? \n \n }\n \n \n class ViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource,UIGestureRecognizerDelegate,nextViewControllerDelegate {\n \n \n \n \n \n @IBOutlet weak var babyImage: UIImageView!\n \n \n @IBOutlet weak var todoCollection: UICollectionView!\n \n let toDos = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]\n \n \n var todos: [MyTodoItem] = [\n MyTodoItem(title: \"1\", dateString: nil),\n MyTodoItem(title: \"2\", dateString: nil),\n MyTodoItem(title: \"3\", dateString: nil),\n MyTodoItem(title: \"4\", dateString: nil),\n MyTodoItem(title: \"5\", dateString: nil),\n MyTodoItem(title: \"6\", dateString: nil),\n ]\n \n \n \n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n let layout = UICollectionViewFlowLayout()\n layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)\n layout.itemSize = CGSize(width: 100,height: 100)\n todoCollection.collectionViewLayout = layout\n \n let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(cellLongPressed))\n longPressGestureRecognizer.delegate = self\n longPressGestureRecognizer.allowableMovement = 15\n longPressGestureRecognizer.minimumPressDuration = 0.6\n todoCollection.addGestureRecognizer(longPressGestureRecognizer)\n \n }\n \n func nextViewController(_ nextVC: NextViewController, didFinishText text: String?) {\n \n if let editingItem = self.editingItem {\n \n todos[editingItem].dateString = text\n \n todoCollection.reloadItems(at: [IndexPath(item: editingItem, section: 0)])\n }\n \n \n \n }\n \n \n //表示するセルの数\n func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {\n return 6\n }\n \n func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {\n \n let cell = collectionView.dequeueReusableCell(withReuseIdentifier: \"cell\", for: indexPath)\n //セルの色\n cell.backgroundColor = .systemPink\n \n let item = todos[indexPath.row]\n \n \n let todoLabel = cell.contentView.viewWithTag(1) as! UILabel\n todoLabel.text = item.title //<-\n let dateLabel = cell.contentView.viewWithTag(2) as! UILabel\n dateLabel.text = item.dateString//<-\n \n \n \n return cell\n \n \n }\n func collectionview(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {\n let horizontalSpace : CGFloat = 20\n let cellSize : CGFloat = self.view.bounds.width / 3 - horizontalSpace\n return CGSize(width: cellSize, height: cellSize)\n }\n \n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n }\n \n @objc func cellLongPressed(sender: UILongPressGestureRecognizer){\n \n \n if sender.state == UIGestureRecognizer.State.began{\n \n performSegue(withIdentifier: \"next\", sender: nil)\n \n \n \n \n }\n \n \n \n \n }\n \n \n \n var editingItem: Int?\n \n \n \n \n override func prepare(for segue: UIStoryboardSegue, sender: Any?) {\n \n if segue.identifier == \"next\" {\n \n let cell = sender as! UICollectionViewCell\n \n if let indexPath = todoCollection.indexPath(for: cell) {\n editingItem = indexPath.item\n } else {\n editingItem = nil\n }\n \n \n let nextVC = segue.destination as! NextViewController\n nextVC.delegate = self\n \n }\n \n \n \n }\n \n \n \n }\n \n \n \n \n```",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T15:47:40.293",
"favorite_count": 0,
"id": "59422",
"last_activity_date": "2019-10-06T16:54:53.580",
"last_edit_date": "2019-10-06T16:54:53.580",
"last_editor_user_id": "34757",
"owner_user_id": "34757",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode"
],
"title": "swift 値渡しがされない場合の解決方法",
"view_count": 433
} | [] | 59422 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Android Studioのライセンスに関する質問があります。\n\nGoogle社へ直接質問ができず、かつ別の方々ではあいまいな回答や無回答しか得られませんでしたので、確認と念のためも含めて質問をいたしました。\n\n内容としましては、\n\n 1. Android Studioで作成されたAndroidアプリなど制作物の著作権は、Android Studioで作成した人になるのでしょうか?\n\n 2. 自由に販売や公開をしても問題ないでしょうか?\n\n 3. Android Studioは無料で使ってもいいという理解でよろしかったでしょうか?\n\n 4. Android Studioを使う上で売り上げの上限など何か規制はあるのでしょうか?\n\n以上よろしくお願いします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T18:54:50.437",
"favorite_count": 0,
"id": "59423",
"last_activity_date": "2019-10-04T16:30:28.823",
"last_edit_date": "2019-10-04T16:30:28.823",
"last_editor_user_id": "36047",
"owner_user_id": "36047",
"post_type": "question",
"score": 0,
"tags": [
"android-studio",
"ライセンス"
],
"title": "Android Studioのライセンスに関する質問",
"view_count": 654
} | [] | 59423 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Windows updateを自動で取得して再起動までするバッチを教えていただきたいです。\n\nWindows updateの自動設定の機能が使えないため、ログオンスクリプトかスタートアップに設定したいと考えております。\n\n更新プログラムは、インターネットに取りに行きます。 \nご教示お願い致します。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-02T23:21:56.720",
"favorite_count": 0,
"id": "59424",
"last_activity_date": "2019-10-02T23:21:56.720",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36048",
"post_type": "question",
"score": 0,
"tags": [
"windows",
"powershell",
"batch-file"
],
"title": "Windows updateを取得し再起動するバッチ",
"view_count": 583
} | [] | 59424 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "WebAppにデプロイしたnodejsで作ったアプリから外部のApiを利用するため、利用元にグローバルアドレスを報告しなければならなくなりました。WebAppのグローバルIPアドレスはどのように設定すれば良いでしょうか。またはグローバルIPアドレスを知る方法をご教示いただけないでしょうか。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T00:23:19.927",
"favorite_count": 0,
"id": "59425",
"last_activity_date": "2023-05-19T19:01:05.127",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36049",
"post_type": "question",
"score": 0,
"tags": [
"azure"
],
"title": "Microsoft Azureのweb App のグローバルアドレスを作りたい。",
"view_count": 672
} | [
{
"body": "外部の API から見た WebApps のグローバル IP アドレスを知りたいというご質問だと理解しました。次の URL をご確認ください。\n\n<https://docs.microsoft.com/ja-jp/azure/app-service/overview-inbound-outbound-\nips#when-outbound-ips-change>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T13:29:15.607",
"id": "59466",
"last_activity_date": "2019-10-04T13:29:15.607",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "32270",
"parent_id": "59425",
"post_type": "answer",
"score": 0
}
] | 59425 | null | 59466 |
{
"accepted_answer_id": "59427",
"answer_count": 1,
"body": "Kerasでcifar10のデータセットを転移学習を用いて分類するという目的のコードなのですが、エラーが出てきてこれはどういうことなのでしょうか?\n\n* * *\n\n**ソースコード**\n\n```\n\n from keras import optimizers\n from keras.applications.vgg16 import VGG16\n from keras.datasets import cifar10\n from keras.layers import Dense, Dropout, Flatten, Input\n from keras.models import Model, Sequential\n from keras.utils.np_utils import to_categorical\n import matplotlib.pyplot as plt\n import numpy as np\n \n (X_train, y_train), (X_test, y_test) = cifar10.load_data()\n X_train = X_train[:300]\n X_test = X_test[:100]\n y_train = to_categorical(y_train)[:300]\n y_test = to_categorical(y_test)[:100]\n \n #input_tensorを定義\n input_tensor = Input(shape=(32, 32, 3))\n \n vgg16 = VGG16(include_top=False, weights='imagenet', input_tensor=input_tensor)\n \n top_model = Sequential()\n top_model.add(Flatten(input_shape=vgg16.output_shape[1:]))\n top_model.add(Dense(256, activation='sigmoid'))\n top_model.add(Dropout(0.5))\n top_model.add(Dense(10, activation='softmax'))\n \n # vgg16とtop_modelを連結\n model = Model(inputs=vgg16.input, outputs=top_model(vgg16.output))\n \n # 19層目までの重みをfor文を用いて固定\n for layer in model.layers[:19]:\n layer.trainable = False\n \n model.compile(loss='categorical_crossentropy',\n optimizer=optimizers.SGD(lr=1e-4, momentum=0.9),\n metrics=['accuracy'])\n \n \n model.load_weights('param_vgg.hdf5')\n \n model.fit(X_train, y_train, validation_data=(X_test, y_test), batch_size=32, epochs=1)\n \n # 以下でモデルの重みを保存する\n # model.save_weights('param_vgg.hdf5')\n \n # 精度の評価\n scores = model.evaluate(X_test, y_test, verbose=1)\n print('Test loss:', scores[0])\n print('Test accuracy:', scores[1])\n \n # データの可視化(テストデータの先頭の10枚)\n for i in range(10):\n plt.subplot(2, 5, i+1)\n plt.imshow(X_test[i])\n plt.suptitle(\"テストデータの先頭の10枚\",fontsize=16)\n plt.show()\n \n # 予測(テストデータの先頭の10枚)\n pred = np.argmax(model.predict(X_test[0:10]), axis=1)\n print(pred)\n \n model.summary()\n \n```\n\n**エラーメッセージ**\n\n```\n\n ----------------------------------------\n Using TensorFlow backend.\n WARNING:tensorflow:From /Users/ipodtao/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n Instructions for updating:\n Colocations handled automatically by placer.\n WARNING:tensorflow:From /Users/ipodtao/anaconda3/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\n Instructions for updating:\n Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\n ---------------------------------------------------------------------------\n OSError Traceback (most recent call last)\n <ipython-input-1-da6afae9ece9> in <module>\n 37 \n 38 \n ---> 39 model.load_weights('param_vgg.hdf5')\n 40 \n 41 model.fit(X_train, y_train, validation_data=(X_test, y_test), batch_size=32, epochs=1)\n \n ~/anaconda3/lib/python3.7/site-packages/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape)\n 1155 if h5py is None:\n 1156 raise ImportError('`load_weights` requires h5py.')\n -> 1157 with h5py.File(filepath, mode='r') as f:\n 1158 if 'layer_names' not in f.attrs and 'model_weights' in f:\n 1159 f = f['model_weights']\n \n ~/anaconda3/lib/python3.7/site-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)\n 392 fid = make_fid(name, mode, userblock_size,\n 393 fapl, fcpl=make_fcpl(track_order=track_order),\n --> 394 swmr=swmr)\n 395 \n 396 if swmr_support:\n \n ~/anaconda3/lib/python3.7/site-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)\n 168 if swmr and swmr_support:\n 169 flags |= h5f.ACC_SWMR_READ\n --> 170 fid = h5f.open(name, flags, fapl=fapl)\n 171 elif mode == 'r+':\n 172 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)\n \n h5py/_objects.pyx in h5py._objects.with_phil.wrapper()\n \n h5py/_objects.pyx in h5py._objects.with_phil.wrapper()\n \n h5py/h5f.pyx in h5py.h5f.open()\n \n OSError: Unable to open file (unable to open file: name = 'param_vgg.hdf5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T00:39:49.873",
"favorite_count": 0,
"id": "59426",
"last_activity_date": "2019-10-03T05:23:51.327",
"last_edit_date": "2019-10-03T05:23:51.327",
"last_editor_user_id": "3060",
"owner_user_id": "35156",
"post_type": "question",
"score": 0,
"tags": [
"python",
"keras"
],
"title": "Kerasによる転移学習プログラムの実行時、\"OSError: Unable to open file\" エラーになってしまう",
"view_count": 2940
} | [
{
"body": "`param_vgg.hdf5`というファイルを開こうとして、`No such file or\ndirectory`(そんなファイルは無い)というエラーが出ています。なので、`param_vgg.hdf5`というファイルが存在するかを確認して下さい。\n\n事前に学習したパラメーター(モデルの重み)を`param_vgg.hdf5`というファイルに保存しておくことが前提で動作するプログラムを実行している、ということではないですかね?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T01:18:30.630",
"id": "59427",
"last_activity_date": "2019-10-03T01:18:30.630",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "59426",
"post_type": "answer",
"score": 2
}
] | 59426 | 59427 | 59427 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Paltte上にTextBoxとCombobox、DataGridViewを配置して情報入力用パレットを作成しました。 \nComboboxでは、文字列を選択してCtrl+C、Ctrl+Vで文字列のコピペができるのですが、TextBoxとDataGridViewのセルでは図面内のエンティティへの操作となってしまいます。 \nComboboxと同様に文字列のコピペを有効にする方法をご教示いただけると助かります。 \nどうぞよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T05:59:33.743",
"favorite_count": 0,
"id": "59429",
"last_activity_date": "2019-11-15T14:11:10.310",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "31055",
"post_type": "question",
"score": 0,
"tags": [
".net",
"ijcad"
],
"title": "パレットのテキストボックスのコピペができない",
"view_count": 107
} | [
{
"body": "現在リリースされている最新のIJCADでは、問題なくTextBoxやDataGridViewのセルの内容をCtrl+Cでコピーできましたので、使用しているIJCADが古いバージョンであればアップグレードしてみてはどうでしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T01:08:13.220",
"id": "59518",
"last_activity_date": "2019-10-07T01:08:13.220",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "59429",
"post_type": "answer",
"score": 0
}
] | 59429 | null | 59518 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n fiscalYear is not defined at Object.<anonymous>\n \n```\n\nというエラーが出てしまいます。このエラーからfiscalYearが読み取れてないと思いました。JSが動いているかconsole.log(\"123\");`で試してみたのですが、出力されないじょうたいです。下記に記載しましたJSの2つをつなげたいのですが、なぜ連動させられないのかがわかりません。教えていただきたいです。m(__)m\n\n## Javascript\n\n```\n\n $(function(){\n $('input[name=\"fiscal_year\"]').on('change',function(){\n $('select[name=\"selectyearMonth\"] option').remove();\n $('select[name=\"selectyearMonth\"]').append($(\"<option></option>\"));\n if($(this).val() != \"\"){ \n for(i=4;i<=15;i++){\n let m = (i<13)?i:(i-12);\n m =('0' + m).slice(-2);\n let y = (i<13)?$(this).val():parseInt($(this).val())+1;\n let op =$(\"<option></option>\",{\n value:y+m,\n html:y+\"年\"+m+\"月\"\n });\n $('select[name=\"selectyearMonth\"]').append(op);\n }\n }\n });\n });\n \n \n function setSelect(){ console.log(\"123\");\n var selectElement = document.getElementById(\"setSelect\");\n for(var i = 1; i <= 12; i ++){\n var option = document.createElement(\"option\");\n option.value = i;\n option.innerText = i;\n selectElement.appendChild(option);\n }\n }\n \n```\n\n## html\n\n```\n\n <tr>\n <th>年度 / 年月</th>\n <td>\n <input name=\"fiscal_year\" maxlength='4'> 年 \n <select name=\"selectyearMonth\" style=\"width: 40%;\" id=\"setSelect\"></select> 月\n <script th:src=\"@{/js/year.js}\"></script>\n </td>\n \n```",
"comment_count": 13,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T06:35:37.130",
"favorite_count": 0,
"id": "59430",
"last_activity_date": "2019-11-14T12:01:55.253",
"last_edit_date": "2019-10-11T07:58:34.620",
"last_editor_user_id": "19110",
"owner_user_id": "35696",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"thymeleaf"
],
"title": "Javascriptが動かない理由がわかりません",
"view_count": 945
} | [
{
"body": "[Javascriptが呼ばれない理由がわからない](https://ja.stackoverflow.com/questions/59020/javascript%E3%81%8C%E5%91%BC%E3%81%B0%E3%82%8C%E3%81%AA%E3%81%84%E7%90%86%E7%94%B1%E3%81%8C%E3%82%8F%E3%81%8B%E3%82%89%E3%81%AA%E3%81%84/)\n\n↑の記載に、さらに典型的なjsの呼び出し方を追記しました。参考ください。 \nJavascriptとjQueryの文法を理解するのが、遠回りに見えて一番近道だと思います。\n\nサンプル1、htmlの準備ができた時、1回だけ呼ばれる処理を書く書き方。\n\n```\n\n window.onload = () => {\n // ...\n };\n \n // jQueryを利用しているなら、細かい差異はありますが、下記でもほぼ同じ意味になります。\n // ※ $()な部分は、jQueryの文法になります。\n $(function(){\n // ...\n }\n );\n \n```\n\nサンプル2、buttonを押したときに、対応するfunctionを呼び出す際の書き方です。\n\n```\n\n <input type=\"button\" value=\"4月\" onclick=\"selectSlcMonth(4)\">\n \n```\n\n以下典型サンプル\n\n```\n\n <html>\n \n <head>\n </head>\n \n <body>\n <form method=\"POST\">\n <select name=\"slcMonth\" style=\"width: 40%;\" id=\"slcMonth\"></select>\n <input type=\"button\" value=\"4月\" onclick=\"selectSlcMonth(4)\">\n <input type=\"button\" value=\"5月\" onclick=\"selectSlcMonth(5)\">\n </form>\n <script>\n // ES2015\n window.onload = () => {\n initializeSlcMonth();\n };\n \n function initializeSlcMonth() {\n const selectElement = document.getElementById(\"slcMonth\");\n for (let i = 1; i <= 12; i ++) {\n const option = document.createElement(\"option\");\n option.value = i;\n option.innerText = i + \"月\";\n selectElement.appendChild(option);\n }\n }\n \n function selectSlcMonth(valMonth) {\n const selectElement = document.getElementById(\"slcMonth\");\n selectElement.value = valMonth;\n }\n </script>\n </body>\n \n```\n\n※ 別件補足 name属性とvalue属性、class属性、id属性について\n\nname属性とvalue属性は、 \ninputやselectに使いSubmitすると、サーバーにその内容が送信されます。\n\nclass属性は、 \ncssに対して使用するのが強く推奨されます。 \nまた、一部のjavascriptに対しても使用してもよいです。\n\nid属性は、 \njavascriptに対してのみ使用するのが強く推奨されます。 \n(cssに対しては利用するのは現代では非推奨。)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T09:35:38.353",
"id": "59432",
"last_activity_date": "2019-10-03T09:55:48.577",
"last_edit_date": "2019-10-03T09:55:48.577",
"last_editor_user_id": "25396",
"owner_user_id": "25396",
"parent_id": "59430",
"post_type": "answer",
"score": 1
}
] | 59430 | null | 59432 |
{
"accepted_answer_id": "61897",
"answer_count": 2,
"body": "Docker使い始めの者です。 \ndocker create --name wow centos \nを用いてwowという名前のコンテナを作りそこに接続(?)しようとしたところ、execもattachもできずに困っています。\n\n```\n\n $ docker images\n REPOSITORY TAG IMAGE ID CREATED SIZE\n centos latest 0f3e07c0138f 33 hours ago 220MB\n nginx latest f949e7d76d63 8 days ago 126MB\n \n $ docker ps\n CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n \n $ docker ps -a\n CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n 4c8c97fd5dc1 centos \"/bin/bash\" About a minute ago Exited (0) About a minute ago wow\n \n $ docker start wow\n wow\n \n $ docker ps\n CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\n \n $ docker exec -it wow /bin/bash\n Error response from daemon: Container 4c8c97fd5dc1f98033d71063de8dfb27755f779433af39f00b9ded1c9a7d655a is not running\n \n $ docker attach wow\n You cannot attach to a stopped container, start it first\n \n```\n\nコマンドが違うのでしょうか、そもそもstartでちゃんとコンテナが立ち上がっていないようなのです。\n\n環境は \nOS:macOS Mojave 10.14.6 \nDocker: 2.1.0.3",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T09:01:13.543",
"favorite_count": 0,
"id": "59431",
"last_activity_date": "2020-02-09T11:03:10.423",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "16877",
"post_type": "question",
"score": 1,
"tags": [
"docker",
"docker-for-mac"
],
"title": "Dockerのコンテナが立ち上がらない",
"view_count": 6393
} | [
{
"body": "根本的な解決には繋がりませんでしたが、こうなってしまうのを避ける道はありました。 \n`docker run` \nを用いれば起動状態でコンテナ作成されますので \nそうすれば一度抜けた後も特に問題なく入ることができました。\n\n……よくわかりません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-30T14:53:47.183",
"id": "61897",
"last_activity_date": "2019-12-30T14:53:47.183",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "16877",
"parent_id": "59431",
"post_type": "answer",
"score": 0
},
{
"body": "システムコールのトレースを取ると原因がわかるかもしれません。 \n※あるはずの設定ファイルがなくてopenに失敗しているなど \nLinux系では`strace`、solarisでは`truss`を使います。\n\nMacOSでトレースを取ったことはありませんが、次のページを見つけました。 \n[MacOSXでstraceが欲しいけどdtrace意味わからん→dtruss使おう](https://qiita.com/hnw/items/269f8eb44614556bd6bf) \n[macOS\nでシステムコールトレースを取得する](https://yohei-a.hatenablog.jp/entry/20171206/1512579504)\n\nこれらの記事によれば`dtruss`でコマンドを起動すると`strace`相当のことができるようです。\n\n```\n\n sudo dtruss -f sudo -u $(id -u -n) docker attach wow\n \n```\n\n実行前に`man dtrace`で使い方を調べた方がいいです。 \n大量のトレースログが出るので注意してください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-12-30T22:29:18.733",
"id": "61900",
"last_activity_date": "2019-12-30T22:29:18.733",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35558",
"parent_id": "59431",
"post_type": "answer",
"score": 0
}
] | 59431 | 61897 | 61897 |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "C言語のプログラムをOS無しでブートすることは可能ですか? \n英語版で似てる質問がありますが別人です。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T11:43:32.953",
"favorite_count": 0,
"id": "59433",
"last_activity_date": "2019-10-04T03:44:01.903",
"last_edit_date": "2019-10-03T11:49:50.663",
"last_editor_user_id": "32986",
"owner_user_id": "36054",
"post_type": "question",
"score": 1,
"tags": [
"c"
],
"title": "C言語のプログラムをOS無しでブートすることは可能ですか?",
"view_count": 1192
} | [
{
"body": "組み込み向けのCPUではそれが普通です。 \nPCでやろうとするなら、初期化部分を自分で書くなりすれば可能でしょう\n\nまあ、そのコードをどうやってメモリ上に展開するのか、というのをまず考える必要がありますが",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T23:51:00.620",
"id": "59441",
"last_activity_date": "2019-10-03T23:51:00.620",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27481",
"parent_id": "59433",
"post_type": "answer",
"score": 0
},
{
"body": "[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") 言語規格書は [c](/questions/tagged/c\n\"'c' のタグが付いた質問を表示\") によって OS 自体を記述することを想定しています。 OS を記述するような状況のことを\n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") 言語規格書は「フリースタンディング環境」と呼んでいます。その意味で\nOS が起動する= [c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") で書いたプログラムが起動するってことですね。\n\nいわゆる「組み込み系」つまり家電製品など、ワンチップマイコンの開発においてはマイコン用コンパイラがマイコンの専用機能に対応しており、リセット解除直後処理(のことを、組み込み業界ではブート処理と呼びます)や割り込み処理などをすべて\n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\")\nだけで書くことが可能になっています。もちろん、アセンブラが無いと書けない超特殊な処理ってのもいまだにありますが、まあブート処理だけなら\n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") だけで書けます。オイラ自身が経験者として保証します。\n\nいわゆる Windows パソコンの BIOS/UEFI のリセット解除直後処理であればおそらく 99% は [c](/questions/tagged/c\n\"'c' のタグが付いた質問を表示\") で記述することができると思います。新しい CPU\nがガンガン開発され新しい機能が増えまくっている関係で、初期化処理には [c](/questions/tagged/c \"'c' のタグが付いた質問を表示\")\nコンパイラがまだ対応していない機能を使う必要があったりするので、どうしても残り 1% にはアセンブラが必須と考えていいでしょう。\n\n* * *\n\n質問が `printf()` 関数などごく普通の「ホスト環境」で動かす予定のプログラムを OS\nなしで動かしたいということなら、現代的答えは「無理」というか「無意味」。まあ OS\nを含めて自作すれば話は別っすけど、一般人が試みるにはコスト高すぎでしょう。\n\nまあ世の中には(ワンチップマイコン向けでない)パソコン向けの OS を自作したいって人もいますので、興味があれば検索してみてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T23:59:23.430",
"id": "59442",
"last_activity_date": "2019-10-04T01:24:59.833",
"last_edit_date": "2019-10-04T01:24:59.833",
"last_editor_user_id": "8589",
"owner_user_id": "8589",
"parent_id": "59433",
"post_type": "answer",
"score": 7
},
{
"body": "組み込みソフトの場合、WDTクリアをわざと止めて、CPUリセットをおこさせることもよくあります。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T03:44:01.903",
"id": "59450",
"last_activity_date": "2019-10-04T03:44:01.903",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24490",
"parent_id": "59433",
"post_type": "answer",
"score": -4
}
] | 59433 | null | 59442 |
{
"accepted_answer_id": "59447",
"answer_count": 3,
"body": "大変お世話になっております。どうかご教授頂けませんでしょうか。\n\n以下の様なphpのページ(site_a.php)がございます。このページは他のページから遷移され、そしてphpの処理をして約5秒後に他のページに自動で遷移していきます。\n\nその約五秒の間、白の画面が表示されるのですが、javascriptのローディングの機能を自動発火する様に実装したいと考え、その下にある記述を追加いたしました。\n\nしかしながら、機能しておりません。以前と同様に白の画面が表示され、約5秒後に次のページに遷移していきます。loadingのjavascript、あるいはそのための自動発火が機能していない様です。\n\nこのphpページでjavascriptのローディングがどうすれば機能するかお教え願いませんでしょうか?\n\n尚、同様のローディングの機能はhtmlのページでは手動クリックの後に機能しております。\n\n* * *\n\n * site_a.php\n\n```\n\n <?php\n \n // phpのコーディング\n \n ?>\n \n <form action='xxxxxx.php' METHOD='POST'>\n <input type=\"submit\" id=\"submit\" value=\"\" style=\"display:none;\"/> \n </form>\n \n <script>\n document.getElementById(\"submit\").click();\n </script> \n \n```\n\n * 上記の記述(site_a.php)にjavascriptのローディングの機能を自動発火する様な設定で追加。\n\n```\n\n <html>\n <head>\n <body id=\"loading\">\n </body>\n </head> \n </html>\n \n <script> \n \n $(function () {\n $(\"#loading\").click( function() {\n \n // 処理前に Loading 画像を表示\n dispLoading(\"処理中...\");\n \n });\n });\n \n \n function dispLoading(msg){\n // 引数なし(メッセージなし)を許容\n if( msg == undefined ){\n msg = \"\";\n }\n // 画面表示メッセージ\n var dispMsg = \"<div class='loadingMsg' style='color:blue; padding:10px; \n text-align:center'>\" + msg + \"</div>\";\n // ローディング画像が表示されていない場合のみ出力\n if($(\"#loading\").length == 0){\n $(\"body\").append(\"<div id='loading' style='color:blue; padding:10px; \n text-align:center'>\" + dispMsg + \"</div>\");\n }\n }\n \n \n \n /* ------------------------------\n Loading イメージ削除関数\n ------------------------------ */\n function removeLoading(){\n $(\"#loading\").remove();\n }\n \n \n }\n \n </script>\n \n <script>\n document.getElementById(\"loading\").click();\n </script>\n \n <?php\n \n // phpのコーディング\n \n ?>\n \n <form action='xxxxxx.php' METHOD='POST'>\n <input type=\"submit\" id=\"submit\" value=\"\" style=\"display:none;\"/> \n </form>\n \n <script>\n document.getElementById(\"submit\").click();\n </script> \n \n```\n\n * css\n\n```\n\n #loading {\n display: table;\n width: 100%;\n height: 100%;\n position: fixed;\n top: 0;\n left: 0;\n background-color: #fff;\n opacity: 0.8;\n }\n \n #loading .loadingMsg {\n display: table-cell;\n text-align: center;\n vertical-align: middle;\n padding-top: 140px;\n background: url(\"[LoadingイメージのURL]\") center center no-repeat;\n }\n \n```",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T15:02:26.073",
"favorite_count": 0,
"id": "59436",
"last_activity_date": "2019-10-10T09:15:18.077",
"last_edit_date": "2019-10-10T09:15:18.077",
"last_editor_user_id": "3475",
"owner_user_id": "19211",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"php"
],
"title": "遅いphpコード実行時に、処理中である旨をページ内に表示したい",
"view_count": 5415
} | [
{
"body": "疑問1 \n「document.getElementById(\"loading\").click();」は、「id=\"loading\"」のついているDOMを読むはずだがHTMLには存在しない。\n\n疑問2 \nHTML中に書かれているPHPコードは今回5秒かかる処理のコードではない?(なら質問上で不要では?) \nAjaxで通信している先のPHPが5秒処理がかかるという認識?\n\n疑問3 \n「dispLoading」という関数が呼び出されているが、その関数はどこ? \n表示されない原因がそもそも関数にある可能性もあるのでは?\n\n疑問4 \n同じく不明な関数「showMsg」「removeLoading」も同上。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T02:09:23.243",
"id": "59446",
"last_activity_date": "2019-10-04T02:09:23.243",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36063",
"parent_id": "59436",
"post_type": "answer",
"score": 1
},
{
"body": "ajaxでサーバに処理を依頼し処理結果を待ってからページ遷移すれば良いと思うのですが。\n\n通常は、phpの処理が完了しないと画面が表示されません。(処理が完了するまで **HTML**\nが出力されません)先にhtmlなどのデータを出力為には、phpで[出力バッファリング制御](https://www.php.net/manual/ja/book.outcontrol.php)を行います。 \n以下にサンプルコードを\n\n```\n\n <?php\n //header()などの初期処理を行う。\n ?>\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <title>こんにちは!</title>\n </head>\n <body>\n こんにちは!しばらくお待ちください。\n </body>\n <?php\n $gonext = <<<eot\n <script type=\"text/javascript\"> window.location.href='https://ja.stackoverflow.com/';\n </script>\n eot;\n echo str_pad(\" \",4096);//ブラウザでバッファーリングされて直ぐに表示されない時は空白などを出力する。\n ob_end_flush();\n ob_start('mb_output_handler');\n ob_flush();\n flush();\n //サーバでそれなりの処理を行う。\n \n sleep( 5 ); // 時間がかかる処理1\n echo $gonext;\n ob_flush();\n flush();\n ?>\n </html>\n \n```\n\n追記、phpから、htmlの任意の場所でjavascriptを実行させるには、javascriptを実行させたい場所にscriptタグで囲み出力することで、javascriptを実行させる事が出来ます。 \nサンプルコードを 時間のかかる処理(sleepを入れています。)後、ページ遷移するように修正してみました。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T02:26:49.513",
"id": "59447",
"last_activity_date": "2019-10-08T10:02:12.777",
"last_edit_date": "2019-10-08T10:02:12.777",
"last_editor_user_id": "22793",
"owner_user_id": "22793",
"parent_id": "59436",
"post_type": "answer",
"score": 2
},
{
"body": "サーバ側の処理とクライアント側の処理を混同してると思うのだがどうだろうか? \nサーバ側の処理が完了しドキュメントを生成するまではクライアント側へドキュメントは送信されない。 \nまずはどの処理がどこで発生していてどのような流れでウェブページが表示されるのかを勉強した方が良い。既に回答にもある通りAjaxを利用して非同期通信を行うことが望ましいが、以上を前提として且つ処理中にドキュメントを送信する方法を模索しているのであれば以下の方法がある。\n\n```\n\n <?php\n //処理直前までバッファ出力\n echo <<<EOB\n <html>\n <head>\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js\"></script>\n </head>\n <body>\n <div id='loading' style='color:blue; padding:10px;text-align:center'>\n <div class='loadingMsg' style='color:blue; padding:10px;text-align:center'>処理中...</div>\n </div>\n EOB;\n //送信させるためにバッファを溜める。\n //バッファが溜まっていないと出力されない。\n echo str_repeat( ' ', 1024 );\n //バッファを送信する。\n @ob_flush();\n @flush();\n \n //何かしらの処理\n \n ?>\n <script type=\"text/javascript\">\n $(\"#loading\").remove();\n </script>\n </body>\n </html>\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-10T06:59:39.440",
"id": "59615",
"last_activity_date": "2019-10-10T06:59:39.440",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36159",
"parent_id": "59436",
"post_type": "answer",
"score": 1
}
] | 59436 | 59447 | 59447 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "正規表現でn回目のハイフンとマッチさせたいです。 \n例えば下記のURLの左から二回目のハイフンから右`-fdfd-fd`とマッチし削除する正規表現を知りたいです。\n\n一回目からマッチさせるなら`-.*`なのですが。\n\n<https://www.example.com/a-12345-fdfd-fd>",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-03T23:39:15.543",
"favorite_count": 0,
"id": "59440",
"last_activity_date": "2019-10-04T00:21:26.143",
"last_edit_date": "2019-10-03T23:58:39.477",
"last_editor_user_id": "2238",
"owner_user_id": "32946",
"post_type": "question",
"score": 0,
"tags": [
"正規表現"
],
"title": "n回目のハイフンとマッチさせたい",
"view_count": 2424
} | [
{
"body": "2回目にマッチさせる正規表現の例です\n\n```\n\n ^[^-]*-[^-]*-\n \n```\n\n2回目から右の削除はperlならこれでいけます\n\n```\n\n s/^([^-]*-[^-]*)-.+$/\\1/\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T00:09:47.520",
"id": "59443",
"last_activity_date": "2019-10-04T00:21:26.143",
"last_edit_date": "2019-10-04T00:21:26.143",
"last_editor_user_id": "2238",
"owner_user_id": "36059",
"parent_id": "59440",
"post_type": "answer",
"score": 2
}
] | 59440 | null | 59443 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Arduino IDE 1.8.9 + Spresense(1.4)の環境で、 \nSDHCI >>> read_write.inoは、SDに正常に書き込みできるのに、 \nCamera >>> camera.inoは、\"Insert SD card!\" になる。 \nboard_sdcard_enable: ERROR: Failed to mount the SDCARD. 5 \n上のエラーは何を示していますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T03:09:07.573",
"favorite_count": 0,
"id": "59448",
"last_activity_date": "2019-10-04T06:24:31.670",
"last_edit_date": "2019-10-04T06:15:12.393",
"last_editor_user_id": "36064",
"owner_user_id": "36064",
"post_type": "question",
"score": 0,
"tags": [
"spresense"
],
"title": "camera.inoがinsert SD!になってしまう。",
"view_count": 84
} | [
{
"body": "SDカードの接触不良でした。カード面を布で擦って何度かやり直してみたら動きました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T06:24:31.670",
"id": "59453",
"last_activity_date": "2019-10-04T06:24:31.670",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36064",
"parent_id": "59448",
"post_type": "answer",
"score": 0
}
] | 59448 | null | 59453 |
{
"accepted_answer_id": "59483",
"answer_count": 1,
"body": "ttk.Comboboxでいったん選択された後に、条件によって未選択状態にしたいと思います。 \nselection_clear()メソッドでは、未選択状態になりません。 \ncurrent(-1)では、out of rangeとなってしまいます。\n\n未選択状態に戻すにはどうすればよいでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T04:12:52.200",
"favorite_count": 0,
"id": "59451",
"last_activity_date": "2019-10-05T12:46:38.053",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "32891",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"tkinter"
],
"title": "Python ttk.Combobox いったん選択した後、未選択状態にしたい。",
"view_count": 1820
} | [
{
"body": "`selection_clear()`と`set('')`(空文字列設定)の両方を行えば、初期の状態になるのでは?\n\n[How to control the tkinter combobox selection\nhighlighting](https://stackoverflow.com/q/5235998/9014308)\n\n> You can use the Combobox's selection_clear() method to clear the selection\n> whenever you want. e.g\n```\n\n> inUnitsValue.selection_clear()\n> \n```\n\n[How to clear text field part of\nttk.Combobox?](https://stackoverflow.com/q/35233043/9014308)\n\n> You can clear the selected value of a Combobox by setting its value to an\n> empty string:\n```\n\n> ComboBox.set('')\n> \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T12:46:38.053",
"id": "59483",
"last_activity_date": "2019-10-05T12:46:38.053",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "26370",
"parent_id": "59451",
"post_type": "answer",
"score": 1
}
] | 59451 | 59483 | 59483 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "camera.inoでは、JPGをキャプチャする例が示されています。 \nところで、動画を撮ることは可能なのでしょうか? \nその際、音も録音することは可能なのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T06:57:40.857",
"favorite_count": 0,
"id": "59454",
"last_activity_date": "2020-01-11T01:50:28.987",
"last_edit_date": "2019-10-06T15:35:11.077",
"last_editor_user_id": "3060",
"owner_user_id": "36064",
"post_type": "question",
"score": 0,
"tags": [
"spresense",
"arduino"
],
"title": "Spresenseで動画を撮りたい",
"view_count": 607
} | [
{
"body": "ちょうど少し前にAVIで動画を撮るスケッチを書いてみました。8fps程度しかできていませんが、Spresense の Arduino Camera\nライブラリに手を入れればもう少しfps を出すことが可能かもしれません。残念ながら、このスケッチは音には対応していません。\n\n```\n\n #include <Camera.h>\n #include <SDHCI.h>\n #include <stdio.h>\n #include <math.h>\n \n SDClass theSD;\n \n /* WIDTH == 1280 (0x500) */\n #define WIDTH_1 0x00\n #define WIDTH_2 0x05\n /* HEIGHT == 960 (0x3C0) */\n #define HEIGHT_1 0xC0\n #define HEIGHT_2 0x03\n #define TOTAL_FRAMES 300\n #define AVIOFFSET 240\n \n unsigned long movi_size = 0;\n const char avi_header[AVIOFFSET+1] = {\n 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, \n 0x53, 0x54, 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, \n 0x38, 0x00, 0x00, 0x00, 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, \n 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, WIDTH_1, WIDTH_2, 0x00, 0x00, \n HEIGHT_1, HEIGHT_2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, \n 0x00, 0x00, 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, \n 0x76, 0x69, 0x64, 0x73, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, \n 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, 0x28, 0x00, 0x00, 0x00, \n 0x28, 0x00, 0x00, 0x00, WIDTH_1, WIDTH_2, 0x00, 0x00, HEIGHT_1, HEIGHT_2, \n 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, \n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \n 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, \n 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, \n 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, 0x00\n };\n \n File aviFile;\n String filename = \"movie.avi\";\n uint32_t start_ms = 0;\n \n static void inline uint32_write_to_aviFile(uint32_t v) { \n char value = v % 0x100;\n aviFile.write(value); v = v >> 8; \n value = v % 0x100;\n aviFile.write(value); v = v >> 8;\n value = v % 0x100;\n aviFile.write(value); v = v >> 8; \n value = v;\n aviFile.write(value);\n }\n \n \n void setup() {\n Serial.begin(115200);\n \n theCamera.begin();\n theSD.begin();\n \n theSD.remove(filename);\n aviFile = theSD.open(filename ,FILE_WRITE);\n aviFile.write(avi_header, AVIOFFSET);\n \n Serial.println(\"Recording...\");\n \n theCamera.setStillPictureImageFormat(\n CAM_IMGSIZE_QUADVGA_H,\n CAM_IMGSIZE_QUADVGA_V,\n CAM_IMAGE_PIX_FMT_JPG);\n \n start_ms = millis();\n digitalWrite(LED0 ,HIGH);\n }\n \n int loopCounter = 0;\n void loop() {\n \n CamImage img = theCamera.takePicture();\n if (!img.isAvailable()) {\n Serial.println(\"faile to take a picture\");\n return;\n }\n \n aviFile.write(\"00dc\", 4);\n uint32_t chunk_top = aviFile.position();\n \n uint32_t jpeg_size = img.getImgSize();\n uint32_write_to_aviFile(jpeg_size);\n \n aviFile.write(img.getImgBuff() ,jpeg_size);\n movi_size += jpeg_size;\n \n /* Spresense's jpg file is assumed to be 16bits aligned \n * So, there's no padding operation */\n \n if (++loopCounter == TOTAL_FRAMES) {\n float duration_sec = (millis() - start_ms) / 1000.0f;\n float fps_in_float = loopCounter / duration_sec;\n float us_per_frame_in_float = 1000000.0f / fps_in_float;\n uint32_t fps = round(fps_in_float);\n uint32_t us_per_frame = round(us_per_frame_in_float);\n \n /* overwrite riff file size */\n aviFile.seek(0x04);\n uint32_t total_size = movi_size + 12*loopCounter + 4;\n uint32_write_to_aviFile(total_size);\n \n /* overwrite hdrl */\n /* hdrl.avih.us_per_frame */\n aviFile.seek(0x20);\n uint32_write_to_aviFile(us_per_frame);\n uint32_t max_bytes_per_sec = movi_size * fps / loopCounter;\n aviFile.seek(0x24);\n uint32_write_to_aviFile(max_bytes_per_sec);\n \n /* hdrl.avih.tot_frames */\n aviFile.seek(0x30);\n uint32_write_to_aviFile(loopCounter);\n aviFile.seek(0x84);\n uint32_write_to_aviFile(fps); \n \n /* hdrl.strl.list_odml.frames */\n aviFile.seek(0xe0);\n uint32_write_to_aviFile(loopCounter);\n aviFile.seek(0xe8);\n uint32_write_to_aviFile(movi_size);\n \n aviFile.close();\n \n Serial.println(\"Movie saved\");\n Serial.println(\" File size (kB): \" + String(total_size));\n Serial.println(\" Captured Frame: \" + String(loopCounter)); \n Serial.println(\" Duration (sec): \" + String(duration_sec));\n Serial.println(\" Frame per sec : \" + String(fps));\n Serial.println(\" Max data rate : \" + String(max_bytes_per_sec));\n \n digitalWrite(LED0, LOW);\n while(1);\n \n }\n }\n \n```\n\n撮れた動画の様子などについては、次のブログで見ることができます。ご参考になれば。\n\nSPRESENSE で AVI の動画をサポートしてみた! \n<https://makers-with-myson.blog.ss-blog.jp/2019-09-30>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T21:26:43.357",
"id": "59494",
"last_activity_date": "2019-10-06T08:02:25.863",
"last_edit_date": "2019-10-06T08:02:25.863",
"last_editor_user_id": "27334",
"owner_user_id": "27334",
"parent_id": "59454",
"post_type": "answer",
"score": 3
},
{
"body": "動きましたー! \nSDカードをClass10にすると10Fpsで撮影することができました!\n\n10:44:03.738 -> Recording... \n10:44:32.998 -> Movie saved \n10:44:32.998 -> File size (kB): 32472884 \n10:44:32.998 -> Captured Frame: 300 \n10:44:32.998 -> Duration (sec): 29.24 \n10:44:33.032 -> Frame per sec : 10 \n10:44:33.032 -> Max data rate : 1082309",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2020-01-11T01:50:28.987",
"id": "62151",
"last_activity_date": "2020-01-11T01:50:28.987",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36064",
"parent_id": "59454",
"post_type": "answer",
"score": 2
}
] | 59454 | null | 59494 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "ネットのソースコードを参考にSPRESENSEでジャンケンの手を認識できる機能を実装しています。\n\nLCDの表示について、カメラの画像をリアルタイムでLCDに表示する処理は正しく動作するのですが、そのソースコードでdnnrt.bigin()にてNNCで生成したモデルを読み込むとLCDが動きません。モデルは開いただけでNGでした。モデルが存在しない、開けないといった症状ではなさそうです。\n\n別質問で学習モデルの形式がおかしいとSPRESENSEが動作しなくなるといった書き込みを見ましたがその類でしょうか? \nまたその場合、どのような学習モデルが不適切なのでしょうか?\n\nLCDはILI9341を使用しています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T07:28:35.350",
"favorite_count": 0,
"id": "59455",
"last_activity_date": "2020-08-09T12:01:20.393",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36069",
"post_type": "question",
"score": 0,
"tags": [
"spresense"
],
"title": "SPRESENSE dnnrt.bigin()を実行するとLCDが表示できなくなる",
"view_count": 239
} | [
{
"body": "最近、私がはまったのはブートローダとSDKの不一致です。ブートローダを最新のもの(1.4.0?)にアップデートされてみてはいかがでしょうか?",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T21:32:45.707",
"id": "59495",
"last_activity_date": "2019-10-05T21:32:45.707",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27334",
"parent_id": "59455",
"post_type": "answer",
"score": 0
}
] | 59455 | null | 59495 |
{
"accepted_answer_id": "59465",
"answer_count": 4,
"body": "```\n\n 入力される値\n 2\n 2 5\n 3 4\n \n 期待する出力\n hello = 2 , world = 5 \n hello = 3 , world = 4\n \n```\n\nの場合のコードは、\n\n```\n\n #include <stdio.h>\n int main(void){\n int i, n;\n char buf[1000];\n char token1[100], token2[100];\n \n fgets(buf, sizeof(buf), stdin);\n sscanf(buf, \"%d\\n\", &n);\n for (i=0; i<n; i++) {\n fgets(buf, sizeof(buf), stdin);\n sscanf(buf, \"%s %s\\n\", token1, token2);\n printf(\"hello = %s , world = %s\\n\" ,token1 ,token2);\n }\n return 0;\n }\n \n```\n\nこのように、決まったフォーマットのデータを読み込む際はsscanfとfgetsを組み合わせると、上手くいきますが、 \n入力されるフォーマットが以下のように不規則の場合、sscanfとfgetsを組み合わせてファイルを読み込むことはできるのでしょうか?(全てint型)\n\n```\n\n 入力フォーマット \n M N \n c_1 \n c_2 \n ... \n c_M\n a_{1,1} a_{1,2} ... a_{1,M} \n a_{2,1} a_{2,2} ... a_{2,M} \n ... \n a_{N,1} a_{N,2} ... a_{N,M}\n \n 入力例1\n 3 3\n 250\n 500\n 1000\n 100 200 300\n 30 250 0\n 1 1 1000\n \n 入力例2\n 5 1\n 123\n 456\n 789\n 111\n 220\n 10 10 10 10 10\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T07:40:42.580",
"favorite_count": 0,
"id": "59456",
"last_activity_date": "2019-10-05T08:57:56.237",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34550",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "C言語でファイル読み込みの方法",
"view_count": 313
} | [
{
"body": "一般的には、1行のデータを読み込んで、頭から1文字ずつチェックし、それが数字かスペースか、CR、LFかを判定し、それぞれに適切な処理を行っていくことになると思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T08:07:16.353",
"id": "59459",
"last_activity_date": "2019-10-04T08:07:16.353",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24490",
"parent_id": "59456",
"post_type": "answer",
"score": 0
},
{
"body": "その区切るフォーマットがきちんと定義されているならばどうとでもなります \n#sscanf を使うかどうかは別の話として",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T08:08:58.957",
"id": "59460",
"last_activity_date": "2019-10-04T08:08:58.957",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27481",
"parent_id": "59456",
"post_type": "answer",
"score": 0
},
{
"body": "横方向のときもscanfが使えます。\n\n```\n\n #include<stdio.h>\n int a[10];\n int main()\n {\n int i, j, n; \n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) scanf(\"%d\", a+i);\n for (j = 0; j < i; j++) printf(\"%d\\n\", a[j]);\n }\n \n```\n\n入力例は、\n\n```\n\n 3\n 1 2 3\n \n```\n\nです。3つ読めました。\n\nsscanfを使うときは、\n\n```\n\n int a[10];\n int main()\n {\n int i, n, len;\n char s[20], t[10], *p = s;\n \n fgets(t, 10, stdin);\n sscanf(t, \"%d\", &n);\n \n fgets(s, 20, stdin);\n for (i = 0; i < n; i++) {\n char s2[5];\n sscanf(p, \"%s\", s2);\n sscanf(s2, \"%d\", a+i);\n len = strlen(s2);\n p+=len+1; // スペース1こ\n }\n for (i = 0; i < n; i++) printf(\"%d\\n\", a[i]);\n }\n \n```\n\nです。 \nsscanfでは、ストリームではなく文字列から読み取るので、自分で読み取り位置を調整する必要があります。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T10:43:55.110",
"id": "59465",
"last_activity_date": "2019-10-04T13:23:16.727",
"last_edit_date": "2019-10-04T13:23:16.727",
"last_editor_user_id": "35281",
"owner_user_id": "35281",
"parent_id": "59456",
"post_type": "answer",
"score": 2
},
{
"body": "rueさんが`sscanf`を使った回答をされていますが、もう少しきれいに書けます。[`scanf`系](https://ja.cppreference.com/w/c/io/fscanf)にはそれまでに読み込んだ文字数を返す`%n`があります。これを使うことで一旦`%s`で切り取り長さを調べる必要がなくなり、直接`%d`で数値を取得できます。\n[wandbox](https://wandbox.org/permlink/nMXnk3hog0wVznRo)\n\n```\n\n #include <stdio.h>\n #include <stdlib.h>\n \n int main() {\n char buffer[256], *p;\n int n, *data;\n fgets(buffer, 256, stdin);\n sscanf(buffer, \"%d\", &n);\n data = calloc(n, sizeof(int));\n fgets(buffer, 256, stdin);\n p = buffer;\n for (int i = 0; i < n; i++) {\n int read;\n sscanf(p, \"%d%n\", data + i, &read);\n p += read;\n }\n for (int i = 0; i < n; i++)\n printf(\"%d\\n\", data[i]);\n free(data);\n return 0;\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T08:57:56.237",
"id": "59479",
"last_activity_date": "2019-10-05T08:57:56.237",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "59456",
"post_type": "answer",
"score": 2
}
] | 59456 | 59465 | 59465 |
{
"accepted_answer_id": "59462",
"answer_count": 1,
"body": "arp-scanで取得したipアドレスに一斉にpingを送る方法を模索しています。\n\n一度ターミナルに出力された結果をテキストファイルに保存し、そこからpingを送ろうとしているのですが、上手くいきません。\n\npython自体知識が全くないので、どのようなプログラムを書けばいいのかわかりません。 \n分かる方がいればお願いします。\n\n下記にarp-scanの一例を記載しておきます。(一部変えています)\n\n```\n\n $ arp-scan -l\n Interface: eth0, datalink type: EN10MB (Ethernet)\n Starting arp-scan 1.4 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/)\n 192.168.0.1 00:11 Dell ESG PCBA Test\n 192.168.0.2 00:12 Intel Corporation\n 192.168.0.3 00:16 Dell Inc.\n 192.168.0.4 00:10 Juniper Networks, Inc.\n 192.168.0.5 00:01 Hewlett-Packard Company\n 192.168.0.6 00:04 Cisco Systems, Inc.\n 192.168.0.7 00:30: HEWLETT-PACKARD\n \n \n```\n\n* * *\n\nipアドレスのみ抽出することは出来たのですが、ここから一括でpingを送る方法を考えています。 \nipアドレスをリスト化? してfor文で送ろうとしてみましたが、知識不足で動きませんでした。\n\n```\n\n import subprocess\n cmd = \"sudo arp-scan -l |grep '192' | awk '{print $1}'\"\n subprocess.call(cmd, shell=True)\n \n```\n\n実行結果\n\n```\n\n 192.168.2.1\n 192.168.2.11\n 192.168.2.12\n 192.168.2.14\n 192.168.2.107\n 192.168.2.108\n 192.168.2.112\n 192.168.2.113\n 192.168.2.203\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T07:52:49.893",
"favorite_count": 0,
"id": "59457",
"last_activity_date": "2019-10-09T02:31:59.060",
"last_edit_date": "2019-10-09T02:31:59.060",
"last_editor_user_id": "19110",
"owner_user_id": "36070",
"post_type": "question",
"score": 1,
"tags": [
"python",
"shellscript"
],
"title": "arp-scanで取得したipアドレスへ一斉にpingを送りたい",
"view_count": 709
} | [
{
"body": "参考までに、[fping](https://raspberry-projects.com/pi/software_utilities/fping)\nコマンドが使える環境なら以下の様なワンライナーで実行できます。\n\n```\n\n $ arp-scan -l | grep '^192' | awk '{ print $1 }' | fping -c 1\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T08:38:47.213",
"id": "59462",
"last_activity_date": "2019-10-04T08:38:47.213",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "59457",
"post_type": "answer",
"score": 1
}
] | 59457 | 59462 | 59462 |
{
"accepted_answer_id": "59469",
"answer_count": 1,
"body": "DBから任意の値を取得して、jsonを動的に生成した後の定数?にアクセスする方法がわかりません。 \nどなたかヒント等いただけますでしょうか \n下記のような実装を考えています。\n\n例えばですが\n\n```\n\n (JQuery)\n \n var json_data = <?php echo $json ?>; // php等でJSONの値を取得\n var json = JSON.parse(json_data); // JSONのデコード\n for( value in list ){ // JSONの個数分ループ(3つの場合3回)\n var index = 0; \n if('〇' == json.index){ // 問題点:アクセスしたいのは現在のループ回数\n console.log(true);\n }\n }\n \n JOSN想定\n { 〇, ×, 〇} //1回目\n { 〇, ×, ×, ×} //2回目(別データ)\n { 〇, ×, 〇, ×, ×, 〇} //3回目(別データ)\n \n```\n\nJSONデータは動的に個数は変更されます。実際に入る値としては「6種類」想定です。 \nループはJSONと同じ数分しか行わないので \n「index」の最大値はJSONの個数と同じになります。\n\nつたない質問で申し訳ないですが、回答よろしくおねがいします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T08:01:52.480",
"favorite_count": 0,
"id": "59458",
"last_activity_date": "2019-10-05T01:12:29.767",
"last_edit_date": "2019-10-04T08:08:03.633",
"last_editor_user_id": "32986",
"owner_user_id": "32098",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery",
"json"
],
"title": "json動的生成とアクセス方法について",
"view_count": 367
} | [
{
"body": "この質問内容だと、要するに「回数」という状態をwebブラウザ側(Jquery側)で持ちたいという質問に見えます。\n\nブラウザは通常、状態は持ちえない(原理上リロードされかねないので)ので、そういう場合は、[Web\nStorage](http://www.htmq.com/webstorage/)などを使うのが一般的だと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T00:55:14.290",
"id": "59469",
"last_activity_date": "2019-10-05T01:12:29.767",
"last_edit_date": "2019-10-05T01:12:29.767",
"last_editor_user_id": "2376",
"owner_user_id": "36077",
"parent_id": "59458",
"post_type": "answer",
"score": 0
}
] | 59458 | 59469 | 59469 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "下記のコードのように日報の各項目のあるテーブルを作成しておりまして、\n\nforeachで各auto_id(各日報毎のid)をtableで一覧で表示しております。\n\nそこでjQueryでlikeButtonというクラスをクリックしたらajaxで非同期で\n\nいいねの数が表示されるという実装を行なっています。\n\njQueryで.load('sales_reportSP.php .like_result');とした時に、\n\n表示される数字がauto_idの1~8の分まですべて表示されてしまいます。 \nリロードすると元に戻りDBにもちゃんと登録されています。\n\n.load() で auto_id などの情報は渡してないので8つ返ってきていますが渡し方がわからない状態です。 \njQuery のコードが動いているのが sales_reportSP.php です。\n\nどなたかご教示いただけますと幸いです。\n\n・バージョン \nPHP 7.1.23 \nmysql 5.6.43\n\n```\n\n <table>\n <tr>\n <th>担当</th>\n <th>訪問日付<br>顧客名</th>\n <th>目的<br>結果</th>\n <th>内容</th>\n </tr>\n <?php if(!empty($salesdata) === true) {\n $i = 0;\n foreach ($salesdata as $value) { ?>\n <tr>\n <form action=\"../history/sales_report_commentSP.php\" method=\"post\">\n <td><?php echo $value['first_name']; ?></td>\n <td>\n <?php\n $salesDate = explode(\"-\", $value['sales_date']);\n echo $salesDate[1] . '/' . $salesDate[2] . '<br><br>'; ?>\n <p class=\"shop_url\">\n <a href=\"<?php echo ROOT_PATH; ?>customer/list/customer_dispSP.php?salesClient_id=<?php echo $value['salesClient_id'] ?>\" class=\"shop_url\"><?php echo $value['shop_name']; ?></a>\n </p>\n </td>\n <td>\n <?php echo $value['progress_purpose_name'] . '<br><span>↓<span><br>' . $value['progress_name']; ?>\n </td>\n <td>\n <p><?php echo $value['sales_history']; ?></p>\n <input type=\"submit\" class=\"comment far\" value=\"\">\n <input type=\"hidden\" name=\"auto_id\" value=\"<?php echo $value['auto_id']; ?>\">\n <input type=\"hidden\" name=\"driver_id\" value=\"<?php echo $value['driver_id']; ?>\">\n <input type=\"hidden\" name=\"first_name\" value=\"<?php echo $value['first_name']; ?>\">\n <input type=\"hidden\" name=\"last_name\" value=\"<?php echo $value['last_name']; ?>\">\n <input type=\"hidden\" name=\"sales_date\" value=\"<?php echo $value['sales_date']; ?>\">\n <input type=\"hidden\" name=\"shop_name\" value=\"<?php echo $value['shop_name']; ?>\">\n <input type=\"hidden\" name=\"progress_purpose_name\" value=\"<?php echo $value['progress_purpose_name']; ?>\">\n <input type=\"hidden\" name=\"progress_name\" value=\"<?php echo $value['progress_name']; ?>\">\n <input type=\"hidden\" name=\"sales_history\" value=\"<?php echo $value['sales_history']; ?>\">\n </form>\n <!-- いいねアイコン -->\n <div class=\"icon_cow\" style=\"margin:0;\">\n <input class=\"likeButton<?php echo $i ?>\" type=\"image\" src=\"<?php echo ROOT_PATH; ?>images/logo.jpg\" onclick=\"\"\n style=\"margin:0; width:24px; height:24px; margin:0; margin-left:3px; border:none;\">\n <input type=\"hidden\" name=\"auto_id\" value=\"<?php echo $value['auto_id']; ?>\">\n <?php foreach($driversId as $id) ?>\n <input type=\"hidden\" name=\"voter_id\" value=\"<?php echo $id; ?>\">\n <input type=\"hidden\" name=\"submitter_id\" value=\"<?php echo $value['driver_id']; ?>\">\n <i class=\"far fa-thumbs-up\"></i>\n <?php\n try {\n $dbh = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD, $options);\n $dbh->query('SET NAMES utf8');\n \n // m_like_masterからauto_idに紐づいたlike_idの数をカウントし取得。 AS counted を引数にしています\n $sql = \"SELECT COUNT(like_id) AS counted FROM m_like_master\n WHERE auto_id= \" . $value['auto_id'];\n \n $stmt = $dbh->prepare($sql);\n $stmt->execute();\n $countResult = $stmt->fetch(PDO::FETCH_ASSOC);\n $current_like_count = $countResult['counted'];\n \n $dbh = null;\n \n } catch (PDOException $e) {\n exit('顧客データベース接続失敗。'.$e->getMessage());\n } ?>\n <!-- いいね数の表示 -->\n <p class=\"like_result\"><?php echo $current_like_count; ?></p>\n <input type=\"hidden\" name=\"auto_id\" value=\"<?php echo $value['auto_id']; ?>\">\n <input class=\"like_num\" type=\"submit\">\n </div>\n </td>\n </tr>\n <?php $i++; } ?>\n </table>\n \n```\n\njQueryは同一のhtml内、body一番下に記載しています。\n\n```\n\n let likeButton = $(\".likeButton<?php echo $i; ?>\");\n \n likeButton.on('click', function(e){\n console.log(e)\n let $_parent = $( this ).closest( '.icon_cow' );\n $.ajax({\n type: 'POST',\n url: \"sales_report_like_done_ajaxPost.php\",\n data: {\n auto_id : $_parent.find(\"input[name=auto_id]\").val(),\n voter_id : $_parent.find(\"input[name=voter_id]\").val(),\n submitter_id : $_parent.find(\"input[name=submitter_id]\").val(), }\n });\n });\n \n likeButton.on('click', function(){\n $('.like_result').load('sales_reportSP.php .like_result');\n });\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T08:23:16.883",
"favorite_count": 0,
"id": "59461",
"last_activity_date": "2019-10-04T08:23:16.883",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36071",
"post_type": "question",
"score": 0,
"tags": [
"php",
"jquery",
"sql"
],
"title": "foreach内での非同期通信での表示結果に関して",
"view_count": 131
} | [] | 59461 | null | null |
{
"accepted_answer_id": "59471",
"answer_count": 3,
"body": "200fps[frame per second]で取得した値を、24fpsにダウンサンプリングしたいです。\n\n24/200=0.12なので\n\n```\n\n 0.12*1=0.12\n .\n .\n .\n 0.12*8=0.96\n 0.12*9=1.08\n \n```\n\nと、0.96から1.08など、小数点以下を切り捨てた値が前後で異なった時に \n前後どちらかのループ回数の時に値を取得すれば良いのではないかと思いました。\n\nつまり\n\n```\n\n if not int((loop_count)*(low_fps/high_fps)) == int((loop_count+1)*(low_fps/high_fps)) \n \n```\n\nとなれば良いのではと思い、以下のように200回forループを回してprintをしてみたのですが \nなぜか値が25回出力されてしまいます。(本当は24回出力されるのが正しいはず?)\n\n```\n\n loop_count=1\n high_fps=200\n low_fps=24\n for num in range(200):\n if loop_count == 1 or not int((loop_count)*(low_fps/high_fps)) == int((loop_count+1)*(low_fps/high_fps)) :\n print(loop_count)\n \n loop_count=loop_count+1\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T09:33:36.830",
"favorite_count": 0,
"id": "59463",
"last_activity_date": "2019-10-05T06:30:08.943",
"last_edit_date": "2019-10-05T06:30:08.943",
"last_editor_user_id": "3060",
"owner_user_id": "34471",
"post_type": "question",
"score": 0,
"tags": [
"python",
"数学"
],
"title": "200回/1秒の頻度で取得した値を、24回/1秒の頻度のデータに落とすダウンサンプリングをするには",
"view_count": 740
} | [
{
"body": "専門家ではないのですが、追加されている条件loop_count==1が悪さをしているのかな、と思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-04T10:21:28.010",
"id": "59464",
"last_activity_date": "2019-10-04T10:21:28.010",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35281",
"parent_id": "59463",
"post_type": "answer",
"score": 0
},
{
"body": "2000 : 24\nのような大きな比でのダウンサンプリングであれば、線形補間など考慮する必要がありませんし、基本的な考え方はあなたのやり方であっているように思うのですが、浮動小数点を含む計算や切り捨てが絡んでくると話がややこしくなってきて、どこで差の1が出てくるのか検証するのは大変そうです。\n\n例えば、以下のようにしてみてはどうでしょうか。\n\n```\n\n high_fps=200\n low_fps=24\n # 時間を測る単位\n pitch = high_fps * low_fps\n last_sample_number = -1\n for num in range(200):\n # `num`は`high_fps`でのサンプル番号を表している\n # それを`period`単位での時間に変換する\n time_in_period = num * pitch/high_fps\n # 時間を`low_fps`でのサンプル番号に変換する\n sample_number_in_low_fps = time_in_period // (pitch/low_fps)\n # `low_fps`でのサンプル番号に変化があったら、その時点でサンプルを取る\n if sample_number_in_low_fps != last_sample_number:\n last_sample_number = sample_number_in_low_fps\n print(num)\n \n```\n\n```\n\n 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25…\n | | | | | | | | | | | | | | | | | | | | | | | | | | …\n | | | | …\n 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 …\n \n```\n\n上段から順に、\n\n * 2000 Hzでサンプリングした時のサンプル番号\n * 2000 Hzでサンプリングした時のサンプル時刻\n * 24 Hzでサンプリングする時のサンプル時刻\n * 24 Hzでサンプリングする時のその時刻のサンプル番号\n\nと言う感じですね。\n\nある時刻のデータが「24 Hzなら何番目のサンプルになるか」を求めて、その「何番目」の値が変化する時のデータを「24 Hzでのサンプル値」とします。\n\nこの例で言うと「2000 Hzでサンプリングした時のサンプル番号」が0, 9, 17, 25, ...の時の値を「24\nHzでのサンプル値」として拾えばいいと言うことになります。\n\n上記のコード、`high_fps`と`low_fps`の値を変えながら試してみて、所望の結果になるか確認してみてください。\n\n* * *\n\nあまり本質的ではないですが、`for num in\nrange(200)`で、`num`には0〜199の値が入るのだから、`loop_count`なんてものを別に用意するのは、あまり意味がないように思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T02:23:25.107",
"id": "59470",
"last_activity_date": "2019-10-05T02:23:25.107",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "59463",
"post_type": "answer",
"score": 1
},
{
"body": "間引くだけで良いなら、`high_fps`の回数を回す必要は無いのでは? \n間引いて取得するための位置(添え字)は計算で求められるでしょう。 \n以下で`low_fps`の回数回せば、1秒分の添え字のリストが出来ます。\n\n```\n\n high_fps = 200.0\n low_fps = 24.0\n interval = high_fps / low_fps\n \n sample_index = []\n for i in range(int(low_fps)):\n # 例として0から始まって四捨五入とする。\n # 好みで切り上げ/切り捨て等に変えたり、開始位置を調整する\n sample_index.append(round(float(i) * interval))\n \n```\n\nそして`high_fps`のデータが`data`というリストに入っているものとすれば、 \n上記`sample_index`を以下のように適用すれば、間引いたデータが`new_data`に取得出来るでしょう。\n\n```\n\n data_count = len(data)\n high_fps_int = int(high_fps)\n data_seconds = data_count // high_fps_int\n \n new_data = []\n for sec in range(data_seconds):\n base_index = sec * high_fps_int\n for work_index in sample_index:\n curr_index = base_index + work_index\n if curr_index >= data_count:\n break\n new_data.append(data[curr_index])\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T04:43:26.843",
"id": "59471",
"last_activity_date": "2019-10-05T04:43:26.843",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26370",
"parent_id": "59463",
"post_type": "answer",
"score": 1
}
] | 59463 | 59471 | 59470 |
{
"accepted_answer_id": "59477",
"answer_count": 1,
"body": "現在独自ドメインでメールが利用できるように設定しています。 \nとりあえずうまくいったのですが、1つわからないことがあるので、教えていただけると幸いです。\n\nメールヘッダを見ると以下の様な値があります。\n\n```\n\n Received: from example.net (example.com [xxx.xxx.xxx.xxx])\n (後略)\n \n```\n\nこのうち「example.net」と「example.com」という値はどこから取得しているのでしょうか。 \n前者については、サーバーに設定しているホスト名だと思いますが、後者の値が何を表しているのかわからずにいます。 \nもし「example.com」の部分を変更できるのであれば、どのように変更すればよいのでしょうか。\n\n環境はUbuntu18.04、メールサーバーはDovecotです。 \n以上、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T05:33:06.253",
"favorite_count": 0,
"id": "59472",
"last_activity_date": "2019-10-05T07:37:56.387",
"last_edit_date": "2019-10-05T06:14:38.710",
"last_editor_user_id": "3060",
"owner_user_id": "29034",
"post_type": "question",
"score": 0,
"tags": [
"mail"
],
"title": "メールヘッダの「Received」に表示されるホスト名について",
"view_count": 916
} | [
{
"body": "たぶん、この仕様に基づいて記録されています。\n\n[RFC 5321(Simple Mail Transfer Protocol)](http://srgia.com/docs/rfc5321j.html)\n\n> **4.4. トレース情報** \n> SMTP サーバーが配送またはさらなる処理のためにメッセージを受信したとき、セクション 4.1.1.4\n> で議論されている通り、メッセージ内容の先頭にトレース(\"タイムスタンプ(time stamp)\" または\n> \"Received\")情報を追加しなければならない(MUST)。\n>\n> この行は以下のように構造化されなければならない(MUST):\n>\n> * SMTP 環境では必ず提供されなければならない(MUST) FROM 節は、(1) EHLO\n> コマンド内で提示される通りの送信元ホスト名と、(2) TCP 接続から決定される送信元の IP\n> アドレスを含むアドレスリテラルとを、両方含むべきである(SHOULD)。\n> * ID 節は RFC 822 で提案されている \"@\" を含んでもよい(MAY)が、必須ではない。\n> * FOR 節が現れる場合、たとえ複数の RCPT コマンドが与えられたとしても、正確にひとつの エントリを含まなければならない(MUST)。複数の\n> はある種のセキュリティ問題を引き起こすため、非推奨である。セクション 7.2 参照。\n>\n\n>\n> インターネットメールプログラムは、メッセージのヘッダセクションにすでに追加されている Received:\n> 行を変更したり削除したりしてはならない(MUST NOT)。SMTP サーバーはメッセージの先頭に Received\n> 行を追加しなければならない(MUST)。既存の行の順序を変更したり、別の位置に Received 行を挿入したりしてはならない(MUST NOT)。\n\nおそらく、「example.net」の部分は、「(1) EHLO コマンド内で提示される通りの送信元ホスト名」、\n**「example.com」の部分は、「(2) TCP 接続から決定される送信元の IP アドレスを含むアドレスリテラル」に該当すると思われます。**\n\n同文書の前後に以下のようにあるので、「Dovecot」で **「自身の \"Received:\"\nフィールド」については内容「example.com」を変更することは出来なくはないでしょうが、やらない方が良いでしょう。**\n\n> **3.6.3. リレーとしてのメッセージサブミッションサーバー**\n>\n> 途中省略\n>\n> セクション 6.4 の議論の通り、リレー SMTP はメッセージのヘッダ部やボディを検査したり、それらに基づいて動作したりする必要はなく、\n> **またヘッダに自身の \"Received:\" フィールド(セクション\n> 4.4)を追加する場合と、オプションでメールシステム内のループの検出を試みる場合とを除き、そうしてはならない(MUST NOT)。**\n> 当然ながらこの禁止事項は、これらのヘッダフィールドまたはテキストに対する変更にも適用される(セクション 7.9 も参照してほしい)。\n>\n> **3.7.2. ゲートウェイにおける Received 行** \n> メッセージをインターネット環境の内側または外側へ転送するとき、ゲートウェイは Received:\n> 行を追加しなければならない(MUST)が、すでにヘッダセクションに追加されている Received: 行を変更してはならない(MUST NOT)。\n>\n> 他の環境から発信されたメッセージの \"Received:\" フィールドは、本仕様に正確に従わない可能性がある。 **しかしながら、Received:\n> 行のもっとも重要な使用法はメール障害のデバッグ作業であり、Received: 行を \"修正(fix)\"\n> しようとする善意のゲートウェイによって、そのデバッグ作業はひどく妨げられる可能性がある。** 非 SMTP\n> 環境で発生したトレースヘッダフィールドのための別の結論として、受信システムはトレースヘッダフィールドのフォーマットに基づいてメールを拒否してはならず(MUST\n> NOT)、予期せぬ情報やそれらのヘッダフィールドのフォーマットを踏まえて、極めて頑強であるべきである(SHOULD)。\n>\n> **6.4. 不正行為を補正する**\n>\n> 内容抜粋(全文は紹介先を参照のこと)\n>\n> 発信 SMTP サーバー、または初期投入(メッセージサブミッション)プロトコルとしての SMTP の接続先として使用される SMTP\n> サーバーが必要とするのであれば、処理されるメッセージに以下の変更が適用されてもよい(MAY):\n>\n> * アドレスを適切な FQDN フォーマットに修正する\n>\n\n>\n>\n> 修正を行うべきかどうかやその方法を考慮するとき、クライアントに付いてサーバーが持つ情報が少なければ少ないほど、これらの変更は正しくなりそうになく、より警戒と保守主義とが適用されるべきである。これらの変更は中間リレー機能を提供する\n> SMTP サーバーによって適用されてはならない(MUST NOT)。\n\n関連記事: \n[メールヘッダの Received\nフィールドの読み方](http://www.tains.tohoku.ac.jp/news/news-32/0510.html) \n[▼各種メールサーバーのReceived: 形式▼](http://vega.pgw.jp/%7Ekabe/vsd/mail/received.html)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T07:30:47.143",
"id": "59477",
"last_activity_date": "2019-10-05T07:37:56.387",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "26370",
"parent_id": "59472",
"post_type": "answer",
"score": 1
}
] | 59472 | 59477 | 59477 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、db形式で記録されている音ゲーのスコアをhtmlに出力させてwebで閲覧するタイプのスコアサイトを作ろうと思っています。\n\n保存されているdb形式のファイルにはタイトルの代わりに曲名と連動したハッシュが記録されているのでスクレイピングをして得られたデータをPythonのスクリプトを用いてCSV形式に変換することができたのですが、そのCSVをhtmlにしてブラウザで閲覧する方法が分からないのでご教授いただきたいです。\n\n・CSVファイルの形\n\n```\n\n タイトル(差分名),発狂難易度,判定ランク,クリアタイプ,スコアランク,EXスコア,perfect,great,good,bad,poor,maxcombo,最小BP,プレイ回数,スコアレート\n la noche (end of mix),0,EASY,Hard,AA,4543,2001,541,77,25,36,847/2661,61,36,85.36\n gravitronicⅠ -ANOTHER-,0,NORMAL,Hard,AA,3386,1500,386,93,29,9,1103/2013,38,22,84.1\n Milly Barll,0,NORMAL,Hard,A,3111,1277,557,142,17,16,523/2000,33,6,77.78\n Merry Christmas Mr.DO,0,NORMAL,Easy,A,2596,1084,428,224,73,37,617/1823,104,20,71.2\n Into the sunset [ANOTHER],0,NORMAL,Easy,C,1174,454,266,228,204,134,102/1200,305,7,48.92\n (以下計1036個のデータが並ぶ)\n \n```\n\nよろしくお願いします。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T06:34:03.130",
"favorite_count": 0,
"id": "59475",
"last_activity_date": "2019-10-05T06:34:03.130",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "35838",
"post_type": "question",
"score": 0,
"tags": [
"python",
"javascript",
"csv"
],
"title": "csvファイルをvue.jsを用いてブラウザに出力させたい",
"view_count": 1139
} | [] | 59475 | null | null |
{
"accepted_answer_id": "59544",
"answer_count": 3,
"body": "下記のプログラムは、\n\n * `sum`円の所持金があり、`n`種類の商品の中から`cnt`個の商品を選びお釣り(`min`円)を最小にする\n\nというアルゴリズムです(商品は安い順に`x[1]`円,`x[2]`円,,,,`x[n]`円と示されます)\n\n現状では、下記のコードのとおり、回文の中に回文といった構造になっており、`cnt`の値によってループの数やループの条件が変わっていくようになっております。\n\n`cnt`の値は入力値で与えられるため、どの`cnt`の値にも対応可能な式を作りたいのですが、どのようにすればいいのでしょうか?\n\n```\n\n // cnt=2の場合\n int min=10000001;\n for(int k=n;sum>=x[k]&&k>=cnt;k--){\n for(int j=k-1;sum>=x[k]+x[j]&&j>=cnt-1;j--){\n min=min>(sum-x[k]-x[j])?(sum-x[k]-x[j]):min;\n }\n }\n \n```\n\nと\n\n```\n\n // cnt=4の場合\n int min=10000001;\n for(int k=n;sum>=x[k]&&k>=cnt;k--){\n for(int j=k-1;sum>=x[k]+x[j]&&j>=cnt-1;j--){\n for(int i=j-1;sum>=x[k]+x[j]+x[i]&&i>=cnt-2;i--){\n for(int l=i-1;sum>=x[k]+x[j]+x[i]+x[l]&&l>=cnt-3;l--){\n min=min>(sum-x[k]-x[j]-x[i]-x[l])?(sum-x[k]-x[j]-x[i]-x[l]):min;\n }\n }\n }\n }\n \n```\n\n✳︎初心者であるため、適切でない表現が含まれていますがご了承ください",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T09:13:23.610",
"favorite_count": 0,
"id": "59481",
"last_activity_date": "2019-10-07T22:48:58.007",
"last_edit_date": "2019-10-05T14:47:24.557",
"last_editor_user_id": "34550",
"owner_user_id": "34550",
"post_type": "question",
"score": 2,
"tags": [
"c"
],
"title": "C言語 多重ループの場合のコードの書き方",
"view_count": 965
} | [
{
"body": "現在のご質問文中で「回文の中に回文といった構造」と言うのは、 \nこんな構造↓\n\n```\n\n for(...) {\n for(...) {\n for(...) {\n for(...) {\n ...\n }\n }\n }\n }\n \n```\n\nを表すのに言い得て妙と言う気はするのですが、やはりプログラミングの世界では「入れ子」とか「ネスト」なんて定着した言葉があるので、そちらを使っていただいた方がより多くの人に早く意図を伝えられるかと思います。(「入れ子」の実物なんて、私がプログラミングの学習を始めた頃(戦後です、一応)から見られなかったものなので、適切な用語かどうかは疑問ですが。)\n\nあなたのご質問をプログラミング業界で通じる普通の言い回しにすると「普通に総当たりの解法をfor文の入れ子で表現すると、パラメータ`cnt`の値に応じた深さの入れ子にしないといけないが、`cnt`の値によらず解けるようなコードにしたい」と言った感じになるでしょうか。\n\nこのような問題を解くには「再帰」を使うのが極めて自然でわかりやすくなるのですが、ここではあえて再帰を使わない解答例を挙げておきます。\n\n「元の問題を一般的に解くのは難しいが、(元の問題を解くのに必要な)全ての組み合わせを作るだけなら、再帰を使わなくてもかけそう」と言った場合に使える手法です。\n\n基本はこんな感じ。\n\n```\n\n 「組み合わせ」を初期化;\n do {\n 取得した「組み合わせ」であれこれ;\n } while( 次の「組み合わせ」を求める );\n \n```\n\nと言う感じで、総当たりの問題は、ネストされたfor文を使わなくても、一重のループに書き直すことができます。問題の種類によっては『次の「組み合わせ」を求める』部分が極端に複雑になってしまうのですが。\n\n* * *\n\nとりあえず、あなたの課題を上記の方針で書いてみるとこんな感じ。\n\n```\n\n #include <stdio.h>\n #include <limits.h>\n #include <stdlib.h>\n #include <stdbool.h>\n \n int maxTotal(int cnt, int limit);\n void initSeq(int *seq, int cnt);\n int sumSeq(int *seq, int cnt);\n bool nextSeq(int *seq, int cnt);\n void printSeq(int *seq, int cnt);\n \n int main(int argc, const char * argv[]) {\n printf(\"%d\\n\", maxTotal(4, 1000));\n return 0;\n }\n \n //商品の価格は安い順にx[0]からx[n-1]の順に入っている\n int x[] = {43, 213, 283, 335, 337, 429, 643, 745, 828, 861};\n //商品の種類(出題の`n`)\n #define XCOUNT 10\n \n //中で合計を求めないといけないので、所持金は`sum`ではなく`limit`としている\n int maxTotal(int cnt, int limit) {\n //「お釣りの額を最小」ではなく、「(制限値内で)使う金額を最大」と考える\n int maxSum = INT_MIN;\n int *seq = (int *)calloc(cnt, sizeof(int));\n initSeq(seq, cnt);\n do {\n printSeq(seq, cnt);\n int sum = sumSeq(seq, cnt);\n if( sum <= limit && sum > maxSum) {\n maxSum = sum;\n }\n } while( nextSeq(seq, cnt) );\n return maxSum;\n }\n \n //「組み合わせ」の初期化\n void initSeq(int *seq, int cnt) {\n for( int i = 0; i < cnt; ++i ) {\n seq[i] = XCOUNT - 1 - i;\n }\n }\n \n //現在の「組み合わせ」での合計を求める\n int sumSeq(int *seq, int cnt) {\n int sum = 0;\n for( int i = 0; i < cnt; ++i ) {\n sum += x[seq[i]];\n }\n return sum;\n }\n \n //次の「組み合わせ」を求める\n bool nextSeq(int *seq, int cnt) {\n for( int i = cnt - 1; i >= 0; --i ) {\n if( seq[i] > 0 ) {\n seq[i] -= 1;\n bool finished = true;\n for( int j = i+1; j < cnt; ++j ) {\n if( seq[j-1] == 0 ) {\n finished = false;\n break;\n }\n seq[j] = seq[j-1] - 1;\n }\n if( finished ) {\n return true;\n }\n }\n }\n return false;\n }\n \n //「組み合わせ」の表示(デバッグ用)\n void printSeq(int *seq, int cnt) {\n printf(\"[\");\n for( int i = 0; i < cnt; ++i ) {\n printf(\"%d\", seq[i]);\n if( i < cnt - 1 ) {\n printf(\", \");\n }\n }\n printf(\"]\\n\");\n }\n \n```\n\n(stdbool.hなんかが使えない古いCだと修正が必要になります。K&Rスタイルの古いCを学習した人にチェックされるとダメ出しを食らうような部分があるかもしれません。)\n\nただし、プログラミングチャレンジの出題のような場合、「単純な総当たり」では時間切れになってしまうような設定になっていることが多いです。上記のように「組み合わせ」だけを別途求めるようにすると、単純な枝刈りさえ難しくなるので、あまりお勧めはしにくい解き方ということになります。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T17:17:39.317",
"id": "59488",
"last_activity_date": "2019-10-05T17:17:39.317",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "59481",
"post_type": "answer",
"score": 0
},
{
"body": "中島さんの「組みわせ」の仕方についての質問に対する回答ではありません。 \nfor文の入れ子を再帰で表すコードの例です。\n\n繰り返される処理はfunc()です。 \nこのコード例では \n・次元数はi_level_num \n・多次元配列の添え字がai_idxで渡されます。 \nサンプルのfunc()は各次元の添え字を出力しているだけです。\n\nmain()では以下を行っています。 \n・3次元[3][4][5]のループでfunc()を呼び出す \n・4次元[5][4][3][2]のループでfunc()を呼び出す\n\n【ソースコードサンプル】\n\n```\n\n #include <stdio.h>\n int func(int i_level_num, int ai_idx[]);\n int func(int i_level_num, int ai_idx[])\n {\n int i;\n printf(\"ai_idx\");\n for(i = 0; i < i_level_num; i++){\n printf(\"[%d]\", ai_idx[i]);\n }\n printf(\"\\n\");\n return 0;\n }\n \n int looploop(int ai_level[], int i_level_num, int i_level, int ai_idx[], int (*pfunc)(int i_level_num, int ai_idx[]));\n int looploop(int ai_level[], int i_level_num, int i_level, int ai_idx[], int (*pfunc)(int i_level_num, int ai_idx[]))\n {\n int i;\n if( i_level >= i_level_num){\n pfunc(i_level_num, ai_idx);\n return 0;\n }\n for( i = 0; i < ai_level[i_level]; i++){\n ai_idx[i_level] = i;\n looploop(ai_level, i_level_num, i_level + 1, ai_idx, pfunc);\n }\n return 0;\n }\n #define ELEMENT_NUM(A) (sizeof(A)/sizeof(A[0]))\n int main(int argc, char *argv[])\n {\n int ai_level_3[] = {3,4,5};\n int ai_idx_3[ELEMENT_NUM(ai_level_3)];\n printf(\"3重ループ[3][4][5]\\n\");\n looploop(ai_level_3, ELEMENT_NUM(ai_level_3), 0, ai_idx_3, func);\n \n int ai_level_4[] = {5,4,3,2};\n int ai_idx_4[ELEMENT_NUM(ai_level_4)];\n printf(\"4重ループ[5][4][3][2]\\n\");\n looploop(ai_level_4, ELEMENT_NUM(ai_level_4), 0, ai_idx_4, func);\n return 0;\n }\n \n \n```\n\n【実行結果】\n\n```\n\n 3重ループ[3][4][5]\n ai_idx[0][0][0]\n ai_idx[0][0][1]\n ai_idx[0][0][2]\n ai_idx[0][0][3]\n ai_idx[0][0][4]\n ai_idx[0][1][0]\n ai_idx[0][1][1]\n ai_idx[0][1][2]\n ai_idx[0][1][3]\n ai_idx[0][1][4]\n ai_idx[0][2][0]\n ai_idx[0][2][1]\n ai_idx[0][2][2]\n ai_idx[0][2][3]\n ai_idx[0][2][4]\n ai_idx[0][3][0]\n ai_idx[0][3][1]\n ai_idx[0][3][2]\n ai_idx[0][3][3]\n ai_idx[0][3][4]\n ai_idx[1][0][0]\n ai_idx[1][0][1]\n ai_idx[1][0][2]\n ai_idx[1][0][3]\n ai_idx[1][0][4]\n ai_idx[1][1][0]\n ai_idx[1][1][1]\n ai_idx[1][1][2]\n ai_idx[1][1][3]\n ai_idx[1][1][4]\n ai_idx[1][2][0]\n ai_idx[1][2][1]\n ai_idx[1][2][2]\n ai_idx[1][2][3]\n ai_idx[1][2][4]\n ai_idx[1][3][0]\n ai_idx[1][3][1]\n ai_idx[1][3][2]\n ai_idx[1][3][3]\n ai_idx[1][3][4]\n ai_idx[2][0][0]\n ai_idx[2][0][1]\n ai_idx[2][0][2]\n ai_idx[2][0][3]\n ai_idx[2][0][4]\n ai_idx[2][1][0]\n ai_idx[2][1][1]\n ai_idx[2][1][2]\n ai_idx[2][1][3]\n ai_idx[2][1][4]\n ai_idx[2][2][0]\n ai_idx[2][2][1]\n ai_idx[2][2][2]\n ai_idx[2][2][3]\n ai_idx[2][2][4]\n ai_idx[2][3][0]\n ai_idx[2][3][1]\n ai_idx[2][3][2]\n ai_idx[2][3][3]\n ai_idx[2][3][4]\n 4重ループ[5][4][3][2]\n ai_idx[0][0][0][0]\n ai_idx[0][0][0][1]\n ai_idx[0][0][1][0]\n ai_idx[0][0][1][1]\n ai_idx[0][0][2][0]\n ai_idx[0][0][2][1]\n ai_idx[0][1][0][0]\n ai_idx[0][1][0][1]\n ai_idx[0][1][1][0]\n ai_idx[0][1][1][1]\n ai_idx[0][1][2][0]\n ai_idx[0][1][2][1]\n ai_idx[0][2][0][0]\n ai_idx[0][2][0][1]\n ai_idx[0][2][1][0]\n ai_idx[0][2][1][1]\n ai_idx[0][2][2][0]\n ai_idx[0][2][2][1]\n ai_idx[0][3][0][0]\n ai_idx[0][3][0][1]\n ai_idx[0][3][1][0]\n ai_idx[0][3][1][1]\n ai_idx[0][3][2][0]\n ai_idx[0][3][2][1]\n ai_idx[1][0][0][0]\n ai_idx[1][0][0][1]\n ai_idx[1][0][1][0]\n ai_idx[1][0][1][1]\n ai_idx[1][0][2][0]\n ai_idx[1][0][2][1]\n ai_idx[1][1][0][0]\n ai_idx[1][1][0][1]\n ai_idx[1][1][1][0]\n ai_idx[1][1][1][1]\n ai_idx[1][1][2][0]\n ai_idx[1][1][2][1]\n ai_idx[1][2][0][0]\n ai_idx[1][2][0][1]\n ai_idx[1][2][1][0]\n ai_idx[1][2][1][1]\n ai_idx[1][2][2][0]\n ai_idx[1][2][2][1]\n ai_idx[1][3][0][0]\n ai_idx[1][3][0][1]\n ai_idx[1][3][1][0]\n ai_idx[1][3][1][1]\n ai_idx[1][3][2][0]\n ai_idx[1][3][2][1]\n ai_idx[2][0][0][0]\n ai_idx[2][0][0][1]\n ai_idx[2][0][1][0]\n ai_idx[2][0][1][1]\n ai_idx[2][0][2][0]\n ai_idx[2][0][2][1]\n ai_idx[2][1][0][0]\n ai_idx[2][1][0][1]\n ai_idx[2][1][1][0]\n ai_idx[2][1][1][1]\n ai_idx[2][1][2][0]\n ai_idx[2][1][2][1]\n ai_idx[2][2][0][0]\n ai_idx[2][2][0][1]\n ai_idx[2][2][1][0]\n ai_idx[2][2][1][1]\n ai_idx[2][2][2][0]\n ai_idx[2][2][2][1]\n ai_idx[2][3][0][0]\n ai_idx[2][3][0][1]\n ai_idx[2][3][1][0]\n ai_idx[2][3][1][1]\n ai_idx[2][3][2][0]\n ai_idx[2][3][2][1]\n ai_idx[3][0][0][0]\n ai_idx[3][0][0][1]\n ai_idx[3][0][1][0]\n ai_idx[3][0][1][1]\n ai_idx[3][0][2][0]\n ai_idx[3][0][2][1]\n ai_idx[3][1][0][0]\n ai_idx[3][1][0][1]\n ai_idx[3][1][1][0]\n ai_idx[3][1][1][1]\n ai_idx[3][1][2][0]\n ai_idx[3][1][2][1]\n ai_idx[3][2][0][0]\n ai_idx[3][2][0][1]\n ai_idx[3][2][1][0]\n ai_idx[3][2][1][1]\n ai_idx[3][2][2][0]\n ai_idx[3][2][2][1]\n ai_idx[3][3][0][0]\n ai_idx[3][3][0][1]\n ai_idx[3][3][1][0]\n ai_idx[3][3][1][1]\n ai_idx[3][3][2][0]\n ai_idx[3][3][2][1]\n ai_idx[4][0][0][0]\n ai_idx[4][0][0][1]\n ai_idx[4][0][1][0]\n ai_idx[4][0][1][1]\n ai_idx[4][0][2][0]\n ai_idx[4][0][2][1]\n ai_idx[4][1][0][0]\n ai_idx[4][1][0][1]\n ai_idx[4][1][1][0]\n ai_idx[4][1][1][1]\n ai_idx[4][1][2][0]\n ai_idx[4][1][2][1]\n ai_idx[4][2][0][0]\n ai_idx[4][2][0][1]\n ai_idx[4][2][1][0]\n ai_idx[4][2][1][1]\n ai_idx[4][2][2][0]\n ai_idx[4][2][2][1]\n ai_idx[4][3][0][0]\n ai_idx[4][3][0][1]\n ai_idx[4][3][1][0]\n ai_idx[4][3][1][1]\n ai_idx[4][3][2][0]\n ai_idx[4][3][2][1]\n \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T11:49:34.647",
"id": "59532",
"last_activity_date": "2019-10-07T12:22:50.013",
"last_edit_date": "2019-10-07T12:22:50.013",
"last_editor_user_id": "35558",
"owner_user_id": "35558",
"parent_id": "59481",
"post_type": "answer",
"score": 2
},
{
"body": "「for文の入れ子を再帰で表すコードの例」が投稿されましたので、元の課題を再帰で解く場合のコードを示しておきます。詳細はコメントを参照してください。\n\nまた、別解の`printSeq`相当の情報が出力できませんが、akira ejiri さんの回答を参考にすれば改善できるでしょう。\n\n```\n\n #include <stdio.h>\n \n int maxTotalR(int n, int cnt, int limit);\n \n //商品の価格は安い順にx[0]からx[n-1]の順に入っている\n int x[] = {43, 213, 283, 335, 337, 429, 643, 745, 828, 861};\n //商品の種類(出題の`n`)\n #define XCOUNT 10\n \n int main(int argc, const char * argv[]) {\n printf(\"%d\\n\", maxTotalR(XCOUNT, 4, 1000));\n return 0;\n }\n \n // n: 商品の範囲、x[0]...x[n-1]の中から選ぶ\n // cnt: 残りの個数\n // limit: 残りの使える金額\n int maxTotalR(int n, int cnt, int limit) {\n //終了条件判定、残り0個ってことは合計金額は0円で決定\n if( cnt == 0 ) {\n return 0;\n }\n //自明なケースを早めに刈ることで組み合わせの総数を減らす\n if( cnt > n ) {\n return -1;\n }\n //最大値を求めるため&&有効な値がなければ-1を返すための初期化\n int maxSum = -1;\n for( int i = n - 1; i >= 0; --i ) {\n //再帰呼び出しの時は確実にcntの値を減らしていることに注意、この結果cnt==0が有効な終了条件として働く\n int subsum = maxTotalR(i, cnt - 1, limit - x[i]);\n //subsum<0は解なしを表しているので、subsum>=0の時にだけ合計を求める\n if( subsum >= 0 ) {\n int sum = x[i] + subsum;\n if( sum <= limit && sum > maxSum ) {\n maxSum = sum;\n }\n }\n }\n return maxSum;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T22:48:58.007",
"id": "59544",
"last_activity_date": "2019-10-07T22:48:58.007",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "59481",
"post_type": "answer",
"score": 2
}
] | 59481 | 59544 | 59532 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "お世話になります。 \n下記サイトを参考にVPSにDovecotをインストールして、外部のメールサーバー(今回の例ではConoHaのメールサーバー)のプロキシとして利用するように設定しました。 \n[ConoHa のメールサーバーを使おうとしたら SSL 証明書で難儀した話\n(実装編)](https://www.compnet.jp/posts/2019-01-05T1737_ConoHa%20%E3%81%AE%E3%83%A1%E3%83%BC%E3%83%AB%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E3%82%92%E4%BD%BF%E3%81%8A%E3%81%86%E3%81%A8%E3%81%97%E3%81%9F%E3%82%89%20SSL%20%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%81%A7%E9%9B%A3%E5%84%80%E3%81%97%E3%81%9F%E8%A9%B1%20\\(%E5%AE%9F%E8%A3%85%E7%B7%A8\\).html) \nとりあえず、設定は終わり、大体はうまく動いているのですが、現状だと465番ポートでのSSL通信ができずに困っています。 \nメーラーから送信しようとすると、下記のエラーが出る状況です。\n\n```\n\n mail.example.com への接続に失敗しました。(FD_CONNECT, code=10061)\n \n```\n\nちなみに、STARTTLSをオンにした状態で、587番ポートからの送信は成功しています。 \n465番ポートでSSL通信をできるようにするには、どのようにしたらよいでしょうか。 \nなお、下記コマンドでポート解放を行ったあと、サーバーを再起動しています。\n\n```\n\n ufw allow 465\n \n```\n\n環境は、Ubuntu 18.04、Dovecot 2.3.7.2です。 \n以上、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T12:52:08.597",
"favorite_count": 0,
"id": "59484",
"last_activity_date": "2019-10-06T22:54:39.000",
"last_edit_date": "2019-10-06T05:16:29.843",
"last_editor_user_id": "29034",
"owner_user_id": "29034",
"post_type": "question",
"score": 0,
"tags": [
"dovecot",
"mail"
],
"title": "Dovecotのプロキシ機能で465番ポートでSSL通信できるようにする方法",
"view_count": 341
} | [
{
"body": "なんとか自力で解決したので、メモ代わりに残しておきます。\n\n 1. 「/etc/dovecot/conf.d/10-master.conf」を開き、「service submission-login {」の下に下記を追記する。\n\ninet_listener submission_25 { \nport = 25 \n} \ninet_listener submission_465 { \nport = 465 \nssl = yes \n}\n\n 2. Dovecotを再起動する。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T22:54:39.000",
"id": "59516",
"last_activity_date": "2019-10-06T22:54:39.000",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29034",
"parent_id": "59484",
"post_type": "answer",
"score": 0
}
] | 59484 | null | 59516 |
{
"accepted_answer_id": "59497",
"answer_count": 2,
"body": "ソケット通信を停止させる時にエラーが出ます。 \nエラーを再現するために色々試して見た結果、以下のようにsleepを挟んでデータを送っていると、受信側でソケット通信を停止させる時にエラーになるようです。\n\n**testSend.py**\n\n```\n\n import time\n from socket import socket, AF_INET, SOCK_DGRAM\n \n HOST = ''\n PORT = 5000\n ADDRESS = \"127.0.0.1\"\n \n s = socket(AF_INET, SOCK_DGRAM)\n \n while True:\n s.sendto(str(time.time()).encode(), (ADDRESS, PORT))\n time.sleep(0.1)\n \n s.close()\n \n```\n\n受信側のコードは、以下のようになっています。 \nGUIを立ち上げて[start]ボタンを押すとデータを受信して、200秒に1度ずつ時間をprintし \n[stop]ボタンを押すと受信とprintを停止するプログラムになっています。\n\n**testRecieve.py**\n\n```\n\n import tkinter as tk\n import threading\n import time\n from socket import socket, AF_INET, SOCK_DGRAM\n \n class threadingGUI():\n def __init__(self):\n self.stop_flag = True\n self.s = None\n self.thread1 = None\n self.thread2 = None\n \n def worker(self):\n #文字列を受け取る\n messages, address = self.s.recvfrom(8192)\n print(messages)\n \n def schedule(self,interval, f, wait=True):\n base_time = time.time()\n next_time = 0\n while not self.stop_flag:#接続を切るボタンが押されるまでループ\n self.thread2 = threading.Thread(target=f)\n self.thread2.start()\n if wait:\n self.thread2.join()\n next_time = ((base_time - time.time()) % interval) or interval\n time.sleep(next_time)\n \n def start(self):\n if not self.thread1:\n HOST = ''\n PORT = 5000\n \n #受信\n ADDRESS = \"127.0.0.1\"\n self.s = socket(AF_INET, SOCK_DGRAM)\n self.s.bind((HOST, PORT))\n \n self.thread1 = threading.Thread(target=self.schedule,args=(1.00/200.00, self.worker, False))\n self.stop_flag=False\n self.thread1.start()\n \n \n def stop(self):\n if self.thread1:\n self.stop_flag=True\n self.thread1.join()\n self.s.close()\n self.thread1=None\n \n def GUI_start(self):\n root=tk.Tk()\n Button001=tk.Button(root,text=\"Start\",command=self.start)\n Button001.pack()\n Button002=tk.Button(root,text=\"Stop\",command=self.stop)\n Button002.pack()\n root.mainloop()\n \n t = threadingGUI()\n t.GUI_start()\n \n```\n\n[stop]ボタンを押すと\n\n```\n\n line 15, in worker\n messages, address = self.s.recvfrom(8192)\n OSError: [WinError 10038] ソケット以外のものに対して操作を実行しようとしました。\n \n```\n\nというエラーメッセージが繰り返し表示されます。 \ntestSend.pyからtime.sleep(0.1)を消すとこのエラーはなくなるのですが。 \nこのsleepを残したままエラーを出さない方法はないでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T13:00:52.697",
"favorite_count": 0,
"id": "59485",
"last_activity_date": "2019-10-06T00:27:34.503",
"last_edit_date": "2019-10-05T15:16:54.643",
"last_editor_user_id": "34471",
"owner_user_id": "34471",
"post_type": "question",
"score": 0,
"tags": [
"python",
"network",
"socket"
],
"title": "socket通信を停止させる時にエラー:OSError: [WinError 10038] ソケット以外のものに対して操作を実行しようとしました。",
"view_count": 4457
} | [
{
"body": "一般的にソケットは同期IOです。つまり\n\n```\n\n def worker(self):\n #文字列を受け取る\n messages, address = self.s.recvfrom(8192)\n print(messages)\n \n```\n\nは受信できるまで待ち続けます。そしてこれを起動する\n\n```\n\n def schedule(self,interval, f, wait=True):\n base_time = time.time()\n next_time = 0\n while not self.stop_flag:#接続を切るボタンが押されるまでループ\n self.thread2 = threading.Thread(target=f)\n self.thread2.start()\n if wait:\n self.thread2.join()\n next_time = ((base_time - time.time()) % interval) or interval\n time.sleep(next_time)\n \n```\n\nは受信待ちスレッドを作成し続けます。仮にループが200周すれば、受信待ちスレッドが200個作成されます。これらは送信側から200回受信しなければ完了しません。\n\n[stop]ボタンを押すと、ソケットがクローズされるため、大量に作成された受信待ちスレッドがエラーを発生させます。\n\n* * *\n\nと状況は説明できますが、どのような処理にしたいのかがわからないので、修正案は示すことができません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T23:43:50.060",
"id": "59496",
"last_activity_date": "2019-10-05T23:43:50.060",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "59485",
"post_type": "answer",
"score": 1
},
{
"body": "@sayuriさん回答とほとんど被りますが、 \n動作内容・原因とエラーの状況は以下になるでしょう。\n\n * 作成したsocketが無限待ちのブロッキング型である\n * scheduleスレッドの中で5ms毎にworkerスレッドを作成し、かつ終了を待っていない\n * testSend.pyスクリプトは100ms毎に1回送信\n * 上記により、startボタンクリック後は100ms毎に19個の受信待ちworkerスレッドが積み上がり、時間が経つごとに増えていく\n * stopボタンクリックしてソケットclose&None設定後に、積み上がった受信待ちworkerスレッドが全て例外で終了する\n\n気付かれていないもう一つの異常として、testSend.pyスクリプトを動作させずにtestRecieve.pyスクリプトだけを起動・startボタンクリック・stopボタンクリックすると、無応答状態になります。\n\n対処としては以下の2つを両方組み込むことになるでしょう。\n\n * socketにtimeout値(0.01~0.1秒程度?)を設定する \nあるいはノンブロッキング型に設定する(以下の例はtimeout設定)\n\n* * *\n```\n\n #受信\n ADDRESS = \"127.0.0.1\"\n self.s = socket(AF_INET, SOCK_DGRAM)\n self.s.settimeout(0.1) # タイムアウト値設定を追加する\n self.s.bind((HOST, PORT))\n \n```\n\n* * *\n\n * workerスレッドの受信&print処理を例外処理で囲む \n(正常動作中でも常にtimeout等の例外が発生するので)\n\n* * *\n```\n\n def worker(self):\n try: # 例外処理を組み込む\n #文字列を受け取る\n messages, address = self.s.recvfrom(8192)\n print(messages)\n # 必要であれば以下に発生した例外種類に応じた対処を組み込む\n except:\n pass # 例としては全てにおいて特に何もしない\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T00:17:52.750",
"id": "59497",
"last_activity_date": "2019-10-06T00:27:34.503",
"last_edit_date": "2019-10-06T00:27:34.503",
"last_editor_user_id": "26370",
"owner_user_id": "26370",
"parent_id": "59485",
"post_type": "answer",
"score": 1
}
] | 59485 | 59497 | 59496 |
{
"accepted_answer_id": "59493",
"answer_count": 4,
"body": "C++で動的に配列を確保し、コンストラクタで初期値を与えようと思っているのですがうまくいかいず困っています \n以下のソースなのですがBaseClassをmain内で動的に配列を確保するまでは出来たのですが \nコンストラクタに引数を追加するとコンパイルエラーになります \nbcRec = new BaseClass(5)[n];やbcRec = new BaseClass(5)[n]; \nと言った風にしてみたのですが・・・ \n正しい文法はどのように記述したら良いのでしょう\n\n**BaseClass.h**\n\n```\n\n class BaseClass{\n private:\n int _a;\n public :\n BaseClass();\n BaseClass(int a);\n void setint(int a);\n int fooint();\n };\n \n```\n\n**BaseClass.cpp**\n\n```\n\n #include \"BaseClass.h\"\n BaseClass::BaseClass(int a){\n _a = a;\n }\n \n void BaseClass::setint(int a){\n _a = a;\n }\n \n BaseClass::BaseClass(){\n _a = 0;\n }\n \n int BaseClass::fooint(){\n return _a;\n }\n \n```\n\n**main.cpp**\n\n```\n\n int main(){\n BaseClass bc(10);\n BaseClass *bcRec;\n int n;\n \n n = 10;\n bcRec = new BaseClass[n]; //★本当は引数付きのコンストラクタを使いたい\n \n for (int i = 0; i < n; i++) {\n bcRec[i].setint(i * 10);\n std::cout << bcRec[i].fooint() << \"\\r\\n\";\n }\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T14:46:51.613",
"favorite_count": 0,
"id": "59486",
"last_activity_date": "2019-10-07T04:12:54.500",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15047",
"post_type": "question",
"score": 0,
"tags": [
"c++",
"array"
],
"title": "C++で配列を動的に取りたい(コンストラクタに引数付きで)",
"view_count": 4900
} | [
{
"body": "`new BaseClass[n]`\nとやっても`BaseClass`の配列はできますが`int`の配列にはなりません。`_a`はあくまでも1個の`int`ですので、これを動的配列にする必要があります。\n\nC++での動的配列は、一般的には`vector`を使います。`int _a;`の代わりに`std::vector<int>\n_a;`と書きます。vectorを使うには`#include <vector>`が必要です。そして`BaseClass`のコンストラクタを次のようにします。\n\n```\n\n BaseClass::BaseClass(int a)\n : _a(a)\n {\n }\n \n```\n\nこれは、`_a`を構築するために`std::vector<int>\n_a(a);`と書きたいところですが、`BaseClass`で自身のメンバ変数を初期化するための記述方法は上記のようになります。メンバ変数の初期化の文法についてはC++の参考書で勉強してください。\n\nメンバ関数`setint`は次のようになります。\n\n```\n\n void BaseClass::setint(int i, int a)\n {\n _a[i] = a;\n }\n \n```\n\nメンバ関数`fooint`(`getint`?)は次のようになります。\n\n```\n\n int BaseClass::fooint(int i)\n {\n return _a[i];\n }\n \n```\n\n`_a`は`vector`ですので、`[]`で読み書きできます。`vector`の使い方は参考書で勉強してください。配列のインデックス値をメンバ関数の第一引数で渡している点を理解してください。\n\nここまでできれば、`main`関数をどう書き変えればいいかは想像できると思います。とりあえず`BaseClass\n*bcRec;`は不要なので削除しましょう。あとはご自身で考えてみてください。\n\n以下、改良のための余談。\n\n個数を意味する変数名は`a`より`n`(`number`)の方が相応しいです。同様に、値を意味する変数名は`a`より`v`(`value`)などがいいでしょう。もちろん配列に何を格納するかによって、`value`よりもっと適した意味を持つ単語を使うと良いです。\n\n`fooint`(`getint`)は読み取るだけで書き込みはしませんので`const`をつけるのが理想です。はじめのうちは無くてもいいでしょうが、今後、実用的なプログラムを作るのであれば`const`のテクニックはほぼ必須ですので、参考書で勉強してください。\n\nあと、そもそも`BaseClass`を一切作らずに、`main`関数内で`std::vector<int>\narray(5);`などと書いてやってみるのも理解の助けになると思います。\n\nクラスメンバの変数を配列にしたいのか(上記の書き方)、オブジェクト(クラスのインスタンス)を配列にしたいのかで書き方が変わります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T17:23:22.047",
"id": "59489",
"last_activity_date": "2019-10-05T17:23:22.047",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3337",
"parent_id": "59486",
"post_type": "answer",
"score": 1
},
{
"body": "前提条件があるので、いつでも使えるというわけではありませんが、動的な配列はC++では、`std::vector`が第一候補です。\n\n```\n\n #include <iostream>\n #include <vector>\n #include \"BaseClass.h\"\n \n int main() {\n int n;\n \n n = 10;\n std::vector<BaseClass> bcRec; // 空のvectorを再生\n bcRec.reserve(n); // n個分のメモリを確保するが初期化はしない\n \n // vectorの最後に、初期化をしながら(コンストラクタを呼びながら)\n // 一つずつBaseClassを追加\n for (int i = 0; i < n; ++i) {\n bcRec.emplace_back(i * 10);\n }\n \n // 中身を確認\n for (int i = 0; i < n; i++) {\n std::cout << bcRec[i].fooint() << '\\n';\n }\n \n return 0;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T19:37:45.493",
"id": "59493",
"last_activity_date": "2019-10-05T19:37:45.493",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3605",
"parent_id": "59486",
"post_type": "answer",
"score": 1
},
{
"body": "(不定個数の) 動的配列を `new[]`\nしたい、かつ各要素を「デフォルトでない値」で均一にコンストラクトしたい(代入でなく)とオイラはこの質問を読んだっす。\n\n```\n\n int* a=new int[3]; // だと「3要素をデフォルト初期化」つまり 0 になる\n int* b=new int[3] /* 3要素に同じ初期値 42 を与えたい */ ; // どう書く?\n T* c=new T[3] /* 同じく3要素に同じ初期値(デフォルトでない)を与えたい */;\n \n```\n\nたいていの「無いことの証明」は悪魔の証明なのですが、この件に関しては言語仕様書をさっくり見る限りにおいて **できません**\n。できるような構文が用意されていません。\n\n引用はいいんようということで C++ 言語仕様書 ISO/IEC 14882:2003 から引用\n\n5.3.4 `new` 式の 15\n\n> 型 `T` のオブジェクトを作る《 `new` 式》は (snip) 《生成初期化子》が `(式並び)` という形式 (snip) である場合、\n> 適切なコンストラクタが呼び出される\n\nつまり `T` 型の1つのオブジェクト(変数)を作る場合には初期値式並びが指定できます。\n\n一方で、型 `T` のオブジェクトの配列を作る場合は言語仕様書に記載がありません。できないということです。\n\nSuperBike\nレース車両のレギュレーションブックは「認められると書かれてる変更はして良い」「認められると書かれていない項目は変更してはならない」と読む約束で、この場合も同様と考えます。\n\nココの項目には [c++11](/questions/tagged/c%2b%2b11 \"'c++11' のタグが付いた質問を表示\") にて修正が入っていて \n<https://ja.cppreference.com/w/cpp/language/new> \n集成体初期化ができるようになっています。 \n<https://ja.cppreference.com/w/cpp/language/aggregate_initialization> \nが、この件については集成体初期化ではおそらく望みを達成することができません。\n\n集成体とは「値が複数個含まれるものすべて」つまり配列も集成体ですし、クラスも集成体です。\n\n```\n\n void func() {\n int x[64]={0};\n }\n \n```\n\nこれはよくある「自動変数配列のゼロ初期化」ですが、ここに集成体初期化が使われていて、コンパイラは次のように読む仕様です。 \n\\- `x[0]` の初期値として `0` が明示されている \n\\- `x[1]` 以後は初期値が明示されていない \n\\- このとき、明示されていない要素については値初期化を行う(端的には `0` にする) \n\\- 結果的に全要素を `0` に初期化する挙動となる\n\nなので \n\\- C++03 の場合 `bcRec = new BaseClass[n] {42};` と書くことが認められていない \n\\- C++11 の場合 `bcRec = new BaseClass[n] {42};` と書けるが \n\\- `bcRec[0]` は `42` を受け取るコンストラクタで初期化されるが \n\\- `bcRec[1]` 以後はデフォルトコンストラクトされる \nという挙動になります。\n\n要素数が事前にわかっていれば `bcRec = new BaseClass[3] { 42, 42, 42 };`\nと書けるわけですが、この例では可変個数なので無理っす。\n\n可変要素数配列の2要素目以後のコンストラクタがうまく指定できないのは言語仕様上の欠陥ではあるのですが、集成体初期化は既にあるソースで広く使われているので\n`Breaking Change` (既存ソースコードの動作挙動が変わる変更) に慎重な [c](/questions/tagged/c \"'c'\nのタグが付いた質問を表示\") / [c++](/questions/tagged/c%2b%2b \"'c++' のタグが付いた質問を表示\")\nにおいてこの辺の仕様変更は今後もまず無いと考えていいでしょう。\n\nオイラならこの件、コンストラクタによる初期化だけで処理するのはあきらめて、デフォルトコンストラクト後に代入します(だって無理だし)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T01:50:19.117",
"id": "59520",
"last_activity_date": "2019-10-07T01:50:19.117",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "59486",
"post_type": "answer",
"score": 0
},
{
"body": "`new`は次の2つの役割を持っています。\n\n * メモリ確保を行う\n * コンストラクターを呼び出す \n * (非配列版)引数を指定できる\n * (配列版)引数を指定できず、デフォルトコンストラクターが呼ばれる\n\nこの質問では、配列版においてデフォルトコンストラクター以外を呼び出したい、とのことですが、とりあえずは実現できません。\n\nただし、[`new`](https://ja.cppreference.com/w/cpp/memory/new/operator_new)の機能を分割して、それぞれを呼び出せば実現可能です。 \n`::operator new`は指定されたサイズのメモリを確保し、対になる`::operator delete`で解放できます。またplacement\nnew(配置new)は指定されたアドレス上でコンストラクターを実行します。\n\n```\n\n // メモリ確保\n bcRec = static_cast<BaseClass*>(::operator new(sizeof(BaseClass) * n));\n // コンストラクター実行\n for (int i = 0; i < n; i++)\n ::new (bcRec + i)BaseClass(5);\n // デストラクター実行\n for (int i = 0; i < n; i++)\n bcRec[i].~BaseClass();\n // メモリ解放\n ::operator delete(bcRec);\n \n```\n\nSTLはこれを支援する関数を提供しています。\n\n```\n\n std::allocator<BaseClass> al;\n // メモリ確保\n bcRec = al.allocate(n);\n // コンストラクター実行\n std::uninitialized_fill_n(bcRec, n, 5);\n // デストラクター実行\n std::destroy_n(bcRec, n);\n // メモリ解放\n al.deallocate(bcRec, n);\n \n```\n\nとはいえ、上記コードは煩雑であり、要素数を誤ると簡単に不正な処理を行ってしまうため非常に危険です。STLに用意されている[`std::vector`](https://ja.cppreference.com/w/cpp/container/vector)で動的に確保することをお勧めします。特に`reserve()`で事前にメモリ確保しておくことで、要素数増減に伴うメモリ確保のオーバーヘッドを削減することができます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T04:12:54.500",
"id": "59521",
"last_activity_date": "2019-10-07T04:12:54.500",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "59486",
"post_type": "answer",
"score": 3
}
] | 59486 | 59493 | 59521 |
{
"accepted_answer_id": "59724",
"answer_count": 2,
"body": "現在、ブログ投稿アプリケーションの実装をしているところでして、 \nテンプレートにカスタムユーザのPKを直接渡してDBに登録させる仕様になっています。\n\n◆Viewより抜粋\n\n```\n\n def get_context_data(self, **kwargs):\n context = super().get_context_data(**kwargs)\n context['user_pk'] = self.request.user.pk\n return context\n \n```\n\n◆テンプレートより抜粋\n\n```\n\n <div class=\"form-group col-md-11\">\n <label for=\"id_author\">著者</label>\n <input type=\"hidden\" name=\"{{ form.author.name }}\" id=\"{{ form.author.id_for_label }}\" value=\"{{ user_pk }}\" >\n </div>\n \n```\n\nそこで、hiddenでフォームは表示させておりませんが、devtoolsでは当然のことながら参照ができてしまいます。 \nですので、もし他ユーザのPKを取得された場合、投稿ユーザの改ざんが可能になってしまいます。\n\nセキュアな部分ですので、可能ならソース側のみで完結させたいのですが、その場合どう実装したらよいでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T18:21:35.293",
"favorite_count": 0,
"id": "59490",
"last_activity_date": "2019-10-15T11:09:19.353",
"last_edit_date": "2019-10-05T20:20:43.227",
"last_editor_user_id": "3060",
"owner_user_id": "36021",
"post_type": "question",
"score": 0,
"tags": [
"python",
"django"
],
"title": "djangoのFormで直接PKを渡してよいのか??",
"view_count": 894
} | [
{
"body": "pkの意味が具体的にわからないのでプライマリーキーと捉えて回答してみます。\n\nまず、プライマリーキーについて。 \nデーターベースで使われる単語です。[django-\ngirls](https://tutorial.djangogirls.org/ja/extend_your_application/)やいくつかのブログではidという意味でpkが使われています。この意味で取るとuser_pkはuser_idと同義になります。\n\nこの場合、質問者さんの言う「他ユーザのPKを取得される」状況は十分起こりうります。その人のブログを読んだら、user_idを見ることでなりすましが可能なので、セキュリティに問題があるということになります。こうなると認証機能を実装する必要があります。\n\nどのように認証を実装するか。 \n今じゃ見ませんが、簡単なモデルとして[Basic認証](https://ja.wikipedia.org/wiki/Basic%E8%AA%8D%E8%A8%BC)が挙げられます。ユーザー名とパスワードの組み合わせを使って、その人しか知らない情報で認証します。(httpという盗聴可能な通信をするため現在では使われませんが、)ユーザー名とパスワードの組み合わせで認証するというのはどのサイトでも見ますね。\n\nただ毎回パスワードを入力するのも面倒であったり、のぞき見されるリスクが増えます。ですので、アクセストークンを使うやり方が考えれます。一度、パスワードで認証した人に誰にもわからない秘密鍵のようなものを渡します。以降これで認証が可能です。必要があれば、有効期限を決めて再発行したりします。(サイトによって[いろいろ違う](https://qiita.com/r7kamura/items/3e03471e02ea9ab5902a#%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E3%83%88%E3%83%BC%E3%82%AF%E3%83%B3%E3%81%AB%E6%9C%89%E5%8A%B9%E6%9C%9F%E9%99%90%E3%82%92%E6%8C%81%E3%81%9F%E3%81%9B%E3%81%A6%E3%81%8A%E3%81%8F%E3%81%A8%E3%81%A1%E3%82%87%E3%81%A3%E3%81%A8%E5%AE%89%E5%85%A8)みたいです)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-10T23:15:49.097",
"id": "59627",
"last_activity_date": "2019-10-10T23:15:49.097",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36129",
"parent_id": "59490",
"post_type": "answer",
"score": 0
},
{
"body": "自己解決しました。\n\nフォーム定義\n\n```\n\n class BlogForm(forms.ModelForm):\n class Meta:\n model = Blog\n # 'author'はここで処理しない\n fields = ('title', 'text', 'category')\n \n```\n\nビュー内定義\n\n```\n\n class ScriptCreateView(generic.CreateView):\n model = Blog\n form_class = BlogForm\n template_name = 'creator/blog_create_form.html'\n success_url = reverse_lazy('Blog:home')\n \n def form_valid(self, form):\n # データベースに保存する前のモデルオブジェクトを変数に格納\n blog = form.save(commit=False)\n # ※ここでログインユーザ情報を渡す\n blog.author = self.request.user\n blog.save()\n # スーパーメソッドを呼び出しバリデーション(form.is_valid)を行う\n return super().form_valid(form)\n \n```\n\n以上の処理で、投稿フォームにユーザ(PK)情報を含めずにDB登録できるようになりました。\n\nご回答していただいた方、ありがとうございます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-15T11:09:19.353",
"id": "59724",
"last_activity_date": "2019-10-15T11:09:19.353",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36021",
"parent_id": "59490",
"post_type": "answer",
"score": 0
}
] | 59490 | 59724 | 59627 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "### 実現したいこと\n\n * herokuにrailsアプリをデプロイしたい\n\n### 環境\n\n * Ruby 2.4.0\n\n * Ruby on Rails 5.1.6\n\n * bundler 2.0.1\n\n * Javascriptランタイム: node.js\n\n### 現在の状況\n\nvagrant環境ではrailsサーバの起動、ブラウザでの表示まで確認しています\n\n### 問題・エラーメッセージ\n\n * `git push heroku master`でデプロイに失敗します\n * heroku buildpacksがnode.jsに設定されてしまいます\n\nbuildpacksを指定しないでcreate後にgit push heroku master場合のエラーコード\n\n```\n\n 2019-10-03T21:33:48.503244+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 28886`\n 2019-10-03T21:33:50.666191+00:00 heroku[web.1]: Process exited with status 1\n 2019-10-03T21:33:50.708819+00:00 heroku[web.1]: State changed from starting to crashed\n 2019-10-03T21:33:50.712474+00:00 heroku[web.1]: State changed from crashed to starting\n 2019-10-03T21:33:50.586012+00:00 app[web.1]: /usr/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': Could not find 'bundler' (2.0.1) required by your /app/Gemfile.lock. (Gem::GemNotFoundException)\n 2019-10-03T21:33:50.586039+00:00 app[web.1]: To update to the lastest version installed on your system, run `bundle update --bundler`.\n 2019-10-03T21:33:50.586041+00:00 app[web.1]: To install the missing version, run `gem install bundler:2.0.1`\n 2019-10-03T21:33:50.586047+00:00 app[web.1]: from /usr/lib/ruby/2.5.0/rubygems.rb:263:in `bin_path'\n 2019-10-03T21:33:50.586049+00:00 app[web.1]: from /app/bin/bundle:3:in `<main>'\n \n```\n\nbuildpacksをheroku/rubyを指定してcreate後にgit push heroku masterした場合のエラーコード\n\n```\n\n remote: -----> App not compatible with buildpack: https://github.com/heroku/heroku-buildpack-ruby.git\n remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure\n remote:\n remote: ! Push failed\n remote: Verifying deploy...\n remote:\n remote: ! Push rejected to your-appname\n \n```\n\n### 試したこと\n\n * bundlerのバージョンを2.0.1に変更しGemfile.lockを再生成\n\n<https://qiita.com/haru52/items/c2e062f6e1c7d4ecfe49>\n\n * Gemfileが小文字のgemfileになっていたので修正\n\n<https://qiita.com/leavescomic1/items/ca938f4637b125da5bcf>\n\n * buildpacksをheroku/rubyを指定してデプロイ\n\n<https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-ruby>\n\n<https://dhtakeuti.hatenablog.com/entry/2018/12/11/142638>\n\n<https://devcenter.heroku.com/articles/buildpacks#detection-failure>\n\nなかなか解決できないのでよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T18:58:29.563",
"favorite_count": 0,
"id": "59491",
"last_activity_date": "2019-10-05T19:09:48.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25084",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby",
"heroku",
"rubygems",
"bundler"
],
"title": "railsアプリがherokuにデプロイできません",
"view_count": 233
} | [
{
"body": "`heroku buildpacks:set https://github.com/bundler/heroku-buildpack-bundler2`\nしてみるとどうでしょうか?",
"comment_count": 13,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-05T19:09:48.150",
"id": "59492",
"last_activity_date": "2019-10-05T19:09:48.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29695",
"parent_id": "59491",
"post_type": "answer",
"score": 0
}
] | 59491 | null | 59492 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "# やりたいこと\n\n_FirstView_ から _TableView_ へ画面遷移した時に,1月の値がインクリメントされ,値が多い順に上から _Cell_ に表示する.\n\n# これまでの流れ\n\n 1. 新しいプロジェクトを作成する.\n 2. _Firebase_ とアプリを接続する.\n 3. **写真1** のようにオブジェクトを配置する.\n 4. **コード1** と **コード2** を記述する.\n 5. **写真3** のように _Realtime Database_ を構成する.\n 6. プロジェクトを実行すると **写真4** のようになる.\n\n# 問題点\n\n1月が _Cell_ に表示されない. \n(インクリメントする月を変えても,そのインクリメントした月が表示されない.) \n(*print() _で_ Log*を監視しても表示がない.)\n\n# コード1\n\n_ViewController.swift_\n\n```\n\n import UIKit\n import Firebase\n \n class ViewController: UIViewController {\n \n var ref: DatabaseReference!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n self.ref = Database.database().reference().child(\"This\")\n }\n \n override func viewWillDisappear(_ animated: Bool) {\n super.viewWillDisappear(animated)\n \n self.ref.child(\"1月\").runTransactionBlock { (MutableData) -> TransactionResult in\n if let inc = MutableData.value as? Int {\n MutableData.value = inc + 1\n }\n return TransactionResult.success(withValue: MutableData)\n }\n }\n }\n \n```\n\n# コード2\n\n_TableViewController.swift_\n\n```\n\n import UIKit\n import Firebase\n \n class TableViewController: UITableViewController {\n \n @IBOutlet var list: UITableView!\n var ref: DatabaseReference!\n var rank = [(key: String, value: Int)]()\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n self.ref = Database.database().reference().child(\"This\")\n self.ref.observeSingleEvent(of: .value) { (DataSnapshot) in\n let namesArray = DataSnapshot.value as! [String: Int]\n self.rank = namesArray.sorted {$0.value > $1.value}\n self.list.reloadData()\n }\n }\n \n override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n return self.rank.count\n }\n \n override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n let cell = tableView.dequeueReusableCell(withIdentifier: \"listCell\", for: indexPath)\n cell.textLabel?.text = self.rank[indexPath.row].key\n cell.detailTextLabel?.text = String(self.rank[indexPath.row].value)\n return cell\n }\n }\n \n```\n\n# 写真1\n\n_Main.storyboard_ \n[](https://i.stack.imgur.com/DgS16.png)\n\n# 写真2\n\n構成 \n[](https://i.stack.imgur.com/MV4Ab.png)\n\n# 写真3\n\n_Firebase_ \n[](https://i.stack.imgur.com/4uoec.png)\n\n# 写真4\n\nデバイス上 \n[](https://i.stack.imgur.com/2jXSI.png)\n\n# 環境\n\nxcode : ver11.0 \nSwift : ver5.1 \niOS : ver13.1.2\n\n# 最後に\n\nお力をお貸しください.宜しくお願い致します. \n(分かり難所があれば言ってください)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T02:45:02.177",
"favorite_count": 0,
"id": "59500",
"last_activity_date": "2019-10-06T07:16:17.510",
"last_edit_date": "2019-10-06T07:16:17.510",
"last_editor_user_id": "3060",
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode",
"firebase",
"uitableview"
],
"title": "iOSアプリで画面遷移に伴うFirebaseのバグ",
"view_count": 110
} | [] | 59500 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "プログラミング初心者です。\n\n現在、Google Cloud Speech APIをしようしたアプリを作ろうとしています。\n\nこのAPIを使用して、ユーザーが発音した単語を結果として表示します。 \nその際に、複数の候補がある場合(例えば、ユーザーが「save」と発音した際、発音が悪く、「save」か「shave」なのかわからない)、saveとshaveの両方を結果として表示したいです。\n\n例えば、google translateでは、saveかshaveのどちらか一方が表示されます。 \nしかし、「発音チェック」というアプリでは(googleのAPI(たぶんspeech\nAPI)を使用)、発音が悪いと、saveとshaveの両方が表示されます。\n\n私は、発音チェックと同様の結果を表示したいです。\n\nどのようにすれば、発音チェックのように複数候補を結果として返すことができますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T02:48:09.460",
"favorite_count": 0,
"id": "59501",
"last_activity_date": "2020-07-06T21:06:55.700",
"last_edit_date": "2019-10-06T04:08:42.817",
"last_editor_user_id": "36090",
"owner_user_id": "36090",
"post_type": "question",
"score": 0,
"tags": [
"java",
"api",
"google-cloud"
],
"title": "音声認識APIを使用したアプリに関しての質問",
"view_count": 202
} | [
{
"body": "ご質問の「Google Cloud Speech API」と同じものかどうか分かりませんが、以下のページに概要が記述されていますので、参照してみてください。\n\n[Cloud Speech-to-Text の基本](https://cloud.google.com/speech-to-\ntext/docs/basics?hl=ja)\n\n> 音声同期認識リクエスト\n>\n> `maxAlternatives` \\-\n> (オプション、デフォルト`1`)レスポンスで表示する音声文字変換候補の数を示します。デフォルトでは、Speech-to-Text API\n> は最も可能性が高い音声文字変換候補を 1 つ表示します。別の変換候補も表示するには、`maxAlternatives`を 1\n> よりも大きな値に設定します。Speech-to-Text は、品質が十分であると判断された変換候補のみ返します。変換候補の表示は一般に、ユーザー\n> フィードバックを必要とするリアルタイムのリクエスト(音声コマンドなど)に適しているため、ストリーミング認識リクエスト向けです。\n>\n> Speech-to-Text API レスポンス\n>\n>\n> `alternatives`には`SpeechRecognitionAlternatives`型の音声文字変換テキスト候補のリストが格納されます。複数の変換候補が表示されるかどうかは、ユーザーが(maxAlternatives\n> に`1`より大きい値に設定して)複数の変換候補をリクエストしたかどうか、さらに Speech-to-Text\n> が十分に高品質の変換候補を生成したかどうかによって異なります。各変換候補は次のフィールドから構成されます。\n>\n> * `transcript`には音声文字変換テキストが含まれます。後述の音声文字変換テキストの処理をご覧ください。\n> * `confidence`には、Speech-to-Text の特定の音声文字変換テキストの信頼度を示す 0 から 1\n> までの値が格納されます。後述の信頼値の解釈をご覧ください。\n>\n\n>\n> 変換候補(alternatives)の選択\n>\n> 正常な同期認識レスポンス内の各結果に、1\n> つまたは複数(リクエストの`maxAlternatives`値が`1`より大きい場合)の`alternatives`が含まれる場合があります。Speech-\n> to-Text\n> で、変換候補の信頼値が十分に高いと判断された場合、その変換候補はレスポンスに含められます。レスポンスの最初の変換候補が、通常は最適な(最も可能性が高い)変換候補です。\n>\n>\n> `maxAlternatives`を`1`より大きい値に設定しても、複数の変換候補が返されるとは限りません。一般に、複数の変換候補は、ストリーミング認識リクエストによって結果を取得するユーザーにリアルタイムのオプションを提供する場合に適しています。\n\n* * *\n\n> 非同期リクエストとレスポンス\n>\n> LongRunningRecognize メソッドに対する非同期 Speech-to-Text API リクエストの形式は、同期 Speech-to-\n> Text API リクエストと同じです。\n>\n> 次にリクエストの完了後のすべてのレスポンスを示します。~途中省略~この型は、同期 Speech-to-Text API\n> 認識リクエストによって返される型と同じです。\n\n* * *\n\n> ストリーミング Speech-to-Text API 認証リクエスト\n>\n> `config` \\- (必須)RecognitionConfig\n> 型の音声の構成情報が含まれます。これは同期リクエストや非同期リクエストで指定するものと同じです。\n>\n> ストリーミング レスポンス\n>\n> `alternatives`には候補の音声文字変換リストが含まれます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T04:37:56.927",
"id": "59503",
"last_activity_date": "2019-10-06T04:37:56.927",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "26370",
"parent_id": "59501",
"post_type": "answer",
"score": 0
}
] | 59501 | null | 59503 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "タイトルの通りです。\n\n最近ATOMからVScodeに変更したのですが、自動補完機能のやり方がわかりません。\n\nATOMだったら、例えば、divなどを打った後にTABキーを打つと`<div></div>`のようになりますが、VScodeで同じようなやり方が、調べましたがわからないので、教えていただきたいです。\n\nMACを使ってます。\n\nよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T04:43:54.290",
"favorite_count": 0,
"id": "59504",
"last_activity_date": "2019-10-06T09:57:06.580",
"last_edit_date": "2019-10-06T07:18:03.653",
"last_editor_user_id": "20098",
"owner_user_id": "34645",
"post_type": "question",
"score": 1,
"tags": [
"vscode"
],
"title": "vscodeで自動補完機能のつけ方を教えて欲しいです。",
"view_count": 6897
} | [
{
"body": "VS Code\nでは多くのプログラミング言語に対して拡張機能によって自動補完を実装しており、どの言語のモードを使っているかによって自動補完のやり方や必要な拡張機能が異なります。また、いくつかの言語ではデフォルトで対応されています。\n\n質問文に書かれている HTML に関しては、公式ドキュメントが存在します:\n\n * [HTML in Visual Studio Code](https://code.visualstudio.com/docs/languages/html)\n\nここに書かれているとおり、デフォルト設定では `</` を打ったときに閉じタグが補完されます。また `Ctrl`+`Space`\nを押すと手動で補完を呼び出せます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T09:57:06.580",
"id": "59511",
"last_activity_date": "2019-10-06T09:57:06.580",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "59504",
"post_type": "answer",
"score": 1
}
] | 59504 | null | 59511 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "ubuntu for windows上でYOLOv3のwebカメラを用いたリアルタイムな物体検出がしたいと考えています。 \n各種サイトを見ながらOpenCVが動くところまで来たのですが、実際にYOLOv3を動かす段階で下記のようなエラーが出ました。\n\n```\n\n cv2.VideoCapture(0)\n >>VIDEOIO ERROR: V4L: can't open camera by index 0\n \n```\n\n調べた限り、このエラーを解決するには dev/video0 に使用可能なwebカメラを紐づければ良いようなのですが、その方法が分かりません。 \n何かご存じの方はいませんか? \n他にも、WSL上でwebカメラに接続する方法をご存じの方はその方法をご教授いただければ幸いです。\n\n参考にしたサイト: \n[Linux:\n利用できるWebカメラの情報を取得する](https://leico.github.io/TechnicalNote/Linux/webcam-usage) \n[VIDEOIO ERROR: V4L: can't find camera\ndevice](https://stackoverflow.com/questions/53007924/videoio-error-v4l-cant-\nfind-camera-device)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T05:46:44.660",
"favorite_count": 0,
"id": "59505",
"last_activity_date": "2019-10-06T07:30:04.200",
"last_edit_date": "2019-10-06T07:13:05.133",
"last_editor_user_id": "3060",
"owner_user_id": "36092",
"post_type": "question",
"score": 0,
"tags": [
"ubuntu",
"opencv",
"windows-10",
"wsl"
],
"title": "WSL(ubuntu)からwebカメラに接続したい",
"view_count": 4456
} | [
{
"body": "現在の標準で使えるWSLでは、まだサポートされていないようです。\n\n[/dev/video0 Camera support on WSL?](https://askubuntu.com/q/1020419)\n\n> Is there any way to pass the camera through to Windows Subsystem for Linux?\n> This feature would make everything I'm doing right now so much easier. I\n> know there is a feature request for USB support, but is there a workaround\n> for now? Can I setup a camera stream on my host and access the 'networked'\n> stream on the Ubuntu terminal?\n>\n> カメラをLinuxのWindows\n> Subsystemに渡す方法はありますか?この機能は、私が今していることすべてをとても簡単にします。USBサポートの機能リクエストがあることは知っていますが、今のところ回避策はありますか?ホストでカメラストリームをセットアップし、Ubuntuターミナルで「ネットワーク」ストリームにアクセスできますか?\n\n* * *\n\n> Alas, no, WSL doesn't support camera devices at this time. If this is\n> something you'd like to see in future releases, please find & upvote or file\n> an ask on the WSL UserVoice page.\n>\n> 残念ながら、現時点では、WSLはカメラデバイスをサポートしていません。 これが将来のリリースで見たいものである場合は、WSL\n> UserVoiceページで質問を見つけて、投票するか、質問を提出してください。\n\n現行のリポジトリを検索しても何も出てきません。 \n[We couldn’t find any code matching 'camera' in\nmicrosoft/WSL](https://github.com/microsoft/WSL/search?q=camera&unscoped_q=camera) \n[We couldn’t find any code matching 'video' in\nmicrosoft/WSL](https://github.com/microsoft/WSL/search?q=video&unscoped_q=video)\n\n* * *\n\nただし、今後出てくるはずのWSL2ならば、色々とサポートされていそうです。 \nリポジトリを検索すると、多数出てきます。 \n[Search - camera 770 code results in microsoft/WSL2-Linux-\nKernel](https://github.com/microsoft/WSL2-Linux-\nKernel/search?q=camera&unscoped_q=camera) \n[Search - video 3,283 code results in microsoft/WSL2-Linux-\nKernel](https://github.com/microsoft/WSL2-Linux-\nKernel/search?q=video&unscoped_q=video)\n\nWindows Insider programで先行テスト用のWindowsおよびそこで動作するWSL2が入手可能ならば、使えるかもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T06:08:37.270",
"id": "59506",
"last_activity_date": "2019-10-06T07:30:04.200",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "26370",
"parent_id": "59505",
"post_type": "answer",
"score": 1
}
] | 59505 | null | 59506 |
{
"accepted_answer_id": "59557",
"answer_count": 1,
"body": "**JavaScript**\n\n```\n\n var expr = 'Papayas';\n switch (expr) {\n case 'Oranges':\n <a herf=\"\">リンク</a>\n break;\n case 'Papayas':\n <div>準備</div>\n break;\n }\n \n```\n\n**Ajax**\n\n```\n\n .done((data)=>\n $('.result').append('<div></div><div></div>')\n \n })\n \n```\n\nJavaScriptのswitch条件式をAjaxのdoneに埋め込みたいです。 \n以下のように埋め込んだのですが、正しくはどのように入れたらいいのか分かりません教えていただきたいです。\n\n**JavaScript**\n\n```\n\n .done((data)=>\n var expr = 'Papayas';\n switch (expr) {\n case 'Oranges':\n <a herf=\"\">リンク</a>\n break;\n case 'Papayas':\n <div>準備</div>\n break;\n }\n $('.result').append('')\n \n })\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T07:17:01.873",
"favorite_count": 0,
"id": "59509",
"last_activity_date": "2019-10-08T04:20:53.037",
"last_edit_date": "2019-10-06T07:18:54.280",
"last_editor_user_id": "3060",
"owner_user_id": "32774",
"post_type": "question",
"score": 1,
"tags": [
"javascript"
],
"title": "ajaxのdoneに入れるjs条件式について",
"view_count": 174
} | [
{
"body": "通常通り変数を設定して、変数でappendに渡して上げましょう。\n\n```\n\n .done((data)=>\n var expr = 'Papayas';\n var append_content;\n switch (expr) {\n case 'Oranges':\n append_content = '<a herf=\"\">リンク</a>'\n break;\n case 'Papayas':\n append_content = '<div>準備</div>';\n break;\n }\n $('.result').append(append_content);\n \n })\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T04:20:53.037",
"id": "59557",
"last_activity_date": "2019-10-08T04:20:53.037",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22665",
"parent_id": "59509",
"post_type": "answer",
"score": 1
}
] | 59509 | 59557 | 59557 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Nuxt.jsの初学者です。Nuxt.jsのプロジェクトの作成をする際にESLintの利用を選択すると.eslintrc.jsが自動的に作成されpackage.jsonにもeslintが書かれているとことだったのですが作成したプロジェクトには.eslintrc.jsがありません。\n\n```\n\n nuxt-test\n ├── README.md\n ├── assets/\n ├── components/\n ├── layouts/\n ├── middleware/\n ├── node_modules/\n ├── nuxt.config.js\n ├── package-lock.json\n ├── package.json\n ├── pages/\n ├── plugins/\n ├── static/\n └── store/\n \n \n```\n\nChoose linting toolsはESLintを選択しました。 \n一点気がかりなのが\n\n<https://github.com/nuxt/create-nuxt-app> \n<https://ja.nuxtjs.org/guide/installation/>\n\n共に質問で\n\nCheck the features needed for your project\n\nがあるとのことでしたが聞かれませんでした。リポジトリのprompts.jsも \n確認しましたがありませんでした。\n\n代わりに\n\nChoose development tools\n\nの質問がありましたがこちら関係ありますでしょうか?\n\nまたもしよろしければESLint、Prettier周りの設定(.eslintrc.jsとVSCodeのsetting.json)はこうした方がいいよっていうのがあればご教示いただければと思います。\n\nよろしくお願いいたします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T07:37:22.110",
"favorite_count": 0,
"id": "59510",
"last_activity_date": "2019-10-06T07:37:22.110",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "34605",
"post_type": "question",
"score": 0,
"tags": [
"vue.js",
"nuxt.js"
],
"title": "Nuxt.jsのESlintとPrettierについて",
"view_count": 131
} | [] | 59510 | null | null |
{
"accepted_answer_id": "71966",
"answer_count": 1,
"body": "### C/C++/C#/Pythonで、ポインターごとの座標を取得したい\n\n環境:Ubuntu 18.04LTS \n使用マウス:USBマウス \nUbuntu環境では、xinputなどを用いることにより、複数のカーソル(ポインター)をそれぞれ1つずつ割り当てられた複数のマウスでコントロールすることができます。\n\nこれを利用し複数作ったポインターそれぞれの区別した座標を、プログラムから継続的に取得したいです。 \n例えるとすると、OpenSiv3DのCursor::Pos()を複数カーソルについて区別した、みたいな情報がほしいです。\n\n具体的には、xinputで出てくるデバイスのなかで、virtual core pointerや、2nd pointer、3rd\npointerなどのそれぞれ区別された座標の取得がしたいです。 \n区別されたというのは、どのマウスの情報かわからなくなることがない、ということです。 \nこのとき、どのデバイスからの情報からか識別できる必要はなく、その前のフレームで取得したどの情報と発信元が同じかという識別ができればよいです。\n\n調べても何もわからない状況なので、皆様のお力をお借りしたいです。\n\n### 試したこと\n\nxinputを用いてUSBマウスで複数ポインターをコントロールできた。 \nUbuntuのファイルシステムからPointerとつくファイルを探してそれぞれの機能を検索した。\n\n### 補足情報(FW/ツールのバージョンなど)\n\n使用CPU:Ryzen \n最終的にC#で制御を行いたいので、C#から呼び出しができる、C, C++, C#, Pythonなどの言語での解決をお願いします。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T11:51:56.550",
"favorite_count": 0,
"id": "59513",
"last_activity_date": "2020-11-15T11:53:11.147",
"last_edit_date": "2020-11-15T09:16:26.530",
"last_editor_user_id": "3060",
"owner_user_id": "36097",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"ubuntu"
],
"title": "複数のマウスポインターの座標をプログラムから区別して取得したい",
"view_count": 548
} | [
{
"body": "[こちらのコメント](https://ja.stackoverflow.com/questions/59513/%E8%A4%87%E6%95%B0%E3%81%AE%E3%83%9D%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%BC%E3%81%AE%E5%BA%A7%E6%A8%99%E3%82%92%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%A0%E3%81%8B%E3%82%89%E5%8C%BA%E5%88%A5%E3%81%97%E3%81%A6%E5%8F%96%E5%BE%97%E3%81%97%E3%81%9F%E3%81%84#comment64191_59513)で解決しました。ありがとうございました。\n\n> この辺が参考になるかも。[Linux Input\n> Subsystemの使い方](http://www.tatapa.org/%7Etakuo/input_subsystem/input_subsystem.html),\n> [The Linux input driver\n> subsystem](http://www.infradead.org/%7Emchehab/kernel_docs_pdf/linux-\n> input.pdf), [Linux /dev/input からマウスイベントを取得する](https://qiita.com/koara-\n> local/items/6484723d29afad4c3afb), [Linux の入力デバイスをカスタマイズ,\n> インプットデバイスの情報を表示する](http://yomi322.hateblo.jp/entry/2013/10/05/141654) –\n> [kunif](https://ja.stackoverflow.com/users/26370/kunif) 19年10月6日 15:58",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2020-11-15T07:14:01.357",
"id": "71966",
"last_activity_date": "2020-11-15T11:53:11.147",
"last_edit_date": "2020-11-15T11:53:11.147",
"last_editor_user_id": "32986",
"owner_user_id": "36097",
"parent_id": "59513",
"post_type": "answer",
"score": 0
}
] | 59513 | 71966 | 71966 |
{
"accepted_answer_id": "59643",
"answer_count": 1,
"body": "C#側からすでに開いているEdge画面を操作する方法についてご教示願います。\n\n**やりたいこと**\n\n①すでに開いているEdge(複数画面)から、一つの必要な画面を特定する \n②Edge画面のDOMを取得する \n③Edge画面の項目の値を検証し、間違ったら、該当項目に色を付ける \n④C#からEdge画面の遷移を発生させ、必要なデータを取得してから、 \n元のEdge画面に戻る。 \n⑤Edgeの画面でのボタン押下(Link 押下)イベントを検知し、 \n押下するタイミングに合わせて、C#側で処理を行わせる\n\nSelenium WebDriverから操作しようとしたが、既存Edge画面を一回閉じて \nWebDriverからEdgeプロセスを新規で起動して、必要な画面を開かなければならない。\n\n(現在の調査では)WebDriverからは【やりたいこと①】を実現できませんでした。\n\n**質問**\n\n 1. SeleniumWebDriverから既存Edge画面を閉じずに、そのままキャッチして、 \nDOMを取得し、更に、該当項目に背景色つけることは可能でしょうか?\n\n 2. 他にネイティブ部品、もしくは、サードパーティ製の部品で、 \nやりたいことを実現できる方法はあるでしょうか?\n\n 3. セキュリティの側面からして、そもそも、EdgeはIE11(mshtml.dll、 \nSHDocVw.InternetExplorer等で操作する)のように外部操作できないでしょうか?",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-06T23:22:05.187",
"favorite_count": 0,
"id": "59517",
"last_activity_date": "2019-10-11T13:31:13.257",
"last_edit_date": "2019-10-07T03:53:24.573",
"last_editor_user_id": "3060",
"owner_user_id": "26610",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"dom"
],
"title": "C#側からすでに開いているEdge画面を操作する方法についてご教示願います。",
"view_count": 7846
} | [
{
"body": "> 1. SeleniumWebDriverから既存Edge画面を閉じずに、そのままキャッチして、 \n> DOMを取得し、更に、該当項目に背景色つけることは可能でしょうか?\n>\n\nSeleniumの開発途中に実現できていた時もあったようですが、ブラウザ個別の特定モード/構成時のみなので、「実現不可能」状態のようです。 \n[Can Selenium interact with an existing browser\nsession?](https://stackoverflow.com/q/8344776/9014308) \n[Allow webdriver to attach to a running browser\n#18](https://github.com/seleniumhq/selenium-google-code-issue-\narchive/issues/18)\n\nその特定モードは、Chrome/Firefoxや次の?Edgeでは、デバッグポートを有効にして起動したブラウザと通信して操作が出来るという、これのことかも。 \n[Microsoft Edge DevTools Protocol Clients](https://docs.microsoft.com/ja-\njp/microsoft-edge/devtools-protocol/0.2/clients?view=azurermps-5.0.0) \n[How to connect Selenium to an existing browser that was opened\nmanually?](https://cosmocode.io/how-to-connect-selenium-to-an-existing-\nbrowser-that-was-opened-manually/) \n[デスクトップ版 Firefox\nのデバッグを行う](https://developer.mozilla.org/ja/docs/Tools/Remote_Debugging/Debugging_Firefox_Desktop)\n\n他に古い版数のSeleniumの機能に、こんなのがあるようです。 \n[Selenium Remote-Control](https://www.seleniumhq.org/projects/remote-control/)\n/ [Selenium 1 (Selenium RC) - Selenium\nDocumentation](https://www.seleniumhq.org/docs/05_selenium_rc.jsp)\n\n> 2. 他にネイティブ部品、もしくは、サードパーティ製の部品で、 やりたいことを実現できる方法はあるでしょうか?\n>\n> 3. セキュリティの側面からして、そもそも、EdgeはIE11(mshtml.dll、 \n> SHDocVw.InternetExplorer等で操作する)のように外部操作できないでしょうか?\n>\n>\n\nコメントで紹介した[【2017年8月版】起動中のMicrosoft EdgeからタイトルとURLを取得するC#コード](https://www.ka-\nnet.org/blog/?p=9085)の方法で、DOMのオブジェクト([IHTMLDocument2](https://docs.microsoft.com/en-\nus/previous-versions/windows/internet-explorer/ie-developer/platform-\napis/aa752574\\(v=vs.85\\)), [IHTMLDocument3](https://docs.microsoft.com/en-\nus/previous-versions/windows/internet-explorer/ie-developer/platform-\napis/aa752541\\(v=vs.85\\))等) が取得できましたし、単純なページで IHTMLDocument2::fgColor\nにより文字色を変えるとかが出来ました。\n\n細かい要素の検索とか変更は、IHTMLDocument3のオブジェクトを取得して操作した方が良いのでしょう。 \nC++での話ですが、こんな記事があります。 \n[MSHTML / ドキュメントとエレメント -\nEternalWindows](http://eternalwindows.jp/browser/mshtml/mshtml01.html)\n\nIHTMLDocument3オブジェクト取得は、紹介先のIHTMLDocument2オブジェクト取得ルーチンの中で使っているGUIDをIHTMLDocument3のものに変えることで出来ます。 \nGUIDは [open-watcom-v2/bld/w32api/lib/uuid.c](https://github.com/open-\nwatcom/open-watcom-v2/blob/master/bld/w32api/lib/uuid.c) とか\n[mingw-w64/mingw-w64-crt/libsrc/mshtml-\nuuid.c](https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-crt/libsrc/mshtml-\nuuid.c) から調べてください。\n\nただし、Edgeの1つのウィンドウに複数のタブがあって、表示してから時間が経過した場合、アクティブでないタブの情報は取れなくなっていました。 \n1ウィンドウ1タブにするよう注意しておいた方が良いでしょう。\n\nなお新しいEdgeは来年に出るそうで、しかも勝手にモードが切り替わるようなので、今上記のことが出来たとしても、何か不具合が起こる可能性は大きいですね。 \n[Chromiumベースの「Microsoft Edge」には「IE\nmode」あり](https://www.itmedia.co.jp/news/articles/1905/07/news050.html) \n[ChromiumベースのMicrosoft\nEdge、2020年5月から切り替え開始か](https://news.mynavi.jp/article/20190718-860627/)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-11T09:54:54.110",
"id": "59643",
"last_activity_date": "2019-10-11T13:31:13.257",
"last_edit_date": "2019-10-11T13:31:13.257",
"last_editor_user_id": "3060",
"owner_user_id": "26370",
"parent_id": "59517",
"post_type": "answer",
"score": 0
}
] | 59517 | 59643 | 59643 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "NSTextFieldについて2点ご教授ください。\n\n1.数値のみにしたいのですが、そのようなプロパティなどはありますでしょうか? \n2.2つTextFieldを用意し、別のTextFieldにカーソルが移った際に、 \n元のTextFieldの値をチェックしたいと思っているのですが、 \nイベントなどは拾えますでしょうか? \nkeyUpと、cursolUpdateというのがあったので、下記のように試したのですが、 \n両方のTextFieldからくるので判別方法などありますでしょうか?\n\n**ViewController.swift**\n\n```\n\n import Cocoa\n \n class ViewController: NSViewController {\n \n @IBOutlet weak var text1: NSTextField!\n @IBOutlet weak var text2: NSTextField!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n // Do any additional setup after loading the view.\n }\n \n override var representedObject: Any? {\n didSet {\n // Update the view, if already loaded.\n }\n }\n \n override func keyUp(with event: NSEvent) {\n print(\"keyUp\")\n }\n \n override func cursorUpdate(with event: NSEvent) {\n print(\"cursorUpdate\")\n } \n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T04:42:33.583",
"favorite_count": 0,
"id": "59522",
"last_activity_date": "2019-10-07T04:52:45.790",
"last_edit_date": "2019-10-07T04:52:45.790",
"last_editor_user_id": "3060",
"owner_user_id": "35619",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"macos"
],
"title": "swift4 macos NSTextFieldの入力文字制限とイベントについて",
"view_count": 250
} | [] | 59522 | null | null |
{
"accepted_answer_id": "59526",
"answer_count": 1,
"body": "AzureADにテナント(ディレクトリ)を作成してそこに複数のユーザー情報を登録してあります。\n\n質問1: \nAzureADに登録してあるユーザー情報をJavaアプリケーションのユーザー情報として連携したいと考えていますがJavaでAzureADのユーザー情報を取得することは可能でしょうか?\n\n質問2: \nJavaアプリケーションのログイン画面で入力したユーザ名とパスワードの組み合わせがAzureAD上に存在するかチェックしたいのですが可能でしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T05:09:32.553",
"favorite_count": 0,
"id": "59523",
"last_activity_date": "2019-10-07T06:42:32.950",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36102",
"post_type": "question",
"score": 0,
"tags": [
"java",
"azure"
],
"title": "AzureADに登録してあるユーザー情報をJavaで取得する方法",
"view_count": 1241
} | [
{
"body": "> 質問1: \n>\n> AzureADに登録してあるユーザー情報をJavaアプリケーションのユーザー情報として連携したいと考えていますがJavaでAzureADのユーザー情報を取得することは可能でしょうか?\n\nGraphAPIを使用して可能だと思います。 \n[Microsoft GraphAPI](https://docs.microsoft.com/ja-\njp/graph/api/resources/user?view=graph-rest-1.0)\n\nSCIMのリクエストでも可能だと思います。 \n<https://docs.microsoft.com/ja-jp/azure/active-directory/manage-apps/use-scim-\nto-provision-users-and-groups>\n\n> 質問2: \n> Javaアプリケーションのログイン画面で入力したユーザ名とパスワードの組み合わせがAzureAD上に存在するかチェックしたいのですが可能でしょうか?\n\nユーザ(ID)が存在すること というのは確認できますが、APIを使って存在するユーザのパスワードとのセットで検索することはできません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T06:36:03.437",
"id": "59526",
"last_activity_date": "2019-10-07T06:42:32.950",
"last_edit_date": "2019-10-07T06:42:32.950",
"last_editor_user_id": "24823",
"owner_user_id": "24823",
"parent_id": "59523",
"post_type": "answer",
"score": 0
}
] | 59523 | 59526 | 59526 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "以下の通りにAdapterとactivity_main.xmlを記述しています。 \nコメントアウトしてあるところを有効にすると、実行に失敗します。\n\nMainActivity.java内にメソッドをたくさん書いていますが、 \nAdapterをListViewに設定するところで落ちたり、 \nonCreateのsetContentView(R.layout.activity_main);で落ちたりしています。\n\n英語で調べましたが独学で限界です。\n\n何かわかる方いらっしゃったらよろしくお願い致します。\n\n* * *\n\n**BoolAndDateAdapter.java**\n\n```\n\n public class BoolAndDateBeanAdapter extends BaseAdapter {\n public BoolAndDateBeanAdapter(Context context) {\n this.context = context;\n this.layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n }\n \n Context context;\n LayoutInflater layoutInflater = null;\n ArrayList<BoolAndDateBean> beans;\n \n public void setBeans(ArrayList<BoolAndDateBean> beans) {\n this.beans = beans;\n }\n \n @Override\n public int getCount() {\n return beans.size();\n }\n \n @Override\n public Object getItem(int position) {\n return beans.get(position);\n }\n \n @Override\n public long getItemId(int position) {\n return 0;\n }\n \n @Override\n public View getView(int position, View convertView, ViewGroup parent) {\n convertView = layoutInflater.inflate(R.layout.activity_main,parent);\n \n // ((TextView)convertView.findViewById(R.id.bool)).setText(String.valueOf(beans.get(position).bool));\n // ((TextView)convertView.findViewById(R.id.hour)).setText(beans.get(position).hour);\n // ((TextView)convertView.findViewById(R.id.minit)).setText(beans.get(position).minit);\n return convertView;\n }\n }\n \n```\n\n**Activity_main.xml**\n\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <FrameLayout 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/container\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n tools:context=\".MainActivity\"\n tools:ignore=\"MergeRootFrame\">\n \n <RelativeLayout\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\">\n \n <ToggleButton\n android:id=\"@+id/toggleButton\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_gravity=\"center\"\n android:textOff=\"off\"\n android:textOn=\"on\"\n android:visibility=\"invisible\" />\n \n <com.google.android.material.floatingactionbutton.FloatingActionButton\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_alignParentRight=\"true\"\n android:layout_alignParentBottom=\"true\"\n android:layout_marginStart=\"20sp\"\n android:layout_marginLeft=\"20sp\"\n android:layout_marginTop=\"20sp\"\n android:layout_marginEnd=\"20sp\"\n android:layout_marginRight=\"20sp\"\n android:layout_marginBottom=\"20sp\"\n android:clickable=\"true\"\n android:onClick=\"OnClick_Add\"\n app:rippleColor=\"#00FCFCFC\"\n app:srcCompat=\"@drawable/ic_add_24dp\" />\n <GridLayout\n android:id=\"@+id/grid\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"120dp\"\n android:layout_marginTop=\"50dp\">\n <Button\n android:layout_width=\"60dp\"\n android:layout_height=\"60dp\"\n android:id=\"@+id/button0\"\n android:layout_row=\"0\"\n android:layout_column=\"0\">\n </Button>\n <Button\n android:layout_width=\"60dp\"\n android:layout_height=\"60dp\"\n android:id=\"@+id/button1\"\n android:layout_row=\"0\"\n android:layout_column=\"1\">\n </Button>\n <Button\n android:layout_width=\"60dp\"\n android:layout_height=\"60dp\"\n android:id=\"@+id/button2\"\n android:layout_row=\"0\"\n android:layout_column=\"2\">\n </Button>\n \n <Button\n android:id=\"@+id/button3\"\n android:layout_width=\"60dp\"\n android:layout_height=\"60dp\"\n android:layout_row=\"0\"\n android:layout_column=\"3\"></Button>\n </GridLayout>\n <ListView\n android:id=\"@+id/listview\"\n android:layout_width=\"100dp\"\n android:layout_height=\"100dp\"\n android:layout_below=\"@+id/grid\">\n <!--<TextView-->\n <!--android:id=\"@+id/bool\"-->\n <!--android:layout_width=\"50dp\"-->\n <!--android:layout_height=\"50dp\"/>-->\n <!--<TextView-->\n <!--android:id=\"@+id/hour\"-->\n <!--android:layout_width=\"50dp\"-->\n <!--android:layout_height=\"50dp\"/>-->\n <!--<TextView-->\n <!--android:id=\"@+id/minit\"-->\n <!--android:layout_width=\"50dp\"-->\n <!--android:layout_height=\"50dp\"/>-->\n </ListView>\n \n </RelativeLayout>\n </FrameLayout>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T06:00:57.643",
"favorite_count": 0,
"id": "59524",
"last_activity_date": "2019-10-07T07:23:08.270",
"last_edit_date": "2019-10-07T06:11:02.527",
"last_editor_user_id": "3060",
"owner_user_id": "36104",
"post_type": "question",
"score": 0,
"tags": [
"android",
"xml"
],
"title": "ListViewの中にTextViewを入れてAdapterで値を紐づけようとすると実行に失敗する",
"view_count": 146
} | [
{
"body": "ListViewの中に別のViewを入れていたことが原因でした。解決しました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T07:23:08.270",
"id": "59528",
"last_activity_date": "2019-10-07T07:23:08.270",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36104",
"parent_id": "59524",
"post_type": "answer",
"score": 0
}
] | 59524 | null | 59528 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "itamae で構築対象のEC2サーバーについてる EC2 Role に特定のポリシーを付与したいです\n\nどうするのがスマートかわからないので \nとりあえずリモートの hostname を取得して \nローカルで aws-sdk-ruby で同じ hostname になる ec2 インスタンスを探して\n\n```\n\n ec2 = Aws::EC2::Resource.new(region: 'ap-northeast-1')\n ec2.instances.each do |i|\n if i.private_dns_name == hostname\n \n \n```\n\nその中の role_id を取得して \nその role_id から role オブジェクトを作って \natttach policy を呼ぶ \nというかなり回りくどい方法しか思いつかないのですが \nスマートな方法はないでしょうか\n\nまたその場合リモートの hostname の結果をローカルの ruby 上で取得したいのですが \nitamae でリモートのシェル実行結果を取得することはどうすれば実現できますか\n\n### 追記\n\nec2_instance に IamInstanceProfile というプロパティはあるのですが \nRole に関しては出てきません \nAWS Console には Role が表示されるんですが \nこの EC2 Role はどうやって取得すればいいですか",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T08:42:58.440",
"favorite_count": 0,
"id": "59529",
"last_activity_date": "2019-10-18T06:06:55.850",
"last_edit_date": "2019-10-18T06:06:55.850",
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"itamae",
"aws-iam",
"aws-sdk"
],
"title": "対象の EC2 内から情報を取得し、そのEC2についている Role に policy を付与したい",
"view_count": 69
} | [] | 59529 | null | null |
{
"accepted_answer_id": "59555",
"answer_count": 1,
"body": "日本語で取得したツイートをCSVで出力する際に、文字化けします。 \nutf_8の代わりにshift_jisに変換しても文字化けします。 \n文字化けしない方法あれば、教えていただけますでしょうか。 \nお手数ですが、よろしくお願いいたします。\n\n```\n\n #ツイート取得\n tweet_data = []\n \n for tweet in tweepy.Cursor(api.user_timeline,screen_name = \"beechhangergals\",exclude_replies = True).items():\n tweet_data.append([tweet.id,tweet.created_at,tweet.text.replace('\\n',''),tweet.favorite_count,tweet.retweet_count])\n \n #csv出力\n with open('tweets.csv', 'w',newline='',encoding='utf_8') as f:\n writer = csv.writer(f, lineterminator='\\n')\n writer.writerow([\"id\",\"created_at\",\"text\",\"fav\",\"RT\"])\n writer.writerows(tweet_data)\n pass\n \n```",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T10:03:53.920",
"favorite_count": 0,
"id": "59530",
"last_activity_date": "2019-10-08T04:19:22.847",
"last_edit_date": "2019-10-07T10:12:29.510",
"last_editor_user_id": "32986",
"owner_user_id": "18859",
"post_type": "question",
"score": -1,
"tags": [
"python"
],
"title": "pythonの文字コード変換する",
"view_count": 387
} | [
{
"body": "Ubuntuの場合、lessとfileを以下でインストール可能です:\n\n```\n\n apt install less file\n \n```\n\n実行のテストを高速化させるため、以下の部分を修正してください:\n\n```\n\n for tweet in tweepy.Cursor(api.user_timeline,screen_name = \"beechhangergals\",exclude_replies = True).items():\n tweet_data.append([tweet.id,tweet.created_at,tweet.text.replace('\\n',''),tweet.favorite_count,tweet.retweet_count])\n break #breakを追加し、実行のテストを高速化する\n \n```\n\n次にスクリプトを実行し、以下のコマンドで開きます。\n\n```\n\n less tweets.csv\n \n```\n\nすると日本語が正常に表示されるはずです。文字のエンコードを確かめるためには以下を実行します:\n\n```\n\n file -i tweets.csv\n \n```\n\n[出力]\n\n```\n\n tweets.csv: text/plain; charset=utf-8\n \n```\n\nつまり、このスクリプトを実行することによって生成されるcsvのエンコードはutf-8です。\n\npythonのバージョンを確認するために、以下を実行します:\n\n```\n\n python --version\n \n```\n\nもし、バージョンが2系であれば、3系を試してください。\n\n```\n\n apt install python3 python3-pip\n python3 script.py\n \n```\n\n2019/10/08 時点では、少なくともtweepyのバージョンが `tweepy==3.8.0`\nであればスクリプトの実行は成功します。バージョンを最新にするために以下を実行してください。\n\n```\n\n pip3 install -U tweepy\n \n```\n\nExcelを使わずに、lessコマンド等で見るか、あるいはEmacsやVimのようなエディタで開いて試してください。\n\nもしこれらを行っても文字化けする場合、OSの言語設定を確認してください。Ubuntuの場合、言語設定の詳細は以下で確認できます: \n<https://help.ubuntu.com/stable/ubuntu-help/session-language.html.en>",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T04:11:24.957",
"id": "59555",
"last_activity_date": "2019-10-08T04:19:22.847",
"last_edit_date": "2019-10-08T04:19:22.847",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "59530",
"post_type": "answer",
"score": 1
}
] | 59530 | 59555 | 59555 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "下記の様な書き方は可能でしょうか? \ndoneのsearchResultでの結果を数分回したいのですが、どのように書けばいいのかわかりません。 \n上記で実行してみた結果ループは動きませんでした。ajaxの結果をどのように回すのか教えていただきたいです。\n\n* * *\n\nAjax\n\n```\n\n $(function(){\n $('#ajax').on('click',function(){\n \n $.ajax({\n url:'/home',\n type:'GET',\n data:{\n \n }\n })\n .done( (searchResult) => {\n \n $('result').html(searchResult);\n console.log(searchResult); console.log(searchResult);\n \n var total=searchResult;\n for(total i=0; i < 'searchResult';i++){\n $('.result').append('<tr><td>' + testingDateFrom + '</td><td>' + testingDateTo + '</td><td>' + competitionName + '</td><td>' + kitSendPrefecture + '</td><td>' + associationName + '</td><td>' + subAssociationName + '</td></tr>')\n }\n })\n \n```",
"comment_count": 10,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T10:29:23.540",
"favorite_count": 0,
"id": "59531",
"last_activity_date": "2019-10-07T11:17:50.933",
"last_edit_date": "2019-10-07T11:17:50.933",
"last_editor_user_id": "3060",
"owner_user_id": "35696",
"post_type": "question",
"score": 0,
"tags": [
"jquery",
"ajax"
],
"title": "ajax JavaScriptにfor文を埋め込みたい",
"view_count": 243
} | [] | 59531 | null | null |
{
"accepted_answer_id": "59574",
"answer_count": 1,
"body": "リモートでコマンドを実行してその結果を変数として使いたいです\n\n```\n\n host_name = `hostname`.strip\n \n```\n\nのような感じのことを\n\n```\n\n execute 'hostname'\n \n```\n\nの出力に対して行う方法はないでしょうか",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T11:58:47.310",
"favorite_count": 0,
"id": "59533",
"last_activity_date": "2019-10-08T12:26:27.907",
"last_edit_date": "2019-10-07T13:01:01.943",
"last_editor_user_id": "19110",
"owner_user_id": null,
"post_type": "question",
"score": 2,
"tags": [
"itamae"
],
"title": "itamae でリモートの実行結果をレシピ内で使う方法",
"view_count": 75
} | [
{
"body": "```\n\n host_name = run_command('hostname').stdout.strip\n \n```\n\nでできました",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T12:26:27.907",
"id": "59574",
"last_activity_date": "2019-10-08T12:26:27.907",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "59533",
"post_type": "answer",
"score": 2
}
] | 59533 | 59574 | 59574 |
{
"accepted_answer_id": "59545",
"answer_count": 1,
"body": "<https://github.com/RxSwiftCommunity/RxKeyboard>\n\nのREADMEには、\n\n> With Carthage, RxKeyboard only supports binary installation:\n\nCarthageの場合、バイナリーインストールのみサポートとあります。\n\nCarthageの仕組みをあまり把握していないのですが、\n\n```\n\n $ carthage update --platform ios --cache-builds --no-use-binaries\n \n```\n\nとした場合、 \n`--cache-builds`の意味は`ビルド済みのライブラリはスキップ` \n`--no-use-binaries`の意味は`そうでないライブラリはソースからコンパイル` \nと考えました。\n\nここで疑問なのですが、バイナリーインストールのみサポートとはどういうことなのでしょうか? \nなぜGitHubにソースコードがあるにもかかわらず、バイナリーを私達のローカルマシーンで作り出すことができないのでしょうか?\n\n今回の質問は、どちらかというと`RxKeyboard`の`Carthage`について **ということではなく** 、 \nより一般的に **Carthageにおけるソースコードとバイナリーの関係性** について教えていただきたいと考えております。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T12:19:55.747",
"favorite_count": 0,
"id": "59535",
"last_activity_date": "2019-10-07T23:03:37.910",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9008",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode",
"carthage"
],
"title": "Carthageでバイナリーインストールのみサポートということがなぜ起こるのでしょうか?",
"view_count": 365
} | [
{
"body": "RxKeyboardのリポジトリにはXcodeプロジェクトファイル(`*.xcodeproj`)が存在しないからです。\n\nCarthageはCocoaPodsやSwift Package Managerと異なり、ビルド設定はXcodeプロジェクトの仕組みをそのまま利用します。 \n(CocoaPodsはPodspecの内容からXcodeプロジェクトファイルを生成してビルドするし、Swift Package\nManagerは標準ではXcodeプロジェクトファイルを使用しません。)\n\n他のパッケージマネージャと異なり、Carthageは独自のビルドシステムを持たず、主な役割はパッケージ間の依存関係の解決のみを行います。\n\nそのため、Xcodeプロジェクトファイル(`*.xcodeproj`)がリポジトリにコミットされてない以上、Carthageは依存関係を解決して、リポジトリをチェックアウトするところまではできますが、ビルドすることはできません。\n\nそれが、このプロジェクトではCarthageはバイナリインストールのみ、ソースコードからのビルドはサポートされていない理由です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T23:03:37.910",
"id": "59545",
"last_activity_date": "2019-10-07T23:03:37.910",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "59535",
"post_type": "answer",
"score": 3
}
] | 59535 | 59545 | 59545 |
{
"accepted_answer_id": "59543",
"answer_count": 1,
"body": "上の表題にもある通り、二分探索木を利用して動的なハッシュマップを自分で作ろうとしたのですが、私が書いた以下のコードは実行しても入力に対して期待された出力をしません。 \nどのように以下のコードに改善すれば、期待された出力を得られるのでしょうか? \nとても読みづらいコードになってしまっていて申し訳ないのですが、アドバイスを頂けると大変助かります。\n\n実行したコード:\n\n```\n\n #include <stdlib.h>\n #include <stdio.h>\n #include <string.h>\n \n typedef struct tnode{ //二分木内のノード\n char* key;\n char* value;\n struct tnode* left;\n struct tnode* right;\n } tnode;\n \n tnode* btree_empty()\n {\n tnode* t;\n t = (tnode*)malloc(sizeof(tnode));\n t->key = (char*)malloc(sizeof(char)*100);\n t->value = (char*)malloc(sizeof(char)*100);\n t->left = NULL;\n t->right = NULL;\n return t;\n }\n \n tnode* btree_insert_helper(tnode* parent, char* key, char* val, tnode* t)\n {\n if(t == NULL){\n tnode* node = btree_empty();\n strcpy(node->key, key);\n strcpy(node->value, val);\n if(parent == NULL){\n ;\n }else if(strcmp(parent->key, node->key) < 0){\n parent->right = node;\n }else{\n parent->left = node;\n }\n return node;\n }\n int cmp = strcmp(key, t->key);\n if(cmp < 0){\n if(t->left == NULL){\n t->left = btree_empty();\n tnode* node = t->left;\n strcpy(node->key, key);\n strcpy(node->value, val);\n return node;\n }else{\n tnode* node = btree_insert_helper(t, key, val, t->left);\n return node;\n }\n }else if(cmp > 0){\n if(t->right == NULL){\n t->right = btree_empty();\n tnode* node = t->right;\n strcpy(node->key, key);\n strcpy(node->value, val);\n return node;\n }else{\n tnode* node = btree_insert_helper(t, key, val, t->right);\n return node;\n }\n }else{\n strcpy(t->value, val);\n return t;\n }\n }\n \n tnode* btree_insert(char* key, char* val, tnode* t)\n {\n return btree_insert_helper(NULL, key, val, t);\n }\n \n tnode** deletemin(tnode* node){\n tnode** res = (tnode**)malloc(2*sizeof(tnode*));\n if(node->left != NULL){\n tnode** temp = deletemin(node->left);\n tnode* min;\n node->left = temp[0];\n min = temp[1];\n res[0] = node;\n res[1] = min;\n }else{\n res[0] = node->right;\n res[1] = node;\n }\n return res;\n }\n \n tnode* btree_delete(char* key, tnode* t)\n {\n if(t == NULL){\n return NULL;\n }\n int cmp = strcmp(key, t->key);\n if(cmp < 0){\n t->left = btree_delete(key, t->left);\n return t;\n }else if(cmp > 0){\n t->right = btree_delete(key, t->right);\n return t;\n }else{\n if(t->left == NULL && t->right == NULL){\n return NULL;\n }else if(t->left != NULL && t->right == NULL){\n return t->left;\n }else if(t->left == NULL && t->right != NULL){\n return t->right;\n }else{\n tnode** temp = deletemin(t->right);\n tnode* right = temp[0];\n tnode* min = temp[1];\n free(temp);\n min->right = right;\n min->left = t->left;\n return min;\n }\n }\n }\n \n tnode* btree_search(char* key, tnode* t){\n int cmp = 0;\n tnode* result = NULL;\n \n if(t == NULL){\n result = NULL;\n }else{\n cmp = strcmp(key, t->key);\n if(cmp == 0){\n result = t;\n }else if(cmp < 0){\n result = btree_search(key, t->left);\n }else{\n result = btree_search(key, t->right);\n }\n }\n \n return result;\n }\n \n void btree_destroy(tnode* t)\n {\n if(t == NULL){\n ;\n }else{\n btree_destroy(t->left);\n btree_destroy(t->right);\n free(t->key);\n free(t->value);\n free(t);\n }\n return;\n }\n \n int main(){\n char command[100];\n char word[100];\n char tango[100];\n tnode *tree = NULL;\n tnode *temp = NULL;\n \n while(1){\n scanf(\"%s\", command);\n if(strcmp(command, \"insert\") == 0){\n scanf(\"%s %s\", word, tango);\n temp = btree_insert(word, tango, tree);\n if(tree == NULL){\n tree = temp;\n }\n }else if(strcmp(command, \"delete\") == 0){\n scanf(\"%s\", word);\n temp = tree_delete(word, tree);\n /*\n if(temp == tree->left){\n tree = tree->left;\n }else if(temp == tree->right){\n tree = tree->right;\n }else{\n ;\n }\n */\n }else if(strcmp(command, \"search\") == 0){\n scanf(\"%s\", word);\n temp = btree_search(word, tree);\n if(temp == NULL){\n printf(\"(not found)\\n\");\n }else{\n printf(\"%s\\n\", temp->value);\n }\n }else if(strcmp(command, \"quit\") == 0){\n break;\n }else{\n printf(\"ERROR\\n\");\n }\n }\n btree_destroy(tree);\n return 0;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T12:33:05.153",
"favorite_count": 0,
"id": "59536",
"last_activity_date": "2022-06-15T17:03:32.837",
"last_edit_date": "2022-06-15T17:03:32.837",
"last_editor_user_id": "31249",
"owner_user_id": "31249",
"post_type": "question",
"score": 3,
"tags": [
"c",
"アルゴリズム",
"binary-tree"
],
"title": "二分探索木を用いて英単語をキーとした連想配列を動的に作りたいが、連想配列が期待通りの動作をしてくれない。",
"view_count": 282
} | [
{
"body": "```\n\n temp = btree_delete(word, tree);\n \n```\n\nの行を\n\n```\n\n tree = btree_delete(word, tree);\n \n```\n\nに変えれば求める出力は得られます。\n\nコメントアウトしてある部分を見るに、何か気にかかることがあって敢えてこういう書き方をしなかったのかとも思いますが、全体の流れからするとこれが想定された用法でしょう。\n\n質問の趣旨から外れるので深入りしませんが一応付言しておくと、deleteの処理関連でメモリリークがあるので、そこは修正が必要です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T18:49:04.883",
"id": "59543",
"last_activity_date": "2019-10-07T18:49:04.883",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "33033",
"parent_id": "59536",
"post_type": "answer",
"score": 3
}
] | 59536 | 59543 | 59543 |
{
"accepted_answer_id": "59604",
"answer_count": 1,
"body": "お世話になっております。 \nApacheをインストールして、Nginxをリバースプロキシとして利用しています。 \nこの環境にPHP7.3-fpmを組み込んだのですが、存在しないPHPファイルにアクセスすると、下記のエラーが表示されます。\n\n```\n\n No input file specified.\n \n```\n\nこれをApacheの404エラーページが表示されるようにするには、どうしたらよいでしょうか。 \nちなみに、Nginxの設定ファイルを一部抜粋して掲載します。\n\n```\n\n server {\n root /home/example/public_html/example.com;\n server_name example.com;\n client_max_body_size 20M;\n \n location / {\n proxy_set_header Host $http_host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-Proto https;\n proxy_set_header X-Forwarded-Host $host;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_pass http://127.0.0.1:8080;\n proxy_redirect off;\n }\n \n location ~ \\.php$ {\n fastcgi_pass unix:/run/php/php7.3-fpm.sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n include fastcgi_params;\n }\n }\n \n```\n\n環境は、Ubuntu 18.04、Apache 2.4.29、Nginx 1.16.1です。 \n以上、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T14:36:50.863",
"favorite_count": 0,
"id": "59541",
"last_activity_date": "2019-10-09T14:57:12.303",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29034",
"post_type": "question",
"score": 0,
"tags": [
"php",
"apache",
"nginx"
],
"title": "Nginx+Apache環境でのPHP7.3-fpmの動作について",
"view_count": 229
} | [
{
"body": "パスが **.php** のときに、`if` 文を使って、ファイルが存在しなければ別の処理をするようにします。 \nNginx で 404 を返す例です。\n\n```\n\n location ~ \\.php$ {\n if (!-f $request_filename) {\n return 404;\n }\n fastcgi_pass unix:/run/php/php7.3-fpm.sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n include fastcgi_params;\n }\n \n```\n\nApache で 404 を返すのであれば、`return 404` の替わりに `proxy_pass` を使うとできそうです。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-09T14:57:12.303",
"id": "59604",
"last_activity_date": "2019-10-09T14:57:12.303",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4603",
"parent_id": "59541",
"post_type": "answer",
"score": 0
}
] | 59541 | 59604 | 59604 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "以下のコードに `\"Botton\n5\"`を追加するとして、`Botton5`を押した時、今までどのボタンを押したか履歴が表示されるようにするにはどう書き加えればよいでしょうか。\n\n```\n\n import javax.swing.*;\n import java.awt.event.*;\n import java.awt.BorderLayout;\n \n public class SwingTest extends JFrame implements ActionListener{\n JLabel label;\n \n public static void main(String[] args){\n SwingTest test = new SwingTest(\"SwingTest\");\n \n test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n test.setVisible(true);\n }\n \n SwingTest(String title){\n setTitle(title);\n setBounds( 10, 10, 300, 200);\n \n label = new JLabel(\"\");\n label.setHorizontalAlignment(JLabel.CENTER);\n \n JButton btn1 = new JButton(\"Button 1\");\n btn1.addActionListener(this);\n btn1.setActionCommand(\"Button 1\");\n \n JButton btn2 = new JButton(\"Button 2\");\n btn2.addActionListener(this);\n btn2.setActionCommand(\"Button 2\");\n \n JButton btn3 = new JButton(\"Button 3\");\n btn3.addActionListener(this);\n btn3.setActionCommand(\"Button 3\");\n \n JButton btn4 = new JButton(\"Button 4\");\n btn4.addActionListener(this);\n btn4.setActionCommand(\"Button 4\");\n \n JPanel p = new JPanel();\n p.add(btn1);\n p.add(btn2);\n p.add(btn3);\n p.add(btn4);\n \n getContentPane().add(p, BorderLayout.CENTER);\n getContentPane().add(label, BorderLayout.PAGE_END);\n }\n \n public void actionPerformed(ActionEvent e){\n String cmd = e.getActionCommand();\n \n if (cmd.equals(\"Button 1\")){\n label.setText(\"open\");\n }else if (cmd.equals(\"Button 2\")){\n label.setText(\"print\");\n }else if (cmd.equals(\"Button 3\")){\n label.setText(\"rename\");\n }else if (cmd.equals(\"Button 4\")){\n label.setText(\"move\");\n }\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-07T16:04:51.990",
"favorite_count": 0,
"id": "59542",
"last_activity_date": "2019-10-08T01:22:22.220",
"last_edit_date": "2019-10-07T16:55:36.230",
"last_editor_user_id": "3068",
"owner_user_id": "35992",
"post_type": "question",
"score": 0,
"tags": [
"java",
"swing"
],
"title": "swingで押されたボタンの履歴を表示したい",
"view_count": 290
} | [
{
"body": "履歴を保持する`ArrayList`などのフィールドを用意して、\n\n```\n\n private static List<String> history = new ArrayList<>();\n \n```\n\nボタンがクリックされたら、そこにラベルを追加して、表示すればいいと思います。\n\n```\n\n public void actionPerformed(ActionEvent e) {\n String cmd = e.getActionCommand();\n history.add(cmd);\n if (cmd.equals(\"Button 1\")) {\n label.setText(\"open\");\n } else if (cmd.equals(\"Button 2\")) {\n label.setText(\"print\");\n } else if (cmd.equals(\"Button 3\")) {\n label.setText(\"rename\");\n } else if (cmd.equals(\"Button 4\")) {\n label.setText(\"move\");\n } else if (cmd.equals(\"Button 5\")) {\n label.setText(history.toString());\n }\n }\n \n```\n\n表示の仕方などは工夫した方がいいと思いますが。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T01:22:22.220",
"id": "59548",
"last_activity_date": "2019-10-08T01:22:22.220",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "59542",
"post_type": "answer",
"score": 0
}
] | 59542 | null | 59548 |
{
"accepted_answer_id": "59551",
"answer_count": 2,
"body": "ボタンをクリックすることで、styleSheetを変更し、テーマカラー(背景色)を変えるように設定しました。\n\nここまでの設定はできたのですが、 \nlocalStorageを使って、変更したテーマカラー保存した状態にしたいのですが、 \nlocalStorageをどのように設定したらよいのかがわかりません。。\n\nlocalStorageを使用するのが初めてで、 \n保存するときは、`localStorage.setItem('Key', '保存する値');`などの情報があるのですが、 \nこれをどう扱っていけばよいのかがわかりません。。\n\n情報に不足部分があるかもしれませんが、ご教授いただけますと大変助かります。\n\n```\n\n //テーマカラーの切り替え\r\n function setHref($href) {\r\n var $elementReference = document.getElementById(\"s_theme\");\r\n $elementReference.href = $href;\r\n }\n```\n\n```\n\n <link rel=\"stylesheet\" href=\"normalmode.css\" id=\"s_theme\">\r\n \r\n <ul>\r\n <li>\r\n <button onclick=\"setHref('normalmode.css');\" class=\"normalmode\"></button>\r\n </li>\r\n <li>\r\n <button onclick=\"setHref('darkmode.css');\" class=\"darkmode\"></button>\r\n </li>\r\n <li>\r\n <button onclick=\"setHref('lightmode.css');\" class=\"lightmode\"></button>\r\n </li>\r\n </ul>\n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T01:00:58.623",
"favorite_count": 0,
"id": "59547",
"last_activity_date": "2019-10-08T02:45:14.347",
"last_edit_date": "2019-10-08T01:07:54.007",
"last_editor_user_id": "35901",
"owner_user_id": "35901",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"jquery"
],
"title": "localstorageを使って、テーマカラーを取得しテーマカラーを保存しておく方法",
"view_count": 120
} | [
{
"body": "setHrefでlocalStorageに保存。\n\n```\n\n function setHref($href) {\n var $elementReference = document.getElementById(\"s_theme\");\n $elementReference.href = $href;\n localStorage.setItem('key', $href); //ここで保存\n }\n \n```\n\nbodyのonload時などでlocalStorageから読みだして下記のような関数でセットします。\n\n```\n\n function getHref() {\n var $elementReference = document.getElementById(\"s_theme\");\n $elementReference.href = localStorage.getItem('key');\n }\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T02:44:29.710",
"id": "59550",
"last_activity_date": "2019-10-08T02:44:29.710",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19858",
"parent_id": "59547",
"post_type": "answer",
"score": 0
},
{
"body": "`setHref()`内で `localStorage.setItem(固定のキー文字列,\n$href)`して、ページロード時に`getItem(固定のキー文字列)`が`null`でない場合は`setHref()`を呼んでしまえばよいでしょう。\n\n```\n\n <link rel=\"stylesheet\" href=\"normalmode.css\" id=\"s_theme\">\n <script>\n function setHref($href) {\n var $elementReference = document.getElementById(\"s_theme\");\n $elementReference.href = $href;\n localStorage.setItem('theme_style', $href);\n }\n \n // このコードは文書ロード時に実行される前提\n let style = localStorage.getItem('theme_style');\n if (style !== null) {\n setHref(style);\n }\n </script>\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T02:45:14.347",
"id": "59551",
"last_activity_date": "2019-10-08T02:45:14.347",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3475",
"parent_id": "59547",
"post_type": "answer",
"score": 0
}
] | 59547 | 59551 | 59550 |
{
"accepted_answer_id": "59553",
"answer_count": 1,
"body": "Tkを使用して、Imageファイルを描画しているのですが、部分テストのために、一部のダイアログのみ描画配置などを確認するため、ソースコードを一部流用していました。 \n今まで動作していた以下の関数からエラーが発生しました。\n\n```\n\n def LoadImage(self):\n self.img_single = self._chk_image_file_(\".\\\\icon\\\\mon_s.gif\")\n \n self.img_single = ImageTk.PhotoImage(self.img_single)\n \n return\n \n```\n\nエラーの内容\n\n```\n\n RuntimeError: Too early to create image\n Exception ignored in: <bound method PhotoImage.__del__ of <PIL.ImageTk.PhotoImage object at 0x0000029C4F87A9E8>>\n Traceback (most recent call last):\n File \"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Anaconda3_64\\lib\\site-packages\\PIL\\ImageTk.py\", line 123, in __del__\n name = self.__photo.name\n AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'\n \n```\n\n全ソースコード\n\n```\n\n #! /usr/bin/env python3\n # -*- coding: utf-8 -*-\n \n import tkinter as tk\n from tkinter import ttk\n from PIL import Image,ImageTk,ImageDraw\n \n \n class class_Pattern_main(object): \n def __init__(self):\n \n self.screen_w = 300\n self.screen_h = 200\n self.dlg_pos_x = 10\n self.dlg_pos_y = 10\n self.dlg_pad = 4\n \n self.sticky = tk.N+tk.S+tk.E+tk.W\n \n self.LoadImage()\n \n \n def createMainWindow(self):\n \n obj = ttk.tkinter.Tk() \n \n geo_string = str(self.screen_w) + \"x\" + str(self.screen_h) + \"+\" + str(self.dlg_pos_x) + \"+\" + str(self.dlg_pos_y) \n \n obj.geometry(geo_string) \n \n return obj\n \n def _chk_image_file_(self,f_path):\n try:\n # ファイルを読み込んで64x64にリサイズ\n ret_obj = Image.open(f_path).resize((64,64))\n except IOError:\n #Logに残すとか\n msg_text = \"{0}{1}{2}\".format(self.log_header,\"指定されたアイコンファイルが読み込めません。\" ,f_path)\n \n # 代わりとなるイメージを作成して返す。\n ret_obj = Image.new('RGB',(64,64),(150,150,150))\n draw = ImageDraw.ImageDraw(ret_obj)\n draw.rectangle((4,4,60,60), fill = None, outline = (250,30,30),width=2)\n draw.line((60,4,4,60), fill = (250,30,30),width=2)\n \n return ret_obj \n \n def LoadImage(self):\n self.img_single = self._chk_image_file_(\".\\\\icon\\\\mon_s.gif\")\n \n self.img_single = ImageTk.PhotoImage(self.img_single)\n \n return\n \n def _PatternDialog(self, parent):\n \n self.dlg_width = 1260\n self.dlg_height = 680\n self.dlg_h_btn = 30\n self.dlg_pad = 8\n \n self.dev_dialog = tk.Toplevel(parent,background = 'aliceblue')\n \n title_str = \" イメージ表示 : \" \n \n self.dev_dialog.title(title_str)\n \n # MainWindowの表示位置を反映して表示位置を決めたい。\n \n self.dev_dialog.geometry(str(self.dlg_width) + \"x\"+ str(self.dlg_height) )\n \n _InFrame_ = ttk.Frame(\n self.dev_dialog\n )\n \n _Label_ = tk.Label(\n _InFrame_,\n image = self.img_single\n )\n \n \n _Label_.pack()\n _InFrame_.pack()\n \n \n if __name__ == '__main__':\n screen_obj = class_Pattern_main()\n \n MainWindow_obj = screen_obj.createMainWindow()\n \n MainWindow_obj.after(100,screen_obj._PatternDialog(MainWindow_obj))\n MainWindow_obj.mainloop()\n \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T02:53:58.030",
"favorite_count": 0,
"id": "59552",
"last_activity_date": "2020-05-10T11:02:00.213",
"last_edit_date": "2019-10-11T17:16:01.263",
"last_editor_user_id": "3060",
"owner_user_id": "32891",
"post_type": "question",
"score": 0,
"tags": [
"python3",
"tkinter",
"pil"
],
"title": "Python PIL ImageTkでRuntimeErrorが発生する。",
"view_count": 1096
} | [
{
"body": "結論として、呼び出しが早すぎました。 **init** ()において呼び出してしまっているのが原因です。 \n子ダイアログを表示させる_PatternDialog関数の先頭にself.LoadImage()を移動させました。 \n参考リンクは以下の通りです。\n\n[RuntimeError: Too early to create image - Stack\nOverflow](https://stackoverflow.com/questions/53861528/runtimeerror-too-early-\nto-create-image)\n\n修正したソースコード\n\n```\n\n #! /usr/bin/env python3\n # -*- coding: utf-8 -*-\n \n import tkinter as tk\n from tkinter import ttk\n from PIL import Image,ImageTk,ImageDraw\n \n \n class class_Pattern_main(object): \n def __init__(self):\n \n self.screen_w = 300\n self.screen_h = 200\n self.dlg_pos_x = 10\n self.dlg_pos_y = 10\n self.dlg_pad = 4\n \n self.sticky = tk.N+tk.S+tk.E+tk.W\n \n # ここではだめなのね\n #self.LoadImage()\n \n \n def createMainWindow(self):\n \n obj = ttk.tkinter.Tk() \n \n geo_string = str(self.screen_w) + \"x\" + str(self.screen_h) + \"+\" + str(self.dlg_pos_x) + \"+\" + str(self.dlg_pos_y) \n \n obj.geometry(geo_string) \n \n return obj\n \n def _chk_image_file_(self,f_path):\n try:\n # ファイルを読み込んで64x64にリサイズ\n ret_obj = Image.open(f_path).resize((64,64))\n except IOError:\n #Logに残すとか\n msg_text = \"{0}{1}{2}\".format(self.log_header,\"指定されたアイコンファイルが読み込めません。\" ,f_path)\n \n # 代わりとなるイメージを作成して返す。\n ret_obj = Image.new('RGB',(64,64),(150,150,150))\n draw = ImageDraw.ImageDraw(ret_obj)\n draw.rectangle((4,4,60,60), fill = None, outline = (250,30,30),width=2)\n draw.line((60,4,4,60), fill = (250,30,30),width=2)\n \n return ret_obj \n \n def LoadImage(self):\n self.img_single = self._chk_image_file_(\".\\\\icon\\\\mon_s.gif\")\n \n self.img_single = ImageTk.PhotoImage(self.img_single)\n \n return\n \n def _PatternDialog(self, parent):\n self.LoadImage()\n \n self.dlg_width = 1260\n self.dlg_height = 680\n self.dlg_h_btn = 30\n self.dlg_pad = 8\n \n self.dev_dialog = tk.Toplevel(parent,background = 'aliceblue')\n \n title_str = \" イメージ表示 : \" \n \n self.dev_dialog.title(title_str)\n \n # MainWindowの表示位置を反映して表示位置を決めたい。\n \n self.dev_dialog.geometry(str(self.dlg_width) + \"x\"+ str(self.dlg_height) )\n \n _InFrame_ = ttk.Frame(\n self.dev_dialog\n )\n \n _Label_ = tk.Label(\n _InFrame_,\n image = self.img_single\n )\n \n \n _Label_.pack()\n _InFrame_.pack()\n \n \n if __name__ == '__main__':\n screen_obj = class_Pattern_main()\n \n MainWindow_obj = screen_obj.createMainWindow()\n \n MainWindow_obj.after(100,screen_obj._PatternDialog(MainWindow_obj))\n MainWindow_obj.mainloop()\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T02:53:58.030",
"id": "59553",
"last_activity_date": "2019-10-11T17:17:09.800",
"last_edit_date": "2019-10-11T17:17:09.800",
"last_editor_user_id": "3060",
"owner_user_id": "32891",
"parent_id": "59552",
"post_type": "answer",
"score": 0
}
] | 59552 | 59553 | 59553 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "OWASP Session Management Cheat Sheet の Cookies > [Expire and Max-Age\nAttributes](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#expire-\nand-max-age-attributes)\nセクション([JPCERT日本語訳](https://jpcertcc.github.io/OWASPdocuments/CheatSheets/SessionManagement.html#Expire_and_Max-\nAge_Attributes))では、`Expires` 及び `Max-Age` が設定されていないクッキー(non-persistent\ncookies)はブラウザインスタンスが終了すれば強制的に消されるので、セッション管理にはこのnon-persistent cookiesを用いることを\n**強く推奨する(highly recommended)** 、とあります。\n\n一方で、この文章中に登場する「ブラウザインスタンスの終了」がどのタイミングを指すのか自明では無いのでは、という懸念があります。 \n例えば次のリンクにあるような挙動は(少なくとも私の)予想に反します。 \n(いずれも少し古い記述のようなので、現在もこの通りなのかはわかりませんが。)\n\n * [Chrome doesn't delete session cookies](https://stackoverflow.com/q/10617954/4506703) \\- Stack Overflow\n * [スマホブラウザでのセッションクッキーの有効期限](http://lab.informarc.co.jp/javascript/smartphone_session_cookie.html) \\- HTML5/CSS3, JavaScript 次世代WEB研究開発\n\n今回、有効期限を長くとも1時間程度のセッションを管理しようと考えています。\n\n上記のような挙動を考えると、persistent cookiesを用いても問題ないのでは(むしろnon-persistent\ncookiesよりは確実に管理(削除)できるのでは)、と考えたのですが、何か理解を誤っている/問題を見落としているでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T03:06:50.607",
"favorite_count": 0,
"id": "59554",
"last_activity_date": "2019-10-08T04:15:27.863",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"post_type": "question",
"score": 4,
"tags": [
"cookie",
"browser"
],
"title": "セッションを管理するクッキーに有効期限を設定すべきか否か",
"view_count": 2262
} | [
{
"body": "この問題はなかなか難しいですが、それでも私はセッション管理用Cookieの有効期限の設定は慎重であるべきだと思います。\n\nなぜなら、逆に意図せずセッションが残ってしまい、使い回しが発生する可能性があるからです。 \n例えば共有PCなども一律で一時間残す設定にしてしまうと、セッションが残ってしまう問題が起きてしまいます。 \nブラウザのセッションが維持されてしまう問題は情報管理部門では既知の問題として対策されている可能性が高く、大抵はセッションを維持してブラウザを起動しないように対策されていることもあると思います。 \nその場合は逆に有効期限があるとブラウザインスタンスを消したのにCookieのせいでセッションが残ってしまうという問題が発生してしまうでしょう。\n\n慎重であるべきと答えた理由としては、例えばこのサイトは \n「Cookieを1時間の有効期限で利用しています」とか「共有パソコンの方は有効期限を設定しない」的な、クライアント側で何らかの対応ができればより良いと思います。もちろん共有PCが使えないようなシステムだったりといった、環境や状況にもよるでしょう。\n\nまた、セッションはあくまで、ブラウザとサーバの情報の整合で使っているのでサーバ側のセッションの保持期間を短くしてしまうのも手です。 \n例えブラウザでセッションが残っていたとしてもサーバ側では一定期間で削除してしまうようにすれば、セッションの維持は難しくなるでしょう。もちろん利便性の問題もあるので、よく要件を確認する必要はあるとは思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T04:15:27.863",
"id": "59556",
"last_activity_date": "2019-10-08T04:15:27.863",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22665",
"parent_id": "59554",
"post_type": "answer",
"score": 1
}
] | 59554 | null | 59556 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "ラズベリーパイにMonoDevelopをインストールし、WindowsPCのVisualStudio2017で作ったC#のプログラム(GUI)をプロジェクトごとフォルダでコピーしたところ、\nMonoDevelopでソースをビルド(コンパイル)できません。 \nどうしたらいいのでしょうか。\n\nちなみにビルドするとMonoDevelopで以下のエラーメッセージが出力されます。\n\n```\n\n 331 \n インポートされたプロジェクト\n “/home/pi/,cache/MonoDevelop/7.0/MSBuild/1068_1/Microsoft.CSharp.Core.targets”\n が見つかりませんでした。\n <Import>宣言のパスが正しいかどうか、およびファイルがディスクに存在しているかどうかを確認してください。(MSB4019)\n \n```\n\nライン入力で`cd`と`ls`を使って調べたところ、フォルダ「1608_1」(ビルドするごとにこの数値は変化します)内に「Microsoft.CSharp.Core.targets」は見つかりませんでした(似た名前のファイルはたくさんありました)。 \n(C#では「using System?」などNet.Frameworksのライブラリが読み込まれてないようです。)\n\nところで、すでにWindowsPCでビルドした実行ファイルはラズパイで動作します。 \n大まかにWindowsPCのVisualStudioでプログラムを作り、細かいデバッグをターゲットマシンであるラズパイ上のMonoDevelopで調整したいのです。\n\nなお、ラズパイは産業向けのCM3+(32GB)とCMIOの組み合わせです。 \nラズビアンは10(buster)です。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T05:28:24.923",
"favorite_count": 0,
"id": "59558",
"last_activity_date": "2019-10-08T10:52:52.883",
"last_edit_date": "2019-10-08T10:52:52.883",
"last_editor_user_id": "36119",
"owner_user_id": "36119",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"raspbian"
],
"title": "ラズパイ上のMonoDevelopでC#ソースをビルドできません",
"view_count": 317
} | [] | 59558 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Unityのアニメーションはリアルタイムに合わせて再生される仕様ですが、 \nこれだとfpsが落ちているときにコマが飛ばされて再生されてしまいます。\n\nコマ落ちを避けるために、再生速度を0にして毎フレームAnimator.Update(1/fps)でアニメーションを進めようとしましたが、この方法だと処理速度が大幅に落ちてしまいました。\n\nAnimator.Playで毎フレーム再生位置を動かす方法も試してみたのですが、こちらだとAnimationEventが正常に動かず、Animatorの遷移もできません。\n\nコマ落ちを避け、AnimationEventも正常に動かすいい方法は何かないでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T05:47:25.297",
"favorite_count": 0,
"id": "59559",
"last_activity_date": "2019-10-08T05:47:25.297",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36118",
"post_type": "question",
"score": 2,
"tags": [
"unity3d",
"unity2d"
],
"title": "fps低下時のアニメーションのコマ落ちを避けたい",
"view_count": 279
} | [] | 59559 | null | null |
{
"accepted_answer_id": "59565",
"answer_count": 1,
"body": "表題の通り Anaconda 環境で pyinstaller を利用し実行ファイルを生成を行います。 \n実行ファイルを作るシステムに Numpy を含んでいるため MKL が含まれます。\n\nこの実行ファイルを有償配布を考えており、MKL の再配布に当たると考えられるのですが、intel との契約なしに配布しても大丈夫なのでしょうか",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T06:57:41.143",
"favorite_count": 0,
"id": "59562",
"last_activity_date": "2019-10-08T07:55:23.487",
"last_edit_date": "2019-10-08T07:55:23.487",
"last_editor_user_id": "3060",
"owner_user_id": "7978",
"post_type": "question",
"score": 0,
"tags": [
"python",
"ライセンス"
],
"title": "Anaconda 環境で pyinstaller を利用した際の MKL のライセンス",
"view_count": 831
} | [
{
"body": "有償化するソフトに関しては確認しておいた方が良いかもしれません。 \nまずは弁護士とか、自分の会社の法務部などに問い合わせることでしょうね。\n\n基本的にはランセンスの条項に従っていれば配布しても大丈夫なようです。\n\n[Home › Forums › Intel® Software Development Products › Intel® Math Kernel\nLibrary](https://software.intel.com/en-us/forums/intel-math-kernel-\nlibrary/topic/802160) \n質問\n\n> Hello MKL fans and sorry for such stupid question >.<\n>\n> We are some open Source developer who working at the moment on a project\n> called \"NumSharp\" which shall offers the same APIs from numpy but for .NET\n> languages.\n>\n> When implementing LAPACK functionalities we saw that there are multiple\n> lapack providers (or LAPACK libs) like NetLib standard LAPACK, MKL, ....and\n> so want to give users the possibility to choose free which licensed provider\n> they want to use.\n>\n> Sure MKL is one of the most popular. Since anaconda distro using the MKL lib\n> in so many packages like numpy - we was thinking about offering MKL and\n> different other LAPACK providers (native libs) as .NET package / nuget\n> package.\n>\n> Licensing is always a sensitive topic and so we were discussing in\n> <https://github.com/SciSharp/NumSharp/issues/116>.\n>\n> Now our question\n>\n> is it allowed to distribute the MKL dlls in package like nuget or is it\n> totally forbitten and everybody has to install by him or herself?\n>\n> Sorry for this question but we do not want to do sth wrong and so better ask\n> then do.\n>\n> Wish all a nice day and thanks for your time.\n\n回答\n\n> Hi ,\n>\n> please refer here : [license FAQ](https://software.intel.com/en-\n> us/mkl/license-faq)\n>\n> you won't have a problem redistributing it.\n>\n> Thank you\n\n* * *\n\nFAQの抜粋 \n[Intel® Math Kernel Library License FAQ](https://software.intel.com/en-\nus/mkl/license-faq)\n\n> This information is for general guidance. For the licensing terms for Intel®\n> Math Kernel Library (Intel® MKL), consult the Intel Simplified Software\n> License (ISSL).\n>\n> [Intel Simplified Software License](https://software.intel.com/en-\n> us/license/intel-simplified-software-license)\n>\n> **Can I redistribute Intel MKL?** \n> Yes, redistribution is allowed per the terms of the ISSL.\n>\n> **Do I need to pay royalty fees when I redistribute this library?** \n> No, there are no royalty fees.\n>\n> **Are there limits to the number of copies of my application that I can\n> distribute with this resource?** \n> No, there are no redistribution limits.\n>\n> **Is including this library in a publicly-available container such as\n> Docker* allowed?** \n> Yes, you can include Intel MKL in a public container.\n>\n> **Can I install and use this resource on cloud servers from providers such\n> as Amazon Web Services (AWS)*?** \n> Yes, you are allowed to perform these actions on any cloud server.\n>\n> **To benefit multiple users, can I install and make this library available\n> on a cluster?** \n> Yes, you can install Intel MKL on a cluster and provide it to users.\n>\n> インテルMKLを再配布できますか? \n> はい、ISSLの条項に従って再配布が許可されています。\n>\n> このライブラリを再配布する際にロイヤリティ料を支払う必要がありますか? \n> いいえ、ロイヤリティ料はかかりません。\n>\n> このリソースで配布できるアプリケーションのコピーの数に制限はありますか? \n> いいえ、再配布の制限はありません。\n>\n> このライブラリをDocker *などの公開されているコンテナーに含めることは許可されていますか? \n> はい、インテルMKLをパブリックコンテナーに含めることができます。\n>\n> Amazon Web Services(AWS)*などのプロバイダーからクラウドサーバーにこのリソースをインストールして使用できますか? \n> はい、クラウドサーバーでこれらのアクションを実行できます。\n>\n> 複数のユーザーに利益をもたらすために、クラスターにこのライブラリをインストールして利用可能にできますか? \n> はい。インテルMKLをクラスターにインストールして、ユーザーに提供できます。\n\n* * *\n\nライセンスの抜粋 \n[Intel Simplified Software License (Version April\n2018)](https://software.intel.com/en-us/license/intel-simplified-software-\nlicense)\n\n> Copyright (c) 2018 Intel Corporation.\n>\n> Use and Redistribution. You may use and redistribute the software (the\n> “Software”), without modification, provided the following conditions are\n> met:\n>\n> * Redistributions must reproduce the above copyright notice and the\n> following terms of use in the Software and in the documentation and/or other\n> materials provided with the distribution.\n>\n> * Neither the name of Intel nor the names of its suppliers may be used to\n> endorse or promote products derived from this Software without specific\n> prior written permission.\n>\n> * No reverse engineering, decompilation, or disassembly of this Software is\n> permitted.\n>\n> 使用と再配布。次の条件が満たされている場合、お客様は修正なしでソフトウェア(「ソフトウェア」)を使用および再配布できます。\n>\n> *再配布では、上記の著作権表示および以下のソフトウェアの使用条件、および配布で提供されるドキュメントおよび/またはその他の資料を複製する必要があります。\n>\n>\n> *事前の書面による特別な許可なしに、Intelの名前もサプライヤーの名前も、このソフトウェアから派生した製品を推奨または宣伝するために使用することはできません。\n>\n> *このソフトウェアのリバースエンジニアリング、逆コンパイル、または分解は許可されていません。\n\n以下省略",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T07:36:09.547",
"id": "59565",
"last_activity_date": "2019-10-08T07:43:35.390",
"last_edit_date": "2019-10-08T07:43:35.390",
"last_editor_user_id": "26370",
"owner_user_id": "26370",
"parent_id": "59562",
"post_type": "answer",
"score": 1
}
] | 59562 | 59565 | 59565 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "SQLServerの以下のデッドロックグラフがうまく解釈できません。\n\n[](https://i.stack.imgur.com/21E6V.png)\n\n(A)と(B)は、IDが同じなので、同一ページ(同一オブジェクト)と読み取れます。 \n更に、この同一のページに対して、プロセス363(左)とプロセス358(右上)がSIXロックを獲得していること(Owner Mode)も読み取れます。\n\n[SIXロックは、SIXロックと互換性が無い](https://docs.microsoft.com/ja-jp/sql/2014-toc/sql-\nserver-transaction-locking-and-row-versioning-guide?view=sql-server-2014#lock-\ncompatibility)はずなので、2つのプロセス(トランザクション)が、同じページのSIXロックを既に獲得している、ということが不可解です。 \nどの部分の解釈が間違っているのでしょうか?\n\n### 環境の情報\n\n * SQLServerのバージョンは2017 \n * トランザクション分離レベルは READ COMMITTED\n * Is Read Committed Snapshot On = False\n * スナップショット分離を許可 = False",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T07:26:18.207",
"favorite_count": 0,
"id": "59564",
"last_activity_date": "2019-10-08T07:26:18.207",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8078",
"post_type": "question",
"score": 2,
"tags": [
"sql-server"
],
"title": "同じページに対して2つのトランザクションがSIXロックを取得している?",
"view_count": 113
} | [] | 59564 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "SIPのインストールが上手く行かないです。 \n<https://www.riverbankcomputing.com/software/sip/download> \nここから、sip-4.19.8をダウンロード、展開し、そのディレクトリで\n\n```\n\n python configure.py --platform win32-g++\n \n```\n\nを実行したのち\n\n```\n\n make\n \n```\n\nを実行すると\n\n```\n\n make[1]: ディレクトリ `c:/Users/swall/python/sip-4.19.8/sipgen' に入ります\n makefile:29: 警告: ターゲット `.c.o' へのコマンドを置き換えます\n makefile:26: 警告: ターゲット `.c.o' への古いコマンドは無視されます\n make[1]: `all' に対して行うべき事はありません.\n make[1]: ディレクトリ `c:/Users/swall/python/sip-4.19.8/sipgen' から出ます\n make[1]: ディレクトリ `c:/Users/swall/python/sip-4.19.8/siplib' に入ります\n makefile:29: 警告: ターゲット `.c.o' へのコマンドを置き換えます\n makefile:26: 警告: ターゲット `.c.o' への古いコマンドは無視されます\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o siplib.o siplib.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from siplib.c:20:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n siplib.c: In function 'wrapInstance':\n siplib.c:1653:42: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]\n return sip_api_convert_from_type((void *)addr, wt->wt_td, NULL);\n ^\n siplib.c: In function 'parsePass2':\n siplib.c:5812:24: warning: 'enc' may be used uninitialized in this function [-Wmaybe-uninitialized]\n if (enc < 0)\n ^\n siplib.c:5708:32: warning: 'owner' may be used uninitialized in this function [-Wmaybe-uninitialized]\n *owner = arg;\n ~~~~~~~^~~~~\n siplib.c: In function 'slot_richcompare':\n siplib.c:11320:52: warning: 'st' may be used uninitialized in this function [-Wmaybe-uninitialized]\n if ((f = (PyObject *(*)(PyObject *,PyObject *))findSlot(self, st)) == NULL)\n ^~~~~~~~~~~~~~~~~~\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o apiversions.o apiversions.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from apiversions.c:20:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o descriptors.o descriptors.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from descriptors.c:20:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o qtlib.o qtlib.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from qtlib.c:21:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o threads.o threads.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from sipint.h:24,\n from threads.c:22:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o objmap.o objmap.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from sipint.h:24,\n from objmap.c:23:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o voidptr.o voidptr.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from voidptr.c:20:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o array.o array.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from array.c:20:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n gcc -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o int_convertors.o int_convertors.c\n In file included from C:\\python\\Python3.5.2\\include/Python.h:65,\n from int_convertors.c:38:\n C:\\python\\Python3.5.2\\include/pytime.h:112:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n C:\\python\\Python3.5.2\\include/pytime.h:117:12: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration\n struct timeval *tv,\n ^~~~~~~\n g++ -c -O2 -Wall -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\\python\\Python3.5.2\\include -o bool.o bool.cpp\n g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -shared -Wl,-subsystem,console -Wl,-s -o sip.pyd siplib.o apiversions.o descriptors.o qtlib.o threads.o objmap.o voidptr.o array.o int_convertors.o bool.o -LC:\\python\\Python3.5.2\\libs -lpython35\n c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\\python\\Python3.5.2\\libs/libpython35.a: error adding symbols: file format not recognized\n collect2.exe: error: ld returned 1 exit status\n make[1]: *** [sip.pyd] エラー 1\n make[1]: ディレクトリ `c:/Users/swall/python/sip-4.19.8/siplib' から出ます\n make: *** [all] エラー 2\n \n```\n\nのようにエラーが出てきてしまいます。\n\npython環境はvenvで作ったpython3.5.2です。\n\nお力添えいただけますと幸いです。\n\n(追記) \nコマンドはcmd.exeで入力しています。 \nmingw32とGnuWin32をインストールしています。OSはwindows10 64ビットです。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-08T08:13:31.573",
"favorite_count": 0,
"id": "59566",
"last_activity_date": "2019-10-10T03:15:20.973",
"last_edit_date": "2019-10-10T03:15:20.973",
"last_editor_user_id": "35820",
"owner_user_id": "35820",
"post_type": "question",
"score": 3,
"tags": [
"python",
"pyqt"
],
"title": "SIPのインストールが上手く行かないです。",
"view_count": 596
} | [] | 59566 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.