Skip to content

Instantly share code, notes, and snippets.

View awwal1999's full-sized avatar

Lawal Akanbi awwal1999

  • Lagos, Nigeria
View GitHub Profile
parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "(${BRANCH}${STAT})"
else
echo ""
fi
@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)
<?php
// custom validator in laravel to validate comma separated emails.
\Validator::extend("emails", function($attribute, $values, $parameters) {
$value = explode(',', $values);
$rules = [
'email' => 'required|email',
];
if ($value) {
foreach ($value as $email) {
@ba11b0y
ba11b0y / installing-postman.md
Last active August 31, 2023 19:21
Installing Postman on Ubuntu/Gnome

Since Chrome apps are now being deprecated. Download postman from https://dl.pstmn.io/download/latest/linux

Although I highly recommend using a snap

sudo snap install postman

Installing Postman

tar -xzf Postman-linux-x64-5.3.2.tar.gz
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active June 30, 2024 08:42
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@aquasmit
aquasmit / laravel-query-many-to-many-relationship.md
Last active August 23, 2021 04:00
Laravel - Eloquent - query many to many relationship

Laravel - Eloquent - query many to many relationship

Example:

Table 1: posts

Table 2: categories

Pivot Table: category_post with foreign keys category_id, post_id

@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active June 30, 2024 07:40
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@parmentf
parmentf / GitCommitEmoji.md
Last active June 28, 2024 10:47
Git Commit message Emoji
@yoavniran
yoavniran / ultimate-ut-cheat-sheet.md
Last active June 23, 2024 21:35
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon, and Jest
@amochohan
amochohan / 01_Laravel 5 Simple ACL manager_Readme.md
Last active April 22, 2024 17:19
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php