Skip to content

Instantly share code, notes, and snippets.

View theonlydaleking's full-sized avatar

Dale King theonlydaleking

View GitHub Profile
@theonlydaleking
theonlydaleking / useTraceUpdate.js
Created May 12, 2022 04:25
What caused a re-render?
// Tracks what prop is changing to trigger re-render
// shout out to this legend
// https://stackoverflow.com/a/51082563/5157083
// usage useTraceUpdate(props)
function useTraceUpdate(props) {
const prev = React.useRef(props)
React.useEffect(() => {
const changedProps = Object.entries(props).reduce((ps, [k, v]) => {
if (prev.current[k] !== v) {
ps[k] = [prev.current[k], v]
@theonlydaleking
theonlydaleking / .graphqlconfig
Created January 24, 2020 03:27
graphql linting config basic
{
"schema": {
"files": "**/*.graphql"
}
}
@theonlydaleking
theonlydaleking / submodules.md
Last active April 2, 2024 00:28 — forked from manasthakur/submodules.md
Using git submodules to version-control Vim plugins

Using git-submodules to version-control Vim plugins

If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need. Thus, you should keep the .vim directory along with your .vimrc version-controlled.

But when you have plugins installed inside .vim/bundle (if you use pathogen), or inside .vim/pack (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well as your vim-configuration as a whole, requires you to use git submodules.

Creating the repository

Initialize a git repository inside your .vim directory, add everything (including the vimrc), commit and push to a GitHub/BitBucket/GitLab repository:

cd ~/.vim

Customer Requests

Both Sites (YB & SE)

  1. Youngblood & Sunescape checkout pages. Abandoned cart issue (There is currently no way to abandon the cart on our current website (so we can't currently re-market via email to them). The billing, shipping, total amount, payment method and credit card details are all in the one shopping cart page. We are needing this to be split onto two pages so that they don't complete the actual payment credit card details until the next page. This way they have to submit their information and it will display on our backend as an abandoned cart and we have their email address to re-market too.)

  2. Websites will not talk to Mailchimp even in ""MailChimp for WooCommerce" Plugin. Integration has been made but it does not pull across the data of what customer purchased (or any details)

  3. Plugin already talking to mailchimp in terms of customers and seeing their purchase

  4. I just can't see any abandoned carts to re-market to them

Sunescape

@theonlydaleking
theonlydaleking / README.md
Created February 23, 2019 21:59 — forked from simov/README.md
Run `node` scripts using `nvm` and `crontab` without hardcoding the node version

Run node scripts using nvm and crontab without hardcoding the node version

cronjob.env.sh

#!/bin/bash

# NVM needs the ability to modify your current shell session's env vars,
# which is why it's a sourced function
@theonlydaleking
theonlydaleking / scrollTo.js
Last active February 11, 2019 05:09
Scrolls to a specific element in the querySelector (rather than using a package)
window.scrollTo({
top: document.querySelector('.stats__chart').scrollHeight,
behavior: "smooth"
})
or
const scrollToVideo = () => {
let e = document.getElementById('video')
e.scrollIntoView({behavior: 'smooth'})

Create a node server with es6 support

Step 1:

yarn add --dev @babel/core @babel/cli @babel/preset-env @babel/node nodemon

Step 2: Add build step:

add this to your package.json file

@theonlydaleking
theonlydaleking / weights.js
Last active November 27, 2018 07:11
weighted allocation example
/*
This can be used when we need to move to a front end that only delivers the
users and their allocation percentage
salesReps is the sample array we would get from the DB.
*/
const salesReps = [
{name: "Renee", id:"30761006", allocation: 70},
{name: "Emma", id:"33620479", allocation: 10},
{name: "Marian", id:"33495420", allocation: 10},
// Prevent Multi Submit on WPCF7 forms
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<script type="text/javascript">
var disableSubmit = false;
jQuery('input.wpcf7-submit[type="submit"]').click(function() {
jQuery(':input[type="submit"]').attr('value',"Sending...")
@theonlydaleking
theonlydaleking / docker-compose.yml
Last active July 6, 2018 07:58
docker setup for wordpress, mariadb and phpmyadmin
version: '2'
services:
db:
container_name: database
image: mariadb # Pull mysql image from Docker Hub
ports: # Set up ports exposed for other containers to connect to
- "3306:3306"
volumes:
- ./dep/mysql:/docker-entrypoint-initdb.d