Skip to content

Instantly share code, notes, and snippets.

View zachmayberry's full-sized avatar

Zachary Mayberry zachmayberry

View GitHub Profile
@zachmayberry
zachmayberry / collectionView.js
Created November 16, 2012 01:02
A simple reference example for rendering a collection in a list view using Backbone.js
(function() {
// Model
var User = Backbone.Model.extend({
defaults: {
name: '',
email: '',
password: ''
},
@zachmayberry
zachmayberry / formToModel.js
Created November 17, 2012 02:31
Serialize form data and reduce to model object
// Serialize form data and reduce to model object
var form = this.$el.find('form').serializeArray();
var data = _(form).reduce(function( acc, field ) {
acc[field.name] = field.value;
return acc;
}, {});
// Save the result
this.collection.create(data);
@zachmayberry
zachmayberry / tree
Last active January 4, 2021 12:09
Simple alias to allow "tree" command anywhere...
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
@zachmayberry
zachmayberry / attachEvents.js
Last active December 13, 2015 18:58
A simpler helper for pretty, backbone-like event assignments.
// Be sure to include underscore.js in your project
app.attachEvents = function( events ) {
_.each( events, function(value, key, list) {
var ev = key.split(' ')[0],
el = key.split(' ')[1],
fn = value;
jq( el ).bind( ev, fn );
});
};
@zachmayberry
zachmayberry / zeptoAjaxCacheDisable.js
Created March 23, 2013 03:44
A simple reminder of the difference between disabling ajax cache in Zepto from what I'm used to in jQuery.
$.ajaxSettings.cache = false;
@zachmayberry
zachmayberry / parallax.js
Last active January 4, 2016 08:11
Parallax scroll event optimization for changing background images and not disrupting the fluid scroll
/*
Used in conjunction with Scott Robin's backstretch script:
https://github.com/srobbin/jquery-backstretch
*/
(function($) {
var justExecuted = false;
$(window).on('scroll', function() {
@zachmayberry
zachmayberry / respawn-pane
Last active October 6, 2016 07:52
Restart tmux pane hanging ssh session
:respawn-pane -k
# http://unix.stackexchange.com/a/88393
(function($, _, Backbone) {
// Configuration
var config = {};
config.imageHost = 'https://s3.amazonaws.com/suh-s3-nfs/static/images/Squarespace/';
// Parent object
var Tiles = Tiles || {};
// Model
@zachmayberry
zachmayberry / package.json
Created November 19, 2014 04:33
Stop using grunt
{
"name": "AbandonGrunt",
"version": "1.0.0",
"description": "A quick test to try to leave grunt behind.",
"main": "main.js",
"watch": {
"lint": "source/js/*.js",
"sass": "source/sass/*.scss"
},
"scripts": {