Skip to content

Instantly share code, notes, and snippets.

Avatar
🤙
makka thangs

Christopher James Curtin ccurtin

🤙
makka thangs
View GitHub Profile
@ccurtin
ccurtin / Animated Canvas Gradient Background.jsx
Created Dec 17, 2020
Animated Canvas Gradient Background
View Animated Canvas Gradient Background.jsx
const animatedCanvasGradient = () => {
useEffect(() => {
animateCanvas('canvas')
}, [])
return (
<canvas
id="canvas"
width="26"
height="26"
style={{
@ccurtin
ccurtin / COPYING OVER WOOCOMMERCE PRODUCT CATEGORY IMAGES FROM A SOURCE TO TARGET SERVER.md
Created Nov 20, 2020
COPYING OVER WOOCOMMERCE PRODUCT CATEGORY IMAGES FROM A SOURCE TO TARGET SERVER
View COPYING OVER WOOCOMMERCE PRODUCT CATEGORY IMAGES FROM A SOURCE TO TARGET SERVER.md

COPYING OVER WOOCOMMERCE PRODUCT CATEGORY IMAGES FROM A SOURCE TO TARGET SERVER

  • wp_posts

  • wp_postmeta

  • wp_termmeta

    --- EXPORT the product cat image "post ids" (used for the rest of the import/)
    --- note: `meta_value` contains the wp_posts post IDs we will be using
    SELECT meta_value FROM wp_termmeta INNER JOIN wp_term_taxonomy ON wp_termmeta.term_id = wp_term_taxonomy.term_id WHERE wp_termmeta.meta_key LIKE 'thumbnail_id' AND wp_term_taxonomy.taxonomy LIKE 'product_cat';
View js-currying-example.js
function curry(func) {
return function curried(...args) {
if (args.length >= func.length) {
return func.apply(this, args);
} else {
return function(...args2) {
return curried.apply(this, args.concat(args2));
}
}
}
@ccurtin
ccurtin / hm_get_template_part.php
Created Jan 26, 2020
Same as include_template_part, require, include, but allows for arguments to be passed into template file.
View hm_get_template_part.php
<?php
/**
* Like get_template_part() put lets you pass args to the template file
* Args are available in the tempalte as $template_args array
* @param string filepart
* @param mixed wp_args style argument list
* @example hm_get_template_part( 'template_path', [ 'option' => 'value' ] ); ---> then in template: $template_args['option'];
*/
function hm_get_template_part( $file, $template_args = array(), $cache_args = array() ) {
@ccurtin
ccurtin / blobToJSONObject.js
Created Jan 15, 2020
Converts Blob Objects to JSON objects, creating accessible Object keys from Blob properties
View blobToJSONObject.js
BlobToJSONObject = (blob) => {
obj = {}
for (var prop in blob) {
obj[prop] = blob[prop]
}
return obj
}
View get-duplicate-woocommerce-skus.sql
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 Dec 14, 2019
testingjavascript.com video list
View 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 Aug 20, 2019
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.
View braintree-upgrade-subscription.js
// 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
View wordpress-query-products-n-shit-liners-and-covers.php
<?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 Mar 4, 2019
Creates index keys based on key matches for an array of objects
View groupArrayItemsByKey.jsx
/**
* 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"},