Skip to content

Instantly share code, notes, and snippets.

View minthemiddle's full-sized avatar

Martin minthemiddle

View GitHub Profile
#!/bin/bash
# @parameters file workspace
# Set locale to UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# Get the current file and workspace paths
current_file="$1"
workspace="$2"
#!/bin/bash
# @parameters workspace
# Set the path to the Daily folder
daily_folder="$1/Daily"
# Check if the Daily folder exists
if [ ! -d "$daily_folder" ]; then
echo "Error: Daily folder not found in workspace"
exit 1
#!/usr/bin/env node
// @parameters file
/*
# Save Hook
This save hook is a Node.js script that automatically updates or adds a `date_updated` field in the YAML frontmatter of a file when it's saved. It's designed to work with text files that may or may not already have YAML frontmatter.
## Features
@minthemiddle
minthemiddle / Markdium-HTML.html
Created July 9, 2020 20:14
Markdium-How to use AlpineJS with Laravel Mix
<div x-data="{ open: false }">
<button @click="open = true">Open Dropdown</button>
<ul
x-show="open"
@click.away="open = false"
>
Dropdown Body
</ul>
</div>
@minthemiddle
minthemiddle / Markdium-HTML.html
Created July 9, 2020 20:12
Markdium-Laravel Forms 101
<!-- Blade, e.g. welcome.blade.php -->
<form action="{{ route('form.submit') }}" method="POST" class="space-y-4">
@csrf
<div>
@error('fullname')
<div class="text-red-500">{{ $message }}</div>
@enderror
<label for="fullname">Fullname</label>
@minthemiddle
minthemiddle / Markdium-Hack.php
Created July 9, 2020 20:12
Markdium-Laravel Forms 101
// routes/web.php
validate([
'fullname' => 'required|alpha|min:3',
]);
return 'Submission allowed';
})->name('form.submit');
@minthemiddle
minthemiddle / Markdium-Hack.php
Created July 9, 2020 20:09
Markdium-Lessons Learnt: PHPUnit for Beginners
public function handle($request, Closure $next)
{
if (! auth()->user()->is_admin)
{
abort(403);
}
return $next($request);
}
@minthemiddle
minthemiddle / Markdium-Hack.php
Created July 9, 2020 20:09
Markdium-Lessons Learnt: PHPUnit for Beginners
private function create_user(is_admin = 0)
{
$this->user = factory(User::class)->create([
'is_admin' => $is_admin,
]);
}
@minthemiddle
minthemiddle / Markdium-Hack.php
Created July 9, 2020 20:09
Markdium-Lessons Learnt: PHPUnit for Beginners
$response = $this->post('login', [
'email' => 'EMAIL',
'password' => 'PW'
]);
// assert where you expect to be redirected to, e.g. home
$response->assertRedirect('/home');
@minthemiddle
minthemiddle / Markdium-Hack.php
Created July 9, 2020 20:09
Markdium-Lessons Learnt: PHPUnit for Beginners
public rules() {
return [
'name' => 'required',
'price' => 'required',
];
}