text stringlengths 10 2.61M |
|---|
# Generated via
# `rails generate curation_concerns:work GenericWork`
module CurationConcerns
class GenericWorkForm < Sufia::Forms::WorkForm
self.model_class = ::GenericWork
include HydraEditor::Form::Permissions
self.terms += [:resource_type]
def self.date_terms
[
:accepted,
:... |
require 'common/on_login_window'
def on_setting_window
on_login_window { click('設 定') }
with_window('環境設定-OpenDolphin') do
yield
end
end
def on_setting_window_for(name)
on_setting_window do
select(name, 'true')
yield
end
end
|
class TryesController < ApplicationController
# GET /tryes
# GET /tryes.json
def index
@tryes = Trye.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tryes }
end
end
# GET /tryes/1
# GET /tryes/1.json
def show
@trye = Trye.find(params[:id])
... |
require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Userバリデーションチェック' do
it 'nameが空欄の場合、User作成不可' do
@user = FactoryBot.build(:user, name:'')
expect(@user.valid?).to eq(false)
end
it 'name,ユニークemail,passwordを入力の場合はUser作成' do
@user = FactoryBot.create(:user)
expec... |
class Doctor < UserBase
belongs_to :medical_specialization, optional: true
validates :medical_specializations_id, presence: true
end
|
class Address < ActiveRecord::Base
geocoded_by :location
reverse_geocoded_by :latitude, :longitude do |obj,results|
if geo = results.first
obj.number = geo.street_number
obj.street = geo.route
obj.city = geo.city
obj.postal_code = geo.postal_code
obj.country =... |
class Book < ActiveRecord::Base
validates :author_id, :presence => true
validates :user_id, :presence => true
validates :title, :presence => true, :uniqueness => { :scope => :author }
validates :blurb, :presence => true
has_many :classifications , :class_name => "Classification", :foreign_key => "book_id", ... |
class CreateFoursquareData < ActiveRecord::Migration
def change
create_table :foursquare_data do |t|
t.integer :client_id
t.integer :social_network_id
t.date :start_date
t.date :end_date
t.integer :new_followers
t.integer :total_followers
t.integer :total_unlocks
t.... |
module Crud
require 'bcrypt'
#creation method
def create_hash_digest(password)
BCrypt::Password.create(password)
end
#verify method
def verify_hash_digest(password)
BCrypt::Password.new(password)
end
#hash passwords with salt tech
def create_secure_users(list_of_users)
list_of_users.each... |
class CommentSerializer < ActiveModel::Serializer
attributes :id, :user_id, :stories, :content
end
|
require 'level_object/touch_strategy/base'
require 'level_object/touch_strategy/direction'
module LevelObject
module TouchStrategy
class Mud < TouchStrategy::Base
include Direction
VELOCITY = 0.6
def after_init
self.direction = :vertical
end
def base_strategy
@bas... |
require 'spec_helper'
describe :meta_data_field_type do
before :each do
@meta_data_field_type = Factory.create(:meta_data_field_type)
end
it "Should create a valid meta data field type" do
@meta_data_field_type.should be_valid
end
end
|
class ImageUploader < AvatarUploader
#文件永久存储,项目内部路径
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
#临时文件存储,项目外部路径
def cache_dir
"/tmp/ebook_pavilion/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
#文件格式白名单
def extension_whitelist
%w(jpg ... |
class Society < ActiveRecord::Base
has_many :discounts
has_many :categories, through: :discounts
has_many :memberships
belongs_to :user
accepts_nested_attributes_for :discounts,reject_if: :all_blank,allow_destroy: true
end
|
class CreateSeriesGenres < ActiveRecord::Migration
def change
create_table :series_genres do |t|
t.integer :series_id, index: true
t.integer :genre_id, index: true
t.timestamps null: false
end
end
end
|
class AddImgUrlToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :image_url, :string, default: "profile/placeholder.png"
end
end
|
class AddOtherDetailsToOrderItems < ActiveRecord::Migration
def change
add_column :order_items, :title, :string
add_column :order_items, :name, :string
add_column :order_items, :vendor, :string
end
end
|
FactoryBot.define do
factory :post do
description { 'encontrei um cachorro na rua das flores' }
title { 'vira-lata caramelo' }
photo { 'https://www.hypeness.com.br/1/2019/09/Vira-lata_Caramelo_1.jpg'}
date { Date.new }
user { association :user }
end
end
|
class SearchController < ApplicationController
def index
@stores = Stores.all_by(search_params)
end
private
def search_params
params.permit(:zipcode)
end
end
|
class Answer < ApplicationRecord
belongs_to :user, optional: true
belongs_to :question
end
|
ELF_COUNT = INPUT.to_i
class Elf
attr_accessor :gifts, :next, :prev, :number
def initialize(number)
@number = number
@gifts = 1
@next = nil
@prev = nil
end
def take_from(elf)
@gifts += elf.gifts
elf.gifts = 0
elf.prev.next = elf.next
elf.next.prev = elf.prev
end
end
def elf... |
class Api::ReviewsController < ApplicationController
def create
@review = current_user.reviews.new(review_params)
if !(current_user.lodgings.find_by(id: params[:review][:lodging_id]) == nil)
render json: ['You cannot review your own place!'], status: :unprocessable_entity
elsif @review.save
r... |
#
# Cookbook Name:: predictionio
# Recipe:: default
#
# Copyright 2014 Makoto Kawasaki
#
# 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
#
# ... |
#!/usr/bin/env ruby
# encoding: utf-8
require 'pp'
require_relative 'busii_utils'
file = ARGV.first
position_events = extract_and_clean_machine_receives(file).map do |events|
events.keep_if { |event| event[:name].end_with?('LeadP') || event[:name].end_with?('actToolIdent') }
end.keep_if { |a| !a.empty? }.flatten.so... |
require 'rom/support/deprecations'
require 'rom/relation/class_interface'
require 'rom/pipeline'
require 'rom/mapper_registry'
require 'rom/relation/loaded'
require 'rom/relation/curried'
require 'rom/relation/composite'
require 'rom/relation/graph'
require 'rom/relation/materializable'
module ROM
# Base relation ... |
require 'rails_helper'
require 'spec_helper'
RSpec.describe ImportReadingWorker, type: :worker do
let(:thermostat) {FactoryBot.create(:thermostat)}
let(:reading_params){ FactoryBot.attributes_for(:reading) }
describe '#perform_async' do
it 'enque a reading import worker & execute it' do
expect {
... |
require 'spec_helper'
describe TextsController, :type => :controller do
render_views
describe "POST" do
before :each do
permit_with 200
request.headers['HTTP_ACCEPT'] = "application/json"
request.headers['X-API-Token'] = "incredibly-fake!"
@args = {app: "the_app", context: "t... |
class CustomerMobile < ApplicationRecord
belongs_to :mobile
belongs_to :buyer
belongs_to :seller
belongs_to :invoice
end
|
class Admin::ItemsController < Admin::AdminController
def index
@items = Item.all
end
def new
@item = Item.new
@categories = Category.all
end
def update
dao = params[:id]
item = Item.find_by_dao(dao)
if item.update(item_params)
flash[:notice] = "Item successfully updated!"
... |
# frozen_string_literal: true
RSpec.shared_context 'customerio' do
let(:customerio_client) { instance_double('Customerio::Client') }
before do
Container.stub('customerio.client', customerio_client)
end
end
|
class Gym
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def memberships
Membership.all.select {|contract| contract.gym == self}
end
def gym_members
memberships.map {|contract| contract.lifter}
end
def gym_member_na... |
require 'spec_helper'
describe Procedure, "#to_s" do
before(:each) do
@procedure = Procedure.new(:name_en => "Dickie Doo-Doo Bone Saw Extravaganza")
end
context "English" do
before(:each) do
set_english
end
it "returns its name" do
@procedure.to_s.should == "Dickie Doo-Doo Bone Saw Ex... |
module Api::V1::Customers
class NeightborhoodsController < CustomerUsersController
include Serializable
before_action :set_city
def index
neightborhoods = @city.neightborhoods
set_response(
200,
'Barrios listados exitosamente',
serialize_neightborhood(neightborhoods)
... |
require 'spec_helper'
RSpec.describe Contact, type: :model do
context 'with correct data' do
FactoryBot.factories[:contact].defined_traits.map(&:name).map(&:to_sym).each do |trait|
it "with trait #{trait}" do
expect(build(:contact, trait)).to be_valid
end
end
end
context 'with incor... |
class SubmitEventsController < ApplicationController
before_filter :require_logged_user, :only => [:new, :create]
def new
@schedule = Schedule.new
@talk = Talk.find(params[:talk_id])
@events = Event.where(:to_public => true, :accepts_submissions => true, :end_date.gte => Date.today).order_by(:start_dat... |
# encoding: utf-8
class UsersMailer < ActionMailer::Base
default :from => "\"Júlio Santos\" <hi@whoisjuliosantos.com>"
def friends_likes_email (user)
@unicorns = user.unicorns?
mail({
:to => user.email,
:subject => "#{user.name}, your friends' likes are ready!"
})
end
end
|
class CustomersController < ApplicationController
def index
customers = Customer.all.as_json(
only: [:id, :name, :registered_at, :postal_code, :phone],
methods: :movies_checked_out_count
)
render json: customers, status: :ok
end
end
|
class Exercise < ApplicationRecord
belongs_to :context
belongs_to :group, optional: true
has_many :progressions
has_many :entries, through: :progressions
def group_name
group&.name
end
end
|
describe "Main::Products" do
let(:product_attribute_groups) { double put: nil }
let(:runtime_table) { double }
let(:row) { double }
subject(:products) do
require __FILE__.sub('/spec/', '/').sub('_spec.rb', '.rb')
Main::Products.new
end
before do
stub_const "DataObjects", Class.new
stub_cons... |
require 'spec_helper'
describe TheGrid::Api::Command::BatchUpdate do
let(:table) { double(:primary_key => double(:name => 'id').as_null_object) }
let(:relation) { double(:table => table).tap{ |r| r.stub(:scoped => r, :where => r) } }
it "raise exception when items is blank" do
expect{
subject.execu... |
require File.expand_path '../../spec_helper.rb', __FILE__
describe 'Swagger endpoints' do
context '/swagger' do
let(:endpoint) { '/swagger' }
subject { get endpoint }
it 'responds with public/swagger.json' do
subject
expect(last_response).to be_ok
expect(last_response.body).to eq File.... |
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as com... |
require File.expand_path(File.dirname(__FILE__) + '/simple_spec_helper')
describe Lolita::Register do
let(:register){ Lolita::Register.new }
it "should create new" do
expect do
Lolita::Register.new
end.not_to raise_error
end
it "should set new key" do
register.set(:test, 1).should be_truthy
... |
class FavoritesController < ApplicationController
before_action :logged_in_user
def create
@micropost = Micropost.find(params[:micropost_id])
current_user.favorite(@micropost)
respond_to do |format|
format.html { redirect_to request.referrer || root_url }
fo... |
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
devise_for :users, :path => 'users', :controllers => {:registrations => "registrations", confirmations: 'confirmations'}
root to: "home#index"
get '/erreur', to: 'cache_users#error'
get '/inscription', to: 'cache_users#n... |
# frozen_string_literal: true
require 'tty-prompt'
require 'tty-font'
require 'pastel'
require 'thwait'
require './core/browser'
require './utils'
module Nostradamus
BOT_TYPE = {
video_views: 'Video Views'
}.freeze
class CLI
def initialize
@prompt = TTY::Prompt.new
@font = TTY::Font.new(:do... |
class Item < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
with_options presence: true do
validates :product_name
validates :text, length: { maximum: 1000 }
validates :price,
numericality: { only_integer: true, with: /\A[0-9]+\z/, greater_than_or_equal_to: 300,... |
class Api::V1::OnDutyFirmsController < Api::V1::ApiController
def show
organisation_on_duty = OnDutyLocator.new(
requested_time,
rota_slots_for_location
).locate
render json: { "organisation_uid" => organisation_on_duty }
end
private
def rota_slots_for_location
RotaSlot.joins(:shi... |
require 'position'
require 'lib/weapon.rb'
class Vehicle
attr_accessor :bearing, :speed, :position, :health, :fuel, :weapon_primary, :weapon_secondary
STEP_TURN = 12
STEP_MOVE = 12
def initialize(options = {})
@position = options[:position] || Position.new
@bearing = options[:bearing] || 0
end
... |
class A031435Builder
def self.a031435(n, m = 1)
(m..Float::INFINITY).find { |i| (i * Math.log(n, n + 1)).to_i < i - 1 } - 1
end
def self.sequence(seed, term)
return seed if seed[term - 1]
(seed.length + 1..term).inject(seed) { |a, i| a << a031435(i, a.last) }
end
end
class OEIS
@@a031435 = [1... |
class CreateIllustrators < ActiveRecord::Migration
def change
create_table :illustrators do |t|
t.string :firstname
t.string :lastname
t.text :about
t.timestamps
end
create_table :illustrators_items, id: false do |t|
t.belongs_to :illustrators
t.belongs_to :items
... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_time_zone
layout :layout
def set_time_zone
Time.zone = ActiveSupport::TimeZone.new('Pacific/Honolulu')
end
private
def layout
if devise_controller? && admin_signed_in?
"admin"
... |
require 'fileutils'
require 'json'
module Oyaspirateur
class Downloader
class << self
def save(folder, as = :json)
case as
when :write
mkdir_cd(folder)
when :simulate
@current_path = ::File.dirname(__FILE__)
fake_mkdir_cd(folder)
else
... |
require_relative 'test_helper'
begin
require 'tilt/radius'
# Disable radius tests for old Radius versions since it's still buggy.
# Remove when fixed upstream.
raise LoadError if Radius.version < "0.7"
describe 'tilt/radius' do
it "registered for '.radius' files" do
assert_equal Tilt::RadiusTempl... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Etd, :clean do
subject(:etd) { FactoryGirl.build(:etd) }
it_behaves_like 'a model with hyrax basic metadata', except: :keyword
it_behaves_like 'a model with ohsu core metadata'
it_behaves_like 'a model with ohsu ETD metadata'
describe 'an ... |
class Api::V1::DeviseTokenAuth::SessionsController < ::DeviseTokenAuth::SessionsController
protect_from_forgery with: :null_session, only: Proc.new { |c| c.request.format.json? }
before_action :authenticate_user!, except: [:new, :create, :validate_token]
after_action :sign_in_active_admin_user
# Prevent sessi... |
class Node
attr_accessor :leaves, :val, :parent_element
def initialize(val, per_elem)
@val = val
@parent_element = per_elem
@leaves = []
end
end
|
class Post < ApplicationRecord
include Rails.application.routes.url_helpers
LIKES_LIMIT = 3
has_one_attached :image
has_many :likes, dependent: :destroy
has_many :likers, through: :likes, source: :user
belongs_to :user
validates :caption, presence: true, length: { minimum: 3, maximum: 200 }
validates ... |
require './app'
Flaggrocrag::Application.flags.each do |flag|
raise "EXPIRED FLAG: #{flag.content} on line #{flag.lineno}" if flag.expired?
end
run Flaggrocrag::Application
|
# frozen_string_literal: true
require 'carrierwave/storage/fog'
CarrierWave.configure do |config|
if Rails.env.test? || Rails.env.development?
config.storage = :file
config.root = "#{Rails.root}/tmp"
else
config.storage = :fog
config.fog_provider = 'fog/aws'
config.fog_credentials = {
pr... |
#!/usr/bin/env ruby
require 'getoptlong'
opts = GetoptLong.new(
[ '--node', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--modulepath', '-m', GetoptLong::OPTIONAL_ARGUMENT ],
[ '--external_nodes', '-e', GetoptLong::OPTIONAL_ARGUMENT ]
)
require 'puppet'
node, external_nodes, modulepath = 'default', n... |
require File.dirname(__FILE__) + '/../test_helper'
class UserJobNotificationTest < ActiveSupport::TestCase
# Replace this with your real tests.
should_belong_to :user, :job_log
context "Create new job log and pop UserJobNotification" do
setup do
# Build a post object
@old_count = UserJobNotific... |
require "test_helper"
class TestPolygonPatternSymbolizer < Test::Unit::TestCase
def setup
@filename = "/my/file.png"
path_expression = Mapnik::PathExpression.parse("/my/file.png")
@sym = Mapnik::PolygonPatternSymbolizer.new(path_expression)
end
def test_presence
assert Mapnik::PolygonPatter... |
class CreateItems < ActiveRecord::Migration[6.0]
def change
create_table :items do |t|
t.string :name, null: false
t.string :genre_id, null: false
t.integer :place, null: false
t.text :explanation, null: f... |
require 'spec_helper'
describe Kata::DataStructures::Nodes::Graphs::Person do
describe '#display_network_breadth_first' do
context 'when graph with one node' do
subject(:person) do
described_class.new('Alice')
end
it 'displays the network' do
expect(person.display_network_bread... |
# frozen_string_literal: true
require 'common/models/base'
module Preneeds
class BranchesOfService < Common::Base
attribute :code, String
attribute :flat_full_descr, String
attribute :full_descr, String
attribute :short_descr, String
attribute :upright_full_descr, String
attribute :begin_da... |
class Library
attr_accessor :books
def initialize(input_books)
@books = input_books
end
def book_name()
return @books[title]
end
def book_info()
return @books
end
end
|
@work_spaces.each do |work_space|
json.set! work_space.id do
json.partial! 'api/work_spaces/work_space', work_space: work_space
end
end |
require_relative '../feature_helper'
feature 'User can remove files from his older answers', %q(
In order to clean the answer from wrong files
As an author
I want to be able to remove wrong files from my answer
) do
given(:author) { create :user }
given(:user) { create :user }
given(:question) { create :qu... |
require 'spec_helper'
describe Project do
let(:project){Factory(:project)}
describe "Validations" do
context "Project is valid" do
it "with all the attributes" do
project.should be_valid
end
it "without assigned employees" do
project.employees = []
project.should be_va... |
Rails.application.routes.draw do
namespace :admin do
resources :taxons do
get :children, :on => :member
end
resources :taxonomies do
resources :taxons
end
end
root :to => "admin/taxonomies#index"
end
|
# == Schema Information
#
# Table name: students
#
# id :integer not null, primary key
# school_id :integer
# first_name :string(255)
# middle_name :string(255)
# last_name :string(255)
# gender :string(255)
# date_of_birth :string(255)
# admis... |
# frozen_string_literal: true
module Events
module Preload
# This module defines no public methods.
def _; end
private
def load_registrations
@registered = Registration.includes(:payment).for_user(current_user).not_refunded
.each_with_object({}) do |reg, hash|
... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_one :user_profile, dependent: :destroy
has_many ... |
class Genre < ApplicationRecord
has_many :products, dependent: :destroy
end
|
xml.instruct!
xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.channel do
xml.title "Vancouver Job/Gigs Board"
xml.link feed_jobs_url
xml.description "Joint Vancouver Job/Gigs Board - Full Time, Part Time, Contract - Design, Development, Business/Exec"
... |
# frozen_string_literal: true
compose = ->(*fns) {
->(x) {
fns.reverse_each.reduce(x, &->(acc, fn) { fn.(acc) })
}
}
split = ->(char) { ->(str) { str.split(char) } }
downcase = ->(str) { str.downcase }
map = ->(cb) { ->(array) { array.map(&cb) } }
join = ->(char) { ->(array) { array.join(char) } }... |
class BeerSong
def verse(verse_number) # Taking the easy way out.
if verse_number == 0
return 'No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
'
elsif verse_number == 1
return '1 bottle of beer on the wall, 1 bottl... |
class Room
attr_reader :capacity
class CapacityReachedError < Exception; end
def initialize(attributes = {})
# data?
@capacity = attributes[:capacity] # integer
@patients = [] # an array of INSTANCES
end
def full?
@patients.length == capacity
end
# vip_room.add_patient(abdul)
def add_... |
class User < ActiveRecord::Base
has_secure_password
has_many :posts, dependent: :nullify
has_many :comments, dependent: :nullify
has_many :favourites, dependent: :destroy
has_many :favourited_posts, through: :favourites, source: :post
validates :first_name, presence: true
validates :last_name, presence: ... |
class Api::ProjectsController < Api::ApiController
before_action :find_project, only: [:show]
def index
@projects = Project.all
render json: @projects
end
def show
render json: @project
end
private
def find_project
@project = Project.find_by_url(params[:id]) || not_found
end
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.ssh.insert_key = false
config.vm.network "forwarded_port", guest: 5432, host: 5432
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# config.vm.network "private_n... |
# The first value here should only actually be used during testing
vault_token = data_bag_item('vault', 'tokens')[node.chef_environment]['vault']['default']
ruby_block 'renew vault token' do
block do
begin
require 'net/http'
def fetch(uri_str, vault_token, limit = 10)
raise ArgumentError, 't... |
module Refinery
class ProjectsController < ::ApplicationController
before_filter :find_all_projects, :find_page, :find_models
def index
# you can use meta fields from your model instead (e.g. browser_title)
# by swapping @page for @project in the line below:
present(@page)
end
def... |
class Api::V1::SessionAttendeesController < Api::BaseController
before_action :set_session_attendee, only: %i[show update destroy]
before_action :authenticate_user!, except: %i[index]
def index
@session_attendees = SessionAttendee.all
render json: SessionAttendeeSerializer.new(@session_attendees)
end
... |
Gem::Specification.new do |s|
s.name = 'tooth'
s.version = '0.3.0'
s.date = '2014-07-31'
s.description = 'Simple page objects for Capybara. All tooth-generated methods return Capybara Elements so that you can use these familiar objects for your needs.'
s.summary = 'Simple page objects fo... |
#!/usr/bin/env ruby
# Usage:
#
# run all test suites
#
# $ tests/run
#
# run a particular test suite
#
# $ tests/run tests/test_sequencehelpers.rb
#
# script dir
dir = File.dirname(__FILE__)
# setup load path
require 'rubygems'
$LOAD_PATH.unshift(File.join(dir, '..', 'lib'))
# user specified or glob all?
fil... |
class SearchController < ApplicationController
def new
@page_title = "Search Rubyocracy"
end
def create
query = params[:query]
# Handle invalid queries
if query.blank?
redirect_to search_path
return false
end
@page_title = "Search results for #{query}"
@scope ... |
class Project < ApplicationRecord
mount_uploader :thumb, ImageUploader
has_many :photos, -> { order('sorting asc') }, dependent: :destroy, inverse_of: :project
accepts_nested_attributes_for :photos
end
|
# frozen_string_literal: true
FactoryBot.define do
factory :user do
to_create(&:save)
email { FFaker::Internet.unique.email }
first_name { FFaker::Name.first_name }
last_name { FFaker::Name.last_name }
avatar { fixture_file_upload('spec/fixtures/files/image.png', 'image/png') }
password { FF... |
#!/usr/bin/env ruby
# Dezoomify. See README.markdown.
# By Henrik Nyh <http://henrik.nyh.se> 2009-02-06 under the MIT License.
require 'cgi'
require 'open-uri'
require 'rubygems'
require 'nokogiri'
module Kernel
def windows?
RbConfig::CONFIG['host_os'].match(/mswin|windows|mingw/i)
end
end
if windows?
# Ca... |
# encoding: utf-8
module ActiverecordDIY
module VERSION
version = {}
File.read(File.join(File.dirname(__FILE__), '../', 'VERSION')).each_line do |line|
type, value = line.chomp.split(":")
next if type =~ /^ +$/ || value =~ /^ +$/
version[type] = value
end
MAJOR = version['major']
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.define "app" do |app|
app.vm.box = "ubuntu/trusty64"
app.vm.synced_folder "../api", "/var/www/api", type: "nfs"
app.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = "1024"
end
app.vm.network ... |
module Ai
class Grid
attr_reader :data, :size
def initialize size = Size
@size = size
@data = Array.new size do
Array.new size
end
end
def each
@size.times do |x|
@size.times do |y|
yield x, y, @data[x][y]
end
end
end
def empty
@data = Array.new @size do
Array.new ... |
# frozen_string_literal: true
# Helper methods for the DoctorsController and Doctors views
module DoctorsHelper
def doctor_has_appointments?(doctor)
return false if doctor.appointments.count.zero?
true
end
def reassign_appointments(doctor)
appointments = doctor.appointments
admin = Doctor.fetch_... |
class AddBulkDescriptionToIngredient < ActiveRecord::Migration
def change
add_column :ingredients, :bulk_description, :boolean, :default => true
end
end
|
require 'rails_helper'
describe Product do
describe 'associations' do
it { should have_one(:image) }
end
end
|
class Post < ApplicationRecord
validates :title, presence: true, length: {maximum: 50}
validates :body, presence: true
belongs_to :user
has_many :comments
end
|
before_all do
xcversion(version: "~> 9")
clear_derived_data
end
lane :test do |options|
cocoapods(podfile: 'Example/Podfile', try_repo_update_on_error: true)
podname=sh('pod ipc spec ../UpdateCenter.podspec | python -c \'import json,sys,sets;obj=json.load(sys.stdin);print(obj["name"])\'|tr -d \'\n\'')
scan(
... |
class Pic < ActiveRecord::Base
validates :user_id, presence: true
validates :public_id, presence: true
validates :public_id, uniqueness: true
belongs_to :user,
primary_key: :id,
foreign_key: :user_id,
class_name: "User"
has_many :comments,
primary_key: :id,
foreign_key: :pic_id,
class_name: "C... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.