Sunday, October 9, 2016

making a symbolic link in mac (mysql and sublime example)

ln -s "/Applications/MAMP/Library/bin/mysql" /usr/local/bin/mysql
- for mysql
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
- for sublime

How to Block any website in MAC Os or linux

To be more productive some time you may want to block some website.  In my case sometimes I block amazon.com, amazon.in, facebook.com.
To block  website you need to edit your host file
go to terminal and type 
sudo vi /etc/hosts
It will ask for your password

in hosts file add the following line
127.0.0.1   www.facebook.com
127.0.0.1   www.amazon.com

you can add as many as you want to your host file. State above example block www.facebook.com and www.amazon.com.

You may find out some time those example not work with out reboot. In this case you need to clear  dns cache

just type following line in terminal to clear cache

dscacheutil -flushcache




Monday, September 5, 2016

How to install worpress theme , plugin in localhost without ftp in linux environment like ubuntu ..

I installed wordpress in my ubuntu machine but problem is when ever I want to install theme or plugin it require to put ftp credential for localhost. I search on google about this. Lot of article suggest lot of things in this regard. After reading all of this I have understood that this is problem with linux permission(ownership). You need to chown your apache account for that. Here is the command
sudo chown www-data:www-data -R <your wordpress publishing directory>

Wednesday, August 31, 2016

how to change sublime theme color(sidebar or anything) (coffe dark roast and material theme as example)

first install desired theme like material or coffee roast.
Second install package resource viewer using package control.
Go to command palate (ctrl + shift + p) and search for "package resource view extarct"
Extract your appropriate theme. 
Now go to preference > browse package. 
open <theme>.sublime-theme
Search the color value which your side bar currently has. 
In case of material theme color value is "38, 50, 56" 
In first occurrence is look like "layer0.tint": [38, 50, 56] 
Select this color and type (ctrl + d) for all occurrence. and paste your desired color. Here is the problem. You will find some theme don't use color for side bar. like coffee theme use background image. In coffee theme it looks like "layer0.texture": "Theme - Coffee/Dark Roast/sidebar-background.png".
So in this case what you should do? delete the line and paste following line "layer0.tint": [38, 50, 56]. 
Here rgb value is 38, 50, 56. change this rgb value to your favorite color

Thursday, July 14, 2016

Making a super simple express server

sequential terminal command

mkdir "simpleServer"
cd simpleServer
npm init -y
npm i --save-dev express
touch server.js
touch index.html

now open server.js and paste following code
var host = "localhost"; var port = 3000; var express = require('express'); var app = express(); app.use('/', express.static(__dirname + '/')); app.listen(port, host); console.log("runnin server at http://localhost:" + port )
now open index.html and paste following code
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>super simple server</title>
</head>
<body>
    <h1>This is the Headline</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia possimus, repellendus quaerat debitis, necessitatibus natus quisquam et magnam reiciendis mollitia placeat nulla rem totam dolores adipisci ullam. Repellat, eligendi accusantium.</p>
</body>
</html>
now open package.js and replace the scripts object by following scripts objects
"scripts": { "start" : "node server.js" },




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

Tuesday, March 22, 2016

Necessary MySql command

to log in 
=================
mysql -u root -p

to show databases
===================
SHOW DATABASES;

to select a database
======================
USE databaseName;

RENAME TABLE <old table name> TO <newtable name>

to show tables;
==============================
SHOW TABLES;

to show details of a specific table
===================================
DESCRIBE tableName;

to create a database
============================
CREATE DATABASE databaseName

to delete a database 
======================
DROP DATABASE databaseName

to create a table under a database
===============================
CREATE TABLE tableName(
id INT(11) AUTO_INCREMENT PRIMARY KEY NOT NULL,
name VARCHAR(30) NOT NULL,
email VARCHAR(30) NOT NULL,
contact INT(11),
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

to delete a table
======================================
DROP TABLE tableName;

add primary key to existing table
==============================
ALTER TABLE tableName
ADD PRIMARY KEY (columnName);

remove primary key from a table;
===============================
ALTER TABLE tableName
DROP PRIMARY KEY;

How to delete a column in existing table
====================================
ALTER TABLE tableName
DROP COLUMN
columnName;

How to add a new column in existing table;
=========================================
ALTER TABLE tableName
ADD COLUMN
columnName;

How to add a new column with current timestamp;
===================================
ALTER TABLE tableName
ADD COLUMN
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP;

How to change datatype of column in mysql
==================================
ALTER TABLE tableName
MODIFY (COLUMN = optional)
columnName VARCHAR(30);

alter a column to be auto increment;
=================================
ALTER TABLE tableName 
MODIFY COLUMN (column keyword is optional) 
columnName INT AUTO_INCREMENT;

insertion in a table
=============================
INSERT INTO 
tableName (column1, column2, column3) 
VALUES ('value_1', 'value_2', 'value_3');

to show all row in table;
===============================
SELECT * FROM tableName;

to update a row in table;
===================================
UPDATE tableName 
SET country = 'india', name = 'Vasanth', email = 'vasanth@gmail.com'
WHERE id = 2; 

to delete a row in a table
=================================
DELETE FROM tableName WHERE id = 3;

how to move a column OR sort column
==========================================
ALTER TABLE tableName 
MODIFY COLUMN (column keyword is optional)
id INT(11) AFTER another_column_name;


ALTER TABLE tableName
MODIFY COLUMN (column keyword is optional)
id INT(11) FIRST;

css snippet for blogger code highlighting

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