Skip to content

Instantly share code, notes, and snippets.

View dgowrie's full-sized avatar
🤘

David Gowrie dgowrie

🤘
View GitHub Profile
@dgowrie
dgowrie / acf-inline-svg.php
Created January 21, 2018 02:45 — forked from derekshirk/acf-inline-svg.php
Output Inline SVGs from ACF image field
<?php
/* ————————————————————————— */
/* ACF Inline SVGs
/* ————————————————————————— */
$repeater = 'repeater_field_name'
if ( have_rows( $repeater ) ): ?>
<section class="content-main">
<div class="container"> <?php
var ReactTable = React.createClass({
getInitialState: function() {
return {currentData: this.props.data};
},
render: function() {
var key = Date.now();
@dgowrie
dgowrie / react-redux-container-component.sublime-snippet
Last active August 9, 2017 07:54
Sublime Text snippet for a React Redux Container Component
<snippet>
<content><![CDATA[
import React from 'react';
import PropTypes from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
const propTypes = {
name: PropTypes.string,
};
@dgowrie
dgowrie / react_class_component.sublime-snippet
Last active August 7, 2017 04:08
Sublime Text Snippet: React: class component
<snippet>
<content><![CDATA[
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
name: PropTypes.string,
};
class ${1:${TM_FILENAME/(.+)\..+|.*/$1/:ComponentName}} extends React.Component {
@dgowrie
dgowrie / react_component_stateless.sublime-snippet
Last active August 19, 2017 21:10
Sublime Text Snippet: react_component_stateless.sublime-snippet
<snippet>
<content><![CDATA[
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
};
function ${1:${TM_FILENAME/(.+)\..+|.*/$1/:ComponentName}}(${2:props}) {
@dgowrie
dgowrie / Tab.js
Created July 4, 2017 19:37 — forked from diegocasmo/Tab.js
Source code for implementing a React <Tabs/> component.
import React, {PropTypes} from 'react';
export const Tab = (props) => {
return (
<li className="tab">
<a className={`tab-link ${props.linkClassName} ${props.isActive ? 'active' : ''}`}
onClick={(event) => {
event.preventDefault();
props.onClick(props.tabIndex);
}}>
@dgowrie
dgowrie / app.js
Created June 29, 2017 14:05 — forked from verticalgrain/app.js
React Router V4 Redirect after form submission
import React, { Component } from 'react'
import { Redirect } from 'react-router'
export default class ContactForm extends Component {
constructor () {
super();
this.state = {
fireRedirect: false
}
}
@dgowrie
dgowrie / gist:41b7146b5f0f61780dd988a290f0b932
Created June 15, 2017 17:23 — forked from davisford/gist:5039064
git clone into non-empty directory

Let's say you start a project locally, and do some editing.

$ mkdir -p ~/git/foo && cd ~/git/foo
$ touch NEWFILE

Now you decide you want to create a new github repo and track it, but the directory is non-empty so git won't let you clone into it. You can fix this, thusly:

@dgowrie
dgowrie / remote_uploads.php
Created July 22, 2016 19:30
WordPress Plugin: Remote Uploads Directory
<?php
/*
Plugin Name: Remote Uploads Directory
Author: David Gowrie
*/
add_filter('upload_dir', 'remote_media_upload_dir');
function remote_media_upload_dir( $upload ) {
@dgowrie
dgowrie / gist:674b7b31e2f91c244fc7
Created March 24, 2016 16:36 — forked from pgoldrbx/gist:d730cda13de64db69175
This ___ isn't working... did I do something dumb?

Why aren't I seeing my changes?

What do you mean 404 error?!?

Oh come ON, I just DID that!

How often are you working on something and are stuck trying to debug some irritation problem, only to discover after time that you've done something embarrassingly stupid? It's good to go through a checklist of "dumb" questions before spending an hour in the debugger or pouring over changesets.

Example:

  • Is the computer plugged in? (classic tech support!)