text stringlengths 10 2.61M |
|---|
require './user.rb'
require './sorters.rb'
require 'faker' # from Gemfile
# setup some users using faker
def generate_random_login(length = 6)
(('a'..'z').to_a + (0..9).to_a).sample(length).join
end
def print_user_list(user_list)
puts " \tfirst name\tlast name\tlogin"
user_list.each_with_index do |user, id... |
class AddCharityNumberToCharity < ActiveRecord::Migration
def change
add_column :charities, :charity_number, :integer
end
end
|
class ManageIQ::Providers::Amazon::AgentCoordinatorWorker < MiqWorker
include ProviderWorkerMixin
include MiqWorker::ReplicaPerWorker
require_nested :Runner
self.required_roles = ['smartproxy']
self.workers = 1
def self.has_required_role?
super && all_valid_ems_in_zone.any?
end
def self.e... |
# Andrew Horsman
# Millipede Remake
# Error handling.
require 'configuration'
module GameHelpers
module Errors
def self.throw(error_message, severity)
log_string = "[#{Time.now.to_i}] [#{severity.to_s}] #{error_message}"
File.open(Configuration::LOG_FILE, "a") do |log_file|
log_file.p... |
class AddPermissionsToAppzips < ActiveRecord::Migration
def change
add_column :appzips, :permissions, :string, :limit => 3, :default => "FFF"
end
end
|
require 'wsdl_mapper/type_mapping/base'
require 'wsdl_mapper/dom/builtin_type'
require 'bigdecimal'
module WsdlMapper
module TypeMapping
Boolean = Base.new do
register_xml_types %w[
boolean
]
def to_ruby(string)
case string.to_s
when 'true', '1'
true
... |
# frozen_string_literal: true
require 'item'
describe Item do
subject { described_class.new('name', 'sell_in', 'quality') }
describe '#to_s' do
it 'converts item to string name, sell_in, quality' do
expect(subject.to_s).to eq 'name, sell_in, quality'
end
end
end
|
# "[Luke:] I can't believe it. [Yoda:] That is why you fail.".include?('Yoda')
# "Ruby is a beautiful language".start_with?('Ruby')
# "I can't work with any other language but Ruby".end_with?('Ruby')
# puts "I am a Rubyist".index('R')
# puts 'Fear is the path to the dark side'.split(/ /)
# Heap
# The standard an... |
class CreateUsers < ActiveRecord::Migration[5.2]
def up
create_table :users do |t|
t.string "email", :limit => 200 #user email
t.string "username", :limit => 200 #user email
t.string "password_digest" #user password
t.string "first_name", :limit => 100 #user first name
t.string "las... |
# :nocov:
require 'aws-sdk-s3'
require 'typhoeus'
module WorkbenchUpload
def self.upload_file_to_workbench(workflow_id:, step_id:, api_token:, path:, filename:)
s3_config = get_s3_config_from_workbench(workflow_id, step_id, api_token)
puts "Uploading to s3://#{s3_config['bucket']}/#{s3_config['key']}"
up... |
class InscritoContactado
include Mongoid::Document
field :nombre_inscrito, type: String
field :cedula_inscrito, type: Float
field :celular_inscrito, type: String
field :codigo_mesa, type: Integer
field :edad_inscrito, type: Integer
field :sexo_inscrito, type: Mongoid::Boolean
embedded_in :mesa, :invers... |
class CreateRepository
class << self
%w( create create! ).each do |sym|
define_method sym do |*args|
new.send(sym, *args)
end
end
end
def klass
self.class.name.gsub(/^Create/, '').constantize
end
%w( create create! ).each do |sym|
define_method sym do |hash|
sanitiz... |
require 'spec_helper'
feature "when signed in" do
feature "when on the goal index page" do
before(:each) do
visit new_user_url
fill_in 'Username', :with => "user1"
fill_in 'Password', :with => "password1"
click_on("Submit")
click_link("Create New Goal")
fill_in 'Title', :wi... |
class FileFormatProfilesController < ApplicationController
before_action :require_medusa_user, except: [:index, :show]
before_action :find_file_format_profile, only: [:show, :edit, :update, :destroy, :clone]
def index
@file_format_profiles = FileFormatProfile.order(:name)
end
def show
@file_formats... |
require 'spec_helper'
#This tests the mechanism for all user accounts
#Ex. The faciliity to log in, sign up, delete, edit etc
describe User do
#This command is run before carrying out all the tests.
before { @user = User.new(name: "Example User", email: "user@example.com", password:"foobar", password_confirmatio... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
root 'tops#index'
resources :tops do
resources :artists
end
resources :artists do
resources :songs
end
end
|
class RawPlane
include Mongoid::Document
field :created_at, type: Time
field :deal_tweeted, type: Boolean, default: false
field :last_updated, type: Time
field :region
field :locality
field :full_address
field :price, type: Float
field :make
field :model
field :year, type: Integer
field :reg_num... |
class PlayerActivityJob < ActiveJob::Base
queue_as :urgent
def perform(player_id)
player = Player.find(player_id)
Player::SaveActivity.call(player)
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe RouteStop do
it { should belong_to(:bus_route) }
it { should belong_to(:bus_route) }
it { should have_many(:pickups) }
it { should have_many(:dropoffs) }
it { should have_db_column(:stop_time) }
it { should validate_presence_of(:stop_time... |
module::Dieroll
class Roller
attr_reader :total
# Roll 1dX
def self.d(sides)
rand(1..sides)
end
# Roll arbitrary dice notation string
def self.from_string(string)
rolls = [0]
sets = s_to_set(string)
sets.each do |set|
if(set.respond_to?(:count) && set.count =... |
require 'test_helper'
class Liquid::Drops::UserDropTest < ActiveSupport::TestCase
include Liquid
def setup
@buyer = FactoryBot.create(:buyer_account)
@user = @buyer.users.first
@drop = Drops::User.new(@user)
end
test '#display_name' do
assert_equal @user.decorate.display_name, @drop.display_... |
class User < ApplicationRecord
has_secure_password
has_many :addresses, dependent: :destroy
has_many :cart_items, dependent: :destroy
has_many :orders, dependent: :destroy
validates :roll, presence: true
validates_acceptance_of :roll, accept: ["admin", "user", "clerk"]
validates :email, presence: true
v... |
module FreeKindleCN
class Item
def initialize(subject)
@subject = subject
end
# asin, title, amount, details_url, review*, image_url, author*,
# binding*, brand, ean, edition, isbn,
# item_dimensions, item_height, item_length, item_width, item_weight,
# package_dimensions, package_hei... |
class IsHideByAdminInItemComments < ActiveRecord::Migration
def change
add_column :item_comments, :is_hide_reward_by_admin, :integer,:default => 0
end
end
|
class Exercise < ActiveRecord::Base
self.per_page = 10
# default_scope where("visibility IS 'Published'")
attr_accessible :name, :type, :information, :visibility, :information_attributes, :owner,
:distance, :hours, :minutes, :seconds, :reps, :unit
has_one :information
belongs_to :owner, :class_name => "User", :f... |
require 'tmpdir'
require 'fileutils'
module Guard
class PHPUnit2
# The Guard::PHPUnit runner handles running the tests, displaying
# their output and notifying the user about the results.
#
class RealtimeRunner < Runner
def self.run(paths, options)
self.new.run(paths, options)
e... |
class MapsController < ApplicationController
before_action :authenticate_entity!
# Definition: Gets all online startups in the db and shows them on the map.
# Input: Startup Table.
# Output: Online Startups.
# Author: Alia Tarek.
def show_online
if params[:sector] == "please select a sector..."
@online = S... |
# frozen_string_literal: true
require "dry/core/equalizer"
require "dry/types/options"
require "dry/types/meta"
module Dry
module Types
module Composition
include Type
include Builder
include Options
include Meta
include Printable
include Dry::Equalizer(:left, :right, :option... |
class AlterFlightsTable < ActiveRecord::Migration[6.0]
def change
add_column :flights, :seconds_duration, :integer
remove_column :flights, :duration
end
end
|
require 'spec_helper'
module Categoryz3
describe Item do
let(:category) { FactoryGirl.build(:category) }
let(:item) { FactoryGirl.create(:item, category: category) }
context "child items" do
context "first level item" do
it "should create child items when created" do
item
... |
# frozen_string_literal: true
require "rails_helper"
module Renalware
module Diaverum
module Incoming
RSpec.describe SessionBuilders::Factory do
context "when the Diaverum XML treatment node has a start time" do
it "returns a SessionBuilders::Closed instance" do
args = {
... |
require_relative '../helper'
# require_relative 'app_identifier_guesser'
module PantographCore
class ActionLaunchContext
UNKNOWN_P_HASH = 'unknown'
attr_accessor :action_name
attr_accessor :p_hash
attr_accessor :platform
attr_accessor :pantograph_client_language # example: ruby pantfile
def... |
describe SetupWizardController do
describe '/apply' do
it 'should not apply the settings if an env is duplicate' do
payload = {
application: {
name: 'WEBv1'
},
envs: [
{ name: 'dev' }, { name: 'uat2' }, { name: 'prod2' }
],
hosts: {
dev: ... |
require 'cgi'
module Imdb #:nordoc:
module StringExtensions
if RUBY_VERSION.to_f < 1.9
# Unescape HTML
require 'iconv'
def imdb_unescape_html
Iconv.conv("UTF-8", 'ISO-8859-1', CGI::unescapeHTML(self)).strip
end
else
def imdb_unescape_html
CGI::unescapeHTML(self).encode(Encod... |
require 'ruby-kong/request/plugin'
module RubyKong
module Plugin
class << self
# Params: api:,
# plugin: {name:, consumer_id: nil, config.{property}}
#
# Usage: RubyKong::Plugin.create api: 'shipit',
# plugin: {name: 'key-auth'}
def creat... |
class CurriculumVitaeJobsController < ApplicationController
before_action :find_job, only: :create
def create
command = CurriculumVitaeUpload.call current_user, @job, cv_job_params
if command.success?
flash[:success] = t ".success"
else
flash[:danger] = command.errors[:failed]
end
... |
# The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145:
# 1! + 4! + 5! = 1 + 24 + 120 = 145
# Perhaps less well known is 169, in that it produces the longest chain of numbers that link back to 169;
# it turns out that there are only three such loops that exist:
#... |
# frozen_string_literal: true
# rubocop:disable RSpec/DescribeClass
require 'rails_helper'
RSpec.describe 'load_seeds' do
let(:valid_email) { 'jan@gmail.com' }
include_context 'rake'
it 'raises an error when user is not found' do
expect { subject.invoke('jan@jan.pl') }.to raise_error(RuntimeError)
end
... |
require 'rubygems'
require 'rake'
require './lib/rfm'
task :default => :spec
#require 'spec/rake/spectask'
#require 'rspec'
require 'rspec/core/rake_task'
# Manual
# desc "Manually run rspec 2 - works but ugly"
# task :spec do
# puts exec("rspec -O spec/spec.opts") #RUBYOPTS=W0 # silence ruby warnings.
# end
RSp... |
module XClarityClient
#
# Exposes UpdateRepoManagement features
#
module Mixins::UpdateRepoMixin
def discover_update_repo(opts = {})
UpdateRepoManagement.new(@config).fetch_all(opts)
end
def read_update_repo
UpdateRepoManagement.new(@config).read_update_repo
end
def refresh_upd... |
require 'spec_helper'
require 'yt/models/ownership'
describe Yt::Ownership, :partner do
subject(:ownership) { Yt::Ownership.new asset_id: asset_id, auth: $content_owner }
context 'given an asset managed by the authenticated Content Owner' do
let(:asset_id) { ENV['YT_TEST_PARTNER_ASSET_ID'] }
describe 'th... |
#!/usr/bin/env ruby
# Encoding : UTF-8
require "shellwords"
class UTF8
def initialize(*args)
@files = args.map do |file|
File.expand_path(file)
end
end
def get_encoding(file)
output = %x[file -bi #{file.shellescape}]
matches = output.match(/(.*)charset=(.*)/)
return nil unless matches
return match... |
class Article < ApplicationRecord
validates :title, presence:true, length: {minium: 3, maximun: 50}
validates :description, presence: true, length: {minimum:10, maximun: 300}
end
|
require 'text_order/matcher'
RSpec.describe TextOrder::Matcher do
it 'detects included text' do
matcher = described_class.new('lolwat')
expect(matcher.matches?('hahalolwatok')).to be(true)
expect(matcher.matches?('lolno')).to be(false)
end
it 'returns failure message' do
matcher = described_cla... |
class StoreController < ApplicationController
before_filter :find_cart, :except => :empty_cart
def index
#initialize
@count = increment_count
@time = Time.now
@date = Date.today
@products = Product.find_products_for_sale
@cart = find_cart
@current_item = nil
end
def increment_count
session... |
class AddIndexToFollow < ActiveRecord::Migration[5.1]
def change
add_index :follows, :followee_id
add_index :follows, :follower_id
end
end
|
module Vuf
class Batch
def initialize(size,&batch)
@mutex = Mutex.new
@batchQ = []
@size = size
@batch = batch
end
def push(obj)
@mutex.synchronize { @batchQ << obj }
objsToProc = get_objs(@size)
@batch.call(objsToProc) unless objsToProc.nil?
... |
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
content title: proc{ I18n.t("active_admin.dashboard") } do
columns do
column do
panel "Últimas 10 compras realizadas HOJE" do
purchases = Purchase.where(status: PurchaseStatus::P... |
class SavedSearch < ActiveRecord::Base
belongs_to :user
def count
feeds = user.feeds.collect { |item| item.id }
if feeds.count > 0
search_params = {:query => query, :after => last_access, :feeds => feeds}
Article.count(search_params)
else
0
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
class TimeslotsController < PlatformController
def index
@study = current_user.studies.find(params[:study_id])
# Use the provided date_from and then add 8 days to get the date to (an
# extra day to account for this being a DateTime, so we want to get all
# timeslots on the last day, up to 23:59)
f... |
class State < ActiveRecord::Base
has_many :cities
validates :name, :presence=>true
default_scope { order('name ASC') }
end
|
class AddSharingTypeToTools < ActiveRecord::Migration
def change
add_column :tools, :sharing_type, :string
end
end
|
class Room < ApplicationRecord
belongs_to :user
has_and_belongs_to_many :themes
has_many :bookings, dependent: :destroy
has_many :guests, through: :bookings, source: :user
validates :address, presence: true
validates :home_type, presence: true
validates :room_type, presence: true
validates :accommodate... |
require_relative 'intervals/genome_region'
require 'zlib'
def cages_initial_hash
cages = {:+ => Hash.new{|h, chromosome| h[chromosome] = Hash.new{|h2,pos| h2[pos] = 0 } },
:- => Hash.new{|h, chromosome| h[chromosome] = Hash.new{|h2,pos| h2[pos] = 0 } } }
end
# returns {strand => {chromosome => {position =... |
require 'vanagon/common/user'
describe 'Vanagon::Common::User' do
describe 'initialize' do
it 'group defaults to the name of the user' do
user = Vanagon::Common::User.new('willamette')
expect(user.group).to eq('willamette')
end
end
describe 'equality' do
it 'is not equal if the names dif... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe 'SDAM error handling' do
require_topology :single, :replica_set, :sharded
clean_slate
after do
# Close all clients after every test to avoid leaking expectations into
# subsequent tests because we set global assertions on ... |
module WsdlMapper
module Naming
# Represents the value of an enumeration value, consisting of the constant to
# generate and the string key, that will be the enumeration value.
class EnumerationValueName
attr_reader :constant_name, :key_name
# @param [String] constant_name Name for the consta... |
require 'active_record'
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: 'development.sqlite3'
)
class ReviewsMigration < ActiveRecord::Migration
def change
create_table :employees do |t|
t.references :department
t.string :name
t.decimal :salary, precision: 8, scale: ... |
# encoding: utf-8
describe Faceter::Functions, ".keep_symbol" do
let(:function) { -> value { value.to_s.reverse.to_i } }
it_behaves_like :transforming_immutable_data do
let(:arguments) { [:keep_symbol, function] }
let(:input) { 123 }
let(:output) { 321 }
end
it_behaves_like :transforming_immut... |
require 'SssSEMapp.rb'
require 'SssSEMtriggerBase.rb'
# Sends 'o' or 'O' command to all SBAMFDDDs
# read SssSEMtriggerBase for ruby-side-usage.
#
# 0 = stop loop; any other value = start loop
#
# Usage from cli (start demo loop):
# echo -n '1' >> triggers/demoID
# Usage from php (stop demo loop):
# file_put_contents... |
class PizzaandrollsSharesController < ApplicationController
def index
@shares = Share.all.where(type:'PIZZA&ROLLS').order_by(to: 'asc').where({:from.lte => Date.current()}).where({:to.gte => Date.current()})
end
end
|
# In the code below, sun is randomly assigned as 'visible' or 'hidden'.
sun = ['visible', 'hidden'].sample
# Write an if statement that prints "The sun is so bright!" if sun equals visible. Also, write an unless statement that prints "The clouds are blocking the sun!" unless sun equals visible.
if sun == 'visible'
... |
require "set"
require "tsort"
module Gem
# A really, really stupid resolver stub. Doesn't do source pinning,
# platforms, or really much of anything. Just a placeholder to play
# with API.
class Resolver
include TSort
attr_reader :sources
# Initialize a resolver, providing the initial set of +s... |
class CustomerJobsController < ApplicationController
before_action :set_customer_job, only: [:show, :edit, :update, :destroy]
# GET /customer_jobs
# GET /customer_jobs.json
def index
@customer_jobs = CustomerJob.all
end
# GET /customer_jobs/1
# GET /customer_jobs/1.json
def show
end
# GET /cu... |
require 'bundler/setup'
require 'ruby2d'
require './lib/snake_square.rb'
require './lib/snake_controller.rb'
RSpec.describe SnakeController, "#initialize" do
context "New snake" do
it "can it create a new snake?" do
snake = []
s = SnakeSquare.new(x:0,y:20,size:20, color:'red', dir:'right')
snak... |
# encoding: UTF-8
require 'spec_helper'
describe "courses/_sections_pane" do
before do
stub_template 'courses/_sections_table' => "Sections table"
end
it "display a pane with the sections of a course" do
course = mock_model Course, number: 321, duration: Durations::FULL_YEAR, credits: 5.0, full_name: ... |
module TwitterCli
class RegisterProcessor < Processor
attr_accessor :user_interface
def initialize(conn)
super(conn)
@rejected_values = ["Another user exists with same name pls go for some other username!"]
end
def execute
name = get_name
user_register = UserRegistration.... |
module RSpec
module Mocks
module AnyInstance
# @private
# The `AnyInstance::Recorder` is responsible for redefining the klass's
# instance method in order to add any stubs/expectations the first time
# the method is called. It's not capable of updating a stub on an instance
# that's ... |
module Api
module Endpoints
class Movies < Grape::API
namespace :movies do
desc 'Get movie.',
summary: 'Movies by day',
detail: 'Returns movies that are being shown given one week day.',
is_array: true,
success: Entities::Movie
params do
... |
class RemoveOrderProductFromProduct < ActiveRecord::Migration[5.0]
def change
remove_reference :orders, :order_product
end
end
|
module Merb
module GlobalHelpers
def format_datetime(datetime)
datetime.respond_to?(:strftime) ? datetime.strftime("%d.%m.%Y %H:%M") : ""
end
def human_size(size)
return "0 B" if size == 0
size = Float(size)
suffix = %w(B KB MB GB TB)
max_exp = suffix.size - 1
... |
class CreateUserInvites < ActiveRecord::Migration
def change
create_table :user_invites do |t|
t.integer :inviter_id
t.string :type
t.string :message
t.boolean :accepted
t.boolean :pending
t.integer :user_id
t.integer :campaign_id
t.timestamps
end
end
end
|
class Api::CommentsController < ApplicationController
def index
@comments = Book.find_by_url(params[:url]).comments
if @comments
render 'api/comments/index'
else
render json: ["Could not find matching "], status: 422
end
end
def create
@book = Book.find_by_url(book_url[:url])
... |
require 'spec_helper'
## Input:
# Data: subject code, sleep period #, labtime, sleep stage
# Options: min bout length == X, epoch length(if not from database data)
# The input can come from scored_epoch events as well. In that case, only the subject code need be supplied
## Output:
# 1. Sleep bouts
# 2. Wake bouts
# ... |
require 'rltk/cg/llvm'
require 'rltk/cg/module'
require 'rltk/cg/execution_engine'
require 'rltk/cg/contractor'
# tells LLVM we are using x86 arch
RLTK::CG::LLVM.init(:X86)
# include supporting library
RLTK::CG::Support.load_library('./stdlib.so')
module JS
class Contractor < RLTK::CG::Contractor
attr_reader :m... |
class AddRepresentativeToPolicyCalculations < ActiveRecord::Migration
def change
add_reference :policy_calculations, :representative, index: true
add_foreign_key :policy_calculations, :representatives
end
end
|
class CreateInsumos < ActiveRecord::Migration[5.0]
def change
create_table :insumos do |t|
t.integer :codigo
t.string :descricao
t.string :codigo_seinfra
t.references :unidade, foreign_key: true
t.timestamps
end
end
end
|
class CreatePeopleData < ActiveRecord::Migration
def change
create_table :people_data do |t|
t.hstore :values
t.references :person
t.timestamps
end
add_index :people_data, :person_id
end
end
|
class UsersController < ApplicationController
before_action :allready_logged, only: :new
def new
@user=User.new
end
def create
@user = User.new(user_params)
if @user.save
flash[:notice] = "Murlock successfully created"
redirect_to @user
else
render 'new'
end
end
def sh... |
require 'spec_helper'
describe PrivateMessenger, '#invitation' do
it 'sends the correct invitation' do
event_owner = create(:user)
invitee = create(:user)
message = :invitation
event = create(:event, owner: event_owner)
invitation = build(:invitation, event: event, invitee: invitee)
PrivateM... |
class EventsController < ApplicationController
layout 'admin'
# TOOD probably want to make this more restrictive
def checkAccess
end
def edit_remotely
@event = Event.find(params[:id])
render :update do |page|
page.replace_html("event_#{@event.id}",
:partial => "events/ev... |
class Rsvp < ApplicationRecord
self.table_name= 'rsvp'
belongs_to :user
has_many :rsvp_guests, inverse_of: :rsvp, dependent: :destroy
accepts_nested_attributes_for :rsvp_guests, allow_destroy: true, reject_if: proc { |a| a['name'].blank? }
end
|
require_relative 'util/i18n'
module Errors
class BaseError < StandardError
attr_writer :line_num
def initialize(error_message = '')
super error_message
end
end
# Dynamically define custom error classes (using anonymous class objects).
# send is used to bypass visibility on define_method, an... |
class ChangeColumnNameArticles < ActiveRecord::Migration
def change
rename_column :articles, :format, :article_format
end
end
|
class IngredientsController < ApplicationController
# GET /ingredients
# GET /ingredients.json
def index
@ingredients = Ingredient.all.sort_by { |e| e.name }
respond_to do |format|
format.html # index.html.erb
format.json { render json: @ingredients }
end
end
# GET /ingredients/1
#... |
require 'rails_helper'
describe ExerciseTask do
let(:company) { create(:company) }
let(:user) { create(:user, company: company) }
let(:track) { create(:track, company: company.reload) }
let(:exercise_task) { build(:exercise_task, track: track, reviewer: user) }
describe 'association' do
it { should belo... |
module ActionView
module Helpers
class FormBuilder
def genre_select(method, priority_or_options = {}, options = {}, html_options = {})
if Hash === priority_or_options
html_options = options
options = priority_or_options
else
options[:priority_countries] = priori... |
module Wolves
class Png
PNG_HEADER = "\x89PNG\r\n\x1A\n"
PNG_TXT = ['Title',
'Author',
'Description',
'Copyright',
'Creation Time',
'Software',
'Disclaimer',
'Warning',
'Source',
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
aws_credentials_path = File.dirname(__FILE__) + '/../aws.credentials'
aws_credentials = File.read(aws_credentials_path)
load_aws = <<SCRIPT
aws_credentials='#{aws_credentials}'
mkdir -p ~/.aws
echo "$aws_credentials" > /home/ubuntu/.aws/credentials
SCRIPT
Vagrant.configure("2"... |
module ActiveRecord::IdRegions
module Migration
def create_table(table_name, options = {})
options[:id] = :bigserial if options[:id].nil?
value = anonymous_class_with_id_regions.rails_sequence_start
super
return if options[:id] == false
set_pk_sequence!(table_name, value) unless val... |
class Trainer
attr_accessor :locations
attr_reader :name
@@all = []
###### Instance methods ######
#Initialize a trainer with a name and an array of locations
def initialize(name)
@name = name
@@all << self
end
#Return an array of all the trainer's contracts with loc... |
class Removetempfromproperties < ActiveRecord::Migration
def change
remove_column :properties, :buildingsinfotemp, :string
end
end
|
# Exercise A
stops = [ "Croy", "Cumbernauld", "Falkirk High", "Linlithgow", "Livingston", "Haymarket"]
#1 Add "Edinburgh Waverley" to the end of the array
stops.push("Edinburgh Waverley")
#2 Add "Glasgow Queen St" to the start of the array
stops.unshift("Glasgow Queen Street")
#3 Add "Polmont" at the appropriate point... |
class School < ActiveRecord::Base
has_many :ratings
has_many :features
has_many :badges
end
|
class Area < ApplicationRecord
belongs_to :state
has_many :clinicas
geocoded_by :nombre
after_validation :geocode
def display_name
" #{self.nombre}"
end
end |
class ConversationMessage < ApplicationRecord
belongs_to :author, :class_name => 'User'
belongs_to :conversation
belongs_to :author, :class_name => 'User'
after_commit { PipelineService.publish(self) }
end
|
class Admin::PropertyContactsController < ApplicationController
before_filter :authenticate_admin
before_filter :current_admin
layout 'admin'
def create
parms = {}
parms[:person_id] = params[:person_id]
parms[:property_id] = params[:property_id]
parms[:person_attr_type_id] = params[:type_id]
... |
class EpmSavedQueries < EasyPageModule
def category_name
@category_name ||= 'others'
end
def get_show_data(settings, user, page_context = {})
public, personal = Hash.new, Hash.new
queries = EasyQuery.registered_subclasses.keys.select{ |query_class| !settings['queries'] || settings['queries'].include... |
# Exercise 10: What Was That?
# https://learnrubythehardway.org/book/ex10.html
tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split\non a line."
blackslash_cat = "I'm \\ a \\ cat."
# Single quotes ' only takes \' as scape sequence
fat_cat = '''
I\'ll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Gras... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.