Skip to content

Instantly share code, notes, and snippets.

View joshuabaker's full-sized avatar

Joshua Baker joshuabaker

View GitHub Profile
@joshuabaker
joshuabaker / Node.js FreeAgent Data Exporter.md
Created November 4, 2024 17:04
📦 Node.js FreeAgent Data Exporter

Node.js FreeAgent Data Exporter

A simple script for exporting everything from a FreeAgent account as JSON formatted data. I made this because I wanted something more machine accessible (i.e. nested structures).

Usage

  1. Download script.js and package.json, and place them into a folder together
  2. Run pnpm install, or similar
  3. Replace the ACCESS_TOKEN with your access token (see below)
  4. Run the script (i.e. node script.js or pnpm start)
@joshuabaker
joshuabaker / screen-record-chrome.md
Last active November 27, 2024 20:23
Hide Chrome link preview for screen recording

Generate bookmarket using this tool.

(function() {
  const isNextApp = !!document.getElementById("__next");

  function hasUserDefinedCursor(link) {
    for (let sheet of document.styleSheets) {
        try {
            for (let rule of sheet.cssRules) {

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}'}
</>
}