text stringlengths 10 2.61M |
|---|
# require 'faker'
# 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 th... |
=begin
You are given the following information, but you may prefer to do some research for yourself.
1 Jan 1900 was a Monday.
Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on leap years, twenty-nine.
A leap year occu... |
# See Listing 10.25
class OccupationsController < ApplicationController
# See Listing 10.46
before_action :signed_in_user, only: [:create, :destroy]
before_action :correct_user, only: :destroy
# See Lisiting 9.23
def index
# Simple Search Form. See http://railscasts.com/episodes/37-simple-search-form.
... |
ActiveAdmin.register OfficialDoc do
menu :parent => "My Documents"
permit_params :file, :type, :name, :user_id
index do
selectable_column
@index = 30 * (((params[:page] || 1).to_i) - 1) # 30 needs to set to that what your page size is
column :no do
@index += 1
end
column :name
colu... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Tikkie::Notifications::PaymentNotification do
subject(:notification) { described_class.new(body) }
let(:body) { JSON.parse(File.read('spec/fixtures/notifications/payment.json'), symbolize_names: true) }
describe '#subscription_id' do
it 'r... |
class Node
attr_reader :data
attr_accessor :link
def initialize(data)
@data = data
end
# def link
# @link
# end
# def link=(node)
# @link = node
# end
end
|
class AddColumnsToUsers < ActiveRecord::Migration
def change
add_column :joh_users, :provider, :string
add_column :joh_users, :uid, :string
add_column :joh_users, :name, :string
end
end
|
class Figure < ActiveRecord::Base
has_many :landmarks
has_many :figure_titles
has_many :titles, :through => :figure_titles
# def initialize(name)
# @name = name
# end
end |
# frozen_string_literal: true
class ModSignupsController < ApplicationController
before_action :authenticate_as_local_guide_with_mod_manager_privilege!, only: :kick
after_action :log_event, only: %i[kick], if: -> { response.successful? }
def update
render_as_json do
event_attendee.mods << mod
mo... |
=begin
Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
OpenAPI spec version: 1... |
require_relative '../types/function_type'
class Function
attr_reader :params, :body
def initialize(params, body)
@params = params
@body = body
end
def eval(_)
self
end
def call(arg_values, env)
call_env = Environment.new(parent: env)
params.each.with_index do |param, idx|
call... |
class Site::StaticController < ApplicationController
def show
@page_name = params[:page_name].to_s.gsub(/\W/,'')
unless partial_exists?(@page_name)
render 'missing', :status => 404
end
end
private
def partial_exists?(partial)
Site::ValidPartials.include?(partial)
end
def self.find_p... |
class Comment < ActiveRecord::Base
belongs_to :user, foreign_key: :user_id
belongs_to :discussion
end
|
class Event < ActiveRecord::Base
belongs_to :club
belongs_to :user
validates_presence_of :start, :finish, :club_id, :location, :name, :description
validates_length_of :name, :maximum => 40
validates_length_of :link, :maximum => 255
validates_length_of :description, :maxim... |
class ArticlesController < ApplicationController
skip_before_action :authenticate_user!, only: [ :index, :show ]
before_action :set_article, only: [ :show, :edit, :update ]
def index
@articles = Article.all
end
def show
@initials = set_initials(@article.author.username)
end
def new
@article... |
class SwitchCommentsToPolymorphic < ActiveRecord::Migration
def self.up
rename_column :comments, :content_id, :commentable_id
add_column :comments, :commentable_type, :string
add_index :comments, [:commentable_type, :commentable_id]
Comment.all.each do |comment|
comment.commentable_type = 'C... |
class Calculator
attr_accessor :accumulator
def add(num)
@accumulator += num
end
def subtract(num)
@accumulator -= num
end
def multiply(num)
@accumulator *= num
end
def divide(num)
@accumulator /= num
end
end |
require 'test_helper'
class ClassesTimetablesControllerTest < ActionDispatch::IntegrationTest
setup do
@classes_timetable = classes_timetables(:one)
end
test "should get index" do
get classes_timetables_url
assert_response :success
end
test "should get new" do
get new_classes_timetable_url
... |
# Created by Ing. Tatioti Mbogning Raoul(tatiotir@gmail.com, tatioti.raoul@gmail.com)
class RefreshTokenResult
attr_accessor :error, :token, :statusCode
def initialize(token, error, statusCode)
@token, @error, @statusCode = token, error, statusCode
end
end |
class Post < ApplicationRecord
belongs_to :user
validates :title, presence: true, length: {in: 3..30}
validates :content, presence: true, length: {in: 20..500}
def author
User.find_by(id: self.user_id).name
end
end
|
class LRUCache
attr_reader :max
def initialize(size)
@max = size
@queue = []
end
def count
queue.length
end
def add(el)
if queue.include?(el)
self.queue = reset_item(el)
else
queue.shift if queue.length >= max
queue << el
end
end
def show
print queue
... |
class StatusesController < ApplicationController
def new
@status = Status.new
end
def create
@status = Status.new(status_params)
if @status.save
flash[:notice] = "Status is created successfully."
redirect_to @status
else
flash[:alert] = "Error creating status."
render 'new'
end
end
def edit... |
GitHumungus::Application.routes.draw do
root :to => "index#home"
resources :templates do
resources :workouts
end
resources :workouts
resources :exercises
resources :users
resources :sessions, only: [:new, :create, :destroy]
match '/signup', to: 'users#new'
match '/login', to: 'sessions#n... |
require 'spec_helper'
require 'shanty/task_set'
RSpec.describe(Shanty::TaskSet) do
include_context('with tmp shanty')
subject(:task_set) { test_plugin.new(env, graph) }
let(:env) { double('env') }
let(:graph) { double('graph') }
let(:test_plugin) do
Class.new(described_class) do
desc 'foo [--cat ... |
# My first solution commented out below.
class SumOfMultiples
attr_reader :multiples
def self.to(num)
SumOfMultiples.new().to(num)
end
def initialize(*multiples)
@multiples = !multiples.empty? ? multiples : [3, 5]
end
def to(num)
(1...num).select do |n|
any_multiples?(n)
end.sum
... |
class Api::HeartRatesController < ApplicationController
before_filter :get_heart_rate, except: [:show, :update, :destroy]
def index
heart_rate = HeartRate.select('MAX(rate) as rate, MAX(updated_at) as updated_at').group("date(updated_at)").last(7)
return render :json => {:data => heart_rate.collect(&:rate)... |
class MediaController < ApplicationController
before_action :check_login_status, only: [:index, :create]
# GET /media
def index
@medium = Medium.order(:id)
end
# GET /media/upload
def index_upload
end
# POST /media/upload
def create_upload
media = Medium.new(media_params)
media.save!
... |
class Song < ActiveRecord::Base
# add associations here
belongs_to :artist
belongs_to :genre
has_many :notes
### some high-power Rails magic
# accepts_nested_attributes_for lets us create multiple Notes when creating a
# Song. That's pretty awesome.
# However we can define a proc (a small in-line meth... |
require 'rails_helper'
RSpec.feature "Events", type: :feature do
before(:each) do
@user = User.create(email: 'a@a.com', name: 'A Test', password: '1234')
@venue1 = Venue.create!(name: "Da lat")
@category1 = Category.create!(name: "Entertainment")
@event1 = Event.create!(name: "Event 1", extended_html... |
name "bamboo"
maintainer "Brian Flad"
maintainer_email "bflad@wharton.upenn.edu"
license "Apache 2.0"
description "Installs/Configures Atlassian bamboo"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.7.0"
recipe "bamboo", "I... |
require 'helper_frank'
module Rdomino
ziptures :test
describe Database do
before { Rdomino.local }
subject { Rdomino[:test] }
it { subject.template.must_equal 'templi'}
it { subject.template_name.must_equal 'ny_template'}
describe '#with_documents' do
it "Strings fixnum time and defa... |
class League < ApplicationRecord
validates :name, presence: true
validates :number_of_teams, presence: true
validates :year_founded, presence: true
validates :description, presence:true
end |
class CreateDiagnosesPatients < ActiveRecord::Migration[5.2]
def change
create_table :diagnoses_patients, id: false do |t|
t.belongs_to :diagnosis, index: true
t.belongs_to :patient, index: true
end
end
end
|
#
# This provides an easy way to locally spin up a cluster of `nsqd` and
# `nsqlookupd` processes.
#
# Usage:
#
# require 'nsq-cluster'
# cluster = NsqCluster.new(nsqd_count: 2, nsqlookupd_count: 2)
# cluster.nsqd[0].stop
# cluster.nsqd[0].start
# cluster.destroy
#
require_relative 'nsq-cluster/nsq... |
class MaterialAssignment < ActiveRecord::Base
before_create :change_task_status
before_update :set_quantities
belongs_to :task
belongs_to :material
belongs_to :assignment
def change_task_status
if self[:task_id]
task = Task.find(self[:task_id])
task.update_attributes(:status => "In Progres... |
# -*- encoding : utf-8 -*-
class Flight < ActiveRecord::Base
attr_accessible :arrival_airport, :date, :departure_airport, :econom, :fl
belongs_to :from_airport, :class_name => "Airport", :foreign_key => 'departure_airport'
belongs_to :to_airport, :class_name => "Airport", :foreign_key => 'arrival_airport'
... |
class Thing
attr_accessor :name, :num
def initialize(name, num)
@name = name
@num = num
end
end |
SPEC_RUNNING = true
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'billtrap'))
require 'rspec'
require 'fakefs/safe'
module BillTrap::StubConfig
def with_stubbed_config options = {}
defaults = BillTrap::Config.defaults.dup
BillTrap::Config.stub(:[]).and_return do |k|
defaults.... |
require 'spec_helper'
describe Book, :type => :model do
let(:book) { create(:book) }
it "has a valid factory" do
expect(book).to be_valid
end
describe "associations" do
it { should belong_to(:editorial) }
it { should have_many(:authors).through(:works) }
end
end
|
module Api::V1
class VenuesController < ApplicationController
def index
@location = GeolocationService.new(params[:location]).location
venues = VenueFilter.new(@location, params).venues
@venues_json = VenuePresenter.wrap(venues).map(&:to_json)
render json: {
location: @location.to... |
# frozen_string_literal: true
class Content < ApplicationRecord
has_many :slides, dependent: :destroy
has_many :playlists, through: :slides
belongs_to :user
validates :content, presence: true
mount_uploader :content, ContentUploader
end
|
require 'json'
require 'csv'
require 'set'
RAW_JSON_PATH = './raw/australian_political_donations.json'
JSON_HEADERS = [
"Financial Year",
"Donor",
"Value",
"Party Name",
"Party Group",
"Receipt Type",
"Donor Category",
"Link to AEC"
]
raw_file = File.read(RAW_JSON_PATH)
donations_json = JSON.parse(raw... |
set :application, "moviedb"
set :app_port, 3001
set :server_name, "localhost"
set :scm, :git
set :repository, "git@github.com:mschuerig/#{application}.git"
set :git_enable_submodules, 1
set :deploy_via, :remote_cache
set :branch, "master"
###set :base_path, "/var/www"
set :base_path, "/tmp"
set :deploy_to, "#{base_pat... |
#3) ARRAY 3
#1. Eliminar todos los números pares del arreglo.
a = [1,2,3,9,1,4,5,2,3,6,6]
a.each do |x|
if x.even?
a.delete(x)
end
end
print a
#2. Obtener la suma de todos los elementos del arreglo utilizando .each
suma = 0
a.each do |num|
suma += num
end
puts suma
#3. Obtener el promedio ... |
class CommentsController < ApplicationController
#before_filter :authenticate_user!
respond_to :json
def create
@post = Post.find(params['post_id'])
@comment = @post.comments.build(params['comment'])
@comment.user_id = current_user.id
if @comment.save
return render :json => @comment.to_json... |
describe "Display status text" do
context "parallel approvals" do
it "displays complete status" do
proposal = create(:proposal, :with_parallel_approvers)
proposal.individual_steps.each { |approval| approval.complete! }
login_as(proposal.requester)
visit proposals_path
expect(page).... |
class ImportsController < ApplicationController
before_filter :login_required
filter_access_to :all
def new
@export = Export.find(params[:id])
@import = @export.imports.build
instructions
end
if Rails.env.production? || Rails.env.development?
rescue_from FasterCSV::MalformedCSVError do |e... |
class Admin::UsersGroupsAssignment < ActiveRecord::Base
belongs_to :user, :class_name => 'Admin::User'
belongs_to :group, :class_name => 'Admin::Group'
end
|
class MoviesController < ApplicationController
=begin
def new
@movie = Movie.new
end
def create
@movie = Movie.new(movie_params)
if @movie.save
redirect_to @movie
else
render 'new'
end
end
def show
@movie = Movie.find(params[:id])
end
def index
@movies = TmdbMovie.all
end
def edit
@m... |
class Transaction < ApplicationRecord
has_many :users
has_many :chats
belongs_to :pet
end
|
class TodoItem < ActiveRecord::Base
def self.number_of_completed_todos
return TodoItem.all.where(completed: true).size
end
end
|
require 'spec_helper'
require "generator_spec/test_case"
require 'generators/localized/localized_generator'
describe LocalizedGenerator do
include GeneratorSpec::TestCase
destination File.expand_path("../../../../tmp", __FILE__)
before do
prepare_destination
run_generator
end
specify do
destina... |
require 'fileutils'
# some utility/helper functions here
# print out message to console
# example:
# log("map closed")
# log("map closed", self)
def log(msg, cls=nil)
time_stamp = Time.now.strftime("%H:%M:%S")
if cls.nil?
print " [#{time_stamp}] #{msg}\n"
else
print " [#{time_stamp}] #{... |
module SwaggerAuthenticationController
extend ActiveSupport::Concern
included do
include Swagger::Blocks
swagger_path '/sign_in' do
operation :post do
key :description, 'Sign-in the user'
key :operationId, 'signIn'
key :produces, [
'application/json'
]
ke... |
require 'rails_helper'
feature 'Identity edits document title', js: true, enqueue: false do
context "User deletes a document" do
context "from the All Reports page" do
context "except they don't because the document is still processing" do
scenario "and they see the delete icon is greyed out" do
... |
class RemoveFirstQuestionFromGroups < ActiveRecord::Migration[4.2]
def change
remove_column :groups, :first_question, :string
end
end
|
class AddForeignKeyToRaces < ActiveRecord::Migration[6.0]
def change
add_foreign_key :races, :locations
end
end
|
class Stage < ActiveRecord::Base
belongs_to :tournament
has_many :matches
synchronisable
end
|
class CreateEquipment < ActiveRecord::Migration[5.0]
def change
create_table :equipment do |t|
t.string "tipo"
t.string "marca"
t.string "modelo"
t.string "validade"
t.string "situacao"
t.integer "quantidade"
t.integer "work_place_id"
t.timestamps
end
add_in... |
class Api::V1::GroupMembershipsController < Api::V1::BaseController
before_action :load_group_membership, :except => [:index, :create]
def index
authorize GroupMembership
render :json => GroupMembership.all
end
def show
authorize @group_membership
render :json => @group_membership
end
d... |
class FeedEntriesController < ApplicationController
load_and_authorize_resource
layout "admin"
# GET /feed_entries
# GET /feed_entries.json
def index
@feed_entries = FeedEntry.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @feed_entries }
end
... |
require 'sads'
class Verifier
include Sads
#TODO - check_radix_int requires @q
#TODO - check_radix_label requires @log_q_ceil
def initialize(k, n, q, log_q_ceil, l, r, m)
@k = k
@n = n
@q = q
@log_q_ceil = log_q_ceil
@L = l
@R = r
@root_digest = Vector.elements( Array.new(@k) { 0 } )
@universe_si... |
require 'date'
class Scheduler
SESSION_LENGTHS = [180, 240]
def schedule(talks)
tracks = []
scheduled_talks = []
until talks.empty?
track = Track.new
SESSION_LENGTHS.each do |length|
scheduled_talks = []
until scheduled_talks.map(&:length).inject(:+).to_i == length
... |
module CsvUploads
class CommunityChestCards < CsvUploader
def self.identifier
"CommunityChestCard"
end
def self.label
:id
end
end
end
|
require "conduit/sureaddress/request_mocker/base"
module Conduit::Sureaddress::RequestMocker
class VerifyAddress < Base
private
def response_statuses
%i(success failure error low_confidence)
end
end
end
|
require 'test_helper'
require 'tins'
module Tins
class ExtractLastArgumentOptionsTest < Test::Unit::TestCase
require 'tins/xt/extract_last_argument_options'
def test_empty_argument_array
arguments = []
result = arguments.extract_last_argument_options
assert_equal [ [], {} ], result
a... |
RSpec.describe User, type: :model do
subject { build(:user) }
it 'has a valid :user factory' do
user = build(:user)
expect(user.valid?).to be true
end
it 'has an invalid :invalid_user factory' do
user = build(:invalid_user)
expect(user.valid?).to be false
end
it { is_expected.to validate... |
# -*- encoding : utf-8 -*-
class ChangeColumnTypes < ActiveRecord::Migration[5.1]
def change
change_column :plannedmeals, :MealName, :string
change_column :savedmeals, :MealName, :string
add_column :savedmeals, :SavedMealID, :integer
end
end
|
#
# Cookbook:: aws_build_dotnetcore
# Recipe:: default
#
# Copyright:: 2017, The Authors, All Rights Reserved.
packages = {
# package => version,
'dotnetcore' => '2.0.0',
'dotnetcore-sdk' => '2.0.0.20170906',
'netfx-4.5.2-devpack' => '4.5.5165101',
'netfx-4.6.2-devpack' => '4.6.01590.20170129',
'visualstud... |
class TeachingSessionPolicy < ApplicationPolicy
attr_reader :user, :teaching_session
def initialize(user, teaching_session)
@user = user
@teaching_session = teaching_session
end
def index?
true
end
def show?
true
end
def create?
user.role == "admin"
end
def update?
user.... |
require 'rails_helper'
feature "vacations have notes", js: true do
let!(:skywalker) { FactoryGirl.create(:vacation) }
let!(:note) { Note.create(body: "Watch out for sandstorms", vacation: skywalker) }
scenario "user successfully adds note" do
visit vacation_path(skywalker)
expect(page).to have_content ... |
# encoding: utf-8
require 'spec_helper'
module DCC
describe Worker, "Notifications" do
fixtures :buckets, :builds
let(:bucket) {
build = Build.new()
build.id = 1000
build.commit = 'very long commit hash'
build.build_number = 2342
allow(build).to receive(:project).and_return(do... |
class AddProjectcodeToProject < ActiveRecord::Migration[5.1]
def change
add_column :project_costs, :project_code, :string
end
end
|
class Stage < ActiveRecord::Base
has_many :games
validates :name, presence: true, uniqueness: true
validates :legality, presence: true
end
|
class TagStats
attr_reader :tag_id, :amount
def initialize(options)
@tag_id = options['tag_id']
@amount = options['amount']
end
end
|
FactoryBot.define do
factory :goal do
comment { Faker::ChuckNorris.fact }
end
end
|
require File.expand_path("../../Strategies/cache_wo_download", __FILE__)
# A formula that installs the Instant Client Basic Lite package.
class InstantclientBasiclite < Formula
desc "Oracle Instant Client Basic Lite x64."
homepage "http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html"
url "http://... |
class AddBreakDurationToReports < ActiveRecord::Migration
def change
add_column :reports, :break_duration, :time
end
end
|
class CommentsController < ApplicationController
def create
if session[:user_id] != nil
@blog = Blog.find(params[:blog_id])
@comment = @blog.comments.create(comment_params.merge(user_id: current_user.id))
redirect_to blog_path(@blog)
else
redirect_... |
class AddNameToUsers < ActiveRecord::Migration
def up
add_column :users, :lastname, :string
rename_column :users, :name, :firstname
end
end
|
gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/node'
class TestNode < Minitest::Test
def setup
@node = Node.new(47, "movie", 0)
end
def test_node_class_exists
assert_instance_of Node, @node
end
def test_insert_right_adds_new_movie_to_right
assert_eq... |
class Serializers::Notification < Serializers::Base
structure(:default) do |arg|
{
id: arg.id,
triggering_user: (arg.triggering_user && Serializers::User.new(:default).serialize(arg.triggering_user)),
demand: (arg.demand && Serializers::Demand.new(:default).serialize(Demand.where(id: arg.demand.... |
require 'spec_helper'
# require 'app'
require 'timecop'
require 'active_support/time'
require 'workers'
require_relative '../../app/app'
describe 'freemium signup' do
include Rack::Test::Methods
ENV['RACK_ENV'] = 'test'
def app
App
end
before(:each) do
@freemium_default = School.create(signature: ... |
require File.dirname(__FILE__) + '/../../test_helper'
require 'simplepay/support/subscription_period'
class Simplepay::Support::TestSubscriptionPeriod < Test::Unit::TestCase
context 'Simplepay::Support::SubscriptionPeriod' do
setup do
@interval = Simplepay::Support::SubscriptionPeriod.new
end
... |
require 'rails_helper'
describe MediaItem do
let(:user) { create(:user) }
let(:media_item) { create(:media_item, user: user) }
describe "validations" do
subject { media_item }
it { should be_valid }
it { should belong_to(:user) }
it { should have_many(:images) }
it { should have_one(:link) ... |
class Vendedor < ActiveRecord::Base
validates_presence_of :nome
validates_uniqueness_of :nome
end
|
require 'rails_helper'
feature 'admin get' do
scenario 'admin views motorcycles' do
user = FactoryGirl.create(:user, role: "admin")
style = FactoryGirl.create(:style)
moto = FactoryGirl.create(:motorcycle)
visit root_path
click_link 'Sign In'
fill_in 'Email', with: user.email
fill_in 'Pas... |
require 'rubygems'
begin
require 'bundler'
require 'bundler/setup'
require 'date'
begin
Bundler.setup
require 'xctasks/test_task'
rescue Bundler::GemNotFound => gemException
raise LoadError, gemException.to_s
end
rescue LoadError => exception
unless ARGV.include?('init')
puts "Rescued exc... |
class AddColumnsToSalesOrdersCurrency < ActiveRecord::Migration
def change
add_column :orders, :currency_ref, :string
add_column :orders, :exchange_rate, :integer
end
end
|
class Api::V1::ItemsSerializer < ActiveModel::Serializer
attribute :name, :description, :image_url
end |
# class Compliance
module Compliance
# module Batch Controller
module EncounterBase
# DRG impact calculation
module DrgImpact
extend ActiveSupport::Concern
included do
def render_drg(accuracy = [])
render json: { code_id: @compliance_code.id, code_type: @compliance_code.code_t... |
ActiveAdmin.register ServiceType do
permit_params :name, :image
filter :services
filter :name
end
|
require_relative "room"
class Hotel
def initialize(name, capacities)
@name = name
@rooms = {}
# iterate through each hash argument
capacities.each do |room_name, capacity|
# key value
@rooms[room_name] = Room.new(capacity)
# eac... |
# frozen_string_literal: true
module TestProf
# Add #strip_heredoc method to use instead of
# squiggly docs (to support older Rubies)
module StringStripHeredoc
refine String do
def strip_heredoc
min = scan(/^[ \t]*(?=\S)/).min
indent = min ? min.size : 0
gsub(/^[ \t]{#{indent}}/... |
class CreateCities < ActiveRecord::Migration
def up
create_table :cities do |t|
t.string :name
t.string :state
t.timestamps
end
end
def down
drop_table :cities
end
end |
class YhPrsController < ApplicationController
before_action :set_yh_pr, only: [:show, :edit, :update, :destroy, :taken]
# GET /yh_pr
# GET /yh_pr.json
def index
@q = YhPr.ransack(params[:q])
@yh_prs = @q.result
session[:current_yh_pr_category] = params[:q]['category_cont'] if params[:q]
@yh_prs... |
#!/usr/bin/ruby
# simple script for fork
if ARGV.size == 0
puts "Usage: start PROCESSNUM"
exit(1)
end
Process.daemon(true)
Process.setproctitle('CROOK MASTER')
pids = Array.new(ARGV[0].to_i) do |n|
fork do
begin
require_relative './lib/crawler'
Process.setproctitle("crawler #{n + 1}")
Craw... |
Rails.application.routes.draw do
get '/posts/list', to: 'posts#list'
resources :posts
root to: 'posts#index'
end
|
# frozen_string_literal: true
class SeriesValidator < ActiveModel::Validator
# ensure the property exists and is in the controlled vocabulary
def validate(record)
valid = ['Joe Pike', 'Elvis Cole', 'Elvis Cole/Joe Pike'].include? record.series
return true if valid
record.errors.add :series, "#{record.se... |
class CreateResourceVendors < ActiveRecord::Migration
def self.up
create_table :resource_vendors do |t|
t.references :resource
t.references :vendor
t.integer :created_by
t.timestamps
end
end
def self.down
drop_table :resource_vendors
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.