60% of the time it works EVERY time!
gem 'ny_address', git: 'git://gist.github.com/1672379.git'
require 'bundler/inline' | |
## | |
# Get dependencies | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'pg' | |
gem 'activerecord', require: 'active_record' | |
gem 'benchmark-ips' | |
gem 'pry' |
# frozen_string_literal: true | |
source "https://rubygems.org" | |
gem "activerecord", github: "bodacious/rails" | |
gem "sqlite3" |
require "bundler/inline" | |
gemfile do | |
gem "benchmark-ips" | |
gem "jbuilder" | |
gem "activesupport", require: ["active_support"] | |
end | |
class User | |
attr_accessor :id, :name, :email, :password, :age, :username |
module PesaPal | |
require 'active_support' | |
include ActiveSupport::Configurable | |
self.configure do |config| | |
config.test_mode = true | |
config.consumer_key = "<your key>" | |
config.consumer_secret = "<your secret>" | |
end | |
class String | |
def palindrome? | |
clean_string = self.gsub(/[^\w]/, '').downcase | |
clean_string == clean_string.reverse | |
end | |
end | |
puts "madam".palindrome? # => true | |
puts "racecar".palindrome? # => true | |
puts "madam, . ".palindrome? # => true | |
puts "02/02/2020".palindrome? # => true |
[Time, Date].map do |klass| | |
klass::DATE_FORMATS[:variable] = lambda do |t| | |
date = | |
case | |
# display today's date as "today" | |
when t >= Date.today then "today" | |
# display yesterday's date as 'Yesterday' | |
when (t >= Date.yesterday and t <= Date.today) then "yesterday" | |
# otherwise, display date: eg. Mon 4th June | |
else |
The purpose of this document is to define the strategy which all Katana Code employees and subcontractors must adhere to when working on Katana Code projects.
The aim is to develop a uniform, coherent and effective solution. This document is not written in stone and can be updated as and when better approaches are discovered.
class Game | |
attr_accessor :doors | |
attr_reader :correct_door | |
def initialize(door_count: ) | |
chosen_door = (1..door_count).to_a.sample | |
@doors = door_count.times.map.with_index do |d, i| | |
Door.new(i+1 == chosen_door) | |
end | |
@correct_door = @doors.detect(&:correct?) | |
end |
module ActiveRecord | |
class Base | |
COLUMN_TYPES_MAPPING = { | |
:int => 'INTEGER', | |
:long => 'INTEGER', | |
:longLongInt => 'BIGINT', | |
:bool => 'BOOLEAN', | |
:double => 'DECIMAL', |