Skip to content

Instantly share code, notes, and snippets.

View JodiWarren's full-sized avatar
🎯
Focusing

Jodi Warren JodiWarren

🎯
Focusing
View GitHub Profile
@JodiWarren
JodiWarren / johnlewisgiftlist2csv.js
Created September 7, 2017 20:11
Output CSV based on the HTML of a John Lewis Gift List page
const guests = [].slice.call(document.querySelectorAll('tr.guest'));
const itemText = element => element.querySelector('td[align=left]').textContent.replace(/\(\d*\)/g, '').trim()
const guestData = guests.map(guestElement => {
const name = itemText(guestElement);
const message = itemText(guestElement.nextElementSibling)
let giftEl = guestElement.nextElementSibling.nextElementSibling;
let gifts = [];
while ( giftEl.classList.contains('item') ) {
#!/bin/bash
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
# Bundle React Native app's code and image assets.
# This script is supposed to be invoked as part of Xcode build process
@JodiWarren
JodiWarren / wp-get-plugin-names.js
Last active March 29, 2018 12:44
Get a list of plugin names from a WordPress plugins admin page. You can change the `[data-plugin]` selector to `.active` or `.inactive` to get a subset. Just pop it into the dev tools console.
jQuery.map(jQuery('[data-plugin]').map((index, element) => $(element).find('strong').first().html()), value => [value]).join('\n');
<?php
class OutputTemplateDetails {
function init() {
add_action( 'all', [$this, 'output_template_data'], 10, 2);
}
function get_template_location($slug, $name) {
$templates = array();
@JodiWarren
JodiWarren / one-line-jqueryish.js
Created November 30, 2018 13:02
A one-line jQuery replacement (not really)
const $ = (selector) => Array.from(document.querySelectorAll(selector));
@JodiWarren
JodiWarren / filter_search_wp.php
Created October 26, 2019 17:12
Filter SearchWP results by post type.
<?php
function filter_search_by_post_type( $included, $engine, $terms ) {
$post_type = get_query_var('post_type');
if (!is_array($post_type)) {
return $included;
}
$posts = new \WP_Query([
'no_found_rows' => true,
@JodiWarren
JodiWarren / machine.js
Last active November 1, 2019 16:51
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
<style>
.measurement-container {
position: fixed;
z-index: 999;
top: 30px;
left: 30px;
background: white;
padding: 15px;
border: 10px solid wheat;
}
@JodiWarren
JodiWarren / cf7-autocomplete.php
Created August 12, 2020 14:25
Naively add autocomplete attribute to Contact Form 7 inputs
<?php
/**
* @param $content
*
* @return string|string[]
*/
function imp_wpcf7_form_elements( $content ) {
$valid_autocomplete = [
'name',