text stringlengths 10 2.61M |
|---|
# == Schema Information
#
# Table name: question_attempts
#
# id :integer not null, primary key
# quiz_attempt_id :integer
# question_id :integer
# data :json
# created_at :datetime not null
# updated_at :datetime not null
# type :string
#... |
class AddImporterChecksumToUser < ActiveRecord::Migration
def change
add_column :users, :importer_checksum, :string
end
end
|
# coding: utf-8
module Preflight
module Rules
# Every page should have a CropBox that matches the MediaBox
#
# Arguments: none
#
# Usage:
#
# class MyPreflight
# include Preflight::Profile
#
# rule Preflight::Rules::CropboxMatchesMediabox
# end
#
class... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/8"
config.vm.hostname = "iam.kites.rocks"
config.vm.provision "shell", inline: <<-SHELL
dnf module install -y idm:DL1
# dnf install -y @idm:DL1
# dnf module install -y idm:client
dnf install -y ... |
class Country < ActiveRecord::Base
belongs_to :continent
has_many :regions
has_many :cities
attr_accessible :dial_code, :name, :short_name
end
|
$LOAD_PATH.unshift File.join(__dir__, "bogus_twitter_pictures_ingestor")
require "twitter_client"
require "twitter_ingestion_task"
require "data_exporter"
require "data_export_task"
require "forwardable"
# Ingest data about bogus twitter pictures
class BogusTwitterPicturesIngestor
extend Forwardable
def_delegato... |
class RenameTrack < ActiveRecord::Migration
def self.up
rename_column :display_infos, :song_id, :track_id
rename_column :play_infos, :song_id, :track_id
end
def self.down
rename_column :display_infos, :track_id, :song_id
rename_column :play_infos, :track_id, :song_id
end
end
|
class Asiento
include ActiveModel::Validations
def initialize(concepto)
@concepto = concepto
end
def importe
return @concepto.valor if @concepto.respond_to?(:valor)
return @concepto.importe if @concepto.respond_to?(:importe)
end
def fecha
@concepto.respond_to?(:fecha_de_vencimiento) ? @co... |
require 'formula'
class RockRuntimeNode08 < Formula
homepage 'http://nodejs.org/'
url 'http://nodejs.org/dist/v0.8.26/node-v0.8.26.tar.gz'
sha1 '2ec960bcc8cd38da271f83c1b2007c12da5153b3'
keg_only 'rock'
def patches
DATA
end
def install
system './configure', "--prefix=#{prefix}"
system 'mak... |
# encoding: binary
# frozen_string_literal: true
require "rbnacl/sodium"
module RbNaCl
module Sodium
# libsodium version API
module Version
MINIMUM_LIBSODIUM_VERSION = [0, 4, 3].freeze
MINIMUM_LIBSODIUM_VERSION_FOR_ARGON2 = [1, 0, 9].freeze
MINIMUM_LIBSODIUM_VERSION_FOR_ARGON2ID = [1, 0, 1... |
class Logistics::MoneyController < ApplicationController
before_filter :authenticate_user!, :only => [:index, :new, :create, :edit, :update ]
protect_from_forgery with: :null_session, :only => [:destroy, :delete]
def index
flash[:error] = nil
@moneys = Money.all
@ex = ExchangeOfRate.all
render ... |
# If nodejs is enabled, install Bower?
execute "Installing Bower via NPM" do
cwd '/home/vagrant/app'
user 'root'
command '/usr/local/bin/npm install -g bower'
action :run
end
|
class RemoveSellerReferenceFromBids < ActiveRecord::Migration
def change
remove_column :bids, :seller_id, :reference
end
end
|
# Map a row from the CSV file to easy to use properties
class MovementRow
attr_reader :row
def initialize(row)
@row = row
end
def legacy_account
row["Rekening tegenpartij"] || row["Compte partie adverse"]
end
def number
row["Omzetnummer"] || row["Numéro de mouvement"]
end
def date
ro... |
require "spec_helper"
describe AdaptivePayments::PayResponse do
it_behaves_like "a ResponseEnvelope"
it_behaves_like "a FaultMessage"
let(:response) do
AdaptivePayments::PayResponse.from_json(
{
:payKey => "ABCD-1234",
:paymentExecStatus => "COMPLETED",
:defaultFundingPlan => ... |
require "yajl"
# Parse Big JSON
# https://stackoverflow.com/questions/53476973/parse-a-massive-json-array-of-hashes
class PBJ
attr_reader :json_string, :json
def initialize(file)
@json_string = File.read(file)
end
def parse
parser = Yajl::Parser.new(symbolize_keys: false)
@json = parser.parse(jso... |
module DateUtils
class << self
def months_between( date1=Time.now, date2=Time.now )
date1 ||= Time.now
date2 ||= Time.now
if date1 > date2
recent_date = date1.to_date
past_date = date2.to_date
else
recent_date = date2.to_date
past_date = date1.to_date
... |
require 'fileutils'
require 'thor'
module PokeyRunner
module Generators
class Base < ::Thor
def self.source_root(arg)
File.dirname(__FILE__)
end
# File railties/lib/rails_generator/commands.rb, line 298
def template(relative_source, relative_destination, template_options = {})
... |
FactoryGirl.define do
factory :survivor do
name 'Survivor Test'
age '43'
gender 'M'
last_location ({latitude: '89809809809', longitude: '-88983982100'})
infection_count 0
factory :survivor_1 do
name 'Jonh Smith'
end
factory :survivor_2 do
name 'Mary Adams'
age '21'
gender 'F'
last_loca... |
require "spec_helper"
RSpec.describe ActiveRecordFiles::Core do
it 'set root folder' do
ActiveRecordFiles::Base.configurations = {root: '~/spec/dummy'}
expect(ActiveRecordFiles::Base.configurations[:root]).to eq('~/spec/dummy')
end
it 'rise error if root folder not defined' do
ActiveRecordFiles::Ba... |
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
root "payments#index"
resources :payments do
member do
get :payment_pdf
get :next_step
get :thankyou
get :resend
end
end
resources :signatures, only: [:new, :create]... |
namespace :scheduler do
desc "Send dues due email to users with scheduler"
task send_dues_email: :environment do
puts "Sending emails..."
User.all.each do |user|
if user.paid_date
@due_date = user.paid_date.to_date + 1.month
@current_date = Date.today
if ((@due_date - @current_date == 5) && (u... |
# == Schema Information
# Schema version: 20110529234238
#
# Table name: places
#
# id :integer not null, primary key
# address :string(255)
# phone :string(255)
# longitude :float
# latitude :float
# startTime :datetime
# name :string(255)
# url ... |
Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "hashicorp/bionic64"
# Configuração da guest machine
config.vm.provider "virtualbox" do |vb|
vb.memory = 1024
vb.cpus = 1
end
... |
require 'rails_helper'
RSpec.describe Org, type: :model do
it "should require a slug and name when creating an org" do
org = Org.create
expect(org.id).to be_nil
# slug auto-created if there's a name
#org = Org.create name: 'Foo Bar'
#expect(org.id).to be_nil
org = Org.create name: 'Foo Bar', s... |
class ListsController < ApplicationController
def index
@user = current_user
end
def show
@user = current_user
@list = List.find(params[:id])
@item = Item.new
end
def new
@list = List.new
end
def create
@list = current_user.lists.build(params.require(:list).permit(:title))
i... |
#encoding: UTF-8
# == Schema Information
#
# Table name: monsters
#
# id :integer not null, primary key
# name :string(40)
# skill :integer
# energy :integer
# chapter_id :integer
# created_at :datetime
# updated_at :datetime
#
FactoryGirl.define do
factory :monster do
nam... |
class Evento < ActiveRecord::Base
belongs_to :cliente
has_many :equipos
has_many :clientes, :through => :equipos
validates_presence_of :descripcion, :premio, :cantidad_equipos
end
|
class TicketsController < ApplicationController
before_filter :zendesk
def zendesk
set_response_headers
check_email(@email)
set_client
@tickets = @ticket_client.get_tickets(@email)
if @tickets.kind_of? Array
set_params
update_visitor
else
response.status = 204
... |
module EmbeddableContent
class RecordNodeProcessor < NodeProcessor
delegate :title, to: :record
def record_id
@record_id ||= tag_match_data[:id] if tag_references_record?
end
def record_model
@record_model ||= tag_match_data[:model].classify.constantize if
tag_references_record?
... |
require './lib/oystercard.rb'
describe OysterCard do
let(:card) { OysterCard.new }
let(:aldgate) { Station.new('Aldgate', 1) }
let(:monument) { Station.new('Monument', 1) }
it 'new card has balance of zero' do
expect(card.balance).to eq 0
end
it 'tops up card with amount' do
expect(card.top_up(20... |
require 'rails_helper'
describe CmsBlog do
setup_account
it 'write more tests'
describe 'slug handling' do
#------------------------------------------------------------------------------
it 'allows the same blog slug per account (scoped to account)' do
blog1 = create(:blog)
Account.curre... |
FactoryGirl.define do
factory :country, class: Hash do
initialize_with {
{
'id' => '1',
'code' => 'US',
'currency' => '$',
'region_id' => 'US',
'name' => 'United States'
}
}
end
end
|
class Event < ActiveRecord::Base
belongs_to :owner
belongs_to :client
validates :owner_id, :start, :estimated_time, presence: true
validates :start, uniqueness: {scope: :client}
def end
start + estimated_time.seconds_since_midnight
end
def title
"#{name} (#{email_or_mob})"
end
end
|
module D4P1
class D4P1
def run(input)
required_fields = ["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]
valid_count = 0
parsed_data = {}
input.each do |line|
if line.chomp.empty?
if (required_fields - parsed_data.keys).count == 0
valid_count += 1
e... |
class Admin::OrganizationKindsController < Admin::ApplicationController
before_filter :setup_default_filter, only: :index
def index
@search = OrganizationKind.search(params[:q])
search_result = @search.result(distinct: true)
@organization_kinds = show_all? ? search_result : search_result.page(params[... |
class Loan < ActiveRecord::Base
validates :borrower_name,presence: true,length: {maximum: 25}
validates :loan_number,presence: true,uniqueness: true, numericality:{ only_integer: true,greater_than: 0}
validates :principal,presence: true,numericality: { only_integer: true,greater_than: 0,less_than: 500000 }
v... |
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def test_should_have_a_valid_factory
assert FactoryGirl.build(:user).valid?
end
def test_should_have_a_unique_email_address
user = FactoryGirl.create(:user)
assert !FactoryGirl.build(:user, :email => user.email).valid?
assert Fa... |
# Copyright © 2011-2019 MUSC Foundation for Research Development
# All rights reserved.
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this list... |
# frozen_string_literal: true
require 'net/http'
module EtAzureInsights
# A drop in replacement for ApplicationInsights::TelemetryClient
# but supports extra features.
class Client
def self.client
Thread.current[:azure_insights_global_client] ||= new
end
def initialize(config: EtAzureInsights.... |
require 'pry'
require 'minitest/autorun'
require 'minitest/pride'
require './matcher'
class SnailTest < Minitest::Test
def setup
@good = "[123]{a(b)}"
end
def test_it_exists
assert_instance_of Matcher, Matcher.new(@good)
bad = "[123{a(b)}"
assert_instance_of Matcher, Matcher.new(bad)
e... |
class MessagesAddPrivate < ActiveRecord::Migration
def self.up
add_column :messages, :private, :boolean, :default => false
end
def self.down
remove_column :messages, :private
end
end
|
require 'buildr/git_auto_version'
require 'buildr/gpg'
require 'buildr/gwt'
Buildr::MavenCentral.define_publish_tasks(:profile_name => 'org.realityforge', :username => 'realityforge')
desc 'Arez-TestNG: Arez utilities for writing TestNG tests'
define 'arez-testng' do
project.group = 'org.realityforge.arez.testng'
... |
module Api::V3::LogApiUsageByUsers
extend ActiveSupport::Concern
included do
before_action :log_api_usage
def log_api_usage
Loggers::ApiUsageLogger.tagged(params[:controller], params[:action], current_user&.id || "no-user-id") { Loggers::ApiUsageLogger.info(1) }
end
end
end
|
require 'ostruct'
require 'rom-csv'
setup = ROM.setup(:csv, METRICS)
setup.relation(:metrics) do
def by_metric_id(metric_id)
restrict(metric_id: metric_id)
end
def by_start_date(start_date)
restrict(start_date: start_date)
end
def by_time_range_length(time_range_length)
restrict(time_range_leng... |
class RenameOrganizationToOrga < ActiveRecord::Migration
def change
rename_table :organizations, :orgas
rename_table :organization_category_relations, :orga_category_relations
rename_column :roles, :organization_id, :orga_id
rename_column :orga_category_relations, :organization_id, :orga_id
end
end... |
require 'rails_helper'
#include ActionView::Helpers::UrlHelper
#config.include Capybara::DSL
RSpec.feature "Viewing all tournaments" do
before do
visit '/'
click_link "Sign Up"
fill_in "Email", with: "rspec@user.no"
fill_in "Password", with: "rspec1234"
fill_in "Password confirmation", with: "rs... |
# == Schema Information
#
# Table name: profiles
#
# id :bigint not null, primary key
# user_id :integer
# name :string(255)
# birthday :date
# address :string(255)
# education :string(255)
# occupation :string(255)
# bref_introdu... |
require 'rails_helper'
RSpec.describe Item, type: :model do
before { @item = FactoryBot.build(:item) }
describe '商品の新規登録' do
context '新規登録がうまくいくとき' do
it '各項目が存在すれば登録できる' do
expect(@item).to be_valid
end
end
context '新規登録がうまくいかないとき' do
it 'nameが空だと登録できない' do
@item.na... |
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base
include MailerHelper
helper :application
default from: noreply_address
def mail(headers = {}, &)
headers['X-Title'] = @title if @title
headers['X-User-Email'] = @user_email if @user_email
headers['X-Message-Timestamp'] = @... |
class VotesController < ApplicationController
before_action :logged_in_user, only: [:create, :destroy, :index, :update_like, :update_dislike]
def create
@micropost = Micropost.find(params[:micropost_id])
@vote = @micropost.votes.build(vote_params)
if @vote.save
respond_to do |format|
format... |
# encoding: UTF-8
module LinkedBus::Welcome
SM_QUOTES= [
"My name is Sherlock Holmes. It is my business to know what other people don't know.",
"You know my methods, Watson.",
"The name is Sherlock Holmes and the address is 221B Baker Street.",
"The lowest and vilest alleys in London do not present... |
module Hippo::Segments
class IEA < Base
segment_identifier 'IEA'
field :name => 'NumberOfIncludedFunctionalGroups',
:datatype => :alpha_numeric,
:minimum => 1,
:maximum => 5,
:required => false
field :name => 'InterchangeControlNumber',
... |
module IdentitiesHelper
def display_avatar(avatar, url)
options = {:class => "img-responsive", :target => "_blank"}
size = "_full.jpg"
#size = "_medium.jpg"
if avatar.present? && (avatar.include? "steam")
avatar = avatar.gsub(".jpg", size)
end
if avatar.present? && url.present?
s... |
require 'habitica_client/api_base'
class HabiticaClient
# The authed user.
class User < HabiticaClient::ApiBase
endpoint '/user/'
require 'habitica_client/user/stats'
def stats
@stats ||= Stats.new(data['stats'])
end
end
end
|
require 'yaml'
require 'cucumber/rake/task'
ENV['capybara'] = 'true'
ENV['settings'] = File.open("#{File.dirname(__FILE__)}\\settings.yml").read
# Extract environments from Rake file
environments = []
YAML::load(ENV['settings']).each do |key,value|
environments.push key.to_s
end
# Set up dynamic tasks
tasks = {
"... |
# === COPYRIGHT:
# Copyright (c) Jason Adam Young
# === LICENSE:
# see LICENSE file
module TeamsHelper
def display_gb(gb)
if(gb == 0.0)
'-'
elsif((gb - 0.5) == gb.to_i)
"#{gb.to_i} ½"
else
"#{gb.to_i}"
end
end
def display_wl(wl)
if(wl.is_a?(Array))
(wins,losses) = wl... |
#!/usr/bin/env ruby
times = Hash.new(0)
count = Hash.new(0)
REGEX = /\((\d+)\): JSC_EXEC_TIME: (\d+\.\d+)/
ARGV.each do |filename|
f = File.open(filename)
pid = File.basename(filename)
while a = f.gets
matches = a.match(REGEX)
next unless matches
time = matches[2].to_f
times[pid] += time
cou... |
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... |
require 'rails_helper'
RSpec.describe Movie do
describe "relationships"do
it{should belong_to :studio}
it{should have_many :movie_actors}
it{should have_many(:actors).through(:movie_actors)}
end
before :each do
@studio1 = Studio.create(name: "studio01", location: "location01")
@movie01 = @st... |
#!/usr/bin/ruby
# Class to encapsulate creation of GERALD configuration file
class BuildGERALDConfig
def initialize(lanes, refPath, numCycles, isPaired, output, seqType, mapAlgo)
@lanesToAnalyze = lanes
@referencePath = refPath
@numCycles = numCycles
@paired = isPaired
@fcVersion ... |
# frozen_string_literal: true
module Decidim
module Participations
# Custom helpers, scoped to the participations engine.
#
module ApplicationHelper
include Decidim::Comments::CommentsHelper
include PaginateHelper
include ParticipationVotesHelper
include Decidim::MapHelper
i... |
# 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 Guest < ActiveRecord::Base
has_many :guest_assignments
has_many :welcomers, through: :guest_assignments
has_many :community_applicants
has_many :communities, through: :community_applicants
end
|
# frozen_string_literal: true
class ShotType < ApplicationRecord
belongs_to :sport
has_many :scores
end
|
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... |
module Queries
class FetchEmoji < Queries::BaseQuery
type [Types::EmojifyType], null: false
def resolve
Emoji.all.order(created_at: :desc)
end
end
end
|
class StudentsController < ApplicationController
before_action :set_student, only: [:first_name, :last_name, :email, :dojo_id]
# =============================
# GET Request - Renders [.html]
# =============================
def new
@dojos = Dojo.all
@student = Student.new
@this_dojo = Dojo.find(p... |
class ApplicationController < ActionController::Base
helper_method :user_signed_in?, :current_user
def user_signed_in?
current_user.present?
end
def current_user
@current_user ||= User.find_by(id: session[:user_id]) if session[:user_id]
end
def require_logged_user
redir... |
class MeetingsController < ApplicationController
def index
@meetings = policy_scope(Meeting)
end
def create
@meeting = Meeting.new(meeting_params)
@meeting.mentoree_id = current_user.id
authorize @meeting
if @meeting.save
redirect_to my_dashboard_path
else
render :new
end
... |
require 'spec_helper'
describe "Editing todo items" do
let!(:todo) { Todo.create(title: "Groceries", description: "Grocery list.") }
left!(:todo_item) { todo.todo_items.create(content: "Milk") }
it "is successful when marking a single item complete" do
expect(todo_item.completed_at).to be_nil
visit_todo_list t... |
require "rails_helper"
RSpec.describe TotalPresenter do
describe "#value" do
it "returns a currency formatted string" do
expect(TotalPresenter.new(BigDecimal("4321.1")).value).to eq("£4,321.10")
end
end
end
|
class ApplicationMailer < ActionMailer::Base
default from: 'kevin@kevinbudd.com'
layout 'mailer'
end
|
#!/bin/env ruby
# encoding: utf-8
require "prawn"
require "prawn/measurement_extensions"
def cover
@pdf.font "res/Dosis-Regular.ttf"
@pdf.fill_color = "80e2ff"
@pdf.fill_rectangle [0.mm, 287.mm], 200.mm, 287.mm
@pdf.fill_color = "000000"
@pdf.bounding_box [15.mm,250.mm], :width => 150.mm, :he... |
#!/usr/bin/env ruby
require "uri"
require "sinatra"
require "haml"
require "erb"
require "maxminddb"
require_relative "visit"
require_relative "visit_store_mongo"
require_relative "config_from_env"
require_relative "config_from_mongo"
# Freedjit is a widget that can be added to a blogspot page layout.
# It logs vis... |
require "test/unit"
def smallest_goal_difference(days)
min_day = days.min { |a, b| (a["For"] - a["Against"]).abs <=> (b["For"] - b["Against"]).abs }
min_day["Name"]
end
def load_football(path)
padded_lines = File.open(path).map { |line| '%-60.60s' % line }
filtered_lines = padded_lines.select { |line| line... |
class AddColumnShortAddressToCompanies < ActiveRecord::Migration
def change
add_column :companies, :short_address, :string
end
end
|
class CreateProjectFolders < ActiveRecord::Migration
def self.up
create_table :project_folders do |t|
t.column :name, :string
t.column :project_id, :integer
t.column :parent_id, :integer
t.column :lft, :integer
t.column :rgt, :integer
t.column :created_at, :timestamp
end
... |
require "rails_helper"
describe Sentence, type: :model do
it { should belong_to :paragraph }
it { should have_valid(:content).when("My favorite penguin is the rock hopper") }
it { should_not have_valid(:content).when(nil) }
end
|
class AddLastPolledAtToFeeds < ActiveRecord::Migration[5.1]
def change
add_column :feeds, :last_polled_at, :datetime
end
end
|
class AddTypeToAlbums < ActiveRecord::Migration
def change
add_column :albums, :record_type, :string, null: false
end
end
|
#coding : utf-8
require 'digest'
require 'fileutils'
require 'json'
#
# 资源相关的rake任务
#
namespace :resources do
#
# 加密resources文件
#
root = GGA.root
desc '加密resources文件'
task(:encode_resource_files) do
system("cd #{root}/data;for f in `find . -type f`; do cp $f . > /dev/null 2>&1 ;done;")
system("rm -... |
class BloodPressureExportService
require "csv"
include ActionView::Helpers::NumberHelper
include DashboardHelper
attr_reader :start_period, :end_period, :facilities, :data_for_facility, :stats_by_size, :display_sizes
FACILITY_SIZES = %w[large medium small community]
DATA_TYPES = [:controlled_patients_rate... |
class CreateProviders < ActiveRecord::Migration[5.1]
def change
create_table :authentication_methods do |t|
t.string :provider, null: false
t.string :uid, null: false
t.string :token
t.string :secret
t.boolean :expires
t.datetime :expires_at
t.belongs_to :user, null: fals... |
class User < ApplicationRecord
has_secure_password
validates :name, presence: true
validates :email, presence: true, format: { with: /\A[^@\s]+@[^@\s]+\z/ }
validates :password, length: { minimum: 5 }, if: :password_required?
def enforce_password_validation
@enforce_password_validation = true
end
p... |
# -*- encoding : utf-8 -*-
class Post < ActiveRecord::Base
belongs_to :user
belongs_to :topic,touch: true
attr_accessible :body
validates :user_id, presence:true
validates :body,presence: true,length:{maximum: 2000}
validates :topic_id,presence: true
def edit?(current_user)
current_user && (current_us... |
module AirMonitor::Error
def self.http_status_for(error)
error.code
end
end
|
class ProfilesController < ApplicationController
def show
# Service object
@profile = Profile.new(current_user)
end
end |
module Clot
module TagHelper
def split_params(params)
params.split(",").map(&:strip)
end
def resolve_value(value, context)
case value
when Liquid::Drop then
value.source
when /^([\[])(.*)([\]])$/ then
array = $2.split " "; array.map { |item| resolve_value i... |
class Location
attr_reader :city
@@all = []
def initialize(city)
@city = city
@@all << self
end
def self.all
return @@all
end
def self.least_clients
all.min_by { |location| Appointment.by_location(location).length }
end
end |
require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = 'rails-settings'
gem.summary = 'A nice little settings plugin for Rails'
gem.email = 'pnomolos@gmail.com'
gem.homepage = 'http://github.com/pnomolos/rails-settings'
gem.authors = ['Philip Schalm', '... |
class SignUpPage < BasePage
def field_set(name, value)
name.downcase!
common_name="user[#{name}]"
$browser.text_field(:name, common_name).set(value)
end
end |
# http://www.mudynamics.com
# http://labs.mudynamics.com
# http://www.pcapr.net
require 'thread'
require 'net/http'
require 'uri'
module PcaprLocal
class Xtractr
class XtractrError < StandardError; end
EXE_PATH = File.join(ROOT, 'lib/exe/xtractr')
def initialize config
@xtractr_path = EXE_PA... |
# coding: utf-8
# Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
# License: New BSD License
$KCODE = "u"
require "securerandom"
require "fileutils"
class Session
STORE_PATH = "data/session.marshal"
def self.get(id)
session = @sessions[id]
session.touch() if session
return s... |
require_relative "../spec_helper.rb"
require_relative "../../components.rb"
describe Strip do
context "\n - When Stripping an array of elements containing X number of matching elements" do
it "Removes the items matching the ignore list from a Hash" do
ignore_key = [/delete/]
ignore_list = [/git/,/\.... |
# frozen_string_literal: true
module MachineLearningWorkbench::NeuralNetwork
# Recurrent Neural Network
class Recurrent < Base
# Calculate the size of each row in a layer's weight matrix.
# Each row holds the inputs for the next level: previous level's
# activations (or inputs), this level's last acti... |
class StoreService
class << self
include ApiClientRequests
def build(resp, attrs = {})
json = resp.respond_to?(:body) ? resp.body : resp
if json.is_a? Array
json.map do |store|
store = Store.new(store)
attrs.each do |key, value|
store.send("#{key}=", value)... |
#### Number of vagrant boxes to create
INSTANCES = 2
#### Hostname specific information
HOSTNAME_PREFIX = "mms-automation-"
HOSTNAME_SUFFIX = ".vbox.vagrant"
USE_DHCP = false
#### Following IP related setting is useful only if USE_DHCP = false
IP_ADDRESS_PREFIX = "192.168.20."
IP_SUFFIX_START = 2
#### MMS Automati... |
class AddActiveToSections < ActiveRecord::Migration[5.0]
def change
add_column :sections, :active, :boolean
end
end
|
#モジュールを学習する
module Loggable
# private
def log(text)
puts "[LOG]#{text}"
end
end
class Product
extend Loggable
def self.create_products(names)
log 'create_products is called.'
end
# include Loggable
# def title
# log 'title is called.'
# 'A great movie'
# end
end
class User
include Loggable
def na... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.