Skip to content

Instantly share code, notes, and snippets.

View daronspence's full-sized avatar

Daron daronspence

View GitHub Profile
@daronspence
daronspence / stale-branch-delete.js
Created March 9, 2024 13:08
Bulk Delete Stale Branches Userscript
// Copy and paste this into the browser console: https://github.com/<your-username>/<your-repo-name>/branches/stale
// Helper function
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
async function clickDeleteElements() {
// Note: the label here may be different if you are not using English
const elements = Array.from(document.querySelectorAll('button[aria-label*=Delete]'));
for (let index = 0; index < elements.length; index++) {
@daronspence
daronspence / BaseTable.vue
Created August 24, 2022 19:47
A table component to act as the base for larger table features.
<script>
const BaseTable = {
props: {
fields: {
type: Array,
default: [],
validator(fields) {
return fields.find(field => field?.key === undefined || field?.label === undefined) === undefined
},
},
@daronspence
daronspence / markdown-with-iframes.php
Created April 29, 2022 15:23
Stringable Markdown with Iframe Support
<?php
// within AppServiceProvider::boot() or a similar entry point
Stringable::macro('markdownWithIframes', function ($config = []) {
$config['disallowed_raw_html'] = [
'disallowed_tags' => ['title', 'textarea', 'style', 'xmp', 'noembed', 'noframes', 'script', 'plaintext'],
];
$environment = new Environment($config);
@daronspence
daronspence / hyper-volume.json
Created January 13, 2022 07:58
Hyper Volume
{
"title": "Hyper Volume",
"rules": [
{
"description": "Hyper + Up = Volume Up",
"manipulators": [
{
"from": {
"key_code": "up_arrow",
"modifiers": {
@daronspence
daronspence / nvmrc.zsh
Created February 22, 2021 21:50
Automagic .nvmrc
#!/bin/zsh
# Put this in your .zshrc
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
@daronspence
daronspence / example.js
Created May 20, 2020 20:30
Contentful debug example
/**
* Essentially, the `onValueChanged` callback used to provide an object/array that was `===` during comparisons.
* In the last few days though, something changed and === was not working anymore.
* My solution is to serialize the values and compare those strings to ensure things are
not triggering unnecessary re-renders.
The external change handler is triggered even when the current editor updates the field value,
so we need to check it's equality to what is already in state,
otherwise the current editor will be in an endless loop of updating their own UI.
@daronspence
daronspence / a.js
Created April 30, 2020 18:38
Contentful
import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import { TextInput } from '@contentful/forma-36-react-components';
import { init } from 'contentful-ui-extensions-sdk';
import '@contentful/forma-36-react-components/dist/styles.css';
import './dist.css';
import { createApolloFetch } from 'apollo-fetch';
import { debounce, union, keyBy } from 'lodash-es';
@daronspence
daronspence / config.json
Created October 11, 2019 04:55
Tailwind Config - tailwindcss.now.sh
{
"variants": {
"borderColor": ["responsive", "hover", "focus", "focus-within"]
}
}
@daronspence
daronspence / acf-copy-repeater-field-to-singular.php
Created May 2, 2019 06:32
Copy last row of ACF field to hidden custom fields on save
<?php
/**
* Plugin Name: ACF Copy Repeater Field to Singular - docs_list_renew
* Version: 0.1
* Description: Copies the values of the last row of a repeater field to separate custom fields to be used with Admin Columns
*/
// Rename the second argument if you're going to copy the plugin to work with another repeater.
add_action('wp_insert_post', 'reddit_acf_copy_repeater_field_to_singular', 10);
@daronspence
daronspence / webpack.mix.js
Created April 27, 2019 14:35
Laravel Mix with Sass and Tailwind 1.0 Configuration
const mix = require('laravel-mix');
require('laravel-mix-tailwind');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass