Skip to content

Instantly share code, notes, and snippets.

View Jamiewarb's full-sized avatar
🦑

Jamie Warburton Jamiewarb

🦑
View GitHub Profile
@Jamiewarb
Jamiewarb / .htaccess
Created April 26, 2017 10:03
Remove file extension with .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
@Jamiewarb
Jamiewarb / .htaccess
Last active June 16, 2017 08:48
Maintenance page using .htaccess
# Maintenance page
RewriteCond %{REMOTE_ADDR} !^000\.000\.000\.000
RewriteCond %{REQUEST_URI} !^/maintenance\.php$
# Allow a specific requ
RewriteCond %{REQUEST_URI} !^/company-logo.png$ [NC]
# Allow a series of filetypes
RewriteCond %{REQUEST_URI} !\.(css|jpe?g?|png|gif|woff|ttf) [NC]
RewriteRule ^(.*)$ https://www.domain.com/maintenance.php [R=307,L]
@Jamiewarb
Jamiewarb / gist:de90a919c6df36b7be2b4f9f135761d2
Last active November 16, 2017 21:32
PHP Switcher Script (For Homebrew installations)
#!/bin/bash
# If user id not equal to root user id
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# If no params are passed
@Jamiewarb
Jamiewarb / gist:f81f1d50d30a05a5e1bd63912d108e3b
Last active May 10, 2018 13:25
Generate SSL Cert and Self Sign for Apache VHost
# Here we generate an SSL cert for zuma.local, add it to keychain and trust it.
# https://support.citrix.com/article/CTX135602
# Steps:
# 1. Create a .cnf file for the config of our certificate.
# This is required to get the subjectAltName field, which Firefox and Chrome
# required to trust our cert.
# 2. Generate a key and a cert file using openssl
# 3. Add the cert to your ssl vhost (e.g. port :443)
# 4. Add the cert to your MacOS KeyChain, and set it to Always Trust
@Jamiewarb
Jamiewarb / CaseStudyImage.vue
Last active October 23, 2018 09:27
Vue x Lottie - animation controller
// This is an example of how we can use the above two files to add a background image to the case
// study animation data
<template>
<lottie
:class="classes"
:height="height"
:options="options"
class="v-cs-image"
@animCreated="setupAnimation"
@Jamiewarb
Jamiewarb / gist:c0a42af70b19d1a5a0699fa57da202c8
Created January 12, 2019 14:15
Rename all files in a directory with a sequential numerical prefix/suffix
#ls | cat -n | while read n f; do mv -n "$f" "FILENAME-$n.extension"; done
#e.g.
ls | cat -n | while read n f; do mv -n "$f" "rheinbacher-premium-beissbier-$n.jpg"; done
@Jamiewarb
Jamiewarb / analytics.js
Last active February 8, 2019 12:31
Analytics Helper for Vue, to decide what platform to track specific events in
import Vue from 'vue';
/**
* This helper file is used to track analytics events to the correct platform.
* It is designed to track page views and events to Google Analytics.
* It then tracks conversions, registrations and leads to Facebook.
* Some events it may track to both GA and FB where applicable.
*
* It is recommended to just use the helper methods for tracking (e.g. trackBooking() )
*/
@Jamiewarb
Jamiewarb / AnalyticsTracker.vue
Last active February 12, 2019 11:02
Vue Decorator Component for analytics tracking of non-vue button clicks
<template>
<div>
<slot :trackButtonClick="trackButtonClick" />
</div>
</template>
<script>
import { trackButtonClick } from '~/helpers/analytics';
export default {
@Jamiewarb
Jamiewarb / slugify.js
Last active March 28, 2019 16:33 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}