Skip to content

Instantly share code, notes, and snippets.

View JvanderHeide's full-sized avatar

Jeffrey van der Heide JvanderHeide

View GitHub Profile
@JvanderHeide
JvanderHeide / elementFromTemplateString.ts
Created September 9, 2020 14:30
elementFromTemplateString.ts
export default <T extends HTMLElement>(templateString: string): T => {
const div = document.createElement('div');
div.innerHTML = templateString;
return <T>div.firstElementChild;
}
@JvanderHeide
JvanderHeide / hard-reset-and-clean.sh
Last active July 1, 2020 09:38
Completely reset a git repository. I found this useful when testing external scripts etc. on a repo that modify and create files. Only use this if you're really sure you want to get rid of all your local changes.
# Added this prompt for safety's sake in case you wanted to add this to your profile
while true; do
read -p "Are your sure you want to completely reset your repository, including untracked files? (y/N) " yn
yn=${yn:-N}
case "$yn" in
[Yy]* ) break;;
[Nn]* ) exit;;
esac
done
@JvanderHeide
JvanderHeide / string-methods.js
Last active August 29, 2015 14:17
JavaScript String/URL methods
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (str){
return this.slice(0, str.length) == str;
};
}
if (typeof String.prototype.toURL != 'function') {
String.prototype.toURL = function () {
var parser = document.createElement('a');
parser.href = this;
@JvanderHeide
JvanderHeide / W3 Total Cache Flushing
Created January 20, 2014 14:23
Place this file somewhere and call it directly or via a cron tab. It allows you to flush all, or an array of pages. I'm using this to clear the cache of a pages that contain a date reference, at midnight. This is particularly useful when using "Disk Enhanced" page caching with the W3TC plugin, since WP_cron does not work with it. You might want …
<?php
// Flush everything or just some pages
$flush_all_pages = false;
// An array of urls to flush (required if $flush_all_pages is false)
$urls = array(
'http://www.example.com/',
);
//Set W3TC Constants