megacolorboy

Abdush Shakoor's Weblog

Writings, experiments & ideas.

Check branch status

Ever wondered if you've edited or committed anything in your project before pushing it to your repository, do this:

git status

Check Ubuntu version

Want to know the current version of your Ubuntu distro? Type this:

lsb_release -r

Clear all lines

  1. Switch to normal mode by pressing ESC key
  2. Press gg and it will take you to first line of the file.
  3. Then type dG and it will clear all the lines from start to the end of the file.

Enable spellcheck

This can be useful when you're writing stuff, just do the following:

:set spellcheck=[lang]

Integrate Excel into your Laravel project

Before you integrate Excel into your application, make sure your project meets the following requirements:

  • PHP v7.0 or greater
  • Laravel v5.5 or greater
  • PhpSpreadsheet v1.6 or greater

Download the package

Download the maatwebsite/excel package using Composer:

composer require maatwebsite/excel

Add it to service provider

By default, this will be done automatically when you're installing the package but if you want to do it yourself, add this in your config/app.php file:

<?php
// ...
'providers' => [
    // ...
    Maatwebsite\Excel\ExcelServiceProvider::class,
],

// ...
'aliases' => [
    // ...
    'Excel' => 'Maatwebsite\Excel\Facades\Excel::class',
],
?>;

Publish your configuration

Last but not the least, run the vendor:publish command using artisan to publish your configuration:

php artisan vendor:publish -provider="Maatwebsite\Excel\ExcelServiceProvider"

Upon publishing, the config/excel.php configuration file will be created where you can make your changes.

Hope this helps you out!

Find files containing specific text

This helped me a lot whenever I'm in a remote server trying to find a keyword or specific text amongst a bunch of files.

This command will save you a lot of time:

grep -rwn [path] -e 'pattern'
  • r stands for recursion
  • n displays the line number
  • w matches the whole word

Refer to man find pages for more info.

Find a file by extension

This comes in handy whenever I want to look for files that exists with a specific extension in a computer or server:

find . -name "*.ext"

In addition, sometimes, you might want to look for a bunch of files with a specific extension but with matching keywords:

find .name "*.ext" | grep "keyword"

Hope you found this helpful!

Including and excluding files in zip

When zipping a directory or a bunch of files, there'll be a lot of stuff that you want to include and exclude.

To exclude a file:

zip -r files.zip . -x file_1 file_2

Alternatively, you can choose to include files:

zip -r files.zip . -i file_1 file_2