Skip to content

Instantly share code, notes, and snippets.

@jnicol
jnicol / gist:98e1b4fae45b8befab321248b6acde8c
Created July 3, 2026 12:39
Migrate bitbucket repo to github
# Github's importer does not support Bitbucket's new mandarotry API token authentication.
# Manual migration is required:
# Clone the Bitbucket repository
git clone https://bitbucket.org/<workspace>/<repo>.git
cd <repo>
# Create an empty repository on GitHub (do NOT add README)
git remote add github https://github.com/<username>/<repo>.git
@jnicol
jnicol / animated-lazy-load.html
Last active June 28, 2026 23:45
Animate native loading="lazy" images
Source: https://medienbaecker.com/articles/animate-native-lazy-loading
<style>
@media (scripting: enabled) {
[loading="lazy"] {
opacity: 0;
transition: opacity 0.5s;
}
}
</style>
@jnicol
jnicol / cursor-fill.html
Last active June 2, 2026 04:59
CSS/JS cursor effects
<html>
<body>
<style>
/*
Cursor follow + fill effect inspired by
https://juno-hamburg.com/
and
@jnicol
jnicol / .htaccess
Created April 28, 2025 01:22
.htaccess redirect insecure traffic to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@jnicol
jnicol / functions.php
Created August 22, 2023 22:31
Display advanced custom fields values in WordPress admin columns
/*
* Add columns to exhibition post list
*/
function add_acf_columns ( $columns ) {
return array_merge ( $columns, array (
'start_date' => __ ( 'Starts' ),
'years' => __ ( 'Years' )
) );
}
add_filter ( 'manage_exhibition_posts_columns', 'add_acf_columns' );
@jnicol
jnicol / fix-mail-return-path.php
Created May 5, 2023 23:00
Fix WordPress wp_mail Return Path header, which is used for SPF checks, so that it matches From domain.
<?php
/*
Plugin Name: Email Return Path Fix
Author: Abdussamad Abdurrazzaq
Author URI: https://abdussamad.com/archives/567-Fixing-the-WordPress-Email-Return-Path-Header.html
*/
class email_return_path {
function __construct() {
add_action( 'phpmailer_init', array( $this, 'fix' ) );
}
@jnicol
jnicol / stop-video.js
Last active February 26, 2023 07:13 — forked from cferdinandi/stop-video.js
A simple method to stop YouTube, Vimeo, and HTML5 videos from playing.
/**
* Stop all iframes or HTML5 <video>'s from playing
*/
var stopVideos = function () {
var videos = document.querySelectorAll('iframe, video');
Array.prototype.forEach.call(videos, function (video) {
if (video.tagName.toLowerCase() === 'video') {
video.pause();
} else {
var src = video.src;
@jnicol
jnicol / copy-to-clipboard.js
Created February 23, 2022 23:20
Copy to clipboard
function copyToClipboard() {
const cb = navigator.clipboard;
const el = document.getElementById('my-element');
cb.writeText(el.innerText);
}
/* source: https://stackoverflow.com/a/43763137/315045 */
ol, ul {
padding-left: 0;
}
li {
list-style: none;
padding-left: 1.25rem;
position: relative;
@jnicol
jnicol / polyfills.html
Created March 20, 2020 01:05
polyfill.io for old browsers only
<!--
Only load polyfills for old browsers
@see https://devhints.io/polyfill.io
@see https://polyfill.io
-->
<script>if(!(window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('<script src="https://cdn.polyfill.io/v3/polyfill.min.js"></scr'+'ipt>')}</script>
<!-- Same as above, but also loads Fetch API polyfill -->
<script>if(!(window.fetch&&window.Promise&&[].includes&&Object.assign&&window.Map)){document.write('<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=default,fetch"></scr'+'ipt>')}</script>