-
Back up
A few things to think about:
- media
- photos, music, and videos should all be on external drive
- projects/code
- media
- make sure all Git repos are pushed up
# This is a record, as in a vinyl. | |
class Record < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :album | |
# explicitly stating what is needed | |
def from_library_for_album(collector, album) | |
where(user_id: collector).where(album_id: album) | |
end |
### UPDATE: ruby-debuy19 is no longer maintained, use https://github.com/cldwalker/debugger | |
# Install with: | |
# bash < <(curl -L https://raw.github.com/gist/1333785) | |
# | |
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug | |
echo "Installing ruby-debug with ruby-1.9.3-p0 ..." | |
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem |
// iOS Media Queries | |
// Goal: capture styles for iPhone, iPhone 3G, iPhone 3GS, iPhone 4, iPhone 4S, iPad, and iPad 2 | |
// | |
// Author: Tony Schneider (@tonywok) | |
// Please tell me where I fail. :) | |
// iPhone v(4,4S) portrait | |
// test: black text (overwritten by v* portrait) with blue background | |
@media all and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) { | |
a { |
person = { | |
save: function(){ | |
$.ajax('...', { | |
context: this, | |
success: this.saved, | |
error: this.errored | |
}) | |
}, | |
saved: function(data){ | |
console.log('OMG. USEFUL SCOPING.') |
class Edition < ActiveRecord::Base | |
scope :published, where(arel_table[:published_at].not_eq(nil)) | |
scope :generated, where(arel_table[:generated_at].not_eq(nil)) | |
scope :available, published.generated | |
end | |
class Magazine < ActiveRecord::Base | |
# This is where #merge works its magic, by allowing you to merge scopes from other models. | |
scope :with_available_editions, includes(:editions).merge(Edition.available) | |
end |
Performance is often ignored in Rails development until it becomes a problem. If ignored too long, though, it can get very tricky to improve. It's valuable to regularly audit performance and look for hotspots or design choices that are slowing things down.
Inspecting the log will help identify the source of several performance issues the application may have.
The Rails application log outputs the time spent processing each request. It breakdowns the time spent at the database level as well processing the view code. In development mode, the logs are displayed on STDOUT where the server is being run. In a production setting the logs will be in log/production.log
within the application's root directory.
#If you're on a mac/linux, you can just copy and paste this. If you're on Windows, you need to figure out how to do this using Putty. | |
ssh [email protected] |
#include <stdlib.h> | |
#include <stdio.h> | |
int(*outer(int val))() { | |
int inner() { | |
return val; | |
} | |
return inner; | |
} |
dc.ui.Document = Backbone.View.extend({ | |
initialize: function() { | |
this.model.bind('change', this._onDocumentChange); | |
this.model.bind('change:selected', this._setSelected); | |
this.model.bind('view:pages', this.viewPages); | |
this.model.notes.bind('add', this._addNote); | |
this.model.notes.bind('reset', this._renderNotes); | |
this.model.pageEntities.bind('reset', this._renderPages); | |
} |