where better to get user IP in cakephp [closed] - cakephp

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Where is it better
in bootstrap.php or app_controller.php
it's needed for geolocation.

In 1.x use
RequestHandlerComponent::getClientIP()
it already covers all problems you might be facing
and yes, "at the point in time at which at which you need it"
For 2.x it's best to use
$this->request->getClientIp()
from inside the controller as documented on http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#requesthandlercomponent

It really depends on what you are using the IP for. If you need it in all parts of your code, then the app_controller is the place to put it. If you only need it for log in for example, then put it in the users_controller.
That being said, it may be better to write a session variable and then it is available wherever you need it without the code overhead.

echo $_SERVER['REMOTE_ADDR'];
or
$remIP = $_SERVER['REMOTE_ADDR'];
at the point in time at which at which you need it. That way you can be sure it's current, although I'm not sure if it could get stale. It's there in the server all of the time, so there's no concept of when to assign it - just get it when you need it.

Related

How to use AngularJS for writing the interface of a node-red custom node? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am referring to the .html file associated with the node, not to the UI related nodes. I asked on the official forum and the response was that at the moment Angular is not used. My opinion is that it can be useful for writing nodes faster, without having to use only jQuery.
Thank you!
Short answer, at the this time you can not do this. Asking on here isn't going to get you a different answer.
If you want this to change then you need to make a very strong case (on the forum) as to why this needs to be done. The node's config (as described in the nodes HTML file) really shouldn't be that complicated that it needs a complex framework to lay it out.

Why is there no $interval in AngularJS? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
AngularJS has a $timeout service which acts as a convenience wrapper around setTimeout.
Why is there no equivalent for setInterval?
Since $timeout is calls scope.apply after each call it can get expensive. However creating a simple interval you can decide what watches and apply calls are needed to keep it clean.
For example, if you interval was running once every minute to check if the user's values had changed and optionally saving it if the values had been changed since the last check. Depending on how you write the code, you may never need to update the web page, so your interval can get by without triggering an update.
That doesn't answer the question directly of why $interval isn't provided by default, but I suspect it is because since it is simple to create your own with you specific requirements, it is better to leave it open for you to enhance, instead of providing a default implementation that is too complex, or too inflexible.

Object detection methodologies [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have an assignment of object detection.
I have googled but I didn't find all object detection methods.
Can anyone show me all the methods of object detection?
For starters, have a look at this post.
Then Google around (I'm sorry, you've said you've tried, but I just don't believe that a Google search on object detection gave you zero useful results). Look up things you're not sure about on Wikipedia. Finally, refine your question to be directed at a specific issue. You'll get a lot more useful input that way, and you'll learn more, too.
I don't think anyone here would indulge in teaching you all methods of object detection. To put it bluntly, you're simply asking for too much.

Groovy download files [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I just had a quick question about downloading files. I was reading this page:
http://groovy.codehaus.org/Simple+file+download+from+URL
Can someone explain what the difference is between the two ways explained on that page? (Aside from overriding the leftshift operator) Is there any significance for doing it one way or the other?
The former method is far cleaner and is what you would do in most cases.
The second is effectively enhancing the File object within the use closure. I can't see where it would be useful in this context, but say in your code you were often putting content from urls into files, or you had a dsl where you wanted to allow for that functionality, you could use categories to extend the file object.
Personally, I see the example as really just showing (a rather impractical) use for categories.

Documenting CakePHP components [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm mostly concerned with documenting Controller actions, e.g http://foo.bar/app/thing/action/param. How would you recommend documenting these? I'm less interested in the method of generating the documentation (e.g. phpdoc or doxygen) and more a style of doing it. Should I list the parameters and return values as if I were documenting any other method?
In terms of format, I typically follow the same (well, similar) convention used by the CakePHP project itself (http://book.cakephp.org/view/509/Coding-Standards#Commenting-code-601). It's similar enough to JavaDoc that I found it easy to adopt and works nicely with the phpDoc engine. I do tend to include #param values as well as #return. I often find it helpful to provide a bit of additional explanation for acceptable/expected values.

Resources