Skip to content

Instantly share code, notes, and snippets.

View seansch's full-sized avatar

Sean Schoonover seansch

View GitHub Profile
@seansch
seansch / laravel_relationships.php
Last active February 28, 2024 15:14
Display all Laravel relationships
Route::get('relations', function () {
$modelList = [];
$path = app_path() . "/Models";
$results = scandir($path);
foreach ($results as $result) {
if ($result === '.' or $result === '..') continue;
$filename = $result;
if (is_dir($filename)) {
@seansch
seansch / gen-ipv6-network.sh
Last active January 10, 2022 01:27
Generate Unique IPv6 Local Network
#!/bin/bash
# Generates a unique local IPv6 network
# Based on RFC4193 https://www.rfc-editor.org/rfc/rfc4193#section-3.2.2
QUIET=0
while getopts :hqs: flag
do
case "${flag}" in
q) # Only output network prefix
QUIET=1
@seansch
seansch / webp-convert.sh
Last active December 31, 2021 02:10
WebP Convert
#!/bin/bash
# Source: https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website#step-3-%E2%80%94-converting-jpeg-and-png-images-in-a-directory
# Usage ./webp-convert.sh /path/to/images
if [ $# -eq 0 ]; then
echo "Usage ./webp-convert.sh /path/to/images"
exit 1
fi
@seansch
seansch / .htaccess
Last active December 31, 2021 02:58
Apache detect browser support and serve webp images
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{REQUEST_URI} (?i)(.*)(\.jpe?g|\.png)$
RewriteCond %{DOCUMENT_ROOT}%1.webp -f
RewriteRule (?i)(.*)(\.jpe?g|\.png)$ %1\.webp [L,T=image/webp,R]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
$collection = new Collection($array);
$perPage = 4;
$currentPageSearchResults = $collection->slice((LengthAwarePaginator::resolveCurrentPage() - 1) * $perPage, $perPage)->all();
$paginatedSearchResults= new LengthAwarePaginator($currentPageSearchResults, count($collection), $perPage);
return $paginatedSearchResults;
google-chrome --use-fake-device-for-media-stream --use-file-for-fake-video-capture=/path/to/video.y4m
dig +short myip.opendns.com @resolver1.opendns.com
@seansch
seansch / Diff 2 repos
Created March 7, 2016 21:21
Diff 2 repos on disk
diff -ywr --exclude=".git" --suppress-common-lines repo1/ repo2/
@seansch
seansch / Laravel-wordpress-integration
Created February 15, 2016 17:09
Simple Laravel / Wordpress Integration
// public/index.php
// Wordpress / Laravel Integration
// Wordpress lives in public/wp/
if ( file_exists(__DIR__.'/wp/index.php') ) {
// Retrieve the current URL
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
// Get first URL segment, strip any GET params
$segment = strtok($segments[0], '?');