Skip to content

Instantly share code, notes, and snippets.

@seanbehan
seanbehan / email-regex-match.js
Last active October 3, 2022 07:49
extract email addresses from string with javascript
// http://rubular.com/r/twBPG8HQgP
regex = /\S+[a-z0-9]@[a-z0-9\.]+/img
"hello sean@example.com how are you? do you know bob@example.com?".match(regex)
// ["sean@example.com", "bob@example.com"]
/*
How to use Angular inside a Backbone view.
*/
var ViewWithAngular = Backbone.View.extend({
render: function(container){
var $injector = angular.injector(['ng', 'mason']);
$injector.invoke(function($rootScope, $compile){
var elem = $compile('<h1 ng-controller="NestedCtrl">Backbone View with nested Angular. Message: {{message}}</h1>')($rootScope);
@dpfranklin
dpfranklin / s3.thor
Created April 26, 2013 22:05
Thor task for deploying Middleman site to S3.
class Deploy < Thor
default_task :s3
desc "cleanS3test", "delete current
deploy"
def cleanS3test
puts "Deleting current deploy..."
system "s3cmd -r -f del s3://www.example.com/"
puts "Done"
/**
* Watcher leaks for jQuery
* RubaXa <trash@rubaxa.org>
* MIT Licensed.
*
* API:
* $.leaks.get();
* $.leaks.watch();
* $.leaks.unwatch();
* $.leaks.remove();
@paulkoegel
paulkoegel / mixed_layout.md
Last active December 11, 2015 19:28
Extended MarionetteLayout to which you can pass an array of region names and View instances (via .addViews()); automatically creates the required region DOM containers. SEE BELOW FOR CODE.

MixedLayout

MixedLayouts are our custom extension of MarionetteLayouts which we use to wrap a heterogeneous collection of Backbone Views. This allows us to change the contents of complex pages all at once while preventing zombie views and leaving certain static elements like Navigation, Toolbar, or FooterViews on the page.

Rationale and Raison d'être

Marionette's Composite and CollectionViews are limited to rendering all their associated collection's items with the same ItemView. For our homepage, e.g., we need to encapsulate various Views - TopView, CategoryView, QuoteOfTheDayView etc. - in dynamic order into one Marionette View construct that can be .closed() to prevent zombie views. The Marionette view component designed to encapsulate heterogeneous subviews is the Layout. However, we cannot use a vanilla MarionetteLayout for the homepage because a Layout relies

@davidmfoley
davidmfoley / coffeelint.vim
Created April 2, 2012 14:07
coffeelint/vim quickfix integration
" Get coffeelint errors in the vim quickfix menu
" requires coffeelint to be installed and in the path
" http://www.coffeelint.org/
" lint the current file
function! CoffeeLintFile()
let current = fnamemodify(expand("%"), ':p')
call CoffeeLintAnalyze(current)
endfunction
@strathmeyer
strathmeyer / handlebars.object_helpers.js
Created November 16, 2011 21:57
Handlebars.js helpers to iterate over objects
// HELPER: #key_value
//
// Usage: {{#key_value obj}} Key: {{key}} // Value: {{value}} {{/key_value}}
//
// Iterate over an object, setting 'key' and 'value' for each property in
// the object.
Handlebars.registerHelper("key_value", function(obj, fn) {
var buffer = "",
key;