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
# frozen_string_literal: true | |
class FlatpickrInput < SimpleForm::Inputs::StringInput | |
def input(wrapper_options) | |
template.content_tag(:div, class: "input-group", | |
data: {controller: "flatpickr", flatpickr_disable_mobile: true}) do | |
template.concat input_addon(calendar_button, data: {toggle: true}) | |
template.concat @builder.text_field(attribute_name, input_html_options) | |
template.concat input_addon(close_button, data: {clear: true}) | |
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
class Organization < ApplicationRecord | |
has_one_attached :logo | |
# Old Paperclip config | |
# must be removed BEFORE to running the rake task | |
has_attached_file :logo, | |
path: "/companies/:id/:basename_:style.:extension", | |
default_url: "https://xxxxx.cloudfront.net/companies/missing_:style.jpg", | |
default_style: :normal, | |
styles: { thumb: "64x64#", normal: "400x400>" }, |
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
puts "What year where you born? (Enter a 4 digit year, ie 1984)" | |
birth_year = gets.chomp | |
puts "What month where you born? (Enter the month number, ie June would be 6)" | |
birth_month = gets.chomp | |
puts "What day of the month where you born?" | |
birth_day = gets.chomp |
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 weddingNumber number | |
if number < 0 # No negative numbers. | |
return 'Please enter a number that isn\'t negative.' | |
end | |
if number == 0 | |
return 'zero' | |
end | |
# No more special cases! No more returns! |
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 englishNumber number | |
if number < 0 # No negative numbers. | |
return 'Please enter a number that isn\'t negative.' | |
end | |
if number == 0 | |
return 'zero' | |
end | |
# No more special cases! No more returns! |
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
require_relative 'english_number.rb' #https://gist.github.com/kylekeesling/4b73a984421f120312de | |
num_bottles = 999 | |
while num_bottles > 0 | |
puts "#{englishNumber(num_bottles)} bottles of beer on the wall, | |
#{englishNumber(num_bottles)} bottles of beer, take one down, pass it | |
around, #{englishNumber(num_bottles - 1)} bottles of beer on the wall!" | |
num_bottles = num_bottles - 1 | |
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
num_bottles = 99 | |
while num_bottles > 0 | |
puts "#{num_bottles} bottles of beer on the wall, | |
#{num_bottles} bottles of beer, take one down, pass it | |
around, #{num_bottles - 1} bottles of beer on the wall!" | |
num_bottles = num_bottles - 1 | |
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
puts "Enter a starting year in the format YYYY" | |
starting = gets.chomp!.to_i | |
puts "Enter an ending year in the format YYYY" | |
ending = gets.chomp!.to_i | |
puts "LEAP YEARS between #{starting} and #{ending}" | |
starting.upto(ending) do |year| | |
divisible_by_4 = (year % 4) == 0 | |
not_divisible_by_100 = (year % 100) != 0 | |
divisible_by_400 = (year % 400) == 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
chatting = true | |
byes = 0 | |
while chatting | |
puts "Ask Grandma a question:" | |
said = gets.chomp! | |
if said == "BYE" | |
byes += 1 | |
if byes > 2 | |
chatting = false | |
else |
NewerOlder