Skip to content

Instantly share code, notes, and snippets.

View colinrymer's full-sized avatar

Colin Rymer colinrymer

View GitHub Profile

When I first saw this #asset_allowed? method, I knew there was a nice collection method I could use to clean this up, but couldn't remember and forgot to check the Enumerable module. Stumbled upon the #any? method while looking at a nice git pre-commit hook in Ruby and thought, "Bingo!".

def asset_allowed?(asset)
  self.logical_asset_filter.reduce(false) do |accum, matcher|
    accum || (matcher =~ asset)
  end ? true : false
end
@colinrymer
colinrymer / commit_message_rant.md
Last active December 17, 2015 15:09
Thoughts on commit messages

TL;DR: What's the interest in updating our release tool (probably as a 10% project) to let us not have to use 16+ characters before we start our summary? Are there any reasonable barriers?

So

I'm a big fan of the 50/72 commit message line length philosophy, and I think/hope most everyone else here is of the same opinion (but even if you're not, I still think you'll appreciate what follows). As such, I consider those first 50 characters precious and hate wasting them with something like "[CR] [12345678] " - that's a minimum of 16 characters!

Don't even get me started on when it's multiple authors and/or stories…

ugh

@colinrymer
colinrymer / gist:5775992
Last active December 18, 2015 11:29
Basic jenkins setup
#!/bin/bash
# Set "fail on error" in bash
set -e
[[ -s "/var/lib/jenkins/.rvm/scripts/rvm" ]] && source "/var/lib/jenkins/.rvm/scripts/rvm"
# Use the correct ruby
export MAIN_RUBY="1.9.3-p194"
rvm use --create --install $MAIN_RUBY
rvm gemset use $JOB_NAME --create

Product management has come up with the idea of allowing website users to leave reviews and ratings for listings. This feedback will be entered similar to how leads are submitted, but the user must enter the following information:

  • name
  • email address
  • phone number
  • rating from 1 to 5
  • optional review

In addition to the above information, a CAPTCHA presenting three different apartment complexes (only one of which is correct) is used in conjunction with the user’s name and phone number to determine whether or not the user actually lived at the listing. After validating and verifying the information, the user gets redirected to a thank you page. After a review is successfully submitted, it will show up as the first entry in the reviews for the listing. Pre-existing “certified resident” reviews will be integrated along with reviews that are submitted through the site. On the search results page, users can sort on rating type or filter on review type and rating. A link on each listing will take the us

@colinrymer
colinrymer / continuous_delivery_manifesto.md
Last active April 7, 2019 10:41
A manifesto on continuous delivery

When developing a process for deployment of production code, several key concepts should be held as critical:

Above all else, the most important thing is a working production system. This is where all business value is derived and therefore, it must be maintained in a suitable state.

The main working branch of the code base should always be ready to be deployed. Changes committed to this branch must not prevent the deployment of code. If they do, immediate priority should be directed at fixing the broken code. If

@colinrymer
colinrymer / output
Last active December 19, 2015 01:59
using Ruby 1.9.3-p327-perf
$ ruby split_benchmark.rb
naive_regex
6.320000 0.130000 6.450000 ( 6.798818)
naive_squeeze
6.770000 0.070000 6.840000 ( 7.122865)
assigned_regex
5.710000 0.060000 5.770000 ( 5.869347)
assigned_squeeze

We hold these Truths to be self-evident, that all Men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the Pursuit of Happiness — That to secure these Rights, Governments are instituted among Men, deriving their just Powers from the Consent of the Governed, that whenever any Form of Government becomes destructive of these Ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its Foundation on such Principles, and organizing its Powers in such Form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient Causes; and accordingly all Experience hath shewn, that Mankind are more disposed to suffer, while Evils are sufferable, than to right themselves by abolishing the Forms to which they are accustomed. But when a long Train of Abuses and Usurpations, pursuing

environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'production'
app_path = "/var/www/webapp"
bundle_path = "#{working_directory}/../shared/bundle"
#listen "/tmp/.sock", :backlog => 64
listen 8080, :tcp_nopush => true
timeout 30
worker_processes 12
preload_app true
@colinrymer
colinrymer / Ternary Method Proposal.md
Created September 20, 2013 18:14
Ternary Shortcut Proposal

Basis

Currently the convention is for methods ending in ? to return a boolean value. Often this method is used at the beginning of a ternary operator, e.g. protocol = request.ssl? ? 'https' : 'http'.

Proposal

The proposed would be to allow the ...? method to accept two arguments, returning the first if the method would return true, the second if false. This may not follow the principal of least surprise, so another proposed alternative would be suffixing the method with ??.

Examples

def tag_to_deploy
Capistrano::CLI.ui.choose do |menu|
menu.choices *last_ten_tags
menu.header = "Available tags"
menu.prompt = "Tag to deploy?"
menu.select_by = :index_or_name
end
end
def last_ten_tags