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 fib(n)a,b,s=0,1,[];n.times{s<<a;a,b=b,a+b};s end | |
p fib(33) | |
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, ...] |
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
ru: | |
devise: | |
invitations: | |
send_instructions: 'Приглашение было отправлено %{email}.' | |
invitation_token_invalid: 'Некорретный ключ приглашения!' | |
updated: 'Ваш пароль изменён. Теперь вы вошли в систему.' | |
no_invitations_remaining: "Больше нет приглашений" | |
new: | |
header: "Отправка приглашения" | |
submit_button: "Отправить приглашение" |
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
// Simple style for the content of parent & child | |
p{ | |
margin: 0; | |
background-color: #fff; | |
color: #00B9AE; | |
padding: 20px; | |
border-radius: 10px; | |
box-shadow: 0 3px 6px rgba(#CC8367, 0.22); | |
} |
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 RandomColor | |
def self.get_random | |
rand(255) | |
end | |
def self.color_hex(options = {}) | |
default = { red: get_random, green: get_random, blue: get_random } | |
options = default.merge(options) | |
'#%X%X%X' % options.values | |
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 User < ApplicationRecord | |
belongs_to :parent, primary_key: :username, | |
foreign_key: :parent_username, | |
class_name: 'User', | |
optional: true | |
has_many :children, primary_key: :username, | |
foreign_key: :parent_username, | |
class_name: 'User' | |
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
arr_size = 100 | |
arr = [[0,5], [20, 30], [50, 70]] | |
def get_ranges(arr_size, arr) | |
# calculating adjacent indices | |
# flatten multiple arrays in one | |
arr.map!{|k, v| [get_min(k), get_max(v, arr_size)]}.flatten! | |
# checking the occurrence of range boundaries | |
sum = arr + [0, arr_size] |