Skip to content

Instantly share code, notes, and snippets.

View AllanPooley's full-sized avatar
💃

Allan Pooley AllanPooley

💃
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AllanPooley
AllanPooley / LookHappyIconBlack.svg
Last active August 8, 2017 22:03
LookHappyIconBlack
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AllanPooley
AllanPooley / AussiePhoneValidation.js
Created July 25, 2018 00:48
Australian Phone Number Validation in JavaScript
const isPhone = (phoneNumber) => {
const cleanedPhoneNumber = phoneNumber.replace(/-|\s/g, ''); // Remove spaces and hyphens before performing test
const pattern = new RegExp('^(?:\\+?(61))? ?(?:\\((?=.*\\)))?(0?[2-57-8])\\)? ?(\\d\\d(?:[- ](?=\\d{3})|(?!\\d\\d[- ]?\\d[- ]))\\d\\d[- ]?\\d[- ]?\\d{3})$');
return pattern.test(cleanedPhoneNumber);
};
@AllanPooley
AllanPooley / UpdateWPTablesNewAddress.txt
Last active August 7, 2018 00:27
WordPress - Change Address / URL SQL Tables Update
UPDATE wp_options SET option_value = replace(option_value, 'oldURL', 'newURL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'oldURL','newURL');
UPDATE wp_posts SET post_content = replace(post_content, 'oldURL', 'newURL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldURL','newURL');
@AllanPooley
AllanPooley / ScrollTrackedComponent.jsx
Created September 9, 2018 21:59
Higher Order Component to track top and bottom position of an element (useful for elements that need to change when inside the viewport)
import React, { Component } from 'react';
import { isClient } from '../../config/app';
const scrollComponent = (WrappedComponent) => {
class ScrollComponent extends Component {
state = {
topPos: 0,
bottomPos: 0
};
componentDidMount() {
@AllanPooley
AllanPooley / moment-greetings.js
Created October 9, 2018 09:59
Time based user greetings (Good Morning, Afternoon, Evening) using moment.js
getGreetingTime = (currentTime) => {
if (!currentTime || !currentTime.isValid()) { return 'Hello'; }
const splitAfternoon = 12; // 24hr time to split the afternoon
const splitEvening = 17; // 24hr time to split the evening
const currentHour = parseFloat(currentTime.format('HH'));
if (currentHour >= splitAfternoon && currentHour <= splitEvening) {
// Between 12 PM and 5PM
return 'Good afternoon';
@AllanPooley
AllanPooley / hobbies.js
Created November 9, 2018 02:13
Compiled List of Hobbies Array
const interests = [
'3D printing',
'Amateur radio',
'Scrapbook',
'Amateur radio',
'Acting',
'Baton twirling',
'Board games',
'Book restoration',
'Cabaret',