- Read the PR description
- Read through all the changes, considering the following questions.
- Is there anything you can praise about this PR? Start with praise.
- Are variable names brief but descriptive?
- Are new/changed functions no longer than a paragraph?
- Do all function parameters have default values where appropriate?
- Is the code clear and clean? (see Robert C. Martin's Clean Code)
- Is there enough documentation?
- Does the programming style meet the requirements of the repository (PEP8 for python, google for c++, etc.)
This file contains hidden or 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
Model | |
.where( | |
"EXTRACT(dow FROM log_in) IN (1,2,3,4,5)" | |
) | |
.where( | |
"log_in::time BETWEEN '9:00' AND '18:00'" | |
) | |
.where( | |
"log_in BETWEEN now()::timestamp - (interval '1 week' AND now()::timestamp)" | |
) |
This file contains hidden or 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
# app/models/experience.rb | |
# | |
# == Schema Information | |
# | |
# Table name: experiences | |
# | |
# id :integer not null, primary key | |
# title :string | |
# description :text | |
# created_at :datetime not null |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'fileutils' | |
files = Dir["*/*.PDF"].collect{|f| File.expand_path(f)} | |
files.each_with_index do |file, index| | |
puts "copying file #{index}" | |
FileUtils.cp file, "pdf/#{index}.pdf" | |
end |
This file contains hidden or 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
If someone (like me) finds this later, I was able to achieve this without adding this helper, and instead having capybara attach like so: | |
attach_file(@basic_file, class: 'dz-hidden-input', make_visible: true) | |
Found via Stack Overflow, here: https://stackoverflow.com/questions/16722291/how-to-test-dropzone-js-upload-with-rails-cucumber-and-capybara |
This file contains hidden or 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
Test Dropzone.js File Uploads With Capybara | |
Dec 29, 2014 | |
Integration tests involving complex JS interactions are a pain, especially with something like drag and drop file uploads (you can’t exactly drag something into a headless browser). My recent use case was an AngularJS application using Dropzone.js with Ruby on Rails on the backend, so I needed a way to make Dropzone play nicely with Capybara Webkit. Here is the spec helper I ended up with: | |
def drop_in_dropzone(file_path) | |
# Generate a fake input selector | |
page.execute_script <<-JS | |
fakeFileInput = window.$('<input/>').attr( | |
{id: 'fakeFileInput', type:'file'} |
This file contains hidden or 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 self.dedupe | |
# find all models and group them on keys which should be common | |
grouped = all.group_by{|model| [model.title,model.info,model.address,model.phone] } | |
grouped.values.each do |duplicates| | |
# the first one we want to keep right? | |
first_one = duplicates.shift # or pop for last one | |
# if there are any more left, they are duplicates | |
# so delete all of them | |
duplicates.each{|double| double.destroy} # duplicates can now be destroyed | |
end |
(wherever it says url.com, use your server's domain or IP)
Login to new server as root, then add a deploy user
sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy
And Update the new password
This file contains hidden or 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
<div class="selection:bg-rose-500 selection:text-white"> | |
<div class="min-h-screen bg-rose-100 flex justify-center items-center"> | |
<div class="p-8 flex-1"> | |
<div class="w-80 bg-white rounded-3xl mx-auto overflow-hidden shadow-xl"> | |
<div class="relative h-48 bg-rose-500 rounded-bl-4xl"> | |
<svg class="absolute bottom-0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"> | |
<path fill="#ffffff" fill-opacity="1" d="M0,64L48,80C96,96,192,128,288,128C384,128,480,96,576,85.3C672,75,768,85,864,122.7C960,160,1056,224,1152,245.3C1248,267,1344,245,1392,234.7L1440,224L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path> | |
</svg> | |
</div> | |
<div class="px-10 pt-4 pb-8 bg-white rounded-tr-4xl"> |
This file contains hidden or 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
#!/bin/bash | |
# | |
# I use this bash script to create an rvm gemset for a new rails app | |
# and I call this script from my rails_prep.rb ruby script | |
# | |
echo "create new gemset for new rails application ..." | |
#rvm --create 1.9.2@$1 # <--> this instruction does not work, but the following does | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" && rvm --create @$1 | |
# ------------------------------- | |
# Use the gemset we just created |