Bash function to check if it’s friday

Ever wondered if today’s Friday? Yeah me too, every day.

Keep yourself updated with this simple function.

 

1) Open your profile settings file
nano ~/.bashrc

2) Enter the following function in the bottom

yay() {
    day=$(date +%u)
    if [ "$day" == "5" ];
    then
        echo "YAY, IT'S FRIDAY!!!"
    else
        echo "Not to bring you down, but it's not friday yet :("
    fi
}

3) Reload your config file
. ~/.bashrc

4) Try it out! Just type yay in your terminal window whenever you wonder if it’s Friday or not.

Javascript bookmark function to add emojis to website 😀

After fiddling around with some DOM manipulation I figured an emoji generator would be fun…

Add a new bookmark to your browser and paste the following code into the URL target:

javascript:(function(){
    const c='😀';
    let domh= document.getElementsByTagName('h1');
    let domp= document.getElementsByTagName('p');
    for(let i=0; i<domh.length; i++) {
        domh[i].innerHTML+=c
    }
    for(let i=0; i<domp.length; i++) {
       const s='<span style="font-size:'+Math.random()*1000/5+'px;">';
       const se='</span>';
       domp[i].innerHTML=s+c+se+domp[i].innerHTML+c.repeat(i);
    }
})();

 

Quick explanation:

First of we define the emoji (&#128512;) in the c variable.

Then we scan the website for every h1 and p tags.

For every h1 tag we append the smiley.

For every p tag, we prepend the smiley in a random size by using inline span and styling, then we append a few more smileys at the end.

 

This is really stupid, but it’s just a quick demonstration that Javascript functions in bookmarks can be used for many useful things. For instance I have one shortcut which opens a prompt() where I enter a Dell servicetag, then it redirects me to the Dell website to check ProSupport warranty.

 

Here’s a pic of this website destroyed by stupid emojis: