Skip to content

Instantly share code, notes, and snippets.

Mark Hewitt yayMark

  • Perth, Western Australia
Block or report user

Report or block yayMark

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
yayMark / objectAsJSON.js
Created Nov 15, 2019
JavaScript: pretty print an object as formatted plain text
View objectAsJSON.js
console.log(JSON.stringify(obj, null, 2);
yayMark /
Created Oct 4, 2019
Shell: test if a website is redirecting due to server or application software
curl -I http://site.test
View gist:ffdb066c0a7517ef023add8edd1987e5
yayMark / carsalesHelper.js
Last active Sep 17, 2019
JavaScript: helper - get the year of the car and odometer reading from the DOM
View carsalesHelper.js
// year of car
document.querySelector('.details-wrapper h1').innerText.split(' ')[0]
// odometer
Number(document.querySelector('.key-details-item-title').innerText.split(' ')[0].replace(/,/g, ''))/20000
// 20000 km average a year
yayMark / addDay.js
Created Mar 22, 2019
JavaScript: add a day to a date if one time is less than another
View addDay.js
const startedTime = '14:30';
const completedTime = '01:15';
const startedDate = '20/01/2019';
if (completedTime < startedTime) {
const [day, month, year] = startedDate.split('/');
const currentDate = new Date(Date.parse(`${year}-${month}-${day}`));
const currentDateUnix = currentDate.valueOf();
const newDateUnix = currentDateUnix + 24*60*60*1000;
yayMark / findParentTagId.js
Created Mar 9, 2019
WordPress, Elementor: Get to a parent element of a Elementor element that I attach a class to. I wish I didn't have to do this.
View findParentTagId.js
function findParentTagId(childClass, parentTag) {
var element = document.querySelector(childClass);
var tag = element.tagName;
// repeat until you get to body
while (tag != 'body') {
element = element.parentElement;
if (element.tagName.toLowerCase() === parentTag.toLowerCase()) {
var dataset = element.dataset['id'];
return document.querySelector('[data-id="' + dataset + '"]');
View gist:11d394e83ef209f35015006c7166d96d
yayMark /
Created Feb 19, 2019
Bash script to generate a list of random passwords
for i in `seq 10`; do openssl rand -base64 16 | colrm 17; done
yayMark /
Created Feb 6, 2019
Use rsync to sync files from server to local
rsync -avP user@server:/home/servername/website/web/wp-content/uploads/ /Users/yaymark/projects/website/web/wp-content/uploads
yayMark / wp_change_user_password.sql
Created Dec 13, 2018
WordPress: change the password for an existing user
View wp_change_user_password.sql
UPDATE `wp_users` SET `user_pass`= MD5('tzFuO7YR1ElE85lu3Xmt') WHERE `user_login`='iamtheadminbowbeforeme';
You can’t perform that action at this time.