text stringlengths 10 2.61M |
|---|
class Api::Public::TargetGroupsController < ApiController
def show
@target_groups = TargetGroup.by_country_code(params[:country_code])
render @target_groups
end
end
|
module ZMQ
class Socket
attr_reader :socket
def initialize sock
@socket = sock
end
def send msg, flags=0
p, size = if msg.is_a?(NSData)
[msg.bytes, msg.length]
else
[msg.to_data.bytes, msg.size]
end
zmq_send @socket,... |
class Person
def initialize(firstName, lastName)
@firstName = firstName
@lastName = lastName
end
def to_s
"Person: #@firstName #@lastName"
end
end
person = Person.new("Lino","Espinoza")
print person |
require 'optparse'
require 'strscan'
require 'fileutils'
module Deadpool
module Generator
class UpstartConfig
attr :active
alias active? active
def initialize
@active = false
@options = [
Deadpool::ScriptOption.new('deadpool_config_dir', '/etc/deadpool'),
... |
require 'benchmark'
require 'nokogiri'
require 'ox'
require 'colorize'
# This file contains a Jmeter Performance Test Result
# it contains 1.5M lines and is 51MB
source_file = "test_file.xml"
class NokoDocSax < Nokogiri::XML::SAX::Document
attr_reader :counter
def initialize
@counter = 0
end
def star... |
class ProjectsController < ApplicationController
before_filter :authenticate_user!, except: [:show]
def new
@project = Project.new
end
def show
@project = Project.find(params[:id])
end
def destroy
@project = Project.find(params[:id])
if(@project.destroy)
flash[:success] = "You... |
class User < ApplicationRecord
def to_string
"#{id}. #{name} #{email}"
end
end
|
require "#{File.dirname(__FILE__)}/../code/Demo"
def render_partial(partial, locals = {})
# assuming we want to keep the rails practice of prefixing file names
# of partials with "_"
Haml::Engine.new(File.read("#{File.dirname(__FILE__)}/../partials/_#{partial}.html.haml")).render(Object.new, locals)
end |
# frozen_string_literal: true
require_relative '../lib/gamelogic'
require_relative '../lib/players'
RSpec.describe GameLogic do
subject(:game) { GameLogic.new }
describe '#check_empty_space method' do
context 'when all the cells are available for marking' do
it 'will return true' do
game.instanc... |
pg_ver = input('pg_version')
pg_dba = input('pg_dba')
pg_dba_password = input('pg_dba_password')
pg_db = input('pg_db')
pg_host = input('pg_host')
pg_log_dir = input('pg_log_dir')
pg_audit_log_dir = input('pg_audit_log_dir')
control "V-72975" do
title "PostgreSQL must generate audit records when unsuccessful a... |
#spec/cc_test.rb
require 'rspec'
require './lib/cc.rb'
describe Cc do
describe '#caesar_cipher' do
it "Accepts two parameters, string and number, the method shifts the letters of the string along the alphabet by 'number' places" do
cc = Cc.new
expect(cc.caesar_cipher('dog', 3)).to eql('grj')
expect(cc... |
# encoding: utf-8
class PratosController < ApplicationController
# GET /pratos
# GET /pratos.json
def index
@pratos = Prato.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @pratos }
end
end
# GET /pratos/1
# GET /pratos/1.json
def show
@pr... |
require 'active_support/secure_random'
module Loudmouth
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.join(File.dirname(__FILE__), 'templates')
desc "Copies a loudmouth initializer and locale files to your application."
class_option :orm
def copy_in... |
INSTRUCTION_MATCHER = /row (?<row>\d+), column (?<column>\d+)/
instructions = INSTRUCTION_MATCHER.match(INPUT)
row = instructions[:row].to_i
column = instructions[:column].to_i
def generate(num)
num * 252_533 % 33_554_393
end
def code_for(row, column)
num = 20_151_125
r = 1
c = 1
loop do
break if r ==... |
require 'net/http'
require 'aws-sdk-rails'
require 'json'
class SQSService
def initialize(sqs)
@sqs = sqs
end
def enqueue(check, start_time)
Rails.logger.debug "SQSService: Start enqueuing message"
resp = @sqs.get_queue_url({
queue_name: check.queue_name,
})
if check.scan_id
scan... |
require 'pp'
require 'set'
def knot lengths, list, pos, skip
lens = lengths.dup
size = list.size
while !lens.empty?
len = lens.shift
list = list.cycle(2).to_a
sublist = list[pos, len]
sublist.reverse!
cdr_start = (pos + len) % size
cdr_end = size - len
cdr = list[cdr_start, cdr_en... |
# Translates model.User Java objects to User Ruby objects
class UserTranslator
def translate(java_user)
ruby_user = User.where(:rdbms_id => java_user.getId).first
ruby_user ||= User.new
ruby_user.rdbms_id = java_user.getId
ruby_user.username = java_user.getUsername
ruby_user.save!
ruby_user
... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Parsers
class UnicodeRegexParser
# This is analogous to ICU's UnicodeSet class.
class CharacterClass < Component
GROUPING_PAIRS = {
close_bracket: :open_bracket
... |
require 'yaml'
class VariationReader
@tabix = 'tabix'
def initialize(chromosome, vcf, output_dir)
@chr = chromosome
@file = vcf
@output_dir = output_dir
raise IOError "#{@output_dir} does not exist." unless File.exists?@output_dir
end
def set_tabix(tabix)
@tabix = tabix
end
def re... |
class ImageSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
attributes :id, :image_element, :user_id, :user, :client_id, :client
def image_element
if object.image_element.attached?
{
url: rails_blob_url(object.image_element)
}
end
end
end
|
require "../factory/*"
class TableTray < Factory
def initialize(caption:)
super(caption: caption)
end
def make_html
buffer = String.new
buffer.add("<td>¥n")
buffer.add("<table width=\"100%\" border=\"1\">")
buffer.add("<td bgcolor=\"#cccccc\" align=\"centor\" colspan=\"#{tray.size}\"><b... |
#
# Cookbook Name:: replica-test
# Recipe:: replica
#
# Copyright 2015, Dave Shawley
#
# 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
#
# Unl... |
require_relative 'open_uri_cache/version'
require 'fileutils'
require 'pathname'
require 'open-uri'
require 'cgi'
require 'json'
module OpenUriCache
class SuccessCheckError < StandardError; end
class CacheFile < File
private_class_method :new
def set_info(info)
@info = info
end
def method... |
class ImportWorker
include Sidekiq::Worker
sidekiq_options queue: "importer_default", retry: false
def perform(import_id)
import = Import.find(import_id)
# it would be nice if worker abort could be handled here instead of deep in the model =\
import.abort_key = ImportWorker.abort_key(jid)
impo... |
class UsersConfirmService
def initialize(user)
@user = user
end
def execute
create_main_album
end
private
attr_reader :user
def create_main_album
profile = user.profile
profile.albums.create(name: 'Main album', is_main: true) unless profile.albums.any?
end
end
|
require 'spec_helper'
SIZES = ['Square 75', 'Thumbnail', 'Square 150', 'Small 240', 'Small 320',
'Medium 500', 'Medium 640', 'Medium 800', 'Large 1024']
describe Flickrie::Photo do
def test_sizes(photo)
# TODO: simplify this
# non-bang versions
[
[[photo.square(75), photo.square75], ['Square 7... |
class AddFollupUpDateToClientStatuses < ActiveRecord::Migration[5.1]
def change
add_column :client_statuses, :followup_date, :integer
ClientStatus.reset_column_information
active_status = ClientStatus.find_by(name: 'Active')
active_status.update!(followup_date: 25) if active_status
training_stat... |
Facter.add(:pagesize) do
confine :kernel => "Linux"
setcode do
Facter::Util::Resolution.exec('getconf PAGESIZE')
end
end
|
class Ingredient
attr_accessor :cost, :name
def initialize(hash)
@name = hash[:name]
@cost = hash[:cost]
end
def ==(obj)
if self.__id__ != obj.__id__ && self.name == obj.name && self.cost == obj.cost
true
else
false
end
end
end
|
class FanDashboardsController < ApplicationController
before_action :ensure_fan_account, only: [:show]
def show
@venues = Venue.where(state: current_account.location)
@concerts = Concert.where(venue_id: @venues).upcoming.page params[:page]
end
end
|
class AssessmentDate < ActiveRecord::Base
belongs_to :assessment_group
belongs_to :batch
validate :check_dates
def check_dates
errors.add(:start_date, :start_date_cant_be_after_end_date) if start_date > end_date
end
def self.save_dates(params)
params[:batch_ids].each do |batch_id|
... |
class CreateCategories < ActiveRecord::Migration
def change
create_table(:market_categories) do |t|
t.text :name, null: false
t.integer :position, default: 0
t.index :position
t.references :category
t.foreign_key :market_categories, column: :category_id
t.index :category_id
... |
Given(/^I have signed up$/) do
visit '/new_player'
fill_in :playername, :with => :playername
end
When(/^I click on "(.*?)"$/) do |text|
click_button "Register"
end
Then(/^I should go to the game page$/) do
expect(current_path).to eq('/')
end
Given(/^I am on the game page$/) do
visit '/game'
end
When(/^I ... |
class Comment < ActiveRecord::Base
acts_as_nested_set scope: [:commentable_id, :commentable_type]
validates :body, presence: true
validates :user, presence: true
validates :email, :full_name, presence: true, if: :guest_user?
# NOTE: install the acts_as_votable plugin if you
# want user to vote on the qual... |
class Address < ApplicationRecord
belongs_to :user, optional: true
has_one :product
validates :postal_code, :city, :address, :prefecture_id, presence: true
# active_hashで都道府県データを導入する
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :prefecture
end
|
class TransactionDetail < ActiveRecord::Base
belongs_to :transaction
belongs_to :product
validates :product_id, presence: true
validates :amount, presence: true, numericality: { only_integer: true }
end
|
require 'spec_helper'
require 'crc_examples'
require 'digest/crc32'
describe Digest::CRC32 do
before(:all) do
@crc_class = Digest::CRC32
@string = '1234567890'
@expected = '261daee5'
end
it_should_behave_like "CRC"
end
|
class Category < ApplicationRecord
belongs_to :style
has_many :articles
end
|
class Puppy
def initialize
puts "Initializing new puppy instance..."
end
def fetch(toy)
puts "I brought back the #{toy}!"
toy
end
def speak(quantity)
quantity.times {puts "Woof!"}
end
def roll_over
puts "*rolls over*"
end
def dog_years(years)
puts ye... |
class Equation
def self.solve_quadratic(a, b, c)
if a == 0 #pokud 'a' je nula
if b == 0 #a 'b' je taky nula
return nil #tak vrať 'nil'
else
x = -c.to_f / b
return [x] #jinak vrať 'x' (b*x + c = 0 -> x = -c / b)
end
else #pokud 'a' není nula
d = b**2 - 4*a*c #vypočitej diskriminant
if d ... |
require 'spec_helper'
module Belafonte
describe ArgumentProcessor do
describe '.new' do
it 'processes the arguments' do
expect_any_instance_of(described_class).to receive(:process).and_call_original
described_class.new(argv: [], arguments: [])
end
it 'requires an argv array op... |
#!/usr/bin/env ruby
{{ruby_copyright}}
require 'gli'
require '{{project_name}}'
include GLI::App
arguments :strict
subcommand_option_handling :normal
program_desc 'Sample application'
desc 'To-do list file name'
flag [:f, :file], default_value: File.join(ENV['HOME'],'.{{project_name}}')
pre do |global_options, com... |
module Contentful
class RecipeService
CONTENT_TYPE = 'recipe'.freeze
RESPONSE_TYPE = {
success: 200,
api_error: 401,
not_found: 404,
}.freeze
def perform(method_name, *arguments)
begin
{ data: self.send(method_name, *arguments), status: map_status(:success) }
re... |
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-pl... |
class State < ActiveRecord::Base
belongs_to :nation
has_many :towns
validates :name, presence: true
end
|
class Createforiegnkeypaymentidincustomermobile < ActiveRecord::Migration[5.0]
def change
add_foreign_key :customer_mobiles, :invoices, column: :payment_id, primary_key: :id
end
end
|
describe ManageIQ::PostgresHaAdmin::ConfigHandler do
describe "#before_failover" do
it "raises an ArgumentError if called without a block" do
expect { subject.before_failover }.to raise_error(ArgumentError)
end
end
describe "#after_failover" do
it "raises an ArgumentError if called without a bl... |
class Item
include Mongoid::Document
include Mongoid::Paperclip
include Sunspot::Mongoid2
include Mongoid::Slug
#has_mongoid_attached_file :picture, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
#active_admin purpose
field :bids_id, type: String
#... |
class TiposubtipoSerializer < ActiveModel::Serializer
attributes :id, :tasa_co, :tasa_runt, :valor_prima
belongs_to :edad
end
|
require 'openssl'
require 'base64'
require 'net/http'
require 'uri'
require 'json'
require 'cgi'
require 'digest/sha2'
require 'time'
class Amazonapi < ActiveRecord::Base
def self.request(jan_code)
aws_host = 'webservices.amazon.co.jp'
if Rails.env == 'development'
keys = YAML::load(File.open("#{R... |
# frozen_string_literal: true
class Message < ApplicationRecord
belongs_to :user
belongs_to :room
after_create_commit do
ChatMessageCreationEventBroadcastJob.perform_later(self)
end
end
|
class AddFacebookFieldsToCampaign < ActiveRecord::Migration
def change
add_column :campaigns, :facebook_share_title, :string
add_column :campaigns, :facebook_share_lead, :string
add_column :campaigns, :facebook_share_thumb, :string
end
end
|
module RunnersConnectApi
module V1
class SessionsController < BaseApiController
skip_before_action :authenticate_user_from_api_token#, only: :create
def create
user = User.find_for_authentication(email: params[:email])
if @authenticated_user = user.valid_password?(params[:password])... |
Rails.application.routes.draw do
resources :authors, shallow: true do
resources :articles
end
root 'authors#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
|
class Author
attr_accessor :name
attr_reader :posts
@@post_count = 0
@@authors = []
def initialize(name)
@name = name
@posts = []
@@authors << self
end
def add_post(post)
@posts << post
post.author = self
end
def add_post_by_title(post_title)
post = Post.new(post_title)
@posts << pos... |
class User < ApplicationRecord
include RatingAverage
has_secure_password
validates :username, uniqueness: true,
length: { minimum: 3,
maximum: 30 }
validates :password, length: { minimum: 3 }
validates_format_of :password, with: /[A-Z]/
... |
module Antlr4::Runtime
class TextChunk
attr_reader :text
def initialize(text)
raise IllegalArgumentException, 'text cannot be null' if text.nil?
@text = text
end
def to_s
"'" + @text + "'"
end
end
end |
# frozen_string_literal: true
require 'rails_helper'
feature 'user needs to be authenticated' do
scenario 'not access user view' do
person = create(:person)
user = create(:user, person: person)
visit user_path(user.id)
expect(current_path).to eq(new_person_session_path)
end
scenario 'not acces... |
require 'appium_lib'
describe 'Liputan 6' do
before(:all) do
appium_txt = File.join(Dir.pwd, '../appium.txt')
caps = Appium.load_appium_txt file: appium_txt
Appium::Driver.new(caps).start_driver
Appium.promote_appium_methods RSpec::Core::ExampleGroup
@top_elements = find_elements :class_name, 'android.suppo... |
require 'spec_helper'
require_relative '../../models/user'
require_relative '../../mappers/user_mapper'
describe UserMapper do
describe "persist" do
let(:db) {Database.new}
let(:mapper) {UserMapper.new(db)}
let(:user) {User.new("test@test.com", "testpassword", "testpassword")}
before do
... |
require "veda/version"
module Veda
class << self
attr_accessor :instance_attempted_credit_enquiry
include Decisioning::Logger
# TODO: Implement this
VALID_ENQUIRY_TYPES = [:individual_consumer_enquiry]
def enquiry(creditable, enquiry_type, product = nil)
raise ArgumentError, "Entity mus... |
#http://ruby.bastardsbook.com/chapters/html-parsing/
require 'open-uri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
html = open(index_url)
index_page = Nokogiri::HTML(html)
students = []
index_page.css(".student-card a").each do |student|
#binding.pry
url = student.... |
module CDI
module V1
module ServiceConcerns
module LearningTrackReviewsParams
extend ActiveSupport::Concern
WHITELIST_ATTRIBUTES = [
:learning_track_id,
:student_class_id,
:review_type,
:comment,
:score
]
included do
... |
require 'common'
class TestSCP < Net::SCP::TestCase
def test_start_without_block_should_return_scp_instance
ssh = stub('session', :logger => nil)
Net::SSH.expects(:start).
with("remote.host", "username", { :password => "foo" }).
returns(ssh)
ssh.expects(:close).never
scp = Net::SCP.start... |
class AddAddress2ToCampaignRecords < ActiveRecord::Migration
def change
add_column :campaign_records, :postcode, :string
add_column :campaign_records, :address2, :string
add_column :campaign_records, :telphone, :string
add_column :campaign_records, :name, :string
end
end
|
class PublicController < ApplicationController
layout "public"
before_filter :setup_navigation, :request_separator
def index
# intro text, landing page
end
def show
@page = Page.where(:permalink => params[:id], :visible => true ).first
redirect_to(:action => 'index') unless @page
end... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def show
render json: @parks
end
def current_user
@current_user ||= begin
auth_token = request.env... |
HighVoltage.configure do |config|
if ENV['PRIVATE_MODE'] != 'true'
config.home_page = 'home'
end
end |
namespace :db do
desc "Fill db with sample data"
task populate: :environment do
require 'faker'
(1..5).each do |i|
fake_name = Faker::Lorem.sentence(1)
List.create!(name: fake_name, id: i)
30.times do |j|
fake_content = Faker::Lorem.sentence(7)
Point.create!(content:... |
ActiveAdmin.register User do
action_item :only => :show do
link_to('View on site', user_path(user))
end
form do |f|
f.inputs "User Details" do
f.input :username
f.input :email
f.input :password
f.input :password_confirmation
f.input :admin, :label => "Administrator"
f... |
=begin
In the previous exercise, you developed a method that converts
simple numeric strings to Integers. In this exercise, you're
going to extend that method to work with signed numbers.
Write a method that takes a String of digits, and returns the
appropriate number as an integer. The String may have a
leadin... |
FactoryBot.define do
factory :brewery do
name {"7Peaks Brasserie Sàrl"}
city {"Morgins"}
postal_code {"1875"}
registration_number {623}
end
end
|
class AddColumnsToPeople < ActiveRecord::Migration
def change
add_column :people, :encrypted_email_iv, :string
add_column :people, :encrypted_phone_iv, :string
end
end
|
require 'open-uri'
# Reads hamlet.txt from the given URL
# Saves it to a local file on your hard drive named "hamlet.txt"
# Re-opens that local version of hamlet.txt and prints out every 42nd line to the screen
url = "http://ruby.bastardsbook.com/files/fundamentals/hamlet.txt"
File.open("files_io/hamlet.txt", "w"){ ... |
module Network
module Device
class PPP < Stub
attr_accessor :serial
@ids = [{class: 'net', uevent: {interface: 'ppp.*'}}]
def initialize(dev)
super(dev)
@operator = nil
@serial = nil
if @serial = Device.present.find { |dev|
dputs(3) { "Checking dev: #{... |
class CreateReplies < ActiveRecord::Migration[5.1]
def change
create_table :replies do |t|
t.integer :user_id, null: false
t.integer :announcement_id, null: false
t.string :content, null: false
t.timestamps
end
add_index :replies, :user_id
add_index :replies, :announcemen... |
module GHI
module Commands
module Version
MAJOR = 1
MINOR = 2
PATCH = 0
PRE = nil
VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join '.'
def self.execute args
puts "ghi version #{VERSION}"
end
end
end
end
|
# Copyright (c) 2009-2011 VMware, Inc.
class VCAP::Services::Mysql::MysqlError<
VCAP::Services::Base::Error::ServiceError
MYSQL_DISK_FULL = [31001, HTTP_INTERNAL, 'Node disk is full.']
MYSQL_CONFIG_NOT_FOUND = [31002, HTTP_NOT_FOUND, 'Mysql configuration %s not found.']
MYSQL_CRED_NOT_FOUND = [31003, HTT... |
# 1. Concatenate your first and last name
puts "My name concatenated:"
puts "Mila " + "Hose"
puts ""
# 2. Use the modulo and/or division operator to
# take a 4-digit number and find the digit in the:
# 1) thousands place
# 2) hundreds place
# 3) tens place
# 4) ones place
puts "Here is the thousands, hundreds... |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :email, :limit => 256, :null => false
t.string :display_name, :limit => 256
t.string :persistence_token, :limit => 256
t.string :privacy_token, :limit => 256, :null => fa... |
class Api::DamagesController < ApplicationController
def index
@damages = Damage.all
end
def show
@damage = Damage.find(params[:id])
render :show
end
def create
@damage = Damage.new(damage_params)
if @damage.save!
render :show
else
... |
require "rack/reloader"
require "sinatra"
module Sinatra
class Reloader < Rack::Reloader
def safe_load(file, mtime, stderr = $stderr)
Sinatra::Application.reset! if file == Sinatra::Application.app_file
begin
super
# This seems to be an issue on 1.8.7. I don't recommend using 1.8.7
... |
require 'spec_helper'
describe UsersController do
let(:fake_user){FactoryGirl.create(:user)}
let(:fake_users){[FactoryGirl.create(:user),
FactoryGirl.create(:user),
FactoryGirl.create(:user)]}
describe "index" do
before(:each) { get :index }
it "renders @users... |
require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/flashcards'
class CardTest < Minitest::Test
def test_card
card = Card.new("What is the capital of Alaska?", "Juneau")
assert_equal "What is the capital of Alaska?", card.question
card.answer
assert_equal ("Juneau"), card.ans... |
require 'test_helper'
class DealStepsControllerTest < ActionController::TestCase
setup do
@deal_step = deal_steps(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:deal_steps)
end
test "should get new" do
get :new
assert_response :succe... |
require "rails_helper"
RSpec.describe "When I visit the flight index page" do
before :each do
@flight1 = Flight.create!(
number: "1737",
date: "10/20/20",
time: "10:00 AM",
departure_city: "Tampa",
arrival_city: "Las Vegas"
)
@passenger1 = @flight1.passengers.create(
n... |
class CreateFeatures < ActiveRecord::Migration
def change
create_table :spree_features do |t|
t.string :name
t.integer :position
t.string :link
t.string :headline1
t.string :headline2
t.boolean :active
t.timestamps
end
end
end
|
# (c) Copyright 2016-2017 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... |
class Request < ActiveRecord::Base
belongs_to :recruiter
belongs_to :vacancy
validates :status, presence: true
end
|
class AddGameIdToDeeds < ActiveRecord::Migration[5.1]
def change
add_column(:deeds, :game_id, :integer, null: false)
add_index(:deeds, [:property_id, :game_id], unique: true)
end
end
|
class CreateQuestions < ActiveRecord::Migration
def self.up
create_table :questions do |t|
t.string :title
t.integer :type_of_answer
t.integer :score
t.references :quiz, index: true, foreign_key: true
t.timestamps null: false
end
end
def self.down
drop_table :questions
... |
module Mutant
# An AST cache
class Cache
include Equalizer.new, Adamantium::Mutable
# Initialize object
#
# @return [undefined]
#
# @api private
def initialize
@cache = {}
end
# Root node parsed from file
#
# @param [#to_s] path
#
# @return [AST::Node]
... |
source 'https://rubygems.org'
ruby '2.3.0'
gem 'rails', '4.2.5' # MVC framework vs. sinatra which is a routing framework
# environment gems (front & backend, admin, db, etc.)
gem 'pg', '~> 0.18.4' # Postgres db instead of sqlite
# gem 'puma', '2.11.1' ... |
def clockChime &block
((Time.now.hour + 11) % 12 + 1).times do |i|
puts i + 1
block.call
end
end
clockChime do
puts "DONG"
end
def log blockDescription, &block
puts "Beginning'" + blockDescription + "'..."
ret = block.call
puts "...'" + blockDescription + "' finished, returning: #{ret}"
end
log "... |
# frozen_string_literal: true
require 'spec_helper'
describe HealthMonitor::Providers::Base do
let(:request) { test_request }
subject { described_class.new(request: request) }
describe '#initialize' do
it 'sets the request' do
expect(described_class.new(request: request).request).to eq(request)
... |
include_recipe 'chef-openstack::common'
packages = %w[keystone
python-keystone
python-keystoneclient
python-mysqldb
memcached
python-memcache]
packages.each do |pkg|
package pkg do
action :install
end
end
service 'keystone' do
provider ... |
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'sim_launcher'
# SimLauncher starts on port 8881 by default. To specify a custom port just pass it as the first command line argument.
set :port, (ARGV[0] || 8881)
# otherwise sinatra won't always automagically launch its embedded
# http server when t... |
require 'test_helper'
# Test para el Controlador Proyectos
class ProyectosControllerTest < ActionController::TestCase
setup do
@proyecto = proyectos(:one)
end
test 'should get index' do
get :index
assert_response :success
assert_not_nil assigns(:proyectos)
end
test 'should get new' do
g... |
class AddIsStoppedToOrg < ActiveRecord::Migration
def change
add_column :organizations,:is_stopped,:boolean,:default => false
end
end
|
require 'pry'
class Song
@@count = 0
@@genres = []
@@artists = []
def initialize(name, artist, genre)
@name = name
@artist = artist
@genre = genre
@@count += 1
@@genres << genre
@@artists << artist
end
attr_accessor :name
attr_accessor :artist
attr_accessor :genre
def self.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.