Skip to content

Instantly share code, notes, and snippets.

View parkerl's full-sized avatar

Lew Parker parkerl

  • Rxrevu Inc.
  • Denver, CO, USA
View GitHub Profile
@parkerl
parkerl / gist:1479099
Created December 14, 2011 23:30
Find all symlinks below a given directory
ls -lR /path/to/folder | grep ^l
@parkerl
parkerl / gist:1479105
Created December 14, 2011 23:32
Iterate directories in bash
#!/bin/bash
src="/my/path"
for dir in `ls "$src/"`
do
if [ -d "$src/$dir" ]; then
fi
done
@parkerl
parkerl / Filtered Log Tail
Created December 20, 2011 22:22
Here is a nice way to filter out debugging messages from a log file.
tail -f log/development.log | grep DEBUG
@parkerl
parkerl / yaml_dump
Created January 13, 2012 23:14
Dump objects to YAML in home directory
File.open(File.expand_path("~/objects.yml"),"w") {|f| f.puts(objects.to_a.to_yaml)}
@parkerl
parkerl / legacy_firefox_for_selenium.md
Created January 20, 2012 22:19
Configuring selenium to use a legacy Firefox version in Rails applications.

Motivation

We recently were working on a project where the version of Firefox on the development machines was causing acceptance tests running on Capybara and Selenium to fail and/or hang erroneously. The solution was to point Selenium at a custom version of Firefox. We also added the Firefox binaries to the application git repo so that all devs could run against a known good version of Firefox.

Solution

  1. Download the desired version of Firefox from ftp://ftp.mozilla.org/pub/firefox/releases/

  2. Put Firefox.app in your rails app somewhere like ./bin/spec/macosx/

@parkerl
parkerl / extract_and_download_images_from_css.md
Created February 8, 2012 18:31
Extract image URLs from a CSS file and download them onto a new server (Linux)

#Extract Image URLs and WGet Them to a New Server#

This was a fun problem. I needed to move all the images referenced in a CSS file to another server. I didn't want to just grab all the image files as there were a bunch I didn't need. Here is how I went about it. I am sure you could do it in one step but doing it this way gives you a chance to check for errors.

First you may want to use wget http://otherserver/the_css.css to pull the CSS file on to the target server if it is still on the old server as it was in my case.

  1. User grep to extract the URLs from the css file into another file. (You may need to adjust the regular expression if you have funny characters in your file names) Note the use of the -o flag that tells grep to only print out that part of the line that matches the expression rather than the entire line.

     grep -o '\/path\/to\/files\/[a-zA-Z0-9/.:_-]*' the_css.css > images.txt
    

#Lew's Opinionated Guide to Delivering Features#


  1. First, understand the story.

Do you understand the story completely? If not, talk to the product owner to clarify your understanding.

Is the story a logically cohesive grouping of functionality? If not, can it be broken into multiple stories?

Do the points assigned make sense given your current level of understanding of the story? If not, can it be broken into multiple stories?

As with most programming answers...it depends.

The command /bin/rails explicitly runs the rails command found in your system's /bin direcory.

The command rails causes bash to look in the directories listed in the special evironment variable $PATH for the first command named "rails" that it finds. The directory bin is usually in your $PATH and if the system finds the rails command there the /bin/rails and rails execute the same command.

If however, you happen to have another version of rails installed somewhere like /usr/bin/rails and that is in your $PATH first then rails might run that. In this case tehre might be a world of difference as the two commands could run diffrent versions of rails.

In general, unless you are explicitly trying to run a different version of rails than the one in your $PATH, it is best to call just rails g blah as that is the one your system "assumes" to be the right one.

@parkerl
parkerl / legacy_code_14_to_17.md
Last active August 29, 2015 14:01
Working Effectively with Legacy Code: Chapters 14 to 17

###Chapter 14: Dependencies on Libraries Are Killing Me###

  • Avoid promiscuously calling on libraries throughout your code. (ActiveRecord??)
  • “Every hard-coded use of a library class is a place where you could have had a seam.”
  • Is there any relevance for the language feature enforced design constraints in Ruby? Objective-C?

###Chapter 15: My Application Is All API Calls###

  • Don't test if your app is all API calls?
  • ActiveRecord must be one the best tested libraries in existence
┌────────────────────────────┐
│ Trips │ ┌────────────────────────────┐
│ - Start Date │ │ Fishermen │
│ - End Date │╲ ╱│ - Name │
│ │────────────────│ - Date of Birth │
│ │╱ ╲│ │
│ │ └────────────────────────────┘
└────────────────────────────┘ ┼