Skip to content

Instantly share code, notes, and snippets.

@thekevinscott
thekevinscott / custom_post_type_scaffold.php
Created January 10, 2012 16:37
Easily add custom post types, with custom fields, in Wordpress
<?php
/*
////////////////////////////////////////////////////////////
//////
////// Abstracted code for quickly adding custom post types
////// include this file in functions.php, then add custom post types like so:
//////
////////////////////////////////////////////////////////////
@thekevinscott
thekevinscott / explodeTree.js
Last active August 15, 2017 05:17
explodeTree in Javascript
// Function for exploding an array of strings representing files on disk into a tree structure.
// Takes something like this
var files = [
'debug.js',
'users/create.js',
'users/edit.js',
'users/list/a.js',
'users/list/b.js'];
@thekevinscott
thekevinscott / connectWillAppear: Full implementation
Last active August 8, 2016 13:02
An example of adding a componentWillFocus event to a react native class
import React, { Component } from 'react';
import { connect } from 'react-redux';
import {
AppState,
} from 'react-native';
function getWrappedComponent(
component,
[
mapStateToProps,
class WrapperComponent extends Component {
constructor(props) {
super(props);
this.state = {
handledMounted: false,
appState: null,
};
this.refHandler = this.refHandler.bind(this);
this.handleAppStateChange = this.handleAppStateChange.bind(this);
this.componentWillAppear = this.componentWillAppear.bind(this);
import React, { Component } from 'react';
import { connect } from 'react-redux';
function getWrappedComponent(
component,
[
mapStateToProps,
mapDispatchToProps,
mergeProps,
options,
import React, { Component } from 'react';
import { connect } from 'react-redux';
function getWrappedComponent(
component,
[
mapStateToProps,
mapDispatchToProps,
mergeProps,
options,
class WrapperComponent extends Component {
constructor(props) {
super(props);
this.refHandler = this.refHandler.bind(this);
}
refHandler(c) {
this.instance = c.getWrappedInstance();
}
class WrapperComponent extends Component {
constructor(props) {
super(props);
this.state = {
handledMounted: false,
};
this.refHandler = this.refHandler.bind(this);
this.componentWillAppear = this.componentWillAppear.bind(this);
}
class WrapperComponent extends Component {
constructor(props) {
super(props);
this.state = {
handledMounted: false,
};
this.refHandler = this.refHandler.bind(this);
this.componentWillAppear = this.componentWillAppear.bind(this);
}
import typeToReducer from 'type-to-reducer';
import {
ActionConst,
} from 'react-native-router-flux';
const initialState = {
scene: {
name: 'Games Overview',
key: 'Games Overview',
title: 'Games Overview',