Skip to content

Instantly share code, notes, and snippets.

View LarryBarker's full-sized avatar
🚀

Larry Barker LarryBarker

🚀
View GitHub Profile
@LarryBarker
LarryBarker / VerificationController.php
Created August 30, 2018 19:43
New Verification Controller for Laravel 5.7 Email Vertification
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
@LarryBarker
LarryBarker / gist:b8f93e8034c7605fbd0e9c72f316577c
Created January 4, 2019 14:30
Script used to process VIN numbers on NHTSA
$(document.vhr).submit(function (e) {
$vin = $(this).find('input[name="decodeVIN"]');
if (!$vin.val() || $vin.val().length <= 10) {
$('.digits-error').show();
$('.triangle-border').hide();
return false;
}
else {
e.preventDefault();
$('.miniBox ul:eq( 0 )').after('<div class="loader"></div>');
@LarryBarker
LarryBarker / Auth.php
Created September 22, 2019 01:14
Dummy Auth class to fix Corcel error
<?php
/**
* Class Auth
* Dirty hack used to avoid error within corcel
*/
class Auth {
public static function provider($name, $callback){
return false;
}
@LarryBarker
LarryBarker / Controller.php
Created October 23, 2019 01:10
AJAX PDF Download
/**
* AJAX handler to generate and return a PDF of the desired report
*
* @param string $shareCode The share code for the report
* @return Response PDF download response
*/
public function view_onDownloadPdf($shareCode)
{
return Backend::redirect("author/plugin/download-pdf/$shareCode");
}
@LarryBarker
LarryBarker / gist:26a4c66a97dde7479b7ed6551cb75608
Created March 2, 2020 19:16
Streaming Large CSV Files with chunk()
// See: https://medium.com/@barryvdh/streaming-large-csv-files-with-laravel-chunked-queries-4158e484a5a2
/*
* Response
*/
$response = new StreamedResponse(function() {
// Set the file name
$filename = 'claims.csv';
@LarryBarker
LarryBarker / .env.example
Created August 3, 2020 04:28 — forked from LukeTowers/.0 - cheatsheet.sh
Introduction to OctoberCMS
APP_DEBUG=true
APP_URL=http://example.local
APP_KEY=
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=website-oc-example-LOCAL
DB_USERNAME=homestead
DB_PASSWORD=secret
@LarryBarker
LarryBarker / gist:dfbe62eb1bf7787753c69d87b4cfe3ca
Created August 6, 2020 14:01
Custom request object for October-based SPA
export const request = async (handler, data) => {
let response = await fetch('/api', {
method: 'POST',
credentials: 'same-origin',
body: JSON.stringify(data),
cache: 'no-cache',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json',
'X-OCTOBER-REQUEST-HANDLER': handler,
@LarryBarker
LarryBarker / gist:101bf047bf63f64abbc5956821c578a2
Created August 17, 2020 03:47
MySQL lat/lng coordinate search
/**
* Scope locations near a pair of coordinates
*
* @param Builder $query
* @param float $int
* @param float $lng
*/
public function scopeIsNear($query, $lat, $lng)
{
$statement = sprintf("id, name, street, locality, region, postal_code, country, website, phone, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance",
@LarryBarker
LarryBarker / gist:48e184417b72eedcd5f55cca432de574
Created October 1, 2020 14:42
Determine the next item in an associative array
<?php
$stages = $this->getStages(); // ['foo'=>'bar','bar'=>'foo']
while (key($stages) !== $this->status) {
next($stages); // advance til there's a match
}
return next($stages);
@LarryBarker
LarryBarker / input.trigger.js
Created March 18, 2024 03:29
Input Trigger API - This API allows you to change an elements' visibility or status (enabled/disabled) based on another elements' status(es)
/*
* Input Trigger API
* This API allows to change elements' visibility or status (enabled/disabled) basing on other elements' statuses.
* Example: enable a button if any checkbox inside another element is checked.
* - Checked Condition:
<input type="checkbox" id="triggerChk1" />
<button class="btn disabled"
data-trigger-action="enable"
data-trigger="#triggerChk1"
data-trigger-condition="checked">