Skip to content

Instantly share code, notes, and snippets.

View thecrypticace's full-sized avatar

Jordan Pittman thecrypticace

View GitHub Profile
@thecrypticace
thecrypticace / AttachContext.php
Created August 12, 2020 23:47
Log requests middleware
<?php
namespace App\Logs\Sticky;
use Illuminate\Log\Logger;
class AttachContext
{
public function __invoke(Logger $logger)
{
@thecrypticace
thecrypticace / prefix.js
Last active April 25, 2020 04:21
Prefix All Tailwind UI classes
// Prefix all Tailwind UI classes with "tw-"
// Works as of 2020-04-25
// Examples:
// mx-4 -> tw-mx-4
// -mx-4 -> tw--mx-4
// lg:mx-4 -> lg:tw-mx-4
// lg:-mx-4 -> lg:tw--mx-4
const prefix = "tw-"
@thecrypticace
thecrypticace / ParentChildHierarchy.php
Last active February 20, 2020 07:09
Eloquent recursive relationships
<?php
namespace App;
use Illuminate\Database\Eloquent\Collection;
class ParentChildHierarchy
{
public static function apply($entities, $primaryKey = "id", $parentKey = "parent_id", $parentRelation = "parent", $childRelation = "children")
{
@thecrypticace
thecrypticace / webpack.mix.js
Created October 2, 2019 00:50
Multi Config Laravel Mix idea
// Build two webpack configs
mix.build(mix => {
mix.js('resources/js/site1/app.js', 'public/js/site1.js')
mix.sass('resources/sass/site1/app.scss', 'public/css/site1.css')
})
mix.build(mix => {
mix.js('resources/js/site2/app.js', 'public/js/site2.js')
mix.sass('resources/sass/site2/app.scss', 'public/css/site2.css')
})

#!/usr/bin

Test

Test 2

@thecrypticace
thecrypticace / colors.swift
Created December 1, 2018 23:55
Tailwind Colors interpreted as Display P3 converted to sRGB
// Why?
// Figma (as of this writing) doesn't have color management
// As a result of this when using hex values intended for sRGB the colors end up much richer on a P3 display
// If you throw them into a color managed browser you're not going to get what you expect. It'll look washed out.
// This is a best approximation of the colors by interpeting as Display P3 and converting to sRGB
// Some colors are not fully representable (and are marked as such by noting which channels were clipped)
// h/t to Marc Edwards for pointing me in the right direction on how to do this. Thanks!
import Cocoa
=== RUN TestNextToken
=== RUN TestNextToken/{,}
=== RUN TestNextToken/{a,}
=== RUN TestNextToken/{ab,c}
=== RUN TestNextToken/{1..10}
=== RUN TestNextToken/{1...10}
panic: runtime error: slice bounds out of range [recovered]
panic: runtime error: slice bounds out of range
goroutine 24 [running]:
@thecrypticace
thecrypticace / imap-fetch.php
Created March 8, 2018 00:08
Sample IMAP Code
<?php
use Fetch\Server;
// https://github.com/tedious/Fetch
$server = new Server("outlook.office365.com", 993);
$server->setAuthentication("myemail@domain.com", "mypassword");
$server->setFlag("novalidate-cert");
$server->setParam("DISABLE_AUTHENTICATOR", ["PLAIN"]);
@thecrypticace
thecrypticace / settings.json
Last active October 23, 2017 14:09
VSCode Integrated Terminal Customizations
{
"workbench.colorCustomizations": {
"terminalCursor.foreground": "#fee381",
"terminal.selectionBackground": "#cb392e",
"terminal.background": "#0d151b",
"terminal.foreground": "#ffffff",
"terminal.ansiBlack": "#3c444d",
"terminal.ansiBlue": "#266b85",
"terminal.ansiBrightBlack": "#515d68",
"terminal.ansiBrightBlue": "#329dcc",
<?php
class Combinations
{
public static function unique($values, $minLength = 1, $maxLength = null)
{
// $combinations is an array of [["a"], ["a"], … ["a", "b"], ["a", "b", "c"], …]
// The array may not be sorted. Each internal array IS sorted.
// Keys produced by the generator are sequential but shouldn't matter