Categories
Javascript

Auto-Refresh your Browser on file change

    How? Just include Live.js and it will monitor the current page including local CSS and Javascript by sending consecutive HEAD requests to the server. Changes to CSS will be applied dynamically and HTML or Javascript changes will reload the page. Try it!

Where? Live.js works in Firefox, Chrome, Safari, Opera and IE6+ until proven otherwise. Live.js is independent of the development framework or language you use, whether it be Ruby, Handcraft, Python, Django, NET, Java, Php, Drupal, Joomla or what-have-you.

<script type="text/javascript" src="http://livejs.com/live.js"></script>

There is another way to achieve this using jQuery
You could just place a javascript interval on your page, have it query a local script which checks the last date modified of the css file, and refreshes it if it changed.

var modTime = 0;
setInterval(function(){
  $.post("isModified.php", {"file":"main.css", "time":modTime}, function(rst) {
    if (rst.time != modTime) {
      modTime = rst.time;
      // reload style tag
      $("head link[rel='stylesheet']:eq(0)").remove();
      $("head").prepend($(document.createElement("link")).attr({
          "rel":"stylesheet",
          "href":"http://cp.swatantra.info/kb/"
        })
      );
    }
  });
}, 5000);
'Coz sharing is caring
Categories
linux

ls command with a long listing format

When we execute the ls command with a long listing format, what does this mean?

ls -l filename

-l option of a ls command will instruct ls to display output in a long listing format which means that instead of output containing only a name(s) of file or directory the ls command will produce additional information.

linux ls command

Example:

ls -l file
-rw-rw-r--. 1 root swat 0 Jan 26 09:30 file1

From the output above we can deduct a following information:

  • -rw-rw-r- permissions
  • 1 : number of linked hard-links
  • root: owner of the file
  • swat: to which group this file belongs to
  • 0: size
  • Jan 26 09:30 modification/creation date and time
  • file1: file/directory name

To answer your question we will look more closely at the permissions part of ls long listing format output:

- -rw-rw-r--

The permissions part can be broken down to 4 parts. First part in this example is “-” which specifies that this is a regular file. Other common uses are:

  • l this specifies symbolic links
  • d stands for directory
  • c stands for character file

Next three parts are also called octets and they define a permissions applied to this file. First octet ( -rw- ) defines a permission for a file owner. In this case owner has read and write permissions. Second part ( rw- ) defines read and write permissions defined for a group. And the last part defines read-only permissions for others ( everyone else ).

From permissions listed as:

lrwxrwxrwx

we can conclude that this particular file is a symbolics link pointing to yet another file somewhere within a file system. It lists full permissions for an owner, group and everyone else. Although it has full permissions for everyone it does not mean that the file it is pointing to will also have the same permissions ( in most cases it does not !). We can check the file name to see where this symbolic link is pointing to. For example this X executable binary points to Xorg in the same directory:

$ ls -l X
lrwxrwxrwx. 1 root root 4 Feb 22 10:52 X -> Xorg
'Coz sharing is caring