question
dict
answers
list
id
stringlengths
2
5
accepted_answer_id
stringlengths
2
5
popular_answer_id
stringlengths
2
5
{ "accepted_answer_id": null, "answer_count": 2, "body": "Storyboard上でNavigationControllerとViewControllerを RelationShipSegue, root view\ncontroller\nで関連付ける処理を、NavigationControllerとViewControllerがそれぞれ別のStoryboardにある場合はどのようにすればいいんでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T03:51:59.090", "favorite_count": 0, "id": "8464", "last_activity_date": "2015-09-14T13:30:04.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8060", "post_type": "question", "score": 0, "tags": [ "ios", "storyboard" ], "title": "別のストーリーボードのNavigationControllerとViewControllerを関連つけたい", "view_count": 393 }
[ { "body": "ストーリボード間でセグエを設定することはできません。コード上で行うしかありません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-06-16T08:28:10.727", "id": "11403", "last_activity_date": "2015-06-16T08:28:10.727", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9558", "parent_id": "8464", "post_type": "answer", "score": 0 }, { "body": "もしXcode7でターゲットがiOS9であれば、Storyboardから別のStoryboardを参照できるようになりました\n\n<https://developer.apple.com/library/prerelease/ios/recipes/xcode_help-\nIB_storyboard/Chapters/AddSBReference.html>\n\nですが、iOS9より前のiOSでは利用できないので別のStoryboardを参照するにはコードで呼び出すしかないですね。例えばUIStoryboardのクラスメソッドstoryboardWithName:bundle:などを使います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-09-14T13:30:04.120", "id": "16600", "last_activity_date": "2015-09-14T13:30:04.120", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7374", "parent_id": "8464", "post_type": "answer", "score": 1 } ]
8464
null
16600
{ "accepted_answer_id": "8471", "answer_count": 2, "body": "<http://qiita.com/jtemplej/items/1c1b7204341ac01e561e>\n\n上記のサイトを参考に`Realm`を使い始めたのですが、`for realmBook in\nBook.allObjects()`の行で`'RLMResults' does not have a member named\n'Generator'`というエラーが表示されます。何か初歩的なことが間違っているような気がするのですが、どこが間違っているのでしょうか?下記に現在のコードを記しますので、どなたか分かる方がいれば教えていただきたいです。すみませんが、よろしくお願いします。\n\nBook.swift\n\n```\n\n import Foundation\n import Realm\n \n class Book : RLMObject {\n dynamic var isbn = \"\"\n dynamic var name = \"\"\n dynamic var price = 0\n }\n \n```\n\nViewController.swift\n\n```\n\n import UIKit\n import Realm\n \n class ViewController: UIViewController {\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view, typically from a nib.\n \n stockData()\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n \n func stockData() {\n let realm = RLMRealm.defaultRealm()\n \n // Bookオブジェクト生成.\n let book = Book()\n book.isbn = \"999999\"\n book.name = \"realm sample\"\n book.price = 100\n \n // Bookオブジェクトを保存.\n realm.beginWriteTransaction()\n realm.addObject(book)\n realm.commitWriteTransaction()\n \n // 先ほどのBookオブジェクトを取得\n // Class.allObjectsで全オブジェクト取得.\n for realmBook in Book.allObjects() {\n // book name:realm sample\n println(\"book name:\\((realmBook as Book).name)\")\n }\n \n let book2 = Book()\n book2.isbn = \"999998\"\n book2.name = \"realm tutorial 1\"\n book2.price = 1000\n \n // Blockでの保存の仕方.\n realm.transactionWithBlock() {\n realm.addObject(book2)\n }\n \n for realmBook in Book.allObjects() {\n // book name:realm sample\n // book name:realm tutorial 1\n println(\"book name:\\((realmBook as Book).name)\")\n }\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T04:07:52.577", "favorite_count": 0, "id": "8466", "last_activity_date": "2015-03-27T05:30:59.010", "last_edit_date": "2015-03-27T04:24:43.303", "last_editor_user_id": "5210", "owner_user_id": "5210", "post_type": "question", "score": 1, "tags": [ "swift", "realm" ], "title": "RLMResults' does not have a member named 'Generator", "view_count": 390 }
[ { "body": "`import Realm`してないからじゃないですか?Realmフレームワークを使っているswiftファイルは、すべてimportしてみましょう。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T04:17:33.107", "id": "8467", "last_activity_date": "2015-03-27T04:17:33.107", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "8466", "post_type": "answer", "score": 1 }, { "body": "ここを見る限りでは「RLMSupport.swift」というファイルが必要なようですが入っていますか?\n\n<https://github.com/realm/realm-cocoa/issues/1487>", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T05:30:59.010", "id": "8471", "last_activity_date": "2015-03-27T05:30:59.010", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3516", "parent_id": "8466", "post_type": "answer", "score": 1 } ]
8466
8471
8467
{ "accepted_answer_id": "8474", "answer_count": 1, "body": "Cookieを用いて要素の表示・非表示を行いたいのですが、うまくいきません。\n\n求めている一連の動作は、\n\n1:要素A,B,C ← 要素別にクリックしたらKEYを保存 \n2:ページにアクセス時、クリック時に保存したKEYの有無の確認・取得 \n3:クリックしていないのであれば、display:none;している要素をdisplay:block;させる\n\nといった処理を行いたいのですが、Cookieには疎く求めている動作を実現させることができません。\n\n文章での説明なので、わかり辛いとは思いますが、どなたかお力を貸していただけないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T05:28:09.883", "favorite_count": 0, "id": "8470", "last_activity_date": "2015-03-27T05:52:52.553", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7887", "post_type": "question", "score": 0, "tags": [ "php", "jquery", "css" ], "title": "Cookieに要素をクリックしたらKEYを保存する", "view_count": 317 }
[ { "body": "<https://github.com/carhartl/jquery-cookie> を利用するのも手ですが……。 \ncookieって、サーバー側へ自動送信して、サーバー側で何か処理するためのというイメージがあります。\n\n質問にあるような目的であればSessionStorageを使うべきだと思います。 \nSessionStorageを使った場合は、サーバー側で何かする必要もなく \nJavaScriptだけの世界に閉じるので私ならそうします。 \n(参考:<http://www.htmq.com/webstorage/>)\n\njquery-cookieもSessionStorageもKVSライクに書けるので \nどちらかを使うべきだと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T05:52:52.553", "id": "8474", "last_activity_date": "2015-03-27T05:52:52.553", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8335", "parent_id": "8470", "post_type": "answer", "score": 1 } ]
8470
8474
8474
{ "accepted_answer_id": "8494", "answer_count": 1, "body": "Amazon RDSのパラメータグループに使える`DBInstanceClassMemory`の値についての質問です。\n\n現在、RDSにMySQL5.6のdb.t2.microインスタンスを1つ持っています。 \nその`innodb_buffer_pool_size`はパラメータグループで下記のように定義されています。\n\n```\n\n {DBInstanceClassMemory*3/4}\n \n```\n\nこの `DBInstanceClassMemory`はインスタンスのメモリと同じ`1GB`になるんだろうと思っていたので、\n`innodb_buffer_pool_size`は、\n\n```\n\n 1*1024*1024*1024*3/4 = 805306368Bytes = 768MB\n \n```\n\nとなると思いました。 \nしかし、実際の値を見てみると下記のように`598MB`となっていました。\n\n```\n\n mysql> select @@innodb_buffer_pool_size/1024/1024;\n +-------------------------------------+\n | @@innodb_buffer_pool_size/1024/1024 |\n +-------------------------------------+\n | 598.00000000 |\n +-------------------------------------+\n \n```\n\nこれから逆算すると`DBInstanceClassMemory`は\n\n```\n\n 598/3*4 = 797MB\n \n```\n\nとなり、前述の1GBという予想より200MBほど少なくなります。\n\nこういうものなのでしょうか?あるいは計算間違いでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T06:06:10.770", "favorite_count": 0, "id": "8475", "last_activity_date": "2015-03-27T13:57:25.800", "last_edit_date": "2015-03-27T06:52:42.580", "last_editor_user_id": "3922", "owner_user_id": "3922", "post_type": "question", "score": 1, "tags": [ "aws" ], "title": "RDSのDBInstanceClassMemoryが200MB少ない?", "view_count": 1949 }
[ { "body": "RDS の\n[ユーザーガイド](http://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/USER_WorkingWithParamGroups.html#USER_FormulaVariables)によりますと\nインスタンスを管理する Amazon RDS プロセスによって使用されるメモリよりも小さくなります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T13:57:25.800", "id": "8494", "last_activity_date": "2015-03-27T13:57:25.800", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5008", "parent_id": "8475", "post_type": "answer", "score": 1 } ]
8475
8494
8494
{ "accepted_answer_id": "8481", "answer_count": 1, "body": "SSHで繋いだサーバーにあるテキストの内容をクリップボードにコピーする方法を探しています。\n\n現在はテキスト量が少なく画面内に収まるのであれば、`vim`で開いてマウスでの選択からのコピー、 \n多すぎる場合は`rsync`でダウンロードしてきてローカルで開くという方法をとっているのですが\n\nもっと簡単にサーバー上にある特定のファイルのテキスト全体をローカルのクリップボードにコピーする方法はないでしょうか?\n\n使用環境はMacでiTermを使っていますが、できるだけローカルの環境依存にしない方法を探しています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T06:23:31.093", "favorite_count": 0, "id": "8476", "last_activity_date": "2015-03-27T07:48:10.943", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3271", "post_type": "question", "score": 1, "tags": [ "ssh" ], "title": "SSH先のテキストの内容をローカルのクリップボードにコピーする方法", "view_count": 2645 }
[ { "body": "Macだと標準で`pbcopy`が使えます。\n\n```\n\n ssh [email protected] 'cat hello.txt' | pbcopy\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T07:48:10.943", "id": "8481", "last_activity_date": "2015-03-27T07:48:10.943", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "8476", "post_type": "answer", "score": 5 } ]
8476
8481
8481
{ "accepted_answer_id": "8480", "answer_count": 1, "body": "setAttributeでvideoタグにcontrolsを追加したいのですが、 \ncontrolsに第二引数のvalueはないので、element.setAttribute(name,value)に反してしまいエラーとなってしまいます。\n\nどのようにしてvideoタグにcontrolsを追加したらよいか分かりません。 \n分かる方がいましたら、ご教授をお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T07:06:22.423", "favorite_count": 0, "id": "8479", "last_activity_date": "2015-03-27T07:34:02.540", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7626", "post_type": "question", "score": 0, "tags": [ "javascript", "jquery", "html5" ], "title": "setAttributeでvideoタグにcontrolsを追加したい", "view_count": 1135 }
[ { "body": "変数videoがvideo要素を指している変数だとして、\n\n```\n\n video.setAttribute('controls', '');\n \n```\n\nです。実際は2番目のパラメータに何を入れても同じ意味です。setAttribute()を使わずに、\n\n```\n\n video.controls = true;\n \n```\n\nでもよいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T07:34:02.540", "id": "8480", "last_activity_date": "2015-03-27T07:34:02.540", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3475", "parent_id": "8479", "post_type": "answer", "score": 1 } ]
8479
8480
8480
{ "accepted_answer_id": null, "answer_count": 1, "body": "React.jsのチュートリアル(<https://facebook.github.io/react/docs/tutorial.html>)をやっていた所、以下のようなコードが出てきました。\n\n```\n\n // tutorial13.js\n var CommentBox = React.createClass({\n getInitialState: function() {\n return {data: []};\n },\n componentDidMount: function() {\n $.ajax({\n url: this.props.url,\n dataType: 'json',\n success: function(data) {\n this.setState({data: data});\n }.bind(this),\n error: function(xhr, status, err) {\n console.error(this.props.url, status, err.toString());\n }.bind(this)\n });\n },\n render: function() {\n return (\n <div className=\"commentBox\">\n <h1>Comments</h1>\n <CommentList data={this.state.data} />\n <CommentForm />\n </div>\n );\n }\n });\n \n```\n\nここのbind(this)とは、どういった意味なのでしょうか", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T08:04:05.033", "favorite_count": 0, "id": "8482", "last_activity_date": "2015-03-27T09:13:46.507", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4971", "post_type": "question", "score": 2, "tags": [ "javascript", "jquery", "ajax", "reactjs" ], "title": "bind(this)とは", "view_count": 3112 }
[ { "body": "<https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Function/bind>\n\nの例に、ドンピシャに書いてありました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T09:13:46.507", "id": "8485", "last_activity_date": "2015-03-27T09:13:46.507", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4971", "parent_id": "8482", "post_type": "answer", "score": 1 } ]
8482
null
8485
{ "accepted_answer_id": null, "answer_count": 1, "body": "monad-\ncontrolパッケージにはMonadTransControlとMonadBaseControlがありますが、どのような使い分けをするのが正しいのでしょうか? \n<http://maoe.hatenadiary.jp/entry/20111207/1323185162> \nには\n\n> 簡単に解説すると、MonadTransControlクラスのliftWith :: Monad m => (Run t -> m a) -> \n> t m aはモナドスタックt m aを一つpopした型m \n> aを弄れるようにする役割を持ち、MonadBaseControlのliftBaseWith :: (RunInBase m b -> b \n> a) -> m aは、スタックの最下部までpopしたベースモナドの型b aを弄れるようにする役割を持っています。\n\nとかいてありますが、どちらも一番下まで持ち上げなければなりませんでした。 \nMonadTransControlはMonadBaseControlを定義するための補助なのでしょうか?\n\n```\n\n {-# LANGUAGE ScopedTypeVariables #-}\n {-# LANGUAGE DeriveDataTypeable #-}\n {-# LANGUAGE FlexibleContexts #-}\n {-# LANGUAGE FlexibleInstances #-}\n {-# LANGUAGE GeneralizedNewtypeDeriving #-}\n {-# LANGUAGE MultiParamTypeClasses #-}\n {-# LANGUAGE StandaloneDeriving #-}\n {-# LANGUAGE TypeFamilies #-}\n {-# LANGUAGE UndecidableInstances #-}\n \n import Control.Monad.Base\n import Control.Monad.Reader\n import Control.Monad.State\n import Control.Applicative\n import Control.Monad.Trans.Control\n import Control.Monad.Identity\n import Control.Monad.Except\n import Control.Monad.Trans.Except\n import Data.Maybe\n import qualified Data.Map as Map\n \n type Name = String\n type Value = String\n type Env = Map.Map Name Value\n -- EvalRの内部\n newtype EvalE m a = EvalE {runEvalE :: ExceptT String m a}\n deriving (Functor\n , Applicative\n , Monad\n , MonadError String\n , MonadBase base\n )\n instance MonadTrans EvalE where\n lift = EvalE . lift\n \n instance MonadTransControl EvalE where\n type StT EvalE a = StT (ExceptT String) a\n liftWith = defaultLiftWith EvalE runEvalE\n restoreT = defaultRestoreT EvalE\n \n instance (MonadBaseControl b m) => MonadBaseControl b (EvalE m) where\n type StM (EvalE m) a = ComposeSt EvalE m a\n liftBaseWith = defaultLiftBaseWith\n restoreM = defaultRestoreM\n evalET :: (Monad (t []), MonadTransControl t) => t [] Int\n evalET = return 1\n evalEM :: (MonadBaseControl [] m) => m Int\n evalEM = return 1\n \n doEvalET :: EvalE [] Int -> EvalE [] Int\n doEvalET t = liftWith (\\run -> run t) >>= restoreT . return\n doEvalEM :: EvalE [] Int -> EvalE [] Int\n doEvalEM m = liftBaseWith (\\run -> run m) >>= restoreM\n \n exEvalE :: EvalE [] Int -> IO ()\n exEvalE = print . runEvalE\n exEvalET :: EvalE [] Int -> IO ()\n exEvalET = print . runEvalE . doEvalET\n exEvalEM :: EvalE [] Int -> IO ()\n exEvalEM = print . runEvalE . doEvalEM\n \n newtype EvalR m a = EvalR {runEvalR :: ReaderT Env (EvalE m) a}\n deriving (Functor\n , Applicative\n , Monad\n , MonadError String\n , MonadReader Env\n , MonadBase base\n )\n instance MonadTrans EvalR where\n lift = EvalR . lift . lift\n \n -- 全部持ち上げないとだめだった\n -- 本当は1つだけ持ち上げてEvalEにしかかった\n instance MonadTransControl EvalR where\n type StT EvalR a = StT EvalE (StT (ReaderT Env) a)\n liftWith f = EvalR $ liftWith $ \\runReader ->\n liftWith $ \\runEval ->\n f $ runEval . runReader . runEvalR\n restoreT = EvalR . restoreT . restoreT\n \n instance (MonadBaseControl b m) => MonadBaseControl b (EvalR m) where\n type StM (EvalR m) a = ComposeSt EvalR m a\n liftBaseWith = defaultLiftBaseWith\n restoreM = defaultRestoreM\n \n env :: Env\n env = Map.fromList [(\"0\", \"zero\"), (\"1\", \"one\")]\n \n doEvalRT :: EvalR [] Int -> EvalR [] Int\n doEvalRT t = do\n x <- liftWith $ \\r ->\n r t\n restoreT $ return x\n doEvalRM :: EvalR [] Int -> EvalR [] Int\n doEvalRM m = liftBaseWith (\\run -> run m) >>= restoreM\n \n exEvalR :: EvalR [] Int -> IO ()\n exEvalR = print . runEvalE . (flip runReaderT env) . runEvalR\n exEvalRT :: EvalR [] Int -> IO ()\n exEvalRT = print . runEvalE . (flip runReaderT env) . runEvalR . doEvalRT\n exEvalRM :: EvalR [] Int -> IO ()\n exEvalRM = print . runEvalE . (flip runReaderT env) . runEvalR . doEvalRM\n \n```\n\nそれとも型がt m aとm aで型が違うのでうまく使い分けるのでしょうか?\n\n```\n\n maybeTIO :: (Monad (t IO), MonadTransControl t) => t IO Int\n maybeTIO = lift (putStrLn \"testMaybeT\") >> return 1\n maybeMIO :: (MonadBaseControl IO m) => m Int\n maybeMIO = liftBase (putStrLn \"testMaybeT\") >> return 1\n \n twiceIO :: IO a -> IO a\n twiceIO action = action >> action\n \n testLiftWith :: MaybeT IO Int -> MaybeT IO Int\n testLiftWith f = liftWith (\\run -> twiceIO (run f)) >>= restoreT . return\n testLiftBaseWith :: MaybeT IO Int -> MaybeT IO Int\n testLiftBaseWith f = liftBaseWith (\\run -> twiceIO (run f)) >>= restoreM\n testControl :: MaybeT IO Int -> MaybeT IO Int\n testControl f = control (\\run -> twiceIO (run maybeTIO))\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T09:28:11.337", "favorite_count": 0, "id": "8486", "last_activity_date": "2015-03-30T06:37:30.683", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9043", "post_type": "question", "score": 1, "tags": [ "haskell" ], "title": "monad-controlのMonadTransControlとMonadBaseControlについて", "view_count": 187 }
[ { "body": "提示された例では、`MaybeT\nIO`という二階層のモナドスタックが使用されているため、`MonadTransControl`を使っても`MonadBaseControl`を使っても持ち上げられ方は変わりませんが、三階層以上のスタックを使うと違いが明確になります。\n\n以下の例では、`StateT Int (MaybeT\nIO)`という三階層のスタックを使っています。この場合、`MonadBaseControl`を使用した`testLiftBaseWith2`は自動的に二階層持ち上げてくれるので、`testLiftBaseWith`のコードがそのまま使えます。一方、`MonadTransControl`を使用した`testLiftWith2`では、一つの`liftWith`が一階層しか持ち上げないため、明示的に二回持ち上げる必要があります。\n\n```\n\n testLiftWith2 :: StateT Int (MaybeT IO) Int -> StateT Int (MaybeT IO) Int\n testLiftWith2 f = liftWith (\\runState -> liftWith (\\runMaybe -> twiceIO (runMaybe (runState f))) >>= restoreT . return) >>= restoreT . return\n \n testLiftBaseWith2 :: StateT Int (MaybeT IO) Int -> StateT Int (MaybeT IO) Int\n testLiftBaseWith2 f = liftBaseWith (\\run -> twiceIO (run f)) >>= restoreM\n \n```\n\n`MonadTrans`の`lift`が一階層しか持ち上げないのに対して、`MonadIO`の`liftIO`が最下層の`IO`を何階層でも持ち上げられるのと同様に考えれば良いと思います(`MonadBase`は`MonadIO`をSTモナドにも適用できるように一般化したものです)。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T04:34:59.580", "id": "8548", "last_activity_date": "2015-03-30T06:37:30.683", "last_edit_date": "2015-03-30T06:37:30.683", "last_editor_user_id": "3066", "owner_user_id": "3066", "parent_id": "8486", "post_type": "answer", "score": 2 } ]
8486
null
8548
{ "accepted_answer_id": "8493", "answer_count": 2, "body": "rubyの`String#ord`メソッドが何かの略称だと思うのですが探しても見つかりませんでした。 \n`order`などでしょうか?\n\n`codepoint`の方がしっくり来る気がするのですが、 \nメソッドの振る舞いを正確に理解できてないだけかもしれません。\n\n`ord`は何の略で何故そう決まったのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T11:18:49.757", "favorite_count": 0, "id": "8490", "last_activity_date": "2015-03-27T13:15:46.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3271", "post_type": "question", "score": 4, "tags": [ "ruby" ], "title": "Rubyのordメソッドは何の略称ですか?", "view_count": 1390 }
[ { "body": "なぜそう決まったかは判りませんが ordinal だと思います。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T11:26:10.540", "id": "8491", "last_activity_date": "2015-03-27T11:26:10.540", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2494", "parent_id": "8490", "post_type": "answer", "score": 4 }, { "body": "Rubyでordが採用された経緯そのものは直接には知りませんが、文字からそのコードを求める操作をordと呼ぶのは歴史が長いです。COBOLや初期のBASICにありましたし、PythonやPerlに備わっているのもその流れだと思います。\n\ncodepointは文字符号化の方からの用語ですが、本来は符号化文字の位置を特定する情報という意味なので、1次元のスカラ値とは限らないです(例えばJISの区点コードは2次元と言うこともできます。区と点をつなげちゃえばスカラ値として扱うこともできますが)。現代ではまずUnicode\ncodepointを思い浮かべるでしょうから曖昧さは少ないと思いますし、これからの言語ならcodepointの方がわかりやすいかもしれません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T13:15:46.770", "id": "8493", "last_activity_date": "2015-03-27T13:15:46.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5258", "parent_id": "8490", "post_type": "answer", "score": 3 } ]
8490
8493
8491
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在、理由は不明なのですが、 \n突然herokuへpushしようとするとエラーが出るようになってしまいました。\n\n```\n\n % git push heroku master --force\n Fetching repository, done.\n Total 0 (delta 0), reused 0 (delta 0)\n \n -----> Fetching custom git buildpack... done\n -----> Multipack app detected\n =====> Downloading Buildpack: https://github.com/markaschneider/heroku-buildpack-ruby-ffmpeg-sox.git\n =====> Detected Framework: Ruby\n -----> Compiling Ruby/Rails\n -----> Using Ruby version: ruby-2.0.0\n -----> Installing dependencies using 1.7.12\n Ruby version change detected. Clearing bundler cache.\n Old: ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-linux]\n New: ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-linux]\n Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment\n Fetching source index from http://rubygems.org/\n Net::HTTPNotFound: <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <Error><Code>NoSuchKey</Code><Message>The specified key does not\n exist.</Message><Key>quick/Marshal.4.8/0.1.0.gemspec.rz</Key><RequestId></RequestId><HostId></HostId></Error>\n Bundler Output: Fetching source index from http://rubygems.org/\n Net::HTTPNotFound: <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <Error><Code>NoSuchKey</Code><Message>The specified key does not\n exist.</Message><Key>quick/Marshal.4.8/0.1.0.gemspec.rz</Key><RequestId></RequestId><HostId></HostId></Error>\n !\n ! Failed to install gems via Bundler.\n !\n \n ! Push rejected, failed to compile Multipack app\n \n To [email protected]:app.git\n ! [remote rejected] master (pre-receive hook declined)\n error: failed to push some refs to '[email protected]:app.git'\n \n```\n\ngitでいくら遡っても、以前pushできていた物まで同じエラーが出てしまうのですが、どこを直せば良いのでしょうか?何時間考えても分かりません。\n\n[Heroku push rejected, Ruby Version Changed Detected, Could not find net-\nscp-1.0.6](https://stackoverflow.com/questions/15033607/heroku-push-rejected-\nruby-version-changed-detected-could-not-find-net-scp-1-0) \nを参考に \ngem cleanup \nbundle update \nしてみたり、 \npackage.json \nをルートに加えてみたりしましたが、何も変わりません。\n\nヒントだけでも教えていただければ、幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-27T17:07:38.373", "favorite_count": 0, "id": "8495", "last_activity_date": "2016-06-02T09:37:28.110", "last_edit_date": "2017-05-23T12:38:56.467", "last_editor_user_id": "-1", "owner_user_id": "7668", "post_type": "question", "score": 4, "tags": [ "ruby-on-rails", "heroku" ], "title": "herokuへpushできません。Failed to install gems via Bundler.Push rejected, failed to compile Multipack app", "view_count": 924 }
[ { "body": "もう既に解決されているかもしれませんが、試しに同じbuildpackでRails4.2をインストールしてみたところうまく同様のエラーは発生しませんでしたので、気になる点だけお伝えしておきます。\n\n * 現在はGemfileのsourceは `http` ではなく `https` が標準になっているので変更してみてはどうでしょう。\n * Gemfileの中にyankされた(リリースが取りけされた)バージョンのgemがない確認してみてください。この場合、ローカルには既にインストールできているので動作に問題がありませんが、新たにインストールしようとすると失敗することになります。\n\n完全な回答になっておらず申し訳ありませんが、ヒントになれば幸いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-04T08:53:10.907", "id": "17241", "last_activity_date": "2015-10-04T08:53:10.907", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2535", "parent_id": "8495", "post_type": "answer", "score": 1 } ]
8495
null
17241
{ "accepted_answer_id": "8500", "answer_count": 1, "body": "<http://3g28wn33sno63ljjq514qr87.wpengine.netdna-cdn.com/wp-\ncontent/uploads/2013/08/YouTube-Android-Update-1.png>\n\n上の画像の、リスト項目の右上に3つの点が書かれています。そこをタッチすると、その下、または上にメニューが表示されます。 \nこのようにActionBarやToolbarではない場所にMenuを実装するにはどうしたら良いのでしょうか。 \nよろしくおねがいします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T02:02:46.493", "favorite_count": 0, "id": "8498", "last_activity_date": "2015-03-28T03:27:38.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "android" ], "title": "ViewにMenuを実装したいです。", "view_count": 84 }
[ { "body": "[PopupMenu](http://developer.android.com/reference/android/support/v7/widget/PopupMenu.html)\nを使えば良いのではないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T03:27:38.687", "id": "8500", "last_activity_date": "2015-03-28T03:27:38.687", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7558", "parent_id": "8498", "post_type": "answer", "score": 0 } ]
8498
8500
8500
{ "accepted_answer_id": null, "answer_count": 1, "body": "JAVA_HOMEをterminalで変更したのですが、別タブのterminalでは初期の設定に戻ってしまいます。\n\nTerminal で設定した環境変数を、永続的に反映させたい場合どうするればよいですか?\n\n.bash_profileに直接書き込むのだと面倒なので、terminalで行いたいです。\n\n```\n\n export JAVA_HOME=`/usr/libexec/java_home -v 1.7`\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T03:38:52.603", "favorite_count": 0, "id": "8502", "last_activity_date": "2015-03-28T03:56:21.520", "last_edit_date": "2015-03-28T03:56:21.520", "last_editor_user_id": "3639", "owner_user_id": "8782", "post_type": "question", "score": 1, "tags": [ "bash" ], "title": "Terminal で設定した環境変数を、永続的にしたい", "view_count": 904 }
[ { "body": "普通にリダイレクトすれば良いのではないでしょうか。\n\n```\n\n echo 'export JAVA_HOME=`/usr/libexec/java_home -v 1.7`' >> ~/.bash_profile\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T03:56:05.520", "id": "8503", "last_activity_date": "2015-03-28T03:56:05.520", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "8502", "post_type": "answer", "score": 2 } ]
8502
null
8503
{ "accepted_answer_id": null, "answer_count": 0, "body": "タイトルの事象が発生します。以下を読むとよくある問題みたいですが、試しても解決しませんでした。 \n同じ現象が発生して、解決できた方がいらっしゃいましたらご教授お願いします。\n\n[SwiftでNSManagedObjectのSubclassを使った上でテストも書きたい!書けます!](http://qiita.com/YukiAsu/items/74eb1d1a5687e870d1ae)\n\n本家にも質問投稿しました。\n\nSwift CoreData UnitTest: How to avoid EXC_BREAKPOINT \n<https://stackoverflow.com/questions/29313645/swift-coredata-unittest-how-to-\navoid-exc-breakpoint>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T04:34:30.470", "favorite_count": 0, "id": "8504", "last_activity_date": "2015-03-30T05:23:43.090", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "9050", "post_type": "question", "score": 3, "tags": [ "ios", "swift" ], "title": "SwiftでCoreDataのユニットテスト時にEXC_BREAKPOINTエラーが発生します", "view_count": 305 }
[]
8504
null
null
{ "accepted_answer_id": "8534", "answer_count": 1, "body": "Java の Stream において、pipeline を途中で止める方法を探しています。\n\n例えば以下のようにすると、\n\n```\n\n IntStream stream = IntStream.of(1, 2, 3);\n stream.peek(i -> System.out.println(\"1st: \" + i))\n .peek(i -> System.out.println(\"2nd: \" + i))\n .peek(i -> System.out.println(\"3rd: \" + i))\n .sum();\n \n```\n\n結果は以下の通りで、\n\n```\n\n 1st: 1\n 2nd: 1\n 3rd: 1\n 1st: 2\n 2nd: 2\n 3rd: 2\n 1st: 3\n 2nd: 3\n 3rd: 3\n \n```\n\n各要素が順に pipeline で処理されているのがわかります。\n\nこれを 1st の peek() の後で堰き止め、\n\n```\n\n 1st: 1\n 1st: 2\n 1st: 3\n 2nd: 1\n 3rd: 1\n 2nd: 2\n 3rd: 2\n 2nd: 3\n 3rd: 3\n \n```\n\nといった感じにできないかと考えています。\n\n以下のように sorted() を使うとまさにその通りの結果が得られるのですが、 \nsort はコストが高そうで使いたくありません。\n\n```\n\n IntStream stream = IntStream.of(1, 2, 3);\n stream.peek(i -> System.out.println(\"1st: \" + i))\n .sorted()\n .peek(i -> System.out.println(\"2nd: \" + i))\n .peek(i -> System.out.println(\"3rd: \" + i))\n .sum();\n \n```\n\n用途としては、前半で全要素から得た結果を後半で使いたいと思っています。\n\n何か良い手はないでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T07:11:45.153", "favorite_count": 0, "id": "8505", "last_activity_date": "2015-03-31T05:15:20.057", "last_edit_date": "2015-03-29T22:19:08.713", "last_editor_user_id": "46", "owner_user_id": "5288", "post_type": "question", "score": 2, "tags": [ "java", "java8", "stream" ], "title": "Java の Stream において pipeline を途中で止める方法", "view_count": 1390 }
[ { "body": "そもそも、[`peek()`中間操作](https://docs.oracle.com/javase/jp/8/docs/api/java/util/stream/Stream.html#peek-\njava.util.function.Consumer-)は主にデバッグ用途(中間値の確認)として提供されるものです。Stream処理ロジックの一部として使うことは推奨されません。ストリーム処理中の[副作用に関する注意](https://docs.oracle.com/javase/jp/8/docs/api/java/util/stream/package-\nsummary.html)も確認してください。\n\nまた`sorted()`中間操作による堰き止めに頼るのもお勧めできません。例示コードでは、ソート処理には全要素値バッファリングが必要なので、結果的に期待する動作となっています。しかしSpliteratorが[`SORTED`特性](http://docs.oracle.com/javase/jp/8/docs/api/java/util/Spliterator.html#SORTED)をもつ場合、`sorted()`中間操作は\"何もしない\"と考えられます。\n\n仰るような動作をさせたければ、単にストリームを2回生成すべきだと思います。(`peek`の使用はあえて残しましたが、本来は全体処理を見直すべきです。)\n\n```\n\n IntStream stream = IntStream.of(1, 2, 3);\n stream.forEach(i -> System.out.println(\"1st: \" + i))\n \n stream = IntStream.of(1, 2, 3);\n stream.peek(i -> System.out.println(\"2nd: \" + i))\n .peek(i -> System.out.println(\"3rd: \" + i))\n .sum();\n \n```\n\n* * *\n\n> 用途としては、前半で全要素から得た結果を後半で使いたいと思っています。\n\n一応、堰き止めたいタイミングで配列へ変換(`toArray()`)し、新たにストリームを生成する方法があります。ただし、中間操作の処理順序に依存すること自体がStream処理にそぐわないため、\"堰き止め\"ても処理が非効率になるだけですね。\n\n```\n\n IntStream stream = IntStream.of(1, 2, 3);\n IntStream.of(\n stream\n .map(x -> x * 2)\n .peek(i -> System.out.println(\"1st: \" + i)) // for DEBUG\n .toArray()\n )\n .peek(i -> System.out.println(\"2nd: \" + i)) // for DEBUG\n .peek(i -> System.out.println(\"3rd: \" + i)) // for DEBUG\n .sum();\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T14:07:44.163", "id": "8534", "last_activity_date": "2015-03-31T05:15:20.057", "last_edit_date": "2015-03-31T05:15:20.057", "last_editor_user_id": "49", "owner_user_id": "49", "parent_id": "8505", "post_type": "answer", "score": 1 } ]
8505
8534
8534
{ "accepted_answer_id": "8517", "answer_count": 1, "body": "setlocale関数とwprintf関数を使用したプログラムが意図した通りに動作しません。\n\n```\n\n printf(\"Hello\\n\");\n setlocale(LC_CTYPE, \"\");\n wprintf(L\"今日は\\n\");\n printf(\"Goodbye\\n\");\n \n```\n\nこのプログラムで「今日は」だけが表示されません。 \n1行目のprintfをコメントアウトすると「今日は」だけが表示されます。 \nなぜこのような現象が発生するのでしょうか。\n\n環境はDebian7、gccは4.7.2です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T11:46:50.897", "favorite_count": 0, "id": "8507", "last_activity_date": "2015-03-31T15:33:52.970", "last_edit_date": "2015-03-29T01:51:52.247", "last_editor_user_id": "4236", "owner_user_id": "9052", "post_type": "question", "score": 15, "tags": [ "linux", "c" ], "title": "setlocale使用時の挙動について", "view_count": 1373 }
[ { "body": "大雑把に言うと、ひとつのストリーム (今回の例では `stdout`)\nに対して、`char`での入出力と`wchar_t`での入出力を混在させることができないからです。\n\nストリームは、 _byte-oriented_ というモードと _wide-oriented_ というモード のいずれかのモードを持ちます。 \nそれぞれ、簡単に言うと、バイト (`char`) 単位で入出力をするモードと、ワイド文字 (`wchar_t`) 単位で入出力するモードです。 \n最初は未設定状態で、最初に呼ばれた入出力関数に合ったモードに設定されます。 \nそして、一度どちらかに決まったら、それと合わない入出力を行うことはできません。片方しか表示されないのはそのためです。 \n[コメントで補足があったため編集:ここから] \n~~(合わない入出力関数を使った結果は、無視される、ではなく未定義かも。規格には「shall not be\napplied」としか書かれていないような……)~~ \n厳密には、合わない入出力の結果は表示されない/入力されないのではなく未定義です。 \n[編集:ここまで]\n\n今回の場合、`printf()` がバイト単位の入出力、`wprintf()`がワイド文字単位の入出力を行う関数になります。 \n最初に `prnitf(\"Hello\\n\")` を呼び出すことによって、`stdout` が _byte-oriented_ になり、後続の\n`wsprintf()` が使えなくなります。 \n一方、`prnitf(\"Hello\\n\")` をコメントアウトすると、 `wprintf(L\"今日は\\n\")`\nが最初に呼び出されることになり、`stdout` が _wide-oriented_ になり、`printf()`が使えなくなります。\n\n`fwide()` という関数を使うことによって切り替えられそうですが、手元の man ページでは、一度決定したら変更できないとあります。 \nISO/IEC 9899 にはそのような記述が見当たらないのですが、見落しか glibc の制限か。 \nいずれにせよ、現在の Linux の実装上では、`fwide()`で都度切り替えながら出力するというのは無理そうです。 \n`freopen()`を使えば未設定の状態に戻るので、これを都度呼ぶという手もありますが、それよりは入出力をバイト単位かワイド文字単位かのどちらかに統一する方針にした方がよいかと思います。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T17:01:58.953", "id": "8517", "last_activity_date": "2015-03-31T15:33:52.970", "last_edit_date": "2015-03-31T15:33:52.970", "last_editor_user_id": "7831", "owner_user_id": "7831", "parent_id": "8507", "post_type": "answer", "score": 17 } ]
8507
8517
8517
{ "accepted_answer_id": "8509", "answer_count": 1, "body": "現在、位置情報を取得するiPhoneAppを作っています。\n\nその為のコードを追加し、実行したのですが、設定の位置情報の欄にそのApp名が表示されません。\n\n欄にApp名を表示させる方法と仕組みを教えてください。\n\nなお、`Info.plist`に`NSLocationAlwaysUsageDescription`と`NSLocationWhenInUsageDescription`は追加しています。\n\n以下に、位置情報取得の為に追加したコードを載せます。\n\n```\n\n #import <UIKit/UIKit.h>\n #import <CoreLocation/CoreLocation.h>\n @interface ViewController : UIViewController<UIAlertViewDelegate,CLLocationManagerDelegate>\n {\n //位置情報メンバを定義\n CLLocationManager *locationManager;\n }\n @property(readonly, nonatomic) CLLocationManager *locationManager;\n \n #import \"ViewController.h\"\n \n @interface ViewController ()\n \n @end\n \n @implementation ViewController\n - (void)viewDidLoad {\n [super viewDidLoad];\n CLAuthorizationStatus status = [CLLocationManager authorizationStatus];\n \n switch (status) {\n case kCLAuthorizationStatusAuthorizedAlways: // アクセスが許可\n case kCLAuthorizationStatusAuthorizedWhenInUse: // アクセスを許可するか選択されていない\n \n {\n locationManager=[[CLLocationManager alloc]init];//初期化\n locationManager.delegate=self;\n locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigation;//精度\n locationManager.distanceFilter=1.0;//更新頻度\n [locationManager startUpdatingLocation];//サービス開始\n }\n break;\n \n \n case kCLAuthorizationStatusRestricted: // 機能制限で利用が制限されている\n {\n UIAlertView *alertView = [[UIAlertView alloc]\n initWithTitle:@\"エラー\"\n message:@\" 機能制限で利用が制限されています\"\n delegate:nil\n cancelButtonTitle:@\"OK\"\n otherButtonTitles:nil];\n [alertView show];\n }\n break;\n \n case kCLAuthorizationStatusDenied: // 許可していない\n {\n UIAlertView *alertView = [[UIAlertView alloc]\n initWithTitle:@\"エラー\"\n message:@\"アクセスを許可されていません\"\n delegate:nil\n cancelButtonTitle:@\"OK\"\n otherButtonTitles:nil];\n [alertView show];\n }\n break;\n \n default:\n break;\n }\n }\n \n - (void)locationManager:(CLLocationManager *)manager \n   didUpdateToLocation:(CLLocation *)newLocation\n fromLocation:(CLLocation *)oldLocation {\n   NSLog(@\"didUpdateToLocation latitude=%f, longitude=%f, speed=%f, time=%@\",\n [newLocation coordinate].latitude,\n [newLocation coordinate].longitude,\n newLocation.speed,\n newLocation.timestamp);\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T11:48:57.417", "favorite_count": 0, "id": "8508", "last_activity_date": "2015-07-26T17:08:38.790", "last_edit_date": "2015-03-28T13:39:00.727", "last_editor_user_id": "7996", "owner_user_id": "7996", "post_type": "question", "score": 3, "tags": [ "ios", "objective-c", "xcode", "iphone" ], "title": "位置情報を取得するiPhoneAppを設定->位置情報の欄に表示させる方法", "view_count": 388 }
[ { "body": "```\n\n @implementation ViewController\n @synchronize locationManager;\n \n```\n\nインスタンス変数`locationManager`と、プロパティ`locationManager`をシンクロさせる必要があると思いますが、いかが?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T12:00:14.997", "id": "8509", "last_activity_date": "2015-03-28T12:00:14.997", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "8508", "post_type": "answer", "score": 1 } ]
8508
8509
8509
{ "accepted_answer_id": "8536", "answer_count": 1, "body": "python3でhttp.server.BaseHTTPRequestHandlerを継承してWebサーバのクラスを作っているのですが、下記のように、do_POSTでデータを受け取り、処理した後、303でリダイレクトさせたいのですがブラウザの画面が変わりません。なぜなのでしょうか?\n\n```\n\n \n class handler(http.server.BaseHTTPRequestHandler):\n def do_POST(self):\n # データの処理 ...\n self.send_response(303, self.responses[303][0])\n self.send_header(\"Location\", \"/\")\n self.send_header(\"Content-Length\", len(data))\n self.send_header(\"Content-Type\", mimetypes.guess_type(\"views/list_view.html\", False)[0])\n self.send_header(\"Access-Control-Allow-Origin\", \"*\")\n self.send_header(\"Server\", self.server_version)\n self.end_headers()\n \n \n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T12:49:14.477", "favorite_count": 0, "id": "8510", "last_activity_date": "2015-03-29T14:11:37.320", "last_edit_date": "2015-03-29T06:23:35.320", "last_editor_user_id": "5246", "owner_user_id": "5246", "post_type": "question", "score": -1, "tags": [ "python" ], "title": "PythonのWebサーバでのリダイレクトができない", "view_count": 1136 }
[ { "body": "Python-3.4.1とFirefox-36.0.4で、以下のコードで期待する動作を得られました。\n\n```\n\n import http.server\n \n class handler(http.server.BaseHTTPRequestHandler):\n \n def do_GET(self):\n self.send_response(200)\n self.send_header(\"Content-Type\", 'text/html')\n self.end_headers()\n self.wfile.write(b'<html><body>hello!<form method=\"POST\"><input type=\"submit\"></form></body></html>')\n \n def do_POST(self):\n self.send_response(303, self.responses[303][0])\n self.send_header(\"Location\", \"/\")\n self.end_headers()\n \n \n def run(server_class=http.server.HTTPServer, handler_class=handler):\n server_address = ('', 8000)\n httpd = server_class(server_address, handler_class)\n httpd.serve_forever()\n \n \n if __name__ == '__main__':\n run()\n \n```\n\nブラウザのデバッガ等でサーバーからの通信を見てみると原因が分かるのではないかと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T14:11:37.320", "id": "8536", "last_activity_date": "2015-03-29T14:11:37.320", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "8510", "post_type": "answer", "score": 2 } ]
8510
8536
8536
{ "accepted_answer_id": "8519", "answer_count": 1, "body": "iPhoneアプリを製作中です。\n\n遷移元を画面A、遷移先を画面Bとします。現在の目標は、この二つの画面を \nお互いに Segue でループさせることです。画面Bは CollectionView です。\n\n画面Aに配置したボタンをタップすると、ポップアップメニューが出てきます。 \nその中のメニューの一つに画面遷移用のボタンを実装しました。 \n実装方法は以下の通りです。[Ryusuke Fuda's Tech Blog - iOS\nSegueを使わずにコードで画面遷移](http://salvador.hatenablog.jp/entry/2014/04/27/164132)を参考にしました。\n\n 1. 遷移先の storyboad の Identity で、 **Use Storyboad ID** にチェックを入れる\n 2. Storyboad ID に遷移先のクラス名を入力する\n 3. 遷移元のヘッダファイルに、遷移先のヘッダファイルをインポートする\n 4. 遷移元の、画面遷移用ボタンに以下のコードを書き込む\n\n```\n\n GamenBViewController *controller =\n [self.storyboard instantiateViewControllerWithIdentifier:@\"GamenBViewController\"];\n [self presentModalViewController:controller animated:YES]; //モーダルで呼び出す\n \n```\n\n上記内容で画面 A から画面 B に遷移させました。\n\n画面 B から画面 A には以下の内容で遷移させます。 \n※ showDetail は Segue の名前です\n\n```\n\n - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{\n if ([[segue identifier] isEqualToString:@\"showDetail\"]) {\n NSIndexPath *indexPath = [self.collectionView indexPathForCell:sender];\n UIImage *img = _objects[indexPath.row];\n [[segue destinationViewController] setDetailItem:img]; \n }\n }\n \n```\n\n画面 A から画面 B に遷移させる内容を実装すると、なぜかそれまでは上手くいっていたはずの、 \n画面 B から画面 A への遷移がエラーになってしまいます。 \nエラーメッセージは以下の通りです。\n\n> Terminating app due to uncaught exception 'NSGenericException', reason:\n> 'Could not find a navigation controller for segue 'showDetail'. Push segues\n> can only be used when the source controller is managed by an instance of\n> UINavigationController.'\n\nどう対処すれば良いか、どなたかご教示いただけないでしょうか。 \n以上、何卒よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T15:27:21.223", "favorite_count": 0, "id": "8514", "last_activity_date": "2015-03-29T10:50:44.757", "last_edit_date": "2015-03-28T16:49:40.840", "last_editor_user_id": "7926", "owner_user_id": "7470", "post_type": "question", "score": 0, "tags": [ "objective-c", "iphone", "xcode6" ], "title": "2つの画面を Segue でお互いに遷移させる為にはどうすればいいのでしょうか", "view_count": 1056 }
[ { "body": "エラーメッセージが教えてくれること、そのものです。すなわち`UINavigationController`が運営(Manage)している環境でなければ、`push\nsegues`ができないのだから、`UINavigationController`を作ってやればいいのです。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/ircnF.png)\n\nXcodeのStoryboardで、ルートになるView Controllerを選択して、Editorメニュー>Embed In>Navigation\nControllerで、UINavigationControllerが作られます。 \nしかし、\n\n> 二つの画面をお互いに Segue でループさせること\n\nというのは、むだにメモリを消費して、最悪アプリを落とすことにしかなりませんので、するべきではありません。外見は、「互いの画面を行ったり来たり」しているように見えますが、じっさいは、View\nController Aの上に、View Controller Bがのっかり、その上にView Controller\nAがのっかるという、スタックが形成されていきます。モーダルで遷移したViewControllerは、`dismiss`で前のViewControllerに戻ること。Navigation\nControllerで遷移した場合は、`pop`するか、`Unwind\nSegue`するかして、戻ることです。「戻る」という処理をすることで、遷移前のViewConttollerは、メモリから解放され、メモリを圧迫する要因ではなくなります。\n\nさて、あなたが書いたプログラムを詳細に見ていきます。\n\n```\n\n [self presentModalViewController:controller animated:YES]; //モーダルで呼び出す\n \n```\n\n`presentModalViewController:animated:`は、iOS 6にて **Deprecated**\nされているので、使うべきではありません。代わりに[`presentViewController:animated:completion:`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instm/UIViewController/presentViewController:animated:completion:)を使ってください。 \nモーダルで遷移したViewControllerから「戻る」には、[dismiss〜](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instm/UIViewController/dismissViewControllerAnimated:completion:)か、`Unwind\nSegue`を使います。`Unwind\nSegue`は、これをキーワードにしてネット検索すれば、ていねいな説明をしているブログがヒットしますので、それで勉強してください。なお、くれぐれもそのドキュメントが書かれた日付は、かならずチェックしてください。あまりに古い情報はそのまま受け取らないほうがいいです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T17:42:58.657", "id": "8519", "last_activity_date": "2015-03-29T10:50:44.757", "last_edit_date": "2015-03-29T10:50:44.757", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "8514", "post_type": "answer", "score": 2 } ]
8514
8519
8519
{ "accepted_answer_id": "8836", "answer_count": 1, "body": "以下のことを同時に実現させたいと思っております。\n\n 1. カメラプレビューをリアルタイムで白黒変換する。 \nCamera の onPreviewFrame でピクセルを操作することによってモノクロにしています。\n\n 2. 動画を撮影する。 \nMediaRecorder を用いて録画しています。\n\n1 と 2 はそれぞれ単体のテストで成功しています。MediaRecorder を使っていると Camera の onPreviewFrame\nは触れることができないので、実装がうまくいきません。 \nまずは OpenCV を用いない方針で考えていて、どうしても無理なら OpenCV を使った方法も考えています。 \nAndroid での動画撮影に詳しい方、ご教授お願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T16:24:44.843", "favorite_count": 0, "id": "8516", "last_activity_date": "2015-04-06T15:06:17.450", "last_edit_date": "2015-03-28T16:45:37.983", "last_editor_user_id": "7926", "owner_user_id": "7699", "post_type": "question", "score": 1, "tags": [ "android", "java", "opencv" ], "title": "カメラプレビューをリアルタイムで白黒変換しながら、撮影をして保存したい。", "view_count": 1244 }
[ { "body": "動画撮影には詳しくありませんが、AndroidJavaからどうにかするには、`onPreviewFrame`か何かで受け取ったデータを[MediaCodec](http://developer.android.com/reference/android/media/MediaCodec.html)で直接変換するしか方法がなさそうです。16未満がターゲットですと、指定の条件では手出してきません。\n\nちなみにOpenCVではモノクロ画像に変換はできますが、それを動画として保存するにはffmpegが必要で、さらに、ffmpegを使うように`WITH_FFMPEG=YES`でOpenCVをコンパイルする必要があるようです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-06T15:06:17.450", "id": "8836", "last_activity_date": "2015-04-06T15:06:17.450", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9191", "parent_id": "8516", "post_type": "answer", "score": 1 } ]
8516
8836
8836
{ "accepted_answer_id": "8565", "answer_count": 4, "body": "シェルスクリプトをコマンドラインからしか実行できないようにしたいです。\n\nそこで思いついたのが、pythonで見たことある以下の書き方です。 \n(importでは実行されないようにしている)\n\n```\n\n if __name__ == '__main__':\n pass\n \n```\n\nシェル(bashを想定)でもこんな簡単に出来るでしょうか。 \nまた、そもそも別の方法があればご教示頂きたいです。\n\n特殊変数の$0と実ファイル名を比較する方法だと、実ファイル名を変更した時にスクリプト内のファイル名も修正しないといけない気がしてます。そこで上記のpythonのようなやり方が \nベストかなと思いついたところです。\n\nよろしくお願いします。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-28T17:26:31.100", "favorite_count": 0, "id": "8518", "last_activity_date": "2015-10-15T04:44:15.667", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8695", "post_type": "question", "score": 4, "tags": [ "python", "bash", "sh" ], "title": "シェルスクリプトをコマンドラインからしか実行できないようにしたい", "view_count": 1940 }
[ { "body": "> 別のシェルスクリプトファイルからは実行できない(読み込まれない)ようにしたい\n\nシェル変数[`$SHLVL`](http://www.atmarkit.co.jp/flinux/rensai/linuxtips/529shelldep.html)を使えば、要望に近いことは実現できます。以下は`bar.sh`から`foo.sh`を呼び出す例です。\n\n```\n\n $ cat foo.sh\n #!/bin/sh\n if [ 2 -lt $SHLVL ]; then\n exit\n fi\n echo Hello,\n \n $ cat bar.sh\n #!/bin/sh\n ./foo.sh\n echo World!\n \n $ ./foo.sh\n Hello,\n $ ./bar.sh\n World!\n \n```\n\nただし、新しいシェルを起動せずに`bar.sh`を呼び出したり、シェルレベルが2以上の状態で`foo.sh`を呼び出すケースには対応できません。\n\n```\n\n $ . bar.sh\n Hello,\n World!\n \n $ bash\n $ echo $SHLVL\n 2\n $ ./foo.sh\n Hello,\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T05:01:04.300", "id": "8552", "last_activity_date": "2015-03-30T05:01:04.300", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49", "parent_id": "8518", "post_type": "answer", "score": 4 }, { "body": "bashのバージョンが3以上であれば、`BASH_SOURCE`が使えると思います:\n\n```\n\n #!/bin/bash\n [ \"${0}\" = \"${BASH_SOURCE[0]}\" ] || return 0\n \n```\n\n冒頭に入れておけばスクリプトが`source`された時にreturnします。\n\n* * *\n\n追記: 他のスクリプトの中で実行されるパターンを潰すのであれば、親プロセスから実行コマンドを確認するのがスマートかなぁと思います。\n\n```\n\n #!/bin/sh\n [ \"`ps -o comm= $PPID`\" = \"-bash\" ] || exit 1\n \n```\n\nbashの前についているハイフン`-`はログインシェルを意味します。\n\n```\n\n $ man bash | less '+/^[ ]*exec '\n \n```\n\n> If the -l option is supplied, the shell places a dash at the begin-ning of \n> the zeroth arg passed to command. This is what login(1) does.", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T10:34:55.593", "id": "8565", "last_activity_date": "2015-10-15T04:44:15.667", "last_edit_date": "2015-10-15T04:44:15.667", "last_editor_user_id": "62", "owner_user_id": "62", "parent_id": "8518", "post_type": "answer", "score": 5 }, { "body": "`caller`を使って呼び出し元をチェックできます。`sh`でも動くと思います。\n\n```\n\n #! /bin/sh\n \n function called_by() {\n local by\n by=$(caller 0)\n by=${by#* }\n by=${by% *}\n echo -n \"$by\"\n }\n \n if test \"$(called_by)\" = source\n then\n echo \"Do not source\"\n fi 1>&2\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-14T06:50:44.650", "id": "17633", "last_activity_date": "2015-10-14T06:50:44.650", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12773", "parent_id": "8518", "post_type": "answer", "score": 0 }, { "body": "Shebang行を読んだOSにより実行された場合に、特定の環境変数を設定する方法を考えてみました。 \nShebang行を以下のようにすれば起動されたインタプリタのプロセスの環境変数`\"__SHEBANG__\"`が \"1\" に設定されます。\n\n```\n\n #!/usr/bin/perl -e$ENV{'__SHEBANG__'}=1;exec('インタプリタ',@ARGV)\n \n```\n\nShellスクリプト部では、この`\"__SHEBANG__\"`が `\"1\"`かどうかで処理を分けることが出来ます。\n\n```\n\n #!/usr/bin/perl -e$ENV{'__SHEBANG__'}=1;exec('sh',@ARGV)\n # shell script (not perl)\n \n [ \"$__SHEBANG__\" = \"1\" ] || exit 1\n unset __SHEBANG__\n \n echo 'shebang行の設定により起動されました'\n \n```\n\nPythonなどでも同じように出来ます。 \n\n```\n\n #!/usr/bin/perl -e$ENV{'__SHEBANG__'}=1;exec('python3',@ARGV)\n # python3 script (not perl)\n \n import os\n import sys\n \n if os.environ.get('__SHEBANG__', '') != '1': sys.exit(0)\n del os.environ['__SHEBANG__']\n \n print('shebang行の設定により起動されました')\n \n```\n\nShebang行にPerlを使っているのは以下を満たすコマンドがPerlしか思い付かなかったからです。\n\n 1. 環境変数を設定出来る\n 2. 与えられた引数をそのまま渡して別プロセスを起動できる\n 3. 上記の処理を、空白を含まない一つの引数で指示できる \n(Shebang行の引数部分に空白があった場合、OSによって扱いが違います。 \nLinuxの場合、空白を含んだ一つの引数と見なされますが、空白で区切られた複数の引数と見なすOSもあるようです。 \nよってshebang行では、空白を含まない一つの引数のみ使うようにしました)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-10-14T11:52:14.520", "id": "17650", "last_activity_date": "2015-10-14T11:52:14.520", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3054", "parent_id": "8518", "post_type": "answer", "score": 2 } ]
8518
8565
8565
{ "accepted_answer_id": null, "answer_count": 2, "body": "例えば、Google サジェストなど文字を入力する度サーバーと通信(HTTPリクエスト)しますが \n通信(HTTPリクエスト)は非同期で行われてる為、前回のレスポンスが返ってきてない状態で新たにリクエストを行います。\n\nこの時、戻ってきてないリクエストはもう不要ですがabortした方が良いでしょうか? \nそれとも、放置でかまわないでしょうか?\n\nクライアント側は、どちらの実装が良いでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T00:35:55.380", "favorite_count": 0, "id": "8520", "last_activity_date": "2020-02-20T13:08:59.113", "last_edit_date": "2020-02-20T13:08:59.113", "last_editor_user_id": "19110", "owner_user_id": "4191", "post_type": "question", "score": 0, "tags": [ "network", "http", "非同期" ], "title": "通信(HTTPリクエスト)のキャンセルと放置はどちらが良いか", "view_count": 5143 }
[ { "body": "例で挙げていらっしゃるものですと、結局実装次第になるかと思います。 \nサーバと通信するタイミングは、おそらくKey関連イベントで即時にやっているわけではなく、1秒単位等でやっていると思います(そうでなければ無駄な負荷が多すぎるので) \nまた、サーバ側でも受け取ったデータの処理は1秒単位等で丸めてやっていると思うので、放置でもキャンセルでも大差ありません。\n\nただ、サーバ側の処理が一瞬で終わるようなものに限定し、且つあえて仰る様な実装を行う場合には、「2」の放置がより良いと思います。 \n理由としては、HTTPのAPI通信で最も重い処理は、HTTPリクエスト自体の処理なので、キャンセルリクエストを送ることでより処理負荷が高くなってしまう場合の方が多いはずだからです。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T04:43:18.363", "id": "8550", "last_activity_date": "2015-03-30T04:43:18.363", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7474", "parent_id": "8520", "post_type": "answer", "score": 1 }, { "body": "APIの一般論としては、リクエストをきちんと完結させたり不要なリクエストをキャンセルすることを提供側が求めているのであれば、キャンセルする仕組みがあるはずです。一方で、キャンセルする仕組みが無ければそもそも利用者にはどうしようもありません。\n\n単純なリクエスト/レスポンスを繰り返すweb\nAPIはまず間違いなく後者でしょうが、重い処理をする(レスポンスに時間がかかる)処理とか、状態を持っているものであればキャンセルする仕組みがある場合もあります。\n\nということで、コスト云々よりもまずはAPIの仕様を確認すべきです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T03:35:42.850", "id": "8588", "last_activity_date": "2015-03-31T03:35:42.850", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "8520", "post_type": "answer", "score": 1 } ]
8520
null
8550
{ "accepted_answer_id": null, "answer_count": 1, "body": "Visual Studio Community 2013 で webView を含む cocos2d-x 3.4\nのコードをビルドすると、以下の様なリンクエラーが発生します。\n\n> error LNK2019: 未解決の外部シンボル \"__declspec(dllimport) public: static class \n> cocos2d::experimental::ui::WebView * __cdecl\n> cocos2d::experimental::ui::WebView::create(void)\"\n> (__imp_?create@WebView@ui@experimental@cocos2d@@SAPAV1234@XZ) が関数 \"public:\n> virtual bool __thiscall HelloWorld::init(void)\" (?init@HelloWorld@@UAE_NXZ)\n> で参照されました。\n\nこのエラーに対処するには、どうしたらいいのでしょうか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T04:24:14.900", "favorite_count": 0, "id": "8521", "last_activity_date": "2020-06-22T02:56:02.290", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3431", "post_type": "question", "score": 1, "tags": [ "c++", "cocos2d-x" ], "title": "VSC2013 、cocos2d-x 3.4 で webView を使うとリンクエラーが発生する", "view_count": 463 }
[ { "body": "WebView は iOS と Android でのみ使用可能です。\n\n* * *\n\n_この投稿は[@h2so5\nさんのコメント](https://ja.stackoverflow.com/questions/8521/vsc2013-cocos2d-x-3-4-%e3%81%a7-webview-%e3%82%92%e4%bd%bf%e3%81%86%e3%81%a8%e3%83%aa%e3%83%b3%e3%82%af%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%8c%e7%99%ba%e7%94%9f%e3%81%99%e3%82%8b#comment7714_8521)\nの内容を元に コミュニティwiki として投稿しました。_", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2020-06-22T02:56:02.290", "id": "67892", "last_activity_date": "2020-06-22T02:56:02.290", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3060", "parent_id": "8521", "post_type": "answer", "score": 1 } ]
8521
null
67892
{ "accepted_answer_id": "8523", "answer_count": 1, "body": "<http://syucream.github.io/hpack-spec-ja/header-compression-10-ja.html>\n\n6.2.3 インデックスされないリテラルヘッダフィールド\n\nの箇所に\n\n> インデックスされないリテラルヘッダフィールド表現は 動的テーブルの変更を伴わずにデコードされたヘッダリストへの \n> ヘッダフィールドの追加を引き起こします。 中継者はこのヘッダフィールドのエンコードに同じ表現を 使用しなければなりません (MUST) 。\n\nとあります。 \nこれは「6.2.2 インデックス更新を伴わないリテラルヘッダフィールド」と何が違うのでしょうか?\n\n> この表現は圧縮によるリスクに晒されないよう ヘッダフィールド値を保護することを意図しています (詳細は Section 7.1 を 参照) \n> 。\n\nと書かれています。 \n私はCRIME攻撃に詳しくないですが、MSBに「0001」を使用する以外はフォーマットは同じように見えます。 \nなぜこれでヘッダフィールド値を保護できるのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T05:24:03.733", "favorite_count": 0, "id": "8522", "last_activity_date": "2015-03-29T05:45:34.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3496", "post_type": "question", "score": 1, "tags": [ "http", "ssl", "http2", "hpack" ], "title": "HTTP2のHPACKにおける\"インデックスされないリテラルヘッダフィールド\"について", "view_count": 154 }
[ { "body": "§7.1.3に書かれていますが、これはセキュリティ上の理由からわざと冗長なエンコードで送信したヘッダを、プロキシサーバー側で勝手に最適化されないように通知するためのものです。\n\nですからプロキシサーバー側がこのヘッダーを正しく扱っていないと効果がありません。\n\n> 7.1.3 インデックスされないリテラル\n>\n> ヘッダフィールドのインデックス表現の生成を止める ことは圧縮がすべてのホップで行われない場合のみ\n> 影響します。インデックスされないリテラル(Section 6.2.3 を 参照) は中継者に特定の値が意図的にリテラルとして\n> 送信されたことを通知するのに使用できます。中継者はインデックスを伴うインデックスされないリテラルを 使用する値を再エンコードしてはいけません (MUST\n> NOT) 。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T05:45:34.770", "id": "8523", "last_activity_date": "2015-03-29T05:45:34.770", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "8522", "post_type": "answer", "score": 1 } ]
8522
8523
8523
{ "accepted_answer_id": "8549", "answer_count": 1, "body": "テキストフィールドに入力された文字をデータベースに登録していく際、`primaryKey`に`autoincrement`を設定したいのですが、`swift`ではどうやって設定すればいいでしょうか?\n\n```\n\n override class func primaryKey() -> String {\n return \"id\"\n }\n \n```\n\n色々調べてみたのですが、上記ようにprimaryKeyを設定する方法しか見つけることができませんでした。どなたか分かる方に教えていただきたいです。すみませんが、よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T05:55:30.430", "favorite_count": 0, "id": "8524", "last_activity_date": "2015-03-30T04:42:50.827", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5210", "post_type": "question", "score": 3, "tags": [ "swift", "realm" ], "title": "Realmでauto incrementを設定する", "view_count": 1381 }
[ { "body": "現在RealmにはAuto Incrementの機能はありませんので、必要なら自分でその仕組みを実装する必要があります。 \n(Auto Incrementの機能についての要望は多いのでタスクには挙がっていますが、まだその機能がいつリリースされるかは未定です。)\n\nもし、IDがユニークであればよくて、連続していたり、順番に増加していく必要がないのであれば、UUIDをIDとして利用することをお勧めします。 \niOSでUUIDを生成するには`NSUUID`クラスを利用すると簡単です。\n\n連番のIDが必要なのであれば、連番を自分で管理する必要があります。簡単なのは連番を別にクラス変数などで管理することです。この方法なら毎回レコード数をカウントするクエリを発行せずに済む、などのメリットがあります。\n\nもし、このモデルが複数のスレッドから使用される場合は、`nextPrimaryKey()`のようなメソッドをスレッドセーフになるように注意深く実装する必要があります。\n\nこちらの同様の質問も参考にしてください。 \n<https://stackoverflow.com/questions/26252432/how-do-i-set-a-auto-increment-\nkey-in-realm/26257616#26257616>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T04:42:50.827", "id": "8549", "last_activity_date": "2015-03-30T04:42:50.827", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "5519", "parent_id": "8524", "post_type": "answer", "score": 3 } ]
8524
8549
8549
{ "accepted_answer_id": null, "answer_count": 1, "body": "**Hearts of Iron** や **Plague inc**\nのような、地図をクリックするとその地域や国がハイライトされるというようなものが作りたいです。\n\nもちろん、UnityAnswersなどでも調べたのですが、英語で書かれてあるためかきちんと理解できません。\n\nどうすれば上のような地図が作れるのでしょうか? 具体的にお願いします。\n\nUnityのバージョンは5.0.0f4です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T07:08:28.590", "favorite_count": 0, "id": "8525", "last_activity_date": "2015-04-28T09:54:26.863", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7500", "post_type": "question", "score": 0, "tags": [ "unity3d" ], "title": "Unityでクリック+ハイライトできる地図の作成", "view_count": 410 }
[ { "body": "その部分がクリックされたら色を変えればいいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T09:14:46.803", "id": "8526", "last_activity_date": "2015-03-29T09:14:46.803", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8266", "parent_id": "8525", "post_type": "answer", "score": 1 } ]
8525
null
8526
{ "accepted_answer_id": null, "answer_count": 2, "body": "デバッガでプロジェクトの起動時、以下のような警告が発生するのですが、 \n解消の方法はないでしょうか。 \nこの警告が原因かは現時点で不明ですが、デバッグ起動しない状態です。\n\n「プロジェクトのCordovaバージョンがデバッガーと一致しないため、正常に \n動作しない可能性があります。」\n\nプロジェクトのバージョン:3.5.1 または4.1.0 \n(バージョンの切り替えは上記2バージョンのみ可能だったため) \nios8にインストールしたデバッガのバージョン:3.7.0 \n(2015.3.29時点、最新verのデバッガです)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T09:15:27.973", "favorite_count": 0, "id": "8527", "last_activity_date": "2015-08-07T11:14:12.197", "last_edit_date": "2015-04-09T06:21:42.297", "last_editor_user_id": "7978", "owner_user_id": "9058", "post_type": "question", "score": 1, "tags": [ "ios", "monaca" ], "title": "monacaのiosのデバッガとプロジェクトのcordovaバージョン相違の警告を解消するには?", "view_count": 1760 }
[ { "body": "このエラーが過去に出ていたことがありますが、私の場合は、MonacaのダッシュボードでプロジェクトをCordova 2.9からCordova\n3.5にアップデートすることで解決しました。また、Siegさんが仰るようにMonacaデバッガーの最新版は3.2.0です。 (2015年4月3日現在)\n\ntuchiさんのプロジェクトのCordovaバージョンは本当に2.9ではないのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T09:15:01.630", "id": "8725", "last_activity_date": "2015-04-03T09:15:01.630", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7871", "parent_id": "8527", "post_type": "answer", "score": 1 }, { "body": "横から失礼します。\n\n> ios8にインストールしたデバッガのバージョン:3.7.0 \n> (2015.3.29時点、最新verのデバッガです)\n\nデバッガのバージョンは3.2.0、デバッガの左上の三本マークから「その他」>「デバッガ情報」で確認できるCordovaバージョンが3.7.0ということですね。\n\nApp Store で Monaca Debugger の 3.2.0 の「新機能」を見ると、2015/01/24時点で「Cordova\n4.1.2ベースにアップデートしました」と書かれています。なのに「その他」>「デバッガ情報」では 3.7.0 とあるので、私も全く意味が分かりません。\n\n私はプレビューでは動くのにデバッガーでは動いたり動かなかったり(なにやらタイムラグがあるような動作をする)という状態で悩んでいます。\n\nまず「プロジェクトのCordovaバージョンがデバッガーと一致しないため、正常に動作しない可能性があります。」を解消して、Cordovaバージョンが問題なのかそうでないのかの切り分けをしたいです。\n\nMonaca内部の皆様、このバージョンの差異について確認していただけないでしょうか。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-08T05:11:34.923", "id": "8899", "last_activity_date": "2015-04-08T05:11:34.923", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "parent_id": "8527", "post_type": "answer", "score": 1 } ]
8527
null
8725
{ "accepted_answer_id": "16878", "answer_count": 1, "body": "下記手順でアセットバンドルを作成したのですが、 \nCreateFormFileを使用してLoadする方法がわかりません。\n\n●アセットバンドル作成側 \n1.新しくシーンを作成しCameraの下にCanvasを作り、Canvasの下にButtonを作成しました。 \n2.Canvas以下をプレハブとし、そのPrefabにInspector上でAssetBandleの名前をtestcanvas \nとしました。 \n3.\n\n```\n\n BuildPipeline.BuildAssetBundles(\"Assets/BundleOutPut/\");\n \n```\n\nメソッドにてアセットバンドルを作成し、 \nAssets/BundleOutPut/ の下に下記4つのファイルができました。 \n**BundleOutPut** \n**BundleOutPut.manifest** \n**testcanvas** \n**testcanvas.manifest**\n\n●アセットバンドルロード側 \n作成したBundleOutPutをAssetsの下のStreamingAssetsに置き \n下記のソースでロードしてみたのですがエラーメッセージが表示されます。\n\n```\n\n public void CreateFileAssetBundleFileLoad()\n {\n string path = \"file://\" + Application.streamingAssetsPath + \"/\" \n + \"BundleOutPut\";\n AssetBundle NoCompress = AssetBundle.CreateFromFile(path);\n Instantiate(NoCompress.mainAsset);\n }\n \n```\n\nエラーメッセージ:Error while reading AssetBundle header! \nエラーメッセージ:NullReferenceException: Object reference not set to an instance of an\nobject\n\n●質問 \n・Unity4.xと違い拡張子がUnity3dではないアセットバンドルが作成されるのですが、 \nUnity5からは拡張子がUnity3dでなくてもロードできるのでしょうか? \n・AssetBundle.CreateFromFile(path)でロードする時に必要なファイルは \nmanifestが拡張子についていない側をパス付きでロードすれば良いでしょうか?\n\nAssetBundle自体はmanifestではない方に入っていると認識しています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T10:28:06.370", "favorite_count": 0, "id": "8528", "last_activity_date": "2015-09-23T13:28:46.097", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5261", "post_type": "question", "score": 1, "tags": [ "c#", "unity3d" ], "title": "Unity5のアセットバンドル作成とロード", "view_count": 2729 }
[ { "body": ">\n> Unity4.xと違い拡張子がUnity3dではないアセットバンドルが作成されるのですが、Unity5からは拡張子がUnity3dでなくてもロードできるのでしょうか?\n\nはい。Unity5からは拡張子は任意のもので大丈夫です。\n\n>\n> AssetBundle.CreateFromFile(path)でロードする時に必要なファイルはmanifestが拡張子についていない側をパス付きでロードすれば良いでしょうか?\n\nはい。manifestがないほうをロードしてください。\n\nただし質問内容の使い方ではいくつか問題があります。 \n \nまず、CreateFromFile()は非圧縮のアセットバンドルしか使用することができません。 \nBuildPipeline.BuildAssetBundles()にてBuildAssetBundleOptionsを指定しない場合はNoneになってしまうため、非圧縮用のオプションを指定してください。\n\n```\n\n BuildPipeline.BuildAssetBundles(\"Assets/BundleOutPut/\", BuildAssetBundleOptions.UncompressedAssetBundle);\n \n```\n\n \n読み込みパスを指定する際に、\"file://\"の記述がありますが、これはWWWクラスを用いてローカルファイルのパスを指定する際に使うものです。 \nCreateFromFile()はローカルファイルを取得する関数なので\"file://\"は必要ありません。 \n \ntestcanvasのアセットバンドルを読み込む場合は、LoadAsset関数を使って以下のとおりにすることで読み込めます。\n\n```\n\n string path = Application.streamingAssetsPath + \"/\";\n AssetBundle ab = AssetBundle.CreateFromFile( path + \"testcanvas\" );\n foreach( var assetName in ab.GetAllAssetNames() )\n {\n var asset = ab.LoadAsset< GameObject >( assetName );\n GameObject.Instantiate( asset );\n }\n \n```\n\n \nBuildPipeline.BuildAssetBundles()関数で指定したフォルダ名と同名のファイル(今回の場合はBundleOutPut)は複数のAssetBundleを作成した場合の、全AssetBundleのパスと関係性の記述されたファイルですので、このファイルそのものをLoadAssetでファイルを読んでもオブジェクトは取得できないので気をつけてください。 \n詳しくは以下のサイトを参考にしてください。 \n<http://qiita.com/satotin/items/7a481c69230e9393401b>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-09-23T13:28:46.097", "id": "16878", "last_activity_date": "2015-09-23T13:28:46.097", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "12383", "parent_id": "8528", "post_type": "answer", "score": 1 } ]
8528
16878
16878
{ "accepted_answer_id": null, "answer_count": 1, "body": "open\nprocessingにある[こちらのコード](http://www.openprocessing.org/sketch/6655)で分からない部分があります.\n\n```\n\n void bounce(Particle a, Particle b) {\n if (sqrt(pow(a.posX - b.posX, 2) + pow(a.posY - b.posY, 2)) < (a.radius + b.radius)) {\n if (sqrt(pow(a.posX - b.posX, 2) + pow(a.posY - b.posY, 2)) > sqrt(pow(\n a.posX + a.vX - b.posX - b.vX, 2)\n + pow(a.posY + a.vY - b.posY - b.vY, 2))) {\n \n float commonTangentAngle = atan2(b.posX - a.posX, b.posY\n - a.posY)\n + asin(1);\n \n```\n\n最初のif文で距離を取っているのは分かるんですが,そのあとに続くifの条件分\n\n```\n\n if (sqrt(pow(a.posX - b.posX, 2) + pow(a.posY - b.posY, 2)) > sqrt(pow(\n a.posX + a.vX - b.posX - b.vX, 2)\n + pow(a.posY + a.vY - b.posY - b.vY, 2))) {\n \n```\n\nとcommonTangentAngleの示す意味がよくわかりません.プログラミングというより物理運動の公式だと思いますが…初歩的な物理すらわからないのでひょっとすると教科書レベルの公式なのかもしれませんが詳しく教えてください.", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T10:50:45.953", "favorite_count": 0, "id": "8529", "last_activity_date": "2015-03-29T12:45:08.663", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9056", "post_type": "question", "score": 1, "tags": [ "processing" ], "title": "processingでの衝突判定", "view_count": 958 }
[ { "body": "```\n\n if (sqrt(pow(a.posX - b.posX, 2) + pow(a.posY - b.posY, 2)) > sqrt(pow(\n a.posX + a.vX - b.posX - b.vX, 2)\n + pow(a.posY + a.vY - b.posY - b.vY, 2))) {\n \n```\n\nこのif文については、現在の2つのパーティクル間の距離が次フレームのパーティクル間の距離より大きいかどうかを判定しています。言い換えると、2つのパーティクルが互いに近接している途中なのか離反している途中なのかチェックしています。\n\n![picture](https://i.stack.imgur.com/A3QTk.png)\n\n衝突が発生するのはもちろん近接している場合のみです。 \nちなみに`sqrt`はなくても結果は同じなのでもう少しすっきり書きなおすことができます。\n\n```\n\n if (pow(a.posX - b.posX, 2) + pow(a.posY - b.posY, 2) > \n pow(a.posX + a.vX - b.posX - b.vX, 2) + pow(a.posY + a.vY - b.posY - b.vY, 2))\n \n```\n\n`commonTangentAngle`は反射面の角度です。\n\n![commonTangentAngle](https://i.stack.imgur.com/VYPRp.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T12:37:44.240", "id": "8531", "last_activity_date": "2015-03-29T12:45:08.663", "last_edit_date": "2015-03-29T12:45:08.663", "last_editor_user_id": "3639", "owner_user_id": "3639", "parent_id": "8529", "post_type": "answer", "score": 4 } ]
8529
null
8531
{ "accepted_answer_id": "8539", "answer_count": 2, "body": "現在、RubyのDate型を利用して2つのDate型インスタンスから、 \nその差分の日数を「□年◯ヶ月△日」で取得する方法を考えいているのですが上手く行きません。\n\n例) d1 = Date.new(2014,3,3), d2 = Date.new(2014,5,10) \n望んでいる出力 \n'0年2ヶ月7日' = date_difference(d1,d2)\n\n結果はStringオブジェクトでなくても構いません。\n\n現状はIntegerで日数の差分を取得を取得しています。(上の例の場合:68日) \nですが、そこから上手く年、月、日に変換する事ができていません。 \n主に日数の差が1月以上ある際に、月数を出すために、その月の日数(30,31,28など)によって除数が変わるためアルゴリズムが複雑になってしまうという問題があります。\n\n上記ような理由があり、期待する値をシンプルに求めるためにDate型の機能を使用できればと思っています。 \nなにか思い当たる節がある方がいらしゃったら教えていただけると幸いです。 \nまた,Date型を使用しなくてもスマートに書ける方法が思いつく方がいましたら、そちらでも構いません。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T10:53:26.377", "favorite_count": 0, "id": "8530", "last_activity_date": "2015-03-29T21:27:54.800", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7944", "post_type": "question", "score": 1, "tags": [ "ruby", "ruby-on-rails" ], "title": "RubyのDate型で日付の差分を「□年◯ヶ月△日」で取得する方法", "view_count": 5717 }
[ { "body": "d1 <= d2 限定ですが、こんな感じでどうでしょう?\n\n```\n\n require 'date'\n \n d1 = Date.new( 2014, 3, 3 )\n d2 = Date.new( 2014, 5, 10 )\n \n # d1の1日を作ってd2を補正\n d2 -= d1 - Date.new( d1.year, d1.month, 1 )\n \n # 月数で計算\n diff_months = d2.year * 12 + d2.month - d1.year * 12 - d1.month\n \n # 年月日に戻す\n diff_years = diff_months / 12\n diff_months -= diff_years * 12\n diff_days = d2.day - 1\n \n puts \"#{diff_years}年#{diff_months}ヶ月#{diff_days}日\"\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T14:38:01.733", "id": "8539", "last_activity_date": "2015-03-29T14:38:01.733", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7900", "parent_id": "8530", "post_type": "answer", "score": 3 }, { "body": "activesupportというgemを使うと、特定の日付からのxx日後、xx日前、xxヶ月後、xxヶ月前、といった日付を取得することができます。\n\n```\n\n require 'active_support/all'\n \n '2015-01-01'.to_date.since(1.day).to_date\n # => Fri, 02 Jan 2015\n '2015-01-01'.to_date.since(1.month).to_date\n # => Sun, 01 Feb 2015\n '2015-01-01'.to_date.since(1.year).to_date\n # => Fri, 01 Jan 2016\n \n```\n\n全部自前で計算しようとするとかなり苦労すると思うので、まずはこういったgemの力を借りるのがよいかと思います。\n\nただし、具体的な計算ロジックはここで書くことは出来ません。 \nなぜなら仕様が明確でないからです。\n\n同じ年月内(2015-01-01から2015-01-15等)や、xx月1日同士のdiff(2015-01-01から2015-02-01等)であればわかりやすいですが、どちらかの日付に28日~31日が含まれる場合や、閏年が絡んでくる場合にどういう結果を得たいのかが不明です。\n\nたとえば、activesupportを使うと、2015-01-28の1ヶ月後も、2015-01-31の1ヶ月後も、どちらも2015-02-28が返ってきます。\n\n```\n\n '2015-01-28'.to_date.since(1.month).to_date\n # => Sat, 28 Feb 2015\n '2015-01-31'.to_date.since(1.month).to_date\n # => Sat, 28 Feb 2015\n \n```\n\nなので、考え方によっては'2015-01-28'から'2015-02-28'も、'2015-01-31'から'2015-02-28'も、どちらも「0年1ヶ月0日」だ、という見方もできます。\n\n一方で、「'2015-01-31'から'2015-02-27' => 0年0ヶ月27日」であれば「'2015-01-31'から'2015-02-28' =>\n0年0ヶ月28日」だ、と考える人も出てきそうです。\n\nこのあたりはかなり多くの組み合わせが考えられそうです。\n\nもし仕様が明確に決まっているのであればそのあたりも追記してください。\n\n### 追記\n\n参考までに動作確認用に書いた計算ロジックとテストコードを載せておきます。 \nあくまで動作確認用なので、あまりきれいなコードじゃないです。\n\n```\n\n require 'active_support/all'\n \n def date_diff(date_from, date_to)\n month_diff = 0\n while date_from.since((month_diff + 1).months).to_date <= date_to\n month_diff += 1\n end\n day_diff = (date_to - date_from.since((month_diff).months).to_date).to_i\n year_diff, month_diff = month_diff.divmod(12)\n [year_diff, month_diff, day_diff]\n end\n \n describe '#date_diff' do\n subject { date_diff(date_from.to_date, date_to.to_date) }\n context '同じ日' do\n let(:date_from) { '2015-01-01' }\n let(:date_to) { '2015-01-01' }\n it { is_expected.to eq [0, 0, 0] }\n end\n context '1日違い' do\n let(:date_from) { '2015-01-01' }\n let(:date_to) { '2015-01-02' }\n it { is_expected.to eq [0, 0, 1] }\n end\n context '1日-月末' do\n let(:date_from) { '2015-01-01' }\n let(:date_to) { '2015-01-31' }\n it { is_expected.to eq [0, 0, 30] }\n end\n context '1ヶ月違い' do\n let(:date_from) { '2015-01-01' }\n let(:date_to) { '2015-02-01' }\n it { is_expected.to eq [0, 1, 0] }\n end\n context '1ヶ月と1日違い' do\n let(:date_from) { '2015-01-01' }\n let(:date_to) { '2015-02-02' }\n it { is_expected.to eq [0, 1, 1] }\n end\n context '1ヶ月後に同じdayが存在しない場合' do\n context '1ヶ月未満' do\n let(:date_from) { '2015-01-31' }\n let(:date_to) { '2015-02-01' }\n it { is_expected.to eq [0, 0, 1] }\n end\n context '翌月の月末まで' do\n let(:date_from) { '2015-01-31' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 0] }\n end\n context '1/30から翌月の月末まで' do\n let(:date_from) { '2015-01-30' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 0] }\n end\n context '1/29から翌月の月末まで' do\n let(:date_from) { '2015-01-29' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 0] }\n end\n context '1/28から翌月の月末まで' do\n let(:date_from) { '2015-01-28' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 0] }\n end\n context '1/27から翌月の月末まで' do\n let(:date_from) { '2015-01-27' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 1] }\n end\n context '1/28から翌月の月末-1まで' do\n let(:date_from) { '2015-01-28' }\n let(:date_to) { '2015-02-27' }\n it { is_expected.to eq [0, 0, 30] }\n end\n context '1/29から翌月の月末-1まで' do\n let(:date_from) { '2015-01-29' }\n let(:date_to) { '2015-02-27' }\n it { is_expected.to eq [0, 0, 29] }\n end\n context '31-27' do\n let(:date_from) { '2015-01-31' }\n let(:date_to) { '2015-02-27' }\n it { is_expected.to eq [0, 0, 27] }\n end\n end\n context 'スタックオーバーフローの例' do\n let(:date_from) { '2014-03-03' }\n let(:date_to) { '2014-05-10' }\n it { is_expected.to eq [0, 2, 7] }\n end\n context '1年違い' do\n let(:date_from) { '2015-01-01' }\n let(:date_to) { '2016-01-01' }\n it { is_expected.to eq [1, 0, 0] }\n end\n context '1年と1日違い' do\n let(:date_from) { '2015-01-01' }\n let(:date_to) { '2016-01-02' }\n it { is_expected.to eq [1, 0, 1] }\n end\n context '1年と-1日違い' do\n let(:date_from) { '2015-01-01' }\n let(:date_to) { '2015-12-31' }\n it { is_expected.to eq [0, 11, 30] }\n end\n context '閏年が関連する場合' do\n context '28-28' do\n let(:date_from) { '2015-02-28' }\n let(:date_to) { '2016-02-28' }\n it { is_expected.to eq [1, 0, 0] }\n end\n context '28-29' do\n let(:date_from) { '2015-02-28' }\n let(:date_to) { '2016-02-29' }\n it { is_expected.to eq [1, 0, 1] }\n end\n context '閏年の28-28' do\n let(:date_from) { '2016-02-28' }\n let(:date_to) { '2017-02-28' }\n it { is_expected.to eq [1, 0, 0] }\n end\n context '29-28' do\n let(:date_from) { '2016-02-29' }\n let(:date_to) { '2017-02-28' }\n it { is_expected.to eq [1, 0, 0] }\n end\n context '閏年の29-3月1日' do\n let(:date_from) { '2016-02-29' }\n let(:date_to) { '2017-03-01' }\n it { is_expected.to eq [1, 0, 1] }\n end\n context '閏年の28-3月1日' do\n let(:date_from) { '2016-02-28' }\n let(:date_to) { '2017-03-01' }\n it { is_expected.to eq [1, 0, 1] }\n end\n end\n end\n \n```\n\nこのロジックを使うと、例として挙がっている日付のdiffも「0年2ヶ月7日」になります。\n\n```\n\n context 'スタックオーバーフローの例' do\n let(:date_from) { '2014-03-03' }\n let(:date_to) { '2014-05-10' }\n it { is_expected.to eq [0, 2, 7] }\n end\n \n```\n\n一方で、日付は異なるのにdiffは同じ、というケースも出てきます。\n\n```\n\n context '翌月の月末まで' do\n let(:date_from) { '2015-01-31' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 0] }\n end\n context '1/30から翌月の月末まで' do\n let(:date_from) { '2015-01-30' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 0] }\n end\n context '1/29から翌月の月末まで' do\n let(:date_from) { '2015-01-29' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 0] }\n end\n context '1/28から翌月の月末まで' do\n let(:date_from) { '2015-01-28' }\n let(:date_to) { '2015-02-28' }\n it { is_expected.to eq [0, 1, 0] }\n end\n \n context '閏年の28-28' do\n let(:date_from) { '2016-02-28' }\n let(:date_to) { '2017-02-28' }\n it { is_expected.to eq [1, 0, 0] }\n end\n context '29-28' do\n let(:date_from) { '2016-02-29' }\n let(:date_to) { '2017-02-28' }\n it { is_expected.to eq [1, 0, 0] }\n end\n \n```\n\nなお、テストコード(RSpec)がよくわからないという場合はこちらの記事を参考にしてみてください。\n\n[使えるRSpec入門・その1「RSpecの基本的な構文や便利な機能を理解する」](http://qiita.com/jnchito/items/42193d066bd61c740612)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T21:05:14.103", "id": "8543", "last_activity_date": "2015-03-29T21:27:54.800", "last_edit_date": "2015-03-29T21:27:54.800", "last_editor_user_id": "85", "owner_user_id": "85", "parent_id": "8530", "post_type": "answer", "score": 1 } ]
8530
8539
8539
{ "accepted_answer_id": "8537", "answer_count": 1, "body": "Pyserialを使って受信データに応じて処理を変えようとして以下を書きました。 \nprint文の結果は\"TEST\"が表示されるのですが、その際に\"OK\"まで行きません。 \n対策を教えてください。(Python 2.7.3)\n\n```\n\n import serial\n port = \"/dev/rfcomm0\"\n baudrate = 115200\n ser = serial.Serial(port, baudrate)\n \n while 1:\n if ser.inWaiting > 0\n print ser.read(ser.inWaiting())\n if ser.read(ser.inWaiting()) == \"TEST\"\n     print (\"OK\")\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T13:44:33.210", "favorite_count": 0, "id": "8532", "last_activity_date": "2015-03-29T14:53:45.650", "last_edit_date": "2015-03-29T14:53:45.650", "last_editor_user_id": "806", "owner_user_id": "5818", "post_type": "question", "score": 2, "tags": [ "python" ], "title": "pyserialでreadしたデータの文字比較", "view_count": 10092 }
[ { "body": "printするためにser.read()を読み込んでしまっています。if文でser.read()するときにはその続きを読み込もうとするはずです。以下のように修正すれば良いかと思います。\n\n```\n\n while 1:\n if ser.inWaiting() > 0\n data = ser.read(ser.inWaiting())\n print data\n if data == \"TEST\"\n     print (\"OK\")\n \n```", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T14:17:27.147", "id": "8537", "last_activity_date": "2015-03-29T14:17:27.147", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "8532", "post_type": "answer", "score": 2 } ]
8532
8537
8537
{ "accepted_answer_id": null, "answer_count": 0, "body": "[https://play.google.com/store/apps/details?id=com.Mata.YTplayer&hl=ja](https://play.google.com/store/apps/details?id=com.Mata.YTplayer&hl=ja) \nこのアプリのように、YouTube動画の再生画面の上にToolbarなどのViewを、オーバーレイして表示したいです。 しかし、`YouTube\nPlayer\nAPI`([URL](https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/package-\nsummary?hl=ja))を使うと、ToolbarなどのViewをオーバーレイした時に、以下のエラーがでてできません。\n\n**エラー**\n\n```\n\n YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.support.v7.widget.Toolbar{1b111527 V.E..... ........ 0,0-1200,128 #7f090047 app:id/toolbar}. The view is inside the YouTubePlayerView, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 0, top: 0, right: 0, bottom: 547..\n \n```\n\nどうすれば上のアプリのような再生画面を実現できるのでしょうか、デバイスモニタでViewを確認したのですが、やり方がわからないので教えていただけると有難いです。\nよろしくおねがいします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T14:09:25.053", "favorite_count": 0, "id": "8535", "last_activity_date": "2015-03-31T02:13:12.400", "last_edit_date": "2015-03-31T02:13:12.400", "last_editor_user_id": "7232", "owner_user_id": "7232", "post_type": "question", "score": 1, "tags": [ "android", "youtube-player-api" ], "title": "YouTube PlayerにオーバーレイしてViewを表示したい", "view_count": 573 }
[]
8535
null
null
{ "accepted_answer_id": "8541", "answer_count": 1, "body": "<http://syucream.github.io/hpack-spec-ja/header-compression-10-ja.html>\n\n5.2 文字列リテラル表現\n\n> ハフマンエンコードされたデータは常にオクテット境界で終わる\n> わけではないので、その後に次のオクテット境界までパディングが挿入されます。このパディングが文字列リテラルの一部だと誤認\n> されることを防ぐため、符号の最上位ビットに EOS(end-of-string) に対応するシンボルが使用されます。\n>\n> EOS シンボルのコードの 最上位ビットに対応しないパディングはデコードエラーとして 扱われなければなりません (MUST) 。\n\nの記述ですが、 \n「符号の最上位ビットに EOSに対応するシンボルを使用する」とは具体的にどのように行うのですか?\n\n次のリテラルをハフマンコーディングする場合、\n\nwww.example.com\n\nwは「1111000」なので、「1111 0001 1110 0011 1100 0」のように連結していき、最終的に\n\n11110001 f1 \n11100011 e3 \n11000010 c2 \n11100101 e5 \n11110010 f2 \n00111010 3a \n01101011 6b \n10100000 a0 \n10101011 ab \n10010000 90 \n11110100 f4 \n1 ff\n\nになります。 \n最後のオクテットは中途半端な7ビットを1でパディングしています。 \nこのリテラル文字列のレングスはHビットを立てて12で「8c」。\n\nこの中で「符号の最上位ビットに EOSに対応するシンボルを使用する」行為はどこになりますか?\n\n該当箇所の原文\n\n> As the Huffman encoded data doesn't always end at an octet boundary, \n> some padding is inserted after it, up to the next octet boundary.\n>\n> To prevent this padding to be misinterpreted as part of the string \n> literal, the most significant bits of the code corresponding to the \n> EOS (end-of-string) symbol are used.", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T15:19:49.223", "favorite_count": 0, "id": "8540", "last_activity_date": "2015-03-29T15:47:12.373", "last_edit_date": "2015-03-29T15:35:00.507", "last_editor_user_id": "3496", "owner_user_id": "3496", "post_type": "question", "score": 1, "tags": [ "http", "http2", "hpack" ], "title": "HTTP2のHPACKにおけるEOSの使い方", "view_count": 150 }
[ { "body": "符号の最上位ビットに EOSに対応するシンボルを使用しているのはこの部分です。\n\n> 最後のオクテットは中途半端な7ビットを1でパディングしています。\n\nEOSの符号は、\n\n> EOS (256) |11111111|11111111|11111111|111111 3fffffff [30]\n\nです。つまりパディングの部分をすべて1で埋めます。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T15:47:12.373", "id": "8541", "last_activity_date": "2015-03-29T15:47:12.373", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "8540", "post_type": "answer", "score": 1 } ]
8540
8541
8541
{ "accepted_answer_id": "8551", "answer_count": 1, "body": "ターミナルを初めて使ってruby on railsの環境を設定しています。ruby/rails/gemというもののアップデートを行っております。Mac OS\nX 10.9.5です。 \nそれぞれのバージョンは\n\nruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13] \nRails 4.2.1 \ngem 2.4.6 \nです。 \nそこで確か cd my_app(my_appというディレクトリを動画を見ながらターミナルで \n作ってあります。)というコマンドを実行したところ \nかなりの頻度で以下のエラーが出てきます。\n\nWarning: Running `gem pristine --all` to regenerate your installed gemspecs\n(and deleting then reinstalling your bundle if you use bundle --path) will\nimprove the startup performance of Spring.\n\nこれが何を示すのか調べたのですがさっぱり検討がつきません。初歩的な質問かもしれませんが \nぜひお知恵をおかりしたくよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-29T18:01:09.277", "favorite_count": 0, "id": "8542", "last_activity_date": "2015-03-30T04:43:37.563", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9060", "post_type": "question", "score": 1, "tags": [ "ruby", "ruby-on-rails", "macos" ], "title": "Ruby on Railsをターミナルで環境設定する際のエラー(Warning:)について教えて下さい。", "view_count": 390 }
[ { "body": ">cd my_app というコマンドを実行したところ\n\ncdというコマンドで表示されたというのは、何かの間違いだと思います。 \nその警告は、railsをspring経由で実行しようとすると表示されるもので。 \ncd(change directory)で表示されるものではありません。 \n実際に警告を発しているコードは、以下をご確認ください。 \n( 参照: <https://github.com/rails/spring/blob/master/bin/spring#L39-L41> )\n\nGem::Specification(Gemのメタデータ)から情報を絞り込んでいって、 \n最終的にunstubbed配列に、何かしらデータが含まれていると警告を発するようです。 \nその絞り込み方は、specifications/defaultディレクトリを見ていたり。stubbed?メソッドの真偽値を利用していて、少々複雑なのですが気になるのであれば先に示したコードの部分を、script\nrunner等で実行して値を確認してみると良いでしょう。(それでどのgemが問題になっているのかも分かるはずです)\n\n確保済のメタデータに、何かしらの差異が生じてしまっていると考えられますので \n素直に`gem pristine --all`して、警告を解決されて良いと思います。", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T04:43:37.563", "id": "8551", "last_activity_date": "2015-03-30T04:43:37.563", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8335", "parent_id": "8542", "post_type": "answer", "score": 1 } ]
8542
8551
8551
{ "accepted_answer_id": "8545", "answer_count": 2, "body": "・あるサイトで下記のように書いてあったのですが、内容について教えてください\n\n> addEventListenerで登録したイベントリスナの第一引数に、イベントオブジェクトが自動的に渡されます\n\n**質問** \n・何のために自動的に渡されるのでしょうか? \n・試しに第一引数を利用せず「event.preventDefault()」と書いたらイベントキャンセルされたのですが… \n・下記の違いは?\n\n・自動的に渡される引数を使用\n\n```\n\n function hoge(evt) {\n evt.preventDefault();\n }\n \n```\n\n・eventを使用\n\n```\n\n function hoge() {\n event.preventDefault();\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T00:47:51.147", "favorite_count": 0, "id": "8544", "last_activity_date": "2015-03-30T02:17:25.140", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 0, "tags": [ "javascript" ], "title": "addEventListenerで登録したイベントリスナの第一引数に、イベントオブジェクトが自動的に渡されます", "view_count": 593 }
[ { "body": "・リスナがなんのイベントを処理してるか知るためです。 \nたとえば、複数の種類のイベントを1つのリスナで処理したい場合などです。inputイベントとchangeイベントで同じリスナを使いたいけどちょっとだけ処理を変えたいとか、WindowでのblurイベントとDocumentでのblurイベントでだいたい同じような処理をしたいけど、ちょっとだけ違う処理をしたいとか。evt.typeでイベントの種類、evt.targetでイベントが発火したオブジェクトを参照できます。\n\n・引数を使わないでeventを参照する方法は非標準です \nFirefoxで動きません。IEの独自拡張で、WebKit系でもIEとの互換性のために動くようになっています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T02:11:06.973", "id": "8545", "last_activity_date": "2015-03-30T02:11:06.973", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3475", "parent_id": "8544", "post_type": "answer", "score": 5 }, { "body": "```\n\n function hoge(){\n ここに処理\n }\n \n function fuga(){\n hoge(引数1);\n }\n \n```\n\nこの場合、fuga()で渡された「引数1」を使用したい場合にどうするでしょうか?\n\n```\n\n function hoge(evt){\n evt.preventDefault();\n }\n \n function fuga(){\n hoge(引数1);\n }\n \n```\n\nとして、hoge()の受け取る引数に名前を付けてあげるか、\n\n```\n\n function hoge(){\n argments[0].preventDefault();\n }\n \n function fuga(){\n hoge(引数1);\n }\n \n```\n\nとしてargmentsを使用するかのどちらかだと思います。\n\n```\n\n function hoge() {\n event.preventDefault();\n }\n \n```\n\nだと「event」は何者?ということになってしまいます。\n\n \n\n * 何のために自動的に渡されるのでしょうか?\n\n「addEventListener」では渡されたイベントオブジェクトによって処理を分岐したいことがあるからではないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T02:17:25.140", "id": "8546", "last_activity_date": "2015-03-30T02:17:25.140", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8963", "parent_id": "8544", "post_type": "answer", "score": 0 } ]
8544
8545
8545
{ "accepted_answer_id": "8558", "answer_count": 4, "body": "次のような関数を作ろうとしています。\n\n```\n\n public static void Hoge<int>(Func<int> function)\n {\n var value = function();\n var expression = new Expression<Func<int>>(function); // ←ビルドエラー。何か方法は無いか?\n var name = (expression.Body as MemberExpression).Member.Name;\n \n // 以下、valueとnameを使った処理\n }\n \n```\n\n`Hoge(() => x)` という感じに呼び出して、変数名`x`とその値を同時に渡したいのです。 \nしかし、このような`Expression<T>`のコンストラクタは存在しないので、このままでは実現できません。 \n`Hoge()`の引数を`Expression<Func<int>>`にして、`Compile()`してから実行して値を取り出す、というのも可能ですが、`Compile()`がとても遅いのでやりたくないです。 \n※`MemberExpression`経由で変数名を取り出すのに比べて2桁以上遅い\n\n↓こういう形ならさくっと`Expression`インスタンスを作れるから簡単だろうと思いましたが、もしかしてこれはコンパイル時にすごいことをやってくれているだけなのであって、実行時にやろうとすると容易ではないのでしょうか?\n\n```\n\n int x = 10;\n Expression<Func<int>> exp = () => x;\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T05:01:22.733", "favorite_count": 0, "id": "8553", "last_activity_date": "2015-03-30T23:42:13.143", "last_edit_date": "2015-03-30T07:40:23.417", "last_editor_user_id": "8000", "owner_user_id": "8078", "post_type": "question", "score": 2, "tags": [ "c#" ], "title": "Func<T> から Expression<Func<T>> のインスタンスを生成する方法", "view_count": 3509 }
[ { "body": "おそらく、無いと思います。残念ですが…。 \n代替案ですが、プロパティみたいに何回も同じものを渡す場合は、引数を`Expression<Func<T>>`にしておいて、内部で`Compile`した結果を`Dictionary<string,\nFunc<T>>`みたいなものにキャッシュしておくと2回目からは早くできます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T06:25:53.047", "id": "8554", "last_activity_date": "2015-03-30T07:17:23.853", "last_edit_date": "2015-03-30T07:17:23.853", "last_editor_user_id": "4765", "owner_user_id": "9063", "parent_id": "8553", "post_type": "answer", "score": 1 }, { "body": "`Func<T>` は実行可能なコードへの参照、`Expression` は構文木のようなデータ構造ですから、`Func<T> → Expression`\nの変換は逆コンパイルをするようなものです。\n\n`Expression<T> e = ラムダ式;` は「`Expression`\nを生成するプログラム」に変換される糖衣構文のようなものですが、コンパイル中には当然その部分の構文木もあるわけなので、これを `Expression`\nに変形するのも容易でしょう。\n\nラムダ式をデリゲートと式木(あるいは文字列)の両方にコンパイルできると便利そうですが、実装される気はしないですね・・・。\n\n```\n\n // 妄想:後から変換できるように\n Lambda<Func<int>> l = () => 1; //この型はコンパイル時のみ存在する??\n Func<int> f = l;\n Expression<Func<int>> e = l; //式木にできないラムダ式はどうする?\n \n // 妄想:同時に受け取る\n Func<int> f, Expression<Func<int>> e;\n (f, e) = () => 1; //この構文はC#にはない\n \n```\n\n参考\n\n * [c# - converting a .net `Func<T>` to a .net `Expression<Func<T>>` - Stack Overflow](https://stackoverflow.com/q/767733/2818869)\n * [式木(Expression Trees) (C# によるプログラミング入門)](http://ufcpp.net/study/csharp/sp3_expression.html)\n * [Expression(TDelegate) クラス (System.Linq.Expressions)](https://msdn.microsoft.com/ja-jp/library/bb335710.aspx)\n\n* * *\n\n追記:質問にあるコードでは `() => hoge.piyo`\nといった式を期待されているようですが、単純なフィールド・プロパティアクセスならリフレクションを使うと速いかもしれません。\n\n[c# - How do I get the value of MemberInfo? - Stack\nOverflow](https://stackoverflow.com/q/238555/2818869)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T08:32:27.807", "id": "8558", "last_activity_date": "2015-03-30T08:59:49.803", "last_edit_date": "2017-05-23T12:38:56.467", "last_editor_user_id": "-1", "owner_user_id": "8000", "parent_id": "8553", "post_type": "answer", "score": 4 }, { "body": "質問の状況であれば逆コンパイルによって`Func<int>`から変数名を読み取ることは可能です。\n\n考え方としては\n\n 1. `Delegate`インスタンスの`Method`プロパティから`MethodInfo`を取得する\n 2. `MethodInfo`から`GetMethodBody().GetILAsByteArray()`でILコードを取得する\n 3. IL中の`ldfld`(`0x7B`)がフィールドから値を読みだしている箇所で、続く4バイト(リトルエンディアン)が`FieldInfo.MetadataToken`に該当する\n 4. フィールドの定義されている`ModuleHandle`は`Delegate.Target`→`Object.GetType()`→`Type.TypeHandle`→`RuntimeTypeHandle.GetModuleHandle()`で取得できる\n 5. `ModuleHandle.ResolveFieldHandle(int)`でメタデータトークンからハンドルが取得できる\n 6. `FieldInfo.GetFieldFromHandle()`で`FieldInfo`が取得できる\n\nのようになります。\n\n```\n\n static class Program\n {\n static void Main(string[] args)\n {\n var a = typeof(Program).GetHashCode();\n var b = typeof(Program).GetType().GetHashCode();\n WriteFieldName(() => a);\n WriteFieldName(() => b);\n Console.ReadKey();\n }\n private static void WriteFieldName(Func<int> a)\n {\n var body = a.Method.GetMethodBody().GetILAsByteArray();\n var ldfldPos = Array.LastIndexOf(body, (byte)0x7B);\n var metadataToken = (body[ldfldPos + 4] << 24) + (body[ldfldPos + 3] << 16) + (body[ldfldPos + 2] << 8) + body[ldfldPos + 1];\n Console.WriteLine(FieldInfo.GetFieldFromHandle(a.Target.GetType().TypeHandle.GetModuleHandle().ResolveFieldHandle(metadataToken)).Name);\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T11:43:15.920", "id": "8568", "last_activity_date": "2015-03-30T11:43:15.920", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "8553", "post_type": "answer", "score": 2 }, { "body": "この処理の目的ってなんでしょうか? 処理速度が求められるものなのでしょうか?\n\n別のアプローチとしてC# 6.0になるとnameof演算子が導入されるので変数名を渡すのも楽になります。\n\n```\n\n // Hoge(x, \"x\") が呼び出される\n Hoge(x, nameof(x));\n \n```\n\nもしくはC# 3.0の匿名型+拡張メソッドで対処できる場合もあります。\n\n```\n\n static void Hoge(this object obj) {\n var type = obj.GetType();\n //\n }\n \n // プロパティxに変数xの値が格納された匿名型オブジェクト\n new{ x }.Hoge();\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T23:42:13.143", "id": "8582", "last_activity_date": "2015-03-30T23:42:13.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4236", "parent_id": "8553", "post_type": "answer", "score": 2 } ]
8553
8558
8558
{ "accepted_answer_id": null, "answer_count": 3, "body": ".NET Framework 4.5でWCFサービスと、それを利用するクライアントアプリケーションを作っています。 \nWCFサービスの引数や戻り値に使用するカスタムクラスや列挙型で、`DataMember`属性とか`EnumMember`属性を付け忘れることがあるのですが、このときにクライアント側で発生する例外のメッセージから原因を特定するのが難しく困っています。 \n戻り値がカスタムクラスで、そのいずれかのプロパティで使用している`enum`のメンバーに`EnumMember`属性を付け忘れると、次のようなエラーが出ます。\n\nExceptionの型:`System.ServiceModel.CommunicationException` \nメッセージ:`基礎になる接続が閉じられました: 維持される必要があった接続が、サーバーによって切断されました` \n※実際には`TargetInvocationException`が発生しており、その`InnerException`に上記の`CommunicationException`が入っていた。\n\nこのメッセージから、データコントラクト周りの属性付け忘れの可能性があることまでは、経験として覚えました。 \nしかし、どこで何を付け忘れているのかという具体的な原因は、今のところひたすらコードを目視で精査している状況です。 \nもう少しデバッグをしやすくする手段はないものでしょうか?\n\n例外をToStringした結果を記載しておきます。 \n`System.Reflection.TargetInvocationException: 呼び出しのターゲットが例外をスローしました。 --->\nSystem.ServiceModel.CommunicationException: 基礎になる接続が閉じられました:\n維持される必要があった接続が、サーバーによって切断されました ---> System.Net.WebException: 基礎になる接続が閉じられました:\n維持される必要があった接続が、サーバーによって切断されました ---> System.IO.IOException: 転送接続からデータを読み取れません:\n既存の接続はリモート ホストに強制的に切断されました。。 ---> System.Net.Sockets.SocketException:\n既存の接続はリモート ホストに強制的に切断されました。` \n※以下スタックトレースは省略", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T06:36:07.060", "favorite_count": 0, "id": "8555", "last_activity_date": "2015-04-09T11:02:52.093", "last_edit_date": "2015-03-30T23:53:10.290", "last_editor_user_id": "8078", "owner_user_id": "8078", "post_type": "question", "score": 2, "tags": [ "c#", "wcf" ], "title": "WCFの接続エラーから原因を特定する方法", "view_count": 17316 }
[ { "body": "`[EnumMember]`の場合`CommunicationException`ではなく内部例外のエラーメッセージを見ればフィールド名も含めて原因が分かるはずです。 \n`excetion.ToString()`をログに出力するなどしておけばよいかと。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T10:34:04.300", "id": "8564", "last_activity_date": "2015-03-30T10:34:04.300", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "8555", "post_type": "answer", "score": 1 }, { "body": "`wcf`のトレースログを出力するようにconfigファイルを変更し、出力されたログを下記のツールから閲覧すると、より詳しく調べることができるかもしれません。\n\nトレースログ出力の設定方法などは以下のMSDNページに記載があります。\n\ncf. [Service Trace Viewer Tool\n(SvcTraceViewer.exe)](https://msdn.microsoft.com/en-\nus/library/ms732023%28v=vs.110%29.aspx)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T04:16:13.127", "id": "8590", "last_activity_date": "2015-03-31T04:16:13.127", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3313", "parent_id": "8555", "post_type": "answer", "score": 0 }, { "body": "データコントラクタをチェックするコード書いてみました。 \n実行時のログで調査するのも良いですが、事前に保証できるようにして置くのも \n一つの方法だと思います。 \n単体テストでデータコントラクタを事前にチェックしておくのが良いと思いますが、 \n私の場合は、デバッグ実行時のみチェックが走るようにしたりしています。 \nご参考まで。\n\n```\n\n using System;\n using System.Diagnostics;\n using System.Linq;\n using System.Reflection;\n using System.Runtime.Serialization;\n \n namespace Tests\n {\n #if DEBUG\n \n // テスト用にenumを宣言\n [DataContract]\n public enum MyEnum\n {\n [EnumMember]\n Enum1,\n \n [EnumMember]\n Enum2,\n \n // これがエラー\n Enum3,\n }\n \n // テスト用にデータコントラクタを宣言\n [DataContract]\n public class MyData\n {\n [DataMember]\n public MyEnum MyEnum { get; set; }\n }\n \n // データコントラクタをチェックするクラスです\n public static class DataContractChecker\n {\n // データコントラクタをインスタンスからチェックする\n // デバッグ実行時のチェックはこっちを使うと楽かもです。\n public static void Assert(object dataContract)\n {\n Debug.Assert(dataContract != null);\n Assert(dataContract.GetType());\n }\n \n // タイプからチェックする。\n // ユニットテストなどはこっちの方が楽かな。\n public static void Assert(Type dataContractType)\n {\n // [DataContract]属性が指定されている\n Debug.Assert(dataContractType.CustomAttributes.Any(atr => atr.AttributeType == typeof (DataContractAttribute)),\n string.Format(\"class {0} に DataContract属性が必要です\", dataContractType.FullName));\n \n // [DataMember]が付いているプロパティを列挙し、そのプロパティがenumのものに絞る\n var q = dataContractType.GetProperties(BindingFlags.Instance | BindingFlags.Public)\n .Where(p => p.CustomAttributes.Any(atr => atr.AttributeType == typeof (DataMemberAttribute)))\n .Where(p => p.PropertyType.IsEnum)\n .Select(p => p.PropertyType);\n \n foreach (var et in q)\n {\n // enumにも[DataContract]属性が指定されている\n Debug.Assert(et.CustomAttributes.Any(atr => atr.AttributeType == typeof (DataContractAttribute)),\n string.Format(\"enum {0} に DataContractAttribute属性が必要です\", et.FullName));\n \n foreach (var ev in et.GetEnumValues())\n {\n var en = ev.GetType().GetField(ev.ToString());\n \n // enumの列挙子に[EnumMember]属性がしていされている\n Debug.Assert(en.GetCustomAttributes(typeof (EnumMemberAttribute), false).Length == 1,\n string.Format(\"enum {0} / {1} に EnumMember属性が必要です\", et.FullName, en.Name));\n }\n }\n }\n \n // 呼び出し方のサンプルです。\n public static void Test()\n {\n Assert(typeof (MyData));\n Assert(new MyData());\n }\n }\n #endif\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-09T11:02:52.093", "id": "8953", "last_activity_date": "2015-04-09T11:02:52.093", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8514", "parent_id": "8555", "post_type": "answer", "score": 1 } ]
8555
null
8564
{ "accepted_answer_id": "8560", "answer_count": 2, "body": "現在下記のソースのようにspliceを用いた実装をしたのですが、\n\n```\n\n filtered_files.splice('key', 1);\n \n```\n\n目的の要素が削除されません。\n\nlengthも減る要素の削除方法があれば、ご教授をお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T08:08:07.073", "favorite_count": 0, "id": "8556", "last_activity_date": "2015-03-30T10:17:40.190", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7626", "post_type": "question", "score": 2, "tags": [ "javascript", "html" ], "title": "連想配列に対して、lengthも減る削除がしたいです", "view_count": 17388 }
[ { "body": "・まず連想配列にはLengthの概念はないので、\n\n```\n\n var hogeArr = { hoge1 : \"h\" , hoge2 : \"o\" , hoge3 : \"g\" , hoge4 : \"e\" };\n \n var count = 0;\n for(var j in hogeArr){\n count++;\n }\n alert(count);\n \n```\n\nでLengthを数えるみたいですね。\n\n・lengthの減る削除方法はないので、\n\n```\n\n // 連想配列を生成する\n var myObj = { key1: 'value1', key2: 'value2', key3: 'value3' };\n \n // 連想配列のキー(key2)を削除する\n delete myObj['key2'];\n \n```\n\nで削除します", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T08:22:56.193", "id": "8557", "last_activity_date": "2015-03-30T08:30:30.303", "last_edit_date": "2015-03-30T08:30:30.303", "last_editor_user_id": "7626", "owner_user_id": "7626", "parent_id": "8556", "post_type": "answer", "score": 0 }, { "body": "Javascriptの連想配列は[`Array`](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array)ではなくて、[`Object`](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object)ですから、`length`とのプロパティがありません。要素数を取得するには下記のように[`Object.keys()`](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Object/keys)を用いると一番便利だと思います。\n\n```\n\n var hash = { key1: \"value 1\", key2: \"value 2\"};\n var hash = Object.keys(hash).length;\n \n```\n\n要素の削除には、[delete](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/delete)演算子が使用できます:\n\n```\n\n delete hash.key1;\n \n```\n\nまたは\n\n```\n\n delete hash['key1'];\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T10:02:00.680", "id": "8560", "last_activity_date": "2015-03-30T10:17:40.190", "last_edit_date": "2015-03-30T10:17:40.190", "last_editor_user_id": "3371", "owner_user_id": "3371", "parent_id": "8556", "post_type": "answer", "score": 3 } ]
8556
8560
8560
{ "accepted_answer_id": "8566", "answer_count": 2, "body": "たまに次のようなシェルスクリプトを見かけることがあるのですが、`/dev/null` を入力にする意味を教えてください。\n\n```\n\n cp -i %p /mnt/server/archivedir/%f < /dev/null\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-03-30T09:56:08.457", "favorite_count": 0, "id": "8559", "last_activity_date": "2020-07-31T07:18:43.383", "last_edit_date": "2020-07-31T07:18:43.383", "last_editor_user_id": "3060", "owner_user_id": "9029", "post_type": "question", "score": 10, "tags": [ "linux" ], "title": "/dev/null を入力としたリダイレクトの意味", "view_count": 4510 }
[ { "body": "行全体の意図としては、コピー先にファイルが存在する場合は上書きせずに終了するために `cp -i src dest < /dev/null`\nという表現を使っています。\n\n`cp\n-i`はコピー先にファイルが存在する場合、標準入力を受け取って、`y`で始まる文字列が入力されれば上書き、それ以外の入力が渡されれば、上書きせずに終了します。\n\n`< /dev/null` は標準入力を `/dev/null`\n(すなわち空)に切り替えることによって、端末上の応答を行うこと無しに上書きをしないコピーを実現しています。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T10:31:37.743", "id": "8563", "last_activity_date": "2015-03-30T10:31:37.743", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "344", "parent_id": "8559", "post_type": "answer", "score": 2 }, { "body": "そのコードを書いた人の真の意図はその人に訊かないとわかりませんけど推測するなら\n\n * `-i` オプションを付けているので上書きしようとするとプロンプトが出る\n * プロンプトに対する入力を `</dev/null` が抑制し no を入力したことになる\n\nことから \n「上書きしないときはコピーを実施する(警告なし)」 \n「上書きしようとしたらログファイルに警告を残す(コピーはしない)」 \nということであろうと思われるです。\n\n`cp -n` だと上書きしないけどメッセージが残らないので...\n\nあと Linux で採用している GNU coreutils の GNU `cp` でなくて、 \n古い unix (ウチにある HPUX11.11 とか) の native `cp` だと \n`-n` が無いものがあり「上書き禁止」を指定できません。 \n`-n` が無い場合に上書き禁止するには `-i </dev/null` が古くからあるイディオムです。 \nいちいち `test -e` とかするより簡単。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T10:39:53.530", "id": "8566", "last_activity_date": "2015-03-31T05:10:10.453", "last_edit_date": "2015-03-31T05:10:10.453", "last_editor_user_id": "8589", "owner_user_id": "8589", "parent_id": "8559", "post_type": "answer", "score": 11 } ]
8559
8566
8566
{ "accepted_answer_id": "8569", "answer_count": 1, "body": "iPhoneのカメラを使って写真を撮った時に、斜めに傾いてしまった写真を正確な位置に戻したいです。\n\niPhoneの連写アプリなどをつかって何枚か写真を撮った時、写真1のようにまっすぐ撮れた写真と写真2のように少し傾いてしまった写真があったとします。傾いてしまった写真2をまっすぐにするために、写真1を基準にし何かしらのアルゴリズム(★1)を使って、写真2を補正したいと考えています。OpenCVにおいて、この問題を解決できるアルゴリズムは存在するでしょうか?\n\n![写真1と写真2](https://i.stack.imgur.com/ttuLd.png) \n![写真2の補正](https://i.stack.imgur.com/UvHM7.png)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T10:13:52.027", "favorite_count": 0, "id": "8561", "last_activity_date": "2015-03-30T12:00:20.007", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "7699", "post_type": "question", "score": 4, "tags": [ "objective-c", "c++", "opencv" ], "title": "OpenCVを使って、傾いてしまった写真を正確な位置に戻したい", "view_count": 4957 }
[ { "body": "こちらの記事が参考になるのではないでしょうか。 \n[Opencvを使ってパノラマ写真を作る](http://goya813.hatenablog.com/entry/2014/11/30/180002)\n\nこの記事のソースコードでは、以下の様な変換を行っています。\n\n 1. 2枚の写真のSIFT特徴量を抽出し、\n 2. 特徴量のマッチングを行い\n 3. 画像間のホモグラフィ行列を求め\n 4. 写真2を写真1平面に透視変換した画像(写真3とする)を作成\n 5. 写真3に写真1を貼り付ける\n\n上記のステップうち、5.のステップを端折れば良いかと。\n\n記事に掲載されているソースコードの最後の部分を以下のように改変します。\n\n```\n\n Mat homo = cv::findHomography(points1, points2, CV_RANSAC);\n cv::warpPerspective(src[0], result, homo, Size(src[0].cols, src[0].rows));\n \n imshow(\"result img\", result);\n waitKey(0);\n \n```\n\nこの`result`が求めるべき写真2(完成)になると思われます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T12:00:20.007", "id": "8569", "last_activity_date": "2015-03-30T12:00:20.007", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9044", "parent_id": "8561", "post_type": "answer", "score": 7 } ]
8561
8569
8569
{ "accepted_answer_id": null, "answer_count": 1, "body": "Androidアプリ開発で困っています。 \nフローティングしてスクロール時についてくるViewの実装方法を教えて下さい。\n\nイメージは以下サンプルの「asideFixedBox」のような動きになるViewです。 \n<http://detelu.com/blog/sample/jQuery/floatbox/index2.html>\n\n常時固定位置ではなく、あくまである一定以上スクロールしたらついてくるという仕様です。 \n標準・ライブラリ問わず簡単に実現出来る方法を探しています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T12:33:07.227", "favorite_count": 0, "id": "8570", "last_activity_date": "2015-08-27T20:12:14.787", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9069", "post_type": "question", "score": 2, "tags": [ "android" ], "title": "Androidアプリでスクロール時にViewを追随させるには", "view_count": 519 }
[ { "body": "<https://github.com/emilsjolander/StickyScrollViewItems>\n\nこんなのでしょうか。\n\nこの手のライブラリはandroid sticky viewとかで検索すると色々ヒットします", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T16:29:47.497", "id": "8581", "last_activity_date": "2015-03-30T16:29:47.497", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4739", "parent_id": "8570", "post_type": "answer", "score": 1 } ]
8570
null
8581
{ "accepted_answer_id": "8572", "answer_count": 1, "body": "Firefox39でFetch APIを使い、User-Agentを意図的に変更してGETリクエストを送信したいのですが、うまくできません。\n**サーバは127.0.0.1にあり、** 下記のようになっています。\n\n```\n\n \n import http.server\n \n class handler(http.server.BaseHTTPRequestHandler):\n def do_GET(self):\n self.send_response(200, \"OK\")\n self.send_header(\"Access-Control-Allow-Origin\", \"*\")\n print(self.headers[\"User-Agent\"])\n \n server_address = (\"\", 8000)\n httpd = http.server.HTTPServer(server_address, handler);\n \n \n```\n\nJavaScriptのコード\n\n```\n\n \n fetch(\"http://localhost:8000\", {\n \"mode\": \"cors\",\n \"headers\": {\n \"User-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36\" // ChromeのUser-Agent\n }\n })\n .then(() => console.log(\"Successed\"))\n .catch(() => console.log(\"Failed\"))\n \n \n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T12:45:26.840", "favorite_count": 0, "id": "8571", "last_activity_date": "2015-03-30T13:10:02.270", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5246", "post_type": "question", "score": 0, "tags": [ "javascript", "python", "ajax" ], "title": "Fetch APIでUser-Agentを変更したGETリクエストを送る", "view_count": 3186 }
[ { "body": "User-Agent をはじめとする一部ヘッダは変更することができません。\n\n> [Headers - Web API Interfaces | MDN](https://developer.mozilla.org/en-\n> US/docs/Web/API/Headers)\n>\n> For security reasons, some headers can only be controller by the user agent.\n> These headers include the [forbidden header\n> names](https://developer.mozilla.org/en-\n> US/docs/Glossary/Forbidden_header_name) and [forbidden response header\n> names](https://developer.mozilla.org/en-\n> US/docs/Glossary/Forbidden_response_header_name).\n\nこれは XMLHttpRequest でも同様のようです。\n\n * [JQuery Ajax Request: Change User-Agent - Stack Overflow](https://stackoverflow.com/questions/5771878/jquery-ajax-request-change-user-agent)\n * [Chrome拡張でHTTPヘッダを改変 | 言葉の海のプログラマー](http://lostlinksearch.net/blog/2012/03/chrome%E6%8B%A1%E5%BC%B5%E3%81%A7http%E3%83%98%E3%83%83%E3%83%80%E3%82%92%E6%94%B9%E5%A4%89/)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T13:10:02.270", "id": "8572", "last_activity_date": "2015-03-30T13:10:02.270", "last_edit_date": "2017-05-23T12:38:56.467", "last_editor_user_id": "-1", "owner_user_id": "8000", "parent_id": "8571", "post_type": "answer", "score": 1 } ]
8571
8572
8572
{ "accepted_answer_id": "9616", "answer_count": 1, "body": "Windows7上でplay 2.3.8とEclipseのScalaIDEの環境で開発しています。\n\n以前はうまく動作していたコマンドが動作しなくなったのですが、原因や調査方法に \n心当たりある方がいましたらご教示ください。\n\n * 事象 \n`activator -jvm-debug 9999 run` でプロジェクトが起動できなくなった。 \n以前だと `Listening for transport dt_socket at address: 9999` というメッセージの後に \nリッスンまで稼働していたと思うのですが、原因不明ですが↑のメッセージで止まってしまい、 \nそれ以上動作しなくなってしまいました。 \nプロジェクトを新規作成してそちらで同じコマンドを叩いても変わらなかったので、ソースや \nライブラリ依存性ではないと思っています。\n\nrunで実行するとアプリ自体は稼働しますが、debugでブレークポイントを仕掛けられないので \n詳細の確認が難しい状況になっています。\n\nやりたいこととしてはEclipseでのデバッグのステップ操作なので、もし対処法をご存知の方が \nいましたらよろしくお願いします。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T13:26:37.583", "favorite_count": 0, "id": "8573", "last_activity_date": "2015-04-27T16:48:48.450", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9070", "post_type": "question", "score": 1, "tags": [ "scala", "playframework" ], "title": "play 2.3.8(activator)からのjvm-debugについて", "view_count": 340 }
[ { "body": "すみません、自己解決できました。\n\n動かなかった原因がactivatorのバージョンが悪かったみたいで、activatorの1.2.2だとjvm-\ndebugがうまく行かないようで、1.3.2に変更したらうまくいくようになりました。 \nどこかで過去に使っていたバージョンが混ざりこんでバージョンが変わったみたいです。 \nお騒がせしました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-27T16:48:48.450", "id": "9616", "last_activity_date": "2015-04-27T16:48:48.450", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9070", "parent_id": "8573", "post_type": "answer", "score": 1 } ]
8573
9616
9616
{ "accepted_answer_id": null, "answer_count": 1, "body": "表題の通り、並列パターンライブラリ(PPL)を使用しているDLLをC#側から利用しようと思い、 \nC++/CLIでラッパーDLLを作成していたのですが、\n\n**ERROR: Concurrency Runtime is not supported when compiling /clr.** \nとエラーが発生しました。 \nどうもPPLはCLI上からは使えないようなのですが、 \nこのライブラリをどうにかC#上から使う方法はないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T13:52:59.857", "favorite_count": 0, "id": "8574", "last_activity_date": "2015-04-30T01:37:35.960", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9071", "post_type": "question", "score": 3, "tags": [ "c#", "c++", "c++-cli" ], "title": "並列パターンライブラリ(PPL)を用いたDLLをC#から使う", "view_count": 492 }
[ { "body": "エラーメッセージにある通り、C++/CLIとPPLは併用不可能です。以下の代案が考えられます。\n\n 1. [System.Threading.Tasks 名前空間](https://msdn.microsoft.com/ja-jp/library/system.threading.tasks.aspx) 以下のクラスを用いて、C#で並列処理を書き直す。PPL相当の機能が提供されます。\n 2. C++/CLIではなくネイティブC++でラッパーDLLを作る。C#からはP/InvokeでDLL関数を呼び出す。\n 3. [本家SO質問の回答](https://stackoverflow.com/a/3948016/684921)によれば、C++ソースを分離してPimplイディオムで行ける?(Body側は/clr無し、Handle側は有りでコンパイルしてリンク可能?)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T00:39:01.933", "id": "8584", "last_activity_date": "2015-03-31T00:47:09.263", "last_edit_date": "2017-05-23T12:38:56.467", "last_editor_user_id": "-1", "owner_user_id": "49", "parent_id": "8574", "post_type": "answer", "score": 2 } ]
8574
null
8584
{ "accepted_answer_id": "10121", "answer_count": 1, "body": "![画像の説明をここに入力](https://i.stack.imgur.com/nzsDw.png)\n\nbuild.sbt\n\n```\n\n name := \"\"\"sample\"\"\"\n \n version := \"1.0-SNAPSHOT\"\n \n lazy val root = (project in file(\".\")).enablePlugins(PlayScala)\n \n scalaVersion := \"2.11.6\"\n \n libraryDependencies ++= Seq(\n jdbc,\n cache)\n \n libraryDependencies ++= Seq(\n \"org.scalikejdbc\" %% \"scalikejdbc\" % \"2.2.+\",\n \"com.h2database\" % \"h2\" % \"1.4.+\",\n \"ch.qos.logback\" % \"logback-classic\" % \"1.1.+\",\n \"jp.t2v\" %% \"play2-auth\" % \"0.13.2\",\n \"jp.t2v\" %% \"play2-auth-test\" % \"0.13.2\" % \"test\",\n \"com.github.t3hnar\" %% \"scala-bcrypt\" % \"2.4\"\n )\n \n```\n\nアプリケーションを起動できませんどうしたらよいですか?", "comment_count": 4, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T14:31:14.757", "favorite_count": 0, "id": "8576", "last_activity_date": "2015-05-13T11:00:37.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8355", "post_type": "question", "score": 1, "tags": [ "scala", "playframework" ], "title": "object github is not a member of package com", "view_count": 452 }
[ { "body": "> build.sbt に \"com.github.t3hnar\" %% \"scala-bcrypt\" % \"2.4\" の行を追加した後に、sbt(\n> activator )を reload してない、とかでしょうか? – Kenji Yoshida 3月31日 2:14", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-05-13T11:00:37.193", "id": "10121", "last_activity_date": "2015-05-13T11:00:37.193", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8355", "parent_id": "8576", "post_type": "answer", "score": 0 } ]
8576
10121
10121
{ "accepted_answer_id": "8583", "answer_count": 4, "body": "私は今、unique_ptrを用いてメモリ管理を行っています。 \nその際、unique_ptrで配列を動的確保し、それをforeach文で回す方法があるかどうか知りたいです。\n\n具体的には、\n\n```\n\n unique_ptr < int[] > foo = make_unique< int[] >(20);\n for(auto& a : foo){\n a = 0;\n }\n \n```\n\nのような感じです。 \nunique_ptrにはイテレータが用意されていないので、私の知識ではこのような処理を記述することができませんが、配列の要素数を気にせず使えるので、出来ればforeach文で処理したいと考えています。 \nC++はまだ1年も触ってない初心者ですので、解りにくい表現や、間違えて認識している部分を多々あるとは思いますが、どなたかご教授願います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T14:56:52.450", "favorite_count": 0, "id": "8577", "last_activity_date": "2015-04-05T17:34:17.960", "last_edit_date": "2015-03-30T15:20:32.247", "last_editor_user_id": "3639", "owner_user_id": "9074", "post_type": "question", "score": 3, "tags": [ "c++", "c++11" ], "title": "unique_ptr< T[] >をforeach文で使用する方法をご教授お願いします。", "view_count": 2725 }
[ { "body": "`unique_ptr`でなく`vector`を使いましょう。\n\n```\n\n vector<int> foo(20);\n for(auto& a : foo) {\n a = 0;\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T15:18:19.297", "id": "8578", "last_activity_date": "2015-03-30T15:18:19.297", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "8577", "post_type": "answer", "score": 1 }, { "body": "> unique_ptrで配列を動的確保し、それをforeach文で回す方法があるかどうか知りたいです。\n\nありません。\n\n(ちなみに、C++には\"foreach文\"は存在しないので、range-based\nfor構文か[`std::for_each`アルゴリズム](http://cpprefjp.github.io/reference/algorithm/for_each.html)ですね。)\n\nスマートポインタ`unique_ptr<T[]>`には配列要素数を管理する機構がないため、別変数を使って要素数を管理しなければなりません。また、要素走査には古典的forループが必要です。\n\n```\n\n size_t num = 20;\n unique_ptr<int[]> foo = make_unique<int[]>(num);\n for(size_t i = 0; i < num; ++i){\n auto& a = foo[i];\n a = 0;\n }\n \n```\n\nなので、通常は可変長配列`vector<T>`の利用をお勧めします。\n\n* * *\n\nおまけ:C++ランタイムライブラリは、配列の解放処理`delete[]`を正しく行うために、[その要素数を知っています](https://isocpp.org/wiki/faq/freestore-\nmgmt#num-elems-in-new-array)。ただし、プログラムからこの情報にアクセスする方法は存在しません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T00:26:52.707", "id": "8583", "last_activity_date": "2015-03-31T00:26:52.707", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "49", "parent_id": "8577", "post_type": "answer", "score": 4 }, { "body": "yohjpさんの述べているとおり`unique_ptr`では要素数を知る方法がないため、別途要素数を自分で保存しておくことで実現することになります。要素数が分かれば、ラッパークラスを作ることで対応可能です。\n\n以下のコードでは、そのようなラッパーとしてクラステンプレート`boost::iterator_range`およびそれを作成するヘルパ関数`boost::make_iterator_range`を使っています。\n\n```\n\n #include <iostream>\n #include <memory>\n #include <boost/range/iterator_range.hpp>\n \n int main()\n {\n int n = 20;\n auto foo = std::make_unique<int[]>(n);\n for (auto& a : boost::make_iterator_range(foo.get(), foo.get() + n))\n {\n a = 0;\n }\n }\n \n```\n\nBoostライブラリを使えなかったり使いたくなかったりする場合には、自作することになります。メンバ関数`begin`および`end`が存在するだけでよいので、比較的作成は容易だと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T16:12:40.300", "id": "8663", "last_activity_date": "2015-04-01T16:12:40.300", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8616", "parent_id": "8577", "post_type": "answer", "score": 3 }, { "body": "他の方も言っているように、使用するクラスを変えるか、ラッパーを作成する。 \nboostが使えない or どのように作るか知りたい場合の為、C++標準でどのように書けるか、最低限のサンプルのつもりで置いておく。\n\n```\n\n #include <iostream>\n #include <memory>\n \n \n // unique_wrapperとmake_unique_wrapperを作るためのヘルパ - かなり手抜きその1.\n // 配列か判定する - 結果はvalueが1 or 0で判別.\n template <class vType> struct is_array {\n enum { value = 0 }; // falseである.\n };\n template <class vType> struct is_array<vType[]> {\n enum { value = 1 }; // trueである.\n };\n // trueのときだけ型が存在する - SFINAEに用いる.\n template <bool Condition, class vType>\n struct condition_type {};\n template <class vType>\n struct condition_type<true, vType> {\n using type = vType;\n };\n // 型から配列要素を抜く - 配列じゃなければ元のままに.\n template <class vType>\n struct remove_array {\n using type = vType;\n };\n template <class vType>\n struct remove_array<vType[]> {\n using type = vType;\n };\n \n // 通常版と配列版を同時にラッピングしている分、若干危険かもしれない・・・?.\n template <class vType>\n class unique_wrapper : public std::unique_ptr<vType> {\n std::size_t num_array;\n using MyType = unique_wrapper<vType>;\n using PtrType = typename remove_array<vType>::type;\n public:\n unique_wrapper(MyType const &) = delete;\n // 1個版と配列版と両方のコンストラクタを持つ - make_unique_wrapperのfriendにしてprivate化するか?.\n unique_wrapper(PtrType *ptr) : std::unique_ptr<vType>(ptr), num_array(1){}\n unique_wrapper(PtrType *ptr, std::size_t num) : std::unique_ptr<vType>(ptr), num_array(num){}\n unique_wrapper(MyType &&rhs) : std::unique_ptr<vType>(rhs.release()), num_array(rhs.num_array){}\n \n // 最低限このようなインターフェースを持つiteratorと\n class iterator {\n PtrType *ptr_;\n public:\n iterator(PtrType *ptr) : ptr_(ptr){}\n ~iterator(){}\n \n PtrType *operator ++(){ ++ptr_; return ptr_; }\n PtrType &operator *(){ return *ptr_; }\n bool operator !=(iterator rhs){ return *ptr_ != *rhs; }\n };\n // 上記を戻すbeginとendというインターフェースがあればrange-based forは動く.\n iterator begin(){ return this->get(); }\n iterator end(){ return this->get() + num_array; }\n };\n \n // make_unique_wrapper自体の各種 - かなり手抜きその2.\n template <class vType>\n unique_wrapper<typename condition_type<is_array<vType>::value == 1, vType>::type> make_unique_wrapper(std::size_t n){\n unique_wrapper<vType> wrap(new typename remove_array<vType>::type[n], n);\n return wrap;\n }\n template <class vType, class ...Args>\n unique_wrapper<typename condition_type<is_array<vType>::value == 0, vType>::type> make_unique_wrapper(Args... args){\n unique_wrapper<vType> wrap(new vType((args)...));\n return wrap;\n }\n \n \n struct Foo {\n ~Foo(){\n std::cout << \"Foo destructor.\" << std::endl;\n }\n void print(){\n std::cout << \"My name is Foo.\" << std::endl;\n }\n };\n \n \n int main()\n {\n // use test code.\n {\n unique_wrapper<int[]> ptr = make_unique_wrapper<int[]>(7);\n {\n for (auto &n : ptr){\n std::cout << \"Please number and enter : \";\n std::cin >> n;\n }\n }\n \n for (auto n : ptr){\n std::cout << n << std::endl;\n }\n std::cin.get();\n std::cin.get();\n } // この段階でちゃんとdelete[]が働く.\n {\n // 折角なんでFooさんでテスト.\n unique_wrapper<Foo> ptr = make_unique_wrapper<Foo>();\n ptr->print();\n }\n \n std::cin.get();\n }\n \n```\n\n※コード書き直した。前の状態だと、破棄する場面で正しく破棄できない(配列版unique_ptrが使用されない)のに、make_unique_wrapperで指定できるのは配列作成のみだったのでちぐはぐな状態だった。 \n書き直した現状でも、想定通りのmake_unique_wrapperやmake_unique_wrapper以外の書き方への正しいエラー化を行ってはおらず、あくまで知識のたたき台として用意。 \n大事なのは、最低限あれだけのインターフェース(iteratorのoperatorとunique_wrapperのbeginとend)を作りさえすればrange-\nbased-forに投げ込めるという部分である。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-05T13:17:21.437", "id": "8793", "last_activity_date": "2015-04-05T17:34:17.960", "last_edit_date": "2015-04-05T17:34:17.960", "last_editor_user_id": "8675", "owner_user_id": "8675", "parent_id": "8577", "post_type": "answer", "score": 2 } ]
8577
8583
8583
{ "accepted_answer_id": null, "answer_count": 3, "body": "データベースの設計で悩んでいます。\n\n例えばユーザー情報用のデータベースを作るとします。\n\n* * *\n\n### users\n\n * id\n * name\n\n* * *\n\nこれに性別を持たせるときは\n\n* * *\n\n### users\n\n * id\n * name\n * sex_id\n\n### sexes\n\n * id\n * name\n\n* * *\n\nこれでよいと思うのですが、例えばグループを持たせたいときにすごく悩んでしまいます。\n\n* * *\n\n### users\n\n * id\n * name\n * group_id\n\n### groups\n\n * id\n * name\n\n* * *\n\nこうしてしまうと、将来複数のグループを持たせたいとなった時に融通がきかなくなると思います。 \nなので\n\n* * *\n\n### users\n\n * id\n * name\n\n### groups_users\n\n * id\n * user_id\n * group_id\n\n### groups\n\n * id\n * name\n\n* * *\n\nこのように中間テーブルを挟むことになると思うのですが、将来必要になるかどうかわからないものを最初からこのように設計しても問題ありませんか? \n必要になってから工事するくらいなら・・・と思ってしまうのですが。\n\nみなさんはどうしてますか? \n失敗談などもあれば是非教えて下さい。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T15:54:34.930", "favorite_count": 0, "id": "8579", "last_activity_date": "2015-04-01T04:04:27.173", "last_edit_date": "2015-04-01T04:04:27.173", "last_editor_user_id": "49", "owner_user_id": "5855", "post_type": "question", "score": 1, "tags": [ "mysql", "データベース設計" ], "title": "データベースの設計について", "view_count": 1188 }
[ { "body": "一言にグループと言っても \n単一所属グループの場合、複数所属グループの場合、階層型グループの場合。 \n複数グループに所属して、その中で優先グループをもつ場合もあります。 \nどれを想定するかで適切な設計が決まります。\n\n今迷っているのは将来の拡張性ではなく、まだグループの要件が詰めきれていないからではないでしょうか。 \nもしそうなら、決定まで設計は待った方がいい気がします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T03:58:13.427", "id": "8589", "last_activity_date": "2015-03-31T03:58:13.427", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8431", "parent_id": "8579", "post_type": "answer", "score": 1 }, { "body": "「将来を見据えた設計をすべし」とも言われますし「将来を見越しすぎるのは無駄」とも言われます。正解はありません。\n\nこういう状況で様々な要素を判断してよりベターな選択ができるのが設計者のスキルそのものです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T06:48:17.867", "id": "8597", "last_activity_date": "2015-03-31T06:48:17.867", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5793", "parent_id": "8579", "post_type": "answer", "score": 1 }, { "body": "フレームワーク的なアプローチで考えてみますね。 \nuser.groupでドバーっとあちこち書きまくったやつを、 \nuser.groupsにしたらレコードインスタンスだったものが配列になるので大変です。 \nそれなら最初から「常に配列だけど現状1件しか帰ってこないよ」の方が気が楽です。\n\nしかしその場合でもuser.groups.firstとか書いちゃったら意味がありません。\n\n以上のことから \n「groupsが複数あること前提で設計する(=複数きた時の挙動が定義できる)」 \nかどうかが判断材料としています。現時点で定義できないなら書くよりも \n「そのときは、変更コストかかりますからね?」と釘刺したほうがストレスなく済みますよ。 :)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T08:15:14.033", "id": "8603", "last_activity_date": "2015-03-31T08:15:14.033", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8335", "parent_id": "8579", "post_type": "answer", "score": 0 } ]
8579
null
8589
{ "accepted_answer_id": null, "answer_count": 1, "body": "unmanagedなC++ DllをC#側から使うため、C++/CLIでラッパーライブラリを作成しました。 \nC#側から、とりあえずTestプロジェクトを作成して動作を確認しようと試みたのですが、ライブラリの読み込みに失敗してしましました。\n\nTestプロジェクトのビルド出力フォルダにはラッパーライブラリのコピーが作成されるのですが、 \nUnmanagedのDllはコピーされないことが原因のようです。 \nこの場合、プロジェクトの設定はどのように設定するのが良いのでしょうか?\n\n実行環境はVisualStudio2013 Comunity \nUnmanagedなDllもソースコードからソリューションに登録しています。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-30T16:00:32.767", "favorite_count": 0, "id": "8580", "last_activity_date": "2015-04-01T16:17:20.327", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9071", "post_type": "question", "score": 4, "tags": [ "c#", "c++", "c++-cli" ], "title": "ラッパーライブラリの配置", "view_count": 504 }
[ { "body": "1つの方法として、C#プロジェクトとC++/CLIプロジェクトの双方で出力ディレクトリを同じ場所にするというものがあります。私は、ソリューション内のすべてのプロジェクトで出力ディレクトリを`$(SolutionDir)$(Configuration)`や`$(SolutionDir)$(Configuration)-$(PlatformShortName)`に統一することをよくやります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T16:17:20.327", "id": "8664", "last_activity_date": "2015-04-01T16:17:20.327", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8616", "parent_id": "8580", "post_type": "answer", "score": 1 } ]
8580
null
8664
{ "accepted_answer_id": "8631", "answer_count": 1, "body": "Vimでjavascriptのシンタックスチェックをしたくて、[scrooloose/syntastic](https://github.com/scrooloose/syntastic)を導入したのですが、正しく動作しません。 \n以下の画像のように`:SyntasticInfo javascript`でチェックすると、`Available checkers`も`Current\nenabled checkers`も空になってしまいます。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/Tp8YQ.png)\n\njshintはnpmでインストールし、パスは以下のようになっています。\n\n```\n\n $ which jshint\n /Users/***/.nodebrew/current/bin/jshint\n \n```\n\nまた、.vimrcは以下のように設定をしています。\n\n```\n\n let g:syntastic_mode_map = {\n \\ 'mode': 'active',\n \\ 'active_filetypes': ['javascript'],\n \\ 'passive_filetypes': ['html']\n \\}\n let g:syntastic_auto_loc_list = 1\n let g:syntastic_javascript_jshint_exec='/Users/***/.nodebrew/current/bin/jshint'\n let g:syntastic_javascript_checkers = ['jshint']\n \n```\n\n`syntastic_javascript_jshint_exec`に関しては、jshintのパスが通っていれば、設定不要であるという認識ですが、以下を参照して、一応設定しています。 \n[Syntastic doesn't detect JSHint as an available\nchecker](https://stackoverflow.com/questions/18661653/syntastic-doesnt-detect-\njshint-as-an-available-checker)\n\nなにか、情報をお持ちの方がいらっしゃいましたら、ご教示いただけると幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T02:21:37.717", "favorite_count": 0, "id": "8586", "last_activity_date": "2015-04-01T01:29:34.803", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "5710", "post_type": "question", "score": 2, "tags": [ "vim" ], "title": "Vim の Syntasticがうまく動作しない", "view_count": 884 }
[ { "body": "Vimのパスの問題でした。 \n`:echo $PATH`でパスを確認したところ、jshintのパスが設定されていませんでした。 \n以下を参考にzshのPATHを`.zshenv`に設定したところ正しく動作しました。 \n[why $PATH in vim and in zsh is\ndifferent?](https://stackoverflow.com/questions/18548351/why-path-in-vim-and-\nin-zsh-is-different)\n\nまた、原因はわかりませんが、Neobundleでインストールしたsyntasticのバージョンが最新の3.6ではなかったので、`:NeoBundleClean`をしてから再インストールしました。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T01:29:34.803", "id": "8631", "last_activity_date": "2015-04-01T01:29:34.803", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "5710", "parent_id": "8586", "post_type": "answer", "score": 2 } ]
8586
8631
8631
{ "accepted_answer_id": "8593", "answer_count": 1, "body": "# きっかけ\n\n> \"x: 100, y: 200, z: 300\" のような文字列を \n> {x: 100, y: 200, z: 300}のようなハッシュに変換する方法 \n> :\n>\n> ### パターン2 eval使う\n>\n> 超簡単(ruby怖っ)\n```\n\n> def to_hash(str)\n> eval(\"{#{str}}\")\n> end\n> \n```\n\n>\n> [Ruby 文字列をハッシュに変換 -\n> Qiita](http://qiita.com/uplus_e10/items/65a50935250639bf8308)\n\nを読んで、ふと \n「`eval` 族を使うのは怖いけど、 `BasicObject#instance_eval` であれば `str`に何らかのメソッドを使われたとしても\n`NoMethodError` になるのではなかろうか。リテラルは使えるし、これって `eval` でのセキュリティ対策に使えるかも?」 \nと思いました。\n\nRubyist の共通見解として「`eval` 族と `method_missing` は最終兵器」というのがあるかと思いますが、\n`BasicObject#instance_eval` を使うと少し気楽に `eval` できるかも、と考えました(速度などは考慮してません)。\n\n# 具体的にみてみる\n\n## 上記例を実行\n\n```\n\n $ pry\n [1] pry(main)> str = \"x: 100, y: 200, z: 300\"\n => \"x: 100, y: 200, z: 300\"\n [2] pry(main)> BasicObject.new.instance_eval(\"{#{str}}\")\n => {:x=>100, :y=>200, :z=>300}\n \n```\n\n問題なくハッシュを生成できました。\n\n## インジェクションしてみる1:メソッド\n\n```\n\n [3] pry(main)> str = \"};puts 'hello!';{\"\n => \"};puts 'hello!';{\"\n [4] pry(main)> BasicObject.new.instance_eval(\"{#{str}}\")\n NoMethodError: undefined method `puts' for #<BasicObject:0x007fa980ca39c0>\n from (pry):4:in `instance_eval'\n \n```\n\n無事に `NoMethodError` になりました。\n\n## インジェクションしてみる2:コマンド出力\n\n```\n\n [5] pry(main)> str = \"};`echo hello`;{\"\n => \"};`echo hello`;{\"\n [6] pry(main)> `echo hello`\n => \"hello\\n\"\n [7] pry(main)> BasicObject.new.instance_eval(\"{#{str}}\")\n NoMethodError: undefined method ``' for #<BasicObject:0x007fa9814fe0e8>\n from (pry):7:in `instance_eval'\n \n```\n\n`str = \"};%x[echo hello];{\"` でも同じく `NoMethodError` でした。\n\n## 定数設定\n\n```\n\n [8] pry(main)> ARY\n NameError: uninitialized constant ARY\n from (pry):8:in `__pry__'\n [9] pry(main)> str = '};::ARY = %w[a b c];{'\n => \"};::ARY = %w[a b c];{\"\n [10] pry(main)> BasicObject.new.instance_eval(\"{#{str}}\")\n => {}\n [11] pry(main)> ARY\n => [\"a\", \"b\", \"c\"]\n \n```\n\n設定されてしまいました。\n\n## グローバル変数設定\n\n```\n\n [12] pry(main)> $ary\n => nil\n [13] pry(main)> str = '};$ary = %w[a b c];{'\n => \"};$ary = %w[a b c];{\"\n [14] pry(main)> BasicObject.new.instance_eval(\"{#{str}}\")\n => {}\n [15] pry(main)> $ary\n => [\"a\", \"b\", \"c\"]\n \n```\n\nグローバル変数も設定されてしまいました。\n\n# 質問\n\n`BasicObject#instance_eval`\nだと定数とグローバル変数が犯されうることがわかりましたが、そのほかに危険性はあるでしょうか。具体的に攻撃文字列を挙げていただければ幸いです。 \nまた、定数とグローバル変数が犯されると、どのような危険性が考えられるでしょうか。\n\n以上2点について、よろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T04:23:01.093", "favorite_count": 0, "id": "8591", "last_activity_date": "2015-03-31T04:37:17.200", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "4114", "post_type": "question", "score": 3, "tags": [ "ruby", "security" ], "title": "ブランクスレート(BasicObject)のインスタンスでinstance_evalするのはセキュリティ対策になりうるか?", "view_count": 146 }
[ { "body": "たとえば、puts は、\n\n```\n\n str = \"};::Kernel.puts 'hello';{\"\n \n```\n\nとやれば働きますし、同様に外部コマンドも次のようにして実行できちゃいます。\n\n```\n\n str = \"};::Kernel.system 'ls';{\"\n \n```\n\nまた、定数を触れるということは、クラスも触れるということなので、クラスに対してなんでもできると思った方がいいと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T04:37:17.200", "id": "8593", "last_activity_date": "2015-03-31T04:37:17.200", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3249", "parent_id": "8591", "post_type": "answer", "score": 8 } ]
8591
8593
8593
{ "accepted_answer_id": "8604", "answer_count": 2, "body": "現在`Realm`を使ってデータベースを操作しているのですが、データベースの中身を確認しようと`Realm\nBrowser`なるものを見つけて色々試しているのですが、データベースの中身を見ることができません。そもそもまずRealmを使って生成されたデータベースファイルがどこの場所にあるのかすらもわかりません。どなたか分かる方がいれば`Realm\nBrowser`の使い方を教えていただきたいです。すみませんが、宜しくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T04:29:17.037", "favorite_count": 0, "id": "8592", "last_activity_date": "2015-03-31T13:34:01.870", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5210", "post_type": "question", "score": 3, "tags": [ "swift", "realm" ], "title": "Realm Browserの使い方", "view_count": 8412 }
[ { "body": "SimulatorのデータであればFinderでSimulatorのアプリのDocumentsフォルダを開いてdefault.realmファイルをダブルクリックすればRealm\nBrowserで開けます。[SimPholders2](http://simpholders.com/)を使うと簡単に開けます。\n\n実機であれば[iExplorer](http://www.macroplant.com/iexplorer/)(有料)やFuse for\nOSX(ちょっと面倒)等を利用して実機をマウントしてアプリのDocumentsディレクトリのdefault.realmファイルを開けばいいはずです。(試してませんが…)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T05:01:16.783", "id": "8595", "last_activity_date": "2015-03-31T05:01:16.783", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "238", "parent_id": "8592", "post_type": "answer", "score": 2 }, { "body": "## シミュレータの場合\n\nシミュレータの場合、Realmのファイルは\n\n```\n\n /Users/<username>/Library/Developer/CoreSimulator/Devices/<simulator-uuid>/data/Containers/Data/Application/<application-uuid>/Documents/default.realm\n \n```\n\nのような場所に保存されます。\n\n### SimPholders2を使う\n\nこの場所を探すのは大変なので、 r.izumita さんが書かれているように[SimPholders2](http://simpholders.com\n\"SimPholders\")などのシミュレータのDocumentディレクトリを簡単に探してくれるソフトウェアを利用すると便利です。\n\n[SimPholders2](http://simpholders.com\n\"SimPholders\")を利用した場合、次のようにしてRealmのファイルを開くことができます。\n\n[SimPholders2](http://simpholders.com \"SimPholders\")を起動するとメニューバーにアイコンが表示されます。 \nメニューをクリックすると、シミュレータにインストールされたアプリの一覧が表示されるので、選択すると、そのアプリのDocumentディレクトリが表示されます。\n\nRealmを使ってデータを保存した場合、普通はそこに`.realm`という拡張子のファイルがあると思いますので、それをRealm\nBrowserにドラッグ&ドロップします。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/JExSs.png)\n\n### コマンドラインから\n\n```\n\n println(realm.path)\n \n```\n\nなどとしてRealmファイルの場所をデバッグコンソールに出力して、出力されたパスをコピーして、コマンドラインから、\n\n```\n\n open /Users/katsumi/Library/Developer/CoreSimulator/Devices/.../Documents/default.realm\n \n```\n\nとすると自動的にそのファイルをRealm Browserで開くことができます。\n\n## デバイスの場合\n\nXcodeからインストールしたアプリケーションの場合は、デバイスを接続して、Xcodeのメニューから`Window>Devices`と選択するとデバイスの一覧ウインドウが開きます。\n\nアプリがインストールされているデバイスを選択すると、Xcodeからインストールしたアプリの一覧が表示されますので、ファイルを見たいアプリを選択して、`歯車のボタン>Download\nContainer...`を選択すると、アプリのデータがダウンロードされます。\n\nダウンロードされたデータは`<バンドルID>\n<タイムスタンプ>.xcappdata`のようなパッケージ形式になっていますので、選択して右クリックから、`パッケージの内容を表示`を選択すると、中身が表示されます。 \n普通はDocumentディレクトリに`.realm`という拡張子のファイルがあると思いますので、それをRealm Browserにドラッグ&ドロップします。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/QXaY0.png)\n\n![画像の説明をここに入力](https://i.stack.imgur.com/weAfK.png)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T08:20:34.407", "id": "8604", "last_activity_date": "2015-03-31T13:34:01.870", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "5519", "parent_id": "8592", "post_type": "answer", "score": 6 } ]
8592
8604
8604
{ "accepted_answer_id": "8640", "answer_count": 2, "body": "WEBページを制作しておりまして、feedlyのリンクを設置しようと思いました。 \nfeedlyで取得したURLをアンカータグに設置したのですが、URLを正しく読み込んでくれません。\n\nHTMLタグは\n\n`<a class=\"RSS\"\nhref=\"https://feedly.com/i/subscription/feed/http://hogehoge.com/?feed=rss2\">hoge</a>`\n\nといったURLですが \n`https://feedly.com/i/subscription/feed//?feed=rss2` \nといった感じで、`http://hogehoge.com`の部分が省略されてしまいます。 \n消えてしまうURLの部分をechoで出力しても結果は変わりませんでした。 \nそもそもが無理な話なのでしょうか?\n\n## 原因の自己解決と追加の質問\n\n原因がわかりました。 \nドメインを表示させない処理を行っておりました。 \nこの処理はできれば残しておきたいのですが……。 \nこの処理を残したまま、フィード用のリンクのみドメインを出力させる方法はございますか?\n\n```\n\n <?php\n class relative_URI {\n function relative_URI() {\n add_action('get_header', array(&$this, 'get_header'), 1);\n add_action('wp_footer', array(&$this, 'wp_footer'), 99999);\n }\n function replace_relative_URI($content) {\n $home_url = trailingslashit(get_home_url('/'));\n return str_replace($home_url, '/', $content);\n }\n function get_header(){\n ob_start(array(&$this, 'replace_relative_URI'));\n }\n function wp_footer(){\n ob_end_flush();\n }\n }\n new relative_URI();\n ?>\n \n```\n\n上記がドメインを表示させない処理となっております。", "comment_count": 7, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T05:01:11.567", "favorite_count": 0, "id": "8594", "last_activity_date": "2015-04-01T05:12:23.563", "last_edit_date": "2015-03-31T15:26:53.930", "last_editor_user_id": "7887", "owner_user_id": "7887", "post_type": "question", "score": 0, "tags": [ "php", "html", "wordpress" ], "title": "ドメイン文字列を、add_filterで削除しているが特定のAタグの中身だけ残したい。", "view_count": 426 }
[ { "body": "`delete_host_from_attachment_url`を以下のように変えてみて試してみて下さい。 \nおそらくこれでいけるかと思いますが、すみません自信ありません。\n\n```\n\n function delete_host_from_attachment_url($url) {\n $regixFeedly = '/^(http(s)?:\\/\\/feedly.*?)\\/(http.+)$/';\n $regex = '/^http(s)?:\\/\\/[^\\/\\s]+(.*)$/';\n if (preg_match($regixFeedly, $url, $m)) {\n // http(s)://feedlyから始まるときに\n // httpが含まれていれば次のhttp以降の文字列をURLエンコードする\n $url = $m[1].'/'.urlencode($m[3]);\n } elseif (preg_match($regex, $url, $m)) {\n $url = $m[2];\n }\n return $url;\n }\n \n```\n\n```\n\n // https://feedlyから始まる場合\n $url = 'https://feedly.co.jp/i/subscription/feed/http://hogehoge.com/?feed=rss2';\n echo delete_host_from_attachment_url($url);\n // 結果\n https://feedly.co.jp/i/subscription/feed/http%3A%2F%2Fhogehoge.com%2F%3Ffeed%3Drss2\n \n```\n\n```\n\n // https://feedlyから始まる場合2\n $url = 'https://feedly.co.jp/i/subscription/feed/abc.png';\n echo delete_host_from_attachment_url($url);\n // 結果\n /i/subscription/feed/abc.png\n \n```\n\n```\n\n // http://fugafugaから始まる場合\n $url = 'https://fugafuga.co.jp/i/subscription/feed/http%3A%2F%2Fhogehoge.com%2F%3Ffeed%3Drss2';\n echo delete_host_from_attachment_url($url);\n // 結果\n /i/subscription/feed/http://hogehoge.com/?feed=rss2\n \n```\n\n```\n\n // http://fugafugaから始まる場合2\n $url = 'https://fugafuga.co.jp/i/subscription/feed/abc.png';\n echo delete_host_from_attachment_url($url);\n // 結果\n /i/subscription/feed/abc.png\n \n```", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T13:05:29.953", "id": "8616", "last_activity_date": "2015-03-31T14:07:57.693", "last_edit_date": "2015-03-31T14:07:57.693", "last_editor_user_id": "8963", "owner_user_id": "8963", "parent_id": "8594", "post_type": "answer", "score": 0 }, { "body": "[WordPress で URL をすべて相対 URL にする方法 |\ndogmap.jp](http://dogmap.jp/2011/03/18/wordpress-relative-url/)\n\n「get_header~wp_footerの間に出力された文字列に含まれる、サイトのホームURLを全て除去する」みたいなことになるので、確かに今回の問題が起きると思います。なかなか豪快な処理ですね・・・。\n\n本文にベタ書きされたものは処理しなくていいのなら、 `=\"http://...` だけ置換するようにすれば、URLの先頭だけを消せます。\n\n```\n\n // 略\n \n function replace_relative_URI($content) {\n $home_url = trailingslashit(get_home_url('/'));\n return str_replace('=\"'.$home_url, '=\"/', $content);\n }\n \n // 略\n \n```\n\n実行例 <http://melpon.org/wandbox/permlink/2xDBQR3qnPIhUi7i>\n\n* * *\n\n恐らく上の方法で問題ないと思いますが、他の方法も参考までに載せておきます。\n\n正規表現の[戻り読み言明](http://php.net/manual/ja/regexp.reference.assertions.php)で、スラッシュが前についてる時は消さないようにする方法。\n\n```\n\n function replace_relative_URI($content) {\n $home_url = trailingslashit(get_home_url('/'));\n $home_url_pattern = preg_quote($home_url, '#');\n return preg_replace('#(?<!/)'.$home_url_pattern.'#u', '/', $content);\n }\n \n```\n\n実行例 <http://melpon.org/wandbox/permlink/7GGPiLwV6qx5bOpv>\n\nスラッシュに続くホームURLをURLエンコードする方法。ホームURL以降のスラッシュはエンコードされないのが微妙です(Feedlyでは動きます)。\n\n```\n\n function replace_relative_URI($content) {\n $home_url = trailingslashit(get_home_url('/'));\n $escaped_content = str_replace('/'.$home_url, '/'.urlencode($home_url), $content);\n return str_replace($home_url, '/', $escaped_content);\n }\n \n```\n\n実行例 <http://melpon.org/wandbox/permlink/PgZDbsogi1BnO2BN>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T05:12:23.563", "id": "8640", "last_activity_date": "2015-04-01T05:12:23.563", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "8594", "post_type": "answer", "score": 1 } ]
8594
8640
8640
{ "accepted_answer_id": null, "answer_count": 4, "body": "今、`C++`のマクロを自力で展開しようとしています。 \nそこで、\"#define\" を見つけたのですが、このようになっていました。\n\n```\n\n #ifndef OuHolder_h\n #define OuHolder_h\n \n```\n\nこのような\"`#define`\"は「`OuHolder_h`が定義されている」ということを表すようなのですが、 \nこれをどう展開すればよいか分かりません。 \nどうすればいいでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T06:27:52.283", "favorite_count": 0, "id": "8596", "last_activity_date": "2015-04-05T14:32:00.750", "last_edit_date": "2015-04-01T03:55:48.410", "last_editor_user_id": "49", "owner_user_id": "8224", "post_type": "question", "score": -3, "tags": [ "c++", "preprocessor" ], "title": "#define に関して", "view_count": 577 }
[ { "body": "言い換えるなら `#ifndef` はその定義がまだ定義されていなければ、という意味です。\n\nそのため、定義されていなければ定義する、ということになります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T06:51:13.593", "id": "8598", "last_activity_date": "2015-03-31T06:51:13.593", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7926", "parent_id": "8596", "post_type": "answer", "score": 1 }, { "body": "何をされようとしているのかは分かりませんが、以下は俗にインクルードガードと呼ばれるものです。説明には書かれていませんが、そのファイルの末尾に『endif』も居るはずです。\n\n```\n\n #ifndef OuHolder_h\n #define OuHolder_h\n // 省略\n #endif\n \n```\n\nまず、『ifdef』と『ifndef』は違いますので、ご注意を...\n\n『ifndef』から『endif』内は『OuHolder_h』が定義されていなかった場合にのみ実行されます。 \nなので、2行目の『define』で『OuHolder_h』が定義されると、『ifndef』から『endif』内は実行されません。\n\nこれは、同じheader fileを複数ファイルから読んでいる場合に、何度も同じheader fileを読み込まないようにするためのものです。\n\nまずは、簡単なことから理解して徐々にやりたいことを試して行くことをオススメします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T07:04:46.967", "id": "8599", "last_activity_date": "2015-03-31T07:24:26.797", "last_edit_date": "2015-03-31T07:24:26.797", "last_editor_user_id": "2383", "owner_user_id": "2383", "parent_id": "8596", "post_type": "answer", "score": 4 }, { "body": "もし、自力展開が目的なのではなく、プリプロセス完了後のソースを見たいというだけなら、コンパイラがそのオプションを持っていることがありますので、それを使うという手があります。 \n例えば、VC++ (コマンド名: `cl`) なら `/E` 、`g++` や `clang++` では `-E`\nで、プリプロセス結果を出力することができます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T16:18:49.777", "id": "8623", "last_activity_date": "2015-03-31T16:18:49.777", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7831", "parent_id": "8596", "post_type": "answer", "score": 1 }, { "body": "基礎的なところを書くと\n\n```\n\n #ifndef OuHolder_h // もしここまででOuHolder_hというものが定義されて「いないなら」#endifまでのソースコードを有効にする.\n #define OuHolder_h // OuHolder_hというマクロを定義する。この行以降OuHolder_hと書かれればこのマクロのこと\n \n #endif\n \n```\n\nということとなる。なので\n\n```\n\n #include <iostream>\n \n #define Macro1\n #ifndef Macro1\n // #ifndefの前でMacro1が#defineされているから、ここはプリプロセスもコンパイルもされない.\n #define SUM( x, y ) (x + y)\n void print_hello(){ std::cout << \"Hello, World!\" << std::endl; }\n #endif\n \n int main(){\n int x = SUM( 1, 2 ); // SUMは定義されていない。コンパイルエラー.\n print_hello(); // print_helloも同様に定義されていtない。エラー.\n }\n \n```\n\nであればコメントの通りコンパイルエラーとなり\n\n```\n\n #include <iostream>\n \n #ifndef Macro2\n // #ifndefの前で#define Macro2が書かれていないから、プリプロセスもコンパイルも行われる.\n #define SUM( x, y ) (x + y)\n void print_hello(){ std::cout << \"Hello, World!\" << std::endl; }\n #endif\n \n int main(){\n int x = SUM( 1, 2 ); // 通る.\n print_hello(); // これも通る。Hello, World!とコンソールに出力される.\n }\n \n```\n\nこちらは通るということになる。\n\nちなみに`#define\nOuHolder_h`という定義以降からは`OuHolder_h`という識別子がソースコードに記述されている個所は全部``に置き換えるような形で展開する。実際には一切の空白も入れないだろうが。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-05T14:32:00.750", "id": "8797", "last_activity_date": "2015-04-05T14:32:00.750", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8675", "parent_id": "8596", "post_type": "answer", "score": 1 } ]
8596
null
8599
{ "accepted_answer_id": null, "answer_count": 1, "body": "Rails 3.2.13 + MySQL 5 を使っています。\n\nMySQL の Collation が collate utf8_unicode_ci となっています。 \nこの機能の存在自体知らなくて全角カタカナのデータに対し全角平仮名で検索マッチしたのでびっくりしました。\n\nで、とあるお客様のデータは **半角カタカナ** で登録されていました。(不吉な匂い!?) \nそれでもいい感じで検索してくれるのですが、なぜか「スズキ」や「すずき」がマッチしないことが判明しました。\n\n```\n\n > User.where(\"kana LIKE '%スズキ%'\").count\n (4.1ms) SELECT COUNT(*) FROM `users` WHERE (kana LIKE '%スズキ%')\n => 42\n > User.where(\"kana LIKE '%すずき%'\").count\n (2.6ms) SELECT COUNT(*) FROM `users` WHERE (kana LIKE '%すずき%')\n => 0\n > User.where(\"kana LIKE '%スズキ%'\").count\n (2.6ms) SELECT COUNT(*) FROM `users` WHERE (kana LIKE '%スズキ%')\n => 0\n \n > pp User.where(\"kana LIKE '%スズキ%'\").limit(10).map{|x| x.kana.sub(/...$/, 'xxx')}\n User Load (1.1ms) SELECT `users`.* FROM `users` WHERE (kana LIKE '%スズキ%') LIMIT 10\n [\"スズキ xxx\",\n \"スズキxxx\",\n \"スズキタケxxx\",\n \"スズキxxx\",\n \"スズキノxxx\",\n \"スズキリュxxx\",\n \"スズキxxx\",\n \"スズxxx\",\n \"スズキ タxxx\",\n \"スズキ xxx\"]\n \n```\n\nこれは何故でしょうか?ご教示頂ければ幸いです。\n\nちなみに「フクダ/ふくだ」はマッチします...\n\n```\n\n User.where(\"kana LIKE '%フクダ%'\").count # => 9\n User.where(\"kana LIKE '%ふくだ%'\").count # => 9\n User.where(\"kana LIKE '%フクダ%'\").count # => 9\n \n```\n\nググると最近の記事、[「utf8_unicode_ci\nに対する日本の開発者の見解」](http://blog.kamipo.net/entry/2015/03/08/145045)が気になってます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T07:22:30.297", "favorite_count": 0, "id": "8600", "last_activity_date": "2015-04-02T07:33:47.113", "last_edit_date": "2015-04-02T07:33:47.113", "last_editor_user_id": "7208", "owner_user_id": "7208", "post_type": "question", "score": 4, "tags": [ "ruby-on-rails", "mysql", "rails-activerecord" ], "title": "MySQL の collate utf8_unicode_ci で「スズキ」がマッチしない", "view_count": 5996 }
[ { "body": "半角カナの「ズ」は「ス」と「゙」の2文字なので「ズ」にはマッチしないのではないかと思います。\n\n「フクダ」は「フクダ」が「フクタ」にマッチし、後ろの「゙」はワイルドカードの「%」にマッチしているのだと思います。\n\nなお、LIKE ではなく = だと「スズキ」と「スズキ」はマッチします。 \nLIKE は1文字ずつマッチングを行いますが、= は正規化してマッチングするためのようです。\n\n<http://mysql.gr.jp/mysqlml/mysql/msg/15636> が参考になるかも知れません。 \n(半角カナが全角に変換されてしまってるのでちょっとわかりにくいですが、心の目で読んでください)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T08:54:22.237", "id": "8608", "last_activity_date": "2015-03-31T09:06:25.777", "last_edit_date": "2015-03-31T09:06:25.777", "last_editor_user_id": "3249", "owner_user_id": "3249", "parent_id": "8600", "post_type": "answer", "score": 4 } ]
8600
null
8608
{ "accepted_answer_id": "8644", "answer_count": 1, "body": "<https://github.com/monsat/Ogp>\n\nを使っているのですが、\n\n/View/Helper/OgpHelper.php \nを編集して \n`fb:admins`、`fb:app_id`、`article:publisher`を設定したいのですがどのようにすれば良いのかいまいち分かりません。\n\nどなたかtipを頂けると幸いです。 \n宜しくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T08:29:48.170", "favorite_count": 0, "id": "8605", "last_activity_date": "2015-04-01T07:28:40.857", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8500", "post_type": "question", "score": 1, "tags": [ "cakephp" ], "title": "facebookOGPをCakePHPで使う際に他のprefixも使いたい", "view_count": 117 }
[ { "body": "こんにちは。 \nプラグインを作成した者です。 \nと言っても、こちら、PullRequestをいただき実装した機能であり、かつ、最近触ってないので、TestCaseを見て回答します。\n\n<https://github.com/monsat/Ogp/blob/master/Test/Case/View/Helper/OgpHelperTest.php#L135>\n\nにある通り\n\n```\n\n $this->Ogp->set('ipp_id', '1234567890', array('prefix' => 'fb:'));\n \n```\n\nとすると\n\n```\n\n <meta property=\"fb:ipp_id\" content=\"1234567890\" />\n \n```\n\nこのように表示されます。\n\nいかがでしょうか?", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T07:28:40.857", "id": "8644", "last_activity_date": "2015-04-01T07:28:40.857", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9105", "parent_id": "8605", "post_type": "answer", "score": 1 } ]
8605
8644
8644
{ "accepted_answer_id": null, "answer_count": 1, "body": "キーボードの上に表示されているDoneなどが書かれているツールバーを非表示にするにはios/confing.xml に`<preference\nname=\"HideKeyboardFormAccessoryBar\" value=\"true\"/>` \nを追加すればいいとあったのでやってみたのですが、うまく行きません。どうすればいいでしょうか", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T08:30:27.237", "favorite_count": 0, "id": "8606", "last_activity_date": "2015-08-31T20:28:41.783", "last_edit_date": "2015-03-31T09:53:40.493", "last_editor_user_id": "8748", "owner_user_id": "8748", "post_type": "question", "score": 3, "tags": [ "monaca" ], "title": "キーボードの上に表示されているツールバーを非表示にするには、", "view_count": 778 }
[ { "body": "自分も使ってみたのですが、CordovaのバグでiOSではうまく動かないようです。 \nこっちに乗り換えたという人が多いみたいです。MonacaでもGoldプラン以上だと組み込めると思います。\n\n<https://github.com/driftyco/ionic-plugins-keyboard>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T09:09:59.820", "id": "8724", "last_activity_date": "2015-04-03T09:09:59.820", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7871", "parent_id": "8606", "post_type": "answer", "score": -1 } ]
8606
null
8724
{ "accepted_answer_id": null, "answer_count": 0, "body": "mobileのsafariにて、画面を表示した段階でfocusをあてて入力可能な状態にしたいのですが \nfocusが上手く動作しません。 \n(focusがあたってはいるのかもしれませんが、キーボードが表示されない状態です)\n\niOSのsafariの場合、clickなどのイベントにbindしたらfocusが効くようになるとの記事等は見つけたのですが、click自体しないでfocusを当てておきたいため、上手くいっておりません。 \nHTML\n\n```\n\n <form id=\"sample\">\n <input type=\"text\" id=\"text\" />\n <input id=\"bind\" type=\"button\" value=\"バインドさせるボタン\" />\n </form>\n \n```\n\nJavaScript\n\n```\n\n $(document).on('pageshow', '#sample', function() {\n var onClickHandler = function () {\n $('#text').focus();\n }\n $('#bind').on('click', onClickHandler);\n /* #bindをクリックすると#textにfocusはあいますが、\n * setTimeout('$(\"#bind\").click()', 1000);\n * のように操作してもキーボードが表示されない状態です\n */\n });\n \n```\n\nどなたか方法をご存知のかたはいらっしゃいますでしょうか。 \nよろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-03-31T08:43:42.047", "favorite_count": 0, "id": "8607", "last_activity_date": "2019-09-10T19:08:58.990", "last_edit_date": "2019-09-10T19:08:58.990", "last_editor_user_id": "32986", "owner_user_id": "7809", "post_type": "question", "score": 3, "tags": [ "jquery", "safari" ], "title": "mobileのsafariでページを表示した段階でfocusをあてたい(入力可能な状態にしたい)", "view_count": 1478 }
[]
8607
null
null
{ "accepted_answer_id": "8626", "answer_count": 1, "body": "Wordpressのテーマ開発環境は、VCCWとDockerのどちらがオススメでしょうか? \nそれぞれの利点・欠点、用途による使い分けなど、お聞かせ頂ければ幸いです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T10:52:48.770", "favorite_count": 0, "id": "8610", "last_activity_date": "2015-03-31T22:37:21.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9092", "post_type": "question", "score": 2, "tags": [ "vagrant", "wordpress", "docker" ], "title": "Wordpress開発環境 - VCCW vs Docker?", "view_count": 1494 }
[ { "body": "Docker ベースの WordPress 開発環境 [Wocker](http://wckr.github.io/) の作者です。そして VCCW\nのコントリビューターの一人でもあります。\n\nまず、VCCW について。\n\n# VCCW の利点\n\n * **豊富な初期設定オプション** \nWordPress のバージョン、言語、プラグイン、テーマ、サブディレクトリへのインストールなどを予め指定した状態で環境を構築することができます。\n\n * **テストツール** \nPHPUnit というテストツールを利用することができます。 \nまた、テーマテスト、プラグインテストも、初期設定のオプションが用意されていたり、テスト用のプラグインを予めインストールするよう設定することができます。\n\n * WordMove \n本番を開発環境に同期させることができるデプロイツール WordMove を利用できます。\n\n# VCCW の欠点\n\n * **プロビジョニング** \nこれはどうしようもないことではありますが、やはりプロビジョニングに多少は時間がかかります。マシンスペックにもよりますが、おそらく5分ほどはかかるでしょう。\n\n * **複数バーチャルマシン** \nVCCW\nで複数サイトを管理しようとすると、おそらく複数のバーチャルマシンを作ることになります。これはそこまで欠点というほどではありませんが、バーチャルマシンを抱えすぎるのはあまり理想的ではないように思います。\n\n次に、Wocker について。\n\n# Wocker の利点\n\n * **速さ** \nやはりなんといっても新しい環境の立ち上げの速さです。バーチャルマシンを起動した状態であればほぼ3秒で新しい環境が立ち上がります。\n\n * **複数サイトも軽量** \nWocker で複数サイトを管理する場合は、一つのバーチャルマシン上に複数の Docker コンテナを作ることなります。都度 Github から Clone\nしたり、ファイルをコピーしたりする必要もまったくありません。\n\n# Wocker の欠点\n\n * **オプションがほとんどない** \nオプションを用意できないわけではありませんが、しかし、やはりその分プロビジョニングに時間がかかってしまいます。ただ、もし Docker\nに慣れていれば、Wocker のデフォルトイメージや Dockerfile をカスタマイズして、自分のよく使う環境をイメージとして保存して、Wocker\nから利用することができます。\n\n * **複数サイトを同時に立ちあげられない** \n現時点で、Wocker\nで複数サイトを同時に立ちあげることができません。複数サイトを管理している場合、それぞれのコンテナ間をスイッチする必要がありますが、ただ、コンテナの停止/再起動はすべて一瞬で終わります。これについては今後のバージョンで対応するかもしれません。\n\n# 用途\n\n今のところ、Wocker に PHPUnit や WordMove が入っていないので、それらのツールを利用した本格的な開発環境が必要な場合は VCCW\nの方がよいかもしれません。一方、それらが特に必要ない、もしくはとりあえず WordPress で何か試したいなどで、WordPress\n環境を頻繁に作ったり捨てたりする場合、Wocker はおすすめのツールです。MAMP や XAMPP\nの代替になる可能性は十分にあると思いますので、インストールしておいて損はないと思います。\n\n他にも細かいところでいろいろあると思いますが、大まかに言うと大体こんな感じでしょうか。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T22:27:39.647", "id": "8626", "last_activity_date": "2015-03-31T22:37:21.810", "last_edit_date": "2015-03-31T22:37:21.810", "last_editor_user_id": "4730", "owner_user_id": "4730", "parent_id": "8610", "post_type": "answer", "score": 5 } ]
8610
8626
8626
{ "accepted_answer_id": "8613", "answer_count": 1, "body": "AndroidでSQLiteを操作する方法はある程度分かるのですが、サーバー上のデータベースを操作(主に追加)をしたいのですがどうしたらいいのでしょうか。 \nURLで取得などすればいいのでしょうか。 \nMySQLなら出来なくはなさそうだったのですが、SQLiteは見つける事が出来ませんでした。 \nご教授願います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T11:57:51.393", "favorite_count": 0, "id": "8611", "last_activity_date": "2015-03-31T12:41:26.490", "last_edit_date": "2015-03-31T12:41:26.490", "last_editor_user_id": "3639", "owner_user_id": "9093", "post_type": "question", "score": 2, "tags": [ "android", "java", "sqlite" ], "title": "Androidでインターネット(サーバー上)のSQLiteデータベースの操作について", "view_count": 1960 }
[ { "body": "MySQLなどはクライアントからネットワークなりを通してサーバーに接続するモデルなので、アプリケーションからネットワーク越しにDBに接続することができます。\n\nしかしSQLiteの場合、アプリケーションに組み込まれたSQLiteライブラリが直接データベースファイルを操作しますから、サーバーという概念がなく、ネットワーク越しに接続するということもできません。\n\nですから、サーバー上のSQLiteデータベースに対して操作がしたいとなると、サーバー側に「SQLiteを操作するプログラム(API)」を自分で用意する必要があります。\n\n「任意のSQLを受け取って実行し、結果をJSONで返す」といった形もありですが、実際には「○○を保存するAPI」「××を取得するAPI」といった形にして、SQLを隠ぺいしたり、データの前処理・後処理もサーバー側でやることが多いかと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T12:40:09.317", "id": "8613", "last_activity_date": "2015-03-31T12:40:09.317", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "8611", "post_type": "answer", "score": 3 } ]
8611
8613
8613
{ "accepted_answer_id": null, "answer_count": 1, "body": "現在、angularJSとonsenUIを用いて、開発中です。\n\nonsenUIのons-lazy-repeatを使ってみたのですが、上手く動きません。 \nmaincontrollerに適当なメソッドを追加してよぶことはできているので、コントローラーとの接続ミスではないと思うのですが、色々いじっても動かず途方にくれています。\n\nどこが問題なのか指摘していただけるとありがたいです。\n\nindex.html\n\n```\n\n <!DOCTYPE HTML>\n <html ng-app=\"myApp\">\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 <script src=\"components/loader.js\"></script>\n <script src=\"https://www.google.com/jsapi\"></script>\n <script src=\"js/xdate.js\"></script>\n <script src=\"js/maincontroller.js\"></script>\n <script src=\"js/dataservice.js\"></script>\n \n \n \n \n <link rel=\"stylesheet\" href=\"components/loader.css\">\n <link rel=\"stylesheet\" href=\"css/style.css\">\n <link rel=\"stylesheet\" href=\"css/accodinon.css\">\n \n <script>\n \n \n var app=angular.module('myApp', ['onsen','mainControllers']);\n \n \n \n \n \n </script>\n </head>\n <body>\n \n <ons-navigator page=\"lazy_list_page.html\">\n \n \n </ons-navigator> \n </body>\n </html>\n \n```\n\nmaincontroller.js\n\n```\n\n var mainControllers=angular.module('mainControllers',[]);\n \n //メインコントローラー \n mainControllers.controller('MainController',['$scope','DataService',\n function($scope,DataService){\n \n \n \n $scope.MyDelegate = {\n countItems: function() {\n // Return number of items.\n return 1000000;\n },\n \n calculateItemHeight: function(index) {\n // Return the height of an item in pixels.\n return 45;\n },\n \n configureItemScope: function(index, itemScope) {\n // Initialize scope\n itemScope.item = 'Item #' + (index + 1);\n itemScope.hoge = 'Hoge #' + (index + 1);\n },\n \n destroyItemScope: function(index, itemScope) {\n // Optional method that is called when an item is unloaded.\n console.log('Destroyed item with index: ' + index);\n }\n };\n }\n }]);\n \n```\n\nlazy_list_page.html\n\n```\n\n <ons-list ng-controller=\"MainController\">\n <ons-list-item ons-lazy-repeat=\"MyDelegate\"`>\n {{ item }}\n {{ hoge }}\n </ons-list-item>\n </ons-list>\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T12:00:21.700", "favorite_count": 0, "id": "8612", "last_activity_date": "2015-08-31T15:27:07.130", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9094", "post_type": "question", "score": 2, "tags": [ "monaca", "onsen-ui", "angularjs" ], "title": "ons-lazy-repeatがうまく動きません。", "view_count": 1625 }
[ { "body": "こちらのソースコードで正常に動作することを確認しました。ng-\nappディレクティブを使ってモジュール初期化を行われているようですが、user7461さんも仰っているように、まずはons.bootstrap()を使ったサンプルをカスタマイズしていった方が良いかなと思います。\n\nindex.html \n \n\n```\n\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 <script src=\"components/loader.js\"></script>\n <link rel=\"stylesheet\" href=\"components/loader.css\">\n <link rel=\"stylesheet\" href=\"css/style.css\">\n <script>\n ons.bootstrap()\n \n .controller('MyController', function($scope) {\n $scope.MyDelegate = {\n countItems: function() {\n // Return number of items.\n return 1000000;\n },\n \n calculateItemHeight: function(index) {\n // Return the height of an item in pixels.\n return 45;\n },\n \n configureItemScope: function(index, itemScope) {\n // Initialize scope\n itemScope.item = 'Item #' + (index + 1);\n },\n \n destroyItemScope: function(index, itemScope) {\n // Optional method that is called when an item is unloaded.\n console.log('Destroyed item with index: ' + index);\n }\n };\n });\n </script>\n </head>\n <body>\n <ons-navigator var=\"myNavigator\" page=\"page1.html\">\n </ons-navigator>\n </body>\n </html>\n \n```\n\npage1.html\n\n```\n\n <ons-page>\n <ons-toolbar>\n <div class=\"center\">Navigator</div>\n </ons-toolbar>\n \n <ons-list ng-controller=\"MyController\">\n <ons-list-item ons-lazy-repeat=\"MyDelegate\"`>\n {{ item }}\n </ons-list-item>\n </ons-list>\n \n </ons-page>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T09:55:55.370", "id": "8729", "last_activity_date": "2015-04-03T09:55:55.370", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7871", "parent_id": "8612", "post_type": "answer", "score": 1 } ]
8612
null
8729
{ "accepted_answer_id": null, "answer_count": 0, "body": "Chefのレシピ内で`active_support`が使いたかったので\n\n```\n\n require 'active_support'\n require 'active_support/core_ext'\n \n```\n\nと `site-cookbooks/mycookbook/recipes/default.rb` の初めに記述して \n正常に読み込みが行われてるのを確認したのですが本当にこの方法であってるかどうかの自信がありません。\n\nこの方法であっているのでしょうか? もっと適切な方法があればご教示ください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T13:06:37.520", "favorite_count": 0, "id": "8617", "last_activity_date": "2015-03-31T13:06:37.520", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3271", "post_type": "question", "score": 1, "tags": [ "chef" ], "title": "chefのレシピ内で外部ライブラリが使いたい時の呼び出し場所", "view_count": 98 }
[]
8617
null
null
{ "accepted_answer_id": "8622", "answer_count": 2, "body": "以下のようにバイナリやライブラリが入る場所が沢山あります。 \nこれらの用途の使い分けを簡単にで構いませんので教えてください。 \nとくに、optがよくわかっていないです。\n\nまた、これらの場所以外にバイナリやライブラリが入る可能性はありますか? \n(自分でprefixのディレクトリを指定した場合は別として)\n\n```\n\n /usr/bin\n /usr/sbin\n /usr/lib\n /usr/include\n /usr/libexec\n \n /usr/local\n /usr/local/bin\n /usr/local/lib\n /usr/local/include\n /usr/local/opt\n \n /opt/local/bin\n /opt/local/lib\n \n```", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-03-31T14:51:41.243", "favorite_count": 0, "id": "8619", "last_activity_date": "2020-08-02T07:57:06.943", "last_edit_date": "2020-08-02T07:57:06.943", "last_editor_user_id": "3060", "owner_user_id": "9072", "post_type": "question", "score": 6, "tags": [ "linux", "filesystems" ], "title": "Linuxのディレクトリ構造について、用途や使い分け方を知りたい", "view_count": 1072 }
[ { "body": "最近のLinuxは [Filesystem Hierarchy Standard\n(wikipediaより)](http://ja.wikipedia.org/wiki/Filesystem_Hierarchy_Standard)\nに則っています。細かく定義されていますので、そちらを参照するのが良いでしょう。\n\n> これらの場所以外にバイナリやライブラリが入る可能性はありますか?\n\nディストリのパッケージマネージャーを使ってる限りは、まず無いと考えてよいでしょう。しかし例外としての可能性までは否定できません。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T15:58:56.967", "id": "8620", "last_activity_date": "2015-03-31T15:58:56.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "208", "parent_id": "8619", "post_type": "answer", "score": 8 }, { "body": "`man hier` 読みましょう。FHSという標準についての解説があります。 \nと言いたいところなのですが、あまり分かりやすいとは言えませんね。 \nまた、現状にそぐわなくなっている部分もあります。\n\n大雑把に以下のように覚えておくとよいかと。\n\n**~/bin/** : 実行ファイルが入る。 \n**~/lib/** : ライブラリが入る。 \n**~/libexec/** :\n他のプログラムから間接的に実行され、直接実行されることはない実行ファイルが入る。ただし、`~/share/サブディレクトリ/`\nに入ったり、`~/lib/サブディレクトリ/` に入ったりする例も多く、出番は少なめ。 \n**~/include/** : ~ を使った開発を行うためのヘッダー群が入る。\n\n**/usr/~** \n大抵のディストリビューションにおいて、システムの起動や最低限の運用に必要なものを除く大部分のプログラム・ライブラリが収められる。 \nただし、設定ファイルについては `/usr/etc` ではなく `/etc/` になっている場合が多し。 \nという解説で十分だったが、近年では、起動に必要な udev や systemd も `/usr/`\n以下を使い出しているため、上記の「システムの起動や最低限の運用に必要なものを除く」という注釈も外れつつある。 \n`/` 直下との棲み分けはどうなるんだか。\n\n**/usr/local/~** \nこちらは野良ビルドしたプログラム・ライブラリが置かれることが多い。 \nautotools を使って、デフォルトのままビルドすると大抵こちらに入る。\n\n**/usr/locl/opt** \n**/opt/local** \nこれらはあまり聞きません。ただ、類似例として、プロプラ系や、バイナリ配布のものは、 \n`/opt/ソフト名や開発元名/~` 以下に入れることが多いです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T16:01:00.223", "id": "8622", "last_activity_date": "2015-03-31T16:01:00.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7831", "parent_id": "8619", "post_type": "answer", "score": 6 } ]
8619
8622
8620
{ "accepted_answer_id": "8633", "answer_count": 1, "body": "C++でゲーム開発を行っております。 \nマウスカーソルをウィンドウから出さないためにはどのような処理をすればよろしいでしょうか。\n\n例えば Teeworlds や Steam 内の多数のゲームで実装されています。\n\nゲーム内ではマウスカーソルは別の画像を用いているのでマウスカーソルを消すことは可能です。\n\nマウスカーソルがウィンドウ外に出ている場合 `SetCursorPos` で内に戻す処理を行っても \nやはり 60FPS なので多少出てしまいます。 \nマウスカーソルを消して、常にアクティブ状態にすれば見かけ上可能ですが、 \nその場合は\n\n 1. 現在 `ShowCursor` によりカーソルを非表示にしておりますが、自 window 外でも消去する方法。\n 2. 常にアクティブ状態に保つ方法が分かりません。( `WM_ACTIVATE` 時に `SetForegroundWindow` や 60FPS で`SetForegroundWindow` を行いましたが少しちらつきます)\n\nカーソルを 60FPS\nで画面中央に固定し、各フレーム毎に変位を求め、別でマウスカーソルの位置を処理する方法だとまあまあ上手くいきますが、1フレームで画面外まで移動されるとやはり同じこととなってしまいます。\n\n60FPS が遅いなら別スレッドで処理すれば良いのですが、Windows がマウスを処理するクロックサイクル以下にはできないかと思います。\n\nですので、できれば他の方法で行いたいと考えております。\n\n環境は C++ で行っており、DxLib を使用しておりますが、Window メッセージは処理できる形になっております。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-03-31T15:59:53.733", "favorite_count": 0, "id": "8621", "last_activity_date": "2015-04-01T04:00:00.520", "last_edit_date": "2015-03-31T16:20:43.847", "last_editor_user_id": "7926", "owner_user_id": "9095", "post_type": "question", "score": 2, "tags": [ "c++", "directx", "winapi" ], "title": "ウィンドウ内にマウスカーソルを維持", "view_count": 2527 }
[ { "body": "Win32SDKの関数、[ClipCursor()](https://msdn.microsoft.com/en-\nus/library/windows/desktop/ms648383.aspx)ですかね。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T02:27:45.397", "id": "8633", "last_activity_date": "2015-04-01T04:00:00.520", "last_edit_date": "2020-06-17T08:14:45.997", "last_editor_user_id": "-1", "owner_user_id": "3793", "parent_id": "8621", "post_type": "answer", "score": 2 } ]
8621
8633
8633
{ "accepted_answer_id": null, "answer_count": 1, "body": "スマートフォン用ブラウザの多くはWebページの記事部分のみを抜き出して読み易く表示する「リーダーモード」という機能が備わっています。他にも似たような機能を持つWebサービスとしてReadabilityやInstapaperがあります。\n\nリーダーモードは便利ですが、ページによっては画像が表示されなかったり記事の抽出に失敗したりと、ブラウザの実装やサービスによってレンダリングがまちまちな印象です。\n\nこれらの表示をある程度統一させるためのガイドラインまたは参考資料はあるのでしょうか?\n\n参考までに、IE11のReading Viewに関する資料は見つかりました。\n\n * [Introducing Reading View in IE 11 - MSDN Blogs](https://docs.microsoft.com/en-us/archive/blogs/ie/introducing-reading-view-in-ie-11)\n * [Reading View Guidelines](https://web.archive.org/web/20150428121220/http://ie.microsoft.com:80/testdrive/browser/readingview/)", "comment_count": 0, "content_license": "CC BY-SA 4.0", "creation_date": "2015-03-31T18:01:02.020", "favorite_count": 0, "id": "8625", "last_activity_date": "2021-01-06T00:34:29.880", "last_edit_date": "2021-01-06T00:34:29.880", "last_editor_user_id": "19769", "owner_user_id": "2391", "post_type": "question", "score": 1, "tags": [ "html" ], "title": "リーダーモード用HTMLのガイドライン", "view_count": 898 }
[ { "body": "stackoverflow(英語版)にAndroid Firefox のリーダーモードに関する質問がありました。 \n参考になるかもしれません。 \n[android - How is 'reader mode' in Firefox triggered? - Stack\nOverflow](https://stackoverflow.com/questions/15206695/how-is-reader-mode-in-\nfirefox-triggered)", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T13:27:43.400", "id": "8657", "last_activity_date": "2015-04-01T13:27:43.400", "last_edit_date": "2017-05-23T12:38:55.307", "last_editor_user_id": "-1", "owner_user_id": "5246", "parent_id": "8625", "post_type": "answer", "score": 1 } ]
8625
null
8657
{ "accepted_answer_id": "8629", "answer_count": 1, "body": "**質問** \naddEventListenerで、クリックした要素そのもの(id未指定)を受け取るには、どうすれば良いでしょうか? \n・渡す側で何とかしてループ処理するしかない? \n \n\n**現状** \n・onclick\n\n```\n\n <div id=\"area\">\n <button onclick=\"hoge(this);\">1</button>\n <button onclick=\"hoge(this);\">2</button>\n </div>\n \n <script>\n function hoge(obj) {\n console.log(obj);\n }\n </script>\n \n```\n\n \n \n**やりたいこと** \n・addEventListenerで、クリックした要素(divではなくbutton)を受け取りたい\n\n```\n\n <div id=\"area\">\n <button>1</button>\n <button>2</button>\n </div>\n \n <script>\n function hoge() {\n console.log(this); \n //ここでクリックした要素(divではなくbutton)を受け取りたい\n }\n var el = document.getElementById(\"area\");\n el.addEventListener(\"click\",hoge, false);\n </script>\n \n```\n\n \n \n**その他** \n・buttonタグには、id名class名を付与しない \n・buttonタグは動的生成のため、階層構造は変化する(生成の度に前後にノードを挿入する可能性あり)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T00:17:53.377", "favorite_count": 0, "id": "8628", "last_activity_date": "2015-04-01T00:41:35.450", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7886", "post_type": "question", "score": 1, "tags": [ "javascript" ], "title": "addEventListenerで、クリックした要素そのものを受け取りたい", "view_count": 11667 }
[ { "body": "イベントハンドラで Event\nを受け取るようにすれば、[Event.target](https://developer.mozilla.org/ja/docs/Web/API/Event/target)\nでイベントを発生させた要素を参照できます\n\n```\n\n function hoge(e) {\n console.log(e.target)\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T00:41:35.450", "id": "8629", "last_activity_date": "2015-04-01T00:41:35.450", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5575", "parent_id": "8628", "post_type": "answer", "score": 5 } ]
8628
8629
8629
{ "accepted_answer_id": null, "answer_count": 2, "body": "仕事の合間なので時間がかかってしまいましたが、やっと編集できました! \n現在、こんな感じです。↓\n\n```\n\n $(function(){\r\n var duration=300;\r\n var duration2=500;\r\n \r\n $(\"#pc-page-box1\").on(\"mouseover\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:0.6},\r\n duration);\r\n });\r\n $(\"#pc-page-box1\").on(\"mouseout\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:1},\r\n duration);\r\n });\r\n \r\n $(\"#pc-page-box2\").on(\"mouseover\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:0.6},\r\n duration);\r\n });\r\n $(\"#pc-page-box2\").on(\"mouseout\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:1},\r\n duration);\r\n });\r\n \r\n $(\"#pc-page-box3\").on(\"mouseover\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:0.6},\r\n duration);\r\n });\r\n $(\"#pc-page-box3\").on(\"mouseout\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:1},\r\n duration);\r\n });\r\n \r\n $(\"#pc-page-box4\").on(\"mouseover\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:0.6},\r\n duration);\r\n });\r\n $(\"#pc-page-box4\").on(\"mouseout\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:1},\r\n duration);\r\n });\r\n \r\n $(\"#pc-page-box5\").on(\"mouseover\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:0.6},\r\n duration);\r\n });\r\n $(\"#pc-page-box5\").on(\"mouseout\",function(){\r\n $(this).find(\".black-sheet\").stop(true).animate({\r\n opacity:1},\r\n duration);\r\n });\r\n });\r\n \r\n $(function(){\r\n var duration=300;\r\n $(document).on('click', '.leftBoxParent', function(){\r\n $(this).parent('div').find('.leftBox').stop(true).animate({left:-300}, duration);\r\n $(this).find('.leftBox').stop(true).animate({left:300}, duration);\r\n });\r\n });\r\n \r\n $(function(){\r\n var duration=300;\r\n $(document).on('click', '.rightBoxParent', function(){\r\n $(this).parent('div').find('.rightBox').stop(true).animate({right:-300}, duration);\r\n $(this).find('.rightBox').stop(true).animate({right:300}, duration);\r\n });\r\n });\n```\n\n```\n\n body,td,th {\r\n font-family: \"Noto Sans CJK JP Light\", \"Noto Sans CJK JP Black\", \"Noto Sans CJK JP Bold\", \"Noto Sans CJK JP DemiLight\", \"Noto Sans CJK JP Medium\", \"Noto Sans CJK JP Regular\", \"Noto Sans CJK JP Thin\";\r\n }\r\n h1,h2,h3,h4,h5,h6 {\r\n font-family: \"Noto Sans CJK JP Light\", \"Noto Sans CJK JP Black\", \"Noto Sans CJK JP Bold\", \"Noto Sans CJK JP DemiLight\", \"Noto Sans CJK JP Medium\", \"Noto Sans CJK JP Regular\", \"Noto Sans CJK JP Thin\";\r\n }\r\n .img_box {\r\n position:relative;\r\n display:block;\r\n margin:0;\r\n padding:0;\r\n }\r\n .img_box img {\r\n z-index:0;\r\n margin:0;\r\n padding:0;\r\n }\r\n .img_box a {\r\n color:white;\r\n font-size:70px;\r\n }\r\n \r\n .img_comment2 {\r\n font-size:70px;\r\n font-family: 'Oswald', sans-serif;\r\n font-weight:300;\r\n position:absolute;\r\n bottom:150px;\r\n left:0px;\r\n z-index:1;\r\n text-align:left;\r\n padding:10px;\r\n margin:0;\r\n text-shadow:3px 3px 3px #000;\r\n }\r\n \r\n .pages{\r\n display:block;\r\n float:left;\r\n position:relative;\r\n }\r\n .comments{\r\n font-size:70px;\r\n font-family: 'Oswald', sans-serif;\r\n font-weight:300;\r\n color:white;\r\n position:absolute;\r\n bottom:150px;\r\n left:150px;\r\n z-index:1;\r\n text-align:center;\r\n padding:10px;\r\n margin:0;\r\n text-shadow:3px 3px 3px #000;\r\n }\r\n .japanese-font{\r\n font-family:\"Noto Sans\";\r\n font-size:18px;\r\n font-weight:bold;\r\n color:white;\r\n position:absolute;\r\n bottom:100px;\r\n left:150px;\r\n z-index:1;\r\n text-align:center;\r\n padding:10px;\r\n margin:0;\r\n text-shadow:3px 3px 3px #000;\r\n }\r\n \r\n body{\r\n \r\n }\r\n \r\n /*.gridContainer {\r\n width: 88.5%;\r\n max-width: 1300px;\r\n padding-top:50px;\r\n padding-left: 0.75%;\r\n padding-right: 0.75%;\r\n margin: auto;\r\n clear: none;\r\n float: none;\r\n margin-left: auto;\r\n }*/\r\n \r\n #pc-wrapper{\r\n display:block;\r\n width:1300px;\r\n height:1800px;\r\n margin:0 auto;\r\n }\r\n #pc-wrapper p{\r\n margin:0;\r\n }\r\n #pc-wrapper img{\r\n display:block;\r\n }\r\n #pc-header-box{\r\n display:block;\r\n position:relative;\r\n width:1300px;\r\n height:800px;\r\n margin:0 auto;\r\n vertical-align:bottom;\r\n }\r\n .pc-header-title{\r\n display:inline-block;\r\n position:absolute;\r\n font-size:60px;\r\n }\r\n \r\n #pc-logo-box{\r\n display:block;\r\n position:relative;\r\n width:1300px;\r\n height:200px;\r\n margin:0 auto;\r\n }\r\n #pc-logo-box img{\r\n display:block;\r\n position:relative;\r\n top:50px;\r\n margin:0 auto;\r\n }\r\n \r\n #pc-page-box1{\r\n display:block;\r\n position:relative;\r\n width:650px;\r\n height:430px;\r\n float:left;\r\n overflow:hidden;\r\n }\r\n #pc-page-box2{\r\n display:block;\r\n position:relative;\r\n width:650px;\r\n height:430px;\r\n float:left;\r\n overflow:hidden;\r\n }\r\n \r\n #pc-page-box3{\r\n display:block;\r\n position:relative;\r\n width:650px;\r\n height:430px;\r\n float:left;\r\n overflow:hidden;\r\n }\r\n #pc-page-box4{\r\n display:block;\r\n position:relative;\r\n width:650px;\r\n height:430px;\r\n float:left;\r\n overflow:hidden;\r\n }\r\n #pc-page-box5{\r\n display:block;\r\n position:relative;\r\n width:650px;\r\n height:430px;\r\n float:left;\r\n overflow:hidden;\r\n }\r\n \r\n .black-sheet{\r\n display: block;\r\n position: absolute;\r\n width: 650px;\r\n height: 430px;\r\n background: rgba(0,0,0,0.8);\r\n z-index: 1;\r\n }\r\n .pc-page-title{\r\n display:block;\r\n position:absolute;\r\n font-size:30px;\r\n color:rgba(255,255,255,1);\r\n z-index:2;\r\n }\r\n .pc-page-title-japanese{\r\n display:block;\r\n position:absolute;\r\n top:30px;\r\n font-size:24px;\r\n color:rgba(255,255,255,1);\r\n z-index:3;\r\n }\r\n #we-are-infobox{\r\n display:block;\r\n position:absolute;\r\n left:-300px;\r\n width:300px;\r\n height:300px;\r\n background:rgba(51,153,204,1);\r\n opacity:1;\r\n z-index:5;\r\n }\r\n #info-infobox{\r\n display:block;\r\n float:right;\r\n position:absolute;\r\n right:-300px;\r\n width:300px;\r\n height:300px;\r\n background:rgba(51,153,204,1);\r\n opacity:1;\r\n z-index:5;\r\n }\r\n #price-infobox{\r\n display:block;\r\n position:absolute;\r\n left:-300px;\r\n width:300px;\r\n height:300px;\r\n background:rgba(51,153,204,1);\r\n opacity:1;\r\n z-index:5;\r\n }\r\n #blog-infobox{\r\n display:block;\r\n float:right;\r\n position:absolute;\r\n right:-300px;\r\n width:300px;\r\n height:300px;\r\n background:rgba(51,153,204,1);\r\n opacity:1;\r\n z-index:5;\r\n }\r\n #contact-us-infobox{\r\n display:block;\r\n position:absolute;\r\n left:-300px;\r\n width:300px;\r\n height:300px;\r\n background:rgba(51,153,204,1);\r\n opacity:1;\r\n z-index:5;\r\n }\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script>\r\n <div class=\"gridContainer\">\r\n <div id=\"pc-wrapper\">\r\n <div id=\"pc-header-box\">\r\n <p><div class=\"pc-header-title\">Welcome to our website\"</div>\r\n </p>\r\n </div>\r\n \r\n <div id=\"pc-logo-box\">\r\n </div>\r\n \r\n <div id=\"pc-page-box1\" class=\"leftBoxParent\">\r\n <p>\r\n <div class=\"pc-page-title\">We Are</div><div class=\"pc-page-title-japanese\">私たちについて</div>\r\n <div id=\"we-are-infobox\" class=\"leftBox\"></div>\r\n <div class=\"black-sheet\"></div>\r\n </p>\r\n </div>\r\n \r\n <div id=\"pc-page-box2\" class=\"rightBoxParent\">\r\n <p><div class=\"pc-page-title\" >Info</div>\r\n <div class=\"pc-page-title-japanese\">お知らせ</div>\r\n <div id=\"info-infobox\" class=\"rightBox\"></div>\r\n <div class=\"black-sheet\"></div>\r\n </p>\r\n </div>\r\n \r\n <div id=\"pc-page-box3\" class=\"leftBoxParent\">\r\n <p><div class=\"pc-page-title\">Price</div><div class=\"pc-page-title-japanese\">プライス</div>\r\n <div id=\"price-infobox\" class=\"leftBox\"></div><div class=\"black-sheet\"></div>\r\n </p>\r\n </div>\r\n \r\n <div id=\"pc-page-box4\" class=\"rightBoxParent\">\r\n <p><div class=\"pc-page-title\">Blog</div><div class=\"pc-page-title-japanese\">ブログ</div>\r\n <div id=\"blog-infobox\" class=\"rightBox\"></div>\r\n <div class=\"black-sheet\"></div>\r\n </p>\r\n </div>\r\n \r\n <div id=\"pc-page-box5\" class=\"leftBoxParent\">\r\n <p><div class=\"pc-page-title\">Contact Us</div>\r\n <div class=\"pc-page-title-japanese\">メール</div>\r\n <div id=\"we-are-infobox\" class=\"leftBox\">\r\n </div><div class=\"black-sheet\"></div>\r\n </p>\r\n </div>\r\n </div>\r\n </div><!--end gridContainer-->\n```\n\nまずは状況から説明させていただきます。\n\nモニターの可視領域を作り、その中にボタンを4つ作りました。 \nbtnA B C D という風です。\n\nそれから、モニターの不可視領域にコンテンツABCDを作りました。\n\nイラストαの状況です\n\n![イラストα](https://i.stack.imgur.com/XrMUl.png) \n![イラストβ](https://i.stack.imgur.com/71iEZ.png)\n\n次にそれぞれのbtnにプログラムしたいです。 \n・btnAをクリックしたら、不可視領域にあるAが左から右へスライドしてきて、可視領域の中央に配置される。\n\nイラストβの状況です。\n\nまた、btnA C は「左から右へ」、btnB Dは「右から左へ」動かしたいです。\n\n自分の知識でできる範囲で作ってみました。\n\nif文を使って動かすべきなのかどうか、よくわからず、とにかく動くようにプログラミングしてみました。 \nしかし、右セクションはは右、左セクションは左とセパレートになってしまっていますが、本来は、右が動いていて、もし、左を押したら、右は右に戻って、左は左から出てくるという動きにしたいです。。\n\n教えてください。\n\nお願いいたします", "comment_count": 5, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T01:05:01.920", "favorite_count": 0, "id": "8630", "last_activity_date": "2015-12-08T05:14:15.573", "last_edit_date": "2015-04-03T06:17:40.847", "last_editor_user_id": "8000", "owner_user_id": "7647", "post_type": "question", "score": -2, "tags": [ "javascript", "jquery" ], "title": "jQuery のif文が上手くいきません。(訂正)", "view_count": 702 }
[ { "body": ">btnA C は「左から右へ」、btnB Dは「右から左へ」動かしたいです。 \nbtnではなくコンテンツですか?\n\n>・そのとき、すべてのbtnA B C Dはクリック不可。 \nz-index: 0 ボタンA,B,C,D配置 \nz-index: 1 画面全体に覆いかぶさるようにdiv要素(id=\"cover\"としておきます)を(body直下に)配置 \nz-index: 2 コンテンツA,B,C,Dを配置する\n\ncss: \n{ \nposition: absolute; top: 0px; left: 0px; \nwidth: 100%; height: 100%; \nz-index: 1; \n}\n\nstyle=\"display: none;\"\n\nアニメーションが開始したら表示する \n$(\"#cover\").css(\"display\", \"\");\n\nAをクリックしたら非表示にする \n$(\"#cover\").css(\"display\", \"none\");", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T03:34:02.960", "id": "8635", "last_activity_date": "2015-04-01T03:34:02.960", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9095", "parent_id": "8630", "post_type": "answer", "score": 1 }, { "body": "```\n\n $(function(){\n var duration=300;\n $(document).on('click', '.leftBoxParent', function(){\n $(this).parent('div').find('.leftBox').stop(true).animate({left:-300}, duration);\n $(this).find('.leftBox').stop(true).animate({left:300}, duration);\n $('.rightBoxParent').find('.rightBox').stop(true).animate({right:-300}, duration);\n });\n });\n \n $(function(){\n var duration=300;\n $(document).on('click', '.rightBoxParent', function(){\n $(this).parent('div').find('.rightBox').stop(true).animate({right:-300}, duration);\n $(this).find('.rightBox').stop(true).animate({right:300}, duration);\n $('.leftBoxParent').find('.leftBox').stop(true).animate({left:-300}, duration);\n });\n });\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-12-08T05:14:15.573", "id": "19750", "last_activity_date": "2015-12-08T05:14:15.573", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13291", "parent_id": "8630", "post_type": "answer", "score": 0 } ]
8630
null
8635
{ "accepted_answer_id": "8634", "answer_count": 1, "body": "現在 heroku 上で django を利用したWebアプリケーションを動かしています。 \n本番環境では settings.py 内の DEBUG 変数を False\nとしているのですが、そのせいで管理サイトへアクセスすると400エラーとなってしまいます。 \n(DEBUG=Trueとすればアクセスできます)\n\nデバッグモードで運用するわけにもいきませんし、管理サイトも有効化しておきたいのですが、なにか回避方法はありませんでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T01:36:27.333", "favorite_count": 0, "id": "8632", "last_activity_date": "2015-04-01T02:57:50.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9098", "post_type": "question", "score": 1, "tags": [ "django" ], "title": "django の管理サイトを本番環境でも有効化したい", "view_count": 969 }
[ { "body": "heroku上では、管理サイト以外のページは表示されていますか。 \nもし管理サイト以外のページも表示できていないようならば、`ALLOWED_HOSTS`の設定に問題がある可能性があります。\n\nsettings.py\n\n```\n\n # herokuのURLを追加\n ALLOWED_HOSTS = ['hoge.heroku.com']\n \n```\n\nまた、エラーメッセージがありましたら、そちらも併せて教えていただけると助かります。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T02:57:50.810", "id": "8634", "last_activity_date": "2015-04-01T02:57:50.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9044", "parent_id": "8632", "post_type": "answer", "score": 0 } ]
8632
8634
8634
{ "accepted_answer_id": "8667", "answer_count": 1, "body": "outline-mode にてある heading が sibling の中で末の要素であることを確認したいと考えています。\n\nイメージとしては、 \n(defun last-sibling-heading-p () \n......)\n\nが定義されるイメージなのですが、これはどう実装したらよいでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T04:35:00.597", "favorite_count": 0, "id": "8636", "last_activity_date": "2020-05-16T22:58:34.780", "last_edit_date": "2020-05-16T22:58:34.780", "last_editor_user_id": "19110", "owner_user_id": "754", "post_type": "question", "score": 1, "tags": [ "elisp" ], "title": "outline-mode にてある heading が sibling の中で末の要素であることを確認するには?", "view_count": 88 }
[ { "body": "「outline-mode にてある heading が sibling の中で末の要素であることを確認したい」 \nということだと、\n\n 1. outline-modeのフォーマットのテキストデータをパーズして、その中の「末の要素」だけ抜き出す\n 2. Emacsのoutline-mode 中でをカーソルが、ある heading 上にあって、sibling の中では「末の要素」になっているかを確認する関数を作りたい\n\n等の解釈ができるかと思います。\n\n自分は、2の場合で回答したいと思います。 \nとりあえず、動作としては、\n\n```\n\n (defun last-sibling-heading-p ()\n (save-excursion\n (let ((start (point))\n prev)\n (ignore-errors (outline-forward-same-level 1))\n (setq prev (point))\n (ignore-errors (outline-forward-same-level 1))\n (and (= prev (point))\n (>= start (point))))))\n \n ;; M-x fooでカーソル位置のsiblingが「末の要素」かを確認する\n (defun foo ()\n (interactive)\n (message (if (last-sibling-heading-p) \"last\" \"butlast\")))\n \n```\n\nのようなものを想定されているのでしょうか。 \nこのコマンドの場合\n\n```\n\n * A\n ** a\n ** b\n ** c\n * B\n * C\n \n```\n\nのような場合、cの位置にカーソルがあれば、\"last\"と表示されます。 \nもしこの動作が希望ということであれば、上の実装はいい加減なものですので、 \nemacs-lispに詳しい方がもっと良い実装を教えてくれるかもしれません。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T21:46:24.717", "id": "8667", "last_activity_date": "2015-04-01T21:46:24.717", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3510", "parent_id": "8636", "post_type": "answer", "score": 1 } ]
8636
8667
8667
{ "accepted_answer_id": null, "answer_count": 3, "body": "いくつか参考サイトを探し、 \n<http://qiita.com/yoya_k/items/4bce6201fde9ee3a9561>\n\nこちらを参考にさせていただきながら、なんとか近い形にはできたのですが \n気になったのはそもそも情報が少ないということは、別の方法があるからなのか? \n予想ではもっとこの問題で悩んでいる方がいるかと思っておりましたので意外でした。\n\nime-modeが使えない場合の基本的なやり方が分かればと思います。 \n入力モードが全角になっていても半角の数値のみが入力(即時変換?)可能にしたいです。 \n実現可能であれば、jqueryやangularjs等も利用したいと思っています。 \n何卒どうぞよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T04:39:16.173", "favorite_count": 0, "id": "8637", "last_activity_date": "2015-04-21T15:16:29.097", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6072", "post_type": "question", "score": 1, "tags": [ "javascript", "jquery", "angularjs" ], "title": "chromeのテキストボックスに入力した全角英数字をjavascriptでリアルタイムに半角へ変換したい", "view_count": 3924 }
[ { "body": "リアルタイムで…というのは、IMEの挙動も制御したいということですよね?\n\nその前提で話をしますが。 \n私が思うに、そもそも情報が少ないのは、そのような制御が好ましくないからです。 \n(うろ覚えですがime-modeすら廃止の勧告を受けた記憶があります)\n\n例えばあるユーザーは「郵便番号辞書」を使いたくても入力できなくなります。 \nさらに「あれ?なんで勝手に入力確定しているんだ!?」と大変驚くことでしょう。 \nユーザービリティの観点からすべきではありません。 \n普通に、pattern属性なり$watchなりで入力確定したものを検証すべきです。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T05:10:49.207", "id": "8639", "last_activity_date": "2015-04-01T05:10:49.207", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8335", "parent_id": "8637", "post_type": "answer", "score": 3 }, { "body": "onkeydownでキー種を取得してpreventDefaultすればいいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T20:57:17.580", "id": "8666", "last_activity_date": "2015-04-01T20:57:17.580", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5721", "parent_id": "8637", "post_type": "answer", "score": 0 }, { "body": "参考サイトのやり方ですとFirefoxでは使用できないため \nあまり実用的ではないです。 \n<http://qiita.com/yoya_k/items/4bce6201fde9ee3a9561>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-21T15:16:29.097", "id": "9404", "last_activity_date": "2015-04-21T15:16:29.097", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9301", "parent_id": "8637", "post_type": "answer", "score": 0 } ]
8637
null
8639
{ "accepted_answer_id": null, "answer_count": 0, "body": "SpringBoot 製 の war を JBoss にデプロイしてセッションレプリケーションしたいのですが方法が解らず困っています。\n\n通常、Java のウェブアプリケーションでセッションレプリケーションしたい場合、web.xml に を追記する必要があるかと思います。 \nしかし SpringBoot の場合、web.xml が存在しないため、通常通りに行きません。 \nなにか方法がないか検索してみたのですが、解らずじまいでした。\n\nSpringMVC などの他のフレームワークで作成したアプリケーションでのセッションレプリケーションは出来ることを確認しております。\n\nやりたいことの前提としましては、下記のとおりです。 \n・SpringBoot を使いたい。 \n・アプリケーションサーバは SpringBoot の組み込み Tomcat ではなく、通常の JBoss を使いたい。 \n・JBoss の機能でセッションレプリケーションしたい。 \n他のプロダクト(Hazelcast 等)を使う方法はあまり望んでおりません。\n\nこれが可能かどうか、可能であればその方法が知りたいです。 \n宜しくお願い致します。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T06:33:34.810", "favorite_count": 0, "id": "8642", "last_activity_date": "2015-05-08T06:11:48.183", "last_edit_date": "2015-05-08T06:11:48.183", "last_editor_user_id": "7214", "owner_user_id": "9102", "post_type": "question", "score": 1, "tags": [ "java", "spring" ], "title": "SpringBoot 製 の war を JBoss にデプロイしてセッションレプリケーションしたい", "view_count": 1076 }
[]
8642
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "OCamlYaccやMenhirを使ったりするのですが、コンフリクトが発生した場合の解消はトライアンドエラーでなんとなく消しています。\n\n何かツールの使い方やコツ等ご存知の方いましたら教えてください。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T07:10:53.083", "favorite_count": 0, "id": "8643", "last_activity_date": "2015-04-01T11:04:18.783", "last_edit_date": "2015-04-01T09:04:58.867", "last_editor_user_id": "898", "owner_user_id": "7532", "post_type": "question", "score": 2, "tags": [ "ocaml" ], "title": "OCamlYaccやMenhirでコンフリクトを消す方法", "view_count": 795 }
[ { "body": "YACC の shift/reduce, reduce/reduce conflict\nの解消はパーサーの教科書もしくはネット情報に沢山書かれているます。まず、YACC の基本動作原理とともにそれなりに理解してください。たとえば\n<http://guppy.eng.kagawa-u.ac.jp/2006/ProgLang/bison-1.2.8/bison-ja_8.html>\nなど。\n\nどの教科書にもありますが、だいたい、\n\n * ルールが大雑把過ぎるのが原因であることが多いので、ジェネレータが conflict で迷わないようになるまでルールを書き下す。\n * トークンの優先順位と結合方向を指定することで適用可能なルールの数を減らす\n * reduce/reduce は解消したほうがよい\n * shift/reduce の場合は shift 優先なので、それで満足ならほっておく (ただしあなたの YACC 経験値は上がりません)\n\nことで解消します。どこを直すべきかは、各パーサジェネレータの conflict レポートをよく読む。これしかないと私は思います。\n\n私は一般的なパーサの知識はあまりないので、ここからは OCaml 特定の情報のみを紹介します。\n\n### Menhir を使う\n\nOCaml では、 OCamlYacc は古いのでもう使わない Menhir を使う。 \nそして、 `menhir --explain` を使ってどこに conflict があるかちゃんと理解する、くらいでしょうか。\n\n### Menhir のレポートの読み方\n\n次の例を使って `<basename>.conflicts` の読み方を説明します。 Bison などのドキュメントで出て来る reduce/reduce\nの例に少し足したものです:\n\n```\n\n %token WORD\n %token START\n \n %start <int> statement\n \n %%\n \n statement:\n | START sequence { $2 }\n ;\n \n sequence:\n | /* empty */ { 0 }\n | maybeword { $1 }\n | sequence WORD { $1 + $2 }\n ;\n \n maybeword:\n | /* empty */ { 0 }\n | WORD { 1 }\n ;\n \n %%\n \n```\n\n上のコードを `menhir --explain x.mly` とすると次のような `x.conflicts` ファイルが出来ます。`.conflicts`\nファイルは `** Conflict (...) in state XXX.` というラインから始まる conflict\nの説明の集合からなっています。レポートを読んでいて、 `** Conflict (..)` が出てきた時は別の conflict\nの説明に移っていることに注意すると読み易い:\n\n```\n\n ** Conflict (shift/reduce/reduce) in state 1.\n ** Tokens involved: WORD #\n ** The following explanations concentrate on token WORD.\n ** This state is reached from statement after reading:\n \n START \n \n```\n\nWORD に対する処理回りで conflict が起っています。これは `statement` からはじめて `START`\nを読み込んだ後、発生します。shift/reduce と reduce/reduce が同時に起っているようですね。\n\n```\n\n ** The derivations that appear below have the following common factor:\n ** (The question mark symbol (?) represents the spot where the derivations begin to differ.)\n \n statement \n START sequence \n (?)\n \n```\n\nConflict を起こす複数の解釈は `statement` を `START sequence` だとする所までは共通ですが、そこから先、\n`sequence` をどうするか、の所で発生しています。以下はそれぞれの解釈がどうなっているかの説明です\n\n```\n\n ** In state 1, looking ahead at WORD, reducing production\n ** maybeword -> \n ** is permitted because of the following sub-derivation:\n \n sequence WORD // lookahead token appears\n maybeword // lookahead token is inherited\n . \n \n```\n\n先読みトークン `WORD` がある時、この `WORD` を消費せず、 reduce を行って `sequence` を得ることができます:\n下から読むと、 `(空) -> maybeword -> sequence` という構成法。(さらに先読みトークンの `WORD` を消費すると\n`sequence WORD -> sequence` になりますね。) `.` はパーサが見ているところはここ、というマークです。\n\n```\n\n ** In state 1, looking ahead at WORD, shifting is permitted\n ** because of the following sub-derivation:\n \n maybeword \n . WORD \n \n```\n\n先読みトークン `WORD` がある時に、この `WORD` を shift で消費することで、下から `WORD -> maybeword ->\nsequence` という構成が可能。 `. WORD` は今パーサが居るところが `.` で `WORD` は先読みトークンです。\n\n```\n\n ** In state 1, looking ahead at WORD, reducing production\n ** sequence -> \n ** is permitted because of the following sub-derivation:\n \n sequence WORD // lookahead token appears\n . \n \n```\n\n先読みトークン `WORD` がある時に、この `WORD` を消費せずに reduce して `sequence` が構成できる: 下から `(空) ->\nsequence`。(さらに先読みトークンの `WORD` と併せると `sequence WORD -> sequence` を構成できます。)\n\nさて、conflict の解消はとにかく受理可能セットを(それが正しいと仮定して)そのまま保ったまま、 \nこのように複数のルールの選択可能性をルールを変更したり優先順位を加えたりして狭めていく、 \nということなのですが、とにかくこうしろ、という機械的な方法はないのではないでしょうか。 \n(あればそもそもパーサジェネレータが勝手に解消してくれるはずです。) \nもうこれは conflict レポートをよく読んで原因理由を理解するのが一番かと思います。 \n何かコツがあれば私も知りたいところです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T10:43:10.503", "id": "8652", "last_activity_date": "2015-04-01T11:04:18.783", "last_edit_date": "2015-04-01T11:04:18.783", "last_editor_user_id": "898", "owner_user_id": "898", "parent_id": "8643", "post_type": "answer", "score": 4 } ]
8643
null
8652
{ "accepted_answer_id": "8647", "answer_count": 1, "body": "`TabBarController`から他の画面に画面遷移すると、画面遷移後の`ViewController`に`TabBar`が表示されません。 \nそしてその`ViewController`から元の`TabBarController`のタブページに戻った時も、画面下に`TabBar`が表示されていません。 \n`TabBarController` → `ViewController`\nで`ViewController`に`TabBar`が表示されないのは今回いいとして、 \n`ViewController` → `TabBarController`\nで`TabBarController`のタブページに戻った時に`TabBar`が表示されるようにするにはどうすればいいでしょうか? \nどなたか分かる方がいれば教えていただきたいです。すみませんが、よろしくお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T08:21:14.007", "favorite_count": 0, "id": "8645", "last_activity_date": "2015-04-01T09:05:15.580", "last_edit_date": "2015-04-01T08:43:36.247", "last_editor_user_id": "7362", "owner_user_id": "5210", "post_type": "question", "score": 1, "tags": [ "ios", "swift", "xcode", "uitabbarcontroller" ], "title": "TabBarControllerの画面遷移について", "view_count": 5079 }
[ { "body": "![ナビゲーション図](https://i.stack.imgur.com/wL6pX.png) \nStoryboard上に上図のような構成を作り、赤矢印のようなSegueを張りました。 \nタブ(2)の`ViewController`から、(2)の`ViewController`に遷移すると、タブバーは消えます。しかし、(2)の`ViewController`からタブ(2)の`ViewController`にバックすると、タブバーが表示されます。あなたの構成は、こうなっていないということですね?その差異が、問題の原因を探るカギになると思います。\n\nなお、タブ(2)の`ViewController`から、(2)の`ViewController`に遷移するとき、タブバーが消えないようにするには、タブ(2)の`ViewController`を、`UINavigationController`に置き換えることになると思います。", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T09:05:15.580", "id": "8647", "last_activity_date": "2015-04-01T09:05:15.580", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7362", "parent_id": "8645", "post_type": "answer", "score": 1 } ]
8645
8647
8647
{ "accepted_answer_id": "8658", "answer_count": 1, "body": "![画像の説明をここに入力](https://i.stack.imgur.com/jWegB.png)<https://github.com/t2v/play2-auth/blob/46d2dafa883551afdf3cb87f771195b911816dca/sample/app/jp/t2v/lab/play2/auth/sample/Account.scala>\n\nのコードで、autoConstructが解決されないのですが、どうすればよいですか?\n\nbuild.sbt\n\n```\n\n name := \"\"\"bank\"\"\"\n \n version := \"1.0-SNAPSHOT\"\n \n lazy val root = (project in file(\".\")).enablePlugins(PlayScala)\n \n scalaVersion := \"2.11.6\"\n \n libraryDependencies ++= Seq(\n \"org.scalikejdbc\" %% \"scalikejdbc\" % \"2.2.+\",\n \"com.h2database\" % \"h2\" % \"1.4.+\",\n \"ch.qos.logback\" % \"logback-classic\" % \"1.1.+\",\n \"jp.t2v\" %% \"play2-auth\" % \"0.13.2\",\n \"jp.t2v\" %% \"play2-auth-test\" % \"0.13.2\" % \"test\",\n \"com.github.t3hnar\" %% \"scala-bcrypt\" % \"2.4\"\n )\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T08:37:49.630", "favorite_count": 0, "id": "8646", "last_activity_date": "2015-04-01T22:20:53.200", "last_edit_date": "2015-04-01T22:20:53.200", "last_editor_user_id": "56", "owner_user_id": "8355", "post_type": "question", "score": 0, "tags": [ "scala", "playframework", "scalikejdbc" ], "title": "not found: value autoConstruct", "view_count": 283 }
[ { "body": "`autoConstruct` はマクロで実験的な機能なので、現時点(2.2.5)ではscalikejdbc本体とは別になっています。 \n具体的には \n`\"org.scalikejdbc\" %% \"scalikejdbc-syntax-support-macro\" % \"バージョン\"` \nです。 \nその他、そのサンプルのプロジェクトで加えるべき依存は、このあたり\n\n<https://github.com/t2v/play2-auth/blob/46d2dafa883551afdf3cb87f771195b911816dca/project/Build.scala#L91-L97>\n\nなどを参考にしてください。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T14:45:25.283", "id": "8658", "last_activity_date": "2015-04-01T14:45:25.283", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "56", "parent_id": "8646", "post_type": "answer", "score": 0 } ]
8646
8658
8658
{ "accepted_answer_id": "8651", "answer_count": 2, "body": "現在実行しているEXEファイルと検索対象フォルダであるNameは、同じ階層にあります。 \nそして、Nameフォルダ内にある、1つのファイル(ファイル名はランダム)を相対パスで取得したいのですが、取得することが出来ません。\n\n現在のC#での実装は\n\n```\n\n var file = Directory.GetFiles(\"Name\",\"*.DAT\");\n \n```\n\nとしており、var fileにはなにも入らない状態です。 \n解決方法の分かる方がいましたら、ご教授をお願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T09:40:29.050", "favorite_count": 0, "id": "8648", "last_activity_date": "2015-04-01T10:40:58.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7626", "post_type": "question", "score": 1, "tags": [ "c#" ], "title": "C# 相対パスでファイル検索をしたい", "view_count": 8094 }
[ { "body": "Exeのディレクトリを取得するということで良いんでしょうか\n\n```\n\n var file = Directory.GetFiles(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, \"Name\"), \"*.DAT\");\n \n```\n\nとか、\n\n```\n\n var file = Directory.GetFiles(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), \"Name\"), \"*.DAT\");\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T09:57:22.037", "id": "8650", "last_activity_date": "2015-04-01T09:57:22.037", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7740", "parent_id": "8648", "post_type": "answer", "score": 2 }, { "body": "階層を特に限定しない場合、相対パスの解決には`System.Uri`を使用します。\n\n```\n\n var dirPath = new Uri(new Uri(Assembly.GetExecutingAssembly().Location), \"./Name\").LocalPath;\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T10:40:58.947", "id": "8651", "last_activity_date": "2015-04-01T10:40:58.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "8648", "post_type": "answer", "score": 2 } ]
8648
8651
8650
{ "accepted_answer_id": null, "answer_count": 3, "body": "アプリ内で、jsonファイルを読み込んだ箇所があるのですが、サーバー上のjsonファイルを更新してもアプリの内容に反映されません。(アプリを一端落とすと反映されたりもする。)反映されるようにするにはどのような処理を入れれば良いのでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T09:54:50.433", "favorite_count": 0, "id": "8649", "last_activity_date": "2015-04-02T05:04:15.833", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7724", "post_type": "question", "score": -2, "tags": [ "monaca", "json" ], "title": "jsonファイルの差分がある場合、jsonデータを更新したい。", "view_count": 1055 }
[ { "body": "取得しなおしても反映されないということであれば、通信内容がキャッシュされてないかを確認するのが良いのではないでしょうか。たぶんJSON\nかどうかは関係ないと思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T10:45:49.210", "id": "8653", "last_activity_date": "2015-04-01T10:45:49.210", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "319", "parent_id": "8649", "post_type": "answer", "score": 1 }, { "body": "> (アプリを一端落とすと反映されたりもする。)\n\nとあるので、ダウンロードしたjsonファイルを保存するタイミングとそれを読み出すタイミング? \nが逆転するなどして古いjsonファイルのデータを保持し続けてしまっていたりしませんか?\n\n何にせよ、もう少し詳細にどういった仕組みで実装しているのかや、 \n具体的に関連部分のコードを明示された方が解決に近づく意見がもらえると思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T00:31:19.947", "id": "8671", "last_activity_date": "2015-04-02T00:31:19.947", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3227", "parent_id": "8649", "post_type": "answer", "score": 1 }, { "body": "キャッシュが保存されているだけなら、ランダムなパラメータを付けてアクセスすればキャッシュを使わないように出来ます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T05:04:15.833", "id": "8681", "last_activity_date": "2015-04-02T05:04:15.833", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "525", "parent_id": "8649", "post_type": "answer", "score": 1 } ]
8649
null
8653
{ "accepted_answer_id": null, "answer_count": 2, "body": "お世話になります。PHPとsymfony勉強中です。\n\n * Parent/AdminBundle/\n * Parent/UserBundle/\n\n二つのBundleがあります。 \nテーブルは以下の3つです。(既に作成済みでデータも入っています。)\n\n * admin\n * user\n * product\n\nproductをAdminBundleからもUserBundleからも参照したいです。 \nParentの下にEntityを作れば良いのかと思いymlファイルを定義して生成を試してみたのですが\n\n```\n\n $ sudo php app/console doctrine:generate:entities Parents\n Generating entities for namespace \"Parents\"\n \n [RuntimeException] \n Namespace \"Parents\" does not contain any mapped entities. \n \n```\n\nというエラーが出てきてしまい、Entityを作成することができませんでした。 \nどのようにすれば解決することができますか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T10:51:29.190", "favorite_count": 0, "id": "8654", "last_activity_date": "2015-05-19T15:41:40.987", "last_edit_date": "2015-04-01T11:44:31.760", "last_editor_user_id": "8000", "owner_user_id": "9110", "post_type": "question", "score": 3, "tags": [ "php", "symfony2" ], "title": "symfony2 Bundleを越えて1つのテーブルを参照したい", "view_count": 313 }
[ { "body": "※誤りがあったので訂正しました。\n\nCoreBundleのような共通のバンドルを作ってそこにEntityをまとめる事で、やりたい事が実現できると思います。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-05-19T14:17:22.417", "id": "10385", "last_activity_date": "2015-05-19T15:41:40.987", "last_edit_date": "2015-05-19T15:41:40.987", "last_editor_user_id": "242", "owner_user_id": "242", "parent_id": "8654", "post_type": "answer", "score": 0 }, { "body": "Issei.Mさんの回答と技術的には同じですが、内容を補足します。\n\nSymfonyのバンドルという構造はソフトウェアのパッケージの単位ではありますが、1つのアプリケーション内で複数のバンドルを利用している場合に、パッケージをまたがる利用に制限はありません。どのバンドルのクラスをどこからでも利用可能です(オートロードが効くため)。\n\nただし、だからといって無制限にあちこちにエンティティが散らばると大変なので、通常はパッケージの依存の方向が1方向になるように、なるべく管理します。Issei.Mさんの回答のようにCoreBundleというところに共通で利用するのをまとめるのは、そのための1つの方法といった感じになります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-05-19T14:37:11.143", "id": "10386", "last_activity_date": "2015-05-19T14:37:11.143", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5444", "parent_id": "8654", "post_type": "answer", "score": 1 } ]
8654
null
10386
{ "accepted_answer_id": "8662", "answer_count": 1, "body": "ブラウザから送られてきたPOSTのフォームデータをcgi.FieldStorage()として、受け取ろうとするのですが、 \nFieldStorage(None, None, []) \nになってしまいます。どうすればいいのでしょうか?\n\nhtmlは\n\n```\n\n \n <!DOCTYPE html>\n <html lang=\"ja\">\n <head>\n <meta charset=\"UTF-8\">\n <title>data Create</title>\n </head>\n <body>\n <h1>Create</h1>\n <form action=\"/post\" enctype=\"multipart/form-data\" method=\"POST\">\n <div>\n <label for=\"name\">name</label><input type=\"text\" id=\"name\" name=\"name\" required>\n </div>\n <div>\n <input type=\"number\" id=\"age\" name=\"age\" min=\"0\" required>\n </div>\n <div>\n <input type=\"file\" id=\"fileselector\" name=\"file\">\n </div>\n <div><input type=\"submit\" value=\"送信\"></div>\n </form>\n \n <br>\n <div><a href=\"/\">Back to top</a></div>\n </body>\n </html>\n \n \n \n \n```\n\nserverは\n\n```\n\n \n import http.server\n import cgi\n \n class handler(http.server.BaseHTTPRequestHandler):\n def do_POST(self):\n print(cgi.FieldStorage()) # FieldStorage(None, None, [])\n \n \n```\n\nというふうになっています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T13:19:40.473", "favorite_count": 0, "id": "8656", "last_activity_date": "2015-04-01T15:31:16.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5246", "post_type": "question", "score": 3, "tags": [ "python", "http" ], "title": "POSTで送ったデータをpythonのcgi.FieldStrageで受け取れない", "view_count": 2793 }
[ { "body": "なぜBaseHTTPRequestHandlerでがんばっているのか、という疑問はありますが、以下のようにすれば取得出来ます。\n\n```\n\n import http.server\n import cgi\n import os\n \n class handler(http.server.BaseHTTPRequestHandler):\n def do_POST(self):\n os.environ['REQUEST_METHOD'] = 'POST'\n form = cgi.FieldStorage(self.rfile, self.headers)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T15:31:16.433", "id": "8662", "last_activity_date": "2015-04-01T15:31:16.433", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "806", "parent_id": "8656", "post_type": "answer", "score": 3 } ]
8656
8662
8662
{ "accepted_answer_id": "8672", "answer_count": 3, "body": "「3, 4, 5」という範囲の整数があるとします。カレントロケーションを `5`、インクリメントを `+1` としたとき、`3`\nを返してほしいです。もし、インクリメントが `+2` なら `4`、`+7` であれば `3` のように、3, 4, 5, 3, 4, 5, 3...\nとインクリメントの結果が循環してほしいです。\n\n**やってみたこと** :\n\n+1、-1 のインクリメント/デクリメントの場合は下記のコードで実装できましたが、+2 や -4 など加減数が 1\nを超える場合に対応させようとすると、方法がわからなくなります(下記の関数を加減数ぶんfor文で繰り返し実行することはできますが……)。\n\n実装\n\n```\n\n NSUInteger NSRangeIncrementLocationInRange(NSUInteger location, NSRange range) {\n \n NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange: range];\n \n if (![indexSet containsIndex: location]) {\n return NSNotFound;\n }\n \n NSUInteger index = [indexSet indexGreaterThanIndex: location];\n \n return index != NSNotFound ? index : [indexSet firstIndex];\n }\n \n NSUInteger NSRangeDecrementLocationInRange(NSUInteger location, NSRange range) {\n \n NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange: range];\n \n if (![indexSet containsIndex: location]) {\n return NSNotFound;\n }\n \n NSUInteger index = [indexSet indexLessThanIndex: location];\n \n return index != NSNotFound ? index : [indexSet lastIndex];\n }\n \n```\n\n実行例\n\n```\n\n // 4 〜 8の範囲内で8をインクリメントする\n NSLog(@\"%zd\", NSRangeIncrementLocationInRange(8, NSMakeRange(4, 5))); // 8の次は最小値に戻って4が返る\n \n```\n\n**求めているもの** :\n\n理想的なのは下記のような関数で、\n\n```\n\n NSUInteger NSRangeIncrementLocationInRange(NSUInteger location, NSInteger increment, NSRange range);\n \n```\n\n`increment` に `3` だの `-8` だの正負どちらでも渡せるようにしたいです。\n\n**質問** :\n\nこのようなメソッド、または関数は、Objective-C、またはCのフレームワークやライブラリに存在しますか?\nもしない場合、実装するためにどのようなコードが考えられますか?", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T19:08:29.047", "favorite_count": 0, "id": "8665", "last_activity_date": "2015-04-02T18:51:05.313", "last_edit_date": "2015-04-02T02:47:21.980", "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 3, "tags": [ "ios", "objective-c", "c" ], "title": "ある範囲内で整数のインクリメント・デクリメントを循環させるには?", "view_count": 852 }
[ { "body": "自己回答です。\n\n**`location` を基点に加減するべき数(距離)を求める** 解法です。\n\n```\n\n NSUInteger NSRangeIncrementLocationInRange(NSUInteger location, NSInteger increment, NSRange range) {\n \n if (!NSLocationInRange(location, range)) {\n return NSNotFound;\n }\n \n BOOL incrementIsPositive = increment >= 0;\n NSUInteger distance = ABS(increment) % range.length;\n \n NSInteger result = location;\n result += incrementIsPositive ? distance : -distance;\n \n if (!NSLocationInRange(result, range)) {\n result += incrementIsPositive ? -range.length : range.length;\n }\n \n return result;\n }\n \n```\n\n**解法** :\n\n * インクリメントの増減値を整理する(周回数を取り除く) : `incrementの絶対値 % range.length`\n * `location` に増減値を加算(インクリメントが正なら加算、負なら減算)\n * `result` が範囲外なら `range.length` を加算または減算して範囲内で1周させる", "comment_count": 7, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T21:48:31.553", "id": "8668", "last_activity_date": "2015-04-02T18:51:05.313", "last_edit_date": "2015-04-02T18:51:05.313", "last_editor_user_id": null, "owner_user_id": null, "parent_id": "8665", "post_type": "answer", "score": 1 }, { "body": "デクリメントのほうなんですけど、整数値が環状に並んでいるというイメージをしてください。(下図) \n![画像の説明をここに入力](https://i.stack.imgur.com/CMrdv.png) \n2戻るということは、3進むのと同じです。これを、一般化して表現すると、increment **戻る** ということは、range.length -\nincrement **進む** とおなじであることに気づくはずです。さらに厳密に表現すると、range.length - increment %\nrange.length進むと同じです。これをそのままインクリメント(increment >\n0)のときの式に代入してやります。具体的にコードにすると、こうなります。\n\n```\n\n #import <Foundation/Foundation.h>\n \n NSUInteger NSRangeIncrementLocationInRange(NSInteger location, NSInteger increment, NSRange range) {\n NSUInteger result;\n // locationがrangeの範囲外なら、NSNotFoundを返す。\n if (!NSLocationInRange(location, range)) return NSNotFound;\n if (increment > 0) { // incrementが正数の場合。\n result = (location - range.location + (NSUInteger)increment) % range.length + range.location;\n } else if (increment == 0) { // incrementが0の場合、locationをそのまま返す。\n result = location;\n } else { // incrementが負数の場合。range.lengthとincrementの差を、locationに加えるという計算をする。\n result = (location - range.location + (NSUInteger)((NSInteger)range.length + increment % (NSInteger)range.length)) % range.length + range.location;\n // ((NSInteger)range.length + increment)) % range.length + range.location; 修正しました。\n }\n \n return result;\n }\n \n int main(int argc, const char * argv[]) {\n @autoreleasepool {\n NSUInteger inc = NSRangeIncrementLocationInRange(5, -8, NSMakeRange(4, 5));\n NSLog(@\"Result = %ld\", inc);\n }\n return 0;\n }\n \n```\n\n編集しました。 \n引数incrementの型を、NSUIntegerからNSIntegerに変えました。きわめて初歩的な間違いですね。ご容赦。暗黙的に型キャストしてくれるであろう箇所も、明示的に型キャストしました。\n\n二度目の編集をしました。負の向きに1巡以上するincrementで、正しい結果にならないという指摘を受けて、修正しました。 \n「increment **戻る** ということは、range.length - increment **進む** とおなじ」を、 \n「increment **戻る** ということは、range.length - increment % range.length **進む**\nとおなじ」に変更しました。\n\n三度目の編集をしました。 \n「整数値を環状に並べる」を、図にして、わかりやすくしました。", "comment_count": 8, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T23:43:10.967", "id": "8670", "last_activity_date": "2015-04-02T09:11:40.117", "last_edit_date": "2015-04-02T09:11:40.117", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "8665", "post_type": "answer", "score": 1 }, { "body": "Cっぽく書けば下記コードで算出できます。一度`range`で剰余(`%`)を求めたあと、負値に対処するため再び`(N + range) %\nrange`を行っています。\n\n```\n\n // 値(value+diff)を範囲[rl, rh)にマッピング\n int f(int value, int diff, int rl, int rh)\n {\n int range = rh - rl;\n return (((value + diff - rl) % range) + range) % range + rl;\n }\n \n```\n\n入力値`value`の範囲チェックはしていませんので、必要ならば別途追加してください(要不要は要件によると思います)。\n\nLiveDemo: <http://melpon.org/wandbox/permlink/4gUve20aihTOVhuz>", "comment_count": 6, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T00:55:58.440", "id": "8672", "last_activity_date": "2015-04-02T02:26:28.487", "last_edit_date": "2015-04-02T02:26:28.487", "last_editor_user_id": "49", "owner_user_id": "49", "parent_id": "8665", "post_type": "answer", "score": 2 } ]
8665
8672
8672
{ "accepted_answer_id": "8676", "answer_count": 1, "body": "`PickerView`の最初に選択されている値を取得してデータベースに格納しようとしているのですが、データ登録後にデータベースを確認すると中身が空になってしまっています。 \nまた、この`ViewController`から他の`ViewController`へ移動しようとすると、「`fatal error:\nunexpectedly found nil while unwrapping an Optional\nvalue`」というエラーがログに出力されてアプリが落ちてしまいます。 \nいまいちまだオプショナル型についても分かってないので、詰まってしまいました。 \nどうすれば`PickerView`の初期値を取得して正常に動かすことができるでしょうか? \nどなたか分かる方がいれば教えていただきたいです。すみませんが、よろしくお願いします。\n\n```\n\n import UIKit\n \n class ViewController: UIViewController {\n \n @IBOutlet weak var speechPicker: UIPickerView!\n @IBOutlet weak var textField: UITextField!\n \n var dataForSpeechPicker = [\"A\", \"B\", \"C\"]\n var registerWordStore = \"\"\n var registerSpeechStore = \"\"\n \n override func viewDidLoad() {\n super.viewDidLoad()\n // Do any additional setup after loading the view, typically from a nib.\n }\n \n override func viewDidAppear(animated: Bool) {\n speechPicker.selectRow(0, inComponent: 0, animated: true)\n }\n \n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n \n // MARK:- picker\n \n func numberOfComponentsInPickerView(pickerview1: UIPickerView) -> Int {\n return 1\n }\n \n func pickerView(pickerview1: UIPickerView, numberOfRowsInComponent component: Int) -> Int {\n return dataForSpeechPicker.count\n }\n \n func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {\n return dataForSpeechPicker[row]\n }\n \n func pickerView(pickerview1: UIPickerView, didSelectRow row: Int, inComponent component: Int) {\n registerSpeechStore = dataForSpeechPicker[row]\n }\n \n // MARK:- textField\n \n func textFieldShouldReturn(textField: UITextField!) -> Bool{\n registerWordStore = textField.text\n \n textField.resignFirstResponder()\n return true\n }\n \n // MARK:- registerButton\n \n @IBAction func registerWord(sender: AnyObject) {\n //データベース登録処理\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-01T23:41:40.917", "favorite_count": 0, "id": "8669", "last_activity_date": "2015-04-02T01:39:39.010", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5210", "post_type": "question", "score": 0, "tags": [ "swift", "uipickerview" ], "title": "PickerViewにデフォルト値を設定できない", "view_count": 1674 }
[ { "body": "初めまして。 \nそのエラーはnilの値をアンラップしようとした際に出るエラーです。\n\nつまりnilなのに強制的にOptionalから型を戻そうとしている感じです。 \n通常の型はnilを扱えないのでこのようなエラーがでます。\n\n値についてですが、delegateがないのでコールバックが呼ばれていないのではないでしょうか?", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T01:39:39.010", "id": "8676", "last_activity_date": "2015-04-02T01:39:39.010", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "297", "parent_id": "8669", "post_type": "answer", "score": 1 } ]
8669
8676
8676
{ "accepted_answer_id": "8678", "answer_count": 3, "body": "プログラミング初心者です、検索しても答え見つからないので質問させてもらいます。\n\n例えばこの記述\n\n```\n\n // 背景画像を読み込む\n let texture = SKTexture(imageNamed: \"background\")\n texture.filteringMode = .Nearest\n \n```\n\nの `= .Nearest`の.の前の省略?された文を教えてください \n`.Nearest`の.の前に記述があるのは勉強したことあるが忘れてしまいました。 \nswift補助機能がでないので省略された記述を知りたいです。\n\n似た文で\n\n```\n\n scene = GameScene(size: skView.bounds.size)\n scene.scaleMode = .AspectFill\n skView.presentScene(scene)\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T01:01:31.457", "favorite_count": 0, "id": "8673", "last_activity_date": "2015-04-02T03:50:56.927", "last_edit_date": "2015-04-02T01:21:39.003", "last_editor_user_id": "7362", "owner_user_id": "9116", "post_type": "question", "score": 3, "tags": [ "swift", "xcode" ], "title": "swift .の前の省略された文を教えてください .AspectFillとか.Nearestなど", "view_count": 762 }
[ { "body": "初めまして。 \nSKTextureFilteringMode.Nearestです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T01:28:56.417", "id": "8675", "last_activity_date": "2015-04-02T01:28:56.417", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "297", "parent_id": "8673", "post_type": "answer", "score": 1 }, { "body": "それは、型が自明な変数に代入する場合、enumの型名を省略できる というSwiftの構文です。\n\nよって、`SKTexture.filteringMode`プロパティの型を確認すると、省略されたのが`SKTextureFilteringMode`であると分かります。\n\n\"似た文で\"の方も`GameScene.scaleMode`の型を調べると分かります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T02:08:08.077", "id": "8677", "last_activity_date": "2015-04-02T02:08:08.077", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3022", "parent_id": "8673", "post_type": "answer", "score": 2 }, { "body": "こういう場合は、式の右辺だけ見ずに、左辺も注目します。\n\n```\n\n texture.filteringMode = .Nearest\n \n```\n\nプロパティ`filteringMode`の型を調べれば、右辺の値の型もわかるはずです。 \nOptionキーを押しながら、`filteringMode`をクリックすると、バルーンヘルプが表示されます。(下図)\n\n![画像の説明をここに入力](https://i.stack.imgur.com/5Mh6e.png)\n\n`filteringMode`の型が`SKTextureFilteringMode`なので、`.Nearest`を省略せずに書くと、`SKTextureFilteringMode.Nearest`であるとわかります。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T02:19:30.197", "id": "8678", "last_activity_date": "2015-04-02T03:50:56.927", "last_edit_date": "2015-04-02T03:50:56.927", "last_editor_user_id": "7362", "owner_user_id": "7362", "parent_id": "8673", "post_type": "answer", "score": 5 } ]
8673
8678
8678
{ "accepted_answer_id": "9055", "answer_count": 2, "body": "現在Java、Seasar2(SAStrats/S2JDBC)、JSP、PostgreSQLで \nDBを使ったWebアプリケーションを作っています。\n\n質問があるのですが、 \n \n\n**Javaでログイン時の「パスワードを記憶する」機能を作るにはどうしたらいいでしょうか?**\n\n \n \n次のような機能です。 \n![画像の説明をここに入力](https://i.stack.imgur.com/kJFai.jpg)\n\n作り方やサンプルコードを調べているのですが、なかなか見つけられません。 \nもし情報を提供できる方がいれば、参考ページのURLなどを教えて頂けると助かります。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T01:21:55.613", "favorite_count": 0, "id": "8674", "last_activity_date": "2015-04-11T16:50:00.383", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8982", "post_type": "question", "score": 2, "tags": [ "java", "html", "seaser2" ], "title": "Javaでログイン時の「パスワードを記憶する」を作るには", "view_count": 2441 }
[ { "body": "次のようなやり方で取り組んでみたいと思います。\n\ncookieを使用。 \n1.最初のログイン時にログイン情報をDBなどに保存。その際ログイン状態を表すユニークなID(文字列など)をDBのキーとしておく \n2.そのキーをCookieに保存(有効期限付きで) \n3.サイトが開かれた際に、2のCookieがあればDBを検索 \n4.DBにログイン情報が存在すればログイン状態とする\n\n参照 \n<http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q14107632694>\n\n大方やりたいことは合っているのでもう少し勉強してみます。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T03:17:25.967", "id": "8679", "last_activity_date": "2015-04-02T03:17:25.967", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8982", "parent_id": "8674", "post_type": "answer", "score": 1 }, { "body": "ブラウザの認証画面はBasic認証と呼ばれる方式で、ID・パスワードの入力と、1回ログインしたらそのときの認証情報を今後も使用するかどうを、ブラウザ側の機能として実現しています。\n\n今回質問者さんがやりたいことは、この機能を使わずに、Java EEアプリケーションで独自に実装をしたい、ということだと思われます。\n\nその場合はフォーム認証というやり方になります。ログイン画面は自分でHTMLなりJSP・JSFなりで作成し、認証処理、認証結果の保存を自力でやることになります。\n\n方法としてはすでにご自身で回答のとおりCookieを使った方法が良いでしょう。注意点としては、Cookieに保存するのはIDやパスワードそのものではなく、それと紐づいた独自の生成値にすること、ドメイン属性を設定し自分のサイトだけにCookieを送信するようにすること、環境的に可能であればSSLを有効にし、CookieにもSecure属性を付けること、です。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-11T16:50:00.383", "id": "9055", "last_activity_date": "2015-04-11T16:50:00.383", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9277", "parent_id": "8674", "post_type": "answer", "score": 2 } ]
8674
9055
9055
{ "accepted_answer_id": null, "answer_count": 1, "body": "MonacaおよびJavaScript、アプリ開発初心者です。 \n恐れ入りますがお力添えいただきたく質問させていただきます。\n\n以下のサイトで初歩の初歩を勉強しており、実際にMonacaで同じソースコードをコピーして動かしているのですがクラスを呼び出すようにすると、なぜか画面に何も出てこなくなってしまいます。 \n<http://code.9leap.net/>\n\n 1. 想定どおり画像が表示されるソースコード\n``` enchant(); // おまじない\n\n \n // ここで自作クラスBearをつくる\n Bear = Class.create(Sprite, // Spriteクラスを継承\n {\n initialize: function(x, y) { //初期化する\n Sprite.call(this, 32, 32); //Spriteオブジェクトを初期化\n this.image = game.assets['./img/chara1.png'];\n this.x = x;\n this.y = y;\n \n this.tx = this.x; //行きたい場所のX座標\n this.ty = this.y; //行きたい場所のY座標\n this.frame = 0;\n game.rootScene.addChild(this);\n },\n //enterframeイベントのリスナーを定義する\n onenterframe: function() {\n slow = 30; //クマが行きたい場所へ近づく遅さ\n //行きたい場所へ近づく\n this.x += (this.tx - this.x) / slow;\n this.y += (this.ty - this.y) / slow;\n }\n });\n \n window.onload = function() {\n var game = new Game(320, 320); // ゲーム本体を準備すると同時に、表示される領域の大きさを設定しています。\n game.fps = 24; // frames(フレーム)per(毎)second(秒):ゲームの進行スピードを設定しています。\n game.preload('./img/chara1.png'); // pre(前)-load(読み込み):ゲームに使う素材をあらかじめ読み込んでおきます。\n game.onload = function() { // ゲームの準備が整ったらメインの処理を実行します。\n //bear = new Bear(100, 120); // クマさんをつくる \n \n var kuma = new Sprite(32, 32); // くまというスプライト(操作可能な画像)を準備すると同時に、スプライトの表示される領域の大きさを設定しています。\n kuma.image = game.assets['./img/chara1.png']; // くまにあらかじめロードしておいた画像を適用します。\n kuma.x = 100; // くまの横位置を設定します。\n kuma.y = 120; // くまの縦位置を設定します。\n game.rootScene.addChild(kuma); // ゲームのシーンにくまを表示させます。\n game.rootScene.backgroundColor = '#7ecef4'; // ゲームの動作部分の背景色を設定しています。\n };\n game.start(); // ゲームをスタートさせます![画像の説明をここに入力][1] \n };\n \n```\n\n 2. クラス呼び出しのために以下のコメントアウトを取り消すと何も表示されなくなってしまいます\n``` bear = new Bear(100, 120); // クマさんをつくる\n\n \n```\n\nコンソールにエラーなども出ておらず、何が原因か見当もつかない状態でして、何かお気づきの方いらっしゃいましたら助けていただけないでしょうか…。\n\n以上よろしくお願いいたします。\n\n![画像の説明をここに入力](https://i.stack.imgur.com/yYS5N.png)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T04:51:44.000", "favorite_count": 0, "id": "8680", "last_activity_date": "2015-04-02T06:04:07.190", "last_edit_date": "2015-04-02T06:04:07.190", "last_editor_user_id": "3068", "owner_user_id": "9119", "post_type": "question", "score": 1, "tags": [ "javascript", "monaca" ], "title": "Monacaを使ってjavascriptでクラスを作成し呼び出しに失敗", "view_count": 601 }
[ { "body": "たぶん、window.onloadの中で宣言しているローカル変数gameを、グローバル変数にしなければならないのではないでしょうか。 \nでないと、Bearクラスのinitializeから変数gameを参照できないです。 \n変数gameの宣言だけ外に出せばいいと思います。\n\n```\n\n var game;\n window.onload = function () {\n game = new Game(300, 300);\n // あとは同じ\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T05:48:58.493", "id": "8683", "last_activity_date": "2015-04-02T05:48:58.493", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8078", "parent_id": "8680", "post_type": "answer", "score": 1 } ]
8680
null
8683
{ "accepted_answer_id": "8687", "answer_count": 1, "body": "Datatablesのソースで、表示件数変更欄を生成している部分が知りたいと思い、 \nsettings._iDisplayLengthと記載されているソースを調査していますが、見つける事が出来ていません。 \n分かる方がいましたらご教授をお願いします。\n\n[DataTablesダウンロード](http://datatables.net/download/)", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T05:34:20.467", "favorite_count": 0, "id": "8682", "last_activity_date": "2015-04-02T08:55:37.790", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7626", "post_type": "question", "score": 1, "tags": [ "javascript", "html", "jquery" ], "title": "Datatablesのソースで、表示件数変更欄を生成している部分が知りたいです", "view_count": 2035 }
[ { "body": "表示件数変更欄というのはテーブルの左上に表示される `Show [10] entries` のことでしょうか。\n\n<http://datatables.net/examples/advanced_init/length_menu.html>\n\nオプション名が `lengthMenu` なので、これを `jquery.dataTables.js` 内で検索したら\n`_fnFeatureHtmlLength()` にたどり着きました。\n\n<https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L3353>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T08:55:37.790", "id": "8687", "last_activity_date": "2015-04-02T08:55:37.790", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "8682", "post_type": "answer", "score": 1 } ]
8682
8687
8687
{ "accepted_answer_id": "8888", "answer_count": 2, "body": "Sidekiqを動かすためにAWSのElasticacheを使用しています。 \nRedisのバージョンは2.8.6です。\n\n**Redisの「(error) ERR max number of clients reached」というエラー対応に困っています。 \nコマンドライン操作で「FLUSHALL」を実行して、データを一旦クリアすることで対応しましたが、待機状態のジョブもリセットしてしまう結果となったので、ジョブのリセットを防ぐ良い解決策を知っている方がいればお教えください。**\n\nよろしくお願いします。詳細は下記にまとめました。\n\nRedisのmaxclientsというパラメーターが上限値(65000)に達してしまった際に発生するエラーで、Sidekiqのダッシュボード画面の下部の「接続」という項目(※下図の赤枠箇所)が64999となり、Sidekiqの動作も止まってしまう。\n\n![Sidekiqのダッシュボード画面](https://i.stack.imgur.com/E70W9.png)\n\nElasticacheのマニュアル(<http://docs.aws.amazon.com/ja_jp/AmazonElastiCache/latest/UserGuide/CacheParameterGroups.Redis.html>) \nによると、maxclientsの上限値は変更できないとのこと。\n\nエラーへの対応として、Elasticacheをリブートして、コマンドライン操作で「FLUSHALL」を実行して、データを一旦クリアすることで対応。 \n(※Redisのコマンドライン操作で何を打ち込んでも、「(error) ERR max number of clients\nreached」のエラーが返ってきてしまい、「FLUSHALL」すらできなかったので、Elasticacheの再起動が必要だった。) \nしかし、待機状態のジョブもリセットしてしまう結果となった。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T06:21:43.583", "favorite_count": 0, "id": "8684", "last_activity_date": "2015-04-08T01:36:12.100", "last_edit_date": "2015-04-02T08:25:04.057", "last_editor_user_id": "8000", "owner_user_id": "8558", "post_type": "question", "score": 1, "tags": [ "ruby-on-rails", "aws", "redis", "sidekiq" ], "title": "AWSのElasticache(Redis)のパラメーターmaxclientsの値が上限に達したときの対応方法", "view_count": 5411 }
[ { "body": "> maxclientsの値は蓄積されるようなのですが\n\nそんなはずはないだろうと調べてみると、AutoScalingでインスタンスが減るときに切断処理が行えないため、タイムアウトするまでつなぎっぱなしになってしまうようです。\n\n[redisをAutoScaling環境で使う場合はtimeoutの設定に注意 -\nまめ畑](http://d.conma.me/entry/2013/03/21/114044)\n\nterminateする時に何かしらフックを仕掛けられないだろうかと思うのですが、ちょっとわからないです。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T10:52:55.837", "id": "8691", "last_activity_date": "2015-04-02T10:52:55.837", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "8684", "post_type": "answer", "score": 1 }, { "body": "Elasticacheのパラメーターであるtimeoutの値がデフォルトだと0だったため、0より上の値に設定してあげたところ(とりあえず3600に設定)、接続(maxclients)の値も解放され、解決することができました。\n\ntimeoutの値が0だとアイドル状態のクライアントとの切断処理を行わないため、蓄積されていました。AutoScalingしたインスタンスからElasticache(Redis)に接続するときは注意が必要です。\n\nデフォルトのパラメーターグループの値は編集できないので、新しくパラメーターグループを作成し、適用しました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-08T01:36:12.100", "id": "8888", "last_activity_date": "2015-04-08T01:36:12.100", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8558", "parent_id": "8684", "post_type": "answer", "score": 1 } ]
8684
8888
8691
{ "accepted_answer_id": "8686", "answer_count": 1, "body": "こんにちは。よろしくお願いいたします。 \n現在、jqueryを使って下記のような動きを試みています。\n\n4つのselectタグ(0番~3番とします)があり、デフォルトでは\n\n * select0(選択可能状態)\n * select1~3(disabled状態)\n\nとなっています。\n\nこれを、0が選択されたら次の1を選択可能に、1が選択されたら次の2を・・・と順番に選んでいけるようにしたく、下記のようにIDを指定して個別に書く方法ではなんとかできるようになりました。\n\n```\n\n $(\"#select0\").change(function(){ $(\"#select1\").removeAttr(\"disabled\"); });\n $(\"#select1\").change(function(){ $(\"#select2\").removeAttr(\"disabled\"); });\n ...\n \n```\n\n上記の書き方でselect3まで繰り返して書いています。\n\nこれを、eq: などを使ってもっとスマートに書きたいのですが変数?の書き方がわからず困っています。\n\n```\n\n $(\"select\").change(function(){\n $(\"select\").eq(ここに自身の番号に+1した番号).removeAttr(\"disabled\");\n });\n \n```\n\nこんな感じでまとめることは可能でしょうか? \n当方、javascript自体あまりよくわかっていない状態です。 \nどなたかご教示いただければと思います。\n\nよろしくお願いいたします。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T07:43:13.623", "favorite_count": 0, "id": "8685", "last_activity_date": "2015-04-02T08:20:45.547", "last_edit_date": "2015-04-02T08:03:29.253", "last_editor_user_id": "8000", "owner_user_id": "9123", "post_type": "question", "score": 2, "tags": [ "javascript", "jquery" ], "title": "複数のselect(disabled状態)を、順番に選択可能に", "view_count": 1468 }
[ { "body": "[`.index(element)`](https://api.jquery.com/index/) である要素が集合の何番目かを調べることができます。\n\n```\n\n $('select').change(function(){\r\n var curno = $('select').index(this);\r\n $('select').eq(curno + 1).prop('disabled', false);\r\n });\n```\n\n```\n\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script>\r\n <select><option>-</option><option>some</option></select>\r\n <select disabled><option>-</option><option>some</option></select>\r\n <select disabled><option>-</option><option>some</option></select>\r\n <select disabled><option>-</option><option>some</option></select>\n```\n\nただ `$('select')` としてしまうと関係ない `<select>`\nが増えたときに困るので、親要素で絞り込んだり、classを付けたほうがいいような気がします。\n\n構造によっては [`.next()`](https://api.jquery.com/next/) も使えるかもしれません。参考までに。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T08:20:45.547", "id": "8686", "last_activity_date": "2015-04-02T08:20:45.547", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8000", "parent_id": "8685", "post_type": "answer", "score": 1 } ]
8685
8686
8686
{ "accepted_answer_id": "8702", "answer_count": 2, "body": "現在Functional Programming in Scalaの日本語訳を読んでいます。exercise\n4.5のtraverse関数を実装せよという問題に関しての質問です。\n\n```\n\n def traverse[A,B](as:List[A])(f:A=>Option[B]):Option[List[B]]= as match{\n | case Nil => Some(Nil)\n | case (h::t) => for{\n | hh <- f(h)\n | tt <- traverse(t)(f)\n | } yield(hh::tt)\n | }\n \n traverse: [A, B](as: List[A])(f: A => Option[B])Option[List[B]]\n \n```\n\nこの関数は正常に動くようですが、\n\n```\n\n traverse((1 to 10000).toList)(i => Some(i))\n \n```\n\nと長さが一万程度のlistでstackoverflowになってしまいます。 \nflatMap内で再帰しているので末尾再帰にできません。 \nflatMapで再帰する関数でstacksafeにするにはどのようにすればいいでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T09:29:02.783", "favorite_count": 0, "id": "8688", "last_activity_date": "2015-04-03T00:17:48.063", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8928", "post_type": "question", "score": 0, "tags": [ "scala" ], "title": "flatMap内での再帰呼び出しの最適化", "view_count": 378 }
[ { "body": "方法はいくつかあるかもしれませんが、とりあえずScalazではDList(差分リスト)を使っています\n\n<https://github.com/scalaz/scalaz/blob/v7.1.1/core/src/main/scala/scalaz/std/List.scala#L44-L60>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T09:50:00.723", "id": "8689", "last_activity_date": "2015-04-02T09:50:00.723", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "56", "parent_id": "8688", "post_type": "answer", "score": 1 }, { "body": "この本のGitHubにあるヒントと答えを見ると、`foldRight`で`traverse`を実装できるよ、と書いてあります(答えを先に見るのが嫌な人は、1つめのリンクだけクリックしてください)。\n\n<https://github.com/fpinscala/fpinscala/blob/master/answerkey/errorhandling/05.hint.txt> \n<https://github.com/fpinscala/fpinscala/blob/master/answerkey/errorhandling/05.answer.scala>\n\nここで、第3章のエクササイズを一通りやっていれば、`List.foldRight`を末尾再帰に実装する方法も出てきたはずです。その方法で実装されている`foldRight`を使えば、`traverse`もスタックセーフに実装できると思います。(Scala標準のListも`foldRight`は末尾再帰で実装されているようなので、多分そのままでスタックセーフに動くのではないでしょうか。)", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T18:00:27.600", "id": "8702", "last_activity_date": "2015-04-03T00:17:48.063", "last_edit_date": "2015-04-03T00:17:48.063", "last_editor_user_id": "244", "owner_user_id": "244", "parent_id": "8688", "post_type": "answer", "score": 2 } ]
8688
8702
8702
{ "accepted_answer_id": "8699", "answer_count": 2, "body": "phpのheader関数でリダイレクトの指定をしているのですが、 \n<http://example.com>/あいうえお/かきくけこ \nなどの日本語が入っているURLにリダイレクトされません。\n\n```\n\n $redirect = 'http://example.com/あいうえお/かきくけこ';\n \n if(!empty($redirect)){\n header(\"Location: 0; URL= \".$redirect );\n }\n \n```\n\nどなたかご教示いただければと思います。 \nよろしくお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T10:10:15.093", "favorite_count": 0, "id": "8690", "last_activity_date": "2015-04-02T14:07:24.230", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9128", "post_type": "question", "score": 2, "tags": [ "php" ], "title": "PHPのLocationのURLに日本語URLを指定してリダイレクトする方法", "view_count": 1074 }
[ { "body": "日本語の部分をurlencode関数でURL用にエンコードしてやれば大丈夫かと思います。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T10:55:29.473", "id": "8692", "last_activity_date": "2015-04-02T10:55:29.473", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6072", "parent_id": "8690", "post_type": "answer", "score": 0 }, { "body": "2箇所を修正する必要があります。一つはuworkさん指摘 urlencoe、もう一つはLocationヘッダの書式です。0; URL= はMETA\nrefreshの際の書式ですので、Locationヘッダを使う場合は直にURLを書きます。 \n以下の様な感じになります。\n\n```\n\n $redirect = 'http://example.com/' . urlencode('あいうえお') . '/' . urlencode('かきくけこ');\n \n if(!empty($redirect)){\n header(\"Location: \".$redirect );\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T13:48:52.613", "id": "8699", "last_activity_date": "2015-04-02T14:07:24.230", "last_edit_date": "2015-04-02T14:07:24.230", "last_editor_user_id": "781", "owner_user_id": "781", "parent_id": "8690", "post_type": "answer", "score": 3 } ]
8690
8699
8699
{ "accepted_answer_id": "8694", "answer_count": 2, "body": "Visual studio2013でクラスライブラリを作成しようと考えています。\n\n新しいプロジェクトでクラスライブラリを選択してプロジェクトを作成、新しい項目の追加でClass2.csを追加しました。そしてビルドをしてdllを作成しました。 \n次に、新しいプロジェクトでコンソールアプリケーションを選択してプロジェクトを作成、参照の追加で先ほど作成したdllを追加しました。 \nその結果、コンソールアプリケーションのプロジェクトでデフォルトで生成されるClass1は認識できるのですが、後から自分で追加したClass2は見つからずコンパイルエラーとなります。\n\nこのような現象について何か考えられることはありますか \nよろしくお願いします", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T11:11:08.013", "favorite_count": 0, "id": "8693", "last_activity_date": "2015-04-07T08:23:20.733", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "9130", "post_type": "question", "score": 1, "tags": [ "c#" ], "title": "C#のクラスライブラリについて", "view_count": 1256 }
[ { "body": "おだんさんが、追加されたClass2に、publicアクセス修飾子は付いていますでしょうか?\n\n```\n\n public class Class2{...}\n \n```\n\nこのようにしないと、自分のアセンブリの外方から見えなくなります。\n\n```\n\n class Class2{...}\n \n```\n\nと書いた場合は、\n\n```\n\n internal class Class2{...}\n \n```\n\nと同じ意味になるので、アセンブリ内で参照可能でも、アセンブリ外では参照できず、コンパイルエラーとなります。\n\nその点を確かめてみてはいかがでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T11:26:19.600", "id": "8694", "last_activity_date": "2015-04-02T11:26:19.600", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7287", "parent_id": "8693", "post_type": "answer", "score": 7 }, { "body": "Class2を使用するファイルの一番上にusing句を追加してみてはいかがでしょうか。\n\n```\n\n using SampleClassLibrary;\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-07T08:23:20.733", "id": "8860", "last_activity_date": "2015-04-07T08:23:20.733", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "6040", "parent_id": "8693", "post_type": "answer", "score": 0 } ]
8693
8694
8694
{ "accepted_answer_id": "8698", "answer_count": 2, "body": "各桁の数字がその桁の出現回数を表すような数を \nSelf-descriptive numberと呼びます。 \n(<http://en.wikipedia.org/wiki/Self-descriptive_number>) \n以下のコードで、10桁までのSelf-descriptive numberを \n求めようとしたのですが、 \n9桁、10桁のSelf-descriptive numberの算出に時間が \nかかっています。 \nもっと高速に求める方法があれば、ご教示ください。\n\n```\n\n N = 10\n (1..N).each{|b|\n (0..b - 1).to_a.repeated_permutation(b){|a|\n if a[0] > 0\n i = b - 1\n flag = true\n while i > -1 && flag\n if a.count(i) == a[i]\n i -= 1\n else\n flag = false\n end\n end\n p a.join.to_i if i == -1\n end\n }\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T11:33:47.377", "favorite_count": 0, "id": "8696", "last_activity_date": "2015-04-03T15:40:14.177", "last_edit_date": "2015-04-02T12:07:35.713", "last_editor_user_id": "5363", "owner_user_id": "5363", "post_type": "question", "score": 2, "tags": [ "ruby", "アルゴリズム" ], "title": "10桁までのSelf-descriptive numberの求め方について", "view_count": 241 }
[ { "body": "各桁の合計が目的の桁数を超える時点で計算を打ち切っています。\n\n```\n\n def sdn(len, x = [])\n a = []\n if x.size == len\n if (0..len - 1).all? {|i| x.count(i) == x[i]}\n a << x.join.to_i\n end\n elsif x.inject(0) {|sum, n| sum + n } <= len\n s = x.size > 0 ? 0 : 1\n (s..len - 1).each { |n|\n a += sdn(len, x + [n])\n }\n end\n a\n end\n \n N = 10\n (1..N).each{|b|\n sdn(b).each {|n| p n}\n }\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T13:34:30.900", "id": "8698", "last_activity_date": "2015-04-02T22:17:59.547", "last_edit_date": "2015-04-02T22:17:59.547", "last_editor_user_id": "3639", "owner_user_id": "3639", "parent_id": "8696", "post_type": "answer", "score": 2 }, { "body": "(コメントでコードを書くと上手く表示されないので、回答を使っています。) \nh2so5さんのコードを用いて少しばかり高速化しました。\n\n```\n\n def sdn(len, l = 0, m = 0, x = [])\n a = []\n if l == len\n if (0..len - 1).all?{|i| x.count(i) == x[i]}\n a << x.join.to_i\n end\n elsif m <= len\n s = l > 0 ? 0 : 1\n (s..len - 1).each{|n| a += sdn(len, l + 1, m + n, x + [n])}\n end\n a\n end\n \n N = 10\n (1..N).each{|b|\n sdn(b).each{|n| p n}\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T15:20:29.797", "id": "8733", "last_activity_date": "2015-04-03T15:40:14.177", "last_edit_date": "2015-04-03T15:40:14.177", "last_editor_user_id": "5363", "owner_user_id": "5363", "parent_id": "8696", "post_type": "answer", "score": 1 } ]
8696
8698
8698
{ "accepted_answer_id": null, "answer_count": 1, "body": "chartjsやjqpolotを試してみたのですが表示されません。Webサイトと同じ設定では動かないのでしょうか?それともmonacaでは対応されていないのでしょうか?ご教授お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T13:10:54.267", "favorite_count": 0, "id": "8697", "last_activity_date": "2015-07-03T11:11:15.853", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8748", "post_type": "question", "score": 2, "tags": [ "monaca" ], "title": "monacaでグラフを表示するために", "view_count": 1618 }
[ { "body": "MonacaでChart.js使っていますが、正常に動いています。下記のソースコードをChart.jsを読み込んでからMonacaで試してみてください。\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 <script src=\"components/loader.js\"></script>\n <link rel=\"stylesheet\" href=\"components/loader.css\">\n <link rel=\"stylesheet\" href=\"css/style.css\">\n <script src=\"libs/Chart.js\"></script> \n </head>\n <body>\n \n <div id=\"canvas-holder\">\n <canvas id=\"chart-area\" width=\"300\" height=\"300\"/>\n </div>\n \n <script>\n var pieData = [\n {\n value: 300,\n color:\"#F7464A\",\n highlight: \"#FF5A5E\",\n label: \"Red\"\n },\n {\n value: 50,\n color: \"#46BFBD\",\n highlight: \"#5AD3D1\",\n label: \"Green\"\n },\n {\n value: 100,\n color: \"#FDB45C\",\n highlight: \"#FFC870\",\n label: \"Yellow\"\n },\n {\n value: 40,\n color: \"#949FB1\",\n highlight: \"#A8B3C5\",\n label: \"Grey\"\n },\n {\n value: 120,\n color: \"#4D5360\",\n highlight: \"#616774\",\n label: \"Dark Grey\"\n }\n \n ];\n \n window.onload = function(){\n var ctx = document.getElementById(\"chart-area\").getContext(\"2d\");\n window.myPie = new Chart(ctx).Pie(pieData);\n };\n \n </script> \n </body>\n </html>\n \n```\n\n![画像の説明をここに入力](https://i.stack.imgur.com/OKuko.jpg)\n\nP.S (2015年4月4日) Onsen UIのSliding Menu中で使用できるように改良\n\nindex.html\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 <script src=\"components/loader.js\"></script>\n <link rel=\"stylesheet\" href=\"components/loader.css\">\n <link rel=\"stylesheet\" href=\"css/style.css\">\n <script src=\"Chart.js\"></script> \n <script> \n var myApp = ons.bootstrap();\n \n myApp.controller('myCtrl', function () {\n \n var pieData = [\n {\n value: 300,\n color:\"#F7464A\",\n highlight: \"#FF5A5E\",\n label: \"Red\"\n },\n {\n value: 50,\n color: \"#46BFBD\",\n highlight: \"#5AD3D1\",\n label: \"Green\"\n },\n {\n value: 100,\n color: \"#FDB45C\",\n highlight: \"#FFC870\",\n label: \"Yellow\"\n },\n {\n value: 40,\n color: \"#949FB1\",\n highlight: \"#A8B3C5\",\n label: \"Grey\"\n },\n {\n value: 120,\n color: \"#4D5360\",\n highlight: \"#616774\",\n label: \"Dark Grey\"\n }\n \n ];\n \n var ctx = document.getElementById(\"chart-area\").getContext(\"2d\");\n window.myPie = new Chart(ctx).Pie(pieData);\n \n });\n \n </script>\n </head>\n <body>\n <ons-sliding-menu var=\"app.slidingMenu\" menu-page=\"menu.html\" main-page=\"page1.html\" side=\"left\" type=\"overlay\" max-slide-distance=\"200px\">\n </ons-sliding-menu>\n </body>\n </html>\n \n```\n\npage1.html\n\n```\n\n <ons-navigator>\n <ons-page ng-controller=\"myCtrl\">\n \n <div id=\"canvas-holder\">\n <canvas id=\"chart-area\" width=\"300\" height=\"300\"/>\n </div>\n \n </ons-page>\n </ons-navigator>\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T09:28:37.817", "id": "8726", "last_activity_date": "2015-04-04T10:10:13.823", "last_edit_date": "2015-04-04T10:10:13.823", "last_editor_user_id": "7871", "owner_user_id": "7871", "parent_id": "8697", "post_type": "answer", "score": 1 } ]
8697
null
8726
{ "accepted_answer_id": null, "answer_count": 1, "body": "ラズベリーパイからBluetoothスピーカーを使いたいのですがペアリングが上手くいかず再生をできずに困っています。\n\nラズベリーパイにログインして`hcitool`で\n\n```\n\n $ hcitool scan\n Scanning ...\n 00:25:DB:96:09:5E MEOSOUND003\n \n```\n\nと一覧には出てくるのですが\n\n```\n\n $ sudo bluetoothctl\n [bluetooth]#\n \n```\n\nとして表示はされても入力を`Ctrl+c`の強制終了しか受け付けてくれません。\n\n`BlueZ 4`でおなじ質問を英語版スタックフローでしてペアリングまでは教えて頂いてできたのですが、その後BLEを使用すると`BlueZ\n4`では動かなかったために`BlueZ 5`に上げたところ同様の問題に嵌ってしまいました。 \n<https://stackoverflow.com/questions/29273935/cant-pairing-with-bluetooth-\nspeaker-by-using-bluez-simple-agent>\n\nそれとペアリングは自動で行われるようにしたいのでBluetoothの内部シェル(?)を使わない方法を探しています。\n\n何か良い方法はないでしょうか?", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T14:58:43.773", "favorite_count": 0, "id": "8700", "last_activity_date": "2015-11-30T21:40:20.680", "last_edit_date": "2017-05-23T12:38:56.467", "last_editor_user_id": "-1", "owner_user_id": "3271", "post_type": "question", "score": 0, "tags": [ "raspberry-pi", "bluetooth", "bluez" ], "title": "BlueZ 5でラズベリーパイをBluetoothスピーカーとペアリングする方法", "view_count": 1174 }
[ { "body": "sudo bluetoothctl -a \nで試してはいかがでしょうか。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-11-30T21:40:20.680", "id": "19486", "last_activity_date": "2015-11-30T21:40:20.680", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "13464", "parent_id": "8700", "post_type": "answer", "score": -1 } ]
8700
null
19486
{ "accepted_answer_id": "8703", "answer_count": 1, "body": "Mac OS Xで起動時に特定のコマンドを実行させたいです。 \n具体的には\n\n```\n\n apachectl start\n mysql.server start\n \n```\n\nです。 \nそれぞれhomebrew経由でインストールされており、apacheは特権ポートを利用するため特権ユーザでの起動が必要です。 \nスタートアップスクリプトなどを置く場所があるのでしょうか?\n\n下記のスレッドではlaunchctlを利用する方法が掲載されていました。 \nしかし内容が古く(10.6)、自分もmac portsを利用していた頃はlaunchctlを使っていましたが、今でもそういったやり方になるのでしょうか? \n<https://stackoverflow.com/questions/2564394/add-a-start-up-item-via-command-\nline-mac>", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T15:59:30.787", "favorite_count": 0, "id": "8701", "last_activity_date": "2015-04-02T21:25:01.223", "last_edit_date": "2017-05-23T12:38:55.250", "last_editor_user_id": "-1", "owner_user_id": "8801", "post_type": "question", "score": 1, "tags": [ "macos" ], "title": "Mac OS X 10.xで起動時に特定のコマンドを実行するには", "view_count": 607 }
[ { "body": "参考:\n\n * homebrew の Apache 自動起動設定 <http://kazuomabuo.hatenablog.jp/entry/2014/06/17/232728>\n\n * brew servicesを使ってHomebrewでインストールしたMySQLを自動起動する <http://cockscomb.hatenablog.com/entry/2014/04/05/153451>", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-02T21:25:01.223", "id": "8703", "last_activity_date": "2015-04-02T21:25:01.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "2987", "parent_id": "8701", "post_type": "answer", "score": 0 } ]
8701
8703
8703
{ "accepted_answer_id": "8712", "answer_count": 1, "body": "お世話になります。 \nXcodeのStoryboardでViewのサイズ取得について質問があります。 \nマルチデバイス対応をしたくて、AutoLayoutを利用しています。 \n添付画像のツールバーは高さ44と左右のSpacingを0にConstraints設定しています。 \nラベルは一番下はツールバーに対してBottom Spaceと、上のラベルに対するTop\nSpaceとのConstraintsを、以下他のラベルも上下関係のConstraintsを設定しています。 \n上にある赤い部分はViewで、Top Spaceを0に、左右のSpacingを0に、Bottom\nSpaceを一番上のラベルに対して5のConstraintsを設定しています。 \n動作させると赤いViewはデバイスに対して大きさをきちんと変えてくれるのですが、この「Constraintsの制約によって大きさの変わったView」の正確なサイズを取得する事はできますか? \nご教示頂ければ幸いです。\n\n![Storyboard画面](https://i.stack.imgur.com/6iTdj.jpg)\n\n追記:4/5 \nご指摘に従って再度試してみました。 \nviewDidLayoutSubviewsで \n[self.view layoutIfNeeded]; \nの後に数値を取得したところ、正しい値を取得できました。 \n有難うございました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T00:51:59.993", "favorite_count": 0, "id": "8706", "last_activity_date": "2015-04-05T00:41:20.643", "last_edit_date": "2015-04-05T00:41:20.643", "last_editor_user_id": "8083", "owner_user_id": "8083", "post_type": "question", "score": 1, "tags": [ "ios", "xcode", "storyboard" ], "title": "XcodeのAutoLayoutについて", "view_count": 1044 }
[ { "body": "取得したいタイミングで、`UIView`のプロパティ「`frame`」を取得すれば、Constraintによって変更された後の大きさと位置になっています。\n\n`\\- (void)viewDidAppear:(BOOL)animated`メソッドや`\\-\n(void)viewDidLayoutSubviews`メソッドをオーバーライドして、取得すれば、自動レイアウト適用後のサイズと位置が取れます。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T04:01:09.857", "id": "8712", "last_activity_date": "2015-04-03T06:13:30.547", "last_edit_date": "2015-04-03T06:13:30.547", "last_editor_user_id": "7362", "owner_user_id": "8986", "parent_id": "8706", "post_type": "answer", "score": 1 } ]
8706
8712
8712
{ "accepted_answer_id": "8718", "answer_count": 2, "body": "結論から言うと、 \n \n \n**どうしたらAtomの日本語化ができるのでしょうか?**\n\n \n\nAtomをWindows7の環境にインストールしました。 \nそしてメニューの日本語化のためlocalizationプラグインをインストールし再起動したのですが \n日本語化になりません。\n\nそもそもメニューの[Packages]に[localization]が表示されていません。 \n調べたところ、Windowsではreplaceする文言がマッチしていないため、できなかったという記事もありました。 \n \n \n**Windowsではできないのでしょうか? \nまた他の方法によって日本語化できる方法はあるでしょうか?** \n \n\nわかる方お願いします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T01:25:13.637", "favorite_count": 0, "id": "8707", "last_activity_date": "2015-04-06T05:41:19.867", "last_edit_date": "2015-04-06T05:39:51.140", "last_editor_user_id": "46", "owner_user_id": "8982", "post_type": "question", "score": 0, "tags": [ "windows", "atom-editor" ], "title": "Atom localizationでの日本語化ができない Windows7", "view_count": 3112 }
[ { "body": "次のリンク先のプラグインを利用して解決したいと思います \n<https://github.com/hinaloe/Atom-Localization/archive/patch-2.zip>\n\nありがとうございました。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T07:39:52.963", "id": "8718", "last_activity_date": "2015-04-06T05:41:19.867", "last_edit_date": "2015-04-06T05:41:19.867", "last_editor_user_id": "8982", "owner_user_id": "8982", "parent_id": "8707", "post_type": "answer", "score": 2 }, { "body": "[この json ファイル](https://github.com/hinaloe/Atom-\nLocalization/blob/patch-2/i18n/win32/japanese.json) を、atom の config フォルダ以下にある\n\n`.atom/packages/localization/i18n/japanese.json`\n\nに上書きすると、多少マシになります。 \n後はご自身で `japanese.json` を編集して、より良い日本語環境にしてみるといいと思います.", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T08:02:22.810", "id": "8720", "last_activity_date": "2015-04-03T08:02:22.810", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "7926", "parent_id": "8707", "post_type": "answer", "score": 2 } ]
8707
8718
8718
{ "accepted_answer_id": "8716", "answer_count": 1, "body": "以下のとおりSampleベースで書いたのですが、tabbarとslidemenuが競合しているのかどっちかしか動きません。両方成立させるためにはどうするべきでしょうか?ちなみにしたのコードだとtabbarしか動きません。\n\n```\n\n <!DOCTYPE HTML>\n <html lang=\"ja\">\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 <link rel=\"stylesheet\" href=\"components/loader.css\">\n <link rel=\"stylesheet\" href=\"css/style.css\">\n <script src=\"components/loader.js\"></script>\n <script src=\"https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js\"></script>\n <script>ons.bootstrap();</script>\n </head>\n <body>\n <ons-tabbar>\n <ons-tab page=\"home.html\" label=\"Home\" icon=\"ion-home\" active=\"true\"></ons-tab>\n <ons-tab page=\"comments.html\" label=\"Comments\" icon=\"ion-chatbox-working\"></ons-tab>\n <ons-tab page=\"tags.html\" label=\"Tags\" icon=\"ion-ios-pricetag\"></ons-tab>\n <ons-tab page=\"settings.html\" label=\"Settings\" icon=\"ion-ios-cog\"></ons-tab>\n </ons-tabbar>\n \n <ons-sliding-menu\n main-page=\"index.html\"\n menu-page=\"menu.html\"\n side=\"left\"\n max-slide-distance=\"250px\"\n var=\"menu\">\n </ons-sliding-menu>\n \n <ons-template id=\"home.html\">\n <ons-page>\n <ons-toolbar>\n <div class=\"left\">\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\">\n <ons-icon icon=\"ion-navicon\" style=\"font-size: 32px; width: 1em;\"></ons-icon>\n </ons-toolbar-button>\n </div>\n <div class=\"center\">Home</div>\n </ons-toolbar>\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Page Contents</p>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"comments.html\">\n <ons-page>\n <ons-toolbar>\n <div class=\"left\">\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\">\n <ons-icon icon=\"ion-navicon\" style=\"font-size: 32px; width: 1em;\"></ons-icon>\n </ons-toolbar-button>\n </div>\n <div class=\"center\">Comments</div>\n </ons-toolbar>\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Page Contents</p>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"tags.html\">\n <ons-page>\n <ons-toolbar>\n <div class=\"left\">\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\">\n <ons-icon icon=\"ion-navicon\" style=\"font-size: 32px; width: 1em;\"></ons-icon>\n </ons-toolbar-button>\n </div>\n <div class=\"center\">Tags</div>\n </ons-toolbar>\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Page Contents</p>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"feed.html\">\n <ons-page>\n <ons-toolbar>\n <div class=\"left\">\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\">\n <ons-icon icon=\"ion-navicon\" style=\"font-size: 32px; width: 1em;\"></ons-icon>\n </ons-toolbar-button>\n </div>\n <div class=\"center\">Feed</div>\n </ons-toolbar>\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Page Contents</p>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"settings.html\">\n <ons-page>\n <ons-toolbar>\n <div class=\"left\">\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\">\n <ons-icon icon=\"ion-navicon\" style=\"font-size: 32px; width: 1em;\"></ons-icon>\n </ons-toolbar-button>\n </div>\n <div class=\"center\">Settings</div>\n </ons-toolbar>\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Page Contents</p>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"page1.html\">\n <ons-page>\n <ons-toolbar>\n <div class=\"left\">\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\">\n <ons-icon icon=\"ion-navicon\" style=\"font-size: 32px; width: 1em;\"></ons-icon>\n </ons-toolbar-button>\n </div>\n <div class=\"center\">page1</div>\n </ons-toolbar>\n <p style=\"text-align: center; color: #999; padding-top: 100px;\">page1 Contents</p>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"page2.html\">\n <ons-page>\n <ons-toolbar>\n <div class=\"left\">\n <ons-toolbar-button onclick=\"menu.toggleMenu()\">\n <ons-icon icon=\"ion-navicon\" style=\"font-size: 32px; width: 1em;\"></ons-icon>\n </ons-toolbar-button>\n </div>\n <div class=\"center\">Page 2</div>\n </ons-toolbar>\n <p style=\"text-align: center; color: #999; padding-top: 100px;\">Page2 Contents</p>\n </ons-page>\n </ons-template>\n \n <ons-template id=\"menu.html\">\n <ons-list><ons-list-item modifier=\"chevron\" onclick=\"menu.setMainPage('page1.html', {closeMenu: true})\">page1.html</ons-list-item>\n <ons-list-item modifier=\"chevron\" onclick=\"menu.setMainPage('page2.html', {closeMenu: true})\">page2.html</ons-list-item>\n </ons-list>\n </ons-template>\n \n </body>\n </html>\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T02:49:31.963", "favorite_count": 0, "id": "8708", "last_activity_date": "2015-04-03T06:59:08.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": null, "post_type": "question", "score": 0, "tags": [ "onsen-ui" ], "title": "Onsen-uiでtabbarとslidemenuを共存させる方法", "view_count": 1534 }
[ { "body": "こんな感じでいかがでしょう。 \nざっくり大事そうな所を書くと\n\n1.`ons-sliding-menu`の`main-page`をタブバーを配置したhtmlに変更 \n2.`menu.html`のリストクリック時の処理をアクティブタブの変更 + スライドメニューを閉じるに変更\n\nとなっています。\n\n```\n\n ons.bootstrap();\n```\n\n```\n\n <link href=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.2.2/build/css/onsenui.css\" rel=\"stylesheet\"/>\r\n <link href=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.2.2/build/css/onsen-css-components.css\" rel=\"stylesheet\"/>\r\n <script src=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.2.2/build/js/angular/angular.min.js\"></script>\r\n <script src=\"https://cdn.rawgit.com/OnsenUI/OnsenUI/1.2.2/build/js/onsenui.min.js\"></script>\r\n \r\n <ons-sliding-menu var=\"menu\" menu-page=\"menu.html\" main-page=\"tabbar.html\" side=\"left\" type=\"push\" max-slide-distance=\"200px\">\r\n </ons-sliding-menu>\r\n \r\n <ons-template id=\"tabbar.html\">\r\n <ons-tabbar var=\"tabbar\">\r\n <ons-tab page=\"home.html\" label=\"Home\" icon=\"ion-home\" active=\"true\"></ons-tab>\r\n <ons-tab page=\"comments.html\" label=\"Comments\" icon=\"ion-chatbox-working\"></ons-tab>\r\n <ons-tab page=\"tags.html\" label=\"Tags\" icon=\"ion-ios-pricetag\"></ons-tab>\r\n <ons-tab page=\"settings.html\" label=\"Settings\" icon=\"ion-ios-cog\"> \r\n </ons-tab>\r\n </ons-tabbar>\r\n </ons-template>\r\n \r\n <ons-template id=\"home.html\">\r\n <ons-toolbar>\r\n <div class=\"left\">\r\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\"><ons-icon icon=\"bars\"></ons-icon></ons-toolbar-button>\r\n </div>\r\n <div class=\"center\">Home</div>\r\n </ons-toolbar>\r\n \r\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Home Page Contents</p>\r\n </ons-template>\r\n \r\n <ons-template id=\"comments.html\">\r\n <ons-toolbar>\r\n <div class=\"left\">\r\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\"><ons-icon icon=\"bars\"></ons-icon></ons-toolbar-button>\r\n </div>\r\n <div class=\"center\">Comments</div>\r\n </ons-toolbar>\r\n \r\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Comments Page Contents</p>\r\n </ons-template>\r\n \r\n <ons-template id=\"tags.html\">\r\n <ons-toolbar>\r\n <div class=\"left\">\r\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\"><ons-icon icon=\"bars\"></ons-icon></ons-toolbar-button>\r\n </div>\r\n <div class=\"center\">Tags</div>\r\n </ons-toolbar>\r\n \r\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Tags Page Contents</p>\r\n </ons-template>\r\n \r\n <ons-template id=\"settings.html\">\r\n <ons-toolbar>\r\n <div class=\"left\">\r\n <ons-toolbar-button ng-click=\"menu.toggleMenu()\"><ons-icon icon=\"bars\"></ons-icon></ons-toolbar-button>\r\n </div>\r\n <div class=\"center\">Settings</div>\r\n </ons-toolbar>\r\n \r\n <p style=\"padding-top: 100px; color: #999; text-align: center\">Settings Page Contents</p>\r\n </ons-template>\r\n \r\n <ons-template id=\"menu.html\">\r\n <ons-list>\r\n <ons-list-item modifier=\"chevron\" onclick=\"tabbar.setActiveTab(0), menu.closeMenu()\">\r\n Home\r\n </ons-list-item>\r\n <ons-list-item modifier=\"chevron\" onclick=\"tabbar.setActiveTab(1), menu.closeMenu()\">\r\n Comments\r\n </ons-list-item>\r\n <ons-list-item modifier=\"chevron\" onclick=\"tabbar.setActiveTab(2), menu.closeMenu()\">\r\n Tags\r\n </ons-list-item>\r\n <ons-list-item modifier=\"chevron\" onclick=\"tabbar.setActiveTab(3), menu.closeMenu()\">\r\n Settings\r\n </ons-list-item>\r\n </ons-list>\r\n </ons-template>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T06:59:08.223", "id": "8716", "last_activity_date": "2015-04-03T06:59:08.223", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3516", "parent_id": "8708", "post_type": "answer", "score": 0 } ]
8708
8716
8716
{ "accepted_answer_id": null, "answer_count": 1, "body": "application:(UIApplication *)application\nopenURL:を用いてURLスキームより独自のアプリを起動しているのですが、TOPページより何回か遷移したDetailページをいきなり表示させることはできますでしょうか?また、そのページから戻る処理を行いTOPに戻ることもできればよいです。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T02:51:00.820", "favorite_count": 0, "id": "8709", "last_activity_date": "2016-10-29T11:21:50.537", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "8060", "post_type": "question", "score": 0, "tags": [ "ios" ], "title": "application:openURL:を使ってViewControllerを指定したい。", "view_count": 836 }
[ { "body": "UINavigationControllerで管理しているビューコントローラでしたら、application:openURL:sourceApplication:annotation:メソッドで、Detailページのビューコントローラのインスタンスを確保し、-[UINavigationController\npushViewController:animated:]メソッドでDetailページを表示すすることで実装できると思います。", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T03:56:45.807", "id": "8711", "last_activity_date": "2015-04-03T08:35:33.153", "last_edit_date": "2015-04-03T08:35:33.153", "last_editor_user_id": "8986", "owner_user_id": "8986", "parent_id": "8709", "post_type": "answer", "score": 1 } ]
8709
null
8711
{ "accepted_answer_id": null, "answer_count": 1, "body": "「Onsen UI最小限のテンプレート」で「Onsen UI\nGuide」にある「アラートダイアログを使う」を行いたいのですが、「アラートダイアログを使う」のHTMLとJSのソースコードをどのように「Onsen\nUI最小限のテンプレート」に適用すればアラートダイアログを出力できるのでしょうか。\n\nindex.htmlの\n\n```\n\n <script>\n ons.bootstrap();\n </script>\n \n```\n\nを\n\n```\n\n <script>\n ons.bootstrap();\n \n .controller('NotificationController', function($scope) {\n $scope.alert = function() {\n ons.notification.alert({message: 'An error has occurred!'});\n }\n \n $scope.confirm = function() {\n ons.notification.confirm({\n message: 'Are you sure you want to continue?',\n callback: function(idx) {\n switch(idx) {\n case 0:\n ons.notification.alert({\n message: 'You pressed \"Cancel\".'\n });\n break;\n case 1:\n ons.notification.alert({\n message: 'You pressed \"OK\".'\n });\n break;\n }\n }\n });\n }\n \n $scope.prompt = function() {\n ons.notification.prompt({\n message: \"Please enter your age\",\n callback: function(age) {\n ons.notification.alert({\n message: 'You are ' + parseInt(age || 0) + ' years old.'\n });\n }\n });\n }\n });\n \n </script>\n \n```\n\nにするとプレビュー画面は真っ白になります\n\nこれを無くして page1.html の\n\n```\n\n </ons-page>\n \n```\n\nの直前に\n\n```\n\n <ons-list ng-controller=\"NotificationController\">\n <ons-list-item ng-click=\"alert()\" modifier=\"tappable\">\n Alert\n </ons-list-item>\n <ons-list-item ng-click=\"confirm()\" modifier=\"tappable\">\n Confirm\n </ons-list-item>\n <ons-list-item ng-click=\"prompt()\" modifier=\"tappable\">\n Prompt\n </ons-list-item>\n </ons-list>\n \n```\n\nを加えただけだと、画面上に\"Alert Confirm Prompt\"という文字が表示されます。\n\n本当に初歩的なことと思いますが、どうかご回答をお願いいたします。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T03:22:43.710", "favorite_count": 0, "id": "8710", "last_activity_date": "2015-04-03T09:30:58.197", "last_edit_date": "2015-04-03T03:45:23.493", "last_editor_user_id": "49", "owner_user_id": "9140", "post_type": "question", "score": 1, "tags": [ "monaca", "onsen-ui" ], "title": "「Onsen UI最小限のテンプレート」で「Onsen UI Guide」にある「アラートダイアログを使う」を行うには", "view_count": 581 }
[ { "body": "こんな感じでいけると思います。\n\nindex.html\n\n```\n\n <script>\n ons.bootstrap()\n .controller('NotificationController', function($scope) {\n $scope.alert = function() {\n ons.notification.alert({message: 'An error has occurred!'});\n }\n \n $scope.confirm = function() {\n ons.notification.confirm({\n message: 'Are you sure you want to continue?',\n callback: function(idx) {\n switch(idx) {\n case 0:\n ons.notification.alert({\n message: 'You pressed \"Cancel\".'\n });\n break;\n case 1:\n ons.notification.alert({\n message: 'You pressed \"OK\".'\n });\n break;\n }\n }\n });\n }\n \n $scope.prompt = function() {\n ons.notification.prompt({\n message: \"Please enter your age\",\n callback: function(age) {\n ons.notification.alert({\n message: 'You are ' + parseInt(age || 0) + ' years old.'\n });\n }\n });\n }\n });\n </script>\n \n```\n\npage1.html\n\n```\n\n <ons-page>\n <ons-toolbar>\n <div class=\"center\">Navigator</div>\n </ons-toolbar>\n \n <ons-list ng-controller=\"NotificationController\">\n <ons-list-item ng-click=\"alert()\" modifier=\"tappable\">\n Alert\n </ons-list-item>\n <ons-list-item ng-click=\"confirm()\" modifier=\"tappable\">\n Confirm\n </ons-list-item>\n <ons-list-item ng-click=\"prompt()\" modifier=\"tappable\">\n Prompt\n </ons-list-item>\n </ons-list>\n </ons-page>\n \n```\n\n質問に書いてあるコードの`ons.bootstrap();`のセミコロンは不要です。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T06:15:26.070", "id": "8714", "last_activity_date": "2015-04-03T06:15:26.070", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3516", "parent_id": "8710", "post_type": "answer", "score": 1 } ]
8710
null
8714
{ "accepted_answer_id": null, "answer_count": 0, "body": "[MailNow](https://itunes.apple.com/us/app/mail-now-one-tap-speed-\nmailer/id825674091?ls=1&mt=8)というアプリを作っているのですが、iOS8.2から突然が不具合が発生しました。 \nいろいろ試行錯誤してみたのですが、手詰まりになってしまったので助けていただけませんか。\n\n*やりたいこと \nTableViewのセルをタップすると、plistに格納されたメールアドレス、タイトル、本文情報を読み込んで、URL\nscheme経由でiPhoneのメーラーに渡す\n\n*症状 \nメーラーが起動していないときはうまくいく(送信ボタンが有効になる)が、メーラーを1度起動すると送信ボタンが無効になってしまう。メーラーを終了すれば、送信ボタンが再び有効になる\n\n[症状を動画で撮りました](https://www.youtube.com/watch?v=RCeg0NDJFiw)\n\nURL scheme起動時のコードは下記のとおりです。 \n問題解決のヒントを頂けたら幸いです。\n\n```\n\n - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {\n [tableView deselectRowAtIndexPath:indexPath animated:YES];\n \n NSDictionary *ContentDetail = [_defaultList objectAtIndex:indexPath.row];\n NSString *email = ContentDetail[@\"email\"];\n NSString *subject = ContentDetail[@\"subject\"];\n NSString *message = ContentDetail[@\"message\"];\n \n //UTF-8でエンコード\n NSString*encEmail =\n [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];\n NSString*encSubject =\n [subject stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];\n NSString*encText =\n [message stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];\n \n NSString *scheme;\n if (![subject isEqualToString:@\"\"] && ![message isEqualToString:@\"\"]) {\n scheme = [NSString stringWithFormat:@\"mailto:%@?subject=%@&body=%@\",encEmail,encSubject,encText];\n } else if (![subject isEqualToString:@\"\"]) {\n scheme = [NSString stringWithFormat:@\"mailto:%@?subject=%@\",encEmail,encSubject];\n } else if (![message isEqualToString:@\"\"]) {\n scheme = [NSString stringWithFormat:@\"mailto:%@?body=%@\",encEmail,encText];\n } else {\n scheme = [NSString stringWithFormat:@\"mailto:%@\", encEmail];\n }\n \n [[UIApplication sharedApplication] openURL:[NSURL URLWithString:scheme]];\n \n }\n \n```", "comment_count": 2, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T06:55:23.607", "favorite_count": 0, "id": "8715", "last_activity_date": "2015-04-03T07:04:45.477", "last_edit_date": "2015-04-03T07:04:45.477", "last_editor_user_id": "682", "owner_user_id": "682", "post_type": "question", "score": 3, "tags": [ "objective-c", "ios8" ], "title": "iOS URLSchemeでメールを送る時、送信ボタンが無効になってしまう", "view_count": 332 }
[]
8715
null
null
{ "accepted_answer_id": null, "answer_count": 1, "body": "javascript(jQueryなど可)を使ってドラッグ可能な要素を作りたいのですがやり方が全くわかりません。\n\njQuery UIを使えばドラッガブルな要素を作るのは簡単ですが、以下の条件にしたいときはどうしたらよいのでしょうか。\n\n * 縦には動かせない\n * 横には10pxずつ動かすことができる\n * 指定した範囲を超えることはできない\n\nまた、Aの要素に近づいたらAに吸い付いてピタッと止まるというものも教えていただけますか。\n\nあと、こういうUIの動きはどういうところで学べますか? \n今まで決まった動きをするということしかやったことが無いため、これから挑戦しようと思っています。", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T07:44:42.973", "favorite_count": 0, "id": "8719", "last_activity_date": "2015-04-03T08:16:19.070", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5855", "post_type": "question", "score": 1, "tags": [ "javascript", "jquery", "jquery-ui" ], "title": "ドラッグすると10pxずつ動く要素を作りたい", "view_count": 342 }
[ { "body": "JQuery\nUIの[`draggable`](http://api.jqueryui.com/draggable/)で全ての条件を満たすことができると思います。\n\n```\n\n $(\"#draggable\").draggable({\r\n axis: \"x\", // 縦には動かせない\r\n grid: [10, 10], // 横には10pxずつ動かすことができる\r\n containment: \"#container\", // 指定した範囲を超えることはできない\r\n snap: \"#anchor\", // Aの要素に近づいたらAに吸い付いてピタッと止まる\r\n snapTolerance: 50\r\n });\n```\n\n```\n\n <script src=\"//code.jquery.com/jquery-1.10.2.js\"></script>\r\n <script src=\"//code.jquery.com/ui/1.11.4/jquery-ui.js\"></script>\r\n \r\n <div id=\"container\" style=\"background-color: #ccc; width:400px; height: 100px;\">\r\n <div id=\"draggable\" style=\"background-color: #000; color: #fff; float:left;\">Drag me!</div>\r\n <div id=\"anchor\" style=\"background-color: #f00; float:right\">Snap to me!</div>\r\n </div>\n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T08:16:19.070", "id": "8721", "last_activity_date": "2015-04-03T08:16:19.070", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3371", "parent_id": "8719", "post_type": "answer", "score": 4 } ]
8719
null
8721
{ "accepted_answer_id": "8739", "answer_count": 1, "body": "ibatisで受け取ったList型のキーワードで \nキーワードの数だけSELECTを行いたいと考えています。 \nキーワードと一致した分だけポイントを加算していく方法は無いでしょうか? \nイメージとしては下記のSQLのように加算していきたいと考えています。 \n解決方法が有ればどなたかお願い致します。\n\n```\n\n SELECT tbl1.id,point1 + point2 AS point\n FROM \n (SELECT user.id, user_point1.point1\n FROM tbl_user AS user\n (SELECT id,100::integer AS point1\n FROM tbl_user\n WHERE user_name LIKE '%田中%') AS user_point1\n ON user.id = user_point1.id\n ) AS tbl1\n FULL OUTER JOIN\n (SELECT id,100::integer AS point2\n FROM tbl_user\n WHERE user_name ILIKE '%田中%') AS user_point2\n ON tbl1.id = user_point2.id\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T11:54:02.277", "favorite_count": 0, "id": "8730", "last_activity_date": "2015-04-04T01:25:59.517", "last_edit_date": "2015-04-03T12:02:15.613", "last_editor_user_id": "49", "owner_user_id": "8876", "post_type": "question", "score": 0, "tags": [ "sql" ], "title": "ibatisを用いたSQL", "view_count": 633 }
[ { "body": "質問にあるSQLを出力するためには、キーワードの他にテーブルのエイリアスとしてインデックスの値が必要となります。 \n`MyBatis`であれば`<foreach>`要素で`index`が参照できますが、`iBatis`の`<iterate>`では難しいのではないかと思います。\n\n同様の結果が取得できるエイリアスが不要なSQLとしては\n\n```\n\n SELECT id\n , (CASE WHEN user_name LIKE '%田中%' THEN 100 ELSE 0 END)\n + (CASE WHEN user_name LIKE '%hoge%' THEN 100 ELSE 0 END)\n + (CASE WHEN user_name LIKE '%fuga%' THEN 100 ELSE 0 END) AS point\n FROM tbl_user\n \n```\n\nや\n\n```\n\n SELECT id, SUM(point) AS point\n FROM\n (\n SELECT id, 100 AS point FROM tbl_user\n UNION ALL\n SELECT id, 100 AS point FROM tbl_user\n UNION ALL\n SELECT id, 100 AS point FROM tbl_user\n )\n \n```\n\nが思いつきます。", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-04T01:25:59.517", "id": "8739", "last_activity_date": "2015-04-04T01:25:59.517", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "5750", "parent_id": "8730", "post_type": "answer", "score": 1 } ]
8730
8739
8739
{ "accepted_answer_id": "8732", "answer_count": 2, "body": "`swift`で`for-in`文を使おうとしているのですが、うまくいきません。 \n下のコードの`wordData.append`の行で、「`RLMObject does not have a member named\nword`」というエラーが表示されてしまいます。 \n`Word`というクラスには`word`というメンバ変数が存在しています。 \nなので初歩的なことでしょうけど、どうすればいいかわからなくなり詰まってしまいました。 \nどなたか分かる方がいればどこが間違っているのかを教えていただきたいです。 \nすみませんが、よろしくお願いします。\n\n```\n\n var wordData: [String] = []\n let word = Word.objectsWhere(\"speech == A\")\n \n for wordStore in word {\n wordData.append(wordStore.word)\n }\n \n```", "comment_count": 0, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T14:45:31.917", "favorite_count": 0, "id": "8731", "last_activity_date": "2015-04-04T00:30:15.530", "last_edit_date": "2015-04-03T14:57:44.130", "last_editor_user_id": "3639", "owner_user_id": "5210", "post_type": "question", "score": 2, "tags": [ "swift", "realm" ], "title": "for in 文の使い方", "view_count": 216 }
[ { "body": "ダウンキャストが必要です。\n\n```\n\n for item in word {\n if let wordStore = item as? Word {\n wordData.append(wordStore.word)\n }\n }\n \n```", "comment_count": 1, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T14:57:17.530", "id": "8732", "last_activity_date": "2015-04-03T14:57:17.530", "last_edit_date": null, "last_editor_user_id": null, "owner_user_id": "3639", "parent_id": "8731", "post_type": "answer", "score": 3 }, { "body": "※ Realmを使っていると知らず以下の様な回答をしました・・・ダウンキャストが対応として正しいと思います。\n\nWord#objectsWhereはどのように宣言されていますか?\n\n```\n\n class Word {\n class func objectsWhere(where: String) -> [Word] {\n // Do something.\n }\n }\n \n```\n\nのようになっていれば以下のコードはコンパイル可能だと思います(変数名をわかりやすく変更しましたが、やっていることは同じです)\n\n```\n\n var wordData: [String] = []\n let wordArray = Word.objectsWhere(\"speech == A\")\n \n for word in wordArray {\n wordData.append(word.word)\n }\n \n```", "comment_count": 3, "content_license": "CC BY-SA 3.0", "creation_date": "2015-04-03T23:50:46.450", "id": "8735", "last_activity_date": "2015-04-04T00:30:15.530", "last_edit_date": "2015-04-04T00:30:15.530", "last_editor_user_id": "8666", "owner_user_id": "8666", "parent_id": "8731", "post_type": "answer", "score": 1 } ]
8731
8732
8732