Skip to content

Instantly share code, notes, and snippets.

View einnar82's full-sized avatar
🎯
Doing nice things.

Rannie Ollit einnar82

🎯
Doing nice things.
View GitHub Profile
@einnar82
einnar82 / settings.json
Last active December 16, 2019 08:18
VS Code Custom Settings
{
"workbench.colorTheme": "Slime",
"terminal.external.windowsExec": "C:\\Program Files\\Git\\git-bash.exe",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"editor.fontLigatures": true,
"editor.fontFamily": "\"Fira Code\"",
"terminal.integrated.fontFamily": "\"Fira Code\"",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.jediEnabled": false,
@einnar82
einnar82 / sample-route.php
Created July 13, 2018 11:58
Separating route files in laravel
<?php
Route::name(your.name)
->prefix('your/prefix')
->middleware(Path\To\YourMiddleware::class)
->group(base_path('routes/your-route.php'));
@einnar82
einnar82 / Base64ServiceProvider.php
Last active July 13, 2018 15:52
Base 64 Image Validator in Laravel
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Validator;
class Base64ServiceProvider extends ServiceProvider
{
/**
@einnar82
einnar82 / stripNamespaceFromClassName.php
Created December 21, 2018 08:12 — forked from jasondmoss/stripNamespaceFromClassName.php
Strip the namespace from the class to get the actual class name
<?php
/**
* Strip the namespace from the class to get the actual class name
*
* @param string $obj Class name with full namespace
*
* @return string
* @access public
*/
@einnar82
einnar82 / Handler.php
Created January 10, 2019 07:06
Override ModelNotFoundException in Laravel
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Auth\AuthenticationException;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use Illuminate\Database\Eloquent\ModelNotFoundException;
@einnar82
einnar82 / CanProcessPhotos.php
Created February 21, 2019 09:29
Upload multiple photos in a polymorphic relation
<?php
/**
* Created by PhpStorm.
* User: rannie
* Date: 2/21/19
* Time: 11:33 AM
*/
namespace App\Modules\Photos\Traits;
body {
/* font-size: calc(14px + (26 - 14) * ((100vw - 300px) / (1600 - 300))); */
font-size: calc([minimum size]px + ([maximum size] - [minimum size]) * ((100vw - [minimum viewport width]px) / ([maximum viewport width] - [minimum viewport width])));
}
@einnar82
einnar82 / get.js
Created September 19, 2019 07:41
lodash.get behavior using Vanilla JS
/**
* Gets the value at `path` of `object`.
* @param {Object} object
* @param {string|Array} path
* @returns {*} value if exists else undefined
*/
const _.get = (object, path) => {
if (typeof path === "string") path = path.split(".").filter(key => key.length);
return path.reduce((dive, key) => dive && dive[key], object);
};
@einnar82
einnar82 / StoredProcController.php
Created October 8, 2019 09:36
Stored Procedure PHP
<?php
namespace App\Http\Controllers;
use App\Model\Notification;
use App\Abstracts\Controllers\ApiController;
use Doctrine\DBAL\Driver\PDOConnection;
use Illuminate\Http\Request;
@einnar82
einnar82 / CanIndexQueries.php
Last active October 14, 2019 08:33
Indexing Eloquent
<?php
namespace App\Rise\Traits;
trait CanIndexQueries
{
/**
* Example
* $properties = Property::indexRaw('USE INDEX (brand)')