Display web notifications only when the browser window/tab is not active

HTML5 has brought with it the Notification API. In other words, HTML5 allow us to show browser notifications to the web app users. The most important feature is that the notification will be displayed regardless of which tab or window is focused.

That being said, personally I want to display a notification only when the source tab is not focused (actually,  that’s the desired behavior in most of the cases).
So, how can we display browser notifications only when the tab is not active/focused?

 
 //make sure the tab is not active/focused
 if(!document.hasFocus()) {
     showNotification('Hello world!');
 }

//source: https://developer.mozilla.org/en-US/docs/Web/API/notification
function showNotification($message) {
    // Let's check if the browser supports notifications
    if (!("Notification" in window)) {
        alert("This browser does not support desktop notification");
    }

    // Let's check whether notification permissions have already been granted
    else if (Notification.permission === "granted") {
        // If it's okay let's create a notification
        var notification = new Notification($message);
    }

    // Otherwise, we need to ask the user for permission
    else if (Notification.permission !== 'denied') {
        Notification.requestPermission(function (permission) {
            // If the user accepts, let's create a notification
            if (permission === "granted") {
               var notification = new Notification($message);
            }
        });
     }

 // At last, if the user has denied notifications, and you
 // want to be respectful there is no need to bother them any more.
 }

Resources:

Notification documentation on MDN

Browser compatibility

Official Notification API specs

Google’s new favicon – what do you think?

I’m sure that many of you noticed that Google has a new favicon. On their blog, you can find an anouncement aboutthis change. At the end of the article, the VP of the Search Products and User Experience department writes:

“We hope you like the new favicon, which nicely integrates all of our original criteria: distinctive in shape, noticeable, colorful, timeless, and scalable to other sizes.”

Google's favicons
Google's favicons

Well, I’m not an expert in design, but … it’s just me, or this new design is far away from Google’s “original criteria” as it is perceived by us, the users. Is’nt Google about simplicity, and eficienty? Think about their website. Can you describe it as being “colorful”? Is this somehow complex and color-packed favicon a fit symbol for Google? What do you think?

Bookmark and Share

Top 20 Linux websites

I have compiled a list with the most useful websites about Linux (the distro specific sites are not included). They are great resources you can learn from or to find answer to your linux questions. These should be in any linux user bookmarks, so go ahead and look through these links and bookmark your favorite ones:

1)www.ibm.com/developerworks/linux

Provides information on Linux, Linux resources, and Linux development.

2)www.howtogeek.com

Includes help, tutorials, tips and how-to guides for Linux.

3)www.linuxquestions.org

LinuxQuestions.org offers a free Linux forum where Linux newbies can ask questions and Linux experts can offer advice. Topics include security, installation, networking and much more.

4)www.tldp.org

The Linux Documentation Project is working
towards developing free, high quality documentation for the Linux operating
system. The overall goal of the LDP is to collaborate in all of the issues
of Linux documentation.

5)www.linux.org

Comprehensive information and resources about the Linux Operating System.

6)www.linux.com

Our goal is to provide all the information necessary to make your use of Linux a success.

7)www.linuxforums.org

The Linux Software Resource, providing Linux Forums, Linux Server Distro info, Linux Training, Linux Help, Articles, Tutorials, News, Downloads and more!

Continue reading

10 must-have Linux (and not only) cheat-sheets

Need a quick reference card? Here you have a list you can choose from:

1.Linux Command Line Tips

This is a linux command line reference for common operations (HTML format).

2.Unix/Linux Reference Card

Linux Reference Card published on  FOSSwire website by Jacob. (PDF format)

3.One Page LInux Manual

A summary of useful Linux command by Squadron. (PDF format)

4.Linux Security Quick Reference

The intent of this Quick Reference Guide is to provide a starting point for improving the security of your system, to serve as a pointer to more in-depth security information, and to increase security awareness and methods that can be used to improve security. (PDF format)

5. Screen Cheat Sheet

This cheat sheet summarizes all they default keyboard mappings, with screen’s commands to execute the mapping and a description of each mapping. (PDF format)

6.Ubuntu Cheat Sheet 

There comes a time when one needs an end-all reference to the system. The time is now, and if you’re an Ubuntu user  you’ll like this cheat sheet. (PDF format)

7.VIM Graphical Cheat Sheet 

Probably the best Vim Cheat Sheet: “This is a single page describing the full vi/vim input model, the function of all keys, and all major features. You can see it as a compressed vi/vim manual. ” (GIF format)

Read more >> (Update: the link is down. I’m sorry)

How to get system info in Linux

Here are some useful commands that you can use to find (almost) every information that you want to know about your system from the command line. Most of this commands can be run as non-privileged user, but more information can be obtained if (and should be) run as root.:

linux_inside
General system information:
# uname -a
Process information:
# top

(Shift-M to order the list by memory use)

Memory information:
# free -m
BIOS information:
# dmidecode | less
Read more >>(UPDATE: The link is broken. Sorry)

 

How to backup your Windows in Linux

I will show you how to make a fast backup of your windows partition from the command line. Of course, that is if you have enough space on your linux partition. Open a console and type the following command:

 

$ tar -cvzf win_backup.tar.gz /mnt/win

Where win_backup.tar.gz is the name of the archive and /mnt/win/  is the path to the windows partition (what to backup).

If there is a folder you don’t want to backup, use the exclude option. E.g.:

 

$ tar -cvzf win_backup.tar.gz --exclude= "/mnt/win/Downloads/*" /mnt/win

 

To restore do:

 

 $  tar -xvzf win_backup.tar.gz

 

Switch Explanation:
x -extract the contents of the TAR file
c -create a TAR file
z– uncompress it before extracting, used on file ending in .tar.gz or .tgz
v -verbose – display contents as it is tarring or extracting

f  -filename to follow


Bookmark and Share

How to lock the screen in GNOME

I’m sure that many of you are used with the <Win>+<L> key combination in
windows, to lock the screen. In Ubuntu (the distro I use), the
corespondent shortcut is <CTRL>+<ALT>+<L>. But, in many other distros
there is no shortcut for this command. Here is what you can do to assign a shortcut for locking the screen. (In order to do that, you have to activate the Win key. Read “How to use the Win key in Linux” to find out how to do it.)
Open the gconf-editor by typing “gconf-editor” in the terminal.

nongeek@mma:~$ gconf-editor

Go to: apps>metacity>keybinding_commands

select keybindings-commnads

Read more>>