text stringlengths 10 2.61M |
|---|
class FontIosevkaSs14 < Formula
version "18.0.0"
sha256 "ea29d667e46d0101d6f0adebbee80a195cc28f68f98a57b4a9726c02fba867be"
url "https://github.com/be5invis/Iosevka/releases/download/v#{version}/ttc-iosevka-ss14-#{version}.zip"
desc "Iosevka SS14"
desc "Sans-serif, slab-serif, monospace and quasi‑proportional ... |
class MorningActivityResultsController < ApplicationController
skip_before_action :verify_authenticity_token
def index
range = params[:month].to_date.all_month
@month_results = current_user.morning_activity_results.where(execution_at: range)
respond_to do |format|
format.html
format.json { ... |
module CgScout
class Config
def initialize
data = YAML.load_file(Pathname.getwd.join('cloudgate.yml')) || {}
deploy_dir_name = data['deploy_dir'] || 'deploy'
@deploy_dir = Pathname.getwd.join(deploy_dir_name)
end
def get_environments
files = Pathname.glob(@deploy_dir.join('environ... |
class City < ActiveRecord::Base
attr_accessible :name, :state
has_many :users
end |
class SecuenciaDeAcordesSerializer < ActiveModel::Serializer
attributes :id, :usuario_id, :nombre_usuario, :titulo, :bpm
has_many :acordes
has_many :comentarios
def usuario_id
object.usuario.id_externo
end
def nombre_usuario
object.usuario.nombre
end
end |
require 'pathname'
# Configurator::DEFAULTS[:logger].formatter = Logger::Formatter.new
lgr = Logger.new($stderr)
logger lgr
app_path = Pathname.new(__FILE__).expand_path.dirname.parent
apps_folder, this_app_name = app_path.split
current_release = apps_folder.join('../current')
is_cap_release = current_release.exist... |
class CollateralAttributeOption < ApplicationRecord
belong_to :collateral
belong_to :attribute_option
end
|
require 'rails/generators'
require 'rails/generators/migration'
module Taxis
class MigrationGenerator < Rails::Generators::Base
include Rails::Generators::Migration
def self.source_root
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
end
def self.next_migration_number(dirname)... |
# frozen_string_literal: true
module XML
# This class dynamically builds xml to send to dealersocket
class Base
def initialize(variables)
@variables = variables
end
protected
def application_area(xml, service_message_id)
xml.ApplicationArea do
xml.Sender do
xml.Creat... |
class CreateBalances < ActiveRecord::Migration[5.2]
def change
create_table :balances do |t|
t.references :account, foreign_key: true
t.references :transfer, foreign_key: true
t.references :deposit, foreign_key: true
t.references :withdrawal, foreign_key: true
t.decimal :amount
... |
require 'spec_helper'
describe Project do
context "#validations" do
it "should require a name" do
project = build(:project, name: "")
expect(project).to_not be_valid
end
it "should have a unique name" do
project = create(:project)
project = build(:project, name: project.name)
... |
# (c) Copyright 2016-2017 Hewlett Packard Enterprise Development LP
#
# 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
#
# Unless required by applicabl... |
class User < ApplicationRecord
has_secure_password
has_many :auctions, dependent: :destroy
has_many :bids, dependent: :destroy
has_many :auctions_bid_on, through: :bids, source: :auction
has_many :watches, dependent: :destroy
has_many :watched_auctions, through: :watches, source: :auction
before_valida... |
class RenameExerciseSuperSetColumn < ActiveRecord::Migration[5.1]
def change
rename_column :exercises, :super_set_id, :exercise_circuit_id
end
end
|
class Game < ActiveRecord::Base
include Auditable
attr_accessible :playerstats_attributes, :teamstat1_id, :teamstat2_id, :league_id, :visiting_team_goals, :home_team_goals, :completed
before_create :team_rosters_to_playerstats
before_update :update_game
before_destroy :revert_teamstat
belongs_to :visiting_... |
class CountryPhoto < ActiveRecord::Base
belongs_to :country
belongs_to :photo
attr_accessor :association_should_exist
end
|
class CreateValuations < ActiveRecord::Migration
def change
create_table :valuations do |t|
t.integer :facebook_user_id
t.integer :restaurant_id
t.boolean :recommend, :default => false
t.timestamps null: false
end
end
end
|
class AddPropertyReffToTenants < ActiveRecord::Migration
def change
add_reference :tenants, :property, index: true
end
end
|
require 'spec_helper'
describe PostsController do
describe 'index' do
context 'no posts whatsoever' do
before :each do
get :index
end
it 'is successful' do
expect(response).to be_success
end
it 'has an empty posts' do
expect(assigns(:published_posts)).to b... |
class AddInformedToDialogues < ActiveRecord::Migration
def change
add_column :dialogues, :informed, :boolean
end
end
|
# 単純ベイズ分類器
class NaiveBayesClassifier
def initialize(hash = {})
@features = hash[:features] || {}
@quantities = hash[:quantities] || {}
end
def to_hash
return {
:features => @features,
:quantities => @quantities,
}
end
def train(category, features)
features.each { |fe... |
class AddMetaioIdToPoi < ActiveRecord::Migration
def change
add_column :pois, :metaio_id, :string
end
end
|
class SetWindowsDefaultToZero < ActiveRecord::Migration
def change
change_column :visit_groups, :window_before, :integer, default: 0
change_column :visit_groups, :window_after, :integer, default: 0
end
end
|
class AuthToken
# Encode a hash in a json web token
def self.encode(payload, expiration = 1.month.from_now)
payload = payload.dup
payload[:exp] = expiration.to_i
JWT.encode(payload, Rails.application.secrets.secret_key_base)
end
# Decode a token and return the payload inside
# It will throw an er... |
require_relative '../bin/player'
require_relative '../bin/item'
require_relative '../bin/room'
require_relative '../bin/parser'
parser = Parser.new('../data/petite_cave.if')
items = parser.all_items
rooms = parser.all_rooms
describe Player do
let(:player) {Player.new("Nikki")}
it 'should have a name' do
expe... |
class AddChefIdToRecipes < ActiveRecord::Migration
def change
add_column :recipes, :chef_id, :integer #first one is the table we add to,
# second is the name and the third is the type
end
end
|
class Bookmark < ApplicationRecord
belongs_to :user
belongs_to :job
validates_uniqueness_of :user_id, scope: :job_id
end
|
require 'spec_helper'
require 'capybara/rails'
require 'capybara/rspec'
require 'selenium-webdriver'
require "database_cleaner"
# access session from capybara
require "rack_session_access/capybara"
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Chrome::Profile.new
Capybara::Selenium:... |
class Article < ActiveRecord::Base
def comments
Comment.where(article_id: id)
has_many :comments
end
end
|
# encoding: UTF-8
module WineDb
module Model
class Tavern < ActiveRecord::Base
belongs_to :winery, class_name: 'WineDb::Model::Winery', foreign_key: 'winery_id'
has_many :taggings, :as => :taggable, class_name: 'WorldDb::Model::Tagging'
has_many :tags, :through => :taggings, class_name: 'WorldDb::Model:... |
require 'rails_helper'
RSpec.describe Articles::FeedsController, type: :controller do
render_views
let(:user_1) { create(:user) }
let(:user_2) { create(:user) }
before { sign_in user_1 }
let!(:article_1) { create(:article, user: user_1) }
let!(:article_2) { create(:article, user: user_1) }
let!(:artic... |
class Importer::Importer
def initialize(parser)
@parser = parser
end
private
def attribution
@parser.attribution
end
def incidents_by_number(numbers)
by_number = Hash.new { |h,k| h[k] = Incident.new }
by_number.merge!(
Incident.where(incident_number: numbers).index_by(&:incident_numb... |
module Hemp
class RequestProcessor
attr_reader :request, :route
def initialize(request, route)
@request = request
@route = route
end
def rack_response
route ? process_request(route) : send_default_response
end
def process_request(route)
request = overwite_request_par... |
class NotesController < ApplicationController
def new
end
def create
@note = Note.new note_params
if @note.save
@username = @note.username
@note_id = @note.note_id
redirect_to note_path(@username,@note_id)
else
render template: "homes/index"
end
end
def show
@note... |
require 'spec_helper'
describe Boost do
let(:boost) { Boost.new(14) }
let(:twitter) { TwitterEngine.new }
let(:stock) { :AAPL }
let(:search_term) { "Apple" }
let(:search_term_2) { "iphone" }
let(:search_term_3) { "ipad" }
let(:search_term_4) { "macbook" }
let(:stock_2) { :GOOG }
let(:search_term_5)... |
require 'spec_helper'
describe ConsumptionProfile do
it "should let us make add a new one" do
consumption_profile = FactoryGirl.create(:consumption_profile)
consumption_profile.save.should be_true
end
it "should require a code" do
consumption_profile = FactoryGirl.build(:consumption_profile, code: ni... |
require 'rails_helper'
RSpec.describe Api::V2::MealsController do
after(:all) do
DatabaseCleaner.clean_with(:truncation)
end
describe "CREATE" do
before(:all) do
@restaurant = create(:restaurant)
end
context " Unauthorized" do
it "get status 401 due to unauthorized" do
get :cr... |
class ComparisonResultsController < ApplicationController
before_action :set_comparison_result, only: [:show, :edit, :update, :destroy]
# GET /comparison_results
# GET /comparison_results.json
def index
@comparison_results = ComparisonResult.all
end
# GET /comparison_results/1
# GET /comparison_resu... |
require 'chemistry/element'
Chemistry::Element.define "Ytterbium" do
symbol "Yb"
atomic_number 70
atomic_weight 173.04
melting_point '1097K'
end
|
class MultiFeePayment < Payment
#has many payments for single multi payment
has_many :finance_payments,:foreign_key=>"payment_id"
has_one :finance_transactions,:through=> :finance_payments
#to make finance transaction and payment entry
def self.create_multi_fees_transactions(params,hostname,identification... |
class CreateApps < ActiveRecord::Migration[5.0]
def change
create_table :apps do |t|
t.string :name
t.string :public_id
t.integer :owner_id
t.jsonb :config, default: {}
t.jsonb :public_data, default: {}
t.timestamps
end
add_index :apps, :public_id, unique: true
end
e... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Tikkie::Api::Clients::Payments do
subject(:client) { described_class.new(config) }
let(:config) { Tikkie::Api::Configuration.new(api_key: '12345', app_token: 'abcdef') }
describe '#list' do
it 'returns a list of payments' do
data = F... |
module Magick
class Image
def crop_resized(ncols, nrows, gravity=CenterGravity)
copy.crop_resized!(ncols, nrows, gravity)
end
def crop_resized!(ncols, nrows, gravity=CenterGravity)
if ncols != columns || nrows != rows
scale = [ncols/columns.to_f, nrows/rows.to_f].max
resiz... |
# encoding: utf-8
require "dynamoid/paperclip/version"
begin
require 'paperclip'
rescue LoadError
puts "Dynamoid::Paperclip requires that you install the Paperclip gem."
exit
end
begin
require 'dynamoid'
rescue LoadError
puts "Dynamoid::Paperclip requires that you install the Dynamoid gem."
exit
end
##
... |
class Book < ApplicationRecord
belongs_to :user, optional: true
belongs_to :condition
belongs_to :genre
has_one_attached :picture
# Scope methods for @books search & filter functionality
#
scope :search, ->(search) { where('name like ?', "%#{search}%") }
scope :condition_id, ->(cond... |
class MoneyArrivalFilesController < ApplicationController
before_action :set_money_arrival_file, only: [:show, :edit, :update, :destroy, :send_raw, :send_display]
before_action :set_business_data, only: [:new, :create]
# GET /money_arrival_files
# GET /money_arrival_files.json
def index
@money_arrival_fi... |
Rails.application.routes.draw do
root 'questions#index'
devise_for :users
resources :questions do
resources :answers, only: %i[create destroy update] do
put :accept, on: :member
end
end
end
|
class Notification < ActiveRecord::Base
belongs_to :client
belongs_to :lawyer
end
|
class AdminsController < ApplicationController
before_filter :auth_change, :only => [:change_password, :update_password]
before_filter :auth_super, :only => [:index, :edit, :update, :destroy]
before_filter :auth_new, :only => [:new, :create]
#su_admin only
def index
@admins = Admin.all
@page_t... |
module TubesHelper
def hidden_div_if(condition, attributes = {}, &block)
if condition
attributes["style"] = "display: none"
end
content_tag("div" , attributes, &block)
end
def operators
operators = [
["",""],
["equal", "="],
... |
array.index(value)
#returns what place in the index that value is in the array (0, 1, 2)
array(value_x - value_y).abs
#returns absolute value of the equation
## just like class "Car"
class Person
## all the below are attributes of "Car" or "Person"
attr_accessor :name, :age, :gender, :eye_color
#called wit... |
control "M-2.9" do
title "2.9 Ensure the default cgroup usage has been confirmed (Scored)"
desc "
The --cgroup-parent option allows you to set the default cgroup parent to
use for all the
containers. If there is no specific use case, this setting should be left
at its default.
System administrators typ... |
# frozen_string_literal: true
module Vedeu
# Provides methods to be used by {Vedeu::ApplicationView}.
#
module View
# Returns the current local time.
#
# @example
# time_now # => Mon 29 Jun 19:26
#
# @return [String]
def time_now
Time.now.strftime('%a %e %b %k:%M')
end
... |
class Clock
attr_accessor :hour, :minute
def initialize(hour, minute)
@hour = hour
@minute = minute
end
def self.at(hour, minute = 0)
wrap_around_hours = 0
if minute > 59
wrap_around_hours += minute / 60
minute %= 60
end
Clock.new(hour + wrap_around_hours, minute)
end
... |
class Note < ApplicationRecord
belongs_to :user
belongs_to :ed_pursuit
validates :title, presence: true
validates :content, presence: true
validates :ed_pursuit_id, presence: true
# scope :for_user, -> (userid) { where("user_id" == ?, userid)}
end |
require 'spec_helper'
describe StaticContent::ContentHelper do
before do
content = StaticContent::Content.new.tap do |sc|
sc.slug = :sidebar_text
sc.text = "Hi, this is dog"
end
StaticContent::Content.should_receive(:from_slug).with(options).and_return(content)
end
let(:options) do
[... |
# set ENV variables for testing
ENV["RAILS_ENV"] = "test"
require 'bundler/setup'
Bundler.setup
require 'simplecov'
SimpleCov.start
require File.expand_path("../../config/environment", __FILE__)
require "rspec/rails"
require "capybara/rspec"
require "capybara/rails"
require "webmock/rspec"
require "rack/test"
requir... |
class AddressCocoonsController < ApplicationController
before_action :set_address_cocoon, only: [:show, :edit, :update, :destroy]
# GET /address_cocoons
# GET /address_cocoons.json
def index
@address_cocoons = AddressCocoon.all
end
# GET /address_cocoons/1
# GET /address_cocoons/1.json
def show
... |
require 'test_helper'
class LogTest < ActiveSupport::TestCase
test "validate presence of required fields in Log" do
log = Log.new
log.save
assert log.invalid?
assert !log.errors[:severity].blank?, "Severity must be present for all logs"
assert !log.errors[:description].blank?, "Description must ... |
class CreateFeedback < ActiveRecord::Migration[5.2]
def change
create_table :feedbacks do |t|
t.text :message
t.integer :user_id
t.timestamps
end
end
end
|
class Relationship < ActiveRecord::Base
# Associations
belongs_to :kid
belongs_to :care_taker
end
|
require 'test/unit'
require 'de'
require 'de/sunspot_solr'
class DeSunspotSolrAndTest < Test::Unit::TestCase
include De::SunspotSolr
def test_constructor
assert_nothing_raised(De::Error::AbstractClassObjectCreationError) { And.new }
assert_nothing_raised(De::Error::AbstractClassObjectCreationError) { And.... |
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.references :speaker, null: false
t.references :school, null: false
t.date :date, null: false
t.boolean :approved, null: false, default: false
t.string :name
t.text :details
t.timestamps... |
# Really trivial convenience class, I was just sick of inconsistent logging
# output, but can't be bothered adding an external dependency.
#
# Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2013.
# License: The MIT License
# (See http://www.opensource.org/licenses/mit-license.php for details.)
module BM3
... |
require 'pry'
def sort_by_appearance(characters_to_sort, long_text)
letters_hash = {}
characters_to_sort.split('').each do |letter|
counter = 0
long_text.split('').each do |p_letter|
if letter == p_letter
counter += 1
end
end
letters_hash[letter] = counter
end
letters_hash =... |
require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context '新規登録できるとき' do
it 'nicknameとemail、passwordとpassword_confirmation、family_name、first_name、family_name_kana、first_name_kana、birth_dayが存在すれば登録できる' do
expect(... |
class InvitesController < ApplicationController
def index
#カテゴリー検索の実装
@invite_categories = InviteCategory.all
if params[:invite_category_id].present?
invite_category = InviteCategory.find(params[:invite_category_id].to_i)
@invites = invite_category.invites.order(id: "... |
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'portunes/version'
Gem::Specification.new do |gem|
gem.name = "portunes"
gem.version = Portunes::VERSION
gem.authors = ["Jon Gillies"]
gem.email = ["... |
class Person < ActiveRecord::Base
require 'csv'
require "open-uri"
# Associations
has_many :phone_numbers, as: :phonable, dependent: :destroy
has_many :addresses, as: :addressable, dependent: :destroy
has_many :dog_people, dependent: :destroy
has_many :dogs, through: :dog_people
#has_many :roles
#has... |
class RemoveColumnsFileProblem < ActiveRecord::Migration
def change
remove_column :problems, :problem_statement
remove_column :problems, :solution_file
remove_column :problems, :test_file
end
end
|
class Seller < ApplicationRecord
has_many :mobiles, through: :customer_mobiles
end
|
# frozen_string_literal: true
module TugoCommon
module ErrorHandler
class ServiceErrorHandlerResult
attr_reader :handler
def initialize(handler = nil)
@handler = handler
end
def handled?
@handler&.handled? || false
end
end
end
end
|
require 'rails_helper'
RSpec.describe Notifications::NotifyFollower do
include Rails.application.routes.url_helpers
describe '#notify' do
let(:interrelationship) { create(:interrelationship) }
subject { described_class.new(interrelationship) }
let(:receiver) { interrelationship.followed }
let(:tran... |
class FontEbh < Formula
version "1.0.0"
sha256 "6787471d7766a8be31f2e601620e402ff43bafd183d626a8df75767e91052af3"
url "https://exeterbookhand.com/EBH-v#{version}.zip"
desc "EBH"
desc "Exeter Book Hand"
desc "Vectorized font based on script in the Exeter Book"
homepage "https://exeterbookhand.com/"
def i... |
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :recording
has_many :webimages, dependent: :destroy
accepts_nested_attributes_for :webimages
end
|
module Rooms
class UsersController < ApplicationController
include RoomCommonMethods
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
def index
@users = @room.users
end
def new
end
def create
@user = User.find_by(email: ... |
module AuthenticationHelper
def login(options={})
@user = create :user, options.reverse_merge!(username: "bricker", password: "secret")
visit outpost.login_path
fill_in "username", with: @user.username
fill_in "password", with: "secret"
click_button "Submit"
end
end
|
class EmploymentStatusesController < ApplicationController
def index
@employment_status = EmploymentStatus.all
respond_to do |format|
#format.html # index.html.erb
format.json { render json: @employment_status }
end
end
# POST /people_employment_statuses
# POST /people_employment_stat... |
require_relative 'build.rb'
class Platform
SUPPORTED_ON = Hash.new { |h, k| h[k] = [] }
SUPPORTED_ON.update({ darwin: ['darwin-x86_64'], linux: ['linux-x86_64', 'windows-x86_64', 'windows'] })
NAMES = SUPPORTED_ON.values.flatten
MACOSX_VERSION_MIN = '10.6'
TOOLCHAIN = { 'darwin/darwin' => { tool_path: ... |
require 'spec_helper'
describe ColorFamily do
let(:color_family) { FactoryGirl.create(:color_family) }
subject { color_family }
describe "validations" do
it { should be_an_instance_of(ColorFamily) }
it { should be_valid }
it { should validate_presence_of(:name) }
it { should validate_uniqueness... |
class UsersController < ApplicationController
def show
@my_events = UserEvent.where(user_id: current_user.id)
end
end
|
class Brand < ActiveRecord::Base
has_many :products
before_create :init_value
has_attached_file :image_logo, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
validates_attachment_content_type :image_logo, :content_type => /\Aimage\/.*\Z/
private
def i... |
class SongList < ApplicationRecord
belongs_to :user
has_many :song_list_songs
has_many :songs, through: :song_list_songs
end
|
class Article < ActiveRecord::Base
has_attached_file :main_image, styles: {:thumb => ''}
validates_attachment_content_type :main_image, :content_type => /\Aimage\/.*\Z/
crop_attached_file :main_image, :aspect => "11:6"
has_many :comments
end
|
class Track < ActiveRecord::Base
belongs_to :account
belongs_to :candidate
belongs_to :mission
belongs_to :funnel
belongs_to :user
belongs_to :interview
belongs_to :evaluation
validates_inclusion_of :event_title, :in => Constants::TRACKS_EVENTS, :allow_nil => true
validates_presence_of :event_date
... |
class Deck
SUITS = %w[♠ ♥ ♦ ♣].freeze
NAMES = %w[2 3 4 5 6 7 8 9 10 Jack Queen King Ace].freeze
VALUES = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 1].freeze
attr_accessor :cards
def initialize
@cards = []
create_deck
end
def shuffle!
@cards.shuffle!
end
private
def create_deck
SU... |
# Author:: Philip Oliva (<philoliva8@gmail.com>)
# Cookbook:: zabbix-agent
# Recipe:: install_skip
#
# Apache 2.0
log 'Skip the installation of zabbix agent' do
level :info
end
|
require "rails_helper"
RSpec.describe "Sensors" do
describe "CRUD Requests" do
before :each do
@user = create :user
@garden = create(:garden)
@user_garden = create(:user_garden, user_id: @user.id, garden_id: @garden.id)
@moisture_sensor = create(:sensor, :moisture_sensor, garden_id: @gard... |
require 'rails_helper'
RSpec.describe User, type: :model do
it "名前、メール、パスワードがあれば有効な状態であること" do
user = FactoryBot.build(:user)
expect(user).to be_valid
end
it "名前がなければ無効な状態であること" do
user = FactoryBot.build(:user, name: nil)
user.valid?
expect(user.errors[:name]).to include("を入力してください")
... |
require 'rspec'
require 'deck'
require 'card'
describe Deck do
subject(:deck) { Deck.new }
let(:random_cards) { [Card.new(:hearts, :king), Card.new(:spades, :queen)] }
describe "#initialize" do
let(:random_deck) { Deck.new(random_cards) }
it "initializes with 52 playing cards if nothing is passed" do
... |
namespace :mediabumper do
desc "Starts the indexing of all repositories"
task :index => :environment do
Repository.find(:all).each do |r|
Mediabumper::Indexer.new(r).start
end
# FIXME: there should be a faster way :)
MediaFile.find(:all).each do |mf|
mf.destroy unless File.exists? mf.pa... |
# frozen_string_literal: true
require_relative 'player'
require_relative 'card'
require_relative 'deck'
require_relative 'commands/pile'
module Brigitte
#
# A Game has maximum 4 players (+active_players+)
# and can be started with +play+ method when all players are ready.
class Game
attr_accessor :current... |
class V1::Dashboards::Teacher::ConregsController < V1::BaseController
include V1::MessageHelper
def index
load_current_regs
regs = ActiveModel::ArraySerializer.new(@regs, each_serializer: ::Teacher::ContestRegSerializer)
render json: regs
end
def create
@con = Contest::Reg.find_or_create_by(un... |
class StatisticsDisplay
include Observer, DisplayElement
attr_reader :num_readings, :temp_sum, :max_temp, :min_temp
def initialize(weather_data)
@max_temp = 0.0
@min_temp = 200
@temp_sum = 0.0
@num_readings = 0
@weather_data = weather_data
weather_data.register_observer(self)
end
def... |
require 'pry'
module MergeSort
def merge arr1, arr2
merged_arr = Array.new
# collect smaller element of 2 arrays until one of array become empty
while 0 < arr1.length && 0 < arr2.length do
if arr1[0] > arr2[0]
merged_arr.push arr2.delete_at(0)
else
merged_arr.push arr1.delete_... |
require "erb"
# require "jcode"
require "uri"
class String
SANITIZE_HELPER = Class.new { include ActionView::Helpers::SanitizeHelper }.new
LAME_CHARS = [0x200c, 0x200d, 0x200e, 0x200f, 0x2028, 0x2029, 0x202a, 0x202b, 0x202c, 0x202d, 0x202e, 0x206a, 0x206b, 0x206c, 0x206d, 0x206e, 0x206f, 0xfeff].pack("U*")
def ... |
# -*- encoding : utf-8 -*-
# The model of the OAuth nonce resource.
#
# Simple store of nonces. The OAuth Spec requires that any given pair of nonce and timestamps are unique.
# Thus you can use the same nonce with a different timestamp and viceversa.
#
# This code is part of the Stoffi Music Player Project.
# Visit ou... |
class Dog
require 'pry'
attr_accessor :name, :breed
attr_reader :id
def initialize(id:nil, name:, breed:)
self.breed = breed
self.name = name
@id = id
end
def self.create_table
sql = <<-SQL
CREATE TABLE IF NOT EXISTS dogs (
id INTEGER PRIMNARY KEY,
name T... |
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: "Dashboard"
content title: "All Testing Sites" do
host_id = params[:host_id].presence
all_lines = sum_all_lines(host_id)
all_patients = sum_all_patients(host_id)
avg_time = calculate_average_times(host_id)
render partial: "grap... |
require 'rails_helper'
RSpec.describe RegistrationService do
before do
@password = "Qwerty1$"
end
context "Registration Service Vlidation" do
it "should register new user succesfully" do
registration_params = {
first_name: Faker::Name.first_name,
last_name: Faker::Name.last_nam... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.