text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
# rubocop:todo all
module Mongo
module CRUD
# Represents a single CRUD test.
#
# @since 2.0.0
class CRUDTest < CRUDTestBase
# Spec tests have configureFailPoint as a string, make it a string here too
FAIL_POINT_BASE_COMMAND = BSON::Document.new(
'co... |
require "rails_helper"
RSpec.describe ZipCode, type: :model do
describe "#coordinates" do
it "returns an array of latitude, longitude" do
latitude = 12.345
longitude = 67.890
zip_code = ZipCode.new(latitude: latitude, longitude: longitude)
expect(zip_code.coordinates).to eq [latitude, lo... |
class Blogpicture < ActiveRecord::Base
belongs_to :post
has_attached_file :picture,
style: { medium: "500x400", thumb: "100x100"},
default_url: "/assets/original/portfolio-demo.gif",
url: ":s3_domain_url",
path: "public/admin/posts/:id_:basename.:extension",
storage: :fog,
fog_credentials: {... |
require_relative 'method_documentation'
require_relative 'tagged_markdown'
class Apiculture::AppDocumentation
JOINER = "\n\n"
TEMPLATE_PATH = '/app_documentation_tpl.mustache'
def initialize(app, mountpoint, action_definitions_and_markdown_segments)
@app_title = app.to_s
@mountpoint = mountpoint
@... |
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2016-09-16
# description: The Microsoft Internet Explorer 11 Security Technical Implementation Guide (STIG) is published as a tool to improve the security of Department of Defense (DoD) information systems. Comments or proposed revisions to... |
require_relative '../../../config/environment'
require_relative '../option_methods/main_menu_methods'
require 'highline/import'
def user_login_menu
puts "Do you already have an account? (y/n)"
login
end
def login
answer = gets.strip.downcase
case answer
when "y", "yes"
puts "\nGreat!"
login_to_acc... |
class TradingStrategyService
MAX_CONSECUTIVE_FAIL_TIMES = 5
DEFAULT_STRATEGY = 'constant'
DEFAULT_PERCENTAGE = 0.005.to_d
attr_reader :trader, :exchange
def initialize(trader:, exchange:)
@trader = trader
@exchange = exchange
end
def open_order_percentage
@open_order_percentage ||= begin
... |
class Mutations::CreateBreakpoint < GraphQL::Schema::Mutation
argument :description, String, required: true
field :breakpoint, Types::BreakpointType, null: true
def resolve(description:)
{
breakpoint: {
id: "new_uuid",
description: "woooooah #{description}",
timestamp: Time.cur... |
class AddPlanetarySystemToStar < ActiveRecord::Migration[5.1]
def change
add_reference :stars, :planetary_system, foreign_key: true
end
end
|
class Pnameforms::Piece10sController < ApplicationController
before_action :set_piece10, only: [:show, :edit, :update, :destroy]
# GET /piece10s
# GET /piece10s.json
def index
@pnameform = Pnameform.find(params[:pnameform_id])
@piece10s = @pnameform.piece10s
end
# GET /piece10s/10
# GET /piece1... |
class FeedSubscription < ActiveRecord::Base
belongs_to :feed
belongs_to :feed_item
end
|
require 'rltk/parser'
class FlechaParser < RLTK::Parser
left :OR
left :AND
right :NOT
left :EQ, :NE, :GE, :LE, :GT, :LT
left :PLUS, :MINUS
left :TIMES
left :DIV, :MOD
right :MINUS
class Environment < Environment
def generar_lambda(expresion, parametros)
parametros.reverse.inject(expresion)... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe UserSessionsController do
#Delete this example and add some real ones
it "should use SessionsController" do
controller.should be_an_instance_of(UserSessionsController)
end
describe "PUT 'destroy'" do
before(:each)... |
# frozen_string_literal: true
require 'stannum/constraint'
require 'support/examples/constraint_examples'
RSpec.describe Stannum::Constraint do
include Spec::Support::Examples::ConstraintExamples
subject(:constraint) { described_class.new(**constructor_options) }
let(:constructor_options) { {} }
describe ... |
class IspSession
extend Ispremote::Soap
operations :login, :logout
def initialize sid
self.sessionid = sid
end
def sessionid=(sid)
@sessionid = sid
end
def sessionid
@sessionid
end
def self.login
loginresponse = super(:message => {:username => Setting.remote_user, :password =>... |
class Schedule < ApplicationRecord
belongs_to :service
belongs_to :customer
belongs_to :worker
end
|
When /^I create an index named (.*) on the (.*) collection$/ do |index_name, doc|
klass = doc.constantize
klass.index(index_name)
end
Then /^there is an index on (.*) on the (.*) collection$/ do |index_name, doc|
klass = doc.constantize
klass.collection.index_information.should include("#{index_name}_1")
end
|
class GameOfLife
attr_reader :initial_matrix, :next_matrix
def initialize(matrix)
@initial_matrix = matrix
@next_matrix = matrix
end
def check_top(x, y)
initial_matrix[x-1][y] == 1
end
def check_top_right(x, y)
initial_matrix[x - 1][y + 1] == 1
end
def check_right(x, y)
initial_m... |
class SlackersController < ApplicationController
def index
render json: { slackerboard: slackerboard.to_json }
end
private
def slackerboard
if this_week?
SlackerRanking.new(since: Time.zone.today.monday)
else
SlackerRanking.new
end
end
def this_week?
params.keys.include? '... |
require 'json'
require_relative './helpers/data_former_helper'
class ParserJson
include DataFormerHelper
def initialize(path, file_name)
@path = path
@file_name = file_name
end
def parse
data = JSON.parse(File.read(File.expand_path("#{@path}#{@file_name}.json", __FILE__)))
keys = []
value... |
require 'spec_helper'
include Liquider
RSpec::Matchers.define :parse_to do |token_type|
match do |source|
string_scanner = StringScanner.new(source)
string_scanner.scan(token_type.pattern) && string_scanner.eos?
end
end
describe Tokens::IdentToken do
it 'cannot be empty' do
expect('').not_to parse_... |
require 'rails_helper'
RSpec.describe Order, type: :model do
describe "Associations" do
it "has many line_items" do
assc = described_class.reflect_on_association(:line_items)
expect(assc.macro).to eql :has_many
end
it "belongs to a user" do
assc = described_class.reflect_on_associa... |
class CreateDragonhoards < ActiveRecord::Migration[5.2]
def change
create_table :dragonhoards do |t|
t.string :name
t.text :message
t.datetime :created_on
t.string :ogg
t.string :mp3
t.float :taxbase, limit: 53
t.float :taxinc, limit: 53
t.integer :ocpoints
t.... |
class Followship < ApplicationRecord
validates :following_id, uniqueness: {scope: :user_id}
belongs_to :follower, class_name: :User, foreign_key: :user_id, counter_cache: :followings_count
belongs_to :following, class_name: :User, counter_cache: :followers_count
end
|
class CreateReservationStatuses < ActiveRecord::Migration[5.0]
def change
create_table :reservation_statuses do |t|
t.string :type
t.timestamps
end
add_column :reservations, :reservation_status_id, :integer
end
end
|
class User < ActiveRecord::Base
has_many :user
has_many :authentications
has_many :trails
has_one :setting
has_many :pages
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable,
... |
class Admins::BannersController < ApplicationController
before_action :authenticate_admin!
def index
@banners = Banner.where(status: 1).order('sort_order IS NULL').order(sort_order: 'ASC', id: 'ASC')
end
def new
@banner = Banner.new()
end
def create
@banner = Banner.new(banner_params)
if... |
require "./cellnum.rb"
require "./assembler.rb"
class Disassembler
def Disassembler.disassemble(code)
cmd,param1,param2=code
return ("#{cmd} "+Disassembler.disassemble_param(param1)+" "+Disassembler.disassemble_param(param2)).strip
end
def Disassembler.disassemble_param(param)
ret... |
class AddEnergyToClothes < ActiveRecord::Migration[6.1]
def change
add_column :clothes, :energy_consumption, :string
end
end
|
class PostSerializer < ActiveModel::Serializer
attributes :id, :title, :content, :created_at, :url_for_post, :associated_topics
has_many :post_links
end
|
require 'securerandom'
require 'spec_helper'
describe "Binding a Riak CS service instance" do
let(:instance_id) { SecureRandom.uuid }
let(:binding_id) { SecureRandom.uuid }
def make_request(id = instance_id, b_id = binding_id)
put "/v2/service_instances/#{id}/service_bindings/#{b_id}"
end
it "returns a... |
class ShopsController < ApplicationController
def index
@categories = Category.all
@shops = Shop.search(params[:search])
end
def show
@shop = Shop.find(params[:id])
@review_access = @shop.reviews.find_by(:user_id => current_user.id) if user_signed_in?
end
def edit
if user_signed_in?
... |
require File.dirname(__FILE__) + '/../test_helper'
class HostTest < Test::Unit::TestCase
def setup
Host.delete_all
end
def test_creation
assert_equal 0, Host.count
assert_nothing_raised{
h = Host.create!(:name => "test.example.com")
}
assert_equal 1, Host.count
end
... |
=begin
Copyright (c) 2013 ExactTarget, Inc.
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 of conditions and the
... |
ActiveAdmin.application.tap do |config|
# Set the default configuration for authenticating with admin users
config.authentication_method = :authenticate_admin_user!
config.current_user_method = :current_admin_user
config.logout_link_method = :delete
config.logout_link_path = :destroy_admin_user_sess... |
class DeleteWinFromMatches < ActiveRecord::Migration
def self.up
remove_column(:matches, :win)
end
def self.down
add_column(:matches, :win, :boolean)
end
end
|
module Opity
module Resource
class Balancer < Base
attribute :name
attribute :type
attribute :environment
attribute :application
def list
[self, Opity::Resource::Dns.new(name: self.name, type: 'dns')]
end
def valid?
b = self.class.balancers.detect {|e| e... |
class ChangeDocumentsPagesToContent < ActiveRecord::Migration
def change
rename_column :documents, :pages, :content
end
end
|
FactoryGirl.define do
factory :partner do
name_ru { generate :string }
description_ru { generate :string }
end
end
|
require_relative "../ebook_converter"
require_relative "../prince"
require_relative "../preprocessor"
require_relative "../postprocessor"
require_relative "../prince_post_processor"
require 'yaml'
require 'zip'
## x = FileList["text/**/*.md"]
## x.pathmap("new file pattern %n %x") %p %f %d %x %n {^source,target}
# d... |
class AddPhotoToBusinesses < ActiveRecord::Migration
def change
add_attachment :businesses, :logo
end
end
|
module Jruby::Pcap
class Frame
def initialize(handle, frame)
@handle = handle
@frame = frame
@header = @frame.header
end
def src_addr
@header.src_addr.to_s.gsub("/","")
end
def src_host
@header.src_addr.host_name
end
def src_port
@header.src_port.va... |
#encoding: utf-8
class SpecimenGroupRelationship < ActiveRecord::Base
# Constants
# Put here constants for SpecimenGroupRelationship
# Relations
belongs_to :specimen
belongs_to :specimen_group
# Callbacks
# Put here custom callback methods for SpecimenGroupRelationship
# Validations
# validates :s... |
class EnquiryService < ApplicationRecord
belongs_to :service
belongs_to :enquiry
validates :service_id, uniqueness: { scope: :enquiry_id }
end
|
module Rockauth
class SessionsController < ActionController::Base
include Rockauth::Controllers::Scope
include Rockauth::Controllers::UnsafeParameters
before_filter :set_variables
helper_method :resource
helper_method :param_key
helper_method :resource_owner_class
layout :configured_layo... |
require "rails_helper"
RSpec.feature "Visitor adds a space to cart" do
context "valid reservation" do
scenario "visitor adds a valid reservation to the cart" do
space = create(:space, approved: true)
visit space_path(space)
fill_in "start_date", with: "2016/08/17"
fill_in "end_date", wi... |
require 'spec_helper'
require 'timecop'
require_relative 'shared_examples'
RSpec.describe Bambooing::Timesheet::Clock::Entry::Factory do
let(:employee_id) { 'an_employee_id' }
let(:pto_class) { Bambooing::TimeOff::Table::PTO }
describe '.create_current_weekdays' do
let(:method) { :create_current_weekdays }
... |
require 'httparty'
require 'active_collab/version'
require 'active_collab/client'
module ActiveCollab
@@api_key = nil
@@api_url = nil
def self.api_key=(api_key)
@@api_key = api_key
end
def self.api_url=(api_url)
@@api_url = api_url
end
def self.client
ActiveCollab::Client.new(@@api_url, @... |
class ReviewTag < AbstractTag
belongs_to :review
belongs_to :tag, :class_name => 'NormalizedTag', :foreign_key => 'normalized_tag_id'
acts_as_list :scope => 'review_id = #{review_id} AND kind = \'#{kind}\'', :column => :sort_order
validates_uniqueness_of :value, :scope => [:review_id, :kind], :allow_nil... |
require 'active_support/all' # Should be required first.
require 'seed_migrator/update_class_loader' #Should be required second.
require 'seed_migrator/updater'
require 'seed_migrator/seeds'
# Extends the migrations DSL to include the functionality to execute data updates.
#
# Note that each data update class is inst... |
#encoding: UTF-8
class CoverPhoto
include Mongoid::Document
include Mongoid::Paperclip
include Mongoid::Timestamps
# extend Mongoid::PaperclipQueue
store_in collection: "cover_photo", database: "dishgo"
field :original_url, type: String
field :position, type: Integer
field :img_url_medium, type: Stri... |
Vertex = Struct.new(:graph, :label) do
def initialize(graph, label)
self.explored = false
super(graph, label)
end
attr_writer :explored
def explored?
@explored
end
def unexplored?
!explored?
end
def outgoing_edges
@outgoing_edges ||= []
end
def incoming_edges
@incoming_ed... |
class TemporaryUser < ApplicationRecord
def voted_on?(object, positive)
object_type = object.class.to_s.downcase
return positive == true if (public_send("parsed_#{object_type}s") || {})[object.id.to_s].present?
vote_id = parsed_votes[object_type][object.id.to_s]
return false if vote_id.nil?
vote ... |
require 'rack/proxy'
module VueCli
module Rails
class DevServerProxy < ::Rack::Proxy
def initialize(app)
@app = app
config = Configuration.instance
@host = config.dev_server_host
@assets_path = config.output_url_path
end
def perform_request(env)
if env['... |
# frozen_string_literal: true
FactoryGirl.define do
factory :car do
brand "Ford"
model "Focus"
production_year "2010"
comfort "basic"
places 4
color "black"
category "hatchback"
user
factory :car_with_photo do
car_photo { File.open(Rails.root.join("spec", "fixtures", "image... |
require 'spec_helper'
describe "Escapes show request" do
let!(:escape) { FactoryGirl.create(:escape, :title => "Testing Specs",
:expiration => (Time.now.to_date + 7),
:nearest_metro => "Wookieland") }
let!(:metro) { Factor... |
module MRuby
module RubyCompat
module Bundler
def self.setup_standalone_bundle(bundler_setup_file)
Object.const_set(:RbConfig, RbConfig)
root_dir = File.expand_path('../..', bundler_setup_file)
versions = []
Dir.glob(File.join(root_dir, 'ruby', '*')).each do |version_dir|
... |
class User < ApplicationRecord
def admin_exist_check
throw :abort if self.admin? && User.where(admin: true).count == 1
end
def admin_exist_check_update
@admin_user = User.where(admin: true)
throw :abort if @admin_user.first == self && @admin_user.count == 1
end
before_destroy :admin_exist_check
... |
class CreateNodes < ActiveRecord::Migration
def change
create_table :nodes do |t|
t.integer :story_id, null: false
t.integer :parent_id
t.integer :user_id, null: false
t.integer :level, null: false, default: 2
t.text :path
t.text :content, ... |
class GoogleCalendar
def self.client_secrets(base_url)
Google::APIClient::ClientSecrets.new(
{
web: {
client_id: ENV["GOOGLE_CLIENT_ID"],
client_secret: ENV["GOOGLE_SECRET_KEY"],
redirect_uris: ["#{base_url}/oauth2callback"],
auth_uri: "https://accounts.google... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string default(""), not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_password_sent_at :datet... |
class EventsController < ApplicationController
before_action :signed_in_user
before_action :student_user, only: [:new_reservation]
before_action :not_in_past, only: [:new_reservation]
before_action :not_already_attending, only: [:new_reservation]
before_action :correct_admin, only: [:edit, :update, :ads, :ann... |
require 'minitest/spec'
require 'minitest/autorun'
require 'redis'
require "#{File.dirname(__FILE__)}/../lib/turnstile"
def turnstile
redis = Redis.new
redis.flushall
Turnstile::Model::Turnstile.new(redis)
end
describe Turnstile::Model::Turnstile do
describe "realms" do
it "should be creatable" do
... |
require 'rails_helper'
feature 'Footer' do
context "anybody visits home page" do
before { visit root_path }
specify "she sees correct footer links" do
expect(page).to have_link "Home", href: root_path
expect(page).to have_link "Contact", href: contact_new_path
expect(page).to have_link "Se... |
require "language/go"
class Peco < Formula
homepage "https://github.com/peco/peco"
url "https://github.com/peco/peco/archive/v0.2.12.tar.gz"
sha1 "4f5caf6eab2f7c08191939dec7543afc32a6ddde"
bottle do
cellar :any
sha1 "c266e3919d01293aedfc7f4ce459be76ccacd954" => :yosemite
sha1 "9374ae50643d4b8b0e1d... |
module Admin
class MenusController < AdminBaseController
before_action :load_menu, except: %i(index create)
def index
@menu = Menu.new
@menus = Menu.lastest
end
def show
@dishes = @menu.dishes.distinct
@menudetail = @menu.picks.build
end
def edit; end
def create... |
require 'test_helper'
require 'test/unit'
require_relative '../lib/util.rb'
class TestUtil < Test::Unit::TestCase
def test_load_config
plan, contacts, mail_config = load_config_data(File.expand_path('../../dat.yml', __FILE__))
assert(contacts.size >= 1)
assert_equal(plan.keys, ['public', 'discount', '... |
class InfinityPoint
def +(other)
return other
end
def -(other)
return -other
end
def -@
return self
end
def *(scalar)
return self
end
def eql?(other)
return other.is_a? InfinityPoint
end
def hash
return 1234
end
def to_s
"<Point at Infinity>"
end
end
|
class ImagesController < ApplicationController
before_action :set_image, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
def index
@images = Image.all
@instaimages = Image.last
end
def show
end
def new
@image = current_user.images.build... |
class UserMailer < ApplicationMailer
default from: "owner@address_book.com"
def shared(email, user)
@user = user
mail(to: email, subject: 'Shared email')
end
end
|
# WRONG WAY!
if ! tweets.empty?
puts "Timline:"
puts tweets
end
# GOOD WAY!
# Instead of if ! use unless
unless tweets.empty?
puts "Timline:"
puts tweets
end
# WRONG WAY!
if attachment.file_path != nill
attachement.post
end
# GOOD WAY!
#nil id=s treated ad false
if attachment.file_path != nill
attachement.post... |
FactoryBot.define do
factory :comment do
comment { Faker::Lorem.paragraphs }
user
concert
end
end
|
# frozen_string_literal: true
class Api::V1::Users::Mailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
def confirmation_instructions(record, token, opts = {})
mail = super
... |
# frozen_string_literal: true
require 'weakref'
require_relative 'memory_cache/lock'
require_relative 'memory_cache/entry'
require_relative 'memory_cache/node'
require_relative 'memory_cache/linked_list'
require_relative 'memory_cache/maintainer'
module Super
class MemoryCache
include Super::Component
ins... |
module NdrError
# Global controller logic
class ApplicationController < ActionController::Base
before_action :authenticate
# Ensure Rails doesn't find any host layouts first:
layout 'ndr_error/ndr_error'
helper NdrUi::BootstrapHelper
private
def authenticate
return if NdrError.chec... |
require 'tk'
require 'tkextlib/tile' #Advanced GUI
require_relative '../WinBoxes'
require_relative '../Engineering'
require_relative 'GUI/MC9090 RMA GUI.rb'
require_relative 'Scripts/MC9090 RMA.rb'
=begin
#Ocra command for tk:
#ocra "MC9090 RMA GUI.rbw" --windows C:\Ruby193\lib\tcltk\ --no-autoload --add-all-core
=e... |
FactoryBot.define do
factory :target_group do
name { Faker::Job.field }
external_id { Faker::IDNumber.valid }
parent_id { nil }
secret_code { Faker::IDNumber.valid }
panel_provider_id { Faker::Number.between(1, 10) }
end
end |
# frozen_string_literal: true
module Sentry
# @api private
class ReleaseDetector
class << self
def detect_release(project_root:, running_on_heroku:)
detect_release_from_env ||
detect_release_from_git ||
detect_release_from_capistrano(project_root) ||
detect_release_from_he... |
require 'rails_helper'
describe Mutations::UserMutationType do
it 'defines a field signInUser that returns Types::UserType type' do
expect(subject).to have_a_field(:signInUser).that_returns(Types::UserType)
end
context 'with signInUser field' do
let(:facebook) { Faker::Omniauth.facebook }
let(:acce... |
#
# Copyright 2011 National Institute of Informatics.
#
#
# 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 ... |
class AddAdminToNodes < ActiveRecord::Migration
def change
add_column :nodes, :admin, :boolean, :default => false
end
end
|
require("minitest/autorun")
require("minitest/rg")
require_relative("../room.rb")
require_relative("../guest.rb")
require_relative("../song.rb")
class TestRoom < MiniTest::Test
def setup
@guest1 = Guest.new("Waymar Royce")
@guest2 = Guest.new("Lady Stoneheart")
@guest3 = Guest.new("Coldhands")
@gues... |
require 'leboncoin/items'
module LeBonCoin
module Search
class << self
###
# Load the given URL as a well-formed HTML document
def loadHTML url
require 'open-uri'
require 'nokogiri'
doc = begin
Nokogiri::HTML(open(url))
rescue
nil
end... |
# frozen_string_literal: true
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :facts, only: %i[index show] do
get :list, on: :collection
resources :happenings, only: %i[index show] do
resources :tickets, o... |
class Api::V1::ScoresController < ApplicationController
before_action :assert_user
before_action :assert_course, only: [:update, :destroy]
# POST /api/scores/scored_groups.json
def scored
@scores = paginate(Api::Group.base.base_users.base_scores.with_users.with_scores(@user.id))
render json: @scores.a... |
class PoorPokemon::Enemy < PoorPokemon::BasePlayer
def initialize(pokeGroup)
@roster = pokeGroup
@currentPokemon = @roster[0]
end
def switch
#switches current pokemon (should be dead) for another valid pokemon
@currentPokemon = @roster.select{|pokemon|pokemon.alive?}.sample
... |
# encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe HasEnum do
let :model do
TestModel.new(:category => :stuff, :status => :pending, :state => :done, :speed => :slow)
end
let :human_enums do
{
:category => {
:stuff => 'Stuff',
:things ... |
require 'rails_helper'
describe "Places" do
it "if one is returned by the API, it is shown at the page" do
allow(BeermappingApi).to receive(:places_in).with("kumpula").and_return( [Place.new(name:"Oljenkorsi", id:1)])
visit places_path
fill_in('city', with: 'kumpula')
click_button 'Search'
expect(page).t... |
class Category < ApplicationRecord
validates :title, presence: { message: "请输入分类名称" }
has_many :products
end
|
class OrganizationDocumentsDatasetGenerator
include Rails.application.routes.url_helpers
def initialize(organization)
@organization = organization
end
def generate!
dataset = build_dataset
dataset.sector = Sector.friendly.find('otros')
build_distribution(dataset)
dataset.save
end
priv... |
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/object/blank'
module BlueprintAgreement
class ExcludeFilter
class << self
def deep_exclude(content, exclude_attributes)
... |
class Api::AnswersController < ApplicationController
def create
@answer = Answer.new(answer_params)
@answer.question_id = params[:question_id]
if (current_user)
@answer.author_id = current_user.id
else
@answer.author_id = 1
end
if @answer.save
@user = current_user
@qu... |
puts "Enter 1 to add, 2 to subtract, 3 to multiply, or 4 to divide two numbers."
operator = gets.to_i
if operator > 4
puts "Invalid entry please enter a number between 1 and 4."
operator = gets.to_i
end
puts "Enter the first number to put in the equation."
number1 = gets.to_i
puts "Enter the second number to p... |
class AddColumnToAlbums < ActiveRecord::Migration[5.1]
def change
add_column :albums, :band_id, :integer, null: true
add_column :tracks, :album_id, :integer, null: true
end
end
|
class PagesController < ApplicationController
def home
@post = Post.new
@comment = Comment.new
@like = Like.new
@alreadyLiked = false
# When we get to the home page, check if the user is logged in. If so, get the posts for it and chuck it in an array.
if @current_user.present?
# ... |
class User < ApplicationRecord
authenticates_with_sorcery!
has_many :posts, dependent: :destroy
has_many :comments, dependent: :destroy
validates :name, presence: true, length: { maximum: 50 }
validates :email, presence: true, uniqueness: true
validates :password, presence: true, confirmation: true, length:... |
class User < ActiveRecord::Base
has_secure_password
def set_password_reset
self.code = SecureRandom.urlsafe_base64
self.expires_at = 4.hours.from_now
self.save!
end
def self.authenticate (email, password)
User.find_by_email(email).try(:authenticate, password)
end
has_one :profile
has_ma... |
class RemoveIntervalFromStationService < ActiveRecord::Migration
def change
remove_column :station_services, :interval, :string
end
end
|
class ManageIQ::Providers::Amazon::CloudManager::Vm < ManageIQ::Providers::CloudManager::Vm
include_concern 'Operations'
include_concern 'ManageIQ::Providers::Amazon::CloudManager::VmOrTemplateShared'
supports :capture
POWER_STATES = {
"running" => "on",
"powering_up" => "powering_up",
"sh... |
# wkhtml2pdf Ruby interface
# http://wkhtmltopdf.org/
require 'logger'
require 'digest/md5'
require 'rbconfig'
require 'chrome_remote'
require 'base64'
require 'tempfile'
require 'open3'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/object/blank'
require 'wicked_pdf/ve... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.