text stringlengths 10 2.61M |
|---|
class TeacherController < ApplicationController
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = exception.message
redirect_to home_path
end
before_filter :authenticate_user!
before_filter :authenticate_teacher
def index
end
def practicas
@practicas = current_user.practicas
... |
class ActionStepsController < ApplicationController
include Authenticatable
before_action :lookup_all, only: [:index]
before_action :lookup_one_action, only: [:edit, :update, :complete, :uncomplete]
# GET /action_steps
# GET /action_steps.json
def index
@action_step = ActionStep.new
respond... |
require 'setback/util'
require 'redis'
require 'redis-namespace'
require 'uri'
require 'yaml'
module Psych
class SyntaxError
end
end
module Setback
class RedisProvider
class << self
attr_writer :redis_url, :namespace_prefix
def redis_url
@redis_url ||= 'redis://localhost:6379'
end... |
class Contact < ActiveRecord::Base
attr_accessible :email, :name
validates :email, :presence => true
validates :name, :format => { :with => /^[a-zA-z ]*$/} # Alpha, Nil and Spaces
has_many :send_lists_contacts, :dependent => :destroy
has_many :send_lists, :through => :send_lists_contacts
def send_forma... |
class TasksController < ApplicationController
before_action :set_list , only: [:new, :create, :show, :edit, :update,:destroy]
before_action :set_task, only: [ :show, :edit, :update,:destroy]
before_action :check_admin , only: [:new, :destroy]
before_action :downcase_strip_title, only: [:create]
def index
... |
class RenameEvaluationColumnToStoreComments < ActiveRecord::Migration[5.2]
def change
rename_column :store_comments, :evaluation, :rate
end
end
|
class AddLastPublicStoryFieldsToUsers < ActiveRecord::Migration
def change
add_column :users, :last_public_story_id, 'CHAR(10)'
add_column :users, :last_public_story_created_at, :datetime
add_index :users, :last_public_story_created_at
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Applicants name link', type: :feature do
before(:each) do
@application1 = Application.create(
name: 'Test App Name',
address: 'Test App Address',
city: 'Test App City',
state: 'Test App State',
zip: 'Test App Zip'... |
# -*- coding: utf-8 -*-
require 'gtk2'
require 'lib/diva_hacks'
module Pango
ESCAPE_RULE = {'&': '&'.freeze ,'>': '>'.freeze, '<': '<'.freeze}.freeze
class << self
# テキストをPango.parse_markupで安全にパースできるようにエスケープする。
def escape(text)
text.gsub(/[<>&]/){|m| ESCAPE_RULE[m] }
end
alias ol... |
class Participant < ActiveRecord::Base
belongs_to :role
belongs_to :event
has_many :participant_days
has_many :days, through: :participant_days
has_many :participant_services
has_many :services, through: :participant_services
enum gender: %i(man woman)
enum status: %w(created pending delayed paid arr... |
Rails.application.routes.draw do
# get 'sessions/new'
# get 'sessions/create'
# get 'sessions/destroy'
# get 'users/new'
# get 'users/create'
# get 'users/show'
#user signup routes
get "/signup", to: "users#new"
get"/profile", to: "users#show"
resources :users, only: [:create]
#sessions routes
get "/log... |
class EditItem < HyperComponent
param :todo
triggers :saved
triggers :cancel
others :etc
after_mount { DOM[dom_node].focus }
render do
INPUT(@Etc,
defaultValue: @Todo.title,
placeholder: 'What is left to do today?',
key: @Todo)
.on(:enter) do |evt|
@Todo.update(title: ... |
require './morse.rb'
class Game
ALPHABET = ("a".."z").to_a + [" "]
MAX_LETTERS_IN_ANSWER = 100
def initialize(answer=nil)
@answer = answer
@answer ||= (rand(MAX_LETTERS_IN_ANSWER)+1).times.map{ ALPHABET[rand(26)] }.join
@question = Morse.tap_out(@answer)
end
def question
@question
end
d... |
#!/usr/bin/env ruby
require 'TestSetup'
require 'test/unit'
#require 'rubygems'
require 'ibruby'
include IBRuby
class SQLTypeTest < Test::Unit::TestCase
CURDIR = "#{Dir.getwd}"
DB_FILE = "#{CURDIR}#{File::SEPARATOR}sql_type_test.ib"
def setup
puts "#{self.class.name} started." if TEST_... |
=begin
This file is part of the Arachni::Reactor project and may be subject to
redistribution and commercial restrictions. Please see the Arachni::Reactor
web site for more information on licensing and terms of use.
=end
module Arachni
class Reactor
class Connection
# @author Tasos "Zapotek" Laskos <tas... |
require 'graphql'
module Types
ManagedSubscriptionType = GraphQL::ObjectType.define do
name 'ManagedSubscription'
description 'Resembles a ManagedSubscription Object Type'
field :id, !types.ID
field :tenant_id, types.String
field :subscription_id, types.String
field :subscription_source, ty... |
# frozen_string_literal: true
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :order do
date Time.zone.today
from { Faker::Company.name }
user
company
trait :with_ordered_status do
status :ordered
end
factory :past_order do
... |
require 'test_helper'
class FlannelTest < Test::Unit::TestCase
should "wrap functionality up in a neat package" do
markup = ":header_two foo: Foo\n\n:list list: Bar"
assert_equal "<h2 id='foo'>Foo</h2>\n\n<ul id='list'><li>Bar</li></ul>", Flannel.quilt(markup)
end
should "return nil if text is nil" do
... |
class QuoteItemsController < ApplicationController
before_filter :authenticate
def new
end
def create
@quote = Quote.find(params[:quote_id])
@quote_item = @quote.quote_items.build(params[:quote_item])
if @quote_item.save
@quote_items = @quote.quote_items.paginate(:page => params[:page],... |
# Advance Conditionals with Methods in Ruby part 3
# Check if this object is responsive to the method next
num = 1000
p num.respond_to?("next")
puts
# check if this object is responsive to .length method
p num.respond_to?("length")
puts
# Making a condition to run a method
if num.respond_to?("next")
p num.next... |
require 'rails_helper'
RSpec.describe "Microposts", type: :request do
before(:each) do
user = create(:user)
visit signin_path
fill_in "session_email", :with => user.email
fill_in "session_password", :with => user.password
click_button "Sign in"
end
describe "creation" do
describe "failure" do
... |
# coding: utf-8
module HupoWidget
class Engine < Rails::Engine
initializer 'hupo_widget.add_widget_paths' do |app|
app.config.paths.add 'app/widgets', glob: '**/*.rb'
app.config.eager_load_paths += app.config.paths['app/widgets']
app.config.paths.add 'config/widgets', glob: '**/*.yml'
end
... |
require 'rails_helper'
RSpec.describe UsersExpense, type: :model do
it { expect(subject).to belong_to(:user) }
it { expect(subject).to belong_to(:expense) }
end
|
class Lichsu < ActiveRecord::Base
belongs_to :cauhoi
belongs_to :nguoichoi
end
|
namespace :unit do
desc "Builds the unit tests for COMPONENT on the MinGW platform"
task :'mingw' do
include UnitTestOperations
component=Gaudi::Component.new($configuration.component,$configuration,'mingw')
ut=unit_test_task(component,$configuration)
Rake::Task[ut].invoke
sh(ut.name)
end
end
... |
$: << File.join( File.dirname( __FILE__ ), '../lib' )
require 'rubygems'
require 'rspec'
require 'data_table/validators'
describe Validators do
before :each do
class MyTest
include Validators
end
end
context "DataTable" do
it 'raise an exception when not a DataTable' do
t = MyTest.new
... |
begin
require 'robots'
rescue LoadError
end
module Spider
class Agent
def initialize_robots
unless Object.const_defined?(:Robots)
raise(ArgumentError,":robots option given but unable to require 'robots' gem")
end
@robots = Robots.new(@user_agent)
end
... |
if(ARGV.empty?)
puts "empty argument"
exit
end
domain = ARGV.first
dns_raw = File.readlines("zone.txt")
$typeA = {}
$typeC = {}
def parse_dns(dns_raw)
dns_raw.each do |raw_record|
record = raw_record.split(",")
if record[0] == "A"
$typeA[record[1].strip.to_sym] = record[2].strip
elsi... |
class Fine < ActiveRecord::Base
belongs_to :infraction
belongs_to :law
end
|
class AddUserIdToOgre < ActiveRecord::Migration[5.2]
def change
add_column :ogres, :user_id, :string
end
end
|
class Hazy < Formula
desc "Command line interface (CLI) to the Hazy web service."
homepage "https://github.com/hazy/toolbelt"
url "https://github.com/hazy/toolbelt/releases/download/v0.0.3-alpha/hazy.tar.gz"
sha256 "a88cd10f9f57fe15798d8dac581b744b0aa1d9bd575df91cb47ff6835ef925e1"
version "0.0.3"
bottle :u... |
# @param {Integer[]} nums
# @return {Integer}
def array_pair_sum(nums)
nums.sort!
res = 0
nums.each_with_index do |n, index|
if index % 2 == 0
res += n
end
end
return res
end
p array_pair_sum([1,1]) |
require 'rails_helper'
RSpec.describe "admin/mona_articles/index", type: :view do
before(:each) do
assign(:mona_articles, [
MonaArticle.create!(),
MonaArticle.create!()
])
end
it "renders a list of admin/mona_articles" do
render
end
end
|
# ****************************************************************************
#
# Copyright (c) Microsoft Corporation.
#
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
# copy of the license can be found in the License.html file at the root of this distribution. If
# you ... |
Types::ConversationType = GraphQL::ObjectType.define do
name 'Conversation'
field :author do
type Types::UserType
resolve ->(obj, args, ctx) { obj.author }
end
field :receiver do
type Types::UserType
resolve ->(obj, args, ctx) { obj.receiver }
end
end
|
class InviteRequestPolicy < ApplicationPolicy
def new?
true
end
def create?
true
end
def created?
true
end
def approve?
user.admin?
end
def save_approve?
user.admin?
end
def decline?
user.admin?
end
end
|
require "digest"
module Digest
class Perfect
class << self
def hexdigest(string_to_hash)
bytes = byte_array(string_to_hash)
length = bytes.length
a = b = 0x9E3779B9
c = 0xE6359A60
k, len = 0, length
while(len >= 12)
a = m(a + bytes[k + 0] + (byt... |
require 'spec_helper'
describe 'CapsuleCD::Ruby::RubyEngine', :ruby do
describe '#build_step' do
describe 'when building an empty package' do
let(:engine) do
require 'capsulecd/ruby/ruby_engine'
CapsuleCD::Ruby::RubyEngine.new(source: :github,
pac... |
class User < ActiveRecord::Base
searchkick callbacks: :async
enum role: [:guest, :user, :manager, :administrator]
after_initialize :set_default_role, :if => :new_record?
has_many :news
has_many :knowledge
has_many :overtime
has_many :logbook
has_many :holidays
has_many :event
has_many :post
devise :database_... |
# ****************************************************************************
#
# Copyright (c) Microsoft Corporation.
#
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
# copy of the license can be found in the License.html file at the root of this distribution. If
# you ... |
# frozen_string_literal: true
module Sentry
# TransactionEvent represents events that carry transaction data (type: "transaction").
class TransactionEvent < Event
TYPE = "transaction"
# @return [<Array[Span]>]
attr_accessor :spans
# @return [Hash]
attr_accessor :measurements
# @return [F... |
#!/usr/bin/env ruby
$LOAD_PATH << File.expand_path("../../lib", __dir__)
require 'async/reactor'
require 'async/io/stream'
require 'async/io/host_endpoint'
require 'async/io/protocol/line'
class User < Async::IO::Protocol::Line
end
endpoint = Async::IO::Endpoint.parse(ARGV.pop || "tcp://localhost:7138")
input = As... |
# source: https://fire.ca.gov/incidents/2019/
# pulled from https://fire.ca.gov/umbraco/Api/IncidentApi/GetIncidents?year=2019
require "json"
require "hashie"
require "active_support/all"
class Fire < Hashie::Mash
def initialize(hash)
super(
hash.dup.transform_keys { |k| k.underscore }
)
end
end
cl... |
module PluckMap
module HashPresenter
def to_h(query)
define_to_h!
to_h(query)
end
private def define_to_h!
ruby = <<-RUBY
def to_h(query)
pluck(query) do |results|
results.map { |values| values = Array(values); { #{attributes.map { |attribute| "#{attribute.name.... |
module LittleMapper
module Mappers
module AR
class OneToOne < Mappers::Base
attr_accessor :mapper, :field, :persistent_klass, :persistent_field, :entity_setter, :persistent_entity_setter
def initialize(mapper, field, opts = {})
@mapper = mapper
@field = field
@p... |
class ItemPolicy < ApplicationPolicy
attr_reader :user, :item
def initialize(user, item)
@user = user
@item = item
end
def update?
user.admin?
end
def destroy?
user.admin?
end
end |
module SchemaToScaffold
class Schema
attr_reader :data, :tables
def initialize(data)
@data, @tables = data, Schema.parse(data)
end
def table_names
tables.map(&:name)
end
def print_table_names
table_names.each_with_index { |name, i| puts "#{i}. #{name}" }
end
def... |
class Try
def inspect
"Trying to inspect me, eh!?"
end
def to_s
"See? 'to_s' is called."
end
end
man = Try.new
# method 'p' calls instance method internally on the object passed to it.
p man
# 'puts' calls 'to_s' method internally.
puts man |
class CreateWebPlans < ActiveRecord::Migration
def change
create_table :web_plans do |t|
t.references :project, index: true, foreign_key: true
t.string :moodboard
t.text :themes
t.string :chosen_theme
t.text :desc
t.string :inspiration_links
t.timestamps null: false
... |
class CreateCourses < ActiveRecord::Migration[6.0]
def change
create_table :courses do |t|
t.string :title, null: false
t.string :term, null: false
t.string :units
t.string :campus
t.string :subject, default: 'CSE'
t.string :catalog_number, null: false
t.timestamps
... |
require 'pp'
class TileBag
def initialize(options)
fill_bag(options.fetch(:tiles, []))
end
def count(tile)
@counts[tile]
end
def points(tile)
@points[tile]
end
def can_form?(word)
letters = {}
word.each_char do |letter|
letters[letter] = letters.fetch(letter, 0) + 1
end
... |
require 'spec_helper'
describe StylistAdmin::Assigns::BedroomsController do
# fixtures :all
render_views
before(:all) do
create_product_type_structure
end
before(:each) do
activate_authlogic
@user = Factory(:stylist_user)
login_as(@user)
@customer = Factory(:user)
@product = Factor... |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :visit do
visit_nr 1
visit_date 2.years.ago
league "The Championship"
home_club "Charlton Athletic"
away_club "Millwall"
ground "The Valley"
street ... |
# frozen_string_literal: true
module Dry
module Types
# Sum type
#
# @api public
class Sum
include Composition
def self.operator
:|
end
# @return [Boolean]
#
# @api public
def optional?
primitive?(nil)
end
# @param [Object] inpu... |
require "rails_helper"
RSpec.describe InvestigationinjurylocationsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(get: "/investigationinjurylocations").to route_to("investigationinjurylocations#index")
end
it "routes to #new" do
expect(get: "/investigation... |
require 'em-synchrony'
require 'em-synchrony/mysql2'
require 'em-synchrony/fiber_iterator'
require 'amqp'
require 'fiber'
require 'yaml'
require 'logging'
require 'digest'
require_relative 'SearchWorker'
require_relative File.expand_path(File.join(File.dirname(__FILE__), '../app/models/Product'))
require_relative File... |
module Mutations
class Parse < Mutations::BaseMutation
argument :cdl, String, required: true
field :response, GraphQL::Types::JSON, null: true
def resolve(cdl:)
{
response: (ParserEval.run!(cdl, :Ns) rescue nil)
}
end
end
end
|
class CreateTables < ActiveRecord::Migration
def change
create_table :tables do |t|
t.string :position
t.string :team
t.string :played
t.string :won
t.string :drawn
t.string :lost
t.string :goalfor
t.string :goalagainst
t.string :goaldifference
t.string :points
... |
# == Schema Information
#
# Table name: profiles
#
# id :bigint not null, primary key
# role :string
# profile_type :string
# first_name :string
# last_name :string
# civility :string
# address :string
# phone :string
# country_id :bigint
# locality_id :bigi... |
module SyntheticHelper
include CradleModule
def show_internal_structure(option)
option[:section_indexes] = "" if option[:section_indexes].blank?
html_string = ""
option[:structure].each_with_index{|section,index|
next if index == 0
if is_string(section) == true
if section =~ /^\d+... |
module Effects
class External < Effect
class ExternalEffectFailed < StandardError; end
class InvalidConfiguration < StandardError; end
def perform(workflow_id, subject_id)
raise InvalidConfiguration unless valid?
reductions = SubjectReduction.where(
workflow_id: workflow_id,
... |
require 'spec_helper'
describe MarkdownMediaSplitter do
subject { described_class }
it "splits the content on the split tag " do
ms = subject.new(one_media_tag)
expect(ms.top_text).to eq(split_top_text)
expect(ms.bottom_text).to eq(split_bottom_text)
end
it "puts all the content in the bottom ... |
class AddScaleToPress < ActiveRecord::Migration
def self.up
add_column :press, :scale, :string
end
def self.down
remove_column :press, :scale
end
end
|
require "spec_helper"
describe "/api/v1/features", :type => :api do
let(:market) { Factory(:market, :name => "Atlanta") }
before do
@user = create_user!
@user.update_attribute(:admin, true)
@user.permissions.create!(:action => "view", :thing => market)
@feature = Factory(:feature)
end
let... |
Rails.application.routes.draw do
root to: 'users#welcome'
devise_for :users
get '/proposals', to: "proposals#index", as: "after_sign_out_path_for"
get '/users/proposals', to: "users#proposals", as: "users_proposals"
get '/proposals/:proposal_id/amendments/:id/accept', to: "amendments#accept", as: "accept_amen... |
class ApplicationController < ActionController::Base
protect_from_forgery
def current_user
if session[:user_id]
# ||= assigns only if not already assigned (only calling db if necessary)
@current_user ||= User.find(session[:user_id])
end
@current_user
end
def logged_in?
# !! R... |
class Hangman
attr_accessor :name,:guessed,:correct_blank,:counter
def initialize(password_name)
@name = password_name.upcase
@guessed = []
@counter = 7
@correct_blank = blank
end
def make_move(letter)
if correct_letter?(letter)
correct_index(letter)
else
@counter -=1
end
end
def charcoun... |
require 'singleton'
class Question
include Singleton
include Enumerable
attr_accessor :answer, :question
def initialize
@statement = [
{
q: [
'3 5 R',
'790319030',
'091076399',
'143245946',
'590051196',
'398226115',
'4425... |
require 'net/http'
namespace :crawler do
desc "Do all currently opened tasks from crawlers"
task :crawl => :environment do
# while CrawlerLog.count(:conditions => ['status = ? or status = ?', :pull, :push]) > 0
Crawler.pull :sleep => 10, :limit => 5
Crawler.push :sleep => 10, :limit => 5
# end
... |
module Yaks
class Format
# Hypertext Application Language (http://stateless.co/hal_specification.html)
#
# A lightweight JSON Hypermedia message format.
#
# Options: +:plural_links+ In HAL, a single rel can correspond to
# a single link, or to a list of links. Which rels are singular
# and... |
require 'rubygems'
require 'ngrams'
class PasswordGenerator
def initialize(file = Ngram::Dictionary::DEFAULT_STORE)
@dictionary = Ngram::Dictionary.load(file)
end
def generate_password(length)
@dictionary.word(length)
end
end
|
class Group < ActiveRecord::Base
has_many :matches
has_many :teams
belongs_to :competition
end
|
require File.dirname(__FILE__) + '/spec_helper'
describe "pattern_match" do
def o(&block)
Class.new(&block).new
end
def not_pattern_match
raise_error(/No pattern matching/)
end
it "should call the method when pattern is matched" do
o { pattern_match(:foo, Integer) { :integer } }.
foo(123)... |
module Kindergarten
# A very easy governess, lets everything happen unguarded. Perhaps not such
# a good idea to be using this...
#
class EasyGoverness < HeadGoverness
def initialize(child)
super
@unguarded = true
end
end
end |
def multiplication_table (number, heading = false, decorate = false)
column_width(number)
heading(heading)
decorate(decorate)
table(number)
decorate(decorate)
end
private
def column_width(number)
@col_width = (number * number).to_s.length
if number == 0 || number == 1
@decoration_width = 3
else
... |
require 'active_record'
require 'active_support/concern'
module ActsAsSuggestable
extend ActiveSupport::Concern
included do
extend ClassMethods
end
module ClassMethods
def is_suggestee
send :include, SuggesteeMethods
end
def is_suggestor
send :include, SuggestorMethods
... |
class InstantBookingProfilesController < ApplicationController
layout 'application-admin'
before_filter :profile_owner, :only => [:edit, :update]
def edit
@instant_booking_profile = InstantBookingProfile.find_by_id(params[:id])
render 'edit'
end
def update
@instant_booking_profile ... |
class User < ApplicationRecord
devise :invitable, :database_authenticatable, :lockable, :recoverable, :rememberable, :trackable, :secure_validatable, :password_expirable, :password_archivable, :invite_for => 1.week
attr_reader :raw_invitation_token
enum role: [:volunteer, :accompaniment_leader, :admin]
enum vo... |
require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "pokename"
gem.summary = "Choose a random Pokémon name to name your project"
gem.description = "This gem choose one from the 151 Pokémons names (Yeah, just the first generation) to be used in your projects.... |
class OrderItem < ApplicationRecord
belongs_to :dish
belongs_to :order
belongs_to :user
belongs_to :day
before_save :set_total
def total
if persisted?
self[:total]
else
dish.price
end
end
private def set_total
self[:total] = total
end
end
|
module BEL
module Format
Format = BEL::Extension::Format
FormatError = BEL::Extension::Format::FormatError
def self.evidence(input, input_format)
prepared_input = process_input(input)
in_formatter = BEL::Extension::Format.formatters(input_format) or
raise FormatError.new(input_... |
require 'bcrypt'
class User
attr_reader :password
attr_accessor :password_confirmation
include DataMapper::Resource
# when we 'include' and call DataMapper as a class,
# Resource is the module in that class
# include takes all the methods in the Resource module
# and makes them class methods inside... |
# Encoding: UTF-8
require 'spec_helper'
require 'openssl'
describe WikipediaWrapper, :type => :model do
describe ".search" do
ww = WikipediaWrapper.new("svend foyn")
before { @result = ww.search() }
subject { @result }
it "should return array" do
expect(@result).to be_an_instance_of(Array)
end
it "s... |
class OrderItemsController < ApplicationController
before_action :authenticate_user!, only: [:create]
layout 'header'
def show
render 'carts/show'
end
def create
if user_signed_in?
@order = current_order
@order_item = @order.order_items.new(order_item_params)
@order_item.save!
... |
class ChangeDates < ActiveRecord::Migration
def change
change_column :cat_rental_requests, :start_date, :datetime
change_column :cat_rental_requests, :end_date, :datetime
end
end
|
class Warden::SessionSerializer
def serialize(record)
[record.class, record.id]
end
def deserialize(keys)
klass, id = keys
klass.first(:conditions => { :id => id })
end
end |
# Write a program that prints the numbers from 1 to 100.
# But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”
oneToHundred = 1..100
oneToHundred.each {|i|
if i%3==0 && i%5==0
puts... |
class PrivateController < ApplicationController
before_action :before_action
after_action :after_action
private def before_action
redirect_to root_path if !user_signed_in?
@user = current_user
end
private def after_action
end
end
|
require 'i18n'
module Rack
module DevMark
module I18nHelper
def self.included(base)
class << base
def env_with_i18n
s = env_without_i18n
::I18n.translate(s, scope: 'rack_dev_mark', default: s)
end
alias_method :env_without_i18n, :env
a... |
require 'rails_helper'
RSpec.describe "guns/edit", type: :view do
before(:each) do
@gun = assign(:gun, Gun.create!(
:name => "MyString",
:description => "MyText",
:size => 1,
:damage => 1.5,
:fire_rate => 1.5,
:clip_size => 1,
:reload_time => 1.5,
:proj_size => 1.5... |
task :test do
original_words = File.readlines 'words.txt'
unique_words = original_words.uniq
if original_words.size != unique_words.size
raise "Duplicate words detected"
end
puts "No duplicate words"
sorted_words = original_words.sort
original_words.each.with_index do |w1,i|
w2 = sorted_words[i]
... |
#!/usr/bin/env ruby
class Hangman
def initialize(guessing_player, checking_player)
@guessing_player, @checking_player =
guessing_player, checking_player
@board = []
guessing_player.board = @board
end
def play
puts 'Thank-you for playing HangmanTM, Enterprise Edition!'
secret_word_pick
... |
module Api
class BooksController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :set_book, only: [:show, :update]
skip_before_action :check_user_confirmation_status, only: [:index, :show]
def index
@books = Book.nearby(set_coordinates, current_u... |
class Ogre
attr_accessor :name, :home, :encounter_counter, :swings
def initialize(name, home = "Swamp")
@name = name
@home = home
@encounter_counter = 0
@swings = 0
end
def encounter(human)
human.encounter_counter += 1
if human.encounter_counter < 3
human.ogre_aware = false
e... |
# frozen_string_literal: true
module Assembler
class Parser
AInstruction = Struct.new(:value) do
def accept(visitor)
visitor.visit_a_instruction(self)
end
end
CInstruction = Struct.new(:destination, :computation, :jump) do
def accept(visitor)
visitor.visit_c_instruction(... |
require 'test/unit'
# require "global/jwOneTag"
# require "global/jwSingle"
require '../../lib/global/jwOneTag'
require '../../lib/global/jwSingle'
module Jabverwock
using StringExtension
class DoctypeTest < Test::Unit::TestCase
class << self
# テスト群の実行前に呼ばれる.変な初期化トリックがいらなくなる
def startup
... |
# Copyright 2011-2015, The Trustees of Indiana University and Northwestern
# University. 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
#
# ... |
class BeerClub < ActiveRecord::Base
has_many :memberships, dependent: :destroy
has_many :members, through: :memberships, source: :user
def to_s
"#{name}, anno #{founded} #{city}"
end
end
|
class MatchesController < ApplicationController
before_action :set_match, only: [:show, :edit, :update, :destroy]
before_action :require_login
def require_login
if not user_signed_in? || admin_signed_in?
flash[:error] = "Você precisa estar logado para acessar esta seção."
redirect_to new_user_s... |
require File.dirname(__FILE__) + '/../spec_helper'
describe PostsController do
include SpecControllerHelper
include FactoryScenario
before :each do
Site.delete_all
factory_scenario :forum_with_topics
@post = Factory(:post, :author => @user, :commentable => @topic)
@topic.reload; @forum.reload ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.