Skip to content

Instantly share code, notes, and snippets.

@southpolesteve
southpolesteve / gist:5060497
Created February 28, 2013 22:02
Rake taks for finding unused methods in your rails app. A bit hacky and slow, but seems to work for most cases!
namespace :cleaner do
task :find do
models = Dir.glob("app/models/**/*")
all_files = Dir.glob("app/**/*")
models.each do |model|
if File.file?(model)
File.open(model).lines.each do |line|
if line=~ /def ([a-z0-9._?!]*)/
method_name = line.match(/def ([a-z0-9._?!]*)/)[1]
method_name.sub!(/self./, '')

Strings in Ruby can be set with single or double quotes, but the behavior is slightly different. Double quotes allow for the ability to insert variables into a string. Check out the following example:

name = "Steve"
puts "My name is #{name}"
#=> My name is Steve
puts 'My name is #{name}'
#=> My name is #{name}
@southpolesteve
southpolesteve / gist:4152385
Created November 27, 2012 04:31
Open Source License for a Commercial SaaS Application

Background

I am building a SaaS application and I would like to be able to publish the source code while retaining commercial rights to the application. I did some research and it seems that most popular licenses are not structured to fit this model. I realize this kind of license may not fit with the general spirit of open source, but the alternative for most SaaS companies is that their primary code base is closed source. I am not convinced that has be the case. Why couldn't an app like Github or Basecamp be open source? Why couldn't community members submit pull requests and be paid for their work? There may be valid reasons this model won't work, but I am interested in exploring this further and hearing opinions

License Goals

  • Code can be freely distributed
  • Code can be modified without consent
  • Code can be run on a personal machine for personal use
  • Code cannot be used for commercial purposes, for the benefit of a commercial entity, or to directly compete with the copyright owner ("the co
@southpolesteve
southpolesteve / gist:4020578
Created November 5, 2012 21:50
Macbook Air (2011, i7) vs Raspberry Pi

Last night I finally got my raspberry pi up and running one of my current rails projects. This project is relatively simple, only 30 specs, and I wanted to see how it would stack up against my macbook air.

TL;DR: The pi is about 20 times slower running the actual tests (46s vs 2.2s), but loading the test environment is by far the slowest part. ~7 minutes.

This result makes me believe that I could use my pi as a nice little CI server for personal projects as long as the test suites are simple. This week I will be taking a look at some light weight CI servers and try running them on the pi.

See the full results below.

Hi,
Found what seems to be a bug in the issues section of the github API. it may exist elsewhere, but I am not sure.
Your documentation says under the pagination section "Requests that return multiple items will be paginated to 30 items by default"
But I only seem to be getting 25 by default. Tested this on my own private repos as well as public. See example here:
curl "https://api.github.com/repos/rails/rails/issues"
# Custom RSpec matcher to test that an array contains only a single class of object
RSpec::Matchers.define :contain_only_instances_of do |expected|
match do |actual|
classes = actual.map(&:class).uniq
classes.size == 1 && classes.first == expected
end
end
%td
= form_for task, :remote => true, :url => ajax_update_path do |f|
= f.collection_select :task_type_id, TaskType.all, :id, :name, {}, { :class => 'submittable'}