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
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
Just migrated it from Codepen.io to markdown. Credit goes to David Conner.
Working with DOM | Working with JS | Working With Functions |
---|---|---|
Accessing Dom Elements | Add/Remove Array Item | Add Default Arguments to Function |
Grab Children/Parent Node(s) | Add/Remove Object Properties | Throttle/Debounce Functions |
Create DOM Elements | Conditionals |
Note: these instructions are for pre-Sierra MacOS. Sierra (10.12) and newer users see https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d by @gravitylow
If you are getting this in gdb on OSX while trying to run a program:
#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.
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
require "rspec/autorun" | |
class Enumerator::Lazy | |
def reduce(*) | |
Lazy.new([nil]) do |yielder, _| | |
yielder << super | |
end | |
end | |
def join(separator="") |
(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) |
jq -r '["List", "Card"], ((reduce .lists[] as $list ({}; .[$list.id] = $list.name)) as $lists | .cards[] | select(.closed != true) | [$lists[.idList],.name]) | @csv' <nw3RUeLl.json |