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
uploadAvatar: function (req, res) { | |
req.file('avatar').upload({ | |
// don't allow the total upload size to exceed ~10MB | |
maxBytes: 10000000 | |
},function whenDone(err, uploadedFiles) { | |
if (err) { | |
return res.negotiate(err); | |
} |
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 User < ActiveRecord::Base | |
# keep the default scope first (if any) | |
default_scope { where(active: true) } | |
# constants come up next | |
COLORS = %w(red green blue) | |
# afterwards we put attr related macros | |
attr_accessor :formatted_date_of_birth |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 generate_uuid | |
loop do | |
uuid = SecureRandom.hex(11) | |
break uuid unless User.find_by(uuid: uuid) | |
end | |
end |
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
Capybara.javascript_driver = :poltergeist | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end |