Skip to content

Instantly share code, notes, and snippets.

View jasonmccreary's full-sized avatar

Jason McCreary jasonmccreary

View GitHub Profile
@jasonmccreary
jasonmccreary / README.md
Created October 4, 2021 12:12
Command to update your Vimeo thumbnail links

This artisan command will update your Vimeo video thumbnails for their recent link change (September 2021).

To run:

  1. Add the command to your Laravel project.
  2. Update any references for your application (model name, column names, thumbnail size, thumnail type)
  3. Install vimeo/laravel
  4. Configure your environment with you Vimeo app credentials
@jasonmccreary
jasonmccreary / example.php
Created September 9, 2021 15:20
Collection Challenge
<?php
// before
$registry = [
'tests/BasicClass.php' => [
'TestCase',
],
'tests/ComplexClass.php' => [
'TestCase',
'RefreshDatabase',
@jasonmccreary
jasonmccreary / fixup.sh
Last active September 19, 2019 14:37
Shell function to "fixup" and "autosquash" a commit with a single command.
# ref: https://twitter.com/gonedark/status/1174460639005356032
# usage: fixup [ref]
function fixup() {
git commit --fixup="$1"
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash "$1"~1
}
# credit: https://stackoverflow.com/questions/29094595/git-interactive-rebase-without-opening-the-editor
@jasonmccreary
jasonmccreary / .php_cs.laravel.php
Created August 9, 2019 14:18 — forked from laravel-shift/.php-cs-fixer.php
PHP CS Fixer - Laravel Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'binary_operator_spaces' => [
'operators' => ['=>' => null]
],
'blank_line_after_namespace' => true,
@jasonmccreary
jasonmccreary / test-controllers.sh
Last active July 23, 2019 07:10
One-line shell script to generate HTTP Tests for your application's controllers.
# Run `artisan make:test` for all Controllers under `your app/Http/Controllers` folder.
# Created tests mirror their path under the `app` folder and are suffixed with "Test".
find app/Http/Controllers -type f -name '*Controller.php' -exec sh -c 'php artisan make:test $(dirname "${1:4}")/$(basename "$1" .php)Test' sh {} \;
@jasonmccreary
jasonmccreary / .php_cs.laravel
Created May 6, 2019 12:44
PHP CS Fixer - Laravel Presets + Customizations
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'phpdoc_indent' => true,
'binary_operator_spaces' => [
'operators' => ['=>' => null]
],
@jasonmccreary
jasonmccreary / renamer.php
Created January 4, 2019 18:31
Scripts to rename posts filenames
<?php
require 'vendor/autoload.php';
$renamed_posts = [];
foreach (new DirectoryIterator('source/_posts') as $file) {
if (!$file->isFile()) {
continue;
}
@jasonmccreary
jasonmccreary / condense-front-matter.php
Created January 4, 2019 18:24
Script to condense Jekyll front matter for Jigsaw
<?php
require 'vendor/autoload.php';
$parser = new \Mni\FrontYAML\Parser();
$config = [
'whitelist' => ['title', 'excerpt', 'comments', 'categories', 'seo_image'],
'merge' => [
'extends' => '_layouts.post',
@jasonmccreary
jasonmccreary / config.php
Created January 4, 2019 18:19
Jigsaw Configuration for https://jasonmccreary.me
<?php
return [
'baseUrl' => 'https://jasonmccreary.me',
'production' => true,
'siteName' => 'Jason McCreary',
'siteTitle' => 'I build things with my hands',
'siteDescription' => 'I build things with my hands',
'siteAuthor' => 'Jason McCreary',
@jasonmccreary
jasonmccreary / regex.md
Created October 26, 2018 14:56
Regex to convert old closure based view routes to Route::view()

The following regex will convert old, closure-based view routes from:

Route::get('faq', function () {
    return view('faq');
});

to the new, cacheable Route::view() introduced in Laravel 5.5.