text stringlengths 10 2.61M |
|---|
require_relative "../helper_sequences/a000217"
require_relative "../helper_sequences/a047838"
class OEIS
def self.a128223(n)
n.even? ? a000217(n) : a047838(n + 1)
end
end
# This is the number of numbers required for
# 0 != 1
# 0 != 1 != 2 != 0
# 0 != 1 != 2 != 3 != 0 != 2 != 1 != 3
# 0 != 1 != 2 != 3 != 4 != ... |
require 'pry'
class Owner
attr_reader :name, :species
attr_accessor :pets
@@all = []
def initialize(name)
@name = name
@@all << self
@species = "human"
@pets = {:fishes => [], :dogs => [], :cats => []}
end
# CLASS METHODS
def self.all
@@all
end
def self.reset_all
@@all.cl... |
class MembersController < ApplicationController
before_filter :redirect_if_not_logged_in, only: [ :show, :edit, :update ]
before_filter :redirect_if_logged_in, only: [ :new, :create ]
before_filter :redirect_if_user_doesnt_match, only: [ :show, :edit, :update ]
def new
@member = Member.new
end
def... |
Rails.application.routes.draw do
devise_for :sign_ups
resources :projects
root 'welcome#index'
end |
# pseudo
#
# handle input and output as far as the user is concerned
# one user enters word
# a second user guesses the word with letters
# Guesses are limited, and the number of guesses available is related to the length of the word.
# repeated letters not penalized - just dumb
# prompt one user to enter a wo... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# v_bootstrap.sh
#
# jorgedlt@gmail.com - 2016-07-22 12:50:19
Vagrant.configure(2) do |config|
config.vm.box = "boxcutter/ubuntu1604"
# Provisioning & Start-Up
config.vm.provision :shell, path: "v_bootstrap.sh"
config.vm.provision :shell, path: "v_st... |
module TrelloPresenter
class List
attr_reader :name, :id
attr_accessor :cards
def self.build(lists)
lists.map {|l| new(l) }
end
def initialize(raw_data)
@raw_data = raw_data
@name = raw_data['name']
@id = raw_data['id']
@cards = []
end
... |
class TestScenariosController < ApplicationController
before_action :authenticate_user!, only: [:index, :show, :edit, :update, :destroy, :create, :new, :edit_all]
before_action :set_test_scenario, only: [:show, :edit, :update, :destroy, :send_xml_order]
before_action :set_paper_trail_whodunnit
load_and_authoriz... |
class SessionsController < ApplicationController
skip_before_action :verify_authenticity_token
def create
user=User.find_by(name: params[:user][:name])
if user && user.authenticate(params[:user][:password])
session[:name] = user.name
redirect_to '/listings/index'
else
redirect_to roo... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path('../lib', __FILE__)
require 'sinatra/opencaptcha_version'
Gem::Specification.new do |s|
s.name = 'sinatra-opencaptcha'
s.version = Sinatra::OpenCaptcha::VERSION
s.authors = ['Bruno Kerrien']
s.email = ['bruno@neirrek.com']
s.homepage ... |
class Librarian
attr_accessor :name, :age, :fave_book
def initialize(name, age, fave_book, id=nil)
@id = id
@name = name
@age = age
@fave_book = fave_book
end
def self.new_table
DB[:conn].execute("CREATE TABLE librarians(id INTEGER PRIMARY KEY, name TEXT, age INTEGER, fave_book TEXT)")
e... |
json.array!(@sprinkles) do |sprinkle|
json.extract! sprinkle, :id, :time_input, :duration, :state, :circuit_id
json.url sprinkle_url(sprinkle, format: :json)
end
|
#!/usr/bin/env ruby
# load HTTP request class and REXML Document class
require 'net/http'
require 'rexml/document'
# set the username to fetch
username = 'othiym23'
# the URL for the most recent weekly chart
weekly_feed_url = "http://ws.audioscrobbler.com/1.0/user/#{username}/weeklyartistchart.xml"
# load the feed
... |
class Topic < ActiveRecord::Base
attr_accessible :description, :title
has_many :votes
def as_json(*args)
{description: description, title: title}
end
end
|
class CreateCellSkeds < ActiveRecord::Migration
def self.up
create_table :cell_skeds do |t|
t.integer :number_couple
t.time :start_time
t.time :end_time
t.timestamps
end
end
def self.down
BusInf_table :cell_skeds
end
end |
class Deployment < ApplicationRecord
belongs_to :app
MAX_IMAGE_SIZE = 256 * 1024
MAX_DEBUG_DATA_SIZE = 32 * 1024
validates :version, uniqueness: { scope: :app_id }
validates :tag,
format: { with: Device::TAG_NAME_REGEX },
length: { in: 0..Device::TAG_LEN },
allow_nil: true
validates :co... |
require 'socket'
module RTALogger
# show log items on console out put
class LogRepositoryUDP < LogRepository
def initialize(host = '127.0.0.1', port = 4913)
super()
@udp_socket = UDPSocket.new
@udp_socket.bind(host, port)
end
def load_config(config_json)
super
host = con... |
class EngineersController < ApplicationController
before_filter :protect_controller
protected
def protect_controller
if current_user.has_role?("PowerUser")
return true
else
redirect_to "/devices/index"
flash[:notice] = "Не достаточно прав!"
return false
end
end
public
def i... |
class Fan < ActiveRecord::Base
has_many :comments
has_many :photos, dependent: :destroy
has_many :rsvps
has_many :concerts, through: :rsvps
mount_uploader :profile_picture, ImageUploader
def attend(concert)
rsvps.create(concert: concert)
end
def cancel(concert)
concerts.destroy(concert)
end... |
class Gotbattle < ActiveRecord::Base
def self.search(term)
where("lower(name) like ? ", "%#{term}%").pluck(:name)
end
def self.list_battles(term)
where("lower(name) like ? ", "%#{term}%")
end
end
|
class ReplaceGluedByProximity < ActiveRecord::Migration[5.1]
def up
add_column :interpretations, :proximity, :integer, default: Interpretation.proximities['close']
Interpretation.where(glued: true).in_batches do |interpretations|
interpretations.update_all(proximity: 'glued')
end
Interpretatio... |
require 'spec_helper'
feature "Sign Up" do
scenario "A new user signs up" do
visit '/'
fill_in :email, with: 'test@example.com'
click_on 'Create Registration'
page.should have_content registration_token
end
def registration_token
@registration_token ||= Registration.first.token
end
end
|
class OrderProduct < ApplicationRecord
belongs_to :order
belongs_to :product
enum make_status: {
"制作不可": 0,
"制作待ち": 1,
"製作中": 2,
"制作完了": 3,
}
end
|
require 'securerandom'
require 'barby/barcode/qr_code'
require 'barby/outputter/png_outputter'
require 'csv'
namespace :tickets do
desc "Generate tickets"
task generate: :environment do
Ticket.transaction do
if Ticket.count > 0
STDERR.puts("Do nothing because tickets have already been generated"... |
require 'event'
# purpose:
# base class for all termcap classes
class Termcap
def initialize(seq_key)
@seq_key = seq_key
end
attr_reader :seq_key
end
# purpose:
# build one gigantic hash-table which translates
# from XTerm-escape-sequences into AEditor-events.
class TermcapXTerm < Termcap
include KeyEvent::Key... |
##
#
#https://projecteuler.net/problem=23
#
#4179871 ANS
#5 s
start = Time.now
def prob23
abundant = []
limit = 28123
sum_abundant = []
abundant = (2..limit).select do |num|
divs = get_divisors(num)
num if abundant?(num, divs)
end
abundant.each_with_index do |num1,id... |
require 'test_helper'
class TransactionsControllerTest < ActionController::TestCase
test "should get new" do
get :new
assert_response :success
end
test "should get pickup" do
get :pickup
assert_response :success
end
test "should get create" do
get :create
assert_response :success
... |
require 'spec_helper'
describe Yandex::Market::Client::Regions do
let(:client) { Yandex::Market::Client.new(token: 'test') }
describe '.regions', :vcr do
it 'returns top level regions' do
result = client.regions
expect(result.regions).to be_kind_of Array
assert_requested :get, market_url('/g... |
class PostAssetJob < ApplicationJob
queue_as :post_asset
after_perform do |job|
Rails.logger.info "#{Time.current}: finished execution of the job: #{job.inspect}"
logger.debug 'Deleted ' + AmsAsset.where('ebarcode LIKE ?', '%Error%').each{|asset| asset.destroy}.size.to_s + ' assets with errors'
end
de... |
class AddManyColumnsToTrial < ActiveRecord::Migration
def change
add_column :trials, :nct_id, :text
add_column :trials, :official_title, :text
add_column :trials, :agency_class, :text
add_column :trials, :detailed_description, :text
add_column :trials, :overall_status, :text
add_column :trials... |
class IctNetworkPointsController < ApplicationController
def index
@requisition = IctNetworkPoint.where(:user_id => current_user.id).order.page(params[:page]).per(4)
end
def new
@requisition=IctNetworkPoint.new
end
def show
@ict_network = IctNetworkPoint.find(params[:id])
@type_name = Requ... |
class Rsvp < ActiveRecord::Base
validates :name, presence: true, length: { minimum: 2 }
validates :attending, numericality: true, presence: true
attr_accessible :name, :attending
end |
require 'rails_helper'
RSpec.describe User, type: :model do
it { should have_many(:answers).dependent(:destroy) }
it { should have_many(:questions).dependent(:destroy) }
it { should have_many(:badges).dependent(:destroy) }
it { should have_many(:comments) }
it { should validate_presence_of :email }
it {... |
class User < ApplicationRecord
validates :email, presence: true
has_one :loan
has_one :loan_application
accepts_nested_attributes_for :loan,
:loan_application
end
|
class CommentsController < ApplicationController
def create
@article = Article.find(params[:article_id])
@comment = @article.comments.new(comment_params)
@comment.user = current_user
if @comment.user != nil
if @comment.save
flash[:success] = "Comment has been created"
else
flash[:danger] = "Com... |
class JobApplication < ApplicationRecord
include Filterable
scope :status, -> (status) { where status: status }
#Relationships
#a job application belongs to a job posting
belongs_to :job_posting
#a job application belongs to a user
belongs_to :user
has_one :resume
#a job application has many job appl... |
# encoding: UTF-8
module API
module V1
class Libraries < API::V1::Base
helpers API::Helpers::V1::LibraryHelpers
before do
authenticate_user
end
with_cacheable_endpoints :library do
paginated_endpoint do
desc 'Get paginated library'
params do
... |
#
# Cookbook:: baseline
# Recipe:: upgrade
#
# Greg Konradt. Dec 2016
case node['platform_family']
when 'debian'
bash 'upgrade_system' do
user 'root'
not_if 'ls /usr/local/initial_upgrade.date'
cwd '/tmp'
code <<-EOH
apt-get update
date > /usr/local/initial_upgrade.date
apt-get upgrad... |
class CommentsController < ApplicationController
def create
@order = Order.find(comment_params[:order_id])
unless can? :comment_on, @order
return redirect_to orders_path, alert: "You aren't allowed to comment on this order."
end
@comment = Comment.new(comment_params)
@comment.user = current_user
@com... |
class ItemsController < ApplicationController
before_action :check_admin, :only => [:edit, :update, :create, :new, :add]
def index
@items = Item.where(hidden: nil)
end
def show
@item = Item.find(params[:id])
@categories = Category.all
end
def create
@item = Item.new(item_params)
if @item... |
# frozen_string_literal: true
module Admin
class DmarcReportsController < ::ApplicationController
secure!(:admin, strict: true)
def index
@reports = DmarcReport.all
@new_report = DmarcReport.new
end
def show
@report = DmarcReport.find(params[:id])
respond_to do |format|
... |
require "test_helper"
describe Comment do
before do
@comment = Comment.new(
user: create(:user),
commentable: create(:game)
)
end
it "must be valid" do
@comment.valid?.must_equal true
end
end
|
module Adzerk
class Reporting
include Adzerk::Util
attr_accessor :client
def initialize(args = {})
@client = args.fetch(:client)
end
def create_report(data={})
data = { 'criteria' => camelize_data(data).to_json }
parse_response(client.post_request('report', data))
end
... |
require 'rails_helper'
RSpec.describe "bookings", type: :request do
describe "GET api/bookings" do
it "get the list of all bookings" do
assignment = Fabricate(:assignment)
timeslot = assignment.timeslot
booking = Booking.create(timeslot_id: timeslot.id, size: 6)
get api_bookings_path
... |
class AdditionalReportCsv < ActiveRecord::Base
serialize :parameters, Hash
has_attached_file :csv_report,
:url => "/report/csv_report_download/:id",
:path => "uploads/:class/:attachment/:id_partition/:style/:basename.:extension"
def csv_generation
method_name=self.method_name
data=self.model_name... |
# encoding utf-8
require "date"
require "logstash/inputs/base"
require "logstash/namespace"
require "socket"
require "tempfile"
require "time"
# Read events from the connectd binary protocol over the network via udp.
# See https://collectd.org/wiki/index.php/Binary_protocol
#
# Configuration in your Logstash configura... |
class UserMailer < ApplicationMailer
def invite(invitation)
@user = invitation.user
@event = invitation.event
mail to: @user.email, subject: "An invitation to #{@event.title}"
end
end
|
class UsersController < ApplicationController
skip_before_action :require_login
# https://stackoverflow.com/questions/4982371/handling-unique-record-exceptions-in-a-controller
# rescue_from ActiveRecord::RecordNotUnique, :with => :my_rescue_method
before_action :user_params, only: [:create]
def confirm_emai... |
module Typedown
class Shorthand
def self.process body
# Find all occurences mathcing the shorthand syntax
# 'action/param1[/param2]
offset = 0
while(match = body[offset..-1].match(/\'\w+[\/\w+]+/)) do
m = match[0]
res = self.resolve m
body.gsub!(m, res) if res
... |
require 'fizzbuzz'
describe 'fizzbuzz' do
it'returns fizz when passed multiple of 3' do
expect(fizzbuzz(3)).to eq 'fizz'
end
it'returns buzz when passed multiple of 5' do
expect(fizzbuzz(5)).to eq 'buzz'
end
it'returns fizzbuzz when passed multiple of 5 and a multiple 3' do... |
class UpdatePicturesTable < ActiveRecord::Migration[5.2]
def change
add_reference :pictures, :attached_to, foreign_key: {to_table: :pictures}
end
end
|
require 'spec_helper'
describe ParatureFaqData do
before { ParatureFaq.recreate_index }
let(:fixtures_dir) { "#{Rails.root}/spec/fixtures/parature_faqs/" }
let(:resource) { "#{fixtures_dir}/articles/article%d.xml" }
let(:folders_resource) { "#{fixtures_dir}/folders.xml" }
let(:importer) { ParatureFaqData.new... |
class ListingsController < ApplicationController
before_action :set_listing, only:[:edit, :update, :delete, :destroy, :show]
def index
@listings = Listing.all.page(params[:page]).order('created_at DESC')
@listings = @listings.listing_name(params[:listing_name].strip).page(params[:page]).order('created_at D... |
require 'orocos/test'
DATAFLOW_STRESS_TEST =
if ENV['DATAFLOW_STRESS_TEST']
Integer(ENV['DATAFLOW_STRESS_TEST'])
end
describe Orocos::Port do
include Orocos::Spec
it "should not be possible to create an instance directly" do
assert_raises(NoMethodError) { Orocos::Port.new }
end
it "... |
# Copyright (C) 2014 Jan Rusnacko
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of the
# MIT license.
require 'spec_helper'
require 'ruby_util/hash'
describe Hash do
it 'should symbolize_keys correctly' do
expect(... |
require_relative 'grid'
class Point
attr_accessor :p1, :p2 #public variables
def initialize
@p1 = 0
@p2 = 0
end
def move!(direction) #moves the kangaroo in the given direction
case direction
when :north
@p1 += 1
when :east
@p2 += 1
when :south
@p1 -= 1... |
require File.dirname(__FILE__) + '/../../../test_helper'
class TinyCI::Report::TestReportTest < ActiveSupport::TestCase
test "should add test case" do
report = TinyCI::Report::TestReport.new
report.add_test_case('SomeTest', 'test_should_do_something', 'success')
test_case = report.test_case('SomeTes... |
require 'rails_helper'
RSpec.describe Event, type: :model do
before do
Rails.application.load_seed
end
let(:event) { Event.find_by(title: 'This is the 3rd event') }
it "is valid with valid attributes" do
expect(event).to be_valid
end
context 'is not valid without a valid title' do
it 'title ... |
class MeMyselfAndI
puts self
def self.me
puts self
end
def myself
puts self
end
end
i = MeMyselfAndI.new
p MeMyselfAndI.me
p i.myself |
# Generated via
# `rails generate hyrax:work Image`
require 'rails_helper'
RSpec.describe Image do
subject(:image) { FactoryBot.build(:image) }
it_behaves_like 'a model with admin metadata'
it_behaves_like 'a model with workflow metadata'
it_behaves_like 'a model with image metadata'
it_behaves_like 'a mod... |
class Api::V1::RestockItemsController < ApplicationController
def index
@restock_items = Restock_item.all
render json: @restock_items
end
def create
@restock_item = Restock_item.create(restock_item_params)
render json: @restock_item
end
private
def restock_item_params
params.require(... |
module OpenID
class StandardFetcher
def fetch(url, body=nil, headers=nil, redirect_limit=REDIRECT_LIMIT)
unparsed_url = url.dup
url = URI::parse(url)
if url.nil?
raise FetchingError, "Invalid URL: #{unparsed_url}"
end
headers ||= {}
headers['User-agent'] ||= USER_AGENT... |
require 'spec_helper'
require 'fileutils'
describe 'db' do
let(:db) do
if File.exists?("test.db")
FileUtils.rm("test.db")
end
RPS::DB.new("test.db")
end
let(:user1) {db.create_user(:name => "Ashley", :password => "1234")}
let(:user2) {db.create_user(:name => "Katrina", :password => "123kb")}... |
=begin
- input: array of elements that can be sorted
- output: same array with elements sorted
- Data Structure: work directly with Array
Algorithm:
- if first element > second element then array[0], array[1] = array[1], array[0]
- now second element compared to third => if array[1] > array[2] th... |
# rspec ./spec/requests/users_request_spec.rb
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Users', type: :request do
let!(:admin) { FactoryBot.create(:admin) }
let!(:guestuser) { FactoryBot.create(:guestuser) }
describe 'PUT #update' do
context 'パラメータが妥当な場合' do
before do
... |
class Player
attr_reader :num
def initialize(player_number)
@num = player_number
end
def valid_move?(board, move)
(0..6).include?(move) && board.game[move].include?(0)
end
end |
describe 'The Apprentice News submission page', type: :feature do
before(:each) do
database = double(:database)
allow(database).to receive(:init)
Capybara.app = ApprenticeNews.new(nil, database)
end
it 'should allow the user to submit a story' do
pending 'Not implemented yet'
visit '/submit'
... |
class TarantoolNginxModule < Formula
desc "Tarantool upstream for nginx"
homepage "https://github.com/tarantool/nginx_upstream_module"
url "https://github.com/tarantool/nginx_upstream_module/archive/v2.7.tar.gz"
version "2.7"
sha256 "48d0bd45de57c9c34c836941d79ac53b3d51d715361d447794aecd5e16eacfea"
bottle ... |
class AddHasBusinessPaypalToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :has_business_paypal, :bool, default: :false
end
end
|
class WelcomeController < ApplicationController
def index
redirect_to categories_path if logged_in?
end
end
|
module Poe
class TextCache
attr_accessor :text
attr_reader :text_str
attr_accessor :lines
attr_reader :filename
attr_accessor :full_filename
def initialize(file)
@filename = File.basename(file)
@full_filename = File.expand_path(file)
if File.exist?(File.expand_path(file))
@text = File.open(F... |
require 'mustache'
module Couchino
module Plugins
class Mustache < Couchino::Plugin
name 'mustache'
# Run the mustache plugin.
# Available options:
#
# * :files - Run these files through mustache. Can be an array of patterns
# or a single file. The default is '*.m... |
class TripFamily < ApplicationRecord
belongs_to :family
belongs_to :trip
validates :family, presence: true
validates :trip, presence: true
end
|
points = []
File.open("temp.log") do |file|
file.each do |line|
timestamp, temp = line.split
temp = temp.to_f
next if temp > 100
next if temp < 30
points << [timestamp.to_i, temp]
end
end
p points
|
#spec/factories/books.rb
FactoryGirl.define do
factory :book do
name RandomWord.adjs.next.capitalize
description "The Stunning Conclusion to the recent arc!"
factory :book_with_author
after(:build) do |book|
book.authors << FactoryGirl.build(:author)
end
end
end
|
Gem::Specification.new do |s|
s.name = 'rufus-tokyo'
s.version = '0.1.13.2'
s.authors = [ 'John Mettraux', ]
s.email = 'jmettraux@gmail.com'
s.homepage = 'http://rufus.rubyforge.org/'
s.platform = Gem::Platform::RUBY
s.summary = 'ruby-ffi based lib to access Tokyo Cabinet and Tyrant'
s.require_path =... |
class MissionNamesController < ApplicationController
include MyUtility
before_action :set_mission_name, only: [:show, :edit, :update, :destroy]
# GET /mission_names
def index
placeholder_set
param_set
@count = MissionName.search(params[:q]).result.count()
@search = MissionName.page(params[:page... |
# Calculate the mode Pairing Challenge
# I worked on this challenge with Gaston Gouron
# I spent 2.5 hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented.
# 0. Pseudocode
# What is the inp... |
# while loop
# - checks to see if condition is true, WHILE it is, it will continue to loop
|
#==============================================================================
# KGC_PassiveSkills + Yanfly New Battle Stats Patch (DEX, RES, DUR, and LUK)
# v1.0 (August 24, 2011)
# By Mr. Bubble
#==============================================================================
# Installation: Insert this patch into its... |
require 'page-object'
require 'watir'
class FileUpload
include PageObject
page_url('http://the-internet.herokuapp.com/upload')
button(:file_submit, id: 'file-submit')
h3(:file_uploaded, text: 'File Uploaded!')
file_field(:the_file, id: 'file-upload')
div(:uploaded_files, id: 'uploaded-files')
def ... |
require 'rails_helper'
RSpec.describe User, :type => :model do
it "responds to name" do
expect(User.new).to respond_to(:first_name)
end
it "requires first name" do
expect(User.new(last_name: "Mulray", email: "Hollis@Hollis.com", password: "foo", password_confirmation: "foo")).to be_invalid
end
it... |
module CourseHelper
def course_tab_link(course, name, text, current, semester, count=0)
span_text = content_tag :span, text
count_text = count > 0 ? (content_tag :span, count, :class => 'count') : ''
link_text = span_text + count_text
klass = (name.to_sym == current.to_sym) ? "link #{name} ... |
class PoiBookingsController < ApplicationController
def create
skip_authorization
end
def update
@poi_booking = PoiBooking.find(params[:id])
skip_authorization
@poi_booking.booking_status = true
if @poi_booking.save
redirect_to journey_path(@poi_booking.connection.journey_id), notice: '... |
require 'kmeans-clusterer'
require_relative 'tsp'
class FisherJaikumar
def initialize(points:, courier_num:)
@points = points
@courier_num = courier_num
end
def solve
clusters.each do |cluster|
tsp = TSP.new(points: cluster)
tsp.calculate_route
tsp.pretty_print
end
end
pri... |
##
# This module requires Metasploit: http://metasploit.com/download
## Current source: https://github.com/rapid7/metasploit-framework
###
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info={})
super(update_info(info,
... |
class Party < ApplicationRecord
has_many :party_characters, dependent: :destroy
has_many :party_maps, dependent: :destroy
has_many :party_equipments, dependent: :destroy
has_many :maps, through: :party_maps
has_many :characters, through: :party_characters
has_many :equipments, through: :party_equipments
b... |
# encoding: UTF-8
module CDI
module V1
module GameQuestionsAnswers
class BatchCreateService < BaseActionService
action_name :batch_game_question_answers_options_create
attr_reader :answers, :services
def initialize(game, user, options = {})
@game, @user = game, user
... |
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are igno... |
class Web::Admin::MenusController < Web::Admin::ProtectedApplicationController
authorize_actions_for ::Menu
def index
@menus = Menu.includes(:binder, binder: :section).admin_order.page(params[:page]).decorate
end
def new
@menu = MenuType.new
@sections = Section.all
@other_menus = Menu.all
... |
# frozen_string_literal: true
module RequestHelper
def have_sent_request_with(**request_settings) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
request = Request.new(**request_settings)
HOST_PARAMS.each do |attribute|
request.public_send(:"#{attribute}=", request_settings[attribute] || clien... |
require 'spec_helper'
describe VenuesController do
before do
mock_geocoding!
@theVenueType = FactoryGirl.create(:venue_type)
@theLocation = FactoryGirl.create(:location)
end
def valid_attributes
{
name:"Pumphouse",
venue_type_id:@theVenueType.id,
location_attributes:... |
# Completed step definitions for basic features: AddMovie, ViewDetails, EditMovie
Given /^I am on the RottenPotatoes home page$/ do
visit movies_path
end
When /^I have added a movie with title "(.*?)" and rating "(.*?)"$/ do |title, rating|
visit new_movie_path
fill_in 'Title', :with => title
select rating... |
class AddMigrationCreateMessageSettings < ActiveRecord::Migration
def self.up
create_table :message_settings do |t|
t.string :config_key
t.string :config_value
t.timestamps
end
end
def self.down
drop_table :message_settings
end
end
|
class Gif < ActiveRecord::Base
belongs_to :category
has_many :favorite_gifs
has_many :users, through: :favorite_gifs
validates :image_path, presence: true
end
|
require "test_helper"
class ItemTest < ActiveSupport::TestCase
should belong_to :itemable
should belong_to :skill_set
test "category and cat_attributes test" do
blacksmith = Category.create(name: "blacksmith")
armory = Category.create(name: "armory")
weapon_ss = SkillSet.create(strength: 1)
armo... |
module V1
class ItinerariesController < ApplicationController
before_action :set_itinerary, only: [:show, :update, :destroy]
def index
@itineraries = Itinerary.all
json_response(@itineraries, :ok, ItinerariesSerializer)
end
def show
json_response(@itinerary, :ok, ItinerariesSeriali... |
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ▼ Autobackup
# Author: Kread-EX
# Version 1.03
# Release date: 26/12/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#--------------------------------------------------------------------------
# ... |
class Recipe < ActiveRecord::Base
has_many :ratings
belongs_to :user
belongs_to :category
has_and_belongs_to_many :ingredients
validates :title, presence: true
validates :user_id, presence: true
validates :method, presence: true
end |
class FontNotoSansMultani < Formula
head "https://github.com/google/fonts/raw/main/ofl/notosansmultani/NotoSansMultani-Regular.ttf", verified: "github.com/google/fonts/"
desc "Noto Sans Multani"
homepage "https://fonts.google.com/specimen/Noto+Sans+Multani"
def install
(share/"fonts").install "NotoSansMulta... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.