Skip to content

Instantly share code, notes, and snippets.

View leemcd56's full-sized avatar
🔋
Fully Charged (100%)

Nathanael McDaniel leemcd56

🔋
Fully Charged (100%)
View GitHub Profile
@leemcd56
leemcd56 / Macro.php
Created September 13, 2023 20:08
Laravel joinWithOxfordComma (X @martinbean)
<?php
Collection::macro('joinWithOxfordComma', function(): string {
/** @var \Illuminate\Support\Collection $this */
return $this->join(
glue: ', ',
finalGlue: $this->count() > 2 ? ', and ' : ' and ',
);
});
@leemcd56
leemcd56 / ArrayHelper.php
Last active November 21, 2023 21:10
Common Helpers
<?php
namespace App\Helpers;
final class ArrayHelper
{
/**
* Determine if two associative arrays are similar.
*
* Both arrays must have the same indexes with identical values
@leemcd56
leemcd56 / .php-cs-fixer.php
Created February 11, 2022 16:57
My PHP-CS-Fixer configuration
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_syntax' => [
'syntax' => 'short',
],
'align_multiline_comment' => [],
@leemcd56
leemcd56 / DeleteButton.vue
Last active May 18, 2021 23:35
Vue 3 Delete Button
<template>
<button type="button" @click="confirmDelete">
{{ state.message }}
</button>
</template>
<script>
import { reactive } from 'vue'
export default {

Keybase proof

I hereby claim:

  • I am leemcd56 on github.
  • I am leemcd56 (https://keybase.io/leemcd56) on keybase.
  • I have a public key ASCD4fYH1ogTZFtoHp5_BHyeSKm3NdA-MFKNCLYCE5T4Pwo

To claim this, I am signing this object:

@leemcd56
leemcd56 / packages.sh
Created April 30, 2020 17:20
Script for updating packages via crontab
#!/bin/sh
# Determine if any updates were made
did_update=false
# Update Homebrew
brew update > /dev/null;
new_brew_packages=$(brew outdated --quiet)
num_brew_packages=$(echo $new_brew_packages | wc -w)
@leemcd56
leemcd56 / functions.php
Last active June 26, 2018 15:24
(WIP) List of the only PHP functions that really need to exist
<?php
array();
array_add();
array_change_key_case();
array_chunk();
array_column();
array_combine();
array_compact();
array_count();
@leemcd56
leemcd56 / up
Created June 18, 2018 16:22
Packages Updater
#!/bin/sh
# up - script to keep your Mac up-to-date (both OS and Homebrew updates) via the command line
# run thus to to install: cd /usr/local/bin && curl -s -O https://gist.githubusercontent.com/mayel/e681a6175bf17366a16e03006d7feac2/raw/bb4ddb0c4842f5633fa1f29df61c433760c4affe/up && chmod 755 /usr/local/bin/up
# and then run it anytime by simply entering the command: up
# By https://github.com/mayel based on a script by https://github.com/imwally
# Homebrew
@leemcd56
leemcd56 / functions.php
Created May 21, 2018 13:52
Current template in Wordpress admin bar
<?php
// Trouble knowing the current template?
add_action('admin_bar_menu', function ($adminBar) {
global $template;
$templateName = basename($template);
$adminBar->add_menu([
'id' => 'template-name',
'parent' => 'top-secondary',
@leemcd56
leemcd56 / navigation.blade.php
Created May 19, 2018 00:12
Sage 9 Navigation (Bootstrap 4.1)
<nav class="container navbar navbar-light navbar-expand-md" role="navigation">
<a class="navbar-brand" href="{{ home_url('/') }}">
<img alt="{{ get_bloginfo('name', 'display') }}" src="@asset('images/logo.png')">
</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarNav">