Get html contents from iframe using jquery

The following code works fine in all browsers for getting HTML contents from iframe.

Create thumbnail image in codeigniter

Adding the following method as custom helper file and check the below sample.


Remove directory and its sub folders & files in codeigniter

We can extend the core directory helper.  Creating a new file as MY_directory_helper.php and add the following code in helper file to remove directory and it’s sub folders &  files.


Remove index.php in codeigniter using htaccess

Add the following code in htaccess file and place this in project root directory.



Perform ajax call in codeigniter

You can simply add the following jquery code to perform ajax using codeigniter


Clear APC cache in Apache using PHP

The following code will clear the apc cache using PHP


DB synchronization- local and remote DB using SymmetricDS

We can sync local DB (which is running in each physical store) with remote DB (centralized DB) which is running in web.

– Local DB always not connected with internet.
– We can not use mysql replication (two way sync) because it requires that both DB
should run in web. otherwise, remote DB not understand and sync with local DB.
– Even, if we are achieving i.e two way sync in some other way, all remote DB data going to sync with local DB. This is not good idea to maintain all the store details in all places.
– May some tables are one-way sync from remote DB to local DB vice versa.
– May some tables are condition based sync from remote DB to local DB (eg): Products table

Pre Condition
– Assume that we have mysql running in local & remote server
– We had created database in both places (local & remote server) which we are going to sync
– We have created tables in both Database (local & remote server)

– SymmetricDS is best fit for this requirements after reviewing number of open source tools like SqlYog, Todd, MySql Benchmark..etc..,
– It is developed by Java but it can run as standalone application in server. Means, no need tomcat or weblogic servers.
– SymmetricDS should be run in both places (local & remote)
– It is listening and syncing all the changes based on the configuration.

System Requirements
– SymmetricDS is written in Java 5 and requires a Java SE Runtime Environment (JRE) or Java SE Development Kit (JDK) version 5.0 or above.
– It supports MySQL version 5.0.2 and above

Installing SymmetricDS
– Download the source from
– Unzip the file in any directory you choose. This will create a symmetric-ds-3.x.x directory, which corresponds to the version you downloaded.
– Please install the same version in both local & remote system.

SymmetricDS configuration for Remote
– Copy the [samples/] properties files for the server into the [engines] directory of the SymmetricDS installed
– Change the property file name to [] instead of []
– Do the changes in the following property file

– Import configuration tables that is needed for symmetricDS by executing the following
command using CLI. It will create 41 tables with prefix [sym_]

– –Two way sync configuration (or) Default router
The simplest router is a router that sends all the data that is captured by its
associated triggers to all the nodes that belong to the target node group defined in
the router. A router is defined as a row in the ROUTER table. It is then linked to
triggers in theTRIGGER_ROUTER table.

The following SQL statement defines a router that will send data from the ‘corp’ group
to the ‘store’ group.

One way sync configuration (or) Column Match Router
Consider a table that needs to be routed to only nodes in the target group whose
STORE_ID column matches the external id of a node. The following SQL statement will
insert a column router to accomplish that.

SymmetricDS configuration for Local
– Copy the [samples/] properties files for the local into the [engines] directory of the SymmetricDS install
– change the property file name to [] instead of []
– Do the changes in the following property file

– Please apply [store id] from DB table to []
– set the following property in the file to specify where the server node
can be contacted

Starting SymmetricDS
Database setup and configuration is now completed. Time to put SymmetricDS into action.
We will now start both SymmetricDS nodes and observe the logging output.
– Start SymmetricDS by executing:

— The server and client nodes both start up. The server node creates all the
triggers that were configured by the sample configuration. It listens on port
8080 for synchronization and registration requests.
— The client node server starts up and uses the auto-creation feature to create
the SymmetricDS system tables. It begins polling the server node in order to
register. Since registration is not yet open, the client node receives an
authorization failure (HTTP response of 403).

– Registering a Node
Open registration for the client node server by executing:

— The registration is now opened for a node group called “store” with an external
identifier of “1”. This information matches the settings in for
the client node. Each node is assigned to a node group and is given an
external ID that makes sense for the application. In this tutorial, we have retail
stores that run SymmetricDS, so we named our node group “store” and we
used numeric identifiers starting with “1”. More information about node groups
will be covered in the next chapter.
— Watch the logging output of the client node to see it successfully register with
the server node. The client is configured to attempt registration once per
minute. Once registered, the server and client are enabled for synchronization!

– Sending an Initial Load
— Next, we will send an initial load of data to our store (that is, the client node),
again using the server node administration feature.
— Open a command prompt and navigate to the samples subdirectory of your
SymmetricDS installation.
— Send an initial load of data to the client node server by executing:

— With this command, the server node queues up an initial load for the client
node that will be sent the next time the client performs its pull. The initial load
includes data for each table that is configured for synchronization.
— Watch the logging output of both nodes to see the data transfer. The client is
configured to pull data from the server every minute.

The above steps are needed to be followed for syncing local & remote DB. The following point
are very useful for us.
– [] should be unique for each store configuration and it should not be
changeable and it must be a store id which is created by Administrator in store table.
This store id is a reference for one way sync.
– Data will not sync with remote DB if server not started in local but data will be sync
after starting local symmtricDS server viceversa.
– We need to add entry in [sym_router] & [sym_trigger_router] for every new table
that is used by our application.
– For every new store, need to [registering a node] with remote server.
– For every new store, need to recognize [initial load] that is sent by remote server.
then only, sync will happen.


Execute script in each partial loads in Angularjs

By default, Angularjs is not loading script if we put it in partial HTML. Also, it is compiling the HTML  once template is loaded. So subsequent request template will be loaded from browser cache instead of from server.

In some cases, we want to execute some codes whenever partials loaded (for eg: Tracking page count code, putting Google Analytics code or any other tracking code).

So the solution is to call Jquery before loading Angularjs. This way, Angular in-built JQlite is detached and Angular will use full fledged of external Jquery.


The following partials are used in this demo.
– home.html
– projects.html
– services.html
– downloads.html
– about.html
– contact.html

Each file contains inline script with console log and it will be printed whenever the partials are loaded.

Enable developer tool and check the console log.

loading order of files with dependency using requirejs

The following demo demonstrates the loading order of files with dependency. Below is my project directory structure. JS folder contains number of js files (required by project).

– js
—main.js (this is having the configuration)
—app.js (init the loading process)

We are going to load the js files in the following order.






Open in new tab with browser developer tool and track the loading order

IE confusing browser & document modes

Often developers confusing regarding the following IE modes. Simply I explained below what does, each one.

Browser Mode:
It is an identifier of browser version which is used in code.
Client Side:
Javascript: navigator.userAgent
Server Side:

Document Mode:
This is only renedering the page using IE engine.

Compatibility Mode:
This is changing the browser mode and document mode to lower version i.e IE7. This is mostly creating a problem in production environment in IE.

Edge Mode:
> Developer can force document mode to Edge. Means, IE automatically changed to highest version of browser.
> It is very useful for fixing the compatability mode issue.
> Anyway, developer can not force browser mode. So still your apps gets problem if you ae checking with IE versions in code level.

<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
header(“X-UA-Compatible: IE=Edge”);

Quirks Mode:
> If you are not mention doctype, then your browser gets old browser engine and some of the functionality will not works fine in your app.
> Use standart doctype <!DOCTYPE html>

> Use doctype <!DOCTYPE html>
> Add X-UA-Compatible to edge
> Both mode (Browser mode & Document mode) should same in your testing scenarios if edge mode not enabled.

© 2019 Asik Blog

Theme by Anders NorenUp ↑