Monday, November 25, 2019

css snippet for blogger code highlighting

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

how to add background image overlay in CSS

.class-selector {
background:url(http://lorempixel.com/800/600/nature/2) rgba(255,0,150,0.3);
background-size:cover;
background-blend-mode: multiply;
}

Get Static Properties from a PHP Class

We will get all the static properties as an PHP Array

private function theme_default_value ($key) {
  $full_class_path = Constants::$my_namespace . 'MyClass';
  $class = new \ReflectionClass( $full_class_path );
  $default_value = $class->getStaticPropertyValue( $key );
  return $default_value;
}

photoshop shortcut for developer

ctrl + h = toggle ruler

ctrl + alt + z = previous | alternatively browse history

ctrl + shift + c = to copy of selected portion where transparent stuff will be automatically cropped

ctrl + alt + 0 = 100%;
ctrl + 1= 100%;
ctrl + 0 = 0;

Tab = to get full view;

f8 = info of a layer

# how to know info of layer by click on mouse


To know a layer info we have to select another layer from layer option. Then need to click on expected layer.
Now if we open info window (F8 - shortcut), we will see info of that layer


# to know layer color
just double click on layer

# how to crop a image in a desired size

create a new canvas with your desired size.   

now paste image on this canvas     

Now use free transform tool (`ctrl + t` shortcut) by holding `shift` key.     

# for color overlay
When we take a new canvas `color mode` should be `rgb` and `resolution` should be `72`

Sublime key bindings for jsx emmet expansion using shift + tab

{
  "keys": ["shift+tab"], "command": "expand_abbreviation_by_tab",
  "context": [
    {
      "operand": "source.js",
      "operator": "equal",
      "match_all": true,
      "key": "selector"

    },
    { 
      "key": "selection_empty",
      "operator": "equal",
      "operand": true,
      "match_all": true
    }
 
  ]
}

Tuesday, February 20, 2018

laravel pagination with materialize css

Publishing pagination vendor using artisan command



php artisan vendor:publish --tag=laravel-pagination



make a file name materializecss.blade.php inside views/vendor/pagination directory and paste following code




@if ($paginator->hasPages())


    <ul class="pagination">


        {{-- Previous Page Link --}}


        @if ($paginator->onFirstPage())


            <li class="disabled"><i class="material-icons">chevron_left</i></li>


        @else


            <li class="waves-effect"><a href="{{ $paginator->previousPageUrl() }}"><i class="material-icons">chevron_left</i></a></li>


        @endif



        {{-- Pagination Elements --}}


        @foreach ($elements as $element)


            {{-- "Three Dots" Separator --}}


            @if (is_string($element))


                <li class="disabled">{{ $element }}</li>


            @endif



            {{-- Array Of Links --}}


            @if (is_array($element))


                @foreach ($element as $page => $url)


                    @if ($page == $paginator->currentPage())


                        <li class="active">


                            <a>{{ $page }}</a>


                        </li>


                    @else


                        <li class="waves-effect"><a class="page-link" href="{{ $url }}">{{ $page }}</a></li>


                    @endif


                @endforeach


            @endif


        @endforeach



        {{-- Next Page Link --}}


        @if ($paginator->hasMorePages())


            <li class="waves-effect"><a href="{{ $paginator->nextPageUrl() }}"><i class="material-icons">chevron_right</i></a></li>


        @else


            <li class="disabled"><a href="{{ $paginator->nextPageUrl() }}"><i class="material-icons">chevron_right</i></a></li>


        @endif


    </ul>




@endif








In order to use in views




    {{$variable->links('vendor.pagination.materializecss')}}





Monday, November 6, 2017

Specified key was too long error in laravel 5.4 in case of old mysql / mariadb

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}



changed to AppServiceProvider.php file

Monday, October 9, 2017

mysql default database

mysql has 4 default database


  • information_schema
  • mysql
  • performance_schema
  • says



Sunday, October 8, 2017

export and import in mysql

mysqldump -p -uroot <databasename> > location/backup.sql
mysql -p -uroot <databasename> < location/backup.sql;

Saturday, September 9, 2017

Seeding database in Laravel

Using php artisan make:seeder
=========================

php artisan make:seeder PeopleTableSeeder
inside PeopleTableSeeder class

<?php

use Illuminate\Database\Seeder;
use Faker\Factory as Faker;
use Carbon\Carbon;

class PeopleTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
      $faker = Faker::create();
      DB::table('people')->insert(
          [
            'first_name' => $faker->firstname,
            'last_name' => $faker->lastname,
            'age' => rand(10, 44),
            'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
            'updated_at' => Carbon::now()->format('Y-m-d H:i:s')
          ]
        );
    }
}

In DatabaseSeeder class

$this->call(PeopleTableSeeder::class);


For multiple entry
======================
 DB::table('people')->insert([
   [], []
 ]);

Using PHP factory
====================
$factory->define(App\Person::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->name,
        'first_name' => $faker->firstname,
        'last_name' => $faker->lastname,
        'age' => rand(10, 44)
    ];
});

In DatabaseSeeder class

factory(Person::class, 100000)->create();

Thursday, August 17, 2017

sass variable completion in sublime all auto completion

just add a new setting in side user setting json file
"word_separators": "./\\()\"':,.;<>~!@#%^&*|+=[]{}`~?",

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; }