text stringlengths 10 2.61M |
|---|
# An intro to the exercise.
puts "I will now count my chickens:"
# Counting the number of hens.
puts "Hens #{25 + 30 / 6}"
# Counting the number of roosters.
puts "Roosters #{100 - 25 * 3 % 4}"
# Switching to a differnt count.
puts "Now I will count the eggs:"
# Doing some math with Ruby.
puts 3 + 2 + 1 - 5 + 4 % 2 ... |
class CreateCategoryFieldValues < ActiveRecord::Migration[5.0]
def change
create_table :category_field_values do |t|
t.references :item, foreign_key: true
t.references :category_field, foreign_key: true
t.string :value, null: true
t.timestamps
end
end
end
|
module ROM
describe Dynamo::Relation do
include_context 'dynamo' do
let(:table_name) { :hash_table }
let(:table) { build(:hash_table, table_name: table_name.to_s) }
end
include_context 'rom setup' do
let(:definitions) {
Proc.new do
relation(:hash_table) { }
... |
require 'simplecov'
SimpleCov.start
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/pride'
require 'webmock'
require 'vcr'
VCR.configure do |config|
config.cassette_library_dir = "test/vcr_cassettes"
config.hook_into :webmock
... |
require "httplog/extensions/replacers/full_replacer"
module Extensions
module DataFilters
class BaseFilter
attr_accessor :filtered_keys
def initialize(opts={})
@filtered_keys = opts.fetch(:filtered_keys, [])
@replacer = opts.fetch(:replacer, default_replacer).new(opts)
... |
class WeightsController < ApplicationController
layout 'internal'
before_action :authenticate_user!
before_action :block_crossprofile_access
before_action :recover_profile
def index
@weights = @profile.weights
end
def new; end
def edit
@weight = Weight.find(params[:id])
end
def create... |
include Migrations::DisableUpdatedAt
class CreateOrgaTypes < ActiveRecord::Migration[5.0]
def up
create_table :orga_types do |t|
t.string :name
t.timestamps
end
OrgaType.create!(name: 'Root')
OrgaType.create!(name: 'Organization')
OrgaType.create!(name: 'Project')
OrgaType.create... |
module Validators
extend ActiveSupport::Concern
included do
validates :embodiment, presence: true
validates :deadline_on, presence: true
validates :unit, presence: true
validates :quantification, presence: true
end
end
|
require "lucie/utils"
module Status
#
# An error raised by Status::* classes.
#
class StatusError < StandardError; end
#
# A base class for Status::* classes.
#
class Common
include Lucie::Utils
attr_reader :path
def self.base_name name # :nodoc:
module_eval %-
@@base_na... |
class Message < MailForm::Base
attribute :name, :validate => true
attribute :email, :validate => /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
attribute :message_title, :validate => true
attribute :message_body, :validate => true
def headers
{
:subject => "A message",
:to => ... |
require_relative "Task"
require_relative "../common/FileHandler"
require_relative "../common/Utilities"
class TaskCrud < Utilities
def finaliza_tarefa(lista_tarefas)
if lista_tarefas.length > 0
puts
print_list(lista_tarefas)
puts
puts 'selecione o índice da tarefa que deseja finalizar:'
... |
class Admin::ApplicationController < ApplicationController
before_action :authenticate_user!
before_action :authenticate_admin!
private
def authenticate_admin!
return if current_user&.admin?
redirect_to root_path, alert: t('admin.alert')
end
end
|
require 'row'
describe Dodecaphony::Row do
it "initializes with an array of strings and returns the original row" do
tone_row = %w[ a a# b c db d eb e f f# g g# ]
new_dod = Dodecaphony::Row.new tone_row
expect(new_dod.to_a).to eq tone_row
end
it "raises an error for a row with more than 12 pitches... |
class EventsController < ApplicationController
def new
@event = Event.new
end
def create
if logged_in?
@user = User.find_by(name: session[:user_name])
@user.events.create(name: params[:event][:name])
redirect_to @user
else
flash.now[:error] = "You're not logged in so you can'... |
class PodInfosController < ApplicationController
before_action :set_pod_info, only: [:show, :edit, :update, :destroy]
# GET /pod_infos
# GET /pod_infos.json
def index
@pod_infos = PodInfo.all
end
# GET /pod_infos/1
# GET /pod_infos/1.json
def show
end
# GET /pod_infos/new
def new
@pod_i... |
Deface::Override.new(:virtual_path => "spree/layouts/admin",
:name => "Add Pos tab to menu",
:insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
:text => " <%= tab( :pos , :url => admin_pos_path) %>",
:sequence => {:af... |
class AddLevelToUsers < ActiveRecord::Migration
def change
add_column :users, :level, :string, :null => false, :default => 'New Seller'
end
end
|
Pod::Spec.new do |s|
s.name = 'GeoFireX-Swift'
s.version = '1.0.0'
s.summary = 'The framework ported from GeoFireX for Swift.'
s.description = <<-DESC
This framework helps you to get geometry data from Firebase with geohash. Basic logic is the same as G... |
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers 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 Foundat... |
require_relative "../../lib/extractor"
require_relative "../../lib/supervisor"
describe Charger::Extractor do
let(:file) { "input.txt" }
let(:supervisor) { Charger::Supervisor.new(input: file) }
let(:expected_data) do
" Name Balance \n Tom: $500.00 \n Lisa: $-93.00 \n Quincy: error \n"
end
... |
class Api::UsersController < ApplicationController
def index
if params[:filter] == "recent"
limit_param = params[:limit].to_i
limit = limit_param > 0 ? limit_param : 3
@users = User.all.order(id: :desc).limit(limit).pluck(:id)
render json: @users
else
@users = User.all
ren... |
require 'rails_helper'
RSpec.describe "Api::V1::Projects", type: :request do
describe "GET /api/v1/projects/:id" do
before { get "/api/v1/projects/#{project.id}" }
describe "response" do
subject { response }
context "when project is released" do
let(:project) { create(:project, :release... |
module Neo4j
module Shared
extend ActiveSupport::Concern
extend ActiveModel::Naming
include ActiveModel::Conversion
begin
include ActiveModel::Serializers::Xml
rescue NameError; end # rubocop:disable Lint/HandleExceptions
include ActiveModel::Serializers::JSON
module ClassMethods
... |
#==============================================================================
# ** Window_Chat
#------------------------------------------------------------------------------
# Esta classe lida com a janela do bate-papo.
#------------------------------------------------------------------------------
# Autor: Valent... |
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
@product = Product.where(user_id: params[:id])
@user_info = UserInfo.find_by(user_id: @user.id)
@product = Product.where(user_id: @user.id)
@search_rate3 = search_rate(3)
@search_rate2 = search_rate(2)
@s... |
#
# This file was ported to ruby from Composer php source code.
#
# Original Source: Composer\Package\Dumper\ArrayDumper.php
# Ref SHA: 346133d2a112dbc52163eceeee67814d351efe3f
#
# (c) Nils Adermann <naderman@naderman.de>
# Jordi Boggiano <j.boggiano@seld.be>
#
# For the full copyright and license information, plea... |
class BoardCase
attr_accessor :boardcase_content
def initialize
@boardcase_content = " "
end
def add_content(player)
@boardcase_content = player.sign #on met le signe du joueur en cours dans l'array
end
end |
# require 'purchase/cart'
# require 'purchase/creation'
class Purchase < ApplicationRecord
# include Creation
# include Cart
belongs_to :customer
has_many :order_items
# has_many :workflows, as: :workable, class_name: "Workflow::Base"
before_create :generate_purchase_number
PURCHASE_NUMBER_PREFIX = "811"
state... |
# frozen_string_literal: true
# rot13.rb
# Author: William Woodruff
# ------------------------
# A Cinch plugin that rot-13 'encryption' for yossarian-bot.
# ------------------------
# This code is licensed by William Woodruff under the MIT License.
# http://opensource.org/licenses/MIT
require_relative "yossar... |
require_relative 'view'
require_relative 'recipe'
require_relative 'scrape_allrecipes_service'
require 'open-uri'
require 'nokogiri'
require 'pry-byebug'
class Controller
def initialize(cookbook) # cookbook is an instance of Cookbook class
@view = View.new
@cookbook = cookbook
end
def create
#1. As... |
class Api::V1::Transactions::TransactionInvoiceController < ApplicationController
def show
@transaction = Transaction.find(params[:transaction_id])
@invoice = @transaction.invoice
end
end
|
#!/usr/bin/ruby
module MyEnumerable
def my_each
for i in 0..self.length-1
puts self[i]
end
end
end
class Array
include MyEnumerable
end
[1,2,3,4].my_each { |i| puts i} #prints 1 2 3 4 in the terminal
|
require 'cells_helper'
RSpec.describe LoyaltyAccount::Cell::ExpirationDate do
let(:account) { Struct.new(:expiration_date).new(expires) }
let(:result) { cell(account).() }
def have_text(text)
have_selector '.loyalty_account_expiration_date', text: text
end
def have_warning_icon
have_selector '.fa.f... |
Rails.application.routes.draw do
authenticated do
resources :users, only: [:show] do
resources :answers
end
resources :questions do
collection do
get :answered
end
resources :answers do
member do
patch :select_answer
end
end
end
en... |
require 'spec_helper'
require 'cinema/netflix'
require 'rspec/its'
require 'rspec-html-matchers'
describe Cinema::Netflix do
let(:netflix) { Cinema::Netflix.new('data/movies.txt') }
describe '.pay' do
it { expect { netflix.pay(5) }.to change { netflix.account }.by 5 }
end
describe '.how_much?' do
it ... |
# $LOAD_PATH << File.dirname(__FILE__) +'/../lib'
require 'rubygems'
require 'glutton_ratelimit'
puts "Maximum of 12 executions every 5 seconds (Bursty):"
rl = GluttonRatelimit::BurstyTokenBucket.new 12, 5
start = Time.now
n = 0
rl.times(25) do
puts "#{n += 1} - #{Time.now - start}"
# Simulating a constant-time ... |
source 'http://rubygems.org'
gem 'rails', '~> 3.2.0'
gem 'json'
gem 'jquery-rails'
gem 'sass-rails'
gem 'thin'
gem 'therubyracer'
gem 'whenever', :require => false
gem 'sorcery'
gem 'simple_form'
gem 'carrierwave'
gem 'savon'
gem 'draper'
gem 'kaminari'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'sunspot_rails... |
class UsersController < ApplicationController
before_action :set_user, :check_userself, :only => [:show, :edit, :coupon]
def show
if @user.invite_token == ""
@secure_number = SecureRandom.hex(8)
#Invitation.create!(invite_token: @secure_number)
@user.invite_token = @secure_number
@user.... |
class BundleContent < ActiveRecord::Migration
def self.up
create_table "bundle_contents" do |t|
t.column :content, :text, :limit => 16777215
end
add_column "bundles", :bundle_content_id, :integer
end
def self.down
drop_table "bundle_contents"
remove_column "bundles", :bundle_content_id
... |
class Agendas::TagsController < TagsController
before_action :set_taggable
private
def set_taggable
@taggable = Agenda.find(params[:agenda_id])
end
end
|
class UsersController < ApplicationController
def index
authorize! :manage, User
@users = User.all_paged(params.slice(*User::DEFAULT_FILTERS.keys).symbolize_keys)
@filters = params.reverse_merge(User::DEFAULT_FILTERS)
end
def new
if current_user
redirect_to root_path
end
@user = Us... |
require_relative './test_helper'
require 'time'
require './lib/merchant'
require './lib/merchant_repository'
require 'mocha/minitest'
class MerchantRepositoryTest < Minitest::Test
def setup
@engine = mock
@m_repo = MerchantRepository.new("./fixture_data/merchants_sample.csv", @engine)
end
def test_it_ex... |
module BGGTigris
def self.nickname
'tigris'
end
def self.my_turn?(doc, username)
current = doc.css('img[alt="Current Player"]').first.parent.css('.t_medtitle').first.content
username == current
end
def self.icon
'http://farm1.staticflickr.com/129/344808931_e82e768a14_s.jpg'
end
end
|
# This file configures our Error logging.
Rails.application.config.to_prepare do
# In the Era schema, the column is ERROR_LOG.ZUSERID:
NdrError.user_column = :custom_user_column
# Authenticate all users:
NdrError.check_current_user_authentication = ->(_context) { true }
end
|
FactoryGirl.define do
factory :word do
text_hindi "भालू"
text_romanized "baalu"
meaning
category
end
end
|
class GFA
##
# Find all independent modules by greedily crawling the linking entries for
# each segment, and returns an Array of GFA objects containing each individual
# module. If +recalculate+ is false, it trusts the current calculated
# matrix unless none exists
def split_modules(recalculate = true)
... |
require 'bindable_block'
class Surrogate
class Options
attr_accessor :options, :default_proc
def initialize(options, default_proc)
self.options, self.default_proc = options, default_proc
end
def has?(name)
options.has_key? name
end
def [](key)
options[key]
end
de... |
module TheCityAdmin
class UserBarcode < ApiObject
tc_attr_accessor :id,
:barcode,
:created_at
# Constructor.
#
# @param json_data JSON data of the user barcode.
def initialize(json_data)
initialize_from_json_object(json_data)
end
end
... |
require 'json'
class Product
def initialize(wombat_product, config={})
@wombat_product = wombat_product['product']
@config = config
@ebay_product = {}
end
def search_params
{ start_time_from: @config['ebay_start_time_from'],
start_time_to: @config['ebay_start_time_to'],
end_time_from... |
class BikesController < ApplicationController
def index
@bikes = Bike.all
render json: @bikes, include: [:zipcode]
end
def show
@bike = Bike.find(params[:id])
if @bike
render json: @bike
else
render json: {message:"We couldn't find a bike wi... |
class EventAnalyzer
attr_accessor :app_sha, :good_count, :count, :good_ips, :bad_ips
EXPECTED_IP_NETBLOCK = 28
def initialize(app_sha)
self.app_sha = app_sha
reset
end
def execute
reset
# SQL is very fast at counting and sorting
# also this could theoretically be a very large data set ... |
require "rails_helper"
require "app/services/manage_hound"
require "app/services/add_hound_to_repo"
require "app/models/github_user"
describe AddHoundToRepo do
describe "#run" do
context "with org repo" do
context "when repo is part of a team" do
context "when request succeeds" do
it "add... |
class CreatePdcaPosts < ActiveRecord::Migration[5.0]
def change
create_table :pdca_posts do |t|
t.text :plan
t.text :do
t.text :check
t.text :action
t.references :user, foreign_key: true
t.timestamps
end
add_index :pdca_posts, [:user_id, :created_at]
end
end
|
=begin
#EVE Swagger Interface
#An OpenAPI for EVE Online
OpenAPI spec version: 0.8.6
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.1
=end
require 'spec_helper'
require 'json'
# Unit tests for EVEOpenAPI::ContactsApi
# Automatically generated by swagger-codegen (gith... |
# require_relative 'prescription'
class Interaction < ActiveRecord::Base
belongs_to :med1, class_name: "Prescription"
belongs_to :med2, class_name: "Prescription"
def self.interactions(med)
self.all.select{|med1| med1.med1_id == med.id}
end
end
|
# encoding: utf-8
control "V-92629" do
title "The Apache web server log files must only be accessible by privileged users."
desc "Log data is essential in the investigation of events. If log data were to become compromised, competent forensic analysis and discovery of the true source of potentially malicious system ... |
module SlackBotServer
class App
def initialize
@filenames = ['', '.html', 'index.html', '/index.html']
@rack_static = ::Rack::Static.new(
-> { [404, {}, []] },
root: File.expand_path('../../public', __FILE__),
urls: ['/']
)
check_database!
end
def self.in... |
require_relative '../spec_helper'
RSpec.describe OpenAPIParser::PathItemFinder do
let(:root) { OpenAPIParser.parse(petstore_schema, {}) }
describe 'parse_path_parameters' do
subject { OpenAPIParser::PathItemFinder.new(root.paths) }
it 'matches a single parameter with no additional characters' do
re... |
module WsdlMapperTesting
class FakeS8r
def initialize
@xmls = {}
end
def xml_for_input(input, xml)
@xmls[input] = xml
end
def to_xml(input)
@xmls.fetch input
end
end
end
|
class Skill
class << self
def all
['Organized', 'Clean', 'Punctual', 'Strong', 'Crazy', 'Flexible']
end
end
end
|
# Widget for displaying the image data.
# If you want mouse events for interacting with the image, they can be put in this class.
class ImageWidget < Qt::Widget
# Initialize the widget.
def initialize(parent=nil)
@parent = parent
super(parent)
setMinimumSize(512, 512)
@pixmap = Qt::Pixmap.new
en... |
source "https://supermarket.getchef.com"
metadata
cookbook 'apt'
cookbook 'elasticsearch'
cookbook 'memcached'
cookbook 'runit'
# Convenience function to use local (development) cookbooks instead of remote
# repositories if they are found in ./cookbooks.
#
# Important:
# - local cookbook folder names MUST be identic... |
require 'test_driver/logger'
require 'test_driver/process'
module Browsers
PROGRAM_FILES = ENV[ENV.has_key?('ProgramFiles(x86)') ? 'ProgramFiles(x86)' : 'ProgramFiles']
def os_version
if @windows_version.nil?
@windows_version = mac? ? System::Environment.o_s_version.version.major : nil
end
@wi... |
form_for @content, :html => {:multipart => true} do |content|
tab "content" do
tab_item content.object.new_record? ? t('.new_content') : t('.edit_content', :name => content.object.name) do
content.text_field :name
content.text_area :description
content.select :purpose, t... |
# Migration to create preferences table
class UpdatePreferences < ActiveRecord::Migration[4.2]
def change
remove_column :preferences, :service, :string
remove_column :preferences, :url, :string
add_column :preferences, :auto_close_brackets, :boolean, after: :user_id
add_column :preferences, :smart_ind... |
class Favorite < ApplicationRecord
belongs_to :petprofile
belongs_to :user
end
|
class AddResetToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :reset, :string
add_column :users, :reset_confirmation, :string
end
end
|
# typed: strict
# frozen_string_literal: true
module Packwerk
class NodeProcessorFactory < T::Struct
extend T::Sig
const :root_path, String
const :context_provider, Packwerk::ConstantDiscovery
const :constant_name_inspectors, T::Array[ConstantNameInspector]
const :checkers, T::Array[Checker]
... |
class Product < ActiveRecord::Base
validates :description, :name, presence: true
validates :price, numericality: {only_integer: true}
def formatted_price
price_in_dollars = price.to_f * 10
sprintf("$%.2f", price_in_dollars)
end
end
|
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{coolerator.vision}
s.version = "0.2.10"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? ... |
class InstrumentController < ApplicationController
helper :work, :edition
def show
@instrument = Instrument.find(params[:id])
end
end
|
Rails.application.routes.draw do
devise_for :users
mount Ckeditor::Engine => '/ckeditor'
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
#top
get '/', to: 'top#index'
#user
get '/user/question', to: 'user#question'
#cart
get '/cart/complete', to: 'cart#complete'
ge... |
class ProductsController < ApplicationController
skip_before_action :authenticate_user!, only: [:index, :show]
before_action :set_product, only: [:show]
def index
@products = Product.all
end
def show
set_product
end
private
#def product_params
#params.require(:product).permit(:name, :d... |
#!/usr/bin/env ruby
require 'rubygems'
require 'thor'
class Runner < Thor
desc "solve", "solve problems"
method_option :all, :type => :boolean, :default => true, :aliases => "-a", :desc => "Run all tests"
method_option :only, :type => :array, :required => false, :aliases => "-o", :desc => "Run specifi... |
class AddCashFlowLotSizeToProperties < ActiveRecord::Migration
def change
add_column :properties,:cash_flow,:decimal,precision: 15,scale: 2
add_column :properties,:lot_size,:integer
end
end |
class AddHtmlCacheFields < ActiveRecord::Migration
def up
add_column :repositories, :notes_html, :text
add_column :production_units, :notes_html, :text
add_column :assessments, :notes_html, :text
add_column :assessments, :preservation_risks_html, :text
add_column :collections, :notes_html, :text
... |
Refinery::PagesController.class_eval do
before_action :find_all_landing_images, :only => [:home]
protected
def find_all_landing_images
@landing_images = Refinery::LandingImages::LandingImage.order('position ASC')
end
end |
class HomeController < ApplicationController
def index
@email = user_signed_in? ? current_user.email : 'undefined'
end
end
|
#1から10000までの数字を順にカンマ区切りで出力するプログラムを作成する
#出力条件
#3の倍数のときは数字を出力せずに文字列Fizzを出力
#5の倍数のときは数字を出力せずに文字列Buzzを出力
#15の倍数のときは数字を出力せずに文字列FizzBuzzを出力
#
#追加制限
#剰余演算子は使用しない
#最大値まで第1引数の倍数を配列にして返すメソッド
def multiple_calc(multi, max)
score_result = []
work = multi
while (work <= max)
score_result.push(work)
work += multi
... |
class AddLastSyncToGsNodes < ActiveRecord::Migration
def change
add_column :gs_nodes, :last_sync, :datetime
end
end
|
require 'maestro_plugin'
require 'puppet_blacksmith'
# overwrite git execution to use our utils
module Blacksmith
class Git
def exec_git(cmd)
new_cmd = "LANG=C #{git_cmd_with_path(cmd)}"
Maestro.log.debug("Running git: #{new_cmd}")
exit_status, out = Maestro::Util::Shell.run_command(new_cmd)
... |
require 'rails_helper'
describe Item do
%i(price seller title).each do |field|
it "requires a #{field}" do
# item = build :item, :price => nil
item = build :item, field => nil
expect( item.valid? ).to be false
end
end
it 'requires price to be positive' do
item = build :item, price:... |
class ClientAddrsController < ApplicationController
before_filter :authenticate, :only => [:create, :edit, :update, :new]
def new
@title = "Add Address for Client"
@client = client_account
@client_addr = @client.client_addrs.new
end
def create
@client = client_account
@client_addr = @c... |
class RemoveSlugFromCategories < ActiveRecord::Migration[4.2]
def change
remove_column :categories, :slug, :remove
end
end
|
module Whiteplanes
Token = Struct.new(:token, :step, :parameter)
@tokens = {
push: Token.new(' ', 2, true),
copy: Token.new(' \t ', 3, true),
slide: Token.new(' \t\n', 3, true),
duplicate: Token.new(' \n ', 3, false),
swap: Token.new(' \n\t', ... |
class RMQ
# @return [RMQResource]
def self.resource
RMQResource
end
# @return [RMQResource]
def resource
RMQResource
end
end
class RMQResource
class << self
def find(resource_type, resource_name)
application = PMApplication.current_application
application.resources.getIdentifier(... |
# 1. que diga "Bienvenido a la calculadora mas deahuevo"
# input <=
# output <= "Bienvenido a la calculadora mas deahuevo"
puts "Bienvenido a la calculadora mas deahuevo"
# 6. repetir hasta que escriba "salir"
# input <= codigo de los pasos 2, 3 y 4
# output <= loop until "salir"
while true
# 2. imprimir "Ing... |
class PassangerVagon
attr_reader :type
def initialize
@type = 'passanger'
end
end |
require 'bookmark'
require 'database_helpers'
describe Bookmark do
let(:bookmark) {described_class}
describe '.all' do
it "calls all bookmarks" do
# connection = PG.connect(dbname: 'bookmark_manager_test')
bookmark = Bookmark.create(url: "http://www.makersacademy.com", title: "Makers Academy")
... |
class PerformancePiecesController < ApplicationController
def new
@piece = Piece.new
end
def create
@performance_piece = PerformancePiece.new(performance_piece_params)
if @performance_piece.save
flash[:success] = "Piece Added!"
else
flash[:warning] = "Oops! There was a problem"
en... |
module BF
module Instruction
DECREMENT = Instruction::Decrement.new
INCREMENT = Instruction::Increment.new
INPUT_CHARACTER = Instruction::InputCharacter.new
JUMP = Instruction::Jump.new
JUMP_RETURN = Instruction::JumpReturn.new
MOVE_LEFT = Instruction::MoveLeft.new
MOVE_RIGHT = Instructio... |
class BookUsersController < ApplicationController
before_action :set_book_user, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
load_and_authorize_resource
# GET /book_users
# GET /book_users.json
def index
@book_users = BookUser.set_current_user_records(current_user)
end
... |
# frozen_string_literal: true
# Encapsulates the many genders that are affected by this
class Gender < ActiveRecord::Base
has_many :subjects
alias_attribute :name, :sex
end
|
require 'sinatra/base'
require 'idobata_gateway/strategies'
module IdobataGateway
class Application < Sinatra::Base
configure do
set :show_exceptions, false
end
helpers do
def strategy
IdobataGateway::Strategies.find(params[:strategy]).new(self, params[:hook_id])
rescue Idobata... |
require File.dirname(__FILE__) + '/test_helper'
require 'nokogiri'
require 'sanitize'
class HttpclientTest < Test::Unit::TestCase
def setup
@junit_url = 'http://127.0.0.1:3000/caterpillar/test_bench/junit'
end
def teardown
# Nothing really
end
def test_get
# SIMPLE GET
client = HTTPC... |
class Api::SearchResultsController < ApplicationController
def search
@search_results = Project
.search_by_title(params[:query])
.includes(:searchable)
render :search
end
end
|
# frozen_string_literal: true
require 'test_helper'
module Admin
class HoldsControllerTest < ActionController::TestCase
setup do
@hold = holds(:hold2)
@hold11 = holds(:hold11)
sign_in AdminUser.create!(email: 'admin@example.com', password: 'password')
end
test "test index method" do
... |
class AddStartLocationIdAndDestinationLocationIdToRides < ActiveRecord::Migration[5.0]
def change
add_column :rides, :start_location_id, :integer
add_column :rides, :destination_location_id, :integer
end
end
|
module MugMultiples
class Face < MugMultiples::Image
def eyes?
eyes.count > 0
end
def eyes(opts={})
eyes(opts)
end
def detect_eyes(opts={})
detect_objects(:eyes, opts)
end
end
end |
module Api
module V0
class EndpointsController < ApplicationController
def create
endpoint = Endpoint.create!(create_params)
render :json => endpoint, :status => :created, :location => api_v0x0_endpoint_url(endpoint.id)
end
def destroy
Endpoint.destroy(params[:id])
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.