text stringlengths 10 2.61M |
|---|
require 'pathname'
module Twigg
autoload :Cacher, 'twigg/cacher'
autoload :Command, 'twigg/command'
autoload :Commit, 'twigg/commit'
autoload :CommitSet, 'twigg/commit_set'
autoload :CommitSetDecorator, 'twigg/commit_set_decorator'
autoload :Config, '... |
class Api::V1::TodoListPresenter < Api::V1::BasePresenter
def present_object(object, options = {})
return object unless object.errors.empty? # Renders validation errors
unless options[:include_root]
if options[:minimal]
{
:id => object.id,
:name => object.name
}
... |
require "requests/spec_helper"
# This file will be required by
# all file in this directory and subdirectory
shared_context "setup_s2_environment_for_dna_rna_manual_extraction" do
let(:user_uuid) { "2ea2d340-7f57-0130-e344-282066132de2" }
let(:study_uuid) { "2ea2dc40-7f57-0130-e344-282066132de2" }
let(:sample_uu... |
class Post::TopRatingQuery
include ActiveModel::Validations
validates :quantity, presence: true, numericality: { only_integer: true }
attr_reader :collection, :quantity, :page
def initialize(params:)
@quantity = params[:quantity]
@page = params[:page].to_i > 0 ? params[:page] : 1
end
def perform
... |
class LinkedinUserUpdateComment < ActiveRecord::Base
belongs_to :linkedin_user_comment_like,:foreign_key => "linkedin_user_comment_like_id"
def self.process_hash(comment)
if (comment.nil?)
return nil
end
comment['linkedin_id'] = comment['person']['id']
comment['first_name'] = comment['person... |
require 'test_helper'
describe Rack::PrxAuth do
let(:app) { Proc.new {|env| env } }
let(:prxauth) { Rack::PrxAuth.new(app) }
let(:fake_token) { 'afawefawefawefawegstgnsrtiohnlijblublwjnvrtoign'}
let(:env) { {'HTTP_AUTHORIZATION' => 'Bearer ' + fake_token } }
let(:iat) { Time.now.to_i }
let(:exp) { 3600 }
... |
require 'spec_helper'
describe Tapir::Reports::Template do
context 'given an object attribute tag' do
let(:content) { '<%= @foo.bar %>' }
it 'should output Twitter Bootstrapped erb (for displaying as a preview)' do
expect(Tapir::Reports::Template.to_bootstrap_erb(content)).to eq('<%= @foo.bar %>'... |
class TuristicPoint < ActiveRecord::Base
include Visitavel
belongs_to :pais
belongs_to :estado
belongs_to :cidade
#Galleria
has_many :turistic_point_galleries
accepts_nested_attributes_for :turistic_point_galleries
#Validação
validates :nome, presence: true
validates :pais, presence: true
va... |
class MetabolicRatesController < ApplicationController
layout 'tracking'
before_filter :authenticate_user!
def edit
@user = current_user
end
def update
if current_user.birthdate.blank?
redirect_to(user_edit_personal_info_path(current_user), :alert => 'Please set your birthdate first, we... |
class SemanticalPhase
@@operators = ['StartSym', 'PlusOp', 'MinusOp', 'MultiplyOp', 'DivideOp',
'NegOp', 'LParen', 'RParen', 'AssignOp', 'SemiColon', 'Comma']
@@comparison_operators = ['EqSym', 'NotEqSym', 'LsSym', 'LsEqSym',
'GrSym', 'GrEqSym']
def... |
# frozen_string_literal: true
require_relative 'mixins/command'
# select-pane (alias: selectp)
# [-DdeLlMmRUZ]
# [-T title] [-t target-pane]
module Build
module Util
class Tmux
module SelectPane
include Mixins::Command
aka :selectp
switch D: :below
switch d: :disable... |
class AccountController < ApplicationController
before_filter :build, :except=>'index'
require 'account' #Explicit include of model because we use derived classes
#so autoloader gets confused cos I didn't make each one its own file
def graph
case @code
when false
else
@basex=8
@basey=... |
class UsersController < ApplicationController
before_filter :authenticate_user!
before_filter :verify_is_admin
def index
if params[:approved] == "false"
@users = User.find_all_by_approved(false)
else
@users = User.find(:all, :conditions => ["id != 1"])
end
end
def approve
@user = User.fi... |
require 'rails_helper'
RSpec.describe ProfileSocial, type: :model do
it {should belong_to(:profile)}
it {should belong_to(:social_type)}
it {should validate_presence_of(:profile)}
it {should validate_presence_of(:social_type)}
it {should validate_presence_of(:link)}
end
|
require 'station'
describe Station do
context 'station returns expected attributes' do
before (:each) do
@subject = Station.new("Baker Street", 1)
end
it 'returns Baker Street when asked for station name' do
expect(@subject.name).to eq("Baker Street")
end
it 'returns 1 when asked f... |
class AddOptionToImageFiles < ActiveRecord::Migration[5.0]
def change
change_column :image_files, :file, :text, null: false
change_column :image_files, :about_file, :text, null: false
change_column :image_files, :status, :integer, null: false
end
end
|
class JobType < ActiveRecord::Base
has_and_belongs_to_many :requirements
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class ChangeNotesTypeInTmk < ActiveRecord::Migration[4.2]
def change
change_column :tmks, :notes, :text
end
end
|
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2014-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# U... |
Rails.application.routes.draw do
devise_for :users
resources :entries do
resources :comments
end
root 'entries#index'
get '/list', to: "entries#list"
namespace :api do
resources :entries, path: 'news' do
resources :comments
end
end
end
|
class FinancialYear
include Comparable
class InvalidYear < StandardError; end
attr_reader :start_year, :end_year
def initialize(start_year)
@start_year = DateTime.strptime(start_year.to_s, "%Y").year
@end_year = @start_year + 1
rescue ArgumentError
raise InvalidYear
end
class << self
d... |
class MP3Importer
attr_accessor :path, :file
def initialize(path)
@path = path
@file = file
end
def files
Dir.chdir(@path) {| path | Dir.glob("*.mp3")}
# Dir.entries(path).each {|filename| @file_names << "#{filename}"}
end
def import
self.files.each {|filename| Song.new_by_filename(fi... |
require 'test_helper'
class SupervisortsControllerTest < ActionDispatch::IntegrationTest
setup do
@supervisort = supervisorts(:one)
end
test "should get index" do
get supervisorts_url
assert_response :success
end
test "should get new" do
get new_supervisort_url
assert_response :success
... |
# frozen_string_literal: true
(1..99).each { |number| puts number, ' ' if number.even? }
|
class AddTimestapsToTmpgImpressions < ActiveRecord::Migration
def change_table
add_column(:tmpg_impressions, :created_at, :datetime)
add_column(:tmpg_impressions, :updated_at, :datetime)
end
end
|
class MessagesController < ApplicationController
before_action :signed_in?, only: :create
def create
@post = Post.find_by id: params[:post_id]
user = photographer_signed_in? ? current_photographer : current_customer
unless (@post.customer.eql?(user) || @post.photographer.eql?(user))
flash[:alert]... |
module Workflow
module Concerns
module DynamicAnnotationFieldConcern
DynamicAnnotation::Field.class_eval do
attr_accessor :previous_status
before_validation :normalize_workflow_status
validate :workflow_status_is_valid
validate :can_set_workflow_status, unless: proc { |x| x.... |
# frozen_string_literal: true
module RakutenWebService
class Recipe < Resource
def self.large_categories
categories('large')
end
def self.medium_categories
categories('medium')
end
def self.small_categories
categories('small')
end
def self.categories(category_type)
... |
module YelpAPI
API_HOST = "https://api.yelp.com"
SEARCH_PATH = "/v3/businesses/search"
BUSINESS_PATH = "/v3/businesses/" # trailing / because we append the business id to the path
TOKEN_PATH = "/oauth2/token"
GRANT_TYPE = "client_credentials"
SEARCH_LIMIT = 20
def self.test(location, term)
url = "#{API_H... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "pebblebed/version"
Gem::Specification.new do |s|
s.name = "pebblebed"
s.version = Pebblebed::VERSION
s.authors = ["Katrina Owen", "Simen Svale Skogsrud"]
s.email = ["katrina@bengler.no", "simen@bengler.no"]
s... |
class PublisherAuthorizer < ApplicationAuthorizer
# Users can view all publishers
def self.readable_by?(user)
true
end
# Users can create publishers if they are admins
def self.creatable_by?(user)
user.has_role? :admin
end
# Users can edit publishers if they are admins
def self.updatable_by?(... |
class DropSuppliersTableIfExists < ActiveRecord::Migration
def change
drop_table :suppliers if table_exists? :suppliers
end
end
|
#! /usr/bin/env ruby
#
# Check Graphite Thresholds
# ===
#
# This is a Sensu plugin to check Graphite Thresholds.
#
#
require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-plugin/check/cli'
require 'sensu-plugin/utils'
require 'json'
require 'open-uri'
require 'openssl'
require 'cgi'
class CheckGraphiteThreshold... |
require 'scorched_earth/helpers'
module ScorchedEarth
module Services
class Deform
include Helpers
attr_reader :array
def initialize(array)
@array = array
end
def call(center_x, radius, center_y = array[center_x])
new_array = array.dup
circle(radius) do |of... |
# your code goes here
# #begins_with_r
# Return true if every element of the tools array starts with an "r" and false otherwise. (FAILED - 1)
# should return false if there's an element that does not begin with r (FAILED - 2)
def begins_with_r(tools)
counter = 0
tools.each do |data|
counter +=1 if data[... |
module ETL #:nodoc:
module Processor #:nodoc:
# Row-level processor that will convert a single row into multiple rows designed to be inserted
# into a hierarchy bridge table.
class HierarchyExploderProcessor < ETL::Processor::RowProcessor
attr_accessor :id_field
attr_accessor :parent_id_field
... |
# frozen_string_literal: true
require 'cinch'
class JoinPart
include Cinch::Plugin
extend Usagi::Help
info 'join', 'Join channel. join <channel>'
info 'part', 'Leave channel. part [channel]'
match /join (.+)/, method: :join
match /part(?: (.+))?/, method: :part
def initialize(*args)
super
@ad... |
# frozen_string_literal: true
class AddStatusDefaultToPets < ActiveRecord::Migration[5.1]
def change
change_column :pets, :status, :string, default: 'Adoptable'
end
end
|
require "rubygems"
require "eventmachine"
# From "An EventMachine Tutorial"
# http://20bits.com/articles/an-eventmachine-tutorial/
# ハンドラー
module EchoServer
# connectionからデータを受け取った時に呼び出されるメソッド
def receive_data(data)
# receive_dataを呼び出したconnectionにデータを返す
# receive_dataしたらsend_dataする
send_data(data)
e... |
module Socialable
extend ActiveSupport::Concern
included do
has_many :social_media_accounts, as: :socialable, dependent: :destroy
end
def facebook_url
return '' if self.is_a?(Beer)
account = social_media_accounts.find_by(website: 'Facebook')
account ? "http://www.facebook.com/#{account.handle}... |
#!/usr/bin/env ruby
require 'vanagon/logger'
script = File.basename($0)
VanagonLogger.info "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
Use: 'vanagon #{script}' instead."
exec "vanagon", script, *ARGV
|
require 'spec_helper'
describe G5Authenticatable do
it 'should have a version' do
expect(G5Authenticatable::VERSION).to_not be_blank
end
end
|
class PendingRequest < ActiveRecord::Base
belongs_to :household
belongs_to :request
before_create :assign_default_status
def send_request_volunteered_email(users)
for user in users
PendingRequestMailer.deliver_request_volunteered_email(self, user)
end
end
def send_volunteer_confirmed_em... |
require 'rails_helper'
RSpec.describe Thing, type: :model do
describe 'associations' do
it { should belong_to(:user) }
it { should belong_to(:borrower).class_name('User') }
it { should have_db_index(:borrower_id) }
it { should have_db_index(:user_id) }
end
describe 'validations' do
it { sho... |
class ProjectsController < ApplicationController
def index
projects = Project.all
render json: projects.sort_by { |project| project.created_at }
end
def create
project = Project.new(project_params)
if project.save
render json: project
serialized_data= ActiveModelSerializers::Adapter:... |
#
# Cookbook Name:: mariadb
# Recipe:: _debian_server
#
# Copyright 2014, blablacar.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... |
class AddUserIdToPointOfInterest < ActiveRecord::Migration
def change
add_column :point_of_interests, :user_id, :integer
add_index :point_of_interests, :user_id
end
end
|
class CreateAUsers < ActiveRecord::Migration
def change
create_table :a_users do |t|
t.string :username, :limit => 100, null: false
t.string :password, null: false
t.string :encrypted_password, null: false
t.string :nickname, :limit => 100, null: false
t.string :fullname, null: false... |
require 'rails_helper'
describe ComputeHistory, type: :model do
it { is_expected.to be_mongoid_document }
it { is_expected.to embed_many(:ips) }
it { is_expected.to validate_presence_of(:computed_at) }
end
|
module UseCase
class Base
def self.call(params:)
new(params: params).call
end
def initialize(params:)
@params = params
end
def call
ActiveRecord::Base.transaction do
persist.tap do
rescue Exception => e
Rails.logger.error(
e.message + "\n" + e.backtrace[0, 1... |
require 'rails_helper'
describe EadIndexer::Behaviors do
let(:behaviors){ Class.new{ extend EadIndexer::Behaviors } }
describe "#repository_display" do
subject { behaviors.repository_display }
context "when EAD variable is a folder in the client application" do
before { stub_const('ENV', {'EAD' =... |
class ChangeDataTypeForFieldname < ActiveRecord::Migration
def up
rename_column :emojis, :transaction, :transaction_id
end
def down
end
end
|
require "colored"
require "forwardable"
require "highline"
require "hirb-colors"
require "hirb"
module TrelloFlow
class Cli
class << self
extend Forwardable
def_delegators :client, :table, :open_url, :say, :success, :ask, :title, :error, :run, :read
attr_accessor :client
end
self.clien... |
class Step8Proc < ActiveRecord::Migration
def up
connection.execute(%q{
-- STEP 8 of process
CREATE OR REPLACE FUNCTION public.proc_step_8(process_representative integer,
experience_period_lower_date date,
experience_period_upper_date date,
current_payroll_period_lower_date date,
... |
require 'spec_helper'
describe Contact do
it "has a valid factory" do
expect(build(:contact)).to be_valid
end
it { should validate_presence_of :first_name }
it { should validate_presence_of :last_name }
it { should validate_presence_of :email }
it { should validate_uniqueness_of(:email) }
it "retur... |
class RemoveCreateYearFromEvaluation < ActiveRecord::Migration[5.0]
def change
remove_column :evaluations, :create_year, :string
end
end
|
class Message < ActiveRecord::Base
belongs_to :project
belongs_to :sender, :class_name => 'User'
belongs_to :receiver, :class_name => 'User'
validates :subject, :body, :project_id, presence: true
end
|
class Home
attr_reader(:name, :city, :capacity, :price)
def initialize(name, city, capacity, price)
@name = name
@city = city
@capacity = capacity
@price = price
end
end
homes = [
Home.new("Nizar's place", "San Juan", 2, 42),
Home.new("Fernando's place", "Seville", 5, 47),
Home.new("Josh's... |
module Kubik
class MetaTagDefaultsController < ApplicationController
layout :resolve_layout
def edit; end
def update
@meta_tag_defaults = Kubik::MetaTagDefaultsForm.new(meta_tag_defaults_params)
if @meta_tag_defaults.save
flash.now[:notice] = t('kubik_metatagable.defaults_saved')
... |
require_relative '../schema/permutation'
module Services
class PermutationMaker
def initialize(collection, value, options = {})
@collection = collection
@value = value
@options = options
end
def make
{}.tap do |hash|
@collection.each do |member|
dividend = @val... |
=begin
* ****************************************************************************
* BRSE-SCHOOL
* HELPER - RegisstAdvisoriesHelper
*
* 処理概要 :
* 作成日 : 2017/09/15
* 作成者 : havv – havv@ans-asia.com
*
* 更新日 :
* 更新者 :
* 更新内容 :
*
... |
require "spec_helper"
describe MatchDay do
it { should have_many(:matches) }
describe '.next' do
subject { MatchDay.next }
context 'with several futur match_days' do
let!(:match_day_0) { create :match_day, :finished }
let!(:match_day_1) { create :match_day, start_date: 1.days.ago, end_date... |
class DataController < ApplicationController
layout false
before_action :check_minimum_files_required, only: :csv
def csv
files = Uploads.get_uploaded(params[:csv][:files])
concern = params[:csv][:concern]
csv_merged = CsvMerger.merge(*files)
models = DiscrepancyCsvParser.parse(csv_merged)
@di... |
# encoding: utf-8
control "V-92689" do
title "The Apache web server must generate a session ID using as much of the character set as possible to reduce the risk of brute force."
desc "Generating a session identifier (ID) that is not easily guessed through brute force is essential to deter several types of session at... |
require 'deep_thought/deployer/deployer'
module DeepThought
module Deployer
class Shell < DeepThought::Deployer::Deployer
def execute?(deploy, config)
environment = deploy.environment || "development"
root = config['root'] || "script/deploy"
command = "#{root} #{environment} deplo... |
# Copyright (c) 2016 Nathan Currier
# This Source Code File is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
module Rideliner
VERSION = '0.3.6'.freeze
end
|
Factory.define :response, :class => Noodall::FormResponse do |response|
response.name "A User"
response.email "user@example.com"
response.ip "127.0.0.1"
response.created_at Time.zone.now
response.referrer "http://rac.local/the-college"
end
|
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.0.1"
gem "rails", "~> 6.1.4"
gem 'hotwire-rails'
# Use postgresql as the database for Active Record
gem "pg", ">= 0.18", "< 2.0"
# Use Puma as the app server
gem "puma", "~> 4.3.5"
# Transpile app-like JavaScript. R... |
class Constructor < ActiveRecord::Base
has_many :drivers
def pick_driver(driver)
drivers << driver
end
def increase_techfactor(tech_points)
self.tech_factor += tech_points
end
def after_driver_selection
drivers.each do |d|
Constructor.budget -= d.price
end
... |
# puts 'I am a fortune-teller. Tell me your name: '
# name = gets.chomp
# if name == 'Chris'
#puts 'I see great things in your future. '
#else
# puts 'Your future is... oh my! Look at the time!'
# puts 'I really have to go, sorry!'
#end
#puts 'Hello and welcome to seventh grade English. '
#puts 'My name is Mrs. Ga... |
# frozen_string_literal: true
class RenamePostUserIdToBooks < ActiveRecord::Migration[6.0]
def change
rename_column :books, :post_user_id, :user_id
end
end
|
class EducationalRelationship < ApplicationRecord
belongs_to :education_program
belongs_to :educational, polymorphic: true
end
|
class User
include Mongoid::Document
has_many :sources
has_many :posts
def self.find_or_create_by_hash(auth_hash)
@user = nil
@source = Source.where(:provider => auth_hash["provider"], :identifier => auth_hash["uid"])
if @source.first
#assert only one source
@user = @source.first.us... |
# encoding: utf-8
require 'spec_helper'
describe "mail encoding" do
it "should allow you to assign a mail wide charset" do
mail = Mail.new
mail.charset = 'utf-8'
expect(mail.charset).to eq 'utf-8'
end
describe "using default encoding" do
it "should allow you to send in unencoded strings to fiel... |
class Customer < ApplicationRecord
validates_presence_of :name, :email, :address, :city, :country, :creditcard
end
|
module WizardOfAwes
def self.frameworks
frameworks = ['rails']
frameworks
end
def self.load_framework!
show_warning if frameworks.empty?
frameworks.each do |framework|
begin
require framework
rescue NameError => e
raise "Failed to load framework #{framework.inspect}. H... |
# frozen_string_literal: true
class UsersController < ApplicationController
before_action :authenticate_user!
before_action :find_user, only: :show
def index
@orders = Order.active.sort_created_at
@customers = User.active.customer
@leeds = Leed.sort_created_at
@recents = @customers.sort_created_... |
class AuditsController < ApplicationController
before_filter :authenticate_user!
before_filter :find_audit, except: [:clone, :create, :deleted, :index]
helper_method :current_audit
def index
respond_to do |format|
format.html do
@audits = current_user.available_audits
... |
class Product < ActiveRecord::Base
has_many :reviews
validates :name, :presence => true
validates :cost, :presence => true, numericality: true
# validates :country, :presence => true
scope :sort_date, -> {order(created_at: :desc).limit(3)}
scope :sort_cost, -> {order(cost: :asc).limit(5)}
end
|
require 'test_helper'
class ProfissionalsControllerTest < ActionDispatch::IntegrationTest
setup do
@profissional = profissionals(:one)
end
test "should get index" do
get profissionals_url
assert_response :success
end
test "should get new" do
get new_profissional_url
assert_response :suc... |
class AddView3AttribsToApps < ActiveRecord::Migration[5.2]
def change
add_column :apps, :available_since, :date
add_column :apps, :mydata_membership, :string
add_column :apps, :license, :string
add_column :apps, :user_id, :integer
end
end
|
class UserStatistic < ApplicationRecord
belongs_to :user
def total_questions
self.right_questions + self.wrong_questions
end
end
|
# frozen_string_literal: true
namespace :dev do
desc "Configure development environment"
task setup: :environment do
unless Rails.env.production?
# show_spinner("Migrating DB...") { %x(rails db:migrate) }
# show_spinner("Creating Default User...") { %x(rails dev:add_users) }
show_spinner("Cre... |
# Write a method that takes a block and calls it once for
# each hour that has passed today.
# Hint: You can use Time.new.hour to get the current hour.
# However, this returns a number between 0 and 23, so you
# will have to alter those numbers in order to get ordinary
# clock-face numbers (1 to 12).
def grandfather_... |
class Role
include Mongoid::Document
field :name, type: String
belongs_to :app
belongs_to :permissions
has_many :assignments
end
|
require File.expand_path("../../Abstract/abstract-php-phar", __FILE__)
class Climb < AbstractPhpPhar
init
desc "Composer version manager tool"
homepage "https://github.com/vinkla/climb"
url "https://github.com/vinkla/climb/releases/download/0.8.0/climb.phar"
sha256 "72c7dfa15d86b8c09bd0628bc11bed79ce00c9c03c... |
class Ball
@@image = Rubygame::Surface.load_image("resources/ball.png")
def initialize(x, y, moving_left, moving_up, min_x, max_x, min_y, max_y)
@step = 12
@x = x
@y = y
@x_start = x
@y_start = y
@moving_left = moving_left
@moving_up = moving_up
... |
Rails.application.routes.draw do
resources :candidate_profile, only: [:new, :create]
devise_for :users
namespace :admin do
resources :candidate_profiles, only: [:index, :show]
root 'candidate_profiles#index'
end
get '/guides' => 'guides#index'
root 'home#index'
end
|
class MealsController < ApplicationController
before_action :set_meal, only: [:show, :edit, :update, :destroy]
def index
@meals = Meal.all
end
def show
end
def new
@meal = Meal.new
end
def create
@meal = Meal.new(meals_params)
if @meal.save
redirect_to meals_path, notice: 'You... |
# $LICENSE
# Copyright 2013-2014 Spotify AB. All rights reserved.
#
# The contents of this file are licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-... |
require_relative './node'
require_relative './doubly_linked_list_errors'
class DoublyLinkedList
include DoublyLinkedListErrors
attr_reader :head, :tail, :length
def initialize
@head = nil
@tail = nil
@length = 0
end
def insert(data)
# O(1)
node = Node.new(data)
if @head
no... |
Rails.application.routes.draw do
devise_for :installs
devise_for :users, controllers: {sessions: 'sessions'}
root 'pages#home', id: 'home'
# Other Pages
get '/list', to: 'pages#list'
get '/terms', to: 'boilerplate#terms'
get '/home', to: redirect('/')
get '/admin', to: 'admin#index'
get '/users/:id/... |
class Station
attr_reader :name, :trains
def initialize(name)
@name = name
@trains= []
end
#Принимает поезда
def take_train(train)
@trains << train
end
#Отправляет поезда
def send_train(train)
@trains.delete(train)
train.stations = nil
end
#Возращает список грузовых и пасса... |
puts "Hello! What is your name?"
user_name = gets.chomp
again = "yes"
while again != "no"
puts "Welcome to the Love Letter Mad Lib " + user_name + "!"
puts " "
puts "Tell me a name:"
name_1 = gets.chomp
puts "Tell me an adjective:"
adjective_1 = gets.chomp
puts "Tell me a verb:"
verb_1 = gets.chomp
... |
class LostsController < ApplicationController
load_and_authorize_resource
before_action :set_lost, only: [:show, :edit, :update, :destroy]
respond_to :html, :js
# GET /losts
def index
if params[:name]
@losts = Lost.search("%#{params[:name]}%")
flash[:notice] = "No search result found".html... |
=begin
@File Name : galleries_controller.rb
@Company Name : Mindfire Solutions Private Limited
@Creator Name : Vikram Kumar Mishra
@Date Created : 2013-03-03
@Date Modified :
@Last Modification Details :
@Purpose : To ha... |
require 'rubygems'
require 'rake'
require 'echoe'
require './lib/syslog_logger.rb'
Echoe.new('SyslogLogger', SyslogLogger::VERSION) do |p|
p.author = 'Eric Hodel; Chris Powell'
p.email = 'drbrain@segment7.net; cpowell@prylis.com'
p.description = "An improved Logger replacement that logs to syslog. It is almost d... |
# class for table departments
class StoreDepartment < ApplicationRecord
include Stats::Efficiency
include Defaults
include CommercialCalendar::Period
PERIODS = Settings.productivity_periods_keys
WEEK_PERIODS = Settings.productivity_week_periods_keys
belongs_to :store, dependent: :destroy
belongs_to :dep... |
class TagsController < ApplicationController
def index
render json: ActsAsTaggableOn::Tag.where('taggings_count > 0').pluck(:name).to_json
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.