text stringlengths 10 2.61M |
|---|
class Bear
attr_accessor :name, :type, :tummy
def initialize(name, type, tummy )
@name = name
@type = type
@tummy = tummy
end
def bear_roar
text = "I am a big scary #{type} bear"
return text
end
def bear_eaten(fish)
if fish.length > 0
fish_name = fish.pop()
fish_name = f... |
class Category
include Mongoid::Document
field :libelle_category
has_many :requests
has_many :proaccounts
end
|
require 'simple_spec_helper'
describe Lolita::Support::Formatter do
let(:klass){Lolita::Support::Formatter}
context "create new" do
it "should accept value as format" do
formatter=klass.new("%Y-%m")
formatter.format.should == "%Y-%m"
end
it "should accept block" do
formatter=klass.... |
class LikesController < ApplicationController
before_action :set_preschool
def create
@like = current_user.likes.create(preschool_id: params[:preschool_id])
@like.save
@user = User.find(@like.user_id)
html = render_to_string layout: false
render json: { like: @like, user: @user, html: html }
e... |
def filter(num_arr, **kwargs)
min = kwargs[:min]
max = kwargs[:max]
odd = kwargs[:odd]
even = kwargs[:even]
scale = kwargs[:scale]
index = 0
while index < num_arr.length
num = num_arr[index]
index = index + 1
next unless (min.nil? || num >= min)
next unless (max.nil? || num <= max)
next unless (odd... |
name 'monitoring'
maintainer 'Nick Charlton'
maintainer_email 'nick@nickcharlton.net'
license 'MIT'
description 'An opinionated monitoring cookbook using collectd and Librato.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'
depends 'col... |
require File.expand_path('../helper', __FILE__)
module Sawyer
class SchemaTest < TestCase
def setup
@schema = Sawyer::Schema.read FakeAgent.new,
IO.read(File.expand_path("../../example/user.schema.json", __FILE__))
end
def test_parses_properties
assert_equal 'integer', @schema.proper... |
control "M-2.3" do
title "2.3 Ensure Docker is allowed to make changes to iptables (Scored)"
desc "
Iptables are used to set up, maintain, and inspect the tables of IP packet
filter rules in the
Linux kernel. Allow the Docker daemon to make changes to the iptables.
Docker will never make changes to you... |
class CreateSalas < ActiveRecord::Migration
def change
create_table :salas do |t|
t.string :name
t.integer :capacidad
t.text :ubicacion
t.string :responsable
t.boolean :windows
t.boolean :linux
t.boolean :video_beam
t.timestamps null: false
end
end
end
|
require 'redis'
require 'bloomfilter-rb'
require 'digest/sha1'
require 'fast-filter/engine'
module FastFilter
class BloomEngine < Engine
attr_accessor :bloom_connections
# See: http://www.igvita.com/2008/12/27/scalable-datasets-bloom-filters-in-ruby/
# This default filter size assumes a 100M key si... |
class SalesFact < ActiveWarehouse::Fact
aggregate :qty, :label => "Units Sold"
aggregate :sale_price, :label => "Revenue"
dimension :date, :foreign_key => 'date_id', :class_name => 'DateDimension'
dimension :customer, :foreign_key => 'customer_id', :class_name => 'CustomerDimension'
dimension :product, :fo... |
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info={})
super(update_info(info,
'Name' => "Unitrends Unauthenticated Root RCE",
'Description' => %q{
},
'License' => MSF_L... |
class CreateGesparticipants < ActiveRecord::Migration
def change
create_table :gesparticipants do |t|
t.string :participanttype_code
t.integer :reg_id
t.string :rfid
t.string :hotelstatus_code
t.string :transportstatus_code
t.string :committeestatus_code
t.timestamps
... |
module Concerns::Help::Method
extend ActiveSupport::Concern
included do
START_INDEX = 1
PRIVATE = 0
PUBLIC = 1
paginates_per 10
scope :search, -> (keyword) { where("name LIKE ?", "%#{keyword}%") }
scope :private, -> { where('public = ?', PRIVATE) }
scope :showing, -> { where('public =... |
require 'google_drive'
class DumpBankAccountJob < ApplicationJob
queue_as :default
def perform(bank_account, online=false)
# localhost = `getent hosts app | awk '{ print $1 ; exit }'`.strip
filename = "#{bank_account.display_name}_#{Date.current.to_formatted_s(:iso8601)}".parameterize + ".pdf"
command... |
class User < ApplicationRecord
lease_envelopable
lease_signable
alias_attribute :full_name, :name
end
|
require_relative "pyrite/version"
require_relative "pyrite/parser"
require_relative "pyrite/transformer"
require_relative "pyrite/cli"
module Swift
module Pyrite
def self.generate_fake_for(file_path, output_path)
code = File.read(file_path)
parser = Parser.new
ast = parser.parse(code)
t... |
require 'rails_helper'
require_relative '../support/devise'
RSpec.describe "/models", type: :request do
def valid_attributes
{
model: attributes_for(:model, {
category_id: create(:category).id,
manufacturer_id: create(:manufacturer).id
},)
}
end
def invalid_attributes
{
... |
class Person
attr_reader :name
attr_accessor :limit, :balance
def initialize(args)
@name = args[:name]
@card_num = args[:card_num]
@limit = args[:limit]
if valid_card?(args[:card_num])
@balance = 0
else
@balance = "error"
end
end
def valid_card?(card_num)
return false... |
# Write a class that will display:
# ABC
# xyz
class Transform
attr_accessor :text
def initialize(text)
@text = text
end
def uppercase
text.upcase
end
def self.lowercase(value)
value.downcase
end
end
# when the following code is run:
my_data = Transform.new('abc')
puts my_data.uppercase
p... |
# TrashConnect.rb
# Andrew Muro <andrewdangermuro@gmail.com>
# 2006/07/18
# List of remote connections. Just a Hash wrapper.
class ConnectionList
def initialize
@connections = Hash.new
end
# Add a remote connection to the list.
def add(remote_host, remote_port, socket = nil)
@connections[remote_host] ... |
require 'rails_helper'
feature "visitor sees details for a planet" do
let!(:tatooine) { FactoryGirl.create(:planet) }
let(:skywalker) { FactoryGirl.create(:vacation) }
let!(:anakin) { FactoryGirl.create(:user) }
scenario "visitor may book a vacation from show page" do
visit planets_path
click_link tat... |
require 'rails_helper'
RSpec.describe QueryPlannedTrays, type: :command do
let!(:facility) do
facility = create(:facility, :is_complete)
facility.rooms.each do |room|
room.rows.each do |row|
row.shelves.each do |shelf|
shelf.trays.each(&:save!)
end
end
end
facili... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe FlagsHelper do
it 'generates the correct officer flag HTML' do
expect(officer_flags('PSTFC')).to eql(
'<div class="officer-flags"><img width="150" height="100" ' \
'src="https://static.bpsd9.org/flags/PNG/PSTFC.thumb.png" /><br>' \
... |
class Event
include Mongoid::Document
field :name
field :description
field :date, :type => Date
validates_presence_of :name
validates_presence_of :date
end
|
# frozen_string_literal: true
require 'rails_helper'
feature 'user visit new user after signup spec' do
scenario 'create user after account signed up' do
person = create(:person)
build(:user, person_id: person)
login_as(person)
visit new_user_path
expect(page).to have_content(person.email)
... |
class Medicine < ApplicationRecord
has_many :prescriptions
monetize :price_cents
def titlecase_name
name.titlecase
end
end
|
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Schema::UniqueWithinType do
describe 'encode / decode' do
it 'Converts typename and ID to and from ID' do
global_id = GraphQL::Schema::UniqueWithinType.encode("SomeType", 123)
type_name, id = GraphQL::Schema::UniqueWithinType.decod... |
class CreateLessonWordAnswers < ActiveRecord::Migration
def change
create_table :lesson_word_answers do |t|
t.references :lesson, index: true, foreign_key: true
t.references :word, index: true, foreign_key: true
t.references :word_answer, index: true, foreign_key: true
t.timestamps null: ... |
module OneUp
module GooglePlus
# A representation of a Google+ user circle
class Circle
attr_reader :user
attr_accessor :members, :name, :info
def initialize(user, circle = nil)
@user = user
raise "Invalid user: #{user}" unless user.kind_of?(User)
@members = Hash.n... |
class Subscription < ActiveRecord::Base
enum frequency: [:no, :daily, :weekly, :monthly]
validates :pincode, length: { is: 6 }, format: {with: /\d{6}/}, allow_nil: true
validates :address, :city, :start_time, :end_time, :category_set, presence: true
validates :user, presence: true
validates :date, presence: ... |
class NvsGoalTypesController < ApplicationController
before_filter :find_project
before_filter :authorize
before_filter :find_user , :expect => [:index,:show, :detroy]
# GET /nvs_goal_types
# GET /nvs_goal_types.json
def index
@nvs_goal_types = NvsGoalType.all
respond_to do |format|
format.... |
Gem::Specification.new do |s|
s.name = 'power-age'
s.version = '1.0.0'
s.author = 'Kevin Melchert'
s.email = 'kevin.melchert@gmail.com'
s.summary = 'Age Calculator'
s.description = 'A handy little age calculation class'
s.files = ['age.rb', 'README.md']
s.require_pat... |
require("minitest/autorun")
require('minitest/reporters')
require_relative('../rooms')
require_relative('../songs')
require_relative('../guests')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
class RoomsTest < MiniTest::Test
def setup
@guest1 = Guests.new("Leela", 20.00, "Florence and the Mac... |
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..")
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..\libs')
require "test/unit"
require "browser_operator"
require "fetch_table"
class FetchTableTest < Test::Unit::TestCase
def setup
@browserOperator = BrowserOperator.instance
@br... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Events
describe Trigger do
let(:described) { Vedeu::Events::Trigger }
let(:instance) { described.new(event_name, args) }
let(:event_name) { :_testing_event_ }
let(:args) {}
describe '.trigger' do
... |
json.array!(@conference_people) do |conference_person|
json.extract! conference_person, :id, :conference_id, :person_id, :old_lastname, :is_teacher, :is_staffteacher, :is_student, :is_postgrad, :details
json.url conference_person_url(conference_person, format: :json)
end
|
require 'sinatra/base'
require_relative './database'
class ApprenticeNews < Sinatra::Application
def initialize(app = nil, database = Database.new)
super app
@db = database
@db.init
end
get '/' do
submissions = @db.get_submissions
erb :index, locals: { submissions: submissions }
end
end
... |
require("spec_helper")
describe(Stylist) do
describe("#name") do
it "returns a name" do
test_stylist = Stylist.new({:name => "Chris", :id => nil})
expect(test_stylist.name()).to eq("Chris")
end
end
describe("#id") do
it("sets its ID when you save it") do
stylist = Stylist.new({:nam... |
class Room < ActiveRecord::Base
has_many :reviews, :dependent => :destroy
belongs_to :user
scope :most_recent, ->{order('created_at DESC')}
#scope :confirmed, -> { where.not(confirmed_at: nil) }
#attr_accessible :description, :location, :title
def complete_name
"#{title}, #{location}"
end
end
|
class HomesController < ApplicationController
before_filter :checked_logged_in_user
def show
end
private
def checked_logged_in_user
if signed_in?
redirect_to dashboard_path
end
end
end |
#!/usr/bin/ruby
def parse(line)
line.split('x').map(&:to_i)
end
def ribbon_for_item(line)
line.reduce(:*) + line.sort[0, 2].map { |e| e * 2 }.reduce(:+)
end
begin
input = File.open(ARGV[0]).read.split
rescue
puts 'Valid input file from AdventOfCode required as first argument.'
else
entries = input.map { |l... |
Rails.application.routes.draw do
devise_for :admins, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
constraints CanAccessFlipperUI do
mount Flipper::UI.app(Flipper) => '/admin/flipper'
end
constraints(:host => /oaklandbreadfored.org/) do
match "/(*path)" => redirect {|params, req| "https://east... |
require_relative 'solver/naked_single'
require_relative 'solver/boxed_single'
module Sudoku
class Game
attr_reader :grid
def initialize(grid)
@grid = grid
@grid.calculate_possible_values!
end
# This method only solves puzzles which don't need to think in next moves
def naive_solutio... |
require 'rails_helper'
RSpec.describe UsersController, type: :controller do
render_views
describe "GET 'index'" do
describe "pour utilisateur non identifiés" do
it "devrait refuser l'accès" do
get :index
response.should redirect_to(signin_path)
flash[:notice].should =~ /identi... |
# frozen_string_literal: true
module Vedeu
module Input
# Translates escape sequences provided by the terminal into
# symbols which Vedeu can use for various behaviours.
#
# @api private
#
class Translator
# @param (see #initialize)
# @return [Symbol]
def self.translate(c... |
class TaskMailer < ApplicationMailer
default from: 'notifications@example.com'
def task_start(task)
@email = task.email
mail(to: @email, subject: 'Your task has started')
end
end |
# frozen_string_literal: true
require_relative 'printer'
require_relative 'game_status'
# Controls the game and it's parts
class Game
def initialize
@file_with_words = 'data/5desk.txt'
@printer = Printer.new
@game_status = GameStatus.new(choose_word)
welcome_and_initialize
game_loop
end
de... |
require 'spec_helper'
describe CurationConcern::CaseGenericWorkActor do
describe "attachments" do
let(:curation_concern) { CaseGenericWork.new(pid: Worthwhile::CurationConcern.mint_a_pid )}
let(:visibility) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED }
let(:user) { FactoryG... |
class Address < ActiveRecord::Base
belongs_to :person
belongs_to :address_type
end
|
class Cart < ActiveRecord::Base
has_many :order_items
belongs_to :user
has_many :line_items, dependent: :destroy
def add_part(part_id)
current_part = line_items.find_by(part_id: part_id)
if current_part
current_part.quantity += 1
else
current_part = line_items.build(part_id: part_id)
... |
class TracksController < ApplicationController
def show
@track = Track.find(params[:id])
end
def new
@track = Track.new
end
def create
@track = Track.new(params[:track])
if @track.save
flash.notice = "Track saved"
redirect_to album_url(@track.album)
else
render :new
... |
control "M-5.16" do
title "5.16 Ensure the host's IPC namespace is not shared (Scored)"
desc "
IPC (POSIX/SysV IPC) namespace provides separation of named shared memory
segments,
semaphores and message queues. IPC namespace on the host thus should not be
shared
with the containers and should remain iso... |
class ArtistType < ApplicationRecord
acts_as_paranoid
has_many :artists
validates_presence_of :name
validates_presence_of :in_use
validates_uniqueness_of :name, case_sensitive: false
end
|
class PlayedTrackSerializer < ActiveModel::Serializer
attributes :id, :track
end
|
require "test_helper"
class DownloaderTest < Minitest::Test
def test_initialized_ok
zip_file_url = "http://nlp.stanford.edu/software/stanford-corenlp-full-2014-06-16.zip"
destination = File.join('./lib/ext/')
assert Downloader.new(zip_file_url, destination)
end
end
|
# frozen_string_literal: true
require "spec_helper"
describe GraphQL::Query::Context do
after do
# Clean up test fixtures so they don't pollute later tests
# (Usually this is cleaned up by execution code, but many tests here don't actually execute queries)
Thread.current[:__graphql_runtime_info] = nil
... |
class KontoManager
STORAGE = "/home/le/workspace/OnlineBank/Konten/konto_information.csv"
def initialize(file_path=STORAGE)
@path = file_path
@konten = read_from_file
end
def read_from_file
konten_temp = {}
File.open(@path).each do |line|
konto_nr, pin, betrag = line.chomp.split(",")
... |
class ApplicationController < ActionController::Base
before_action :set_cookies
private
def set_cookies
cookies[:actions] = cookies[:actions].present? ? cookies[:actions].to_i + 1 : 1
end
def current_user
@current_user ||= Author.find(session[:author_id]) if session[:author_id]
end
helper_metho... |
class CreateGames < ActiveRecord::Migration[5.2]
def change
create_table :games do |t|
t.string :website
t.string :mode
t.datetime :release
t.timestamps
end
reversible do |dir|
dir.up do
Game.create_translation_table! title: :string, description: :string, body: :text... |
#!/usr/bin/env ruby
require_relative "../lib/paradox"
require_relative "../lib/paradox_mod_file_serializer"
require "rgl/adjacency"
require "rgl/connected_components"
require "rgl/topsort"
class ExportTradeGraph < ParadoxGame
def initialize(trade_graph_file, *args)
super(*args)
trade_graph_data = open(trade... |
class ChangeEventColumnNames < ActiveRecord::Migration
def change
rename_column :gsa18f_events, :title_of_training, :title_of_event
rename_column :gsa18f_events, :training_provider, :event_provider
end
end
|
json.array!(@mix_parts) do |mix_part|
json.extract! mix_part, :ingredient_id, :juicemix_id, :parts
json.url mix_part_url(mix_part, format: :json)
end
|
require "spec_helper"
describe "Watch talk", :type => :request do
let!(:user) { create(:user, :paul) }
let!(:other_user) { create(:user, :billy) }
let!(:talk) { create(:talk, :users => [ user ], :owner => user.id) }
before do
login_as(other_user)
visit talk_path(talk)
end
it "mark and unmark talk... |
require_relative 'view'
require_relative 'scrape_marmiton'
class Controller
def initialize(cookbook)
@cookbook = cookbook
@view = View.new
end
def list
# Method to list all our recipe of our cookbook
recipes = @cookbook.all
@view.display_all(recipes)
end
def create
# Method to create... |
class Nutracoapi::Broker::SentOrdersMarker
def check_and_mark_orders_as_sent
non_shipped_orders = Nutracoapi::OrderIntegration.non_shipped_orders
non_shipped_orders.each do |order|
three_order = three_find_order_provider.call_find_order(order.order_number)
if three_order.try(:any?)
track... |
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# Grab some DOIS and metadata via OAI PMH.
# Record metadata in the test-data dir.
# If there is no corresponding PDF in the test-data dir, download it using
# get-pdf.
require 'commander/import'
require 'nokogiri'
require 'json'
require 'mongo'
require_relative '../lib/p... |
class RenameEmployeesToEmployeeRecords < ActiveRecord::Migration[5.1]
def self.up
rename_table :employees, :employee_records
end
def self.down
rename_table :employee_records, :employees
end
end
|
module Seek
module AdminDefinedRoles
class UnknownRoleException < Exception
end
ROLES = %w[admin pal project_manager asset_manager gatekeeper]
PROJECT_DEPENDENT_ROLES = %w[pal project_manager asset_manager gatekeeper]
def self.included(base)
raise "Only People can have roles" unless base... |
class Analytic
attr_accessor :events
def initialize(events)
@events = events
end
def group_by_name
colors = ["red", "green", "blue", "gray"]
highlights = ["green", "red", "gray"]
counted_events = events.group_by { |event| event.name }.map{ |name, events| { value: events.count, label: name } }
... |
# KDTree based on the MagLev version:
# - https://github.com/MagLev/maglev/blob/master/examples/persistence/kdtree/lib/treekd.rb
# Ported from Adam Doppelt's C/Ruby 2D kd-tree:
# - http://gurge.com/blog/2009/10/22/ruby-nearest-neighbor-fast-kdtree-gem/
#
# This class is optimized for up to 3D cases (KDNode accessor met... |
class CreateClientsPaths < ActiveRecord::Migration
def change
create_table :clients_paths, id: false do |t|
t.belongs_to :path
t.belongs_to :client
end
end
end
|
class Inbox < ApplicationRecord
has_many :holiday_requests
end
|
FactoryGirl.define do
factory :order do
sequence(:name) { |n| "Random Person #{n+1}" }
address "MyText"
sequence(:email) { |e| "randomperson#{e+1}@example.com" }
pay_type "Check"
end
end
|
# frozen_string_literal: true
module Common
module HashHelpers
module_function
def deep_compact(hash)
delete_if_block = proc do |_k, v|
if v.is_a?(Hash)
v.delete_if(&delete_if_block)
nil
elsif v.is_a?(Array)
v.compact!
v.each do |item|
... |
#
# EDOS/lib/mixin/color.rb
# by IceDragon
# dm 27/03/2013
# vr 2.1.0
module Mixin
module ColorEx
extend MACL::Mixin::Archijust
class Blend
attr_accessor :color
def initialize(color)
@color = color
end
def none(obj)
@color
end
[
:alpha,
... |
require 'spec_helper'
describe Oshpark::Upload do
subject { Oshpark::Upload.new({}) }
it { should be_an Oshpark::Model }
it { should be_an Oshpark::RemoteModel }
%w| id state original_filename error_message queued_at started_at completed_at errored_at failed_at project_id |.each do |attr|
it { should resp... |
class GoodDog
DOG_YEARS = 7
attr_accessor :name, :age
def initialize(n, a)
self.name = n
self.age = a
end
def public_disclosure
"#{self.name} in human years is #{human_years}" # can use self.human_years in ruby 2.7
end
private
def human_years
age * DOG_YEARS
end
end
snowball = Go... |
class CreateMovies < ActiveRecord::Migration[5.0]
def change
create_table :movies do |t|
t.string :name, limit: 50, comment: "电影名称"
t.datetime :release_time, comment: "上映日期"
t.integer :film_time, comment: "片长"
t.string :alias_name, comment: "电影别名"
t.timestamps
end
end
end
|
require 'rails_helper'
RSpec.describe PostsController, type: :controller do
let!(:user1) { FactoryGirl.create(:user) }
let!(:posts1) { FactoryGirl.create_list(:post, 3, user: user1) }
let!(:special_post) { FactoryGirl.create(:post, body: 'zzZZdddf', user: user1) }
let!(:user2) { FactoryGirl.create(:user) }
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure("2") do |config|
config.vm.define "vm1" do |vm1|
vm1.vm.hostname = "challenge"
vm1.vm.box = "bento/centos-7.6"
vm1.vm.network "private_network", ip: "198.163.33.10"
vm1.vm.provider "virtualbox" do |vb|
... |
class Api::V1::SearchController < ApplicationController
before_action :search_anime, only: [:search]
before_action :page_params, only: [:search]
def search
@animes = []
if params[:q]
if params[:arr].nil?
@animes = @pgsearch_animes
else
@arr = Array(params[:arr])
@anime... |
require 'rails_helper'
describe Admin::FitBitStatsController do
context 'with a signed in user' do
before do
sign_in create(:user)
end
describe '#index' do
before do
@stats = create(:fit_bit_stats)
get :index
end
it 'populates @fit_bit_stats with the latest FitB... |
#
# This is an asset retriever to be used as a companion to the PHP hot_cache script.
#
# Dependencies:
# * Thin web server (and all its dependencies: ruby, rubygems etc.)
#
current_path = File.dirname(__FILE__)
$:.unshift(current_path)
require 'rubygems'
require 'open-uri'
require 'yaml'
$settings = YAML.load(File.... |
class ExcluirClientePage < SitePrism::Page
set_url "http://www.way2automation.com/angularjs-protractor/banking/#/manager/list"
element :campo_buscar, 'input[placeholder="Search Customer"]'
element :botao_excluir, "button[ng-click='deleteCust(cust)']"
end
|
require 'pg'
require_relative './database_connection.rb'
class Peep
attr_reader :id, :text, :time, :date, :user_id
def self.create(text:, user_id:)
Peep.set_environment
@connection = DatabaseConnection.connection
clock = Time.new
time = "#{clock.hour}:#{clock.min}:#{clock.sec}"
date = "#{clo... |
class InterestGenre < ApplicationRecord
belongs_to :interest
belongs_to :genre
end |
require "spec_helper"
describe Kiik do
context 'initialization' do
before(:each) do
Kiik.config_path = 'spec/fixtures/kiik.yml'
end
it 'should set the token' do
expect(Kiik.config[:token]).to eq("098f6bcd4621d373cade4e832627b4f6")
end
it 'should set the wallet object' do
e... |
class AddTotalColumnToParcuris < ActiveRecord::Migration
def change
add_column :parcuri_industriales, :total, :float
end
end
|
class CreateCollaborations < ActiveRecord::Migration
def change
create_table :collaborations do |t|
t.integer :profile_id, :null => false
t.integer :submission_id, :null => false
t.boolean :is_approved, :default => false
t.boolean :show_on_profile, :defau... |
module TitlesHelper
def titlecount
100000
end
def bookcount
250000
end
def membercount
30000
end
def librarycount
30
end
def get_btn_name(caller)
case
when caller.nil? then 'BORROW'
when caller.blank? then 'BORROW'
when caller.eql?(BookList::CATEGORY[:READ]) then 'R... |
class VoteRecorderWorker
include Sidekiq::Worker
sidekiq_options queue: :recorder
def perform
Cache::Votes.flush_all
end
end
|
require 'test/unit'
require 'de'
require 'de/boolean'
class DeBooleanOrTest < Test::Unit::TestCase
def test_constructor
assert_nothing_raised(De::Error::AbstractClassObjectCreationError) { De::Boolean::Or.new }
assert_nothing_raised(De::Error::AbstractClassObjectCreationError) { De::Boolean::Or.new([De::Boo... |
class Restaurant < ApplicationRecord
mount_uploader :img, ImgUploader
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :prefecture
geocoded_by :address
after_validation :geocode, if: :address_changed?
validates :name, presence: true
validates :prefecture, presence: true
... |
class AddIndexToEvents < ActiveRecord::Migration
def change
add_index :events, [ :date, :start_time, :creator_id ], unique: true
end
end
|
# frozen_string_literal: true
require 'jiji/test/test_configuration'
require 'jiji/test/data_builder'
describe Jiji::Model::Trading::Order do
describe '#carried_out?' do
it '成行き注文の場合、常にtrue' do
order = Jiji::Model::Trading::Order.new(:EURJPY, 1, :sell, :market, nil)
expect(order.carried_out?(create... |
class Post < ApplicationRecord
has_one_attached :photo
validates :message, presence: true,
length: { minimum: 3 }
end
|
class VisitsController < ApplicationController
def create
if !day.already_has?(current_user)
day.visits.create!(:user => current_user)
flash[:notice] = "Success! You're all signed up for that day."
else
flash[:error] = "Looks like you're already signed up for that day."
end
redirec... |
module Gameboy
Instruction.define do
family(:ld_16) do
# LD n, nn
opcode(0x01, 12, 3) { Registers.bc = MMU.wread(Registers.pc); Registers.pc += 2 }
opcode(0x11, 12, 3) { Registers.de = MMU.wread(Registers.pc); Registers.pc += 2 }
opcode(0x21, 12, 3) { Registers.hl = MMU.wread(Registers.pc)... |
require_relative 'operator'
require_relative 'visit_occurrence'
require_relative '../date_adjuster'
require 'facets/kernel/blank'
module ConceptQL
module Operators
class OneInTwoOut < Operator
register __FILE__
desc <<-EOF
Represents a common pattern in research algorithms: searching for an event
th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.