Skip to content

Instantly share code, notes, and snippets.

View ccurtin's full-sized avatar
🤙
makka thangs

Christopher James Curtin ccurtin

🤙
makka thangs
View GitHub Profile
@ccurtin
ccurtin / get-duplicate-woocommerce-skus.sql
Created December 23, 2019 17:56
Get Dupliate WooCommerce Skus
SELECT meta_value
FROM wp_postmeta
WHERE meta_key = '_sku'
AND meta_value != ''
GROUP BY meta_value HAVING COUNT(meta_value) > 1
@ccurtin
ccurtin / testingjavascript.com video list
Created December 14, 2019 19:52
testingjavascript.com video list
1 Intro to Fundamentals of Testing in JavaScript
2 Throw an Error with a Simple Test in JavaScript
3 Abstract Test Assertions into a JavaScript Assertion Library
4 Encapsulate and Isolate Tests by building a JavaScript Testing Framework
5 Support Async Tests with JavaScripts Promises through async await
6 Provide Testing Helper Functions as Globals in JavaScript
7 Verify Custom JavaScript Tests with Jest
8 Intro to Static Analysis Testing JavaScript Applications
9 Lint JavaScript by Configuring and Running ESLint
10 Use the ESLint Extension for VSCode
<?php
preg_match("/\d+(\.\d+)?x\d+(\.\d+)?/", $q, $new);
if ($new && $new[0]) {
$q = str_replace("x", " x ", $new[0]);
}
$args = array(
'posts_per_page' => 24,
'limit' => -1,
@ccurtin
ccurtin / add-yoast-seo-data-to-WP-REST-API.php
Created October 27, 2017 17:49
Add 'yoast' SEO data to the REST API w/ og & twitter meta fallbacks...
<?php
/*
Creates and end-point that get Yoast SEO meta tags...
*/
add_action('rest_api_init', 'add_yoast_data');
function add_yoast_data()
{
// Add your post types here...
register_rest_field(array(
@ccurtin
ccurtin / bulk-rename-files-in-shell.sh
Last active March 4, 2019 04:19
Bulk Rename Files in Shelly
# removes "wholesale-" prefix from all files.
for filename in wholesale-*; do
[ -f "$filename" ] || continue
mv "$filename" "${filename//wholesale-/}"
done
@ccurtin
ccurtin / Good Job, Buddy!
Last active March 4, 2019 04:01
Updated Description via API #24
*{
font-size: "ONE MILLION and one!";
}
@ccurtin
ccurtin / groupArrayItemsByKey.jsx
Last active March 4, 2019 03:53
Creates index keys based on key matches for an array of objects
/**
* Creates index keys. Groups an array of objects by the specified key group.
* Note: if there are multiple objects with the same key and the type arg is set to `object`, only the frst match will be included in the result
* @exmaple:
* const users = [{name:"jill", favColor:"teal"}, {name:"kim", favColor:"blue"},{name:"rachel", favColor:"teal"}]
* groupArrayItemsByKey(users, 'favColor')
* output:
* {
* teal":[
* {"name":"jill","favColor":"teal"},
@ccurtin
ccurtin / App.jsx
Last active March 4, 2019 03:50
Redux-Form Material-UI v1 Example
import React from 'react'
import FormExample from '_helpers/FormExample'
/*
Add the form to your application. `initialValues` are handled through props as well as form submissions `onSubmit()`
*/
<FormExample onSubmit={(values) => {window.alert(`You submitted:\n\n${JSON.stringify(values, null, 2)}`)}} initialValues={{date:null, textbox:'This was generated via `initialValues` prop on the Form!', switchExample:true, poops: true, ethnicity: 'asian' }} />
@ccurtin
ccurtin / javascript-shallow-clone-and-deep-clone-notes.jsx
Last active March 4, 2019 03:49
Javascript Shallow Clone & Deep Clone Notes
/*
Javascript Shallow Clone & Deep Clone Notes
--------------------------------------------
"Variables that are assigned a non-primitive value are given a reference to that value.
That reference points to the object’s location in memory.
The variables don’t actually contain the value."
*/
/*===================================================================================================*/
@ccurtin
ccurtin / Delete-All-WooCommerce-Products.sql
Created August 4, 2016 15:59
Delete Remove All WooCommerce Products from WordPress. Useful SQL query to run when `wp_posts where post_type=product` is VERY large. Will remove 10,000 products @ 2/3mins
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';