Skip to content

Instantly share code, notes, and snippets.

View kbav's full-sized avatar

Kyle Bavender kbav

View GitHub Profile
@abalejr
abalejr / prepare-commit-msg
Created July 8, 2022 14:57
Append Issue Number to Commit Message
#!/bin/bash
FILE=$1
MESSAGE=$(cat $FILE)
TICKET=$(git rev-parse --abbrev-ref HEAD | grep -Eo '^(\w+/)?(\w+[-_])?[0-9]+' | grep -Eo '(\w+[-])?[0-9]+' | tr "[:lower:]" "[:upper:]")
if [[ $TICKET == "" || "$MESSAGE" == "$TICKET"* ]];then
exit 0;
fi
echo "$MESSAGE (#$TICKET)" > $FILE
type AnyFunction = (...args: any[]) => any
function useEvent<T extends AnyFunction>(callback?: T) {
const ref = useRef<AnyFunction | undefined>(() => {
throw new Error("Cannot call an event handler while rendering.")
})
// Or useInsertionEffect if it's React 18
useLayoutEffect(() => {
ref.current = callback
})
@markerikson
markerikson / job-search-questions.md
Last active August 2, 2024 18:59
Assorted questions to ask companies in interviews

Questions

Company

  • company location / remote?
  • what project management method?
  • good and bad company culture?
  • performance reviews?
  • what's the path to profitability?
@mirisuzanne
mirisuzanne / cq.css
Last active October 6, 2021 10:41
Thoughts on Container Queries
/*
This is not meant to be a final CSSWG proposal,
but reflects my immediate thoughts after reading
[David Baron's](https://github.com/dbaron/container-queries-implementability) promising draft.
This gist was created to demonstrate my idea for removing selectors from his query syntax.
More of my thoughts & notes are online at css.oddbird.net/rwd/
*/
main,
@tanaikech
tanaikech / submit.md
Created February 17, 2020 23:42
Uploading File to Google Drive using HTML and Google Apps Script

Uploading File to Google Drive using HTML and Google Apps Script

This is a simple sample script for uploading a file using the file input tag of HTML. As the important point, the file is sent as the byte array for using Google Apps Script. By this, at Google Apps Script side, the byte array can be converted to a blob using a simple script.

HTML & Javascript

<input id="file" type="file" onchange="saveFile(this)" />
<script>
 function saveFile(f) {
@anthonycoffey
anthonycoffey / wp_rest_api_endpoint_example.php
Last active June 30, 2022 11:27
WordPress REST API Custom Endpoint Example
<?php
/* 1. add function to rest_api_init hook, */
/* 2. then, call register_rest_route() function */
add_action( 'rest_api_init', 'define_endpoint');
function define_endpoint(){
register_rest_route( 'namespace', '/new/route', array(
'methods' => array('POST','GET','UPDATE','DELETE'),
'callback' => 'my_awesome_func'
) );
}
@adactio
adactio / minimal-serviceworker.js
Last active August 18, 2023 09:15
An attempt at a minimal viable service worker.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
// HTML files: try the network first, then the cache.
// Other files: try the cache first, then the network.
// Both: cache a fresh version if possible.
// (beware: the cache will grow and grow; there's no cleanup)
const cacheName = 'files';
@SleepWalker
SleepWalker / swipe.js
Created September 30, 2015 04:59
A simple swipe detection on vanilla js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
@emaildano
emaildano / acf-field-counter.php
Created May 28, 2014 20:15
ACF field counter snippet.
<?php
// get the count on the repeater field
// mabye use get_sub_field() instead of get_field() if it's nested
$count = count( get_sub_field( 'the_field' ) );
// begin $count conditions
if ( $count > 1 ) { ?>
// greater than 1
<?php the_field( 'great_than_1' ); ?>
<?php } else { ?>
@townivan
townivan / iOS email links
Last active January 14, 2016 14:43
Email HTML - Override iOS auto-linking addresses and phone numbers. At least styling the link how you want.Source: https://litmus.com/blog/update-banning-blue-links-on-ios-devices?utm_campaign=bestpractices&utm_source=litmusblog&utm_medium=blog