- Unit tests: Review unit tests first. Unit tests are a fantastic way to grasp how code is meant to be used by others and to learn what the expected behavior is. Are there any test gaps that should be there?
- Method arguments" Make sure arguments to methods make sense and are validated. Mentally test boundary conditions and edge cases.
- Null References" (Yah yah, we know. Use F# and this goes away. We get it already.) Null references are a bitch and it’s worth looking out for them specifically.
- Conventions Consistency" Make sure naming, formatting, etc. follow our conventions and are consistent. I like a codebase that’s fairly consistent so you know what to expect.
- Disposables: Make sure disposable things are disposed. Look for usages of resources that should be disposed but are not.
- Security: There is a whole threat and mitigation review process that falls under this bucket. In simple terms, ask yourself how this code could be exploited. The [STRIDE Threat Mo
This file contains 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
module PaymillSupport | |
def get_payment_token | |
# Simulate the JavaScript bridge we would use in production | |
params = { | |
'transaction.mode' => 'CONNECTOR_TEST', | |
'channel.id' => Rails.configuration.paymill_public_key, | |
'jsonPFunction' => 'function', | |
'account.number' => '4111111111111111', | |
'account.expiry.month' => 1.year.from_now.month, |
This file contains 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
Run tests: | |
mix test | |
Run single test file: | |
mix test path/to/file | |
Run single test: |
This file contains 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/ruby -w | |
module Foo | |
module Foo4Class | |
def reset_instance_count | |
@instance_count = 0 | |
end | |
def new(*a, &b) | |
super.tap { @instance_count += 1 } |
This file contains 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
RSpec::Matchers.define :terminate do |code| | |
actual = nil | |
def supports_block_expectations? | |
true | |
end | |
match do |block| | |
begin | |
block.call |
This file contains 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
require 'rspec/expectations' | |
module ExitCodeMatchers | |
extend RSpec::Matchers::DSL | |
matcher :terminate do | |
actual = nil | |
match do |block| | |
begin |
This file contains 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
After automatically updating Postgres to 9.6.1 via Homebrew, the pg_ctl start command didn't work. | |
The error was something like "database files are incompatible with server". | |
Database files have to be updated before starting the server, here are the steps that had to be followed: | |
# need to have both 9.6.1 and latest 9.5.x installed, and keep 9.6.1 as default | |
brew unlink postgresql | |
brew install postgresql95 | |
brew unlink postgresql95 | |
brew link postgresql |
First, check your current config (example output in homebrew.mxcl.postgresql.plist.xml
lower down in this gist):
cat ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Most importantly, note the -D /usr/local/var/postgres
argument.
Second, shut down your current PostgreSQL.
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.
# Ensure system is in ship-shape.
aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev
OlderNewer