Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍🔬

Luján Fernaud lujanfernaud

👨‍🔬
View GitHub Profile
View slow_query_logger.rb
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)
@castwide
castwide / rails.rb
Last active Oct 26, 2020
Enhance Rails Intellisense in Solargraph
View rails.rb
# 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
@redrick
redrick / rspec_rails_cheetsheet.rb
Last active Jun 18, 2020 — forked from nerdinand/rspec_rails_cheetsheet.rb
New expect syntax + new hash syntax and couple corrections
View rspec_rails_cheetsheet.rb
#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)
@baweaver
baweaver / ruby_books.md
Last active Sep 16, 2020
A list of books for learning and expanding on your Ruby knowledge.
View ruby_books.md

Ruby Book List

Learning Ruby

You're taking your first steps into Ruby

The Well Grounded Rubyist

A good introduction to programming in general. Easy on newer programmers.

@phansch
phansch / yardoc_cheatsheet.md
Last active Oct 19, 2020 — forked from chetan/yardoc_cheatsheet.md
Improved YARD cheatsheet
View yardoc_cheatsheet.md
View capybara_cheat_sheet.md

Navigating

visit("/projects")
visit(post_comments_path(post))

Clicking links and buttons

@eparreno
eparreno / sidekiq_delete_jobs.md
Last active Sep 4, 2020
How to delete Sidekiq jobs in a Rails app using ActiveJobs
View sidekiq_delete_jobs.md

How to delete Sidekiq jobs in a Rails app using ActiveJobs

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.

job_id and jid

When using ActiveJobs, Rails will return a job_id after sending the job to ActiveJobs

job = UserMailer.send_invite(params).deliver_later
@aembleton
aembleton / docx2md.md
Last active Oct 5, 2020 — forked from vzvenyach/docx2md.md
Convert a Word Document into MD
View docx2md.md

Converting a Word Document to Markdown in One Move

The Problem

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.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

@PurpleBooth
PurpleBooth / README-Template.md
Last active Oct 25, 2020
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

You can’t perform that action at this time.