text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
module Api
module V1
class SitesController < ApplicationController
protect_from_forgery with: :null_session
before_action :assign_page
def assign_page
@page = params[:page] || 1
end
private
def load_collection(serializer, query)
... |
def profile(block_descr, &block)
profiling? = true
if profiling?
start_time = Time.new
block.call
duration = Time.new - start_time
puts "#{block_descr}: #{duration} seconds"
else
block.call
end
end
profile 'counting', do
number = 0
100000000.times do
number = ... |
class Item < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :category
belongs_to_active_hash :condition
belongs_to_active_hash :postage_type
belongs_to_active_hash :shipping_region
belongs_to_active_hash :preparation_day
# 空の投稿を保存できないようにする
with_options p... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
# Before action filters.
# Precendence is important. So please add specs if you change the order or add to the chai... |
Given /^I am on the home page$/ do
visit "http://localhost:3000/"
end
Then /^I should see "([^"]*)"$/ do |text|
page.should have_content text
end
Then /^I should see "([^"]*)" in the selector "([^"]*)"$/ do |text, selector|
page.should have_selector selector, text: text
end
Then /^I should ... |
#==============================================================================
# Random Encounters by Level
# Version: 1.0.0
# Author: modern algebra (rmrk.net)
# Date: 22 September, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script ... |
module BootstrapCDN::Rails
module ActionViewExtensions
OFFLINE = ( ::Rails.env.development? )
BOOTSTRAP_VERSIONS = ["3.0.3", "3.0.2", "3.0.1", "3.0.0", "2.3.2"]
FONTAWESOME_VERSIONS = [ '4.0.3', '3.2.1' ]
def boostrap_css_include_tag(options = {version: BOOTSTRAP_VERSIONS.first})
styleshee... |
require 'rails_helper'
describe AccountsController, type: :controller do
let(:user) {create(:user)}
describe 'GET #new' do
context 'ログインしている場合' do
before do
login user
end
context 'accountを作成済みの場合' do
it 'アカウント編集画面にリダイレクトされること' do
account = create(:account, user_id: ... |
module FogTracker
module Query
# A class for filtering the Fog resources for a set of {AccountTracker}s,
# based on a regular-expression-based query
class QueryProcessor
# The Regular Expression which all resource queries must match
QUERY_PATTERN = %r{(.*)::(.*)::(.*)::(.*)}
# Creates ... |
require 'rails_helper'
describe 'ReportingRelationships', type: :request, active_job: true do
let(:department1) { create :department, name: 'AAA' }
let(:department2) { create :department, name: 'BBB' }
let(:department3) { create :department, name: 'CCC' }
let(:user1) { create :user, department: department1 }
... |
# module Shout
# def self.yell_angrily(words)
# words + "!!!" + " :("
# end
# def self.yell_happily(words)
# words + "!!!" + ":)"
# end
# end
# ## Driver Code --------------------------------------------------------------------------------------------------------------------------------
# p Shout.yel... |
class Breed < ActiveRecord::Base
has_many :pet_breeds
has_many :pets, through: :pet_breeds
end
|
# == Schema Information
#
# Table name: notes
#
# id :integer(4) not null, primary key
# user_id :integer(4)
# content :string(255)
# latitude :float
# longitude :float
# created_at :datetime not null
# updated_at :datetime not null
# region_id :integer(4)
# local_id :int... |
require 'spec_helper'
describe Moderator do
it 'has valid factory' do
expect(build(:moderator)).to be_valid
end
it { should have_many(:rooms) }
end
|
require 'test_helper'
class TecladosControllerTest < ActionController::TestCase
setup do
@teclado = teclados(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:teclados)
end
test "should get new" do
get :new
assert_response :success
en... |
require 'spec_helper'
describe User do
describe "validation" do
describe "name" do
context "is nil" do
it { expect(build(:user, name: nil)).to have(1).error_on(:name) }
end
end
describe "uid" do
context "is nil" do
it { expect(build(:user, uid: nil)).to have(1).error_on... |
require_relative('../lib/fizzbuzz')
require('spec_helper')
#TDD approach makes you write the test before you write the code. This can help you
# create and write the methods before solving the problem
describe "FizzBuzz" do
before :each do
@buzzer = FizzBuzz.new
end
describe "#fizz?" do
it "should ret... |
class Cipher
def initialize(key)
validate_key(key)
@key = key || generate_key
end
def validate_key
raise ArgumentError, "The key can't have capital letters or numbers." if key.match(/[A-Z0-9])
end
def encode(plain_text)
result = []
plan_text.split('').each_with_index do |char, index|
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe FeedbackSubmissionMailer, type: [:mailer] do
let(:feedback) { build :feedback }
let(:feedback_with_email) { build :feedback, :email_provided }
let(:feedback_malicious) { build :feedback, :malicious_email }
let(:github_url) { 'https://github.c... |
class ProductSerializer < ActiveModel::Serializer
attributes :id, :description, :special, :available, :cover, :status, :value, :code, :code_type
belongs_to :product_item, polymorphic: true, include: true
belongs_to :user, serializer: UserSerializer
has_many :photos, serializer: PhotoSerializer
has_many :comments,... |
class StudentAddlAttachment < ActiveRecord::Base
has_attached_file :attachment,
:url => "/uploads/:class/:id/:attachment/:attachment_fullname?:timestamp",
:path => "uploads/:class/:attachment/:id_partition/:style/:basename.:extension",
:max_file_size => 5242880,
:reject_if => proc { |attributes| attri... |
class AddCouponCodeToCart < ActiveRecord::Migration[5.2]
def change
add_column :shopping_carts, :coupon_code, :string
end
end
|
#!/usr/bin/ruby
# encoding: utf-8
# This file is used for installation-specific configuration, utilizing
# hooks in the main gallery class to allow configurable behavior.
#
# Copy this file to gallery_config.rb to enable.
#
# Copyright 2014 Ville Misaki <ville@misaki.fi>
module Gallery
class Gallery
# Map the ... |
require 'spec_helper'
RSpec.describe ImageHandler do
subject(:handler) { described_class.new }
context "nodes change colour" do
let(:expected_image) { [%w(O O), %w(L L)] }
before { handler.new_image(2, 2) }
it "left to right returns expected image" do
handler.horizontal_line(1, 0, 1, 'L')
... |
class CreateTempActivities < ActiveRecord::Migration
def change
create_table :temp_activities do |t|
t.integer :user_id
t.string :political_view
t.string :categories
t.integer :t1_id
t.integer :t2_id
t.string :friend_question1
t.string :friend_question2
t.string :fr... |
class AddConsoleToPost < ActiveRecord::Migration
def change
add_column :posts, :console, :string
end
end
|
class Comment < ActiveRecord::Base
attr_accessible :programme_id, :details, :author
validates_presence_of :programme_id, :details, :author
belongs_to :programme, :dependent => :destroy
end
|
#!/usr/bin/env ruby
require 'openssl'
class BSGS
def initialize(a, b, n)
@a = a.to_i
@b = b.to_i
@n = n.to_i
raise "error" if sanitycheck
end
def exploit
m = findm
table = {}
(0..m-1).each do |j|
tmp = @a.to_bn.mod_exp(j,@n)
table["#{tmp}"] = j
end
y = @b
... |
class Image
include Mongoid::Document
include Mongoid::Timestamps
field :description, type: String
field :thumbnail_url, type: String
field :url, type: String
field :size, type: Integer, default: 0
field :delete_type, type: String
mount_uploader :photo, PhotoUploader
#validates :description, presen... |
class CreatePresenters < ActiveRecord::Migration
def change
create_table :presenters do |t|
t.integer :gesparticipant_id
t.string :identification
t.string :username
t.string :password
t.string :password_salt
t.string :email
t.string :dob
t.string :details
t.t... |
require 'csv'
require '../comrank/app'
class CxbRankApp < CxbRank::AppBase
include CxbRank
CSV_DIFFS = {
'STANDARD' => MUSIC_DIFF_STD,
'HARD' => MUSIC_DIFF_HRD,
'MASTER' => MUSIC_DIFF_MAS,
}
get IMPORT_CSV_URI do
private_page do |user|
if !SiteSettings.edit_enabled?
haml :... |
# coding: utf-8
module API
class MessagesAPI < Grape::API
resource :messages do
# 获取未读消息
desc "获取未读消息条数"
params do
requires :token, type: String, desc: "Token"
end
get :unread_count do
user = authenticate!
# 检测未读系统消息
if user.last_r... |
module SliderDecorator
def draw_state
if on_publishing?
col = case aasm_state
when 'modifying'
'info'
when 'active'
'success'
else
'default'
end
str = aasm.human_state
else
col = 'default'
str = I... |
class Tagging < ActiveRecord::Base
validates :tag, :bookmark, presence: true
belongs_to :tag
belongs_to :bookmark
end
|
class CreateAdvanceFeeTransactionReceiptRecords < ActiveRecord::Migration
def self.up
create_table :advance_fee_transaction_receipt_records do |t|
t.references :advance_fee_collection
t.references :transaction_receipt
t.integer :fee_account_id
t.integer :fee_receipt_template_id
t.int... |
require 'qbwc'
class TrackingEmailWorker < QBWC::Worker
# This worker was setup for testing purposes, it does work, but not reccomened to use during production.
# ** make decision if you want to use this in production
def requests(job)
Rails.logger.info("Starting customer modify")
# de... |
class App < ActiveRecord::Base
# attr_accessible :title, :body
attr_accessible :name, :description, :email, :url, :event, :twitter, :avatar
has_attached_file :avatar, :styles => { :medium => "400x400", :thumb => "100#x100#" }
validates_presence_of :name, :description, :url
end
|
require 'spec_helper'
describe 'merchants/_grid_info' do
let(:merchant) { create(:merchant) }
it "has the merchant info" do
render :partial => 'merchants/grid_info', :locals => { :merchant => merchant }
rendered.should have_image(merchant.picture.grid_info)
rendered.should have_selector('#grid-info'... |
class CreateHistoryPoints < ActiveRecord::Migration[5.2]
def change
create_table :history_points do |t|
t.references :user, foreign_key: true
t.references :reserv, foreign_key: true
t.integer :used_points
t.timestamps
end
end
end
|
WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + # rows
[[1, 4, 7], [2, 5, 8], [3, 6, 9]] + # cols
[[1, 5, 9], [3, 5, 7]] # diagonals
INITIAL_MARKER = ' '
PLAYER1_MARKER = 'X'
PLAYER2_MARKER = 'O'
###########################################
# Initialize Methods
#####################... |
require 'spec_helper'
describe StudentGrades do
after { FileUtils.rm_rf(StudentGrades.grade_report_path) }
describe '.report_for' do
let(:path) { File.join(StudentGrades.class_scores_path, 'class_1_grades.csv') }
let(:class1_grades) { File.join(StudentGrades.grade_report_path, 'class_1_grade_ave... |
require 'csv'
require 'sunlight/congress'
require 'erb'
# get an api key @ http://sunlightfoundation.com/api/accounts/register/
Sunlight::Congress.api_key = ""
def clean_zipcode(zipcode)
zipcode.to_s.rjust(5, '0')[0..4]
end
def legislators_by_zipcode(zipcode)
Sunlight::Congress::Legislator.by_zipcode(zipcode)
e... |
require 'test_helper'
class TripTest < ActiveSupport::TestCase
def setup
@trip = Trip.new(name: "test", start_date: "2018-01-01", end_date: "2018-01-31", location: "TA")
end
test "should be valid" do
assert @trip.valid?
end
test "name should be present" do
@trip.name = ""
assert_no... |
class Skill < ActiveRecord::Base
using_access_control
validates_presence_of :name, :level, :description, :category
validates_uniqueness_of :name, :scope => :person_id
belongs_to :person
belongs_to :category
has_and_belongs_to_many :projects, :readonly => true
acts_as_list :scope => :person
default_s... |
class Ticket < ApplicationRecord
has_many :logs
validates :description, presence: true
validates_format_of :pr_url,
:with => /\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,63}(:[0-9]{1,5})?(\/.*)?\z/ix,
allow_blank: true,
message: 'not a valid URL'
STATUSES = [
'product_backlog',
... |
class ShoppingList < ApplicationRecord
belongs_to :user
has_one :order, dependent: :destroy
has_one :driver, through: :order
has_many :items, dependent: :destroy
end
|
# frozen_string_literal: true
class CoursesController < ApplicationController
before_action :authenticate_user!
def show
@course = Course.find(params[:id])
end
def course_params
params.require(:course).permit(:name)
end
end
|
=begin
* Modelo de la tabla Product de la base de datos
* @author rails
* @version 14-10-2017
=end
class Product < ApplicationRecord
belongs_to :material_type
belongs_to :construction_type
belongs_to :product_line
has_many :articles
has_many :quotations, through: :articles
validates :name, format: {with... |
require 'spec_helper'
describe Susanoo::Admin::HelpCategoriesController do
shared_examples_for "未ログイン時のアクセス制限" do |action|
it "#{action} ログイン画面にリダイレクトされること" do
expect(response).to redirect_to(login_susanoo_users_path)
end
end
shared_examples_for "情報提供責任者ログイン時のアクセス制限" do |action|
before{@user =... |
# frozen_string_literal: true
module Devise
module Strategies
class Token < Base
def valid?
access_token.present? && uid.present? && client.present?
end
def authenticate!
user = mapping.to.find_by(uid: uid)
success! user if user.valid_token?(access_token, client)
... |
class ArrayGenerator < Generator
protected
def generate_by_type
Array.new(@description["size"].to_i) { self.class.generate(@description["element"]) }
end
def validate_by_type(description)
missing_fields = ["size", "element"] - description.keys
raise Generator::MissingFieldsError.new(missing_fields... |
module CreateHelper
def create_resource(resource, options={}, &block)
Creator.new(resource, options, block, self).request
end
def create_resource_ajax(resource, options={}, &block)
Creator.new(resource, options, block, self).ajax_request
end
class Creator
def initialize(resource, options, block,... |
class SessionsController < ApplicationController
skip_before_filter :authorize
skip_before_filter :admin_authorize
def new
if User.find_by_id(session[:user_id])
redirect_to user_index_path, :notice => '您已经登录'
end
end
def create
sleep(1) #延迟一秒避免暴力破解
if user = User.authenticate(params[:... |
class CreateAttentions < ActiveRecord::Migration
def change
create_table :attentions do |t|
t.integer :id
t.string :medical_notes
t.string :medical_images
t.string :special_conditions
t.references :users
t.references :owners
t.references :patients
t.timestamps
... |
def timer_for
# TODO: Return time taken to execute the given block
beginning = Time.now
yield
return Time.now - beginning
end
def my_map(array)
# TODO: Re-implement the same behavior as `Enumerable#map` without using it! You can use `#each` though.
map_array = []
array.each do |elem|
map_array << yie... |
class User < ApplicationRecord
has_many :flats, dependent: :destroy
before_save { self.email = email.downcase }
validates :login, presence: true, length: { maximum: 50, minimum: 4 }, uniqueness: { case_sensitive: true }
validates :last_name, presence: true, length: { maximum: 50 }
validates :first_name, lengt... |
class CreateTasks < ActiveRecord::Migration
def change
create_table :tasks do |t|
t.string :participant_name
t.string :created_by
t.integer :protocol_id
t.string :visit_name
t.string :arm_name
t.string :task
t.string :assignment
t.date :due_date
t.boolean :is_... |
require 'spec_helper'
describe "address_types/edit" do
before(:each) do
@address_type = assign(:address_type, stub_model(AddressType,
:name => "MyString",
:description => "MyString",
:created_by => 1,
:updated_by => 1
))
end
it "renders the edit address_type form" do
render
... |
require "spec_helper"
RSpec.describe "Day 1: Not Quite Lisp" do
let(:runner) { Runner.new("2015/01") }
describe "Part One" do
it "finds the resulting floor" do
expect(runner.execute!("(())", part: 1)).to eq(0)
expect(runner.execute!("()()", part: 1)).to eq(0)
expect(runner.execute!("(((", pa... |
class NotifyMailer < ApplicationMailer
default from: "from@example.com"
def send_email(purchase,user)
@purchase = purchase
@user = user
mail(to: @user.email, subject: 'Notificacion')
end
end
|
#
# Lint
# `pod lib lint --verbose --no-clean --sources=http://git.souche.com/geliang/cheniu_pod.git,master --use-libraries --allow-warnings'
# Push
# `pod repo push cheniu_pod --verbose --sources=http://git.souche.com/geliang/cheniu_pod.git,master --use-libraries --allow-warnings`
#
Pod::Spec.new do |s|
s.name ... |
# -------------------------------------------------------------------------- #
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# no... |
require_relative '../../spec_helper'
device_type = Puppet::Type.type(:device)
describe device_type do
let :params do
[ :hostname, :account, :access_id, :access_key ]
end
let :properties do
[:display_name, :description, :disable_alerting, :groups, :properties]
end
it 'should have the expected param... |
class UserGroceryList < ActiveRecord::Base
has_many :grocery_lists
has_many :users
end
|
require 'rubygems'
require 'rake/gempackagetask'
require 'rubygems/specification'
require 'date'
require 'test/unit'
GEM = "acts_as_recoverable"
GEM_VERSION = "1.0.0"
AUTHOR = "Revolution Health"
EMAIL = "rails@revolutionhealth.com"
HOMEPAGE = "http://"
SUMMARY = ""
spec = Gem::Specification.new do |s|
s.name = G... |
load "Utils.rb"
##
# La classe Classement permet d'afficher le classement des 5 premiers utilisateurs en fonction du temps réalisé sur chacun des
# chapitres du mode libre
##
# * +window+ la fenêtre de l'application
# * +box+ le layout manager pour placer les éléments à l'écran
# * +indexChapitre+... |
class Admins::CoursesController < ApplicationController
load_and_authorize_resource
# GET /admin/courses
def index
@courses = @courses.page(params[:page])
end
# GET /admin/courses/new
def new
end
# POST /admin/courses
def create
if @course.save
redirect_to admins_courses_path... |
require 'word'
require 'environment'
include Environments
class Parser
attr_accessor :stack
attr_accessor :env
def initialize
@env = Environments::DEFAULT_ENV
@dec_valid = ('0'..'9').to_a + ['.'] + ['-']
@hex_valid = ('0'..'9').to_a + ('a'..'z').to_a
@position = 0
@stack = []
end
def par... |
require 'rails_helper'
RSpec.describe Like, type: :model do
before(:each) do
@user = User.create(first_name: "John", last_name: "Doe", age: 20, email: "blablabla@cool.fr", description: "helloooooooooo woooooooorld",city: @city)
@like = Like.create(user: @user)
end
context "validation" do
it "is val... |
json.array!(@theater_screens) do |theater_screen|
json.extract! theater_screen, :id, :theater_id, :screen_no, :is_deleted
json.url theater_screen_url(theater_screen, format: :json)
end
|
module AdjacencyList
#mixin for the Knight class.
# a list of legal moves from any given position on the board.
def build_adj_list
completed_list = []
for x in 0..7
for y in 0..7
temp_list = []
temp_list << [x - 2,y - 1] unless (x - 2 < 0... |
Gem::Specification.new do |spec|
spec.name = 'lita-fortune'
spec.version = '0.0.8'
spec.authors = ['Chris Horton']
spec.email = ['hortoncd@gmail.com']
spec.description = %q{A Lita handler for fortune cookies.}
spec.summary = %q{A Lita handler for fortune cookies.}
spec... |
require 'json'
require 'rest_client'
require 'pry'
require 'awesome_print'
require 'colorize'
system("clear")
puts("Starting up...")
if ARGV.first
if ARGV.first.include?("r/")
reddit_hash = JSON.parse(RestClient.get('http://reddit.com/' + ARGV.first + '.json'))
else
reddit_hash = JSON.parse(RestClient.get... |
class Province < ApplicationRecord
has_many :city
validates :province,presence:true,
length:{minimum:2}
end
|
class ManageIQ::Providers::Kubevirt::InfraManager::Provision < MiqProvision
include_concern 'Cloning'
include_concern 'StateMachine'
#
# The ManageIQ core calls this method during the provision workflow to get the name of the object that is being
# provisioned, only to include it in the generated log message... |
# = vickey.rb
#
# Description:: VIC cipher substitution key
# Author:: Ollivier Robert <roberto@keltia.net>
# Copyright:: © 2001-2013 by Ollivier Robert
#
# $Id: vickey.rb,v f9e55abc2763 2013/03/10 18:19:19 roberto $
require 'key/base'
require 'key/base'
module Key
# == VICKey
#
# The VIC cipher is described o... |
object false
child @slides => :slides do
attributes :id, :title, :presentation, :attachment_file_name, :position, :url
node(:image_url_original) { |s| s.attachment.url }
node(:image_url_mini) { |s| s.attachment.url(:mini) }
node(:image_url_small) { |s| s.attachment.url(:small) }
node(:image_url_medium) { |s|... |
class PagesController < ApplicationController
def top
@matches = Match.past_week.presence || Match.before(Time.zone.now).limit(9)
end
end
|
require 'test_helper'
require 'minitest/autorun'
require 'chartup'
class ChartTest < MiniTest::Test
def test_Chart_must_be_initialized_with_string
assert_raises(Chartup::ArgumentError) { Chartup::Chart.new(5) }
end
def test_Chartup_headers_are_loaded_into_chart
t = "Symphony No. 9"
c = "Beethoven"... |
class ClioController < ApplicationController
def callback
if params[:code]
@user = User.find_or_create_by_clio_code(params[:code])
if @user
sign_in @user
redirect_to guardianships_path
end
else
redirect_to new_user_session_path
end
end
def log_in
redirect_t... |
class CreateTransactions < ActiveRecord::Migration[5.2]
def change
create_table :transactions do |t|
t.references :user, foreign_key: true, null: false
t.references :transaction_with, null: false
t.integer :transaction_state, null: false
t.decimal :amount, null: false
t.timestamps
... |
require 'spec_helper'
describe "social_networks/new.html.slim" do
before(:each) do
client = assign(:client, stub_model(Client, :name => "Name", :id => 1))
Client.stub(:find).and_return(client)
info_social_network = assign(:info_social_network, stub_model(InfoSocialNetwork, :name => 'Twitter', :id => 1))... |
class RecipeSerializer < ActiveModel::Serializer
belongs_to :user
has_many :recipe_ingredients
has_many :ingredients, through: :recipe_ingredients
attributes :id, :name, :image, :ingredients
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
include SessionsHelper
private
def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Пожалуйста залогиньтесь"
redirect_to login_ur... |
require 'time'
require 'csv'
ALL_ROOMS_CSV = "data/all_rooms.csv"
ALL_RESERVATIONS_CSV = "data/all_reservations.csv"
ALL_BLOCKS_CSV = "data/all_blocks.csv"
STANDARD_RATE = 200
MAX_BLOCK_SIZE = 5
module Helpers
def non_zero_integer?(num)
if num.class != Integer
return false
elsif num.nil? || nu... |
require 'watir-webdriver'
RSpec.describe do
describe "basic test for drone" do
it "simple test return true" do
browser = Watir::Browser.new :chrome
browser.goto "http://www.benharrington.com"
expect(browser.title).to eq("Ben Harrington")
end
end
end
|
class UserMailer < ActionMailer::Base
default from: "noreply@supplybetter.com",
bcc: "partreach@gmail.com"
include SessionsHelper
MATT = "matt@supplybetter.com"
ROB = "rob@supplybetter.com"
JAMES = "james@supplybetter.com"
CUSTOMER_SERVICE = "robert@supplybetter.com"
INTERNAL_EMAIL_DISTRIBUT... |
require 'spec_helper'
describe MDB::Membership do
describe :relationships do
it "should validate presence of user and group" do
# Not valid without any relations
membership = build(:membership, user: nil,
group: nil)
membership.should_not be_valid... |
class CreateContents < ActiveRecord::Migration[5.0]
def change
create_table :contents do |t|
t.text :ct
t.integer :floor
t.references :post, foreign_key: true
t.references :user, foreign_key: true
t.time :last_reply_time
t.timestamps
end
add_index :contents, [:user_id, :... |
module WillScanString
class StringScanner
def register_replacement( pattern, replacement )
@replacements = [] if @replacements.nil?
@replacements << [ pattern, replacement, @replacements.last.present? ? @replacements.last[2] + (@replacements.last[0].is_a?(Regexp) ? @replacements.last[0].capture_groups.length :... |
module BinarySearchTree
Infinite_Range = -1.0/0..1.0/0
def binary_search_tree? valid_range=Infinite_Range
return false unless valid_range.include? @value
return false if @left and @value < @left.value
return false if @right and @value > @right.value
# left nodes can't be bigger than the upper boun... |
FactoryGirl.define do
factory :census do
sequence(:name) {|n| "census #{n}"}
end
factory :survey do
end
factory :locality do
sequence(:city) {|n| "city#{n}"}
sequence(:state) {|n| "S#{n}"}
end
factory :user do
sequence(:email) {|n| "user#{n}@example.com"}
first_name "Phil"
last... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile for Vagrant Machine
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version
Vagrant.configure("2") do |config|
# The Name of the Vagrant Box that you will be using goes here
# e.g. I used "centos/7" vir... |
#==============================================================================
# Item Drop Ranks
# Version: 1.0.2
# Author: modern algebra (rmrk.net)
# Date: 28 September, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# In effect, this script is d... |
class CreateMomentumCmsFields < ActiveRecord::Migration
def up
create_table :momentum_cms_fields do |t|
t.references :document, index: true
t.references :field_template, index: true
t.string :identifier
t.timestamps
end
MomentumCms::Field.create_translation_table! value: :text
... |
class LoginPage < SitePrism::Page
set_url 'https://vivosync-front-homol.whitelabel.com.br'
element :btn_partner, 'a[data-partner=movel]'
element :msisdn, 'input[id=usernumber]'
element :password, 'input[id=password]'
element :login, 'input[id=elogin_submit]'
def with(user, pass)
self.bt... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
#... |
class FTMGATE
class FTM
attr_accessor :gid, :control, :input1, :input2, :output1, :output2
def initialize(gid, control, input1, input2)
@gid = gid
@control = control
@input1 = input1
@input2 = input2
@output1 = check(@input1)
@output2 = check(@input2)
end
def in... |
require "net/http"
require "uri"
module Picolib
module OAuth2
class API
def initialize(end_point, headers=nil, opts={})
@end_point = end_point
@debug = opts[:debug]
if headers.class == String
@args = {headers: {authorization: headers}}
elsif headers.clas... |
# frozen_string_literal: true
module GraphQL
# This error is raised when `Types::ISO8601Date` is asked to return a value
# that cannot be parsed to a Ruby Date.
#
# @see GraphQL::Types::ISO8601Date which raises this error
class DateEncodingError < GraphQL::RuntimeTypeError
# The value which couldn't be en... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.