Skip to content

Instantly share code, notes, and snippets.

View jasonmccreary's full-sized avatar

Jason McCreary jasonmccreary

View GitHub Profile
@jasonmccreary
jasonmccreary / getting-git-resources.md
Last active June 7, 2017 18:16
Getting Git Resources

Resources from the Getting Git workshop

These resources are either referenced during my Getting Git workshop or serve as materials for additional learning.

  • Pro Git - Recommend reading the first three chapters.
  • Git Flow and GitHub Flow - two of the popular branching models. I recommend GitHub Flow or more generally the master/feature branching model.
  • How to write a good commit message
  • My Blog - many of the recent articles go into more detail on Git commands and everyday scenarios we covered in the workshop.

In addition, the Getting Git workshop is based on the Getting Git video course. This can not only serve as a refresher, but also cover more commands and scenarios than the workshop.

@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.

@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 / 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 / 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 / prep.md
Last active January 18, 2019 22:19
Prep: Start testing your PHP code

Start testing your PHP code

To prepare for this workshop, attendees should clone or download the start-testing-php repository and run composer install. This will install all the necessary tools to follow along with the live coding demos.

Requirements

While only PHP and Composer are required, if you would like to take the opportunity to set up a complete, local development environment, check out Homestead or Docker.

@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 / 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
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 / .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,