Skip to content

Instantly share code, notes, and snippets.

View jdickey's full-sized avatar
💭
Open to possibilities. Enquire within.

Jeff Dickey jdickey

💭
Open to possibilities. Enquire within.
View GitHub Profile
@jdickey
jdickey / removing all files and subdirectories in a deep thick tree
Last active August 29, 2015 13:56
Removing all files in a deep, thick tree of files and directories
$ find . | cpio -pmdu /tmp/foo
1738239 blocks
$ cd /tmp/foo
$ du -hsc .
916M .
916M total
$ find .[a-z]* * | wc -l
27791
$ time find .[a-z]* * -delete
@jdickey
jdickey / 00-Four Generations of spec_helper.rb.md
Last active August 29, 2015 13:57
Four generations of an RSpec `spec/spec_helper.rb` file.
@jdickey
jdickey / RuboCop- and coverage-aware teaspoon_env.rb
Created March 30, 2014 18:57
Teaspoon `spec/teaspoon_env.rb` file with added code-coverage settings and RuboCop warnings disabled.
# encoding: utf-8
# This file allows you to override various Teaspoon configuration directives
# when running from the command line. It is not required from within the Rails
# environment, so overriding directives that have been defined within the
# initializer is not possible.
#
# Set RAILS_ROOT and load the environment.
ENV['RAILS_ROOT'] = File.expand_path('../../', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
@jdickey
jdickey / Attempt at understanding namespaces in a Rails app SOLVED.md
Last active August 29, 2015 13:57
Trying to understand namespaces through a bog-simple Rails app stand-up. (SOLVED)S

SOLVED IT! See this Gist. Original follows:

====

OK, here's where I am: trying to get a bog-simple blog app (adapting Avdi Grimm's Objects on Rails e-book example up and happy. With a few twists, as I explain here.

But I can't spec my routes. Why?

In this Gist:

@jdickey
jdickey / Getting closer to figuring out namespaces in a Rails app SOLVED.md
Last active August 29, 2015 13:57
Getting closer(?) to figuring out namespaces in a Rails app
@jdickey
jdickey / SOLVED Specifying namespaces in a Rails routing spec.md
Last active August 29, 2015 13:57
SOLVED specifying namespaces in a Rails routing spec.

FINALLY! For the three of you who have been following this epic saga through Gists 9907240 and 9908206, we have finally found the elusive green bar; a mystery wrapped in an enigma disguised as a riddle.

There were two key changes that made this work:

  1. The describe group containing the routing spec must have the annotation :type => :routing; and
  2. The route I was actually trying to get was /blog/blog.

The fact that get 'index' returns success in the third spec in the file is the most flaming of red herrings I've seen in a long, long time.

Green-bar-inducing code and spec files follow. The routing is unchanged from that quoted in the first Gist.

@jdickey
jdickey / 00-Local Gem server question.md
Last active August 29, 2015 14:01
Problem running local Gem server.

I have two systems on my local network, alpha.local and bravo.local. alpha is a Mac (OS X 10.8.5); bravo is a Linux box (Fedora 20).

  1. On bravo, I start gem server -V and get the message Server started at http://0.0.0.0:8808;
  2. On alpha, I run gem list --source http://bravo.local:8808, which produces a full list of gems installed on bravo;
  3. On alpha, I then run bundle install --gemfile Gemfile_local --jobs 3 --path vendor; it fails with the output
Updating git://github.com/bbatsov/rubocop.git
Fetching source index from http://bravo.local:8808/
Retrying source fetch due to error (2/3): Bundler::HTTPError Could not fetch specs from http://bravo.local:8808/
@jdickey
jdickey / BASIC problem with Slim and RSpec -- Now SOLVED.md
Last active August 29, 2015 14:01
Slim and RSpec: I Was Obviously Doing It Wrong

Solved with the gracious help of @jenrzzz on IRC (whom I presume is the same as @jenrzzz on Twitter?

The solution was to change

    @blog = OpenStruct.new(title: blog_title,
                           subtitle: blog_subtitle,
                           entries: [])
@jdickey
jdickey / Breaking Circular Dependencies in Rails.md
Last active August 29, 2015 14:02
Beware the circular Rails trap!

The Rails convention for associating dependent records has long been dependent on creating circular references between the master and detail record. Following a typical blog-type app, one might see

class Blog < ActiveRecord::Base
  has_many :posts
  # ...
end

and

@jdickey
jdickey / run_my_project.sh
Created July 5, 2014 10:57
Shell script used by CruiseControl.rb to build a recent-Ruby app.
#!/bin/bash --login
RBENV_VERSION = 2.0.0-p481
env
rbenv versions
rbenv exec bundle install --path vendor --jobs 3
RAILS_ENV=test rbenv exec bundle exec rake db:migrate
RAILS_ENV=test rbenv exec bundle exec rake cruise