How to convert the each date components to particular date format in swift 2

Uncategorized
Question: I can obtain the individual date components as:let dateString = String(dataModel.dateCompletedDay) + String(dataModel.dateCompletedMonth) + String(dataModel.dateCompletedYear) print(dateString) //2532016 Now how can i to convert it to DD/MM/YYYY format? Answer: I suggest to use Calendar, DateComponents and DateFormatter (Swift 3) let components = DateComponents(year:dataModel.dateCompletedYear, month: dataModel.dateCompletedMonth, day: dataModel.dateCompletedDay) let calendar = Calendar(identifier: .gregorian)! let date = calendar.date(from: components)! let formatter = DateFormatter() formatter.dateFormat = "dd/MM/yyyy" let dateString = formatter.string(from: date) Additionally this is a simple solution which is supposed to work also in Swift 2 let dateString = String(format: "%02ld/%02ld/%ld", dataModel.dateCompletedDay, dataModel.dateCompletedMonth, dataModel.dateCompletedYear) Read more
Read More

how to make div float center of viewport always using CSS

Uncategorized
Question: The goal is to have the div (willscape-holder in this case) containing the two images float in the middle of the viewport always. Is there a way to do this without having to do media queries adjusting the margin top and bottom for every type of screen? Thank you for help in advance. body { background: url(../images/willscape-bg.png); background-repeat: no-repeat; background-size: 100% 100%; /* background-position: center top; */ background-attachment: fixed; } .container { height: 100vh; } .willscape-holder { width: 100%; max-width: 350px; margin: 0 auto; padding: 0 20px; } #willscape-logo { padding: 0 60px; width: 100%; } #willscape-title { width: 100%; max-width: 500px; } Answer: You can use the viewport's height and the css calc function to calculate the top margin for the images:.willscape-holder { width: 100%; max-width: 350px; margin:…
Read More

Parse all XML text using XMLPullParser

Uncategorized
Question: I have a question that is similar to [this one here][1] I have read tutorials about XMLPullParser and do not seem to get this one. I have an XML tag I want to parse using XMLPullParser : outcome result I want to get the result ": outcome result." Because I am reading this XML from an online base. It may change. For instance ::degree or measure of succeeding The question is how do I parse and get all the text in the tag "dt" irrespective of the name of the tags in it? This is what I have tried but it is not working. while (parser.next() != END_TAG){ if (parser.getEventType() != TEXT) { continue; } else if (parser.getEventType() == TEXT) { Log.d("Text", parser.getText()+" in the likelihood"); stringBuilder.append(parser.getText()); parser.next(); }…
Read More

The imported packages in source codes are as submodules of my package when using setup.py

Uncategorized
Question: I got a problem when using setup.py. An instances maybe clear: Suppose I have a.py in my source folder as a module. I import os and implement a function named 'b' in a.py. After ruunning python setup.py install, I should be able to import a and call a.b. But I can also call a.os in my case. why does this happen? a.os should not appear, right? How to solve this issue? Looking for help! Answer: It happens because you imported os in a.py, and then you imported a.py as a module. You may either redesign the a into a class or overwrite os as a function in a.py. Hope this helps. Read more
Read More

How can I get the previous resolved query to webhook in API.AI?

Uncategorized
Question: I have a webhook setup with api.ai. The webhook is integrated with youtube api which search for given keywords and return corresponding video. I facing a trouble like below Example conversations with bot:Me: Base 10 equations bot: Which grade are you studying ? me: grade 3 Then i want to search the keyword “Base 10 equations grade 3” using webhook youtube api and send the most relevant video to api.ai. I’m getting only the parameter grade 3 to the Webook. But i want both “base 10 equations” and “grade 3” to the webhook to proceed. Can somebody please help me how to proceed ?? Thanks. Answer: Read more
Read More

Tensorflow: Where is gen_logging_ops source code?

Uncategorized
Question: I have a question about this import from tensorflow/tensorflow/python/summary/summary.py line 53: from tensorflow.python.ops import gen_logging_ops as _gen_logging_ops When I go to the directory tensorflow/python/ops, there is no such file called gen_logging_ops. I am wondering how this worked out? BTW, I am tracking the r1.3 version. Any suggestion is highly appreciated! Answer: I had a similar question. gen_ files are files generated at build time by bazel and if you build TensorFlow yourself, they can be found in the bazel-genfiles/ directory. The tf_op_gen_wrapper_py bazel rule is the rule generating the gen_ files. As explained, in this answer, this rule generates all the python wrapper of the ops defined in this library:py_library( name = "logging_ops", srcs = ["ops/logging_ops.py"], srcs_version = "PY2AND3", deps = [ ":framework_for_generated_wrappers", ":logging_ops_gen", ":util", ], ) In the…
Read More