Skip to content

Instantly share code, notes, and snippets.

View kevinruscoe's full-sized avatar
💻
Working

Kevin Ruscoe kevinruscoe

💻
Working
View GitHub Profile
@kevinruscoe
kevinruscoe / ArrayUserProvider.2.php
Last active January 1, 2021 15:23
Array User Provider
<?php
namespace App;
use App\Models\User;
use Exception;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\UserProvider;
class ArrayUserProvider implements UserProvider
@kevinruscoe
kevinruscoe / ResponseMacros.php
Last active June 14, 2020 10:54
A few handy response macros
<?php
Request::macro('startsWith', function(string $needle) {
return collect(array_filter(
$this->all(),
fn($key) => str_starts_with($key, $needle),
ARRAY_FILTER_USE_KEY
));
});

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

Collection::macro(
'sortWithPreference',
function ($preference = [], $key = 'id') {
return $this->sort(
function ($a, $b) use ($preference, $key) {
$a = array_search(is_array($a) ? $a[$key] : $a->$key, $preference);
$b = array_search(is_array($b) ? $b[$key] : $b->$key, $preference);
if ($a === false && $b === false) {
@kevinruscoe
kevinruscoe / Remove _notes directories
Created July 29, 2019 09:46 — forked from pcmccull/Remove _notes directories
Remove all _notes directories from a project that has been 'touched' by Dreamweaver
find . -name _notes -type d -exec rm -rf {} \;
<?php
namespace App\Http\Middleware;
use Closure;
use Config;
class ConnectToCorrectDatabase
{
/**
<?php
// Assuming the field name is 'url'.
// Don't forget to URL encode
$url = sprintf("http://www.facebook.com/share/dialog/app_id=xxxxxx%s&redirecht_uri=myurl.com", get_field('url'));
// Or use http_build_query
$url = sprintf('http://www.facebook.com/share/dialog/%s', http_build_query([
'app_id' => 'xxxxxx',
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/MyTheme/Theme',
__DIR__
);