This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
now=$(date +%s) | |
two_years_in_seconds=$((2 * 365 * 24 * 60 * 60)) | |
cutoff_date=$((now - two_years_in_seconds)) | |
git for-each-ref --format '%(authordate:iso) %(refname)' refs/heads | while read line; do | |
authordate="${line%% refs/heads/*}" | |
authordate_unix=$(date -j -f "%Y-%m-%d %H:%M:%S %z" "$authordate" +%s) | |
refname="${line##* refs/heads/}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function str_inflect(string $value, Countable|int|float $count = null, bool $format = false, bool $spellout = false): string | |
{ | |
preg_match('/^(?:(?<verb>is(?: an?)?|are)\s+)?(?:(?<count>\d+(?:[,.]\d+)?)\s+)?(?<value>.*)/m', $value, $matches); | |
// Get rid of any commas in the input value | |
$matches['count'] = str_replace(',', '', $matches['count']); | |
// This is used for pluralization, but whatever input was provided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alpine.directive('typed', (el, { expression, modifiers }, { evaluateLater, effect, cleanup }) => { | |
const getStrings = evaluateLater(expression); | |
const modifierValue = (key, fallback) => { | |
if (-1 === modifiers.indexOf(key)) { | |
return fallback; | |
} | |
const value = modifiers[modifiers.indexOf(key) + 1]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DemoTest extends DatabaseTestCase | |
{ | |
use TestsMoney; | |
use TestsStripeWebhooks; | |
use MocksAuthorizeNet; | |
protected User $owner; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
\Illuminate\Support\Str::macro('extremeSnake', function($value, $delimiter = '_') { | |
$pattern = <<<'REGEXP' | |
/ | |
(?<!^) # don't match the beginning of a string | |
( | |
(?<=[^\p{Lu}])[\p{Lu}\p{M}]+(?=\p{M}?[^\p{Ll}]\p{M}?\p{L}) # string of upper-case (like an abbreviation) | |
| (?<=\p{Lu}{2})[\p{Lu}\p{M}](?=\p{M}?\p{Ll}) # the final upper-case in a sequence | |
| (?<=[^\p{Lu}])[\p{Lu}\p{M}](?=\p{M}?\p{Ll}) # first upper-case in a capitalized sequence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Team implements Node { | |
"The unique identifier of the entity." | |
id: ID! | |
"The time at which the entity was created." | |
createdAt: DateTime! | |
""" | |
The last time at which the entity was meaningfully updated, i.e. for all changes of syncable properties except those | |
for which updates should not produce an update to updatedAt (see skipUpdatedAtKeys). This is the same as the creation time if the entity hasn't |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nah() { | |
# Configuration | |
local cutoff_in_seconds=86400 # 1 day | |
# Stash our current changes, including untracked files | |
git stash save -u "<<nah - $(date +%s)>>" | |
# Get a list of all stashes that match our message format | |
IFS=$'\n' existing_stashes=($(git stash list | grep "<<nah - [0-9]*>>")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Reading | |
CsvReader::read($path)->each(function(array $row) { | |
// Do something with $row | |
}); | |
// Writing | |
return CsvWriter::for($data)->writeToHttpFile(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Promotions | |
{ | |
public static function for(User $user) | |
{ | |
return new static($user); | |
} | |
public function __construct(protected User $user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<x-chart wire:model="chartData" /> | |
<!-- I can be explicit if I want… --> | |
<div x-modelable="values" x-data="{ | |
values: [], | |
init() { | |
const chart = new Chart(this.$refs.canvas, { | |
data: this.values | |
}); | |
NewerOlder