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": 2, "body": "storyboard上でAttributeStringを設定したいです。\n\n`let attributedText = NSMutableAttributedString(string: “Hello, I am”,\nattributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 17)])`\n\nとソースでAttributedStringを実装してましたが、storyboard上で設定できることに気づきました。 \nしかし問題があってsystemFontが「FontFamily」に出てきません。これって何故なのでしょう。 \nTextのタイプを「Plain」だと問題なく選択できますが、「Attributed」の時はどれを選択すればsystemFontとなるのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-25T12:32:42.127", "favorite_count": 0, "id": "56091", "last_activity_date": "2022-05-13T08:03:35.313", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14760", "post_type": "question", "score": 0, "tags": [ "swift", "ios", "xcode", "storyboard" ], "title": "storyboard上でAttributeStringを設定したい", "view_count": 1137 }
[ { "body": "iOSのシステムフォントは、San Francisco Pro というフォントです。これはAppleがiOS, macOS,\ntvOS用に作ったフォントで、Apple Font とも呼ばれています。\n\n私の環境では、フォントを選択する小ウィンドウの\"Collection\"で\"Recently Used\"を選ぶと、\"システムフォント\n25.0\"というのが出てきます。これを選ぶとシステムフォントになります。サイズも変えられます。なぜこれが出るようになったのかわかりませんが、もしアーサーさんの環境にもこれがあったら、それを選ぶと良いです。ないかもしれません。\n\nStory Bo...
56091
null
56120
{ "accepted_answer_id": null, "answer_count": 1, "body": "PyTorchでCUDAを使って計算しようとしたところ、下記エラーが吐かれてしまいました。\n\n```\n\n RuntimeError: Expected object of backend CPU but got backend CUDA for argument #4 'mat1'\n \n```\n\nこのエラーの対処方法をご教授していただけないでしょうか。 \nコードは下記の通りで、MNISTの画像分類問題を簡単なニューラルネットワークで解こうと思っておりました。 \n一応テンソルとモデルをすべてGPUに送っているつもりでしたが、うまくいきませんでした。\n\n```\n\n import torch\n use_cuda = torch.cuda.is_available()\n device = torch.device(\"cuda\" if use_cuda else \"cpu\")\n print(device)\n \n \n \n # 手書き数字の画像データMNISTをダウンロード\n from sklearn.datasets import fetch_openml\n mnist = fetch_openml('mnist_784', version=1, data_home=\".\")\n \n X = mnist.data / 255 # 0-255を0-1に正規化\n y = mnist.target\n \n # MNISTのデータセットの変更により、ラベルが数値データになっていないので、\n # 以下により、NumPyの配列の数値型に変換します\n import numpy as np\n y = np.array(y)\n y = y.astype(np.int32)\n \n # 2. DataLoderの作成\n from torch.utils.data import TensorDataset, DataLoader\n from sklearn.model_selection import train_test_split\n \n \n # 2.1 データを訓練とテストに分割(6:1)\n X_train, X_test, y_train, y_test = train_test_split(\n X, y, test_size=1/7, random_state=0)\n \n # 2.2 データをPyTorchのTensorに変換\n X_train = torch.Tensor(X_train).to(device)\n X_test = torch.Tensor(X_test).to(device)\n y_train = torch.LongTensor(y_train).to(device)\n y_test = torch.LongTensor(y_test).to(device)\n \n # 2.3 データとラベルをセットにしたDatasetを作成\n ds_train = TensorDataset(X_train, y_train)\n ds_test = TensorDataset(X_test, y_test)\n \n # 2.4 データセットのミニバッチサイズを指定した、Dataloaderを作成\n # Chainerのiterators.SerialIteratorと似ている\n loader_train = DataLoader(ds_train, batch_size=64, shuffle=True)\n loader_test = DataLoader(ds_test, batch_size=64, shuffle=False)\n \n # 3. ネットワークの構築\n from torch import nn\n \n model = nn.Sequential().to(device)\n model.add_module('fc1', nn.Linear(28*28*1, 100))\n model.add_module('relu1', nn.ReLU())\n model.add_module('fc2', nn.Linear(100, 100))\n model.add_module('relu2', nn.ReLU())\n model.add_module('fc3', nn.Linear(100, 10))\n \n print(model)\n \n # 4. 誤差関数と最適化手法の設定\n from torch import optim\n \n # 誤差関数の設定\n loss_fn = nn.CrossEntropyLoss()\n \n # 重みを学習する際の最適化手法の選択\n optimizer = optim.Adam(model.parameters(), lr=0.01)\n \n # 5. 学習と推論の設定\n # 5-1. 学習1回でやることを定義します\n def train(epoch):\n model.train() # ネットワークを学習モードに切り替える\n \n # データローダーから1ミニバッチずつ取り出して計算する\n for data, targets in loader_train:\n data = data.to(device)\n targets = targets.to(device)\n \n optimizer.zero_grad() # 一度計算された勾配結果を0にリセット\n outputs = model(data) # 入力dataをinputし、出力を求める\n loss = loss_fn(outputs, targets) # 出力と訓練データの正解との誤差を求める\n loss.backward() # 誤差のバックプロパゲーションを求める\n optimizer.step() # バックプロパゲーションの値で重みを更新する\n \n print(\"epoch{}:終了\\n\".format(epoch))\n \n # 5-2. 推論1回でやることを定義します\n def test():\n model.eval() # ネットワークを推論モードに切り替える\n correct = 0\n \n # データローダーから1ミニバッチずつ取り出して計算する\n with torch.no_grad(): # 微分は推論では必要ない\n for data, targets in loader_test:\n data = data.to(device)\n targets = targets.to(device)\n \n outputs = model(data) # 入力dataをinputし、出力を求める\n \n # 推論する\n _, predicted = torch.max(outputs.data, 1) # 確率が最大のラベルを求める\n correct += predicted.eq(targets.data.view_as(predicted)).sum() # 正解と一緒だったらカウントアップ\n \n # 正解率を出力\n data_num = len(loader_test.dataset) # データの総数\n print('\\nテストデータの正解率: {}/{} ({:.0f}%)\\n'.format(correct,\n data_num, 100. * correct / data_num))\n \n # 学習なしにテストデータで推論してみよう\n test()\n \n # 6. 学習と推論の実行\n import time\n t1 = time.time() \n \n for epoch in range(10):\n train(epoch)\n test()\n \n \n \n```\n\n何卒宜しくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-25T12:47:44.880", "favorite_count": 0, "id": "56093", "last_activity_date": "2023-05-05T13:03:42.907", "last_edit_date": "2019-06-25T12:53:56.810", "last_editor_user_id": "30280", "owner_user_id": "30280", "post_type": "question", "score": 1, "tags": [ "python", "cuda", "gpu", "pytorch" ], "title": "PyTorchでCUDAが使えない", "view_count": 2081 }
[ { "body": "手元の環境で試していましたが\n\n```\n\n model = nn.Sequential()\n model.add_module('fc1', nn.Linear(28*28*1, 100))\n model.add_module('relu1', nn.ReLU())\n model.add_module('fc2', nn.Linear(100, 100))\n model.add_module('relu2', nn.ReLU())\n model.add_module('fc3', nn.Linear(100, 10))\n model....
56093
null
94754
{ "accepted_answer_id": "56101", "answer_count": 1, "body": "お世話になります。\n\nMicrosoftAccess2010(32bit)のDB(.accdb)を、PHPで接続してWeb化をしようとしています。 \n将来的にはXAMPPのMySqlのデータを使用するので、Accessからは切り離せるのですが、 \n今まで生きていたAccessのシステムで使用していたデータはAccessにあるため、 \n完全に完成して公開するまではデータベースは既存のAccessのものを転用する流れでいます。\n\nそこで、その方法を調べていたところ、こちらのサイト様にたどり着きました。 \n『<https://qiita.com/ginga_sil/items/865299fa3a899ac723d9>』 \n始まって間もなくのところに、AccessとPHPを32bitで合わせないと動かないと \n書かれておりました。\n\nところが、現況ダウンロードできるXAMPPは64bitのものしか見当たりません(単に探し方が \n悪いだけかもしれませんが…)。そうなってしまうと、実質接続できないということに \nなってしまうのですが、あきらめるしかないのでしょうか。\n\nご助力をお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-25T23:20:55.307", "favorite_count": 0, "id": "56096", "last_activity_date": "2020-02-22T16:29:51.197", "last_edit_date": "2020-02-22T16:29:51.197", "last_editor_user_id": "3060", "owner_user_id": "9374", "post_type": "question", "score": 0, "tags": [ "php", "xampp", "ms-access" ], "title": "XAMPP環境でPHPからAccessのDBに接続する方法", "view_count": 1316 }
[ { "body": "条件に合う?使える?性能は?費用を出せるか?等の様々な疑問はありますが、 \n以下の記事の解決マークの付いていない方の回答に、こんな情報があります。\n\n使えるなら費用を払っても良いと考えられるなら、14日間試用版で調査してみるのはどうでしょう?\n\n[Using 32 Bit Modules with Apache 86_64 Arch (64\nbit)](https://stackoverflow.com/q/11938802/9014308) \n質問:\n\n> So I have a very unique problem. \n> I am using php-ODBC...
56096
56101
56101
{ "accepted_answer_id": "56107", "answer_count": 2, "body": "解決策をご存知の方にご教示をお願いいたします。\n\n**実現したいこと** \n大きさの決まったダイアログおよびLabelFrame内で、Treeviewを使用して表を表示したいです。 \n表は見やすいように、カラムを項目に合わせて固定幅とします。そのため、決められた大きさの中で、Treeview上の表は表示しきれないので、縦横のスクロールバーが埋め込む有効な状態としたいです。\n\n**現在の問題点** \n・Treeview上の表全体の幅が収めたい幅にならない。 \n・Treeviewの幅が抑えられないので、横スクロールバーが有効にならない。\n\n**サンプルコード** \nLabelFrame内にTreeviewおよびscrollbarを配置します。 \nTreeviewには全体の幅するオプションがないので、LabelFrame.columnconfigureで指定するが無視されて、Treeviewの表データに合わせた幅になってしまっています。\n\n**試したこと** \n以下のリンクについて、試しました。 \n私の用途では、place()による配置は適していないため、2つ目のリンクの内容は参考になりませんでした。 \n[Horizontal scrolling won't activate for ttk Treeview\nwidget](https://stackoverflow.com/questions/14359906/horizontal-scrolling-\nwont-activate-for-ttk-treeview-widget) \n[python ttk\nNotebookにtreeviewをグリッドで配置した時にスクロールバーが収まらない](https://teratail.com/questions/139274)\n\n* * *\n```\n\n #! /usr/bin/env python3\n # -*- coding: utf-8 -*-\n \n import tkinter as tk\n from tkinter import ttk\n \n class CreateScreen(object):\n def __init__(self):\n self.screen_w = 300\n self.screen_h = 200\n self.dlg_pos_x = 10\n self.dlg_pos_y = 10\n \n return super().__init__()\n \n def createMainWindow(self):\n \n obj = ttk.tkinter.Tk() \n \n geo_string = str(self.screen_w) + \"x\" + str(self.screen_h) + \"+\" + str(self.dlg_pos_x) + \"+\" + str(self.dlg_pos_y) \n \n obj.geometry(geo_string) \n \n _InFrame_ = ttk.LabelFrame(\n obj,\n width = self.screen_w,\n height = self.screen_h,\n text = \"決められた幅のフレーム内で表示したい。\",\n )\n \n _TreeList_ = ttk.Treeview(\n _InFrame_,\n selectmode = 'none',\n show = \"headings\",\n height = 6,\n )\n \n tree_h_scroll = ttk.Scrollbar(\n _InFrame_,\n orient = tk.HORIZONTAL,\n command = _TreeList_.xview\n )\n \n tree_v_scroll = ttk.Scrollbar(\n _InFrame_,\n orient = tk.VERTICAL,\n command = _TreeList_.yview\n )\n \n _TreeList_['xscrollcommand'] = tree_h_scroll.set\n _TreeList_['yscrollcommand'] = tree_v_scroll.set\n \n tree = _TreeList_\n tree[\"columns\"]=(1,2,3,4,5,6)\n tree.heading(\"#0\",text = \"\")\n tree.heading(1,text = \"項\")\n tree.heading(2,text = \"名前\")\n tree.heading(3,text = \"型式\")\n tree.heading(4,text = \"単価\")\n tree.heading(5,text = \"在庫数\")\n tree.heading(6,text = \"備考\")\n \n tree.column(1, width = 30, stretch = False)\n tree.column(2, width = 100, stretch = False)\n tree.column(3, width = 150, stretch = False)\n tree.column(4, width = 50, stretch = False)\n tree.column(5, width = 50, stretch = False)\n tree.column(6, width = 150, stretch = False)\n \n tree_value = list()\n \n #適当にデータを埋め込む。\n for i in range(32):\n tree_value.append((i,\"tree\"+str(i),\"T-\"+str(i),i%5*1000+100,i%2*50,\"*******\"))\n \n for ch, val in enumerate(tree_value):\n tree.insert(\"\",index = \"end\",tags = ch%2,value=val)\n else:\n tree.tag_configure(0,background = \"lightcyan\")\n tree.tag_configure(1,background = \"white\")\n \n _InFrame_.grid(padx = 5, pady = 5, ipadx = 5, ipady = 5)\n _InFrame_.columnconfigure(0, minsize = 250)\n _TreeList_.grid(row = 0,column = 0, sticky = tk.N+tk.S+tk.E+tk.W )\n tree_h_scroll.grid(row = 1,column = 0,sticky = tk.EW )\n tree_v_scroll.grid(row = 0,column = 1,sticky = tk.NS )\n \n return obj\n \n if __name__ == '__main__':\n screen_obj = CreateScreen()\n \n MainWindow_obj = screen_obj.createMainWindow()\n \n MainWindow_obj.mainloop()\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T03:33:29.320", "favorite_count": 0, "id": "56104", "last_activity_date": "2019-06-26T08:30:01.530", "last_edit_date": "2019-06-26T03:56:32.420", "last_editor_user_id": "3060", "owner_user_id": "32891", "post_type": "question", "score": 1, "tags": [ "python", "python3" ], "title": "Treeview内リストを固定幅にし、横スクロールバーを有効にしたい。", "view_count": 6295 }
[ { "body": "```\n\n _InFrame_.grid(padx = 5, pady = 5, ipadx = 5, ipady = 5)\n _InFrame_.columnconfigure(0, minsize = 250)\n _TreeList_.grid(row = 0,column = 0, sticky = tk.N+tk.S+tk.E+tk.W )\n tree_h_scroll.grid(row = 1,column = 0,sticky = tk.EW )\n tree_v_scroll.grid(row = 0,column = 1,sti...
56104
56107
56107
{ "accepted_answer_id": "56123", "answer_count": 1, "body": "Realmを初めて使っている者です。 \nRealmで単語のデータベースを作り、その初期データを読み込んで単語クイズアプリを作っています。\n\n書籍を参考に読み取り専用で使用する場合のスクリプトを書いてみたのですが、エラーが出てしまいました。\n\n> Cannot use instance member 'fileURL' within property initializer; property\n> initializers run before 'self' is available\n\n自分でも調べてみたのですが理解できず、お力をお借りしたいです。 \nよろしくお願いします。\n\nなお、Xcodeのバージョンは 10.2.1 です。\n\n* * *\n```\n\n import UIKit\n import RealmSwift\n \n class ViewController: UIViewController {\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view.\n \n //デフォルトRealmnファイルのファイルURL\n let defaultFileURL = Realm.Configuration.defaultConfiguration.fileURL!\n \n //新しいデフォルトRealmファイルを生成したいため、存在する場合は削除\n if FileManager.default.fileExists(atPath: defaultFileURL.path){\n try! FileManager.default.removeItem(at: defaultFileURL)\n }\n \n let realm = try! Realm()\n \n print(Realm.Configuration.defaultConfiguration.fileURL!)\n \n let word = Word()\n \n try! realm.write{\n word.id = 1\n word.noun = \"acceptance\"\n word.verb = \"accept\"\n word.adj = \"acceptable\"\n word.adv = \"acceptably\"\n \n word.id = 2\n word.noun = \"preference\"\n word.verb = \"prefer\"\n word.adj = \"preferable\"\n word.adv = \"preferably\"\n \n realm.add(word)\n }\n \n //最適化したRealmファイルのファイルURL\n let fileURL = realm.configuration.fileURL!\n .deletingLastPathComponent()\n .appendingPathComponent(\"default-old.realm\")\n \n //新しく最適化したRealmファイルを生成したいので存在する場合は削除\n if FileManager.default.fileExists(atPath: fileURL.path){\n try! FileManager.default.removeItem(at: fileURL)\n }\n //Realmファイルを別ファイルに保存して(コピー)してファイルサイズを最適化する\n try! realm.writeCopy(toFile: fileURL)\n }\n \n //初期データの入ったRealmファイルを利用\n let oldRealmURL = Bundle.main.url(forResource: \"default-old\", withExtension: \"realm\")!\n \n //読み取り専用で使用\n let fileURL = Bundle.main.url(forResource: \"template\", withExtension: \"realm\")!\n let config = Realm.Configuration(fileURL: fileURL, readOnly: true) //ここでエラーが発生\n let templateRealm = try! Realm(configuration: config)\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T04:23:16.667", "favorite_count": 0, "id": "56105", "last_activity_date": "2019-06-27T00:12:54.660", "last_edit_date": "2019-06-27T00:12:54.660", "last_editor_user_id": "3060", "owner_user_id": "34585", "post_type": "question", "score": 0, "tags": [ "swift", "xcode", "realm" ], "title": "Realm\"Cannot use instance member..... \"のエラーについて", "view_count": 2531 }
[ { "body": "Realmと言うよりSwift言語特有の問題ですね。\n\nエラーメッセージの内容は、\n\n> Cannot use instance member 'fileURL' within property initializer; \n> property initializers run before 'self' is available\n>\n>\n> プロパティ初期化の中でインスタンスメンバーの`'fileURL'`を使うことはできません。プロパティ初期化は`'self'`が利用可能になる前に呼び出されます\n\n * 「インスタンスメンバー」インスタンスプロパティやインスタンスメ...
56105
56123
56123
{ "accepted_answer_id": null, "answer_count": 1, "body": "お世話になります。 \n現在私は独自ドメインをレンタルサーバーに設定して、一部のサブドメインをVPSに設定して利用しています。 \n今回レンタルサーバーの移行を行おうと思っているのですが、少し困っていることがあります。 \nVPSではcertbotでDNS認証を用いて、証明書の自動更新を行っていますが、APIで「_acme-\nchallenge」というレコードを追加する必要があります。 \n現在利用しているレンタルサーバー付属のDNSはAPIで操作することができるのですが、移行先のレンタルサーバー付属のDNSはAPIでの操作はできないようです。 \n現在利用中のサーバーでAレコード等を移行先サーバーに向ければよいかと思っていたのですが、移行先サーバーのマニュアルを見ると、Let'sEncryptの無料証明書を設定する場合は、ネームサーバーを変更しないといけないようです。 \nちなみに、Aレコードを移行先サーバーに向けた状態で、SSL設定をだめもとで試してみましたが、「ネームサーバーが当サービス指定のネームサーバーになっていません。」というエラーが出て、やはり設定できませんでした。 \nまた、移行元のレンタルサーバーと移行先のレンタルサーバー両方のネームサーバーを指定するという方法も考え、利用していないドメインで試してみましたが、うまくいきませんでした。 \nそれから、VPS上のcertbotでは、ワイルドカード証明書を発行しているため、httpでの認証は行えません。 \nまた、「_acme.challenge」レコードを手動で追加するのは、証明書を自動更新させたいため、難しいです。 \n情報不足とは思いますが、ほかに方法はありますでしょうか。 \nよろしくお願いいたします。", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T05:50:06.597", "favorite_count": 0, "id": "56106", "last_activity_date": "2019-06-28T12:35:05.283", "last_edit_date": "2019-06-27T12:35:31.990", "last_editor_user_id": "29034", "owner_user_id": "29034", "post_type": "question", "score": 0, "tags": [ "dns" ], "title": "複数サーバーでの運用に関して", "view_count": 111 }
[ { "body": "サーバのサービスとは関係ないサービスを使ってDNSを運用するのが結果的には早道だと思います。例えばCloudFlareのDNSサービスは無料でAPIも使えます。\n\n今の環境のまま解決する方法もあるのかもしれませんが、質問の内容からは現在の環境も状況もよくわからないので、その方向で解決するのは難しいです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T12:35:05.283", "id": "56190", "last_acti...
56106
null
56190
{ "accepted_answer_id": null, "answer_count": 0, "body": "初歩的な質問で失礼します。\n\nGCE上にインスタンスを作成し、postfixをインストールおよび設定をし、sendmailコマンドでSnedgridを経由しての送信には成功しました。\n\npostfixはリレーサーバとして利用したくインストールしており、いざWebアプリケーションからSMTPリクエストでGCEインスタンスの外部IPアドレス宛に送ってもうまく受信しません。\n\n受信の設定(main.cf)として、mynetworksにWebアプリケーション側のIPアドレスを入力しています。また、inet_interfaces =\nallもしています。\n\nそのほかにも設定が必要なのでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T07:05:36.987", "favorite_count": 0, "id": "56108", "last_activity_date": "2019-06-27T05:16:50.807", "last_edit_date": "2019-06-27T05:16:50.807", "last_editor_user_id": "3061", "owner_user_id": "34869", "post_type": "question", "score": 0, "tags": [ "linux", "google-cloud", "postfix", "google-compute-engine" ], "title": "GCE 上の Postfix への SMTP リクエスト", "view_count": 162 }
[]
56108
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "MySQLに対してMicrosoft Accessから接続と操作を行いたいのですがうまくいきません。 \n間違っている個所、抜けている個所がありましたらご指摘、ご教授をお願いいたします。\n\n環境 \nPC Windows10 (64bit) \nXAMPP 7.3.6 (64bit) \nAccess 2010 (32bit) \n使用したODBCドライバ mysql-connector-odbc-8.0.16-winx64.msi\n\n[Access から MySQLに接続する方法](http://accessmyusql.blog.fc2.com/blog-entry-8.html)\n\n上記サイトの「パススルークエリ」を参考に試したのですが、エラーで落ちてしまいます。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/ehnyW.jpg)](https://i.stack.imgur.com/ehnyW.jpg)\n\n**エラーメッセージ:**\n\n```\n\n ODBC--'{MySQL ODBC 8.0.16 DRIVER}localhost' への接続が失敗しました。\n \n```\n\n記述したODBC接続文字列は以下の通りです。\n\n```\n\n ODBC;Driver={MySQL ODBC 8.0.16 DRIVER};SERVER=localhost;DATABASE=test;UID=root;PWD=;\n \n```\n\nその後、両方のドライバを試してみましたが、今度はMySQL自体がエラーで \n動かなくなりました。\n\nその時のログが下記です。\n\n```\n\n 2019-06-27 9:07:01 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions\n 2019-06-27 9:07:01 0 [Note] InnoDB: Uses event mutexes\n 2019-06-27 9:07:01 0 [Note] InnoDB: Compressed tables use zlib 1.2.11\n 2019-06-27 9:07:01 0 [Note] InnoDB: Number of pools: 1\n 2019-06-27 9:07:01 0 [Note] InnoDB: Using SSE2 crc32 instructions\n 2019-06-27 9:07:01 0 [Note] InnoDB: Initializing buffer pool, total size = 16M, instances = 1, chunk size = 16M\n 2019-06-27 9:07:01 0 [Note] InnoDB: Completed initialization of buffer pool\n 2019-06-27 9:07:01 0 [Note] InnoDB: 128 out of 128 rollback segments are active.\n 2019-06-27 9:07:01 0 [Note] InnoDB: Creating shared tablespace for temporary tables\n 2019-06-27 9:07:01 0 [Note] InnoDB: Setting file 'C:\\xampp\\mysql\\data\\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...\n 2019-06-27 9:07:01 0 [Note] InnoDB: File 'C:\\xampp\\mysql\\data\\ibtmp1' size is now 12 MB.\n 2019-06-27 9:07:01 0 [Note] InnoDB: Waiting for purge to start\n 2019-06-27 9:07:02 0 [Note] InnoDB: 10.3.15 started; log sequence number 42861982; transaction id 184187\n 2019-06-27 9:07:02 0 [Note] InnoDB: Loading buffer pool(s) from C:\\xampp\\mysql\\data\\ib_buffer_pool\n 2019-06-27 9:07:02 0 [Note] Plugin 'FEEDBACK' is disabled.\n 2019-06-27 9:07:02 0 [Note] InnoDB: Buffer pool(s) load completed at 190627 9:07:02\n 2019-06-27 9:07:02 0 [Note] Server socket created on IP: '::'.\n \n```\n\n何卒よろしくお願いいたします。", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T07:56:53.020", "favorite_count": 0, "id": "56109", "last_activity_date": "2020-02-22T16:32:58.663", "last_edit_date": "2020-02-22T16:32:58.663", "last_editor_user_id": "3060", "owner_user_id": "9374", "post_type": "question", "score": 0, "tags": [ "mysql", "xampp", "ms-access", "odbc" ], "title": "AccessからMYSQL(MariaDB)に接続する方法", "view_count": 1323 }
[]
56109
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "***問題** \nBootstrapのnavでheaderにドロップダウンメニューを導入しているのですが、ドロップダウンが開く場合と開かない場合があり困っています。\n\nnavbarには現在ビューのあるリンクとしてHome画面とEdit画面(ドロップダウン内)へのリンクがあるのですが、それらのリンク先へ遷移した直後にドロップダウンメニューが動かなくなってしまいます。しかし、ブラウザで再読込(更新)するとドロップダウンメニューが動くようになります。\n\n***やったこと** \njsの問題かと思い調べてみたのですが、なかなか適切な資料も見つからず解決には至っていません。\n\n下記にコードを添付いたします。よろしくお願いいたします。\n\nroutes.rb\n\n```\n\n Rails.application.routes.draw do\n root 'static_pages#home'\n get '/help' => 'static_pages#help'\n get '/about' => 'static_pages#about'\n get '/contact' => 'static_pages#contact'\n get '/signup' => 'users#new'\n get '/login' => 'sessions#new'\n post '/login' => 'sessions#create'\n delete '/logout' => 'sessions#destroy'\n resources :users\n resources :account_activations, only: [:edit]\n resources :password_resets, only: [:new, :create, :edit, :update]\n end\n \n```\n\n_header.html.erb\n\n```\n\n <nav class=\"navbar navbar-fixed-top navbar-expand-lg navbar-dark bg-primary\">\n <div class=\"container\">\n <a href=\"/\" class=\"navbar-brand\">\n Body-Weight App\n </a>\n <ul class=\"navbar-nav\">\n <% if logged_in? %>\n <li><a href=\"/\" class=\"nav-link\">Home</a></li>\n <li><a href=\"#\" class=\"nav-link\">Help</a></li>\n <li class=\"dropdown\">\n <a href=\"#\" class=\"nav-link dropdown-toggle\" id=\"navbarDropdown\" role=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n Account<span class=\"caret\"></span>\n </a>\n <div class=\"dropdown-menu\" aria-labelledby=\"navbarDropdown\">\n <a href=\"/users/<%= current_user.id.to_s %>/edit\" class=\"dropdown-item\">Settings</a>\n <div class=\"dropdown-divider\"></div>\n <a class=\"dropdown-item\" rel=\"nofollow\" data-method=\"delete\" href=\"/logout\" >Log Out</a>\n </div>\n </li>\n <% else %>\n <li><a href=\"#\" class=\"nav-link\">Help</a></li>\n <% end %>\n </ul>\n \n```\n\n \n\n_head.html.erb\n\n```\n\n <head>\n <title><%= full_title(yield(:title)) %></title>\n <%= csrf_meta_tags %>\n \n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n <link rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css\" integrity=\"sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4\" crossorigin=\"anonymous\">\n \n <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>\n <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>\n </head>\n \n```\n\napplication.html.erb\n\n```\n\n <!DOCTYPE html>\n <html>\n <%= render \"layouts/head\"%>\n <body>\n <%= render \"layouts/header\" %>\n <div class=\"container\">\n <%= render \"layouts/flash\" %>\n <%= yield %>\n <%= render 'layouts/footer' %>\n </div>\n <script src=\"https://code.jquery.com/jquery-3.3.1.slim.min.js\" integrity=\"sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo\" crossorigin=\"anonymous\"></script>\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js\" integrity=\"sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1\" crossorigin=\"anonymous\"></script>\n <script src=\"https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js\" integrity=\"sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM\" crossorigin=\"anonymous\"></script>\n </body>\n </html>\n \n```\n\napplication.js\n\n```\n\n // This is a manifest file that'll be compiled into application.js, which will include all the files\n // listed below.\n //\n // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's\n // vendor/assets/javascripts directory can be referenced here using a relative path.\n //\n // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the\n // compiled file. JavaScript code in this file should be added after the last require_* statement.\n //\n // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details\n // about supported directives.\n //= require rails-ujs\n //= require turbolinks\n //= require_tree .\n //= require jquery3\n //= require popper\n //= require bootstrap-sprockets\n \n```\n\napplication.scss\n\n```\n\n /*\n * This is a manifest file that'll be compiled into application.css, which will include all the files\n * listed below.\n *\n * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's\n * vendor/assets/stylesheets directory can be referenced here using a relative path.\n *\n * You're free to add application-wide styles to this file and they'll appear at the bottom of the\n * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS\n * files in this directory. Styles in this file should be added after the last require_* statement.\n * It is generally better to create a new file per style scope.\n \n */\n @import 'bootstrap';\n \n \n \n $main-blue:#428bca;\n $light-gray:#777777;\n \n li{\n list-style: none;\n }\n \n \n .dropdown-item{\n color:$main-blue;\n }\n \n \n .footer{\n margin-top: 100px;\n border-top: 1px solid $main-blue;\n small{\n float:left;\n color:$main-blue;\n }\n ul{\n float:right;\n }\n li{\n float:left;\n margin-left: 15px;\n }\n a{\n color:$main-blue;\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T08:50:19.457", "favorite_count": 0, "id": "56111", "last_activity_date": "2019-06-26T21:17:50.937", "last_edit_date": "2019-06-26T21:17:50.937", "last_editor_user_id": "32986", "owner_user_id": "34872", "post_type": "question", "score": 0, "tags": [ "javascript", "ruby-on-rails", "bootstrap", "bootstrap4" ], "title": "Bootstrapのドロップダウンが開かないことがある", "view_count": 1577 }
[ { "body": "自己解決 \ngemですでに導入してるのにもかかわらずcdnでも導入してしまったのが原因でした。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T09:30:20.897", "id": "56113", "last_activity_date": "2019-06-26T09:30:20.897", "last_edit_date": null, "last_editor_user_id": null, "...
56111
null
56113
{ "accepted_answer_id": "56126", "answer_count": 1, "body": "python初級者です。 \npython 、plotlyでガントチャートを作成し、しばしば利用しています。 \nしかし、tooltipが柔軟でなく、工夫の余地がなさそうです。\n\nBokehはtooltipが柔軟で、表示させる内容は自由にカスタマイズできます。\n\nしかし、ガントチャートを作れるのかが分かりません。\n\nご指導よろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T12:28:50.667", "favorite_count": 0, "id": "56114", "last_activity_date": "2019-06-27T00:31:41.973", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34450", "post_type": "question", "score": 0, "tags": [ "python", "bokeh" ], "title": "Bokeh で ガントチャートを作ることはできるでしょうか?", "view_count": 1263 }
[ { "body": "出来ると言えば出来るでしょう。以下の記事の2つ目の回答が、Bokehでガントチャートを表示する内容になっています。 \nただし、表示内容はシンプルですね。 \n色々と付加情報表示にこだわるなら、それは別途ということでしょうか。 \n[How to plot stacked event duration (Gantt Charts) using Python\nPandas?](https://stackoverflow.com/q/31820578/9014308)\n\nこの回答の後で仕様変更になって、`bokeh.charts`はサポートされなくなったようですが、コメントアウトすれば動...
56114
56126
56126
{ "accepted_answer_id": null, "answer_count": 0, "body": "CakePHP2系で投稿機能で投稿した記事にコメントできる機能を実装しています。\n\nDB上ではCommentテーブルのPost_idカラムに投稿した記事のPostテーブル上のPost_idと同じ値が入るようにしたいです。また、PostとCommentの二つのモデルは`public\n$hasMany =\n\"Comment\";`でリレーションが作れています。現状はURLまでpost_idの値が反映されているのですが、コントローラー側で受け取ることができていない状態です。\n\n**ビューファイル**\n\n```\n\n <td> \n <?php echo $this->Html->link('Comment',array('controller'=>'comments',\n 'action'=>'comment', \n $post['Post']['id']))?>\n </td>\n \n```\n\n**コントローラー**\n\n```\n\n <?php\n class CommentsController extends AppController {\n public $helper = array('Html','Form');\n \n public function comment($post_id)\n {\n if ($this->request->is('post'))\n {\n $data=$this->request->data;\n $id=$this->request->params['post_id'];\n $data['Comment']['post_id']=$post_id;\n \n if ($this->Comment->save($data))\n {\n $this->Session->setFlash('Success!');\n return $this->redirect('/comments/comment/');\n //$this->Comment(array('controller' => 'comments', 'action' => 'view', $this->data['Comment']['id']));\n } else {\n $this->Session->setFlash('failed');\n }\n }\n }\n }\n ?>\n \n```", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T14:20:31.027", "favorite_count": 0, "id": "56116", "last_activity_date": "2019-06-27T04:05:52.393", "last_edit_date": "2019-06-27T04:05:52.393", "last_editor_user_id": "3060", "owner_user_id": "34463", "post_type": "question", "score": 0, "tags": [ "cakephp" ], "title": "CakePHP2系にてURLからコントローラーに引数を渡したい", "view_count": 258 }
[]
56116
null
null
{ "accepted_answer_id": "56119", "answer_count": 1, "body": "Spring Bootを勉強しようと始めたのですが、 \n「Springスタータプロジェクト」を作成して、実行した後、ブラウザからアクセスするとログイン認証が来てしまいます。ユーザ名とパスワードが分からず先に進めません。\n\n現象 \n「サーバlocalhostがユーザ名とパスワードを要求しています。サーバの報告によると、これはXDBからの要求です。」 \nこのメッセージが出て、ユーザ名とパスワードを求められてしまいます。127.0.0.1でも同じです。\n\n環境 \nspring-tool-suite-3.9.8 \nJDK12 \nWindows10 \nMicrosoft Edge\n\n実行 \nプロジェクトの実行で「SpringBootアプリケーション」で実行 \nURL:localhost:8080/", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T15:03:25.270", "favorite_count": 0, "id": "56117", "last_activity_date": "2019-06-27T12:53:22.537", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34875", "post_type": "question", "score": 0, "tags": [ "java", "spring-boot", "tomcat" ], "title": "Spring Boot 起動するとユーザ名とパスワードを求められる", "view_count": 1330 }
[ { "body": "XDBということは、そのマシンにOracle DBをインストールしていませんか?おそらく、Oracle\nDBと同時に入るアプリケーションサーバーが8080番ポートで既に起動していて、ログインを要求しているのではないかと思います。Spring\nBootはポート競合で起動していないかもしれませんね。なので、Oracleを停止してから、Spring Bootを起動してみて下さい。", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T15:29:19.753...
56117
56119
56119
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n arrays=[[7,5],[8,9,9,8],[13,13],[3,4,2,15,18],[3,2],[0,3,6,10,14,7],[7,10,9,11,14],\n [4,8,5,8,1,10],[5,11,21,2],[11,18,19,17]]\n =>\n [12, 34, 26, 42, 5, 40, 51, 36, 39, 65]\n \n```\n\nのような結果にしたいのですが、手順を教えてほしいです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T18:09:36.103", "favorite_count": 0, "id": "56121", "last_activity_date": "2019-06-27T23:08:18.947", "last_edit_date": "2019-06-27T00:04:29.890", "last_editor_user_id": "3060", "owner_user_id": "34878", "post_type": "question", "score": 0, "tags": [ "ruby" ], "title": "ruby 2次元配列内の計算方法", "view_count": 827 }
[ { "body": "[`Array#map` メソッド](https://ruby-doc.org/core-2.5.0/Array.html#method-i-\nmap)を用いて、各配列に対して [`Array#sum` メソッド](https://ruby-\ndoc.org/core-2.4.0/Array.html#method-i-sum)を実行すれば良いと思います。\n\n```\n\n arrays = [\n [7, 5],\n [8, 9, 9, 8],\n [13, 13],\n [3, 4, 2, 15, 18],\n [3, 2],\...
56121
null
56122
{ "accepted_answer_id": "56151", "answer_count": 2, "body": "Naudio.dllを使用して、ストリーミングでlan接続先の端末共有フォルダに置いてある音声ファイルを再生しています。 \nplay()メソッドを呼んだ時(音声ファイル再生中)にlanケーブルを抜くと、アプリが応答なしで固まってしまいます。 \n再生中に音声ファイルへのアクセスが出来なくなったことを検知する方法はありますでしょうか。\n\n・Naudio \n<https://github.com/naudio/NAudio>", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-26T22:54:18.290", "favorite_count": 0, "id": "56125", "last_activity_date": "2019-06-27T22:56:15.313", "last_edit_date": "2019-06-26T23:13:38.023", "last_editor_user_id": "32228", "owner_user_id": "32228", "post_type": "question", "score": 0, "tags": [ "c#", "audio-streaming" ], "title": "Naudio.dllによるリソースアクセスエラー検出方式が知りたい", "view_count": 520 }
[ { "body": "いずれも、@774RRさんコメントのように、タイムリに通知されるかどうか疑問がありますが、以下のような通知や監視方法が考えられます。\n\nNAudio.dll自身で言えば、`waveOut.Play()`メソッドで`PlaybackStopped`イベントが通知される可能性が考えられます。要因は`e.Exception`プロパティに入るでしょう。 \nあるいは`AudioFileReader`の`read`メソッドでExceptionが発生する可能性が考えられます。\n\n[再生の停止 - NAudio | C# プログラミング解説](https://so-\nzou.jp/software...
56125
56151
56151
{ "accepted_answer_id": "56284", "answer_count": 1, "body": "お世話になります。\n\nObjective-CでUICollectionViewを実装しています。 \nこのUICollectionViewは画面一杯に表示し、左右にスクロールするように実装しました。 \n(カレンダーを実装しているところです。)\n\nこの実装はiPhone5sやiPhone8では正常に描画されるのですが、iPhoneXだと、少し上にずれてしまい、NavigationBarにもぐりこんでしまいます。\n\nこのような事象に対する対応方法がわからず困っております。 \nお手数をお掛け致しますが、対応方法が御座いましたらご教示頂けますでしょうか。\n\n以下が、対象のUICollectionViewのソースコード(一部抜粋)となります。\n\n```\n\n #import \"Sample.h\"\n #import \"CalendarCell.h\"\n \n @interface Sample ()<UICollectionViewDataSource, UICollectionViewDelegate> {\n // カレンダーのViewを表示するコレクションView\n UICollectionView *coll;\n }\n \n @end\n \n @implementation Sample\n \n \n - (void)viewWillAppear:(BOOL)animated {\n [super viewWillAppear:animated];\n [self setUi];\n }\n \n - (void)setUi {\n UIView *view = [[UIView alloc] init];\n view.frame = CGRectMake(0, [UIApplication sharedApplication].statusBarFrame.size.height + self.navigationController.navigationBar.frame.size.height, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);\n [self.view addSubview:view];\n \n UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc] init];\n flowLayout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);\n [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];\n \n coll = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) collectionViewLayout:flowLayout];\n coll.backgroundColor = VIEW_BACK_COLOR;\n coll.pagingEnabled = true;\n [coll setShowsVerticalScrollIndicator:false];\n [coll setShowsHorizontalScrollIndicator:false];\n [view addSubview:coll];\n \n [coll registerClass:[CalendarCell class] forCellWithReuseIdentifier:@\"cell\"];\n \n coll.delegate = self;\n coll.dataSource = self;\n }\n \n #pragma mark - UICollectionViewDataSource and UICollectionViewDelegate\n \n -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {\n return 1;\n }\n \n -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section\n {\n return 12;\n }\n \n - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath\n {\n CalendarCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@\"cell\" forIndexPath:indexPath];\n return cell;\n }\n \n - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section\n {\n return 0.0f;\n }\n \n - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section\n {\n return 0.0f;\n }\n \n @end\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T02:11:15.743", "favorite_count": 0, "id": "56128", "last_activity_date": "2019-07-01T06:50:50.707", "last_edit_date": "2019-06-27T02:49:35.697", "last_editor_user_id": "33025", "owner_user_id": "33025", "post_type": "question", "score": 0, "tags": [ "ios", "objective-c", "uicollectionview", "uicollectionviewcell", "iphone-x" ], "title": "iPhoneXでUICollectionViewがずれてしまいます。", "view_count": 326 }
[ { "body": "みなさま、様々なご意見有難う御座いました! \n色々と試した結果、以下を追加することで潜り込まなくなりました!!\n\n```\n\n if (@available(iOS 11.0, *)) {\n coll.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-...
56128
56284
56284
{ "accepted_answer_id": null, "answer_count": 1, "body": "anacondaを用いてpython環境を扱っています。 \n一部ライブラリをダウングレードしようとshellにて以下のコマンドを入力したところ\n\n```\n\n conda list\n \n```\n\nエラーが発生しました。\n\nエラーメッセージは以下の通りです。\n\n```\n\n OSError: libiconv.so.2: cannot open shared object file: No such file or directory\n \n```\n\n解決策を模索しましたが、解決には至りません。 \n大変恐縮なのですが、解決方法がわかるかたがいましたら、ご教授いただきたいです。 \n\n* * *\n\n \n環境\n\n * python 3.6.8\n * Ubuntsu 16.04 LTS (Xenial Xerus)\n * anaconda 4.7.5", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T03:00:48.207", "favorite_count": 0, "id": "56129", "last_activity_date": "2019-10-16T05:44:56.933", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34881", "post_type": "question", "score": 0, "tags": [ "python", "python3", "linux", "ubuntu", "anaconda" ], "title": "condaコマンドにおけるOSerrorについて", "view_count": 156 }
[ { "body": "libiconvの共有オブジェクトが存在しないようなので、condaでlibiconvを入れたらどうでしょうか。\n\n```\n\n conda install -c conda-forge libiconv\n \n```\n\nRef: <https://stackoverflow.com/questions/41775441/chef-installing-uwsgi-\nlibiconv-so-2-no-such-file-or-directory>", "comment_count": 0, "content_license": "CC BY-SA 4.0...
56129
null
59738
{ "accepted_answer_id": null, "answer_count": 2, "body": "下記のような駅一覧のページでは、jQueryのtoggleClassでboxクラスをクリックするとonboxクラスの追加と削除を繰り返して箱の中に色が付くようになっています。こういったページで「東京と小田原の行の箱だけクリックされて色がついている」という各行の状態を配列にし、LocalStorageなどに保存すれば、リロードしたり次回以降にドキュメントを読み込んだりしたとしてもリセットされることなく前回と同じ状態にすることができるということはわかりました。\n\nしかし、肝心の配列の作成に行き詰ってます。 \n空の配列を作って、そこに「東京」や「品川」の行のbox要素がクリックされonboxが追加した時に配列にその行を情報を保存。再度box要素がクリックされonboxが削除されたときにその行の情報を削除する。というイメージなのですが、うまくいきません。 \n配列内にonboxのあるid要素を保存したり削除したりしたりする感じなのですが。hasClassでtrueとfalseを返したのものを配列に保存するなど迷走してます。\n\n* * *\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\" dir=\"ltr\">\n <head>\n <meta charset=\"utf-8\">\n <style>\n .box{\n margin:0 5px 0 0;\n padding: 10px 1px 10px 30px;\n width: 20px;\n height: 50px;\n border: 0.5px solid #000;\n display: inline;\n }\n \n .onbox{\n margin:0 5px 0 0;\n padding: 10px 1px 10px 30px;\n width: 20px;\n height: 50px;\n border: 0.5px solid #ccc;\n display: inline;\n background: #000;\n }\n </style>\n \n <title>東海道新幹線</title>\n </head>\n <body>\n <div class=\"wreppar\">\n <div class=\"head\">\n <h1>東海道新幹線</h1>\n </div>\n \n <h2>駅一覧</h2>\n <ul>\n <li><div id=\"st1\" class=\"box\"></div>東京</li>\n <li><div id=\"st2\" class=\"box\"></div>品川</li>\n <li><div class=\"box\"></div>新横浜</li>\n <li><div class=\"box\"></div>小田原</li>\n <li><div class=\"box\"></div>熱海</li>\n </ul>\n \n </div>\n </body>\n </html>\n \n```\n\n```\n\n $(function() {\n $('.box').on('click', function() {\n $(this).toggleClass('onbox');\n });\n });\n \n```\n\n配列を作成するコード:\n\n```\n\n $('.box').on('click', function() {\n let slc = [];\n \n let p = $('#st1').hasClass('onbox');\n if( p ) {\n slc.shift(p);\n slc.push(p);\n } else {\n slc.shift(p);\n slc.push(p);\n }\n \n let r = $('#st2').hasClass('onbox');\n if( r ) {\n slc.shift(r);\n slc.push(r);\n } else {\n slc.shift(r);\n slc.push(r);\n }\n });\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T04:06:17.690", "favorite_count": 0, "id": "56130", "last_activity_date": "2019-06-30T11:12:46.923", "last_edit_date": "2019-06-29T04:39:03.327", "last_editor_user_id": "32986", "owner_user_id": "34882", "post_type": "question", "score": 0, "tags": [ "javascript", "jquery" ], "title": "追加と削除を繰り返す配列について", "view_count": 272 }
[ { "body": "ひとつの方法として、カスタムデータ属性、もしくは `id` 属性を用いて、各要素に一意な id を割り振っておき、クリックされた要素の id を配列として\nlocalStorage に格納しておく方法があります。\n\nこのとき、 **`Storage` オブジェクトの key と value\nが文字列のみをサポートしている**ため、配列を文字列形式に変換する必要があることに注意しなければなりません[[1]](https://html.spec.whatwg.org/multipage/webstorage.html#the-\nstorage-interface)。\n\n> ### 11...
56130
null
56158
{ "accepted_answer_id": null, "answer_count": 0, "body": "一身上の都合によりArch系ディトリであるArchLabsのシステムを暗号化して使わざるをえなくなった者です.事の次第を書いていきます.\n\n## なぜ暗号化したのか\n\n完結にまとめますと,ラップトップを紛失した際や,万が一犯罪に巻き込まれてしまった時のために暗号化しました.もちろんプライバシー保護を強固なものにするという理由でもあります.\n\n## 本題\n\nシステムを暗号化したものの,何故かOSの読み込み(ログインではない)と同時に暗号化が自動で解除されてしまいます.本来であれば,システム起動時にパスフレーズを求められるはずですが,なぜかそれがありませんでした.調べてみてもよくわからず,どうもキーファイルを自動で読み込んでいるのではないか(暗号化する際に英語で\"キーファイルが...\"と出たので)と想像していますが,根本的な解決には至りませんでした.\n\n## 参考にしたサイト\n\n暗号化の方法は[こちら](http://u10e10.hatenablog.com/entry/dm-crypt-\nusage)の方法で暗号化しました,ただ暗号化方式はAESではなくCamelliaに変更し,システムのインストールとロケーション設定や領域のフォーマット・ディレクトリの割当には専用のインストーラーである`archlabs-\ninstaller`を使いました.\n\nなお,GRUBに暗号化パーティションを読み込ませる方法は上記のサイトを参考にしました.\n\n## まとめ\n\nまとまりのない文章になりましたが,伺いたいことをまとめると\n\n * システム起動時にパスフレーズを求めてくるように設定するにはどうすればよいのか?\n * どこをどのように変更すればよいのか?\n\nなるべく情報を絞り出してみましたが,これぐらいしか書けませんでした. \n不明な点等がございましたらコメントの方までお願いします.\n\n## 追記:設定ファイル等の諸設定\n\nGitHubに設定等をまとめたテキストをアップロードしようかと思いましたが,スタックオーバーフローの中で完結した方が得策かと存じ上げますので,こちらに設定等を書かせていただきます.\n\n## /etc/crypttab\n\n特に何も書かれていませんでしたが,念の為こちらに掲載させていただきます.\n\n```\n\n # Configuration for encrypted block devices.\n # See crypttab(5) for details.\n \n # NOTE: Do not list your root (/) partition here, it must be set up\n # beforehand by the initramfs (/etc/mkinitcpio.conf).\n \n # <name> <device> <password> <options>\n # home UUID=b8ad5c18-f445-495d-9095-c9ec4f9d2f37 /etc/mypassword1\n # data1 /dev/sda3 /etc/mypassword2\n # data2 /dev/sda5 /etc/cryptfs.key\n # swap /dev/sdx4 /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256\n # vol /dev/sdb7 none\n \n```\n\n## /etc/default/grub\n\n```\n\n # GRUB boot loader configuration\n \n GRUB_DEFAULT=0\n GRUB_TIMEOUT=5\n GRUB_DISTRIBUTOR=\"ArchLabs\"\n GRUB_CMDLINE_LINUX_DEFAULT=\"\"\n GRUB_CMDLINE_LINUX=\"cryptdevice=/dev/sda2:cryptroot\"\n \n # Preload both GPT and MBR modules so that they are not missed\n GRUB_PRELOAD_MODULES=\"part_gpt part_msdos\"\n \n # Uncomment to enable booting from LUKS encrypted devices\n GRUB_ENABLE_CRYPTODISK=y\n \n # Uncomment to enable Hidden Menu, and optionally hide the timeout count\n #GRUB_HIDDEN_TIMEOUT=5\n #GRUB_HIDDEN_TIMEOUT_QUIET=true\n \n # Uncomment to use basic console\n GRUB_TERMINAL_INPUT=console\n \n # Uncomment to disable graphical terminal\n #GRUB_TERMINAL_OUTPUT=console\n \n # The resolution used on graphical terminal\n # note that you can use only modes which your graphic card supports via VBE\n # you can see them in real GRUB with the command `vbeinfo'\n GRUB_GFXMODE=auto\n \n # Uncomment to allow the kernel use the same resolution used by grub\n GRUB_GFXPAYLOAD_LINUX=keep\n \n # Uncomment if you want GRUB to pass to the Linux kernel the old parameter\n # format \"root=/dev/xxx\" instead of \"root=/dev/disk/by-uuid/xxx\"\n #GRUB_DISABLE_LINUX_UUID=true\n \n # Uncomment to disable generation of recovery mode menu entries\n GRUB_DISABLE_RECOVERY=true\n \n # Uncomment and set to the desired menu colors. Used by normal and wallpaper\n # modes only. Entries specified as foreground/background.\n #GRUB_COLOR_NORMAL=\"light-blue/black\"\n #GRUB_COLOR_HIGHLIGHT=\"light-cyan/blue\"\n \n # Uncomment one of them for the gfx desired, a image background or a gfxtheme\n #GRUB_BACKGROUND=\"/path/to/wallpaper\"\n #GRUB_THEME=\"/path/to/gfxtheme\"\n \n # Uncomment to get a beep at GRUB start\n #GRUB_INIT_TUNE=\"480 440 1\"\n \n # Uncomment to make GRUB remember the last selection. This requires to\n # set 'GRUB_DEFAULT=saved' above.\n #GRUB_SAVEDEFAULT=\"true\"\n \n```\n\n## /etc/mkinitcpio.conf\n\nHOOKSの内容は[このページを参考にしました](http://u10e10.hatenablog.com/entry/dm-crypt-usage)\n\n```\n\n # vim:set ft=sh\n # MODULES\n # The following modules are loaded before any boot hooks are\n # run. Advanced users may wish to specify all system modules\n # in this array. For instance:\n # MODULES=(piix ide_disk reiserfs)\n MODULES=()\n \n # BINARIES\n # This setting includes any additional binaries a given user may\n # wish into the CPIO image. This is run last, so it may be used to\n # override the actual binaries included by a given hook\n # BINARIES are dependency parsed, so you may safely ignore libraries\n BINARIES=()\n \n # FILES\n # This setting is similar to BINARIES above, however, files are added\n # as-is and are not parsed in any way. This is useful for config files.\n FILES=(/crypto_keyfile.bin)\n \n # HOOKS\n # This is the most important setting in this file. The HOOKS control the\n # modules and scripts added to the image, and what happens at boot time.\n # Order is important, and it is recommended that you do not change the\n # order in which HOOKS are added. Run 'mkinitcpio -H <hook name>' for\n # help on a given hook.\n # 'base' is _required_ unless you know precisely what you are doing.\n # 'udev' is _required_ in order to automatically load modules\n # 'filesystems' is _required_ unless you specify your fs modules in MODULES\n # Examples:\n ## This setup specifies all modules in the MODULES setting above.\n ## No raid, lvm2, or encrypted root is needed.\n # HOOKS=(base)\n #\n ## This setup will autodetect all modules for your system and should\n ## work as a sane default\n # HOOKS=(base udev autodetect block encrypt filesystems shutdown)\n #\n ## This setup will generate a 'full' image which supports most systems.\n ## No autodetection is done.\n # HOOKS=(base udev block encrypt filesystems shutdown)\n #\n ## This setup assembles a pata mdadm array with an encrypted root FS.\n ## Note: See 'mkinitcpio -H mdadm' for more information on raid devices.\n # HOOKS=(base udev block mdadm encrypt filesystems)\n #\n ## This setup loads an lvm2 volume group on a usb device.\n # HOOKS=(base udev block lvm2 filesystems)\n #\n ## NOTE: If you have /usr on a separate partition, you MUST include the\n # usr, fsck and shutdown hooks.\n HOOKS=(base udev autodetect modconf keyboard keymap block encrypt filesystems fsck)\n # COMPRESSION\n # Use this to compress the initramfs image. By default, gzip compression\n # is used. Use 'cat' to create an uncompressed image.\n #COMPRESSION=\"gzip\"\n #COMPRESSION=\"bzip2\"\n #COMPRESSION=\"lzma\"\n #COMPRESSION=\"xz\"\n #COMPRESSION=\"lzop\"\n #COMPRESSION=\"lz4\"\n \n # COMPRESSION_OPTIONS\n # Additional options for the compressor\n #COMPRESSION_OPTIONS=()\n \n```", "comment_count": 7, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T05:10:39.700", "favorite_count": 0, "id": "56132", "last_activity_date": "2019-06-27T07:01:07.613", "last_edit_date": "2019-06-27T07:01:07.613", "last_editor_user_id": "30493", "owner_user_id": "30493", "post_type": "question", "score": 4, "tags": [ "linux", "encryption" ], "title": "システムを暗号化したArch系OSが自動で暗号化を解除してしまう問題について", "view_count": 177 }
[]
56132
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "iText\n2.1.7を利用して作成したサイトに、動的に作成したPDFを複数置いています。しかし、ユーザーの中には障害を持っているため、JAWSなどの画面リーダーを利用してPDFをレンダリングしているユーザーも数多くおられます。PDFへのタグ指定には`setTagged()`メソッドを利用しますが、PDFの一部の要素の順序が正しくありません。一部は`setTagged()`を呼び出した後、さらにごちゃごちゃになってしまいました! \nPDF/UAに関して読んだところ、問題解決に役立ちそうでした。ですが、PDF/UA文書の作成方法についての良いサンプルコードが見つかりませんでした。サンプルコードをご提供していただけますでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T05:14:36.957", "favorite_count": 0, "id": "56133", "last_activity_date": "2019-06-27T05:26:27.480", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30882", "post_type": "question", "score": 0, "tags": [ "java", "pdf" ], "title": "iTextでPDF/UA互換PDFを作成するにはどうしたらいいですか?", "view_count": 106 }
[ { "body": "PdfUAのサンプルコードをご覧ください。PDF/UA遵守するために必要なことが段階ごとに説明されています。2014年にiText\nSummitとJavaOneから類似サンプルコードを提示しました。[iText\nSummit動画チュートリアル](https://www.youtube.com/watch?v=9b-ikCV_z8A)をご覧ください。\n\n```\n\n public void manipulatePdf(String dest) throws IOException, XMPException {\n PdfDocument pdfDoc = new Pdf...
56133
null
56134
{ "accepted_answer_id": null, "answer_count": 1, "body": "初学者です。ターミナルでコマンドを入力した後、エンターを押すと\">\"のみが出てきて、何度エンターを押しても\">\"のみで改行されていきます。\n\nこれはどういった状態なのでしょうか。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T06:37:26.730", "favorite_count": 0, "id": "56136", "last_activity_date": "2020-08-10T06:55:10.250", "last_edit_date": "2020-08-10T06:55:10.250", "last_editor_user_id": "3060", "owner_user_id": "34887", "post_type": "question", "score": 0, "tags": [ "rubygems", "shell" ], "title": "ターミナルでコマンド入力後にエンターを押しても、繰り返し ”>\" のみが表示されてしまう", "view_count": 1510 }
[ { "body": "セカンダリプロンプトが表示されてると思います。 \nコマンド入力が完了しておらず 入力待ちの状態です。 \nCtrl-C (Ctrlを押しながらC)を押すことで 入力がキャンセルされて元の状態に戻ると思います。\n\nクォートを閉じ忘れると そういう状態になるので \n入力した コマンドに間違いがないか 確認してみてください\n\n例)\n\n```\n\n $ echo \"hello world ← クォートを閉じ忘れたままEnterを押した状態\n > ← クォートが閉じてないので 入力まちの状態\n >\n > \" ...
56136
null
56139
{ "accepted_answer_id": "56445", "answer_count": 3, "body": "kerasで全結合ニューラルネットの回帰モデルを組んでいます(入力は10次元で出力が1次元)。 \nまた, 損失関数には平均二乗誤差を用いています。\n\n誤差に対する入力の勾配(誤差をL, 入力をxとしたときの dL/dx)を知りたいのですが, kerasでそれを実現できるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T06:42:25.727", "favorite_count": 0, "id": "56137", "last_activity_date": "2020-06-10T06:44:08.357", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34886", "post_type": "question", "score": 1, "tags": [ "python", "keras" ], "title": "kerasで入力に対する勾配を得るにはどうすればよいですか?", "view_count": 2815 }
[ { "body": "同様の質問は以下かと思います。 \n<https://stackoverflow.com/questions/53649837/how-to-compute-loss-gradient-w-\nr-t-to-model-inputs-in-a-keras-model>\n\nこれによると backend functions を使えというようなことが記載されていました。 \nbackend functions については以下に記載がありました。\n\n<https://keras.io/backend/#using-the-abstract-keras-backend-to-write-new...
56137
56445
56445
{ "accepted_answer_id": "56469", "answer_count": 1, "body": "JavaEEで開発したアプリケーションで、デッドロックが大量に発生しました。 \nSQLServerのsystem_healthを見てみると、あるテーブルXに対するDELETEのトランザクション同士によるデッドロックです。\n\nsystem_healthからこの画像が見れるのですが、これの読み取り方を教えてください。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/KPVu0.png)](https://i.stack.imgur.com/KPVu0.png)\n\n黒塗りで消してある部分は \nObject name:「テーブルX」 \nIndex name:「テーブルXのインデックスY」 \nです。 \n「キーロック」の枠が2つありますが、どちらも同じ内容でした。\n\n## 以下の解釈は正しいですか?\n\n### 1\\. 獲得済みロックとロック要求の解釈\n\n * プロセスID367 が、ロック対象Bの更新ロックを獲得済み(Owner Mode: U)\n * プロセスID391 が、ロック対象Aの排他ロックを獲得済み(Owner Mode: X)\n\nという状況において、 \nお互いに逆のロック対象に対する更新ロックを要求(Request Mode: U)して、デッドロックを引き起こしている。\n\n### 2\\. ロック対象の解釈\n\nロック対象A、Bはともに、インデックスY全体に対するロックである。 \nつまり、AとBは同じものであり、同一の対象でデッドロックが発生している。\n\n## 正しいとした場合の疑問\n\n### 同一対象への更新ロックは競合するのでは?\n\n[この解説](https://docs.microsoft.com/ja-jp/sql/2014-toc/sql-server-transaction-\nlocking-and-row-versioning-guide?view=sql-server-2014#lock-\ncompatibility)によると、更新ロックは共有ロックとしか互換性がなく、同一対象に2つの更新ロックは持てないはずです。 \n従って、私の解釈の2と矛盾します。\n\n恐らく解釈が間違っていると思うのですが・・・ \nどなたか、正しい解釈を教えていただけないでしょうか。 \n※最終的には原因究明と回避策を検討しますが、まずはこのsystem_healthの情報を正しく解釈したいという主旨の質問です。\n\n## 環境の情報\n\n * SQLServerのバージョンは2017\n * トランザクション分離レベルは READ COMMITTED \n * Is Read Committed Snapshot On = False\n * スナップショット分離を許可 = False\n\n## 追加情報\n\n * テーブルXにトリガーはありません\n * [Understanding the graphical representation of the SQL Server Deadlock Graph](https://www.sqlshack.com/understanding-graphical-representation-sql-server-deadlock-graph/) \nグラフの読み方はこれを見て理解したつもりです。英語が苦手なので解釈に自信が無いのですが・・・\n\n> Owner edge\n>\n> Occurs when resources are waiting on processes. In this case the\n> Person.person table is waiting on process 62 to release it.\n\nテーブル「Person.person」はプロセス62がロックを解放するのを待っている=プロセス62がテーブル「Person.person」のロックを持っている、ですよね?\n\n * SQL発行時にヒントは含めていません。 \n * ロック対象を指定していないです。", "comment_count": 10, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T06:44:33.270", "favorite_count": 0, "id": "56138", "last_activity_date": "2019-07-07T06:27:45.027", "last_edit_date": "2019-06-30T23:36:45.293", "last_editor_user_id": "8078", "owner_user_id": "8078", "post_type": "question", "score": 2, "tags": [ "sql-server" ], "title": "SQLServerのデッドロックグラフの読み方", "view_count": 3630 }
[ { "body": "ちょっと試してみた範囲では、Request Mode: Xでデッドロックしましたが、ほぼ同じ現象を出せました\n\n解釈の間違ってる点ですが\n\n> ロック対象A、Bはともに、インデックスY全体に対するロックである。\n\nインデックス全体に対するロックではなく、インデックスのキー範囲に対するロックです \nなので対象インデックスが同じでも、違うキーに対するロックは複数が同時に存在しえます\n\n対策案は、 \n同一キーに対する削除があるなら、nowait指定で削除でのロック待ちをなくすぐらいですかね \nこちらはデッドロックではなくロックタイムアウトでエラーはでるので適切なハンドリング...
56138
56469
56469
{ "accepted_answer_id": "56145", "answer_count": 1, "body": "<http://a-records.info/upgrade-centos69-to-centos-73/>\n\nこちらの記事を参考に、CentOS6をCentOS7にアップグレードしました。 \nアップグレード自体は完了したのですが、その後yum\nupdateをしようとしたところ、el6関連のパッケージが残っていてエラーになりました。これらのほとんどはyum\nremove等で解消できたのですが、最後に下記のエラーが残って解消できず、 yum update が実行できません。\n\n> Transaction check error: \n> file /usr/lib64/libnsspem.so from install of nss-pem-1.0.3-5.el7_6.1.x86_64\n> conflicts with file from package nss-3.36.0-9.el6_10.x86_64\n\n「el6」というのがあったので yum remove しようとしたのですが、\n\n> エラー: \"systemd\" を削除しようとしています、保護されています \n> エラー: \"yum\" を削除しようとしています、保護されています\n\nと表示され、削除できませんでした。 \nならばと yum install nss とやってみたのですが、\n\n> 一致したパッケージ nss-3.36.0-7.1.el7_6.x86_64 はすでにインストールされています。更新を確認しています。 \n> 何もしません\n\nとなってしまいます。\n\nインストールされていますと書かれてはいますが、 yum list installed や rpm -qi\n等で調べてみてもel7のものは存在せず、el6のものしかインストールされていないようです。\n\nちなみに yum update nss とやってみましたら、\n\n> No packages marked for update\n\nとなり、こちらでも解決できませんでした。\n\nアップグレードツールのせいかもしれませんが、このようなインストール済みパッケージのバージョンが誤認されるケースは通常起こり得るのでしょうか。 \nまた、今回遭遇しているこのエラーを解消する方法はあるのでしょうか。\n\nCentOS7をクリーンインストールした方が良いとも思うのですが、事情がありクリーンインストールではなくアップグレードを完遂させたいと考えております。 \n何卒皆様のお力添えを頂きたく存じます。 \nよろしくお願いいたします。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T09:55:45.770", "favorite_count": 0, "id": "56140", "last_activity_date": "2019-06-27T12:31:46.900", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14346", "post_type": "question", "score": 1, "tags": [ "centos", "yum" ], "title": "CentOS6をCentOS7にアップグレード後、yum updateでTransaction check error (nss-pemとnssのconflicts)", "view_count": 1210 }
[ { "body": "CentOS 7 の nss-3.36.0-7.1.el7_6.x86_64 より CentOS 6 の\nnss-3.36.0-9.el6_10.x86_64 の方がバージョン・リリース番号が新しいため、yum でアップデートできないようです。\n\nnss-3.36.0-7.1.el7_6.x86_64.rpm ファイルをダウンロードして、 \n`rpm -Uvh --oldpackage nss-3.36.0-7.1.el7_6.x86_64.rpm` または `rpm -Uvh --force\nnss-3.36.0-7.1.el7_6.x86_64.rpm` で nss を置き換えら...
56140
56145
56145
{ "accepted_answer_id": null, "answer_count": 3, "body": "Rubyでは3から6の値を持った配列を作るには以下のようにできます。\n\n```\n\n irb(main):001:0> [*3..6]\n => [3, 4, 5, 6]\n \n```\n\nこれをJSで実現するにはどうしたらいいのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T11:01:26.680", "favorite_count": 0, "id": "56141", "last_activity_date": "2019-12-11T05:03:00.477", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32878", "post_type": "question", "score": 3, "tags": [ "javascript" ], "title": "JavaScriptで特定の範囲の数値の配列を作りたい", "view_count": 5092 }
[ { "body": "あまり得意ではないですが、回答がないようですので回答致します。 \nRubyのように連番を表現する方法はないようです。 \n以下で実現が可能でした。\n\n```\n\n start = 3\n end = 6\n new Array(end - start + 1).fill(null).map((_, i) => i + start)\n // [3, 4, 5, 6]\n \n```\n\n以下が参考になりましたので記載しておきます。 \n<https://qiita.com/Nossa/items/e420c15175d87cec079e>", ...
56141
null
56176
{ "accepted_answer_id": "56159", "answer_count": 3, "body": "単一始点最短経路問題で負の閉路がある場合、アルゴリズムとしてベルマンフォード法が適用され、負の閉路がない場合、ダイクストラ法が適用されますが、閉路でなくても辺の重みが負数の場合ダイクストラ法の出力が正しくない原因は何でしょうか。\n\n以下のダイクストラ法の参考コードを辺の重みが非負数の場合と負数を含む場合で実行したところ、出力が変わりましたが、その理由がわかりません。\n\n閉路でなくても、辺の重みが負数だとなぜダイクストラ法では、出力が正しく求められないのでしょうか。\n\n[ダイクストラ法の参考コード](https://engineeringnote.hateblo.jp/entry/python/algorithm-and-\ndata-structures/dijkstra) \n出力(辺のコストが非負の場合)\n\n```\n\n $ python dijkstra.py\n visited to A.\n visited to B.\n visited to C.\n visited to D.\n visited to E.\n visited to F.\n minimal cost is 9.\n optimum route is 'A->B->D->E->F'.\n \n```\n\n辺のコストが非負の場合\n\n```\n\n route = [\n [INF, 2, 3, INF, INF, INF],\n [2, INF, 4, 3, 5, INF],\n [3, 4, INF, 6, 4, INF],\n [INF, 3, 6, INF, 1, 5],\n [INF, 5, 4, 1, INF, 3],\n [INF, INF, INF, 5, 3, INF]]\n \n```\n\n出力(辺のコストに負数を含む場合)\n\n```\n\n $ python dijkstra.py\n visited to A.\n visited to B.\n visited to E.\n visited to D.\n visited to F.\n visited to C.\n #printなし、プログラムが終了しない\n \n```\n\n辺のコストに負数を含む場合\n\n```\n\n route = [\n [INF, 2, 3, INF, INF, INF],\n [2, INF, 4, 3, -5, INF],\n [3, 4, INF, 6, 4, INF],\n [INF, 3, 6, INF, 1, 5],\n [INF, 5, 4, 1, INF, 3],\n [INF, INF, INF, 5, 3, INF]]\n \n```\n\n実行したプログラム(上記URLより引用)\n\n```\n\n # dijkstra.py\n import sys\n \n INF = 10000\n VISITED = 1\n NOT_VISITED = 0\n \n route = [\n [INF, 2, 3, INF, INF, INF],\n [2, INF, 4, 3, 5, INF],\n [3, 4, INF, 6, 4, INF],\n [INF, 3, 6, INF, 1, 5],\n [INF, 5, 4, 1, INF, 3],\n [INF, INF, INF, 5, 3, INF]]\n \n size = len(route)\n cost = [INF for _ in range(size)]\n visit = [NOT_VISITED for _ in range(size)]\n before = [None for _ in range(size)]\n cost[0] = 0\n while True:\n min = INF\n for i in range(size):\n if visit[i] == NOT_VISITED and cost[i] < min:\n x = i\n min = cost[x]\n if min == INF:\n break\n visit[x] = VISITED\n print(\"visited to {}.\".format(chr(65+x)))\n \n for i in range(size):\n if cost[i] > route[x][i] + cost[x]:\n cost[i] = route[x][i] + cost[x]\n before[i] = x\n \n if cost[size-1] == INF:\n print(\"could not find optimum route.\")\n sys.exit(1)\n \n i = size - 1\n optimum_route = []\n while True:\n optimum_route.insert(0, chr(65+i))\n if i == 0:\n break\n i = before[i]\n \n print(\"minimal cost is {}.\".format(cost[size-1]))\n print(\"optimum route is '\", end=\"\")\n for i in range(len(optimum_route)):\n print(optimum_route[i], end=\"\")\n if i == len(optimum_route) -1:\n print(\"'.\")\n break\n print(\"->\", end=\"\")\n \n```\n\n**回答を受けてやったこと** \n負の辺がある場合のテストケースを実行した結果を求めました。 \nしかし、ダイクストラ法は閉路がなくて出力は求められても、辺の重みが負数だとなぜダイクストラ法では、出力が正しく求められないのかまだ理解できていません。\n\n```\n\n #負の辺があって閉路ではないケース\n route = [\n [INF, 5, 3, INF, 3, INF],\n [2, INF, 4, 3, -3, INF],\n [3, 4, INF, 6, 4, INF],\n [INF, 3, 6, INF, 1, 5],\n [INF, 5, 4, 1, INF, 3],\n [INF, INF, INF, 5, 3, INF]]\n \n \n #結果\n $ python dijkstra.py\n visited to A.\n visited to C.\n visited to E.\n visited to D.\n visited to B.\n visited to F.\n minimal cost is 6.\n optimum route is 'A->B->E->F'.\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T12:00:35.930", "favorite_count": 0, "id": "56143", "last_activity_date": "2019-06-28T09:45:26.830", "last_edit_date": "2019-06-28T05:41:19.220", "last_editor_user_id": "32568", "owner_user_id": "32568", "post_type": "question", "score": 0, "tags": [ "python", "python3", "アルゴリズム" ], "title": "ダイクストラ法における辺の重みの正負における出力のちがいについて", "view_count": 1595 }
[ { "body": "自分の理解ですと、負の閉路がある時点でそれは最短経路問題としては解けないことになります。(ぐるぐるまわると、無限に負の重みを稼げるから)\n\n2度と同じ枝ないし頂点を通らないとした場合であっても、それは多分 NP 困難な問題になりそうだと思ってます。(要検証)\n\n負の閉路がない、負の重みを持つ枝があるグラフ上で最短経路を求めるのがベルマンフォードで、負の重みがないグラフ上での最短経路を求めるのがダイクストラだという理解です。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date...
56143
56159
56159
{ "accepted_answer_id": "56153", "answer_count": 2, "body": "```\n\n class Hoge<T: Equatable>: Equatable {\n let e: T\n \n init(e: T) {\n self.e = e\n }\n \n static func == (lhs: Hoge<T>, rhs: Hoge<T>) -> Bool {\n return lhs.e == rhs.e\n }\n }\n \n class HogeA: Hoge<Int> {}\n class HogeB: Hoge<String> {}\n \n class Foo<T: Equatable, U: Hoge<T>>: Equatable {\n var ee: U\n \n init(ee: U) {\n self.ee = ee\n }\n \n static func == (lhs: Foo<T, U>, rhs: Foo<T, U>) -> Bool {\n return lhs.ee == rhs.ee\n }\n }\n \n class FooA: Foo<Int, HogeA> {}\n class FooB: Foo<String, HogeB> {}\n \n let fooA1 = FooA(ee: HogeA(e: 1))\n let fooA2 = FooA(ee: HogeA(e: 2))\n \n let fooB1 = FooB(ee: HogeB(e: \"あ\"))\n let fooB2 = FooB(ee: HogeB(e: \"あ\"))\n \n print(fooA1 == fooA2)\n print(fooB1 == fooB2)\n \n```\n\n上記のコードにおいて\n\n```\n\n class Foo<T: Equatable, U: Hoge<T>>: Equatable {\n ...\n }\n \n class FooA: Foo<Int, HogeA> {}\n class FooB: Foo<String, HogeB> {}\n \n```\n\nの部分が、特殊化の引数を2つ取って冗長です。\n\n本当は\n\n```\n\n class Foo<U: Hoge<T: Equatable>>: Equatable { // 文法エラー\n ...\n }\n \n class FooA: Foo<HogeA> {}\n class FooB: Foo<HogeB> {}\n \n```\n\nとしたいのですが、Fooの定義をうまく書けません(文法エラー)。 \nなにかうまい書き方はSwiftに用意されていますか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T12:39:06.210", "favorite_count": 0, "id": "56146", "last_activity_date": "2019-06-29T08:46:33.243", "last_edit_date": "2019-06-29T08:46:33.243", "last_editor_user_id": "9008", "owner_user_id": "9008", "post_type": "question", "score": 0, "tags": [ "swift", "ジェネリクス" ], "title": "クラスのジェネリクスの特殊化の冗長な書き方をなくしたい", "view_count": 282 }
[ { "body": "ではこうですかね?\n\n```\n\n protocol HogeProtocol: Equatable {\n \n associatedtype Value\n }\n \n class Hoge<T: Equatable>: HogeProtocol {\n \n typealias Value = T\n \n let e: T\n \n init(e: T) {\n self.e = e\n }\n \n static fun...
56146
56153
56152
{ "accepted_answer_id": "56171", "answer_count": 2, "body": "**自作したカスタムセルを自分の画面に表示したいのですが表示されなのは何故なのでしょうか。**\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/6mhOl.png)](https://i.stack.imgur.com/6mhOl.png) \n[![画像の説明をここに入力](https://i.stack.imgur.com/UGXX6.png)](https://i.stack.imgur.com/UGXX6.png) \n[![画像の説明をここに入力](https://i.stack.imgur.com/JxZ5C.png)](https://i.stack.imgur.com/JxZ5C.png)\n\n```\n\n class TableViewSkillController: UIViewController, UITableViewDelegate, UITableViewDataSource {\n \n \n @IBOutlet weak var myTableView: UITableView!\n @IBOutlet weak var addSkill: UIBarButtonItem!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n self.myTableView.register(UINib(nibName: \"TableViewCell\", bundle: nil), forCellReuseIdentifier: \"TableViewCell\")\n \n }\n \n func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n return 1\n }\n \n func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n \n let cell = tableView.dequeueReusableCell(withIdentifier: \"TableViewCell\") as! TableViewCell\n \n cell.skillName.text = \"〇〇〇〇〇〇\"\n cell.goalCountNumber.text = \"20 : 00\"\n \n return cell\n }\n \n @IBAction func addSkillButton(_ sender: UIBarButtonItem) {\n }\n \n \n }\n \n \n```\n\n```\n\n import UIKit\n \n class TableViewCell: UITableViewCell {\n \n @IBOutlet weak var skillName: UILabel!\n @IBOutlet weak var goalCountNumber: UILabel!\n \n \n override func awakeFromNib() {\n super.awakeFromNib()\n // Initialization code\n }\n \n \n \n \n @IBAction func ToEachSkillButton(_ sender: Any) {\n \n \n }\n \n \n }\n \n```\n\n↑↑これからコードの中身を入れるつもりです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T12:43:40.230", "favorite_count": 0, "id": "56147", "last_activity_date": "2019-06-28T03:44:33.663", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34541", "post_type": "question", "score": 0, "tags": [ "swift", "xcode" ], "title": "tableViewにカスタムセルを表示したい。", "view_count": 450 }
[ { "body": "`TableViewSkillController`クラスの中、\n\n```\n\n func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n \n let cell = tableView.dequeueReusableCell(withIdentifier: \"TableViewCell\") as! TableViewCell\n \n cell.skillName.text = \"〇〇〇〇〇〇\"\n ...
56147
56171
56162
{ "accepted_answer_id": null, "answer_count": 0, "body": "任意の数字を入力して、以下の条件で値を判別するプログラムを作っています。\n\n * 偶数で100以上\n * 偶数で100未満\n * 奇数で99未満\n * それ以外\n\nしかし、何を入れても`a`は「偶数かつ100以上」になります。なぜでしょうか。\n\n```\n\n #include <stdio.h>\n \n int main() {\n int a;\n scanf(\"%d\", &a);\n \n if (a % 2 == 0 && a >= 100) {\n printf(\"aは偶数かつ100以上\");\n }\n else if (a % 2 == 0 && a < 100) {\n printf(\"aは偶数かつ100未満\");\n }\n else if (a % 2 == 1 && a >= 99) {\n printf(\"aは奇数かつ99以上\");\n }\n else {\n printf(\"それ以外\");\n }\n }\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T14:04:29.213", "favorite_count": 0, "id": "56149", "last_activity_date": "2019-06-28T01:30:42.003", "last_edit_date": "2019-06-28T01:30:42.003", "last_editor_user_id": "3060", "owner_user_id": "34892", "post_type": "question", "score": 0, "tags": [ "c" ], "title": "if-elseを用いた数値の判別が、意図した通り動かない", "view_count": 208 }
[]
56149
null
null
{ "accepted_answer_id": "56194", "answer_count": 1, "body": "Vue.jsのコンポーネントの単体テスト(Vue Test\nUtils)で、テストしているコンポーネントから子コンポーネントに、想定通りのpropsが渡っているかテストしたいのですが、どのように書けばいいでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T14:13:33.023", "favorite_count": 0, "id": "56150", "last_activity_date": "2019-06-28T13:40:50.130", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13492", "post_type": "question", "score": 1, "tags": [ "vue.js", "テスト" ], "title": "Vue.jsの子コンポーネントのpropsのテスト", "view_count": 516 }
[ { "body": "`@vue/test-utils`のmount (もしくはshallowMount)\nメソッドを用いてコンポーネントをマウントした場合、`wrapper.find(Child).props(\"prop\")`のようにして子コンポーネントに渡されたpropsを取得することができます。\n\nテスト全体は以下のようになるでしょう。\n\n```\n\n import { mount } from \"@vue/test-utils\";\n import App from \"./App.vue\";\n import Child from \"./components/Chi...
56150
56194
56194
{ "accepted_answer_id": "56203", "answer_count": 1, "body": "現在、Docker上でruby:2.5.5-slim-\nstretchのイメージを使って、既存のRails5アプリの開発環境を構築しているのですが、`rails\nc`を実行した所、フリーズしてしまい、ctrl+cすら受け付けません。 \nまた何度イメージを作り直しても同じ現象が発生し、コンソール上にログなどを吐かずにフリーズするだけなので、エラーの原因も特定出来ずに困っています。\n\nどの様にすればこの問題を解決できるでしょうか?ご回答いただけると助かります。\n\n以下に試した事を書かせていただきます。\n\n「rails フリーズ」などで検索するとspringに関する記事が上がったので`DISABLE_SPRING=1 rails\nc`を試してみましたが、同じくフリーズしました。ただしCtrl+Cは受け付けました。 \nその際のログは以下の通りです。\n\n```\n\n DISABLE_SPRING=1 rails c\n \n ^CTraceback (most recent call last):\n 36: from bin/rails:9:in `<main>'\n 35: from bin/rails:9:in `require'\n 34: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'\n 33: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command.rb:44:in `invoke'\n 32: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command/base.rb:63:in `perform'\n 31: from /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'\n 30: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'\n 29: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'\n 28: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/commands/console/console_command.rb:96:in `perform'\n 27: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command/actions.rb:15:in `require_application_and_environment!'\n 26: from /usr/local/bundle/gems/railties-5.1.7/lib/rails/command/actions.rb:15:in `require'\n 25: from /home/hoge/config/application.rb:7:in `<top (required)>'\n 24: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:114:in `require'\n 23: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `require'\n 22: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `each'\n 21: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `block in require'\n 20: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `each'\n 19: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in `block (2 levels) in require'\n 18: from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in `require'\n 17: from /usr/local/bundle/gems/config-1.7.2/lib/config.rb:9:in `<top (required)>'\n 16: from /usr/local/bundle/gems/config-1.7.2/lib/config.rb:9:in `require'\n 15: from /usr/local/bundle/gems/config-1.7.2/lib/config/validation/schema.rb:1:in `<top (required)>'\n 14: from /usr/local/bundle/gems/config-1.7.2/lib/config/validation/schema.rb:1:in `require'\n 13: from /usr/local/bundle/gems/dry-validation-0.13.3/lib/dry-validation.rb:1:in `<top (required)>'\n 12: from /usr/local/bundle/gems/dry-validation-0.13.3/lib/dry-validation.rb:1:in `require'\n 11: from /usr/local/bundle/gems/dry-validation-0.13.3/lib/dry/validation.rb:39:in `<top (required)>'\n 10: from /usr/local/bundle/gems/dry-validation-0.13.3/lib/dry/validation.rb:39:in `require'\n 9: from /usr/local/bundle/gems/dry-validation-0.13.3/lib/dry/validation/schema.rb:2:in `<top (required)>'\n 8: from /usr/local/bundle/gems/dry-validation-0.13.3/lib/dry/validation/schema.rb:2:in `require'\n 7: from /usr/local/bundle/gems/dry-types-0.14.1/lib/dry/types/constraints.rb:1:in `<top (required)>'\n 6: from /usr/local/bundle/gems/dry-types-0.14.1/lib/dry/types/constraints.rb:1:in `require'\n 5: from /usr/local/bundle/gems/dry-logic-0.6.1/lib/dry/logic/rule_compiler.rb:3:in `<top (required)>'\n 4: from /usr/local/bundle/gems/dry-logic-0.6.1/lib/dry/logic/rule_compiler.rb:3:in `require'\n 3: from /usr/local/bundle/gems/dry-logic-0.6.1/lib/dry/logic/rule.rb:4:in `<top (required)>'\n 2: from /usr/local/bundle/gems/dry-logic-0.6.1/lib/dry/logic/rule.rb:4:in `require'\n 1: from /usr/local/bundle/gems/dry-logic-0.6.1/lib/dry/logic/operations.rb:9:in `<top (required)>'\n /usr/local/bundle/gems/dry-logic-0.6.1/lib/dry/logic/operations.rb:9:in `require': Interrupt\n \n```\n\nまた`rails c`時のフリーズ状態で`ps aux`を実行した際の出力を書かせていただきます。\n\n```\n\n root 1 0.0 0.0 52060 188 pts/0 Ssl+ 17:01 0:00 irb\n root 7 0.0 0.0 19948 224 pts/1 Ss 17:01 0:00 /bin/bash\n root 15 0.0 0.0 19952 232 pts/2 Ss 17:02 0:00 /bin/bash\n root 98 0.1 0.4 70268 9516 pts/1 Sl+ 17:43 0:00 /usr/local/bin/ruby bin/rails c\n root 101 0.2 0.6 344256 13292 pts/1 Sl 17:43 0:00 spring server | hoge | started 2 mins ago\n root 104 18.2 1.6 420792 34064 ? Rsl 17:43 0:30 spring app | hoge | started 2 mins ago | development mode\n root 117 12.6 0.5 71948 11292 pts/2 Rl 17:45 0:06 ruby /usr/local/bundle/gems/spring-2.1.0/bin/spring server --background\n root 119 23.5 0.0 38380 360 pts/2 R+ 17:46 0:00 ps aux\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T18:15:07.167", "favorite_count": 0, "id": "56156", "last_activity_date": "2019-06-28T18:11:57.810", "last_edit_date": "2019-06-28T01:11:32.443", "last_editor_user_id": "3060", "owner_user_id": "15186", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "docker" ], "title": "rails cがフリーズする", "view_count": 414 }
[ { "body": "すみません、自己解決しました。 \ndocker-composeが異常に重いのが原因でした。 \nお騒がせいたしました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T18:11:57.810", "id": "56203", "last_activity_date": "2019-06-28T18:11:57.810", "last_edit_date": null, "last_editor_user_id"...
56156
56203
56203
{ "accepted_answer_id": "56160", "answer_count": 1, "body": "`uint8(x ^ y)`\n\n`^` これは、\n\n> ^ bitwise XOR integers\n\nという文法のようですが、\n\nどのようなときに使われるのかがわかりません。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-27T18:21:13.040", "favorite_count": 0, "id": "56157", "last_activity_date": "2019-06-27T22:23:57.453", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12896", "post_type": "question", "score": 0, "tags": [ "go" ], "title": "uint8(x ^ y) がわからない", "view_count": 112 }
[ { "body": "`uint8( )` の部分は明示的型変換というものなので、これは除外して考えてよいです。\n\n`^` は書いてある通り「ビットごとの排他的論理和」というもので、次の演算となります。\n\n```\n\n bit3210\n x 0011\n y 0101\n ----------\n xor 0110\n \n```\n\n2つの値を2進数で表記したときの各ビットが \n\\- 一致 (0,0) または (1,1) のとき、結果 0 \n\\- 不一致 (0,1) または (1,0) のとき、結果 1 \nを得ます(これを各ビットご...
56157
56160
56160
{ "accepted_answer_id": "56165", "answer_count": 1, "body": "Wordpressの構築をやっています。 \n文字を置換する際の正規表現の読み方がわかりません。 \n理解しようとネットで調べて書いてることはなんとなく分かるのですが、コードに向き合うとわかりません。というか読めません、読めないので意味がわかりません。 \n特に「/」と「\\」の組み合わせがわかりません。 \n正規表現に書いてることを話し言葉で解説していただけないでしょうか。\n\n```\n\n $html = preg_replace('/(width|height)=\"\\d*\"\\s/', '', $html); \n $html = preg_replace('/class=[\\'\"]([^\\'\"]+)[\\'\"]/i', '', $html); \n $html = preg_replace('/title=[\\'\"]([^\\'\"]+)[\\'\"]/i', '', $html); \n $html = preg_replace('/<a href=\".+\">/', '', $html); \n $html = preg_replace('/<\\/a>/', '', $html); \n \n```\n\n以上、よろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T00:58:42.930", "favorite_count": 0, "id": "56163", "last_activity_date": "2019-06-28T01:59:20.993", "last_edit_date": "2019-06-28T01:26:21.563", "last_editor_user_id": "34895", "owner_user_id": "34895", "post_type": "question", "score": 1, "tags": [ "php", "正規表現", "wordpress" ], "title": "正規表現の読み方がわかりません", "view_count": 312 }
[ { "body": "質問に記載のコードは`preg_replace`でヒットした文字列を全て削除しています。 \n(正確には`''`の空文字で置換している状態) \nHTMLのタグの中で指定した属性や、Aタグを削除したいんですかね。\n\n* * *\n```\n\n $html = preg_replace('/(width|height)=\"\\d*\"\\s/', '', $html); \n \n```\n\n`(width|height)` \n\"()\"でグループ化し、\"width\"もしくは、\"height\"を選択します。 \n`=\"\\d*\"` \n「`=\"\"...
56163
56165
56165
{ "accepted_answer_id": null, "answer_count": 1, "body": "SPRESENSEのリリースバージョン1.3.0を利用しているのですがgnss_atcmdを動かして暫く置いてみてもQZQSMだけ受信できていないようです。@BSSLは0x40efに、@GNSは0x29に設定しました。このexamples/gnss_atcmdを動かしてQZQSMを取得するために必要な手順が何かあるでしょうか。デベロッパーガイドの11.6.6Short\nmessage deliveryの設定が具体的にどのようなものなのか理解できず何がおかしいのかわからない状況です。 \n何かしらの手順があればお教え頂けるとありがたいです。そうでなければ設定が正しいかの確認方法をお教え頂けると助かります。 \n以上よろしくお願い致します。 \n追伸:config.pyの編集を見るとExample supports QZ DC report outputは*で選択されているように見えます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T01:06:26.697", "favorite_count": 0, "id": "56164", "last_activity_date": "2019-07-01T05:21:33.250", "last_edit_date": "2019-06-28T02:03:35.343", "last_editor_user_id": "34896", "owner_user_id": "34896", "post_type": "question", "score": 0, "tags": [ "spresense" ], "title": "SPRESENSEのQZQSMが受信できない件", "view_count": 243 }
[ { "body": "私のところでは同様の設定内容で正常に受信できています。 \nQZQSMだけが取得できていないということは、 EXAMPLES_GNSS_ATCMD_SUPPORT_DCREPORT が \n有効になっていないことが考えられますが、追伸いただいた内容からすると問題なさそうです。 \n他に考えられるのはQZSSのL1S信号を正常に受信しているかどうかです。 \nGPGSVの中に衛星番号183/184/185/189のいずれかが含まれていること、もしくは \nQZGSVの中に衛星番号55/56/57/61のいずれかが含まれていることを確認してみてください。", "comment_co...
56164
null
56167
{ "accepted_answer_id": "56181", "answer_count": 1, "body": "**悩んでいる点** \n「tテーブルcカラムに格納されている文字数の合計」を取得したい。 \n結果自体は取得できるが、下記何れで実装した方が重くならないか、知りたい \n・MySQL \n・PHP\n\n* * *\n\n**MySQL** \n下記を試したら、TypeがALLでした\n\n```\n\n explain SELECT sum(CHAR_LENGTH(c)) FROM `t` WHERE `a_id`=1\n \n```\n\n> [ALL\n> フルスキャンなので一番重い。改善必須](https://qiita.com/mtanabe/items/33a80bf2749a872645e6)\n\nと書かれていたのでMySQLではなくPHPで実装しようかと思ったのですが、 \n試しに下記を実行したらTypeは同じくALLでした(インデックスの問題??)\n\n```\n\n explain SELECT c FROM `t` WHERE `a_id`=1\n \n```\n\n* * *\n\n**Q1** \nexplain で TypeがALLだからと言って必ずしも改善する必要はない?\n\n**Q2** \n`SELECT sum(CHAR_LENGTH(c)) FROM`t`WHERE`a_id`=1`を見て何か思うことはありますか? \nsumやCHAR_LENGTHは(重くなりそうなので)なるべく使用しない方が良い?\n\n**Q3** \n・MySQLでもPHPでも実装できる場合は、どう判断? \n・環境に依存するので両方実装して速度測定するしかない? \n・その場合、レコード数が増加する度に、計測しなおす??", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T02:47:42.920", "favorite_count": 0, "id": "56169", "last_activity_date": "2019-06-28T07:52:12.240", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "php", "mysql" ], "title": "複数レコードの同カラムに格納されている文字数の合計", "view_count": 172 }
[ { "body": "確認しなければならない変数が多い質問なので非常に回答は付きづらいものと思います。 \n例えばリソース(CPUやメモリ)が十分予算も潤沢にあるのであればあまり気にせず動くことだけに注力できますし、非常に限られたリソースで実装する場合はかなり厳密に検査を実施する必要があります。 \nまたアプリケーション的に頻繁に動かないバッチ処理でかつ実行時間に制約がないものであれば無理に改修する必要はないはずです。しかしながら厳密な性能(たとえば一プロセスは0.5secを超えないとか)が設定されている場合は厳密に見る必要があります。 \nさらにはアプリケーションの仕様で書き込みが多いのかそれとも参照が多いの...
56169
56181
56181
{ "accepted_answer_id": "56197", "answer_count": 3, "body": "以下のような処理をPython3で実行した場合に、modelのハイパーパラメータ(メンバ変数)の値の変更は関数learnの外でも適用されてしまうのでしょうか? \nまた、メンバ変数の変更が行われるにせよ行われないにせよそのような動作をするのは何故でしょうか? \nどなたか分かる方がいらっしゃればご教授頂けると助かります。 \n(Jupyter Notebook上でのコード実行を想定しています。)\n\n```\n\n class Model:\n def train(self,..):\n #ハイパーパラメータ(メンバ変数)の値を変える処理\n \n def learn(model):\n model.train()\n \n model = Model()\n learn(model)\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T03:49:53.667", "favorite_count": 0, "id": "56172", "last_activity_date": "2019-06-28T22:50:24.377", "last_edit_date": "2019-06-28T11:16:07.780", "last_editor_user_id": "31249", "owner_user_id": "31249", "post_type": "question", "score": 1, "tags": [ "python", "python3" ], "title": "Python3においてクラス外の関数内で渡されたインスタンスのメンバ変数を変更した場合に、そのメンバ変数の変更は関数の外でも適用されるかどうか?", "view_count": 939 }
[ { "body": "まず、Python3ではメンバ変数ではなくクラス変数、及びインスタンス変数と言います。\n\n[9\\. クラス — Python 3.7.4rc1\nドキュメント](https://docs.python.org/ja/3/tutorial/classes.html#class-and-instance-\nvariables)\n\nその上で回答すると、 **どのように値をセットしたかによって変わります** 。\n\n以下に、インスタンス変数をセットしたもの、クラス変数を変更した例を示します。\n\n```\n\n class Apple:\n color = 'gree...
56172
56197
56191
{ "accepted_answer_id": "56175", "answer_count": 1, "body": "[レーベンシュタイン距離(編集距離)](https://ja.wikipedia.org/wiki/%E3%83%AC%E3%83%BC%E3%83%99%E3%83%B3%E3%82%B7%E3%83%A5%E3%82%BF%E3%82%A4%E3%83%B3%E8%B7%9D%E9%9B%A2)を計算して、2単語間の最小編集コストを求めようとしています。 \n以下のように、[python-Levenshtein](https://pypi.org/project/python-\nLevenshtein/)というライブラリを使って簡単に実行できますが、グラフを書いて同数の最短ルートが求められずに困っています。\n\n「kitten」を「sitting」に変形する場合には、3回の処理が必要で手で文字を入れ替え・削除処理をする場合や、[レーベンシュタイン距離(編集距離)](https://ja.wikipedia.org/wiki/%E3%83%AC%E3%83%BC%E3%83%99%E3%83%B3%E3%82%B7%E3%83%A5%E3%82%BF%E3%82%A4%E3%83%B3%E8%B7%9D%E9%9B%A2)のアルゴリズムに入れると確かに、最小値は3です。\n\nしかし、グラフで左下をスタート、右上をゴールとして斜線はコスト0、横・縦はコスト1とすると最短距離(赤線のコスト合計)は「5」となり、グラフ上で「3」はどのように求まるのか、プログラムとのちがいは何なのかわからない状態です。\n\nグラフ \n[![画像の説明をここに入力](https://i.stack.imgur.com/OoC2K.png)](https://i.stack.imgur.com/OoC2K.png)\n\nプログラム結果\n\n```\n\n $ python edit_graph.py\n 3\n \n```\n\n実行したコード\n\n```\n\n #!/usr/bin/env python\n # coding: utf8\n \n import Levenshtein\n \n text1 = 'kitten'\n text2 = 'sitting'\n \n print (Levenshtein.distance(text1, text2))\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T06:23:59.100", "favorite_count": 0, "id": "56174", "last_activity_date": "2019-06-29T11:55:53.360", "last_edit_date": "2019-06-29T11:55:53.360", "last_editor_user_id": "32568", "owner_user_id": "32568", "post_type": "question", "score": 1, "tags": [ "python", "python3", "アルゴリズム", "データ構造", "グラフ理論" ], "title": "レーベンシュタイン距離(編集距離/エディットグラフ)の出力とグラフにおける最短経路に関して", "view_count": 400 }
[ { "body": "レーベンシュタイン距離は各編集操作それぞれに別々のコストを割り当てることが可能です。ライブラリが出力したものは、挿入・削除・置換にコスト1を割り当てた場合のレーベンシュタイン距離だと思われます。グラフで求めているものは、挿入・削除にコスト1、置換にコスト2が割り振った場合(あるいは置換操作がなく、削除と挿入にした場合)のレーベンシュタイン距離となります。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T06:48:38.163", "id":...
56174
56175
56175
{ "accepted_answer_id": "56182", "answer_count": 3, "body": "`ps` コマンドなどを実行すると、ある時刻の特定のプロセスに、何の pid が割り振られているかを確認することができます。\n\n別の時刻にもう一回 `ps` を実行すると、先ほど確認した pid を持つプロセスがあるかどうかを確認することができますが、 linux/unix では\npid が使い回されることを考えると、この、別の時刻において取得された pid\nに紐づいたプロセスは、必ずしも前に取得した際のプロセスとは同一ではないと思っています。\n\nたとえば、 pid を記録しておいて、のちのちにプロセス制御でその pid\nを利用する場合に、万が一、再利用によって別プロセスになっていた場合に、事故のようなことが起きたら嫌だな、と考えると、以下の疑問が生じました。\n\n### 質問\n\nある別々の時刻で特定の pid に対応するプロセスを取得したときに、これらが同一のものであるかを確認するための手段はありますか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T07:19:37.003", "favorite_count": 0, "id": "56177", "last_activity_date": "2020-05-16T07:51:32.537", "last_edit_date": "2020-04-14T15:56:03.067", "last_editor_user_id": "754", "owner_user_id": "754", "post_type": "question", "score": 6, "tags": [ "linux", "unix" ], "title": "ある時刻の、特定の pid のプロセスと、別の時刻における同じ pid のプロセスの同一性の判定はできる?", "view_count": 2153 }
[ { "body": "`/proc/`ディレクトリ以下に実行中のPIDごとの情報があるので、これらが利用出来そうです。 \n活用しやすそうなものを挙げると、\n\n```\n\n /proc/<PID>/cmdline 起動したプログラムとその引数\n /proc/<PID>/exe 起動したプログラムへのシンボリックリンク\n \n```\n\n参考: \n[/proc/プロセスID を探検する - いますぐ実践! Linuxシステム管理 /\nVol.024](http://www.usupi.org/sysad/024.html)", "comment_count"...
56177
56182
56182
{ "accepted_answer_id": "56205", "answer_count": 2, "body": "現状、Naudioライブラリを使用してネットワークドライブに保存されたWavファイルを再生しようとしていました。 \nしかし、再生中にネットワークが切断された場合、UIスレッドが停止します。 \nおそらく原因は、Naudio内部でファイル読込が完了しないため発生していると思われます。 \nそこで、StreamのReadTimeoutが設定できないかと試しましたが無理でした。 \n以上により、ストリーミング(逐次読込)のWavファイル再生ができ、かつ上記のファイル読込異常が発生した場合はTimeOut値が設定できる、C#用のライブラリを探しております。ご存知でしょうか。\n\n追記 \nネットワーク切断によって、Naudio内部で使用されるFilestreamのRead()で応答が返らない(System.IO.IOException\n)ため、UIスレッドがストールされていると思っています。 \nReadtimeOutを実施することで、UIスレッドのストールを回避しタイムアウト時には何らかの処理をして再生自体を中止しようと考えていました。 \nタイムアウトは1秒程度を想定しています。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T07:42:30.923", "favorite_count": 0, "id": "56179", "last_activity_date": "2019-06-30T12:42:46.647", "last_edit_date": "2019-06-28T09:40:57.090", "last_editor_user_id": "32228", "owner_user_id": "32228", "post_type": "question", "score": 0, "tags": [ "c#", "audio-streaming" ], "title": "ストリーミング(逐次読込)のWavファイル再生のC#用のライブラリはありませんか", "view_count": 801 }
[ { "body": "今のところ無いのでは? C#では [NAudio](https://github.com/naudio/NAudio) と\n[CSCore](https://github.com/filoe/cscore) が主なようですが、両方ともそうした機能は無さそうですし。\n\n[Popular C# audio Projects -\nLibraries.io](https://libraries.io/search?keywords=audio&languages=C%23) や\n[Free Audio / Sound Libraries and Source\nCode](https://ww...
56179
56205
56211
{ "accepted_answer_id": "56185", "answer_count": 1, "body": "tableViewCellをスワイプして削除したいのですが下の画像の様にdeleteを押したら致命的なエラーになる。どの様なコードを追加しなければならないですか。またそれは何故ですか。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/dx7Ia.png)](https://i.stack.imgur.com/dx7Ia.png)\n\n問題のあるコード↓↓\n\n```\n\n import UIKit\n \n class TableViewController: UITableViewController {\n \n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n tableView.register(UINib(nibName: \"TableViewCell\", bundle: nil), forCellReuseIdentifier: \"customTableViewCell\")\n \n }\n \n \n override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n return 1\n }\n \n override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n let cell = tableView.dequeueReusableCell(withIdentifier: \"customTableViewCell\", for: indexPath) as! TableViewCell\n \n return cell\n }\n \n override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {\n \n }\n \n \n //問題のある部分!\n override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {\n if editingStyle == .delete {\n        //おそらくarray.remove(at: indexPath.row)的な処理が必要であるはず、、\n \n tableView.deleteRows(at: [indexPath], with: .fade)\n }\n }\n \n @IBAction func addSkillButton(_ sender: UIBarButtonItem) {\n }\n \n \n @IBAction func secret(_ sender: UIBarButtonItem) {\n }\n \n \n }\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T07:48:28.617", "favorite_count": 0, "id": "56180", "last_activity_date": "2019-06-28T23:39:59.190", "last_edit_date": "2019-06-28T23:39:59.190", "last_editor_user_id": "14745", "owner_user_id": "34541", "post_type": "question", "score": 0, "tags": [ "swift", "xcode" ], "title": "tableViewCell の削除について", "view_count": 1085 }
[ { "body": "デバッグコンソールには **Internal Incosistency Exception** という表示がどこかに出ていたのではないでしょうか?\n何らかのエラーメッセージが表示されている場合には、致命的なエラーとだけ言わずに、そのメッセージをご質問に含められた方が、より的確なアドバイスをより早く得ることにつながります。\n\n今回の問題に関して言えば、結論はご自身のコメントにあるように「`array.remove(at:\nindexPath.row)`的な処理が必要」だと言うことです。\n\nもう少し具体的に言うと、\n\n 1. `tableView(_:numberOfRowsInS...
56180
56185
56185
{ "accepted_answer_id": "56215", "answer_count": 1, "body": "`TableViewController` に `PopupViewController` のポップアップを表示したいのですがうまく行かないです。\n何故なのでしょうか。どうしたら良いですか。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/3OHNk.png)](https://i.stack.imgur.com/3OHNk.png) \n** この右側のポップアップを表示したい**\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/KhSlL.png)](https://i.stack.imgur.com/KhSlL.png)\n\n↓↓こうなります。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/Zx3Dn.png)](https://i.stack.imgur.com/Zx3Dn.png)\n\n**TableViewのクラス**\n\n```\n\n import UIKit\n \n class TableViewController: UITableViewController {\n \n var array : Array = [1, 2, 3, 4, 5]\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n \n }\n \n \n override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n return array.count\n }\n \n override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n let cell = tableView.dequeueReusableCell(withIdentifier: \"customTableViewCell\", for: indexPath) as! costomViewCell\n \n cell.skillName.text = \"〇〇〇〇〇〇\\(array[indexPath.row])\"\n cell.goalCountLabel.text = \"20 : 00\"\n \n return cell\n }\n \n override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {\n \n }\n \n override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {\n if editingStyle == .delete {\n array.remove(at: indexPath.row)\n tableView.deleteRows(at: [indexPath], with: .fade)\n }\n }\n \n \n let popupViewController = PopupViewController()\n @IBAction func addSkillButton(_ sender: UIBarButtonItem) {\n view.addSubview(popupViewController.view)\n }\n \n \n @IBAction func secret(_ sender: UIBarButtonItem) {\n }\n \n \n }\n \n \n \n```\n\n**Popupクラス**\n\n```\n\n import UIKit\n \n class PopupViewController: UIViewController {\n \n @IBOutlet weak var newSkillView: UIView!\n @IBOutlet weak var newSkillLabel: UILabel!\n @IBOutlet weak var newSkillText: UITextField!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n self.view.backgroundColor = UIColor(\n red: 150/255,\n green: 150/255,\n blue: 150/255,\n alpha: 0.6\n )\n // newSkillView.layer.cornerRadius = 25.0 この処理を行うとThread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value というエラーが出る。。。何故???\n \n }\n \n @IBAction func newSkillButton(_ sender: UIButton) {\n }\n \n @IBAction func tapGestureRecogButton(_ sender: UITapGestureRecognizer) {\n self.view.removeFromSuperview()\n \n }\n \n }\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T14:27:42.517", "favorite_count": 0, "id": "56198", "last_activity_date": "2019-06-29T06:56:47.887", "last_edit_date": "2019-06-29T01:32:53.777", "last_editor_user_id": "34541", "owner_user_id": "34541", "post_type": "question", "score": 0, "tags": [ "swift", "xcode" ], "title": "(UITableView上に)ポップアップを表示したい!", "view_count": 531 }
[ { "body": "**こうなります** の画像を見ると、table viewの部分がグレーになっていますよね? これは`PopupViewController`が\n**表示はされているけど、中身がない** 状態になっているからです。\n\nこの事象でいちばんの元凶はこの行です。\n\n```\n\n let popupViewController = PopupViewController()\n \n```\n\nview controllerの引数なしのイニシャライザを呼んでいますが、これではiOSは、storyboardの中身を読みに行ってくれません。\n\n従って、\n\n * I...
56198
56215
56215
{ "accepted_answer_id": "56210", "answer_count": 1, "body": "以下のpythonのコードは、生産管理システムから取得したデータを「手順」「号機」で分類して \n作業時間を求めています。作業は3つの手順からなり、開始日時と終了日時の差分が作業時間になりますが、中断があるので累積させる必要があります。\n\nやりたいことは以下2つです。 \n1つ目:もっと高速に「手順」別、「号機」別の作業時間の算出と累積時間の算出はできないでしょうか?2重のforループとなっているのはあまりスマートではなさそうです。えらく時間がかかります。 \n2つ目:画像のような横軸が号機、縦軸が手順でセルには累積時間をセットした表を作成したいのですが方法が分かりません。リスト内辞書を作って、DataFrameに出来るかなとも思ったのですが \nここからが分かりませんでした。\n\n```\n\n import pandas as pd\n from datetime import datetime\n \n DF=ps.DataFrame(columns=['手順名','状態','開始日時','終了日時','号機'])\n Items=[\n ['手順1','中断','2019-6-28 08:15:00','2019-6-28 08:16:00','1'],\n ['手順1','中断','2019-6-28 08:16:30','2019-6-28 08:17:30','1'],\n ['手順1','完成','2019-6-28 08:18:30','2019-6-28 08:19:30','1'],\n ['手順2','中断','2019-6-28 08:20:30','2019-6-28 08:21:30','1'],\n ['手順2','完成','2019-6-28 08:22:30','2019-6-28 08:23:30','1'],\n ['手順3','中断','2019-6-28 08:24:30','2019-6-28 08:25:30','1'],\n ['手順3','完成','2019-6-28 08:26:30','2019-6-28 08:27:30','1'],\n ['手順1','中断','2019-6-28 08:30:00','2019-6-28 08:31:00','2'],\n ['手順1','中断','2019-6-28 08:31:30','2019-6-28 08:32:30','2'],\n ['手順1','完成','2019-6-28 08:33:30','2019-6-28 08:34:30','2'],\n ['手順2','中断','2019-6-28 08:35:30','2019-6-28 08:36:30','2'],\n ['手順2','完成','2019-6-28 08:37:30','2019-6-28 08:38:30','2'],\n ['手順3','中断','2019-6-28 08:39:30','2019-6-28 08:40:30','2'],\n ['手順3','完成','2019-6-28 08:41:30','2019-6-28 08:42:30','2']\n ]\n for i,Dat in enumerate(Items[::-1]):\n DF.loc[i]=Dat\n \n list_手順と号機=[]\n \n for name,group in DF.groupby('手順名'):\n df_時間sort = group.sort_values(by=['開始日時'],ascending=[True])\n for name2,group2 in df_時間sort.groupby('号機'):\n group2['作業時間'] = pd.to_datetime(group2['終了日時'])-pd.to_datetime(group2['開始日時'])\n group2['累積時間'] = group2['作業時間'].cumsum()\n list_手順と号機.append({'手順名':name,'号機':name2,'時間':group2['累積時間'].max()})\n \n```\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/noXIp.png)](https://i.stack.imgur.com/noXIp.png) \n画像のセル中の時間はあくまで例です。適当な値が入っています。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T14:42:08.610", "favorite_count": 0, "id": "56199", "last_activity_date": "2019-06-29T05:46:26.587", "last_edit_date": "2019-06-29T01:47:44.170", "last_editor_user_id": "34450", "owner_user_id": "34450", "post_type": "question", "score": 0, "tags": [ "python", "pandas" ], "title": "pandas のデータ処理の高速化 と 表作成方法", "view_count": 260 }
[ { "body": "`list_手順と号機=[]`以後の部分を以下に置き換えればプログラムはすっきりするでしょう。 \n処理時間が速くなるか、については質問に提示されたプログラムがそのままではWindowsのPython3.7.3+pandas0.24.2で動作しなかったので分かりませんが、2重forループより少しは速くなるのではないでしょうか。\n\n```\n\n DF = DF.sort_values(['号機','手順名','開始日時'])\n DFdelta = DF.assign(作業時間 = (pd.to_datetime(DF['終了日時']) - pd.to_datetime(DF[...
56199
56210
56210
{ "accepted_answer_id": "56202", "answer_count": 1, "body": "<http://bamch0h.hatenablog.com/entry/2019/06/21/000743> \n上記のブロクにも書いたのですが、rb_load と rb_f_load の挙動の違いについての質問になります。\n\n[質問内容] \nrb_load() を使用して カレントディレクトリにあるファイル(例えば test.rb) をロードするようなC言語拡張を書いたときに、cannot\nload such file -- test.rb (LoadError) となりロードできませんでした。Kernel.#load は\nrb_f_load() を使用しているようで、load \"test.rb\" という指定でも問題なくロードできます。\n\n<https://docs.ruby-lang.org/ja/latest/function/rb_load.html> を見る限り、rb_load() は\nKernel.#load の低レベルインターフェースということですが、rb_load() を使用すれば、Kernel.#load\nと同様のことができる。ということでもないのでしょうか?\n\nrb_load() と rb_f_load() がある経緯について知れるならば幸いです。", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T14:45:43.027", "favorite_count": 0, "id": "56200", "last_activity_date": "2019-06-28T17:25:18.187", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "18863", "post_type": "question", "score": 2, "tags": [ "ruby" ], "title": "rb_load と rb_f_load の挙動の違いについて", "view_count": 98 }
[ { "body": "Ruby 2.6.3 のソースコードを調べてみました。Yamanaka さんのブログ記事に記載がある通りに `rb_load()` ->\n`file_to_load()` -> `load_failed()` という順序で実行が続いています。\n\n**load.c** \n\n```\n\n void\n rb_load(VALUE fname, int wrap)\n {\n rb_load_internal(file_to_load(fname), wrap);\n }\n \n static VALUE\n file_to_lo...
56200
56202
56202
{ "accepted_answer_id": "56208", "answer_count": 1, "body": "Twitter で `isOdd` 関数を switch-case\nで実装する効率の悪い例が[バズっていました](https://twitter.com/NAGAYASU_Shinya/status/1143868066440216577)。この例では\n1 から 10000 まで書いていましたが、僕はこれを INT_MIN から INT_MAX まで case\nを書けば確かに動作するなと(冗談で)思いました。\n\nそこで、INT_MIN から INT_MAX まで case で分岐する C 言語のプログラムを出力するプログラムを書き実行したところ、108 GB\nのプログラムファイルを得ました。\n\nここまでは良かったのですが、この巨大なプログラムを gcc でコンパイルしようとしたところ、以下のように `out of memory` エラーが出ました。\n\n```\n\n $ ls -lah calc.c\n -rwxrwxrwx 1 nek nek 108G Jun 28 06:10 calc.c\n $ gcc -Wall -Wextra -o calc calc.c\n \n cc1: out of memory allocating 115889378580 bytes after a total of 475136 bytes\n \n```\n\n`free` コマンドで確認してみたところ、なるほど確かにメモリ(とスワップ領域)が足りないようです。115889378580 bytes ≒ 116 GB\nです。\n\n```\n\n $ free -h\n total used free shared buff/cache available\n Mem: 15G 6.8G 8.9G 17M 223M 9.0G\n Swap: 48G 100M 47G\n \n```\n\nエラーメッセージで検索したところ、`swapon`\nで[一時的にスワップ領域を増やす方法を見つけました](https://stackoverflow.com/a/11289081/5989200)。これを試してみたのですが、いまこれを実行していたのが\nWSL であり、どうやら WSL では `swapon` が実装されていないため、スワップ領域を増やすことができませんでした。\n\n```\n\n $ swapon tmpswap\n swapon: /mnt/c/(中略)/tmpswap: insecure permissions 0777, 0600 suggested.\n swapon: /mnt/c/(中略)/tmpswap: insecure file owner 1000, 0 (root) suggested.\n swapon: /mnt/c/(中略)/tmpswap: swapon failed: Function not implemented\n \n```\n\nさて、では WSL 上でこの巨大なプログラムをコンパイルするための領域を確保するにはどうすれば良いでしょうか? `swapon`\n以外に何か方法はありませんでしょうか。\n\n※Windows 上の mingw-w64 を使う方法もありそうですが、ひとまず WSL 上でコンパイルできないか考えています。\n\n### 環境\n\n * Windows 10 Home, Version 1803, Build 17134.829\n * Windows Subsystem for Linux (WSL 1) の Ubuntu 18.04.2\n * gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T16:46:48.367", "favorite_count": 0, "id": "56201", "last_activity_date": "2019-06-29T01:52:28.980", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "post_type": "question", "score": 1, "tags": [ "linux", "ubuntu", "gcc", "wsl", "スワップ" ], "title": "WSL 1で大量のメモリを確保する方法", "view_count": 2156 }
[ { "body": "公式の資料を見つけられませんが、下記issueにある開発メンバーのコメントを読む限り、どうやら、WSL1はWindows側の物理メモリとページングファイルをそのまま使用するらしく、`free`でもそれらのサイズをそのまま表示しているだけのようです。\n\n<https://github.com/Microsoft/WSL/issues/92#issuecomment-222318797>\n\n注意して欲しいのは、Windowsのシステムのプロパティにある仮想メモリのページングファイルサイズ、タスクマネージャーのコミット済みのサイズ(仮想メモリのサイズ)、`systeminfo`で表示される仮想...
56201
56208
56208
{ "accepted_answer_id": null, "answer_count": 0, "body": "`Rails`で`Postgresql`を使用しておりカラムに配列をもたせようとしたところRailsガイドの解説ではインデックスの方式に`gin`という物が使われていました。\n\n```\n\n create_table :books do |t|\n t.string 'title'\n t.string 'tags', array: true\n t.integer 'ratings', array: true\n end\n add_index :books, :tags, using: 'gin'\n add_index :books, :ratings, using: 'gin'\n \n```\n\n<https://edgeguides.rubyonrails.org/active_record_postgresql.html#array>\n\n検索してみてもそういうインデックス形式があるとわかるだけで具体的にどのような特徴を持つアルゴリズムかわかりませんでした。\n\nカラムに配列を使う時は必ず`gin`を指定すべきなのでしょうか? \nまた`gin`がどのような条件で最適の選択肢になるかが知りたいです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-28T21:01:18.777", "favorite_count": 0, "id": "56204", "last_activity_date": "2019-06-28T21:01:18.777", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3271", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "postgresql" ], "title": "Postgresql の gin とはどのような特徴をもつインデックス形式ですか?", "view_count": 179 }
[]
56204
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "起動時に以下のメッセージが出るようになってしまいました。 \nパスの問題?のようなのですがどうしたらでないようにできるのかわかりません。\n\n```\n\n rt: Unknown command 'PATH=~/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/ProgramData/Oracle/Java/javapath:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files/CMake/bin:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/Calibre2:/mnt/c/Ruby21-x64/bin:/mnt/c/Users/adminryzen/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Username/AppData/Local/Programs/Microsoft VS Code/bin:/snap/bin'.\n rt: For help, run 'rt help'.\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-29T04:47:30.540", "favorite_count": 0, "id": "56214", "last_activity_date": "2019-06-29T10:00:46.340", "last_edit_date": "2019-06-29T10:00:46.340", "last_editor_user_id": "3068", "owner_user_id": "34905", "post_type": "question", "score": 0, "tags": [ "ubuntu", "wsl" ], "title": "Windows Subsystem for Linux のubuntu起動時のメッセージ", "view_count": 280 }
[]
56214
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "下記表のような時系列温度データにつき、`2000年、2001年・・・`と、各年ごとの値の平均値を計算しています。\n\n日付のstart-endが分かっている場合、\n\n```\n\n df['2000-01-04':'2000-12-27'].mean()\n df['2001-01-05':'2001-12-28'].mean()\n \n```\n\nなどと値を直指定すればいいと思うのですが、データを見ていちいち確認するのではなく、プログラム的にstart/endを判定したい場合、どのようにプログラムを組んだらいいのでしょうか?\n\n`df.min()`を使えばとも思ったのですが、各年ではなくデータ全体の最小値を抽出してしまいます。\n\n```\n\n date(index) 気温\n 2000-01-04 -1℃\n 2000-01-05 0℃\n ・\n ・\n 2000-12-27 8℃\n 2001-01-05 2℃\n 2001-01-06 3℃\n ・\n ・\n 2001-12-28 -1℃\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-29T08:06:51.363", "favorite_count": 0, "id": "56216", "last_activity_date": "2019-06-29T09:51:28.033", "last_edit_date": "2019-06-29T08:31:01.860", "last_editor_user_id": "31764", "owner_user_id": "31764", "post_type": "question", "score": 1, "tags": [ "python", "python3", "pandas" ], "title": "pandasで日付の最小値、最大値を自動抽出するには", "view_count": 3914 }
[ { "body": "```\n\n df.resample('1Y').mean()\n \n```\n\nでは?\n\n```\n\n pd.Series(df.index).min()\n pd.Series(df.index).max()\n df.index[0]\n df.index[-1]\n df.idxmin()\n df.idxmax()\n \n```\n\nindexの最大と最小は用途によって使い分ければいいかと", "comment_count": 0, "content_license": "CC BY-SA 4.0",...
56216
null
56229
{ "accepted_answer_id": "56249", "answer_count": 2, "body": "アプリをインストールした直後に一回だけ NavigationBar のタイトルを決める処理をしたいのですが書いたコードが実行されない理由はなんですか?\n又、どの様にしたら実行される様になりますか?\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/oNcFJ.png)](https://i.stack.imgur.com/oNcFJ.png)\n\n```\n\n import UIKit\n \n @UIApplicationMain\n class AppDelegate: UIResponder, UIApplicationDelegate {\n static let share = AppDelegate()\n \n var window: UIWindow?\n \n var theFarstNameDidSet : ((_ nowNumber : String) -> Void)? = nil\n var theFarstBool = false\n \n func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { //ここが初回起動のコードらしい。\n \n // Override point for customization after application launch.\n print(\"最初に実行\")\n self.theFarstBool = true\n self.theFarstNameDidSet?(\"\")\n print(\"最後に実行\")\n self.theFarstBool = false\n return true\n }\n \n func applicationWillResignActive(_ application: UIApplication) {\n // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.\n // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.\n }\n \n func applicationDidEnterBackground(_ application: UIApplication) {\n // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.\n // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.\n }\n \n func applicationWillEnterForeground(_ application: UIApplication) {\n // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.\n }\n \n func applicationDidBecomeActive(_ application: UIApplication) {\n // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.\n }\n \n func applicationWillTerminate(_ application: UIApplication) {\n // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.\n }\n \n \n }\n \n```\n\n```\n\n import UIKit\n \n \n class ViewController: UIViewController {\n \n \n @IBOutlet weak var characterImage: UIImageView!\n @IBOutlet weak var timerlabel: UILabel!\n @IBOutlet weak var startButton: UIButton!\n \n let userDefaults = UserDefaults.standard\n let fastTitleKey = \"fastTitleKey\"\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view.\n \n startButton.layer.cornerRadius = 25.0\n \n guard let obj = UserDefaults.standard.object(forKey: \"goalCountKey\") else {\n return\n }\n \n let goalString = \"\\(obj)\"\n timerlabel.text = secondsToGoalTimerLabel(Int(goalString)!)\n \n if AppDelegate.share.theFarstBool == true {\n print(\"2番目に実行\")\n AppDelegate.share.theFarstNameDidSet = { nowNumber in\n var alertTextFeld: UITextField?\n let alert = UIAlertController(title: \"Skill Name\", message: \"Enter new name\", preferredStyle: UIAlertController.Style.alert)\n alert.addTextField { (textField: UITextField!) in\n alertTextFeld = textField\n }\n \n alert.addAction(UIAlertAction(title: \"OK\", style: .default, handler: { _ in\n if let text = alertTextFeld?.text {\n self.title = text\n self.userDefaults.set(text, forKey: self.fastTitleKey)\n self.userDefaults.synchronize()\n \n }\n }))\n self.present(alert, animated: true, completion: nil)\n }\n \n }\n \n \n self.title = self.userDefaults.object(forKey: self.fastTitleKey) as? String\n \n }\n \n override func viewWillAppear(_ animated: Bool) {\n \n guard let obj = UserDefaults.standard.object(forKey: \"goalCountKey\") else {\n return\n }\n \n let goalString = \"\\(obj)\"\n timerlabel.text = secondsToGoalTimerLabel(Int(goalString)!)\n }\n \n }\n \n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-29T09:42:03.043", "favorite_count": 0, "id": "56228", "last_activity_date": "2019-06-30T08:05:18.750", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34541", "post_type": "question", "score": 0, "tags": [ "swift", "xcode" ], "title": "アプリの初回起動の限定の処理について", "view_count": 2142 }
[ { "body": "奇跡的にできました。 \nUserDefaultsを使ったらできました。 なんで機能しているのかよくわかっていないのですが。わかる方がいらしたら教えてください。\n\n```\n\n import UIKit\n \n @UIApplicationMain\n class AppDelegate: UIResponder, UIApplicationDelegate {\n static let share = AppDelegate()\n \n var window: UIWindow?\n \n let use...
56228
56249
56249
{ "accepted_answer_id": "56233", "answer_count": 2, "body": "[ダイクストラ法のコード(python)](https://engineeringnote.hateblo.jp/entry/python/algorithm-\nand-data-structures/dijkstra)を参考に以下のプログラムを実行しました。 \n出力として最短ルートは'A->C->B->D'と求められましたが、コストは「5+(-4)+1=2」になるところ、'A->B->D'の「3+1=4」が出力されました。原因がわからないです。\n\nグラフ部分はコードのrouteにあたります。 \n出力\n\n```\n\n $ python dijkstra.py\n visited to A.\n visited to B.\n visited to D.\n visited to C.\n minimal cost is 4.\n optimum route is 'A->C->B->D'.\n \n```\n\n```\n\n # dijkstra.py\n import sys\n \n INF = 10000\n VISITED = 1\n NOT_VISITED = 0\n \n route = [\n [INF, 3, 5, INF],\n [INF, INF, INF, 1],\n [INF, -4, INF, INF],\n [INF, INF, INF, INF]\n ]\n \n size = len(route)\n cost = [INF for _ in range(size)]\n visit = [NOT_VISITED for _ in range(size)]\n before = [None for _ in range(size)]\n cost[0] = 0\n while True:\n min = INF\n for i in range(size):\n if visit[i] == NOT_VISITED and cost[i] < min:\n x = i\n min = cost[x]\n if min == INF:\n break\n visit[x] = VISITED\n print(\"visited to {}.\".format(chr(65+x)))\n \n for i in range(size):\n if cost[i] > route[x][i] + cost[x]:\n cost[i] = route[x][i] + cost[x]\n before[i] = x\n \n if cost[size-1] == INF:\n print(\"could not find optimum route.\")\n sys.exit(1)\n \n i = size - 1\n optimum_route = []\n while True:\n optimum_route.insert(0, chr(65+i))\n if i == 0:\n break\n i = before[i]\n \n print(\"minimal cost is {}.\".format(cost[size-1]))\n print(\"optimum route is '\", end=\"\")\n for i in range(len(optimum_route)):\n print(optimum_route[i], end=\"\")\n if i == len(optimum_route) -1:\n print(\"'.\")\n break\n print(\"->\", end=\"\")\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-29T12:11:03.120", "favorite_count": 0, "id": "56230", "last_activity_date": "2019-06-29T18:02:06.500", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32568", "post_type": "question", "score": 0, "tags": [ "python", "python3", "アルゴリズム", "データ構造", "グラフ理論" ], "title": "ダイクストラ法で最短経路を見つけるときに負の値を持つ辺があると経路は正しくても誤ったコストが出力される", "view_count": 454 }
[ { "body": "一言でいうと、このプログラムは、すべての辺が正であることを仮定したアルゴリズムを使っているため、うまく動きません。以下は、プログラムの`while`ループを抜き出したものです。説明のために`#\nfor ループ 1`と`# for ループ 2`というコメントを入れています。\n\n```\n\n while True:\n min = INF\n \n # for ループ 1\n for i in range(size):\n if visit[i] == NOT_VISITED and cost[i] < min:\n...
56230
56233
56233
{ "accepted_answer_id": "56246", "answer_count": 2, "body": "インデックスはSELECTクエリを見て作成すると思うのですが、1つのテーブルに対して1つのSELECTクエリしか発行しないとは限らないと思います\n\n例えば、下記のように1つのテーブルに対して複数のSELECTクエリを実行する(可能性がある)場合は、どのクエリを元にインデックスを作成するのですか?\n\n```\n\n SELECT * FROM t WHERE a = 1 \n \n SELECT * FROM t WHERE a = 1 ORDER BY b\n \n SELECT * FROM t WHERE c = 1 ORDER BY d\n \n```\n\n * **案1.SELECT文の数だけ、それに応じたインデックスを作成する** \nこの場合は、インデックス(a)と複合インデックス(a,b)と複合インデックス(c,d)を作成する?\n\n * **案2.1つのSELECT文にだけ対応したインデックスを作成する** \n該当テーブルに対して、最も参照回数が多いSELECT文をどうにかして特定して、それに応じたインデックスだけを作成する\n\n * **案3.計測した結果に基づきインデックスを作成する** \n(レコード数などによって)ケースバイケースなので、面倒でも総当たりで全部試していって計測するしかない?\n\nその他の案は何かありますか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-29T13:47:44.393", "favorite_count": 0, "id": "56231", "last_activity_date": "2019-06-30T07:27:23.007", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 1, "tags": [ "mysql" ], "title": "インデックス作成について", "view_count": 82 }
[ { "body": "インデックスを作成することで`SELECT`は性能向上が見込まれますが、逆に`INSERT` / `UPDATE` /\n`DELETE`等の更新処理はインデックスの更新のため性能低下します。更新処理中のロック時間が長くなることで他の処理も遅延します。質問のように`SELECT`だけでは判断できず、テーブルに対するアクセス全体を踏まえての判断が必要です。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T03:41:48.393", "id":...
56231
56246
56246
{ "accepted_answer_id": "56277", "answer_count": 3, "body": "groupsテーブルとusersテーブルがあったとします。\n\ngroupsテーブルのカラムが、 \n・ id \n・ group_id \n・ name\n\nidがuuid、group_idがユーザーが見ることができるidになっています。\n\nusersテーブルのカラムが \n・ id \n・ user_id \n・ group_id \n・ name\n\nidがuuid、user_idがユーザーが見ることができるid、group_idがgroupsのidに紐づいています。\n\nこの場合、usersのgroup_idがgroup_idではなくidに紐づいているので、 \nとてもややこしいと感じます。\n\nこういった場合はどのように名前をつけるべきでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-29T22:36:50.693", "favorite_count": 0, "id": "56235", "last_activity_date": "2019-07-01T08:07:51.103", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "29047", "post_type": "question", "score": 2, "tags": [ "mysql", "sql", "oracle" ], "title": "sqlのカラムの命名規則について", "view_count": 764 }
[ { "body": "「異なる意味なのに同じ名前」がややこしさの原因なので、「異なる意味なら異なる名前」になるようにするようにすればよいわけですが、これをどうするかはアプリケーション全体を見ないと決められない話です。\n\n* * *\n\ngroupsのgroup_idの名前を変えるのが自明で短絡的な方法ですが、group_idが真にIDなのであればリレーションをそっちに張るとか、それならidいらないのではとか、IDじゃないのであればgroup_idとは一体何者でそれにふさわしい名前は何かとか、別の視点でgroup_idが既存の名前付けルールにより決まる名前なのであればそのルール自体見直さないといけないのでは、とか...
56235
56277
56259
{ "accepted_answer_id": "56237", "answer_count": 1, "body": "先日質問でガントチャートの作成事例を指導いただきました。以下のソースで1つ理解できないところがありました。 \nガントチャートの縦軸が数値ではなく、DataFrameの入力データのItemカラムが縦軸にできています。今まで自作したグラフは、縦軸・横軸共に数値もしくは時間のものを扱うことが多かったので、縦軸を文字列にするカラクリを身に付けたいと思っています。 \nご指導よろしくお願いいたします。\n\n```\n\n from bokeh.plotting import figure, show, output_notebook, output_file\n from bokeh.models import ColumnDataSource, Range1d\n from bokeh.models.tools import HoverTool\n from datetime import datetime\n #from bokeh.charts import Bar # コメントアウト\n #output_notebook() # コメントアウト\n #output_file('GanntChart.html') #use this to create a standalone html file to send to others\n import pandas as ps\n \n DF=ps.DataFrame(columns=['Item','Start','End','Color'])\n Items=[\n ['Contract Review & Award','2015-7-22','2015-8-7','red'],\n ['Submit SOW','2015-8-10','2015-8-14','gray'],\n ['Initial Field Study','2015-8-17','2015-8-21','gray'],\n ['Topographic Procesing','2015-9-1','2016-6-1','gray'],\n ['Init. Hydrodynamic Modeling','2016-1-2','2016-3-15','gray'],\n ['Prepare Suitability Curves','2016-2-1','2016-3-1','gray'],\n ['Improvement Conceptual Designs','2016-5-1','2016-6-1','gray'],\n ['Retrieve Water Level Data','2016-8-15','2016-9-15','gray'],\n ['Finalize Hydrodynamic Models','2016-9-15','2016-10-15','gray'],\n ['Determine Passability','2016-9-15','2016-10-1','gray'],\n ['Finalize Improvement Concepts','2016-10-1','2016-10-31','gray'],\n ['Stakeholder Meeting','2016-10-20','2016-10-21','blue'],\n ['Completion of Project','2016-11-1','2016-11-30','red']\n ] #first items on bottom\n \n for i,Dat in enumerate(Items[::-1]):\n DF.loc[i]=Dat\n \n #convert strings to datetime fields:\n DF['Start_dt']=ps.to_datetime(DF.Start)\n DF['End_dt']=ps.to_datetime(DF.End)\n \n G=figure(title='Project Schedule',x_axis_type='datetime',width=800,height=400,y_range=DF.Item.tolist(),\n x_range=Range1d(DF.Start_dt.min(),DF.End_dt.max()), tools='save')\n \n hover=HoverTool(tooltips=\"Task: @Item<br>\\\n Start: @Start<br>\\\n End: @End\")\n G.add_tools(hover)\n \n DF['ID']=DF.index+0.3 # 数値調整 元は 0.8\n DF['ID1']=DF.index+0.7 # 数値調整 元は 1.2\n CDS=ColumnDataSource(DF)\n G.quad(left='Start_dt', right='End_dt', bottom='ID', top='ID1',source=CDS,color=\"Color\")\n #G.rect(,\"Item\",source=CDS)\n show(G)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-29T23:38:43.233", "favorite_count": 0, "id": "56236", "last_activity_date": "2019-06-30T00:48:43.373", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34450", "post_type": "question", "score": 0, "tags": [ "python", "pandas", "bokeh" ], "title": "Bokeh で作成するグラフの縦軸を数値以外にする方法が分かりません", "view_count": 458 }
[ { "body": "[figure()](https://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.figure.figure)メソッドの`y_range`パラメータ指定ですね。 \n以下の`y_range=DF.Item.tolist()`が、DataFrameのItem列(作業名文字列)のリストを指定しています。\n\n```\n\n G=figure(title='Project Schedule',x_axis_type='datetime',width=800,height=400,y_range=...
56236
56237
56237
{ "accepted_answer_id": null, "answer_count": 1, "body": "## 目的\n\nボタンをおすとテキストが複製されて画面が埋め尽くされる演出を作りたいです \n調べてみてもうまく動くものがありませんでした\n\n## 問題\n\nただ、HTMLを増やすとHTMLの数等でCSSを当てている所でデザインが崩れてしまいます \n(例:nth-childやjQueryのeq)\n\n * これの直すのにかなりの時間がかかりそうなので、できればhtmlをふさやないままでテキストを複製したいです\n\n * また演出がデザインのためなので、じかにhtmlを増やしてしまうよりcssでやるほうが行儀がいいと感じたのでCSSでやりたいです\n\n * text()でテキストを複製してもその位置が指定できないのでつまってしまいました\n\n## ソース\n\n元ソースはもっと複雑で全部のせれないですが、簡単にはこのようになっています \n(実際はJQueryやCSSで順番系の指定を使ってると思っていただければ)\n\n```\n\n <body>\n <div class=\"wrap\">\n <section class=\"horror_phase3\">\n <p>怖い文章</p><button type=\"button\">~ですか?</button>\n </section>\n </div>\n </body>\n \n```\n\n```\n\n .wrap {\n height: 100vh;\n width: 100%;\n position: relative;\n }\n .horror_phase3 {\n z-index: 3;\n position: absolute;\n display: flex;\n width: 100%;\n height: 100%;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n .horror_phase3 p {\n display: none;\n }\n \n```\n\n```\n\n $(\".horror_phase3 button\").click(function() {\n let count = 1;\n let this1 = $(this);\n this1.prop(\"disabled\", true);\n var counter = setInterval(function() {\n \n \n let p = this1.prev().clone();\n this1.parent().append(p.css({\n display: \"block\",\n position: \"absolute\",\n top: Math.floor(Math.random() * Math.floor(100)).toString() + \"%\",\n right: Math.floor(Math.random() * Math.floor(100)).toString() + \"%\"\n }));\n count++;\n if (count == 100) {\n clearInterval(counter);\n }\n }, 50);\n });\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T03:10:24.940", "favorite_count": 0, "id": "56238", "last_activity_date": "2019-06-30T07:23:10.277", "last_edit_date": "2019-06-30T06:43:59.557", "last_editor_user_id": "2376", "owner_user_id": "34910", "post_type": "question", "score": 0, "tags": [ "html", "jquery", "css" ], "title": "テキストをHTMLを増やさず複製するには?", "view_count": 201 }
[ { "body": "質問者さんの行ないたいことは、[`text-shadow`\nプロパティ](https://developer.mozilla.org/ja/docs/Web/CSS/text-\nshadow)を用いることで実現出来ると思います。しかし、この方法では **テキストに細かい装飾を行なうことが難しい**\nため、もし各テキストに対して適用するスタイルなどが存在する場合は、ノードを複製したほうが簡単だと思います。\n\n今回は、[`color` プロパティ](https://developer.mozilla.org/ja/docs/Web/CSS/color)に\ntransparent を設定し...
56238
null
56245
{ "accepted_answer_id": null, "answer_count": 3, "body": "この問題がわからず困っています。\n\n# 問題文\n\n配列のst番目から最後の要素までの、最小値を探す。ただし、最小値の値そのものではなく、インデックスを求める。(何番目が最小値であるかを返す)下記の[ここを書く]にコードを入力せよ。\n\n```\n\n def min_index(a,st):\n minidx=st # 先頭の要素のインデックスを最小値のインデックスとする\n for i in range(st+1,len(a)) # i番目のほうが最小値よりも小さいなら\n if[ここを書く]: # iを最小値のインデックスをする\n minidx = i\n return[ここを書く]\n \n```\n\n先ほど挙げた実行例は別のプログラムでした、すみません! \nこの問題の実行例は載っていませんでした。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T03:42:13.653", "favorite_count": 0, "id": "56240", "last_activity_date": "2019-07-04T06:43:50.430", "last_edit_date": "2019-06-30T09:03:20.307", "last_editor_user_id": "19110", "owner_user_id": "34911", "post_type": "question", "score": 0, "tags": [ "python" ], "title": "最小値のインデックスを求めたい", "view_count": 451 }
[ { "body": "問題文は「配列aのst番目から最後の要素」という事だと思います。 \nまた、for文の文末には:が必要です。\n\n```\n\n def min_index(a,st):\n minidx=st # 先頭の要素のインデックスを最小値のインデックスとする\n for i in range(st+1,len(a)): # i番目のほうが最小値よりも小さいなら\n if a[i] < a[minidx]: # iを最小値のインデックスをする\n minidx = i\n return minidx\n \n```", ...
56240
null
56257
{ "accepted_answer_id": "56244", "answer_count": 1, "body": "**Q1.600×335の比率を計算すると、16:9にならないのですが、どういう意味ですか?**\n\n> 画像サイズ: 横600×縦335ピクセル以上 \n> 縦横比: 横16:縦9 \n> [単一の画像付きツイートおよびGIF画像](https://business.twitter.com/ja/help/campaign-\n> setup/advertiser-card-specifications.html)\n\n* * *\n\n**Q2.上記リンク先の(翻訳前)原文ページを確認する方法はありますか?** \njaをenへ変更しても、リダイレクトされてしまいます \n<https://business.twitter.com/en/help/campaign-setup/advertiser-card-\nspecifications.html>", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T04:15:33.967", "favorite_count": 0, "id": "56241", "last_activity_date": "2019-06-30T07:19:53.110", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "twitter" ], "title": "単一の画像付きツイートの画像サイズについて", "view_count": 64 }
[ { "body": "A1. あくまで「以上」の推奨値なので、16:9ぴったりである必要は無いのではないでしょうか (モバイル端末を意識した値と書いてありますよね)。\n\nA2. ページを開いたフッタ(最下段)に「言語」というメニューがあるので、ここからEnglishを選択すれば切り替わります。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T07:19:53.110", "id": "56244", "last_activity_date": "201...
56241
56244
56244
{ "accepted_answer_id": "56250", "answer_count": 1, "body": "<http://uu-hokkaido.cedars.jp/renewal.shtml>\n\nこちらのメインビジュアルの北海道の地図の上のピンクの丸をクリックすると、 \n濃いピンクの色が、マウスを丸から移動しても維持し続けるようにするにはどうすればよいでしょうか?\n\n今は、:hoverにしていますが、 \n:active \n:focus \n:focus-within \n:visited\n\n全部試しましたが上手くいきませんでした。\n\nお分かりになる方いましたら、ご教授願います。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T05:35:00.093", "favorite_count": 0, "id": "56242", "last_activity_date": "2019-06-30T08:14:07.657", "last_edit_date": "2019-06-30T07:41:16.873", "last_editor_user_id": "34913", "owner_user_id": "34913", "post_type": "question", "score": 0, "tags": [ "html", "css" ], "title": "クリックしたら、色の変化を維持したい。", "view_count": 5657 }
[ { "body": "`:focus` 擬似クラスによって、フォーカスを持っている要素に対して装飾を行うことが出来ます。\n\nここで、要素がフォーカス可能な領域となるためには、\n**以下の条件を満たす必要があります**[[1]](https://html.spec.whatwg.org/multipage/interaction.html#data-\nmodel)。実際は別の条件によってもフォーカス可能な要素となり得ますが、今回は紹介しません。\n\n * 該当の要素にタブインデックスフォーカスフラグがセットされている\n * 該当の要素がレンダリングされているか、関連するキャンバスフォールバックコンテンツ...
56242
56250
56250
{ "accepted_answer_id": "56248", "answer_count": 1, "body": "いつもお世話になっています。 \n下記の質問についてご存知の方がいらっしゃいましたら、ご教示を願います。\n\n* * *\n\n## 【質問の主旨】\n\n[GitHub](https://github.com/echizenyayota/ch6/blob/developer/scripts/es5_class3.js)にUPしたコードではAnimalクラス内で条件文を使用しています。そのうち\n\n```\n\n if (!(this instanceof Animal)) {\n return new Animal(name);\n }\n \n```\n\n上記のコードを使ってコンソール画面を表示させると、以下の結果が表示されます。\n\n```\n\n トクジロウ\n Animal: トクジロウ\n \n```\n\n```\n\n if (!(this === instanceof Animal)) {\n return new Animal(name);\n }\n \n```\n\n一方、上記のコードを用いると下記のエラーが表示されます。\n\n```\n\n Uncaught SyntaxError: Unexpected token instanceof\n \n```\n\n両者の間において結果に差が出るのはなぜでしょうか?\n\n## 【質問の補足】\n\n### 1.\n\n公式ドキュメントで[instanceof](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/instanceof)の用例を確認すると、\n\n```\n\n function Car(make, model, year) {\n this.make = make;\n this.model = model;\n this.year = year;\n }\n \n var auto = new Car('Honda', 'Accord', 1998);\n console.log(auto instanceof Car);\n \n```\n\nという感じでinstanceof演算子の前に、オブジェクトを記述するという用例があります。ただし今回の質問で使っている`this`については特別に何かを定義している感じがしません。\n\n### 2.\n\n個人的な予測ですが今回の質問で使われている`this`は、グローバルオブジェクトを表す特殊なキーワードではないかと推測しています。もしthisがグローバルオブジェクトであるならば、`this\n=== instanceof Animal`としても条件式として文法的に正しい表現をしていると思います。\n\n* * *\n\n以上、ご確認よろしくお願い申し上げます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T07:33:37.930", "favorite_count": 0, "id": "56247", "last_activity_date": "2019-06-30T07:55:16.137", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32232", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "\"this instanceof Animal\" と \"this === instanceof Animal\" の差を教えてください", "view_count": 82 }
[ { "body": "`instanceof`は二項演算子なので、文法上の扱いは`*`などと同じです。よって`hoge === *\n3`がSyntaxErrorになるのと同じ理由で、`this === instanceof Animal`もSyntaxErrorとなります。\n\n参考:\n<https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/instanceof>", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_...
56247
56248
56248
{ "accepted_answer_id": "56252", "answer_count": 1, "body": "```\n\n let Car = function(num, gas) {\n this.num = num;\n this.gas = gas;\n };\n \n Car.prototype = {\n getInfo: function() {\n return '車のナンバーは' + this.num + 'です。ガソリン量は' + this.gas + 'です。';\n }\n };\n \n let RacingCar = function(course) {\n Car.call(this, 2345, 30);\n this.course = course;\n };\n \n RacingCar.prototype = new Car();\n \n RacingCar.prototype = {\n getCourse: function() {\n return 'コースは' + this.course + 'です。';\n }\n };\n \n let rccar = new RacingCar(5);\n console.log(rccar.getInfo());\n console.log(rccar.getCourse());\n \n```\n\n上記のコードを実行すると、\n\n> TypeError: rccar.getInfo is not a function\n\nとエラーが出るのですが、何故プロトタイプチェーンが効かないのでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T08:18:12.487", "favorite_count": 0, "id": "56251", "last_activity_date": "2019-06-30T09:01:33.823", "last_edit_date": "2019-06-30T08:22:26.503", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "JavaScriptのプロトタイプチェーンについて", "view_count": 57 }
[ { "body": "`RacingCar.prototype` に対して **`new Car` を代入した直後で `getCourse`\nメソッドを持つオブジェクトを代入している**ためです。\n\n```\n\n {\n let Car = function(num, gas) {\n this.num = num;\n this.gas = gas;\n };\n \n Car.prototype = {\n getInfo: function() {\n return '車のナンバーは' + this.n...
56251
56252
56252
{ "accepted_answer_id": "56281", "answer_count": 2, "body": "STSの「Springスタータープロジェクト」を作成して、実行すると①の画面表示して送信ボタンを押すと次のエラーが表示されます。 \n同じ端末にOracleとTOMCATがインストールしているためTOMCATのポートを8081に変更して実行しています。 \n何が原因したエラーなのでしょうか?\n\n【エラーメッセージ】\n\n> Whitelabel Error Page \n> This application has no explicit mapping for /error, so you are seeing this\n> as a fallback.\n>\n> There was an unexpected error (type=Not Found, status=404). \n> No message available\n\n【①index.html】\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n <title>Hello Page</title>\n </head>\n <body>\n <form method=\"post\" action=\"/result\">\n 名前を入力してください<br>\n <input type=\"text\" name=\"inputvalue\"/>\n <input type=\"submit\" value=\"送信\" />\n </form>\n </body>\n </html>\n \n```\n\n【②result.html】 \n\n```\n\n <html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n <title>Hello Page2</title>\n </head>\n <body>\n 入力した値はこちらです!\n <p th:text=\"${message}\"></p>\n </body>\n </html>\n \n```\n\n【③HelloSpringBootWebController.java】\n\n```\n\n package com.example.demo;\n import org.springframework.stereotype.Controller;\n import org.springframework.web.bind.annotation.RequestMapping;\n import org.springframework.web.bind.annotation.RequestMethod;\n import org.springframework.web.bind.annotation.RequestParam;\n import org.springframework.web.servlet.ModelAndView;\n \n @Controller\n public class HelloSpringBootWebController {\n @RequestMapping(value=\"/\", method=RequestMethod.GET)\n public ModelAndView index(ModelAndView mv) {\n mv.setViewName(\"index\");\n return mv;\n }\n \n @RequestMapping(value=\"/result\", method=RequestMethod.POST)\n public ModelAndView send(@RequestParam(\"inputvalue\")String inputvalue, ModelAndView mv) {\n mv.setViewName(\"result\");\n mv.addObject(\"message\", inputvalue);\n return mv;\n }\n }\n \n```\n\n【ファイルの格納先】 \nsrc/main/resources/templates/index.html \nsrc/main/resources/templates/result.html \nsrc/main/java/com/example/demo/HelloSpringBootWebController.java\n\n【環境】\n\n * spring-tool-suite-3.9.8\n * JDK12\n * Oracle11g\n * Win10\n\n【エラーが出ています。】 \n[![Porn.xmlにエラー](https://i.stack.imgur.com/1usdd.png)](https://i.stack.imgur.com/1usdd.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T09:21:41.517", "favorite_count": 0, "id": "56255", "last_activity_date": "2020-02-22T05:23:10.763", "last_edit_date": "2020-02-22T05:23:10.763", "last_editor_user_id": "3060", "owner_user_id": "34875", "post_type": "question", "score": 0, "tags": [ "java", "spring-boot" ], "title": "STS Springスタータ-プロジェクト 404エラー", "view_count": 8117 }
[ { "body": "考えられる一つの原因は、`@SpringBootApplication`のアノテーションを付与したクラスを格納したパッケージが`com.example.demo`や`com.example`ではないことですかね。このクラスのパッケージ配下に`HelloSpringBootWebController`が無いので、コンポーネントスキャンの対象にならないのではないかと予想しました。それでも`index.html`が表示されるのは、実は別のController経由で呼びだされているだけとか。", "comment_count": 3, "content_license": "CC BY-...
56255
56281
56266
{ "accepted_answer_id": "56261", "answer_count": 1, "body": "<http://uu-hokkaido.cedars.jp/renewal.shtml>\n\nこちらのサイトのメインビジュアルの北海道の地図の丸いピンクをクリックすると、\n\n地図の周りの左右8個の要素が変化します。\n\n例:\n\n札幌〇クリック \n⇒函館〇クリック \n⇒人気観光スポット(左一番上)クリック \n⇒札幌の人気観光スポットのURLになってしまいます。(函館の人気観光スポットのURLへ飛びたいです。)\n\n例えば、まず札幌の丸をクリックし、そのあと函館の丸をクリックしても、\n\n地図の周りの左右8個の要素が変化しません。\n\n函館を一番初めにクリックすると、ちゃんと地図の周りの左右8個の要素が函館のURLになってくれるのですが、 \n2回目にクリックすると、地図の周りの左右8個の要素が1回目のままで変わってくれません。\n\n地図の周りの左右8個の要素が、クリックされるたびに、クリックした地域に変更するには、どのようにすればよいでしょうか?\n\nお分かりになる方いらっしゃいましたら、ご教授よろしくお願います。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T10:28:46.427", "favorite_count": 0, "id": "56260", "last_activity_date": "2019-06-30T10:55:22.677", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34913", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "css" ], "title": "2回目のクリックで要素が変化しない。", "view_count": 94 }
[ { "body": "8 個の要素が奇妙な動作をする原因は、一度 `visibility` プロパティの値が一度 visible になった要素は、 **フォーカスが外れた状態でも\nvisible のまま**\nであるためです。これを解決するためには、「北海道の地図の丸いピンク」をクリックしたときに「それ以外のピンクの項目をクリックしたときに出現する左右 8\n個の要素」を非表示に戻さなければなりません。\n\nこれは恐らく、質問文ページ内に含まれている `show` 関数を以下のように修正することで、この問題は解決すると思います。\n\n```\n\n function show(course) {\n ...
56260
56261
56261
{ "accepted_answer_id": "56264", "answer_count": 1, "body": "<http://uu-hokkaido.cedars.jp/renewal.shtml>\n\nこちらのサイトのメインビジュアルで、北海道の地図の上の札幌の上のピンクの丸をクリックすると、\n\n・地図の左右にある8つの要素の変更。(これはできました。) \n・北海道人気観光8エリアの文字を変更(これも変更したいです。)\n\nをしたいです。\n\n札幌の上のピンクの丸に、 \nonclick=\"show('sapporo')を入れて、\n\n上記2つにclass=\"sapporo\"にすると、 \n1つしか変更されませんでした。\n\n試しに \n・地図の左右にある8つの要素 class=\"sapporo\" \n・北海道人気観光8エリアの文字 class=\"sapporo2\" と分けて、\n\n札幌の上のピンクの丸に、 \nonclick=\"show('sapporo','sapporo2')などいれると無効になりました。\n\n札幌の上のピンクの丸をクリックすると、\n\n・地図の左右にある8つの要素の変更。(これはできました。) \n・北海道人気観光8エリアの文字を変更(これも変更したいです。)\n\nこれを2つ同時に変更したいのですが、わかる方ご教授お願い致します。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T11:21:14.850", "favorite_count": 0, "id": "56263", "last_activity_date": "2019-06-30T11:49:45.683", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34913", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "css" ], "title": "クリックして、2つの要素を同時に変更したい。", "view_count": 118 }
[ { "body": "`show` 関数にはどの要素を表示したいのかが引数として渡されるため、その値が札幌だった場合にのみ見出しのテキスト内容を `textContent`\nプロパティを用いて変更すれば良いと思います。\n\n```\n\n function show(course) {\n document\n .querySelectorAll(\".container_mainvisual > div[id]\")\n .forEach(e => (e.style.visibility = \"hidden\"));\n document.getEleme...
56263
56264
56264
{ "accepted_answer_id": null, "answer_count": 1, "body": "Ruby初心者です。以下のようなロジックで、`each do`の中でDBを参照しようとしています。\n\nmaxrating変数にUear_Ratingテーブルでratingがmaxとなる値をとって、それと事前にとっておいたbooksテーブルのidを使ってwhere条件でレコードを取得しようとしていますが、どうしても結果が最後に取得したレコードだけとなってしまいます。とても基本的な事だと思いますが、よくわからず困っていますので、解決方法を教えてください。\n\n```\n\n @books.each do |sb|\n  maxrating = User_Rating.where(book_id: sb.id).maximum(:rating)\n @search_result = User_Summary.joins('LEFT OUTER JOIN Books ON user_summaries.book_id = books.id').joins('LEFT OUTER JOIN user_ratings ON user_summaries.id = user_ratings.user_summary_id').where(\"user_summaries.book_id = #{sb.id}\").where(\"user_ratings.rating = #{maxrating}\").select('User_Summaries.comment, User_Ratings.rating')\n end\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T12:06:38.800", "favorite_count": 0, "id": "56265", "last_activity_date": "2019-06-30T13:52:11.197", "last_edit_date": "2019-06-30T12:14:44.643", "last_editor_user_id": "32986", "owner_user_id": "34920", "post_type": "question", "score": 1, "tags": [ "ruby", "sinatra" ], "title": "each doの処理の中でDBを参照する場合", "view_count": 256 }
[ { "body": "```\n\n (1..10).each do |i|\n @result = i\n end\n \n```\n\nというコードに置き換えてみれば何が起きているのかわかるのではないでしょうか。取り出されるのは最後の`i`の値(=10)だけで、1~9はループのたびに次の`i`で上書きされ消えてしまっています\n\nすべての値がほしいなら、例えば\n\n```\n\n @result = []\n (1..10).each do |i|\n @result << i #書き方はほかにも\n end\n \n```\n\nなどと...
56265
null
56267
{ "accepted_answer_id": "56270", "answer_count": 1, "body": "お世話になります。 \nArmadillo-IoT\nG3(Linux9(stretch))をgcc7へアップグレードしたいのですが、Debianの公式サイトで公開されているdebファイルをdpkgコマンドで手動で行ったところ、設定中の表示が出てそのまま終わってしまい、またaptitudeコマンドで自動で行おうとしたものの今度はgcc-7が見つからないと言われました。\n\nArmadillo-IoT G3でgcc7へアップグレードされた方いましたらご教示ください。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-06-30T14:04:57.043", "favorite_count": 0, "id": "56268", "last_activity_date": "2019-06-30T17:21:59.170", "last_edit_date": "2019-06-30T17:21:00.387", "last_editor_user_id": "3060", "owner_user_id": "34921", "post_type": "question", "score": 0, "tags": [ "linux", "debian" ], "title": "Armadillo-IoT G3をgcc7へアップグレードする方法", "view_count": 72 }
[ { "body": "stretchは現在 **安定版 (stable)** ですが、gcc-7は **buster (testing)** か **sid\n(unstable)** 以降で提供されているようです。\n\n[Debian パッケージ検索結果 --\ngcc-7](https://packages.debian.org/search?suite=all&arch=any&searchon=names&keywords=gcc-7)\n\nそのままではstableにインストール出来ないので、testing/unstableのミラーサーバをsources.listに追加し、指定パッケージの優先度を設定する...
56268
56270
56270
{ "accepted_answer_id": null, "answer_count": 0, "body": "こんにちは。 \nレガシーな(.NET Framework+SQL Server+WinFrom)ローカルアプリをWPF化しています。 \nその中で、機能拡張や導入ユーザ別のカスタマイズなどが発生しており、データベースの定義情報や設定などの初期データの管理方法でどのようなツール?概念?を使えばよいか困っています。\n\n新規から作成のWebアプリの場合、EntityFrameworkを使い、Code First(もしくは、Model First、DB\nFirst)で複数人(10~20人程度)での開発をやってきました。\n\nしかし、今回は、DBが8割できており、Entityの定義はないという条件下で、アジャイル的な変更をチームでかけていきたいのですが、うまくスムーズな共有と開発同期や開発環境の切替などが出来ずにこまっております。\n\n一人で開発をする場合は、個別にローカルのDBにクエリを当てて管理することが出来るのですが、、、多人数で管理するとなると共有の仕組み、切替の仕組みが必要になると考えています。\n\nどのようなよいプラクティス、ツールがありますでしょうか?\n\n考えているのが、Ruby on RailsのDB管理の仕組みを自分で作る?(VersionUP/Down) \nもしくは、もっと、単純に適応するクエリをフォルダにバージョンをつけて入れておき、 \n最新のバージョンになるまで適応する管理を行う?(最新ソースの取得して実行する。)\n\nなどで考えています。\n\n# 環境\n\n * Visual Studio 2015~2019\n * SQL Server 2016~2017\n * WPFアプリ\n * ソース管理 git", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T01:20:23.850", "favorite_count": 0, "id": "56273", "last_activity_date": "2019-07-01T02:28:30.653", "last_edit_date": "2019-07-01T02:28:30.653", "last_editor_user_id": "29826", "owner_user_id": "34923", "post_type": "question", "score": 1, "tags": [ "visual-studio", "sql-server", "entity-framework" ], "title": "Visual StudioとSQL Serverで複数人で開発する際のデータベースの定義や初期データの管理方法について", "view_count": 331 }
[]
56273
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "iS110Bを挿入し、MQTTで信号を送受信したいと思っています。 \nこれにつき、セットアップや実装に役立つサイトがあれば教えていただけないでしょうか。\n\n宜しくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T02:51:03.577", "favorite_count": 0, "id": "56275", "last_activity_date": "2019-07-03T01:30:25.470", "last_edit_date": "2019-07-02T01:09:48.057", "last_editor_user_id": "34924", "owner_user_id": "34924", "post_type": "question", "score": 0, "tags": [ "spresense" ], "title": "SPRESENSE Wi-Fi Add-onボード iS110Bの使い方", "view_count": 600 }
[ { "body": "<https://github.com/jittermaster/GS2200-WiFi/blob/master/Documents/GS2200_MQTT-001.pdf>\n\nこういったものがあるようです。 \nちなみに、他のサイトは自分も探してみたのですが、現時点でなさそうです。\n\nそれと、もともと質問されていた、ハンドサインAIの情報は、ここで見つけました。 \n<https://www.rs-online.com/designspark/sony-spresense-ai-hand-sign-\nrecognition>", "comment_count": 1, ...
56275
null
56333
{ "accepted_answer_id": "56279", "answer_count": 2, "body": "お世話になります。 \nPython3.7でプログラムを作成していますが、ログ機能を導入しようとしてつまずいています。 \nとりあえず、例として、下記のようなプログラムを作成して、ログをファイルに出力しようとしているのですが、ログが出力されず、困っております。 \nどこが問題なのか、よければ教えていただけないでしょうか。 \nなお、ソースコードは2つに分かれていますが、両方ともログが出力されない状況です。 \nよろしくお願いいたします。\n\n## ソースコード\n\n### test1.py\n\n```\n\n import logging\n from logging import getLogger, FileHandler, Formatter\n from test2 import *\n \n def main():\n print(\"start\")\n log = getLogger(\"test1\")\n log.info(\"main initialized.\")\n ret=test2()\n log.info(\"result=%d\" % ret)\n log.info(\"finished.\")\n print(\"result=%d\" % ret)\n print(\"finished\")\n \n def log_init():\n hLogHandler=FileHandler(\"testapp.log\", mode=\"w\", encoding=\"UTF-8\")\n hLogHandler.setLevel(logging.DEBUG)\n hLogFormatter=Formatter(\"%(levelname)s - %(name)s (%(asctime)s.%(msecs)03d):\\n%(message)s\", \"%H:%M:%S\")\n hLogHandler.setFormatter(hLogFormatter)\n log = getLogger(\"logger\")\n log.setLevel(logging.DEBUG)\n log.addHandler(hLogHandler)\n \n if __name__ == \"__main__\":\n log_init()\n main()\n \n```\n\n### test2.py\n\n```\n\n import logging\n from logging import getLogger, FileHandler, Formatter\n \n def test2():\n log = getLogger(\"test2\")\n log.setLevel(logging.DEBUG)\n log.info(\"test2 initialized.\")\n ret=1*2*3*4*5\n log.info(\"finished.\")\n return ret\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T02:59:37.613", "favorite_count": 0, "id": "56276", "last_activity_date": "2019-07-01T04:28:59.327", "last_edit_date": "2019-07-01T04:28:59.327", "last_editor_user_id": "3060", "owner_user_id": "29034", "post_type": "question", "score": 0, "tags": [ "python", "python3" ], "title": "Pythonのログ機能に関して", "view_count": 228 }
[ { "body": "`getLogger` で取得したロガーがそれぞれ異なっているのが問題です。 一旦以下のようにすることで `test1` 内部のログを取得可能です。\n\nまた、 `test2` についても、モジュールとして構成する場合は通常 `__name__` として参照することで同様にログを出力することが可能です。\n\n```\n\n import logging\n from logging import getLogger, FileHandler, Formatter\n \n def main():\n print(\"start\")\n l...
56276
56279
56278
{ "accepted_answer_id": null, "answer_count": 1, "body": "今はこういう状態ですが\n\n```\n\n $body .= '<select name=\"number\" id=\"';\n //コンボボックス内容が変えた時 onchangeのfunctionが実行\n $body .= $row[\"ID\"] . '\" onchange=\"changeNumber( this );\" >';\n //数量を数値に変換する\n $qty = (int) $row[\"quantity\"];\n \n for ($number = 0; $number <= 10; $number++) {\n $body .= '<option ';\n \n if ($number == $qty) {\n $body .= ' selected value=\"' . $number . '\">' . $number . '</option>';\n } else {\n $body .= ' value=\"' . $number . '\">' . $number . '</option>';\n }\n }\n \n $body .= '</select>';\n \n```\n\n`input type=\"text\" name=number value=\"??\"`がわかりません。。。。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/KRuzh.png)](https://i.stack.imgur.com/KRuzh.png)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T05:14:48.087", "favorite_count": 0, "id": "56280", "last_activity_date": "2019-07-01T06:40:01.953", "last_edit_date": "2019-07-01T06:40:01.953", "last_editor_user_id": "3060", "owner_user_id": "34775", "post_type": "question", "score": 0, "tags": [ "php", "html" ], "title": "カート画面のセレクトボックスをテキストボックスに変更したい", "view_count": 159 }
[ { "body": "余談ですが、HTMLではコンボボックスではなく「セレクトボックス」と呼ぶことの方が多いと思います。\n\n* * *\n\n既存のコードだと`<select>`で選択肢を選ばせていますが、これをテキストボックスでの任意入力にさせたいということであれば、以下のHTMLを出力するようにすればよさそうです。\n\n```\n\n <input type=\"text\" name=\"number\">\n \n```\n\n表示されたHTMLに入力された値が`value`として送信されるので、HTMLを出力するタイミングでは \n`<input type=\"text\" value=...
56280
null
56282
{ "accepted_answer_id": null, "answer_count": 0, "body": "ヒープを作成しようとしています \n要素xを挿入するinsert()を完成させたいのですが \n何を書き加えればよいでしょうか\n\n```\n\n include <stdio.h> //printf,ramd用\n include <stdlib.h> \n include <string.h> \n include <time.h> \n define INIARRYSIZE 1 \n int* pA; \n int sA; \n int size; \n \n void create()\n {\n sA = INIARRYSIZE; //配列の現在サイズを初期化\n if((pA = (int*)malloc(sizeof(int)*sA))==0) exit(1);\n size=0; //記憶中のデータ個数を初期化\n }\n \n void insert(int x)\n {\n if(size==sA-1)\n {\n int* oldpA = pA;\n sA = sA*2;\n if((pA=(int*)malloc(sizeof(int)*sA))==0) exit(1);\n memcpy(pA, oldpA, sizeof(int)*(size+1));\n free(oldpA);\n }\n size++;\n pA[size]=x;\n printf(\"%d\",size);\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T08:36:25.347", "favorite_count": 0, "id": "56289", "last_activity_date": "2019-07-01T08:38:23.683", "last_edit_date": "2019-07-01T08:38:23.683", "last_editor_user_id": "3060", "owner_user_id": "34931", "post_type": "question", "score": 0, "tags": [ "c" ], "title": "動的配列によるヒープの実現", "view_count": 167 }
[]
56289
null
null
{ "accepted_answer_id": "56305", "answer_count": 1, "body": "一行が長くて表示が隠れてしまっているときに、 \nどうすれば折り返せるでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T12:17:21.243", "favorite_count": 0, "id": "56292", "last_activity_date": "2019-07-01T21:10:40.520", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12896", "post_type": "question", "score": 0, "tags": [ "untagged" ], "title": "tig で diff view を開いたとき、一行が長いときの表示", "view_count": 108 }
[ { "body": "`~/.tigrc` (あるいは `~/.config/tig/config`) に以下の設定を追加してください。\n\n```\n\n set wrap-lines = yes\n \n```\n\n行の折り返しはデフォルトでは無効化されています。 \n詳しくはマニュアルを参照してください <https://jonas.github.io/tig/doc/tigrc.5.html>\n\n余談ですが、折り返しがない状態でも左右矢印キー (`<Left>`, `<Right>`) に割り当てられている \n列スクロールを利用すれば隠れている行を見ることができます。", "...
56292
56305
56305
{ "accepted_answer_id": null, "answer_count": 1, "body": "### 前提・実現したいこと\n\nRuby on\nRailsを使ってアプリを開発していた際にgithubを通してHerokuにデプロイしていたのですが,ある時誤まってherokuのappを消してしまいました. \nそこで新しくappを作り直し,git remote set-url heroku URL を打ち込んでpush先を変えてgit push heroku\nmaster を打ち込んだら以下のようなエラーメッセージが出ました.\n\n### 発生している問題・エラーメッセージ\n\n```\n\n (base) mbp:hello hoge$ git push heroku master\n Enumerating objects: 87, done.\n Counting objects: 100% (87/87), done.\n Delta compression using up to 4 threads\n Compressing objects: 100% (72/72), done.\n Writing objects: 100% (87/87), 22.64 KiB | 2.26 MiB/s, done.\n Total 87 (delta 2), reused 0 (delta 0)\n remote: Compressing source files... done.\n remote: Building source:\n remote: \n remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.\n remote: Detected buildpacks: Ruby,Node.js\n remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order\n remote: -----> Ruby app detected\n remote: -----> Compiling Ruby/Rails\n remote: -----> Using Ruby version: ruby-2.5.5\n remote: -----> Installing dependencies using bundler 2.0.2\n 省略\n remote: * For more details, please refer to the Sass blog:\n remote: https://sass-lang.com/blog/posts/7828841\n remote: \n remote: Bundle completed (51.26s)\n remote: Cleaning up the bundler cache.\n remote: -----> Installing node-v10.15.3-linux-x64\n remote: -----> Detecting rake tasks\n remote: \n remote: !\n remote: ! Could not detect rake tasks\n remote: ! ensure you can run `$ bundle exec rake -P` against your app\n remote: ! and using the production group of your Gemfile.\n remote: ! Activating bundler (2.0.1) failed:\n remote: ! Could not find 'bundler' (2.0.1) required by your /tmp/build_cf0cee9dff2cef20e79c0cb16f784873/Gemfile.lock.\n remote: ! To update to the latest version installed on your system, run `bundle update --bundler`.\n remote: ! To install the missing version, run `gem install bundler:2.0.1`\n remote: ! Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information\n remote: ! \n remote: ! To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`\n remote: !\n remote: /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/rake_runner.rb:106:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)\n remote: ensure you can run `$ bundle exec rake -P` against your app\n remote: and using the production group of your Gemfile.\n remote: Activating bundler (2.0.1) failed:\n remote: Could not find 'bundler' (2.0.1) required by your /tmp/build_cf0cee9dff2cef20e79c0cb16f784873/Gemfile.lock.\n remote: To update to the latest version installed on your system, run `bundle update --bundler`.\n remote: To install the missing version, run `gem install bundler:2.0.1`\n remote: Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information\n remote: \n remote: To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'`\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/ruby.rb:866:in `rake'\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/rails4.rb:84:in `block (2 levels) in run_assets_precompile_rake_task'\n 省略\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/base.rb:44:in `instrument'\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/rails4.rb:40:in `compile'\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/bin/support/ruby_compile:20:in `block (2 levels) in <main>'\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/base.rb:134:in `log'\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/bin/support/ruby_compile:19:in `block in <main>'\n 省略\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:35:in `trace'\n remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/bin/support/ruby_compile:15:in `<main>'\n remote: ! Push rejected, failed to compile Ruby app.\n remote: \n remote: ! Push failed\n remote: Verifying deploy...\n remote: \n remote: ! Push rejected to shrouded-ocean-42963.\n remote: \n To https://git.heroku.com/shrouded-ocean-42963.git\n ! [remote rejected] master -> master (pre-receive hook declined)\n error: failed to push some refs to 'https://git.heroku.com/shrouded-ocean-42963.git'\n \n```\n\n### 試したこと\n\n仕方ないので,新しくプロジェクトを書き直して新しいgitのリポジトリからherokuにデプロイしようとしても再び **同じようなエラー** が出ました. \nさらに,herokuのアカウントも作り直して,rails newしたばかりのプロジェクトをherokuにあげるという誰がやってもデプロイできるという状況でも\n**同じエラー** が出ます", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T12:27:02.160", "favorite_count": 0, "id": "56293", "last_activity_date": "2019-07-04T02:07:51.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34935", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails", "git", "heroku", "github" ], "title": "Herokuにデプロイできなくなりました", "view_count": 650 }
[ { "body": "```\n\n remote: -----> Installing dependencies using bundler 2.0.2\n \n```\n\nとなっているので、heroku上ではbundler 2.0.2がインストールされているようです。そのあとのログで\n\n```\n\n remote: ! Could not detect rake tasks\n remote: ! ensure you can run `$ bundle exec rake -P` against your app\n remote: ! and...
56293
null
56365
{ "accepted_answer_id": "56296", "answer_count": 1, "body": "c#初心者です。\n\nstring\nButtonBase.Textというデータ型のオブジェクト(1次元のリスト)を列方向にcsv出力したいのですが、StreamWriterを使うと行方向に出力されてしまいます。\n\nオブジェクトの転置も考えましたがなかなかうまくいかず困っています。\n\n列方向に(右に)出力できればなんでもいいのですが、どなたか解決できそうな方はいらっしゃいますか?\n\n追記:回答ありがとうございます。String.Join\nMethodを使って、カンマ区切りで文字列を連結してみましたが、やはり行方向(下)に出力されてしまいます。\n\n下記が該当コードです。よろしければ、目を通していただけますか?昨日から初めてC#を使い始めたので、理解が追い付いていないまま書いているところもあります。ご了承ください。\n\n```\n\n private void radioButton1_CheckedChanged(object sender, EventArgs e)\n {\n // 指定した複数のグループ内のラジオボタンでチェックされている物を全部取り出す\n var RadioButtonCheckedAll_InGroups = new[] { groupBox3, groupBox4, groupBox6, groupBox8, groupBox10, groupBox11, groupBox12, groupBox13, }\n .SelectMany(g => g.Controls.OfType<RadioButton>()\n .Where(r => r.Checked));\n \n // 結果\n foreach (var rb in RadioButtonCheckedAll_InGroups ?? new RadioButton[0])\n {\n \n string tempString = String.Join(\",\",rb.Text);\n \n // ファイルを書き込みモード(上書き)で開く\n StreamWriter file = new StreamWriter(\"survey.csv\", true, Encoding.UTF8);\n // ファイルに書き込む\n file.WriteLine(tempString);\n // ファイルを閉じる\n file.Close();\n }\n }\n \n```", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T12:44:36.763", "favorite_count": 0, "id": "56294", "last_activity_date": "2019-07-02T11:53:13.790", "last_edit_date": "2019-07-02T07:08:25.920", "last_editor_user_id": "34501", "owner_user_id": "34501", "post_type": "question", "score": 0, "tags": [ "c#" ], "title": "C#のCSV書き込みについて", "view_count": 1645 }
[ { "body": "最初にソースが提示されていれば、全然違う答えになっていましたね。\n\n原因は`foreach`ループの中で処理しているからです。\n\nソースの`foreach`ループでは、RadioButtonコントロールが1個づつ選択されて処理されます。\n\nそのため、その中でCSVを作成して`WriteLine`でファイルに書くと、1個につき1行書かれます。 \nそれでは、質問のように、行方向に出力されることになります。\n\n`foreach`ループの前にstringのList変数を宣言・初期化しておき、`foreach`ループの中では、そのListにTextをAddしていく処理だけ行って、ループ...
56294
56296
56296
{ "accepted_answer_id": null, "answer_count": 1, "body": "変数の制約付きで関数を最小化するため, scipy.optimize.minimizeで以下のようにL-BFGS-Bを指定しました\n\n```\n\n import scipy.optimize as opt\n \n bounds = opt.Bounds(#np.ndarray, #np.ndarray)\n result = opt.minimize(loss_f, x0_ft, method='L-BFGS-B', jac=f_grad, \n bounds=bounds, tol=10e-6, options={'maxiter': 100, 'disp': True})\n \n```\n\nこのとき, `failed to initialize intent(inout) array -- expected elsize=8 but got\n4`のエラーが発生し, 実行できません\n\n`method`に他のものを指定したときは正しく実行でき, L-BFGS-Bのときだけこのエラーが発生します\n\n解決法など知っている方がいましたら教えていただきたいです\n\npython 3.6.8 \nscipy:1.3.0 \n以下出力\n\n```\n\n RUNNING THE L-BFGS-B CODE\n \n * * *\n \n Machine precision = 2.220D-16\n N = 9 M = 10\n \n At X0 0 variables are exactly at the bounds\n # ここまで標準出力\n \n # ここからエラー出力\n Traceback (most recent call last):\n File \"main.py\", line 147, in <module>\n main()\n File \"main.py\", line 120, in main\n options={'maxiter': 100, 'disp': True})\n File \"略/scipy/optimize/_minimize.py\", line 600, in minimize\n callback=callback, **options)\n File \"略/scipy/optimize/lbfgsb.py\", line 328, in _minimize_lbfgsb\n isave, dsave, maxls)\n ValueError: failed to initialize intent(inout) array -- expected elsize=8 but got 4\n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T15:39:54.580", "favorite_count": 0, "id": "56299", "last_activity_date": "2020-04-04T05:01:30.220", "last_edit_date": "2019-07-02T09:32:53.383", "last_editor_user_id": "34886", "owner_user_id": "34886", "post_type": "question", "score": 3, "tags": [ "python", "scipy" ], "title": "scipy.minimizeでL-BFGS-Bのときだけエラーが出る", "view_count": 840 }
[ { "body": "自己解決しました. 目標関数とその勾配を返す関数 `loss_f`, `f_grad`が`np.float32`を返していたのですが,\nこれを`np.float64`を返すようにしたところ実行できました.\n\nそうするとエラーの`elsize`はバイト数を意味していたのかなと思います.\n\n対症療法的な解決方法ですが, 参考までに.", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T07:27:17.353", "id": "56344"...
56299
null
56344
{ "accepted_answer_id": "56330", "answer_count": 1, "body": "# 環境\n\n * Python 3.7\n * tox 3.13\n\n# 背景\n\n以下のツールを利用して、Pythonのパッケージを作成しています。\n\n * [yapf](https://github.com/google/yapf):Formatter\n * [isort](https://github.com/timothycrosley/isort):Formatter\n * [Pylint](https://www.pylint.org/):Lintter\n * [flake8](http://flake8.pycqa.org):Lintter\n * [tox](https://tox.readthedocs.io/en/latest/)\n\n上記のツールの設定情報は、可能な限り1つのファイルにまとめて記載したいです。 \nPylintとflake8の設定情報が互いに依存しているためです。例えば、「flake8では1行の文字数をチェックするから、pylintでは1行の文字数をチェックしない」などです。\n\n## Formatter, Lintterの設定\n\n[toxパッケージのtox.ini](https://github.com/tox-\ndev/tox/blob/master/tox.ini)には、flake8の設定情報が記載されています。\n\n```\n\n [flake8]\n max-complexity = 22\n max-line-length = 99\n ignore = E203, W503, C901, E402, B011\n \n```\n\n私はこれに倣って、`tox.ini`にFormatter, Lintterの設定情報を記載しようとしました。 \nしかし、yapfだけは`tox.ini`に記載した設定情報を読み込めません。コマンドライン引数で設定ファイルを指定できず、デフォルトでは`tox.ini`を読み込まないためです。 \n`setup.cfg`に記載した設定情報は読み込めます。 \n<https://github.com/google/yapf#id7>\n\nまた、pandasでは[setup.cfg](https://github.com/pandas-\ndev/pandas/blob/master/setup.cfg)にflake8, yapfの設定情報が記載されていました。 \n※tox.iniは存在しない\n\n以上のことから私は、Formatter, Linterの設定情報は`setup.cfg`に書いた方が良いと思いました。\n\n# 質問\n\nFormatter, Linterの設定は、`setup.cfg`か`tox.ini`どちらに記載すればよいですか?\n\nまた、`setup.cfg`と`tox.ini`はどう使い分ければよいですか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-01T17:43:29.130", "favorite_count": 0, "id": "56302", "last_activity_date": "2019-07-03T01:21:56.247", "last_edit_date": "2019-07-03T01:13:55.983", "last_editor_user_id": "19524", "owner_user_id": "19524", "post_type": "question", "score": 1, "tags": [ "python", "setuptools", "tox" ], "title": "setup.cfgとtox.iniの使い分け", "view_count": 421 }
[ { "body": "`setup.cfg` を参照するか `tox.ini` を参照するか、あるいは別のファイル `.pylintrc` や `pytest.ini`\nを参照するかは、各ライブラリによって任されています。\n\nこのため、それぞれのライブラリの組み合わせ次第では、「どちらを使えば良いか」ではなく「両方使う必要がある」かもしれません。\n\n今後は `pyproject.toml` に集約されていくのかもしれませんが、\n[flake8](https://pypi.org/project/flake8/) 等の一部のライブラリは現状 `pyproject.toml`\n未対応ですし、逆に [town...
56302
56330
56330
{ "accepted_answer_id": "56324", "answer_count": 1, "body": "**前提** \nアップロードか画像URLから画像を読み込み、表示し、画像にお絵描きができるツールを作っています。\n\n[動作サンプル](https://jsbin.com/vokohexoxe/1/edit?html,js,output)\n\n表示された画像をクリックするとパスを打つことができ、パスを3点以上打ってから1点目を打つとパスが閉じます。 \nパスを閉じた後の次のクリックは、リセットされ1点目になります。\n\n**問題点** \nリセットボタンを押すと画像が消えフォームの中身もクリアされますが、パスがクリアされません。 \nパスを打った後にリセットボタンを押し再度画像を読み込むと、リセット前に打ったパスが復活します。 \nなので、リセットボタンによってパスもクリアできるようにしたいです。\n\n**使用ライブラリ** \n・jQuery \n・Paper.js\n\n**ソースコード**\n\n```\n\n $(function () {\r\n \r\n //リセットボタン\r\n $('#close').click(function () {\r\n $('#view').fadeOut();\r\n $('#url')[0].value = '';\r\n $('#file')[0].value = '';\r\n $('#pen').value = '';\r\n });\r\n \r\n $('#url').change(function () {\r\n $('#view').fadeOut(1);\r\n $('#file')[0].value = '';\r\n $('#view').fadeIn();\r\n input(this.value);\r\n });\r\n $('#file').change(function () {\r\n $('#view').fadeOut(1);\r\n $('#url')[0].value = '';\r\n $('#view').fadeIn();\r\n var fr = new FileReader();\r\n fr.onload = function (e) {\r\n input(e.target.result);\r\n };\r\n fr.readAsDataURL(this.files[0]);\r\n });\r\n function input(e) {\r\n var img = new Image();\r\n img.onload = draw;\r\n img.src = e;\r\n }\r\n function draw(e) {\r\n var img = e.target;\r\n var imgcnv = $('#img');\r\n var imgH = 800;\r\n var imgW = img.naturalWidth * imgH / img.naturalHeight;\r\n imgcnv.attr('width', imgW);\r\n imgcnv.attr('height', imgH);\r\n var ctx = imgcnv[0].getContext('2d');\r\n ctx.drawImage(img, 0, 0, imgW, imgH);\r\n $('#img').width('100%');\r\n $('#img').height('100%');\r\n var penW = $('#img').width();\r\n var penH = $('#img').height();\r\n var pencnv = $('#pen');\r\n pencnv.attr('width', penW);\r\n pencnv.attr('height', penH);\r\n }\r\n });\n```\n\n```\n\n #view {\r\n display: none;\r\n }\r\n #draw {\r\n position: relative;\r\n }\r\n #img {\r\n border: 3px solid black;\r\n }\r\n #pen {\r\n position: absolute;\r\n cursor: crosshair;\r\n top: 0;\r\n left: 0;\r\n }\n```\n\n```\n\n <!DOCTYPE html>\r\n <html>\r\n <head>\r\n <meta charset=\"utf-8\">\r\n <meta name=\"viewport\" content=\"width=device-width\">\r\n <title>JS Bin</title>\r\n <script\r\n src=\"https://code.jquery.com/jquery-3.4.1.js\"\r\n integrity=\"sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=\"\r\n crossorigin=\"anonymous\"></script>\r\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.12.2/paper-full.js\"></script>\r\n </head>\r\n <body>\r\n <input id=\"url\" type=\"text\" placeholder=\"画像URLを貼付\">\r\n <input id=\"file\" type=\"file\" accept=\"image/*\">\r\n <div id=\"view\">\r\n <div id=\"draw\">\r\n <canvas id=\"img\"></canvas>\r\n <script type=\"text/paperscript\" canvas=\"pen\">\r\n var hitOptions = Object.seal({\r\n segments: true,\r\n stroke: false,\r\n fill: false,\r\n tolerance: 10\r\n });\r\n var path = null;\r\n function onMouseDown(e) {\r\n var hitSeg = project.hitTest(e.point.clone(), hitOptions);\r\n var isClose = path != null\r\n && path.segments.length > 2\r\n && hitSeg\r\n && hitSeg.type === 'segment'\r\n && hitSeg.item.firstSegment === hitSeg.segment;\r\n if (isClose) {\r\n path.closed = true;\r\n path = null;\r\n return false;\r\n }\r\n if (path == null) {\r\n path = new Path();\r\n path.selected = true;\r\n path.add(e.point);\r\n }\r\n else {\r\n path.add(e.point);\r\n }\r\n } \r\n </script>\r\n <canvas id=\"pen\" width=\"720\" height=\"600\"></canvas>\r\n </div>\r\n <button id=\"close\">リセット</button>\r\n </div>\r\n </body>\r\n </html>\n```\n\n**試したこと** \npaper.js及びpaperscriptの有無でパスを打てる機能のオンオフが切り替えられると考え、\n\n```\n\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.12.2/paper-full.js\"></script>\n \n <script type=\"text/paperscript\" canvas=\"pen\">\n \n```\n\n画像を読み込んだタイミング上記2つのタグをで生成し、リセットボタンで上記2つのタグを消す、という処理をしてみました。 \nしかし、生成したタグではpaperscriptが機能せず、パスが打てませんでした。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T02:31:37.033", "favorite_count": 0, "id": "56308", "last_activity_date": "2019-07-02T11:09:48.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "32275", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "css" ], "title": "リセットボタンでcanvasに描いた線を消したい。", "view_count": 503 }
[ { "body": "※ Paper.js\nは今始めて知ったものなので、間違っている箇所があるかもしれませんが、一応質問文の問題点が改善されたと思われるので、回答を残しておきます。\n\n* * *\n\nまず、リファレンスによれば、Path\nアイテムはアクティブなレイヤーの最上位に配置されます[[1]](http://paperjs.org/tutorials/project-\nitems/project-hierarchy/#active-layer)。\n\n> ## Active Layer[[1]](http://paperjs.org/tutorials/project-items/project-...
56308
56324
56324
{ "accepted_answer_id": "56331", "answer_count": 2, "body": "<https://stackoverflow.com/a/44115223/1979953>\n\n> `self.view.window!.rootViewController?.dismiss(animated: false, completion:\n> nil)`\n>\n> It will dismiss all the presented view controllers and remain root \n> view controller.\n\nすべてのview controllerをdismissして、root view controllerはいつづけるとありました。\n\nたしかに、試してみるとこの挙動になったのですが、公式の動きなのでしょうか? \nどこかに言及している場所はありますか?\n\n`rootViewController`に限って`dismiss`の動きが特殊(実際に試したところ`rootViewController`に代入されている`ViewController`で`dismiss`しても同じ)なので気になりました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T04:34:34.083", "favorite_count": 0, "id": "56311", "last_activity_date": "2019-07-02T17:56:11.660", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "post_type": "question", "score": 0, "tags": [ "swift", "ios" ], "title": "rootViewControllerをdismissするとrootViewControllerはいつづけることについてドキュメントは存在しますか?", "view_count": 942 }
[ { "body": "公式APIドキュメントの\n[dismiss(animated:completion:)](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621505-dismiss)\nは以下のように記載されています。\n\n> Dismisses the view controller that was presented modally by the view\n> controller. \n> (Google翻訳) View Controllerによってモーダルモードで表示されていたView Controller...
56311
56331
56331
{ "accepted_answer_id": null, "answer_count": 1, "body": "WEBアプリをDjangoで開発しようとしています。そこで気になったのがrunserverのセキュリティです。\n\n開発用とは言えサーバーを立ち上げるので、攻撃されるリスクか0ではないのかなと思いました。(この辺りの知識が薄いためもしかしたらとんちんかんな事を言っているかもしれないです、申し訳ありません。) \nここで言う攻撃は、そのサーバー経由で開発してるコードが漏洩したり、開発してる端末の情報の漏洩などを指しています。\n\nもし0でない場合、攻撃された事例などはございますでしょうか?(サラッと調べて特に見当たらなかったのですが) \nまた、これを行っておけばリスクが下がるなどのアドバイスがありました頂けると幸いです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T05:49:57.220", "favorite_count": 0, "id": "56312", "last_activity_date": "2019-07-04T04:24:56.697", "last_edit_date": "2019-07-02T08:15:39.320", "last_editor_user_id": "2238", "owner_user_id": "34949", "post_type": "question", "score": 0, "tags": [ "python", "django", "security" ], "title": "Djangoのrunserverの脆弱性について", "view_count": 571 }
[ { "body": "> 攻撃された事例などはございますでしょうか?\n\n個人の開発環境のサーバーを攻撃されたという話は聞いたことがありません(私は)。\n\n外部に公開していないDjangoサーバー(のポート)には、外部から直接アクセスできません。公開=外部からのアクセスの許可なので、当たり前ですが。なので、何らかの方法で間接的にアクセスするしかないですが、それが可能な方法があったとしても、攻撃者がそれを見つけることは簡単ではありません。\n\nそれほどの労力をかけてまで、攻撃する価値のあるサーバーであれば別ですが、そうでなければそこに労力をかける攻撃者はいないでしょう。さらにアクセスされたとしても、アプリ自体に...
56312
null
56329
{ "accepted_answer_id": "56327", "answer_count": 1, "body": "Pythonで開発しているアプリをスタンドアローン実行するexeにしたく、Pyinstallerを使用したいと考えました。\n\n**開発環境:** \nOS:Windows10 Pro \nIDE:Visual Studio 2017\n\nVisual Studioのpython環境タブからパッケージを選択、`pip install pyinstaller`\nを実行し成功したメッセージがでました。 \n添付する<python環境.jpg>にpython環境タブを示しますが、インストールされているようです。 \npypiwin32, pywin32 もインストールされていることを確認しました。\n\n[![Python環境](https://i.stack.imgur.com/iXtbn.jpg)](https://i.stack.imgur.com/iXtbn.jpg)\n\nインタラクティブウィンドウで、実行した結果が、<pyinstaller実行.jpg>です。\n\n[![Pythoninstaller実行](https://i.stack.imgur.com/nAIPH.jpg)](https://i.stack.imgur.com/nAIPH.jpg)\n\nファイル名指定なしで実行すると、以下のように表示されるため、pyinstallerが正しく認識されていないのでしょうか。 \n`C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\Lib\\site-\npackages` というフォルダの中には `PyInstaller` というフォルダができています。 \nご存知の方がいらっしゃいましたら、ご教示をお願いいたします。\n\n```\n\n Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n NameError: name 'pyinstaller' is not defined\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T06:00:19.970", "favorite_count": 0, "id": "56313", "last_activity_date": "2020-07-11T16:56:06.230", "last_edit_date": "2020-07-11T16:56:06.230", "last_editor_user_id": "3060", "owner_user_id": "32891", "post_type": "question", "score": 0, "tags": [ "python", "visual-studio", "pyinstaller" ], "title": "VisualStudio2017 で PyInstaller を使用したい", "view_count": 3964 }
[ { "body": "PyInstallerで.exeを作成する際に、インタラクティブウィンドウから実行する(下記のようにコマンドプロンプトから\n-mで実行と同じ?)場合は、大文字小文字の区別があるかもしれません。 \n**pyinstaller** ではなく、 **PyInstaller** でやってみてください。\n\n[Using pyinstaller with Visual Studio\n2017](https://www.reddit.com/r/learnpython/comments/972274/using_pyinstaller_with_visual_studio_2017/)\n\n> ...
56313
56327
56327
{ "accepted_answer_id": "56323", "answer_count": 1, "body": "お世話になります。\n\nCSVのテキストを読み込み、自動的にContextMenuStripを生成するコードを書いています。 \n一つルート階層のToolStripMenuItemを準備してから、ツリー構造を作るような \nアルゴリズムにしました。\n\n最後に、いざContextMenuStripに乗せるときに、rootをそのまま乗せると、root自体が \n邪魔に感じてしまうので、rootの子供からContextMenuStripに乗せようとするのですが、 \n例外が発生して思うように動きません。\n\n原因と対策をお教えいただけますでしょうか。\n\n下記にコードを記述します。\n\n```\n\n private void BaseForm_Load(object sender, EventArgs e)\n {\n // cmsはContextMenuStrip\n \n string[] stItems = File.ReadAllLines(@\"C:\\xxxxxxx\\売り物.txt\");\n \n if(stItems == null)\n {\n return;\n }\n \n this.cms.Items.Clear();\n \n ToolStripMenuItem root = new ToolStripMenuItem();\n foreach (string s in stItems)\n {\n string[] values = s.Split(',');\n ToolStripMenuItem parent = root;\n \n foreach (string ss in values)\n {\n if (ss != \"\")\n {\n ToolStripMenuItem mi = new ToolStripMenuItem();\n mi.Text = ss;\n parent.DropDownItems.Add(mi);\n parent = mi;\n }\n else\n {\n parent = (ToolStripMenuItem)parent.DropDownItems[root.DropDownItems.Count - 1];\n }\n }\n }\n \n        // コレクションごとごっそり入れようとしてもエラー\n this.cms.Items.AddRange(root.DropDownItems);\n \n       // 一つ一つ取り出して入れようとしても違ったエラー \n foreach (ToolStripMenuItem tsmi in root.DropDownItems)\n {\n this.cms.Items.Add(tsmi);\n }\n }\n \n```\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/aRREo.jpg)](https://i.stack.imgur.com/aRREo.jpg) \nCSVの中身は↓\n\nくだもの,りんご \n,いちご \n,みかん \n,スイカ \n野菜,キャベツ \n,きゅうり \n,大根 \n,玉ねぎ\n\n以上、よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T07:15:00.010", "favorite_count": 0, "id": "56315", "last_activity_date": "2019-07-02T10:52:32.807", "last_edit_date": "2019-07-02T08:27:31.137", "last_editor_user_id": "9374", "owner_user_id": "9374", "post_type": "question", "score": 0, "tags": [ "c#", "form" ], "title": "C# 階層の出来上がっているToolStripMenuItemから一段階下の階層を得るときにエラーになる", "view_count": 559 }
[ { "body": "`root.DropDownItems`の型`ToolStripItemCollection`と、`ContextMenuStrip.Items.AddRange()`のパラメータの型`ToolStripItem[]`が違うためでしょう。\n\n以下のようにいったん変換すれば設定できるのでは?\n\n```\n\n ToolStripItem[] menuItems = new ToolStripItem[root.DropDownItems.Count];\n root.DropDownItems.CopyTo(menuItems, 0);\n \n this.cms....
56315
56323
56323
{ "accepted_answer_id": "56529", "answer_count": 1, "body": "IJCAD2019を用いた.NETアプリケーションの開発をしております。\n\nApplication.ShowModelessDialog()で \nWindowsFormで作成したダイアログを呼び出したところ、 \n呼び出したダイアログ上でTabキーを押してもフォーカスが移動しませんでした。\n\nTabキーでのフォーカス移動を有効にするにはどうすればいいでしょうか?\n\n各コントロールのTabStopはTrueとなっています。\n\n```\n\n public class Class1\n {\n [CommandMethod(\"Test\")]\n public void DoIt()\n {\n Form1 form = new Form1();\n GrxCAD.ApplicationServices.Application.ShowModelessDialog(form);\n }\n }\n \n```\n\n[![Tabキーでフォーカスが移動しない](https://i.stack.imgur.com/scASA.png)](https://i.stack.imgur.com/scASA.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T07:17:49.617", "favorite_count": 0, "id": "56316", "last_activity_date": "2019-07-10T00:35:14.133", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34593", "post_type": "question", "score": 0, "tags": [ ".net", "ijcad" ], "title": "IJCAD上でWindowFormを呼び出した際のTabStopについて", "view_count": 123 }
[ { "body": "IJCADの.NET APIで作成したウインドウをモードレスで呼び出した場合、TABでフォーカスは移動されないようです。 \nモーダルでは大丈夫そうなので、恐らく.NET APIの不具合だと思われます。 \nIJCADのサポートに、APIの不具合として報告した方が良いと思われます。\n\n余談ですが、WPFを使用して作成されたウインドウは大丈夫なようです。 \nこの際、ShowModelessDialogでなく、ShowModelessWindowで呼び出す必要があります。", "comment_count": 0, "content_license": "CC BY-SA...
56316
56529
56529
{ "accepted_answer_id": null, "answer_count": 0, "body": "C言語で双方向リストを用いて降順ソートを作成したのですが出力がうまく表示されません。どこがおかしいのでしょうか。\n\n```\n\n #include <stdio.h>\n #include <stdlib.h>\n #include <string.h>\n #define LIMIT_LOW 0\n #define LIMIT_HIGH 25\n \n /* 構造体の定義 */\n typedef struct tag {\n int temp; /* 温度 */\n struct tag *prev; /* 1つ前のデータへのポインタ変数 */\n struct tag *next; /* 1つ後のデータへのポインタ変数 */\n } tempData; /* 温度データ */\n \n /* 新データ作成関数 */\n tempData* makeNewNode(int t) {\n tempData* pNewNode;\n /*** tempData 型のメモリ領域確保 ***/\n pNewNode = (tempData*)malloc(sizeof(tempData));\n if (pNewNode != NULL) {\n /*** データ設定 ***/\n pNewNode->temp= t;\n pNewNode->prev = NULL;\n pNewNode->next = NULL;\n }\n return pNewNode ;\n }\n \n int main(void) {\n int temp; /* 温度入力用変数 */\n tempData *pTop; /* 温度データリストのトップ */\n tempData *pLast; /* 温度データリストの末尾 */\n tempData *pNow; /* 温度データリスト内の現在位置 */\n tempData *pNew; /* 温度データの新規データ */\n /* 必要であれば,ここに変数を追加 */\n \n /* 最初のデータは,必ず範囲内のデータであるとする */\n scanf(\"%d\", &temp);\n pTop = makeNewNode(temp);\n pLast = pTop;\n \n /* 次のデータを入力 */\n scanf(\"%d\", &temp);\n while ( (LIMIT_LOW <= temp) && (temp <= LIMIT_HIGH)) {\n /* データ作成 */\n pNew = makeNewNode(temp);\n \n /* 先頭データより小さいか? */\n if (pNew->temp < pTop->temp) {\n /* 先頭の入れ替え */\n \n } else {\n /* 挿入する場所を探す */\n pNow = pTop;\n /* 末尾に達するまで探す */\n while (pNow != pLast) {\n /* 1つ先のデータが pNew より大きかったら,そこが挿入ポイント */\n if (pNew->temp < pNow->next->temp) {\n /* 挿入処理 */\n \n pNew->next = pNow->next;\n pNew->prev = pNow;\n pNow->next = pNew;\n pNow->next->prev = pNew;\n \n /* 探索終了 */\n break;\n }\n pNow = pNow->next;\n }\n /* 探索が末尾に達して終了したら,末尾に追加 */\n if (pNow == pLast) {\n pNow->next = pNew ;\n pNew->prev = pNow ;\n /* 末尾に追加 */\n \n }\n \n }\n \n /* 次のデータを入力 */\n scanf(\"%d\", &temp);\n }\n \n /* 出力処理 */\n pNow = pLast;\n while (pNow != NULL) {\n printf(\"%d\\n\", pNow->temp);\n pNow = pNow->prev;\n }\n \n return 0 ;\n }\n \n```", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T07:26:51.913", "favorite_count": 0, "id": "56317", "last_activity_date": "2019-07-02T08:59:51.557", "last_edit_date": "2019-07-02T08:59:51.557", "last_editor_user_id": "3060", "owner_user_id": "34950", "post_type": "question", "score": 0, "tags": [ "c" ], "title": "双方向リストを用いた降順ソート", "view_count": 1021 }
[]
56317
null
null
{ "accepted_answer_id": "56321", "answer_count": 1, "body": "利用端末 TeraTerm 4.103 \nMySQL 5.6.10\n\nTeraTerm 端末設定 \nコーディング受信、コーディング送信 = UTF-8 \nロケール: american <= あまり影響ないと思います。 \n[![TeraTerm端末設定](https://i.stack.imgur.com/saOSg.png)](https://i.stack.imgur.com/saOSg.png)\n\n設定はUTF8です。 \nUTF8エンコーディングあるファイルは`source`コマンドで実行時、正常に実行できますが、selectを実行時日本語がある情報は???を示します。\n\n```\n\n mysql> show variables like '%char%';\n +--------------------------+--------------------------------------------------+\n | Variable_name | Value |\n +--------------------------+--------------------------------------------------+\n | character_set_client | utf8 |\n | character_set_connection | utf8 |\n | character_set_database | latin1 |\n | character_set_filesystem | binary |\n | character_set_results | utf8 |\n | character_set_server | latin1 |\n | character_set_system | utf8 |\n | character_sets_dir | 。。。。 |\n +--------------------------+--------------------------------------------------+\n 8 rows in set (0.01 sec)\n \n```\n\n別のstackoverflowのpost確認時、2つ対応方法を試し見ましたが、文字化け文字を残ります。\n\n対応1:\n\n```\n\n set names utf8; \n \n```\n\n対応2: \nクライアント実行時、デフォルト文字コードを指定\n\n```\n\n mysql --default-character-set=utf8\n \n```\n\n或いは\n\n```\n\n mysql --default-character-set=utf8mb4\n \n```\n\n参照: \n[MySQL command line formatting with UTF8 - Stack\nOverflow](https://stackoverflow.com/questions/6787824/mysql-command-line-\nformatting-with-utf8)\n\n他の方法がないですか?ちなみに、OS(Linux)の文字コードはUTF8です。\n\n============================================\n\n補足情報\n\nシステム言語値:\n\n```\n\n [ec2-user@ip-10-16-0-53 ~]$ echo $LANG\n en_US.UTF-8\n [ec2-user@ip-10-16-0-53 ~]$ env | grep LANG\n LANG=en_US.UTF-8\n \n```\n\nフォント設定\n\nフォント名:Terminal \nフォントStype:Regular \nフォントサイズ:9 \nScript: OEM/DOS\n\n====================\n\n※解決できましたが、原因分からない、もし他人同じ問題があるため、補足情報追加\n\n最初インストールしたのTeraTermはWindows Installer型はProgram Files\n(x86)ディレクトりにインストールします。このTeraTermは日本語示すできません。\n\n<https://osdn.net/projects/ttssh2/downloads/71232/teraterm-4.103.exe/>\n\nも一回RC版の圧縮ZIPファイル型のTeraTermダウンロードして、解凍し、今回のTeraTermは日本語表示できます。\n\n<https://osdn.net/projects/ttssh2/downloads/71210/teraterm-4.103-RC2.zip/>\n\nteraterm-4.103.exe vs teraterm-4.103-RC2.zipはどの違いがわかりません。多分Program\nFilesでインストール影響がある、原因調査します。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T08:30:46.733", "favorite_count": 0, "id": "56320", "last_activity_date": "2019-07-03T00:26:41.147", "last_edit_date": "2019-07-02T11:33:44.663", "last_editor_user_id": "7404", "owner_user_id": "7404", "post_type": "question", "score": 0, "tags": [ "linux", "mysql", "teraterm" ], "title": "MySQLからロードした日本語の文字情報をクライアントで表示できない", "view_count": 446 }
[ { "body": "Tera Termでロケールが\"american\"だと、 \n\"言語コード(P)\"はこうなっているのでは?[![画像の説明をここに入力](https://i.stack.imgur.com/8pKDM.png)](https://i.stack.imgur.com/8pKDM.png)\n\nここの \"言語コード(P)\" を`932`に変更したらいかがでしょう?\n\n* * *\n\n**追記**\n\n自分のTeraTermのフォント設定は以下の通りです。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/3SBlV.png)](http...
56320
56321
56321
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在、下記コード・添付画像のような、ユーザー情報を入力してもらうポップアップを作っています。\n\n```\n\n <template>\n <v-btn class=\"create-button\" color=\"yellow\" @click=\"alertDisplay\">Create</v-btn>\n \n <br/>\n \n <p>Test result of createCustomer: {{ createdCustomer }}</p>\n </div>\n </template>\n \n <script>\n export default {\n data() {\n return {\n createdCustomer: null\n }\n },\n methods: {\n async alertDisplay() {\n \n const {value: formValues} = await this.$swal.fire({\n title: 'Create private customer',\n html: '<input id=\"swal-input1\" class=\"swal2-input\" placeholder=\"Customer Number\">' +\n '<select id=\"swal-input2\" class=\"swal2-input\"> <option value=\"fi_FI\">fi_FI</option> <option value=\"sv_SE\">sv_SE</option> </select>'\n + \n '<input id=\"swal-input3\" class=\"swal2-input\" placeholder=\"regNo\">' +\n '<input v-model=\"createdCustomer.address.street\" id=\"swal-input4\" class=\"swal2-input\" placeholder=\"Address (street)\">' +\n '<input v-model=\"createdCustomer.address.city\" id=\"swal-input5\" class=\"swal2-input\" placeholder=\"Address (city)\">' +\n '<input v-model=\"createdCustomer.address.country\" id=\"swal-input6\" class=\"swal2-input\" placeholder=\"Address (country)\">' +\n '<input v-model=\"createdCustomer.address.region\" id=\"swal-input7\" class=\"swal2-input\" placeholder=\"Address (region)\">' +\n '<input v-model=\"createdCustomer.address.zipCode\" id=\"swal-input8\" class=\"swal2-input\" placeholder=\"Address (zipCode)\">' +\n '<input id=\"swal-input9\" class=\"swal2-input\" placeholder=\"First Name\">' +\n '<input id=\"swal-input10\" class=\"swal2-input\" placeholder=\"Last Name\">'\n ,\n focusConfirm: false,\n preConfirm: () => {\n return [\n document.getElementById('swal-input1').value,\n document.getElementById('swal-input2').value,\n document.getElementById('swal-input3').value,\n document.getElementById('swal-input4').value,\n document.getElementById('swal-input5').value,\n document.getElementById('swal-input6').value,\n document.getElementById('swal-input7').value,\n document.getElementById('swal-input8').value,\n document.getElementById('swal-input9').value,\n document.getElementById('swal-input10').value\n ] \n \n }\n })\n if (formValues) {\n this.createdCustomer = formValues;\n console.log('the content of this.createdCustomer');\n console.log(this.createdCustomer);\n console.log('the content of this.createdCustomer.address');\n console.log(this.createdCustomer.address);\n } \n }\n }\n </script>\n \n \n```\n\n[![multiple\ninputs](https://i.stack.imgur.com/8cM4R.png)](https://i.stack.imgur.com/8cM4R.png)\n\nただ複数の項目を入力してもらう事だけなら今のコードのままでもできるのですが、「アドレス(住所)」の部分に関しては単なる「文字列」ではなく、下記コードのような複数の文字列からなる「オブジェクト型」として保存したいです。\n\n```\n\n \"address\": {\n \"street\": \"string\",\n \"city\": \"string\",\n \"country\": \"string\",\n \"region\": \"string\",\n \"zipCode\": \"string\"\n }\n \n```\n\n今の所、HTMLとpreConfirm\nparametersを使って入力項目をポップアップ内に表示させているのですが、上記のようなオブジェクト型でユーザーのアドレス(住所)を保存したい場合、どのようにすれば良いのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T10:26:20.940", "favorite_count": 0, "id": "56322", "last_activity_date": "2022-12-18T06:01:25.140", "last_edit_date": "2019-07-03T12:50:44.350", "last_editor_user_id": "34951", "owner_user_id": "34951", "post_type": "question", "score": 0, "tags": [ "vue.js" ], "title": "Vue-SweetAlert2のポップアップ内で複数のユーザーインプットを読み取り、その内のいくつかを1つのオブジェクトとして保存するには?", "view_count": 539 }
[ { "body": "一応解決したので、備忘録も兼ねて追記しておきます。\n\n問題だったのは、\n\n```\n\n if (formValues) {\n this.createdCustomer = formValues;\n console.log('the content of this.createdCustomer');\n console.log(this.createdCustomer);\n console.log('the content of this.createdC...
56322
null
56357
{ "accepted_answer_id": null, "answer_count": 1, "body": "こんにちは。 \n任意の数を入力して、`*`でピラミッドが右90度に傾いているように出力されるようにプログラミングしたいのですが、例えば、3だったら以下のように出力され、0と入力されたらストップする。\n\n```\n\n *\n **\n ***\n **\n *\n \n```\n\n以下のようにプログラミングしたのですが、添付のようにうまくいきません。 \nどこが間違えているのでしょうか?\n\n```\n\n #include <stdio.h>\n \n int main(){\n int i, j, len, k;\n for(;;){\n scanf(\"%d\", &len);\n if(len==0){break;}\n for(i=1;i<=len;i++){\n for(j=1;j<=i;j++)\n printf(\"*\");\n printf(\"\\n\");\n }\n for(k=len-1;k>0;k--){\n for(j=1;j<=len-1;j++)\n printf(\"*\");\n printf(\"\\n\");\n }\n }\n }\n \n```\n\n[![](https://i.stack.imgur.com/BM6na.png)](https://i.stack.imgur.com/BM6na.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T11:18:44.230", "favorite_count": 0, "id": "56325", "last_activity_date": "2019-07-02T14:20:57.847", "last_edit_date": "2019-07-02T14:20:57.847", "last_editor_user_id": "76", "owner_user_id": "34892", "post_type": "question", "score": 0, "tags": [ "c" ], "title": "多重ループを使ったプログラミングがうまくいかない", "view_count": 160 }
[ { "body": "下のコメント部分のループの条件が間違っています。`j<len-1`となっているため、必ず`入力値-1`の個数だけ`*`を書いてしまいます。蛇足だとは思いますが、正しくは`j<=k`です。\n\n```\n\n #include <stdio.h>\n \n int main(){\n int i, j, len, k;\n for(;;){\n scanf(\"%d\", &len);\n if(len==0){break;}\n for(i=1;i<=len;i++){\n for(j=1;j<=...
56325
null
56328
{ "accepted_answer_id": "56339", "answer_count": 1, "body": "以下の旧URLに来た場合、301リダイレクトで新URLへ転送したいのですが、 \n.htaccessのRewriteRuleはどのように書けばいいでしょうか? いろいろ試していますが、 \nうまくいきません。アドバイスいただければ幸いです。\n\n旧URL `https://example.com/stay/db/database.cgi?cmd=dp&num=1234&dp=ad.html` \n新URL `https://example.com/stay/db/database.cgi?cmd=dp&num=1234&dp=all.html`\n\n【条件追記】上記新旧URLに書きました「1234」という部分は、実は複数あるうちの一つでして、他に「2354」になったURLもあります。この数字が「1234」の時だけリダイレクトしたいのです。\n\n【テスト結果】\n\nURLが新URLへリダイレクトされましたが、以下のエラー画面が出て、\n\n「このページは動作していません 「ドメイン名」でリダイレクトが繰り返し行われました。Cookie を消去してみてください. \nERR_TOO_MANY_REDIRECTS」\n\n新URL\n[https://example.com/stay/db/database.cgi?cmd=dp&num=1234&dp=all.html](https://example.com/stay/db/database.cgi?cmd=dp&num=1234&dp=all.html) \nの画面が表示されなくなりました。(代わりに上記エラー画面が出ます) \n(Cookie を消去してみましたが同じで上記エラー画面が出ます)\n\n【成功しました】\n\n1234があるとリダイレクトし続けるようなので、以下のようにしましたら無事成功しました。\n\n \nRewriteEngine on \nRewriteCond %{REQUEST_URI} !=/stay/db/database.cgi?cmd=dp&num=1234&dp=all.html \nRewriteCond %{QUERY_STRING} &num=1234&dp=ad.html \nRewriteCond %{QUERY_STRING} ^(. _& dp)=(.+)$ \nRewriteRule ._ <https://%>{HTTP_HOST}%{REQUEST_URI}?%1=all.html [R=301,L] \n\nアドバイスありがとうございました。感謝です。 \n上記結果で、何か不備がありましたら、ご教示をよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-02T23:24:58.987", "favorite_count": 0, "id": "56332", "last_activity_date": "2019-07-03T06:22:45.557", "last_edit_date": "2019-07-03T06:01:59.487", "last_editor_user_id": "34954", "owner_user_id": "34954", "post_type": "question", "score": 1, "tags": [ ".htaccess" ], "title": ".htaccessでの別ページへのリダイレクト", "view_count": 218 }
[ { "body": "これで通じますかね? \nまた、恐らくサンプルURLだとおもいますが、構造が全く同じであればこれでいけると思います。 \n一度試して、問題が無ければ`R=301`へ変更してください。\n\n* * *\n\n**追記** \n基本的に条件が増えた場合は`RewriteCond`を増やせば問題ありません。 \nまた、質問文を見て他の人が回答できるように質問してください。 \n質問する際は次のページが参考になります。 \n[最小限の・自己完結した・確認可能なサンプルコードの書き方](https://ja.stackoverflow.com/help/minimal-\nreproduci...
56332
56339
56339
{ "accepted_answer_id": null, "answer_count": 0, "body": "こちらteratailでも質問している内容(マルチポスト)です。 \n<https://teratail.com/questions/198296>\n\n### 前提・実現したいこと\n\n自作railsアプリケーション(DBはMysql)をDocker環境で動くように開発し、GKE(google kubernetes\nengine)にデプロイしたい\n\n[こちらのサイト](https://qiita.com/ryu-yama/items/dc640c35a56e42ebdba8)を参考にしています\n\n前提 \n・アプリケーションはローカル(開発環境)だとdocker-compose upで正常に起動する状態 \n・localのワーキングディレクトリにはkey.jsonがある \n・GCPのIAMと管理「サービス アカウントの詳細」にキーは設定されていてkey.jsonのものと同じ(メールアドレスも一致) \n・cloudsql-db-credentialsとcloudsql-instance-credentialsはGCP側に設定されている\n\nGKE構成 \n・nodeは2つ、それぞれに同じ2つpodを入れている \n・マニュフェストファイルはひとつ(deployment.yml)\n\n```\n\n #key.json\n {\n \"type\": \"service_account\",\n \"project_id\": \"プロジェクト名\",\n \"private_key_id\": \"・・・8a8c5\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\n・・・BfYN\\nMkTAtnTgtiC77mllNDhONA==\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"test-user@プロジェクト名.iam.gserviceaccount.com\",\n \"client_id\": \"・・・06700\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://oauth2.googleapis.com/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/test-user%40プロジェクト名.iam.gserviceaccount.com\"\n }\n \n```\n\n### 発生している問題・エラーメッセージ\n\nGKEにデプロイする際にエラー(podのstatusがCrashLoopBackOff)になってしまう。\n\n```\n\n textPayload: \"/usr/local/bundle/gems/railties-5.2.3/lib/rails/application.rb:585:in `validate_secret_key_base': Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit` (ArgumentError)\n \n```\n\n```\n\n textPayload: \"2019/07/02 14:18:29 invalid json file \"./key.json\": open ./key.json: no such file or directory\n \n```\n\n```\n\n $ kubectl get pods\n NAME READY STATUS RESTARTS AGE\n rails-api-798fd446db-c6jwc 1/2 CrashLoopBackOff 1 5s\n rails-api-798fd446db-d8g8k 1/2 CrashLoopBackOff 1 5s\n \n```\n\n### 該当のソースコード\n\n```\n\n #deployment.yml\n apiVersion: extensions/v1beta1\n kind: Deployment\n metadata:\n name: rails-api\n spec:\n replicas: 2\n template:\n metadata:\n labels:\n app: rails-api\n spec:\n containers:\n - image: gcr.io/プロジェクト名/rails_api\n name: web\n env:\n - name: DB_USER\n valueFrom:\n secretKeyRef:\n name: cloudsql-db-credentials\n key: username\n - name: DB_PASS\n valueFrom:\n secretKeyRef:\n name: cloudsql-db-credentials\n key: password\n - name: DB_NAME\n value: SQLのインスタンス\n - name: DB_HOST\n value: 127.0.0.1\n - name: RAILS_ENV\n value: production\n - name: RACK_ENV\n value: production\n - name: RAILS_SERVE_STATIC_FILES\n value: 'true'\n ports:\n - containerPort: 3000\n name: rails-api\n command: [\"rm\", \"-f\", \"/rails_api/tmp/pids/server.pid\"]\n command: [\"bundle\", \"exec\", \"rails\", \"server\", \"-p\", \"3000\", \"-b\", \"0.0.0.0\"]\n - image: b.gcr.io/cloudsql-docker/gce-proxy:1.11\n name: cloudsql-proxy\n command: [\"/cloud_sql_proxy\",\n \"-instances=プロジェクト名:asia-northeast1:SQLのインスタンス=tcp:3306\",\n \"-credential_file=./key.json\"]\n volumeMounts:\n - name: cloudsql-instance-credentials\n mountPath: /secrets/cloudsql\n readOnly: true\n volumes:\n - name: cloudsql-instance-credentials\n secret:\n secretName: cloudsql-instance-credentials\n \n```\n\n```\n\n #Dockerfile\n FROM ruby:2.6.2\n \n \n # 必要なパッケージのインストール(基本的に必要になってくるものだと思うので削らないこと)\n RUN apt-get update -qq && \\\n apt-get install -y build-essential \\\n libpq-dev \\\n nodejs\n \n # 作業ディレクトリの作成、設定\n RUN mkdir /rails_api\n ##作業ディレクトリ名をAPP_ROOTに割り当てて、以下$APP_ROOTで参照\n ENV APP_ROOT /rails_api\n WORKDIR $APP_ROOT\n \n # ホスト側(ローカル)のGemfileを追加する(ローカルのGemfileは【3】で作成)\n ADD ./Gemfile $APP_ROOT/Gemfile\n ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock\n \n # Gemfileのbundle install\n RUN bundle install\n ADD . $APP_ROOT\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T01:46:43.370", "favorite_count": 0, "id": "56334", "last_activity_date": "2019-07-03T04:28:17.630", "last_edit_date": "2019-07-03T04:28:17.630", "last_editor_user_id": "34956", "owner_user_id": "34956", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "sql", "docker", "kubernetes", "google-kubernetes-engine" ], "title": "Railsサービス(mysql)をGKEにデプロイする際に秘密鍵が見つからずpodのstatusがCrashLoopBackOffになる", "view_count": 117 }
[]
56334
null
null
{ "accepted_answer_id": "56355", "answer_count": 2, "body": "# 背景\n\nPythonでCLIツールを作成しています。 \n[aws-cli](https://github.com/aws/aws-\ncli)のような、外部サービスにアクセスするCLIツールです。以下のようにコマンドを実行します。\n\n```\n\n # ユーザusr1を登録\n $ mycli register_user --user_id usr1 --user_info \"{'name': 'alice`}\"\n \n # usr1,usr2,usr3に関する詳細情報を出力する\n $ mycli print_users --user_id usr1 usr2 usr3\n \n```\n\nコマンドライン引数のパースには、[argparser](https://docs.python.org/ja/3/library/argparse.html)モジュールを利用しています。\n\n# 悩んでいること\n\nCLIツールのサブコマンドやオプションの設計に悩んでいます。 \n例えば、以下のような内容です。\n\n### サブコマンド名やオプション名の命名規則\n\n * アンダースコア区切り?ハイフン区切り?\n * 複数の値を受け取ることができる(1個でもOK)オプション名は単数形?複数形? `--user alice bob` or `--users alice bob`\n\n### オプション\n\n * 使わない方が良い(競合しやすい)オプション名(`-h`?)\n\n### その他\n\n * 標準入力の使いどころ。ファイルで渡すか標準入力で渡すか\n * 引数の順番(例:コピー元、コピー先の順)\n\n# 質問\n\nCLIツールに関して、ベターパターンやアンチパターン、標準や慣習が記載されているサイトがありましたら、教えていただきたいです。 \n「command line interface design pattern」で検索してみましが、私が期待するサイトが見つかりませんでした。", "comment_count": 6, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T01:56:17.310", "favorite_count": 0, "id": "56335", "last_activity_date": "2019-07-04T01:38:12.760", "last_edit_date": "2019-07-04T01:36:19.250", "last_editor_user_id": "19524", "owner_user_id": "19524", "post_type": "question", "score": 0, "tags": [ "python", "command-line" ], "title": "CLIツールのベターパターン/アンチパターンを教えてください", "view_count": 419 }
[ { "body": "アンチ(ベター)パターンがあるのか分かりませんが、Linuxでよく使われるオプション名などは \n「linux command long option」などで検索すると参考になるかもしれません。\n\n以下はあくまで個人的な意見として\n\n> * アンダースコア区切り?ハイフン区切り?\n> * 複数の値を受け取ることができる(1個でもOK)オプション名は単数形?複数形?\n>\n\n少しでもキーボードのタイプ数を減らしたいので、(Shiftキーを押しながらの)アンダースコアより **ハイフン区切り** 、複数の値を取りうる場合も\n**単数形** を使いたいです。 \nただし後者...
56335
56355
56355
{ "accepted_answer_id": null, "answer_count": 1, "body": "閲覧ありがとうございます。 \nGASでの開発中に次のような事象が発生しており困っています。\n\n# ■発生している問題\n\n[公開]タブ>[ウェブアプリケーションとしての導入…]をクリック後、 \n「データを取得しています…」という画面が表示された状態で止まってしまう。\n\n# ■やったこと\n\n * Chromeのキャッシュの削除\n * 違うスプレッドシートで導入テスト \n * ⇒問題なく公開可能\n * 対象のスクリプトが導入可能かどうか確認 \n * ⇒別のスプレッドシートであれば導入可能\n\nGoogleのサーバ側の問題であるかもしれないのですが、同様の事象が発生しており解決した方がいらっしゃれば何か知見を伺えればと思い質問させて頂きました。 \n以上、よろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T04:03:32.387", "favorite_count": 0, "id": "56338", "last_activity_date": "2019-12-13T04:05:40.913", "last_edit_date": "2019-07-03T05:34:01.730", "last_editor_user_id": "29826", "owner_user_id": "34958", "post_type": "question", "score": 0, "tags": [ "google-apps-script" ], "title": "ウェブアプリケーションとしての導入について", "view_count": 1771 }
[ { "body": "自己解決しましたので、同じところで躓いた人のために残しておきます。 \nどうやら「ウェブアプリケーションとしての導入…」は対象ドキュメントのオーナーでしかできない操作のようです。オーナー権限を譲渡してもらったら解決しました。 \n何かしらエラーメッセージ出してほしいですね。。\n\n【備考:オーナーの譲渡方法】 \n・ドライブでスクリプトの付属するドキュメントを右クリック \n・共有⇒詳細設定 \n・オーナーの場合、人に付属する右側のプルダウンに「閲覧可」「編集可」に加えて「オーナー」が存在しますのでそちらを選択", "comment_count": 0, "conte...
56338
null
56341
{ "accepted_answer_id": null, "answer_count": 0, "body": "phpでオブジェクト指向型のプログラムを実装しています。(初級者です。) \nnamespaceを設定してクラスの呼び出しを行っていますが、以下のエラーが解消されません。 \nクラス名を変えたりと色々やってますが、原因の追究ができません。 \nどなたか分かる方、アドバイスをいただけると幸いです。\n\n_facilityEditController.php (Controllerまでのパス:facility/edit/)_\n\n```\n\n <?php\n session_start();\n //ディレクトリcommonまでのパス(facility/edit/common)\n require('common/sqlDefinedClass.php');\n require('common/pdoAceessClass.php');\n require('common/commonClass.php');\n require('facility_edit_model.php');\n $pdo_aceess = new Edit\\aceessPDO();\n $sql_defind_edit = new Edit\\sqlDefindEdit();\n $common = new Edit\\common();\n $facility_edit_model = new facilityEditModel();\n \n```\n\n_sqlDefinedClass.php (パス:facility/edit/)_\n\n```\n\n <?php\n namespace Edit;\n \n class sqlDefind {\n function insertSql($tablename,$column,$value) {\n //sql格納用変数を初期化\n $sql = \"\";\n $sql .= <<< EOF\n INSERT INTO \n EOF;<?php\n //以下、省略\n \n```\n\n_facilityInputController.php (Controllerまでのパス:facility/input/)_\n\n```\n\n <?php\n session_start();\n require('common/sqlDefinedClass.php');\n require('common/pdoAceessClass.php');\n require('common/commonClass.php');\n require('facility_input_model.php');\n \n $pdo_aceess = new Input\\aceessPDO();\n $sql_defind_input = new Input\\sqlDefindInput();\n $common = new Input\\common();\n $facility_input_model = new facilityModel();\n \n```\n\n_sqlDefinedClass.php (パス:facility/input/)_\n\n```\n\n <?php\n namespace Input;\n \n class sqlDefind {\n function insertSql($tablename,$column,$value) {\n //sql格納用変数を初期化\n $sql = \"\";\n $sql .= <<< EOF\n INSERT INTO \n EOF;<?php\n //以下、省略\n \n```\n\n**エラー内容**\n\n```\n\n Fatal error: Cannot declare class Edit\\sqlDefind, because the name is already in \n use in C:\\xampp\\htdocs\\hoikushien\\wp-content\\plugins\\matching_system\\facility\\edit\\common\\sqlDefinedClass.php on line 4\n \n```\n\nお手数おかけしますが、よろしくお願いいたします。", "comment_count": 5, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T04:29:15.097", "favorite_count": 0, "id": "56340", "last_activity_date": "2019-07-04T08:21:50.250", "last_edit_date": "2019-07-04T08:21:50.250", "last_editor_user_id": "30872", "owner_user_id": "30872", "post_type": "question", "score": 0, "tags": [ "php" ], "title": "Fatal error: Cannot declare class **** because the name is already in use in のエラーを解消できない。", "view_count": 1593 }
[]
56340
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "抜き取りたいのは以下のOOOOOOOOO部分です。\n\n```\n\n 商品 :\n ------------------------------------------------------------------\n OOOOOOOOO\n \n```\n\nメールではこのように商品:の後に点線を挟んで商品名が来ます。matchメソッドを使用し、ほかの部分は抜き出せるのですが、商品の後に商品名が来ない仕様になっているので抜き出し方がわからないです。さらにいろいろな種類の商品があり、matchメソッドを使ってもスプレッドシートが横に広がるだけです。なのでOOOOOOOの特定の行だけを抜き出す方法が知りたいです。\n\n点線の後に来る行 (実際の商品名) を指定して、抜き出しスプレッドシートに書き込ませたいです。\n\n使用しているスクリプトは以下の通りです:\n\n```\n\n function fetchContactMail() {\n \n var strTerms = '(is:unread \"OOOOOOOOOO\")';\n var myThreads = GmailApp.search(strTerms, 0, 10); \n var myMsgs = GmailApp.getMessagesForThreads(myThreads); \n \n var valMsgs = [];\n \n for(var i = 0;i < myMsgs.length;i++){\n \n valMsgs[i] = [];\n \n valMsgs[i][0] = myMsgs[i][0].getDate();\n valMsgs[i][1] = myMsgs[i][0].getFrom();\n valMsgs[i][2] = myMsgs[i][0].getSubject();\n valMsgs[i][3] = myMsgs[i][0].getPlainBody().match(/OOOOOO(.+)/); \n valMsgs[i][4] = myMsgs[i][0].getPlainBody().match(/OOOOOOO(.+)/); \n valMsgs[i][5] = myMsgs[i][0].getPlainBody().match(/OOO(.+)/); \n valMsgs[i][6] = myMsgs[i][0].getPlainBody().match(/OOOO(.+)/); \n valMsgs[i][7] = myThreads[i].getPermalink();\n \n myMsgs[i][0].markRead(); \n \n }\n \n if(myMsgs.length>0){\n \n var mySheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName('OOO'); \n var maxRow=mySheet.getDataRange().getLastRow();\n mySheet.getRange(maxRow+1, 1, i, 9).setValues(valMsgs); \n \n } \n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T07:23:16.453", "favorite_count": 0, "id": "56343", "last_activity_date": "2019-07-03T10:01:34.233", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34932", "post_type": "question", "score": 0, "tags": [ "google-apps-script" ], "title": "GmailからGASを使って特定の部分を抜き出す方法をしりたいです", "view_count": 829 }
[ { "body": "上記フォーマットの `0000...` 部分は、以下のような正規表現で取得することができます。\n\n```\n\n /商品 :\\n-+\\n(.*)/\n \n```\n\nこれは、 `\\n` が改行を意味することを利用しています。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T08:32:19.457", "id": "56348", "last_activity_date": "2019-07-03T10:01...
56343
null
56348
{ "accepted_answer_id": null, "answer_count": 0, "body": "お世話になります。 \n掲題の件で、画像をリサイズ(比率を保持して縮小する)後、画質が荒くなってしまいます。 \npillowを使って以下の通りにしていますが、何か別のやり方等ご教示いただければ幸いです。\n\n```\n\n # original file size (1000, 3000)\n \n from PIL import Image\n imagePil = Image.open(file)\n imagePil = imagePil.resize((100,300), resample=Image.LANCZOS)\n imagePil.save(fileName, quality=95, dpi=(600,600))\n \n```\n\nやりたいことは元画像のサムネイルサイズに縮小し、エクセルの指定幅のセルに表示したいのがやりたいことです。\n\n単純にサイズを落とさず、縮小したものをエクセルに添付できればOKなんですが。。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T08:26:49.877", "favorite_count": 0, "id": "56347", "last_activity_date": "2019-07-03T08:35:48.520", "last_edit_date": "2019-07-03T08:35:48.520", "last_editor_user_id": "3060", "owner_user_id": "34961", "post_type": "question", "score": 0, "tags": [ "python", "画像", "pillow" ], "title": "python image resize で品質を落とさない方法", "view_count": 1500 }
[]
56347
null
null
{ "accepted_answer_id": "57269", "answer_count": 2, "body": "この記事にあるように\n\n[Kivyのrootについて](https://qiita.com/Agipy/items/6be3651b1200c1e3c677)\n\nKV言語でappと書くことではAppインスタンスを参照できますが、KV言語ではなくPythonで書いたWidgetからAppのインスタンスを得るにはどうしたらいいのでしょうか?\n\nWidgetごとにファイルを分けて、アプリケーションを作っていますが、設定値などウィジェットツリー全体でグローバル変数のように値を読み書きしたいです。 \nAppインスタンスにメンバとして設ければよいかと思ったものの、Appの参照方法で躓いてしまいました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T09:47:22.323", "favorite_count": 0, "id": "56351", "last_activity_date": "2019-08-09T07:33:03.390", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "34495", "post_type": "question", "score": 0, "tags": [ "python", "kivy" ], "title": "自作Widgetが配置されたAppインスタンスを取得したい", "view_count": 232 }
[ { "body": "```\n\n Builder.load_string(\"\"\"\n <hoge>:\n app: app\n \"\"\")\n \n class hoge(Widget):\n app = ObjectProperty()\n \n```\n\nappプロパティを自作して、Kivy言語でセットすることでやりたいことはひとまず解決しました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07...
56351
57269
56708
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在、以下のバージョン、ライブラリを利用してRedmineのActiveなユーザ情報を全て取得しようとしています。\n\n * Python3.7\n * python-redmine\n\n対象のRedmineには一度のAPIで取得できる件数(100)を超えているのでページングするために、一度total_countを取得しようと以下のコードを書いてみたのですが、「user_list.total_count」を取得する際に\n`exceptions.ResultSetTotalCountError` が発生してしまいます。\n\n```\n\n redmine = Redmine('https://example.com/redmine', key='XXXXXXXXXXXXXXXX')\n user_list = redmine.user.filter(offset=1, limit=1, status=1)\n \n repeat = user_list.total_count // 100\n if user_list.total_count % 100 > 0:\n repeat += 1\n for i in range(0, repeat):\n offset = (i * 100 ) + 1\n user_list = redmine.user.filter(offset=offset, limit=100, status=1)\n \n```\n\nそこで試しにuser_listが取得できてきないのかどうか、上記コードの1行目と2行目の間に以下のコードを追加すると、何の問題もなく正常に動作してしまいました。\n\n```\n\n for user in user_list:\n print(user)\n \n```\n\nなぜこれを追加するだけでうまくいってしまうのか理解できず、、for文を消してsleepを入れてみたり色々と試してみたのですが、原因がわからず気持ち悪いと感じております。\n\n何か思い当たる方いらっしゃれば、Adviseいただけますと幸いです。よろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T09:55:21.877", "favorite_count": 0, "id": "56352", "last_activity_date": "2019-07-04T04:52:21.557", "last_edit_date": "2019-07-04T04:52:21.557", "last_editor_user_id": "2238", "owner_user_id": "34963", "post_type": "question", "score": 0, "tags": [ "python", "python3", "redmine" ], "title": "python-redmineでuserをfilterを利用したときの戻り値について", "view_count": 1185 }
[]
56352
null
null
{ "accepted_answer_id": "56362", "answer_count": 1, "body": "* 画像縦横比が2対3の場合 \n何もしない\n\n * 画像縦横比が2対3以外の場合 \n画像縦横比が2対3となるよう(良い感じに)縮小したい \n短辺を基準?にしてリサイズ後、(左上基準で)トリミング??\n\n* * *\n\n作成中のコード\n\n```\n\n $im = new Imagick();\n $size = $im->getImageGeometry();\n $w = $size['width'];\n $h = $size['height'];\n \n if($w > $h){ //縦が短辺\n if($w*3 != $h*2){\n $im->resize(null, $h, function ($constraint) {\n $constraint->aspectRatio();\n });\n $im->cropImage(?, $h, 0, 0);\n }\n \n }elseif($w = $h){\n \n \n }elseif($w < $h){\n if($h*3 != $w*2){\n }\n \n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T12:11:07.693", "favorite_count": 0, "id": "56354", "last_activity_date": "2019-07-03T21:04:51.437", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "php", "imagemagick" ], "title": "PHPとImageMagickで画像縦横比が2対3となるよう縮小トリミングしたい", "view_count": 305 }
[ { "body": "どの部分がわからないで質問されているのか曖昧な部分がありますが、2:3(縦長)で入力画像のはみでる部分だけをトリミングする場合こんなかんじでしょうか。(小数点以下の端数が出るアス比は適当に近い数字で)\n\n```\n\n <?php\n \n function crop(string $in, string $out)\n {\n $image = new Imagick($in);\n \n $size = $image->getImageGeometry();\n $w = $size['width'];\n ...
56354
56362
56362
{ "accepted_answer_id": "56363", "answer_count": 1, "body": "タイトルとは少し違いますが下記のコードの `if cell.skillName.text! == i { print(\"確認3\") }` \nのコードでデバックエリアに「確認3」と出力したいのですが出ない理由はなんですか\n\n**確認のコード**\n\n```\n\n import UIKit\n \n class TableViewController: UITableViewController {\n \n @IBOutlet var myTableView: UITableView!\n \n var array : Array<String> = [\"\\(UserDefaults.standard.object(forKey: \"fastTitleKey\") as! String)\"]\n \n let arrayNameKey = \"arrayNameKey\"\n \n override func viewDidLoad() {\n super.viewDidLoad()\n }\n \n override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n return array.count\n }\n \n override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n let cell = tableView.dequeueReusableCell(withIdentifier: \"customTableViewCell\", for: indexPath) as! costomViewCell\n \n cell.skillName.text = \"\\(array[indexPath.row])\"\n cell.goalCountLabel.text = secondsToGoalTimerLabel(UserDefaults.standard.integer(forKey: \"goalCountKey\"))\n \n return cell\n }\n \n override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {\n \n let storyboard : UIStoryboard = self.storyboard!\n let nextView =\n storyboard.instantiateViewController(withIdentifier: \"ViewController\")\n let navi = UINavigationController(rootViewController: nextView)\n \n let cell = tableView.dequeueReusableCell(withIdentifier: \"customTableViewCell\", for: indexPath) as! costomViewCell\n print(\"確認1\")\n \n if let arr = UserDefaults.standard.array(forKey: self.arrayNameKey) {\n print(\"確認2\")\n let arrConversion = arr as! [String]\n print(arrConversion)\n \n for i in arrConversion {\n if cell.skillName.text! == i {\n print(\"確認3\")\n }\n }\n \n }\n \n present(navi, animated: true, completion: nil)\n \n }\n \n override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {\n if editingStyle == .delete {\n array.remove(at: indexPath.row)\n tableView.deleteRows(at: [indexPath], with: .fade)\n UserDefaults.standard.set(self.array, forKey: self.arrayNameKey)\n }\n }\n \n @IBAction func addSkillButton(_ sender: UIBarButtonItem) {\n \n var alertTextFeld: UITextField?\n let alert = UIAlertController(title: \"Skill Name\", message: \"Enter new name\", preferredStyle: UIAlertController.Style.alert)\n alert.addTextField { (textField: UITextField!) in\n alertTextFeld = textField\n }\n alert.addAction(UIAlertAction(title: \"キャンセル\", style: .cancel, handler: nil))\n alert.addAction(UIAlertAction(title: \"OK\", style: .default, handler: { _ in\n if let text = alertTextFeld?.text {\n self.array.append(text)\n UserDefaults.standard.set(self.array, forKey: self.arrayNameKey)\n self.myTableView.reloadData()\n }\n }))\n \n self.present(alert, animated: true, completion: nil)\n }\n \n @IBAction func secret(_ sender: UIBarButtonItem) {\n }\n \n func saveDate() {\n }\n \n }\n \n```\n\n**カスタムセルコード**\n\n```\n\n import UIKit\n \n class costomViewCell: UITableViewCell {\n \n @IBOutlet weak var skillName: UILabel!\n @IBOutlet weak var goalCountLabel: UILabel!\n \n override func awakeFromNib() {\n super.awakeFromNib()\n // Initialization code\n }\n \n override func setSelected(_ selected: Bool, animated: Bool) {\n super.setSelected(selected, animated: animated)\n // Configure the view for the selected state\n }\n \n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T14:15:40.723", "favorite_count": 0, "id": "56359", "last_activity_date": "2019-07-04T02:03:55.837", "last_edit_date": "2019-07-04T02:03:55.837", "last_editor_user_id": "3060", "owner_user_id": "34541", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "if Label.text! == \"ほげ \" でエラーにならないのに実行はされないのはなぜですか?", "view_count": 139 }
[ { "body": "ひとことで申し上げると、条件式の評価値(結果)が`false`だからです。\n\n```\n\n if cell.skillName.text! == i\n { print(\"確認3\") }\n else { print(\"確認3で、falseとなりました。\" }\n \n```\n\nとでもコードを書き加えれば、検証可能になるでしょう。 \nSwiftの比較演算子(`==`、`!=`)は、左辺右辺あるいは両辺の値が`nil`でもエラーにならないという文法になっていますので、まず`cell.skillName.text!`と`i`が`nil`で...
56359
56363
56363
{ "accepted_answer_id": null, "answer_count": 0, "body": "### 解決したいこと\n\n<理解できないこと>\n\n「ドットインストール」のサイトを参考に簡易掲示板を作るレッスンを学習していた。 \n実際に作成した掲示板で、投稿フォームから送ったメッセージと名前の入力データが、データファイルであるbbs.datに書き込まれないという問題が発生している。\n\n動画 \n<https://gyazo.com/6eff4c24a9d4c1d5a90969de3b8a12fb>\n\nしかし、自分では、解決することができなかった。 \nどのようにすれば、入力データがbbs.datに書き込まれるようになるでしょうか?\n\n<理解できること> \nbbs.datは、index.phpと同じディレクトリに作成したこと。また、パーミッションの設定においても、書き込みが誰でもできるように設定している。\n\n動画 \n<https://gyazo.com/030eb1f12b2181d4cccc1ddc46abc1f2>\n\nteratailに自分と同じ問題が発生した方の質問に対する回答を参考にしたが、解決できなかった。 \n<https://teratail.com/questions/113439>\n\n### 自力で調べた内容\n\nGoogle検索キーワード: \n「ドットインストール dataファイル 書き込まれない」\n\n * [#04 エラーチェックをしていこう | PHPで作る簡易掲示板 - ドットインストール](https://dotinstall.com/lessons/bbs_php_v2/24504)\n * [ドットインストールの簡易掲示板 - teratail](https://teratail.com/questions/21002)\n * [掲示板を作ったが、datファイルに書き込まれない - teratail](https://teratail.com/questions/113439)\n\n### 仮説と検証作業の結果\n\n**仮説** \nファイル名や入力データがbbs.datに書き込まれる処理を実行するプログラムが間違っていると考えた。\n\n**検証** \nbbs.datというファイル名を確認した。\n\n3行目のコードを確認した。\n\n```\n\n $dataFile = 'bbs.dat';\n \n```\n\n52行目のコードを確認した。\n\n```\n\n $fp = fopen($dataFile, 'a');\n \n```\n\n61行目のコードを確認した。\n\n```\n\n $posts = file($dataFile, FILE_IGNORE_NEW_LINES);\n \n```\n\n**結果**\n\n自分が検証した限りにおいて、ファイル名やプログラムの記述は合っていた。\n\n**全体のソースコード**\n\n```\n\n <?php\n \n $dataFile = 'bbs.dat';\n \n session_start();\n \n function setToken() {\n $token = sha1(uniqid(mt_rand(), true));\n $_SESSION['token'] = $token;\n }\n \n function checkToken() {\n if (empty($_SESSION['token']) || $_SESSION['token'] != $_POST['token']) {\n echo \"不正なPOSTをが行われました\";\n exit;\n }\n }\n \n function h($s) {\n return htmlspecialchars($s, ENT_QUOTES, 'UTF-8');\n }\n \n function redirect() {\n header('Location: http://' .$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);\n exit;\n }\n \n if ($_SERVER['REQUEST_METHOD'] == 'POST' &&\n isset($_POST['message']) &&\n isset($_POST['user'])) {\n \n checkToken(); //投稿された後\n \n $message = trim($_POST['message']);\n $user = trim($_POST['user']);\n \n if ($message !== '') {\n \n $user = ($user === '') ? 'ななしさん' : $user;\n \n $message = str_replace(\"\\t\", ' ', $message);\n $user = str_replace(\"\\t\", ' ', $user);\n \n $postedAt = date('Y-m-d H:i:s');\n \n $newData = $message . \"\\t\" . $user . \"\\t\" . $postedAt . \"\\n\";\n \n $fp = fopen($dataFile, 'a');\n fwrite($fp, $newData);\n fclose($fp);\n }\n redirect();\n } else {\n setToken(); \n }\n \n $posts = file($dataFile, FILE_IGNORE_NEW_LINES);\n \n $posts = array_reverse($posts);\n \n ?>\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta charset=\"utf-8\">\n <title>簡易掲示板</title>\n </head>\n <body>\n <h1>簡易掲示板</h1>\n <form action=\"\" method=\"post\">\n message:<input type=\"text\" name=\"message\" >\n user:<input type=\"text\" name=\"user\" >\n <input type=\"submit\" value=\"投稿\" >\n <input type=\"hidden\" name=\"token\" value=\"<?php echo ($_SESSION['token']); ?>\" >\n </form>\n <h2>投稿一覧(<?php echo count($posts); ?>件)</h2>\n <ul>\n <?php if(count($posts)) : ?>\n <?php foreach ($posts as $post) : ?>\n <?php list($message, $user, $postedAt) = explode(\"\\t\", $post); ?>\n <li><?php echo h($message); ?><?php echo h($user); ?><?php echo h($postedAt); ?> </li>\n <?php endforeach; ?>\n <?php else : ?>\n <li>まだ投稿はありません。</li>\n <?php endif; ?>\n </ul>\n </body>\n </html>\n \n```", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-03T16:52:50.193", "favorite_count": 0, "id": "56360", "last_activity_date": "2019-07-04T02:00:15.527", "last_edit_date": "2019-07-04T02:00:15.527", "last_editor_user_id": "3060", "owner_user_id": "34608", "post_type": "question", "score": 3, "tags": [ "php" ], "title": "PHPで簡易掲示板を作ったが、datファイルに書き込まれない", "view_count": 358 }
[]
56360
null
null
{ "accepted_answer_id": "56389", "answer_count": 1, "body": "**環境** \nOS: Windows10 \nJDK: JDK-11\n\n**やりたいこと** \nExcelでWorkbookを編集中に、`ファイル->新規`,\n`ファイル->開く`を行うと、別プロセスのExcelが立ち上がります。こういった動作をJavaFXのアプリケーションで行いたいのですが方法がわかりません。\n\n自身のjarのPATHを何かで取得して、Processクラスで呼び出すという方法しかないでしょうか? \nアプリケーションはjavapackagerでexe化して配布するつもりです。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-04T00:32:02.870", "favorite_count": 0, "id": "56364", "last_activity_date": "2019-07-04T11:55:42.310", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17238", "post_type": "question", "score": 0, "tags": [ "javafx" ], "title": "JavaFXでアプリケーションから自分と同じアプリケーションを別プロセスで呼び出したい", "view_count": 169 }
[ { "body": "試していないのでわかりませんが,新しくstageを作製したら新規ウィンドウが立ち上がったりしませんか? \n例えばですが\n\n```\n\n @FXML\n void onClickAction(ActionEvent event){\n Parent root = FXMLLoader.load(getClass().getResource(\"<fxmlファイルのパス>\");\n Scene scene = new Scene(root);\n Stage newStage = new Stage();\n newSt...
56364
56389
56389
{ "accepted_answer_id": null, "answer_count": 1, "body": "<https://stackoverflow.com/a/42166899/1979953> \nと \n<https://stackoverflow.com/a/38297423/1979953>\n\nを参考に\n\n```\n\n extension UILabel {\n func replaceAttributedText(string: String) {\n if let originalAttributedText = self.attributedText {\n let attributes = originalAttributedText.attributes(at: 0, effectiveRange: nil)\n self.attributedText = NSAttributedString(string: string, attributes: attributes)\n }\n }\n }\n \n```\n\nを作ってみたのですが、`空文字`を与えた後で\n\n`Terminating app due to uncaught exception 'NSRangeException', reason:\n'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'`\n\nになります。\n\nつまり\n\n```\n\n self.hogeLabel.replaceAttributedText(string: \"hoge\")\n self.hogeLabel.replaceAttributedText(string: \"\")\n self.hogeLabel.replaceAttributedText(string: \"aaa\") // 空文字を与えてしまった後なのでエラー\n \n```\n\nこのようなコードでエラーが発生します。\n\n`空文字`を与えたことによってアトリビュート情報が吹っ飛んでしまったせいなのかと推測しているのですが、うまく文字列だけ入れ替える方法はないのでしょうか?\n\n(`空文字`ではなくて、スペースなどの`空白文字`を入れるとうまくいくのですが、`空文字`を入れたいです)", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-04T05:13:09.370", "favorite_count": 0, "id": "56370", "last_activity_date": "2019-07-05T11:44:59.283", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "post_type": "question", "score": 0, "tags": [ "swift", "ios" ], "title": "ストーリーボードで設定したアトリビュートを残してUILabelの文字列のみを変更したい", "view_count": 183 }
[ { "body": "コメントしたように現在の`NSAttributeString`の実装では(空文字列を代入したい、と言う前提のもとで)掲載されたextensionは使えない、と言うことになります。\n\nここでは、「他の方法」のひとつとして、「ストーリーボードで設定したアトリビュートを残して文字列のみを変更」出来るようなカスタムLabelクラスをお示ししておきます。\n\n```\n\n import UIKit\n \n class AttrLabel: UILabel {\n //ストーリーボードで設定されたアトリビュートを保存しておくインスタンスプロパティ\n ...
56370
null
56422
{ "accepted_answer_id": "56393", "answer_count": 1, "body": "# 環境\n\n * Python 3.6\n\n# 背景\n\nPythonでCLIツールを作成しています。 \nあるWebサービスから情報を取得して、以下のようなフォーマットでCSVファイルを出力するようなCLIです。 \n実際には20~40列あります。\n\n```\n\n name,a_seconds,b_seconds\n Alice,3600,1800\n Bob,3600,3600\n \n```\n\nコマンドは以下のように実行します。\n\n```\n\n $ python print_csv.py \n \n```\n\n# やりたいこと\n\nCSVのいくつかの列は、ユーザがカスタマイズして出力できるようにしたいです。 \nたとえば、`a_b_hours`列を出力したい場合、以下のような設定をコマンドの外から渡せるようにしたいです。\n\n```\n\n column_name = \"a_b_hours\"\n \n def column_func(df):\n df[column_name] = df[\"a_secons\"] + df[\"b_seconds\"]\n \n```\n\n出力結果\n\n```\n\n name,a_seconds,b_seconds,a_b_hours\n Alice,3600,1800,1.5\n Bob,3600,3600,2\n \n```\n\n# 質問\n\n上記の機能を提供するために、コマンドの外から、Pythonスクリプトを渡すにはどうすればよいでしょうか? \n以下のようなコマンドを実行できるようにしたいです。\n\n```\n\n $ python main.py 3\n num = 3\n \n $ python main.py 3 --script custom.py\n num * num = 9\n \n```\n\nmain.py\n\n```\n\n def custom_print(num: int):\n \"\"\"実際には、10~100行の処理を想定している\"\"\"\n print(f\"num = {num}\")\n \n if if __name__ == \"__main__\":\n parser = argparse.ArgumentParser()\n parser.add_argument(\"num\", type=int, help=\"出力する整数\")\n parser.add_argument(\"--script\", help=\"外部から注入するスクリプト\")\n args = parser.parse_args()\n \n if args.script is not None:\n # args.scriptを使ってcustom_printを変更する\n custom_print = ...\n \n custom_print(args.num)\n \n \n```\n\ncustom.py \nカスタマイズしたい場合、Pythonスクリプトを作成して、このファイルをコマンドに渡します。\n\n```\n\n def custom_print(num: int):\n print(f\"num * num = {num*num}\")\n \n \n```\n\n### 考えたこと\n\n * `exec`を使えばよいんですかね?", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-04T05:32:46.113", "favorite_count": 0, "id": "56371", "last_activity_date": "2019-07-08T17:02:41.807", "last_edit_date": "2019-07-08T17:02:41.807", "last_editor_user_id": "3060", "owner_user_id": "19524", "post_type": "question", "score": 0, "tags": [ "python", "command-line" ], "title": "CLIツールにPythonスクリプトを渡して、柔軟にカスタマイズできるようにしたい", "view_count": 173 }
[ { "body": "`exec`でいいんじゃない?と思いますが、ちゃんと実装するならば`importlib`モジュールを使いたいところです。(何を持って「ちゃんと実装」なのか、と突っ込まれると辛いところですが)\n\nそんなわけで興味があったので、調べました。 \n調べた、と言っても、リファレンスマニュアルを眺めていたら[そのまんまのサンプル](https://docs.python.org/ja/3/library/importlib.html#importing-\na-source-file-directly)があっただけなんですが。\n\n```\n\n # coding: utf-8\n #...
56371
56393
56393
{ "accepted_answer_id": "56438", "answer_count": 1, "body": "Dockerの勉強でPC(Windows 10 Pro)にPHPのコンテナとMariaDBのコンテナを立てて開発をはじめました。\n\nPHPのコンテナからもWindows(A5SQLというツール)からもMariaDBに接続してデータを操作できますが、しばらく開発を続けていると突然A5SQLで接続できなくなり、以下のメッセージが表示されます。\n\n```\n\n Lost connection to MySQL server during query\n Error on data reading from the connection\n \n```\n\nこの状態になってもPHPのコンテナからは接続できます。 \nDocker Desktopを再起動するとまたA5SQLから接続できるようになります。\n\n何が悪いのかわからず原因調査もどこからやっていいかわからない状態です。 \n経験があったり見当がつく方がいらっしゃいましたらご教授いただければ幸いです。\n\n追記 \nmariadbはdocker_composeで起動しています。 \nwebサーバーの方はubuntuのイメージにnginxとphpをインストールしたものです。\n\n```\n\n version: '3'\n services:\n web:\n image: nginx_php:0.1\n container_name: webserver\n ports:\n - 80:80\n volumes:\n - ./setting/nginx.conf:/etc/nginx/conf.d/default.conf\n - ./src:/var/www/html\n depends_on:\n - db\n \n db:\n image: mariadb/server:10.3\n container_name: testdb\n ports:\n - 13306:3306\n volumes:\n - ./db/data:/var/lib/mariadb\n environment:\n MYSQL_ROOT_PASSWORD: testdbpass\n \n```\n\n追記2 \n同じdocker-comoposeをMacで試したところこの現象は発生しませんでした。 \nwindowsとほぼ同時に起動して、しばらくしてwindowsの方では接続できなくなりましたが \nmacのほうでは接続できる状態が続いています。", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-04T07:06:47.940", "favorite_count": 0, "id": "56374", "last_activity_date": "2019-07-06T01:56:21.267", "last_edit_date": "2019-07-05T02:55:03.517", "last_editor_user_id": "19607", "owner_user_id": "19607", "post_type": "question", "score": 0, "tags": [ "docker", "mariadb" ], "title": "DockerのMariaDBに突然つながらなくなります。", "view_count": 324 }
[ { "body": "すいません、自己解決しました。 \n根本的な原因は不明ですが、どうやらA5SQLとの相性が悪かったようです。 \nMySQL Workbenchに変えたらこの現象はおきなくなりました。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-06T01:56:21.267", "id": "56438", "last_activity_date": "2019-07-06T01:56:21.267", "last_edit_date":...
56374
56438
56438
{ "accepted_answer_id": "56384", "answer_count": 1, "body": "[検索の際に全角のスペース記号がセパレータとして扱われていない](https://ja.meta.stackoverflow.com/q/3037/754)\n\nメタの、上記のレポートをみていて、これは、一般的なシステムにおいてよくある問題な気がしました。というのも、日本人を対象にしたシステムであれば、スペースとして取り扱いたいものは、大体の場合において半角スペース(U+0020)と全角スペース(U+3000)ぐらいですが、これを、システムを\ni18n 化して取り扱うときには、各言語ごとにスペースっぽいものを定義して、それらをまとめてスペースと同じ処理を適用することになると思いました。\n\nであるならば、もうちょっと汎用的にこの問題を解決したく、そこで考えたのが、 Unicode の NFKC\n正規化変換をおこなったのちに、結果が半角スペースになるものを、一括してスペースとして取り扱う、というものです。\n\n# 質問\n\nある文字列 s があったときに、 nfkc\n正規化で半角スペースになる文字列のみを、実際に半角スペースに置換したいです。これは、どうやったら実現できるでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-04T07:22:25.610", "favorite_count": 0, "id": "56375", "last_activity_date": "2019-07-04T09:27:28.963", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 1, "tags": [ "python", "unicode" ], "title": "nfkc 正規化で半角スペースに変わる文字たちだけを半角スペースに変更したい", "view_count": 457 }
[ { "body": "Unicode文字にはカテゴリが設定されており、U+0020もU+3000もSeparator, space\n(Zs)となっています。NFKCよりもこちらを使う方が簡単ですし、対応しやすいと思います。Perlや.NET、ES2018の正規表現では`\\p{Zs}`で表現できます。残念ながらPythonには含まれていなさそうです。\n\n改行などを含んでもよければ、[`\\s`](https://docs.python.org/ja/3/library/re.html#index-30)がU+3000を含みます。\n\n> Unicode 空白文字 (これは `[ \\t\\n\\r\\f\\v...
56375
56384
56384
{ "accepted_answer_id": null, "answer_count": 0, "body": "JPA(EclipseLink)を使っています。 \n「画面を開いてから更新操作をするまでに、他のユーザによってデータが変更されていた場合に、エラーとしてデータを再読込する」という仕様があり、そのために`@Version`アノテーションによる楽観的ロックを利用しています。 \nその仕様の対象となるデータは、バージョン値を画面側まで持っていき、更新操作時に再びサーバに送りつけているわけです。\n\nただ、そのデータはバッチ処理でも更新されます。 \nバッチ処理側ではOptimisticLockExceptionを起こすことなく、問答無用で更新できるようにしたいです。 \nしかし、エンティティに`@Version`アノテーションをつけてしまうと、常に楽観ロック制御されてしまいます。\n\n【質問】 \n`@Version`を使用した上で、楽観ロック制御するかどうかを動的に切り替える方法はありますか? \nトランザクション単位で指定できれば、バッチ処理で実行するトランザクションでは楽観ロックをOFFにする、みたいに実装できるので、理想的です。\n\n【環境】 \nWildfly 10 \nJava 8", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2019-07-04T07:29:01.513", "favorite_count": 0, "id": "56376", "last_activity_date": "2019-07-04T07:29:01.513", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8078", "post_type": "question", "score": 1, "tags": [ "java", "java-ee", "jpa" ], "title": "楽観ロック制御の有無を動的に切り替えたい", "view_count": 142 }
[]
56376
null
null