Skip to content

Instantly share code, notes, and snippets.

function subStringBetweenTwo(a, b) {
const arr = a.split('');
const brr = b.split('');
return [...new Set(arr.filter(item => brr.includes(item)))]
}
subStringBetweenTwo('Hello', 'World')
// output: ['l', 'o']
subStringBetweenTwo('Hi', 'World')
@gravitano
gravitano / README.md
Last active October 11, 2016 03:47
LAMP Script (Originally from Laravel Homestead).

LAMP (PHP 5.6/Nginx/MySQL)

What's Included?

  • PHP 5.6
  • HHVM (Optional)
  • Nginx
  • MySQL
  • Postgres
  • Git 2+
@gravitano
gravitano / README.md
Last active August 29, 2015 14:26
Bash script for creating new virtual host in OS X (Homebrew, Nginx, PHP-FPM)

First, you need to follow this blog tutorial for installing Nginx, PHP-FPM and MySQL to your computer (OSX Only). Then, get the vhost.sh file to your PC and make it executable:

chmod +x /path/to/vhost.sh

You may also move the vhost.sh file to /usr/local/bin path for global use.

sudo mv /path/to/vhost.sh /usr/local/bin/vhost
@gravitano
gravitano / README.md
Last active November 29, 2018 15:18
Auto create nginx virtualhost

Usage

chmod +x /path/to/serve.sh
sudo /path/to/serve.sh foo.app /home/foo/Code/project/root
@gravitano
gravitano / post-receive.sh
Last active August 29, 2015 14:24
Git Hook Script
#!/bin/sh
#
## store the arguments given to the script
read oldrev newrev refname
# The deployed directory (the running site)
DEPLOYDIR=/root/web/domain.com
# Repository Directory
REPODIR=/root/repo/domain.git
# Redirect to non-www
server {
server_name *.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
# Document root
root /var/www/example.com;
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Barang extends Model {
protected $primaryKey = 'id_barang';
@gravitano
gravitano / eos.sh
Last active March 17, 2016 10:24
After Installing Elementary OS
# Add PPA(s)
sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder
sudo add-apt-repository ppa:mpstark/elementary-tweaks-daily
sudo add-apt-repository ppa:linrunner/tlp
sudo add-apt-repository ppa:hanipouspilot/focaltech-dkms
sudo apt-add-repository ppa:strukturag/libde265
# Update
sudo apt-get update
<?php
if ( ! function_exists('xls'))
{
/**
* XLS Response.
*
* @param string $filename
* @param string $view
* @param array $data
@gravitano
gravitano / Envoy.blade.php
Last active December 14, 2021 12:19
Simple laravel envoy deploy script :)
@servers(['web' => '[email protected]'])
@setup
$root = '~/public_html';
$dir = $root . '/laravel';
$branch = 'master';
$artisan = $dir . '/artisan';
$composer = '~/composer.phar';
$repo = '[email protected]:username/repository.git';
@endsetup