text stringlengths 10 2.61M |
|---|
# 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 bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... |
require_relative '../config/environment'
def run
Application.welcome
user = Application.get_pilot
input = ''
Application.help
while input
input = gets.chomp.downcase
case input
when 'help'
system('clear')
Application.help
when 'all airports'
system('clear')... |
# PLEASE READ THIS BEFORE EDITING.
# WARNING - If adding a new pod, please check to see if it causes an issue and correct this in the configure_pods section at the bottom!
# See the confluence guide for more details - https://poqcommerce.atlassian.net/wiki/spaces/EN/pages/311492863/Cocoapods+Implementation
def bag_pod... |
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
describe "OptionsHash!(hash)" do
before(:each) do
@h = {"a" => "string", :b => "sym"}
@oh = OptionsHash!(@h)
end
it { @oh.object_id.should == @h.object_id }
it { @h.should be_kind_of(OptionsHash) }
it { @h.should respond... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :current_user, :logged_in?
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
def logged_in?
!!current_user
end
def require_user
if !logged_in?
... |
class AddSpecificsToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :work_place, :string
add_column :users, :profession, :string
add_column :users, :degree, :string
end
end
|
class Quiz < ActiveRecord::Base
has_many :questions, :dependent => :destroy
validates :title, :category, :description, presence: true
validates :title, :category, :description, length: {minimum: 3, maximum: 254, too_short: "must have at least %{count} words", too_long: "must have at most %{count} words"}
# Tot... |
class User < ApplicationRecord
has_many :sessions, dependent: :destroy
attr_accessor :password, :password_confirmation
validates :email, uniqueness: { case_sensitive: false, message: 'This email address is already registered.'},
format: { with: /.*\@.*\..*/, message: 'is incorrect'},
... |
module Fog
module Terremark
class Real
# Get list of organizations
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# * 'description'<~String> - Description of organization
# * 'links'<~Array> - An array of links to entities in the organizatio... |
json.array!(@cotizacions) do |cotizacion|
json.extract! cotizacion, :id, :name, :surename, :email, :landline_phone, :mobile_phone, :quotation_details
json.url cotizacion_url(cotizacion, format: :json)
end
|
class BlendsController < ApplicationController
before_action :set_blend, only: [:show, :edit, :update, :destroy]
# GET /blends
# GET /blends.json
def index
@blends = Blend.all
end
# GET /blends/1
# GET /blends/1.json
def show
end
# GET /blends/new
def new
@blend = Blend.new
end
#... |
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Shared
class Caser
REGEX = /./
class << self
def upcase(string)
string.gsub(REGEX, uppercasing_hash)
end
def downcase(string)
string.gs... |
class AddQType < ActiveRecord::Migration[5.1]
def change
add_column :questions, :qno, :integer
add_column :questions, :type, :string
end
end
|
require 'spec_helper'
describe PagesController do
render_views
describe "when not logged in" do
it "should redirect to the login page" do
controller.user_signed_in?.should be_false
get 'home'
response.should redirect_to(:action=>"new", :controller=>"devise/sessions")
end
end
descri... |
#
# Cookbook Name:: bcpc-hadoop
# Recipe:: zookeeper_packages
#
# Copyright 2017, Bloomberg Finance L.P.
#
# 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/LIC... |
require 'test_helper'
class PaymentsApiPaymentsTest < Minitest::Test
def test_create_payment
payment = VCR.use_cassette('payments_api/create_payment', record: :none) do
unity_client.payments.create_payment(
merchant_ref_num: random_id,
payment_handle_token: 'SSbLhbXLFnMksSAL',
amou... |
XmlTest::Application.routes.draw do
resources :agents
match 'agent_property/:id/property' => 'agent_properties#show', :as => :property
match 'xml_with_error' => 'agent_properties#xml_errors', :as => :xml_with_errors
root :to => 'agents#index'
end
|
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu1804"
config.vm.box_check_update = false
config.vm.synced_folder "data", "/vagrant_data"
config.vm.define "default", primary: true do |default|
default.vm.hostname = 'jenkins'
default.vm.network "forwarded_port", guest: 8080, host:9090
... |
class CommentService
def initialize(user, notify = true)
@user = user
@notify = notify
end
def comment(commentable, content, url, subscribers=[])
url = nil if url && !url.starts_with?('http:', 'https:')
return if [content.presence, url.presence].compact.empty?
comment = Comment.create!(:comme... |
class CreateProvenances < ActiveRecord::Migration
def change
create_table :provenances do |t|
t.string :name
t.timestamps null: false
end
Provenance.create([
{ name: 'Nacional' },
{ name: 'Importado' }
])
end
end
|
class Lecture
attr_reader :title, :duration, :video_key
def initialize(attrs)
@title = attrs[:title]
@duration = attrs[:duration].to_i
@video_key = attrs[:video_key]
end
end
|
module Fluent
class RedshiftOutput < BufferedOutput
Fluent::Plugin.register_output('redshift_anton', self)
# ignore load table error. (invalid data format)
IGNORE_REDSHIFT_ERROR_REGEXP = /^ERROR: Load into table '[^']+' failed\./
def initialize
super
require 'aws-sdk'
require 'zlib'
require... |
require 'rails_helper'
RSpec.describe Category, type: :model do
describe 'Test for category model' do
context 'Create Category without name' do
it "It's hard to Validation" do
category = Category.new(name: '')
expect(category).not_to be_valid
... |
require 'BasicConstraint'
class BooleanAmenitiesConstraint < BasicConstraint
cattr_reader :LABEL_DINING_TABLE, :LABEL_FRIDGE, :LABEL_SOFA, :LABEL_GAS_PIPE, :LABEL_STOVE,
:LABEL_GYM, :LABEL_SWIMMING_POOL, :LABEL_LIFT, :LABEL_WASHING_MACHINE, :LABEL_MICROWAVE,
:LABEL_SERVENT_ROOM, :LABEL_SUBMIT_BU... |
# encoding: UTF-8
class Dialog_new_map < Wx::Dialog
class New_map_panel < Wx::Panel
#--------------------------------------------------------------------------------------------------------------------------------
# initialize
#-------------------------------------------------------------------------------... |
########################################################
# Defines the main methods that are necessary to split Nextera long mate pair reads
########################################################
class PluginMatePairs < Plugin
#Returns an array with the errors due to parameters are missing
def check_params
... |
# frozen_string_literal: true
# {
# "id":2,
# "branch_id":4,
# "name":"Ye Olde Commons",
# "address":"120 Northside Rd",
# "state":"MA",
# "zip_code":1507,
# "address2":"",
# "city":""
# }
module Importers
class Locations < Importer
self.path = :locations
BLACKLIST = [8].freeze
def hash... |
require 'test_helper'
class WholesaleTest < ActiveSupport::TestCase
def setup
@john = publishers(:john)
end
test 'Wholesale sales named fixtures and STI' do
assert_equal 10, @john.sales.count
assert_equal 3, @john.whole_sales.count
end
end
|
# If you want to add custom tile properties to your game you can use this class.
# Make sure to ALWAYS derive from Tile to get the integration working.
# Certain attributes like animations and the solidity are implemented in the base class.
module SDC
class CustomTile < SDC::Tile
def at_init
end
def initiali... |
module Kaseya
class Response
attr_reader :code, :status, :error, :result
delegate_missing_to :@result
def initialize(response)
@code = response["ResponseCode"]
@status = response["Status"]
@error = response["Error"]
@result = Result.new(response["Result"])
end
def error?... |
class PantStyle < ActiveEnum::Base
value :id => 1,
:name => 'Contemporary'
value :id => 2,
:name => 'Relaxed'
value :id => 3,
:name => 'Trend'
value :id => 4,
:name => 'Surf and Skate'
value :id => 5,
:name => 'Other'
end |
require "coveralls"
Coveralls.wear!
require "bundler/setup"
require "stanford_corenlp_xml_adapter"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
c... |
class CreateAdverts < ActiveRecord::Migration
def change
create_table :adverts do |t|
t.text :content
t.decimal :rent
t.integer :user_id
t.date :expiration_date
t.integer :property_id
t.integer :nb_of_free_beds
t.timestamps
end
end
end
|
class StatesController < ApplicationController
def show
state = State.where(acronym: params[:acronym]).first
respond_to do |format|
format.json { render json: state }
end
end
end
|
require 'rails_helper'
RSpec.describe CheckIn, type: :model do
#escribe CheckIn do
# describe 'validations' do
# subject(:event) { CheckIn.new } # sets the subject of this describe block
# before { event.valid? } # runs a precondition for the test/show
# [:title, :... |
class PasswordResetController < ApplicationController
def new
end
def create
@user = User.find_by(email: password_reset_params[:email])
if @user
UserResetPasswordMailer.send_password_reset_email(@user).deliver
flash[:success] = 'Password reset link sent'
redirect_to('/')
else
... |
# == Schema Information
#
# Table name: blankets
#
# created_at :datetime
# id :integer not null, primary key
# unit_id :integer
# updated_at :datetime
#
class Blanket < ActiveRecord::Base
belongs_to :unit, :inverse_of => :blankets
has_many :hubs, :inverse_of => :blanket
validates :unit... |
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
helper_method :current_user
def index
@best_seller = Order.best_seller_product_pic.take(5)
@mainposter = Po... |
class User < ApplicationRecord
has_many :favorites
has_many :palettes, through: :favorites
validates :username, uniqueness: true
# validates :password, presence: true, on: :create
# validates :password_confirmation, presence: true, on: :create
has_secure_password
end
|
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_user
def current_user
@user ||= User.find_by_uuid(cookies[:auth_token])
end
helper_method :current_user
private
def set_user
if cookies[:auth_token].blank? || !User.exists?(uuid: cookie... |
Pod::Spec.new do |s|
s.name = "PennyPincher"
s.version = "0.0.1"
s.summary = "PennyPincher is a fast template-based gesture recognizer, developed by Eugene Taranta and Joseph LaViola"
s.homepage = "https://github.com/wilthink/PennyPincher"
s.license = { :type => "Apache License, Version 2.0", :file => "LICENS... |
class Album < ActiveRecord::Base
validates :title, :description, :presence => true
has_many :photos
def destroy
# ensure we physically delete each photo's image
photos.each do |photo|
photo.destroy
end
super
end
end
|
require_relative './game'
require_relative './board'
# class responsible for the character representations and their movements
class Character
def initialize (symbol, color, position, board)
@symbol = symbol
@color = color
@position = position
@board = board
@moved = true
end
def to_array
... |
# return a new array containing the same sub arrays
# but ordered logically
# taking into considertation the odd numbers only
arr = [[1, 6, 7], [1, 4, 9], [1, 8, 3]]
# [[1, 8, 3], [1, 6, 7], [1, 4, 9]]
a = arr.sort_by do |sub|
sub.select do |v|
v.odd?
end
end
p a |
class AddRecintoToGastospropiedad < ActiveRecord::Migration[5.1]
def change
add_reference :gastospropiedads, :recinto, foreign_key: true
end
end
|
# frozen_string_literal: true
class Homework < ApplicationRecord
belongs_to :lesson
belongs_to :student
has_one_attached :homework_file
has_one :review
end
|
class Goal < ActiveRecord::Base
# Associations
belongs_to :appearance
end
|
class Url < ApplicationRecord
def self.resolve url
original_url = url
get_response_cookie = nil
static_headers = {"User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36", "Accept" => "*/*", "Accept-Encoding" => "plain"}
... |
class Lobby < ApplicationRecord
has_many :messages
validates :name, presence: true, length: { in: 2..32 }
end
|
require 'rails_helper'
RSpec.describe ArraysController, type: :controller do
describe "GET index" do
it "has a 200 status code" do
get :index
expect(response.code).to eq("200")
end
it "creates a flattened_x variables as arrays" do
get :index
expect(assigns(:flattened_1)).to ... |
class TwitterDownloader
class << self
@@last_tweet = 0;
def twitter_name
"@kuwest"
end
def sync
tweets = unprocessed_tweets
tweets.each do |tweet|
parse tweet
end
store_last_tweet tweets
end
def store_last_tweet (tweets)
setting = Settings.f... |
class FinanceFeeDiscount < ActiveRecord::Base
belongs_to :finance_fee_particular
belongs_to :finance_fee
belongs_to :fee_discount
end
|
class CsvUserImporter
attr_accessor :first_name_col, :last_name_col, :email_col
def initialize(csv_path, client)
@csv = CSV.read(csv_path, headers: true)
@client = client
headers = @csv.headers()
self.first_name_col = headers.find {|h| h.downcase.include? "first"}
self.last_name_col = headers.f... |
require 'test_helper'
class RxesControllerTest < ActionDispatch::IntegrationTest
setup do
@rx = rxes(:one)
end
test "should get index" do
get rxes_url
assert_response :success
end
test "should get new" do
get new_rx_url
assert_response :success
end
test "should create rx" do
as... |
class CreateMedicinePrescriptInternals < ActiveRecord::Migration[5.0]
def change
create_table :medicine_prescript_internals do |t|
t.references :station, foreign_key: true
t.string :code
t.integer :customer_id
t.integer :employee_id
t.integer :result_id
t.string :number_id
... |
class CreateUIStates < ActiveRecord::Migration
def change
create_table :ui_states do |t|
t.string :component, null: false
t.references :user, null: false
t.text :state
end
add_index :ui_states, :user_id
add_index :ui_states, [:user_id, :component], unique: true
end
end
|
require 'spec_helper'
describe Game do
let(:game) { Game.new }
describe ".new" do
it "creates a new Game and sets the number of players" do
Game.any_instance.stub(:gets).and_return(2)
expect(game).to be_an_instance_of Game
expect(game.number_of_players).to eq(2)
end
end
describe "... |
require 'spec_helper'
require 'support/data/query_category_data'
require 'support/data/query_date_data'
require 'support/data/query_type_data'
describe BankStatements::InMemoryQuery do
describe '#query' do
context 'transaction categories' do
describe 'no category is specified' do
it 'returns all da... |
require 'rails_helper'
RSpec.describe Newsletter, type: :model do
let(:newsletter) { FactoryBot.create(:newsletter) }
it 'has a valid factory' do
expect(newsletter).to be_valid
end
describe 'validations' do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:content) }
... |
require 'rails_helper'
RSpec.describe ReviewsController, type: :routing do
describe "GET /categories/:category_id/systems/:system_id/reviews" do
let(:category) { create(:category) }
let(:system) { create(:system) }
it "should route to reviews#index" do
route = "/categories/#{category.to_param}/syst... |
# frozen_string_literal: true
require 'spec_helper'
require 'darlingtonia/streams/formatted_message_stream'
describe Darlingtonia::FormattedMessageStream do
subject(:stream) { described_class.new(stream: fake_stream) }
let(:fake_stream) { [] }
it_behaves_like 'a Darlingtonia::MessageStream'
describe ... |
class Api::V1::CopOutsController < ApplicationController
before_action :set_student, only: [:create, :update]
def create
@student.cop_out = @student.create_cop_out(cop_out_params)
render json: { status: 200 }
end
def update
if @student.cop_out.update_attributes(cop_out_params)
render json: ... |
require 'aws-sdk'
module DCell
module Registry
class S3Adapter
def initialize(options)
# Convert all options to symbols :/
options = options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
@env = options[:env] || 'production'
bucket = options[:bucket] || "dcell_#{Celluloid.uuid... |
require 'rails_helper'
describe 'POST /v1/tokens' do
it 'creates a token for the user', vcr: { cassette_name: 'facebook_valid_token' } do
post '/v1/tokens', {
uid: '10153057521702250',
auth_token: 'good-token',
first_name: 'Jeff',
last_name: 'Fisher',
email: 'im4ussoccer@yahoo.com'... |
class ChangeDefaultExerciseTime < ActiveRecord::Migration[5.2]
def change
change_column_default(:exercises, :time_by_minutes, 1)
end
end
|
class Triangle
attr_reader :x, :y, :z
def initialize(x,y,z)
@x = x
@y = y
@z = z
end
def kind
triangle?
if x == y && y == z
:equilateral
elsif x == y || x == z || y == z
:isosceles
else
:scalene
end
end
def triangle?
if x > 0 && y > 0 && z > 0 && x + y... |
Rails.application.routes.draw do
scope :api do
scope :v1 do
resources :websites, only: [:index, :show], format: :json do
get :extract_content, on: :collection
end
end
end
end
|
require 'tdd'
require 'towers_of_hanoi'
describe Array do
describe "#my_uniq" do
subject(:array) { [1, 2, 2, 3, 4, 4] }
it "removes duplicates from an array" do
expect(array.my_uniq).to match_array(array.uniq)
end
it "does not call Array#uniq" do
expect(array).not_to receive(:uniq)
... |
Sinatra.autoload :Flash, "sinatra/flash"
module Shoperb module Theme module Editor
module Mounter
class Server
module Defaults
module Helpers
def default_locals locals={}
set_pagination_defaults
request.define_singleton_method(:query_parameters) do
... |
module CurrencyHistoriesHelper
require 'net/http'
require 'uri'
require 'openssl'
require 'json'
def get_currencies(url)
uri = URI.parse(url)
request = Net::HTTP::Get.new(uri)
req_options = {
use_ssl: uri.scheme == "https",
verify_mode: OpenSSL::SSL::VERIFY_NONE,
}
response = Net::HTTP.start(uri... |
require 'spec_helper'
describe LawyerCasesPermission do
describe "#can_read?" do
before(:each) do
@lawyer = build(:lawyer)
@law_case = @lawyer.init_case(1234)
end
it "should return true if the permission is full_access and the target has the case" do
lawyer_cases_permission = build(:... |
# frozen_string_literal: true
class AdMediaController < ApplicationController
before_action :set_ad_medium, only: %i[edit update destroy]
before_action :not_accessible_different_company_data, only: %i[edit update destroy]
before_action :not_accessible_except_to_grader, only: %i[new edit update destroy]
before_... |
module Byebug
#
# Reopens the +var+ command to define the +const+ subcommand
#
class VarCommand < Command
#
# Shows constants
#
class ConstSubcommand < Command
def regexp
/^\s* c(?:onst)? (?:\s+ (.+))? \s*$/x
end
def execute
str_obj = @match[1] || 'self.class'
... |
class AddWinToBet < ActiveRecord::Migration[5.1]
def change
add_column :bets, :win, :boolean
end
end
|
require 'spec_helper'
require 'date'
describe BankAccount do
it 'returns transactions' do
transaction1 = double('transaction', purchase_date: Date.today)
transaction2 = double('transaction', purchase_date: Date.today)
transaction3 = double('transaction', purchase_date: Date.today.next_day)
bank_acco... |
Given 'a "$project" git repository' do |project|
fixture_repo = File.join(@prodder_root, 'features', 'support', "#{project}.git")
unless File.directory? fixture_repo
raise "Cannot initialize repo for project #{project}; expected fixture at: #{fixture_repo}"
end
run_simple "mkdir -p repos"
if File.exist? ... |
class Investor < ActiveRecord::Base
belongs_to :forecast
has_many :investments
has_one :account, as: :entity, dependent: :destroy
end
|
# frozen_string_literal: true
# Robot class to run under multiplexing infrastructure
module Robots
module DorRepo
module Release
# Sends updated metadata to PURL. Specifically stuff in identityMetadata
class ReleasePublish < LyberCore::Robot
def initialize
super('releaseWF', 'releas... |
require 'test_helper'
class VenueUsersControllerTest < ActionController::TestCase
setup do
@venue_user = venue_users(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:venue_users)
end
test "should get new" do
get :new
assert_response :s... |
class CourseClass < AbstractModel
belongs_to :course
belongs_to :location
has_many :study_guides
accepts_nested_attributes_for :study_guides, :allow_destroy => true
has_many :live_class_dates
accepts_nested_attributes_for :live_class_dates, :allow_destroy => true
has_many :test_questions, :for... |
describe "ProductListPage" do
let(:products) { double }
subject(:product_list_page) do
require __FILE__.sub("/spec/", "/").sub("_spec.rb", ".rb")
ProductListPage.new
end
def load_prepare_fakes
products.should_receive(:load_from_db)
.with attribute_group: :list, order: :last, limit: 10
end
... |
class CreateUsedTimes < ActiveRecord::Migration
def change
create_table :used_times do |t|
t.integer :otdel_id
t.float :seconds
t.integer :user_id
t.integer :ut_type_id
t.integer :task_id
t.timestamps null: false
end
end
end
|
class FontBarlowCondensed < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/barlowcondensed"
desc "Barlow Condensed"
homepage "https://fonts.google.com/specimen/Barlow+Condensed"
def install
(share/"fonts").install "BarlowCondensed-Bla... |
#require 'rubygems'
#gem 'mongoid' , '=2.5.1'
require 'mongoid'
require 'mongo'
#Configure MongoDB block
configure do
Mongoid.configure do |config|
# Mongoid
name = "mongocloud-db"
host = "localhost"
config.master = Mongo::Connection.new.db(name)
end
end
helpers do
def print(text)
... |
module MDML
class FileSystem
attr_accessor :root
def initialize(root)
@root = root
end
def full_path(template_path)
pattern = '%s.mdml'
raise FileSystemError, "Illegal template name '#{template_path}'" unless template_path =~ /\A[^.\/][a-zA-Z0-9_\/]+\z/
full_path = if t... |
require 'json'
module ConsulDo
class Elect
def initialize()
yield ConsulDo.configure! if block_given?
end
def base_url
"http://#{ConsulDo.config.host}:#{ConsulDo.config.port}"
end
def get_key
url = "#{base_url}/v1/kv/service/#{ConsulDo.config.key}/leader?" + token_str
r... |
#!/usr/bin/env ruby
# :title: PlanR::Plugin::Specification::Ident
=begin rdoc
Specification for file and data ident plugins
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
require 'tg/plugin'
require 'plan-r/datatype/ident'
module PlanR
module Plugins
module Spec
# Input: a string conta... |
class Github
include Mongoid::Document
include Mongoid::Timestamps
field :commit_url, type: String
field :commit_time, type: DateTime
validates :commit_url, presence: true
validates :commit_time, presence: true
scope :last_month, -> { where(created_at: (30.days.ago..Time.now)) }
scope :last_yea... |
# lib/puppet/type/rbac_user.rb
Puppet::Type.newtype(:rbac_user) do
desc <<-EOT
Manages RBAC users for Puppet Enterprise
EOT
ensurable do
defaultvalues
defaultto :present
end
newparam(:name) do
desc "The user"
end
newparam(:password) do
desc "RBAC user's password"
end
newproper... |
require './lib/card'
require './lib/turn'
require './lib/deck'
require './lib/round'
RSpec.describe Round do
it 'exists' do
card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography)
card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which ... |
class User < ActiveRecord::Base
# has_attached_file :image styles: { large: "700x700", medium: "300x300>", thumb: "125x125>" }
# validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
has_many :rentals
has_many :subleases
# Include default devise modules. Others available are:
# :conf... |
class AddEmailToOrders < ActiveRecord::Migration
def change
add_column :orders, :email, :string
add_index :orders, :email
end
end
|
module RunPal
class Challenge < Entity
attr_accessor :id, :name, :sender_id, :recipient_id, :post_id, :state, :notes
validates_presence_of :name, :sender_id, :recipient_id
# sender_id and recipient_id refer to the ids of the sending and
# receiving circles, not to admins of said circles
# A chall... |
class Raindrops
CONVERSION_STRING = {
3 => "Pling",
5 => "Plang",
7 => "Plong"
}
def self.convert(number)
return "1" if number == 1
factors = []
divisor = 2
dividend = number
while dividend != 1
if dividend % divisor == 0
dividend /= divisor
factors.push(divisor)
... |
require 'dank'
require 'spec_helper'
describe 'Dank' do
describe 'module functions' do
describe 'we can add tags ' do
before do
Dank.add 'turtles'
Dank.add 'ninjas'
Dank.add 'traps'
end
subject{Dank.redis.zrange 'dank:tags', 0, -1}
it do
subject.should ==... |
class InvitesController < ApplicationController
def create
@plan = Plan.find(params[:plan_id])
@invite = Invite.new(invite_params)
@invite.plan = @plan
if @invite.save
redirect_to user_path(current_user), notice: "#{@invite.user.first_name} was added to your plan"
else
redirect_to user... |
require 'puppet-lint'
require_relative 'rules/rule'
require_relative 'rules/hard_coded_credentials_rule'
require_relative 'rules/no_http_rule'
require_relative 'rules/admin_by_default_rule'
require_relative 'rules/empty_password_rule'
require_relative 'rules/invalid_ip_addr_binding_rule'
require_relative 'rules/suspici... |
class AddDateTimesToGoalSession < ActiveRecord::Migration
def change
add_column :goal_sessions, :user_start_at, :datetime
add_column :goal_sessions, :user_completed_at, :datetime
add_column :goal_sessions, :remind_user_at, :datetime
end
end
|
#!/usr/bin/env ruby
require 'json'
require 'vanagon/extensions/ostruct/json'
require 'vanagon/extensions/set/json'
require 'vanagon/extensions/hashable'
load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <plat... |
class KpcsController < ApplicationController
before_action :set_kpc, only: [:show, :edit, :update, :destroy]
before_filter :authenticate_user!
respond_to :html
def index
@kpcs = Kpc.all
respond_with(@kpcs)
end
def show
respond_with(@kpc)
end
def new
@kpc = Kpc.new
respond_with(@k... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.