text stringlengths 10 2.61M |
|---|
require "application_system_test_case"
class CounselorsTest < ApplicationSystemTestCase
setup do
@counselor = counselors(:one)
end
test "visiting the index" do
visit counselors_url
assert_selector "h1", text: "Counselors"
end
test "creating a Counselor" do
visit counselors_url
click_on ... |
class AddStatusAndStatusChangedAtToLearningTrack < ActiveRecord::Migration
def change
add_column :learning_tracks, :status, :string
add_index :learning_tracks, :status
add_column :learning_tracks, :status_changed_at, :datetime
end
end
|
class ExamsController < ApplicationController
#before_action :set_exam, only: [:show, :edit, :update, :destroy]
#before_action :authenticate_teacher!, only: [ :edit, :update, :destroy]
#before_action :authenticate_student!, only: [:show,:submit_exam]
# GET /exams
# GET /exams.json
def index
@exams = Ex... |
class ProductsController < ApplicationController
helper_method :cart
def index
end
def add
cart << products_params
redirect_to root_path
end
private
def products_params
params.require(:product)
end
end |
# frozen_string_literal: true
RSpec.describe Api::V1::Admin::Users::ResetPasswordPolicy do
subject { described_class }
let!(:user) { create(:user) }
let!(:admin_user) { create(:user, :admin) }
permissions :create? do
context 'not admin' do
it 'denies access' do
expect(subject).not_to permit... |
class AddImagesSnippetToOrderGroups < ActiveRecord::Migration
def change
add_column :order_groups, :images_snippet, :text
rename_column :order_groups, :email_snippet, :parts_snippet
end
end
|
module Supports
class SocialGroupSupport
attr_reader :social_group, :group_user, :micropost
def initialize args = {}
@social_group = args[:social_group]
@group_user = args[:group_user]
@micropost = args[:micropost]
end
def group_microposts
social_group.feed
end
def n... |
require "test_helper"
class SchemaChangeTest < IdentityCache::TestCase
class AddColumnToChild < ActiveRecord::Migration
def up
add_column :associated_records, :shiny, :string
end
end
class AddColumnToDeepChild < ActiveRecord::Migration
def up
add_column :deeply_associated_records, :new_c... |
require 'typhoeus'
module HexFormatter
class DijixCurl
def get(hex)
formatter = HexFormatter::Ipfs.new
ipfs_address = formatter.encode(hex)
data = JSON.parse(::Typhoeus::Request.get("https://ipfs.digix.global/ipfs/#{ipfs_address}").response_body)
return data
end
end
end
|
module Webmoney
# Presets for interfaces
def interface_urls
{
:create_invoice => w3s_url + 'XMLInvoice.asp', # x1
:create_transaction => w3s_url + 'XMLTrans.asp', # x2
:operation_history => w3s_url + 'XMLOperations.asp', # x3
:outgoing_invoices => w3s_url + 'XM... |
# This file was generated by GoReleaser. DO NOT EDIT.
class Skeema < Formula
desc "Skeema is a tool for managing MySQL tables and schema changes in a declarative fashion using pure SQL."
homepage "https://www.skeema.io/"
version "v1.4.5"
bottle :unneeded
if OS.mac?
url "https://github.com/skeema/skeema/r... |
# purpose:
# find a suitable non-modal setup for AEditor
# which works both for windowed mode and fullscreen mode.
#
# questions:
# Q: how to hide mainwindow? so it still appears in taskbar in win32?
#
# status:
# shutdown is ok
#
# checklist:
# ALT-F4 must invoke shutdown on both dialog and window
# quit button mus... |
# This model tracks the list of skills users can endorse eachother on.
class Skill < ApplicationRecord
has_many :endorsements
has_many :noteskills
validates_presence_of :name
validates_presence_of :image_url
def notes
self.noteskills.map(&:note)
end
end
|
require 'set'
require_relative 'helpers/console'
require_relative 'helpers/constants'
require_relative 'helpers/menu'
require_relative 'base_menu/list_menu'
class EventMenu
def initialize(record_set)
@record_set = record_set
end
def run
return if !Menu.check_empty_notebook(@record_set)
show_create_... |
module Zheng
module Interactive
PROMPT = '> '
module_function
# Run in interactive mode
def run
output "Welcome to Zheng. Type 'help' for... well, for help."
while true
line = Readline.readline(PROMPT)
break if line.nil? or line.strip == 'exit'
Readline::HISTORY.pus... |
default_platform(:ios)
TMP_KEYCHAIN_NAME_DEFAULT = "fastlane_flutter"
TMP_KEYCHAN_PASSWORD_DEFAULT = "tmppassword"
def delete_tmp_keychain(name)
delete_keychain(
name: name
) if File.exist? File.expand_path("~/Library/Keychains/#{name}-db")
end
def create_tmp_keychain(name, password)
create_keychain(
n... |
# frozen_string_literal: true
module MangaEdenRipper
VERSION = '0.1.0'.freeze
end
|
module Bosh::AzureCloud
class VMManager
include Helpers
OS_DISK_PREFIX = 'bosh-os'
def initialize(azure_properties, registry_endpoint, disk_manager)
@azure_properties = azure_properties
@registry_endpoint = registry_endpoint
@disk_manager = disk_manager
@logger = Bosh::Clouds::C... |
@b9 = Episode.create(
"title" => "Ep 9: Colin Wright and His Amazing Science Fiction",
"number" => 9,
"published_at" => "2014-08-11 12:00:00",
"media" => "http://resources.brickcaster.com/singularity/009_colin_wright.mp3",
"media_length" => 2028,
"media_size" => 48760237,
"summary" => "Micah interviews world-traveling ... |
require 'test_helper'
class AttachFilesControllerTest < ActionDispatch::IntegrationTest
setup do
@attach_file = attach_files(:one)
end
test "should get index" do
get attach_files_url
assert_response :success
end
test "should get new" do
get new_attach_file_url
assert_response :success
... |
class ChangeColumnTransportFee < ActiveRecord::Migration
def self.up
rename_column :transport_fees ,:user_id ,:receiver_id
add_column :transport_fees, :receiver_type , :string
rename_column :transports ,:user_id ,:receiver_id
add_column :transports, :receiver_type , :string
end
def self.d... |
class ListingsController < ApplicationController
before_action :find_listing, only: [:show, :edit, :update]
def index
# @listings = Listing.all
@listings = Listing.all.paginate(:page => params[:page], per_page: 5)
@listings = Listing.filter(params.slice(:price, :max_guests, :starts_with)).paginate(:p... |
class AddBookIdToCodebook < ActiveRecord::Migration
def change
add_column :codebooks, :book_id, :integer
add_index :codebooks, :book_id
end
end
|
default['anyenv']['user'] = nil
# git repository containing anyenv
default['anyenv']['git_url'] = 'https://github.com/riywo/anyenv.git'
default['anyenv']['git_ref'] = 'master'
# whether to create profile.d shell script
default['anyenv']['create_profiled'] = true
# extra system-wide tunables
default['anyenv']['root_p... |
class CreateVideos < ActiveRecord::Migration
def change
create_table :videos do |t|
t.string 'name', limit: 255, null: false
t.string 'description', limit: 255
t.string 'path', limit: 255
t.index 'name', unique: true
t.timestamps
end
end
end
|
# Monolithic class to handle printers. Horribly incomplete and quite likely
# wrong in many areas.
#
# Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2013.
# License: The MIT License
# (See http://www.opensource.org/licenses/mit-license.php for details.)
require_relative 'gdi/base'
module BM3
module Win... |
class TrackAppearancesController < ApplicationController
before_filter :authorize, :except => [:index, :show]
# GET /track_appearances
# GET /track_appearances.xml
def index
@track_appearances = TrackAppearance.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xm... |
require 'csv'
class Applicants < ActiveRecord::Base
attr_accessible :PhoneNo, :RollNo, :Gender, :EmailAdd, :Qualification, :Percentage, :Branch, :CodePairing, :Comment, :FirstStatus, :FirstTech, :Name, :PairingStatus, :Result, :Role, :Score, :SecondTech, :collegeId
validates :Name, :presence => true
validates ... |
# Ducktype in ruby is the same of PHP, not is exactly parametric polymorphism like Java see ducktype example:
class RegularDuck
def quack!
"Quack! Quack!"
end
end
class SicDuck
def quack!
"Queeeck =("
end
end
class Person
def self.check_duck duck
duck.quack!
end
end
s... |
class ChangeIngredientFreshToDefaultFalse < ActiveRecord::Migration[5.2]
def up
change_column :ingredients, :fresh, :boolean, null: false, default: false
end
def down
change_column :ingredients, :fresh, :boolean
end
end
|
# frozen_string_literal: true
class RemoveColumnFromUser < ActiveRecord::Migration[6.0]
def change
remove_column :users, :encrypted_password
end
end
|
ActiveAdmin.register Category do
# config.clear_action_items!
form do |f|
f.inputs do
f.input :parent, as: :select, collection: Category.root.where(["categories.id <> ?", f.object.id.to_i])
f.input :name
f.input :description
end
f.buttons
end
index do
column :id
column :parent... |
module Nicolive
class Chat
attr_reader :comment, :mail, :vpos, :date, :user_id, :premium, :anonymity, :locale, :score, :origin, :user
def initialize(comment, mail, vpos, date, user_id, premium, anonymity, locale, score, origin)
@comment = comment
@mail = mail
@vpos = vpos
@date = date
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Bookings API', type: :request do
let(:user) { create(:user) }
before do
sign_in(user)
end
it 'returns all bookings' do
booked_room = create(:room)
create(:booking, user_id: user.id, room_id: booked_room.id, date: DateTime.now)
... |
class Vendor < ActiveRecord::Base
validate :picture_has_correct_format
def picture_has_correct_format
unless picture.blank? || picture.downcase.start_with?('https://', 'http://')
errors.add(:picture, 'must start with https:// or http://')
end
end
validates :name, presence: true, uniqueness: true
... |
require 'spec_helper'
require 'crc_examples'
require 'digest/crc16_modbus'
describe Digest::CRC16Modbus do
before(:all) do
@crc_class = Digest::CRC16Modbus
@string = '1234567890'
@expected = 'c20a'
end
it_should_behave_like "CRC"
end
|
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
if RUBY_VERSION < '1.9'
require 'rubygems'
end
require File.expand_path('../../config/boot', __FILE__)
require 'json'
require 'mechanize'
require 'cgi'
require 'rexml/document'
require 'movie'
require 'tag'
class NicoVideoFetcher
def start
# 既にニコニコ動画経由で取得された動画の識別子(s... |
require "stringio"
RSpec.describe S3WebsiteDeploy::CLI do
describe ".parse_argv" do
let(:argv) do
[
"--source", "build/",
"--region", "ap-northeast-1",
"--bucket", "bucket1",
"--prefix", "dummy/",
"--cache-policy", %({ "*.html": { "cache_control": "max-age=600" } })
... |
# Write a program that prints 99 bottles of beer on the wall.
# The song starts with
def write_line(idx)
puts "\n"
puts idx.to_s + " bottles of beer on the wall"
puts idx.to_s + " bottles of beer!"
puts "You take one down and pass it around,"
idx -= 1
if idx < 1
puts "No more bottles of beer on the wa... |
module Api
module V1
class UsersController < ApplicationController
before_action :doorkeeper_authorize!
skip_before_action :authenticate_user!
protect_from_forgery with: :null_session
respond_to :json
def index
u... |
class CourseSerializer < ActiveModel::Serializer
attributes :id, :name, :description, :created_at, :updated_at, :educator_id
has_many :course_student_relationships
belongs_to :educator
end
|
class AddUserInfoToUsers < ActiveRecord::Migration
def change
add_column :users, :nickname, :string
add_column :users, :first_name, :string
add_column :users, :last_name, :string
add_column :users, :image_url, :string
add_column :users, :location, :string
add_column :users, :verified, :boolean... |
# 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class LineItemsController < ApplicationController
def index
load_line_items
end
def show
load_line_item
end
def new
build_line_item
end
def edit
end
def create
create_line_item
end
def update
end
def destroy
load_line_item
destroy_line_item
end
private
def... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :name, presence: true
# FRIENDS (and frien... |
Rails.application.routes.draw do
mount Tramway::Admin::Engine => "/"
end
|
# frozen_string_literal: true
require "webtrap/rspec/matchers"
module WebTrap
# Implementation of the WebTrap features for the RSpec testing tool.
#
# @example
# require "webtrap/rspec"
module RSpec
end
end
|
FactoryBot.define do
factory :complaint do
ia_number { "IAD2020-0042" }
factory :complaint_kirk do
ia_number { "IAD2260-0001" }
case_number { 1234 }
incident_type { "Internal investigation" }
received_date { "2061-05-01" }
occurred_date { "2061-04-20" }
summary { "rofl xyz... |
# Model for application
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
|
require 'test_helper'
class PlayerTest < ActiveSupport::TestCase
def setup
Preference.path_to_server = "#{Rails.root}/tmp"
end
def test_stats
player = Player.find_by_nick('inertia186')
refute_nil player.stats, 'did not expect nil stats'
refute_nil player.stats.mob_kills, 'did not expect nil s... |
class CalEnd::Tip < CalEnd::Base
def distance_human
if distance < 0
"孕#{40+distance}周"
else
month = distance / 4
"#{month/12}岁#{month % 12}月#{distance % 4}周"
end
end
end
|
require 'spec_helper'
describe TeachersController do
describe 'Teachers options' do
it 'Only logged in user can see the page' do
session = nil
get :choose_classes
response.should redirect_to root_path
end
it 'Teacher must see only classes he teach' do
session[:manager]=false
Teacher.stub(:... |
WIN_COMBINATIONS = [
[0,1,2], #top row win
[3,4,5], #middle row win
[6,7,8], #bottom row win
[0,4,8], #top left diagonal win
[2,4,6], #top right diagonal win
[0,3,6], #left column win
[1,4,7], #middle column win
[2,5,8] #right column win
]
def display_board(board)
puts " #{board[0]} | #{board[1]} | #... |
class User < ActiveRecord::Base
# new columns need to be added here to be writable through mass assignment
attr_accessible :username, :email, :password, :password_confirmation, :roles_mask, :roles
attr_accessor :password
before_save :prepare_password
has_many :your_queues
has_many :your_queues, :through =... |
json.array!(@raw_motion_data) do |raw_motion_datum|
json.extract! raw_motion_datum, :pitch, :quaternion_w, :quaternion_x, :quaternion_y, :quaternion_z, :roll, :rotation_rate_x, :rotation_rate_y, :rotation_rate_z, :user_accel_x, :user_accel_y, :user_accel_z, :yaw, :touch_datum_id
json.url raw_motion_datum_url(raw_mo... |
class Game < ActiveRecord::Base
has_many :hands
has_many :cards
def game_outcome
if 21 < dealer_hand.total
"Dealer Busts! Player Wins!"
elsif player_hand.total > dealer_hand.total
"Player Wins!"
else
"Dealer Wins!"
end
end
def dealer_turn
#if dealer has blackjack, deale... |
class SessionsController < ApplicationController
skip_before_action :require_login, only: [:new, :create]
respond_to :html, :json
# GET /sign_in
def new
redirect_signed_in_users
form Session::SignIn
end
# POST /sign_in
def create
respond Session::SignIn do |op|
auto_login(op.model, par... |
class CreateNotificationConfigurations < ActiveRecord::Migration
def change
create_table :notification_configurations do |t|
t.boolean :notify_friendships, default: true
t.boolean :notify_likes, default: true
t.boolean :notify_comments, default: true
t.references :user
t.timestamps ... |
# frozen_string_literal: true
module Concerns
module PropertyQueryable
extend ActiveSupport::Concern
included do
scope :with_faiths, ->(faith_id) { where(faith_id: faith_id) }
scope :with_strains, ->(strain_id) { where(strain_id: strain_id) }
scope :with_lores, lambda { |lores_id|
... |
class JobsController < ApplicationController
# GET /jobs
# GET /jobs.json
def index
#@jobs = Job.order('id DESC').includes(:actions)
@jobs = Job.includes(:step).order('id DESC')
# Fetch real beanstalk queued IDs
bs = Q.new
@bs_jobs_ids = bs.fetch_queued_jobs_ids
# Parse db jobs with bs j... |
require 'kaede/channel'
require 'kaede/grpc/kaede_services_pb'
require 'kaede/syoboi_calendar'
require 'kaede/updater'
module Kaede
class SchedulerService < Grpc::Scheduler::Service
def initialize(reload_event, stop_event, db)
super()
@reload_event = reload_event
@stop_event = stop_event
... |
class Supervisor < ApplicationRecord
has_many :groups, dependent: :destroy
def self.import(file)
all_supervisors = []
Supervisor.all.each do |supervisor|
all_supervisors.push(supervisor.username)
end
xlsx = Roo::Spreadsheet.open(file.path)
xlsx.drop(1).each do |row|
username = ro... |
require 'aws-sdk'
Puppet::Type.type(:placement_group).provide(:v2, :parent => PuppetX::Puppetlabs::Aws) do
desc "Provider for Placement Group" do
puts "*"
end
client = Aws::EC2::Client.new
begin
ec2 = client.create_placement_group({group_name: @resource[:group_name],strategy: @resource[:strategy]})
r... |
class RenameCostToBudget < ActiveRecord::Migration[4.2]
def self.up
add_column :deliverables, :budget, :decimal, :precision => 15, :scale => 2
remove_column :deliverables, :cost
end
def self.down
add_column :deliverables, :cost, :decimal, :precision => 15, :scale => 2
remove_column :deliverable... |
require 'dank'
require 'spec_helper'
describe 'Dank' do
describe 'module functions'
describe 'mixin' do
before :all do
class FuckerUser
include Dank::Taggable
tag_name :tag
def initialize(id)
@id = id
end
def id
@id
end
end
... |
get '/private', to: 'private_pages#index'
get '/', to: 'pages#index'
# Configure your routes here
# See: http://www.rubydoc.info/gems/hanami-router/#Usage
|
class RemoveWorldregionsCenter < ActiveRecord::Migration
def change
remove_column :worldregions , :center_x
remove_column :worldregions , :center_y
end
end
|
class ChangeColumnName2 < ActiveRecord::Migration[5.0]
def change
rename_column :campaigns, :campaign, :category
end
end
|
# frozen_string_literal: true
class UsersController < ApplicationController
include JwtAuthenticator
def index
@users = User.all
render json: @users
end
def login
@current_user = User.find_by(email: user_params[:email])
if @current_user&.authenticate(user_params[:password])
jwt_token = ... |
require 'snmp2mkr/config_types/base'
require 'snmp2mkr/config_types/oid'
require 'snmp2mkr/config_types/value_definition'
module Snmp2mkr
module ConfigTypes
class MetaDefinition < Base
def setup(h)
raise TypeError, "#{self.class} must be given a Hash" unless h.kind_of?(Hash)
raise ArgumentE... |
# frozen_string_literal: true
describe Zafira::XmlConfigBuilder do
let(:env) { build(:environment, :with_optional_data) }
describe '#construct' do
it do
expect(Zafira::XmlConfigBuilder.new(env).construct).to eq(
'<?xml version="1.0" encoding="UTF-8"?>' \
'<config>' \
'<arg>'... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "blink1/version"
Gem::Specification.new do |s|
s.name = "rb-blink1"
s.version = Blink1::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Atsushi Nagase']
s.email = ['a@ngs.io']
s.homepage = "http... |
require 'misc'
module ScannerHierarchy
class Base
end
class Match < Base
# must be initialized with a node in the abstract
# syntax tree (AST)
def initialize(ast_node)
@node = ast_node
end
attr_reader :node
def accept(visitor); visitor.visit_match self end
def match(other); node.match(other) end
... |
require 'httparty'
require 'json'
module Mollie
class Client
include HTTParty
base_uri 'https://api.mollie.nl/v1'
format :json
attr_accessor :api_key
def initialize(api_key)
self.api_key = api_key
end
def auth_token
"Bearer " + self.api_key
end
def prepare_payment(a... |
class AddMembershipTypeToCustomerProfiles < ActiveRecord::Migration
def change
add_column :customer_profiles, :membership_type, :string
end
end
|
# represent review given to member after a job
class Review
include Mongoid::Document
include Mongoid::Timestamps
field :description
field :rating, type: Integer
belongs_to :reviewer, polymorphic: true
belongs_to :workspace
embedded_in :member
validates :reviewer, presence: true
validates :rating... |
Pod::Spec.new do |spec|
spec.name = "HTML"
spec.version = "1.0.1"
spec.summary = "A small framework to monitor network changes in Swift."
spec.description = <<-DESC
HTML is a small and lightweight Swift framework that allows to monitor and being notified for network status... |
require '04_book'
RSpec.describe 'Effective Testing with RSpec 3 book' do
let(:rspec_book) { Book.new('bestseller', ['programming'], 100) }
it 'costs €100' do
cost = rspec_book.cost
expect(cost).to eq(100)
end
context 'with ebook' do
before { rspec_book.with_epub = true }
it 'costs €120' do
... |
class BonusDrink
BONUS_DRINK_GET_COUNT = 3
def self.total_count_for(amount)
#整数値チェック
if !amount.is_a?(Integer)
puts "error:#{amount} is not integer"
return -1
end
#マイナスチェック
if amount < 0
puts "error:#{amount} is not positive number"
return -1
end
... |
# require gems
require 'sinatra'
require 'sqlite3'
db = SQLite3::Database.new("students.db")
db.results_as_hash = true
# write a basic GET route
# add a query parameter
# GET /
get '/' do
p params
"#{params[:name]} is #{params[:age]} years old."
end
# write a GET route with
# route parameters
get '/about/:person... |
class AddPaperclipToProjectRequestForm < ActiveRecord::Migration
def change
add_attachment :project_request_forms, :signed_copy
add_attachment :project_request_forms, :mail_approval
end
end
|
# madlibs.rb
# Mad libs are a simple game where you create a story template with blanks for
# words. You, or another player, then construct a list of words and place them
# into the story, creating an often silly or funny story as a result.
# Create a simple mad-lib program that prompts for a noun, a verb, an adverb,
... |
class Vote < ActiveRecord::Base
validates :contestant_id, presence: true
def self.count_for(contestant_id)
where(contestant_id: contestant_id).count
end
def self.per_contestant
votes = group(:contestant_id).count
Contestant.ids.each_with_object({}) do |contestant_id, h|
h[contestant_id] = vo... |
# == Schema Information
#
# Table name: withdrawals
#
# id :integer not null, primary key
# wallet_id :integer
# status :integer
# amount :decimal(8, 2)
# created_at :datetime not null
# updated_at :datetime not null
#
class Withdrawal < ActiveRecord::Base
include With... |
class DatProject < ActiveRecord::Base
#########################
# 関連定義
#########################
# プロジェクト構成データを所有する(1:多)
has_many :dat_projectcomps, :foreign_key => "project_id", :dependent=>:destroy
# プロジェクトユーザーデータを所有する(1:多)
has_many :dat_projectusers, :foreign_key => "project_id", :dependent=>:destroy
... |
# encoding: UTF-8
require 'sinatra/base'
module Sinatra
module WuHelpers
def colors
%w{turquoise green-sea emerald nephritis peter-river belize-hole amethyst wisteria wet-asphalt midnight-blue sun-flower orange carrot pumpkin alizarin pomegranate clouds silver concrete asbestos}
end
def bg_color... |
module V1
class FestivalsController < ApplicationController
before_action :log_search, only: [:show]
before_action :set_festival, only: [:show]
before_action :log_result, only: [:show]
BASE_URL = "https://www.musicfestivalwizard.com/festivals/"
# GET /festivals/slug
def show
if @festi... |
When(/^I visit (.*)/) do |path|
navigate_to(path)
end
When(/^I click(?: on|) "([^"]*)"/) do |link_or_button|
click_on(link_or_button, match: :first)
end
When(/^I check "([^"]*)"/) do |checkbox|
check(checkbox)
end
When(/^I fill in the following$/) do |table|
table.raw.each do |row|
fill_in(row[0], with: ... |
class Ad < SnapshotCluster
cluster_of :ad_snapshots
has_context :email
has_many :account_ads
has_many :gmail_truths
field :labeled
field :in_master
index({ labeled: 1 })
index({ labeled: 1, in_master: 1 })
index({ labeled: 1, _type: 1 })
index({ labeled: 1, in_master: 1, _type: 1 })
field :tar... |
require ENV['ABT'] + '/src/lib/config.rb'
require ENV['ABT'] + '/src/lib/compile.rb'
class Test
def initialize
@config = Config.new
end
def test(task, lang)
input_files_length = Dir.glob('./test/' + task + '/' + 'in/*').length
exec_command = @config.make_exec_command(task, lang)
input_files_... |
class Notifications < ActionMailer::Base
default from: "from@example.com" #od kogo - i tu można się podszywać ;P
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.notifications.hello.subject
#
def hello(email)
@greeting = "Hi"
mail to: email
... |
class AddRelacionPersonaTipoUsuario < ActiveRecord::Migration
def up
add_column :personas, :tipo_usuario_id, :integer
end
def down
end
end
|
# Back in the good old days, you used to be able to write a darn near
# uncrackable code by simply taking each letter of a message and incrementing it
# by a fixed number, so "abc" by 2 would look like "cde", wrapping around back
# to "a" when you pass "z". Write a function, `caesar_cipher(str, shift)` which
# will ta... |
# == Schema Information
#
# Table name: items
#
# id :integer not null, primary key
# name :string(255)
# price :float
# bill_id :integer
# created_at :datetime
# updated_at :datetime
#
class Item < ActiveRecord::Base
belongs_to :bill
validates :name, presence: true
... |
class TimeController < ApplicationController
def show
if time_params[:client_id].blank? && time_params[:project_id].blank?
@error_message = 'Debes incluir un id de cliente o proyecto'
else
@title = harvest_summary[:title]
@hours_by_month = harvest_summary[:hours_by_month]
end
end
pr... |
# frozen_string_literal: true
# Collection controller methods.
class CollectionsController < ApplicationController
before_action :set_collection, only: %i[show]
before_action :set_user, only: %i[show download]
before_action :set_collection_id, only: %i[download]
before_action :gexf_path, only: %i[download_gexf... |
class Admin::ResourcesController < Admin::BaseController
# generic controller for model admin manipulation
before_action :load_resource, only: [:show, :edit, :update, :destroy]
def new
@resource = resource_class.new.decorate
authorize @resource
end
def create
@resource = resource_class.new(resou... |
class Dictionary
def initialize
@dict = {}
end
def entries
@dict
end
def add entry
if entry.class == String
@dict[entry] = nil
else
@dict = @dict.merge(entry)
end
end
def keywords
@dict.keys.sort
end
def include? key
@dict.has_key?(key)
end
def find word
@dict.select {|k,v| k.incl... |
module ApplicationHelper
ALERT_STYLE = { notice: 'alert-info',
success: 'alert-success',
error: 'alert-danger',
alert: 'alert-warning' }.freeze
def current_year
Time.current.year
end
def github_url(author, repo)
link_to "Репозиторий проекта #{repo}... |
# -*- encoding : utf-8 -*-
module ConfigurationsHelper
def play_pause_image(config)
case config.media_state
when "Playing"
"media/pause.png"
else
"media/play.png"
end
end
def repeat_image(config)
case config.repeat
when "RepeatAll"
return "media/repeat_all.png"
when "RepeatOne"
return "me... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.