question
dict | answers
list | id
stringlengths 2
5
| accepted_answer_id
stringlengths 2
5
⌀ | popular_answer_id
stringlengths 2
5
⌀ |
---|---|---|---|---|
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Raspberry Pi 3 Model B上で動くOpenCVを用いたシステムの開発を行いたいのですが, 開発環境の設定方法がよくわかりません. \nそもそもプログラミングをRaspberry PiとWindows10のどちらでやった方がやりやすいのかもよくわからないので,\nおすすめの開発環境とその設定方法について教えていただけると幸いです. \nよろしくお願いします.\n\n-追記 \n・ 言語はC++を想定, Linuxは数ヶ月前に初めて触れるのでWindowsの方がまだ慣れていると思います.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T01:17:39.580",
"favorite_count": 0,
"id": "48523",
"last_activity_date": "2018-09-19T06:15:41.703",
"last_edit_date": "2018-09-19T02:08:46.960",
"last_editor_user_id": "30000",
"owner_user_id": "30000",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"opencv",
"raspberry-pi",
"windows-10"
],
"title": "Rasppberry Pi 3 Model B上で動作させるOpenCV を用いたシステムの開発環境について",
"view_count": 99
} | [
{
"body": "「Raspberry Pi 3 Model B上で動くOpenCVを用いたシステムの開発」をするのであれば、Raspberry pi\n3の環境(RaspbianなどのLinux系)に触らずに済ませる訳にはいきません。\n\nRaspberry piで動くシステムなら、Raspberry piのメジャーな開発環境で構築するのが素直だと思いますよ。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T06:15:41.703",
"id": "48537",
"last_activity_date": "2018-09-19T06:15:41.703",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "48523",
"post_type": "answer",
"score": 0
}
] | 48523 | null | 48537 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Spresense SDKのチュートリアルで、 \nブートローダーをインストールの際に、『key not specified』が二回出力されます。\n\n```\n\n root@ubuntu:~/tools/kconfig-frontends/spresense/sdk# ./tools/flash.sh -e ~/spresense-binaries-v1.0.000.zip\n Update succeed.\n root@ubuntu:~/tools/kconfig-frontends/spresense/sdk# \n root@ubuntu:~/tools/kconfig-frontends/spresense/sdk# ./tools/flash.sh -l ../firmware/spresense -c /dev/ttyUSB0\n >>> Install files ...\n install -b 115200\n Install ../firmware/spresense/loader.espk\n Waiting for XMODEM (CRC or 1K) transfer. Ctrl-X to cancel.\n ....................................................................................................................115984 bytes loaded.\n Key not specified.\n updater# install -b 115200\n Install ../firmware/spresense/gnssfw.espk\n Waiting for XMODEM (CRC or 1K) transfer. Ctrl-X to cancel.\n ......................................................................................................................................................................................................................................................................................................................................................................................................................................429984 bytes loaded.\n Key not specified.\n updater# sync\n updater# Restarting the board ...\n reboot\n \n```\n\nKey not specifiedのKeyとは何をさしているのでしょうか。 \nライセンスキーと思いましたが、そのようなものもありませんでした。\n\nHelloサンプルの動作確認は完了していますが、今後の開発の時に支障が起きない為に、 \n質問しています。\n\nボードはSPRITZERを使用していますが、SONYさんの公式サイトでは名前をSPRESENSEに変更したとの事、また、Arduino\nIDEでのLチカは確認済みであるため、ボードの影響はないです。\n\n何卒、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T02:12:54.877",
"favorite_count": 0,
"id": "48525",
"last_activity_date": "2018-10-02T01:49:20.150",
"last_edit_date": "2018-09-26T02:14:55.250",
"last_editor_user_id": "30164",
"owner_user_id": "30164",
"post_type": "question",
"score": 1,
"tags": [
"spresense"
],
"title": "Sony Spresenseにnuttx.spkをロード後のKey not specified.について",
"view_count": 372
} | [
{
"body": "ソニーのSPRESENSEサポート担当です。 \nお問い合わせの件について、回答いたします。\n\n一部のSPRITZER試作ボードは製品版のソフトウェアと互換性がないため、 \n\"Key not specified\" が表示されます。\n\n大変恐れ入りますが、製品版のSPRESENSEボードでお試しいただけるでしょうか。\n\nどうぞ、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-10-02T01:49:20.150",
"id": "48885",
"last_activity_date": "2018-10-02T01:49:20.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29520",
"parent_id": "48525",
"post_type": "answer",
"score": 2
}
] | 48525 | null | 48885 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "【質問経緯】\n\n 1. DockerをRHEL7.5 上に導入し、Docker Hubから最新のJenkinsのイメージをpull。\n 2. ただ、Jenkinsの公式が公開しているJenkinsイメージのバージョンが2.6.Xと古いため、 \npipeline等の一部のプラグインがインストールできません。\n\n 3. そこで、/var/lib/docker/overlay2/XXX(コンテナID?)/diff/usr/share/jenkins \nディレクトリ配下に存在するjenkins.warを、公式から落としてきた最新バージョンの物に \n差し替えてコンテナを立ち上げたところ、最新バージョンのjenkinsが立ち上がり、 \nプラグインのインストールも行える様になりました。\n\n【質問内容】 \nDocker Hub等で公開されているイメージのバージョンが古い場合、上記の様な対処方法で問題が \n無いか(そもそもDocker、Jenkinsが公式として想定している方法かどうか)に関しまして、 \nご存知の方がいましたら教えて頂ければ幸いです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T02:37:02.857",
"favorite_count": 0,
"id": "48526",
"last_activity_date": "2018-09-19T03:44:06.137",
"last_edit_date": "2018-09-19T03:03:36.283",
"last_editor_user_id": "19110",
"owner_user_id": "30165",
"post_type": "question",
"score": 0,
"tags": [
"docker",
"jenkins"
],
"title": "コンテナのファイルシステム内の一部ファイルの差し替えについて",
"view_count": 169
} | [
{
"body": "## Jenkinsのバージョンについて\n\n[公式Dockerhubレポジトリ](https://hub.docker.com/r/jenkins/jenkins/)のドキュメントから、[公式のDockerfile](https://github.com/jenkinsci/docker/blob/7e871e754b9e1a69791293af9cbe3501967856f4/Dockerfile#L45-L53)を確認したところ、2.121.1のバージョンが指定されているようです。また、念の為実際に自分でも`docker\npull jenkins/jenkins && docker run\njenkins/jenkins`というコマンドで確認したところ、2.141のJenkinsが起動しました。 \nそのため、おっしゃっているバージョンが古い問題はそもそも起きないはずです。 \nおそらく、[deprecatedの旧公式リポジトリ](https://hub.docker.com/_/jenkins/)を利用してしまっているか、あるいは`:lts`タグを使われているのではないでしょうか。\n\n## Dockerファイルの中身を差し替えて対処する方法に問題がないか\n\n実行すること自体に問題はないと考えられますが、Dockerを利用するメリットが失われているように感じます。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T03:08:10.257",
"id": "48527",
"last_activity_date": "2018-09-19T03:44:06.137",
"last_edit_date": "2018-09-19T03:44:06.137",
"last_editor_user_id": "29826",
"owner_user_id": "29826",
"parent_id": "48526",
"post_type": "answer",
"score": 2
}
] | 48526 | null | 48527 |
{
"accepted_answer_id": "48529",
"answer_count": 1,
"body": "プログラミング初心者です。 \n現在、Chromeの拡張機能開発を行っています。\n\nChromeの拡張機能をクリックするだけで、閲覧中のWEBサイトのURLを取得し、別タブでWEBサイトの表示速度が測定できる「Google\nPageSpeed Insights」に取得したURLが自動的に反映されるプログラムを制作しています。\n\n完成イメージとしては、閲覧中のサイト(stackoverflow)でChromeの拡張機能をクリックすることで、 \n[](https://i.stack.imgur.com/JoMu6.png)\n\n「Google PageSpeed Insights」のサイト内にある、URL入力欄に取得したURLが自動的に反映されるプログラムです。 \n[](https://i.stack.imgur.com/lYF2u.png)\n\n### 発生している問題・エラーメッセージ\n\njavascriptの「location.href」を活用して、閲覧中のサイトのURLを取得しようとしたのですが、うまくいきません。\n\n閲覧中のサイトのURLを「https://○○○」の形で取得できず、 \n「chrome-\nextension://afodfheljgloicekcifhieopgnbpibjm/_generated_background_page.html」の形で取得してしまいます。\n\n### 該当のソースコード\n\n**manifest.json**\n\n```\n\n {\n \"manifest_version\": 2,\n \"name\": \"page speed checker\",\n \"version\": \"2.0\",\n \"description\": \"閲覧中のサイトの表示速度を測定します\",\n \"icons\": {\n \"128\": \"page.png\"\n },\n \"browser_action\": {\n \"default_title\": \"page speed checker\",\n \"default_icon\": \"page.png\"\n },\n \"background\": {\n \"scripts\": [\"contents.js\"]\n },\n \n \"permissions\": [\n \"tabs\",\n \"http://*/*\",\n \"https://*/*\"\n ]\n }\n \n```\n\n**contents.js**\n\n`chrome.browserAction.onClicked.addListener(function()\n{void(window.open('https://developers.google.com/speed/pagespeed/insights/?url='+location.href));});`\n\n原因がわかる方がいましたら、教えていただきたいです。\n\njavascriptの「location.href」を使わない方が簡単にできるなどのご意見もありましたら、 \nお伝えいただけると嬉しいです。\n\n何卒よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T03:16:20.090",
"favorite_count": 0,
"id": "48528",
"last_activity_date": "2018-09-19T03:47:52.127",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30166",
"post_type": "question",
"score": 4,
"tags": [
"javascript",
"json",
"google-chrome",
"chrome-extension"
],
"title": "Chromeの拡張機能開発でJavaScriptの「location.href」が正しく動作しない",
"view_count": 2853
} | [
{
"body": "Chromeの拡張機能で現在開いているページを取得するために`location.href`を使用することはできません。 \n理由は少し難しいですが、「拡張機能のJavaScriptコードが動いているページ」と「ブラウザが現在開いているページ」が異なるためです(`location.href`で取得されるのは後者ではなく前者)。\n\n実はお使いの`chrome.browserAction.onClicked.addListener`APIではコールバック引数の第一引数として現在のタブを表す[Tabオブジェクト](https://developer.chrome.com/extensions/tabs#type-\nTab)が与えられています。 \nその`url`プロパティを調べることで現在のURLを得ることができます。具体的には以下のコードのように行います。\n\n```\n\n chrome.browserAction.onClicked.addListener(function(tab) { \n // 現在開いているURLを取得\n var url = tab.url; \n // 試しに表示してみる \n console.log(url); \n // Google PageSpeed Insightsを開く \n window.open('https://developers.google.com/speed/pagespeed/insights/?url='+url); \n });\n \n```\n\n* * *\n\nまた、多少ややこしいものの、`location.href`を用いる別の方法として[chrome.tabs.executeScript](https://developer.chrome.com/extensions/tabs#method-\nexecuteScript)を用いる方法もあるので一応紹介いたします。 \nこれは現在開いているページで特定のJavascriptコードを実行するものです。`window.open`を実行するコードを実行してやることで、`location.href`を用いて目的の動作をさせることができます。コードを文字列で与えている点が少し難しいので注意してください。\n\n```\n\n chrome.browserAction.onClicked.addListener(function() {\n chrome.tabs.executeScript({\n code: `\n window.open('https://developers.google.com/speed/pagespeed/insights/?url='+location.href);\n `,\n });\n });\n \n```\n\n* * *\n\nどちらの方法も、browser\naction内で[activeTabパーミッション](https://developer.chrome.com/extensions/activeTab)が与えられることを利用しています。manifest.json内の`permissions`内は`\"tabs\"`ではなく`\"activeTab\"`としても動作すると思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T03:26:16.603",
"id": "48529",
"last_activity_date": "2018-09-19T03:47:52.127",
"last_edit_date": "2018-09-19T03:47:52.127",
"last_editor_user_id": "30079",
"owner_user_id": "30079",
"parent_id": "48528",
"post_type": "answer",
"score": 6
}
] | 48528 | 48529 | 48529 |
{
"accepted_answer_id": "48540",
"answer_count": 1,
"body": "お世話になります。\n\nC#にて、フォームを生成して、BackgroundImageを設定した後、BackgroundImageLayoutをNoneに \nすれば、設定した画像は左上に表示されますが、これを右下に表示されることはできますでしょうか。もちろん、フォームの拡大・縮小に合わせて配置されるものとします。また、元の画像自体には一切手を加えないものとします。\n\n自分で考えた方法ですが、フォームの起動時、及びサイズ変更時にフォーム全体のサイズを図り、それに対するクライアント領域と同じサイズのイメージを生成し、そのイメージの右下に描画されるように背景の画像を描画した後、そのイメージをフォームの背景として設定する…などの方法があると \n思いましたが、そもそももっと簡単に設定だけで行うことはできますでしょうか?\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T04:59:28.107",
"favorite_count": 0,
"id": "48532",
"last_activity_date": "2018-09-19T06:45:43.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9374",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"form"
],
"title": "C# フォームの背景を右下に表示させたい",
"view_count": 210
} | [
{
"body": "`BackgroundImageLayout`プロパティは[ImageLayout](https://docs.microsoft.com/en-\nus/dotnet/api/system.windows.forms.imagelayout?redirectedfrom=MSDN&view=netframework-4.7.2)のみ設定可能ですので、「簡単に設定だけで」右下に表示することはできないと認識しています。\n\n本家SOの[類似質問](https://stackoverflow.com/questions/3707562/position-of-\nbackgroundimage-in-windows-\nform)では`OnPaintBackground`イベントで[再描画](https://stackoverflow.com/a/3707769)するコード例が紹介されています。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T06:45:43.550",
"id": "48540",
"last_activity_date": "2018-09-19T06:45:43.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "48532",
"post_type": "answer",
"score": 0
}
] | 48532 | 48540 | 48540 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "## わからないこと\n\nキャラ移動させる際にLookRotation()でキャラの向きを指定しているのですが、立ち止まった際にZ方向へ向きを元に戻してしまいます。解決策やアイデアがありましたらお教えいただければ幸いです。\n\n```\n\n using System.Collections;\n using System.Collections.Generic;\n using UnityEngine;\n \n public class CharacterMove : MonoBehaviour {\n \n public float walkSpeed; // 歩く速さ\n public float runSpeed; // 走る速さ\n \n private Vector3 moveDirection = Vector3.zero; // 移動する量\n private Vector3 direction; // 移動する方向\n private float x; // horizontal\n private float z; // vertical\n private float gravity = 98f; // 下方向への移動量\n private CharacterController controller; // character controller\n \n \n \n // Use this for initialization\n void Start () {\n // character controller 取得\n controller = GetComponent<CharacterController>();\n }\n \n // Update is called once per frame\n void Update () {\n \n // GetAxisを定義\n x = Input.GetAxis(\"Horizontal\");\n z = Input.GetAxis(\"Vertical\");\n \n direction = new Vector3(x, 0, z); // GetAxisから方向を取得\n \n if(Input.GetMouseButton(1)) { // 右クリックしながら移動するとダッシュ\n moveDirection = direction * runSpeed;\n } else {\n moveDirection = direction * walkSpeed;\n }\n \n \n // 地面についていなかったら下方向に落ちる\n if(controller.isGrounded) {\n moveDirection.y = 0f;\n } else {\n moveDirection.y -= gravity * Time.deltaTime;\n }\n \n // 移動する\n controller.Move(moveDirection * Time.deltaTime);\n \n // ここが問題のよう。移動中は回転するのだが、移動し終わると元の向きに戻ってしまう。\n Quaternion q = Quaternion.LookRotation(direction);\n transform.rotation = Quaternion.RotateTowards(transform.rotation, q, 1200.0f * Time.deltaTime);\n \n \n }\n }\n \n```\n\n## 試してみたこと\n\n * Lookrotationの部分を変えてみる\n``` Vector3 relativePos = target.position - transform.position;\n\n Quaternion rotation = Quaternion.LookRotation(relativePos);\n transform.rotation = rotation;\n \n```\n\nだめでした。\n\n * moveDirectionを引数に入れてみる\n``` Quaternion q = Quaternion.LookRotation(moveDirection);\n\n \n```\n\nだめでした。\n\n * x, zが入力されていないとき、returnする\n``` if(x == 0 && z == 0) {\n\n return;\n } else {\n direction = new Vector3(x, 0, z);\n }\n \n```\n\n行けるかと思いましたが、returnしてしまうとそれ以降の処理がされないので、空中で立ち止まると落下しなくなるようになってしまいました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T05:12:05.510",
"favorite_count": 0,
"id": "48533",
"last_activity_date": "2018-09-19T07:48:45.250",
"last_edit_date": "2018-09-19T07:07:32.983",
"last_editor_user_id": "30059",
"owner_user_id": "30059",
"post_type": "question",
"score": 2,
"tags": [
"c#",
"unity3d"
],
"title": "Character controllerで移動する際、移動する方向にキャラクターを向かせてもすぐに戻ってしまう。",
"view_count": 739
} | [
{
"body": "returnにすると処理が止まってしまうので、if文にしました。\n\n```\n\n if(x != 0 || z != 0) {\n direction = new Vector3(x, 0, z);\n }\n \n```\n\nこうすることで、「x, z が0ではない(入力されている)ときに、direction\nを更新する」という処理になり、立ち止まっていても方向がもとに戻ることなく、また、着地判定も継続して処理され、落下するようになりました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T07:48:45.250",
"id": "48545",
"last_activity_date": "2018-09-19T07:48:45.250",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30059",
"parent_id": "48533",
"post_type": "answer",
"score": 1
}
] | 48533 | null | 48545 |
{
"accepted_answer_id": "48539",
"answer_count": 1,
"body": "XcodeをVersion 10.0 (10A255)にバージョンアップしました。SwiftのプラグラムをiPhone8\nSimulatorで実行すると以下のエラーが表示されるようになりました。また、iPhone X/XR/XS/XS\nMaxのSimulatorでは以下のエラーは表示されません。なにか、地図関係か何かに変化があったのでしょうか? ご存知の方があれば ご教授ください。\n\n2018-09-19 14:41:26.945506+0900 VoiceToDo1[13120:353456] libMobileGestalt\nMobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T05:55:13.747",
"favorite_count": 0,
"id": "48534",
"last_activity_date": "2018-09-19T06:38:39.373",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21142",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode",
"swift4"
],
"title": "XcodeでMGIsDeviceOneOfType is not supported on this platform.と表示されてしまいます",
"view_count": 4803
} | [
{
"body": "同内容のスレッドが、AppleのDeveloper Forumsにありました。\n\n[What is\nMGIsDeviceOneOfType](https://forums.developer.apple.com/thread/103753)\n\n残念ながらAppleの技術者からのコメントはありませんが、「新しいSDKにありがちな、フレームワークの内部メッセージ(フレームワーク開発者が仕込んだデバッグメッセージ)だろう。今の所実害はないし無視して大丈夫そうだ。」と言うところに落ち着いたようです。\n\n本家StackOverflowのスレッドがこちら。\n\n[Xcode Error on Simulation](https://stackoverflow.com/q/50701321/6541007)\n\n回答ではなくコメントに「シミュレータじゃなくデバイスで実行(Xcode10正式版、10A255のこと)したらメッセージは出ない」と言う報告もあるので、やはり無視しても問題ないのではないかと思われます。\n\n何やら「自分はこうしたら解決した」と言うやり方を書いている方もいるのですが、それが正しい解決方法だと言う確証がないので、たまたまいろんな要因が重なってその時点で解決できたように見えただけ、と言う可能性も高そうです。\n\n下手に真似すると自分のプロジェクトを壊してしまう可能性もあるので、メッセージが出てくる以外に実害が無いのでしたら、無視した方が良いのではないかと思います。(AppleのSDKの一部には、そんなメッセージが出るものが時々あります。)",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T06:38:39.373",
"id": "48539",
"last_activity_date": "2018-09-19T06:38:39.373",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "48534",
"post_type": "answer",
"score": 2
}
] | 48534 | 48539 | 48539 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "productsの中にあるproduct_idの番号を取得してnameやmain_imageを取得してJqueryで表示させたい場合、どのような記述が必要なんでしょうか。おしえてください。\n\n```\n\n {\n \"products\": [\n {\n \"product_id\": \"11\",\n \"product_code_min\": \"inf02\",\n \"product_code_max\": \"inf02\",\n \"name\": \"インフルブロックのどあめ ブルーベリー味\",\n \"comment1\": null,\n \"comment2\": null,\n \"comment3\": null,\n \"main_list_comment\": \"<燕の巣を使った奇跡のキャンディ>\",\n \"main_image\": \"11020721_56369067217cb.jpg\",\n \"main_list_image\": \"11020721_563690672a095.jpg\",\n \"main_large_image\": \"11020721_56369067196de.jpg\",\n \"price01_min\": null,\n \"price01_max\": null,\n \"price02_min\": \"2500\",\n \"price02_max\": \"2500\",\n \"stock_min\": null,\n \"stock_max\": null,\n \"stock_unlimited_min\": \"1\",\n \"stock_unlimited_max\": \"1\",\n \"deliv_date_id\": \"2\",\n \"status\": \"1\",\n \"del_flg\": \"0\",\n \"update_date\": \"2017-08-24 10:14:46\",\n \"price01_min_inctax\": null,\n \"price01_max_inctax\": null,\n \"price02_min_inctax\": 2700,\n \"price02_max_inctax\": 2700,\n \"price01_min_format\": \"0\",\n \"price01_max_format\": \"0\",\n \"price02_min_format\": \"2,500\",\n \"price02_max_format\": \"2,500\",\n \"price01_min_inctax_format\": \"0\",\n \"price01_max_inctax_format\": \"0\",\n \"price02_min_inctax_format\": \"2,700\",\n \"price02_max_inctax_format\": \"2,700\",\n \"price01_min_tax_format\": \"0\",\n \"price01_max_tax_format\": \"0\",\n \"price02_min_tax_format\": \"2,700\",\n \"price02_max_tax_format\": \"2,700\",\n \"papc2\": {\n \"value_id\": \"103\",\n \"product_id\": \"11\",\n \"column_id\": \"2\",\n \"value\": \"11181905_564c4d7b4000e.jpg\",\n \"name\": \"サムネイル画像01\",\n \"type\": \"image\",\n \"required\": \"0\",\n \"max_length\": null\n },\n \"papc3\": {\n \"value_id\": \"104\",\n \"product_id\": \"11\",\n \"column_id\": \"3\",\n \"value\": \"01271507_588ae396af94a.jpg\",\n \"name\": \"サムネイル画像02\",\n \"type\": \"image\",\n \"required\": \"0\",\n \"max_length\": null\n },\n \"papc4\": {\n \"value_id\": \"101\",\n \"product_id\": \"11\",\n \"column_id\": \"4\",\n \"value\": \"東京都\",\n \"name\": \"原産地\",\n \"type\": \"text\",\n \"required\": \"0\",\n \"max_length\": \"50\"\n },\n \"papc5\": {\n \"value_id\": \"102\",\n \"product_id\": \"11\",\n \"column_id\": \"5\",\n \"value\": \"常温\",\n \"name\": \"常温・冷蔵・冷凍\",\n \"type\": \"text\",\n \"required\": \"0\",\n \"max_length\": \"50\"\n }\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T06:00:57.993",
"favorite_count": 0,
"id": "48536",
"last_activity_date": "2018-09-19T10:01:16.403",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25400",
"post_type": "question",
"score": 0,
"tags": [
"jquery",
"json"
],
"title": "Jsonの中にある情報の取り出し方を知りたい",
"view_count": 146
} | [
{
"body": "productsの内容をリスト表示するサンプルコードを知りたいという質問でしたら、下記のサンプルコードが参考になるでしょうか。\n\n```\n\n <html>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n <script src=\"https://code.jquery.com/jquery-3.3.1.min.js\"></script>\n <script>\n function showProducts() {\n var data = {\n \"products\": [\n {\n \"product_id\": \"11\",\n \"name\": \"インフルブロックのどあめ ブルーベリー味\",\n \"main_image\": \"11020721_56369067217cb.jpg\",\n \"papc2\": {\n \"value_id\": \"103\",\n \"product_id\": \"11\" \n }\n },\n {\n \"product_id\": \"12\",\n \"name\": \"タミフルブロックのどあめ ブラックベリー入り\",\n \"main_image\": \"11020721_56369067217cb.jpg\",\n \"papc2\": {\n \"value_id\": \"104\",\n \"product_id\": \"12\" \n }\n }\n ]}\n var products = data.products;\n for(var i in products){\n $(\"#output\").append(\"<li>\" + products[i].product_id + \" : \" + products[i].name + \"<img src=\\\"\" + products[i].main_image + \"\\\"/></li>\");\n }\n }\n </script>\n <body onload=\"showProducts()\">\n <ul id=\"output\"></ul>\n </body>\n </html>\n \n```\n\nもし「質問文のJSONが不正なのでエラーが発生する」「外部のURLからJSONが取得できない」「自作のスクリプトで期待通りの表示ができない」など、別の内容で困っているならば\n@OOPer さんの指摘通り、作成中のコードや要件を明示するとより適切な回答が得やすいと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T10:01:16.403",
"id": "48549",
"last_activity_date": "2018-09-19T10:01:16.403",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "48536",
"post_type": "answer",
"score": 2
}
] | 48536 | null | 48549 |
{
"accepted_answer_id": null,
"answer_count": 5,
"body": "配列の`[0]`には人名を、配列の`[1]`にはスコアが入っている二次元配列をまとめる方法を教えてください。\n\n* * *\n```\n\n score = [[\"taro\",10],[\"taro\", 70], [\"taro\", 170], [\"jiro\", 90], [\"jiro\", 55]]\n \n```\n\n求める出力\n\n```\n\n taro => 250\n jiro => 145\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T06:29:04.983",
"favorite_count": 0,
"id": "48538",
"last_activity_date": "2018-11-09T16:30:14.363",
"last_edit_date": "2018-09-19T06:38:24.943",
"last_editor_user_id": "3060",
"owner_user_id": "30169",
"post_type": "question",
"score": 2,
"tags": [
"ruby"
],
"title": "Ruby 二次元配列のまとめ方について教えてください。",
"view_count": 679
} | [
{
"body": "```\n\n score.group_by { |name, _| name }\n .map do |name, entries|\n [name, entries.map { |_, value| value }.sum]\n end.to_h\n \n```\n\nEnumerable クラスの、 `group_by`, `sum`, `map`, `to_h` を利用すると実現できます。\n\n<https://docs.ruby-lang.org/ja/latest/class/Enumerable.html>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T07:00:26.683",
"id": "48541",
"last_activity_date": "2018-09-19T07:00:26.683",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "48538",
"post_type": "answer",
"score": 1
},
{
"body": "配列を舐めて各キーごとにハッシュに突っ込む感じで作ってみました。\n\n```\n\n score_map = Hash.new()\n score.each{|pair|\n score_map.has_key?(pair[0])?score_map[pair[0]]+=pair[1]:score_map[pair[0]]=pair[1]\n }\n \n # => {\"taro\"=>250, \"jiro\"=>145}\n \n```\n\nもっとスマートなやり方があるかもしれません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T07:00:52.393",
"id": "48542",
"last_activity_date": "2018-09-19T07:00:52.393",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29826",
"parent_id": "48538",
"post_type": "answer",
"score": 0
},
{
"body": "```\n\n score = [[\"taro\", 10], [\"taro\", 70], [\"taro\", 170], [\"jiro\", 90], [\"jiro\", 55]]\n result = score.group_by do |s|\n s[0]\n end.map do |k, v|\n { k => v.sum{ |num| num[1] } }\n end\n puts result\n \n #=> [{\"taro\"=>250}, {\"jiro\"=>145}]\n \n```\n\nこんなのとか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T07:06:44.533",
"id": "48543",
"last_activity_date": "2018-09-19T07:26:02.817",
"last_edit_date": "2018-09-19T07:26:02.817",
"last_editor_user_id": "2383",
"owner_user_id": "2383",
"parent_id": "48538",
"post_type": "answer",
"score": 0
},
{
"body": "こういうのって、大喜利かコードゴルフ大会になるからあまり多くのパターンを出し過ぎるのもよくないんですが、私好みのコードの例がなかったので、参戦します。\n\n```\n\n score.group_by(&:first).transform_values { |a| a.sum(&:last) }\n \n```\n\n[`Hash#transform_value`](https://docs.ruby-\nlang.org/ja/latest/method/Hash/i/transform_values.html)と[`Array#sum`](https://docs.ruby-\nlang.org/ja/latest/method/Array/i/sum.html)は2.4.0からですので注意してください。`&:first`と言う表現は`:first`が`to_proc`で`Proc`になってブロックとして渡されるというものです。ブロックだらけになるのをある程度は防いでくれます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T10:42:14.040",
"id": "48554",
"last_activity_date": "2018-09-19T10:42:14.040",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7347",
"parent_id": "48538",
"post_type": "answer",
"score": 2
},
{
"body": "```\n\n score = [[\"taro\",10],[\"taro\", 70], [\"taro\", 170], [\"jiro\", 90], [\"jiro\", 55]]\n \n hash = {}\n score.each do |a|\n if hash[a[0]]\n hash[a[0]] = hash[a[0]] + a[1]\n else\n hash[a[0]] = a[1]\n end\n end\n \n pp hash\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-11-09T16:30:14.363",
"id": "50139",
"last_activity_date": "2018-11-09T16:30:14.363",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30913",
"parent_id": "48538",
"post_type": "answer",
"score": 0
}
] | 48538 | null | 48554 |
{
"accepted_answer_id": "48547",
"answer_count": 2,
"body": "MathMLという、数式をWEB上で表示するマークアップ言語を \nJavascriptから呼び出してHTML上で使用したいのですが、うまく行きません。\n\nJavascript側で以下のような関数を作って\n\n```\n\n function displayText()\n {\n var str = \"<math>\";\n str += \"<mi>i</mi>\";\n str += \"</math>\";\n \n var elem = document.getElementById(\"test\");\n elem.innerHTML = str;\n }\n \n```\n\nHTML側でボタンを押して以下のように呼び出しをします。\n\n```\n\n <div id=\"test\"></div>\n <input type=\"button\" value=\"MathML\" onclick=\"displayText()\">\n \n```\n\nすると、本来、以下のようにカッコいい数式用の「i」の文字が表示されるはずなのに \n[](https://i.stack.imgur.com/6sGp9.png)\n\n実際には以下のような普通の「i」しか表示されません。 \n[](https://i.stack.imgur.com/HlMTC.png)\n\nJavascriptを使用した時のみこの問題が起きていて \n普通にMathML+MathJaxを使ってもこの問題は起きません。 \n何か私のJavascriptやHTMLの使い方がおかしいのでしょうか?\n\n以下にサンプルのHTMLファイルをアップロードしました。\n\n・こちらがJavascriptを使った場合のサンプルです。 \nボタンを押すと、普通の「i」のみ表示されます。 \n<https://github.com/pekochun/test/blob/master/JavascriptWithMathML.html>\n\n・こちらがJavascriptを使わずにMathMLを直に書いた場合のサンプルです。 \nボタンを押す前から、カッコいい「i」が表示されます。 \n<https://github.com/pekochun/test/blob/master/NoJavascriptMathML.html>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T07:40:27.703",
"favorite_count": 0,
"id": "48544",
"last_activity_date": "2018-09-19T10:35:19.630",
"last_edit_date": "2018-09-19T10:35:19.630",
"last_editor_user_id": "22541",
"owner_user_id": "22541",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"html",
"html5"
],
"title": "数式をJavascriptから読み込んでHTML上に表示させたい(MathML+MathJax)",
"view_count": 1407
} | [
{
"body": "MathJaxを動的に使うには\n\n```\n\n MathJax.Hub.Typeset()\n \n```\n\nを利用する必要があります。 \n書き換えはなかなか重いのでターゲット要素を指定して実行したりしましょう。 \n<https://docs.mathjax.org/en/v1.0/typeset.html>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T07:56:45.763",
"id": "48546",
"last_activity_date": "2018-09-19T07:56:45.763",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22665",
"parent_id": "48544",
"post_type": "answer",
"score": 2
},
{
"body": "MathJaxのスクリプトは、ページを読み込んだ際にページのHTML中のMathML要素をかっこいい表示に変換します。 \nということは、JavaScriptで後からページにMathML要素を追加してもMathJaxによる処理が行われません。 \nこれが、ご提示のサンプルでかっこいい数式が表示されない理由です。\n\n後から追加したMathML要素をMathJaxに処理してもらうには、[MathJax.Hub.Typeset](http://docs.mathjax.org/en/latest/api/hub.html#Typeset)を用いるとよいようです。 \n具体的には以下のようにすると求める動作になりました。\n\n```\n\n <html>\n <head>\n <script async=\"\" src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML\"></script>\n <script type=\"text/javascript\">\n function displayText()\n {\n var str = \"<math>\";\n str += \"<mi>i</mi>\";\n str += \"</math>\";\n \n var elem = document.getElementById(\"test\");\n elem.innerHTML = str;\n \n // elemの中身をMathJaxに処理してもらう\n MathJax.Hub.Typeset(elem);\n }\n </script> \n </head>\n <body>\n <div id=\"test\"></div>\n <input type=\"button\" value=\"MathML\" onclick=\"displayText()\">\n </body>\n </html>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T07:59:27.703",
"id": "48547",
"last_activity_date": "2018-09-19T07:59:27.703",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30079",
"parent_id": "48544",
"post_type": "answer",
"score": 2
}
] | 48544 | 48547 | 48546 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "pythonについての質問です. \n初心者ですので,よろしくお願いします.\n\nコード上で,下記のような記載があります. \n意味が理解できないのですが,お教えいただけませんか? \n最後の「A,B=B,A」部分が理解できていません. \nイコールの両側にふたつずつ変数があるこの行はどういう意味なのでしょうか?\n\nよろしくお願いします.\n\n* * *\n```\n\n X=40\n Y=30\n A = zeros((X,Y),\"float64\")\n B = zeros((X,Y),\"float64\")\n \n A,B=B,A\n \n```\n\n* * *",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T10:07:42.710",
"favorite_count": 0,
"id": "48551",
"last_activity_date": "2018-09-19T10:38:27.153",
"last_edit_date": "2018-09-19T10:38:27.153",
"last_editor_user_id": "19110",
"owner_user_id": "30172",
"post_type": "question",
"score": 9,
"tags": [
"python",
"python3"
],
"title": "Python の A, B = B, A とはなに?",
"view_count": 2956
} | [
{
"body": "`A, B = B, A` は、2 つの変数 `A`, `B` の内容を入れ替えています。多重代入などと呼ばれており、「`B` の値を `A`\nに代入」と「`A` の値を `B` に代入」を同時に行っていると解釈できます。この代入の前後で `A`, `B` の内容を `print`\nすると分かりやすいです。\n\nPython 以外の言語だと、2 つの変数の入れ替え操作 (いわゆる swap 操作) は以下のように 3\nつ目の一時的な変数を用意して行うのが一般的なことがあります。\n\n```\n\n tmp = B\n B = A\n A = tmp\n \n```\n\nPython ではこれと同様のことを 1 行で書けます。\n\n```\n\n A, B = B, A\n \n```\n\nより正確には、この代入はタプルへのパックとシーケンスのアンパックで実現されています。つまり、右辺がタプル `(B, A)`\nとして解釈されたあと、そのアンパック操作が行われることで多重代入になっています。\n\n * 参考 \n * [5.3. タプルとシーケンス](https://docs.python.org/ja/3/tutorial/datastructures.html#tuples-and-sequences) -- Python 3 ドキュメント\n * [Pythonでタプルやリストをアンパック(複数の変数に展開して代入)](https://note.nkmk.me/python-tuple-list-unpack/) -- note.nkmk.me",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T10:11:57.047",
"id": "48552",
"last_activity_date": "2018-09-19T10:23:49.803",
"last_edit_date": "2018-09-19T10:23:49.803",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "48551",
"post_type": "answer",
"score": 14
}
] | 48551 | null | 48552 |
{
"accepted_answer_id": "48559",
"answer_count": 1,
"body": "Rubyで呼び出しごとに異なる乱数列が生成されるメソッドを作成したいです. \nD言語であれば unpredictableSeed のような感じです. \n仕様は以下のようです. \nご教授お願い致します.\n\n仕様: \n・randomSeed()呼び出しごとに異なる乱数列を生成する \n・返り値にとあるclassを返す\n\n```\n\n def randomSeed\n rnd = Random.new(rand(1000)) ← ここで呼び出しごとに異なる乱数列を生成する\n return class.new(rnd)\n end\n \n```\n\n補足: \nD言語ではこのように書けます\n\n```\n\n Class!xxx randomSeed()\n {\n Random rnd;\n rnd.seed(unpredictableSeed);\n return Class!xxx(rnd);\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T10:19:46.897",
"favorite_count": 0,
"id": "48553",
"last_activity_date": "2018-09-20T05:17:15.450",
"last_edit_date": "2018-09-20T05:17:15.450",
"last_editor_user_id": "30173",
"owner_user_id": "30173",
"post_type": "question",
"score": 2,
"tags": [
"ruby",
"random"
],
"title": "Rubyで呼び出しごとに異なる乱数列が生成されるメソッドを作成したい",
"view_count": 117
} | [
{
"body": "そのまま`Random.new`としてください。`Random.new`はシード値を引数として渡さない場合、[`Random.new_seed`](https://docs.ruby-\nlang.org/ja/latest/method/Random/s/new_seed.html)を呼び出し、その結果をシード値とします。`Random.new_seed`はシード値として適切な値を呼び出す毎にランダムに返します。\n\n```\n\n a = Random.new\n b = Random.new\n p a.seed\n p b.seed\n p a.rand\n p b.rand\n \n```\n\n上のコードを実行すれば、`a`と`b`でシード値が異なること、最初の乱数も異なることが確認できると思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T12:28:25.123",
"id": "48559",
"last_activity_date": "2018-09-19T12:28:25.123",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7347",
"parent_id": "48553",
"post_type": "answer",
"score": 4
}
] | 48553 | 48559 | 48559 |
{
"accepted_answer_id": "48593",
"answer_count": 1,
"body": "以下の関数を実行すると、上から投票数が多い順に\n\n```\n\n (例)\n 1.13.1.14: 8回\n 5.11.5.12: 3回\n 2.13.3.14: 1回\n \n```\n\n(1.13.1.14の部分が投票内容) \nといった感じで表示されるはずなんですが、たぶんソートの部分が間違ってて一番大きい投票結果が並び続けてしまいます。\n\n```\n\n (例)\n 1.13.1.14: 8回\n 1.13.1.14: 8回\n 1.13.1.14: 8回\n \n```\n\n教えてくれる方いたらよろしくおねがします。\n\n追記\n\n\"投票内容\"の中身は数値。今回は18になっています。 \n\"投票ボタンが押された回数\"の中身は、\n\n```\n\n (実際)\n 3.19.8.13\n 2.19.8.13\n 3.19.8.13\n 3.19.8.13\n 3.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.8.13\n 2.19.7.13\n 2.19.7.13\n \n```\n\nとなっています。理想では、show_votes()を実行すると、\n\n```\n\n (実際)\n 2.19.8.13:12回\n 3.19.8.13:4回\n 2.19.7.13:2回\n \n```\n\nと画面に表示されます。\n\n```\n\n function show_votes(){\n //数えたい。\n $vote_sofar = file(\"投票内容\");\n $times_vote = file_get_contents(\"投票ボタンが押された回数\");\n $int_times_vote = intval($times_vote);\n $vote_sofar_num = array();\n $maximum=0;\n \n for ($b=0 ; $b<$int_times_vote ; $b++){\n $number=0;\n $flag=0;\n if($b!=0){\n for ($c=$b-1 ; $c>=0 ; $c--){//前に重複があるならスキップして次のループへ。\n if($vote_sofar[$c] == $vote_sofar[$b]){\n $flag=1;\n }\n }\n }\n if($flag == 1){\n $vote_sofar_num[$b] = -1;\n continue;\n }\n for ($a=0 ; $a<$int_times_vote ; $a++){//以降に重複があればnumberをインクリメント。\n if($vote_sofar[$b]==$vote_sofar[$a]){\n $number++;//おなじ投票内容があれば数え上げる。\n } \n }\n $vote_sofar_num[$b] = $number;\n //echo $vote_sofar_num[$b];\n }\n $dd = 0;\n for ($b=0 ; $b<$int_times_vote ; $b++){\n $found_max = 0;\n if($vote_sofar_num[$b] > 0){\n for ($d=$b+1 ; $d<$int_times_vote ; $d++){//マキシマムを求める。\n $pos_max=$b;\n if($vote_sofar_num[$b] < $vote_sofar_num[$d]){\n $maximum = $vote_sofar_num[$d];\n $pos_max=$d;\n \n $found_max = 1; //見つけた。\n }\n \n }\n \n //求めたマキシマムと最上の値を交換。\n if ($found_max = 1){\n $vote_sofar_num[$pos_max] = $vote_sofar_num[$b];\n $vote_sofar_num[$b] = $maximum;\n \n $swap = $vote_sofar[$pos_max];\n $vote_sofar[$pos_max] = $vote_sofar[$b];\n $vote_sofar[$b] = $swap;\n }\n }\n }\n for($b=0 ; $b<$int_times_vote ; $b++){//ここで画面に表示。\n if($vote_sofar_num[$b] > 0){\n \n echo $vote_sofar[$b];\n echo \":\";\n echo $vote_sofar_num[$b];\n echo \"回\\n\";\n \n }\n }\n return;\n }\n \n```",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T11:32:57.660",
"favorite_count": 0,
"id": "48555",
"last_activity_date": "2018-09-20T09:33:41.337",
"last_edit_date": "2018-09-20T08:37:18.687",
"last_editor_user_id": "20666",
"owner_user_id": "20666",
"post_type": "question",
"score": 0,
"tags": [
"php",
"sort"
],
"title": "投票結果を投票数が多い順に並べ替えて表示したい",
"view_count": 193
} | [
{
"body": "私だったらこうします。 \nこれではだめですかね?\n\n```\n\n function showVotes()\n {\n $vote_sofar = file(\"投票内容\");\n \n //データをためるバケツを用意\n $backet = array();\n \n foreach($vote_sofar as $one_vote)\n {\n //キーの有無チェック\n if(array_key_exists($one_vote, $backet))\n {\n //既にキーがあれば数をインクリメント\n $num = $backet[$one_vote];\n $num++;\n $backet[$one_vote] = $num;\n }\n else\n {\n //キーが無ければ枠を用意\n $backet[$one_vote] = 1;\n }\n }\n \n //値で降順並べ替え\n arsort($backet);\n \n foreach($backet as $key => $value)\n {//ここで画面に表示。\n echo $key;\n echo \":\";\n echo $value;\n echo \"回\\n\";\n }\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T09:33:41.337",
"id": "48593",
"last_activity_date": "2018-09-20T09:33:41.337",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17014",
"parent_id": "48555",
"post_type": "answer",
"score": 3
}
] | 48555 | 48593 | 48593 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "基本的な質問で申し訳ありません。 \nSwiftでtableViewを使用する際にstoryboadでdatasourceとdelegateに紐付けをするのは何故ですか?色んなサイトでtableViewの使い方を見ていますが、紐付けをする場合としない場合があり違いがよく分かりません。どなたかご教授頂けると幸いです。よろしくお願い申し上げます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T11:49:08.603",
"favorite_count": 0,
"id": "48556",
"last_activity_date": "2018-09-20T07:43:00.623",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30174",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"tableview"
],
"title": "SwiftのtableViewの紐付けについて",
"view_count": 210
} | [
{
"body": "**datasourceについて** \nTableViewにデータを表示することができます。 \nその表示するデータの数、セクションの数、セルの内容などを返却する役割を担当するオブジェクトを指定します。 \nレコードの削除や挿入など、データに変更が加えられるときの通知もこちらが呼び出されます。 \nレコードの削除や挿入は応答するメソッドが実装されているかどうかで、操作の可否が決まったります。 \nTableViewを利用するには必須といえます。 \n仮に何も指定しないと、ただ線が表示されるだけのスクロールビューになるはずです。 \n詳細はこちらのApple公式をご覧ください。 \n<https://developer.apple.com/documentation/uikit/uitableviewdatasource>\n\n**delegateについて** \nセルの選択イベント等、TableView上でイベントが発生すると、delegateに指定されたオブジェクトが呼び出されます。 \nイベントごとに呼び出されるメソッドは様々で、受け取れるように実装されていないイベントは発生しても通知されません。 \n表示オンリーで何もイベントを受け取る必要がないTableViewには紐づける必要はありません。 \n詳細はこちらのApple公式をご覧ください。 \n<https://developer.apple.com/documentation/uikit/uitableviewdelegate>\n\n**datasourceやdelegateの紐づけについて** \ndatasourceやdelegateの紐づけ方法はStoryBoardで行う方法のほかに、コード上で記述することが可能です。 \nStoryBoardで紐づけていない場合はコード上で紐づけているのかもしれません。 \n以下のような感じで、TableViewのインスタンスのdatasourceプロパティやdelegateプロパティにオブジェクトを登録しているはずです。\n\n```\n\n self.tblView.datasource = self\n self.tblView.delegate = self\n \n```\n\n以上です。 \n間違い等ありましたらご指摘ください。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T07:43:00.623",
"id": "48587",
"last_activity_date": "2018-09-20T07:43:00.623",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17014",
"parent_id": "48556",
"post_type": "answer",
"score": 1
}
] | 48556 | null | 48587 |
{
"accepted_answer_id": "48558",
"answer_count": 1,
"body": "javascriptで指定したcookieの値を取り出す場合の参考で正規表現による取り出し方法がありましたが、なぜうまく値がとれているのかがあまり理解できません…\n\n> Document.cookie \n> <https://developer.mozilla.org/ja/docs/Web/API/Document/cookie>\n```\n\n> document.cookie = \"test1=Hello\";\n> document.cookie = \"test2=World\";\n> \n> var cookieValue =\n> document.cookie.replace(/(?:(?:^|.*;\\s*)test2\\s*\\=\\s*([^;]*).*$)|^.*$/,\n> \"$1\");\n> \n> function alertCookieValue() {\n> alert(cookieValue);\n> }\n> \n```\n\n```\n\n (?:(?:^|.*;\\s*)test2\\s*\\=\\s*([^;]*).*$)\n \n```\n\n↑ test2=以降の「;」を除いた文字列\n\n```\n\n |^.*$\n \n```\n\n↑ またはすべての文字列\n\nになると考えていたので、例えば「test2=World;test1=Hello;」だった場合は「Worldtest1=Hello」を返すのかと思っていたのですが、実行すると「World」が返ってきます。\n\n正規表現を調べたのですが、なぜ「World」だけが返ってくるのかが理解できませんでした。\n\n詳しい方がいらっしゃいましたら、なぜ「World」だけが返ってくるのかを詳しく教えていただきたいです。\n\n宜しくお願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T11:51:16.940",
"favorite_count": 0,
"id": "48557",
"last_activity_date": "2018-09-19T12:10:36.050",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29531",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"正規表現"
],
"title": "正規表現を使った値の取得について",
"view_count": 411
} | [
{
"body": "`[^;]*`の部分の意味を間違えていらっしゃると思います。 \n`[^;]`は **「`;`」以外のすべての文字** を表し、それに`*`がつくことにより、「`[^;]`がなるべく長く続く文字列」、つまり「\n**`;`以外の文字がなるべく長く続く文字列**」という意味になります。これは「全ての文字列から`;`を除く」という意味 **ではありません** 。\n\nこの正規表現は、`;`が来た時点で途切れます。`test2=World;test1=Hello;`という文字列だった場合は、`[^;]*`という正規表現がマッチするのは`World`の部分だけです。なぜなら、その次の`;`は`[^;]`に当てはまらないため、`;`が入ってしまうと「`;`以外の文字がなるべく続く文字列」ではなくなってしまい`[^;]*`の意味に反してしまうからです。\n\n* * *\n\nちなみに、replaceの第二引数の文字列中の`$1`は正規表現の括弧で囲まれた部分にマッチした文字列を取り出すという意味です。今回は正規表現中括弧で囲まれているのは`([^;]*)`なので、ここにマッチした文字列、すなわち`World`が取り出されます。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T12:10:36.050",
"id": "48558",
"last_activity_date": "2018-09-19T12:10:36.050",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30079",
"parent_id": "48557",
"post_type": "answer",
"score": 3
}
] | 48557 | 48558 | 48558 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "discordのbot作成でつまづきました。node.jsで作成し、foreverコマンドで動かしているのですが、リプライを何件も送るバグ(?)みたいなのがおきています。これはforeverコマンドの実行のたびに増えていきます。\n\n```\n\n //ログイン処理\n const Discord = require('discord.js');\n const client = new Discord.Client();\n const token = 'とーくん';\n client.on('ready', () => {\n console.log('ready...');\n });\n //Bot自身の発言を無視する呪い\n client.on('message', message =>{\n if(message.author.bot){\n return;\n }\n //↓ここに後述のコードをコピペする↓\n if (message.content === '寒いね') {\n let channel = message.channel;\n let author = message.author.username;\n let reply_text =`寒いね`;\n message.reply(reply_text)\n .then(message => console.log(`Sent message: ${reply_text}`))\n .catch(console.error);\n return;\n }\n if (message.content === '暑いね') {\n let channel = message.channel;\n let author = message.author.username;\n let reply_text =`暑いね`;\n message.reply(reply_text)\n .then(message => console.log(`Sent message: ${reply_text}`))\n .catch(console.error);\n return;\n }\n if (message.content.match(/おはよ/)) {\n message.channel.send(`${author}さん、おはようございます!`)\n }\n if (message.content.match(/discord.gg/)) {\n message.delete(100)\n }\n //↑ここに後述のコードをコピペする↑\n });\n client.login(token);\n \n```\n\nおはよの部分は一回だけなのですが\"寒いね\"の部分が何回も繰り返されます。どのようにすればよいのでしょうか。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T14:17:01.350",
"favorite_count": 0,
"id": "48564",
"last_activity_date": "2020-10-27T18:00:25.117",
"last_edit_date": "2018-09-19T14:28:20.423",
"last_editor_user_id": "19110",
"owner_user_id": "29881",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"node.js",
"discord"
],
"title": "foreverコマンド",
"view_count": 238
} | [
{
"body": "node discord.jsで起動しましょう!\n\n確実に動くと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-10-12T01:58:05.920",
"id": "59653",
"last_activity_date": "2019-10-12T01:58:05.920",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "36174",
"parent_id": "48564",
"post_type": "answer",
"score": 0
}
] | 48564 | null | 59653 |
{
"accepted_answer_id": "48568",
"answer_count": 1,
"body": "Node.js+Expressフレームワークを使ってWEBアプリケーションを作成しています。\n\nNode.js内に3次方程式の解を求めるようなプログラムを組み込みたいのですが \n自力で実装すると大変そうなので、Pythonのライブラリの力を借りようと思いました。\n\n以下のように、PythonのSymPyモジュールを使って3つの解を求めて、解をsol変数を入れ \nsol変数をNode.jsの変数に渡すような処理をしたいです。\n\n```\n\n from sympy import *\n x=Symbol('x') #文字'x'を変数xとして定義\n \n #4x^3+12x^2+8x=0の解を求めて変数solに代入\n sol=solve(4*x**3+12*x**2+8*x, x)\n \n```\n\nこういった処理は、Node.jsのpython-shellモジュールなどを使えばできるのでしょうか? \n<https://www.npmjs.com/package/python-shell>\n\npython-shellの使い方を読んでもあまり理解が出来ませんでした。 \n以下のような使い方をするのではないかと色々触ってみたのですがエラーで全然前に進めません。\n\n```\n\n //まずpython-shellモジュールを読み込む\n var PythonShell = require('python-shell');\n \n //json形式で別ファイルのpython(script.py)にデータを渡すことを前提にオブジェクト作成\n var shell = new PythonShell('script.py', { mode: 'json '});\n \n //jsonデータ作成\n var json = {\n \"a\": \"4\",\n \"b\": \"12\",\n \"c\": \"8\"\n }\n \n //pythonにjsonデータを渡してpythonから返り値を受け取る\n var test = shell.receive(json);\n \n```\n\nどうしたら出来ますか...?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T16:32:44.147",
"favorite_count": 0,
"id": "48567",
"last_activity_date": "2018-09-19T17:24:01.293",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22541",
"post_type": "question",
"score": 0,
"tags": [
"python",
"node.js"
],
"title": "Node.js内でPythonを呼び出して相互に変数をやり取りしたい",
"view_count": 7019
} | [
{
"body": "[python-shellモジュールのテスト](https://github.com/extrabacon/python-\nshell/blob/master/test/test-python-shell.ts#L191)が参考になると思います。\n\nまず、今回作成したJSONデータをnode.jsからPython側に送るには、sendメソッドを使う必要があります。\n\n```\n\n shell.send(json);\n \n```\n\nPython側のスクリプトは[このように](https://github.com/extrabacon/python-\nshell/blob/master/test/python/echo_json.py)書くとよいようです。すなわち、標準入力にJSONを表す文字列が送られてくるので、それを`json.loads`でデコードします。 \n計算が終わってnode.js側に送り返すデータは`json.dumps`で文字列にしたあとprintで標準出力に出力します。\n\nそして、Python側から送られてきたJSONデータは、ドキュメントによればmessageイベントで受け取ることができます。\n\n```\n\n shell.on('message', function (data) {\n // Pythonスクリプトから送られてきたデータを表示\n console.log(data);\n });\n \n```\n\n* * *\n\n以上をまとめると、次のようにすればできます。\n\n**index.js**\n\n```\n\n //まずpython-shellモジュールを読み込む\n var { PythonShell } = require('python-shell');\n \n //json形式で別ファイルのpython(script.py)にデータを渡すことを前提にオブジェクト作成\n var shell = new PythonShell('script.py', {\n mode: 'json',\n });\n \n //jsonデータ作成\n var json = {\n \"a\": 4,\n \"b\": 12,\n \"c\": 8,\n };\n \n // scirpt.pyにJSONを送信\n shell.send(json);\n \n // script.pyからの返事を待機\n shell.on('message', data => {\n // データを表示 \n console.log(data.result);\n });\n \n // 入力を終了\n shell.end();\n \n```\n\n**script.py**\n\n```\n\n import sys, json\n from sympy import *\n x=Symbol('x') #文字'x'を変数xとして定義\n \n # nodejsスクリプトからデータを受信\n data = json.loads(sys.stdin.readline())\n a = data[\"a\"]\n b = data[\"b\"]\n c = data[\"c\"]\n \n # 方程式の解を求める\n sol=solve(a*x**3+b*x**2+c*x, x)\n \n # 各解をintに変換\n intsol = [int(value) for value in sol]\n \n # オブジェクトを作成\n response = {\"result\": intsol}\n # JSON文字列にして出力\n print(json.dumps(response))\n \n```\n\nこれを実行すると`[ -2, -1, 0 ]`のように表示され、正しく解が求まっていることが分かります。\n\n* * *\n\nとりあえずこのスクリプトを実行すれば動きますが、質問文にある元のスクリプトからはいくつか変わっているので注意してください。 \n例えば1行目のrequireの行が少し変わっています。元のままだと`PythonShell`をnewできないというエラーが出るはずです。 \nまた、`{ mode: 'json ' }`という部分ですが、`'json '`という文字列に余計なスペースが含まれておりこれでは正しく動かないはずです。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-19T17:24:01.293",
"id": "48568",
"last_activity_date": "2018-09-19T17:24:01.293",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30079",
"parent_id": "48567",
"post_type": "answer",
"score": 1
}
] | 48567 | 48568 | 48568 |
{
"accepted_answer_id": "48580",
"answer_count": 1,
"body": "`io.Discard` の\n[ソースコード](https://github.com/golang/go/blob/master/src/io/ioutil/ioutil.go#L122)\nを見ていて疑問点が2点あります。\n\n**Q1.**\n\nGoの基本的な文法に関する質問になってしまいますが、以下は何を意図しているのでしょうか。\n\n```\n\n // devNull implements ReaderFrom as an optimization so io.Copy to\n // ioutil.Discard can avoid doing unnecessary work.\n var _ io.ReaderFrom = devNull(0)\n \n```\n\nコード内のコメントから、`devNull` が `io.Copy`\nで使われる場合に備えて「`io.ReaderFrom`インタフェースを実装している」ことを宣言しているのだろうとは思うのですが、一体どういう理屈で上記がインタフェースを実装していることの宣言になるのでしょうか(そういう文法なのだと言われるとそれまでなのですが…)。\n\n**Q2.**\n\n以下のように `WriteString` 関数が定義されていますが、\n\n```\n\n func (devNull) WriteString(s string) (int, error) {\n return len(s), nil\n }\n \n```\n\nそもそも `io.Discard` は `ioutil` パッケージに `io.Writer` 型の変数として宣言されているため、\n\n```\n\n // Discard is an io.Writer on which all Write calls succeed\n // without doing anything.\n var Discard io.Writer = devNull(0)\n \n```\n\n例えば以下のように呼び出すことはできません。\n\n```\n\n ioutil.Discard.WriteString(\"hoge\")\n // ビルドエラー:\n // ioutil.Discard.WriteString undefined \n // (type io.Writer has no field or method WriteString)\n \n```\n\n一体なんのために存在しているのでしょうか。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T02:00:40.783",
"favorite_count": 0,
"id": "48570",
"last_activity_date": "2018-09-21T06:43:26.013",
"last_edit_date": "2018-09-21T06:43:26.013",
"last_editor_user_id": "3054",
"owner_user_id": "19759",
"post_type": "question",
"score": 1,
"tags": [
"go"
],
"title": "使用しない変数をインターフェース型で宣言する意味と、io.Discard に関する質問",
"view_count": 111
} | [
{
"body": "自己回答です。(metropolisさんのコメントより)\n\n**A1.**\n\n`devNull` が `io.ReaderFrom` インタフェースを実装していることを、コンパイル時にチェックさせることが目的。\n\n型が `io.ReaderFrom` である何らかの変数を宣言して、それに `devNull` を代入することができるのであれば、`devNull` は\n`io.ReaderFrom`\nインタフェースを実装している、ということになる。また「なんらかの変数」は宣言後に使用しないので、ブランク識別子(アンダースコア)にしている。チェックするだけなので、この行を削除してもコンパイルできるし動作も変わらない。\n\n**A2.**\n\n同パッケージの `stringWriter` インタフェースの実装。 \n`stringWriter` インタフェースは、`io.WriteString` 関数や `io.multiWriter.WriteString`\n関数の中で型アサーションがokであれば委譲される。\n\n例えば以下の時、内部では `Discard` の `WriteString` 関数が使われる。\n\n```\n\n io.WriteString(ioutil.Discard, \"hogehoge fugafuga\")\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T06:26:00.320",
"id": "48580",
"last_activity_date": "2018-09-20T06:26:00.320",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19759",
"parent_id": "48570",
"post_type": "answer",
"score": 1
}
] | 48570 | 48580 | 48580 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "> Fatal error in PMPI_Allgather: Invalid buffer pointer, error stack: \n> PMPI_Allgather(1093): MPI_Allgather(sbuf=0x2621ed0, scount=1, \n> MPI_INTEGER, rbuf=0x2621ed0, rcount=1, MPI_INTEGER, MPI_COMM_WORLD) \n> failed PMPI_Allgather(1026): Buffers must not be aliased\n\n上のようなエラーが出てしまうのですが,原因がわかりません. \n何が原因なのでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T02:01:57.230",
"favorite_count": 0,
"id": "48571",
"last_activity_date": "2018-09-20T02:47:26.060",
"last_edit_date": "2018-09-20T02:47:26.060",
"last_editor_user_id": "19110",
"owner_user_id": "30180",
"post_type": "question",
"score": 0,
"tags": [
"linux",
"fortran",
"mpi"
],
"title": "fortranでMPIを使って並列計算しようとしています",
"view_count": 655
} | [] | 48571 | null | null |
{
"accepted_answer_id": "48577",
"answer_count": 1,
"body": "WebRTCに関連するuv4l等をインストールしたところ、uv4l-uvcデーモンが自動起動されるようになりました。 \nこの自動起動を、止めたいのですがどこで起動されているのかが分かりません。\n\n/etc/inidt.dにはuv4l_uvcのスクリプトはあります。 \nしかし、ls rc*.d -l | grep uv4l_uvc を打っても何も表示されません。 \nまた、uv4l_uvcスクリプト内にremoveがあったので、実行してみましたが、やはり自動起動は止まりませんでした。\n\nuv4l_vucは、どこから起動されているのでしょうか? \n或いは、サービスの起動シーケンスはどのように調べれば良いでしょうか? \nOSはDebian 9です",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T03:30:08.120",
"favorite_count": 0,
"id": "48576",
"last_activity_date": "2018-09-20T03:53:26.797",
"last_edit_date": "2018-09-20T03:41:43.277",
"last_editor_user_id": "19110",
"owner_user_id": "15090",
"post_type": "question",
"score": 3,
"tags": [
"linux",
"debian",
"webrtc"
],
"title": "サービスの自動起動を止めたい",
"view_count": 215
} | [
{
"body": "# サービスの自動起動を止める\n\n> OSはDebian 9\n\nsystemdでサービスが管理されているはずなので、\n\n```\n\n sudo systemctl stop uv4l.service\n sudo systemctl disable uv4l.service\n \n```\n\nでいかがでしょうか。\n\n# サービスの起動シーケンスを調べる\n\nsystemdのユニットファイルが格納されているパスの一覧は、以下のコマンドにより表示することができます。\n\n```\n\n systemctl show --property=UnitPath\n \n```\n\n表示されるパスのいずれかに`uv4l.service`というファイルが含まれているはずですので、そちらの中身からサービスの起動シーケンスについて調べられます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T03:45:30.033",
"id": "48577",
"last_activity_date": "2018-09-20T03:53:26.797",
"last_edit_date": "2018-09-20T03:53:26.797",
"last_editor_user_id": "29826",
"owner_user_id": "29826",
"parent_id": "48576",
"post_type": "answer",
"score": 6
}
] | 48576 | 48577 | 48577 |
{
"accepted_answer_id": "48581",
"answer_count": 2,
"body": "プログラミング初心者です。(Python2.7・Iron Python使用) \nタプルを含んだキーを持つ辞書型のリストにおいて、キーが重複する際、値を足して1つの辞書型にマージしたいと思っています。 \n用途としては、簡単な施設動線のヒートマップの作成です。キーに平面座標、値にその座標の上を人が通過した回数です。\n\nつまり下記のような、 \nリスト=[{(x座標,y座標) : 回数 , (x座標,y座標) : 回数,} , {(x座標,y座標) : 回数 , (x座標,y座標) :\n回数},{}...] \nを1つの辞書型にマージする際、同じ座標の上を通過した回数は足して表示したいという事です。\n\n例えば、\n\n```\n\n dict_list = [{(1,2):10, (1,3):10, (2,4):10} , {(1,2):15, (2,3):15, (2,4):15} , {(1,1):3 ,(2,2):3 }, {(1,1):60, (1,2):60}]\n \n```\n\nを\n\n```\n\n dict = {(1,1):63, (1,2):85, (1,3):10, (2,2):3 , (2,3):15, (2,4):25}\n \n```\n\nという感じにしたいです。\n\ncollections importによるCounterを使用して解決できましたが、Iron\npythonを使用しているため、ライブラリーのimportなしで解決したいです。最後に平面座標とその合計回数が分かる形なら辞書型でなくても構いません。\n\n何卒よろしくお願い致します。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T05:51:16.217",
"favorite_count": 0,
"id": "48579",
"last_activity_date": "2018-09-20T07:09:16.097",
"last_edit_date": "2018-09-20T05:58:50.967",
"last_editor_user_id": "2238",
"owner_user_id": "30176",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python2"
],
"title": "辞書型において、タプルのキーが重複する場合、上書きせず連結する方法",
"view_count": 443
} | [
{
"body": "愚直に for 文で実装してみました。Python 2.7.15 および 3.6.2 で動作確認済みです。\n\n```\n\n dct_lst = [{(1,2):10, (1,3):10, (2,4):10},\n {(1,2):15, (2,3):15, (2,4):15},\n {(1,1):3 ,(2,2):3},\n {(1,1):60, (1,2):60}]\n \n result = {}\n for dct in dct_lst:\n for k, v in dct.items():\n if k in result.keys():\n result[k] += v\n else:\n result[k] = v\n \n print(result)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T06:28:27.053",
"id": "48581",
"last_activity_date": "2018-09-20T06:28:27.053",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "48579",
"post_type": "answer",
"score": 2
},
{
"body": "内包表記と3項演算子を使ってみました。 \n行数は削減できますが直感的ではありませんので、素直にimportや多重forを使った方が保守しやすいように思います。 \nPython 2.7.5, 3.6.1で動作確認済みです。\n\n```\n\n dict_list = [{(1,2):10, (1,3):10, (2,4):10} , {(1,2):15, (2,3):15, (2,4):15} , {(1,1):3 ,(2,2):3 }, {(1,1):60, (1,2):60}]\n result = {}\n for (k, v) in [(k, p[k]) for p in dict_list for k in p]:\n result[k] = result[k] + v if k in result.keys() else v\n \n result\n # {(1, 2): 85, (1, 3): 10, (2, 4): 25, (2, 3): 15, (1, 1): 63, (2, 2): 3}\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T07:09:16.097",
"id": "48582",
"last_activity_date": "2018-09-20T07:09:16.097",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9820",
"parent_id": "48579",
"post_type": "answer",
"score": 2
}
] | 48579 | 48581 | 48581 |
{
"accepted_answer_id": "48586",
"answer_count": 2,
"body": "**状況**\n\n 1. VirtualBoxにWindows10(64bit)の仮想マシンを作成。\n 2. Win10_1803_Japanese_X64.isoを選択\n 3. 仮想マシン起動\n\n**エラー内容**\n\n```\n\n FATAL:No bootable medium found! System halted.\n \n```\n\n仮想マシンに Win10_1803_Japanese_X64.iso のOSが入ってない状況なのでしょうか。 \nVirtualBoxに不慣れなので、原因特定に時間がかかってます。 \nお手数おかけしますが、ご回答頂けると幸いです。 \n宜しくお願いします。\n\n追記 \nシステムで起動順序が変更できません。 \nこの半透明状態で起動順序を変更する術を知っている方がいればご教示ください。\n\n[](https://i.stack.imgur.com/FX45p.png)\n\n**環境**\n\nmacOS HighSierra macOS HighSierra 10.13.6 \nVirtualBox バージョン 5.2.12",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T07:18:24.147",
"favorite_count": 0,
"id": "48584",
"last_activity_date": "2021-08-28T03:45:10.013",
"last_edit_date": "2020-02-27T17:01:15.803",
"last_editor_user_id": "3060",
"owner_user_id": "29530",
"post_type": "question",
"score": 1,
"tags": [
"virtualbox"
],
"title": "No bootable medium found! System halted. になる",
"view_count": 31447
} | [
{
"body": "考え方としては物理マシンにOSをインストールする時と同じで、インストールメディア(CD/DVD等)をHDDよりも先に参照するよう設定する必要があります。\n\n * 仮想マシンの設定でインストールに使用するISOイメージが「ストレージ」で選択されているか確認。\n * 同じく仮想マシンの設定で「システム」>「マザーボード」の「起動順序」で **光学** をハードディスクより上に移動しておく。\n\nもしくは\n\n * 仮想マシン(ゲストOS)を起動してVirtualBoxのロゴが出ている画面で`F12`を何度か押すと(一時的な)ブートデバイスの選択画面が出るので、 **CD-ROM** を選択。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T07:35:57.863",
"id": "48586",
"last_activity_date": "2018-09-20T07:35:57.863",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "48584",
"post_type": "answer",
"score": 4
},
{
"body": "Oracle_VM_VirtualBox_Extension_Pack-5.2.2-119230.vbox-extpack",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2021-08-28T03:45:10.013",
"id": "81085",
"last_activity_date": "2021-08-28T03:45:10.013",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "47951",
"parent_id": "48584",
"post_type": "answer",
"score": -1
}
] | 48584 | 48586 | 48586 |
{
"accepted_answer_id": "48591",
"answer_count": 1,
"body": "```\n\n let hoge: String? = nil\n let foo: String? = \"foo\"\n \n var dict = [String: Any]()\n \n if let hoge = hoge {\n dict[\"hoge\"] = hoge\n }\n \n if let foo = foo {\n dict[\"foo\"] = foo\n }\n \n print(dict) // => [\"foo\": \"foo\"]\n \n```\n\n上記のような \n`オプショナルな値`が入っていた場合のみ`アンラップ`して`ディクショナリ`に登録していく処理をもっとシンプルにしたいと考え、いろいろ試していると下記のような挙動を発見しました。\n\n```\n\n let hoge: String? = nil\n let foo: String? = \"foo\"\n \n var dict = [String: Any]()\n \n dict[\"hoge\"] = hoge\n dict[\"foo\"] = foo\n \n print(dict) // => [\"foo\": \"foo\"]\n \n```\n\n`nil`である `dict[\"hoge\"] = hoge` の処理が無視されているようです。\n\nこれは安全な書き方なのでしょうか?\n\n<https://developer.apple.com/documentation/swift/dictionary>\n\n> Update an existing value by assigning a new value to a key that already\n> exists in the dictionary. If you assign nil to an existing key, the key and\n> its associated value are removed.\n\nによるとnilの代入は削除を意味しているようです。 \n削除ではない今回のような初期化ぽい使い方をしても問題ないでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T07:22:13.300",
"favorite_count": 0,
"id": "48585",
"last_activity_date": "2018-09-20T08:46:25.683",
"last_edit_date": "2018-09-20T08:35:13.590",
"last_editor_user_id": "19110",
"owner_user_id": "9008",
"post_type": "question",
"score": 3,
"tags": [
"swift",
"swift4"
],
"title": "勝手にnilが無視される挙動を使って安全?",
"view_count": 122
} | [
{
"body": "**_削除ではない今回のような初期化ぽい使い方をしても問題ないでしょうか?_**\n\n「問題ない」をどのように捉えるかによります。ご自身が確かめられたように、現在のSwiftで、そのコードの書き方なら問題ないようです。\n\nただ、`Any`は`nil`を含む任意の値を格納しうる型なので、今後のSwiftでも確実にそのような動作になるか、と言うのはリンク先の記載からは読み取れません。\n\n例えば、ほとんど同じ意味のはずと思われているこちらのコードは、以下のような結果になります。\n\n```\n\n let dict2: [String: Any] = [\n \"hoge\": hoge,\n \"foo\": foo,\n ]\n print(dict2) //-> [\"hoge\": nil, \"foo\": Optional(\"foo\")]\n \n```\n\nSwiftの`nil`には実際には型があって、`String?`型の`nil`と`Any?`型の`nil`は別物なので、「`Any?`型の`nil`ではなく`String?`型の`nil`を代入しているのに、そのような動作になるのはバグではないか?」と言うバグ報告が上がったら、「修正」される可能性もありそうです。\n\nまた、現在のSwiftには、[Warn when Optional converts to Any, and bridge Optional As Its\nPayload Or NSNull](https://github.com/apple/swift-\nevolution/blob/master/proposals/0140-bridge-optional-to-\nnsnull.md)という仕様が取り込まれています。`[String: Any]`がObjective-\nC側に`NSDictionary`として渡される場合、`String?`型の`nil`が`NSNull`にならずに、エントリー削除になってしまうのは、この仕様とも相性が悪そうです。\n\nこの辺り、swift.orgに投稿すれば(英語でってことになりますが)、Swift言語開発Teamのメンバーから直接意見をもらえるかもしれません。\n\nと言うわけで、何らかのドキュメントに明示されるまでは、\n\n**「値が`nil`の場合にはエントリー自体を追加したくない」と言う場合、面倒がらずに上のように書いた方が良い**\n\nように思われます。(将来のSwiftのバージョンで動作が変更になった場合、表に現れる影響から原因を探るのはかなり大変になりそうです。)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T08:46:25.683",
"id": "48591",
"last_activity_date": "2018-09-20T08:46:25.683",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "48585",
"post_type": "answer",
"score": 2
}
] | 48585 | 48591 | 48591 |
{
"accepted_answer_id": "48709",
"answer_count": 1,
"body": "クライアントPC1台+サーバーPC2台(A、B)という構成で、 \nクライアントPCからサーバAにtcp接続を行い、コネクション確立されたらAに、確立されなければBにアクセスするというソフトを作成しています。\n\nTCPポート50002を指定して接続確認を行いたいのですが、うまく行えません。 \nファイアウォールの送受信設定で50002を許可にはしています。\n\n下記が実装中のTCPアクセスクラスです。\n\n```\n\n public class TcpClientAcs\n {\n string strPartnerIpAddress;\n int nPort;\n int nTcpConnectionTimeout;\n int nTcpConnectionCount;\n \n \n public TcpClientAcs()\n {\n nPort = 50002;\n nTcpConnectionTimeout = 2000;\n nTcpConnectionCount = 2; \n }\n \n public bool CLTMain(string ipaddress)\n {\n strPartnerIpAddress = ipaddress;\n System.Net.Sockets.TcpClient tcp; \n int ConnectionRetryCnt = 0;\n tcp = null;\n \n // TCP connection\n while (true)\n {\n \n if (ConnectionRetryCnt < nTcpConnectionCount)\n {\n try\n {\n tcp = new TcpClient();\n var connection = tcp.BeginConnect(strPartnerIpAddress, nPort, null, null);\n var success = connection.AsyncWaitHandle.WaitOne(nTcpConnectionTimeout);\n //add retry count\n if (!success)\n {\n ConnectionRetryCnt++;\n continue;\n }\n else\n { \n break;\n }\n }\n catch (Exception)\n {\n ConnectionRetryCnt++;\n }\n }\n else\n {\n return false;\n }\n return true;\n }\n return true;\n }\n }\n \n```\n\n宜しくお願いします。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T08:26:00.047",
"favorite_count": 0,
"id": "48588",
"last_activity_date": "2018-09-26T00:22:27.163",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19580",
"post_type": "question",
"score": 1,
"tags": [
"c#",
"visual-studio",
"tcp"
],
"title": "TcpClientでTCP接続がうまくできない",
"view_count": 6934
} | [
{
"body": "自己解決しました。 \nWiresharkで調べたところ送信元のポート番号が毎回異なることに気づきました。 \n今回の場合、送信先のポート番号のみ指定しており、送信元のポート番号を指定していなかった為、起きていました。 \nTcpClientのインスタンス作成時にIPEndpointを指定することで解決できました。\n\n```\n\n IPEndPoint ep = new IPEndPoint(ip, nPort);\n tcp = new TcpClient(ep);\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T00:22:27.163",
"id": "48709",
"last_activity_date": "2018-09-26T00:22:27.163",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19580",
"parent_id": "48588",
"post_type": "answer",
"score": 3
}
] | 48588 | 48709 | 48709 |
{
"accepted_answer_id": "48628",
"answer_count": 1,
"body": "Rubyを最近使い始めまして,勉強中の身です. \n熱雑音生成のプログラムを書いているのですが,UnitTestをしたところ,乱数で降ってるはずなのに値が更新されず,同一のままになってしまいます. \nデバッグをしていますが,原因がわかりません. \nご教授お願い致します. \n詳細は以下のコードになります.\n\n長文失礼しました.\n\n* * *\n```\n\n def BoxMullerNoise\n rnd = Random.new\n return BoxMuller.new_create(rnd)\n end\n \n class BoxMuller\n attr_accessor :_urng\n attr_accessor :_x\n attr_accessor :_y\n attr_accessor :_saveIns\n \n def self.new_create(urng)\n obj = self.new\n obj._urng = urng\n obj._x = urng.rand(1.0)\n obj._y = urng.rand(1.0)\n \n obj._saveInst = obj # インスタンスの保存\n \n return obj\n end\n \n def value # この中身の_x, _yが,popfrontをUnitTestでしているのに更新されない\n p _x\n p _y\n return Math.sqrt((-2.0) * Math.log(_x)) * Complex(Math.cos(2*Math::PI*_y), Math.sin(2*Math::PI*_y))\n end\n \n @@empty = false\n \n def popfront\n p \"BoxMullerクラス内です\"\n _x = _urng.rand(1.0)\n _y = _urng.rand(1.0)\n end\n \n def seed(seed)\n srand(seed)\n end\n \n def save\n _keepInst = _saveInst\n \n _keepInst._urng = _urng\n \n return _keepInst\n end\n end\n \n \n def noisePower(bandwidth, tempK)\n return bandwidth * tempK * BoltzmannConst\n end\n \n \n class ThermalNoise\n attr_accessor :_rnd\n attr_accessor :_gain\n attr_accessor :_saveInst\n \n def self.new_create(sampFreq, tempK, seed = Random.new.seed)\n obj = self.new\n obj._rnd = BoxMullerNoise()\n obj._gain = Math.sqrt(noisePower(sampFreq, tempK) / 2)\n obj._rnd.seed(seed)\n \n obj._saveInst = obj # インスタンスの保存\n \n return obj\n end\n \n \n def value\n return _rnd.value * _gain\n end\n \n @@empty = false\n \n def popfront\n p \"ThermalNoiseクラス内です\"\n _rnd.popfront\n end\n \n def save\n _keepInst = _saveInst\n \n _keepInst._rnd = _saveInst._rnd.save\n \n p _keepInst\n return _keepInst\n end\n end\n \n \n # UnitTest\n class UnitTest < Test::Unit::TestCase\n def test_ThermalNoise\n buf = Array.new(64*1024)\n rndSeed = 114514\n thermalNoise = ThermalNoise.new_create((20*10**6)*4, 300, rndSeed + 123321)\n \n (0 ... 4).each{ |i|\n thermalNoise.popfront # BoxMullerクラスの_x, _yを変えているはずなのに\n thermalNoise.value # ここで同じ値が表示されてしまう\n }\n end\n end\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T09:21:01.770",
"favorite_count": 0,
"id": "48592",
"last_activity_date": "2018-09-21T15:29:28.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30173",
"post_type": "question",
"score": 0,
"tags": [
"ruby"
],
"title": "乱数で変化させているはずが値が同一となってしまう",
"view_count": 177
} | [
{
"body": "```\n\n def popfront\n p \"BoxMullerクラス内です\"\n _x = _urng.rand(1.0)\n _y = _urng.rand(1.0)\n end\n \n```\n\nを\n\n```\n\n def popfront\n p \"BoxMullerクラス内です\"\n self._x = _urng.rand(1.0)\n self._y = _urng.rand(1.0)\n end\n \n```\n\nのようにしてください。\n\nRubyでは`a =\nb`と言う表現は常にローカル変数`a`へ`b`を代入するとみなされます。ローカル変数`a`が未定義であれば、同時にローカル変数`a`が定義されることになります。`_x\n=\n_urng.rand(1.0)`という表現もローカル変数`_x`の定義と代入になり、インタンスメソッドの呼び出しにはなりません。インスタンスメソッドとして扱いたい場合は`self._x\n= _urng.rand(1.0)`というようにレシーバーを明記する必要があります。\n\nさて、全体的に言えることはRubyっぽくないことです。何か別の言語で作られた物を無理矢理移植したように思えます。たぶん、どこかで無理が出て、破綻します。\n\n * 初期化には`initialize`を使いましょう。特殊なことをしない限り、クラスメソッドを新しい`new`もどきを作る必要はありません。\n * クラス内の処理はインスタンス変数を使いましょう。`attre_accessor`等は外部にインスタンス変数を見せるための手段です。外部に見せる必要が無いのであれば、使うべきではありません。\n * Rubyのクラスは構造体ではありません。C++/D/Javaのように構造体の拡張と考えてはいけません。\n * 郷には入れば郷に従えです。Rubyでは2スペースのインデント、ローカル変数やメソッドはスネークケースが推奨されています。その他は[Ruby Style Guide](https://github.com/rubocop-hq/ruby-style-guide)を参考にしてください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T15:29:28.150",
"id": "48628",
"last_activity_date": "2018-09-21T15:29:28.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7347",
"parent_id": "48592",
"post_type": "answer",
"score": 2
}
] | 48592 | 48628 | 48628 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "現在、Laravelで開発をしているのですが、下記コードで\n\n```\n\n \n \n \r\n \n```\n\n <?php\r\n \r\n /*\r\n |--------------------------------------------------------------------------\r\n | Web Routes\r\n |--------------------------------------------------------------------------\r\n |\r\n | Here is where you can register web routes for your application. These\r\n | routes are loaded by the RouteServiceProvider within a group which\r\n | contains the \"web\" middleware group. Now create something great!\r\n |\r\n */\r\n \r\n Route::get(‘/’,function(){return redirect(‘/tasks’);});\r\n Route::get(‘/tasks’,‘TaskController@index’);\r\n Route::post(‘/tasks’,‘TaskController@store’);\r\n Route::delete(‘/tasks/{task}’,’TaskController@destroy’);\r\n \r\n \\URL::forceScheme(‘https’);\n```\n\n`\n\n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T11:30:00.957",
"favorite_count": 0,
"id": "48594",
"last_activity_date": "2018-09-20T11:53:01.923",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30190",
"post_type": "question",
"score": 0,
"tags": [
"laravel-5"
],
"title": "syntax error, unexpected '@', expecting ',' or ')' エラーの原因教えてください。",
"view_count": 4039
} | [
{
"body": "ご質問に掲載のコードではシングルクオート(`'`, U+0027, APOSTROPHE)になるべきところが、左シングルクオート(`‘`, U+2018,\nLEFT SINGLE QUOTATION\nMARK)になってしまっているようです。(Webサイトに文字化けしたコードが掲載されていたり、使っているエディタやブラウザの機能で勝手に変換されることもあるようです。)\n\nVS Codeでは、そのような間違いがあると同じ表示「syntax error, unexpected '@', expecting ',' or\n')'」になった(他のエラーは無視されて…)ので、質問をアップロードする時の文字化けではなく、実際にソースコードの中で間違われているのだと思います。\n\nエディタの一括置換等を用いて全ての左シングルクオート(`‘`)を正しいシングルクオート(`'`)に置き換えて試してみてください。両者の表示上の違いは非常にわかりにくいですが、フォントをいろいろ変えながら見直せば、見えてくると思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T11:53:01.923",
"id": "48595",
"last_activity_date": "2018-09-20T11:53:01.923",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "48594",
"post_type": "answer",
"score": 2
}
] | 48594 | null | 48595 |
{
"accepted_answer_id": "48747",
"answer_count": 4,
"body": "```\n\n func フェードインしてからフェードアウト {\n フェードイン()\n 5秒表示\n フェードアウト()\n }\n \n```\n\n`アンドロイド`の`トースト`のようにフェードインして来てしばらく表示されその後フェードアウトしていくアニメーションに適切な名前はありますでしょうか?\n\n<http://www.moon-light.ne.jp/termi-nology/meaning/fade-in.htm> \n上記URLにヒントになりそうなのがありそうでしたが、今回求めているものはありませんでした...\n\n> ちなみに、主に音声でフェードイン、フェードアウトを同時に行なうこと、 つまり一方の音を徐々に絞り、もう一方を徐々に大きくすることを \n> 「クロスフェ-ド」(cross fade)と言います。 そして同様のことを映像で行う場合、 \n> つまり映像が徐々に消えていく中、次の映像が徐々に現れてくるのを 「ディゾルブ」(dissolve)、 そしてこの二つの映像を重ねてしまうのを \n> 「オーバーラップ」(over lap)と言います。\n\n`トースト`のようによく知られた名称のついた部品だと良いのですが、今回はもっと一般的にフェードインしてフェードアウトして消えていく一般的な名称を求めております。",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T12:27:39.087",
"favorite_count": 0,
"id": "48596",
"last_activity_date": "2019-07-03T07:35:22.330",
"last_edit_date": "2019-04-05T09:44:12.867",
"last_editor_user_id": "19769",
"owner_user_id": "9008",
"post_type": "question",
"score": 0,
"tags": [
"untagged"
],
"title": "フェードインしてフェードアウトするアニメーション処理に適切な名前をつけたい",
"view_count": 341
} | [
{
"body": "あえて1単語で表現するなら`fading`はいかがでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T13:57:29.980",
"id": "48601",
"last_activity_date": "2018-09-20T13:57:29.980",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3060",
"parent_id": "48596",
"post_type": "answer",
"score": 0
},
{
"body": "私個人的な意見としては、アニメーションはあくまで属性だと思いますので、それをベースで名前を付けるのではなく、そのViewを表示する目的で名前を付けるべきかと思います。 \nアラートを出したいならalertionですし、注記ならannotation、通知であればnotification、警告ならwarningにします。 \n一時的にしか表示しないというのを名前で表現するのであればinstantをつけて表現します。\n\nお求めの回答とは違うかもしれませんが、一意見として参考にしていただければと思います。 \n質問の目的とあまりにもずれている場合は回答を取り下げますので、コメントください。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T01:18:34.563",
"id": "48606",
"last_activity_date": "2018-09-21T01:18:34.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17014",
"parent_id": "48596",
"post_type": "answer",
"score": 1
},
{
"body": "**更新**\n\n前回よりかなりの期間が空きましたので、いまさら回答されても仕方がないかもしれませんが、\n\n**fadecurve** というのがしっくりくるかと思います。 \nこの言葉はネットで検索しても、どうやら通常の英単語としては存在しない単語のようです。\n\nしかし、[PySide documentation 1.2.1\nPhonon](https://pyside.github.io/docs/pyside/PySide/phonon/Phonon.VolumeFaderEffect.html?highlight=fadecurve#PySide.phonon.PySide.phonon.Phonon.VolumeFaderEffect.FadeCurve)を見てましたら、 \nここに、似た現象を表すために、fadecurveという言葉が使われています。\n\nただ、5秒間のインターバルについては、この言葉に含まれていないものと思いますので、 \nこの言葉を軸にして、何かプラスされたらいかがかと思います。少し長くなるかもしれませんが、 \nfadeintervalcurveとかが適当なんじゃないかと思います。\n\n**以前**\n\nコメントに\n\n> 「来て去っていく」というより「来て戻っていく」のイメージのほうが(あくまで私のイメージに)近そうです。\n>\n> どちらかというと今出てきました!って感じ(フェードイン)、後ろの要素が見えないですよねーひっこみますー(フェードアウト)って感じですね。\n\n質問者様は、その動作現象自体に適切な名前をつけたい。という事で、「正確にそれを表現する英語が欲しい」という訳ではなさそうです。和製英語でも、中々そのような表現は見当たりませんでした。\n\n私がこの二つのコメントを読んで感じたイメージとしては、 **鳩時計** です。\n\n`cuckoo_clock`\n\n来て戻っていきます。今出てきました!後ろの要素が見えません。引っ込みます。 \nこの5つの現象を全て満たしています。動きも、フェードイン、フェードアウトと言ってもいいかもしれません。鳩の方が若干早い気もしますが。余計な事を言えば、後ろの要素が見えなくなる流れも少し変な気もしますけど、とにかく見えなくなっているかなと。\n\n結構英語圏の方達も、現象の特徴から勝手にイメージに合う言葉をコンピュータ関係の名前付けに付けてらっしゃるので、これはそんなに的外れの名前付けではないのではないかな。と感じています。\n\n> キャメルケース(英:\n> `camelcase`)は、複合語をひと綴りとして、要素語の最初を大文字で書き表すことをいう。キャメルケースとは、大文字が「らくだのこぶ」のように見えることからの命名である。 \n> [wikipedia-\n> camelcase](https://ja.wikipedia.org/wiki/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9)\n\nみたいな感じ。最初は、フェードイン、フェードアウトは、左か、あるいは右からスライドしてくると思っていましたが、縦の動きでも問題がなさそうに思えました。\n\nコメントからはどのような目的(例えば鳩時計だと時刻を知らせる)があるのかは読み取れませんでしたので、純粋に行動だけで表現する語を選びました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T00:37:34.353",
"id": "48747",
"last_activity_date": "2019-07-03T07:35:22.330",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "24284",
"parent_id": "48596",
"post_type": "answer",
"score": 1
},
{
"body": "「ちらつく」「ゆらめく」という意味の glimmer や flicker\nという単語がありますが、想定している効果が「じわっと出てきてじわっと消える」というものだと、イメージされる効果の変化スピード感が不釣り合いかな。あとは、「まばたく」という意味の\nblink …はHTML要素があったか。\n\n上記いずれも、単発ではなく周期的な動作にこそ適切な気がしますね。\n\n最終的には「このプロダクトではこのような効果を○○○と呼ぶ」という、用語集を作って解決する話かも。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T08:13:24.553",
"id": "48765",
"last_activity_date": "2018-09-27T08:13:24.553",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17037",
"parent_id": "48596",
"post_type": "answer",
"score": 0
}
] | 48596 | 48747 | 48606 |
{
"accepted_answer_id": "48615",
"answer_count": 3,
"body": "int main関数の部のコメント部のなのですが[暗黙的に宣言、削除された関数です]と \nエラーが出てしまい修正に困っています、ヘッダー部にoperator関数を用意しているので。何が間違えなのか検討もつきません、教えてもらえますでしょうか?初学者なので解説もお願いしたいです。参考書:新版明解c++中級編\nvisual studio 2017\n\n```\n\n //////////////////////boolArray.h////boolへの明示的特殊化をしたクラス/////\n \n #ifndef ___Class_Template_Array_Bool\n #define ___Class_Template_Array_Bool\n #include <iostream>\n #include <limits>\n #include \"Array.h\"\n \n //===== 配列クラステンプレートArray(bool型への特殊化)=====//\n template<> class Array<bool> {\n typedef unsigned char BYTE;\n static const int CHAR_BITS = std::numeric_limits<unsigned char>::digits;\n \n int nelem; // bool型配列の要素数\n int velem; // bool型配列を格納するためのBYTE型配列の要素数\n BYTE *vec; // BYTE型先頭要素へのポインタ\n \n // bool型sz個の要素の格納に必要なBYTE型配列の要素数\n static int size_of(int sz) { return (sz + CHAR_BITS - 1) / CHAR_BITS; }\n \n public:\n \n //=== ビットベクトル(バイト)中の1ビットへの参照を表すためのクラス ===//\n class BitOfByteRef {\n BYTE &vec; // 参照先BYTE\n int idx;// 参照先BYTE中のビット番号\n \n public:\n \n BitOfByteRef(BYTE& r, int i) : vec(r), idx(i) { } // コンストラクタ\n \n operator bool() const { return (vec >> idx) & 1U; } // 真偽を取得\n \n BitOfByteRef& operator = (bool b) {// 真偽を設定\n std::cout << \"BitOfByteRef operator = \\n\";\n \n if (b)\n vec |= 1U << idx;\n else\n vec &= ~(1U << idx);\n \n return *this;\n }\n \n };\n \n //----- 添字範囲エラー class -----//\n class IdxRngErr {\n const Array<bool>* ident;\n int index;\n public:\n IdxRngErr(const Array<bool>* p, int i) : ident(p), index(i) { }\n \n int Index() const { return index; }\n };\n \n //--- 明示的コンストラクタ ---//\n explicit Array(int sz, bool v = bool()) : nelem(sz), velem(size_of(sz)) {\n vec = new BYTE[velem];\n \n for (int i = 0; i < velem; i++) { // 全要素を初期化\n vec[i] = v;\n std::cout << vec[i]<<'\\n';//デバック\n }\n }\n \n //--- コピーコンストラクタ ---//\n Array(const Array& x) {\n if (&x == this) { // 初期化子が自分自身であれば…\n nelem = 0;\n vec = NULL;\n }\n else {\n nelem = x.nelem; // 要素数をxと同じにする\n velem = x.velem; // 要素数をxと同じにする\n vec = new BYTE[velem]; // 配列本体を確保\n \n for (int i = 0; i < velem; i++) // 全要素をコピー\n vec[i] = x.vec[i];\n }\n }\n \n //--- デストラクタ ---//\n ~Array() { delete[] vec; }\n \n //--- 要素数を返す ---//\n int size() const { return nelem; }\n \n //--- 代入演算子= ---//\n Array& operator = (const Array<bool>& x) {\n //std::cout << \"=\\n\";\n if (&x != this) { // 代入元が自分自身でなければ…\n if (velem != x.velem) { // 代入前後の要素数が異なれば…\n delete[] vec; // もともと確保していた領域を解放\n velem = x.velem; // 新しい要素数\n vec = new BYTE[velem]; // 新たに領域を確保\n }\n \n nelem = x.nelem; // 新しい要素数\n \n for (int i = 0; i < velem; i++) // 全要素をコピー\n vec[i] = x.vec[i];\n }\n return *this;\n }\n \n //--- 添字演算子[] ---//\n BitOfByteRef operator[](int i) {\n if (i < 0 || i >= nelem)\n throw IdxRngErr(this, i); // 添字範囲エラー送出\n \n return BitOfByteRef(vec[i / CHAR_BITS], (i & (CHAR_BITS - 1)));\n }\n \n //--- 添字演算子[] ---//\n bool operator[](int i) const {\n if (i < 0 || i >= nelem)\n throw IdxRngErr(this, i); // 添字範囲エラー送出\n \n return (vec[i / CHAR_BITS] >> (i & (CHAR_BITS - 1)) & 1U) == 1;\n }\n \n };\n \n //--- Array<bool>型配列aの全要素を0または1で連続表示 ---//\n void print_Array_bool(const Array<bool>& a)\n {\n for (int i = 0; i < a.size(); i++)\n std::cout << (a[i] ? '1' : '0');\n \n }\n \n #endif\n \n /////////////////////int main関数部//////////////////////////////\n #include <iostream>\n #include \"conio.h\"\n #include \"Array.h\"\n #include \"BoolArray.h\"\n using namespace std;\n \n int main() {\n \n Array<bool> x(10); // 全要素をfalseで初期化\n Array<bool> y(x); // yはxのコピー(要素数が10で全要素がfalse)\n Array<bool> z(5); // zの要素数は5だが\n z = y; // yが代入されるので要素数は10となる\n \n // z[1] = y[3];///ここです。\n y[2] = true;\n z[3] = true;\n \n Array<bool> a(10);\n \n cout << boolalpha;\n \n try {\n \n for (int i = 0; i < x.size(); i++)\n {\n cout << \"x[\" << i << \"] = \" << x[i] << '\\n';\n }\n \n std::cout << \"\\n\\n\";\n \n for (int i = 0; i < y.size(); i++)\n {\n cout << \"y[\" << i << \"] = \" << y[i] << '\\n';\n }\n \n std::cout << \"\\n\\n\";\n \n for (int i = 0; i < z.size(); i++)\n {\n cout << \"z[\" << i << \"] = \" << z[i] << '\\n';\n }\n \n }\n catch (Array<bool>::IdxRngErr &x) {\n cout << \"添え字範囲エラー:\";\n \n cout << x.Index();\n \n _getch();\n return 0;\n }\n \n cout << \"x = \"; print_Array_bool(x); cout << '\\n';\n cout << \"y = \"; print_Array_bool(y); cout << '\\n';\n cout << \"z = \"; print_Array_bool(z); cout << '\\n';\n \n _getch();\n return 0;\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T12:36:36.780",
"favorite_count": 0,
"id": "48597",
"last_activity_date": "2018-09-22T12:57:28.727",
"last_edit_date": "2018-09-21T08:30:02.527",
"last_editor_user_id": "76",
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"c++"
],
"title": "operator関数が機能しない?",
"view_count": 1808
} | [
{
"body": "Visual Studio 2013 コンソールプロジェクト on Win10 \nでは、コンパイルも実行もできました。 \nただし、\n\n・「Array.h」が見つからなかったので、当該インクルードをコメント化、 \nかつ、以下のコード様にclass Array を自前で用意しました。\n\n```\n\n template< typename T> class Array {};\n \n```\n\n以上から推測するに、Array.h に問題があるのかもしれません。 \n「#include \"Array.h\"」行を右クリックしてファイルを開き、意図したものか調べてみてはどうでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T02:19:42.447",
"id": "48608",
"last_activity_date": "2018-09-21T02:19:42.447",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3793",
"parent_id": "48597",
"post_type": "answer",
"score": 0
},
{
"body": "`template <typename T> class Array;` を補って gcc-7.3.0@x86_64-cygwin で試したところ\n\n>\n```\n\n> depr.cpp:17:13: error: ambiguous overload for 'operator=' (operand types\n> are 'Array<bool>::BitOfByteRef' and 'Array<bool>::BitOfByteRef')\n> z[1] = y[3];///ここです。\n> BoolArray.h:35:19: note: candidate: Array<bool>::BitOfByteRef&\n> Array<bool>::BitOfByteRef::operator=(bool)\n> BoolArray.h:24:9: note: candidate: Array<bool>::BitOfByteRef&\n> Array<bool>::BitOfByteRef::operator=(const Array<bool>::BitOfByteRef&)\n> <deleted>\n> BoolArray.h:24:9: note: candidate: Array<bool>::BitOfByteRef&\n> Array<bool>::BitOfByteRef::operator=(Array<bool>::BitOfByteRef&&) <deleted>\n> \n```\n\nとなりました。\n\nで。エラーになっている原因は\n\n * コピーコンストラクタがコンパイラによって暗黙に作られる場合がある\n * `operator=` がコンパイラによって暗黙に作られる場合がある\n * ところがこの例では `BitOfByteRef::operator=` を明示しているので「作られない = deleted 」\n * 自前で作った `BitOfByteRef::operator=` が正しく呼べない \n(暗黙に作られるはずの `operator=` と曖昧になっている)\n\n曖昧さがある以前に現コードはほとんど全く意味が無いです。現コードにおいて `z[1]` は `BitOfByteRef operator[] (int i)\n{ ... }` を呼び出しています。この返却値はコピーされた `BitOfByteRef`\n一時オブジェクト、つまり右辺値になっています。この右辺値に対して `operator=`\nを呼ぼうとしていますが、一時オブジェクト(右辺値)に代入しても意味がないです(即時デストラクトされるため)\n\nこの `z[1]=y[3];` で何がしたいのか次第で直し方が違うわけですが、どうしたいですか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T05:53:32.177",
"id": "48614",
"last_activity_date": "2018-09-21T05:53:32.177",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "48597",
"post_type": "answer",
"score": 1
},
{
"body": "直接の原因は、`Array<bool>::BitOfByteRef`型(以降、単に`BitOfByteRef`)が参照フィールド(`BYTE &\nvec`)を持っているため、暗黙に定義される`operator=(const BitOfByteRef &)`メソッドが定義されないことが原因と思います。\n\nですので、`operator=(const BitOfByteRef &)を明示的に定義することでエラーが解消されると思います。\n\n```\n\n // コード例\n BitOfByteRef & operator=(const BitOfByteRef & rhs) {\n return this->operator=(rhs.operator bool());\n // 多分、これでもOK.\n // return *this = static_cast<bool>(rhs);\n }\n \n```\n\n* * *\n\n補足です。順を追ってみてみると、\n\n```\n\n z[3] = y[1];\n \n```\n\nでは、`z[3]`は`BitOfByteRef`型と評価されます。また、`y[1]`も`BitOfByteRef`型と評価されます。つまり、`BitOfByteRef`型同士の代入と見なされます。 \nここで、`BitOfByteRef`型は`operator=(const BitOfByteRef\n&)`(代入演算子)のメンバメソッドを定義していないので、暗黙に定義されようとします。が、暗黙に定義されるメソッドでは、各メンバをコピーする処理にしようとするのですが、参照型変数自身は代入できないため、暗黙のメソッド定義は行わない(定義を禁止(`delete`))ようです。 \nそのため、コンパイラは「暗黙的に宣言、削除された関数です」とエラーにしていると思います。\n\n#`std::vector`の`std::vector<bool>`特殊化でも同じように`std::vector<bool>::reference`の代入演算子を2種類(`bool`と`reference`)定義しているようです。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T07:33:35.753",
"id": "48615",
"last_activity_date": "2018-09-22T12:57:28.727",
"last_edit_date": "2018-09-22T12:57:28.727",
"last_editor_user_id": "20098",
"owner_user_id": "20098",
"parent_id": "48597",
"post_type": "answer",
"score": 2
}
] | 48597 | 48615 | 48615 |
{
"accepted_answer_id": "48602",
"answer_count": 1,
"body": "[pytube](https://github.com/nficano/pytube)の使い方を調べていて以下の記事を見つけたのですが、ここで使われているpytubeがドキュメントに載っていない使い方をしているのでどうなっているの教えて欲しいです。\n\n[[Python] YouTubeからビデオをmp4形式でダウンロード](https://qiita.com/prs-\nwatch/items/577544e19f87e8531e13)\n\n```\n\n from pytube import YouTube\n from enum import Enum\n import ffmpeg\n import os\n import re\n \n class Loader(Enum):\n MP4 = 'mp4'\n WEBM = 'webm'\n \n def load(self, yt, res):\n vd = yt.get(self.value, res)\n vd.download('./videos')\n \n def download(url):\n ext = 'mp4'\n res = ''\n exts = []\n yt = YouTube()\n yt.url = url\n for video in yt.videos:\n exts.append(video.extension)\n if video.extension == 'mp4':\n res = video.resolution\n if 'mp4' not in exts:\n ext = 'webm'\n ext = ext.upper()\n val = getattr(Loader, ext)\n val.load(yt, res)\n \n def rename():\n path = os.path.join(os.getcwd(), 'videos')\n pattern = re.compile('(mp4|webm)$')\n files = os.listdir(path)\n for file in files:\n if pattern.search(file):\n file_path = os.path.join(path, file)\n new_file_path = file_path.replace(' ', '_')\n os.rename(file_path, new_file_path)\n \n def convert():\n path = os.path.join(os.getcwd(), 'videos')\n pattern = re.compile('webm$')\n files = os.listdir(path)\n for file in files:\n if pattern.search(file):\n file_path = os.path.join(path, file)\n stream = ffmpeg.input(file_path)\n stream = ffmpeg.hflip(stream)\n stream = ffmpeg.output(stream, file_path.replace('.webm', '.mp4'))\n ffmpeg.run(stream)\n os.remove(file_path)\n \n if __name__ == '__main__':\n url = input('url >> ')\n download(url)\n rename()\n convert()\n \n```\n\nfor文の`yt.videos`この部分が自分の環境だとうまく動かないのですが、videosの部分はpytubeによるものなのでしょうか? \nそれとも他のライブラリーによるものでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T12:55:41.507",
"favorite_count": 0,
"id": "48598",
"last_activity_date": "2018-09-21T01:05:27.610",
"last_edit_date": "2018-09-21T01:05:27.610",
"last_editor_user_id": "3060",
"owner_user_id": "22565",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "pythonのライブラリーpytubeの使い方",
"view_count": 363
} | [
{
"body": "> ドキュメントに載っていない使い方\n\nそもそも記事が古く、最新バージョンのpytubeが9.2.2であるのに対して記事の最終更新当時のものは7.0.18であり、すでにドキュメントと異なっているのが原因だと考えられます。\n\nそこで、[公式リポジトリのREADME.rstの変遷](https://github.com/nficano/pytube/commits/master/README.rst)を確認したところ、 \n以下のコミットによりドキュメントから`.videos`の記述が消えたため、この前後に破壊的な仕様変更があったものと考えられます。 \n<https://github.com/nficano/pytube/commit/deff05682b0567ff005f37adcb9b0af1583ada20#diff-88b99bb28683bd5b7e3a204826ead112>",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-20T18:02:52.670",
"id": "48602",
"last_activity_date": "2018-09-20T18:02:52.670",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29826",
"parent_id": "48598",
"post_type": "answer",
"score": 1
}
] | 48598 | 48602 | 48602 |
{
"accepted_answer_id": "49861",
"answer_count": 1,
"body": "<https://github.com/mxcl/PromiseKit> \nのREADME.md \nには\n\n```\n\n firstly {\n when(fulfilled: fetchImage, fetchLocation)\n }.done { image, location in\n self.imageView.image = image\n self.label.text = \"\\(location)\"\n }.ensure {\n UIApplication.shared.isNetworkActivityIndicatorVisible = false\n }.catch { error in\n self.show(UIAlertController(for: error), sender: self)\n }\n \n```\n\nのようにインデントされていて、とても読みやすいと思います。\n\nしかし、自分の`Xcode10.0`では下記のようにインデントされてしまいます。 \n(`Xcode9`でもこうだった記憶があります)\n\n```\n\n firstly {\n when(fulfilled: fetchImage, fetchLocation)\n }.done { image, location in\n self.imageView.image = image\n self.label.text = \"\\(location)\"\n }.ensure {\n UIApplication.shared.isNetworkActivityIndicatorVisible = false\n }.catch { error in\n self.show(UIAlertController(for: error), sender: self)\n }\n \n```\n\nREADMEのように自動でインデントさせる設定方法はありますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T01:15:24.400",
"favorite_count": 0,
"id": "48605",
"last_activity_date": "2018-11-01T12:21:49.460",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9008",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"xcode"
],
"title": "Xcodeのクロージャをチェーンさせるときのインデント設定",
"view_count": 112
} | [
{
"body": "なさそうです。\n\n<https://bugs.swift.org/browse/SR-2188> \nに報告されていました。\n\n> Type: Bug \n> Status:OPEN (View Workflow) \n> Priority: Medium\n\nという状況です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-11-01T12:21:49.460",
"id": "49861",
"last_activity_date": "2018-11-01T12:21:49.460",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9008",
"parent_id": "48605",
"post_type": "answer",
"score": 0
}
] | 48605 | 49861 | 49861 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Swiftのオープンソースライブラリのfolding-\ncellというものを使おうとしたんですけど、その際にCAMediaTimingFunctionNameの部分で以下のエラーが出てしまっていてビルドがうまくいきません。\n\nUse of undeclared type 'CAMediaTimingFunctionName'\n\nAppleのDeveloperサイトを見た時にこのクラスは存在しているように思えたので、自分で作成する必要はないと思っているのですが、どうなのでしょうか??\n\n知っている方がいらっしゃれば教えていただきたいです。また、Swiftのバージョンアップによって使うクラスが変わったということであればそれについても教えていただきたいです。\n\nよろしくお願いします。\n\nfolding-cellのURL \n<https://github.com/Ramotion/folding-cell>",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T02:23:49.367",
"favorite_count": 0,
"id": "48609",
"last_activity_date": "2018-09-21T02:23:49.367",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29508",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"github"
],
"title": "CAMediaTimingFunctionNameが使えない",
"view_count": 117
} | [] | 48609 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Arduino\nIDEを使って、SonyのSpresenseにブートローダーを書き込むことがどうしてもできません。デバイスも認識されていますが、「マイコンボードにブートローダーを書き込んでいます」と下部に表示され、長い時間が経過した後、「ブートローダーの書き込む中にエラーが発生しました。」というメッセージが表示されます。動作環境は以下の通りです。 \nWindows10 \nArduino 1.8.7\n\n念のため、recoverytoolによるリカバリーも行ってみましたが、「.....」という表示の後、そのまま停止してしまう状況です。製品不具合以外に何か原因が考えられますでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T03:02:09.567",
"favorite_count": 0,
"id": "48610",
"last_activity_date": "2023-07-03T01:04:30.660",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30194",
"post_type": "question",
"score": 0,
"tags": [
"spresense"
],
"title": "ブートローダーが書き込めない",
"view_count": 600
} | [
{
"body": "ソニーのSPRESENSEサポート担当です。\n\nご不便をお掛けして、誠に申し訳ございません。\n\nお手数ですが、症状などを添えてお買い上げいただいた販売店にお問い合わせいただけるでしょうか。どうぞ、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T09:06:29.773",
"id": "48766",
"last_activity_date": "2018-09-27T09:06:29.773",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29520",
"parent_id": "48610",
"post_type": "answer",
"score": 0
}
] | 48610 | null | 48766 |
{
"accepted_answer_id": "48613",
"answer_count": 2,
"body": "前と後ろの文字列を指定して、その間にある文字列を抜き出したいです。 \n例\n\n```\n\n const str = \"あいうえおかきくけこさしすせそ\";\n const before = \"あいうえお\";\n const after = \"さしすせそ\";\n //出力: \"かきくけこ\"\n \n```\n\n正規表現などを使えばいいのかなと思いつつも書き方が分からないので教えていただきたいです。(正規表現使わない方法でも全然いいです)\n\nご回答の程、よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T05:27:04.307",
"favorite_count": 0,
"id": "48611",
"last_activity_date": "2018-09-21T05:39:14.347",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30065",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"jquery"
],
"title": "前後を指定して間の文字列を出力",
"view_count": 8285
} | [
{
"body": "## 単純に正規表現を使う例\n\n```\n\n const str = \"あいうえおかきくけこさしすせそ\";\n const before = \"あいうえお\";\n const after = \"さしすせそ\";\n let re = new RegExp(before+'(.*?)'+after); // 間の部分を最小マッチ\n str.replace(re, '$1'); // マッチした部分だけ残すように置換\n // => 'かきくけこ'\n \n```\n\n## 正規表現を使わず、前後の文字列を順番に除去する例\n\n```\n\n const str = \"あいうえおかきくけこさしすせそ\";\n const before = \"あいうえお\";\n const after = \"さしすせそ\";\n str.replace(before, '').replace(after, '')\n // => 'かきくけこ'\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T05:33:12.167",
"id": "48612",
"last_activity_date": "2018-09-21T05:33:12.167",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29826",
"parent_id": "48611",
"post_type": "answer",
"score": 1
},
{
"body": "`before`と`after`の内容は常に決まっているのでしょうか。その場合は、以下のように正規表現を用いれば抜き出すことができます。\n\n```\n\n const result = str.match(/あいうえお(.*)さしすせそ/);\n if (result != null) {\n console.log(result[1]); // かきくけこ\n }\n \n```\n\n`before`と`after`が変数の場合は上と同様の正規表現オブジェクトを動的に作る必要がありますが、その場合は`before`や`after`の中に正規表現用の特殊文字が含まれていたら困るのでそれをエスケープする必要があります。これを行う標準的な方法は用意されていませんが、以下のようなコードで行うことができます([MDNより引用](https://developer.mozilla.org/ja/docs/Web/JavaScript/Guide/Regular_Expressions)):\n\n```\n\n function escapeRegExp(string) {\n return string.replace(/[.*+?^=!:${}()|[\\]\\/\\\\]/g, '\\\\$&'); // $&はマッチした部分文字列全体を意味します\n }\n \n```\n\nこの関数と`RegExp`コンストラクタを用いて以下のように正規表現オブジェクトを作って利用できます。\n\n```\n\n const re = new RegExp(`${escapeRegExp(before)}(.*)${escapeRegExp(after)}`);\n \n const result = str.match(re);\n if (result != null) {\n console.log(result[1]); // \"かきくけこ\"\n }\n \n```\n\n* * *\n\n正規表現を使わない方法としては、文字列の前後から`before`と`after`を検索して真ん中を取り出す方法があります。\n\n```\n\n // strの中のbeforeを前から検索\n const beforeIdx = str.indexOf(before);\n // strの中のafterを後ろから検索\n const afterIdx = str.lastIndexOf(after);\n \n if (beforeIdx >= 0 && afterIdx >= 0) {\n // 両方とも見つかったら中身を取り出す\n const result = str.substring(beforeIdx + before.length, afterIdx);\n console.log(result); // \"かきくけこ\"\n } \n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T05:39:14.347",
"id": "48613",
"last_activity_date": "2018-09-21T05:39:14.347",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30079",
"parent_id": "48611",
"post_type": "answer",
"score": 2
}
] | 48611 | 48613 | 48613 |
{
"accepted_answer_id": "48888",
"answer_count": 1,
"body": "マーカーを右クリックしてinfowindowを表示、その中にボタンを2つ以上作成しそれぞれ別のイベントを行う。というコードを書きたいのですが、方法がわかりません。HTMLを入れた場合onclickの対象がnullという風になってしまいます。よろしくお願いします。\n\n```\n\n var marker;\n var map;\n var infowindow;\n var getMap = (function() {\n function codeAddress(address) {\n // google.maps.Geocoder()コンストラクタのインスタンスを生成\n var geocoder = new google.maps.Geocoder();\n \n //Mapのオプション\n var mapOptions = {\n zoom: 16,\n mapTypeId: google.maps.MapTypeId.ROADMAP\n };\n \n //make map\n map = new google.maps.Map(document.getElementById('map-box'), mapOptions);\n \n // geocoder.geocode()メソッドを実行 \n geocoder.geocode( { 'address': address}, function(results, status) {\n \n // if success\n if (status == google.maps.GeocoderStatus.OK) {\n \n // 変換した緯度・経度情報を地図の中心に表示\n map.setCenter(results[0].geometry.location);\n \n //☆表示している地図上の緯度経度\n document.getElementById('lat').value=results[0].geometry.location.lat();\n document.getElementById('lng').value=results[0].geometry.location.lng();\n \n // Marker設定\n marker = new google.maps.Marker({\n map: map,\n position: results[0].geometry.location,\n });\n \n \n \n marker.addListener('rightclick', function(e) {\n getRightClickLatLng(e.latLng, marker);\n });\n function getRightClickLatLng(lat_lng, marker) {\n \n infowindow.open(map, marker);\n \n }\n \n \n // geocording成功しなかった場合\n } else {\n console.log('Geocode was not successful for the following reason: ' + status);\n }\n \n });\n \n //Mapをクリックで位置変更\n map.addListener('click', function(e) {\n getClickLatLng(e.latLng, map,marker);\n });\n function getClickLatLng(lat_lng, map,marker) {\n \n //☆表示している地図上の緯度経度\n document.getElementById('lat').value=lat_lng.lat();\n document.getElementById('lng').value=lat_lng.lng();\n \n // Marker設置\n marker.setMap(null);\n marker.position = lat_lng; \n marker.setMap(map); \n \n \n //latlngの中心をずらす\n map.panTo(lat_lng);\n }\n \n //lat,lngから地図表示\n document.getElementById(\"latlon_button\").onclick = function(){\n var s_lat = document.getElementById(\"lat\").value;\n var s_lng = document.getElementById(\"lng\").value;\n /*document.getElementById(\"form-text\").innerHTML = \"Pushed\"+parseFloat(s_lat);*/\n var latlng = {lat: Number(s_lat), lng: Number(s_lng)};\n marker.setMap(null);\n marker = new google.maps.Marker({\n position: latlng,\n map: map\n });\n \n // 座標の中心をずらす\n map.panTo(latlng);\n \n }\n \n \n var s_btn = document.createElement(\"button\");\n s_btn.innerText = \"出発地にセット\";\n google.maps.event.addDomListener(s_btn,\"click\", function(){\n document.getElementById(\"start_lat\").value = document.getElementById(\"lat\").value;\n document.getElementById(\"start_lng\").value = document.getElementById(\"lng\").value;\n document.getElementById(\"start-set\").innerHTML = \"出発地を設定しました。\";\n });\n \n var g_btn = document.createElement(\"button\");\n g_btn.innerText = \"到着地にセット\";\n google.maps.event.addDomListener(g_btn,\"click\", function(){\n document.getElementById(\"goal_lat\").value = document.getElementById(\"lat\").value;\n document.getElementById(\"goal_lng\").value = document.getElementById(\"lng\").value;\n document.getElementById(\"goal-set\").innerHTML = \"到着地を設定しました。\";\n });\n \n infowindow = new google.maps.InfoWindow({\n content:s_btn,//ここに上で作成したs_btnとg_btnを並べたい\n size: new google.maps.Size(20, 20)\n });\n \n \n \n document.getElementById(\"s_latlng_button\").onclick = function(){\n document.getElementById(\"start_lat\").value = document.getElementById(\"lat\").value;\n document.getElementById(\"start_lng\").value = document.getElementById(\"lng\").value;\n document.getElementById(\"start-set\").innerHTML = \"出発地を設定しました。\";\n }\n \n \n \n document.getElementById(\"g_latlng_button\").onclick = function(){\n document.getElementById(\"goal_lat\").value = document.getElementById(\"lat\").value;\n document.getElementById(\"goal_lng\").value = document.getElementById(\"lng\").value;\n document.getElementById(\"goal-set\").innerHTML = \"到着地を設定しました。\";\n }\n \n \n \n \n }\n \n //inputのvalueで検索して地図を表示\n return {\n getAddress: function() {\n // buttonに指定したid要素を取得\n var button = document.getElementById(\"map_button\");\n \n // buttonを押された時の処理\n button.onclick = function() {\n // formに入力された住所情報を取得\n var address = document.getElementById(\"address\").value;\n // 取得した住所を引数に指定してcodeAddress()関数を実行\n codeAddress(address);\n }\n \n \n //windowが読み込まれたときに地図を表示\n window.onload = function(){\n // formに入力された住所情報を取得\n var address = document.getElementById(\"address\").value;\n // 取得した住所を引数に指定してcodeAddress()関数を実行\n codeAddress(address);\n }\n } \n \n };\n })();\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T07:37:03.490",
"favorite_count": 0,
"id": "48616",
"last_activity_date": "2018-10-02T02:59:56.703",
"last_edit_date": "2018-09-21T07:59:47.777",
"last_editor_user_id": "2238",
"owner_user_id": "30195",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"google-maps"
],
"title": "infowindowに動的にボタンを2つ以上作る",
"view_count": 359
} | [
{
"body": "HTMLも含めた全体のソースが分からないのでInfoWindowに2つのボタンを追加する部分だけですが、以下の方法でどうでしょうか。\n\n```\n\n var container = document.createElement(\"div\");\n container.appendChild(s_btn);\n container.appendChild(g_btn);\n \n var infowindow = new google.maps.InfoWindow({\n content: container\n });\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-10-02T02:59:56.703",
"id": "48888",
"last_activity_date": "2018-10-02T02:59:56.703",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13314",
"parent_id": "48616",
"post_type": "answer",
"score": 0
}
] | 48616 | 48888 | 48888 |
{
"accepted_answer_id": "48620",
"answer_count": 1,
"body": "とくに意味をなさないうえに冗長なコードですが、サンプルのために、下記のようなソースがあるとします。\n\n```\n\n class Hoge<T: Equatable, U: Equatable> {\n var x: T?\n var y: U?\n \n init() {\n }\n }\n \n typealias TT = String\n typealias UU = Int\n \n let hoge = Hoge<TT, UU>()\n \n```\n\n`T`には`String`。 `U`には`Int`を教えることができました(この`教える`にあたる専門用語を忘れてしまいました...\n追記:`特殊化(specialization)`でした)。\n\nこれと同じことをするファクトリーのような関数を作りたいと考え下記のようにしましたがうまくいきません。うまい書き方はありますか?\n\n```\n\n func hogeFactory<TT: Equatable, UU: Equatable>() -> Hoge<TT, UU> {\n return Hoge<TT, UU>()\n }\n \n let h = hogeFactory<String, Int>()\n \n```\n\n> MyPlayground.playground:12:20: note: while parsing this '<' as a type\n> parameter bracket \n> let h = hogeFactory()",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T08:21:04.160",
"favorite_count": 0,
"id": "48617",
"last_activity_date": "2019-06-29T08:52:01.770",
"last_edit_date": "2019-06-29T08:52:01.770",
"last_editor_user_id": "9008",
"owner_user_id": "9008",
"post_type": "question",
"score": 1,
"tags": [
"swift",
"ジェネリクス"
],
"title": "ジェネリクスに型を教えた状態のクラスを返したい",
"view_count": 613
} | [
{
"body": "コメントに書きましたが、Swiftではジェネリック関数を呼び出す時、ジェネリックパラメータ(この例でいう`TT`や`UU`に当てはめるための具体的な型)を明示的に指定することはできません。\n\n```\n\n func hogeFactory<TT: Equatable, UU: Equatable>() -> Hoge<TT, UU> {\n return Hoge<TT, UU>()\n }\n \n let h = hogeFactory<String, Int>() //<-これはエラーになる\n \n```\n\nもちろん型が決定できないのでは、別のエラーになります。では、どうやって指定するのかというと、型推論でそれが決定できるようにしてやらないといけません。\n\n例えばこんな感じ。\n\n```\n\n let h: Hoge<String, Int> = hogeFactory()\n \n```\n\nただ、これではせっかくファクトリーメソッドを作って、表から`Hoge`クラスの存在を隠したのに、あまり意味がない(普通にイニシャライザを使った方が簡単…)ように見えるので、こんな書き方もよくします。\n\n```\n\n func hogeFactory<TT: Equatable, UU: Equatable>(_:TT.Type, _:UU.Type) -> Hoge<TT, UU> {\n return Hoge<TT, UU>()\n }\n \n let hh = hogeFactory(String.self, Int.self)\n \n```\n\n後者の書き方(型推論ができるようにするためだけの型引数を持たせる)と言うのは、Swiftの標準ライブラリでもよく使われているのですが、何か動的に型が指定できるような気がしてくるという欠点があります。(Swiftの型推論はコンパイル時に働く、実行時に動的に働くのではない。)\n\nその辺はまた実際の問題に遭遇した時に再度質問してもらった方がいいでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T08:59:24.333",
"id": "48620",
"last_activity_date": "2018-09-21T08:59:24.333",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "48617",
"post_type": "answer",
"score": 2
}
] | 48617 | 48620 | 48620 |
{
"accepted_answer_id": "48625",
"answer_count": 3,
"body": "極めて初心者らしい質問になりますがよろしくお願いします。\n\nWebシステムはステートレスとよく言われますが、PHP側の検証が成立せずDBへの登録が進行できなかった場合、送信されてきた状態の画面を維持したい、ということがあると思います。 \n逆に、DBへの登録まで成立した場合は(他へ遷移せず当該画面で継続して処理していくケース)、 \n入力されていた内容のほとんどをクリアして画面を再表示したい という仕様を望んでいます。\n\n送信結果を再格納するケースと、送信結果を再格納しないケースに大別できますが、一般的にはどういう解決策で、制御すべきなのでしょうか? \n下記は送信された結果を変数に蓄え、それを再格納するようなHTML&PHPです。 \n・この仕様では、画面上の項目数分 変数を用意しなければならない。 \n・正常にDBへの登録へ進行した場合、これら変数をクリアしなければならない。\n\n```\n\n <input type=\"text\" name=\"tcd\" id=\"tcd\" style=\"width: 5em;\" value=\"<?php if(isset($tcd)){ echo $tcd; } ?>\" />\n \n```\n\nと思いました。こういう達成の仕方が一般的なのでしょうか? \nセッション変数を使うにしても、維持とクリアの制御が必要ですよね??\n\nフレームワークを使わない場合、どういった対策をとるのが一般的なのか知りたいです。 \nよろしくお願い致します。\n\n<<追記>> \n$dataに蓄えたい内容は、この中のinput要素\n\n```\n\n <div class=\"appControl\">\n <table>\n <tr>\n <td class=\"extd\">得意先</td>\n <td><input name=\"tcd\" id=\"tcd\" type=\"text\"></td>\n <td><input name=\"tname\" type=\"text\" readonly=\"\"></td>\n <td><input name=\"tperson\" type=\"text\" readonly=\"\"></td>\n <td class=\"extd\">納品先</td>\n <td><input name=\"scd\" id=\"scd\" type=\"text\"></td>\n <td><input name=\"sname\" type=\"text\" readonly=\"\"></td>\n <td><input name=\"sperson\" type=\"text\" readonly=\"\"></td>\n </tr>\n </table>\n </div>\n \n <div class=\"appLines\">\n <table>\n <tr>\n <td><input name=\"cd[]\" type=\"text\" value=\"\"></td>\n <td><input name=\"name[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><input name=\"capa[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><input name=\"scond[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><input name=\"lot[]\" type=\"text\" value=\"\"></td>\n <td><input name=\"amount[] type=\"text\" value=\"\"></td>\n <td><input name=\"unitp[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><input name=\"totalp[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><span class=\"errmark\"></span></td>\n <td><button class=\"rowins\" type=\"button\">+</button></td>\n <td><button class=\"rowdel\" type=\"button\">-</button></td>\n </tr>\n <tr>\n <td><input name=\"cd[]\" type=\"text\" value=\"\"></td>\n <td><input name=\"name[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><input name=\"capa[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><input name=\"scond[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><input name=\"lot[]\" type=\"text\" value=\"\"></td>\n <td><input name=\"amount[] type=\"text\" value=\"\"></td>\n <td><input name=\"unitp[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><input name=\"totalp[]\" type=\"text\" readonly=\"\" value=\"\"></td>\n <td><span class=\"errmark\"></span></td>\n <td><button class=\"rowins\" type=\"button\">+</button></td>\n <td><button class=\"rowdel\" type=\"button\">-</button></td>\n </tr>\n </table>\n </div>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T08:36:35.230",
"favorite_count": 0,
"id": "48618",
"last_activity_date": "2018-10-13T19:26:27.910",
"last_edit_date": "2018-09-22T03:22:16.140",
"last_editor_user_id": "25696",
"owner_user_id": "25696",
"post_type": "question",
"score": 0,
"tags": [
"php",
"html"
],
"title": "PHP ステートレス故消える前回入力されていた画面の内容を、再送する方法を知りたい。",
"view_count": 979
} | [
{
"body": "javascriptでajaxを使って画面を残したままデータを送信して、非同期で処理をさせることで実現可能です。 \n処理の成否をajaxの結果としてクライアント側に返却し、その結果の内容をjavascriptで確認します。\n\n処理の結果が失敗であれば画面上に失敗を示すメッセージを表示させてそのままにすることで、入力内容はリセットされることがありません。\n\n処理の結果が成功であれば、javascriptで画面をリロードするなどして入力をクリアします。\n\najaxは非同期で通信するので、送信ボタンを連打したらその数だけリクエストが飛びます。 \n送信ボタンが押されたらボタンを無効にするか、画面全体を処理中の画面でオーバーラップするなどでボタンの連打を阻止する必要があります。\n\nこの方法をとることのメリットとして、POST後の画面で画面を更新するときに情報の再送信を求められることがないという点もあります。\n\n・参考)JavaScriptが禁止の場合 \n最近はあまり聞かないですが、一昔前にJavaScriptの利用が禁忌とされている時代がありました。 \nその頃でもセッション変数は利用せずに、自身にPOSTして失敗した場合はリクエストの処理後に、送信されてきたデータを利用して画面を再構築していました。 \n成功した場合はHTTP HeaderのLocationを利用して成功後の画面に遷移させていました。\n\nリクエストの内容を保持するためにセッション変数を利用するとセッションが肥大化したり、画面を直接消すなど、イベントの取れない操作をユーザーがしたときに前に入力していたデータが復活してしまうなどの不具合に悩まされてしまうことがあります。\n\nいかがでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T09:44:35.637",
"id": "48621",
"last_activity_date": "2018-09-21T09:44:35.637",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "17014",
"parent_id": "48618",
"post_type": "answer",
"score": 0
},
{
"body": "いろいろやり方はあるでしょうが。基本的には、層別モデルで言うところのビジネスロジック層とプレゼンテーション層はできるだけくっきりはっきり分ける、と言うことになるかと思います。\n\n[入力フォーム初期処理ロジック.php]\n\n```\n\n (ログインチェックやなんかはこちら。フレームワークを使うと自動的にやってくれたりする。)\n (nonceを生成したり、それをcookieに入れたり、セッションに保存するのもここ)\n $data = 「入力画面に全部空っぽのデータを表示するためのデータ」\n [入力フォーム画面表示.php]を呼び出す (*)\n \n```\n\n(*)`require`とか何とかでよい。フレームワークを使うと決まったやり方がある。\n\n[入力フォーム画面表示.php]\n\n```\n\n $dataの中身を元にformの初期値やエラー表示(もちろん初期表示では空)のHTMLを返す\n (nonceがある場合は、もちろんそれをhiddenに入れておく。)\n 「登録」ボタンの飛び先は、[入力データ登録ロジック.php]にしておく\n \n```\n\n[入力データ登録ロジック.php]\n\n```\n\n (ログインチェックやなんかはこちら。フレームワークを使うと以下同上。)\n 入力画面のformから受け取ったデータを$dataに入れる。\n ([入力フォーム画面表示.php]が扱える形式にしておくと便利。フレームワークを使うと以下同上。)\n $dataを検証(nonceなんかのチェックも)\n if( 検証失敗 ) {\n $dataに検証失敗のエラー情報などを追加。\n (必要ならnonceの更新などもやる。)\n [入力フォーム画面表示.php]を呼び出す\n } else {\n $dataをDBに登録\n if( 成功 ) {\n (全くの初めてじゃないことを知らせるときはセッションなんかを利用する)\n (nonceのクリアなんかはこちら。)\n [入力フォーム初期処理ロジック.php]へ**リダイレクト**(*2)\n ($dataのクリアなんかは、[入力フォーム初期処理ロジック.php]がやってくれる。)\n } else if( 入力データの修正で何とかなりそうなエラー ) {\n $dataにDB登録失敗のエラー情報などを追加。\n (必要ならnonceの更新などもやる。)\n [入力フォーム画面表示.php]を呼び出す\n } else {\n (nonceのクリアなんかはこちら。)\n (エラー情報は変数には入らないので、セッションとかに入れる。)\n [どうしようもないエラーロジック.php]へ**リダイレクト**(*2)\n }\n }\n \n```\n\n(*2)リダイレクトを使うのはいわゆるリロード対策。[入力データ登録ロジック.php]から直接(画面表示用のphpを`require`なんかで表示するのは、ブラウザから見ると「直接」と同じ)HTMLを返すとブラウザに[入力データ登録ロジック.php]のURLが記憶され、リロード(WindowsならF5?)をするだけで「入力データ登録」の処理が何度も走ってしまう。\n\n[どうしようもないエラーロジック.php]は省略します。普通は、何もしないで[どうしようもないエラー画面表示.php]を呼び出すだけですね。\n\n異常系を除けば、入力フォーム初期処理ロジック.php(これはほぼ空のデータを作るだけなので簡単)、入力フォーム画面表示.php(ひたすらformを含むHTMLの記述)、入力データ登録ロジック.php(普通メインの登録処理よりエラーチェックの方が長くなったりする)の3つをしっかり作ればOKと言うことになります。\n\nユーザがどんな操作をしたら、サーバ側のPHPがどんな処理を行い、ブラウザがどんな表示をするのかとかを頭の中でシミュレートしながら読んでみてください。\n\n* * *\n\nちなみに、今時のシステムなら、JavaScriptでユーザビリティを高めるような処理をあれこれ入れ込むのは当然です。\n\nさらにちなみに、今まで(他質問を含めて)簡単に「セッション」なんて書いてきましたが、PHPのデフォルトのセッション管理はなかなか脆弱なので、高セキュアなシステムが要求されているなら、そこら辺の対策も考えないといけません。\n\n* * *\n\n<<追記>>に示していただいたフォーム内の要素に初期値を埋め込むコードは以下のような感じになります。掲載の都合上繋げてしまってますが、PHPのコード部分は[入力フォーム初期処理ロジック.php]みたいな場所に、HTML部分は[入力フォーム画面表示.php]みたいな場所に置かれるのを想定しています。\n\n```\n\n <?php \n //PHPのコード部分は実際には別ファイルにしておく\n \n //この手の関数を(短い名前で)用意しないとHTMLに埋め込まれるコードが長くなりすぎて可読性を損なう\n function esc($value) {\n if( isset($value) && $value !== '' ) {\n return htmlspecialchars(value);\n } else {\n return '';\n }\n }\n \n //$dataの初期化\n $data = [];\n //'tcd'〜'sperson'までの値を入れていく\n $data['tcd'] = 'Txxxx';\n //...\n //'row'の中身は初期画面なら空配列を入れる\n $data['row'] = [];\n ?>\n <div class=\"appControl\">\n <table>\n <tr>\n <td class=\"extd\">得意先</td>\n <td><input name=\"tcd\" id=\"tcd\" type=\"text\" value=\"<?=esc($data['tcd'])?>\"></td>\n <td><input name=\"tname\" type=\"text\" readonly=\"\" value=\"<?=esc($data['tname'])?>\"></td>\n <td><input name=\"tperson\" type=\"text\" readonly=\"\" value=\"<?=esc($data['tperson'])?>\"></td>\n <td class=\"extd\">納品先</td>\n <td><input name=\"scd\" id=\"scd\" type=\"text\" value=\"<?=esc($data['scd'])?>\"></td>\n <td><input name=\"sname\" type=\"text\" readonly=\"\" value=\"<?=esc($data['sname'])?>\"></td>\n <td><input name=\"sperson\" type=\"text\" readonly=\"\" value=\"<?=esc($data['sperson'])?>\"></td>\n </tr>\n </table>\n </div>\n \n <div class=\"appLines\">\n <table>\n <?php //画面表示用PHPのHTML内にはデータ構造を分解する簡単なPHPコードだけ埋め込み可能とする\n if( count($data['row']) > 0 ) {\n for( $i = 0; $i < count($data['row']); ++$i ) { ?>\n <tr>\n <td><input name=\"row[<?=$i?>][cd]\" type=\"text\" value=\"<?=esc($data['row'][$i]['cd'])?>\"></td>\n <td><input name=\"row[<?=$i?>][name]\" type=\"text\" readonly=\"\" value=\"<?=esc($data['row'][$i]['name'])?>\"></td>\n <td><input name=\"row[<?=$i?>][capa]\" type=\"text\" readonly=\"\" value=\"<?=esc($data['row'][$i]['capa'])?>\"></td>\n <td><input name=\"row[<?=$i?>][scond]\" type=\"text\" readonly=\"\" value=\"<?=esc($data['row'][$i]['scond'])?>\"></td>\n <td><input name=\"row[<?=$i?>][lot]\" type=\"text\" value=\"<?=esc($data['row'][$i]['lot'])?>\"></td>\n <td><input name=\"row[<?=$i?>][amount] type=\"text\" value=\"<?=esc($data['row'][$i]['amount'])?>\"></td>\n <td><input name=\"row[<?=$i?>][unitp]\" type=\"text\" readonly=\"\" value=\"<?=esc($data['row'][$i]['unitp'])?>\"></td>\n <td><input name=\"row[<?=$i?>][totalp]\" type=\"text\" readonly=\"\" value=\"<?=esc($data['row'][$i]['totalp'])?>\"></td>\n <td><span class=\"errmark\"></span></td>\n <td><button class=\"rowins\" type=\"button\">+</button></td>\n <td><button class=\"rowdel\" type=\"button\">-</button></td>\n </tr>\n <?php\n }\n } else { ?>\n <!-- $data内の'row'が空の時の画面を別に作る(例えば表は最低2行表示するとか)ならこちらへ -->\n <?php\n } ?>\n </table>\n </div>\n \n```\n\n(ちなみにPHPでは、文法的にはHTMLの途中に好きなだけPHPのコードを挟み込めたり、グローバル変数もグローバル関数も定義し放題なので、ある程度コーディングルールを縛らないと、なんでもありの好き勝手し放題でメンテほぼ不能なコードが大量に出来上がりますのでお気をつけを…。)\n\nあまりきちんと検証していないので、あちこち手直ししないといけないでしょうが、ざっくりの雰囲気はわかると思います。これをフォームにして送信されたデータをPHP側で受けるとどうなるかとかは、フォーム側と受信側のサンプルを作ってみて、`$_POST`の中身を調べるとかしてください。\n\n(基本的には受信側で`$data = $_POST`なんてやると、一発で必要なデータが`$data`に入っちゃう、と言う想定です。)",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T11:25:32.937",
"id": "48625",
"last_activity_date": "2018-09-22T04:43:08.810",
"last_edit_date": "2018-09-22T04:43:08.810",
"last_editor_user_id": "13972",
"owner_user_id": "13972",
"parent_id": "48618",
"post_type": "answer",
"score": 1
},
{
"body": "メアドとパスワードのみチェックする簡単な例で説明します。\n\n 1. まだ、POSTが送信されていない場合は、中ほどの }else{ 以降のフォームが表示されています。\n\n 2. フォームが送信されたら、POSTの値をチェックして、エラーの場合には$err、パスした場合には$msgに配列で入れます。 \n$msg['']は、再表示するための配列です。\n\n 3. $err配列の数をチェックして、0だったらエラーなしの場合の処理に移ります。(DBに入れるなど) \nスクリプト中は省いてますが、mysqli_real_escape_string()などの処理をしてください。\n\n 4. DBに入れた後、 'スタッフを登録しました.' で、すべての処理が終わりです。\n\n※解りやすくするために、2重投稿のチェックは省いてます。\n\n```\n\n <?php\n if(isset($_POST['publish'])){//------ publishがPOSTされたら\n \n //------------------------------------- emailのチェック\n if($_POST['email'] == \"\")\n {\n $err['email'] = '<font color=\"red\"> 未記入です。</font>';\n }else{\n \n if(preg_match('/^([a-z0-9\\+_\\-]+)(\\.[a-z0-9\\+_\\-]+)*@([a-z0-9\\-]+\\.)+[a-z]{2,6}$/iD',$_POST['email'])){\n $msg['email'] = htmlspecialchars($_POST['email'], ENT_QUOTES);//サニタイズ\n }else{\n $err['email'] = '<font color=\"red\"> 正しくないメールアドレスです。</font>';\n }\n }\n //------------------------------------- passwordのチェック\n if($_POST['password'] == \"\"){//空かどうかチェック\n $err['password'] = '<font color=\"red\"> 未記入です。</font>';\n }else{\n //-- 正規表現でチェック 必ず英字を1文字以上数字を1文字以上含み半角英数記号で構成\n if(preg_match('/^[0-9a-zA-Z -\\/:-@\\[-`\\{-\\~\\]]*([a-zA-Z]+(?=[0-9])|[0-9]+(?=[a-zA-Z]))[0-9a-zA-Z -\\/:-@\\[-`\\{-\\~\\]]*$/', $_POST['password'])){\n $msg['password'] = htmlspecialchars($_POST['password'], ENT_QUOTES);\n }else{\n $err['password'] = '<font color=\"red\"> 必ず英字を1文字以上数字を1文字以上含み半角英数記号で構成してください。</font>';\n }\n }\n \n if(count($err) == 0){//-------------------- すべてのエラーチェックを通ったら\n //--------------------- ここでPOSTの値をデータベースに入れます。\n $q_email = $_POST['email'];\n $q_password = $_POST['password'];\n \n $sql = \"insert into `$table` (`id`,`email`,`password`) values ('','$q_email','$q_password')\";\n //----- DBに入れた後、$success = TRUE\n $success=\"true\";\n }\n }\n if($success==\"true\"){\n echo 'スタッフを登録しました.';\n }else{\n //------------- 未送信の場合 ---------//\n \n ?>\n <h3>メンバー追加</h3>\n <form action=\"\" method=\"post\" autocomplete=\"off\">\n \n <h4>email :\n <input type=\"text\" name=\"email\" maxlength=\"50\" size=\"40\" value=\"<?php echo $msg['email'];?>\" /><?php echo $err['email'];?>\n </h4>\n \n <h4>password :\n <input type=\"password\" name=\"password\" maxlength=\"20\" size=\"20\" value=\"<?php echo $msg['password'];?>\" /><?php echo $err['password'];?>\n </h4>\n \n <hr />\n <input name=\"publish\" type=\"submit\" value=\"送信\">\n </form>\n \n <?php\n }\n ?>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-10-13T17:23:39.823",
"id": "49254",
"last_activity_date": "2018-10-13T19:26:27.910",
"last_edit_date": "2018-10-13T19:26:27.910",
"last_editor_user_id": "30255",
"owner_user_id": "30255",
"parent_id": "48618",
"post_type": "answer",
"score": 0
}
] | 48618 | 48625 | 48625 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "私の質問の概要は、リスト内包表記で文字列から複数の不要な文字列を除去する処理の書き方です。\n\n例えば、\n\n```\n\n \"a皆a様aよbろbしbくcおc願cいcしNULLまNULLす。\"\n \n```\n\nから不要な[\"a\",\"b\",\"c\",\"NULL\"]を除去して\n\n```\n\n \"皆様よろしくお願いします。\"\n \n```\n\nを得るために\n\n```\n\n words = \"a皆a様aよbろbしbくcおc願cいしNULLまNULLす。\"\n alist = [\"a\", \"b\", \"c\",\"NULL\"]\n for delstr in alist:\n words = words.replace(delstr, \"\")\n \n```\n\nという処理をしています。しかし、wordsは多数存在し、alistも巨大なため、リスト内包表記で高速化が出来ないかと考え、以下のようなコードを書きました。\n\n```\n\n [words.replace(delstr, \"\") for delstr in alist]\n \n```\n\nしかし、これではwordsからalistのそれぞれの要素を除去したリストが得られてしまうため、目的を果たせません。\n\n一つの方法は上記のwordsをリスト内包表記にしてalistの要素をループ毎にwordsのリストから除去する方法ですが、もし内包表記で単一のオブジェクトに複数の処理ことができるならばwordsのリストとalistを一括して内包表記にできるため、より望ましいと考えています。wordsからalistの要素すべてをリスト内包表記で除去する方法があればご教示頂ければ幸いです。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T10:01:38.277",
"favorite_count": 0,
"id": "48622",
"last_activity_date": "2018-09-22T03:03:42.327",
"last_edit_date": "2018-09-21T11:39:43.583",
"last_editor_user_id": "30198",
"owner_user_id": "30198",
"post_type": "question",
"score": 7,
"tags": [
"python"
],
"title": "list内包表記で単一の文字列から複数の文字列を取り除く方法はあるでしょうか",
"view_count": 471
} | [
{
"body": "[`re.sub`](https://docs.python.jp/3/library/re.html#re.sub) を使う案です。\n\n```\n\n import re\n words_re = re.compile(\"|\".join(re.escape(w) for w in alist))\n result = re.sub(words_re, '', words)\n \n```\n\n削除文字列(`alist`)の内容によっては `replace` を繰り返した場合とは違う結果になるので注意して下さい。例えば、\n\n```\n\n words = \"<abc>\"\n alist = [\"b\", \"abc\"]\n \n```\n\nだとすると、`replace` では `b` の削除のみが起こり結果は `<ac>`で、正規表現だと先に `abc` のマッチが始まるので `abc`\nが削除され結果は `<>` になります。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T10:26:37.317",
"id": "48623",
"last_activity_date": "2018-09-21T12:52:07.233",
"last_edit_date": "2018-09-21T12:52:07.233",
"last_editor_user_id": "3054",
"owner_user_id": "3054",
"parent_id": "48622",
"post_type": "answer",
"score": 5
},
{
"body": "高階関数の`functools.reduce`を使うと1行で書くことができます。 \n<https://docs.python.org/ja/3/howto/functional.html#the-functools-module>\n\n```\n\n def func(a, b):\n return a.replace(b, \"\")\n \n words = \"a皆a様aよbろbしbくcおc願cいしNULLまNULLす。\"\n alist = [\"a\", \"b\", \"c\",\"NULL\"]\n functools.reduce(func, alist, words)\n \n```\n\nこれをラムダ式を使って書くと\n\n```\n\n functools.reduce(lambda a, b:a.replace(b, \"\"), alist, words)\n \n```\n\nただし、ドキュメントには、「多くの場合 functools.reduce() を使うよりは、単に for\nループを書いたほうがわかりやすくなります」とあります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T03:03:42.327",
"id": "48634",
"last_activity_date": "2018-09-22T03:03:42.327",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "48622",
"post_type": "answer",
"score": 3
}
] | 48622 | null | 48623 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "MPI では -np と OMP_NUM_THREADS の値をどのように設定すればよいですか? \nPCによって,値は決まっていますか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T10:51:58.120",
"favorite_count": 0,
"id": "48624",
"last_activity_date": "2018-09-23T14:20:23.807",
"last_edit_date": "2018-09-23T14:20:23.807",
"last_editor_user_id": "19110",
"owner_user_id": "30199",
"post_type": "question",
"score": 2,
"tags": [
"fortran",
"mpi"
],
"title": "MPI では -np と OMP_NUM_THREADS の値をどのように設定すればよいですか?",
"view_count": 711
} | [
{
"body": "並列数の最大値は PC ごとに決まっています。\n\nその PC でどれくらいの並列数が持てるのかの確認で、一番簡単なのは、\n\nLinux\n\n```\n\n $ top\n \n```\n\nそのまま `1` を押す\n\n[](https://i.stack.imgur.com/8QecF.png)\n\nこの場合 8 並列が可能です。\n\n* * *\n\nWindows\n\nタスクバーで右クリック > タスクマネージャ > [パフォーマンス]タブ > [CPU]タブ > グラフ上で右クリック > グラフの変更 > 論理プロセッサ\n\n[](https://i.stack.imgur.com/TLvZy.png)\n\nこの場合も 8 並列が可能です。\n\n* * *\n\nきちんと MPI で書かれた fortran プログラムの実行バイナリが `a.out` であり、並列数が `8` だとすれば\n\n```\n\n mpirun -np 8 ./a.out\n \n```\n\nになります。\n\nまた、`OMP_NUM_THREADS` は OpenMP を使う際の並列数に関する環境変数です。MPI 系とは似て非なりますので、まずは MPI\nか、OpenMP か、どちらでかかれたプログラムを実行しようとしているのか調べると早い解決に繋がると思われます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T07:37:21.510",
"id": "48639",
"last_activity_date": "2018-09-22T07:52:27.317",
"last_edit_date": "2018-09-22T07:52:27.317",
"last_editor_user_id": "29146",
"owner_user_id": "29146",
"parent_id": "48624",
"post_type": "answer",
"score": 4
}
] | 48624 | null | 48639 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "local環境 \nmacOS HighSierra\n\nDocker環境 \nCentOS\n\nです。\n\nDockerfileに、NEologdのインストールコマンドを記載してDockerコンテナに反映させようとしています。\n\n手順としては、\n\ngit cloneでNEologdをダウンロード。\n\nNEologdがあるフォルダに移動し、そこで\n\n```\n\n RUN ./bin/install-mecab-ipadic-neologd -n -a\n \n```\n\nのコマンドを書いています。ローカルのPC上ではこれでうまくインストール出来たのですが、Dockerfileでコンテナにインストールしようとすると。下記エラーが出ます。\n\n```\n\n Step 63/64 : RUN ./bin/install-mecab-ipadic-neologd -n -a\n --> Running in bc6b31c0e729\n [install-mecab-ipadic-NEologd] : Start..\n [install-mecab-ipadic-NEologd] : Check the existance of libraries\n [install-mecab-ipadic-NEologd] : find => ok\n [install-mecab-ipadic-NEologd] : sort => ok\n [install-mecab-ipadic-NEologd] : head => ok\n [install-mecab-ipadic-NEologd] : cut => ok\n [install-mecab-ipadic-NEologd] : egrep => ok\n [install-mecab-ipadic-NEologd] : mecab => ok\n [install-mecab-ipadic-NEologd] : mecab-config => ok\n [install-mecab-ipadic-NEologd] : make => ok\n [install-mecab-ipadic-NEologd] : curl => ok\n [install-mecab-ipadic-NEologd] : sed => ok\n [install-mecab-ipadic-NEologd] : cat => ok\n [install-mecab-ipadic-NEologd] : diff => ok\n [install-mecab-ipadic-NEologd] : tar => ok\n [install-mecab-ipadic-NEologd] : unxz => ok\n [install-mecab-ipadic-NEologd] : xargs => ok\n [install-mecab-ipadic-NEologd] : grep => ok\n [install-mecab-ipadic-NEologd] : iconv => ok\n which: no patch in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)\n [install-mecab-ipadic-NEologd] : patch is not found.\n ERROR: Service 'predict-regulation-type' failed to build: The command '/bin/sh -c ./bin/install-mecab-ipadic-neologd -n -a' returned a non-zero code: 1\n \n```\n\nどうすれば解決出来るのかわからず苦戦しております。何かアドバイス頂ければ幸いです。 \nよろしくお願い致します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T13:41:11.470",
"favorite_count": 0,
"id": "48626",
"last_activity_date": "2018-09-27T04:53:38.957",
"last_edit_date": "2018-09-27T04:53:38.957",
"last_editor_user_id": "19110",
"owner_user_id": "30201",
"post_type": "question",
"score": 3,
"tags": [
"python",
"docker"
],
"title": "Dockerコンテナに mecabの辞書、NEologdをインストールしたいのですがエラー解決が出来ません。",
"view_count": 650
} | [
{
"body": "エラーメッセージから判断すると`patch`がインストールされていないためと思われます。\n\nDebian系だと以下でインストールできます。\n\n```\n\n sudo apt install patch\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T05:04:15.743",
"id": "48636",
"last_activity_date": "2018-09-22T05:04:15.743",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "48626",
"post_type": "answer",
"score": 1
}
] | 48626 | null | 48636 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "boolean\nのカラムへのインデックスの追加は偏りが大きくなければ基本的にあまり変わらないと認識していたのですが、インデックスをはっていないと非常に(数百倍)遅くなる現象に遭遇しました。\n\n```\n\n Benchmark.measure{ Company.where(boolean_column_without_index: false).count }\n #<Benchmark::Tms:0x00007fbf763319f8 @label=\"\", @real=4.518864024430513, @cstime=0.0, @cutime=0.0, @stime=0.0, @utime=0.010000000000000675, @total=0.010000000000000675>\n Benchmark.measure{ Company.where(boolean_column_with_index: false).count }\n #<Benchmark::Tms:0x00007fbf75466130 @label=\"\", @real=0.017290733754634857, @cstime=0.0, @cutime=0.0, @stime=0.0, @utime=0.009999999999999787, @total=0.009999999999999787>\n \n```\n\nDBは`psql (PostgreSQL) 9.6.9`を使用しています。ローカル環境(`9.6.3`)では同じ内容のデータを使っても現象が再現しません。\n\n`Company`の件数は5000件ほどしかありません、`false`が2,3割程度とそれほど方よりもありません。\n\nとりあえずは必要なカラムにindexを追加することで対処したのですが、\n\n何故このような状態に何故なってしまうのでしょうか? \nまたどうやって原因を調査すればよいですか?",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T21:04:09.783",
"favorite_count": 0,
"id": "48631",
"last_activity_date": "2018-09-21T21:04:09.783",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3271",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"postgresql"
],
"title": "Postgresql で boolean のカラムにインデックスを付けてないと非常に遅くなる",
"view_count": 1264
} | [] | 48631 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Windows formでのUI面のデザインがシンプルだったりするため、webBrowserを使ってブタンを表示してみようと思いました。 \n試しに以下のシンプルなボタンをbtn1.htmlとして、WindowsFormsApplication1.exeと同じフォルダーパスに配置しました。\n\nbtn1.htmlの中身は以下のようになっています。\n\n```\n\n <html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n <style type=\"text/css\">\n #btn{\n margin: 0px;\n width: 180px;\n border-radius: 5px;\n box-shadow: 0 4px 0 #e91b0c;\n background: #f44336;\n color:#fff;\n cursor: pointer;\n padding: 7px;\n text-align: center;\n }\n #btn:hover{\n opacity: 0.8;\n }\n #btn:active{\n background: #FFA500 ;\n box-shadow: 0 4px 0 #FFB550 ;\n width: 150px ;\n margin: 5px;\n }\n </style>\n <script type=\"text/javascript\">\n \n </script>\n <title>test</title>\n </head>\n \n <body>\n <div id=\"btn\">button1</div>\n </body>\n </html>\n \n```\n\nこのbtn1.htmlはIEやChromeで開くとhover、activeはしっかり動いています。 \nですが、これをwebBrowserを実装したWinformで動かすと全く動いてくれません(ボタンの描画はできています)。 \n正確にはCSSが反映されていないのでhoverやactiveが読み込まれないようです。\n\n下記がwinformのソースです。\n\n```\n\n using System;\n using System.Collections.Generic;\n using System.ComponentModel;\n using System.Data;\n using System.Drawing;\n using System.Linq;\n using System.Text;\n using System.Windows.Forms;\n \n namespace WindowsFormsApplication1\n {\n public partial class Form1 : Form\n {\n public Form1( )\n {\n InitializeComponent( );\n }\n \n private void Form1_Load( object sender , EventArgs e )\n {\n \n }\n \n private void button1_Click( object sender , EventArgs e )\n {\n String local ;\n String address ;\n \n local = Application.StartupPath ;\n address = \"file:\\\\\\\\\" + local + textBox1.Text ;\n label1.Text = address ;\n \n webBrowser1.Navigate( new Uri( address ) ) ;\n }\n \n public bool IsHorizontalScrollbarPresent( WebBrowser web )\n {\n try\n {\n var widthofScrollableArea = web.Document.Body.ScrollRectangle.Width;\n var widthofControl = web.Document.Window.Size.Width;\n \n return widthofScrollableArea > widthofControl;\n }\n catch( Exception ex )\n {\n return false ;\n }\n }\n \n private void webBrowser1_DocumentCompleted( object sender , WebBrowserDocumentCompletedEventArgs e )\n {\n if ( IsHorizontalScrollbarPresent( webBrowser1 ) )\n {\n webBrowser1.ScrollBarsEnabled = false ;\n webBrowser1.Document.Body.Style = \"zoom:40%\" ;\n webBrowser1.Visible = true ;\n }\n else\n {\n webBrowser1.Visible = true ;\n }\n }\n }\n }\n \n```\n\nどう修正したらCSSが反映されるようになるのでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-21T23:36:37.797",
"favorite_count": 0,
"id": "48632",
"last_activity_date": "2023-05-07T03:19:19.387",
"last_edit_date": "2023-05-07T03:19:19.387",
"last_editor_user_id": "4236",
"owner_user_id": "29866",
"post_type": "question",
"score": 0,
"tags": [
"c#",
"css",
"winforms"
],
"title": "Windows formでWebBrowserを使うとCSSが反映されない",
"view_count": 1438
} | [
{
"body": "WebBrowserコントロールは描画にInternet Explorerを使用しています。そしてInternet\nExplorerにはブラウザーモードとドキュメントモードがあり、これを理解する必要があります。\n\n * WebBrowserコントロールは表示内容が変化しないように互換性を維持するため、IE7ブラウザーモードとなります。\n * IE10以下のブラウザーモードで適切な`<!DOCTYPE>`宣言がされていない場合、IE5ドキュメントモードで表示されます。\n\nその上で質問文にあるHTMLには`<!DOCTYPE>`宣言が含まれていないため、CSSが反映されないのではなくIE5モードで表示されているだけです。参考までにIE11で当該HTMLを開きF12開発者ツールを使用してドキュメントモードをIE5に指定すると同じ結果を見ることができます。\n\nWebBrowserコントロールのブラウザーモードを変更するにはWebBrowserコントロールを読み込む前に[Browser\nEmulation](https://docs.microsoft.com/en-us/previous-\nversions/windows/internet-explorer/ie-developer/general-\ninfo/ee330730\\(v%3Dvs.85\\)#browser-emulation)のレジストリ値を設定します。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T08:37:51.460",
"id": "48640",
"last_activity_date": "2018-09-22T08:37:51.460",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "48632",
"post_type": "answer",
"score": 1
}
] | 48632 | null | 48640 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "アンドロイドスタジオについての初歩的な質問です。 \n現在アンドロイドスタジオをインストールして2日の初心者です。 \n`Hallo world`やその他のテキストビューを配置したいのです。 \nしかし、水平方向についての制約に対するエラーだとは思うのですが、\n\n> This view is not constrained horizontally: at runtime it will jump to \n> the left unless you add a horizontal constraint The layout editor \n> allows you to place widgets anywhere on the canvas, and it records the \n> current position with designtime attributes (such as \n> layout_editor_absoluteX). These attributes are not applied at runtime, \n> so if you push your layout on a device, the widgets may appear in a \n> different location than shown in the editor. To fix this, make sure a \n> widget has both horizontal and vertical constraints by dragging from \n> the edge connections.\n\nという文がでてテキストビューをドラッグ&ドロップできません。\n\nよろしければ回答おねがいします。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T02:23:20.300",
"favorite_count": 0,
"id": "48633",
"last_activity_date": "2018-09-22T04:51:17.560",
"last_edit_date": "2018-09-22T04:51:17.560",
"last_editor_user_id": null,
"owner_user_id": "30204",
"post_type": "question",
"score": 0,
"tags": [
"android"
],
"title": "AndroidStudioでテキストビューをドラッグ&ドロップできない。",
"view_count": 536
} | [] | 48633 | null | null |
{
"accepted_answer_id": "48638",
"answer_count": 1,
"body": "例えば、以下を実行するとわかる通り、環境変数は必ずしも大文字でなくても動作します。\n\n```\n\n $ hello=fuga sh -c 'echo $hello'\n fuga\n \n```\n\n### 質問\n\n大文字でない環境変数を利用することに、慣習に従っていない以上の技術的な問題はありますか?",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T05:10:13.673",
"favorite_count": 0,
"id": "48637",
"last_activity_date": "2018-09-22T06:16:49.343",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 9,
"tags": [
"linux",
"unix"
],
"title": "大文字でない環境変数を利用することに問題はありますか",
"view_count": 1291
} | [
{
"body": "問題ないです。\n\n### 仕様\n\n仕様的には、\n\n> The name space of environment variable names containing lowercase letters is\n> reserved for applications. \n> —— [Environment Variable\n> Definition](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html)\n\nとあり、小文字の環境変数はアプリケーション用に予約されているとのことなので、むしろ標準ツールが使用する環境変数との衝突を避けるという意味で使用が推奨されているとも読めます。\n\n### 慣習\n\n慣習的には、他のアプリケーションやユーザーに設定させて引き継ぐことを意図する環境変数には大文字を使い、それ以外には小文字を使うことが多いようです。書籍『UNIXプログラミング環境』には、\n\n> 特別な意味をもつ変数は伝統的に大文字で綴るので、ユーザーの作る変数名は通常、小文字で書く。\n\nとあり、小文字の変数を `export` して子プロセスに渡す例も出てきます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T06:16:49.343",
"id": "48638",
"last_activity_date": "2018-09-22T06:16:49.343",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3054",
"parent_id": "48637",
"post_type": "answer",
"score": 13
}
] | 48637 | 48638 | 48638 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "### 前提・実現したいこと\n\nRubyで外部APIを使用し、配達の集荷状況が確認出来るWebアプリを作っています。 \nAPIを連携出来たものの、Viewだと`無効なAPI`と表示されてしまい、どこをどのように直したら良いのか分かりません。コードの編集方法および外部APIの実装方法が誤っている場合、そちらを教えていただきたいです。\n\n * 使用している外部API:[Tracking more](https://www.trackingmore.com/ja.html)\n * [コードを書いた上で参考にしたページ](https://www.trackingmore.com/api-ruby.html)\n\n### 発生している問題・エラーメッセージ\n\n\n\n\n\n### 該当のソースコード\n\n * collecting-status_controller.rb\n\n```\n\n```\n\n class CollectingStatusController < ActionController::Base\n class Trackingmore\n require 'uri'\n require 'net/http'\n require 'net/https'\n require 'json'\n def tracker(url,postData,method)\n headers ={'Content-Type' =>'application/json','Trackingmore-Api-Key':'my api key'}\n if postData.empty?\n @toSend =\"\"\n else\n @toSend =postData.to_json\n end\n uri = URI.parse(url)\n https = Net::HTTP.new(uri.host,uri.port)\n if method ==\"GET\"\n req = Net::HTTP::Get.new(uri.path,headers)\n elsif method ==\"POST\"\n req = Net::HTTP::Post.new(uri.path,headers)\n elsif method ==\"PUT\"\n req = Net::HTTP::Put.new(uri.path,headers)\n elsif method ==\"DELETE\"\n req = Net::HTTP::Delete.new(uri.path,headers)\n else\n puts \"parameter method is wrong!\"\n end\n req.body = \"#{@toSend}\"\n res = https.request(req)\n \n return res\n end\n end\n end\n \n```\n\n```\n\n * index.html.erb\n\n```\n\n```\n\n <!-- [1] classとactionを変更します -->\n <form class=\"index\" action=\"https://api.trackingmore.com/v2\" method=\"post\">\n \n <div class=\"container\">\n <div class=\"flex space-between\">\n <div class=\"articlesNews-leftContent\">\n <div class=\"article-MainBlock\">\n <form action=\"/connpass_clients\" accept-charset=\"UTF-8\" method=\"get\"><input name=\"utf8\" type=\"hidden\" value=\"✓\">\n <div class=\"flex\">\n <div class=\"p-t-b-5\">伝票番号</div>\n <div><input type=\"text\" name=\"form_words\" id=\"form_words\" placeholder=\"東京都 プログラミング\"></div>\n </div>\n <div class=\"text-10\">スペース カンマで複数検索可</div>\n <div class=\"flex m-t-b-30\">\n <div>配達日時</div>\n <div><select id=\"start_date_year\" name=\"start_date[year]\">\n <option value=\"2017\">2017</option>\n <option value=\"2018\" selected=\"selected\">2018</option>\n <option value=\"2019\">2019</option>\n </select>\n <select id=\"start_date_month\" name=\"start_date[month]\">\n <option value=\"1\">1</option>\n <option value=\"2\">2</option>\n <option value=\"3\">3</option>\n <option value=\"4\">4</option>\n <option value=\"5\">5</option>\n <option value=\"6\">6</option>\n <option value=\"7\">7</option>\n <option value=\"8\">8</option>\n <option value=\"9\" selected=\"selected\">9</option>\n <option value=\"10\">10</option>\n <option value=\"11\">11</option>\n <option value=\"12\">12</option>\n </select>\n <input type=\"hidden\" id=\"start_date_day\" name=\"start_date[day]\" value=\"1\">\n </div>\n <div>~</div>\n <div><select id=\"end_date_year\" name=\"end_date[year]\">\n <option value=\"2017\">2017</option>\n <option value=\"2018\" selected=\"selected\">2018</option>\n <option value=\"2019\">2019</option>\n </select>\n <select id=\"end_date_month\" name=\"end_date[month]\">\n <option value=\"1\">1</option>\n <option value=\"2\">2</option>\n <option value=\"3\">3</option>\n <option value=\"4\">4</option>\n <option value=\"5\">5</option>\n <option value=\"6\">6</option>\n <option value=\"7\">7</option>\n <option value=\"8\">8</option>\n <option value=\"9\" selected=\"selected\">9</option>\n <option value=\"10\">10</option>\n <option value=\"11\">11</option>\n <option value=\"12\">12</option>\n </select>\n <input type=\"hidden\" id=\"end_date_day\" name=\"end_date[day]\" value=\"1\">\n </div>\n </div><input type=\"submit\" name=\"commit\" value=\"Search\">\n \n```\n\n```\n\n### 補足情報(FW/ツールのバージョンなど)\n\nruby ver \n2.3.3p222 (2016-11-21 revision 56859)\n\nRails ver \nRails 5.1.6",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T09:01:02.463",
"favorite_count": 0,
"id": "48641",
"last_activity_date": "2018-09-23T06:29:16.197",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30202",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby"
],
"title": "Rubyで外部APIを使用し、集荷状況を表示したい。",
"view_count": 958
} | [
{
"body": "まだコメントに対する返信がいただけていないのですが、「画像の2枚目、これは上の画像の「Search」ボタンを押したらブラウザ画面に表示された(もしくはダウンロードが始まって、ダウンロード完了したファイルをエディタなどで開いた)もの」と言うことと掲載の\n**`index.html.erb`** は、`CollectingStatusController`用のビューであると言うのを仮定しています。\n\n一番の問題点は、 **`index.html.erb`** のこの行です。\n\n```\n\n <form class=\"index\" action=\"https://api.trackingmore.com/v2\" method=\"post\">\n \n```\n\nこれではブラウザから直接APIサーバにリクエストが送られることになりますが、ブラウザはpostリクエストをJSONに変換してくれたりはしませんし、HTTPヘッダーにAPIキーを入れたりもしてくれません。APIキーの入っていないリクエストを送っているので、APIサーバの側が`{\"code\":4001,\"type\":\"Unauthorized\",\"message\":\"Invalid\nAPI key\"}`というメタ情報の応答をブラウザに返しているものと思われます。\n\n(ご使用中のブラウザのURL窓に直接`https://api.trackingmore.com/v2`と入力しても、同じ応答が見られるはずです。)\n\nあちこち動きを確かめながら、少しずつコードを書いていっておられるのでしょうが、今のコードではRuby版のAPI呼び出しが動くかどうかを試すには足りなさすぎます。Ruby側のコードとしてAPI呼び出しクラス(`Trackingmore`)を使用するようなコードを書いてやらないといけません。\n\n先の1行を次のように置き換えて見てください。\n\n### **`index.html.erb`**\n\n```\n\n ...\n <form class=\"index\" action=\"<%= url_for :controller => 'collection_status', :action => 'search' %>\" method=\"post\">\n ...\n \n```\n\n(コントローラ名やアクション名は実際のWebアプリの構成によっては書き換えないといけないでしょうが、以下はこの内容を仮定しています。実際の構成によっては適宜読み替える必要があります。)\n\nこれで、ブラウザからは`CollectingStatusController`にリクエストが送られるので、それを処理するメソッドが必要になります。\n\nただ、 **`collecting_status_controller.rb`**\nをいじる前に`Trackingmore`クラスが`CollectingStatusController`の内側にネストして定義されているのは改めた方が良いでしょう。\n\nRailsであれば必ず **`app`** ディレクトリがあると思いますが、その下に **`lib`**\nディレクトリを作り(似た目的のディレクトリが既にあるならそこでも良いです)そこに公式サイトからダウンロードした **`trackingmore.rb`**\nを以下の1行のみ修正した上で置いてください。\n\n### **`app/lib/trackingmore.rb`**\n\n```\n\n ...\n headers ={'Content-Type' =>'application/json','Trackingmore-Api-Key'=>'実際のAPIキー'}\n ...\n \n```\n\nこれが終わったら、 **`collecting_status_controller.rb`**\nには`search`メソッドを追加する必要があります。(もちろん`Trackingmore`クラスの定義部分は全部削除。)\n\n全体はこんな雰囲気になるでしょう。\n\n### **`collecting_status_controller.rb`**\n\n```\n\n ...\n \n class CollectingStatusController < ActionController::Base\n \n def search\n #params内のパラメータを取り出してpostDataを作成する(必要なら検証してエラー処理)\n #post_data = ...\n #利用したいサービスのURLを文字列として用意しておく\n url = 'https://api.trackingmore.com/v2/trackings/updatemore'\n #参考ページに書いてある呼び出し方ほぼそのまま\n tracker = Trackingmore.new\n res = tracker.tracker(url, post_data, 'POST')\n #res.codeなんかも調べて、エラーがなければ、res.bodyをJSONとして解析する\n #json = ...\n #jsonの中身がエラーじゃないかのチェックも必要かも\n #...\n #解析したJSONからviewへ渡すデータを作成\n #@search_results = ...\n #結果表示用のviewを表示\n end\n \n end\n \n```\n\n`post_data`をリクエストパラメータを作るのは結構大変でしょうが、APIがうまく呼べているかどうかの確認だけなら、とりあえずダミーのデータを作ってやれば良いでしょう。結果確認用のビュー(\n**`search.html.erb`** )も作成する必要があるでしょうが、それはどんな結果を見たいのかによるので、ここでは置いておきます。\n\n* * *\n\n色々不明な点もあるのと、実際に動かして確かめたわけではないこともあって何かと不完全な部分があるでしょうが、修正の方向性は一通り盛り込んだつもりです。参考にしていただければ幸いです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T06:16:30.023",
"id": "48652",
"last_activity_date": "2018-09-23T06:29:16.197",
"last_edit_date": "2018-09-23T06:29:16.197",
"last_editor_user_id": "13972",
"owner_user_id": "13972",
"parent_id": "48641",
"post_type": "answer",
"score": 1
}
] | 48641 | null | 48652 |
{
"accepted_answer_id": "48643",
"answer_count": 1,
"body": "[swift - 勝手にnilが無視される挙動を使って安全? -\nスタック・オーバーフロー](https://ja.stackoverflow.com/questions/48585/%e5%8b%9d%e6%89%8b%e3%81%abnil%e3%81%8c%e7%84%a1%e8%a6%96%e3%81%95%e3%82%8c%e3%82%8b%e6%8c%99%e5%8b%95%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e5%ae%89%e5%85%a8) \nでは、`ディクショナリ`における`nilの削除挙動`の質問をしました。\n\n同様のソースをここに再掲しますが、\n\n```\n\n let hoge: String? = nil\n let foo: String? = \"foo\"\n \n var dict = [String: Any]()\n \n if let hoge = hoge {\n dict[\"hoge\"] = hoge\n }\n \n if let foo = foo {\n dict[\"foo\"] = foo\n }\n \n print(dict) // => [\"foo\": \"foo\"]\n \n```\n\nやはり `if let` の連続が書きにくいし、読みにくい。 \nなんとかして別の手段はないかと思い `map` を試しました。\n\n```\n\n let hoge: String? = nil\n let foo: String? = \"foo\"\n var dict = [String: Any]()\n \n hoge.map{ dict[\"hoge\"] = $0 }\n foo.map{ dict[\"foo\"] = $0 }\n \n```\n\nこれで目的が達成できたように感じます... しかしここで疑問が...\n\n * 質問1. mapは返り値をなにかに代入する目的のもののはず、この使い方は正しいのか?\n * 質問2. なぜ `Result of call to 'map' is unused` の警告はでないのか?\n\n蛇足ですが、質問2の警告がたまたまXcodeの調子で出ないだけかと思い、\n\n```\n\n func bar() -> String? {\n return \"f\"\n }\n \n```\n\nという関数を作ってみたところ添付画像のように警告は出ていました。 \n[](https://i.stack.imgur.com/KfTQm.png)\n\nさらに蛇足ですが、なぜ `bar関数`の戻り値を`String?`とオプショナルにしたかというと、 \n`map`の定義が下記のようになっていたので `-> U?` の部分に似せることができるかと考えたためです。 \n`public func map<U>(_ transform: (Wrapped) throws -> U) rethrows -> U?` \n(ただし、私がクロージャとジェネリクスが混合して書かれた型の読み方に慣れておらず、なにか勘違いしている可能性があります...)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T09:24:37.543",
"favorite_count": 0,
"id": "48642",
"last_activity_date": "2018-09-22T12:54:23.130",
"last_edit_date": "2018-09-22T10:15:02.967",
"last_editor_user_id": "9008",
"owner_user_id": "9008",
"post_type": "question",
"score": 2,
"tags": [
"swift",
"swift4"
],
"title": "オプショナルのmapの返り値は代入しなくてもよい?",
"view_count": 226
} | [
{
"body": "_**・質問1. mapは返り値をなにかに代入する目的のもののはず、この使い方は正しいのか?**_\n\n「正しい」と言うのを前のご質問の回答後半で「安全じゃない」と言ったのと逆の意味、つまりSwiftの実装が変わったりしても、\n**挙動が変わって困る心配はなさそう、と言う意味に捉えると「正しい」** と言えます。\n\n[`Optional`型の`map`のドキュメント](https://developer.apple.com/documentation/swift/optional/1539476-map)には、以下のように明記されています。\n\n> Evaluates the given closure when this `Optional` instance is not nil, \n> passing the unwrapped value as a parameter.\n>\n> (拙訳、要らないような気もしますが、質問で英文を掲載すると即座に拒否られる日本語サイトですので…) \n> `Optional`インスタンスが非`nil`の場合にクロージャを評価する。その際クロージャのパラメータとしてはアンラップされた値が渡される。\n\nまた、「mapは返り値をなにかに代入する目的」についてですが、「\n**確かに目的外使用は無駄が出るかもしれないし、リーダビリティを損なう可能性もあるけど、確実に動くんだし、他に手段がなければありかも**\n」くらいのところでしょうか。\n\n(個人的なことを言うと、「自分ではやらないが、他人がこんなコードを書いているのをみたら、なかなか上手いことやってるな、なんてニヤリとする」と言ったニュアンスです。)\n\n大昔のSwiftには配列(正確には`Sequence`)に`forEach`と言うメソッドがなかったので、代わりに`map`を使う人たちがいました。そっちなら、「自分ではやらないし、他人がそんなコードを書いているのをみたら、無駄な配列を作ってすぐ捨ててることになります、なんて注意する」と言ったところなんですが。\n\n今回の`Optional`の`map`の場合、クロージャの中で副作用として出来た値を型だけ`Optional`型にラップして返しているだけなので、目くじら立てるほどの無駄じゃないと言えるでしょう。\n\n* * *\n\n_**・質問2. なぜ`Result of call to 'map' is unused` の警告はでないのか?**_\n\nこれについては、どんな時にどんな警告が出るかと言うのはちゃんとドキュメント化されていないので、「将来のバージョンでは警告が出るようになる」可能性がありますし、若干推測も入るんですが。\n\nまず、このメソッドの宣言には警告を抑制する`@discardableResult`なんてアノテーションはついていないようです。実際、こんな使い方だと(少なくともXcode\n10では)警告が出ます。\n\n```\n\n func setHogeToDict(_ str: String) -> String {\n dict[\"hoge\"] = str\n return str\n }\n hoge.map{ setHogeToDict($0) } //! Result of call to 'map' is unused\n \n```\n\nと言うわけで、`Optional.map`に渡されるクロージャの戻り値が`String`型なら、ちゃんと警告は出ます。(この場合、`map`の戻り値は`String?`型になる。)\n\n警告が出ない例`hoge.map{ dict[\"hoge\"] = $0 }`では、(Swiftの代入文は値を返さないので)\n**クロージャの戻り値が`Void`型なので、この場合には警告を出さないようにしている**のだと思われます。(この場合、`map`の戻り値は`Void?`型(別の書き方なら`()?`型)になる。)\n\n明確に戻り値なしを意味する、`Void`型と違って`Void?`型の値は一応使う時があるんですが、まぁ、そんなことは滅多にないだろうと言うことでしょう。実際、`Void?`型に推論される変数を宣言しようとすると、警告が出ます。\n\n```\n\n let result = hoge.map{ dict[\"hoge\"] = $0 }\n //! constant 'result' inferred to have type '()?', which may be unexpected\n \n```\n\n* * *\n\nところで、上に「リーダビリティを損なう可能性もある」なんてことを書きましたが、どうせリーダビリティの方はちょっと我慢するなら、`Dictionary`型にちょっとした`extension`を定義しちゃう(独自`extension`の多用はリーダビリティを損なうとして嫌がる人たちがいるんですが)なんて手もありそうです。\n\n```\n\n extension Dictionary {\n subscript(ignoreNil key: Key) -> Value? {\n get {\n return self[key]\n }\n set {\n if let value = newValue {\n self[key] = value\n }\n }\n }\n \n```\n\n}\n\n```\n\n let hoge: String? = nil\n var dict = [String: Any]()\n dict[ignoreNil: \"hoge\"] = hoge\n print(dict) //->[:]\n \n```\n\n* * *\n\nコメントに「`Void?` (のあまり使用場面が想像できてないですが)」というのをいただいたので補足。\n\n`Void?`型は値として空タプル`()`または`nil`を格納できますから、わざわざ変数(定数含む)の宣言まではしないでしょうが、値を利用してこんな書き方はできます。\n\n```\n\n let hoge: String? = nil\n var dict = [String: Any]()\n let result: Void? = hoge.map{ dict[\"hoge\"] = $0 } //`Void?`を明記すると警告は出ない\n //hogeが非nilの場合`result`の値も非nil(空タプル)になる\n if result != nil {\n print(\"dictに値が追加されました\")\n } else {\n print(\"dictは変更されていません\") //->dictは変更されていません\n }\n \n```\n\n滅多にどころか、「こんなことする奴ぁいねぇよ!」と言いたくなるコード(後で条件分けするんなら初めからif-\nlet使えば数段読みやすい)ですが、こんなこともやろうと思えば出来ますと言うことで。\n\n「違和感」については、Optional\nChaining代わりに`map`を使うテクニックの一種なんで、多くの人に広まればそれほどでもなくなるかもしれません。(Optional\nChainingに普通に`?.`を使った式の型が`Void?`になる例はいっぱいあるんですが、多分あまり気にしてないですよね?)",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T11:18:27.393",
"id": "48643",
"last_activity_date": "2018-09-22T12:54:23.130",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "13972",
"parent_id": "48642",
"post_type": "answer",
"score": 3
}
] | 48642 | 48643 | 48643 |
{
"accepted_answer_id": "48675",
"answer_count": 1,
"body": "## やりたいこと\n\nRaspberryPiにGPSモジュールを接続して緯度経度を出力したい\n\n## 環境\n\n * ハードは RaspberryPi ZeroWH\n * OS は RASPBIAN STRETCH LITE\n * GPSモジュール \n\\-- GPS受信機キット 1PPS出力付き\n「みちびき」3機受信対応(<http://akizukidenshi.com/catalog/g/gK-09991/>) \n\\-- GT-902PMGG 「GPS/GLONASS受信機(Galileo/BeiDou可)u‐blox M8搭載\nみちびき3機受信対応」(<http://akizukidenshi.com/catalog/g/gM-12905/>)\n\n## 変更した点:\n\n基本的には以下ページの8~13まで \n<https://gist.github.com/CLCL/e0f840461e20a3a83179b4941d45c203>\n\n * UART設定 \n\\-- `# raspi-config nonint do_serial 1` \n\\-- /boot/config.txt 内の enable_uartを1へ変更\n\n * /dev/gps0 の設定\n``` # stty -F /dev/ttyS0 ispeed 9600\n\n # cat << 'EOS' | tee /etc/udev/rules.d/40-selialgps.rules\n KERNEL==\"ttyS0\", SYMLINK+=\"gps0\"\n EOS\n \n```\n\n * gpsd のインストール\n``` apt-get -y install gpsd gpsd-clients\n\n \n```\n\n * gpsdの設定\n``` cat << EOS | sudo tee -a /etc/default/gpsd\n\n USBAUTO=\"false\"\n DEVICES=\"/dev/gps0\"\n EOS\n \n```\n\n## 確認したこと:\n\n\\-- GPS/GLONASS受信機(Galileo/BeiDou可)u‐blox M8搭載 みちびき3機受信対応 を接続したとき\n\n```\n\n # cat /dev/gps0 \n C,V,,,,,,,,,,N*4D\n $GNVTG,,,,,,,,,N*2E\n $GNGGA,,,,,,0,00,99.99,,,,,,*56\n $GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E\n $GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*2E\n $GPGSV,1,1,01,16,,,09*76\n $GLGSV,1,1,00*65\n $GNGLL,,,,,,V,N*7A\n $GNRMC,,V,,,,,,,,,,N*4D\n $GNVTG,,,,,,,,,N*2E\n \n```\n\n\\-- GPS受信機キット 1PPS出力付き 「みちびき」3機受信対応 を接続したとき\n\n```\n\n # cat /dev/gps0 \n $GPGGA,000044.799,,,,,0,0,,,M,,M,,*4F\n $GPGSA,A,1,,,,,,,,,,,,,,,*1E\n $GPRMC,000044.799,V,,,,,0.00,0.00,050180,,,N*46\n $GPZDA,000044.799,05,01,3880,,*56\n $GPGRS,000044.799,1,,,,,,,,,,,,*79\n $GPGST,000044.799,0.000,99999,99999,00.0,99999,99999,99999*47\n $GPGGA,000045.799,,,,,0,0,,,M,,M,,*4E\n $GPGSA,A,1,,,,,,,,,,,,,,,*1E\n \n```\n\n## 質問したいこと:\n\n * /dev/gps0 には出力されているのでgpsライブラリの設定は問題ないという認識で問題ないでしょうか?\n * スマートフォンのGPSは届くのになぜ$GNRMCが V(警告)から変わらないのでしょうか?\n\n不足している情報等ありましたらコメントお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T14:22:17.053",
"favorite_count": 0,
"id": "48644",
"last_activity_date": "2018-09-24T11:31:20.330",
"last_edit_date": "2018-09-22T14:28:08.537",
"last_editor_user_id": "29942",
"owner_user_id": "29942",
"post_type": "question",
"score": 1,
"tags": [
"raspberry-pi",
"raspbian",
"gps"
],
"title": "RaspberryPi ZeroW にGPS受信機キットを接続したが緯度経度が測定失敗する",
"view_count": 960
} | [
{
"body": "自己解決しました。\n\n * /dev/gps0 には出力されているのでgpsライブラリの設定は問題ないという認識で問題ないでしょうか? \n\\-- 問題ありませんでした。上記ログのように出力されていれば設定関連はOKです\n\n * スマートフォンのGPSは届くのになぜ$GNRMCが V(警告)から変わらないのでしょうか? \n\\-- 空がよく見える場所で数分バッテリーで置いたところ問題なく受信できました。部屋の中(かつマンションの1F)では受信できなかったみたいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T11:31:20.330",
"id": "48675",
"last_activity_date": "2018-09-24T11:31:20.330",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29942",
"parent_id": "48644",
"post_type": "answer",
"score": 2
}
] | 48644 | 48675 | 48675 |
{
"accepted_answer_id": "48730",
"answer_count": 1,
"body": "こんにちは。\n\n現在、練習の意味を込めて、dockerのコンテナ内でjupyterを一から構築しようとしています。 \njupyternotebook自体が最初から入ったイメージのことは既に知っており、使い方も把握しているのですが、今回はそのようなイメージを使わず、自分で一から作れるかをやって見るというのが趣旨になります。 \n最終的にはこれをDockerfileに落とし込めるかまでやってみようと思っています。\n\nその中で、Dockerへのjupyterのインストールと起動まではうまく行ったのですが、最後のブラウザからのアクセスのところでつまづいています。\n\n具体的には、jupyter\nnotebookの起動時に出てくるIPアドレスとポート番号でブラウザからアクセスしようとするのですが、読み込み中のバーが最初のところで止まり、画面も含めてそこから一切反応しなくなります。 \njupyterの設定は、IPアドレスは'*'で指定しないようにしており、ポートは\"8888\"で指定しています。\n\nそもそもCentOSの設定上で対応するIPアドレスか何かを決める必要があるのかな(「開放」のようなイメージです)と勝手に思っているのですが、ググり方が悪いのか有効な解決策が見つけられていません。\n\n何か心当たりがあれば、ご教示いただければと思います。\n\nこのDockerコンテナの構築方法については下記に記しております。\n\nイメージ(OS):CentOS7 \n構築手順 :yumでgitをインストール \n-> gitでpyenvをクローン \n-> pyenvでpython3.6.5をインストール\n\n### 追記\n\n> コメント:Docker に渡す権限が足りていないような気がします。その Docker\n> イメージでコンテナを起動する際にどのようなコマンドを打っているのか追記して頂けませんか?\n\n→ 下記のように特段、権限設定のようなものはしておりません。ここでIPアドレスやポート番号の設定が必要なのでしょうか。\n\n```\n\n docker run -it --name test_jupyter centos /bin/bash\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T14:56:22.950",
"favorite_count": 0,
"id": "48645",
"last_activity_date": "2018-09-26T21:39:34.183",
"last_edit_date": "2018-09-26T12:07:06.640",
"last_editor_user_id": "19110",
"owner_user_id": "29884",
"post_type": "question",
"score": 0,
"tags": [
"docker",
"jupyter-notebook"
],
"title": "ローカルPC上にDockerで仮想環境を構築、jupyterを入れた場合のローカルからアクセスする方法",
"view_count": 652
} | [
{
"body": "Docker コンテナ内部で起動している Jupyter Notebook\nへローカルマシンからポート経由でアクセスしようとしている場合、コンテナ内部のポートとローカルマシンのポートを繋ぐことが必要です。\n\nたとえば Jupyter 公式が配布している `jupyter/scipy-notebook` イメージでは起動時に [`-p`\nオプション](http://docs.docker.jp/engine/reference/run.html#expose)を使って以下のような起動の仕方をすると[書かれています](https://jupyter-\ndocker-stacks.readthedocs.io/en/latest/index.html)。\n\n```\n\n docker run -p 8888:8888 jupyter/scipy-notebook:2c80cf3537ca\n \n```\n\n質問者さんが自作なさっているイメージがどのようなものか分かりませんが、少なくともポートは公開するようにしておかないとコンテナ内部へポート経由でアクセスすることはできないはずです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T12:04:40.707",
"id": "48730",
"last_activity_date": "2018-09-26T21:39:34.183",
"last_edit_date": "2018-09-26T21:39:34.183",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "48645",
"post_type": "answer",
"score": 2
}
] | 48645 | 48730 | 48730 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Mac Python3.6 を使用しているものです。\n\nseleniumをimportして、 \nbrowser=webdriver.Firefox() \nを実行してみたのですが、 \nうまくいかず困っています。(エラー文は下記)\n\ngeckodriverのPATHについては問題ないと思うのですが。\n\n初心者なのでわかりやすく教えて頂けるとありがたいです。\n\n```\n\n >>> from selenium import webdriver\n >>> browser = webdriver.Firefox()\n Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"/anaconda3/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py\", line 167, in __init__\n keep_alive=True)\n File \"/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py\", line 156, in __init__\n self.start_session(capabilities, browser_profile)\n File \"/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py\", line 251, in start_session\n response = self.execute(Command.NEW_SESSION, parameters)\n File \"/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py\", line 320, in execute\n self.error_handler.check_response(response)\n File \"/anaconda3/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py\", line 242, in check_response\n raise exception_class(message, screen, stacktrace)\n selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-22T16:20:40.860",
"favorite_count": 0,
"id": "48647",
"last_activity_date": "2019-04-05T05:23:04.540",
"last_edit_date": "2018-09-22T17:25:11.077",
"last_editor_user_id": "3060",
"owner_user_id": "30207",
"post_type": "question",
"score": 4,
"tags": [
"python",
"selenium",
"firefox",
"selenium-webdriver"
],
"title": "Pythonでbrowser=webdriver.Firefox() を実行するとエラー",
"view_count": 3282
} | [
{
"body": "UPDATE Firefox First",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2019-04-05T05:23:04.540",
"id": "53934",
"last_activity_date": "2019-04-05T05:23:04.540",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "32793",
"parent_id": "48647",
"post_type": "answer",
"score": -3
}
] | 48647 | null | 53934 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "## 発生している問題・実現したいこと\n\nrequirements.txtに\n\n```\n\n mecab-python-windows==0.996\n \n```\n\nと記述して `git push` コマンドで mecab のインストールを試みたものの、\n\n```\n\n Could not find a version that satisfies the requirement mecab-python-windows==0.996 \n \n```\n\nというエラーが返ってきました。 \nmecab を Heroku へインストールするにはどうすればよいのでしょうか。\n\n* * *\n\n## 追記\n\nmecab-python3 としたところ\n\n```\n\n Command \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-build-alv4puww/mecab-python3/\n \n```\n\nというエラーが返ってきました。このエラーを解消するにはどうすればよいでしょうか。\n\nログ:\n\n```\n\n remote: -----> Installing requirements with pip\n remote: Collecting mecab-python3 (from -r /tmp/build_48589b6a2c92201982f5d27fbec47bfe/requirements.txt (line 3))\n remote: Downloading https://files.pythonhosted.org/packages/25/e9/bbf5fc790a2bedd96fbaf47a84afa060bfb0b3e0217e5f64b32bd4bbad69/mecab-python3-0.7.tar.gz (41kB)\n remote: Complete output from command python setup.py egg_info:\n remote: /bin/sh: 1: mecab-config: not found\n remote: Traceback (most recent call last):\n remote: File \"<string>\", line 1, in <module>\n remote: File \"/tmp/pip-build-btsgxibr/mecab-python3/setup.py\", line 41, in <module>\n remote: include_dirs=cmd2(\"mecab-config --inc-dir\"),\n remote: File \"/tmp/pip-build-btsgxibr/mecab-python3/setup.py\", line 21, in cmd2\n remote: return cmd1(strings).split()\n remote: File \"/tmp/pip-build-btsgxibr/mecab-python3/setup.py\", line 18, in cmd1\n remote: return os.popen(strings).readlines()[0][:-1]\n remote: IndexError: list index out of range\n remote:\n remote: ----------------------------------------\n remote: Command \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-build-btsgxibr/mecab-python3/\n \n```",
"comment_count": 11,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T02:29:33.013",
"favorite_count": 0,
"id": "48649",
"last_activity_date": "2019-05-04T16:49:13.313",
"last_edit_date": "2019-05-04T16:49:13.313",
"last_editor_user_id": "32986",
"owner_user_id": "30138",
"post_type": "question",
"score": 0,
"tags": [
"python",
"heroku",
"mecab"
],
"title": "Heroku mecabインストール時にエラー",
"view_count": 641
} | [] | 48649 | null | null |
{
"accepted_answer_id": "48758",
"answer_count": 1,
"body": "pip freezeでインストールされているパッケージの一覧を出力できますが、 \n各パッケージのライセンスを確認するコマンドはあるのでしょうか。 \n個別にWebで検索しなければいけないのでしょうか。",
"comment_count": 9,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T03:10:18.860",
"favorite_count": 0,
"id": "48650",
"last_activity_date": "2018-10-01T05:43:59.863",
"last_edit_date": "2018-09-27T04:48:58.830",
"last_editor_user_id": "19110",
"owner_user_id": "30138",
"post_type": "question",
"score": 3,
"tags": [
"python",
"python3",
"pip"
],
"title": "Pythonパッケージのライセンスを確認する方法",
"view_count": 4733
} | [
{
"body": "個別には `pip show <パッケージ名>` で表示することができる場合があります。\n\nまた、[pip-licenses](https://pypi.org/project/pip-licenses/)\nというパッケージを使ってライセンスのみを一覧表示させることもできます。\n\nもしライセンスが UNKNOWN\nと表示される場合、[ライセンスが書かれているフィールドが別にあるからかもしれません](http://raimon49.github.io/2018/02/18/check-\nlicense-as-unknown-with-pip-show-command.html)。その場合は\n\n```\n\n pip-licenses --from-classifier\n \n```\n\nを使うと表示される場合があります。詳しくは[ドキュメント](https://pypi.org/project/pip-licenses/#option-\nfrom-classifier)をご参照ください。\n\n\\-- この投稿は [metropolis](https://ja.stackoverflow.com/users/16894/metropolis)\nさんの[コメント1](https://ja.stackoverflow.com/questions/48650/python%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%81%AE%E3%83%A9%E3%82%A4%E3%82%BB%E3%83%B3%E3%82%B9%E3%82%92%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95#comment50509_48650)、[2](https://ja.stackoverflow.com/questions/48650/python%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%81%AE%E3%83%A9%E3%82%A4%E3%82%BB%E3%83%B3%E3%82%B9%E3%82%92%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95#comment50512_48650)を元にしつつ加筆編集したものです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T05:55:49.683",
"id": "48758",
"last_activity_date": "2018-10-01T05:43:59.863",
"last_edit_date": "2018-10-01T05:43:59.863",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "48650",
"post_type": "answer",
"score": 3
}
] | 48650 | 48758 | 48758 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "**samples table**\n\n```\n\n id, A, B\n 1, 1, 1\n 2, 1, 2\n 3, 1, 3\n 4, 1, 3\n 5, 2, 1\n \n```\n\n上のようなテーブルに対して、\n\nAでGroup byした状態で、Bに2が含まれている場合は、true、含まれていない場合はfalseを返すようなSQLを書きたいです\n\n**レスポンス例**\n\n```\n\n A, contains\n 1, true\n 2, false\n \n```\n\nどのようにすれば、上記が満たせるSQLが書けるでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T05:51:17.217",
"favorite_count": 0,
"id": "48651",
"last_activity_date": "2020-09-09T01:52:35.090",
"last_edit_date": "2020-09-09T01:52:35.090",
"last_editor_user_id": "32986",
"owner_user_id": "25991",
"post_type": "question",
"score": 1,
"tags": [
"mysql",
"sql"
],
"title": "Group By でまとめられた後に、特定の値が含まれているか true or false で返したい",
"view_count": 3479
} | [
{
"body": "(コメントより)\n\n[How to determine if a value appears in a GROUP BY\ngroup](https://stackoverflow.com/questions/10545932) が参考になるかと思います。\n\n```\n\n SELECT A, IF(SUM(B = 2), 'true', 'false') AS contains FROM samples GROUP BY A;\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-10-04T16:34:42.393",
"id": "48980",
"last_activity_date": "2018-10-04T16:34:42.393",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "48651",
"post_type": "answer",
"score": 1
}
] | 48651 | null | 48980 |
{
"accepted_answer_id": "48660",
"answer_count": 1,
"body": "Pythonで作ったアプリケーションをMITライセンスで公開しようと思います。 \nPythonプログラムで使っているパッケージには以下のライセンスになっているものが含まれています。 \n・BSDライセンス \n・Apache Software License \n・MITライセンス \nMITライセンス以外のパッケージも含まれていますが、MITライセンスで公開できるのでしょうか。 \nまた、ライセンスを表記する際はパッケージ名とライセンス名以外の記述で何が必要になるでしょうか。パッケージの作者名も必要でしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T07:54:17.287",
"favorite_count": 0,
"id": "48654",
"last_activity_date": "2018-09-23T14:03:49.987",
"last_edit_date": "2018-09-23T14:03:49.987",
"last_editor_user_id": "19110",
"owner_user_id": "30138",
"post_type": "question",
"score": 6,
"tags": [
"python",
"ライセンス",
"mit-license"
],
"title": "MITライセンスでの配布",
"view_count": 966
} | [
{
"body": "* もしかして:`import`文などでモジュールを読み込む場合で、そのモジュールがあなたのアプリケーションに付属していない場合は、そのモジュールのライセンスはあなたのアプリケーションに影響を与えません。\n\n * 3つのライセンスを共存させる場合 \n互換性はありますが、100%とはいえません。\n\n> In general, lax permissive licenses (modified BSD, X11, Expat, Apache,\n> Python, etc.) are compatible with each other.\n> [出典](https://www.gnu.org/licenses/license-compatibility.html)\n\n * ライセンス表記 \nMITライセンスを表記するときは、[規定のライセンス文](https://opensource.org/licenses/MIT)を使用しないといけません。もしMITライセンスで公開された既存のモジュールなどを使用する場合は、そのモジュールのライセンス文そのものが著作権表示になります。\n\n間違っていた場合はごめんなさい。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T13:00:01.440",
"id": "48660",
"last_activity_date": "2018-09-23T13:00:01.440",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29212",
"parent_id": "48654",
"post_type": "answer",
"score": 3
}
] | 48654 | 48660 | 48660 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "表題の件について、 \nテーブルがあるとして、 \nその表の中に、何行か値があります。 \n欲しいのは、A列ではなく、B列、2行目以降のセルの値です。\n\nFor Eachでループをかけ、行に値がなくなったら終了。 \nという繰り返しで、\n\n```\n\n Dim dtRows As datatable \n For each dtRows in Keywords.row\n String.isNullofEmpty(dtRows.item(\"値\").ToString())\n Next\n \n```\n\n\"値\" = B2 セルになります。 \n上記ループで取得する方法を教えていただければと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T10:33:10.603",
"favorite_count": 0,
"id": "48656",
"last_activity_date": "2018-09-23T11:53:07.410",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30212",
"post_type": "question",
"score": 0,
"tags": [
"excel",
"vb.net",
"rpa"
],
"title": "Excelの特定の列、行の値の取得方法について教えてください",
"view_count": 62
} | [
{
"body": "すみません。\n\n自己解決しました。\n\nコード上の問題ではなく、 \nExcelのパラメータ取得する、対象のシートが違っていました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T11:53:07.410",
"id": "48657",
"last_activity_date": "2018-09-23T11:53:07.410",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30212",
"parent_id": "48656",
"post_type": "answer",
"score": 1
}
] | 48656 | null | 48657 |
{
"accepted_answer_id": "48659",
"answer_count": 1,
"body": "Vim scriptからコマンドラインにコマンドを入力する方法を教えてください。\n\n例えば、Vim scriptで \nlet cmd = 'echo \"Hello\"' \nという変数があり、これをコマンドラインに挿入し、 \nEnterを押すと、このExコマンドを実行したいのですが、 \nどのようにすれば良いでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T12:02:10.277",
"favorite_count": 0,
"id": "48658",
"last_activity_date": "2018-09-23T12:41:09.747",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22748",
"post_type": "question",
"score": 0,
"tags": [
"vim"
],
"title": "Vim scriptからコマンドラインにコマンドを挿入する方法を教えてください。",
"view_count": 183
} | [
{
"body": "```\n\n call feedkeys(':' . cmd, 'n')\n \n```\n\nで出来るはずです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T12:41:09.747",
"id": "48659",
"last_activity_date": "2018-09-23T12:41:09.747",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25694",
"parent_id": "48658",
"post_type": "answer",
"score": 3
}
] | 48658 | 48659 | 48659 |
{
"accepted_answer_id": "48673",
"answer_count": 2,
"body": "テンプレートクラスで`template<class type,int N>`と`template<class type>`で \n`template<class type,int N>`の場合は配列がオブジェクトに含まれて \n`template<class type>`の場合は配列にオブジェクトに含まれないっていう参考書にあるのですがどういう意味なのでしょうか?\n\n```\n\n //配列がオブジェクトに含まれる。\n template<class type,int N> class x {\n type vec[N] = { type() };\n \n public:\n x(){ }\n \n void print() {\n int i = 0;\n for(i; i<N; i++)\n cout << vec[i]<<\"\\n\";\n }\n \n \n int size() { return N; }\n \n };\n \n //配列はオブジェクトに含まれない。\n template<class type> class y {\n int nelem;//要素数\n type *vec;//配列の先頭要素を指すポインタtype型\n \n public:\n \n y(int s = 0, type t = type()) :nelem(s) {\n \n vec = new type[nelem];\n vec = { type() };\n \n }\n void print() {\n int i = 0;\n for (i; i < nelem; i++)\n cout << vec[i] << \"\\n\";\n }\n \n int size() { return nelem; }\n };\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T15:52:50.430",
"favorite_count": 0,
"id": "48661",
"last_activity_date": "2018-09-24T06:26:16.560",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": -1,
"tags": [
"c++"
],
"title": "templateクラスで定数がある配列について",
"view_count": 615
} | [
{
"body": "記載のコード例から察するに、`class x`は配列メンバを含んでいる、`class\ny`は配列は含んでおらず、ポインタで配列の位置を指している、という違いから、そのように記載されているのではないかと予想します。\n\n#次のようなコード例で言うと、`sizeof(xArray)`は「40」(配列の要素の合計が計上される)になるのに対し、`sizeof(yArray)は16にしかならない(サイズを表す整数変数とポインタ変数)、という意味と予想します。 \n(実際の結果は、環境によって変化します。差異が出る、という点を示しています)\n\n```\n\n #include <iostream>\n \n // template<class type, int N> class x , template<class type y>\n // の定義は省略。\n \n int main() {\n // xArray, yArrayはどちらも10個の要素を持つ配列\n x<int, 10> xArray;\n y<int> yArray(10);\n // 出力は、それぞれ「40」(4×10)、「16」(8×2)と異なる値になる。\n std::cout << sizeof(xArray) << \"\\n\";\n std::cout << sizeof(yArray) << \"\\n\";\n return 0;\n }\n \n```\n\nいかがでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T04:51:10.060",
"id": "48671",
"last_activity_date": "2018-09-24T04:51:10.060",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20098",
"parent_id": "48661",
"post_type": "answer",
"score": 0
},
{
"body": "真に訊きたい質問が何か微妙にわかりませんが\n\nテンプレート仮引数に `<int N>` のようなものを書いたとして、それだけで配列がとられることはありません。提示クラス前者は `type\nvec[N];` なるメンバをきっちり作っているから「配列メンバがある」、後者は `type *vec;`\nしかないから「配列」はなくてポインタメンバがあるだけです。\n\nオイラのサンプル [c++\nconstexpr型指定子の使い方とconstとの使い分けの方法](https://ja.stackoverflow.com/questions/48369/)\nでも `<int n>` なテンプレート仮引数を取っていますけど、配列なんぞありません。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T06:26:16.560",
"id": "48673",
"last_activity_date": "2018-09-24T06:26:16.560",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "48661",
"post_type": "answer",
"score": 0
}
] | 48661 | 48673 | 48671 |
{
"accepted_answer_id": "48663",
"answer_count": 1,
"body": "swift初心者です。 ゲームなどのチーム選択の表現方法について教えていただきたいです。 \n自分の選択したチームにおいてそのUIImageを自分のチームとして設定できるようにしたいのですがどうすればよいでしょうか。的外れなコードかもしれませんが下のコードではエラーが起こってしまいます。教えていただけると嬉しいです。\n\n```\n\n enum Team {\n case WhiteTeam\n case StripeTeam\n }\n \n enum WhiteTeam: String {\n case A = \"whiteplayer_1\"\n case B = \"whiteplayer_7\"\n case C = \"whiteplayer_10\"\n case D = \"whiteplayer_11\"\n case E = \"whiteplayer_12\"\n case F = \"whiteplayer_13\"\n \n static let values = [A, B, C, D, E, F]\n \n \n }\n \n enum StripeTeam: String {\n case A = \"stripeplayer_1\"\n case B = \"stripeplayer_3\"\n case C = \"stripeplayer_4\"\n case D = \"stripeplayer_7\"\n case E = \"stripeplayer_10\"\n case F = \"stripeplayer_11\"\n \n static let values = [A, B, C, D, E, F]\n }\n \n struct Allyteam {\n var myteam: Team\n \n for player in myteam.values {\n image = UIImage(named: player)\n }\n }\n \n```\n\nswift4 xcode ver9.4.1です。 \nこの場合forの部分についてExpected declarationのエラーが発生します。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T16:58:11.247",
"favorite_count": 0,
"id": "48662",
"last_activity_date": "2018-09-23T18:21:48.360",
"last_edit_date": "2018-09-23T17:16:28.933",
"last_editor_user_id": "30215",
"owner_user_id": "30215",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"swift4"
],
"title": "ゲームなどのチーム選択の表現方法について",
"view_count": 81
} | [
{
"body": "**_swift4 xcode ver9.4.1です。_**\n\nXcode\n9.4.1についてくるSwiftのバージョンは正確には4.1ですね。(さらに正確にいうとサブマイナー番号が付きますが、実際のコードには影響しないので、普通そこまでは書きません。)4.0と4.1を比べると、ちょっとだけ違いがあります。Swiftのバージョンを聞かれたら、Xcode\n9.4.1ならSwift 4.1と答えられるようにして置いてください。(Xcode 9.4.1にはSwift\n4.1しかついてこないんで、Xcodeのバージョンがわかれば十分なんですが。)\n\n**_この場合forの部分についてExpected declarationのエラーが発生します。_**\n\nSwiftでは、for-\nin文のような実行文は、何かのメソッド(またはイニシャライザ)の中に書く必要があります。ここではイニシャライザにしておくと例えば、次のようになります。\n\n(以下のコードは説明用でコンパイル時にエラーになります。)\n\n```\n\n struct Allyteam {\n var myteam: Team\n \n init(team: Team) {\n self.myteam = team\n for player in myteam.values {\n image = UIImage(named: player)\n }\n }\n }\n \n```\n\nひとつエラーを解消したので、元のコードにあった別のエラーが顕在化してきました。 \n`myteam.values`のところで、次のようなエラーになります。\n\n>\n```\n\n> Value of type 'Team' has no member 'values'\n> \n```\n\n`Team`型の値には`values`なんてメンバー(メソッドかプロパティなんかのこと)は無いですよと言われてます。\n\n実際あなたの`Team`型の宣言はこれだけ:\n\n```\n\n enum Team {\n case WhiteTeam\n case StripeTeam\n }\n \n```\n\nで、どこにも`values`なんて定義されていません。case名と同じ`WhiteTeam`型と`StripeTeam`型を定義したので、それらと結びつけてくれると思われたのでしょうが、case名と型名は全く別物なので、識別子が同じだからといって、自動的に関連づけることはできません。\n\nその辺をはっきりさせるためにも、case名はSwiftの慣習に従って、小文字始まりの識別子にした方が良いでしょう。\n\n```\n\n enum Team {\n case whiteTeam\n case stripeTeam\n }\n \n```\n\n`Team`型の各caseと、`WhiteTeam`型や`StripeTeam`型との関連づけは、メソッドかプロパティの形で自分で書いてやらないといけません。今はplayer名が文字列で得られれば良いようなので、計算型プロパティを追加するとこんな感じになります。\n\n```\n\n extension Team {\n var players: [String] {\n switch self {\n case .whiteTeam:\n return WhiteTeam.values.map{$0.rawValue}\n case .stripeTeam:\n return StripeTeam.values.map{$0.rawValue}\n }\n }\n }\n \n```\n\n(`WhiteTeam`型の`values`は`[WhiteTeam]`型、`StripeTeam`型の`values`は`[StripeTeam]`型なので、それぞれ`map`を使って`[String]`型に変換しています。)\n\nこの`players`を使って、さっきのイニシャライザを書き換えてやるとこうなります。\n\n(以下のコードもまだコンパイル時にエラーになります。)\n\n```\n\n struct Allyteam {\n var myteam: Team\n \n init(team: Team) {\n self.myteam = team\n for player in myteam.players {\n image = UIImage(named: player)\n }\n }\n }\n \n```\n\n今度は、`image`のところで:\n\n>\n```\n\n> Use of unresolved identifier 'image'\n> \n```\n\nSwiftでは全ての変数は宣言しないと使えません。しかも画像は`player`ごとに異なるはずなので、1つじゃ足りないですね。配列型のインスタンスプロパティにしてみましょう。\n\n```\n\n struct Allyteam {\n var myteam: Team\n var playerImages: [UIImage]\n \n init(team: Team) {\n self.myteam = team\n playerImages = []\n for player in myteam.players {\n playerImages.append(UIImage(named: player)!)\n }\n }\n }\n \n```\n\nこれでコンパイル時のエラーは出なくなります。\n\n(危険な強制アンラップ(`!`)を使ってます。画像リソースが存在しないとアプリがクラッシュするのでご注意を。)\n\n* * *\n\nただ、この`Allyteam`型、プレーヤーの画像を配列で持っているのに、画像以外のプレーヤー情報を持っていない、というのは何か変な気がしますね。\n\nひとくちにゲームと言ってもいろいろあるので、確実なことは言えませんが、チーム内のプレーヤー構成を表すのにenumを使うというのはかなり考えにくいケースのように思います。\n\nただ、ご質問に書かれていない内容をあれこれ推測して書いたものを見ていただくより、ここまでの修正を試してご理解いただいてから、何か困ったことがあれば、また質問していただいた方が良いように思います。\n\nこのようなとりあえずの内容ですが、お試しください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T18:16:30.727",
"id": "48663",
"last_activity_date": "2018-09-23T18:21:48.360",
"last_edit_date": "2018-09-23T18:21:48.360",
"last_editor_user_id": "13972",
"owner_user_id": "13972",
"parent_id": "48662",
"post_type": "answer",
"score": 0
}
] | 48662 | 48663 | 48663 |
{
"accepted_answer_id": "48690",
"answer_count": 1,
"body": "```\n\n Auth.auth().createUser(withEmail: address, password: password, completion: {(user, error) in\n if let error = error {\n self.showAlert(msg: error.localizedDescription)\n return \n } else {\n let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest()\n changeRequest?.displayName = self.displaynameTextField.text\n changeRequest?.commitChanges(completion: nil)\n \n```\n\n現在、このような形でユーザーを作成しています。\n\n引数addressとpasswordにはtextFieldに入れられた値を代入しています。 \naddressとpasswordが空であったり、不正なメールアドレスを入れるとエラーメッセージが出て \nユーザーは作成されません。\n\n今、悩んでいるのは \nそれとは別にもう一つdisplayNameのためのtextFieldを用意して \nそれが空だとエラーメッセージを出して、ユーザーを作成しないという処理を行いたいのですが \nエラーメッセージは出せても、それでもdisplayNameが無いままユーザーは作成されてしまいます。\n\ntextFieldが空だとcreateUserしないという処理はどのように行えばよいでしょうか。",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-23T20:47:12.557",
"favorite_count": 0,
"id": "48664",
"last_activity_date": "2018-09-25T04:09:50.667",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27271",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"firebase"
],
"title": "FirebaseAuth の createUser について",
"view_count": 219
} | [
{
"body": "OOPerさんのコメントのおかけで解決致しました。\n\n自分が追加したテキストフィールドが空だと、createUserをキャンセルするという処理は出来ないようなので \nまず第一にテキストフィールドが空かどうか確認し、条件判定で空だとcreateUserを呼び出さないという風に対処しました。\n\nOOPerさん、ありがとうございました!",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T04:09:50.667",
"id": "48690",
"last_activity_date": "2018-09-25T04:09:50.667",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27271",
"parent_id": "48664",
"post_type": "answer",
"score": 0
}
] | 48664 | 48690 | 48690 |
{
"accepted_answer_id": "48838",
"answer_count": 1,
"body": "SPRESENEに拡張ボードを接続し、Arduio IDE on WindowsでのI2C通信を行おうとしています。\n\n```\n\n #include <Wire.h>\n \n #define OLED_ADDR 0x3C\n \n void setup() {\n // put your setup code here, to run once:\n Wire.begin();\n Wire.beginTransmission(OLED_ADDR);\n Wire.write(0x00);\n Wire.endTransmission();\n \n }\n \n```\n\nWire.writeで以下のエラーが出てしまいます。\n\n```\n\n C:\\Users\\***\\AppData\\Local\\Arduino15\\packages\\SPRESENSE\\hardware\\spresense\\1.0.0\\cores\\spresense/Print.h:53:12: note: candidate: size_t Print::write(const char*)\n \n size_t write(const char *str) {\n ^\n \n exit status 1\n call of overloaded 'write(int)' is ambiguous\n \n```\n\nおかしなところがあればご指摘願います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T02:47:14.833",
"favorite_count": 0,
"id": "48665",
"last_activity_date": "2018-10-02T16:47:08.023",
"last_edit_date": "2018-09-24T04:34:06.680",
"last_editor_user_id": "3060",
"owner_user_id": "30217",
"post_type": "question",
"score": 1,
"tags": [
"spresense"
],
"title": "spresense wire.writeについて",
"view_count": 272
} | [
{
"body": "[API のリファレンス](https://www.arduino.cc/en/Reference/WireWrite)を眺めてみますと、`a value\nto send as a single byte` などと書かれていますので、`Wire.write(byte(0x00));`\nとするのではないでしょうか。\n\n\\-- [metropolis](https://ja.stackoverflow.com/users/16894/metropolis)\nさんの[コメント](https://ja.stackoverflow.com/questions/48665/spresense-wire-\nwrite%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6/48838#comment50545_48665)より",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-30T03:07:01.493",
"id": "48838",
"last_activity_date": "2018-09-30T03:07:01.493",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "48665",
"post_type": "answer",
"score": 2
}
] | 48665 | 48838 | 48838 |
{
"accepted_answer_id": "48670",
"answer_count": 1,
"body": "swift初心者です。\n\n```\n\n class Animal {\n \n // 動物名を返すメソッド\n class func returnAnimalName() -> String {\n fatalError(message: \"このメソッドはオーバーライドされていません\")\n }\n \n requied init() {\n }\n \n }\n \n class Dog: Animal {\n override class func returnAnimalName() -> String {\n return \"Dog\"\n }\n }\n \n class Cat: Animal {\n override class func returnAnimalName() -> String {\n return \"Cat\"\n }\n }\n \n```\n\nこのようなコードで動物名の文字列(\"Dog\"や\"Cat\"等)を使ってその動物名が指すAnimalのサブクラスのメタタイプを得たいです。\n\n```\n\n let animalDict = [\"Dog\": Dog.self, \"Cat\": Cat.self]\n \n let dogType = animalDict[\"Dog\"]\n let dog = dogType.init()\n \n let catType = animalDict[\"Cat\"]\n let cat = catType.init()\n \n```\n\nこのように動物名を入れるとそれが指すメタタイプを返すDictionaryを作るという方法もあるのですが、このようにするとAnimalのサブクラスを追加した時にこのDictionaryにも追加する必要があるゆえ、追加し忘れた時のことを考えるとバグの元です。他に何かいい方法はないでしょうか。 \nswift4、xcode9.2です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T02:52:21.303",
"favorite_count": 0,
"id": "48666",
"last_activity_date": "2018-09-24T04:21:57.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30216",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"swift4"
],
"title": "swift あるクラスのサブクラスの一覧を出す方法について",
"view_count": 583
} | [
{
"body": "\"swift get all subclasses of a\nclass\"なんてキーワードで検索したら、本家StackOverflowの記事に同趣旨のものがありました。\n\n[List all subclasses of one\nclass](https://stackoverflow.com/q/42746981/6541007)\n\n**現在のSwiftの実装では** (*)一部の[Objective-\nC用実行時関数](https://developer.apple.com/documentation/objectivec/objective-\nc_runtime)が動作すると言う事実に基づいています。\n\nちなみに...\n\n * あるクラスから、そのサブクラスの一覧を取るような関数はObjective-Cにも無いので、実行時のアプリに登録されているクラス(iOSのクラスも含む)を全部リストアップして、指定のクラスがスーパークラスになっているかどうかを調べています。リストには対象のクラス以外も膨大な数が含まれるので、壮絶(と言うほどでもないが…)に無駄な時間を食います。度々呼び出されるような場所やクリティカルな実行速度が要求される場所で使うのはやめた方が良いでしょう。\n\n * 直接のスーパークラスしか調べていません。よって、指定クラスの直接の子クラスだけが取得できます。孫クラスや子孫クラスも取れるようにするには、ちょっと工夫する必要があるでしょうが、ここでは置いておきます。\n\nと言うわけで、上記リンク先の承認された記事では「こんな大層なもん別に要らんやん」て感じのユーティリティクラス(`ClassInfo`)がかなりの行数を取っていたのと、メモリ管理的に怪しそうだったので、エッセンスの部分だけ拝借して、メモリ管理面を改良した関数を作ってみました。\n\n```\n\n func getAllSubclasses<T>(of theClass: T.Type) -> [T.Type] {\n var subclasses: [T.Type] = []\n autoreleasepool {\n var classCount: UInt32 = 0\n if let classes = objc_copyClassList(&classCount) {\n for i in 0..<Int(classCount) {\n let aClass: AnyClass = classes[i]\n if\n let superclass = class_getSuperclass(aClass),\n ObjectIdentifier(superclass) == ObjectIdentifier(theClass)\n {\n subclasses.append(aClass as! T.Type)\n print(aClass) //デバッグ用\n }\n }\n free(UnsafeMutableRawPointer(classes))\n } else {\n print(\"objc_copyClassList retruned nil\")\n }\n }\n return subclasses\n }\n \n```\n\n現在Xcode 9.2は手元にないので、Xcode 9.4.1と10でしか試していませんが、Xcode 9.2でも動くはずです。(多分…。)\n\n以下のような感じで使えます。\n\n```\n\n let animalSubclasses = getAllSubclasses(of: Animal.self)\n let animalDict = Dictionary(uniqueKeysWithValues: animalSubclasses.map{(String(describing: $0), $0)})\n \n if let dogType = animalDict[\"Dog\"] {\n print(dogType.returnAnimalName())\n let dog = dogType.init()\n print(dog)\n } else {\n print(\"NO type named Dog in subtypes of Animal\")\n }\n \n if let catType = animalDict[\"Cat\"] {\n print(catType.returnAnimalName())\n let cat = catType.init()\n print(cat)\n } else {\n print(\"NO type named Cat in subtypes of Animal\")\n }\n \n```\n\n* * *\n\n(*)SwiftのクラスにどこまでObjective-Cの実行時関数が正常に働くかは明記されていません。今後「ABIの安定性」が宣言される予定のSwift\n5までに大きな変更はないとは思いますが、なんせ「Objective-\nC用の実行時間数」なんで、`objc_copyClassList()`なんかがいつまで期待通り動くかは未知数です。\n\nもし使われるなら、「追加し忘れた時のことを考えるとバグの元」と「いつまで期待通り動くかは未知数」と言うのを天秤にかける必要があるでしょう。",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T04:21:57.563",
"id": "48670",
"last_activity_date": "2018-09-24T04:21:57.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "48666",
"post_type": "answer",
"score": 1
}
] | 48666 | 48670 | 48670 |
{
"accepted_answer_id": "48763",
"answer_count": 1,
"body": "Pythonでnumpyモジュールとcv2(opencv)のモジュールを使おうとしているのですがエラーになります。 \nソースコードは以下の通りです。\n\n* * *\n\n**cap.py**\n\n```\n\n import sys\n sys.path.append('/home/vagrant/.local/lib/python3.4/site-packages')\n import numpy as np\n import cv2\n \n print(\"test\")\n \n```\n\n* * *\n\n実行すると、以下のようなエラーが出ます。\n\n```\n\n vagrant@vagrant-ubuntu-trusty-64:~/workspace/pythonCapture$ python cap.py\n Traceback (most recent call last):\n File \"cap.py\", line 3, in <module>\n import numpy as np\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/__init__.py\", line 142, in <module>\n from . import add_newdocs\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/add_newdocs.py\", line 13, in <module>\n from numpy.lib import add_newdoc\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/lib/__init__.py\", line 8, in <module>\n from .type_check import *\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/lib/type_check.py\", line 11, in <module>\n import numpy.core.numeric as _nx\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/core/__init__.py\", line 26, in <module>\n raise ImportError(msg)\n ImportError: \n Importing the multiarray numpy extension module failed. Most\n likely you are trying to import a failed build of numpy.\n If you're working with a numpy git repo, try `git clean -xdf` (removes all\n files not under version control). Otherwise reinstall numpy.\n \n Original error was: cannot import name multiarray\n \n```\n\ncap.pyから\n\n```\n\n import numpy as np\n import cv2\n \n```\n\nの部分の記述を消して実行すると、問題なく`test`とprintされます。\n\n* * *\n\nnumpyを再インストールしてくださいとメッセージが出ていたので、$ `pip uninstall numpy`と`$ pip install\nnumpy`をした後、`$ python cap.py`を再度実行してみましたが同様のエラーが出ました。\n\nまた、エラー文にgit clean -xdfを実行するようにあったので`$ git clean\n-xdf`をしてみましたが、cap.pyのファイルが消えただけで、エラーは直りませんでした。\n\n```\n\n $ git clean -xdf\n Removing cap.py\n \n```\n\n* * *\n\n$ pip showコマンドでnumpyの場所を一応確認してみました。\n\n```\n\n $ pip show numpy\n Name: numpy\n Version: 1.15.2\n Summary: NumPy: array processing for numbers, strings, records, and objects.\n Home-page: http://www.numpy.org\n Author: Travis E. Oliphant et al.\n Author-email: None\n License: BSD\n Location: /home/vagrant/.local/lib/python3.4/site-packages\n Requires: \n Required-by: opencv-python\n \n```\n\n$ pip showコマンドでopencv-pythonの場所も確認してみました。\n\n```\n\n $ pip show opencv-python\n Name: opencv-python\n Version: 3.4.3.18\n Summary: Wrapper package for OpenCV python bindings.\n Home-page: https://github.com/skvark/opencv-python\n Author: None\n Author-email: None\n License: MIT\n Location: /home/vagrant/.local/lib/python3.4/site-packages\n Requires: numpy\n Required-by: \n \n```\n\nnumpyとopencv、共にsys.path.appendで指定した'/home/vagrant/.local/lib/python3.4/site-\npackages'のフォルダ内にあるようです。\n\n* * *\n\nどうしたらエラーを消せますでしょうか...? \n環境は、Windows10 ProにVirtualBoxとVagrantでUbuntuの仮想環境を作って実行しています。\n\n* * *\n\n[追記]\n\n```\n\n sudo apt-get install libblas3 liblapack3 libc6\n \n```\n\n上記のコマンドを実行しても同様のエラーが出ました。 \n回答して頂いた下記のコマンドも実行してみました。 \n実行コマンドとエラー文を下記に記載します。\n\n* * *\n```\n\n $ sudo apt-get install python3-venv\n パッケージリストを読み込んでいます... 完了\n 依存関係ツリーを作成しています \n 状態情報を読み取っています... 完了\n E: パッケージ python3-venv が見つかりません\n \n```\n\n* * *\n```\n\n $ python3 -m venv env\n The virtual environment was not created successfully because ensurepip is not\n available. On Debian/Ubuntu systems, you need to install the python3-venv\n package using the following command.\n \n apt-get install python3-venv\n \n You may need to use sudo with that command. After installing the python3-venv\n package, recreate your virtual environment.\n \n vagrant@vagrant-ubuntu-trusty-64:~/workspace/pythonCapture$ souece env/bin/activate\n souece: command not found\n \n```\n\n* * *\n```\n\n $ source env/bin/activate\n -bash: env/bin/activate: No such file or directory\n \n```\n\n* * *\n```\n\n $ pip install numpy opencv-python\n Requirement already satisfied: numpy in /home/vagrant/.local/lib/python3.4/site-packages (1.15.2)\n Requirement already satisfied: opencv-python in /home/vagrant/.local/lib/python3.4/site-packages (3.4.3.18)\n \n```\n\n* * *\n```\n\n $ python cap.py\n Traceback (most recent call last):\n File \"test.py\", line 3, in <module>\n import numpy as np\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/__init__.py\", line 142, in <module>\n from . import add_newdocs\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/add_newdocs.py\", line 13, in <module>\n from numpy.lib import add_newdoc\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/lib/__init__.py\", line 8, in <module>\n from .type_check import *\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/lib/type_check.py\", line 11, in <module>\n import numpy.core.numeric as _nx\n File \"/home/vagrant/.local/lib/python3.4/site-packages/numpy/core/__init__.py\", line 26, in <module>\n raise ImportError(msg)\n ImportError: \n Importing the multiarray numpy extension module failed. Most\n likely you are trying to import a failed build of numpy.\n If you're working with a numpy git repo, try `git clean -xdf` (removes all\n files not under version control). Otherwise reinstall numpy.\n \n Original error was: cannot import name multiarray\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T03:01:54.467",
"favorite_count": 0,
"id": "48667",
"last_activity_date": "2018-09-29T09:53:17.280",
"last_edit_date": "2018-09-29T02:32:58.243",
"last_editor_user_id": "22541",
"owner_user_id": "22541",
"post_type": "question",
"score": 3,
"tags": [
"python",
"ubuntu",
"opencv",
"numpy"
],
"title": "Pythonでモジュールのimportエラーになる",
"view_count": 16480
} | [
{
"body": "質問にあるエラーは、numpyが使用する数値演算ライブラリーがインストールされていないため発生しているように思われます。`numpy`を`pip`でインストールしたのであれば、`libblas3`,\n`liblapack3`, `libc6`をインストールしてみてください。\n\n```\n\n sudo apt-get install libblas3 liblapack3 libc6\n \n```\n\nもし、それでも同じエラーが出るのであれば、仮想環境を作成してインストールしてみてください。\n\n```\n\n sudo apt-get install python3.4-venv\n python3 -m venv env\n source env/bin/activate\n pip install numpy opencv-python\n \n```",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T07:26:24.553",
"id": "48763",
"last_activity_date": "2018-09-29T09:53:17.280",
"last_edit_date": "2018-09-29T09:53:17.280",
"last_editor_user_id": "15171",
"owner_user_id": "15171",
"parent_id": "48667",
"post_type": "answer",
"score": 2
}
] | 48667 | 48763 | 48763 |
{
"accepted_answer_id": "48703",
"answer_count": 1,
"body": "**環境** \nmacbookにvagrantをインストールさせてその中でubuntu14.04を動作している。\n\n**症状** \njupyter\nnoteをvagrantで動作させているのですがサーバーを立ち上げた時に出てくるurlをコピーしてMac側のブラウザーで開いてもアクセスできません。\n\n**やったこと** \n最初、jupyterが8888で立ち上がっているのを確認し他のアプリを作った時に使用していた番号が9000だったのでvagrantfileに以下の文を追加したのですが`config.vm.network\n\"forwarded_port\", guest: 8888, host: 8888`うまく動作しませんでした。 \nじゃあ`config.vm.network \"forwarded_port\", guest: 9000, host:\n9000`を消して変えたらいいのではと思うのですが、これは他のアプリで使いたいので残しておきたいです。\n\n**解決したいこと** \nひとつのipアドレスで複数のゲストとホスト番号を使用したいのですが、このようなことは可能でしょうか? \n可能な場合どのようにvagrantfileを変更したらよろしいでしょうか? \njupyter noteのデフォルトアドレスを変更する方法もあるかと思います。 \nそのやり方も教えて下さるとても助かります。よろしくお願いします。\n\n**Vagrantfile**\n\n```\n\n # -*- mode: ruby -*-\n # vi: set ft=ruby :\n \n # All Vagrant configuration is done below. The \"2\" in Vagrant.configure\n # configures the configuration version (we support older styles for\n # backwards compatibility). Please don't change it unless you know what\n # you're doing.\n Vagrant.configure(2) do |config|\n # The most common configuration options are documented and commented below.\n # For a complete reference, please see the online documentation at\n # https://docs.vagrantup.com.\n \n # Every Vagrant development environment requires a box. You can search for\n # boxes at https://atlas.hashicorp.com/search.\n #ここで公式サイトからOSのイメージをダウンロードしている。 \n config.vm.box = \"ubuntu/trusty64\"\n # Disable automatic box update checking. If you disable this, then\n # boxes will only be checked for updates when the user runs\n # `vagrant box outdated`. This is not recommended.\n # config.vm.box_check_update = false\n \n # Create a forwarded port mapping which allows access to a specific port\n # within the machine from a port on the host machine. In the example below,\n # accessing \"localhost:8080\" will access port 80 on the guest machine.\n config.vm.network \"forwarded_port\", guest: 9000, host: 9000\n config.vm.network \"forwarded_port\", guest: 8888, host: 8888\n \n # Create a private network, which allows host-only access to the machine\n # using a specific IP.\n config.vm.network \"private_network\", ip: \"192.168.22.41\"\n \n # Create a public network, which generally matched to bridged network.\n # Bridged networks make the machine appear as another physical device on\n # your network.\n # config.vm.network \"public_network\"\n \n # Share an additional folder to the guest VM. The first argument is\n # the path on the host to the actual folder. The second argument is\n # the path on the guest to mount the folder. And the optional third\n # argument is a set of non-required options.\n # config.vm.synced_folder \"./\", \"/home/vagrant\"\n \n # Provider-specific configuration so you can fine-tune various\n # backing providers for Vagrant. These expose provider-specific options.\n # Example for VirtualBox:\n #\n # config.vm.provider \"virtualbox\" do |vb|\n # # Display the VirtualBox GUI when booting the machine\n # vb.gui = true\n #\n # # Customize the amount of memory on the VM:\n # vb.memory = \"1024\"\n # end\n #\n # View the documentation for the provider you are using for more\n # information on available options.\n \n # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies\n # such as FTP and Heroku are also available. See the documentation at\n # https://docs.vagrantup.com/v2/push/atlas.html for more information.\n # config.push.define \"atlas\" do |push|\n # push.app = \"YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME\"\n # end\n \n # Enable provisioning with a shell script. Additional provisioners such as\n # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the\n # documentation for more information about their specific syntax and use.\n \n end\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T03:11:57.310",
"favorite_count": 0,
"id": "48668",
"last_activity_date": "2018-09-25T13:28:29.657",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22565",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"vagrant",
"virtualbox",
"jupyter-notebook"
],
"title": "vagrantfileで1つのipアドレスに複数のゲストとホストを設定するには?",
"view_count": 355
} | [
{
"body": "状況把握しました。 \njupyter note自体が、特定のIP以外を拒否するc.NotebookApp.ipという設定があるのですね。 \n制限しつつ公開するには、以下のようなものが考えられます。\n\n【方針1】 \njupyter noteのc.NotebookApp.ipにホストPCのローカルIPを設定する。\n\n【方針2】 \nVMのiptables/firewalldなどで、許可するIPをホストPCのみに絞る。\n\n【方針3】 \njupyter noteパスワード機能を有効にする \n<https://qiita.com/SaitoTsutomu/items/aee41edf1a990cad5be6>\n\n※ 方針1や方針2でうまくいかない場合は \nvagrantをpublic_networkにして見てください。 \nただし、これをするとVMのIPさえ知っていれば社内LANから自由にアクセスできます。 \n(VMがLANに直接所属するシンプルなネットワーク構成になる。)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T13:28:29.657",
"id": "48703",
"last_activity_date": "2018-09-25T13:28:29.657",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "25396",
"parent_id": "48668",
"post_type": "answer",
"score": 0
}
] | 48668 | 48703 | 48703 |
{
"accepted_answer_id": "48674",
"answer_count": 1,
"body": "```\n\n version: \"3\"\n services:\n es:\n image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2\n container_name: es\n environment:\n - discovery.type=single-node\n ports:\n - 9200:9200\n volumes:\n - esdata1:/usr/share/elasticsearch/data\n web:\n image: prakhar1989/foodtrucks-web\n command: python app.py\n depends_on:\n - es\n ports:\n - 5000:5000\n volumes:\n - ./flask-app:/opt/flask-app\n volumes:\n esdata1:\n driver: local\n \n```\n\n上記のコードはここにあります:[チュートリアル](https://docker-curriculum.com/)\n\nVolumesはContainerが終わってもPersistするデータの事だと思いますが、既にここ:\n\n```\n\n volumes:\n - esdata1:/usr/share/elasticsearch/data\n \n```\n\nとここ:\n\n```\n\n volumes:\n - ./flask-app:/opt/flask-app\n \n```\n\nで各Container内にMount pointを指定していると思います。 \nなので最後の部分が何を指定しているのかが分かりません:\n\n```\n\n volumes:\n esdata1:\n driver: local\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T06:11:21.197",
"favorite_count": 0,
"id": "48672",
"last_activity_date": "2018-09-24T08:12:18.783",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29239",
"post_type": "question",
"score": 3,
"tags": [
"docker"
],
"title": "Docker Beginner Tutorial のVolumesの説明が分かりません",
"view_count": 83
} | [
{
"body": "最後の部分ではPersistent volume(esdata1)の設定をしています。 \nローカルのディレクトリをマウントする(flask-appディレクトリ)ならばこれはいりませんが、Persistent\nvolumeを使う場合はこのように別途利用するVolumeを宣言する必要があります。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T08:12:18.783",
"id": "48674",
"last_activity_date": "2018-09-24T08:12:18.783",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7232",
"parent_id": "48672",
"post_type": "answer",
"score": 3
}
] | 48672 | 48674 | 48674 |
{
"accepted_answer_id": "48771",
"answer_count": 1,
"body": "PHPプログラミング超初心者です。\n\n勉強を主目的に、とある多数のチェック項目に対する記録をするサイトをcloud9とLaravelを使って作成しているのですが、1000を超えるデータをPOSTで送信できないです。 \n1001以上ある場合に、1000個までしかデータが送られてないです。(Controller内で、 `dd($request);` で確認しました) \nいろいろ調べてphp.iniファイル内の `max_input_vars = 3000` にしましたが、1000個のデータしか遅れてないです。\n\nどのようにしたら1000以上のデータがPOST出来るのか教えていただけないでしょうか \n該当箇所のViewは以下のように、チェック項目数分データを取得して、 `foreach` で表示しています。\n\n```\n\n @foreach ($evidence as $a_evidence)\n <tr>\n @if ($first == true)\n <td>{!! Form::select('evidence_type[]',['null'=>'', 'strength'=>'+', 'weakness'=>'-', 'neutral'=>'±'], $a_evidence->evidence_type, ['class' => 'form-control']) !!}</td>\n <?php $first = false; ?>\n @endif\n <td>{!! Form::textarea('evidence_comment[]', $a_evidence->evidence_comment, ['class' => 'form-control', 'rows' => '2']) !!}</td>\n <td>{!! Form::text('evidence_document[]', $a_evidence->evidence_document, ['class' => 'form-control']) !!}</td>\n </tr>\n @endforeach \n \n```",
"comment_count": 7,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T11:40:56.317",
"favorite_count": 0,
"id": "48676",
"last_activity_date": "2018-09-27T13:41:22.183",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30220",
"post_type": "question",
"score": 1,
"tags": [
"php"
],
"title": "PHPのPOSTの上限について",
"view_count": 644
} | [
{
"body": "どこに問題があったか一部曖昧ですが、POSTのデフォルト値を変更したときに実施したことを記録しておきます\n\n 1. `$ sudo vi php.ini` でphp.iniを編集状態にする\n 2. `max_input_vars = 1000` を `max_input_vars = 3000` に変更する\n 3. `$ sudo /etc/init.d/httpd restart` でApacheを再起動させる\n 4. ここで確認したが反映されず\n 5. PCをシャットダウン\n 6. 翌日再度確認したら、反映されてました",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T13:41:22.183",
"id": "48771",
"last_activity_date": "2018-09-27T13:41:22.183",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30220",
"parent_id": "48676",
"post_type": "answer",
"score": 1
}
] | 48676 | 48771 | 48771 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "皆様のアイデアを頂戴したいです。\n\n仕事上の目的で、下のような有向グラフの最長経路を求めたい \nと考えております。①から⑤までです。\n\n実際のグラフはもっと複雑です。ですので総当たりは難しいです。\n\n最初ダイクストラ法を用いようと考えましたが \n①ダイクストラ法は最小経路を求めるので、そのままでは最長経路 \nが求められない。 \n②負の重みがある。 \nため断念しました。\n\n上手くこの問題をダイクストラ法で解く方法、あるいはダイクストラ法 \nに限らず解く方法はないでしょうか。[](https://i.stack.imgur.com/fsqlR.png)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T12:04:45.443",
"favorite_count": 0,
"id": "48677",
"last_activity_date": "2018-10-02T15:06:14.493",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30222",
"post_type": "question",
"score": 5,
"tags": [
"アルゴリズム"
],
"title": "負の重みを含んだ最長経路の求め方",
"view_count": 2463
} | [
{
"body": "<https://en.wikipedia.org/wiki/Longest_path_problem>\n\n最長経路問題は、たとえ負の重みがなくても、一般的に NP 困難なので、総当たりするぐらいしか解がないかと思います。\n\nいくつか、特殊なケースの最長経路問題(例えばループが存在しないグラフとか)であるならば、NP困難性を回避する手法は見つかっている様子ですが(mjy\nさんのおっしゃる、重みの正負をひっくり返したグラフで解く)、今回のようなグラフについては、すくなくともこのグラフにおいては、そのような性質はなさそうだと思っています。\n\n実際に仕事で扱うとしたら、最長経路問題を解かないで済むような方法をどうにかして考える、しかないと思っています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T04:05:04.807",
"id": "48689",
"last_activity_date": "2018-09-25T04:14:10.857",
"last_edit_date": "2018-09-25T04:14:10.857",
"last_editor_user_id": "754",
"owner_user_id": "754",
"parent_id": "48677",
"post_type": "answer",
"score": 4
},
{
"body": "皆様回答ありがとうございます。参考にさせていただきます。 \n問題を見直して、DAG化して最長経路に近そうな値を求めることにしました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-10-02T15:06:14.493",
"id": "48907",
"last_activity_date": "2018-10-02T15:06:14.493",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30222",
"parent_id": "48677",
"post_type": "answer",
"score": 0
}
] | 48677 | null | 48689 |
{
"accepted_answer_id": "48700",
"answer_count": 2,
"body": "brew でパッケージをインストールしていくと、 zsh の completion\nコードが付属している場合があることに気づきました。それらは、パッケージをインストールした際のメッセージによれば、\n`/usr/local/share/zsh/site-functions` に配置される様子です。\n\n```\n\n zsh completions have been installed to:\n /usr/local/share/zsh/site-functions\n \n```\n\n### 質問\n\n * brew で入ってくる zsh の補完を on にするには、どうしたらいいでしょうか。\n * また、上記のディレクトリをのぞいてみたところ、ある種の規則に従った naming convention でファイルたちは作られているように見受けられます。これらを一括で利用できるようにするような、 zsh のプロファイリングスクリプトを作るとしたら、どのようになりますでしょうか。\n\nインストールされている zsh completion 一覧\n\n```\n\n $ ls /usr/local/share/zsh/site-functions \n _aws _brew_cask _gibo _heroku aws_zsh_completer.sh\n _brew _brew_services _git _kubectl git-completion.bash\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T13:36:24.937",
"favorite_count": 0,
"id": "48678",
"last_activity_date": "2018-09-25T10:17:44.860",
"last_edit_date": "2018-09-25T10:17:44.860",
"last_editor_user_id": "754",
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"homebrew",
"zsh"
],
"title": "zsh で、 brew でインストールされている zsh 補完を一括で利用可能にしたい",
"view_count": 2927
} | [
{
"body": "fpathに加えると使えるようになります\n\n具体的には、.zshrcの`compinit`よりも前の行に、下記のコードを追加します。\n\n```\n\n fpath=(/usr/local/share/zsh/site-functions $fpath)\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T14:35:31.207",
"id": "48680",
"last_activity_date": "2018-09-24T14:35:31.207",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9575",
"parent_id": "48678",
"post_type": "answer",
"score": 2
},
{
"body": "`compinit` (大抵は`.zshrc`に記載すると思いますが)の一行前に、 \n`autoload -U compinit` の記述はしておられますか? \nつまり、 \n`.zshrc`の中に記載されるべきは、\n\n```\n\n autoload -U compinit\n compinit\n \n```\n\nこの順番に、2行になります。 \nもう一つ見落としやすいのは`/usr/local/share/zsh/site-functions`のパーミッションですね \n。 \nこれで`TAB`キーでの補完が可能になると思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T09:52:37.897",
"id": "48700",
"last_activity_date": "2018-09-25T09:52:37.897",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "14745",
"parent_id": "48678",
"post_type": "answer",
"score": 3
}
] | 48678 | 48700 | 48700 |
{
"accepted_answer_id": "48704",
"answer_count": 1,
"body": "Pythonでrandom関数を使ったじゃんけんプログラムを作っています。 \nその中で今までの勝ち負け引き分けのそれぞれ合計を出す部分が\n\n```\n\n Index Error : Taple index out of range \n \n```\n\nというエラーを出していてその解決法が分かりません。\n\nどなたかご指導お願いします。\n\n```\n\n # じゃんけんゲーム\n import random\n \n hand = [\"グー\", \"チョキ\", \"パー\", \"ゲーム終了\"]\n \n win = 0\n lose = 0\n draw = 0\n time = 0\n \n print(\"===じゃんけんしましょう===\")\n \n while True:\n \n com = random.randint(0,2)\n for i, desc in enumerate(hand):\n print(i, \":\", desc)\n you = int(input(\"出す手を数値で入力: \"))\n \n time += 1 # 試行回数\n \n if you == 3: break\n if you < 0 or you > 2:\n print(\"0から3の間で入力してね\")\n continue\n \n print(\"---\")\n print(\"自分 : \", hand[you])\n print(\"相手 : \", hand[com])\n input(\"---\")\n \n j = (you - com + 3) % 3\n if j == 0:\n print(\"あいこ\")\n draw += 1 # 引き分けた回数\n elif j == 1:\n print(\"負け...\")\n lose += 1 # 負けた回数\n elif j == 2:\n print(\"勝ち!!!\")\n win += 1 # 勝った回数\n input(\"---\")\n \n rate = win / time\n print(\"現在の勝率 : \", rate) # 勝率\n s = win, \"勝\", lose, \"敗\", draw, \"分\" #内訳。ここはエラーなし\n print(s)\n s2 = \"{1}勝ち{2}負け{3}分け\".format(win, lose, draw) # Tuple index out of range と出る\n print(s2)\n input(\"---\")\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T14:52:20.380",
"favorite_count": 0,
"id": "48681",
"last_activity_date": "2021-01-03T06:05:58.513",
"last_edit_date": "2018-09-24T16:33:08.730",
"last_editor_user_id": "3060",
"owner_user_id": "27172",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3"
],
"title": "Python で tuple index out of range というエラーが出る",
"view_count": 42082
} | [
{
"body": "\"{1}勝ち{2}負け{3}分け\"ではなく、\"{0}勝ち{1}負け{2}分け\"とすればうまくいきます。 \n0オリジンで、タプルとしては3つしか与えていないのに、3つまりは4番目の値を入れようとして、その値が見つからないという意味です。 \nwin:0番目 \nlose: 1番目 \ndraw: 2番目\n\n試しに、\n\n```\n\n >>> \"{1}勝ち{2}負け{3}分け\".format(1,2,3)\n Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n IndexError: tuple index out of range\n >>> \"{0}勝ち{1}負け{2}分け\".format(1,2,3)\n '1勝ち2負け3分け'\n >>>\n \n```\n\n正しく動作するようになります。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T16:36:38.590",
"id": "48704",
"last_activity_date": "2018-09-25T16:36:38.590",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10174",
"parent_id": "48681",
"post_type": "answer",
"score": 4
}
] | 48681 | 48704 | 48704 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "お世話になります。 \nWindows10にMinGWをインストールして、G++を利用して、CPPのソースをコンパイルしようとしているんですが、下記のソースコードをコンパイルすると、エラーが発生します。\n\n```\n\n #define _USE_MATH_DEFINES\n #include <cmath>\n #include \"beeps.h\"\n \n const int sampleRate=44100;\n const int amplitude=14000;\n \n int generateBeep(short* buf, const float hz, const int length, const int left, const int right) {\n const int samplesPerCycle=static_cast<int>(sampleRate/hz);\n int totalSamples=static_cast<int>((length/1000.0)/(1.0/sampleRate));\n totalSamples+=samplesPerCycle-(totalSamples%samplesPerCycle);\n if (!buf) { //just return buffer length\n return totalSamples*4;\n }\n const double lpan=(left/100.0)*amplitude, rpan=(right/100.0)*amplitude;\n const double sinFreq=(2.0*M_PI)/(sampleRate/hz); //DON'T use samplesPerCycle here\n for (int sampleNum=0; sampleNum<totalSamples; ++sampleNum) {\n const double sample=min(max(sin((sampleNum%sampleRate)*sinFreq)*2.0,-1.0),1.0);\n buf[sampleNum*2]=static_cast<short>(sample*lpan);\n buf[sampleNum*2+1]=static_cast<short>(sample*rpan);\n }\n return totalSamples*4;\n }\n \n```\n\nエラー内容は、下記のとおりです。\n\n```\n\n beeps.cpp:18:75: error: 'max' was not declared in this scope\n const double sample=min(max(sin((sampleNum%sampleRate)*sinFreq)*2.0,-1.0),1.0);\n \n beeps.cpp:18:80: error: 'min' was not declared in this scope\n const double sample=min(max(sin((sampleNum%sampleRate)*sinFreq)*2.0,-1.0),1.0);\n \n```\n\n何かインストールが必要なパッケージ等があるのでしょうか。 \n何か解決方法がありましたら、教えていただけると幸いです。 \nよろしくお願いいたします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T15:16:19.737",
"favorite_count": 0,
"id": "48682",
"last_activity_date": "2018-09-27T04:45:53.330",
"last_edit_date": "2018-09-27T04:45:53.330",
"last_editor_user_id": "19110",
"owner_user_id": "29034",
"post_type": "question",
"score": 1,
"tags": [
"c++"
],
"title": "G++でのコンパイルエラー: 'max' was not declared in this scope",
"view_count": 4476
} | [
{
"body": "[標準ライブラリヘッダ\n`<cmath>`](https://ja.cppreference.com/w/cpp/header/cmath)では`min`や`max`は宣言されていません。`std::min`や`std::max`であれば\n[`<algorithm>` で定義](https://ja.cppreference.com/w/cpp/algorithm/min)されています。\n\nちなみに`<algorithm>`の[`std::clamp`](https://ja.cppreference.com/w/cpp/algorithm/clamp)を使用すると\n\n>\n```\n\n> const double\n> sample=min(max(sin((sampleNum%sampleRate)*sinFreq)*2.0,-1.0),1.0);\n> \n```\n\nは\n\n```\n\n const double sample=std::clamp(sin((sampleNum%sampleRate)*sinFreq)*2.0,-1.0,1.0);\n \n```\n\nと書くことができ、コードがわかりやすくなります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-24T22:42:16.457",
"id": "48683",
"last_activity_date": "2018-09-24T22:42:16.457",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "48682",
"post_type": "answer",
"score": 2
}
] | 48682 | null | 48683 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "こんにちは 最近pythonを学び始めた初心者です、質問をさせていただきます。 \nヤフーニュースから記事のタイトルだけを抜き出すコードを描いたのですが、 \nbs4.FeatureNotFound: Couldn't find a tree builder with the features you \nrequested: html_parser. Do you need to install a parser library? \nと表示されてしまいます。インタラクティブモードで実行したときはうまく表示されたのですが... \nどのようにすれば解決できますか?\n\n* * *\n```\n\n import requests\n from bs4 import BeautifulSoup\n result = requests.get('https://news.yahoo.co.jp/list/')\n soup = BeautifulSoup(result.text,'html_parser')\n midashi_all = soup.find_all('dl', class_='title')\n for midashi in midashi_all:\n print(midashi.dt.get_text())\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T03:29:19.437",
"favorite_count": 0,
"id": "48685",
"last_activity_date": "2018-09-25T03:33:26.053",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30006",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"web-scraping"
],
"title": "pythonのwebスクレイピングについて",
"view_count": 319
} | [
{
"body": "BeautifulSoupに指定しているパーサが間違っているようです。`html_parser` ではなく、 `html.parser`\nを指定してみてください。\n\n```\n\n import requests\n from bs4 import BeautifulSoup\n result = requests.get('https://news.yahoo.co.jp/list/')\n soup = BeautifulSoup(result.text,'html.parser')\n midashi_all = soup.find_all('dl', class_='title')\n for midashi in midashi_all:\n print(midashi.dt.get_text())\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T03:33:26.053",
"id": "48687",
"last_activity_date": "2018-09-25T03:33:26.053",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29826",
"parent_id": "48685",
"post_type": "answer",
"score": 2
}
] | 48685 | null | 48687 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "local環境 Macos HighSierra \nDocker環境 CentOS \nです。 \nDockerfileに、NEologdのインストールコマンドを記載してDockerコンテナに反映させようとしています。 \n手順としては、 \ngit cloneでNEologdをダウンロード。 \nNEologdがあるフォルダに移動し、そこで \n`RUN ./bin/install-mecab-ipadic-neologd -n -a` \nのコマンドを書いています。ローカルのPC上ではこれでうまくインストール出来たのですが、Dockerfileで\nコンテナにインストールしようとすると。下記エラーが出ます。\n\n```\n\n (venv) bash-4.2# ./bin/install-mecab-ipadic-neologd -n -a\n [install-mecab-ipadic-NEologd] : Start..\n [install-mecab-ipadic-NEologd] : Check the existance of libraries\n [install-mecab-ipadic-NEologd] : find => ok\n [install-mecab-ipadic-NEologd] : sort => ok\n [install-mecab-ipadic-NEologd] : head => ok\n [install-mecab-ipadic-NEologd] : cut => ok\n [install-mecab-ipadic-NEologd] : egrep => ok\n [install-mecab-ipadic-NEologd] : mecab => ok\n [install-mecab-ipadic-NEologd] : mecab-config => ok\n [install-mecab-ipadic-NEologd] : make => ok\n [install-mecab-ipadic-NEologd] : curl => ok\n [install-mecab-ipadic-NEologd] : sed => ok\n [install-mecab-ipadic-NEologd] : cat => ok\n [install-mecab-ipadic-NEologd] : diff => ok\n [install-mecab-ipadic-NEologd] : tar => ok\n [install-mecab-ipadic-NEologd] : unxz => ok\n [install-mecab-ipadic-NEologd] : xargs => ok\n [install-mecab-ipadic-NEologd] : grep => ok\n [install-mecab-ipadic-NEologd] : iconv => ok\n [install-mecab-ipadic-NEologd] : patch => ok\n [install-mecab-ipadic-NEologd] : which => ok\n which: no file in (/home/ec2-user/venv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)\n \n```\n\nこのエラーはファイルが存在しないといういう意味なのでしょうか? \nローカルと同様にgit cloneしているのにどうしてファイルが存在しないというエラーが出るのか解決出来なくて困っています。 \nアドバイス頂ければ幸いです。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T03:29:36.607",
"favorite_count": 0,
"id": "48686",
"last_activity_date": "2020-06-26T02:03:10.250",
"last_edit_date": "2018-09-26T01:05:24.823",
"last_editor_user_id": "2383",
"owner_user_id": "30201",
"post_type": "question",
"score": 3,
"tags": [
"python",
"docker",
"mecab"
],
"title": "Dockerコンテナに mecabの辞書、NEologdをインストール中、ファイルが存在しないと言われる。",
"view_count": 452
} | [
{
"body": "ログを見るに、インストールに必要なコマンドが存在しているか調べている最中に、見つからなかったコマンドがあったように見えます。\n\n`install-mecab-ipadic-neologd`\nのソースコードを読むと、件のログは[このあたり](https://github.com/neologd/mecab-ipadic-\nneologd/blob/5318015d9532cbdf473e003776d5dc189f0f87d5/bin/install-mecab-\nipadic-neologd#L322)で出力されており、このログは「`file` コマンドが見つからない」と言っているようです。\n\nしたがって後は [metropolis\nさんのコメント](https://ja.stackoverflow.com/questions/48686/docker%E3%82%B3%E3%83%B3%E3%83%86%E3%83%8A%E3%81%AB-\nmecab%E3%81%AE%E8%BE%9E%E6%9B%B8-neologd%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E4%B8%AD-%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%8C%E5%AD%98%E5%9C%A8%E3%81%97%E3%81%AA%E3%81%84%E3%81%A8%E8%A8%80%E3%82%8F%E3%82%8C%E3%82%8B#comment50581_48686)通り、`file`\nコマンドが存在するか確かめてください。存在していなければインストールが必要です。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T04:43:24.547",
"id": "48755",
"last_activity_date": "2018-09-27T04:43:24.547",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "48686",
"post_type": "answer",
"score": 1
}
] | 48686 | null | 48755 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "以前開発した歩数計アプリを改修することになり、今年11月からのターゲットSDKがAndroid8以上必須の影響度を調査しています。\n\n現状は歩数のカウントをサービスで行っています。アプリが起動していなくても歩数をカウントしています。 \nサービスは下記のタイミングで startService() で起動しています。 \n・アプリ起動時 \n・端末起動時(RECEIVE_BOOT_COMPLETED) \n・アプリ更新時(PACKAGE_REPLACED)\n\nこれをAndroid8に対応したいのですが、Android8の実機が無いので試せません。 \nどのような対応をすれば、Android8でも問題なく動作するようになりますか? \nアドバイスをよろしくお願いいたします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T05:02:10.303",
"favorite_count": 0,
"id": "48692",
"last_activity_date": "2018-09-28T06:09:48.437",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7212",
"post_type": "question",
"score": 0,
"tags": [
"android"
],
"title": "Android8のサービス実装方法について教えてください。",
"view_count": 136
} | [
{
"body": "自己レスです。\n\nandroid8端末を入手できて、下記の変更で動作することを確認できました。思っていたより単純でした。\n\n```\n\n サービス起動を下記に変更。\n ContextCompat.startForegroundService(this, new Intent(this, PedometerService.class));\n \n サービスのonCreateで下記を実行。\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)\n startForeground(1, new NotificationCompat.Builder(this).build());\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-28T06:09:48.437",
"id": "48783",
"last_activity_date": "2018-09-28T06:09:48.437",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7212",
"parent_id": "48692",
"post_type": "answer",
"score": 2
}
] | 48692 | null | 48783 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "初めて利用します。 \n私は、chainerを利用してConvolutionalLSTMという機構を用いた機械学習の研究を行っております。\n\nMovingMnistを利用した実験ではプログラムが動いたのですが、手持ちのデータを利用しようとした所エラーが出てしまい、困っております。 \n入力データは、320x256のbmpデータ(1チャンネル)になります。\n\n**エラー内容**\n\n```\n\n /home/denko/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n from ._conv import register_converters as _register_converters\n \n Exception in main training loop: Unsupported dtype object\n Traceback (most recent call last):\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py\", line 299, in run\n update()\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py\", line 223, in update\n self.update_core()\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py\", line 228, in update_core\n in_arrays = self.converter(batch, self.device)\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/dataset/convert.py\", line 93, in concat_examples\n [example[i] for example in batch], padding[i])))\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/dataset/convert.py\", line 35, in to_device\n return cuda.to_gpu(x, device)\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/backends/cuda.py\", line 275, in to_gpu\n return _array_to_gpu(array, device_, stream)\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/backends/cuda.py\", line 322, in _array_to_gpu\n return cupy.asarray(array)\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/cupy/creation/from_data.py\", line 61, in asarray\n return core.array(a, dtype, False)\n File \"cupy/core/core.pyx\", line 2070, in cupy.core.core.array\n File \"cupy/core/core.pyx\", line 2101, in cupy.core.core.array\n Will finalize trainer extensions and updater before reraising the exception.\n Traceback (most recent call last):\n File \"train.py\", line 81, in <module>\n train()\n File \"train.py\", line 69, in train\n trainer.run()\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py\", line 313, in run\n six.reraise(*sys.exc_info())\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/six.py\", line 693, in reraise\n raise value\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py\", line 299, in run\n update()\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py\", line 223, in update\n self.update_core()\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py\", line 228, in update_core\n in_arrays = self.converter(batch, self.device)\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/dataset/convert.py\", line 93, in concat_examples\n [example[i] for example in batch], padding[i])))\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/dataset/convert.py\", line 35, in to_device\n return cuda.to_gpu(x, device)\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/backends/cuda.py\", line 275, in to_gpu\n return _array_to_gpu(array, device_, stream)\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/chainer/backends/cuda.py\", line 322, in _array_to_gpu\n return cupy.asarray(array)\n File \"/home/denko/anaconda3/lib/python3.6/site-packages/cupy/creation/from_data.py\", line 61, in asarray\n return core.array(a, dtype, False)\n File \"cupy/core/core.pyx\", line 2070, in cupy.core.core.array\n File \"cupy/core/core.pyx\", line 2101, in cupy.core.core.array\n ValueError: Unsupported dtype object\n \n```\n\n**コード**\n\n\\--dataset_for_rr--\n\n```\n\n import numpy as np\n import chainer\n from PIL import Image\n from chainer import cuda, Variable\n \n class rrDataset(chainer.dataset.DatasetMixin):\n def __init__(self,l,r,inf,outf):\n self.rr_list = np.load('/media/denko/OS/data/rr_list/test.npy')\n self.l = l\n self.r = r\n self.inf = inf\n self.outf = outf\n self.flames = self.inf + self.outf\n self.num = self.r - self.l\n self.xp = cuda.cupy\n \n def __len__(self):\n return self.num\n \n def get_example(self,i):\n self.ind = self.l + i\n self.data = np.empty((self.flames,1,256,320),dtype=np.float32)\n \n for j in range(self.flames):\n self.bmp_name = str(int(self.rr_list[self.ind][j]))\n self.year = self.bmp_name[0:4]\n self.month = self.bmp_name[4:6]\n self.path = '/media/denko/OS/data/bmp/' + self.year + '/' + self.month + '/' + self.bmp_name + '.bmp'\n self.bmp_data = Image.open(self.path)\n self.bmp_data = np.array(self.bmp_data).astype(dtype=np.float32)\n self.bmp_data = self.bmp_data / 255\n self.data[j,0,:,:] = self.bmp_data\n \n self.data = Variable(np.array(self.data,dtype=np.float32))\n \n return self.data[:self.inf,0,:,:], self.data[self.inf:self.flames,0,:,:]\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T06:19:02.180",
"favorite_count": 0,
"id": "48693",
"last_activity_date": "2018-09-26T01:22:47.620",
"last_edit_date": "2018-09-25T06:31:00.623",
"last_editor_user_id": "3060",
"owner_user_id": "30229",
"post_type": "question",
"score": 0,
"tags": [
"python",
"chainer"
],
"title": "Chainerで学習時にエラーが出てしまい、学習できない",
"view_count": 4525
} | [
{
"body": "短く言えば,\n\n```\n\n 34 self.data = Variable(np.array(self.data,dtype=np.float32))\n \n```\n\nを\n\n```\n\n 34 self.data = np.array(self.data,dtype=np.float32)\n \n```\n\nとすればよいでしょう.\n\n以下は詳細です. \nわかりにくかったので行をつけさせていただきました.\n\n```\n\n 1 import numpy as np\n 2 import chainer\n 3 from PIL import Image\n 4 from chainer import cuda, Variable\n 5\n 6 class rrDataset(chainer.dataset.DatasetMixin):\n 7 def __init__(self,l,r,inf,outf):\n 8 self.rr_list = np.load('/media/denko/OS/data/rr_list/test.npy')\n 9 self.l = l\n 10 self.r = r\n 11 self.inf = inf\n 12 self.outf = outf\n 13 self.flames = self.inf + self.outf\n 14 self.num = self.r - self.l\n 15 self.xp = cuda.cupy\n 16\n 17 def __len__(self):\n 18 return self.num\n 19\n 20 def get_example(self,i):\n 21 self.ind = self.l + i\n 22 self.data = np.empty((self.flames,1,256,320),dtype=np.float32)\n 23\n 24 for j in range(self.flames):\n 25 self.bmp_name = str(int(self.rr_list[self.ind][j]))\n 26 self.year = self.bmp_name[0:4]\n 27 self.month = self.bmp_name[4:6]\n 28 self.path = '/media/denko/OS/data/bmp/' + self.year + '/' + self.month + '/' + self.bmp_name + '.bmp'\n 29 self.bmp_data = Image.open(self.path)\n 30 self.bmp_data = np.array(self.bmp_data).astype(dtype=np.float32)\n 31 self.bmp_data = self.bmp_data / 255\n 32 self.data[j,0,:,:] = self.bmp_data\n 33\n 34 self.data = Variable(np.array(self.data,dtype=np.float32))\n 35\n 36 return self.data[:self.inf,0,:,:], self.data[self.inf:self.flames,0,:,:]\n \n```\n\n問題はmetropolis氏が指摘しているように,34行目でVaribleを返しているところです.DatasetMixinは通常np.ndarrayまたはnp.ndarrayのタプルを返すことが想定されています.\n\n検証用に短いコードを示します.\n\n```\n\n 1 from chainer.dataset.convert import concat_examples\n 2 from chainer import Variable\n 3 import numpy as np\n 4\n 5 data_np_1 = np.arange(9, dtype=np.float32).reshape((3, 3))\n 6 data_np_2 = data_np_1 * 2\n 7 data_Variable_1 = Variable(data_np_1)\n 8 data_Variable_2 = Variable(data_np_2)\n 9\n 10 batch_1_np = (data_np_1[:1, :], data_np_1[1:, :])\n 11 batch_2_np = (data_np_2[:1, :], data_np_2[1:, :])\n 12\n 13 batch_1_Variable = (data_Variable_1[:1, :], data_Variable_1[1:, :])\n 14 batch_2_Variable = (data_Variable_2[:1, :], data_Variable_2[1:, :])\n 15\n 16 print(concat_examples([batch_1_np, batch_2_np]))\n 17 print(concat_examples([batch_1_Variable, batch_2_Variable]))\n 18\n \n```\n\n結果が以下のようになります.\n\n```\n\n (\n array([\n [[0., 1., 2.]],\n [[0., 2., 4.]]\n ], dtype=float32),\n array([\n [[ 3., 4., 5.], [ 6., 7., 8.]],\n [[ 6., 8., 10.], [12., 14., 16.]]\n ], dtype=float32)\n )\n \n (\n array([\n [[variable(0.), variable(1.), variable(2.)]],\n [[variable(0.), variable(2.), variable(4.)]]\n ], dtype=object),\n array([\n [[variable(3.), variable(4.), variable(5.)], [variable(6.), variable(7.), variable(8.)]],\n [[variable(6.), variable(8.), variable(10.)], [variable(12.), variable(14.), variable(16.)]]\n ], dtype=object)\n )\n \n```\n\nこのように,dtypeがobjectであるndarrayが生成されているため, \nValueError: Unsupported dtype object \nと言われるわけです.\n\nこれは`chainer.dataset.convert._concat_arrays`内で,\n\n```\n\n if not isinstance(arrays[0], numpy.ndarray) and\\\n not isinstance(arrays[0], cuda.ndarray):\n arrays = numpy.asarray(arrays)\n \n```\n\nが呼ばれており,numpy.asarrayにVariableを渡すと,返り値が通常のndarrayにならないことが原因です.\n\n以下はTipsなので,読み飛ばしていただいても結構です.\n\n`inf`はmathでInfinityを表す予約語です.使わないことが推奨されます. \n同様に`.data`属性はnumpyとcupyでメモリへのポインタを表す予約語,\nChainerでxp.ndarrayを表す予約語なので,自分では使わないことが推奨されます.(実際にはChainerではv3.0.0以降予約語から解除されていますが,これはnumpy,\ncupyとの予約語の競合を避けたためです)",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T01:22:47.620",
"id": "48711",
"last_activity_date": "2018-09-26T01:22:47.620",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29620",
"parent_id": "48693",
"post_type": "answer",
"score": 1
}
] | 48693 | null | 48711 |
{
"accepted_answer_id": "48698",
"answer_count": 2,
"body": "jQuery(3.3.1)のajaxで得たhtmlデータのhead内に対して操作をしたいです。 \n以下のようにscriptタグ内に書かれたjsを表示しようとしましたが、コンソールに何も表示されません。何が原因なのでしょうか? \n(もちろんですがドメインは一緒で他のディレクトリのページです)\n\n```\n\n $.ajax({\n type: \"GET\",\n url: targetUrl,\n timeout: 1000,\n datatype: \"html\"\n }).then(function(data){\n $(data).find('head').find('script').each(function(index, el) {\n console.log(el.text());\n });\n },function(){\n //略\n });\n \n```\n\n色々調べたのですが分からなかったので、質問させて頂きました。 \nご回答の程、よろしくお願い致します。\n\n質問しておいてアレですが、\n\n```\n\n $(data).filter('script').text();\n \n```\n\nで script 内のjsが取得できました。これでやりたいことができそうです。 \nご回答頂いた皆様、ありがとうございました。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T06:35:19.290",
"favorite_count": 0,
"id": "48694",
"last_activity_date": "2018-09-25T08:38:34.433",
"last_edit_date": "2018-09-25T08:08:59.857",
"last_editor_user_id": "30065",
"owner_user_id": "30065",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"jquery"
],
"title": "ajaxで取得したhtmlのhead内を操作したい",
"view_count": 923
} | [
{
"body": "[jQuery関数](http://api.jquery.com/jquery/#jQuery2)では次のように説明されています。\n\n> When passing in complex HTML, some browsers may not generate a DOM that\n> exactly replicates the HTML source provided. As mentioned, jQuery uses the\n> browser's `.innerHTML` property to parse the passed HTML and insert it into\n> the current document. During this process, some browsers filter out certain\n> elements such as `<html>`, `<title>`, or `<head>` elements. As a result, the\n> elements inserted may not be representative of the original string passed.\n\n`.innerHTML`を使用して解析を行うため、ブラウザーによっては`<html>`、`<title>`、`<head>`などのタグが省略されることがあるそうです。ですので、今回の用途には使えなさそうです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T07:44:52.987",
"id": "48696",
"last_activity_date": "2018-09-25T07:44:52.987",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "48694",
"post_type": "answer",
"score": 1
},
{
"body": "すでに自己解決しているようですが、一応\n\n`$.ajax` で取得したウェブページのデータ(文字列)を扱う場合は\n[DOMParser](https://developer.mozilla.org/ja/docs/Web/API/DOMParser)\nを利用する手段もあります。これを `$` でラップすれば jQuery API 群が使えるようになります。\n\n```\n\n $.ajax({\n /* 中略 */\n }).then(function(data) {\n var parser = new DOMParser();\n var doc = parser.parseFromString(data, \"text/html\"); //=> HTMLDocument\n $(doc).find('head > script').each(function(index, el) {\n console.log(el.text());\n });\n })\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T08:38:34.433",
"id": "48698",
"last_activity_date": "2018-09-25T08:38:34.433",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2391",
"parent_id": "48694",
"post_type": "answer",
"score": 0
}
] | 48694 | 48698 | 48696 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "dockerfileを使って、docker上にNEologdをインストールしようとしています。\n\n```\n\n WORKDIR /usr/local/lib/mecab/dic\n RUN git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git\n \n```\n\n上記コマンドを使いインストールして、エラーは出ずにcloningは完了するのですが、Dockerを見てみると指定したディレクトリに mecab-\nipadic-neologdのディレクトリがありません。なので後の\n\n```\n\n RUN .bin/install-mecab-ipadic-neologd -n -a\n \n```\n\nで\n\n```\n\n /bin/sh: .bin/install-mecab-ipadic-neologd: No such file or directory\n \n```\n\nというエラーが出てしまいます。こういう状況を解決された経験がある方、もしくは知識がある方アドバイス頂けませんでしょうか?\n\nmecab-NEologdの箇所のみ追記致します。\n\n```\n\n RUN yum -y install xz\n \n RUN yum -y install patch\n RUN yum -y install file\n \n WORKDIR /usr/local/lib/mecab/dic\n \n RUN git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git\n \n WORKDIR /usr/local/lib/mecab/dic/mecab-ipadic-neologd/\n \n RUN .bin/install-mecab-ipadic-neologd -n -a\n \n```\n\ncloningは下記の通り表示されているので出来ていると思うのですが。\n\n```\n\n Step 59/67 : RUN yum -y install xz\n ---> Using cache\n ---> e36c255a6c4f\n Step 60/67 : RUN yum -y install patch\n ---> Using cache\n ---> 0d508606bef7\n Step 61/67 : RUN yum -y install file\n ---> Using cache\n ---> 7d0f183a946e\n Step 62/67 : RUN echo done!\n ---> Running in 2aad4678689a\n done!\n Removing intermediate container 2aad4678689a\n ---> 1d6e5c5b2ad3\n Step 63/67 : WORKDIR /usr/local/lib/mecab/dic\n Removing intermediate container 975276dcd91e\n ---> ababd2f4b24a\n Step 64/67 : RUN git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git\n ---> Running in a4ce121470f9\n Cloning into 'mecab-ipadic-neologd'...\n Removing intermediate container a4ce121470f9\n ---> 751d96787e7d\n Step 65/67 : WORKDIR /usr/local/lib/mecab/dic/mecab-ipadic-neologd/\n Removing intermediate container 4a6c62a8abcc\n ---> 68230fdc8224\n Step 66/67 : RUN .bin/install-mecab-ipadic-neologd -n -a\n ---> Running in e4fd4d4729db\n /bin/sh: .bin/install-mecab-ipadic-neologd: No such file or directory\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T07:36:32.757",
"favorite_count": 0,
"id": "48695",
"last_activity_date": "2018-09-25T09:08:39.793",
"last_edit_date": "2018-09-25T09:08:39.793",
"last_editor_user_id": "3054",
"owner_user_id": "30201",
"post_type": "question",
"score": 0,
"tags": [
"command-line"
],
"title": "Dockerfileを使ってのgit cloneが出来ない。Using Cacheは試しています。",
"view_count": 2822
} | [] | 48695 | null | null |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "java : jdk9.01 \nos : linux Red Hat 4.8.5-11\n\nJavaのコードで他のプログラムの出力するファイルのチェックを数秒毎にチェックし、 \n存在を確認できたら次に進むというコードを書こうとしています。\n\n```\n\n int n = 0;\n boolean flag = false;\n while (flag == false) {\n TimeUnit.SECONDS.sleep(waitsec);\n flag = Files.exists(path);\n n += 1;\n if (n > limit) {\n System.out.println(\"limit over\");\n }\n }\n \n```\n\n上のような感じで書いているのですが \nところがファイルが出力されているはずなのにflagがtrueになりません。 \ntrueが帰ることもあるのですがタイミングがバラバラだったりします。 \nlsコマンドなどで自分で存在を確認すると \nそのとたんにFiles.existsでもtrueが帰ります。\n\n理由は分かりませんが、シュレディンガーの猫のような感じです。 \n自分で見つけた解決策としてはFiles.findを使えばなんとかなるのですが \nFiles.existsがなぜうまく作用しないのか理由がしりたいと考えています。\n\n原因がわかる方がいましたら、ご教授お願いします。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T08:33:07.930",
"favorite_count": 0,
"id": "48697",
"last_activity_date": "2018-09-26T12:46:09.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "29195",
"post_type": "question",
"score": 1,
"tags": [
"java",
"linux"
],
"title": "JavaのFiles.existsであるはずのファイルが確認できない",
"view_count": 3547
} | [
{
"body": "ファイル出力側のプログラムでファイル出力をフラッシュしてない場合、タイミングよっては出力がバッファリングされた状態となり、ディスクに書き込まれてないので、他のプログラムからは読めないのかもしれません。\n\nCだとfflushやfsyncなどを使って明示的に書き込みをフラッシュしてみると変化があるかもしれません。また、Javaだと、PrintWriterなどのFlushableインターフェースの実装で\nflush() を呼び出すと書き込みがフラッシュされると思います。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T10:01:26.710",
"id": "48701",
"last_activity_date": "2018-09-25T10:01:26.710",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "48697",
"post_type": "answer",
"score": 3
},
{
"body": "> ネットワークドライブ上の他のPCから出力されたファイルの監視\n\nという条件から推測すると、NFS領域を非同期モードで使用しているため、他のPCで書き出した(作成した)ファイルが同期的に見えないため、と考えます。\n\nNFSサーバのエクスポートオプションに「`sync`」を指定する、加えてNFSクライアントのマウントオプションにも「`sync`」を指定することで解消すると思います。\n\n* * *\n\nなお、OSは「RHEL4」ということですが、[Java9の動作条件](https://www.oracle.com/technetwork/java/javase/jdk9certconfig-3761018.html)によると、RHEL6以上とのことですので、Java9は見送られたほうがよいかと思います。\n\nまた、RHEL4のkernelは2.6.9ですので、inotify-java APIも動作しないかと思います。([inotify-\njavaのサイト](https://www.openhub.net/p/inotify-java)には、2.6.13以降が必要、とあるため)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T12:46:09.150",
"id": "48731",
"last_activity_date": "2018-09-26T12:46:09.150",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "20098",
"parent_id": "48697",
"post_type": "answer",
"score": 2
}
] | 48697 | null | 48701 |
{
"accepted_answer_id": "48751",
"answer_count": 1,
"body": "mysql で、リモートサーバー上の mysql から select して、その結果をローカルの mysql に insert できたらいいなと思いました。\n\n### 質問\n\n * insert into select 構文は、ホストが違う二つの mysql サーバーの間で実行できますか?",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T09:31:20.870",
"favorite_count": 0,
"id": "48699",
"last_activity_date": "2018-09-27T01:33:30.310",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"mysql"
],
"title": "mysql でリモートからローカルに insert into select したい",
"view_count": 514
} | [
{
"body": "思っているものと同じかわかりませんが、\"テーブル単位でリモートのデータをローカルに持ってくる\" ということはmysqldumpを使ってできそうです。\n\n```\n\n mysqldump -u username -p password -h remote_host --databases remote_database --tables remote_table --where=\"id=757575\" | mysql local_database -u username -p password\n \n```\n\nこちらを[参考](https://dba.stackexchange.com/questions/30586/how-to-insert-the-\nremote-table-data-into-another-table-in-my-local-computer-in-m)にしました。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T01:33:30.310",
"id": "48751",
"last_activity_date": "2018-09-27T01:33:30.310",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24823",
"parent_id": "48699",
"post_type": "answer",
"score": 1
}
] | 48699 | 48751 | 48751 |
{
"accepted_answer_id": "48727",
"answer_count": 1,
"body": "[python](/questions/tagged/python \"'python'\nのタグが付いた質問を表示\")を用いて、世界地図上と自分のアプリのデータをリンクさせたいです。\n\n例えば、ある国のある都市を世界地図上のマウスポインタ等の操作でアクセスを行い、そこの都市をクリックすれば、対応する自分のデータが出てくる。あるいは、自分のデータからその都市へとアクセスする。相互リンクを築きたいです。地図はできるだけ詳細なものがあればいいなと思っていますが、ツールとしては、[cartopy](/questions/tagged/cartopy\n\"'cartopy' のタグが付いた質問を表示\")を考えています。 \n都市と言いましても、厳密なピンポイントのアクセスでは無くて、 **大体の地域や地帯** で構いません。見たところ、`Google\nmap`のように、そこまで表示できるようには思えないからです。\n\nしかし、この[cartopy](/questions/tagged/cartopy \"'cartopy'\nのタグが付いた質問を表示\")は、科学計算用のライブラリで、気象情報等を計測する目的で作成されているようであり、[matplotlib](/questions/tagged/matplotlib\n\"'matplotlib' のタグが付いた質問を表示\")と連携されて使用されることを念頭においているようです。\n\n私のように、自分のデータと世界地図上の位置座標をリンクさせたいという目的で、使うことはできますか?\n\n[python](/questions/tagged/python \"'python'\nのタグが付いた質問を表示\")で世界地図上の様々な位置情報とアクセスできるライブラリはありませんか?また、その世界地図上にデータを埋め込むことが出来るのであれば、それを行いたいです。[cartopy](/questions/tagged/cartopy\n\"'cartopy' のタグが付いた質問を表示\")はデータを **可視化**\nする目的であって、いわゆる[userーinterface](/questions/tagged/user%ef%bd%b0interface\n\"'userーinterface' のタグが付いた質問を表示\")向きではありませんか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T12:04:52.443",
"favorite_count": 0,
"id": "48702",
"last_activity_date": "2018-09-26T10:53:29.073",
"last_edit_date": "2018-09-25T12:10:10.907",
"last_editor_user_id": "24284",
"owner_user_id": "24284",
"post_type": "question",
"score": 0,
"tags": [
"pyside"
],
"title": "自分のデータと世界地図上の情報をリンクさせるのにCartopyは適切な手段でしょうか。",
"view_count": 125
} | [
{
"body": "cartopy\nは、地図上に天気図等の画像を作成するために使うのは便利ですが、あくまで画像なのでインターラクティブな操作はできません。インターラクティブなことをするのであれば、d3.js等のJavaScriptのライブラリーを使った方が便利だと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T10:53:29.073",
"id": "48727",
"last_activity_date": "2018-09-26T10:53:29.073",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15171",
"parent_id": "48702",
"post_type": "answer",
"score": 1
}
] | 48702 | 48727 | 48727 |
{
"accepted_answer_id": "48719",
"answer_count": 1,
"body": "* [teratailでも投稿](https://teratail.com/questions/148502)してはいますが解決できておりません。 \nマルチポストとなり申し訳ないです。\n\n * 実現したいこと \nVScodeで、pythonインタープリタを追加したい。\n\n * 困っていること \nVScodeのユーザー設定で、python.pythonPath部分に、仮想環境上にあるpython環境のパスを記述しても、インタープリタを選択しようとした時に、選択肢として出てこない。\n\n * 該当ソースコード \n{ **\"python.pythonPath\":\n\"/Users/usernamexxx/xxx/.vagrant/venv/bin/python3.6\"** }\n\n * 試したこと \nターミナルから、仮想環境に入り、\"Code\"コマンドでVScodeを起動する方法も試したが、 \n「コマンド'code'は見つかりませんでした」となった。 \nVScodeで、PATHにCodeコマンドを追加した後もうまくいかず。。。\n\n * 動作環境 \nPC: MacBookPro \nOS: High sierra \nVM: Virtual Box \n仮想環境:vagrant \nゲストOS:ubuntu16.04 \nPython3: 3.6.4\n\n* * *\n\n追記: \n実行しようとしていたのは、ゲスト上にインストールしたPythonです。 \nホスト上は `/Users/username/.pyenv/versions/3.6.4/bin/python` \nゲスト上は `/home/vagrant/work/venv/bin/python` にそれぞれインストールし直しました。 \nその後\n\n```\n\n {\"python.pythonPath\": \"/home/vagrant/work/venv/bin/python\"}\n \n```\n\nと記述したのですが、このpathでゲスト上の python ということは認識されるのでしょうか?\n\nホスト上の pythonから codeコマンドを実行すると、VScodeを起動できます。また、ゲスト上の pythonでも、hoge.py\nを実行できました。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T17:05:39.510",
"favorite_count": 0,
"id": "48705",
"last_activity_date": "2018-09-26T08:29:46.873",
"last_edit_date": "2018-09-26T07:59:43.620",
"last_editor_user_id": "3054",
"owner_user_id": "30238",
"post_type": "question",
"score": 0,
"tags": [
"python",
"python3",
"vagrant",
"vscode"
],
"title": "VSCodeで仮想マシン上のPythonを利用したい",
"view_count": 1357
} | [
{
"body": "どうも仮想マシンを利用していることで混乱があるようです。まず以下の点を確認しつつ作業すると解決に近付くかと思います。\n\n 1. 実行しようとしている `/Users/usernamexxx/xxx/.vagrant/venv/bin/python3.6` はどういった物ですか?\n\n * Mac(ホスト)上でインストールしたPython: \nもしこれであれば、Vagrantで作った仮想環境とは関係無いことになります。 \n動作環境はMac OSです。 \n紛らわしいので、インストール先はVagrantディレクトリと関係無い場所に変えた方がよいです。\n\n * Linux(ゲスト)上でインストールしたPython: \nもしこれであれば、Linux(Vagrantで作った仮想マシン)で動かさないといけません。 \nMac側から直接には実行できません。 \nMac側のファイルとして存在しているのは、ゲストとの共有ディレクトリ(ゲストのLinux側では `/vagrant/`\n以下にマウントされていると思います)にインストールしたからです。 \nこれも紛らわしいので、別の場所(ゲストの `/home/vagrant/` 以下など)にインストールした方がよいです。\n\n 2. コマンドでは正しく実行できていますか?\n\n * コマンド(端末での操作)でもうまくいっていない場合は、まずそちらから解決が必要です。\n * コマンドではうまくいっている場合は、どのようなコマンドを入力して成功しているのか、ホスト側とゲスト側の区別に注意して質問に追記すると回答者が状況を理解しやすいです。\n\n* * *\n\n### 追記: 仮想マシン上のPythonをVSCodeで使いたい場合\n\n仮想マシンで動作するLinux上のPythonをホストのMacが直接実行することはできません。 \n(同じく、ホストのMacで動作するVSCodeをゲストのLinux上で実行することもできません)\n\nこれを解決するには、リモートデバッグと言われる仕組みを導入する方法があります。 \n(参考: [「Pythonのリモートデバッグ (Visual Studio\nCode編)」](https://qiita.com/kiakiraki/items/76251798e38eee242e11)\n[「VisualStudioCodeでPythonコードのリモートデバッグ」](https://qiita.com/YukinoriManome/items/119cd490513a091e649e)) \nまた、\"Remote Interpreter\" というものも[提案されている](https://github.com/Microsoft/vscode-\npython/issues/79)ようで、これは未実装のようですが、自分の目的のみにフォーカスするなら似た物の作成は難しくないと思います。\n\n他にもVSCodeに詳しい方が拡張機能などを教えて下さるかもしれませんが、そういった物が無ければ私としては、あきらめることをお勧めします。初心者が行うにはちょっと、ややこし過ぎる事な気がします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T06:33:37.933",
"id": "48719",
"last_activity_date": "2018-09-26T08:29:46.873",
"last_edit_date": "2018-09-26T08:29:46.873",
"last_editor_user_id": "3054",
"owner_user_id": "3054",
"parent_id": "48705",
"post_type": "answer",
"score": 1
}
] | 48705 | 48719 | 48719 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "開発環境: \nWindows10 64bit \nブラウザ:GoogleChrome 69.0.3497 \nエディタ:Brackets(リリース 1.13 ビルド 1.13.0-17696) \n使用言語:HTML/CSS/Javascript/jQuery\n\n<概要> \njQueryの勉強中です。 \n「Webページの図面(丸*1、四角*2)をクリックしたら、その図面がフェードアウトしていく」という動きをさせるため、fadeOutを指定しましたが、図面をクリックしてもフェードアウトしません(何も起こりません)。どこを修正したらよいでしょうか?\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <style>\n #circle {\n width:150px;\n height:150px;\n border-radius: 50%;\n background-color:green;\n margin:10px;\n }\n .square {\n width:150px;\n height:150px;\n background-color: red;\n margin:10px;\n }\n </style>\n \n </head>\n <body>\n <!--\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\">\n </script>\n -->\n <script src=\"jquery-3.3.1.slim.min.js\"></script>\n \n <div id=\"circle\"></div>\n <div class=\"square\"></div>\n <div class=\"square\"></div>\n \n #HTML要素をクリックしたらフェードアウトさせたい\n <script type=\"text/javascript\">\n $(\"div\").click(function(){\n $(this).fadeOut();\n })\n \n </script> \n </body> \n </html>\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T20:22:24.230",
"favorite_count": 0,
"id": "48707",
"last_activity_date": "2020-07-27T14:07:15.767",
"last_edit_date": "2018-09-25T23:39:35.143",
"last_editor_user_id": "2238",
"owner_user_id": "30112",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"html",
"jquery",
"css"
],
"title": "要素(図面)をクリックしたらfadeOutさせたい",
"view_count": 157
} | [
{
"body": "エラー内容(Uncaught TypeError: $(...).fadeOut is not a\nfunction)で調べたところ、stackoverflowで似たような質問をされてる方がいました。それによれば\n「アニメーションエフェクトは\"スリム\"なjQueryだと使えないから、\"フル\"のjQueryを導入すればいい」とのことでしたので検討してみます。ひとまず解決とさせて頂きます。コメントを頂きありがとうございました。\n\n<https://stackoverflow.com/questions/934446/why-does-jquery-throw-the-error-\nfadeout-is-not-a-function>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T00:43:41.027",
"id": "48710",
"last_activity_date": "2018-09-26T00:43:41.027",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30112",
"parent_id": "48707",
"post_type": "answer",
"score": 1
}
] | 48707 | null | 48710 |
{
"accepted_answer_id": "48717",
"answer_count": 1,
"body": "vscode上でflake8とyapfが動いてくれません。 \n現在はユーザーセッティングの方に設定を書いていて、ワークスペースの設定のほうに書いても動作してくれませんでした。 \n環境は以下のとおりです。\n\n * Windows 10 Home 1803 17134.286 \n * VSCode 1.27.2\n * Python 3.5.1\n * flake8 3.5.0\n * yapf 0.24.0\n\n下記のコードで試してみましたが、だめでした。 \n設定の画像を貼りますので、ここが間違っていて、こうすると動くよというのがあれば教えていただければ幸いです。 \nよろしくおねがいします。\n\n```\n\n print('test')\n \n```\n\n[](https://i.stack.imgur.com/mT7Md.jpg)\n\n* * *\n\n解決しました。 \npycodestyleのバージョンが新しいとflake8が追従しきれなくて依存性に問題が出るそうです。 \nそこで、flake8のバージョンを上げるか、pycodestyleのバージョンを下げると問題が解決します。 \n私の場合、flake8の更新が来ていたので、更新したところ、無事に動くようになりました。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-25T23:35:32.990",
"favorite_count": 0,
"id": "48708",
"last_activity_date": "2018-09-28T11:18:49.977",
"last_edit_date": "2018-09-28T11:18:49.977",
"last_editor_user_id": "30221",
"owner_user_id": "30221",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3",
"vscode"
],
"title": "VSCodeのflake8とyapfが動いてくれない",
"view_count": 3551
} | [
{
"body": "* **可能性1** : ファイルが Python モードで開かれていないのかもしれません。よくありそうなのは言語モードが「プレーンテキスト」になっている場合です。標準ではウィンドウ右下に表示されていますので、拡張子 `.py` のファイルとして保存するなどして言語モードを Python にしてください。\n\n[](https://i.stack.imgur.com/nABbW.png)\n\n * **可能性2** : そもそも flake8 や yapf に適合したコードになっていて、何も通知が出ないのかもしれません。明らかにエラーが出る例を渡した方が分かりやすそうです。たとえばインデント幅が 4 の倍数になっていない以下のコードは flake8 が E111 \"indentation is not a multiple of four\" を出します。また yapf はこのコードのインデント幅を 4 にします。\n``` if True:\n\n pass\n \n```\n\n * **可能性3** : flake8 や yapf が VSCode 側から見つかっていないのかもしれません。`python.linting.flake8Path` や `python.formatting.yapfPath` をご確認ください。\n\n * **可能性4** : flake8 3.5.0 において、flake8 が依存している pycodestyle と依存性の問題があるようです。2018 年 9 月現在 flake8 は pycodestyle >=2.4.0 と[互換していません](https://gitlab.com/pycqa/flake8/issues/427)。これは flake8 がアップデートに追従しきれていないことが原因です。このため、新しいバージョンの pycodestyle をダウングレードする必要があります。まず、今インストールされている pycodestyle のバージョンを確認します。\n``` pip show pycodestyle\n\n \n```\n\npycodestyle のバージョンが新しすぎれば、一度アンインストールして再度バージョン指定してインストールします\n(おそらく後者を行うだけで大丈夫ですが、念の為アンインストールの手順も入れてあります)。\n\n``` pip uninstall pycodestyle\n\n pip install \"pycodestyle<2.4.0\"\n \n```",
"comment_count": 5,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T06:01:25.097",
"id": "48717",
"last_activity_date": "2018-09-27T06:24:02.667",
"last_edit_date": "2018-09-27T06:24:02.667",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "48708",
"post_type": "answer",
"score": 0
}
] | 48708 | 48717 | 48717 |
{
"accepted_answer_id": "48718",
"answer_count": 1,
"body": "vscode extension api\nを利用し、動的にサイドバーのエクスプローラの背景色変更する方法が分かりません。(extension.ts上のロジックで色変更をしたい)\n\nちなみに、静的に変える方法は、下記手段を知っています。 \n同様にプログラムで実現したいです\n\n```\n\n \"workbench.colorCustomizations\": {\n \"list.activeSelectionBackground\": \"#a02e9b\",\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T05:20:44.970",
"favorite_count": 0,
"id": "48716",
"last_activity_date": "2018-09-26T06:13:05.773",
"last_edit_date": "2018-09-26T05:29:57.480",
"last_editor_user_id": "2238",
"owner_user_id": "30241",
"post_type": "question",
"score": 2,
"tags": [
"vscode"
],
"title": "サイドバーのエクスプローラの背景色変更方法",
"view_count": 263
} | [
{
"body": "[WorkspaceConfiguration](https://code.visualstudio.com/docs/extensionAPI/vscode-\napi#WorkspaceConfiguration)クラスの`update`メソッドを用いることで、VSCodeの設定を上書きすることができます。このクラスのオブジェクトは`workspace.getConfiguration`を用いて取得できます。\n\n```\n\n // 'workbench.*'に対応するWorkspaceConfigurationオブジェクトを取得\n const config = vscode.workspace.getConfiguration('workbench')\n // 'workbench.colorCustomizations'の値を更新\n config.update('colorCustomizations', {\n // set 'list.activeSelectionBackground'\n 'list.activeSelectionBackground': '#a02e9b'\n })\n \n```\n\nただし、この方法では既存の値を考慮せずに`settings.json`を上書きしてしまうので、設定を保存したり、プロパティをマージしたり、いろいろ工夫する必要はあるかと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T06:13:05.773",
"id": "48718",
"last_activity_date": "2018-09-26T06:13:05.773",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "48716",
"post_type": "answer",
"score": 1
}
] | 48716 | 48718 | 48718 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "下記関連ですが、 \n[サイドバーのエクスプローラの背景色変更方法](https://ja.stackoverflow.com/questions/48716/%E3%82%B5%E3%82%A4%E3%83%89%E3%83%90%E3%83%BC%E3%81%AE%E3%82%A8%E3%82%AF%E3%82%B9%E3%83%97%E3%83%AD%E3%83%BC%E3%83%A9%E3%81%AE%E8%83%8C%E6%99%AF%E8%89%B2%E5%A4%89%E6%9B%B4%E6%96%B9%E6%B3%95)\n\nvscodeのサイドバーのエクスプローラ上のソースツリーにて、 \n任意のファイルの背景色だけを動的に変更したいのですが、実現方法が分かりません。 \ntypescriptのロジックイメージとしては、こんな感じです↓ \nエクスプローラ上のソースツリー内でファイルXXXを探索し、 \nファイルが存在した場合、ファイルXXXの背景色表示だけを変更する。 \n(また、凄い欲を言うと色もフェード出来れば理想です)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T07:01:43.573",
"favorite_count": 0,
"id": "48720",
"last_activity_date": "2018-09-27T02:23:42.153",
"last_edit_date": "2018-09-27T02:23:42.153",
"last_editor_user_id": "30241",
"owner_user_id": "30241",
"post_type": "question",
"score": 2,
"tags": [
"typescript",
"vscode"
],
"title": "vscodeのエクスプローラ表示で、任意のファイルの背景色だけを動的に変更する方法",
"view_count": 92
} | [] | 48720 | null | null |
{
"accepted_answer_id": "48725",
"answer_count": 1,
"body": "RxSwiftを始めて間もないため、タイトルが変でしたらご了承ください。\n\nRxSwiftのサンプルにある、Simple Validationを写経して学習していました。 \n<https://qiita.com/kzykbys/items/3bbb4fa24d30917afd05#simple-validation>\n\nその際、Observableにbind処理をし、その後disposedでDisposeBagを設定すると、textFieldに値を入れても、バリデーションの処理が行われません。\n\n変わりにdisposedをコメントアウトすると、処理が動くようになりました。\n\nRxSwiftのサンプルではdisposedを使っても動作していたため、理由がわからず困っています。 \nRxSwiftのバージョンは4.3.1です。\n\nこちらの画面を初期画面として呼び出しています。\n\nどうぞよろしくおねがいします。\n\n```\n\n import UIKit\n import RxSwift\n import RxCocoa\n \n fileprivate let minimalUsernameLength = 5\n fileprivate let minimalPasswordLength = 5\n \n class ValidationViewController: UIViewController {\n \n @IBOutlet weak var userNameTextField: UITextField!\n @IBOutlet weak var passwordTextField: UITextField!\n \n @IBOutlet weak var userNameDescriptionLabel: UILabel!\n @IBOutlet weak var passwordDescriptionLabel: UILabel!\n \n @IBOutlet weak var loginButton: UIButton!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n let disposeBag = DisposeBag()\n \n let usernameValidate = userNameTextField.rx.text.orEmpty\n .map{ text -> Bool in\n print(\"比較処理実行\")\n return text.count >= 5\n }\n .share(replay: 1)\n \n let passwordValidate = passwordTextField.rx.text.orEmpty\n .map { $0.count >= minimalPasswordLength }\n .share(replay: 1)\n \n let loginButtonValidate = Observable.combineLatest(usernameValidate, passwordValidate){ $0 && $1 }\n .share(replay: 1)\n \n usernameValidate\n .bind(to: passwordTextField.rx.isEnabled)\n //.disposed(by: disposeBag) //コメントアウトすることで比較処理が行われ、表示制御ができるようになります。\n \n usernameValidate\n .bind(to: userNameDescriptionLabel.rx.isHidden)\n //.disposed(by: disposeBag)\n \n passwordValidate\n .bind(to: passwordDescriptionLabel.rx.isHidden)\n .disposed(by: disposeBag)\n \n loginButtonValidate\n .bind(to: loginButton.rx.isEnabled)\n //.disposed(by: disposeBag)\n \n loginButton.rx.tap\n .subscribe(onNext: { [weak self] _ in self?.showAlert() })\n //.disposed(by: disposeBag)\n \n \n }\n \n func showAlert() {\n let alertView = UIAlertView(\n title: \"RxExample\",\n message: \"This is wonderful\",\n delegate: nil,\n cancelButtonTitle: \"OK\"\n )\n \n alertView.show()\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T08:34:40.373",
"favorite_count": 0,
"id": "48723",
"last_activity_date": "2019-06-29T04:39:54.577",
"last_edit_date": "2019-06-29T04:39:54.577",
"last_editor_user_id": "9008",
"owner_user_id": "13447",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"reactive-programming",
"rx-swift"
],
"title": "RxSwiftのObservableにDisposeBag処理を行うと、画面起動後の処理に反応しなくなる",
"view_count": 567
} | [
{
"body": "`let disposeBag = DisposeBag()` \nの生存期間(スコープ)が`viewDidLoad`のせいです。\n\n`DisposeBag`は`ValidationViewController`のプロパティに持たせましょう。\n\n`DisposeBag`はどのインスタンスと運命共同体(メモリ解放のタイミングを同じにするという意味合い)なのか自分で意識して必要なところに定義することが肝心です。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T10:30:09.943",
"id": "48725",
"last_activity_date": "2018-09-26T10:42:11.280",
"last_edit_date": "2018-09-26T10:42:11.280",
"last_editor_user_id": "9008",
"owner_user_id": "9008",
"parent_id": "48723",
"post_type": "answer",
"score": 3
}
] | 48723 | 48725 | 48725 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Python3.6を使用してます。 \nnp.arrayで下の配列と範囲を与えられたとき \narr[a][b][c][d] \na --1 ~ 72 \nb -- 0 ~ 11 \nc -- 0 ~ 9 \nd -- 0 ~ 4500 \nこのような形でarr1に代入したいのですが\n\narr1 = arr[全て(1-72)][12個からから1つ][全て(0 - 9][全て(0 - 4500]\n\nどうやればいいのでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T10:04:51.173",
"favorite_count": 0,
"id": "48724",
"last_activity_date": "2018-09-27T10:04:42.400",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30243",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3",
"array",
"numpy"
],
"title": "Pythonでの多次元配列の選び方",
"view_count": 126
} | [
{
"body": "NumPy では Python の添え字記法を拡張して使えるようにしており、ある軸の要素を全部取りたいときは `:` を指定すれば取ることができます。\n\n実行例:\n\n```\n\n >>> import numpy as np\n >>> arr = np.zeros((72, 12, 10, 4501))\n >>> arr.shape\n (72, 12, 10, 4501)\n >>> arr1 = arr[:, 5, :, :] # 試しに 5 番目の行を取ってきてみます\n >>> arr1.shape\n (72, 10, 4501)\n \n```\n\nより詳しい使い方については、NumPy ドキュメントの\n[Indexing](https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.indexing.html)\nに書かれています。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T04:29:07.380",
"id": "48754",
"last_activity_date": "2018-09-27T10:04:42.400",
"last_edit_date": "2018-09-27T10:04:42.400",
"last_editor_user_id": "19110",
"owner_user_id": "19110",
"parent_id": "48724",
"post_type": "answer",
"score": 2
}
] | 48724 | null | 48754 |
{
"accepted_answer_id": "48756",
"answer_count": 2,
"body": "C#でフォームボタンがクリックして条件がととのうまで処理をすすめたくないのですが、whileを使用するとフォームが固まってしまいます。いろいろネットで調べたのですがまだ解決していません。下記にコードを示します。\n\n```\n\n public partial class Form1 : Form\n {\n public int count{get; set;} = 0;\n public List<int> list = new List<int>{1,2,3,4};\n \n private void start_Click(object sender, EventArgs e){\n if(this.count == this.list.Count){\n //this.countが4になるまで処理をすすめたくない\n }\n }\n \n //this.countのインクリメントはボタンで行いたい。\n private void button2_Click(object sender, EventArgs e){\n this.count += 1;\n }\n \n }\n \n```\n\nwhileを使って条件がそろうまでループしてやればいいと思っていたのですが、whileを使うと固まってしまいます。なにか解決方法はありますでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T10:38:28.757",
"favorite_count": 0,
"id": "48726",
"last_activity_date": "2018-09-27T04:56:53.583",
"last_edit_date": "2018-09-26T11:25:37.607",
"last_editor_user_id": "26076",
"owner_user_id": "26076",
"post_type": "question",
"score": 0,
"tags": [
"c#"
],
"title": "C#でフォームボタンクリックし条件がそろうまでコードをすすめたくない。",
"view_count": 1566
} | [
{
"body": "## 自己解決しました\n\n```\n\n while(true){\n if(this.count == 4){\n break;\n }\n Application.DoEvent();\n }\n \n```\n\nwhile構文に\nApplication.DoEvent()メソッドを使用することでフォームが固まらなくなるようです。詳しい仕組みはあまり理解できていませんが、以下のサイトが参考になりました。\n\n[時間がかかる処理での「応答なし」を回避するには?](http://www.atmarkit.co.jp/ait/articles/0403/19/news088.html)",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T14:51:19.790",
"id": "48738",
"last_activity_date": "2018-09-26T14:51:19.790",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "26076",
"parent_id": "48726",
"post_type": "answer",
"score": 0
},
{
"body": "オイラ的には `DoEvent` を使ったら負けだと思っているので別の解決策を\n\n要するに `this.count==4` となれば `start_Click` できるようになれば良いわけです。ということは `start`\n(ボタンですよね?) の `Enabled` を操作すればよくて、例えば\n\n * `Form_Load` やデザイナなどで `start.Enabled=false;` にして `start` を押せない状況で起動する\n * `button2_Click` 中で `start.Enabled = (count == list.Count);` などとし、適切なタイミングで `start` を押せるようにする\n * `start_Click` では処理するだけでよい(条件成立まで押せないため)\n\nWinForm App であれ WPF App であれ、イベントハンドラの中で待つようなコードは書かないよう今から心がけてください。 UWP App\nではそもそも待ってはいけないことになっています。\n\n`DoEvent` は弊害が大きすぎてオイラは一度も実用したことないです。ダメ。ゼッタイ。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T04:56:53.583",
"id": "48756",
"last_activity_date": "2018-09-27T04:56:53.583",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "48726",
"post_type": "answer",
"score": 1
}
] | 48726 | 48756 | 48756 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[CLLocation]のデータをUserDefaultsを用いて保存しようとしたところ、UserDefaultsでは[CLLocation]をサポートしていないとのエラーが吐かれました。\n\n[CLLocation]のデータを保存する方法はどのようなものがあるでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T11:18:45.787",
"favorite_count": 0,
"id": "48728",
"last_activity_date": "2018-09-26T12:52:00.820",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30244",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode"
],
"title": "[CLLocation]のデータを永続化する方法",
"view_count": 350
} | [
{
"body": "まず、第一に認識しておいて欲しいのは「`UserDefaults`はアプリの設定画面など、少量のユーザ別設定を保存しておくことを主眼として設計された枠組」みだということです。配列の要素数が数千を超えるなど巨大な場合は、`UserDefaults`の使用は避けるべきでしょう。\n\n(残念ながら、そのお手軽さゆえに、初心者向けの入門記事等では`UserDefaults`が多用される傾向にあり、なんとある程度経験を経たプロでさえ「初心者向けの入門記事」まんまのやり方で作ったアプリをまんまApp\nStoreにあげたりしています…。アプリ全体のパフォーマンスに影響する場合もありますので、あなたが「アプリ開発初心者」を卒業している場合は、是非適切な方法を採用するようにしてください。)\n\n* * *\n\nまずは`UserDefaults`に保存可能なデータ型のおさらいから。\n\n##\n[UserDefaults](https://developer.apple.com/documentation/foundation/userdefaults)\n\n> A default object must be a property list—that is, an instance of (or for\n> collections, a combination of instances of) `NSData`, \n> `NSString`, `NSNumber`, `NSDate`, `NSArray`, or `NSDictionary`. If you \n> want to store any other type of object, you should typically archive \n> it to create an instance of `NSData`.\n>\n> (節約) \n> `UserDefaults`用のオブジェクトはプロパティリストでなければいけません。それはつまり`NSData`, `NSString`,\n> `NSNumber`, `NSDate`, `NSArray`, または \n>\n> `NSDictionary`のインスタンス(または、コレクション型の場合、インスタンスの組み合わせ)のいずれかです。他の型のオブジェクトを保存したいなら、アーカイブして`NSData`のインスタンスを作成するのが一般的です。\n\nSwiftなら、`Data`, `String`, 組み込みの数値型及び`Bool`, `Date`, `Array`,\n`Dictionary`(`Array`と`Dictionary`なら要素、キー、値もこのいずれか)にあたります。(通称「plist互換」と言ったりします。)`CLLocation`は、このいずれでもない(plist互換ではない)ので、そのままでは`UserDefaults`には保存出来ません。\n\n* * *\n\nこのようなデータを保存する場合、以下のような方法が考えられます。\n\n 1. (`UserDefaults`のドキュメントにあるように)アーカイブして`Data`に変換してから`UserDefaults`に登録する。\n\n 2. ファイルに直接保存する。(ファイルの中身は要はバイト列なので、上記の「アーカイブして`Data`に変換」はこの場合にも使われる。)\n\n 3. Core Dataを使う。\n\n 4. RealmなどのサードパーティライブラリやSQLiteなどを直接使う。\n\n* * *\n\nと言うわけで、3.,\n4.の方法は単純な配列を保存するには大げさすぎる割にメリットが少ないので、以下では(2.への応用も利く)1.のやり方を説明しておきます。\n\n今、現在Swiftでの主流のアーカイブ(他言語ならシリアライズ、なんて言ったりもします)方法は、`Codable`プロトコルを使う(新しい、Swiftネイティブな型でないと使いにくい)ものと、Objective-\nC時代から続く`NSCoding`プロトコルを使う(古い、`NSObject`の子孫クラスでないと使えない)ものの大きく2つがあります。(探せば他にもありますが。)\n\n[`CLLocation`は`NSCoding`を継承した`NSSecureCoding`プロトコルが実装されている](https://developer.apple.com/documentation/corelocation/cllocation)ので、後者の方が簡単です。\n\n* * *\n\nでは、`[CLLocation]`から`Data`を作って`UserDefaults`に保存するコードから。\n\n```\n\n var locations: [CLLocation] = []\n //`locations`に値を入れる\n //...\n let locationData = NSKeyedArchiver.archivedData(withRootObject: locations)\n UserDefaults.standard.set(locationData, forKey: \"locationData\")\n \n```\n\n`Data`に変換するのが1行、`UserDefaults`に入れるのが1行とシンプルです。\n\n(`UserDefaults`に入れる代わりにファイルに保存するのもそう難しくはありません。)\n\n* * *\n\n`UserDefaults`から`Data`を取得してそれを元の`[CLLocation]`に復元するコード。\n\n```\n\n if\n let locationData = UserDefaults.standard.data(forKey: \"locationData\"),\n let locations = NSKeyedUnarchiver.unarchiveObject(with: locationData) as? [CLLocation]\n {\n print(locations)\n //`locations`を使った処理\n //...\n } else {\n print(\"NO locationData in UserDefaults\")\n //UserDefaultsにlocationDataが無い時の処理\n //...\n }\n \n```\n\nデータが`UserDefaults`に存在するかどうか、それが`[CLLocation]`に変換できるかどうかをif-\nletで判定しているで少し長くなっていますが、実質はこちらもそれぞれ1行です。\n\n* * *\n\nちょっと説明がしつこくて読みにくかったかもしれませんが、それぞれのコード、ご自身のプロジェクトに組み込むなどしてお試しください。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T12:52:00.820",
"id": "48732",
"last_activity_date": "2018-09-26T12:52:00.820",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13972",
"parent_id": "48728",
"post_type": "answer",
"score": 1
}
] | 48728 | null | 48732 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "JSONデータの仕様書を書く場合、どのようなフォーマットやツールを使って仕様書を書くことが一般的なのでしょうか? \nできれば、サンプルのJSONファイルから、ある程度仕様書の雛形を自動生成できるツールを教えてもらえると嬉しいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T11:27:31.040",
"favorite_count": 0,
"id": "48729",
"last_activity_date": "2018-09-26T13:46:30.100",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "22748",
"post_type": "question",
"score": 1,
"tags": [
"json"
],
"title": "JSONデータの仕様書を書く方法とツール",
"view_count": 6962
} | [
{
"body": "JSONの仕様を定めるものとして「 **JSON Schema**\n」が有名です。これはJSONが満たすべき条件(何とかというフィールドは文字列が入っていなければいけないとか)を記述することができるフォーマットで、JSON\nSchema自体もJSONで記述されます。\n\nJSON\nSchema自体もJSONで記述することになるため、人間が読んで理解するためのものというよりは機械が読むものという位置づけとなり、お求めの「仕様書」とは少し違うかもしれません。一応、人間が読めるようなドキュメントをJSON\nSchemaから生成しようという試みも存在するようです([参考1](https://groups.google.com/forum/#!topic/json-\nschema/PWfDH0ibS4c),[参考2](https://github.com/gratex/schema2doc))。\n\n入力されたJSONがJSON Schemaに合致するかどうかを検査できるライブラリも存在します。「JSON Schema\ngenerator」などの検索ワードで調べればJSON SchemaをJSONのサンプルから生成するツールも発見できます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T13:03:47.877",
"id": "48733",
"last_activity_date": "2018-09-26T13:46:30.100",
"last_edit_date": "2018-09-26T13:46:30.100",
"last_editor_user_id": "30079",
"owner_user_id": "30079",
"parent_id": "48729",
"post_type": "answer",
"score": 2
}
] | 48729 | null | 48733 |
{
"accepted_answer_id": "48753",
"answer_count": 1,
"body": "pip-licenses --from-classifierでライセンス一覧を表示したところ、 \nfeedparserパッケージがOSI Approved ライセンスと表示されていました。\n\nfeedparser 5.2.1 OSI Approved\n\nこのパッケージをインポートで参照しているアプリをMITライセンスで配布しても大丈夫でしょうか。 \n配布する際はこのライセンスを表記する必要があるのでしょうか。\n\nネットで調べても有力な情報が見つからずに困っております。 \nどなたかご存知の方はいらっしゃらないでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T14:18:52.273",
"favorite_count": 0,
"id": "48735",
"last_activity_date": "2018-09-27T04:21:22.577",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30138",
"post_type": "question",
"score": 1,
"tags": [
"python",
"ライセンス"
],
"title": "OSI Approved ライセンスについて",
"view_count": 1195
} | [
{
"body": "※ 注意: 私は法律の専門家ではないので、この回答の厳密な正確性は保証できません。内容は必ずご自身でも確認するようにしてください。\n\n* * *\n\nまず OSI-approved License とは Open Source Initiative (OSI)\nという団体によって承認されたライセンスの集合を示す言葉であり、特定のライセンスひとつを指しているものではありません\n([参考1](https://ja.wikipedia.org/wiki/Open_Source_Initiative#%E3%83%A9%E3%82%A4%E3%82%BB%E3%83%B3%E3%82%B9%E3%83%AC%E3%83%93%E3%83%A5%E3%83%BC)、[2](https://ja.osdn.net/projects/opensource/wiki/licenses)、[3](https://opensource.org/licenses))。\n\nさて、では feedparser はどのようなライセンスを持っているのでしょうか? pip が表示する情報だけだと分からないので、[feedparser\nのソースコード・リポジトリ](https://github.com/kurtmckee/feedparser)を見てみます。LICENSE\nというファイルに詳しいライセンス情報が書かれています。2018 年 9\n月現在、このライセンスは何か名前のついた有名なライセンスではなく、特に以下のように書かれています。\n\n> * Redistributions in binary form must reproduce the above copyright\n> notice, \n> this list of conditions and the following disclaimer in the documentation \n> and/or other materials provided with the distribution.\n>\n\nしたがって、バイナリとして配布する限りは、LICENSE\nファイルの内容を併記する形にすれば大丈夫そうです。ただし正確なところは著作者に対して確認が必要かもしれません。\n\nなお feedparser のライセンスが \"OSI Approved\" と表示されているのは [`setup.py`\nにそう書いてある](https://github.com/kurtmckee/feedparser/blob/2b11c8028321ed43cbaf313f83b0c94820143d66/setup.py#L21)からだと思われますが、OSI\nが公開している[承認済みライセンス一覧](https://opensource.org/licenses/alphabetical)には\nfeedparser のライセンスが載っていないように見えます。このあたり正確なことは問い合わせが必要かもしれません。",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T04:21:22.577",
"id": "48753",
"last_activity_date": "2018-09-27T04:21:22.577",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "48735",
"post_type": "answer",
"score": 2
}
] | 48735 | 48753 | 48753 |
{
"accepted_answer_id": "48740",
"answer_count": 2,
"body": "JavaScriptの関数の引数名を取得することはできるのでしょうか?\n\n```\n\n function my_func(foo, bar) {\n return foo * bar\n }\n \n```\n\n上のような`my_func`関数があったとして、\n\n```\n\n my_func.args_name // [\"foo\", \"bar\"]\n \n```\n\nこの`args_name`のように引数の名前を配列などで取ることはできないのでしょうか?\n\n正規表現を使えばできなくはないのですが、デフォルト引数などを使ったりするとさらに複雑になってしまうのでなるべく避けたいです。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T14:40:40.063",
"favorite_count": 0,
"id": "48736",
"last_activity_date": "2018-09-26T15:29:46.120",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5246",
"post_type": "question",
"score": 3,
"tags": [
"javascript"
],
"title": "JavaScriptの関数の引数名を取得する",
"view_count": 740
} | [
{
"body": "参考としてですが、質問で言った正規表現での方法を載せておきます。 \nただし、この方法では関数にデフォルト値を設定するとうまく動かなくなります。\n\n```\n\n function my_func(foo, bar) {\r\n return foo * bar\r\n }\r\n \r\n let func_str = String(my_func);\r\n let arg_names = /\\((.+)\\)/.exec(func_str)[1].split(\",\"); // [\"foo\", \"bar\"]\r\n console.log(arg_names);\n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T14:47:24.613",
"id": "48737",
"last_activity_date": "2018-09-26T14:47:24.613",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5246",
"parent_id": "48736",
"post_type": "answer",
"score": 1
},
{
"body": "残念ながら、関数の引数名を取得する簡単な方法は用意されていません。\n\n質問者さんのおっしゃるように関数を文字列に変換してそこから情報を取得するしかありませんが、正規表現では確かにデフォルト値があるときに太刀打ちするのが難しくなります。\n\nそれを乗り越える一つの方法は、例えば[acorn](https://github.com/acornjs/acorn)のような\n**JavaScriptパーサー** を用いて、関数を表す文字列を再度構文解析して関数の情報を得ることです。\n\nとりあえずacornを使って関数の引数名を取得するコードは以下のとおりです。\n\n```\n\n const acorn = require('acorn');\n \n function my_func(foo, bar = 3, baz, {hoge}) {\n return foo * bar;\n } \n \n // my_funcを文字列化する\n const my_func_str = my_func.toString();\n \n // acorn.parseで構文解析する\n const parsed = acorn.parse(my_func_str);\n \n // 正しくパースされていることを確認\n console.assert(parsed.type === 'Program');\n \n // 関数宣言が認識されていることを確認\n const funcDecl = parsed.body[0];\n console.assert(funcDecl.type === 'FunctionDeclaration');\n \n // 一応名前が合っている確認\n console.assert(funcDecl.id.name === 'my_func');\n \n // 引数の名前の配列を作成\n const argNames = funcDecl.params.map(mapArgToName);\n \n console.log(argNames); // ['foo', 'bar', 'baz', 'no name']\n \n // 関数引数のオブジェクトを関数名にマップする関数\n // (適当に書いたので処理漏れがあるかもしれません)\n function mapArgToName(argObject) {\n switch (argObject.type) {\n case 'Identifier': {\n return argObject.name;\n }\n case 'AssignmentPattern': {\n return mapArgToName(argObject.left);\n }\n }\n return 'no name';\n } \n \n```\n\nこれで一応目的のことは可能かと思いますが、ソースコードをいちいち構文解析するのは決して軽い処理ではありません。本当にこんなことをしてまで関数の引数名を取得する必要があるのかはよく考えたほうがよいかと思います。\n\n* * *\n\n余談ですが、JavaScriptの引数においては「引数名」は必ず存在するとは限りません。例えば以下の関数の第一引数は名前がありません。上の例ではこれは`'no\nname'`にしています。\n\n```\n\n function func({foo, bar}) { return foo * bar; }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T15:18:34.187",
"id": "48740",
"last_activity_date": "2018-09-26T15:29:46.120",
"last_edit_date": "2018-09-26T15:29:46.120",
"last_editor_user_id": "30079",
"owner_user_id": "30079",
"parent_id": "48736",
"post_type": "answer",
"score": 3
}
] | 48736 | 48740 | 48740 |
{
"accepted_answer_id": "48831",
"answer_count": 1,
"body": "CentOS7にcudaを入れると、Xが立ち上がらなくなります。 \ncudaのインストールまでは成功します。\n\n原因と対処法をご存知の方、ご教授お願いします。\n\n環境 \nOS: CentOS Linux release 7.5.1804 (Core) \nCPU: Intel i5 2.8GHz (8th gen) \nGPU: NVIDIA Geforce 1070 \nGPUのドライバ: nouveauではなく、NDIVIAのものを使用 \ncuda 10(本来はver.9を入れたい)\n\n### 追記\n\nKnoppixを使って、/var/log/Xorg.0.log を取ることが出来ました。 \nコンソールからstart x を実行しています。 \n以下の通り、Segmentation fault が発生しています。\n\n```\n\n [ 41.821] (II) Loading sub module \"fb\"\n [ 41.821] (II) LoadModule: \"fb\"\n [ 41.845] (II) Loading /usr/lib64/xorg/modules/libfb.so\n [ 41.858] (II) Module fb: vendor=\"X.Org Foundation\"\n [ 41.858] compiled for 1.19.5, module version = 1.0.0\n [ 41.858] ABI class: X.Org ANSI C Emulation, version 0.4\n [ 41.858] (II) Loading sub module \"wfb\"\n [ 41.858] (II) LoadModule: \"wfb\"\n [ 41.859] (II) Loading /usr/lib64/xorg/modules/libwfb.so\n [ 41.864] (II) Module wfb: vendor=\"X.Org Foundation\"\n [ 41.864] compiled for 1.19.5, module version = 1.0.0\n [ 41.864] ABI class: X.Org ANSI C Emulation, version 0.4\n [ 41.864] (II) Loading sub module \"ramdac\"\n [ 41.864] (II) LoadModule: \"ramdac\"\n [ 41.864] (II) Module \"ramdac\" already built-in\n [ 41.880] (**) NVIDIA(0): Depth 24, (--) framebuffer bpp 32\n [ 41.880] (==) NVIDIA(0): RGB weight 888\n [ 41.880] (==) NVIDIA(0): Default visual is TrueColor\n [ 41.880] (==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)\n [ 41.881] (**) NVIDIA(0): Enabling 2D acceleration\n [ 41.899] (EE) \n [ 41.899] (EE) Backtrace:\n [ 41.899] (EE) 0: /usr/bin/X (xorg_backtrace+0x55) [0x56458cd0a135]\n [ 41.899] (EE) 1: /usr/bin/X (0x56458cb5c000+0x1b1ec9) [0x56458cd0dec9]\n [ 41.899] (EE) 2: /lib64/libpthread.so.0 (0x7f1d21e19000+0xf6d0) [0x7f1d21e286d0]\n [ 41.899] (EE) \n [ 41.899] (EE) Segmentation fault at address 0x0\n [ 41.899] (EE) \n Fatal server error:\n [ 41.899] (EE) Caught signal 11 (Segmentation fault). Server aborting\n [ 41.899] (EE) \n [ 41.899] (EE) \n Please consult the The X.Org Foundation support \n at http://wiki.x.org\n for help. \n [ 41.899] (EE) Please also check the log file at \"/var/log/Xorg.0.log\" for additional information.\n [ 41.899] (EE) \n [ 41.900] (EE) Server terminated with error (1). Closing log file.\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T15:17:41.547",
"favorite_count": 0,
"id": "48739",
"last_activity_date": "2018-12-26T01:03:19.153",
"last_edit_date": "2018-12-25T10:55:18.083",
"last_editor_user_id": "76",
"owner_user_id": null,
"post_type": "question",
"score": 2,
"tags": [
"linux",
"centos",
"cuda",
"gpu"
],
"title": "CentOS 7にcudaを入れるとXが立ち上がらなくなる",
"view_count": 1066
} | [
{
"body": "解決しました。 \nNVIDIA Developer Forums で海外の方とやり取りをして、 \nアドバイスをいただきました。 \n日本語での記録を残しておくために、ポイントを書きます。\n\n* * *\n\ncudaインストールの際、先にGeForceのドライバを入れてから、 \ncuda-toolkitを入れていたのですが、 \ncuda-toolkitにはドライバが含まれるため、ドライバが二重に入った状態でした。 \nしかも、バージョンの不整合により、Segentation Faultが起こっていたものと \n思われます。 \n正しくは、ドライバを入れずに、cuda-toolkitを入れる、ということでした。 \nこの方法で、正しく起動しました。 \n初歩的なミスでした。\n\nこのミスを発見するにあたりroot で \nnvidia-bug-report.sh\n\nを実行することで得られる \nnvidia-bug-report.log.gz\n\nが役に立ちました。 \n以上",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-29T15:03:36.483",
"id": "48831",
"last_activity_date": "2018-09-29T15:03:36.483",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "48739",
"post_type": "answer",
"score": 2
}
] | 48739 | 48831 | 48831 |
{
"accepted_answer_id": "48757",
"answer_count": 1,
"body": "# 環境\n\n * pip 18.0\n * Python 3.6.6\n * Anaconda 3.5.2\n * Windows10\n\n# 背景\n\n私のホームディレクトリには、`.netrc`ファイルを配置しています。これは、Gitコマンドなどを使ったとき、ユーザID、パスワードを省略するためです。 \n先日、以下のように`.netrc`ファイルのフォーマットが間違っていたため、`pip install`時に「UnicodeDecodeError:\n'cp932' codec can't decode byte 0x82 in position 56: illegal multibyte\nsequence」というエラーが発生しました。\n\n```\n\n machine example.com\n login xxxxxx\n password yyyyyy\n \n あ\n \n```\n\n上記のエラーから、`pip install`では`.netrc`を参照することが分かりました。 \nまた、以下のイシューからも`.netrc`を参照することが分かります。 \n<https://github.com/pypa/pip/issues/3569>\n\nしかし、pipのドキュメントにnetrcについては記載されていませんでした。 \n<https://pip.pypa.io/en/stable/#>\n\n# 質問\n\n## `.netrc`を参照する理由\n\n単純な興味なのですが、`pip install`時に`.netrc`を参照するのは、どういった理由でしょうか? \n`pip install`時にユーザIDとパスワードが必要である状況が分からないので、なぜ`.netrc`を参照するのかが疑問です。 \nまた、pipのドキュメントにnetrcについて言及していないのも気になります。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T16:20:45.610",
"favorite_count": 0,
"id": "48741",
"last_activity_date": "2018-09-27T05:47:36.270",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19524",
"post_type": "question",
"score": 8,
"tags": [
"python",
"pip"
],
"title": "pip installコマンドが.netrcファイルを参照する理由",
"view_count": 1532
} | [
{
"body": "まず pip の\n[NEWS.rst](https://github.com/pypa/pip/blob/f0ab8dfe5fcf7274efc8aaa118f4b4650c03689e/NEWS.rst#L425)\nを見ると、pip 9.0.0 (2016-11-02) において `.netrc` からクレデンシャル情報を読み取る機能が追加されたと書かれています。これは\npip の [Issue #3569](https://github.com/pypa/pip/issues/3569) で要望され、[Pull\nRequest #3715](https://github.com/pypa/pip/pull/3715) で実装されています。ただし Pull\nRequest の内容を見るに、このバージョン以前から .netrc を読み取る機構自体は依存ライブラリである [requests\nに存在し](https://github.com/requests/requests/commit/79bb9ee1417afe2231972c1331308500104e5dc7)、この\nPull Request から pip でも使うようになったようです。\n\n用途に関してですが、[`pip\ninstall`](https://pip.pypa.io/en/stable/reference/pip_install/) は URI\nからインストールすることもできるので、プライベートなリポジトリからインストールする場合にはクレデンシャル情報が必要そうです。私はやったことがありませんが、実際\n[\"Is it possible to use pip to install a package from a private github\nrepository?\"](https://stackoverflow.com/a/39519547/5989200) によると .netrc\nを使えるようです。\n\nドキュメントに書かれていない点は先の Issue #3569\nで[指摘されています](https://github.com/pypa/pip/issues/3569#issuecomment-324047840)が、現状反応が無いので解決されていない既知の問題に見えます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T05:47:36.270",
"id": "48757",
"last_activity_date": "2018-09-27T05:47:36.270",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "48741",
"post_type": "answer",
"score": 7
}
] | 48741 | 48757 | 48757 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "python3.6環境下で以下の.csvファイルを出力しました。これをカンマ(`,`)区切りの.csvファイルに変換したいのですがうまくいきません。zepp.csv\nの一行1列目の要素には `a b c d e f` が格納されており、区切りが空白なのです。これらをカンマ区切りで `a, b, c, d, e, f`\nに訂正するアルゴリズムを各成分に対して適用するコードが書きたいです。以下に試してみたコードを並べます。\n\n```\n\n import csv\n with open(zepp.csv, 'w') as f:\n writer = csv.writer(f, delimiter=',')\n \n```\n\npandasも使用したのですが思い通りに動きませんでした。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T16:37:04.310",
"favorite_count": 0,
"id": "48742",
"last_activity_date": "2018-09-27T00:40:32.247",
"last_edit_date": "2018-09-27T00:40:32.247",
"last_editor_user_id": "3060",
"owner_user_id": "29315",
"post_type": "question",
"score": 3,
"tags": [
"python",
"python3",
"pandas",
"csv"
],
"title": ".txtファイルを.csvファイルに変換したい",
"view_count": 6798
} | [
{
"body": "`writer`オブジェクトを生成しただけで、ファイルに書き込む処理が無いですね。\n\n例外処理などを省略していますが(=ファイルが存在しない場合や半角スペース区切りではない場合を考慮していませんが)、以下のようなコードでいいと思います。\n\n```\n\n import csv\n import os\n \n os.rename('zepp.csv', 'backup_zepp.csv')\n with open('backup_zepp.csv') as fin, open('zepp.csv', 'w') as fout:\n o=csv.writer(fout)\n for line in fin:\n o.writerow(line.split())\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T17:48:39.713",
"id": "48743",
"last_activity_date": "2018-09-26T17:54:06.313",
"last_edit_date": "2018-09-26T17:54:06.313",
"last_editor_user_id": "21092",
"owner_user_id": "21092",
"parent_id": "48742",
"post_type": "answer",
"score": 6
},
{
"body": "元のTXTファイルにヘッダ行が無く、CSVファイルにもヘッダ行・Index列が共に必要無いと仮定すると、 **pandas** では\n\n```\n\n import pandas as pd\n df = pd.read_table('zepp.txt', header=None, delim_whitespace=True)\n df.to_csv('zepp.csv', index=False, header=False)\n \n```\n\nで良いかと思います",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T23:31:44.063",
"id": "48744",
"last_activity_date": "2018-09-26T23:31:44.063",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "24801",
"parent_id": "48742",
"post_type": "answer",
"score": 6
}
] | 48742 | null | 48743 |
{
"accepted_answer_id": "48748",
"answer_count": 1,
"body": "DDDでエンティティをORM(例えばPHPのLaravel(Eloquent))を利用して永続化する際、リポジトリの実装の中でエンティティをORM固有のオブジェクトに詰め替える必要があるように思うのですが、つまりエンティティにはgetterが必須ということになるのでしょうか?\n\n```\n\n function persist($itemEntity) {\n $item = new Item(); // ORMのオブジェクト\n \n $item->id = $itemEntity->getId()->value();\n $item->name = $itemEntity->getName()->value();\n \n $item->save();\n }\n \n```\n\nPHPでDDDの実装サンプルを見ると皆このようになっています。 \nが、IDDD本のサンプルコードを見る限り永続化メソッドにgetterは登場していないように見えます。(但しJavaはよく分かっていないのでコードの意味が理解出来ていないだけかもしれません。)\n\nViewに渡すようなクエリ系はCQSのクエリサービス+DTOの構造にして、getterの役割はDTO側に実装しつつ、コマンド側に徹するエンティティからはgetterを取り除いてより閉じた状態にしたいと考えたのですが。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-26T23:57:10.363",
"favorite_count": 0,
"id": "48745",
"last_activity_date": "2018-09-27T00:51:15.800",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "28206",
"post_type": "question",
"score": 1,
"tags": [
"ドメイン駆動設計"
],
"title": "ドメイン駆動設計のエンティティにgetterは必須でしょうか",
"view_count": 841
} | [
{
"body": "getterは必須ではありません。 \nちょっと手間ですが、私は「リポジトリでカプセル化を破るためのインタフェース」を使うことがよくあります。 \n※多分何かのデザインパターンとして名前があったと思いますが、分からないです\n\nPHPが分からないのでJavaで書きます。\n\n```\n\n // Hogeエンティティ\n // ドメインモデルなので当然ドメインレイヤーに配置\n public class Hoge {\n // IDはずっと変化しない\n // ドメイン上ではgetterが不要だが、永続化の際に取り出せる必要がある\n private final int id;\n \n // 名前は変更することがある\n private String name;\n \n public Hoge(int id, String name) {\n this.id = id;\n this.name = name;\n }\n \n public String name() {\n return this.name;\n }\n \n public void rename(String newName) {\n this.name = newName;\n }\n \n public void deencapsulate(HogeDeencapsulator deencap) {\n deencap.setId(this.id);\n deencap.setName(this.name);\n }\n }\n \n // Hogeのカプセル化を破るためのインタフェース\n // これはドメインレイヤーに配置\n public interface HogeDeencapsulator {\n void setId();\n void setName();\n }\n \n // HogeDeencapsulatorの実装クラス\n // これはリポジトリの実装と同じインフラレイヤーに配置\n public class HogeDeencapsulatorImpl implements HogeDeencapsulator{\n private int id;\n private String name;\n \n public int getId() {\n return this.id;\n }\n \n @Override\n public void setId(int id) {\n this.id = id;\n }\n \n public String getName() {\n return this.name;\n }\n \n @Override\n public void setName(String name) {\n this.name = name;\n }\n }\n \n```\n\nここまで用意すれば、リポジトリの実装では次のようにしてHogeのidを取り出せます。\n\n```\n\n public void save(Hoge hoge) {\n HogeDeencapsulatorImpl hogeDeencap = new HogeDeencapsulatorImpl();\n hoge.deencapsulate(hogeDeencap);\n \n int id = hogeDeencap.getId();\n String name = hogeDeencap.getName();\n ...\n }\n \n```\n\nどうしてもカプセル化を維持したい場合に使ってます。 \n列挙型(enum)を持ってるけど、ドメインとしてのインタフェースは「isなんちゃら」のメソッドしか公開したくない場合とかも。 \n面倒なときは普通にgetter付けちゃいますが。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T00:51:15.800",
"id": "48748",
"last_activity_date": "2018-09-27T00:51:15.800",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8078",
"parent_id": "48745",
"post_type": "answer",
"score": 0
}
] | 48745 | 48748 | 48748 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "現在、JavaでSQL\nServerにJDBCドライバ経由でアクセスし情報を取得するプログラムを作成しており、初回のDB接続時にエラーが発生し、接続に失敗する現象が発生しています。(発生頻度は毎回ではなく、2週間に1回程度です(回数にして500回に1回程度))\n\nどの点に着目すれば良いか、ご教授いただけないでしょうか。 \n(仮想環境のネットワークカードのバグなどあるのでしょうか。。。)\n\n環境は以下になります。 \nOS:Windows Server 2016 \nDB:SQL Server 2016 \nJDBCドライバ:sqljdbc41.jar \nJava:1.7.0_67 \nVMWareの仮想環境上で動作させています。\n\n以下にエラー内容を抜粋します。\n\n```\n\n java.lang.Exception: java.lang.Error: IP Helper Library GetAdaptersAddresses function failed\n \n Caused by: java.lang.Error: IP Helper Library GetAdaptersAddresses function failed\n at java.net.NetworkInterface.getAll(Native Method)\n at java.net.NetworkInterface.getNetworkInterfaces(Unknown Source)\n at sun.security.provider.SeedGenerator.addNetworkAdapterInfo(Unknown Source)\n at sun.security.provider.SeedGenerator.access$000(Unknown Source)\n at sun.security.provider.SeedGenerator$1.run(Unknown Source)\n at sun.security.provider.SeedGenerator$1.run(Unknown Source)\n at java.security.AccessController.doPrivileged(Native Method)\n at sun.security.provider.SeedGenerator.getSystemEntropy(Unknown Source)\n at sun.security.provider.SecureRandom$SeederHolder.<clinit>(Unknown Source)\n at sun.security.provider.SecureRandom.engineNextBytes(Unknown Source)\n at java.security.SecureRandom.nextBytes(Unknown Source)\n at java.util.UUID.randomUUID(Unknown Source)\n at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1317)\n at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:993)\n at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:829)\n at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)\n at java.sql.DriverManager.getConnection(Unknown Source)\n at java.sql.DriverManager.getConnection(Unknown Source)\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T00:22:03.990",
"favorite_count": 0,
"id": "48746",
"last_activity_date": "2018-09-27T01:07:29.313",
"last_edit_date": "2018-09-27T01:07:29.313",
"last_editor_user_id": "21092",
"owner_user_id": "30247",
"post_type": "question",
"score": 0,
"tags": [
"java",
"network"
],
"title": "JDBCドライバでDBサーバ接続時にネットワーク情報の取得エラーが発生する",
"view_count": 801
} | [] | 48746 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "pythonのパッケージのpycriptoをpip installしようとすると、以下のエラーの表示がでて最後まで実行できません。\n\nwindows10 python3.6 anaconda導入済み msVS2017インストール済み です。\n\nネットで調べてはみたのですが解決しませんでした。 \n何かいい解決策はありませんか?よろしくお願いします。(******はユーザー名です)\n\n```\n\n C:\\Users\\******>pip install pycrypto\n Collecting pycrypto\n Using cached https://files.pythonhosted.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz\n Installing collected packages: pycrypto\n Running setup.py install for pycrypto ... error\n Complete output from command c:\\users\\******\\desktop\\python36\\python.exe -u -c \"import setuptools, tokenize;__file__='C:\\\\Users\\\\******\\\\AppData\\\\Local\\\\Temp\\\\pip-install-dlelcucn\\\\pycrypto\\\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record C:\\Users\\******\\AppData\\Local\\Temp\\pip-record-4drr4pk1\\install-record.txt --single-version-externally-managed --compile:\n running install\n running build\n running build_py\n creating build\n creating build\\lib.win-amd64-3.6\n creating build\\lib.win-amd64-3.6\\Crypto\n copying lib\\Crypto\\pct_warnings.py -> build\\lib.win-amd64-3.6\\Crypto\n copying lib\\Crypto\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\n creating build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\hashalgo.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\HMAC.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\MD2.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\MD4.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\MD5.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\RIPEMD.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\SHA.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\SHA224.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\SHA256.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\SHA384.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\SHA512.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n copying lib\\Crypto\\Hash\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\Hash\n creating build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\AES.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\ARC2.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\ARC4.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\blockalgo.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\Blowfish.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\CAST.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\DES.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\DES3.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\PKCS1_OAEP.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\PKCS1_v1_5.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\XOR.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n copying lib\\Crypto\\Cipher\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\Cipher\n creating build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\asn1.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\Counter.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\number.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\py3compat.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\randpool.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\RFC1751.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\winrandom.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\_number_new.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n copying lib\\Crypto\\Util\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\Util\n creating build\\lib.win-amd64-3.6\\Crypto\\Random\n copying lib\\Crypto\\Random\\random.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\n copying lib\\Crypto\\Random\\_UserFriendlyRNG.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\n copying lib\\Crypto\\Random\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\n creating build\\lib.win-amd64-3.6\\Crypto\\Random\\Fortuna\n copying lib\\Crypto\\Random\\Fortuna\\FortunaAccumulator.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\Fortuna\n copying lib\\Crypto\\Random\\Fortuna\\FortunaGenerator.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\Fortuna\n copying lib\\Crypto\\Random\\Fortuna\\SHAd256.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\Fortuna\n copying lib\\Crypto\\Random\\Fortuna\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\Fortuna\n creating build\\lib.win-amd64-3.6\\Crypto\\Random\\OSRNG\n copying lib\\Crypto\\Random\\OSRNG\\fallback.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\OSRNG\n copying lib\\Crypto\\Random\\OSRNG\\nt.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\OSRNG\n copying lib\\Crypto\\Random\\OSRNG\\posix.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\OSRNG\n copying lib\\Crypto\\Random\\OSRNG\\rng_base.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\OSRNG\n copying lib\\Crypto\\Random\\OSRNG\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\Random\\OSRNG\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\n copying lib\\Crypto\\SelfTest\\st_common.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\n copying lib\\Crypto\\SelfTest\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\common.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_AES.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_ARC2.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_ARC4.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_Blowfish.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_CAST.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_DES.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_DES3.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_pkcs1_15.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_pkcs1_oaep.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\test_XOR.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n copying lib\\Crypto\\SelfTest\\Cipher\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Cipher\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\common.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_HMAC.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_MD2.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_MD4.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_MD5.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_RIPEMD.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_SHA.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_SHA224.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_SHA256.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_SHA384.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\test_SHA512.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n copying lib\\Crypto\\SelfTest\\Hash\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Hash\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Protocol\n copying lib\\Crypto\\SelfTest\\Protocol\\test_AllOrNothing.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Protocol\n copying lib\\Crypto\\SelfTest\\Protocol\\test_chaffing.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Protocol\n copying lib\\Crypto\\SelfTest\\Protocol\\test_KDF.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Protocol\n copying lib\\Crypto\\SelfTest\\Protocol\\test_rfc1751.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Protocol\n copying lib\\Crypto\\SelfTest\\Protocol\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Protocol\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\PublicKey\n copying lib\\Crypto\\SelfTest\\PublicKey\\test_DSA.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\PublicKey\n copying lib\\Crypto\\SelfTest\\PublicKey\\test_ElGamal.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\PublicKey\n copying lib\\Crypto\\SelfTest\\PublicKey\\test_importKey.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\PublicKey\n copying lib\\Crypto\\SelfTest\\PublicKey\\test_RSA.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\PublicKey\n copying lib\\Crypto\\SelfTest\\PublicKey\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\PublicKey\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\n copying lib\\Crypto\\SelfTest\\Random\\test_random.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\n copying lib\\Crypto\\SelfTest\\Random\\test_rpoolcompat.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\n copying lib\\Crypto\\SelfTest\\Random\\test__UserFriendlyRNG.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\n copying lib\\Crypto\\SelfTest\\Random\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\Fortuna\n copying lib\\Crypto\\SelfTest\\Random\\Fortuna\\test_FortunaAccumulator.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\Fortuna\n copying lib\\Crypto\\SelfTest\\Random\\Fortuna\\test_FortunaGenerator.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\Fortuna\n copying lib\\Crypto\\SelfTest\\Random\\Fortuna\\test_SHAd256.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\Fortuna\n copying lib\\Crypto\\SelfTest\\Random\\Fortuna\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\Fortuna\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\OSRNG\n copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_fallback.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\OSRNG\n copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_generic.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\OSRNG\n copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_nt.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\OSRNG\n copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_posix.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\OSRNG\n copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\test_winrandom.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\OSRNG\n copying lib\\Crypto\\SelfTest\\Random\\OSRNG\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Random\\OSRNG\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Util\n copying lib\\Crypto\\SelfTest\\Util\\test_asn1.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Util\n copying lib\\Crypto\\SelfTest\\Util\\test_Counter.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Util\n copying lib\\Crypto\\SelfTest\\Util\\test_number.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Util\n copying lib\\Crypto\\SelfTest\\Util\\test_winrandom.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Util\n copying lib\\Crypto\\SelfTest\\Util\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Util\n creating build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Signature\n copying lib\\Crypto\\SelfTest\\Signature\\test_pkcs1_15.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Signature\n copying lib\\Crypto\\SelfTest\\Signature\\test_pkcs1_pss.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Signature\n copying lib\\Crypto\\SelfTest\\Signature\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\SelfTest\\Signature\n creating build\\lib.win-amd64-3.6\\Crypto\\Protocol\n copying lib\\Crypto\\Protocol\\AllOrNothing.py -> build\\lib.win-amd64-3.6\\Crypto\\Protocol\n copying lib\\Crypto\\Protocol\\Chaffing.py -> build\\lib.win-amd64-3.6\\Crypto\\Protocol\n copying lib\\Crypto\\Protocol\\KDF.py -> build\\lib.win-amd64-3.6\\Crypto\\Protocol\n copying lib\\Crypto\\Protocol\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\Protocol\n creating build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n copying lib\\Crypto\\PublicKey\\DSA.py -> build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n copying lib\\Crypto\\PublicKey\\ElGamal.py -> build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n copying lib\\Crypto\\PublicKey\\pubkey.py -> build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n copying lib\\Crypto\\PublicKey\\RSA.py -> build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n copying lib\\Crypto\\PublicKey\\_DSA.py -> build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n copying lib\\Crypto\\PublicKey\\_RSA.py -> build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n copying lib\\Crypto\\PublicKey\\_slowmath.py -> build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n copying lib\\Crypto\\PublicKey\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\PublicKey\n creating build\\lib.win-amd64-3.6\\Crypto\\Signature\n copying lib\\Crypto\\Signature\\PKCS1_PSS.py -> build\\lib.win-amd64-3.6\\Crypto\\Signature\n copying lib\\Crypto\\Signature\\PKCS1_v1_5.py -> build\\lib.win-amd64-3.6\\Crypto\\Signature\n copying lib\\Crypto\\Signature\\__init__.py -> build\\lib.win-amd64-3.6\\Crypto\\Signature\n Skipping optional fixer: buffer\n Skipping optional fixer: idioms\n Skipping optional fixer: set_literal\n Skipping optional fixer: ws_comma\n running build_ext\n warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.\n building 'Crypto.Random.OSRNG.winrandom' extension\n creating build\\temp.win-amd64-3.6\n creating build\\temp.win-amd64-3.6\\Release\n creating build\\temp.win-amd64-3.6\\Release\\src\n C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x64\\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -Ic:\\users\\crosby.red\\desktop\\python36\\include -Ic:\\users\\crosby.red\\desktop\\python36\\include \"-IC:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\include\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\shared\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\um\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\winrt\" \"-IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\cppwinrt\" /Tcsrc/winrand.c /Fobuild\\temp.win-amd64-3.6\\Release\\src/winrand.obj\n winrand.c\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(27): error C2061: 構文エラー: 識別子 'intmax_t'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(28): error C2061: 構文エラー: 識別子 'rem'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(28): error C2059: 構文エラー: ';'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(29): error C2059: 構文エラー: '}'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(31): error C2061: 構文エラー: 識別子 'imaxdiv_t'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(31): error C2059: 構文エラー: ';'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(41): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(42): error C2146: 構文エラー: ')' が、識別子 '_Number' の前に必要です。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(42): error C2061: 構文エラー: 識別子 '_Number'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(42): error C2059: 構文エラー: ';'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(43): error C2059: 構文エラー: ')'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(46): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(47): error C2146: 構文エラー: ')' が、識別子 '_Numerator' の前に必要です。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(47): error C2061: 構文エラー: 識別子 '_Numerator'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(47): error C2059: 構文エラー: ';'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(47): error C2059: 構文エラー: ','\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(49): error C2059: 構文エラー: ')'\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(51): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(57): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(64): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(70): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(77): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(83): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(90): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.17134.0\\ucrt\\inttypes.h(96): error C2143: 構文エラー: '{' が '__cdecl' の前にありません。\n error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2017\\\\BuildTools\\\\VC\\\\Tools\\\\MSVC\\\\14.15.26726\\\\bin\\\\HostX86\\\\x64\\\\cl.exe' failed with exit status 2\n \n ----------------------------------------\n Command \"c:\\users\\******\\desktop\\python36\\python.exe -u -c \"import setuptools, tokenize;__file__='C:\\\\Users\\\\******\\\\AppData\\\\Local\\\\Temp\\\\pip-install-dlelcucn\\\\pycrypto\\\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))\" install --record C:\\Users\\******\\AppData\\Local\\Temp\\pip-record-4drr4pk1\\install-record.txt --single-version-externally-managed --compile\" failed with error code 1 in C:\\Users\\******\\AppData\\Local\\Temp\\pip-install-dlelcucn\\pycrypto\\\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T01:22:42.803",
"favorite_count": 0,
"id": "48749",
"last_activity_date": "2018-09-27T03:51:56.343",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "27172",
"post_type": "question",
"score": 3,
"tags": [
"python",
"python3"
],
"title": "暗号化ライブラリのpycryptoをpipでインストールするとエラーが出る。",
"view_count": 8675
} | [
{
"body": "pycryptoの開発は終了しており、[pycryptodome](https://github.com/Legrandin/pycryptodome)への移行を推奨されているようです。\n\n> tl;dr: PyCrypto is dead. \n> Switch to PyCryptodome (GitHub: <https://github.com/Legrandin/pycryptodome>\n> PyPi: <https://pypi.python.org/pypi/pycryptodome>). \n> <https://github.com/dlitz/pycrypto/issues/238>\n\nなお、WindowsでのビルドエラーはIssueとして上がっています。(こちらでもPycryptodomeへの移行をうながされています。) \n[Windows Pycrypto Build Issues/Not Supported · Issue #25 ·\nCiscoUcs/intersight-python](https://github.com/CiscoUcs/intersight-\npython/issues/25)",
"comment_count": 3,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T01:32:21.387",
"id": "48750",
"last_activity_date": "2018-09-27T03:51:56.343",
"last_edit_date": "2018-09-27T03:51:56.343",
"last_editor_user_id": "29826",
"owner_user_id": "29826",
"parent_id": "48749",
"post_type": "answer",
"score": 2
}
] | 48749 | null | 48750 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "こんにちはJAVAの初心者です。 \n今はspring bootの勉強をしています。\n\n以下のデータを使ってthymeleafで簡単なページング機能を実装したいです。 \nインターネット上はJPAを用いてページング機能を実装する例が多くあるますが、 \n今回はJPAとDB使っていませんので、どのように簡単なページング機能を実装できますでしょうか? \nご教示お願い致します。\n\nspring boot version = 2.0.4 \nthymeleaf version = 3.0.2 \njava version = Java8\n\n```\n\n @RequestMapping(path = \"/find\", method = { RequestMethod.GET, RequestMethod.POST })\n public String find(AttendanceListForm form, Model model) {\n \n AttendanceListDetail detail1 = new AttendanceListDetail();\n detail1.setListChkBox(\"\");\n detail1.setOffice(\"1\");\n detail1.setAPayStructure(\"2\");\n detail1.setEmpNums(\"3\");\n detail1.setEmpName(\"4\");\n detail1.setAttendanceSheetRosterDays(\"5\");\n detail1.setAPaidVacations(\"6\");\n detail1.setCongratulationOrCondolenceLeave(\"7\");\n detail1.setOperationTime(\"8\");\n detail1.setOverTime(\"9\");\n detail1.setHolidayWorkTime(\"10\");\n detail1.setMoveTime(\"11\");\n detail1.setTotalWorkingTime(\"12\");\n detail1.setState(\"13\");\n \n AttendanceListDetail detail2 = new AttendanceListDetail();\n detail2.setListChkBox(\"\");\n detail2.setOffice(\"1\");\n detail2.setAPayStructure(\"2\");\n detail2.setEmpNums(\"3\");\n detail2.setEmpName(\"4\");\n detail2.setAttendanceSheetRosterDays(\"5\");\n detail2.setAPaidVacations(\"6\");\n detail2.setCongratulationOrCondolenceLeave(\"7\");\n detail2.setOperationTime(\"8\");\n detail2.setOverTime(\"9\");\n detail2.setHolidayWorkTime(\"10\");\n detail2.setMoveTime(\"11\");\n detail2.setTotalWorkingTime(\"12\");\n detail2.setState(\"13\");\n \n AttendanceListDetail detail3 = new AttendanceListDetail();\n detail3.setListChkBox(\"\");\n detail3.setOffice(\"1\");\n detail3.setAPayStructure(\"2\");\n detail3.setEmpNums(\"3\");\n detail3.setEmpName(\"4\");\n detail3.setAttendanceSheetRosterDays(\"5\");\n detail3.setAPaidVacations(\"6\");\n detail3.setCongratulationOrCondolenceLeave(\"7\");\n detail3.setOperationTime(\"8\");\n detail3.setOverTime(\"9\");\n detail3.setHolidayWorkTime(\"10\");\n detail3.setMoveTime(\"11\");\n detail3.setTotalWorkingTime(\"12\");\n detail3.setState(\"13\");\n \n AttendanceListDetail detail4 = new AttendanceListDetail();\n detail4.setListChkBox(\"\");\n detail4.setOffice(\"1\");\n detail4.setAPayStructure(\"2\");\n detail4.setEmpNums(\"3\");\n detail4.setEmpName(\"4\");\n detail4.setAttendanceSheetRosterDays(\"5\");\n detail4.setAPaidVacations(\"6\");\n detail4.setCongratulationOrCondolenceLeave(\"7\");\n detail4.setOperationTime(\"8\");\n detail4.setOverTime(\"9\");\n detail4.setHolidayWorkTime(\"10\");\n detail4.setMoveTime(\"11\");\n detail4.setTotalWorkingTime(\"12\");\n detail4.setState(\"13\");\n \n AttendanceListDetail detail5 = new AttendanceListDetail();\n detail5.setListChkBox(\"\");\n detail5.setOffice(\"1\");\n detail5.setAPayStructure(\"2\");\n detail5.setEmpNums(\"3\");\n detail5.setEmpName(\"4\");\n detail5.setAttendanceSheetRosterDays(\"5\");\n detail5.setAPaidVacations(\"6\");\n detail5.setCongratulationOrCondolenceLeave(\"7\");\n detail5.setOperationTime(\"8\");\n detail5.setOverTime(\"9\");\n detail5.setHolidayWorkTime(\"10\");\n detail5.setMoveTime(\"11\");\n detail5.setTotalWorkingTime(\"12\");\n detail5.setState(\"13\");\n \n AttendanceListDetail detail6 = new AttendanceListDetail();\n detail6.setListChkBox(\"\");\n detail6.setOffice(\"1\");\n detail6.setAPayStructure(\"2\");\n detail6.setEmpNums(\"3\");\n detail6.setEmpName(\"4\");\n detail6.setAttendanceSheetRosterDays(\"5\");\n detail6.setAPaidVacations(\"6\");\n detail6.setCongratulationOrCondolenceLeave(\"7\");\n detail6.setOperationTime(\"8\");\n detail6.setOverTime(\"9\");\n detail6.setHolidayWorkTime(\"10\");\n detail6.setMoveTime(\"11\");\n detail6.setTotalWorkingTime(\"12\");\n detail6.setState(\"13\");\n \n AttendanceListDetail detail7 = new AttendanceListDetail();\n detail7.setListChkBox(\"\");\n detail7.setOffice(\"1\");\n detail7.setAPayStructure(\"2\");\n detail7.setEmpNums(\"3\");\n detail7.setEmpName(\"4\");\n detail7.setAttendanceSheetRosterDays(\"5\");\n detail7.setAPaidVacations(\"6\");\n detail7.setCongratulationOrCondolenceLeave(\"7\");\n detail7.setOperationTime(\"8\");\n detail7.setOverTime(\"9\");\n detail7.setHolidayWorkTime(\"10\");\n detail7.setMoveTime(\"11\");\n detail7.setTotalWorkingTime(\"12\");\n detail7.setState(\"13\");\n \n AttendanceListDetail detail8 = new AttendanceListDetail();\n detail8.setListChkBox(\"\");\n detail8.setOffice(\"1\");\n detail8.setAPayStructure(\"2\");\n detail8.setEmpNums(\"3\");\n detail8.setEmpName(\"4\");\n detail8.setAttendanceSheetRosterDays(\"5\");\n detail8.setAPaidVacations(\"6\");\n detail8.setCongratulationOrCondolenceLeave(\"7\");\n detail8.setOperationTime(\"8\");\n detail8.setOverTime(\"9\");\n detail8.setHolidayWorkTime(\"10\");\n detail8.setMoveTime(\"11\");\n detail8.setTotalWorkingTime(\"12\");\n detail8.setState(\"13\");\n \n AttendanceListDetail detail9 = new AttendanceListDetail();\n detail9.setListChkBox(\"\");\n detail9.setOffice(\"1\");\n detail9.setAPayStructure(\"2\");\n detail9.setEmpNums(\"3\");\n detail9.setEmpName(\"4\");\n detail9.setAttendanceSheetRosterDays(\"5\");\n detail9.setAPaidVacations(\"6\");\n detail9.setCongratulationOrCondolenceLeave(\"7\");\n detail9.setOperationTime(\"8\");\n detail9.setOverTime(\"9\");\n detail9.setHolidayWorkTime(\"10\");\n detail9.setMoveTime(\"11\");\n detail9.setTotalWorkingTime(\"12\");\n detail9.setState(\"13\");\n \n AttendanceListDetail detail10 = new AttendanceListDetail();\n detail10.setListChkBox(\"\");\n detail10.setOffice(\"1\");\n detail10.setAPayStructure(\"2\");\n detail10.setEmpNums(\"3\");\n detail10.setEmpName(\"4\");\n detail10.setAttendanceSheetRosterDays(\"5\");\n detail10.setAPaidVacations(\"6\");\n detail10.setCongratulationOrCondolenceLeave(\"7\");\n detail10.setOperationTime(\"8\");\n detail10.setOverTime(\"9\");\n detail10.setHolidayWorkTime(\"10\");\n detail10.setMoveTime(\"11\");\n detail10.setTotalWorkingTime(\"12\");\n detail10.setState(\"13\");\n \n AttendanceListDetail detail11 = new AttendanceListDetail();\n detail11.setListChkBox(\"\");\n detail11.setOffice(\"1\");\n detail11.setAPayStructure(\"2\");\n detail11.setEmpNums(\"3\");\n detail11.setEmpName(\"4\");\n detail11.setAttendanceSheetRosterDays(\"5\");\n detail11.setAPaidVacations(\"6\");\n detail11.setCongratulationOrCondolenceLeave(\"7\");\n detail11.setOperationTime(\"8\");\n detail11.setOverTime(\"9\");\n detail11.setHolidayWorkTime(\"10\");\n detail11.setMoveTime(\"11\");\n detail11.setTotalWorkingTime(\"12\");\n detail11.setState(\"13\");\n \n AttendanceListDetail detail12 = new AttendanceListDetail();\n detail12.setListChkBox(\"\");\n detail12.setOffice(\"1\");\n detail12.setAPayStructure(\"2\");\n detail12.setEmpNums(\"3\");\n detail12.setEmpName(\"4\");\n detail12.setAttendanceSheetRosterDays(\"5\");\n detail12.setAPaidVacations(\"6\");\n detail12.setCongratulationOrCondolenceLeave(\"7\");\n detail12.setOperationTime(\"8\");\n detail12.setOverTime(\"9\");\n detail12.setHolidayWorkTime(\"10\");\n detail12.setMoveTime(\"11\");\n detail12.setTotalWorkingTime(\"12\");\n detail12.setState(\"13\");\n \n AttendanceListDetail detail13 = new AttendanceListDetail();\n detail13.setListChkBox(\"\");\n detail13.setOffice(\"1\");\n detail13.setAPayStructure(\"2\");\n detail13.setEmpNums(\"3\");\n detail13.setEmpName(\"4\");\n detail13.setAttendanceSheetRosterDays(\"5\");\n detail13.setAPaidVacations(\"6\");\n detail13.setCongratulationOrCondolenceLeave(\"7\");\n detail13.setOperationTime(\"8\");\n detail13.setOverTime(\"9\");\n detail13.setHolidayWorkTime(\"10\");\n detail13.setMoveTime(\"11\");\n detail13.setTotalWorkingTime(\"12\");\n detail13.setState(\"13\");\n \n AttendanceListDetail detail14 = new AttendanceListDetail();\n detail14.setListChkBox(\"\");\n detail14.setOffice(\"1\");\n detail14.setAPayStructure(\"2\");\n detail14.setEmpNums(\"3\");\n detail14.setEmpName(\"4\");\n detail14.setAttendanceSheetRosterDays(\"5\");\n detail14.setAPaidVacations(\"6\");\n detail14.setCongratulationOrCondolenceLeave(\"7\");\n detail14.setOperationTime(\"8\");\n detail14.setOverTime(\"9\");\n detail14.setHolidayWorkTime(\"10\");\n detail14.setMoveTime(\"11\");\n detail14.setTotalWorkingTime(\"12\");\n detail14.setState(\"13\");\n \n List<AttendanceListDetail> detailList = new ArrayList<>();\n detailList.add(detail1);\n detailList.add(detail2);\n detailList.add(detail3);\n detailList.add(detail4);\n detailList.add(detail5);\n detailList.add(detail6);\n detailList.add(detail7);\n detailList.add(detail8);\n detailList.add(detail9);\n detailList.add(detail10);\n detailList.add(detail11);\n detailList.add(detail12);\n detailList.add(detail13);\n detailList.add(detail14);\n \n form.setAttendanceListDetail(detailList);\n \n model.addAttribute(\"areaListItems\", areaListItems());\n model.addAttribute(\"salesOffice\", salesOffice());\n model.addAttribute(\"listDisplayer\", listDisplayer());\n model.addAttribute(\"attendanceListForm\", form);\n \n return \"views/attendance/attendanceList\";\n }\n \n```\n\nthymeleaf\n\n```\n\n <div class=\"container-fluid\" id=\"pager\">\n <div class=\"form-group\">\n \n <div class=\"col-xs-7\">\n <div class=\"row\">\n <div class=\"col-xs-2 text-left\">\n <label class=\"control-label\">1~30 / 100</label>\n </div>\n <div class=\"col-xs-10\">\n <div class=\"btn-group pull-left\">\n <button type=\"button\" class=\"btn btn-link\">\n <span class=\"glyphicon glyphicon-fast-backward\"></span>\n </button>\n <button type=\"button\" class=\"btn btn-link\">\n <span class=\"glyphicon glyphicon-backward\"></span>\n </button>\n <button type=\"button\" class=\"btn btn-link\">1</button>\n <button type=\"button\" class=\"btn btn-link\">2</button>\n <button type=\"button\" class=\"btn btn-link\">3</button>\n <button type=\"button\" class=\"btn btn-link\">4</button>\n <button type=\"button\" class=\"btn btn-link\">5</button>\n <button type=\"button\" class=\"btn btn-link\">\n <span class=\"glyphicon glyphicon-forward\"></span>\n </button>\n <button type=\"button\" class=\"btn btn-link\">\n <span class=\"glyphicon glyphicon-fast-forward\"></span>\n </button>\n </div>\n </div>\n </div>\n </div>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T02:22:16.300",
"favorite_count": 0,
"id": "48752",
"last_activity_date": "2018-09-27T19:28:44.827",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13007",
"post_type": "question",
"score": 0,
"tags": [
"java",
"spring",
"spring-boot",
"thymeleaf"
],
"title": "spring boot + thymeleaf JPAなしデータベースなしでページング機能を実装したいです",
"view_count": 2843
} | [
{
"body": "英語ですが、[このページ](https://www.baeldung.com/spring-thymeleaf-\npagination)が参考になると思います。GitHubにソースコードも公開されています。\n\nもしくは、[このページ](https://qiita.com/KevinFQ/items/ca68a3001bae19f92879)のJPAのリポジトリクラス(`WordRepository`)を使用する箇所を、JPAのリポジトリクラスを使用しないように変更すればいいと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T19:28:44.827",
"id": "48776",
"last_activity_date": "2018-09-27T19:28:44.827",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "21092",
"parent_id": "48752",
"post_type": "answer",
"score": 1
}
] | 48752 | null | 48776 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "chromeで動作確認したsweetalert2がIEで動きません。\n\n```\n\n <!-- Include a polyfill for ES6 Promises (optional) for IE11, UC Browser and Android browser support -->\n <script src=\"https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js\"></script>\n \n```\n\nIE対応のために上記の記述を入れたのですが、動きませんでした。 \nこれだけでは不十分ということでしょうか?",
"comment_count": 6,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T06:08:04.667",
"favorite_count": 0,
"id": "48759",
"last_activity_date": "2018-09-27T06:08:04.667",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "30061",
"post_type": "question",
"score": 0,
"tags": [
"javascript"
],
"title": "sweetalert2がIEで動かない",
"view_count": 711
} | [] | 48759 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "アンドロイドスタジオを使い始めて一週間くらいの初心者です。今回デザインエディターが表示されなくなってしまいました。デザインエディターにはこう表示されています。\n\n```\n\n design editor is unavailable until a successful build\n \n```\n\nイベントログでは\n\n```\n\n Gradle sync failed: Could not get unknown property 'exe' for object of type org.gradle.api.internal.initialization.DefaultScriptHandler.\n Consult IDE log for more details \n \n```\n\nと表示されています。\n\n```\n\n build syncにはCould not get unknown property 'exe' for object of type org.gradle.api.internal.initialization.DefaultScriptHandler.\n Open File\n \n```\n\nと表示されていて、Open\nFileをひらいたものがこちらの画像です。[](https://i.stack.imgur.com/jgtSR.jpg)\n\nデザインエディターが表示されないため困っています。 \nよろしくお願いします。",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T06:11:27.670",
"favorite_count": 0,
"id": "48760",
"last_activity_date": "2018-09-27T19:29:44.723",
"last_edit_date": "2018-09-27T19:29:44.723",
"last_editor_user_id": "21092",
"owner_user_id": "30204",
"post_type": "question",
"score": 0,
"tags": [
"android-studio"
],
"title": "AndroidStudioのデザインエディターが表示されなくなったことに関して",
"view_count": 1877
} | [
{
"body": "```\n\n exe.anko_version\n \n```\n\nを\n\n```\n\n ext.anko_version\n \n```\n\nに変更してみて下さい。Gradleの拡張プロパティの指定は`ext`ですね。\n\n[ここ](https://github.com/Kotlin/anko)に以下のように記載されています。\n\n> Make sure that you have the $anko_version settled in your gradle file at the\n> project level:\n>\n> `ext.anko_version='0.10.6'`",
"comment_count": 1,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T18:44:55.933",
"id": "48775",
"last_activity_date": "2018-09-27T18:52:16.353",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "21092",
"parent_id": "48760",
"post_type": "answer",
"score": 2
}
] | 48760 | null | 48775 |
{
"accepted_answer_id": "48774",
"answer_count": 1,
"body": "あるデータとパスワードを暗号化するプログラムを、pycryptoを使用して作っていたところ、以下のようなエラーが出ました。 \n\n```\n\n File \"C:\\Users\\******\\Desktop\\Python36\\Python教科書\\crypto-test.py\", line 51, in <module>\n enc = encrypt(password, message)\n File \"C:\\Users\\******\\Desktop\\Python36\\Python教科書\\crypto-test.py\", line 30, in encrypt\n aes = AES.new(password, mode, iv)\n File \"C:\\Users\\******\\Desktop\\Python36\\lib\\site-packages\\Crypto\\Cipher\\AES.py\", line 206, in new\n return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)\n File \"C:\\Users\\******\\Desktop\\Python36\\lib\\site-packages\\Crypto\\Cipher\\__init__.py\", line 79, in _create_cipher\n return modes[mode](factory, **kwargs)\n File \"C:\\Users\\******\\Desktop\\Python36\\lib\\site-packages\\Crypto\\Cipher\\_mode_cbc.py\", line 253, in _create_cbc_cipher\n return CbcMode(cipher_state, iv)\n File \"C:\\Users\\******\\Desktop\\Python36\\lib\\site-packages\\Crypto\\Cipher\\_mode_cbc.py\", line 96, in __init__\n c_uint8_ptr(iv),\n File \"C:\\Users\\******\\Desktop\\Python36\\lib\\site-packages\\Crypto\\Util\\_raw_api.py\", line 196, in c_uint8_ptr\n raise TypeError(\"Object type %s cannot be passed to C code\" % type(data))\n TypeError: Object type <class 'str'> cannot be passed to C code\n \n```\n\nこれはC言語かpycryptoに関することが原因なのでしょうか。ancondaをインストール済みです。\n\n元のプログラムはこちらです。\n\n```\n\n from Crypto.Cipher import AES\n import base64\n \n \n # 暗号化したいデータとパスワードを指定\n \n message = \"自分がしてほしいと思うことをヒトのもするように。\"\n password = \"xxxxxxxxxx\" # 適当なパスワードを設定\n iv = \"L3f4mlTJtCIPV9af\" # 初期化ベクトル(16文字で適当な値を設定)\n mode = AES.MODE_CBC # 暗号化モードを指定\n \n \n # 特定の長さの倍数にするため空白でデータを埋める関数\n \n def mkpad(s, size):\n s = s.encode(\"utf-8\") # UTF-8文字列をバイト列に変換する\n pad = b' ' * (size - len(s) % size) # 特定の長さの倍数にするための空白を生成\n return s + pad\n \n \n # 暗号化する\n \n def encrypt(password, data):\n # 特定の長さに調節する\n password = mkpad(password, 16) # 16の倍数にそろえる\n data = mkpad(data, 16) # バイト列に変換し16の倍数に揃える\n password = password[:16] # ちょうど16文字に揃える\n \n # 暗号化\n aes = AES.new(password, mode, iv)\n data_cipher = aes.encrypt(data)\n return base64.b64encode(data_cipher).decode(\"utf-8\")\n \n \n # 複合化する\n \n def decrypt(password, encdata):\n # パスワードの文字数を調整\n password = mkpad(password, 16) # 16の倍数に揃える\n password = password[:16] # ちょうど16文字に揃える\n \n # 複合化\n aes = AES.new(password, mode, iv)\n encdata = base64.b64decode(encdata) # 暗号化データをBASE64でデコードしてバイト列に\n data = aes.decrypt(encdata) # 複合化\n return data.decode(\"utf-8\")\n \n \n # 暗号化する\n enc = encrypt(password, message)\n \n # 複合化する\n dec = decrypt(password, enc)\n \n \n # 結果を表示する\n \n print(\"暗号化\", enc)\n print(\"複合化\", dec)\n \n```\n\n何かいい解決策があれば教えていただきたいです。お願いします。",
"comment_count": 8,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T07:59:00.177",
"favorite_count": 0,
"id": "48764",
"last_activity_date": "2022-01-30T16:47:31.613",
"last_edit_date": "2022-01-30T16:47:31.613",
"last_editor_user_id": "3060",
"owner_user_id": "27172",
"post_type": "question",
"score": 1,
"tags": [
"python",
"python3",
"pycrypto"
],
"title": "pycryptoを使ったデータの暗号化に失敗する",
"view_count": 3616
} | [
{
"body": "質問文に書かれているエラーログは、PyCrypto のものではなく PyCryptodome のものに見えます。PyCryptodome\nで動かすのであれば、そのための変更が必要です。\n\n[質問者さんによる前回の質問](https://ja.stackoverflow.com/q/48749/19110)に書かれている通り現在\nPyCrypto は非推奨であり、PyCryptodome への移行が推奨されています。どちらで書いても `import`\n文は一緒になるため同じように使えそうですが、いくつか違いがあります。\n\nAPI レベルの主な変更点は、PyCryptodome のドキュメント [\"Compatibility with\nPyCrypto\"](https://pycryptodome.readthedocs.io/en/latest/src/vs_pycrypto.html)\nに書かれています。また、[Changelog](https://pycryptodome.readthedocs.io/en/latest/src/changelog.html)\nに書かれている変更点も別に注意が必要です。\n\n更にこれ以外にも細かい変更点があるようです。たとえば metropolis\nさんが[コメントでご指摘なさっている](https://ja.stackoverflow.com/questions/48764/pycrypto%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9F%E3%83%87%E3%83%BC%E3%82%BF%E3%81%AE%E6%9A%97%E5%8F%B7%E5%8C%96%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%99%E3%82%8B#comment50687_48764)ように、`Crypto.Cipher.AES.new()`\nの引数 `iv` の受け付けるものが [\"byte\nstring\"](https://www.dlitz.net/software/pycrypto/api/current/Crypto.Cipher.AES-\nmodule.html) から [\"bytes, bytearray,\nmemoryview\"](https://pycryptodome.readthedocs.io/en/latest/src/cipher/aes.html#Crypto.Cipher.AES.new)\nに変わっています。今回のエラーはこの違いに由来するもので、`iv` に string を渡すと質問文に書かれたエラーが出ます。bytes\nにすればよいので、たとえば\n\n```\n\n iv = \"L3f4mlTJtCIPV9af\".encode('utf-8')\n \n```\n\nとすればエラーを回避できます。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T17:11:18.740",
"id": "48774",
"last_activity_date": "2018-09-27T17:11:18.740",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19110",
"parent_id": "48764",
"post_type": "answer",
"score": 2
}
] | 48764 | 48774 | 48774 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Twitter連携を行い、自動投稿を行うアプリを開発しています。\n\nアプリ自体は完成したのですが、 \nTwitter REST API で特定の文字を含む文言を投稿しようとすると、\n\n```\n\n \"code\":32,\"message\":\"Could not authenticate you.\"\n \n```\n\nというエラーとなってしまいます。 \n特定文字が含まれない文章の場合はエラーにならず、正常に投稿されます。\n\n自作アプリが異常なのかと思い、Twitterオフィシャルのtwurlを利用して投稿してみても、やはり同様のエラーとなります。\n\n今のところ、NGとなっている単語は`や^などです。\n\n具体的にエラーになるtwurlの実行時のコマンドは以下の通りです。\n\n```\n\n twurl -t -X POST -d 'status=(*´∀`)♪(o)v( ^∀^)( ^∀^)(´∇`)' /1.1/statuses/update.json\n \n```\n\nTwitterのオフィシャルドキュメントを読んでも特に文字種制限については触れられていませんし、投稿時のPOSTをトレースすると正常にURLエンコードされて送信されているように見えます。 \nTwitterのWebから上記文言を投稿すると正常に投稿できるので、NG文言ではないとは思います。 \n投稿文字列をUTF-8の\\u28\\u2A ... のように数値参照にするなどいろいろ試してみたものの、うまくいきませんでした。\n\nこちら、上記のような特殊文字でも正常に投稿される方法をご存知の方がいらっしゃたら、ご教授いただけないでしょうか?\n\n■■■追記■■■\n\nご質問いただいたので、再現環境について補足いたします。\n\n■自作アプリ \n・開発環境:Untiy2018.1.5f \n・開発言語:C# \n・再現環境:UnityEditor上、Windows、iPhone、Androidいずれの環境でも再現します \n・投稿コード抜粋(おおよその流れで実際のコードとは異なります)\n\n```\n\n WWWForm form = new WWWForm();\n form.AddField(\"status\", \"(*´∀`)♪(o)v( ^∀^)( ^∀^)(´∇`)\");\n UnityWebRequest request = UnityWebRequest.Post(\"https://api.twitter.com/1.1/statuses/update.json\", form);\n request.SetRequestHeader(\"ContentType\", \"application/x-www-form-urlencoded\");\n request.SetRequestHeader(\"Authorization\", Oauth.GenerateHeaderWithAccessToken(\"/1.1/statuses/update.json\"));\n yield return request.SendWebRequest();\n \n```\n\n■twurl \n・再現環境:CentOS release 6.6 (Final)、ruby 2.2.0p0、twurl 0.9.3 \n・LANG環境変数:ja_JP.UTF-8 \n・再現コード(最初の投稿の記載の通りです)\n\n```\n\n twurl -t -X POST -d 'status=(*´∀`)♪(o)v( ^∀^)( ^∀^)(´∇`)' /1.1/statuses/update.json\n \n```\n\ntwurlでも再現するので、自作アプリの再現環境・コードについては不要かと思っておりました。 \n失礼いたしました。\n\n他にも必要な情報がございましたらご指摘ください。",
"comment_count": 4,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T11:55:23.003",
"favorite_count": 0,
"id": "48768",
"last_activity_date": "2018-09-28T04:09:13.720",
"last_edit_date": "2018-09-28T04:09:13.720",
"last_editor_user_id": "29491",
"owner_user_id": "29491",
"post_type": "question",
"score": 2,
"tags": [
"twitter"
],
"title": "Twitter REST APIで特定の文字で投稿に失敗する",
"view_count": 281
} | [] | 48768 | null | null |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "重複の可能性ありですが質問してみます。 \nrorのまったくの初心者ですがrubyとrailsをインストール後 \n`rails new sample` とした後 \n`rails s`を入力すると以下の結果となりlocalhost:3000を表示できません。\n\n```\n\n c:\\rails>rails s\n Usage:\n rails new APP_PATH [options]\n \n Options:\n [--skip-namespace], [--no-skip-namespace] # Skip namespace (aff\n ects only isolated applications)\n -r, [--ruby=PATH] # Path to the Ruby bi\n nary of your choice\n # Default: C:/Ruby25-\n x64/bin/ruby.exe\n -m, [--template=TEMPLATE] # Path to some applic\n ation template (can be a filesystem path or URL)\n -d, [--database=DATABASE] # Preconfigure for se\n lected database (options: mysql/postgresql/sqlite3/oracle/frontbase/ibm_db/sqlse\n rver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)\n # Default: sqlite3\n [--skip-yarn], [--no-skip-yarn] # Don't use Yarn for\n managing JavaScript dependencies\n [--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemf\n ile\n -G, [--skip-git], [--no-skip-git] # Skip .gitignore fil\n e\n [--skip-keeps], [--no-skip-keeps] # Skip source control\n .keep files\n -M, [--skip-action-mailer], [--no-skip-action-mailer] # Skip Action Mailer\n files\n -O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record\n files\n [--skip-active-storage], [--no-skip-active-storage] # Skip Active Storage\n files\n -P, [--skip-puma], [--no-skip-puma] # Skip Puma related f\n iles\n -C, [--skip-action-cable], [--no-skip-action-cable] # Skip Action Cable f\n iles\n -S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets file\n s\n [--skip-spring], [--no-skip-spring] # Don't install Sprin\n g application preloader\n [--skip-listen], [--no-skip-listen] # Don't generate conf\n iguration that depends on the listen gem\n [--skip-coffee], [--no-skip-coffee] # Don't use CoffeeScr\n ipt\n -J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript fil\n es\n [--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem\n \n -T, [--skip-test], [--no-skip-test] # Skip test files\n [--skip-system-test], [--no-skip-system-test] # Skip system test fi\n les\n [--skip-bootsnap], [--no-skip-bootsnap] # Skip bootsnap gem\n [--dev], [--no-dev] # Setup the applicati\n on with Gemfile pointing to your Rails checkout\n [--edge], [--no-edge] # Setup the applicati\n on with Gemfile pointing to Rails repository\n [--rc=RC] # Path to file contai\n ning extra configuration options for rails command\n [--no-rc], [--no-no-rc] # Skip loading of ext\n ra configuration options from .railsrc file\n [--api], [--no-api] # Preconfigure smalle\n r stack for API only apps\n -B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle in\n stall\n [--webpack=WEBPACK] # Preconfigure for ap\n p-like JavaScript with Webpack (options: react/vue/angular/elm/stimulus)\n \n Runtime options:\n -f, [--force] # Overwrite files that already exist\n -p, [--pretend], [--no-pretend] # Run but do not make any changes\n -q, [--quiet], [--no-quiet] # Suppress status output\n -s, [--skip], [--no-skip] # Skip files that already exist\n \n Rails options:\n -h, [--help], [--no-help] # Show this help message and quit\n -v, [--version], [--no-version] # Show Rails version number and quit\n \n Description:\n The 'rails new' command creates a new Rails application with a default\n directory structure and configuration at the path you specify.\n \n You can specify extra command-line arguments to be used every time\n 'rails new' runs in the .railsrc configuration file in your home directory.\n \n Note that the arguments specified in the .railsrc file don't affect the\n defaults values shown above in this help message.\n \n Example:\n rails new ~/Code/Ruby/weblog\n \n This generates a skeletal Rails installation in ~/Code/Ruby/weblog.\n \n c:\\rails>cd sample\n \n c:\\rails\\sample>rails s\n Traceback (most recent call last):\n 43: from bin/rails:4:in `<main>'\n 42: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `require'\n 41: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:253:in `load_dependency'\n 40: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `block in require'\n 39: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:29:in `require'\n 38: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'\n \n 37: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/loaded_features_index.rb:65:in `register'\n 36: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_boot\n snap_lfi'\n 35: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `require'\n 34: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /commands.rb:18:in `<top (required)>'\n 33: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /command.rb:46:in `invoke'\n 32: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /command/base.rb:65:in `perform'\n 31: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:\n 387:in `dispatch'\n 30: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/inv\n ocation.rb:126:in `invoke_command'\n 29: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/com\n mand.rb:27:in `run'\n 28: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /commands/server/server_command.rb:142:in `perform'\n 27: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /commands/server/server_command.rb:142:in `tap'\n 26: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /commands/server/server_command.rb:145:in `block in perform'\n 25: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `require'\n 24: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:253:in `load_dependency'\n 23: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `block in require'\n 22: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:29:in `require'\n 21: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'\n \n 20: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/loaded_features_index.rb:65:in `register'\n 19: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_boot\n snap_lfi'\n 18: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `require'\n 17: from c:/rails/sample/config/application.rb:7:in `<top (required)>'\n 16: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler.rb:114:in `requi\n re'\n 15: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in\n `require'\n 14: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in\n `each'\n 13: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in\n `block in require'\n 12: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in\n `each'\n 11: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in\n `block (2 levels) in require'\n 10: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:29:in `require'\n 9: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'\n \n 8: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/loaded_features_index.rb:65:in `register'\n 7: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_boot\n snap_lfi'\n 6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `require'\n 5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw\n 32/lib/sqlite3.rb:2:in `<top (required)>'\n 4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw\n 32/lib/sqlite3.rb:6:in `rescue in <top (required)>'\n 3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `require'\n 2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:253:in `load_dependency'\n 1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `block in require'\n C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cac\n he/core_ext/kernel_require.rb:32:in `require': cannot load such file -- sqlite3/\n sqlite3_native (LoadError)\n \n c:\\rails\\sample>gem install sqlite3\n Successfully installed sqlite3-1.3.13-x64-mingw32\n Parsing documentation for sqlite3-1.3.13-x64-mingw32\n Done installing documentation for sqlite3 after 1 seconds\n 1 gem installed\n \n c:\\rails\\sample>rails s\n Traceback (most recent call last):\n 43: from bin/rails:4:in `<main>'\n 42: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `require'\n 41: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:253:in `load_dependency'\n 40: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `block in require'\n 39: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:29:in `require'\n 38: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'\n \n 37: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/loaded_features_index.rb:65:in `register'\n 36: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_boot\n snap_lfi'\n 35: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `require'\n 34: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /commands.rb:18:in `<top (required)>'\n 33: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /command.rb:46:in `invoke'\n 32: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /command/base.rb:65:in `perform'\n 31: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:\n 387:in `dispatch'\n 30: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/inv\n ocation.rb:126:in `invoke_command'\n 29: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/com\n mand.rb:27:in `run'\n 28: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /commands/server/server_command.rb:142:in `perform'\n 27: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /commands/server/server_command.rb:142:in `tap'\n 26: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails\n /commands/server/server_command.rb:145:in `block in perform'\n 25: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `require'\n 24: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:253:in `load_dependency'\n 23: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `block in require'\n 22: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:29:in `require'\n 21: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'\n \n 20: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/loaded_features_index.rb:65:in `register'\n 19: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_boot\n snap_lfi'\n 18: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `require'\n 17: from c:/rails/sample/config/application.rb:7:in `<top (required)>'\n 16: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler.rb:114:in `requi\n re'\n 15: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in\n `require'\n 14: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in\n `each'\n 13: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in\n `block in require'\n 12: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in\n `each'\n 11: from C:/Ruby25-x64/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in\n `block (2 levels) in require'\n 10: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:29:in `require'\n 9: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'\n \n 8: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/loaded_features_index.rb:65:in `register'\n 7: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_boot\n snap_lfi'\n 6: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/boots\n nap/load_path_cache/core_ext/kernel_require.rb:21:in `require'\n 5: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw\n 32/lib/sqlite3.rb:2:in `<top (required)>'\n 4: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.3.13-x64-mingw\n 32/lib/sqlite3.rb:6:in `rescue in <top (required)>'\n 3: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `require'\n 2: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:253:in `load_dependency'\n 1: from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/\n active_support/dependencies.rb:287:in `block in require'\n C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cac\n he/core_ext/kernel_require.rb:32:in `require': cannot load such file -- sqlite3/\n sqlite3_native (LoadError)\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-09-27T15:23:35.427",
"favorite_count": 0,
"id": "48773",
"last_activity_date": "2018-10-04T16:26:31.950",
"last_edit_date": "2018-09-27T16:24:43.353",
"last_editor_user_id": "19110",
"owner_user_id": "30259",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails"
],
"title": "rubyonrailsのプロジェクトのブラウザ表示ができません",
"view_count": 106
} | [] | 48773 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.