from PIL import Image | |
cover = Image.open(self.get_art_path(track)) | |
cover_mime = Image.MIME[cover.format] | |
cover_width = cover.size[0] | |
cover_height = cover.size[1] | |
cover_bitdepth = cover.bits | |
with open(self.get_art_path(track), 'rb') as image_file: | |
cover_data = image_file.read() |
When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.
-
Raw Attribute Strings
<div my-directive="some string" another-param="another string"></div>
# | |
# UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs | |
# just run "sudo trimforce enable" to activate the trim support from now on! | |
# | |
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/) | |
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/ | |
# | |
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything | |
# | |
# Alternative to http://www.groths.org/trim-enabler-3-0-released/ |
# Keep code struture in models consistent | |
# Inspired by http://rails-bestpractices.com/posts/75-keep-code-struture-in-models-consistent | |
# One example: (From top to bottom) | |
associations | |
scopes | |
class methods | |
validates | |
callbacks | |
instance methods |
It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media
This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.
Your app/widgets
directory can get crazy pretty fast. If you're learning Apotomo, then you'll probably move things around and try many ways to order your widgets directory. This is not so much about that - I still haven't found a good way to organize my widgets, but I've found a way to keep the widget classes themselves DRY.
And it should look something like this:
# A BaseWidget to apply stuff to widgets across
# the board. All widgets should inherit from this
class ApplicationWidget < Apotomo::Widget
include ActionController::RecordIdentifier # so I can use dom_id
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
set :sync_directories, ["public/assets", "public/galleries"] | |
set :sync_backups, 3 |