question
dict
answers
list
id
stringlengths
2
5
accepted_answer_id
stringlengths
2
5
popular_answer_id
stringlengths
2
5
{ "accepted_answer_id": null, "answer_count": 1, "body": "Chrome無効設定時にwebviewを含むactivityで落ちる状況です。 \n改善方法がなく困っております。\n\n 1. 設定->設定->アプリと通知からChromeを無効にする\n 2. webviewを含むアプリを起動し、webviewのあるactivityまで遷移する\n\n上記手順2でアプリが強制終了します。 \n事象はAndroid 6.0 / 7.0では起きておらず、Android O(APIレベル26 / 8.0.0)で起きている \nその他は不明\n\n該当コードは下記の通りです\n\n```\n\n public class TestWebActivity extends Activity {\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_testweb);\n WebView webView = (WebView) findViewById(R.id.webView);\n webView.setWebViewClient(new MyWebViewClient());\n }\n \n class MyWebViewClient extends WebViewClient {\n @Override\n public boolean shouldOverrideUrlLoading(WebView view, String url) {\n return true;\n }\n }\n }\n \n```\n\nエラーログは下記の通り\n\n> 12-28 16:41:42.146 31047-31047/xxxxxxxxx E/AndroidRuntime: FATAL EXCEPTION:\n> main \n> Process: xxxxxxxxx, PID: 31047 \n> java.lang.RuntimeException: Unable to start activity\n> ComponentInfo{xxxxxxxxx/xxxxxxxxx.TestWebActivity}:\n> android.view.InflateException: Binary XML file line #33: Binary XML file\n> line #33: Error inflating class android.webkit.WebView \n> at\n> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817) \n> at\n> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) \n> at android.app.ActivityThread.-wrap11(Unknown Source:0)\n\nError inflating class android.webkit.WebViewについてはAndroid5でのバグの話はありますが、Android\nOでの事象が見つかりませんでした。\n\n何かご存じの方いらっしゃいましたらお知らせいただけると幸いです。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T08:46:36.170", "favorite_count": 0, "id": "40580", "last_activity_date": "2018-07-16T01:42:42.653", "last_edit_date": "2017-12-28T09:20:30.617", "last_editor_user_id": "3068", "owner_user_id": "26822", "post_type": "question", "score": 0, "tags": [ "android" ], "title": "Android OでChrome無効設定時にwebviewを含むactivityで落ちる", "view_count": 857 }
[ { "body": "該当の機種がAndroid8βから8.0.0にアップデートしたものだっただめ起きていたようです。 \n同様の状態の機種が2台あり、1台は8.1にアップデートでこの事象は起こりませんでした。 \nもう1台は8.0.0のままで端末のリセットをかけると同様の事象は起こらなくなりました。\n\nここからは憶測ですが、Android8βから8.0.0にアップデートした際にchrome等のパッケージがβで利用されていたものが残っていたのではないかと推測しています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-11T04:36:58.610", "id": "40878", "last_activity_date": "2018-01-11T04:36:58.610", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26822", "parent_id": "40580", "post_type": "answer", "score": 1 } ]
40580
null
40878
{ "accepted_answer_id": null, "answer_count": 2, "body": "<http://ftpkimi-hirama.udr.weblife.me>\nが私のHPのアドレスですが、たどり着けません。このアドレスは存在するのですが、二重にアドレスが使用されているかも知れません。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T10:07:19.450", "favorite_count": 0, "id": "40582", "last_activity_date": "2017-12-28T12:37:57.580", "last_edit_date": "2017-12-28T12:21:18.643", "last_editor_user_id": "3060", "owner_user_id": "26823", "post_type": "question", "score": -4, "tags": [ "windows" ], "title": "localhost3000/1/index.html が開けません", "view_count": 232 }
[ { "body": "タイトルと本文でURLが異なります。とりあず本文側のURLは間違っているため、IPアドレス以前の問題です。まずはURLを再度確認すべきです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T10:15:45.783", "id": "40583", "last_activity_date": "2017-12-28T10:15:45.783", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "40582", "post_type": "answer", "score": 2 }, { "body": "問題の起きている環境がはっきりしないので、現時点で気になる点を挙げてみると\n\n**1点目** \n単純に打ち間違いかもしれませんが、タイトルの`localhost3000`は正しくは`localhost:3000`ではないでしょうか。\n\n**2点目** \n本文の`http://ftpkimi-\nhirama.udr.weblife.me/`ですが、`ftp`という文字が含まれていることを考えるとレンタルサーバ等へのコンテンツアップロード用のURLと、実際にHP(webサイト)としてアクセスする際のURLは別のものになるのではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T12:37:57.580", "id": "40586", "last_activity_date": "2017-12-28T12:37:57.580", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "40582", "post_type": "answer", "score": 0 } ]
40582
null
40583
{ "accepted_answer_id": "40587", "answer_count": 1, "body": "Swift, ios アプリの開発で、 `UserDefaults.standard.set(\"hogehoge\", forKey: \"my-key\")`\nを、設定値の永続化の手段として使ってみようとしています。 その過程で、 UserDefaults の set メソッドを見ていました。\n\n```\n\n /*!\n -setObject:forKey: immediately stores a value (or removes the value if nil is passed as the value) for the provided key in the search list entry for the receiver's suite name in the current user and any host, then asynchronously stores the value persistently, where it is made available to other processes.\n */\n open func set(_ value: Any?, forKey defaultName: String)\n \n```\n\n端的にまとめると、「最初は実行プロセスの中で値を書き換えて、それをそのうち永続化層などに反映するよ、その後は他のプロセスから見えるようになるよ」と書いてあると思っています。\n\nふと疑問に思ったのが、とあるアプリケーションが設定した default 値は他のアプリから参照できるでしょうか? (できてしまうのでしょうか?)\nというのも、仮に他のアプリから見えたとすると、一つおかしなアプリをダウンロードしてきて、その挙動のお行儀が悪かったとすると、他のアプリ達にもれなく影響を与えてしまいそうだな、と考えたからです。\n\n### 質問\n\n * `UserDefaults.standard.set(val, forKey: key)` で保存した設定値は、どの範囲に影響を及ぼしますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T11:48:02.503", "favorite_count": 0, "id": "40584", "last_activity_date": "2017-12-28T12:38:19.370", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 0, "tags": [ "swift", "ios" ], "title": "swift で UserDefaults.standard.set した値はすべてのアプリケーションで共有される?", "view_count": 720 }
[ { "body": "* **_UserDefaults.standard.set(val, forKey: key) で保存した設定値は、どの範囲に影響を及ぼしますか?_**\n\n(通常の)`UserDefaults`により格納される値は、該当アプリケーションからだけ参照できます。(最終的にSandbox保護されたアプリケーション専用の領域にファイルとして永続化されます。)\n\n**_とあるアプリケーションが設定した default 値は他のアプリから参照できるでしょうか? (できてしまうのでしょうか?)_** \n⇒(通常は)できません。\n\n※どんな場合が通常でないのかは、下の方まで読んでください。\n\n**_仮に他のアプリから見えたとすると、一つおかしなアプリをダウンロードしてきて、その挙動のお行儀が悪かったとすると、他のアプリ達にもれなく影響を与えてしまいそうだ_**\n\niOSアプリケーションなどで言われる「Sandbox保護」と言うのはアプリケーション間で、可能な限り、そう言った「他のアプリたちにもれなく影響を与えて」しまうのを防ぐ仕組みだと思ってもらうと良いでしょう。その分、iOSでは複数のアプリでデータを共有したり、協調動作したりするのが難しくなっており、極めて少数の限られたAPIを通じてのみデータの共有や協調動作ができるようになっています。(通常の)`UserDefaults`は、その極めて少数には入っておらず、アプリケーションごとに独立です。\n\n#\n[`UserDefaults`](https://developer.apple.com/documentation/foundation/userdefaults)\n\n(抜粋)\n\n> ## Sandbox Considerations\n>\n> A sandboxed app cannot access or modify the preferences for any other \n> app, with the following exceptions:\n>\n> * App extensions on macOS and iOS\n> * Other apps in your application group on macOS\n>\n\n(拙訳)\n\n> ## Sandbox環境での考慮事項\n>\n>\n> Sandbox保護されたアプリでは、以下の例外を除き、他のいかなるアプリの設定(訳注:`UserDefaults`は「設定」の保存を主な用途と想定しているので、これは`UserDefaults`の保存内容だと思ってください)を参照することも変更することもできません。\n>\n> * macOSとiOSのアプリ拡張\n>\n> * macOSのアプリグループ内の他のアプリ (訳注:明記されていませんが、iOSにもアプリグループの概念があります)\n>\n>\n\nアプリグループの機能は同じデベロッパー内のアプリでしか使用できないようになっていますが、同じアプリグループに所属するアプリの中で、「その挙動のお行儀が悪かった」ものがあったとすると、「他のアプリ達に」「影響を与えて」しまう可能性はあります。が、「もれなく」ではないので、それはそのデベロッパーの責任ということになるでしょう。 \n(アプリグループによる`UserDefaults`の共有に関しては、日本語の良記事がすぐに見つかりますので、興味がお有りならば検索してみてください。)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T12:38:19.370", "id": "40587", "last_activity_date": "2017-12-28T12:38:19.370", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "40584", "post_type": "answer", "score": 1 } ]
40584
40587
40587
{ "accepted_answer_id": "40588", "answer_count": 1, "body": "本日Apache2.2を動作させているWebサーバを確保できたので \nこちらでのPHP動作環境を構築しようとしています。\n\n当該筐体はWindwosServer2012R2 = 64bitですが \nProgramFiles(x86)側にしかApacheのフォルダが存在していない状況でしたので、 \nPHPはx86版を入手し格納しました。 \n(php-7.0.26-Win32-VC14-x86)\n\nここでいう格納とは、PHPのサイトから入手した上記zipを解凍後、 \nphpというフォルダ名に変え、丸ごとをC:\\Program Files (x86)に配置した操作です。\n\n<https://www.adminweb.jp/apache/php/index1.html> \nこちらのサイトの見よう見まねで、PHPの環境構築に挑んでいますが \nApatcheの再起動で、phpのdllを読み込めない事態が生じています(多分)。添付のハードコピーのとおり。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/o7qob.png)](https://i.stack.imgur.com/o7qob.png)\n\nこの英語の意味がよく分かりませんが、現在生じている問題は \n今回のWebサーバのVer(Apache2.2)に対し \nApatchのhttpd.confに新たに定義したPHPのdllのVerがそぐわない、ということを述べているのでしょうか?\n\nLoadModule php7_module C:\\Program Files (x86)\\PHP\\php7apache2_4.dll\n\nもし私の推察どおりであった場合、かつPHPのVerを7.X以上であることがマストである場合、 \nせっかく確保できたWebサーバのApacheは2.4へアップグレードせざるを得ない?ということでしょうか?\n\n(自分の端末をWebサーバに見立て開発を開始しだした際は、xamppで一連を入手し \nなんら苦労せず環境を整えられたが、いざ実動作環境へ移行しようとなると、この時のツケが=勉強不足がアダに)\n\nいつも初歩的な質問をしてしまい、申し訳ありませんが \n何卒よろしくお願い申し上げます。\n\n=====追記===== \nhttpd.confに記載したパスに空白が含まれていたので、ご教示頂きましたとおり「\"」の引用符を使用したことで、一応に状況は変化しました。 \nしかしまだ下記のとおり、PHPのdllの読み込みに失敗しているようです。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/mcYFG.png)](https://i.stack.imgur.com/mcYFG.png) \n何を意味しているのか分からないメッセージなのですが、 \n①64bitの筐体ながら32bit版のphpを入手して利用しようとしていることが問題なのか(ApacheがProgramFile\nx86フォルダにしか見当たらなかったので、x86バージョンを入手しました。これ問題?)\n\n②入手したPHPのVerがApache2.2に対応していないことが問題なのか\n\n③その他の問題なのか \n一体どういう事象なのかどなたかご教示をお願いできますでしょうか?何卒よろしくお願い申し上げます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T12:28:10.607", "favorite_count": 0, "id": "40585", "last_activity_date": "2017-12-29T07:11:05.227", "last_edit_date": "2017-12-29T05:25:30.357", "last_editor_user_id": "25696", "owner_user_id": "25696", "post_type": "question", "score": 0, "tags": [ "php", "apache" ], "title": "本番環境Webサーバ(Apache)に、PHPの動作環境を構築したい", "view_count": 648 }
[ { "body": "LoadModule行は「モジュール名」と「共有ライブラリ名(=ファイル名)」の2つを引数に指定する必要がありますが、インストール先のフォルダ名に空白が含まれているためエラーになっているのだと思います。 \n該当箇所を以下の様に`\" \"`でくくってみてください。\n\n`LoadModule php7_module \"C:\\Program Files (x86)\\PHP\\php7apache2_4.dll\"`\n\n参考: \n<http://d.hatena.ne.jp/amagasa2106/20100528/1275065976>\n\n* * *\n\n**追記** \nLoadModuleで指定するファイル(DLL)は推察の通りApacheのバージョンに合わせる必要があるようなので、PHPのインストール先に`php7apache2_2.dll`が既に存在するならそれに合わせて`httpd.conf`の記述も修正するか、もしくはApacheの入れ替えやXAMPPでの導入を検討してみてください。 \n(手に入れたマシンに元々入っていたApacheにこだわる必要は無いと思います)\n\n`PHP{PHP_MAIN_VERSION}apache{APACHE_HTTPD_VERSION}.dll`\n\n参考: \n<https://teratail.com/questions/94332>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T12:47:20.243", "id": "40588", "last_activity_date": "2017-12-29T07:11:05.227", "last_edit_date": "2017-12-29T07:11:05.227", "last_editor_user_id": "3060", "owner_user_id": "3060", "parent_id": "40585", "post_type": "answer", "score": 1 } ]
40585
40588
40588
{ "accepted_answer_id": null, "answer_count": 1, "body": "なぜseabornはsnsと略すんですか? \nまた、matplotlibがpltやmplと略されているのを見ますがどちらが一般的なのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T14:29:47.417", "favorite_count": 0, "id": "40589", "last_activity_date": "2017-12-28T16:57:56.310", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25518", "post_type": "question", "score": 2, "tags": [ "matplotlib" ], "title": "Seaborn、matplotlib.pyplotの略称", "view_count": 535 }
[ { "body": "・sns \n[ここ](https://stackoverflow.com/questions/41499857/seaborn-why-import-as-\nsns)からリンクをたどれますが、snsはSeabornという名前を持つキャラクターのイニシャルだそうです。 \n[Samuel Norman \"Sam\" Seaborn ](https://en.wikipedia.org/wiki/Sam_Seaborn)\n\n・pltとmpl \nmatplotlib.pyplotならplt, matplotならmplかなと。\n\n```\n\n import matplotlib.pyplot as plt\n import matplotlib as mpl\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T16:57:56.310", "id": "40594", "last_activity_date": "2017-12-28T16:57:56.310", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25449", "parent_id": "40589", "post_type": "answer", "score": 2 } ]
40589
null
40594
{ "accepted_answer_id": null, "answer_count": 0, "body": "python3系で書かれた[サンプルコード](https://github.com/KatsuhiroMorishita/AMeDAS_downloader/blob/master/html_parser.py)をpython2系で実行するためにコードを書き換えようとしているのですが不明な点があります.\n\n上のサンプルコードに`from io import open`と追加し`python html_parser.py`と実行したところ\n\n```\n\n File \"html_parser.py\", line 314, in get_data\n if \"1時間ごとの値\" in txt or \"10分ごとの値\" in txt: # 観測データの種類を判別し\n て呼び出す関数を変えている\n TypeError: 'in <string>' requires string as left operand \n \n```\n\nと表示されました. \nそこで `def get_data(lines, data=None)`の中で`if u\"1時間ごとの値\" in txt or u\"10分ごとの値\" in\ntxt`のようにすべての日本語の前にuをつけて実行したところ,\n\n```\n\n Traceback (most recent call last):\n File \"html_parser.py\", line 412, in <module>\n main()\n File \"html_parser.py\", line 399, in main\n data = get_data(lines, _date) # error occurred! 2017 12 28\n File \"html_parser.py\", line 315, in get_data\n data = get_data_from_past_format(lines)\n File \"html_parser.py\", line 166, in get_data_from_past_format\n indexes = get_column_names(lines) # 項目名と、項目名が含まれる最後の行号\n を取得\n File \"html_parser.py\", line 146, in get_column_names\n index_list = [\"\"] * len(table[0]) # まずは列の数だけ空の文字列を作る\n IndexError: list index out of range\n \n```\n\nとのエラーが出ました.python3の環境とpython2の環境で出力を比べたところpython2環境下では`def\nget_data_from_past_format(lines)`の返り値がなにもなく,おそらく関数内の正規表現マッチングが上手く働いていないかと思っております.どのように対応すればよいでしょうか.\n\n実行手順は \n1\\.\n[サンプルコード](https://github.com/KatsuhiroMorishita/AMeDAS_downloader/blob/master/download.py)(download.py)に`from\nio import open`を追加して`python download.py`を実行 \n2\\.\n[サンプルコード](https://github.com/KatsuhiroMorishita/AMeDAS_downloader/blob/master/html_parser.py)を実行 \nしています.\n\nちなみにpython3環境下では1,2とも動作確認済みです.\n\nよろしくお願いいたします.", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T14:38:05.680", "favorite_count": 0, "id": "40590", "last_activity_date": "2018-01-25T10:56:38.770", "last_edit_date": "2018-01-25T10:56:38.770", "last_editor_user_id": "26604", "owner_user_id": "26604", "post_type": "question", "score": 3, "tags": [ "python", "python3", "正規表現", "unicode", "python2" ], "title": "python2とpython3の文字コードと正規表現", "view_count": 312 }
[]
40590
null
null
{ "accepted_answer_id": null, "answer_count": 2, "body": "3次元空間において、r = (x, y, z)を1点決めて、 \nこれを中心とした半径nの球を考えます。 \n次に、この球の内部をグリッドで細かく立方体に分割します。 \nこの立方体の辺の長さはmとします。 \nこのとき、グリッドの交点の座標をすべて計算したいです。\n\nやりたいことのイメージは、3次元の球で図を書くのが難しいので、 \n2次元の円で図を書きました。以下がそれです。 \nグリッドの交点の座標(赤色の点)をすべて求めたいです。\n\n[![](https://i.stack.imgur.com/8CYqE.jpg)](https://i.stack.imgur.com/8CYqE.jpg)\n\nこのようなことを実現するコードは、Pythonでどのように書けば良いでしょうか? \nfor文で座標をmずつずらすのをぜんぶ書けば良さそうだと思ったのですが、 \n球体だと効率的に書くのが思ったより難しい気がしました。\n\nどなたかご教授いただけるとありがたいです。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T15:43:11.640", "favorite_count": 0, "id": "40592", "last_activity_date": "2018-01-14T06:19:00.190", "last_edit_date": "2018-01-14T06:19:00.190", "last_editor_user_id": "754", "owner_user_id": "25649", "post_type": "question", "score": 1, "tags": [ "python", "アルゴリズム" ], "title": "球内のグリッドの交点の座標をすべて求めたい", "view_count": 783 }
[ { "body": "簡単のために`r=(0,0,0)`の場合を考えると、擬似コードで書くとこうすればできるのではないでしょうか。(`abs`は絶対値、`i,j,k`は整数)\n\n```\n\n for i s.t. abs(i*m) <= n:\n for j s.t. abs(j*m) <= (n**2 - (i*m)**2)^(1/2):\n for k s.t. abs(k*m) <= (n**2 - (i*m)**2 - (j*m)**2)^(1/2):\n print(im, jm, km)\n \n```\n\n逆に言うとこれ以上高速化するには並列処理するぐらいしかないと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T16:41:20.890", "id": "40593", "last_activity_date": "2017-12-28T16:46:27.083", "last_edit_date": "2017-12-28T16:46:27.083", "last_editor_user_id": "20206", "owner_user_id": "20206", "parent_id": "40592", "post_type": "answer", "score": 1 }, { "body": "for のループ回数と掛け算の回数を減らして、代わりに set の操作を使ってみました。 \nどちらが効率が良いかは計測してないのでわかりません。\n\n```\n\n import math\n \n X = 10\n Y = 15\n Z = 20\n \n n = 10\n m = 4\n \n points = set()\n \n # 0<=x<=y<=z の座標を列挙\n vals = list(map(lambda i: i * m, range(n // m + 1)))\n for xi, x in enumerate(vals):\n for yi, y in enumerate(vals[xi:]):\n for zi, z in enumerate(vals[yi:]):\n if x * x + y * y + z * z <= n * n:\n points.add((x, y, z))\n \n # x, y, z の座標を入れ替えても球の中にある\n #points |= set(map(lambda p: (p[0], p[1], p[2]), points))\n points |= set(map(lambda p: (p[0], p[2], p[1]), points))\n points |= set(map(lambda p: (p[1], p[2], p[0]), points))\n points |= set(map(lambda p: (p[1], p[0], p[2]), points))\n points |= set(map(lambda p: (p[2], p[0], p[1]), points))\n points |= set(map(lambda p: (p[2], p[1], p[0]), points))\n \n # x, y, z の符号を反転させても球の中にある\n points |= set(map(lambda p: ( p[0], p[1], -p[2]), points))\n points |= set(map(lambda p: ( p[0], -p[1], p[2]), points))\n points |= set(map(lambda p: (-p[0], p[1], p[2]), points))\n \n # 中心を移動\n points = [ ( p[0] + X, p[1] + Y, p[2] + Z ) for p in points ]\n \n print(points)\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-28T17:46:46.200", "id": "40595", "last_activity_date": "2017-12-28T17:46:46.200", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5288", "parent_id": "40592", "post_type": "answer", "score": 1 } ]
40592
null
40593
{ "accepted_answer_id": null, "answer_count": 1, "body": "ホームページの画像を中心に持っていきたいです。 \nプログラマの方に依頼して、ページを作成していただきました。 \n大変素早く作っていただき、感謝しております。\n\n基本的なコードしか知らないので、こちらは作っていただいたのをいじるぐらいです。 \n画像を align centerに設定しても動きません。\n\nFTPサーバー経由でなんどもチャレンジしたのですが・・・ \n失敗に終わっております。\n\n一部コードを記載します。 \nよろしくお願いします。\n\n```\n\n <div id=\"section-blog\" class=\"page-section\">\n <h2 class=\"center uppercase t300 ls3 font-body\">レジュメについて</h2>\n <div class=\"section nobottommargin\">\n <div class=\"container clearfix\">\n <div class=\"row topmargin clearfix\">\n <div class=\"ipost col-sm-12 bottommargin clearfix\">\n <div class=\"row\">\n <div class=\"col-sm-12\">\n <br />\n \n <p class=\"center\"> サンプル </p> \n <div class=\"textcenter\"><img align=\"left\" src=\"images/IMG_4708.JPG\" alt=\"SAMPLE2\" height=\"400px\" width=\"300px\" align=\"center\"></div> \n <div class=\"textcenter\"><img align=\"rigtht\" src=\"images/IMG_4709.JPG\" alt=\"SAMPLE1\" height=\"390px\" width=\"300px\" align=\"center\"></div> <br clear=\"both\"> \n <p class=\"p_no_margin\"><i class=\"fa fa-hand-o-right\" aria-hidden=\"true\"></i>レジュメのページ数は原則1枚です。職務歴が長い場合、ページ数が2枚でも許されています。</p>\n <p class=\"p_no_margin\"><i class=\"fa fa-hand-o-right\" aria-hidden=\"true\"></i>弊社はTOP RESUMEなどの、RSSを受信し日々のアドバイスに活用させていただいております。</p>\n \n </div> \n </div>\n </div>\n </div>\n </div>\n </div>\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T02:10:37.493", "favorite_count": 0, "id": "40597", "last_activity_date": "2018-02-27T05:42:06.473", "last_edit_date": "2018-02-27T05:42:06.473", "last_editor_user_id": "21007", "owner_user_id": "21007", "post_type": "question", "score": -1, "tags": [ "html" ], "title": "ホームページの画像を中心に持っていきたい。", "view_count": 187 }
[ { "body": "img align=\"rigtht\"となっていますが、img align =\n\"center\"にしました。imgの部分をタグで括りました。こちらで大丈夫ですか?\n\n```\n\n <div id=\"section-blog\" class=\"page-section\">\r\n <h2 class=\"center uppercase t300 ls3 font-body\">レジュメについて</h2>\r\n <div class=\"section nobottommargin\">\r\n <div class=\"container clearfix\">\r\n <div class=\"row topmargin clearfix\">\r\n <div class=\"ipost col-sm-12 bottommargin clearfix\">\r\n <div class=\"row\">\r\n <div class=\"col-sm-12\">\r\n <br />\r\n \r\n <p class=\"center\"> サンプル </p>\r\n <div class=\"textcenter\"><center><img align=\"center\" src=\"images/IMG_4708.JPG\" alt=\"SAMPLE2\"  height=\"400px\" width=\"300px\"></center></div>\r\n <div class=\"textcenter\"><center><img align=\"center\" src=\"images/IMG_4709.JPG\" alt=\"SAMPLE1\" height=\"390px\" width=\"300px\" ></center></div>\r\n <br clear=\"both\">\r\n <p class=\"p_no_margin\"><i class=\"fa fa-hand-o-right\" aria-hidden=\"true\"> </i>レジュメのページ数は原則1枚です。職務歴が長い場合、ページ数が2枚でも許されています。</p>\r\n <p class=\"p_no_margin\"><i class=\"fa fa-hand-o-right\" aria-hidden=\"true\"></i>弊社はTOP RESUMEなどの、RSSを受信し日々のアドバイスに活用させていただいております。</p>\r\n \r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T03:06:07.463", "id": "40600", "last_activity_date": "2017-12-29T03:06:07.463", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25766", "parent_id": "40597", "post_type": "answer", "score": 1 } ]
40597
null
40600
{ "accepted_answer_id": "40603", "answer_count": 1, "body": "今日、街中を歩いていたら次のような qr コードのようなものを見つけました。\n\n[![qr コード without\n四隅の四角形](https://i.stack.imgur.com/q72yd.jpg)](https://i.stack.imgur.com/q72yd.jpg)\n\nQR コードっぽいのですが、四隅に四角形がないので、多分仕様としては QR コードではなさそうだ、と思っています。\n\n### 質問\n\n * 上記のような qr コードっぽいものは一体何ですか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T03:54:46.177", "favorite_count": 0, "id": "40602", "last_activity_date": "2017-12-29T13:28:39.633", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 5, "tags": [ "untagged" ], "title": "四隅に四角形がない、 QR コードようなこれは何?", "view_count": 1795 }
[ { "body": "[SPコード](https://ja.wikipedia.org/wiki/SP%E3%82%B3%E3%83%BC%E3%83%89)です。 \n質問の画像のコードには2行程度のテキストが11の言語で含まれていました。\n\n中国語の部分:\n\n> 於夜間穿越行人穿越道時 請按下按鈕 \n> 為保障您的安全 敬請遵守交通號誌\n>\n\n>> google翻訳: \n> 夜に横断歩道を横断するときにボタンを押す \n> 安全を守るために、交通標識に従ってください\n\n利用例として、個人番号通知の封筒と通知カード(の台紙?)に印刷されていたものがあります。 \nQRコードがカメラの端にでも入ればすぐに認識される一方、このSPコードはもう少し正確にカメラを合わせる必要があり、視覚障害者向けとして機能していたかは疑問です。\n\n### 商標・特許\n\n「SPコード」は登録商標のようで、これを避けるために一部では「音声コード」や「Uni-Voice」と呼ばれています。 \nただし、\n\n>\n> 「SPコード」および「スピーチオ」に関する権利は、(株)廣済堂と(株)オリジナルデザインが共同出願した特許第3499220号、特許第4439756号、特許第4744745号および特許第4772631号保護されています。 \n> <http://www.sp-code.com/index.html>\n\nとの事で、「音声コード」などと呼ばれているものでも、自由に使える実装などは無さそうです。\n\n### 参考\n\n関連団体:\n\n * [SPコード公式ホームページ](http://www.sp-code.com/index.html)\n * [日本視覚障がい情報普及支援協会](http://www.javis.jp/index.php)\n * [Uni-Voice事業企画株式会社](http://uni-voice.co.jp/)\n\n報道:\n\n * [押しボタン式信号機、15言語対応に 警視庁](https://www.nikkei.com/article/DGXLASDG09H0Q_Z01C16A2CN0000/)\n * [信号表示を多言語対応へ 押しボタン式、警視庁](http://www.sankei.com/photo/daily/news/161209/dly1612090008-n1.html)\n * [<音声コード・ユニボイス>手話や音声、多言語に対応−−らくらくホンやiPhoneで…](http://mainichi.jp/universalon/articles/20140930/mog/00m/040/030000c)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T04:25:27.187", "id": "40603", "last_activity_date": "2017-12-29T13:28:39.633", "last_edit_date": "2017-12-29T13:28:39.633", "last_editor_user_id": "3054", "owner_user_id": "3054", "parent_id": "40602", "post_type": "answer", "score": 5 } ]
40602
40603
40603
{ "accepted_answer_id": "40617", "answer_count": 1, "body": "AWS Lambdaから、curlを使ってFTP接続をしようとしています。 \nしかし、pwが'\\06'始まりなのが災いしてか、PWを正しく引き渡すことができず、 \nAccess denied: 530\"になってしまいます。 \n(コマンドプロンプトから実行すると接続でることを確認しました。)\n\n一部ですが、コードは以下の通りです。\n\n```\n\n var com = 'curl --globoff -u testuser:\\06testpw ${url}'\n const child = exec(com, function(error) {\n context.done(error, 'Process complete!')});\n \n```\n\n※実際には、${url}に接続先を指定しています。\n\n・上記の場合、'testuser:06testpw'が引き渡されます。 \n・’testuser:'+'\\06'+'testpw'とすると、'testuser:testpw'が引き渡されます。 \n・'\\\\\\06testpw'を指定すると、'\\\\\\06testpw'そのままになってしまいます。\n\nEncodeなどいろいろ試しましたが、うまくいきませんでした。。\n\nお力添えいただきたく、よろしくお願いいたします。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T11:20:01.377", "favorite_count": 0, "id": "40604", "last_activity_date": "2017-12-30T02:25:21.497", "last_edit_date": "2017-12-29T22:22:26.653", "last_editor_user_id": "26828", "owner_user_id": "26828", "post_type": "question", "score": 0, "tags": [ "javascript", "node.js", "aws-lambda" ], "title": "AWS Lambda Node.js6.10 '/06'のエスケープがうまくいかない", "view_count": 86 }
[ { "body": "[`child_process.exec`](https://nodejs.org/docs/v0.6.10/api/child_processes.html#child_process.exec)は\n\n> Runs a command in a shell and buffers the output.\n\nとのことですので、`exec`に渡した値が改めてシェルによって再度解析されます。`curl`に引数`--globoff`, `-u`,\n`testuser:\\06testpw`, `${url}`を渡したいのであれば`exec`には\n\n```\n\n curl --globoff -u testuser:\\\\06testpw ${url}\n \n```\n\nを渡す必要があり、JavaScriptコードでは\n\n```\n\n var com = 'curl --globoff -u testuser:\\\\\\\\06testpw ${url}';\n \n```\n\nと2重エスケープすればいいのではないでしょうか?\n\n* * *\n\n> '\\06testpw'を指定すると、'\\06testpw'そのままになってしまいます。\n\nこれは本当でしょうか? 単に成功しないことと`\\\\06testpw`になることは別問題ですが、どのように確認されたのでしょうか?", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-30T02:25:21.497", "id": "40617", "last_activity_date": "2017-12-30T02:25:21.497", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "40604", "post_type": "answer", "score": 0 } ]
40604
40617
40617
{ "accepted_answer_id": null, "answer_count": 0, "body": "以下、問題再現のために無理矢理書いたコードです。 \n(実際は、多少入り組んだ rspec のファイルを rubocop でパースした際に遭遇しました)\n\n```\n\n # test.rb\n n = 100000\n res = {}\n 1.upto(n).to_a.inject(res) do |r, i|\n r[i] = {}\n end\n \n def f(x)\n x.each_value { |v| f(v) }\n end\n \n f(res)\n \n```\n\nこのコードを、DockerHub で配布されている Docker イメージ `ruby:2.5.0-alpine3.7`\nで実行すると、比較的浅い段階で例外になります。\n\n```\n\n % docker container run -v (pwd):/mnt/my --rm -it ruby:2.5.0-alpine3.7 ruby -v /mnt/my/test.rb\n ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux-musl]\n Traceback (most recent call last):\n 149: from /mnt/my/test.rb:11:in `<main>'\n 148: from /mnt/my/test.rb:8:in `f'\n 147: from /mnt/my/test.rb:8:in `each_value'\n 146: from /mnt/my/test.rb:8:in `block in f'\n 145: from /mnt/my/test.rb:8:in `f'\n 144: from /mnt/my/test.rb:8:in `each_value'\n 143: from /mnt/my/test.rb:8:in `block in f'\n 142: from /mnt/my/test.rb:8:in `f'\n ... 137 levels...\n 4: from /mnt/my/test.rb:8:in `f'\n 3: from /mnt/my/test.rb:8:in `each_value'\n 2: from /mnt/my/test.rb:8:in `block in f'\n 1: from /mnt/my/test.rb:8:in `f'\n /mnt/my/test.rb:8:in `each_value': stack level too deep (SystemStackError)\n \n```\n\n一方で、Ruby のソース以外は同等である Docker イメージ `ruby:2.4.3-alpine3.7` では比較的深めの段階で例外となります。\n\n```\n\n % docker container run -v (pwd):/mnt/my --rm -it ruby:2.4.3-alpine3.7 ruby -v /mnt/my/test.rb\n ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux-musl]\n /mnt/my/test.rb:8:in `each_value': stack level too deep (SystemStackError)\n from /mnt/my/test.rb:8:in `f'\n from /mnt/my/test.rb:8:in `block in f'\n from /mnt/my/test.rb:8:in `each_value'\n from /mnt/my/test.rb:8:in `f'\n from /mnt/my/test.rb:8:in `block in f'\n from /mnt/my/test.rb:8:in `each_value'\n from /mnt/my/test.rb:8:in `f'\n from /mnt/my/test.rb:8:in `block in f'\n ... 10067 levels...\n from /mnt/my/test.rb:8:in `block in f'\n from /mnt/my/test.rb:8:in `each_value'\n from /mnt/my/test.rb:8:in `f'\n from /mnt/my/test.rb:11:in `<main>'\n \n```\n\n加えて、Debian 版の Docker イメージ `ruby:2.5.0-stretch` で実行すると、比較的深めの段階で例外となります。\n\n```\n\n % docker container run -v (pwd):/mnt/my --rm -it ruby:2.5.0-stretch ruby -v /mnt/my/test.rb\n ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]\n Traceback (most recent call last):\n 9878: from /mnt/my/test.rb:11:in `<main>'\n 9877: from /mnt/my/test.rb:8:in `f'\n 9876: from /mnt/my/test.rb:8:in `each_value'\n 9875: from /mnt/my/test.rb:8:in `block in f'\n 9874: from /mnt/my/test.rb:8:in `f'\n 9873: from /mnt/my/test.rb:8:in `each_value'\n 9872: from /mnt/my/test.rb:8:in `block in f'\n 9871: from /mnt/my/test.rb:8:in `f'\n ... 9866 levels...\n 4: from /mnt/my/test.rb:8:in `f'\n 3: from /mnt/my/test.rb:8:in `each_value'\n 2: from /mnt/my/test.rb:8:in `block in f'\n 1: from /mnt/my/test.rb:8:in `f'\n /mnt/my/test.rb:8:in `each_value': stack level too deep (SystemStackError)\n \n```\n\nこの違いは、Ruby によるものでしょうか?それとも Linux (実行環境)によるものでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T12:46:20.370", "favorite_count": 0, "id": "40605", "last_activity_date": "2017-12-29T12:46:20.370", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26830", "post_type": "question", "score": 2, "tags": [ "ruby" ], "title": "Alpine Linux 3.7 でコンパイルした Ruby 2.5.0 が比較的浅い再帰で SystemStackError となる理由を教えてください", "view_count": 200 }
[]
40605
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "初心者です。 \nわかる方教えていただけると本当に助かります!\n\nnode.jsをインストールしまして、以下のコマンドを入れるとこんな感じで表示されます。node.jsで動作保証しています。 \nどうしたら解決できますでしょうか。\n\n```\n\n git clone xxx\n \n git clone xxx\n ^^^^^\n \n SyntaxError: Unexpected identifier\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T13:53:42.250", "favorite_count": 0, "id": "40608", "last_activity_date": "2017-12-29T14:28:36.840", "last_edit_date": "2017-12-29T14:28:36.840", "last_editor_user_id": "19110", "owner_user_id": "26831", "post_type": "question", "score": 0, "tags": [ "git", "node.js" ], "title": "node.jsでgit clone xxx出来ません。", "view_count": 192 }
[]
40608
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "お世話になります。\n\nアプリが起動していない状態で、 \nローカル通知を受信した時にアプリのバッジの数を増やしたいのですが、 \nローカル通知を受信した時に、何かの処理をさせるには、 \nどうすれば良いのでしょうか?\n\nアプリがフォアグラインドの時は、\n\n```\n\n func userNotificationCenter(_ center: UNUserNotificationCenter,\n willPresent notification: UNNotification,\n withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {\n {\n }\n \n```\n\nで受け取れるようなのですが、アプリが起動していない時に、 \nバッジの数を増やす方法がわかりません。\n\nローカル通知ではこのようなことができないのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T14:51:12.997", "favorite_count": 0, "id": "40610", "last_activity_date": "2017-12-29T14:58:05.067", "last_edit_date": "2017-12-29T14:58:05.067", "last_editor_user_id": "12297", "owner_user_id": "12297", "post_type": "question", "score": 1, "tags": [ "swift", "ios", "xcode" ], "title": "swiftで、アプリが起動していない状態で、ローカル通知を受信した時にアプリのバッジの数を増やしたい。", "view_count": 305 }
[]
40610
null
null
{ "accepted_answer_id": "40614", "answer_count": 1, "body": "第9回 驚きの性能?! Obeject Detection APIで物体認識に挑戦 \n<https://book.mynavi.jp/manatee/detail/id=76951>\n\nにならってGCPを動かしてみました。 \nアプリが使用可能になるところまで順調に進み、 \n最後にVMインスタンスで作成した外部IPアドレスにアクセスしたところ、 \n認証を求められました。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/66YOM.png)](https://i.stack.imgur.com/66YOM.png)\n\nSSHのパスワード認証方式になるかと思いますが、 \nこのユーザー名とパスワードはどこで得ることができるのでしょうか??? \nGCP初心者に是非助言をお願い致します。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T16:33:41.723", "favorite_count": 0, "id": "40613", "last_activity_date": "2017-12-30T05:52:56.197", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26832", "post_type": "question", "score": 0, "tags": [ "tensorflow", "google-cloud", "google-compute-engine" ], "title": "GCPのObject Detection APIを動かしたところ静的IPアドレスの認証でつまりました", "view_count": 95 }
[ { "body": "SSH の認証ではなく、ウェブアプリ自体に簡易認証の仕組みをつけているのではないでしょうか。\n\n以下、[質問者さんが参考になさったページ](https://book.mynavi.jp/manatee/detail/id=76951)からの引用です。\n\n> このアプリでは、Webブラウザから接続した際に簡易的な認証処理が行われるようになっています。ファイル\n> /opt/object_detection_app/decorator.py をエディタで開いて、次の 'username' と 'passw0rd'\n> の部分を書き換えることで、認証用のユーザー名とパスワードを変更することができます。このままのユーザー名/パスワードで使用する場合は、書き換えなくても構いません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-29T21:58:00.727", "id": "40614", "last_activity_date": "2017-12-29T21:58:00.727", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "40613", "post_type": "answer", "score": 1 } ]
40613
40614
40614
{ "accepted_answer_id": "40620", "answer_count": 1, "body": "<https://techacademy.jp/magazine/1846> を参考に \nWindowsServer2012R2=64bit筐体にApache2.4をインストールしようとしています。 \n一応作業的にはインストールを終え、サービスをStartさせているつもりですが、当該サーバのブラウザに\"it\nworks\"が現れず、ド壷にはまっています。(IE:x86とx64 両方試してもダメ) \n[![画像の説明をここに入力](https://i.stack.imgur.com/xkHcf.png)](https://i.stack.imgur.com/xkHcf.png)\n\n【事象発生までの行動】 \n・こちらの筐体はかつて、Apache2. **2** が動作しておりましたが、今朝アンインストールを実施しました。\n\n・先に記載したサイトで、Apache2.4のフォルダをCドライブ直に配置した上、インストールの作業を行うよう指示がありますが、これに逆らいc:\\ProgramFilesの直下に配置した上でhttpd\n-k installをコマンド指示してインストールを終えています。\n\n・すぐさま当該サービスを起動させようとしましたが、httpd.confが見当たらないみたいなエラーが表示されたので、Apache2.4のフォルダをCドライブ直におき直し、再度サービス起動を試行したことで一応に起動に成功した模様です。\n\n・コントロールパネル内プログラムと機能(旧:プログラムの追加と削除)メニューに、Apache2.4の羽アイコンの行が見当たらないのが気になっています。ちなみに再度インストールの指示をすると、既にインストールされているのメッセージが現れます。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/9FQhx.png)](https://i.stack.imgur.com/9FQhx.png) \n[![画像の説明をここに入力](https://i.stack.imgur.com/5OYmt.png)](https://i.stack.imgur.com/5OYmt.png)\n\n====質問==== \nApache2.4が正常にインストールできているかの確認、 \nサービスを稼動させたことで、無事当該サーバのブラウザにit\nworksを表すための手立てをご教示ください。(何が問題で現事象が生じているのか特定できていないので、曖昧な質問になってしまいました、ご容赦下さい)\n\nインターネットに接続できない筐体のため、皆様がよくいうxamppというユーティリティの利用をあきらめています。今朝インストールのためにApacheのサイトから取得したファイルは「httpd-2.4.29-Win64-VC15」です。\n\n年末のお忙しいところ恐縮ですが、皆様の暖かいご支援をお待ち申し上げております。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-30T02:50:56.500", "favorite_count": 0, "id": "40618", "last_activity_date": "2017-12-30T05:35:37.010", "last_edit_date": "2017-12-30T05:13:06.310", "last_editor_user_id": "3060", "owner_user_id": "25696", "post_type": "question", "score": 1, "tags": [ "windows", "apache" ], "title": "Apacheの再インストールに挑戦中。http://localhost/が表示されなくて困っています", "view_count": 1925 }
[ { "body": "「プログラムの機能」の一覧に表示されるのはいわゆるインストーラ(EXEやMSI形式)のファイルを実行してインストールした場合のみです。今回はZipアーカイブを展開しているだけなので当然一覧には表示(登録)されません。\n\n今回コマンドプロンプトで実施しているインストールはApacheをバックグラウンドで実行するための **サービス**\nをWindowsに登録する作業で、普段のWindowsアプリをインストールしているのとは少し意味合いが違います。 \n一度`Program Files (x86)`以下に`Apache`フォルダを置いて`httpd -k\ninstall`を実行しているので、その後に`C:\\`直下にフォルダだけ移動してもサービスの登録は以前の場所で残ったままになっているのだと思います。\n\n念のためApacheを元の`Profram Files\n(x86)`配下に戻し、起動を試してみてください。`httpd.confが見つからない`などのエラーが出ていたとのことですが、もう一度表示されるメッセージを確認してください。 \n(表示されていた通り単純に`httpd.conf`が存在しないのが原因かもしれません。エラーメッセージにはきちんと意味があるので、見るだけでなく読んで意味を理解してください)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-30T05:35:37.010", "id": "40620", "last_activity_date": "2017-12-30T05:35:37.010", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "40618", "post_type": "answer", "score": 1 } ]
40618
40620
40620
{ "accepted_answer_id": "40717", "answer_count": 1, "body": "PHPのVerは7.0.26です。こちらはWindowsServer2012(64bit)で利用のため、昨日PHPのサイトから入手してきたものです。\n\n拡張dllの収まったフォルダ=extには、当初からldap認証を達成するためのdll(php_ldap.dll)が格納されていました。 \n(個別に入手したわけでなく上記作業でextフォルダに収まっていた) \n[![画像の説明をここに入力](https://i.stack.imgur.com/hCKiS.png)](https://i.stack.imgur.com/hCKiS.png)\n\n尚、こちらの利用を確実にするため、php.iniの定義ファイル上で、拡張フォルダの所在をフルパス(C:\\Program\nFiles\\PHP\\ext)で記載しなおしています。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/xXtRf.png)](https://i.stack.imgur.com/xXtRf.png) \nこの所在の指定は問題ないとみえ、自らSQLServer接続のためMicrosoftから入手したdllは(extフォルダに格納:PDO\ndrivers=sqlsrv、またOracle接続のために定義・配置したdll、OCI8も表示されている)PHPINFOのPDO枠にしっかり現れています。\n\nところが、標題のとおり、LDAPの定義がPHPINFOに現れてきません。 \n案の定、LDAPの関数を利用したWebページで、関数未定義のエラー(Undefined function ldap_connect)を招きます。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/NAiWA.png)](https://i.stack.imgur.com/NAiWA.png)\n\n====質問==== \nApacheの再起動は繰り返していますが一向にPHPINFOへ、LDAPの定義が表れてこない理由、対策をご教示頂けないでしょうか。\n\n年末のご多忙な時期ですがよろしくお願い致します。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-30T13:34:13.753", "favorite_count": 0, "id": "40627", "last_activity_date": "2018-01-04T09:12:11.113", "last_edit_date": "2017-12-31T07:45:28.237", "last_editor_user_id": "25696", "owner_user_id": "25696", "post_type": "question", "score": 0, "tags": [ "php" ], "title": "LDAP認証を達成したいが、拡張dllが作用していないのかPHPINFOにLDAP定義が現れない", "view_count": 516 }
[ { "body": "皆様 あけましておめでとうございます、本件が無事解決を迎えましたので一応にご報告申し上げます。\n\nPHPの動作環境を整える上で、現在動作させようとしているのは64bit版ですが、以前環境構築に試行錯誤していた際、32bit版をサイトから取得して設定を進めていた時期があったのです。\n\nこの時ちょっと記憶にないのですが、システム環境変数に \nC:\\Program Files (x86)\\PHPを記載していたようでした。(php拡張子の関連付け??)\n\n本日PHPinfoのenviroment定義を舐めるようにみて気がつき、早速こちらを修正=環境変数のパスから現在PHPフォルダが配置された正規パス\nつまり(x86)の文字を除去してみると... \n無事LDAPのdllが読み込まれるようになりました。\n\nphpinfoにldapの定義が表れ、Webページの動作も無事行えるようになりました。\n\nお騒がせして大変申し訳ございませんでした。重ねてお詫び申し上げます。 \nまた別の機会で皆様のご支援を頂けましたら幸いでございます。\n\n本年もよろしくお願い申し上げます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T09:12:11.113", "id": "40717", "last_activity_date": "2018-01-04T09:12:11.113", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25696", "parent_id": "40627", "post_type": "answer", "score": 0 } ]
40627
40717
40717
{ "accepted_answer_id": null, "answer_count": 1, "body": "以下のように、サイズの異なる行列の集合Aが与えられた時、\n\n```\n\n A = \n [[[1, 2, 3],\n [1, 2, 3],\n [1, 2, 3]],\n [[1, 2],\n [1, 2],\n [1, 2],\n [1, 2]],\n [[1, 2, 3, 4],\n [1, 2, 3, 4]]]\n \n```\n\n以下のように、0でパディングして全体を連結させて、1つの行列にしたいです。\n\n```\n\n B =\n [[1, 2, 3, 0],\n [1, 2, 3, 0],\n [1, 2, 3, 0],\n [1, 2, 0, 0],\n [1, 2, 0, 0],\n [1, 2, 0, 0],\n [1, 2, 0, 0],\n [1, 2, 3, 4],\n [1, 2, 3, 4]]\n \n```\n\nChainerで上のような入力と出力を実現するためには、 \nどのようなコードを書けば良いでしょうか? \nAとBはnumpy array型です。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-30T13:37:34.027", "favorite_count": 0, "id": "40628", "last_activity_date": "2017-12-30T15:21:09.790", "last_edit_date": "2017-12-30T14:06:00.063", "last_editor_user_id": "25649", "owner_user_id": "25649", "post_type": "question", "score": 0, "tags": [ "python", "chainer" ], "title": "サイズの異なる行列の集合をパディングしてサイズを揃えたい", "view_count": 12326 }
[ { "body": "一旦、リストに変換します。\n\n```\n\n import numpy as np\n \n A = np.array([\n [[1, 2, 3],\n [1, 2, 3],\n [1, 2, 3]],\n [[1, 2],\n [1, 2],\n [1, 2],\n [1, 2]],\n [[1, 2, 3, 4],\n [1, 2, 3, 4]]])\n \n ## Flatten\n X = sum(A.tolist(), [])\n ## Max size\n l = max(map(len, X))\n ## Padding\n B = np.array(map(lambda x: x + [0]*(l-len(x)), X))\n \n B\n =>\n array([[1, 2, 3, 0],\n [1, 2, 3, 0],\n [1, 2, 3, 0],\n [1, 2, 0, 0],\n [1, 2, 0, 0],\n [1, 2, 0, 0],\n [1, 2, 0, 0],\n [1, 2, 3, 4],\n [1, 2, 3, 4]])\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-30T15:21:09.790", "id": "40629", "last_activity_date": "2017-12-30T15:21:09.790", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "40628", "post_type": "answer", "score": 1 } ]
40628
null
40629
{ "accepted_answer_id": null, "answer_count": 0, "body": "R言語でできることが、Pythonでも出来るという話を聴いて、実際はそんなことあるのだろうかと疑問に感じています。R言語はpythonに取って代わられてしまうのでしょうか?", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-30T15:42:18.203", "favorite_count": 0, "id": "40630", "last_activity_date": "2017-12-30T15:42:18.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26581", "post_type": "question", "score": 1, "tags": [ "python", "python3", "r" ], "title": "R言語がこれからPythonに取って代わられてしまうのでしょうか?", "view_count": 417 }
[]
40630
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在、arduino,unityを用いてロボットを動かそうとしています。 \nunity側から持ってきた変数をarduino側で扱いたいのですが、うまくいきません。\n\nunity側から持ってきたB,Cはプログラム通りに動くのですが、Aに関してはうまくいっていません。Aに関しては、Unity側から「A」と「数字(1桁)」の2つを連続で送っています。 \nUnity側でデバックしている分には数値や文字はこちらの想定通りに送られています。\n\n・やりたいこと \nUnity側から送られた数値によってロボットが進む時間を変えたい。\n\n・現状 \nロボットは動くのですが、数値を変えてもdelayの時間が変わらず変化がない状態です。\n\n・試したこと \nbyte型をlong型に変更してdelayに入れてみた。\n\n解決方法がわからずつまづいています、よろしくお願いします。\n\n追加 \n返信遅れてすみません、回答ありがとうございます。 \nお答えいただいたように、次のように書き換えてみました。 \nそうすると、Aに入ったときにどの数値にも関わらず17秒で止まってしまいました。やはり数値に問題があり、byte型をint型に直すところで間違いがあると思うのですが、その解決方法がわかりません。 \nよろしくお願いします。\n\nそれと、デバック方法としてSerial.print()とありますが、Unityとつないでる状態でシリアルボードはシリアルポートが多重に開いてしまい、使えないと思うのですが、方法があるのでしょうか?こちらもよろしくお願いします。\n\naはint型です。\n\n```\n\n void loop() {\n if(Serial.available()){\n int i=0;\n disbyte[5]={};\n while(Serial.available()>0){\n disbyte[i] = Serial.read();\n i++;\n }\n if(disbyte[0] == 'A'){\n a = disbyte[1] - 0x30;\n distime = a*1000;\n forward();\n delay(distime);\n stop();\n }\n if(disbyte[0] == 'B'){\n forward();\n delay(1000);\n stop();\n }\n if(disbyte[0] == 'C'){\n forward();\n delay(1000);\n stop();\n }\n }\n }\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-30T16:17:44.843", "favorite_count": 0, "id": "40631", "last_activity_date": "2018-01-03T16:39:36.217", "last_edit_date": "2018-01-03T16:39:36.217", "last_editor_user_id": "25857", "owner_user_id": "25857", "post_type": "question", "score": 0, "tags": [ "arduino" ], "title": "arduinoでdelay関数がうまく機能してくれません", "view_count": 827 }
[]
40631
null
null
{ "accepted_answer_id": "40667", "answer_count": 2, "body": "```\n\n enum { SYMBOL=100 } /* ASCII文字コードで指定する */\n \n```\n\n上記のように定数を定義していますが、`SYMBOL`は`strtok_r()`の2つめの引数として`(const\nchar*)SYMBOL`の形で使用するだけです。 \nコンパイル時にエラーは出ないので文法的な辻褄はあっていると思うのですが、このような場合はやはり`enum`を使わずに下記のように定義するときに(コメントでなくプログラムとして)使用目的を明示するべきでしょうか?\n\n```\n\n const char* SYMBOL = \"d\";\n \n```\n\n<774RRさんからの返答を受けて主に以下の点について質問文を修正しました> \n`enum`でまとめて定義するときはそれらが1つのグループであるかを考えるべきという視点から見ると`SYMBOL`は明らかに仲間外れで別に定義するほうが自然でした。 \nなお、`SYMBOL`の使用目的は`strtok_r()`の2つめの引数である`delim`です。 \n(返答を読んで改めて調べなおしたりしているうちに、自分が\"何を分かっていなかったのか\"とか\"どこを遠回りしていたのか\"が少しづつ見えてきた気がします……。)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-31T05:44:25.690", "favorite_count": 0, "id": "40637", "last_activity_date": "2018-01-02T09:11:35.220", "last_edit_date": "2018-01-02T09:11:35.220", "last_editor_user_id": "25936", "owner_user_id": "25936", "post_type": "question", "score": 0, "tags": [ "c" ], "title": "int型としては使わない定数をenumで定義してもいいでしょうか?", "view_count": 646 }
[ { "body": "`enum` は一つのオブジェクト(変数)に格納する数値に名前を付けたい場合に使うわけで\n\n```\n\n enum e_go_ranger_colors {\n AKA, AO, KI, MOMO, MIDO\n };\n \n```\n\n明らかに [ `char` に格納する値 ] でない `SYMBOL` を `enum`\nに含めてしまうのはオイラ的には変です(オイラ個人の選択肢としてはありえない)。\n\n警告 `initialization makes pointer from integer without a cast`\nは文章の通り、キャストを明示すれば消えます。 \n[c](/questions/tagged/c \"'c' のタグが付いた質問を表示\") `const char* SYMBOL=(const\nchar*)(100);` \n[c++](/questions/tagged/c%2b%2b \"'c++' のタグが付いた質問を表示\") `const char*\nSYMBOL=reinterpret_cast<const char*>(100);`\n\n以下蛇足。\n\n```\n\n const char SYMBOL=100;\n printf(\"%p\\n\", &SYMBOL);\n \n```\n\nで出力される値は `100` ではないことのほうが普通です。その意味で `const char SYMBOL=100`; としたうえで `&SYMBOL`\nを使うのと `const char* SYMBOL=100;` とは全く挙動が異なります。なのでオイラには当該 `SYMBOL`\nを具体的にどういう目的でどんな形で使うのか想像がつきません。その辺の解説があると別提案が(オイラ以外からも)出るでしょう。\n\nマイコンの世界だと `100` 番地 (`0x64` 番地)\nに有効な何かがあるのは普通のことです。割り込みベクタだったり、周辺回路レジスタだったり、普通に変数だったり。なので余計に想像つかなかったりします。\n\n\\--- 以上は編集前の質問内容に対する回答としてそのまま残しておいて以下追記 ---\n\n`strtok_r` の第二引数は `'\\0'` で終端されたデリミタ文字の列であるわけで \n<https://linuxjm.osdn.jp/html/LDP_man-pages/man3/strtok.3.html> \n最低でも `char[2]` の先頭を指すポインタでなければなりません。なので1文字である `SYMBOL`\nへのポインタを渡すのはおかしいことになります(既に回答されていますね)\n\n値 `100` は `0x64` つまり ASCII では小文字の d ですから、これを区切り文字に使いたいのであれば `strtok_r(元文字列,\n\"d\", &saveptr)` のように呼ぶことになりますし、以下別回答の通りっす。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T23:03:01.617", "id": "40661", "last_activity_date": "2018-01-02T09:09:12.627", "last_edit_date": "2018-01-02T09:09:12.627", "last_editor_user_id": "8589", "owner_user_id": "8589", "parent_id": "40637", "post_type": "answer", "score": 3 }, { "body": "```\n\n const char* SYMBOL = (const char*) 'd';\n \n```\n\nこれは、`SYMBOL` を `strtok_r()` の第2引数 `delim` に渡すなら、おそらく\n\n```\n\n const char* SYMBOL = \"d\";\n \n```\n\nではないでしょうか。\n\nもし、`\"d\"` と文字列で直接書くのでなく、文字コードを別に定義しておきたい、ということであれば、\n\n```\n\n /* strtok_r() の区切り文字の文字コード */\n #define SYMBOL_CHARCODE 100\n \n const char SYMBOL[2] = { SYMBOL_CHARCODE, 0 };\n \n```\n\nとすることもできます。\n\n`#define` の代わりに `enum` を使うこともできますが、`enum` は 774RR\nさんの例にあるような一連の定数をひとまとめに定義するためのものであって、単体で(または無関係な定数と一緒に)定義するためのものではないので、ここで\n`enum` を使うことにはとても違和感を感じます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T08:37:06.947", "id": "40667", "last_activity_date": "2018-01-02T08:37:06.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5288", "parent_id": "40637", "post_type": "answer", "score": 4 } ]
40637
40667
40667
{ "accepted_answer_id": null, "answer_count": 1, "body": "vbaでrangeの式展開は可能なのでしょうか?stringはどうやらできるみたいなのですが、rangeは可能なのでしょうか。一応やりたいことは下記のようなコードです。\n\n### 特定のセルだけに色を付ける => cells()を使って書いたもの\n\n```\n\n 'このコードは成功しました\n sub cellcolor\n for i = 3 to 27 step 4\n for j = 1 to 13\n cells(i, j).interior.colorindex = 3\n cells(i + 1, j).interior.colorindex = 4\n cells(i + 2, j).interior.colorindex = 5\n next j: next i\n end sub\n \n```\n\n### rangeで式展開しようと試みたができなかったコード\n\n```\n\n sub sippai\n set r as range = range.format(\"a{i}\", \"m{i}\")\n for i = 3 to 27 step 4\n r.interior.colorindex = 3\n next i\n End sub\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-31T06:51:40.747", "favorite_count": 0, "id": "40638", "last_activity_date": "2020-03-24T04:03:55.463", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26076", "post_type": "question", "score": 0, "tags": [ "vba" ], "title": "VBAのセルのrange(\"\")の式展開について", "view_count": 211 }
[ { "body": "### 行を選択する rows()がある。\n\n```\n\n sub step_row\n for i = 3 to 27 step 4\n rows(i).interior.colorindex = 3\n next i\n end sub\n \n```\n\nしかし、行全体が選択されてしまい、止めたいところで止めれないという問題あり。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-31T09:41:39.447", "id": "40643", "last_activity_date": "2017-12-31T09:41:39.447", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "26076", "parent_id": "40638", "post_type": "answer", "score": 1 } ]
40638
null
40643
{ "accepted_answer_id": "40640", "answer_count": 1, "body": "以下のようなeventsテーブルがあります。\n\n```\n\n t.string \"event_title\"\n t.date \"event_date\"\n t.string \"event_place\"\n t.text \"event_content\"\n t.datetime \"created_at\", null: false\n t.datetime \"updated_at\", null: false\n \n```\n\nすべての値を@eventsに代入します。\n\n`@events = Event.all`\n\nこれを`@event.each`で一覧表示する際に、`event_date`の昇順で表示させるにはどうしたらいいでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-31T08:05:13.393", "favorite_count": 0, "id": "40639", "last_activity_date": "2017-12-31T13:57:08.227", "last_edit_date": "2017-12-31T13:57:08.227", "last_editor_user_id": "76", "owner_user_id": "26111", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails" ], "title": "rubyで、レコードの特定の値でソートするには", "view_count": 233 }
[ { "body": "```\n\n @events.sort_by(&:event_date).each do |e|\n hogehoge e\n end\n \n```\n\nみたいな感じでいけると思います。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-31T08:20:07.577", "id": "40640", "last_activity_date": "2017-12-31T08:20:07.577", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "40639", "post_type": "answer", "score": 0 } ]
40639
40640
40640
{ "accepted_answer_id": null, "answer_count": 1, "body": "visual studioのような、cakephp3 でおすすめのデバッグツールがあれば教えて下さい。 \n例えばブレークポイントを設定して、そのときに格納されている変数の中身を簡単にみたいです。(JavaScript側、php側で) \nAtomを使ってますが、そのような機能も使えるのでしょうか。 \n今は、phpはdebug.logに出力、JavaScriptはconsole.log出力にて確認している状況です。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-31T17:17:00.327", "favorite_count": 0, "id": "40645", "last_activity_date": "2020-09-05T07:38:36.793", "last_edit_date": "2018-01-01T14:35:23.170", "last_editor_user_id": "26840", "owner_user_id": "26840", "post_type": "question", "score": -1, "tags": [ "php", "cakephp" ], "title": "cakephp3 デバッグツール", "view_count": 558 }
[ { "body": "CakePHP は PHP なので、Xdebug の利用が可能です。\n\nAtom、VSCode、PhpStorm といったメジャーどころのエディタでは、Xdebugに対応しています。\n\n適切に設定すると、Webサーバから開発マシンへ通信が行われ、典型的なブレークポイント・ステップ実行・再続行・変数の閲覧と改ざんが可能になります。\n\nなお、CakePHP 3.4.x\n系の一部のバージョンで特定の処理を行った場合、Ajaxなどで頻繁にサーバーにリクエストを発行するプロジェクトでは、うまくデバッグできない場合がありますので、ご注意ください。\n\n 1. 仮想マシンを立てて環境構築 \n例えばVirtualBox上のブリッジ接続で構築したCentOSのLAMPなど\n\n 2. 仮想マシンにxdebug拡張と、対応するphp.iniを設定する \n例:php7.0、remi経由\n\n``` $ yum -y install --enablerepo=remi-php70 php-devel php-pecl-xdebug\n\n \n```\n\n例:php.dフォルダを参照している場合。直接php.iniに記述してもOK\n\n``` $ sudo vi /etc/php.d/15-xdebug.ini\n\n \n```\n\n``` [xdebug]\n\n xdebug.default_enable = 1\n xdebug.idekey = \"vscode\"\n xdebug.remote_enable = 1\n xdebug.remote_port=9000\n xdebug.remote_autostart = 1\n xdebug.remote_host=<開発マシン(ホストマシン)のIP>\n \n```\n\n 3. Apache再起動\n``` $ sudo systemctl restart httpd.service\n\n \n```\n\n 4. エディタ側の設定を適切し、エディタのデバッグ開始(xdebug通信を待ち受ける)\n\n例:Visual Studio codeの場合\n\nlaunch.json\n\n``` {\n\n \"version\": \"0.2.0\",\n \"configurations\": [\n {\n \"name\": \"Listen for XDebug\",\n \"type\": \"php\",\n \"request\": \"launch\",\n \"port\": 9000,\n \"serverSourceRoot\": \"/var/www/html/<AppRoot>\",\n \"localSourceRoot\": \"${workspaceRoot}\"\n }\n ]\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2018-01-16T01:02:58.333", "id": "40979", "last_activity_date": "2020-09-05T07:38:36.793", "last_edit_date": "2020-09-05T07:38:36.793", "last_editor_user_id": "3060", "owner_user_id": "25396", "parent_id": "40645", "post_type": "answer", "score": 1 } ]
40645
null
40979
{ "accepted_answer_id": "40659", "answer_count": 1, "body": "次のようなtagの、liの内容の一つづつを、listとして保存したいと考えています。\n\n```\n\n <ul id=\"front\">\n <li class=\"icon-01\">乗用車</li>\n <li class=\"icon-02\">トラック</li>\n <li class=\"icon-11\">軽自動車</li>\n </ul>\n \n```\n\n現在、次のようなコードを書いています。\n\n```\n\n import requests\n import bs4\n import pandas as pd # pandas\n \n resp = requests.get(url)\n html = resp.content\n soup = bs4.BeautifulSoup(html, \"lxml\")\n \n icon_part = soup.find_all(\"ul\", id = \"front\")\n \n```\n\nこれにより、ulの部分を取ることが出来るが、要素一つのlistとなります。\n\n```\n\n [<ul id=\"front\">\n <li class=\"icon-01\">乗用車</li>\n <li class=\"icon-02\">トラック</li>\n <li class=\"icon-11\">軽自動車</li>\n </ul>]\n \n```\n\nliの内容が、次のようにlistの要素となるようにしたいのですが、 \nどうすれば良いのでしょうか? \n['乗用車', 'トラック', '軽自動車']\n\nlistの中身をsplitとしようとして 次のようにも書いてみました。\n\n```\n\n icon_part[0].str.split('</li>', expand=True)\n \n```\n\nしかし、次のようなエラーが出てきます。\n\n```\n\n AttributeError: 'NoneType' object has no attribute 'split'\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-12-31T21:18:48.463", "favorite_count": 0, "id": "40646", "last_activity_date": "2018-07-20T07:50:34.253", "last_edit_date": "2018-07-20T07:50:34.253", "last_editor_user_id": "19110", "owner_user_id": "20148", "post_type": "question", "score": 1, "tags": [ "python", "beautifulsoup" ], "title": "BeautifulSoupを使って<li>の内容をリストとして保存する方法?", "view_count": 6121 }
[ { "body": "```\n\n # -*- coding: utf-8 -*-\n import requests\n import bs4\n import pandas as pd # pandas\n \n \n def main():\n html =\"\"\"\n <ul id=\"front\">\n <li class=\"icon-01\">乗用車</li>\n <li class=\"icon-02\">トラック</li>\n <li class=\"icon-11\">軽自動車</li>\n </ul>\n \"\"\"\n soup = bs4.BeautifulSoup(html, \"lxml\")\n icon_part = soup.find_all(\"ul\", id=\"front\")\n car_model = []\n for ul_tag in icon_part:\n for li in ul_tag.find_all('li'):\n car_model.append(li.text)\n print(car_model)\n \n \n if __name__ == '__main__':\n main()\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T21:42:57.453", "id": "40659", "last_activity_date": "2018-01-01T21:42:57.453", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21356", "parent_id": "40646", "post_type": "answer", "score": 2 } ]
40646
40659
40659
{ "accepted_answer_id": null, "answer_count": 0, "body": "あけましておめでとうございます。本年もよろしくお願いします。 \nPython3で以下のようなコードを実行したところ、エラーが発生しました。 \n実験の趣旨はexecにプログラムを文字列で渡すことです。\n\n```\n\n #! /usr/bin/env python3\n # hash_exec_test.py\n \n def exec_test(s):\n exec(s)\n \n exec_test ('''\n book = {\"Apple\":[120,15], \"Orange\":[95,32], \"Banana\":[60,71]}\n print(\"↓↓One-Values↓↓\")\n print(book[\"Apple\"])\n print()\n keys = [x for x in list(book.keys())]\n print(\"↓↓All-Keys↓↓\")\n print(keys)\n print()\n values = [book[x] for x in list(book.keys())]\n print(\"↓↓All-Values↓↓\")\n print(values)\n ''')\n \n```\n\n実行結果は以下のとおりです。\n\n```\n\n $ ./hash_exec_test.py\n ↓↓One-Values↓↓\n [120, 15]\n \n ↓↓All-Keys↓↓\n ['Apple', 'Banana', 'Orange']\n \n Traceback (most recent call last):\n File \"./hash_exec_test.py\", line 19, in <module>\n ''')\n File \"./hash_exec_test.py\", line 5, in exec_test\n exec(s)\n File \"<string>\", line 10, in <module>\n File \"<string>\", line 10, in <listcomp>\n NameError: name 'book' is not defined\n \n```\n\nbookという名前が定義されていない、と言われています。 \nしかし、上ではbook[\"Apple\"]という検索が成功していますし、その後でキーを取り出すことはできているのに、最後に値を取り出そうとすると成功しない理由が分かりません。\n\nちなみに、関数exec_testを介さずに、execに文字列を渡してみます。\n\n```\n\n #! /usr/bin/env python3\n # hash_exec_test.py\n \n exec ('''\n book = {\"Apple\":[120,15], \"Orange\":[95,32], \"Banana\":[60,71]}\n print(\"↓↓One-Values↓↓\")\n print(book[\"Apple\"])\n print()\n keys = [x for x in list(book.keys())]\n print(\"↓↓All-Keys↓↓\")\n print(keys)\n print()\n values = [book[x] for x in list(book.keys())]\n print(\"↓↓All-Values↓↓\")\n print(values)\n ''')\n \n```\n\nこれだとうまくいきます。\n\n```\n\n $ ./hash_exec_test.py\n ↓↓One-Values↓↓\n [120, 15]\n \n ↓↓All-Keys↓↓\n ['Banana', 'Orange', 'Apple']\n \n ↓↓All-Values↓↓\n [[60, 71], [95, 32], [120, 15]]\n \n```\n\nなお、ディクショナリ型bookをグローバル変数にしてみます。\n\n```\n\n #! /usr/bin/env python3\n # hash_exec_test.py\n \n def exec_test(s):\n exec(s)\n \n book = {\"Apple\":[120,15], \"Orange\":[95,32], \"Banana\":[60,71]}\n \n exec_test ('''\n print(\"↓↓One-Values↓↓\")\n print(book[\"Apple\"])\n print()\n keys = [x for x in list(book.keys())]\n print(\"↓↓All-Keys↓↓\")\n print(keys)\n print()\n values = [book[x] for x in list(book.keys())]\n print(\"↓↓All-Values↓↓\")\n print(values)\n ''')\n \n```\n\nこれでも、うまくいきます。\n\n```\n\n $ ./hash_exec_test.py\n ↓↓One-Values↓↓\n [120, 15]\n \n ↓↓All-Keys↓↓\n ['Orange', 'Apple', 'Banana']\n \n ↓↓All-Values↓↓\n [[95, 32], [120, 15], [60, 71]]\n \n```\n\nなぜ一番上のケースで、値のリストを得ようとするところだけNameErrorになるのでしょうか。 \nご教示願います。 \nちなみに環境は以下のとおりです。\n\n```\n\n $ uname -a\n Linux DESKTOP-AHPUUO5 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux\n $ python3 -V\n Python 3.5.2\n \n```\n\n(2017-01-02 11:51 追記) \nローカル変数の定義状況を示すためにprint(locals())を加えてみました。\n\n```\n\n #! /usr/bin/env python3\n # hash_exec_test.py\n def exec_test(s):\n exec(s)\n \n exec_test ('''\n book = {\"Apple\":[120,15], \"Orange\":[95,32], \"Banana\":[60,71]}\n print(\"locals\")\n print(locals())\n print()\n print(\"One-Values:\")\n print(book[\"Apple\"])\n print()\n keys = [x for x in list(book.keys())]\n print(\"All-Keys\")\n print(keys)\n print()\n print(\"locals in the list comprehension\")\n values = [locals() for x in list(book.keys())]\n print(values)\n print(\"All-Values\")\n values = [book[x] for x in list(book.keys())]\n print(\"All-Values\")\n print(values)\n ''')\n \n```\n\n実行結果は以下のとおりです。\n\n```\n\n $ ./hash_exec_test.py\n locals\n {'s': '\\nbook = {\"Apple\":[120,15], \"Orange\":[95,32], \"Banana\":[60,71]}\\nprint(\"locals\")\\nprint(locals())\\nprint()\\nprint(\"One-Values:\")\\nprint(book[\"Apple\"])\\nprint()\\nkeys = [x for x in list(book.keys())]\\nprint(\"All-Keys\")\\nprint(keys)\\nprint()\\nprint(\"locals in the list comprehension\")\\nvalues = [locals() for x in list(book.keys())]\\nprint(values)\\nprint(\"All-Values\")\\nvalues = [book[x] for x in list(book.keys())]\\nprint(\"All-Values\")\\nprint(values)\\n', 'book': {'Banana': [60, 71], 'Orange': [95, 32], 'Apple': [120, 15]}}\n \n One-Values:\n [120, 15]\n \n All-Keys\n ['Banana', 'Orange', 'Apple']\n \n locals in the list comprehension\n [{'x': 'Apple', '.0': <list_iterator object at 0x7f871a502470>}, {'x': 'Apple', '.0': <list_iterator object at 0x7f871a502470>}, {'x': 'Apple', '.0': <list_iterator object at 0x7f871a502470>}]\n All-Values\n Traceback (most recent call last):\n File \"./hash_exec_test.py\", line 25, in <module>\n ''')\n File \"./hash_exec_test.py\", line 4, in exec_test\n exec(s)\n File \"<string>\", line 17, in <module>\n File \"<string>\", line 17, in <listcomp>\n NameError: name 'book' is not defined\n \n```\n\nリスト内包表記の中ではローカル変数bookが定義されていません。 \nこれが原因なのでしょう。 \nではなぜ\n\n```\n\n keys = [x for x in list(book.keys())]\n \n```\n\nは正しく動いたかというと、book.keys()は<list_iterator object at\n0x7f871a502470>を介して(?)bookにアクセスできていたということでしょうか。", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T00:35:11.687", "favorite_count": 0, "id": "40647", "last_activity_date": "2018-01-11T09:54:17.483", "last_edit_date": "2018-01-02T02:50:19.443", "last_editor_user_id": "26673", "owner_user_id": "26673", "post_type": "question", "score": 0, "tags": [ "python3" ], "title": "Pythonでexec文字列の中にプログラムを書くとNameErrorになる", "view_count": 2609 }
[]
40647
null
null
{ "accepted_answer_id": "40650", "answer_count": 1, "body": "xcodeのバージョンが9.2で,3つのイメージを一つのグループにしたいのですが(レイアウトの為)\n\n3つのイメージをクリックして選択し,alineボタンの左のstackボタンを押すと一つのグループにまとまるのですが\n\nUIStackView before iOS 9.0 (iOS 9.0より前のUIStackView) \nというメッセージが出てエラーになります。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T02:07:43.610", "favorite_count": 0, "id": "40649", "last_activity_date": "2018-01-01T02:37:33.243", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26811", "post_type": "question", "score": 0, "tags": [ "xcode" ], "title": "XCODE stack viewについて", "view_count": 111 }
[ { "body": "`UIStackView`はiOS9以降で使うことができます。 \n何かしらの設定がiOS9より前になっているためエラーがでています。\n\n<https://stackoverflow.com/questions/31758808/uistackview-before-ios-9-0>\n\nを参考に各種設定を見直してみるとよいと思います。\n\n具体的には\n\n`Project Targets-> Deployment info -> Deployment Target` \nや \nストリーボードやxibの`Builds for` \nです。\n\nもちろん、設定を変更すればアプリ全体もしくは一部がiOS9以降のみのサポートとなります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T02:16:34.557", "id": "40650", "last_activity_date": "2018-01-01T02:37:33.243", "last_edit_date": "2018-01-01T02:37:33.243", "last_editor_user_id": "9008", "owner_user_id": "9008", "parent_id": "40649", "post_type": "answer", "score": 0 } ]
40649
40650
40650
{ "accepted_answer_id": null, "answer_count": 1, "body": "カメラで写真を撮影した後、その画像に対して文字を任意の文字を入力できるアプリを制作しています。\n\n方法としては以下の手順で考えています。\n\n * AndroidStudioで制作したカメラアプリを起動し撮影、画像データを取得。\n * その画像データをopencvに読み込み画像に文字の挿入。\n\n現在はカメラアプリの制作まで終了していてここからどのようにしてopencvに撮った画像データを取り込むかわかりません。\n\nどなたか教えていただけませんでしょうか。\n\nよろしくお願い致します。\n\nカメラアプリのソースコード\n\n```\n\n import android.app.Activity;\n import android.content.Intent;\n import android.graphics.Bitmap;\n import android.os.Bundle;\n import android.provider.MediaStore;\n import android.view.View;\n import android.view.View.OnClickListener;\n import android.widget.Button;\n import android.widget.ImageView;\n \n public class MainActivity extends Activity {\n \n static final int REQUEST_CAPTURE_IMAGE = 100;\n \n Button button1;\n ImageView imageView1;\n \n @Override\n public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n findViews();\n setListeners();\n }\n \n protected void findViews(){\n button1 = (Button)findViewById(R.id.button1);\n imageView1 = (ImageView)findViewById(R.id.imageView1);\n }\n \n protected void setListeners(){\n button1.setOnClickListener(new OnClickListener(){\n @Override\n public void onClick(View v) {\n Intent intent = new Intent(\n MediaStore.ACTION_IMAGE_CAPTURE);\n startActivityForResult(\n intent,\n REQUEST_CAPTURE_IMAGE);\n }\n });\n }\n \n @Override\n protected void onActivityResult(\n int requestCode,\n int resultCode,\n Intent data) {\n if(REQUEST_CAPTURE_IMAGE == requestCode\n && resultCode == Activity.RESULT_OK ){\n Bitmap capturedImage =\n (Bitmap) data.getExtras().get(\"data\");\n imageView1.setImageBitmap(capturedImage);\n }\n }\n \n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2018-01-01T06:25:15.347", "favorite_count": 0, "id": "40654", "last_activity_date": "2023-05-20T02:05:05.713", "last_edit_date": "2021-04-15T04:08:45.893", "last_editor_user_id": "3060", "owner_user_id": "26848", "post_type": "question", "score": 1, "tags": [ "java", "android", "opencv" ], "title": "カメラアプリの画像データをOpenCVに読み込む方法", "view_count": 1683 }
[ { "body": "AndroidでOpenCVを開発する環境は整っていますでしょうか。 \nまだの場合は公式からopencvのダウンロードとライブラリの設定をしてください。 \n簡単なopencvでのキャプチャなら自分のプロジェクトを作成し、AndroidManifest.xml内に\n\n```\n\n <uses-permission android:name=\"android.permission.CAMERA\"/>\n <uses-feature android:name=\"android.hardware.camera2\" android:required=\"false\"/>\n <uses-feature android:name=\"android.hardware.camera2.autofocus\" android:required=\"false\"/>\n \n```\n\nを追加して、layoutに\n\n```\n\n <org.opencv.android.JavaCameraView\n android:layout_width=\"fill_parent\"\n android:layout_height=\"fill_parent\"\n android:visibility=\"gone\"\n android:id=\"@+id/tutorial1_activity_java_surface_view\"\n opencv:show_fps=\"true\"\n opencv:camera_id=\"any\" />\n \n```\n\nを追加して、メインに\n\n```\n\n import org.opencv.android.BaseLoaderCallback;\n import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;\n import org.opencv.android.LoaderCallbackInterface;\n import org.opencv.android.OpenCVLoader;\n import org.opencv.core.Mat;\n import org.opencv.android.CameraBridgeViewBase;\n import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;\n \n import android.app.Activity;\n import android.os.Bundle;\n import android.util.Log;\n import android.view.Menu;\n import android.view.MenuItem;\n import android.view.SurfaceView;\n import android.view.WindowManager;\n import android.widget.Toast;\n \n public class MainActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener {\n private static final String TAG = \"OCVSample::Activity\";\n \n private CameraBridgeViewBase mOpenCvCameraView;\n private boolean mIsJavaCamera = true;\n private MenuItem mItemSwitchCamera = null;\n \n private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {\n @Override\n public void onManagerConnected(int status) {\n switch (status) {\n case LoaderCallbackInterface.SUCCESS:\n {\n Log.i(TAG, \"OpenCV loaded successfully\");\n mOpenCvCameraView.enableView();\n } break;\n default:\n {\n super.onManagerConnected(status);\n } break;\n }\n }\n };\n \n public MainActivity() {\n Log.i(TAG, \"Instantiated new \" + this.getClass());\n }\n \n /** Called when the activity is first created. */\n @Override\n public void onCreate(Bundle savedInstanceState) {\n Log.i(TAG, \"called onCreate\");\n super.onCreate(savedInstanceState);\n getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);\n \n setContentView(R.layout.activity_main);\n \n mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.tutorial1_activity_java_surface_view);\n \n mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);\n \n mOpenCvCameraView.setCvCameraViewListener(this);\n }\n \n @Override\n public void onPause()\n {\n super.onPause();\n if (mOpenCvCameraView != null)\n mOpenCvCameraView.disableView();\n }\n \n @Override\n public void onResume()\n {\n super.onResume();\n if (!OpenCVLoader.initDebug()) {\n Log.d(TAG, \"Internal OpenCV library not found. Using OpenCV Manager for initialization\");\n OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);\n } else {\n Log.d(TAG, \"OpenCV library found inside package. Using it!\");\n mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);\n }\n }\n \n public void onDestroy() {\n super.onDestroy();\n if (mOpenCvCameraView != null)\n mOpenCvCameraView.disableView();\n }\n \n public void onCameraViewStarted(int width, int height) {\n }\n \n public void onCameraViewStopped() {\n }\n \n public Mat onCameraFrame(Mat inputFrame) {\n return inputFrame;\n }\n }\n \n```\n\nをして実行してみてください。 \nbuild.grableとかmainにエラーが出るとは思いますが自分の環境に合わせてください。 \nちなみに自分のコードはOpenCV 3.2のものです。", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2018-01-08T12:00:52.420", "id": "40817", "last_activity_date": "2021-04-15T04:10:12.367", "last_edit_date": "2021-04-15T04:10:12.367", "last_editor_user_id": "3060", "owner_user_id": "26893", "parent_id": "40654", "post_type": "answer", "score": 0 } ]
40654
null
40817
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在Swift4のSpriteKitにて、シューティングゲームを製作しております。 \nその中で必要な衝突判定(didBegin)が動かなく、困っております。\n\n# 該当のソースコード\n\n```\n\n //Swift4、Xcode9、iOS 11.2(最新版)を利用し、ビルドシステムはデフォルトのものを使用しております。\n import SpriteKit\n import GameplayKit\n import Foundation\n \n class GameScene: SKScene, SKPhysicsContactDelegate {\n \n let playerjudge = SKShapeNode(circleOfRadius: 2.5)\n let enemy1 = SKEmitterNode(fileNamed: \"ghost.sks\")\n \n let category_player:UInt32 = 1 << 1 // 000001\n let category_graze:UInt32 = 1 << 2 // 000010\n let category_playerbullet:UInt32 = 1 << 4 // 000100\n let category_enemy1:UInt32 = 1 << 10 // 001000\n let category_enemybullet1:UInt32 = 1 << 20 // 010000\n let category_other:UInt32 = 1 << 40 // 100000\n \n private var bullet : SKShapeNode?\n \n \n override func didMove(to view: SKView) {\n self.physicsBody = SKPhysicsBody(edgeLoopFrom: self.frame)\n // 物理衝突の情報を自分で受け取る\n self.physicsWorld.contactDelegate = self\n // 物理空間の外枠の種類は、その他\n self.physicsBody?.categoryBitMask = category_other\n \n playerjudge.strokeColor = .red\n playerjudge.physicsBody = SKPhysicsBody(circleOfRadius: 2)\n playerjudge.physicsBody?.isDynamic = false\n addChild(playerjudge)\n playerjudge.physicsBody?.categoryBitMask = category_player\n self.bullet = SKShapeNode(circleOfRadius: 15)\n \n enemy1!.xScale = enemy1!.xScale / 2.5\n enemy1!.yScale = enemy1!.yScale / 2.5\n enemy1!.position.x = frame.midX\n enemy1!.position.y = frame.midY + 150\n enemy1!.physicsBody = SKPhysicsBody(circleOfRadius: 10)\n addChild(enemy1!)\n enemy1!.physicsBody?.isDynamic = false\n enemy1!.physicsBody?.categoryBitMask = category_enemy1\n if let bullet = self.bullet {\n bullet.run(SKAction.repeatForever(SKAction.rotate(byAngle: CGFloat(Double.pi), duration: 1)))\n bullet.run(SKAction.sequence([SKAction.wait(forDuration: 0.5),\n SKAction.fadeOut(withDuration: 0.5),\n SKAction.removeFromParent()]))\n }\n }\n \n func playershot() {\n if let n = self.bullet?.copy() as! SKShapeNode? {\n n.position = playerjudge.position\n n.physicsBody = SKPhysicsBody(circleOfRadius: 12.5)\n n.physicsBody?.isDynamic = false\n self.addChild(n)\n n.physicsBody?.categoryBitMask = category_playerbullet\n n.run(SKAction.repeatForever(SKAction.rotate(byAngle: CGFloat(Double.pi), duration: 0.1)))\n n.run(SKAction.sequence([SKAction.moveBy(x: n.position.x, y: n.position.y + 350, duration:0.75),\n SKAction.fadeOut(withDuration: 0.5),\n SKAction.removeFromParent()]))\n }\n }\n \n override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {\n let location = touches.first!.location(in: self)\n let action = SKAction.move(to: CGPoint(x:location.x, y:location.y + 50), duration:0.1)\n playerjudge.run(action)\n playershot()\n }\n \n override func update(_ currentTime: TimeInterval) {\n // Called before each frame is rendered\n }\n \n //ここの衝突判定のプログラムが機能していないようで、ログに衝突と表示されない。\n func didBegin(_ contact: SKPhysicsContact) {\n print(\"衝突\")\n if contact.bodyA.node?.physicsBody?.categoryBitMask == category_playerbullet && contact.bodyB.node?.physicsBody?.categoryBitMask == category_enemy1{\n contact.bodyA.node!.removeFromParent()\n contact.bodyB.node!.removeFromParent()\n }else if contact.bodyB.node?.physicsBody?.categoryBitMask == category_playerbullet && contact.bodyA.node?.physicsBody?.categoryBitMask == category_enemy1{\n contact.bodyA.node!.removeFromParent()\n contact.bodyB.node!.removeFromParent()\n }\n }\n }\n \n```\n\n回答よろしくお願い致します。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T07:57:30.857", "favorite_count": 0, "id": "40655", "last_activity_date": "2018-01-01T07:57:30.857", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "26850", "post_type": "question", "score": 0, "tags": [ "swift", "ios", "spritekit", "swift4" ], "title": "SpriteKit、Swift4にて、衝突判定(didBegin)が動作しない", "view_count": 1040 }
[]
40655
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "PIC16F1827を用いAD変換値で \nLEDの点滅速度を変化させようとしています。\n\n以下にコードを示します。 \n↓\n\n```\n\n #include <stdio.h>\n #include <stdlib.h>\n #include <xc.h>\n #define _XTAL_FREQ 4000000\n \n // CONFIG1\n #pragma config FOSC = INTOSC // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)\n #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)\n #pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)\n #pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)\n #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)\n #pragma config CPD = OFF // Data Memory Code Protection (Data memory code protection is disabled)\n #pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)\n #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)\n #pragma config IESO = ON // Internal/External Switchover (Internal/External Switchover mode is enabled)\n #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)\n \n // CONFIG2\n #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)\n #pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)\n #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)\n #pragma config BORV = HI // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), high trip point selected.)\n #pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)\n \n void internal_osc();\n void io_int();\n void adc_int();\n int adc_read();\n void wait1(char val);\n int adc_tmp;\n \n void main(void){\n internal_osc();\n io_int();\n adc_int();\n while(1){\n adc_tmp = adc_read();\n PORTB = 0x01;\n wait1(adc_tmp>>2);\n PORTB = 0x03;\n wait1(adc_tmp>>2);\n PORTB = 0x07;\n wait1(adc_tmp>>2);\n PORTB = 0x0f;\n wait1(adc_tmp>>2);\n PORTB = 0x00;\n wait1(adc_tmp>>2);\n PORTB = 0x0f;\n wait1(adc_tmp>>2);\n PORTB = 0x00;\n wait1(adc_tmp>>2);\n PORTB = 0x0f;\n wait1(adc_tmp>>2);\n }\n }\n \n void internal_osc(void){\n /*\n * SPLLEN=0;4xPLL is disabled\n * IRCF=1101;4MHz\n * SCS=10;Internal oscillator block\n * OSCCON=0b01101010;\n */\n OSCCON = 0x6a;\n }\n void io_int(void){\n /*\n * RB0=0;LED0\n * RB1=0;LED1\n * RB2=0;LED2\n * RB3=0;LED3\n * RA0=1;AN0\n * TRISA=0b00000001;\n * TRISB=0b00000000;\n * ANSELA=0b00000001;\n * ANSELB=0b00000000;\n */\n TRISA = 0x01;\n TRISB = 0x00;\n ANSELA = 0x01;\n ANSELB = 0x00;\n }\n void adc_int(void){\n /*\n * CHS=00000;AN0\n * ADON=1;\n * ADFM=1;Right justified\n * ADCS=001;FOSC->1/8;\n * ->4MHz ad_scan 2us\n * ADNREF=0;VREF- is connected to AVSS\n * ADPREF=00;VREF+ is connected to AVDD\n * ADCON0=0b00000001;\n * ADCON1=0b10010000;\n */\n ADCON0 = 0x01;\n ADCON1 = 0x90;\n }\n int adc_read(void){\n __delay_us(20);\n ADCON0bits.GO_nDONE = 1;\n while(ADCON0bits.GO_nDONE);\n return (ADRESH<<8) + ADRESL;\n }\n void wait1(char val){\n for(int i=0; i<=val; i++){\n __delay_ms(10);\n }\n }\n \n```\n\nこのコードではAD変換値を読み取ったら \nwhileで先頭に戻るまでadc_tmpの値を \n変化させることはできないかと思います。\n\nwhileループの中で依存せず、 \n自由にadc_tmpの値を変化させる \n方法が思いつきません。\n\nどなたかご教授お願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T12:41:42.337", "favorite_count": 0, "id": "40656", "last_activity_date": "2018-01-02T11:42:14.790", "last_edit_date": "2018-01-01T12:49:23.963", "last_editor_user_id": "7283", "owner_user_id": "26851", "post_type": "question", "score": 0, "tags": [ "c" ], "title": "リアルタイムでのAD変換方法", "view_count": 160 }
[ { "body": "自己解決しました。 \nタイマー割り込みを用い、割り込み中にAD変換をすることで \nメインルーチンに依存せずLEDの点滅速度を変化させることができました。 \nありがとうございました。\n\n```\n\n #include <stdio.h>\n #include <stdlib.h>\n #include <xc.h>\n #define _XTAL_FREQ 4000000\n \n // CONFIG1\n #pragma config FOSC = INTOSC // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)\n #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)\n #pragma config PWRTE = ON // Power-up Timer Enable (PWRT enabled)\n #pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)\n #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)\n #pragma config CPD = OFF // Data Memory Code Protection (Data memory code protection is disabled)\n #pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)\n #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)\n #pragma config IESO = ON // Internal/External Switchover (Internal/External Switchover mode is enabled)\n #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)\n \n // CONFIG2\n #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)\n #pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)\n #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)\n #pragma config BORV = HI // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), high trip point selected.)\n #pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)\n \n void internal_osc();\n void io_int();\n void tmr0_int();\n void adc_int();\n int adc_read();\n void wait1(char val);\n char tmr0_cnt;\n int adc_tmp;\n \n void main(void){\n internal_osc();\n io_int();\n tmr0_int();\n adc_int();\n while(1){\n PORTB = 0x01;\n wait1(adc_tmp>>2);\n PORTB = 0x03;\n wait1(adc_tmp>>2);\n PORTB = 0x07;\n wait1(adc_tmp>>2);\n PORTB = 0x0f;\n wait1(adc_tmp>>2);\n PORTB = 0x00;\n wait1(adc_tmp>>2);\n PORTB = 0x0f;\n wait1(adc_tmp>>2);\n PORTB = 0x00;\n wait1(adc_tmp>>2);\n PORTB = 0x0f;\n wait1(adc_tmp>>2);\n }\n }\n void interrupt ISR(void){\n INTCONbits.TMR0IF = 0;\n TMR0 = 130;\n adc_tmp = adc_read();\n }\n void internal_osc(void){\n /*\n * SPLLEN=0;4xPLL is disabled\n * IRCF=1101;4MHz\n * SCS=10;Internal oscillator block\n * OSCCON=0b01101010;\n */\n OSCCON = 0x6a;\n }\n void io_int(void){\n /*\n * RB0=0;LED0\n * RB1=0;LED1\n * RB2=0;LED2\n * RB3=0;LED3\n * RA0=1;AN0\n * TRISA=0b00000001;\n * TRISB=0b00000000;\n * ANSELA=0b00000001;\n * ANSELB=0b00000000;\n */\n TRISA = 0x01;\n TRISB = 0x00;\n ANSELA = 0x01;\n ANSELB = 0x00;\n }\n void tmr0_int(void){\n /*\n * 1msec interval_timer\n * FOSC->4MHz\n * interval_time=(255-TMR0)*(FOSC/4)*PS;\n * PS=010;Prescaler->1/8\n * TMR0=130\n * OPTION_REG=0b10000010;\n */\n OPTION_REG = 0x82;\n TMR0 = 130;\n INTCONbits.TMR0IE = 1;\n INTCONbits.GIE = 1;\n }\n void adc_int(void){\n /*\n * CHS=00000;AN0\n * ADON=1;\n * ADFM=1;Right justified\n * ADCS=001;FOSC->1/8;\n * ->4MHz ad_scan 2us\n * ADNREF=0;VREF- is connected to AVSS\n * ADPREF=00;VREF+ is connected to AVDD\n * ADCON0=0b00000001;\n * ADCON1=0b10010000;\n */\n ADCON0 = 0x01;\n ADCON1 = 0x90;\n }\n int adc_read(void){\n __delay_us(20);\n ADCON0bits.GO_nDONE = 1;\n while(ADCON0bits.GO_nDONE);\n return (ADRESH<<8) + ADRESL;\n }\n void wait1(char val){\n for(int i=0; i<=val; i++){\n __delay_ms(10);\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T07:40:33.280", "id": "40665", "last_activity_date": "2018-01-02T11:42:14.790", "last_edit_date": "2018-01-02T11:42:14.790", "last_editor_user_id": "754", "owner_user_id": "26851", "parent_id": "40656", "post_type": "answer", "score": 1 } ]
40656
null
40665
{ "accepted_answer_id": "43383", "answer_count": 1, "body": "CloudFormationでlambdaのファンクションを追加するためのリソースを作りたいと考えています。\n\n## 聞きたい事\n\ncloudFormationのテンプレートで、lambdaに必要な作業を1つのテンプレートにまとめて書くことはできませんか?\n\n## 状況\n\nCloudFormationの「AWS::Lambda::Function」で使うソースを指定する場合は、次の方法があります。\n\n 1. s3バケットにソースをアップして、Code属性にそのバケットの情報を追記する\n 2. CloudFormtaionに直接スクリプトを書いてしまう。 \n\n今回は、jsのライブラリを組み合わせて使うので、前者の方法で実装します。 \nこの場合、バケット作成->lambdaのアップロード->スタック作成の順番で実施する必要があります。 \n私の調べる限り、CloudFormationでは、この3つの作業を1つのテンプレートに入れることは出来なさそうです。\n\n`aws cloudformation\npackage`で、s3のパスを指定した状態のテンプレートを生成(コンパイル?)する事ができる様ですが、バケットの作成までは自動化出来ないです。\n\n## テンプレート化したい一連の作業の詳細\n\n下記の作業をCloudFormationのテンプレートに書いて、実行時に全て実行する。\n\n * 任意のS3バケットを作成する\n * 作成したS3バケットに対してLambdaのソースコードをアップロードする\n * CloudFormationのテンプレートのCodeプロパティに上記の情報を適用する。 \n具体的にはResouceのPropertiesに下記を追加したいです。\n\n``` \"Code\": {\n\n \"S3Bucket\": <1.で作成したbucket名>,\n \"S3Key\": \"<2.でアップロードしたファイル名>\"\n }\n \n```\n\n### イメージ\n\n[![構成イメージ](https://i.stack.imgur.com/1Mlda.png)](https://i.stack.imgur.com/1Mlda.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T15:09:29.007", "favorite_count": 0, "id": "40657", "last_activity_date": "2018-07-08T08:23:53.357", "last_edit_date": "2018-07-08T08:23:53.357", "last_editor_user_id": "754", "owner_user_id": "17060", "post_type": "question", "score": 0, "tags": [ "aws", "aws-lambda", "aws-cloudformation" ], "title": "CloudFormationでLambdaを追加するための、S3バケット作成からTemplateに反映までの作業を一括で実現する方法はないでしょうか?", "view_count": 942 }
[ { "body": "SAMと`aws cloudformation package`を使うのが良いと思います。\n\n例えば、下記の`template.yaml`の`CodeUri`のようにファイルのパスを指定します。\n\n```\n\n $ grep Uri template.yaml\n CodeUri: LambdaFunctionOverHttps.py\n $ ls LambdaFunctionOverHttps.py \n LambdaFunctionOverHttps.py\n $\n \n```\n\n`aws cloudformation package`で`template.yaml`とS3バケットを指定すると、\n\n 1. lambda関数をS3バケットにアップロード\n 2. `template.yaml`の`CodeUri`をS3バケットにアップロードしたS3パスに修正したcloudformationのテンプレートを出力\n\nしてくれます。\n\n```\n\n $ aws cloudformation package --template template.yaml --s3-bucket lambda-zipfile > packaged-template.yaml\n $ grep CodeUri packaged-template.yaml \n CodeUri: s3://lambda-zipfile/7a1fd29b27ea23ac1cc381189182062b\n $ aws s3 ls s3://lambda-zipfile/7a1fd29b27ea23ac1cc381189182062b\n 2018-04-19 19:17:19 640 7a1fd29b27ea23ac1cc381189182062b\n \n```\n\n出力されたテンプレートを`aws cloudformation deploy`すればlambda関数が作成されます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-04-19T10:27:48.347", "id": "43383", "last_activity_date": "2018-04-19T10:34:48.510", "last_edit_date": "2018-04-19T10:34:48.510", "last_editor_user_id": "5285", "owner_user_id": "5285", "parent_id": "40657", "post_type": "answer", "score": 1 } ]
40657
43383
43383
{ "accepted_answer_id": null, "answer_count": 1, "body": "<https://localhost:3000/1/pg185.html>\nが開けません。hpの試作をクラウドを使ってアップロードしたいと思い、試みているのですが、開けません。webアドレスを取得したい?思うのですが。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T22:43:21.560", "favorite_count": 0, "id": "40660", "last_activity_date": "2018-01-02T08:58:27.597", "last_edit_date": "2018-01-02T07:36:19.930", "last_editor_user_id": "754", "owner_user_id": "26823", "post_type": "question", "score": -1, "tags": [ "javascript" ], "title": "localhost:3000が開けません", "view_count": 377 }
[ { "body": "自分のコンピュータに web server がインストールされていて、正しく起動できていて、ポート 3000 で待ち受けていて、その web server\nの公開ドキュメントディレクトリに `1/pg185.html`\nを配置すれば開けるはずです。時と場合によってはセキュリティソフト(ウイルス対策ソフト)のファイアウォール設定を変更してポート 3000\nを開く必要があるでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-01T23:09:31.843", "id": "40662", "last_activity_date": "2018-01-02T08:58:27.597", "last_edit_date": "2018-01-02T08:58:27.597", "last_editor_user_id": "8589", "owner_user_id": "8589", "parent_id": "40660", "post_type": "answer", "score": 2 } ]
40660
null
40662
{ "accepted_answer_id": null, "answer_count": 3, "body": "VBAでセルを足し算するんじゃなくって、 \n式を埋め込みたいときに思いついた方法が文字列でゴリ押しする方法でした。 \n一応成功しましたが。これだとさすがに冗長すぎると思いました。\n\n前にも似たような質問をしたのですが、VBAでrubyのように式展開させる方法はないのでしょうか?\n\n```\n\n sub cells_sum\n for i = 1 to sheets.count\n for j = 4 to 34\n sheets(i).cells(j, 5) = \"=sum(b\"+cstr(j)+\":c\"+cstr(j)+\")\" \n next j: next i\n end sub\n \n```\n\nformat()で実現できそうな気配ですが、なかなか情報にたどりつきません。 \n\n```\n\n sub fo\n dim s as string\n dim array(100) as integer\n for i = 0 to 100\n array(i) = i + 1\n next i\n for each a in array\n a = cstr(a)\n range(\"a1\") = format(a,\"=sum(a@:b@)\")\n next a\n end sub 'NG\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T04:53:25.423", "favorite_count": 0, "id": "40663", "last_activity_date": "2018-11-29T09:41:26.210", "last_edit_date": "2018-01-02T07:52:54.930", "last_editor_user_id": "26076", "owner_user_id": "26076", "post_type": "question", "score": 0, "tags": [ "vba" ], "title": "VBAでセルに式を埋め込むときに良い式展開の方法はないでしょうか", "view_count": 1310 }
[ { "body": "### 他の策(コピーしたものを貼り付ける)\n\n```\n\n sub copy_calc\n range(\"c1\").copy\n for i = 2 to 5\n sheets(1).paste destination:=cells(i, 3)\n next i\n end sub\n \n```\n\n### formula\n\nformulaという構文で数式を一括入力できるようです。こちらは試していません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T07:51:52.533", "id": "40666", "last_activity_date": "2018-01-02T07:51:52.533", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26076", "parent_id": "40663", "post_type": "answer", "score": 0 }, { "body": "VBAの標準機能ではないですね。\n\nいげ太さんという方が公開している Ariawase というライブラリを使えば、それっぽいことができます。\n\nライブラリの置き場所 \n<https://github.com/vbaidiot/Ariawase>\n\n解説 \n<http://igeta-diary.blogspot.com/2014/03/>\n\nCore.bas に入っている Formats 関数を使います。\n\n```\n\n Sheets(i).Cells(j, 5).Formula = Formats(\"=SUM(B{0}:C{0})\", j)\n \n```\n\nこんな感じで書けます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2018-11-29T09:08:07.750", "id": "50754", "last_activity_date": "2018-11-29T09:08:07.750", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "31109", "parent_id": "40663", "post_type": "answer", "score": 0 }, { "body": "セル`E4`に数式`=SUM(B4:C4)`を埋め込みたいということでしょうか?\nこの数式はExcelで広く使われているA1形式での表現形式となっていますが、この他にR1C1形式があり、こちらを使うと`=SUM(RC[-3]:RC[-2])`と相対アドレスが簡単に表現できるようになります。その結果、数式が固定文字列になるため\n\n```\n\n sub cells_sum\n for i = 1 to sheets.count\n for j = 4 to 34\n sheets(i).cells(j, 5).FormulaR1C1 = \"=SUM(RC[-3]:RC[-2])\" \n next j: next i\n end sub\n \n```\n\nで済みます。さらに言えば範囲指定で一気に代入できます。\n\n```\n\n sub cells_sum\n for i = 1 to sheets.count\n sheets(i).range(\"E4:E34\").FormulaR1C1 = \"=SUM(RC[-3]:RC[-2])\" \n next i\n end sub\n \n```\n\nより複雑な数式を扱う場合、[`ADDRESS`標準関数](https://support.office.com/ja-\njp/article/address-%E9%96%A2%E6%95%B0-d0c26c0d-3991-446b-8de4-ab46431d4f89)を使用することでセルを表す文字列を生成できます。この文字列を使用すれば柔軟に数式を組み立てることができます。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2018-11-29T09:41:26.210", "id": "50757", "last_activity_date": "2018-11-29T09:41:26.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "40663", "post_type": "answer", "score": 1 } ]
40663
null
50757
{ "accepted_answer_id": null, "answer_count": 1, "body": "いつもお世話になっております。\n\nSpriteKitでUITableViewを利用したいと考えております。 \n以下のサイトを参考にし、さらにセルをカスタマイズしたいと考えております。 \n以下のソースではセル内を「画像+タイトル+値段」で構成しております。\n\nですが、スクロールさせると画像やタイトルなどが、既存のセル上に次々に重なって新規に作成されてしまいました。 \nご教授ご鞭撻のほどよろしくお願い致します。\n\n他に良い方法がありましたらご教授頂けると幸いです。\n\n参考サイト \n<https://stackoverflow.com/questions/41626348/using-a-uitableview-in-\nspritekit>\n\n■サンプルコード\n\n```\n\n import SpriteKit\n import UIKit\n ...\n override func didMove(to view: SKView) {\n \n let tableView = TableView()\n tableView.register(UITableViewCell.self, forCellReuseIdentifier: \"cell\")\n tableView.frame = CGRect(x: 20, y: 50, width: 280, height: 200)\n self.view?.addSubview(tableView)\n tableView.reloadData()\n }\n ...\n class TableView: UITableView, UITableViewDelegate, UITableViewDataSource {\n \n private var itemTitle = [\"Cell 1\", \"Cell 2\", \"Cell 3\", \"Cell 4\", \"Cell 5\", \"Cell 6\", \"Cell 7\", \"Cell 8\", \"Cell 9\", \"Cell 0\"]\n \n override init(frame: CGRect, style: UITableViewStyle) {\n \n super.init(frame: frame, style: style)\n \n self.delegate = self\n self.dataSource = self\n }\n \n required init?(coder aDecoder: NSCoder) {\n fatalError(\"init(coder:) has not been implemented\")\n }\n \n func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n return itemTitle.count\n }\n \n func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n \n let cell = tableView.dequeueReusableCell(withIdentifier: \"cell\", for: indexPath)\n \n let padding: CGFloat = 5.0\n let cellWidth = tableView.frame.size.width - padding\n let cellHeight = cell.frame.size.height - padding\n \n let image = UIImage(named: \"spaceship\")\n \n let ratio = cellHeight / (image?.size.height)!\n \n let imageView = UIImageView(\n frame: CGRect(\n x: 0.0 + padding,\n y: 0.0 + padding,\n width: ((image?.size.width)! - (padding * 2)) * ratio,\n height: ((image?.size.height)! - (padding * 2)) * ratio))\n imageView.image = image\n cell.addSubview(imageView)\n \n let label = UILabel(\n frame: CGRect(\n x: imageView.frame.maxX,\n y: imageView.frame.minY,\n width: cellWidth - imageView.frame.maxX,\n height: cellHeight))\n label.text = self.itemTitle[indexPath.row]\n cell.addSubview(label)\n \n let price = UILabel(\n frame: CGRect(\n x: imageView.frame.maxX,\n y: imageView.frame.minY,\n width: cellWidth - imageView.frame.maxX,\n height: cellHeight))\n price.text = \"100\"\n price.textAlignment = .right\n cell.addSubview(price)\n \n return cell\n }\n \n func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {\n print(\"Cell Value : \\(itemTitle[indexPath.row])\")\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T12:52:22.117", "favorite_count": 0, "id": "40669", "last_activity_date": "2018-01-02T17:41:12.260", "last_edit_date": "2018-01-02T12:59:43.453", "last_editor_user_id": "20142", "owner_user_id": "20142", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "SpriteKitでUITableViewを利用しカスタムセル", "view_count": 128 }
[ { "body": "自己解決しましたので参考までにソースを記載します。\n\n```\n\n import SpriteKit\n import UIKit\n ...\n override func didMove(to view: SKView) {\n \n let tableView = TableView(frame: CGRect(x: 20, y: 50, width: 280, height: 200), style: .plain)\n tableView.register(UITableViewCell.self, forCellReuseIdentifier: \"cell\")\n self.view?.addSubview(tableView)\n tableView.reloadData()\n }\n ...\n class TableView: UITableView, UITableViewDelegate, UITableViewDataSource {\n \n private var itemImage = [\"spaceship\", \"spaceship\", \"spaceship\", \"spaceship\", \"spaceship\", \"spaceship\", \"spaceship\", \"spaceship\", \"spaceship\", \"spaceship\"]\n private var itemTitle = [\"Cell 1\", \"Cell 2\", \"Cell 3\", \"Cell 4\", \"Cell 5\", \"Cell 6\", \"Cell 7\", \"Cell 8\", \"Cell 9\", \"Cell 0\"]\n private var itemPrice = [\"100\", \"200\", \"300\", \"400\", \"500\", \"600\", \"700\", \"800\", \"900\", \"000\"]\n \n override init(frame: CGRect, style: UITableViewStyle) {\n \n super.init(frame: frame, style: style)\n \n self.delegate = self\n self.dataSource = self\n }\n \n required init?(coder aDecoder: NSCoder) {\n fatalError(\"init(coder:) has not been implemented\")\n }\n \n func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n return itemTitle.count\n }\n \n func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n \n //var cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: \"cell\")!\n let cell = tableView.dequeueReusableCell(withIdentifier: \"cell\", for: indexPath)\n \n // セルの再利用対策(再利用されたセル上のすべてのノードを削除)\n if cell.isHidden {\n let _ = cell.subviews.map { $0.removeFromSuperview() }\n }\n \n let padding: CGFloat = 5.0\n let cellWidth = tableView.frame.size.width\n let cellHeight = cell.frame.size.height\n \n if let image = UIImage(named: self.itemImage[indexPath.row]) {\n \n let ratio = cellHeight / image.size.height\n \n let imageView = UIImageView(\n frame: CGRect(\n x: 0.0 + padding,\n y: 0.0 + padding,\n width: (image.size.width * ratio) - (padding * 2),\n height: (image.size.height * ratio) - (padding * 2)))\n imageView.image = image\n cell.addSubview(imageView)\n \n let title = UILabel(\n frame: CGRect(\n x: imageView.frame.maxX,\n y: imageView.frame.minY,\n width: (cellWidth - imageView.frame.maxX) - padding,\n height: cellHeight - padding))\n title.text = self.itemTitle[indexPath.row]\n cell.addSubview(title)\n \n let price = UILabel(\n frame: CGRect(\n x: imageView.frame.maxX,\n y: imageView.frame.minY,\n width: (cellWidth - imageView.frame.maxX) - padding,\n height: cellHeight - padding))\n price.text = self.itemPrice[indexPath.row]\n price.textAlignment = .right\n cell.addSubview(price)\n }\n \n return cell\n }\n \n func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {\n //print(\"Cell Value : \\(itemTitle[indexPath.row])\")\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T15:57:39.037", "id": "40675", "last_activity_date": "2018-01-02T17:41:12.260", "last_edit_date": "2018-01-02T17:41:12.260", "last_editor_user_id": "20142", "owner_user_id": "20142", "parent_id": "40669", "post_type": "answer", "score": 0 } ]
40669
null
40675
{ "accepted_answer_id": "40671", "answer_count": 1, "body": "プログラミングスクールでvagrantfileをもらってそれを使いたいフォルダに移動し`vagrant\nup`でするだけでubuntu14.04を自動でインストールするようになっているのですが`add\nbox`を行っていないのにいきなりubuntu14.04が起動するのですがそのようなことは可能なのでしょうか? \nVagrantfileを見ても特に記述してなく書いてあると言えば`config.vm.box = ubuntu/trusty32`くらいです。\n\nどなたか詳しい方教えて頂けると幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T12:58:33.057", "favorite_count": 0, "id": "40670", "last_activity_date": "2018-01-02T14:37:52.533", "last_edit_date": "2018-01-02T14:37:52.533", "last_editor_user_id": "76", "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "vagrant" ], "title": "vagrantfileにインストールOSを指定することは可能なのでしょうか?", "view_count": 55 }
[ { "body": "`config.vm.box` の部分でまさに OS を指定しています。\n\nUbuntu にはコードネームといって、各リリースに対してバージョン番号とは別に名前が振り分けられています。Ubuntu Trusty Tahr とは\nUbuntu 14.04 LTS のことです。[Wikipedia の Ubuntu\nのページ](https://ja.wikipedia.org/wiki/Ubuntu#%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%B9%E4%B8%80%E8%A6%A7)などに一覧が載っています。\n\n`config.vm.box` には、既にインストールされている box の名前か、[Vagrant\nCloud](https://app.vagrantup.com/boxes/search) にアップロードされている box\nの名前を指定します([ドキュメント](https://www.vagrantup.com/docs/vagrantfile/machine_settings.html)にそう書いてあります)。今回の場合\n`config.vm.box = ubuntu/trusty32` なので、Vagrant Cloud にアップロードされている\n<https://app.vagrantup.com/ubuntu/boxes/trusty32> が指定されていることになり、したがって 32 bit 版\nUbuntu 14.04 の box が使われます。他にたとえば `config.vm.box = centos/7` とすると、\n<https://app.vagrantup.com/centos/boxes/7> が指定されることになり CentOS 7 の box が使われます。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T13:48:49.833", "id": "40671", "last_activity_date": "2018-01-02T14:12:37.567", "last_edit_date": "2018-01-02T14:12:37.567", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "40670", "post_type": "answer", "score": 3 } ]
40670
40671
40671
{ "accepted_answer_id": null, "answer_count": 1, "body": "以下のコードで物体検出を行うと1つの対象に対して複数の検出窓が表示されてしまいます。(対象物が画像上でわずかに離れて複数と認識されてしまったからだと思います。)検出窓は1つで良いので、複数の検出窓から1つの検出窓を抽出できるコードを知っていましたら教えていただきたいです。cv2.contourArea(contour)で表示できる領域を絞ってもだめでした。\n\n```\n\n img = cv2.imread(image)\n \n im2, contours, hierarchy = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE\n \n # draw contour\n for contour in contours:\n if cv2.contourArea(contour) < 1000 :\n continue\n \n # rectangle area\n x, y, w, h = cv2.boundingRect(contour)\n \n \n \n # draw contour\n img5=cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 3) \n \n return img5\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T13:51:43.597", "favorite_count": 0, "id": "40672", "last_activity_date": "2022-04-03T06:06:35.733", "last_edit_date": "2018-01-03T01:46:33.193", "last_editor_user_id": "25909", "owner_user_id": "25909", "post_type": "question", "score": 1, "tags": [ "python", "opencv" ], "title": "物体検出での検出できる検出窓を減らす方法", "view_count": 657 }
[ { "body": "検出された複数の輪郭の中で1つを選ぶには、判断する基準(2つの抽出された輪郭を比べて、どちらかを選ぶための方法)が必要です。\n\n例えば、以下のようなものが考えられます。 \n・輪郭の面積が大きいほうを選ぶ \n・輪郭の形が円に近いほうを選ぶ \n・輪郭の縦横比が1に近い(正方形に近い輪郭)を選ぶ\n\n判断基準が決まっていれば、検出された輪郭どうしを比較して一方を除外するという作業を繰り返すことで1つに絞り込むことができます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T04:15:06.820", "id": "40681", "last_activity_date": "2018-01-03T04:15:06.820", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "217", "parent_id": "40672", "post_type": "answer", "score": 1 } ]
40672
null
40681
{ "accepted_answer_id": "40697", "answer_count": 1, "body": "visual studio 2017でPowerShell上でコンパイラを使う方法はありますか? \nDeveloper Command Prompt for VS 2017もありますがPowerShell上ではなくcmd.exe上になってしまいます。\n\nまた、Developer Commnd Prompt for VS\n2017だとこのメニューから起動しないとcl.exeが使えません。(普通にコマンドプロンプトを起動しただけでは使えない)\n\n普通にPowerShellを起動すれば、いつでもコンパイラを使えるようにしたいのですがどうすればいいのでしょうか?\n\nOS: Windows 10 1709", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T13:59:56.290", "favorite_count": 0, "id": "40673", "last_activity_date": "2018-01-03T16:38:32.343", "last_edit_date": "2018-01-02T15:29:34.510", "last_editor_user_id": "5246", "owner_user_id": "5246", "post_type": "question", "score": 0, "tags": [ "windows", "visual-studio", "powershell" ], "title": "PowerShell上でcl.exeを使う", "view_count": 519 }
[ { "body": "[Pscx](https://www.powershellgallery.com/packages/Pscx)モジュールをインストールして`Import-\nVisualStudioVars`関数を使うのはどうでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T16:38:32.343", "id": "40697", "last_activity_date": "2018-01-03T16:38:32.343", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8324", "parent_id": "40673", "post_type": "answer", "score": 2 } ]
40673
40697
40697
{ "accepted_answer_id": "40678", "answer_count": 1, "body": "次のようなタグの情報を取得したいと考えています。\n\n```\n\n <ul class=\"dtlTbl\">\n <li data-locate=\"address\"><dl>\n <dt>住所</dt> \n </dl>\n </li>\n <li data-locate=\"tel\"><dl>\n <dt>TEL</dt>\n </dl>\n </li>\n </ul>\n \n```\n\nこのタグから、次のようにli の内容をひとつづつ保存したいと考えています。 \naddress = [\"住所\"] \ntel = [\"tel\"] \nこのために、次のようなコードを書いています。\n\n```\n\n import requests\n import bs4 \n import pandas as pd \n \n resp = requests.get(url)\n html = resp.content\n soup = bs4.BeautifulSoup(html, \"lxml\")\n \n li_part = soup.find_all(\"ul\", class_=\"dtlTbl\")\n address = li_part.find_all(\"li\", data-locate=\"address\")\n \n```\n\nしかし、次のようなエラーが出生じています。\n\n```\n\n address = detail_part.find_all(\"li\", data-locate=\"address\")\n ^\n SyntaxError: keyword can't be an expression\n \n```\n\nこの問題について、解決方法を示唆して頂けますと、大変ありがたいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-02T22:20:38.040", "favorite_count": 0, "id": "40676", "last_activity_date": "2018-07-20T07:49:47.903", "last_edit_date": "2018-07-20T07:49:47.903", "last_editor_user_id": "19110", "owner_user_id": "20148", "post_type": "question", "score": 2, "tags": [ "python", "beautifulsoup" ], "title": "BeautifulSoup を用いた、特定のli の内容の取得", "view_count": 565 }
[ { "body": "引用: [kondou.com - Beautiful Soup 4.2.0 Doc. 日本語訳\n(2013-11-19最終更新)](http://kondou.com/BS4/)\n\n```\n\n HTML5の ‘data-*’ 属性など、いくつかの属性についてはキーワード引数として用いることができません。:\n \n data_soup = BeautifulSoup('<div data-foo=\"value\">foo!</div>')\n data_soup.find_all(data-foo=\"value\")\n # SyntaxError: keyword can't be an expression\n しかし、これらの属性を辞書にして、キーワード引数 attrs として値を渡せばフィルタリングすることができます。:\n \n data_soup.find_all(attrs={\"data-foo\": \"value\"})\n # [<div data-foo=\"value\">foo!</div>]\n \n```\n\n \n \nなので、やりたいことは下記になると思います。 \n`li_part.find_all(\"li\", attrs={\"data-locate\": \"address\"})`", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T00:10:49.643", "id": "40678", "last_activity_date": "2018-01-03T00:10:49.643", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "parent_id": "40676", "post_type": "answer", "score": 3 } ]
40676
40678
40678
{ "accepted_answer_id": "40682", "answer_count": 2, "body": "macのbashでのコマンド処理についての質問です。 \nフォルダ内にある末尾がzip以外のモノを削除するようにしたいのですが、ファイル・フォルダ名に空白がある場合、うまく処理してくれません。解決するにはどうすればいいでしょうか。 \n宜しくお願い致します。\n\n`ls | grep -v -E 'zip$' | xargs rm -r`", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T02:36:32.237", "favorite_count": 0, "id": "40679", "last_activity_date": "2018-01-05T14:12:20.520", "last_edit_date": "2018-01-03T04:53:19.423", "last_editor_user_id": "3060", "owner_user_id": "25524", "post_type": "question", "score": 2, "tags": [ "bash", "macos" ], "title": "bashでファイル名の半角処理についての質問です", "view_count": 127 }
[ { "body": "`xargs`(1)\nのデフォルトは標準入力をそのまま指定したコマンドに渡すのではなく、空白文字で分けたり、ダブルクォートやバックスラッシュでエスケープしたり、色々解釈します。詳しくはマニュアルなどをどうぞ。よって、そのような特別な文字を含む入力を与える場合は工夫が必要です。よくわからない、理解したくないというなら\n`xargs`(1) は危険なので使わないことを推奨します。\n\nファイルの名前や種類を条件に絞り込み一定の処理をしたい場合は `find`(1) をお薦めします:\n\n```\n\n $ find /path/to/dir -type f ! -name '*.zip' -delete\n \n```\n\nフォルダが空になったら削除したいなら:\n\n```\n\n $ find /path/to/dir -type f -name '*.zip' -delete -o -type d -empty -delete\n \n```\n\n挙げられているコマンドライン例のように特定フォルダ直下の `*.zip` 以外のファイルを削除するなら:\n\n```\n\n $ find /path/to/dir -maxdepth 1 -type f ! -name '*.zip' -delete\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T05:50:25.547", "id": "40682", "last_activity_date": "2018-01-05T14:12:20.520", "last_edit_date": "2018-01-05T14:12:20.520", "last_editor_user_id": "3061", "owner_user_id": "3061", "parent_id": "40679", "post_type": "answer", "score": 3 }, { "body": "補足として。bashのオプションで`extglob`が有効になっていると、`!(pattern)`という(パターンにマッチしないファイルにマッチする)パターンマッチング演算子が使えます。ただし、macOSのデフォルトでは`extglob`がオフだったと思います。\n\n```\n\n $ shopt -s extglob\n $ rm !(*.zip)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T08:08:43.710", "id": "40686", "last_activity_date": "2018-01-03T08:08:43.710", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4010", "parent_id": "40679", "post_type": "answer", "score": 0 } ]
40679
40682
40682
{ "accepted_answer_id": null, "answer_count": 1, "body": "Microsoft R OpenとRstudioの違いはなんですか?またどちらがおすすめなのかも教えていただきたいです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T04:12:42.047", "favorite_count": 0, "id": "40680", "last_activity_date": "2018-01-03T18:56:19.840", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26581", "post_type": "question", "score": 1, "tags": [ "python", "r" ], "title": "Microsoft R OpenとRstudioの違いはなんですか?", "view_count": 1678 }
[ { "body": "Microsoft R OpenとRstudioはどちらかと言われれば、Rstudio 。理由はドキュメントの充実度。\n\n結論としては、、、 \nMicrosoft R\nOpenとRstudioはどちらもお勧めできません。インストールが楽ちんというメリットがありますが、「拡張性が低い」「マークダウンなどの機能が直感的でなく使いにくい」「ドキュメントが少ない」などのデメリットがたくさんあります。\n\n使うなら今後のことも考えてjupyter notebook というものを使ってください。 \njupyter\nnotebookはもともとpython用に開発されたIpythonが発祥ですが、今はあらゆる言語に対応しています。若干環境構築手順が多いですが、断然おすすめ。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T18:19:19.103", "id": "40702", "last_activity_date": "2018-01-03T18:56:19.840", "last_edit_date": "2018-01-03T18:56:19.840", "last_editor_user_id": "20267", "owner_user_id": "20267", "parent_id": "40680", "post_type": "answer", "score": 1 } ]
40680
null
40702
{ "accepted_answer_id": "40685", "answer_count": 1, "body": "ubuntu14.04にanacondaをインストールしたくpyenvを以下のコマンドでインストールしたのですが、パスが上手く通せません。\n\n実行したコマンド\n\n```\n\n sudo apt-get install git\n sudo apt-get install gcc make libssl-dev libbz2-dev libreadline-dev libsqlite3-dev zlib1g-dev\n git clone https://github.com/yyuu/pyenv.git ~/.pyenv\n echo \"export PYENV_ROOT=$HOME/.pyenv\" >> ~/.bashrc\n echo \"export PATH=$PYENV_ROOT/bin:$PATH\" >> ~/.bashrc\n echo 'eval \"$(pyenv init -)\"' >> ~/.bashrc\n source ~/.bashrc\n \n```\n\n最後のsourceコマンドを実行すると\n\n```\n\n No command 'pyenv' found, did you mean:\n Command 'p7env' from package 'libnss3-tools' (main)\n pyenv: command not found\n \n```\n\nこのようなエラーが出ます。\n\nvimで見ると\n\n```\n\n echo \"export PATH=$PYENV_ROOT/bin:$PATH\" >> ~/.bashrc\n \n```\n\n上の部分が下記のパスに変わっていてここがおかしいと思うのですがどのように直していいのかわかりません。\n\nvimで見た~/.bashrc\n\n```\n\n export PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\n \n```\n\nどなたか詳しい方教えて下さると幸いです。よろしくおねがします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T06:06:19.433", "favorite_count": 0, "id": "40683", "last_activity_date": "2018-01-03T07:21:54.907", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22565", "post_type": "question", "score": 1, "tags": [ "python", "linux", "python3", "ubuntu", "pyenv" ], "title": "ubuntu14.04にpyenvをインストールしたけどパスが上手く通らない。", "view_count": 2708 }
[ { "body": "結論としてはVimで開いたのなら直接編集すればいいと思います。\n\nなお、そうなる原因を説明するとクォートの違いです。\n\n```\n\n echo \"export PATH=$PYENV_ROOT/bin:$PATH\" >> ~/.bashrc\n \n```\n\nこの場合、ダブルクォートで囲われた文字列に変数があると展開されます。 \nしかし、この段階ではまだ`$PYENV_ROOT`が定義されていないので空文字列になります。 \nどうしても`echo`からダブルクォートされた文字列を追記したいなら変数が展開されないようにする必要があります。\n\n```\n\n echo 'export PATH=$PYENV_ROOT/bin:$PATH' >> ~/.bashrc\n \n```\n\n一方、シングルクォートで囲われた文字列では変数が展開されず、そのまま追記されます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T07:21:54.907", "id": "40685", "last_activity_date": "2018-01-03T07:21:54.907", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25936", "parent_id": "40683", "post_type": "answer", "score": 3 } ]
40683
40685
40685
{ "accepted_answer_id": "40695", "answer_count": 1, "body": "初心者です。 \npythonの画像認識をしてみたいと思い[こちら](http://karaage.hatenadiary.jp/entry/2016/07/08/073000)の記事に沿って進めていましたが、chainer\n公式リポジトリの[このコード](https://github.com/chainer/chainer/blob/4f0073f70f2d4a044b382214cf1ea592654d1f04/examples/modelzoo/evaluate_caffe_net.py)を実行しようとして\n\n```\n\n $ python evaluate_caffe_net.py test.txt caffenet bvlc_reference_caffenet.caffemodel -b ./ -B 1\n \n```\n\nで\n\n```\n\n Traceback (most recent call last):\n File \"evaluate_caffe_net.py\", line 46, in <module>\n chainer.config.train = False # All the codes will run in test mode\n AttributeError: module 'chainer' has no attribute 'config'\n \n```\n\nというエラーが出てしまいました。 \n本来なら記事のように、\n\n```\n\n Loading Caffe model file bvlc_reference_caffenet.caffemodel...\n Loaded\n mean loss: 8.06329917908\n mean accuracy: 0.0\n \n```\n\nというように出力されるようです。 \nAttributeErrorについて色々調べてみたりコードも読んでみましたが解決しません。何か考えられる原因があれば試してみたいので、思いつく問題点を教えていただきたいです。よろしくお願いします。\n\nOSはmacOS HighSierra 10.13.2 \nAnacondaを使用してPythonのバージョンを3.6.3に切り替えていました。 \nChainerのバージョンは1.8.1です。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T06:35:50.333", "favorite_count": 0, "id": "40684", "last_activity_date": "2018-01-03T16:34:01.500", "last_edit_date": "2018-01-03T14:55:42.677", "last_editor_user_id": "26866", "owner_user_id": "26866", "post_type": "question", "score": 1, "tags": [ "python", "python3", "chainer" ], "title": "chainerを使った画像認識でAttributeError", "view_count": 207 }
[ { "body": "`chainer.config.train` は Chainer [バージョン 2\nからの機能であり](https://docs.chainer.org/en/stable/upgrade.html#global-\nconfigurations)、今回これが見つからないとエラーが出ています。このため、Chainer のバージョンを確認してください。\n\n現在インストールされているバージョンの確認は、Chainer を Anaconda 経由でインストールした場合 \n`conda list | grep chainer` で可能です。また、pip 経由でインストールした場合 `pip show chainer`\nで可能です。\n\nChainer のアップグレードは、Anaconda を使うのでしたら `conda install -c anaconda chainer`、素の pip\nを使うのでしたら `pip install 'chainer>=2.0.0'` で可能です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T15:59:39.233", "id": "40695", "last_activity_date": "2018-01-03T16:34:01.500", "last_edit_date": "2018-01-03T16:34:01.500", "last_editor_user_id": "19110", "owner_user_id": "19110", "parent_id": "40684", "post_type": "answer", "score": 1 } ]
40684
40695
40695
{ "accepted_answer_id": "40693", "answer_count": 1, "body": "現在以下のようにパラメーターと共にPOST通信を行なっています。\n\n```\n\n let parameters: [String:Any] = [\n \"Diary\": [\n \"ID\": diary.id,\n \"Title\": diary.title,\n \"Content\": diary.content,\n \"XTime\": diary.xtime,\n \"IsShared\": diary.isShare\n ]]\n \n var request = URLRequest(url: url!)\n request.httpMethod = \"POST\"\n request.timeoutInterval = 10\n request.httpBody = try! JSONSerialization.data(withJSONObject: parameters, options: .prettyPrinted)\n let task = URLSession.shared.dataTask(with: request) { data, response, error in\n \n```\n\nそしてPHP側は以下のようになっています。\n\n```\n\n $json = file_get_contents('php://input');\n $data = json_decode($json, true);\n var_dump($json);\n \n```\n\nしかし実際にブラウザには以下のように表示されてしまっています。\n\nstring(0) \"\"\n\nなぜPHP側で値が受け取れていないのでしょうか。 \nどなたか分かる方がいれば教えていただきたいです。よろしくお願いします。", "comment_count": 7, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T08:25:40.870", "favorite_count": 0, "id": "40687", "last_activity_date": "2018-01-03T14:46:16.447", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5210", "post_type": "question", "score": 0, "tags": [ "swift", "ios", "php", "json" ], "title": "POST通信をした時にPHP側で値が空になる", "view_count": 1594 }
[ { "body": "Swift のコードに\n\n```\n\n request.addValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n \n```\n\nを追加するとどうでしょうか?\n\nまた、アクセスする url を `https://httpbin.org/post` に変えてみるとどうでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T14:46:16.447", "id": "40693", "last_activity_date": "2018-01-03T14:46:16.447", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "369", "parent_id": "40687", "post_type": "answer", "score": 1 } ]
40687
40693
40693
{ "accepted_answer_id": "40690", "answer_count": 1, "body": "mac vimをさわり初めたばかりで、書籍で勉強中です。 \n行末に移動するショートカットが$マークになっていますが、移動しません。Shiftキー+$では移動できるのですが、面倒です。$マークだけでは移動できないのでしょうか。宜しくお願い致します。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T12:41:55.810", "favorite_count": 0, "id": "40689", "last_activity_date": "2018-01-03T13:58:40.567", "last_edit_date": "2018-01-03T13:58:40.567", "last_editor_user_id": "754", "owner_user_id": "25524", "post_type": "question", "score": 0, "tags": [ "vim", "macos" ], "title": "macのvimでの行末コマンドについての質問です。", "view_count": 332 }
[ { "body": "`$`のキーを`Shift`を押さないで押すと`4`です。 \n`4`を押しているので末尾に移動しなくて当然です。\n\n`4`が使えなくなると、`4x`など`x`を4回繰り返せなどの命令ができなくなってしまうので、それはそれで混乱しやすい環境になってしまうと思います。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T12:48:02.403", "id": "40690", "last_activity_date": "2018-01-03T12:53:02.430", "last_edit_date": "2018-01-03T12:53:02.430", "last_editor_user_id": "9008", "owner_user_id": "9008", "parent_id": "40689", "post_type": "answer", "score": 3 } ]
40689
40690
40690
{ "accepted_answer_id": null, "answer_count": 0, "body": "ここだけでなく多くの質問掲示板で、検索した語から適応度の高いものを表示していますが、その適応のさせ方にはどのようなものがあるのでしょうか。 \nまた、こちらではコードがある場合がございますが、それに関して他との違いはないのでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T13:33:06.847", "favorite_count": 0, "id": "40691", "last_activity_date": "2018-10-15T08:21:32.193", "last_edit_date": "2018-10-15T08:21:32.193", "last_editor_user_id": "19769", "owner_user_id": "25236", "post_type": "question", "score": 2, "tags": [ "検索" ], "title": "質問掲示板の検索結果の表示の仕組みについて", "view_count": 111 }
[]
40691
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "html の勉強を始めたばかりなのですが、container や jumbotronなどは使えるのにnavbarが正しく表示されません。 \nbootstrapのNAVSやNAVBARから直接コピペしても表示がホームページにある例とは異なる形で表示されてしまうので何が間違っているのかが全く分からない状態で困っています。 \nudemyを主な学習材料に使っていましたが、教材にはこのような場合の留意点などはありませんでした。困り果てて別の教材も買ってみたのですが同様でした。 \nhtmlのコード以外などでbootstrap使用時に注意しなければならないことなどがあれば教えていただきたいです。\n\nよろしくお願いします。\n\n写真では[Tabsのコード](https://getbootstrap.com/docs/3.3/components/#nav-\ntabs)をそのままコピーしています。\n\n```\n\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n \n <title></title>\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css\" integrity=\"sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy\" crossorigin=\"anonymous\">\n </head>\n <body>\n \n </body>\n </html>\n \n <ul class=\"nav nav-tabs\">\n <li role=\"presentation\" class=\"active\"><a href=\"#\">Home</a></li>\n <li role=\"presentation\"><a href=\"#\">Profile</a></li>\n <li role=\"presentation\"><a href=\"#\">Messages</a></li>\n </ul>\n \n```\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/bLRvC.png)](https://i.stack.imgur.com/bLRvC.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T15:00:18.697", "favorite_count": 0, "id": "40694", "last_activity_date": "2019-01-13T16:03:05.647", "last_edit_date": "2018-01-03T22:56:05.647", "last_editor_user_id": "3068", "owner_user_id": "26869", "post_type": "question", "score": 0, "tags": [ "html", "bootstrap" ], "title": "bootstrap でnavbar が正しく表示されません", "view_count": 573 }
[ { "body": "スクリーンショットを見る限り、bootstrapの前にhtmlについて勉強する必要があります。特に`<html>`タグや`<body>`タグの役割といった基礎の基礎の知識が足りてないように見受けられます。\n\nとりあえずの解決策としては、全てのコンテンツは`</body>`の手前に書く必要があります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T22:10:54.297", "id": "40705", "last_activity_date": "2018-01-03T22:10:54.297", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "40694", "post_type": "answer", "score": 2 } ]
40694
null
40705
{ "accepted_answer_id": null, "answer_count": 3, "body": "C言語でプログラムを書いた後、gccによって実行ファイルを作成し、それをバイナリ解析しようと思ったのですが、以下のプログラムであると、stringsコマンドによって\"hoge\"という文字列が出力されてしまいます。そこで、それが出力されないようにしたいのですが、どういった手法を用いれば良いのでしょうか。txtファイルに保存してということもできると思うのですが、これをバイナリ解析の問題としてダウンロードファイルにしたいため、それをするとtxtファイルまでダウンロードさせることになり、簡単に解かれてしまうと思い質問しました。\n\n```\n\n #include <stdio.h>\n #include <string.h>\n \n int main(void)\n {\n char buf[32];\n char key[] = \"hoge\";\n \n puts(\"Please input password.\");\n fgets(buf, sizeof(buf), stdin);\n strtok(buf, \"\\n\");\n \n if(!strcmp(buf, key)){\n puts(\"Congratulations!\");\n }\n else{\n puts(\"Invalid input.\");\n }\n return 0;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T16:17:50.653", "favorite_count": 0, "id": "40696", "last_activity_date": "2018-01-06T07:48:35.647", "last_edit_date": "2018-01-03T16:31:26.357", "last_editor_user_id": "5288", "owner_user_id": "20760", "post_type": "question", "score": 2, "tags": [ "c" ], "title": "strings コマンドによる解析に対する対策", "view_count": 1155 }
[ { "body": "strings コマンドで簡単にバレてしまうことに対する対策であれば、 \n簡単に以下のようにするのはいかがでしょう?\n\n```\n\n char key[] = {'h', 'o', 'g', 'e', 0};\n \n```\n\n手元で strings コマンドで確認したところ、`hoge` はなくなりました。\n\nただし、少なくとも gcc の場合、以下のようにオプションにもよるようです。\n\n`cc -S test.c` の場合:\n\n```\n\n movb $104, -53(%rbp)\n movb $111, -52(%rbp)\n movb $103, -51(%rbp)\n movb $101, -50(%rbp)\n movb $0, -49(%rbp)\n \n```\n\n↑これだと問題ありませんが、\n\n`cc -O2 -S test.c` の場合:\n\n```\n\n movl $1701277544, 11(%rsp)\n \n```\n\n↑最適化すると `hoge` が見えてしまいました。\n\n```\n\n luna:~ % cc --version\n cc (GCC) 7.2.1 20171128\n Copyright (C) 2017 Free Software Foundation, Inc.\n This is free software; see the source for copying conditions. There is NO\n warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n \n```\n\nコメントにもある通り、`-fno-store-merging` でこの挙動は抑制できますが、 \n同じ `.c` ファイルの他の部分にも影響を与えてしまいますので、 \nこのオプションを使うなら、この部分だけ別の `.c` ファイルに分離するのが良い \nだろうと思います。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T16:39:09.853", "id": "40698", "last_activity_date": "2018-01-06T04:24:22.483", "last_edit_date": "2018-01-06T04:24:22.483", "last_editor_user_id": "5288", "owner_user_id": "5288", "parent_id": "40696", "post_type": "answer", "score": 0 }, { "body": "本当にやりたいのは実行形式ファイルの難読化であって `strings` に特化した話ではなさそうですが、質問タイトルに沿う形で話を続けることにします。\n\n前提条件 \n\\- ソースコードを大きく変更しない \n\\- `strings` で表示されない\n\n案1.日本語にしてしまう \n`strings` は日本語文字列を表示しませんから `strcmp(buf, \"ほげ\")` でよさそうです。\n\n案2.ワイド文字にしてしまう \n入力文字を `char` → `wchar_t` に変換して `wcscmp(buf, L\"hoge\")` とすると `strings a.exe` では\n`hoge` は表示されなくなります。ただし `strings -el a.exe` では表示されてしまいます。知っている人には通用しなさそうです。\n\n案3.難読化ツール・圧縮ツールを使う \nMS-DOS の時代には EXE ファイルを圧縮し、起動時に自己展開するようなツールが流行っていました。圧縮すれば `strings`\nで見ても中身はぐちゃぐちゃです。今はあまり見かけないのでしょうか?ちょっと探しただけだと upx とか超古いものしか見つかりませんでした。 \n難読化ツール Obfuscator は .NET の世界では広く使われていますが native\nの世界ではあまり見かけないようです。とりあえずちょろっと検索して見つけた範囲では PELock とか <https://www.pelock.com>\n\n案4.直接見られたくない文字列はコンパイル前に base64 や uuencode する \nソースコード上例えば `strcmp(buf, unbase64(BASE64IZE(\"hoge\")))` のように書きます。 \n\\- `BASE64IZE()` はコンパイル前に base64 変換するマクロっつかツールでソース置換する \n\\- `unbase64()` は実行時に base64 逆変換する関数を自作\n\nwindows 特化であれば文字列リソースを base64/uuencode しておいて `LoadResource`\n後に元に戻すとか。パスワードを含むテキストファイルを zip\n圧縮してヘッダ取り除くとか。まあやろうと思えばいくらでもできます。あとはコストパフォーマンスの問題に過ぎないです。\n\n\\--- 以下追記 ---\n\nパスワードの生文字列を見せたくないのであればパスワードシステムとしてすでに確立しているソルト+暗号学的単方向ハッシュ(+ストレッチング)を実装してみるとか。固定ソルト+固定ハッシュを1回で十分(ソルトなしでも十分という話がちらほら聞こえてきそうです)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T04:57:09.830", "id": "40707", "last_activity_date": "2018-01-04T23:03:23.110", "last_edit_date": "2018-01-04T23:03:23.110", "last_editor_user_id": "8589", "owner_user_id": "8589", "parent_id": "40696", "post_type": "answer", "score": 1 }, { "body": "多少脱線しますが回答者も間違えているので重要なこととして補足しておきます。K&R 2nd 4.9 Initializationにも\n\n> Character arrays are a special case of initialization; a string may be used\n> instead of the braces and commas notation:\n```\n\n> char pattern[] = \"ould\";\n> \n```\n\n>\n> is a shorthand for the longer but equivalent\n```\n\n> char pattern[] = { 'o', 'u', 'l', 'd', '\\0' };\n> \n```\n\nと説明されているように、たとえソースコード中で1文字ずつ分割して記述したとしても言語仕様上は同じ意味となります。\n\n* * *\n\nさて回答ですが、ここから一歩発展させて各文字を`~`ビット反転させてみてはどうでしょうか? \n実行時にはもう一度ビット反転させることで値が復元できます。もちろん`~`でなくても特定のビットパターンでのXORでも可能です。\n\n```\n\n char key[] = { ~'h', ~'o', ~'g', ~'e', '\\0' };\n for (int i = 0; i < 4; i++) key[i] = ~key[i];\n \n```\n\nこれで質問にある「strings コマンドによる解析」に対してとりあえずの対策とはなります。\n\n* * *\n\nなお、有名ソフトウェアになりますと例えば[MS SQL\nServerで全ユーザーの生パスワード閲覧可能な脆弱性](https://news.mynavi.jp/article/20090909-a055/)のようにプログラム動作中のメモリを盗み見ることで漏洩する・その対策が求められることになります。 \n実行ファイルの難読化も実行開始時に復号してプログラムスタートとなる実装の場合、復号完了した時点でプロセスを一時停止しメモリイメージをダンプされてしまうと簡単に難読化前の実行ファイルを取得できてしまいます。 \nそういった事例も踏まえましてどこまで対策を試みるべきかから見直した方がいいかもしれません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T06:03:33.173", "id": "40737", "last_activity_date": "2018-01-06T07:48:35.647", "last_edit_date": "2018-01-06T07:48:35.647", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "40696", "post_type": "answer", "score": 3 } ]
40696
null
40737
{ "accepted_answer_id": null, "answer_count": 1, "body": "matplotlibを用いたグラフを作成した際に、y軸の目盛りが表示されずに困っています。以下のようなコードを用いて、y軸がログスケールになるようなグラフを作りたいのですがグラフを表示してみるとy軸の目盛りが何も表示されません。\n\n```\n\n import csv\n import matplotlib.pyplot as plt\n with open(\"hoge.csv\", 'r') as f:\n list = []\n reader = csv.reader(f)\n for line in reader:\n list.append(float(line[0]))\n \n plt.yscale(\"log\")\n plt.plot(list)\n plt.grid()\n plt.xlabel(\"x\", fontsize = 15)\n plt.ylabel(\"y\", fontsize = 15)\n plt.show()\n \n```\n\nhoge.csvの中身は以下のようになっています。\n\n```\n\n 125853.0904\n 125844.9593\n 125843.4201\n 125842.9831\n 125842.7985\n 125842.7672\n 125842.6343\n 125842.4554\n 125842.4153\n 125842.3786\n \n```\n\nこのように値が大きくあまり変化しない場合、y軸の目盛りが表示されないような仕様なのでしょうか。解決策などあればお教えいただけるとありがたいです。 \nこちらの環境は \nOS:windows7 \npython:3.5 \nmatplotlib:2.0.2 \nとなっています。よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T17:07:42.083", "favorite_count": 0, "id": "40699", "last_activity_date": "2018-01-03T21:36:41.690", "last_edit_date": "2018-01-03T21:22:41.117", "last_editor_user_id": "7837", "owner_user_id": "26872", "post_type": "question", "score": 0, "tags": [ "python", "matplotlib" ], "title": "matplotlibを用いた際に軸の数字が表示されない問題について", "view_count": 3544 }
[ { "body": "手っ取り早い方法は次のようにyticksを指定する方法です。\n\n```\n\n plt.yticks(range(125840,125854))\n \n```\n\n[![Y軸のtickを指定](https://i.stack.imgur.com/O9q3v.png)](https://i.stack.imgur.com/O9q3v.png)\n\n丁寧にやるなら英語版の[この回答](https://stackoverflow.com/questions/29188757/matplotlib-\nspecify-format-of-floats-for-tick-lables)をご参考ください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T21:36:41.690", "id": "40704", "last_activity_date": "2018-01-03T21:36:41.690", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7837", "parent_id": "40699", "post_type": "answer", "score": 1 } ]
40699
null
40704
{ "accepted_answer_id": null, "answer_count": 0, "body": "reduxのcreateStore, applyMiddlewareのソースの\n\n```\n\n function createStore(reducer, preloadedState, enhancer) {\n //省略\n return enhancer(createStore)(reducer, preloadedState)\n //省略\n }\n \n function applyMiddleware(...middlewares) {\n return createStore => (...args) => {\n //省略\n }\n \n```\n\n上記のcreateStore、applyMiddleware関数の動作がいまいち分かりません \nこれはcreateStoreを実行した際enhancerを実行 \nenhancer(applyMiddleware)がコールバックでcreateStoreを実行しreducerとpreloadedStateを引数にとり再度createStoreを実行している \nといった感じで合っているのでしょうか?\n\n該当ソースのリンクは以下になります \n<https://github.com/reactjs/redux/blob/master/src/createStore.js> \n<https://github.com/reactjs/redux/blob/master/src/applyMiddleware.js>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-03T18:02:51.840", "favorite_count": 0, "id": "40701", "last_activity_date": "2018-01-04T17:03:36.387", "last_edit_date": "2018-01-04T17:03:36.387", "last_editor_user_id": "26616", "owner_user_id": "26616", "post_type": "question", "score": 0, "tags": [ "javascript", "redux" ], "title": "reduxのcreateStore, applyMiddleware", "view_count": 82 }
[]
40701
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "## 前提・実現したいこと\n\nXcode ver9.2 、 Swift で iOS アプリを開発しています。\n\nNavigationBar 右上の編集ボタンが押されたら、 TableViewCell 内の textField を編集可能にする方法を教えてください。\n\n* * *\n\n## 発生している問題\n\nオブジェクトの配置とコード(括弧内)の関係:\n\n * NavigationController \n * TableViewController (`TableViewController.swift`) \n * TableViewCell (`TableViewCell.swift`) \n * TextField\n\n初期表示では TextField が編集できないように、 `TableViewCell.swift` 内の `awakeFromNib()` で\n`textField.isEnabled = false` と設定しています。\n\n編集ボタンが押されたら、 TextField を編集できるように、 true に設定したく、方法を教えて頂けませんでしょうか?\n\n* * *\n\n## 該当のソースコード\n\n`TableViewController.swift`:\n\n```\n\n import UIKit\n \n class TableViewController: UITableViewController, TableViewCellDelegate {\n \n @IBOutlet var ttableView: UITableView!\n \n var array:[String] = [\"あああ\", \"いいい\", \"ううう\", \"えええ\", \"おおお\"]\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n // Uncomment the following line to preserve selection between presentations\n // self.clearsSelectionOnViewWillAppear = false\n \n // Uncomment the following line to display an Edit button in the navigation bar for this view controller.\n self.navigationItem.rightBarButtonItem = self.editButtonItem\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n \n override func setEditing(_ editing: Bool, animated: Bool) {\n super.setEditing(editing, animated: animated)\n }\n \n // MARK: - Table view data source\n \n override func numberOfSections(in tableView: UITableView) -> Int {\n // #warning Incomplete implementation, return the number of sections\n return 1\n }\n \n override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {\n // #warning Incomplete implementation, return the number of rows\n return array.count\n }\n \n override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n let cell = tableView.dequeueReusableCell(withIdentifier: \"inputCell\", for: indexPath) as! TableViewCell\n cell.textField.text = array[indexPath.row]\n // デリゲート設定\n cell.delegate = self\n return cell\n }\n \n // テキストフィールド編集後\n func textFieldDidEndEditing(cell: TableViewCell, value: String) -> () {\n let path = tableView.indexPathForRow(at: cell.convert(cell.bounds.origin, to: tableView))\n array[(path?.row)!] = value\n }\n \n // 削除ボタン押下後\n override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {\n if (editingStyle == UITableViewCellEditingStyle.delete) {\n array.remove(at: indexPath.row)\n tableView.deleteRows(at: [indexPath], with: .fade)\n }\n }\n \n override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {\n \n let cell = tableView.cellForRow(at: sourceIndexPath) as! TableViewCell\n let moveData = cell.textField.text\n array.remove(at: sourceIndexPath.row)\n array.insert(moveData!, at: destinationIndexPath.row)\n }\n \n }\n \n```\n\n`TableViewCell.swift`:\n\n```\n\n import UIKit\n \n // プロトコル\n protocol TableViewCellDelegate {\n func textFieldDidEndEditing(cell: TableViewCell, value: String) -> ()\n }\n \n class TableViewCell: UITableViewCell, UITextFieldDelegate {\n \n var delegate: TableViewCellDelegate! = nil\n \n // テキストフィールド接続\n @IBOutlet weak var textField: UITextField!\n \n override func awakeFromNib() {\n super.awakeFromNib()\n // テキストフィールドデリゲート\n textField.delegate = self\n // テキストフィールド入力キーボードの改行を完了に変更\n textField.returnKeyType = .done\n // 右上の編集ボタンが押される前はテキストフィールドを編集不可に設定\n textField.isEnabled = false\n }\n \n override func setSelected(_ selected: Bool, animated: Bool) {\n super.setSelected(selected, animated: animated)\n \n // Configure the view for the selected state\n }\n \n // テキストフィールド編集後デリゲート\n func textFieldDidEndEditing(_ textField: UITextField) {\n self.delegate.textFieldDidEndEditing(cell: self, value: textField.text!)\n }\n \n // リターンキー押下後デリゲート\n func textFieldShouldReturn(_ textField: UITextField) -> Bool {\n textField.resignFirstResponder()\n return true\n }\n \n }\n \n```\n\n編集画面: \n[![画像の説明をここに入力](https://i.stack.imgur.com/7xRy1.png)](https://i.stack.imgur.com/7xRy1.png)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2018-01-04T02:17:39.590", "favorite_count": 0, "id": "40706", "last_activity_date": "2021-12-26T14:02:15.220", "last_edit_date": "2019-05-05T16:14:52.937", "last_editor_user_id": "29826", "owner_user_id": "26867", "post_type": "question", "score": 0, "tags": [ "swift", "ios" ], "title": "NavigationBarの編集ボタンが押されたらTableViewCell内のtextFieldを編集可能にする方法", "view_count": 826 }
[ { "body": "CellのawakeFromNib()での`textField.isEnabled =\nfalse`は不要なので削除し、TableViewControllerのCellForRowAtにて、`cell.textField.isEnabled =\nself.isEditing`すればひとまずは解決だと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-13T12:53:43.660", "id": "40933", "last_activity_date": "2018-01-13T12:53:43.660", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "427", "parent_id": "40706", "post_type": "answer", "score": 1 } ]
40706
null
40933
{ "accepted_answer_id": "40734", "answer_count": 2, "body": "```\n\n $array = array(\n array('name'=>'いちご','id'=>'10'),\n array('id'=>'13'),\n array('name'=>'りんご','id'=>'20'),\n array('id'=>'28'),\n array('name'=>'みかん','id'=>'30'),\n array('name'=>'りんご','id'=>'50'),\n array('name'=>'いちご','id'=>'60'),\n )\n \n```\n\nこのデータを、nameがないものはそのままで、nameのあるものは、一番最初に出現した同じnameの下にまとめたいとおもっています。\n\nソート後のイメージとしては、\n\n```\n\n $array = array(\n array('name'=>'いちご','id'=>'10'),\n array('name'=>'いちご','id'=>'60'),\n array('id'=>'13'),\n array('name'=>'りんご','id'=>'20'),\n array('name'=>'りんご','id'=>'50'),\n array('id'=>'28'),\n array('name'=>'みかん','id'=>'30'),\n )\n \n```\n\nこういったソートを行う手段をご存知でしたら教えてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T05:41:56.697", "favorite_count": 0, "id": "40708", "last_activity_date": "2018-01-05T06:19:50.423", "last_edit_date": "2018-01-04T23:55:59.360", "last_editor_user_id": "26875", "owner_user_id": "26875", "post_type": "question", "score": 0, "tags": [ "php" ], "title": "二次元配列の値を、値の出現順を変えず、空白は無視してまとめたい", "view_count": 378 }
[ { "body": "プログラミング言語やライブラリの「ソート」機能は何らかのキーの値に従って順序を並べ替えるものなので、ご自身でちょっとしたコードを書いてやらないといけないだろうと思います。\n\n例えばこんな感じ。\n\n```\n\n <?php\n \n $array = [\n ['name'=>'いちご','id'=>'10'],\n ['id'=>'13'],\n ['name'=>'りんご','id'=>'20'],\n ['id'=>'28'],\n ['name'=>'みかん','id'=>'30'],\n ['name'=>'りんご','id'=>'50'],\n ['name'=>'いちご','id'=>'60'],\n ];\n //'name'の値で分類して、「キー=>配列」の連想配列を作る\n $tmp_arr = [];\n foreach( $array as $element ) {\n if( array_key_exists('name', $element) ) {\n //'name'キーが存在する場合、同じ'name'値の配列の最後に付け足す\n $tmp_arr[$element['name']][] = $element;\n } else {\n //'name'キーが存在しない場合、1要素配列にして$tmp_arrの最後に付け足す\n $tmp_arr[] = [$element];\n }\n }\n var_dump($tmp_arr);\n /*\n `var_dump`の出力は見難いので、省略記法にするとこんな感じになる\n $tmp_arr = [\n 'いちご' => [['name'=>'いちご','id'=>'10'], ['name'=>'いちご','id'=>'60']],\n 0 => [['id'=>'13']],\n ’りんご' => [['name'=>'りんご','id'=>'20'], ['name'=>'りんご','id'=>'50']],\n 1 => [['id'=>'28']],\n 'みかん' => [['name'=>'みかん','id'=>'30']],\n ];\n */\n //array_mergeで再度結合\n //phpの配列は連想配列として使っても順序保存されることを利用している\n $array = call_user_func_array('array_merge', $tmp_arr);\n var_dump($array);\n \n```\n\nあなたの言い方で言えば三次元配列を中間結果として作成して、それをもう一度つなげなおしています。\n\n(今時5.3以前の古いPHPを使っている人は滅多にいないと思われるので、配列は省略記法にしてあります。)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T03:20:46.640", "id": "40734", "last_activity_date": "2018-01-05T05:58:07.477", "last_edit_date": "2018-01-05T05:58:07.477", "last_editor_user_id": "13972", "owner_user_id": "13972", "parent_id": "40708", "post_type": "answer", "score": 0 }, { "body": "配列の中で、その配列をidのみのものを最初に抜き出し、その後で元の配列の中から一つのnameをピックアップし、forループをしている時に同じnameがあれば新しい配列にいれて、元の配列からそのnameを含む配列を取り除く。forループし終わった後に、何もnameが見つかっていなければ、新しい配列にあらかじめ用意しておいたidのみの配列を加えるというやり方にしました。\n\n```\n\n <?php\n \n $array = array(\n array(\n 'name' => 'いちご',\n 'id' => '10'\n ),\n array(\n 'id' => '13'\n ),\n array(\n 'name' => 'りんご',\n 'id' => '20'\n ),\n array(\n 'id' => '28'\n ),\n array(\n 'name' => 'みかん',\n 'id' => '30'\n ),\n array(\n 'name' => 'りんご',\n 'id' => '50'\n ),\n array(\n 'name' => 'いちご',\n 'id' => '60'\n )\n );\n $arraylength = count($array);\n $result = array();//仮の結果。結果として三次元配列になる。\n $bararray = array();// idだけの配列を抜き出す。\n \n \n for ($j = 0; $j < $arraylength; $j++) {\n if (array_key_exists('id', $array[$j]) == true && array_key_exists('name', $array[$j]) != true) {\n $newarr = array();\n $newarr['id'] = $array[$j]['id'];\n array_push($bararray, $newarr);\n }\n }// idのみの配列を抜き出した。\n $j = 0;\n for ($i = 0; $i < $arraylength; $i++) {\n \n $newarr = array();\n for ($k = $i; $k < $arraylength; $k++) {\n if (array_key_exists('id', $array[$i]) == true && array_key_exists('name', $array[$i]) == true && array_key_exists('name', $array[$k]) == true && $array[$k]['name'] == $array[$i]['name']) {\n array_push($newarr, $array[$k]);\n if ($i != $k) {\n unset($array[$k]);\n $arraylength--;\n }\n ;\n }\n }\n \n if (!$newarr) {\n array_push($result, $bararray[$j]);\n $j++;\n } else {\n array_push($result, $newarr);\n }\n }//仮の結果、三次元配列はここまで\n \n $realresult = array();//求めたい結果\n $resultlength = count($result);\n for ($k = 0; $k < $resultlength; $k++) {\n $resultArraylength = count($result[$k]);\n if ($resultArraylength == 1) {\n if (is_array($result[$k]) == true && array_key_exists(0, $result[$k]) == false) {\n array_push($realresult, $result[$k]);\n } else {\n array_push($realresult, $result[$k]['0']);\n }\n \n } else {\n for ($m = 0; $m < $resultArraylength; $m++) {\n array_push($realresult, $result[$k][$m]);\n }\n }\n \n }\n print_r($realresult);\n ?>\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T06:19:50.423", "id": "40740", "last_activity_date": "2018-01-05T06:19:50.423", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25766", "parent_id": "40708", "post_type": "answer", "score": 0 } ]
40708
40734
40734
{ "accepted_answer_id": null, "answer_count": 3, "body": "Numpyで、n次元のランダムベクトルvを作りたいのですが、 \nベクトルの要素の総和がNになるようにしたいです。\n\n例えば、 \nn=4で、N=1ならば、`v = np.array([0.1, 0.3, 0.2, 0.4])` \nあるいは、 \nn=6で、N=3ならば、`v = np.array([0.3, 0.1, 1.2, 0.6, 0.5, 0.3])` \nというような感じです。\n\nこのようなことをNumpyで実現するにはどうすれば良いでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T06:30:54.137", "favorite_count": 0, "id": "40711", "last_activity_date": "2018-01-05T19:02:56.560", "last_edit_date": "2018-01-04T06:50:50.787", "last_editor_user_id": "19110", "owner_user_id": "25649", "post_type": "question", "score": 4, "tags": [ "python", "numpy" ], "title": "Numpyで、要素数の総和がNとなる制約の下、n次元のランダムベクトルを生成したい。", "view_count": 1173 }
[ { "body": "多少の誤差を気にしないのであれば、ひとまず `n` 個のランダムな数を生成した後、正規化すれば良いです。\n\n```\n\n >>> import numpy as np\n >>> n = 7\n >>> N = 3\n >>> random_numbers = np.random.rand(n)\n >>> print(random_numbers)\n [ 0.61444461 0.44538832 0.80188737 0.57265561 0.05225624 0.07613083\n 0.55669533]\n >>> print(np.sum(random_numbers))\n 3.11945832298\n >>> answer = N * random_numbers / np.sum(random_numbers)\n >>> print(answer)\n [ 0.59091472 0.42833237 0.77117943 0.55072601 0.05025511 0.07321543\n 0.53537692]\n >>> print(np.sum(answer))\n 3.0\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T06:50:33.653", "id": "40712", "last_activity_date": "2018-01-04T06:50:33.653", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "40711", "post_type": "answer", "score": 5 }, { "body": "他にもやり方がありそうですが、求めたい総和を乱数の範囲として、乱数をその範囲の上限と下限を除いたものの中から、n-2個出して、上限と下限を含むものに加えて小さい数から大きい数へソートした後、numpy.arrayに入っている小さい方から隣り合った項の差を加えていくと求めたい値が出るはずです。\n\n```\n\n import numpy as np, numpy.random\n // N = 3 総和を3とする、つまり以下では乱数が出る範囲を3とする. \n 以下では下限が0.0、上限が3.0。np.random.uniformは上限の値は出力しないはず。\n // n = 6 要素の数を 6つとする。\n values = numpy.array([0.0, N]);\n x = np.random.uniform(0.0, N,size= n-2);\n values = numpy.append(x, values);\n values.sort();\n print(values) \n // [ 0. 0.83087151 1.27426042 1.47701249 2.83517723 3. ] 0., 3.は0.0, 3.0のはず。repl.itによる。\n results = numpy.array([]);\n for i in range(1, 6):\n results = numpy.append(results, values[i] - values[i-1]);\n print(np.sum(results));\n // 3.0\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T08:02:03.487", "id": "40714", "last_activity_date": "2018-01-04T09:16:53.930", "last_edit_date": "2018-01-04T09:16:53.930", "last_editor_user_id": "25766", "owner_user_id": "25766", "parent_id": "40711", "post_type": "answer", "score": 2 }, { "body": "[SO英語版に同じ質問](https://stackoverflow.com/questions/18659858/generating-a-list-\nof-random-numbers-summing-to-1/18662466#18662466)がありました。\n\n```\n\n import numpy as np\n \n n = 7\n N = 3\n \n answer = np.random.dirichlet(np.ones(n)) * N\n \n print(\"n =\", answer.size)\n print(\"N =\", answer.sum())\n print(answer)\n \n```\n\n### 実行結果\n\n```\n\n n = 7\n N = 3.0\n [ 0.23253049 1.45542211 0.36459806 0.39199048 0.31374561 0.20020738\n 0.04150587]\n \n```\n\nnp.ones(n)に係数を掛けると乱数の分布を変えることもできるみたいです。詳しくは英語版をご覧ください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T18:39:10.817", "id": "40760", "last_activity_date": "2018-01-05T19:02:56.560", "last_edit_date": "2018-01-05T19:02:56.560", "last_editor_user_id": "7837", "owner_user_id": "7837", "parent_id": "40711", "post_type": "answer", "score": 4 } ]
40711
null
40712
{ "accepted_answer_id": "40730", "answer_count": 1, "body": "下の`IOPS=33.9k`はxfsでやると3354と表示されました。何度やっても10倍くらいの差になります。\n\nファイルシステムでそこまで変わるとは思えないので、フォーマットのやり方に問題があるのかもしれませんがこちらのとおりやってます。 \n<https://qiita.com/shiru/items/c765accff6d3c5f8ea34>\n\nただ、マウント時にxfsだと下のオプションが使えないのでそのまま`mount /dev/md0`とやっていますが、これが問題でしょうか?\n\nXFS \nmount /dev/md0 /media/ephemeral0\n\nEXT4 \nmount -o rw,relatime,errors=continue,user_xattr,acl,barrier=1,data=ordered\n/dev/md0 /media/ephemeral0\n\n> fio -name=random-write -ioengine=libaio -rw=randrw -rwmixread=0 -bs=16k\n> -numjobs=16 -iodepth=16 -size=100m -direct=1 -directory=/media/ephemeral0\n> -group_reporting \n> random-write: (g=0): rw=randrw, bs=(R) 16.0KiB-16.0KiB, (W)\n> 16.0KiB-16.0KiB, (T) 16.0KiB-16.0KiB, ioengine=libaio, iodepth=16 \n> ... \n> fio-3.3 \n> Starting 16 processes \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> random-write: Laying out IO file (1 file / 100MiB) \n> Jobs: 1 (f=1): [w(1),_(15)][100.0%][r=0KiB/s,w=502MiB/s][r=0,w=32.1k\n> IOPS][eta 00m:00s] \n> random-write: (groupid=0, jobs=16): err= 0: pid=6855: Thu Jan 4 08:26:29\n> 2018 \n> write: IOPS=33.9k, BW=529MiB/s (555MB/s)(1600MiB/3022msec) \n> slat (usec): min=3, max=27676, avg=253.30, stdev=1452.90 \n> clat (usec): min=89, max=64093, avg=7102.46, stdev=5838.76 \n> lat (usec): min=141, max=64104, avg=7356.88, stdev=6093.65 \n> clat percentiles (usec): \n> | 1.00th=[ 157], 5.00th=[ 219], 10.00th=[ 318], 20.00th=[ 750], \n> | 30.00th=[ 3359], 40.00th=[ 5276], 50.00th=[ 6456], 60.00th=[ 7898], \n> | 70.00th=[ 9372], 80.00th=[11469], 90.00th=[15008], 95.00th=[17433], \n> | 99.00th=[23200], 99.50th=[27132], 99.90th=[43779], 99.95th=[47973], \n> | 99.99th=[54789] \n> bw ( KiB/s): min=22176, max=52544, per=6.54%, avg=35470.31, stdev=4276.22,\n> samples=81 \n> iops : min= 1386, max= 3284, avg=2216.56, stdev=267.30, samples=81 \n> lat (usec) : 100=0.01%, 250=6.73%, 500=9.79%, 750=3.48%, 1000=1.71% \n> lat (msec) : 2=3.19%, 4=7.53%, 10=41.29%, 20=24.05%, 50=2.18% \n> lat (msec) : 100=0.04% \n> cpu : usr=1.68%, sys=5.76%, ctx=20890, majf=0, minf=514 \n> IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=99.8%, 32=0.0%, >=64=0.0% \n> submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% \n> complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.1%, 32=0.0%, 64=0.0%, >=64=0.0% \n> issued rwt: total=0,102400,0, short=0,0,0, dropped=0,0,0 \n> latency : target=0, window=0, percentile=100.00%, depth=16\n\nRun status group 0 (all jobs): \nWRITE: bw=529MiB/s (555MB/s), 529MiB/s-529MiB/s (555MB/s-555MB/s), io=1600MiB\n(1678MB), run=3022-3022msec\n\nDisk stats (read/write): \nmd0: ios=0/96376, merge=0/0, ticks=0/0, in_queue=0, util=0.00%,\naggrios=0/49418, aggrmerge=0/1797, aggrticks=0/229064, aggrin_queue=229245,\naggrutil=82.68% \nxvdb: ios=0/50290, merge=0/926, ticks=0/307177, in_queue=307422, util=81.91% \nxvdc: ios=0/48546, merge=0/2669, ticks=0/150951, in_queue=151069, util=82.68%", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T08:35:57.733", "favorite_count": 0, "id": "40715", "last_activity_date": "2018-01-05T00:21:57.630", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7973", "post_type": "question", "score": 0, "tags": [ "linux", "centos", "aws", "filesystems" ], "title": "ファイルシステムext4とxfsのIOPSの差が10倍", "view_count": 4979 }
[ { "body": "ファイルシステムの **デフォルトチューニング** の性能比較であれば結果の通りでしょう。\n\n**ファイルシステム自体**\nの性能比較であれば、適切にチューニングを行わなければ意味がありません。わかりやすい値としてブロックサイズを適切に設定する必要があります。EXT4は[tune2fs](https://linuxjm.osdn.jp/html/e2fsprogs/man8/tune2fs.8.html)、XFSは[xfs_info](https://linux.die.net/man/8/xfs_info)で各パラメーターを確認できます。ベンチマークが`-bs=16k`とのことなので、どちらのファイルシステムも16kにすべきでしょう。\n\nなお、XFSはジャーナルログを別デバイスに設定できます。パフォーマンスを求めるのであれば別ディスク(≠別パーティション)に設定すべきでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T00:21:57.630", "id": "40730", "last_activity_date": "2018-01-05T00:21:57.630", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "40715", "post_type": "answer", "score": 4 } ]
40715
40730
40730
{ "accepted_answer_id": null, "answer_count": 1, "body": "動画認識に挑戦している初心者です。環境はUbuntu 16.04LTSを使用しています。 \n以下のサイトに記載されているように、CUDA、OpenCV、Darknetをそれぞれインストールし、mp4ファイルを指定してコード実行したのですが、エラーがでてしまいました。 \n何か解決方法はありますでしょうか。よろしくお願いします。\n\n<https://pjreddie.com/darknet/yolo/>\n\n```\n\n $ ./darknet detect cfg/yolo.cfg yolo.weights data/videoplayback.mp4\n layer filters size input output\n 0 conv 32 3 x 3 / 1 608 x 608 x 3 -> 608 x 608 x 32\n 1 max 2 x 2 / 2 608 x 608 x 32 -> 304 x 304 x 32\n 2 conv 64 3 x 3 / 1 304 x 304 x 32 -> 304 x 304 x 64\n 3 max 2 x 2 / 2 304 x 304 x 64 -> 152 x 152 x 64\n \n 省略\n \n 29 conv 1024 3 x 3 / 1 19 x 19 x1280 -> 19 x 19 x1024\n 30 conv 425 1 x 1 / 1 19 x 19 x1024 -> 19 x 19 x 425\n 31 detection\n mask_scale: Using default '1.000000'\n Loading weights from yolo.weights...Done!\n Cannot load image \"data/videoplayback.mp4\"\n STB Reason: can't fopen\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T09:08:58.210", "favorite_count": 0, "id": "40716", "last_activity_date": "2018-01-05T09:51:03.407", "last_edit_date": "2018-01-04T11:49:51.420", "last_editor_user_id": "3068", "owner_user_id": "26879", "post_type": "question", "score": 0, "tags": [ "python", "c", "ubuntu", "opencv" ], "title": "Darknet yolov2を使用した動画認識の質問", "view_count": 1168 }
[ { "body": "このコマンドを試してみてください(コマンド最後は自分の動画の場所) \n./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights video_file", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T09:45:12.733", "id": "40752", "last_activity_date": "2018-01-05T09:51:03.407", "last_edit_date": "2018-01-05T09:51:03.407", "last_editor_user_id": "26893", "owner_user_id": "26893", "parent_id": "40716", "post_type": "answer", "score": -1 } ]
40716
null
40752
{ "accepted_answer_id": "40729", "answer_count": 2, "body": "超初心者っぽい質問で申し訳ありません。 \n先日WindowsServer2012R2にApache2.4をインストールすることに成功しました。インターネットの記事、<https://techacademy.jp/magazine/1846>\nを参考に行い \n特別なインストーラ(msi)を実行したわけではなく、ただ単にzipを解凍として該当サービスを登録した感じです...\n\n====質問==== \nインターネット上の別の記事で、Windows版というものがあり、そちらに従ったインストールを行えば、サービスの起動・停止を行うユーティリティが同梱されている雰囲気に受けてとれます。 \n当方は先に記載した方法でインストールを行ったからか、サービスの停止・起動を行う際に \nWindowsの管理ツール/サービスメニュから指示をしなければならない状況です。\n\n皆様 同様なのでしょうか?簡易にワンタッチで行うことはできないのでしょうか?該当コマンド(httpd -k\nstart)のbatファイルを自分で作っておく、というのが常識なら それはそれで納得しますが、皆がそうしているのかな??と思ったわけで\n\nお手すきの方 よろしくお願い申し上げます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T10:11:37.283", "favorite_count": 0, "id": "40719", "last_activity_date": "2018-01-04T21:03:53.577", "last_edit_date": "2018-01-04T12:15:56.577", "last_editor_user_id": "3060", "owner_user_id": "25696", "post_type": "question", "score": 0, "tags": [ "apache" ], "title": "Apacheのサービス起動・停止・再起動を簡易にしたい", "view_count": 1050 }
[ { "body": "webサーバの使用目的や運用ルールにもよりますが、サーバ(サービス)類は基本的に一度起動させたら滅多なことでは停止しませんし、再起動もApacheの場合ならhttpd.confなどの設定ファイルを変更した時のみでしょう。 \nWindowsのサービスとして登録したのであれば、管理ツールからApacheのサービスを「自動起動」にしておけば手動で立ち上げる必要はありません(OS起動時にバックグラウンドで勝手に立ち上がる)。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T15:58:13.683", "id": "40726", "last_activity_date": "2018-01-04T15:58:13.683", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "40719", "post_type": "answer", "score": 1 }, { "body": "> サービスの起動・停止を行うユーティリティが同梱されている\n\nこれは、タスクトレイに常駐する **Apache Service Monitor** のことかと思われます。 \n提示されているURLから取得したバイナリでは、下記のものが該当します。\n\nApache24\\bin\\ApacheMonitor.exe\n\nオフィシャルドキュメントでの言及は下記リンク先くらいしか見つけられませんでしたが、使用法については、ファイル名 \"ApacheMonitor.exe\"\nで検索すれば日本語で解説されている方々のサイトもヒットするかと思います。\n\n * [Running Apache as a Service : Using Apache HTTP Server on Microsoft Windows - Apache HTTP Server Version 2.4 ](https://httpd.apache.org/docs/2.4/platform/windows.html#winsvc)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T21:03:53.577", "id": "40729", "last_activity_date": "2018-01-04T21:03:53.577", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2808", "parent_id": "40719", "post_type": "answer", "score": 1 } ]
40719
40729
40726
{ "accepted_answer_id": null, "answer_count": 0, "body": "こんにちは。はじめまして。\n\nxcode 7.3、swift 2.2, cocoapods 1.0.0.beta.2 環境でプロジェクトを進めてきています。 \nライブラリが正しくプロパティからデータが取得されないのなぜでしょうか。 \n(参照:<http://webfood.info/swift-rss-reader/>)\n\n実装後、メニューバーにはタイトルが表示されるものの、 \nウェブデーターが表示されず困っています。\n\nご参考までにコードを表記します。\n\nTableViewController.swiftのコードはimportとプロパティを追加しています。\n\n```\n\n```\n\n import UIKit\n import Alamofire\n import SwiftyJSON\n \n \n class TableViewController: UITableViewController {\n \n var fetchFrom: String?\n var parent: UIViewController?\n \n override func viewDidLoad() {\n super.viewDidLoad()\n Alamofire.request(.GET, fetchFrom!).responseJSON { response in\n if let values = response.result.value {\n JSON(values)[\"responseData\"][\"feed\"][\"entries\"].forEach {i,value in\n print(value[\"title\"].string!)\n print(value[\"link\"].string!)\n }\n }\n }\n }\n \n ```\n \n```\n\nViewController.swiftのコードは、\n\n```\n\n import UIKit\n import PageMenu\n \n class ViewController: UIViewController {\n \n var pageMenu : CAPSPageMenu?\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n var controllers : [UIViewController] = []\n \n var feeds: [Dictionary<String, String>] =\n [\n [\n \"link\": \"https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://menthas.com/top/rss\",\n \"title\": \"top\"\n ],\n [\n \"link\": \"https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://menthas.com/ruby/rss\",\n \"title\": \"ruby\"\n ],\n [\n \"link\": \"https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://menthas.com/ios/rss\",\n \"title\": \"ios\"\n ],\n [\n \"link\": \"https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://menthas.com/infrastructure/rss\",\n \"title\": \"infrastructure\"\n ],\n ]\n for feed in feeds\n {\n let feedController = TableViewController(nibName: \"TableViewController\", bundle: nil)\n feedController.parent = self\n feedController.fetchFrom = feed[\"link\"]!\n feedController.title = feed[\"title\"]\n controllers.append(feedController)\n }\n \n```\n\nとなっており。\n\nPodfileは下記です。\n\n```\n\n source 'https://github.com/CocoaPods/Specs.git'\n use_frameworks!\n platform :ios, '9.3'\n \n target 'RSSReaderApp' do\n pod 'PageMenu', '1.2.9'\n pod 'Alamofire', '3.3.1'\n pod 'SwiftyJSON', '2.3.2'\n \n end\n \n```\n\nビルド後は成功するものの、データが表示されません。 \nPageMenuはうまく活用されているように思われます。AlamofireかSwiftyJSONに問題があるのだと思います。\n\nRSSデータの取得元は、<http://menthas.com/> というサイトです。 \nAPIにうまく通されていないからでしょうか?\n\nこちらから確認できません。 \n<https://github.com/tarky/RssReaderApp/tree/connect-api>\n\n何か心当たりがあればご共有ください。 \nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T12:45:39.653", "favorite_count": 0, "id": "40722", "last_activity_date": "2018-01-05T07:44:42.183", "last_edit_date": "2018-01-04T15:52:58.207", "last_editor_user_id": "76", "owner_user_id": "21007", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "SwiftyJSONによるデータ表示コードについて知りたい。", "view_count": 91 }
[]
40722
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "# 環境説明\n\npymediainfoはメディアファイル解析ツールであるmediainfoのpythonラッパーです。\n\nWindows10環境にmediaInfoをインストール行い、pycharmを利用してpymdeiainfoのパッケージをインストールをした上で下記コードを実行しました。\n\nWelcome to pymediainfo’s documentation! \n<https://pymediainfo.readthedocs.io/en/latest/>\n\n# 実行コード\n\n```\n\n from pymediainfo import MediaInfo\n media_info = MediaInfo.parse('指定の動画ファイルパス')\n for track in media_info.tracks:\n if track.track_type == 'Video':\n print track.bit_rate, track.bit_rate_mode, track.codec\n \n```\n\n# エラー文\n\n```\n\n Traceback (most recent call last):\n File \"ディレクトリパス/script.py\", line 110, in <module>\n media_info = MediaInfo.parse(filepath)\n File \"C:\\Python34\\lib\\site-packages\\pymediainfo\\__init__.py\", line 176, in parse\n lib = cls._get_library(library_file)\n File \"C:\\Python34\\lib\\site-packages\\pymediainfo\\__init__.py\", line 142, in _get_library\n return windll.MediaInfo\n File \"C:\\Python34\\lib\\ctypes\\__init__.py\", line 421, in __getattr__\n dll = self._dlltype(name)\n File \"C:\\Python34\\lib\\ctypes\\__init__.py\", line 351, in __init__\n self._handle = _dlopen(self._name, mode)\n OSError: [WinError 126] 指定されたモジュールが見つかりません。\n \n Process finished with exit code 1\n \n```\n\n# 問題点\n\n下記リンクを見てみると、似たような問題の方がいます。 \n恐らくmediainfo.dllが読み込まれていない事が原因だと思うのですが、対処方法が不明です。 \nおわかりの方がいれば教えていただきたいです。\n\n<https://stackoverflow.com/questions/36453900/python-pymediainfo-module-\nerror-126-the-specified-module-could-not-be-found>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T14:37:16.903", "favorite_count": 0, "id": "40724", "last_activity_date": "2018-01-04T14:37:16.903", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "13969", "post_type": "question", "score": 0, "tags": [ "python", "windows" ], "title": "pymediainfoが利用できずエラーが発生する", "view_count": 1161 }
[]
40724
null
null
{ "accepted_answer_id": "40803", "answer_count": 1, "body": "flex itemの中の文字をitemの幅に合わせて折り返すにはどうしたら良いでしょうか?\n\n```\n\n word-wrap: break-word;\n \n```\n\nだとうまくいきません。\n\n```\n\n .container {\r\n display: flex;\r\n flex-wrap: wrap;\r\n }\r\n \r\n .item {\r\n background-color: skyblue;\r\n height: 150px;\r\n width: 150px;\r\n margin: 3px;\r\n \r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n }\n```\n\n```\n\n <div class=\"container\">\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n <div class=\"item\"><a href=\"https://www.yahoo.co.jp/\" >https://www.yahoo.co.jp/</a></div>\r\n </div>\n```\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/cuZ2e.png)](https://i.stack.imgur.com/cuZ2e.png)\n\n青い四角:flex container \nリンク:flex item\n\nとなっています。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-04T15:24:44.687", "favorite_count": 0, "id": "40725", "last_activity_date": "2018-01-08T00:50:51.040", "last_edit_date": "2018-01-04T19:23:51.980", "last_editor_user_id": "3068", "owner_user_id": "12297", "post_type": "question", "score": 0, "tags": [ "css" ], "title": "flex itemの中の文字をitemの幅に合わせて折り返すにはどうしたら良いでしょうか?", "view_count": 755 }
[ { "body": "親要素を\n\n```\n\n display:grid\n \n```\n\nとするとできました!\n\nありがとうございました!", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T00:50:51.040", "id": "40803", "last_activity_date": "2018-01-08T00:50:51.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12297", "parent_id": "40725", "post_type": "answer", "score": 0 } ]
40725
40803
40803
{ "accepted_answer_id": null, "answer_count": 1, "body": "findにて繰り返しデータを取得し、データを追加していくにはどのようにすべきでしょうか。 \nちょっと文字では伝えにくく、下記に例を添付します。 \n(jqueryのajaxにより、JSONを返すような内容です。)\n\n1回目格納時に$aaaはobject型で[{...},{...}]となりますが、 \n下記のようにarray_pushすると、[{...},{...}][{...},{...},{...}]となります。 \n[{...},{...},{...},{...},{...}]のように追加するにはどのようにしたら良いでしょうか? \n※一度に取得するのでなく、分けて取得している理由は、データが膨大で、メモリが高くなり、 \nエラーとなる為です。(例は全5件ですが、実際は何万と取得することがあります)\n\n```\n\n //1回目\n $query = $this->Lists->find();\n $lists = $query->limit(2)->offset(0);\n \n $response = $this->response; \n $response->getBody()->write(json_encode($list1s));\n \n //変数に格納\n $aaa = $response;\n \n //2回目\n $list1s = $query->limit(3)->offset(2);\n $response = $this->response;\n $response->getBody()->write(json_encode($list1s));\n \n //データを変数に追加\n array_push($aaa, $response);\n \n return $aaa;\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T02:32:07.950", "favorite_count": 0, "id": "40732", "last_activity_date": "2020-03-27T04:04:25.803", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26840", "post_type": "question", "score": 0, "tags": [ "php", "cakephp" ], "title": "cakephp3 オブジェクト型へのデータ追加について", "view_count": 423 }
[ { "body": "lists → jsonエンコード → responseへjsonを書き込み とやっているわけですから \nlists ← jsonデコード ← responseからjsonを読み出し としないと、筋が通りません。\n\n何かの理由で処理を調整できないなら、上記のように必要なものを取り出してください。 \n1関数内の話なら、lists同士を直接繋げるのが一番手っ取り早いです。\n\nちなみにサンプルコードは不自然にlistsやlist1sになってたりするので、 \nそこら辺の凡ミスもないか確認しましょう。\n\nまた細かい話ですが、listsで名前が妥当かも検討しましょう。 \nこれだとlistのコレクション、というニュアンス、つまりコレクションのコレクション、 \nとなります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-16T07:55:58.723", "id": "41005", "last_activity_date": "2018-01-16T07:55:58.723", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "25396", "parent_id": "40732", "post_type": "answer", "score": 1 } ]
40732
null
41005
{ "accepted_answer_id": null, "answer_count": 1, "body": "Webアプリケーションを作成しているのですが、moduleの戻り値の設計についてどうすれば良いのか悩んでいます。\n\n「usersモデルのuser_nameを更新する」という単純なmoduleを作成することを例にしてみます。\n\n```\n\n module UserNameUpdate\n def update(user, user_name)\n if user.blank?\n return xxx\n end\n \n if user_name.blank?\n return xxx\n end\n \n user.update!(user_name: user_name)\n end\n end\n \n```\n\n引数がnilでないことや、必要であれば型もチェックするかもしれません。 \nhashで返してみることやstringで返すことも考えてみましたが、奥が深くて指針となるようなドキュメントを読んでみたいです。\n\n```\n\n module UserNameUpdate\n def update(user, user_name)\n hash = {\n code: 1,\n message: nil\n }\n \n if user.blank?\n hash['message'] = '引数のmessageがnilです'\n return hash\n end\n \n if user_name.blank?\n hash['message'] = '引数のuser_nameがnilです'\n return hash\n end\n \n user.update!(user_name: user_name)\n end\n end\n \n```\n\n戻り値はどう設計するのがベストでしょうか。Ruby/Railsに関係なく普遍的な問題かと思っていますので、言語/FWは特に限定はしないです。 \nドキュメントや良いアイディアがあれば教えていただけますでしょうか。\n\nあと、タグって何を付けるのが適切ですかね。。それっぽいタグが無く。。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T03:14:24.100", "favorite_count": 0, "id": "40733", "last_activity_date": "2018-01-05T05:40:52.247", "last_edit_date": "2018-01-05T05:40:52.247", "last_editor_user_id": "754", "owner_user_id": "26885", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails", "プログラミング言語", "詳細設計" ], "title": "モジュールの戻り値の設計について", "view_count": 107 }
[ { "body": "@shingo.nakanishi\nさんも仰っていますが、言語・FW(が提供する機能)によって、適切な設計は変わってくると思います。おそらく、最終的に質問者様が知りたいのは、 rails\nにおいて今回の機能を実装する場合の正しい(たしからしい)方法は何か、だと思っています。\n\nその前提で回答をすると、今回はカラムの値チェックがほぼなので、 [rails tutorial にある active record\nvalidation](https://railsguides.jp/active_record_validations.html) に従うのが、\nrails 的な実装なのではないかと思います。\n\n抜粋して説明してみますと、カラムに対する値チェックならば、\n\n```\n\n class Person < ActiveRecord::Base\n validates :name, presence: true\n end\n \n```\n\nのように宣言的に記述することが可能です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T05:39:58.767", "id": "40736", "last_activity_date": "2018-01-05T05:39:58.767", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "40733", "post_type": "answer", "score": 0 } ]
40733
null
40736
{ "accepted_answer_id": null, "answer_count": 0, "body": "C++の数値計算ライブラリEigenに含まれる、非線形最小二乗法(Levenberg-Marquardt法)で関数フィッティングを実行してみました \n開発環境はVisual Studio 2015です \nフィッティング対象の関数は、y = a×cos(x)^b で、ノイズを含む観測データx,yからパラメータa,bを求めます\n\n```\n\n #include <iostream>\n #include <vector>\n #include <fstream>\n #include <string>\n #include <random>\n #define _USE_MATH_DEFINES\n #include <cmath>\n \n #include <Eigen/Dense>\n #include <unsupported/Eigen/NonLinearOptimization>\n #include <unsupported/Eigen/NumericalDiff>\n \n using namespace std;\n using namespace Eigen;\n \n template<typename _Scalar, int NX = Dynamic, int NY = Dynamic>\n struct Functor\n {\n typedef _Scalar Scalar;\n enum {\n InputsAtCompileTime = NX,\n ValuesAtCompileTime = NY\n };\n typedef Matrix<Scalar, InputsAtCompileTime, 1> InputType;\n typedef Matrix<Scalar, ValuesAtCompileTime, 1> ValueType;\n typedef Matrix<Scalar, ValuesAtCompileTime, InputsAtCompileTime> JacobianType;\n };\n \n struct myFunctor : Functor<double> {\n myFunctor(int inputs, int values, double*x, double*y)\n : inputs_(inputs), values_(values), x(x), y(y) {}\n \n double *x, *y;\n \n int operator()(const VectorXd &b, VectorXd &fvec) const {\n // 目的関数\n for (int i = 0; i < values_; i++) {\n fvec[i] = (b[0] * pow(cos(x[i]), b[1])) - y[i];\n }\n return 0;\n }\n \n const int inputs_;\n const int values_;\n int inputs() const { return inputs_; }\n int values() const { return values_; }\n };\n \n void showLMStatus(int);\n void writeDatas(vector<double> &x, vector<double> &y);\n \n int main()\n {\n const int seed = 20; // 乱数生成シード値\n const int dataSize = 60; // データ数\n \n vector<double> x(dataSize), y(dataSize);\n \n const double ans[] = { 0.2, 100 }; // 真のパラメータ\n \n mt19937 mt(seed);\n // xデータをランダムに生成\n uniform_real_distribution<double> x_rand(-M_PI / 2.0, M_PI / 2.0);\n // x,yそれぞれの(正規分布に従う)ノイズを生成\n normal_distribution<double> x_noise(0.0, M_PI / 90.0);\n normal_distribution<double> y_noise(0.0, 0.01);\n \n for (int i = 0; i < dataSize; i++) {\n // 真値\n x[i] = x_rand(mt);\n y[i] = ans[0] * pow(cos(x[i]), ans[1]);\n \n // ノイズを加える\n x[i] += x_noise(mt);\n y[i] += y_noise(mt);\n }\n \n // データの保存\n writeDatas(x, y);\n \n VectorXd p(2);\n p(0) = 0.6;\n p(1) = 30;\n \n myFunctor functor(2, dataSize, &x[0], &y[0]);\n \n NumericalDiff<myFunctor> numDiff(functor);\n LevenbergMarquardt<NumericalDiff<myFunctor> > lm(numDiff);\n lm.parameters.maxfev = (dataSize + 1) * 100; // max function evaluation\n \n int info = lm.minimize(p);\n showLMStatus(info);\n \n cout << p[0] << \", \" << p[1] << endl;\n }\n \n void showLMStatus(int info)\n {\n string status;\n switch (info) {\n case 0:\n status = \"ImproperInputParameters\";\n break;\n case 1:\n status = \"RelativeReductionTooSmall\";\n break;\n case 2:\n status = \"RelativeErrorTooSmall\";\n break;\n case 3:\n status = \"RelativeErrorAndReductionTooSmall\";\n break;\n case 4:\n status = \"CosinusTooSmall\";\n break;\n case 5:\n status = \"TooManyFunctionEvaluation\";\n break;\n case 6:\n status = \"FtolTooSmall\";\n break;\n case 7:\n status = \"XtolTooSmall\";\n case 8:\n status = \"GtolTooSmall\";\n break;\n case 9:\n status = \"UserAsked\";\n break;\n default:\n status = \"Unknown\";\n break;\n }\n \n cout << status << endl;\n }\n \n void writeDatas(vector<double> &x, vector<double> &y) {\n ofstream outputFile(\"./output1.txt\");\n \n for (int i = 0; i < x.size(); i++) {\n outputFile << x[i] << \"\\t\" << y[i] << endl;\n }\n \n outputFile.close();\n }\n \n```\n\n実行結果は以下のようになりました\n\n```\n\n TooManyFunctionEvaluation\n 0.6, 30\n \n```\n\n収束しておらずパラメータも初期値のままなので、うまくいっていない様子です \nしかし、Gnuplot(version\n4.6)のfitコマンドを用いて同じデータ(保存した\"output1.txt\")でフィッティングを行ったところ、収束をし、パラメータも真値に近づきました\n\n```\n\n gnuplot> f(x) = a * cos(x)**b\n gnuplot> a = 0.6\n gnuplot> b = 30\n gnuplot> fit f(x) \"output1.txt\" via a, b\n \n \n Iteration 0\n WSSR : 1.32176 delta(WSSR) / WSSR : 0\n delta(WSSR) : 0 limit for stopping : 1e-005\n lambda : 0.217494\n \n initial set of free parameter values\n \n a = 0.6\n b = 30\n /\n \n Iteration 1\n WSSR : 0.0219191 delta(WSSR) / WSSR : -59.302\n delta(WSSR) : -1.29984 limit for stopping : 1e-005\n lambda : 0.0217494\n \n resultant parameter values\n \n a = 0.125571\n b = 30.0348\n /\n \n Iteration 2\n WSSR : 0.0214163 delta(WSSR) / WSSR : -0.0234765\n delta(WSSR) : -0.000502779 limit for stopping : 1e-005\n lambda : 0.00217494\n \n resultant parameter values\n \n a = 0.122193\n b = 30.7021\n /\n \n Iteration 3\n WSSR : 0.0124169 delta(WSSR) / WSSR : -0.724764\n delta(WSSR) : -0.00899934 limit for stopping : 1e-005\n lambda : 0.000217494\n \n resultant parameter values\n \n a = 0.146067\n b = 54.2227\n /\n \n Iteration 4\n WSSR : 0.00728884 delta(WSSR) / WSSR : -0.703554\n delta(WSSR) : -0.00512809 limit for stopping : 1e-005\n lambda : 2.17494e-005\n \n resultant parameter values\n \n a = 0.185555\n b = 95.4605\n /\n \n Iteration 5\n WSSR : 0.00708739 delta(WSSR) / WSSR : -0.028424\n delta(WSSR) : -0.000201452 limit for stopping : 1e-005\n lambda : 2.17494e-006\n \n resultant parameter values\n \n a = 0.196069\n b = 106.342\n /\n \n Iteration 6\n WSSR : 0.00708611 delta(WSSR) / WSSR : -0.000180134\n delta(WSSR) : -1.27645e-006 limit for stopping : 1e-005\n lambda : 2.17494e-007\n \n resultant parameter values\n \n a = 0.196878\n b = 107.308\n /\n \n Iteration 7\n WSSR : 0.00708611 delta(WSSR) / WSSR : -6.06245e-007\n delta(WSSR) : -4.29592e-009 limit for stopping : 1e-005\n lambda : 2.17494e-008\n \n resultant parameter values\n \n a = 0.196921\n b = 107.368\n \n After 7 iterations the fit converged.\n final sum of squares of residuals : 0.00708611\n rel.change during last iteration : -6.06245e-007\n \n degrees of freedom(FIT_NDF) : 58\n rms of residuals(FIT_STDFIT) = sqrt(WSSR / ndf) : 0.0110532\n variance of residuals(reduced chisquare) = WSSR / ndf : 0.000122174\n \n Final set of parameters Asymptotic Standard Error\n == == == == == == == == == == == = == == == == == == == == == == == == ==\n \n a = 0.196921 + / -0.009823 (4.988%)\n b = 107.368 + / -9.945 (9.263%)\n \n \n correlation matrix of the fit parameters :\n \n a b\n a 1.000\n b 0.708 1.000 \n \n```\n\n調べたところ、GnuplotのfitコマンドはLevenberg-\nMarquardt法を用いているようなので、EigenとGnuplotでフィッティングがうまくいく場合といかない場合があるのはなぜでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T06:12:01.883", "favorite_count": 0, "id": "40738", "last_activity_date": "2018-01-05T09:17:58.450", "last_edit_date": "2018-01-05T09:17:58.450", "last_editor_user_id": "4236", "owner_user_id": "26888", "post_type": "question", "score": 1, "tags": [ "c++", "アルゴリズム" ], "title": "Levenberg-Marquardt法の結果がEigenとGnuplotで異なるのはなぜでしょうか", "view_count": 1636 }
[]
40738
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "macOS Sierra バージョン 10.12.6 \nXcode Version 9.2(9C40b) \nの環境です。初めてBitbucketで作成したrepositoryにXcodeからremote pushしたいと思っています。\n\nXcodeのsource control navigatorによりRemotes Repositoryを登録できました。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/eFCl9.png)](https://i.stack.imgur.com/eFCl9.png) \nRemotes\nRepositoryはBitbuket(Git)です。もちろんBitbuketの自分のアカウントでもRepositoryを作成しています。README.mdもBitbuketのサイトで作成しています。\n\nその状態で、BitbuketリポジトリにPushした所、 \n[![画像の説明をここに入力](https://i.stack.imgur.com/WYwzT.png)](https://i.stack.imgur.com/WYwzT.png) \nのようにまずRomote repositoryからPullしなさいとメッセージが表示されました。 \n次にPullを行うと、 \n[![画像の説明をここに入力](https://i.stack.imgur.com/dpwJv.png)](https://i.stack.imgur.com/dpwJv.png) \nのようにエラーが発生します。\n\nサイトを検索すると、 \nmergeのオプションに「--allow-unrelated-\nhistories」を付けて無関係なヒストリを持つブランチをマージする必要があるようですが、Xcodeでは同様の処理を行う部分が見つかりません。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/5DzAY.png)](https://i.stack.imgur.com/5DzAY.png)\n\nどのように対処すればいいかご存知の方はご教示お願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T06:12:54.773", "favorite_count": 0, "id": "40739", "last_activity_date": "2018-01-05T06:12:54.773", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8593", "post_type": "question", "score": 0, "tags": [ "xcode", "git", "bitbucket" ], "title": "Xcodeから初めてBitbuketリポジトリにpushしたらエラー", "view_count": 202 }
[]
40739
null
null
{ "accepted_answer_id": "40762", "answer_count": 1, "body": "GoogleCloudDatastoreにおいて \nデータが大量に入っているとあるテーブル(kind)を削除したいと思っておりますが \ndelete()やdeleteMulti()を使うと速度的な懸念があるとともに \ndeleteのoperation数も大量に発生するのでGCPへの課金も発生するかと思います。\n\n他のデータベースにあるようにとあるKindのデータをすべてtruncateできるような方法はdatastoreにありますでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T06:53:07.453", "favorite_count": 0, "id": "40741", "last_activity_date": "2018-01-05T23:20:23.777", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "23189", "post_type": "question", "score": 0, "tags": [ "google-app-engine", "google-cloud" ], "title": "google cloud datastoreにおけるtruncate", "view_count": 241 }
[ { "body": "いいえ、Datastoreにはtruncateの機能はないので、KindのEntityをすべて削除する場合はDeleteOpesが発生します。\n\nKindのEntityをすべて削除する場合は\n<https://cloud.google.com/appengine/docs/standard/java/console/datastore-\nbacking-up-restoring> を利用すると楽です。 \nドキュメントにはbackupとrestoreのことが書いてありますが、deleteの機能もあります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T23:20:23.777", "id": "40762", "last_activity_date": "2018-01-05T23:20:23.777", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4361", "parent_id": "40741", "post_type": "answer", "score": 1 } ]
40741
40762
40762
{ "accepted_answer_id": null, "answer_count": 2, "body": "大変漠然とした質問で恐縮なのですが、 \n只今Raspberry Pi3(OS:Raspbian 8.0)でネットワーク周りのステータスを調べています。 \n有線NICであるeth0が使用可能になった際、 \nどこのディレクトリの値が変化するのか...というのが質問の内容です。\n\n/proc/sys/netあたりを参照していますが、いまいちピンと来ていません。 \nこのあたりではないかという意見をいただければ幸いです。 \nご教授よろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T07:17:43.937", "favorite_count": 0, "id": "40742", "last_activity_date": "2018-01-05T07:51:16.900", "last_edit_date": "2018-01-05T07:21:03.437", "last_editor_user_id": "76", "owner_user_id": "26890", "post_type": "question", "score": 0, "tags": [ "raspberry-pi", "raspbian" ], "title": "/proc/sys/net... リンクアップ確認", "view_count": 300 }
[ { "body": "このコマンドで何か返って来ればeth0デバイスがUPと言うことになります。\n\n```\n\n ip link show eth0 up\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T07:25:45.823", "id": "40743", "last_activity_date": "2018-01-05T07:25:45.823", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7837", "parent_id": "40742", "post_type": "answer", "score": 0 }, { "body": "敢えて`/proc`以下で確認をしたいという事であれば、`/proc/net/dev`にNIC毎の転送量が記録されているので、こちらの数値を参照するというのはどうでしょうか。\n\n```\n\n > cat /proc/net/dev\n Inter-| Receive | Transmit\n face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed\n lo: 2530 142 0 0 0 0 0 0 2530 142 0 0 0 0 0 0\n eth0: 4730 118 0 33 0 12 0 48 2883 11 0 0 0 0 0 0\n eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T07:51:16.900", "id": "40746", "last_activity_date": "2018-01-05T07:51:16.900", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "40742", "post_type": "answer", "score": 1 } ]
40742
null
40746
{ "accepted_answer_id": null, "answer_count": 0, "body": "子供向けのアプリを製作し、AdMobで収益化を図ろうとしたのですが、 \n子供向けフラグを立ててアプリをAppleの審査に提出したところ、\n\nGuideline 1.3 - Safety - Kids Category \n(ガイドライン1.3 - 安全性 - キッズカテゴリー)\n\nの部分で審査を却下されました。 \n要約すると以下のようなものです。\n\n1、子供向けに不適切なコンテンツを表示する広告がアプリに含まれています。 \n2、タップすると、ユーザーをWebページやApp Storeに誘導する広告が含まれています。\n\nどうやら子供向けとして配信する必要があるようでした。 \nそこで、下記のページを参考にして、子供向けタグの設定を行いました。\n\n<https://support.google.com/admob/answer/6219315?hl=ja>\n\n```\n\n let request = GADRequest()\n var components = DateComponents()\n let time = timeGetYear() //現在の年(2018)\n components.month = 1\n components.day = 1\n components.year = time-6 //6歳\n req.birthday = Calendar.current.date(from: components)\n request.tag(forChildDirectedTreatment: true)\n \n```\n\nしかし配信される広告に変化はなく、一応改めて審査に提出しましたが、先と同様に却下されてしまいました。\n\nそのほかに必要な設定の変更などがあるかどうかなど調べてみましたが、情報が出てきません。\n\n子供向けの広告を配信し、広告をタップした後、遷移の確認を挟んだのちにURLのページに飛ぶといった広告を見たことがあるので、そういった広告を出す必要があるのだと思います。\n\nほかの広告会社を利用するなどを含め、解決法をご存知の方いらっしゃいましたらよろしくお願いします。\n\n開発環境 \nXcode9.2 Swift4.0.3", "comment_count": 7, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T08:42:04.013", "favorite_count": 0, "id": "40747", "last_activity_date": "2018-01-06T05:21:11.430", "last_edit_date": "2018-01-06T05:21:11.430", "last_editor_user_id": "19428", "owner_user_id": "19428", "post_type": "question", "score": 0, "tags": [ "swift", "xcode", "admob" ], "title": "iOSアプリのAdMob広告を子供向けに設定したい。", "view_count": 790 }
[]
40747
null
null
{ "accepted_answer_id": "40750", "answer_count": 1, "body": "[![現象発生時の画面](https://i.stack.imgur.com/yVjrN.png)](https://i.stack.imgur.com/yVjrN.png)\n\n**環境** \nホストOS Windows10 64bit \nゲストOS(Vagrant + VirtualBox) Ubuntu16.04 \nターミナル (Mintty 2.8.2 (MSYS2)) \ntmux 2.1 (ゲストOS)\n\n上記の環境で稀に画像のようにlsの表示が崩れることがあります(上は異常なPane,\n下は正常なPane)。一度こうなると一旦該当のPainをkillするしか現象が改善されません。\n\n何が原因なのか不明なのですが、なんとなく不正な制御シーケンスを入力してしまった時のような気がしています。こういう場合、Paneのkill,\n再作成以外で復帰できる方法はないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T09:15:21.137", "favorite_count": 0, "id": "40748", "last_activity_date": "2018-01-05T09:25:33.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17238", "post_type": "question", "score": 2, "tags": [ "tmux" ], "title": "ターミナルで色々作業をしているとlsの出力が崩れて元に戻らなくなることがある", "view_count": 339 }
[ { "body": "原因にも依りますが[`reset`コマンド](https://linuxjm.osdn.jp/html/util-\nlinux/man1/reset.1.html)で復旧できませんか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T09:23:22.777", "id": "40750", "last_activity_date": "2018-01-05T09:23:22.777", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "40748", "post_type": "answer", "score": 7 } ]
40748
40750
40750
{ "accepted_answer_id": "40755", "answer_count": 1, "body": "PythonでWebスクレイピングを試みていますが、NameErrorが出ます。 \nBeautifulSoupはインストールされていると思うのですが、記述方法に問題があるのでしょうか。\n\n【環境】 \nOS:Win7 32bit \nPython:3.6.4 \nIDE:ATOM \n環境変数(Pathに追加済み):`C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python36-32;C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python36-32\\Scripts`\n\n【パッケージのインストール確認】\n\n```\n\n C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python36-32\\Scripts>pip freeze\n beautifulsoup4==4.6.0\n certifi==2017.11.5\n chardet==3.0.4\n idna==2.6\n requests==2.18.4\n urllib3==1.22\n \n```\n\n【コード】\n\n```\n\n import requests\n from bs4 import BeautifulSoup\n \n url = \"http://www.kyodonews.jp/\"\n r = requests.get(url)\n \n print(soup.find(\"h1\"))\n \n```\n\n【エラー】\n\n```\n\n Traceback (most recent call last):\n File \"C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python36-32\\Scripts\\code\\scraping1.py\", line 7, in <module>\n print(soup.find(\"h1\"))\n NameError: name 'soup' is not defined\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T09:21:38.120", "favorite_count": 0, "id": "40749", "last_activity_date": "2018-07-20T07:47:33.693", "last_edit_date": "2018-07-20T07:47:33.693", "last_editor_user_id": "19110", "owner_user_id": "26841", "post_type": "question", "score": 1, "tags": [ "python", "python3", "web-scraping", "beautifulsoup" ], "title": "BeautifulSoup4をインストールしているのですが、NameErrorが出て利用できません。", "view_count": 3700 }
[ { "body": "エラーメッセージを読むと、`soup`が定義されていないと書いてありますので、`soup`を定義する必要があります。 \n`find(\"h1\")`を使おうとしていることから想像すると、`soup`はBeautifulSoupのオブジェクトであるべきです。\n\n要するに、`r`と`BeautifulSoup`を使って、`soup`を作る処理が抜けているということになります。\n\n何か参考にして書かれたのであれば、記述に漏れがないか確認してみてください。\n\n参考までに、動作するように内容を補完するとこうなります:\n\n```\n\n import requests\n from bs4 import BeautifulSoup\n \n url = \"http://www.kyodonews.jp/\"\n r = requests.get(url)\n soup = BeautifulSoup(r.text, 'html.parser')\n \n print(soup.find(\"h1\"))\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T13:58:24.073", "id": "40755", "last_activity_date": "2018-01-05T19:52:09.483", "last_edit_date": "2018-01-05T19:52:09.483", "last_editor_user_id": "9575", "owner_user_id": "9575", "parent_id": "40749", "post_type": "answer", "score": 2 } ]
40749
40755
40755
{ "accepted_answer_id": "40765", "answer_count": 1, "body": "Swift3にて、tableViewControllerのセルのindexによって画面遷移先を指定し、遷移した先の画面同士でページ移動できるようにし、tableView(初期画面)に戻る時はNavigationControllerの戻るボタンで戻れるアプリを作りたいと思っております。\n\n<苦戦しているところ> \ntableViewControllerのあるviewControllerからpageViewControllerにセグエで接続し、pageViewControllerからそれぞれページを表示させているのですが、その際に次のページに値(index)を渡そうとしているのですが、うまくいきません。\n\n※ viewControllerにはNavigationControllerをEmbedしてあります。\n\nTableViewControllerのあるViewController\n\n```\n\n class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {\n \n @IBOutlet weak var tableView: UITableView!\n \n var indexCell:Int?\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n \n (略)\n \n //セルを作る\n func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {\n let cell = tableView.dequeueReusableCell(withIdentifier: \"Cell\", for: indexPath)\n let cellData = section0[(indexPath as NSIndexPath).row]\n cell.textLabel?.text = cellData.0\n cell.detailTextLabel?.text = cellData.1\n return cell\n }\n \n \n //セルがタップされた時の処理\n func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){\n indexCell = indexPath.row\n performSegue(withIdentifier: \"segue1\",sender: self)\n \n }\n \n //セグエで移動する前にデータを受け渡す\n override func prepare(for segue: UIStoryboardSegue, sender: Any?) {\n if segue.identifier == \"segue1\" {\n if let indexPath = self.tableView.indexPathForSelectedRow { \n tableView.deselectRow(at: indexPath, animated: false) \n if let pvc = segue.destination as? PageViewController {\n pvc.received = indexCell \n }\n }\n }\n }\n \n \n }\n \n```\n\npageViewController\n\n```\n\n class PageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {\n \n var contentVCs = [UIViewController]()\n \n var select:Int?\n \n //遷移後に渡される値を格納する\n var received:Int?\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n dataSource = self\n delegate = self\n \n let storyboard = UIStoryboard(name: \"Main\", bundle: nil)\n let fvc = storyboard.instantiateViewController(withIdentifier: \"FirstViewController\") as! FirstViewController\n fvc.received = received\n let svc = storyboard.instantiateViewController(withIdentifier: \"SecondViewController\") as! SecondViewController\n svc.received = received\n let tvc = storyboard.instantiateViewController(withIdentifier: \"ThirdViewController\") as! ThirdViewController\n tvc.received = received\n \n contentVCs.append(fvc)\n contentVCs.append(svc)\n contentVCs.append(tvc)\n \n // タップされたcellのindexによって表示VCを分岐\n switch received! {\n case 0,3,6,9,12,15,18 :\n select = 0\n case 1,4,7,10,13,16,19 :\n select = 1\n case 2,5,8,11,14,17,20 :\n select = 2\n default :\n break\n }\n \n setViewControllers([contentVCs[select!]], direction: .forward, animated: true, completion: nil)\n \n }\n \n \n // MARK: - UIPageViewControllerDataSource\n \n func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {\n guard let index = contentVCs.index(of: viewController), index != NSNotFound else { return nil }\n if index < contentVCs.count - 1 {\n return contentVCs[index + 1]\n } else {\n return nil\n }\n }\n \n func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {\n guard let index = contentVCs.index(of: viewController), index != NSNotFound else { return nil }\n if index > 0 {\n return contentVCs[index - 1]\n } else {\n return nil\n }\n }\n }\n \n```\n\nFirstViewController(second,thirdも同じ)\n\n```\n\n class FirstViewController: UIViewController {\n \n @IBOutlet weak var indexLabel: UILabel!\n \n //シーン移動の際に設定されるデータ\n var received:Int?\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n \n // 受取りdata確認用ラベル\n indexLabel.text = String(received!)\n \n }\n \n }\n \n```\n\nこのコードだと、セルのindex通りのvcを選んで表示されるのですが、ページをめくると同じindex番号のまま(タップした時のセルのindex)になってしまいます。ページが進んだらindex番号もカウントアップさせたりダウンさせたりしたいのですが、Before/Afterのところで値を渡せたらいいのかと思いましたが、適切なコードが書けず苦戦しております。 \n長くなりましたが、分かる方いらっしゃいましたらご教授お願い致します。\n\n<回答を参考に修正したコード>\n\n```\n\n // MARK: - UIPageViewControllerDataSource\n \n func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {\n guard let index = contentVCs.index(of: viewController), index != NSNotFound else { return nil }\n let nextIndex = index + 1\n if index == 0 {\n if let nextVC = contentVCs[nextIndex] as? SecondViewController {\n nextVC.received = nextIndex \n return nextVC\n }\n return nil\n } else if index == 1 {\n if let nextVC = contentVCs[nextIndex] as? ThirdViewController {\n nextVC.received = nextIndex\n return nextVC\n }\n return nil\n } else {\n return nil\n }\n }\n \n func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {\n guard let index = contentVCs.index(of: viewController), index != NSNotFound else { return nil }\n let nextIndex = index - 1\n if index == 2 {\n if let nextVC = contentVCs[nextIndex] as? SecondViewController {\n nextVC.received = nextIndex\n return nextVC\n }\n return nil\n } else if index == 1 {\n if let nextVC = contentVCs[nextIndex] as? FirstViewController {\n nextVC.received = nextIndex\n return nextVC\n }\n return nil\n } else {\n return nil\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T16:24:26.307", "favorite_count": 0, "id": "40758", "last_activity_date": "2018-01-09T09:57:11.307", "last_edit_date": "2018-01-09T09:57:11.307", "last_editor_user_id": "26719", "owner_user_id": "26719", "post_type": "question", "score": 0, "tags": [ "swift3" ], "title": "Swift3 PageViewControllerでの画面移動の際の値の渡し方", "view_count": 587 }
[ { "body": "Afterなら`return contentVCs[index + 1]`としてるところで、\n\n```\n\n // return contentVCs[index + 1]\n let nextIndex = index + 1\n if let nextVC = contentVCs[nextIndex] as? FirstViewController {\n nextVC.received = nextIndex\n return nextVC\n }\n return nil\n \n```\n\nですね。\n\nここでデータを渡そうというのは正しいと思います。「適切なコードが書けず」とのことですが、`ViewController`の配列に格納した遷移先のビューコントローラを`FirstViewController`のインスタンスとしてキャストせずにいて`received`にアクセスできなかったのではないでしょうか。このような場合は\n`as` を使った型キャストが必要です。", "comment_count": 9, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T05:01:23.620", "id": "40765", "last_activity_date": "2018-01-06T05:01:23.620", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "40758", "post_type": "answer", "score": 0 } ]
40758
40765
40765
{ "accepted_answer_id": null, "answer_count": 0, "body": "Firefoxでよく使うアドオンがあるのですが、毎回マウスを移動させるのが面倒なのでボタン一発で開けるようにしたいです。\n\n私なりに考えたやり方では(代案があればぜひ!)、 \n1\\. ブックマークレット中のJavascriptからアドオンを開く \n2\\. ショートカットを設定してブックマークレットを開くようにする\n\nの2段構えでできると思っています。 \nここで質問なのですが、1.のようにJavascriptからアドオンを開くにはどうしたらよいでしょうか?\n\nご教示いただければ幸いです。ヒント等でも大歓迎です。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-05T21:27:55.020", "favorite_count": 0, "id": "40761", "last_activity_date": "2018-01-05T21:27:55.020", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26110", "post_type": "question", "score": 0, "tags": [ "firefox", "firefox-webextension" ], "title": "Firefoxでプログラムからアドオンを開きたい", "view_count": 80 }
[]
40761
null
null
{ "accepted_answer_id": null, "answer_count": 3, "body": "検索結果のクエリ速度を上げるため、DistinctをExistに置き換えたいのですが、自分には複雑でうまく置き換えができませんでした。 \n2つあるのですが、下記となります。 \n尚、計測したところ合計で約2.5秒ほどかかっています。(wp_postmetaは30万件)\n\n1つ目\n\n```\n\n SELECT DISTINCT\n PM.meta_value AS madorisu,\n PM_2.meta_value AS madorisyurui \n FROM\n (\n (\n (\n wp_posts AS P \n INNER JOIN wp_postmeta AS PM \n ON P.ID = PM.post_id\n ) \n INNER JOIN wp_postmeta AS PM_1\n ON P.ID = PM_1.post_id\n ) \n INNER JOIN wp_postmeta AS PM_2\n ON P.ID = PM_2.post_id\n )\n WHERE\n P.post_status = 'publish' \n AND P.post_password = '' \n AND P.post_type = 'fudo' \n AND PM_1.meta_key = 'bukkenshubetsu' \n AND CAST( PM_1.meta_value AS SIGNED ) > 3000 \n AND PM.meta_key = 'madorisu' \n AND PM_2.meta_key = 'madorisyurui'\n \n```\n\n2つ目\n\n```\n\n SELECT DISTINCT\n DTR.rosen_name,\n DTR.rosen_id,\n DTS.station_name,\n DTS.station_id,\n DTS.station_ranking \n FROM\n (\n (\n (\n (\n (\n (\n wp_posts AS P\n )\n INNER JOIN wp_postmeta AS PM \n ON P.ID = PM.post_id\n ) \n INNER JOIN wp_postmeta AS PM_1\n ON P.ID = PM_1.post_id\n )\n INNER JOIN wp_postmeta AS PM_2 \n ON P.ID = PM_2.post_id\n ) \n INNER JOIN wp_train_rosen AS DTR\n ON CAST( PM_1.meta_value AS SIGNED ) = DTR.rosen_id\n ) \n INNER JOIN wp_train_station AS DTS\n ON DTS.rosen_id = DTR.rosen_id \n AND CAST( PM.meta_value AS SIGNED ) = DTS.station_id\n )\n WHERE\n (\n P.post_status = 'publish' \n AND P.post_password = '' \n AND P.post_type = 'fudo' \n AND PM.meta_key = 'koutsueki1' \n AND PM_1.meta_key = 'koutsurosen1' \n AND PM_2.meta_key = 'bukkenshubetsu' \n AND PM_2.meta_value > 3000 \n )\n OR (\n P.post_status = 'publish' \n AND P.post_password = '' \n AND P.post_type = 'fudo' \n AND PM.meta_key = 'koutsueki2' \n AND PM_1.meta_key = 'koutsurosen2' \n AND PM_2.meta_key = 'bukkenshubetsu' \n AND PM_2.meta_value > 3000 \n )\n \n```\n\nどうぞよろしくお願いいたします。\n\npost_metaの構造ですが、ワードプレス標準のものをそのまま利用しており下記となっています。\n\n【post_metaテーブル】(1つ目の参考に抜粋しました。meta_idがプライマリとなります。)\n\n| meta_id | post_id | meta_key | meta_value | \n| 100000 | 3120 | mardorisu | 4 | \n| 100001 | 3120 | mardorisyurui | 10 |\n\n【期待する結果】(1つ目の抜粋)\n\n| mardorisu | mardorisyurui | \n| 1 | 50 | \n| 2 | 50 | \n| 1 | 10 | \n| 1 | 55 | \n| 3 | 30 |", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T03:10:45.917", "favorite_count": 0, "id": "40763", "last_activity_date": "2018-06-24T02:53:27.973", "last_edit_date": "2018-01-10T15:57:53.310", "last_editor_user_id": "23921", "owner_user_id": "23921", "post_type": "question", "score": 0, "tags": [ "mysql", "sql", "phpmyadmin" ], "title": "SQLでDistinctをExistに置き換えたい", "view_count": 2785 }
[ { "body": "`Exists` 句の使用は相関副問合せとセットとなる事が多いのですが、そうするとパフォーマンスは悪化する事の方が多いです。それよりも `OR`\nを避ける事に注力する方が良いプランになるように思います。\n\nところで、インデックスは使用されているでしょうか。\n\n> (wp_postmetaは30万件)\n\nとの事でネックは `wp_postmeta` の方だと思いますので、`wp_postmeta` に `post_id` 及び `meta_key`\nのカバリングインデックスを作成するとクエリパフォーマンスの向上が見込めると思います。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T13:41:02.357", "id": "40800", "last_activity_date": "2018-01-07T13:41:02.357", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26808", "parent_id": "40763", "post_type": "answer", "score": 1 }, { "body": "_返信をいただいたので回答を更新。_\n\n# ver 0.2\n\n想定条件: meta_key\nmadorisyuruiとmadorisuはpost一つにつきそれぞれ一度しか現れない。publishされているpostが全体のうち大半を占める。\n\nポイントとしては \n1\\. 質問者の元のクエリではwp_posts x wp_postmeta x wp_postmeta x\nwp_postmetaとなって行数が爆発するから、先にサブSELECTで、wp_postmetaを一度だけ読み込んでbukkenshubetsuの条件に従ってmadirisyurui,madorisuだけ抽出した。 \n2\\.\nほとんどのpostsはpublishされているので上で抽出した行で捨てるものはほとんど無い想定。もし想定が逆なら先にpost_idでメタデータのSELECTを絞ることも考えると良い。 \n3\\. group_concatしているのは縦のテーブルを横のテーブルに変換するため。\n\n```\n\n select\n pm3.madorisyurui,\n pm3.madorisu\n from\n wp_posts as p join\n (\n select\n pm2.post_id as post_id,\n group_concat(case when meta_key='madorisyurui' then meta_value end) as madorisyurui,\n group_concat(case when meta_key='madorisu' then meta_value end) as madorisu\n from\n wp_postmeta as pm2 join\n (\n select\n post_id\n from\n wp_postmeta\n where\n meta_key='bukkenshubetsu' AND\n CAST( meta_value AS SIGNED ) > 3000\n ) as pm1\n ON pm1.post_id=pm2.post_id\n where\n meta_key in ('madorisyurui', 'madorisu')\n group by 1\n ) as pm3\n ON (\n p.id = pm3.post_id and\n p.post_status = 'publish' and\n p.post_password = '' AND\n p.post_type = 'fudo'\n )\n group by 1,2\n ;\n \n```\n\n# ver 0.1\n\n最適なクエリーはデータの行数、性質によりますし、検証のしようがないので、目的にあっているのかもわかりませんが、とりあえずの回答です。目的に合わない、速度が遅いと言うことであればご指摘ください。返信があればその2についても考えてみます。\n\n```\n\n select\n p.id,\n group_concat(case when pm3.meta_key='madorisyurui' then pm3.meta_value end order by 1) as madorisyurui,\n group_concat(case when pm3.meta_key='madorisu' then pm3.meta_value end order by 1) as madorisu\n from\n wp_posts as p join\n (\n select\n pm2.post_id as post_id,\n meta_key,\n meta_value\n from\n wp_postmeta as pm2 join\n (\n select\n post_id\n from\n wp_postmeta\n where\n meta_key='bukkenshubetsu' AND\n CAST( meta_value AS SIGNED ) > 3000\n ) as pm1\n ON pm1.post_id=pm2.post_id\n where\n meta_key in ('madorisyurui', 'madorisu')\n ) as pm3\n ON (\n p.id = pm3.post_id and\n p.post_status = 'publish' and\n p.post_password = '' AND\n p.post_type = 'fudo'\n )\n group by p.id\n ;\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T03:06:14.477", "id": "40807", "last_activity_date": "2018-01-10T22:54:11.847", "last_edit_date": "2018-01-10T22:54:11.847", "last_editor_user_id": "7837", "owner_user_id": "7837", "parent_id": "40763", "post_type": "answer", "score": 0 }, { "body": "別回答の形で恐縮です。 \n質問者さんのクエリの要件を明確にしたかったのでクエリを整形してみたのですが、この認識で相違ないでしょうか?\n\n1)\n\n```\n\n -- 記事に紐づく、`madorisu` と `madorisyurui` の組合せ一覧\n SELECT DISTINCT\n madorisu.meta_value AS madorisu,\n madorisyurui.meta_value AS madorisyurui \n FROM wp_posts AS post \n INNER JOIN wp_postmeta AS bukkenshubetsu ON post.ID = bukkenshubetsu.post_id AND bukkenshubetsu.meta_key = 'bukkenshubetsu'\n INNER JOIN wp_postmeta AS madorisu ON post.ID = madorisu.post_id AND madorisu.meta_key = 'madorisu' \n INNER JOIN wp_postmeta AS madorisyurui ON post.ID = madorisyurui.post_id AND madorisyurui.meta_key = 'madorisyurui'\n WHERE\n post.post_status = 'publish' \n AND post.post_password = '' \n AND post.post_type = 'fudo' \n AND CAST(bukkenshubetsu.meta_value AS SIGNED) > 3000 \n \n```\n\n2)\n\n```\n\n -- 記事に紐づく、`路線`と`駅`の組合せ一覧\n SELECT \n rosen.rosen_name,\n rosen.rosen_id,\n station.station_name,\n station.station_id,\n station.station_ranking \n FROM (\n -- 先に rosen_id と station_id の組合せで一意に絞り込む。\n SELECT DISTINCT\n CAST(koutsurosen.meta_value AS SIGNED) AS rosen_id,\n CAST(koutsueki.meta_value AS SIGNED) AS station_id\n FROM wp_posts AS post\n INNER JOIN wp_postmeta AS bukkenshubetsu ON post.ID = bukkenshubetsu.post_id AND bukkenshubetsu.meta_key = 'bukkenshubetsu'\n INNER JOIN wp_postmeta AS koutsueki ON post.ID = koutsueki.post_id\n INNER JOIN wp_postmeta AS koutsurosen ON post.ID = koutsurosen.post_id\n WHERE\n post.post_status = 'publish' \n AND post.post_password = '' \n AND post.post_type = 'fudo' \n AND bukkenshubetsu.meta_value > 3000\n AND (\n koutsueki.meta_key = 'koutsueki1' AND koutsurosen.meta_key = 'koutsurosen1' \n OR\n koutsueki.meta_key = 'koutsueki2' AND koutsurosen.meta_key = 'koutsurosen2'\n )\n ) t\n INNER JOIN wp_train_rosen AS rosen ON t.rosen_id = rosen.rosen_id\n INNER JOIN wp_train_station AS station ON t.station_id = station.station_id AND rosen.rosen_id = station.rosen_id\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-10T23:32:03.223", "id": "40873", "last_activity_date": "2018-01-10T23:32:03.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26808", "parent_id": "40763", "post_type": "answer", "score": -1 } ]
40763
null
40800
{ "accepted_answer_id": null, "answer_count": 2, "body": "ログイン先のサーバーにてディレクトリとファイルの色が全て白色に表示されてしまいます. \n最初に /etc/DIR_COLORS をホームディレクトリに .dir_colors としてコピーしました.\n\n~/.dir_colors の中身の一部は以下の通りです.\n\n```\n\n # Below are the color init strings for the basic file types. A color init\n # string consists of one or more of the following numeric codes:\n # Attribute codes:\n # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed\n # Text color codes:\n # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white\n # Background color codes:\n # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white\n NORMAL 00 # global default, although everything should be something.\n FILE 00 # normal file\n DIR 01;34 # directory\n LINK 01;36 # symbolic link\n FIFO 40;33 # pipe\n SOCK 01;35 # socket\n BLK 40;33;01 # block device driver\n CHR 40;33;01 # character device driver\n ORPHAN 01;05;37;41 # orphaned syminks\n MISSING 01;05;37;41 # ... and the files they point to\n \n # This is for files with execute permission:\n EXEC 01;32\n \n```\n\nこれを ~/.bashrc に `eval `dircolors .dir_colors -b`` を追加し、`source .bashrc`\nと実行したのですが,ファイルもディレクトリも白色のままでした.\n\n`echo $LS_COLORS` としても何も表示されません. \n何が原因なのでしょうか?", "comment_count": 4, "content_license": "CC BY-SA 4.0", "creation_date": "2018-01-06T06:38:45.150", "favorite_count": 0, "id": "40767", "last_activity_date": "2022-04-14T11:47:13.177", "last_edit_date": "2022-04-14T11:47:13.177", "last_editor_user_id": "3060", "owner_user_id": "26604", "post_type": "question", "score": 0, "tags": [ "linux", "unix", "cygwin" ], "title": ".dir_colors を定義しても、ディレクトリとファイルの色が同色になってしまう", "view_count": 411 }
[ { "body": "```\n\n eval `dircolors .dir_colors -b`\n \n```\n\nではなく、\n\n```\n\n eval `dircolors ~/.dir_colors -b`\n \n```\n\nにする必要があると思います。(`~/`が抜けています)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T10:26:28.650", "id": "40773", "last_activity_date": "2018-01-06T10:26:28.650", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9575", "parent_id": "40767", "post_type": "answer", "score": 0 }, { "body": "`echo\n$TERM`の変数が`DIR_COLORS`に記載されていませんでした.コピーした`.dir_colors`の中に`TERM`を追加し‌​たところ無事に解決しました.\n\nちなみにエイリアスで`ls='ls --color'`としても解決しました.\n\n\\--\n[質問者](https://ja.stackoverflow.com/users/26604/tm-y)さんの[コメント](https://ja.stackoverflow.com/questions/40767/%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%A8%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E8%89%B2%E3%81%8C%E5%90%8C%E8%89%B2%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%97%E3%81%BE%E3%81%86#comment41587_40767)より。アイディアは\n[metropolis](https://ja.stackoverflow.com/users/16894/metropolis)\nさんの[このコメント](https://ja.stackoverflow.com/questions/40767/%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%A8%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E8%89%B2%E3%81%8C%E5%90%8C%E8%89%B2%E3%81%AB%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%97%E3%81%BE%E3%81%86#comment41583_40767)に由来します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-24T10:48:39.807", "id": "41183", "last_activity_date": "2018-01-24T10:48:39.807", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "40767", "post_type": "answer", "score": 1 } ]
40767
null
41183
{ "accepted_answer_id": "40779", "answer_count": 2, "body": "[![画像の説明をここに入力](https://i.stack.imgur.com/Y4rpw.png)](https://i.stack.imgur.com/Y4rpw.png)\n\nALE等のプラグインを使っていると、Linterがこのようなメッセージをコマンドラインウインドウに表示してくれますが、これをそのままクリップボードにコピーし、ブラウザでGoogle検索等を行いたいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T07:06:40.207", "favorite_count": 0, "id": "40769", "last_activity_date": "2021-03-06T08:24:12.273", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17238", "post_type": "question", "score": 2, "tags": [ "vim" ], "title": "Vimのコマンドラインウインドウに表示されているメッセージをクリップボードにコピーしたい", "view_count": 709 }
[ { "body": "[thinca](https://ja.stackoverflow.com/users/2541/thinca)さんの[回答](https://ja.stackoverflow.com/a/40779/25936)を見ていて閃きました。 \n`:messages`の最下行をクリップボードへコピーするコマンドとクエリにしてWeb検索するコマンドです。 \n(が、まだまだ改善の余地がある筈なのでよろしければコメントを付けていただくなり、回答を編集するなりお願いします) \nなお、`xdg-open`がなかったり別の検索エンジンを使いたいという場合は、お使いの環境に合わせて適宜書き換えてください。\n\n```\n\n command MesToClipboard let @+ = execute(\"1messages\")\n \n command! MesDeSearch call system(\"xdg-open \\\"https://www.duckduckgo.com/?q=\" .. execute(\"1messages\") .. \"\\\"\")\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2018-01-06T14:30:03.333", "id": "40778", "last_activity_date": "2021-03-06T08:24:12.273", "last_edit_date": "2021-03-06T08:24:12.273", "last_editor_user_id": "25936", "owner_user_id": "25936", "parent_id": "40769", "post_type": "answer", "score": 3 }, { "body": "`:messages` をバッファに出す方法を紹介します。\n\n```\n\n :new\n :put =execute('messages')\n \n```\n\nこれで新しいバッファに `:messages` の出力が書き込まれるので、通常のテキストと同様に扱えます。\n\nただし、中には `:messages` に記録されないメッセージもあります。その場合は表示された後で結果を取ることは残念ながらできません。(CUI\nなら端末側の機能で取ることはできます)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T15:08:38.860", "id": "40779", "last_activity_date": "2018-01-06T15:08:38.860", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2541", "parent_id": "40769", "post_type": "answer", "score": 4 } ]
40769
40779
40779
{ "accepted_answer_id": null, "answer_count": 1, "body": "例えば以下のようなファイルがあるとして\n\n```\n\n # add.py\n a = 1\n b = 2\n c = a + b\n \n```\n\nこれをPythonの対話実行中に呼び出して、cの値を確認するようなことはできないでしょうか? \nprint文でデバッグしなくて済むのでプログラミングがものすごく楽になるのですが...\n\nどうぞよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T08:02:38.427", "favorite_count": 0, "id": "40770", "last_activity_date": "2018-01-06T08:18:24.373", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26110", "post_type": "question", "score": 1, "tags": [ "python", "python3" ], "title": "Pythonのプログラムを対話実行中に呼び出せないでしょうか", "view_count": 209 }
[ { "body": "解決しました!\n\nPyhton -i add.py のようにオプションiをつけて起動することによって、 \nスクリプト実行後に対話入力モードにシフトすることができました。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T08:18:24.373", "id": "40772", "last_activity_date": "2018-01-06T08:18:24.373", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26110", "parent_id": "40770", "post_type": "answer", "score": 3 } ]
40770
null
40772
{ "accepted_answer_id": null, "answer_count": 0, "body": "RaspberryPiに接続したGPSモジュールからGPSデータ(タイムスタンプ・緯度・経度)を取得して繰り返し保存するプログラムを書きました。保存されたCSVファイルのタイムスタンプを見るとおよそ1秒に1回ごとに記録されています。1秒で5回は記録したいのですが、どのように実装すればよいですか?\n\n```\n\n #!/usr/bin/env python\n # -*- coding: utf-8 -*-\n #GPS Program\n \n import serial\n import pandas as pd\n import sys\n import os\n \n args = sys.argv\n \n data1= '$GPGGA'\n data2= '$GPGLL'\n data3= '$GPRMC'\n \n s = serial.Serial('/dev/serial0', 9600, timeout=10)\n s.readline()\n \n while 1:\n s = serial.Serial('/dev/serial0', 9600, timeout=10)\n s.readline()\n sentence = s.readline().decode('utf-8')\n li = sentence.split(',')\n \n # NMEAのGPGGAからUTC,緯度,経度を取得してCSVファイルに保存\n if data1 in li[0]:\n timeutc = li[1]\n lat = li[2]\n lon = li[4]\n w = pd.DataFrame([[timeutc,lon,lat]])\n w.to_csv(args[1], index=False, encoding=\"utf-8\", mode='a', header=False)\n \n # NMEAのGPGLLからUTC,緯度,経度を取得してCSVファイルに保存\n if data2 in li[0]:\n timeutc = li[5]\n lat = li[1]\n lon = li[3]\n w = pd.DataFrame([[timeutc,lon,lat]])\n w.to_csv(args[1], index=False, encoding=\"utf-8\", mode='a', header=False)\n \n # NMEAのGPRMCからUTC,緯度,経度を取得してCSVファイルに保存\n if data3 in li[0]:\n timeutc = li[1]\n lat = li[3]\n lon = li[5]\n w = pd.DataFrame([[timeutc,lon,lat]])\n w.to_csv(args[1], index=False, encoding=\"utf-8\", mode='a', header=False)\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T10:53:24.770", "favorite_count": 0, "id": "40774", "last_activity_date": "2018-01-06T10:53:24.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26901", "post_type": "question", "score": 0, "tags": [ "python", "raspberry-pi", "gps" ], "title": "RaspberryPi GPSプログラム(python)", "view_count": 1622 }
[]
40774
null
null
{ "accepted_answer_id": "41298", "answer_count": 1, "body": "swift でチャット機能を作りたいと思いました。\n\n少しググってみたところ、 firebase +\n[JSQMessagesViewController](https://github.com/jessesquires/JSQMessagesViewController)\nで作るのがよい、という記事をたくさん見掛けたのですが、 JSQMessagesViewController は、公式で deprecated\nになっている様子です。\n\n### 質問:\n\n * ios 11, swift でチャットを作る際の UI ライブラリとして利用可能な pod で、 JSQMessagesViewController の代替となるようなものは、どのようなものがあるでしょうか。 \n * もしくは、 deprecated だけれども JSQMessagesViewController を使いつづけたほうがひとまずよかったりするのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T10:55:25.460", "favorite_count": 0, "id": "40775", "last_activity_date": "2018-01-29T14:42:10.167", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 0, "tags": [ "swift", "ios" ], "title": "swift でチャット機能を実装するにあたって利用できる pod", "view_count": 758 }
[ { "body": "[MessageKit](https://github.com/MessageKit/MessageKit) が、おそらく\nJSQMessagesViewController の後継に該当する様子です。\n\n> In-progress: A community-driven replacement for JSQMessagesViewController\n> <https://messagekit.github.io>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-29T14:42:10.167", "id": "41298", "last_activity_date": "2018-01-29T14:42:10.167", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "40775", "post_type": "answer", "score": 0 } ]
40775
41298
41298
{ "accepted_answer_id": null, "answer_count": 1, "body": "HTML+Javascriptのページがあります。このページにはvideoタグで動画が再生されるのですが、動画のURLはjavascriptの実行により動画URLがvideoタグにセットされる構成になっています。\n\nこのvideoタグにセットされるURLを取得したいと思っています。 \nbashもしくはPHPを使って、ページURLからjavascriptを実行して生成される動画url(mp4)を取得するにはどうしたらいいのでしょうか?\n\nやりたいことは以下のイメージです。\n\n```\n\n $ getmovieurl.sh http://aaa.com/aaa.html\n http://bbb.com/ccc.mp4\n \n```\n\n関連ページ情報でもかいません。ご存知の方はご教授いただけると幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T16:41:12.753", "favorite_count": 0, "id": "40780", "last_activity_date": "2018-01-07T09:56:04.020", "last_edit_date": "2018-01-07T07:06:46.413", "last_editor_user_id": "25766", "owner_user_id": "8593", "post_type": "question", "score": 0, "tags": [ "javascript", "php", "html", "bash" ], "title": "javascript実行後のURLを取得する", "view_count": 1448 }
[ { "body": "スクレイピング関連を調べるのが良いかと思います。\n\n例えば、以下の記事では PhantomJS を用いてレンダリング後の HTML を取得する様子を示しています。 \n<https://qiita.com/_RJ/items/de57cf2a7602b64ffed9>", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T09:56:04.020", "id": "40793", "last_activity_date": "2018-01-07T09:56:04.020", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26808", "parent_id": "40780", "post_type": "answer", "score": 1 } ]
40780
null
40793
{ "accepted_answer_id": null, "answer_count": 1, "body": "WindowsのOffice365 ProplusとExcel 2013では動くVBAがMacのExcel 2016 for Macでは動きません。 \nサンプルとして掲載されていた以下のコードなのですが、以下の個所で「`実行時エラー5\nプロシージャの呼出し、または引数が無効です`」となります、Mac版の制約か何かなのでしょうかご教示下さい。\n\n```\n\n Set NewM = CommandBars(\"Worksheet Menu Bar\").Controls.Add(Type:=msoControlPopup)…\n \n Sub AddMenu()\n Dim NewM As Variant, NewC As Variant\n ''(1)[新しいメニュー]というメニューを作成します\n Set NewM = CommandBars(\"Worksheet Menu Bar\").Controls.Add(Type:=msoControlPopup)\n With NewM\n .Caption = \"新しいメニュー(&C)\"\n End With\n \n ''(2)作成したメニューに2つのコマンドを登録します\n Set NewC = NewM.Controls.Add\n With NewC\n .Caption = \"1行目の処理\" ''1つ目コマンド名\n .OnAction = \"Action_Row\" ''実行するマクロ\n .FaceId = 541\n End With\n Set NewC = NewM.Controls.Add\n With NewC\n .Caption = \"1列目の処理\" ''2つ目コマンド名\n .OnAction = \"Action_Column\" ''実行するマクロ\n .FaceId = 542\n End With\n End Sub\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-06T18:31:46.747", "favorite_count": 0, "id": "40782", "last_activity_date": "2019-04-14T03:01:41.407", "last_edit_date": "2018-03-03T10:45:21.113", "last_editor_user_id": "2383", "owner_user_id": "26904", "post_type": "question", "score": 0, "tags": [ "vba" ], "title": "Excel 2016 for MacとOffice365 Proplus(windows)でのVBAの挙動の差", "view_count": 482 }
[ { "body": "Mac版のVBAは、無保証です。 \n動いたら運が良かったと思う程度。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-04-15T14:22:39.957", "id": "43271", "last_activity_date": "2018-04-15T14:22:39.957", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "40782", "post_type": "answer", "score": 1 } ]
40782
null
43271
{ "accepted_answer_id": null, "answer_count": 1, "body": "LSM9DS1 9軸慣性計測モジュールを使ってI2C接続で加速度・ジャイロ・磁気・温度センサ値の取得・表示を繰り返すプログラムを作りました。\n\n生データを表示するとAが加速度センサ、Gがジャイロセンサ、Mが磁気センサ、XYZはそれぞれの軸、Tempは温度センサ(謎の値)を出力しました。\n\nこのセンサの生データの値を加速度(m/S^2)、ジャイロ(dps)、磁気(gauss)、温度(℃)に変換するプログラムについてご教示ください。\n\n[![センサの生データの値](https://i.stack.imgur.com/JvBO1.png)](https://i.stack.imgur.com/JvBO1.png) \n<実際のプログラム>\n\n```\n\n #!/usr/bin/python\n # -*- coding: utf-8 -*-\n import smbus\n import time\n \n addressG = 0x6a\n addressA = 0x6a\n addressM = 0x1c\n getG=0x18\n getA=0x28\n getM=0x28\n getTemp = 0x15\n \n CTRL_REG1_G = 0x10\n CTRL_REG4 = 0x1E\n CTRL_REG5_XL = 0x1F\n CTRL_REG3_M = 0x22\n \n bus = smbus.SMBus(1)\n \n bus.write_byte_data(addressG, CTRL_REG1_G, 0b00100000) #gyro/accel odr and bw\n bus.write_byte_data(addressG, CTRL_REG4, 0b00111000) #enable gyro axis\n bus.write_byte_data(addressA,CTRL_REG5_XL, 0b00111000) #enable acceleromete\n bus.write_byte_data(addressM, CTRL_REG3_M, 0b00000000) #enable mag continuous\n def alter(alterdata):\n return alterdata if alterdata < 32768 else alterdata - 65536\n \n # ジャイロ・加速度・磁気・温度センサの生データを取得して繰り返し表示\n while True:\n dataA = bus.read_i2c_block_data(addressA, getA,6)\n rawAX = dataA[0] | dataA[1] << 8\n rawAY = dataA[2] | dataA[3] << 8\n rawAZ = dataA[4] | dataA[5] << 8\n AX = alter(rawAX)\n AY = alter(rawAY)\n AZ = alter(rawAZ)\n print \"AX:\"+\"%d\" % AX + \" \",\n print \"AY:\"+\"%d\" % AY + \" \",\n print \"AZ:\"+\"%d\" % AZ + \" \"\n dataG = bus.read_i2c_block_data(addressG, getG,6)\n rawGX = dataG[0] | dataG[1] << 8\n rawGY = dataG[2] | dataG[3] << 8\n rawGZ = dataG[4] | dataG[5] << 8\n GX = alter(rawGX)\n GY = alter(rawGY)\n GZ = alter(rawGZ)\n print \"GX: \"+\"%d\" % GX + \"\",\n print \"GY: \"+\"%d\" % GY + \"\",\n print \"GZ: \"+\"%d\" % GZ + \"\"\n dataM = bus.read_i2c_block_data(addressM, getM,6)\n rawMX = dataM[0] | dataM[1] << 8\n rawMY = dataM[2] | dataM[3] << 8\n rawMZ = dataM[4] | dataM[5] << 8\n MX = alter(rawMX)\n MY = alter(rawMY)\n MZ = alter(rawMZ)\n print \"MX:\"+\"%d\" % MX + \"\",\n print \"MY:\"+\"%d\" % MY + \"\",\n print \"MZ:\"+\"%d\" % MZ + \"\"\n dataTemp = bus.read_i2c_block_data(addressG, getTemp,2)\n rawTemp = dataTemp[0] | dataTemp[1] <<8\n print \"Temp:\"+\"%d\" % rawTemp + \" \"\n print(\"---------------------------------------------\")\n time.sleep(1)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T00:29:59.690", "favorite_count": 0, "id": "40783", "last_activity_date": "2018-04-16T12:04:00.463", "last_edit_date": "2018-01-07T05:22:15.933", "last_editor_user_id": "3060", "owner_user_id": "26901", "post_type": "question", "score": 0, "tags": [ "python", "raspberry-pi", "センサー" ], "title": "【i2c】RaspberryPiに接続した9軸慣性センサのプログラムについてご教示ください!!", "view_count": 1917 }
[ { "body": "もう解決されているかもしれませんし、 \n直接の回答ではありませんが、 \nArduino用のライブラリで、Rawデータを直読可能な値に変換してます。 \nライブラリソース内をcalAccelとかcalcGyroとかで検索してみて下さい", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-04-16T12:04:00.463", "id": "43295", "last_activity_date": "2018-04-16T12:04:00.463", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9423", "parent_id": "40783", "post_type": "answer", "score": 1 } ]
40783
null
43295
{ "accepted_answer_id": null, "answer_count": 1, "body": "これまで、GPL3で配布していた自作のプログラムのライセンスをMITなどに変更にして条件を緩和したいと思っています。\n\nこういうことって著作権者でも許されるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T02:08:33.660", "favorite_count": 0, "id": "40785", "last_activity_date": "2018-01-07T02:34:46.650", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5461", "post_type": "question", "score": 5, "tags": [ "ライセンス" ], "title": "自作プログラムのライセンスの変更", "view_count": 219 }
[ { "body": "自身の著作物であれば、次バージョンからライセンスを変更するのは問題ないと思います。 \n(すでにリリース済みのバージョンのプログラムのライセンスを変更するのは、いろいろと問題になると思いますが)\n\n#自身がライセンサであり一次配布元であるので、GPLの条項適用前という解釈です。 \n#もちろん、自身のプログラムがGPLなソースコードを流用、リンクしていれば、MITライセンスへの変更は許可されないでしょう。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T02:34:46.650", "id": "40787", "last_activity_date": "2018-01-07T02:34:46.650", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "20098", "parent_id": "40785", "post_type": "answer", "score": 7 } ]
40785
null
40787
{ "accepted_answer_id": "40789", "answer_count": 1, "body": "環境: Ubuntu 16.04.3, python 2.7.14\n\n<https://qiita.com/kenmatsu4/items/23768cbe32fe381d54a2> \ntwitterのタイムラインから単語を収集し解析するプログラムの勉強のために、上記ページのプログラムで、Twitterのタイムラインを収集するプログラムを動かしたいです。\n\nfunctions.pyで以下のようにエラーが表示されます。\n\n```\n\n $ python functions.py\n \n Traceback (most recent call last):\n File \"functions.py\", line 31, in <module>\n print(getTweetData())\n TypeError: getTweetData() takes exactly 3 arguments (0 given)\n \n```\n\n自分の手元にコピーし、編集したソースコードは以下のようになっています。\n\nfunctions.py\n\n```\n\n from initialize import initialize\n def getTweetData(search_word, max_id, since_id):\n global twitter\n url = 'https://api.twitter.com/1.1/search/tweets.json'\n params = {'q': 'search_word',\n 'count':'100',\n }\n # max_idの指定があれば設定する\n if max_id != -1:\n params['max_id'] = max_id\n # since_idの指定があれば設定する\n if since_id != -1:\n params['since_id'] = since_id\n \n req = twitter.get(url, params = params) # Tweetデータの取得\n \n # 取得したデータの分解\n if req.status_code == 200: # 成功した場合\n timeline = json.loads(req.text)\n metadata = timeline['search_metadata']\n statuses = timeline['statuses']\n limit = req.headers['x-rate-limit-remaining'] if 'x-rate-limit-remaining' in req.headers else 0\n reset = req.headers['x-rate-limit-reset'] if 'x-rate-limit-reset' in req.headers else 0\n return {\"result\":True, \"metadata\":metadata, \"statuses\":statuses, \"limit\":limit, \"reset_time\":datetime.datetime.fromtimestamp(float(reset)), \"reset_time_unix\":reset}\n else: # 失敗した場合\n print (\"Error: %d\" % req.status_code)\n return{\"result\":False, \"status_code\":req.status_code}\n \n print(getTweetData())\n \n def obj_nullcheck(string): # Y if X else Z\n return False if string is None else True\n \n def is_exist_id(id_str):\n return tweetdata.find({'id':long(id_str)},{'id':1}).count() > 0\n \n```\n\ninitialize.py\n\n```\n\n from requests_oauthlib import OAuth1Session\n from requests.exceptions import ConnectionError, ReadTimeout, SSLError\n import json, datetime, time, pytz, re, sys, traceback, unicodedata, pymongo\n from pymongo import MongoClient\n import numpy as np\n from collections import defaultdict\n from bson.objectid import ObjectId\n import MeCab as mc\n from logging import getLogger, DEBUG\n from logging.handlers import SysLogHandler\n \n KEYS = {\n 'consumer_key':'*****************',\n 'consumer_secret':'*****************',\n 'access_token':'*****************',\n 'access_secret':'*****************',\n }\n \n twitter = None\n connect = None\n db = None\n tweetdata = None\n meta = None\n posi_nega_dict = None\n \n def initialize(): # twitter接続情報や、mongoDBへの接続処理等initial処理実行\n global twitter, twitter, connect, db, tweetdata, meta\n twitter = OAuth1Session(KEYS['consumer_key'],KEYS['consumer_secret'],\n KEYS['access_token'],KEYS['access_secret'])\n \n connect = MongoClient('localhost', 27017)\n db = connect.kenko\n tweetdata = db.tweetdata\n meta = db.metadata\n posi_nega_dict = db.posinegadict\n \n initialize()\n print(initialize())\n \n```\n\n* * *\n\n自分で調べて実行したことは \n1.global変数twitterの中身が定義されていないので twitter = で \nreq = twitter.get(url, params = params) # Tweetデータの取得までを {}で囲む \n→ 結果\n\n```\n\n File \"functions.py\", line 7\n url = 'https://api.twitter.com/1.1/search/tweets.json'\n ^\n \n```\n\nSyntaxError: invalid syntax\n\n色々試すが無関係そうだと判断。\n\n 2. initialize.py内のtwitterのapiキーが間違っている \n→ キーを確認。問題なし。\n\n 3. 0 givenとエラーに表示されているので、 search_word, max_id, since_id が機能していないのではと考えたがその先どうすれば直るのかが不明\n\nお手数ですが、アドバイスよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T02:30:15.173", "favorite_count": 0, "id": "40786", "last_activity_date": "2018-01-07T05:23:45.190", "last_edit_date": "2018-01-07T05:07:24.133", "last_editor_user_id": "3060", "owner_user_id": "26905", "post_type": "question", "score": 0, "tags": [ "python", "ubuntu", "api", "twitter" ], "title": "Twitterのタイムライン収集を行うPythonの関数の動かし方", "view_count": 584 }
[ { "body": "エラーメッセージに表示されている通り、`getTweetDate()`を呼び出す際は引数を3つ渡す必要があるのにプログラムでは **引数なし**\nで呼び出しているため、エラーになっているのだと思います。\n\nエラーメッセージ\n\n```\n\n TypeError: getTweetData() takes exactly 3 arguments (0 given)\n \n```\n\n定義部分\n\n```\n\n def getTweetData(search_word, max_id, since_id):\n \n```\n\n呼び出し部分\n\n```\n\n print(getTweetData())\n \n```\n\n参照先URL(Qiita)ソースコードでの呼び出し部分\n\n```\n\n res = getTweetData(u'スタバ', max_id=mid, since_id=sid)\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T05:13:46.433", "id": "40789", "last_activity_date": "2018-01-07T05:23:45.190", "last_edit_date": "2018-01-07T05:23:45.190", "last_editor_user_id": "3060", "owner_user_id": "3060", "parent_id": "40786", "post_type": "answer", "score": 1 } ]
40786
40789
40789
{ "accepted_answer_id": null, "answer_count": 0, "body": "タイトルの通りですがEC2インスタンスに接続できません。\n\n先日1週間ぶりに接続しようとしたところ接続ができなかった(特に何も設定はいじっていない)ので一度インスタンスを再起動しました。そのところサイト自体も接続ができなくなってしまいました。おそらくターミナルからapacheを起動させなければいけないと思うのですが、インスタンスに接続ができないのでそれができません。\n\n**接続方法**\n\n * teratermでssh接続(elastic ipを使用)\n * awsコンソールからインスタンスの停止、起動を実行 \n\n**手順**\n\n 1. ssh接続をしようとした\n 2. タイムアウトしてつながらない(インスタンスは正常に動いている)\n 3. インスタンスを停止\n 4. インスタンスを起動\n 5. サイトが表示されなくなる\n 6. インスタンスを停止\n 7. インスタンスを起動\n 8. sshログインできないまま \n\naws初心者ですが、どなたか解決方法がわかる方がいたら教えていただけないでしょうか?", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T04:18:31.923", "favorite_count": 0, "id": "40788", "last_activity_date": "2021-06-27T03:10:15.323", "last_edit_date": "2021-06-27T03:10:15.323", "last_editor_user_id": "3060", "owner_user_id": "26906", "post_type": "question", "score": 0, "tags": [ "ssh", "amazon-ec2" ], "title": "awsインスタンスに接続できない", "view_count": 1255 }
[]
40788
null
null
{ "accepted_answer_id": "40812", "answer_count": 1, "body": "Aizu\nOnlineジャッジの[最大公約数と最小公倍数の問題](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005&lang=jp)をPython3で解いていますが、「Runtime\nError」(はやく言えばスクリプト言語単位でのエラーですね)と出てしまいます。 \nどこに「Runtime Error」の原因があるのか教えてくれないでしょうか。\n\n```\n\n class GCD():\n def __init__(self,a,b):\n self.a = a\n self.b = b\n \n def swap(self):\n temp = self.a\n self.a = self.b\n self.b = temp\n \n def gcd(self):\n if self.b < self.a:\n self.swap()\n \n temp = self.b % self.a\n \n if temp == 0:\n ans = self.a\n return ans\n \n ans = self.b % temp\n \n return ans\n \n \n def lcm(self):\n gcd = self.gcd()\n temp = self.a * self.b\n ans = temp // gcd\n return gcd,ans\n \n def print(self):\n num = self.lcm()\n print(\"{0} {1}\".format(num[0],num[1]))\n \n def main():\n data = []\n \n while 1:\n try:\n n = input().split()\n \n a = int(n[0])\n b = int(n[1])\n \n data.append(GCD(a, b))\n \n except EOFError:\n break\n \n for array in data:\n array.print()\n \n if __name__ == \"__main__\":\n main()\n \n```", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T05:24:13.627", "favorite_count": 0, "id": "40790", "last_activity_date": "2018-01-08T05:54:54.800", "last_edit_date": "2018-01-08T05:45:09.027", "last_editor_user_id": "26886", "owner_user_id": "26886", "post_type": "question", "score": 1, "tags": [ "python", "python3" ], "title": "PythonでAizu Onlineジャッジの最大公約数と最小公倍数の問題でRuntime Errorと出る。", "view_count": 238 }
[ { "body": "色々と回答を出しているみたいですが、Kenji\nNoguchiさんの意見を参考にして、コードを以下のように変更したら「Accept」(正解です)になりました。みなさま、どうもありがとうございました!!\n\n```\n\n class GCD():\n def __init__(self,a,b):\n self.a = a\n self.b = b\n \n def gcd(self):\n if self.a < self.b:\n self.a, self.b = self.b, self.a\n while self.b:\n self.a, self.b= self.b, self.a % self.b\n \n return self.a\n \n def print(self):\n lcm = self.a * self.b // self.gcd()\n print(self.gcd(), lcm)\n \n def main():\n data =[]\n \n while 1:\n try:\n n = input().split()\n \n a = int(n[0])\n b = int(n[1])\n \n data.append(GCD(a, b))\n \n except EOFError:\n break\n \n for array in data:\n array.print()\n \n if __name__ == \"__main__\":\n main()\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T05:54:54.800", "id": "40812", "last_activity_date": "2018-01-08T05:54:54.800", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26886", "parent_id": "40790", "post_type": "answer", "score": 1 } ]
40790
40812
40812
{ "accepted_answer_id": null, "answer_count": 1, "body": "これは書かれていたものの一部なのですが、 \nこれを解読するツールってありませんか? \n解読できるウェブサイトなどはすでに試しましたが改行されただけで \n解読はできないみたいでした \nそれとこれはnodejsで動作するプログラムのコードです\n\n以下コードです\n\n```\n\n var jv = c(this, function() {\n var c = function() {\n return '\\x64\\x65\\x76';\n },\n d = function() {\n return '\\x77\\x69\\x6e\\x64\\x6f\\x77';\n };\n var e = function() {\n var f = new RegExp('\\x5c\\x77\\x2b\\x20\\x2a\\x5c\\x28\\x5c\\x29\\x20\\x2a\\x7b\\x5c\\x77\\x2b\\x20\\x2a\\x5b\\x27\\x7c\\x22\\x5d\\x2e\\x2b\\x5b\\x27\\x7c\\x22\\x5d\\x3b\\x3f\\x20\\x2a\\x7d');\n return !f['\\x74\\x65\\x73\\x74'](c['\\x74\\x6f\\x53\\x74\\x72\\x69\\x6e\\x67']());\n };\n var g = function() {\n var h = new RegExp('\\x28\\x5c\\x5c\\x5b\\x78\\x7c\\x75\\x5d\\x28\\x5c\\x77\\x29\\x7b\\x32\\x2c\\x34\\x7d\\x29\\x2b');\n return h['\\x74\\x65\\x73\\x74'](d['\\x74\\x6f\\x53\\x74\\x72\\x69\\x6e\\x67']());\n };\n var i = function(j) {\n var k = ~-0x1 >> 0x1 + 0xff % 0x0;\n if (j['\\x69\\x6e\\x64\\x65\\x78\\x4f\\x66']('\\x69' === k)) {\n l(j);\n }\n };\n var l = function(m) {\n var n = ~-0x4 >> 0x1 + 0xff % 0x0;\n if (m['\\x69\\x6e\\x64\\x65\\x78\\x4f\\x66']((!![] + '')[0x3]) !== n) {\n n(m);\n }\n };\n if (!e()) {\n if (!g()) {\n i('\\x69\\x6e\\x64\\u0435\\x78\\x4f\\x66');\n } else {\n i('\\x69\\x6e\\x64\\x65\\x78\\x4f\\x66');\n }\n } else {\n i('\\x69\\x6e\\x64\\u0435\\x78\\x4f\\x66');\n }\n });\n jv();\n var y = 0x1f91;\n const z = require('ws');\n const A = require(b('0x0', 'k&7f'));\n const B = require(b('0x1', '16E5'));\n const C = require(b('0x2', 'KK1n'))(y);\n const D = require('fs');\n const E = require(b('0x3', '32fx'));\n let F = 0x7d0;\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T07:28:08.163", "favorite_count": 0, "id": "40791", "last_activity_date": "2018-01-07T12:12:36.513", "last_edit_date": "2018-01-07T12:12:36.513", "last_editor_user_id": "3060", "owner_user_id": "26909", "post_type": "question", "score": 0, "tags": [ "javascript", "node.js" ], "title": "難読化されたJavascriptの解読について", "view_count": 1862 }
[ { "body": "「解読」がどの程度のものを指すかわかりませんが、たとえば文字列リテラル内のhex表記(`\\x77`)をデコードするようなことのできるツールならいろいろあるでしょう。(提示されているコードならこれだけでもかなり読めるようになるはず)\n\nex: [Online JavaScript beautifier](http://jsbeautifier.org/) ([js-\nbeautify](https://www.npmjs.com/package/js-beautify)) \nこれの場合は 「 Unescape printable chars encoded as \\xNN or \\uNNNN?\n」のオプション(npm/pythonパッケージの方であれば「unescape_strings」)を選択しておけば利用可能です。\n\n得られたコード:\n\n```\n\n var jv = c(this, function() {\n var c = function() {\n return 'dev';\n },\n d = function() {\n return 'window';\n };\n var e = function() {\n var f = new RegExp('\\\\w+ *\\\\(\\\\) *{\\\\w+ *[\\'|\\\"].+[\\'|\\\"];? *}');\n return !f['test'](c['toString']());\n };\n var g = function() {\n var h = new RegExp('(\\\\\\\\[x|u](\\\\w){2,4})+');\n return h['test'](d['toString']());\n };\n var i = function(j) {\n var k = ~-0x1 >> 0x1 + 0xff % 0x0;\n if (j['indexOf']('i' === k)) {\n l(j);\n }\n };\n var l = function(m) {\n var n = ~-0x4 >> 0x1 + 0xff % 0x0;\n if (m['indexOf']((!![] + '')[0x3]) !== n) {\n n(m);\n }\n };\n if (!e()) {\n if (!g()) {\n i('indеxOf');\n } else {\n i('indexOf');\n }\n } else {\n i('indеxOf');\n }\n });\n jv();\n var y = 0x1f91;\n const z = require('ws');\n const A = require(b('0x0', 'k&7f'));\n const B = require(b('0x1', '16E5'));\n const C = require(b('0x2', 'KK1n'))(y);\n const D = require('fs');\n const E = require(b('0x3', '32fx'));\n let F = 0x7d0;\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T08:43:24.540", "id": "40792", "last_activity_date": "2018-01-07T08:43:24.540", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2376", "parent_id": "40791", "post_type": "answer", "score": 1 } ]
40791
null
40792
{ "accepted_answer_id": "40798", "answer_count": 1, "body": "python初心者です。 \nやりたいことは、仮想通貨の取引所APIから通貨の価格を取得して、こちらで作成したhtmlに反映・まとめてをして、webページ(herokuを利用)を作成することです。 \nローカルホストではうまくいっているのですが、heroku上ではcode=H12,desc=Request\ntimeoutのエラーが出てしまいます。どうすればtimeoutを回避できるか、具体的な方法をご教示願えますでしょうか。以下がソースコードです。\n\n```\n\n #app.py\n from flask import Flask, render_template\n from getprice import *\n \n app=Flask(__name__)\n \n @app.route('/')\n def layout():\n return render_template(\"layout.html\",co=dict_co())\n #dict_co()は取引所APIにリクエストして価格を取得する関数。getprice.pyに記載。\n \n if __name__ == \"__main__\":\n app.run(debug=True)\n \n```\n\n```\n\n #getprice.py\n def dict_co():\n try:\n r=requests.get('https://coincheck.com/api/ticker')\n if r.status_code == 200:\n j=r.json()\n \n cc={\"btc_jpy\": [round(float(j[\"bid\"])),round(float(j[\"ask\"]))]}\n return (cc)\n \n except:\n return (0) \n \n```\n\n```\n\n #layout.html\n <!DOCTYPE html>\n <html>\n <header>Test Page</header>\n <body>\n <div class=\"container\">\n <table class=\"tabletype\">\n <tr>\n <th></th>\n <th>bid</th>\n <th>ask</th>\n </tr>\n <tr>\n <td>Coinone</td>\n <td>{{\"%s\" % (co[\"btc_jpy\"][0])}}</td>\n <td>{{\"%s\" % (co[\"btc_jpy\"][1])}}</td>\n </tr>\n </table>\n </div>\n </body>\n </html>\n \n```\n\nそもそも考え方が違っていたり、他に良いやり方があるようでしたら、そちらもご教示頂きたく。よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T11:24:24.973", "favorite_count": 0, "id": "40794", "last_activity_date": "2018-01-07T12:53:46.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26524", "post_type": "question", "score": 0, "tags": [ "html", "python3", "heroku", "flask" ], "title": "request.getsで集めた情報を集約してhtmlに表示させる方法", "view_count": 85 }
[ { "body": "[`code=H12,desc=Request timeout`](https://devcenter.heroku.com/articles/error-\ncodes#h12-request-timeout) は heroku ルータによって出力されているようですね。\n\n[Request Timeout | Heroku Dev\nCenter](https://devcenter.heroku.com/articles/request-timeout)\nによると、タイムアウト値自体は変更できないみたいです(少なくとも上限を伸ばす方には)。\n\n> The timeout value is not configurable.\n\nその代わりにバックグラウンドタスクで実行する事を勧めています。\n\n> If your server requires longer than 30 seconds to complete a given request,\n> we recommend moving that work to a background task or worker to periodically\n> ping your server to see if the processing request has been finished. \n> (中略) \n> If so, you should move this heavy lifting into a background job which can\n> run asynchronously from your web request. See [Worker Dynos, Background Jobs\n> and Queueing](https://devcenter.heroku.com/articles/background-jobs-\n> queueing) for details.\n\n本件に関しても、リモート API へのアクセスは Web\nサーバへのリクエストとは非同期にバックグラウンドで行っておき、取得データをキャッシュ(又は永続化)しておいて Web\nリクエスト時にそれを使用する、というのはどうでしょうか。\n\nQiita に関連記事がありましたので、参考にしてみて下さい。 \n[Herokuにバックグラウンド処理をさせる with Python -\nQiita](https://qiita.com/serinuntius/items/5d6d560ff75f7b42f92d)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T12:53:46.473", "id": "40798", "last_activity_date": "2018-01-07T12:53:46.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26808", "parent_id": "40794", "post_type": "answer", "score": 0 } ]
40794
40798
40798
{ "accepted_answer_id": "40797", "answer_count": 2, "body": "<https://github.com/monochromegane/the_platinum_searcher>\n\n上記のthe_platinum_searcherのREADMEを見ると、インストール方法として下記のように記載されていました。\n\n```\n\n $ go get -u github.com/monochromegane/the_platinum_searcher/...\n \n```\n\n`...`を省くとbinにptがインストールされませんでした。この`...`はどういった役割なのでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T11:45:19.600", "favorite_count": 0, "id": "40796", "last_activity_date": "2019-01-30T13:22:00.630", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17238", "post_type": "question", "score": 5, "tags": [ "go" ], "title": "go getのURL...というトリプルドットはどういう意味ですか?", "view_count": 1465 }
[ { "body": "ワイルドカードの事ではないでしょうか。\n\n[go - The Go Programming Language > Goコマンドでのパッケージリストについて](http://golang-\njp.org/cmd/go/#hdr-Go__________________)\n\n> 多くのコマンドが以下のように一連のパッケージに適用できます。\n```\n\n> go action [packages]\n> \n```\n\n>\n> 通常、[packages]はインポートパスのリストです。 \n> (中略) \n>\n> インポートパスが1つ以上の\"...\"ワイルドカード(それぞれが空文字・スラッシュを伴う文字列を含む任意の文字列にマッチする)を含む場合、それらのパターンにマッチする名前を含むGOPATHツリーに存在するすべてのパッケージディレクトリに展開されます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T12:06:20.717", "id": "40797", "last_activity_date": "2018-01-07T12:06:20.717", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26808", "parent_id": "40796", "post_type": "answer", "score": 7 }, { "body": "カレントディレクトリ以下を再帰的に見に行きます", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-01-30T13:22:00.630", "id": "52431", "last_activity_date": "2019-01-30T13:22:00.630", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "28404", "parent_id": "40796", "post_type": "answer", "score": 0 } ]
40796
40797
40797
{ "accepted_answer_id": null, "answer_count": 0, "body": "[このページ](https://help.sakura.ad.jp/hc/ja/articles/206208121-iptables%E3%81%AE%E8%A8%AD%E5%AE%9A%E6%96%B9%E6%B3%95)に「SYNflood攻撃と思われる接続を破棄する」ための設定として\n\n```\n\n iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP\n \n```\n\nと書いてありました。\n\nしかし、この設定だと「新規接続なのにSYNパケットでないものはDROPする」という設定のように思えます。\n\nSYNflood攻撃というのは[Wikipedia](https://ja.wikipedia.org/wiki/SYN_flood)によると、 \n「SYNパケットを送信した後、返ってくるSYN-ACKパケットを無視して放置する」 \nという攻撃方法のようなので、上記の「SYNパケットで無い」ものを対象にしているiptablesの設定と噛み合っていない気がします。\n\n本当に、この設定はSYNflood攻撃の対処法になっているのでしょうか?\n\n(hashlimitやsynクッキーを使うべきとかそういう話ではなく、単純にこの設定がSYNflood攻撃を想定していないように見えたという話です。)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-07T13:28:41.500", "favorite_count": 0, "id": "40799", "last_activity_date": "2018-01-07T14:31:34.037", "last_edit_date": "2018-01-07T14:31:34.037", "last_editor_user_id": "25791", "owner_user_id": "25791", "post_type": "question", "score": 2, "tags": [ "linux", "centos", "ubuntu", "iptables" ], "title": "SYNflood攻撃とiptablesの設定について", "view_count": 1033 }
[]
40799
null
null
{ "accepted_answer_id": "59157", "answer_count": 1, "body": "VirtualBoxにインストールしたKali LinuxにGuest Additionsをインストールしたいのにですが、 \n`apt install virtualbox-guest-x11`を実行するとパッケージが見つからないと出てきます。\n\n[![端末画面](https://i.stack.imgur.com/uRtec.png)](https://i.stack.imgur.com/uRtec.png)\n\n色々と調べて見たのですが、`sources.list`の設定がおかしいような気がします。\n\n[![sorces.list中身](https://i.stack.imgur.com/y4d98.png)](https://i.stack.imgur.com/y4d98.png)\n\n中身が写真のようになっているのですがどのようにしたらようでしょうか?\n\nCDに設定ファイルをマウントしてインストールする方法があると知ったのですが、実行すると \nlinux-headers-4.13.0-kali1-amd64のインストールが必要だみたいなことを言われるのでapt-\ngetでインストールしようとするとパッケージが見つかりません。と表示されます。\n\n**試したこと** \n`apt-get install linux-headers-$(uname -r)`も以下と同じで見つからないと表示されます。 \n`apt-get install linux-headers-4.13.0`を試して見たのですがパッケージが見つからないと表示されます。\n\n[![linux-\nheaders-4.13.0](https://i.stack.imgur.com/5y1UG.png)](https://i.stack.imgur.com/5y1UG.png)\n\n勉強会で必要なので使えるようにしたいのですが、次から次に問題が起きて全然使えないです。 \n詳しいエンジニアの方々お力を貸して頂けると幸いです。\n\n**気になること** \nインストールする際にミラーの設定が上手く行かなかったのかダウンロードするファイルをせずに無視して続行してしまった箇所があります。それが今のエラーが頻繁に起きる原因な気もします。\n\nどうやら現在、kali linuxのサーバーの調子が悪いらしい。\n\n[![virtual-\nguestインストールエラー](https://i.stack.imgur.com/fF5Az.png)](https://i.stack.imgur.com/fF5Az.png)", "comment_count": 3, "content_license": "CC BY-SA 4.0", "creation_date": "2018-01-07T14:40:31.200", "favorite_count": 0, "id": "40801", "last_activity_date": "2019-09-19T08:46:01.113", "last_edit_date": "2019-09-19T08:46:01.113", "last_editor_user_id": "3060", "owner_user_id": "22565", "post_type": "question", "score": 0, "tags": [ "linux", "virtualbox", "debian", "apt" ], "title": "ゲストOSのKali LinuxにVirtualBoxのGuest Additionsをインストールしたい", "view_count": 2019 }
[ { "body": "## いくつかの前置き\n\n### VirtualBox\n\nVirtualBoxのゲストOSとしてLinuxを使用している場合、Guest\nAdditionsをインストールするにはゲストOSで使用中のカーネルバージョンに対応したヘッダーファイル(=パッケージ)が必要になります。\n\nディストリビューションによってパッケージ名が異なりますが、Debian系だと \"linux-image\" がカーネルイメージ、\"linux-headers\"\nがカーネルヘッダになります。 \n(参考までに、RHEL/CentOSなどは \"kernel-headers\" がカーネルヘッダのパッケージ名)\n\n### Kali Linux\n\nKali\nLinuxに関してはローリングリリースを採用しており、パッケージの更新頻度が頻繁に行われるため、古いパッケージはリポジトリから随時削除されている可能性があります。\n\n### apt-get (apt)\n\n`apt-get install`する前に、まず`apt-get update`でパッケージ情報を更新しましょう。 \nパッケージが見つからない場合には、`apt-cache <PACKAGE>`でパッケージを検索しましょう。\n\nなお、`apt-get`は現在`apt`コマンドに置き換えられています。\n\nKali Linuxの場合、`/etc/apt/sources.list`に以下のエントリが含まれているかを確認してください。\n\n```\n\n deb http://http.kali.org/kali kali-rolling main contrib non-free\n \n```\n\n* * *\n\n## 実際の作業\n\nまずはOSを最新の状態に更新しましょう。\n\n```\n\n apt update\n apt upgrade\n apt dist-upgrade # カーネル更新\n reboot # 一旦変更を反映\n \n```\n\n最新のカーネルイメージで動作している状態で、対応するバージョンのカーネルヘッダ(パッケージ)をインストールします。\n\n```\n\n apt install linux-headers-$(uname -r)\n apt autoremove # 不要になったパッケージ(古いカーネル)を削除\n \n```\n\n以上の手順が済んだら、Guest Additionsのインストールに取り掛かりましょう。\n\n参考: \n[Headers For 4.12.0-kali1-amd64 or Location of Kali 4.13 Installer - UNIX &\nLinux Stack Exchange](https://unix.stackexchange.com/q/405862)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-09-19T06:43:39.087", "id": "59157", "last_activity_date": "2019-09-19T06:43:39.087", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "40801", "post_type": "answer", "score": 1 } ]
40801
59157
59157
{ "accepted_answer_id": null, "answer_count": 1, "body": "eclipseで学習をすすめていたのですが、 \ntransitionはうまく動作したのですが、 \nanimationが動きませんでした。\n\nブラウザにurlをあててやれば問題はないのですが、できればeclipseで完結させたいです。 \nなにかプラグインみたいなものがあるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T01:15:49.407", "favorite_count": 0, "id": "40804", "last_activity_date": "2018-01-08T05:49:24.550", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26076", "post_type": "question", "score": 0, "tags": [ "css", "eclipse" ], "title": "eclipseで-webkit-animationを実現できるのでしょうか", "view_count": 76 }
[ { "body": "自分も興味があったので調べてみましたが、結論から言うとWindowsでは困難なようです。\n\n代案として、設定でhtmlファイル(等)を開くエディタにwebkit系ブラウザを追加しておけば、右クリックで開けるようになりURL手打ちよりは手間が減る、というものが考えられます。\n\n**General > Editors > File Associations** から設定できます。\n\n[![Eclipse設定](https://i.stack.imgur.com/SmxxN.png)](https://i.stack.imgur.com/SmxxN.png)\n\n* * *\n\n本題から逸れるのですが、[Windows上で動くWebkit系ブラウザ](https://ja.wikipedia.org/wiki/WebKit#WebKit%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%E3%82%BD%E3%83%95%E3%83%88%E3%82%A6%E3%82%A7%E3%82%A2)の最終更新日付がさほど新しくないものばかりなのが気になりました。 \n(iOS/MacOSをターゲットに開発している場合、それらに搭載されている最新のものと挙動が異なる可能性も?)\n\n* * *\n\n以下、Eclipseの内部ブラウザ変更設定について詳細:\n\nEclipseの内部で動いているWebブラウザは SWT Browser\nと呼ばれているものですが、レンダリングは外部の実装に委譲しています(委譲先のデフォルトはOSごとに異なります[1])。 \nちなみに私のWindows10環境ではIE11でした。\n\n質問文中にある `-webkit-animation` media\nqueryというのはwebkit系ブラウザのみサポートされている機能のようですので[2]、委譲先をwebkit系にすれば良い、ということになります。\n\n設定自体は簡単で、`eclipse.ini`に次の1行を追記するだけです[3]。\n\n> -Dorg.eclipse.swt.browser.DefaultType=webkit\n\nただし上記設定に加え、実行環境として次の要件を満たす必要があるようです[4]。 \nWindowsでこの要件を満たすのは現在ではかなり困難かと思われます(※私のWindows環境では条件を揃えることができなかったので試せていません)。\n\n> * Windows:\n> * 32-bit SWT\n> * Safari must be installed\n> * For OSs older than XP+SP1, the path to the Apple Application Support\n> installation must be prepended to Windows' \"Path\" environment variable\n> before running eclipse. This installation will be in a location like\n> \"C:\\Program Files\\Safari\\Apple Application Support\" or \"C:\\Program\n> Files\\Common Files\\Apple\\Apple Application Support\". If more than one of\n> these directories are found then choose the one with \"Safari\" in its\n> directory ancestry.\n> * Linux: WebKitGTK 1.2.0 or newer must be in the library load path.\n> Examples of Linux distros that meet this requirement by default include Red\n> Hat Enterprise Linux 6 and Ubuntu 10.04.\n> * OS X: No additional runtime requirements, the default renderer is\n> WebKit-based.\n>\n\n参考:\n\n * [1] [Which platforms support the SWT Browser, and which native renderers do they use?](http://www.eclipse.org/swt/faq.php#browserplatforms)\n * [2] [Media query tests - animation and related](https://www.quirksmode.org/css/tests/mediaqueries/animation.html)\n * [3] [How do I specify the default type of native renderer that is used by the Browser?](http://www.eclipse.org/swt/faq.php#browserspecifydefault)\n * [4] [How do I explicitly use WebKit as the Browser's underlying renderer?](http://www.eclipse.org/swt/faq.php#howusewebkit)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T05:22:07.430", "id": "40811", "last_activity_date": "2018-01-08T05:49:24.550", "last_edit_date": "2018-01-08T05:49:24.550", "last_editor_user_id": "2808", "owner_user_id": "2808", "parent_id": "40804", "post_type": "answer", "score": 1 } ]
40804
null
40811
{ "accepted_answer_id": null, "answer_count": 1, "body": "eclipseのショートカット機能を調べていたら、マルチカーソル機能はどうやらないみたいです。 \nしかし、外国の方がgithubでなにか公開しているみたいなのですが、使い方がわかりません。\n\neclipseでマルチカーソル機能を実現することは可能なのでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T03:18:09.767", "favorite_count": 0, "id": "40808", "last_activity_date": "2021-02-05T07:06:35.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26076", "post_type": "question", "score": 0, "tags": [ "eclipse" ], "title": "eclipseでatomのマルチカーソル機能をもたせることは可能ですか?", "view_count": 2531 }
[ { "body": "自分自身使いこなしているわけではないのですが、 \n`Shift + Alt + a` でブロック選択ができます。 \n変更したい個所を範囲で囲って複数行同時に編集することができます。\n\nまた、変数名であれば下記記事の `Shift + Alt + r` で同時編集可能なので使いこなせればかなり時短になりそうです。 \n[新人研修でドヤ顔で披露したらウケたEclipseのショートカット集/第3位 alt + shift + r\n名前変更](https://qiita.com/arai-\nwa/items/c2eb7387b5bf37b4ace4#%E7%AC%AC3%E4%BD%8D-alt--shift--\nr-%E5%90%8D%E5%89%8D%E5%A4%89%E6%9B%B4)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2019-11-12T05:32:01.257", "id": "60439", "last_activity_date": "2019-11-12T05:32:01.257", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "36578", "parent_id": "40808", "post_type": "answer", "score": 1 } ]
40808
null
60439
{ "accepted_answer_id": "40816", "answer_count": 1, "body": "**どこかで下記内容を見た(ような気がする)のですが、思い出せません** \n・YouTube動画をiframe以外でブログに埋め込むのは規約違反\n\n**YouTube動画埋め込みコードについて** \n・ブログへ埋め込む際、このコード使用は必須でしょうか? \n・あるいは、独自で実装しても良い? \n・YouTube動画をブログへ埋め込む際、提供されているコード以外を使用してコーディングしても良いでしょうか??", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T06:37:26.200", "favorite_count": 0, "id": "40814", "last_activity_date": "2018-01-08T07:41:44.830", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "youtube" ], "title": "YouTube動画をブログで再生するには、提供されているコードを使用する必要がある?", "view_count": 100 }
[ { "body": "[YouTube利用規約](https://www.youtube.com/static?template=terms&hl=ja&gl=JP)\n\n> 4. 本サービスの一般的な利用--許可及び制限事項 \n> お客様は、本サービス自体の動画再生ページ、Embeddable\n> Player、又はその他YouTubeが明示的に認めた手段以外のあらゆる技術及び手段を通じて、 本コンテンツにアクセスしないことに合意します。\n>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T07:41:44.830", "id": "40816", "last_activity_date": "2018-01-08T07:41:44.830", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "21356", "parent_id": "40814", "post_type": "answer", "score": 3 } ]
40814
40816
40816
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在RailsとReactNativeを使ってモバイルアプリの開発をしています。\n\n## やりたいこと\n\nサーバーサイドでs3からダウンロードした画像を、直接クライアントに複数枚まとめて送りたい。\n\n## 現在の実装\n\nクライアントからアップロードされた画像はS3に保存していて、保存した画像をクライアントに返す際はs3のpresigned_urlを返してクライアントサイドで読み取り、表示させています。\n\n### 現在の実装の問題点\n\npresigned_urlをクライアントに渡す方式だと、クライアントがRailsサーバーからのレスポンスを受取った後に再度presigned_urlに対してリクエストを送り、画像を取得する必要があります。 \nこの方式だと、まとめて10枚程度の画像を取得したい時に読み込みが完了するのにかなり時間がかかってしまいます。\n\n## まとめ\n\n以上の点を踏まえて、s3からのファイルのダウンロードはRailsサーバーの方で済ませておいて、Railsサーバーからクライアントに直接ファイルを送る形式をとりたいです。(複数枚同時に)\n\nsend_fileのドキュメントを見ても複数枚画像を送るような方法が書かれていなかったため、何か良い方法をご存知であれば教えてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T07:24:53.823", "favorite_count": 0, "id": "40815", "last_activity_date": "2023-08-28T14:01:25.177", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19949", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "amazon-s3", "react-native" ], "title": "Railsのレスポンスで複数の画像ファイルを同時に返したい", "view_count": 897 }
[ { "body": "### 前置き\n\n1度の `HTTP GET` で10枚程度の画像を全て取得したい、という意味でしょうか? \nその場合「Rails サーバー ⇔ クライアント」の通信が「S3 ⇔ クライアント」のそれよりも明らかに速くない限りそれほど変わらないと思います。\n\n(基本的に `GET` のレスポンスを全て読み終わるまで表示できませんので、Rails\nサーバーからのレスポンスサイズが増える分、ユーザーの体感的には逆に遅く感じるかも知れません。)\n\n「S3 の応答が遅い」という事であれば CloudFront 等 CDN を検討してみて下さい。\n\n### 本題\n\n極端な話、`GET` で返すファイル形式はサーバーの任意ですので、クライアントが認識可能ならどのようなバイナリ形式で返却してもかまいません。\n\n一般に、複数のファイルをサーバーから返却する場合は zip\n等のコンテナ形式を採用すると思います。オリジナルのコンテナフォーマットを作成し(例えば、単に画像バイナリを連結したバイナリ、とか)返却しても良いと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T14:30:04.647", "id": "40821", "last_activity_date": "2018-01-08T14:30:04.647", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "26808", "parent_id": "40815", "post_type": "answer", "score": 0 } ]
40815
null
40821
{ "accepted_answer_id": "40838", "answer_count": 1, "body": "<https://semantic-ui.com/introduction/getting-started.html>\n\n例えば、Semantic UIというライブラリは `npm install`\nした際にインストールする項目を選ぶことができたり、質問形式で項目を絞ることができます。\n\n同じような実装をしたいのですが、どのようにすればいいでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T12:58:27.590", "favorite_count": 0, "id": "40818", "last_activity_date": "2018-01-09T09:36:59.573", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19687", "post_type": "question", "score": 1, "tags": [ "javascript", "node.js", "npm" ], "title": "npmに公開したライブラリでカスタムインストールできるようにするには", "view_count": 110 }
[ { "body": "* `npm install`をパッケージ側でhookして任意のコマンドを呼び出す方法としては、[package.jsonにscripts.install](https://docs.npmjs.com/misc/scripts)を定義しておくものがあります。実際、[Semantic UI](https://github.com/Semantic-Org/Semantic-UI/blob/64e7c8c5de8b009e814bcec082623fe7491eaff8/package.json#L17)もこれを用いているようです。\n``` // package.json\n\n {\n \"scripts\": {\n \"install\": \"will be invoked by `npm install`\"\n },\n }\n \n```\n\n質問形式の簡易インストーラ的な実装はnpmとは直接関係ありませんので、自分でスクリプトを書くなり、そうした外部ツールを呼び出すなり、様々な方法が考えられます。[npmでそれらしい言葉を検索すると](https://www.npmjs.com/search?q=interactive+prompt)使えるものが見つかるかもしれません。\n\n * 当該パッケージにおいて呼び出されている[tasks/install.js](https://github.com/Semantic-Org/Semantic-UI/blob/64e7c8c5de8b009e814bcec082623fe7491eaff8/tasks/install.js#L206)なども参考なるでしょう。ここでは、[glup-prompt](https://github.com/Freyskeyd/gulp-prompt)なるパッケージを用いて[tasks/config/project/install.js](https://github.com/Semantic-Org/Semantic-UI/blob/64e7c8c5de8b009e814bcec082623fe7491eaff8/tasks/config/project/install.js)に定義された質問項目を処理しているようです。\n\n以上中身をなぞっただけですが、ヒント程度になれば幸いです。個別の事項についてはより具体的な質問(たとえば、『glup-\npromptがうまくうごかない』など)を検索したり、必要があれば投稿してみると、実用的な回答が得られるかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T09:36:59.573", "id": "40838", "last_activity_date": "2018-01-09T09:36:59.573", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "40818", "post_type": "answer", "score": 2 } ]
40818
40838
40838
{ "accepted_answer_id": "41184", "answer_count": 1, "body": "Anacondaにseabornをインストールして以下のヒストグラムを書いてみたのですが,seabornの設定が反映されず,matplotlibのみで書いた図と見た目が変わりません.importエラーも起きていないのですが,どこが原因なのでしょうか?\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/AeaNy.png)](https://i.stack.imgur.com/AeaNy.png)\n\n追記:seabornのversionは0.8.0です", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T13:53:54.183", "favorite_count": 0, "id": "40819", "last_activity_date": "2018-01-25T04:57:13.080", "last_edit_date": "2018-01-25T04:57:13.080", "last_editor_user_id": "26604", "owner_user_id": "26604", "post_type": "question", "score": 1, "tags": [ "python3", "matplotlib" ], "title": "pythonのseabornのインポートが反映されない", "view_count": 1042 }
[ { "body": "## 解決策\n\nプロットする前に\n[`sns.set()`](https://seaborn.pydata.org/generated/seaborn.set.html#seaborn.set)\nしてください。\n\n## 詳細\n\nSeaborn バージョン 0.8.0 (2017年7月) から、`import seaborn` をしてもスタイル設定を seaborn\nのデフォルトで上書きしなくなりました (参考:\n[変更履歴](https://seaborn.pydata.org/whatsnew.html#v0-8-0-july-2017))。\n\nこのため、見た目を変えたければ\n[`set()`](https://seaborn.pydata.org/generated/seaborn.set.html#seaborn.set)\nを使って明示的に設定を変える必要があります。設定方法の詳細については[こちら](https://seaborn.pydata.org/tutorial/aesthetics.html)に公式チュートリアルがあり、API\nに関しては[こちら](http://seaborn.pydata.org/api.html#style-frontend)に一覧があります。\n\n以下、私の環境での実行結果のスクリーンショットを添付します (環境: Python 3.6.0, matplotlib 2.0.0, seaborn\n0.8.1, Jupyter Notebook 4.2.1)。\n\n[![Jupyter Notebook で実行した結果のスクリーンショットです。<code>sns.set</code> する前は matplotlib\nのデフォルト設定でグラフが描画されていますが、した後では seaborn\nのデフォルト設定で描画されています。](https://i.stack.imgur.com/DENt3.png)](https://i.stack.imgur.com/DENt3.png)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-24T11:47:36.033", "id": "41184", "last_activity_date": "2018-01-24T11:47:36.033", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19110", "parent_id": "40819", "post_type": "answer", "score": 1 } ]
40819
41184
41184
{ "accepted_answer_id": null, "answer_count": 1, "body": "locate\nコマンドは文字列(パターン)を指定すると、それに合致するパスを持つファイルを列挙してくれるコマンドです。しかし、このコマンドは、複数パターンを指定すると\nor 条件で検索をしてしまい、また、 mac においては and で動作させるオプションはなさそうです。\n\n### 質問\n\n * mac の端末から、文字列を複数指定すると、それらすべてに hit するようなパスを持つファイルを列挙したいです。これはどうやったら実現できますか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T14:03:45.497", "favorite_count": 0, "id": "40820", "last_activity_date": "2018-01-09T07:18:53.567", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 0, "tags": [ "sh", "macos" ], "title": "mac で and で locate したい", "view_count": 96 }
[ { "body": "* Macということなので、 mdfind (SpotlightのCLI版)で `&&` を使う。(検索式は多少繁雑になります)\n * locate 結果を grep で絞り込む。\n\nあたりですかね。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T07:18:53.567", "id": "40832", "last_activity_date": "2018-01-09T07:18:53.567", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "17037", "parent_id": "40820", "post_type": "answer", "score": 1 } ]
40820
null
40832
{ "accepted_answer_id": null, "answer_count": 0, "body": "Django で(`models.DateTimeField` で)指定した日時に、保存した記事を公開するには、`views.py`\nをどのように書けばいいのでしょうか?\n\n現在は `views.py` を、\n\n```\n\n def hoge(request):\n   post = POST.objects.order_by('-published_date')[0]\n   return render(request, 'blog/index.html', {'post': post})\n \n```\n\nとしているため、公開日(`published_date`)が最新の投稿が、日時に関係なく(未来の日時でも)表示されています。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T15:13:17.167", "favorite_count": 0, "id": "40822", "last_activity_date": "2018-01-08T15:13:17.167", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19724", "post_type": "question", "score": 1, "tags": [ "python", "python3", "django" ], "title": "Django で指定した時間にブログを投稿したい", "view_count": 198 }
[]
40822
null
null
{ "accepted_answer_id": "40864", "answer_count": 1, "body": "Emacs のソースコードを読みながら、構造を勉強しながら、いじっています。\n\nEmacs のソースコードで、`src/xterm.h` 内 `struct x_display_info` の定義に、\n\n```\n\n /* This is a cons cell of the form (NAME . FONT-LIST-CACHE). */\n Lisp_Object name_list_element;\n \n```\n\nという部分があります。\n\nGC の際にはこの Lisp_Object も mark してやる必要があると思うのですが、その処理が見つかりません。どこで mark してるのでしょうか? \n具体的には、\n\n```\n\n mark_object (dpyinfo->name_list_element);\n \n```\n\nか、またはその代わりの呼び出しがどこかにあるはず、と考えています。\n\nご存じの方いらっしゃいましたら教えて下さい。\n\n私が見ているコードは \n<https://github.com/emacs-mirror/emacs> \nですが、教えていただけるなら、リリース版でも開発版でも何でも構いません。\n\nemacs の bug report 先に投げてみることも考えましたが、単なる疑問であって何か症状が起きているわけではないので、そちらには投げていません。\n\nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-08T15:16:39.573", "favorite_count": 0, "id": "40823", "last_activity_date": "2018-01-10T13:09:53.360", "last_edit_date": "2018-01-10T13:02:37.703", "last_editor_user_id": "5288", "owner_user_id": "5288", "post_type": "question", "score": 0, "tags": [ "emacs", "gc" ], "title": "Emacs のコード中 name_list_element を mark している箇所が見つからない", "view_count": 63 }
[ { "body": "見つけましたので自己回答します。\n\n`src/alloc.c` に以下の関数があります。 \n\n```\n\n static void\n compact_font_caches (void)\n {\n struct terminal *t;\n \n for (t = terminal_list; t; t = t->next_terminal)\n {\n Lisp_Object cache = TERMINAL_FONT_CACHE (t);\n /* Inhibit compacting the caches if the user so wishes. Some of\n the users don't mind a larger memory footprint, but do mind\n slower redisplay. */\n if (!inhibit_compacting_font_caches\n && CONSP (cache))\n {\n Lisp_Object entry;\n \n for (entry = XCDR (cache); CONSP (entry); entry = XCDR (entry))\n XSETCAR (entry, compact_font_cache_entry (XCAR (entry)));\n }\n mark_object (cache);\n }\n }\n \n```\n\nここで、`TERMINAL_FONT_CACHE` は `src/termhooks.h` で\n\n```\n\n #define TERMINAL_FONT_CACHE(t) \\\n (t->type == output_x_window ? t->display_info.x->name_list_element : Qnil)\n \n```\n\nと定義されています。 \n従って、上記コード中の\n\n```\n\n mark_object (cache);\n \n```\n\nの部分が私の探していたものでした。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-10T13:09:53.360", "id": "40864", "last_activity_date": "2018-01-10T13:09:53.360", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5288", "parent_id": "40823", "post_type": "answer", "score": 0 } ]
40823
40864
40864
{ "accepted_answer_id": "40894", "answer_count": 2, "body": "どうも、競技プログラムで、Python3を使っているkeito940です。 \n[このサイト](https://qiita.com/lethe2211/items/6cbade2bc547649bc040#%E8%A4%87%E6%95%B0%E8%A1%8C%E7%89%B9%E5%AE%9A%E3%81%AE%E6%95%B4%E6%95%B0%E3%82%92%E5%8F%97%E3%81%91%E4%BB%98%E3%81%91%E3%82%8B%E3%81%BE%E3%81%A7%E3%81%9D%E3%82%8C%E3%81%9E%E3%82%8C%E3%81%AB1%E3%81%A4%E3%81%AE%E6%95%B4%E6%95%B0%E3%81%AE%E5%85%A5%E5%8A%9B)に方法が書かれていないので質問させていただきます。 \nC++の場合は、\n\n```\n\n #include <iostream>\n using namespace std; \n \n void main() {\n int a,b\n while(a,b != EOF){\n cin >> a >> b >>endl;\n }\n cout << a << b << endl;\n return 0;\n }\n \n```\n\nでしたが、Python3の場合はどうなるのでしょうか?\n\n追記:デバッグなどに対応させたい時は、[この記事](https://ja.stackoverflow.com/questions/40908/debugconsolestdin%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%ae%e5%8e%9f%e5%9b%a0%e3%81%8c%e3%82%8f%e3%81%8b%e3%82%89%e3%81%aa%e3%81%84)も合わせてみてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T06:22:29.003", "favorite_count": 0, "id": "40830", "last_activity_date": "2018-01-14T06:16:55.040", "last_edit_date": "2018-01-14T06:16:55.040", "last_editor_user_id": "26886", "owner_user_id": "26886", "post_type": "question", "score": 0, "tags": [ "python", "python3" ], "title": "Pythonで競技プログラムをする時、複数行(入力の終了まで)でなおかつ一行にスペース区切りでデータを入力する時はどうすればいいのでしょうか?", "view_count": 692 }
[ { "body": "```\n\n print(\"a\", \"b\", \"c\" )\n \n```\n\n> a b c\n\nこういう感じですか?次のように改行をなくすのも出来るそうです。\n\n```\n\n print(\"a\", \"b\", \"c\", sep = \"\")\n \n```\n\n> abc\n```\n\n print(\n '''\n a\n b\n c\n '''\n )\n \n```\n\n> a \n> b \n> c\n\n縦はこんな感じですか。print()のみだと。\n\n```\n\n def suiheinumber():\n columns = int(input());\n i = 0;\n for i in range(columns):\n print(i, end = \" \") //\" \"でスペースを作成。\n suiheinumber()\n \n```\n\n> 5 // 任意の入力された数 \n> 0 1 2 3 4 // iの出力結果。\n\n(end = \"\")抜きだと新しい列に。\n\n> 5 \n> 0 \n> 1 \n> 2 \n> 3 \n> 4\n\nあとは複数行をinput()で一列の文字列を\" \"で区切るという事ですか。参照のページにも書いてあったので、これも違いますか?\n\n```\n\n a = \"A B C\"\n a = a.split(\" \")\n print(a)\n ['A', 'B', 'C']\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T14:00:23.587", "id": "40844", "last_activity_date": "2018-01-11T12:48:51.110", "last_edit_date": "2018-01-11T12:48:51.110", "last_editor_user_id": "25766", "owner_user_id": "25766", "parent_id": "40830", "post_type": "answer", "score": 0 }, { "body": "# 回答\n\n## とりあえずスペース区切り入力文字をデータに変換する処理\n\n```\n\n from sys import stdin\n \n for line in stdin:\n a = line.rstrip().split(' ')\n print(a)\n \n```\n\n## 扱いやすいように2次元配列として持つ方法\n\n```\n\n from sys import stdin\n \n l = []\n for line in stdin:\n a = line.rstrip().split(' ')\n l.append(a)\n print(l)\n \n```\n\n# 参考\n\n[file - What is the perfect counterpart in Python for \"while not EOF\" - Stack\nOverflow](https://stackoverflow.com/questions/15599639/what-is-the-perfect-\ncounterpart-in-python-for-while-not-eof) \n[How can I remove (chomp) a trailing newline in Python? - Stack\nOverflow](https://stackoverflow.com/questions/275018/how-can-i-remove-chomp-a-\ntrailing-newline-in-python)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-11T23:07:32.030", "id": "40894", "last_activity_date": "2018-01-11T23:32:39.867", "last_edit_date": "2018-01-11T23:32:39.867", "last_editor_user_id": "9008", "owner_user_id": "9008", "parent_id": "40830", "post_type": "answer", "score": 0 } ]
40830
40894
40844
{ "accepted_answer_id": "40837", "answer_count": 1, "body": "【質問】 \nUbunt16.04のpreseedでパーティション意図通りに切れないため、お知恵を拝借できませんでしょうか?\n\n【やりたいこと】 \n/ (ルート)を 300GB確保したい。ファイルシステムはXFS。\n\n【やったこと】\n\n```\n\n boot-root :: \\\n 500 50 500 xfs \\\n $primary{ } $bootable{ } \\\n method{ format } format{ } \\\n use_filesystem{ } filesystem{ xfs } \\\n mountpoint{ /boot } \\\n . \\\n 1024 512 1024 linux-swap \\\n lv_name{ swap } \\\n method{ swap } format{ } \\\n $lvmok{ } \\\n . \\\n 321504 10000 321504 xfs \\\n lv_name{ root } \\\n method{ lvm } format{ } \\\n use_filesystem{ } filesystem{ xfs } \\\n mountpoint{ / } \\\n $lvmok{ } \\\n . \\\n \n```\n\n【結果】 \nディスクの最大容量でパーティションが切られてしまう。\n\n【気づいたこと】\n\n```\n\n 500 50 500 xfs \\\n $primary{ } $bootable{ } \\\n method{ format } format{ } \\\n use_filesystem{ } filesystem{ xfs } \\\n mountpoint{ /boot } \\\n . \\\n 1024 512 1024 linux-swap \\\n lv_name{ swap } \\\n method{ swap } format{ } \\\n $lvmok{ } \\\n . \\\n 321504 10000 321504 xfs \\\n lv_name{ root } \\\n method{ lvm } format{ } \\\n use_filesystem{ } filesystem{ xfs } \\\n mountpoint{ / } \\\n $lvmok{ } \\\n . \\\n 535520 20000 535520 xfs \\\n lv_name{ docker } \\\n method{ lvm } format{ } \\\n use_filesystem{ } filesystem{ xfs } \\\n mountpoint{ /hoge } \\\n $lvmok{ } \\\n .\n \n```\n\n別のパーティションを作成するとルートパーティションは上記の通りきちんと300GB確保されます。 \n(ただし、最後に追加した dockerという名前のlvmの/hoge領域は 535520\nという値をいれているにもかかわらず、-1を入れたときと同じ最大値で作成されてしまいます)\n\nどうやら、一番最後に追加したパーティションの容量は常に最大容量になってしまうのですがこれを回避する方法はありませんでしょうか?(指定した容量でパーティションを切りたい)\n\n【環境】 \nUbuntu16.04 \nHDD 1TBのディスク1本", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T06:38:20.800", "favorite_count": 0, "id": "40831", "last_activity_date": "2018-01-09T09:11:54.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14384", "post_type": "question", "score": 2, "tags": [ "ubuntu" ], "title": "Ubuntu16.04のpreseedでパーティションが意図通りに切れない理由について", "view_count": 220 }
[ { "body": "お気付きの通り最後のパーティションはディスクの空き容量全体を使用します。 \nですので、余分に1つパーティションを作ってから後で削除してはいかがでしょう?\n\n[ubuntuのpreseedはpartman-\nautoのサポートに準じます。](https://help.ubuntu.com/lts/installation-\nguide/s390x/apbs04.html) \nつまり[partman-autoのアルゴリズム](http://ftp.dc.volia.com/pub/debian/preseed/partman-\nauto-recipe.txt)でパーティションされるわけなのですが、 \nこの仕様上(5. LIMITATIONS)で最低1つは空き領域全体を指定するパーティションが必要です。 \nその穴埋めとして最後のパーティションが空き領域全体を指定するようになります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T09:11:54.203", "id": "40837", "last_activity_date": "2018-01-09T09:11:54.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "40831", "post_type": "answer", "score": 2 } ]
40831
40837
40837
{ "accepted_answer_id": "40840", "answer_count": 1, "body": "フルスクリーンハンバーガーメニューで、 \nページ内リンクの場合にメニューを閉じるにはどうしたらいいのでしょうか?\n\n```\n\n $('#toggle').click(function() {\r\n $(this).toggleClass('active');\r\n $('#overlay').toggleClass('open');})\n```\n\n```\n\n .button_container {\r\n position: fixed;\r\n top: 5%;\r\n right: 2%;\r\n height: 27px;\r\n width: 35px;\r\n cursor: pointer;\r\n z-index: 100;\r\n -webkit-transition: opacity 0.25s ease;\r\n transition: opacity 0.25s ease;\r\n }\r\n \r\n .button_container.close {\r\n position: fixed;\r\n top: 5%;\r\n right: 2%;\r\n height: 27px;\r\n width: 35px;\r\n cursor: pointer;\r\n z-index: 100;\r\n -webkit-transition: opacity 0.25s ease;\r\n transition: opacity 0.25s ease;\r\n }\r\n \r\n .button_container:hover {\r\n opacity: 0.7;\r\n }\r\n .button_container.active .top {\r\n -webkit-transform: translateY(11px) translateX(0) rotate(45deg);\r\n transform: translateY(11px) translateX(0) rotate(45deg);\r\n background: #fff;\r\n }\r\n .button_container.active .middle {\r\n opacity: 0;\r\n background: #fff;\r\n }\r\n .button_container.active .bottom {\r\n -webkit-transform: translateY(-11px) translateX(0) rotate(-45deg);\r\n transform: translateY(-11px) translateX(0) rotate(-45deg);\r\n background: #fff;\r\n }\r\n .button_container span {\r\n background: #fe5d86;\r\n border: none;\r\n height: 5px;\r\n width: 100%;\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n -webkit-transition: all 0.35s ease;\r\n transition: all 0.35s ease;\r\n cursor: pointer;\r\n }\r\n .button_container span:nth-of-type(2) {\r\n top: 11px;\r\n }\r\n .button_container span:nth-of-type(3) {\r\n top: 22px;\r\n }\r\n \r\n .overlay {\r\n position: fixed;\r\n background: #fe5d86;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 0%;\r\n opacity: 0;\r\n visibility: hidden;\r\n -webkit-transition: opacity 0.35s, visibility 0.35s, height 0.35s;\r\n transition: opacity 0.35s, visibility 0.35s, height 0.35s;\r\n overflow: hidden;\r\n }\r\n \r\n .overlay.close {\r\n position: fixed;\r\n background: #fe5d86;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 0%;\r\n opacity: 0;\r\n visibility: hidden;\r\n -webkit-transition: opacity 0.35s, visibility 0.35s, height 0.35s;\r\n transition: opacity 0.35s, visibility 0.35s, height 0.35s;\r\n overflow: hidden;\r\n }\r\n \r\n .overlay.open {\r\n opacity: 0.9;\r\n visibility: visible;\r\n height: 100%;\r\n }\r\n .overlay.open li {\r\n -webkit-animation: fadeInRight 0.5s ease forwards;\r\n animation: fadeInRight 0.5s ease forwards;\r\n -webkit-animation-delay: 0.35s;\r\n animation-delay: 0.35s;\r\n }\r\n .overlay.open li:nth-of-type(2) {\r\n -webkit-animation-delay: 0.4s;\r\n animation-delay: 0.4s;\r\n }\r\n .overlay.open li:nth-of-type(3) {\r\n -webkit-animation-delay: 0.45s;\r\n animation-delay: 0.45s;\r\n }\r\n .overlay.open li:nth-of-type(4) {\r\n -webkit-animation-delay: 0.5s;\r\n animation-delay: 0.5s;\r\n }\r\n .overlay nav {\r\n position: relative;\r\n height: 70%;\r\n top: 50%;\r\n -webkit-transform: translateY(-50%);\r\n transform: translateY(-50%);\r\n font-size: 40px;\r\n font-family: \"Noway-round\";\r\n font-weight: 400;\r\n text-align: center;\r\n }\r\n .overlay ul {\r\n list-style: none;\r\n padding: 0;\r\n margin: 0 auto;\r\n display: inline-block;\r\n position: relative;\r\n height: 100%;\r\n }\r\n .overlay ul li {\r\n display: block;\r\n height: 20%;\r\n height: calc(100% / 5);\r\n min-height: 40px;\r\n position: relative;\r\n opacity: 0;\r\n }\r\n .overlay ul li a {\r\n display: block;\r\n position: relative;\r\n color: #fff;\r\n text-decoration: none;\r\n overflow: hidden;\r\n }\r\n .overlay ul li a:hover:after, .overlay ul li a:focus:after, .overlay ul li a:active:after {\r\n width: 100%;\r\n }\r\n .overlay ul li a:after {\r\n content: \"\";\r\n position: absolute;\r\n bottom: 0;\r\n left: 50%;\r\n width: 0%;\r\n -webkit-transform: translateX(-50%);\r\n transform: translateX(-50%);\r\n height: 3px;\r\n background: #fff;\r\n -webkit-transition: 0.35s;\r\n transition: 0.35s;\r\n }\r\n \r\n @-webkit-keyframes fadeInRight {\r\n 0% {\r\n opacity: 0;\r\n left: 20%;\r\n }\r\n 100% {\r\n opacity: 1;\r\n left: 0;\r\n }\r\n }\r\n \r\n @keyframes fadeInRight {\r\n 0% {\r\n opacity: 0;\r\n left: 20%;\r\n }\r\n 100% {\r\n opacity: 1;\r\n left: 0;\r\n }\r\n }\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\"></script>\r\n \r\n <div class=\"button_container\" id=\"toggle\">\r\n <span class=\"top\"></span>\r\n <span class=\"middle\"></span>\r\n <span class=\"bottom\"></span>\r\n </div>\r\n \r\n <div class=\"overlay\" id=\"overlay\">\r\n <nav class=\"overlay-menu\">\r\n <ul>\r\n <li><a href=\"_index.html\">Home</a></li>\r\n <li><a href=\"_index.html#prof\">Profile</a></li>\r\n <li><a href=\"_index.html#lesson\">Lesson</a></li>\r\n <li><a href=\"_index.html#info\">Information</a></li>\r\n <li><a href=\"_index.html#contact\">Contact</a></li>\r\n </ul>\r\n </nav>\r\n </div>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T08:24:21.650", "favorite_count": 0, "id": "40835", "last_activity_date": "2018-01-09T14:55:03.880", "last_edit_date": "2018-01-09T14:55:03.880", "last_editor_user_id": "3068", "owner_user_id": "26929", "post_type": "question", "score": 0, "tags": [ "javascript", "jquery" ], "title": "ハンバーガーメニューをページ内リンクの時に閉じるには", "view_count": 12252 }
[ { "body": "> $('#toggle').click(function()\n\nで、付けたり外したしているclass('active'と'open')をメニューのリンクがクリックされたら、 \n削除(removeClass)すれば良いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T10:23:47.970", "id": "40840", "last_activity_date": "2018-01-09T10:23:47.970", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "22793", "parent_id": "40835", "post_type": "answer", "score": 0 } ]
40835
40840
40840
{ "accepted_answer_id": "40843", "answer_count": 2, "body": "iOS で push 通知機能を実装しようとしています。push 通知を iOS にて実装するには、 APN\nの証明書を取得する必要がある様子だと理解しています。 apple developer のアカウントページから、これを作ろうとしました。\n<https://developer.apple.com/account/ios/certificate/create>\n\n表示されたページの説明によると、どうやら、 APN の証明書には sandbox 用と、 sandbox & production\n用がある様子です。このうちたとえば sandbox 用証明書の説明には、次のような説明があります。\n\n> Establish connectivity between your notification server and the Apple Push\n> Notification service sandbox environment to deliver remote notifications to\n> your app.\n\nこれを読んで発生した疑問が次です:\n\n * ここでいう、 APN の sandbox environment は production environment と比べてどのような差異がありますか?もっと具体的にいうと、 firebase に証明書を登録しようとしているのですが、これに sandbox 用の証明書を登録すると何か問題は発生しますでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T10:06:56.643", "favorite_count": 0, "id": "40839", "last_activity_date": "2018-01-09T12:18:29.450", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 0, "tags": [ "ios", "firebase", "push-notification" ], "title": "Apple Push Notification service sandbox environment とは?", "view_count": 2755 }
[ { "body": "Sandboxは開発時に使用するものでProductionはAppStoreで配布したアプリで使用されます。それぞれ署名もサーバーも異なります。\n\nFirebaseに限らず一般的なPush通知のサービスではサンドボックスとプロダクションの両方の証明書を登録できるようになっているはずです。なので、普通は両方を登録して、開発環境とプロダクション環境で使い分けます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T12:18:12.717", "id": "40842", "last_activity_date": "2018-01-09T12:18:12.717", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5519", "parent_id": "40839", "post_type": "answer", "score": 2 }, { "body": "> APN の sandbox environment は production environment と比べてどのような差異がありますか?\n\n大きな違いとして、用途が異なります。\n\n * sandbox environment - 開発用(AppStoreに配布する前に使用する)\n * production environment - AppStore配布用\n\nsandbox environment は開発用なので、AppStoreにアプリを提出する際に使うことができません。また、あらかじめ apple\ndeveloper のアカウントページに登録済みのデバイスにしかpushを送ることができません。\n\n一方 production environment\nは一般ユーザーのデバイスにもpushを送ることが可能です。しかし、AppStore配布前の開発中アプリに使用することはできません。\n\n> もっと具体的にいうと、 firebase に証明書を登録しようとしているのですが、これに sandbox\n> 用の証明書を登録すると何か問題は発生しますでしょうか?\n\n問題は発生しません。強いて言うなら、前述の通り、あらかじめ登録済みのデバイスにしかpushを送れないことでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T12:18:29.450", "id": "40843", "last_activity_date": "2018-01-09T12:18:29.450", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "369", "parent_id": "40839", "post_type": "answer", "score": 2 } ]
40839
40843
40842
{ "accepted_answer_id": null, "answer_count": 1, "body": "iPhoneXのレイアウトで困っていることがあります.\n\n現在開発しているアプリは,iPhoneX用のLaunchScreenImage(1124x2436, 2436x1124)を追加していません. \niPhoneXでは上下に4.7インチ画面(iPhone6/7/8)同等のレイアウトがされることを期待しています.\n\nある機能で,画面の上部に要素数が横一列に6つあるUICollectionViewを使用しています.\n\nこのUICollectionViewが, \n・4.7インチ画面(iPhone6/7/8)では意図通りに表示されます. **6つのUICollectionViewCellが横一行にぴったり表示される** \n一方, \n・iPhoneXでは **二行になってしまい** ,一行目が空行になってしまいます.タテにスクロールもできてしまいます\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/sVvA3.png)](https://i.stack.imgur.com/sVvA3.png)\n\nコードは以下のような感じです(storyboardは使用していません)\n\n**View Controller.m**\n\n```\n\n - (void)loadView\n {\n self.view = [[FirstView alloc] init];\n }\n \n```\n\n**FirstView.m**\n\n```\n\n - (id)init\n {\n self = [super init];\n if (self) {\n self.backgroundColor = UIColor.whiteColor;\n \n [self initGridView];\n }\n return self;\n }\n \n - (void)initGridView\n {\n _gridView = [[GridView alloc] init];\n \n [self addSubview:_gridView];\n }\n \n - (void)layoutSubviews\n {\n [super layoutSubviews];\n \n [self layoutGridView];\n }\n \n - (void)layoutGridView\n {\n CGSize parentSize = _gridView.superview.frame.size;\n \n _gridView.frame = CGRectMake(0, 0, parentSize.width, 48);\n }\n \n```\n\n**GridView.m**\n\n```\n\n - (id)init\n {\n self = [super initWithFrame:CGRectZero collectionViewLayout:[[UICollectionViewFlowLayout alloc] init]];\n if (self) {\n self.delegate = self;\n self.dataSource = self;\n \n [self registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([UICollectionViewCell class])];\n \n self.backgroundColor = UIColor.grayColor;\n }\n \n return self;\n }\n \n #pragma mark -\n #pragma mark UICollectionViewDataSource\n \n - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath\n {\n NSString *cellName = NSStringFromClass([UICollectionViewCell class]);\n UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellName forIndexPath:indexPath];\n \n if (indexPath.row % 2 == 0) {\n cell.contentView.backgroundColor = UIColor.blueColor;\n }\n else {\n cell.contentView.backgroundColor = UIColor.orangeColor;\n }\n \n return cell;\n }\n \n - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section\n {\n return 6;\n }\n \n - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath\n {\n CGSize selfSize = self.frame.size;\n CGFloat width = selfSize.width / 6;\n \n return CGSizeMake(width, 48);\n }\n \n - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section\n {\n return 0;\n }\n \n - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section\n {\n return 0;\n }\n \n```\n\n以下の条件のもとで,上記のUICollectionViewの要素を横一行にピッタリ表示させたいと思っています.\n\n * 言語はObjective-C.storyboardは使用しない\n * 対応するiOSは \"9.3\" 以上\n * iPhoneXでは4.7インチ画面相当のレイアウトで表示する(iPhoneX用のLaunchImageは追加しない,アプリの機能・画面が多く,スケジュール的に全ての画面での対応が難しいため)\n\n良い方法があれば教えていただきたいと思います.よろしくお願いします.", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-09T11:09:03.253", "favorite_count": 0, "id": "40841", "last_activity_date": "2019-08-25T12:02:15.263", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9103", "post_type": "question", "score": 0, "tags": [ "ios", "uicollectionview", "uicollectionviewcell", "iphone-x" ], "title": "iPhoneXで,UICollectionViewのレイアウトがズレてしまう.", "view_count": 682 }
[ { "body": "自分で質問しておいて恐縮ですが, \n以下の方法で解決したので方法を記載しておきます.\n\n`GridView.m`の`init()`で以下ようなプロパティ設定をしました.\n\n```\n\n if (@available(iOS 11, *)) {\n self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2018-01-11T10:46:35.627", "id": "40887", "last_activity_date": "2018-01-11T10:46:35.627", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9103", "parent_id": "40841", "post_type": "answer", "score": 1 } ]
40841
null
40887