Printing web pages from JavaScript, although not a common scenario, can be easily accomplished with some simple code. On the other hand, selectively printing some elements from a web page – like a div or a paragraph, can be challenging. Fortunately there are libraries available that can make the task easier. One such useful jQuery plugin is jQuery PrintElement, which allows you to selectively print a DOM element. Usage is extremely easy; just select any element from a webpage and fire the ‘printElement’ method.
Read More

For any moderately complex web application a help section is mandatory. Most of us rely on displaying the help in a popup or a different window. One other interesting way is to display the help section beneath the main window, which then slides to display the help section below.
Read More

Changing the domain name or URL of a WordPress site, whether from local server to a live or vice versa, can be a frustrating and time consuming task. One nice script I found helps ease that process considerately. WordPress-Domain-Changer is a simple PHP script that lets you quickly change domains of your WordPress installation.

The script basically works by replacing the old domain name strings in the ‘wp_options’ table with the new values. It will also replace any references to the old domain name in post content with the new domain name. Upload paths will also be changed.

Rendering PDF in HTML5 Canvas

Posted in: html,javascript |  

19 Feb 2012

pdf.js is an HTML5 technology experiment from Mozilla that explores building a faithful and efficient Portable Document Format (PDF) renderer using Canvas without any native code support. The goal of the project is to create a general-purpose, web standards-based platform for parsing and rendering PDFs, and eventually to release a PDF reader extension powered by pdf.js. Integration with Firefox is a possibility if the experiment proves successful.
Read More

In the last post we constructed a graph structure using the Structure_Graph Pear library. But building a graph is not enough; we also need the ability to search through it. To make it easier to build search algorithms, it is useful if we can represent the graph and its connections in a different way; adjacency matrix being one such representation.


Read More

undirected graphGraphs are one of the most frequently used data structures,along with linked lists and trees. In a recent PHP project I needed to build a Graph structure to analyze some interlinked urls. The problem was of a simple nature, so rather than writing my own code, I went with the one available in the Pear repository.

The Pear Structures_Graph package allows creating and manipulating graph data structures. It allows building of either directed or undirected graphs, with data and metadata stored in nodes. The library provides functions for graph traversing as well as for characteristic extraction from the graph topology.
Read More

The ebook has moved to leanpub.

The ebook has moved to leanpub.

One of the features lacking in the current browser api is that of determining whether the web page is currently visible to the user or is hidden (either in another tab or window).

The new Page Visibility API allows you to do just that – determine whether your web page is visible to the user, is hidden in a background tab or window, or is prerendering. It allows the developer to use the page visibility state in JavaScript logic to make the user experience more friendly; for example, by stopping video, animation or slideshow playback whenever the user switches to another browser tab or window, and resuming whenever the user switches back. Also if your page is doing some ajax processing periodically, which consumes precious system resources, we can pause it when the page is not in focus. Other use can be in analytics, checking how long the page had been in actual user focus, rather then as a hidden tab or window.

Check the below demo page to see how this works. The demo was tested in Safari, Opera 11.10, Chrome and Firefox.
Read More

In a recent project I needed to generate clean search urls on a form submit. There are basically two ways to do that. One is to post the search variables to the same page, and generate a clean url using PHP and then redirect it to the new url. The other way is to generate clean urls using JavaScript and immediately direct the page to the new url. This saves some processing on the server and one redirection, and also allows us to generate a url without a page refresh. I decided to go with the JavaScript solution.
Read More