text stringlengths 10 2.61M |
|---|
# frozen_string_literal: true
require 'bolt/error'
# Collects facts based on a list of certnames.
#
# If a node is not found in PuppetDB, it's included in the returned hash with an empty facts hash.
# Otherwise, the node is included in the hash with a value that is a hash of its facts.
Puppet::Functions.create_functi... |
require 'chemistry/element'
Chemistry::Element.define "Tantalum" do
symbol "Ta"
atomic_number 73
atomic_weight 180.94788
melting_point '3269K'
end
|
# -*- encoding: utf-8 -*-
require 'test/unit'
require_relative '../convert/temperature'
NUMBER = 25.0
# Celsius class
class TestCelsius < Test::Unit::TestCase
TO_F = 77
TO_K = 298.15
TO_R = 536.6700000000001
TO_E = 20
def setup()
@number = NUMBER.celsius()
end
def teardown()
end
def test_di... |
require 'spec_helper'
module Logical
module Naf
module JobStatuses
describe Errored do
context "no conditions" do
let!(:conditions) { "" }
it "returns executable query" do
expect { ActiveRecord::Base.connection.execute(Errored.all(conditions)) }.to_not ... |
class CreateNotifications < ActiveRecord::Migration[5.0]
def change
create_table :notifications do |t|
t.integer 'type', limit: 1, null: false
t.string 'title', limit: 64, null: false
t.timestamps
end
end
end
|
require 'spec_helper'
require 'json'
require 'ffordd/mocks/MockPresenter'
require 'ffordd/mocks/MockWriter'
describe 'SassTranslator' do
before(:each) do
@mock_writer = MockWriter.new
@mock_presenter = MockPresenter.new
end
describe '.translate' do
context 'given an empty input' do
let(:empty_... |
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "clojurescript_rails/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "clojurescript_rails"
s.version = ClojurescriptRails::VERSION
s.authors = ["Zach Allaun", "Nic... |
class ProjectsController < ApplicationController
def new
@project = new_project
end
def create
@project = current_user.projects.build(project_params)
if @project.save
redirect_to root_path, notice: I18n.t('project.create.success')
else
render :new
end
end
def edit
@proje... |
class PemFile < ApplicationRecord
before_create :set_status
ACTIVE = 1
DELETED =99
def set_status
self.status = 1
end
end
|
class PermissionsController < HighlandController
before_action :get_menu
# GET /permissions
def index
@q = policy_scope(Permission).ransack(params[:q])
@permissions = @q.result.page(params[:page]).per(@per_page)
end
# GET /permissions/1
def show
end
# GET /permissions/new
def new
@permi... |
class CreateTimeStamps < ActiveRecord::Migration[5.0]
def change
create_table :time_stamps do |t|
t.datetime :signature
t.timestamps
end
end
end
|
# encoding: utf-8
class PhotoUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
version :sneaker if :is_sneaker?
version :thumb if :is_sneaker?
version :banner if :is_banner?
def is_banner?
model.class == Blog || model.class == Promo
end
version :banner do
process :eager =... |
#! /usr/local/bin/ruby
#
# Copyright © 2001 by Ollivier Robert <roberto@keltia.freenix.fr>
#
# Implementation of the well known cipher used by Russian agents during
# WWII. Code number assignment is probably different from the original
# cipher due to implementation choices.
#
# See The Codebreakers, D. Kahn, 1996 for ... |
# encoding: utf-8
require 'carrierwave/processing/mime_types'
class FileUploader < CarrierWave::Uploader::Base
include CarrierWave::MimeTypes
process :set_content_type
process :filename
process :save_attributes_in_model
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include Ca... |
class SectionHeadingsController < ApplicationController
before_action :set_section_heading, only: [:show, :edit, :update, :destroy]
# GET /section_headings
# GET /section_headings.json
def index
@section_headings = SectionHeading.all
end
# GET /section_headings/1
# GET /section_headings/1.json
def... |
Gem::Specification.new do |s|
s.name = %q{debugger}
s.version = "0.0.1"
s.author = ['mattl@surveymonkey.com']
s.summary = 'Debug helper'
s.files = Dir["debugger.rb"]
s.add_dependency 'web-console', '3.5.1'
end |
module Assetable
module HtmlAsset
include BasicAsset
def asset_type
:html
end
def max_size
500.kilobytes
end
def extension
'html'
end
end
end
|
class Shelf < ActiveRecord::Base
belongs_to :user
# Grab the latest data from Goodreads
def refresh!
update_attributes(
books: update_data,
books_count: update_data.length
)
end
# Get genres for all books
def annotate_books!
update_attribute(:books, annotated_books)
end
def ne... |
#String concatenation
#be mindful with single quotes you can use string interpolation
first_name = "seif"
last_name = "delta"
age = 32
puts first_name + " " + last_name
#String interpolation
puts "My first name is #{first_name} and my is #{last_name}"
#Methods, how to find them
first_n... |
require "group_me"
module Commands
class NullCommand
include GroupMe
def initialize(message)
@message = message
end
def execute
name = @message["name"].to_s.split(/\s+/).first
post_as_bot(KRYPPIE_BOT_ID, generate_response(name))
end
private
def generate_response(name)... |
# A method named `binary_to_decimal` that receives as input an array of size 8.
# The array is randomly filled with 0’s and 1’s.
# The most significant bit is at index 0.
# The least significant bit is at index 7.
# Calculate and return the decimal value for this binary number using
# the algorithm you devised in clas... |
class Bathroom < ApplicationRecord
has_many_attached :photos
has_many :bookings
has_many :clients, through: :bookings
belongs_to :owner, class_name: 'User', foreign_key: 'user_id'
validates :price, presence: true
validates :description, presence: true
validates :title, presence: true
validates :address,... |
class Team
TEAMS = {
arizona: 'Cardinals',
atlanta: 'Falcons',
baltimore: 'Ravens',
buffalo: 'Bills',
carolina: 'Panthers',
chicago: 'Bears',
cincinnati: 'Bengals',
cleveland: 'Browns',
dallas: 'Cowboys',
detroit: 'Lions',
... |
# Write a method that combines two Arrays passed in as arguments, and returns a new Array that contains all elements from both Array arguments, with the elements taken in alternation.
def interleave(array1, array2)
interleaved = []
counter = 0
while array1 != [] || array2 != []
if counter.even?
interl... |
require 'rails_helper'
describe Comment do
context "when comment gets created" do
let(:product) { Product.create!(name: "Cool old toy") }
let(:user) { User.create!(email: "bob@gmail.com", password: "password123") }
it "comment not valid without a body" do
expect(Comment.new(body: "", user:user, pr... |
# frozen_string_literal: true
module FeCoreExt
VERSION = '0.28.0'
end
|
class AddDistributionStrategyToExercise < ActiveRecord::Migration
def change
add_column :exercises, :distribution_strategy, :string, null: false, default: ''
add_column :exercises, :distributed, :boolean, null: false, default: false
end
end
|
class CreatePlaces < ActiveRecord::Migration
def change
create_table :places do |t|
t.string :name
t.string :slug
t.text :description
t.string :street_address
t.string :zipcode
t.belongs_to :city
t.string :phone
t.string :website
t.string :email
t.string... |
class Comment < ApplicationRecord
validates :body, presence: { message: 'Body is required' }, length: { minimum: 10, maximum: 700 }
belongs_to :user
belongs_to :post
end
|
class AdminController < ApplicationController
before_action :authorize
def authorize
if current_user && !current_user.admin?
redirect_to produtos_path
end
end
end
|
require 'action_controller/macros'
require 'active_cache/active_cache_store'
require 'active_cache/store/dalli_store'
require 'dalli'
module ActiveCache
def self.cache_store
Rails.application.config.active_cache_store
end
end
|
module Exportable
extend ActiveSupport::Concern
class_methods do
def csv_export_headers
raise 'not implemented'
end
def csv_export(data)
[csv_export_headers] + data.map(&:csv_export_attributes)
end
def generate_csv(data)
CSV.generate(headers: true) do |csv|
([csv_exp... |
class Expression < ActiveRecord::Base
self.abstract_class = true
has_one :node, as: :expressible
def to_s
'?'
end
def to_html
'<div>?</div>'
end
end
|
require_relative '../../models/errors/plan_inexistente_error'
HealthAPI::App.controllers :planes do
get :index do
param_plan = request.params['nombre']
if param_plan.nil?
planes = PlanRepository.new.all
PlanResponseBuilder.create_from_all(planes)
else
plan = PlanRepository.new.find_by_sl... |
Given(/^I navigate to the tesco grocery site$/) do
website.home.load
website.home.displayed?
#website.home.navigate_to("Groceries")
website.first_registration_page.load
end
Given(/^I register as a new grocery user with postcode "(.*?)"$/) do |postcode|
website.first_registration_page.displayed?
website.fir... |
class Person
# this class will likely be simple, and just remember its name
attr_accessor :username, :rank, :best_score
def initialize(username)
@username = username
end
# Returns a rank depending on number of attemps
def get_rank(attempts)
if attempts == 1
"Hero"
elsif attempts > 1 && att... |
require "spec_helper"
describe ProjectsController do
before :each do
@project=FactoryGirl.create(:project)
end
describe "routing" do
it "routes to #index" do
get("/en/projects").should route_to("projects#index", locale: 'en')
end
it "routes to #new" do
get("/en/projects/new").sh... |
# spec/requests/scenarios/delete_spec.rb
require 'rails_helper'
RSpec.describe 'delete scenario (DELETE scenario)', type: :request do
let(:admin) { create(:user, :admin) }
let!(:scenario) { create(:scenario, user: admin) }
let(:scenario_id) { scenario.id }
let(:headers) { { 'ACCEPT' => 'application/json' } }
... |
class User < ActiveRecord::Base
attr_accessor :role_cd
has_many :cards
has_many :games_as_dealer, foreign_key: "dealer_id", class_name: "Game"
has_many :games_as_player, foreign_key: "player_id", class_name: "Game"
as_enum :role, dealer: 1, player: 2
accepts_nested_attributes_for :cards
def add_card card
... |
class Material < ActiveRecord::Base
include TopList::TopListHelper
attr_accessible :author_id, :description, :publication_date, :title, :type
attr_accessible :lock_version
has_one :top_list_item, as: :positioned, class_name: 'TopList::TopListItem'
belongs_to :author, class_name: User.name
scope :position... |
# frozen_string_literal: true
module BasicCommand
# Outcome stores outcome data for a command
class Outcome
attr_reader :valid, :result, :errors
def initialize(valid, result, errors)
@valid = valid
@result = result
@errors = errors
end
def valid?
valid
end
end
end
|
module Weather
def stormy?
rand(10).even?
end
end |
Pod::Spec.new do |s|
s.name = 'Kommander'
s.version = '1.1'
s.summary = 'A command pattern implementation written in Swift'
s.homepage = 'https://github.com/intelygenz/Kommander-iOS'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.authors = { 'Al... |
FactoryGirl.define do
factory :identity do
uid "MyString"
provider "MyString"
access_token "MyString"
refresh_token "MyString"
expires_at 1
end
end
|
# frozen_string_literal: true
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def google
@user = User.find_for_google(request.env['omniauth.auth'])
flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: 'Google'
sign_in_and_redirect @user, event: :authentication... |
class PolyCartSerializer < ActiveModel::Serializer
attributes :id, :cartable
has_one :user
has_one :cartable
end
|
class User < ActiveRecord::Base
has_many :events, dependent: :destroy
validates :username, presence: true, length: {maximum: 50}, uniqueness: { case_sensitive: false }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, format: {with: VALID_EMAIL_REGEX}, uniqueness: { case_se... |
require 'rails_helper'
RSpec.feature 'Cookie preferences', type: :feature do
describe 'banner behaviour' do
context 'when no preference has been set' do
before do
set_cookie('consented-to-cookies', nil)
end
it 'shows the cookie banner on visiting the homepage' do
visit '/'
... |
require "rails_helper"
RSpec.feature "Registered non-member user" do
let(:email) { 'shaanjain@gmail.com' }
let(:password) { 'password' }
let!(:family) {
Family.create!(
address: '420 Birmingham Lane',
city: 'Schaumburg',
state: 'IL',
zip: '60193'
)
}
let!(:primary_user) {
... |
require 'csv'
require 'pry'
class Transaction
attr_reader :date, :amount, :description, :account
def initialize(date, amount, description, account)
@date = date
@amount = amount
@description = description
@account = account
end
def deposit?
if @amount.to_f > 0
return "DEPOSIT"
e... |
module Services
extend ActiveSupport::Concern
included do
def album_service
@album_service ||= Services::AlbumService.new
end
end
end
|
FactoryGirl.define do
factory :call_event, :class => "Event::Call" do
user { FactoryGirl.create(:user) }
prospect { FactoryGirl.create(:snda) }
type Event::Call::VOICEMAIL
end
factory :email_event, :class => "Event::Email" do
prospect { FactoryGirl.create(:snda) }
sent_email { FactoryGirl.cre... |
class ProposalHistoric < ActiveRecord::Base
audited
belongs_to :proposal
belongs_to :user
validates_presence_of :comment
end
|
# coding: UTF-8
require 'spec_helper'
describe Localized::Convert do
include Localized
before :each do
Rails.stub!(:root).and_return(Pathname.new(File.join(File.dirname(__FILE__),'..', '..')))
end
describe "Locale cache", :locales => :to_csv do
it "should return cache keys for each unique key path" do... |
# frozen_string_literal: true
class ChatMessageSerializer < ActiveModel::Serializer
attributes :id,
:sender_id,
:content,
:created_at
end
|
# encoding: UTF-8
module Delayed
module JobGroups
VERSION = '0.3.0'
end
end
|
class NotesController < ApplicationController
def index
@notes = Note.all
end
def new
@note = Note.new
end
def show
@note = Note.find_by(id: params[:id])
authorize! :read, @note
if !@note
redirect_to root_path
end
end
def edit
@note = Note.find_by(id: params[:id])
... |
require 'colere'
class Colere::ClassInfo
def initialize(class_name)
@klass = eval class_name
end
def class_messages
@klass.methods(false)
end
def instance_messages
@klass.instance_methods(false)
end
def private_instance_messages
@klass.private_instance_methods
end
end
|
# == Schema Information
# Schema version: 20081119013232
#
# Table name: neighbours
#
# id :integer(4) not null, primary key
# country_id :integer(4)
# neighbour_id :integer(4)
# created_at :datetime
# updated_at :datetime
#
class Neighbour < ActiveRecord::Base
belongs_to :country, :includ... |
require 'spec_helper'
describe Delayed::Job do
before(:each) do
@j1 = YoutubeMultipleDL::Download.new(url: "http://www.foo.bar", priority: 1).call_downloader
@j2 = YoutubeMultipleDL::Download.new(url: "http://www.foo.bar", priority: 3).call_downloader
@j3 = YoutubeMultipleDL::Download.new(url: "http://ww... |
require 'puppet'
require 'yaml'
require 'syslog/logger'
Puppet::Reports.register_report(:syslog_reports) do
desc 'Send the corrective changes to syslog'
desc 'Setup logger'
# logdest = Syslog::Logger.new 'PuppetReports'
def debug(msg)
timestamp = Time.now.utc.iso8601
f = File.open('/var/log/puppetlab... |
module HalPresenters
module Helpers
module Rootify
def self.included(klass)
klass.instance_eval do
include(InstanceMethods)
default_after_filter :absolutify
default_after_filter :rootify
end
end
module InstanceMethods
# Add dtime:root if it d... |
class CreateProblems < ActiveRecord::Migration
def change
create_table :problems do |t|
t.string :title
t.decimal :timeLimit
t.decimal :sourceLimit
t.date :dateAdded
t.text :problemStatement
t.text :solutionFile
t.text :testFile
t.timestamps
end
end
end
|
module OpsWorks
module GemSupport
require 'rubygems/version'
def gem_provider(name)
resource = Chef::Resource::GemPackage.new(name, nil, node)
provider_class = Chef::Platform.find_provider_for_node(node, resource)
@gem_provider = provider_class.new(node, resource)
end
def current_g... |
require_relative 'robot'
require_relative 'board'
require "test/unit"
class TestRobot < Test::Unit::TestCase
def test_valid_placement1
robot = Robot.new(5, 5)
assert_equal(robot.place(1, 1, "east"), true)
end
def test_valid_placement2
robot = Robot.new(5, 5)
assert_equal(robot.place(1, 4, "east... |
class Omelette < ApplicationRecord
validates :title, presence: true
validates :description, presence: true
validates :ingredients, presence: true
belongs_to :reg_user
has_many :reviews
mount_uploader :photo, OmelettePhotoUploader
end
|
class FontNanumGothic < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/nanumgothic"
desc "Nanum Gothic"
homepage "https://fonts.google.com/specimen/Nanum+Gothic"
def install
(share/"fonts").install "NanumGothic-Bold.ttf"
(share/"f... |
# Identifies articles that were published within the last 1.day and emails them out to the whole list of subscribers
class Newsletter
# TODO: test this
# query articles of the day, so that we only search them once
# figure out when you want the rake task to call Newsletter, since that'll determine what articles are swe... |
RSpec.describe 'Image (feature)', type: :feature do
CTA_TEXT = 'Besuch anlegen'
it 'can upload .jpg files' do
visit new_place_path
attach_file('visits_images', test_jpg)
click_on CTA_TEXT
expect(last_image_content_type).to eq('image/jpg')
end
it 'can upload .png files' do
visit new_place_pa... |
# To run this code, be sure your current working directory
# is the same as where this file is located.
# ruby 2.rb
# EXERCISE
# Continue your craps program.
# When executed, this program should print out two random
# numbers, one on each line, simulating the roll of two
# dice. Set two variables, with names that make... |
require "rails_helper"
RSpec.describe Api::V1::Items::BestDayController, type: :controller do
describe "GET #show" do
let(:json_response) { JSON.parse(response.body) }
it "responds with successful 200 HTTP status code" do
merchant1, merchant2, merchant3 = load_merchants_with_transactions
item1 =... |
class ProjectsController < ApplicationController
before_action :find_project, except: [ :index ]
def index
@projects = Resource.where(resourceable_type: 'Project')
.visible
.paginate(page: params[:page], per_page: 15)
@page_title = "#{helpers.nice_sats_numbe... |
class Ingredient < ActiveRecord::Base
belongs_to :recipe, through: :recipe_ingredient_instance
has_many :recipe_ingredient_instances
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
require 'spec_helper'
describe TwitterCldr::Localized::LocalizedHash do
describe "#to_yaml" do
it "should be able to successfully roundtrip the hash" do
hash = { foo: "bar", "string_key" => Object.new }
res... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/ministerios/new.html.erb" do
include MinisteriosHelper
before(:each) do
@ministerio = mock_model(Ministerio)
@ministerio.stub!(:new_record?).and_return(true)
@ministerio.stub!(:ministerio).and_return("MyString")
@ministerio.stub!(:... |
# frozen_string_literal: true
require 'date'
require 'ostruct'
RSpec.describe Minutely::Time do
it 'includes Comparable' do
expect(described_class).to include Comparable
end
describe '#initialize' do
subject { described_class.new(14, 32) }
it 'sets #hour from first arg' do
expect(subject.hou... |
class LinkedList
attr_reader :head
class Node
attr_reader :data
attr_accessor :next_node
def initialize(data)
@data = data
@next_node = nil
end
end
def addToTail(data)
new_node = Node.new(data)
unless @head
@head = new_node
return
end
tmp = @head
... |
require "spec_helper"
describe TransferSlipsController do
describe "routing" do
it "routes to #index" do
get("/transfer_slips").should route_to("transfer_slips#index")
end
it "routes to #new" do
get("/transfer_slips/new").should route_to("transfer_slips#new")
end
it "routes to #sho... |
class Point < ActiveRecord::Base
belongs_to :educational_institution
belongs_to :achievement
validates :educational_institution_id, :achievement_id, :score, presence: true
validates :achievement_id, uniqueness: { scope: :educational_institution_id }
end
|
class AddPartners < ActiveRecord::Migration
def self.up
create_table :partners do |t|
t.integer :person_id
t.integer :partner_id
t.integer :order
t.string :nature # married, children
t.boolean :current
end
end
def self.down
drop_table :partners
end
end
|
# Based on the original ipaddress6 fact, but we also exclude RFC4193 local
# (private) IPv6 addresses and pick the shortest address to prefer static over
# autoconfiguration.
require 'facter/util/ip'
def get_address_after_token(output, token)
ip = []
String(output).scan(/#{token}\s?((?>[0-9,a-f,A-F]*\:{1,2})+[0-9... |
require 'open-uri'
require 'csv'
class BatchImportJob
include Delayed::ScheduledJob
run_every 30.minutes
def display_name
"Batch Import Traffic Speed Data"
end
def perform
url = "http://207.251.86.229/nyc-links-cams/LinkSpeedQuery.txt"
conn = open(url)
columns = [:link_id, :speed, :avg_travel_time, ... |
# Dynamic methods.
require_relative 'store'
class ReportingSystem
def initialize
@store = Store.new
@store.methods.grep(/^get_(.*)_[desc,price]/) do
ReportingSystem.define_report_methods_for($1)
end
end
def self.define_report_methods_for(item)
define_method("get_#{item}_desc") do
@store.send("get_... |
=begin
1) 1 # returns the element being deleted not the one(s) left over
2) [1,2,3] # arr.product([Array(1..3)]) creates an even more nested array; [["a", [1, 2, 3]], ["b", [1, 2, 3]]]
=end
|
module Naf
class LoggerName < NafBase
# Protect from mass-assignment issue
attr_accessible :name
#---------------------
# *** Associations ***
#+++++++++++++++++++++
has_many :logger_style_names,
class_name: '::Naf::LoggerStyleName'
has_many :logger_styles,
through: :logger_s... |
require 'rails_helper'
RSpec.describe "thumbs up an idea endpoint", type: :request do
it "thumbs up an existing idea and increases quality 1 notch" do
idea_1 = Idea.create(title: "This is idea #1",
body: "The body of idea #1 should be here")
idea_2 = Idea.create(title: "This is idea ... |
# frozen_string_literal: true
module Sodor
class App
# attr_reader :railroad
def initialize(railroad:)
# @railroad = railroad.freeze
end
end
end
|
FactoryBot.define do
factory :setting do
ip_addresses { [] }
work_from_home { 2 }
end
end
|
require "bundler/gem_tasks"
require "rake/extensiontask"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
Rake::ExtensionTask.new("jaro_winkler") do |ext|
ext.lib_dir = "lib/jaro_winkler"
end
task default: [:compile, :spec]
desc 'type can be "native" or "pure"'
task :benchmark, :type do |t, args|
... |
# encoding: UTF-8
# require 'rake/notes/rake_task'
# require 'rspec/core/rake_task'
desc 'Generates the book'
task :book do
system 'cd lib && rake book'
end
desc 'Build book'
task :build do
system 'cd lib && rake build'
end
desc 'Run continuous integration'
task :ci do
system 'cd lib && rake ci'
end
desc 'Ru... |
class Restaurant < ApplicationRecord
has_many :reviews, dependent: :destroy
validates :name, uniqueness: true, presence: true
validates :address, presence: true
def average_rating
average_rating = 0
if self.reviews.length > 0
self.reviews.each do |review|
average_rating += review.rating
... |
require 'test_helper'
class CollectionshipTest < ActiveSupport::TestCase
def setup
@collectionship = collectionships(:christelle_iphone)
end
test "should not save collectionship without user_id" do
@collectionship.user_id = nil
assert_not @collectionship.save
end
test "should not save collectio... |
class Admin < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
email_regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]... |
class User < ActiveRecord::Base
has_many :proficiencies
has_many :skills, :through => :proficiencies
end
|
array = [1, 2, 3, 4, 5]
def select(args)
counter = 0
new_arr = []
while counter < args.size
new_arr << args[counter] if yield(args[counter])
counter += 1
end
new_arr
end
p select(array) { |num| num.odd? } # => [1, 3, 5]
p select(array) { |num| puts num } # => [], because "puts num" returns nil a... |
class InvitationsController < ApplicationController
def new
end
def create
invitee_data = InviteService.new(invite_params[:handle], current_user.token).get_user_json
if invitee_data[:email]
host = request.env["HTTP_HOST"]
InvitationMailer.invite(current_user, invitee_data, host).deliver_n... |
# frozen_string_literal: true
RSpec.describe 'Ticket Request', type: :request do
include_context 'with branch location'
include_context 'with json response'
include_context 'with user token'
let(:event) { build(:event, branch: branch, location: location) }
before do
event.save!
branch.locations << ... |
# solitaire_encryption.rb
# Oct 28, 2016
# dmg
# list of classes, fields, methods
require 'pry'
class Card # :deck_ix, :suit, :face, :rank
attr_accessor :current_deck_ix
attr_reader :original_deck_ix, :suit, :face, :rank
@@deck_index = 1
def initialize(suit, face, rank)
unless @@deck_index > 54
@s... |
#
# Cookbook Name:: monit
# Attributes:: default
#
# Copyright 2010, Estately, Inc.
#
# 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
#
# Unle... |
class Admin::ContractPdf < Prawn::Document
def initialize(contract, template, requisite)
super()
@contract = contract
@student = contract.student
@template = template
@period = "с #{@student.group.start.to_s} по #{@student.group.end.to_s}"
@requisite = requisite
text_content
end
def t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.