require "json" | |
require "digest" | |
require "logger" | |
class SlowQueryLogger | |
def initialize(output = nil, opts = {}) | |
# will log any query slower than 500 ms | |
@threshold = opts.fetch(:threshold, "500").to_i | |
@logger = Logger.new(output || STDOUT) |
# The following comments fill some of the gaps in Solargraph's understanding of | |
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but | |
# ignored at runtime. | |
# | |
# You can put this file anywhere in the project, as long as it gets included in | |
# the workspace maps. It's recommended that you keep it in a standalone file | |
# instead of pasting it into an existing one. | |
# | |
# @!parse | |
# class ActionController::Base |
#Model | |
expect(@user).to have(1).error_on(:username) # Checks whether there is an error in username | |
expect(@user.errors[:username]).to include("can't be blank") # check for the error message | |
#Rendering | |
expect(response).to render_template(:index) | |
#Redirecting | |
expect(response).to redirect_to(movies_path) |
You're taking your first steps into Ruby
A good introduction to programming in general. Easy on newer programmers.
NOTE: This is outdated. Check the comments below for more up-to-date forks of this gist.
Improved YARD CHEATSHEET http://yardoc.org
forked from https://gist.github.com/chetan/1827484 which is from early 2012 and contains outdated information.
Sidekiq jobs can be enqueued or scheduled. Enqueued means that they are gonna be picked up as soon as possible, scheduled jobs will be enqueued at some specific time.
When using ActiveJobs, Rails will return a job_id
after sending the job to ActiveJobs
job = UserMailer.send_invite(params).deliver_later
A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.
On a mac you can use homebrew by running the command brew install pandoc
.