Skip to content

Instantly share code, notes, and snippets.

View yayMark's full-sized avatar
💾
Gettin ma tech awn

Mark Hewitt yayMark

💾
Gettin ma tech awn
  • Perth, Western Australia
View GitHub Profile
@yayMark
yayMark / addDay.js
Created March 22, 2019 02:13
JavaScript: add a day to a date if one time is less than another
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
yayMark / findParentTagId.js
Created March 9, 2019 23:44
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.
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 + '"]');
@yayMark
yayMark / gist:11d394e83ef209f35015006c7166d96d
Created March 5, 2019 01:31
WordPress: logout via URL
http://example.com/wp-login.php?action=logout
@yayMark
yayMark / passwords.sh
Created February 19, 2019 04:16
Bash script to generate a list of random passwords
for i in `seq 10`; do openssl rand -base64 16 | colrm 17; done
@yayMark
yayMark / sync.sh
Created February 6, 2019 06:32
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
yayMark / wp_change_user_password.sql
Created December 13, 2018 03:30
WordPress: change the password for an existing user
UPDATE `wp_users` SET `user_pass`= MD5('tzFuO7YR1ElE85lu3Xmt') WHERE `user_login`='iamtheadminbowbeforeme';
@yayMark
yayMark / other_pages_using_template.php
Created October 11, 2018 07:32
WordPress: find out which pages are using the same template as this one
<?php
$template = get_page_template_slug();
$args = array(
'post_type' => 'page',
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => $template
)
)
// Callback function to remove default bio field from user profile page
// https://gist.github.com/dkomando/6214787a8d36d9f13c9b
if(!function_exists('remove_bio_box')){
function remove_bio_box($buffer){
$buffer = preg_replace('/<tr class=\"user-description-wrap\"[\s\S]*?<\/tr>/','',$buffer,1);
return $buffer;
}
function user_profile_subject_start(){ ob_start('remove_bio_box'); }
function user_profile_subject_end(){ ob_end_flush(); }
@yayMark
yayMark / functions.php
Created September 17, 2018 22:16
WordPress: remove the editor from the top of a post type in wp-admin
<?php
function post_type_no_editor() {
$post_type = 'insert_post_type_here';
remove_post_type_support($post_type, 'editor');
}
add_action('init', 'post_type_no_editor', 100);
@yayMark
yayMark / jQuery.outline.js
Created September 6, 2018 07:19
Put a border on a jQuery element or two
(function ($) {
$.fn.outline = function(options) {
var settings = $.extend({
borderWidth: "1px",
borderStyle: "solid",
borderColor: "red"
}, options);
return this.css({
borderWidth: settings.borderWidth,