Skip to content

Instantly share code, notes, and snippets.

Code Review

A consolidation of advice and stuff from the internet

What is code review?

Code review one person reading over another's code and offering comments, suggestions, and feedback about how it could be improved. Often this is done at companies or in open source projects as a required step before proposed changes can be merged into a

@ntamvl
ntamvl / controller-concerns-in-rails-4.md
Last active May 12, 2022 14:34
Controller Concerns in Rails 4

Controller Concerns in Rails 4

If you setup a Rails 4 app, you’ll notice the app/models/concerns and app/controllers/concerns directories. Concerns are modules that can be mixed into your models and controllers to share code between them.

Some developers falsely classify mixins as composition when they are actually a form of inheritance. When you include a module in a class, that module’s methods are added to the inheritance chain just like a parent class’ methods are added to a subclass. So, don’t think you’ve solved the problem of inheritance by simply splitting your inherited code into separate files!

That being said, mixins can be a valuable tool to share code between classes that are otherwise unrelated. Here’s an example of how I chose to use it recently.

I am adding admin reporting features to an app I’m hoping to launch soon. I have an admin controller with a simple before filter to redirect if the current user is not an administrator.

class AdminController < ApplicationController
@thegitfather
thegitfather / vanilla-js-cheatsheet.md
Last active April 7, 2025 02:00
Vanilla JavaScript Quick Reference / Cheatsheet
@hlissner
hlissner / codesign_gdb.md
Last active September 29, 2024 00:25
Codesign gdb on OSX
@tache
tache / README-SSL-Certificates.md
Last active June 15, 2017 16:38
LetsEncrypt and AWS

#Using LetsEncrypt SSL certificates on AWS

This is a document for managing the LetsEncrypt certificates on AWS for Cloudfront and Opsworks.

##Setup

The following are instructions for using LetsEncrypt under Mac OS. It is for a single token for a single server.

It is an active project, so make sure you do a pull every so often.

@loisaidasam
loisaidasam / README.md
Last active January 10, 2025 09:49
Sort git tags by semver

If you're like me and you use semver for versioning your tags, you probably hate when you do this:

$ git tag -l
0.1.0
0.10.0
0.2.0
0.3.0
0.3.1
0.4.0

0.5.0

@sharplet
sharplet / lazy_reduce.rb
Created August 7, 2015 10:44
Lazy `#reduce` and `#join` in Ruby
require "rspec/autorun"
class Enumerator::Lazy
def reduce(*)
Lazy.new([nil]) do |yielder, _|
yielder << super
end
end
def join(separator="")
@maxivak
maxivak / readme.md
Last active February 19, 2025 23:23
Integrating Gem/Engine and Main Rails App
@nberger
nberger / recipes.clj
Created July 8, 2015 03:22
recipes with core.logic
(ns recipes.core
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]
[clojure.core.logic.pldb :as pldb]))
(db-rel in-larder i)
(db-rel recipe r)
(db-rel in-recipe r i)
(db-rel compound-ingredient i is)
@mrw34
mrw34 / gist:b12531d1a8df25f6c170
Last active May 21, 2024 10:47
Trello JSON to CSV conversion using jq
jq -r '["List", "Card"], ((reduce .lists[] as $list ({}; .[$list.id] = $list.name)) as $lists | .cards[] | select(.closed != true) | [$lists[.idList],.name]) | @csv' <nw3RUeLl.json