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": "windows10でAnacondaをインストールして、コマンドプロンプトでipython\nnotebookを起動しようとしたら、コマンドプロンプトの処理が延々と続いてしまいます。ipython notebookは起動しており使える状態なのですが。 \n何か分かる方がいれば教えてください。\n\n[![コマンドプロンプト画面](https://i.stack.imgur.com/X8vu1.png)](https://i.stack.imgur.com/X8vu1.png)", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-26T12:22:08.703", "favorite_count": 0, "id": "33553", "last_activity_date": "2020-07-24T05:49:02.593", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21204", "post_type": "question", "score": 0, "tags": [ "python", "anaconda" ], "title": "ipython notebookを起動しようとするとコマンドプロントが止まらない", "view_count": 891 }
[ { "body": "コメントで解決されたようですので、回答として編集・転記いたします。\n\n### コマンドラインオプションによる解決法\n\nログレベルが DEBUG に設定されている場合、コマンドラインでオプションスイッチに `--log-level=CRITICAL` を追加してみてください。\n\n`> ipython --log-level=CRITICAL`\n\n### 設定変更による解決法\n\n> (コマンドラインのオプションスイッチでは)毎回`--log-level=CRITICAL`と入力しないと正常に起動できません。 \n> どこかに設定を保存できないのでしょうか?\n\nまず、`ipython notebook --generate-config` を実行してみて下さい。 \n実行後、`~/.jupyter/jupyter_notebook_config.py` というファイルが作成されているかと思います。 \nこの jupyter_notebook_config.py に `c.Application.log_level = 50` を追加して下さい(50 が\nCRITICAL に相当します)。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-07-24T05:49:02.593", "id": "68885", "last_activity_date": "2020-07-24T05:49:02.593", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "33553", "post_type": "answer", "score": 1 } ]
33553
null
68885
{ "accepted_answer_id": null, "answer_count": 2, "body": "C#のApp.configについての質問です。 \nアプリを立ち上げたときに、App.configからドロップダウンリスト1のデータおよび、その他のドロップダウンリスト2のデータを読み取りたいと思っています。また、keyとそのvalueは後に使用するので、まだ実装していませんが、App.configから読み込むときに、配列もしくはリストに格納しようと考えています。\n\nApp.configにデータを追加することで、ユーザはプログラムをいじることなく、ドロップダウンリストのリストや、その他のドロップダウンリストのリストを増やせるようにしたいと考えています。 \n現在は、foreachで全てを読み込むというプログラムをしようと考えていますが、 \nそうなった際にドロップダウンリスト1に使用するデータとドロップダウンリスト2に使用するデータをどのように分けたらよいか、というのが質問です。 \n宜しくお願い致します。\n\nclass1↓\n\n```\n\n private void Form1_Load(object sender, EventArgs e)\n {\n //すべてのキーとその値を取得(本当はcomboBox1と2で分けたい)\n foreach (string key in System.Configuration.ConfigurationSettings.AppSettings.AllKeys)\n {\n //key=a,bがcomboBox1\n comboBox1.Items.Add(System.Configuration.ConfigurationSettings.AppSettings[key]);\n //配列に格納する機能未実装\n \n //key=AB,CDがcomboBox2\n comboBox2.Items.Add(System.Configuration.ConfigurationSettings.AppSettings[key]);\n //配列に格納する機能未実装\n }\n }\n \n```\n\nApp.config↓\n\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\" ?>\n <configuration>\n <startup> \n <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.5.2\" />\n </startup>\n <appSettings>\n     //リスト1\n <add key=\"a\" value=\"1\"/>\n <add key=\"b\" value=\"2\"/>\n //ユーザはここにどんどん追加\n //リスト2\n <add key=\"AB\" value=\"3\"/>\n <add key=\"CD\" value=\"4\"/>\n //ユーザはここにどんどん追加\n </appSettings>\n </configuration>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-26T15:10:29.943", "favorite_count": 0, "id": "33555", "last_activity_date": "2017-03-26T22:30:10.907", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19213", "post_type": "question", "score": 0, "tags": [ "c#", "アルゴリズム" ], "title": "C# App.configのデータ取得について", "view_count": 20520 }
[ { "body": "方針としては\n\n 1. `<appSettings>`のキー名に条件を付けて区別する\n 2. 特定の1つのキーの値にすべての値を登録する\n 3. 専用の型を用意し、XMLとしてシリアライズする\n\nなどが考えられます。\n\n1.の場合、たとえばキーの名前を`List1_a`や`List2_AB`のように変更し、`key.StartsWith(\"List1_\")`のような条件を追加します。キー名は`key.Substring(6)`で取得します。\n\n2.では値としてたとえば\n\n```\n\n <add key=\"list1\" value=\"a:1;b:2\" />\n <add key=\"list2\" value=\"AB:3;CD:4\" />\n \n```\n\nのようにすべての項目を含む文字列を設定します。上記の例では`;`と`:`が区切りですが、制御文字や解析の手間を考えると`XML`や`JSON`で格納するのが簡単だと思います。\n\n3.の場合、`<appSettings>`セクションではなく`Settings.settings`で生成される項目を使用します。 \nまずプロジェクトのプロパティから「設定」を開き、適当なキー名を2個登録します。 \n次に型を指定する必要がありますが、既定の型ではうまく行かないと思いますので適当な「クラスライブラリー」プロジェクトを別に用意し、たとえば下記のような型を作成します。\n\n```\n\n public struct Entry\n {\n [XmlAttribute]\n public string Key { get; set; }\n \n [XmlText]\n public string Value { get; set; }\n }\n public sealed class EntryCollection : Collection<Entry>\n {\n }\n \n```\n\nこのプロジェクトをビルドし、`Settings.settings`を含むプロジェクトから参照すると「設定」の「型」の「参照」から上記の型が選択できます。\n\nここまで準備ををするとC#コードから\n\n```\n\n EntryCollection entries = Settings.Default.キー1;\n if (entries != null)\n {\n foreach (Entry e in entries)\n {\n comboBox1.Items.Add(e.Value);\n }\n }\n \n```\n\nのように参照できます。`app.config`の設定値は`userSettings`または`applicationSettings`に設定すればよく、\n\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <configuration>\n <userSettings>\n <プロジェクト名.Properties.Settings>\n <setting name=\"キー1\" serializeAs=\"Xml\">\n <value>\n <ArrayOfEntry>\n <Entry Key=\"a\">1</Entry>\n <Entry Key=\"b\">2</Entry>\n </ArrayOfEntry>\n </value>\n </setting>\n <setting name=\"キー2\" serializeAs=\"Xml\">\n <value>\n <ArrayOfEntry>\n <Entry Key=\"AB\">3</Entry>\n <Entry Key=\"CD\">4</Entry>\n </ArrayOfEntry>\n </value>\n </setting>\n </プロジェクト名.Properties.Settings>\n </userSettings>\n </configuration>\n \n```\n\nのようになります。\n\n私としては`<appSettings>`の複数のキーを利用するやり方は想定外のキーが存在しうるのでお勧めできません。下の方法ほど型安全で堅実だと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-26T16:08:43.913", "id": "33556", "last_activity_date": "2017-03-26T16:08:43.913", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "33555", "post_type": "answer", "score": 1 }, { "body": "基本的にはpgrhoさんの回答の通りですが、Visual Studioには便利な機能がいくつか用意されていますので、その部分を紹介します。\n\nまず、`Entry`クラス`EntryCollection`クラスを作らなくともSettings.settingsに`System.Collections.Specialized.StringCollection`が用意されていますのでこれを使うと楽です。これによって作成されるApp.configは\n\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\" ?>\n <configuration>\n <userSettings>\n <WindowsFormsApp1.Properties.Settings>\n <setting name=\"Key1\" serializeAs=\"Xml\">\n <value>\n <ArrayOfString xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <string>1</string>\n <string>2</string>\n </ArrayOfString>\n </value>\n </setting>\n </WindowsFormsApp1.Properties.Settings>\n </userSettings>\n </configuration>\n \n```\n\nとなります(`Entry`でなく`string`になりますね)。\n\nまた、このコレクションを`ComboBox`に設定するには`DataSource`プロパティが使えます。\n\n```\n\n comboBox1.DataSource = Settings.Default.Key1;\n \n```\n\nただしApp.configに記述されていない項目も追加する場合にはこの方法は使えず、1項目ずつ`Add`していく必要があります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-26T22:30:10.907", "id": "33559", "last_activity_date": "2017-03-26T22:30:10.907", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "33555", "post_type": "answer", "score": 2 } ]
33555
null
33559
{ "accepted_answer_id": "33592", "answer_count": 1, "body": "ansible-playbook は、 inventory を指定しなかった場合でも、何かしらの設定を読み込んで、実行できていることに気が付きました。 \nこのデフォルトの設定を変更したいと考えています。\n\n### 質問:\n\nAnsible に inventory を指定しなかった場合、どこの設定から inventory 情報を読み込むのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T04:12:31.673", "favorite_count": 0, "id": "33560", "last_activity_date": "2017-03-28T00:58:32.510", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "754", "post_type": "question", "score": 0, "tags": [ "ansible" ], "title": "ansible inventory を指定しなかった場合はどこから読み込む?", "view_count": 76 }
[ { "body": "デフォルトは /etc/ansible/hosts になります。\n\n<http://docs.ansible.com/ansible/intro_inventory.html>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T00:58:32.510", "id": "33592", "last_activity_date": "2017-03-28T00:58:32.510", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21227", "parent_id": "33560", "post_type": "answer", "score": 0 } ]
33560
33592
33592
{ "accepted_answer_id": null, "answer_count": 0, "body": "Amazon EC2 Container Service(ECS)をつかって\n\n<http://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/images/application.png>\n\nのような構成をつくりたいと思っています\n\nnginx + php-fpm + mysql \nだとすると、それぞれのタスク定義を\n\n * nginxタスク\n * php-fpmタスク\n * mysqlタスク\n\nと別々につくり\n\nserviceを \n\\- front service には nginxタスク \n\\- backend service には php-fpmタスク \n\\- data service には mysqlタスク\n\nを紐付ければいいとは思うのですが、 \nここから、php-fpmからmysqlへのつなぎ方が分かりません \nどうやって紐付けられるでしょうか?\n\nタスク定義内のlinkの指定だと、同じタスク定義内のcontainerしか紐付けられなさそうでした", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T04:29:23.823", "favorite_count": 0, "id": "33561", "last_activity_date": "2017-03-27T04:29:23.823", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10253", "post_type": "question", "score": 1, "tags": [ "aws", "docker" ], "title": "Amazon EC2 Container Service(ECS)をつかってインスタンス間の接続がしたい", "view_count": 160 }
[]
33561
null
null
{ "accepted_answer_id": "33582", "answer_count": 2, "body": "ハードリンクは既存のiノードを参照するディレクトリエントリを追加する事と習いました。 \n例えば \nln foo.txt bar.txtとすると、 \nfoo.txtとbar.txtは同じiノードを参照する事になります。\n\nここでrm foo.txtとした場合、bar.txtは既存のiノードを参照している状態だと思います。\n\nさらにbar.txtを削除した場合は参照元のiノードも削除されるということで合っていますか?\n\n1つわからなかったのがiノード自体はファイルの長さ、モード、iノード番号などの情報しか持っていないようですが、foo.txtとbar.txtの中に記述されているデータはfoo.txtとbar.txtが別々で持っているということなのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T04:34:48.773", "favorite_count": 0, "id": "33562", "last_activity_date": "2017-03-28T20:33:53.587", "last_edit_date": "2017-03-28T20:33:53.587", "last_editor_user_id": "3054", "owner_user_id": "15279", "post_type": "question", "score": 4, "tags": [ "linux", "unix", "filesystems" ], "title": "inodeへの参照(ハードリンク)が無くなると、そのinodeは削除されますか?", "view_count": 1280 }
[ { "body": "> さらにbar.txtを削除した場合は参照元のiノードも削除されるということで合っていますか?\n\nはい。\n\n> 1つわからなかったのがiノード自体はファイルの長さ、モード、iノード番号などの情報しか持っていないようですが、\n\nこれはVFSでのiノードの定義のことを言っているものと思います。各ファイルシステムではVFSでの定義をもとに、データ情報などファイルシステム固有の情報を含んだiノードを定義しています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T06:19:50.810", "id": "33567", "last_activity_date": "2017-03-27T06:19:50.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4010", "parent_id": "33562", "post_type": "answer", "score": 2 }, { "body": "foo.txt と bar.txt 同じデータを参照しています。\n\n次のように考えるとイメージがつかみやすいと思います。\n\n * i-node → ファイルの実体\n * foo.txt や bar.txt → i-nodeへのリンク\n\n同じ i-node を指している 2つのハードリンクは、リンク先の実体が同じものですので、全く同じデータが参照されます。\n\nまた、i-nodeには ハードリンクの数を表すカウント情報が含まれています。 \nこの、カウントが 0 になると iノードは削除されます。(つまりファイルが削除されます)\n\nLinux で `ls -il` を実行すると i-node番号 と リンク数が表示することができます。 \n試していただくと foo.txtとbar.txtは同じ i-node番号、リンク数が表示されるはずです。\n\nまた、新たに作成したファイルは、ハードリンク数が 1 であることが確認出来ます。 \nつまり普通のファイルはカウント数 1 の ハードリンクなのです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T13:07:00.033", "id": "33582", "last_activity_date": "2017-03-27T13:07:00.033", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "33562", "post_type": "answer", "score": 4 } ]
33562
33582
33582
{ "accepted_answer_id": "33682", "answer_count": 1, "body": "<https://book.cakephp.org/3.0/ja/orm.html>\n\n<https://book.cakephp.org/3.0/ja/orm/database-basics.html#database-query-\nlogging>\n\n上記を参考にして、SQLクエリのログを出力しようとしましたが、出力されませんでした。\n\n```\n\n use Cake\\ORM\\TableRegistry;\n use Cake\\Datasource\\ConnectionManager;\n \n $connection = ConnectionManager::get('default');\n \n // クエリログを有効\n $conn->logQueries(true);\n \n $articles = TableRegistry::get('Articles');\n \n $query = $articles->find();\n \n foreach ($query as $row) {\n echo $row->title;\n }\n \n // クエリログを停止\n $conn->logQueries(false);\n \n```\n\nコネクションについてはTableクラスの \n<https://api.cakephp.org/3.4/class-Cake.ORM.Table.html#_getConnection> \nも使ってみましたが、同様に出力されませんでした。\n\n他のエラーログなどは出力されています。\n\n正しいやり方を教えていただけますでしょうか。\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T07:16:42.673", "favorite_count": 0, "id": "33569", "last_activity_date": "2017-03-31T22:43:23.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7256", "post_type": "question", "score": 0, "tags": [ "cakephp" ], "title": "cakePHP3 テーブルクラスのインスタンスからSQLクエリログを取得する方法", "view_count": 1260 }
[ { "body": "config/bootstrap.phpにログ出力の設定はありますか\n\n```\n\n Log::config('queries', [\n 'className' => 'File',\n 'path' => LOGS,\n 'file' => 'queries.log',\n 'scopes' => ['queriesLog']\n ]);\n \n```\n\nまた、Debugkitが有効になっていると出力されないようです。プラグインを一時的に無効にするか。app.phpのdebug=falseにするなどしてみてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T22:43:23.210", "id": "33682", "last_activity_date": "2017-03-31T22:43:23.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19633", "parent_id": "33569", "post_type": "answer", "score": 1 } ]
33569
33682
33682
{ "accepted_answer_id": "33576", "answer_count": 1, "body": "現在jQuery+PHPで画面を開いたときにsocket_createで接続し、成功したら以降は \nsocket_createせずにsocket_write(),socket_read()を繰り返すソースを書いています。\n\nPHPの関数はjsで3sec毎に呼び出され、phpで取得したデータを#datadisplayのidを付けた \nテーブルタブに更新するものです。(*1)\n\n本題は、呼び出されたphp内でsocket_create -> socket_write() -> socket_read() ->\nsocket_close()をしています。 \nしかし、画面を開いた際にsocket_create()し、成功したら$_SESSION('socketNo')に返り値を格納し、以後はsocket_write()\n->\nsocket_read()を繰り返し、終了時には手動操作によりsocket_close()を呼び出そうとした場合、1回目の処理には$_SESSION('socketNo')が格納されるのですが、2回目以降phpが呼び出された際に$_SESSION('socketNo')の値が0になってしまい、socket_write(),socket_read()の処理でエラーが戻ってきてしまいます。(*2)\n\nsocket_create()の返り値を$_SESSION('socketNo')に入れて保管するのはできないのでしょうか?\n\nわかりにくい文になってしまい、申し訳ございませんが、よろしくお願い致します。\n\n以下、一部略している箇所がありますが、該当箇所のコードを添付します。\n\n(*1)------------------------------------------------------\n\n```\n\n function displayData()\n {\n $(\"#datadisplay\").load(\"dispData.php\").fadeIn(\"normal\");\n }\n $.get(\"dispData.php\",{},displayData);\n \n function autoRefresh(interval){\n autoloader = setInterval(displayData,interval);\n }\n autoRefresh(3000);\n \n```\n\n(*2)------------------------------------------------------\n\n```\n\n <?php\n \n session_start();\n \n // tcp socket client\n function connect($sendCmd, $ver)\n {\n global $sysVer, $recvBuf;\n \n   $socket = $_SESSION['socketNo'];\n \n ChromePhp::log('sendCmd'.$sendCmd);\n ChromePhp::log('log : connectFlg : '.$_SESSION['connectFlg']);\n ChromePhp::log('log : socketNo : '.$socket); // <==== 接続後の値が0になる\n \n if( $_SESSION['connectFlg'] == 0 ) {\n \n ChromePhp::log('connect to server : start');\n \n $server = '127.0.0.1';\n $port = 1000;\n $headLen = 8;\n \n // ソケット接続(TCP/IP)\n if(!($socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)))\n {\n $errorcode = socket_last_error();\n $errormsg = socket_strerror($errorcode);\n \n die(\"Couldn't create socket: [$errorcode] $errormsg \\n\");\n }\n \n \n if(!($result = socket_connect($socket, $server, $port)))\n {\n $errorcode = socket_last_error();\n $errormsg = socket_strerror($errorcode);\n \n die(\"Couldn't connect socket: [$errorcode] $errormsg \\n\");\n }\n \n $_SESSION['connectFlg'] = 1;\n ChromePhp::log('connect to server : success'.$_SESSION['connectFlg']);\n \n $_SESSION['socketNo'] = $socket;\n \n }\n \n $socket = $_SESSION['socketNo'];\n ChromePhp::log('get data');\n \n //get data\n $in = pack('s*', $sendCmd, 0, 0, 0);\n socket_write($socket, $in, strlen($in));\n \n $buf = socket_read($socket, $headLen);\n $out = unpack('s*', $buf);\n $dataSize = $out[4];\n \n $buf = socket_read($socket, $dataSize);\n $recvBuf = $buf;\n \n }\n \n ?> \n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T07:19:20.590", "favorite_count": 0, "id": "33570", "last_activity_date": "2017-03-27T11:55:25.723", "last_edit_date": "2017-03-27T11:55:25.723", "last_editor_user_id": "8000", "owner_user_id": "21215", "post_type": "question", "score": 0, "tags": [ "php", "jquery" ], "title": "socket_createの返り値を$_SESSIONに入れたときの保存期間", "view_count": 112 }
[ { "body": "socket_createメソッドの返り値はresource型です。 \n<http://php.net/manual/ja/function.socket-create.php>\n\nPHPの以下のマニュアルに、resource型はセッションに保存できないとあります。 \n<http://php.net/manual/ja/intro.session.php>\n\n> 警告 \n> セッションデータはシリアライズされるので、 resource 型の変数はセッションに格納できません。 \n> シリアライズハンドラ (php および php_binary) は、register_globals の制約を引き継いでいます。\n> そのため、数値のインデックスや特殊文字 (| や !) を含む文字列のインデックスは使えません。\n> これらを使っていると、スクリプトのシャットダウン時にエラーが発生します。 php_serialize には、そのような制約はありません。\n> php_serialize は PHP 5.5.4 以降で使えます。\n\nこのため、セッションへの登録に失敗しているのではないかと思います。 \nいかがでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T11:09:34.743", "id": "33576", "last_activity_date": "2017-03-27T11:09:34.743", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17014", "parent_id": "33570", "post_type": "answer", "score": 1 } ]
33570
33576
33576
{ "accepted_answer_id": null, "answer_count": 0, "body": "はじめまして\n\n最近、会社でRailsの案件を受け持ったのですが、 \n自宅でRailsを起動するときにはbundle exec rails sとコマンド入力してサーバを立ち上げると \n\"localhost:3000\"でアプリケーションにアクセスできます。\n\nただ、会社ではbundle exec rails s -b 0.0.0.0とコマンド入力してサーバを立ち上げて、 \n\"[http://(自分のIPアドレス):3000/](http://\\(%E8%87%AA%E5%88%86%E3%81%AEIP%E3%82%A2%E3%83%89%E3%83%AC%E3%82%B9\\):3000/)\"\nにアクセスして開発を行っています。\n\nというのも、会社ではlocalhost:3000にはアクセスができずにLAN内に公開している状態なのですが、どうしてlocalhostにアクセスできないのでしょうか?\n\n考えられる原因などありましたら教えていただけると助かります。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T08:48:11.833", "favorite_count": 0, "id": "33571", "last_activity_date": "2017-03-27T08:57:26.803", "last_edit_date": "2017-03-27T08:57:26.803", "last_editor_user_id": "20774", "owner_user_id": "20774", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails" ], "title": "railsの起動オプションについて(localhostにアクセスできない)", "view_count": 334 }
[]
33571
null
null
{ "accepted_answer_id": "33577", "answer_count": 1, "body": "DropzoneJs を使ってファイルをアップロードさせるプログラムを作成しています。 \nDropzoneにサーバー内に既にあるファイルを表示させる方法は、以下のサイトを参考にできました。\n\n<https://www.startutorial.com/articles/view/dropzonejs-php-how-to-display-\nexisting-files-on-server>\n\n```\n\n <script>\n <!-- 3 -->\n Dropzone.options.myDropzone = {\n init: function() {\n thisDropzone = this;\n <!-- 4 -->\n $.get('upload.php', function(data) {\n <!-- 5 -->\n $.each(data, function(key,value){\n var mockFile = { name: value.name, size: value.size };\n thisDropzone.options.addedfile.call(thisDropzone, mockFile);\n thisDropzone.options.thumbnail.call(thisDropzone, mockFile, \"uploads/\"+value.name);\n });\n });\n }\n };\n </script>\n \n```\n\nしかし、上記方法では、サムネイルが元ファイルを縮小表示しただけのため、読み込みに時間が掛かってしまいます。\n\nそこで、既存のファイルは、サイズを縮小したサムネイルを表示させたいと思い、 \n以下のページを見つけました。 \n[How to show files already stored on\nserver](https://github.com/enyo/dropzone/wiki/FAQ)\n\n上記ページを見ると、以下のような感じで書いています。\n\n```\n\n // Create the mock file:\n var mockFile = { name: \"Filename\", size: 12345 };\n \n // Call the default addedfile event handler\n myDropzone.emit(\"addedfile\", mockFile);\n \n // And optionally show the thumbnail of the file:\n myDropzone.emit(\"thumbnail\", mockFile, \"/image/url\");\n // Or if the file on your server is not yet in the right\n // size, you can let Dropzone download and resize it\n // callback and crossOrigin are optional.\n myDropzone.createThumbnailFromUrl(file, imageUrl, callback, crossOrigin);\n \n```\n\n上記ページを参考にすればいいと思うのですが、 \n上記ページと最初のページとでは書き方が違っているため、 \n組み合わせる方法がわかりません。 \n(そもそも、myDropzone.emit がどのような動きをするのかが理解できていません。)\n\nどうすればファイルのサムネイルを表示させることができるのでしょうか?\n\nどなたか教えていただければ助かります。 \nどうぞよろしくお願い致します。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T09:04:39.853", "favorite_count": 0, "id": "33572", "last_activity_date": "2017-03-28T00:51:31.890", "last_edit_date": "2017-03-28T00:51:31.890", "last_editor_user_id": "18800", "owner_user_id": "18800", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "DropzoneJs + PHP: サムネイルの表示方法について", "view_count": 1485 }
[ { "body": "`addedfile` や `thumbnail` というのは dropzone.js におけるイベントでして、\n\n * DOMやjQueryのように、`addEventListener()` と `on()` でイベントハンドラを登録\n * `emit()` でイベントを発火(登録されたイベントハンドラを全て実行)\n\nすることができます。\n\ndropzone.js では(デフォルトのものを含め)イベントハンドラが `options`\nオブジェクトの中に書かれており、初期化する際にこれらのイベントハンドラを `on()`\nで[登録しています](https://github.com/enyo/dropzone/blob/v4.3.0/src/dropzone.coffee#L655-L65)。ですから大抵は\n`options.addedfile.call()` と `emit(\"addedfile\", ...)` のどちらを使っても同じですが、\n`addEventListener()` や `on()`\nでイベントハンドラを追加しているとそれが呼ばれるかどうかが変わってきます。[公式のFAQ](https://github.com/enyo/dropzone/wiki/FAQ#how-\nto-show-files-already-stored-on-server)でも `emit()` が使われていますし、こちらの方が行儀はよいです。\n\n公式FAQに書かれている点も盛り込んで、最終的に次のような形になります。\n\n```\n\n $.each(data, function(key,value){\n var mockFile = { name: value.name, size: value.size };\n thisDropzone.emit(\"addedfile\", mockFile);\n // thisDropzone.emit(\"thumbnail\", mockFile, \"uploads/\" + value.name);\n thisDropzone.createThumbnailFromUrl(mockFile, \"uploads/\" + value.name);\n // アップロード完了処理(プログレスバーの非表示など)を呼び出す\n thisDropzone.emit(\"complete\", mockFile);\n \n });\n // もし maxFiles オプションを使っていれば、手動で減らしておく\n // thisDropzone.options.maxFiles -= data.length;\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T11:31:41.540", "id": "33577", "last_activity_date": "2017-03-27T11:31:41.540", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "33572", "post_type": "answer", "score": 1 } ]
33572
33577
33577
{ "accepted_answer_id": "35042", "answer_count": 2, "body": "バージョンはLaravel5.4です。 \n下記の様な形でテーブルに値をインサートしたいのですが、行が上書きされているのか、最後の値しかインサートできません. \nEloquent ORMでこのような処理を書く方法は無いでしょうか? \nまた、それが無理な場合、どのように記述するのが適切でしょうか.\n\n```\n\n <?php\n \n namespace App\\Models;\n \n use Illuminate\\Database\\Eloquent\\Model;\n \n class Image extends Model\n {\n protected $table = 'pictures';\n protected $primaryKey = 'id';\n \n public function storeUrls($urls)\n {\n foreach ($urls as $url) {\n $this->user_id = 'test';\n $this->url = $url;\n $this->save();\n }\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T09:12:19.797", "favorite_count": 0, "id": "33573", "last_activity_date": "2020-01-09T23:01:20.173", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "18697", "post_type": "question", "score": 1, "tags": [ "laravel" ], "title": "Laravelでの一括インサート", "view_count": 4900 }
[ { "body": "Eloquent::insert() がいいかもしれないです。 \n例:\n\n```\n\n $data = array(\n array('name'=>'Coder 1', 'rep'=>'4096'),\n array('name'=>'Coder 2', 'rep'=>'2048'),\n //...\n );\n \n User::insert($data);\n \n```\n\nAUTOINCREMENTがある場合は下記も参考までに。\n\n```\n\n $id = DB::table('users')->insertGetId(\n ['email' => '[email protected]', 'votes' => 0]\n );\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T07:04:40.963", "id": "33602", "last_activity_date": "2017-03-28T07:04:40.963", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21211", "parent_id": "33573", "post_type": "answer", "score": 0 }, { "body": "インスタンスを作ってあげると解決できます。 \n\n```\n\n namespace App\\Models;\n \n use Illuminate\\Database\\Eloquent\\Model;\n \n class Image extends Model\n {\n protected $table = 'pictures';\n protected $primaryKey = 'id';\n \n public function storeUrls($urls)\n {\n foreach ($urls as $url) {\n $image = new static();\n $image->user_id = 'test';\n $image->url = $url;\n $image->save();\n }\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-05-26T10:54:59.130", "id": "35042", "last_activity_date": "2017-05-26T10:54:59.130", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13404", "parent_id": "33573", "post_type": "answer", "score": 0 } ]
33573
35042
33602
{ "accepted_answer_id": "33575", "answer_count": 1, "body": "# 前提\n\ndjango1.10を使っています。 \npython3.5.1でやっています。\n\n# やりたいこと\n\ndjango1.10では、_meta.get_field_by_nameが使えなくなったのですが、 \n_meta.get_field_by_nameと同じことができるものってあるんですか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T09:23:31.153", "favorite_count": 0, "id": "33574", "last_activity_date": "2017-05-01T00:32:47.867", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "21218", "post_type": "question", "score": 0, "tags": [ "django", "python3" ], "title": "django1.10の_meta.get_field_by_nameについて", "view_count": 303 }
[ { "body": "django 1.10の[Model `_meta`\nAPIについてのドキュメント](https://docs.djangoproject.com/ja/1.10/ref/models/meta/)によると、`Options.get_field(name)`か`Options.get_fields()`を使って書き換えられる、とのことです。\n\n具体的に`_meta.get_field_by_name(name)`についてどうすればよいかも書いてあったので (まだ英語のままですが) 引用します。\n\n> Assuming you have a model named `MyModel`, the following substitutions can\n> be made to convert your code to the new API:\n>\n> (中略)\n>\n> * `MyModel._meta.get_field_by_name(name)` returns a tuple of these four \n> values with the following replacements:\n> * `field` can be found by `MyModel._meta.get_field(name)`\n> * `model` can be found through the `model` attribute on the field.\n> * `direct` can be found by: `not field.auto_created or field.concrete` \n> The `auto_created` check excludes all “forward” and “reverse” relations\n> that are created by Django, but this also includes `AutoField` and\n> `OneToOneField` on proxy models. We avoid filtering out these attributes\n> using the `concrete` attribute.\n> * `m2m` can be found through the `many_to_many` attribute on the field.\n>\n\nただし、新しいAPIを使う形にリファクタリングする方が良いだろう、とも書いてあります。 \nより詳しくはドキュメントを参考にしてください。\n\n * [Model `_meta` API](https://docs.djangoproject.com/ja/1.10/ref/models/meta/) \\-- Django 1.10 Documentation (ja)", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T09:52:02.150", "id": "33575", "last_activity_date": "2017-05-01T00:32:47.867", "last_edit_date": "2017-05-01T00:32:47.867", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "33574", "post_type": "answer", "score": 1 } ]
33574
33575
33575
{ "accepted_answer_id": null, "answer_count": 1, "body": "練習でスタートボタンを押すと、3,2,1でじゃんけんが出るように書いたのですがエラーが出ます。`Uncaught SyntaxError: missing\n) after argument\nlist`がでていろいろ試したのですが解決しませんでした。根本的におかしなことをしているかもわかりませんがご教示お願いいたします。\n\n```\n\n <script>\n \"use strict\";\n \n var gyanken =[\"✊\",\"✌\",\"✋\"];\n var i=3;\n document.getElementById(\"start\").getElementById(\"moniter\").addEventListener(\"click\", function(){ function show(){\n moniter.innerHTML=(i--);\n var time = setTimeout(function() {\n show();\n }, 1000);\n if(i<0){\n clearTimeout(time);\n // start.addEventListener(\"click\", function(){\n var result = Math.floor(Math.random()*3);\n moniter.innerHTML= gyanken[result];\n }}}\n show();)\n </script>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T11:47:35.833", "favorite_count": 0, "id": "33578", "last_activity_date": "2017-03-28T04:45:54.453", "last_edit_date": "2017-03-27T11:59:49.377", "last_editor_user_id": null, "owner_user_id": "21220", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "JSの練習でスタートボタンを押すと、3,2,1でじゃんけんが出るように書いたのですがエラーが出ます。", "view_count": 1253 }
[ { "body": "インデントをかけて整形すれば見やすくなってミスに気づくかもしれないです。\n\n```\n\n <script>\n \"use strict\";\n \n var gyanken =[\"✊\",\"✌\",\"✋\"];\n var i=3;\n document.getElementById(\"start\").getElementById(\"moniter\").addEventListener(\n \"click\", \n function(){\n function show(){\n moniter.innerHTML=(i--);\n var time = setTimeout(\n function() {show();}, \n 1000\n );\n if(i<0){\n clearTimeout(time);\n // start.addEventListener(\"click\", function(){\n var result = Math.floor(Math.random()*3);\n moniter.innerHTML= gyanken[result];\n }\n }\n }\n show();\n );\n </script>\n \n```\n\n`addEventListerner`の引数がおかしいのに気づきましたでしょうか? \n`Uncaught SyntaxError`:基本的のこのエラーは構文エラーの際に表示されます。 \n`missing ) after argument list`:引数リストの後ろに`)`閉じが無いって怒られてます\n\n気になる点はありますが、とりあえずイベントに食わせている無名関数内で \n関数宣言と実行を行えば動くのではないでしょうか?\n\n```\n\n document.getElementById(\"start\").getElementById(\"moniter\").addEventListener(\n \"click\", \n function(){\n function show(){\n moniter.innerHTML=(i--);\n var time = setTimeout(\n function() {show();}, \n 1000\n );\n if(i<0){\n clearTimeout(time);\n // start.addEventListener(\"click\", function(){\n var result = Math.floor(Math.random()*3);\n moniter.innerHTML= gyanken[result];\n }\n }\n show();\n }\n );\n \n```\n\n* * *\n\n動作するコードを追記しました。参考にしてください。\n\n```\n\n //グローバル変数\r\n var gyanken =[\"✊\",\"✌\",\"✋\"];\r\n var sec=3;\r\n var time = null;\r\n \r\n //クリックイベントをバインド(onloadなど初期化関数に入れても良い)\r\n document.getElementById(\"monitor\").addEventListener(\r\n \"click\", \r\n function(){\r\n //クリック時初期化\r\n sec=3;\r\n if(null!=time){ clearTimeout(time); }\r\n time=null;\r\n //表示開始\r\n show(); \r\n }\r\n );\r\n \r\n /**\r\n * 表示処理関数\r\n */\r\n function show(){\r\n //再起処理の最後にムダ処理するのでIFで切り分け\r\n if(0<=--sec){\r\n //表示更新\r\n monitor.innerHTML=sec+1;\r\n //1秒後再起\r\n time = setTimeout(\r\n function() {show();}, \r\n 1000\r\n );\r\n }else{\r\n //タイマーが存在した場合、破棄\r\n if(null!=time){ clearTimeout(time); }\r\n //タイマー変数初期化\r\n time=null;\r\n \r\n //乱数生成\r\n var result = Math.floor(Math.random()*3);\r\n //結果表示\r\n monitor.innerHTML= gyanken[result];\r\n }\r\n }\n```\n\n```\n\n #monitor {\r\n background-color:#d0f0f0;\r\n width:180px;\r\n height:120px;\r\n cursor:pointer;\r\n }\n```\n\n```\n\n <div id=\"monitor\"></div>\n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T12:18:23.660", "id": "33579", "last_activity_date": "2017-03-28T04:45:54.453", "last_edit_date": "2017-03-28T04:45:54.453", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "33578", "post_type": "answer", "score": 3 } ]
33578
null
33579
{ "accepted_answer_id": null, "answer_count": 2, "body": "以前 VSCode で Markdown\nファイルを編集するとき、自動でウィンドウが左右分割され、右側にプレビューが表示されていた気がするのですが、現在はそのような挙動になりません。\n\n仕方ないので「エディターの分割 (Ctrl+¥)」→「プレビューを開く\n(Ctrl+Shift+V)」→プレビューじゃないエディタが右パネルに残っているので閉じる、という操作を毎回行っているのですが、これを一回の操作で(願わくばファイルを開いたり言語を指定したら自動で)やりたいのですが、そういった設定などないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T12:57:42.820", "favorite_count": 0, "id": "33580", "last_activity_date": "2021-03-07T07:38:49.187", "last_edit_date": "2021-03-07T07:09:07.887", "last_editor_user_id": "3060", "owner_user_id": "20204", "post_type": "question", "score": 1, "tags": [ "vscode", "markdown" ], "title": "Visual Studio Code でMarkdownプレビューを右側に表示する方法", "view_count": 3634 }
[ { "body": "Auto-Open Markdown Preview - Visual Studio Marketplace \n<https://marketplace.visualstudio.com/items?itemName=hnw.vscode-auto-open-\nmarkdown-preview> \nこの拡張機能で「自動でその右隣にプレビュータブを並べて表示」が実現できそうです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T15:00:39.333", "id": "33585", "last_activity_date": "2017-03-27T15:00:39.333", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2238", "parent_id": "33580", "post_type": "answer", "score": 2 }, { "body": "質問当時そんな状況があったかもしれませんが, (現在)以下の環境では `Ctrl`+`K` `V` で表示可能です\n\n(環境)\n\n> バージョン: 1.54.1 \n> 〜 \n> Electron: 11.3.0 \n> Chrome: 87.0.4280.141 \n> Node.js: 12.18.3 \n> V8: 8.7.220.31-electron.0 \n> OS: Linux x64 5.8.0-44-generic", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2021-03-07T07:38:49.187", "id": "74493", "last_activity_date": "2021-03-07T07:38:49.187", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "43025", "parent_id": "33580", "post_type": "answer", "score": 2 } ]
33580
null
33585
{ "accepted_answer_id": "33609", "answer_count": 1, "body": "データベースのレプリケーション設定を行おうと思いまして、mariadbをインストールしました。 \n実際データベースの動作上は問題なく、マスタースレーブの設定も大体が上手くいきました。 \n最終の段階で`show slave status`を打つと下記のようになりました。\n\n```\n\n Slave_IO_Running: No\n Slave_SQL_Running: Yes\n Last_IO_Errno: 1593\n \n```\n\n何がおかしいのかID系を調べたところ`select uuid();`は問題なかったのですが、 \n`show variables like '%server%';`の結果がマスタースレーブ共に`server_id=1`でした。 \n`my.cnf`自体には`server-id=102`と記載があったのにもかかわらず反映されていないようです。\n\nちなみに`set global server_id=102;`と打って手動で変更するとレプリケーションも通りました。 \n`/datadir/mysql/auto.cnf`も疑いましたが、そもそも存在しませんでした。 \n`log-bin=mysql-bin`の値はレプリケーションのステータスから反映されているので \n`my.cnf`が読めていないわけではなさそうなのですが…… \nファイルの場所自体は`/etc/my.cnf`で、他のユーザディレクトリなどの場所には存在しませんでした。\n\nなにか原因になりそうな箇所が分かりませんでしょうか? \n以上、どうぞよろしくお願いいたします。\n\n環境 \n`mysql Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1` \n`CentOS Linux release 7.3.1611 (Core)`", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T13:04:25.993", "favorite_count": 0, "id": "33581", "last_activity_date": "2017-03-28T11:00:27.467", "last_edit_date": "2017-03-28T04:21:12.383", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "mysql", "mariadb" ], "title": "my.cnfでserver-idが反映されない", "view_count": 1933 }
[ { "body": "CentOS7 では `/etc/my.cnf.d` の下に設定ファイルが作成され `/etc/my.cnf`\n内でインクルードされますのでそちらも探してみてください。\n\n```\n\n /etc/my.cnf\n \n #\n # include all files from the config directory\n #\n !includedir /etc/my.cnf.d\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T11:00:27.467", "id": "33609", "last_activity_date": "2017-03-28T11:00:27.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "33581", "post_type": "answer", "score": 1 } ]
33581
33609
33609
{ "accepted_answer_id": "33593", "answer_count": 1, "body": "下記のコードのデジタル時計をリアルタイムで表示させるには、文字を更新する処理などが \n必要かと思われますが、どのように書き変えたらいいのか分かりません。var ti~var msgまでを \nどこに記入し、その他必要な処理があればご教示ください。\n\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=Shift_JIS\">\n <meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\">\n <meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n <title>文字マウスストーカー</title>\n \n \n <style type=\"text/css\">\n \n #myText {\n font-style: italic;\n font-weight: bold;\n font-family: 'comic sans ms', verdana, arial;\n color: gold;\n \n position: absolute;top: 0;left: 0;z-index: 3000;cursor: default;}\n #myText div {position: relative;}\n #myText div div {position: absolute;top: 0;left: 0;text-align: center;}\n \n </style>\n \n \n <script type=\"text/javascript\">\n <!--\n \n ;(function(){\n \n var ti = new Date;\n \n var Hour = ti.getHours();\n var Min = ti.getMinutes();\n var Sec = ti.getSeconds();\n \n if(Hour <= 9) { \n Hour = \"\\u0020\\u0020\" + Hour; \n } \n     if(Min <= 9) { \n Min = \"0\" + Min; \n }\n if(Sec <= 9) { \n Sec = \"0\" + Sec; \n }\n \n var msg = Hour + \":\" + Min + \":\" + Sec ;\n \n \n var size = 24;\n \n var circleY = 0.75; var circleX = 2;\n \n var letter_spacing = 5;\n \n var diameter = 10;\n \n var rotation = 0.4;\n var speed = 0.3;\n \n \n if (!window.addEventListener && !window.attachEvent || !document.createElement) return;\n \n msg = msg.split('');\n var n = msg.length - 1, a = Math.round(size * diameter * 0.208333), currStep = 20,\n ymouse = a * circleY + 20, xmouse = a * circleX + 20, y = [], x = [], Y = [], X = [],\n o = document.createElement('div'), oi = document.createElement('div'),\n b = document.compatMode && document.compatMode != \"BackCompat\"? document.documentElement : document.body,\n \n mouse = function(e){\n e = e || window.event;\n ymouse = !isNaN(e.pageY)? e.pageY : e.clientY; // y-position\n xmouse = !isNaN(e.pageX)? e.pageX : e.clientX; // x-position\n },\n \n makecircle = function(){ // rotation/positioning\n \n if(init.nopy){\n o.style.top = (b || document.body).scrollTop + 'px';\n o.style.left = (b || document.body).scrollLeft + 'px';\n };\n currStep -= rotation;\n for (var d, i = n; i > -1; --i){ // makes the circle\n d = document.getElementById('iemsg' + i).style;\n d.top = Math.round(y[i] + a * Math.sin((currStep + i) / letter_spacing) * circleY - 15) + 'px';\n d.left = Math.round(x[i] + a * Math.cos((currStep + i) / letter_spacing) * circleX) + 'px';\n };\n },\n \n drag = function(){ // makes the resistance\n \n y[0] = Y[0] += (ymouse - Y[0]) * speed;\n x[0] = X[0] += (xmouse - 20 - X[0]) * speed;\n for (var i = n; i > 0; --i){\n y[i] = Y[i] += (y[i-1] - Y[i]) * speed;\n x[i] = X[i] += (x[i-1] - X[i]) * speed;\n };\n makecircle();\n },\n \n init = function(){\n if(!isNaN(window.pageYOffset)){\n ymouse += window.pageYOffset;\n xmouse += window.pageXOffset;\n } else init.nopy = true;\n for (var d, i = n; i > -1; --i){\n d = document.createElement('div'); d.id = 'iemsg' + i;\n d.style.height = d.style.width = a + 'px';\n d.appendChild(document.createTextNode(msg[i]));\n oi.appendChild(d); y[i] = x[i] = Y[i] = X[i] = 0;\n };\n o.appendChild(oi); document.body.appendChild(o);\n setInterval(drag, 25);\n },\n \n ascroll = function(){\n \n ymouse += window.pageYOffset;\n xmouse += window.pageXOffset;\n window.removeEventListener('scroll', ascroll, false);\n };\n \n o.id = 'myText'; o.style.fontSize = size + 'px';\n \n if (window.addEventListener){\n \n window.addEventListener('load', init, false);\n document.addEventListener('mouseover', mouse, false);\n document.addEventListener('mousemove', mouse, false);\n if (/Apple/.test(navigator.vendor))\n window.addEventListener('scroll', ascroll, false);\n }\n else if (window.attachEvent){\n window.attachEvent('onload', init);\n document.attachEvent('onmousemove', mouse);\n };\n \n })();\n \n // -->\n </script>\n \n </head>\n \n <body bgcolor=\"black\">\n \n </body>\n </html>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T14:59:27.643", "favorite_count": 0, "id": "33584", "last_activity_date": "2017-03-28T01:56:02.737", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20431", "post_type": "question", "score": -1, "tags": [ "javascript" ], "title": "デジタル時計をリアルタイムで表示させたい(別コード)", "view_count": 196 }
[ { "body": "drag = function(){}の内容を以下のように書き換えます\n\n```\n\n drag = function(){ // makes the resistance\n \n var ti = new Date;\n \n var Hour = ti.getHours();\n var Min = ti.getMinutes();\n var Sec = ti.getSeconds();\n \n if(Hour <= 9) \n {\n Hour = \"\\u0020\\u0020\" + Hour; \n }\n if(Min <= 9)\n {\n Min = \"0\" + Min; \n }\n if(Sec <= 9)\n {\n Sec = \"0\" + Sec; \n }\n \n var msg = Hour + \":\" + Min + \":\" + Sec ;\n \n msg = msg.split('');\n var n = msg.length - 1;\n \n for (var d, i = n; i > -1; --i)\n {\n var elm = document.getElementById('iemsg' + i);\n elm.innerHTML = msg[i];\n };\n \n y[0] = Y[0] += (ymouse - Y[0]) * speed;\n x[0] = X[0] += (xmouse - 20 - X[0]) * speed;\n for (var i = n; i > 0; --i){\n y[i] = Y[i] += (y[i-1] - Y[i]) * speed;\n x[i] = X[i] += (x[i-1] - X[i]) * speed;\n };\n makecircle();\n }\n \n```\n\n各文字はid「iemsg+連番」を持つdiv要素で絶対位置配置されているようです。 \nそのdivの要素の中身のinnnerHTMLプロパティを毎回書き換えてあげることで希望の動きになります。 \nいかがでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T01:48:58.737", "id": "33593", "last_activity_date": "2017-03-28T01:56:02.737", "last_edit_date": "2017-03-28T01:56:02.737", "last_editor_user_id": "17014", "owner_user_id": "17014", "parent_id": "33584", "post_type": "answer", "score": 0 } ]
33584
33593
33593
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n @tags = Tag.all\n @post.taggings.build\n \n```\n\n上記はcontorllerのプログラムででtaggingsはpostテーブルとtagsテーブルの中間テーブルです。下記はviewです。\n\n```\n\n <div class=\"form-group\">\n <%= f.fields_for :taggings do |pt| %>\n <%= pt.collection_select :tag_id, @tags, :id, :display_name, { prompt: \"選択してください\", label: \"タグ\" }, class: \"tag-fields\" %>\n <% end %>\n </div>\n \n```\n\npost(ブログの投稿)を編集するときに編集ページを開くと、その投稿に紐づくタグが表示されるのはよいのですが、新規のセレクトボックス(選択してくださいと表示されているセレクトボックス)まで表示されてしまいます。\n\nどうすれば、関連しているタグのみ表示できるのでしょうか?それとselectとcollection_selectも違いがよく分かっていないので、その辺の使い分けもご教示いただけると助かります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T15:33:03.560", "favorite_count": 0, "id": "33586", "last_activity_date": "2020-09-10T13:01:30.140", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "18982", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails" ], "title": "collection_selectについて", "view_count": 856 }
[ { "body": "> 新規のセレクトボックス(選択してくださいと表示されているセレクトボックス)まで表示されてしまいます。\n\n編集でも新規でも以下のコードがhtmlになってしまうため「選択してください」が表示されてしまいます。\n\n`<%= pt.collection_select :tag_id, @tags, :id, :display_name, { prompt:\n\"選択してください\", label: \"タグ\" }, class: \"tag-fields\" %>`\n\n以下のようにすればうまくいくと思います。\n\n 1. セレクトボックスの先頭に空の行を追加する\n 2. 空の行に「選択してください」と表示する\n\n実際のコードとしては以下のようなイメージです。\n\n`<%= pt.collection_select :tag_id, @tags, :id, :display_name, label: \"タグ\" },\nclass: \"tag-fields\", include_blank: '選択してください' %>`\n\n`include_blank` については以下でご確認ください。 \n<http://railsdoc.com/references/collection_select>\n\nまた、文字列を `erb` に直接記載するよりも `i18n` を利用する方が一般的なので、余裕があれば `i18n`\nについて調べてみて、以下を試してみるとより良いコードになると思います、\n\n`<%= pt.collection_select :tag_id, @tags, :id, :display_name, label: \"タグ\" },\nclass: \"tag-fields\", include_blank: true %>`\n\napp_name/config/locales/ja.yml\n\n```\n\n ja:\n helpers:\n select:\n include_blank: \"選択してください\"\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-18T01:04:41.447", "id": "34082", "last_activity_date": "2017-04-18T01:04:41.447", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22531", "parent_id": "33586", "post_type": "answer", "score": 1 } ]
33586
null
34082
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n hoge n = [(x,y) | x <- [-n .. n], y <- [-n .. n]]\n \n```\n\nこの関数をリスト内包表記を使わずに書くなら、どう書けますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T15:36:33.890", "favorite_count": 0, "id": "33587", "last_activity_date": "2017-03-27T20:58:22.213", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12896", "post_type": "question", "score": 1, "tags": [ "haskell" ], "title": "リスト内包表記を使わずに書くなら", "view_count": 204 }
[ { "body": "リストをアプリカティブとして使うなら\n\n```\n\n hoge n = (\\x y -> (x,y)) <$> [-n .. n] <*> [-n .. n]\n \n```\n\nモナドとして使うなら\n\n```\n\n hoge n = do x <- [-n .. n]\n y <- [-n .. n]\n return (x,y)\n \n```\n\nと書けます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T20:58:22.213", "id": "33591", "last_activity_date": "2017-03-27T20:58:22.213", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3605", "parent_id": "33587", "post_type": "answer", "score": 6 } ]
33587
null
33591
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n manlen p1 p2 = abs(fst p1 - fst p2) + abs(snd p1 - snd p2)\n points n = [(x,y) | x <- [-n .. n], y <- [-n .. n]]\n mancircle n = [p | p <- points n, manlen (0,0) p == n]\n \n```\n\n最後のリスト内包表記内の、`manlen (0,0) p == n`がよくわかりません。 \nmanlen の引数に p == nを取っているのはなぜなんでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T17:49:40.267", "favorite_count": 0, "id": "33589", "last_activity_date": "2017-03-28T07:46:06.423", "last_edit_date": "2017-03-28T07:46:06.423", "last_editor_user_id": "20272", "owner_user_id": "12896", "post_type": "question", "score": 0, "tags": [ "haskell" ], "title": "「manlen (0,0) p == n」の解釈について", "view_count": 124 }
[ { "body": "haskell では `==` のような両側に引数を取る infix の演算子の優先順位は、普通の関数呼び出しより低いです。したがって `manlen\n(0,0) p == n` は `manlen (0,0) (p == n)` ではなく`(manlen (0,0) p) == n`と解釈されます。これは\nBool を返すのでフィルターになります。従って\n\n```\n\n mancircle n = [p | p <- points n, manlen (0,0) p == n]\n \n```\n\nは、`points n`の要素の中で`manlen (0,0) p`が n になるものだけを返します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-27T18:21:16.227", "id": "33590", "last_activity_date": "2017-03-27T18:21:16.227", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3605", "parent_id": "33589", "post_type": "answer", "score": 3 } ]
33589
null
33590
{ "accepted_answer_id": "33616", "answer_count": 3, "body": "パスワードなどのハッシュ値をDBで持とうと思っているのですが、 \n通常のデータベースではハッシュ値はどのような型で扱うべきなのでしょうか?\n\nちなみにオラクル12cを使用しております。 \nRAW型で持つのが一般的なのでしょうか? \nそれともハッシュ値を16進数表記の文字列にしてCHAR型等で持つべきでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T02:58:38.687", "favorite_count": 0, "id": "33594", "last_activity_date": "2017-05-10T08:24:03.953", "last_edit_date": "2017-03-28T06:47:33.057", "last_editor_user_id": null, "owner_user_id": "12842", "post_type": "question", "score": 1, "tags": [ "database" ], "title": "ハッシュ値の持ち方について", "view_count": 909 }
[ { "body": "用途に依るのではないでしょうか。 \n頻繁にもしくは積極的に表示を行うのであればCHAR等の文字列型の方が効率がいいでしょう。 \n一致比較を主とするのであればRAW等のバイナリ型の方が効率がいいでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T03:06:43.753", "id": "33595", "last_activity_date": "2017-03-28T03:06:43.753", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "33594", "post_type": "answer", "score": 1 }, { "body": "私ならBASE64なりHEX表記の文字列で格納します。データベース保守ツールはRAW/BLOBデータの扱いに制約があるものが少なくなく、開発言語を問わずRAW/BLOBを扱うのは一手間増える事が多いからです。もちろんデータサイズが増えるなどのデメリットもありますが、格納するのがハッシュ値であるなら最大でも1KB程度に過ぎず、十分に許容できるサイズと考えています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T06:36:54.610", "id": "33599", "last_activity_date": "2017-03-28T06:36:54.610", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12774", "parent_id": "33594", "post_type": "answer", "score": 1 }, { "body": "人力でINSERT、UPDATEするケースを考慮して、16進数表記の文字列にしてCHAR型で持つのが便利かと思います。(`sha512sum`等のコマンドの出力を使えるといった点も考慮して)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T15:57:46.083", "id": "33616", "last_activity_date": "2017-03-28T15:57:46.083", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20098", "parent_id": "33594", "post_type": "answer", "score": 0 } ]
33594
33616
33595
{ "accepted_answer_id": "33604", "answer_count": 1, "body": "Mac でアナログ時計のようなデスクトップアプリケーションを作成しようとしています。(Xcode 8 + Swift 3) \n短針や長針などのPNG画像を重ね合わせて描画したいのですが、Swift自体初めてで正しい方法が分かりません。\n\nまず NSView を拡張したクラスを作り、draw()\nメソッドをオーバーライドすることにし、ファイルパスから画像を読み込み、コンテキストを使って描き込もうと考えました。\n\n### 画像の読み込み\n\n```\n\n let image = NSImage(contentsOfFile: path as String);\n \n```\n\n### 描画処理\n\n```\n\n class MyView: NSView {\n \n override var isFlipped: Bool { return true }\n \n override func draw(_ dirtyRect: NSRect) {\n super.draw(dirtyRect)\n let bounds = NSRect(x: 0, y: 0, width: 100, height: 100);\n let context = NSGraphicsContext.current()?.cgContext;\n context.draw(image: self.image!, in: bounds)\n }\n }\n \n```\n\n省略してありますが大きな流れは上記のとおりです。 \n読み込んだ image は NSImage ですが、 context.draw() の引数は CGImage\nでなければならないためエラーになっているように見えます。(Argument labels '{image:, in:}' do not match any\navailable overloads)\n\n```\n\n image!.draw(in: bounds);\n \n```\n\ncontext を使わず上のようにすれば描画自体はできます。ただ回転処理などもする予定なので CoreGraphics\nを使っておいたほうが良いのではと思っています。(このあたりもよくわかっていません)\n\nこういったケースでは通常どのようにすれば良いのでしょうか?\n\n* * *\n\n**追記**\n\nNSViewの拡張クラスに isFlipped = true を追加", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T04:13:20.433", "favorite_count": 0, "id": "33596", "last_activity_date": "2017-03-28T22:31:26.740", "last_edit_date": "2017-03-28T08:32:52.453", "last_editor_user_id": "10083", "owner_user_id": "10083", "post_type": "question", "score": 0, "tags": [ "swift", "macos", "swift3" ], "title": "NSViewに複数の画像を描画したい", "view_count": 1624 }
[ { "body": "> 読み込んだ image は NSImage ですが、 context.draw() の引数は CGImage\n> でなければならないためエラーになっているように見えます。\n\nこれは、`NSImage`のメソッド`cgImage(forProposedRect:context:hints:)`を使って、`CGImage`に変換します。\n\n```\n\n override func draw(_ dirtyRect: NSRect) {\n super.draw(dirtyRect)\n \n guard let context = NSGraphicsContext.current(),\n let image = NSImage(contentsOfFile: path as String) else {\n return\n }\n \n var imageRect = NSRect(x: 32.0, y: 32.0, width: image.size.width, height: image.size.height)\n if let cgImage = image.cgImage(forProposedRect: &imageRect, context: context, hints: nil) {\n context.cgContext.draw(cgImage, in: imageRect)\n }\n }\n }\n \n```\n\n* * *\n\n> こういったケースでは通常どのようにすれば良いのでしょうか?\n\nCore Graphicsフレームワークは、正直お勧めできません。アナログ時計といっても、イメージを動かすのは、静的イメージを描画するためのCore\nGraphicsは、なじまないと思います。QuartzCoreフレームワークか、ゲーム製作フレームワークのSpriteKitなどがお勧めになります。 \nここでは、QuartzCoreフレームワークを使ったケースを紹介します。QuartzCoreでは、`CALayer`クラスが、描画の単位となっていて、`addSublayer()`によって、レイヤーを多層化し、複雑な構成を実現します。レイヤーごとに`CGAffineTransform`あるいは`CATransform3D`による座標変換を加えることができます。アナログ時計の時針、分針、秒針を、別々に動かすのに、適しています。\n\n```\n\n import Cocoa\n \n class MyView: NSView {\n \n var subLayer = CALayer()\n // Storyboard、Interface Builderからインスタンスを生成した時の、初期化処理。\n override func awakeFromNib() {\n super.awakeFromNib()\n \n wantsLayer = true // レイヤー操作を有効にする。\n subLayer.contents = NSImage(named: \"a.png\") // レイヤーにイメージを貼り付け。\n subLayer.frame = CGRect(x: 50.0, y: 50.0, width: 50.0, height: 50.0)\n layer?.addSublayer(subLayer) // MyViewのviewのサブレイヤーにする。\n }\n // マウスをクリックしたら、\n override func mouseDown(with event: NSEvent) {\n let affinTransform = subLayer.affineTransform()\n subLayer.setAffineTransform(affinTransform.rotated(by: CGFloat.pi / 4.0))\n // レイヤーが45度ずつ回転する。\n \n // subLayer.transform = CATransform3DRotate(subLayer.transform, CGFloat.pi / 4.0, 0.0, 0.0, 1.0)\n // CATransform3Dを利用する場合は、こちら。\n }\n }\n \n```\n\nここでは、QuartzCoreの、`CALayer`と`CATransform3D`を紹介しましたが、`CAAnimation`クラスと、そのサブクラスについても、勉強してみてください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T07:34:02.640", "id": "33604", "last_activity_date": "2017-03-28T22:31:26.740", "last_edit_date": "2017-03-28T22:31:26.740", "last_editor_user_id": "18540", "owner_user_id": "18540", "parent_id": "33596", "post_type": "answer", "score": 1 } ]
33596
33604
33604
{ "accepted_answer_id": null, "answer_count": 0, "body": "```\n\n <p>カテゴリー</p>\n <ul>\n {% for category in categories %}\n <li><a href=\"{% url 'index' category.slug %}\">{{ category.name }}</a></li>\n {% endfor %}\n </ul>\n \n <p>場所</p>\n <ul>\n {% for location in locations %}\n <li><a href=\"{% url 'index' location.slug %}\">{{ location.name }}</a></li>\n {% endfor %}\n </ul>\n \n```\n\nというリンクがあり、categoryをクリックして遷移した先のページURLは/category/だとします。 \nこの状態でlocationをクリックしてURLを/category/location/としたい場合、\n\n```\n\n <li><a href=\"{% url 'index' category.slug location.slug %}\">{{ location.name }}</a></li>\n \n```\n\nとすればいいのですが、こういった動的なURLの生成を実現するためにはどうすればいいのでしょうか?\n\n**_Updated_**\n\nソースコードも全て載せます。テンプレートも少し詳しく記載したので御覧ください\n\n```\n\n from django.db import models\n \n class Category(models.Model):\n parent = models.ForeignKey('Category', related_name='children', null=True, blank=True)\n name = models.CharField(max_length=255)\n slug = models.SlugField()\n \n @property\n def dispatch(self):\n # parent が nullであれば親カテゴリなので自分自身を返す\n if not self.parent:\n return self\n # そうでなければ親カテゴリ(parent)を返す\n else:\n return self.parent\n \n def __str__(self):\n return self.name\n \n class Location(models.Model):\n parent = models.ForeignKey('Location', related_name='children', null=True, blank=True)\n name = models.CharField(max_length=255)\n slug = models.SlugField()\n \n @property\n def dispatch(self):\n # parent が nullであればStateなので自分自身を返す\n if not self.parent:\n return self\n # そうでなければState(parent)を返す\n else:\n return self.parent\n \n def __str__(self):\n return self.name\n \n class PostQuerySet(models.QuerySet):\n \n def filter_category(self, category):\n if not category.parent:\n # Big Category であれば、childrenのカテゴリに所属するPostをfilter\n return self.filter(category__in=category.children.all())\n else:\n # Small Category であれば、categoryに所属するPostをfilter\n return self.filter(category=category)\n \n def filter_location(self, location):\n if not location.parent:\n # State であれば、childrenのlocationに所属するPostをfilter\n return self.filter(location__in=location.children.all())\n else:\n # Region であれば そのlocationに所属するPostをfilter\n return self.filter(location=location)\n \n \n class Post(models.Model):\n category = models.ForeignKey(Category)\n location = models.ForeignKey(Location)\n title = models.CharField(max_length=255)\n text = models.CharField(max_length=255)\n \n objects = PostQuerySet.as_manager()\n \n def __str__(self):\n return self.title \n \n urlpatterns = [\n url(r'^all-categories/$', views.all_cat_index, name='index'),\n url(r'^all-categories/(?P<loc>[-\\w]+)/$', views.all_cat_loc_index, name='index'),\n url(r'^(?P<cat>[-\\w]+)/$', views.cat_index, name='index'),\n url(r'^(?P<cat>[-\\w]+)/(?P<loc>[-\\w]+)/$', views.cat_loc_index, name='index'),\n ]\n \n def all_cat_index(request):\n big_cats = Category.objects.filter(parent__isnull=True)\n states = Location.objects.filter(parent__isnull=True)\n \n c = {\n 'big_cats': big_cats,\n 'states': states,\n 'posts': Post.objects.all()\n }\n return render(request, 'classifieds/index.html', c)\n \n def all_cat_loc_index(request, loc):\n location = get_object_or_404(Location, slug=loc)\n \n c = {\n 'big_cats': Category.objects.filter(parent__isnull=True),\n 'state': location.dispatch,\n 'posts': Post.objects.filter_location(location).all()\n }\n return render(request, 'classifieds/index.html', c)\n \n def cat_index(request, cat):\n category = get_object_or_404(Category, slug=cat)\n \n c = {\n 'big_cat': category.dispatch,\n 'states': Location.objects.filter(parent__isnull=True).all(),\n 'posts': Post.objects.filter_category(category).all()\n }\n return render(request, 'classifieds/index.html', c)\n \n def cat_loc_index(request, cat, loc):\n category = get_object_or_404(Category, slug=cat)\n location = get_object_or_404(Location, slug=loc)\n \n c = {\n 'big_cat': category.dispatch,\n 'state': location.dispatch,\n 'posts': Post.objects.filter_category(category).filter_location(location).all()\n }\n return render(request, 'classifieds/index.html', c)\n \n \n {% extends 'base.html' %}\n {% block left %}\n <p>[カテゴリー]</p>\n <ul>\n {% if big_cat %}\n <li><a href=\"{% url 'classifieds:index' param %}\">{{ big_cat.name }}</a></li>\n {% for small_cat in big_cat.children.all %}\n <li><a href=\"{% url 'classifieds:index' param %}\">{{ small_cat.name }}</a></li>\n {% endfor %}\n {% else %}\n {% for big_cat in big_cats %}\n <li><a href=\"{% url 'classifieds:index' param %}\">{{ big_cat.name }}</a></li>\n {% endfor %}\n {% endif %}\n \n \n </ul>\n \n <p>[フィルター]</p>\n <ul>\n {% if state %}\n <li><a href=\"{% url 'classifieds:index' param %}\">{{ state.name }}</a></li>\n {% for region in state.children.all %}\n <li><a href=\"{% url 'classifieds:index' param %}\">{{ region.name }}</a></li>\n {% endfor %}\n {% else %}\n {% for state in states %}\n <li><a href=\"{% url 'classifieds:index' param %}\">{{ state.name }}</a></li>\n {% endfor %}\n {% endif %}\n </ul>\n {% endblock %}\n \n {% block content %}\n <ul>\n {% for post in posts %}\n <li>{{ post.title }} | {{ post.category }} | {{ post.location }}</li>\n {% endfor %}\n </ul>\n {% endblock %}\n \n```\n\nつまり\n\n```\n\n <a href=\"{% url 'index' big_cat.slug %}\">{{ big_cat.name }}</a>\n \n```\n\nをクリックして遷移するページは/category/で、このときにこのリンクを\n\n```\n\n <a href=\"{% url 'index' big_cat.slug state.slug %}\">\n \n```\n\nというように、big_cat.slugがすでに含まれている状態に動的に変化させたいです。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T06:22:12.937", "favorite_count": 0, "id": "33598", "last_activity_date": "2017-04-01T15:17:29.753", "last_edit_date": "2017-04-01T15:17:29.753", "last_editor_user_id": "21116", "owner_user_id": "21116", "post_type": "question", "score": 1, "tags": [ "python", "django" ], "title": "同一テンプレート内にてURLの動的変更について", "view_count": 801 }
[]
33598
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "ある要素の innerText/textContent のうち、特定の正規表現(例:\n`/#\\d+/`)に該当する文字列をタグで囲み、イベントハンドラを設定したいと考えています。例えば、`<p>その件は #123\nを参照してください。</p>` というHTMLの中で `#123`\nにマウスカーソルを乗せると、対応するIssueの詳細がポップアップされる、といったものです。\n\n一つ思いついた方法としては、innerHTML に対して置換を行うものです。\n\n```\n\n target.innerHTML = target.innerHTML\n .replace(/#(\\d+)/g, (s, id) => `<a href=\".../${id}\">${s}</a>`);\n \n```\n\n単純なリンクに置き換えるだけならこれでもいいのですが、設定する属性やイベントハンドラが多くなってくるとタグに記載するのは面倒ですし、読みにくくなってしまいます。かといってこの時点では文字列なので、Elementオブジェクトにはアクセスできません。\n\nUserScript として作る都合上、できれば class 属性等を使うのも避けたいです(対象ページでの使用箇所と競合する可能性があるので)。\n\n選択範囲に対して同様のことをした時には\n[`Range.prototype.surroundContents()`](https://developer.mozilla.org/en-\nUS/docs/Web/API/range/surroundContents)\nが使えたので、今回もマッチ範囲をRangeで取得する、なんてことができれば簡単そうなのですが…。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T07:16:48.870", "favorite_count": 0, "id": "33603", "last_activity_date": "2017-12-08T04:12:09.237", "last_edit_date": "2017-03-29T22:53:05.230", "last_editor_user_id": "20204", "owner_user_id": "20204", "post_type": "question", "score": 0, "tags": [ "javascript", "html" ], "title": "正規表現にマッチしたテキストをタグで囲み、イベントハンドラを設定したい", "view_count": 1188 }
[ { "body": "DOMはDOMオブジェクトで表現されていないものに対する操作がとても苦手です。というかほぼできません。逆に言えばDOMに落とし込めれば操作可能になります。 \nHTMLにおける文字列はDOMにおいて`nodeType ===\nTEXT_NODE`のNodeオブジェクト、いわゆるtextNodeとして構成されますが、このオブジェクトは任意長の部分文字列に分割することが可能です(子要素にtextNodeがいくつあってもよい/最初のtextNodeが.textContentに一致するわけではない)。今回のアプローチではまず対象となる文字列を部分文字列のtextNodeに分割します。 \nしかしながらtextNodeはEventTargetを継承していません(`Node instanceof EventTarget ===\nfalse`)ので、ふつうのDOM要素(HTMLElement)とは異なりイベントを登録できません。これを解決するために、質問内容でいうところの「HTML要素に置き換える」操作が解決方法になるわけです。 \n以下、サンプルコードでは部分文字列の生成と置換を同時に行っています。部分文字列の検索はtextNodeを[NodeIterator](https://developer.mozilla.org/en-\nUS/docs/Web/API/NodeIterator)による列挙で抽出し、それぞれのtextNodeの内容を文字列検索・分割・置換しています。関数`__replaceTextNodes`は置換した要素への参照配列をかえしますので、その後のアプリケーションでイベントハンドラの登録等に利用できます。全体としてはRange.prototype.surroundContents()のpolyfillのような印象になりました。\n\n```\n\n const __getTextNodesByContent = (target, pattern) => {\r\n // get iterator\r\n const textNodeIterator = document.createNodeIterator(\r\n // search for\r\n target,\r\n // enumerate for\r\n NodeFilter.SHOW_TEXT,\r\n // filter\r\n {\r\n acceptNode: node => pattern.test(node.textContent) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT,\r\n }\r\n );\r\n \r\n // into array\r\n const ret = [];\r\n let current;\r\n while (current = textNodeIterator.nextNode()) {\r\n ret.push(current);\r\n }\r\n \r\n return ret;\r\n };\r\n \r\n const __replaceTextNodes = (target, pattern, replace) => {\r\n // get the list of textNodes that contains /pattern/\r\n const matchedTextNodes = __getTextNodesByContent(target, pattern);\r\n \r\n // for each textnode\r\n const ret = [];\r\n for (const node of matchedTextNodes) {\r\n // replace each part of textNode\r\n let currentNode = node;\r\n let matches;\r\n \r\n while (pattern.lastIndex = 0, matches = pattern.exec(currentNode.textContent)) {\r\n // separate [currentNode|<before><match><after>]\r\n // into [currentNode|<before>] [nextNode|<match><after>]\r\n const nextNode = currentNode.splitText(matches.index);\r\n \r\n // slice <match> part; [currentNode|<before>] [nextNode|<after>]\r\n nextNode.textContent = nextNode.textContent.slice(matches[0].length);\r\n \r\n // insert surround <match> part as a new sibling;\r\n // [currentNode|<before>] [surroundNode|<match>] [nextNode|<after>]\r\n const surroundNode = replace(matches[0]);\r\n nextNode.parentElement.insertBefore(surroundNode, nextNode);\r\n \r\n // store reference\r\n ret.push(surroundNode);\r\n \r\n // next\r\n currentNode = nextNode;\r\n }\r\n }\r\n \r\n // return a list of surround elements\r\n return ret;\r\n };\r\n \r\n //\r\n // for example\r\n //\r\n const $target = document.body;\r\n const targetPattern = /Lorem|massa|ridiculus|pellentesque/gi;\r\n \r\n const surroundElements = __replaceTextNodes($target, targetPattern, text => {\r\n // surround with <span>, colored with red, add title attribute\r\n const el = document.createElement('span');\r\n el.textContent = text;\r\n el.style.color = 'red';\r\n el.title = 'surround with <span>, text content is \"' + text + '\";';\r\n return el;\r\n });\r\n \r\n // event handler filterd by surround elements\r\n window.addEventListener('click', e => {\r\n if (surroundElements.includes(e.target)) {\r\n console.log('click', e.target);\r\n }\r\n });\r\n \r\n // or for each surround elements\r\n /*\r\n for (const se of surroundElements) {\r\n se.addEventListener(evt, fn);\r\n }\r\n */\n```\n\n```\n\n <h1>Lorem Lorem ipsum dolor sit amet consectetuer adipiscing \r\n elit</h1>\r\n \r\n <p>Lorem ipsum dolor sit amet, consectetuer adipiscing \r\n elit. Aenean commodo ligula eget dolor. Aenean massa \r\n <strong>strong</strong>. Cum sociis natoque penatibus \r\n et magnis dis parturient montes, nascetur ridiculus \r\n mus. Donec quam felis, ultricies nec, pellentesque \r\n eu, pretium quis, sem. Nulla consequat massa quis \r\n enim. Donec pede justo, fringilla vel, aliquet nec, \r\n vulputate eget, arcu. In enim justo, rhoncus ut, \r\n imperdiet a, venenatis vitae, justo.</p>\r\n \r\n <h2>Lorem ipsum dolor sit amet consectetuer adipiscing \r\n elit</h2>\r\n \r\n <h3>Aenean commodo ligula eget dolor aenean massa</h3>\r\n \r\n <p>Lorem ipsum dolor sit amet, consectetuer adipiscing \r\n elit. Aenean commodo ligula eget dolor. Aenean massa. \r\n Cum sociis natoque penatibus et magnis dis parturient \r\n montes, nascetur ridiculus mus. Donec quam felis, \r\n ultricies nec, pellentesque eu, pretium quis, sem.</p>\r\n \r\n <ul>\r\n <li>Lorem ipsum dolor sit amet consectetuer.</li>\r\n <li>Aenean commodo ligula eget dolor.</li>\r\n <li>Aenean massa cum sociis natoque penatibus.</li>\r\n </ul>\n```\n\n期待した動作ではない、バグがある、その他不明な点についてはコメントをお願いします。\n\n* * *\n\n参考:\n\n_innerHTML_ プロパティの変更によるDOMの操作は _極めて_\n高コストかつリスクが高いことを認識しておいてください。個人的な意見としては何が何でも使わないと実現できない場合のみ使用するものとし、リフレクション目的以外では使用禁止にしたいぐらいです。次の例では何の変更もしていないようで、body以下すべての要素が置換されています。\n\n```\n\n const $target = document.querySelector('#target');\r\n $target.addEventListener('click', e => console.log(e));\r\n \r\n // will be true\r\n console.log($target === document.querySelector('#target'));\r\n \r\n // reconstruct; SCRAP AND REBUILD ALL DOM ELEMENTS\r\n document.body.innerHTML = document.body.innerHTML;\r\n \r\n // will be false\r\n console.log($target === document.querySelector('#target'));\r\n \r\n // now no event listener attached to <div#target>\n```\n\n```\n\n <div id=\"target\">target element</div>\n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T12:28:22.137", "id": "33610", "last_activity_date": "2017-03-30T03:58:47.560", "last_edit_date": "2017-03-30T03:58:47.560", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "33603", "post_type": "answer", "score": 1 }, { "body": "XPath式 `descendant::text()[contains(.,\"#123\")]`\nを使用する事で文字列「`\"#123\"`」を含むテキストノードを得る事が可能です。 \nただし、XPath 1.0 では `\"` のエスケープシーケンスが利用できない為、`concat()`\nを利用して対応させます(詳細は後述の参考リンクを参照)。\n\n * [指定文字列を含むテキストノードを置換する - JSFiddle](https://jsfiddle.net/4047z5vp/2/)\n\n**(2017/03/30 08:00追記)** \nすみません。質問内容を誤解していました。 \n正規表現でマッチさせるなら「XPath式 `:matches()` を使う」もしくは「全てのテキストノードを参照後に\n`/#\\d+/.test(textNode.data)` を `while` 文で回す」方法が考えられます。\n\n * [7.6.2 fn:matches - XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)](https://www.w3.org/TR/xpath-functions/#func-matches)\n\n```\n\n 'use strict';\r\n var toXPathStringLiteral = (function () {\r\n function replacefn (match, p1) {\r\n \r\n if (p1) {\r\n return ',\\u0027' + p1 + '\\u0027';\r\n }\r\n \r\n return ',\"' + match + '\"';\r\n }\r\n \r\n return function toXPathStringLiteral (string) {\r\n string = String(string);\r\n \r\n if (/^\"+$/g.test(string)) {\r\n return '\\u0027' + string + '\\u0027';\r\n }\r\n \r\n switch (string.indexOf('\"')) {\r\n case -1:\r\n return '\"' + string + '\"';\r\n case 0:\r\n return 'concat(' + string.replace(/(\"+)|[^\"]+/g, replacefn).slice(1) + ')';\r\n default:\r\n return 'concat(' + string.replace(/(\"+)|[^\"]+/g, replacefn) + ')';\r\n }\r\n };\r\n }());\r\n \r\n function handleClick (event) {\r\n console.log(event.target.textContent);\r\n }\r\n \r\n function markupHighlight (targetString, contextNode) {\r\n var doc = contextNode.nodeType === contextNode ? contextNode : contextNode.ownerDocument,\r\n xpathResult = doc.evaluate('descendant::text()[contains(.,' + toXPathStringLiteral(targetString) + ')]', contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null),\r\n df = doc.createDocumentFragment(),\r\n mark = doc.createElement('mark');\r\n \r\n mark.appendChild(doc.createTextNode(targetString));\r\n \r\n for (var i = 0, xLen = xpathResult.snapshotLength, currentTextNode, stringList, textNode; i < xLen; ++i) {\r\n currentTextNode = xpathResult.snapshotItem(i);\r\n stringList = currentTextNode.data.split(targetString);\r\n textNode = df.appendChild(doc.createTextNode(stringList[0]));\r\n \r\n for (var j = 1, stringLen = stringList.length, textNode; j < stringLen; ++j) {\r\n mark = mark.cloneNode(true);\r\n df.appendChild(mark);\r\n mark.addEventListener('click', handleClick, false);\r\n textNode = textNode.cloneNode(false);\r\n textNode.data = stringList[j];\r\n df.appendChild(textNode);\r\n }\r\n \r\n currentTextNode.parentNode.replaceChild(df, currentTextNode);\r\n }\r\n }\r\n \r\n markupHighlight('foo', document.body);\n```\n\n```\n\n mark {\r\n color: black;\r\n background-color: #ddf;\r\n border: solid 1px #55f;\r\n }\n```\n\n```\n\n <ul id=\"foo\">\r\n <li>foo1</li>\r\n <li>foo2</li>\r\n <li>foo3</li>\r\n <li>\r\n <ul>\r\n <li>foo4-1</li>\r\n <li>foo4-2 foo4-2</li>\r\n <li>\r\n <ul>\r\n <li>foo4-3-1</li>\r\n <li>foo4-3-2 foo4-3-2 foo4-3-2</li>\r\n </ul>\r\n </li>\r\n </ul>\r\n </li>\r\n </ul>\n```\n\n### 参考リンク\n\n * [JavaScript - XPath 式の文字列リテラルでダブルクォートをエスケープするには?(31949)|teratail](https://teratail.com/questions/31949)\n * [JavaScript - XPath 式でテキストノード値を指定してフィルタするには?(31198)|teratail](https://teratail.com/questions/31198)\n\nRe: user20204 さん", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T17:55:55.080", "id": "33643", "last_activity_date": "2017-03-29T23:00:39.077", "last_edit_date": "2017-03-29T23:00:39.077", "last_editor_user_id": "20262", "owner_user_id": "20262", "parent_id": "33603", "post_type": "answer", "score": 1 } ]
33603
null
33610
{ "accepted_answer_id": "33607", "answer_count": 2, "body": "ssh の設定は普通は `~/.ssh/config` に記載されますが、プロジェクトごとに config を特殊化して使いたい場合などがあります。\n\n## 質問:\n\nssh は普通に実行すると、 `~/.ssh/config` が利用されますが、これ以外の場所に config を作成して、実行時にコマンドラインからこの別\nconfig を読み込むように指定することはできますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T09:08:14.783", "favorite_count": 0, "id": "33605", "last_activity_date": "2017-03-28T14:09:40.543", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 1, "tags": [ "ssh", "openssh" ], "title": "ssh コマンドで利用する config を指定することはできるか", "view_count": 2950 }
[ { "body": "manで確認したところ以下の記載がありました。\n\n```\n\n -F configfile\n Specifies an alternative per-user configuration file. If a configuration file is given on the command line, the system-wide configuration file\n (/etc/ssh/ssh_config) will be ignored. The default for the per-user configuration file is ~/.ssh/config.\n \n```\n\nコマンドラインからユーザごとの設定を指定するのであれば-Fオプションで可能です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T09:38:41.687", "id": "33607", "last_activity_date": "2017-03-28T09:38:41.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "33605", "post_type": "answer", "score": 3 }, { "body": "OpenSSH 7.3 より `ssh_config` に導入された `Include` キーワードを利用してはどうでしょうか。\n\nプロジェクトごとに config ファイルを分割、それらを `~/.ssh/config` 内でまとめて読み込めば目的は果たせるかと思います。\n\n```\n\n # 記述例\n # ファイル名には HOME `~` やワイルドカード `*` が指定可能\n Include config_localnet\n Include ~/path/to/ssh_config_*\n \n Host example\n HostName example.com\n Include configs/example\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T14:09:40.543", "id": "33614", "last_activity_date": "2017-03-28T14:09:40.543", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2391", "parent_id": "33605", "post_type": "answer", "score": 0 } ]
33605
33607
33607
{ "accepted_answer_id": null, "answer_count": 1, "body": "GTMを使用して、GAを導入しています。 \n過去にさかのぼって、サイトのイベントクリックを測定したいのですが、可能でしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T09:18:04.260", "favorite_count": 0, "id": "33606", "last_activity_date": "2020-03-02T03:33:47.950", "last_edit_date": "2020-03-02T03:33:47.950", "last_editor_user_id": "32986", "owner_user_id": "21240", "post_type": "question", "score": 0, "tags": [ "google-analytics-api", "google-tag-manager" ], "title": "GoogleAnalyticsのイベントタグを事後集計できるか?", "view_count": 69 }
[ { "body": "Googleアナリティクスに限らず、どのようなアクセス解析ツールを使ったとしても、データが送信されていないものについてはどうすることもできません。 \n事前に「何を計測するべきか」をきっちり決めておく必要があります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T01:04:29.253", "id": "33774", "last_activity_date": "2017-04-05T01:04:29.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19909", "parent_id": "33606", "post_type": "answer", "score": 1 } ]
33606
null
33774
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n <android.support.design.widget.BottomNavigationView\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n android:id=\"@+id/navigation\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"56dp\"\n android:layout_alignParentBottom=\"true\"\n android:background=\"@color/colorPrimary\"\n app:itemIconTint=\"#FFF\"\n app:itemTextColor=\"#FFF\"\n app:menu=\"@menu/footer_menu\" />\n \n```\n\n一般的なBottomNavigationですが、これをすべてのActivityにコピペするのは格好悪いので、\n\n```\n\n <android.support.design.widget.BottomNavigationView\n android:id=\"@+id/navigation\"\n style=\"@style/Footer\" />\n \n```\n\nこのようにstyleにまとめたいのですが、`app:itemIconTint`などはどうすればstyleに記述できますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T13:36:14.913", "favorite_count": 0, "id": "33612", "last_activity_date": "2021-03-07T05:02:54.280", "last_edit_date": "2021-03-07T05:02:54.280", "last_editor_user_id": "3060", "owner_user_id": "15279", "post_type": "question", "score": 1, "tags": [ "android", "android-layout" ], "title": "Android BottomNavigationのまとめ方", "view_count": 226 }
[ { "body": "こんな感じで app を無視して書くと動きます。\n\n```\n\n <style name=\"Footer\">\n <item name=\"itemIconTint\">#FFF</item>\n </style>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T23:33:22.267", "id": "33620", "last_activity_date": "2017-03-28T23:33:22.267", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "354", "parent_id": "33612", "post_type": "answer", "score": 2 } ]
33612
null
33620
{ "accepted_answer_id": null, "answer_count": 1, "body": "webのプログラミングとか、パソコンを動かすためのプログラミングとか、学ぼうと思ってズルズル引きずって来たので、何から始めたらいいですか? \nパソコンはfujitsuのintelのOS?はWindowsです \n高校生で商業科に通っています \nパソコンで使ったことがあるソフトウェアは、 \nエクセルとワードくらいです\n\n### 追記\n\n * 全体的にネットを動かしたい\n * webに関しては、あまりぱっとするイメージがありません\n * OS作ってみたいです!", "comment_count": 18, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T13:41:51.997", "favorite_count": 0, "id": "33613", "last_activity_date": "2017-05-19T04:30:59.693", "last_edit_date": "2017-03-28T15:45:04.483", "last_editor_user_id": "19110", "owner_user_id": "21247", "post_type": "question", "score": -4, "tags": [ "プログラミング言語" ], "title": "今からプログラミング始めるのですが何から始めたらいいですか", "view_count": 521 }
[ { "body": "(OSを作りたい、という前提のもとで回答します)\n\nオペレーティングシステム (OS)\nを作るためや、ネットワークのとても基礎的な部分をさわるためのプログラミング言語として古くから使われているのは、C言語のみでしょう。 \n正直はじめてのプログラミング言語としてはとっつきにくいですが、他を思いつきません。\n\nC言語を学ぶためのWeb上にある無料の日本語資料としては、たとえば[『苦しんで覚えるC言語』](http://9cguide.appspot.com/)があります。 \nこれが気に入らなければ、[『一週間で身につくC言語の基本』](http://c-lang.sevendays-\nstudy.com/)などの他のサイトや[書店で売っている書籍](https://www.amazon.co.jp/s/?field-\nkeywords=C%E8%A8%80%E8%AA%9E)、あるいは[ドット・インストールのC言語入門](http://dotinstall.com/lessons/basic_c)などの動画教材が参考になるでしょう。\n\nC言語をある程度読み書きできるようになったら、次のステップです。 \nOSを作るための基礎を学べる日本語の書籍としては[『30日でできる!\nOS自作入門』](https://www.amazon.co.jp/30%E6%97%A5%E3%81%A7%E3%81%A7%E3%81%8D%E3%82%8B-OS%E8%87%AA%E4%BD%9C%E5%85%A5%E9%96%80-%E5%B7%9D%E5%90%88-%E7%A7%80%E5%AE%9F/dp/4839919844)がおすすめです。 \nOSを作る中で、コンピュータでたくさんのアプリケーションを同時に動かしたり、メモリを管理したり、TCP/IPをはじめとするネットワークの処理をしたりなどするためにはどういうことが必要なのかということが学べることでしょう。 \nこの本が気に入らなければ、類書として[『12ステップで作る組込みOS自作入門』](https://www.amazon.co.jp/12%E3%82%B9%E3%83%86%E3%83%83%E3%83%97%E3%81%A7%E4%BD%9C%E3%82%8B%E7%B5%84%E8%BE%BC%E3%81%BFOS%E8%87%AA%E4%BD%9C%E5%85%A5%E9%96%80-%E5%9D%82%E4%BA%95-%E5%BC%98%E4%BA%AE/dp/4877832394)があります(ただし組み込みOSという分野なので普段使っているWindowsやmacOSとは少し異なるOSになります)。また、[「Linuxカーネル」で検索したら見つかる本](https://www.amazon.co.jp/s/field-\nkeywords=Linux%E3%82%AB%E3%83%BC%E3%83%8D%E3%83%AB)も、少し難しいですが参考になるかもしれません。\n\n全体的に難しいことだらけだとは思いますので、自分で考えるだけでは解決しないことが多々あると思います。そういった場合はまず色んな単語で検索してみましょう。それでも駄目だった場合は再びスタック・オーバーフローのような質問サイトを利用したり、詳しい知人に尋ねたりするのが良いと思います。\n\n* * *\n\n[おまけ]\n\nここから更に深く知りたい場合、少し毛色は違いますがIPA (情報処理推進機構)\nが主催するセキュリティ・キャンプの全国大会や地方大会でたまに開かれているOSにまつわる講座を見に行くと面白いでしょう。\n\n * [セキュリティ・キャンプ実施協議会](http://www.security-camp.org/index.html)\n * [セキュリティ・キャンプ 全国大会 2014 セキュアなシステムを作ろうクラス](http://www.ipa.go.jp/jinzai/camp/2014/zenkoku2014_kougi.html#section6)\n * [セキュリティ・キャンプ九州 in 福岡 2016 いじって壊して遊んでハッカーになろう](http://www.security-camp.org/minicamp/kyushu2016.html)\n * [セキュリティ・キャンプ 全国大会 2017 言語やOSを自作しよう](https://www.ipa.go.jp/jinzai/camp/2017/zenkoku2017_kougi.html#section7)\n\nあるいは、実際のOSのソースコードを眺めてみるのも面白いかもしれません。たとえばLinuxというOSの中心部分 (OSカーネル)\nのソースコードはここで見れます。\n\n * <https://github.com/torvalds/linux>\n\n[xv6](https://ja.wikipedia.org/wiki/Xv6)や[Minix](https://ja.wikipedia.org/wiki/Minix)などの教育用の小さいOSからはじめ、カーネルハックして遊ぶのも面白いかもしれません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T16:34:49.017", "id": "33617", "last_activity_date": "2017-05-19T04:30:59.693", "last_edit_date": "2017-05-19T04:30:59.693", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "33613", "post_type": "answer", "score": 5 } ]
33613
null
33617
{ "accepted_answer_id": null, "answer_count": 1, "body": "動画を紹介するアプリを作成しています。\n\nユーザーが気に入った動画をチェックボックスでチェックし、アプリを閉じてもチェック状態は保たれるようにしたいです。\n\nXMLファイルによってチェックボックスを表示させることはできますが、上記の機能を盛り込むにはどうすればよいのでしょうか。\n\n開発環境はAndroid Studio 、言語はJavaです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T18:39:38.247", "favorite_count": 0, "id": "33618", "last_activity_date": "2017-03-29T01:23:41.857", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21250", "post_type": "question", "score": 0, "tags": [ "android" ], "title": "アプリを消してもチェックボックスのチェックが消えないようにするには?", "view_count": 192 }
[ { "body": "方法としてはいくつかありますが、DBを使うのが一番良いでしょう。\n\n例えば、お気に入りテーブルを作成して管理をするようにします。\n\nチェックボックスをチェックされたらお気に入りテーブルにインサート。 \nチェックボックスからチェックを外された場合はお気に入りテーブルから削除します。 \nアプリを再起動した場合はお気に入りテーブルに登録されている動画のチェックボックスを初期表示でチェックするようにします。\n\nDBのライブラリはいくつかあるので、[ここ](https://www.gaprot.jp/pickup/tips/android-db-\nchoice)を参考に使いやすいものを選んでみてください。 \n私個人としてはRealmがオススメです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T01:23:41.857", "id": "33623", "last_activity_date": "2017-03-29T01:23:41.857", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21081", "parent_id": "33618", "post_type": "answer", "score": 2 } ]
33618
null
33623
{ "accepted_answer_id": null, "answer_count": 2, "body": "参考:[RuboCop | Style/FormatString -\nQiita](http://qiita.com/tbpgr/items/d11b28753dc893920db6)\n\n参考リンクにある通り、RuboCopで`%`を使うのをやめて`format`を使うようにメッセージを出力する方法があります。 \n同じように 配列の`hoge[1, 2]`を使うのをやめて`hoge.slice(1,2)`を使うようにさせることはできますか?\n\n`values_at`と混合しやすいため、sliceを使えという警告を出すことによって`values_at`のつもりで使ってしまっていたのに気づくやすくなると考えています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-28T22:52:18.883", "favorite_count": 0, "id": "33619", "last_activity_date": "2017-03-30T05:38:34.123", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "post_type": "question", "score": 0, "tags": [ "ruby" ], "title": "RuboCopで hoge[0, 1] の形式を警告させる方法", "view_count": 95 }
[ { "body": "もしそういうCopがあれば、[リポジトリをsliceで検索](https://github.com/bbatsov/rubocop/search?utf8=%E2%9C%93&q=slice)すれば、指摘メッセージの一部として存在するだろう、という予測の元に調べてみたら、ありませんでした。\n\nというわけで、今のところなさそうなので、Issueで提案するか自分でCopを書くか、でしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T01:06:55.883", "id": "33622", "last_activity_date": "2017-03-29T01:06:55.883", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17037", "parent_id": "33619", "post_type": "answer", "score": 0 }, { "body": "先に回答している方がおっしゃるとおり、そのようなCopは存在しません(ちなみに、CopというのはRuboCopにおけるルールの単位です)。\n\nまた、偽陽性の警告が非常に多くなると思われるため、そのようなCopを作成したとしても、RuboCop自身に含むことはないとおもいます。\n\n例えば、以下のように String クラスにも `[]` メソッドは定義されています。 \n<https://docs.ruby-lang.org/ja/latest/class/String.html#I_--5B--5D>\n\n```\n\n x = \"hoge\"\n x[1, 2] # => \"og\"\n \n```\n\nそのため、単純にコードを見ただけでは `hoge[1, 2]` は Array に対するメソッド呼び出しなのか String\nに対するものなのかが区別できないため、偽陽性の原因となってしまいます。\n\nそのため、RuboCop ではなく別のツールを使ってみてはいかがでしょうか? \n例えば querly というツールでは、このようなルールを手軽に自分で定義することが可能です。 \n<https://github.com/soutaro/querly>\n\n```\n\n # querly.yaml\n rules:\n - id: array.slice\n pattern: \"[](_, _)\"\n message: 'array[x, y] でなく、array.slice(x, y) を使用して下さい'\n before: 'array[x, y]'\n after: 'array.slice(x, y)'\n \n```\n\n上記の内容を`querly.yaml`として保存した上で、`querly check .`とコマンドを実行することで期待した検査を実行することが可能です。\n\nこのツールは Rubygems で配布されているため、`gem install querly`としてインストールすることが可能です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T05:38:34.123", "id": "33647", "last_activity_date": "2017-03-30T05:38:34.123", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21283", "parent_id": "33619", "post_type": "answer", "score": 2 } ]
33619
null
33647
{ "accepted_answer_id": null, "answer_count": 1, "body": "jenkinsでバッチの自動実行を設定したいです。\n\n**設定例**\n\n```\n\n 3/31(金) 22:00 実行 \n 4/01(土) 02:00 実行\n \n```\n\n曜日は無視していただいて構いません。\n\n上記のように月をまたぐような場合、どのように書けばよいのでしょうか?\n\n参考サイト \n[Jenkins ビルドトリガ(定期的に実行)設定についてのまとめ - Qiita](http://qiita.com/koara-\nlocal/items/79cb9c08e77ac9d94b1d)\n\nよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2017-03-29T01:06:15.597", "favorite_count": 0, "id": "33621", "last_activity_date": "2019-07-18T01:15:19.027", "last_edit_date": "2019-07-18T01:15:19.027", "last_editor_user_id": "3060", "owner_user_id": "13381", "post_type": "question", "score": 0, "tags": [ "jenkins" ], "title": "Jenkins で月をまたいだビルドトリガの設定を記述したい", "view_count": 326 }
[ { "body": "2行で表現すればどうでしょう。\n\n```\n\n # 3/31 22:00\n 0 22 31 3 *\n \n # 4/1 2:00\n 0 2 1 4 *\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T03:09:23.203", "id": "33628", "last_activity_date": "2017-03-29T03:09:23.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "33621", "post_type": "answer", "score": 2 } ]
33621
null
33628
{ "accepted_answer_id": "33639", "answer_count": 1, "body": "mongodにてスロークエリを出力することに関して質問させてください。 \n最近mongodでスロークエリを出力するために,ProfilingLevelを1に引き上げ、system.profileコレクションにスローログを出力するように設定しました。 \nこのスローログをarbiterでも閲覧したいと考え、 \n(1) system.profileに出力 \n(2) oplog.rsに(1)のオペレーションログを出力 \n(3) arbiterが(2)を同期する\n\nという流れを考えたのですが、(2)のoplog.rsに(1)のオペレーションログがうまく出力されません。 \nもしかして、oplog.rsにはsystem系のコレクションに対するオペレーションログは出力されないのでしょうか。(現状(1)に関しては、system.profileにちゃんと出力されるようになっています)\n\nすみませんがご教授のほどよろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T01:26:22.973", "favorite_count": 0, "id": "33624", "last_activity_date": "2017-03-29T13:15:14.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10222", "post_type": "question", "score": 0, "tags": [ "mongodb" ], "title": "oplog.rsにsystem系コレクションのオペレーションログを出力させたい。", "view_count": 121 }
[ { "body": "> もしかして、oplog.rsにはsystem系のコレクションに対するオペレーションログは出力されないのでしょうか。\n\n_local_ DBの全部と _system.profile_ だけはレプリケーションしないんです。\n\nsrc/mongo/db/repl/oplog.cppから\n\n```\n\n bool oplogDisabled(OperationContext* txn,\n ReplicationCoordinator::Mode replicationMode,\n const NamespaceString& nss) {\n if (replicationMode == ReplicationCoordinator::modeNone)\n return true;\n \n if (nss.db() == \"local\")\n return true;\n \n if (nss.isSystemDotProfile()) // == \"system.profile\"\n return true;\n \n if (!txn->writesAreReplicated())\n return true;\n \n fassert(28626, txn->recoveryUnit());\n \n return false;\n }\n \n```\n\nなぜならプライマリーのプロファイル結果はセコンダリーのと一致しないべきです。ハードウェア差、ランダムタイミングなどの理由で異なっています\n\ndb.setProfilingLevel()を実行したらそのMongoDBノードだけで _system.profile_\nを適用する仕組みがあるということです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T13:15:14.987", "id": "33639", "last_activity_date": "2017-03-29T13:15:14.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "113", "parent_id": "33624", "post_type": "answer", "score": 0 } ]
33624
33639
33639
{ "accepted_answer_id": "33636", "answer_count": 1, "body": "自作関数にてURLから取得するようにしたんですが \n以下の物は出来たのですが、それ以外に最終更新者、最終更新日を取得したいと思っています。 \nそれとURLと紐づけされたスクリプトエディタ?プロジェクトの中の○○○.gsのソースコードを抜き出し、そこに記載されいるURLの一部を抜き出したいのですが可能でしょうか?\n\nドキュメント名取得関数\n\n```\n\n function getDocumentName(url) {\n var URLNum = SpreadsheetApp.openByUrl(url);\n return(URLNum.getName());\n }\n \n```\n\nドキュメント所有者取得関数\n\n```\n\n function getDocumentOwner(url) {\n var URLNum = SpreadsheetApp.openByUrl(url);\n return(URLNum.getOwner().getEmail());\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T04:29:50.727", "favorite_count": 0, "id": "33629", "last_activity_date": "2017-03-29T11:44:49.863", "last_edit_date": "2017-03-29T08:35:28.490", "last_editor_user_id": null, "owner_user_id": "21256", "post_type": "question", "score": 0, "tags": [ "google-apps-script", "google-spreadsheet" ], "title": "スプレッドシートから情報取得関数について", "view_count": 1245 }
[ { "body": "SpreadSheet API内には見つかりませんでしたね・・・ \n最終更新日時に関してはDriveAppsAPIを併用してこんな感じでしょうか\n\n```\n\n id = SpreadsheetApp.openByUrl(url).getId();\n last = DriveApp.getFileById(id).getLastUpdated();\n \n```\n\n最終日時に関してはAppsScript内には見つけられませんでした。 \nREST経由でとる方法なら以下が紹介されていますが・・・ \n<https://stackoverflow.com/questions/28017673/google-apps-script-drive-file-\nhow-to-get-user-who-last-modified-file>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T11:44:49.863", "id": "33636", "last_activity_date": "2017-03-29T11:44:49.863", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "19716", "parent_id": "33629", "post_type": "answer", "score": 0 } ]
33629
33636
33636
{ "accepted_answer_id": "33638", "answer_count": 1, "body": "rubyの文に直書きでクエリを書き、そのdbからもってきた文字列を条件にかけて検索しようとしているのですが、持って来ている値が同じに関わらず、if文で条件がtrueになりません。 \n下記のようなコードなのですが、どこがおかしいのかご教授いただけないでしょうか? \n条件の部分は、一番下の行の箇所となります。\n\n```\n\n $db = Mysql2::Client.new(:host => 'localhost', :user => 'root', :password => '')\n usedb = $db.query(%q{use ruby_nfcpy;})\n \n $select_column = $db.query(%q{select id, name, idm, status from users;})\n $select_name = $db.query(%q{select name from users;})\n $select_idm = $db.query(%q{select idm from users;})\n $select_status = $db.query(%q{select status from users;})\n \n loop do\n unlock_user_id = idm(nfc)\n \n p unlock_user_id\n $select_idm.each do |user|\n user.each do |key, value|\n p value.to_i\n if value == unlock_user_id\n \n```\n\npメソッドで表示したクエリの文字列は以下のようになります。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/fYe9f.png)](https://i.stack.imgur.com/fYe9f.png)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T09:03:55.443", "favorite_count": 0, "id": "33633", "last_activity_date": "2017-03-29T13:14:26.987", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "13491", "post_type": "question", "score": 0, "tags": [ "ruby", "mysql" ], "title": "rubyにクエリを書き、持って来た文字列が条件検索に失敗する", "view_count": 146 }
[ { "body": "`p value.to_i` しているのに比較のときは`.to_i`していないのが気になります。 \n比較しているもの通しのクラスは同じでしょうか?\n\n```\n\n a = 1\n b = \"1\"\n \n p (a == b) #=> false\n \n```\n\n以下のように正しく比較できるように型を合わせてください。\n\n```\n\n a = 1\n b = \"1\"\n \n p (a == b.to_i) #=> true\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T13:14:26.987", "id": "33638", "last_activity_date": "2017-03-29T13:14:26.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "parent_id": "33633", "post_type": "answer", "score": 1 } ]
33633
33638
33638
{ "accepted_answer_id": "34356", "answer_count": 2, "body": "Windows Formアプリケーション(.Net C#)をwindowsパソコンにインストールして利用して頂く際に \nライセンス管理をしたいと考えています。\n\nアプリケーションの仕様 \n・windows 7/8/10上での動作を想定 \n・windowsサーバに接続してアプリケーションで利用するデータを取得する。(WCFを検討)\n\nライセンス管理方法案 \n・インストールできる台数を制限する。 \n・サーバに同時接続できるアプリ数を制限する。 \n・ClickOnceのテクノロジーでダウンロード数の制限をかける。\n\nサーバで管理する、ローカルで制御するなど方法はいろいろあるかと存じますが、 \n何か良い方法をご存知の方がおりましたら、 \n参考URL等の情報でも構いませんのでご教示頂きたく、よろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T09:52:58.873", "favorite_count": 0, "id": "33635", "last_activity_date": "2017-04-28T12:20:56.267", "last_edit_date": "2017-03-30T09:09:49.553", "last_editor_user_id": "9228", "owner_user_id": "9228", "post_type": "question", "score": 1, "tags": [ "c#" ], "title": "Windows Formアプリケーション(C#)のライセンス管理で良い方法はありますか?", "view_count": 2701 }
[ { "body": "ライセンス管理するということは、ライセンス対価、つまり課金処理と連動すると思うのですが。しかし、質問はライセンスに終始している点が気になります。\n\n課金体系を設計すれば、自ずとライセンス管理も定まりませんか? (クライアントインストール数なのか同時接続数なのか等)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T09:23:02.767", "id": "33654", "last_activity_date": "2017-03-30T09:23:02.767", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "33635", "post_type": "answer", "score": 1 }, { "body": "お目汚しでございますが(実績に基づいた回答はできていません)、メモ程度の内容を記載します。実際に利用するには追加調査等が必要です。\n\nライセンス管理について: \n資料を見かけた程度の情報しかありませんが、.NET Framework が提供するLicenseManagerというクラスがあるようです。 \nそのほかの解決策として、あまり高額ではないソフトウェアでファイルベースのライセンス認証を行うコードなどが以下のサイトにありました。ライセンスファイルをWCFを利用してネットワーク経由で取得するというのも良いでしょう。 \n<https://stackoverflow.com/questions/3624149/license-for-c-sharp-desktop-\napplication>\n\n同時利用制限について: \n利用時の制限については、WCFで可能のように思います。注意点としては同時接続数の管理や、セキュリティを適用する(不特定多数からのアクセス)場合、公的証明機関から証明書の取得が必須になることです。 \nオフラインで同時利用制限を課したい場合は、ライセンスサーバーを準備させるか、ハードウェアキーでの制限が考えられます。\n\nライセンス回避の対策: \nソフトウェアという資源のため、ライセンス認証を回避されることがあります(逆アセンブル等をされやすい)。費用が掛かりますがハードウェアキーを利用する等の対策をとることも可能です。 \n一般的には難読化や、ネイティブコードへの変換が考えられます。併せて、複数のDLLから成るソフトウエアであるのならば署名を追加することでDLL入れ替えを防ぐことは可能と考えています(このときアセンブリバージョンの変更は要注意)。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-28T12:20:56.267", "id": "34356", "last_activity_date": "2017-04-28T12:20:56.267", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "882", "parent_id": "33635", "post_type": "answer", "score": 2 } ]
33635
34356
34356
{ "accepted_answer_id": null, "answer_count": 0, "body": "```\n\n from sympy import *\n var('x y a b z')\n expr1 = x*y + x - 3 + 2*x**2 - z*x**2 + x**3\n print(collect(expr1, x))\n expr2=a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n print(collect(expr2, x))\n #x**3 + x**2*(-z + 2) + x*(y + 1) - 3\n #a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n #4*x**3+4*a*x**2+ x*(b - 3)-a\n \n```\n\nexpr1は、うまくいきますが、 \nexpr2は、うまくいきません。 \nよろしくお願いします。\n\n追加情報 \nmetropolis様 \nありがとうございます。\n\n①expandしてみました。 \n②Wolfram|Alphaで実行してみました。 \n4*x**3から、始まりませんでした。何か規則がありますか?\n\n```\n\n from sympy import *\n var('x a b')\n expr2=a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n print(expr2)\n print(collect(expand(expr2),x))\n # a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n # 2*a*x**2 - a + 4*x**3 + x*(b - 3)\n \n```\n\n(参考)Wolfram|Alpha: Computational Knowledge Engine \n<https://www.wolframalpha.com/input/?i=Collect%28a%2a%282%2ax%2a%2a2-1%29%2b4%2ax%2a%2a3%2bx%2a%28b-3%29%29>", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T13:29:18.880", "favorite_count": 0, "id": "33640", "last_activity_date": "2017-10-17T06:58:30.990", "last_edit_date": "2017-10-17T06:58:30.990", "last_editor_user_id": "754", "owner_user_id": "17199", "post_type": "question", "score": 0, "tags": [ "python", "sympy" ], "title": "sympyのcollectの使い方を教えて下さい", "view_count": 430 }
[]
33640
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "私はVisualStudio2015でsvmlightを使い、プログラムを書いています。\n\nここにあるソースを用いました。 \n<https://github.com/DaHoC/trainHOG> \nしかしコンパイルしようとしてもsvmlight.hから以下のようなエラーが出てしまいます。\n\n* * *\n```\n\n エラー (アクティブ) \"WORD\" があいまいです Get_Car_Information c:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\svmlight\\svmlight.h 137 \n エラー C2872 'WORD': あいまいなシンボルです。 Get_Car_Information c:\\users\\kanazashi\\documents\\get_car_information\\get_car_information\\svmlight\\svmlight.h 137 \n エラー C2440 '=': 'svmlight::WORD' から 'WORD' に変換できません。 Get_Car_Information c:\\users\\kanazashi\\documents\\get_car_information\\get_car_information\\svmlight\\svmlight.h 140 \n エラー C2228 '.weight' の左側はクラス、構造体、共用体でなければなりません Get_Car_Information c:\\users\\kanazashi\\documents\\get_car_information\\get_car_information\\svmlight\\svmlight.h 141 \n エラー C2228 '.wnum' の左側はクラス、構造体、共用体でなければなりません Get_Car_Information c:\\users\\kanazashi\\documents\\get_car_information\\get_car_information\\svmlight\\svmlight.h 141 \n \n```\n\n* * *\n\nこのエラーの解決方法が分かりません。 \n<https://stackoverflow.com/questions/14765698/errors-in-using-svmlight-on-\nvisual-studio> \nここにある回答を読み、解決を試みました。 \n具体的には、WORDのあいまいさを回避するため、svmlight::wordと書き直しました。 \nしかし、回答者の言う「いくらかのリンクのエラー」が発生してしまい、その解決法もわかりません。 \nそのエラーも以下に記載します。\n\n* * *\n```\n\n エラー LNK2019 未解決の外部シンボル free_example が関数 \"private: virtual __cdecl SVMlight::~SVMlight(void)\" (??1SVMlight@@EEAA@XZ) で参照されました。 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\learnSVM.obj 1 \n エラー LNK2019 未解決の外部シンボル free_model が関数 \"private: virtual __cdecl SVMlight::~SVMlight(void)\" (??1SVMlight@@EEAA@XZ) で参照されました。 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\learnSVM.obj 1 \n エラー LNK2019 未解決の外部シンボル read_documents が関数 \"public: void __cdecl SVMlight::read_problem(char *)\" (?read_problem@SVMlight@@QEAAXPEAD@Z) で参照されました。 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\learnSVM.obj 1 \n エラー LNK2019 未解決の外部シンボル my_malloc が関数 \"private: __cdecl SVMlight::SVMlight(void)\" (??0SVMlight@@AEAA@XZ) で参照されました。 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\learnSVM.obj 1 \n エラー LNK2019 未解決の外部シンボル svm_learn_regression が関数 \"public: void __cdecl SVMlight::train(void)\" (?train@SVMlight@@QEAAXXZ) で参照されました。 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\learnSVM.obj 1 \n エラー LNK2019 未解決の外部シンボル kernel_cache_cleanup が関数 \"private: virtual __cdecl SVMlight::~SVMlight(void)\" (??1SVMlight@@EEAA@XZ) で参照されました。 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\learnSVM.obj 1 \n エラー LNK2019 未解決の外部シンボル write_model が関数 \"public: void __cdecl SVMlight::saveModelToFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)\" (?saveModelToFile@SVMlight@@QEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) で参照されました。 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\learnSVM.obj 1 \n エラー LNK2001 外部シンボル \"verbosity\" は未解決です。 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\Get_Car_Information\\learnSVM.obj 1 \n エラー LNK1120 8 件の未解決の外部参照 Get_Car_Information C:\\Users\\Kanazashi\\Documents\\Get_Car_Information\\x64\\Debug\\Get_Car_Information.exe 1 \n \n```\n\n* * *\n\n完全に私の知識不足ですが、どなたか解決方法を教えていただきたいです。 \nよろしくお願いします。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T13:48:41.693", "favorite_count": 0, "id": "33641", "last_activity_date": "2017-03-29T16:38:52.500", "last_edit_date": "2017-05-23T12:38:56.083", "last_editor_user_id": "-1", "owner_user_id": "21277", "post_type": "question", "score": 1, "tags": [ "c++", "visual-studio", "opencv", "機械学習" ], "title": "VisualStudioでsvmlightを使いたいのですがエラーが発生してしまいます。", "view_count": 263 }
[]
33641
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "既存のiosアプリでadmobを使用しています。 \nsdkを最新にしたところ、firebase analyticsのフレームワークももれなく入れることになり、 \n折角なのでAnalyticsの機能も使ってみようと、現在設定中です。 \nGoogleService-Info.plistをプロジェクトに追加し、以下のコードをAppDelegateクラスに追加してみました。\n\n```\n\n import FirebaseAnalytics //追加\n func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {\n \n //〜省略〜\n \n FIRApp.configure() //追加\n return true\n }\n \n```\n\n↓のサイトでは`verbatim`や`endverbatim`の記述もあるのですが、これらを入れるとエラーになるので外しているのですが、`verbatim`とは何でしょうか? \n外した状態でビルドはできているのですが、この他に記述すべきコード等があればお教えください。\n\n<https://firebase.google.com/docs/analytics/ios/start> \n[![アプリにAnalyticsを追加する](https://i.stack.imgur.com/MNvXR.png)](https://i.stack.imgur.com/MNvXR.png)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-29T16:29:10.847", "favorite_count": 0, "id": "33642", "last_activity_date": "2017-03-30T15:15:49.723", "last_edit_date": "2017-03-30T15:15:49.723", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 1, "tags": [ "swift", "ios", "firebase" ], "title": "Firebase Analyticsの設定における`verbatim`とは?", "view_count": 163 }
[]
33642
null
null
{ "accepted_answer_id": "33653", "answer_count": 4, "body": ".classNameはメソッドではなく、プロパティなので下記のように引数ではなく代入をするというのはわかったのですが、メソッドなのかプロパティなのかすべて覚えるのは非常に困難だと思います。 \n何か区別する方法はないのでしょうか? \n無限にあるメソッド、プロパティを毎度調べて今回はメソッドだったので()か、プロパティだったので=で代入かと判断するしかないのでしょうか?\n\n```\n\n const inputElement = document.createElement(\"input\");\n \n // 正:\n inputElement.className = \"alert-time\";\n \n // 誤: TypeError: inputElement.className is not a function\n inputElement.className('alert-time');\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T07:29:43.803", "favorite_count": 0, "id": "33649", "last_activity_date": "2017-04-01T06:14:21.480", "last_edit_date": "2017-04-01T06:14:21.480", "last_editor_user_id": "3054", "owner_user_id": "20834", "post_type": "question", "score": 4, "tags": [ "javascript" ], "title": "メソッドなのかプロパティなのかすべて覚えるのは非常に困難だと思います。 何か区別する方法はないのでしょうか?", "view_count": 713 }
[ { "body": "JavaScriptに限らず、扱う対象がどういったものなのかは常に考える必要があります。\n\n例えば[createElement()](https://developer.mozilla.org/ja/docs/Web/API/Document/createElement)で生成されるものはMDNのドキュメントを見ると[Element](https://developer.mozilla.org/ja/docs/Web/API/Element)オブジェクトであることがわかると思います。 \nElementオブジェクトのプロパティに何があるかはドキュメントに記載されていますし、メソッドも記載されています。 \nこれらのドキュメントを確認する癖をつけておいたほうが良いでしょう。 \n慣れてくればよく利用するものは自然に覚えますし、わからないものはドキュメントを確認すれば良いのです。\n\n* * *\n\nまた、プログラム上で判断する必要がある場合は、[typeof演算子](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/typeof)を利用することができます。\n\n```\n\n if (typeof Math.sin === 'function') {\n // Math.sinはfunctionオブジェクトです\n }\n \n```\n\njQueryやUnderscore(lodash)などのライブラリを使用されているのであれば`jQuery.isFunction()`や`_.isFunction`のように判定用のメソッドが用意されています。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T08:13:26.743", "id": "33651", "last_activity_date": "2017-03-30T08:13:26.743", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20272", "parent_id": "33649", "post_type": "answer", "score": 1 }, { "body": "定義されているClass/method/propertyは確かに膨大な量がありますが、 \nプログラマがコーディングする分の使用Classはプログラマが意識している分だけですので \n各APIの使用方法に関しては都度API Referenceを見るべきかと思います。\n\nが、APIの大体の使用方法が把握済みで型の細かい所だけうろ覚えということであるならば \nIDEツールにて補完してもらうのが良いと思います。 \nVisualStudio/Eclipse/WebStorm...等 \n色々ありますので \njavascript IDE 補完 \nなんかでググって頂くとよいかと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T08:18:22.987", "id": "33652", "last_activity_date": "2017-03-30T08:18:22.987", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19716", "parent_id": "33649", "post_type": "answer", "score": 3 }, { "body": "一般的にメソッド名は動詞か、動詞から始まる命令文になります。対してプロパティは名詞であることが多いです。極端なこと言えば get, set, has,\nadd, remove, create, insert で始まる名前は大体メソッドです。(他に request, send, close など…) \nただし例外もありますし、外部ライブラリの場合はそうでない命名規則であることが多々ありますので、それについては個々に判断が必要です。こればっかりはリファレンスを見るなどの習慣で慣れてください。\n\nまた、そういったメソッドやプロパティを正確に覚えなくても良い方法として、静的解析付きコード補完というものがあります。これに対応した開発環境であれば入力時にメソッドやプロパティの仕様情報などの支援を受けられます。 \n詳細は「JavaScript コード補完」で検索してみてください。\n\n追記: \nSublimeText3であれば、[Tern for\nSublime](https://github.com/ternjs/tern_for_sublime)を使えばコード補完できます。 \nPackage Controlに未対応なので、手動で導入してください。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T08:26:37.913", "id": "33653", "last_activity_date": "2017-03-30T17:40:58.787", "last_edit_date": "2017-03-30T17:40:58.787", "last_editor_user_id": "19925", "owner_user_id": "19925", "parent_id": "33649", "post_type": "answer", "score": 2 }, { "body": "JavaScriptにおいてメソッドは「関数であるプロパティ」の事です([参考](https://www.ecma-\ninternational.org/ecma-262/7.0/index.html#sec-\nmethod))。メソッドはプロパティの一種であり、プロパティとして扱えます。メソッドで **も**\nあるプロパティとメソッドではないプロパティをコードで区別するには関数であるかどうか(`typeof`で`\"function\"`を返すか、つまり、呼び出し(Call)できるか)を見るしかありません。\n\n基本的にはあるオブジェクトにどんなプロパティやメソッドがあるかを見るには、APIリファレンスを眺めるしかありません。じゃあ、みんなリファレンスの内容を覚えているとか、ということではありません。色々工夫して、APIリファレンスを素早く引けるようにしているだけです。リファレンスを見ないと選択肢は存在しません。\n\nといっても、エディタやIDEで補完してくれたり、説明が出たり、時にはリファレンスへのリンクまで表示されたら便利です。そういう機能は無いのかと言われると、各エディタやIDEであると言えばあるのですが、完璧にはできません。なぜなら、JavaScriptは動的型付き言語であり、変数の型が不明だからです。\n\n下記のような関数を作ろうとしたとします。\n\n```\n\n function f(e) {\n if (!e.hasAttribute('lang')) {\n e.setAttribute('lang', 'ja');\n }\n e.classList.add('has-lang');\n return e.className;\n }\n \n```\n\n仮引数である`e`は[Element](https://developer.mozilla.org/ja/docs/Web/API/Element)であることを期待していますが、この関数からそれを完全に予測することはできません。`f()`を呼び出している全てから推測すれば良いと言っても、呼び出し側が未実装だったり、別ファイルだったりした場合があるため、現実的ではありません。そのため、`e`に対して`setAttribute()`というメソッドがあるとか、`className`というプロパティがあるとかを常に完全に補完してくれるようなものは存在しません(前後からある程度予測はしてくれる場合はありますが)。これは、動的型付き言語の欠点の一つでもあります。\n\nでは、どうすれば良いのかというと静的型付けにしてしまえば良いのです。有名なのはTypeScriptとFlowでしょう。少なくともTypeScriptの場合、Visual\nStuido CodeとAtomで補完候補が出て、プロパティかメソッドかがわかるようになっています(Sublime\nTextは持っていないのでわかりません)。\n\nTypeScriptをVisual Studio Codeでコーディングしたときの様子\n\n[![Visual Studio\nCodeで補完される様子](https://i.stack.imgur.com/KhuXW.gif)](https://i.stack.imgur.com/KhuXW.gif)\n\n`function f(e: Element)\n{...`と`e`がElementであることを指定しているため、完全な予測が可能であり、補完でもメソッドなのかプロパティなのかがわかるようになっています。\n\nもし、補完を楽にしたい、補完時にメソッドなのかメソッドではないのかをはっきりさせたいというのであれば、JavaScriptではなくTypeScript等の静的型付き言語を検討してください。", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T22:51:20.660", "id": "33683", "last_activity_date": "2017-04-01T01:33:32.713", "last_edit_date": "2017-04-01T01:33:32.713", "last_editor_user_id": "7347", "owner_user_id": "7347", "parent_id": "33649", "post_type": "answer", "score": 6 } ]
33649
33653
33683
{ "accepted_answer_id": "33671", "answer_count": 1, "body": "開発するにあたって使用しているECMAScript6の各Classやmethodが各ブラウザに対応しているかどうか確認したいのですが\n\nWEB UIにては \n<http://kangax.github.io/compat-table/es6/> \nのサイトを使用すれば一つ一つ確認はとれるようなのですが \n手作業でひとつひとつ上記サイトにてチェックすることになりそうです。\n\nそうではなくローカルで組んだscript等を使用して自動的に確認する方法を取りたく思っています。\n\nCan I useサイトに関しては \n<https://github.com/Fyrd/caniuse> \nにてCan I useで使用している情報がjsonで提供されているので \n上記目的が実現可能なのですがECMAScript6の情報に関しては網羅されていないように見えます。 \n(WEB UI版Can I Useでもhttp://kangax.github.io/compat-table/es6/にリダイレクトされるようです。)\n\nECMAScriptに関して各ブラウザの対応状況を確認できるような \nデータ / REST等のWEB API / もしくはツールそのもの \nをご存知であればご教示いただきたく思います。\n\n* * *\n\n追記: \n<https://github.com/kangax/compat-table> \nにkangax氏のcompat-table/es6の元ソースがありそうでした。\n\nただしあるのは \ndata-es6.js:各ブラウザで検証するためのECMAScript6検証用ソース \ncompat-table/es6/index.html:上記を実行した結果のHtml \nで \ndata-es6.jsの実行結果がjsonなりxmlなりのprimitiveなデータであれば都合がよかったのですが \nViewつきのindex.htmlしかないように見えました・・・\n\nindex.htmlをスクレイピングするしかないのでしょうか・・・", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T07:58:58.237", "favorite_count": 0, "id": "33650", "last_activity_date": "2017-03-31T10:38:47.957", "last_edit_date": "2017-03-31T05:07:28.920", "last_editor_user_id": "19716", "owner_user_id": "19716", "post_type": "question", "score": 3, "tags": [ "javascript", "ecmascript-6" ], "title": "JavaScriptの各ブラウザ対応状況のチェック方法", "view_count": 3049 }
[ { "body": "コメント欄にてunaristさんから頂いた情報の通りとなりますが\n\n<https://babeljs.io/docs/plugins/preset-env/> \nにてkangax‌​/compat-tableを元に定期生成されているものが \n<https://github.com/babel/babel-preset-env/blob/master/data/built-ins.json> \nにて参照可能なようです。\n\n```\n\n \"es6.promise\": {\n \"chrome\": 51,\n \"edge\": 13,\n \"firefox\": 45,\n \"safari\": 10,\n \"node\": 6.5,\n \"ios\": 10,\n \"opera\": 38,\n \"electron\": 1.2\n },\n \n```\n\nの形にて「対応しているクライアント」が確認可能です。 \n(実際はAndroidなどではPromiseは使用可能ですが、Feature中使用不可能なものがひとつでもあると「非サポート」扱いになっているようで、AndroidはPromise中の \n\"Promise.race, generic iterables\"が非サポートになっています。)\n\nメソッド単位の情報は上記jsonにはないようですが、今はそのレベルまでのチェックは必須でないのと \n必須になった場合は \n<https://github.com/babel/babel-preset-env/blob/master/scripts/build-data.js> \nを参考にする等してAPI単位でとれるように検討します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T10:38:47.957", "id": "33671", "last_activity_date": "2017-03-31T10:38:47.957", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19716", "parent_id": "33650", "post_type": "answer", "score": 2 } ]
33650
33671
33671
{ "accepted_answer_id": "33662", "answer_count": 1, "body": "GAEよりDataStoreを使用し、エンティティ中の文字列の部分一致したレコードを取り出したいのですが \n検索し、色んなサイト様を見ますと「部分一致は無理、前方一致なら可能」と記載されているサイトは割と見つかるのですが \n具体的な方法が書かれているサイトが見つかりません。\n\nGCPコンソール上でも文字列の前方一致が行えるようなUIは見当たりませんし \nGAE/Go側にて\n\n```\n\n datastore.NewQuery(kind).Filter(\"Hoge>=\", hoge).GetAll(ctx, &fuga)\n \n```\n\nのようにしてしまうと \n目的文字列の文字コードより後ろに出現する文字コードから始まるエンティティもマッチしてしまいます。 \n例えば\"<http://10>\"で検索すると\"<http://11>....\"も引っかかってしまいます\n\n「前方一致が可能」と言われているのは、上記のような余計なレコード込で前方一致可能、という意味なのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T09:49:54.637", "favorite_count": 0, "id": "33655", "last_activity_date": "2017-03-31T03:11:44.127", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19716", "post_type": "question", "score": 0, "tags": [ "google-app-engine", "google-cloud" ], "title": "DataStoreでの文字列前方一致の方法", "view_count": 1013 }
[ { "body": "例えば'abc'から前方一致で検索したい場合は、 \n`Hoge >= \"abc\"` \nと \n`Hoge < \"abc\" + \"\\ufffd\"` \nの条件を組み合わせれば検索できます。\n\nコード↓ \n`datastore.NewQuery(kind).Filter(\"Hoge>=\", hoge).Filter(\"Hoge<\",\nhoge+\"\\ufffd\").GetAll(ctx, &fuga)`", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T02:57:02.157", "id": "33662", "last_activity_date": "2017-03-31T03:11:44.127", "last_edit_date": "2017-03-31T03:11:44.127", "last_editor_user_id": "7282", "owner_user_id": "7282", "parent_id": "33655", "post_type": "answer", "score": 1 } ]
33655
33662
33662
{ "accepted_answer_id": "33658", "answer_count": 1, "body": "URLが\n\n```\n\n // http://wonderland.com/street/愛媛県\n app.get(/^\\/street\\/.{1,50}$/)\n console.log(req.params[0])\n // 愛媛県\n // パスが通る\n \n```\n\nとなる場合はOKですが、 \n下記のようにもし`/id/数値`が入っていても処理するにはどうすればよいでしょうか?\n\n```\n\n // http://wonderland.com/street/Улаанбаатар/id/1230515654\n app.get(/^\\/street\\/(.{1,50}$)(\\/id\\/([0-9]{1,3}$))?$/)\n console.log(req.params[0])\n // Улаанбаатар/id/1230515654\n // 4桁以上でもパスが通ってしまう\n \n```\n\nやりたいことは\n\n```\n\n /street/(記号以外の日本語や英語、数字、外国語50文字以内)\n /street/(記号以外の日本語や英語、数字、外国語50文字以内)/id/(数字3桁)\n \n```\n\nです。なるべくセキュアにしたいのですがstreetのあとの文字列は\\w{1,50}では都合がわるかったのでドットを使用しました。\n\n> `\\w` \n> 単語に使用される任意の文字と一致します。アンダースコアも含まれます。'[A-Za-z0-9_]' と同じ意味になります。\n>\n> `.` \n> \"\\n\" を除く任意の 1 文字に一致します。'\\n' など、任意の文字と一致するには、'[.\\n]' などのパターンを指定します。\n\nまた、正規表現を使うとややこしうなるので`req.params.name :name`などは使用しておりません。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T15:56:56.407", "favorite_count": 0, "id": "33657", "last_activity_date": "2017-03-30T17:10:18.760", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7973", "post_type": "question", "score": 0, "tags": [ "node.js", "正規表現" ], "title": "NodeJS Express 正規表現 何桁でもパスが通ってしまう", "view_count": 667 }
[ { "body": "※ コメント欄からの転記になります(一部文言を変更)\n\nセパレータが `/` ですので、\n\n```\n\n /^\\/street\\/([^/]{1,50})(\\/id\\/([0-9]{1,3}))?$/\n \n```\n\nとしてみてはどうでしょう。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-30T17:10:18.760", "id": "33658", "last_activity_date": "2017-03-30T17:10:18.760", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "33657", "post_type": "answer", "score": 1 } ]
33657
33658
33658
{ "accepted_answer_id": null, "answer_count": 2, "body": "動作はしているのですが,メモリを無駄に使用量しているのは明らかですし,他にもっと良い方法があると思うのです. \n知識を貸していただけないでしょうか.したいことは \ndata.generate.mu_sigma() \nようにパラメータを生成したり,変更したりして \ndata.mu \nとしてデータの参照することです.\n\n理由は \ndata.generate_mu_sigma(self) \nというような方法では,予測補間での検索が大変なことや, \ndata.generate. \ndata.generate2. \nなどを作って別な生成方法を試したりしたいからです\n\n.pyファイルでモジュールとしてあつかえばいいかなとも思いましたが,オブジェクトとして値が保持されなかったりするのかなと考えたりしてしまします.\n\n他にもcの構造体のように型をだけを宣言するクラスと,処理を主に扱うクラスをまとめたクラスなどをつくれたら,うれしいなと思うのですが,不可能でしょうか.\n\nよろしくお願いします.\n\n```\n\n import numpy as np\n class test_data:\n def __init__(self,n_samples,dim):\n class generate:\n def __init__(self,n_samples,dim):\n self.n_samples = n_samples\n self.dim = dim\n self.mu = 0.0\n self.sigma = 0.0\n \n def mu_sigma(self):\n self.mu = np.random.uniform(low=-2.0, high=2.0, size=self.dim)\n self.sigma = np.random.uniform(low=1.0, high=2.0, size=self.dim)\n \n self.n_samples = n_samples\n self.dim = dim\n self.generate = generate(n_samples,dim)\n self.generate.mu_sigma()\n self.mu = self.generate.mu\n self.sigma = self.generate.sigma\n \n data=test_data(n_samples=10,dim=2)\n print(data.generate.mu)\n print(data.mu)\n \n```\n\n結果 \n[ 0.97730724 1.0678634 ] \n[ 0.97730724 1.0678634 ]", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T00:17:23.723", "favorite_count": 0, "id": "33659", "last_activity_date": "2017-03-31T09:18:17.690", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21291", "post_type": "question", "score": 0, "tags": [ "python", "python3" ], "title": "pythonのクラス内クラスについて", "view_count": 8265 }
[ { "body": "なぜクラス内にクラスを定義したいのかよくわかりません。普通に2つのクラスを定義して、test_dataのクラスから、内部に持つgenerateクラスに処理を委譲すれば良いのではないでしょうか。\n\n```\n\n import numpy as np\n \n class GenerateData:\n \n def __init__(self, n_samples, dim):\n self.n_samples = n_samples\n self.dim = dim\n \n @property\n def mu(self):\n return np.random.uniform(low=-2.0, high=2.0, size=self.dim)\n \n @property\n def sigma(self):\n return np.random.uniform(low=-2.0, high=2.0, size=self.dim)\n \n class TestData:\n \n def __init__(self, n_samples, dim):\n self.generate_data = GenerateData(n_samples, dim)\n \n @property\n def mu(self):\n return self.generate_data.mu\n \n @property\n def sigma(self):\n return self.generate_data.sigma\n \n test = TestData(n_samples=10, dim=2)\n \n print(test.mu)\n print(test.sigma)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T08:46:38.303", "id": "33667", "last_activity_date": "2017-03-31T08:46:38.303", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2168", "parent_id": "33659", "post_type": "answer", "score": 1 }, { "body": "参考までに、inner class の代わりに named tuple を返す関数を使う方法などを。\n\n```\n\n import collections\n import numpy as np\n \n class test_data:\n def __init__(self, n_samples, dim, generator):\n self.n_samples = n_samples\n self.dim = dim\n self.generate = generator(n_samples, dim)\n self.mu = self.generate.mu\n self.sigma = self.generate.sigma\n \n def generator(n_samples, dim):\n generate = collections.namedtuple('generate', ['mu', 'sigma'])\n return generate(\n mu = np.random.uniform(low=-2.0, high=2.0, size=dim),\n sigma = np.random.uniform(low=1.0, high=2.0, size=dim))\n \n data = test_data(n_samples=10, dim=2, generator=generator)\n \n print(data.generate.mu)\n print(data.mu)\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T09:18:17.690", "id": "33669", "last_activity_date": "2017-03-31T09:18:17.690", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "33659", "post_type": "answer", "score": 2 } ]
33659
null
33669
{ "accepted_answer_id": "33668", "answer_count": 1, "body": "Swift初学者ですが、データ保存にRealmの利用してアプリを開発しようと思っています。\n\nRealmで保存したデータを読み出す際、Stringの項目に対して「○○以降」という抽出をかけたいのですが、 \nfilterで比較演算子”>=”を記述したところ、下記エラーとなりました。\n\n```\n\n class realmLog: Object {\n dynamic var stringItem = String() //項目をStringで宣言\n }\n \n ・・・\n \n /* 抽出結果の取得 */\n let realmRec = realm.objects(realmLog.self).filter(\"stringItem >= \\\"\\(Condition)\\\"\")\n \n```\n\n> 'Invalid operator type', reason: 'Operator '>=' not supported for string\n> type'\n\nRealmでString項目に対し「○○以降」という抽出をかけるにはどのように記述すればよいのでしょうか。\n\nあるいはRealmで一旦全件抽出を行い、別途抽出結果に対して「○○以降」という条件で読み飛ばすような処理を記述すべきでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T01:31:37.947", "favorite_count": 0, "id": "33660", "last_activity_date": "2017-03-31T08:47:50.997", "last_edit_date": "2017-03-31T06:03:02.343", "last_editor_user_id": "76", "owner_user_id": "21293", "post_type": "question", "score": 0, "tags": [ "swift", "realm" ], "title": "Stringの大小比較の方法について", "view_count": 599 }
[ { "body": "Stringのプロパティに対して大小比較はできないので、代わりにソートして上から(もしくは下から)使うのが良いと思います。\n\n```\n\n let realmRec = realm.objects(realmLog.self).sorted(byKeypath: \"stringItem\")\n \n```\n\n^ Realmは遅延ロードが自動的に働くので、抽出しなくても実際に使った(アクセスした)ぶんだけのメモリ消費しかありません。\n\nあと、filterの条件をSwiftのString Interpolationを使ってますが、一般的にString\nInterpolationをクエリの組み立てなど重要な部分に使用するのはバグの元なので、NSPredicateの置き換えを利用して、\n\n```\n\n .filter(\"stringItem >= %@\", Condition)\n \n```\n\nと書いてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T08:47:50.997", "id": "33668", "last_activity_date": "2017-03-31T08:47:50.997", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "33660", "post_type": "answer", "score": 0 } ]
33660
33668
33668
{ "accepted_answer_id": "33664", "answer_count": 1, "body": "rbenv をビルドして、rubyをインストールしようと思っています。\n\nubuntu16.04のイメージを使用して、rbenvをgithubからとってきて、ビルドし以下のようにして、rbenv\nの初期化を実行しようとしたところ、`RUN rbenv global 2.3.3` のところでエラーになります。\n\n```\n\n RUN echo 'eval \"$(rbenv init -)\" >> /root/.profile\n RUN . /root/.profile\n RUN rbenv install 2.3.3\n RUN rbenv global 2.3.3\n RUN ruby -v\n \n```\n\n調べていくと、`eval \"$(rbenv init -)\"`\nで設定している環境変数が設定されていないようでした。ENVを使用すれば環境変数が設定できることは知っているのですが、今回はrbenvが自動で実行するスクリプト内で設定されているので、ENVは使えないのではないか?と思っています。なにか回避策はありますでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T03:49:12.153", "favorite_count": 0, "id": "33663", "last_activity_date": "2017-03-31T05:38:53.530", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "18863", "post_type": "question", "score": 1, "tags": [ "docker", "rbenv" ], "title": "Dockerfileに記述しているシェルスクリプト内で環境変数を設定したい。", "view_count": 1313 }
[ { "body": "Dockerfile の中の RUN\nコマンドは、それぞれ別のシェルで実行されたはずです。なので、ひとつのシェルコマンドにしてしまえば、正しく動くと考えられます。\n\n```\n\n RUN echo 'eval \"$(rbenv init -)\" >> /root/.profile && \\\n . /root/.profile && \\\n rbenv install 2.3.3 && \\\n rbenv global 2.3.3 && \\\n ruby -v\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T05:38:53.530", "id": "33664", "last_activity_date": "2017-03-31T05:38:53.530", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "33663", "post_type": "answer", "score": 1 } ]
33663
33664
33664
{ "accepted_answer_id": null, "answer_count": 4, "body": "C++11には`weak`, `shared`, `unique`のスマートポインタがありますが、これらが使える環境であえてnew,\ndeleteだけを使ったインスタンスの生成を使う意味はありますか?\n\nC++11ではnew, deleteだけを使った方法は、使うべきではない方法という位置付けなのでしょうか?\n\n後方互換性は考えないものとします", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T06:38:26.527", "favorite_count": 0, "id": "33665", "last_activity_date": "2017-07-25T17:13:54.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5246", "post_type": "question", "score": 3, "tags": [ "c++", "c++11" ], "title": "C++11のスマートポインタが使える場合に、new, deleteは必要なのか", "view_count": 7908 }
[ { "body": "newを使う理由の一つとして速度があるのではないかと思い、検証を行いました。以下、その検証結果です。\n\n```\n\n #include <chrono>\n #include <cstdlib>\n #include <cstring>\n #include <functional>\n #include <iomanip>\n #include <iostream>\n #include <memory>\n \n struct Test {\n int v;\n Test(int v) : v(v){};\n int f(int i)\n {\n v += i;\n return v;\n }\n };\n \n auto benchmark(const std::function<void(int)> &func, const int count = 1)\n {\n auto start = std::chrono::high_resolution_clock::now();\n for (int i = 0; i < count; ++i) func(i);\n auto end = std::chrono::high_resolution_clock::now();\n return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start)\n .count();\n }\n \n int main()\n {\n const int count = 100000;\n int n;\n // stack\n n = 0;\n auto stack_t = benchmark(\n [&n](int i) {\n Test t(i);\n n += t.f(i);\n },\n count);\n std::cout << \" stack: \" << std::setw(12) << stack_t << \"ns, \" << n\n << std::endl;\n // malloc\n n = 0;\n auto malloc_t = benchmark(\n [&n](int i) {\n auto t = static_cast<Test *>(std::malloc(sizeof(Test)));\n t->v = i;\n n += t->f(i);\n std::free(t);\n },\n count);\n std::cout << \"malloc: \" << std::setw(12) << malloc_t << \"ns, \" << n\n << std::endl;\n // new\n n = 0;\n auto new_t = benchmark(\n [&n](int i) {\n auto t = new Test(i);\n n += t->f(i);\n delete t;\n },\n count);\n std::cout << \" new: \" << std::setw(12) << new_t << \"ns, \" << n\n << std::endl;\n // unique\n n = 0;\n auto unique_t = benchmark(\n [&n](int i) {\n auto t = std::make_unique<Test>(i);\n n += t->f(i);\n },\n count);\n std::cout << \"unique: \" << std::setw(12) << unique_t << \"ns, \" << n\n << std::endl;\n // shared\n n = 0;\n auto shared_t = benchmark(\n [&n](int i) {\n auto t = std::make_shared<Test>(i);\n n += t->f(i);\n },\n count);\n std::cout << \"shared: \" << std::setw(12) << shared_t << \"ns, \" << n\n << std::endl;\n return 0;\n }\n \n```\n\n※ このコードはC++14向けです\n\n上のコードをmacOSのApple LLVM version 8.1.0 (clang-802.0.38)で`clang++ -O0\n-std=c++14`(最適化無し)でコンパイルして実行すると下記の結果になりました。\n\n```\n\n stack: 2346911ns, 1409965408\n malloc: 7772341ns, 1409965408\n new: 8951401ns, 1409965408\n unique: 10864862ns, 1409965408\n shared: 22686880ns, 1409965408\n \n```\n\nunique_ptrやshared_ptrはラップされている分newよりも遅くなっていると思われます。さらにshared_ptrが遅いのは参照カウンタの処理分と思われます。しかし、`clang++\n-O2 -std=c++14`(最適化有り)でコンパイルすると下記の結果になりました。\n\n```\n\n stack: 270138ns, 1409965408\n malloc: 306524ns, 1409965408\n new: 263298ns, 1409965408\n unique: 287971ns, 1409965408\n shared: 8967664ns, 1409965408\n \n```\n\nshared_ptr以外はスタックに詰む場合とほとんど変わらなくなります。最適化により、newやunique_ptrはスタックとほぼ同レベルまで速くなるようです。ただ、最適化がどれほど有効になるかはコンパイラとコードに依るため、一概に最適化によって同レベルの速度になると結論づけることはできないと考えています。\n**unique_ptrが最適化によってnewと同等レベルの速度に必ずなる、または、ならない場合もあるという証拠をお持ちの方は情報をお願いします。**\n\nshared_ptrについては、参照カウンタの仕組みがあるためか、その分が遅くなっていると思われます。newと同等速度にまで最適化できる場合があるかはわかりませんでした。\n\nなお、Homebrew GCC 6.3.0_1でコンパイルすると\n\n```\n\n # g++-6 -O0 -std=c++14 の場合\n stack: 2711000ns, 1409965408\n malloc: 9153000ns, 1409965408\n new: 13656000ns, 1409965408\n unique: 16941000ns, 1409965408\n shared: 33897000ns, 1409965408\n # g++-6 -O2 -std=c++14 の場合\n stack: 229000ns, 1409965408\n malloc: 251000ns, 1409965408\n new: 7885000ns, 1409965408\n unique: 7101000ns, 1409965408\n shared: 8947000ns, 1409965408\n \n```\n\nとなり、newとunique_ptrは最適化でほぼ同等の結果になります。\n\n※ 最新のVC++は今手元にないため、検証できる方が編集で追記いただけると助かります。\n\n検証からの結論としては、\n**最適化されなければ、newよりnuique_ptrとshared_ptrは遅くなるが、最適化によってunique_ptrはほぼ度速度になり、shared_ptrは遅いままになる場合がある**\nと言えるかと思います。しかし、最適化の影響がどこまで有効かはコンパイラやコード内容によるため、安易に結論づけることはは難しいです。\n\n* * *\n\n**初版の検証コードは問題があったため、参考にしないでください。詳細は[sayuriさんの回答](https://ja.stackoverflow.com/a/33723/7347)を参照してください。**", "comment_count": 9, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T05:55:26.540", "id": "33689", "last_activity_date": "2017-04-04T12:45:24.637", "last_edit_date": "2017-04-13T12:52:38.920", "last_editor_user_id": "-1", "owner_user_id": "7347", "parent_id": "33665", "post_type": "answer", "score": 2 }, { "body": "らっしーさんの回答は更新されて`new`と`unique`とで大差ない値が出てしまっているので、[更新前](https://ja.stackoverflow.com/revisions/33689/1)、何が起こっていたのかを説明しておきます。\n\n当たり前と感じるかもしれませんが、\n\n```\n\n int i0;\n \n```\n\nと記述した場合、C言語互換で未初期化の変数`i0`が用意されます。これを\n\n```\n\n int i1 = int();\n int i2{};\n \n```\n\nなどの記述をするとデフォルトコンストラクターが実行され`0`で初期化されます。同様のことが`new`でも存在し\n\n```\n\n int* j0 = new int;\n int* j1 = new int();\n int* j2 = new int{};\n \n```\n\n`j0`はメモリ確保は行われますが未初期化のままであり、`j1`および`j2`はメモリ確保の後にデフォルトコンストラクターによって`0`で初期化されます。 \nそして本題、\n\n```\n\n std::unique_ptr<int> k = std::make_unique<int>();\n \n```\n\nですとどうしてもデフォルトコンストラクターを呼び出してしまうため強制的に初期化のコストがかかります。\n\nまた`unique_ptr`は動的に`release()`可能です。そのため、`unique_ptr`デストラクターでは保持しているポインターが解放済みであるかどうかのテストが追加されます。対してハードコードされた`delete\nvar;`文ではこのテストが省略されている点も実行時間の差分に含まれています。\n\nまとめると **実行時の初期化コストの差**\nでしょうか。この程度の差を気にしないのであれば、`delete`し忘れを防ぐ意味でも`unique`や`shared`を使うべきでしょう。また実行時間に対して初期化が支配的となるような場合、`new`と`unique`の差を気にするよりも構造を見直すべきです。\n\n* * *\n\nこの他に、`make_unique()`を使う場合、`make_unique()`からコンストラクターを呼び出すことになりますので必然的にコンストラクターを`public`にする必要があります。\n\n```\n\n class Test {\n Test() = default;\n public:\n static auto create() {\n return std::make_unique<Test>(); // error\n }\n };\n \n```\n\n* * *\n\n蛇足ですが、`malloc()`もメモリ確保だけを行い初期化しませんが、`calloc()`はゼロクリアします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T02:02:54.877", "id": "33723", "last_activity_date": "2017-04-03T02:02:54.877", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "33665", "post_type": "answer", "score": 3 }, { "body": "> C++11にはweak, shared, uniqueのスマートポインタがありますが、これらが使える環境であえてnew,\n> deleteだけを使ったインスタンスの生成を使う意味はありますか?\n\n[alphaさんコメント](https://ja.stackoverflow.com/questions/33665/#comment33105_33665)の通り`std::make_unique<T>`が追加されたC++14以降では、「スマートポインタで要求仕様を満たせるなら、new/deleteによるインスタンス生成/破棄を避けるべき」でしょう。\n\n> C++11ではnew, deleteだけを使った方法は、使うべきではない方法という位置付けなのでしょうか?\n\nどうしてもnew演算子を使わなければ解決できないケース(placement new,\nalignment指定)を除いて、new/deleteを使うべきでないと考えます。\n\n英語版SOの\"[Are new and delete still useful in\nC++14?](https://stackoverflow.com/questions/30762994/)\"も参考にください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-08T14:36:34.713", "id": "33872", "last_activity_date": "2017-04-08T14:36:34.713", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "49", "parent_id": "33665", "post_type": "answer", "score": 0 }, { "body": "基本的にスマートポインタで統一すべきでしょう。 \nただ、コンストラクタがpublicでないクラスではmake_shared は簡単には使えません。\n\n```\n\n class Foo {\n private:\n Foo();\n \n public:\n static std::shared_ptr<Foo> create() {\n return std::make_shared<Foo>(); // コンパイルエラー\n }\n };\n \n```\n\nそのため\n\n```\n\n std::shared_ptr<Foo>( new Foo() );\n \n```\n\nと new を使うことになるかと思います。ただし、これを嫌ってテクニックを駆使してmake_shared を使う人も多いようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-07-25T15:47:45.937", "id": "36670", "last_activity_date": "2017-07-25T17:13:54.193", "last_edit_date": "2017-07-25T17:13:54.193", "last_editor_user_id": "24517", "owner_user_id": "24517", "parent_id": "33665", "post_type": "answer", "score": 0 } ]
33665
null
33723
{ "accepted_answer_id": null, "answer_count": 1, "body": "トップページをAとして \nA → B → C \nという遷移と \nA → X → Y \nという遷移があります。 \nそれぞれはpushPage()とpopPage()で行き来できます。\n\n今回、CからYに遷移させたいのですが、その際の戻る操作は以下のように遷移させたいのです。 \nしかしその方法がわかりません。 \nC → Y → X → A(TOP)\n\nページスタックを自作するなど方法はありますでしょうか?AngularJSによらない方法だと助かります。 \n(※CからTOPに戻れば解決する話ではありますが…)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T10:02:40.560", "favorite_count": 0, "id": "33670", "last_activity_date": "2022-08-19T00:03:40.373", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21300", "post_type": "question", "score": 0, "tags": [ "monaca", "onsen-ui" ], "title": "ページスタックを自作する方法", "view_count": 461 }
[ { "body": "`ページC`から`ページY`に遷移した場合、ページスタックの`ページB`と`ページC`を削除し、`ページX`を挿入すれば実現できます。\n\n`ons-navigator`のドキュメントも参照してください。 \n<https://ja.onsen.io/v2/docs/js/ons-navigator.html>\n\n```\n\n ons.ready(function() {\n document.querySelector(\"#navigator\").addEventListener(\"postpush\", function(e) {\n // page-cからpage-yに遷移したか?\n if ((e.leavePage.name == \"page-c.html\") && (e.enterPage.name == \"page-y.html\")) {\n var navi = e.navigator;\n // スタックに4ページ存在するか?\n if (navi.pages.length == 4) {\n // ページCを削除\n navi.pages[2].remove();\n // ページBを削除\n navi.pages[1].remove();\n // ページXを挿入\n navi.insertPage(1, \"page-x.html\");\n }\n }\n });\n });\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T05:14:57.620", "id": "33687", "last_activity_date": "2017-04-01T05:14:57.620", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9566", "parent_id": "33670", "post_type": "answer", "score": 0 } ]
33670
null
33687
{ "accepted_answer_id": "33678", "answer_count": 2, "body": "Atomで囲んだ(行単位でなく)選択している文字だけをコメントアウトする方法(ショートカットキー)はありますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T10:44:35.367", "favorite_count": 0, "id": "33672", "last_activity_date": "2017-12-02T04:32:42.567", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12297", "post_type": "question", "score": 0, "tags": [ "atom-editor" ], "title": "Atomで囲んだ選択している文字だけをコメントアウトする方法はありますか?", "view_count": 557 }
[ { "body": "block-commentパッケージをインストールすると `Option`+`Ctrl`+`Command`+`/` でできるようです。 \n同様の機能を持ったパッケージは数種類あるようですので、いろいろお試しください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T14:38:45.123", "id": "33678", "last_activity_date": "2017-03-31T14:38:45.123", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17037", "parent_id": "33672", "post_type": "answer", "score": 1 }, { "body": "Macの場合コマンド+Shift+範囲選択で複数選択が可能です。そのあとコマンド+スラッシュでコメントアウトができます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-02T04:32:42.567", "id": "39973", "last_activity_date": "2017-12-02T04:32:42.567", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26334", "parent_id": "33672", "post_type": "answer", "score": 1 } ]
33672
33678
33678
{ "accepted_answer_id": null, "answer_count": 0, "body": "<https://superuser.com/questions/38323/use-shift-caps-lock-instead-of-caps-\nlock>\n\n上記のリンク先に書かれているように、Windows で Caps Lock を有効にするには US/UK キーボードでは `Caps Lock`\nキーを押すだけでいいのに対し、日本語キーボードだと `Shift` キー + `Caps Lock`\nキーと同時に2個キーを押さないといけないのですが、この挙動を US/UK キーボードの方式に戻すにはどうしたらいいでしょうか?\n\nできれば AutoHotKey などの追加のソフトウェアをインストールしなくてもいい方法( `regedit` などを使った方法)を教えてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T12:05:07.377", "favorite_count": 0, "id": "33674", "last_activity_date": "2017-03-31T12:05:07.377", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21098", "post_type": "question", "score": 2, "tags": [ "windows", "windows-10", "key-mapping" ], "title": "Shift + Caps Lock でなく Caps Lock で Caps Lock をオンにしたい", "view_count": 2050 }
[]
33674
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "Fragment内にListViewを配置しているのですが、Android4.x環境で以下のエラーが発生します(Android6.xでは問題なし)。解決法を探しても似た事例が見つかりませんでした。よろしくお願いします。\n\n```\n\n E/AndroidRuntime: FATAL EXCEPTION: main\n android.view.InflateException: Binary XML file line #7: Error inflating class TextView\n at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)\n at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)\n at android.view.LayoutInflater.inflate(LayoutInflater.java:489)\n at android.view.LayoutInflater.inflate(LayoutInflater.java:396)\n at android.view.LayoutInflater.inflate(LayoutInflater.java:352)\n at {MyPackageName}.CustomAdapter.getView(CustomAdapter.java:36)\n at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)\n at android.widget.AbsListView.obtainView(AbsListView.java:2271)\n at android.widget.ListView.makeAndAddView(ListView.java:1769)\n at android.widget.ListView.fillDown(ListView.java:672)\n at android.widget.ListView.fillFromTop(ListView.java:733)\n at android.widget.ListView.layoutChildren(ListView.java:1622)\n at android.widget.AbsListView.onLayout(AbsListView.java:2106)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:598)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.widget.FrameLayout.onLayout(FrameLayout.java:448)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1759)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.widget.FrameLayout.onLayout(FrameLayout.java:448)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:435)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.widget.FrameLayout.onLayout(FrameLayout.java:448)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)\n at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)\n at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.widget.FrameLayout.onLayout(FrameLayout.java:448)\n at android.view.View.layout(View.java:13754)\n at android.view.ViewGroup.layout(ViewGroup.java:4364)\n at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1868)\n at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1689)\n at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)\n at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)\n at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)\n at android.view.Choreographer.doCallbacks(Choreographer.java:555)\n at android.view.Choreographer.doFrame(Choreographer.java:525)\n at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)\n at android.os.Handler.handleCallback(Handler.java:615)\n at android.os.Handler.dispatchMessage(Handler.java:92)\n at android.os.Looper.loop(Looper.java:137)\n at android.app.ActivityThread.main(ActivityThread.java:4745)\n at java.lang.reflect.Method.invokeNative(Native Method)\n at java.lang.reflect.Method.invoke(Method.java:511)\n at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)\n at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)\n at dalvik.system.NativeStart.main(Native Method)\n Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x1010433 a=-1}\n at android.content.res.Resources.loadColorStateList(Resources.java:\n \n```\n\nCustomAdapterのコードは以下です。\n\n```\n\n import android.content.Context;\n import android.view.LayoutInflater;\n import android.view.View;\n import android.view.ViewGroup;\n import android.widget.ArrayAdapter;\n import android.widget.TextView;\n \n import java.util.List;\n \n public class CustomAdapter extends ArrayAdapter<Article> {\n private LayoutInflater layoutInflater_;\n Context context;\n List<Article> articles;\n \n public CustomAdapter(Context context, int textViewResourceId, List<Article> objects) {\n super(context, textViewResourceId, objects);\n this.context = context;\n this.articles = objects;\n layoutInflater_ = LayoutInflater.from(context);\n }\n \n @Override\n public View getView(int position, View convertView, ViewGroup parent) {\n View v = convertView;\n Article item = articles.get(position);\n \n // convertViewがnullの時のみ作成\n if (v == null) {\n v = layoutInflater_.inflate(R.layout.row, null); //←ここでエラー\n }\n \n TextView textView = (TextView)convertView.findViewById(R.id.textView2);\n textView.setText(item.getTitle());\n \n TextView textView1 = (TextView)convertView.findViewById(R.id.textView3);\n textView1.setText(item.getSite());\n \n TextView textView2 = (TextView)convertView.findViewById(R.id.textView4);\n textView2.setText(item.getDate());\n \n return v;\n }\n }\n \n```\n\n-追記-\n```\n\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:layout_width=\"match_parent\" android:layout_height=\"match_parent\"\n android:paddingTop=\"5dp\"\n android:paddingBottom=\"5dp\">\n \n <TextView\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:textAppearance=\"?android:attr/textAppearanceSmall\"\n android:text=\"Small Text\"\n android:id=\"@+id/textView3\"\n android:layout_below=\"@+id/textView2\"\n android:layout_alignParentLeft=\"true\"\n android:layout_alignParentStart=\"true\"\n android:textColor=\"?android:attr/colorPrimary\"\n android:textAllCaps=\"false\"\n android:fontFamily=\"sans-serif\" />\n \n <TextView\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:textAppearance=\"?android:attr/textAppearanceSmall\"\n android:text=\"Small Text\"\n android:id=\"@+id/textView4\"\n android:layout_alignTop=\"@+id/textView3\"\n android:layout_alignParentRight=\"true\"\n android:layout_alignParentEnd=\"true\"\n android:textColor=\"#505050\" />\n \n <TextView\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:textAppearance=\"?android:attr/textAppearanceMedium\"\n android:text=\"Medium Text\"\n android:id=\"@+id/textView2\"\n android:layout_alignParentTop=\"true\"\n android:layout_alignParentLeft=\"true\"\n android:layout_alignParentStart=\"true\"\n android:textColor=\"#000000\" />\n \n </RelativeLayout>\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T13:21:19.297", "favorite_count": 0, "id": "33676", "last_activity_date": "2017-04-01T16:00:11.407", "last_edit_date": "2017-04-01T16:00:11.407", "last_editor_user_id": "21303", "owner_user_id": "21303", "post_type": "question", "score": 0, "tags": [ "android" ], "title": "getViewでlayoutInflater.inflateした際のエラー", "view_count": 765 }
[]
33676
null
null
{ "accepted_answer_id": "51027", "answer_count": 1, "body": "```\n\n from sympy import *\n var('x a b')\n f=a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n #次の行不要です。\n #f=collect(expand(f),x)\n print(\"#f=#\" ,f)\n print(\"#3次#\" ,f.coeff(x**3))\n print(\"#2次#\" ,f.coeff(x**2))\n print(\"#1次#\" ,f.coeff(x**1))\n print(\"#0次#\" ,f.coeff(x**0))\n #f=# a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n #3次# 4\n #2次# 0\n #1次# b - 3\n #0次# a*(2*x**2 - 1) + x*(b - 3)\n \n```\n\n0次はaになりません。いい方法がありますか? \nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T13:24:40.723", "favorite_count": 0, "id": "33677", "last_activity_date": "2018-12-08T06:45:52.627", "last_edit_date": "2017-10-17T06:59:15.077", "last_editor_user_id": "754", "owner_user_id": "17199", "post_type": "question", "score": 3, "tags": [ "python", "sympy" ], "title": "sympyのcoeffの使い方を教えて下さい", "view_count": 1036 }
[ { "body": "(コメントより)\n\n`p = Poly(f, x)` として、`p.coeff_monomial(x**0)` もしくは `p.coeff_monomial(1)` とします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2018-12-08T06:45:52.627", "id": "51027", "last_activity_date": "2018-12-08T06:45:52.627", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "33677", "post_type": "answer", "score": 2 } ]
33677
51027
51027
{ "accepted_answer_id": null, "answer_count": 0, "body": "こんにちは。python初心者のものです。私が今使っている教材で \n・pip install [library名] \nとすると、パッケージをインストールできるとのことですが、画像のようなエラーが出てきました。ググりにググった結果、埒が明かないので質問させていただきました。[![実行した結果](https://i.stack.imgur.com/EaA11.png)](https://i.stack.imgur.com/EaA11.png)\n\n見にくいですが、UnicodeDecodeErrorと出ています。 \nどなたか解決に力を貸してくれたらうれしいです!\n\n環境:Python 3.6.0, Windows 10\n\n[![環境変数に追加して実行](https://i.stack.imgur.com/6Jter.png)](https://i.stack.imgur.com/6Jter.png)", "comment_count": 15, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T18:17:51.407", "favorite_count": 0, "id": "33679", "last_activity_date": "2017-04-01T13:46:52.350", "last_edit_date": "2017-04-01T13:46:52.350", "last_editor_user_id": "21305", "owner_user_id": "21305", "post_type": "question", "score": 0, "tags": [ "python", "unicode", "pip" ], "title": "pythonでinstall library をしたときのエラー", "view_count": 1426 }
[]
33679
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "お願いします。\n\n現在UITableViewCellの実装をしているのですが、一つのセルに2つの Labelを配置するには、どう設定すればよろしいですか?\n\nCell一つだと、\n\n```\n\n override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n let _cell = tableView.dequeueReusableCell(withIdentifier:cellIdentifier,for:indexPath) as UITableViewCell\n let cell = _cell\n cell.textLabel?.text = \"a\"\n return cell\n }\n \n```\n\nでいけるのですが、もう一つ同じセル内に文字を表示させたい場合どのように実装すればよろしいですか?\n\n* * *\n\n***追記*** \ncellインスタンスを生成、 \n`<変数名>:label = cell.viewWithTag(x) as? UILabel` \nで、予め各オブジェクトにTag設定してviewWithTag()で指定するとできました。\n\n追加でもう一つ質問お願いできますか? \nMagicNumberとよく聞きますが、こういったコーティングは個人では問題ないでしょうが、自分以外の人たちが関わる開発等で今回のような、手法は有効になるでしょうか?それとも、もっと分かり易い効率的な手法があるでしょうか??抽象的な質問かと思いますが、よろしくお願いします。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T20:51:49.493", "favorite_count": 0, "id": "33680", "last_activity_date": "2017-04-19T22:36:34.033", "last_edit_date": "2017-04-07T12:29:45.450", "last_editor_user_id": "20049", "owner_user_id": "20049", "post_type": "question", "score": 0, "tags": [ "swift3" ], "title": "UITableViewCellについて", "view_count": 85 }
[ { "body": ">\n> MagicNumberとよく聞きますが、こういったコーティングは個人では問題ないでしょうが、自分以外の人たちが関わる開発等で今回のような、手法は有効になるでしょうか?\n\nマジックナンバーで問題になるのは、「何故」そのようになっているのか、といったコードだけからは読み取れないという部分ですので、\n\n 1. 変数名で意図が伝わるようにする \n1.08 * price => (1 + tax) * price\n\n 2. そうなっている理由をコメントにきちんと書く\n\nといった方法で回避可能です。\n\n> 追加で質問文下に追記‌​します\n\n再度質問し直したほうがタイトルなどを含め、回答を得やすくなるかと思います", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-19T22:36:34.033", "id": "34130", "last_activity_date": "2017-04-19T22:36:34.033", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "15705", "parent_id": "33680", "post_type": "answer", "score": 0 } ]
33680
null
34130
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n num_list = [[0 * 100]] * 2 \n for i in range(4): \n for j in range(100): \n num_list[i].append(j)\n \n print(num_list)\n \n```\n\nとして\n\n```\n\n [[0, 1, 2, 3 -- 100], [0, 1, 2, 3 -- 100]]\n \n```\n\nのような配列を作りたいのですが、結果として\n\n```\n\n [[0, 1, 2, 3 -- 100, 0, 1, 2, 3 -- 100],[0, 1, 2, 3 -- 100, 0, 1, 2, 3 -- 100]]\n \n```\n\nとなってしまいます。\n\n明らかにイテレーションの理解不足だと思うのですが、 \nどなたかご助言していただけないでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T21:05:18.177", "favorite_count": 0, "id": "33681", "last_activity_date": "2017-04-01T06:03:32.430", "last_edit_date": "2017-04-01T06:03:32.430", "last_editor_user_id": "3054", "owner_user_id": "21306", "post_type": "question", "score": 1, "tags": [ "python3" ], "title": "入れ子構造for文のイテレーション", "view_count": 203 }
[ { "body": "分かりやすく書くとこんな感じじゃないでしょうか。\n\n```\n\n # python3 --\n num_list = []\n for _ in range(2):\n nums = []\n for num in range(101):\n nums.append(num)\n num_list.append(nums)\n print(num_list)\n \n```\n\n短く書きたいのであれば、下記のようにすれば良いです。\n\n```\n\n # python3 --\n num_list = [list(range(101))] * 2\n print(num_list)\n \n```\n\nUPDATE\n\nラッシーさんから指摘があったので追記します。\n\n上記の書き方だと、num_list にある 2つのリストは同じオブジェクトが参照されてしまうので、 \nあまり良い書き方ではありませんでした。以下のようなことが起きてしまいます。\n\n```\n\n # python3 --\n num_list = [list(range(101))] * 2\n num_list[0][0] = 999\n # 1番目のリストの最初の要素を書き換えると、同じオブジェクトを参照してるので\n # 2番目のリストの最初の要素の値も書き換わってしまう\n print(num_list[1][0]) # => 999\n \n```\n\nあらためて、2つのリストを独立させた状態で生成する方法を記載します。\n\n```\n\n # python3 --\n num_list = [list(range(101)) for _ in range(2)]\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-03-31T23:55:31.970", "id": "33684", "last_activity_date": "2017-04-01T03:07:23.993", "last_edit_date": "2017-04-01T03:07:23.993", "last_editor_user_id": "2168", "owner_user_id": "2168", "parent_id": "33681", "post_type": "answer", "score": 1 } ]
33681
null
33684
{ "accepted_answer_id": null, "answer_count": 1, "body": "MACの情報しか見つからないのですが、windows10だと下記のパスに tern_for_sublime-master\nフ‌​ォルダを入れてインストールをnpmで行う‌​のでしょうか?\n\n参考サイト <https://liginc.co.jp/312755>\n\n参考サイトを見ると \nまず初めに `C:\\Users\\user\\AppData\\Roaming\\Sublime Text 3\\package` に \ntern_for_sublime-master フォルダをそのまま入れてやればよいのでしょうか?\n\n次にgulpを使っているのでnode自体は入っているので、 windows10だと\n`C:\\Users\\user\\AppData\\Roaming\\Sublime Text 3\\package\\tern_for_sublime-master`\nをカレントディレクトリとしてどんなコマンドを打てばよいのでしょうか?\n\n`npm install tern` ではないですよね?\n\nコメントの通りにやってみましたが下記のようにエラーが出ました。\n\n```\n\n AppData\\Roaming\\Sublime Text 3\\Packages\\tern_for_sublime-master>npm install\n npm WARN enoent ENOENT: no such file or directory, open 'C:\\Users\\h\\AppData\\Roaming\\Sublime Text 3\\Packages\\tern_for_sublime-master\\package.json'\n npm WARN tern_for_sublime-master No description\n npm WARN tern_for_sublime-master No repository field.\n npm WARN tern_for_sublime-master No README data\n npm WARN tern_for_sublime-master No license field.\n \n```\n\nなぜか入れ子になっていたのでフォルダを入れ子にならないようにしたところ一瞬インストールと出るようになりました。\n\nその結果 \nPreferences > Package Settings > Tern > Settings – User \nに\n\n```\n\n {\n \"tern_argument_hints\": true,\n \"tern_output_style\": \"status\",\n \"tern_argument_completion\": true,\n \"auto_complete\": true,\n \"auto_complete_triggers\": [\n {\"selector\": \"text.html\", \"characters\": \"<\"},\n {\"selector\": \"source.js\", \"characters\": \".\"}\n ]\n }\n \n```\n\nを追加するところまでおかげさまでできました。 \nただ \ndocument.getElementsByClassName \nと打ってコントロール、スペースを押しても()と出てきません。 \nこちらを行う前とあまり変化を感じません。 \n引数か代入かわかるように保管してくれないのでしょうか?\n\ndcmt.addEvtLisrが \ndcmt.addEventListener \nと変化はします。これは使えていると考えてよいのでしょうか?\n\nconsole.log(i); \nを記載すると下記のリンクやlog()などの英語の解説がサブライムテキスト3上に出るようになりました。 \n<https://developer.mozilla.org/en-\nUS/docs/Web/JavaScript/Reference/Global_Objects/Math/log>\n\n恐らくインストール自体はできたように見えます。\n\nただdocument.getElementsByClassNameと入力してコントロールとスペースを押しても、 \n引数か代入かのヒントが出てきません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T01:10:43.773", "favorite_count": 0, "id": "33686", "last_activity_date": "2017-04-09T17:12:58.127", "last_edit_date": "2017-04-05T02:47:36.517", "last_editor_user_id": "20834", "owner_user_id": "20834", "post_type": "question", "score": -1, "tags": [ "windows", "sublimetext" ], "title": "Windows 上の Sublime Text 3 に Tern をインストールするには?", "view_count": 648 }
[ { "body": "> まず初めに `C:\\Users\\user\\AppData\\Roaming\\Sublime Text 3\\package` に \n> tern_for_sublime-master フォルダをそのまま入れてやればよいのでしょうか?\n\ngitを導入されていない場合はその通りです。\n\n> 次にgulpを使っているのでnode自体は入っているので、 windows10だと \n> `C:\\Users\\user\\AppData\\Roaming\\Sublime Text 3\\package\\tern_for_sublime-\n> master` をカレントディレクトリとしてどんなコマンドを打てばよいのでしょうか?\n\n`npm install`でNodeモジュールをインストールしてください。この時にTernがnode_modulesフォルダにインストールされます。\n\n* * *\n\n追記について: \n`console.log()`で補完と解説が出ているということなので、インストールはできています。 \nデフォルトでは汎用性を優先してECMAScriptで定義されたものやNode.jsで標準的なものだけが補完されるようです。 \n`document`や`Document.addEventListener(..)`等のウェブブラウザ向けの補完を使う場合は、プロジェクトフォルダ、もしくはデフォルトのTern設定に次のような設定ファイルが必要になります。\n\n.tern-project :\n\n```\n\n {\n \"libs\": [\n \"browser\", // ウェブブラウザ用の補完設定\n \"jquery\" // jQuery用の補完設定\n ]\n }\n \n```\n\nデフォルトのプロジェクトフォルダはTern for Sublimeをインストールしたフォルダ内のdefault_project_dir\nというフォルダになります。 \nそこに上記のJSONを書いた .tern-project を設置して、Sublime Textを再起動してみてください。", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T21:48:21.127", "id": "33720", "last_activity_date": "2017-04-09T17:12:58.127", "last_edit_date": "2017-04-09T17:12:58.127", "last_editor_user_id": "19925", "owner_user_id": "19925", "parent_id": "33686", "post_type": "answer", "score": 1 } ]
33686
null
33720
{ "accepted_answer_id": "33691", "answer_count": 1, "body": "XcodeのPlaygroundで、スプライトを動かす簡単なゲームを作っています\n\nスプライトの表示で、このようなコードを作りました\n\n```\n\n import UIKit\n import SpriteKit\n import PlaygroundSupport\n \n let sceneWidth = 768.0\n let sceneHeight = 1024.0\n let sceneView = SKView(frame: CGRect(x: 0.0, y: 0.0, width: sceneWidth, \n height: sceneHeight))\n sceneView.backgroundColor = UIColor.yellow\n PlaygroundPage.current.liveView = sceneView\n let character = SKSpriteNode(fileNamed: \"SobacchiStand.png\")\n \n```\n\nしかし、characterがnilになってしまっています\n\n画像自体はPlaygroundに元からある「Resources」フォルダに入れた「SobacchiStand.png」です\n\nどのようにすれば画像を表示できるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T07:10:10.580", "favorite_count": 0, "id": "33690", "last_activity_date": "2017-04-01T07:34:51.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21307", "post_type": "question", "score": 1, "tags": [ "swift", "xcode" ], "title": "SKSpriteNodeがnilになってしまう", "view_count": 172 }
[ { "body": "```\n\n let character = SKSpriteNode(fileNamed: \"SobacchiStand.png\")\n \n```\n\nこの行を、こう書き換えてみてください。\n\n```\n\n let character = SKSpriteNode(imageNamed: \"SobacchiStand.png\")\n \n```\n\n[SpriteKit - SKNode -\ninit(file​Named:​)](https://developer.apple.com/reference/spritekit/sknode/1483083-init)\n\nここから引用:\n\n> Parameters \n> **filename** \n> The name of the file, without a file extension. The file must be in the\n> app’s main bundle and have a .sks filename extension.\n\n拡張子`.sks`のSpriteKit\nSceneファイルを読み込んで、`SKScene`インスタンスを生成するときに使うイニシアライザです。`SKSpriteNode`のイメージを読み込むのは、`init(imageNamed:​)`を使います。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T07:34:51.947", "id": "33691", "last_activity_date": "2017-04-01T07:34:51.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "18540", "parent_id": "33690", "post_type": "answer", "score": 0 } ]
33690
33691
33691
{ "accepted_answer_id": null, "answer_count": 2, "body": "GoDaddyでドメインを購入し、 \nかつ、ドメインメールもGoDaddy経由で購入しました。(Office365)\n\n購入当初はメールの送受信が出来ていたのですが、 \n要件上、AWSのRoute53を使わなくてはいけなくなり、 \nRoute53にネームサーバーを移行しました。\n\nDNSがAWSに移り、ドメインとの紐付けも完了して一段落したのですが、 \nGoDaddyで購入したOffice365のメールが受信できなくなりました。\n\n但し、送信はできております。\n\n次のような記事を参照して \nOffice 365 カスタムドメインを追加しRoute 53に各種レコードを設定する方法等を探っているのですが \nGoDaddyで購入したためか、ドメイン追加へのリンクが存在しておりません。\n\n[Office 365 カスタムドメインを追加しRoute 53に各種レコードを設定する](http://blog.hrendoh.com/add-\ncustom-domain-to-office365/)\n\n[Office365の管理者ページ、参考キャプチャ](https://gyazo.com/972cc5063794ed2ed49edf447516a9f1?token=bd72c149db06b6a3d89b0e3653fe4f1e)\n\nOffice 365のメールは年間契約してしまっったため、可能な限り、こちらを使う方法で、 \nRoute53との接続を行いたいです。\n\n宜しくお願いします。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T08:11:43.127", "favorite_count": 0, "id": "33692", "last_activity_date": "2017-04-04T02:21:28.283", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13175", "post_type": "question", "score": 0, "tags": [ "aws", "dns", "サーバー管理" ], "title": "Route53にネームサーバーを移行後、GoDaddyで購入したOffice365のメールが受信できなくなりました。", "view_count": 536 }
[ { "body": "1. 権威DNSが正しくRoute53に移っているか \n 2. Route53で正しくゾーンが作成できているか\n 3. Office365にドメインの設定が正しくできているか\n 4. Office365にメールをルーティングするMXレコードが適切に設定できているか\n\nこれらを順を追って確認してください。DNSの場合、TTLの影響もありますのでその点も考慮してください。これらができていれば普通は動くはずです。各種コントロールパネルが手順通りに動作しないのであれば、ここで聞くよりそれぞれのサポート窓口に問いあわせた方が確実です。\n\n上記の項目で具体的に何をしたら良いのかわからないとか結果の良否が判断できないのであれば、構築や運用は経験のあるシステムインテグレータに費用を払ってやってもらうことを強くお勧めします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T01:48:37.063", "id": "33704", "last_activity_date": "2017-04-02T05:51:39.850", "last_edit_date": "2017-04-02T05:51:39.850", "last_editor_user_id": "5793", "owner_user_id": "5793", "parent_id": "33692", "post_type": "answer", "score": 2 }, { "body": "あるドメインに対するメールをどこのメールサーバーに配送するかは、そのネームサーバーからMXレコードで提供する情報です。GoDaddyのネームサーバーを利用していた時は必要なレコードを自動的に追加してくれていただけなので、\n**ネームサーバーを変更したらそれらを自分で追加しなければいけません** し、さもなくばそのドメイン宛のメールの配送ができなくなります。\n\nそこで本来はOffice365の方で必要なレコードが調べられるはずですが、それが管理画面に出てこないということは、\n**GoDaddy専用版だから表示していない**\n、と考えるのが妥当ではないでしょうか。「ドメイン」メニューを含んだ管理画面の例は、例えば公式の「[Office 365 の [ドメイン] ページに移動する\n- Office 365](https://support.office.com/ja-\njp/article/Office-365-%E3%81%AE-%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3-%E3%83%9A%E3%83%BC%E3%82%B8%E3%81%AB%E7%A7%BB%E5%8B%95%E3%81%99%E3%82%8B-026af1f2-0e6d-4f2d-9b33-fd147420fac2?ui=ja-\nJP&rs=ja-JP&ad=JP)」という記事で古い管理センターとして紹介されていますから、見比べてみてください。\n\n理屈上は以前のネームサーバーに登録されていたレコードをRoute53に登録すれば動くと思いますが、今後その内容が変化しても追従することができませんし、ライセンス契約上の問題がある可能性もあります。個人的にも勧めたくない方法ですから、これ以上の説明は避けておきます。\n\n正攻法でなんとかしたいなら、サポート窓口に問い合わせるのがベストです。 \n「無理です」という回答になるかもしれませんが。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T06:49:33.963", "id": "33735", "last_activity_date": "2017-04-04T02:21:28.283", "last_edit_date": "2017-04-04T02:21:28.283", "last_editor_user_id": "8000", "owner_user_id": "8000", "parent_id": "33692", "post_type": "answer", "score": 3 } ]
33692
null
33735
{ "accepted_answer_id": null, "answer_count": 1, "body": "windows10のコマンドプロンプトで質問です。\n\n```\n\n dir > tmp.txt\n \n```\n\nという内容のバッチファイルを作成し、test.bat と名前をつけます。 \nこれをコマンドプロンプトで実行すると、\n\n> D:\\>test\n>\n> D:\\>dir 1>tmp.txt\n\nと表示され、リダイレクト記号の前に半角の\"1\"が表示されます。 \nまた、リダイレクト記号のあとにあった半角スペースは消えています。 \ntmp.txtの内容は問題ありません。\n\nなぜバッチファイルの内容と違う命令が出力されてしまうのでしょうか。 \nこの1は標準出力STDOUTのことなのでしょうか。 \nバッチファイルは S-JIS、コマンドプロンプトも CP932 です。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T13:44:52.073", "favorite_count": 0, "id": "33693", "last_activity_date": "2021-03-09T09:05:15.547", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20300", "post_type": "question", "score": 2, "tags": [ "windows", "batch-file", "command-line" ], "title": "windows10のコマンドプロンプトで数字の1が表示される", "view_count": 2616 }
[ { "body": "[Batch files - How To ... Display and Redirect\nOutput](http://www.robvanderwoude.com/battech_redirection.php)\nには以下のように書かれています。\n\n> When we use > to redirect Standard Output, CMD.EXE interprets this as 1>, as\n> can be seen by writing and running ...\n\n* * *\n\nこの投稿は @metropolis\nさんの[コメント](https://ja.stackoverflow.com/questions/33693/#comment33153_33693)などを元に編集し、[コミュニティWiki](https://ja.meta.stackoverflow.com/q/1583)として投稿しました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2021-01-26T00:52:24.900", "id": "73573", "last_activity_date": "2021-01-26T01:00:56.510", "last_edit_date": "2021-01-26T01:00:56.510", "last_editor_user_id": "3060", "owner_user_id": "9820", "parent_id": "33693", "post_type": "answer", "score": 2 } ]
33693
null
73573
{ "accepted_answer_id": "33695", "answer_count": 1, "body": "昨日からfishシェルを使い始めまして、anyenvの設定を `~/.config/fish/config.fish` に記述しました。\n\n```\n\n set -x PATH $HOME/.anyenv/bin $PATH\n eval (anyenv init - fish)\n \n```\n\nそしてfishを起動すると、以下のエラーがでました。\n\n```\n\n Variables cannot be bracketed. In fish, please use \"$PATH\".\n - (line 1): begin; source \"/home/vagrant/.anyenv/libexec/../completions/anyenv.fish\" function anyenv set command $argv[1] set -e argv[1] command anyenv \"$command\" $argv end set -x GOENV_ROOT \"/home/vagrant/.anyenv/envs/goenv\" set -x PATH $PATH \"/home/vagrant/.anyenv/envs/goenv/bin\" export PATH=\"/home/vagrant/.anyenv/envs/goenv/shims:${PATH}\" goenv rehash 2>/dev/null set -x NDENV_ROOT \"/home/vagrant/.anyenv/envs/ndenv\" set -x PATH $PATH \"/home/vagrant/.anyenv/envs/ndenv/bin\" ndenv rehash 2>/dev/null ndenv() { typeset command command=\"$1\" if [ \"$#\" -gt 0 ]; then shift fi case \"$command\" in rehash|shell) eval \"`ndenv \"sh-$command\" \"$@\"`\";; *) command ndenv \"$command\" \"$@\";; esac } set -x PYENV_ROOT \"/home/vagrant/.anyenv/envs/pyenv\" set -x PATH $PATH \"/home/vagrant/.anyenv/envs/pyenv/bin\" setenv PATH '/home/vagrant/.anyenv/envs/pyenv/shims' $PATH setenv PYENV_SHELL fish . '/home/vagrant/.anyenv/envs/pyenv/libexec/../completions/pyenv.fish' command pyenv rehash 2>/dev/null function pyenv set command $argv[1] set -e argv[1] switch \"$command\" case rehash shell . (pyenv \"sh-$command\" $argv|psub) case '*' command pyenv \"$command\" $argv end end set -x RBENV_ROOT \"/home/vagrant/.anyenv/envs/rbenv\" set -x PATH $PATH \"/home/vagrant/.anyenv/envs/rbenv/bin\" setenv PATH '/home/vagrant/.anyenv/envs/rbenv/shims' $PATH setenv RBENV_SHELL fish source '/home/vagrant/.anyenv/envs/rbenv/libexec/../completions/rbenv.fish' command rbenv rehash 2>/dev/null function rbenv set command $argv[1] set -e argv[1] switch \"$command\" case rehash shell source (rbenv \"sh-$command\" $argv|psub) case '*' command rbenv \"$command\" $argv end end\n ^\n from sourcing file -\n called on line 60 of file /usr/local/share/fish/functions/eval.fish\n \n in function “eval”\n called on line 15 of file ~/.config/fish/config.fish\n \n from sourcing file ~/.config/fish/config.fish\n called during startup\n \n source: Error while reading file “-”\n \n```\n\nエラー内容をググってもどうにもならなかったので、config.fishの`eval`部分を`anenv init -\nfish`で表示される内容に変えてみました。\n\n```\n\n set -x PATH $HOME/.anyenv/bin $PATH\n \n # anyenv init - fish で出てくる内容\n source \"/home/vagrant/.anyenv/libexec/../completions/anyenv.fish\"\n function anyenv\n set command $argv[1]\n set -e argv[1]\n \n command anyenv \"$command\" $argv\n end\n \n set -x GOENV_ROOT \"/home/vagrant/.anyenv/envs/goenv\"\n set -x PATH $PATH \"/home/vagrant/.anyenv/envs/goenv/bin\"\n export PATH=\"/home/vagrant/.anyenv/envs/goenv/shims:${PATH}\"\n goenv rehash 2>/dev/null\n set -x NDENV_ROOT \"/home/vagrant/.anyenv/envs/ndenv\"\n set -x PATH $PATH \"/home/vagrant/.anyenv/envs/ndenv/bin\"\n export PATH=\"/home/vagrant/.anyenv/envs/ndenv/shims:${PATH}\"\n \n ndenv rehash 2>/dev/null\n ndenv() {\n typeset command\n command=\"$1\"\n if [ \"$#\" -gt 0 ]; then\n shift\n fi\n \n case \"$command\" in\n rehash|shell)\n eval \"`ndenv \"sh-$command\" \"$@\"`\";;\n *)\n command ndenv \"$command\" \"$@\";;\n esac\n }\n \n set -x PYENV_ROOT \"/home/vagrant/.anyenv/envs/pyenv\"\n set -x PATH $PATH \"/home/vagrant/.anyenv/envs/pyenv/bin\"\n setenv PATH '/home/vagrant/.anyenv/envs/pyenv/shims' $PATH\n setenv PYENV_SHELL fish\n . '/home/vagrant/.anyenv/envs/pyenv/libexec/../completions/pyenv.fish'\n command pyenv rehash 2>/dev/null\n \n function pyenv\n set command $argv[1]\n set -e argv[1]\n \n switch \"$command\"\n case rehash shell\n . (pyenv \"sh-$command\" $argv|psub)\n case '*'\n command pyenv \"$command\" $argv\n end\n end\n \n set -x RBENV_ROOT \"/home/vagrant/.anyenv/envs/rbenv\"\n set -x PATH $PATH \"/home/vagrant/.anyenv/envs/rbenv/bin\"\n setenv PATH '/home/vagrant/.anyenv/envs/rbenv/shims' $PATH\n setenv RBENV_SHELL fish\n source '/home/vagrant/.anyenv/envs/rbenv/libexec/../completions/rbenv.fish'\n command rbenv rehash 2>/dev/null\n function rbenv\n set command $argv[1]\n set -e argv[1]\n \n switch \"$command\"\n case rehash shell\n source (rbenv \"sh-$command\" $argv|psub)\n case '*'\n command rbenv \"$command\" $argv\n end\n end\n \n```\n\nこうしてfishを起動しても、また以下のエラーが出ます。どのように対応すれば良いのでしょうか?\n\n```\n\n 'case' builtin not inside of switch block\n ~/.config/fish/config.fish (line 43): case \"$command\" in\n ^\n from sourcing file ~/.config/fish/config.fish\n called during startup\n \n source: Error while reading file “/home/vagrant/.config/fish/config.fish”\n \n```\n\nちなみにanyenvは最新バージョンにアップデートしてあります。 \nよろしくお願い致します。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T13:49:19.103", "favorite_count": 0, "id": "33694", "last_activity_date": "2017-04-01T15:32:05.393", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "11178", "post_type": "question", "score": 1, "tags": [ "shell" ], "title": "fishシェルでanyenvを設定したときにcalled during startupエラーが出る", "view_count": 2081 }
[ { "body": "バグといいますか、コードを見る限り、`goenv` や `ndenv` は `fish` に対応していないです。 \n想定しているのは`bash`、`ksh`、`zsh`です。 \n<https://github.com/kaneshin/goenv/blob/master/libexec/goenv-init#L56> \n<https://github.com/riywo/ndenv/blob/master/libexec/ndenv-init#L59>\n\n`pyenv` と `rbenv`は対応しているようです。 \n<https://github.com/pyenv/pyenv/blob/master/libexec/pyenv-init#L46> \n<https://github.com/rbenv/rbenv/blob/master/libexec/rbenv-init#L35>\n\nmetropolis さんがコメントで指摘している`${PATH}`の件も、\n\n> 'case' builtin not inside of switch block\n\nというエラーも、sh系の文法を `fish` に読ませた事が原因です。\n\n* * *\n\n解決策としては二つ、\n\n * 自分で頑張って対応させる\n * `bash` などで環境のスイッチをした後に `fish` を起動する\n\nが考えられます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T14:23:50.620", "id": "33695", "last_activity_date": "2017-04-01T15:32:05.393", "last_edit_date": "2017-04-01T15:32:05.393", "last_editor_user_id": "3054", "owner_user_id": "3054", "parent_id": "33694", "post_type": "answer", "score": 2 } ]
33694
33695
33695
{ "accepted_answer_id": null, "answer_count": 0, "body": "storyboardを使いviewController(=シーン)A,B,Cを作成し A->B->Cとmodalでsegueをつなぎます。 \nシーンBとシーンCともにシーンAへ戻るためunwind segueを作成しました。 \nシーンCからシーンAへ戻る際に、シーンBが下部へ消えていくアニメーションが一瞬表示されます。 \nシーンBが見えないようにするにはどうすればよいでしょうか。\n\nイメージとしては\n\n * シーンA:スタート画面\n * シーンB:ゲームプレイ画面 \n * シーンC:結果画面\n\nです。よろしくお願いします。\n\n※NavigationCotrollerかと考えましたが、上段のNavigation Barが不要なため質問しました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T15:06:26.040", "favorite_count": 0, "id": "33697", "last_activity_date": "2017-04-01T15:18:18.797", "last_edit_date": "2017-04-01T15:18:18.797", "last_editor_user_id": "21310", "owner_user_id": "21310", "post_type": "question", "score": 2, "tags": [ "swift", "ios", "objective-c", "storyboard" ], "title": "iOS「(シーン)A->B->C」 modalを重ねた遷移した「シーンC」でunwind segueを使うと「シーンB」が一瞬表示される", "view_count": 291 }
[]
33697
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "Google CGI API for Japanese\nInputで返ってくるjsonをGsonを使って解析したいのですが、解析結果の格納用にどのようなJavaのクラスを作ればいいのか分かりません。 \nパースする方法をご存知の方がいらっしゃいましたらご教授いただけると幸いです。\n\nGoogle CGI API for Japanese Inputで得られるjsonが次のようなものです:\n\n```\n\n [\n [\"ここでは\",\n [\"ここでは\", \"個々では\", \"此処では\"]\n ],\n [\"きものを\",\n [\"着物を\", \"きものを\", \"キモノを\"]\n ],\n [\"ぬぐ\",\n [\"脱ぐ\", \"ぬぐ\", \"ヌグ\"]\n ]\n ]\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T16:44:42.460", "favorite_count": 0, "id": "33699", "last_activity_date": "2019-07-18T11:02:00.517", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "java", "json" ], "title": "GsonでGoogle CGI API for Japanese Inputの結果をパースしたい", "view_count": 177 }
[ { "body": "JsonDeserializerを使えば、自分でパースすることができます。\n\n```\n\n class Response {\n String keyword;\n String[] results;\n \n public Response(String keyword, String[] results) {\n this.keyword = keyword;\n this.results = results;\n }\n }\n \n class ResponseDeserializer implements JsonDeserializer<Response> {\n \n @Override\n public Response deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)\n throws JsonParseException {\n JsonArray jsonArray = json.getAsJsonArray();\n \n String keyword = jsonArray.get(0).getAsString();\n String[] results = new Gson().fromJson(jsonArray.get(1), String[].class);\n \n return new Response(keyword, results);\n }\n }\n \n```\n\nこんな感じで定義しておいて、使うときに以下のように書きます。\n\n```\n\n Gson gson = new GsonBuilder()\n .registerTypeAdapter(Response.class, new ResponseDeserializer())\n .create();\n Response[] responses = gson.fromJson(json, Response[].class);\n \n```\n\n* * *\n\n逆にJsonに戻したい場合はJsonSerializerを作れば良いでしょう。\n\n```\n\n class ResponseSerializer implements JsonSerializer<Response> {\n \n @Override\n public JsonElement serialize(final Response src, Type typeOfSrc, JsonSerializationContext context) {\n JsonArray array = new JsonArray();\n array.add(src.keyword);\n \n JsonArray results = new JsonArray();\n for (String result : src.results) {\n results.add(result);\n }\n array.add(results);\n \n return array;\n }\n }\n \n```\n\n使うときは、以下のように。\n\n```\n\n Gson gson = new GsonBuilder()\n .registerTypeAdapter(Response.class, new ResponseDeserializer())\n .registerTypeAdapter(Response.class, new ResponseSerializer())\n .create();\n Response[] responses = gson.fromJson(json, Response[].class);\n \n System.out.println(gson.toJson(responses));\n \n```\n\noutput:\n\n```\n\n [[\"ここでは\",[\"ここでは\",\"個々では\",\"此処では\"]],[\"きものを\",[\"着物を\",\"きものを\",\"キモノを\"]],[\"ぬぐ\",[\"脱ぐ\",\"ぬぐ\",\"ヌグ\"]]]\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T03:14:37.880", "id": "33706", "last_activity_date": "2017-04-02T03:14:37.880", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7655", "parent_id": "33699", "post_type": "answer", "score": 1 } ]
33699
null
33706
{ "accepted_answer_id": null, "answer_count": 2, "body": "リスト内を部分一致で検索する方法について分からず困っております。 \n以下リストで、例えば’.xlsx’が含まれるものだけを、新しリストに追加したい場合、 \nコードをどのように記述すればいいのでしょうか? \ninはリスト内の検索では完全一致でしか適用しないような様子でした。 \nよろしくお願いいたします。\n\n↓これだけといけるのですが、\n\n```\n\n list = ['aaa.xlsx','bbb.xlsx','ccc.csv']\n newlist = []\n kensaku = 'aaa.xlsx'\n if kensaku in list:\n newlist.append(kensaku)\n \n```\n\n↓これだけいけません\n\n```\n\n list = ['aaa.xlsx','bbb.xlsx','ccc.csv']\n newlist = []\n kensaku = '.xlsx'\n if kensaku in list:\n newlist.append(kensaku)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T17:33:06.770", "favorite_count": 0, "id": "33700", "last_activity_date": "2017-04-01T22:37:25.883", "last_edit_date": "2017-04-01T18:42:00.427", "last_editor_user_id": "3605", "owner_user_id": "21314", "post_type": "question", "score": 3, "tags": [ "python" ], "title": "Python リスト内を部分一致で検索する方法について", "view_count": 48859 }
[ { "body": "こんな感じでどうでしょうか。\n\n```\n\n l = ['aaa.xlsx', 'bbb.xlsx', 'ccc.csv']\n newl = []\n kensaku = '.xlsx'\n if any(s.endswith(kensaku) for s in l):\n newl.append(kensaku)\n \n```\n\n`s.endswith(kensaku) for s in l`の部分は、`l`の要素を一つ一つ`kensaku`で終わっているか確認してブール値のリスト\n(実際はジェネレータですが) を返します。上の例だと`[True, True, False]`を返します。 \n`any`は、引数のリストの中の要素が一つでも`True`なら、`True`を返しますので、`any(s.endswith(kensaku) for s\nin l)`は全体として、`l`の中の文字列がどれか一つでも`kensaku`で終わっていれば`True`を返します。\n\n* * *\n\n余談ですが`list`は、Pythonでデフォルトで定義されている型です。\n\n```\n\n list = ['aaa.xlsx','bbb.xlsx','ccc.csv']\n \n```\n\nとすると上書きしてしまい、型名として使えなくなってしまうので避けたほうがいいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T19:22:47.743", "id": "33701", "last_activity_date": "2017-04-01T19:22:47.743", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3605", "parent_id": "33700", "post_type": "answer", "score": 3 }, { "body": "リスト要素それぞれについて部分一致したものを取り出す、という便利な機能はないので、以下のように書きます。\n\n```\n\n list = ['aaa.xlsx','bbb.xlsx','ccc.csv']\n newlist = []\n kensaku = '.xlsx'\n for l in list:\n if kensaku in l:\n newlist.append(l)\n \n```\n\n内包表記を使って以下のように書いても良いでしょう。\n\n```\n\n list = ['aaa.xlsx','bbb.xlsx','ccc.csv']\n newlist = [l for l in list if '.xlsx' in l]\n \n```\n\n拡張子を取り出したいのであれば、Hidekiさんが書かれているように、.endswithを使う方がより正確です。\n\n```\n\n list = ['aaa.xlsx','bbb.xlsx','ccc.csv']\n newlist = [l for l in list if l.endswith('.xlsx')]\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-01T22:37:25.883", "id": "33702", "last_activity_date": "2017-04-01T22:37:25.883", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "33700", "post_type": "answer", "score": 2 } ]
33700
null
33701
{ "accepted_answer_id": null, "answer_count": 1, "body": "Edit Modeの時の頂点の追加をCtrl+右クリックで行いたいと思い、 \nUser Preferencesで「Add Vertex」の項目を上書きし、 \nSave User Settingで保存しました。\n\nしかし、何度試みても、Ctrl+左クリックでの追加になってしまいます。\n\nすでにCtrl+右クリックに他のショートカットが振り当てられているのかと思い、 \nすべて検索して削除しましたが何も変わりませんでした。\n\nどこか変更場所などの間違いがございましたら、お教えいただきたいと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T01:29:59.053", "favorite_count": 0, "id": "33703", "last_activity_date": "2018-01-22T05:12:29.343", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21319", "post_type": "question", "score": 0, "tags": [ "blender" ], "title": "Blenderの「User Preferences」での変更が反映されない事例", "view_count": 88 }
[ { "body": "Add Vertex は別カテゴリ(Curve)になっています。Mesh 内を探さしましょう。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/KImRD.png)](https://i.stack.imgur.com/KImRD.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-22T05:12:29.343", "id": "41130", "last_activity_date": "2018-01-22T05:12:29.343", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "27002", "parent_id": "33703", "post_type": "answer", "score": 0 } ]
33703
null
41130
{ "accepted_answer_id": "33747", "answer_count": 1, "body": "# 実現したいこと\n\nrails4 ローカル環境\n\n現在メッセージ機能を実装してラインのようなメッセージのやりとりができるようにしたいと思っています。\n\n# 解決したい問題\n\nメッセージ機能は無事に実装できて、メッセージのやり取りをしているページで『相手のメッセージは左側』『自分のメッセージは右側』という表示にして吹き出しをつけて表示しようと思っています。\n\n吹き出しもCSSで実装したのですが、吹き出しをつけると下記の画像のように空の吹き出しが1つ勝手に表示されてしまいます。\n\n[![問題点](https://i.stack.imgur.com/MOmJw.png)](https://i.stack.imgur.com/MOmJw.png)\n\n私なりに原因を探ってみたところ、 \nCSSで枠線をつけるとこういう現象が出るため、枠線の付け方に問題がある?\n\nただ単に、メッセージのやり取りを一覧で表示して枠線をつけると、このような現象は起きなかったためメッセージの取得に関する記述が間違っている?\n\n怪しいのはここら辺かと思っているのですが、解決はできずにいます。\n\nどのようにしたらいいか教えていただけると嬉しいです。\n\n現在はこのように記述しています。\n\n`messages/index.html.erb`\n\n```\n\n <div class=\"container message\">\n <div class=\"wrapper col-md-8 col-md-offset-2 col-sm-10 message-index\">\n <div class=\"message-user-name\">\n <p><%= @conversation.target_user(current_user).name %>さんとのメッセージ</p>\n </div>\n \n <!-- メッセージが10件以上あれば以前のメッセージへのリンクを表示する -->\n <% if @over_ten %>\n <center><%= link_to '以前のメッセージをすべて表示', '?m=all' %></center>\n <% end %>\n \n <!-- メッセージを一件ずつ抽出 -->\n <div class=\"ui segment\">\n <% @messages.each do |message| %>\n <% if message.user_id == current_user.id %>\n <!-- 自分のメッセージ -->\n <% user = User.find(message.user_id) %>\n <div class=\"item-right\">\n <div class=\"balloon1\">\n <%= qiita_markdown(message.body) %>\n </div>\n <div class=\"clear\"></div>\n <p><%= message.message_time %></p>\n </div>\n <% else %>\n <!-- 相手のメッセージ -->\n <div class=\"item-left\">\n <% user = User.find_by(id: message.user_id) %>\n <%= link_to user_path(message.user_id) do %>\n <%= profile_img(message.user) %>\n <% end %>\n <div id=\"balloon\">\n <%= qiita_markdown(message.body) %>\n </div>\n <p><%= message.message_time %></p>\n </div>\n <% end %>\n <% end %>\n </div>\n \n <!-- メッセージの送信 -->\n <%= form_for [@conversation, @message], html: {class: \"ui reply form\"} do |f| %>\n <div class=\"message-field\">\n <%= f.text_area :body, class: \"form-control input-mysize-message\" %>\n <%= f.text_field :user_id, value: current_user.id, type: \"hidden\" %>\n <%= f.submit \"メッセージを送る\" %>\n </div>\n <% end %>\n \n```\n\n \n\n# 実際に出力されるHTML\n\n```\n\n <div class=\"container message\">\n <div class=\"wrapper col-md-8 col-md-offset-2 col-sm-10 message-index\">\n <div class=\"message-user-name\">\n <p>hogeさんとのメッセージ</p>\n </div>\n <!-- メッセージが10件以上あれば以前のメッセージへのリンクを表示する -->\n <!-- メッセージを一件ずつ抽出 -->\n <div class=\"ui segment\">\n <!-- 自分のメッセージ -->\n <div class=\"item-right\">\n <div class=\"balloon1\">\n <p>huga</p>\n </div>\n <div class=\"clear\"></div>\n <p>04/02/17 at 5:34 PM</p>\n </div>\n <br>\n <!-- 自分のメッセージ -->\n <div class=\"item-right\">\n <div class=\"balloon1\">\n \n </div>\n <div class=\"clear\"></div>\n <p></p>\n </div>\n <br>\n </div>\n \n <!-- メッセージの送信 -->\n <form class=\"ui reply form\" id=\"new_message\" action=\"/conversations/6/messages\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"authenticity_token\" value=\"NdypJ7WEIU/M0JAzIFGZHq4yBBZX8MMtVxaEqqFAvtYY9PzzG6yjj10XF/NMeqnAMjZZHdncS946HxF5N3DiAg==\" />\n <div class=\"message-field\">\n <textarea class=\"form-control input-mysize-message\" name=\"message[body]\" id=\"message_body\">\n </textarea>\n <input value=\"3\" type=\"hidden\" name=\"message[user_id]\" id=\"message_user_id\" />\n <input type=\"submit\" name=\"commit\" value=\"メッセージを送る\" />\n </div>\n </form>\n </div>\n </div>\n \n```\n\n# messages_controller\n\n```\n\n class MessagesController < ApplicationController\n before_action :authenticate_user!\n \n before_action do\n @conversation = Conversation.find(params[:conversation_id])\n end\n \n def index\n @messages = @conversation.messages\n if @messages.length > 10\n @over_ten = true\n @messages = @messages[-10..-1]\n end\n \n if params[:m]\n @over_ten = false\n @messages = @conversation.messages\n end\n \n if @messages.last\n if @messages.last.user_id != current_user.id\n @messages.last.read = true\n end\n end\n \n @message = @conversation.messages.build(user: current_user)\n end\n \n def create\n @message = @conversation.messages.build(message_params)\n if @message.save\n redirect_to conversation_messages_path(@conversation)\n end\n end\n \n private\n def message_params\n params.require(:message).permit(:body, :user_id)\n end\n end\n \n```", "comment_count": 7, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T02:18:11.533", "favorite_count": 0, "id": "33705", "last_activity_date": "2017-04-03T12:03:24.203", "last_edit_date": "2017-04-03T06:06:38.030", "last_editor_user_id": "21311", "owner_user_id": "21311", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby" ], "title": "Ruby on Rails メッセージ機能でのメッセージの取得について", "view_count": 883 }
[ { "body": "`index` メソッドの最後の行、\n\n```\n\n @message = @conversation.messages.build(user: current_user)\n \n```\n\nを\n\n```\n\n @message = Message.new(user: current_user)\n \n```\n\nに変更すれば治ると思います。\n\n* * *\n\n以下、理由です。 \nまず、\n\n```\n\n @messages = @conversation.messages\n \n```\n\nで、`@conversation` に紐付いたメッセージを取得して、最後に、\n\n```\n\n @message = @conversation.messages.build(user: current_user)\n \n```\n\nで、その `@conversation` にメッセージを追加しています。 \nその追加分が空のメッセージとなって表示されているのだと思います。\n\n直接的に `@messages` と関係ないように見えますが、 \n`@messages` と `@conversation.messages` は同じオブジェクトを指していますので、 \n`@conversation` へのメッセージの追加は `@messages` への追加と同じことです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T12:03:24.203", "id": "33747", "last_activity_date": "2017-04-03T12:03:24.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5288", "parent_id": "33705", "post_type": "answer", "score": 1 } ]
33705
33747
33747
{ "accepted_answer_id": null, "answer_count": 0, "body": "初めてApp Store公開用のpkgファイルを作成しているのですが、Achiveファイルの作成が出来ていません。(\n**一応Archiveは作成されるのですが、正しく作成されていないと思っています** ) \n下記の設定でArciveを作成しています。しかし、\n\n * この設定でRunするとFinished Runとなりアプリケーションは立ち上がりません。\n * ArchiveされたファイルをOrganizerでのValidateするとエラーとはならず、Valifation \nSuccessfulでした。\n\n * privisioning profileをDevelopmentのMac App Development, DistributionのDeveloper IDで設定してArciveを作成し、exportしたアプリは実行可能でした。\n * DistributionのMac App Storeのprivisioning profileでArchiveを作成し、それをexportしたpkgをインストールしたアプリは起動できず、アプリケーションはクラッシュします。そのときのException Typeは、EXC_CRASH (Code Signature Invalid)となっていました。\n * privisioning profileの設定の変更以外の変更(ソースコードの変更)は行なっていません。\n\nprovisioning profile等のsigningの設定に不備があると考えているのですが、その不備を指摘頂けませんか。\n\n[Xcode ver. 8.3] \n(General:Signing) Debug, Release共に同一に設定しています。 \nProvisioning Profile: XC OSX: xxx \nTeam: xxx \nSigning Certificate: 3rd Party Mac Developer Application: xxx\n\n(Capabilities) \nApp Sandbox: ON\n\n(Build Setting:Signing) \nCode Signing Identity: Mac Distribution \nDeveloper Team: xxx \nProvisioning Profile: XC OSX: xxx\n\n[Apple Developer] \n(Provisioning Profiles) \nName: XC OSX: xxx \nType: Mac Distribution \nApp ID: xxx \nCertificates: 1 total \nDevices: 0 total \nEnabled Services: In-App Purchase \nStatus: Active \nExpires: Apr 02, 2018 \nCerficates: xxx(Mac App Distribution)\n\n[Cetificates] Xcode8.3から作成 \nName: xxx \nType: Mac App Distribution \nExprires: Apr 02, 2018\n\nまた、不足している情報などありましたらお知らせ下さい。 \nよろしくお願いします。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T03:17:58.800", "favorite_count": 0, "id": "33707", "last_activity_date": "2017-07-21T18:05:17.623", "last_edit_date": "2017-07-21T18:05:17.623", "last_editor_user_id": "754", "owner_user_id": "20521", "post_type": "question", "score": 0, "tags": [ "macos", "app-store" ], "title": "App Store公開用Archiveの作成方法について", "view_count": 118 }
[]
33707
null
null
{ "accepted_answer_id": "33709", "answer_count": 2, "body": "以下のWebページによると、ON句がJOIN句よりも先に評価されるそうです。 \n[SELECT (Transact-SQL)](https://technet.microsoft.com/ja-\njp/library/ms189499\\(v=sql.110\\).aspx) <https://technet.microsoft.com/ja-\njp/library/ms189499(v=sql.110).aspx> \nしかし、JOIN句に別名を付したときその別名はON句でも使用できます。 \n例: `select * from data d inner join mst m on m.num=d.num` \n評価順序の関係でSELECT句に付した別名がWHERE句で使用できないことに対応するのであれば、JOIN句→ON句の順に評価されているのではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T04:23:37.180", "favorite_count": 0, "id": "33708", "last_activity_date": "2017-04-02T09:39:53.213", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19705", "post_type": "question", "score": 2, "tags": [ "sql", "sql-server" ], "title": "ON句がJOIN句よりも先に評価されるのは本当ですか?", "view_count": 5994 }
[ { "body": "論理的な処理としては`JOIN`~`ON`の評価は以下の三段階に分かれています。\n\n 1. `JOIN`句のテーブルを評価し、直積を求める。(≒`CROSS JOIN`)\n 2. `ON`句の条件に該当しない行を除外する。\n 3. `OUTER JOIN`である場合は必要な未結合の行を追加する。\n\nですので評価の開始はかならず`JOIN`が先なのですが、完了順では遅くなる場合があります。またこの場合は`ON`の評価に使用した行とは異なる結果が出力されます。TechNetの記述はバインド順についての言及であるので、結果セットの確定タイミングを踏まえて`JOIN`を後ろにしているのではないでしょうか。\n\nなお詳細な評価プロセスはMicrosoftが出版しているリファレンスである『T-SQL\nQerying』で説明されています。当該書籍に説明されている`SELECT`文の完全な評価フローは以下のようになります。[![T-SQL Logical\nQuery Processing\nFlow](https://i.stack.imgur.com/MIbtv.png)](https://i.stack.imgur.com/MIbtv.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T06:50:16.860", "id": "33709", "last_activity_date": "2017-04-02T09:39:53.213", "last_edit_date": "2017-04-02T09:39:53.213", "last_editor_user_id": "5750", "owner_user_id": "5750", "parent_id": "33708", "post_type": "answer", "score": 4 }, { "body": "SQLはインタプリタではないので、構文解析をすることと式を評価することは別です。\n\n>\n```\n\n> select * from data d inner join mst m on m.num=d.num\n> \n```\n\n構文解析中に`data`テーブルに`d`と名を付け、`mst`テーブルに`m`を名を付けた上で、実行時に`m.num`と`d.num`にアクセスしているに過ぎません。\n\n> 評価順序の関係でSELECT句に付した別名がWHERE句で使用できないことに対応する\n\nわけではありません。`SELECT`句でカラムに名前を付けたとしても、実行時、`WHERE`句の段階ではまだ`SELECT`句が実行されておらず値が存在しないためにアクセスできないだけです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T08:54:10.737", "id": "33712", "last_activity_date": "2017-04-02T08:54:10.737", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "33708", "post_type": "answer", "score": 1 } ]
33708
33709
33709
{ "accepted_answer_id": "33739", "answer_count": 2, "body": "```\n\n $.ajax({\n type:'POST',\n url: URL, // POST送信先のURL\n crossDomain: true,\n contentType:'application/x-www-form-urlencoded',\n data: date,\n success: function(json_data) {\n if (!json_data[0]) {\n alert('Transaction error. ' + json_data[1]);\n return;\n }\n console.log(json_data);\n },\n error: function() {\n alert('Server Error. Pleasy try again later.');\n },\n complete: function() {\n button.attr('disabled', false);\n }\n });\n });\n \n```\n\n上記のような感じでWordpressで外部サービスにPOSTしたいのですが、\n\n```\n\n XMLHttpRequest cannot load \"送信先のURL\". No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '送信元URL' is therefore not allowed access.\n \n```\n\n上記のようなエラーを吐いてしまいます。\n\n以下のような記事を参考にしましたがうまくいかず、wordpressの仕様でうまくいっていないのでしょうか? \n<https://stackoverflow.com/questions/20433655/no-access-control-allow-origin-\nheader-is-present-on-the-requested-resource-or>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T06:54:36.390", "favorite_count": 0, "id": "33710", "last_activity_date": "2017-04-03T07:35:04.560", "last_edit_date": "2017-05-23T12:38:56.083", "last_editor_user_id": "-1", "owner_user_id": "9988", "post_type": "question", "score": 0, "tags": [ "api", "wordpress", "ajax" ], "title": "Wordpressでajaxで外部のサービスのAPIにPOSTしたいとき", "view_count": 1010 }
[ { "body": "本件「クロスドメイン」と言われる動作になっており、 \njavascriptが置いてあるサーバー(質問者様のサーバー)の問題ではなく \najaxでアクセスしようとしているサーバー(外部サービスのサーバー)の問題となります。\n\nご記載いただいているエラーにも記載されていますが。 \nレスポンスヘッダーにAccess-Control-Allow-Originが必要だが、ない。 \nと言われております。\n\nPublicでサービスを公開しているのではない場合、APIキーの認証だったりドメインの登録、署名の登録が必要だったりします。 \n「外部サービス」側でAPIキーに認証が必要だったり、ドメイン指定が必要だったり、のようなユーザー設定項目が存在しませんでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T10:19:25.497", "id": "33713", "last_activity_date": "2017-04-02T10:19:25.497", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19716", "parent_id": "33710", "post_type": "answer", "score": 0 }, { "body": "WordPressは多分関係ないと思うので、WordPressを使わないページで同様のコードを書いて試してみていただきたいですが...。\n\nブラウザでは Same-origin Policy\nというルールに基づき、異なるドメイン間での通信に制限があります。具体的には、CORSというルールに従ってサーバー側が「そのドメインからは呼び出してもいい」ということをレスポンスヘッダを使ってブラウザに伝えなければいけません。\n\nそして `No 'Access-Control-Allow-Origin' header is present on the requested\nresource.` はそのようなヘッダがないことを示しています。ですからまず考えられるのは、\n**そのAPIが異なるドメインからの呼び出しに対応していない**\n、という可能性です。この照会は実際のPOSTの前に行われるので、APIキーの渡し方以前の問題です。\n\nこのあたりは呼び出したいAPIを具体的に提示していただかないとこちらでは調べようがないので、ここでは書けないのでしたらご自身でその外部サービスのヘルプを読んだり、問い合わせていただくことになります。\n\nもし対応していなければ、ブラウザから直接ではなく、呼び出し元ページのあるサーバーからPHPなどのプログラムで呼び出しを行う必要があるかと思います。\n\nちなみに `$.ajax()` の crossDomain オプションは、異なるドメインへの通信では自動的に true\nになるので、通常明示する必要はありません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T07:35:04.560", "id": "33739", "last_activity_date": "2017-04-03T07:35:04.560", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "33710", "post_type": "answer", "score": 1 } ]
33710
33739
33739
{ "accepted_answer_id": null, "answer_count": 0, "body": "進捗状況を数値でアウトプットしつつ作業を行いたく以下のように書きました。\n\n```\n\n for (int iRun = 0; iRun <nRun; iRun++){\n double[] d = new double[10000];\n Arrays.fill(d, 1);\n if (100 < nRun && iRun % (nRun / 100) == 0)\n System.err.print(\"\\rWorking \" + Math.ceil(100.0 * iRun / nRun) + \"%\");\n }\n System.err.println(\"\\rWorking \" + Math.ceil(100.0 * iRun / nRun) + \"%\");\n System.err.println(\"fin\");\n \n```\n\n, \nこちらが想定しているコンソール上での最終状態です。(数値は変化しつつ100で止まる)\n\n```\n\n Working 100.0%\n fin\n \n```\n\n, しかしおおくの場合(5回に3、4回は)期待通りいかず、以下のようになります。\n\n```\n\n Working 100.0%Working 100.0%\n fin\n \n```\n\n. \nfor終了後に `Thread::sleep`等を用いても改善は見られません。\n\n```\n\n double[] d = new double[10000];\n Arrays.fill(d, 1);\n \n```\n\n部は 本来の作業の部分を置き換えていますが、上記でも問題は発生しています。\n\n`nRun=10000`において発生しております。`nRun`が小さいときは発生しない模様です。(私の環境下では)\n\n恐らくコンパイラによる所だと思いますが、どうやって常に期待どおりの結果にすることができるでしょうか? \n実行環境は \nOS:CentOS 7.3 \nJava: 1.8.0_121 \nIntelliJ IDEA the Java IDE 2017.1 上での実行 \nとなっております。\n\n# \n皆様の回答から、IDE上での実行が原因である可能性が濃厚で、実際に他のターミナルからの実行では発生しませんでした。詳しい方には呆れられても仕方のない顛末ですが、気がつかせていただきありがとうございました。", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T07:13:36.050", "favorite_count": 0, "id": "33711", "last_activity_date": "2017-04-05T03:15:43.063", "last_edit_date": "2017-04-05T03:15:43.063", "last_editor_user_id": "10768", "owner_user_id": "10768", "post_type": "question", "score": 2, "tags": [ "java" ], "title": "Java System.err.printの制御", "view_count": 431 }
[]
33711
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "以下のコードのような`yr`(年)に関するloopを回して、クエリから一部データを抽出し、加工したいのですが、 `name 'yr' is not\ndefined` というエラーが出て実行してくれません。\n\nクエリの中で変数を使うときには、下のような表記ではいけないのでしょうか? \n正しい表記法を教えて頂けますと幸いです。\n\n```\n\n for yr in range(2004,2010):\n TF=TS.query('m>(yr+1)*12+0 and m<(yr+1)*12+10')[['CID','m']]\n   …\n \n```\n\n```\n\n [TS](テストデータ)\n ID m\n A 201001\n C 200510\n E 200601\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2017-04-02T13:34:37.970", "favorite_count": 0, "id": "33714", "last_activity_date": "2019-05-13T09:43:58.480", "last_edit_date": "2019-05-13T09:43:58.480", "last_editor_user_id": "29826", "owner_user_id": "21324", "post_type": "question", "score": 0, "tags": [ "python", "pandas" ], "title": "Pandasでquery実行の際に name 'yr' is not definedというエラー", "view_count": 2083 }
[ { "body": "一応コメント欄で解決したと思いますが、後から見る人の参考になるように…\n\nPandasのデータフレームの`query`構文の中で、ローカル変数を参照するには、 \n`変数名`の代わりに`@変数名`を使う必要があります。\n\nたとえば、今回の質問であれば`@yr`とすることで参照することができます。\n\n詳しくは、 \n<http://pandas.pydata.org/pandas-\ndocs/stable/generated/pandas.DataFrame.query.html> \nをご参照ください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T14:33:06.513", "id": "33718", "last_activity_date": "2017-04-02T14:33:06.513", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6092", "parent_id": "33714", "post_type": "answer", "score": 1 } ]
33714
null
33718
{ "accepted_answer_id": null, "answer_count": 1, "body": "Matlabのサンプルソースコードを読まなければならない必要に駆られたのですが未経験なものでちょっとした文法も良く分からない状況です。\n\n```\n\n for t=1:1000\n I=100*(rand(N,1)-0.5);\n end;\n \n```\n\n上記のコードの意味を教えていただけないでしょうか。 \n1000回ループしている意味は分かるのですがそのあのIへ一体何をしているのかがいまいち分かりません。 \nMatlabを普段から使っている方にしてみれば何のことはないコードだとは思いますが、宜しくお願いします。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T14:02:38.903", "favorite_count": 0, "id": "33715", "last_activity_date": "2020-07-24T05:57:32.247", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13260", "post_type": "question", "score": 0, "tags": [ "matlab" ], "title": "matlabの文法について", "view_count": 170 }
[ { "body": "コメントで解決されたようですので、回答として編集・転記いたします。\n\nマニュアルからのコピペ的説明ですが、「区間 (-50, 50) の一様分布した実数値から成る、N 行 1 列のベクトルを生成しています」。 \n[一様分布の乱数 - MATLAB rand](https://jp.mathworks.com/help/matlab/ref/rand.html)\nを読むと理解できるかと思います。\n\nつまり質問文のコードは、(0~1.0)の実数を返す乱数に0.5を引くことで(-0.5~0.5)までの範囲にしぼった後でさらに100を掛けることで(-50.0~50)へ拡張して、それをN行1列のベクトルとしてIに代入しています。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-07-24T05:57:32.247", "id": "68886", "last_activity_date": "2020-07-24T05:57:32.247", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9820", "parent_id": "33715", "post_type": "answer", "score": 1 } ]
33715
null
68886
{ "accepted_answer_id": null, "answer_count": 1, "body": "Groupbyを用いて、ある変数が最大の時の別の変数の値を取ってきたいのですが、どのように表記すれば良いでしょうか。 \n例えば、<http://ailaby.com/groupby_easy/> \nにある「max\nを適用すると」の箇所で、値引きが最大の時の価格データ(150000,70000)を取ってきたいのですが、どのような関数の表現になるか教えて頂けますでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T14:21:45.117", "favorite_count": 0, "id": "33717", "last_activity_date": "2017-04-03T00:09:26.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21324", "post_type": "question", "score": 0, "tags": [ "python", "pandas" ], "title": "Groupbyの使用法", "view_count": 138 }
[ { "body": "CUSTOMER列をキーにしてfor文で回した例です。 \nこれはあまりスマートではないので、元のDataFrameにインデックスをつけるとよいかもしれません。\n\n```\n\n from pandas import DataFrame\n \n df = DataFrame(\n [['AA', 'TV', 150000, 20000], ['BB', 'Camera', 70000, 10000],\n ['AA', 'Video', 2000, 200], ['AA', 'Video', 3000, 150],\n ['BB', 'TV', 200000, 8000], ['BB', 'Camera', 50000, 5000],\n ['AA', 'Video', 1000, 200]],\n columns=['CUSTOMER', 'PRODUCT', 'PRICE', 'DISCOUNT'])\n \n grouped = df.groupby('CUSTOMER')\n discount_max = grouped['DISCOUNT'].max()\n \n for customer in discount_max.index:\n print(df.loc[(df['CUSTOMER'] == customer) & \n (df['DISCOUNT'] == discount_max[customer]),\n 'PRICE'].values[0])\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T00:09:26.687", "id": "33722", "last_activity_date": "2017-04-03T00:09:26.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7754", "parent_id": "33717", "post_type": "answer", "score": 1 } ]
33717
null
33722
{ "accepted_answer_id": null, "answer_count": 1, "body": "このようなプログラムを、XcodeのPlaygroundで作りました \nしかし、touchesBeganが動作しません \n上手く行けば、「touched」と表示されるはずなのですが、表示されません\n\n```\n\n import UIKit\n import SpriteKit\n import PlaygroundSupport\n \n class set: SKScene {\n //var Progress = 0\n //var button: SKNode? = nil\n \n func start() {\n let sceneWidth = 450.0\n let sceneHeight = 800.0\n //var ProcessSeed = 0\n let sceneView = SKView(frame: CGRect(x: 0.0, y: 0.0, width: sceneWidth, height: sceneHeight))\n PlaygroundPage.current.liveView = sceneView\n let back: SKScene = SKScene(size: CGSize(width: sceneWidth, height: sceneHeight))\n back.backgroundColor = UIColor.white\n sceneView.presentScene(back)\n \n let character = SKSpriteNode(imageNamed: \"SobacchiStand.png\")\n character.position = CGPoint(x: sceneWidth/2, y: sceneHeight/2)\n character.xScale = 0.5;\n character.yScale = 0.5;\n back.addChild(character)\n \n let button = SKSpriteNode(imageNamed: \"Button.png\")\n button.xScale = 0.1;\n button.yScale = 0.1;\n button.position = CGPoint(x: 400.0, y:100.0)\n button.zPosition = 1\n button.name = \"button\"\n back.addChild(button)\n \n button.isUserInteractionEnabled = true\n }\n func doit() {\n print(\"実行\")\n print(\"されています\")\n }\n \n /* override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {\n if let touch = touches.first as UITouch? {\n let location = touch.location(in: self)\n if self.atPoint(location).name == \"button\" {\n print(\"button tapped\")\n }\n }\n }*/\n override func touchesBegan(_ touches: Set<UITouch>,with event: UIEvent?) \n { //super.touchesBegan(touches, with: event)\n print(\"touched\")\n }\n override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {\n super.touchesEnded(touches, with: event)\n print(\"touchend\")\n }\n }\n \n let first = set()\n let second = first.start()\n var Progress = 0\n \n /*while Progress <= 100 {\n first\n }*/\n \n```\n\nエラー自体は出ていない上、どのサイトを見ても、間違っている点が見当たらないのですが、どこか間違っているのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T18:20:31.103", "favorite_count": 0, "id": "33719", "last_activity_date": "2021-04-02T02:08:00.893", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21307", "post_type": "question", "score": 0, "tags": [ "swift", "spritekit" ], "title": "touchesBeganが動作しない", "view_count": 388 }
[ { "body": "> エラー自体は出ていない上、\n\n以前なさった[質問](https://ja.stackoverflow.com/questions/33690/skspritenode%E3%81%8Cnil%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%97%E3%81%BE%E3%81%86)のコメント欄で指摘させていただいたのですが、提示のコードは、じっさいPlaygroundに記述して、実行したものを、そのままコピーしてください。異なるものを提示していただくと、いかに正しい的確な回答をしても、「回答どおりにしても解決しない」ということが起きてしまいます。\n\n_最後から2行目_\n\n```\n\n let second = first.start()\n \n```\n\nここで、「Constant 'second' inferred to have type '()', which may be\nunexpected」という警告(ビルドはできるが、書式に問題があるという警告)が出ます。このことから、提示のコードと、Playgroundで実行したコードが、異なることがわかります。メソッド`start()`は、返り値がない、言い換えると返り値が`Void`(`()`)なので、変数`second`の型を推論すると`Void`(`()`)になっちゃうよ?という警告です。`let\nsecond =`を削除してください。\n\n* * *\n\n本題に入ります。\n\n_15行目_\n\n```\n\n let back: SKScene = SKScene(size: CGSize(width: sceneWidth, height: sceneHeight))\n \n```\n\nこれを書き換えてください。\n\n```\n\n let back = set(size: CGSize(width: sceneWidth, height: sceneHeight))\n \n```\n\nこの変更で、意図どおりの結果になりますが、無駄があるコードです。 \nそれと、Swiftの推奨命名規則として、クラス名は大文字で始めるようにしてください。\n\n```\n\n class set: SKScene {\n // 推奨は、こう\n class Set: SKScene {\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-02T23:15:45.073", "id": "33721", "last_activity_date": "2017-04-02T23:15:45.073", "last_edit_date": "2017-04-13T12:52:39.113", "last_editor_user_id": "-1", "owner_user_id": "18540", "parent_id": "33719", "post_type": "answer", "score": 0 } ]
33719
null
33721
{ "accepted_answer_id": "33749", "answer_count": 1, "body": "df1は、indexが2015-01-04,2015-01-05,2015-01-06のように日次で入っています。 \ndf2は、indexが2015-01-04,2015-01-11,2015-01-18のように週次で入っています。\n\ndf2のindexをdf1に揃え、df2の2015-01-04と同じ値が2015-01-04,01-05,01-06,01-07、、の一週間に入るようにするには、どのようにコードを書けばよいのでしょうか。\n\n分かる方いらっしゃいましたら、ご教授よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T02:20:47.737", "favorite_count": 0, "id": "33724", "last_activity_date": "2017-04-03T12:24:33.960", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20949", "post_type": "question", "score": -1, "tags": [ "python", "pandas" ], "title": "週次データを日次に格納する方法", "view_count": 281 }
[ { "body": "あんまりかっこよくないですが、以下でどうでしょうか。\n\n```\n\n for index in df2.index:\n df1[(df1.index >= index) & (df1.index < index+pd.Timedelta(days=7))]=df2.ix[index,:][0]\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T12:24:33.960", "id": "33749", "last_activity_date": "2017-04-03T12:24:33.960", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19716", "parent_id": "33724", "post_type": "answer", "score": 0 } ]
33724
33749
33749
{ "accepted_answer_id": "33728", "answer_count": 2, "body": "恐れ入ります。 \nasp.netのServer.Transferでページ遷移をしていますが \n**Transfer後に”自分”のURL** はどこで取得できるでしょうか? \nつまり\n\n```\n\n Server.Transfer(\"/dirA/page1.aspx\")\n \n```\n\nで遷移したページ/dirA/page1.aspxで自分のURL「/dirA/page1.aspx」を”動的”に知りたい \nという間抜けな話です。\n\nちなみに、以下\n\n```\n\n Page.PreviousPage.Request.Url\n Page.Request.Url\n \n```\n\nいずれもTransfer前のURIですね。\n\n**Transfer前にどこかに”わざわざ”保存** しておかないと \n”自分”のURLすらも取れないのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T02:29:21.973", "favorite_count": 0, "id": "33725", "last_activity_date": "2017-04-03T04:19:22.950", "last_edit_date": "2017-04-03T04:19:22.950", "last_editor_user_id": "4236", "owner_user_id": "20996", "post_type": "question", "score": 0, "tags": [ "asp.net" ], "title": "asp.net:server.transfer後のurl(?)の取得方法", "view_count": 1326 }
[ { "body": "これが最善であるかは分かりませんが、`Page.GetType().FullName`で\n\n> ASP.dir1_page1_aspx\n\nという物理パスに基づいた型名が参照できます。ですので\n\n```\n\n GetType().FullName.Substring(4).Replace(\"_aspx\", \".aspx\").Replace('_', '\\\\')\n \n```\n\nの要領で変換できます。ただし元から`_`が含まれているような場合は特別な考慮が必要です。\n\nまた状況によっては`GetType().BaseType.FullName`の名称を使用したほうが良いかもしれません。こちらは各ASPXファイルの`Inherits`属性に記述されている値が取得できますが、変更可能ですので実際のディレクトリー構成とは一致していない可能性があります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T03:12:01.377", "id": "33727", "last_activity_date": "2017-04-03T03:25:50.343", "last_edit_date": "2017-04-03T03:25:50.343", "last_editor_user_id": "5750", "owner_user_id": "5750", "parent_id": "33725", "post_type": "answer", "score": 0 }, { "body": "[`Server.Transfer()`メソッド](https://msdn.microsoft.com/ja-\njp/library/y4k58xk7\\(v=vs.110\\).aspx)はブラウザーに対して元のURLのまま、返すコンテンツを切り替えるものですから\n\n> いずれもTransfer前のURIですね\n\nは当然の結果ですし\n\n> **Transfer前にどこかに”わざわざ”保存** しておかないと”自分”のURLすらも取れないのでしょうか。\n\n正しく自分のURLが取得できています。\n\n`Transfer()`後、処理しているURLを取得するには[`Request.CurrentExecutionFilePath`プロパティ](https://msdn.microsoft.com/ja-\njp/library/system.web.httprequest.currentexecutionfilepath\\(v=vs.110\\).aspx)を使用します。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T04:17:40.093", "id": "33728", "last_activity_date": "2017-04-03T04:17:40.093", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "33725", "post_type": "answer", "score": 0 } ]
33725
33728
33727
{ "accepted_answer_id": null, "answer_count": 1, "body": "恐れ入ります。 \nまずは現象を説明します。\n\n```\n\n /dirBefore/xxx.aspxで\n Server.Transfer(\"/dirAfter/yyy.aspx\")を実行し表示された\n /dirAfter/yyy.aspxで\n <asp:TextBox AutoPostBack=\"true\"/>からポストバックすると\n フォームのactionが\"/dirBefore/yyy.aspx\"に書き換わってしまう\n \n```\n\nちなみに\n\n```\n\n <asp:button UseSubmitBehavior=\"false\"/>\n \n```\n\nで先に一度サブミットさせると、以降症状は起きません。\n\nそこで質問は \nこの書き換えはどのモジュールで行っていて \nどうすれば制御できるのか \nです。\n\n* * *\n\nちなみに、こちら \nASP.NET Web フォーム用の URL 書き換え \n<https://technet.microsoft.com/ja-jp/library/ee890797.aspx> \nは参照し、以下のようにしましたが理解が及ばず解決しません。\n\nForm.Actionの設定を試し \n以下の絶対パスではひとまずは成功していましたが\n\n```\n\n Private Sub Page_Load(・・・) Handles MyBase.Load\n Page.Form.Action = Page.Request.CurrentExecutionFilePath\n End Sub\n \n```\n\nある事情からセッションをクッキーレスにしなければならなくなり \nそのため以下のように(手抜きですが)相対パスに変更しましたが \nそうするとサブミット時に書き換えられてしまうケースが発生します。\n\n```\n\n Private Sub Page_Load(・・・) Handles MyBase.Load\n Page.Form.Action = \"..\" & Page.Request.CurrentExecutionFilePath\n End Sub\n \n```\n\n書き換えられるのは、Transfer前後のパスの深度が異なる場合のようですが \n未確認です。\n\nそもそもformのactionがブラウザのソースのままで \n勝手に書き換えらることさえなければこんな苦労は無用です。 \n書き換え動作を無効にするか、さもなくば書き換えるパスを操作する方法知りたいということです。\n\nよろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2017-04-03T04:26:23.487", "favorite_count": 0, "id": "33730", "last_activity_date": "2018-05-27T14:43:43.183", "last_edit_date": "2018-05-27T14:43:43.183", "last_editor_user_id": "2238", "owner_user_id": "20996", "post_type": "question", "score": -1, "tags": [ "asp.net" ], "title": "postBackでフォームのactionが書き換わるのを制御したい", "view_count": 519 }
[ { "body": "非同期ポストバックで送られてくるアクションが何らかの理由で`Server.Transfer`を使用しない場合と同じ`./yyy.aspx`となっているのだと思われます。\n\n対策としてはコードビハインドの適当なイベントで`Page.Form.Action`を設定すれば`action`属性を明示することが出来ます。共通化するなら`Page_PreRenderComplete`などでしょうか。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T05:49:45.733", "id": "33732", "last_activity_date": "2017-04-03T05:49:45.733", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "33730", "post_type": "answer", "score": 0 } ]
33730
null
33732
{ "accepted_answer_id": "33740", "answer_count": 1, "body": "サイトのナビゲーションなどによくある、選択されている箇所に背景色を付けたいのですが、 \nどのようにすれば良いのでしょうか? \n例えば以下の場合、会社案内をクリックしたとしたら、`<li>会社案内</li>`の背景色を赤色とかにしたいです。\n\n```\n\n <ul class=\"nav\">\n <li>会社案内</li>\n <li>製品一覧</li>\n <li>お問い合わせ</li>\n </ul>\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T05:45:52.483", "favorite_count": 0, "id": "33731", "last_activity_date": "2017-04-03T07:46:07.697", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12323", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "jquery", "css" ], "title": "サイトのナビゲーションで、選択されている箇所に背景色を付けたい。", "view_count": 14332 }
[ { "body": "クリックした時の動作をイベントハンドラとして登録しておく。\n\nクリックした時の動作は、 \ncssとして`background-color`を書き換えてもいいが、 \ncss は別に用意しておきクラス付け(例として`selected`とします)を変更することでcssを切り替える。 \n現在選択されている(`class='selected'`になっている)要素からクラスを取り除く \nクリックした要素にクラス付けをする。\n\njQuery を利用した例:\n\n```\n\n ul.nav li {\r\n background-color: transparent; /* default value */\r\n }\r\n ul.nav li.selected {\r\n background-color: red;\r\n }\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script>\r\n <script>\r\n $(function(){\r\n $(\"ul.nav li\").click(function(){\r\n $(\"ul.nav li.selected\").removeClass(\"selected\");\r\n $(this).addClass(\"selected\");\r\n });\r\n });\r\n </script>\r\n <ul class=\"nav\">\r\n <li>会社案内</li>\r\n <li>製品一覧</li>\r\n <li>お問い合わせ</li>\r\n </ul>\n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T07:46:07.697", "id": "33740", "last_activity_date": "2017-04-03T07:46:07.697", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "33731", "post_type": "answer", "score": 1 } ]
33731
33740
33740
{ "accepted_answer_id": "33755", "answer_count": 1, "body": "既存のASP.NET MVC5プロジェクトにAngular2をインストールするため、 \n<http://www.mithunvp.com/using-angular-2-asp-net-mvc-5-visual-studio/>\nを参考にしていたのですが、npm installで\n\n```\n\n UNMET PEER DEPENDENCY [email protected]\n UNMET PEER DEPENDENCY [email protected]\n npm WARN [email protected] requires a peer of [email protected] but none was installed.\n npm WARN [email protected] requires a peer of zone.js@^0.7.2 but none was installed.\n \n```\n\nと表示されてしまいます。(node_modulesは作成される)\n\nそのまま実行しても、zone.js等が見つからず、エラーが出てしまいます。[![画像の説明をここに入力](https://i.stack.imgur.com/I1Kas.png)](https://i.stack.imgur.com/I1Kas.png)\n\n依存関係を解決するにはどのようにすればよいでしょうか? \nよろしくお願い致します。\n\n手順\n\n 1. node.js(v6.10.1 LTS)をインストール\n 2. TypeScript for Visual Studio 2015(v2.2.2)をインストール\n 3. 参考にしたサイトの[デモプロジェクト](https://github.com/mithunvp/ng2Mvc5Demo)をダウンロード\n 4. package.jsonのあるパスでnpm install(ここで上記のWARN)\n 5. そのまま実行すると画像のエラー\n\n環境 \nWindows10 \nVisual Studio 2015", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T06:16:44.147", "favorite_count": 0, "id": "33733", "last_activity_date": "2017-04-04T03:29:43.187", "last_edit_date": "2017-04-03T08:53:15.697", "last_editor_user_id": "19110", "owner_user_id": "21330", "post_type": "question", "score": 0, "tags": [ "node.js", "npm" ], "title": "npm installでUNMET PEER DEPENDENCY", "view_count": 1317 }
[ { "body": "クリーンな状態で`npm install`してみましたが、特に問題は確認できませんでした。 \n依存関係の変化で発生したトラブルだと思われますので、一度次の手順でリセットしてみてください。\n\n 1. `node_modules`ディレクトリを削除\n 2. `npm cache clean`\n 3. `npm install`", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T03:29:43.187", "id": "33755", "last_activity_date": "2017-04-04T03:29:43.187", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19925", "parent_id": "33733", "post_type": "answer", "score": 1 } ]
33733
33755
33755
{ "accepted_answer_id": "33748", "answer_count": 2, "body": "お世話になります。\n\niOS10と9に対応したいアプリの通知処理を作っています。 \niOS9ではフォアグラウンドのとき通知が表示されないので通知の受信を\n\n```\n\n application(_ application: UIApplication, didReceive notification: UILocalNotification)\n \n```\n\nを使って制御してバックグラウンドと同じような通知を表示しようとしています。 \nしかしこれは **Deprecated** なメソッドだそうでiOS9のみで実装するようにしたいです。\n\n```\n\n @available(iOS 10.0より古い, *)\n \n```\n\nといった感じの指定がしたいのですがそういった事はできるのでしょうか?\n\n* * *\n\n修正 \n現状はメソッドの中でバージョンを判定して処理を分けるようにしました。\n\n```\n\n func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)\n \n```\n\nを実装している状態でiOS9ではフォアグラウンドで通知が来た時とバックグラウンドで通知表示を押して戻った時、 \niOS10ではフォアグラウンド、バックグラウンド時の通知表示をタップした時、\n\n```\n\n func application(_ application: UIApplication, didReceive notification: UILocalNotification)\n \n```\n\nが呼ばれ、これはiOS9でしか使う予定がないのでこの下のメソッドをiOS10より前でのみこの内容で実装するということは出来ないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T06:36:04.713", "favorite_count": 0, "id": "33734", "last_activity_date": "2017-04-03T14:17:17.843", "last_edit_date": "2017-04-03T14:17:17.843", "last_editor_user_id": "14222", "owner_user_id": "14222", "post_type": "question", "score": 0, "tags": [ "swift", "ios", "xcode" ], "title": "Swiftでメソッドの実装をiOSバージョンごとに分ける・無くす方法", "view_count": 2204 }
[ { "body": "`UIDevice`クラスを使います。\n\n```\n\n UIDevice.current.systemVersion\n \n```\n\n返り値は、数値でなく、文字列(`String`)なのに注意してください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T07:00:06.493", "id": "33737", "last_activity_date": "2017-04-03T07:00:06.493", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "18540", "parent_id": "33734", "post_type": "answer", "score": 1 }, { "body": "こんな指定ができます。\n\n```\n\n @available(iOS, deprecated: 10.0)\n func application(_ application: UIApplication, didReceive notification: UILocalNotification) {\n //...\n }\n \n```\n\n他のプラットフォーム(tvOS, macOS等)もサポートする必要があれば、同様の複数のアトリビュートを重ねることもできます。\n\n`@available`アトリビュートの使い方については、こちらに記載されているのですが、実例が少ないのでちょっとわかりにくいかもしれません。\n\n[Declaration\nAttributes](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Attributes.html#//apple_ref/doc/uid/TP40014097-CH35-ID348)\n([The Swift Programming Language (Swift\n3.1)](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/index.html#//apple_ref/doc/uid/TP40014097))", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T12:04:38.277", "id": "33748", "last_activity_date": "2017-04-03T12:04:38.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "33734", "post_type": "answer", "score": 1 } ]
33734
33748
33737
{ "accepted_answer_id": "33751", "answer_count": 1, "body": "MPVolumeViewで作ったボリュームスライダーを右側へゆっくりスライドしていくと、スライドバーが黄色く点滅し、ボリューム位置が少し左へ移動します。 \n再度右側へスライドすると点滅は解除され右端まで移動することができます。\n\nなぜ黄色く点滅するのかわかりません。 \n原因と解決方法を教えていただけないでしょうか?\n\nよろしくお願いします。\n\nimport UIKit \nimport MediaPlayer\n\nclass ViewController: UIViewController {\n\n```\n\n var mpVolumeSlider = UISlider()\n var volumeParentView = UIView()\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n volumeParentView.backgroundColor = UIColor.clear\n let volumeView = MPVolumeView(frame: CGRect(x: 10, y: 300, width: 300, height: 50))\n \n for view in volumeView.subviews {\n let uiview: UIView = view as UIView\n if (uiview.description as NSString).range(of: \"MPVolumeSlider\").location != NSNotFound {\n self.mpVolumeSlider = uiview as! UISlider\n self.view.addSubview(volumeView)\n }\n }\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n \n```\n\n} \n[![実機画像](https://i.stack.imgur.com/P3YT1.png)](https://i.stack.imgur.com/P3YT1.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T06:59:00.520", "favorite_count": 0, "id": "33736", "last_activity_date": "2017-04-03T12:35:52.523", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "19781", "post_type": "question", "score": 0, "tags": [ "swift", "swift3" ], "title": "swift3.0 MPVolumeViewで作ったボリュームスライダー右側の黄色点滅を解除したい", "view_count": 454 }
[ { "body": "本家stackoverflowに類似の質問があるのが見つかりました。\n\n[Customising MPVolumeView's high volume warning on\niOS](https://stackoverflow.com/q/29193657/6541007)\n\n要はEUの音量制限(大きすぎるボリュームにすると健康に悪い影響を与える可能性があることを明示しなければいけない)に対応するもののようです。\n\n上の記事中にもありますが、この表示をカスタマイズするためのプロパティもあるようですが、完全に無しにすることは許されていないようです。\n\n>\n```\n\n> // Sets the image for the EU volume limit. When appropriate, this image\n> will be displayed on top of the\n> // maximumVolumeSliderImage. It must be visually distinct from the\n> maximumVolumeSliderImage, and use\n> // a color similar to the default, to convey a sense of warning to the\n> user. The same image is used for\n> // all control states. For debugging purposes, switch on the \"EU Volume\n> Limit\" setting in the Developer\n> // menu of the Settings application to always enable the volume limit.\n> @available(iOS 7.0, *)\n> open var volumeWarningSliderImage: UIImage?\n> \n```\n\n>\n>\n> (私訳)EUの音量制限用の画像を設定します。それが適切な状況では、この画像が`maximumVolumeSliderImage`の上に重ねて表示されます。この画像は、ユーザに警告と感じさせるため、`maximumVolumeSliderImage`とは異なるもので、デフォルトと同じ色を使用しなければいけません。全てのコントロールのステートで同じ画像が使用されます。デバッグ用途に、常に音量制限を有効にしたい場合には、設定アプリの開発者メニューから「EU音量制限」設定をオンにしてください。\n\nと言うわけで、 **ユーザが音量制限を有効化している場合には** 必ず表示されるべきものなので、そう言う用途のもだと思って受け入れるしかないでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T12:35:52.523", "id": "33751", "last_activity_date": "2017-04-03T12:35:52.523", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "13972", "parent_id": "33736", "post_type": "answer", "score": 1 } ]
33736
33751
33751
{ "accepted_answer_id": null, "answer_count": 1, "body": "下記のようなユーザーコントロールを作成しました。\n\n```\n\n <UserControl x:Class=\"MyCombobox\"\n ...\n \n <ComboBox x:Name=\"Value\" ItemsSource=\"{Binding MyItemsSource}\"/>\n \n```\n\nさらにMyItemsSourceの依存プロパティを下記のように設定しました。\n\n```\n\n public partial class MyCombobox : UserControl\n {\n public MyCombobox ()\n {\n InitializeComponent();\n }\n \n public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(\"MyItemsSource\",\n typeof(IEnumerable<string>),\n typeof(MyCombobox),\n new FrameworkPropertyMetadata(\"MyItemsSource\");\n \n public IEnumerable<string> MyItemsSource\n {\n get { return (IEnumerable<string>)GetValue(ItemsSourceProperty); }\n set { SetValue(ItemsSourceProperty, value); }\n }\n }\n \n```\n\nメインウインドウで下記のように使用しました。\n\n```\n\n <Window x:Class=\"MainWindow\"\n ・\n ・\n ・\n <local:MyCombobox x:Name=\"FontType\" MyItemsSource=\"{Binding testEnums}\"/>\n \n```\n\ntestEnumsは下記の型の変数で、ViewModelに記載されています。\n\n```\n\n ObservableCollection<string>\n \n```\n\nコンパイルは通るのですがメインウインドウのxamlに「既定値の型がプロパティ\"MyItemsSource\"の型と一致しません。」と警告が表示され実行すると例外で落ちてしまいます。\n\nコンボボックスのItemsSourceにEnumのリストをバインドしたいのですがどこを直せばよいのかわかりません。 \nどなたか何かご存知でしたら、教えてください。。。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T07:22:23.063", "favorite_count": 0, "id": "33738", "last_activity_date": "2017-10-18T01:22:08.837", "last_edit_date": "2017-04-03T09:07:48.680", "last_editor_user_id": "21333", "owner_user_id": "21333", "post_type": "question", "score": 0, "tags": [ "c#", "wpf" ], "title": "WPF コンボボックスのItemsSourceにEnumのリストをバインドできない", "view_count": 2505 }
[ { "body": "エラーメッセージの\n\n> 既定値の型がプロパティ\"MyItemsSource\"の型と一致しません。\n\nにある「既定値」はソースコードの`new\nFrameworkPropertyMetadata(\"MyItemsSource\")`の引数`\"MyItemsSource\"`を指しますが、この値は`IEnumerable<string>`に変換できないためエラーとなっています。互換性のある`null`や`new\nstring[0]`などに変更してください。\n\nなおC#/.NETの用語では`Enum`(列挙型/列挙値)は`enum`キーワードを使用して宣言された型のみを指し、質問のように`IEnumerable<string>`をEnumと称するのは誤りです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T08:34:22.850", "id": "33741", "last_activity_date": "2017-04-03T08:34:22.850", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "33738", "post_type": "answer", "score": 1 } ]
33738
null
33741
{ "accepted_answer_id": "33902", "answer_count": 1, "body": "```\n\n * (rev1, HEAD, BranchA)\n |\n * (rev2)\n |\n * / (rev3, BranchB)\n |/\n * (rev4)\n |\n * (rev5)\n \n```\n\nの状況で、rev2 の SHA-1 を指定せずに (rev1, rev2) のみを対象とする git rebase -i\nをしたいのですが、そのようなオプションは存在するのでしょうか", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T09:26:35.193", "favorite_count": 0, "id": "33742", "last_activity_date": "2017-04-10T08:23:46.970", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9796", "post_type": "question", "score": 0, "tags": [ "git" ], "title": "current branch のみに所属する revesions のみを git rebase -i したい", "view_count": 54 }
[ { "body": "How to get the changes on a branch in git \n<https://stackoverflow.com/questions/53569/how-to-get-the-changes-on-a-branch-\nin-git>\n\n```\n\n git log BranchA --not BranchB\n git log BranchB..BranchA\n \n```\n\nといった表記で実現できるようです", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-10T08:23:46.970", "id": "33902", "last_activity_date": "2017-04-10T08:23:46.970", "last_edit_date": "2017-05-23T12:38:56.467", "last_editor_user_id": "-1", "owner_user_id": "9796", "parent_id": "33742", "post_type": "answer", "score": 0 } ]
33742
33902
33902
{ "accepted_answer_id": "33762", "answer_count": 2, "body": "こんにちは\n\nruby on rails のapplication.rbに以下を記入して、lib/test/hoge.rbを読み込みたいと考えています。\n\n```\n\n config.enable_dependency_loading = true\n config.autoload_paths += %W(#{config.root}/lib)\n \n```\n\nしかし、上記を記入したところhoge.rbの内容を読み込んでくれません。 \n下記がファイルの内容とコマンドの実行結果になりますが、どうすれば読み込むようになるでしょうか?\n\n* * *\n```\n\n # hoge.rb\n class Hoge\n def hello\n puts \"Hoge#hello\"\n end\n end\n \n```\n\n* * *\n```\n\n # application.rb\n module TestApp\n class Application < Rails::Application\n # Settings in config/environments/* take precedence over those specified here.\n # Application configuration should go into files in config/initializers\n # -- all .rb files in that directory are automatically loaded.\n config.enable_dependency_loading = true\n config.autoload_paths += %W(#{config.root}/lib)\n end\n end\n \n```\n\n* * *\n```\n\n # console\n PS C:\\work\\testApp> bundle exec rails c\n Loading development environment (Rails 5.0.2)\n \n [1] pry(main)> Hoge\n NameError: uninitialized constant Hoge\n from (pry):1:in `<main>'\n \n```\n\n* * *\n```\n\n PS C:\\work\\testApp> bundle exec rails runner 'puts ActiveSupport::Dependencies.autoload_paths'\n C:/work/testApp/lib\n C:/work/testApp/app/assets\n (略)\n C:/work/testApp/test/mailers/previews\n \n```\n\n* * *\n\nrails rの実行結果より対象のtestディレクトリ以下を読み込んでないと推測していますが、具体的な解決策がわからず困っております。 \n※他のディレクトリを読み込む可能性がありますので、できれば「config.autoload_paths +=\n%W(#{config.root}/lib/test)」などを追加せずに1行でまとめたい。\n\nどなたか解決策がわかる方がいらしましたら教えていただけると助かります。 \nなお各バージョンは \nRails 5.0.2 \nruby 2.4.0p0 (2016-12-24 revision 57164) [x64-mingw32] となります。\n\n~(追記)~ \nなお、hoge.rbの配置ディレクトリは/lib/test/である必要があり、 \n呼び出し方は、できれば new Hoge などとやりたいですが、Test::Hogeでも問題はありません。 \n以上、お手数ですがよろしくお願いいたします。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T09:37:53.510", "favorite_count": 0, "id": "33743", "last_activity_date": "2017-04-04T07:42:06.923", "last_edit_date": "2017-04-04T05:43:11.320", "last_editor_user_id": "20774", "owner_user_id": "20774", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails" ], "title": "lib配下のディレクトリに格納しているファイルを読み込みたい", "view_count": 3023 }
[ { "body": "> できれば「config.autoload_paths += %W(#{config.root}/lib/test)」などを追加せずに1行でまとめたい。\n\nこれだとどうですか?\n\n```\n\n config.autoload_paths += Dir[\"#{config.root}/lib/**/\"]\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T05:09:30.723", "id": "33757", "last_activity_date": "2017-04-04T05:09:30.723", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "33743", "post_type": "answer", "score": -2 }, { "body": "Railsのautoloadの仕組みを簡単に説明すると、`Foo::Bar`が現れたら、`autoload_paths`に書かれたディレクトリから`foo/bar.rb`を探してrequireします。\n\n`lib/test/hoge.rb`で`Hoge`を定義したいなら、`autoload_paths`には`lib/test`を追加する必要があります。同じファイルを`autoload_paths`に`lib`にした状態で読みたいのであれば、クラスは`Test::Hoge`である必要があります。\n\nパスやクラス名を間違えると失敗しますので、うまく行かない時は\n\n * autoload_pathsの内容\n * ファイルのパス\n * クラス定義\n * 参照しているクラス\n\nをひとつずつ確認してください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T07:42:06.923", "id": "33762", "last_activity_date": "2017-04-04T07:42:06.923", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "33743", "post_type": "answer", "score": 4 } ]
33743
33762
33762
{ "accepted_answer_id": null, "answer_count": 1, "body": "サイトのナビゲーションなどによくある、選択されているページの文字色を変えたいのですが、 \nどのようにすれば良いのでしょうか? \n例えば以下の場合、会社案内をクリックしたら、会社案内ページが表示されているときは`<li><a\nhref=\"#\">会社案内</a></li>`のテキストをredにする。といった動きにしたいです。\n\n```\n\n <ul class=\"nav\">\n <li><a href=\"#\">会社案内</a></li>\n <li><a href=\"#\">製品一覧</a></li>\n <li><a href=\"#\">お問い合わせ</a></li>\n </ul>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T10:19:58.997", "favorite_count": 0, "id": "33744", "last_activity_date": "2019-06-11T01:10:14.147", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12323", "post_type": "question", "score": 1, "tags": [ "javascript", "html", "jquery", "css" ], "title": "サイトのナビゲーションの、選択されているテキストに色を付けたいです。", "view_count": 192 }
[ { "body": "ページの読み込まれ方もあると思いますがajaxなどで必要な時に部分的に読み込んでいる場合 \n以下のようにクリックをもとに切り替える方法もあれば\n\n```\n\n // .active 表示中のページのボタンを表すクラス\n $('.nav li').on('click', function() {\n $('.active').removeClass('active');\n $(this).addClass('active');\n });\n \n```\n\n取ってきたページに依存して(ファイル名やファイル内の情報など)取ってきた後でどの要素にクラスをつけるのかを選ぶ方法があります。\n\n前者は手軽ですが後者だといろいろなページの切り替わり方、同じページでも色々なボタンがあったり条件を満たしたら切り替わったり……に対応し易いです。\n\nまた単純にhtmlファイルが少なくてまとめて読み込むのでしたらそれぞれのファイルごとにactiveなどのクラスを付けてそれで色を付ければいいとおもいます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T14:56:22.657", "id": "33753", "last_activity_date": "2017-04-03T14:56:22.657", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14222", "parent_id": "33744", "post_type": "answer", "score": 2 } ]
33744
null
33753
{ "accepted_answer_id": null, "answer_count": 2, "body": "CentOSで \n(1:Remoteサーバ) mysql \n(2:localサーバ) phpmyadmin \nのサーバ構成を組んでいます(TCP接続)。\n\n(2)にはphpもphp-mysqlもapacheも入れています。 \nphpmyadminのログイン画面は出てくるのですが、ユーザ名・パスワードを入力して[実行]ボタンを押したところ、「MySQL\nサーバにログインできません」とのエラー表示が表示されます。\n\n(1)のmysqld.logを確認すると、\n\n```\n\n 2017-04-03T10:52:40.593052Z 11 [Note] Access denied for user '(アカウントにつき削除)'@'gateway' (using password: YES)\n \n```\n\nというログが出ます。この'gateway'というのは何でどこで設定するのでしょうか?\n\n(2)の/etc/phpMyAdmin/config.inc.phpの設定は修正と見直しは行なっているつもりなのですが。\n\nどなたかご存知の方はご教示お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T10:59:04.867", "favorite_count": 0, "id": "33745", "last_activity_date": "2017-08-31T23:34:50.900", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8593", "post_type": "question", "score": 0, "tags": [ "mysql", "phpmyadmin" ], "title": "リモートのmysqlにphpmyadminで接続する際のアクセス拒否エラー", "view_count": 1140 }
[ { "body": "サーバー側のログに出力されるユーザーの「@」の後ろはサーバーから見たアクセス元のホスト名です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T14:55:35.520", "id": "33752", "last_activity_date": "2017-04-03T14:55:35.520", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3249", "parent_id": "33745", "post_type": "answer", "score": 0 }, { "body": "MySQLのユーザを作成する際に接続元ホストを指定してください。 \n指定したホストからの接続のみ許可されます。 \nホスト名にはワイルドカード (`%` `_`) が使えますので次のようにすることも可能です。\n\n```\n\n CREATE USER 'myname'@'%.mydomain.com' IDENTIFIED BY 'mypass';\n CREATE USER 'myname'@'192.168.0.%' IDENTIFIED BY 'mypass';\n CREATE USER 'myname'@'%' IDENTIFIED BY 'mypass';\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T05:23:58.113", "id": "33758", "last_activity_date": "2017-04-04T05:23:58.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "33745", "post_type": "answer", "score": 1 } ]
33745
null
33758
{ "accepted_answer_id": "33754", "answer_count": 1, "body": "Swif t3でのCoreDataに保存したデータの並び順を保存する方法について教えてください。 \n要素にtitleとurl(どちらもString型)を持つbookmarkエンティティがあります。 \nこれらの各要素をtableviewに表示しています。編集ボタンを押してtableviewを編集したあと、 \nその並びをCoreDataに反映させたいのですが、良い方法が浮かびません。現在、下記のコードのように擬似的に並び替えを行なっています。\n\n```\n\n // 並び替え後の処理\n func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {\n // bookmarkListにはCoreDataから読み込んだデータが格納されている\n let moveData = bookmarkList[sourceIndexPath.row] // 移動先のデータを格納\n bookmarkList.remove(at: sourceIndexPath.row) //元の位置のデータを配列から削除する。\n bookmarkList.insert(moveData, at:destinationIndexPath.row) //移動先の位置にデータを配列に挿入する。\n deleteBookmark() // 一旦CoreDataの中身を全て削除\n for bookmark in bookmarkList { // 再度並び替え後のデータを保存\n addBookmark(aTitle: bookmark.Title!, aUrl: bookmark.Url!)\n }\n }\n // CoreDataからの削除関数\n func deleteBookmark() {\n let query: NSFetchRequest<MyBookmark> = MyBookmark.fetchRequest()\n \n do {\n let fetchResults = try context.fetch(query)\n for result: AnyObject in fetchResults {\n let record = result as! NSManagedObject\n context.delete(record)\n }\n try context.save()\n } catch {\n }\n }\n // CoreData新規登録関数\n func addBookmark(aTitle: String, aUrl: String) {\n let mybookmark = MyBookmark(context: context)\n \n // 既に登録されているものは登録されないようにURLで検索する。\n let fetchRequest:NSFetchRequest<MyBookmark> = MyBookmark.fetchRequest()\n let predicate = NSPredicate(format:\"%K = %@\",\"Url\",\"\\(aUrl)\")\n fetchRequest.predicate = predicate\n let fetchData = try! context.fetch(fetchRequest)\n \n if fetchData.isEmpty {\n // 新しく登録する\n if aTitle != \"\" && aUrl != \"\" {\n mybookmark.Title = aTitle\n mybookmark.Url = aUrl\n }\n do{\n try context.save()\n }catch{\n }\n }else{\n context.reset()\n }\n }\n \n```\n\n上のコードのように、一旦CoreDataの中身をからにして、並び替えたデータを再度保存しています。一応これでも動くのですがスマートではありません。データベースのように好きなところにデータをインサートする方法を教えて欲しいです。(CoreDataの中身を見るとz_pkという主キーのようなものがあるのを見つけました。これを上手く使えばできるのでしょうか?)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T12:35:09.823", "favorite_count": 0, "id": "33750", "last_activity_date": "2017-04-03T17:25:40.183", "last_edit_date": "2017-04-03T16:59:36.440", "last_editor_user_id": "5519", "owner_user_id": "21189", "post_type": "question", "score": 0, "tags": [ "swift", "ios" ], "title": "CoreDataで並び順を保存したい", "view_count": 1191 }
[ { "body": "一般的なデータベースではオブジェクトの並び順は保存されません。ですので、並び順を示すカラムを追加して、それを用いて並べ替えを行う必要があります。 \nCoreDataの場合、結果の並べ替えには`NSSortDiscriptor`を使います。\n\n汎用的な方法としては並び順を示すカラムをモデルに追加し、のタイミング(`tableView(_ tableView: UITableView,\nmoveRowAt sourceIndexPath: IndexPath, to destinationIndexPath:\nIndexPath)`)でそのカラムの値を更新します。\n\nもしくは、例外的にCoreDataはOrderedSetという並び順を保持するデータ型がありますので、関連を作って一段階ラップして利用するのも有効です。そうすると、おそらくより直感的にやりたいことが実現できると思います。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-03T17:25:40.183", "id": "33754", "last_activity_date": "2017-04-03T17:25:40.183", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "33750", "post_type": "answer", "score": 0 } ]
33750
33754
33754
{ "accepted_answer_id": "33761", "answer_count": 1, "body": "キーボードで入力できる全角記号を除外したいのですが、知識不足で理解できず、どなたかご教授いただければと存じます。\n\n■やりたい事■ \nフォームの名前フィールド(全角漢字)で、登録許可項目以外エラーメッセージを表示 \nエラーは送信ボタンを選択する前に表示したい。その為JSでバリデーションを作成している \n※ブラックリストを作成し、Ajaxで確認する方法もあるかと思いますが、一旦は正規表現での \nやり方をご教授いただければと存じます。\n\n▲フィールドの登録許可▲ \n漢字・全角カナ\n\n●現在設定したバリデーション● \n半角記号・連続文字\n\n■現在作成した正規表現■\n\n```\n\n /^([\\w\\u3040-\\u309f])\\1*$|\\d+|[a-zA-Z]|[!-/]|[:-?]|[[-`]|[{-~]/\n \n```\n\n▲止まっている所▲ \nキーボードで入力できる全角記号除外の正規表現\n\n元々の要望は漢字 カナ ひらがな 以外は登録を除外するという要望なので、 \nカナ ひらがな 以外は登録を除外という正規表現の書き方がありましたら、その内容もご教授いただければと存じます。 恐れ入りますが、よろしくお願いします", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T05:08:03.767", "favorite_count": 0, "id": "33756", "last_activity_date": "2017-04-04T07:18:27.260", "last_edit_date": "2017-04-04T06:34:17.103", "last_editor_user_id": "8000", "owner_user_id": "20360", "post_type": "question", "score": 0, "tags": [ "javascript", "正規表現" ], "title": "入力値にひらがな・カタカナ・漢字以外が含まれていないかを調べたい", "view_count": 771 }
[ { "body": "ご教授頂いたユニコード文字プロパティが利用できなかったので、べた書きで対応しました。 \nもっとよい書き方があるかもしれませんが、、、、\n\n```\n\n /^([\\w\\u3040-\\u309f])\\1*$|\\d+|[a-zA-Z]|[!-/]|[:-?]|[[-`]|[{-~]|[\"!”#$%&’()=~|‘{+*}<>?_-^¥@「;:」、。・\"]/\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T07:18:27.260", "id": "33761", "last_activity_date": "2017-04-04T07:18:27.260", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20360", "parent_id": "33756", "post_type": "answer", "score": 0 } ]
33756
33761
33761
{ "accepted_answer_id": "33768", "answer_count": 1, "body": "Redmineでガントチャートの左側に以下の項目を追加する方法はありますでしょうか? \n・担当者 \n・開始日 \n・期限\n\n右側のグラフに詳細が表示されることは承知していますが、 \n一覧として並べて確認できればと思っております。\n\n以下のプラグインで担当者は表示出来そうでしたが、Redmineの \nバージョン(3.3.2)が合わないようで断念しました。 \n<https://github.com/stgeneral/redmine-progressive-gantt-mods>\n\n何かよい方法をご存知の方がいましたら、ご教示お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T08:18:04.153", "favorite_count": 0, "id": "33763", "last_activity_date": "2017-04-04T12:47:14.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21358", "post_type": "question", "score": 0, "tags": [ "redmine" ], "title": "Redmineのガントチャートに担当者、開始日、期限を表示したい", "view_count": 6616 }
[ { "body": "[Redmine Gantt Plugin - Easy Redmine](https://www.easyredmine.com/redmine-\ngantt-plugin) : 担当者と進捗率なら出せます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T12:47:14.770", "id": "33768", "last_activity_date": "2017-04-04T12:47:14.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "33763", "post_type": "answer", "score": 0 } ]
33763
33768
33768
{ "accepted_answer_id": "33784", "answer_count": 1, "body": "サーバーにあるJsonファイルを読み込み、オフライン環境下でも起動できるように、以下のコードでLibrary/cachesに保存します。\n\n```\n\n let dataName = \"test.json\"\n \n if let jsonUrl = url {\n let jsonData = NSData(contentsOf: jsonUrl)\n let cashesPath = NSHomeDirectory() + \"/Library/caches\"\n if let localData = jsonData {\n localData.write(toFile: \"\\(cashesPath)/\\(dataName)\", atomically: true)\n print(\"\\(cashesPath)/\\(dataName)\")\n }\n }\n \n```\n\nそしてこの保存したtest.jsonのファイルを読み込むために\n\n```\n\n let path = localPath + \"/\" + dataName\n let jsonData : NSData = NSData(contentsOfFile: path)\n let data = try! JSONSerialization.jsonObject(with: jsonData as! Data, options: []) as! Array<[String: AnyObject]>\n \n```\n\nとしてるのですが、\n\n```\n\n fatal error: unexpectedly found nil while unwrapping an Optional value\n \n```\n\nというエラーが出ます。 \nこれはdataにtest.jsonが読み込めてないのか、もしくはそもそもPathの指定が間違ってるのかと思うのですが、どう訂正したらうまくいくのでしょうか? \nswiftを学び始めてまだ1週間足らずなので見当違いなところももしかしたらあるとは思いますが、教えて頂けると嬉しいです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T08:38:15.407", "favorite_count": 0, "id": "33764", "last_activity_date": "2017-04-05T08:49:03.683", "last_edit_date": "2017-04-04T08:44:23.927", "last_editor_user_id": "5793", "owner_user_id": "21359", "post_type": "question", "score": 0, "tags": [ "swift", "json" ], "title": "Jsonで読み込んだファイルをローカルに保存して、再び読み込みたい", "view_count": 2061 }
[ { "body": "> これはdataにtest.jsonが読み込めてないのか、もしくはそもそもPathの指定が間違ってるのかと思うのですが、\n> **どう訂正したらうまくいくのでしょうか?**\n\n訂正箇所を指摘してもらうより、訂正箇所を自力で探し出す方法を尋ねたほうが、汎用性、応用性で優れています。ここでは、その方法を考えてみましょう。 \nプログラムでは、成功しないかもしれない処理、期待しない結果になる可能性のある処理を、条件文を使って、分岐する方法がよく使われます。今回のプログラムでも、多用されています。このうまくいっていない方の分岐に、`print()`関数で、その旨を出力するようにすると、どこで期待しない結果になったのか、知ることができます。 \nまた、例外処理(`do - try -\ncatch`ブロック)で、エラーメッセージを`print()`関数で出力するようにすると、どんな例外が、どこで起きたのか、知ることができます。`NSError`オブジェクトは、`localizedDescription`プロパティで、エラーを人間が読める文字列にしてくれます。\n\n以上を踏まえて、さらに二つの方針を加えて、コードを書いてみました。 \n二つの方針のひとつは、レガシーな項目は、できるだけ使わず、新しいものに置き換えることです。`NSData`クラスは、Objective-\nCのコードとブリッジするために使われるもので、`Data`構造体に置き換えます。 \nもうひとつは、「`!`」を使わないということです。この記号は、「変数や式の評価の値が`nil`だったら、実行をクラッシュして教えてね」という意味を持っていて、開発中のデバッグでは、有効ですが、完成したプログラムには、できるだけなくしておきたいものです。プログラムの実行がクラッシュして、`fatal\nerror: unexpectedly found nil while unwrapping an Optional\nvalue`というエラーメッセージがコンソールに出たなら、「`!`」のある箇所を探すのが、有効なデバッグの方法です。プログラムが完成に近づいたら、「`!`」は、Optional\nBinding文(`if let 〜`)に置き換えるようにしましょう。 \nXcodeで、macOSの新規アプリケーションを作成し、`ViewController.swift`ファイルに、以下のコードを記述します。Storyboardにおいて、ボタンをひとつ貼り付け、アクションメソッド`getJSON(_:)`と接続します。\n\n```\n\n import Cocoa\n \n class ViewController: NSViewController {\n \n let fileName = \"test.json\"\n let urlString = \"http://....../test.json\" // JSONファイルのURL\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n if let url = URL(string: urlString) {\n if let desktopURL = FileManager.default.urls(for: .desktopDirectory, in: .userDomainMask).first {\n do {\n let data = try Data(contentsOf: url)\n let fileURL = desktopURL.appendingPathComponent(fileName)\n try data.write(to: fileURL)\n } catch let error {\n print(\"Read or Write Error: \\(error.localizedDescription)\")\n }\n } else {\n print(\"ローカルディスク上のパス取得失敗\")\n }\n } else {\n print(\"不正なURL\")\n }\n \n }\n \n @IBAction func getJSON(_ sender: Any) {\n if let url = FileManager.default.urls(for: .desktopDirectory, in: .userDomainMask).first {\n let fileURL = url.appendingPathComponent(fileName)\n do {\n if FileManager.default.fileExists(atPath: fileURL.path) {\n let data = try Data(contentsOf: fileURL)\n if let dataArray = try JSONSerialization.jsonObject(with: data) as? [[String : Any]] {\n for element in dataArray {\n print(\"\\(element)\")\n }\n } else {\n print(\"JSONファイル作成失敗\")\n }\n } else {\n print(\"ファイル保存失敗\")\n }\n } catch let error {\n print(\"Error \\(error.localizedDescription)\")\n }\n } else {\n print(\"ローカルディスク上のパス取得失敗\")\n }\n }\n \n }\n \n```\n\nJSON書類ファイルを、「Library/cachesに保存」する意味がわからない(危険な香りがする)ので、上のコードでは、デスクトップに保存するようにしました。また、各種ディレクトリパスの取得は、`FileManager`クラスを使うようにしてください。パスを直書きしてもいいのですが、そのほうが移植性が高まります。 \nちなみに、~/Library/Cachesディレクトリの取得は、こう書きます。\n\n```\n\n FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first\n \n```\n\nこのメソッドは配列を返すので、最初の要素を`first`で取り出します。また、ローカルディスク上のファイルにアクセスするときは、ファイルの有無を事前に確認するようにしましょう。これも`FileManager`クラスを使います。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T06:03:03.390", "id": "33784", "last_activity_date": "2017-04-05T08:49:03.683", "last_edit_date": "2017-04-05T08:49:03.683", "last_editor_user_id": "18540", "owner_user_id": "18540", "parent_id": "33764", "post_type": "answer", "score": 0 } ]
33764
33784
33784
{ "accepted_answer_id": "33766", "answer_count": 1, "body": "「仮想テーブルレイアウト」で上下センター揃えができないのですが、 \n以下のCSSでどこががおかしいのでしょうか?\n\n**希望のイメージ** (上下左右#innerの中央揃え) \n[![画像の説明をここに入力](https://i.stack.imgur.com/boyC2.png)](https://i.stack.imgur.com/boyC2.png)\n\n子要素の`li`に\n\n```\n\n display: table-cell;\n \n```\n\nを設定し、 \n親要素の`ul`に\n\n```\n\n display: table;\n \n```\n\nを設定しています。\n\n**[index.html]**\n\n```\n\n <!DOCTYPE html>\n <head>\n <link rel=\"stylesheet\" href=\"style.css\">\n <meta name=\"\" content=\"\" charset=\"utf-8\">\n </head>\n \n \n <body>\n \n <div id=\"inner\">\n \n <ul>\n <li><a href=\"\">あああああ</a></li>\n <li><a href=\"\">いいいいい</a></li>\n <li><a href=\"\">ううううう</a></li>\n </ul>\n \n </div>\n \n </body>\n \n```\n\n**[style.css]**\n\n```\n\n body {\n background: #ccc;\n width: 940px;\n margin: 10px auto;\n }\n \n #inner {\n background: #aaa;\n height: 100px;\n }\n \n ul {\n display: table;\n text-align: center;\n }\n \n li {\n display: table-cell;\n vertical-align: middle;\n background: #896;\n width: 150px;\n border: #f94 1px solid;\n }\n \n```\n\nブラウザで表示すると、下の画像のようになります。 \n[![結果](https://i.stack.imgur.com/SGQud.png)](https://i.stack.imgur.com/SGQud.png)\n\n```\n\n ul{\n height: inherit;\n display: table;\n text-align: center;\n }\n \n```\n\nとすると以下のようになりました。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/cEyVA.png)](https://i.stack.imgur.com/cEyVA.png)", "comment_count": 9, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T08:39:10.940", "favorite_count": 0, "id": "33765", "last_activity_date": "2017-04-04T10:13:05.333", "last_edit_date": "2017-04-04T10:13:05.333", "last_editor_user_id": "12297", "owner_user_id": "12297", "post_type": "question", "score": 0, "tags": [ "css", "html5" ], "title": "仮想テーブルレイアウトで上下センター揃えができない。", "view_count": 96 }
[ { "body": "テーブルセルに対する `vertical-align` は、セルの `margin` ではなく `padding`\nを制御するものであり、`vertical-align: middle` は **セルの中で**\n上下中央にするという意味です。セル自体の高さは常に行の高さに等しく、テーブルが一行で構成されていればテーブルの高さに等しくなります。\n\nですから、メニュー項目の高さを変えることなく上下中央にしたいのであれば、メニュー項目をセルにしてはいけません。例えばセルの中に背景やボーダーを設定した要素を置きます。\n\nそうでなくともメニュー項目は文字の部分以外(例えば左右の余白)をクリックしても反応すべきで、そのためにリンクであるAタグでボタン全体を形作ることが多いです。\n\n```\n\n body {\r\n background: #ccc;\r\n width: 940px;\r\n margin: 10px auto;\r\n }\r\n \r\n #inner {\r\n background: #aaa;\r\n height: 100px;\r\n }\r\n \r\n ul {\r\n display: table;\r\n text-align: center;\r\n height: inherit; /* ないし 100% */\r\n }\r\n \r\n li {\r\n display: table-cell;\r\n vertical-align: middle;\r\n }\r\n \r\n a {\r\n display: block;\r\n background: #896;\r\n width: 150px;\r\n border: #f94 1px solid;\r\n }\n```\n\n```\n\n <div id=\"inner\">\r\n \r\n <ul>\r\n <li><a href=\"\">あああああ</a></li>\r\n <li><a href=\"\">いいいいい</a></li>\r\n <li><a href=\"\">ううううう</a></li>\r\n </ul>\r\n \r\n </div>\n```\n\nもしくは、テーブル全体を別の方法で上下中央にすることになるでしょう。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T10:07:32.620", "id": "33766", "last_activity_date": "2017-04-04T10:07:32.620", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "33765", "post_type": "answer", "score": 0 } ]
33765
33766
33766
{ "accepted_answer_id": null, "answer_count": 2, "body": "powershellを使ってExcelから指定した列をコピーしたいです。\n\n例えばですが、 \nExcel1のA列、D列、F列だけを選んで、Excel2のA列、B列、C列に貼り付けるにはどうすればよいでしょうか?\n\nよろしくお願い致します。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T11:40:47.053", "favorite_count": 0, "id": "33767", "last_activity_date": "2018-04-13T08:30:43.287", "last_edit_date": "2017-04-04T14:31:27.400", "last_editor_user_id": "3054", "owner_user_id": "21361", "post_type": "question", "score": 1, "tags": [ "powershell" ], "title": "Powershellを使ってExcelの列をコピーしたいです。", "view_count": 1514 }
[ { "body": "PowerShellからはCOMや.NETのオブジェクトを参照することができますので、実行するマシンにExcelが導入されている場合は\n\n```\n\n $app = New-Object -ComObject Excel.Application\n \n // 実際のExcel処理\n $app.DisplayAlerts = $false\n ...\n \n```\n\nのようにExcelのCOMインターフェイスを操作するのが良いでしょう。\n\n上記が選択できない場合はNPOIのアセンブリ―を同梱したうえで\n\n```\n\n // 参照ライブラリをすべて読み込む\n [System.Reflection.Assembly]::LoadFrom(\"NPOI.OpenXml4Net.dll\");\n [System.Reflection.Assembly]::LoadFrom(\"NPOI.OpenXmlFormats.dll\");\n [System.Reflection.Assembly]::LoadFrom(\"ICSharpCode.SharpZipLib.dll\");\n [System.Reflection.Assembly]::LoadFrom(\"NPOI.dll\");\n [System.Reflection.Assembly]::LoadFrom(\"NPOI.OOXML.dll\");\n \n $wb = New-Object NPOI.XSSF.UserModel.XSSFWorkbook(\"excel1.xlsx\");\n ...\n \n```\n\nと使用することも可能です。\n\nそれぞれのライブラリで要件を実現する方法についてはPowerShellとはほとんど関係がありませんので、VBAやC#でのサンプルなどを調べてみてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T17:07:53.687", "id": "33772", "last_activity_date": "2017-04-04T17:07:53.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "33767", "post_type": "answer", "score": 2 }, { "body": "Excelに関する情報は頻繁に質問にあがるようなので、最新の状況を共有します。 \nCOM からのエクセル操作がどの言語においても苦しいように、PowerShellにおいても直接触るのは大変といわざるを得ません。\n\n現在、PowerShellコミュニティおいては、ImportExcelというモジュールがよく利用されています。 \n<https://github.com/dfinke/ImportExcel>\n\n詳しい利用方法はリポジトリをご確認いただきたいのですが、PowerShell\n5.0以降であればモジュールのインストールもコマンド1つで可能なので、試してみるといいと思います。\n\n```\n\n Install-Module ImportExcel -scope CurrentUser\n \n```\n\nRedditを始めとして利用方法のサンプルがあります。\n\n<https://www.reddit.com/r/PowerShell/comments/51h101/basic_questions_about_using_importexcel/>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-04-13T08:30:43.287", "id": "43206", "last_activity_date": "2018-04-13T08:30:43.287", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "28142", "parent_id": "33767", "post_type": "answer", "score": 1 } ]
33767
null
33772
{ "accepted_answer_id": "33773", "answer_count": 1, "body": "sympyの連結の使い方を教えて下さい\n\n```\n\n from sympy import *\n var('x a b')\n f=a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n p = Poly(f, x)\n colors = p.all_coeffs()\n print(colors)\n for i in range(len(colors)):\n print(colors[i] +\"*X**\" + str(len(colors)-i-1))\n #WANT 4*x**3+2*a*x**2+(b-3)*x-a\n #TypeError: unsupported operand type(s) for +: 'Integer' and 'str'\n \n```\n\n(参考) \n<https://stackoverflow.com/questions/22955888/how-to-extract-all-coefficients-\nin-sympy> \n<http://kesin.hatenablog.com/entry/2013/05/12/004541>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T13:25:41.537", "favorite_count": 0, "id": "33769", "last_activity_date": "2017-10-17T06:59:37.930", "last_edit_date": "2017-10-17T06:59:37.930", "last_editor_user_id": "754", "owner_user_id": "17199", "post_type": "question", "score": 0, "tags": [ "python", "sympy" ], "title": "sympyの連結の使い方を教えて下さい", "view_count": 409 }
[ { "body": "Poly 型のインスタンス(多項式)を評価すれば、一応、項の次数順に表示されます。\n\n```\n\n >>> from sympy import *\n >>> var('x a b')\n >>> f = a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n >>> p = Poly(f, x)\n >>> p\n Poly(4*x**3 + 2*a*x**2 + (b - 3)*x - a, x, domain='ZZ[a,b]')\n \n```\n\nなので、式部分だけを取り出したいのであれば、`str(p)` の結果を加工しても良いかもしれません。\n\n```\n\n >>> import re\n >>> re.search('^Poly\\((.+?),', str(p)).group(1)\n '4*x**3 + 2*a*x**2 + (b - 3)*x - a'\n \n```\n\n \nところで、Poly 型インスタンスの内容を表示しているのは、以下のメソッドです。\n\n**sympy/printing/str.py**\n\n```\n\n def _print_Poly(self, expr):\n terms, gens = [], [ self._print(s) for s in expr.gens ]\n \n for monom, coeff in expr.terms():\n :\n \n```\n\nここからコードをコピーして適当に変更すれば目的の関数を作成できます。\n\n※ 以下の関数は単項式(monomial)のみに対応しています。\n\n**monomial_as_ordered function**\n\n```\n\n from sympy import *\n \n def monomial_as_ordered(p):\n terms, gen = [], str(p.gens[0])\n \n for monom, coeff in p.terms():\n s_monom = []\n \n for i, exp in enumerate(monom):\n if exp > 0:\n if exp == 1:\n s_monom.append(gen)\n else:\n s_monom.append(gen + \"**%d\" % exp)\n \n s_monom = \"*\".join(s_monom)\n \n if coeff.is_Add:\n if s_monom:\n s_coeff = \"(\" + str(coeff) + \")\"\n else:\n s_coeff = str(coeff)\n else:\n if s_monom:\n if coeff is S.One:\n terms.extend(['+', s_monom])\n continue\n \n if coeff is S.NegativeOne:\n terms.extend(['-', s_monom])\n continue\n \n s_coeff = str(coeff)\n \n if not s_monom:\n s_term = s_coeff\n else:\n s_term = s_coeff + \"*\" + s_monom\n \n if s_term.startswith('-'):\n terms.extend(['-', s_term[1:]])\n else:\n terms.extend(['+', s_term])\n \n if terms[0] in ['-', '+']:\n modifier = terms.pop(0)\n if modifier == '-':\n terms[0] = '-' + terms[0]\n \n return ' '.join(terms)\n \n```\n\n**実行**\n\n```\n\n >>> print(monomial_as_ordered(p))\n 4*x**3 + 2*a*x**2 + (b - 3)*x - a\n \n```\n\n念の為に申し添えて置くと、この関数の戻り値は文字列であって Poly 型のインスタンスではありません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T17:41:56.383", "id": "33773", "last_activity_date": "2017-04-04T18:03:24.357", "last_edit_date": "2017-04-04T18:03:24.357", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "33769", "post_type": "answer", "score": 1 } ]
33769
33773
33773
{ "accepted_answer_id": "34758", "answer_count": 1, "body": "GAEで作成した自作のREST APIへのアクセスを、他のGoogleAppsAPIが行っているように \nAPIキーを使用して署名付きのAndroid端末からのみのアクセスのみ許可するように制限をかけたいのですが、 \nそれらしきIFがGAE/Goのドキュメントに見当たりません。\n\nAPIキーの作成方法自体はGCPコンソールのAPIManager>認証情報から作成したのですが、 \nGAEで組んだ自作REST APIにそれを適用するにはどのようにしたらよいのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T14:11:32.150", "favorite_count": 0, "id": "33770", "last_activity_date": "2017-05-16T13:09:23.610", "last_edit_date": "2017-04-04T14:44:24.453", "last_editor_user_id": "19716", "owner_user_id": "19716", "post_type": "question", "score": 0, "tags": [ "google-app-engine" ], "title": "GAEでの自作REST APIにAPIキーにて制限をかける方法", "view_count": 566 }
[ { "body": "gae自身にAPI Keyを付与することはできません。(現状) \nそのような場合CloudEndpointとしてAPIを作成し、認証情報を付加する必要があります。 \n<https://cloud.google.com/endpoints/>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-05-16T13:09:23.610", "id": "34758", "last_activity_date": "2017-05-16T13:09:23.610", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "23189", "parent_id": "33770", "post_type": "answer", "score": 1 } ]
33770
34758
34758
{ "accepted_answer_id": null, "answer_count": 1, "body": "CentOS7にDockerコンテナのCentOS7を作成してWordPress 4.7.2を動かしています。 \nhttpサーバはApache/2.4.6です。PHP 5.4.16です。\n\niOSの「WordPress」アプリから画像挿入を行うと以下のようなエラー画面になります。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/IsNit.jpg)](https://i.stack.imgur.com/IsNit.jpg)\n\niOSの「PressSync」アプリから画像挿入を行っても以下のエラー画面になります。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/wkLGM.png)](https://i.stack.imgur.com/wkLGM.png)\n\n画像挿入を伴わない投稿であれば問題なくできます。\n\nphpの設定でも \nmemory_limit = 1000M \npost_max_size = 100M \nupload_max_filesize = 100M \nmax_input_time = 60 \nとかなり高めに設定しています。\n\nブラウザからでもiPhoneの写真を直接メディアにアップするとHTTPエラーが発生しました。 \n縮小させてアップロードすると成功します。\n\n解決方法をご存知の方、ご教示お願いします。\n\n==(自己解決しました)== \nwordpressで使用しているDockerコンテナのフロントにnginxでproxy_passしています。 \nそのnginxの設定で \nclient_max_body_size 100M; \nを設定するとできました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-04T14:43:33.320", "favorite_count": 0, "id": "33771", "last_activity_date": "2017-05-18T17:02:10.273", "last_edit_date": "2017-05-18T17:02:10.273", "last_editor_user_id": "8593", "owner_user_id": "8593", "post_type": "question", "score": -1, "tags": [ "ios", "wordpress" ], "title": "iOSアプリからの画像挿入不可", "view_count": 467 }
[ { "body": "質問者様がnginxがインストールしている環境かはわかりませんので \n同件かわかりませんがご参考です。 \n<https://wordpress.org/support/topic/upload-fails-for-photos-taken-with-\niphone/>\n\nnginx.confにを追加したら直ったとのことです。\n\n```\n\n client_max_body_size 20M;\n \n```\n\nPHP側のmemory_limit(/etc/php.ini)も確認された方が良いと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T11:39:39.910", "id": "33794", "last_activity_date": "2017-04-05T11:39:39.910", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19716", "parent_id": "33771", "post_type": "answer", "score": 1 } ]
33771
null
33794
{ "accepted_answer_id": null, "answer_count": 3, "body": "最近asp.netプロジェクトに中途参加したのですが \nどうも基本的な処理でいろいろと問題が発生しています。 \nフレームワークを正しく使っていないのか、さもなくばMSが相変わらずクソなのか \n真実を知りたく達人のお知恵を授かりたいと思います。\n\n以下現在自分が気になっている点です。\n\n * MVC\n\n現行MVCモデルになっておらず、各々別個のページ(.aspx)にアクセスしている。 \nそもそも.NETによるアプリケーションの基本構造のトレンドはMVCではないのか?\n\n * ページ遷移\n\n現行ページ遷移はServer.Transferで行っている。 \n従ってブラウザが認識するのは”前ページ”であるため(か) \nいろいろ”不都合”が生じ妙なパッチを当ててしのぐ必要がある。 \nそもそも.NETでは”ページ遷移”はどうするのが正しいのか?\n\n * ログイン管理あるいはマルチセッション(?)\n\nログインをASPのセッションで管理しているため、 \n複数のウインドウで異なるログインでの使用はアプリケーション側ではできない。 \n「すでにログインしているサービスに、別なウインドウから別なアカウントで同時にログインして使いたい」 \nというのはごくありふれたニーズだが、 \nセッションでシンプルに管理していうとストレートに対応できない。 \nそもそも.NETでは”ログイン管理”はどうするのが正しいのか?\n\n* * *\n\nちなみに本プロジェクトは規模も歴史も長大なので、今更基本構造をどうこうはできませんが \n後学と好奇心のため、お手すきの達人がおられましたらご教授いただければ幸いです。 \nあるいはそこらへんを簡潔明快にまとめた記事があればご紹介ください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T01:20:36.913", "favorite_count": 0, "id": "33775", "last_activity_date": "2017-04-05T14:35:54.080", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20996", "post_type": "question", "score": -1, "tags": [ "asp.net" ], "title": "asp.net:正しい使い方", "view_count": 984 }
[ { "body": "> 現行MVCモデルになっておらず、各々別個のページ(.aspx)にアクセスしている。 \n> そもそも.NETによるアプリケーションの基本構造のトレンドはMVCではないのか?\n\n現在使用されているのはASP.NET Web Formsというフレームワークでこれは10年近く前の技術になります。現在の主力はASP.NET\nMVCで、クロスプラットフォームに再設計されたASP.NET Core MVCが開発段階にあります。\n\n> 現行ページ遷移はServer.Transferで行っている。 \n> 従ってブラウザが認識するのは”前ページ”であるため(か) \n> いろいろ”不都合”が生じ妙なパッチを当ててしのぐ必要がある。 \n> そもそも.NETでは”ページ遷移”はどうするのが正しいのか?\n\nこれは`Response.Redirect`を使用すべきです。\n\n> ログインをASPのセッションで管理しているため、 \n> 複数のウインドウで異なるログインでの使用はアプリケーション側ではできない。\n\nCookieの仕様に基づいたWebアプリケーションではごく一般的な動作だと思います。複数の状態を管理したいのであればクエリー文字列などでパラメーターを明示的に渡してやる必要があるかと思います。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T02:17:29.297", "id": "33777", "last_activity_date": "2017-04-05T02:17:29.297", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "33775", "post_type": "answer", "score": 3 }, { "body": "> 「すでにログインしているサービスに、別なウインドウから別なアカウントで同時にログインして使いたい」 というのはごくありふれたニーズだが、 \n> セッションでシンプルに管理していうとストレートに対応できない。\n\n質問とズレるのでオフトピですが… \n1つのブラウザでセッションが1つきりと言うのは一般的ですので、別アカウントで開きたいというニーズには、Chromeのユーザプロファイルを使い分けることで対応してもらってます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T03:27:39.630", "id": "33778", "last_activity_date": "2017-04-05T03:27:39.630", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "33775", "post_type": "answer", "score": 3 }, { "body": "### MVC\n\nASP.NETの歴史はVisual Studio .net 2002からとなり、当時はまだAJAXという概念が存在していませんでした。ASP.NET\nMVCの登場はVisual Studio 2008からとなります。 \nプロジェクトの歴史が長大とのことですが、2008年以前に設計されたものであれば仕方がないかと思います。ただし古いままを維持するか、AJAXやMVCなど順次新しい技術を取り入れていくかはプロジェクト次第かと思います。\n\n### ページ遷移\n\n[`Server.Transfer`メソッド](https://msdn.microsoft.com/ja-\njp/library/y4k58xk7\\(v=vs.100\\).aspx)はドキュメントに\n\n> 現在のユーザーに対して、Transfer メソッドで提供されるリソースを表示する権限が与えられているかどうかを確認しません。\n\nとあるように、権限の確認が行われないなど特殊な動作をしますからページ遷移に常用するのはお勧めできません。ASP.NETでは通常のHTMLと同じく、`<a\nhref>`によるページ遷移が可能ですので特殊な記述をすべきではありません。\n\n### ログイン管理あるいはマルチセッション\n\n他の方々も言及されていますが、Webとしては一般的な動作です。逆に\n\n> 「すでにログインしているサービスに、別なウインドウから別なアカウントで同時にログインして使いたい」 \n> というのはごくありふれたニーズ\n\nに応えているWebサイト等ありましたら挙げてみてください。例えばここstack overflowは該当しませんよね?\nもし具体例が見つからないようでしたら「ごくありふれたニーズ」という認識を改めることをお勧めします。\n\n* * *\n\n個人的には\n\n> フレームワークを正しく使っていない\n\nに1票投じます。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T14:35:54.080", "id": "33795", "last_activity_date": "2017-04-05T14:35:54.080", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "33775", "post_type": "answer", "score": 1 } ]
33775
null
33777
{ "accepted_answer_id": "33781", "answer_count": 2, "body": "現在、IE11をサポート対象としたWebアプリケーションを作っています。 \nここで、IE11ではサポートされていないECMAScript6で追加された関数などを使いたいと考えています。 \n新たに追加された構文はさすがに無理だとしても、例えばString.prototypeに追加されたメソッドなどは、簡単に同等のものを自作できるので、そのようなライブラリがすでにあるだろうと踏んでいます。 \nただ、検索キーワードが分からないので、探せなくて困っている状況です。\n\nこのようなライブラリを総称する用語はあるでしょうか? \nAltJSとかトランスパイラとか、そういった類の用語です(が、ほしいのはトランスパイラではなく、手軽に導入できる、ただのライブラリです)。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T04:21:22.783", "favorite_count": 0, "id": "33779", "last_activity_date": "2017-04-05T05:11:58.647", "last_edit_date": "2017-04-05T04:51:35.440", "last_editor_user_id": "8078", "owner_user_id": "8078", "post_type": "question", "score": 4, "tags": [ "javascript" ], "title": "ECMAScriptの新バージョンの機能を利用できるようになるライブラリの総称", "view_count": 106 }
[ { "body": "よく使われる用語では無さそうな気がしますが、検索ワードとして \"ECMAScript 6 compatible library\" を使ってググると\n<https://github.com/paulmillr/es6-shim> がヒットしました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T04:31:59.653", "id": "33780", "last_activity_date": "2017-04-05T04:31:59.653", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "33779", "post_type": "answer", "score": 0 }, { "body": "一般的にAPIインターフェイスをすこし変更するための簡単なラッパーのことを`shim`と称し、特にWebブラウザーでサポートされていない機能を追加するためのライブラリーを`polyfill`と呼びます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T05:11:58.647", "id": "33781", "last_activity_date": "2017-04-05T05:11:58.647", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "33779", "post_type": "answer", "score": 7 } ]
33779
33781
33781
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n import UIKit\n \n class ViewController: UIViewController {\n @IBOutlet weak var webview: UIWebView!\n @IBOutlet weak var searhBar: UIBarButtonItem!\n @IBOutlet weak var Stop: UIBarButtonItem!\n @IBOutlet weak var Reload: UIBarButtonItem!\n @IBOutlet weak var Back: UIBarButtonItem!\n \n //起動時に開くページ\n let homeUrlString = \"https://www.google.co.jp/\"\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // ホームページ開く\n open(urlString: homeUrlString)\n }\n \n //指定したurlをweb viewで開く\n func open(urlString: String){\n let url = URL(string: urlString)\n let urlRequest = URLRequest(url:url!)\n WebView.loadRequest(urlRequest)\n }\n \n @IBAction func BackButtonTapped(sender: UIBarButtonItem){\n \n }\n @IBAction func reloadButtonTapped(sender: UIBarButtonItem){\n \n }\n \n @IBAction func stopButtonTapped(sender: UIBarButtonItem){\n \n }\n }\n \n```\n\n`WebView.loadRequest(urlRequest)`のところが`use of unresolved\nidentifier`と表示されどこが間違っているのかがわかりません。初心者で参考書どおりにやってたらこうなって... \n誰かどこが間違っているか教えてください。 \n言語はSwiftです", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T05:44:41.640", "favorite_count": 0, "id": "33783", "last_activity_date": "2018-08-16T09:01:16.447", "last_edit_date": "2017-04-05T06:24:19.267", "last_editor_user_id": "5519", "owner_user_id": "21377", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "webView.loadRequest(urlRequest)のところがuse of unresolved identifierと表示される", "view_count": 578 }
[ { "body": "`WebView.loadRequest(urlRequest)` の`WebView`の`W`と`V`が大文字になっています。\n\nプロパティとして定義している`@IBOutlet weak var webview:\nUIWebView!`では`webview`とすべて小文字なので、同じように書かなければなりません。Swiftでは大文字と小文字は区別されますので、異なると別の変数だと解釈されます。\n\nそのため、定義されてないプロパティを使おうとしたということで`unresolved identifier`というエラーになっています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T06:27:32.687", "id": "33786", "last_activity_date": "2017-04-05T06:27:32.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "33783", "post_type": "answer", "score": 1 } ]
33783
null
33786
{ "accepted_answer_id": "33809", "answer_count": 2, "body": "lambda でリクエストを処理する、サーバーレスアーキテクチャがあると思います。lambda の設定自体がある種のプログラム用な形で、その AWS\nの設定全体がシステムになるのだと理解しています。\n\nこれら AWS の機構は、基本的にひとつひとつ設定する形のみで UI ないし API\nは提供されています。しかし、これをそのまま操作したり、プログラムを実行するスクリプトを書いたりするのは、あまり取り回しがよくありません。\n\nサーバーレスアーキテクチャを、宣言的に記述・管理できるとやりやすいだろうと考えました。\n\nこのような仕組み・ツールなどはありますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T06:25:58.563", "favorite_count": 0, "id": "33785", "last_activity_date": "2017-07-25T17:24:14.347", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 0, "tags": [ "aws" ], "title": "サーバーレスアーキテクチャを宣言的に記述したい", "view_count": 115 }
[ { "body": "CloudFormationを使ってみてはどうでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-06T07:13:59.373", "id": "33809", "last_activity_date": "2017-04-06T07:13:59.373", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "33785", "post_type": "answer", "score": 1 }, { "body": "Serverless Archtecture Framework というツールがあります。CloudFormation の拡張のような位置付けです。 \n<https://github.com/awslabs/serverless-application-model>\n\nAWS Serverless Application Model (AWS SAM) を使ってサーバーレスアプリケーションを構築する \n<http://dev.classmethod.jp/cloud/aws/aws-serverless-application-model/>\n\nその他にも、serverless framework などサードパーティのツールがあります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-07-25T17:24:14.347", "id": "36672", "last_activity_date": "2017-07-25T17:24:14.347", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "33785", "post_type": "answer", "score": 2 } ]
33785
33809
36672
{ "accepted_answer_id": "33971", "answer_count": 2, "body": "【やりたいこと】 \nAndroid にて非同期で複数の処理をしようと考えています。 \n処理 A, B, C... があり、全ての処理が終わったところで UI側にreceiver.sendしたいです。\n\n【やってみたこと】 \nActivityから X_IntentServiceを呼び、 \nそこから A_IntentService, B_IntentService というように複数の処理を行い、 \n全て終わったところで X_IntentServiceから `receiver.send()` しようとしたら \nA,Bなど各IntentServiceにて receiver.send()した時に以下のExceptionになってしまいます。\n\n```\n\n java.lang.RuntimeException: Handler (android.os.Handler) {656e5a68} sending message to a Handler on a dead thread\n \n```\n\nそもそも`IntentService`から `IntentService` は呼べない仕組みなのでしょうか? \nA_IntentServiceから receiver.send() した時には X_IntentService\nの処理がすでに終わってる、ということでしょうか。 \nまた、こう言ったケースのベストプラクティスはありますか?", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T07:31:45.073", "favorite_count": 0, "id": "33787", "last_activity_date": "2017-07-03T12:53:26.863", "last_edit_date": "2017-04-05T09:18:43.297", "last_editor_user_id": "20888", "owner_user_id": "20888", "post_type": "question", "score": 0, "tags": [ "android", "java", "非同期" ], "title": "Android 非同期で複数の処理", "view_count": 1084 }
[ { "body": "通常のJavaのthread(ワーカースレッド)を使用し、join(待ち合わせ)後に処理を開始すればよいと思います。 \n前の方が記述されておりますが、GUIでないスレッド(メインスレッド)から画面を操作するとアプリケーションが異常終了するので、画面を操作する処理の場合はHandlerを使用する必要があります。\n\n注意点として、Activityでthreadを起動した場合、画面遷移(onPouse or\nonDestroy)の動作でthreadが動作停止してしまいます。 \n上記は、Activityではなく、Serviceからthreadを起動させ、バックグランドで常駐させる事で回避が可能です。この辺りはアプリの実装に依存します。\n\n簡単に纏めると、AndroidのServiceは画面遷移を複数挟んでも継続して欲しい処理に対して使用し、その中で並列で走らせたい処理があった場合は、thread等の非同期処理を使用する。が、実装としてシンプルではないでしょうか。\n\n質問の内容の処理なら、サービスを複数起動する必要はないと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-13T03:42:11.000", "id": "33971", "last_activity_date": "2017-04-13T03:42:11.000", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22484", "parent_id": "33787", "post_type": "answer", "score": 0 }, { "body": "別スレッドからUIスレッドへの橋渡しとなるHandlerを使用\n\n```\n\n Handler handler= new Handler();\n \n public void onClickButton(View v) {\n new Thread(new Runnable() {\n @Override\n public void run() {\n // マルチスレッドにしたい処理 ここから\n \n final String result = getMessage(); // 何かの処理\n handler.post(new Runnable() {\n @Override\n public void run() {\n msgView.setText(result); // 画面に描画する処理\n }\n });\n \n // マルチスレッドにしたい処理 ここまで\n }\n \n```\n\n}).start(); \n}", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-07-03T12:53:26.863", "id": "36072", "last_activity_date": "2017-07-03T12:53:26.863", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "23205", "parent_id": "33787", "post_type": "answer", "score": -1 } ]
33787
33971
33971
{ "accepted_answer_id": "33789", "answer_count": 1, "body": "初めまして。 \nかなり強引な書き方ですが、ruby on rails のアプリを公開したいと \n思っています。\n\npuma と nginxでしたいと思っています。参考になるようなサイトを \n探して真似てみたのですがどうしてもつながりません。 \nどなたかエラーとなりそうな所を指摘もらえたらと願っています。\n\nちなみに下記でのpumaだけでは外部から見れます。。\n\n```\n\n rails s -d -b 0.0.0.0 -p 80\n \n```\n\nもちろんこの前に必要事項は`export`と`rails assets:precompile`は実行 \nしています。\n\n私のhostの環境は次の通りです。\n\n```\n\n DISTRIB_ID=Ubuntu\n DISTRIB_RELEASE=16.04\n DISTRIB_CODENAME=xenial\n DISTRIB_DESCRIPTION=\"Ubuntu 16.04.2 LTS\"\n \n ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]\n \n Rails 5.0.1\n \n nginx version: nginx/1.10.0 (Ubuntu)\n \n```\n\n一部設定状況は下記の通りです。\n\n```\n\n ******@nahs:~$ cat /etc/nginx/conf.d/app_nagao_2.conf\n upstream app_nagao2 {\n server unix:/home/nagao/run/app_nagao2.sock fail_timeout=0;\n }\n \n server {\n listen 80;\n server_name 192.168.210.150;\n \n root /home/******/run/app_nagao2/public; # アプリケーション名を記述\n \n try_files $uri/index.html $uri @app_nagao2; # アプリケーション名を記述\n \n location / {\n proxy_pass http://app_nagao2; # アプリケーション名を記述\n \n app_nagao2/config/puma.rb\n _proj_path = \"#{File.expand_path(\"../..\", __FILE__)}\"\n _proj_name = File.basename(_proj_path)\n _home = ENV.fetch(\"HOME\") { \"/home/******\" }\n \n pidfile \"#{_home}/run/#{_proj_name}.pid\"\n bind \"unix://#{_home}/run/#{_proj_name}.sock\"\n directory _proj_path\n \n \n threads_count = ENV.fetch(\"RAILS_MAX_THREADS\") { 8 }.to_i\n threads threads_count, threads_count\n \n```\n\nラン内での <http://192.168.210.150:80> では正常に表示します。 \nでも外からのアクセスでは Welcome to Nginx だけで \n私のページは表示されません。\n\n/var/log/nginx/error.log に下記のようなメッセージが出ています。\n\n```\n\n www-data\n \n [error] 1283#1283: *32 connect() to unix:/home/******/run/app_nagao2.sock failed (111: Connection refused)\n \n root@nahs:~# ls -l /home/******/run/\n 合計 4\n drwxrwxr-x 12 ****** ****** 4096 4月 1 22:29 app_nagao2\n srwxrwxrwx 1 ****** ****** 0 4月 3 20:16 app_nagao2.sock\n \n cat /etc/group\n   ・\n   ・\n ******:x:1000:www-data\n \n```\n\n*****はサーバーでのログイン名です。 \n正直多くのところで内容が理解できていません。 \n何かアドバイスいただけたら幸いです。 \nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T08:04:06.547", "favorite_count": 0, "id": "33788", "last_activity_date": "2017-04-05T08:27:26.340", "last_edit_date": "2017-04-05T08:27:26.340", "last_editor_user_id": "19110", "owner_user_id": "14412", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "nginx" ], "title": "rails5, puma, nginxで繋げる事ができない。", "view_count": 2577 }
[ { "body": "おそらくデフォルトの`server`ディレクティブが邪魔をしているのでしょう。\n\n複数のホストが同一ポートに登録されている場合、Nginxは`Host`ヘッダと`server_name`ディレクティブを参照して利用するものを選択します。\n\nもし単一アプリのみにそのサーバーを利用する予定ならばデフォルトのserverディレクティブ(おそらくnginx.confに定義されている)を削除orコメントアウトすればすべてのリクエストはそのアプリケーションに到達できるでしょう。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T08:17:23.820", "id": "33789", "last_activity_date": "2017-04-05T08:17:23.820", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2376", "parent_id": "33788", "post_type": "answer", "score": 0 } ]
33788
33789
33789
{ "accepted_answer_id": null, "answer_count": 1, "body": "タイトル通りですが、 \npowershellを使って文字列\"(ダブルクォーテーション)を削除したいです。\n\n現状\n\n```\n\n $s = $(get-count \"c:¥work¥sample.txt\")\n $s\n $s.trim(`\"` )\n \n```\n\nなのですが、[\"]を認識させることが出来ません。\n\nどなたかよろしくお願い致します。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T09:02:43.310", "favorite_count": 0, "id": "33790", "last_activity_date": "2017-04-06T06:16:58.017", "last_edit_date": "2017-04-05T09:25:22.027", "last_editor_user_id": "8000", "owner_user_id": "21361", "post_type": "question", "score": 0, "tags": [ "powershell" ], "title": "powershellを使って文字列\"(ダブルクォーテーション)を削除したいです。", "view_count": 27669 }
[ { "body": "PowerShellでダブルクォートを含む文字列を書きたい場合は、\n\n * シングルクォートを使った文字列を使う:`'\"'`\n * バッククォートでエスケープする:`\"`\"\"`\n\nといった方法があります。バッククォートで囲む構文はありません。\n\nで、例えば次のようになります。\n\n```\n\n PS C:\\> $s = '\"foobar\"'\n \n PS C:\\> $s\n \"foobar\"\n \n PS C:\\> $s.Trim('\"')\n foobar\n \n```\n\n参考 [文字列 - Windows PowerShell | ++C++; // 未確認飛行\nC](http://ufcpp.net/study/powershell/string.html#string)\n\n* * *\n\n`Trim()` は文字列の両端で連続する文字を取り除くメソッドなので、文中の \" を取り除きたい場合は `Replace()` や `-replace`\n演算子(こちらは正規表現が使えます)を使います。\n\n```\n\n PS R:\\> 'a\"b\"c\"'.Replace('\"', '')\n abc\n \n PS R:\\> 'a\"b\"c\"' -replace '\"', ''\n abc\n \n```\n\nまた Get-Contents で複数行のテキストを読み込む場合は配列になるので `foreach` を使いますが、直接 `Replace()` メソッドや\n`-replace` 演算子を使っても同じ結果が得られます。\n\n```\n\n PS R:\\> $s\n \"aa\"\n bb\"cc\n \n PS R:\\> $s | foreach { $_.Replace('\"', '') }\n aa\n bbcc\n \n PS R:\\> $s.Replace('\"', '')\n aa\n bbcc\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T09:43:25.550", "id": "33792", "last_activity_date": "2017-04-06T06:16:58.017", "last_edit_date": "2017-04-06T06:16:58.017", "last_editor_user_id": "8000", "owner_user_id": "8000", "parent_id": "33790", "post_type": "answer", "score": 3 } ]
33790
null
33792
{ "accepted_answer_id": null, "answer_count": 2, "body": "タイトルどおりです. \nL次元のベクトルxがi,j,kをパラメータにして生成させるとき, \n列にXベクトルの成分をならべ,インデックスをi,j,kの組み合わせで表示したいです. \n以下のような生成過程のデータをうまく管理したいです.\n\n```\n\n for i range (I)\n for j range (J)\n for k range (K)\n for l range (L)\n x[i,j,k,l] = fanc(i,j,k)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T09:38:48.897", "favorite_count": 0, "id": "33791", "last_activity_date": "2019-01-23T01:06:16.330", "last_edit_date": "2017-04-05T09:51:25.930", "last_editor_user_id": "21291", "owner_user_id": "21291", "post_type": "question", "score": 1, "tags": [ "python", "pandas" ], "title": "pandasで4次元配列を管理したい.", "view_count": 644 }
[ { "body": "reshapeとMultiIndexで解決できそうです. \n良い表現方法がありましたら,ご教授ください", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T10:39:18.007", "id": "33793", "last_activity_date": "2017-04-05T10:39:18.007", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21291", "parent_id": "33791", "post_type": "answer", "score": 0 }, { "body": "やりたいことは、こんな感じでしょうか?\n\n```\n\n import pandas as pd\n I,J,K,L = 3,3,3,5\n \n # Indexは range(I),range(J),range(K) の組み合わせ\n idx = pd.MultiIndex.from_product([range(I),range(J),range(K)])\n # Columnは range(L)\n col = range(L)\n # DataFrameの生成\n df = pd.DataFrame(index=idx, columns=col)\n \n # 何かしらの計算式\n def func(i,j,k,l):\n return i+j+k+l # ←とりあえず適当に定義\n \n # 行毎に上記の計算式を適用して各セルを埋める\n df = df.apply(lambda row: [func(*row.name, x) for x in row.index], axis=1)\n \n print(df)\n # 0 1 2 3 4\n #0 0 0 0 1 2 3 4\n # 1 1 2 3 4 5\n # 2 2 3 4 5 6\n # 1 0 1 2 3 4 5\n # 1 2 3 4 5 6\n # 2 3 4 5 6 7\n # 2 0 2 3 4 5 6\n # 1 3 4 5 6 7\n # 2 4 5 6 7 8\n #1 0 0 1 2 3 4 5\n # 1 2 3 4 5 6\n # 2 3 4 5 6 7\n # 1 0 2 3 4 5 6\n # 1 3 4 5 6 7\n # 2 4 5 6 7 8\n # 2 0 3 4 5 6 7\n # 1 4 5 6 7 8\n # 2 5 6 7 8 9\n #2 0 0 2 3 4 5 6\n # 1 3 4 5 6 7\n # 2 4 5 6 7 8\n # 1 0 3 4 5 6 7\n # 1 4 5 6 7 8\n # 2 5 6 7 8 9\n # 2 0 4 5 6 7 8\n # 1 5 6 7 8 9\n # 2 6 7 8 9 10\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-23T01:06:16.330", "id": "52223", "last_activity_date": "2019-01-23T01:06:16.330", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "24801", "parent_id": "33791", "post_type": "answer", "score": 1 } ]
33791
null
52223
{ "accepted_answer_id": "33798", "answer_count": 1, "body": "`div`に`clear:left`を書くとfloat解除されるのに、 \n`span`だとされないのはなぜですか?\n\n**[html]**\n\n```\n\n <img src=\"images/001.png\" alt=\"\">\n \n <!-- <div id=\"study_001\"> -->\n <span id=\"study_001\">\n <span id=\"margin\">margin</span><span id=\"border\">border</span><span id=\"padding\">padding</span>\n </span>\n <!-- </div>だとfloat解除される! -->\n \n```\n\n**[css]**\n\n```\n\n img {\n width: 500px;\n margin: 20px;\n float: left;\n }\n \n #study_001{\n clear: left;\n }\n \n #margin{\n padding: 10px 50px;\n margin: 10px 0px 10px 20px;\n background: #f98;\n }\n \n #border{\n border-left: 3px #fff solid;\n padding: 10px 0px 10px 2px;\n margin: 0;\n }\n \n #padding{\n background: #498;\n padding: 10px 50px;\n }\n \n```\n\nspanの場合(解除されない) \n[![spanの場合](https://i.stack.imgur.com/aEEk2.png)](https://i.stack.imgur.com/aEEk2.png)\n\ndivの場合(解除される) \n[![divの場合](https://i.stack.imgur.com/DKedA.png)](https://i.stack.imgur.com/DKedA.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T15:52:23.547", "favorite_count": 0, "id": "33796", "last_activity_date": "2017-04-05T23:13:42.350", "last_edit_date": "2017-04-05T17:35:25.077", "last_editor_user_id": "12297", "owner_user_id": "12297", "post_type": "question", "score": 3, "tags": [ "css", "html5" ], "title": "divだとfloat解除されるのに、spanだとされないのはなぜですか?", "view_count": 716 }
[ { "body": "直接的には[`clear`プロパティ](https://www.w3.org/TR/CSS2/visuren.html#propdef-clear)は\n\n> _Applies to:_ block-level elements\n\nとブロック要素にしか適用されないからです。\n\n論理的にもブロック要素の開始位置を下にずらす機能です。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/ckJoR.png)](https://i.stack.imgur.com/ckJoR.png)\n→\n[![画像の説明をここに入力](https://i.stack.imgur.com/hot2m.png)](https://i.stack.imgur.com/hot2m.png)\n\nここでもしブロック要素の中間部分のインライン要素に対して`clear`を指定したとして、どのようなレイアウトを期待されますか?\n…と考えると`<span>`要素で`clear`が機能しないのは適切かと。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-04-05T23:13:42.350", "id": "33798", "last_activity_date": "2017-04-05T23:13:42.350", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "33796", "post_type": "answer", "score": 4 } ]
33796
33798
33798