Skip to content

Instantly share code, notes, and snippets.

View gayanvirajith's full-sized avatar
:octocat:

Gayan Virajith gayanvirajith

:octocat:
View GitHub Profile
@gayanvirajith
gayanvirajith / figlet.md
Last active July 24, 2020 05:40
The figlet command makes turns ordinary terminal text into big fancy letters

Install

sudo apt-get install figlet

Usage

figlet gayan

Output:

@gayanvirajith
gayanvirajith / phpstorm-replace.md
Created August 27, 2018 12:20
Laravel php storm regex search and replace

When we upgrade our laravel version from 5.1 to 5.2 We must replace out $request parameter accsss with a different method, we need replace our current access method eg: $request->id to something new like $request->input('id). So we used to it using phpStorm reqular expression search/replace feature. We have tried following way:

text to replace : (\$request)(\->)([\w]+)

replacement : $1\->input(\'$3\'\)

@gayanvirajith
gayanvirajith / average.js
Created July 9, 2018 13:04
Node js average from command line argument
#!/usr/bin/env node
var sum = 0;
var count = 0;
process.argv.forEach(function (val, index, array) {
if (index > 1) {
sum += parseInt(val);
count++;
}
@gayanvirajith
gayanvirajith / docker-help.md
Last active September 6, 2018 11:42
Docker self reference

Self Learning Docker Reference

Run docker oreilly http application from docker

docker run -p 4567:4567 -d rickfast/hello-oreilly-http

Run a docker container in foreground (it will exit when you hit CTRL+C)

docker run -p 4567:4567 rickfast/hello-oreilly-http

@gayanvirajith
gayanvirajith / RestTrait.php
Last active August 31, 2017 05:54
Laravel is API call trait
<?php
namespace App\Traits;
use Illuminate\Http\Request;
trait RestTrait
{
/**
@gayanvirajith
gayanvirajith / config-step-php-apache.md
Last active July 27, 2017 06:56
Config ubuntu 14 with apache2 php
1  sudo apt-get update
2  sudo apt-get upgrade
3  sudo apt-get install apache2
4  sudo apt-get install mysql-server
5  sudo a2enmod rewrite
6  sudo apt-get install libapache2-mod-php5.6
7  sudo add-apt-repository ppa:ondrej/php
8  sudo apt-get install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-curl
9  sudo add-apt-repository ppa:ondrej/php5-5.6

10 sudo apt-get install php5-6

@gayanvirajith
gayanvirajith / gitignore-global.md
Last active July 6, 2017 17:50
gitignore global

https://stackoverflow.com/a/17628243

The best solution to tackle this issue is to Globally ignore these files from all the git repos on your system. This can be done by creating a global gitignore file like:

vi ~/.gitignore_global

Adding Rules for ignoring files like:

`

Compiled source

@gayanvirajith
gayanvirajith / fix-readonly-usb-drive.md
Last active May 11, 2017 18:17
How to fix write proceted usb in ubuntu
  • Run Command df -Th to find out the location info about usb drive

  • Unmount the drive

umount /media/gayan/{usb-name} (the path where you seen in Mounted On column)

  • Run the following command to fix the drive

dosfcsk -a /dev/{path-info} (the path where you see in File System column)

var a = "@[a b: 222] hi there @[bob barker:11123] @[kyle corn:123] @[kenny logins:123ab-123]"
var extract = a.match(/@\[(.*?)\]/g); // With @ symbol
var extract = a.match(/\[(\.*?)\]/g); // Without @ symbol
extract.map(function (item) { var tempValue = item; tempValue = tempValue.replace(/\[|\]|@/g, ''); var kv = ''; return tempValue; });
extract.map(function (item) {
var tempValue = item;
tempValue = tempValue.replace(/\[|\]|@/g, '');
var kv = tempValue.split(':');
@gayanvirajith
gayanvirajith / git-merge-help.md
Last active May 18, 2017 06:10
How to merge branch into master with mustiple branch tree

Fetch remote branches to your local repository.

git fetch origin QA

git fetch origin master

Fetch the branch that you need to merge

git fetch origin branch_that_you_want_to_merge