Skip to content

Instantly share code, notes, and snippets.

View timacdonald's full-sized avatar

Tim MacDonald timacdonald

View GitHub Profile
@timacdonald
timacdonald / existing.md
Last active May 4, 2018 07:57
existing.md
Trial Trial + Cancelled Recurring Recurring + Cancelled Cancelled [ended]
onTrial()
active()
valid()
cancelled()
onGracePeriod()
@timacdonald
timacdonald / proposed.md
Last active May 4, 2018 08:38
Proposed
Trial Trial + Cancelled Recurring Recurring + Cancelled Cancelled [ended]
ended()
resumable()
activelyRecurring()
@timacdonald
timacdonald / Builder.php
Last active April 19, 2019 23:09
Basic Search
<?php
namespace App\Builders;
use Illuminate\Database\Eloquent\Builder as BaseBuilder;
class Builder extends BaseBuilder
{
public function search($term, $attributes)
{
@timacdonald
timacdonald / app.css
Last active April 26, 2021 04:43
Markdown header links for Jigsaw
// This the CSS for my site. Might not apply directly to yours.
.rich-text h1,
.rich-text h2,
.rich-text h3,
.rich-text h4,
.rich-text h5,
.rich-text h6 {
position: relative;
}
@timacdonald
timacdonald / transducers.php
Last active December 13, 2021 08:30
Transducers
<?php
declare(strict_types=1);
namespace Transducers;
use Closure;
function compose(array $reducers): Closure
{
@timacdonald
timacdonald / ContactIndexResponse.php
Last active February 9, 2023 21:48
Easily respond to content types and url extensions
<?php
namespace App\Http\Responses;
use App\Models\ContactType;
use App\Factories\CsvFactory;
class ContactIndexResponse extends Response
{
public function __construct($contacts)
<?php
$log = fn ($message) => print '['.number_format(microtime(true), 4, '.', '').'] '.$message.PHP_EOL;
$bail = function ($reason = null) use ($log) {
$reason ??= socket_strerror(socket_last_error());
$log($reason);
exit(1);