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
// sample use {{ value | currency:"USD" }} | |
angular.module('filters', []).filter('currency', function() { | |
return function(number, currencyCode) { | |
var currency = { | |
USD: "$", | |
GBP: "£", | |
AUD: "$", | |
EUR: "€", | |
CAD: "$", | |
MIXED: "~" |
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
# This assumes that EVERY spec file has AT LEAST ONE SPEC in it. It can be pending but it must exist. | |
# Otherwise, the file_names and times will be off. | |
RSpec.configure do |config| | |
config.add_setting :file_count, default: 0 | |
config.add_setting :file_times, default: {} | |
config.before(:all) do | |
@start = Time.now | |
end |
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
for n in 1..100 | |
if n.remainder(3) == 0 && n.remainder(5) == 0 | |
puts "fizzbuzz" | |
elsif n.remainder(3) == 0 | |
puts "fizz" | |
elsif n.remainder(5) == 0 | |
puts "buzz" | |
else | |
puts n | |
end |
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
=begin | |
there are probably better ways to do this now and I wrote this when I was originally learning ror, | |
but it is a sample of something mildly complex that I wrote. | |
=end | |
class ResSearch < ActiveRecord::Base | |
belongs_to :users | |
has_many :search_alerts, :dependent => :destroy | |
include ApplicationHelper |
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
# return a sanitized version of the image filename | |
# (remove spaces, etc.) and then determine position | |
# based on filename (eg. 1.jpg, 2.jpg) | |
def sanitize_and_position_photo | |
filename = self.image_file_name | |
ext = File.extname(filename) | |
just_filename = File.basename(filename, ext) | |
unless just_filename.to_i == 0 | |
self.position = just_filename.to_i |