Skip to content

Instantly share code, notes, and snippets.

View seafarer's full-sized avatar
☎️
DM me, maybe

Colin OBrien seafarer

☎️
DM me, maybe
View GitHub Profile
@seafarer
seafarer / template.php
Created October 20, 2015 15:40 — forked from gildotdev/template.php
Drupal 7 hook method to remove cache busting query strings on css and js files. Related to this post https://drupal.org/node/242875
<?php
/**
* Implements hook_process_html
*/
function templatenamespace_process_html(&$vars) {
$search = array('scripts' => 'src=', 'styles' => 'href=', 'styles' => '@import\surl\(');
foreach ( $search as $var => $word ) {
if ( !empty($vars[$var]) ) {
@seafarer
seafarer / nginx-rewrite.conf
Created October 3, 2016 17:14
301 redirect .html to non .html for nginx
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
rewrite ^/(.*)/$ /$1 permanent;
try_files $uri/index.html $uri.html $uri/ $uri =404;
@seafarer
seafarer / functions.php
Last active August 13, 2022 00:52
Use Laravel Mix with a basic WordPress theme like Underscores. So much easier than messing around with Gulp etc.
<?php
/**
* Take advantage of Mix's cache busting function
*/
function asset( $path ) {
// Asset manifest file from Mix
$manifest = get_template_directory_uri() . '/dist/mix-manifest.json';
$manifest_array = json_decode(file_get_contents($manifest), true);
@seafarer
seafarer / lovable-download.js
Created April 4, 2026 02:12
Use this to download a Lovable project. All subfolders must be open. Will not download binary files. Paste into dev tools and go.
(async () => {
const sleep = ms => new Promise(r => setTimeout(r, ms));
if (!window.JSZip) {
await new Promise((resolve, reject) => {
const s = document.createElement('script');
s.src = 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js';
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);