Blog

Restrict viewers to inspect code from the web page

Background: We have curious and lazy minds all over the place who enjoy inspecting the web pages to view the DOM structure, or pull a snippet of code for reference. For such free spirited minds, we have a simple yet effective way to disable the “snooping around”.

Just add a few lines of code to your structure and keep your code hidden from prying eyes!

1) Restrict keyboard shortcuts
Add this code in javascript tag in your DOM structure.
    document.onkeydown = function(e) {
        if(e.keyCode == 123) {
            return false;
        }
        if(e.ctrlKey && e.shiftKey && e.keyCode == ‘I’.charCodeAt(0)){
            return false;
        }
        if(e.ctrlKey && e.shiftKey && e.keyCode == ‘J’.charCodeAt(0)){
            return false;
        }
        if(e.ctrlKey && e.keyCode == ‘U’.charCodeAt(0)){
            return false;
        }
        if(e.ctrlKey && e.shiftKey && e.keyCode == ‘C’.charCodeAt(0)){
            return false;
        }      
    }

2) Restrict right click
Just add one attribute in the body tag.
Example :
    <body oncontextmenu=”return false;”>
        <!–
                …Your Code Here…
        –>
    </body>

Categories: Website Development
Share:

How to make text in header tags and images responsive for websites

Background: While building the website, the UI developers often face problems while making the hero image/landing page responsive. If there are header tags such as h1, h2 or a combination of text and images, making them scale according to the window can become a challenge. To achieve this, we start writing media queries and endRead More…

Categories: Website Development
Share:

Logging Util in the mobile application to help you debug the application faster

When an airplane is flying, black box (flight data recorder) is recording everything. If something goes wrong, log helps to figure out what happened. When a program crashes, if there is no proper logging done, we have little chance to understand what happened. Without the log, finding what went wrong is difficult. Traversing the flowRead More…

Categories: Mobility
Share:

How to find all logged in users in grails application

In this tutorial we assume that we already have grails application with Spring Security core plugin installed. We will explore how to retrieve currently logged-in users using the SessionRegistry. What is SessionRegistry? Maintains a registry of SessionInformation instances. Inject sessionRegistry as a bean in resources.groovy as follows import org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy import org.springframework.security.web.session.ConcurrentSessionFilter import org.springframework.security.core.session.SessionRegistryImpl beans =Read More…

Categories: Grails
Share:

Bulk Insert with Grails GORM

Background: Sometimes we need to insert large number of rows to the database. (For example: transferring data from external source to our database). It is preferable that performance is fast and the expected time to finish is proportional to the number of rows to be inserted. If you’re doing much more frequent imports, with heavyRead More…

Categories: Grails
Share:

Preventing a cycle while creating a tree

Background : In our application we are using a tree structure for representing some logic. The tree may contain another tree as a child node. The requirement was to parse the complete tree  structure by traversing it. While traversing the tree, if a child node refers to another tree, we have to parse this childRead More…

Categories: Grails
Share: