text stringlengths 10 2.61M |
|---|
class AuthenticationsController < ApplicationController
def index
@authentications = Authentication.all
end
def create
omniauth = request.env["omniauth.auth"]
authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
if authentication
if current_user &&... |
require "features_helper"
RSpec.feature "To test overdue appointment functionality", type: :feature do
let(:ihmi) { create(:organization, name: "IHMI") }
let(:ihmi_facility_group) { create(:facility_group, organization: ihmi, name: "Bathinda") }
let(:test_facility) { create(:facility, facility_group: ihmi_facili... |
class Company < ApplicationRecord
belongs_to :country, optional: true
belongs_to :company, optional: true
has_many :companies, dependent: :destroy
has_many :appointments, dependent: :destroy
has_many :offshore_fields, dependent: :destroy
validates :company_name, presence: true
end
|
#!/usr/bin/env ruby
# encoding: UTF-8
#
# Copyright © 2012-2014 Cask Data, Inc.
#
# 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 r... |
module DcrugDna
class Decoder
def initialize(base_pair_sequence)
@base_pair_sequence = base_pair_sequence
end
def decode
sequence_as_ordinals.map { |decimal| decimal.chr }.join
end
private
attr_reader :base_pair_sequence
def base_pairs_as_quaternary
base_pair_sequence... |
require 'spec_helper'
describe UsersHelper do
describe "gravatar_for" do
before do
@user = User.new(name: "Mr. Bennett", email: "mail@mail.com")
@gravatar_base_url = "https://secure.gravatar.com/avatar/"
@gravatar_id = Digest::MD5::hexdigest(@user.email.downcase)
end
it "should includ... |
class Job < ApplicationRecord
validates :title, :level_of_interest, :city, presence: true
belongs_to :company
belongs_to :category, optional: true
has_many :comments
def self.company_jobs_index
Company.find(:company_id).jobs
end
def self.sort(params)
if params == 'location'
order(:city... |
module SyntaxHighlighting
# Represents a tmLanguage file.
#
class Language
# - parameter contents: Hash
#
def initialize(contents, parent_repository = nil)
@name = contents["name"]
@scope_name = contents["scope_name"]
@repository = Repository.new(
{ "$self" => self }.merge(c... |
module Backend
class UsersController < BackendController
before_filter :find_user, only: [:show, :edit, :update, :destroy, :impersonate]
def index
@users = User.all
respond_to do |format|
format.html
format.csv { send_data @users.to_csv }
end
end
def show
end
... |
# coding: utf-8
class Lexer
# 最初に、我々の言語でのspecial keywordsを定数で定義します。
# First we define the special keywords of our language in a constant.
# 後ほど、これはtokenizingの過程で、
# It will be used later on in the tokenizing process to disambiguate
# keywordと識別子(メソッド名、ローカル変数、その他)と区別するために使われます。
# an identifier (method name,... |
class User < ActiveRecord::Base
@@count = 0
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :id, :e... |
class ProductOrder
include ActiveModel::Model
attr_accessor :authenticity_token, :token, :postal_code, :prefecture_id, :city, :address, :building_name, :phone_number, :user_id, :product_id
# バリデーション
validates :token, presence: true
POSTAL_CODE_REGEX = /\A\d{3}[-]\d{4}\z/.freeze
validates :postal_code, pres... |
require 'nokogiri'
require 'date'
require 'ostruct'
require 'delegate'
require 'uri'
# encoding: utf-8
class ITunesLibrary < DelegateClass( OpenStruct )
VERSION="0.0.1"
def initialize itunes_file
@db={}
File.open( itunes_file, 'r' ) {|io|
@parser=Nokogiri::XML::Reader io
... |
require 'rails_helper'
RSpec.describe User, :type => :model do
it { should have_many(:plays) }
it { should have_many(:histories) }
it { should have_many(:words) }
it { should validate_presence_of(:email) }
describe "#premium?" do
it "should return true if the user is premium" do
user = Fabricate(... |
class SongsController < ApplicationController
def index
@songs = Song.all
end
def new
@song = Song.new
end
def create
@song = Song.create(song_params)
if @song.save #If saving the song was successful
redirect_to @song #Go to the show view of the song
else
render "new" #Go to the new view ... |
# frozen_string_literal: true
# rubocop:todo all
class UsingHash < Hash
class UsingHashKeyError < KeyError
end
def use(key)
wrap(self[key]).tap do
delete(key)
end
end
def use!(key)
begin
value = fetch(key)
rescue KeyError => e
raise UsingHashKeyError, e.to_s
end
w... |
class FixBlankRanks < ActiveRecord::Migration
def change
change_column_default :songs, :rank, 0
end
end
|
class Feedback < ActiveRecord::Base
belongs_to :user
scope :latest, -> { order(created_at: :desc) }
end
|
# == Schema Information
#
# Table name: traffics
#
# id :integer not null, primary key
# user_id :integer
# bind_id :integer
# start_at :datetime
# period :string(255)
# remote_ip ... |
class AddTimestampsToApiResponses < ActiveRecord::Migration[5.1]
def change
add_timestamps :api_responses, null: false, default: DateTime.current
change_column_default :api_responses, :created_at, nil
change_column_default :api_responses, :updated_at, nil
end
end
|
#!/usr/bin/env ruby
#this will work unless the system has more than one ext4 part
require 'sensu-plugin/check/cli'
class DiskSpace < Sensu::Plugin::Check::CLI
option :warn,
short: '-w WARN',
proc: proc {|a| a.to_f},
default: 80
option :crit,
short: '-c CRIT',
proc: proc {|a| a.to_f},
default: 90
option :s... |
require 'spec_helper'
describe Author do
context "when the password matches the password confirmation" do
it "is valid" do
subject.password = "Pee-Wee Herman"
subject.password_confirmation = "Pee-Wee Herman"
expect(subject).to be_valid
end
end
context "when the password does not match... |
class Product < ApplicationRecord
belongs_to :user
validates :product_name, presence: true, length: { minimum: 1 }
def self.search(term, per_page, current_page)
if term
Product.offset((current_page-1) * per_page).limit(per_page).where("category LIKE ?", "%#{term}%")
else
... |
class CreatePlaces < ActiveRecord::Migration
def change
create_table :places do |t|
t.references :province, :null => false
t.string :name, :null => false, :limit => 50
t.string :key, :null => false, :limit => 30
t.integer :videos_count, :default => 0
t.integer ... |
begin
require 'syslog_protocol'
rescue LoadError
raise 'Gem syslog_protocol is required for remote logging using the Syslog protol. Please add the gem "syslog_protocol" to your Gemfile.'
end
module SemanticLogger
module Formatters
class Syslog < Default
attr_accessor :level_map, :options, :facility
... |
module RSence
module Plugins
# Include this module in your subclass of {Plugin__ Plugin} to enable sub-plugin bundles in another plugin bundle.
#
# The plugins loaded using this system are isolated from system-wide plugins.
#
# To address them from this plugin, use +@plugin_plugin... |
require 'rails_helper'
describe BusinessService do
context "retrieves businesses by keyword" do
it ".get_businesses_by_keyword" do
business = BusinessService.new("39.7541", "105.0002")
expect(business.get_businesses_by_keyword("food")).to have_key("businesses")
... |
class CreateConversation < ActiveRecord::Migration
def change
create_table :conversations do |t|
t.integer :user_id
t.integer :empresa_request_id
t.boolean :unread_user, :default=>false
t.boolean :unread_empresa, :default=>false
t.timestamps
end
add_index :conversation... |
require 'gmail'
class SantaMailer
def initialize(assignments, host_username, host_password)
@assignments = assignments
@gmail = Gmail.connect(host_username, host_password)
end
def send
@assignments.each do |gifter, giftee|
mail_to(gifter, giftee)
end
end
def mail_to(gifter, giftee)
... |
class ApplicationController < ActionController::Base
def after_sign_in_path_for(resource)
case resource
when Admin
subjects_path #pathは設定したい遷移先へのpathを指定してください
when Customer
root_path #ここもpathはご自由に変更してください
end
end
end
|
puts "Basic classes, constructor, scope and instatiation"
class Person
@@people_count = 0
def initialize(name, age, profession)
@name = name
@age = age.to_s
@profession = profession
@@people_count += 1
puts "Person " << @@people_count.to_s << ": My name is " << @name << "... |
class ResultsController < ApplicationController
def create
@result = Result.find_or_initialize_by(user_id: result_params[:user_id], monster_id: result_params[:monster_id])
@result.update_attributes({
status: result_params[:status],user_id: result_params[:user_id], monster_id: result_params[:monster_id]
... |
require 'rails_helper'
describe ProjectsController do
describe "POST #create" do
context "with valid attributes" do
it "creates a new project" do
expect {
post :create, project: FactoryGirl.attributes_for(:project)
}.to change(Project, :count).by(1)
end
it "responds ... |
class ThemesController < ApplicationController
before_action :set_theme, only: [:show]
def index
@themes = Theme.all
end
def show
@figurines = ScraperService.new(@theme.name).call
TestJob.perform_later
end
def new
@themes = Theme.new
end
def create
@theme = Theme.new(theme_params)
... |
# GSPlan - Team commitment planning
#
# Copyright (C) 2008 Jan Schrage <jan@jschrage.de>
#
# This program 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 Foundation, either version 3 of the License,
# or (at your option) ... |
class NotificationMailer < ActionMailer::Base
include Sidekiq::Mailer
default from: 'notifications@' << Rails.application.secrets.domain_name
def new_episode_added episode_id, user_email
@episode = Episode.find episode_id
mail(to: user_email, subject: 'MovieMan notification')
end
end
|
class ConversationsQuery < Types::BaseResolver
description "Gets all conversations for the current user"
type Outputs::ConversationType.connection_type, null: false
policy ApplicationPolicy, :logged_in?
def authorized_resolve
Conversation.for_user(current_user).order_by_most_recent_message
end
end
|
require 'rails_helper'
describe CourseApi::Purchase do
let(:user) { create(:user) }
let(:auth_token) { user.auth_token }
let(:headers) do
{
'Content-Type' => 'application/json',
'Authorization' => auth_token
}
end
let(:course) { create(:course) }
let(:order) { create(:order, user: us... |
Rails.application.routes.draw do
root to: 'static_pages#home', as: 'home'
get 'about(/:id)', to: 'static_pages#about', as: 'about'
end
|
module Interpreter
class Processor
module TokenProcessors
# QoL note: returns the rounded log if it gives the original argument when
# raising the same base
def process_logarithm(_token)
(base, argument) = resolve_parameters_from_stack!
validate_type [Numeric], base
vali... |
class Download < ActiveRecord::Base
def uploaded_file=(file_field)
self.name = base_part_of(file_field.original_filename)
self.content_type = file_field.content_type.chomp
self.data = file_field.read
end
def base_part_of(file_name)
File.basename(file_name).gsub(/[^\w._-]/, '')
end
e... |
# include into mail-sending scenarios
module MailHelper
extend ActiveSupport::Concern
included do
after(:each) do
ActionMailer::Base.deliveries.each do |mail|
if mail.body.to_s[/translation missing: (.*)"/]
fail "There are missing translations: #{Regexp.last_match(1)}"
end
... |
class CreateBootcamps < ActiveRecord::Migration
def change
create_table :bootcamps do |t|
t.string :name
t.string :location
t.date :starts_at
t.date :ends_at
t.integer :level
t.integer :community_price
t.integer :normal_price
t.integer :supporter_price
t.time... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe PropertiesController, type: :controller do
let(:current_user) { create(:user) }
let(:session) { { user_id: current_user.id } }
let(:landlord) { create(:landlord) }
let(:tenant) { create(:tenant) }
let(:params) { {} }
describe 'PUT #updat... |
describe "Login com Cadastro", :Login3 do
before(:each) do
visit "/access"
end
after(:each) do
sleep 2
end
it "logando" do
within("#login") do #Dentro do elemento pai "#login" pesquise:
find("input[name=username]").set "stark" #Elemento filho username
find("input[name=password]").set... |
require 'spec_helper'
require 'mspire/isotope'
describe Mspire::Isotope do
specify 'Mspire::Isotope[] accesses isotopes by element' do
carbon12 = Mspire::Isotope[:C][0] # the lightest carbon isotope
carbon12.element.should == :C
carbon12.mass_number.should == 12
carbon12 = Mspire::Isotope[:C].find... |
require 'spec_helper'
describe User do
it 'should create one with a valid password and email' do
user = User.create!(name: 'example', email: 'example@domain.com', password: 'example1', password_confirmation: 'example1')
user.id.should be_present
end
it 'should not allow a user creating without a vali... |
Rails.application.routes.draw do
devise_for :admins
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
devise_for :users, path: ''
resources :users, only: [:new, :create]
authenticated :user do
root 'users#dashboard', as: :dashboard
end
get 'invitations/accept', as: :invitation, to: 'invitation... |
class MonsterReward < ActiveRecord::Base
attr_accessible :rank, :action, :drop_rate, :item_id, :monster_id
belongs_to :monster, inverse_of: :monster_rewards
belongs_to :item, inverse_of: :monster_rewards
end
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: photoposts
#
# id :bigint not null, primary key
# aasm_state :string
# ban_reason :string
# comments_count :integer default(0)
# content :text
# picture :string
# rating_count :integer ... |
class Task < ApplicationRecord
belongs_to :card
validates :name, presence: true
enum status: [:todo, :doing, :paused, :pedding, :done]
end
|
class AddLinksToEvents < ActiveRecord::Migration[6.1]
def change
add_column :events, :calendar_link, :string
add_column :events, :meeting_link, :string
end
end
|
# Copyright (c) 2007, The RubyCocoa Project.
# Copyright (c) 2005-2006, Jonathan Paisley.
# All Rights Reserved.
#
# RubyCocoa is free software, covered under either the Ruby's license or the
# LGPL. See the COPYRIGHT file for more information.
# Takes a built RubyCocoa app bundle (as produced by the
# Xcode/Project... |
class Api::V1::StoresController < ApplicationController
def index
if params[:count]
stores = Store.all.limit(params[:count].to_i).select(:id, :name)
else
stores = Store.all.select(:id, :name)
end
render json: {
message: "success",
data: stores
}
end
def search
... |
# This file contains all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
root = Page.root
# About Page
about = Article.create title: 'About',
image_upload_url:"http://st-cuthmans.s3.amazonaws.co... |
require "spec_helper"
describe ExternalRoutes do
context "routes drawing from config/routes" do
it 'routes external/success/index to external::success#index' do
expect(get: "external/success/index").to route_to(
controller: "external/success",
action: "index"
)
end
end
contex... |
module Radiator
module Utils
def hexlify(s)
a = []
if s.respond_to? :each_byte
s.each_byte { |b| a << sprintf('%02X', b) }
else
s.each { |b| a << sprintf('%02X', b) }
end
a.join.downcase
end
def unhexlify(s)
s.split.pack('H*')
end
def v... |
require 'fileutils'
Dir[File.join(File.dirname(__FILE__), "actions", "*.rb")].each do |action|
require action
end
class Thor
module Actions
attr_accessor :behavior
# On inclusion, add some options to base.
#
def self.included(base) #:nodoc:
return unless base.respond_to?(:class_option)
... |
class AddUrlHtmlToYtVideo < ActiveRecord::Migration
def change
add_column :yt_videos, :url_html, :text
end
end
|
module TrackerApi
module Resources
class ReviewType
include Shared::Base
attribute :id, Integer
attribute :project_id, Integer
attribute :name, String
attribute :hidden, Boolean
attribute :created_at, DateTime
attribute :updated_at, DateTime
attribute :kind, String... |
class DecksController < ApplicationController
before_action :set_deck, only: [:show, :edit, :update, :destroy]
#added this
before_action :authenticate_user!, only: [:create, :index ]
# GET /decks
# GET /decks.json
def index
# @decks = Deck.all
@decks = Deck.all
render json: @decks, root: false... |
#encoding: utf-8
class Web::Admin::PartnerProductItemsController < Web::Admin::ApplicationController
before_filter :set_partner_product, except: [:edit, :destroy]
def new
@ppi = @pp.partner_product_items.build
end
def create
@ppi = @pp.partner_product_items.build(params[:partner_product_item])
if... |
require "spec_helper"
require "sentry/integrable"
RSpec.describe Sentry::Integrable do
module Sentry
module FakeIntegration
extend Sentry::Integrable
register_integration name: "fake_integration", version: "0.1.0"
end
end
it "registers correct meta" do
meta = Sentry.integrations["fake_i... |
module Mahjong
class Wind
WINDS = %i(east south west north)
delegate :hash, :to_s, :to_sym, to: :@sym
class << self
def all
WINDS.map {|w| new(w) }
end
end
def initialize(sym)
@sym = sym
end
def next
self.class.new(WINDS.zip(WINDS.rotate).to_h[@sym])
... |
class Admin::CSV::FacilityValidator
def self.validate(*args)
new(*args).validate
end
def initialize(facilities)
@facilities = facilities
@errors = []
end
attr_reader :errors
def validate
at_least_one_facility
duplicate_rows
facilities
self
end
def at_least_one_facility
... |
require 'formula'
#Builds Boost with clang and c++11
class Boost160 < Formula
homepage 'http://boost.org'
url 'http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz'
sha256 '21ef30e7940bc09a0b77a6e59a8eee95f01a766aa03cdfa02f8e167491716ee4'
def install
system "./bootstrap.sh", "--li... |
# -*- coding: utf-8 -*-
require "lucie/debug"
module SSH::Path
include Lucie::Debug
PUBLIC_KEY_NAME = "id_rsa.pub"
PRIVATE_KEY_NAME = "id_rsa"
#
# Returns <tt>[ssh home]/id_rsa.pub
#
#--
# [FIXME] dryrun かどうかでの場合分け。authorized_keys では
# @ssh_home を見てるのでどっちかにすべき。
#++
def public_key
... |
class DelayedJob < ApplicationRecord
has_one :feed_for_email, class_name: 'Feed', foreign_key: :delayed_job_email_id, dependent: :nullify
has_one :feed_for_webpush, class_name: 'Feed', foreign_key: :delayed_job_webpush_id, dependent: :nullify
end
|
class CreateProducersOwnerIdIndex < ActiveRecord::Migration
def up
add_index(:producers, :owner_id, { name: "producers_owner_id_index" })
end
def down
remove_index(:producers, name: "producers_owner_id_index")
end
end
|
class AddDetailFieldsToRightsDeclaration < ActiveRecord::Migration
def change
add_column :rights_declarations, :copyright_jurisdiction, :string
add_column :rights_declarations, :copyright_statement, :string
add_column :rights_declarations, :access_restrictions, :string
end
end
|
require 'test/unit'
require 'html5_tokenizer'
class TestTokenizer < Test::Unit::TestCase
def tokens(tokenizer)
tokens = []
tokenizer.run { |t| tokens << t }
tokens
end
def tokenize(html)
tokenizer = Html5Tokenizer::Tokenizer.new()
tokenizer.insert(html)
tokenizer.eof()
tokens(tokeniz... |
class AddCodeToContent < ActiveRecord::Migration
def self.up
add_column :contents, :code, :string, :limit => 10
add_index :contents, :code, :unique => true
end
def self.down
remove_column :contents, :code
end
end
|
#!/usr/bin/env ruby
#
# Given an mxn matrix, design a function that will print out the contents of the matrix in spiral format.
# Spiral format means for a 5x5 matrix given below:
#
# [ 1 2 3 4 5 ]
# [ 6 7 8 9 0 ]
# [ 1 2 3 4 5 ]
# [ 6 7 8 9 0 ]
# [ 1 2 3 4 5 ]
# path taken is:
#
# [ > > > > > ]
# [ > > > > v ]
# [ ^... |
#
# Mixin for the Merb::DataMapperSession which provides for authentication
#
module Authentication
class DuplicateStrategy < Exception; end
class MissingStrategy < Exception; end
class NotImplemented < Exception; end
@@login_strategies = StrategyContainer.new
def self.login_strategies
@@login_stra... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'statics#landing'
get 'landing', to: 'statics#landing'
get 'home', to: 'statics#home'
get 'about', to: 'statics#about'
get 'contact', to: 'statics#contact'
get 'thankyou', t... |
=begin
input : string
output : is a boolean
steps :
1: define a method that outputs a string
2: compare str to itself reversed.
=end
def palindrome?(str)
str == reverse(str)
end
def reverse(str)
new_str = ''
count = str.size
loop do
break if count == 0
new_str << str[count - 1]
count -= 1... |
# -*- coding: utf-8 -*-
# "Vorwort" => VII
# "Inhaltsverzeichnis" => IX
PART = 0
CHAPTER = 1
SECTION = 2
EXKURS = 3
TOCLIST =
[
["EINLEITUNG", [1, PART]],
["I. Nationalökonomie und Praxeologie", [1, SECTION]],
["II. Das Problem einer Wissenschaft vom menschlichen Handeln", 3],
["III. Nationalökonomie und Zielwahl",... |
class AddForeignKeyToMoussaillon < ActiveRecord::Migration[5.1]
def change
add_reference :moussaillons, :gossip, foreign_key: true
end
end
|
class OrdersController < ApplicationController
before_action :authenticate_user!, except: [:notify]
def preload
bead = Bead.find(params[:bead_id])
today = Date.today
orders = bead.orders.where("start_date >= ? OR end_date >= ?", today, today)
render json: orders
end
def preview
... |
#! /usr/bin/env ruby
#
# Copyright © 2014 Andrew DeMaria (muff1nman) <ademaria@mines.edu>
#
# All Rights Reserved.
require 'pathname'
require 'uri'
require 'optparse'
GIT_ENDING = ".git"
def base_name name
uri = URI.parse(name)
base = File.basename(uri.path)
base = base[0..-(GIT_ENDING.length+1)] if base.end_w... |
require 'rails_helper'
describe 'User visits purchase index page' do
context 'as an admin' do
it 'allows admin to see all purchases' do
admin = User.create!(username: 'Admin', password: 'pass', role: 1)
program = Program.create(name: 'Denver Fire Department')
vendor = Vendor.create(name: 'Benny... |
require 'spec_helper'
require 'redis_cache'
require 'redis'
describe RedisCache do
let!(:redis){ Redis.new }
let!(:redic){ Redic.new }
before(:each){ described_class.stub(:redis){ redic } }
after(:all){ described_class.disable! }
let!(:var_name){ described_class.var_name 'SomeClass', 123 }
let!(:redis_ke... |
class CreateWorkerFamiliars < ActiveRecord::Migration
def change
create_table :worker_familiars do |t|
t.string :paternal_surname
t.string :maternal_surname
t.string :names
t.string :relationship
t.date :dateofbirth
t.string :dni
t.timestamps
end
end
end
|
Rails.application.routes.draw do
devise_for :users
root 'home#index'
get '/about', to: 'home#show'
get '/songs', to: 'home#index'
get '/songs/:id', to: 'home#index'
namespace :api do
namespace :v1 do
resources :songs, only: [:index, :show, :create, :update, :destroy] do
resources :blocks,... |
require_relative '../../lib/models/assembly.rb'
RSpec.describe Assembly do
describe 'instance methods' do
let(:assembly) { Assembly.new }
it 'should respond to id' do
expect(assembly).to respond_to :id
end
# When the class itself is in the `describe` method, RSpec's one... |
ActiveAdmin.register AccountProgram do
actions :all, except: [:update, :destroy, :edit, :create, :new]
index do
column :representative do |i|
i.representative.abbreviated_name
end
column :account
column 'Policy Number', :account do |i|
i.account.policy_number_entered
end
column ... |
class BucketPolicy
attr_reader :user, :bucket
def initialize(user, bucket)
@user = user
@bucket = bucket
end
def new?
@user.is_local_creator?(Bucket) or
@user.is_global_creator?
end
def create?
new?
end
def edit?
@user.is_local_editor?(@bucket) or
@user.is_global_editor?
end
def update?
e... |
# == 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
#... |
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# commentable_id :integer
# commentable_type :string
# text :text
# response_to_id :integer
# user_id :integer
# created_at :datetime not null
# updated_at :... |
class AddCrawledInfoToBlogs < ActiveRecord::Migration
def change
add_column :blogs, :crawl_started_at, :timestamp
add_column :blogs, :crawl_finished_at, :timestamp
add_column :blogs, :crawled_pages, :integer, :default => 0
end
end
|
require 'ProcessMemory'
require 'ProcessMemory/pe/header'
require 'ProcessMemory/pe/sections'
module PE
# メモリ上のPEフォーマットを扱う
class PEModule
# コンストラクタ
# @param mem [ProcessMemoryEx] 入力元
# @param base [Integer] base address
def initialize(mem, base = nil)
@mem = mem
@base_addr = base || me... |
# input: array of string
# output: array of string without vowels
# capital letters are also included, case insensitive
# map method to transform array and delete any vowels
def remove_vowels(array)
array.map do |elements|
elements.delete('aeiouAEIOU')
end
end
|
# calculator
require 'yaml'
MESSAGES = YAML.load_file('calculator_messages.yml')
puts MESSAGES.inspect
def prompt(message)
puts "=> #{message}"
end
result = nil
number1 = nil
number2 = nil
name = nil
operation = nil
def integer?(input)
input.to_i.to_s == input
end
def float?(input)
Float(input) rescue false... |
class Image < ActiveRecord::Base
before_validation :fetch_flickr_details
def self.from_decade(decade_image)
i = Image.new(decade_image)
i.full_path_url = i.date.strftime("http://cdn.m.ac.nz/decade/images/%Y%m%d.jpg")
i.thumbnail_url = i.date.strftime("http://cdn.m.ac.nz/decade/images/small/%Y%m%d.... |
When /^I agree with the terms of use$/ do
check "user_terms"
end
When /^I click "(.*?)"$/ do |link|
click_on link
end
When /^I click "(.*?)" button$/ do |button|
click_button button
end
Then /^I should sign up successfully$/ do
page.should have_selector("li#sign-out-btn")
end
Then /^I should not sign up suc... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'Retryable writes errors tests' do
let(:options) { {} }
let(:client) do
authorized_client.with(options.merge(retry_writes: true))
end
let(:collection) do
client['retryable-writes-error-spec']
end
context 'when the ... |
# frozen_string_literal: true
# Controller for date ranges associated to slides
class DateRangesController < ApplicationController
before_action :set_date_range, only: %i[show edit update destroy]
before_action :authenticate_user!
before_action :authorize
# GET /date_ranges
# GET /date_ranges.json
def ind... |
# encoding: UTF-8
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'solidus_sendwithus'
s.version = '2.2.0'
s.summary = 'SendWithUs integration'
s.license = 'BSD-3'
s.required_ruby_version = '>= 1.9.3'
s.author = 'Stembolt Technologies, Nebulab'
s.email ... |
class Politician <Person
attr_accessor :name, :party
def initialize (name, party)
@name = name
@party = party
end
end
|
# 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.