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 / too_wide.js
Created December 7, 2017 01:03
HTML/CSS: find what element is wider than the content of the page
var docWidth = document.documentElement.offsetWidth;
[].forEach.call(
document.querySelectorAll('*'),
function(el) {
if (el.offsetWidth > docWidth) {
console.log(el);
}
}
);
@yayMark
yayMark / url_contains.js
Created December 12, 2017 04:02
JavaScript: see if the current URL contains a string
function urlContains(chunk) {
return window.location.href.indexOf(chunk) !== -1;
}
@yayMark
yayMark / clearing_301_redirects_in_chrome.md
Created December 14, 2017 03:02
Clearing 301 redirects in Chrome

Clearing 301 redirects in Chrome

  • chrome://net-internals/
  • Click the arrow in the top right of the window
  • Click Clear Cache
@yayMark
yayMark / functions.php
Last active December 14, 2017 23:27
WordPress: display the template in use
<?php
add_action( 'admin_bar_menu', 'show_template' );
function show_template() {
$is_dev = strpos(getenv('APP_ENV'), 'dev') !== false;
if ($is_dev) {
global $template;
print_r( $template );
}
}
@yayMark
yayMark / git_ignore_local_files.md
Last active December 15, 2017 04:32
Git: ignore files without committing to .gitignore

Git: ignore files without committing to .gitignore

If you want to ignore local files, but not commit it to the repo in .gitignore, use .git/info/exclude instead

@yayMark
yayMark / clear_fixed_nav_linking_within_page.html
Created December 19, 2017 09:15
Clear a fixed header when linking to a section within the page
<html>
<title></title>
<head>
<style>
/* replace 200px with the height you're attempting to clear */
.jump-target::before {
display: block;
content: " ";
margin-top: -200px;
height: 200px;
@yayMark
yayMark / resize-throttler.js
Created January 8, 2018 08:23
Run code on window resize, but in a way that won't max out CPU.
window.addEventListener("resize", resizeThrottler, false);
var resizeTimeout;
function resizeThrottler() {
// ignore resize events as long as an actualResizeHandler execution is in the queue
if ( !resizeTimeout ) {
resizeTimeout = setTimeout(function() {
resizeTimeout = null;
actualResizeHandler();
@yayMark
yayMark / remove_p_tags_surrounding_img_tags.js
Created January 23, 2018 02:36
WordPress: use jQuery to remove p tags around your img tags
jQuery('p:has(img) img').unwrap()
@yayMark
yayMark / gist:d10eada1a75f68e3aff59b387c1fa37b
Created March 9, 2018 22:05
Fix gulp watch error with Gaze on Ubuntu
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
from Sebastián Gurin (cancerberoSgx) https://github.com/gulpjs/gulp/issues/217
@yayMark
yayMark / gist:0888764e71abe9cc7197d48b5547b440
Created March 9, 2018 22:42
Blue shows as purple within Chrome on Ubuntu
chrome://flags/#force-color-profile
I switched to sRGB from Default. Worked great.