Tag Info

New answers tagged

0

The reason you are probably not finding those examples is because that would mean implementing a complete templating system in PHP, which is far beyond the scope of a lot of tutorials. A good templating engine does not mingle PHP into the view, but there will always be binding logic in your views. There are plenty of templating frameworks out there and ...


0

See this: ClusterizeJS This plugin makes it possible to scroll a huge number of items while keeping DOM lean and small. It removes out of the view items and replaces them with dummy elements that are dynamically resized so scroll positioning is retained as expected. Facebook doesn't do it this way though, but I suppose this is the best way to have good ...


5

You should respond with HTTP 400: Bad Request. The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. The response should include an explanation of why the request was rejected—e.g., “Invalid JSON” .


2

You're on the right track - each web page request needs to be tracked, but you need to do this is a very simple manner. Then the problem shifts to statistical analysis of these counters, and that's quite easy. Forget storing each webpage in the DB, instead you need to cache it in memory (as you don't really care about flow rate when the system is restarted) ...


0

If you want to roll your own, instead of storing based on timestamp, you could use the thread id or equivalent and current minute of day to create a unique key composite key and increment the associated value every time you get a request. Then after each minute, you can aggregate all the requests for that minute across all threads to get a utilization value ...


2

The easiest way to find out is to disable the User-Agent customization and see if the problem goes away :) . In general, User-Agent is not guaranteed to be what you set. For example, a corporate firewall might use deep packet inspection to rewrite User-Agent and reduce browser entropy. Philosophically, I think modifying User-Agent to include additional ...


0

I would say: "Validate in every place you can do so." The sooner you validate, the sooner you provide feedback to the user of the system. This reduces eventual errors, provides hands-on training and eventually improves the user experience. You need to validate in your business logic, because there are many business rules that won't make it to your UI. ...


1

What you probably want to do here is use a repository... This would have your querying methods directly related to your Object and would use and instance of the DB as part of its constructor: $repo = new MovieRepository($db); $movies = $repo->findAll(); And or writing you might have: $repo = new MovieRepository($db); $movie = $repo->findById($id); ...


0

If technology allows you you should validate in multiple layers - so someone with a security inclination would argue - "why not both?". But to keep it simple I would suggest option 2. The reason being option 2 allows you to unit test your application and your unit test will be bound by the restrictions of the actually deployed application. Option 1 is ...


2

Custom elements are a specification part of the Web Components standard, along with Shadow DOM, Templates and HTML imports. From http://webcomponents.org/articles/introduction-to-custom-elements/: Custom Elements enable developers to create their own custom HTML tags, let them use those tags in their sites and apps, and enable easier component reuse. ...


2

It is quite easy to get frustrated with management in these situations but keep in mind that your company only exists to make money. Having a super useful and secure application is not necessarily a worthwhile goal from a manager's point of view. You have not mentioned in what format the data is pushed to clients but if it is in HTML form then have you ...


2

yes, your manager is right - security flaws don't make themselves, they were all produced by a developer who didn't consider every case. Because software can be complicated, we can all be guilty of this. So you design a system defensively to help prevent us from screwing up. One day some requirement will come in that requires eval, and then.. So, you can ...


0

A Node program is at its core a normal program, it isn't even a web-server unless you write code specifically to make it so (though that is pretty easy with the built-in HTTP library). Your program will get the HTTP requests, and your code can respond any way you like, using all the resources otherwise available to the program. If JavaScript was old-school ...


0

Unlike all other servers you have mentioned, Node is single threaded, but asynchronous - as some have mentioned here, it schedules callbacks instead of waiting for operation to execute and runs callbacks when the operation is complete, however a number of other operations might have been processed in between with the same thread. Caveats: Although it's a ...


6

Let's immediately get the Turing-completeness disclaimer out of the way and say any language can probably approximate any runtime feature of any other language. Good? Good. The main difference between the Node.js approach and a Python threaded-server (or a typical Java HTTP server implementation) is that Node.js is single threaded while the latter two are ...



Top 50 recent answers are included