Skip to content

Instantly share code, notes, and snippets.

View WalrusSoup's full-sized avatar

JL WalrusSoup

View GitHub Profile
@WalrusSoup
WalrusSoup / YiiTinkerwellDriver.php
Last active September 18, 2020 19:57
Yii 1.1 Tinkerwell Driver
<?php
// Put this into the .tinkerwell folder alongside of tinker_bootstrap.php to allow yii 1.1 to work within tinker
use Tinkerwell\ContextMenu\Label;
use Tinkerwell\ContextMenu\Submenu;
use Tinkerwell\ContextMenu\SetCode;
use Tinkerwell\ContextMenu\RunCode;
use Tinkerwell\ContextMenu\OpenURL;
class YiiTinkerwellDriver extends LaravelTinkerwellDriver {
@WalrusSoup
WalrusSoup / MarketoLazyLoader.js
Last active October 28, 2021 18:10
Lazily load marketo forms without additional libraries
// Include this at some point in your wordpress install. It's pretty helpful!
function dynamicScriptInserter(scriptSource, args) {
let script = document.createElement('script');
script.src = scriptSource;
Object.keys(args).forEach(key => {
script.setAttribute(key, args[key]);
})
document.getElementsByTagName('head')[0].appendChild(script);
}
@WalrusSoup
WalrusSoup / LazyLoadIntercom.js
Created October 29, 2021 17:58
Lazy load intercom on scroll to help speed up PageSpeed Insights
// replace YOUR_INTERCOM_URL_HERE with your app_id
var intercomLoader = function() {
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/YOUR_INTERCOM_URL_HERE';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s, x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();
window.Intercom('boot', {
app_id: 'YOUR_INTERCOM_URL_HERE'
})
window.removeEventListener('scroll', intercomLoader);
}
window.addEventListener('scroll', intercomLoader);
@WalrusSoup
WalrusSoup / LazyLoadFacebook.js
Created October 29, 2021 18:07
Lazy Load facebook pixel
var facebookLoader = function() {
window.removeEventListener('scroll', facebookLoader);
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
@WalrusSoup
WalrusSoup / laravel-pint-with-sail-phpstorm.md
Last active September 23, 2024 10:10
Run laravel pint from Phpstorm with WSL on save

Saving this so I dont forget later.

Run Laravel Pint from Phpstorm with WSL on save with Laravel Sail

  1. create custom file watcher
  2. For tool to Run on Changes add the full path to vendor/bin/sail via WSL like so \\wsl$\Ubuntu\home\ozen\projects-sail\MYPROJECT\vendor\bin\sail
  3. Arguments bin pint $/FileRelativePath$
  4. Output paths to refresh $FilePath$
  5. Working Directory $ProjectFileDir$