Skip to content

Instantly share code, notes, and snippets.

@homerjam
homerjam / gist:394a3ba39e8848051195
Created May 14, 2015 14:48
Redirect old domain to new domain via proxy
# .htaccess for old domain
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP:X-FORWARDED-HOST} !(.*)newdomain(.*) [NC]
RewriteRule (.*) http://newdomain.com/$1 [R=301,L]
# .htaccess for new domain
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://olddomain.com/$1 [P,L]
@homerjam
homerjam / mdChipDraggable.js
Last active September 14, 2021 11:06
Angular Material draggable chips directive
angular.module('mdChipDraggable', [])
.directive('mdChipDraggable', function () {
return {
restrict: 'A',
scope: {},
bindToController: true,
controllerAs: 'vm',
controller: ['$document', '$scope', '$element', '$timeout',
function ($document, $scope, $element, $timeout) {
var vm = this;
@homerjam
homerjam / uniforms.default.json
Last active July 29, 2016 13:52 — forked from glslioadmin/TEMPLATE.glsl
GLSL.io Transition (v1)
{}
@homerjam
homerjam / mc-section.js
Created January 11, 2017 12:57
Custom MJML component for use in MailChimp templates
import { MJMLElement, helpers } from 'mjml-core'
import cloneDeep from 'lodash/cloneDeep'
import merge from 'lodash/merge'
import React, { Component } from 'react'
const tagName = 'mc-section'
const parentTag = ['mj-container']
const defaultMJMLDefinition = {
attributes: {
'mc:hideable': null,
@homerjam
homerjam / mc-image.js
Created January 11, 2017 12:58
Custom MJML component useful for MailChimp templates
import { MJMLElement } from 'mjml-core'
import merge from 'lodash/merge'
import min from 'lodash/min'
import React, { Component } from 'react'
const tagName = 'mc-image'
const parentTag = ['mj-column', 'mj-hero-content']
const defaultMJMLDefinition = {
attributes: {
'mc:edit': null,
@homerjam
homerjam / nuxt-axios-cache.js
Last active September 19, 2020 18:18
Simple plugin which decorates the community axios nuxt-module with an lru-cache
import hash from 'object-hash';
import sizeof from 'object-sizeof';
import lruCache from 'lru-cache';
const cacheEnabled = true;
const cacheMaxAge = 30 * 60 * 1000;
const cacheMaxSize = 128 * 1000 * 1000;
const getCacheKey = config => hash({
method: config.method,
@homerjam
homerjam / vue-scrollwizardry.js
Created November 15, 2017 10:59
Vue plugin for scrollwizardy
/*
eslint no-underscore-dangle: 0, max-len: 0, prefer-destructuring: 0, no-nested-ternary: 0
*/
import TweenMax from 'gsap/TweenMax';
import TimelineMax from 'gsap/TimelineMax';
import * as ScrollWizardry from 'scrollwizardry';
// import * as ScrollWizardry from '../../scrollwizardry/src';
const { Controller, Scene } = ScrollWizardry;
@homerjam
homerjam / aframe-render-enabled.js
Created March 20, 2018 12:43
A-FRAME component to allow enabling/disabling/disposing of the renderer - useful for embedded scenes/spa's
const AFRAME = require('aframe');
if (!AFRAME.components['render-enabled']) {
AFRAME.registerComponent('render-enabled', {
schema: { type: 'boolean', default: true },
init() {
const _this = this;
this.renderEnabled = this.data;
this.el.render = function render() {
@homerjam
homerjam / mc-image.js
Last active April 12, 2018 14:21
mc-image: Mailchimp compatible MJML v4 component
import min from 'lodash/min'
import { BodyComponent } from 'mjml-core'
import widthParser from 'mjml-core/lib/helpers/widthParser'
export default class McImage extends BodyComponent {
static tagOmission = true
static allowedAttributes = {
@homerjam
homerjam / mc-section.js
Created April 12, 2018 14:21
mc-section: Mailchimp compatible MJML v4 component
import { BodyComponent } from 'mjml-core'
import { flow, identity, join, filter } from 'lodash/fp'
import widthParser from 'mjml-core/lib/helpers/widthParser'
const makeBackgroundString = flow(filter(identity), join(' '))
export default class McSection extends BodyComponent {
static allowedAttributes = {
'mc:hideable': 'boolean',
'mc:repeatable': 'string',