This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Invoice < ActiveRecord::Base | |
before_validation :generate_number, on: :create | |
private | |
def generate_number | |
prefix = "R#{Date.today.strftime('%y')}-" | |
last_order_number_this_year = self.class.where("number LIKE ?", "#{prefix}%").order("number DESC").limit(1).pluck(:number).first | |
number = last_order_number_this_year ? last_order_number_this_year.match(/\A#{prefix}(\d+)\z/)[1].to_i : 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def buckets | |
[ | |
'myapp-production-backups', | |
'myapp-staging-backups', | |
'myapp-s3-logs' | |
] | |
end | |
def test_buckets_subdomain_private | |
buckets.each do |bucket_name| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Testing | |
Automated testing (even though still not widely used by Objective-C developers) would make | |
refactoring much easier, faster and safer. Good test coverage would also allow maintenance | |
to be done and new features to be added without first having to fully investigate the | |
function of all parts of the codebase and the way these parts fit together. This especially | |
applies when work is contracted out to developers other than those who originally created | |
the application. | |
The lack of a comprehensive automated test suite is a real disadvantage. Adding one is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if defined? ActiveRecord | |
def explain(query) | |
query = query.to_sql if query.is_a?(ActiveRecord::Relation) | |
ActiveRecord::Base.connection | |
.execute("EXPLAIN ANALYZE #{query}") | |
.to_a | |
.each { |hash| puts hash["QUERY PLAN"] } | |
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can you please answer the following questions so we can assess the project, | |
and judge if we would be a good match? | |
1. Is this a new project, or is this for an existing website or application? | |
- This is a project for a completely new site or application | |
- This is a project to update an existing site or application | |
2. Which of the following areas do you need help with? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem 'sprockets' | |
gem 'sprockets-sass' | |
gem 'sass' | |
gem 'compass' | |
gem 'bootstrap-sass' | |
gem 'handlebars_assets' | |
gem 'coffee-script' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// this file is stored in a directory of APP_ROOT/script for me, all things are relative to that | |
var APP_ROOT = __dirname+"/../"; | |
// this assumes there is a file stored in APP_ROOT called "config.js" with the following structure: | |
// | |
// module.exports = { | |
// "development: { | |
// "postgresql": "tcp://postgres@localhost/dev-db" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
My name is Ben Orenstein and I work at thoughtbot in Boston. | |
Notes will be published. | |
I'd like to tell you a story. (5:42) | |
I've never talked about this publicly. | |
Umass. | |
Second job. | |
Version control. | |
Successful since then. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# locales/en.yml | |
en: | |
time: | |
formats: | |
ical: "%Y%m%dT%H%M%SZ" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# local PHP Server | |
server() { | |
url="localhost:${2:-8000}" | |
if [ -z "$1" ]; then | |
php -S $url & # run server in background | |
else | |
php -S $url -t $1 & | |
fi | |
sleep 0.3s # wait for server to start |
OlderNewer