question
dict
answers
list
id
stringlengths
2
5
accepted_answer_id
stringlengths
2
5
popular_answer_id
stringlengths
2
5
{ "accepted_answer_id": "20840", "answer_count": 1, "body": "実行環境はMAC OSX EL CAPITANでpyenvの上にanaconda2.4.0を導入したものです。 \nGPUはGeForceの下位モデルを搭載しており、CUDAは7.0です。\n\nChainerを用いてディープラーニングを行おうとしていますがうまく行きません。 \n<http://qiita.com/hogefugabar/items/312707a09d29632e7288>\nを参考に、データを読み込みクラス数、データ数をだすところまではうまくいきました。 \n参考ページと同じコード、データを用いCNN.pyとanimeface.pyとmain.pyの3つを同じディレクトリに置きました。main.pyを実行すると\n\n```\n\n AnimeFaceDataset instance has no attribute 'read_data_target'\n \n```\n\nのエラーが出ます。 \nちなみにmain.pyは\n\n```\n\n from CNN import CNN\n from animeface import AnimeFaceDataset\n from chainer import cuda\n \n #cuda.init(0)\n cuda.check_cuda_available()\n \n print 'load AnimeFace dataset'\n dataset = AnimeFaceDataset()\n dataset.read_data_target()\n data = dataset.data\n target = dataset.target\n n_outputs = dataset.get_n_types_target()\n \n cnn = CNN(data=data,\n target=target,\n gpu=0,\n n_outputs=n_outputs)\n \n cnn.train_and_test(n_epoch=100)\n \n```\n\nとcuda.init(0)をcuda.check_cuda_available()に書き換えてあります。\n\n参照ページの下にも別の方がした同じ質問が載っていますが、長らく答えられていないようです。わかる方がいらっしゃいましたらよろしくお願い致します。\n\n****追記**** \n無事解決しました。ありがとうございます。 \n今度は\n\n```\n\n cuda driver version is insufficient for cuda runtime version\n \n```\n\nのエラーが出て悩まされています。 \nいろいろ調べOpenCVのインストール、ドライバのアップデート、パス通し、ターミナルから実行などやりましたが効果なしです。 \n詳しい方いらっしゃいましたらよろしくお願いします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-11T17:30:38.843", "favorite_count": 0, "id": "20839", "last_activity_date": "2017-07-30T01:16:45.017", "last_edit_date": "2017-07-30T01:16:45.017", "last_editor_user_id": "19110", "owner_user_id": "12457", "post_type": "question", "score": 1, "tags": [ "python", "cuda", "chainer", "深層学習" ], "title": "ChainerによるDeep-Learning", "view_count": 586 }
[ { "body": "`AnimeFaceDataset`クラスを見てみると`read_data_target`ではなく`load_data_target`と定義されていますので、これで動くと思います。\n\n```\n\n dataset.load_data_target()\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T00:32:52.660", "id": "20840", "last_activity_date": "2016-01-12T00:32:52.660", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7214", "parent_id": "20839", "post_type": "answer", "score": 1 } ]
20839
20840
20840
{ "accepted_answer_id": null, "answer_count": 1, "body": "Excel VBAについての質問になります。 \n作成したマクロを実行した際に、「ダウンロード中」、「保存中」というダイアログが表示され、キャンセルボタンを押下しないと処理が進みません。(添付画像参照)\n\n以下の二点について、教えていただきたいです。\n\n * 「ダウンロード中」、「保存中」ダイアログが表示される原因(ソースに記載していない)\n * キャンセルボタンを押下しないと処理が進まない原因\n\n作成したマクロの処理、実行環境につきまして以下になります。\n\n#### 作成したマクロの処理内容\n\n 0. 比較させたいファイルを環境設定シートに記載。\n 1. 比較元ファイル、比較新規ファイルという2つのファイルを読み込みます。\n 2. 読み込んだファイルの値を確認し、特定の値をコピー\n 3. 新しいブックに貼り付け。\n 4. 新しいブックを保存して終了。\n 5. 0で設定したファイルをすべて処理するまで1~4を繰り返します。\n\n*比較元、比較新規ファイルはネットワークドライブ上に配置しています。 \nまた、保存先もネットワークドライブに保存するように指定しています。\n\n#### 環境情報\n\nOS:Windows7 32bit \nメモリ:4G \nソフト: Excel 2013 32bit\n\nダイアログ表示の原因につきまして、 \n比較元ファイル、比較新規ファイルをネットワークドライブ上に配置しているため、 \n「ダウンロード中」ダイアログが表示されてしまいます。 \nしかし、何度かマクロを実行したところ「ダウンロード中」ダイアログが表示されないこともあります。 \n「保存中」ダイアログも同様にネットワークドライブに比較結果ファイルを保存しているため、表示されます。 \n何度かマクロを実行したところ「保存中」ダイアログが表示されないこともあります。\n\n「ダウンロード中」ダイアログ\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/FBpro.png)](https://i.stack.imgur.com/FBpro.png)\n\n「保存中」ダイアログ\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/kS493.png)](https://i.stack.imgur.com/kS493.png)\n\n長文となって申し訳ありません。 \n以上です。 \nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2016-01-12T01:14:02.890", "favorite_count": 0, "id": "20842", "last_activity_date": "2023-02-28T09:03:25.433", "last_edit_date": "2022-02-15T02:53:50.960", "last_editor_user_id": "3060", "owner_user_id": "12912", "post_type": "question", "score": 1, "tags": [ "excel", "vba" ], "title": "マクロ実行時に表示されるダイアログで、キャンセルを押さないと処理が進まない", "view_count": 7564 }
[ { "body": "保存する際のPath名に問題はありませんか?\n\n・Path名が長すぎる \n・禁則文字が使用されている \n・サーバーとの接続に問題がある 等\n\nサーバーとの問題やPath名の長さを解消するため、試しに自分のPC内で処理を \n完結させてみてはいかがでしょう。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2022-02-15T02:30:25.850", "id": "86345", "last_activity_date": "2022-02-15T02:57:47.353", "last_edit_date": "2022-02-15T02:57:47.353", "last_editor_user_id": "3060", "owner_user_id": "51432", "parent_id": "20842", "post_type": "answer", "score": 0 } ]
20842
null
86345
{ "accepted_answer_id": null, "answer_count": 2, "body": "32bit版のインストーラーなどのファイル名には`x86`という文字がついていますが、これはなんなんですか?\n\n64bit版は`x64`なのに・・・", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T01:21:31.987", "favorite_count": 0, "id": "20843", "last_activity_date": "2016-01-12T01:52:18.487", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9149", "post_type": "question", "score": 12, "tags": [ "macos" ], "title": "なんで32bitはx86?", "view_count": 793 }
[ { "body": "x86とはインストールするプログラムが使用している命令セットの通称です。\n\nx86命令セットは正式にはIA-32という名前で、x86の名はIntelの8086および後継の80186、80286、80386、80486という「80x86」と総称されるCPUで採用されたことに由来しています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T01:47:36.547", "id": "20844", "last_activity_date": "2016-01-12T01:47:36.547", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "20843", "post_type": "answer", "score": 10 }, { "body": "i8086の流れを汲むIntelのCPUは、i8086, i80186, i80386 (通称 \"386\"), i486 のように末尾に \"86\"\nが付けられていたため、慣例的に \"x86\" アーキテクチャと呼ばれています。\n\nただし、最近では、32ビットアーキテクチャのみを指して \"x86\"\nと記載することが一般的です。(x64のCPUも32ビットアーキテクチャと互換性があり広義には \"x86\" に含まれます。)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T01:52:18.487", "id": "20845", "last_activity_date": "2016-01-12T01:52:18.487", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "76", "parent_id": "20843", "post_type": "answer", "score": 11 } ]
20843
null
20845
{ "accepted_answer_id": "20861", "answer_count": 2, "body": "VisualBasic(.NetFramework4.0)Windows10でプログラミングをしております。\n\nsystem.diagnostics.process.startでDOSプロンプト(CMD.EXE)を起動しその画面に表示されているテキストを取得(範囲選択&コピーでクリップボード保存)したく思いますが、WindowsAPIでどのような関数を使用すれば良いのか検討が付きません。\n\n起動したプロセスから取得したMainWindowHandleを対象とした、もしくは引数に取る関数ではないかと想像しているのですがご存知の方おられましたらお助けお願いできますでしょうか?\n\nよろしくお願いします。", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T05:30:31.143", "favorite_count": 0, "id": "20847", "last_activity_date": "2017-02-09T13:14:52.040", "last_edit_date": "2016-01-12T07:22:40.533", "last_editor_user_id": "8000", "owner_user_id": "10607", "post_type": "question", "score": 0, "tags": [ "vb.net", "winapi" ], "title": "VBで起動したDOSプロンプトに表示されているテキスト(表示内容)の取得方法", "view_count": 4415 }
[ { "body": "まず、テキストをどう保持してどう描画するかはアプリケーションによって様々ですから、「ウィンドウハンドルを渡せばウィンドウに表示されているテキストを取り出せる」といった汎用的なAPIは存在しません。\n\ncmd.exe\nをはじめとするコンソールアプリケーションの場合、例のウィンドウはWindowsが管理しているのでコンソールに表示されている文字を読み取るAPIもあります。ただし「現在のプロセスのコンソールウィンドウから読み取る」という形になるので、\n\n * `AttachConsole()` で対象のプロセス(cmd.exeなど)のコンソールウィンドウにアタッチし、\n * `GetStdHandle()` でスクリーンバッファのハンドルを取得し、\n * `GetConsoleScreenBufferInfo()` でスクリーンバッファの大きさを調べ、\n * `ReadConsoleOutputCharacter()` で任意の範囲の文字を読み取る\n\nという流れになります。別のプロセスから読み取る際には `FreeConsole()` で切り離したうえで、上記と同じことを繰り返します。\n\n参考: [コンソールへのアタッチ -\nEternalWindows](http://eternalwindows.jp/windevelop/console/console06.html)\n\n* * *\n\nただこの場合、出力されたという通知は受けられないので定期的に確認する必要がありますし、どこからどこまでが新しい出力なのかも自分で判別する必要があります。改行と折り返しの区別もつきません。\n\n「ボタンを押したらその時点での画面を取り込む」程度ならいいかもしれませんが、次のようなことをしたいなら標準入出力のリダイレクトの方が簡単かと思います。\n\n * 自作のアプリからコンソールアプリとやり取りしたい \n⇒ `process.StandardInput` に書き込んで `process.StandardOutput` から読みだす\n\n * やり取りが画面に表示されるようにしたい \n⇒ `StandardInput` `StandardOutput` を通る内容をテキストボックスなどに表示する\n\n * ユーザーがコマンドを打てるようにしたい \n⇒ テキストボックスにでも入力させて、 `StandardInput` に書き込む\n\n(コンソールAPIを直接叩くアプリや、[出力がリダイレクトされているかどうかで挙動を変えるアプリ](https://superuser.com/q/352490/423291)の場合は別ですが。)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T12:08:51.283", "id": "20861", "last_activity_date": "2016-01-12T12:08:51.283", "last_edit_date": "2017-03-20T10:04:44.677", "last_editor_user_id": "-1", "owner_user_id": "8000", "parent_id": "20847", "post_type": "answer", "score": 6 }, { "body": "ちょっと脱線しますが、こちらも参考になるかもしれません。\n\n>\n```\n\n> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As\n> System.EventArgs) Handles Button1.Click\n> Dim results As String\n> Dim psi As New System.Diagnostics.ProcessStartInfo()\n> \n> 'ComSpecのパスを取得する\n> psi.FileName = System.Environment.GetEnvironmentVariable(\"ComSpec\")\n> '出力を読み取れるようにする\n> psi.RedirectStandardInput = False\n> psi.RedirectStandardOutput = True\n> psi.UseShellExecute = False\n> 'ウィンドウを表示しないようにする\n> psi.CreateNoWindow = True\n> 'コマンドラインを指定(\"/c\"は実行後閉じるために必要)\n> psi.Arguments = \"/c ping 192.168.1.1\"\n> '起動\n> Dim p As System.Diagnostics.Process =\n> System.Diagnostics.Process.Start(psi)\n> '出力を読み取る\n> results = p.StandardOutput.ReadToEnd\n> '出力された結果を表示\n> TextBox1.Text = results\n> \n> 'WaitForExitはReadToEndの後である必要がある\n> '(親プロセス、子プロセスでブロック防止のため)\n> p.WaitForExit()\n> End Sub\n> \n```\n\nここから引用しました。 \n<http://soudan1.biglobe.ne.jp/qa5873147.html>\n\n参考になりそうなページ \n<http://dobon.net/vb/dotnet/process/standardoutput.html>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2017-02-09T11:42:41.930", "id": "32531", "last_activity_date": "2017-02-09T13:14:52.040", "last_edit_date": "2017-02-09T13:14:52.040", "last_editor_user_id": "4765", "owner_user_id": "20585", "parent_id": "20847", "post_type": "answer", "score": 0 } ]
20847
20861
20861
{ "accepted_answer_id": "20855", "answer_count": 1, "body": "```\n\n [(\"南口\",\"19:00:00\"),(\"北口\",\"20:00:00\"),(\"南口\",\"22:40:00\"),(\"北口\",\"23:50:00\")]\n \n```\n\nとなっている配列があり、\n\n現在時刻を\n\n```\n\n let now = NSDate()\n let formatter = NSDateFormatter()\n formatter.dateFormat = \"HH:mm:ss\"\n let string = formatter.stringFromDate(now)\n print(string)\n \n```\n\nでとります。\n\nその際に、タプルの中にある、現在時刻の次に来ると思われる指定時刻のindexを抽出したいのですが、いかんせんString型での大小比較ができなくて困っております。\n\n`subStringWithRange`や`subStringToIndex`などで、Stringの一部分をとって、\n\ntoInt()でInt型に変更し、(NSDate()でとった現在時刻も同時にtoInt型に変更して)大小比較を\"HH\"と\"mm\"で行って、index番号を抽出しようとしましたが、Int型に変えようとした時点でnilが表示されます。アンラップしてもダメみたいです。\n\nNSDate型での比較を試みていますが、いまいちいい解決案が出ません。 \nいい方法等があればご教授願えますでしょうか。\n\n[補足]24時以降の時刻に関してどうするのかという質問があったので補足させていただきます。 \n配列要素の指定時刻については24時以降は要素がない(存在しない)状態で考えております。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T06:17:58.683", "favorite_count": 0, "id": "20848", "last_activity_date": "2016-01-14T05:11:02.957", "last_edit_date": "2016-01-14T02:47:28.530", "last_editor_user_id": "7362", "owner_user_id": "12254", "post_type": "question", "score": 0, "tags": [ "ios", "swift", "swift2" ], "title": "配列で抽出したStringと現在時刻を比較して、現在時刻に一番近い配列要素のindexを抽出したい", "view_count": 1029 }
[ { "body": "時刻の比較、差分の取得は、やはり`NSDate`インスタンスにして行うのが妥当と思います。 \n文字列から、`NSDate`インスタンスを取得するには、メソッド`dateFromString()`を使います。 \n`\"19:00:00\"`を引数にして取得すると、日付の情報がないので、`NSDate`の基準である2000年1月1日の日付になってしまいますが、時刻だけの比較なので問題はありません。(24時以降の時刻をどうするのか、お尋ねしたのはこれが理由です) \n`timeIntervalSinceDate()`による差分は、`NSTimeInterval`型(`Double`のTypeAlias)となり、容易に演算ができます。 \n以下、Playgroundで実行できるサンプルコードです。実際に動かしてみてください。\n\n```\n\n import Foundation\n \n // 時刻のフォーマットを作成。\n let timeFormatter = NSDateFormatter()\n timeFormatter.dateFormat = \"HH:mm:ss\"\n \n // 現在時刻から文字列を作成。\n let nowString = timeFormatter.stringFromDate(NSDate())\n // 文字列からNSDateインスタンスを作成。2000年1月1日+現在時刻のインスタンスとなる。\n let nowTime = timeFormatter.dateFromString(nowString)!\n \n // ゲート名と時刻の配列。\n let gateArray: [(String, String)] = [(\"南口\",\"19:00:00\"),(\"北口\",\"20:00:00\"),(\"南口\",\"21:40:00\"),(\"北口\",\"23:50:00\")]\n // nowTimeとの差分を、別の配列に格納。\n // この箇所を修正。\n let intervalArray: [NSTimeInterval] = gateArray.map({(_, time) in\n // 時刻から、2000年1月1日+時刻のNSDateインスタンスを作成。\n let diff = timeFormatter.dateFromString(time)\n // nowTimeとの差分の絶対値を返す。\n return abs(nowTime.timeIntervalSinceDate(diff ?? nowTime)) // 注\n })\n // 最小値(現在時刻にいちばん近い値)を検索。\n let minimumTime = intervalArray.minElement() ?? 0.0\n // 配列上のインデックスを取得。\n if let minIndex = intervalArray.indexOf(minimumTime) {\n print(\"The nearest gate is \\(gateArray[minIndex].0). The time is \\(gateArray[minIndex].1)\")\n } else {\n print(\"Coudn't find any gate\")\n }\n \n```\n\nOptional型の処理で、ややヨレヨレしてしまいましたが、実践ではOptional Bindingを使って、安全なコードに仕上げたほうがいいでしょう。\n\n* * *\n\n注:Swiftは、C言語の標準ライブラリにある関数が、そのまま使えます。`import Darwin` or `import Foundation` or\n`import UIKit`するのが条件です。`abs()`以外の関数例えば`sin()`、`sort()`なども使えます。\n\n* * *\n\n**Tuple** について\n\nTupleを関数(メソッド、クロージャ)の引数にとる時`(gate, time)`のような書式にします。サンプルコード中では`(_,\ntime)`となっていますが、第1要素の方は使用しないので、`_`で省略しています。このアンダーバーは、SwiftではTuple以外の場面でよく使われますので、覚えておくといいでしょう。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T09:07:33.130", "id": "20855", "last_activity_date": "2016-01-14T05:11:02.957", "last_edit_date": "2016-01-14T05:11:02.957", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "20848", "post_type": "answer", "score": 0 } ]
20848
20855
20855
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在市販のアプリ教本を買って勉強しています。 \n信号に見立てたボタンを配置し、ボタンを押すことでラベルの文字が変わるという動きを \n作ろうとしているのですが、青、黄色のボタンはうまくできシミュレータでも動作が確認できたのに対し、赤のボタンはシミュレータでボタンを押すとシミュレータは落ちてしまい、\n\n```\n\n Error Thread ! : Breakpoint1.1\n \n```\n\nが表示されます。 \nThreadについてはよくわからなくてアシスタントエディタで接続を間違えたのかと思い、接続を切ってみたのですがよくわからなくなってしまいました。何か解決策があれば教えてください。\n\n```\n\n class ViewController: UIViewController {\n @IBOutlet weak var resultLabel: UILabel!\n \n @IBAction func blueBtnPushed(sender: AnyObject) {\n resultLabel.text = \"しんごうはあおいろ!\"\n resultLabel.textColor = UIColor.blueColor()\n }\n \n @IBAction func yellowBtnPushed(sender: AnyObject) {\n resultLabel.text = \"しんごうはきいろ!\"\n resultLabel.textColor = UIColor.yellowColor()\n }\n \n @IBAction func redBtnPushed(sender: AnyObject) {\n resultLabel.text = \"しんごうはあかいろ!\"\n resultLabel.textColor = UIColor.redColor()\n }\n }\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T07:02:36.147", "favorite_count": 0, "id": "20849", "last_activity_date": "2016-11-06T14:42:35.000", "last_edit_date": "2016-09-23T12:24:43.563", "last_editor_user_id": "5519", "owner_user_id": "13961", "post_type": "question", "score": 0, "tags": [ "swift" ], "title": "Error Thread ! : Breakpoint1.1と表示される原因について", "view_count": 188 }
[ { "body": "コメントより\n\n> sugawaraさんありがとうございました。接続は完全に切られてはいませんでした。ご迷惑おかけしました。\n> Takahiroさんありがとうございました。リンク先の情報を参考にし、breakpointを削除してみたところ正常に動く‌​ようになりました。\n> お二方ともお世話になりました。 – kobocchan\n\nbreakpointが意図しないところに貼られていたようです", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-11-06T14:42:35.000", "id": "30143", "last_activity_date": "2016-11-06T14:42:35.000", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "15185", "parent_id": "20849", "post_type": "answer", "score": 1 } ]
20849
null
30143
{ "accepted_answer_id": null, "answer_count": 1, "body": "IE11において、以下のようにHTML内に直接記述したSVGのスケーリングが、他のブラウザと異なります。\n\n```\n\n #svg {\r\n width: 80%;\r\n \r\n background-color: #DDD;\r\n }\n```\n\n```\n\n <svg viewBox=\"0 0 430 330\" id=\"svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n <circle cx=\"100\" cy=\"100\" r=\"100\" fill=\"red\" />\r\n <rect x=\"130\" y=\"130\" width=\"300\" height=\"200\" fill=\"blue\" />\r\n </svg>\n```\n\nFirefox, Chrome, Edgeなどでは横幅に合わせてアスペクト比を保持したままスケーリング(縦幅を自動で調節)しますが、 \nIEにおいては縦幅が固定になってしまいます。\n\nIEにて、横幅に合わせてアスペクト比を保持したまま、縦幅を自動で調節させたいのですが、良い方法はないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T07:41:31.757", "favorite_count": 0, "id": "20853", "last_activity_date": "2016-03-13T05:08:43.773", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7227", "post_type": "question", "score": 6, "tags": [ "html", "css", "svg" ], "title": "IEにおいて、SVGをHTML内に直接記述した場合、他のブラウザと大きさが異なる", "view_count": 1182 }
[ { "body": "[asamuzaK.jp : ♪Vector Vector, please. Oh, the mess I'm in (c)\nUFO](http://asamuzak.jp/html/483)を参照し、以下のようにwidthに応じてheightを計算し設定するjavascriptを書くことで解決しました。\n\n_(実際に使用する場合は、IEのみに適用されるよう、if (document.documentMode)などで条件をつける必要があります。)_\n\n```\n\n function resize_svg_width(elem) {\r\n function getAspect(o) {\r\n var y = o.split(' ');\r\n return y[3] / y[2];\r\n }\r\n \r\n z = document.defaultView.getComputedStyle(elem, '').width;\r\n a = z.match(/([0-9\\.]+)px/)[1] * 1;\r\n b = getAspect(elem.getAttribute('viewBox'));\r\n elem.style.height = (a * b) + 'px';\r\n }\r\n \r\n var resize_event = function() {\r\n var target = document.getElementById(\"svg\");\r\n \r\n resize_svg_width(target);\r\n }\r\n \r\n window.addEventListener('resize', resize_event, false);\r\n resize_event();\n```\n\n```\n\n svg {\r\n width: 80%;\r\n \r\n background-color: #DDD;\r\n }\n```\n\n```\n\n <svg viewBox=\"0 0 430 330\" id=\"svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" id=\"svg\">\r\n <circle cx=\"100\" cy=\"100\" r=\"100\" fill=\"red\" />\r\n <rect x=\"130\" y=\"130\" width=\"300\" height=\"200\" fill=\"blue\" />\r\n </svg>\n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T12:43:53.480", "id": "20863", "last_activity_date": "2016-01-13T03:34:15.513", "last_edit_date": "2016-01-13T03:34:15.513", "last_editor_user_id": "7227", "owner_user_id": "7227", "parent_id": "20853", "post_type": "answer", "score": 1 } ]
20853
null
20863
{ "accepted_answer_id": null, "answer_count": 1, "body": "<https://dev.mysql.com/doc/refman/5.6/ja/replication-howto-masterstatus.html>\n\n上記のURLを参考にレプリケーションを進めていますが、以下のコマンドを打てと書いてありました。このコマンドを打つと現在稼働しているマスターサーバーの読み込みができなくなってしまいます。\n\n```\n\n FLUSH TABLES WITH READ LOCK;\n \n```\n\nマスターサーバーを無停止でレプリケーションを行いたいと思っておりますが、いい方法を教えていただけませんか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T09:01:33.787", "favorite_count": 0, "id": "20854", "last_activity_date": "2016-04-13T13:11:58.930", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7641", "post_type": "question", "score": 0, "tags": [ "mysql" ], "title": "MySQLでレプリケーションする際にマスターを無停止で行いたい", "view_count": 127 }
[ { "body": "無停止はわかりませんが 座標を確認したらすぐに `UNLOCK TABLES;` を実行してロックを開放すると元に戻ります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T10:48:51.047", "id": "20918", "last_activity_date": "2016-01-14T10:48:51.047", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "20854", "post_type": "answer", "score": 1 } ]
20854
null
20918
{ "accepted_answer_id": "20859", "answer_count": 2, "body": "`.NET\nFramework`は長い間`zip`アーカイブに対応せず、[4.5になって対応](https://web.archive.org/web/20151011175756/http://blogs.msdn.com:80/b/japan_platform_sdkwindows_sdk_support_team_blog/archive/2012/03/27/net-\nzip.aspx)しました。 \n[System.IO.Compression](https://docs.microsoft.com/ja-\njp/dotnet/api/system.io.compression?view=netframework-4.5)という名前空間は、[4.0以前](https://docs.microsoft.com/ja-\njp/dotnet/api/system.io.compression?view=netframework-4.0)はさみしい状況でした。\n\nこの経緯には何か理由があるのでしょうか。MSにとって、技術的・政治的・特許ほか、大人の事情で実装しない理由があったのであれば、教えて下さい。非公開なのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2016-01-12T10:16:18.980", "favorite_count": 0, "id": "20857", "last_activity_date": "2022-05-23T12:48:39.010", "last_edit_date": "2022-05-23T12:48:39.010", "last_editor_user_id": "4236", "owner_user_id": "2238", "post_type": "question", "score": 7, "tags": [ ".net" ], "title": ".NETが4.5になってzipアーカイブに対応した理由", "view_count": 1108 }
[ { "body": ".NET 4.5はWindows 8と同時期に開発されています。そしてWindows\n8からエクスプローラーにてZIPファイルに含まれるファイル名のUnicode対応がされています。(ZIP仕様がUnicodeに対応したのは2006年。Windows\n7ではこのフラグを無視してANSIコードと見なす。[KB2704299](https://support.microsoft.com/ja-\njp/kb/2704299)にてHotfixを提供。)\n\nここからは勝手な推測ですが、.NETではUnicode対応が必須なわけですが、いざUnicodeエンコーディングのZIPファイルを作成してもエクスプローラーで文字化けするので、この問題が解消されるのを待っていたというのも1つの要因かもしれません。\n\n* * *\n\n.NET 4.5以前は\n\n * J# Runtimeのjava.util.zip.ZipInputStreamを使ったり\n * DeflateStreamクラスに「このクラスは本来、.zip アーカイブとの間でファイルの追加や抽出を行うための機能を提供するものではありません。」と書かれていたり\n * System.IO.Packagingでzipファイルを扱えるのになぜpublicにしてくれないんだ\n\nとかいろいろありましたね。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T10:39:19.707", "id": "20859", "last_activity_date": "2016-01-12T10:48:35.597", "last_edit_date": "2016-01-12T10:48:35.597", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "20857", "post_type": "answer", "score": 14 }, { "body": "[開発チームのブログ](https://blogs.msdn.microsoft.com/bclteam/2010/07/29/more-on-zip-\nin-net-richard-\nlee/)によると、インターンのメンバーが配属期間で実現できる程度の機能をZipArchiveに実装したという旨の記述があります。また2007年の記事ですでにZIP対応予定が表明されていますので、人員の都合が付いたから低優先度の課題を片付けたというところではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T15:01:17.510", "id": "20865", "last_activity_date": "2016-01-12T15:32:07.410", "last_edit_date": "2016-01-12T15:32:07.410", "last_editor_user_id": "5750", "owner_user_id": "5750", "parent_id": "20857", "post_type": "answer", "score": 2 } ]
20857
20859
20859
{ "accepted_answer_id": "20862", "answer_count": 1, "body": "storyboardの遷移でエラーが出ます。調べても解決しなかったため、質問させて頂きます。\n\n<<目的>> \nViewControllerからListViewControllerへ遷移させたい。\n\n<<失敗箇所>> \nViewControllerのs.instantiateViewControllerWithIdentifierの行\n\n<<エラー内容>> \nUnknown class LlistViewController in Interface Builder file. \nCould not cast value of type 'UITableViewController' (0x1082ed7f8) to\n'ListViewController' (0x1051a7f40).\n\n尚、ListViewController.storyboardのStoryboardIDには ListViewControllerと設定している\n\n<<詳細>>\n\nViewController.swift\n\n```\n\n func onClick() {\n let s = UIStoryboard(name: \"ListViewController\", bundle: nil)\n let vc = s.instantiateViewControllerWithIdentifier(\"ListViewController\") as! ListViewController\n self.navigationController?.pushViewController(vc, animated: true)\n \n }\n \n```\n\nListViewController.swift\n\n```\n\n import Foundation\n import UIKit\n \n class ListViewController: UITableViewController, UITextViewDelegate {\n \n @IBOutlet weak var image: UIImageView!\n @IBOutlet weak var label_title: UILabel!\n \n override func viewDidLoad() {\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n }\n \n }\n \n```\n\n[![ListViewController.storyboardの画面](https://i.stack.imgur.com/EKS0B.png)](https://i.stack.imgur.com/EKS0B.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T11:59:08.963", "favorite_count": 0, "id": "20860", "last_activity_date": "2016-01-12T22:16:28.937", "last_edit_date": "2016-01-12T22:16:28.937", "last_editor_user_id": "8044", "owner_user_id": "13175", "post_type": "question", "score": 1, "tags": [ "ios", "swift" ], "title": "storyboardの遷移でエラーが出ます。(segueを使用しない方法で実装)", "view_count": 5037 }
[ { "body": "_Unknown class LlistViewController in Interface Builder file. \nCould not cast value of type 'UITableViewController' (0x1082ed7f8) to\n'ListViewController' (0x1051a7f40)._ \n私が今まで見た全ての事例でこのようなエラーが出た場合には、1つの例外もなく100%がStoryboardへのCustomClassの設定ミスでした。\n\n_尚、ListViewController.storyboardのStoryboardIDには ListViewControllerと設定している_ \nStoryboardIDというのは、複数のオブジェクトを区別するためにつける単なる目印となる文字列ですので、それと生成されるクラスとは関係ありません。\n\n問題は画面写真でStoryboard IDの上に写っているこの内容の部分です。 \n**Custom Class** \nClass [ListViewController] \nModule [None]\n\nStoryboardからインスタンスを作成する場合に、NibLoaderは\"ListViewController\"と言う正式名称を持つクラスを探しに行きますが、あなたのプロジェクトの中にはそんな名前のクラスはないので、Storyboardに貼り付けられた部品の属性から最も適当と思われるクラス(今回の場合UITableViewController)のインスタンスを作ります。ところが、それをListViewControllerに強制キャストしようとしているので、そこでキャスト落ちしているわけです。\n\nSwiftで書いたクラスの正式名称(Javaで言うところのFQCN)には、(@objcなどを付加しない限り)クラス名の前にモジュール名が入り、\"{ProductModuleName}.ListViewController\"と言った感じになります。つまり、自分がSwiftで書いたクラスをstoryboard中に指定する場合には、Moduleの部分をNoneにしてはいけません。\n\nStoryboardの該当部分を修正し、Moduleの部分を正しく指定して実行しなおしてみてください。(あるいは、`@objc(クラス名)`と言ったアノテーションを付加して、モジュール名のない`クラス名`を正式のクラス名にしてしまうという手もあります。)", "comment_count": 7, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T12:31:46.000", "id": "20862", "last_activity_date": "2016-01-12T12:31:46.000", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "20860", "post_type": "answer", "score": 2 } ]
20860
20862
20862
{ "accepted_answer_id": null, "answer_count": 1, "body": "unityでUGUIを使ってandroidアプリを作成しています\n\n主にUIデザインについて\n\n・androidには様々な端末があるので、解像度、アスペクト比を考慮すると \n全ての端末に合わせて作成するべきか、もしくは利用率の高い端末を優先するべきか\n\n・例えばandroidの端末が5:3 800x480 なら 最適なアスペクト比、解像度はいくらか\n\n・また、unityでgameviewを800x480と設定しても using resolutionとでて800x480とは \n違う数字になるが、解像度には影響があるか", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-12T14:57:34.023", "favorite_count": 0, "id": "20864", "last_activity_date": "2016-01-18T07:01:42.753", "last_edit_date": "2016-01-17T18:47:48.530", "last_editor_user_id": "9268", "owner_user_id": "9268", "post_type": "question", "score": 0, "tags": [ "android", "c#", "unity3d" ], "title": "android解像度最適化", "view_count": 668 }
[ { "body": "> ・また、unityでgameviewを800x480と設定しても using resolutionとでて800x480とは \n> 違う数字になるが、解像度には影響があるか\n\nusing resolution は、GameViewを縮小表示してるときに実際に表示してる大きさが出てるだけです。サイズを\n800x480と設定しているのであれば実際は 800x480で処理されてるので解像度には影響ありません。\n\n> ・例えばandroidの端末が5:3 800x480 なら 最適なアスペクト比、解像度はいくらか\n\nAndroidの解像度最適化については、ゲームやアプリごとに最適な方法が違ってくるので、一概に「この方法が最適である」というのは存在しないと思っています。\n\nなので、方法は決めてしまって、それに対する質問をしたら良いかと思います。\n\n・5:3 アスペクト比を維持したまま端末の画面にできるだけ大きく表示したい \n・画面解像度を 800x480 基準に作成して、android実機に拡大表示したい \n・UIパーツの解像度は固定で、どの端末の解像度にも適切に配置したい", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T07:01:42.753", "id": "21028", "last_activity_date": "2016-01-18T07:01:42.753", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2079", "parent_id": "20864", "post_type": "answer", "score": 3 } ]
20864
null
21028
{ "accepted_answer_id": "20870", "answer_count": 1, "body": "失礼します。いつもお世話になっております。\n\nHTMLでJSONデータ所得を作成途中なのですがあと一歩のところで躓いております。\n\n上記のHTMLでsubmitすると \n「curl -i -v -H \"Accept: application/vnd.glv.v1+json\" -H \"Content-type:\napplication/json\" -X GET localhost:8280/api/test_accesses -d\n'{\"dept_ids\":[\"000002\"]}'」\n\nというリクエストが送られ望んだデータも返却されます。上記のHTMLに \n「~ '{\"dept_ids\":[\"000002\"],\n**\"start_date\":\"20151001\",\"end_date\":\"20151207\"}'** 」\n\nとリクエストを送るようにしたいのですがどの部分を修正すればいいかわからず、ご存知の方に教えていただきたいと思いました。 \n追記する\"start_date\":\"20151001\",\"end_date\":\"20151207\"}'の日付部分はテキストボックスを作成して好きな年月を入れられるようにと考えております。\n\n```\n\n $(function(){\r\n $(\"#response\").html(\"Response Values\");\r\n \r\n $(\"#button\").click( function(){\r\n var url = $(\"#url_post\").val();\r\n var dept_ids = [$(\"#dept_ids\").val()];\r\n \r\n var JSONdata = {};\r\n JSONdata.dept_ids = dept_ids;\r\n \r\n $.ajax({\r\n url : url\r\n , type : \"POST\"\r\n , data : JSON.stringify(JSONdata)\r\n , contentType: \"application/json;charset=UTF-8\"\r\n , processData: false\r\n , dataType : \"json\"\r\n , accepts : {json: \"application/vnd.glv.v1+json;charset=UTF-8\"}\r\n , crossDomain: false\r\n }).done(function(data, status, xhr) {\r\n // 通信成功時の処理\r\n // alert(\"成功\");\r\n $(\"#response\").html(JSON.stringify(data));\r\n }).fail(function(xhr, status, error) {\r\n // 通信失敗時の処理\r\n alert(\"失敗\");\r\n }).always(function(arg1, status, arg2) {\r\n // 通信完了時の処理\r\n // alert(\"完了\");\r\n });\r\n })\r\n })\n```\n\n```\n\n <h1>HTMLファイルからPOSTでJSONデータを送信</h1>\r\n <p>URL: <input type=\"text\" id=\"url_post\" name=\"url\" size=\"100\" value=\"http://52.192.178.185:8280/api/test_accesses\"></p>\r\n <p>value1: <input type=\"text\" id=\"dept_ids\" size=\"30\" value=\"000002\"></p>\r\n <p><button id=\"button\" type=\"button\">submit</button></p>\r\n <textarea id=\"response\" cols=120 rows=10 disabled></textarea>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T00:39:55.893", "favorite_count": 0, "id": "20869", "last_activity_date": "2016-01-13T01:11:39.090", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13072", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "json", "ajax" ], "title": "作成途中のHTMLでJSONデータ所得作成を完成させたいです。", "view_count": 360 }
[ { "body": "`<p>value1: <input type=\"text\" id=\"dept_ids\" size=\"30\"\nvalue=\"000002\"></p>`にならって書けば問題ないかと思いましたが、JavaScript内で、`var dept_ids =\n[$(\"#dept_ids\").val()];`と、テキストボックスから値を取得されていましたので、これにならって書くとすると。\n\n```\n\n <input type=\"text\" id=\"dept_ids\" size=\"30\" value=\"000002\">\n <input type=\"text\" id=\"start_date\" size=\"30\" value=\"\">\n <input type=\"text\" id=\"end_date\" size=\"30\" value=\"\">\n \n```\n\nと入力項目を用意し、JavaScriptにて、\n\n```\n\n var start_date = $(\"#start_date\").val();\n var end_date = $(\"#end_date\").val();\n \n```\n\nとした次のところでJSONデータを作っていますので、\n\n```\n\n var JSONdata = {};\n JSONdata.dept_ids = dept_ids;\n JSONdata.start_date = start_date;\n JSONdata.end_date = end_date;\n \n```\n\nとすれば良いのではないでしょうか。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T01:11:39.090", "id": "20870", "last_activity_date": "2016-01-13T01:11:39.090", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5778", "parent_id": "20869", "post_type": "answer", "score": 0 } ]
20869
20870
20870
{ "accepted_answer_id": null, "answer_count": 0, "body": "いま木構造でそれぞれのノードでGoroutineを作成し、ある処理を行い更に下位のノードのGoroutineをそのGoroutineで起動するようなプログラムを作成しています。そこで問題は、あるノードの下に、これまでに別のGoroutineで辿ったノードが出てきてしまう場合です。同じノードのしたには100%同じ木構造が構築される状況なので、そのすでに辿ったノードの下にはすでに別のGoroutineにより辿ったノードがあるので、無駄な処理になってしまいます。 \nそこで、すでに調べたノードを記憶して後からそのノード以下を辿らないようにしたいです。この場合スライスを用いて、すでに辿ったノードの識別子を登録し、それぞれのGoroutineで参照し、一致しなければ下位ノードのGoroutineを起動するようにしましたがこれがうまくできません。この場合はどのような方法が考えられますか。\n\n以下に検証に用いたサンプルプログラムを示します。\n\n```\n\n package main\n \n import \"math/rand\"\n import \"time\"\n import \"fmt\"\n \n var alpha =[]string{\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\"}\n \n func main() {\n c := make(chan string)\n s := make([]string, 0, len(alpha))\n for i:=0; i<3; i++{\n go routine(s, c)\n }\n \n for{\n res := <-c\n s = append(s, res)\n if len(s) == len(alpha){\n break\n }\n }\n \n for _, v := range s{\n fmt.Println(v)\n }\n }\n \n func routine(s []string, ch chan string){\n c := random()\n for _,v := range s{\n if v == c{\n return\n }\n }\n ch <- c\n for i:=0;i<3;i++{\n go routine(s,ch)\n }\n }\n \n func random()string{\n rand.Seed(time.Now().UnixNano())\n return alpha[rand.Intn(len(alpha))]\n }\n \n```\n\n**結果**\n\n```\n\n C\n H\n M\n I\n L\n D\n L\n F\n I\n I\n K\n K\n H\n \n```\n\nここでは対象のデータは木構造になっていないです。 \nこのようにすでに出てきたものもスライスに保存されてしまいます。さらに実際に作成しようとしているコードでは、木構造全体のノード数(ここではABC...)が未知数なので、Sliceを用いた方法はできないと考えられます(capなしのappendは新しいアドレスを確保するため)。\n\nこの場合どのようにして、すでに辿ったノードを判断すればいいのでしょうか。", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T02:08:14.197", "favorite_count": 0, "id": "20871", "last_activity_date": "2016-01-13T02:08:14.197", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "go" ], "title": "循環してしまう木構造をGoroutineで処理したい。", "view_count": 164 }
[]
20871
null
null
{ "accepted_answer_id": "20885", "answer_count": 1, "body": "PEARライブラリを使ってマルチパートメールを送信したいと考えております。\n\n参考サイト:<http://www.phpbook.jp/pear/pear_mail/index9.html>\n\nところが題名と本文のところで、文字化けが起こってしまいます。\n\n```\n\n <?php\n \n require_once(\"Mail.php\");\n require_once(\"Mail/mime.php\");\n \n $params = array(\n \"host\" => \"mailsvr-01.local\",\n \"port\" => 587,\n \"auth\" => false\n \n );\n \n $mailObject = Mail::factory(\"smtp\", $params);\n \n $recipients = \"[email protected], [email protected]\";\n \n $body = \"テストです。\";\n $body = mb_convert_encoding($body, \"ISO-2022-JP\", \"auto\");\n \n $mimeObject = new Mail_Mime(\"\\n\");\n $mimeObject -> setTxtBody($body);\n \n $bodyParam = array(\n \"head_charset\" => \"ISO-2022-JP\",\n \"text_charset\" => \"ISO-2022-JP\"\n );\n \n $body = $mimeObject -> get($bodyParam);\n \n $addHeaders = array(\n \"To\" => \"[email protected]\",\n \"From\" => \"[email protected]\",\n \"Subject\" =>mb_encode_mimeheader(\"テストメール\")\n );\n \n $headers = $mimeObject -> headers($addHeaders);\n \n $mailObject -> send($recipients, $headers, $body);\n \n \n ?>\n \n```\n\n受け取っメールを表示すると、下記のようになります。\n\n```\n\n [root@mailsvr-01 new]# cat 1452663570.Vfd00Ic3784M864173.mailsvr-01.local\n Return-Path: <[email protected]>\n X-Original-To: [email protected]\n Delivered-To: [email protected]\n Received: from localhost (mailcli-01.local [192.168.100.40])\n by mailsvr-01.local (Postfix) with ESMTP id C27E8A388D;\n Wed, 13 Jan 2016 14:39:30 +0900 (JST)\n MIME-Version: 1.0\n Content-Type: text/plain; charset=ISO-2022-JP\n Content-Transfer-Encoding: quoted-printable\n To: [email protected]\n From: [email protected]\n Subject: =?UTF-8?B?w6PCg8KGw6PCgsK5w6PCg8KIw6PCg8Khw6PCg8K8w6PCg8Kr?=\n \n =1B$B%F%9%H$G$9!#=1B(B\n [root@mailsvr-01 new]#\n \n```\n\nどこの設定を見直せばよいかご教授いただけますでしょうか。\n\n以上、お手数ですがよろしくお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T05:28:39.400", "favorite_count": 0, "id": "20875", "last_activity_date": "2016-01-13T12:43:43.550", "last_edit_date": "2016-01-13T09:25:30.107", "last_editor_user_id": "8000", "owner_user_id": "13426", "post_type": "question", "score": 0, "tags": [ "php", "postfix" ], "title": "PEARライブラリを使ってメール送信を行った際の文字化け", "view_count": 2353 }
[ { "body": "まず、本文が一件訳の分からない文字列になっているのは正しい挙動です。元々の電子メールの規格では件名や本文にASCII文字以外を使うことは想定されておらず、その枠組みの中で他の言語を書く際にはASCII文字だけになるよう符号化して送ることとされました。その符号化を行った結果が\n\n```\n\n =1B$B%F%9%H$G$9!#=1B(B\n \n```\n\nなので、これは問題ありません。メールソフトを通せば正しく日本語で表示されます。\n\n一方、件名はその符号化(MIMEエンコード)が正しく行われていません。\n\n[`mb_encode_mimeheader()`](http://php.net/manual/ja/function.mb-encode-\nmimeheader.php) でその処理を行っているのですが、この関数は `mb_internal_encoding()`\n等で設定される内部エンコーディングから ISO-2022-JP や UTF-8\nへの変換を行い、ヘッダ用の符号化を行います。質問に記載された送信結果から推測するに、この `mb_internal_encoding()`\nが正しく指定されていないため、意図せぬ文字コード変換が行われています。\n\n基本的に [`mb_internal_encoding()`](http://php.net/manual/ja/function.mb-internal-\nencoding.php) にはソースコードの文字コードを指定します。加えて、日本語圏のメールソフトの慣習に合わせて処理を行うために、\n[`mb_language()`](http://php.net/manual/ja/function.mb-language.php)\nも設定しておくとよいでしょう。\n\nまとめると、mb_**系の関数を呼び出す前に以下の二行を実行します。\n\n```\n\n mb_internal_encoding('UTF-8'); // もし違う文字コードであれば変更してください\n mb_language('ja');\n \n```\n\nなお、これらの設定は php.ini でも行うことができます。\n\n参考: [日本語利用の為の設定(mbstring) - php.iniの設定 -\nPHPインストールと初期設定](http://www.phpbook.jp/install/phpini/index5.html#section2)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T12:43:43.550", "id": "20885", "last_activity_date": "2016-01-13T12:43:43.550", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "20875", "post_type": "answer", "score": 0 } ]
20875
20885
20885
{ "accepted_answer_id": "20895", "answer_count": 2, "body": "ラベルの更新をしたいのですが、1つの関数で2回更新したいのですがsleepのような時間の要する関数を使ってもラベルのテキストは更新されないのです。それは、mainloopの最後に到達したときに更新されるからかなと考えたのですが、更新させる方法はありますでしょうか?\n\n以下のコードは直面した問題を抽象化したものです。sleepは時間のかかる処理とでも置き換えてください。実際にこのコードを実行すると、この問題に直面すると思います。\n\n```\n\n from Tkinter import *\n import time\n \n class Window:\n def __init__(self):\n self.flg = False\n self.root = Tk()\n self.txt = StringVar()\n Button(self.root, text=\"test\", command=self.changeLabel).pack()\n self.txt.set(\"hoge\")\n Label(self.root, textvariable=self.txt).pack()\n \n def changeLabel(self):\n self.txt.set(\"hogehoge\")\n time.sleep(2) # sleepのような時間のかかる処理がしたい\n self.txt.set(\"hogehogehoge\")\n \n if __name__ == '__main__':\n w = Window()\n w.root.mainloop()\n \n```\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T05:46:44.797", "favorite_count": 0, "id": "20876", "last_activity_date": "2016-01-14T06:41:55.390", "last_edit_date": "2016-01-14T03:07:09.943", "last_editor_user_id": "2521", "owner_user_id": "13818", "post_type": "question", "score": 4, "tags": [ "python", "tkinter" ], "title": "Tkinterでのラベルの更新", "view_count": 15530 }
[ { "body": "change_label()を呼び出すと`self.text`は実際に\"hogehoge\"になりますが、TkはそのLabel\nwidgetをもう一回表示するチャンスがない、なぜなら機能復帰がこないから。\n\n`sleep(2)`のすぐ前に`print`をすると端末で確認できます\n\n```\n\n class Window:\n def __init__(self):\n self.flg = False\n self.root = Tk()\n self.text = StringVar()\n self.text.set('spam')\n self.button = Button(self.root,\n text = 'test',\n command = self.change_label)\n self.button.pack()\n self.label = Label(self.root, textvariable = self.text)\n self.label.pack()\n \n def change_label(self):\n self.text.set('BACON')\n print self.text.get()\n time.sleep(2) # 機能復帰はまだですね…\n self.text.set('eggs')\n \n if __name__ == '__main__':\n w = Window()\n w.root.mainloop()\n \n```\n\n端末では:\n\n```\n\n ceverett@changa:~/Code/python/tk$ ./tk_label.py \n BACON\n \n```\n\n`change_label()`を呼び出したが機能復帰をTkのmainloopにくるまでは画面(Tk Window)がマヒします\n\n```\n\n def change_label(self):\n if self.text.get() == 'spam':\n self.text.set('eggs')\n elif self.text.get() == 'eggs':\n self.text.set('spam')\n \n```\n\nこれでchang_label()はtoggle buttonににります", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T15:20:41.650", "id": "20890", "last_activity_date": "2016-01-13T15:20:41.650", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2371", "parent_id": "20876", "post_type": "answer", "score": 0 }, { "body": "スレッドを分けるのが適切と思います。\n\n```\n\n from Tkinter import *\n import threading\n from time import sleep\n \n class Window:\n def __init__(self):\n self.flg = False\n self.root = Tk()\n self.txt = StringVar()\n Button(self.root, text=\"test\", command=self.changeLabel ).pack()\n self.txt.set(\"hoge\")\n Label(self.root, textvariable=self.txt).pack()\n \n def changeLabel(self):\n self.txt.set(\"Start...\")\n t = threading.Thread(target=FunctionThatTakeALotOfTime, args=(self,))\n t.start()\n \n def FunctionThatTakeALotOfTime(w):\n sleep(2)\n w.txt.set(\"Finished!\")\n \n if __name__ == '__main__':\n w = Window()\n w.root.mainloop()\n \n```\n\n処理の内容によっては、必要に応じて同時に2つ以上関数が実行されないような処理を追加してください。(処理実行中はコマンド実行ボタンを無効化するなど。)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T22:54:33.300", "id": "20895", "last_activity_date": "2016-01-14T06:41:55.390", "last_edit_date": "2016-01-14T06:41:55.390", "last_editor_user_id": "6092", "owner_user_id": "6092", "parent_id": "20876", "post_type": "answer", "score": 1 } ]
20876
20895
20895
{ "accepted_answer_id": null, "answer_count": 2, "body": "C#入門者です。\n\n```\n\n public class Sample\n {\n \n public void Hoge(){} \n \n void Fuga(){} \n \n }\n \n```\n\n上記のコードの`Sample.Hoge()`と`Sample.Fuga()`の違いはなんでしょうか。 \npublicやprivateなどがないとき、どのような扱いになるのでしょうか。 \nまた、どのような場合にこういった書き方が必要になるのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T06:21:15.680", "favorite_count": 0, "id": "20878", "last_activity_date": "2016-01-13T06:55:07.530", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9149", "post_type": "question", "score": 1, "tags": [ "c#" ], "title": "C#のclassでスコープが明記されていないメソッドについて", "view_count": 2902 }
[ { "body": "メソッドの場合は省略するとprivateと同じ扱いになります。つまり下記と同じ意味です。\n\n```\n\n private void Fuga(){}\n \n```\n\n詳細はMSDNなどが参考になると思います。\n\n * [アクセス修飾子 (C# プログラミング ガイド)](https://msdn.microsoft.com/ja-jp/library/ms173121.aspx \"アクセス修飾子 \\(C# プログラミング ガイド\\)\")\n * [実装の隠蔽 - C# によるプログラミング入門 | ++C++; // 未確認飛行 C](http://ufcpp.net/study/csharp/oo_conceal.html#level \"実装の隠蔽 - C# によるプログラミング入門 | ++C++; // 未確認飛行 C\")\n\n省略する理由はおそらく様々だと思いますが、例えばUnityの場合はUnityが出力するC#スクリプトの雛形ではすでにprivateを省略されているため、Unityのプロジェクトのスクリプトではprivateを省略する書き方をよく見かける気がします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T06:38:56.470", "id": "20879", "last_activity_date": "2016-01-13T06:38:56.470", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3783", "parent_id": "20878", "post_type": "answer", "score": 1 }, { "body": "`Fuga()` は`private` として扱われます。 \n[アクセシビリティ レベル (C# リファレンス)](https://msdn.microsoft.com/ja-\njp/library/ba0a1yw2.aspx)\n\n> メンバー宣言にアクセス修飾子の指定がない場合には、既定のアクセシビリティ(リンク先の表からprivateが既定)が使用されます。\n\n必要というより単に好みの問題かと思います。(いちいち書きたくない、自分の中ではprivateとはっきりしているとか・)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T06:55:07.530", "id": "20880", "last_activity_date": "2016-01-13T06:55:07.530", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "20878", "post_type": "answer", "score": 2 } ]
20878
null
20880
{ "accepted_answer_id": "20990", "answer_count": 1, "body": "jQueryUIのDialogを使って、親画面から子ダイアログ、子ダイアログから孫ダイアログ、という開き方をします。 \n`modal: true`オプション付きです。\n\n孫ダイアログを開いた場合、子ダイアログは孫ダイアログのオーバーレイ(`.ui-widget-\noverlay`)に隠れて欲しいのですが、どのように制御すれば良いでしょうか?\n\n自分で調べてみたところ、`zIndex`オプションや`stack`オプションを使う方法が見つかりましたが、どちらも`1.10`で削除されてしまっています(`1.11`を使ってます)。\n\n今から開くダイアログの`.ui-widget-\noverlay`が特定できれば、自分で`$(...).css('z-index',...)`として書き換えてしまえるのですが、複数のダイアログが開いている(`.ui-\nwidget-overlay`が複数ある)場合、特定する方法が分かりません。\n\n何か良い方法は無いでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T09:19:32.437", "favorite_count": 0, "id": "20882", "last_activity_date": "2016-01-17T05:18:07.677", "last_edit_date": "2016-01-14T01:27:19.180", "last_editor_user_id": "8078", "owner_user_id": "8078", "post_type": "question", "score": 2, "tags": [ "javascript", "jquery-ui" ], "title": "jQueryUI Dialogを複数開いた場合のz-indexの制御", "view_count": 8642 }
[ { "body": "最後に開いたオーバーレイは`$(\".ui-widget-overlay\").last()`で取得できそうです。\n\nただ子ダイアログは自動的に孫ダイアログの後ろに隠れているようです。\n\n下のスニペットでは、ダイアログ内のボタンをクリックすると子ダイアログ開きます。 \nダイアログを開いている状態でオーバーレイ(ダイアログの外側)をクリックすると、\n\n * クリックしたオーバーレイの`z-index`\n\nと、\n\n * `$(\".ui-widget-overlay\").last()`で取得したオーバーレイの`z-index`\n\nがアラートで表示されます。同じ値になることが解ると思います。\n\n```\n\n $(\"#dialog1\").dialog({\r\n \"modal\": true,\r\n \"buttons\": [\r\n {\r\n \"text\": \"OPEN CHILD DIALOG\",\r\n \"click\": function() {\r\n $(\"#dialog2\").dialog(\"open\");\r\n }\r\n }\r\n ],\r\n \"open\": function() {\r\n onMyDialogOpen();\r\n }\r\n });\r\n \r\n $(\"#dialog2\").dialog({\r\n \"modal\": true,\r\n \"autoOpen\": false,\r\n \"buttons\": [\r\n {\r\n \"text\": \"OPEN CHILD DIALOG\",\r\n \"click\": function() {\r\n $(\"#dialog3\").dialog(\"open\");\r\n }\r\n }\r\n ],\r\n \"open\": function() {\r\n onMyDialogOpen();\r\n }\r\n });\r\n \r\n $(\"#dialog3\").dialog({\r\n \"modal\": true,\r\n \"autoOpen\": false,\r\n \"open\": function() {\r\n onMyDialogOpen();\r\n }\r\n });\r\n \r\n $(\"#open1\").on(\"click\", function() {\r\n $(\"#dialog1\").dialog(\"open\");\r\n });\r\n \r\n $(\"#open2\").on(\"click\", function() {\r\n $(\"#dialog2\").dialog(\"open\");\r\n });\r\n \r\n $(\"#open3\").on(\"click\", function() {\r\n $(\"#dialog3\").dialog(\"open\");\r\n });\r\n \r\n function onMyDialogOpen() {\r\n $(\".ui-widget-overlay\").on(\"click\", function() {\r\n alert(\"z-index:clicked: \" + $(this).css(\"z-index\"));\r\n alert(\"z-index:current: \" + $(\".ui-widget-overlay\").last().css(\"z-index\"));\r\n });\r\n };\n```\n\n```\n\n @import \"//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css\";\n```\n\n```\n\n <div id=\"dialog1\" title=\"Dialog 1\">Dialog 1</div>\r\n \r\n <div id=\"dialog2\" title=\"Dialog 2\">Dialog 2</div>\r\n \r\n <div id=\"dialog3\" title=\"Dialog 3\">Dialog 3</div>\r\n \r\n <p>\r\n <button id=\"open1\">Dialog 1</button>\r\n </p>\r\n \r\n <p>\r\n <button id=\"open2\">Dialog 2</button>\r\n </p>\r\n \r\n <p>\r\n <button id=\"open2\">Dialog 3</button>\r\n </p>\r\n \r\n <script src=\"//code.jquery.com/jquery-2.2.0.min.js\"></script>\r\n <script src=\"//code.jquery.com/ui/1.11.4/jquery-ui.min.js\"></script>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T05:18:07.677", "id": "20990", "last_activity_date": "2016-01-17T05:18:07.677", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13493", "parent_id": "20882", "post_type": "answer", "score": 1 } ]
20882
20990
20990
{ "accepted_answer_id": "20913", "answer_count": 1, "body": "`~/Downloads`フォルダに存在するファイルのうち10M以上のサイズのファイル以外をすべて一覧で取得したいです\n\n可能ならば、`~/Downloads/example-dir/*`のように再帰的にすべてのファイルの一覧を取得したい", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T12:16:45.990", "favorite_count": 0, "id": "20883", "last_activity_date": "2016-01-14T06:45:15.397", "last_edit_date": "2016-01-13T13:09:12.353", "last_editor_user_id": "5505", "owner_user_id": "5505", "post_type": "question", "score": 1, "tags": [ "shellscript" ], "title": "ディレクトリにあるサイズの大きなファイル以外を一覧取得したい", "view_count": 110 }
[ { "body": "文字通り「サイズ10M以上のファイル以外」であれば、こうですね。これではディレクトリなども含まれます:\n\n```\n\n $ find ~/Downloads ! -size +10M\n \n```\n\n「サイズ 10M以下のファイル」なら:\n\n```\n\n $ find ~/Downloads -size -10M -type f\n \n```\n\nさらに「*.pdfのみ」という条件を加えるなら:\n\n```\n\n $ find ~/Downloads -size -10M -type f -name \"*.pdf\"\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T06:45:15.397", "id": "20913", "last_activity_date": "2016-01-14T06:45:15.397", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3061", "parent_id": "20883", "post_type": "answer", "score": 1 } ]
20883
20913
20913
{ "accepted_answer_id": "20908", "answer_count": 1, "body": "> Error in Success callbackId: Camera463 : TypeError: undefined is not a\n> constructor (evaluating 'new NCMB.File(fileName, byteCharacters,\n> \"image/png\")')\n\nというエラーが出るのですが、意味を教えてください。 \nniftyのモバイルバックエンドを利用しています。\n\n下記がコードの抜粋になります。\n\nJavaScript\n\n```\n\n function snapPicture () {\n navigator.camera.getPicture (onSuccess, onFail,\n { quality: 50, destinationType: Camera.DestinationType.DATA_URL});\n \n //成功した際に呼ばれるコールバック関数\n function onSuccess (imageData) {\n var byteCharacters = toBlob(imageData);\n var NCMBFile = new NCMB.File(fileName, byteCharacters, \"image/png\");\n NCMBFile.save().then(function() {\n //NCMBサーバーからファイルをダウンロード\n var getFile = new NCMB.File(fileName);\n var image_canvas = document.getElementById(\"showImage\");\n getFile.fetchImgSource(image_canvas);\n },\n function(error) {\n  // The file either could not be read, or could not be saved to NCMB.\n alert(JSON.stringify(error));\n });\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T13:04:58.277", "favorite_count": 0, "id": "20887", "last_activity_date": "2016-01-14T03:29:08.360", "last_edit_date": "2016-01-13T13:56:36.533", "last_editor_user_id": "9566", "owner_user_id": "13934", "post_type": "question", "score": 0, "tags": [ "javascript", "monaca" ], "title": "Error in Success callbackId:というエラー", "view_count": 1014 }
[ { "body": "## エラーの意味\n\n> Error in Success callbackId: Camera463 :\n\nこの部分はMonacaというか内部のCordovaが表示している部分で、どこでエラーが起きたかを示しています。が、これはとりあえず置いておいて次に行きます。\n\n> TypeError: undefined is not a constructor (evaluating 'new\n> NCMB.File(fileName, byteCharacters, \"image/png\")')\n\nこれがJavascriptのエラーです。 `xxx is not a constructor`\nというのは、コンストラクタではないxxxという値がコンストラクタとして呼び出された、ということを表します。この場合、 `NCMB.File`\nはコンストラクタのはずですが、実際には `undefined` だったということになります。\n\nundefinedが意図せずして現れるのは、存在しない変数・プロパティを参照したときが多いです。\n\n## 原因\n\nニフティクラウド mobile backend の Javascript SDK は去年の9月にVersion2が公開されました。\n\n[SDKガイド (JavaScript) : Version2に伴う変更点 | ニフティクラウド mobile\nbackend](http://mb.cloud.nifty.com/doc/current/sdkguide/javascript/versionChangeDescription.html)\n\n[`NCMB.File`\nコンストラクタ](http://mb.cloud.nifty.com/assets/sdk_doc/javascript/jsdoc_1.2.6/symbols/NCMB.File.html)は\nVersion1 系のAPIで、現在の最新である Version2\n系には存在しないものです。そのため、Version2のSDKで実行するとそのようなエラーになるかと思います。\n\nVersion1のサポートは 2016/3/16\nで終了するようなのでVersion2に乗り換えたいところですが、Version2のマニュアルでは[「ブラウザやMonacaでのファイルアップロードは今後対応予定です。」](http://mb.cloud.nifty.com/doc/current/filestore/basic_usage_javascript.html)とあり、現時点でMonacaからファイルストアを利用したい場合はVersion1を利用する必要があるようです。\n\nVersion1のSDKは現在SDKダウンロードページの一番下からダウンロードが可能です。こちらからダウンロードしなおしてお試しください。\n\n[イントロダクション (JavaScript) : SDKダウンロード | ニフティクラウド mobile\nbackend](http://mb.cloud.nifty.com/doc/current/introduction/sdkdownload_javascript)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T03:29:08.360", "id": "20908", "last_activity_date": "2016-01-14T03:29:08.360", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "20887", "post_type": "answer", "score": 0 } ]
20887
20908
20908
{ "accepted_answer_id": null, "answer_count": 0, "body": "下記のソースコードは、 文字マウスストーカーにanimationDURATIONスタイルを設定したのですが、 \nこれを設定したらマウスストーカーの効果が失われてしまいました(*初期状態のみ正常に機能します)。 \nどのように設定しなおせば、マウスストーカーの効果を失わずに、animationDURATIONスタイルを \nセレクトのoptionにも設定できるでしょうか。ご教示ください。\n\n*\"文字マウスストーカー\"とは、マウスポインタの動きに応じて文字列が付いて回る,技法です。\n\n(ソースコード)\n\n```\n\n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=Shift_JIS\">\n <meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\">\n <meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n \n <title>animationDURATIONスタイルについて</title>\n \n \n <style type=\"text/css\">\n \n #myText {\n font-style: italic;\n font-weight: bold;\n font-family: 'comic sans ms', verdana, arial;\n position: absolute;top: 0;left: 0;z-index: 3000;cursor: default;\n -webkit-animation:myText 2s ease-in-out infinite alternate; \n -moz-animation:myText 2s ease-in-out infinite alternate; \n animation:myText 2s ease-in-out infinite alternate; \n } \n @-webkit-keyframes myText{ \n 0% {opacity:0;}\n 100% {opacity:1; color:gold;}\n }\n @-moz-keyframes myText{ \n 0% {opacity:0;}\n 100% {opacity:1; color:gold;}\n } \n @keyframes myText{ \n 0% {opacity:0;}\n 100% {opacity:1; color:gold;}\n } \n \n .mog1 {\n font-style: italic;\n font-weight: bold;\n font-family: 'comic sans ms', verdana, arial;\n position: absolute;top: 0;left: 0;z-index: 3000;cursor: default;\n -webkit-animation:mog1 2s ease-in-out infinite alternate; \n -moz-animation:mog1 2s ease-in-out infinite alternate; \n animation:mog1 2s ease-in-out infinite alternate; \n } \n @-webkit-keyframes mog1{ \n 0% {opacity:0;}\n 100% {opacity:1; color:blue;}\n }\n @-moz-keyframes mog1{ \n 0% {opacity:0;}\n 100% {opacity:1; color:blue;}\n } \n @keyframes mog1{ \n 0% {opacity:0;}\n 100% {opacity:1; color:blue;}\n } \n .mog2 {\n font-style: italic;\n font-weight: bold;\n font-family: 'comic sans ms', verdana, arial;\n position: absolute;top: 0;left: 0;z-index: 3000;cursor: default;\n -webkit-animation:mog2 2s ease-in-out infinite alternate; \n -moz-animation:mog2 2s ease-in-out infinite alternate; \n animation:mog2 2s ease-in-out infinite alternate; \n } \n @-webkit-keyframes mog2{ \n 0% {opacity:0;}\n 100% {opacity:1; color:red;}\n }\n @-moz-keyframes mog2{ \n 0% {opacity:0;}\n 100% {opacity:1; color:red;}\n } \n @keyframes mog2{ \n 0% {opacity:0;}\n 100% {opacity:1; color:red;}\n } \n \n .mog3 {\n font-style: italic;\n font-weight: bold;\n font-family: 'comic sans ms', verdana, arial;\n position: absolute;top: 0;left: 0;z-index: 3000;cursor: default;\n -webkit-animation:mog3 2s ease-in-out infinite alternate; \n -moz-animation:mog3 2s ease-in-out infinite alternate; \n animation:mog3 2s ease-in-out infinite alternate; \n } \n @-webkit-keyframes mog3{ \n 0% {opacity:0;}\n 100% {opacity:1; color:olive;}\n }\n @-moz-keyframes mog3{ \n 0% {opacity:0;}\n 100% {opacity:1; color:olive;}\n } \n @keyframes mog3{ \n 0% {opacity:0;}\n 100% {opacity:1; color:olive;}\n } \n \n #myText div {position: relative;}\n #myText div div {position: absolute;top: 0;left: 0;text-align: center;}\n \n </style>\n \n <script type=\"text/javascript\">\n <!--\n \n var txt1=\"<div class='mog1'>1</div><div class='mog1'>2</div><div class='mog1'>3</div><div class='mog1'>4</div>\";\n var txt2=\"<div class='mog2'>5</div><div class='mog2'>6</div><div class='mog2'>7</div><div class='mog2'>8</div>\";\n var txt3=\"<div class='mog3'>A</div><div class='mog3'>B</div><div class='mog3'>C</div><div class='mog3'>D</div>\";\n \n function anime1(){\n document.getElementById('myText').innerHTML = txt1;\n   }\n function anime2(){\n document.getElementById('myText').innerHTML = txt2;\n   }\n function anime3(){\n document.getElementById('myText').innerHTML = txt3;\n   }\n \n function output(e){\n var selectedIndex = e.selectedIndex;\n document.getElementById(\"mess\").style.background=e[selectedIndex ].style.backgroundColor;\n }\n \n \n ;(function(){\n var msg = \"ABCD\"; \n var size = 26;\n var circleY = 0.75; var circleX = 2;\n var letter_spacing = 5;\n var diameter = 10;\n var rotation = 0.4;\n var speed = 0.3;\n \n if (!window.addEventListener && !window.attachEvent || !document.createElement) return;\n msg = msg.split('');\n var n = msg.length - 1, a = Math.round(size * diameter * 0.208333), currStep = 20,\n ymouse = a * circleY + 20, xmouse = a * circleX + 20, y = [], x = [], Y = [], X = [],\n o = document.createElement('div'), oi = document.createElement('div'),\n b = document.compatMode && document.compatMode != \"BackCompat\"? document.documentElement : document.body,\n \n mouse = function(e){\n e = e || window.event;\n ymouse = !isNaN(e.pageY)? e.pageY : e.clientY;\n xmouse = !isNaN(e.pageX)? e.pageX : e.clientX;\n },\n \n makecircle = function(){\n if(init.nopy){\n o.style.top = (b || document.body).scrollTop + 'px';\n o.style.left = (b || document.body).scrollLeft + 'px';\n };\n currStep -= rotation;\n for (var d, i = n; i > -1; --i){\n d = document.getElementById('iemsg' + i).style;\n d.top = Math.round(y[i] + a * Math.sin((currStep + i) / letter_spacing) * circleY - 15) + 'px';\n d.left = Math.round(x[i] + a * Math.cos((currStep + i) / letter_spacing) * circleX) + 'px';\n };\n },\n \n drag = function(){\n y[0] = Y[0] += (ymouse - Y[0]) * speed;\n x[0] = X[0] += (xmouse - 20 - X[0]) * speed;\n for (var i = n; i > 0; --i){\n y[i] = Y[i] += (y[i-1] - Y[i]) * speed;\n x[i] = X[i] += (x[i-1] - X[i]) * speed;\n };\n makecircle();\n },\n \n init = function(){ \n if(!isNaN(window.pageYOffset)){\n ymouse += window.pageYOffset;\n xmouse += window.pageXOffset;\n } else init.nopy = true;\n for (var d, i = n; i > -1; --i){\n d = document.createElement('div'); d.id = 'iemsg' + i;\n d.style.height = d.style.width = a + 'px';\n d.appendChild(document.createTextNode(msg[i]));\n oi.appendChild(d); y[i] = x[i] = Y[i] = X[i] = 0;\n };\n o.appendChild(oi); document.body.appendChild(o);\n setInterval(drag, 25);\n },\n \n ascroll = function(){\n ymouse += window.pageYOffset;\n xmouse += window.pageXOffset;\n window.removeEventListener('scroll', ascroll, false);\n };\n \n o.id = 'myText'; o.style.fontSize = size + 'px';\n \n if (window.addEventListener){\n window.addEventListener('load', init, false);\n document.addEventListener('mouseover', mouse, false);\n document.addEventListener('mousemove', mouse, false);\n if (/Apple/.test(navigator.vendor))\n window.addEventListener('scroll', ascroll, false);\n }\n else if (window.attachEvent){\n window.attachEvent('onload', init);\n document.attachEvent('onmousemove', mouse);\n };\n })();\n // -->\n </script>\n \n </head>\n \n <body bgcolor=\"black\">\n <form style=\"text-align:center;\">\n  <select id=\"mess\" style=\"background-color:olive; color:black; font-weight:bold;\" onchange=\"output(this)\">\n   <option id=\"op1\" style=\"background-color:blue;\" value=\"1234\" onclick=\"anime1()\">1234</option>\n   <option id=\"op2\" style=\"background-color:red;\" value=\"5678\" onclick=\"anime2()\">5678</option>\n   <option id=\"op3\" style=\"background-color:olive; font-weight:bold\" value=\"ABCD\" onclick=\"anime3(this)\" selected>ABCD</option>\n  </select> \n </form>\n \n </body>\n </html>\n \n```", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T14:17:14.160", "favorite_count": 0, "id": "20888", "last_activity_date": "2016-01-13T14:17:14.160", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9359", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "css" ], "title": "\"マウスストーカー\"の効果を失わずに、セレクトのoptionにもanimationDURATIONスタイルを設定する方法", "view_count": 82 }
[]
20888
null
null
{ "accepted_answer_id": "20897", "answer_count": 1, "body": "今自分が考えているのはゲームでステージ1−1、1−2・・・と沢山あって1−1をクリアすると1−2が解放されるといったよくあるシステムです。 \n1−1をクリアして1−2を解放した後アプリのタスクを切ると初期化されてしまいまた1−1からスタートしてしまいます。 \nどのようにしたらタスクを切ったところから始めることができますか?\n\nサーバーなどを使わないとできませんか? \nもし、使わなくて済むならその方法を教えてください。\n\nコードを簡単に書いていただけると助かります。\n\n説明が下手で申し訳有りません。 \nご回答宜しくお願いします", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T15:05:57.460", "favorite_count": 0, "id": "20889", "last_activity_date": "2016-01-14T01:55:52.367", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "11019", "post_type": "question", "score": 0, "tags": [ "ios", "swift", "iphone", "swift2" ], "title": "swift アプリのタスクを切った後、続きから再開する方法を教えてください。", "view_count": 559 }
[ { "body": "サーバー上でユーザのクリア進捗状況を保持しないのであれば、端末内部に保存する方法を取ることができます。\n\nステージ数のみ保存する形で良いのであれば、 \n`NSUserDefaults`が手軽に使えて良いのではないかなと思います。\n\n【ソースコード例】 \nユーザが **1-2** までステージをクリアしている場合 \n仮で、1をmajorStageNumber, 2をminorStageNumberとします。\n\n```\n\n // 値の保存方法\n let defaults = NSUserDefaults.standardUserDefaults()\n defaults.setInteger(1, forKey: \"majorStageNumber\")\n defaults.setInteger(2, forKey: \"minorStageNumber\")\n defaults.synchronize()\n \n // 値の取得方法\n let majorStageNumber = defaults.integerForKey(\"major\")\n let minor:Int = defaults.integerForKey(\"minorStageNumber\")\n \n```\n\n上記の書き方を踏まえて、\n\n * ステージをクリアするごとにステージ数を端末内部に保存する\n * アプリを起動する度に、端末内部からクリアしたステージ数を取得する\n\nようにしてみたらいかがでしょうか?\n\nもし、\n\n * ステージごとのクリア点数(経験値)やコインも保存したい\n * 1つの端末で複数ユーザでゲームをプレイしたい \n3ゲームまでセーブできるといった機能をつけたいといった場合ですかね。\n\nなどの想定があるのであれば、`Realm`を使った方が良いと思います。 \n`Realm`について、参考までに[公式サイトのリンク](https://realm.io/jp/docs/swift/latest/)をはっておきます。\n\n少しでも参考になれば幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T01:01:44.700", "id": "20897", "last_activity_date": "2016-01-14T01:55:52.367", "last_edit_date": "2016-01-14T01:55:52.367", "last_editor_user_id": "8968", "owner_user_id": "8968", "parent_id": "20889", "post_type": "answer", "score": 1 } ]
20889
20897
20897
{ "accepted_answer_id": "21273", "answer_count": 1, "body": "よろしくお願いします。\n\nディレクトリをまるごとzipでダウンロードしたいです。\n\nWindows8.1 \nphp 5.4.39 \nApache 2.2.14 \nlocalでの実行です。\n\nmysite \n| \n|-image \n| |-image1.png \n| \n|-file1.php \n|-file2.php\n\n上記のような状態のものを、zipで圧縮してダウンロードすることが目標です。\n\nコードは以下の通りです。\n\n```\n\n <php\n \n //Zipクラスロード\n $zip = new ZipArchive();\n \n //Zipファイル名指定\n $zipFileName = 'mysite.zip';\n \n //Zipファイル一時保存ディレクトリ取得\n $zipTmpDir = '/phpdocs/nonprothemes';\n \n //Zipファイルオープン\n $result = $zip->open($zipTmpDir.$zipFileName, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);\n \n if ($result !== true) {\n return false;\n }\n \n //処理制限時間を外す\n set_time_limit(0);\n \n \n /* ファイルパスを指定する処理 */\n \n //mysite内のファイル一覧取得\n //ディクトリパス格納用変数\n $dir = null;\n $dir = 'mysite/';\n \n //ハンドル取得用変数\n $handle = null;\n //ファイル情報取得用変数\n $file = null;\n //ファイルパス指定用配列\n $fpath_array = array();\n \n //ディレクトリの存在確認、ハンドル取得\n if(is_dir($dir) && $handle = opendir($dir))\n {\n //ディレクトリ内のファイルを取得\n while(($file = readdir($handle)) !== false)\n {\n //'.','..'を取り除く処理\n if($file != \".\" && $file != \"..\")\n {\n //ファイルパス指定\n $fpath_array[] = 'mysite/'.$file;\n }\n }\n }\n \n //ファイルパス指定\n //$fpath_array = array('mysite/style.css','mysite/index.php');\n /* ここまで */\n \n //Zip追加処理\n foreach ($fpath_array as $filepath) {\n //filename取得\n $filename = basename($filepath);\n \n //取得ファイルをZipに追加\n $zip->addFromString($filename,file_get_contents($filepath));\n $zip->addFile($filepath);\n }\n \n $zip->close();\n \n // ストリームに出力\n header('Content-Type: application/zip; name=\"' . $zipFileName . '\"');\n header('Content-Disposition: attachment; filename=\"' . $zipFileName . '\"');\n header('Content-Length: '.filesize($zipTmpDir.$zipFileName));\n echo file_get_contents($zipTmpDir.$zipFileName);\n \n // 一時ファイルを削除しておく\n unlink($zipTmpDir.$zipFileName);\n ?>\n \n```\n\n現在、\n\n> Warning: file_get_contents(mysite/images): failed to open stream: \n> Permission denied in C:\\phpdocs\\nonprothemes\\file_dw.php on line 62\n>\n> Warning: Cannot modify header information - headers already sent by \n> (output started at C:\\phpdocs\\nonprothemes\\file_dw.php:62) in \n> C:\\phpdocs\\nonprothemes\\file_dw.php on line 69\n>\n> Warning: Cannot modify header information - headers already sent by \n> (output started at C:\\phpdocs\\nonprothemes\\file_dw.php:62) in \n> C:\\phpdocs\\nonprothemes\\file_dw.php on line 70\n>\n> Warning: filesize(): stat failed for /phpdocs/nonprothemesmysite.zip \n> in C:\\phpdocs\\nonprothemes\\file_dw.php on line 71\n>\n> Warning: Cannot modify header information - headers already sent by \n> (output started at C:\\phpdocs\\nonprothemes\\file_dw.php:62) in \n> C:\\phpdocs\\nonprothemes\\file_dw.php on line 71\n>\n> Warning: file_get_contents(/phpdocs/nonprothemesmysite.zip): failed to \n> open stream: No such file or directory in \n> C:\\phpdocs\\nonprothemes\\file_dw.php on line 72\n>\n> Warning: unlink(/phpdocs/nonprothemesmysite.zip): No such file or \n> directory in C:\\phpdocs\\nonprothemes\\file_dw.php on line 75\n\nこれらのエラーが出ています。\n\napacheの権限の問題なのかと思ったのですが、ネットで調べてみてもhttpd.confのどこにどう記述すればいいのかが分かりませんでした。\n\n参考になるサイトなどありましたら教えていただきたいです。\n\nXAMPPで動かしているときには正常に動いていましたが、XAMPPを消してApacheを入れなおしたら今回のようなことになってしまいました。\n\nどのようにして解決したら良いでしょうか? \nよろしくお願いします。\n\n/********* 追記 ***********/ \nmysite/image(imageフォルダ)を消した場合、\n\n(以下、パターン1) \nmysite.zip \n| \n|-mysite \n| |-file1.php \n| |-file2.php \n| \n|-file1.php \n|-file2.php\n\nこのような形でzipが出来上がりました。\n\nちなみに、\n\n> $zip->addFromString($filename,file_get_contents($filepath));\n\nこちらをコメントアウトした状態で実行すると、 \n(以下、パターン2) \nmysite.zip \n| \n|-mysite \n| |-file1.php \n| |-file2.php\n\nこのような形でzipで出来上がります。\n\n/********* 追記 ***********/\n\nコードを修正した結果、 \n中身の無い(?)8KBのzipフォルダが作成されました。 \nファイルを追加する所で代わりにファイルパスを表示した所、問題なくパスが来ていました。\n\n以下コードです。\n\n```\n\n $dist = 'mysite.zip'; // 生成する圧縮ファイル名\n $path = './mysite'; // 圧縮するパス\n $zipTmpDir = '/phpdocs/nonprothemes'; // 一時パス\n \n \n $zip = new ZipArchive();\n $zip->open($zipTmpDir.$dist, ZipArchive::CREATE | ZipArchive::OVERWRITE);\n addZip($zip, $path);\n $zip->close();\n \n function addZip($zip, $path) {\n if (is_dir($path)) {\n $files = array_diff(scandir($path), ['.', '..']);\n foreach ($files as $file) addZip($zip, \"$path/$file\");\n } else {\n $zip->addFile($path);\n }\n }\n \n // ストリームに出力\n header('Content-Type: application/zip; name=\"' . $dist . '\"');\n header('Content-Disposition: attachment; filename=\"' . $dist . '\"');\n header('Content-Length: '.filesize($zipTmpDir.$dist));\n echo file_get_contents($zipTmpDir.$dist);\n \n // 一時ファイルを削除しておく\n unlink($zipTmpDir.$dist);\n \n```", "comment_count": 7, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T16:02:44.527", "favorite_count": 0, "id": "20891", "last_activity_date": "2016-01-24T22:03:20.427", "last_edit_date": "2016-01-18T04:38:08.137", "last_editor_user_id": "13454", "owner_user_id": "13454", "post_type": "question", "score": 0, "tags": [ "php" ], "title": "ディレクトリを丸ごとzipでダウンロードしたい", "view_count": 3836 }
[ { "body": "自己解決することが出来ました。 \n皆様コメントありがとうございました。\n\n全てのファイルパスを、\n\n> 圧縮したいフォルダ名/(サブフォルダ名)/ファイル名\n\nこのように統一して1つの配列にまとめ、addFileでzipに追加、圧縮という形になっています。 \nサブフォルダはいくつあっても問題ありませんでした。 \n空のサブフォルダが存在していてもエラーは出ません。 \nしかし、圧縮したzipには空のサブフォルダは作られません。 \n以下がコードです。\n\n```\n\n <?php\n \n //Zipクラスロード\n $zip = new ZipArchive();\n \n //Zipファイル名指定\n $zipFileName = 'mysite.zip';\n \n //Zipファイル一時保存ディレクトリ取得\n $zipTmpDir = '/phpdocs/nonprothemes';\n $path = './mysite';\n $path2 = 'mysite';\n \n //Zipファイルオープン\n $result = $zip->open($zipTmpDir.$zipFileName, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);\n \n if ($result !== true) {\n return false;\n }\n \n //処理制限時間を外す\n set_time_limit(0);\n \n //パス取得\n $fpath_array_beta = array_diff(scandir($path), ['.', '..']);\n \n // zip追加する本命のパスを格納する配列\n $fpath_array = array();\n \n // ディレクトリ判別\n foreach ($fpath_array_beta as $key => $value) {\n if(is_dir(\"$path/$value\")){\n // パス指定\n $path_sub = \"$path/$value\";\n // サブフォルダ内のファイル名取得\n $array_beta = array_diff(scandir($path_sub), ['.', '..']);\n // パスとして取得(元配列に追加)\n foreach ($array_beta as $key2 => $value2) {\n array_push($fpath_array,\"$path2/$value/$value2\"); \n }\n }else{\n // ファイルの場合はそのまま追加\n array_push($fpath_array,\"$path2/$value\");\n }\n }\n \n // print \"<pre />\"; var_dump($fpath_array); print \"<pre />\";\n \n //Zip追加処理\n foreach ($fpath_array as $filepath) {\n $zip->addFile($filepath);\n }\n \n $zip->close();\n \n // ストリームに出力\n header('Content-Type: application/zip; name=\"' . $zipFileName . '\"');\n header('Content-Disposition: attachment; filename=\"' . $zipFileName . '\"');\n header('Content-Length: '.filesize($zipTmpDir.$zipFileName));\n echo file_get_contents($zipTmpDir.$zipFileName);\n \n // 一時ファイルを削除しておく\n unlink($zipTmpDir.$zipFileName);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-24T22:03:20.427", "id": "21273", "last_activity_date": "2016-01-24T22:03:20.427", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13454", "parent_id": "20891", "post_type": "answer", "score": 1 } ]
20891
21273
21273
{ "accepted_answer_id": "20909", "answer_count": 1, "body": "plink を用いる際に、 PuTTY で接続情報をセッションとして保存すれば、そのセッション名を指定して\n\n```\n\n plink session-name\n \n```\n\nのようにすると、設定された接続情報で ssh できます。\n\n一方で一般的な ssh コマンドは、接続先情報を `~/.ssh/config` に記述して、その中で設定する Host の設定によって、\n\n```\n\n ssh host\n \n```\n\nを実行すると、 `~/.ssh/config` の、該当 Host の設定に従って ssh できます。\n\n* * *\n\n質問: plink において、 .ssh/config 形式の設定を利用して ssh を行うことはできますか?\n\n背景: `vagrant ssh-config` で出力された ssh 設定を利用して、 plink の接続を行おうと思ったので、この質問をしています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-13T16:05:19.313", "favorite_count": 0, "id": "20892", "last_activity_date": "2016-01-14T03:35:24.393", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "post_type": "question", "score": 1, "tags": [ "windows", "ssh", "putty" ], "title": "plink を使う際に、 .ssh/config 形式の設定を読み込んでそれから実行できるか", "view_count": 1294 }
[ { "body": "`~/.ssh/config`は OpenSSH 特有の設定ファイルなので plink では使えません。 \nWindowsのOpenSSHクライアント (ssh.exe) を使ってください。\n\nOpensSSH のインストールはいくつかバリエーションがあります。 \nCygwin、MinGw、Git(msysGit)、などをインストールすると使えるようになります。\n\nまた、使ったことありませんが PowerShell で使えるOpennSSHがあるそうです。 \n<https://github.com/PowerShell/Win32-OpenSSH>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T03:35:24.393", "id": "20909", "last_activity_date": "2016-01-14T03:35:24.393", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "20892", "post_type": "answer", "score": 1 } ]
20892
20909
20909
{ "accepted_answer_id": "20899", "answer_count": 1, "body": "floatとdoubleをtemplateによって抽象化しようと思っています。そこで次のようなtemplate関数を考えます。\n\n```\n\n template <class T>\n T plus_one(const T& num) {\n return num + T(1.0);\n }\n \n```\n\n1.0\nはコンパイラーではdoubleになるので、とりあえずTでキャストしていますが、キャスティングにかかる負担を削減するため、次のように実際に使うdouble,\nfloatのために特殊化しています。\n\n```\n\n template <>\n double plus_one<double>(const double& num) {\n return num + 1.0;\n }\n template <>\n float plus_one<float>(const float& num) {\n return num + 1.0f;\n }\n \n```\n\nもし、1.0f と\nfloat(1.0)がコンパイラー上で性能上の違いがなければ、上記のような特殊化はせずに元のtemplate関数だけで足りるはずです。1.0fとfloat(1.0)は違いがありますか?\n\nそしてもし1.0fとfloat(1.0)で違いがあれば、M_PI みたいな定数をfloatで使いたい場合は仕方がなく\n\n```\n\n #define M_PI_F (3.141592f)\n \n```\n\nみたいな新たなマクロ変数を定義しなくてはならないのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T01:02:46.520", "favorite_count": 0, "id": "20898", "last_activity_date": "2016-01-14T01:32:22.550", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10856", "post_type": "question", "score": 1, "tags": [ "c++" ], "title": "float number literal を使う場合にconstructorとの性能差はありますか?", "view_count": 157 }
[ { "body": "例えば\n\n```\n\n int x = 1 + 1;\n \n```\n\nと記述した場合、`1 +\n1`は定数式ですのでコンパイル時に計算され、実行時には直接`2`が使用されます。今回の場合、`T(1.0)`もテンプレート展開後には定数式ですのでコンパイル時にキャストされ、実行時には`1.0`や`1.0f`として扱われます。\n\n不安であればアセンブリリストを出力し、直接確認されることをお勧めします。\n\n* * *\n\nこの例に関しては、以下でいいかも。\n\n```\n\n template <class T>\n constexpr T plus_one(T num) {\n return num + 1;\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T01:23:04.050", "id": "20899", "last_activity_date": "2016-01-14T01:32:22.550", "last_edit_date": "2016-01-14T01:32:22.550", "last_editor_user_id": "4236", "owner_user_id": "4236", "parent_id": "20898", "post_type": "answer", "score": 4 } ]
20898
20899
20899
{ "accepted_answer_id": "20977", "answer_count": 2, "body": "失礼します。以下はJSON形式に変換してリクエストをし、画面遷移せずその場に結果を表示させるコードです。 \nこちらのコードだとPOSTだけですが、GETでもデータを送受信したいのです。しかし編集してもやり方が違うのかエラーが生じてしまいます。 \nどの部分に手を加えればいいのか、またできればHTML上で月日が選択できるのと同じようにPOSTかGETを選択できるようにしたいと考えております。\n\n自分の力だとどうしても解決できないためこちらで質問させていただきました。 \n何卒宜しく御願い致します。\n\n```\n\n <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css\">\r\n <link href=\"./css/css.css\" rel=\"stylesheet\">\r\n <script type=\"text/javascript\">\r\n $(function(){\r\n $(\"#response\").html(\"Response Values\");\r\n $(\"#button\").click( function(){\r\n var url = $(\"#url_post\").val();\r\n var dept_ids = $(\"#dept_ids\").val().split(\",\");\r\n var start_date = $(\"#start_date\").val();\r\n var end_date = $(\"#end_date\").val();\r\n \r\n var JSONdata = {};\r\n JSONdata.dept_ids = dept_ids;\r\n JSONdata.start_date = start_date; \r\n JSONdata.end_date = end_date;\r\n \r\n \r\n $.ajax({\r\n url : url\r\n , type : \"POST\"\r\n , data : JSON.stringify(JSONdata)\r\n , contentType: \"application/json;charset=UTF-8\"\r\n , processData: false\r\n , dataType : \"json\"\r\n , accepts : {json: \"application/vnd.glv.v1+json;charset=UTF-8\"}\r\n , crossDomain: false\r\n }).done(function(data, status, xhr) {\r\n // 通信成功時の処理\r\n // alert(\"成功\");\r\n $(\"#response\").html(JSON.stringify(data));\r\n }).fail(function(xhr, status, error) {\r\n // 通信失敗時の処理\r\n alert(\"失敗\");\r\n }).always(function(arg1, status, arg2) {\r\n // 通信完了時の処理\r\n // alert(\"完了\");\r\n });\r\n })\r\n })\n```\n\n```\n\n <table>\r\n <h1>店舗検索</h1>\r\n <tr>\r\n <td><b>URL: <input type=\"text\" id=\"url_post\" name=\"url\" size=\"100\" value=\"http://52.192.178.185:8280/api/dept_accesses\"></b><td>\r\n </tr>\r\n <!-- <p>店舗ID: <input type=\"text\" id=\"dept_ids\" size=\"30\" value=\"BD0002\" class=\"keyword\"></p>-->\r\n <tr>\r\n <td><b>店舗ID:<textarea cols=\"50\" id=\"dept_ids\" pattern=\"^[0-9A-Za-z]+$\" class=\"keyword\"></textarea></td>\r\n </tr>\r\n <tr><td><b>開始日: <input type=\"text\" id=\"start_date\" size=\"30\" value=\"20151001\" class=\"keyword\">\r\n ~ 終了日: <input type=\"text\" id=\"end_date\" size=\"30\" value=\"20161207\" class=\"keyword\">\r\n <button id=\"button\" type=\"button\">submit</button></p></td>\r\n <tr>\r\n </tr>\r\n <td><textarea id=\"response\" cols=170 rows=21 disabled></textarea></td>\n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T02:37:56.447", "favorite_count": 0, "id": "20903", "last_activity_date": "2016-01-16T10:27:01.680", "last_edit_date": "2016-01-14T09:32:03.073", "last_editor_user_id": "208", "owner_user_id": "13072", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "json", "ajax" ], "title": "JSON取得する際にGETかPOSTを切り替えて受信できるようにしたい", "view_count": 1426 }
[ { "body": "Getメソッドで通信出来ない原因として、下記かなぁと思います。 \n検討ハズレかもしれませんが試してみてください。\n\n`data : JSON.stringify(JSONdata)` \nココの部分ですが、文字列にするなら綺麗なクエリストリング形式にする必要があったかと思います。 \nプレインなオブジェクトがそのまま使えるはずなので、下記で試してみてください。 \n`data : JSONdata`\n\n<http://api.jquery.com/jquery.ajax/>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T12:53:10.130", "id": "20923", "last_activity_date": "2016-01-14T12:53:10.130", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13999", "parent_id": "20903", "post_type": "answer", "score": 0 }, { "body": "「セレクトボックスのようなものを作成」する方法がわからない、ということでしょうか。\n\nあなたの言うセレクトボックスというのはおそらく `<select>` のことですよね。タグの使い方は以下のサイトや例を見てもらうとして、値の取得は他の\n`<input>` タグ同様に `$(..).val()` で行うことができます。\n\n[<select>-HTML5タグリファレンス](http://www.htmq.com/html5/select.shtml)\n\n```\n\n $('#submit').on('click', function() {\r\n var http_method = $('#http_method').val();\r\n alert(http_method);\r\n \r\n /* ajaxに組み込む場合の例\r\n $.ajax({\r\n url: ...,\r\n type: http_method,\r\n data: ...,\r\n ...\r\n });\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 <select id=\"http_method\">\r\n <option value=\"get\">GET</option>\r\n <option value=\"post\">POST</option>\r\n </select>\r\n <button id=\"submit\">送信</button>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T10:27:01.680", "id": "20977", "last_activity_date": "2016-01-16T10:27:01.680", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "20903", "post_type": "answer", "score": 0 } ]
20903
20977
20923
{ "accepted_answer_id": null, "answer_count": 1, "body": "お世話になります。\n\nメモ帳のサンプルに、タブのサンプル機能を追加したいと思っております。\n\n```\n\n <ons-tabbar>\n <ons-tab icon=\"home\" label=\"Home\" page=\"StopWatch.html\" active=\"true\"></ons-tab>\n <ons-tab icon=\"comment\" label=\"Comments\" page=\"page2.html\"></ons-tab>\n <ons-tab icon=\"gear\" label=\"Settings\" page=\"page3.html\"></ons-tab>\n </ons-tabbar>\n \n```\n\n上記をコピーし、該当HTMLを作成すればできるかと思ったのですができません。\n\n初歩的な質問で大変申し訳ありませんが、回答をお願いいたします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T02:41:41.817", "favorite_count": 0, "id": "20904", "last_activity_date": "2016-01-14T04:16:00.190", "last_edit_date": "2016-01-14T04:16:00.190", "last_editor_user_id": null, "owner_user_id": "14004", "post_type": "question", "score": -1, "tags": [ "javascript", "monaca", "onsen-ui", "html5" ], "title": "メモ帳のサンプルにOnsenUIでタブを追加したい", "view_count": 453 }
[ { "body": "この情報だけでは推測になってしまいますが、 \n恐らく対象ページでOnsen UIを適用していないと思われます。\n\n以下の様な記述は対象ページに書かれていますか?\n\n```\n\n <link rel=\"stylesheet\" href=\"css/onsenui.css\">\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T03:08:10.930", "id": "20907", "last_activity_date": "2016-01-14T03:08:10.930", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6040", "parent_id": "20904", "post_type": "answer", "score": 0 } ]
20904
null
20907
{ "accepted_answer_id": "20921", "answer_count": 1, "body": "Atomエディタを使って、LaTeXで文書作成をしているのですが、 \n文書中で一度用いた英単語を自動補完してくれる機能はないでしょうか?\n\nAtomにはautocompleteの機能はありますが、 \nlanguage-latexというパッケージを入れても、 \nsyntaxなものを自動補完してくれるだけで、 \n文書中で用いた英単語については補完してくれません。\n\nどなたかご教授いただければと思います。", "comment_count": 10, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T03:01:30.290", "favorite_count": 0, "id": "20906", "last_activity_date": "2016-01-15T02:25:46.247", "last_edit_date": "2016-01-15T02:25:46.247", "last_editor_user_id": "12874", "owner_user_id": "12874", "post_type": "question", "score": 7, "tags": [ "atom-editor", "latex" ], "title": "Atomエディタで、LaTeX文書中で一度用いた単語を自動補完したい。", "view_count": 1072 }
[ { "body": "`autocomplete-plus`パッケージの設定を開いて、`Default\nProvider`の設定を`Symbol`から`Fuzzy`に変更し、Atomを再起動してください。これにより、LaTeXのキーワード以外の単語も候補に出現します。\n\n[![https://gyazo.com/301bb45b91de15f0252cc5853bcde072](https://i.gyazo.com/301bb45b91de15f0252cc5853bcde072.gif)](https://gyazo.com/301bb45b91de15f0252cc5853bcde072)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T12:41:29.933", "id": "20921", "last_activity_date": "2016-01-14T12:51:44.913", "last_edit_date": "2016-01-14T12:51:44.913", "last_editor_user_id": "3639", "owner_user_id": "3639", "parent_id": "20906", "post_type": "answer", "score": 8 } ]
20906
20921
20921
{ "accepted_answer_id": "20912", "answer_count": 1, "body": "Monacaを利用したAndroidアプリにアプリ内課金機能を開発しようとしています。\n\nMonacaライセンスはPersonalなのですが、 \n利用できるCordovaプラグインはありますでしょうか?\n\nもし上記が不可能であれば、 \n上のライセンスで利用できるプラグインを教えていただけますでしょうか?\n\n初歩的な質問で申し訳ありません。ご教示お願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T05:07:41.230", "favorite_count": 0, "id": "20910", "last_activity_date": "2020-09-28T19:08:19.917", "last_edit_date": "2020-09-25T13:51:39.617", "last_editor_user_id": "32986", "owner_user_id": "14007", "post_type": "question", "score": 0, "tags": [ "javascript", "monaca", "アプリ内課金" ], "title": "MonacaのPersonalプランで利用できるアプリ内課金プラグインはありますか?", "view_count": 1564 }
[ { "body": "**Personalプラン** では **Cordovaプラグイン組み込み** は出来ません。 \n[料金プラン一覧](https://monaca.mobi/ja/pricing)に出来ることが記載されております。 \nそれ以外となるとMonacaが提供しているプラグインしか設定できません。 \nMonacaの提供しているプラグインのリストの中に課金の仕組みを実現できるものは無かったかと思います。\n\nMonacaにて外部プラグインの導入を検討するのであれば **Goldプラン** 以上のアカウントである必要があります。 \nおそらく`Cordovaプラグイン`か`PhoneGapプラグイン`のどちらかと入れることになるかと思います。 \nプラグイン導入に関してはMonacaのサポート範囲外ですのでCordovaの知識を多少なり身につける必要があるかと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T06:32:36.253", "id": "20912", "last_activity_date": "2016-01-14T06:32:36.253", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "20910", "post_type": "answer", "score": 1 } ]
20910
20912
20912
{ "accepted_answer_id": "20914", "answer_count": 1, "body": "Railsで開発している場合Sassを使って開発する場面も多いかと思います。\n\nSassには`@import`がありますが、 \nRailsには`Sprockets`もあります。\n\n`Sprockets`の`require`や`require_tree`と **CSSをまとめる** という最終目的は同じように思います。\n\n使い分けのベストプラクティスはあるのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T05:12:22.893", "favorite_count": 0, "id": "20911", "last_activity_date": "2016-01-14T07:13:53.183", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "sass" ], "title": "Sassの@importとSprocketsのrequire, require_treeの使い分けは?", "view_count": 1564 }
[ { "body": "基本的にSassを使うなら、Sassのファイルに関しては`@import`でファイルをロードするのが無難と思います。 \nRailsガイドに[それに関する記載](http://railsguides.jp/asset_pipeline.html#%E3%83%9E%E3%83%8B%E3%83%95%E3%82%A7%E3%82%B9%E3%83%88%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%A8%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%86%E3%82%A3%E3%83%96)もあります。\n\n> Sassファイルを複数使用しているのであれば、Sprocketsディレクティブで読み込まずにSass \n>\n> @importルールを使用する必要があります。このような場合にSprocketsディレクティブを使用してしまうと、Sassファイルが自分自身のスコープに置かれるため、その中で定義されている変数やミックスインが他のSassから利用できなくなってしまいます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T07:13:53.183", "id": "20914", "last_activity_date": "2016-01-14T07:13:53.183", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9403", "parent_id": "20911", "post_type": "answer", "score": 2 } ]
20911
20914
20914
{ "accepted_answer_id": null, "answer_count": 1, "body": "お世話になります。よろしくお願いいたします。\n\nMonacaで日々の運動記録を作ろうと思っています。 \n<http://docs.monaca.mobi/cur/ja/sampleapp/samples/todo/>\n\n新規作成し、TODOリストを読み込みました。\n\nそのまま携帯と連携して動作させたところ、 \nAddした後のデータがクリアされず、 \n前回の値が保持されたままになってしまっています。\n\nこれは、元の提供のデータがおかしいということでしょうか?\n\nまた、メモ帳とストップウォッチを使い \n行った時間を記録していきたいと思っています。 \n<http://www.red.oit-net.jp/tatsuya/java/stopw.htm>\n\n上記を参考に、HTMLに組み込んでも動きませんでした。\n\n良い勉強サイト等ありませんか?\n\n作ろうとしているものとしては、\n\nTOPぺーじにA,Bの画像2つ、ボタン2つ \nボタンをおしたら、それぞれのHTML(A,B)に移動 \nA,Bそれぞれ、Aの画像とストップウォッチ、Bの画像とストップウォッチがある \n(カウントダウン形式) \n終わったら、リストに結果を保存\n\nTOPページは作れます。 \nボタンをおしたらそれぞれのHTMLに移動も可能(なはずです) \nストップウォッチの表示がどうにも上手く行きません。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T10:19:20.973", "favorite_count": 0, "id": "20917", "last_activity_date": "2016-01-15T01:08:58.573", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": -3, "tags": [ "javascript", "monaca", "html", "html5" ], "title": "TODOリストの値がクリアされない、ストップウォッチが表示されない", "view_count": 234 }
[ { "body": "MonacaのサンプルのToDo Appのことだと仮定します。 \nこのサンプルはToDoをAddした後に値のクリアをしていないので値が残っています。 \nAddした後に値をクリアしたい場合は、自分でクリアする処理を実装しましょう。\n\nストップウォッチの件ですが、せめてソースを提示して頂けないと \n何が原因で表示が上手くいっていないのか回答することができません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T01:08:58.573", "id": "20936", "last_activity_date": "2016-01-15T01:08:58.573", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6040", "parent_id": "20917", "post_type": "answer", "score": 1 } ]
20917
null
20936
{ "accepted_answer_id": "20929", "answer_count": 1, "body": "```\n\n ユーザ毎に電話番号を登録します。\n ユーザは複数の電話帳を登録できて、上記の登録済みの電話番号を電話帳に登録できます。\n 電話番号は、複数の電話帳に登録が可能です。\n \n```\n\nとしたい時のテーブル設計で悩んでいます。\n\n今のところは、電話帳テーブルのユニークなIDをtag的に電話番号に付与しようと思っています。 \nただ、そうすると、tagカラムの文字列長が気になっちゃったり、CLOB使うか?とか思っちゃったり、悩みどころが多くて困っています。 \nもちろん電話帳から電話番号を絞りこんだりしたいです。\n\nイメージ的には、スマホなどのアドレス帳で、1つの連絡先に複数のグループを指定できるというのが近い感じだと思います。\n\nこういう多対多のようなデータ設計って、どうしてやるのが良いんでしょうか? \n今回以外でも似たような状況があったんですが...その時は紐付けテーブル(電話帳と電話番号を結び付けるだけのテーブル)が用意されていました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T11:04:50.747", "favorite_count": 0, "id": "20919", "last_activity_date": "2016-01-14T14:06:57.773", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2383", "post_type": "question", "score": 3, "tags": [ "database", "oracle" ], "title": "電話帳のテーブル設計", "view_count": 1011 }
[ { "body": "もし私が実装するなら、ユーザーは複数の電話番号を持てるのかどうか、仕様確認すると思います。 \n複数持てるとするならば、「ユーザー、番号、電話帳」の3つが実体を持つデータで、それぞれを中間テーブルで繋げば良いのかと思いました。\n\n[![画像の説明をここに入力](https://i.stack.imgur.com/ByQnS.png)](https://i.stack.imgur.com/ByQnS.png)", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T14:06:57.773", "id": "20929", "last_activity_date": "2016-01-14T14:06:57.773", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7471", "parent_id": "20919", "post_type": "answer", "score": 3 } ]
20919
20929
20929
{ "accepted_answer_id": null, "answer_count": 1, "body": "Androidアプリの質問です。\n\nadmob で、同じページ複数の広告を表示させる方法教えてください。\n\n1つの広告は表示できました。\n\nよろしくお願いいたします\n\n* * *\n\n2ページ目にも 表示出来ないのですが\n\nどうすれば良いでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T12:49:24.937", "favorite_count": 0, "id": "20922", "last_activity_date": "2016-01-15T10:01:36.280", "last_edit_date": "2016-01-15T10:01:36.280", "last_editor_user_id": "30", "owner_user_id": "14014", "post_type": "question", "score": -1, "tags": [ "android", "java", "admob" ], "title": "admobで 同じページ複数の広告を表示させる方法教えてください。", "view_count": 1539 }
[ { "body": "AdMobのポリシーを確認してください。 \n1ページに表示できる広告は1つまでです。 \n<https://support.google.com/admob/answer/2753860#ad_placement>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T15:33:09.460", "id": "20933", "last_activity_date": "2016-01-14T15:33:09.460", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9498", "parent_id": "20922", "post_type": "answer", "score": 6 } ]
20922
null
20933
{ "accepted_answer_id": "21343", "answer_count": 1, "body": "複数のスレッドから扱うメモリーデータをアクセスする場合に排他をかけたいと考えています。 \nメモリーデータへのset/get/updateの関数があり、updateの関数では更新した結果を戻したいと考えています。 \nその場合、どのようにするのが一般的なのでしょうか。\n\n現状は以下のようにすればどうだろうと考えています。\n\n```\n\n func set(input: Int) {\n let semaphore = dispatch_semaphore_create(0)\n var retval:Int!\n dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {\n \n self.クラスデータ = input\n \n dispatch_semaphore_signal(semaphore)\n }\n dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)\n }\n \n \n func get() -> Int{\n let semaphore = dispatch_semaphore_create(0)\n var retval:Int!\n dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {\n \n retval = self.クラスデータ\n \n dispatch_semaphore_signal(semaphore)\n }\n dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)\n return retval\n }\n \n```\n\n(ご指摘により、質問を修正しました)", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T13:39:44.610", "favorite_count": 0, "id": "20926", "last_activity_date": "2016-01-26T12:00:35.557", "last_edit_date": "2016-01-26T11:29:29.770", "last_editor_user_id": "12842", "owner_user_id": "12842", "post_type": "question", "score": 0, "tags": [ "ios", "swift" ], "title": "排他処理終了後の戻り値", "view_count": 324 }
[ { "body": "最初に前提条件として、その`クラスデータ`の操作は(排他制御は必要であるが)1回あたりの処理時間はせいぜいマイクロ秒のオーダーで終了するようなデータ構造(DictionaryやArray,\nSetなどはみな該当します)であるものとしておきます。\n\n編集後にご掲載のコードは、「非同期処理の待ち合わせ」としては典型的なパターンですが、前提条件に合致するようなデータ構造を操作する場合の排他制御としては、あまり適切とは言えません。\n\nこのような排他制御の場合にsemaphoreを用いる際の基本は、\n\n * 排他されるべき一つの資源ごとに一つのsemaphoreを用意する\n * 使う前にwait\n * 使い終わったらsignal\n\nと言うことです。\n\n具体的には次のような感じになります。\n\n```\n\n var クラスデータ_semaphore = dispatch_semaphore_create(1)\n var クラスデータ = (クラスデータの初期化)\n \n```\n\nのように、排他制御したいデータ構造と対になるようにして、初期値が1になるようなsemaphoreを作成します。この`1`は、排他制御される資源を同時に使用できるスレッドが一つだけであることを表しています。それを実際に使う場合は、以下のようになります。\n\n```\n\n func set(input: Int) {\n //使う前にsemaphoreのカウンター(使える資源数)が1以上になるのを待つ\n dispatch_semaphore_wait(クラスデータ_semaphore, DISPATCH_TIME_FOREVER)\n \n self.クラスデータ = input\n \n //使い終わったらsemaphoreのカウンターを1増やして資源の使用終了を通知する\n dispatch_semaphore_signal(クラスデータ_semaphore)\n }\n \n \n func get() -> Int {\n let retval: Int\n //使う前にsemaphoreのカウンター(使える資源数)が1以上になるのを待つ\n dispatch_semaphore_wait(クラスデータ_semaphore, DISPATCH_TIME_FOREVER)\n \n retval = self.クラスデータ\n \n //使い終わったらsemaphoreのカウンターを1増やして資源の使用終了を通知する\n dispatch_semaphore_signal(クラスデータ_semaphore)\n \n return retval\n }\n \n```\n\nいかがでしょうか。わかりにくいところがあればお知らせください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-26T12:00:35.557", "id": "21343", "last_activity_date": "2016-01-26T12:00:35.557", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "20926", "post_type": "answer", "score": 2 } ]
20926
21343
21343
{ "accepted_answer_id": "20930", "answer_count": 1, "body": "引数、返り値なしのblockの実行方法が分かりません。\n\n下記コードで引数なし、返り値なしのblockと引数あり、返り値なしのblockをテストしています。\n\n```\n\n - (void)test1:(void(^)(void))block {\n NSLog(@\"test1呼び出し\");\n (void)block;\n }\n \n - (IBAction)test1Tapped:(id)sender {\n [self test1:^{\n NSLog(@\"ブロック実行\");\n }];\n }\n \n - (void)test2:(void(^)(NSString *))block {\n NSLog(@\"test2呼び出し\");\n block(@\"ブロックの引数\");\n }\n \n - (IBAction)test2Tappeed:(id)sender {\n [self test2:^(NSString *string) {\n NSLog(@\"ブロック実行: %@\", string);\n }];\n }\n \n```\n\ntest2Tappedメソッドではtest2メソッドに付属しているブロックが実行されましたが \ntest1Tappedメソッドではtest1メソドに付属しているブロックが実行されませんでした。 \nSDKの`- (void)presentViewController:(UIViewController *)viewControllerToPresent\nanimated:(BOOL)flag completion:(void\n(^)(void))completion`メソッドではtest1Tappedメソッドと同じように空のブロック`^{\n}`でメソッド完了後の処理が記述できているので`test1`メソッドで同じことができてもおかしくないと思うのです。\n\n原因および解決策わかる方いましたらご教授お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T13:45:26.883", "favorite_count": 0, "id": "20927", "last_activity_date": "2016-01-14T14:23:08.353", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12232", "post_type": "question", "score": 0, "tags": [ "objective-c", "クロージャ" ], "title": "Objective-c 引数、返り値なしのblockの実行方法", "view_count": 1579 }
[ { "body": "このコードはblockそのものをvoidにキャストしているだけで、block呼び出しにはなっていません。\n\n```\n\n - (void)test1:(void(^)(void))block {\n NSLog(@\"test1呼び出し\");\n (void)block;\n }\n \n```\n\n(引数のない)blockを呼び出したいのであれば、(空の)カッコが必要です。\n\n```\n\n - (void)test1:(void(^)(void))block {\n NSLog(@\"test1呼び出し\");\n (void)block();\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T14:23:08.353", "id": "20930", "last_activity_date": "2016-01-14T14:23:08.353", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "20927", "post_type": "answer", "score": 2 } ]
20927
20930
20930
{ "accepted_answer_id": "21097", "answer_count": 2, "body": "apache2.4をインストールして、Laravelフレームワークを使うため、 \nドキュメントルートを下記のようにしました。\n\nDocumentRoot \"/root/test/laravel/public\" \nServerName mailsvr-01.local:80\n\n※Laravel3.0を/root/test/配下にダウンロードしました\n\nブラウザからアクセスすると、下記の表記が表示されます。 \nアクセス:<http://XX.XX.XX.XX> \n※クラウド環境のため、[http://localhostでアクセスできない](http://localhost%E3%81%A7%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84)\n\nYou don't have permission to access / on this server.\n\nアクセスログには下記のような表示がされております。 \n[14/Jan/2016:18:34:30 +0000] \"GET / HTTP/1.1\" 403 209\n\nどこの設定を変更すればよいのかご教授願えますでしょうか。\n\n以上、よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-14T18:38:15.523", "favorite_count": 0, "id": "20934", "last_activity_date": "2016-01-19T22:44:38.780", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13426", "post_type": "question", "score": 0, "tags": [ "php", "laravel" ], "title": "You don't have permission to access / on this server.がでてアクセスできない", "view_count": 25899 }
[ { "body": "ディレクトリにアクセス([http://xxx.xx.xxx.xx/aa/bb/のように](http://xxx.xx.xxx.xx/aa/bb/%E3%81%AE%E3%82%88%E3%81%86%E3%81%AB)、ファイル名を含まないURLでアクセス)した場合に、以下のエラーが出る状況は、次のようなものが考えられます。\n\n> You don't have permission to access / on this server\n\n1.httpd.configファイル(webサーバの設定を記載するファイル)に、DirectoryIndexの記載がない場合。\n\nDirectoryIndexは、ファイル名を含まないURLでアクセスされた場合に表示するファイルの名前を設定しておくもので、複数のファイル名を設定できます。 \nこの設定がないと、webサーバはディレクトリを返そうとしますが、ディレクトリは内容を読み取られないようにセキュリティ設定されているので、permissionが無いというエラーになります。\n\n2.httpd.configファイルにDirectoryIndexの記載はあるが、index.htmlなどのファイルが存在しない場合。\n\nDirectoryIndexで、index.htmlの内容を返すように設定しているのに、/root/test/laravel/public/の中にindex.html\nというファイルが存在しない場合にも、同様にエラーとなります。\n\n1.が原因の場合は、httpd.configファイルの記述を修正する事で解決できます。 \n2.が原因の場合は、正しいディレクトリに正しい名前でファイルを置くことで解決できます。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T09:51:33.417", "id": "20946", "last_activity_date": "2016-01-15T09:51:33.417", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "217", "parent_id": "20934", "post_type": "answer", "score": 0 }, { "body": "/rootディレクトリ配下はrootユーザーでなければアクセス出来ないため、/root以外(例えば/varや/tmp)の下にディレクトリを作り、ファイル一式を移動、ドキュメントルートも更新して参照すると、どうなるでしょうか。 \n通常Apacheの子プロセスはapacheやnobodyなどrootではない一般ユーザーで動作しているため、/root配下のディレクトリは参照出来ないと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T22:44:38.780", "id": "21097", "last_activity_date": "2016-01-19T22:44:38.780", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9017", "parent_id": "20934", "post_type": "answer", "score": 0 } ]
20934
21097
20946
{ "accepted_answer_id": "21203", "answer_count": 1, "body": "herokuにRailsアプリをデプロイしました。 \nしかし、使用しているiconが反映されません。\n\nMaterial design liteを使用しており`rake\nassets:precompile`後、herokuにデプロイするとMaterialのCSS/JSはうまく反映されているのですが、アイコンのみ文字で表示されてしまいます。\n\n`bower`を使ってインストールしており、以下のようにvender以下のmaterial-design-\niconsのディレクトリへのパスの設定を試みましたがうまくいきません。 \n`config/application.rb` \n`config.assets.paths << \"#{Rails}/vendor/assets/material-design-icons\"`\n\nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T03:46:53.677", "favorite_count": 0, "id": "20937", "last_activity_date": "2016-01-24T02:40:25.407", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14020", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "heroku" ], "title": "herokuにRailsアプリをデプロイ後、使用しているiconが反映されない。", "view_count": 462 }
[ { "body": "logにはどのようなエラーが出ていますでしょうか?\n\n対象のプロジェクト内で`heroku logs` または `heroku logs\n--tail`のコマンドでlogを閲覧できますので、まずはエラーを特定してみてはどうでしょうか。\n\nまた参考までとなりますが、 **Asset Pipeline** に関しては、\n\n * Rails3系 (<https://devcenter.heroku.com/articles/rails-asset-pipeline#the-rails-3-asset-pipeline>)\n * Rails4系 (<https://devcenter.heroku.com/articles/rails-4-asset-pipeline>)\n\nに説明がありますので、設定を見直してみると良いかもしれません。(注:\n`config.serve_static_assets`は4.2系から`config.serve_static_file`に変更されています)\n\nちなみに、Railsプロジェクト以下にある`/vendor/assets/material-design-icons`を指したいのであれば、\n\n```\n\n config/application.rb\n config.assets.paths << \"#{Rails}/vendor/assets/material-design-icons\"\n \n```\n\n↓\n\n```\n\n config.assets.paths << \"#{Rails.root}/vendor/assets/material-design-icons\"\n \n```\n\nとなるかと思います。 \n余談となってしまいますが、変数やメソッドの戻り値/挙動を確認したい場合は`rails console` \nで実行してみると良いかと思います。\n\ne.g.\n\n```\n\n $ cd ~/src/github.com/fukuiretu/hoge # hogeは対象のRailsプロジェクト\n $ bundle exec rails console\n Loading development environment (Rails 4.2.4)\n [1] pry(main)> Rails.root => # <Pathname:/Users/fukuiretu/src/github.com/fukuiretu/hoge>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-22T22:40:15.200", "id": "21203", "last_activity_date": "2016-01-24T02:40:25.407", "last_edit_date": "2016-01-24T02:40:25.407", "last_editor_user_id": "13874", "owner_user_id": "13874", "parent_id": "20937", "post_type": "answer", "score": 1 } ]
20937
21203
21203
{ "accepted_answer_id": null, "answer_count": 1, "body": "Inappbrowserを使う際、以下のような実装方法がわかりません。 \n是非、ご教授頂ければと思います。\n\n・下層面のヘッダー部分を残した表示方法 \n・表示した後、アプリ側で用意したフッターを表示する方法\n\nアプリ内ブラウザである事をユーザに伝えるには、上記のような工夫が不可欠かと思います。 \n例えば、リンク集の特定サイトをクリックした際、アプリ内ブラウザで表示する際、アプリ内で表示されている事が認識できませんので・・・。\n\nまた、Inappbrowserを使った際、location=yesを使うと、かなり見栄えの悪い<>と×が出てしまいます。 \nこれを修正する方法も、ご教示頂けるとたすかります。\n\n出来れば、実例があると助かります。 \n(どなたかのアプリで実装されていたら、インストールして確認させて頂ければと思います)\n\nよろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T04:44:05.417", "favorite_count": 0, "id": "20938", "last_activity_date": "2016-01-16T07:42:04.927", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14021", "post_type": "question", "score": -3, "tags": [ "javascript", "monaca", "html", "html5" ], "title": "Inappbrowserの表示について", "view_count": 598 }
[ { "body": "ご利用されているプランなど、前提条件が分かりませんが2つほど……\n\n`InAppBrowser`はMonacaが採用している **Cordovaプラグイン** です。 \nCordovaプラグインが提供しているUIが目的に沿わないのであれば \n`WebView`を表示するプラグインを自身で作るか、 \nsandbox属性を付与してiframe内で表示するかどちらかです。\n\nアプリにもよると思いますが、 \niframeであれば難しいことはありません。 \nですが、あまり見知らぬWebページを徘徊させるのは危険です。 \n念のためsandboxを付けるのが無難かと思います。\n\nプラグインを作成する方ですが、 \nMonacaでやるならGoldプラン以上のアカウントが必要です。 \n……そもそもプラグインを作成できる能力があるのであれば \n素直にCordovaで開発することをお勧めします。\n\n* * *\n\n**追記** \nちなみに採用しているcordovaプラグインは[こちら](https://github.com/apache/cordova-plugin-\ninappbrowser)になります \nMonacaのドキュメントは[こちら](http://docs.monaca.mobi/3.5/ja/reference/phonegap_3.5/ja/inappbrowser/)です。 \nどういったWebページを表示するのか分かりませんが \nご自身が管理されているWebページのみを見せるのであれば \nツールバーを非表示にしてしまってWebページでUIを作り \nハッシュやリクエストを付けてURLをアプリ側で読み取りながら制御することも可能です \nCordovaはMonacaに比べて更に敷居が高いと思いますし \nCordovaプラグインを作成するとなると`Java`や`Objective-C` or `Swift` or `Swift2`の知識も必要です。 \n時間と手間暇との相談になるかと思いますが、 \n何を採用、優先して、どのように実現するかを明確にすると詳しくアドバイスなどを求められるかと思います", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T06:10:58.227", "id": "20939", "last_activity_date": "2016-01-16T07:42:04.927", "last_edit_date": "2016-01-16T07:42:04.927", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "20938", "post_type": "answer", "score": 0 } ]
20938
null
20939
{ "accepted_answer_id": null, "answer_count": 2, "body": "総務省統計局のe-statのAPIを利用して日本の総人口のデータをjsonで取得しました。\n\nそのjsonデータの中で自分の目当ての値のみ変数に格納したいのですが、いくら調べてもやり方がわからないでいます。\n\nそもそもそのようなことができるのかわかりませんが、なにか助言を頂けるとありがたいです。\n\n使用言語はjavascriptです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T07:28:26.467", "favorite_count": 0, "id": "20940", "last_activity_date": "2016-01-15T08:49:28.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13185", "post_type": "question", "score": -3, "tags": [ "javascript", "json" ], "title": "json形式のデータにおいて特定の値の取り出し方について", "view_count": 87981 }
[ { "body": "> jsonで取得しました。\n\njsonとはjson文字列のことですか? \nパースしてObjectから取得してはどうでしょう? \nパースした結果、多次元配列なのかどうか構造が分かりませんが……\n\n```\n\n //json文字列\n var json_data = '{\"suffix1\":\"value1\",\"suffix2\":\"value2\",\"suffix3\":\"value3\"}';\n //JSONをパース\n var data = JSON.parse(json_data);\n alert(data[\"suffix1\"]);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T07:52:08.920", "id": "20941", "last_activity_date": "2016-01-15T07:52:08.920", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "20940", "post_type": "answer", "score": 1 }, { "body": "こんにちは\n\nJSONデータを表示する感じでしょうか? \n昔、QiitaでjQueryを使用して取得するサンプル記事を書いたことがあったのでリンク貼っておきます。ご参考までに。\n\n<http://qiita.com/miiitaka/items/f77cb83b9dfcd05aea82>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T08:49:28.813", "id": "20945", "last_activity_date": "2016-01-15T08:49:28.813", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2265", "parent_id": "20940", "post_type": "answer", "score": 1 } ]
20940
null
20941
{ "accepted_answer_id": "20944", "answer_count": 1, "body": "Amazon ELBにつないでいる、EC2(Amazon Linux)にNginxをインストールして起動するとエラーが出ます。\n\n用途として、Apacheを起動したままで、Kibana用にNginxを使いたいです。 \nEC2,ELB環境にNginxをインストールして起動したのですが、以下の通りエラーが出てきます。\n\n**設定ファイルを編集:**\n\n```\n\n $ sudo vi /etc/nginx/conf.d/virtual.conf\n \n server {\n listen *:10080 ;\n \n server_name localhost;\n access_log /var/log/nginx/kibana.access.log;\n \n location /kibana/ {\n root /usr/share/nginx/html;\n index index.html index.htm;\n }\n \n location / {\n proxy_pass http://127.0.0.1:9200;\n proxy_read_timeout 90;\n }\n }\n \n```\n\n**nginx サービスを起動:**\n\n```\n\n $ sudo service nginx start\n \n Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)\n nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)\n nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)\n nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)\n nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)\n nginx: [emerg] still could not bind()\n \n```\n\n* * *\n\n`lsof` コマンドでポートの使用状況を調べると以下の通りですが、Nginxが使われておらず、どれを`kill`したらいいのかわからないです。 \nhttpdを止めて、nginxを起動すると成功するんですが、ELBでout of service になってしまいます。\n\n```\n\n $ sudo lsof -i:80\n \n COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME\n httpd 2456 root 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2535 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2536 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2536 apache 9u IPv6 13343 0t0 TCP ip-111-11-11-111.ap-northeast-1.compute.internal:http->ip-111-11-11-11.ap-northeast-1.compute.internal:54275 (ESTABLISHED)\n httpd 2537 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2538 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2538 apache 9u IPv6 13342 0t0 TCP ip-111-11-11-111.ap-northeast-1.compute.internal:http->ip-222-22-22-222.ap-northeast-1.compute.internal:39934 (ESTABLISHED)\n httpd 2539 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2588 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2589 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2590 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n httpd 2701 apache 4u IPv6 10447 0t0 TCP *:http (LISTEN)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2016-01-15T08:13:38.990", "favorite_count": 0, "id": "20942", "last_activity_date": "2022-08-28T08:45:09.730", "last_edit_date": "2022-08-28T08:45:09.730", "last_editor_user_id": "3060", "owner_user_id": "10980", "post_type": "question", "score": 0, "tags": [ "nginx", "amazon-linux" ], "title": "Amazon Linux で Nginx を起動するとエラー: Address already in use", "view_count": 402 }
[ { "body": "apacheが動いていますね。 \nAmazon Linux or CentOS であれば `sudo service httpd stop` で apache を停止してみてください。 \nまた、 `sudo chkconfig httpd off` で apache の自動起動を無効化してください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T08:45:22.407", "id": "20944", "last_activity_date": "2016-01-15T08:45:22.407", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "20942", "post_type": "answer", "score": 2 } ]
20942
20944
20944
{ "accepted_answer_id": null, "answer_count": 1, "body": "Unity を始めてからまだ5日の初心者です。初歩的な内容で申し訳ありませんが、プレハブについて教えてください。\n\nあるボタンにクリックイベントを作成してスクリプトをインスペクタしたあとそのボタンをプレハブ化するとイベントやスクリプトがなくなってしまうのはプレハブ化における普通の出来事なのでしょうか? \n \nプレハブは再利用可能な部品という概念ならば、スクリプトもプレハブに組み込まれると思っていたのですが…。\n\nよろしくご指導ください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T08:14:37.540", "favorite_count": 0, "id": "20943", "last_activity_date": "2016-07-13T04:33:58.887", "last_edit_date": "2016-01-15T09:05:45.137", "last_editor_user_id": "76", "owner_user_id": "14023", "post_type": "question", "score": 1, "tags": [ "unity3d", "ugui" ], "title": "プレハブ化したオブジェクト(ボタン)のスクリプト", "view_count": 3253 }
[ { "body": "状況を正確に把握できていないかもしれませんが、おそらく「スクリプトをアタッチしたGameObjectがプレハブに含まれていない」のが原因ではないかと推察します。\n\nプレハブ化するボタン自体にスクリプトをアタッチするか、スクリプトをアタッチしたGameObjectをボタンの子供にする(入れ子にする)など、スクリプトをアタッチしたGameObjectをプレハブに含めれば解決するものと考えます。\n\n一応手元で簡単なプロジェクトでご質問の現象が起きることと、上記方法で解決することを確認しました。よろしければお試しください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T13:54:35.277", "id": "21087", "last_activity_date": "2016-01-19T13:54:35.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3783", "parent_id": "20943", "post_type": "answer", "score": 1 } ]
20943
null
21087
{ "accepted_answer_id": null, "answer_count": 1, "body": "既存のJSライブラリをElmアプリから使うため、ネイティブモジュールでラッピングしました。しかし、最後のelm-makeでコケます。\n\n```\n\n # 単体コンパイルをテストするコマンド。\n # 実際はwebpackとelm-webpack-loaderでコンパイルするようにセットアップしてある\n $ elm-make app/frontend/elm/Mermaid.elm\n I cannot find find module 'Native.Mermaid'.\n \n Module 'Mermaid' is trying to import it.\n \n Potential problems could be:\n * Misspelled the module name\n * Need to add a source directory or new dependency to elm-package.json\n \n```\n\nファイル配置:\n\n```\n\n $ find app/frontend/elm/ -iname \"Mermaid.*\"\n app/frontend/elm//Mermaid.elm\n app/frontend/elm//Native/Mermaid.js\n \n```\n\n中身: Mermaid.elm\n\n```\n\n module Mermaid where\n {-| ...\n -}\n \n import Html exposing (Html)\n import Native.Mermaid\n \n ...\n \n```\n\n中身: Native/Mermaid.js\n\n```\n\n // setup\n Elm.Native = Elm.Native || {};\n Elm.Native.Mermaid = Elm.Native.Mermaid || {};\n \n // definition\n Elm.Native.Mermaid.make = function(localRuntime) {\n 'use strict';\n \n if ('values' in Elm.Native.Mermaid) {\n return Elm.Native.Mermaid.values;\n }\n \n ...\n \n return Elm.Native.Mermaid.values = {\n toHtmlWith: F2(toHtmlWith)\n };\n };\n \n```\n\nelm-markdownライブラリをほぼコピペしたようなものなのですが、どうすればコンパイルが通るようになるでしょうか", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T10:28:13.063", "favorite_count": 0, "id": "20947", "last_activity_date": "2017-04-30T09:02:38.167", "last_edit_date": "2017-04-30T09:02:38.167", "last_editor_user_id": "19110", "owner_user_id": "30", "post_type": "question", "score": 1, "tags": [ "javascript" ], "title": "Elmのネイティブモジュールが見つからないと言われる", "view_count": 138 }
[ { "body": "ネイティブモジュールを含むパッケージは、そのことをelm-package.json内で明示する必要があります。\n\n```\n\n ...\n \"exposed-modules\": [],\n \"native-modules\": true, // <---\n \"dependencies\": {\n ...\n \n```\n\nこれは、JavaScriptの世界はElmの型チェックが及ばず、副作用も起こし放題で危険なため、JavaScriptを含むパッケージを区別して扱えるようにするためです。ネイティブモジュールを含むパッケージは公式パッケージレポジトリにアップロードする際にレビューをはさむようにもなっています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T10:28:13.063", "id": "20948", "last_activity_date": "2016-01-15T10:28:13.063", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "30", "parent_id": "20947", "post_type": "answer", "score": 2 } ]
20947
null
20948
{ "accepted_answer_id": null, "answer_count": 2, "body": "Node-REDで操作を間違えたときに元に戻したいのですが方法はありますか。 \nヘルプのKeyboard shortcutsのリストにはないようですが。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T11:18:30.480", "favorite_count": 0, "id": "20949", "last_activity_date": "2016-02-02T04:12:13.567", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14025", "post_type": "question", "score": 0, "tags": [ "bluemix" ], "title": "Node-REDでUndoしたい", "view_count": 425 }
[ { "body": "「Ctrl + Z」でUndoできます。\n\n(「Ctrl + Y」でRedoできると嬉しいのですが、それは実装されていないようです)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T11:33:42.240", "id": "20950", "last_activity_date": "2016-01-15T11:33:42.240", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10502", "parent_id": "20949", "post_type": "answer", "score": 1 }, { "body": "ローカルでの開発でよければ、フローを Git で管理する方法が Node-RED ユーザー会で披露されました。 \nFlowを自動でgit commitする仕組みを作ってみた話 \n<http://jaco.udcp.info/flow-git/>\n\nBluemixでは、cloudant の nodered\ndbに格納されるので、原理的には保存のタイミングで新しいドキュメントを作成することができると思われます。具体的には couchstorage.js の\nsaveFlow あたりです。自分で試してなくて申し訳ないです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-02-02T04:12:13.567", "id": "21607", "last_activity_date": "2016-02-02T04:12:13.567", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2789", "parent_id": "20949", "post_type": "answer", "score": 1 } ]
20949
null
20950
{ "accepted_answer_id": null, "answer_count": 1, "body": "SoftLayerのWebサイトが日本語されましたが、英語で表示したいこともあります。しかしブラウザの言語設定を英語にしても日本語のサイトにリダイレクトされてしまいます。英語で見る方法はありますか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T11:37:45.150", "favorite_count": 0, "id": "20951", "last_activity_date": "2016-03-15T21:10:35.037", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14026", "post_type": "question", "score": 0, "tags": [ "softlayer" ], "title": "SoftLayerのWebサイトを英語で表示したい", "view_count": 69 }
[ { "body": "プロフィール設定で表示言語を変更することができます:\n\n<https://control.softlayer.com/account/user/profile>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T15:42:46.860", "id": "20960", "last_activity_date": "2016-01-15T20:08:49.150", "last_edit_date": "2016-01-15T20:08:49.150", "last_editor_user_id": "30", "owner_user_id": "14028", "parent_id": "20951", "post_type": "answer", "score": 1 } ]
20951
null
20960
{ "accepted_answer_id": "20958", "answer_count": 2, "body": "[merge two arrays into a hash - Ruby Forum](https://www.ruby-\nforum.com/topic/125944)を参考に2つのArrayからHashを作る方法を書きました。\n\n```\n\n keys = %i(a b c)\n values = [1,2,3]\n Hash[*keys.zip(values).flatten] #=> {:a=>1, :b=>2, :c=>3}\n \n```\n\nこの場面に出てくる`*`の意味はなんでしょうか?\n\n```\n\n p *keys\n \n```\n\nとした場合\n\n> :a \n> :b \n> :c\n\nと出力されてしまいますし、RubyMineのブレイクポイントで確認しようとすると、\n\n```\n\n 0> *keys\n => /Users/shingo/Documents/sample/hoge.rb:3: syntax error, unexpected '.', expecting '='\n (*keys).inspect\n \n```\n\nとなってしまいます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T12:18:25.853", "favorite_count": 0, "id": "20952", "last_activity_date": "2016-01-18T12:36:37.730", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9008", "post_type": "question", "score": 0, "tags": [ "ruby" ], "title": "2つのArrayからHashを作る方法に出てくる*の意味は何でしょうか?", "view_count": 150 }
[ { "body": "ドキュメント<http://docs.ruby-lang.org/ja/2.3.0/doc/spec=2fcall.html>に記述があります。\n\n> 最後の引数の直前に * がついている場合、その引数の値が展開されて渡されます\n\n今回の例では、`keys.zip(values).flatten` の結果の `[:a, 1, :b, 2, :c, 3]`\nが展開されて、`Hash[:a, 1, :b, 2, :c, 3]` という呼び出しになり、その結果、`{:a=>1, :b=>2, :c=>3}`\nが得られています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T13:53:57.077", "id": "20958", "last_activity_date": "2016-01-15T13:53:57.077", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3249", "parent_id": "20952", "post_type": "answer", "score": 3 }, { "body": "先の回答で理解できたかと思いますが、*によって引数の値が展開されます。\n\n```\n\n [1] pry(main)> keys = %i(a b c)\n => [:a, :b, :c]\n [2] pry(main)> *keys\n SyntaxError: unexpected '\\n', expecting '='\n [2] pry(main)> :a, :b, :c\n SyntaxError: unexpected '\\n', expecting '='\n \n```\n\n※ `*keys` は `:a, :b, :c` と同じ意味となります。\n\n以上、補足まで。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T01:29:00.657", "id": "20961", "last_activity_date": "2016-01-18T12:36:37.730", "last_edit_date": "2016-01-18T12:36:37.730", "last_editor_user_id": "9008", "owner_user_id": "14015", "parent_id": "20952", "post_type": "answer", "score": 0 } ]
20952
20958
20958
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n <?php namespace App\\Http\\Controllers;\n \n use App\\Http\\Requests;\n use App\\Http\\Controllers\\Controller;\n \n use Illuminate\\Http\\Request;\n use Illuminate\\Contracts\\Mail\\Mailer;\n \n use Illuminate\\Mail\\Message;\n \n use Session;\n \n \n \n class ContactController extends Controller\n {\n /*\n |--------------------------------------------------------------------------\n | Welcomeコントローラー\n |--------------------------------------------------------------------------\n |\n | このコントローラーはアプリケーションの「マーケティングページ」を\n | レンダーし、ゲストのみに表示されるように設定されています。\n | 他のコントローラサンプルと同様、好きなように変更したり、削除してください。\n |\n */\n \n /**\n * 新しいコントローラーインスタンスの生成\n */\n public function __construct()\n {\n #$this->middleware('guest');\n }\n \n /**\n * アプリケーションのウェルカムページをユーザーへ表示\n * 非ログインTOPページ\n * @param bool|false $open\n * @return $this\n */\n \n \n /**\n * お問合せフォーム\n */\n public function getIndex(Request $request)\n {\n // $test = Session::get('set_category');\n $test1 = Session::get('set_category1');\n \n $test2 = $request->session()->get('set_category2');\n \n return view('contact.index');\n }\n \n /**\n * 確認処理\n */\n public function postConfirm(Request $request)\n {\n $this->validate($request, [\n 'locations' => 'required',\n 'situation' => 'required',\n 'generation' => 'required',\n 'name' => 'required',\n 'prefectures' => 'required',\n 'movein' => 'required',\n 'tel' => 'required|numeric',\n 'return' => 'required',\n 'time' => 'required',\n \n \n ]);\n \\Session::flash(\"request\", $request->all());\n return redirect('contact/confirm');\n }\n \n /**\n * 確認ページ\n */\n public function getConfirm()\n {\n if (!\\Session::has('request')) {\n return redirect('contact');\n }\n $request = \\Session::get('request');\n \\Session::keep(['request']);\n \n return view('contact.confirm', $request);\n }\n \n /**\n * メール送信処理\n * Todo:メール送信先を設定に加える\n */\n public function postSend(Request $request)\n {\n $this->validate($request, [\n 'locations' => 'required',\n 'situation' => 'required',\n 'generation' => 'required',\n 'generation' => 'required',\n 'name' => 'required',\n 'prefectures' => 'required',\n 'movein' => 'required',\n 'tel' => 'required|numeric',\n 'return' => 'required',\n 'time' => 'required',\n \n ]);\n \n $data = $request->all();\n \\Session::flash(\"request\", $data);\n \n \\Mail::send('emails.contact', $data, function($message) use ($data)\n {\n $message->from($data['email'], $data['name']);\n $message->to('sample@〇〇.jp', '〇〇 サポートセンター')->subject('【】お問合せフォーム');\n });\n return redirect('contact/send');\n }\n \n /**\n * 送信完了ページ\n */\n public function getSend()\n {\n return view('contact.send');\n }\n \n }\n \n```\n\nフォーム入力後、送信してもメールが送信されません。 \n理由わかりますでしょうか。\n\n上記フォーム部分のコントローラーになります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T12:27:26.743", "favorite_count": 0, "id": "20953", "last_activity_date": "2016-05-03T06:57:30.457", "last_edit_date": "2016-01-15T14:17:10.813", "last_editor_user_id": "8000", "owner_user_id": "14027", "post_type": "question", "score": 0, "tags": [ "laravel" ], "title": "Laravel 5.2 フォーム入力後、メールが送信されない", "view_count": 371 }
[ { "body": "何かエラーが発生していないでしょうか。\n\n私の場合は\n\n```\n\n FatalErrorException in ClassLoader.php line 344:\n Maximum function nesting level of '100' reached, aborting!\n \n```\n\nが発生して送信ができませんでした。\n\n```\n\n ini_set('xdebug.max_nesting_level', 200);\n \\Mail::send(...\n \n```\n\nでエラーにならずにメールが送信できるようになりました。 \n参考になれば幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-02-03T05:49:07.913", "id": "21651", "last_activity_date": "2016-02-03T05:49:07.913", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7402", "parent_id": "20953", "post_type": "answer", "score": 1 } ]
20953
null
21651
{ "accepted_answer_id": "20980", "answer_count": 1, "body": "ViewControllerの画面遷移時に下記コードで、NavigationControllerを追加した所NavigationControllerの灰色のNavigationBarと真っ白なViewのみが表示されてしまいTestVCのViewが表示されない状況です。\n\n```\n\n - (IBAction)buttonTapped:(id)sender {\n UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@\"Main\" bundle:nil];\n TestVC *VC = [storyboard instantiateViewControllerWithIdentifier:@\"TestVC\"];\n UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:VC];\n [self presentViewController:navigationController animated:YES completion:nil];\n }\n \n```\n\nネットで確認した所、上記方法が紹介されていたのですがうまくいきません。 \n対応策ご存知の方いましたらご教授お願いします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T12:53:17.967", "favorite_count": 0, "id": "20954", "last_activity_date": "2016-01-16T11:39:14.347", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12232", "post_type": "question", "score": 0, "tags": [ "ios", "uinavigationcontroller" ], "title": "iOS ModalViewとして表示したViewControllerにNavigationControllerを追加する方法", "view_count": 533 }
[ { "body": "`[navigationController\nsetNavigationBarHidden:YES];`を実装していなかったため自分で実装したnavigationbarがnavigationController付属のbarの下に隠れていたのが原因でした。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T11:39:14.347", "id": "20980", "last_activity_date": "2016-01-16T11:39:14.347", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12232", "parent_id": "20954", "post_type": "answer", "score": 0 } ]
20954
20980
20980
{ "accepted_answer_id": "20956", "answer_count": 1, "body": "<http://ichimaruni-design.com/2015/01/viewport/>\n\n```\n\n <meta name=\"viewport\" content=\"width=device-960px\">\n \n```\n\n上記サイトでViewportのwidthにdevice-960pxを指定しています。 \nこれはどういった効果があるのでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T13:21:08.213", "favorite_count": 0, "id": "20955", "last_activity_date": "2016-01-15T14:16:22.887", "last_edit_date": "2016-01-15T14:16:22.887", "last_editor_user_id": "8000", "owner_user_id": "4191", "post_type": "question", "score": 0, "tags": [ "html5" ], "title": "metaタグviewportのwidth=device-960pxはどういった効果があるのでしょうか?", "view_count": 216 }
[ { "body": "`device-width`を`960`に直そうとして書き間違えたのではないでしょうか。\n\n`device-960px`という形式は少なくとも[Safari](https://developer.apple.com/library/iad/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html)および[Firefox](https://developer.mozilla.org/ja/docs/Web/HTML/Element/meta)でサポートされていません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T13:39:09.077", "id": "20956", "last_activity_date": "2016-01-15T13:39:09.077", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "20955", "post_type": "answer", "score": 1 } ]
20955
20956
20956
{ "accepted_answer_id": null, "answer_count": 1, "body": "OS X 10.11でアセンブリを実行するにはどうすればいいのでしょうか? \nGCCだと普通にアセンブルできるようなのですが(`gcc -o helloworld helloworld.s`でアセンブルできるらしい) \nclangではどうすればいいのでしょうか?\n\n* * *\n\n### 追記\n\nOS X に`as`というコマンドがあり、それがアセンブルをするためのコマンドらしいということは分かりました\n\n* * *\n\n### 追記 2\n\n`as -arch x86_64 -o helloworld\nhelloworld.s`と実行したところ,`helloworld`というファイルが生成されたのですが、その後うまく`ld`ができません。 \n`ld -macosx_version_min 10.11 helloworld`としてみたのですが、 \n下記のようなエラーが出てしまいます\n\n```\n\n ld: warning: -macosx_version_min not specified, assuming 10.10\n ld: warning: object file (helloworld) was built for newer OSX version (10.11) than being linked (10.10)\n ld: dynamic main executables must link with libSystem.dylib for inferred architecture x86_64\n \n```\n\n* * *\n```\n\n \n # original: http://dustin.schultz.io/blog/2010/11/15/mac-os-x-64-bit-assembly-system-calls/\n \n # https://gist.github.com/h2so5/d429d0aec527482f6209\n \n .data\n hello_world: .asciz \"Hello world!\\n\"\n \n .text\n .globl _main\n \n _main:\n mov $0x2000004, %rax\n mov $1, %rdi\n lea hello_world(%rip), %rsi\n mov $14, %rdx\n syscall\n mov $0x2000001, %rax\n mov $0, %rdi\n syscall\n \n \n```", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-15T13:42:48.370", "favorite_count": 0, "id": "20957", "last_activity_date": "2016-04-25T19:20:41.737", "last_edit_date": "2016-01-16T04:21:39.980", "last_editor_user_id": "5246", "owner_user_id": "5246", "post_type": "question", "score": 3, "tags": [ "アセンブリ言語" ], "title": "OS X 10.11でアセンブリを実行する方法", "view_count": 508 }
[ { "body": "cc(1)がld(1)をどのように実行しているかは、\n\n```\n\n cc -v -o helloworld helloworld.s\n \n```\n\nといった感じに`-v`オプションを指定すると調べることができます。(表示された個々のオプションの意味はld(1)のオンラインマニュアルで確認しましょう。)\n\nまた、as(1)でアッセンブルした結果のオブジェクト・ファイルは通常、\n\n```\n\n as -arch x86_64 -o helloworld.o helloworld.s\n \n```\n\nと`.o`のファイル名を使用します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-26T15:15:58.690", "id": "21352", "last_activity_date": "2016-01-26T15:15:58.690", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14124", "parent_id": "20957", "post_type": "answer", "score": 1 } ]
20957
null
21352
{ "accepted_answer_id": null, "answer_count": 1, "body": "```\n\n public class BI2DPv extends javax.swing.JPanel{\n BufferedImage bi;//コレに描画してからg2に転写\n @Override\n public void paintComponent(Graphics g){\n //super.paintComponent(g);\n Graphics2D g2 = (Graphics2D)g;\n logger.log(Level.INFO,\"Entered in paintComponent\");\n //paintComponent(repaint)はbiをg2に転写するだけ。\n if(bi != null)g2.drawImage(bi, null, this);\n }\n //biは別メソッドで生成してあります。\n }\n \n```\n\n`JPanel`を継承したJava2D描画用のクラスを用意しました。メインのクラスの方で`BI2DPv`のインスタンスを生成し、`bi2dpv.repaint();`を実行しても`paintComponent`が実行されません。`bi2dpv.repaint();`が呼ばれていることはログで確認してあります。`repaint`を指示しても`paintComponent`が実行されないのはなぜでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T02:15:29.097", "favorite_count": 0, "id": "20962", "last_activity_date": "2016-10-17T04:52:46.277", "last_edit_date": "2016-01-16T22:18:59.113", "last_editor_user_id": "46", "owner_user_id": "14029", "post_type": "question", "score": 1, "tags": [ "java", "swing" ], "title": "repaintしてもpaintComponentが呼ばれない。", "view_count": 2430 }
[ { "body": "`BI2DPv#repaint()`がどう呼ばれているのかが分からないので推測ですが、その`JPanel`が`JFrame`、または`JApplet`などのトップレベルコンテナに追加されていないのではないでしょうか。\n\n参考: [Top-Level Containers and Containment Hierarchies (The Java™ Tutorials >\nCreating a GUI With JFC/Swing > Using Swing\nComponents)](https://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html)\n\n例えば、以下のサンプルコードでは、一秒ごとに`bi2dpv.repaint();`を実行していますが、`return\nbi2dpv;`をコメントアウトして、`return new\nJPanel();`を実行し、`JFrame`に`bi2dpv`を追加しないようにした場合、`bi2dpv`は非表示なので`bi2dpv#repaint()`メソッドを呼んでも`bi2dpv#paintComponent(...)`メソッドは実行されません。\n\n* * *\n\n**サンプルコード編集** : `JTabbedPane`に`bi2dpv`を追加するよう変更\n\n```\n\n import java.awt.*;\n import java.awt.image.*;\n import javax.swing.*;\n \n public class BI2DPv extends JPanel {\n BufferedImage bi;//コレに描画してからg2に転写\n @Override\n public void paintComponent(Graphics g) {\n super.paintComponent(g);\n Graphics2D g2 = (Graphics2D)g;\n //logger.log(Level.INFO,\"Entered in paintComponent\");\n System.out.println(\"paintComponent\");\n //paintComponent(repaint)はbiをg2に転写するだけ。\n if (bi != null) {\n g2.drawImage(bi, null, this);\n }\n }\n //biは別メソッドで生成してあります。\n \n private static JComponent makeUI() {\n JPanel bi2dpv = new BI2DPv();\n new Timer(1000, e -> {\n System.out.println(\"\\nbi2dpv.repaint()\");\n System.out.println(\"isDisplayable? \" + bi2dpv.isDisplayable());\n System.out.println(\"isShowing? \" + bi2dpv.isShowing());\n System.out.println(\"isVisible? \" + bi2dpv.isVisible());\n bi2dpv.repaint();\n }).start();\n \n JTabbedPane tabbedPane = new JTabbedPane();\n tabbedPane.addTab(\"aaa\", new JPanel());\n tabbedPane.addTab(\"bbb\", bi2dpv);\n return tabbedPane;\n //return new JPanel();\n }\n public static void main(String... args) {\n EventQueue.invokeLater(() -> {\n JFrame f = new JFrame();\n f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);\n f.getContentPane().add(makeUI());\n f.setSize(320, 240);\n f.setLocationRelativeTo(null);\n f.setVisible(true);\n });\n }\n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T17:47:15.140", "id": "20985", "last_activity_date": "2016-01-17T15:09:11.563", "last_edit_date": "2016-01-17T15:09:11.563", "last_editor_user_id": "46", "owner_user_id": "46", "parent_id": "20962", "post_type": "answer", "score": 2 } ]
20962
null
20985
{ "accepted_answer_id": "20965", "answer_count": 2, "body": "**どういう選択肢があるでしょうか?**\n\n**PHP複数バージョン管理ツール「phpenv」** \n・どういうツール? \n・切り替えとはどういう意味?\n\n**例えばですが** \n・同じCentOSサーバにも関わらず、サイト単位で、「PHP5」「PHP7」を指定して、それぞれ同時に使用することは可能? \n・それとも、「phpenv」で「PHP7」を指定したら、すべてのPHPが「PHP7」へ切り替わるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T03:17:50.317", "favorite_count": 0, "id": "20964", "last_activity_date": "2016-01-16T07:11:49.017", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "php", "centos" ], "title": "PHP5をインストールしているCentOSで、PHP7も使用したい", "view_count": 11140 }
[ { "body": "> どういう選択肢があるでしょうか?\n\nDockerが今後流行りそうです。\n\nPHP5.6+Apacheを入れただけのコンテナと、 \nPHP7+Apacheを入れただけのコンテナの2つを用意して \n同じサーバーマシンでありながら2サイトを運営するということが可能です。 \n(コンテナというのは仮想マシンと置き換えて理解するとわかり易いかと思います)\n\n> phpenv\n\n普通にPHPをインストールすると、いざバージョンを上げる時に大騒ぎですよね。 \nphpenvというソフトに複数のバージョンのPHPをインストールしてあげて、 \nコマンド1個で瞬時に切り替える事が出来ます。\n\n> 切り替えとはどういう意味?\n\n<https://github.com/phpenv/phpenv> \nこのサイトから持ってきただけですが、このようにするだけで利用出来るPHPのバージョンを切り替えられます\n\n```\n\n $ phpenv install php-5.3.20\n $ phpenv global 5.3.20\n \n```\n\nまた、localという概念があり、指定したディレクトリ配下のPHPはそちらのバージョンを利用するという事も可能なようです。\n\n```\n\n $ phpenv local 5.3.20\n \n```\n\n> 同じCentOSサーバにも関わらず、サイト単位で、「PHP5」「PHP7」を指定して、それぞれ同時に使用することは可能?\n\nphpenvのコマンドとphpenv-apache-versionの切り替えコマンド \n<http://qiita.com/miosee/items/f0e388f09f084abab97a>\n\nQiitaで調べた所、そのものズバリな事をされている方の記事が見つかりました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T04:46:27.807", "id": "20965", "last_activity_date": "2016-01-16T04:46:27.807", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13999", "parent_id": "20964", "post_type": "answer", "score": 0 }, { "body": "> 同じCentOSサーバにも関わらず、サイト単位で、「PHP5」「PHP7」を指定して、それぞれ同時に使用することは可能?\n\nPHPを動かす方法にもいろいろありますが、狭義のCGI(毎回 `php-cgi`\nを起動する)やmod_fcgid+`FCGIWrapper`を使った方法であれば、VirtualHostやパスごとにphp-\ncgiのパスの指定を切り替えることで可能です。\n\n * [Apache2で複数バージョンのPHPを使い分ける - エーエイチレフ linuxサーバー技術情報](http://www.ahref.org/tech/server/server-tips/667.html)\n * [apache の FastCGI(mod_fcgid) で phpを動かしてみる | レンタルサーバー・自宅サーバー設定・構築のヒント](http://server-setting.info/centos/apache_fastcgi_fcgid_php.html)\n\n一方で、yumでインストールした時のように Apache+mod_php\nという構成の場合、Apache起動時にPHPを読み込んでしまうため、Apacheを複数起動する必要があります。\n\n * [CentOS 7でApacheのインスタンスごとに違うバージョンのPHPを利用する | 俺的備忘録 〜なんかいろいろ〜](http://orebibou.com/2015/06/centos-7%E3%81%A7apache%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%B3%E3%82%B9%E3%81%94%E3%81%A8%E3%81%AB%E9%81%95%E3%81%86%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%E3%81%AEphp%E3%82%92/)\n\nPHP-FPMを使う場合もやはり、PHPのバージョンごとにPHP-FPMを起動する必要があります。\n\n * [php-buildで複数バージョンのPHP-FPMを用意する - hnwの日記](http://d.hatena.ne.jp/hnw/20130626)\n\nなおmiyabiさんが紹介されているphpenv-apache-\nversionは、Apacheが読み込むmod_phpの実体であるlibphp5.soまたはlibphp7.soを切り替えるツールですが、前述のようにmod_phpは複数バージョンを同時に読み込めないので、これ自体で併用できるようにはなりません。\n\nというか、見たところ上記のツールはphp5とphp7それぞれのファイルの更新をやるだけのようなので、ファイル名の異なるphp5とphp7の間で切り替えるには別途[httpd.conf等を書き換える](http://qiita.com/ryurock/items/7d031440bb174a55a6a1#httpconf%E3%81%AE%E8%A8%AD%E5%AE%9A%E5%A4%89%E6%9B%B4)必要がありそうです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T07:11:49.017", "id": "20972", "last_activity_date": "2016-01-16T07:11:49.017", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "20964", "post_type": "answer", "score": 0 } ]
20964
20965
20965
{ "accepted_answer_id": null, "answer_count": 1, "body": "SwiftでWebviewを使ってのブラウズと、iPhoneのSafariに比べて表示が遅いように見えます。 \n見え方として、iPhoneのSafariは読み込みながら表示しているのに対して、Webviewでは読み込みが終わるまで表示しないように見えます。\n\nSafariと同じように読み込みながら表示することはできないでしょうか?\n\nまた、実際にiPhoneのSafariに比べてWebviewは表示が遅いなどあるのでしょうか?\n\nご存知の方、ご教授お願いします。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T05:41:51.223", "favorite_count": 0, "id": "20966", "last_activity_date": "2016-01-16T06:25:46.140", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8593", "post_type": "question", "score": 2, "tags": [ "swift", "webview" ], "title": "SwiftのWebviewを使うと表示が遅い件の解決策", "view_count": 5562 }
[ { "body": "iPhoneアプリでWebサイトを表示する方法は大きく分けて3つ存在します。\n\n * UIWebView\n * WKWebView\n * SFSafariViewController\n\nそれぞれ特徴があります。\n\n【UIWebView】\n\n * 最も古くからあるWebView\n * storyboardから追加可能\n\n【WKWebView】\n\n * iOS8から追加されたWebView\n * Safariと同じレンダリングエンジンを利用できるためUIWebViewに比べてJavaScriptの処理速度が約4倍速い\n * storyboardからは追加できないため、コード実装が必要\n * 他2つの方法に比べて、最も自由度が高い\n\n【SFSafariViewController】\n\n * iOS9から追加されたWebサイト表示用のViewController\n * 単にWebサイトを表示するためだけに使うのであれば、最適な方法(リクエストのハンドリングが必要な場合は不向き)\n * Safariをアプリ内で利用することができるといったイメージ\n\n単純な性能で言えば、WKWebViewとSFSafariViewControllerはSafariと同等ですが、UIWebViewは低性能です。\n\nサーバサイドレンダリングやSingle Application\nPageなどレンダリングの手法はWebサイトそれぞれで異なるため、ユーザーが読込みを早く感じられるような工夫をしていることも考えられます。\n\nいずれにしても、iOSでWebサイトを高速に表示する場合は、用途に合わせて、WKWebViewかSFSafariViewControllerを使うのが良いと思います。\n\n詳しい性能結果については、個人的に調査したことがあるため、[iOS9でWebViewの性能を測ろう!](http://grandbig.github.io/blog/2015/09/21/ios9-webview/)をご参照ください。\n\n以上、少しでも参考になれば幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T06:25:46.140", "id": "20968", "last_activity_date": "2016-01-16T06:25:46.140", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8968", "parent_id": "20966", "post_type": "answer", "score": 5 } ]
20966
null
20968
{ "accepted_answer_id": "20969", "answer_count": 3, "body": "Unityでゲーム開発をしており、言語はC#を使用しています。\n\n表題の件、現場で議論したのですが \nどちらが良いのか答えを見つけられませんでした。\n\n下記MSDNのページを見たところ \n<https://msdn.microsoft.com/ja-jp/library/sbbt4032.aspx> \n\"既定では、最初の列挙子の値は 0 で、後続の列挙子の値は 1 ずつ増加していきます。\" \nとあるので値として==で比較するべきだと思っているのですが、 \nEqualsでも判定して正しい結果を得る事ができるので \n用意されているメソッドで判定すべきではないかとの意見もあり、 \n結局どっちで比較するのが正しいのかという問題となりました。\n\nどちらで判定すべきか理由が欲しいのですが \nご教授いただけませんでしょうか?\n\n■開発環境 \nWindows7 \nUnity5.3.0f4", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T06:12:11.677", "favorite_count": 0, "id": "20967", "last_activity_date": "2016-01-16T09:12:06.380", "last_edit_date": "2016-01-16T09:12:06.380", "last_editor_user_id": "76", "owner_user_id": "5261", "post_type": "question", "score": 6, "tags": [ "c#" ], "title": "Enumは== か Equals かどちらで判定すべきでしょうか?", "view_count": 10880 }
[ { "body": "等値演算子”==”を使用すべきだと考えます。\n\n理由は、Equalsメソッド利用した場合、対象となる引数objはobject型となるので、ボックス化が必須となります。これはマネージヒープに本来不要な列挙型の値を展開することになり、ガーベージコレクタにインパクトを与えることになります。(とはいえその影響は微少なものにとどまるとは思いますが)\n\nまた、Equalsメソッドを呼び出すオーバーヘッドもパフォーマンスにインパクトを与える可能性があります。 \n他方、等値演算子\"==\"を使用した場合は、基になる型(明示無き場合はSystem.Int32)の比較となりますから、マネージヒープを利用することはありませんし、又比較も単純なceq命令になります。\n\n以上のことから、高頻度で比較が発生する場合に特に大きな差が発生しかねない点と、可読性の点から見ても問題は無いかと思いますので、等値演算子\"==\"を利用すべきだと考えます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T06:46:44.123", "id": "20969", "last_activity_date": "2016-01-16T07:17:07.240", "last_edit_date": "2016-01-16T07:17:07.240", "last_editor_user_id": "7287", "owner_user_id": "7287", "parent_id": "20967", "post_type": "answer", "score": 15 }, { "body": "enum型を比較するのであれば、個人的には==ではないかと思いますが、Equals()でも同じ結果になりますよね。理由は値型を比較しているからです。ただ、やみくもになんでもEquals()を使うというのは危険かなと思います。\n\nEquals()はオブジェクト同士を比較するので、値型と参照型では==とは結果が異なることがある、という点を理解して使用するのであれば、チーム内の意志を尊重する、というのもアリかと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T06:49:25.770", "id": "20970", "last_activity_date": "2016-01-16T06:49:25.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9515", "parent_id": "20967", "post_type": "answer", "score": 2 }, { "body": "どちらでもいいかと思いますけど\n\n両者の違いというと、例えば\n\n```\n\n enum Colors { Red, Green, Blue, Yellow };\n enum Pet { Cat, Dog, Horse, Dolphin };\n \n```\n\nのような二つの列挙型があるときRed と Cat は既定ではint32の0を意味するというようなことになるわけですが、\n\n```\n\n Pet myPet = Pet.Cat;\n Colors myColor = Colors.Red;\n \n if(myColor == myPet){//数値としての値は同じ?\n ...\n }\n \n```\n\nのようなことはコンパイルエラー(両者の型が異なる)になるのでできません。 \nしかし、\n\n```\n\n if(myColor.Equals(myPet)){//オブジェクトとしてなのでコンパイルは通るが違う型なのでもちろん結果はFalse\n ...\n }\n \n```\n\nはできます。 \nなので(時計屋さんと同じくコストパフォーマンスの点から)、同じ列挙型で比較する場合には単に`==`を使えばいいと思います。 \n逆に言えば相手先の型がわからない(同じ列挙型かもしれないし違うかもしれない)ような状況での等値判定であれば`Equals`を使うのかなと思います。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T06:50:03.047", "id": "20971", "last_activity_date": "2016-01-16T07:12:28.013", "last_edit_date": "2016-01-16T07:12:28.013", "last_editor_user_id": "5044", "owner_user_id": "5044", "parent_id": "20967", "post_type": "answer", "score": 4 } ]
20967
20969
20969
{ "accepted_answer_id": null, "answer_count": 0, "body": "**やりたいこと。** \nUITableViewCellにあるAdd(UIButton)からAddedされたセルを \ndoneを押した時にRealmに保存するという処理を作っています。\n\n**問題点** \nカスタマイズされたUITableViewCell(Xib付き)から、TableViewControllerのparDoneIndexPathにアクセスし、 \n辞書を追加したりしたいのですが、UITableViewCellからsuperviewしてもUITableViewControllerにはアクセスできません。\n\nCellのActionにRealmに保存するよう実装するのも手なのですが、 \ndoneボタンが押された時に保存するようにしたいのです。 \nそのAddされたものをUITableViewControllerに定義した parDoneIndexPath(辞書)に入れ、 \ndoneが押されたときにRealmに保存処理を行いたいのですが、 \nどうすればcellからparDoneIndexPathを取得できるのでしょうか?\n\n```\n\n class TableViewController: UITableViewController {\n var parDoneIndexPath :Dictionary\n \n 省略\n }\n \n class CustomizedTableViewCell: UITableViewCell {\n \n @IBOutlet weak var button: UIButton!\n @IBOutlet weak var labelText: UILabel!\n \n @IBAction func buttonAction(sender: UIButton) {\n \n //indexPathを取得する。\n let cell = sender.superview?.superview as! ChooseTrainingFromMenuTableViewCell\n let tableView = sender.superview?.superview?.superview?.superview as! UITableView\n let indexPath :NSIndexPath = tableView.indexPathForCell(cell)!\n \n print(cell.selected)\n \n \n //ボタンを押したときのSelected:Bool\n if cell.selected == false {\n cell.selected = true\n button.setTitle(\"Added\", forState: .Normal)\n print(button.titleLabel!.text)\n print(indexPath.row)\n print(indexPath.section)\n \n }else {\n cell.selected = false\n button.setTitle(\"Add\", forState: .Normal)\n print(button.titleLabel!.text)\n print(indexPath.row)\n print(indexPath.section)\n \n }\n \n }\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T07:48:53.110", "favorite_count": 0, "id": "20973", "last_activity_date": "2016-01-16T07:48:53.110", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5828", "post_type": "question", "score": 0, "tags": [ "ios", "swift", "uitableview" ], "title": "カスタムUITableViewCellからUITableVIewControllerの変数を取得したい。", "view_count": 1305 }
[]
20973
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "ons-listでRadiobutton Listを実現したく、以下のコードを実装しております。\n\nこれでコマンド `$ cordova emulate ios`\nを実行しシミュレータを表示したところ、メニューの右側(先頭のみ)にチェックマークが表示されません。\n\n「ng-repeat」で各値を取得できているのは確認できたのですが、HTMLに生成し表示する際にうまくいってないようです。\n\nもし解決方法がご存知でしたら、ご教授のほどお願いいたします。\n\n### 表示結果\n\n[![チェックマーク表示しない](https://i.stack.imgur.com/pcpvw.png)](https://i.stack.imgur.com/pcpvw.png)\n\n### 現状のコード\n\nHTML\n\n```\n\n <ons-template id=\"connecttimeout.html\">\n <ons-page>\n <ons-toolbar>\n <div class=\"left\"><ons-back-button>戻る</ons-back-button></div>\n <div class=\"center\">接続タイムアウト</div>\n </ons-toolbar>\n \n <ons-list modifier=\"inset\" class=\"settings-list\">\n <ons-list-item ng-repeat=\"timeOutList in config.timeout\" modifier=\"tappable\">\n <label class=\"radio-button radio-button--list-item\">\n <input type=\"radio\" name=\"timeout\" ng-value=\"{{timeOutList.minisec}}\" {{timeOutList.selected}}>\n <div class=\"radio-button__checkmark radio-button--list-item__checkmark\"></div>\n {{timeOutList.name}}\n </label>\n </ons-list-item>\n </ons-list>\n <br>\n \n </ons-page>\n </ons-template>\n \n```\n\nJSON\n\n```\n\n var config = {\n timeout: [\n {name: '1分', minisec: 600, selected: 'checked'},\n {name: '5分', minisec: 3000, selected: ''},\n {name: '10分', minisec: 6000, selected: ''}\n ]}\n \n```", "comment_count": 1, "content_license": "CC BY-SA 4.0", "creation_date": "2016-01-16T08:27:43.047", "favorite_count": 0, "id": "20974", "last_activity_date": "2022-12-23T02:14:43.913", "last_edit_date": "2022-12-23T02:14:43.913", "last_editor_user_id": "3060", "owner_user_id": "9561", "post_type": "question", "score": 2, "tags": [ "ios", "onsen-ui", "angularjs", "cordova" ], "title": "Onsen UI のラジオボタンで初期設定をしてもチェックマークが表示されない", "view_count": 1719 }
[ { "body": "`Onsen UI`のクラス`radio-\nbutton`は、`input`タグの`checked`属性が存在するまたは実際にタップされた場合にチェックを表示する動きのようです。 \n`input`タグの`{{timeOutList.selected}}`は、そのまま`{{timeOutList.selected}}`と出力されるため、チェックが表示されません。\n\nディレクティブを使用し、取得したエレメント(`input`タグ)の`checked`属性を有効にすることで、チェックを表示することができます。\n\nJavaScript\n\n```\n\n <script>\n var app = ons.bootstrap(\"myApp\", [\"onsen\"]);\n // inputタグのchecked属性を有効にするディレクティブ\n app.directive(\"radioCheck\", function() {\n return {\n restrict : \"A\",\n scope : {checkOn : \"=\"},\n link : function(scope, elem, attr) {\n if (scope.checkOn) {\n elem[0].checked = true;\n }\n }\n };\n });\n // コントローラ\n app.controller(\"connecttimeoutController\", function($scope) {\n $scope.config = {\n timeout: [\n {name: '1分', minisec: 600, selected: 'checked'},\n {name: '5分', minisec: 3000, selected: ''},\n {name: '10分', minisec: 6000, selected: ''}\n ]};\n });\n </script>\n \n```\n\nHTML\n\n```\n\n <ons-template id=\"connecttimeout.html\">\n <ons-page ng-controller=\"connecttimeoutController\">\n <ons-toolbar>\n <div class=\"left\"><ons-back-button>戻る</ons-back-button></div>\n <div class=\"center\">接続タイムアウト</div>\n </ons-toolbar>\n \n <ons-list modifier=\"inset\" class=\"settings-list\">\n <ons-list-item ng-repeat=\"timeOutList in config.timeout\" modifier=\"tappable\">\n <label class=\"radio-button radio-button--list-item\">\n <input type=\"radio\" name=\"timeout\" ng-value=\"timeOutList.minisec\" check-on=\"timeOutList.selected=='checked'\" radio-check>\n <div class=\"radio-button__checkmark radio-button--list-item__checkmark\"></div>\n {{timeOutList.name}}\n </label>\n </ons-list-item>\n </ons-list>\n <br>\n </ons-page>\n </ons-template>\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T14:50:56.697", "id": "20982", "last_activity_date": "2016-01-16T14:50:56.697", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9566", "parent_id": "20974", "post_type": "answer", "score": 1 } ]
20974
null
20982
{ "accepted_answer_id": null, "answer_count": 2, "body": "AngularJSを用いた管理画面の開発をしています。\n\n一般的なWebページの目標値などを聞くと、 \n1秒、遅くとも2秒は切りたい。などと耳にします。\n\nこれはSPAを作る際でも意識するべきでしょうか? \n個人的には管理画面は読み込み後の動作が快適であれば、 \n最初の読み込みに時間がかかってしまっても問題ないと思うのですが。\n\n目安とすべき時間や考え方などがあれば教えて下さい。 \nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T08:43:25.553", "favorite_count": 0, "id": "20975", "last_activity_date": "2020-03-18T01:46:00.843", "last_edit_date": "2020-03-18T01:46:00.843", "last_editor_user_id": "19110", "owner_user_id": "8436", "post_type": "question", "score": 1, "tags": [ "angularjs", "single-page-application" ], "title": "SPAの表示速度の目標について", "view_count": 318 }
[ { "body": "もはやWeb技術を使っているというだけで、用途はPCやスマホで動くアプリケーションと変わらないのですから、そのように考えればよいのではないでしょうか。\n\n電卓のように必要なときにさっと起動して作業が行えた方がよい場合は起動の速さが重要ですし、ゲームのように多少起動に時間がかかってでもそれ以降の作業がスムーズに行えた方がよいものもあります。朝からずっと起動しっぱなしの業務システムなどでは、なおさら起動にかかる時間は些細な問題でしょう。\n\nそういう意味では、SPAだからどうではなく用途次第と言えます。管理画面にも色々ありますから、読み込みとその後の動作のどちらが多く発生するか、あるいは実際の作業フローを踏まえて、どちらを優先すべきか考ればよいのではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T15:46:52.203", "id": "20983", "last_activity_date": "2016-01-16T15:46:52.203", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "20975", "post_type": "answer", "score": 3 }, { "body": "管理画面であれば、初期ロード時間が問題視される事はおそらくありません。 \n初期ロードさえされてしまえば、あとはネイティブと遜色ないぐらいにサクサク動くので、もし何か言われた場合はそういうメリットを強調するか、初期ロードの時だけ、ロード中表示などを行えばいいのではないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-26T15:03:33.887", "id": "21351", "last_activity_date": "2016-01-26T15:03:33.887", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10712", "parent_id": "20975", "post_type": "answer", "score": 1 } ]
20975
null
20983
{ "accepted_answer_id": "20978", "answer_count": 2, "body": "int型とlong型で同じ数値を比較すると == はtrueを返しますが、Equalsはfalseを返すことがあります。\n\n```\n\n Console.WriteLine(\"1 == 1L: {0}\", 1 == 1L);\n Console.WriteLine(\"1L == 1: {0}\", 1L == 1);\n Console.WriteLine(\"1.Equals(1L): {0}\", 1.Equals(1L));\n Console.WriteLine(\"1L.Equals(1): {0}\", 1L.Equals(1));\n \n // 出力:\n // 1 == 1L: True\n // 1L == 1: True\n // 1.Equals(1L): False\n // 1L.Equals(1): True\n \n```\n\n値型では基本的に == と Equals は同じだと思っていたのですが、違うのでしょうか?\n\nまた、もしEqualsだけ型を厳密に見ていると仮定すると、trueを返すこともあるのが謎です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T09:53:29.503", "favorite_count": 0, "id": "20976", "last_activity_date": "2016-01-17T02:23:55.537", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "post_type": "question", "score": 11, "tags": [ "c#" ], "title": "違う型の同じ数値を比較するときに == と Equals で結果が異なる?", "view_count": 4622 }
[ { "body": "`Object.Equals(object)`は型が同じであれば`operator ==(T,\nT)`の結果を、型が異なれば`false`を返すのが標準的な動作です。 \nしかし質問文の例ではオーバーロードにより`int`から`long`への暗黙変換が発生しており、コード上の型が一致していません。\n\n最初の二つの式ですが、C#の数値比較は`int`、`uint`、`long`、`ulong`同士の比較しか定義されていないため、`operator\n==(long, long)`が選択されます。 \nまた最後についても`IEquatable<T>`の実装である`Int64.Equals(long)`が存在するため、こちらも暗黙変換が発生します。 \nこれらの結果が`False`でないのはそのためです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T10:41:54.547", "id": "20978", "last_activity_date": "2016-01-16T10:58:53.557", "last_edit_date": "2016-01-16T10:58:53.557", "last_editor_user_id": "5750", "owner_user_id": "5750", "parent_id": "20976", "post_type": "answer", "score": 11 }, { "body": "等値演算子の`==`に関しては、C# の言語仕様 **7.3.6.2 二項数値上位変換**\nで規定されている通り、`int`が`long`へ暗黙の型変換されるためにtrueとなります。\n\n他方、Equalsメソッドの呼び出しに関しては、pgrhoさんのご指摘の通りですが、多少補足しますと、`long.Equals(long\nobj)`と、`long.Equals(object obj)`のどちらが **より適切** であるかは、C#の言語仕様 **7.5.3\nオーバーロードの解決法** によって、 **より適切な関数メンバ** が解決されていくことになります。\n\nこの際、元の`int`は、`long`へも`object`へも暗黙の型変換が許容されていますので、どちらがより適切なのかと言うことになりますが、これは\n**7.5.3.5 より適切な変換対象** より\n\n> 異なる 2 つの型 T1 と T2 がある場合、次の条件が 1 つでも満たされると、T1 の方が T2 より適切な変換対象です。 \n> • T1 から T2 への暗黙の型変換が存在し、T2 から T1 への暗黙の型変換が存在しない \n> 以下略\n\nとのことから、`long`から`object`への暗黙の型変換が存在し、逆に`object`から`long`への暗黙の型変換が存在しないことから、最終的に`long.Equals(long\nobj)`がより適切な関数メンバと解釈され、適用されるので、\n\n```\n\n Console.WriteLine(\"1L.Equals(1): {0}\", 1L.Equals((long)1));\n \n```\n\n明示的に書くのであれば、このような関数呼び出しなり、引数のi 及び lが同値で有れば、trueに成るのだと思います。\n\n他方、int.Equalsの場合は、long型からint型への暗黙の型変換は存在せず、逆にlong型からobject型への暗黙の型変換は存在するので、結果的にint.Equals(object\nobj)が呼ばれFalseに成るのだと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T11:41:06.903", "id": "20981", "last_activity_date": "2016-01-17T02:23:55.537", "last_edit_date": "2016-01-17T02:23:55.537", "last_editor_user_id": "7287", "owner_user_id": "7287", "parent_id": "20976", "post_type": "answer", "score": 10 } ]
20976
20978
20978
{ "accepted_answer_id": "21007", "answer_count": 1, "body": "Javaに限った話では無いのかもしれませんが、単体テストを実装する際には、\n\n * 関連するクラスのスタブやモックの作成コードのテスト準備コード\n * テスト実行のコード\n * assertionのコード\n\nを記載していくかと思います。 \nだんだんとテストを書いていくと、上記3つが混ざってくる気がしています。\n\nそこで、上記3つの内容が一目で分かるようなテストライブラリを探しているのですが、 \nご存じの方は教えてください。\n\nライブラリのコードイメージは下記のようになります。\n\n```\n\n @Test\n public void testHoge(){\n TestHelper.prepare({\n Hoge hoge = mock(Hoge.class)\n when(hoge.getXXX).thenReturn(\"hogehoge\");\n }).execute({\n result(test.target());\n }).evaluate(r -> {\n assertEquals(r, \"expected\");\n });\n }\n \n```\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-16T16:36:30.857", "favorite_count": 0, "id": "20984", "last_activity_date": "2018-07-19T00:44:11.070", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3355", "post_type": "question", "score": 5, "tags": [ "java", "junit" ], "title": "Javaのテストでstub(mock)/テスト実行/assertionを綺麗に書きたい", "view_count": 1456 }
[ { "body": "xUnit Test Patternsで言う、\"Four Phase\nTest\"を強制&明示できるテスティングフレームワークを探している、ということですね。Javaそのものではありませんが、Groovyで記述するSpockというテスティングフレームワークででは、まさにそのような記述が可能になっています。\n\nSpockではテストコードをGroovyで記述しますが、テスト対象のプロダクトコードはJavaで記述されていても問題ありません。\n\nたとえば、質問にあるような疑似テストコードをSpock風に書くと以下のようになります。\n\n```\n\n void \"test of hoge\"() {\n given: // 関連するクラスのスタブやモックの作成コードのテスト準備コード\n Hoge hoge = Mock(Hoge)\n hoge.getXXX() >> \"hogehoge\"\n test.hoge = hoge\n \n when: // テスト実行のコード\n def result = test.target()\n \n then: // assertionのコード\n result == \"expected\"\n }\n \n```\n\nSpockでは、\n\n * ラベルによるFour Phase Testに従った記法\n * Power Assertによるverifyの簡素化&NG時の詳細表示\n * 強力なParamterized Testサポート\n * 標準でモック&スタブをサポート\n * Javaと親和性の高いGroovyによる柔軟な記述\n\nなどの特徴があります。\n\n詳しい情報は、下記のURLからどうぞ。\n\n * <https://github.com/yamkazu/spock-workshop/tree/master/docs>\n * <https://spock-framework-reference-documentation-ja.readthedocs.org/ja/latest/>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T13:18:50.810", "id": "21007", "last_activity_date": "2016-01-17T13:18:50.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2356", "parent_id": "20984", "post_type": "answer", "score": 3 } ]
20984
21007
21007
{ "accepted_answer_id": null, "answer_count": 1, "body": "以下の処理を行いたい場合、よいミドルウェア(ライブラリ)、方法等あればご教授ください。\n\nクライアントからのリクエストを受け付けるAPIサーバがあり、 \nこのサーバでDBに対し、送信順を考慮してDBにレコードを書き込んでいます。\n\n例えばデータ種別がA、B、Cで通番で1から順番にふられているとして、 \nデータ種別が異なるものは同時送信可能で、通番は同じデータ種別の中では順番に送信しなければならないとします。 \n(例 A-1とB-2 は同時送信可能。 A-2 はA-1の送信完了後に送信したい場合) \nまた、送信NG時に再送なども行う想定です。\n\nこういった処理を行いたい場合、オンラインリクエストを受け付ける仕組みとは切り離してシステムを構築したほうがよいのではと考えています。 \n(常駐化させて、DBが書き込まれるor新システムに通知して処理を実行。任意のタイミングで再送)\n\n現在のAPIサーバの環境 \n(バージョンは不明ですが、2013年くらいに構築されたものです。)\n\nOS : RHEL \nアプリ : Java Servlet (Tomcat上で実行) \nDB : postgresql\n\n現在のシステム構成からできるだけJavaで構築したいと考えていますが、他に便利なものがあれば検討します。フリーウェアのみの想定です。\n\nご回答いただけますと幸いです。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T00:38:21.860", "favorite_count": 0, "id": "20986", "last_activity_date": "2016-04-17T05:11:21.607", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13447", "post_type": "question", "score": 0, "tags": [ "java", "tomcat" ], "title": "DBからデータを取得し、順序性を考慮しながらHttp通信でデータを送付したい。", "view_count": 539 }
[ { "body": "一般的なJavaのWebフレームワークであれば構築できるかと思いますが、まずその選定に悩んでいるようでしたら、情報が多いもの+1つで完結しているものを選定すると良いかと存じます。\n\n日本語情報が出揃っているのをお望みでしたら、以下がありますので参考までに。\n\n<https://osdn.jp/projects/terasoluna/wiki/Server_Framework_for_Java_Web>\n\nSpringフレームワークベースで、かつデータベースのアクセスまでサポートしています。 \n参考になれば幸いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T02:11:57.130", "id": "21018", "last_activity_date": "2016-01-18T02:11:57.130", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5778", "parent_id": "20986", "post_type": "answer", "score": 1 } ]
20986
null
21018
{ "accepted_answer_id": "20989", "answer_count": 2, "body": "はじめまして.質問を見ていただいてありがとうございます.\n\n私は最近,MSVC12.0(以降VC12)からMSVC14.0(以降VC14)への移行を始めた者です.\n\n * ## 症状と原因\n\nVC12では動作できていたオープンソースのライブラリ(とあるカメラ制御APIです)がVC14に移行した途端,ヘッダファイルから大量のエラーをくらいました.\n\nVC12とVC14での違いを調べていたところ,どうやらプラットフォームを確認するヘッダ内の挙動が変わっているようでした.\n\n私が使っているそのライブラリは,\n\n```\n\n #if defined(WIN32) || defined(WIN64)\n // Windows 32-bit and 64-bit\n \n // Some def. here\n \n #elif defined(MAC_OSX)\n // Mac OSX\n \n #else\n // Linux and all others\n // Using GCC 4 where hiding attributes is possible\n \n // Some def. here\n \n #endif\n \n```\n\nとプラットフォームごとに別々な定義をしています. \nVC12では,WIN32が定義されていましたので,Windowsのための定義を通りました. \nしかし,VC14ではWIN32が定義されておらず,代わりに_WIN32が定義されていました. \nちなみに,VC12にも_WIN32は定義されているようでした.\n\n * ## 質問\n\nこのエラーは,「VC14でWIN32から_WIN32に完全に移行したけれど,使っているライブラリがそれに対応していない」ことが原因だと考えているのですが,正しいでしょうか. \nまた,WIN32と_WIN32の違いや,_WIN32になった背景などがわかる方がいれば教えていただきたいです.\n\n長くなってしまいましたが,よろしくお願いします.", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T02:21:24.663", "favorite_count": 0, "id": "20987", "last_activity_date": "2016-01-21T13:57:26.917", "last_edit_date": "2016-01-18T10:51:42.000", "last_editor_user_id": "49", "owner_user_id": "14032", "post_type": "question", "score": 5, "tags": [ "c++", "visual-studio" ], "title": "C++ MSVC14.0 での WIN32マクロについて", "view_count": 3994 }
[ { "body": "[定義済みマクロ](https://msdn.microsoft.com/ja-\njp/library/b0084kay.aspx)に関していえばドキュメントに残っている範囲では少なくともVC7.1(Visual C++.NET\n2003)以降は`_WIN32`しか記載されていません。つまり`WIN32`はundocumentedな動作に依存していたということです。\n\nこれに関して、[C識別子](https://msdn.microsoft.com/en-\nus/library/e7f8y25b.aspx)および[C++識別子](https://msdn.microsoft.com/ja-\njp/library/565w213d.aspx)は\n\n> 識別子の先頭での 2 つの連続するアンダースコア文字 (__)、または 1 つのアンダースコア文字と 1 つの大文字の使用は、すべてのスコープで C++\n> の実装のために予約されています。\n\nという仕様に従うべく、`WIN32`のようにアンダースコアで始まらない識別子はなるべく使わないように順次変更されているものと思われます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T02:59:00.627", "id": "20989", "last_activity_date": "2016-01-17T02:59:00.627", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "20987", "post_type": "answer", "score": 7 }, { "body": "必要なら、自身で`WIN32`を定義してしまえば良いと思います。もちろん、ソースコードの側の改変が可能なら`_WIN32`に変更するのが便利です。\n\n理由は以下の通りです。MSVC 12.0でもMSVC\n14.0でも、`WIN32`はコンパイラで最初から定義されているものではありません。ただ、いずれのバージョンでも、Visual\nStudioでプロジェクトを新規作成すると、初期状態ではプロジェクトのプロパティで`WIN32`が(`_DEBUG`や`NDEBUG`などとともに)定義されるようになっています。\n\nそのため、MSVC 12.0でビルドしていたときも、どこかしら(`Makefile`やVisual\nStudioプロジェクトなど)で`WIN32`が定義されていたはずなのです。MSVC\n14.0に移行した際、その設定が欠落してしまったのではないかと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T14:46:21.027", "id": "21010", "last_activity_date": "2016-01-21T13:57:26.917", "last_edit_date": "2016-01-21T13:57:26.917", "last_editor_user_id": "8616", "owner_user_id": "8616", "parent_id": "20987", "post_type": "answer", "score": 5 } ]
20987
20989
20989
{ "accepted_answer_id": "21014", "answer_count": 1, "body": "RailsでPostgreSQLのArray型を使った時に、配列が空のもののみを取得するにはどうすればいいでしょうか。\n\n例えば、次のコードのようにpreload_article_idsが配列型(Integer)だとして、次のようなコードを書けば取得できるのかなと思いました。\n\n```\n\n Article.where(\"array_length(preload_article_ids, 1) = 0\")\n \n```\n\nしかし、実際には取得することが出来ませんでした。どうすれば空の場合のみ取得できるか、ご教授頂けませんでしょうか。よろしくお願い致します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T02:31:00.693", "favorite_count": 0, "id": "20988", "last_activity_date": "2016-01-18T01:27:35.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12662", "post_type": "question", "score": 0, "tags": [ "ruby-on-rails", "ruby", "postgresql" ], "title": "RailsでPostgreSQLのArray型で、配列が空のものを取得する方法", "view_count": 1739 }
[ { "body": "```\n\n array_length('{}'::int[], 1)\n \n```\n\nは0ではなくNULLを返すんですね。(試してみて今気付きました)\n\nなので、\n\n```\n\n Article.where(\"array_length(preload_article_ids, 1) IS NULL\")\n \n```\n\nとNULL検査にするか、\n\n```\n\n Article.where(\"preload_article_ids = '{}' OR preload_article_ids IS NULL\")\n \n```\n\nと空配列と比較(と必要であればNULL検査)にするか、PostgreSQL9.4以降ですが、`cardinality`関数は空配列に対して0を返すとマニュアルに書いてある(試してません)ので\n\n```\n\n Article.were(\"cardinality(preload_article_ids) = 0\")\n \n```\n\nとこれを使うかでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T01:27:35.810", "id": "21014", "last_activity_date": "2016-01-18T01:27:35.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "20988", "post_type": "answer", "score": 0 } ]
20988
21014
21014
{ "accepted_answer_id": "20994", "answer_count": 1, "body": "改善策を教えていただけないでしょうか? \nエミュレーターでは動きますが、実機はコンパイルエラーになります。\n\n以下参照したホームページです。 \n<https://akira-watson.com/iphone/admob.html> \nここに書かれているフレームワークも追加しています。\n\nよろしくお願いいたします。\n\nエラーコードです。\n\n> ld:\n> '/Users/*****/Desktop/*****/TestKoukoku/GoogleMobileAds.framework/GoogleMobileAds(GADBannerView.o)'\n> does not contain bitcode. You must rebuild it with bitcode enabled (Xcode\n> setting ENABLE_BITCODE), obtain an updated library from the vendor, or\n> disable bitcode for this target. for architecture arm64 \n> clang: error: linker command failed with exit code 1 (use -v to see\n> invocation)\n\nテストコードです。\n\n```\n\n import UIKit\n import GoogleMobileAds\n \n class ViewController: UIViewController, GADBannerViewDelegate {\n // AdMob ID を入れてください\n let AdMobID = \"ca-app-pub-59765xxxxxxxxxx/xxxxxxxxxx\"\n let TEST_DEVICE_ID = \"61b0154xxxxxxxxxxxxxxxxxxxxxxxe0\"\n let AdMobTest:Bool = true\n let SimulatorTest:Bool = true\n \n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n var admobView: GADBannerView = GADBannerView()\n admobView = GADBannerView(adSize:kGADAdSizeBanner)\n admobView.frame.origin = CGPointMake(0, self.view.frame.size.height - admobView.frame.height)\n \n admobView.frame.size = CGSizeMake(self.view.frame.width, admobView.frame.height)\n admobView.adUnitID = AdMobID\n admobView.delegate = self\n admobView.rootViewController = self\n \n let admobRequest:GADRequest = GADRequest()\n \n if AdMobTest {\n if SimulatorTest {\n admobRequest.testDevices = [kGADSimulatorID]\n }\n else {\n admobRequest.testDevices = [TEST_DEVICE_ID]\n }\n \n }\n \n admobView.loadRequest(admobRequest)\n \n self.view.addSubview(admobView)\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T06:08:45.470", "favorite_count": 0, "id": "20991", "last_activity_date": "2016-01-17T07:03:56.510", "last_edit_date": "2016-01-17T07:03:56.510", "last_editor_user_id": "8000", "owner_user_id": "10845", "post_type": "question", "score": 0, "tags": [ "swift", "xcode", "ios8", "swift2" ], "title": "admob sdkを実機で走らすと、エラーになる", "view_count": 609 }
[ { "body": "そのエラーメッセージはあなたが自分のアプリに取り込もうとしているフレームワーク(の少なくとも一部)がbitcode対応していないことを示しています。\n\n_You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE),\nobtain an updated library from the vendor, or disable bitcode for this\ntarget._ \nこのエラーメッセージには3つの対応のどれかを行わないといけないと示されています。\n\n * (そのフレームワーク自体を)bitcodeを有効にして再ビルドする\n * フレームワークの配布元から(bitcodeに対応した)更新版のライブラリを入手する\n * コンパイル中のプロジェクトのターゲットについて、bitcodeを無効化する\n\n最初の2つについては、こちらではどうしようもないので、3番目の設定変更方法を示します。\n\nProject navigatorからPROJECT/TARGETSの設定画面を開いておく。 \nTARGETSのBuild Settingsのタブを選択する。 \n(検索窓に「bit」と入力するなどして)Enable Bitcodeの設定箇所を見つける。 \n※「Build Options」の中にあるはずです。 \n「Yes」になっているはずなので、そこを「No」に書き換える。\n\nAppleは将来的にApp\nStoreに提出するアプリに対してbitcode使用を義務化するかもしれません(tvOSでは既に義務化されているようです)が、今の所は無効化しても大丈夫です。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T06:38:25.963", "id": "20994", "last_activity_date": "2016-01-17T06:38:25.963", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13972", "parent_id": "20991", "post_type": "answer", "score": 0 } ]
20991
20994
20994
{ "accepted_answer_id": "20993", "answer_count": 1, "body": "CheckBoxのON,OFFでTextBoxのIsReadOnlyプロパティを切り替えたいと考えています。 \n以下のソースではGrid直下のTextBoxではTriggerが動き、CheckBoxと連動してIsReadOnlyが変動します。 \nしかし、ListBox内のTextBoxではCheckBoxの値に関係なく、常にReadOnlyとなってしまいます。 \nTemplate内のコレクションにもStyle Triggerを適用させる方法を教えて下さい。\n\n* * *\n```\n\n class TextBoxModel\n {\n public string text { get; set; }\n public int count { get; set; }\n \n public TextBoxModel(string text, int count)\n {\n this.text = text;\n this.count = count;\n }\n }\n \n```\n\n* * *\n```\n\n class MainWindowViewModel : INotifyPropertyChanged\n {\n public List<TextBoxModel> tbm { get; set; }\n \n private bool _isReadOnly;\n public bool IsReadOnly\n {\n get { return _isReadOnly; }\n set\n {\n _isReadOnly = value; \n OnPropertyChanged(nameof(IsReadOnly));\n }\n }\n \n public MainWindowViewModel()\n {\n tbm = new List<TextBoxModel>()\n {\n new TextBoxModel(\"aaa\", 10),\n new TextBoxModel(\"fff\", 10)\n };\n }\n \n public event PropertyChangedEventHandler PropertyChanged;\n [NotifyPropertyChangedInvocator]\n protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)\n {\n PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));\n }\n }\n \n```\n\n* * *\n```\n\n <Window.DataContext>\n <local:MainWindowViewModel />\n </Window.DataContext>\n \n <Window.Resources>\n <Style x:Key=\"ReadOnlyTextBox\" TargetType=\"TextBox\">\n <Setter Property=\"IsReadOnly\" Value=\"True\" />\n <Setter Property=\"HorizontalAlignment\" Value=\"Left\"></Setter>\n <Setter Property=\"TextWrapping\" Value=\"Wrap\"></Setter>\n <Setter Property=\"VerticalAlignment\" Value=\"Top\"></Setter>\n <Setter Property=\"Width\" Value=\"100\"></Setter>\n \n <!--ここがtemplate内のTextBoxに適用されない-->\n <Style.Triggers>\n <DataTrigger Binding=\"{Binding IsReadOnly}\" Value=\"False\">\n <Setter Property=\"IsReadOnly\" Value=\"False\"></Setter>\n </DataTrigger>\n </Style.Triggers>\n \n </Style>\n </Window.Resources>\n \n <Grid>\n <TextBox x:Name=\"textBox\" Style=\"{StaticResource ReadOnlyTextBox}\" Height=\"23\" Margin=\"10,10,0,0\" Text=\"TextBox\"/>\n <ListBox x:Name=\"listBox\" HorizontalAlignment=\"Left\" Height=\"120\" Margin=\"162,10,0,0\" VerticalAlignment=\"Top\" Width=\"108\" ItemsSource=\"{Binding tbm}\">\n <ListBox.ItemTemplate>\n <DataTemplate>\n <Grid>\n <TextBox Style=\"{StaticResource ReadOnlyTextBox}\" Text=\"{Binding text}\"/>\n </Grid>\n </DataTemplate>\n </ListBox.ItemTemplate>\n </ListBox>\n <CheckBox x:Name=\"checkBox\" Content=\"ReadOnly\" HorizontalAlignment=\"Left\" Margin=\"324,20,0,0\" VerticalAlignment=\"Top\" IsChecked=\"{Binding IsReadOnly}\"/>\n </Grid>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T06:17:10.913", "favorite_count": 0, "id": "20992", "last_activity_date": "2016-01-17T06:31:42.220", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14034", "post_type": "question", "score": 0, "tags": [ "wpf", "xaml" ], "title": "Tmplateで生成したTextBoxに対してStyleのTriggerが動きません。", "view_count": 1682 }
[ { "body": "`TextBox`の`DataContext`は`MainWindowViewModel`ではなく`TextBoxModel`のため、`{Binding\nIsReadOnly}`は無効です。\n\n修正するにはVMの設計を変えて`TextBoxModel`から`IsReadOnly`をたどれるようにするか、`RelativeSource`を用いて\n\n```\n\n {Binding RelativeSource={RelativeSource AncestorType=ListBox}, Path=DataContext.IsReadOnly}\n \n```\n\nのように上の階層の要素を経由して参照する必要があります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T06:31:42.220", "id": "20993", "last_activity_date": "2016-01-17T06:31:42.220", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "20992", "post_type": "answer", "score": 1 } ]
20992
20993
20993
{ "accepted_answer_id": "20999", "answer_count": 1, "body": "PHPで自分用(管理者)に届くメール文章と \n差出人に届く文章を変更したかったので \n定形であったmail.phpの管理者欄の名前とテキストの項目を下記のように追加したら(もともと定形のものに管理者に届く差出人の名前とテキスト項目はなかった)フォームから届く管理者用のメール文章の項目で名前とテキストの項目は追加されていましたが届いたメールは文字化けした状態になっていました。 \nどうしたら文字化けすることなく管理者宛に名前とテキストが追加された \n状態で届くようになるのでしょうか。全文は下のソースコードのところに記載しております。 \nちなみにフォームのあるcontact.htmlのヘッダーは`<meta http-equiv=\"content-type\"\ncontent=\"text/html;charset=Shift_JIS\">`でmail.phpもshift_jisの設定で管理者のところに名前とテキスト項目を入れるまでは正常に \n届いたのでこちらが原因ではなさそうです。\n\nソースコード\n\n■全文(文字制限があったためこちらに載せました) \nmail.php\n\n<https://www.evernote.com/shard/s687/sh/6575c872-a53c-43b0-ba67-4ee792ad0442/820429a269a5c41cb1ffaf5de598851b>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T07:45:00.380", "favorite_count": 0, "id": "20996", "last_activity_date": "2016-01-18T05:44:17.393", "last_edit_date": "2016-01-17T16:17:28.403", "last_editor_user_id": "76", "owner_user_id": "14035", "post_type": "question", "score": -1, "tags": [ "php" ], "title": "送信したメールが文字化けする", "view_count": 436 }
[ { "body": "送信後にリダイレクトしてしまっているのでわかりにくいですが、341行目のリダイレクト処理を潰してみると、色々エラーが出ていることがわかります。\n\n```\n\n Notice: Undefined variable: dsp_name in R:\\custom.php on line 486\n \n Call Stack:\n 0.0005 178496 1. {main}() R:\\custom.php:0\n 0.0009 185680 2. mailToAdmin() R:\\custom.php:224\n \n \n Notice: Undefined variable: subject_text in R:\\custom.php on line 487\n \n Call Stack:\n 0.0005 178496 1. {main}() R:\\custom.php:0\n 0.0009 185680 2. mailToAdmin() R:\\custom.php:224\n \n \n Notice: Undefined variable: userBody in R:\\custom.php on line 487\n \n Call Stack:\n 0.0005 178496 1. {main}() R:\\custom.php:0\n 0.0009 185680 2. mailToAdmin() R:\\custom.php:224\n \n \n Warning: mb_convert_encoding(): Illegal character encoding specified in R:\\custom.php on line 500\n \n Call Stack:\n 0.0005 178496 1. {main}() R:\\custom.php:0\n 0.0009 185680 2. mailToAdmin() R:\\custom.php:224\n 0.0325 187168 3. mb_convert_encoding() R:\\custom.php:500\n \n```\n\n224行目で `mailToAdmin()`\nに渡す引数を増やしているのに、その関数が受け取る引数は増えていないので、引数がずれてしまっています。484行目と519行目を比べてみてください。そして本来\n`$encode` が渡されるべき場所に `$mailFooterDsp`\nが渡されていて、エンコーディング変換がエラーになっています(上記4つ目のエラー)。管理者宛のメールが文字化けしてしまうのはこのためです。\n\nまた `mailToAdmin()` に書き足した箇所は `mailToUser()` からコピーしてきたようですが、本文を設定する変数名が\n`$userBody`\nのままになっているため、変数が見つからないというエラーが出ています(上記3つ目)。文字化けとは関係なく、管理者宛のメールには文章を追加できていないでしょう。\n\n残りの前半2つのエラーもそれぞれ変数 `$dsp_name` `$subject_text` が見つからないというものです。\n\n冒頭の設定で使われている変数名と引数名が同じなので紛らわしいですが、設定に書いた `$dsp_name` や `$remail_text` がどのように\n`mailToUser()` に渡され、 `$userBody` に埋め込まれ、 `mb_convert_encoding()`\nを経てreturnされているのか、追っかけてみてください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T10:03:56.750", "id": "20999", "last_activity_date": "2016-01-18T05:44:17.393", "last_edit_date": "2016-01-18T05:44:17.393", "last_editor_user_id": "8000", "owner_user_id": "8000", "parent_id": "20996", "post_type": "answer", "score": 1 } ]
20996
20999
20999
{ "accepted_answer_id": null, "answer_count": 1, "body": "ipadではこのレイアウトを変更しよう\nとsizeClassを縦横Regularに指定した項目があるのですが、エミュレーター・実機共に反応してくれず、何故かany\nanyの設定が反映されてしまいます \niOS8.1のシミュレーター、iOS8.4の実機では正常にRegular Regularの設定が反映される事を確認しました。\n\nxcodeのプロジェクトはこちらとなります \n<http://fushi.x0.com/php_system/20160117-stackoverflow-question/xibTest2.zip>\n\nxibで定義した二つのビュー(AaView と BView)があり \nAaViewはViewController上から\n\n```\n\n class AaViewController : UIViewController{\n var childView : AaView?\n var bView : BView?\n override func loadView() {\n self.edgesForExtendedLayout = UIRectEdge.None;\n if let view = UINib(nibName: \"AaView\", bundle: nil).instantiateWithOwner(self, options: nil).first as? AaView{\n self.view = view;\n }\n }\n override func viewDidLoad() {\n super.viewDidLoad()\n self.childView = self.view as! AaView!\n self.bView = BView(frame: (UIApplication.sharedApplication().keyWindow?.bounds)!)\n UIApplication.sharedApplication().keyWindow?.addSubview(self.bView! )\n }\n }\n \n```\n\nの様に、定義し\n\nBViewは\n\n```\n\n class BView: UIView {\n @IBOutlet var contentView: UIView!\n override init(frame: CGRect) { // for using CustomView in code\n super.init(frame: frame)\n self.commonInit()\n }\n required init?(coder aDecoder: NSCoder) { // for using CustomView in IB\n super.init(coder: aDecoder)\n self.commonInit()\n }\n private func commonInit( ) {\n NSBundle.mainBundle().loadNibNamed(\"BView\", owner: self, options: nil)\n contentView.frame = self.bounds\n self.addSubview(contentView)\n }\n \n```\n\n}\n\nの様に定義しました。\n\nsizeClassがおかしい以外はAもBも表示されており、iphone 6Plus iOS 9.2では正常にanyのラベルのみ表示されます。(左上にB-\nany、右下にA-any) \n[![左上と右下にanyのラベルがある](https://i.stack.imgur.com/eDwZ0.png)](https://i.stack.imgur.com/eDwZ0.png)\n\nところが、ipad2 iOS9.0/ipad air2 iOS 9.2ではA-Regularは狙い通り表示されるのですが、BについてはB-\nanyが表示されてしまいます。レイアウトの指定方法をミスって位置がズレてしまっていますが・・。 \n[![画像の説明をここに入力](https://i.stack.imgur.com/Ae8bX.png)](https://i.stack.imgur.com/Ae8bX.png)\n\nこれらのラベルはxCode上では \n[![画像の説明をここに入力](https://i.stack.imgur.com/7dZym.png)](https://i.stack.imgur.com/7dZym.png) \n[![画像の説明をここに入力](https://i.stack.imgur.com/w85IL.png)](https://i.stack.imgur.com/w85IL.png) \nの様に定義されており、reg regは縦横共にRegularの時のみ表示 \nanyは縦横共にanyの時 ただしRegularの時は除く という指定です。\n\nAaView、BView共に同じ指定方法です。\n\nAaViewに関しては望み通りの表示がされているのですが、BViewについて何故かSizeClassが反映されません。 \nパラメーター、設定不足等ありましたら教えて頂けますでしょうか\n\nxcodeのバージョンは7.2となります\n\nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T08:44:09.170", "favorite_count": 0, "id": "20997", "last_activity_date": "2016-01-19T00:09:51.730", "last_edit_date": "2016-01-18T08:14:16.310", "last_editor_user_id": "805", "owner_user_id": "805", "post_type": "question", "score": 0, "tags": [ "ios", "swift", "xcode", "iphone" ], "title": "iOS9~ のiPadでsizeClassをRegularに設定したのに反映されない", "view_count": 187 }
[ { "body": "BViewにSizeClassが反映されない原因ですが、AaViewControllerのviewDidLoad()において、以下のコードでbViewをUIWindowの直下に追加しているのが原因と思われます。\n\n```\n\n UIApplication.sharedApplication().keyWindow?.addSubview(self.bView!)\n \n```\n\n該当箇所を普通にviewに追加するように書き換えれば、正常に動作するようになるかと思われます。\n\n```\n\n view.addSubview(bView!)\n \n```\n\n『なぜ、UIWindowの直下にViewを追加するとSizeClassが正常に動作しなくなるか?』ですが、この場合、traitCollectionDidChangeが呼び出されなくなるところまではわかりましたが・・・\n詳細な理由は不明です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T12:39:48.560", "id": "21038", "last_activity_date": "2016-01-19T00:09:51.730", "last_edit_date": "2016-01-19T00:09:51.730", "last_editor_user_id": "7459", "owner_user_id": "7459", "parent_id": "20997", "post_type": "answer", "score": 4 } ]
20997
null
21038
{ "accepted_answer_id": null, "answer_count": 0, "body": "PHP、MySQL初心者のものです。\n\n先ほど下記リンクのドットインストールの授業を見て、PHPからデータベースに接続をしようとしたところ、エラーが出てしまいました。\n\n<http://dotinstall.com/lessons/basic_php_db/34204>\n\nエラー文は \nSQLSTATE[HY000] [1045] Access denied for user 'dbuser'@'localhost' (using\npassword: YES) \nとなっています。\n\nちなみにコードは\n\n```\n\n <?php\n define('DB_DATABASE', 'dotinstall_db');\n define('DB_USERNAME', 'dbuser');\n define('DB_PASSWORD', '適当な英数字');\n define('PDO_DSN', 'mysql:dbhost=localhost;dbname=' . DB_DATABASE);\n \n try {\n // connect\n $db = new PDO(PDO_DSN, DB_USERNAME, DB_PASSWORD);\n $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n \n // insert\n $db->exec(\"insert into users (name, score) values ('taguchi', 55)\");\n echo \"user added!\";\n \n // disconnect\n $db = null;\n \n } catch (PDOException $e) {\n echo $e->getMessage();\n exit();\n }\n ?>\n \n```\n\nというコードを書きました。 \ndbuserのアクセスが拒否されたとなっているので、そこが問題なのでしょうが、よくわかりません…。\n\ndbuserでなくphpMyAdminのusernameか何かを調べてここに代入しないといけないということでしょうか? \n詳しいかた、教えていただけると助かります。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T10:29:14.177", "favorite_count": 0, "id": "21000", "last_activity_date": "2016-01-18T03:37:25.370", "last_edit_date": "2016-01-18T03:37:25.370", "last_editor_user_id": "5793", "owner_user_id": "9542", "post_type": "question", "score": 0, "tags": [ "php", "mysql" ], "title": "SQLSTATE[HY000] [1045] Access denied for user dbuser'@'localhost' (using password: YES)というエラーが出てしまいます。", "view_count": 5450 }
[]
21000
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在Swift2を使って、市販のアプリ開発の参考書を1冊半終わらせた \nプログラミング初心者です。 \n現在は私的な練習目的で既存のアプリを真似てみたりしています。\n\nそこで質問なのですが、投稿型で、最初にFacebookもしくはTwitterでログインしてアプリ内でそのアカウントを使って投稿する(情報を交換し合う)ようなものを作ろうと思った場合、どのような手順でやればいいか簡単なヒントを頂けないでしょうか?\n\n既存のアプリでは「しりとり漫才」のような、それでいてシンプルなアプリを作ろうと思っています。 \nSocialフレームワークを使ってゲーム内の結果をSNSに投稿することはできたのですが \nその逆をやってみたいです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T10:59:32.773", "favorite_count": 0, "id": "21003", "last_activity_date": "2016-09-23T12:28:02.933", "last_edit_date": "2016-09-23T12:28:02.933", "last_editor_user_id": "5519", "owner_user_id": "13961", "post_type": "question", "score": -3, "tags": [ "swift", "swift2" ], "title": "「しりとり漫才」のような、それでいてシンプルなアプリを作りたい", "view_count": 462 }
[ { "body": "Parseを使用してログイン機能を実装するのもいいかもしれません\n\n↓参考\n\n個人のスマホアプリ開発者がParseを使うべき15の理由 \n<http://qiita.com/koyopro/items/b9891aa7bb596b958d7e>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-22T08:42:04.897", "id": "21185", "last_activity_date": "2016-01-22T08:42:04.897", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5828", "parent_id": "21003", "post_type": "answer", "score": 1 } ]
21003
null
21185
{ "accepted_answer_id": "21005", "answer_count": 2, "body": "Webにテキストデータとしてアップロードしたスクリプトを CURLで取得して実行したいです。\n\nURL \n<https://dl.dropboxusercontent.com/u/8763485/stackoverflow.sh> \n内容: \n`echo ':)'`\n\nにアップロードしたテキストを curl でダウンロードして実行したいです", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T12:46:13.610", "favorite_count": 0, "id": "21004", "last_activity_date": "2016-01-19T03:39:47.907", "last_edit_date": "2016-01-17T14:01:37.143", "last_editor_user_id": "5505", "owner_user_id": "5505", "post_type": "question", "score": 0, "tags": [ "linux", "shellscript" ], "title": "CURL で取得したテキストをスクリプトとして実行したい", "view_count": 2755 }
[ { "body": "ソース\n\n`curl -sf https://dl.dropboxusercontent.com/u/8763485/stackoverflow.sh | sh\n-s`\n\n出力 \n`:)`\n\nこれでいかがでしょうか", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T12:50:42.280", "id": "21005", "last_activity_date": "2016-01-19T03:39:47.907", "last_edit_date": "2016-01-19T03:39:47.907", "last_editor_user_id": "14041", "owner_user_id": "14041", "parent_id": "21004", "post_type": "answer", "score": 3 }, { "body": "bash以外のshell入っても実行できます。\n\n```\n\n sh -c \"$(curl -fsSL https://dl.dropboxusercontent.com/u/8763485/stackoverflow.sh)\"\n \n```\n\ncurl: \n-f, --fail \nサーバエラーが生じたときに黙って(何も出力しないまま)終わらせます。 \n-s, --silent \n沈黙モードにします。 \n-S, --show-error \n失敗時にはエラーメッセージが表示されるようになります。 \n-L, --location \nサイトからクッキーと location が送信されてくる場合、次のように存在しないファイルを与えて,「クッキーの意識的処理」を起動させられる。\n\nsh: \n-c シェルスクリプトを実行出来る。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T01:17:45.613", "id": "21013", "last_activity_date": "2016-01-18T01:23:39.417", "last_edit_date": "2016-01-18T01:23:39.417", "last_editor_user_id": "7325", "owner_user_id": "7325", "parent_id": "21004", "post_type": "answer", "score": 1 } ]
21004
21005
21005
{ "accepted_answer_id": null, "answer_count": 0, "body": "ターミナルを開いた時にtmuxを自動起動できるようになると聞いてtmux-resurrectを入れてみました。しかし、セッションを復帰させると固まります。\n\n症状としては、入力を一切受け付けなくなる、ただし `prefix Ctrl-q`\nなどは受け付けるので完全に固まってるのではない。カーソルももちろん動かない。\n\nどうしたらターミナルを開いた時にtmux-\nresurrectで自動的にターミナル終了前の環境を、フリーズさせずに、再現できるのでしょうか?よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T13:09:54.303", "favorite_count": 0, "id": "21006", "last_activity_date": "2016-01-17T13:09:54.303", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9371", "post_type": "question", "score": 1, "tags": [ "tmux" ], "title": "tmux-resurrectでセッションを復帰させると固まります", "view_count": 236 }
[]
21006
null
null
{ "accepted_answer_id": "21025", "answer_count": 2, "body": "試すと「別ファイルをincludeしている部分」だけが読み込めない(include結果を表示できない)のですが、どうすれば良いでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T14:26:19.560", "favorite_count": 0, "id": "21009", "last_activity_date": "2016-01-18T13:36:03.383", "last_edit_date": "2016-01-18T13:36:03.383", "last_editor_user_id": "7886", "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "php" ], "title": "「別ファイルをincludeしているphp込みのHTMLファイル」を、file_get_contents で読み込むことは可能?", "view_count": 2791 }
[ { "body": "PHPとして評価されていない実行されないテキストファイルがそのまま表示されるかと思います。 \nfile_get_contentsは`ファイルを単純に読み込み、PHPファイルを読み込んだ場合でもPHPコードは特に実行しない`という動作を行うからです。 \n<http://php.net/manual/ja/function.file-get-contents.php>\n\nどうしてもPHPとして評価して欲しいという場合でしたら、 \n`file_get_contents('http://localhost/xxxxx.php');`等として`http`プロトコルを使ってファイルの拾得をするようにしておけば、 \nWebサーバーの機能(Apache+PHP)でご希望の動作が出来るようになるかと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-17T23:26:20.153", "id": "21012", "last_activity_date": "2016-01-17T23:26:20.153", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13999", "parent_id": "21009", "post_type": "answer", "score": 0 }, { "body": "PHPファイルを実行して読み込む方法の一つに、出力バッファリングを組み合わせるものがあります。例えば `template.php`\nを読み込みたいとすると、以下のように書けます。\n\n```\n\n $template = load_template();\n \n function load_template() {\n // 出力バッファリングを開始\n ob_start();\n \n // ここで読み込むと通常は画面に表示されるが\n // ob_startしているので画面出力の代わりにバッファされている\n include 'template.php';\n \n // バッファの中身を文字列として取り出し、バッファを破棄する\n return ob_get_clean();\n }\n \n```\n\ninclude で読み込まれたファイルは include した変数スコープで評価されます。include 前に定義した変数は `template.php`\nから参照できますし、 `template.php` 内で定義した変数は include\nした側に戻っても参照できます。そのため上記のように関数内で実行することで、互いの変数に必要以上の影響を与えないようにすることが多いかと思います。\n\nまた、`$_GET` `$_POST` `$_SERVER` などのスーパーグローバルや、カレントディレクトリは当然ながら include\nした時点のものを参照することになります。\n\nこれらの挙動はビューテンプレートなどには便利ですが、「ブラウザで表示する時と全く同じように」実行したいなら、miyabiさんが書かれているようにWebサーバーを経由する必要があるかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T05:39:09.620", "id": "21025", "last_activity_date": "2016-01-18T05:39:09.620", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "21009", "post_type": "answer", "score": 1 } ]
21009
21025
21025
{ "accepted_answer_id": null, "answer_count": 4, "body": "git管理している開発で、作業の途中(コミットするには中途半端)のものを一時的に保存する方法はありませんか?\n\n今はやむを得ず「途中」というコメントでコミットしています。\n\nシチュエーションとしては、しばらく作業から離れる時や、別のPCで作業を再開したい時などがあります。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T01:32:36.563", "favorite_count": 0, "id": "21015", "last_activity_date": "2016-08-16T03:39:38.500", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9149", "post_type": "question", "score": 6, "tags": [ "git" ], "title": "作業途中のgit", "view_count": 1811 }
[ { "body": "* **patch** で作業を一時的に保存する. \n作業の追加\n\n``` git add .\n\n \n```\n\n保存\n\n``` git diff >> patchfile\n\n \n```\n\n後は\n\n``` patch -p1 < patchfile\n\n \n```\n\n * **stash** で作業を一時的に保存する \n作業の追加\n\n``` git add .\n\n \n```\n\n保存\n\n``` git stash\n\n \n```\n\nメッセージをつける\n\n``` git stash save 'メッセージ'\n\n \n```\n\n保存されている状態のリストを見ることができる。\n\n``` git stash list\n\n \n```\n\n前の作業をもどして\n\n``` git stash apply\n\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T02:11:24.760", "id": "21017", "last_activity_date": "2016-01-19T06:03:40.727", "last_edit_date": "2016-01-19T06:03:40.727", "last_editor_user_id": "7325", "owner_user_id": "7325", "parent_id": "21015", "post_type": "answer", "score": 3 }, { "body": "Qiitaの記事の[Gitのこれやめて!リスト](http://qiita.com/doilux/items/b5a9abd95ac91e848a5f)の[「その3:とりあえずコミットしてPushするのやめて」](http://qiita.com/doilux/items/b5a9abd95ac91e848a5f#%E3%81%9D%E3%81%AE%EF%BC%93%E3%81%A8%E3%82%8A%E3%81%82%E3%81%88%E3%81%9A%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88%E3%81%97%E3%81%A6push%E3%81%99%E3%82%8B%E3%81%AE%E3%82%84%E3%82%81%E3%81%A6)の対策として書かれているように、それ用のブランチを作ってコミット&プッシュすれば良いのではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T13:59:43.983", "id": "21088", "last_activity_date": "2016-01-19T13:59:43.983", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7291", "parent_id": "21015", "post_type": "answer", "score": 2 }, { "body": "`wip` などのコミットメッセージで、ひとまずコミットして、他の端末で利用するならば、(作業用ブランチに)プッシュをします。\n\n特に、ローカルのみで完結する場合でも、最近は stash ではなく commit を利用しています。なぜかというと、 stash はついうっかり drop\nしてしまうともうその内容は基本的にリカバリーできないですが、 commit ならば reflog が残っていて、そこから復旧できるからです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-08-14T05:26:56.073", "id": "28252", "last_activity_date": "2016-08-14T05:26:56.073", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "754", "parent_id": "21015", "post_type": "answer", "score": 3 }, { "body": "以前同じようなことを調べた時に[git-now](https://github.com/iwata/git-\nnow)というツールを見つけたのでそれを使っています。 \n`git now`で一時コミットを作成し、`git now rebase`で一時コミットをまとめて`rebase -i`できます。\n\nやっていることは一時コミットを作ることと同じなので、pushするのであれば専用のブランチを作ってからにした方が良いと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-08-16T03:39:38.500", "id": "28299", "last_activity_date": "2016-08-16T03:39:38.500", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2988", "parent_id": "21015", "post_type": "answer", "score": 0 } ]
21015
null
21017
{ "accepted_answer_id": "21036", "answer_count": 1, "body": "以下のコードでAutoCompleteTextが現状2文字以上入力した場合にsetCursorToStringConverterが起動します。 \n1文字目で起動させたい場合はどのようにすればよいですか。\n\n```\n\n AutoCompleteTextView inputTextView = (AutoCompleteTextView) findViewById(R.id.m_name);\n Cursor m_cursor = db3.query(DB_TABLE, new String[]{\"rowid as _id\", \"n_data\" },null, null,null, null, null);\n SimpleCursorAdapter M_adapter2 = new SimpleCursorAdapter(getApplicationContext(),\n android.R.layout.simple_spinner_dropdown_item,\n m_cursor,\n new String[]{\"n_data\"},\n new int[]{android.R.id.text1},\n 0) {\n };\n M_adapter2.setCursorToStringConverter(new SimpleCursorAdapter.CursorToStringConverter() {\n @Override\n public String convertToString(Cursor m_cursor) {\n return m_cursor.getString(m_cursor.getColumnIndex(\"n_data\"));\n }\n M_adapter2.setFilterQueryProvider(new FilterQueryProvider() {\n public Cursor runQuery(CharSequence constraint) {\n String str = constraint.toString();\n str = \"%\" + str + \"%\";\n helper = new DBOpenHelper(ItemListActivity.this);// DB作成\n Cursor m_cursor = helper.getReadableDatabase().query(\n DB_TABLE4, new String[]{\"rowid as _id\", \"n_data\"},\n \"n_data LIKE '' || ? || '%' \", new String[]{str},\n null,null, null);\n return m_cursor;\n }\n });\n inputTextView2.setAdapter(M_adapter2);\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T02:36:27.427", "favorite_count": 0, "id": "21019", "last_activity_date": "2016-01-19T01:36:41.623", "last_edit_date": "2016-01-19T01:36:41.623", "last_editor_user_id": "14038", "owner_user_id": "13247", "post_type": "question", "score": 1, "tags": [ "android", "java" ], "title": "androidで予測変換機能を1文字目から起動させたい", "view_count": 278 }
[ { "body": "```\n\n final AutoCompleteTextView inputTextView = (AutoCompleteTextView) findViewById(R.id.m_name);\n inputTextView.addTextChangedListener(new TextWatcher() {\n @Override\n public void beforeTextChanged(CharSequence s, int start, int count, int after) {\n }\n \n @Override\n public void onTextChanged(CharSequence s, int start, int before, int count) {\n if (count == 1) {\n inputTextView.setThreshold(0);\n }\n }\n \n @Override\n public void afterTextChanged(Editable s) {\n \n }\n });\n \n```\n\nこれでできます。テキスト入力前、入力後などは適宜上下のメソッドで可能です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T12:36:56.193", "id": "21036", "last_activity_date": "2016-01-18T12:36:56.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14038", "parent_id": "21019", "post_type": "answer", "score": 2 } ]
21019
21036
21036
{ "accepted_answer_id": "21024", "answer_count": 1, "body": "EC2内で、ダンプファイルのあるディレクトリで下記コマンドを実行するとエラーが表示されます。 \nセキュリティグループは統一してあるのですが、何か設定が必要ですか?\n\n```\n\n mysql -h abc.c3uoslncvvzp.ap-northeast-1.rds.amazonaws.com < schema.sql\n \n ERROR 1045 (28000): Access denied for user 'ec2-user'@'1××.××.11.22' (using password: NO)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2016-01-18T04:19:42.893", "favorite_count": 0, "id": "21021", "last_activity_date": "2023-06-05T01:30:09.177", "last_edit_date": "2023-06-05T01:30:09.177", "last_editor_user_id": "3060", "owner_user_id": "10980", "post_type": "question", "score": 0, "tags": [ "mysql", "amazon-ec2" ], "title": "EC2に置いてあるダンプファイルをRDS(MySQL)にインポートしたい", "view_count": 404 }
[ { "body": "```\n\n mysql -u root -p -h mysql -h abc.c3uoslncvvzp.ap-northeast-1.rds.amazonaws.com [テーブル名] < schema.sql\n \n```\n\nで解決しました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T05:07:11.600", "id": "21024", "last_activity_date": "2016-01-18T05:07:11.600", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10980", "parent_id": "21021", "post_type": "answer", "score": 2 } ]
21021
21024
21024
{ "accepted_answer_id": "21026", "answer_count": 1, "body": "現状で、EC2にVPCを設定していなくてデフォルトにしています、 \nAWSのコンソールでVPCを作成して、サブネットをVPC内に作成して、インスタンスに結びつけるというのをしているのですが、この設定をして、具体的に何が解決するのかが、わかりません。 \nVPCなどの設定をしなくても、ELB,RDS,EC2がつながっていて問題なく運用できているので、どのような意味があるのでしょうか?ネットで調べても記事はでてきますが、イメージができないです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T04:33:23.037", "favorite_count": 0, "id": "21022", "last_activity_date": "2016-01-18T09:49:04.673", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10980", "post_type": "question", "score": 2, "tags": [ "aws" ], "title": "AWSのVPCを設定しないとどのようなことが起こりますか?", "view_count": 1401 }
[ { "body": "現状で問題なく利用できているのであれば、無理して VPC に移行する必要はないと思います。 \nVPC にするメリットは下記があげられます。\n\n * VPN や Direct Connect で社内LANと接続することができる。 \n(いわゆる、プライベートクラウドとして利用)\n\n * インターネットから直接接続できないサブネットを作成することができる。 \n(例: Webサーバーを公開ネットワークに、DBサーバーを内部ネットワークに置く)\n\n * サブネットごとのルーティングや ネットワークACL を設定することができる。\n\n * セキュリティグループで inbound だけでなく、outbound も設定できる。\n\n * EC2インスタンスのローカルIPアドレスを固定にすることができる。\n\n * EC2インスタンスにローカルIPアドレスを複数設定できる。 \n(OS 側で IPエイリアス設定が必要)\n\n * ハードウェア専有オプションが選べる\n\n * T2, M4 などの新しいインスタンスクラスを選べる\n\nサブネット構成がとれるので、従来の(オンプレミスの)ネットワーク設計やセキュリティ設計の考え方をある程度流用できるということかと思います。 \nただし、サブネットといっても、ブロードキャストは使えないので、オンプレミスそのままとはいきませんが。\n\nデメリット\n\n * セキュリティグループの数に制限がかかる。 \n * VPC ごとに最大 100まで\n * 1インスタンスに最大 5 つまで\n * ルールは最大50まで", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T06:25:39.000", "id": "21026", "last_activity_date": "2016-01-18T09:49:04.673", "last_edit_date": "2016-01-18T09:49:04.673", "last_editor_user_id": "5008", "owner_user_id": "4603", "parent_id": "21022", "post_type": "answer", "score": 5 } ]
21022
21026
21026
{ "accepted_answer_id": "21031", "answer_count": 3, "body": "次のような状況を想定します。\n\n```\n\n int a;\n void plus_a_v1(int& elem)\n elem += a;\n int main() {\n a = foo(); // aはruntimeで決まると仮定。constexprにならない。\n int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\n for(int* ptr=array; ptr != array+10; ++ptr)\n plus_a_v1(*ptr);\n return 0;\n }\n \n```\n\n上記のような場合はaがどうしてもruntimeで決まるしかない状況でかつほぼすべての関数で使われるような変数であればある種の「環境」としてaを使っています。しかし、これではaを間違えて変更してしまったりする場合は問題になるので、次のようにプログラムを組み直しました。\n\n```\n\n void plus_a_v2(int& elem, const int a)\n elem += a;\n int main() {\n const int a = foo();\n int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\n for(int* ptr=array; ptr != array+10; ++ptr)\n plus_a_v2(*ptr, a);\n return 0;\n }\n \n```\n\nplus_a_v1とplus_a_v2の間の性能差はありますか?\n\nそして、後に環境が増えてきて、次のように定数の環境だけのための構造体Envを作った場合、Envの参照を変数として渡すplus_a_v3の実装はplus_a_v2およびplus_a_v1との理論的性能差はありますか?一応plus_a_v3のほうが構造体を通じて参照しているので、性能上少し劣りそうですが…\n\n```\n\n struct Env {\n int a;\n int b;\n };\n void plus_a_v3(int& elem, const Env& e)\n elem += e.a;\n int main() {\n const Env e = foo_Env(); // 環境定数を設定\n int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\n for(int* ptr=array; ptr != array+10; ++ptr)\n plus_a_v3(*ptr, e);\n return 0;\n }\n \n```\n\nまた、次のような場合も追加で考えられそうです。一応、これはaが一度決まった後は定数だということに基づきます。\n\n```\n\n struct plus_a_functor {\n const int a; \n plus_a_functor (const int a) : a(a) { }\n void operator() (int& elem) const {\n elem += a;\n }\n };\n int main() {\n const int a = foo();\n plus_a_functor plus_a_v4(a);\n int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\n for(int* ptr=array; ptr != array+10; ++ptr)\n plus_a_v4(*ptr);\n return 0;\n }\n \n```\n\nplus_a_v1, 2, 3, 4 それぞれの性能は理論的にどのように違いがありますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T08:37:50.080", "favorite_count": 0, "id": "21030", "last_activity_date": "2016-01-25T02:41:40.080", "last_edit_date": "2016-01-18T08:55:23.973", "last_editor_user_id": "10856", "owner_user_id": "10856", "post_type": "question", "score": 9, "tags": [ "c++" ], "title": "グローバル変数は極力使わずにそれを関数のargumentとして与えるべきですか?", "view_count": 3063 }
[ { "body": "> グローバル変数は極力使わずにそれを関数のargumentとして与えるべきですか?\n\nソフトウェア設計の一般論として、YESです。\n\n> plus_a_v1とplus_a_v2の間の性能差はありますか?\n\nこのレベルであれば、限りなく性能差はゼロといえます。(性能=実行速度と解釈しました)\n\nちなみに、グローバル変数を利用するplus_a_v1の方が\"速い\"ことを期待されているのであれば、plus_a_v2の方が速くなるケースも存在することを補足しておきます。一般的なC/C++処理系(よくあるCPUとOS)であればplus_a_v2の方がメモリアクセスの局所性が高くなり、ハードウェアが備えるキャッシュ機構を有効に使える可能性があるためです。実際には、観測可能なレベルの性能差が出ることはほぼ無いでしょう…\n\n> Envの参照を変数として渡すplus_a_v3の実装はplus_a_v2およびplus_a_v1との理論的性能差はありますか?\n\n理論的性能差が何を指すかによりますが、 **現実問題としての性能差はない** というのが私の回答です。\n\nまずは **実際のプログラム**\nで性能計測(マイクロベンチマークではダメ)を行い、ソースコードの可読性や保守性を犠牲にしてでも、速度性能が必要であると判断されてから、そこで初めてチューニングを行うべきです。\n\n* * *\n\n> plus_a_v1, 2, 3, 4 それぞれの性能は理論的にどのように違いがありますか?\n\n各バージョンに対する机上の説明としては下記の通りです。厳密にはOSやコンパイラによって挙動は異なりますが、大まかな目安と解釈ください。\n\n * v1:グローバル変数版。設計論の観点から避けるべき。\n * v2:引数値渡し版。スタック上に配置されるため、メモリアクセス局所性が改善。\n * v3:引数参照渡し版。間接参照を行う分の速度ペナルティが存在するが、コンパイラによる最適化で一部は改善見込みあり。\n * v4:本質的にv3と等価。メンバ変数アクセスには`this`ポインタからの間接参照が生じる。\n\nv3とv4では間接参照が必要となるため、若干の速度低下が生じる可能性はたしかにあります。これを抽象化とのトレードオフと捉えるか、許容できない性能劣化と捉えるかは目的によるかと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T09:07:21.390", "id": "21031", "last_activity_date": "2016-01-18T09:24:49.317", "last_edit_date": "2016-01-18T09:24:49.317", "last_editor_user_id": "49", "owner_user_id": "49", "parent_id": "21030", "post_type": "answer", "score": 17 }, { "body": "補足的ですが、静的変数はコンパイラによる最適化の対象となりません(コンパイラオプションなどによって最適化できるコンパイラもあるかもしれないけど・・・)。そのためplus_a_v1とplus_a_v2ではplus_a_v2の方が早くなる可能性が高いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-24T21:11:08.880", "id": "21272", "last_activity_date": "2016-01-24T21:11:08.880", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12774", "parent_id": "21030", "post_type": "answer", "score": -1 }, { "body": "`plus_a_v3`に関しては`b`を伴う`Env`になってしまうので比較できませんが、`plus_a_v1`、\n`plus_a_v2`、`plus_a_v4`について手元のVisual Studio 2015\nUpdate1で生成されるアセンブリコードを比較してみました。\n\nその結果、3者に大差なく、それ以前に **SSEを使用して4並列でplus_aを実行** していました。\n\nコンパイラーがインライン展開可能なように簡潔にすることと、副作用を持たないことや他の要素を変更しないことなど **並列化を妨げないこと**\nも重要になってくるようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-25T02:41:40.080", "id": "21276", "last_activity_date": "2016-01-25T02:41:40.080", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "21030", "post_type": "answer", "score": 2 } ]
21030
21031
21031
{ "accepted_answer_id": "21037", "answer_count": 1, "body": "下記は自分が作成したHTMLです。単純に入力フォームに検索したワードを入力して検索結果を表示するといった簡単なHTMLです。細かな機能として「全角を半角にする」「空白の場合パラメーターに付与しない」といった機能があります。 \n本題ですが検索結果を画面遷移せずにその場に表示するにはあとHTML側で何を用意すればいいのかわからずご質問させていただきます。\n\nAJAXを使用するにも使い方が、間違っているのか画面遷移しない、画面遷移しないようにしてもエラーが起きてしまい結局画面遷移してしまうといった症状が起きます。\n\n厚かましいですが、AJAXに不慣れなためもっと勉強したいです。よろしければおすすめのサイトなどありましたら教えてくださいませ。何卒宜しく御願い致します。\n\n```\n\n $(function() {\r\n $('#FORM').on('submit', function(e) {\r\n e.preventDefault();\r\n var $form = $(this).clone();\r\n $form.prop('method', $('#method_select').val());\r\n $(this).find(':input').each(function() {\r\n var $element = $(this);\r\n if ($element.val() == '') {\r\n $form.find('*[name=\"' + $element.prop('name') + '\"]').remove();\r\n }\r\n });\r\n $form.submit();\r\n });\r\n });\n```\n\n```\n\n <form action=\"http://52.192.178.185:8280/api/rankings\" id=\"FORM\" Accept-charset=\"UTF-8\">\r\n <br>\r\n <b>ランキング種別</b><font color=\"RED\">:必須</font><br>\r\n <p>【車種別:0】【メーカー別:1】【ボディタイプ別:2】【メーカー別:3】【国産車別:4】【輸入車別:5】</p>\r\n <p><input type=\"text\" value=\"0\" name=\"kind\" placeholder=\"例:0\" pattern=\"^[0-9]+$\" class=\"keyword\"></p>\r\n <b>サイト種別</b><font color=\"RED\">:必須</font><br>\r\n <p><input type=\"text\" value=\"0\" name=\"site\" placeholder=\"例:0\" pattern=\"^[0-9]+$\" class=\"keyword\"></p>\r\n <b>取得ページ位置</b>\r\n <p><input type=\"text\" value=\"\" name=\"page\" placeholder=\"例:1~20\" pattern=\"^[0-9]+$\" class=\"keyword\"></p>\r\n <b>取得数</b>\r\n <p><input type=\"text\"value=\"\" name=\"size\" placeholder=\"例:0~20\" pattern=\"^[0-9]+$\" class=\"keyword\"></p>\r\n <b>メーカーCD</b>\r\n <p><input type=\"text\" value=\"\" name=\"maker_cd\" placeholder=\"例:101\" pattern=\"^[0-9A-Za-z]+$\" class=\"keyword\"></p>\r\n <b>ボディタイプCD</b>\r\n <p><input type=\"text\" value=\"\" name=\"body_cd\" placeholder=\"例:10\" pattern=\"^[0-9A-Za-z]+$\" class=\"keyword\"></p>\r\n <b>集計開始年月日</b>\r\n <p><input type=\"text\" name=\"start_date\" placeholder=\"例:yyyymmdd形式\"pattern=\"^[0-9]+$\" class=\"keyword\" ></p>\r\n <b>集計終了日</b>\r\n <p><input type=\"text\" name=\"end_date\"placeholder=\"例:yyyymmdd形式\"pattern=\"^[0-9]+$\" class=\"keyword\"></p>\r\n <b>リクエスト方法</b><br>\r\n <select id=\"method_select\">\r\n <option value=\"GET\" selected>GET</option>\r\n <option value=\"POST\">POST</option>\r\n </select>\r\n <button type=\"submit\" class=\"btn btn-default btn-sm dropdown-toggle\">\r\n <span class=\"glyphicon glyphicon-search\" aria-hidden=\"true\"></span>\r\n </button>\n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T10:04:05.127", "favorite_count": 0, "id": "21033", "last_activity_date": "2016-01-18T12:37:06.883", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13072", "post_type": "question", "score": 0, "tags": [ "javascript", "html", "json", "ajax" ], "title": "作成したJSON取得機能を画面遷移せずに表示させたい", "view_count": 947 }
[ { "body": "そもそもformをsubmitしてしまったら、画面遷移になってしまいます。submitすることと、Ajaxでの非同期通信は全く違うものです。つまり、formのsubmitをe.preventDefault()で抑止するところまでは良いのですが、その後自らform.submit()しちゃってるので、結局submitされて画面遷移になってます。\n\n簡単に言うとpreventDefault()した後に、以下のようにすれば良いかと思います。\n\n```\n\n $.ajax({\n url: ...,\n type: ...,\n data: $form.serialize(),\n success: function(result, textStatus, xhr) {\n // Do something...\n },\n error: function(xhr, textStatus, error) {\n // Do something for error...\n }\n });\n \n```\n\n念のため、更にボタンの無効化、有効化を入れておけば良いかと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T12:37:06.883", "id": "21037", "last_activity_date": "2016-01-18T12:37:06.883", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "531", "parent_id": "21033", "post_type": "answer", "score": 1 } ]
21033
21037
21037
{ "accepted_answer_id": "21331", "answer_count": 1, "body": "pythonのプログラムを並列化しようと考え、pythonのモジュールであるmultiprocessingを実装した所以下のエラーが発生致しました。 \n使用しているモジュールは主に遺伝的アルゴリズム用のDEAPというモジュールです。 \n[DEAPのリファレンス](http://deap.readthedocs.org/en/master/index.html) \nコメントであるように`pool =\nmultiprocessing.Pool(3)`をmainの下に置いた所プロセスは5つ生まれマルチプロセスにはなれたのですが、タスクマネージャーで見たところそのプロセスのうち1つのみ稼働している見た目だけマルチプロセスになってしまいました。 \n<http://gazo.shitao.info/r/i/20160125185509_000.png> \n1つだけ25%でそれ以外0%であり、尚且つプロセスを3つ生み出す命令しているのにプロセスが4つ生み出されているため、プロセスを生み出す処理と動作する処理を別に行っていると考えられるのですがその理由がわかりません。どのようにするべきか教えてくれれば助かります。\n\n```\n\n import random\n import numpy\n import matplotlib.pyplot\n import time\n import multiprocessing\n from multiprocessing import Lock\n #from scoop import futures\n \n from deap import algorithms\n from deap import base\n from deap import creator\n from deap import tools\n \n toolbox = base.Toolbox()\n \n def main():\n # random.seed(64)\n NGEN = 5\n MU = 75\n LAMBDA = 75\n CXPB = 0.6\n MUTPB = 0.3\n \n pop = toolbox.population(n=MU)\n hof = tools.ParetoFront()\n stats = tools.Statistics(lambda ind: ind.fitness.values)\n stats.register(\"avg\", numpy.mean, axis=0)\n stats.register(\"std\", numpy.std, axis=0)\n stats.register(\"min\", numpy.min, axis=0)\n stats.register(\"max\", numpy.max, axis=0)\n \n algorithms.eaMuPlusLambda(pop, toolbox, MU, LAMBDA, CXPB, MUTPB, NGEN, stats,\n halloffame=hof)\n return pop, stats, hof\n if __name__ == '__main__':\n pool = multiprocessing.Pool(processes=3)\n toolbox.register('map', pool.map_async)\n for var in range(0,5):\n      ・・・・・\n \n```\n\n**追記** \n並列化に関してですが、このページを参考にしております。[DEAPの並列化](http://deap.readthedocs.org/en/master/tutorials/basic/part4.html?highlight=multiprocessing) \nここにあるようにMultiprocessing\nModuleを用いて並列化しており、中身としては以下のアルゴリズム中にあるmap関数で`multiprocessing.Pool.map_async`を呼び出すことで並列化計算していると考えています。 \nどこを並列化したいのかという点ですが、コメントにあるようにアルゴリズム中でmap関数が使われている点が個体の評価という点ですのでそこを並列化したいと考えています。 \n並列化していないバージョンですが、`if __name__ == '__main__':`以下の\n\n```\n\n pool = multiprocessing.Pool(processes=3)\n toolbox.register('map', pool.map_async)\n \n```\n\nをコメントアウトするなどで動作させない場合プロセスが生まれず通常通りに動きました。 \nまた、[参考にしたコード](http://pastebin.com/0WazVPKy)を実装した場合しっかりマルチプロセスで動いておりPCの問題ではないと思いますが、自分のコードではどこが原因となって見た目マルチプロセスになっているのかわかりません。 \nよろしくお願いします。 \n**追記2** \n自分のコードですがこのような形になります。 \n[全コード](http://pastebin.com/4wFneYgX) \n[参考にしたコード]同様にDEAPモジュールのalgorithmsを以下のように変更しております。 \n**変更点** \ndef eaMuPlusLambdaの\n\n```\n\n fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)\n \n```\n\nを\n\n```\n\n jobs = toolbox.map(toolbox.evaluate, invalid_ind)\n fitnesses=jobs.get()\n \n```\n\nとしています。全文を以下に載せます。\n\n**algorithms**\n\n```\n\n def eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen,\n stats=None, halloffame=None, verbose=__debug__):\n logbook = tools.Logbook()\n logbook.header = ['gen', 'nevals'] + (stats.fields if stats else [])\n \n # Evaluate the individuals with an invalid fitness\n invalid_ind = [ind for ind in population if not ind.fitness.valid]\n jobs= toolbox.map(toolbox.evaluate, invalid_ind)\n fitnesses=jobs.get()\n for ind, fit in zip(invalid_ind, fitnesses):\n ind.fitness.values = fit\n \n if halloffame is not None:\n halloffame.update(population)\n \n record = stats.compile(population) if stats is not None else {}\n logbook.record(gen=0, nevals=len(invalid_ind), **record)\n if verbose:\n print logbook.stream\n \n # Begin the generational process\n for gen in range(1, ngen+1):\n # Vary the population\n offspring = varOr(population, toolbox, lambda_, cxpb, mutpb)\n \n # Evaluate the individuals with an invalid fitness\n invalid_ind = [ind for ind in offspring if not ind.fitness.valid]\n jobs = toolbox.map(toolbox.evaluate, invalid_ind)\n fitnesses=jobs.get()\n for ind, fit in zip(invalid_ind, fitnesses):\n ind.fitness.values = fit\n \n # Update the hall of fame with the generated individuals\n if halloffame is not None:\n halloffame.update(offspring)\n \n # Select the next generation population\n population[:] = toolbox.select(population + offspring, mu)\n \n # Update the statistics with the new population\n record = stats.compile(population) if stats is not None else {}\n logbook.record(gen=gen, nevals=len(invalid_ind), **record)\n if verbose:\n print logbook.stream\n \n return population, logbook\n \n```\n\n**追記3** \n簡単なコード\n\n```\n\n # coding: UTF-8\n '''\n \n '''\n import multiprocessing\n \n def nibai(x): \n print multiprocessing.current_process()\n return x*x\n \n def aaa():\n p = Pool(3) \n print p.map(nibai, range(100)) \n \n \n if __name__ == \"__main__\":\n aaa()\n \n```", "comment_count": 13, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T11:21:32.897", "favorite_count": 0, "id": "21034", "last_activity_date": "2020-05-27T00:33:51.660", "last_edit_date": "2016-01-26T10:49:31.883", "last_editor_user_id": "13593", "owner_user_id": "13593", "post_type": "question", "score": 3, "tags": [ "python" ], "title": "pythonの並列化について", "view_count": 3043 }
[ { "body": "multiprocess版のeaMuPlusLambdaをコピペした他はimport周りを数行修正しただけですので説明は不要かと思います。ちなみに僕の環境ではmultiprocess化しないほうが速かったです。プロセス生成とプロセス間通信は一般にオーバーヘッドが大きいです。それで皆スレッドを使うわけですね。もっともPythonのスレッドはGIL(グローバル・インタープリタ・ロック)のせいでスピードが出ませんが。\n\n```\n\n diff -u original.py my.py\n --- original.py 2016-01-26 01:00:54.000000000 -0800\n +++ my.py 2016-01-26 01:02:21.000000000 -0800\n @@ -5,7 +5,7 @@\n '''\n import random\n import numpy\n -import matplotlib.pyplot\n +#import matplotlib.pyplot\n import time\n import multiprocessing\n # from multiprocessing import Lock\n @@ -42,6 +42,7 @@\n toolbox.register(\"population\", tools.initRepeat, list, toolbox.individual)\n \n def evalKnapsack(individual):\n + print multiprocessing.current_process()\n energy = 0.0\n power = 0.0\n for item in individual:\n @@ -49,7 +50,7 @@\n power += items[item][0]\n if power < MIN_POWER or energy < MIN_ENERGY:\n return 100000000000,1000000000000\n - print multiprocessing.current_process()\n +\n return energy, power\n \n def cxSet(ind1, ind2):\n @@ -77,6 +78,54 @@\n toolbox.register(\"mutate\", mutSet)\n toolbox.register(\"select\", tools.selSPEA2)\n \n +def eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen,\n + stats=None, halloffame=None, verbose=__debug__):\n + logbook = tools.Logbook()\n + logbook.header = ['gen', 'nevals'] + (stats.fields if stats else [])\n +\n + # Evaluate the individuals with an invalid fitness\n + invalid_ind = [ind for ind in population if not ind.fitness.valid]\n + jobs= toolbox.map(toolbox.evaluate, invalid_ind)\n + print jobs\n + fitnesses=jobs.get()\n + for ind, fit in zip(invalid_ind, fitnesses):\n + ind.fitness.values = fit\n +\n + if halloffame is not None:\n + halloffame.update(population)\n +\n + record = stats.compile(population) if stats is not None else {}\n + logbook.record(gen=0, nevals=len(invalid_ind), **record)\n + if verbose:\n + print logbook.stream\n +\n + # Begin the generational process\n + for gen in range(1, ngen+1):\n + # Vary the population\n + offspring = algorithms.varOr(population, toolbox, lambda_, cxpb, mutpb)\n +\n + # Evaluate the individuals with an invalid fitness\n + invalid_ind = [ind for ind in offspring if not ind.fitness.valid]\n + jobs = toolbox.map(toolbox.evaluate, invalid_ind)\n + fitnesses=jobs.get()\n + for ind, fit in zip(invalid_ind, fitnesses):\n + ind.fitness.values = fit\n +\n + # Update the hall of fame with the generated individuals\n + if halloffame is not None:\n + halloffame.update(offspring)\n +\n + # Select the next generation population\n + population[:] = toolbox.select(population + offspring, mu)\n +\n + # Update the statistics with the new population\n + record = stats.compile(population) if stats is not None else {}\n + logbook.record(gen=gen, nevals=len(invalid_ind), **record)\n + if verbose:\n + print logbook.stream\n +\n + return population, logbook\n +\n def main():\n NGEN =10\n MU = 30\n @@ -95,7 +144,7 @@\n stats.register(\"min\", numpy.min, axis=0)\n stats.register(\"max\", numpy.max, axis=0)\n \n - algorithms.eaMuPlusLambda(pop, toolbox, MU, LAMBDA, CXPB, MUTPB, NGEN, stats,\n + eaMuPlusLambda(pop, toolbox, MU, LAMBDA, CXPB, MUTPB, NGEN, stats,\n halloffame=hof)\n \n return pop, stats, hof\n \n```\n\n**出力(抜粋)**\n\n10世代目で27個体の評価が行われた部分の抜粋です。27個`<Process(PoolWorker-X, started\ndaemon)>`とあるのでワーカーが並列に実行していることがわかります。IDの値が後の方になるにつれて入り乱れているのも並列化されている証拠。次の行にある`10\n27...`とはGA/EAの10世代目で27個の個体が新たに評価されたことを示しています。先の27と一致していますね。\n\n```\n\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-1, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n <Process(PoolWorker-3, started daemon)>\n <Process(PoolWorker-2, started daemon)>\n 10 27 [ 3418.33333333 34263.33333333] [ 559.66110777 3609.56907246] [ 2540. 30400.] [ 4040. 41500.]\n Individual([513, 8439, 9095, 3082, 8203, 2830, 5391, 9876, 1430, 281, 9370, 7962, 7072, 5154, 9635, 8357, 5883, 2473, 4778, 2987, 4785, 5619, 4405, 1718, 9655, 8896, 6593, 9666, 5899, 4555, 8398, 2147, 468, 8014, 9815, 6104, 3988, 347, 9692, 9313, 355, 2020, 5483, 2369, 1523, 1140, 4905, 148, 6523, 4348, 1662, 4223]) (2540.0, 30400.0)\n []\n [28]\n [24]\n []\n [deap.creator.Fitness((2540.0, 30400.0))]\n elapsed_time:5.64607787132[sec]\n Timer unit: 1e-06 s\n \n Total time: 5.64599 s\n File: my.py\n Function: x at line 152\n \n```\n\n**なぜCPUの利用率が上がらないのか**\n\n並列化されている関数は次の極単純な関数です。計算コストは小さそうです。この関数を実行する時間よりも並列化のオーバーヘッド(計算の配信、結果の取得に伴うプロセス間通信など)が高ければCPUの利用率は上がりません。\n\n```\n\n def evalKnapsack(individual):\n print multiprocessing.current_process()\n energy = 0.0\n power = 0.0\n for item in individual:\n energy += items[item][1]\n power += items[item][0]\n if power < MIN_POWER or energy < MIN_ENERGY:\n return 100000000000,1000000000000\n \n return energy, power\n \n```\n\n**CPU利用率を見る実験**\n\n上の関数に時間のかかる処理を入れて、CPUの利用率をみます。オーバーヘッドよりも計算コストが高ければ利用率が上がるはず。ここでは`time.sleep(5)`などとやらず、forループで無駄にCPUを消費するのがポイント。\n\n```\n\n def evalKnapsack(individual):\n print multiprocessing.current_process()\n print \"busy loop\"\n n = 0\n for i in range(100000):\n for j in range(100000):\n n += 1.1\n energy = 0.0\n power = 0.0\n for item in individual:\n energy += items[item][1]\n power += items[item][0]\n if power < MIN_POWER or energy < MIN_ENERGY:\n return 100000000000,1000000000000\n \n return energy, power\n \n```\n\n**実験結果**\n\nWindows環境が今手元にないので、Macでtopコマンドを実行したところ、Pythonのプロセスが3つあり100%近く利用中になっていることがわかります。\n\n[![並列化の様子](https://i.stack.imgur.com/un1f0.png)](https://i.stack.imgur.com/un1f0.png)\n\n**アドバイス**\n\nもっと基礎的なプログラミングの練習をしてから、こういう大きな問題に取り組むことをお勧めしますよ。それに使い方の分からないモジュールはまず小さな問題で使って理解しましょう。例えばmultiprocessなら`def\nnibai(x): return\nx+x`みたいな簡単な関数で挙動を確かめるとか。いきなり組み合わせて結果を出そうとすると、個別に理解してから組み合わせるよりずっと時間がかかります。理解していないものを組み合わせても、どちらに動かない原因があるのかさえ分からないからね。", "comment_count": 2, "content_license": "CC BY-SA 4.0", "creation_date": "2016-01-26T09:06:16.893", "id": "21331", "last_activity_date": "2020-05-27T00:33:51.660", "last_edit_date": "2020-05-27T00:33:51.660", "last_editor_user_id": "40341", "owner_user_id": "7837", "parent_id": "21034", "post_type": "answer", "score": 6 } ]
21034
21331
21331
{ "accepted_answer_id": "21046", "answer_count": 1, "body": "ナビゲーションバーに「編集ボタン」をコードで配置すると、 \n編集モードでは「完了」 \n通常モードでは「編集」とボタンに表示されるかと思います。\n\n```\n\n self.navigationItem.rightBarButtonItem = editButtonItem()\n \n```\n\n一方、Storyboard上で「Bar Button Item」を配置し「System\nItem」プロパティを「Edit」に変更したボタンはボタンの表示が「完了」に変わりません。\n\n質問は2つあります。 \n1.ボタンの文字を変更する方法を教えてください。 \n2.今現在は編集ボタンに関してのみ差異(コードで配置する場合とSB上で配置する場合での差異)に気づきましたが、他にも挙動で違いがあるものでしょうか?\n\n画面レイアウトに関する部分は可能な限りSB上で設定ができれば開発効率が良いかなと思っていたのですが… \nコードでセットする方が安心かな〜と思い始めました^^;", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T11:34:31.143", "favorite_count": 0, "id": "21035", "last_activity_date": "2016-01-19T02:06:55.437", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13962", "post_type": "question", "score": 0, "tags": [ "xcode", "storyboard", "navigationbar" ], "title": "(Bar Button Item) コードで配置した場合とStoryboard上で配置した場合の違い", "view_count": 1198 }
[ { "body": "1. ボタンの文字を変更する方法 \nStoryboard上から追加するデフォルトのBar Button Itemでは自動で「Edit→Done」のように \n**文字を変更することはできない** と思います。 \n \nStoryboardから追加できるBar Button Itemは`UIBarButtonItem`です。 \nSystem Itemプロパティは \nUIBarButtonItemの`initWithBarButtonSystemItem:target:action:`に該当します。 \nこのメソッドの引数のSystem Itemは \niOSデフォルトのボタンの **デザインの設定** を意味します。 \n \n※Referenceに詳細が書かれています。 \n[UIBarButtonItem Class Reference:\ninitWithBarButtonSystemItem:target:action:](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBarButtonItem_Class/#//apple_ref/occ/instm/UIBarButtonItem/initWithBarButtonSystemItem:target:action:) \n[UIBarButtonItem Class Reference:\nUIBarButtonSystemItem](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBarButtonItem_Class/#//apple_ref/swift/enum/c:@E@UIBarButtonSystemItem) \n \nもし、Storyboard上で配置したいのであれば、 \n**UIBarButtonItemをカスタム化** することが考えられます。 \nつまり、UIBarButtonItemを継承して、文字変更メソッドを追加したクラスを作成し、 \nStoryboard上で追加したUIBarButtonItemのCustom Classにそれを設定する方法です。\n\n 2. 「Storyboardから追加するBar Button Item」と「editButtonItem()」の違いについて \n`editButtonItem()`が何かと言うと、 \nEdit/Doneの切換えが可能なカスタム`UIBarButtonItem`を返すメソッドを追加した \n`UIViewController`の拡張機能です。 \n実際に`UIViewController`の中身を見てみると、次のように定義されています。\n\nextension UIViewController {\n\n``` public var editing: Bool\n\n public func setEditing(editing: Bool, animated: Bool) // Updates the appearance of the Edit|Done button item as necessary. Clients who override it must call super first.\n \n public func editButtonItem() -> UIBarButtonItem // Return an Edit|Done button that can be used as a navigation item's custom view. Default action toggles the editing state with animation.\n \n```\n\n} \n \n編集ボタンだけでなく、`UINavigationController`を使うときなど、 \nどうしてもStoryboardだけで収まらなくなることは多々あると思います。 \n \nなので、1ではカスタム化といった方法を書きましたが、 \n個人的には **Storyboardとコードをうまく活用し合う** のが良いと思います。\n\n少しでも参考になれば幸いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T02:06:55.437", "id": "21046", "last_activity_date": "2016-01-19T02:06:55.437", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8968", "parent_id": "21035", "post_type": "answer", "score": 3 } ]
21035
21046
21046
{ "accepted_answer_id": null, "answer_count": 1, "body": "同様の記事は多数見受けられましたが、一通り試して解決しなかったため、ご教授願います。\n\nSpring4 \nJava8 \nWTPServer\n\nを使用した環境での、input type=\"file\"の非同期アップロードについてです。\n\n一部では、「セキュリティー上の都合で、Ajaxでの送信はできない」とのコメントがありましたが、 \n少数派であったため、信ぴょう性にかけました。 \nform.submit()での送信は成功しているため、Springの設定等は省略します。\n\nview.jsp\n\n```\n\n <input type=\"file\" id=\"image_upload\">\n \n```\n\nupload.js\n\n```\n\n $(\"#image_upload\").change(function(){\n var fd = new FormData();\n var file = $(\"#thumbnail_appender\").prop(\"files\")[0];\n var name = file.name;\n var size = file.size;\n \n fd.append(\"file\", file);\n fd.append(\"name\", name);\n fd.append(\"size\", size);\n \n $.ajax({\n url: http://localhost:8080/upload,\n type: \"POST\",\n dataType: \"text\",\n processData: false,\n contentType: false,\n data : fd,\n success : function(data) {\n alert(data);\n },\n error : function(XMLHttpRequest, textStatus, errorThrown) {\n if (callBack != null) {\n return callBack(textStatus);\n }\n }\n });\n });\n \n```\n\nUploadController.java\n\n```\n\n @RequestMapping(value=\"/upload\", method=RequestMethod.POST, produces=\"*/*\")\n public String thumbnailChange(@RequestParam(\"name\") String name,\n @RequestParam(\"size\") long size, \n HttpServletRequest request,\n HttpServletResponse response) throws Exception {\n Collection<Part> parts = request.getParts();\n Part part = parts.iterator().next();\n File inputFile = (File) ReflectionUtils.select(ReflectionUtils.select(part, \"fileItem\"), \"tempFile\");\n BufferedImage bufferedImage = ImageIO.read(inputFile);\n \n String[] nameSep = name.split(\"\\\\.\");\n String outputFile = SAVE_DIRECTORY + name;\n \n ImageIO.write(bufferedImage, nameSep[name.length() - 1], new File(outputFile));\n return outputFile.getName();\n }\n \n```\n\nUploadControllerに\n\n```\n\n @RequestParam(\"file\") MultipartFile multipartFile\n \n```\n\nを設定すると、「そんなパラメータ来てませんよ」となります。 \nHttpServletRequest内にはパラメータが入っているようですが、 \nダンプしても肝心のバイナリデータがありませんでした。 \nアプリケーションコンテキスト内に.tmpというデータで仮保存されているようで、 \nApplicationPart.fileItem.tempFileにフルパスの文字列がありました。 \n※そのパスが指すファイルはありませんでしたので、違うテストを行っている際に作られたものだと思いますが\n\n画像のバイナリデータおよび、メタデータをサーバーサイドで処理したいのですが、 \n何か設定ミスがありますでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T12:56:21.737", "favorite_count": 0, "id": "21039", "last_activity_date": "2016-09-27T13:54:44.747", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8396", "post_type": "question", "score": 1, "tags": [ "jquery", "ajax", "spring", "java8", "mvc" ], "title": "Springでの、MultipartFileの非同期アップロード", "view_count": 5917 }
[ { "body": "質問に記載した実装では、ファイルのヘッダ情報のようなものは受信可能でしたが、バイナリデータ自体は送信されていませんでした。\n\nコントローラ\n\n```\n\n @Controller\n @MultipartConfig(fileSizeThreshold=1024 * 1024, maxFileSize=10 * 1024 * 1024, maxRequestSize=10 * 1024 * 1024)\n public class maintnanceController extends CommonsExceptionHandler {\n \n```\n\nとすることで、受信することができました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-02-26T16:43:13.247", "id": "22576", "last_activity_date": "2016-02-26T16:43:13.247", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8396", "parent_id": "21039", "post_type": "answer", "score": 1 } ]
21039
null
22576
{ "accepted_answer_id": null, "answer_count": 0, "body": "この前からこのバグがどうしても取れません。\n\n```\n\n java.lang.RuntimeException: Unable to start activity\n ComponentInfo{com.pke.liveplusplus/com.pke.liveplusplus.activity.MainActivity}:\n android.content.res.Resources$NotFoundException: File res/drawable/back.png\n from xml type layout resource ID #0x7f020000\n \n```\n\nこんなエラーになります。\n\nいろいろ検索してみましてproject clean からの再ビルドしても解消せず。 \nR.Javaの削除後自動生成し再ビルドも解消せず。\n\nですがdrawableのリソースはあります。 \nレイアウトでもちゃんと表示はしているのですが、、、\n\n今回の事例はEclipseからAndroidStudio移行中におこりました。 \n方法としましてEclipseソースをAndroidStudioに1クラスずつコピペして行っています。\n\ndrawableFileはディレクトリごとコピーしました。\n\n環境は \ncompileSdkVersion 20 \nbuildToolsVersion '20.0.0'\n\nminSdkVersion 14 \ntargetSdkVersion 17\n\nです。\n\nどうかいい提案お願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T13:48:46.223", "favorite_count": 0, "id": "21040", "last_activity_date": "2016-01-18T17:04:14.940", "last_edit_date": "2016-01-18T17:04:14.940", "last_editor_user_id": "208", "owner_user_id": "14051", "post_type": "question", "score": 0, "tags": [ "android" ], "title": "android.content.res.Resources$NotFoundException", "view_count": 304 }
[]
21040
null
null
{ "accepted_answer_id": "21043", "answer_count": 1, "body": "**前提** \nmainテーブル \n・idカラムの値が9のレコード1件(常に1件)\n\ntableaテーブル \n・m_idカラムの値が9のレコード5件(idカラムの値によって変動)\n\ntablebテーブル \n・m_idカラムの値が9のレコード1件(idカラムの値によって変動)\n\n* * *\n\n**この時、「mainテーブル.idカラム」と「tableaテーブルm_idカラム」と「tablebテーブルm_idカラム」を結合してデータ取得したい** \n取得したい内容(idカラムの値は9) \n・mainテーブル全カラム \n・tableaテーブルcolaカラム5件分を連結した内容 \n・tablebテーブルcolbカラム1件分(を連結した内容)\n\n* * *\n\n**うまくいかないSQL** \n・colbconcatの連結数がcolaconcatと同じになってしまう\n\n```\n\n SELECT \n m.*,\n GROUP_CONCAT(a.cola) AS colaconcat,\n GROUP_CONCAT(b.colb) AS colbconcat,\n FROM main AS m\n LEFT JOIN tablea AS a ON (m.id = a.m_id)\n LEFT JOIN tableb AS b ON (m.id = b.m_id)\n WHERE m.id = 9\n GROUP BY m.id\n \n```\n\n下記のような内容を期待しているけど \n★,☆,■,□,● \n▲\n\n実際に取得される内容は \n★,☆,■,□,● \n▲,▲,▲,▲,▲", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T14:02:18.113", "favorite_count": 0, "id": "21041", "last_activity_date": "2016-01-18T15:27:58.950", "last_edit_date": "2016-01-18T15:16:00.757", "last_editor_user_id": "8000", "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "mysql", "sql" ], "title": "「GROUP_CONCAT」を2カラムに対して指定すると、思うような取得結果が取れない。結合の仕方がおかしい?", "view_count": 2114 }
[ { "body": "[`group_concat()`](http://dev.mysql.com/doc/refman/5.6/ja/group-by-\nfunctions.html#function_group-concat)\n関数は各行の値を連結するわけですが、質問に書かれたSQLの場合、連結前はどのような表になっているでしょうか。\n\n```\n\n SELECT \n id, cola, colb\n FROM main AS m\n LEFT JOIN tablea AS a ON (m.id = a.m_id)\n LEFT JOIN tableb AS b ON (m.id = b.m_id)\n WHERE m.id = 9\n \n```\n\nmainの行に対してtableaとtablebを同時にJOINしているので・・・\n\n```\n\n 9,1,1\n 9,2,1\n 9,3,1\n 9,4,1\n 9,5,1\n \n```\n\n`group_concat(colb)` とすると、`1,1,1,1,1` になるわけです。\n\n期待通りの結果を得るには、JOINする前に `group_concat()` する必要があります。\n\n```\n\n SELECT \n m.*, a.colaconcat, b.colbconcat\n FROM main AS m\n LEFT JOIN (\n SELECT m_id, group_concat(cola) AS colaconcat FROM tablea\n ) AS a ON (m.id = a.m_id)\n LEFT JOIN (\n SELECT m_id, group_concat(colb) AS colbconcat FROM tableb\n ) AS b ON (m.id = b.m_id)\n WHERE m.id = 9;\n \n```\n\nこうなるとサブクエリの方がわかりやすいかもしれません(パフォーマンスは知りませんが)。\n\n```\n\n SELECT \n m.*,\n (SELECT group_concat(cola) FROM tablea WHERE m_id = m.id) AS colaconcat,\n (SELECT group_concat(colb) FROM tableb WHERE m_id = m.id) AS colbconcat\n FROM main AS m\n WHERE m.id = 9;\n \n```\n\nJOINでは各テーブルの対応する行全ての組み合わせが結果に表れます。今回はtableb側が1行だったのでたまたまtableaの行数と一致しましたが、tablebが複数行だったらもっと増えていたことでしょう。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-18T15:16:35.047", "id": "21043", "last_activity_date": "2016-01-18T15:27:58.950", "last_edit_date": "2016-01-18T15:27:58.950", "last_editor_user_id": "8000", "owner_user_id": "8000", "parent_id": "21041", "post_type": "answer", "score": 0 } ]
21041
21043
21043
{ "accepted_answer_id": "21063", "answer_count": 2, "body": "HAVING句を「GROUP BY」を使用せず単独で使用可能なのはどういう要件でしょうか?\n\nSELECT句で集約関数を使用する場合か、SELECT句でASを使用する場合であれば、HAVING句を単独で利用可能なのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T02:17:11.563", "favorite_count": 0, "id": "21047", "last_activity_date": "2016-01-19T08:44:19.797", "last_edit_date": "2016-01-19T02:24:56.263", "last_editor_user_id": "7886", "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "mysql" ], "title": "HAVING句を単独で使用可能な要件は? 集約関数かASを使用すれば単独使用可能?", "view_count": 3555 }
[ { "body": "GROUP BY を必用としないHAVINGは「グループが無い=表全体」の集約結果に対して条件が書ける。ということだと思います。\n\nGROUP BYがないので 集約した結果は1行になります。それの結果をHAVINGで条件指定するので\n「1行返る」または「1行も返らない」という結果が期待出来ます。\n\n次の例は、having を使って表の行数とseq 列の最大値を比較してます。\n\n```\n\n select '通し番号が歯抜けです' \n from table\n having count(*) <> max(seq)\n \n```\n\nseq が 1から始まる通し番号だとすると 行数と seq\nの最大値は一致するはずです。一致しない場合は「通し番号が歯抜けです」という行が1行だけ返り、一致する場合は1行も返りません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T05:49:17.467", "id": "21052", "last_activity_date": "2016-01-19T05:49:17.467", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "21047", "post_type": "answer", "score": 1 }, { "body": "標準SQLにおけるHAVING句は **グループ化を行った後** の表から抽出を行う処理です。\n\nそのため[PostgreSQL](http://www.postgresql.jp/document/9.4/html/sql-\nselect.html#SQL-\nHAVING)などでは(SELECT句の列リスト同様に)グループ化を行った後で一意に決まる式しか使うことができません。具体的には以下のような式です。\n\n * GROUP BY に指定した列\n * 集約関数\n * その他、列に依存しない式\n\nGROUP\nBYに列名を指定しなかったとしても全行をひとつとしてグループ化されるため、SELECT句で列を直接参照することはできませんし、結果は0行または1行になります。\n\n* * *\n\n一方MySQL([Oracleも?](http://sqlfiddle.com/#!4/8ca29f/56))では、GROUP\nBYや集約関数を使っていない場合にはグループ化が行われず、HAVING句がWHERE句と同じような挙動をするようです。\n\nGROUP BY や集約関数によってグループ化が行われた場合でも、MySQLではGROUP\nBYに指定しなかった列もHAVINGに書くことができますが、この場合はグループ内の **適当な**\n一行に対して条件式が評価されるのでまた違った挙動を示します。\n\n```\n\n INSERT INTO hoge(a,b) VALUES (1,1), (1,2), (1,3);\n \n SELECT a,b FROM hoge\n HAVING b > 1; -- 結果は2行\n \n SELECT a,b FROM hoge\n GROUP BY 1\n HAVING b > 1; -- 結果は2行\n \n SELECT a,b FROM hoge\n GROUP BY a\n HAVING b > 1; -- 結果は0 or 1行\n \n SELECT a,b FROM hoge\n HAVING b > 1 and count(*) > 0; -- 結果は0 or 1行\n \n SELECT count(*),a,b FROM hoge\n HAVING b > 1; -- 結果は0 or 1行\n \n```\n\nそして、ASで指定した列名のエイリアスをHAVINGで使えるのもMySQLの拡張です。\n\nいずれにせよHAVING句に何を指定できるか、その結果がどうなるか、そしてHAVINGを使う意味があるかという問題でしかなく、「××で○○を使わないとHAVING句が使えない」ということはありません。\n\n参考\n\n * [MySQL :: MySQL 5.6 リファレンスマニュアル :: 13.2.9 SELECT 構文](https://dev.mysql.com/doc/refman/5.6/ja/select.html)\n * [MySQL :: MySQL 5.6 リファレンスマニュアル :: 12.19.3 MySQL での GROUP BY の処理](https://dev.mysql.com/doc/refman/5.6/ja/group-by-handling.html)\n * [What is the correct result for this query? - Database Administrators Stack Exchange](https://dba.stackexchange.com/a/33791)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T08:10:40.690", "id": "21063", "last_activity_date": "2016-01-19T08:44:19.797", "last_edit_date": "2017-04-13T12:43:06.283", "last_editor_user_id": "-1", "owner_user_id": "8000", "parent_id": "21047", "post_type": "answer", "score": 0 } ]
21047
21063
21052
{ "accepted_answer_id": null, "answer_count": 2, "body": "amazon apiに関する質問です。 \n調べてもよくわからなかったので質問させて頂きます。 \napiを使用して商品の下記の情報を取得することは可能でしょうか? \n・商品名 \n・メーカー \n・値段 \n・商品説明文 \n・商品画像 \n詳しい方、ご教示ください。宜しくお願い致します。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T02:59:59.323", "favorite_count": 0, "id": "21048", "last_activity_date": "2016-10-18T04:22:10.903", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8619", "post_type": "question", "score": 0, "tags": [ "php", "api", "amazon" ], "title": "amazon apiで取得できる情報について", "view_count": 2065 }
[ { "body": "公式のドキュメントをみると、「ItemLookup」で商品名、メーカーは取得できますね。 \n「CartAdd」で一回カートに入れれば、値段も取得できそうです。 \nただ、さくっと見た感じだと商品説明文と商品画像は取得できなさそうなので、いっそ「ItemLookup」で取得できるDetailPageURLからスクレイピングして直接全部取ってくるのが良いんじゃないでしょうか。\n\n[Product Advertising API](https://images-na.ssl-images-\namazon.com/images/G/09/associates/paapi/dg/index.html?rw_useCurrentProtocol=1)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T08:17:45.197", "id": "21064", "last_activity_date": "2016-01-19T08:17:45.197", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14047", "parent_id": "21048", "post_type": "answer", "score": 1 }, { "body": "ItemLookupでResponseGroupにItemAttributes,Offers,Reviewsを設定したら帰ってくると思いますよ。 \n多くイメージが欲しい場合はImagesも追加します。\n\nプログラムを作って試してみるのも手ですが \nアカウントを持っているなら以下のページの左側にあるLookup-itemLookupを選択し、必要情報(Marketplace,associate\nTagなど)を記載後に実際のデータを見ることができます。 \n<http://webservices.amazon.co.jp/scratchpad/index.html>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-10-18T04:22:10.903", "id": "29644", "last_activity_date": "2016-10-18T04:22:10.903", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "19208", "parent_id": "21048", "post_type": "answer", "score": 1 } ]
21048
null
21064
{ "accepted_answer_id": "21050", "answer_count": 1, "body": "`~/Desktop/animals/cat.txt`\n\nが存在するかコマンドで確かめたい。\n\n存在したら `Found` \n存在しなかったら `Not found` \nを出力したいです", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T04:33:52.763", "favorite_count": 0, "id": "21049", "last_activity_date": "2016-01-19T06:14:17.587", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5505", "post_type": "question", "score": 1, "tags": [ "linux", "shellscript" ], "title": "指定したファイルパスが存在するか確かめたい", "view_count": 186 }
[ { "body": "ソース \n`[ -e ~/Desktop/animals/cat.txt ] && echo Found || echo Not found`\n\n出力 \n`Not found`\n\nオプション\n\n```\n\n -e ファイルかディレクトリが実在するか判定\n -f ファイルが実在するか判定\n -d ディレクトリが実在するか判定\n -x 実行可能ファイルが実在するか判定\n -r 読み込み可能か判定\n -w 書き込み可能か判定\n \n```\n\nこの書き方は `短絡評価` といいます", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T04:44:35.820", "id": "21050", "last_activity_date": "2016-01-19T06:14:17.587", "last_edit_date": "2016-01-19T06:14:17.587", "last_editor_user_id": "14041", "owner_user_id": "14041", "parent_id": "21049", "post_type": "answer", "score": 3 } ]
21049
21050
21050
{ "accepted_answer_id": "21055", "answer_count": 4, "body": "`~/Library/Application Support/`\n\nのようにスペースを含んだファイルパスを\n\n```\n\n $ path=\"~/Library/Application Support/\"\n $ [ -e \"$path\" ] && echo Found || echo Not Found\n \n```\n\nのように存在するか判定したいのですが、これを実行すると\n\n`Not Found`\n\nとファイルおよびディレクトリが見つからなかったと表示されてしまいます。 \nスペースを含んだファイルパスが存在するかどうか確かめるうまい方法はありませんか", "comment_count": 10, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T05:59:27.180", "favorite_count": 0, "id": "21053", "last_activity_date": "2016-01-20T03:18:55.637", "last_edit_date": "2016-01-19T06:30:24.223", "last_editor_user_id": "5505", "owner_user_id": "5505", "post_type": "question", "score": 2, "tags": [ "linux", "shellscript" ], "title": "スペースを含んだファイルパス存在するか確かめたい", "view_count": 492 }
[ { "body": "変数をクオートで囲みます。\n\n```\n\n $ test -e \"$path\"\n \n```\n\n(追記)\n\n「~」が展開されないというご指摘が有ったので別解として書きます。\n\n```\n\n $ path=\"~/Library/Application Support/\"\n $ ls -1 \"$path\" >/dev/null 2>&1 && echo \"Found\" || echo \"Not Found\"\n \n```\n\nわかりにくければ eval を使うと `~` を展開出来ます。\n\n```\n\n [ -e \"$(eval \"echo $path\")\" ] && echo \"Found\" || echo \"Not Found\"\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T06:04:06.133", "id": "21054", "last_activity_date": "2016-01-19T14:24:56.883", "last_edit_date": "2016-01-19T14:24:56.883", "last_editor_user_id": "5008", "owner_user_id": "5008", "parent_id": "21053", "post_type": "answer", "score": 1 }, { "body": "`test -e \"$HOME/Library/Application Support/\"`\n\nこれでどうでしょう。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T06:15:23.277", "id": "21055", "last_activity_date": "2016-01-19T06:15:23.277", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13999", "parent_id": "21053", "post_type": "answer", "score": 3 }, { "body": "ダブルクォートで囲まれた内部で `~(tilde)` が展開されない事について少し。\n\n> **bash(1)**\n>\n> **QUOTING**\n>\n> Enclosing characters in double quotes **preserves the literal value** of all\n> characters within the quotes, **with the exception of $, `, \\, and, when\n> history expansion is enabled, !**.\n```\n\n $ echo ~\n /home/nemo\n $ echo \"~\"\n ~\n \n```\n\n上記は bash についてですが、POSIX complient な shell 全てに当てはまります。\n\n[Shell Command Language - 2.2.3 Double-\nQuotes](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T08:21:07.583", "id": "21065", "last_activity_date": "2016-01-19T08:21:07.583", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "21053", "post_type": "answer", "score": 5 }, { "body": "すでに回答があるようにダブルクォートでエスケープするとチルダ展開は実行されないので、次のようにしましょう。\n\n```\n\n $ path=~\"/Library/Application Support/\"\n $ [ -e \"$path\" ] && echo Found || echo Not Found\n \n```\n\nこの書き方ならば、自分以外のユーザーでも OK です。\n\n```\n\n $ path=~username\"/Library/Application Support/\"\n $ [ -e \"$path\" ] && echo Found || echo Not Found\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T03:18:55.637", "id": "21103", "last_activity_date": "2016-01-20T03:18:55.637", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3061", "parent_id": "21053", "post_type": "answer", "score": 0 } ]
21053
21055
21065
{ "accepted_answer_id": null, "answer_count": 3, "body": "和暦で年だけを表すjavascriptを頂けますでしょうか?\n\n```\n\n document.write(date.toLocaleDateString(\"ja-JP-u-ca-japanese\"));\n \n```\n\nだと思いましたが違うみたいです。\n\nよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T06:23:02.757", "favorite_count": 0, "id": "21056", "last_activity_date": "2016-02-24T03:34:38.887", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7263", "post_type": "question", "score": 1, "tags": [ "javascript" ], "title": "和暦で年を表すjavascriptは?", "view_count": 3852 }
[ { "body": "「違うみたい」というのを説明して頂けますか? \n単に、年の部分を取り出すということなら`substring`と`indexOf`を使って`/`までを次の様にして切り出せます。\n\n```\n\n var date = new Date();\r\n date = date.toLocaleDateString(\"ja-JP-u-ca-japanese\");\r\n var year = date.substring(0, date.indexOf(\"/\"));\r\n document.write(year);\n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T06:45:21.537", "id": "21060", "last_activity_date": "2016-01-19T06:45:21.537", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "21056", "post_type": "answer", "score": 4 }, { "body": "自動更新される場合は、次のようにもできるようです。\n\n```\n\n <script language=\"javaScript\">\n <!--\n var now=new Date();\n var Wareki=now.getYear();\n if (Wareki>1000){Wareki -=1900;}\n Wareki -=88;\n document.write(\"<font style='font-size : 30px; color : red'>\");\n document.write(\"今年は平成\");\n document.write(Wareki);\n document.write(\"年\");\n document.write(\"です</font>\");\n //-->\n </script>\n \n```\n\n参考:<http://tsunamiblog.blog60.fc2.com/blog-entry-74.html>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T11:49:21.320", "id": "21129", "last_activity_date": "2016-01-20T11:49:21.320", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9359", "parent_id": "21056", "post_type": "answer", "score": -3 }, { "body": "`toLocaleDateString`の第二引数で`era`を指定すればよいのでは。\n\n```\n\n date.toLocaleDateString(\"ja-JP-u-ca-japanese\", { era:\"long\" })\n \n```\n\nただEdgeではこの指定だと`28/02/24`となり元号が出力されないようです。これが仕様なのか不具合なのかはわかりませんが、`平成`を得るには`day`が含まれないオプションにする必要があります。\n\n```\n\n date.toLocaleDateString(\"ja-JP-u-ca-japanese\", { era:\"long\", year:\"numeric\", month:\"numeric\" })\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-02-24T03:34:38.887", "id": "22462", "last_activity_date": "2016-02-24T03:34:38.887", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "21056", "post_type": "answer", "score": 1 } ]
21056
null
21060
{ "accepted_answer_id": "21090", "answer_count": 2, "body": "ドラッグアンドドロップされたローカルファイルを \n別のローカルフォルダにコピーするような処理を考えています。\n\n対応ブラウザはIE11のみとします。\n\nドラッグアンドドロップで取得したfileオブジェクトを元に \n別のローカルフォルダにコピーすることは可能なのでしょうか? \n`<input type=\"file\">`での取得であれば、パスが取得できるので実装は容易ですが、 \n現在パスの取得方法がわからず、困っています。 \nパスを使用しなくとも、何かしらの方法でファイルを目的の階層にコピー又は作成できれば問題ありません。 \n使用言語はPHP,javascriptになります。PHPを利用した方法でも構いません。\n\n申し訳ありませんが、どうかお願いします。\n\n```\n\n <div id=\"drag_zone\"></div>\n <script type=\"text/javascript\">\n $(document).on('dragover', '#drag_zone', function(evt){\n evt.stopPropagation();\n evt.preventDefault();\n evt.originalEvent.dataTransfer.dropEffect = 'copy';\n });\n $(document).on('drop', '#drag_zone', function(evt){\n // 移動先ファイルパス宣言\n var path = 'C://hoge/';\n // fileオブジェクト読込\n var files = evt.target.files;\n for(var i = 0; i < files.lenght;i++){\n // ここでパスを取得してファイルをコピーするか、\n // バイナリデータか何かしらを使用してフォルダに新しいファイルを\n // 新規作成したい。\n }\n });\n </script>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T06:34:30.213", "favorite_count": 0, "id": "21057", "last_activity_date": "2016-01-20T01:58:19.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13114", "post_type": "question", "score": 1, "tags": [ "javascript", "php", "jquery" ], "title": "javascriptでのファイル作成", "view_count": 3910 }
[ { "body": "この記事が参考になると思います。 \n[JavaScriptでファイル操作!? File APIを使いこなそう\n](http://www.atmarkit.co.jp/ait/articles/1112/16/news135.html)", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T14:21:20.433", "id": "21090", "last_activity_date": "2016-01-19T14:21:20.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9515", "parent_id": "21057", "post_type": "answer", "score": 0 }, { "body": "クライアント側のファイルシステムに(ブラウザ上で動作する)Javascriptからアクセスすることは基本的に不可能です。 \n例外的にFilesystemAPIというものがありますが、これは一部のブラウザでしか利用できません。\n\nもしなんらかのデータをファイルとして保存させたい、というのならばブラウザのダウンロード機能を利用することになります。 \nIEであればnavigator.msSaveOrOpenBlobなどを利用することになるでしょうか。 \nむろんこの場合の挙動はブラウザのダウンロード機能の設定次第となり、デフォルトではユーザーの「ダウンロード」ディレクトリに保存されるでしょう。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T01:58:19.770", "id": "21099", "last_activity_date": "2016-01-20T01:58:19.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14064", "parent_id": "21057", "post_type": "answer", "score": 0 } ]
21057
21090
21090
{ "accepted_answer_id": "21059", "answer_count": 4, "body": "`./text.txt`\n\nのファイルを空にしたいです", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T06:38:32.013", "favorite_count": 0, "id": "21058", "last_activity_date": "2016-03-15T22:09:30.690", "last_edit_date": "2016-02-29T18:08:01.700", "last_editor_user_id": "5505", "owner_user_id": "5505", "post_type": "question", "score": 2, "tags": [ "linux" ], "title": "ファイルを空にするコマンドは?", "view_count": 389 }
[ { "body": "`: > ./text.txt`\n\nor\n\n`echo -n > ./text.txt`\n\nこれでできます", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T06:40:36.347", "id": "21059", "last_activity_date": "2016-01-19T06:40:36.347", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14041", "parent_id": "21058", "post_type": "answer", "score": 6 }, { "body": "[truncate](https://linuxjm.osdn.jp/html/GNU_coreutils/man1/truncate.1.html)を使う方法\n\n`truncate --size=0 ./text.txt`", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T07:04:09.143", "id": "21061", "last_activity_date": "2016-01-19T07:04:09.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5044", "parent_id": "21058", "post_type": "answer", "score": 3 }, { "body": "cpコマンドを使う例:\n\n`cp /dev/null ./text.txt`", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-29T17:13:12.967", "id": "21489", "last_activity_date": "2016-01-29T17:13:12.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49", "parent_id": "21058", "post_type": "answer", "score": 2 }, { "body": "`> ./text.txt`\n\nたぶんこれが一番短いコマンドだと思います(`:` コロンすらいらない)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-03-15T22:09:30.690", "id": "23178", "last_activity_date": "2016-03-15T22:09:30.690", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5505", "parent_id": "21058", "post_type": "answer", "score": 1 } ]
21058
21059
21059
{ "accepted_answer_id": null, "answer_count": 0, "body": "GPSで座標を受け取って検索するアプリを書いています。 \nMonacaデバッガーからプロジェクトを開いて実行した際には座標を取得できるのですが、 \nデバッグビルドしたアプリを実行した際には取得できません。\n\n通知領域?(画面右上のあたり)にGPSマークも出ない状態です。 \nどの辺りを確認すればよいでしょうか?\n\n一応、下記が呼び出し部分のコードになります。\n\n```\n\n //GPS起動\n watchId= navigator.geolocation.watchPosition(onSuccessGps,onErrorGps, \n { maximumAge: 3000, timeout: 30000, enableHighAccuracy: true });\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T08:27:04.007", "favorite_count": 0, "id": "21066", "last_activity_date": "2016-01-19T09:23:28.137", "last_edit_date": "2016-01-19T09:23:28.137", "last_editor_user_id": "8000", "owner_user_id": "13177", "post_type": "question", "score": 0, "tags": [ "monaca" ], "title": "GPS機能がMonacaデバッガー上では動作するのにデバッグビルドだと動作しない", "view_count": 295 }
[]
21066
null
null
{ "accepted_answer_id": "21068", "answer_count": 1, "body": "チルダと$HOME では出力結果が違うのはなぜ?\n\n`$ test -e \"~/Library/Application Support/\" && echo Found || echo Not Found`\n\n**`Not Found`**\n\n`$ test -e \"$HOME/Library/Application Support/\" && echo Found || echo Not\nFound`\n\n**`Found`**\n\n**以下の回答からこの質問が生まれました。**\n\n> 「ダブルクォートで囲まれた内部で ~(tilde) が展開されない事について少し。」 \n> <https://ja.stackoverflow.com/a/21065/14041>\n```\n\n> $ echo ~\n> /home/nemo\n> $ echo \"~\"\n> ~\n> \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T08:28:12.747", "favorite_count": 0, "id": "21067", "last_activity_date": "2016-01-20T03:21:41.707", "last_edit_date": "2017-04-13T12:52:39.113", "last_editor_user_id": "-1", "owner_user_id": "5505", "post_type": "question", "score": 15, "tags": [ "bash", "sh", "shellscript", "zsh" ], "title": "チルダ と $HOME の違いってなんでしょうか?", "view_count": 11082 }
[ { "body": "`~`は例えばbashで[Shell\nExpansions](https://www.gnu.org/software/bash/manual/html_node/Shell-\nExpansions.html)の一つ、[Tilde\nExpansion](https://www.gnu.org/software/bash/manual/html_node/Tilde-\nExpansion.html)で、自分や他人のホームディレクトリに展開されます。\n\n> **If a word begins with an unquoted tilde character (‘~’)** , all of the\n> characters up to the first unquoted slash (or all characters, if there is no\n> unquoted slash) are considered a tilde-prefix.\n\nとあり`\"\"`で括られると条件を満たさなくなります。\n\n`$HOME`は同じくShell Expansionsの一つ、[Shell Parameter\nExpansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-\nExpansion.html)で、シェル変数・環境変数の値が展開されます。こちらは`~`のような制限はなさそうです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T08:42:45.640", "id": "21068", "last_activity_date": "2016-01-19T08:42:45.640", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "21067", "post_type": "answer", "score": 16 } ]
21067
21068
21068
{ "accepted_answer_id": null, "answer_count": 2, "body": "li2の中にある要素をliから除外したいと考えています。 \n実行するとli=[4]としようとしていますが,li=[2,4]となってしまいます. \nよろしくお願いします。\n\n```\n\n li=[1,2,3,4]\n li2=[1,2,3]\n \n for i in li:\n if i in li2:\n li.remove(i)\n \n print(li)\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T09:57:14.663", "favorite_count": 0, "id": "21070", "last_activity_date": "2016-01-19T11:14:55.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14061", "post_type": "question", "score": 4, "tags": [ "python" ], "title": "Pythonで1次元のリストを比較し,同一の要素の削除について", "view_count": 4908 }
[ { "body": "forは対象リストのi番目を順に見ていくだけで、対象リストが書き換わっても知ったこっちゃないようです。 \nli[:]の様にして同じ内容の別オブジェクトを用意するとおもったとおり動きます。 \n<http://docs.python.jp/2.7/reference/compound_stmts.html#the-for-statement>\n\n> 注釈\n>\n> ループ中のシーケンスの変更には微妙な問題があります ( これは変更可能なシーケンス、すなわちリストで起こります )\n> 。どの要素が次に使われるかを追跡するために、内部的なカウンタが使われており、このカウンタは反復処理を行うごとに加算されます。このカウンタがシーケンスの長さに達すると、ループは終了します。このことは、スイート中でシーケンスから現在の\n> ( または以前の ) 要素を除去すると、 ( 次の要素のインデクスは、すでに取り扱った要素のインデクスになるために )\n> 次の要素が飛ばされることを意味します。同様に、スイート中でシーケンス中の現在の要素以前に要素を挿入すると、ループ中で現在の要素が再度扱われることになります。こうした仕様は、厄介なバグになります。シーケンス全体に相当するスライスを使って一時的なコピーを作ると、これを避けることができます。\n```\n\n> for x in a[:]:\n> if x < 0: a.remove(x)\n> \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T10:07:10.553", "id": "21071", "last_activity_date": "2016-01-19T10:07:10.553", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "10685", "parent_id": "21070", "post_type": "answer", "score": 2 }, { "body": "新しくリストオブジェクトを作るようにしたほうがコード的にシンプルになります。\n\n```\n\n list(filter(lambda x:x not in li2, li))\n [4]\n \n```\n\nまたは\n\n```\n\n list(x for x in li if x not in li2)\n \n```\n\nあと、細かいことですが、li2 を集合にしたほうが理論上は速くなります。\n\n```\n\n li=[1,2,3,4]\n s={1,2,3}\n \n li = list(filter(lambda x:x not in s, li))\n \n print(li)\n [4]\n \n```\n\nliやli2が大きくなる場合は集合の利用を検討してみてください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T11:07:59.537", "id": "21073", "last_activity_date": "2016-01-19T11:14:55.120", "last_edit_date": "2016-01-19T11:14:55.120", "last_editor_user_id": "13227", "owner_user_id": "13227", "parent_id": "21070", "post_type": "answer", "score": 1 } ]
21070
null
21071
{ "accepted_answer_id": null, "answer_count": 0, "body": "現在、カメラロールから選択した画像をMasterViewControllerのコレクションビューに表示できるようにしています。その一つを選択してShowViewControllerに遷移し、そこで前画面で選択された画像を大きく表示できるようにしています。(iPhoneオリジナルアプリの「写真」のような感じ)\n\nここが問題なのですが、ShowViewControllerからMasterViewControllerに戻った時にShowViewControllerの表示された画像が解放されず、メモリが蓄積されていってしまいます。\n\nMasterViewController.m\n\n```\n\n - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender\n {\n if ([[segue identifier] isEqualToString:@\"showDetailView\"])\n {\n NSIndexPath *indexPath = [self.collectionView.indexPathsForSelectedItems objectAtIndex:0];\n Record *record2 = _records2[indexPath.section];\n ShowViewController *showViewController = segue.destinationViewController;\n showViewController.image2 = record2.images2[indexPath.row];\n showViewController.delegate = self;\n }\n \n```\n\nShowViewController.h\n\n```\n\n #import <UIKit/UIKit.h>\n #import \"SubjectViewController.h\"\n \n @protocol ShowViewControllerDelegate;\n \n @interface ShowViewController : UIViewController <UIScrollViewDelegate>\n {\n // UIImage *image2;\n }\n \n @property (weak, nonatomic) IBOutlet UIView *showSelectedPhoto;\n @property (weak, nonatomic) IBOutlet UIImageView *showSelected;\n @property (weak, nonatomic) IBOutlet UIScrollView *canScroll;\n \n @property (weak, nonatomic) UIImage *image2;\n \n @property (weak, nonatomic) id<ShowViewControllerDelegate> delegate;\n @end\n \n \n @protocol ShowViewControllerDelegate <NSObject>\n \n - (void)showViewControllerDeleteImage:(ShowViewController *)controller;\n \n @end\n \n```\n\nShowViewController.m\n\n```\n\n #import \"ShowViewController.h\"\n #import \"SubjectViewController.h\"\n #import \"LessonManager.h\"\n \n @interface ShowViewController ()\n \n //拡大領域を求めるメソッド\n - (CGRect)zoomRectForScale:(float)scale withCenter:(CGPoint)center;\n \n @end\n \n @implementation ShowViewController\n \n - (void)viewDidLoad {\n [super viewDidLoad];\n // Do any additional setup after loading the view.\n \n self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];\n self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0/255.0 green:105/255.0 blue:62/255.0 alpha:1.0];\n self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor colorWithRed:0/255.0 green:105/255.0 blue:62/255.0 alpha:1.0]};\n \n \n _showSelected.image = _image2;\n \n \n _canScroll.delegate = self;\n \n _canScroll.minimumZoomScale = 1;\n _canScroll.maximumZoomScale = 3;\n \n _canScroll.scrollEnabled = YES;\n _canScroll.showsHorizontalScrollIndicator = YES;\n _canScroll.showsVerticalScrollIndicator = YES;\n \n \n //ダブルタップ時の処理\n UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)];\n doubleTap.numberOfTapsRequired = 2;\n self.view.userInteractionEnabled = YES;\n [self.canScroll addGestureRecognizer:doubleTap];\n \n }\n \n \n //ここで確保したメモリを解放したい\n - (void)viewDidDisappear:(BOOL)animated\n {\n if (_showSelected != nil) {\n _showSelected.image = nil;\n [_showSelected removeFromSuperview];\n _image2 = nil;\n _showSelected = nil;\n }\n \n [self.view removeFromSuperview];\n }\n \n - (IBAction)tappedTrash:(id)sender\n {\n NSLog(@\"画像削除ボタンが押された\");\n [self.delegate showViewControllerDeleteImage:self];\n }\n \n //イメージをピッチアウト・ピッチイン処理\n - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView\n {\n return self.showSelected;\n }\n \n \n //ダブルタップ時の処理\n - (void)doubleTap:(UITapGestureRecognizer *)gesture\n {\n NSLog(@\"画面ダブルタップ\");\n //拡大時のブレ防止\n _canScroll.pagingEnabled = NO;\n \n //最大倍率じゃなければ拡大する\n if (_canScroll.zoomScale < _canScroll.maximumZoomScale) {\n //3倍の比率\n float newScale = _canScroll.zoomScale * 3;\n //拡大領域の指定\n CGRect zoomRect = [self zoomRectForScale:newScale withCenter:[gesture locationInView:gesture.view]];\n //タップした位置を拡大する\n [_canScroll zoomToRect:zoomRect animated:YES];\n } else {\n //倍率を1に戻す\n [_canScroll setZoomScale:1.0 animated:YES];\n }\n }\n \n \n //指定の座標を中心にして拡大領域を決める\n - (CGRect)zoomRectForScale:(float)scale withCenter:(CGPoint)center\n {\n \n CGRect zoomRect;\n //倍率から拡大する縦横サイズを求める\n zoomRect.size.height = [_canScroll frame].size.height / scale;\n zoomRect.size.width = [_canScroll frame].size.width / scale;\n //座標(左上)を設定する\n zoomRect.origin.x = center.x - (zoomRect.size.width / 2.0);\n zoomRect.origin.y = center.y - (zoomRect.size.height / 2.0);\n //領域を返す\n return zoomRect;\n }\n @end\n \n```\n\nこれで、ShowViewControllerからMasterViewControllerに戻った時には、ShowViewControllerで画像表示の際に生成したメモリが解放されると思ったのですが、メモリが減少していないので解放されていないように思われます。\n\nどなたか何か分かる方がいましたら、ご教授お願いします。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T11:00:08.603", "favorite_count": 0, "id": "21072", "last_activity_date": "2016-02-05T06:05:15.290", "last_edit_date": "2016-02-05T06:05:15.290", "last_editor_user_id": "8802", "owner_user_id": "8802", "post_type": "question", "score": 0, "tags": [ "objective-c", "iphone" ], "title": "UIImageの解放 メモリについて", "view_count": 956 }
[]
21072
null
null
{ "accepted_answer_id": null, "answer_count": 0, "body": "お世話になっております。\n\n現在GoogleAppEngineを利用してサーバーサイドを制作しています。 \nServletのバージョンは2.5です。\n\nAPIなどを作成する上でapi.example.comの形でサブドメイン形式にしようと思ってます。\n\nそこで\n\n通常ページ: example.com \nAPIページ: api.example.com \n管理ページ: admin.example.com\n\nのイメージでサブドメインでServletを分けたいと思います。\n\nソースファイルのパッケージ構成はクラス名を統一したいので \nページ用Servlet: com.exampleパッケージ \nAPI用Servlet: com.example.apiパッケージ \n管理用Servlet: com.example.adminパッケージ \nこのように分けて配置しようと考えています。\n\nそこで質問なのですが、 \nnewsの表示: example.com/news \nnewsのAPI: api.example.com/news \nnews管理画面: admin.example.com/news \nとURLを構成する場合、どのようにアクセスを判断してServletを切り分けるのがいいのでしょうか?\n\n`<url-pattern>`を使用するにもドメイン以下が同じのためうまく切り分けれていない状況です。 \n`<url-pattern>`で切り分けられれば`<security-constraint>`を使用するときも楽だなとは思っています。\n\n1つの手段としては \nfilterクラスを定義し、サブドメインを解析してサーブレットにforwardさせる \n方法ならできると思うのですが、news以外にもコンテンツが増えた場合、それに合わせてフィルタークラスも増えていくのがナンセンスだと思っています。\n\n宜しくお願い致します。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T11:17:18.880", "favorite_count": 0, "id": "21075", "last_activity_date": "2016-01-19T15:15:16.330", "last_edit_date": "2016-01-19T15:15:16.330", "last_editor_user_id": "5778", "owner_user_id": "297", "post_type": "question", "score": 1, "tags": [ "java", "java-ee", "servlet" ], "title": "起動するServletをサブドメインで判断したい", "view_count": 160 }
[]
21075
null
null
{ "accepted_answer_id": "21077", "answer_count": 2, "body": "配列の値の遷移を保存しておきたいと思い、下の例のようなプログラムを作成しました。\n\n```\n\n NSMutableDictionary* historyDic = [NSMutableDictionary dictionary];\n NSMutableArray* array = [NSMutableArray array];\n \n [array addObject:@\"1\"];\n [historyDic setObject:array forKey:@\"First\"];\n \n [array addObject:@\"2\"];\n [historyDic setObject:array forKey:@\"Second\"];\n \n [array addObject:@\"3\"];\n [historyDic setObject:array forKey:@\"Third\"];\n \n NSLog(@\"First ->%@\" , [historyDic objectForKey:@\"First\"]);\n NSLog(@\"Second->%@\" , [historyDic objectForKey:@\"Second\"]);\n NSLog(@\"Third ->%@\" , [historyDic objectForKey:@\"Third\"]);\n \n```\n\nしかし、このように辞書に途中途中でオブジェクトを保存しても参照として保存されるのでどのキーのオブジェクトも読み出し時の状態になってしまっています。\n\n実行結果:\n\n```\n\n First -> (1,2,3)\n Second-> (1,2,3)\n Third -> (1,2,3)\n \n```\n\n期待した結果:\n\n```\n\n First -> (1)\n Second-> (1,2)\n Third -> (1,2,3)\n \n```\n\nNSMutableDictionaryに参照ではなく、値としてオブジェクトを保存する方法はないのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T12:14:18.137", "favorite_count": 0, "id": "21076", "last_activity_date": "2016-03-12T07:30:57.837", "last_edit_date": "2016-01-19T12:28:04.280", "last_editor_user_id": "3639", "owner_user_id": "12490", "post_type": "question", "score": 1, "tags": [ "objective-c" ], "title": "NSMutableDictionary にオブジェクトを値で保存したい", "view_count": 792 }
[ { "body": "値を保存することはできませんが、`[NSMutableArray\narrayWithArray:array]`でNSMutableArrayのコピーの参照を保存することができます。\n\n```\n\n NSMutableDictionary* historyDic = [NSMutableDictionary dictionary];\n NSMutableArray* array = [NSMutableArray array];\n \n [array addObject:@\"1\"];\n [historyDic setObject:[NSMutableArray arrayWithArray:array] forKey:@\"First\"];\n \n [array addObject:@\"2\"];\n [historyDic setObject:[NSMutableArray arrayWithArray:array] forKey:@\"Second\"];\n \n [array addObject:@\"3\"];\n [historyDic setObject:[NSMutableArray arrayWithArray:array] forKey:@\"Third\"];\n \n NSLog(@\"First ->%@\" , [historyDic objectForKey:@\"First\"]);\n NSLog(@\"Second->%@\" , [historyDic objectForKey:@\"Second\"]);\n NSLog(@\"Third ->%@\" , [historyDic objectForKey:@\"Third\"]);\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T12:36:00.790", "id": "21077", "last_activity_date": "2016-01-19T12:36:00.790", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "21076", "post_type": "answer", "score": 1 }, { "body": "```\n\n NSMutableArray *historyArray = [[NSMutableArray alloc] init];\n NSMutableArray *array = [NSMutableArray array];\n \n [array addObject:@\"1\"];\n [histroyArray addObject [NSArchiver archivedDataWithRootObject:array];\n \n [array addObject:@\"2\"];\n [histroyArray addObject [NSArchiver archivedDataWithRootObject:array];\n \n [array addObject:@\"3\"];\n [histroyArray addObject [NSArchiver archivedDataWithRootObject:array];\n \n NSUInteger history = 0;\n for (NSData *past in historyArray) {\n NSLog(@\"%ld -> %@\", ++history, [NSUnarchiver unarchiveObjectWithData:past]);\n \n```\n\nとすると、どんなデータ型にも使えますね", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-03-12T07:30:57.837", "id": "23050", "last_activity_date": "2016-03-12T07:30:57.837", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14745", "parent_id": "21076", "post_type": "answer", "score": -1 } ]
21076
21077
21077
{ "accepted_answer_id": "21079", "answer_count": 2, "body": "`rm -rf example/`\n\nと\n\n`rmdir example/`\n\nの違いがわかりません。 \nどのような違いがあるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T12:41:57.990", "favorite_count": 0, "id": "21078", "last_activity_date": "2016-01-20T02:13:09.537", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14041", "post_type": "question", "score": 0, "tags": [ "linux" ], "title": "rm -rf と rmdir の違いって?", "view_count": 3388 }
[ { "body": "rmdir は空のフォルダしか削除できないです。\n\nrm -rf はフォルダの中でファイルが存在すれば削除ができます。\n\n例えば\n\n```\n\n mkdir example/\n touch example/file1\n \n rm -rf example/ はexampleのディレクトリーを隠しファイル以外削除できます。\n \n rmdir example/ はexampleのディレクトリーを削除できないです。\n rmdir: failed to remove `example': Directory not empty\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T12:50:21.130", "id": "21079", "last_activity_date": "2016-01-20T02:13:09.537", "last_edit_date": "2016-01-20T02:13:09.537", "last_editor_user_id": "7325", "owner_user_id": "7325", "parent_id": "21078", "post_type": "answer", "score": 7 }, { "body": "※`rm`について補足\n\n`rm` : 対象のファイルを削除する。 \n`-r` : 再帰的にディレクトリ内部を探査し子孫要素を削除する。 \nまた、このオプションを付与することでディレクトリを削除できる。 \n`-f` : 削除に発生する警告を非表示にする。\n\n下記の命令は同じものです。 \n`rm -r -f` = `rm -rf`\n\n例:対象がファイルのみの場合(警告あり)\n\n```\n\n rm *.txt\n \n```\n\n例:対象がディレクトリの場合(警告あり・子孫要素も削除対象)\n\n```\n\n rm -r example_dir\n \n```\n\n例:削除時に警告を発さずディレクトリを子孫要素ごと全て削除する場合\n\n```\n\n rm -rf example_dir\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T01:50:31.773", "id": "21098", "last_activity_date": "2016-01-20T01:50:31.773", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "21078", "post_type": "answer", "score": 1 } ]
21078
21079
21079
{ "accepted_answer_id": "21082", "answer_count": 2, "body": "`rm text.txt`\n\nで削除したファイルは実は完全削除されたわけではなく復元ができると知りました。\n\nファイルを完全にファイルを削除するコマンドはあるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T12:54:19.127", "favorite_count": 0, "id": "21080", "last_activity_date": "2016-01-19T13:10:39.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "14041", "post_type": "question", "score": 4, "tags": [ "linux" ], "title": "確実にファイルを削除するコマンドは?", "view_count": 1755 }
[ { "body": "rmしたファイルは、ファイルとしての管理情報が消されるだけで、ファイルのあったディスク領域の内容はそのままです。完全に消すには、ランダムに上書きするshredコマンドをかけた後でrmするとよいかと思います。\n\n```\n\n $ shred text.txt\n $ rm text.txt\n \n```\n\nまたは、shredコマンドに-uオプションを付けるとファイルの削除もやってくれます。\n\n```\n\n $ shred -u text.txt\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T13:07:53.453", "id": "21081", "last_activity_date": "2016-01-19T13:07:53.453", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4010", "parent_id": "21080", "post_type": "answer", "score": 3 }, { "body": "CentOS7で確認したところ`shred`コマンドがインストールされているようでした。`-u`オプション付きで削除ができますね。\n\n> shred - ファイルを上書きし、その内容が分からないようにする \n> (追加でファイルの削除も可能)\n\nちなみにMacOSXでは、`rm`に`-P`オプションをつけると似たようなことができるみたいです。\n\n> -P Overwrite regular files before deleting them. Files are overwritten three\n> times, \n> first with the byte pattern 0xff, then 0x00, and then 0xff again, before\n> they are \n> deleted.", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T13:10:39.040", "id": "21082", "last_activity_date": "2016-01-19T13:10:39.040", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2808", "parent_id": "21080", "post_type": "answer", "score": 5 } ]
21080
21082
21082
{ "accepted_answer_id": "21089", "answer_count": 2, "body": "以下の様なディレクトリがあり、ルートの `exile/` から完全にすべてのファイルとディレクトリを削除するコマンドはありますか?\n\n```\n\n exile/\n exile/members/\n exile/members/Hiro_Hiroyuki.txt\n exile/members/Toshio_Matsumoto.txt\n exile/members/Üsa_Yoshihiro.txt\n exile/members/...\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2016-01-19T13:27:16.383", "favorite_count": 0, "id": "21083", "last_activity_date": "2020-07-30T17:02:06.930", "last_edit_date": "2020-07-30T17:02:06.930", "last_editor_user_id": "3060", "owner_user_id": "5505", "post_type": "question", "score": 0, "tags": [ "linux" ], "title": "ディレクトリごと完全に削除するコマンドはありますか?", "view_count": 85985 }
[ { "body": "**MacOS**\n\n`rm -rP exile/`\n\n**Linux** \n<https://ja.stackoverflow.com/a/21089/14041>\n\n`rm -rf exile/`\n\nで完全削除できるはずです。\n\nオプション説明\n\n```\n\n -r 指定ディレクトリ以下をすべて削除\n -P データを3回書き換えてファイルを完全消去(**MacOS専用**)\n \n```\n\nこちらから引用しました\n\n> 「確実にファイルを削除するコマンドは?」 \n> <https://ja.stackoverflow.com/a/21082/5505>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T13:32:31.070", "id": "21084", "last_activity_date": "2016-01-19T15:32:10.563", "last_edit_date": "2017-04-13T12:52:38.920", "last_editor_user_id": "-1", "owner_user_id": "14041", "parent_id": "21083", "post_type": "answer", "score": 0 }, { "body": "「指定したディレクトリ内の全てファイルを削除する方法」という意味であれば、以下のコマンドをオススメします。\n\n```\n\n rm -rf exile\n \n```\n\nオプション指定の `-r` (recursive) は再帰的な削除を、`-f` (force) は警告メッセージを抑制するために使用します。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T14:17:54.250", "id": "21089", "last_activity_date": "2016-01-19T14:17:54.250", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2391", "parent_id": "21083", "post_type": "answer", "score": 4 } ]
21083
21089
21089
{ "accepted_answer_id": null, "answer_count": 1, "body": "PerlのRegexp::AssembleやRegexp::Trie、Emacs付属のregexp-\noptなどに相当するRubyの既存ライブラリを探しています。できればRubyGemsで。\n\n求めるものは、いくつもの文字列から、いずれかにマッチするコンパクトな正規表現(文字列)を作るメソッドです。たとえば、`\"who\"` `\"where\"`\n`\"when\"`の3つの文字列が与えられた場合、`\"who|where|when\"`ではなく、`\"(?:wh(?:e(?:n|re)|o))\"`のような結果を期待しています。\n\nなお、これは、作ることが目的ではなく、既存のものがあるかどうかを知りたいという質問です。そのため、上記の動作をするコード例を示す回答は、質問の意図に反しますので、念のため。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T13:54:00.343", "favorite_count": 0, "id": "21086", "last_activity_date": "2016-02-21T05:13:54.880", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4010", "post_type": "question", "score": 2, "tags": [ "ruby", "正規表現", "rubygems" ], "title": "RubyでRegexp::Assemble相当の既存ライブラリは?", "view_count": 324 }
[ { "body": "質問へのコメントのとおり、[regexp_trie](https://rubygems.org/gems/regexp_trie)がRubyGemsに登録されました。質問をクローズします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-22T04:12:56.320", "id": "21169", "last_activity_date": "2016-01-22T04:12:56.320", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4010", "parent_id": "21086", "post_type": "answer", "score": 1 } ]
21086
null
21169
{ "accepted_answer_id": "21093", "answer_count": 3, "body": "コマンドラインでパスワードの文字列を作成するコマンドはありますか?\n\nCentOS, Ubuntu, MacOS などに標準でインストールされているコマンドで作成がしたいです。", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T15:44:00.383", "favorite_count": 0, "id": "21092", "last_activity_date": "2022-01-07T08:51:58.270", "last_edit_date": "2022-01-07T08:51:58.270", "last_editor_user_id": "3060", "owner_user_id": "5505", "post_type": "question", "score": 2, "tags": [ "linux", "macos", "unix" ], "title": "コマンドラインでパスワードの文字列を作るには?", "view_count": 1200 }
[ { "body": "様々なコマンドあります。\n\n/dev/urandomを使う方法\n\n```\n\n strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\\n'; echo\n \n```\n\nopensslコマンドで\n\n```\n\n openssl rand -base64 32\n \n```\n\ngpgコマンドで\n\n```\n\n gpg --gen-random --armor 1 30\n \n```\n\npwgenが人間のために覚えやすいパスワードを作成します。\n\n```\n\n pwgen 30 1\n \n```\n\nmkpasswdで\n\n```\n\n mkpasswd\n \n```", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T15:49:54.727", "id": "21093", "last_activity_date": "2016-01-20T03:30:14.973", "last_edit_date": "2016-01-20T03:30:14.973", "last_editor_user_id": "7325", "owner_user_id": "7325", "parent_id": "21092", "post_type": "answer", "score": 7 }, { "body": "既に色々挙がっていますが、 \nmkpasswd \nというのが標準で入っているかもしれません。 \nmkpasswdでググるなりすれば、使い方は調べられると思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-19T16:14:28.787", "id": "21095", "last_activity_date": "2016-01-19T16:14:28.787", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8621", "parent_id": "21092", "post_type": "answer", "score": 0 }, { "body": "UbuntuやMac OSならpwgen、CentOSならmkpasswdがデフォルトであります。 \n(インストールすれば組み合わせ関係ないですけど・・・)\n\n8文字のランダムな文字がほしい場合は \n「mkpassword」か「pwgen 8 1」でいいと思います。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T03:00:26.207", "id": "21101", "last_activity_date": "2016-01-20T03:00:26.207", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13177", "parent_id": "21092", "post_type": "answer", "score": 0 } ]
21092
21093
21093
{ "accepted_answer_id": null, "answer_count": 2, "body": "カメラを呼び出して撮影した写真orギャラリから選択した写真をアップロードするツールを作っています。 \nスマホにインストールして動作確認中ですがandroidでの挙動が思ったようにいきません。\n\niPhoneの場合、ボタンをタップすると「写真またはビデオを取る」「フォトライブラリ」「その他」「キャンセル」が表示されます。 \nandroidの場合「次から開く」というメニューが出て、「ドライブ」や「ギャラリー」はあるのですがカメラで撮影できそうなアイテムはありません。 \nまた、写真を長押ししても複数選択できない状態です。\n\nプラグインはCameraとCaptureを有効にしています。 \nHTML内で下記のように書いています。\n\n```\n\n input type=\"file\" id=\"img\" accept=\"image/*;capture=camera\" multiple=\"multiple\">\n \n```\n\niPhoneと同じような挙動にするには、何か他の記述が必要でしょうか?\n\n\\---追記--- \nアプリのパーミッションはAndroidManifest.xmlに \n<uses-permission android:name=\"android.permission.CAMERA\" />を追記して、 \n端末のアプリ情報で「写真と動画の撮影」が付いているのは確認しています。 \n<https://support.google.com/googleplay/answer/6014972?hl=ja>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T02:44:41.063", "favorite_count": 0, "id": "21100", "last_activity_date": "2016-07-11T23:44:29.623", "last_edit_date": "2016-01-21T02:50:04.147", "last_editor_user_id": "13177", "owner_user_id": "13177", "post_type": "question", "score": 0, "tags": [ "monaca", "html5" ], "title": "Monacaのinputタグからカメラを起動したい", "view_count": 2104 }
[ { "body": "オプションの`capture`が`accept`に入ってるけど、こうじゃないのかなぁ?と……\n\n```\n\n <input type=\"file\" id=\"img\" accept=\"image/*\" capture=\"camera\" multiple=\"multiple\">\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-21T00:57:38.557", "id": "21140", "last_activity_date": "2016-01-21T00:57:38.557", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "21100", "post_type": "answer", "score": 0 }, { "body": "Monacaで使用しているCordovaのソースコード(Androidのネイティブコード)を確認してみたのですが、Input[Type=\"FILE\"]で呼ばれるメソッド(SystemWebChromeClient.javaのopenFileChooserやonShowFileChooser)で指定されているIntentが\n\n```\n\n android.intent.action.GET_CONTENT\n \n```\n\nとして実装されているため、カメラの起動は出来ないようです。(カメラを使いたい時は、`android.media.action.IMAGE_CAPTURE`というインテントを使う)\n\nそのため、カメラを起動させたい場合は、カメラプラグインを利用した方が良いと思います。 \nその場合、カメラプラグインで取得した画像を、そのままinput\ntype=\"file\"に紐づけることは出来ないので、用途に応じて以下のように対応すると良いのではないでしょうか。 \n1\\. サーバーに送信するのであればFileTransferプラグインを使用 \n2\\. デバイス内に画像を保存するなら、Fileプラグインを使用 \n3\\. Ajaxを使いたいのであれば、FormDataオブジェクトを使って実装(<http://blog.asial.co.jp/1271>)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-07-11T23:44:29.623", "id": "27548", "last_activity_date": "2016-07-11T23:44:29.623", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8848", "parent_id": "21100", "post_type": "answer", "score": 1 } ]
21100
null
27548
{ "accepted_answer_id": null, "answer_count": 2, "body": "pythonでnetworkXを用いて、頂点のラベル付けとしてfrozensetを用いているのですが、 \nfrozensetの要素を取得する方法が調べてもこれといったサイトを見つけることができなかったのでこちらに書き込まさせていただきました。 \n以下に例を示しておきますのでご参考にしていたければ幸いです。\n\n例 \n・frozenset([1, 2]) \nやりたいこと:要素1,2を取得したい \n困っていること:要素の取得ができない", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T03:12:11.807", "favorite_count": 0, "id": "21102", "last_activity_date": "2016-01-20T04:19:01.657", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13793", "post_type": "question", "score": 1, "tags": [ "python" ], "title": "frozensetの要素を取得する方法で困っております。", "view_count": 1410 }
[ { "body": "Setには順番がないためlistのようには取得できません \nそのため、forで取り出す必要があります。\n\n```\n\n \n s = frozenset([1, 2])\n for value in s:\n print(value) // 1, 2\n \n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T03:29:56.153", "id": "21104", "last_activity_date": "2016-01-20T03:29:56.153", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5246", "parent_id": "21102", "post_type": "answer", "score": 0 }, { "body": "for以外の選択肢もあります。取り出してどう使いたいかによって選んで下さい。\n\n```\n\n >>> f = frozenset([1,2])\n >>> f\n frozenset({1, 2})\n >>> list(f)\n [1, 2]\n >>> set(f)\n {1, 2}\n >>> tuple(f)\n (1, 2)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2016-01-20T04:19:01.657", "id": "21107", "last_activity_date": "2016-01-20T04:19:01.657", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "21102", "post_type": "answer", "score": 2 } ]
21102
null
21107