question
dict | answers
list | id
stringlengths 2
5
| accepted_answer_id
stringlengths 2
5
⌀ | popular_answer_id
stringlengths 2
5
⌀ |
---|---|---|---|---|
{
"accepted_answer_id": "24661",
"answer_count": 1,
"body": "`build.gradle`ファイルに`compileSdkVersion 23`と記述されており、AndroidStudioが`Download JDK7\nSelect a JDK from the File System Open build.gradle`というエラーメッセージを出します。\n\n現在、Macに入っているJavaは下記のようにJava8です。 \n[](https://i.stack.imgur.com/YVpj0.png)\n\n[Java SE Development Kit 7 - Downloads | Oracle Technology Network |\nOracle](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html) \nからJava7をダウンロードしてくればよいと思うのですが、Java7をインストールした場合、現状のJava8はどうなるのでしょうか?\nセキュリティの観点から最新のJavaをMacで使用した方がよいと考えているので、Java7にダウングレードするのはよくないと考えています。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T03:10:49.403",
"favorite_count": 0,
"id": "24659",
"last_activity_date": "2016-05-09T04:38:50.280",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9008",
"post_type": "question",
"score": 2,
"tags": [
"android",
"java",
"gradle"
],
"title": "Download JDK7 Select a JDK from the File System Open build.gradle",
"view_count": 132
} | [
{
"body": "compileSdkVersion は AndroidSDKのバージョン \nAndroid Studioに必要なのはJDK \nJDKは異なるバージョンを共存可能 \n添付の画像は現在macで使用しているJREのバージョン \nエラーメッセージはAndroid StudioにJDKの場所が設定されていないときに表示される \n最新のAndroid StudioはJDK8を使用可能\n\n取り急ぎ",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T04:38:50.280",
"id": "24661",
"last_activity_date": "2016-05-09T04:38:50.280",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7256",
"parent_id": "24659",
"post_type": "answer",
"score": 1
}
]
| 24659 | 24661 | 24661 |
{
"accepted_answer_id": "27700",
"answer_count": 1,
"body": "今までpostgresを使ったことがないのですが以前誰かが使っていたmacで \nrailsアプリ開発をしようとしています。postgres自体はインストールされていたようなので \npostresを起動しようとすると以下エラーが出ます。\n\n```\n\n admins-MacBook-Pro% psql -l\n psql: FATAL: role \"hoge\" does not exist\n \n```\n\npostgresユーザに変更しようとしたのですがユーザがいないみたいです。\n\n```\n\n su - postgres\n admins-MacBook-Pro% finger postgres\n finger: postgres: no such user\n \n```\n\nユーザを作成しようとしてもエラーになります。\n\n```\n\n admins-MacBook-Pro% createuser hoge\n createuser: could not connect to database postgres: FATAL: role \"hoge\" does not exist\n \n```\n\n初心者の質問ですみませんが解決法を教えてください。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T05:01:57.017",
"favorite_count": 0,
"id": "24663",
"last_activity_date": "2016-07-18T09:28:24.993",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10851",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"macos",
"postgresql"
],
"title": "mac railsアプリでpostgresを使いたい",
"view_count": 120
} | [
{
"body": "postgresのバージョンの問題でした。\n\n<http://y-yagi.hatenablog.com/entry/2015/12/02/062354>",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-07-18T09:28:24.993",
"id": "27700",
"last_activity_date": "2016-07-18T09:28:24.993",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10851",
"parent_id": "24663",
"post_type": "answer",
"score": 0
}
]
| 24663 | 27700 | 27700 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Google Maps API の javascript V3\nを使い、自作のスクリプトでウェブページにマップを表示させています。デフォルト表示される地図やマーカーは問題なく表示されているのですが、ペグマンをドラッグ&ドロップする形でストリートビューを表示させると、以前はちゃんと表示できていたものが今現在はちゃんと表示されていません。 \nGoogle API\nの[ストリートビューを解説しているこのページ](https://developers.google.com/maps/documentation/javascript/streetview?hl=ja#StreetView)と全く同じ状態です。 \n[](https://i.stack.imgur.com/NqW1d.png) \n背景はグレーで、ところどころ三角形の画像が散らばっています。方向などを変えるとその三角形も大きさ・位置が変わりますが、全体が表示されることはありません。\n\n実は、大手グルメ口コミサイトの Retty\nでもこの現象を目にしており、まさか自分のサイトでも同じ現象が起こっているとはつゆ知らず・・・この現象は広範に発生している可能性があります。\n\nと、ここまで書いてブラウザが Chrome での現象だと分かりました。IE や firefox ではちゃんと表示されているようです。もしかしたら自分の\nChrome だけこんな現象なのでしょうか?特に設定関係はいじっていないつもりですが・・・ \nChrome のバージョンは 50.0.2661.94 m (64-bit) 。現時点での最新バージョンです。\n\nどなたかご存知のかた、原因と対処法をご教授いただければ幸いです。",
"comment_count": 5,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T10:42:47.993",
"favorite_count": 0,
"id": "24674",
"last_activity_date": "2016-10-21T07:28:22.187",
"last_edit_date": "2016-05-11T02:37:11.807",
"last_editor_user_id": "15422",
"owner_user_id": "15422",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"api",
"google-maps"
],
"title": "Google Maps API V3 でストリートビューが表示できなくなっている。",
"view_count": 802
} | [
{
"body": "JavaやFlashに問題がありそうな気がします。 \n[Googleのトピックでストリートビューが真っ黒になる問題があったようです](https://productforums.google.com/forum/#!topic/maps-\nja/fiXkKjtR6fI/discussion) \n下記からJavaを再インストールしてみてはいかがでしょうか?\n\n<http://java.com/ja/download/>",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T01:38:41.693",
"id": "24731",
"last_activity_date": "2016-05-11T01:38:41.693",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24674",
"post_type": "answer",
"score": 1
}
]
| 24674 | null | 24731 |
{
"accepted_answer_id": "24728",
"answer_count": 1,
"body": "windows7上でpsycopg2とpython3.4.4を使ってredshiftに接続しています。\n\n大文字のテーブル名にアクセスしたいのですが、`relation \"table\" does not\nexist`になってしまい、アクセスできません。ダブルクォートで囲んでもアクセスできないのですが、解決法をご存知の方はいらっしゃいますか?\n\n以下コードになります\n\n```\n\n import psycopg2\n \n class KindOfCoupons:\n \n def get_coupons(self, cur, names):\n coupons = {}\n for name in names:\n coupons[name] = cur.execute(\"SELECT * FROM \\\"\" + name + \"\\\" ;\")\n return coupons\n \n def connect_redshift(self):\n conn = psycopg2.connect(\"dbname=dbname host=host user=user password=password port=000\")\n return conn.cursor()\n \n def get_coupon_used_type(self):\n cur = self.connect_redshift()\n names = [\"TABLE\", \"TABLE_B\", \"TABLE_C\"]\n coupons = self.get_coupons(cur, names)\n coupons[names[0]][0]\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T12:33:34.280",
"favorite_count": 0,
"id": "24675",
"last_activity_date": "2020-04-07T05:37:03.293",
"last_edit_date": "2020-04-07T05:37:03.293",
"last_editor_user_id": "19110",
"owner_user_id": "15425",
"post_type": "question",
"score": 1,
"tags": [
"python",
"aws",
"sql",
"amazon-redshift"
],
"title": "Redshiftで大文字のテーブル名を検索する",
"view_count": 448
} | [
{
"body": "> 標準的な識別子と区切り記号付き識別子は、大文字と小文字の区別がありませんが、小文字で表記されます。 \n> [AWS\n> Documentation](http://docs.aws.amazon.com/ja_jp/redshift/latest/dg/r_names.html)\n\nとの事です。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T22:03:47.277",
"id": "24728",
"last_activity_date": "2016-05-10T22:03:47.277",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3054",
"parent_id": "24675",
"post_type": "answer",
"score": 0
}
]
| 24675 | 24728 | 24728 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "はじめて質問させていただきます。\n\nAWS DynamoDBからAWS CloudSearchへのデータインポートについての質問です。\n\n現在、Swiftにてショッピングアプリの開発を行っています。\n\n特定の商品を検索する際に、DynamoDBのデータをCloudSearchにインポートし、検索ができるような仕組みになっています。\n\n質問なのですが、1日に複数回、DynamoDBに対して、追加・更新された差分データをリアルタイムでCloudSearchに反映させる方法として、どのような手段がありますか?\n\nDynamoDBに対して追加・更新する際に、同じテーブル構造の空のテーブル(yyyy_mm_ddを記載したからテーブル)をCloudSearchに反映をさせる方法があると思いますが、1日かかってしまいます(時間単位でアップロードすれば良いかもしれませんが...)\n\nこの方法以外で、解決方法をご存知の方がいらっしゃったら \nご返信いただければ幸いです。\n\n以上、よろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T12:34:57.607",
"favorite_count": 0,
"id": "24676",
"last_activity_date": "2016-05-12T04:01:37.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15424",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"aws"
],
"title": "DynamoDBからCloudSearchへリアルタイムにデータインポートする方法",
"view_count": 456
} | [
{
"body": "以下のURLに記載されているLogstashプラグインを使った方法はどうでしょうか?\n\n<https://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/Tools.DynamoDBLogstash.html>",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T17:14:22.177",
"id": "24725",
"last_activity_date": "2016-05-10T17:14:22.177",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5959",
"parent_id": "24676",
"post_type": "answer",
"score": 1
},
{
"body": "DynamoDBStreams機能を有効にすることでDynamoDBでのレコードの変化を取得できます。\n\n 1. DynamoDBでレコードを追加\n 2. DynamoDB Streams発動→Lambdaにデータがわたる\n 3. LambdaからCloudSearchへインデックス登録\n\nこのようにすれば実現可能かと思いますが如何でしょうか。\n\n蛇足かもしれませんが商品をリアルタイムにインデクシングしたいのであればCloudSearchより \nElasticSearchSearchの方が相性が良いでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T04:01:37.563",
"id": "24776",
"last_activity_date": "2016-05-12T04:01:37.563",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "11145",
"parent_id": "24676",
"post_type": "answer",
"score": 1
}
]
| 24676 | null | 24725 |
{
"accepted_answer_id": "24722",
"answer_count": 3,
"body": "tmux の中から、 `emacsclient -nw` を利用する形式で tmux と emacs を利用しています。\n\nelscreen でいうところの、 elscreen-clone がやりたくなったのですが、これはどうやったら実現できますでしょうか。\n(実現ができるのであるならば) \n具体的にやりたいことは、「他の tmux window (別端末と読み替えても問題ない)で emacsclient を開く際に、既存の\nemacsclient の emacs window 配置をそっくりそのままコピーしたい」です。\n\n自分の理解ですと、 各 `emacsclient -nw` は frame を作成しているので、新規の emacsclient (の frame) へ元の\nemacsclient の window 配置をコピーすればできるのでは、と踏んでいるのですが、これってそもそも実現可能だったでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T14:06:31.443",
"favorite_count": 0,
"id": "24677",
"last_activity_date": "2016-05-11T13:13:38.663",
"last_edit_date": "2016-05-09T14:12:49.353",
"last_editor_user_id": "754",
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"emacs"
],
"title": "tmux + emacsclient で elscreen-clone のようなことをしたい",
"view_count": 126
} | [
{
"body": "新しいフレームへの配置の複製とは異なる方法になりますが multi-tty 機能を使えばいいんではないかと思います。 \n<http://lorentey.hu/project/emacs.html.hu>\n\n[](https://i.stack.imgur.com/4dnVH.png)",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T23:48:00.093",
"id": "24686",
"last_activity_date": "2016-05-09T23:48:00.093",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "982",
"parent_id": "24677",
"post_type": "answer",
"score": 0
},
{
"body": "以下は `window-state-get` と `window-state-put` を使う方法です。\n\n```\n\n $ emacsclient -nw -e '\n (window-state-put\n (window-state-get (frame-root-window (nth 1 (frame-list)))))'\n \n```\n\n`(nth 1 (frame-list))` としていますので直前に作成した `frame` の `window configuration`\nが適用される事になります。また、`(nth 1 (reverse (frame-list)))` とすると、`emacsclient` で最初に作成した\n`frame` の `window configuration` が適用されます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T13:51:38.243",
"id": "24722",
"last_activity_date": "2016-05-10T13:51:38.243",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24677",
"post_type": "answer",
"score": 1
},
{
"body": "@argus さんの回答を参考に、 emamux に、この機能の PR を作成、マージしてもらいました。\n\n```\n\n M-x emamux:clone-current-frame\n \n```\n\nで、 elscreen-clone のようなことができます。 emamux はMELPA からインストールできます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T12:00:01.710",
"id": "24752",
"last_activity_date": "2016-05-11T13:13:38.663",
"last_edit_date": "2016-05-11T13:13:38.663",
"last_editor_user_id": "754",
"owner_user_id": "754",
"parent_id": "24677",
"post_type": "answer",
"score": 1
}
]
| 24677 | 24722 | 24722 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "画像1と画像2の2つ画像入力フォームがあり、それぞれ選択した画像をプレビュー表示するようにしたいのですが、画像選択すると画像1と画像2のどちらにも同じ画像がプレビュー表示されてしまいます。\n\n画像1(userfile1)と画像2(userfile2)、それぞれ選択した画像がプレビュー表示されるようにするには、どうすれば良いのでしょうか。教えていただけますか。\n\njQueryの部分\n\n```\n\n $(function() {\n $('input[type=file]').after('<span></span>');\n \n // アップロードするファイルを選択\n $('input[type=file]').change(function() {\n var file = $(this).prop('files')[0];\n \n // 画像以外は処理を停止\n if (! file.type.match('image.*')) {\n // クリア\n $(this).val('');\n $('span').html('');\n return;\n }\n \n // 画像表示\n var reader = new FileReader();\n reader.onload = function() {\n var img_src = $('<img>').attr('src', reader.result);\n $('span').html(img_src);\n }\n reader.readAsDataURL(file);\n });\n });\n \n```\n\nフォームの部分\n\n```\n\n <form enctype=\"multipart/form-data\" method=\"post\">\n <input type=\"file\" name=\"userfile1\" accept=\"image/*\">\n <input type=\"file\" name=\"userfile2\" accept=\"image/*\">\n </form>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T14:34:35.750",
"favorite_count": 0,
"id": "24678",
"last_activity_date": "2016-09-26T03:32:29.623",
"last_edit_date": "2016-05-09T17:27:17.063",
"last_editor_user_id": "15312",
"owner_user_id": "15312",
"post_type": "question",
"score": 1,
"tags": [
"jquery"
],
"title": "jQuery 画像アップロード画面で選択した画像をプレビュー表示させたい",
"view_count": 1632
} | [
{
"body": "以下のコードが、すべてのspan要素に対する処理となっているため問題が発生しています。\n\n```\n\n $('span').html(img_src);\n \n```\n\n提示されたコードにあまり手を加えない方向性で考えると、 \n選択されたinput要素の次にあるspan要素のみを表示対象にするとよいのではないでしょうか。\n\n```\n\n $(function() {\n $('input[type=file]').after('<span></span>');\n \n // アップロードするファイルを選択\n $('input[type=file]').change(function(e) {\n var file = $(this).prop('files')[0];\n \n // 画像以外は処理を停止\n if (! file.type.match('image.*')) {\n // クリア\n $(this).val('');\n $('span').html('');\n return;\n }\n \n // 画像表示\n var reader = new FileReader();\n reader.onload = function() {\n var img_src = $('<img>').attr('src', reader.result);\n $(e.target).next().html(img_src);\n }\n reader.readAsDataURL(file);\n });\n });\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T04:49:38.317",
"id": "24701",
"last_activity_date": "2016-05-10T04:49:38.317",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13314",
"parent_id": "24678",
"post_type": "answer",
"score": 1
}
]
| 24678 | null | 24701 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "html5で、テキストエリアに画像をペーストできる枠を作ることはできますか? \niPhoneのメモ帳には画像をペーストできますが、あのようなイメージです",
"comment_count": 4,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T15:22:21.650",
"favorite_count": 0,
"id": "24679",
"last_activity_date": "2016-05-09T15:22:21.650",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15427",
"post_type": "question",
"score": 3,
"tags": [
"javascript",
"html5"
],
"title": "html5で画像をペーストできるエリアを作りたい",
"view_count": 949
} | []
| 24679 | null | null |
{
"accepted_answer_id": "24694",
"answer_count": 2,
"body": "OCamlでコードを書くさいに、ユニットテストを書きたいため、[OUnit](http://ounit.forge.ocamlcore.org/)を利用しています。\n\nそのとき、`foobar.ml`と`foobar_test.ml`といったように、ファイルを分けているのですが、[ドキュメントを見る限り](http://ounit.forge.ocamlcore.org/api-\nounit/index.html)ですとユニットテストを実行する方法として:\n\n```\n\n ocamlfind ocamlc -o test -package oUnit -linkpkg -g foobar.ml foobar_test.ml\n \n```\n\nというのが紹介されているのですが、毎回これを実行するのは、コマンドとして長い印象があります。仕方無いので、`make.sh`みたいな、シェルスクリプトとして、上記のラインを書いて、そこから実行しています。ですが、これはバッドノウハウのように思えて、あまりすっきりとしません。\n\nOCamlを書くさいに、OUnitを実行するときの、良い方法があれば、教えていただけないでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T22:44:41.543",
"favorite_count": 0,
"id": "24683",
"last_activity_date": "2016-11-06T15:48:50.707",
"last_edit_date": "2016-11-06T15:48:50.707",
"last_editor_user_id": "754",
"owner_user_id": "939",
"post_type": "question",
"score": 2,
"tags": [
"ocaml"
],
"title": "OUnitをできるだけ簡単に実行するための方法",
"view_count": 485
} | [
{
"body": "# ocamlbuildを使う\n\nこの場合であれば、ワーキングディレクトリにて、`_tags`を作成して以下のように書き込みます。\n\n```\n\n true: debug, linkpkg, thread\n true: package(oUnit)\n \n```\n\nそして以下のコマンドでビルドできます。\n\n```\n\n ocamlbuild -use-ocamlfind \"foobar.native\" \"foobar_test.native\"\n \n```\n\n`<mlファイル名>.native`でocamloptによるバイナリへのビルド、 \n`<mlファイル名>.byte`でocamlcによるバイトコードへのビルドになります。\n\n`_tags`について簡単に触れておくと、カンマ区切りの左側が「後続のオプションを付ける条件」の記述で、常に適用したいオプションを`true`にします。ファイル名やディレクトリに応じたオプションの指定はここに記述します。右側にはオプションを設定します。両者の一覧は後述のマニュアルを参照して下さい。\n\nocamlbuildの詳細なマニュアルは[こちら](https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc)になります。_tagsでppxやsyntax\nextension、果ては最新のocamlで追加されたflambdaによる最適化も行う説明も載っています。\n\n正直これでも冗長だと思っていますが、公式に取り込まれたドキュメント(先程のマニュアル)によれば将来-use-\nocamlfindはデフォルトになるかもしれないものの、シェルのエイリアス等で対処しておくことをおすすめしているようです。\n\n# ここからは余談\n\n### mliの自動生成\n\n上記の設定でpackageを配置した上で、\n\n```\n\n ocamlbuild -use-ocamlfind \"foobar.inferred.mli\"\n \n```\n\nとすると`foobar.ml`のシグネチャを推論したmliが自動生成されます。勿論人間の手直しも必要ですが、mliを良いドキュメントとする土台として非常に便利なので憶えておいて損は無いと思われます。\n\n### プロジェクトの管理\n\nまた、ocamlbuildは簡単な設定ならば便利なのですが、これだけでプロジェクトを管理するのは大変です。ocamlbuildを細かく操作できるらしい`myocamlbuild.ml`は私も手書きしてません… \nもし今まとまった物を作っていらっしゃるのであれば、OASISをおすすめしておきます。 \n(ユニットテストという単語からそんな雰囲気がしたので) \nLwtを始めとした多くのプロジェクトで[実用されており](https://github.com/ocsigen/lwt/blob/master/_oasis)、見覚えのある感じの管理ができます。 \n[使い方はこちら](https://ocaml.org/learn/tutorials/setting_up_with_oasis.html)です。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T02:49:53.143",
"id": "24693",
"last_activity_date": "2016-05-28T12:40:58.667",
"last_edit_date": "2016-05-28T12:40:58.667",
"last_editor_user_id": "7179",
"owner_user_id": "7179",
"parent_id": "24683",
"post_type": "answer",
"score": 2
},
{
"body": "ユニットテストが必要なレベルのプログラムを書くのならばビルドツールを使ってください。`make` でも `ocamlbuild` でも `omake`\nでもなんでもいいです。\n\n私はテストとライブラリを別けるのは面倒なので全部一つにまとめています。つまり、 `foobar.ml` の中に `foobar_test.ml`\nの内容を書きます。テストが常にリンクされてしまうのが難点ですが、実行ファイルサイズに極端に制限のある埋め込み環境でもない限りハードディスクは安いですし気にすることは無いと思います。この場合、常にテストが走ってしまうのでは意味が無いので、\n\n```\n\n let () = Arg.parse [\"--test\", Arg.Unit (fun () -> OUnit2.run_test_tt_main test), \"run embed tests\"] (fun _ -> ...) \"myapp <options>\"\n \n```\n\nのようにして `--test` オプションをつけた場合にのみテストが走るようにしています。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T02:50:54.090",
"id": "24694",
"last_activity_date": "2016-05-10T02:50:54.090",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "898",
"parent_id": "24683",
"post_type": "answer",
"score": 2
}
]
| 24683 | 24694 | 24693 |
{
"accepted_answer_id": "24691",
"answer_count": 4,
"body": "OCamlでコードを書いているときに、リスト操作をすることがあるのですが、\n\n```\n\n 4 :: [1; 2; 3];;\n \n```\n\nみたいに、\nリストの先頭に対して要素を追加したリストを作成する方法はわかるのですが、リストの最後に対して追加したリストを作る方法がわかりません。とりあえずの方法として:\n\n```\n\n [1; 2; 3;] @ [4];;\n \n```\n\nという風にしているのですが、たかだか要素を後ろに追加するだけのために、リストを作っているのは、変な印象を受けます。\n\nもし直接、リストの最後に要素を追加する方法があれば教えていただければと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T22:50:33.687",
"favorite_count": 0,
"id": "24684",
"last_activity_date": "2016-05-10T04:58:07.763",
"last_edit_date": "2016-05-09T23:58:54.797",
"last_editor_user_id": "939",
"owner_user_id": "939",
"post_type": "question",
"score": 5,
"tags": [
"ocaml"
],
"title": "任意の要素をリストの最後に追加したリストを作成する方法",
"view_count": 1847
} | [
{
"body": "データ構造からするとなさそう。 \n<http://www.atmarkit.co.jp/fdotnet/special/introfs_01/introfs_01_03.html>\n\nF# のマニュアルにも新しく後ろに要素を追加するときは新しいリストを生成する例しか載ってませんでした。 \n<https://msdn.microsoft.com/ja-jp/library/dd233224.aspx>",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T23:38:22.823",
"id": "24685",
"last_activity_date": "2016-05-09T23:38:22.823",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "982",
"parent_id": "24684",
"post_type": "answer",
"score": 1
},
{
"body": "示唆されたところによると、OCamlにおいてリストは[単一連結リスト(?)](https://realworldocaml.org/v1/en/html/lists-\nand-\npatterns.html)という形になっているため、最後に要素を追加するときにはコストがかかり、非推奨であるようです。実際に[Ideon](https://ideone.com/gdq4Bp)で検証コードを書いて頂いたところ、パフォーマンスの違いが明確になっています。\n\n同様に、[海外のStackOverflow](https://ideone.com/gdq4Bp)でも[同様の示唆があります](http://www.joelonsoftware.com/articles/fog0000000319.html)。従って、リストの最後に要素を追加したい場合は、上の方法を取るしかなさそうです。",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-09T23:49:12.773",
"id": "24687",
"last_activity_date": "2016-05-09T23:49:12.773",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "939",
"parent_id": "24684",
"post_type": "answer",
"score": 2
},
{
"body": "Listのappend (`xs @ ys`) は`xs`の各要素を `::` で `ys` に追加していくので、`ys`の長さと関係なく、`xs`\nの長さに比例した時間がかかります。(なお `::` は引数に関係なく定数時間で処理が終了します。)\n\nですから、 `y :: xs` は `::` 一回の操作ですみますが、 `xs @ [y]` は `xs` の長さに比例した時間がかかります。これが `xs\n@ [y]` という式を書いてはいけないといわれる理由です。\n\nですが、\n\n```\n\n [1; 2; 3;] @ [4];;\n \n```\n\nというコードが単体である場合は、それ以外にリストの最後に要素を追加する合法(違法な方法があります。後述)な手はありませんから、それで構わないです。\n\n`xs @ [y]` は避けよと言われるのはライブラリ関数や再帰関数中などで、 `xs` の長さがいくらでも長くなる可能性がある場合です。たとえば:\n\n```\n\n let rec wrong_append xs ys = match ys with\n | [] -> xs\n | y::ys' -> wrong_append (xs@[y]) ys'\n \n```\n\nこのような関数は書いてはいけません。これは`xs`の長さをm、`ys`の長さをnとすると、m + m+1 + ... + m+n-1 回の `::`\nを呼び出すことになり、普通に `xs @ ys` を使った場合(m) と比べると非常に遅くなります。\n\n再帰関数中でリストを状態として持ちまわしつつ、その最後尾に要素を足したい場合は、そうせず、その状態を逆順のリストとして持つコードを書き `::`\nで先頭に付け足していきながら、最後に逆転させることが多いです:\n\n```\n\n (* リストの先頭 n 個の要素からなるリストを返す関数 take *)\n \n (* 補助関数 *)\n let rec take_aux n st xs =\n if n <= 0 then List.rev st\n else match xs with\n | [] -> List.rev st\n | x::xs -> take_aux (n-1) (x::st) xs\n \n let take n xs = take_aux n [] xs\n \n```\n\nこの例でだと `::` の呼び出し回数は 2n くらいになります。これは末尾再帰関数を書く事とも関係しているので是非理解しておきたいポイントです。\n\nなお、大昔のExtlibに破壊的にリストの最後尾に要素を追加する関数がありましたが今は無いようです。これはOCamlの内部値表現をいじる「違法な」方法で実現されていていて、当時(もしくは現在)のOCamlコンパイラの実装でたまたまうまく動くといったもので、全く推奨される方法ではありません。\n\n最後に、もしリストの先頭にも末尾にも要素を頻繁に付け加えたい場合はリストではなく別のデータ型を使うという選択も考えるべきです。たとえばキュー\n(`Queue.t`) などです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T02:35:54.687",
"id": "24691",
"last_activity_date": "2016-05-10T04:58:07.763",
"last_edit_date": "2016-05-10T04:58:07.763",
"last_editor_user_id": "898",
"owner_user_id": "898",
"parent_id": "24684",
"post_type": "answer",
"score": 6
},
{
"body": "**[ocaml-3.12.1-print/pervasives.ml](https://github.com/diml/ocaml-3.12.1-print/blob/master/stdlib/pervasives.ml#L202)**\n\n```\n\n let rec (@) l1 l2 =\n match l1 with\n [] -> l2\n | hd :: tl -> hd :: (tl @ l2)\n \n```\n\nと定義されているので、これを少し変更して `@@` として定義してみます。\n\n```\n\n let rec (@@) l1 l2 =\n match l1 with\n [] -> [l2] (* return list *)\n | hd :: tl -> hd :: (tl @@ l2);;\n \n \n # [1;2;3;] @@ 4;;\n - : int list = [1; 2; 3; 4]\n \n```\n\nまぁ、この様なやり方が OCaml らしいのかどうかは分かりませんが…",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T02:37:22.927",
"id": "24692",
"last_activity_date": "2016-05-10T02:37:22.927",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24684",
"post_type": "answer",
"score": 0
}
]
| 24684 | 24691 | 24691 |
{
"accepted_answer_id": "24723",
"answer_count": 2,
"body": "タイトルのようにしたいのですがうまくいきません。\n\n環境はubuntu 16.04 LTSです。\n\nwget <https://www.openssl.org/source/openssl-1.0.2h.tar.gz> \nその場で解凍、OpenSSLのディレクトリを開く \n./config --prefix=/usr/i686-w64-mingw32 \nmake \nmake test \nsudo make install\n\nこのサイトのサンプルコードを使って \n<http://a4dosanddos.hatenablog.com/entry/2015/03/01/191730>\n\ni686-w64-mingw32-gcc-win32 tes.c \nすると下のエラーが出ます。\n\n```\n\n /tmp/ccozGj6U.o:tes.c:(.text+0x24): `MD5_Init' に対する定義されていない参照です\n /tmp/ccozGj6U.o:tes.c:(.text+0x77): `MD5_Update' に対する定義されていない参照です\n /tmp/ccozGj6U.o:tes.c:(.text+0xb4): `MD5_Final' に対する定義されていない参照です\n collect2: error: ld returned 1 exit status\n \n```\n\nどうすればいいと思いますか?\n\n追記:\n\n```\n\n making depend in crypto...\n make[1]: ディレクトリ '/home/[username]/openssl-1.0.2h/crypto' に入ります\n ../util/domd: 31: ../util/domd: makedepend: not found\n mv: cannot stat 'Makefile.new': No such file or directory\n Makefile:136: ターゲット 'local_depend' のレシピで失敗しました\n make[1]: *** [local_depend] エラー 127\n make[1]: ディレクトリ '/home/[username]/openssl-1.0.2h/crypto' から出ます\n Makefile:471: ターゲット 'depend' のレシピで失敗しました\n make: *** [depend] エラー 1\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T00:39:54.023",
"favorite_count": 0,
"id": "24688",
"last_activity_date": "2016-05-10T22:37:09.737",
"last_edit_date": "2016-05-10T20:03:51.870",
"last_editor_user_id": "13313",
"owner_user_id": "13313",
"post_type": "question",
"score": 1,
"tags": [
"openssl"
],
"title": "Linuxのi686-w64-mingw32向けにOpenSSLライブラリを使った開発環境を構築する方法",
"view_count": 1006
} | [
{
"body": "コンパイルのオプションに「-lcrypto」が必要ではないでしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T08:52:44.103",
"id": "24712",
"last_activity_date": "2016-05-10T08:52:44.103",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15316",
"parent_id": "24688",
"post_type": "answer",
"score": 1
},
{
"body": "こちらの環境も `Ubuntu 16.04` ですが、以下の様にして `libcrypto` を作成しました。\n\n```\n\n $ CC=/usr/bin/i686-w64-mingw32-gcc-win32 \\\n perl Configure mingw no-shared no-asm --prefix=/usr/i686-w64-mingw32\n $ make depend\n $ make\n $ sudo make install\n \n```\n\n`Configure` を実行する際に環境変数 `CC` を設定して、オプションに `no-asm` を指定する必要があります。\n\nインストール後、サンプルプログラムをコンパイルして Windows 環境で実行してみました。\n\n```\n\n $ i686-w64-mingw32-gcc-win32 tes.c -lcrypto -o tes.exe\n \n ## 実行形式ファイルを Windows 環境へコピーして実行\n C:\\> tes\n md5 digest: ea703e7aa1efda0064eaa507d9e8ab7e\n \n```\n\n**追記**\n\n>\n```\n\n> making depend in crypto...\n> make[1]: ディレクトリ '/home/[username]/openssl-1.0.2h/crypto' に入ります\n> ../util/domd: 31: ../util/domd: makedepend: not found\n> \n```\n\n`makedepend` コマンドがインストールされていませんので、`xutils-dev` パッケージをインストールして下さい。\n\n```\n\n $ sudo apt-get install xutils-dev\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T16:05:39.947",
"id": "24723",
"last_activity_date": "2016-05-10T22:37:09.737",
"last_edit_date": "2016-05-10T22:37:09.737",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24688",
"post_type": "answer",
"score": 1
}
]
| 24688 | 24723 | 24712 |
{
"accepted_answer_id": "24721",
"answer_count": 1,
"body": "RealmSwiftをつかってToDoアプリを作ろうと思っています\n\nその際、並べ替えもできるようにしたいのですが、その際に配列を使ったほうが楽だろうという考えに達しました。 \nというわけで以下のような構造を考えてみました\n\n```\n\n //上のリストではTableに配置する際の順番を、下のObjectではそのタスクの詳細情報を管理する\n \n //タスク名を格納する配列\n var list = [\"hoge\",\"fuga\",\"miso\"]\n \n //realmに格納するObject\n class Task: Object{\n dynamic var name: String!\n \n //タスクの詳細\n }\n \n```\n\nしかし、確か(なのですが)RealmSwiftではObject型を継承していない普通の配列を保存することができなかったはずで........\n\nここだけUserDefaultsを使うべきかと迷っています。 \nRealmSwiftで配列を保存できる簡単な方法というのはあるのでしょうか? \nよろしくお願いいたします",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T01:55:10.867",
"favorite_count": 0,
"id": "24689",
"last_activity_date": "2016-05-10T13:50:41.767",
"last_edit_date": "2016-05-10T13:50:41.767",
"last_editor_user_id": "5519",
"owner_user_id": "15418",
"post_type": "question",
"score": 1,
"tags": [
"swift2",
"realm",
"xcode7"
],
"title": "RealmSwiftで配列を保存する方法",
"view_count": 3162
} | [
{
"body": "いろいろやり方はありますが、おっしゃられていることはTaskの順番を記憶したいということですので、大きく2つの方法があります。\n\nまずはオーソドックスに順番を表すプロパティをTaskに持つことです。 \nこの方法はRealmに限らず他のデータベースでもよく使われる基本的なモデリングの考え方になります。\n\nもう一つは、Realmの場合は順番を保持する方法として`List`が使えるので、「タスク名」ではなくタスクそのものを`List`で管理してしまうという方法です。 \nこの方法のメリットは扱いが簡単になることと、先の方法と違って、ソートしなくても良いという点です。\n\n例えば次のような`TaskList`というクラスをもう一つ作ります。\n\n```\n\n class TaskList: Object {\n let list = List<Task>()\n }\n \n```\n\nそして、下記のようにして利用します。\n\n```\n\n let task = Task()\n task.name = \"...\"\n \n let taskList = TaskList()\n taskList.list.append(task)\n \n```\n\n`list`は順番が保持されていますので、これをそのまま利用すればいいです。\n\nなお、順番を保存するためだけに`NSUserDefaults`を使う、という案は、ややこしくなるだけでメリットはほぼないと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T13:49:29.137",
"id": "24721",
"last_activity_date": "2016-05-10T13:49:29.137",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "24689",
"post_type": "answer",
"score": 2
}
]
| 24689 | 24721 | 24721 |
{
"accepted_answer_id": "29800",
"answer_count": 1,
"body": "GitHub初心者の質問です.\n\n結構著名な組織がGitHubに公開しているツールがあります.antのbuild.xmlとそれから起動される数種類のターゲットに対応するXSLTスタイルシート、および共通のスタイルシートで構成されています. \nこのツールは(たぶん)2つの目的があり、1つにはXSLTスタイルシートによりメインの変換を行うこと、2つにはそのメインの変換が終わった後、その結果を利用して派生するであろう無数のサブの変換を行うことです.1つ目の変換結果はすでに確定しています.\n\n私はこのリポジトリをfork⇒cloneして上記の2つ目の用途をローカルで試してみました.なのですが、\n\n① そもそもbuild.xmlからして間違いがある. \n② メインの変換は(結果が公開されて仕様になっているので)大丈夫だったのでしょうけれどもサブの変換はまともな結果を出してくれない.\n\nという残念な結果になっています.仕事上どうしてもこのツールを使用する必要性があるため、ローカルで修正してテストしていますが、見てゆくとターゲット別のXSLTスタイルシートの側にも単純なコーディングミスやバグ、そして期待した結果を得ることができないコードが見つかりました.\n\nissueを出しているのですが、メンテナーの方も忙しいらしく、そのやりとりだけでは埒が空きません.そこでPull\nRequestを出そうと考えたのですが、上記のように様々なレベルで修正しなければならない箇所があり、どのようにPull\nRequestを出したら良いのかがわかりません.\n\nまずPull Requestを出すためのブランチを作る手順は「GitHub実践入門」(WEB+DB PRESS plus\n技術評論社)を読んで理解できたつもりです.しかし上記のように修正点が多岐にわたる場合、は具体的にはどのような手順でブランチを作り、Pull\nRequestを出して行ったら良いのでしょうか?\n\nたぶんスタイルシート以前のbuild.xmlの間違いから直してゆくようPull\nRequestを出す必要があると思うのですが、それ以降のスタイルシートの様々な箇所にわたる修正は、段階的にでないと解決できないように思えます.このような場合、順を追って1つづPull\nRequestが取り込まれるのを待ちながら出してゆくべきなのでしょうか?またブランチはPull Requestに一対一対応させないとダメなのでしょうか?\n\n以上 お手数ですが回答の程よろしくお願いします.",
"comment_count": 4,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T03:11:00.183",
"favorite_count": 0,
"id": "24696",
"last_activity_date": "2016-10-22T12:33:57.737",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9503",
"post_type": "question",
"score": 3,
"tags": [
"git",
"github"
],
"title": "Pull Requestの出し方について",
"view_count": 266
} | [
{
"body": "(コメントの内容をまとめています)\n\nメンテナーにマージしてもらいたい修正の内容を伝えて、メンテナーにどうマージ(PR) して行ったら良いかを聞く。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-10-22T12:33:57.737",
"id": "29800",
"last_activity_date": "2016-10-22T12:33:57.737",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "24696",
"post_type": "answer",
"score": 3
}
]
| 24696 | 29800 | 29800 |
{
"accepted_answer_id": "24698",
"answer_count": 2,
"body": "ヘタすると小学生レベルの計算なのかもしれないのですが、 \n例えば `128x80` の画像があったとして、 \nこれが丁度縦横端数なく縮小できるパーセンテージを求める公式のようなモノはありますでしょうか?\n\nGoogle Sheetsで下記のように一覧を出して求めてもさして時間はかからなかったのですが、よい方法があれば知りたいです。 \n[](https://i.stack.imgur.com/a9ANZ.png)\n\n## 追記:本当にやりたいこと\n\n比率を保ったまま縮小をしたいです。 \nツールとしてはMac標準搭載のPreview.appを想定しています。 \n下記画像からもわかる通り、パーセンテージを入力するツールではなくヨコ:タテどちらかの数値を入れると、勝手にもう片方の数値を計算してくれていますが、このときもう片方の(自動計算された)数値に端数が出ない方法を探しています。(できるだけ多く候補を出したいです。)\n\n[](https://i.stack.imgur.com/hPfZ1.png)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T03:30:33.040",
"favorite_count": 0,
"id": "24697",
"last_activity_date": "2016-05-10T04:18:57.150",
"last_edit_date": "2016-05-10T04:18:57.150",
"last_editor_user_id": "9008",
"owner_user_id": "9008",
"post_type": "question",
"score": 4,
"tags": [
"アルゴリズム"
],
"title": "画像を比率を保ったまま端数なく縮小するパーセンテージの求め方",
"view_count": 317
} | [
{
"body": "小学校の算数で習う[最大公約数](https://ja.wikipedia.org/wiki/%E6%9C%80%E5%A4%A7%E5%85%AC%E7%B4%84%E6%95%B0)でしょうか?\n\n`128`と`80`の最大公約数は`16`なのであとは`128x80`を最大公約数で割った`8x5`の任意倍数ということでしょうか。",
"comment_count": 4,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T03:59:49.137",
"id": "24698",
"last_activity_date": "2016-05-10T04:18:18.313",
"last_edit_date": "2016-05-10T04:18:18.313",
"last_editor_user_id": "4236",
"owner_user_id": "4236",
"parent_id": "24697",
"post_type": "answer",
"score": 4
},
{
"body": "128と80の公約数は、1を除けば [2, 4, 8, 16] です。 \nこれらの公約数の逆数の倍数が、端数の生じない縮小倍率のリストにならないでしょうか?\n\n2: 1/2 \n4: 1/4, 2/4, 3/4 \n8: 1/8, 2/8, ... 7/8 \n16: 1/16, 2/16, ... 15/16",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T04:16:11.880",
"id": "24699",
"last_activity_date": "2016-05-10T04:16:11.880",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8078",
"parent_id": "24697",
"post_type": "answer",
"score": 3
}
]
| 24697 | 24698 | 24698 |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "例えば、次のようなファイルがあったとします。\n\n```\n\n 0, foo\n 0, bar\n 0, hoge\n 0, fuga\n \n```\n\nこの最初の数字(この場合なら0)について、代わりに昇順の数字を割りあてたいと思っています。具体的に言うならば、次のようなテキストにしたいと思っています:\n\n```\n\n 1, foo\n 2, bar\n 3, hoge\n 4, fuga\n \n```\n\nさすがに手作業でちまちま編集するのは、どうも非効率に感じます。もしいい方法がありましたら、教えてください。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T05:16:45.290",
"favorite_count": 0,
"id": "24703",
"last_activity_date": "2016-05-14T12:53:13.317",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "939",
"post_type": "question",
"score": 3,
"tags": [
"vim"
],
"title": "同じ数字を置換するさいに、数字を昇順に割りあてる方法",
"view_count": 1206
} | [
{
"body": "Vim 7.4.765 以降であれば、対象をビジュアルモードで選択して `g<C-a>` をすると連番が生成されます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T05:37:37.793",
"id": "24704",
"last_activity_date": "2016-05-10T05:37:37.793",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2541",
"parent_id": "24703",
"post_type": "answer",
"score": 7
},
{
"body": "少し煩雑になってしまいましたが、マクロ版です。\n\n```\n\n <CTRL-A>:%s/^0//\n ggqqyw+P<CTRL-A>0q2@q\n \n```\n\n * `<CTRL-A>`\n * 一行目の 0 に Add します\n * 10 飛びにしたい場合は `10<CTRL-A>`\n * `:%s/^0//`\n * それ以外の行頭 0 を消します\n * `ggqqyw+P<CTRL-A>0q`\n * 文の頭に戻り (`gg`) レジスタ q にレコーディングを開始 (`qq`)\n * 単語をヤンクし (`yw`) 次の行の行頭に移動し (`+`) カーソル位置の左にペースト (`P`)\n * カーソル位置の数字 (ペーストされた前行の数字) に Add (`<C-A>`)\n * 行頭に戻る (`0`)\n * レコーディングを終了 (`q`)\n * `2@q`\n * 繰り返す回数を指定し `@q` でレジスタ q 内のマクロを実行します",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T06:47:13.710",
"id": "24708",
"last_activity_date": "2016-05-10T06:47:13.710",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15437",
"parent_id": "24703",
"post_type": "answer",
"score": 0
},
{
"body": "一応、他の方法も書いておきますね。\n\n数字==行番号で良い場合:\n\n```\n\n :%s/^\\d\\+/\\=line(\".\")\n \n```\n\n \nビジュアルモードで選択した範囲内の行頭数字を1から振り直す場合: \n(`Shift`+`v`後に複数行選択して`:`を押せば`:'<,'>`が自動で入力されます)\n\n```\n\n :'<,'>s/^\\d\\+/\\=line(\".\")-line(\"'<\")+1\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T11:42:46.527",
"id": "24855",
"last_activity_date": "2016-05-14T12:53:13.317",
"last_edit_date": "2016-05-14T12:53:13.317",
"last_editor_user_id": "2687",
"owner_user_id": "2687",
"parent_id": "24703",
"post_type": "answer",
"score": 3
}
]
| 24703 | null | 24704 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "[](https://i.stack.imgur.com/KQ5I4.gif)\n\n例に示しているのはamazonのアプリですがこれと同じようにコードでセルを少しスライドさせて \n元に戻すアニメーションを実現したいです。 \nUIScrollViewであればcontentOffsetを変更すればオフセット量をコントロールできますが、 \nUITableviewCellの左右のスワイプ動作をアニメーションで表示するにはどうしたらよいでしょうか?\n\nサンプルのアニメーションではswiftの本を表示させていますが、できればobjective-cでお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T07:48:46.423",
"favorite_count": 0,
"id": "24709",
"last_activity_date": "2016-05-10T16:45:28.483",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5549",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"objective-c",
"iphone"
],
"title": "UITableviewを開いた時にセルをピョコッと横方向に移動させるアニメーションを実現したい",
"view_count": 504
} | [
{
"body": "カスタムセルにUIScrollViewがのっているだけです。スワイプではなくパン(ドラッグ)です。\n\nもし、カスタムセルの作成や制御の知識がまるでないのならそれを学ぶ必要がありますし、それが備わっているならUIScrollViewが使用されていると分かるだけで十分でしょう。右方向へのスクロール時に表示される関連項目が随時追加されるのをみると、ページングではなくデリゲートを介して半端なオフセットに対し手動で表示状態を修正したり、コンテンツの横幅を変更していると思われます。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T16:45:28.483",
"id": "24724",
"last_activity_date": "2016-05-10T16:45:28.483",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15444",
"parent_id": "24709",
"post_type": "answer",
"score": 2
}
]
| 24709 | null | 24724 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "```\n\n <p>\n <image src=\"hoge.png\" width=\"50%\">\n </p>\n \n```\n\nとしたところ、hoge.pngの画像サイズに対して50%ではなく \n親要素(pタグ)の大きさに対して50%になってしまいました。\n\n画像の大きさを50%にする方法はあるのでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T09:12:32.323",
"favorite_count": 0,
"id": "24714",
"last_activity_date": "2016-11-02T14:39:11.010",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9008",
"post_type": "question",
"score": 3,
"tags": [
"html"
],
"title": "imageタグで画像のサイズを実際の画像サイズからパーセントで計算させる方法は?",
"view_count": 15911
} | [
{
"body": "サイズを指定せず`img`要素にCSSで`zoom:0.5`ではどうでしょうか?\n\n```\n\n <p>\n <image src=\"hoge.png\" style=\"zoom:0.5;\">\n </p>\n \n```\n\nもしくは`javascript`を使って画像のサイズを取得してサイズを固定するかですかね",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T09:18:36.573",
"id": "24715",
"last_activity_date": "2016-05-10T09:18:36.573",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24714",
"post_type": "answer",
"score": 1
},
{
"body": "javascript で\n\n```\n\n <img src=\"hoge.png\" onload=\"this.width = this.width*0.5\" />\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T10:04:28.177",
"id": "24716",
"last_activity_date": "2016-05-10T10:29:12.380",
"last_edit_date": "2016-05-10T10:29:12.380",
"last_editor_user_id": "5044",
"owner_user_id": "5044",
"parent_id": "24714",
"post_type": "answer",
"score": 1
}
]
| 24714 | null | 24715 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "[`PreferenceFragment`](http://developer.android.com/intl/ja/reference/android/preference/PreferenceFragment.html)は設定画面を手軽に作れて便利なのですが、デフォルトの`SharedPreferences`を利用する前提となっておりアプリ内でグローバルな設定値しか編集できません。\n\n[名前指定による任意の`SharedPreferences`](http://developer.android.com/intl/ja/reference/android/content/Context.html#getSharedPreferences%28java.lang.String,%20int%29)を、`PreferenceFragment`画面に紐付けることはできないでしょうか?もともとの目的としては、App\nWidgetsインスタンス別設定画面を手軽に実装したいという要望です。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-10T10:59:43.190",
"favorite_count": 0,
"id": "24718",
"last_activity_date": "2016-07-08T11:01:32.070",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "49",
"post_type": "question",
"score": 0,
"tags": [
"android"
],
"title": "PreferenceFragmentで任意のSharedPreferencesを使いたい",
"view_count": 965
} | [
{
"body": "[getPreferenceManager()](http://developer.android.com/reference/android/preference/PreferenceFragment.html#getPreferenceManager%28%29).[setSharedPreferencesName(name)](http://developer.android.com/reference/android/preference/PreferenceManager.html#setSharedPreferencesName%28java.lang.String%29)ですかね。\n\n## コメントに対する追記\n\n「PreferenceFragmentが依存するgetDefaultSharedPreferences」というのは、[PreferenceManager#getDefaultSharedPreferences](http://developer.android.com/reference/android/preference/PreferenceManager.html#getDefaultSharedPreferences%28android.content.Context%29)の事でしょうか?\n\nPreferenceManager#setSharedPreferencesNameで名前を設定したら、PreferenceManager#getDefaultSharedPreferencesを使用せず、PreferenceManager#getSharedPreferencesか、Context#getSharedPreferencesで設定した名前を指定して使用してください。\n\nPreferenceManager#getDefaultSharedPreferencesが返すSharedPreferencesの名前は、ソースコードを見る限り、「パッケージ名+_prefereces」でハードコーディングされているので、変えられそうにないですよ。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T12:43:47.313",
"id": "24799",
"last_activity_date": "2016-05-12T16:53:30.207",
"last_edit_date": "2016-05-12T16:53:30.207",
"last_editor_user_id": "15473",
"owner_user_id": "15473",
"parent_id": "24718",
"post_type": "answer",
"score": 0
},
{
"body": "PreferenceFragmentのonCreateで`addPreferencesFromResource(R.xml.preferences)`を呼び出す前に、`getPreferenceManager().setSharedPreferencesName(任意の名前)`とすることで、使用するSharedPreferencesの名前を指定することができます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-07-08T11:01:32.070",
"id": "27458",
"last_activity_date": "2016-07-08T11:01:32.070",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9498",
"parent_id": "24718",
"post_type": "answer",
"score": 1
}
]
| 24718 | null | 27458 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "タイトルの通りですが、 \nSwiftでピンクノイズとホワイトノイズを作成する方法はありますか? \nまた、作成した音声をiOSで再生できるでしょうか",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T00:07:32.547",
"favorite_count": 0,
"id": "24729",
"last_activity_date": "2016-05-11T07:23:34.203",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13404",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"swift2"
],
"title": "Swiftでピンクノイズ、ホワイトノイズを作成し再生したい。",
"view_count": 202
} | [
{
"body": "> Swiftでピンクノイズとホワイトノイズを作成する方法はありますか?\n\nAppleフレームワーク内に簡単に生成できるものはなかったと思うので、 \n自作すれば可能だと思います。\n\n> また、作成した音声をiOSで再生できるでしょうか\n\nできます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T07:23:34.203",
"id": "24749",
"last_activity_date": "2016-05-11T07:23:34.203",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8601",
"parent_id": "24729",
"post_type": "answer",
"score": 1
}
]
| 24729 | null | 24749 |
{
"accepted_answer_id": "24804",
"answer_count": 1,
"body": "こんにちは\n\n現在私はページを遷移した先でNSTimerを起動するといったことをしているのですが、タイマーの作動中にnavigationBarから戻るとタイマーが作動したままになってしまうのです。 \nそれとは別に設置したボタンなら、unwindSegueに対してprepareで処理できるのですが、このボタンの場合そのようなprepare処理は出来ないのでしょうか?\n\nよろしくお願いいたします",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T00:49:23.827",
"favorite_count": 0,
"id": "24730",
"last_activity_date": "2016-05-12T16:53:48.137",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15418",
"post_type": "question",
"score": 0,
"tags": [
"swift2",
"xcode7"
],
"title": "navigationBarのbackButtonで戻った時にアクションを起こす方法",
"view_count": 115
} | [
{
"body": "> navigationBarのbackButtonで戻った時にアクションを起こす方法\n\nという質問の答えであれば、 \n[ViewControllerで戻るボタンのタップを検知する](http://qiita.com/yimajo/items/d9409d83fecf9875061d)の記事にある方法を試してみてはどうでしょうか。\n\n記事はObjective-CなのでSwiftで一番ラクな方法を書くと下記のようになるかと思います。\n\n```\n\n override func viewDidDisappear(animated: Bool) {\n super.viewDidDisappear(animated)\n if isMovingFromParentViewController() {\n // [戻る]ボタンを押された事がわかるのでここにTimerを止める処理\n }\n }\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T16:53:48.137",
"id": "24804",
"last_activity_date": "2016-05-12T16:53:48.137",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7374",
"parent_id": "24730",
"post_type": "answer",
"score": 1
}
]
| 24730 | 24804 | 24804 |
{
"accepted_answer_id": "24739",
"answer_count": 1,
"body": "python初心者です。 \nデコレーターがどういうものなのか、どういった時に必要となるのかが理解できません。 \n例とともに教えていただけたら幸いです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T02:00:29.807",
"favorite_count": 0,
"id": "24732",
"last_activity_date": "2016-05-11T04:53:17.040",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10111",
"post_type": "question",
"score": 3,
"tags": [
"python"
],
"title": "pythonでのデコレーターに関して",
"view_count": 358
} | [
{
"body": "例えば標準ライブラリに functools.lru_cache というデコレータがあります。\n\nこのデコレータは、たとえば自分で作成した関数が実行にある程度長い時間がかかる(1秒程度)けれども、関数の引数に対して返値がずっと変わらない、あるいは一定期間変わらない場合に使用します。\n\n```\n\n def get_first_image(url):\n \"\"\"与えられたURLのページを開いて、HTML内からリンクされている一番大きな画像データを返す\"\"\"\n # ここに実装\n return image_data\n \n```\n\nこんな関数を実装した場合実行に2,3秒くらいかかるかもしれません。もしこの関数に同じURLを何度も指定する可能性があるなら、URLに対する結果をキャッシュしておけば2回目以降の実行は速く返せるはずです。\n\nそこで、以下のように書きます。\n\n```\n\n from functools import lru_cache\n \n @lru_cache()\n def get_first_image(url):\n \"\"\"与えられたURLのページを開いて、HTML内からリンクされている一番大きな画像データを返す\"\"\"\n # ここに実装\n return image_data\n \n```\n\nこれでキャッシュされるようになりました。\n\ndecoratorを使えば関数の呼び出しに対して処理を付加できます。今回の例では、get_first_imageという関数にキャッシュ機能を付加しました。デコレータは、対象関数の呼び出しに対する結果を変えないのが原則です。デコレータを使えば関数の返値を書き換えたりもできてしまいますが、利用者はそのようは副作用があると混乱するので、やらないほうがよいでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T04:53:17.040",
"id": "24739",
"last_activity_date": "2016-05-11T04:53:17.040",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "806",
"parent_id": "24732",
"post_type": "answer",
"score": 8
}
]
| 24732 | 24739 | 24739 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "ruby on\nrailsを使って現在ダウンロード機能を実装しています。構想では、フォルダごとダウンロードできるようにしたいと考えていますが、このようなことは可能でしょうか? \n参考webサイトを探してもなく、自分で、フォルダを指定して実行してみてもできなかったので教えていただきたいです。 \nよろしくお願いします。",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T02:25:03.680",
"favorite_count": 0,
"id": "24733",
"last_activity_date": "2016-05-11T02:25:03.680",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13491",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails"
],
"title": "railsでフォルダごとダウンロードできる機能を実装したい",
"view_count": 351
} | []
| 24733 | null | null |
{
"accepted_answer_id": "24750",
"answer_count": 1,
"body": "iOSのキーボードのような機能を実装するため、animateWithDurationを用いて \n特定の操作後にUIViewを画面外から画面内にスライド表示させ、 \nそのUIViewに対し何かしらの操作できるよう実装しましたが、 \nそのUIView上のUILabelのテキストを変更したり、 \nその他のUIViewにSubViewを追加したりしたタイミングで、 \n画面内に表示させたUIViewが(アニメーションもなく瞬時に)画面外に戻り、 \n最初に画面内の該当箇所にあったUIViewが表示されてしまいます。\n\n操作をしてもUIViewが画面外に戻らなくしたいのですが、原因が全くわからず手がつけられません。 \nどなたかご教示いただけますでしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T02:51:57.403",
"favorite_count": 0,
"id": "24734",
"last_activity_date": "2016-05-11T07:45:29.327",
"last_edit_date": "2016-05-11T04:50:06.570",
"last_editor_user_id": "15449",
"owner_user_id": "15449",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"objective-c"
],
"title": "iOSで画面外から画面内にアニメーションでUIViewをスライドさせた後、その配下の要素の設定変更をするとUIViewが画面外に戻ってしまう",
"view_count": 807
} | [
{
"body": "animateWithDurationで座標値によるアニメーションを行うUIViewに対して、AutoLayoutで制約を指定していて、アニメーション後もその制約がそのままになっているため制約に従って位置が変わっているのではないでしょうか?もしそうであれば、アニメーション後に制約を変更してみてはどうでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T07:45:29.327",
"id": "24750",
"last_activity_date": "2016-05-11T07:45:29.327",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7374",
"parent_id": "24734",
"post_type": "answer",
"score": 0
}
]
| 24734 | 24750 | 24750 |
{
"accepted_answer_id": "24737",
"answer_count": 1,
"body": "ImageViewのsetImageResourceメソッドをつかってpopupwindowから画像を変更したいのですが、上手くいきません。 \nどうすればいいのでしょうか。\n\n```\n\n final PopupWindow mPopupWindow=new PopupWindow(Books_new.this);\n final View popupView=getLayoutInflater().inflate(R.layout.popup_icon, null);\n \n //ポップアップウィンドウでアイコン変更\n \n popupView.findViewById(R.id.btn_red).setOnClickListener(new View.OnClickListener(){\n @Override\n public void onClick(View v){\n ChangeToBlue(v);\n }\n });\n \n popupView.findViewById(R.id.btn_pink).setOnClickListener(new View.OnClickListener(){\n @Override\n public void onClick(View v){\n ChangeToRed(v);\n }\n });\n \n public static void ChangeToRed(View v){\n ImageView iIcon=(ImageView)v.findViewById(R.id.view_books_icon);\n iIcon.setImageResource(R.drawable.red_project);\n }\n public static void ChangeToBlue(View v){\n ImageView iIcon=(ImageView)v.findViewById(R.id.view_books_icon);\n iIcon.setImageResource(R.drawable.blue_project);\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T03:08:55.307",
"favorite_count": 0,
"id": "24735",
"last_activity_date": "2016-05-11T04:42:59.573",
"last_edit_date": "2016-05-11T04:26:07.763",
"last_editor_user_id": "3068",
"owner_user_id": "15279",
"post_type": "question",
"score": 0,
"tags": [
"android"
],
"title": "Android ImageViewの画像の変更",
"view_count": 2230
} | [
{
"body": "```\n\n public static void ChangeToBlue(View v){\n ImageView iIcon=(ImageView)v.findViewById(R.id.view_books_icon);\n iIcon.setImageResource(R.drawable.blue_project);\n }\n \n```\n\nこの`v.findViewById()`は、引数の`View`、`R.id.btn_red`の`id`を持つ`View`の子要素に対して検索を行っています。ですので、`null`が返ってくると思います。\n\nメソッドの`static`を外して、以下のように`Activity`または`Fragment`の`View`全体に対して検索するように修正してみてください。もしこのメソッドが`Activity`や`Fragment`以外で実装されている場合は、それぞれが管理する`View`のルートの参照を取得できるようにしておく必要があります。\n\n```\n\n public void ChangeToRed(View v){\n ImageView iIcon=(ImageView)findViewById(R.id.view_books_icon);\n // Fragmentの場合は、\n // ImageView iIcon=(ImageView)getView().findViewById(R.id.view_books_icon);\n iIcon.setImageResource(R.drawable.red_project);\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T04:42:59.573",
"id": "24737",
"last_activity_date": "2016-05-11T04:42:59.573",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5337",
"parent_id": "24735",
"post_type": "answer",
"score": 0
}
]
| 24735 | 24737 | 24737 |
{
"accepted_answer_id": "24823",
"answer_count": 1,
"body": "RealmSwiftを使ってToDoみたいなものを作ろうとしているのですが、ちょうど良いサンプルが見つかったのでさっそくダウンロードしてビルドしてみました。\n\n<https://github.com/hossamghareeb/realmtasks>\n\nしかし、そのままビルドすると以下のようなエラーが出て止まってしまいます \n[](https://i.stack.imgur.com/dt7Ry.png) \nどのようにしたらビルドできるようになるでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T04:16:32.327",
"favorite_count": 0,
"id": "24736",
"last_activity_date": "2016-05-13T10:13:29.317",
"last_edit_date": "2016-05-11T05:08:48.430",
"last_editor_user_id": "5519",
"owner_user_id": "15418",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"xcode",
"realm"
],
"title": "GitHubのオープンソースプロジェクトがビルドできません",
"view_count": 534
} | [
{
"body": "ずいぶん古いプロジェクトなので最新版のXcode 7.3ではそのままではコンパイルできません。 \nSwiftの仕様が変わっているためです。\n\nビルドする方法は2つあります。 \nまず古いXcodeを使う方法です。 \nこちら <https://developer.apple.com/downloads/>\nから過去のバージョンのXcodeがダウンロードできますので、7.0.1をダウンロードしてください。 \n7.0.1でしたらそのままビルドして実行できます。\n\nもう一つは最新版のXcodeでもビルドできるようにコードを修正することです。 \nサンプルコードとして参考にするということなので、最終的にはこちらの方法がいいでしょう。\n\nまずは、`pod update`を実行して、依存ライブラリを最新にアップデートします。 \n(依存ライブラリが古くてビルドエラーが起きているため) \nこれでRealmのバージョンが0.95から0.102になります。\n\nそして、Swift 2で変更になったエラー処理のコードなどをSwift 2でビルドできるように修正します。 \nこのプロジェクトの場合は`Realm.write()`メソッドの部分に`try!`を付けるだけでビルドできるようになります。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T10:13:29.317",
"id": "24823",
"last_activity_date": "2016-05-13T10:13:29.317",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "24736",
"post_type": "answer",
"score": 1
}
]
| 24736 | 24823 | 24823 |
{
"accepted_answer_id": "24748",
"answer_count": 3,
"body": "回帰結果`result`を`result8`という名前で保存しあとから呼び出したいのですが \nうまくいきません。\n\n```\n\n save(result, file=\"result8.dat\")・・・result8で保存\n load(\"result8.dat\")・・・呼び出し\n summary(result8)・・・回帰結果を表示\n \n```\n\n以下にエラー `summary(result8) : オブジェクト 'result8' がありません` \nと言われてしまいます。\n\n同じファイル名ならうまくいきます。\n\n```\n\n save(result, file=\"result.dat\") ・・・保存し\n rm(result) ・・・削除\n summary(result) ・・・削除を確認\n load(\"result.dat\") ・・・呼び出し\n summary(result)・・・回帰結果を表示\n \n```\n\nどのような問題があるのでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T05:34:16.730",
"favorite_count": 0,
"id": "24741",
"last_activity_date": "2016-05-11T06:49:00.777",
"last_edit_date": "2016-05-11T06:01:19.640",
"last_editor_user_id": "12457",
"owner_user_id": "15333",
"post_type": "question",
"score": 1,
"tags": [
"r"
],
"title": "回帰結果に変数名をつけて保存し呼び出す",
"view_count": 246
} | [
{
"body": "```\n\n save(result, file=\"result8.dat\")\n \n```\n\nではなく\n\n```\n\n save(result8, file=\"result8.dat\")\n \n```\n\nではうまく行きませんか?\n\n上のパターンですとresult8という変数が存在していないのでうまく行っていないんだと思います。 \ndatファイルじゃなくてcsvファイルだとhoge <\\-\nread.csv(\"hoge.csv\")のように代入しますよね。そういう感じで何か変数を設定して読みこめばいいと思います。\n\nRStudioというソフトを使うと右上にメモリ上の変数の状況が表示されて把握しやすくなりますよ。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T05:53:40.050",
"id": "24744",
"last_activity_date": "2016-05-11T06:21:03.000",
"last_edit_date": "2016-05-11T06:21:03.000",
"last_editor_user_id": "12457",
"owner_user_id": "12457",
"parent_id": "24741",
"post_type": "answer",
"score": 1
},
{
"body": "`save`では変数名を含めて保存されます。 \nので、`save(result,\nfile=\"result8.dat\")`とした時点で`result8.dat`には変数名`result`も保存されています。 \nので、`load(\"result8.dat\")`で意図したデータが読み込まれているのは変数名`result`です。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T06:05:05.440",
"id": "24746",
"last_activity_date": "2016-05-11T06:05:05.440",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "6092",
"parent_id": "24741",
"post_type": "answer",
"score": 1
},
{
"body": "セーブ・ロードの対象が 1 つのオブジェクトだけであれば `saveRDS()` と `readRDS()` を使う方法があります。\n\n```\n\n > result <- stats::runif(10)\n > result\n [1] 0.68562100 0.84184211 0.69763579 0.62209902 0.04967879 0.71239629\n [7] 0.70019457 0.08939612 0.40912730 0.35949479\n > saveRDS(result, \"result8.dat\")\n \n ## Restart R\n \n > result8 <- readRDS(\"result8.dat\")\n > result8\n [1] 0.68562100 0.84184211 0.69763579 0.62209902 0.04967879 0.71239629\n [7] 0.70019457 0.08939612 0.40912730 0.35949479\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T06:49:00.777",
"id": "24748",
"last_activity_date": "2016-05-11T06:49:00.777",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24741",
"post_type": "answer",
"score": 2
}
]
| 24741 | 24748 | 24748 |
{
"accepted_answer_id": "24772",
"answer_count": 1,
"body": "iPhoneで文字を入力していて、キーボードの上に表示される予測変換候補を取得する方法がわからず、悩んでおります。 \nご存知の方がいれば、ご教授願います。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T05:55:34.453",
"favorite_count": 0,
"id": "24745",
"last_activity_date": "2016-05-12T03:01:05.537",
"last_edit_date": "2016-05-12T03:00:14.110",
"last_editor_user_id": "5519",
"owner_user_id": "13901",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"xcode"
],
"title": "Swiftにて予測変換候補を取得する方法",
"view_count": 1355
} | [
{
"body": "iOSのAPIに日本語変換システムとやりとりできるようなものはありません。 \nですので変換候補をプログラムから取得することはできません。",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T03:01:05.537",
"id": "24772",
"last_activity_date": "2016-05-12T03:01:05.537",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "24745",
"post_type": "answer",
"score": 0
}
]
| 24745 | 24772 | 24772 |
{
"accepted_answer_id": "24754",
"answer_count": 1,
"body": "Auto Hot Key を用いて入力言語の切り替えを行いたく \nこちらのサイトを参考にして \n<https://autohotkey.com/board/topic/81886-solved-autohotkey-script-input-\nlanguage/> \n以下のスクリプトでロシア語に変更できることはわかりました。\n\n```\n\n ^j::\n PostMessage, 0x50, 0, 0x4190419,, A ; 0x50 is WM_INPUTLANGCHANGEREQUEST\n Return\n \n```\n\nそれで他にも `EN: \"0x4090409\"`, `UA: \"-0xF57FBDE\"` などが載っていたのですが、それ以外の言語がわかりませんでした。\n\nまたMSDNの`WM_INPUTLANGCHANGEREQUEST`の項目に何かあるかと思ったんですが情報まで辿りつけませんでした。 \n<https://msdn.microsoft.com/ja-\njp/library/windows/desktop/ms632630%28v=vs.85%29.aspx>\n\n言語を指定するための定数一覧はどのように探せばよいでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T10:14:31.157",
"favorite_count": 0,
"id": "24751",
"last_activity_date": "2018-05-12T22:15:51.453",
"last_edit_date": "2018-05-12T22:15:51.453",
"last_editor_user_id": "5750",
"owner_user_id": "3271",
"post_type": "question",
"score": 0,
"tags": [
"winapi"
],
"title": "WM_INPUTLANGCHANGEREQUEST で指定できる言語の定数一覧",
"view_count": 203
} | [
{
"body": "入力ロケール識別子(Input Locale\nIdentifier)は`LoadKeyboardLayout`関数に[キーボードレイアウト識別子](https://technet.microsoft.com/ja-\njp/library/cc766503%28v=ws.10%29.aspx)を渡せば求める事が出来ます。\n\nC#であれば以下のようなコードになります。\n\n```\n\n var keyboard = \"00000409\"; // USキーボード\n var id = LoadKeyboardLayout(keyboard, 1); // 0x04090409\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T12:16:07.897",
"id": "24754",
"last_activity_date": "2016-05-11T12:16:07.897",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5750",
"parent_id": "24751",
"post_type": "answer",
"score": 1
}
]
| 24751 | 24754 | 24754 |
{
"accepted_answer_id": "24757",
"answer_count": 1,
"body": "emacs で縦ウィンドウ分割を行っていくと、例えば 1/2, 1/4, 1/4 で分割されます。これを、 1/3, 1/3, 1/3\nになるように、高さを調整したいのですが、これを実現する機能はありますか。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T12:07:57.657",
"favorite_count": 0,
"id": "24753",
"last_activity_date": "2016-05-11T13:13:02.070",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 2,
"tags": [
"emacs"
],
"title": "emacs で、 tmux でいうところの balance-window はできますか?",
"view_count": 140
} | [
{
"body": "`M-x balance-windows`, `C-x +` で実現できました。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T13:13:02.070",
"id": "24757",
"last_activity_date": "2016-05-11T13:13:02.070",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "24753",
"post_type": "answer",
"score": 1
}
]
| 24753 | 24757 | 24757 |
{
"accepted_answer_id": "44453",
"answer_count": 3,
"body": "今、フォームの入力を自動化したいと考えています。 \nたとえば、\n\n```\n\n document.getElementById('SOME_ID').value = 20;\n \n```\n\nのような javascript を実行すれば、該当フォームへ値を入力できることはわかったのですが、 \nfor 文や if 文などを使い構造化していったような、手元で記述したスクリプトを今表示している Web ページに適用することはできますか?\n\nブラウザは、 chrome か firefox が望ましいです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T14:13:39.257",
"favorite_count": 0,
"id": "24758",
"last_activity_date": "2018-06-01T09:41:15.810",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"javascript",
"google-chrome",
"firefox"
],
"title": "ローカルで編集している js ファイルを表示しているWebページに適用できるか",
"view_count": 679
} | [
{
"body": "Developer ToolsのConsoleにJSをコピペではだめですか? \nファイルが1ファイルならコピペでいけると思います(複数ファイルになっているとこの方法だと無理がありますが)。\n\n[](https://i.stack.imgur.com/QCkBL.png)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T14:49:14.637",
"id": "24760",
"last_activity_date": "2016-05-11T14:49:14.637",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9008",
"parent_id": "24758",
"post_type": "answer",
"score": 0
},
{
"body": "特定のサイト、ページに対して何かスクリプトを実行したいということであればGreasemonkeyを試してみてはどうでしょうか。\n\n * <https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/> \\- Firefox用\n * <https://tampermonkey.net/> \\- Chrome用\n\nスクリプト(UserScript)の書き方やインストール方法はここでは省略しますが、DOM操作やHTTPリクエストなど一通りのことは実行可能です。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T17:10:49.253",
"id": "24763",
"last_activity_date": "2016-05-11T17:10:49.253",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2391",
"parent_id": "24758",
"post_type": "answer",
"score": 1
},
{
"body": "今まで解答に挙がっていないので、 \n大抵のブラウザで使用可能な方法を追加しておきます。\n\nブックマークレット (Bookmarklet) という手法で、ブックマークのURLに入れても実行できます。\n\n例えば下記コードをURLに設定したブックマークを起動すると \n表示していたページ内のjavascriptとして動作してページタイトルを表示します。\n\n```\n\n javascript:(function(){alert(document.title);})();\n \n```\n\nもちろん複数の値をフォームに設定することも出来ます。\n\n```\n\n javascript:(function(){document.getElementById('SOME_ID').value = 20;document.getElementById('SOME_PASS').value = 30;})();\n \n```\n\n・解説サイト \n<https://support.mozilla.org/ja/kb/bookmarklets-perform-common-web-page-tasks> \n<https://qiita.com/AQRiL_1132/items/b5f9040ccb8cbc705d04>",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2018-06-01T09:33:00.383",
"id": "44453",
"last_activity_date": "2018-06-01T09:41:15.810",
"last_edit_date": "2018-06-01T09:41:15.810",
"last_editor_user_id": "19995",
"owner_user_id": "19995",
"parent_id": "24758",
"post_type": "answer",
"score": 2
}
]
| 24758 | 44453 | 44453 |
{
"accepted_answer_id": "32804",
"answer_count": 1,
"body": "docker は -v によってファイル・ディレクトリをマウントすることができますが、それを行った際のファイルの所有者の解決はどのように行われますか?\n\nというのも、 docker のホスト側でもコンテナ側でもユーザーの設定は行い得ると考えていて、当然、外と中のユーザー設定は違いますが、このとき docker\nはどうこれを解決するのでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-11T15:19:00.203",
"favorite_count": 0,
"id": "24761",
"last_activity_date": "2017-02-20T07:15:58.423",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"docker"
],
"title": "docker の mount されたファイルの所有者の解決",
"view_count": 482
} | [
{
"body": "1. linux のファイルシステム(ext4)では、ファイルシステム上のそれぞれのファイルの情報として、ユーザーID, グループID を保持する。\n 2. linux は、ファイル情報として記載されているユーザーID, グループID に対して、そのIDがOS上に登録されていなければ、その数字をそのまま所有者・グループとして表示する (e.g. `ls -al`)\n 3. つまり、 OS とファイルシステムは割と直交している。ので mount して host と container でファイルシステムを共有したからといって、(ユーザー周りで)特に取り立てて行わなければならないことはない。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2017-02-20T07:15:58.423",
"id": "32804",
"last_activity_date": "2017-02-20T07:15:58.423",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "24761",
"post_type": "answer",
"score": 0
}
]
| 24761 | 32804 | 32804 |
{
"accepted_answer_id": "24783",
"answer_count": 1,
"body": "DBサーバのCPUとIOPSが、定められた非機能要求にてピーク時の負荷を乗り切るには、どのくらいの性能が必要なのかを負荷テストしたく、以下のことができる負荷テストツールを探しています。\n\n * クエリを指定できる \n\\- JOINやWHERE句なども再現したいため、自分でクエリを指定できる必要があります。\n\n * 同時接続数を指定できる\n * クエリの頻度を指定できる \n\\- 1秒に110回送るクエリ、20秒に1回送るクエリなどが存在するため、クエリの頻度を指定できる必要があります。\n\n * 検証時間を指定できる \n\\- 3分間検証を実施したいため。\n\n以上、このようなことができる負荷ツールをご存知の方がいらっしゃいましたら、ご教示いただけますと幸いです。 \nmysqlslapで行ける!と思ったのですが、どうやら「クエリの頻度を指定」することができないようで…。\n\n自作でスクリプト組むのも非常に面倒なので、教えていただけるととても嬉しいです!",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T02:00:02.777",
"favorite_count": 0,
"id": "24770",
"last_activity_date": "2016-05-12T05:56:15.597",
"last_edit_date": "2016-05-12T04:39:30.107",
"last_editor_user_id": "8000",
"owner_user_id": "9078",
"post_type": "question",
"score": 0,
"tags": [
"mysql",
"database"
],
"title": "MySQLの負荷テストツールを探しています",
"view_count": 762
} | [
{
"body": "Jmeterで出来そうとのことなので改めて回答します。 \n下記Jmeterの配布サイトになります。\n\n<http://jmeter.apache.org/>\n\nテスト計画とシナリオを作って負荷試験を行いログを出力すればよろしいかと思います。 \nまた、試験に使用するテスト計画ファイル(`*.jmx`)を別のマシンで作成してから本番環境へ持っていくことも可能ですので、 \n本番環境でテスト計画ファイルを作成する前に試験環境でテスト計画を作成し、 \nテスト計画に不備が無いことを確認してから本番環境へ持っていくとよろしいかと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T05:56:15.597",
"id": "24783",
"last_activity_date": "2016-05-12T05:56:15.597",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24770",
"post_type": "answer",
"score": 1
}
]
| 24770 | 24783 | 24783 |
{
"accepted_answer_id": "24789",
"answer_count": 1,
"body": "ipv6検証をするために[ios Developer CenterのTest for IPv6 DNS64/NAT64 Compatibility\nRegularly](https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW1)を参考にipv6環境をmacに作りました。\n\n[Qiita](http://qiita.com/yonell/items/16c08e541b4a2b84b0a3)でも同様のやり方が書かれていました。\n\nそして、以下のコードで検証しようとしました。\n\n```\n\n Reachability *reachability = [Reachability reachabilityForInternetConnection];\n [reachability startNotifier];\n \n```\n\n以下が該当の[Reachabilityのソース](https://github.com/tonymillion/Reachability/blob/master/Reachability.m#L122)です。\n\n```\n\n +(instancetype)reachabilityForInternetConnection {\n struct sockaddr_in zeroAddress;\n bzero(&zeroAddress, sizeof(zeroAddress));\n zeroAddress.sin_len = sizeof(zeroAddress);\n zeroAddress.sin_family = AF_INET;\n \n return [self reachabilityWithAddress:&zeroAddress];\n }\n \n +(instancetype)reachabilityWithAddress:(void *)hostAddress {\n SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);\n \n if (ref) \n {\n id reachability = [[self alloc] initWithReachabilityRef:ref];\n return reachability;\n }\n \n return nil;\n } \n \n```\n\nsockaddr_inはipv4用なので動作しないはずと考えていましたが、ios9.3.1で動作させたところ、普通に動作してしまいました。 \n(参考までに[AFNetworking](https://github.com/AFNetworking/AFNetworking/pull/3174/files)のipv6対応を見ると\n`sockaddr_in6` に変えていていました。)\n\nなぜ動作してしまうのか、教えていただけると幸いです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T03:00:15.333",
"favorite_count": 0,
"id": "24771",
"last_activity_date": "2016-05-13T07:42:32.833",
"last_edit_date": "2016-05-12T08:44:17.037",
"last_editor_user_id": "670",
"owner_user_id": "670",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"ipv6"
],
"title": "macでipv6環境を作成して、iosでsockaddr_inを利用しても動作してしまう",
"view_count": 1426
} | [
{
"body": "推測ですが、AppleのReachabilityのサンプルソースのReadme \n<https://developer.apple.com/library/ios/samplecode/Reachability/Listings/ReadMe_md.html> \nには、\n\n> IPv6 Support\n>\n> Reachability fully supports IPv6. More specifically, each of the APIs\n> >handles IPv6 in the following way:\n>\n> reachabilityForInternetConnection\n>\n> This monitors the address 0.0.0.0, which reachability treats as a >special\n> token that causes it to actually monitor the general routing >status of the\n> device, both IPv4 and IPv6\n\nとあるので、IPv4ではReachしないけど、IPv6でReachしているからOKということですかね。\n\niOS9.3.1でreachabilityWithAddressでIPv4アドレスリテラルを使うと失敗しますね。\n\n```\n\n struct sockaddr_in addr;\n addr.sin_len = INET_ADDRSTRLEN;\n addr.sin_family = AF_INET;\n addr.sin_addr.s_addr = inet_addr(\"XXX.XXX.XXX.XXX\"); // ここは適当な0.0.0.0でない有効なグローバルIPを入れる\n Reachability* reachability = [Reachability reachabilityWithAddress:&addr];\n [reachability startNotifier];\n NSLog(@\"reachable[%d]\", reachability.currentReachabilityStatus); // ipv6環境では、NotReachableで、ipv4環境ではReachableViaWiFiになります\n \n```\n\n他のバージョンでは試してません。\n\nこの辺も見ておいた方が良さそうです。\n\n<https://github.com/AFNetworking/AFNetworking/issues/3498>",
"comment_count": 4,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T08:38:00.187",
"id": "24789",
"last_activity_date": "2016-05-13T07:42:32.833",
"last_edit_date": "2016-05-13T07:42:32.833",
"last_editor_user_id": "670",
"owner_user_id": "8601",
"parent_id": "24771",
"post_type": "answer",
"score": 2
}
]
| 24771 | 24789 | 24789 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "3つの3次元ベクトルA,B,Cがあり、ABを2次元空間のx軸に、ACを2次元空間のy軸にそれぞれ当てはめるような座標変換をするにはどうすればいいでしょうか。\n\n[](https://i.stack.imgur.com/J4X5x.png) \n素人考えでは下記のような操作ができればと思っているのですが、具体的なプログラムが組めません…。\n\n 1. ABが新しい3次元系のx軸になるように回転する\n 2. ACが新しい3次元系のxy平面上にくるように回転する\n 3. ACが新しい3次元系のy軸にくるようカメラ?のz座標を調整する\n\nよろしくお願いいたします。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T03:13:38.523",
"favorite_count": 0,
"id": "24773",
"last_activity_date": "2016-05-12T07:10:40.900",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15462",
"post_type": "question",
"score": 1,
"tags": [
"python",
"numpy"
],
"title": "3つの3次元ポイントを軸とする2次元に変換するには",
"view_count": 2895
} | [
{
"body": "与えられた座標pに対して \n1\\. まずAが原点になるようにAを平行移動する `(p-A)` \n2\\. ABがx軸, ACがy軸, ABとACのつくる平面に直行する軸をz軸とする(右手系で考える), そのような変換をする回転行列Rをかける\n`R*(p-A)`\n\nどのように回転行列をつくるかを説明します. まずベクトルABを正規化したものをベクトルbとする. また同様にベクトルACの正規化したものをcとする.\nABC面と直行したベクトルをdとしこれはbとcの外積になっている.\nこのときb,c,dに回転行列Rを作用するとそれぞれx,y,z軸になるようにしたいので以下をみたす. \nRb = (1, 0, 0) \nRc = (0, 1, 0) \nRd = (0, 0, 1) \nこれをとくと R^-1 = (b, c, d) , R^-1は3x3の行列でたてベクトルb,c,dをならべたもの. \nよって R = (b, c, d)^-1 = (b, c, cross(b, c))^-1\n\n```\n\n import numpy\n \n A = numpy.array([0.1,0.1,0.1])\n B = numpy.array([2,1,5])\n C = numpy.array([1,10,-1])\n \n b = (B-A)\n b = b/numpy.linalg.norm(b)\n c = (C-A)\n c = c/numpy.linalg.norm(c)\n d = numpy.cross(b, c)\n \n R = numpy.linalg.inv(numpy.array([b, c, d]))\n \n def transform(p):\n return numpy.dot(R, p-A)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T04:11:25.457",
"id": "24777",
"last_activity_date": "2016-05-12T04:42:34.770",
"last_edit_date": "2016-05-12T04:42:34.770",
"last_editor_user_id": "14418",
"owner_user_id": "14418",
"parent_id": "24773",
"post_type": "answer",
"score": 0
},
{
"body": "takoika\nさんの回答を参考に、[グラム・シュミットの正規直交化法](https://ja.wikipedia.org/wiki/%E3%82%B0%E3%83%A9%E3%83%A0%E3%83%BB%E3%82%B7%E3%83%A5%E3%83%9F%E3%83%83%E3%83%88%E3%81%AE%E6%AD%A3%E8%A6%8F%E7%9B%B4%E4%BA%A4%E5%8C%96%E6%B3%95)を使ってベクトルを変換できました。 \nプログラムとテストケース、図を載せておきます。\n\n[](https://i.stack.imgur.com/fL8qk.png)\n\n```\n\n >>> import numpy as np\n >>> def transform(a, b, c, p):\n ... v1 = b - a\n ... v2 = c - a\n ... u1 = v1\n ... u1 = u1 / np.linalg.norm(u1)\n ... u2 = v2 - (np.dot(u1, v2) / np.dot(u1, u1)) * u1\n ... u2 = u2 / np.linalg.norm(u2)\n ... u3 = np.cross(u1, u2)\n ... u3 = u3 / np.linalg.norm(u3)\n ... rot = np.array([u1, u2, u3])\n ... return np.dot(rot, p - a)\n ... \n >>> A = np.array((2, 0, 0))\n >>> B = np.array((2, 2, 0))\n >>> C = np.array((2, 2, 2))\n >>> p1 = np.array((0, 1, 0))\n >>> transform(A, B, C, p1)[:2]\n array([ 1., 0.])\n >>> p2 = np.array((0, 1, 1))\n >>> transform(A, B, C, p2)[:2]\n array([ 1., 1.])\n >>> p3 = np.array((0, 0, 1))\n >>> transform(A, B, C, p3)[:2]\n array([ 0., 1.])\n >>> p4 = np.array((3, 0, 1))\n >>> transform(A, B, C, p4)[:2]\n array([ 0., 1.])\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T07:10:40.900",
"id": "24785",
"last_activity_date": "2016-05-12T07:10:40.900",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15462",
"parent_id": "24773",
"post_type": "answer",
"score": 1
}
]
| 24773 | null | 24785 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "arduinoでanalogReadから数値を読み込み、一時的にバッファに数値を蓄えておくプログラムを書いていますが、うまくできていないです。どのようにすれば解決できるか教えていただきたいです。 \n私は、上記解決のために、配列を用いようとしているのですが、正式な数値を読み込めません。\n\n今回arduinoのプログラムをpythonで動かし、pythonの方で、数値を表示させるため、このような作業を必要としています。\n\n現在のコードは下記のようになっています。\n\nよろしくお願いします。\n\n```\n\n void setup()\n {\n pinMode(1, OUTPUT);\n Serial.begin(9600);\n }\n \n \n void loop()\n {\n char a;\n if (Serial.available() > 0)\n {\n a = Serial.read();\n if (a == 'z')\n {\n delay(10);\n digitalWrite(8,LOW);\n Measure();\n }\n \n if (a == 'y')\n {\n digitalWrite(8,HIGH);\n \n }\n }\n }\n \n void Measure()\n {\n int x;\n int v[300];\n int i[300];\n for(x = 1; x <= 300; x++)\n {\n v[x] = analogRead(A3);\n i[x] = analogRead(A4);\n delayMicroseconds(1000);\n \n }\n delay(5000);\n for(x = 1; x <= 300; x++)\n {\n Serial.print(v[x]);\n Serial.print(',');\n Serial.println(i[x]);\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T03:56:01.647",
"favorite_count": 0,
"id": "24775",
"last_activity_date": "2016-05-13T02:18:44.823",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13491",
"post_type": "question",
"score": 1,
"tags": [
"arduino"
],
"title": "arduinoで数値をバッファに蓄え、一気にserial送信したい",
"view_count": 935
} | [
{
"body": "入力ピンの指定は、正しいのでしょうか? \n関数 Measure()の中で使われている入力ピンの指定、A3,A4の値を定義しているコードが見当たりません。\n\n```\n\n v[x] = analogRead(A3); \n i[x] = analogRead(A4);\n \n```\n\nもしも、ピン3とピン4からアナログ値を読み込むのであれば、\n\n```\n\n v[x] = analogRead(3); \n i[x] = analogRead(4);\n \n```\n\nと修正してみてください。\n\n「正式な数値を読み込めません。」というのが、意味もなく変動する値が読み込まれるという現象を指しているのなら、何も接続されていないピンからアナログ値を読み込んでいる可能性が高いと思われます。 \nそこで、analogReadの引数を疑いました。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T02:18:44.823",
"id": "24807",
"last_activity_date": "2016-05-13T02:18:44.823",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "217",
"parent_id": "24775",
"post_type": "answer",
"score": 1
}
]
| 24775 | null | 24807 |
{
"accepted_answer_id": "24801",
"answer_count": 1,
"body": "ブログの投稿機能をつけるとして、投稿するのに設定が多いので、ページを分け、descriptionとimageをステップにいれ、3ステップ方式のフォームにしたいです。\n\nroutes.rbではこのようにcollection doを使用し設定をしました。\n\n```\n\n resources :notes do\n collection do\n get :description\n get :images\n end\n end\n \n```\n\nしかし、notes_controllerで\n\n```\n\n def description\n @note = Note.new\n end\n \n def images\n @note = Note.new\n end\n \n```\n\nとしているので、ステップの途中でページごとに保存、作成されてしまいます。\n\n```\n\n def description\n @note = Note.find(params[:id])\n end\n \n```\n\nとしても、Couldn't find Note with 'id'= \nというエラーがでます。初心者です。よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T04:11:58.040",
"favorite_count": 0,
"id": "24778",
"last_activity_date": "2016-05-12T13:15:03.993",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15423",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails"
],
"title": "ステップ方式を途中で保存されないようにする",
"view_count": 51
} | [
{
"body": "プログラムの経験もあまりお持ちではないのでしょうか? \n回答しようとすると範囲が広すぎるので、別解として下記のライブラリをご提案します。\n\n[Examples - jQuery Steps](http://www.jquery-steps.com/Examples#basic)\n\n1つの html を擬似的にステップに見せかけます。 \nsubmit を押すのは一回なので、routes を分ける必要がありません。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T13:15:03.993",
"id": "24801",
"last_activity_date": "2016-05-12T13:15:03.993",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7471",
"parent_id": "24778",
"post_type": "answer",
"score": 0
}
]
| 24778 | 24801 | 24801 |
{
"accepted_answer_id": "24780",
"answer_count": 1,
"body": "下記のコードを書きました。\n\n```\n\n let list = [\"A\":1,\"B\":2,\"C\":3,\"D\":4,\"E\":5]\n for (key:value) in list {\n print(\"\\(key),\\(value)\")\n }\n \n```\n\nコンパイルで「Use of unresolved identifier 'key'」というエラーになります。 \n意味は「'key'は宣言されていません」ですが、見る限り宣言されており、エラーの意味がわかりません。 \n原因及び対処方法についてご教示願います。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T04:48:32.563",
"favorite_count": 0,
"id": "24779",
"last_activity_date": "2016-05-12T05:14:27.637",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15467",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"ios",
"xcode"
],
"title": "辞書参照でuse of unresolved identifier",
"view_count": 3361
} | [
{
"body": "`(key:value)` と書かれていますが、 `(key,value)` の誤りではないでしょうか?\n\n```\n\n let list = [\"A\":1,\"B\":2,\"C\":3,\"D\":4,\"E\":5]\n for (key,value) in list {\n print(\"\\(key),\\(value)\")\n }\n \n```\n\n参考 [The Swift Programming Language (Swift 2.2): Collection\nTypes](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/CollectionTypes.html#//apple_ref/doc/uid/TP40014097-CH8-ID117)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T05:00:53.107",
"id": "24780",
"last_activity_date": "2016-05-12T05:14:27.637",
"last_edit_date": "2016-05-12T05:14:27.637",
"last_editor_user_id": "8000",
"owner_user_id": "8000",
"parent_id": "24779",
"post_type": "answer",
"score": 6
}
]
| 24779 | 24780 | 24780 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "現在作成しているアプリで下記ディレクトリをGitHubには上げたくないので、 \n「.gitignore」ファイルに以下のように記述しました。\n\n【.gitignore】※sample_app/.gitignore\n\n```\n\n /app/views/categories/\n /app/views/chat/\n /app/views/question_mailer/\n \n```\n\nその後、\n\n```\n\n git add -A\n git commit -m \"add_.gitignore\"\n git push -u origin master\n \n```\n\nを行いました。 \nが、GitHubを確認すると、「.gitignore」ファイルに記載したディレクトリがGitHubにアップされてしまっています。 \nこれは「.gitignore」ファイルの書き方が間違っているのでしょうか? \n間違っている場合は正しい書き方を教えて頂きたいです。 \n何卒宜しくお願い致します。",
"comment_count": 6,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T05:04:48.820",
"favorite_count": 0,
"id": "24781",
"last_activity_date": "2016-05-12T06:30:34.033",
"last_edit_date": "2016-05-12T05:16:35.837",
"last_editor_user_id": "8000",
"owner_user_id": "12323",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails",
"git"
],
"title": ".gitignoreに記載したファイルがGithubにpushされてしまう",
"view_count": 2199
} | [
{
"body": "`.gitignore` は名前の通り、Gitから特定のディレクトリ・ファイルを除外するための指定ですから、\n\n * そのファイルはGithubだけでなくローカルでもGitで管理されなくなります\n * リポジトリへの新規追加を抑制するものなので、既にコミットされたファイルには適用されません\n\n`.gitignore` を書く前にコミットしてしまったファイルを取り除きたい場合、当該ファイルを `git rm --cached`\nすることになりますが、当然それまでの履歴には残ったままになります。これも含めて削除するには、ファイルを追加した時点まで遡ってコミットをやり直したり、量が多ければ\n`git filter-branch` を使うことになります。\n\n> やりたいことはGitHubにPUSHする際に上記のディレクトリは上げたくないのですが、そのようなやり方はありますでしょうか?\n> .gitignoreで行うか、他のやり方もあるのでしょうか?\n\nGitの仕組みとして、pushする時にはコミット単位でコピーされますから、コミットのうち一部のファイルだけpushすることはできません。またGithubには特定のファイルを非公開にする機能はありません。\n\nですから「諦めて公開してしまう」か「Gitの管理外に置いてしまう」のどちらかが多く、時々「非公開用と公開用でリポジトリを分ける」といったケースがあるぐらいかと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T06:30:34.033",
"id": "24784",
"last_activity_date": "2016-05-12T06:30:34.033",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8000",
"parent_id": "24781",
"post_type": "answer",
"score": 2
}
]
| 24781 | null | 24784 |
{
"accepted_answer_id": "24791",
"answer_count": 1,
"body": "コード:\n\n```\n\n #!/usr/bin/env python\n #coding: utf-8\n userid=\"**************@gmail.com\"\n passwd=\"*******\"\n import sys, re, cgi, urllib, urllib.request, urllib.error, http.cookiejar, xml.dom.minidom, time, urllib.parse\n import simplejson as json\n \n def getToken():\n html = urllib.request.urlopen(\"http://www.nicovideo.jp/my/mylist\").read()\n for line in html.splitlines():\n mo = re.match(r'^\\s*NicoAPI\\.token = \"(?P<token>[\\d\\w-]+)\";\\s*',line)\n if mo:\n token = mo.group('token')\n break\n assert token\n return token\n \n def mylist_create(name):\n cmdurl = \"http://www.nicovideo.jp/api/mylistgroup/add\"\n q = {}\n q['name'] = name.encode(\"utf-8\")\n q['description'] = \"\"\n q['public'] = 0\n q['default_sort'] = 0\n q['icon_id'] = 0\n q['token'] = token\n cmdurl += \"?\" + urllib.parse.urlencode(q).encode(\"utf-8\")\n j = json.load( urllib.request.urlopen(cmdurl), encoding='utf-8')\n return j['id']\n \n def addvideo_tomylist(mid,smids):\n for smid in smids:\n cmdurl = \"http://www.nicovideo.jp/api/mylist/add\"\n q = {}\n q['group_id'] = mid\n q['item_type'] = 0\n q['item_id'] = smid\n q['description'] = u\"\"\n q['token'] = token\n cmdurl += \"?\" + urllib.parse.urlencode(q).encode(\"utf-8\")\n j = json.load( urllib.request.urlopen(cmdurl), encoding='utf-8')\n time.sleep(0.5)\n \n #ログイン\n opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(http.cookiejar.CookieJar()))\n urllib.request.install_opener(opener)\n urllib.request.urlopen(\"https://secure.nicovideo.jp/secure/login\",\n urllib.parse.urlencode( {\"mail\":userid, \"password\":passwd} ))\n #トークン取得\n token = getToken()\n #マイリストの作成と動画の登録\n mid = mylist_create(u\"テストリスト\")\n addvideo_tomylist(mid, [\"sm9\",\"sm1097445\", \"sm1715919\" ] )\n \n```\n\nエラー:\n\n```\n\n Traceback (most recent call last):\n File \"Nico3.py\", line 47, in <module>\n urllib.request.urlopen(\"https://secure.nicovideo.jp/secure/login\", urllib.parse.urlencode( {\"mail\":userid, \"password\":passwd} ))\n File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py\", line 162, in urlopen\n return opener.open(url, data, timeout)\n File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py\", line 463, in open\n req = meth(req)\n File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py\", line 1170, in do_request_\n raise TypeError(msg)\n TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.\n \n```\n\nエラー2(追記)\n\n```\n\n Traceback (most recent call last):\n File \"Nico3.py\", line 50, in <module>\n token = getToken()\n File \"Nico3.py\", line 11, in getToken\n mo = re.match(r'^\\s*NicoAPI\\.token = \"(?P<token>[\\d\\w-]+)\";\\s*',line)\n File \"/Users/NanjoHiroki/.virtualenvs/uec/lib/python3.5/re.py\", line 163, in match\n return _compile(pattern, flags).match(string)\n TypeError: cannot use a string pattern on a bytes-like object\n \n```\n\nエラー3:\n\n```\n\n Traceback (most recent call last):\n File \"Nico3.py\", line 50, in <module>\n token = getToken()\n File \"Nico3.py\", line 15, in getToken\n assert token\n UnboundLocalError: local variable 'token' referenced before assignment\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T07:14:12.973",
"favorite_count": 0,
"id": "24786",
"last_activity_date": "2016-05-13T07:22:20.667",
"last_edit_date": "2016-05-12T18:40:17.463",
"last_editor_user_id": null,
"owner_user_id": null,
"post_type": "question",
"score": 0,
"tags": [
"python",
"api"
],
"title": "TypeErrorが出てきて実行できない。",
"view_count": 12226
} | [
{
"body": "エラー: \n`POST data`は`str`型ではなく`bytes`型ではないといけないというエラーです.`urllib.parse.urlencode(\n{\"mail\":userid, \"password\":passwd}\n)`は`str`型をかえすのでこれを特定の文字コードを指定して`bytes`型に変換します.\n\n```\n\n urllib.request.urlopen(\"https://secure.nicovideo.jp/secure/login\",\n urllib.parse.urlencode( {\"mail\":userid, \"password\":passwd} ).encode('ascii'))\n \n```\n\nエラー2: \n`urllib.request.urlopen().read()`は`bytes`型を返します.\n`bytes`型にたいして`str`型の正規表現パターンは適用できないよというエラーです. 対応としては \n1\\. htmlを`str`型に変換する(htmlの文字コードがutf-8の場合)\n\n```\n\n html = urllib.request.urlopen(\"http://www.nicovideo.jp/my/mylist\").read().decode('utf-8')\n \n```\n\nまたは \n2. 正規表現パターンを`bytes`型にする\n\n```\n\n mo = re.match(rb'^\\s*NicoAPI\\.token = \"(?P<token>[\\d\\w-]+)\";\\s*',line)\n \n```\n\nエラー3: \n正規表現にマッチする行が1つもなかった場合, `token`の代入文が実行されないので, そのとき`token`はないというエラーです.\n例えば関数の先頭でいったん初期値を代入すれば,そのエラーはきえます.\n\n```\n\n token = False\n \n```\n\n初期値に`False`を入れておけば, `assert`でtokenがみつかったどうかがチェックできます.\nちょっと気になるのは`assert`を使っているということは`html`には必ずtokenが含まれていると想定しているんですよね・・・",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T09:06:49.160",
"id": "24791",
"last_activity_date": "2016-05-13T07:22:20.667",
"last_edit_date": "2016-05-13T07:22:20.667",
"last_editor_user_id": "14418",
"owner_user_id": "14418",
"parent_id": "24786",
"post_type": "answer",
"score": 0
}
]
| 24786 | 24791 | 24791 |
{
"accepted_answer_id": "25370",
"answer_count": 1,
"body": "WkWebviewでユーザエージェントを変更したいのですが、iOS8の場合変更する方法が分からず悩んでおります。 \nご存知の方がいれば、ご教授願います。\n\n```\n\n MainController.h\n @property (nonatomic, strong) WKWebView *webView;\n \n MainController.m\n @synthesize webView = _webView;\n \n - (void)viewDidLoad {\n // 初期化\n _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0,0,[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height)];\n _webView.navigationDelegate = self;\n _webView.allowsBackForwardNavigationGestures = true;\n [[self view] addSubview:_webView];\n \n // ユーザエージェント設定\n [_webView evaluateJavaScript:@\"navigator.userAgent\" completionHandler:^(id __nullable userAgent, NSError * __nullable error) {\n \n NSString *myUserAgent = [NSString stringWithFormat:@\"%@ AppName\", userAgent];\n if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0) {\n _webView.customUserAgent = myUserAgent;\n } else {\n // ユーザエージェントが変わらない(_webView.customUserAgentはiOS9から)\n [[NSUserDefaults standardUserDefaults] registerDefaults:@{@\"UserAgent\": myUserAgent}];\n }\n }];\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T07:25:09.493",
"favorite_count": 0,
"id": "24787",
"last_activity_date": "2016-06-02T01:26:09.290",
"last_edit_date": "2016-05-12T11:41:12.123",
"last_editor_user_id": "15468",
"owner_user_id": "15468",
"post_type": "question",
"score": 0,
"tags": [
"objective-c",
"ios8"
],
"title": "iOS8でWKWebViewのユーザエージェントを変更するには",
"view_count": 982
} | [
{
"body": "自己解決しました。 AppDelegateのdidFinishLaunchingWithOptionsで[[NSUserDefaults\nstandardUserDefaults] registerDefaults:@{@\"UserAgent\":\nmyUserAgent}];を実行したところユーザエージェントが変更されました。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-06-02T01:26:09.290",
"id": "25370",
"last_activity_date": "2016-06-02T01:26:09.290",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15468",
"parent_id": "24787",
"post_type": "answer",
"score": 0
}
]
| 24787 | 25370 | 25370 |
{
"accepted_answer_id": "25264",
"answer_count": 1,
"body": "「数件のstrict standards/noticeでのアップデートリリースはしない」方針のようで、代わりに(有志による?)修正バージョンを見つけました。 \n変更点についてわからない部分があり、質問させていただきます。\n\n(参考URL) \n修正版のコード→<http://pastebin.com/14xJER5S> \nフォーラムトピック→<https://wordpress.org/support/topic/php-deprecated-class-\nconstructor-name-with-php7>\n\n<変更点> \n・66行目…(1) \nfunction WP_Import() { /* nothing _/ } \n↓ \npublic function __construct(){ /_ nothing */ }\n\n・798行目…(2) \n$$meta['key'] = $meta['value'] \n↓ \n${$meta['key']} = $meta['value']\n\n・1032行目…(3) \nscreen_icon(); // 削除\n\n・1110行目…(4) \nfunction bump_request_timeout(){ \n↓ \nfunction bump_request_timeout($val){\n\n●変更点についての、自分なりの解釈 \n(1).class同名のfunctionでのコンストラクタが非推奨になったことへの対応 \n(2).可変変数名の書き方を、より明示的な書き方に修正 \n(3).WP3.8~非推奨になったコマンド「screen_icon(get_screen_icon)」を削除 \n(4).「http_request_timeout」の形式が値設定ありなので、互換性のある書き方に修正\n\n●疑問点 \n(A).この解釈で合っている? \n(B).上記(1)のfunctionは、なぜ「public」なのか?\n\n解釈の間違いや、追加情報、補足情報など。 \nなにかありましたら、コメントをいただけると嬉しいです。 \nよろしくお願いします。\n\n<開発環境> \nXAMPP:7.0.4(PHP7+MariaDB) \nWordPress:4.5.2 \nWordPress Importer:0.6.1 \nOS:Windows Vista SP2\n\n※Word Pressは5/8現時点での最新版。XAMPPは1つ前のバージョンです。 \n※WordPressのDEBUG_MODE=ONでテストしています。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T09:00:54.100",
"favorite_count": 0,
"id": "24790",
"last_activity_date": "2016-05-29T07:25:03.480",
"last_edit_date": "2016-05-29T06:58:19.333",
"last_editor_user_id": "15471",
"owner_user_id": "15471",
"post_type": "question",
"score": 0,
"tags": [
"php",
"wordpress"
],
"title": "PHP7環境で「WordPress Importer」を使うとエラーになる件について",
"view_count": 345
} | [
{
"body": "他サイトで教えてもらったので、回答をかいつまんでメモしておきます。\n\n> (A).この解釈で合っている?\n\n概ねOK。 \n(2)については、PHP5とPHP7で挙動が違うため、双方で同じ解釈になるように{}を使って表記している。 \n(→[PHP: 下位互換性のない変更点 -\nManual](http://php.net/manual/ja/migration70.incompatible.php))\n\n> (B).上記(1)のfunctionは、なぜ「public」なのか?\n\nコンストラクタはpublicでないと外部から呼べない(=このクラスを外部からインスタンス化できない)ため。\n\n※コンストラクタはpublicにするのが基本。 \n(例外的なケースとして、特殊な用途で、わざとprivateにする使い方もないことはない)\n\n補足 \n・メソッドで(スコープを)何も書かない場合、public扱いになる(php7の場合)。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-29T07:25:03.480",
"id": "25264",
"last_activity_date": "2016-05-29T07:25:03.480",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15471",
"parent_id": "24790",
"post_type": "answer",
"score": 0
}
]
| 24790 | 25264 | 25264 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "railsもしくはbootstrapのライブラリを用いて、\n\n[](https://i.stack.imgur.com/FMxAi.png)\n\nこのようにツイッターの新規投稿ボタン?を押すと画面が遷移せず、背景が暗くなり、フォームが \n出てくる。という機能をつけたいのですが、そういったライブラリはあるのでしょうか? \nもしあるのなら何と調べればいいのかご教授願いたいですm(__)m",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T10:05:40.450",
"favorite_count": 0,
"id": "24793",
"last_activity_date": "2016-05-12T12:09:14.280",
"last_edit_date": "2016-05-12T12:09:14.280",
"last_editor_user_id": "76",
"owner_user_id": "12757",
"post_type": "question",
"score": 0,
"tags": [
"bootstrap"
],
"title": "Twitterの様な投稿フォームを再現するには",
"view_count": 349
} | [
{
"body": "[Modals](https://getbootstrap.com/javascript/#modals \"Modals\")\nをベースにフォームやボタンを追加すると、同じような画面を実装できます。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T12:08:56.933",
"id": "24797",
"last_activity_date": "2016-05-12T12:08:56.933",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "76",
"parent_id": "24793",
"post_type": "answer",
"score": 1
}
]
| 24793 | null | 24797 |
{
"accepted_answer_id": "29593",
"answer_count": 1,
"body": "ある org ファイルに対して、 `org-narrow-to-subtree` を、別々の subtree で実行し、 \nそれを別々のウィンドウで表示したいと思いました。\n\nこれを実現するにはどうしたらいいでしょうか。\n\n現状、片一方で narrowing した時点で、もう一方の window でも narrowing されてしまいます。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T11:44:58.233",
"favorite_count": 0,
"id": "24795",
"last_activity_date": "2016-10-15T15:44:56.233",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"emacs"
],
"title": "同一バッファで、別々の箇所を別々の window で narrowing するには?",
"view_count": 70
} | [
{
"body": "`M-x clone-indirect-buffer-other-window`(`C-x 4 c`)で、 org-narrow-to-subtree\nを別々に行えることを確認しました。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-10-15T15:44:56.233",
"id": "29593",
"last_activity_date": "2016-10-15T15:44:56.233",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "24795",
"post_type": "answer",
"score": 0
}
]
| 24795 | 29593 | 29593 |
{
"accepted_answer_id": "24808",
"answer_count": 1,
"body": "お世話になります。 \n題目通りです。すでに何回か質問されてるようで重複の可能性がありますがよろしくお願いします。\n\nInAppBrowserプラグイン追加しました。\n\n(1)var ref = window.open(url,'_system','location=no'); \n(2)var ref = window.open(url,'_system','location=yes,hidden=no'); \n(3)・・・・ \n(4)・・・・ \nなど考えられるパターンをネットで見つけて手当たり次第試しましたが、一切外部ブラウザで立ち上がりません。WebView内ばかりで表示されます。\n\n現在ベーシック会員だからできないのでしょうか? \nそのか設定やJSなどの読み込み、XMLの追加など何かあるのでしょうか? \nIDEからの実機デバッグなので実感しないのでしょうか?\n\n全くお手上げ状態です。\n\n大変申し訳御座いませんが御指導願いします。 \nまた重複と思われ不快に感じる方には、この場で陳謝いたします。\n\n追記:はじめてMONACAを使ってます。この場での質問はダメなのでしょうか?それさえも判断がつきません。申し訳御座いません。 \nありがとうございました。",
"comment_count": 7,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-12T13:44:29.877",
"favorite_count": 0,
"id": "24802",
"last_activity_date": "2016-05-13T05:16:29.047",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15474",
"post_type": "question",
"score": 0,
"tags": [
"monaca",
"cordova"
],
"title": "InAppBrowserで外部ブラウザ起動しない",
"view_count": 6019
} | [
{
"body": "Monacaのサイトより抜粋\n\n> `var ref = cordova.InAppBrowser.open(url, target, options);`\n>\n> target: URL の読み込み先として使用するブラウザーの種別。任意のパラメーターです。デフォルトでは、_self となります。 (String) \n> ・_self: ホワイトリストに対象の URL が登録されている場合には、Cordova WebView\n> を開きます。それ以外の場合には、InAppBrowser を開きます。 \n> ・_blank: InAppBrowser を開きます。 \n> ・_system: システム標準の Web ブラウザー ( system’s web browser ) を開きます。\n\n`FLEAZ POP(Android 5.1.1)`、`iPhone5(iOS 9.3.1)`の **Monacaデバッガー** で動作確認済みです。 \nうまく動作しない場合は、動作環境を変えるなどして対応してください。 \n※スクリーンショットは`Android`。\n\n```\n\n <!DOCTYPE HTML>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no\">\n <meta http-equiv=\"Content-Security-Policy\" content=\"default-src * data:; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'\">\n <script src=\"components/loader.js\"></script>\n <script src=\"lib/onsenui/js/onsenui.min.js\"></script>\n \n <link rel=\"stylesheet\" href=\"components/loader.css\">\n <link rel=\"stylesheet\" href=\"lib/onsenui/css/onsenui.css\">\n <link rel=\"stylesheet\" href=\"lib/onsenui/css/onsen-css-components.css\">\n \n <script>\n ons.ready(function() {\n console.log(\"Onsen UI is ready!\");\n });\n </script>\n </head>\n <body>\n <div style=\"text-align: center\">\n <br>\n <ons-button onclick=\"window.open('http://ja.stackoverflow.com/', '_self')\">_self</ons-button>\n <br>\n <br>\n <ons-button onclick=\"window.open('http://ja.stackoverflow.com/', '_blank')\">_blank</ons-button>\n <br>\n <br>\n <ons-button onclick=\"window.open('http://ja.stackoverflow.com/', '_system')\">_system</ons-button>\n </div>\n </body>\n </html>\n \n```\n\n[](https://i.stack.imgur.com/J4jIf.png)",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T02:35:37.207",
"id": "24808",
"last_activity_date": "2016-05-13T02:42:50.273",
"last_edit_date": "2016-05-13T02:42:50.273",
"last_editor_user_id": "9566",
"owner_user_id": "9566",
"parent_id": "24802",
"post_type": "answer",
"score": 0
}
]
| 24802 | 24808 | 24808 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "以下の機能を利用できるようなIDEがあれば教えてください。\n\n * 関数名のコードヒント(ClassName. まで書けばクラス内の関数や定数がコードヒントで出るような機能)\n * コード内で利用されているクラス・関数にジャンプする機能\n * 特定の関数やクラスを利用しているプロジェクト内のファイルを検索する機能\n\naws-sdkなどの外部パッケージを利用して開発する際にリファレンスを探しながら開発をするのが辛いです。 \nさくっと利用しているクラスや関数のソースをみて開発できれば楽なのにと思って質問しました。",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T01:35:50.973",
"favorite_count": 0,
"id": "24805",
"last_activity_date": "2016-05-13T01:35:50.973",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "14401",
"post_type": "question",
"score": 0,
"tags": [
"node.js"
],
"title": "Node.jsの開発におすすめなIDEを教えてください。",
"view_count": 1537
} | []
| 24805 | null | null |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "Postfix から hotmail.com アカウントへメール送信するとメール送信に失敗します。 \nログを確認したところ以下のログが残っていました。\n\n原因として何が考えられるでしょうか? \nまた、どのように設定すれば解決できるでしょうか? \nアドバイスをよろしくお願いします。\n\n```\n\n May 10 20:40:18 localhost postfix/pickup[28927]: E8C323940359: uid=48 from=<[email protected]>\n May 10 20:40:18 localhost postfix/cleanup[30001]: E8C323940359: message-id=<[email protected]>?\n May 10 20:40:19 localhost postfix/qmgr[23865]: E8C323940359: from=<[email protected]>, size=1140, nrcpt=1 (queue active)\n May 10 20:40:49 localhost postfix/smtp[30003]: connect to mx1.hotmail.com[65.55.92.152]:25: Connection timed out\n May 10 20:40:49 localhost postfix/smtp[30003]: E8C323940359: to=<[email protected]>, relay=mx3.hotmail.com[207.46.8.199]:25, delay=31, delays=0.15/0.01/30/0.14, dsn=5.0.0, status=bounced (host mx3.hotmail.com[207.46.8.199] said: 554 Transaction failed (in reply to MAIL FROM command))\n May 10 20:40:49 localhost postfix/smtp[30003]: E8C323940359: lost connection with mx3.hotmail.com[207.46.8.199] while sending RCPT TO\n May 10 20:40:49 localhost postfix/cleanup[30001]: A2E39394035C: message-id=<[email protected]>\n May 10 20:40:49 localhost postfix/bounce[30012]: E8C323940359: sender non-delivery notification: A2E39394035C\n May 10 20:40:49 localhost postfix/qmgr[23865]: A2E39394035C: from=<>, size=2973, nrcpt=1 (queue active)\n May 10 20:40:49 localhost postfix/qmgr[23865]: E8C323940359: removed\n M\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T03:07:31.007",
"favorite_count": 0,
"id": "24810",
"last_activity_date": "2016-05-14T06:34:35.853",
"last_edit_date": "2016-05-14T06:34:35.853",
"last_editor_user_id": "3061",
"owner_user_id": "7212",
"post_type": "question",
"score": 1,
"tags": [
"postfix"
],
"title": "Postfix から hotmail.com アカウントへのメール送信に失敗します",
"view_count": 2683
} | [
{
"body": "現状を読み解く \n1.「mx1.hotmail.com[65.55.92.152]:25」への接続が出来なかった \n※`Connection timed out`とあり、接続待機に時間がかかっている。\n\n2.`TO`からの送信が`554 Transaction failed`となっており処理に失敗 \n※`in reply to MAIL FROM command`とあり、FROMからの応答が無いため失敗している\n\n3.「mx3.hotmail.com[207.46.8.199]」への送信のための接続が失われた。 \n「lost connection with mx3.hotmail.com[207.46.8.199] while sending RCPT TO」 \n※おそらくエラーのため接続を切断したと思われる\n\n* * *\n\n可能性の話 \n1.メールのアカウントの認証失敗で接続拒否(FROM側が怪しい?) \n2.添付ファイルが受信サーバで受け付けていない \n3.受信先のサーバが落ちている \n4.メール送信時に正常にリレー出来ていない(`main.cf`の設定とか怪しいかも) \n5.サーバが外への接続を拒否している\n\n送受信で同じドメインなので、FROMが接続できなかったらTOも接続できない気はしますが…… \n片方のみっぽいのでアカウントの認証失敗の可能性が高そう……",
"comment_count": 6,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T06:59:25.637",
"id": "24819",
"last_activity_date": "2016-05-13T06:59:25.637",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24810",
"post_type": "answer",
"score": 1
}
]
| 24810 | null | 24819 |
{
"accepted_answer_id": "25360",
"answer_count": 1,
"body": "WKWebViewで「<http://example.com/>」が表示できません。 \n(また、別のURLに変更しても同様の結果です。真っ白になります。) \nwifiを有効にすると表示でき、4Gで接続すると表示できません。 \n(safariでは4Gで表示できます。) \nまた、App Transport SecurityのHTTPは許可をしています。 \nWKWebViewを使った他のアプリでは表示できるのに、何故か表示できない事象になってしまいました。\n\nご存知の方がいれば、ご教授願います。\n\n端末情報:iOS9.3、iPhone6 \nキャリア:au",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T04:01:39.680",
"favorite_count": 0,
"id": "24811",
"last_activity_date": "2016-06-01T09:47:24.653",
"last_edit_date": "2016-05-19T09:45:31.900",
"last_editor_user_id": "15468",
"owner_user_id": "15468",
"post_type": "question",
"score": 1,
"tags": [
"ios",
"objective-c",
"ios9"
],
"title": "4G回線(LTE)でWKWebViewを使ってWebページを表示する方法について",
"view_count": 211
} | [
{
"body": "自己解決しました。 \n設定のモバイルデータ通信がオフになっていたのが問題だったようです。 \nオンに変更したら無事表示できるようになりました。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-06-01T09:47:24.653",
"id": "25360",
"last_activity_date": "2016-06-01T09:47:24.653",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15468",
"parent_id": "24811",
"post_type": "answer",
"score": 0
}
]
| 24811 | 25360 | 25360 |
{
"accepted_answer_id": "24832",
"answer_count": 2,
"body": "Windows10、VisualStudio2015、.Net4.6、WPF、C# で開発しております。\n\n以下のようにIsMouseOverを利用して自動的に隠れるコントロールを作っているのですが、コンテキストメニューを開くとIsMouseOverがFalseになってしまうようで期待する動作になりません。\n\nコンテキストメニューが開かれているときもコントロールを表示状態にしたいのですが、どのようにしたら良いのでしょうか。\n\n* * *\n\nMainWindow.xaml\n\n```\n\n <Window x:Class=\"ContextMenu.MainWindow\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\n xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\"\n xmlns:local=\"clr-namespace:ContextMenu\"\n mc:Ignorable=\"d\"\n Title=\"MainWindow\" Height=\"350\" Width=\"525\">\n <Grid>\n \n <Grid VerticalAlignment=\"Bottom\" Background=\"LightGray\">\n \n <!-- MouseOver状態で自動的に表示する -->\n <Grid.Style>\n <Style TargetType=\"Grid\">\n <Setter Property=\"Opacity\" Value=\"0.1\"/>\n <Style.Triggers>\n <Trigger Property=\"IsMouseOver\" Value=\"True\">\n <Setter Property=\"Opacity\" Value=\"1\"/>\n </Trigger>\n </Style.Triggers>\n </Style>\n </Grid.Style>\n \n <TextBox Text=\"ここでコンテキストメニューを開くと...\" HorizontalAlignment=\"Left\" Margin=\"10\"/>\n \n </Grid>\n \n </Grid>\n </Window>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T05:57:20.947",
"favorite_count": 0,
"id": "24816",
"last_activity_date": "2016-05-14T06:25:31.840",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "14817",
"post_type": "question",
"score": 0,
"tags": [
"wpf"
],
"title": "WPF 自動的に隠れるコントロールを作る時のコンテキストメニューの問題",
"view_count": 2421
} | [
{
"body": "`ContextMenu`を自分で指定している場合は`ContextMenu`が表示されている場合(`IsOpen=\"True\"`)のトリガーを追加してやればいいのではないでしょうか。\n\n```\n\n <Grid\n VerticalAlignment=\"Bottom\"\n Background=\"LightGray\">\n \n <!-- MouseOver状態で自動的に表示する -->\n <Grid.Style>\n <Style\n TargetType=\"Grid\">\n <Setter\n Property=\"Opacity\"\n Value=\"0.1\" />\n <Style.Triggers>\n <Trigger\n Property=\"IsMouseOver\"\n Value=\"True\">\n <Setter\n Property=\"Opacity\"\n Value=\"1\" />\n </Trigger>\n <!-- トリガーを追加 -->\n <DataTrigger\n Binding=\"{Binding ElementName=tb, Path=ContextMenu.IsOpen}\"\n Value=\"True\">\n <Setter\n Property=\"Opacity\"\n Value=\"1\" />\n </DataTrigger>\n </Style.Triggers>\n </Style>\n </Grid.Style>\n \n <!-- Nameを設定 -->\n <TextBox\n Name=\"tb\"\n Text=\"ここでコンテキストメニューを開くと...\"\n HorizontalAlignment=\"Left\"\n Margin=\"10\">\n <!-- ContextMenuを設定 -->\n <TextBox.ContextMenu>\n <ContextMenu>\n <MenuItem\n Header=\"a\"></MenuItem>\n </ContextMenu>\n </TextBox.ContextMenu>\n </TextBox>\n \n </Grid>\n \n```\n\nまた`TextBoxBase`などに用意されているWPF標準ポップアップは通常のプロパティやイベントでは判断できないので、\n\n 1. `PropertyDescriptor`を使って`IsMouseOver`イベントをハンドルする。\n 2. `PresentationSource`から対象の`Popup`を探す。\n\nという2個のトリックを使う必要があります。\n\n```\n\n public MainWindow()\n {\n InitializeComponent();\n \n // IsMouseOverの変更イベントをハンドルする。\n var dpd = DependencyPropertyDescriptor.FromProperty(UIElement.IsMouseOverProperty, typeof(Grid));\n dpd.AddValueChanged(grid, Grid_IsMouseOverChanged);\n }\n \n private void Grid_IsMouseOverChanged(object sender, EventArgs e)\n {\n // IsMouseOverがTrueの場合は処理終了\n if (grid.IsMouseOver)\n {\n grid.Opacity = 1;\n return;\n }\n \n // マウスが実際に乗っているか判定する。\n var mp = Mouse.GetPosition(grid);\n \n if (0 < mp.X && mp.X < grid.ActualWidth\n && 0 < mp.Y && mp.Y < grid.ActualHeight)\n {\n // 内部の要素に対して表示されているPopupを探す\n var popup = PresentationSource.CurrentSources\n .OfType<HwndSource>()\n .Select(_ => ((_.RootVisual as FrameworkElement)?.Parent as Popup))\n .FirstOrDefault(_ => _?.IsOpen == true && _.PlacementTarget == tb);\n \n // TODO:PlacementTargetに対する条件を任意の要素に対応できるよう変える\n \n if (popup != null)\n {\n // PopupのClosedイベントを処理する\n popup.Closed += Popup_Closed;\n return;\n }\n }\n grid.Opacity = 0.1;\n }\n \n private void Popup_Closed(object sender, EventArgs e)\n {\n grid.Opacity = grid.IsMouseOver ? 1 : 0.1;\n ((Popup)sender).Closed -= Popup_Closed;\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T07:33:18.520",
"id": "24820",
"last_activity_date": "2016-05-13T11:38:25.200",
"last_edit_date": "2016-05-13T11:38:25.200",
"last_editor_user_id": "5750",
"owner_user_id": "5750",
"parent_id": "24816",
"post_type": "answer",
"score": 1
},
{
"body": "別のフォーカス対象が必要になりますが、`IsFocused`を使用した解決方法を思いつたので投稿します。\n\n追記:自動的に隠れる条件に「フォーカスされていない」を加えることを許容する場合の回答になります\n\n```\n\n <Grid>\n <!-- 別のフォーカス用 -->\n <Grid x:Name=\"other\" Focusable=\"True\" Background=\"#FEEE\" MouseDown=\"other_MouseDown\" FocusVisualStyle=\"{x:Null}\"/>\n \n <!-- 自動的に隠したいパネル -->\n <Grid x:Name=\"grid\" VerticalAlignment=\"Bottom\" >\n \n <!-- MouseOver状態で自動的に表示する -->\n <Grid.Style>\n <Style TargetType=\"Grid\">\n <Setter Property=\"Background\" Value=\"LightGray\"/>\n <Setter Property=\"Opacity\" Value=\"0.1\"/>\n <Style.Triggers>\n <Trigger Property=\"IsMouseOver\" Value=\"True\">\n <Setter Property=\"Opacity\" Value=\"1\"/>\n </Trigger>\n <DataTrigger Binding=\"{Binding ElementName=tb, Path=IsFocused}\" Value=\"True\">\n <Setter Property=\"Opacity\" Value=\"1\" />\n </DataTrigger>\n </Style.Triggers>\n </Style>\n </Grid.Style>\n \n <TextBox x:Name=\"tb\" Text=\"ここでコンテキストメニューを開くと...\" HorizontalAlignment=\"Left\" Margin=\"10\"/>\n \n </Grid>\n </Grid>\n \n```\n\n* * *\n```\n\n private void other_MouseDown(object sender, MouseButtonEventArgs e)\n {\n this.other.Focus();\n }\n \n```",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T16:16:21.330",
"id": "24832",
"last_activity_date": "2016-05-14T06:25:31.840",
"last_edit_date": "2016-05-14T06:25:31.840",
"last_editor_user_id": "14817",
"owner_user_id": "14817",
"parent_id": "24816",
"post_type": "answer",
"score": 0
}
]
| 24816 | 24832 | 24820 |
{
"accepted_answer_id": "24844",
"answer_count": 1,
"body": "いつもお世話になっております。 \n表題の通りです。\n\n[](https://i.stack.imgur.com/lCW0b.png)\n\n↑登録ボタン(TourokuButton)に画像のような設定をしたいです。 \n(この画像はUIButton)のものです。\n\nですが、BarButtonItemでは、\n\n[](https://i.stack.imgur.com/0x807.png)\n\n↑こうなります。 \nUITextFieldに入力項目がキチンと入力されていないとButtonを押せないような設定をしたいのですが、BarButtonItemでは不可能なのでしょうか?\n\nお解りになる方がいらっしゃればご教授下さい。 \nお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T09:46:14.087",
"favorite_count": 0,
"id": "24822",
"last_activity_date": "2016-05-14T03:46:00.980",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13156",
"post_type": "question",
"score": -1,
"tags": [
"swift"
],
"title": "BarButtonItemにSentEventのTouchUpInsideは設定できますか?",
"view_count": 116
} | [
{
"body": "`Touch Up Inside`や`Editing\nChanged`は[`UIControl`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIControl_Class/)由来の機能なので、[`UIBarButtonItem`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBarButtonItem_Class/)では利用できません。\n\n`UIBarButtonItem`がなぜ`UIControl`継承ではないかというと、`UIBarButtonItem`そのものはボタンのようなUI要素ではなく、「バーに表示されるボタンやその他の要素」を抽象化したクラスだからです。\n\n>\n> UITextFieldに入力項目がキチンと入力されていないとButtonを押せないような設定をしたいのですが、BarButtonItemでは不可能なのでしょうか?\n\n実現したいことはこちらだと思うのですが、`UIBarButtonItem`を`Referencing\nOutlet`で紐付けているのですから、条件に応じて`self.tourokuButton`の`enabled`プロパティを変更すれば良いと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T03:46:00.980",
"id": "24844",
"last_activity_date": "2016-05-14T03:46:00.980",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5337",
"parent_id": "24822",
"post_type": "answer",
"score": 1
}
]
| 24822 | 24844 | 24844 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "listViewのアイテムが10個スクリーンに表示されていて、11個目がスクリーン外にあるとします。11個すべてのデータを取得したいのですが、11個目のデータへの参照の取り方がわかりません。 \n以下のコードを実行すると11個目の参照を得ようとしたときにnull pointer exceptionがでてしまいます。\n\n```\n\n public void saveData() {\n StringBuffer buffer = new StringBuffer();\n int count = listView.getCount();\n for (int i = 0; i < count; i++) {\n View child = listView.getChildAt(i);\n TextView setText1 = (TextView) child.findViewById(R.id.TextView1);\n EditText text = (EditText) child.findViewById(R.id.setText1);\n String content1 = setText1.getText().toString().trim();\n String content2 = text.getText().toString().trim();\n buffer.append(content1);\n buffer.append(\",\");\n buffer.append(content2);\n buffer.append(\",\");\n }\n }\n \n```\n\n* * *\n```\n\n public class CustomAdapter extends ArrayAdapter<String> {\n \n public CustomAdapter(Context context, List<String> num_set) {\n super(context, R.layout.custom_row, num_set);\n }\n \n @Override\n public View getView(int position, View convertView, ViewGroup parent) {\n LayoutInflater inflater = LayoutInflater.from(getContext());\n View CustomView = inflater.inflate(R.layout.custom_row, parent, false);\n \n \n String[] num = getItem(position).split(\",\");\n TextView setText1 = (TextView) CustomView.findViewById(R.id.TextView1);\n EditText setText2 = (EditText) CustomView.findViewById(R.id.setText2);\n \n setText1.setText(num[0]);\n setText2.setText(num[1]);\n return CustomView;\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T11:46:38.963",
"favorite_count": 0,
"id": "24825",
"last_activity_date": "2016-05-14T03:32:39.777",
"last_edit_date": "2016-05-14T03:31:36.003",
"last_editor_user_id": "5337",
"owner_user_id": "15484",
"post_type": "question",
"score": 1,
"tags": [
"android"
],
"title": "android Listviewのスクリーン外のアイテムへの参照を取得する方法",
"view_count": 2660
} | [
{
"body": "`ListView`からデータを取得するのではなく、`Adapter`からデータを取得しましょう。ここでは`CustomAdapter`を使用していると仮定します。\n\n```\n\n public void saveData() {\n StringBuffer buffer = new StringBuffer();\n \n CustomAdapter adapter = (CustomAdapter)listView.getAdapter();\n for(int i = 0, length = adapter.getCount(); i < length; i++) {\n String[] rowData = adapter.getItem(i).split(\",\");\n buffer.append(String.format(\"%s,%s,\", rowData[0].trim(), rowData[1].trim()));\n }\n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T03:32:39.777",
"id": "24843",
"last_activity_date": "2016-05-14T03:32:39.777",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5337",
"parent_id": "24825",
"post_type": "answer",
"score": 1
}
]
| 24825 | null | 24843 |
{
"accepted_answer_id": "24971",
"answer_count": 2,
"body": "elasticsearchのバージョン1.5.1\n\nElasticsearchでインデックス作成時に以下のようなエラーが出ます\n\n$ curl -XPOST localhost:9200/new_index -d @settings.json\n\n* * *\n\nエラー\n\nnested: IndexCreationException[[new_index] failed to create index]; \nnested: FailedToResolveConfigException[Failed to resolve config path\n[products_synonyms.txt], tried file path [products_synonyms.txt], path file\n[/etc/elasticsearch/products_synonyms.txt], and classpath\n\n* * *\n\nsettings.json\n\n```\n\n \"settings\": {\n \"analysis\": {\n \"analyzer\": {\n \"products_analyzer\" : {\n \"type\" : \"custom\",\n \"tokenizer\" : \"kuromoji_products_dict\",\n \"filter\" : [\"products_synonym\", \"lowercase\"]\n }\n },\n \"tokenizer\" : {\n \"kuromoji_products_dict\" : {\n \"type\" : \"kuromoji_tokenizer\",\n \"mode\" : \"search\",\n \"discard_punctuation\" : \"true\"\n }\n },\n \"filter\" : {\n \"products_synonym\" : {\n \"type\" : \"synonym\",\n \"synonyms_path\" : \"products_synonyms.txt\"\n }\n }\n }\n }\n \n```\n\n* * *\n\nsynonyms_pathがまちがっているっぽいのですが、pathはどこに設定すればいいのでしょうか??またsynonymを定義したファイルはどこに置けばいいのでしょうか??\n\nちなみにこのエラーのときにsynonymを定義したファイルは`/etc/elasticsearch/products_synonyms.txt`に置いてます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T13:21:47.770",
"favorite_count": 0,
"id": "24828",
"last_activity_date": "2016-05-18T11:59:13.700",
"last_edit_date": "2016-05-16T01:28:40.127",
"last_editor_user_id": "8558",
"owner_user_id": "8558",
"post_type": "question",
"score": 1,
"tags": [
"elasticsearch"
],
"title": "FailedToResolveConfigException Failed to resolve config path",
"view_count": 87
} | [
{
"body": "エラーを見る限り、\n\n```\n\n /etc/elasticsearch/products_synonyms.txt\n \n```\n\nに配置すれば一応は解決するのではないかと思っていますが、どうでしょうか。",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T05:11:33.813",
"id": "24847",
"last_activity_date": "2016-05-14T05:11:33.813",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "24828",
"post_type": "answer",
"score": 1
},
{
"body": "自己解決ですが、、\n\n`$ curl localhost:9200/_nodes?pretty`\n\nでnode見ると、nodeが「Needle」(node名)、「Jean Grey」(node名)があった。 \n「Needle」があるインスタンスにproducts_synonyms.txtは配置していたが、「Jean\nGrey」には配置していなかった。配置後にエラー起きずインデックス作成できた。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T11:59:13.700",
"id": "24971",
"last_activity_date": "2016-05-18T11:59:13.700",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8558",
"parent_id": "24828",
"post_type": "answer",
"score": 1
}
]
| 24828 | 24971 | 24847 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "うまくいかないので教えてください。\n\nまずこの枠内にユーザーに文字や画像を入力してもらいます。\n\n```\n\n <div id=\"editor\" contenteditable=\"true\"></div>\n \n```\n\n入力後このボタンをユーザーに押してもらうことをトリガに\n\n```\n\n <input type=\"buttun\" onclick=\"add()\">\n \n```\n\njQueryを実行して、\n\n```\n\n function add() {\n var editor = $(\"#editor\").val();\n $.mobile.changePage($(\"#list-page\"));\n $(\"#list\").append(\"<li>” + \"<p>\" + editor + \"</p></li>\")\n $(\"#list\").listview('refresh');\n };\n \n```\n\n以下のリストビューにユーザーが入力した内容を反映\n\n```\n\n <div data-role=\"page\" id=\"list-page\">\n <ul data-role=\"listview\" data-inset=\"true\" id=\"list\"></ul>\n </div>\n \n```\n\nという流れにしたいのですが、ボタンを押しても先に進めずに困っています。 \n上記のコードに何か間違いはあるでしょうか。",
"comment_count": 2,
"content_license": "CC BY-SA 4.0",
"creation_date": "2016-05-13T14:38:56.910",
"favorite_count": 0,
"id": "24829",
"last_activity_date": "2019-07-10T08:06:38.993",
"last_edit_date": "2019-07-10T08:06:38.993",
"last_editor_user_id": "32986",
"owner_user_id": "15427",
"post_type": "question",
"score": 0,
"tags": [
"jquery",
"html5"
],
"title": "div contenteditable=\"true\"でユーザーに入力してもらった値の渡し方",
"view_count": 710
} | [
{
"body": "[jQueryのリファレンス](http://api.jquery.com/val/)には`div`に`.val()`が使えるとは書いていません。おそらく、`.html()`\nなどを使う必要があります。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T15:58:21.770",
"id": "24831",
"last_activity_date": "2016-05-13T15:58:21.770",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3475",
"parent_id": "24829",
"post_type": "answer",
"score": 1
}
]
| 24829 | null | 24831 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "```\n\n >>> import tqdm\n >>> from tqdm import tqdm\n >>> import time\n >>> for i in tqdm(range(100)):\n time.sleep(1)\n \n```\n\nこれを実行すると\n\n```\n\n 0%| | 0/100 [00:00<?, ?it/s]\n 1%|1 | 1/100 [00:01<01:40, 1.02s/it]\n 2%|2 | 2/100 [00:02<01:39, 1.01s/it]\n 3%|3 | 3/100 [00:03<01:38, 1.01s/it]\n \n (略)\n \n 98%|#########8| 98/100 [01:40<00:02, 1.02s/it]\n 99%|#########9| 99/100 [01:41<00:01, 1.02s/it]\n 100%|##########| 100/100 [01:42<00:00, 1.02s/it]\n \n```\n\nという風に全100行分(実際は改行なしで)表示されます。 \nこれが正しい挙動なのでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-13T17:20:17.803",
"favorite_count": 0,
"id": "24834",
"last_activity_date": "2016-05-19T16:09:31.013",
"last_edit_date": "2016-05-13T17:30:22.827",
"last_editor_user_id": null,
"owner_user_id": "15486",
"post_type": "question",
"score": 1,
"tags": [
"python"
],
"title": "Python 3 tqdm の不具合",
"view_count": 3683
} | [
{
"body": "質問の現象は、キャリッジ・リターン(`\\r`)が解釈されていない状態に見えます。\n\n`tqdm`のように画面制御を行なう場合、エスケープシーケンスを解釈出来る端末で動かす必要があります。 \n`idle`やその他のIDE付属のreplの類はエスケープシーケンスを解さない事があります。 \n質問者さんも、そういった環境で動かしているのではないでしょうか。 \n普通の端末で動かせば大丈夫です。\n\n普通の端末で動かしているのも関わらず、質問の現象が起こる場合はargusさんのコメントにある通り、端末がおかしな事になっているのかもしれません。 \nリセット出来ないようであれば再起動してしまうのがよいでしょう。\n\n* * *\n\n本題とずれますが、`from tqdm import tqdm` とする場合は、その前の`import tqdm`は不要です。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-19T16:09:31.013",
"id": "25001",
"last_activity_date": "2016-05-19T16:09:31.013",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3054",
"parent_id": "24834",
"post_type": "answer",
"score": 1
}
]
| 24834 | null | 25001 |
{
"accepted_answer_id": "24873",
"answer_count": 1,
"body": "さくらのVPSにUbuntu 14.04.4 LTSをインストールして使用しています。 \nそのサーバーにsshで接続しようとすると、 \nPermission denied (publickey). \nと表示されて、接続できません。 \nそこで、さくらのVPSコントロールパネルから、VNCコンソールでログインし、その後sshで接続すると、今度は接続できます。 \nコンソールでログインしている間は、sshで接続できるようなのです。 \nそれがなぜか分かりません。 \nどういうことなのでしょうか。",
"comment_count": 6,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T00:34:11.867",
"favorite_count": 0,
"id": "24839",
"last_activity_date": "2016-05-15T07:31:14.320",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15487",
"post_type": "question",
"score": 5,
"tags": [
"ssh"
],
"title": "コンソールからログインしている間はsshで接続できるのはなぜでしょうか。",
"view_count": 580
} | [
{
"body": "[SSH/OpenSSH/Keys - Community Help\nWiki](https://help.ubuntu.com/community/SSH/OpenSSH/Keys#Troubleshooting)\n\nデフォルトではSSHの公開鍵はホームディレクトリに置かれていますが、ホームディレクトリを暗号化した場合、何らかの方法でそのユーザーがログインするまでホームディレクトリ(に入った公開鍵)にアクセスできないため、SSHの公開鍵認証に失敗します。\n\nなのでSSHの公開鍵をホームディレクトリ以外の場所、例えば `/etc/ssh/<username>/`\nに移動することで、問題を回避できるようです。ただそれでも、ホームディレクトリが自動でマウントされないという話もあるようですが・・・。\n\n[Ubuntuでホームディレクトリを暗号化するのを止めた · hnakamur's blog at\ngithub](http://hnakamur.github.io/blog/2016/05/02/uninstall-encrypted-home-on-\nubuntu/)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T07:31:14.320",
"id": "24873",
"last_activity_date": "2016-05-15T07:31:14.320",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8000",
"parent_id": "24839",
"post_type": "answer",
"score": 6
}
]
| 24839 | 24873 | 24873 |
{
"accepted_answer_id": "24854",
"answer_count": 1,
"body": "ご無沙汰しています。 \n自作アプリの完成につきましては、大変お世話になりました。 \n無事GooglePlayストアに公開し、バグがあったので修正版を上げたいのですが、ストアに公開したときの電子署名がPCには残っておらずアップデートできずに困っております。 \nもし復元が可能ならその方法を教えていただけると助かります。 \nこの場合、ストアに公開しているものを非公開にして、もう一度別に作って公開するしかないのでしょうか?\n\nまたEclipseでapkファイルを作るときに既存のKeyStoreのものでつくりたいのですが、 \nいつもエイリアスのところが空白で毎回毎回どうしても違う電子署名で作成しないといけなくなります。\n\n[](https://i.stack.imgur.com/2zCjT.png)\n\nホームページを見てエクスポートから作成しているのですが毎回上記の画像でエイリアス(もちろん作成しているときには記入済み)が選択できずに何か解決策はないでしょうか? \nよろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T00:42:22.753",
"favorite_count": 0,
"id": "24841",
"last_activity_date": "2016-05-14T11:01:45.157",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15276",
"post_type": "question",
"score": 0,
"tags": [
"android",
"eclipse"
],
"title": "自作アプリをGooglePlayストアに公開し、アップデート版を上げたいのですがKeyStore作成のところで躓いてできそうにありません",
"view_count": 110
} | [
{
"body": "お騒がせして大変申し訳ございませんでした。 \n回答を待っていましたが、ネットで調べて自己解決しました。 \nこれからはもう少し良く調べてから質問致します。\n\nロケーションの部分をxxx.keystoreに設定することでapkファイル生成の際エイリアス欄に設定したものが表示されました。 \n閲覧有り難うございます。\n\n[](https://i.stack.imgur.com/n4ioB.png)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T11:01:45.157",
"id": "24854",
"last_activity_date": "2016-05-14T11:01:45.157",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15276",
"parent_id": "24841",
"post_type": "answer",
"score": 0
}
]
| 24841 | 24854 | 24854 |
{
"accepted_answer_id": "27258",
"answer_count": 3,
"body": "InputStreamをStringに変換しようとするとOutOfMemoryErrorが発生します。 \n変換しようとしているInputStreamはAndroidのプロジェクトのrawフォルダの中にあるバイナリファイル(5.5MB)を次のようにInputStreamに変換したものです。 \nOoMがスローされないよう改善できませんか?\n\n```\n\n InputStream is = this.getRawResouces().openRawResouce();\n \n```\n\nメモリが876MBの環境でテストしています。\n\n# ソースコード\n\n## readメソッドを使って書いたコード\n\n```\n\n static String convertInputStreamToString(InputStream is) throws IOException {\n InputStreamReader reader = new InputStreamReader(is);\n StringBuilder builder = new StringBuilder();\n char[] buf = new char[512];\n int numRead;\n while (0 <= (numRead = reader.read(buf))) {\n builder.append(buf, 0, numRead);\n }\n buf=null;\n return builder.toString();//ココでOoM発生\n } \n \n```\n\n# readLine\n\n```\n\n static String inputStreamToString(InputStream is){\n BufferedReader reader = null;\n try{\n reader = new BufferedReader(new InputStreamReader(is,\"UTF-8\"));\n }\n catch (UnsupportedEncodingException e){\n e.printStackTrace();\n }\n StringBuilder sb = new StringBuilder();\n String b = null;\n try{\n while ((b=reader.readLine()) !=null){\n sb.append(b);\n }\n }\n catch (IOException e){\n \n }\n return sb.toString();\n }\n \n```\n\n## 呼び出し元のコード\n\n```\n\n private void checkVersion() throws Throwable{\n //呼び出し元は、onResume()のonClick()\n InputStream versionStream=this.getResources().openRawResource(R.raw.git);\n \n String verchecked=Event.convertInputStreamToString(versionStream);\n //ココでreadメソッドを使って書いたコードを使って変換しようとするが、OoM発生、スローされる\n versionStream.close();//closeは書いている\n java.lang.Process p = null;\n TextView vertext=(TextView) findViewById(R.id.version);\n \n try{\n p=Runtime.getRuntime().exec(verchecked+\" version\");\n verchecked=null;//vercheckedはもう使わないからnull\n InputStream returnVerison=p.getInputStream();//結果を返す\n p=null;//pはもう使わないからnullを代入\n String ver=Event.convertInputStreamToString(returnVerison);\n returnVerison.close();\n vertext.setText(ver);\n ver=null;\n }catch (IOException e){\n e.printStackTrace();\n vertext.setText(\"取得失敗: \"+e);\n }\n vertext=null;\n }\n \n protected void onResume(){\n super.onResume();\n //このクラスはMainActivity(最初に呼び出されるActivity)から呼び出される\n Button Update=(Button) findViewById(R.id.UpdateButton);\n Update.setOnClickListener(new OnClickListener(){\n @Override\n public void onClick(View p1){\n try{\n checkVersion();\n }catch(OutOfMemoryError e){\n e.printStackTrace();\n Toast.makeText(GitUpdate.this,\"取得失敗:\"+e,Toast.LENGTH_SHORT).show();\n }\n }\n });\n \n```\n\n# ヒープ\n\nAndroid StudioでMemoryの様子を見てみました。一応画像貼っておきます。 \n \nへこんでいるところがInputStreamを変換したところです。 \nMB単位です。 \n`totalMemory(),MaxMemory()` \n7 ,96\n\n# スタックトレース\n\n```\n\n 06-22 20:06:54.681 W/System.err(28046): java.lang.OutOfMemoryError\n 06-22 20:06:54.681 W/System.err(28046): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)\n 06-22 20:06:54.681 W/System.err(28046): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)\n 06-22 20:06:54.681 W/System.err(28046): at java.lang.StringBuilder.append(StringBuilder.java:216)\n 06-22 20:06:54.681 W/System.err(28046): at java.lang.ProcessManager.exec(ProcessManager.java:211)\n 06-22 20:06:54.681 W/System.err(28046): at java.lang.Runtime.exec(Runtime.java:173)\n 06-22 20:06:54.681 W/System.err(28046): at java.lang.Runtime.exec(Runtime.java:246)\n 06-22 20:06:54.681 W/System.err(28046): at java.lang.Runtime.exec(Runtime.java:189)\n 06-22 20:06:54.681 W/System.err(28046): at com.jimdo.solarand.git.GitUpdate.checkVersion(GitUpdate.java:153)\n 06-22 20:06:54.681 W/System.err(28046): at com.jimdo.solarand.git.GitUpdate.access$1000009(GitUpdate.java)\n 06-22 20:06:54.681 W/System.err(28046): at com.jimdo.solarand.git.GitUpdate$100000001.onClick(GitUpdate.java:50)\n 06-22 20:06:54.681 W/System.err(28046): at android.view.View.performClick(View.java:4487)\n 06-22 20:06:54.681 W/System.err(28046): at android.view.View$PerformClick.run(View.java:18746)\n 06-22 20:06:54.691 W/System.err(28046): at android.os.Handler.handleCallback(Handler.java:733)\n 06-22 20:06:54.691 W/System.err(28046): at android.os.Handler.dispatchMessage(Handler.java:95)\n 06-22 20:06:54.691 W/System.err(28046): at android.os.Looper.loop(Looper.java:149)\n 06-22 20:06:54.691 W/System.err(28046): at android.app.ActivityThread.main(ActivityThread.java:5257)\n 06-22 20:06:54.691 W/System.err(28046): at java.lang.reflect.Method.invokeNative(Native Method)\n 06-22 20:06:54.691 W/System.err(28046): at java.lang.reflect.Method.invoke(Method.java:515)\n 06-22 20:06:54.691 W/System.err(28046): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)\n 06-22 20:06:54.691 W/System.err(28046): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)\n 06-22 20:06:54.691 W/System.err(28046): at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)\n 06-22 20:06:54.691 W/System.err(28046): at de.robv.android.xposed.XposedBridge.main(Native Method)\n 06-22 20:06:54.691 W/System.err(28046): at dalvik.system.NativeStart.main(Native Method)\n \n```\n\n# その他情報\n\n解決を早めるために、[別サイト](https://teratail.com/questions/38726)にも投稿させて頂きました。",
"comment_count": 9,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T02:48:43.797",
"favorite_count": 0,
"id": "24842",
"last_activity_date": "2016-07-01T22:25:07.747",
"last_edit_date": "2016-06-22T11:17:01.380",
"last_editor_user_id": "15185",
"owner_user_id": "15185",
"post_type": "question",
"score": 1,
"tags": [
"android",
"java"
],
"title": "AndroidでInputStreamをStringに変換しようとするとOOMが発生する",
"view_count": 1449
} | [
{
"body": "readlineがいけないのかもしれません。 \n別方法のread等を使ってみてください。 \nreadlineの対象の1行が巨大だった場合、読込時に連続した領域を確保できなくてOOMが発生している可能性が考えられます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T00:06:28.343",
"id": "24949",
"last_activity_date": "2016-05-18T00:06:28.343",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12233",
"parent_id": "24842",
"post_type": "answer",
"score": 0
},
{
"body": "もし5.5MBのサイズのファイルのすべての文字列が一行としてreadLineで読み込まれるのだとしたら、まずb:Stringにはおそらく11MBのヒープ確保が必要になります。 \nまたStringBuilderのappendではchar配列に文字列を差し込む処理で一時的に、charとString双方を確保するために、サイズが2倍必要になっているのかもしれません(すみません、nativeのコードを見ましたがそこまで把握できず/\n[たぶんここらへん](https://android.googlesource.com/platform/art/+/master/runtime/native/java_lang_String.cc))\n\n仮に22MBそこで必要になっているのだとしたら、上の画像にある75MBから空白Heap含めた約95MBを上回ってしまっているのでは?という仮定はできると思います。 \nただ上記の画像では落ちてないっぽいので、この仮定の前提が違う気がしますけど。\n\n※というか画像のonResumeにsleep書いてるのやばい気がしますけど…。もっと他に何かあるだろうという気がしてきますね…。",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T02:19:13.550",
"id": "24954",
"last_activity_date": "2016-05-18T02:19:13.550",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15237",
"parent_id": "24842",
"post_type": "answer",
"score": 1
},
{
"body": "結論が出ました。バイナリデータを文字列に変換するのは **無理** です。 \nむりやり文字列に変換すると、1バイトのバイナリデータがで2、3バイト程の文字と認識される場合があり、二倍、三倍くらいのヒープが消費されるためです。 \n272shin16さんが言うには\n\n> 最低でもヒープサイズが11MBは必要になるということには変わりないです。\n\nとのことです。teratailでも\n\n> バイナリデータを無理やり文字に変換しようとしていますから、 \n> 1バイトのバイナリデータが2バイトの文字に変換される場合があり、最悪2倍のメモリを消費する結果となっているのではないかと思われます。\n\nとのことです。 \nこれでは空白ヒープを上回り、最終的にはOoMが発生という流れでしょう。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-07-01T22:25:07.747",
"id": "27258",
"last_activity_date": "2016-07-01T22:25:07.747",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15185",
"parent_id": "24842",
"post_type": "answer",
"score": 1
}
]
| 24842 | 27258 | 24954 |
{
"accepted_answer_id": null,
"answer_count": 3,
"body": "python初心者です。 \nいろいろ調べながら進めているのですが、どうしてもすっきりしないので、どなたか教えていただけませんでしょうか?\n\n◆Pandasのデータフレームで、縦持ちのデータを横持ちに変換する方法です。\n\n以下のような縦持ちのデータがあるとします。(csvから読み込み)\n\n```\n\n ID number item\n 0 A 111 nn\n 1 A 123 mm\n 2 A 211 op\n 3 B 121 nm\n 4 B 333 nn\n \n```\n\nこれを、次のような横持ちデータにしたいです。 \nこれもデータフレームで出力したいのです。\n\n```\n\n ID number item number item number item\n A 111 nn 123 mm 211 op\n B 211 nm 333 nn\n \n```\n\nFor文などで地道に実行することはできたのですが、どうも処理速度を考えるとどうかなという気がします。 \nまた、拙いので、ここへの掲載を自粛いたします・・・。\n\nよろしくお願いいたします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T04:18:37.060",
"favorite_count": 0,
"id": "24845",
"last_activity_date": "2016-05-16T00:40:48.087",
"last_edit_date": "2016-05-14T07:21:13.103",
"last_editor_user_id": "15491",
"owner_user_id": "15491",
"post_type": "question",
"score": 6,
"tags": [
"python",
"pandas"
],
"title": "pythonのPandasで、縦持ちのデータを横持ちにするよい方法を教えてください。",
"view_count": 6157
} | [
{
"body": "> 出力はDataframeが理想です。\n\nシンプルと言うには程遠いですが、以下の様になります。\n\n```\n\n >>> import pandas as pd\n >>> from itertools import chain\n >>> df = pd.DataFrame([\n ['A', 111, 'nn'], ['A', 123, 'mm'], ['A', 211, 'op'],\n ['B', 121, 'nm'], ['B', 333, 'nn'],\n ], columns=['ID','number','item'])\n \n >>> df\n ID number item\n 0 A 111 nn\n 1 A 123 mm\n 2 A 211 op\n 3 B 121 nm\n 4 B 333 nn\n \n >>> df2 = df.groupby('ID')\\\n .apply(\n lambda x:\n pd.DataFrame([[list(x.ID)[0]] +\n list(chain.from_iterable(zip(x.number, x.item)))]))\\\n .reset_index(drop=True)\n \n >>> df2.columns = ['ID'] + list(chain.from_iterable(\n [['number'+str(i+1), 'item'+str(i+1)]\n for i in range((len(df2.columns)-1)/2)]))\n \n >>> df2\n ID number1 item1 number2 item2 number3 item3\n 0 A 111 nn 123 mm 211 op\n 1 B 121 nm 333 nn NaN NaN\n \n```\n\nカラムが足りない部分は `NaN` になります。何か特定の値を入れたい場合は `fillna()` を使うと良いかと思います。",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T06:01:00.637",
"id": "24849",
"last_activity_date": "2016-05-14T13:04:27.560",
"last_edit_date": "2016-05-14T13:04:27.560",
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24845",
"post_type": "answer",
"score": 0
},
{
"body": "`groupby`でグループ化し, `apply`でグループ内の要素を結合する関数`f`を適用します.\n`DataFrame`のまま結合するので同じcolumn名は使えないので,ここでは`number`,`number1`,`number2`,...のように末尾に数字を加えるた新たなcolumnにしています(`rsuffix='{0}'.format(i)`のところ).\nこれで以下のようにDataFrameを作れます.\n\n```\n\n def f(a): \n a.index = [0 for i in range(len(a))]\n del a['ID']\n out = a[0:1]\n for i in range(1, len(a)):\n out = out.join(a[i:i+1], rsuffix='{0}'.format(i))\n return out\n \n df = pd.DataFrame([['A', 111, 'nn'], ['A', 123, 'mm'], ['A', 211, 'op'],\n ['B', 121, 'nm'], ['B', 333, 'nn']], columns=['ID','number','item'])\n \n df2 = df.groupby(df['ID']).apply(f)\n \n```\n\n出力してみると以下のようになっています.\n\n```\n\n >>>> print(df2)\n item item1 item2 number number1 number2\n ID \n A 0 nn mm op 111 123 211.0\n B 0 nm nn NaN 121 333 Nan \n \n```\n\nただこのままではindexがよけいな0がはいってMultiindexになっているのがうっとおしいので以下のようにすれば,0を消してSingleindexにできます.\n\n```\n\n >>>> df3 = pandas.DataFrame(df2.to_records())\n >>>> del df3['level_0']\n >>>> print(df3)\n ID item item1 item2 number number1 number2\n 0 A nn mm op 111 123 211.0\n 1 B nm nn NaN 121 333 NaN \n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T07:56:08.550",
"id": "24852",
"last_activity_date": "2016-05-14T08:10:41.103",
"last_edit_date": "2016-05-14T08:10:41.103",
"last_editor_user_id": "14418",
"owner_user_id": "14418",
"parent_id": "24845",
"post_type": "answer",
"score": 1
},
{
"body": "こんなのでもできます。 \nID毎にindexを定義できるので、ある程度応用可能です。\n\n```\n\n df[\"tmpindex\"]=df.index\n df.tmpindex=df.groupby('ID').tmpindex.rank(ascending=True)\n \n```\n\n成型はこんな感じですかね。\n\n```\n\n df[\"numberindex\"]=df.tmpindex.apply(lambda x: \"number{}\".format(int(x)))\n df[\"itemindex\"]=df.tmpindex.apply(lambda x: \"item{}\".format(int(x)))\n df_pv=pd.concat(\n [\n df.pivot(index=\"ID\", columns=\"numberindex\",values=\"number\"),\n df.pivot(index=\"ID\", columns=\"itemindex\",values=\"item\")\n ],\n axis=1)\n df_pv[\"ID\"]=df_pv.index\n df_pv.reset_index(drop=True).ix[:,[-1]+list(range(df_pv.shape[1]-1))]\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T00:40:48.087",
"id": "24888",
"last_activity_date": "2016-05-16T00:40:48.087",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15508",
"parent_id": "24845",
"post_type": "answer",
"score": 0
}
]
| 24845 | null | 24852 |
{
"accepted_answer_id": "24863",
"answer_count": 1,
"body": "質問:\n\n * ubuntu を USB にインストールしてそこからブートさせることはできますか?\n\n環境:\n\n * Ubuntu 16.04\n * Mac OS X El Capitan\n\nやったこと:\n\nMacBookAir と USB*2 を用意して、次を実行しました。\n\n 1. 公式のインストーラー ISO を USB に焼く\n 2. インストーラー USB をブートし、もう一つの USB (以下、対象USB) に向かって ubuntu インストール実行\n 3. インストールが終わった段階で、インストーラー USB を抜いて、対象 USB のみがささった状態でブート対象を選択する方法で PC 再起動 (起動時に `alt/option`長押し) しても、 ubuntu の USB は表示されません。",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T05:21:00.843",
"favorite_count": 0,
"id": "24848",
"last_activity_date": "2016-05-14T18:36:04.303",
"last_edit_date": "2016-05-14T18:36:04.303",
"last_editor_user_id": "754",
"owner_user_id": "754",
"post_type": "question",
"score": 1,
"tags": [
"macos",
"ubuntu"
],
"title": "ubuntu を USB にインストールしてそこからブートさせることはできるか",
"view_count": 2706
} | [
{
"body": "rEFInd を利用するとひとまず、ブートさせることには成功したので、共有します。\n\n# 1\\. rEFInd をダウンロード\n\n<https://sourceforge.net/projects/refind/> からダウンロード\n\n# 2\\. Mac の SIP を無効化する\n\n 1. Mac を再起動\n 2. 起動音がなる前に Command+R を押してリカバリモード起動\n 3. 上のメニューバーから Utility -> Terminal 起動\n 4. `csrutil disable` 実行\n 5. Mac 再起動\n 6. (SIP が off のためか) grub の真っ黒い画面が表示されたが、`exit`を入力すると mac が start する\n\n# 3\\. refind-install を実行する\n\nダウンロードしておいた zip の中にある インストーラーを叩いて指示に従うとインストールできました\n\n# 4\\. Mac の SIP を有効化する\n\nリカバリモードのターミナルで `csrutil enable`\n\n# 5\\. Mac を再起動すると rEFInd の画面が表示され、 EFI の方を選択すると USB からでも ubuntu がブートする",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T18:33:55.573",
"id": "24863",
"last_activity_date": "2016-05-14T18:33:55.573",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "24848",
"post_type": "answer",
"score": 1
}
]
| 24848 | 24863 | 24863 |
{
"accepted_answer_id": "24917",
"answer_count": 1,
"body": "現在野球のデータベースを自作しています。\n\nRealmSwiftに保存するPitcherとBatterのクラスを両方設定して、現在も製作中です。 \nその途中、プロパティーの名前を変更したり、変数を追加したりしたところ、下記のようのエラーで立ち、クラッシュするようになってしまいました。\n\n```\n\n fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=0 \"Provided schema version 0 is less than last set version 1.\" UserInfo={NSLocalizedDescription=Provided schema version 0 is less than last set version 1.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-703.0.18.1/src/swift/stdlib/public/core/ErrorType.swift, line 54\n \n```\n\nschemaと書いてあるので、マイグレーション関係のエラーだと思い、SwiftDocsを参考にマイグレーション処理を行いました(下記)。\n\n```\n\n let config = Realm.Configuration(\n schemaVersion: 1,\n migrationBlock: { migration, oldSchemaVersion in\n if (oldSchemaVersion < 1) {\n }\n })\n Realm.Configuration.defaultConfiguration = config\n \n```\n\n念のためRealmに保存してあるデータも\n\n```\n\n let realm = try! Realm()\n try! realm.write {\n realm.deleteAll()\n \n```\n\nを使って初期化しながら開発をしていますが、クラスが複数になったためなのか?は不明ですが、Realmに書き込むボタンを押すとクラッシュします。 \nどこがいけないのか?お教えいただけますか? \nコードはかなり長いため、Uploadはできませが、 \nどなたか?お解りになる方がいらっしゃればお教え下さい。 \nお願いいたします。\n\n* * *\n\n追伸です。 \nマイグレーション処理をスルーすると下記エラーになります。\n\n```\n\n fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=0 \"Migration is required due to the following errors: \n - Property 'tall2' has been added to latest object model.\" UserInfo={NSLocalizedDescription=Migration is required due to the following errors: \n - Property 'tall2' has been added to latest object model.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-703.0.18.1/src/swift/stdlib/public/core/ErrorType.swift, line 54\n \n```\n\n'tall2'というのは選手の身長を示すプロパティーです。 \n変数の中で一番最後に設定をしました。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T06:51:36.930",
"favorite_count": 0,
"id": "24850",
"last_activity_date": "2016-05-17T04:47:51.647",
"last_edit_date": "2016-05-17T04:47:51.647",
"last_editor_user_id": "5519",
"owner_user_id": "13156",
"post_type": "question",
"score": -2,
"tags": [
"swift"
],
"title": "RealmSwiftのマイグレーションエラーが解決できない",
"view_count": 4644
} | [
{
"body": "```\n\n \"Provided schema version 0 is less than last set version 1.\"\n \n```\n\n上記のエラーメッセージに書いてある通り、最後に設定されたスキーマバージョンは1なので、2以上の値を設定する必要があります。\n\nスキーマ(データ構造)が変わるたびに、古いデータを残すのであればマイグレーションが必要です。その時、スキーマバージョンは必ず前のバージョンより大きい値を指定しなければなりません。\n\n```\n\n \"Migration is required due to the following errors: \n \n```\n\nマイグレーション処理を無くしたときに出たという上記のエラーは文字どおり、スキーマ(データ構造)が変わっているのでマイグレーションが必要だというエラーです。マイグレーション処理を書くか、古いファイルを削除してやり直してください。",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T03:59:35.483",
"id": "24917",
"last_activity_date": "2016-05-17T03:59:35.483",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "24850",
"post_type": "answer",
"score": 2
}
]
| 24850 | 24917 | 24917 |
{
"accepted_answer_id": "24862",
"answer_count": 1,
"body": "```\n\n <link rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/milligram/1.1.0/milligram.min.css\"> \n \n```\n\n上記のタグを`<head>〜</head>`内に追加すると、CSSフレームワークのMilligramを利用することができますが、Milligramのデフォルトテーマカラーの紫色を好きな色に変更するにはどうすれば良いですか?\n\nCDNを利用せずにCSSをダウンロードして全ての`#9b4dca`(紫色)を好きな色に書き換えれば可能ですが、公式に配布されているコードに手を加えたくないと考えています。\n\n何か素敵なアイディアがあれば是非教えてください!よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T13:22:12.203",
"favorite_count": 0,
"id": "24857",
"last_activity_date": "2016-05-15T13:05:32.587",
"last_edit_date": "2016-05-15T13:05:32.587",
"last_editor_user_id": "5840",
"owner_user_id": "5840",
"post_type": "question",
"score": 0,
"tags": [
"css"
],
"title": "Milligramのデフォルトテーマカラーの紫色を好きな色に変更する方法",
"view_count": 709
} | [
{
"body": "Milligramではデフォルトテーマカラーを変更する方法は提供されていません。\n\n読み込むcssを読み込む前に置換することが出来ればいいのですが、そういった手段も同様にブラウザには提供されていません。\n\nそこで、javascriptを利用して無理やりスタイルを上書きする方法が考えられます。\n\n**cssをjsで読み直してカラーを置換して上書きする方法**\n\n以下のコードを`head`タグ内に貼り付け、milligram.cssを読み込んでいる`link`タグの`color`属性の値にお好きなカラーコードを設定してください。\n\n```\n\n <link rel=\"stylesheet\" color=\"orange\" href=\"//cdnjs.cloudflare.com/ajax/libs/milligram/1.1.0/milligram.min.css\">\n <script>\n !function(){var e=new XMLHttpRequest,t=document.querySelectorAll(\"link[color]\")[0];e.timeout=3e4,e.open(\"get\",t.getAttribute(\"href\"),!0),e.onreadystatechange=function(){if(200==this.status&&\"\"!=this.responseText){e.onreadystatechange=null;var n=this.responseText,a=t.getAttribute(\"color\");n=n.replace(/#9b4dca/g,a);var o=document.getElementsByTagName(\"head\").item(0),r=document.createElement(\"style\"),s=document.createTextNode(n);r.media=\"screen\",r.type=\"text/css\",r.appendChild(s),o.appendChild(r)}},e.send()}();\n </script>\n \n```\n\nしかし、スタイルを変更するためだけにcssを読み直すのは馬鹿馬鹿しいので、Milligramのソースコードからカラーにまつわるcss部分だけ抜き出すことでajaxを利用しない手段も考えてみました。\n\nまた、Milligramでは`select`ボックスの逆三角形マークに紫色のsvg画像を利用しているため、カラー置換のみでは全てのテーマカラーを変更することはできません。そこで、selectボックスにフォーカスが当たった時に紫色に変更しないよう対策してみました。こちらは根本的解決にはなりませんが、フォーカスが当たった時に逆三角形マークの色まで変わらなくても見た目は悪くないと思います。\n\n**css再読み込みも発生せずselectボックス問題にも対処した方法(コード長いです)**\n\n以下のコードをheadタグ内に貼り付け、`script`タグ内の`<<< Setting a milligram theme\ncolor!`と書いてある箇所にお好きなカラーコードを設定してください。\n\n```\n\n <link rel=\"stylesheet\" color=\"blue\" href=\"//cdnjs.cloudflare.com/ajax/libs/milligram/1.1.0/milligram.min.css\">\n <script>\n !function(f){f('orange'/* <<< Setting a milligram theme color! */)}(function(c){var h=document.getElementsByTagName('head')[0],s=document.createElement('style'),r=document.createTextNode(\".button,.button.button-disabled:focus,.button.button-disabled:hover,.button[disabled]:focus,.button[disabled]:hover,button,button.button-disabled:focus,button.button-disabled:hover,button[disabled]:focus,button[disabled]:hover,input[type=button],input[type=button].button-disabled:focus,input[type=button].button-disabled:hover,input[type=button][disabled]:focus,input[type=button][disabled]:hover,input[type=reset],input[type=reset].button-disabled:focus,input[type=reset].button-disabled:hover,input[type=reset][disabled]:focus,input[type=reset][disabled]:hover,input[type=submit],input[type=submit].button-disabled:focus,input[type=submit].button-disabled:hover,input[type=submit][disabled]:focus,input[type=submit][disabled]:hover{background-color:#9b4dca;border-color:#9b4dca}.button.button-clear,.button.button-clear.button-disabled:focus,.button.button-clear.button-disabled:hover,.button.button-clear:focus,.button.button-clear:hover,.button.button-clear[disabled]:focus,.button.button-clear[disabled]:hover,.button.button-outline,.button.button-outline.button-disabled:focus,.button.button-outline.button-disabled:hover,.button.button-outline[disabled]:focus,.button.button-outline[disabled]:hover,a,button.button-clear,button.button-clear.button-disabled:focus,button.button-clear.button-disabled:hover,button.button-clear:focus,button.button-clear:hover,button.button-clear[disabled]:focus,button.button-clear[disabled]:hover,button.button-outline,button.button-outline.button-disabled:focus,button.button-outline.button-disabled:hover,button.button-outline[disabled]:focus,button.button-outline[disabled]:hover,input[type=button].button-clear,input[type=button].button-clear.button-disabled:focus,input[type=button].button-clear.button-disabled:hover,input[type=button].button-clear:focus,input[type=button].button-clear:hover,input[type=button].button-clear[disabled]:focus,input[type=button].button-clear[disabled]:hover,input[type=button].button-outline,input[type=button].button-outline.button-disabled:focus,input[type=button].button-outline.button-disabled:hover,input[type=button].button-outline[disabled]:focus,input[type=button].button-outline[disabled]:hover,input[type=reset].button-clear,input[type=reset].button-clear.button-disabled:focus,input[type=reset].button-clear.button-disabled:hover,input[type=reset].button-clear:focus,input[type=reset].button-clear:hover,input[type=reset].button-clear[disabled]:focus,input[type=reset].button-clear[disabled]:hover,input[type=reset].button-outline,input[type=reset].button-outline.button-disabled:focus,input[type=reset].button-outline.button-disabled:hover,input[type=reset].button-outline[disabled]:focus,input[type=reset].button-outline[disabled]:hover,input[type=submit].button-clear,input[type=submit].button-clear.button-disabled:focus,input[type=submit].button-clear.button-disabled:hover,input[type=submit].button-clear:focus,input[type=submit].button-clear:hover,input[type=submit].button-clear[disabled]:focus,input[type=submit].button-clear[disabled]:hover,input[type=submit].button-outline,input[type=submit].button-outline.button-disabled:focus,input[type=submit].button-outline.button-disabled:hover,input[type=submit].button-outline[disabled]:focus,input[type=submit].button-outline[disabled]:hover{color:#9b4dca}input[type=email]:focus,input[type=number]:focus,input[type=password]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=url]:focus,pre,select:focus,textarea:focus{border-color:#9b4dca}select:focus{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiICAgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMjkgMTQiICAgaGVpZ2h0PSIxNHB4IiAgIGlkPSJMYXllcl8xIiAgIHZlcnNpb249IjEuMSIgICB2aWV3Qm94PSIwIDAgMjkgMTQiICAgd2lkdGg9IjI5cHgiICAgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgICBpbmtzY2FwZTp2ZXJzaW9uPSIwLjQ4LjQgcjk5MzkiICAgc29kaXBvZGk6ZG9jbmFtZT0iY2FyZXQtZ3JheS5zdmciPjxtZXRhZGF0YSAgICAgaWQ9Im1ldGFkYXRhMzAzOSI+PHJkZjpSREY+PGNjOldvcmsgICAgICAgICByZGY6YWJvdXQ9IiI+PGRjOmZvcm1hdD5pbWFnZS9zdmcreG1sPC9kYzpmb3JtYXQ+PGRjOnR5cGUgICAgICAgICAgIHJkZjpyZXNvdXJjZT0iaHR0cDovL3B1cmwub3JnL2RjL2RjbWl0eXBlL1N0aWxsSW1hZ2UiIC8+PC9jYzpXb3JrPjwvcmRmOlJERj48L21ldGFkYXRhPjxkZWZzICAgICBpZD0iZGVmczMwMzciIC8+PHNvZGlwb2RpOm5hbWVkdmlldyAgICAgcGFnZWNvbG9yPSIjZmZmZmZmIiAgICAgYm9yZGVyY29sb3I9IiM2NjY2NjYiICAgICBib3JkZXJvcGFjaXR5PSIxIiAgICAgb2JqZWN0dG9sZXJhbmNlPSIxMCIgICAgIGdyaWR0b2xlcmFuY2U9IjEwIiAgICAgZ3VpZGV0b2xlcmFuY2U9IjEwIiAgICAgaW5rc2NhcGU6cGFnZW9wYWNpdHk9IjAiICAgICBpbmtzY2FwZTpwYWdlc2hhZG93PSIyIiAgICAgaW5rc2NhcGU6d2luZG93LXdpZHRoPSI5MDMiICAgICBpbmtzY2FwZTp3aW5kb3ctaGVpZ2h0PSI1OTQiICAgICBpZD0ibmFtZWR2aWV3MzAzNSIgICAgIHNob3dncmlkPSJ0cnVlIiAgICAgaW5rc2NhcGU6em9vbT0iMTIuMTM3OTMxIiAgICAgaW5rc2NhcGU6Y3g9Ii00LjExOTMxODJlLTA4IiAgICAgaW5rc2NhcGU6Y3k9IjciICAgICBpbmtzY2FwZTp3aW5kb3cteD0iNTAyIiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjMwMiIgICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjAiICAgICBpbmtzY2FwZTpjdXJyZW50LWxheWVyPSJMYXllcl8xIj48aW5rc2NhcGU6Z3JpZCAgICAgICB0eXBlPSJ4eWdyaWQiICAgICAgIGlkPSJncmlkMzA0MSIgLz48L3NvZGlwb2RpOm5hbWVkdmlldz48cG9seWdvbiAgICAgcG9pbnRzPSIwLjE1LDAgMTQuNSwxNC4zNSAyOC44NSwwICIgICAgIGlkPSJwb2x5Z29uMzAzMyIgICAgIHRyYW5zZm9ybT0ibWF0cml4KDAuMzU0MTEzODcsMCwwLDAuNDgzMjkxMSw5LjMyNDE1NDUsMy42MjQ5OTkyKSIgICAgIHN0eWxlPSJmaWxsOiNkMWQxZDE7ZmlsbC1vcGFjaXR5OjEiIC8+PC9zdmc+)}\".replace(/#9b4dca/g,c));s.media='screen';s.type='text/css';s.appendChild(r);h.appendChild(s);});\n </script>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T16:25:04.733",
"id": "24862",
"last_activity_date": "2016-05-15T12:53:26.423",
"last_edit_date": "2016-05-15T12:53:26.423",
"last_editor_user_id": "8351",
"owner_user_id": "8351",
"parent_id": "24857",
"post_type": "answer",
"score": 0
}
]
| 24857 | 24862 | 24862 |
{
"accepted_answer_id": "24872",
"answer_count": 2,
"body": "iTunesのsearch APIでアプリを取得したいのですが、 \n120万件のアプリがあるようなのですが、 \n仮にAPIで50件習得できたとしても2万4千回以上叩く必要があります。 \nそれで、質問なのですが以下の2点大丈夫でしょうか?\n\n1、連続して2万4千回APIを叩いても大丈夫か?(レートリミットなど)\n\n2、法的な問題などにならないか?\n\n以上教えていただきたいです。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T14:04:24.683",
"favorite_count": 0,
"id": "24858",
"last_activity_date": "2016-05-16T01:07:44.517",
"last_edit_date": "2016-05-15T16:36:18.153",
"last_editor_user_id": "754",
"owner_user_id": "15498",
"post_type": "question",
"score": 3,
"tags": [
"api",
"app-store"
],
"title": "iTunes Search API での大量データ取得について",
"view_count": 2254
} | [
{
"body": "Apple公式の以下のページを見る限りでは、具体的な制限の有無や内容については言及されていないようですね。\n\n<https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-\nservice-search-api/>\n\nただ実際には、ある程度連続して呼び出したら403エラーが返るようになったという情報が英語版StackOverflowに寄せられています。\n\n * [iTunes search JSON API returning 403 forbidden on server - Stack Overflow](https://stackoverflow.com/q/16957243/2818869)\n * [iTunes Search API rate limit - Stack Overflow](https://stackoverflow.com/q/12596300/2818869)\n\n> 120万件のアプリがあるようなのですが、仮にAPIで50件習得できたとしても2万4千回以上叩く必要があります。\n\n全件取得したいようですが、冒頭の説明ページを見る限りでは `page`\nなどのパラメータが存在せず、2ページ目以降を取得することはできないように思います。よって取得できるのは `limit`\nパラメータに指定できる最大値である200件が限度でしょう。\n\niTunes Storeの掲載データをまとめてダウンロードできる [Enterprise Partner\nFeed](https://affiliate.itunes.apple.com/resources/documentation/itunes-\nenterprise-partner-feed/) の利用を検討した方がいいかもしれません。(SearchAPIと異なり、申請が必要ですが)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T07:14:47.630",
"id": "24872",
"last_activity_date": "2016-05-15T07:14:47.630",
"last_edit_date": "2017-05-23T12:38:55.307",
"last_editor_user_id": "-1",
"owner_user_id": "8000",
"parent_id": "24858",
"post_type": "answer",
"score": 5
},
{
"body": "公式のドキュメントに記載はないようですが、offsetを指定できるので、全件取得はがんばればできそうですが、 (\n<https://syncer.jp/itunes-api-matome> ) \n他の方が回答されているように、403の件もあるので、どうしてもAPIを使いたいなら一定時間あけたりなどの工夫と、かなり時間がかかることへの対応が必要でしょうね。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T01:07:44.517",
"id": "24890",
"last_activity_date": "2016-05-16T01:07:44.517",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15510",
"parent_id": "24858",
"post_type": "answer",
"score": 1
}
]
| 24858 | 24872 | 24872 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "サーバーでEmployee とういうjsonを作成し、画面表示時に以下のようにデータを画面に渡して、 \nこのdata-\nemployeeをなんとかknockout.jsで取得して、knockout.jsの方でデータを編集したものをeditedListとして画面のテーブルに表示したいですが\nこのEmployeeのデータをどうやったらknockout.jsの方で読み込めるのでしょうか?\n\n・ HTML\n\n```\n\n <table id=\"table\" data-employee={{ Emplyee }}>\n <thead>\n <tr>\n <td>名前</td>\n <td>苗字</td>\n .\n .\n </tr>\n </thread>\n <tbody data-bind=\"foreach: editedList\">\n <tr>\n <td data-bind=\"text: firstName\"></td>\n <td data-bind=\"text: secondName\"></td>\n .\n . \n </tr>\n </body>\n </table>\n \n```\n\n・ Knockout.js\n\n```\n\n //1. ここにEmployeeデータを取得する処理\n \n //2. Employeeデータを使って一覧表示用データを作成する\n \n //3. 2で作成したデータを以下のような感じで画面にバインドする\n ko.applyBindings({\n editedList: [\n { firstName: 'Bert', entryDate: 'xxxx-xx-xx' },\n { firstName: 'Charles', lastName: 'xxxx-xx-xx' },\n { firstName: 'Denise', lastName: 'xxxx-xx-xx' }\n ]\n });\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T14:21:17.287",
"favorite_count": 0,
"id": "24859",
"last_activity_date": "2016-11-21T16:03:28.093",
"last_edit_date": "2016-05-15T06:41:48.807",
"last_editor_user_id": "8000",
"owner_user_id": "15499",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"knockout.js",
"sails.js"
],
"title": "knockout.js で サーバからビューに送られたJSONを取得したい。",
"view_count": 399
} | [
{
"body": "data-employee には json 文字列として渡し、kockout 側で JSON.parse にすれば良い、という回答なのですが、json\nの作り方はサーバサイドの言語によって異なります。 \n何をお使いなのでしょうか?\n\n一例として、rails だとこんな感じになりそうです \n(スミマセン。今は手元に環境がないので、イメージです。 \nraw はサニタイズせずに出力、escapse_javascript は json を文字列化するのに必要なはずです。)\n\n```\n\n # sample.html.erb\n <table id=\"table\" data-employee='<%= escape_javascript(raw(@employee.to_json))) %>'>\n \n # sample.js\n jsonString = $(\"#table\").data(\"employee\");\n employee = JSON.parse(jsonString);\n \n```",
"comment_count": 4,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-14T23:45:26.897",
"id": "24865",
"last_activity_date": "2016-05-14T23:45:26.897",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7471",
"parent_id": "24859",
"post_type": "answer",
"score": 1
}
]
| 24859 | null | 24865 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "今、Windowsを使っていて、QtでDirectXを使いたかったので、質問させていただきます。 \nちなみに、C++で書いてます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T03:52:04.643",
"favorite_count": 0,
"id": "24867",
"last_activity_date": "2016-11-09T10:20:41.873",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15503",
"post_type": "question",
"score": 0,
"tags": [
"qt5"
],
"title": "Qt5.7.を使っているのですが、DirectXを使うにはどうしたらいいのでしょうか",
"view_count": 731
} | [
{
"body": "[この記事](http://qiita.com/Chironian/items/acb465f388aa75f5d6a5)が参考にならないでしょうか。(リンク先はQt5.4を使った記事です。5.7の場合、C++11対応のコンパイラが必要らしいです)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-27T09:22:33.357",
"id": "25222",
"last_activity_date": "2016-05-27T09:22:33.357",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9515",
"parent_id": "24867",
"post_type": "answer",
"score": 1
}
]
| 24867 | null | 25222 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "ipython notebookで、誤って「cut\ncell」で複数の削除してしまったCellを復元させる方法、もしくは開いた最初の状態に戻す方法でも構いません。\n\n「Edit」→「Undo Delete Cell」ではひとつしか戻りません。\n\nauto saveされてしまっているので、復元は無理なのでしょうか・・・?\n\nコピーしていなかったので、悔やまれてなりません。 \nどうかお助けください。。。\n\n※Windows使用です。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T06:42:48.067",
"favorite_count": 0,
"id": "24870",
"last_activity_date": "2016-05-15T14:30:31.353",
"last_edit_date": "2016-05-15T06:52:17.450",
"last_editor_user_id": "15491",
"owner_user_id": "15491",
"post_type": "question",
"score": 0,
"tags": [
"python"
],
"title": "ipython notebookで、削除したCellの復元方法を教えてください。",
"view_count": 18584
} | [
{
"body": "復元したいcellが以前に評価したことがあるcellであれば\n\n```\n\n >>>> %history\n \n```\n\nで履歴を表示したり, リスト`In`に過去の入力の履歴が保持されているのでそれを確認してみます.\n\nあと試したことはないですが, checkpointが作成されていればメニューの File->Revert to Checkpoint\nでcheckpointに戻せるようです.",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T07:52:49.087",
"id": "24874",
"last_activity_date": "2016-05-15T14:30:31.353",
"last_edit_date": "2016-05-15T14:30:31.353",
"last_editor_user_id": "14418",
"owner_user_id": "14418",
"parent_id": "24870",
"post_type": "answer",
"score": 1
}
]
| 24870 | null | 24874 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "先ほど、Android Studioで突然実機が認識されなくなりました。 \n今まではつながっていたのですが。。。\n\nUSBケーブルを変えてもダメだったのですが何かわかる方いましたら教えてください。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T06:45:27.083",
"favorite_count": 0,
"id": "24871",
"last_activity_date": "2016-05-20T18:15:46.823",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15279",
"post_type": "question",
"score": -5,
"tags": [
"android"
],
"title": "Android Studioで実機が認識されない",
"view_count": 15087
} | [
{
"body": "1、Android端末を再起動 \n2、\"adb server-kill\"と\"adb server-start\" \nこの二つをしてみて反応しませんかね?\n\nこの場合疑うべきは\n\n * ADB(端末側、AndroidStudio側)\n * Android端末側がデバッグONじゃなくなっている(たまーに設定が内部動作によって書き換えられることあり)\n * USBケーブル二つ\n * ドライバー(Win環境なら)\n * ポートが物理的に破損している\n * AndroidStudioのADBインテグレーション設定がオフになっている(追加)\n\nかなーと思います。\n\n* * *\n\n追記:\n\n * AndroidStudioのADBインテグレーションの確認と設定方法について\n\nAndroidStudioのメニューの`\"Tools->Android->Enable ADB\nIntegration\"`にチェックが入っているか確認してください。チェックが入っていないなら、メニューをクリックしてください。 \nその後AndroidStudioの下の方にあるAndroidMonitorにあるプルダウンから接続しているデバイスを選択するとログなりが出るようになります。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T02:43:59.193",
"id": "24956",
"last_activity_date": "2016-05-20T18:15:46.823",
"last_edit_date": "2016-05-20T18:15:46.823",
"last_editor_user_id": "15237",
"owner_user_id": "15237",
"parent_id": "24871",
"post_type": "answer",
"score": 3
}
]
| 24871 | null | 24956 |
{
"accepted_answer_id": "24879",
"answer_count": 1,
"body": "Realmで一対多の構図のデータ構造を作ろうとしているのですが、その説明の中で出てくる、LinkingObjectsが果たして私の場合に必要なのかが分かりません(利便性が分かりません) \n多対多の関係ならば、まだ必要性はわかるのですが‥‥ \n一対多の関係で、LinkingObjectsが活用できる事例があれば、どのようなものがあるか教えていただけたら幸いです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T08:26:00.240",
"favorite_count": 0,
"id": "24875",
"last_activity_date": "2016-05-15T12:20:25.723",
"last_edit_date": "2016-05-15T11:49:25.180",
"last_editor_user_id": "5519",
"owner_user_id": "15418",
"post_type": "question",
"score": 0,
"tags": [
"realm"
],
"title": "RealmのLinkingObjectsについて",
"view_count": 2486
} | [
{
"body": "LinkingObjectsは逆方向の関連を簡単に取得したいときに使います。必ず使うものではないので、現状のモデルで、使わずにうまくいってるのであれば、無理に使う必要はありません。\n\n逆方向の関連を使って1対多の関連を表現するには、正方向の関連は1対1になりますが、逆方向の関連の有無にかかわらず、1対1の関連というのは、あまり使われるものではないので、まず最初にわかりやすく1対多の関連で説明します。\n\nブログ(`Blog`)とタグ(`Tag`)という2つのテーブルがあり、ブログ記事をタグで分類できるという機能があるとします。タグには複数のブログを関連づけることができます。あるタグが付いているブログを表示するのはタグを取得して関連(`blogs`)を辿るだけです。\n\n```\n\n class Tag: Object {\n dynamic var name = \"\"\n let blogs = List<Blog>()\n }\n \n```\n\n逆に、ブログ記事にどのタグが付いているか、ということを表示したい場合もあります。 \nそのような場合に、下記のように逆方向の関連(`tags`)を設定しておけば、この関連の情報を使うだけでいいのでとても簡単です。\n\n```\n\n class Blog: Object {\n dynamic var title = \"\"\n let tags = LinkingObjects(fromType: Tag.self, property: \"blogs\")\n }\n \n```\n\n上記が逆方向の関連を用いて多対多を表現する例です。\n\n1対1の関連(逆方向の関連を使って1対多になる)の例を無理やり挙げると、ユーザー(`User`)とプロフィール(`Profile`)というテーブルがあるとします。\n\n1対1の関連は、通常1つのテーブルにできますが、カラムが多くなってきた場合など管理上の都合で分けることもあります。そのような例だと思ってください。\n\n```\n\n class User: Object {\n dynamic var id = \"\"\n dynamic var name = \"\"\n var profile: Profile?\n }\n \n```\n\nユーザーには1つのプロフィールが対応します。プロフィールの側から、ユーザーのデータも参照したい、というときに逆方向の関連を使用します。\n\n```\n\n class Profile: Object {\n dynamic var name = \"\"\n let users = LinkingObjects(fromType: User.self, property: \"profile\")\n }\n \n```\n\nまとめますと、逆方向の関連を使わずに困っていないなら無理に使う必要はありません。\n\n多対多の関連は、手作業で整合性をとるのは大変なので、逆方向の関連(`LinkingObjects`)をうまく使うと簡単に表現できます。\n\n逆方向の関連を使って1対多になるような関連は、そもそも1対1の関連というものがあまり使われるものではないので、使っていなくてもまったく問題ありません。",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T12:20:25.723",
"id": "24879",
"last_activity_date": "2016-05-15T12:20:25.723",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "24875",
"post_type": "answer",
"score": 1
}
]
| 24875 | 24879 | 24879 |
{
"accepted_answer_id": "24891",
"answer_count": 2,
"body": "現在C++を勉強中なのですが、unique_ptrの使い方でわからないことがあります。 \nオブジェクトのポインタを渡して、unique_ptrを生成する際、C++14であればヘルパー関数を使うことができると思います。しかし、そのままnewを使う場合と比べてヘルパー関数を使う利点がわかりません。\n\n例えば、下記の1点目と比較して、2点目はどのような利点があるのでしょうか?\n\n * `std::unique_ptr<int> pInt {new int{1}};`\n * `std::unique_ptr<int> pInt {std::make_unique<int>(1)};`",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T08:36:22.160",
"favorite_count": 0,
"id": "24876",
"last_activity_date": "2016-05-16T01:14:29.570",
"last_edit_date": "2016-05-15T09:42:30.837",
"last_editor_user_id": "8000",
"owner_user_id": "15485",
"post_type": "question",
"score": 3,
"tags": [
"c++"
],
"title": "make_uniqueの利点",
"view_count": 10940
} | [
{
"body": "`make_unique`を使用するとコンストラクター呼び出しではなくなるので`auto`変数が使えます。対して`std::unique_ptr`はコンストラクター呼び出しなので型名を省略できません。\n\n```\n\n std::unique_ptr<int> pInt {new int{1}};\n auto pInt = std::make_unique<int>(1);\n \n```\n\nまた前者は`std::unique_ptr`でポインター管理され自動的に`delete`されるとは言え、ソースコードの見た目上は`new`しておいて`delete`していないという非対称な構造になってしまいます。`make_unique`であればそのようなことにはなりません。\n\n* * *\n\n逆に`make_unique`はカスタム`Deleter`を指定できないという欠点があります。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T21:58:41.867",
"id": "24886",
"last_activity_date": "2016-05-15T21:58:41.867",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "24876",
"post_type": "answer",
"score": 5
},
{
"body": "```\n\n std::unique_ptr<int> pInt {new int{1}}; // (1)\n \n```\n\nと\n\n```\n\n std::unique_ptr<int> pInt {std::make_unique<int>(1)}; // (2)\n \n```\n\nの大きな違いは、`unique_ptr<int>` のインスタンスを作るのに、(1) では `new int{1}`\nが呼ばれてから、`unique_ptr<int>` のコンストラクタが呼ばれるという風に、2段階で処理が行われるのに対し、(2)\nでは、`std::make_unique<int>(1)` を呼ぶだけで作られるということです。\n\n例えば\n\n```\n\n class A;\n \n void f(std::unique_ptr<A> p1, std::unique_ptr<A> p2);\n \n```\n\nという関数があったときに、\n\n```\n\n f(std::unique_ptr<A>{new A{0}}, std::unique_ptr<A>{new A{1}}); // (3)\n \n```\n\nと呼び出したとします。ここで生成された二つの A のインスタンスは、`unique_ptr`\nになるので、きちんと解放されるように見えます。しかし、実は解放されないケースがありうるのです。\n\nC++ では、関数の引数の評価の順番は未規定です。(3) の場合だと\n\n 1. `new A{0}`\n 2. `new A{1}`\n 3. 1 で生成した A のインスタンスを用いて、一番目の `std::unique_ptr<A>` を生成\n 4. 2 で生成した A のインスタンスを用いて、二番目の `std::unique_ptr<A>` を生成\n 5. `f()` の呼び出し\n\nという順番で評価しても構わないのです。このとき 2. で A のコンストラクタが例外を投げると、1. で生成された A\nのインスタンスは、まだunique_ptr になっていないので、リークしてしまいます。\n\nここで `std::make_unique` を使えば、\n\n```\n\n f(std::make_unique<A>(0), std::make_unique<A>(1)); // (4)\n \n```\n\n 1. `std::make_unique<A>(0)` で一番目の `unique_ptr<A>` を生成\n 2. `std::make_unique<A>(1)` で二番目の `unique_ptr<A>` を生成\n 3. `f()` の呼び出し\n\nとなり、`new A{1}` が例外を発生する物であっても、メモリリークを起こすことがありません。",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T01:14:29.570",
"id": "24891",
"last_activity_date": "2016-05-16T01:14:29.570",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3605",
"parent_id": "24876",
"post_type": "answer",
"score": 4
}
]
| 24876 | 24891 | 24886 |
{
"accepted_answer_id": "24880",
"answer_count": 1,
"body": "UIButtonをデザイン修飾したいのですが、その方法に\n\n 1. Storyboardsでボタンを配置\n 2. コードから編集\n\nというふうにしています。\n\nしかし、コード側で\n\n```\n\n import UIKit\n \n class ButtonTest: UIViewController {\n \n //ボタンを登録\n @IBOutlet weak var btn1: UIButton!\n \n override func viewDidLoad() {\n super.viewDidLoad()\n \n //背景を真っ赤にする\n btn1.imageView?.backgroundColor = UIColor.redColor()\n \n }\n }\n \n```\n\nのように記述しても何も変化がありません........\n\nそもそもこのような修飾方法はあまりいいものではないのでしょうか? \n調べてみてもボタンそのものをコード側で生成して追加するものか、完全にXcodeのIDE側で設定してしまう側のどちらかしか見つからなくて........\n\nこのような方法でもうまくいく方法があれば是非とも教えてください。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T09:17:40.097",
"favorite_count": 0,
"id": "24877",
"last_activity_date": "2016-05-15T12:30:16.087",
"last_edit_date": "2016-05-15T12:23:14.787",
"last_editor_user_id": "5519",
"owner_user_id": "15418",
"post_type": "question",
"score": 1,
"tags": [
"xcode"
],
"title": "UIButtonを修飾する方法",
"view_count": 83
} | [
{
"body": "ボタンに画像が設定されてないのであれば`imageView`プロパティのサイズはゼロなので、それに背景色を設定しても外観に影響はありません。\n\n```\n\n btn1.backgroundColor = .redColor()\n \n```\n\n上記のように、直接ボタンの`backgroundColor`プロパティに色を設定すると良いのではないでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T12:30:16.087",
"id": "24880",
"last_activity_date": "2016-05-15T12:30:16.087",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "24877",
"post_type": "answer",
"score": 1
}
]
| 24877 | 24880 | 24880 |
{
"accepted_answer_id": "24884",
"answer_count": 1,
"body": "users_controller.rb\n\n```\n\n def index\n @users = User.all\n end\n \n```\n\nviews/users/index.html.erb\n\n```\n\n <p><%= @users %></p>\n \n```\n\n上記のように記述してブラウザで見ると\n\n```\n\n #<User::ActiveRecord_Relation:0x0055a772872fe8>\n \n```\n\nと表示されています。この内容はどういうことなのでしょうか?\n\n`find all`でusersテーブルのusernameを全て取り出したいのですがどのような記述になりますか?",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T15:58:11.653",
"favorite_count": 0,
"id": "24882",
"last_activity_date": "2016-05-15T17:11:09.773",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "10088",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails"
],
"title": "rails4で変数をviewに渡すと中身が出ない",
"view_count": 197
} | [
{
"body": "複数個の`user`モデルが配列のような形で格納されているので、 \nそのままでは意図した通りに表示することができません。 \n以下のように記述することで`user`毎に`username`を表示することができます。\n\n```\n\n <% @users.each do |user| %>\n <p><%= user.username %></p>\n <% end %>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T17:11:09.773",
"id": "24884",
"last_activity_date": "2016-05-15T17:11:09.773",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2646",
"parent_id": "24882",
"post_type": "answer",
"score": 2
}
]
| 24882 | 24884 | 24884 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "AWSのEC2を用いてホームページを作成しているのですが、そのホームページにお問い合わせ(メールフォーム)のページを作成しようと考えています。 \nそこで、こちらのフリーのメールフォームを用いようと頑張っているのですが、どうもうまくいきません。 \n<http://www.synck.com/contents/download/cgi-perl/mailform_jcode.html>\n\nEC2のほうでSMTPのポートを解放し、CGIの動作環境を整え、メールフォームを使用するためのJcodeを導入し、 \nフォームから送信ボタンを押して、「送信できました」という画面までは表示されるようになったのですが、メールが届きませんでした。\n\nsendmail がうまく動いていないのかな?と考え、EC2にsshでログインし\n\n```\n\n $ sudo sendmail <送信先のメールアドレス>\n \n```\n\nと、メールを送信したところ、メールが届きませんでした。\n\n```\n\n $ sudo service sendmail status \n \n```\n\nで、sendmailが動作していることは確認しました。\n\nですので、まずはsendmailがEC2で正しく動かせるように、いろいろ行っているのですが、 \nメールを送信できませんでした。 \nどうすれば、正しくsendmailを動作させることができるでしょうか。\n\nまた、メールフォームからメールを送信できない他の理由は考えられるでしょうか。\n\n追記(2016/05/19 18:38)============================================= \n「サブミッションポートを使う」ということでセキュリティグループに \nEC2サーバのほうで インバウンド カスタムTCP(587) を設定し、 \nsendmail.mc内の\n\n```\n\n DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl\n \n```\n\nのコメントアウトを解除してサブミッションポートを使用するようにしました。\n\nしかし、seamailの動作テストを以下のようにして\n\n```\n\n $ sudo sendmail ***@softbank.ne.jp\n $ From:support@<ドメイン>\n $ To:***@softbank.ne.jp\n $ Subject:テスト送信\n $\n $ テスト送信です\n $ .\n \n```\n\n/var/spool/mail/ec2-user を確認したところ送信失敗していました。\n\n```\n\n ...(略)\n Arrival-Date: Mon, 16 May 2016 09:25:09 GMT\n \n Final-Recipient: RFC822; \\*\\*\\*@softbank.ne.jp\n Action: failed\n Status: 5.1.1\n Remote-MTA: DNS; [127.0.0.1]\n Diagnostic-Code: SMTP; 550 5.1.1 <\\*\\*\\*@softbank.ne.jp>... User unknown\n Last-Attempt-Date: Mon, 16 May 2016 09:25:45 GMT\n \n --u4G9P9UN003320.\\*/ip-\\*-\\*-\\*-\\*.ap-northeast-1.compute.internal\n Content-Type: message/rfc822\n Content-Transfer-Encoding: 8bit\n ...(略)\n \n```\n\nさらに、User unknown とあったので \nlocal-host-names のファイルに ドメインを追加したのですが、うまく動作しませんでした。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-15T21:46:12.710",
"favorite_count": 0,
"id": "24885",
"last_activity_date": "2016-05-16T10:51:42.960",
"last_edit_date": "2016-05-16T09:39:16.557",
"last_editor_user_id": "13404",
"owner_user_id": "13404",
"post_type": "question",
"score": 0,
"tags": [
"aws",
"sendmail",
"amazon-ec2"
],
"title": "EC2で運営しているサイトのメールフォームからsendmailを利用したメール送信ができない",
"view_count": 9716
} | [
{
"body": "TCP/25はブロックされてるのでサブミッションポート(TCP/587)を使ってください。\n\nAmazon SES\nを使う方法もあります。アマゾンのスライドショーが参考になると思いますのでご紹介しておきます→[AWSからのメール送信](http://www.slideshare.net/AmazonWebServicesJapan/aws-30934799)\n\n**迷惑メールにならない為の対策**\n\n 1. サーバーによっては 接続元が実在するか DNS でチェックする場合があります。 \n * DNS ドメインの MX レコードが有るかどうか\n * ehlo (helo) で名乗ったホスト名を DNS クエリで正引きできるか\n * IP を逆引きして ehlo (helo) で名乗ったホストと一致するかどうか\n * MX と A レコード は Route53 を使うか、既にお使いの DNS で設定してください。\n * 逆引きは AWS に申請が必用です [申請フォーム](https://aws.amazon.com/forms/ec2-email-limit-rdns-request)\n 2. 加えて AWS では次の対応を推奨しています。SES と Rotue53 を使うと 設定は自動化できるので面倒であればSESとRoute53を使ってください。 \n * SPF(Sender Policy Framework)/Sender ID を設定する\n * DKIM(DomainKeys Identified Mail) を設定する\n 3. RBL に 現在使用中のEIPが登録されてないかチェックする \n * EIP は使い回しなので 過去の使用者が スパマーで IP がブラックリストに乗っている可能性があります。RBL に登録されていないか検索して 載っていれば EIP を再度取得すると良いでしょう。\n * [Request to Remove Email Sending Limitations](https://aws.amazon.com/forms/ec2-email-limit-rdns-request) で RBL からの登録解除の申請もできるようです。\n 4. 携帯キャリアによっては メール本文をチェックしています。本文が1行だけのメールは ブロックされることもあります。\n\nSMTP サーバーを立てるのは色々と面倒ですので、送信専用であれば SES と Route53 を使って EC2 の sendmail は SES\nにリレーするのがオススメです。",
"comment_count": 6,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T03:06:18.123",
"id": "24893",
"last_activity_date": "2016-05-16T10:51:42.960",
"last_edit_date": "2016-05-16T10:51:42.960",
"last_editor_user_id": "5008",
"owner_user_id": "5008",
"parent_id": "24885",
"post_type": "answer",
"score": 2
},
{
"body": "「送信できました」という画面が表示されるということは、おそらく、メールフォームと同じホストで稼働する sendmail\nを使ってメールを送ろうとして、メールキュー (/var/spool/clientmqueue/, /var/spool/mqueue/)\nには入るけれど、そこから外部に送信できない状況ではないかと思います。\n\n以下を確認ください。\n\n * sendmail サービスは起動していますか?\n * メールキュー (/var/spool/clientmqueue/, /var/spool/mqueue/) にファイルはありませんか?\n * メールログ (/var/log/mailog, /var/log/mail.log など)には何かエラーは出ていませんか?\n\nOS、sendmail のバージョンと sendmail の設定、ログがあると、何かわかるかもしれません。",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T09:46:48.397",
"id": "24901",
"last_activity_date": "2016-05-16T09:46:48.397",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4603",
"parent_id": "24885",
"post_type": "answer",
"score": 1
}
]
| 24885 | null | 24893 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "PDFのブックマーク(Bookmark)と注釈(Annotation)を一覧で出す方法はありますか? \nできればシステムチェックにエクスポートしたい。例えばVBA、またはコマンド行、あるいはScript。サードパーティのライブラリーを使っても構いません。よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T00:22:49.937",
"favorite_count": 0,
"id": "24887",
"last_activity_date": "2016-05-16T04:18:48.437",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15507",
"post_type": "question",
"score": 1,
"tags": [
"pdf",
"vba",
"console",
"annotations"
],
"title": "PDFのブックマークと注釈のエキスポート",
"view_count": 121
} | [
{
"body": "フリーのコマンドラインツールがあるようです。\n\n<https://www.pdflabs.com/blog/export-and-import-pdf-bookmarks/>",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T04:18:48.437",
"id": "24895",
"last_activity_date": "2016-05-16T04:18:48.437",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7471",
"parent_id": "24887",
"post_type": "answer",
"score": 1
}
]
| 24887 | null | 24895 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "react-\nrouterを使っています。そこで質問ですが、下記のDOMでTextFieldにフォーカスした状態でエンターキーを押した時に、Linkをクリックした時と同じアクションつまり(ページ遷移)を起こしたいのですがAPIなどは提供されているのでしょうか。\n\n```\n\n <div>\n <TextField\n floatingLabelText=\"huga\"\n value={this.state.huga}\n onChange={this.onLangChanged}\n /><br />\n <TextField\n floatingLabelText=\"hoge\"\n value={this.state.hoge}\n onChange={this.onPChanged}\n /><br />\n <Link to={link} onClick={this.onSubmitted}>\n <FlatButton label=\"Show\" primary={true} />\n </Link>\n <CodeAppHistory />\n </div>\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T03:55:59.723",
"favorite_count": 0,
"id": "24894",
"last_activity_date": "2016-06-21T15:33:59.373",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7232",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"reactjs"
],
"title": "react-routerでエンターキーをおした時ページ遷移したい",
"view_count": 482
} | [
{
"body": "react-router には KeyDown 検出の機構はとくにないので、onKeyDown イベントの中で\nHistoryAPIを利用してページ遷移するのがよろしいと思います。\n\nハンドラの例:\n\n```\n\n handleKeyDown(e) {\n if (e.keyCode === 13) { // Enter の場合のみ\n console.log(\"Enter Key!\")\n browserHistory.push(\"/new_path\")\n }\n }\n \n```\n\nTextfield の例:\n\n```\n\n <TextField\n floatingLabelText=\"huga\"\n value={this.state.huga}\n onChange={this.onLangChanged}\n onKeyDown={this.handleKeyDown}\n />\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-06-21T15:33:59.373",
"id": "26923",
"last_activity_date": "2016-06-21T15:33:59.373",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7495",
"parent_id": "24894",
"post_type": "answer",
"score": 1
}
]
| 24894 | null | 26923 |
{
"accepted_answer_id": "24904",
"answer_count": 1,
"body": "**実現したいこと**\n\nAサーバ(メイクショップ)のURLにアクセスしたとき、Bサーバ(自社サービス)のURLにリダイレクト処理がかかるようにしたいです\n\n**気になってること**\n\nAサーバ(メイクショップ)のURL: <http://www.example.jp/html/company.html?code=realisent> \nBサーバ(自社サービス)のURL: <http://www.example.jp/jp/our-store.html>\n\n上記を踏まえて、気になっていることがございます。\n\nBサーバに存在しないコンテンツのURL(今回で言えば、<http://www.example.jp/html/company.html?code=realisent>)をBサーバ側でリダイレクト処理はできるのでしょうか?\n\nご教授の程、よろしくお願いします。\n\n**補足情報**\n\nWeb Server: Nginx",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T04:41:14.030",
"favorite_count": 0,
"id": "24896",
"last_activity_date": "2016-05-16T10:15:30.667",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5731",
"post_type": "question",
"score": 0,
"tags": [
"nginx"
],
"title": "サーバ異なるときの、リダイレクトについての質問です",
"view_count": 171
} | [
{
"body": "リダイレクトはできるけど 404なり403になると思います。\n\n 1. クライアントはサーバーAにリクエストを行います。\n 2. サーバーAは クライアントに対して 30X レスポンスを返します。この際 Location ヘッダで サーバーB のURLを返します。\n 3. クライアントはLocation ヘッダにしたがってサーバーB のURLにリクエストを行います。\n 4. サーバーB は 存在しないURLなので 404 403 などの応答を返します。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T10:15:30.667",
"id": "24904",
"last_activity_date": "2016-05-16T10:15:30.667",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5008",
"parent_id": "24896",
"post_type": "answer",
"score": 2
}
]
| 24896 | 24904 | 24904 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "以下のjqueryで受信データの内容で、focusを変更しているのですが、IEではうまくいくのですが、chromeでは全く効きません。ご教授ください。\n\n```\n\n $.ajax(\n \n type: \"POST\", \n url : \"/aoi/TestServlet\",\n dataType:\"json\",\n data: {\"message\" : requestJson}\n }\n ).done(\n function(data, status, xhr){\n $(\"#mes\").text(data.mes);\n if(data.mes == null){\n setTimeout(function(){$('#meisyo').focus();}, 100);\n }else{\n setTimeout(function (){$(\"#code\").focus();}, 100);\n }\n }\n ).fail(\n function(xhr, status, thrown){\n console.log(\"fail: status=\" + status + \"[\" + xhr.status + \"]\");\n }\n );\n }\n \n```",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T07:41:36.410",
"favorite_count": 0,
"id": "24897",
"last_activity_date": "2016-05-24T06:12:23.873",
"last_edit_date": "2016-05-24T06:12:23.873",
"last_editor_user_id": null,
"owner_user_id": "14769",
"post_type": "question",
"score": 0,
"tags": [
"jquery"
],
"title": "jquery focusが効かない",
"view_count": 1404
} | [
{
"body": "別のパソコンでやると正常に動作しました。 \nパソコンの不具合見たいです。 \nお騒がせしました。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-23T19:28:46.717",
"id": "25123",
"last_activity_date": "2016-05-23T19:28:46.717",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "14769",
"parent_id": "24897",
"post_type": "answer",
"score": 1
}
]
| 24897 | null | 25123 |
{
"accepted_answer_id": "24903",
"answer_count": 1,
"body": "_質問を書いている途中で問題が解決したので、回答も併せて投稿させていただきます。_\n\nRaspberry\nPiをヘッドレスで運用しているのですが、`/etc/fstab`の内容が、RPiにSSHログインできるか否か、pingが通るか否かに影響してしまいます。\n\n## 環境\n\nRPi: Raspberry Pi 2 Model B \nOS: Raspbian (jessie) (クリーンインストール) \nヘッドレス \nルータのDHCPで固定IPを割当てている。\n\n`/etc/fstab`の内容(コメント行は削除)\n\n```\n\n proc /proc proc defaults 0 0\n /dev/mmcblk0p1 /boot vfat defaults 0 2\n /dev/mmcblk0p2 / ext4 defaults,noatime 0 1\n \n UUID=<外付けHDD_aのUUID> /media/<外付けHDD_aのUUID> ntfs rw,user,nosuid,nodev,uid=1002,gid=1002,dmask=0002 0 0\n \n```\n\n## 問題\n\n外付けHDD_aを接続 **せず** にRPiを起動すると、固定IPに対するpingがHost\nUnreachableになります(ルータのログに本来あるはずのIPを割り当てたというメッセージも無し)。ところが外付けHDD_aを接続して起動したり、`/etc/fstab`の最後の行をコメントアウトしておくとSSH含め正常に通信できます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T09:49:24.020",
"favorite_count": 0,
"id": "24902",
"last_activity_date": "2016-05-16T09:49:24.020",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "13199",
"post_type": "question",
"score": 1,
"tags": [
"linux",
"raspberry-pi",
"raspbian"
],
"title": "/etc/fstabの内容がホストの到達可能性に影響する",
"view_count": 373
} | [
{
"body": "[jessieのリリースノート](https://www.debian.org/releases/jessie/s390x/release-\nnotes/ch-information.ja.html#systemd-auto-mounts-\nincompat)の以下の記述を参考に、`/etc/fstab`に`nofail`オプションを追加したところ問題が解決しました。\n\n> 新しい標準 init システムである systemd-sysv は、起動中の \"auto\" マウントの失敗について、sysvinit\n> と比べて厳しく取り扱います。(\"nofail\" オプション無しの) \"auto\" マウントに失敗した場合、systemd\n> は起動を続けるのではなく非常時のシェルに落ちます。\n>\n> /etc/fstab 中に記載されている全てのリムーバブルドライブまたは \"optional\" なマウントポイント (例:\n> 必須ではないネットワークドライブ) については、\"noauto\" または \"nofail\" いずれかのオプションの付加を推奨します。\n```\n\n UUID=<外付けHDD_aのUUID> /media/<外付けHDD_aのUUID> ntfs rw,user,nosuid,nodev,nofail,uid=1002,gid=1002,dmask=0002 0 0\n \n```\n\njessieでsystemdに移行したこと、wheezy時代の`fstab`をそのまま使っていたこと、ヘッドレスな環境のため外側たら見た状況しか分からなかったことが原因でした。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T09:49:24.020",
"id": "24903",
"last_activity_date": "2016-05-16T09:49:24.020",
"last_edit_date": "2020-06-17T08:14:45.997",
"last_editor_user_id": "-1",
"owner_user_id": "13199",
"parent_id": "24902",
"post_type": "answer",
"score": 4
}
]
| 24902 | 24903 | 24903 |
{
"accepted_answer_id": "24906",
"answer_count": 1,
"body": "当方、RealmSwiftを使ってアプリを作っております。 \nこの程、RealmSwiftが0.102になり、マイグレーション処理が変更になったそうですね?\n\nそこで質問です。 \nマイグレーションが必要な場合に、Realmファイルを削除する具体的な方法を教えていただきたいです。 \n`deleteRealmIfMigrationNeeded`のプロパティをどう使えば、開発途中の不要なRealmファイルを削除できますか?",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T10:17:58.930",
"favorite_count": 0,
"id": "24905",
"last_activity_date": "2016-05-16T10:39:49.067",
"last_edit_date": "2016-05-16T10:31:08.427",
"last_editor_user_id": "5519",
"owner_user_id": "13156",
"post_type": "question",
"score": 0,
"tags": [
"swift",
"realm"
],
"title": "RealmSwiftのマイグレーションについて",
"view_count": 1683
} | [
{
"body": "> RealmSwiftが0.102になり、マイグレーション処理が変更になったそうですね?\n\nマイグレーション処理の基本はまったく変わっていません。単に小さな改善が入っただけです。 \nRealmには日本語のドキュメントも用意されていますので、まずドキュメントに目を通されることをおすすめします。\n\n<https://realm.io/jp/docs/swift/latest/#section-40>\n\nバージョン0.102から追加された`deleteRealmIfMigrationNeeded`を`true`に設定することで、マイグレーションが必要でかつマイグレーションが行われない場合に、エラーを出す代わりに自動的に古いファイルを削除して新しいデータ定義を用いて作り直してくれるようになりました。\n\n`deleteRealmIfMigrationNeeded`は`Realm.Configuration`のプロパティなので、使用するにはこの値を`true`にして`Configuration`オブジェクトを作成し、Realmインスタンスを作成する際に、この`Configuration`オブジェクトを渡します。\n\n```\n\n let config = Realm.Configuration(deleteRealmIfMigrationNeeded: true)\n let realm = try! Realm(configuration: config)\n \n```\n\nRealmをインスタンス化している場所すべてで同様にする必要がありますが、`defaultConfiguration`として設定すると、それ以降は、いちいち`Configuration`オブジェクトを渡さなくても`defaultConfiguration`に設定したオブジェクトが使用されるようになり便利です。\n\n```\n\n let config = Realm.Configuration(deleteRealmIfMigrationNeeded: true)\n Realm.Configuration.defaultConfiguration = config\n \n let realm = try! Realm()\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T10:39:49.067",
"id": "24906",
"last_activity_date": "2016-05-16T10:39:49.067",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "24905",
"post_type": "answer",
"score": 3
}
]
| 24905 | 24906 | 24906 |
{
"accepted_answer_id": "25002",
"answer_count": 1,
"body": "emacs で、 xml を段階的に unfold していくことはできますか? \n段階的な unfold とは、たとえば次のような挙動です。\n\n 1. 最初はトップレベルの xml のノードがだけが表示されていて、 \nその中身は省略されている\n\n 2. 任意のノードをより詳細表示するようなコマンドが利用可能で、 \nこれを利用すると、1段階分だけノードが展開されて表示される。\n\n今できていることとしては、 nXML-mode + hs-minor-mode で、任意の node の hide/show が可能なのですが、xml\nの全容を俯瞰的に理解しながら気になるところを詳細に調べていくことをやる際に、まず最初にすべての top level の node を hide\nすることからはじめたりしているので、若干不便だと感じているからです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T15:33:43.770",
"favorite_count": 0,
"id": "24908",
"last_activity_date": "2016-05-19T16:32:12.440",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 2,
"tags": [
"emacs"
],
"title": "emacs で段階的に xml を unfold していくことはできるか",
"view_count": 111
} | [
{
"body": "web-mode の `C-c C-f` (`web-mode-fold-or-unfold`), `C-c C-e f` (`web-mode-\nelement-children-fold-or-unfold`) を利用するとやりたいことができました。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-19T16:32:12.440",
"id": "25002",
"last_activity_date": "2016-05-19T16:32:12.440",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "24908",
"post_type": "answer",
"score": 2
}
]
| 24908 | 25002 | 25002 |
{
"accepted_answer_id": "29468",
"answer_count": 1,
"body": "端末上の emacs では、`f10` を実行すると、メニューを選択して、`C-f`,`C-b`,`C-p`,`C-n` でメニュー項目の移動ができます。\n\nRET\nによって、項目の選択(ドリルダウン)ができますが、選択した状態から一つ上の階層へ戻る方法がわからずにいます。このコマンドはどのキーにバインドされていますか?",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T18:05:58.960",
"favorite_count": 0,
"id": "24909",
"last_activity_date": "2016-10-10T16:56:13.087",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"post_type": "question",
"score": 0,
"tags": [
"emacs"
],
"title": "端末上の emacs で、メニューの選択肢で「戻る」を実行するには?",
"view_count": 108
} | [
{
"body": "(コメントを転記しています。)\n\n2年半 _(現時点では3年..?)_ くらい前のメールですが、[Drop-down menus, popup menus, and popup\ndialogs supported on\nTTYs](http://permalink.gmane.org/gmane.emacs.devel/164053) の最後の方に \"I did not\nfind a way from the sub menu back to the main menu ... navigation would\nimprove this?\" \"Not easy to do. Patches are welcome.\"\nとあります。これは現在でも改善されていない様ですね…。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-10-10T16:56:13.087",
"id": "29468",
"last_activity_date": "2016-10-10T16:56:13.087",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "754",
"parent_id": "24909",
"post_type": "answer",
"score": 0
}
]
| 24909 | 29468 | 29468 |
{
"accepted_answer_id": "24912",
"answer_count": 1,
"body": "SPFレコードについて触れるようになり、調べていたところ、 \nこちらのサイト \n<https://sendgrid.kke.co.jp/blog/?p=3509> \nで、SPFレコードについて書かれてあったうちのSPFレコードの例なのですが、\n\n```\n\n v=spf1 ip4:198.51.100.1 include:example.com -all\n \n```\n\nこの 198.51.100.1 というIPアドレスは具体的にはどのサーバのIPアドレスを設定すればよいのでしょうか? \nまた、 example.com も、送信したいドメインを設定すればよいのか、自分のドメインを設定すればよいのか、どちらでしょうか。\n\n私は、お名前ドットコムで取得したドメイン (仮)example.net を \n共有サーバSDのメールサーバで使用しています。 \nDNSは共有サーバSDにあります。\n\n現在、AWSのEC2でサーバを立ち上げ example.net でアクセスできるようにしています。\n\nDNS : 共有サーバSD? \nメールサーバ : 共有サーバSD \nサイトを運営しているサーバ : EC2\n\nドメイン(仮) : example.net \nEC2のIPアドレス(仮) : 203.0.113.1\n\n上のような場合、EC2からどこかに(例えば***@gmail.comなど)メールを送信しようとした場合、SPFレコードはどのように設定すれば正しいでしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-16T20:59:03.020",
"favorite_count": 0,
"id": "24910",
"last_activity_date": "2016-05-17T00:54:56.840",
"last_edit_date": "2016-05-17T00:37:39.763",
"last_editor_user_id": "5793",
"owner_user_id": "13404",
"post_type": "question",
"score": 1,
"tags": [
"aws",
"dns",
"amazon-ec2"
],
"title": "SPFレコードについて教えて下さい。",
"view_count": 669
} | [
{
"body": "SPFは\"Sender Policy Framework\"の略ですから、送信者(Sender)の情報を設定します。\n\n> v=spf1 ip4:198.51.100.1 include:example.com -all\n\nリンク先のブログに解説が書いてありますが、\n\n * ip4 はそのレコードが設定されているドメインでメールを送信するサーバのIPアドレスの宣言\n * includeはそこに指定されたドメインのSPFレコードを参照する宣言\n * -allは無条件で認証を失敗させる宣言\n\nになります。\n\n203.0.113.1からexample.netドメインを発信者とするメールを送信する(そしてそれ以外のサーバからメールを送信することがない)場合、example.netに対するTXTレコードとして\n\n```\n\n v=spf1 ip4:203.0.113.1 -all\n \n```\n\nを設定します。\n\nSPFは変な設定をしても他人に迷惑をかける事はまず無いですが、当然メールが届かないなどのトラブルになりますので、コピペではなくきちんと理解してから設定されることをお勧めします。\n\n[インターネット協会が公開している解説](http://salt.iajapan.org/wpmu/anti_spam/admin/tech/explanation/spf/)は参考になると思います。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T00:54:56.840",
"id": "24912",
"last_activity_date": "2016-05-17T00:54:56.840",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5793",
"parent_id": "24910",
"post_type": "answer",
"score": 4
}
]
| 24910 | 24912 | 24912 |
{
"accepted_answer_id": "24916",
"answer_count": 1,
"body": "RealmSwiftを使ってデータベースアプリを作っております。 \nコーディングの途中でプロパティ名の変更をしたため、マイグレーション処理が必要となりました。 \nその際、ビルドはできてもシミュレーターを動かすと途中で落ちるようになってしまいました。 \nそこで、まだ開発途中なので、一旦RealmSwiftの全てのデータを消去したいと思います。 \nRealmブラウザを使う方法や、Xcodeからそのデータの場所を特定する方法があるようです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T01:40:50.180",
"favorite_count": 0,
"id": "24913",
"last_activity_date": "2016-05-17T03:55:34.147",
"last_edit_date": "2016-05-17T03:54:27.470",
"last_editor_user_id": "5519",
"owner_user_id": "13156",
"post_type": "question",
"score": -1,
"tags": [
"realm"
],
"title": "RealmSwiftのデータを全て消去したい",
"view_count": 1534
} | [
{
"body": "シミュレータ、またはデバイスから開発中のアプリケーションを削除すればファイルも一緒に消えます。 \nその後再インストールすればいいです。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T03:55:34.147",
"id": "24916",
"last_activity_date": "2016-05-17T03:55:34.147",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5519",
"parent_id": "24913",
"post_type": "answer",
"score": 4
}
]
| 24913 | 24916 | 24916 |
{
"accepted_answer_id": "24922",
"answer_count": 1,
"body": "iPodに有線で接続してデバッグしている時は、画面の向きが問題なく切り換わっているのですが、 \n(画面の回転は問題なく行われる) \nそのソースをビルドしてiPodにインストールすると画面の向きが縦のままで横向きにならない \n(iPodを横向きにして画面が回転しない) \n現象が出ています。 \n何か設定が間違っているのでしょうか? \nご教授お願い致します。 \nちなみに、 \niPodは、iOS 9.3.2です。 \nmonacaの設定としては \n「Cordovaプラグイン」は、\n\n * BarcodeScanner\n * Monaca Plugin\n * Splashscreen\n * Whitelist\n\nの4つを指定しています。\n\n「JS/CSSコンポーネント」は、\n\n * Cordova(phoneGap)Loader Ver=1.0.0\n * Monaca Core Utilitu Ver=2.0.4\n\nの2つを設定しています。\n\nソースはJQueryMobileで、記述しています。 \nindex.htmlファイルのheadに次の様にリンクしています。\n\n```\n\n <link rel=\"stylesheet\" href=\"css/jquery.mobile-1.4.5.min.css\" />\n <script src=\"js/jquery-2.1.4.min.js\"></script>\n <script src=\"js/jquery.mobile-1.4.5.min.js\" ></script>\n \n```\n\n画面は`<section>`タブで構成しています。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T05:13:58.230",
"favorite_count": 0,
"id": "24921",
"last_activity_date": "2016-05-17T07:35:27.093",
"last_edit_date": "2016-05-17T07:35:27.093",
"last_editor_user_id": null,
"owner_user_id": "15530",
"post_type": "question",
"score": 0,
"tags": [
"monaca",
"jquery",
"ios9"
],
"title": "ビルドしてiPodにインストールすると画面が回転しなくなる",
"view_count": 163
} | [
{
"body": "Cordovaのフレームワークはバージョン5でしょうか?\n\nでしたら、ファイル一覧にある`config.xml`を開き \n下記の記載があることを確認して下さい。 \nもし、無いようであれば追加してください。 \n追加する場合は`</widget>`の直ぐ上の行当たりが良いです。\n\n```\n\n <platform name=\"ios\">\n <preference name=\"orientation\" value=\"all\"/>\n </platform>\n \n```\n\n中身の説明はIDE画面上部の\"設定\"より \n\"iOSアプリ設定\"を選択し、一番下の\"その他\"に\"画面の向き:\"の欄で説明しております。 \nCordova5未満の場合は此方から確認してください。 \nまた、その下の注意書きの説明を引用すると下記になります。\n\n> 縦横両方対応の場合は上記のvalueに「all」、横向きのみの場合は「landscape」、縦向きのみの場合は「portrait」を指定します。\n\n設定が記載されていないとデフォルトの縦固定になりますね。\n\n* * *\n\nあとは、無いとは思いますが端末側のOSのメニューの回転ロックがかかっていないか? \n回転しないように固定するプラグインを入れていないかなどですかね",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T05:36:27.010",
"id": "24922",
"last_activity_date": "2016-05-17T05:36:27.010",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24921",
"post_type": "answer",
"score": 0
}
]
| 24921 | 24922 | 24922 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "iOSで、facebookのようにスクロールに追従して、ステータスバーを残して、ナビゲーションバーを消す方法ってどうやるのでしょうか。\n\nできればライブラリを使わないで実現したいのですが、(ossライブラリを極力使わない方針なので)実現方法教えてください。\n\n普通に \nself.navigationController?.setNavigationBarHidden(true, animated: true) \nすると、両方消えます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T05:50:41.523",
"favorite_count": 0,
"id": "24923",
"last_activity_date": "2016-05-19T05:29:34.423",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15532",
"post_type": "question",
"score": 0,
"tags": [
"ios",
"objective-c",
"swift2"
],
"title": "ステータスバーを残して、ナビゲーションバーを消す方法",
"view_count": 865
} | [
{
"body": "一番簡単にやるのであれば、`UINavigationController`の`hidesBarsOnSwipe`を`true`にすればできます。\n\n```\n\n navigationController?.hidesBarsOnTap = true\n \n```\n\n[リファレンス](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/#//apple_ref/occ/instp/UINavigationController/hidesBarsOnSwipe)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T06:27:05.237",
"id": "24962",
"last_activity_date": "2016-05-19T01:51:03.610",
"last_edit_date": "2016-05-19T01:51:03.610",
"last_editor_user_id": "10926",
"owner_user_id": "10926",
"parent_id": "24923",
"post_type": "answer",
"score": 1
},
{
"body": "UINavigationControllerのナビゲーションバーは非表示にして、 \nUIView等で、ナビゲーションバーと同じようなUIにしてしまう方が楽だと思います。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-19T05:29:34.423",
"id": "24986",
"last_activity_date": "2016-05-19T05:29:34.423",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15563",
"parent_id": "24923",
"post_type": "answer",
"score": -2
}
]
| 24923 | null | 24962 |
{
"accepted_answer_id": "24926",
"answer_count": 2,
"body": "昨日からmysqlの勉強を始めました。 \n最初の言語設定ってハマっていて、SHOW VARIABLES LIKE 'char%’;したいにも関わらず実行されません。 \n他にも実行されない事が何度もあります。これは何が原因なのでしょうか? \n[](https://i.stack.imgur.com/sjkkF.png)",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T07:33:50.577",
"favorite_count": 0,
"id": "24925",
"last_activity_date": "2016-05-17T08:10:47.690",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15429",
"post_type": "question",
"score": 0,
"tags": [
"mysql"
],
"title": "mysql 実行されずに改行され続ける",
"view_count": 3373
} | [
{
"body": "もし質問に書かれた通り `SHOW VARIABLES LIKE 'char%’;` と入力されているのなら、`char%`\nを囲む右側の記号が間違っています。左側はあっています。\n\nそのため `’;` や改行も文字列の一部だと認識され、続きの入力を促され続けることになります。\n\n英語における引用符は `‘xxx’` `“xxx”` と左右で形の異なる文字を使いますが、プログラミング等では `'xxx'` `\"xxx\"`\nと左右の区別のない文字を使うことが多いです。日本語配列のキーボードであれば、半角英数を入力できる状態で Shift+7\nを押して入力されるのが、今回必要な記号です。\n\n参考 [引用符 -\nWikipedia](https://ja.wikipedia.org/wiki/%E5%BC%95%E7%94%A8%E7%AC%A6#.E7.9B.B4.E7.B7.9A.E5.BD.A2)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T08:01:32.780",
"id": "24926",
"last_activity_date": "2016-05-17T08:01:32.780",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8000",
"parent_id": "24925",
"post_type": "answer",
"score": 0
},
{
"body": "mysql\nコマンドの「`'>`」プロンプトは「`'`」が入力された後、閉じの「`'`」の入力待ちの状態です。どこかで開く「`'`」と閉じる「`'`」の対応がずれたのでしょう。\n\nその状態で「`'`」を入力するとプロンプトが「`->`」になり、「`\\c`」でクエリを中断できます。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T08:10:47.690",
"id": "24927",
"last_activity_date": "2016-05-17T08:10:47.690",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3249",
"parent_id": "24925",
"post_type": "answer",
"score": 0
}
]
| 24925 | 24926 | 24926 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "GoogleMapで位置情報と情報ウィンドウの内容が入ったJSONデータに連動してマーカーをクリックすると情報ウィンドウが表示され、コンテンツ表示させるものを作成しているのですが作ったコードではマーカーが消滅しています。javascript内に位置情報を配列として入力したものは正しく動きました。ご教授お願いいたします。\n\njavascript内に配列を入れたもの\n\n```\n\n <html>\r\n <head>\r\n <meta charset=\"utf-8\" />\r\n <script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>\r\n <link rel=\"stylesheet\"href=\"http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css\" />\r\n <script src=\"http://code.jquery.com/jquery-1.10.2.min.js\"></script>\r\n <script src=\"http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js\"></script>\r\n <script>\r\n var currentWindow = null ;\r\n function initialize() {\r\n \r\n var bodyHeight = $('body').height();\r\n $(\"#map\").css('height',bodyHeight);\r\n \r\n var myOptions = {\r\n zoom: 16,\r\n center: new google.maps.LatLng(35.6954806, 139.76325010000005),\r\n mapTypeId: google.maps.MapTypeId.ROADMAP\r\n };\r\n var map = new google.maps.Map(document.getElementById(\"map\"),myOptions);\r\n var markers = [\r\n ['TAM 東京', 35.6954806, 139.76325010000005,'コメントA'],\r\n ['小川町駅', 35.6951212, 139.76610649999998,'コメントB'],\r\n ['淡路町駅', 35.69496, 139.76746000000003,'コメントC'],\r\n ['御茶ノ水駅', 35.6993529, 139.76526949999993,'コメントD'],\r\n ['神保町駅', 35.695932, 139.75762699999996,'コメントE'],\r\n ['新御茶ノ水駅', 35.696932, 139.76543200000003,'コメントF']\r\n ];\r\n for (var i = 0; i < markers.length; i++) {\r\n var name = markers[i][0];\r\n var latlng = new google.maps.LatLng(markers[i][1],markers[i][2]);\r\n var comment = markers[i][3];\r\n createMarker(name, latlng, comment, map);\r\n }\r\n }\r\n function createMarker(name, latlng, comment, map) {\r\n var infoWindow = new google.maps.InfoWindow({\r\n });\r\n var marker = new google.maps.Marker({\r\n position: latlng,\r\n map: map\r\n });\r\n google.maps.event.addListener(marker, 'click', function() {\r\n if (currentWindow) {\r\n currentWindow.close();\r\n }\r\n infoWindow.setContent(\r\n '<div class=\"infoWindow\">'+\r\n '<h2>'+name+'</h2>'+\r\n '<p>'+comment+'</p>'+\r\n '</div>'\r\n );\r\n infoWindow.open(map, marker);\r\n currentWindow = infoWindow;\r\n });\r\n }\r\n google.maps.event.addDomListener(window, 'load', initialize);\r\n \r\n </script>\r\n </head>\r\n \r\n <body onload=\"initialize()\">\r\n <div data-role=\"page\" id=\"top\">\r\n <div data-role=\"header\">\r\n <h1>DEMO</h1>\r\n </div>\r\n <div role=\"main\" class=\"ui-content\">\r\n <a href=\"#sub\" data-rel=\"dialog\" data-transition=\"slidedown\">ダイアログを表示 »</a>\r\n <div id=\"map\"></div>\r\n </div>\r\n \r\n <div data-role=\"footer\">\r\n <h1>DEMO</h1>\r\n </div>\r\n </div>\r\n \r\n <div data-role=\"page\" id=\"sub\" data-close-btn=\"right\">\r\n <div data-role=\"header\">\r\n <h1>タイトル</h1>\r\n </div>\r\n <div data-role=\"main\" class=\"ui-content\">\r\n <p>コメントはここから始まります</p>\r\n <a href=\"#\" data-role=\"button\" data-rel=\"back\">閉じる</a>\r\n </div>\r\n </div>\r\n </body>\r\n \r\n <style type=\"text/css\">\r\n #map {\r\n width: 100%;\r\n height: auto;\r\n }\r\n \r\n #infoWindow{\r\n width: 300px;\r\n height: 400px;\r\n }\r\n </style>\n```\n\n \n位置情報を別データ(JSON)に分けたコード\n\n```\n\n <html>\n <head>\n <meta charset=\"utf-8\" />\n <script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>\n <link rel=\"stylesheet\"href=\"http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css\" />\n <script src=\"http://code.jquery.com/jquery-1.10.2.min.js\"></script>\n <script src=\"http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js\"></script>\n <script>\n var currentWindow = null ;\n $(function() {\n $.getJSON(\"maps.json\", function(markers){\n var setno = markers.length;\n var title = new Array();\n var lat = new Array();\n var lng = new Array();\n var text = new Array();\n for (var i = 0; i < markers.length; i++) {\n title[i] = markers[i][0];\n lat[i] = markers[i][1];\n lng[i] = markers[i][2];\n text[i] = markers[i][3];\n }\n initialize(setno, title, lat, lng, text);\n });\n });\n function initialize(setno, title, lat, lng, text) {\n \n var bodyHeight = $('body').height();\n $(\"#map\").css('height',bodyHeight);\n \n var myOptions = {\n zoom: 16,\n center: new google.maps.LatLng(35.6954806, 139.76325010000005),\n mapTypeId: google.maps.MapTypeId.ROADMAP\n };\n var map = new google.maps.Map(document.getElementById(\"map\"),myOptions);\n for (var i = 0; i < markers.length; i++) {\n var name = title[i];\n var latlng = new google.maps.LatLng(lat[i],lng[i]);\n var comment = text[i];\n createMarker(name, latlng, comment, map);\n }\n }\n function createMarker(name, latlng, comment, map) {\n var infoWindow = new google.maps.InfoWindow({\n });\n var marker = new google.maps.Marker({\n position: latlng,\n map: map\n });\n google.maps.event.addListener(marker, 'click', function() {\n if (currentWindow) {\n currentWindow.close();\n }\n infoWindow.setContent(\n '<div class=\"infoWindow\">'+\n '<h2>'+name+'</h2>'+\n '<p>'+comment+'</p>'+\n '</div>'\n );\n infoWindow.open(map, marker);\n currentWindow = infoWindow;\n });\n }\n google.maps.event.addDomListener(window, 'load', initialize);\n \n </script>\n </head>\n \n <body onload=\"initialize()\">\n <div data-role=\"page\" id=\"top\">\n <div data-role=\"header\">\n <h1>DEMO</h1>\n </div>\n <div role=\"main\" class=\"ui-content\">\n <a href=\"#sub\" data-rel=\"dialog\" data-transition=\"slidedown\">ダイアログを表示 »</a>\n <div id=\"map\"></div>\n </div>\n \n <div data-role=\"footer\">\n <h1>DEMO</h1>\n </div>\n </div>\n \n <div data-role=\"page\" id=\"sub\" data-close-btn=\"right\">\n <div data-role=\"header\">\n <h1>タイトル</h1>\n </div>\n <div data-role=\"main\" class=\"ui-content\">\n <p>コメントはここから始まります</p>\n <a href=\"#\" data-role=\"button\" data-rel=\"back\">閉じる</a>\n </div>\n </div>\n </body>\n \n <style type=\"text/css\">\n #map {\n width: 100%;\n height: auto;\n }\n \n #infoWindow{\n width: 300px;\n height: 400px;\n }\n </style>\n \n```\n\nmaps.json\n\n```\n\n [\n [\"TAM 東京\", \"35.6954806\", \"139.76325010000005\",\"コメントA\"],\n [\"小川町駅\", \"35.6951212\", \"139.76610649999998\",\"コメントB\"],\n [\"淡路町駅\", \"35.69496\", \"139.76746000000003\",\"コメントC\"],\n [\"御茶ノ水駅\", \"35.6993529\", \"139.76526949999993\",\"コメントD\"],\n [\"神保町駅\", \"35.695932\", \"139.75762699999996\",\"コメントE\"],\n [\"新御茶ノ水駅\", \"35.696932\", \"139.76543200000003\",\"コメントF\"]\n ]\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T08:11:42.930",
"favorite_count": 0,
"id": "24928",
"last_activity_date": "2016-05-17T09:02:47.497",
"last_edit_date": "2016-05-17T09:02:47.497",
"last_editor_user_id": "76",
"owner_user_id": "13526",
"post_type": "question",
"score": 0,
"tags": [
"javascript",
"google-maps"
],
"title": "GoogleMapsAPIで位置情報を別ファイル(JSON)データに分ける",
"view_count": 601
} | [
{
"body": "`initialize`を実行しすぎです。 \nスクリプト内の \n`google.maps.event.addDomListener(window, 'load', initialize);` \nとHTML内の \n`<body onload=\"initialize()\">` \nの`onload=\"initialize()\"`が不要です。`initialize`は引数無しで実行されるとマーカーの無いマップを生成してしまいます。 \n`maps.json`を取得したら一回だけ実行すればよいです。\n\nさらに`initialize`関数自体にもバグがあります。for文のループ条件で`markers.length`を参照していますが、これはこの関数内で未定義です。引数`setno`に配列の長さを渡してますのでそれを使ってください。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T08:59:30.487",
"id": "24929",
"last_activity_date": "2016-05-17T08:59:30.487",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15537",
"parent_id": "24928",
"post_type": "answer",
"score": 1
}
]
| 24928 | null | 24929 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "### 前提・実現したいこと\n\n以下のような関連付けをしているモデルがあります。 \nPlan=>Course=>Lesson \ndeviseのモデルUser \n中間テーブル \n\\- course_plan \n\\- bookmark\n\ncourse_planモデルにpositonカラムがあります。 \nbookmarkのindexページでpositionカラム順にbookmarkを並べ替えたいのですが、どのようにすればよいでしょうか?\n\n```\n\n class Plan\n has_many :users\n \n has_many :course_plans, -> { order(position: :asc) }, dependent: :destroy\n \n has_many :courses, -> { includes(:course_plans).order('course_plans.position ASC') }, through: :course_plans\n \n \n class CoursePlan\n belongs_to :course\n belongs_to :plan\n \n \n class Course < ActiveRecord::Base\n has_many :lessons, -> { order(chapter: :asc) }, dependent: :destroy\n accepts_nested_attributes_for :lessons\n has_many :course_plans\n has_many :plans, through: :course_plans\n \n \n class Lesson < ActiveRecord::Base\n belongs_to :course\n has_many :bookmarks\n has_many :bookmarked_users, through: :bookmarks, source: :user\n \n \n class Bookmark < ActiveRecord::Base\n belongs_to :user\n belongs_to :lesson\n \n```\n\n### 試したこと\n\n現在は苦肉の策で \nコースIDが若い順、同一コースの場合はレッスンIDが若い方を上にしています。\n\n```\n\n def bookmarks\n @bookmarks = Bookmark.where(user_id: current_user.id).sort_bookmarks\n @bookmarks = Bookmark.joins(lesson: [:course]).order(\"course_id\").order(\"chapter\").where(user_id: current_user.id)\n end\n \n```\n\n`joins`や`includes`してみましたが、うまくいきませんでした。 \nどなたか教えていただけると幸いです。\n\n# 下記回答頂いて、やりたいことまでかなり近づきました!\n\nしかし、これをviewでeach文で取り出したところ、同じブックマークしたレッスンが4つも出てきてしまいました。ログインしているユーザーがブックマークしたレッスンをcourse_planのposition順かつ同一コースの場合はレッスンIDが若い方を上に並べたいです。 \n下記現在のコードです。\n\n```\n\n controller.rb\n def bookmark\n @bookmarks = Bookmark.joins(lesson: { course: :course_plans }).order(CoursePlan.arel_table[:position].desc).where(user_id: current_user.id)\n end\n \n```\n\n(bookmark.html.erb)\n\n```\n\n <% if @bookmarks.blank? %>\n <div class=\"not_found\">\n <%= \"ブックマークしているレッスンはありません\" %>\n </div>\n <% else %>\n <div id=\"collapseOne\" class=\"panel-collapse collapse in\">\n <div class=\"panel-body\">\n <table id=\"memo_table\" class=\"table\">\n <thead>\n <tr>\n <th class=\"\">コース名</th>\n <th class=\"\">ブックマークしたレッスン</th>\n </tr>\n </thead>\n <tbody>\n <% @bookmarks.each do |bookmark| %>\n <% if bookmark.present? %>\n <tr valign=\"top\">\n <td class=\"s12\">\n <%= link_to course_path(bookmark.lesson.course) do %>\n <%= bookmark.lesson.course.title %>\n <% end %>\n </td>\n <td class=\"s12\">\n <%= link_to lesson_path(bookmark.lesson) do %>\n <%= bookmark.lesson.title %>\n <% end %>\n </td>\n </tr>\n <% end %>\n <% end %>\n </tbody>\n </table>\n </div>\n </div>\n <% end %>\n \n```",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T10:25:10.767",
"favorite_count": 0,
"id": "24931",
"last_activity_date": "2016-05-18T01:25:38.713",
"last_edit_date": "2016-05-18T01:25:38.713",
"last_editor_user_id": "15539",
"owner_user_id": "15539",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails"
],
"title": "Railsで中間テーブルのカラム順に並べ替えたい",
"view_count": 2245
} | [
{
"body": "> course_planモデルにpositonカラムがあります。 \n> bookmarkのindexページでpositionカラム順にbookmarkを並べ替えたいのですが、どのようにすればよいでしょうか?\n\nBookmark から CoursePlan までを繋いで、CoursePlan の position で order すれば良いかと思います。\n\n```\n\n irb(main):009:0> Bookmark.joins(lesson: { course: :course_plans }).order(CoursePlan.arel_table[:position].desc).to_sql\n => \"SELECT \\\"bookmarks\\\".* FROM \\\"bookmarks\\\" INNER JOIN \\\"lessons\\\" ON \\\"lessons\\\".\\\"id\\\" = \\\"bookmarks\\\".\\\"lesson_id\\\" INNER JOIN \\\"courses\\\" ON \\\"courses\\\".\\\"id\\\" = \\\"lessons\\\".\\\"course_id\\\" INNER JOIN \\\"course_plans\\\" ON \\\"course_plans\\\".\\\"course_id\\\" = \\\"courses\\\".\\\"id\\\" ORDER BY \\\"course_plans\\\".\\\"position\\\" DESC\"\n \n```\n\nただ、提示されているコードを見ると、それ以外のものも多く含まれていらっしゃいますね。 \n本当にやりたいことは、もしかして違うのでしょうか……? \nその場合は、別途質問を追加されることをお勧めします。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T14:08:25.173",
"id": "24940",
"last_activity_date": "2016-05-17T14:08:25.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7471",
"parent_id": "24931",
"post_type": "answer",
"score": 2
}
]
| 24931 | null | 24940 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "MySQLを使ったリレーショナルデータベースを想定しています。\n\n例えば掲示板のようなデータベースでユーザーがどんどんポストしていくもので、消すわけにはいかないものはどのように管理するのがよいのでしょうか。\n\nインデックスを貼ったりしても、肥大化し続けるとどこかで辛くなって行くのではないかと心配です。\n\n思いつく対策としては、`posts-2016`というようにテーブルを1年毎に分割していくやり方ですが、なにか定石はあるのでしょうか。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T10:34:26.547",
"favorite_count": 0,
"id": "24932",
"last_activity_date": "2016-05-17T13:12:00.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9149",
"post_type": "question",
"score": 2,
"tags": [
"mysql",
"postgresql",
"データベース設計"
],
"title": "データベースでデータが増え続けるテーブルの管理の仕方について",
"view_count": 644
} | [
{
"body": "求めている回答とは違うのかもしれませんが、別サーバーを立て、SQLやOracleなどを使用して運用しています。サーバーの容量にも限界がありますので、やはりどこかで見切って削除します。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T11:01:50.463",
"id": "24934",
"last_activity_date": "2016-05-17T11:01:50.463",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15530",
"parent_id": "24932",
"post_type": "answer",
"score": -1
},
{
"body": "[MySQL](http://dev.mysql.com/doc/refman/5.6/ja/partitioning.html)にも[PostgreSQL](https://www.postgresql.jp/document/9.5/html/ddl-\npartitioning.html)にも指定された条件で分割されたテーブルを扱うパーティショニングという機能があります。\n\n本当に必要かどうかはデータ量などを見積もった上で検討してください。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T13:12:00.173",
"id": "24937",
"last_activity_date": "2016-05-17T13:12:00.173",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "5793",
"parent_id": "24932",
"post_type": "answer",
"score": 2
}
]
| 24932 | null | 24937 |
{
"accepted_answer_id": "24952",
"answer_count": 1,
"body": "ViewのWidthやHeightとはどのような単位となるのでしょうか? \nドットなのでしょうか",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T13:31:30.793",
"favorite_count": 0,
"id": "24938",
"last_activity_date": "2016-05-18T00:52:23.763",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12842",
"post_type": "question",
"score": 0,
"tags": [
"xcode",
"ios8"
],
"title": "ios Viewのサイズについて",
"view_count": 636
} | [
{
"body": "単位は「ポイント」です。 \niOSデバイスの場合、Retinaディスプレイでない端末では1ポイント=1ピクセル、Retinaディスプレイ端末(iPhone6(s)Plusを除く)では1ポイント=2ピクセルになります。\n\n余談ですが、DTPの世界では72ポイント=1インチですが、ディスプレイ上ではそのディスプレイの解像度に依存します。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T00:52:23.763",
"id": "24952",
"last_activity_date": "2016-05-18T00:52:23.763",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8077",
"parent_id": "24938",
"post_type": "answer",
"score": 3
}
]
| 24938 | 24952 | 24952 |
{
"accepted_answer_id": "24966",
"answer_count": 1,
"body": "Lispはコードを`quote`するとデータ(リスト)が得られ、そのデータはコードと表現が同じです。\n\n```\n\n [1]> (+ 1 2 3)\n 6\n [2]> (quote (+ 1 2 3))\n (+ 1 2 3)\n \n```\n\nElixirは少し様子が違います。\n\n```\n\n iex(1)> 1 + 2 + 3\n 6\n iex(2)> quote do: 1 + 2 + 3\n {:+, [context: Elixir, import: Kernel],\n [{:+, [context: Elixir, import: Kernel], [1, 2]}, 3]}\n \n```\n\n出て来たASTは確かにElixrで扱えるデータ(タプル)ではあります。 \nしかしプログラマが書くコードとは形が大分異なる物です。これをコードとして実行する事は出来ません。 \nこの点が私の「同図像性」という言葉のイメージと違っていたので質問しました。\n\nElixirには同図像性があるのでしょうか。 \nあるとすれば、Elixirのどの性質が同図像性を持つと言い得る条件を満たしているのでしょうか。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T14:05:40.647",
"favorite_count": 0,
"id": "24939",
"last_activity_date": "2016-05-18T08:51:57.227",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "3054",
"post_type": "question",
"score": 3,
"tags": [
"elixir"
],
"title": "Elixirには同図像性(homoiconicity)があるのか",
"view_count": 479
} | [
{
"body": "どの言語が homoiconic であるかについては、いろいろと議論があるようです。たしかに、Elixir\nには同図像性があると主張する人もいますが、その一方で、Elixir のオフィシャルなドキュメントには、\"homoiconic\"\nという言葉は出てこないようです。\n\n同図像性の定義ですが、私には、こちらに書かれているものが分かりやすかったです。\n\n * <http://c2.com/cgi/wiki?HomoiconicLanguages>\n\n要約すると、こうなります。\n\n**定義:**\n\n * プログラムコードを、その言語の基本データ型で表現できる言語は、「同図像性」があるという。\n\n**同図像性がある言語の利点:**\n\n * そのような言語では、コードとデータを相互に変換できる。そのため、プログラムの実行時に、そのプログラム自身が、新しいコードを生成したり、コードを変更したりすることができる。\n\nもしこの定義に従うなら、Elixir は、以下のようにコードとデータを相互に変換できるため、同図像性があるといえそうです。\n\n**プログラムコード(テキスト表現)から、データ(AST)への変換:**\n\n```\n\n iex(1)> 1 + 2 + 3\n 6\n iex(2)> sum_prog = quote do: 1 + 2 + 3\n {:+, [context: Elixir, import: Kernel],\n [{:+, [context: Elixir, import: Kernel], [1, 2]}, 3]}\n \n```\n\n**データ(AST)をプログラムとみなして実行:**\n\n```\n\n iex(3)> Code.eval_quoted(sum_prog)\n {6, []}\n iex(4)> Code.eval_quoted(sum_prog) |> elem(0)\n 6\n \n```\n\n**データ(AST)から、プログラムコード(テキスト表現)への変換:**\n\n```\n\n iex(5)> Macro.to_string(sum_prog)\n \"1 + 2 + 3\"\n \n```\n\nこのように、プログラムの実行時に、コードとデータの相互変換が可能です。また、ASTはElixirの基本型で構成されていますので、普通のElixirコードが、その実行時に、新しいコードを生成することができます。\n\nただ、 **バイトコード(beamファイル)へコンパイル済みの**\nコードから、ElixirのASTに逆コンパイルすることはできないようです。一応、beamファイルにデバッグ情報が付いている時だけ、ErlangのASTとコード(テキスト表現)までは戻せます。\n\n * [Elixir や Erlang の beam ファイルを逆アセンブル、逆コンパイルする方法 -- おまけ:Erlang コードへ逆コンパイル](http://qiita.com/tatsuya6502/items/fa142cb51824bb72c910#%E3%81%8A%E3%81%BE%E3%81%91erlang-%E3%82%B3%E3%83%BC%E3%83%89%E3%81%B8%E9%80%86%E3%82%B3%E3%83%B3%E3%83%91%E3%82%A4%E3%83%AB)",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T08:30:51.870",
"id": "24966",
"last_activity_date": "2016-05-18T08:51:57.227",
"last_edit_date": "2016-05-18T08:51:57.227",
"last_editor_user_id": "14101",
"owner_user_id": "14101",
"parent_id": "24939",
"post_type": "answer",
"score": 3
}
]
| 24939 | 24966 | 24966 |
{
"accepted_answer_id": "24950",
"answer_count": 1,
"body": "変数に対して同じクラスのインスタンスをセットする必要が出てきたとき、下のように泥臭いコードになってしまいます:\n\n```\n\n a1 := TestClass new.\n a2 := TestClass new.\n a3 := TestClass new.\n a4 := TestClass new.\n \n```\n\nこのように書いてしまうと、同じクラスのインスタンスを代入する行がずっと続くことになり、非常に汚ないように感じてしまいます。もし、このように変数に対して、同じクラスのインスタンスをそれぞれに代入する方法があれば、教えてください。",
"comment_count": 3,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T14:37:12.937",
"favorite_count": 0,
"id": "24941",
"last_activity_date": "2018-10-05T06:21:35.947",
"last_edit_date": "2018-10-05T06:21:35.947",
"last_editor_user_id": "19110",
"owner_user_id": "939",
"post_type": "question",
"score": 4,
"tags": [
"smalltalk"
],
"title": "変数に対して一度に同じクラスのインスタンスを代入したい",
"view_count": 241
} | [
{
"body": "おそらくこういうことだと思うのですが、こうするのがスマートかどうかは微妙ですね。Squeak/Pharo Smalltalk で動作します。\n\n```\n\n | a1 a2 a3 a4 |\n a1 := a2 := a3 := a4 := nil. \"コンパイル時の警告抑止のため\"\n #(a1 a2 a3 a4) do: [:tName |\n | ctxt tNames |\n ctxt := thisContext outerContext.\n tNames := ctxt tempNames.\n ctxt tempAt: (tNames indexOf: tName) put: tName \"実際はTestClass new\"\n ].\n ^{a1. a2. a3. a4} \"=> #(#a1 #a2 #a3 #a4) \"\n \n```\n\n* * *\n\n使える変数の数にも限りがあるので、上の @mjy\nさんのコメントにもありますが、ひとつのコンテキストで扱うオブジェクトの数が増えてきたら、ひとつひとつを変数にアサインせずに済む方法を考えるのもよいかもしれません。\n\nたとえばゲートの組み合わせて回路を構築するような場面であれば、回路をオブジェクトにしてそれに追加するゲート(名前を付けられるようにしておく)を管理させたり、あるいは各ゲートのクラスに\nallInstances で手繰らせるという手もあります。言うまでもなく、名前の衝突については要注意ですが…。\n\n```\n\n NotGate class >> named: gateName\n ^self allInstances\n detect: [:gate | gate name = gateName]\n ifNone: [self new setName: gateName; yourself]\n \n```\n\nSqueak/Pharo Smalltalk であれば、named: を implementers of it (alt/cmd + m)\nして同名メソッドの定義を一覧すると、(そう多くはないですが)その手の管理方法をとっているオブジェクトの例が見つかるので参考にしてみてください。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T00:06:55.510",
"id": "24950",
"last_activity_date": "2016-05-18T01:48:20.687",
"last_edit_date": "2016-05-18T01:48:20.687",
"last_editor_user_id": "15545",
"owner_user_id": "15545",
"parent_id": "24941",
"post_type": "answer",
"score": 4
}
]
| 24941 | 24950 | 24950 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": ".htaccessを用いたリダイレクトの記述を教えてください。\n\n1)~3)にアクセスがあった場合に、4)にリダイレクトさせてたいです。 \n※2)3)のように、/sp/以降にパスが続く場合もリダイレクト対象に含めたいです。 \nただし、ディレクトリspは存在しません。 \nディレクトリspが必要であれば、ディレクトリspを作成することは問題ありません。\n\n1) `http://example.com/sp/` \n2) `http://example.com/sp/index.php` \n3) `http://example.com/sp/2015/01.php` \n4) `http://example.com`",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T14:52:07.400",
"favorite_count": 0,
"id": "24942",
"last_activity_date": "2016-05-19T02:57:14.377",
"last_edit_date": "2016-05-19T02:57:14.377",
"last_editor_user_id": null,
"owner_user_id": "15312",
"post_type": "question",
"score": 0,
"tags": [
".htaccess"
],
"title": "リダイレクトの設定を教えてください",
"view_count": 181
} | [
{
"body": "`http://example.com`でサイトを運用していることと思います。このルートディレクトリに.htaccessファイルを配置(つまり`http://example.com/.htaccess`となるように)します。`sp`ディレクトリは一般に必要ないと思われます。\n\n(1)~(3)までを(4)にリダイレクトするならば、内容は\n\n```\n\n RewriteRule ^sp/(?:index\\.php|2015/01\\.php)?$ / [L,R=301]\n \n```\n\nなどとします。また、質問の趣旨を取り違えていなければ、`/sp/`以下へのアクセスを禁止してサイトのトップページに戻す動作をさせたい、ということでしょう。この場合は正規表現を改め\n\n```\n\n RewriteRule ^sp/.*?$ / [L,R=301]\n \n```\n\nなどとします。ここで、`R=301`はリダイレクトの種類を設定していますので、目的に合わせて301,302など適切に設定してください。\n\nこうやって回答を書いてしまうとあまり勉強にならないと思うので、正規表現やmod_rewriteの使い方・動作については、いろいろ実験しながらご自分で勉強されることをおすすめします。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T15:38:56.883",
"id": "24943",
"last_activity_date": "2016-05-17T15:38:56.883",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24942",
"post_type": "answer",
"score": 1
}
]
| 24942 | null | 24943 |
{
"accepted_answer_id": null,
"answer_count": 0,
"body": "Mac(Yosemite 10.10.5)でHomebrewのインストールができません。\n\n```\n\n ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n \n```\n\n> curl: (56) SSLRead() return error -9806\n\nSSL系のエラーで証明書の設定ということで、日本語の文章少なく難航しております。\n\n```\n\n /usr ls\n \n```\n\n> X11 bin lib share X11R6 include libexec sbin standalone\n\nまた調べたらlocalなどのファイルもなくなっているみたいです。 \n関係あるかわかりませんが、その他の情報も載せておきます。 \n以前はOS 10.11 Capitanでhomebrewも使えておりました。 \nしか作業中にerror\n-9806が返ってきて、それが直せなかったので本日MacのクリーンインストールでYosemiteを入れなおしてみました。しかし状況が変わってなく、現在立ち止まってるところです。\n\n状況判断できる方いましたらコメントいただけますでしょうか。 \nよろしくお願いします。",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-17T22:08:57.633",
"favorite_count": 0,
"id": "24946",
"last_activity_date": "2016-05-17T22:08:57.633",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15542",
"post_type": "question",
"score": 0,
"tags": [
"macos",
"homebrew"
],
"title": "Homebrewのインストールができません。",
"view_count": 284
} | []
| 24946 | null | null |
{
"accepted_answer_id": "24976",
"answer_count": 2,
"body": "OS: OSX Yosemite\n\ntmux上で、以下コマンドでemacsを立ち上げています。\n\n```\n\n $ emacs -nw\n \n```\n\nRedo/Undoを、`C-.`、`C-/`に割り当てていますが、キーを入力しても反応がありません。\n\n`describe-key`でキーバインドを確かめようとしましたが、 \n`C-.`、`C-/`どちらも入力できませんでした。\n\n他のキーだと、入力できてキーバインドを確認することはできました。\n\n上記の状況に心当たりがあり、解決方法をご存知の方はいらっしゃいますでしょうか?",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T02:14:39.337",
"favorite_count": 0,
"id": "24953",
"last_activity_date": "2016-05-18T13:39:52.203",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "12765",
"post_type": "question",
"score": 1,
"tags": [
"emacs",
"tmux"
],
"title": "tmux + emacsで、<C-.>、<C-/>のキーが反応しない",
"view_count": 848
} | [
{
"body": "端末エミュレータ上で`C-.`等の修飾キー操作を入力することは難しかったと思います。\n\n代替案としては、Ctrlキーを押したように見せかけるキーバインド `C-x @ c` (`event-apply-control-modifier`)\nを利用する手があります。ただし、Redo/Undoのように多用するコマンドを呼び出すのには扱いやすいキー操作ではないかもしれません。\n\n * `C-.` を入力したい→ `C-x @ c .`\n * `C-/` を入力したい→ `C-x @ c /`\n\n参考:ターミナル上のEmacsで本来使えない\"Ctrlキー+何か\"を使う方法 \n<http://d.hatena.ne.jp/sugyan/20120228/1330392943>\n\nまた、リンク先の記事ではiTerm2のキーボードショートカット設定で`C-;`を`C-x @ c ;`に変換することもできるそうです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T09:28:19.203",
"id": "24967",
"last_activity_date": "2016-05-18T09:28:19.203",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2391",
"parent_id": "24953",
"post_type": "answer",
"score": 3
},
{
"body": "Teminal として xterm を使うという条件であれば、Emacs で `C-.` などを入力できる様になるかもしれません。したがって、Mac OS\nX で X Window System アプリケーションが利用できない場合、以下は意味がなくなりますのでご承知おき下さい。\n\nこちらの環境は以下の通りです。\n\n```\n\n OS: Linux 4.4.0\n Distro: Ubuntu 16.04\n xterm: 322\n tmux: 2.1\n Emacs: 25.1(snapshot version)\n \n```\n\nxterm には `modifyOtherKeys` という resource が用意されています。\n\n> **modifyOtherKeys (class ModifyOtherKeys)**\n>\n> Like modifyCursorKeys, tells xterm to construct an escape sequence for other\n> keys (such as \"2\") when modified by Control-, Alt- or Meta-modifiers. This\n> feature does not apply to function keys and well-defined keys such as ESC or\n> the control keys. The default is \"0\":\n```\n\n> 0 disables this feature.\n> 1 enables this feature for keys except for those with well-known\n> behavior,\n> e.g., Tab, Backarrow and some special control character cases, e.g.,\n> Control-Space to make a NUL.\n> 2 enables this feature for keys including the exceptions listed.\n> \n```\n\nここでは `1` に設定します(`2` に設定すると全ての escape sequence が「そのままの状態で」出力されてしまいます)。具体的には\n`$HOME/.xresources` に以下を追加します。\n\n```\n\n XTerm*eightBitInput: false\n XTerm*metaSendsEscape: true\n XTerm*modifyOtherKeys: 1\n \n```\n\n設定をリロードします。\n\n```\n\n $ xrdb -load $HOME/.xresources\n \n```\n\nここでは `$HOME/.xresources` としていますが、任意のファイルで構いません。\n\n次に `$HOME/.tmux.conf` に以下を追加します。\n\n```\n\n set -g xterm-keys on\n \n```\n\nこれによって 上記の xterm resource に tmux の動作が対応する様になります。\n\nなお、こちらの環境では `C-.` と `C-/` が効く様になりましたが、`C-;(semicolon)` が無効のままです。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T13:39:52.203",
"id": "24976",
"last_activity_date": "2016-05-18T13:39:52.203",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24953",
"post_type": "answer",
"score": 1
}
]
| 24953 | 24976 | 24967 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "## 起こっている現象\n\nGoogleフォームのスプレッドシートから、「ツール>スクリプトエディタ」編集で、フォーム送信時に自動返信メールが届くように設定をしています。(スクリプト、トリガー設定は最下段参照)\n\nしばらく問題なく正常に機能していたのですが、ある一人のフォーム送信をきっかけに以下の件名のエラーメールが管理者メールに届き、フォーム送信者のメールアドレスに自動返信メールが届かなくなってしまいました。一度このエラーが発生してしまうと、それ以降にフォームを送信した人も同じエラーが起こってしまいます。\n\n> 件名:【失敗】Googleフォームにメールアドレスが指定されていません \n> 本文:フォームの質問項目だけが書かれた、内容が空欄のフォーマット\n\nこのエラーが起こってしまった場合、現在は以下のように一時対処していますが、原因を特定して根本的に解決したいと思っています。\n\n・回答スプレッドシートには、メールアドレスも含め回答内容がすべてきちんと記録されているので、手動で確認メールを作成して送信する(数が多いとかなりの手間になってしまいます)\n\n・回答先のスプレッドシートを新しく指定し直す \n(その度に共同編集者に通知しなくてはいけないのでできれば避けたいです)\n\n## 原因について考えた事・調べたこと\n\n・今まで正常に機能していたことから、スクリプトの記述に問題があるわけではないと思っています。\n\n・エラーメッセジの内容が「メールアドレス指定されていない」ということですが、メールアドレスは必須項目にしてあるので、メールアドレスが空欄のまま送信されてしまったということは考えにくいです。\n\n・スプレッドシートの最後列に、フォームにはない項目を足して、備考欄代わりに使っているので、これが何かエラーの原因になることは考えられるでしょうか・・・?\n\n## 現在のプロジェクトトリガー設定\n\nmyFunction>スプレッドシートから>フォーム送信時\n\n## 現在記述しているスクリプト\n\n```\n\n function myFunction() {\n \n }\n \n //------------------------------------------------------------\n // 設定エリアここから\n //------------------------------------------------------------\n \n // 件名、本文、フッター\n var subject = \"ご予約ありがとうございます\";\n var body\n = \"この度は、ご予約ありがとうございます。\\n\\n\"\n + \"以下の内容にてお問い合わせいただきましたのでご確認ください。\\n\"\n + \"---------------------------------------------------------------------------------\\n\";\n var footer\n = \"---------------------------------------------------------------------------------\\n\\n\"\n \n // 入力カラム名の指定\n var NAME_COL_NAME = '保護者名(漢字)';\n var MAIL_COL_NAME = 'メールアドレス';\n var TIMESTAMP_LABEL = 'タイムスタンプ';\n \n // メール送信先\n var admin = \"xxx@xxxxx\"; // 管理者(必須)\n var cc = \"\"; // Cc:\n var bcc = \"xxx@xxxxx\";// Bcc:\n var reply = \"xxx@xxxxx\"; // Reply-To:\n var to = \"\"; // To: (入力者のアドレスが自動で入ります)\n \n //------------------------------------------------------------\n // 設定エリアここまで\n //------------------------------------------------------------\n \n try{\n // スプレッドシートの操作\n var sh = SpreadsheetApp.getActiveSheet();\n var rows = sh.getLastRow();\n var cols = sh.getLastColumn();\n var rg = sh.getDataRange();\n Logger.log(\"rows=\"+rows+\" cols=\"+cols);\n \n // メール件名・本文作成と送信先メールアドレス取得\n for (var j = 1; j <= cols; j++ ) {\n var col_name = rg.getCell(1, j).getValue(); // カラム名\n var col_value = rg.getCell(rows, j).getValue(); // 入力値\n \n if ( col_name === NAME_COL_NAME ) { //メール本文の最初に名前を入れる\n body = col_value+\" 様\\n\\n\"+body;\n }\n if ( col_name === MAIL_COL_NAME ) { //メールアドレス\n to = col_value;\n }\n if ( col_name === TIMESTAMP_LABEL ) { //タイムスタンプ⇒申込日時\n col_name = '申込日時';\n }\n body += \"【\"+col_name+\"】\\n\";\n body += col_value + \"\\n\\n\";\n }\n body += footer;\n \n // 送信先オプション\n var options = {};\n if ( cc ) options.cc = cc;\n if ( bcc ) options.bcc = bcc;\n if ( reply ) options.replyTo = reply;\n \n // メール送信\n if ( to ) {\n MailApp.sendEmail(to, subject, body, options);\n }else{\n MailApp.sendEmail(admin, \"【失敗】Googleフォームにメールアドレスが指定されていません\", body);\n }\n }catch(e){\n MailApp.sendEmail(admin, \"【失敗】Googleフォームからメール送信中にエラーが発生\", e.message);\n }\n \n```\n\nプログラム経験なしで、手探りでやっているので、読みづらい箇所や不足があるかと思います。近くに頼れるITパーソンもいないため・・・どうかご指摘・ご教授ください。\n\n## 補足\n\n概要:しばらく経ってから、エラーの概要がまとめて送られてきました。\n\nエラーメッセージ \n・スクリプト関数が見つかりません myFunction \n・1 日にサービス email を実行した回数が多すぎます。(行 105、ファイル「コード」)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T03:30:20.207",
"favorite_count": 0,
"id": "24958",
"last_activity_date": "2016-11-05T09:28:28.587",
"last_edit_date": "2016-05-19T05:41:42.557",
"last_editor_user_id": "15548",
"owner_user_id": "15548",
"post_type": "question",
"score": 0,
"tags": [
"google-apps-script",
"google-spreadsheet"
],
"title": "Googleフォームの自動返信メールがエラーで送信されなくなる",
"view_count": 10658
} | [
{
"body": "少し時間が経過してますが、この件は解決済みでしょうか?\n\n現在記述しているスクリプトの myFunctionがいきなり閉じているようですが??\n\n```\n\n function myFunction() {\n \n }\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-06-26T00:28:01.340",
"id": "27081",
"last_activity_date": "2016-06-26T00:28:01.340",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8672",
"parent_id": "24958",
"post_type": "answer",
"score": 1
}
]
| 24958 | null | 27081 |
{
"accepted_answer_id": "24961",
"answer_count": 1,
"body": "普段、開発しているさいにREPL(IPython)を使いながら挙動を確かめているのですが、クラスそれ自体が格納されているような変数を取りあつかう必要が出てきました。\n\n普通、クラスはREPLで以下のような表示になると思われます:\n\n```\n\n In [1]: Test\n Out[1]: __main__.Test\n \n```\n\nですが、以下のようなクラスを定義し:\n\n```\n\n class Test:\n def __repr__(self):\n return \"It works!!\"\n \n```\n\nインスタンスにすると、以下のように、REPL上の表示を変えることができます:\n\n```\n\n In [4]: Test()\n Out[4]: It works!!\n \n```\n\nこれと同様のことを、クラスそれ自体にも行ないたいのですが、どうすればいいでしょうか?",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T05:14:52.987",
"favorite_count": 0,
"id": "24960",
"last_activity_date": "2016-05-18T05:43:44.290",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "939",
"post_type": "question",
"score": 4,
"tags": [
"python"
],
"title": "インスタンスにおける__repr__を利用するような、インタプリタ上の表示の書きかえをクラスでも行ないたい",
"view_count": 584
} | [
{
"body": "REPLでの実行はプログラム的には `repr(obj)` によって処理されています。これは内部的には `obj.__repr__()`\nに近い動作です(実際はもうすこし処理が挟まります)。\n\nPython3.5での動作を例に説明します。\n\n```\n\n >>> class Foo:\n ... pass\n ... \n >>> Foo\n <class '__main__.Foo'>\n \n```\n\nこのようなFooの表示(repr(Foo)と同等)を制御したい、ということになります。 \nしかし、 `Foo.__repr__()` という実行は、__repr__メソッドにインスタンスが渡されないためエラーになります。\n\n```\n\n >>> Foo.__repr__()\n Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n TypeError: descriptor '__repr__' of 'object' object needs an argument\n \n```\n\nclassの__repr__メソッドはインスタンスのためのものなので、classのための__repr__メソッドを用意すればいいかな?とアタリをつけます。\n\nclassのための__repr__メソッドを用意するために、メタクラスを使います。\n\n```\n\n >>> class Type(type):\n ... def __repr__(cls):\n ... return \"Hello\"\n ... \n >>> \n >>> class Foo(metaclass=Type):\n ... def __repr__(self):\n ... return \"World\"\n ... \n >>> \n >>> Foo\n Hello\n >>> Foo()\n World\n \n```\n\nでも、metaclass使い始めたら自分のコードを疑った方が良い場合が多いので、本当に必要か、をよく考えて使ってください。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T05:43:44.290",
"id": "24961",
"last_activity_date": "2016-05-18T05:43:44.290",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "806",
"parent_id": "24960",
"post_type": "answer",
"score": 5
}
]
| 24960 | 24961 | 24961 |
{
"accepted_answer_id": "25093",
"answer_count": 2,
"body": "あるLSIで使用できるDMAの転送速度について調査を行っています。 \nデータシートなどで直接的に転送速度に関する記述が見つけられなかった為、困っています。 \nDMAの転送速度について、一般的にどのような情報があれば算出できるでしょうか。\n\n具体的な製品で言うと例えば Texas Instruments の CC1310 というLSIです。 \n<http://www.tij.co.jp/product/jp/CC1310>\n\n以下の資料で「Data sizes of 8, 16, and 32\nbits」という文言を見つけられたので、一度に書き込めるサイズはこれなのかなと思いました。 \nこの値にクロック周波数などをかければ、bpsに結びつきますでしょうか。 \n・CC1310 SimpleLink Ultralow Power Sub-1-GHz Wireless MCU \n<http://www.tij.co.jp/jp/lit/ds/symlink/cc1310.pdf>\n\n* * *\n\n@774RR \n回答頂きありがとうございます。 \nご認識のとおりです。\n\nまた、最近のマイコンについても教えて頂きありがとうございます。\n\n> DMA TransferSize * (1/Clock) /2\n\nこちらなのですが、以下の場合、認識に相違ないでしょうか。 \n・DMA TransferSize = 1024 \n・Clock = 10kHz \n1024 * (1/10000) / 2 = 転送レート:0.0512 \nどこかで計算を間違えてる気がするのです、、すみません、、H/Wについて知識が浅いもので、ご教示頂けると幸いです。\n\n> (だからデータシートにも載っていないし載せることが不可能)\n\nこちらについては、わからないと DMA を使う意味がわからないと思いました。 \nその為、厳密な値でなくても、参考値みたいなものまではたどり着ける必要があるかなと思いました。 \nこういった場合によく使う求め方があったりしないかなぁと思い、質問した次第です。\n\n* * *\n\n追記\n\n> それはその通りなんですが、データシートを深く理解する時間が取れない場合も多々あります。 \n> 最近はマイコンラインアップも充実してますし、最初の設計段階では深く考えずに \n> 「このマイコンのこのクロックで処理速度を実測して間に合わないなら、 \n> 上位マイコンにしてクロック上げちゃえ」 \n> などという恥ずべき設計者もかなり居る様子っす。\n\nなんと、そうなんですね。。非常に残念な実態です。。 \n自身が実装しようとしている物の上位にあたるシステムを理解せずに開発を進めるということですよね。。 \nWEBアプリなどでも言えることですが、フレームワークのふるまいを理解せずに開発するのって、バグの温床だと思っています。。 \nまた、リソースを増やすことで問題解決って、、なんか残念ですね。。まあ、よくある話なのはわかっています。。笑\n\n> 実際それで行けちゃう(コスト的に)場合も多いので、それなら開発期間短縮のほうが優先、 \n> なんてのが多いようですね。\n\nちょっと、ショックですがコストなど含めて問題ないのであれば、そうなってしまうのかもしれないですね。。\n\n> あるいは通常の割り込み処理でソフトウエア処理しても間に合うマイコンを採用するとか。 \n> ソフトウエア処理では間に合わなくて DMA だと間に合う、ようなぎりぎりの設計することは \n> オイラの周りでは稀っす。\n\nそうなのですね。 \n今回は、「ある時間」内に、ADCからの音声データをソフトコーデックしながら...というシステムなのですが、ADCからのデータをマイコンに割り込みで渡していてはソフトコーデックに支障が出て、間に合わないのでは?という推測により、DMAの利用を検討していました。 \n私の個人的意見になってしまうのですが、今回の様な要件については「DMA\nだと間に合う」っていうのはH/Wを有効に使えているのでシステムとして良いかなと思いました。\n\n> そこまでぎりぎりだと機能追加していくと破綻すること必至だし。\n\n\"ソフト\"の機能追加という意味ならば、DMAで処理を分散したほうが、マイコンの余裕もできて、むしろ拡張性もあるかなと感じました。\n\n> DMA TransferSize / (1/Clock) / (1+1)\n\nすみません、ちょっと分からないのですが、周波数は1秒間のサイクル数ですよね? \nそうなると、「DMA TransferSize * Clock」ではダメでしょうか? \n要するに、例だと「32bit * 48MHz」かなと思いました。 \nそれから、1clockで1bitだけのRead/Writeって考えにくくないでしょうか? \nだいたい、1clockでワード単位ではないですか?なので「/\n(1+1)」について疑問に思ってしまいました。あえて、計算に加えなくても良いかなとも思えました。 \n(検討違いなこと言っていたら、すみません。。)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T08:24:58.513",
"favorite_count": 0,
"id": "24964",
"last_activity_date": "2016-05-23T04:44:50.343",
"last_edit_date": "2016-05-19T01:38:40.530",
"last_editor_user_id": "15316",
"owner_user_id": "15316",
"post_type": "question",
"score": 0,
"tags": [
"c"
],
"title": "Direct Memory Access (DMA)の転送速度の計算方法について",
"view_count": 2800
} | [
{
"body": "DMA ってことは周辺装置の FIFO から RAM へ RAM から FIFO へ転送したいってことだと思うのですが \n周辺装置/RAM/ROM のアクセスクロックが同じで、アクセスウエイトが 0 ならば\n\n```\n\n DMA TransferSize / (1/Clock) / (1+1)\n \n```\n\nで転送レートになるでしょうね (1ビットの転送には Read+Write が必要なので /(1+1) っす)\n\n実際には、最近のマイコンは core だけやたら速くて周辺回路は遅いのが多く \n例えば Renesas の例では RX マイコンとか SH マイコンとかだと \nRAM のクロック (ICLK) と周辺回路のクロック (PCLK) は異なるように使うのが普通です。 \nしかも例えば ICLK=96MHz PCLK=48MHz にて動作させると \nRAM は ICLK で 0wait なのに対して (1ICLK 動作) \nI/O は PCLK で 3wait を要する (4PCLK 動作 = 8ICLK 相当) \nなどとなっています。\n\nマイコンの動作クロックは応用目的でみな違うように使うものですし、 \nあなたが動作させているクロックモードでマイコンコア・周辺回路がどう振る舞うかを \nデータシートを厳密に読んで分析しないと正しい答えが出せません。\n\n結論的には簡単には求まらないってことになりそうです。 \n(だからデータシートにも載っていないし載せることが不可能)\n\n以下追記・すみません最初の式が間違ってますよね。読み直してください。\n\nちょっと例を計算してみましょう。 \n転送バイト数は計算に入れなくていいの OK ですか? \n(1回の転送で何ビット転送できるかだけが要考慮)\n\nRX マイコンのような ICLK と PCLK が違うマイコンを想定します。 RAM は 0wait とします。\n\nICLK=48MHz で RAM から RAM へ DMA (意味がないけど) 32bit Transfer とすると \nDMA の1転送に RAM READ 1ICLK と RAM WRITE 1ICLK を要するので\n\n```\n\n 32bit / (1/48MHz) sec / (1+1) = 768 Mbit/s (除数は 1000)\n \n```\n\n同様 PCLK=24MHz でアクセスに 3wait が必要な 16bit FIFO から RAM へ転送するとして\n\nDMAC が I/O と RAM をオーバーラップアクセスできない場合 \n最初の FIFO の READ に 4PCLK=8ICLK \n最初の RAM の WRITE に 1ICLK \n次の FIFO の READ のためには PCLK/ICLK の同期が必要で +1ICLK \nということは\n\n```\n\n 16bit / (1/48MHz) sec / (8+1+1) = 76.8Mbit/sec (除数は 1000)\n \n```\n\nDMAC が I/O と RAM をオーバーラップアクセスできる場合 \n最初の FIFO の READ に 4PCLK=8ICLK \n次の FIFO の READ をしながら最初の RAM WRITE ができるので \nRAM 側のアクセス時間は FIFO のアクセス時間に吸収されてしまうことになり\n\n```\n\n 16bit / (1/48MHz) sec / (8) = 96Mbit/sec (除数は 1000)\n \n```\n\nなんかえらい差が出てますね。 \n実際のマイコンがどっちなのかはデータシートの深い読み込みが必要です。\n\n> わからないと DMA を使う意味がわからないと思いました。\n\nそれはその通りなんですが、データシートを深く理解する時間が取れない場合も多々あります。 \n最近はマイコンラインアップも充実してますし、最初の設計段階では深く考えずに \n「このマイコンのこのクロックで処理速度を実測して間に合わないなら、 \n上位マイコンにしてクロック上げちゃえ」 \nなどという恥ずべき設計者もかなり居る様子っす。 \n実際それで行けちゃう(コスト的に)場合も多いので、それなら開発期間短縮のほうが優先、 \nなんてのが多いようですね。\n\nあるいは通常の割り込み処理でソフトウエア処理しても間に合うマイコンを採用するとか。 \nソフトウエア処理では間に合わなくて DMA だと間に合う、ようなぎりぎりの設計することは \nオイラの周りでは稀っす。 \nそこまでぎりぎりだと機能追加していくと破綻すること必至だし。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T10:25:51.107",
"id": "24968",
"last_activity_date": "2016-05-18T13:11:03.220",
"last_edit_date": "2016-05-18T13:11:03.220",
"last_editor_user_id": "8589",
"owner_user_id": "8589",
"parent_id": "24964",
"post_type": "answer",
"score": 1
},
{
"body": "コメントでは引用しづらいので別回答の形式で\n\n> そうなると、「DMA TransferSize * Clock」ではダメでしょうか?\n\nはい、問題ないです。個人的に、オイラがこの手の計算するときの考え方として、 \n求めたい解が bit / sec であれば「 ビット数 割る 時間 」になるよう式を考えるので \nああいう書き方をしました。 \nただし、この式はバスアクセスに何クロックかかるかを計算していませんので未完成です。\n\n> それから、1clockで1bitだけのRead/Writeって考えにくくないでしょうか? \n> だいたい、1clockでワード単位ではないですか?\n\nCPU core にせよ DMAC にせよ、考え方は \n\\- 1回のバスアクセス何ビットが転送できるか \n\\- 1回のバスアクセスで何クロックがかかるか \n(速度の考察ならここまで。必要時間の計算なら下記も) \n\\- バスアクセス何回が必要か \nです。\n\n1回のバスアクセスで1ビット転送というのは指摘のとおりまずありえません。 \nでは何ビットの転送ができるか、というと周辺装置のアクセスにはハードウエアによる制約が \n課せれていることが多く、それで決まってしまいます。 \n32bit なマイコンでも、特定ポートは 8bit アクセスのみ許可なんてのはよくあります。 \nその場合先の DMA TransferSize=8 になってしまいます。 \nもちろん 32bit アクセス可能なポートなら 32bit DMA できて DMA TransferSize=32 っす。\n\n> なので「/ (1+1)」について疑問に思ってしまいました。\n\nこの除算は1回のバスアクセスに何クロックかかるか、の考慮分ですので必要です。 \nRead と Write が同時にできないなら Read に1クロック Write に1クロック必要なので \n「1回の転送」には2クロックが必要です。\n\nRAM/ROM は 0wait (1clock) でアクセスできるとしても、 \n周辺回路のアクセスには複数クロックが必要なことが多いです。 \n実際に何クロックかかるかはデータシートを見る必要があります。\n\nで、最終的にどのくらいの性能が出るかの例は前のコメントで計算したような感じになりますね。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-23T04:44:50.343",
"id": "25093",
"last_activity_date": "2016-05-23T04:44:50.343",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "8589",
"parent_id": "24964",
"post_type": "answer",
"score": 0
}
]
| 24964 | 25093 | 24968 |
{
"accepted_answer_id": null,
"answer_count": 1,
"body": "以下のような文字列があり、[]を取り除きたいです。どのような正規表現を書けば実現できますでしょうか。 \n詳しい方、ご教示下さい。\n\nあいうえお[aiu] \n↓ \nあいうえお",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T08:26:28.757",
"favorite_count": 0,
"id": "24965",
"last_activity_date": "2016-06-26T12:00:54.773",
"last_edit_date": "2016-06-26T12:00:54.773",
"last_editor_user_id": "3974",
"owner_user_id": "8619",
"post_type": "question",
"score": 0,
"tags": [
"php",
"html",
"正規表現"
],
"title": "文字列の中から[]で囲った部分を除去する正規表現",
"view_count": 4247
} | [
{
"body": "正規表現で取り除く、ということで[preg_replace](http://php.net/manual/ja/function.preg-\nreplace.php)を使うものと推察します。また、削除対象は文字列末尾の`[`と`]`で囲まれた文字列であると理解して、この場合は以下のような正規表現を用いて部分文字列を削除します。\n\n```\n\n $input = 'あいうえお[aiu]';\n \n $regexp = '/\\[[^\\]]*\\]$/m';\n \n $output = preg_replace($regexp, '', $input);\n \n```\n\n* * *\n\n正規表現について一定程度知識をお持ちでしたらここは蛇足です。\n\n```\n\n \\[[^\\]]*\\]$\n \n```\n\n\n\n[Debuggex Demo](https://www.debuggex.com/r/GBFym9oyiq8YBfGD)\n\n正規表現の構成は、まず`[`で始まる部分文字列の検索を開始し、`[^\\]*`の部分で終了文字である`]`がみつかるまでマッチングを続けます。その後`]`が来れば部分文字列としてマッチします。質問内容から文字列の末尾を想定して、最後の`$`でこの部分文字列が文字列の最後にある条件を設定していますが、場所が不定であればこれを削除することで期待する処理が得られるでしょう。\n\n* * *\n\nそれ以外に、この順番で文字列が来るならば、正規表現を使わずに`[`で文字列を分割して、最初の要素を取り出すやり方もあります。\n\n```\n\n $output = array_shift(explode('[', $input));\n \n```\n\nあるいは、`preg_match`で必要な前半部分をマッチさせて取り出したりすることもできます。\n\n```\n\n if (preg_match('/^[^\\[]*/m', $input, $matches)) {\n $output = $matches[0];\n }\n \n```\n\nいろいろ試してみて、必要に見合った適切なものを見つけてみてください。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T13:41:06.530",
"id": "24977",
"last_activity_date": "2016-05-18T13:41:06.530",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": null,
"parent_id": "24965",
"post_type": "answer",
"score": 5
}
]
| 24965 | null | 24977 |
{
"accepted_answer_id": "24972",
"answer_count": 1,
"body": "```\n\n shop = Shop.first\n # <Shop id: 1, name: \"お店の名前\", tel: \"お店の電話番号\">\n \n```\n\nこのようなデータがあります。\n\n`locals/ja.yml`にモデルのカラムに対応する表示用の名前をつけたのですが、これをフォーム以外で使うにはどうしたらよいのでしょうか。\n\n```\n\n shop.id.label\n # => ID\n shop.name.label\n # => 店名\n shop.tel.label\n # => 電話番号\n \n```\n\nこのように扱いたいのですが。",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T11:19:20.503",
"favorite_count": 0,
"id": "24970",
"last_activity_date": "2016-05-18T12:17:06.960",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "9149",
"post_type": "question",
"score": 1,
"tags": [
"ruby-on-rails",
"rails-activerecord"
],
"title": "railsでラベルを取得するほうほう",
"view_count": 523
} | [
{
"body": "`.human_attribute_name` を利用してみてはいかがでしょうか?\n\n```\n\n Shop.human_attribute_name(:id)\n Shop.human_attribute_name(:name)\n Shop.human_attribute_name(:tel)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T12:17:06.960",
"id": "24972",
"last_activity_date": "2016-05-18T12:17:06.960",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2646",
"parent_id": "24970",
"post_type": "answer",
"score": 3
}
]
| 24970 | 24972 | 24972 |
{
"accepted_answer_id": "24988",
"answer_count": 2,
"body": "**XMLHttpRequestで他オリジンへGET送信したら、コンソールログに下記エラーが表示されました** \n※GET送信内容自体は、(送信先で)受信できました\n\n> XMLHttpRequest cannot load\n> [http://foo.送信先.com/](http://foo.%E9%80%81%E4%BF%A1%E5%85%88.com/). No \n> 'Access-Control-Allow-Origin' header is present on the requested \n> resource. Origin\n> '[http://bar.送信元.co.jp](http://bar.%E9%80%81%E4%BF%A1%E5%85%83.co.jp)' is\n> therefore not allowed \n> access.\n\n* * *\n\n**質問** \n・どう評価したら良いでしょうか? \n・「同一生成元ポリシー」には、データ送信は含まれないのでしょうか? \n・それとも、違反ではあるけれどもデータが送信されているのでしょうか? つまり非推奨? \n\n* * *\n\n**最終的に知りたいこと** \n・XMLHttpRequestで他オリジンへGET送信してもよいか \n※送信元での結果取得は不要です\n\n* * *\n\n**追記**\n\n・GETリクエスト送信だけを XMLHttpRequest\nを使用して行う場合、「Webサーバー側でクロスオリジンを認めない」限りコンソールログにエラーメッセージは出力される、ということでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T14:54:00.490",
"favorite_count": 0,
"id": "24978",
"last_activity_date": "2016-05-20T10:29:58.530",
"last_edit_date": "2016-05-20T10:29:58.530",
"last_editor_user_id": "7886",
"owner_user_id": "7886",
"post_type": "question",
"score": 3,
"tags": [
"javascript",
"ajax"
],
"title": "XMLHttpRequestで他オリジンへGET送信したら、送信内容自体は(送信先で)受信できたのにエラー表示",
"view_count": 598
} | [
{
"body": "クロスオリジン、つまり別ドメインからのリクエストを受け付けるかどうかを決定するのはWebサーバーです。 \nコンソールログに出力されたエラーメッセージは「 **Webサーバー** はクロスオリジンを認めるのであれば、その旨を明示すべき」と言っています。\n\n説明が重複しますが、次のステップですのでブラウザーとしてはリクエストは送信されますし、エラーで正しいです。\n\n 1. ブラウザーはドメインA Webサーバーへリクエストを出す\n 2. ドメインA Webサーバーは「ドメインBへのリクエスト」を含むコンテンツを返す\n 3. ブラウザーはコンテンツに従いドメインB Webサーバーへリクエストを出す\n 4. ドメインB Webサーバーは単純にレスポンスを返す\n 5. ブラウザーはレスポンスヘッダーにクロスオリジンを認める旨が含まれていないことを検出し、エラーとする",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T21:27:12.507",
"id": "24981",
"last_activity_date": "2016-05-18T21:27:12.507",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "4236",
"parent_id": "24978",
"post_type": "answer",
"score": 2
},
{
"body": "クロスオリジンでのGETリクエスト送信自体は XMLHttpRequest を使わずとも `<script>` タグや `<img>`\nタグでできていたことですから、特に制限はありません。例えば画像のURLに情報を埋め込むのはアクセス解析でよく使われる手法です。他にも `<form>`\nの送信先には別オリジンのURLを指定することができ、Javascriptから送信操作が行えます。\n\n問題になるのはこれらの手段では不可能だったこと、つまり\n\n * レスポンスをJavascriptで自由に読み取ること\n * GETやフォーム送信以外のリクエストを送信すること\n\nであり、同一オリジンポリシーはこれらを制限するようになっています。\n\n送信自体が制限される後者の場合はプリフライトリクエストで事前に確認が行われますが、前者の場合は単にレスポンスを読み取れないだけ、という挙動になります。\n\n## 参考\n\n * [同一オリジンポリシー - Web セキュリティ | MDN](https://developer.mozilla.org/ja/docs/Web/Security/Same-origin_policy#Cross-origin_network_access)\n * [HTTP アクセス制御 (CORS) | MDN](https://developer.mozilla.org/ja/docs/HTTP_access_control)\n\n* * *\n\n読み取れないだけと書きましたが、規格上はレスポンスを受け取ったらすぐにチェックが行われます。またチェックに失敗した場合は\n**ネットワークエラーという扱い** で、Javascriptからはリクエストが成功したのかどうかもわかりません。\n\n<https://www.w3.org/TR/cors/#simple-cross-origin-request-0>\n\nそれをコンソールに表示するのはブラウザの機能ですから、[404などで表示される場合と同様](https://ja.stackoverflow.com/a/11293/8000)、ブラウザの設定で非表示にできるぐらいで、Javascript側で制御することはできないかと思います。",
"comment_count": 1,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-19T06:40:01.407",
"id": "24988",
"last_activity_date": "2016-05-19T13:49:56.027",
"last_edit_date": "2017-04-13T12:52:39.113",
"last_editor_user_id": "-1",
"owner_user_id": "8000",
"parent_id": "24978",
"post_type": "answer",
"score": 1
}
]
| 24978 | 24988 | 24981 |
{
"accepted_answer_id": null,
"answer_count": 2,
"body": "Rails で次のようなtableの表を作成する際、いつもif文を用いて実装しております。 \n※ slimで記載しております\n\ncategories/index.html.slim\n\n```\n\n - if store.categorys.present?\n - store.categorys.each do |category|\n tr\n td = category.id\n td = category.name\n td = link_to '編集', new_store_category_path(store.id)\n - else\n td\n td\n td = link_to '新規作成', new_store_category_path(store.id)\n \n```\n\nこれで意図した表は作成できており、今回のようにtdの数が少ない時はいいのですが、tdの数が10個近くあるようなtableを作成する場合、可読性がかなり悪くなります。\n\nこれを何とかリファクタリングしたいと思い調べたところ、content_tagを用いたヘルパーを使えば実現できるのかもしれないというところまでわかり、content_tagを用いたサンプルコードなどを用いて色々と試しておりました。\n\nしかし、上手くいかず、困っております。\n\n目的としては、複数箇所でこういったif文での分岐で、使いわけるtableのリファクタリングです。よろしくお願いします。",
"comment_count": 0,
"content_license": "CC BY-SA 4.0",
"creation_date": "2016-05-18T16:17:40.713",
"favorite_count": 0,
"id": "24980",
"last_activity_date": "2023-05-05T22:03:45.410",
"last_edit_date": "2022-11-22T00:08:53.677",
"last_editor_user_id": "3060",
"owner_user_id": "13175",
"post_type": "question",
"score": 0,
"tags": [
"ruby-on-rails",
"ruby"
],
"title": "次のようなtableをcontent_tagを用いてhelperとして作成したい",
"view_count": 818
} | [
{
"body": "コメントではコードが書けないので、回答側で失礼しますが、質問です。 \nリファクタリングしたい、ということですが、範囲が広く求めているゴールが分かりませんでした。 \n問題意識が下記であれば、繰り返しを使って、まとめれば良いのではないかしら?と思います。\n\n> tdの数が10個近くあるようなtableを作成する場合、可読性がかなりわるくなります。\n```\n\n - if store.categorys.present?\n - store.categorys.each do |category|\n tr\n td = category.id\n td = category.name\n td = link_to '編集', new_store_category_path(store.id)\n - else\n - 2.times.each do \n td\n td = link_to '新規作成', new_store_category_path(store.id)\n \n```\n\n2つなので、`2.times`ですが、10個なら、`10.times`が使えると思います。 \nこの問題だけでしたら、シンプルに回答できてしまいますので、より具体的なイメージ、擬似コードなどを追加していただけないでしょうか?",
"comment_count": 2,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-18T22:13:03.637",
"id": "24982",
"last_activity_date": "2016-05-18T22:13:03.637",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "7471",
"parent_id": "24980",
"post_type": "answer",
"score": 0
},
{
"body": "helper を用意しなくても次のように String の乗算演算子を使って簡潔に記述できます。\n\n```\n\n - if store.categorys.present?\n - store.categorys.each do |category|\n tr\n td = category.id\n td = category.name\n td = link_to '編集', new_store_category_path(store.id)\n - else\n == content_tag(:td) * 2\n td = link_to '新規作成', new_store_category_path(store.id)\n \n```\n\n繰り返す数は掛ける数(上記では 2 )を変えるだけです。 \nただし、slim の `==` 表記(rawヘルパーと同等)を使っていることに注意してください。\n\nもしどうしてもヘルパー化したい場合は、そのままメソッド化することもできます。\n\nhelpers/table_helper.rb\n\n```\n\n module TableHelper\n def empty_td(count=1)\n raw(content_tag(:td) * count)\n end\n end\n \n```\n\nviews/categories/index.html.slim\n\n```\n\n - if store.categorys.present?\n - store.categorys.each do |category|\n tr\n td = category.id\n td = category.name\n td = link_to '編集', new_store_category_path(store.id)\n - else\n = empty_td(2)\n td = link_to '新規作成', new_store_category_path(store.id)\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2017-02-13T16:29:58.580",
"id": "32644",
"last_activity_date": "2017-02-13T16:29:58.580",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "19925",
"parent_id": "24980",
"post_type": "answer",
"score": 0
}
]
| 24980 | null | 24982 |
{
"accepted_answer_id": "24993",
"answer_count": 1,
"body": "### 前提・実現したいこと\n\nCentOS7 で、CentOS6 での runlevel に当たる設定がしたいです。 \nservice に対する設定方法と確認方法がわかりません。\n\n具体的には、CentOS7 で以下の代替となるコマンドを教えていただきたいです。\n\n```\n\n $ sudo chkconfig --level=2345 mysql on <- runlevel を設定\n $ chkconfig --list mysql <- 設定された runlevel を確認\n mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off\n \n```\n\n### 調べたこと\n\nCentOS7では、runlevel ではなく target という概念に変わっていることは \nなんとなくわかったのですが、 \nservice に対する設定方法と確認方法がわかりません。\n\n以下コマンドが chconfig --list の代替とされていたのですが、 \ntarget の確認ができません。また、target の変更方法もわかりませんでした。\n\n```\n\n systemctl list-unit-files\n \n```",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-19T04:27:34.337",
"favorite_count": 0,
"id": "24985",
"last_activity_date": "2016-05-19T08:28:44.523",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "15567",
"post_type": "question",
"score": 1,
"tags": [
"centos"
],
"title": "CentOS7(Systemd) で service に target を設定する方法",
"view_count": 917
} | [
{
"body": "### runlevel に対応する target の確認\n\n`/lib/systemd/system/runlevel*.target` のリンク先を見ることで概ね理解できるかと思います。\n\n```\n\n [centos@localhost ~]$ ls -l /lib/systemd/system/runlevel*.target\n lrwxrwxrwx. 1 root root 15 Feb 15 14:40 /lib/systemd/system/runlevel0.target -> poweroff.target\n lrwxrwxrwx. 1 root root 13 Feb 15 14:40 /lib/systemd/system/runlevel1.target -> rescue.target\n lrwxrwxrwx. 1 root root 17 Feb 15 14:40 /lib/systemd/system/runlevel2.target -> multi-user.target\n lrwxrwxrwx. 1 root root 17 Feb 15 14:40 /lib/systemd/system/runlevel3.target -> multi-user.target\n lrwxrwxrwx. 1 root root 17 Feb 15 14:40 /lib/systemd/system/runlevel4.target -> multi-user.target\n lrwxrwxrwx. 1 root root 16 Feb 15 14:40 /lib/systemd/system/runlevel5.target -> graphical.target\n lrwxrwxrwx. 1 root root 13 Feb 15 14:40 /lib/systemd/system/runlevel6.target -> reboot.target\n \n```\n\n### runlevel(相当)設定変更\n\nユニット定義ファイル内`[Intall]`セクションの`WantedBy`ディレクティブに記述します。 \n(以下`yum install mariadb-server`でインストールしたmariadbについて書きますので適宜読み替えてください。)\n\nCentOSオフィシャルパッケージをインストールした場合、ユニット定義ファイルは `/usr/lib/systemd/system/` に置かれます。\nここにある `mariadb.service`ファイルを `/etc/systemd/system/` へコピーし、それを編集します。\n\nデフォルトでは\n\n```\n\n [Install]\n WantedBy=multi-user.target\n \n```\n\nとなっているので前節の情報と照らし合わせると`--level=2345`相当であることがわかります。 \nこれを、例えば`--level=5`相当に変更するのであれば、`multi-user.target`を`graphical.target`に書き換えます。\n\n編集が終わったらサービスを有効化します。\n\n```\n\n # systemctl enable mariadb.service\n \n```\n\n### 設定確認\n\n上記コマンド実行後、対応するディレクトリ `/etc/systemd/system/*.wants/`\nにシンボリックリンクが置かれますので`ls`で確認できます。\n\n```\n\n $ ls /etc/systemd/system/*.wants/\n (前略)\n /etc/systemd/system/graphical.target.wants/:\n mariadb.service\n (後略)\n \n```\n\n正確な意味合いは異なる(WantedByだけが対象ではない)ようですが、ある特定のサービスについて調べたいのであれば`systemctl list-\ndependencies --reverse`コマンド出力も役に立つかもしれません。\n\n```\n\n $ systemctl list-dependencies --reverse mariadb.service\n mariadb.service\n ● └─graphical.target\n \n```\n\n### 参考\n\n * [SysVinit to Systemd Cheatsheet - FedoraProject](https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet)\n * man page: systemd.special(7), systemd.directives(7), systemd.service(5), systemd.unit(5), systemctl(1)",
"comment_count": 0,
"content_license": "CC BY-SA 3.0",
"creation_date": "2016-05-19T08:28:44.523",
"id": "24993",
"last_activity_date": "2016-05-19T08:28:44.523",
"last_edit_date": null,
"last_editor_user_id": null,
"owner_user_id": "2808",
"parent_id": "24985",
"post_type": "answer",
"score": 3
}
]
| 24985 | 24993 | 24993 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.