Skip to content

Instantly share code, notes, and snippets.

View joshuabaker's full-sized avatar
🎭

Joshua Baker joshuabaker

🎭
View GitHub Profile

Tailwind class autocomplete in object strings

Using Tailwind’s intellisense in VSCode and other IDEs, it’s possible to autocomplete classes in class, className, et al.

In some cases you want to introduce variants, which mean autocomplete is not available. To get around this, I use the following setup.

//                Add this to objects
//                ↓     ↓
const variants = /* tw */ {

How to fix Cloudflare Worker unregister on macOS

[ERROR] Failed to unregister worker TypeError: fetch failed

I noticed that, from time to time, Wrangler worker instances get stuck and cannot be unregistered. Use the following command to force unregister.

kill -9 $(lsof -ti:6284)
@joshuabaker
joshuabaker / composer.json
Created June 20, 2023 15:26
Craft CMS project config deploy script for Fortrabbit
{
"scripts": {
"deploy-project-config": [
"ssh {app-name}@deploy.eu2.frbit.com rm -rf config/project/*",
"rsync -av ./config/project/* {app-name}@deploy.eu2.frbit.com:~/config/project",
"ssh {app-name}@deploy.eu2.frbit.com php craft clear-caches/all",
"ssh {app-name}@deploy.eu2.frbit.com php craft migrate/all",
"ssh {app-name}@deploy.eu2.frbit.com php craft project-config/apply"
]
}
@joshuabaker
joshuabaker / ignored-build-step.sh
Created May 15, 2023 17:22
For use on Vercel. Ignores the build step if a commit includes #nodeploy.
#!/bin/bash
echo "VERCEL_GIT_COMMIT_MESSAGE: $VERCEL_GIT_COMMIT_MESSAGE"
if [[ "$VERCEL_GIT_COMMIT_MESSAGE" == *"#nodeploy"* ]]; then
# Don't build
echo "🛑 - Build cancelled"
exit 0;
else
# Proceed with the build
@joshuabaker
joshuabaker / useChakraResponsiveImageSizes.jsx
Last active January 4, 2023 13:01
Converts Chakra responsive syntax (array or object) to sizes for use with image elements.
import { useTheme } from "@chakra-ui/react";
import { objectToArrayNotation } from "@chakra-ui/utils";
export default function useChakraResponsiveImageSizes(sizes) {
const theme = useTheme();
const details = theme.__breakpoints.details;
if (!sizes) {
return null;
}
@joshuabaker
joshuabaker / border-image-border-radius.css
Created November 29, 2022 18:53
Example of using border image with border radius using a exclusion mask.
.box {
--radius: 3px;
position: relative;
width: 64px;
height: 64px;
background: linear-gradient(to bottom, green, gold);
border-radius: var(--radius);
}
.box::after {
@joshuabaker
joshuabaker / http-status-codes.sh
Created June 30, 2021 15:11
Takes a list of URLs and outputs the HTTP status code.
#!/bin/sh
# Usage
#
# chmod 755 http-status-codes.sh
#
# cat list-of-urls.txt | xargs http-status-codes.sh
for arg in $@ ; do
statusCode=`curl -I 2>/dev/null $arg | head -n 1 | awk '{print $2}'`
@joshuabaker
joshuabaker / component.jsx
Created December 15, 2020 11:24
Component JSX template for Intellij
import React from 'react'
import css from '@styled-system/css';
import PropTypes from 'prop-types';
import styled from 'styled-components';
function ${NAME}() {
return <>
{'${NAME}'}
</>
}
@joshuabaker
joshuabaker / languages.json
Last active April 22, 2024 18:02
List of languages with ISO 639-1 Alpha-2 codes in JSON.
[
{
"code": "aa",
"name": "Afar",
"native": "Afar"
},
{
"code": "ab",
"name": "Abkhazian",
"native": "Аҧсуа"
@joshuabaker
joshuabaker / package.json
Last active January 15, 2019 17:01
Removes outline for mouse users but preserves it for keyboard users.
{
"name": "remove-focus-outline",
"version": "1.0.0"
}