Skip to content

Instantly share code, notes, and snippets.

View thegallagher's full-sized avatar

David Gallagher thegallagher

View GitHub Profile
@thegallagher
thegallagher / rewrite-media.php
Last active June 17, 2022 03:37
Rewrite Media URLs
<?php
/**
* Plugin Name: Rewrite Media URLs
* Plugin URI: https://thegallagher.net/wordpress/plugins/rewrite-media/
* Description: Rewrite URLs for media to a remote server for local development.
* Version: 1.0.1
* Author: David Gallagher
* Author URI: https://thegallagher.net/
* License: GPL v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@thegallagher
thegallagher / wp-init.sh
Created July 29, 2016 06:34
Install WordPress on a devbox
#!/usr/bin/env bash
set -e
# Config
NAME=`basename "$PWD"`
SERVER_URL="http://localhost/$NAME"
ADMIN_USER="devbox"
ADMIN_PASS="devbox"
ADMIN_EMAIL="[email protected]"
@thegallagher
thegallagher / tools.sh
Created July 28, 2016 08:22
Install web development tools on Ubuntu 16.04
#!/bin/bash
# Git
sudo apt-get -y install git
# Node.js
sudo apt-get -y install nodejs
sudo apt-get -y install npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
@thegallagher
thegallagher / lamp.sh
Last active June 8, 2018 15:08
Install LAMP for development on Ubuntu 16.04
#!/bin/bash
# This script is intended for use in development only. It is not optimized or secure for production use.
# Config
export PASSWORD=devbox
# Apache
sudo apt-get -y install apache2
sudo chmod a+rwx /var/www/html # we might want to replace this with group permissions
@thegallagher
thegallagher / even-columns.js
Last active October 27, 2016 23:26
Even height columns and rows
/**
* MIT License
*
* Copyright (c) 2016 David Gallagher
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@thegallagher
thegallagher / main.js
Created April 11, 2016 12:00
Detecting tel link support
<script>
jQuery(function($) {
var iframe = $('<iframe></iframe>');
iframe.attr('name', 'tellink');
iframe.css('display', 'none');
iframe.appendTo('body');
$('a[href^="tel:"]').attr('target', 'tellink');
});
</script>
@thegallagher
thegallagher / mixins.scss
Created April 11, 2016 11:56
Improved CSS text stroke using SASS and trigonometry.
// Trigonometry functions from https://unindented.org/articles/trigonometry-in-sass/
@mixin stroke($width, $color, $step-multiplier: 8) {
$unit: unit($width);
$unitless: $width / ($width * 0 + 1);
$steps: $unitless * $step-multiplier;
$shadow: ''; // need a starter
@for $i from 0 to $steps {
$x: $width * cos(2 * pi() * $i / $steps);
$y: $width * sin(2 * pi() * $i / $steps);
@thegallagher
thegallagher / functions.php
Created April 11, 2016 10:31
WooCommerce - Get a shipping estimate for a product
<?php
/**
* Get a shipping estimate for a product
*
* @param \WC_Product|int|null $product
*
* @return array|null
*/
function get_product_shipping_estimate($product = null) {
if ($product === null) {
@thegallagher
thegallagher / fixsitemanager.php
Created August 24, 2011 02:49
Filezilla site manager duplicates remover.
<?php
/*
* Filezilla site manager duplicates remover.
* Please backup your sitemanager.xml file before using.
*/
// OPTIONS: change here as required.
define('OUTPUT_XML', true); // If set to true then output the browser, otherwise false to save directly back to the file.