text stringlengths 10 2.61M |
|---|
class AddGalleryFooterTextBox < ActiveRecord::Migration
def self.up
add_column :studios, :gallery_footer_box, :text
end
def self.down
remove_column :studios, :gallery_footer_box
end
end |
color = ["Blue ", "Green", "Red", "Orange", "Violet", "Indigo", "Yellow "]
# Write a ruby program to display the colors in the following way :
# “Choice 1 is Blue ."
# “Choice 2 is Green."
# “Choice 3 is Red."
p = ''
color.each_with_index do |color,index|
puts "choice #{(index+1).to_s} is #{color}."
end
|
class ToppagesController < ApplicationController
skip_before_action :authenticate_user, only: [:index]
def index
@items = Item.order(updated_at: :desc)
end
end |
# == Schema Information
#
# Table name: object_iterators
#
# id :integer not null, primary key
# name :string(255)
# iterable_id :integer
# iterable_type :string(255) default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
#
... |
class CitySerializer
def initialize(city_object)
@city = city_object
end
def to_serialized_json
@city.to_json(:include => {
:landmarks => {:only => [:id, :formatted_address, :name, :photos, :longitude, :latitude, :rating, :types, :user_ratings_total, :city_id]}, :comments => {:only... |
require 'backports/2.0.0/array/bsearch'
module ChefAB
class TimeLinearUpgrader < BaseUpgrader
attr_accessor :start_time, :end_time
def initialize(options)
super(options)
@start_time = options[:start_time].to_i
@end_time = options[:end_time].to_i
upgrade_span = @end_time - @start_tim... |
require "rails_helper"
feature "Student dash" do
scenario "list of available exams" do
student = create(:student)
sign_in_as(student)
expect(current_path).to eq(student_dash_path)
expect(page).to have_link("Logout")
end
end
|
class Admin::UsersController < Admin::BaseController
before_action :logged_in_user
before_action :verify_admin
before_action :load_user, only: [:destroy, :update, :show]
def index
if params[:search]
@users = User.search(params[:search])
.paginate page: params[:page], per_page: 10
else
... |
require 'setup_tests'
class NXOS5Test < BaseTestSetup
context 'an NXOS5 target' do
setup do
@connector = @target.connector = SSHConnector.new(@host, {})
@target.stubs(:target_profiler).returns(Profilers::NXOS5)
@target.force_profiler_to(Profilers::NXOS5)
@profiler = @target.profiler
... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :location do
sequence(:ssid) {|n|"LILO5056#{n}#{n}#{n}"}
sequence(:bssid) {|n|"#{n}#{n}:#{n}#{n}:#{n}#{n}:#{n}#{n}:#{n}#{n}"}
capabilities "aaaaaaaaaa"
sequence(:level) {|n|"4#{n}"}
sequence(:frequency) ... |
class TalksController < ApplicationController
before_filter :require_logged_user, :only => [:new, :create, :edit, :update]
def index
@talk = Talk.new
@search = ""
if params[:my].nil?
@my = false
if params[:talk].nil?
@talks = all_public_talks
else
@search = params[:ta... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
#index
#new
#create
#show
get '/', to: "sushis#home"
get '/:anything', to: "application#wrong_page"
end
|
# frozen_string_literal: true
libx = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(libx) unless $LOAD_PATH.include?(libx)
require 'rubygems'
require 'bundler/setup'
require 'date'
require 'json'
require 'aws-sdk-s3'
require 'aws-sdk-sqs'
require 'dumpster_mail'
class Processor
FLOW = {
"inbound": "sc... |
# Sterling's Ruby Assesment
#1.Arrays
# `array = ["Blake","Ashley","Jeff"]`
# a. Add a element to an array
# b. Write a statement to print out all the elements of the array.
# c. Return the value at index 1.
# d. Return the index for the value "Jeff".
names = []
names << "Blake"
names << "Ashely"
names << "... |
class Comment < ApplicationRecord
validates :body, :user, :link, presence: true
belongs_to :user
belongs_to :link
end
|
# frozen_string_literal: true
class Admin::ArticlesController < Admin::AdminController
layout 'admin_dashboard'
before_action :load_categories, only: %i[new create edit]
before_action only: %i[update edit] do
find_article
end
def index
@articles = Article.pending
end
def new; end
def crea... |
# encoding: UTF-8
require_relative '../md_object'
module GoodData
module Model
##
# Base class for GoodData attribute and fact folder abstractions
#
class Folder < MdObject
def initialize(title)
# TODO: should a super be here?
# how to deal with name vs title?
@title = ... |
FactoryGirl.define do
factory :post do
title { FFaker::Lorem.phrase }
body { FFaker::Lorem.paragraph(10) }
user
trait :with_tag_body do
body { "#{FFaker::Lorem.paragraph(10)}##{rand(10_000)} dsafd" }
end
end
end
|
class CarReservationService
include Virtus.model
attribute :user_id, Integer
attribute :car_id, Integer
attribute :taken_at, DateTime
attribute :taken_till, DateTime
attribute :user_car, UserCar, default: :set_user_car
attribute :errors, Array, default: :check_for_errors
def reserve!
user_car... |
FactoryGirl.define do
factory :remote_tournament, class: Hash do
tour_id { generate :tournament_id }
eman { generate :string }
eman_trohs { generate :string }
gninnigeb { generate :date }
gnidge { generate :date }
initialize_with { attributes }
trait :with_stages do
a... |
ActiveAdmin.register City do
permit_params :name, :country_id
end
|
require "set"
OUTER_BAG_MATCHER = /^(?<color>.+) bags contain (?<contents>.+)\.$/
EMPTY_BAG_MATCHER = /^no other bags$/
INNER_BAG_MATCHER = /^(?<count>\d+) (?<color>.+) bags?/
STARTING_BAG = "shiny gold".freeze
class Bag
attr_reader :color, :contents
def initialize(color)
@color = color
@contents = {}
... |
class UpdatesController < ApplicationController
before_action :auth
rescue_from ActiveRecord::RecordNotFound, with: :not_found
before_action :ensure_updateability
def show
account.latest_balance
ServicesMailer.daily_update(current_user).deliver_now
ensure
redirect_to account_path(params[:account_... |
# encoding: utf-8
require 'spec_helper'
describe Dispatcher, '#action_names' do
subject { object.action_names }
let(:object) { described_class.new(config, env) }
let(:config) { { :test => { :action => Spec::Action::Success } } }
let(:env) { double }
it { should eql(Set[ :test ]) }
end
|
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Views
describe Composition do
let(:described) { Vedeu::Views::Composition }
let(:instance) { described.new(attributes) }
let(:attributes) {
{
client: client,
colour: colour,
pare... |
require 'minitest/autorun'
require 'minitest/pride'
require './lib/building'
require './lib/apartment'
require './lib/renter'
class BuildingTest < Minitest::Test
def test_it_exists
building = Building.new
assert_instance_of Building, building
end
def test_it_has_readable_atributes
building = Build... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :user_name
t.string :email
t.string :bio
t.string :city
t.string :state
t.string :password_hash
t.string :password_salt
t.string :tmp_password_hash
t.text :interests
... |
set :root, File.dirname(__FILE__)
# EadChecker is a Sinatra App
class ArchivesspaceChecker < Sinatra::Base
# site-specific configuration
CONFIG = if File.exists?(File.join('config', 'config.yml'))
YAML.safe_load(IO.read(File.join('config', 'config.yml'))) || {}
else
{}
... |
Sequel.migration do
change do
create_table(:reviews) do
uuid :id, default: Sequel.function(:uuid_generate_v4), primary_key: true
Integer :old_id
foreign_key :transaction_id, :transactions, null: false, type: 'uuid'
foreign_key :user_id, :users, null: false, type: 'uuid'
... |
require 'spec_helper'
describe ArticleSearchQuery do
let(:query) { ArticleSearchQuery.new }
let!(:ira) { FactoryGirl.create(:user, given_name: 'Ira', family_name: 'Kaplan' )}
let!(:georgia){ FactoryGirl.create(:user, given_name: 'Georgia', family_name: 'Hubley' )}
let!(:issue_1){ FactoryGirl.create(:... |
# frozen_string_literal: true
class AutomatedTweetComponent < ViewComponent::Base
attr_reader :automated_tweet
def initialize(automated_tweet:)
@automated_tweet = automated_tweet
end
end
|
module Bfire
class Rule
attr_reader :group
attr_reader :opts
include PubSub::Publisher
def initialize(group, opts = {})
@group = group
@opts = {:period => 5*60, :initial => 1, :range => 1..1}.merge(opts)
end
# we only support round-robin placement for now
def monitor
l... |
class CommentsController < ApplicationController
def create
@comment = Comment.create(comment_params)
if @comment.save
ActionCable.server.broadcast 'comment_channel', content: @comment
else
redirect_to post_path
end
end
def destroy
@post = Post.find(params[:post_id])
@comment ... |
class EventsController < ApplicationController
before_action :set_event, only: %i[show edit destroy update]
before_action :require_sign_in, only: %i[index]
def index
@upcoming_events = Event.upcoming
@prev_events = Event.previous
end
def new
@event = Event.new
end
def show
@event = Even... |
class CreateGoals < ActiveRecord::Migration
def change
create_table :goals do |t|
t.string :recurringday
t.boolean :recurring
t.boolean :stretch
t.string :goaloneliner
t.boolean :complete
t.date :duedate
t.timestamps
end
end
end
|
class AddIndexToFacilityDivisionData < ActiveRecord::Migration[5.2]
def change
add_index :facility_division_data, :division_id
add_index :facility_division_data, :detail
add_index :facility_division_data, :major
end
end
|
# == Schema Information
#
# Table name: assessments
#
# id :integer not null, primary key
# definition :string(255)
# date_taken :date
# created_at :datetime not null
# updated_at :datetime not null
#
class Assessment < ActiveRecord::Base
serialize :event_log, JSON
serialize :... |
class Piece
attr_reader :board, :color
attr_accessor :pos
def initialize(board, color, pos)
@board = board
@color = color
@pos = pos
board.add_piece(pos, self)
end
def valid_moves
moves.select do |pos|
x, y = pos
board.in_bounds?(po... |
require 'test/unit'
require_relative './utils/driver'
include Test::Unit::Assertions
include ::Driver
step 'Sign up as <name> with email <email> and <password>' do |name,email,password|
driver.find_element(:link_text, 'Sign up').click
form = driver.find_element(:id, 'new_user')
form.find_element(:name,"user[u... |
class Person
def initialize(name)
@name = name
@emotions = {happiness:rand(1..3),sadness:rand(1..3), angry:rand(1..3)}
end
def display_emotions
@emotions.each do |key,value|
puts "I am feeling, #{display_level(value)} amount of #{key}"
end
end
def display_level(level)
if level == ... |
class FontSeymourOne < Formula
head "https://github.com/google/fonts/raw/main/ofl/seymourone/SeymourOne-Regular.ttf", verified: "github.com/google/fonts/"
desc "Seymour One"
homepage "https://fonts.google.com/specimen/Seymour+One"
def install
(share/"fonts").install "SeymourOne-Regular.ttf"
end
test do
... |
class Item < ActiveRecord::Base
has_many :deliveries, inverse_of: :item
has_many :orders, inverse_of: :item
has_many :bookings, inverse_of: :item
has_many :customers, :through => :bookings
accepts_nested_attributes_for :deliveries, :orders
validates :name, presence:{message:" ne peut être vide"... |
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
class TinyCI::OutputParser::CapistranoCommandParserTest < ActiveSupport::TestCase
test "should parse until eof" do
output = TinyCI::Output.new('1,cap,some output')
result = TinyCI::OutputParser::CapistranoCommandParser.parse(output)
... |
class FontMenloForPowerline < Formula
head "https://github.com/abertsch/Menlo-for-Powerline/archive/master.zip"
desc "Menlo for Powerline"
homepage "https://github.com/abertsch/Menlo-for-Powerline"
def install
parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEMP'] || '/tmp') ? '../' : ''
(share/"fonts... |
Rails.application.routes.draw do
get 'likes/index'
get 'likes/show'
get 'likes/new'
get 'likes/create'
get 'likes/destroy'
# Specify what Rails should route '/'. The root route only routes GET requests to the action > https://edgeguides.rubyonrails.org/routing.html
root 'home#show' #idem que root to: 'ho... |
require "rails_helper"
RSpec.describe Playlist, type: :model do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:playlist_songs) }
it { is_expected.to have_many(:songs) }
end
|
##
# EXPERIMENTAL
#
# Grand Central enhancements to GCD.
#
# From http://www.macruby.org/documentation/gcd.html
class Array
def parallel_map(&block)
result = []
# Creating a group to synchronize block execution.
group = Dispatch::Group.new
# We will access the `result` array from within this serial ... |
class LiabilityAccount < Account
def balance
(credits.map(&:value).inject(&:+) || 0) - (debits.map(&:value).inject(&:+) || 0)
end
end
|
class Task < ApplicationRecord
enum status: [:pending, :running, :paused, :finished]
has_many :project_tasks
has_many :projects, through: :project_tasks, dependent: :destroy
has_many :task_todos
has_many :todos, through: :task_todos, dependent: :destroy
has_many :subtasks, class_name: "Task", foreign_key... |
#
# task :default => :test
#
# task :build do
# sh(*%w( go build ))
# end
#
# task :test => :build do
# sh(*%w( go test -tags integration ))
# end
#
# namespace :run do
#
# task :local => :build do
# sh *%w( ./go-lazycache-app
# --port 7080
# --bind 127.0.0.1 )
# end
#
# task :google_store => :bu... |
class DeviceBatteriesController < ApplicationController
# GET /device_batteries
# GET /device_batteries.json
def index
@device_batteries = DeviceBattery.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @device_batteries }
end
end
# GET /device_batter... |
namespace :apachevhost do
desc "Setup an apache vhost"
task :setup, roles: :web do
template "apache_vhost.erb", "/tmp/apache_vhost"
run "mkdir /var/www/#{application}"
run "#{sudo} mv /tmp/apache_vhost /etc/apache2/sites-available/#{application}"
run "#{sudo} a2ensite #{application}"
run "#{sudo} service ... |
# frozen_string_literal: true
class Notifier < ActionMailer::Base
include DateHelper
add_template_helper ApplicationHelper
add_template_helper TranslationHelper
add_template_helper ViewHookHelper
default from: Settings.email.from, content_type: "multipart/alternative"
# Welcome user, login credentials
... |
class WelcomeController < ApplicationController
def index
@hello_world = 'Hello World'
@time_now = Time.now
end
end
|
class DockingStation
attr_reader :collection
attr_reader :bike
def initialize
@collection = []
end
def release_bike
fail 'No bikes available' unless @collection.length > 0
@bike
@collection.pop
end
def dock(bike)
fail "docking station full" if @collection.length == 20
@bike = ... |
class Gender < ActiveRecord::Base
has_many :categories
has_many :subcategories, through: :categories
has_many :deals
has_many :articles
end
|
module Api
class CommentsController < ApiController
def index
@comments = Comment.all.order(:id).page params[:page]
end
def show
@comment = Comment.find(params[:id])
end
def new
@comment = Comment.new
end
def create
@comment = Comment.new(comment_params)
@c... |
# frozen_string_literal: true
module Kafka
module Protocol
# A decoder wraps an IO object, making it easy to read specific data types
# from it. The Kafka protocol is not self-describing, so a client must call
# these methods in just the right order for things to work.
class Decoder
def self.fr... |
class Ability
include CanCan::Ability
attr_reader :user
def initialize(user)
return guest_abilities if user.nil?
@user = user
send("#{user.status}_abilities")
end
def guest_abilities
can :read, [Question, Answer, Comment, User]
end
def confirmed_user_abilities
guest_abilities
... |
class Asset < ApplicationRecord
has_and_belongs_to_many :users
has_and_belongs_to_many :types
has_many :blocks, dependent: :nullify
validates :name, uniqueness: true
validates :name, presence: true
def transaction_total
blocks.inject(0) do |total, block|
total + block.transaction_num
end
en... |
# Lets create an Object Oriented version of our Secret Number Game.
# Your updated game should have 4 classes (Main, SecretNumber, Game and Player)
# Below is a description of each class and some guidelines for each.
#
# Main
# The main class is where the game begins. This class should tell the player who made it.
# A... |
require "hemp/aliases"
module Hemp
module Routing
class Base
include Hemp::Aliases
include RouteExtensions
attr_reader :routes
SUPPORTED_VERB_LIST = %w(get delete patch post put).freeze
def initialize
@routes = {}
verb_helper SUPPORTED_VERB_LIST
end
d... |
# this is our main file
#things to do
# make call to parse yaml file (vs_builder code)
# create monitor (f5_monitor_create_template)
# update monitor
## add http send/receive (f5_monitor_set_template_string_property)
# create pool (f5_pool_create)
# update pool members
## PGA (f5_poolmember_set_priority.rb)
... |
class Property < ApplicationRecord
has_and_belongs_to_many :tenants, association_foreign_key: "user_id", join_table: "properties_users"
belongs_to :owner, optional: true, foreign_key: "user_id"
has_many :property_images
def address
"#{unit} / #{street}, #{city}"
end
def full_address
"#{unit} #{street... |
module Spec
module Rails
class IllegalDataAccessException < StandardError; end
module Mocks
# Creates a mock object instance for a +model_class+ with common
# methods stubbed out. Additional methods may be easily stubbed (via
# add_stubs) if +stubs+ is passed.
def mock_model(m... |
require 'rails_helper'
describe User do
it { should have_many :vacations }
it { should have_valid(:first_name).when("Luke", "Leia") }
it { should_not have_valid(:first_name).when(nil, "") }
it { should have_valid(:last_name).when("Skywalker", "Organa") }
it { should_not have_valid(:last_name).when(nil, "")... |
# incomplete answer - skipping
class SumOfMultiples
def initialize(*nums)
@nums = nums
end
def to(max_limit)
@nums.reduce(0) do |sum, num|
increment_by = num
while num < max_limit
sum += num >= max_limit ? 0 : num
num += increment_by
end
sum += num >= max_limit ?... |
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "action_controller/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
... |
class Game < ActiveRecord::Base
attr_accessor :boxart_dir
belongs_to :platform
belongs_to :game_type
belongs_to :series
belongs_to :market
belongs_to :rating
belongs_to :local_multi_modes, :class_name => "MultiplayerMode", :foreign_key => :local_multi_modes_id
belongs_to :online_multi_modes, :class_name... |
module Joybox
module Configuration
class GLView < CCGLView
attr_accessor :resize_to_superview
def self.defaults
{
bounds: [[0, 0], [0, 0]],
auto_resize_mask: NSViewHeightSizable | NSViewWidthSizable
}
end
def self.new(options)
bounds_provid... |
class ViewController < ApplicationController
get '/' do
content_type "text/html"
send_file File.expand_path('index.html', settings.public_folder)
end
end
|
require "test_helper"
require "loyalty_connect"
module LoyaltyConnect
class MockApiClient
def get_urls
@get_urls ||= []
end
def get_block_values
@get_block_values ||= []
end
def get url, &block
get_urls << url
error = LoyaltyConnect.error_for "404"
get_block_values... |
module Api::V1::UsersDoc
extend Apipie::DSL::Concern
api :GET, '/v1/users/', 'List of resources: User'
formats %w(json)
header :HTTP_ACCEPT, 'application/json', required: true
header 'X-User-Email', 'email', required: true
header 'X-User-Token', 'authentication token', required: true
description 'Returns... |
# frozen_string_literal: true
require 'application_system_test_case'
module Courses
class IndexTest < ApplicationSystemTestCase
def setup
@course = courses(:potions)
end
test 'guest user can see courses' do
visit root_path
assert_content @course.name
assert_content @course.crea... |
require 'rails_helper'
describe 'user API requests', type: :request do
let (:user) { create(:user) }
let (:url) { '/api/v1/current_user_entries.json' }
context 'not logged in user' do
it "can't access data" do
get url
expect(response).to have_http_status(:unauthorized)
... |
class SchedulerGame
class States
class Pause < CyberarmEngine::GuiState
def setup
background 0xaa_222222
flow(width: 1.0, height: 1.0) do
stack width: 0.3, height: 1.0, padding: 24 do
background 0xff_222222
banner "SCHEDULER", width: 1.0, text_align: :cent... |
require "spec_helper"
describe SeoreviewsController do
describe "routing" do
it "routes to #index" do
get("/seoreviews").should route_to("seoreviews#index")
end
it "routes to #new" do
get("/seoreviews/new").should route_to("seoreviews#new")
end
it "routes to #show" do
get("/s... |
class Response < ApplicationRecord
validates :user_id, :answer_choice_id, presence: true
validate :not_duplicate_response, :respondent_not_author
belongs_to :answer_choice,
primary_key: :id,
foreign_key: :answer_choice_id,
class_name: :AnswerChoice
belongs_to :respondent,
primary_key: :id,
... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Tikkie::Api::Clients::PaymentRequestsSubscription do
subject(:client) { described_class.new(config) }
let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') }
describe '#create' do
it 'creates a new payment re... |
require 'rexml/document'
module HBase
module Response
class BasicResponse
def initialize(raw_data)
@raw_data = raw_data
end
def parse
parse_content @raw_data
end
end
end
end
|
# frozen_string_literal: true
class BoxerPalletCompanion < ApplicationRecord
belongs_to :boxer_pallet, inverse_of: :companion
belongs_to :category
validates :boxer_pallet, :destination, :location, :category, presence: true
scope :for_location, ->(location) { where(location: location) }
scope :for_category,... |
require "thread"
COMMAND = ENV.fetch("COMMAND")
# Webhook server, runs a command serially whenever it receives a request
class Server
attr_reader :queue
def initialize
@queue = Queue.new
end
def consumer_thread
@consumer_thread ||= Thread.new do
consumer_kicker
end
end
alias_method :s... |
#swap the first and last name
#swap the vowels (a, e, i, o or u) to the next vowel. So a becomes e, etc
#swap the consonant for the next consonant, skipping vowels
#provide a user interface, so that a user may enter as many names as they want
#store the aliases
#BUSINESS LOGIC
#write a method to swap the names
def n... |
module V1
class ItinerariesSerializer
include FastJsonapi::ObjectSerializer
belongs_to :user
attributes :price
end
end |
require 'ostruct'
module Aamva
class Proofer < Proofer::Base
vendor_name 'aamva:state_id'
required_attributes :uuid,
:first_name,
:last_name,
:dob,
:state_id_number,
:state_id_type,
:state_id_jurisdiction
stage :s... |
class CreateGoalEntries < ActiveRecord::Migration[5.2]
def change
create_table :goal_entries do |t|
t.string :name
t.belongs_to :goal, foreign_key: true
t.datetime :start
t.datetime :finish
t.jsonb :meta, default: {}
t.timestamps
end
end
end
|
class CreateOrganizationLocations < ActiveRecord::Migration
def change
drop_table :foster_homes if self.table_exists?("foster_homes")
create_table :organization_locations do |t|
t.integer :organization_id
t.references :location, polymorphic: true
t.timestamps
end
end
en... |
Rbpm::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
namespace :admin do
resources :users
resources :blogs
resources :departments
end
get 'signup',to:'users#new'
get 'login',to:'users#newlogin'
post 'login',to:'users#login'
delete... |
#
# part 1
class ProgramTree
attr_reader :links, :node_weights
def initialize(links:, weights:)
@links = links
@node_weights = weights
end
def root
return @root if @root
no_parent = find_root_node(links)
raise "There is only one root" if no_parent.length != 1
@root = no_parent[0]
... |
class AddDirectionToPriceNotifications < ActiveRecord::Migration
def change
add_column :price_notifications, :direction, :string
add_index :price_notifications, :direction
end
end
|
class Prize
# TODO make persistant
#include Mongoid::Document
#include Mongoid::Timestamps::Created
REQUIRED_PRIZES = [
:grand_prize,
:made_in_canada,
:flora_1st,
:flora_2nd,
:flora_3rd,
:fauna_1st,
:fauna_2nd,
:fauna_3rd,
:landscapes_1st,
:landscapes_2nd,
:landscape... |
class Owner < ApplicationRecord
has_many :stores
end
|
RSpec.describe AwesomeBinPack::Rectangle do
describe "#initialize" do
it "rotatable should be false by default" do
rectangle = AwesomeBinPack::Rectangle.new(10, 15)
expect(rectangle.rotatable).to eq(false)
end
it "should accept string as parameters" do
rectangle = AwesomeBinPack::... |
class CategorySerializer < ActiveModel::Serializer
include ApplicationSerializer
attributes :id, :name, :created_at, :updated_at, :_links
def _links
hash = super
hash["self"] = {
"href" => category_url(id)
}
hash
end
end
|
#6) ARRAY 6
a = [1,2,3,9,12,31, "domingo"]
b = ["lunes", "martes", "miércoles", "jueves", "viernes", "sábado", "domingo"]
# 1. La concatenación de a y b. (hint: Los elementos que se repiten en a y b pueden aparecer dos
# veces en el resultado).
print a + b
# 2. La unión de a y b. (hint: Los elementos que se rep... |
require 'csv'
class VisitorsController < ApplicationController
"""
Methods to perform spell checking
Start with correct_word
"""
"""
In this method, we permute through a possible set of words
"""
def double_permute_words word
x = []
a = permute_words word
for i i... |
class Comment
include Mongoid::Document
field :body, type: String
belongs_to :user
belongs_to :product
validates :body, presence: true
end
|
## GENERAL COMMENTS -
# 1. Schedule meeting next day if the user specified day is a holiday, or the user specified time is past working hours of the business center
=begin
Day Scheduling -
We have schedule appointments for a Business Center.
We should be able to specify the start and end timings for the Business Cen... |
class Api::FinanceTransactionsController < ApiController
filter_access_to :all
def index
@xml = Builder::XmlMarkup.new
@finance_transactions = FinanceTransaction.search(params[:search])
respond_to do |format|
unless params[:search].present?
render "single_access_tokens/500.xml", :statu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.