Skip to content

Instantly share code, notes, and snippets.

View thecrypticace's full-sized avatar

Jordan Pittman thecrypticace

View GitHub Profile
@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

#!/usr/bin

Test

Test 2

@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')
})
@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 / 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 / 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)
{
#!/usr/bin/env swift
import Foundation
let df = DateFormatter()
df.locale = Locale(identifier: "en_US")
df.timeZone = TimeZone(identifier: "Antarctica/Casey")
df.setLocalizedDateFormatFromTemplate("zzzz")
print("\(String(describing: df.timeZone))")
print(df.string(from: Date()))
@thecrypticace
thecrypticace / webpack.mix.js
Created September 24, 2020 13:02
Mix + custom API for separate builds
const mix = require("laravel-mix")
mix.site = (id, callback) => {
if (!process.env.SITE || process.env.SITE === id) {
return callback()
}
};
mix.site('admin', () => {
mix.js("resources/js/admin/app.js", "public/js/admin.js")
@thecrypticace
thecrypticace / tsconfig.json
Last active February 14, 2022 12:37
Laravel Mix config for Vue 3 compat build
// If you're using typescript or ts-check you can alias the composition api package as well:
{
"compilerOptions": {
// … other stuff omitted for brevity …
// Ensure your base url is set
"baseUrl": ".",
"paths": {
// Add composition API to your compiler options and alias it to the vue 3 install
// The path is relative to `baseUrl` above
import { createApp, configureCompat } from "vue"
configureCompat({ MODE: 3 })
const app = createApp({
setup() {
return {
// stuff
}
}