Monday, April 25, 2016

Basic Text movement using setTimeout (functional programming)

Following code snippet helped me to learn setTimeout more easily specially when you use setTimeout with for loop. One thing have to be remember when you call setTimeout inside for loop time parameter will be (i * time). and i will be (1 , 2, 3, 4, 5 .. this sequence)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>this is the basic of setTimeout function</title>
</head>
<body>
    <h2 id="subtitle">Hello my name is shibu deb polo...</h2>
    <script type="text/javascript" charset="utf-8">
        function backlash(id) {
            var subtitle = document.getElementById(id);
            var text = subtitle.innerHTML;
            var time = 50;

            for (let i = text.length; i >= 0; i--) {
                setTimeout(function () {
                   subtitle.innerHTML = subtitle.innerHTML.substring(0, i);
                }, time + time * (text.length - i))
            }
            setTimeout(function () {
                textAdd('subtitle', text);
            }, 2000);
        }

        function textAdd (id, text) {
            var subtitle =  document.getElementById(id);
            console.log(text ,'text')
            for (let i = 0 ; i < text.length ; i++) {
                setTimeout(function () {
                    subtitle.innerHTML += text[i]
                    console.log(text[i]);
                }, 100 * i)
            }

            setTimeout(function () {
                backlash('subtitle');
            }, 4000)
        }
        backlash('subtitle');
    </script>
</body>
</html>

Hello my name is shibu deb polo...



Ubuntu desktop suddenly points to home folder or Documents Folder [solved]

Go to your home folder

and type

ctrl + H
that will show all hidden file

now click on follwing folder

.config
inside .config folder open following file in your favorite text editor
user-dirs.dirs now change your existing code by below code
XDG_DESKTOP_DIR="$HOME/Desktop" XDG_DOWNLOAD_DIR="$HOME/Downloads" XDG_TEMPLATES_DIR="$HOME/Templates" XDG_PUBLICSHARE_DIR="$HOME/Work" XDG_DOCUMENTS_DIR="$HOME/Documents" XDG_MUSIC_DIR="$HOME/Music" XDG_PICTURES_DIR="$HOME/Pictures" XDG_VIDEOS_DIR="$HOME/Videos
now restart pc



How to upgrade from python 2.7 to 3.5 linux mint, Ubuntu or any other linux distro

1. First install build Dependencies

sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev


2. cd into your download folder

cd ~/Download

3. download Python 3.5 using wget / or you can download manually

wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz

extract Python zip folder using tar zxvf(zip extract verbose file) command

tar zxvf Python-3.5.0.tgz

Now cd into the Python-3.5.0

cd Python-3.5.0

Now install python by following command ./configure 
sudo make install

now make a bash_alias file

gedit .bash_aliases 

Now define the source

source .bash_aliases
Now check python version
python --version

css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }