text stringlengths 10 2.61M |
|---|
class Event < ApplicationRecord
belongs_to :calendar
validates :notes, :place, length: { maximum: 200 }
validates :title, length: { in: 1..100 }
validates :title, :calendar_id, :start_time, :end_time, presence: true
end
|
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.network :forwarded_port, :host => 5432, :guest => 5432
config.vm.network "private_network", ip: "192.168.40.2"
config.vm.network "public_network"
config.vm.provision "docker"
end |
class Mascota < ActiveRecord::Base
validates :nombre, presence: true, uniqueness: { scope: [:user_id, :sexo, :edad, :tiposmascota_id]}
validates :user_id, presence: true
validates :sexo, presence: true
validates :edad, presence: true
validates :tiposmascota_id, presence: true
belongs_to :user
belongs_to... |
module ControllerMacros
def login_user
@request.env['devise.mapping'] = Devise.mappings[:user]
# Don't create the user twice
user = User.find_by_email(FactoryGirl.attributes_for(:user)[:email])
user = FactoryGirl.create(:user) unless user
sign_in user
end
end
|
require 'thor'
require 'google_drive'
require 'sinatra/base'
require 'launchy'
module GoogleDriveDotenv
class App < Sinatra::Base
set :server, %w(webrick)
class << self
attr_accessor :credentials, :output, :key
def export_env(authorization_code)
credentials.code = authorization_code
... |
class AddForeignKeyToReplies < ActiveRecord::Migration
def change
add_foreign_key :replies, :users
end
end
|
class Product < ApplicationRecord
scope :by_type, ->(type) { where(group_type: type) }
scope :by_maker, ->(maker) { where(maker: maker) }
scope :by_model, ->(model) { where(model: model) }
class << self
def update_records_in_db(list)
list.each do |val|
parse_model_and_maker(val[:name])
... |
module App::TokenSupport
def ids_by_token token
( neg, plain ) = observe_token( token )
ids = where( arel_table[ :name ].matches( "%#{plain}%" ) ).map( &:id )
[ neg, ids ]
end
def model_symbol_id model
"#{model}".underscore << '_id'
end
def observe_token token
token =~ /^-/ && [ true, to... |
class AddTriesToQueueItems < ActiveRecord::Migration
def change
add_column :queue_items, :tries, :integer, :default => 0, :null => false, :after => :state
add_column :queue_items, :run_at, :timestamp, :after => :tries
add_index :queue_items, [:locked, :state]
end
end
|
require 'date'
require 'svntl'
include SvnTimeline
context "Non-existing repository" do
include ContextHelper
mock_svn "file:///existing/repository"
specify "should raise SubversionError(No such repository) during creation" do
lambda { SubversionRepository.new "file:///do/not/exist" }.should_raise Subversi... |
module TopologicalInventory
module Persister
class << self
attr_writer :logger
end
def self.logger
@logger ||= Logger.new(STDOUT, :level => Logger::ERROR)
end
module Logging
def logger
TopologicalInventory::Persister.logger
end
end
end
end
|
=begin
Classe Mail
Usage
------
Mail::send(<data>)
ou
mail = Mail::new(<data>)
mail.send Mail::new(<data>).send
ou
mail = Mail::new
mail.send(<data>) Mail::new.send(<data>)
Data
-----
:to Le mail du destinataire (par défaut, l'administrateur)... |
require_relative '../acceptance_helper'
feature 'Add comment answer' do
given(:user) { create(:user) }
given!(:question) { create(:question, user: user) }
given!(:answer) { create(:answer, question: question, user: user) }
given!(:other_question) { create(:question, user: user) }
given!(:other_answer) { cr... |
# coding: utf-8
class DictionariesController < CompanyController
before_action :redirect_if_not_owner, except: [:index]
add_breadcrumb 'На главную', '/'
add_breadcrumb 'Словари', Dictionary, except: [:index]
def index
@dictionaries = @organization.dictionaries.roots
end
def new
@dictionary = @orga... |
require 'open-uri'
require 'rubygems'
require 'oauth'
require 'json'
#created with the help of codecademy
puts "Enter the text of your tweet"
tweet_to_send = gets.chomp
#check that user input is not greater than 140 characters
if(tweet_to_send.length > 140)
{
put "Tweet was longer than 140 characters, shortenin... |
class LessonsController < ApplicationController
before_action :logged_in_user
before_action :current_lesson, except: [:index, :create]
before_action :correct_user, except: [:index, :create]
before_action :finished?, only: [:edit, :update]
def index
@lessons = current_user.lessons
.paginate page: pa... |
require 'gosu'
require './board.rb'
class GUI < Gosu::Window
def initialize
super(WINDOW_WIDTH, WINDOW_HEIGHT, false)
self.caption = "Minesweeper Gosu GUI"
@faces = load_spritesheet("assets/faces.png", FACE_SIZE)
@tiles = load_spritesheet("assets/tiles.png", SQUARE_SIZE)
@font = Gosu::Font.new... |
FactoryGirl.define do
factory :city do
name {Faker::Address.city}
association :state
end
end
|
class AddFotoPerfilToUsuario < ActiveRecord::Migration
def change
add_column :usuarios, :foto_perfil, :string
end
end
|
class BetStepsController < ApplicationController
include Wicked::Wizard
before_action :find_bet, only: [:show, :update]
steps(*Bet::WIZARD_STEPS)
def show
render_wizard
end
def update
params[:bet][:status] = status_for_step
@bet.update_attributes(bet_step_params)
render_wizard @bet
en... |
=begin
In Ruby, sets are collections of unique elements. The order of the elements doesn’t matter,
so they can’t be reliably referenced by an index. Sets are useful when you want to ensure
there are no duplicate items.
=end
require 'set'
my_set = Set.new
#OR
my_set1 = Set.new([1,2,3,4,5,6])
puts my_set1
pu... |
class FoodOrderItem < ApplicationRecord
belongs_to :foods
belongs_to :orders
end
|
require 'test_helper'
require 'sword/deposit_utils'
class DepositUtilsTest < ActiveSupport::TestCase
include ActionDispatch::TestProcess
setup do
@test_zip_file = fixture_file_upload('/zip_files/test.zip')
@test_zip_file_path = Rails.root.join('test/fixtures/zip_files/test.zip')
@test_dir = File.join(... |
json.array!(@trips) do |trip|
json.extract! trip, :id, :picture, :start, :end, :location, :ocation, :travellor, :details
json.url trip_url(trip, format: :json)
end
|
=begin
Author: Tom Murphy
Last Modified: 2019-11-22 11:45
=end
# https://edabit.com/challenge/Bgbqoyz4HADikdQJr
# No Yelling
=begin
Create a function that transforms sentences ending with multiple question marks ? or exclamation marks ! into a sentence only ending with one.
Notes
Only change ending p... |
# List_Resource_Pools.rb
#
# Description: List the resource pools associated with a provider
#
# Get vm object from root
vm = $evm.root['vm']
raise "Missing $evm.root['vm'] object" if vm.nil?
provider = vm.ext_management_system
$evm.log(:info, "Detected Provider: #{provider.name}")
pools_hash = {'<choose>' => nil}
... |
require 'rake/packagetask'
require 'uri'
require 'net/http'
require 'json'
require 'zip'
require 'date'
require 'nokogiri'
require 'mixlib/shellout'
require './lib/chef/azure/helpers/erb.rb'
PACKAGE_NAME = "ChefExtensionHandler"
MANIFEST_NAME = "publishDefinitionXml"
EXTENSION_VERSION = "1.0"
CHEF_BUILD_DIR = "pkg"
PE... |
class Chat < ActiveRecord::Base
has_many :messages, dependent: :destroy
belongs_to :event
has_many :chat_users
has_many :users, through: :chat_users
def self.existing_chat(event_id, category)
Chat.find_by(event_id: event_id, category: category)
end
end
# validates_uniqueness_of :sender_id, :scope =... |
require 'conf/timer_configuration'
describe TimerConfiguration do
subject(:conf) {TimerConfiguration.new read, write, clock}
let(:clock) {double :clock, now: now}
let(:read) {double :read}
let(:write) {double :write}
let(:now) {double :now, to_s: Time.at(0).to_s}
let(:user) do
require 'sinatra'
ap... |
cask 'dungeon-crawl-stone-soup-console' do
version '0.19.0'
sha256 'd25d7dbb42cd5ba8e04592d431e7b405b4f22152af85a82580a7a610fcfa6639'
url "https://crawl.develz.org/release/stone_soup-#{version}-console-macosx.zip"
name 'Dungeon Crawl Stone Soup'
homepage 'https://crawl.develz.org'
app 'Dungeon Crawl Stone... |
class AddIndexToNewItemUse < ActiveRecord::Migration[5.2]
def change
add_index :new_item_uses, [:result_no, :generate_no], :unique => false, :name => 'resultno_and_generateno'
add_index :new_item_uses, :name
end
end
|
FactoryGirl.define do
factory :idea do
sequence(:content) {|n| "#{n} features!" }
end
end
|
require 'spec_helper'
describe 'donation_orders/_form_fields_info' do
include CampaignExampleHelpers
let!(:campaign) { create_campaign_with_tier_taglines }
let!(:charity) { campaign.charity }
let!(:donation_order) { DonationOrder.new }
let(:form) { ActionView::Helpers::FormBuilder.new(:donatio... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
has_many :posts, dependent: :destroy
... |
module Api
module V1
class UsersController < ApplicationController
def show
user = User.find(params[:id].to_i)
render json: user, except: :password_digest
end
end
end
end |
require 'spec_helper'
describe PasswordResetsController do
let(:user) { Fabricate(:user, token: "12345") }
describe "GET show" do
context "with valid token" do
before(:each) { get :show, id: user.token }
it "renders show template if token is valid" do
expect(response).to render_template ... |
# encoding: utf-8
base_dir = File.expand_path(File.join(File.dirname(__FILE__), "."))
lib_dir = File.join(base_dir, "lib")
$LOAD_PATH.unshift(lib_dir)
require 'FizzBuzz'
print "FizzBuzz したい開始と終了の数値を入力して Enter キーを押してください。[1-100]: "
number = gets.chomp.split(/\-/)
# 何も入力されなかった時の初期値。
if number == [] then
number ... |
require 'rails_helper'
RSpec.describe Memory, type: :model do
let(:user) { FactoryGirl.create(:user) }
let(:the_subject) { Subject.create(user:user, group_tag: 'family', name:'Daffy Duck', email:'daffy@duck.com') }
let(:memory) { Memory.create(subject:the_subject, content: 'Lorum ipsum') }
subject { memory }... |
module CronSpec
##
# Encapsulates the interpretation of a cron specification and
# provides a method which determines if the specified time is effective
# with respect to the specification.
#
class CronSpecification
TimeMethods = [ :min, :hour, :day, :month, :wday ]
MINUTE = 0
HOUR = 1
D... |
# ================================================================================
# Part:
# Desc:
# ================================================================================
class Lead
include Mongoid::Document
include Mongoid::Timestamps
# ... |
class V1::TokensController < Knock::AuthTokenController
include JsonApiController
skip_before_action :verify_authenticity_token, only: :create
def create
render json: TokenSerializer.new(auth_token, is_collection: false), status: :created
end
private
def entity_class
User
end
def auth_param... |
#!/usr/bin/env ruby
# Example post-receive hook written in ruby
# (c) 2016 Brent Laster
puts "Running post-receive hook..."
deployment_dir=`git config user.deploy-dir`
# rest of hook presumes deployment_dir exists
# if the configuration value isn't set for Git, don't deploy
if (deployment_dir == "")
... |
#require 'rexml/document'
#include REXML
require 'nokogiri'
class WeatherResponse
attr_accessor :response, :current_conditions, :forecast_conditions, :lat, :long
def initialize(response)
@response = Nokogiri::XML(response)
@current_conditions = {}
@current_conditions[:condition] = @response.css("curr... |
# Require the dependencies file to load the vendor libraries
require File.expand_path(File.join(File.dirname(__FILE__), "dependencies"))
class GoogleAppsApiV1
# ==== Parameters
# * +input+ - The String of Xml that was built by evaluating the node.xml handler template.
def initialize(input)
# Set the input do... |
module Services
class JobFailed
include Commands::Execute
def call(event)
cmd = Commands::FailJob.new(
uid: event.data[:uid],
queue_name: event.data[:queue_name],
state: event.data[:state],
data: event.data
)
execute(cmd)
end
private
def event_... |
require 'v1/server_logic'
class FayeServer
VERSIONS = %w(v1)
def incoming(faye_message, callback)
start_time = Time.now
if version = check_version(faye_message)
faye_message['custom_data'] = { 'version' => version }
server_logic_class(version).incoming(faye_message)
end
rescue => e
n... |
require 'rails_helper'
describe Cart do
let(:cart) {Cart.create!()}
let(:product) { FactoryGirl.create(:product, price: 2.50)}
describe 'add product' do
it "creates new line item in cart if product is not in cart" do
expect {
cart.add_product(product.id)
}.to change{cart.line_items.size}... |
source 'https://rubygems.org'
# Declare your gem's dependencies in service_api.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# Declare any dependencies that are still in development here instead of ... |
class SubmissionFolder < ActiveRecord::Base
include Folder
has_and_belongs_to_many :filters, -> { uniq }
has_and_belongs_to_many :submissions, -> { uniq }
# Preferred method for adding a submission. This allows
# checks to be made against various factors.
#
def add_submission(sub)
if sub.collaborato... |
require 'active_support/message_encryptor'
require 'active_support/secure_random'
require 'action_controller'
require 'uri'
class SessionInjector
class InvalidHandshake < StandardError; end
RACK_COOKIE_STRING = 'rack.request.cookie_string'.freeze
RACK_COOKIE_HASH = 'rack.request.cookie_hash'.freeze
HTTP_COOK... |
class Audit < ActiveRecord::Base
include Loggable
belongs_to :student
belongs_to :advisor
def added_message
"An audit was recorded on #{self.date_performed} with " \
"the following comments: #{self.comment}"
end
def updated_message
"FIX ME: An audit was updated"
end
def removed_message
"FIX ME: An a... |
class AddMoreColumnsToOrders < ActiveRecord::Migration
def change
add_column :orders, :c_class, :string
add_column :orders, :c_ship1, :string
add_column :orders, :c_ship2, :string
add_column :orders, :c_shipcity, :string
add_column :orders, :c_shipstate, :string
add_column :orders, :c_shippost... |
class HelpItemSerializer < ActiveModel::Serializer
attributes :id, :comment, :status, :student_id, :student_first_name, :student_last_name, :instructor_id, :instructor_full_name, :instructor_first_name
def student_id
object.student.id
end
def student_first_name
object.student.profile.first_name
end... |
class User < ActiveRecord::Base
enum role: {
user: 0,
leader: 1,
orgnization: 2,
admin: 3
}
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
... |
require "tty-prompt"
require "tty-font"
require "tty-link"
require 'json'
require 'httparty'
require 'colorize'
require 'colorized_string'
require_relative './classes/entry.rb'
class Bestiary
attr_accessor :beasts
def initialize(file_path)
@beasts = []
@prompt = TTY::Prompt.new
@font ... |
class Spend < ApplicationRecord
validates :points_req, presence: true
end
|
# A Pythagorean triplet is a set of three natural numbers, {a, b, c}, for
# which,
# a**2 + b**2 = c**2
# For example, 3**2 + 4**2 = 9 + 16 = 25 = 5**2
class Triplet
attr_reader :a, :b, :c
def initialize(n1, n2, n3)
@a = n1
@b = n2
@c = n3
end
def self.where(options)
results = []
max = ... |
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :title
t.text :description
t.timestamps null: false
end
end
end |
class CakBotInitializer
def self.setup(bot)
# bot.custom_command :memes, {},
# ":regional_indicator_m: :regional_indicator_e: :regional_indicator_m: :regional_indicator_e: :regional_indicator_s:"
# bot.custom_command :roll, {},
# "1;2;3;4;5;6"
# bot.command :bold do |_event, *... |
# == Schema Information
#
# Table name: requisitions
#
# id :integer not null, primary key
# vendor :string(255)
# purchaser :string(255)
# created_at :datetime
# updated_at :datetime
# property_type :string(255)
#
class Requisition < ActiveRecord::Base
has_many :requi_ques... |
require "rails_helper"
RSpec.describe Import, :type => :model do
describe 'Validations and relations' do
it { is_expected.to belong_to(:user) }
end
describe 'Initial values' do
let(:import) { build :import }
it do
expect(import.total_count).to eq(0)
expect(import.imported_count).to eq(0... |
FactoryBot.define do
factory :contribution do
factory :contribution_kirk, class: OcpfContribution do
officer factory: :officer_kirk
type { "OcpfContribution" }
date { "2004-04-20" }
contributor { "James" }
zip { 2152 }
employer { "City of Boston" }
occupation { "Law Enfor... |
class AddParticipantsToMessageGroups < ActiveRecord::Migration[6.1]
def change
add_reference :message_groups, :participant, null: true
end
end
|
class FixFuckup < ActiveRecord::Migration
def change
remove_column :podcasts, :producer_id
add_column :episodes, :producer_id, :integer, index: true
end
end
|
class CaptchaNginxModule < Formula
desc "Captcha module for nginx"
homepage "https://github.com/fallgold/ngx_http_captcha"
url "https://github.com/fallgold/ngx_http_captcha/archive/0fbd025edb.tar.gz"
version "0.1"
sha256 "35e701afd0343a7fe167df6b3d546d4a8589e6d5ff1aa9064a8f9ebd936cc50b"
bottle :unneeded
... |
class Device
include MongoMapper::Document
belongs_to :user, class_name: "User"
key :device_token, String, required: true, unique: true
key :device_name, String
key :model, String
key :system_version, String
key :app_version, String
key :app_bundle_version, String
key :locale, String
key :developm... |
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the f... |
class BitcoinsController < ApplicationController
before_action :set_bitcoin, only: [:show, :edit, :update, :destroy]
# GET /bitcoins
# GET /bitcoins.json
def index
@bitcoins = Bitcoin.all
end
# GET /bitcoins/1
# GET /bitcoins/1.json
def show
end
# GET /bitcoins/new
def new
@bitcoin = Bi... |
class SignupController < ApplicationController
layout "login"
def new
end
def create
@user = User.new(user_params)
if @user.save
cookies.signed[:user_id] = @user.id
flash[:success] = "Your account has been created"
redirect_to dashboard_url
else
flash[:error] = @user.error... |
class Player
def initialize
@currentDirection = :forward
@backDirection = :backward
@rested = true
@in_battle = false
@previousHealth = 0
@enemies = ["Thick Sludge", "Archer", "Wizard"]
end
def intelegent_walk(warrior)
if taking_damage?(warrior.health)
then
... |
# frozen_string_literal: true
require 'brigitte/version'
require 'brigitte/game'
module Brigitte
class Error < StandardError; end
end
|
class RemoveConditionFromUser < ActiveRecord::Migration[5.1]
def change
change_column :users, :nationality, :string, null: true
end
end
|
require './shift_subtitle.rb'
describe "shift" do
it "shifts time forward" do
time = "01:32:04,283 --> 01:32:07,769"
shifter = Shift.new(time)
offset = 2.5
result = shifter.shift_forward(offset)
expected = "01:32:06,783 --> 01:32:10,269"
result.should eq(expected)
end
it "shifts time backward" do
tim... |
# 题目: 输入一个数字 x,请判断是否正数、零或负数,以及是不是偶数
print '请输入一个整数,然后按 Enter: '
x = gets
a = if x.to_i > 0
'正数'
elsif x.to_i == 0
'零'
else
'负数'
end
c = x.to_i % 2
b = if c == 0
'偶数'
else
'奇数'
end
# ....
puts "这个数是__#{a}___ (正数或零或负数)"
puts "这个数是___#{b}__ (偶数或奇数)"
|
class RepliesController < ApplicationController
before_action :set_reply, except: [:create, :index]
before_action :reply_params, only: [:update, :create]
def index
@replies = Reply.all
render json:@replies
end
def show
render json:@reply
end
def destroy
... |
class User < ApplicationRecord
#TODO: validates
has_many :tweets
has_many :likes
has_many :like_tweets, through: :likes, source: :tweet
end
|
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
setup do
@admin = users(:admin)
@user = users(:michael)
end
test 'site header' do
get root_path
assert_select 'header' do
assert_select '#title a[href=?]', root_path, text: "The Freeman's newspaper"
assert_s... |
class AddAccountIdToGroups < ActiveRecord::Migration[5.1]
def change
add_column :groups, :account_id, :integer, null: false
end
end
|
# -*- encoding : utf-8 -*-
class CreateMains < ActiveRecord::Migration
def change
create_table :mains do |t|
t.string :login, :presence => true, :limit => 20
t.string :hash_pass
t.string :hash_salt
t.integer :owner_id, :presence => true
t.integer :priv_level, :presence => true
t.ti... |
# Right Triangles
=begin
(Understand the Problem)
Problem:
Write a method that takes a positive integer, n, as an argument, and displays a right triangle whose sides each have n stars
Inputs: Positive integer
Outputs: A right triangle (made up of strings of asterisks)
Questions:
1.
Explicit Rules:
... |
class QuickFind
attr_reader :array
def initialize size
@array = (0...size).to_a
end
def union node1, node2
value_to_be_changed = array[node1]
array.each_with_index do |value, index|
if value == value_to_be_changed
array[index] = array[node2]
end
end
end
end
quick_find =... |
class ColorFamily < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name
has_many :colors, dependent: :destroy
end
|
Rails.application.routes.draw do
namespace :v1 do
resource :auth, only: %i[create]
resource :horses do
get '/:id', to: 'horses#show', as: 'horse'
get '/:id/getVets' => 'horses#getVets', as: 'getVets'
get '/:id/getClients' => 'horses#getClients', as: 'getClients'
get '/:id/getCurrentOwn... |
require 'spec_helper'
describe 'users/passwords/edit' do
include_context 'devise view'
before do
render
end
it "has title" do
rendered.should have_selector('h1', :text => 'Change your password')
end
it "has change password form" do
rendered.should have_xpath("//form[@method='post' and @actio... |
class Task < ActiveRecord::Base
attr_accessible :completed, :content, :date, :name, :task_id
belongs_to :user
belongs_to :project
belongs_to :task
has_many :tasks
#validates :user_id, presence: true
validates :name, presence: true
def for_today?
self.date.today? unless self.date.nil? || self.comp... |
class CreateDisciplineParticipations < ActiveRecord::Migration
def self.up
create_table :discipline_participations do |t|
t.string :type
t.boolean :action_taken
t.integer :school_id
t.references :user
t.references :discipline_complaint
t.timestamps
end
end
def self.do... |
#1 Need-To-Know Basis
class Person
def initialize(name, age)
@name = name
@age = age
end
public # This method can be called from outside the class.
def about_me
puts "I'm #{@name} and I'm #{@age} years old!"
end
private # This method can't!
def bank_account_number
@accou... |
require 'rails/generators'
class UrlStore::InitializerGenerator < Rails::Generators::Base
def self.source_root
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
end
def create_initializer_file
template 'initializer.erb', 'config/initializers/url_store.rb'
end
end
|
Factory.define(:user) do |f|
f.name { fake(:name) }
f.email { fake(:internet, :email) }
end
|
FactoryGirl.define do
to_create {|instance| instance.save(validate: false)}
factory :user do |f|
f.sequence(:email) {|n| "test#{n}@gmail.com"}
password "password"
password_confirmation "password"
phone_number "123-456-7890"
address "2501 Benvenue Ave."
lifegroup... |
Booking.destroy_all
University.destroy_all
Category.destroy_all
Job.destroy_all
User.destroy_all
# LOCATIONS = ["R. do Carmo 51-1, 1200-094, 04015-070, Lisbon", "Rua de Entrecampos 13-3° Esq. 1000-152 Lisbon",
# "Av. Guerra Junqueiro 30 C, 1000-167 Lisbon", "Largo do Carmo 4, 1200-022 Lisbon", "R. de São Pedro de Al... |
class CreateInvoiceMilestones < ActiveRecord::Migration
def change
create_table :invoice_milestones do |t|
t.integer :order
t.text :description
t.integer :estimate_percentage
t.integer :invoice_schedule_id
t.timestamps
end
end
end
|
class GenericJourney
attr_reader :steps, :params
def initialize(first_step_class, slug, params, paths)
@steps = []
@params = HashWithIndifferentAccess.new
@paths = paths
klass = first_step_class
loop do
permitted = params.permit(klass.permit_list)
step = klass.new(permitted)
... |
# typed: true
class AddFields3ToWitAiParseModelExamples < ActiveRecord::Migration[6.0]
def change
add_column :wit_ai_parse_model_examples, :wit_ai_server_response, :text
end
end
|
class CommentsController < ApplicationController
def new
@channel = Channel.find(params[:channel_id])
@post = Post.find(params[:post_id])
end
def create
@channel = Channel.find(params[:channel_id])
@post = @channel.posts.find(params[:post_id])
@comment = @post.comments.create(comment_params)... |
class Review < ApplicationRecord
belongs_to :product
belongs_to :user
#validates :body, length: { minimum: 2, maximum: 200 }
validates :rate, presence:true, numericality: { less_than_or_equal_to: 5, greater_than_or_equal_to:1 , only_integer: true }
# greater_than 0 less_than 6
has_many :likes, dependent... |
class ListItem < BasicInformation
has_one :list, dependent: :destroy
has_one :superinformation, through: :list
validates_associated :list
scope :default_order, ->{ order('lists.ordinal') }
end
|
class AgentClientsController < ApplicationController
before_action :set_agent_client, only: [:show, :edit, :update, :destroy]
# GET /agent_clients
# GET /agent_clients.json
def index
@agent_clients = AgentClient.all
end
# GET /agent_clients/1
# GET /agent_clients/1.json
def show
end
# GET /ag... |
module Fog
module Compute
class Brkt
class Real
def create_security_group_rule(security_group_id, options={})
request(
:expects => [201],
:method => "POST",
:path => "v1/api/config/securitygroup/#{security_group_id}/rules",
:body => Fo... |
require "spec_helper"
RSpec.describe "Day 7: No Space Left On Device" do
let(:runner) { Runner.new("2022/07") }
let(:input) do
<<~TXT
$ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
2557 g
62596 h.lst
$... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.