text stringlengths 10 2.61M |
|---|
class User < ApplicationRecord
validates :username, presence: true, length: {maximum: 50}, uniqueness: true
validates :password, presence: true, length: {maximum: 50}
has_many :rep_mail
has_secure_password
end
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "A class that has a barcode" do
before(:each) do
@model = HasPngBarcode.new
end
it "should have a barcode configuration" do
@model.class.barcode_configurations.should_not be_nil
@model.class.barcode_configurations[:barcode].s... |
# == Schema Information
#
# Table name: trade_posts
#
# id :integer not null, primary key
# title :string
# description :string
# status :string
# created_at :datetime not null
# updated_at :datetime not null
# pokemon_id :integer
#
class TradePost < ApplicationRe... |
=begin
A new system policy has been put in place that requires all accounts to use a passphrase instead of simply a password. A passphrase consists of a series of words (lowercase letters) separated by spaces.
To ensure security, a valid passphrase must contain no duplicate words.
For example:
aa bb cc dd ee is vali... |
require "hijack_method/version"
module HijackMethod
class Hijacker < Struct.new(:object)
def hijack(method_name, options={})
method_name = method_name.to_sym
hijacked_method_name = generate_name(method_name)
return if object.instance_methods(false).include? hijacked_method_name
obje... |
class CreateSnippetsPageParts < ActiveRecord::Migration
def self.up
create_table :snippets_page_parts do |t|
t.integer :snippet_id, :null => false, :references => [:snippets, :id]
t.integer :page_part_id, :null => false, :references => [:page_parts, :id]
t.integer :position, :null => false, :de... |
class ApplicationStylesheet < RubyMotionQuery::Stylesheet
def application_setup
# Change the default grid if desired
# rmq.app.grid.tap do |g|
# g.num_columns = 12
# g.column_gutter = 10
# g.num_rows = 18
# g.row_gutter = 10
# g.content_left_margin = 10
# g... |
require 'rubygems'
require 'grape'
require 'sinatra/activerecord'
require_relative '../helpers/authentication'
require_relative '../models/api_key'
require_relative '../models/character'
require_relative '../models/user'
class Users < Grape::API
format :json
resource :users do
params do
requires :fb_user_id,... |
namespace :medusa do
desc 'Import content from Medusa and DLS'
task :import => :environment do |task, args|
MedusaImporter.new.import(true)
DlsImporter.new.import_collections
puts "\nDone"
end
desc 'Import content from Medusa and DLS, removing old content first'
task :fresh_import => [:clear_con... |
module Transactable
extend ActiveSupport::Concern
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
def catch_errors(&block)
ActiveRecord::Base.transaction { yield }
true
rescue ActiveRecord::ActiveRecordError => ex
errors.add(:base, "An unexpected err... |
require_relative 'employee'
class Owner < Employee
attr_reader :company
def initialize(first_name, last_name, title, base_salary, company)
super(first_name, last_name, title, base_salary)
@company = company
end
def bonus
if @company.hit_quota?
1000
else
0
end
end
def net_... |
# Provide a simple gemspec so you can easily use your
# project in your rails apps through git.
Gem::Specification.new do |s|
s.name = "rails-backbone"
s.version = "0.5.0"
s.authors = ["Ryan Fitzgerald", "Code Brew Studios"]
s.email = ["ryan@codebrewstudios.com"]
s.homepage = "http://github.com/c... |
require 'cloudformation_mapper/resource'
class CloudformationMapper::Resource::AwsResourceOpsworksLayer < CloudformationMapper::Resource
register_type 'AWS::OpsWorks::Layer'
type 'Template'
parameter do
type 'Template'
name :Properties
parameter do
type 'List<Key>'
name :Attributes
... |
class ApplicationController < ActionController::Base
before_action :set_user, except: %i[login do_login]
# GET /login
def login; end
# POST /login
# inspired by: https://www.reddit.com/r/ruby/comments/48ok7h/i_think_ive_got_sessionuser_id_userid_working/
def do_login
uname = params[:username]
user... |
# frozen_string_literal: true
require 'rails_helper'
require 'sidekiq/testing'
describe Jobs::BackupUploadToS3 do
let(:user) { Fabricate(:user) }
let(:file) { file_from_fixtures("logo.png") }
let(:upload) do
UploadCreator.new(file, "logo.png").create_for(user.id)
end
let(:upload_path) do
FileStore... |
class AddLinkToDocuments < ActiveRecord::Migration
def change
add_column :documents, :link_url, :string
end
end
|
# frozen_string_literal: true
class Queve
class QueueOutOfSpaceError < StandardError; end
attr_accessor :base, :size
def initialize(size)
@size = size
@base = []
end
def queue(element)
raise QueueOutOfSpaceError unless @base.size < size
@base << element
end
def dequeue
@base.shif... |
# frozen_string_literal: true
class FeedSubscription < ApplicationRecord
self.table_name = 'feeds_subscriptions'
belongs_to :feed
belongs_to :subscription
end
|
require_relative '../src/judge'
class Scann
def putFizzOrBuzzOrNumber(numbers)
result = ''
for number in 1..numbers
result += Judge.keyWorks(number) + "\n"
end
result
end
end |
class RemoveTreatmentFromIngredients < ActiveRecord::Migration
def up
remove_column :ingredients, :treatment
remove_column :ingredients, :cooking_equipment
end
def down
end
end
|
require 'fileutils'
require 'tmpdir'
require 'repub/epub'
module Repub
class App
module Builder
class BuilderException < RuntimeError; end
def build(parser)
BuilderSupport.new(options).build(parser)
end
class BuilderSupport
include Logger
attr_r... |
class Post < ActiveRecord::Base
validates :title, {presence: true}
validates :content, length: {minimum: 250}
validates :summary, length: {maximum: 250}
validates :category, inclusion: {in: %w{Fiction Non-Fiction}}
validate :is_click_baity
def is_click_baity
phrases = [/Won't Believe/i, /Secret/i, /Top... |
class CheckAnswerSerializer < ActiveModel::Serializer
attributes :option, :value, :correct
def filter(keys)
if object.question.question_type == "radioButton"
keys
else
keys - [:correct]
end
end
end
|
require 'spec_helper'
describe TeamsController do
before do
mock_geocoding!
@league = FactoryGirl.create(:league)
@location = FactoryGirl.build(:location)
@social_info = FactoryGirl.build(:social_info)
end
def valid_attributes
{
name:'Seahawks',
league_id:@league.id,
... |
require 'boris/profilers/unix_core'
#require 'boris/helpers/constants'
module Boris; module Profilers
class SolarisCore < UNIXCore
SOLARIS_ZONE_MODEL = 'Oracle Virtual Platform'
def get_file_systems; super; end
def get_hardware
super
detect_platform if !@platform
detect_zone if ... |
# 2017-04-08
# David Lin
# Method: Use the idea of sort
# @param {Integer[]} nums
# @return {Integer}
# TLE
INT_MAX = 2**31 - 1
INT_MIN = -2**31
def maximum_gap(nums)
nums.sort!
return 0 if nums.length < 2
gap = 0
for i in (0...(nums.length - 1))
gap = [nums[i+1] - nums[i],gap].max
end
gap
end
|
# to run this task from the CLI on heroku, 'heroku run rake flickr:import FLICKR_KEY=XXXXXXXXXXXXXXXXX'
namespace :flickr do
def import_photos(flickr, photos)
photos.each do |image|
p image
@db_image = Image.new
@db_image.url = "https://farm#{image[:farm]}.staticflickr.com/#{image[:server]}/#{... |
# t.date "date", null: false
# t.bigint "classroom_id", null: false
# t.bigint "course_id", null: false
class CourseSession < ApplicationRecord
belongs_to :course, dependent: :destroy
belongs_to :classroom, dependent: :destroy
has_many :session_attendees, dependent: :nullify
has_many :students, through: :... |
class AddAliasToPages < ActiveRecord::Migration
def change
add_column :pages, :page_alias, :string
end
end
|
# From rubinius, but not all of common/dir.rb
class Dir
include Enumerable
def self.[](*patterns)
files = []
patterns.each do |pattern|
pat = Type.coerce_to(pattern, String, :to_str)
files.concat glob(pat, 0)
end
files
end
def self.glob(pat, flags = 0)
pattern = Type.coerce_to(... |
class CreateBooks < ActiveRecord::Migration
def change
create_table :books do |t|
t.string :title
t.text :discription
t.integer :rating
t.integer :year
t.integer :isbn
t.integer :publisher_id
t.timestamps null: false
end
add_index :books, :publisher_id
end... |
class Api::FriendshipsController < ApplicationController
before_action :authenticate
def create
user = User.find(params[:friendship][:user_id])
friendship = Friendship.new(friendship_params)
if friendship.save
render json: friendship, status: 201
else
render json: friendship.errors, status: 422
end
... |
class StoriesController < ApplicationController
before_filter :find_project
def index
@stories = @project.stories.order('position DESC')
end
def new
@story = @project.stories.build
end
def create
@story = @project.stories.build(story_params)
if @story.save
flash[:success] = 'N... |
require 'rails_helper'
RSpec.describe MessagesController, type: :controller do
describe 'Messages' do
let (:message) { create(:message)}
let(:json) { JSON.parse(response.body) }
describe 'GET #index' do
before do
get :index, format: :json
end
it 'should respond with a succ... |
require 'heroku/api'
require 'anvil/engine'
require 'active_support/core_ext/object/blank'
require 'rrrretry'
require 'repl_runner'
require 'json'
require 'stringio'
require 'fileutils'
require 'stringio'
module Hatchet
RETRIES = Integer(ENV['HATCHET_RETRIES'] || 1)
class App
end
def self.git_branch
... |
class CommandTemplateVar < ActiveRecord::Base
attr_accessible :command, :key, :value
belongs_to :command
def self.get_saved_values(command, key)
where(:command_id => command.id, :key => key).map(&:value)
end
end
|
class ChangeFlavorToTypeOnOrders < ActiveRecord::Migration
def up
Order.all.each do |order|
case order.flavor
when "Graphics"
order.flavor = "GraphicOrder"
when "Web"
order.flavor = "WebOrder"
when "Video"
order.flavor = "VideoOrder"
end
order.save!
... |
name "dropbox"
maintainer "Ryan Spaulding"
maintainer_email "ryanspaulding@gmail.com"
license "BSD"
description "Install Dropbox"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.1"
|
class Section < ActiveRecord::Base
belongs_to :chapter
validates :title, presence: :true
end
|
# encoding: utf-8
# copyright: 2016, you
# license: All rights reserved
# date: 2015-08-28
# description: All directives specified in this STIG must be specifically set (i.e. the server is not allowed to revert to programmed defaults for these directives). Included files should be reviewed if they are used. Procedure... |
class CasesController < ApplicationController
before_action :authenticate_user!
before_action :set_case, only: [:show, :edit, :update]
def index
@cases = current_user.profile.cases.where(:status => [:build,:booking,:success]).order(updated_at: :desc)
end
def create
@nanny = Nanny.find_by(:id => params[:nanny_... |
class Tag < String
def initialize name
@name = name
self << "<" << name << ">"
@style = Hash[]
end
def setStyle(key, value)
@style[key] = value
end
def getStyledTag
style = "<" + @name + " style=\""
@style.each{|key, value|
style << (key + ":" + value + ";")
}
style << "\... |
class SessionsController < ApplicationController
before_action :require_login, only: [:destroy]
def create
user = User.find_by_email(params[:email])
if user.try(:authenticate, params[:password])
session[:user_id] = user.id
redirect_to "/events"
else
flash[:errors] = ["Invalid Combination"]
redirect... |
def product(arr)
raise ArgumentError, "less than 3 ints" if arr.length < 3
highest_prod_of_3 = arr[0] * arr[1] * arr[2]
highest_prod_of_2 = arr[0] * arr[1]
lowest_prod_of_2 = arr[0] * arr[1]
highest = arr.first(2).max
lowest = arr.first(2).min
i = 2
while i<arr.length do
current = arr[i]
hi... |
class FontKosugi < Formula
head "https://github.com/google/fonts/raw/main/apache/kosugi/Kosugi-Regular.ttf", verified: "github.com/google/fonts/"
desc "Kosugi"
desc "Available as kosugi maru"
homepage "https://fonts.google.com/specimen/Kosugi"
def install
(share/"fonts").install "Kosugi-Regular.ttf"
end... |
# frozen_string_literal: true
require 'jwt'
require 'json'
class ApplicationController < ActionController::API
def access_token
token = nil
unless request.headers['HTTP_ACCESS_TOKEN'].blank?
token = JWT.decode(
request.headers['HTTP_ACCESS_TOKEN'],
Rails.application.credentials.jwt_se... |
class ChangeBillTypeName < ActiveRecord::Migration
def self.up
change_column :bill_types, :name, :string
end
def self.down
change_column :bill_types, :name, :text
end
end
|
require 'spec_helper'
describe VideoQueuesController do
describe 'GET show' do
let(:user) { Fabricate(:user) }
context "with authentication" do
before do
session[:user_id] = user.id
end
it 'should render the my Queue page' do
populate_queue
get :show, id: VideoQueue.first.id
expe... |
class CreateEmpties < ActiveRecord::Migration
def change
create_table :empties do |t|
t.time :time
t.integer :total
t.references :intersection_osm
end
end
end
|
describe "client_slug confers authz rules" do
include EnvVarSpecHelper
before(:each) do
@ncr_user = create :user, client_slug: "ncr"
@ncr_approver = create :user, client_slug: "ncr"
@gsa_user = create :user, client_slug: "gsa18f"
end
it "rejects requests for user with no client_slug" do
... |
require 'hand'
require 'card'
describe Hand do
let(:hand) do
Hand.new([
Card.new(:deuce, :clubs),
Card.new(:three, :clubs),
Card.new(:four, :clubs),
Card.new(:five, :spades),
Card.new(:seven, :clubs)
])
end
it "has 5 cards" do
expect(hand.cards.all? { |card| card.is_a?... |
class User < ApplicationRecord
has_many :designs, dependent: :destroy
has_many :comments, dependent: :destroy
has_many :follower_relationships, foreign_key: :followed_id, class_name: "FollowJoin"
has_many :isFollowedBy, through: :follower_relationships, source: :following
has_many :following_relat... |
Dir['tasks/**/*.rake'].each { |rake| load rake }
require 'rake/gempackagetask'
require 'rubygems/specification'
require 'date'
GEM = "bt-integration-core"
GEM_VERSION = "0.0.1"
AUTHOR = "Braintree"
EMAIL = "developer@getbraintree.com"
HOMEPAGE = "http://developer.getbraintree.com/blog"
SUMMARY = "Braintree Integratio... |
namespace :db do
desc "Reimport everything"
task remigrate: [:drop, :create, :migrate]
end
|
$: << '../../lib'
$LOAD_PATH << '.'
require 'bundler/setup'
require 'doc_smoosher'
extend DocSmoosher::TopLevel
# Shared fields
limit = define_parameter( name: 'limit' ) do |p|
p.description = 'Return these many results'
p.type = :integer
p.default = 10
end
offset = define_parameter( name: 'offset' ) do |p|
... |
def prompt(message)
puts "=> #{message}"
end
prompt "1. "
puts
# Write a program called name.rb that asks the user to type in their name
# and then prints out a greeting message with their name included.
puts "What is your name?"
name = gets.chomp
puts "Hello #{name}"
puts
prompt "2. "
puts
# Add another sectio... |
# frozen_string_literal: true
require 'rails_helper'
feature 'user create a company' do
scenario 'successfully to create' do
person = create(:person)
user = create(:user, person: person)
company = build(:company)
login_as(person)
visit user_path(user.id)
click_on 'Cadastrar Empresa'
f... |
require 'uri'
require 'shorturl'
module Polidea::Artifacts
class MailGenerator
attr_accessor :installation_website_url, :app_version, :app_name, :image_url, :folder_loc
def initialize
end
def generate_qr_code (url)
if File.exist?("qr_code.png")
File.delete("qr_code.png")
end
... |
# Implement an algorithm to delete a node in the middle (i.e., any
# node but the first and last node, not necessarily the exact
# middle) of a singly linked list, given only access to that node.
# EXAMPLE
# Input: the node c from the linked list
# a->b->c->d->e->f
# Result: nothing is returned, but the new linked l... |
describe 'help pages' do
let(:doc) { Capybara.string(body) }
describe 'GET /help' do
it "renders Markdown successfully" do
get '/help'
expect(response.status).to eq(200)
expect(doc).to have_content('credit card')
end
end
describe 'GET /help/:page' do
it "renders Markdown success... |
class Person < ApplicationRecord
has_many :articles
validates :first_name, presence: {message: "necesario"}
end |
module Driving
class Point
# Creates a new point with specified x, y coordinates
def initialize x, y
@x = x.to_f
@y = y.to_f
end
# Point (0, 0)
ZERO = self.new 0, 0
attr_reader :x, :y
# Creates point (x, y) from vector (x, y)
def self.from_vector v
Point.new v.x, v... |
# Accumulates field definitions and then converts them into an Array that can
# be used to build a form.
module OpenActions
class FormSpec
def initialize
@fields = {}
end
def text_field(name, *args)
@fields[name] = [:text_field, *args]
end
def text_area(name, *args)
@fields[nam... |
class WorkExperience < ApplicationRecord
#t.bigint "user_id"
#t.string "company_name"
#t.string "job_title"
#t.string "job_description"
#t.date "employment_from"
#t.date "employment_to"
#t.string "job_level"
#t.string "job_functions"
#t.datetime "created_at", null: false
#t.datet... |
describe Gateway::Attachments do
subject(:attachments_gateway) { described_class.new }
let(:one_day_ago) { 1.day.ago.to_date }
before do
create_list(:attachment, 7, created_at: 10.days.ago)
create_list(:attachment, 2, created_at: one_day_ago)
end
describe '#delete_data_since' do
it 'removes all... |
require "rails_helper"
RSpec.describe Address, type: :model do
it "has a valid factory" do
expect(create(:address)).to be_valid
end
it "has a valid type factory" do
expect(create(:address, :principal_business)).to be_valid
end
it "has a valid exemption site factory" do
expect(create(:waste_site... |
class Whisper < ActiveRecord::Base
# リレーションの設定
belongs_to :user
end
|
# frozen_string_literal: true
module Vedeu
# Provides a mechanism to control a running client application via
# DRb.
#
module Distributed
end # Distributed
# :nocov:
# See {file:docs/events/drb.md#\_drb_restart_}
Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }
# See {file:docs/... |
class DeviceTestsController < ApplicationController
# GET /device_tests
# GET /device_tests.json
def index
@device_tests = DeviceTest.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @device_tests }
end
end
# GET /device_tests/1
# GET /device_tests... |
class Parser
attr_accessor :array, :pointer, :loop_stack, :op_pointer, :ops
ARRAY_SIZE = 30000
ELEMENT_SIZE = 255;
def initialize
@operators = {"+" => lambda { @array[@pointer] += 1 }, "-" => lambda { @array[@pointer] -= 1 },
">" => lambda { @pointer += 1 }, "<" => lambda { @pointer -= 1... |
class CreateForms < ActiveRecord::Migration[5.1]
def change
create_table :forms do |t|
t.integer :name
t.string :radio
t.string :charge
t.text :item
t.text :who
t.text :content
t.text :why
t.timestamps
end
end
end
|
# Determines whether a given word or phrase is a palindrome, that is,
# it reads the same backwards as forwards, ignoring case, punctuation, and
# nonword characters. (A "nonword character" is defined for our purposes as "a
# character that Ruby regexps would treat as a nonword character".)
def palindrome?(string)
te... |
class UserSubmissionsController < ApplicationController
# GET /user_submissions
# GET /user_submissions.json
def cleanup
user_submissions = UserSubmission.where(:user_id => User.find(params[:user_id]))
user_submissions.each do |us|
if us.uploads.size == 0
us.destroy
end
end
... |
# frozen_string_literal: true
class GradingPalletCompanion < ApplicationRecord
belongs_to :grading_pallet, inverse_of: :companion
belongs_to :category
validates :grading_pallet, :value, :category, presence: true
scope :for_value, ->(value) { where(value: value) }
scope :for_category, ->(category) { include... |
class FontNotoSansDevanagari < Formula
head "https://noto-website-2.storage.googleapis.com/pkgs/NotoSansDevanagari-unhinted.zip", verified: "noto-website-2.storage.googleapis.com/"
desc "Noto Sans Devanagari"
homepage "https://www.google.com/get/noto/#sans-deva"
def install
(share/"fonts").install "NotoSans... |
class Settings::Facilities::ShelvesController < ApplicationController
def index
facility_ids = if selected_facilities_ids.blank?
current_user_facilities_ids
else
selected_facilities_ids
end
@shelves = []
facilities = Facility... |
require 'rails_helper'
RSpec.describe "thumbs down an idea endpoint", type: :request do
it "thumbs down an existing idea and decreases quality 1 notch" do
idea_1 = Idea.create(title: "This is idea #1",
body: "The body of idea #1 should be here",
quality: "genius"... |
# frozen_string_literal: true
class LikesController < ApplicationController
include FindPolymorphic
def index
@likeable = find_polymorphic(params)
render partial: 'tooltip', locals: { likeable: @likeable }
end
def create
@likeable = find_polymorphic(params)
@like = Like.new(likeable: @likeabl... |
# Build a class EmailParser that accepts a string of unformatted
# emails. The parse method on the class should separate them into
# unique email addresses. The delimiters to support are commas (',')
# or whitespace (' ').
class EmailParser
attr_accessor :name, :email
def initialize(email)
@email = email
... |
class Follower < ActiveRecord::Base
belongs_to :user
belongs_to :user_friend, class_name: "User"
end
|
class AddGoaltypeColumn < ActiveRecord::Migration
def self.up
add_column :goals, :goaltype_id, :integer, :null => false, :default => 1
end
def self.down
remove_column :goals, :goaltype_id
end
end
|
class BinaryTreeNode
attr_accessor :left, :right
attr_reader :value
def initialize(value)
@value = value
@left = nil
@right = nil
end
def insert_left(value)
@left = BinaryTreeNode.new(value)
end
def insert_right(value)
@right = BinaryTreeNode.new(value)
end
def largest_value
... |
# == Schema Information
#
# Table name: manufacturers
#
# id :bigint not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# organization_id :bigint
#
require "rails_helper"
RSpec.describe Manufacturer, typ... |
require 'csv'
require 'time'
require_relative 'sales_engine'
class Customer
attr_reader :id, :first_name, :last_name, :created_at, :updated_at,:engine
def initialize(customer_info, engine)
@id = customer_info[:id].to_i
@first_name = customer_info[:first_name]
@last_name = customer_info[:last_name]
... |
require 'rails_helper'
RSpec.describe Post, type: :model do
context 'Posts/Comments relations' do
it 'Checks associations between Posts and Comments' do
user = User.create!(email: 'test@email.com', name: 'testname', password: 'testpassword')
post = Post.create!(content: 'post test', user_id: user.id)
... |
#!/usr/bin/env ruby
require 'io/console'
require 'colorize'
require_relative '../lib/board'
puts 'Hello Player!'
puts 'Instuctions:'
puts '1) Player 1 and Player 2 need to enter their nicknames'
puts '2) Player 1 & 2 need to select their marks (X or O)'
puts '3) Players will need to select their positions to input thei... |
require "rails_helper"
RSpec.describe User, type: :model do
it { is_expected.to(belong_to(:casa_org)) }
it { is_expected.to have_many(:case_assignments) }
it { is_expected.to have_many(:casa_cases).through(:case_assignments) }
it { is_expected.to have_many(:case_contacts) }
it { is_expected.to have_many(:s... |
class GameSerializer < ActiveModel::Serializer
attributes :id, :title, :rules, :score, :tasks, :host, :posts, :users
# has_many :posts
# has_many :users
def posts
self.object.posts.sort_by{|post| post.id}.reverse
end
def users
self.object.users.map{|user| {id: user.id, name: user.name, username: u... |
class Booking < ApplicationRecord
belongs_to :room
belongs_to :band
validates :start_date, :end_date, :band_name, presence: true
validate :end_date_after_start_date
private
def end_date_after_start_date
return if end_date.blank? || start_date.blank?
if end_date < start_date
errors.add(:... |
class Question < ApplicationRecord
# has_many :question_options, dependent: :destroy
# has_many :answers, through: :question_options
belongs_to :quiz
has_many :answers, dependent: :destroy
def display_name
question # or that code will return a representation of your Model instance
end
end
|
class ChatLinesController < ApplicationController
skip_before_action :authorise_admin
before_action :set_chat_room
before_action :chat_line_since_last_params, only: [:refresh_since_last]
before_action :chat_line_params, only: [:create]
def refresh_since_last
respond_to do |format|
format.js
end... |
class RemoveImageDescriptionConstraint < ActiveRecord::Migration[5.0]
def change
change_column :images, :keywords, :string, null: true
end
end
|
# web elements and functions for page
class ResizablePage
include Capybara::DSL
include RSpec::Matchers
include Capybara::RSpecMatchers
def initialize
@restriction_box = Element.new(:css, '#resizableBoxWithRestriction')
@box = Element.new(:css, '#resizable')
end
def visit
Capybara.visit('resiz... |
class Cblas < Formula
desc "C Basic Linear Algebra Subprograms"
homepage "http://www.netlib.org/blas/"
url "http://www.netlib.org/blas/blast-forum/cblas.tgz"
version "2011-01-20"
sha256 "0f6354fd67fabd909baf57ced2ef84e962db58fae126e4f41b21dd4fec60a2a3"
depends_on "clapack" => :build
depends_on "gcc" => :... |
#
# Cookbook Name:: nginx
# Recipe:: default
#
# Copyright 2014, oshiire
#
# All rights reserved - Do Not Redistribute
#
servers = data_bag_item('proxylist','production')['servers']
template "reverse_proxy.conf" do
path "/etc/nginx/conf.d/reverse_proxy.conf"
owner "root"
group "root"
mode 0644
variables ({
... |
class Tolaria::TolariaController < ::ApplicationController
protect_from_forgery
before_action :add_admin_headers!
before_action :authenticate_admin!
protected
def add_admin_headers!
# Don't use old IE rendering modes
response.headers["X-UA-Compatible"] = "IE=edge"
# Forbid putting the admin in ... |
class AddDefaultEnrolled < ActiveRecord::Migration[6.1]
def change
change_column_default :trainees, :enrolled, ""
end
end
|
class Auth::Generators::ConfigurationGenerator < Rails::Generator::Base
attr_reader :model
def initialize(args, options = {})
super(args, options)
end
def manifest
record do |m|
m.directory "lib/tasks"
m.directory "config/initializers"
m.file "tasks/migrations.rb", "lib/tasks/spa... |
homebase File.expand_path("..", File.realdirpath(File.dirname(__FILE__)))
cookbook_path [ File.expand_path('cookbooks', homebase) ]
role_path [ File.expand_path('roles', homebase) ]
base_dir = "/usr/local/var/chef/#{ENV['USER']}"
require 'fileutils'
FileUtils.mkdir_p(base_d... |
# == Schema Information
#
# Table name: locations
#
# id :integer not null, primary key
# name :string
# created_at :datetime
# updated_at :datetime
#
class Location < ActiveRecord::Base
validates :name, :presence => true
scope :with_name, ->(name) { where(name: name.to_s.titleize).first... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.