Skip to content

Instantly share code, notes, and snippets.

View meSingh's full-sized avatar
😜
Making products..

Mandeep Singh meSingh

😜
Making products..
View GitHub Profile
@meSingh
meSingh / JsonMiddleware.php
Last active July 11, 2022 09:19
If you are using laravel as api only, you might want to return JSON on every request, even on errors/exceptions. The easiest way to do so is using this middleware globally.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class JsonMiddleware
{
public function handle(Request $request, Closure $next)
# laravel new-app
alias laravel="git clone -o laravel -b develop https://github.com/laravel/laravel.git"
alias artisan="php artisan"
alias migrate="php artisan migrate"
alias serve="php artisan serve"
alias dump="php artisan dump"
alias t="phpunit"
# Generators Package
@meSingh
meSingh / sublime-text-installation-instructions.md
Last active June 7, 2020 16:20
Sublime Text Installation Instructions for Ubuntu 13.04 and Elementary OS Luna

Sublime Text 2 Installation Guide: Ubuntu 13.04 and Elementary OS Luna

1. Install Sublime Text 2

Open terminal

sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text

2. Install Sublime Package Control

@meSingh
meSingh / make_slug.php
Created July 1, 2013 13:35
Create WordPress like slugs from any string in php.
<?php
/**
*
* Genrate Slugs from Title or any given string
*
* @param string $str
* @return Slug
*
**/
@meSingh
meSingh / routes.php
Created May 26, 2015 13:43
Lumen Resource Routes
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
@meSingh
meSingh / deploy.sh
Created June 17, 2018 17:50 — forked from BenSampo/deploy.sh
Laravel deploy script
# Change to the project directory
cd /home/forge/domain.com
# Turn on maintenance mode
php artisan down
# Pull the latest changes from the git repository
git pull origin master
# Install/update composer dependecies
@meSingh
meSingh / mongodb-setup.sh
Created June 13, 2016 20:35
MongoDB Setup on Ubuntu 14.04 with PHP7
#!/bin/bash
# MongoDB Setup on Ubuntu 14.04 with PHP7
# Source:
#1. Import the public key used by the package management system:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
#2. Create a list file for MongoDB.
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
@meSingh
meSingh / install.sh
Last active March 16, 2018 21:57 — forked from insane-dev/install.sh
Lemp stack for Ubuntu 16.04 (PHP7, Nginx, MongoDB, Git, Composer(with asset plugin))
#!/bin/bash
echo "Please, enter your username, it will be added to 'sudo' and 'docker' groups during the process."
read USERNAME
if [ -z "$USERNAME" ] ; then
echo "Exiting... Done."
exit
else
echo "Adding user to 'sudo' group..."
@meSingh
meSingh / index.html
Created April 5, 2013 20:06
Back To Top button easing with jQuery
<a href="javascript:void(0)" class="backtotop">Back to Top</a>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type='text/javascript'> jQuery('.backtotop').click(function(){ jQuery('html, body').animate({scrollTop:0}, 'slow'); }); </script>
@meSingh
meSingh / README.md
Last active September 29, 2016 23:23
How To Install Elasticsearch on an Ubuntu VPS

Install Java 8

Elasticsearch require Java, so we will install that now. We will install a recent version of Oracle Java 8 because that is what Elasticsearch recommends. It should, however, work fine with OpenJDK, if you decide to go that route.

Add the Oracle Java PPA to apt:

    * sudo add-apt-repository -y ppa:webupd8team/java

Update your apt package database: