Posts

Showing posts from 2016

[HTML5] A Beginner's Guide to Using the Application Cache

Introduction It's becoming increasingly important for web-based applications to be accessible offline. Yes, all browsers can cache pages and resources for long periods if told to do so, but the browser can kick individual items out of the cache at any point to make room for other things. HTML5 addresses some of the annoyances of being offline with the  ApplicationCache  interface. Using the cache interface gives your application three advantages: Offline browsing - users can navigate your full site when they're offline Speed - resources come straight from disk, no trip to the network. Resilience - if your site goes down for "maintenance" (as in, someone accidentally breaks everything), your users will get the offline experience The Application Cache (or AppCache) allows a developer to specify which files the browser should cache and make available to offline users. Your app will load and work correctly, even if the user presses the refresh button while th...

AngularJS Application Calling Order

Here's the calling order: app.config() app.run() directive's compile functions (if they are found in the dom) app.controller() directive's link functions (again, if found) Here's a  simple demo  where you can watch each one executing (and experiment if you'd like). From  Angular's module docs : Run blocks  - get executed after the injector is created and are used to kickstart the application. Only instances and constants can be injected into run blocks. This is to prevent further system configuration during application run time. Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.

Regular Expression - An Introduction

Image
What is a regular expression ? "A regular expression is a pattern that is matched against a subject string from left to right" . Well, that was textbook answer. But in simple terms, regular expression is a string used for find and replacing strings in other large strings. You can even say that regular expression (a.k.a  regex  or  regexp ) are fourth generation (4G) wilcards, that we used in the good ol' days of DOS. (But don't say that I said so, otherwise those perl experts are going to bite my head off for this remark. Why ? Because ... regexp are so powerful, yet easy to use, and saying that they are just wilcard, would be an insult.  So i didn't say it, ok ) Why use regular expression ? Hello ... ?!? Are you paying attention. I just said it, they are  powerful  and  easy  to use, that is why! Ok, seriouly, if you are serious about web development, you will have to use them one time or other be it in JavaScript,  PHP ,  P...