Skip to content

Instantly share code, notes, and snippets.

View CapeRatel's full-sized avatar

Mikhail Krassovskiy CapeRatel

  • Rudny, Kazakhstan
View GitHub Profile
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);
}
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
@CapeRatel
CapeRatel / 0_reuse_code.js
Created June 2, 2016 18:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
def generate_uuid
loop do
uuid = SecureRandom.hex(11)
break uuid unless User.find_by(uuid: uuid)
end
end
Capybara.javascript_driver = :poltergeist
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end