Skip to content

Instantly share code, notes, and snippets.

View mxdvl's full-sized avatar
🧭
I love me an SVG

Max Duval mxdvl

🧭
I love me an SVG
View GitHub Profile
@mxdvl
mxdvl / non-blocking-document.createElement.html
Last active January 22, 2024 23:16 — forked from sndrs/non-blocking-document.write.html
Override document.createElement('script') to prevent 3rd parties injecting blocking scripts
<!DOCTYPE html>
<html>
<head>
<title>Prevent non-async script</title>
<script>
(function(Document) {
const trueCreate = document.createElement.bind(document);
Document.prototype.createElement = function(tag, options) {
const script = trueCreate(tag, options);
@mxdvl
mxdvl / auto-node-verison.sh
Last active July 29, 2021 11:34 — forked from sndrs/auto_nvm_use.sh
Automatically set node version per project using .nvmrc file
# ZSH
autoload -U add-zsh-hook
# place default node version under $HOME/.node-version
load-nvmrc() {
DEFAULT_NODE_VERSION=`cat $HOME/.node-version`
if [[ -f .nvmrc && -r .nvmrc ]]; then
fnm use
elif [[ `node -v` != $DEFAULT_NODE_VERSION ]]; then
echo Reverting to node from "`node -v`" to "$DEFAULT_NODE_VERSION"
@mxdvl
mxdvl / CacheBustingKirbyValetDriver.php
Last active August 2, 2018 14:16 — forked from stidges/CacheBustingLaravelValetDriver.php
Rewrite filename-based cache busting URIs (e.g. jquery.1476809927.js) to the correct filename in Laravel Valet
<?php
class CacheBustingKirbyValetDriver extends KirbyValetDriver
{
public function isStaticFile($sitePath, $siteName, $uri)
{
$result = parent::isStaticFile($sitePath, $siteName, $uri);
if ($result !== false) {
return $result;
}
if (preg_match('/(.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif|svg|mp3|mp4|ogg)$/i', $uri, $matches)) {