You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';
This is quite common and very helpful. Another option is to do:
name || (name = 'joe');
./configure \ | |
--prefix=/usr \ | |
--mandir=/usr/share/man \ | |
--infodir=/usr/share/info \ | |
--sysconfdir=/private/etc \ | |
--with-apxs2=/usr/sbin/apxs \ | |
--enable-cli \ | |
--with-config-file-path=/etc \ | |
--with-libxml-dir=/usr \ | |
--with-openssl=/usr \ |
You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';
This is quite common and very helpful. Another option is to do:
name || (name = 'joe');
// Any way to merge these in Backbone? | |
this.collection.on('thing', this.something, this); | |
this.collection.on('thing', this.anotherThing, this); |
<snippet> | |
<content><![CDATA[ | |
// ${1} Resource | |
Route::get('${1}s', array('as' => '${1}s', 'uses' => '${1}s@index')); | |
Route::get('${1}s/(:any)', array('as' => '${1}', 'uses' => '${1}s@show')); | |
Route::get('${1}s/new', array('as' => 'new_${1}', 'uses' => '${1}s@new')); | |
Route::get('${1}s/(:any)edit', array('as' => 'edit_${1}', 'uses' => '${1}s@edit')); | |
Route::post('${1}s', '${1}s@create'); | |
Route::put('${1}s/(:any)', '${1}s@update'); | |
Route::delete('${1}s/(:any)', '${1}s@destroy'); |
$(window).scroll(function() { | |
var scroll = $(window).scrollTop(); | |
if (scroll > 50) { | |
$(".menu-bar").addClass("menu-bar-scroll"); | |
} else { | |
$(".menu-bar").removeClass("menu-bar-scroll"); | |
} | |
}); | |
(function(){ |
$(window).scroll(function() { | |
var scroll = $(window).scrollTop(); | |
if (scroll > 50) { | |
$(".menu-bar").addClass("menu-bar-scroll"); | |
} else { | |
$(".menu-bar").removeClass("menu-bar-scroll"); | |
} | |
}); | |
(function(){ |
(function(){ | |
var menuBar = $(".menu-bar ul"); | |
var menuActive = menuBar.find("li.active"); | |
menuBar.hover(function() { | |
menuActive.toggleClass("active"); | |
}); | |
})(); |
// Which do you prefer more? | |
// trigger event and get out | |
var vent = _.extend({}, Backbone.Events); | |
App.Router = Backbone.Router.extend({ | |
routes: { | |
'show/:id': 'show' | |
}, | |
show: function(id) { |