This file contains hidden or 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
module Cm | |
module Shared | |
# Calculates a percentage of the amount passed in and returns it rounded to 2 decimals (i.e. cents), | |
# as a BigDecimal object. | |
# | |
# Some takeaways from "Invoices: How to properly round and calculate totals" (https://goo.gl/cHvuPa) | |
# - it is very easy to create invoices where numbers don't add up and a few cents are missing. | |
# - don't pass around unrounded values. Once you round, use the rounded value for all further totals. | |
# - the rounding of money amounts is *not* a matter of presentation, and should never happen in a view. | |
# - don't ever use the float data type in Ruby or MySQL for money |
This file contains hidden or 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
# Right now these checks add more noise than value; may change as the team grows. | |
CommitMsg: | |
ALL: | |
enabled: false | |
# Right now these checks add more noise than value; may change as the team grows. | |
PreCommit: | |
ALL: | |
enabled: false | |
PrePush: | |
RakeTarget: |
This file contains hidden or 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
require 'active_record' | |
require 'mysql2' | |
ActiveRecord::Base.establish_connection(adapter: :mysql2, username: 'root') | |
(Date.new(2000, 01, 01)..Date.new(2020, 12, 31)).each do |date| | |
mysql_week = ActiveRecord::Base.connection.execute("SELECT WEEK('#{date.to_s}', 3)").first.first | |
ruby_week = date.cweek | |
unless mysql_week == ruby_week | |
puts "Week numbers differ for date #{date} (mysql: #{mysql_week}, ruby: #{ruby_week})" |
This file contains hidden or 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
# given this CSV: | |
# | |
# agency_id;award_name;importance;years;description;ignore;is_further_award | |
# 5683;Deloitte Technology ;x;2014 2013;Fast 50 (2013), Fast 500 (2014);x; | |
# | |
# the following code will return: | |
# | |
# #<CSV::Row | |
# agency_id:5683 |
This file contains hidden or 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 hr | |
puts | |
puts '-' * 80 | |
puts | |
end | |
# Number comparsion | |
def number_comparison(a, b) | |
difference = a - b | |
puts "#{a} is #{difference} larger than #{b}" |
This file contains hidden or 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
Scaling RoR MUC | |
Roles | |
- "big decisions" group | |
- Examples: | |
- do we take on non-refugees | |
- when do we start the weekly course | |
- do students have to qualify for the weekly course | |
- which volunteers do we take on |
This file contains hidden or 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 'http://rubygems.org' | |
# REFINERY CMS ================================================================ | |
# Anything you put in here will be overridden when the app gets updated. | |
gem 'refinerycms', '1.0.8' | |
group :development, :test do | |
# To use refinerycms-testing, uncomment it (if it's commented out) and run 'bundle install' | |
# Then, run 'rails generate refinerycms_testing' which will copy its support files. |
This file contains hidden or 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 PortfolioItem::Image | |
dragonfly_accessor :image_original # store original | |
dragonfly_accessor :image_medium # 660px | |
end | |
class PortfolioItem | |
include PortfolioItem::ImagesConcern | |
end |
This file contains hidden or 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 PortfolioItem::Image < ActiveEceord::Base | |
end | |
class PortfolioItem < ActiveEceord::Base | |
has_many :images, class_name: 'PortfolioItem::Image', dependent: :destroy | |
# id stored in column portfolio_items.tile_image_id | |
has_one :tile_image, class_name: 'PortfolioItem::Image', dependent: :destroy |
This file contains hidden or 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 PortfolioItem | |
# | |
# alt | |
# | |
#has_attached_file :teaser, styles: { tile: ["555x>", :jpg] } | |
# | |
# neu | |
# |