Skip to content

Instantly share code, notes, and snippets.

View mmorrison's full-sized avatar

Marcus Morrison mmorrison

View GitHub Profile
@mmorrison
mmorrison / gist:ca1e5fc3d73fd4c85071
Created April 15, 2015 19:05
ChOP Social Replace
was
<meta name='title' content='{{ organization.meta_title }}'>
<meta name='og:title' content='{{ organization.meta_title }}'>
<meta name='description' content='{{ organization.meta_description }}'>
<meta name='og:description' content='{{ organization.meta_description }}'>
<meta name='keywords' content='{{ organization.meta_keywords }}'>
replace
<meta name='title' content='{{ organization.meta_title }}'>
<meta name='description' content='{{ organization.meta_description }}'>
@mmorrison
mmorrison / formhelper.coffee
Created December 1, 2012 05:32 — forked from tdegrunt/formhelper.coffee
Simple FormHelper that works well with Backbone.js Models
###
Helps creating and submitting forms
- easy labeling
- automatically inserts values of the model to the form
- is able to serialize forms to JSON
- can submit the form to the server
- automatically displays errors if there are any
###
class FormHelper
@mmorrison
mmorrison / Timezones
Created November 24, 2012 04:05
Timezone list
@timezones = [
{name: 'MIT', info: 'Midway Islands Time', seconds: -39600},
{name: 'MIT', info: 'Hawaii Standard Time', seconds: -36000},
{name: 'AKST', info: 'Alaska Standard Time', seconds: -32400},
{name: 'AKDT', info: 'Alaska Daylight Savings Time', seconds: -28800},
{name: 'PST', info: 'Pacific Standard Time', seconds: -28800},
{name: 'PDT', info: 'Pacific Daylight Savings Time', seconds: -25200},
{name: 'MST', info: 'Mountain Standard Time', seconds: -25200, country: "United States"},
{name: 'MDT', info: 'Mountain Daylight Savings Time', seconds: -21600},
{name: 'CST', info: 'Central Standard Time', seconds: -21600, country: "United States"},
@mmorrison
mmorrison / i18n.coffee
Created November 23, 2012 03:46 — forked from madrobby/i18n.coffee
Backbone i18n with CoffeeScript
# before this file is loaded, a locale should be set:
#
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
#
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
@mmorrison
mmorrison / app.coffee
Created September 23, 2012 03:13 — forked from jmreidy/app.coffee
Backbone.js Loading notification
activeRequests = []
Backbone._sync = Backbone.sync
Backbone.sync = (method, model, options) ->
asyncToken = Backbone._sync.apply(this,arguments)
asyncToken.then () ->
activeRequests = _.without activeRequests, asyncToken
if activeRequests.length == 0 then console.log "LOADING COMPLETE"
if activeRequests.length == 0
console.log "START LOADING"
@mmorrison
mmorrison / nesting.coffee
Created September 7, 2012 16:31 — forked from lagartoflojo/nesting.coffee
Helper function for nesting Backbone collections (CoffeeScript version)
Backbone.Model::nestCollection = (attributeName, nestedCollection) ->
#setup nested references
for item, i in nestedCollection
@attributes[attributeName][i] = nestedCollection.at(i).attributes
#create empty arrays if none
nestedCollection.bind 'add', (initiative) =>
if !@get(attributeName)
@attributes[attributeName] = []
@get(attributeName).push(initiative.attributes)
@mmorrison
mmorrison / gist:3542884
Created August 30, 2012 22:19 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mmorrison
mmorrison / app.coffee
Created March 7, 2012 22:37 — forked from jmreidy/app.coffee
Backbone.js Loading notification
activeRequests = []
Backbone._sync = Backbone.sync
Backbone.sync = (method, model, options) ->
asyncToken = Backbone._sync.apply(this,arguments)
asyncToken.then () ->
activeRequests = _.without activeRequests, asyncToken
if activeRequests.length == 0 then console.log "LOADING COMPLETE"
if activeRequests.length == 0
console.log "START LOADING"
@mmorrison
mmorrison / app.coffee
Created March 7, 2012 22:37 — forked from jmreidy/app.coffee
Backbone.js Loading notification
activeRequests = []
Backbone._sync = Backbone.sync
Backbone.sync = (method, model, options) ->
asyncToken = Backbone._sync.apply(this,arguments)
asyncToken.then () ->
activeRequests = _.without activeRequests, asyncToken
if activeRequests.length == 0 then console.log "LOADING COMPLETE"
if activeRequests.length == 0
console.log "START LOADING"
@mmorrison
mmorrison / 1) contact.liquid
Created August 4, 2011 22:36 — forked from dirkkelly/1) contact.liquid
Example Contact Form
{% block enquiry %}
<form id="enquiry_form" action="{{ contents.enquiries.api.create }}" method="post">
{% editable_long_text 'welcome' %}
<h3>Got an enquiry?</h3>
<p>Please fill in the form below and we will get in touch as soon as possible.</p>
{% endeditable_long_text %}
<fieldset>
<div id="error_message">No Errors</div>
<ol>
<li>