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
@ccurtin
ccurtin / braintree-upgrade-subscription.js
Last active December 7, 2023 08:51
Braintree API / node How to upgrade a MONTHLY subscription to YEARLY subscription. Rough example. Braintree does NOT automatically prorate user's monthly balance onto the yearly subscription so MUST refund the user's latest Transaction before cancelling current subscription and creating a new subscription.
// 1) Get the customer... required the get the payment method token
await braintreeGateway.customer.find(
billing_customer_id,
async (err, customer) => {
await braintreeGateway.subscription.find(
subscriptionId,
async (err, subscription) => {
if (err) {
res.status(400).json({
error_message: err && err.code
<?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 / 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 / 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 / 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 / delete-all-wordpress-woocommerce-posts-products-within-a-specific-category.sql
Last active March 20, 2018 17:33
Delete All Wordpress/WooCommerce Posts/Products Within a Specific Category
# DELETE all posts with category ID of "2906"
delete a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id = 2906
@ccurtin
ccurtin / get-a-users-public-ip-address.js
Last active August 17, 2020 21:41
Get User's Public IP Address
// FREE: no request linit for ipify.org
var request = new XMLHttpRequest()
var ipAddress = ''
request.open('GET', "https://api.ipify.org?format=jsonp=", true)
var ipAddress = request.onload = function() {
if (request.status >= 200 && request.status < 400) {
// Success!
return ipAddress = request.responseText
} else {
// We reached our target server, but it returned an error
@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