Skip to content

Instantly share code, notes, and snippets.

View stephencroberts's full-sized avatar

Stephen Roberts stephencroberts

View GitHub Profile
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@stephencroberts
stephencroberts / object.js
Last active August 29, 2015 14:21
Convert json object to Review model
{
file: {
url: "http://someimage.jpg",
title: "Some Image"
}
}
{
file: {
url: "http://someimage.jpg",
title: "Some Image"
}
}
@stephencroberts
stephencroberts / data.coffee
Created May 23, 2015 05:09
AngularJS dynamic models
'use strict'
data = ($injector) ->
init = ->
registerModels()
service = {}
registerModels = ->
@stephencroberts
stephencroberts / review.coffee
Created May 25, 2015 15:54
Angular object literal proto
'use strict'
reviewProto = {
getTitle: ->
@fields.title if @fields and @fields.title
getAlias: ->
@fields.alias if @fields and @fields.alias
getSuperLabel: ->
@fields.category if @fields and @fields.category
getShortDescription: ->
@stephencroberts
stephencroberts / service.coffee
Created June 4, 2015 02:12
Angular service promise caching
getResponse = (method, type, params) =>
@promises ||= {}
promiseKey = (method + type + JSON.stringify params).replace(/[\{\}",:\-\._\[\] ]/g, '')
return @promises[promiseKey] if @promises[promiseKey]
console.log promiseKey
deferred = $q.defer()
params ||= {}
params.access_token = contentfulConfig.access_token
@stephencroberts
stephencroberts / config.coffee
Created June 5, 2015 05:12
Angular head module
'use strict'
headConfig = [
{
name: 'title'
selector: 'title'
template: '<title></title>'
html: true
}
{
@stephencroberts
stephencroberts / pre-push
Last active December 27, 2015 14:58
Development pre-push git hook that creates a versioned database patch if pushing to the staging server
#!/bin/bash
# Rename develop.sql to <version>.sql
# Exit if develop.sql is empty
if [ -s database/develop.sql ]; then exit 0; fi
# Get version tag from the latest commit
VER=`git tag --contains HEAD`
@stephencroberts
stephencroberts / setup.php
Last active December 27, 2015 16:59
Setup dev Joomla! site after pulling database from somewhere else
<?php
// Load Joomla! config
if (!file_exists('httpdocs/configuration.php')) {
echo "Couldn't find configuration.php!\n";
exit();
}
include('httpdocs/configuration.php');
$config = new JConfig();
@stephencroberts
stephencroberts / post-merge
Last active December 27, 2015 17:09
Dev git post-merge
#!/bin/bash
# Apply stash to restore local develop.sql (or other changes)
git stash apply
git stash drop
# Which branch are we on?
branch=`git rev-parse --abbrev-ref HEAD`
php -f setup.php "$branch"