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 / extract.sh
Created August 28, 2024 14:59
Extract and list chapters from YouTube video using yt-dlp
#!/bin/bash
# Sourced from Unknown's answer (https://unix.stackexchange.com/a/771262)
# Note: Requires awk and gsed
# Define your YouTube URL here
videoUrl=
yt-dlp $videoUrl --dump-json |
jq -r ".chapters[] | {start_time, title}" |
@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',