Skip to content

Instantly share code, notes, and snippets.

Avatar
💾
Gettin ma tech awn

Mark Hewitt yayMark

💾
Gettin ma tech awn
  • Perth, Western Australia
View GitHub Profile
@yayMark
yayMark / keybindings.json
Created Aug 11, 2020
Visual Studio Code snippets
View keybindings.json
[
{
"key": "shift+alt+cmd+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "console.log('${TM_SELECTED_TEXT}$1: ', ${TM_SELECTED_TEXT})$2;"
}
},
{
@yayMark
yayMark / hideTwitterTrending.js
Last active Mar 8, 2020
JS: hide trending on Twitter
View hideTwitterTrending.js
const sidebar = document.querySelectorAll('[data-testid=sidebarColumn]')[0];
const trending = sidebar.querySelector('div > div > div > div > div > div:nth-child(3)');
trending.style.display = 'none';
@yayMark
yayMark / objectAsJSON.js
Last active Mar 8, 2020
JavaScript: pretty print an object as formatted plain text
View objectAsJSON.js
console.log(JSON.stringify(obj, null, 2));
@yayMark
yayMark / redirect-test.sh
Created Oct 4, 2019
Shell: test if a website is redirecting due to server or application software
View redirect-test.sh
curl -I http://site.test
View gist:ffdb066c0a7517ef023add8edd1987e5
<StyledDialog[\n\s][\s\S]*?size=({'|')xs
@yayMark
yayMark / carsalesHelper.js
Last active Sep 17, 2019
JavaScript: carsales.com.au 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
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
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
http://example.com/wp-login.php?action=logout
@yayMark
yayMark / passwords.sh
Created Feb 19, 2019
Bash script to generate a list of random passwords
View passwords.sh
for i in `seq 10`; do openssl rand -base64 16 | colrm 17; done
You can’t perform that action at this time.