This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* CSS Hack to push/pull a fixed width element left/right without floating. | |
Probably common knowledge but it's new to me. */ | |
/* Margin: auto is often used to center one fixed-width element within another, like so */ | |
#element1 { | |
width: 980px; | |
} | |
#child1 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Does validates :uniqueness get called even if a field has not changed? | |
# Isn't this a performance issue? | |
validates :name, :schedule_id, :uniqueness => true | |
# My experience that it does. So isn't it almost always necessary to make sure a change has taken | |
# place before running the validation? As every field being checked for uniqueness requires a | |
# database hit. | |
# This would be better: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin transparency($opacity, $microsoft_friendly_stupidly_unneccessary_percentage_value) { | |
zoom: 1; | |
filter: alpha(opacity=$microsoft_friendly_stupidly_unneccessary_percentage_value); | |
opacity: $opacity; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Say you want to iterate over a variable that might be an array or null/undefined, | |
# you can do this: | |
for order in orders or [] | |
# Do something with orders | |
# This simply iterates over the empty array if book is null or undefined. Handy if | |
# you have an object like this: | |
customers = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ = jQuery | |
// Takes an array of strings | |
$.preloadImages = function(images) { | |
$(images).each(function() { | |
$('<img />')[0].src = this; | |
}); | |
} | |
// Use it anytime after the document loads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShiftDock.Views.RotasIndex extends Backbone.View | |
# ... | |
initialize: -> | |
@collection.on 'fetched', @render, this | |
render: -> | |
# ... | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShiftDock.Routers.Rotas extends Backbone.Router | |
routes: | |
'': 'index' | |
initialize: -> | |
@collection = new ShiftDock.Collections.Rotas() | |
@collection.view = new ShiftDock.Views.RotasIndex(collection: @collection, el: '#container') | |
index: (year, week) -> | |
@collection.fetch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assume response JSON for `book` looks like this: | |
# { | |
# id: 1, | |
# pages: [{ | |
# id: 1, | |
# chapter: 1, | |
# text: 'It was the best of times, ' | |
# }, { | |
# id: 2, | |
# chapter: 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.dependentSelect = -> | |
$(@).addClass('dependent') | |
@each -> | |
$(@).data('pre', $(@).val()) | |
@disableOthers = -> | |
$('select.dependent') | |
.not($(@)) | |
.find("option[value=#{$(@).val()}]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def as_json | |
super(methods: [:balance, :available]) | |
end |
OlderNewer