Skip to content

Instantly share code, notes, and snippets.

View manuelgeek's full-sized avatar
😎
#mANuEl💯

Magak Emmanuel manuelgeek

😎
#mANuEl💯
View GitHub Profile
@manuelgeek
manuelgeek / gist:09f2dcfc0e616fe360f0c30a8aaf96a1
Created July 6, 2018 16:35 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@manuelgeek
manuelgeek / \Illuminate\Session\TokenMismatchException
Created July 14, 2018 20:02
Token Mismach Exception Handling in Laravel
Replace your app\Exceptions\Handler.php render() function with this
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
@manuelgeek
manuelgeek / ide-helper.php
Created July 20, 2018 19:39
ide-helper.php
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.5.13 on 2017-09-28.
*
* @author Barry vd. Heuvel <[email protected]>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
exit("This file should not be included, only analyzed by your IDE");
/*
* Original script by: Shafiul Azam
* Version 4.0
* Modified by: Luigi Balzano
* Description:
* Inserts Countries and/or States as Dropdown List
* How to Use:
In Head section:
@manuelgeek
manuelgeek / PhpFireBaseNotificationSample.php
Created August 8, 2018 06:17 — forked from MohammadaliMirhamed/PhpFireBaseNotificationSample.php
Simple PHP FireBase (FCM) script showing how to send an Android push notification. Be sure to replace the SERVER_API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call http://sample.com/PhpFireBaseNotificationSample.php?id=THE_DEVICE_REGISTRATION_ID The main Code For GCM is https://gist.github.com/prime…
<?php
#API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-SERVER-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = $_GET['id'];
#prep the bundle
$msg = array
(
'body' => 'Body Of Notification',
@manuelgeek
manuelgeek / instructions.php
Last active August 16, 2018 21:18
Serverside datatables with Yajra in laravel yajra/laravel-datatables
Listing items in tables is one of the ,ost essential while building dashboards. Datatables https://datatables.net/ Add advanced interaction controls
to your HTML tables which we mostly do on the client side. Using the same approach to load large rows of data from the database
always becomes slow as the data grows bigger and bigger untl at some point the datatable break. This is a major reason to
consider using datatables from the start of your development to avoid such. Thats what we are goint to do.
Create a new laravel project composer create-project --prefer-dist laravel/laravel datatable-test
change the .env for database connections
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=datatables-test
@manuelgeek
manuelgeek / file
Created October 11, 2018 18:45
easyteather ubuntu 18.04
sudo easytether-usb
acquired interface tun-easytether
dropped root privileges
now CONNECTING
now CONNECTED
switching to background
manuelgeek@manuelgeek:~$ systemctl enable systemd-networkd
Created symlink /etc/systemd/system/dbus-org.freedesktop.network1.service → /lib/systemd/system/systemd-networkd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/systemd-networkd.service → /lib/systemd/system/systemd-networkd.service.
Created symlink /etc/systemd/system/sockets.target.wants/systemd-networkd.socket → /lib/systemd/system/systemd-networkd.socket.
sudo chmod -R a+w storage/app
sudo chmod -R a+w storage/framework
sudo chmod -R a+w storage/logs
sudo chmod -R a+w storage/cache
sudo chmod -R a+w bootstrap/cache
sudo chmod -R a+w .env
sudo chown -R www-data storage/app
sudo chown -R www-data storage/framework
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
import {initialize} from "./helpers/general";
require('./bootstrap');
@manuelgeek
manuelgeek / README-Template.md
Created April 30, 2019 09:33 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites