Skip to content

Instantly share code, notes, and snippets.

View ecoologic's full-sized avatar

Erik ecoologic

View GitHub Profile
{
"added_words":
[
"App",
"refactored",
"refactor",
"api",
"ui",
"async",
"linter",
@ecoologic
ecoologic / debugging.rb
Last active February 27, 2018 05:54
Ecoologic's debugging and console tricks (for Brisbane Ruby Meetup talk)
# CGI.parse(params) # "checklist_list_ids%5B%5D=10806"
# Gem::Specification.map(&:name).sort
# app.users_path # => "/users"
::U = User # Etc
def self.helpme
puts <<-TEXT
v # view helpers (eg: content_tag)
exceptions # List of all exceptions
## NODE-REINSTALL
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.17"
@ecoologic
ecoologic / git_branch.sh
Created October 29, 2015 22:16
Smart Git branches (ordered by last update)
git for-each-ref --sort=-committerdate --format='%(committerdate:short)|%(refname)|%(authorname)' refs/heads refs/remotes | head -n20 | awk -F '|' '{ printf "%s %-70s %s\n", $1, $2, $3 }'
@ecoologic
ecoologic / choose_dependency_direction_wisely.md
Last active February 19, 2020 12:13
Blog post on OO dependency direction
title date author tags
The Direction Of The Dependency
2016-02-26
ecoologic@protonmail.ch
Architecture, Dependency Management, Ruby

The Direction Of The Dependency

When projects grow they become hard to change. One aspect that is not often highlighted is dependency direction. I haven't found much material on the topic, maybe the best ideas came from this talk by Sandi Metz "Less, the path to a better design".

@ecoologic
ecoologic / seeds_spec.rb
Last active October 4, 2015 09:10
Rails seeds specs example
# Wrap in transaction, it's quicker
# and if something fails it will be easier to re-run them separately
ActiveRecord::Base.transaction do
User.create!(email: "a@b.c", etc: :etc) # Don't use FactoryGirl
end
# And they can be tested as follows
# spec/db/seed_spec.rb
require "rails_helper"

Recycling in Brisbane

Items that can be placed in a recycling bin include:

  • All paper (including junk mail, magazines, newspapers, window envelopes)
  • Cans - aluminium and tin-plated steel cans and lids (e.g. food tins)
  • Cardboard
  • Clean kitchen aluminium foil (alfoil)
  • Empty aerosol cans (full or partially full aerosol cans are considered hazardous waste)
  • Foil pie trays
@ecoologic
ecoologic / return.rb
Last active August 29, 2015 14:17
How to use return statement
# One return per line makes it easy to understand / debug
def done?
return false if no_one_done_it?
return false if not_found?
return true if you_did_it?
false
end
# Special case pattern (!= NullObject)
# Some, including Kent Beck and Martin Fowler argue that one or more guard clauses
@ecoologic
ecoologic / when_monkeypatching
Created February 3, 2015 04:16
avoid getting screwed when you update a gem you monkey-patch
# If the behaviour the gem you're monkey patching changes
# your monkey patch might not work anymore
if Gem::Specification.all_names.detect { |gem_v| gem_v == 'haml-3.1.8' }
# my monkey patch here
else
raise "Please check this gem works with the above monkey patch"
end

Faster Development

I'm looking for techniques to produce the same or better result in less time (without sacrificing quality). I'd be happy to read a good fluent book on the topic.

I work for a small web app development consultancy company. Our code doesn't need to be perfect and our clients are happy to have a few non-critical bugs / imperfection and save some money. I understand.

I hate when I'm in the middle of my development and I discover some detail that forces me to rewrite part of my envisioned solution. Once I TDD a controller API that turned out to be completely useless. It didn't take too long, but it's the sort of waste I'm referring to. Another time I learned how to use a small library, but never used it. Since then I've been doing some research to avoid useless development and become more effective in general.

Searching around "faster development" or similar keywords produces mostly results that focus on tools, like snippet and shortcuts for IDE, ZSH tricks etc, I think I'm setup fine for