text stringlengths 10 2.61M |
|---|
class GamesController < ApplicationController
before_action :authenticate_user!
def index
cars = Car.order("Random()").limit(3).to_a
@car1 = cars[0]
@car2 = cars[1]
@car3 = cars[2]
end
def new
@game = Game.new
end
def create
@game = Game.create_game(current_user, game_params[:leve... |
require 'telegram/errors/common_error'
module Telegram
module Errors
module Configuration
class TokenMissingError < Telegram::Errors::CommonError
def initialize name
super "No token were provided for bot \"#{name}\""
end
end
end
end
end
|
class WordGroup < ActiveRecord::Base
belongs_to :starting_word, class_name: Word
belongs_to :ending_word, class_name: Word
belongs_to :concept
validates :starting_word, presence: true
validates :ending_word, presence: true
validates :group_type, inclusion: { in: [
'Sentence',
'Noun phrase',
... |
RSpec.configure do |config|
config.include FactoryGirl::Syntax:Methods
end |
class Bid < ActiveRecord::Base
belongs_to :pool
belongs_to :user
has_one :team
end |
#==============================================================================
# Drop Options
# Version: 1.1.0
# Author: modern algebra (rmrk.net)
# Date: 23 September 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script is very simple. All... |
class VendorsController < ApplicationController
def new
@vendor = Vendor.new
end
def create
@vendor = Vendor.new(params[:vendor])
if @vendor.save
begin
VendorMailer.registration_confirmation(@vendor).deliver
flash[:success] = "Vendor Added Successfully"
redirect_to amain_path
re... |
class MessagesController < ApplicationController
before_filter :login_required
before_filter :check_permission_for_broadcast, :only=>:create_broadcast
require 'lib/override_errors'
helper OverrideErrors
filter_access_to :all, :except=>:message_settings
filter_access_to [:message_settings]
def index
... |
class SpiralExchange < ActiveRecord::Base
belongs_to :exchange
belongs_to :spiral
end
|
# frozen_string_literal: true
namespace :video do
desc 'Add positions to nil values in video table'
task :add_position, [:videos] => :environment do
final_position = Video.order(position: :desc).first.position
Video.all.each do |video|
if video.position.nil?
video.update(position: final_posit... |
class String
def syllable_count
consonants = "bcdfghjklmnpqrstvwxz"
vowels = "aeiouy"
processed = self.downcase
numbers = processed.scan(/[\d+[\,*]]+/)
processed.gsub!(/[\d+[\,*]]+/, " ")
numbers.each do |number|
number.gsub!(",", "")
processed += " " + I18n.with_lo... |
# frozen_string_literal: true
module Decidim
module Opinions
# A command with all the business logic to reject a user request to
# contribute to a collaborative draft.
class RejectAccessToCollaborativeDraft < Rectify::Command
# Public: Initializes the command.
#
# form - A form ... |
#
# Cookbook Name:: clamav-cookbook
# Recipe:: default
#
# Copyright (C) 2014 Greg Palmier
#
# All rights reserved - Redistribute
#
node['clamav']['packages'].each do |pkg|
package pkg do
action :install
end
end
# freshclam runs quiet after installing, run if no definitions on disk.
execute "freshclam_init" d... |
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-pl... |
def echo(word)
word
end
def shout(word)
word.upcase
end
def repeat(string, time = 2)
word = Array.new(time, string)
word.join(" ")
end
def start_of_word(word, n)
word[0..n - 1]
end
def first_word(word)
word.split(" ")[0]
end
def titleize(string)
little_words = [ "and", "over", "the" ]
words = strin... |
require 'rails_helper'
RSpec.describe 'Ingest suppliers', type: :request do
describe 'POST /uploads' do
let(:headers) { { 'CONTENT_TYPE' => 'application/json' } }
let(:suppliers) do
[
{
'supplier_name' => Faker::Name.unique.name,
'branches' => [
{
'... |
# This controller renders all of the statistics for each project using only a GET request.
class StatController < ApplicationController
include SurveyHelper
before_action :authenticate_user!
before_action :select_course!
# The GET request renders the stats for each project in the currently selected course
de... |
require_relative 'board'
require_relative 'player'
class Game
attr_reader :board, :current_player
def initialize
@board = Board.new(game: self, size_x: 8, size_y: 8)
@player_1 = Player.new(game: self, name: 'p1', color: 'white')
@player_2 = Player.new(game: self, name: 'p2', color: 'black')
@cur... |
require 'rails_helper'
describe UsersController do
#let(:user) {User.create(username: "Bromance", password: "password", password_confirmation: "password")}
before :each do
visit "/"
user = User.create(
username: "Bromano",
password: "password1234",
password_confirmation: "password... |
# frozen_string_literal: true
class User < ApplicationRecord
acts_as_authentic
has_many :presentations, dependent: :delete_all
validates :email,
format: {
with: /@/
},
length: { maximum: 100 },
uniqueness: {
case_sensitive: false,
if: :will_save_change_to_email?
}
valid... |
#!/bin/ruby
require 'open-uri'
# Functionality for querying a historical data server and, optionally,
# preprocessing the result, and then sending the resulting data
# to a specified file (which, by the way, can be $stdout or $stderr).
class URL_Query
public
attr_reader :query, :filter_function, :fatal_error, :... |
#!/usr/bin/env ruby
require 'core'
require 'server_setup'
require 'ducky_setup'
# Class that all modules will inheart from making it easier to create modules
class Skeleton
include Core::Commands
include Core::Files
class << self
attr_accessor :title, :description
end
def initialize
system('clear')
... |
ActiveAdmin.register Tip do
scope :unpublished
scope :published
index do
id_column
column :subject
column :created_at
column :updated_at
actions
end
form do |f|
inputs do
input :subject
input :body, as: :wysihtml5, commands: :all
end
actions
end
action_item... |
class ApplicationController < ActionController::Base
include ApplicationHelper
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
helper_method :c... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos/7"
config.ssh.insert_key = false
config.vm.provider :virtualbox do |v|
v.name = "challenge"
v.memory = 1024
v.cpus = 1
v.customize ["modifyvm", :... |
class New < ActiveRecord::Migration
def change
create_table "Games", force: :cascade do |t|
t.integer "rounds"
end
create_table "GamePlayers", force: :cascade do |t|
t.belongs_to :game
t.string "player_name"
end
add_reference :users, :game
end
end
|
module Votable
extend ActiveSupport::Concern
included do
has_many :votes, as: :votable, dependent: :destroy
end
def rating
votes.sum(:status)
end
def create_positive_vote(user)
votes.create_with(status: 1).find_or_create_by(user_id: user.id)
end
def create_negative_vote(user)
votes.c... |
class Api::CatsController < ApplicationController
def index
response = HTTP
.headers({
"Authorization" => "Bearer #{Rails.application.credentials.cats_api[:api_key]}",
})
.get("https://api.thecatapi.com/v1/images/search")
render json: response.parse
end
end
|
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |s|
s.name = "client_date"
s.version = "0.2"
s.date = "2013-02-10"
s.summary = "Uses client-side Javascript to format a datetime instead of the Ruby on Rails server"
s.email = "piotr.b... |
class Acolyte
def initialize()
@skill_prof = "Insight, Religion",
@equipment = "A holy symbol (a gift to you when you entered the priesthood), a prayer book or prayer wheel, 5 sticks of incense, vestments, a set of common clothes, and a belt pouch containing 15 gp"
@feature = "Shelter of the Faithful: As ... |
require 'snmp2mkr/config_types/base'
require 'snmp2mkr/config_types/oid'
require 'snmp2mkr/config_types/template_string'
require 'snmp2mkr/config_types/raw_string'
require 'snmp2mkr/config_types/transformation'
module Snmp2mkr
module ConfigTypes
class ValueDefinition < Base
def setup(kv)
raise Type... |
class CreateArts < ActiveRecord::Migration[5.0]
def change
create_table :arts do |t|
t.string :title
t.belongs_to :user
t.string :color1
t.string :color2
t.string :color3
t.string :color4
t.string :color5
t.string :color6
t.string :maker
t.string :year
... |
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: :reset_session # TODO: is this what I want?
before_filter :configure_permitted_parameters, if: :devise_controller?
check_a... |
require 'rails_helper'
RSpec.describe Job, type: :model do
it { should belong_to(:company) }
it 'returns the angellist url for the job' do
company = FactoryGirl.create :company, name: 'Expect Labs'
job = FactoryGirl.create :job, angellist_job_id: nil, company: company
expect(job.angellist_url).to be n... |
# Your code goes here!
class Anagram
attr_accessor :input
def initialize(input)
@input = input
end
def match(words)
arr = []
words.each do |word|
if word.split("").sort == @input.split("").sort
arr << word
end
end
arr
end
end |
module Instructor
def self.table_name_prefix
'instructor_'
end
end
|
class Mist::GitFileSystemHistory
def initialize(path_or_repo)
@files = ActiveSupport::OrderedHash.new
@repo = path_or_repo.kind_of?(Git::Base) ? path_or_repo : Git.open(path_or_repo)
end
# Returns files in order of discovery. Since they are discovered
# by traveling up the tree and backward in time, ... |
require 'spec_helper'
describe "people/edit" do
before(:each) do
@theStubTeam = stub_model(Team, name:"Notre Dame", id:1)
@person = assign(:person, stub_model(Person,
:first_name => "MyString",
:last_name => "MyString",
:home_town => "MyString",
:home_school => "MyString",
:posi... |
class CashRegister
attr_accessor :total, :discount
attr_reader :items, :prices
def initialize(discount=nil, total=0)
@total = total
@discount = discount
@items = []
@prices = []
end
def discount
@discount
end
def apply_discount
if @discount
@total -= @total * @discount / 1... |
class RoutesController < ApplicationController
skip_before_filter :verify_authenticity_token, only: :create
before_action :set_route, only: [:show, :edit, :update, :destroy]
SECRET = 'e6902c80c51b5ddb2612ada39d3a8b60'
# POST /routes
def create
if params[:secret] != SECRET
render nothing: true, sta... |
# sudo apt-get install sox
def is_installed(cmd)
stdop = system("#{cmd} > /dev/null 2>&1")
result = $?
exit_code = result.exitstatus
return !exit_code.eql?(127)
end
def play_note(note, duration=0.1, delay=0)
head = 'play -nq -t alsa synth'
cmd = "#{head} #{duration} tri #{note}"
sys... |
class Stem < ActiveRecord::Base
validates :download_url, presence: true, uniqueness: true
validates :track_name, presence: true
validates :producer, presence: true
belongs_to :producer
has_many :remixes
has_many :circles, through: :remixes
end
|
class Game
def initialize
@location = 0
@rooms = []
end
def add_room (room)
@rooms.push(room)
end
#Behavior (methods)
def start
while @location |location|
puts @description.Room
print "Enter a direction"
input = gets.chomp
end
end
def move (dir... |
class AutotestDialogUsingMessage
include Mohawk
DIALOG_MESSAGE = 0
window(title: 'Autotesttest')
button(:smack_down, name: 'OK')
def message
window_element.find_all(control_type: :text)[DIALOG_MESSAGE].name
end
#private
def window_element
adapter.window.element
end
end |
class String
define_method('game_router') do |test_word, replacement_word, transformation, match_type|
if match_type == "whole-word"
self.whole_word(test_word, replacement_word, transformation)
elsif match_type == "partial-word"
self.partial_word(test_word, replacement_word, transformation)
en... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'mahonia:import:bepress_csv', :clean do
include_context 'rake'
subject(:task) { rake[name] }
let(:task_path) { 'lib/tasks/import' }
let(:csv_path) { 'spec/fixtures/bepress_etd_sample.csv' }
it 'outputs info to stdout' do
expect { ta... |
require 'formula'
class Cil < Formula
homepage 'http://kerneis.github.com/cil/'
url 'http://downloads.sourceforge.net/project/cil/cil/cil-1.7.3.tar.gz'
sha256 '69b7f290d2b15dd44e2b837d3de0922245be841f79ab56a7e9ba8205544be314'
depends_on "objective-caml"
depends_on "ocaml-findlib"
option 'with-llvm', 'ena... |
require "set"
COLLECTION_AREA = INPUT.split("\n").map(&:chars).freeze
SIZE = COLLECTION_AREA.size
NEIGHBORS = [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]].freeze
ACRES = {open: ".", forest: "|", lumberyard: "#"}.freeze
TRANSITIONS = {
ACRES[:open] => ->(n) { (n.count(ACRES[:forest]) >= 3) ... |
# frozen_string_literal: true
require 'bigdecimal'
require 'time'
# Item class
class Item
attr_reader :id,
:created_at,
:merchant_id
attr_accessor :name,
:description,
:unit_price,
:updated_at
def initialize(params)
@id ... |
class CreateJobs < ActiveRecord::Migration
def change
create_table :jobs do |t|
t.string :kind
t.string :description
t.datetime :date_of_job
t.string :duration
t.string :address
t.string :cross_street
t.integer :phone_number
t.string :phone_kind
t.string :refe... |
describe ApiTokenPolicy do
let(:token) { create(:api_token, step: approval) }
let(:approval) { proposal.individual_steps.first }
let(:proposal) { create(:proposal, :with_approver) }
let(:approver) { approval.user }
let(:approval_params_with_token) do
{
cch: token.access_token,
id: proposal.id.... |
module Admin
class ItemsController < AdminController
before_action :set_campaign, only: [:create, :index]
def create
Item.create!(item_params)
self.tab_after_redirect = Admin::Tabs::ITEMS_LIST_TAB
redirect_to [:admin, @campaign], notice: 'Item criado com sucesso.'
end
def destroy
... |
# frozen_string_literal: true
if defined?(GlobalID)
GlobalID.app = "graphql-ruby-test"
class GlobalIDUser
include GlobalID::Identification
attr_reader :id
def initialize(id, located_many: false)
@id = id
@located_many = located_many
end
def located_many?
@located_many
... |
require 'rubygems'
require 'xmlsimple'
require 'pp'
module ACMEJobStreamerImport
# Manages converting the XML file contents into a iterable data structure
class XMLDocument
attr_accessor :node_count
# Instantiate with contents of file, tries to parse it catching any
# exceptions and setting the @val... |
class User < ActiveRecord::Base
before_destroy :check_all_events_finished
has_many :created_events ,class_name: 'Event',foreign_key: :owner_id
has_many :tickets, dependent: :nullify
has_many :participating_events,through: :tickets,source: :event
def self.find_or_create_from_auth_hash(auth_hash)
provider = au... |
class AddFieldsToTransportGpsSettings < ActiveRecord::Migration
def self.up
add_column :transport_gps_settings, :vendor_name, :string
add_column :transport_gps_settings, :vendor_code, :string
add_column :transport_gps_settings, :integration_id, :integer
add_column :transport_gps_settings, :integration... |
module JackCompiler
class Source
attr_reader :filename, :source
def initialize(filename)
@filename = filename
@cursor = 0
end
def store!(raw_source)
@source = format_sources(raw_source)
end
def pop
@cursor += 1
@cursor <= size ? code.dup : nil
end
... |
guard 'livereload' do
watch %r{^.*\.(html|css|js|png|jpg)$}
end
|
module Fog
module Compute
class DigitalOceanV2
class Images < Fog::Collection
model Fog::Compute::DigitalOceanV2::Image
# Retrieves images
# @return [Fog::Compute::DigitalOceanV2:Image]
# @raise [Fog::Compute::DigitalOceanV2::NotFound] - HTTP 404
# @raise [Fog::Compu... |
module Effect
class Giveable
attr_accessor :parent
def initialize(parent)
@parent = parent
end
def describe
"May be given to other characters."
end
def save_state
['Giveable']
end
def item
return @item unless @item.nil?
giveable = parent.parent if parent.respond_to?(:parent)
@ite... |
#
# Recipe:: opencv
#
# Copyright:: (c) 2020 Jeff Byrnes
#
# 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
#
# Unless required by applicable l... |
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
$:.unshift(File.dirname(__FILE__))
require 'TestSetup'
require 'RandomThings'
class PgTimeTest < Test
include SqlPostgres
include RandomThings
def test_ctor_defaults
assertEquals(PgTime.new, PgTime.new(0, 0, 0))
end
def test_ctor_and_acce... |
class AuthenticationController < ApplicationController
skip_before_action :authenticate_request
def authenticate
command = AuthenticateUser.call(params[:email], params[:password])
render json: { token: command.result }
end
end
|
require 'faker'
FactoryGirl.define do
factory :user do
email { Faker::Internet.email }
name { Faker::Name.name }
password 'secret1234'
password_confirmation { password }
trait :as_admin do
email 'admin@example.com'
admin true
confirmed true
end
end
end |
require "formula"
class Statismo < Formula
homepage "https://github.com/statismo/statismo"
url "https://github.com/statismo/statismo/archive/v0.10.2.tar.gz"
sha256 "c6f65bb7f37604aebbe40e767adbea4d39509050"
head 'https://github.com/statismo/statismo.git'
patch do
url "https://gist.githubusercontent.com/... |
# Gem spec for pdf-extract.
Gem::Specification.new do |s|
s.name = "pdf-extract"
s.version = "0.1.1"
s.summary = "PDF content extraction tool and library."
s.files = Dir.glob("{bin,lib,data}/**/*")
s.executables << "pdf-extract"
s.authors = ["Karl Jonathan Ward"]
s.email = ["kward@crossref.org"]
s.homep... |
class Piece < ActiveRecord::Base
belongs_to :batiment
has_many :elements, dependent: :destroy
assignable_values_for :nom do
['Entrée', 'Toilettes', 'Cuisine', 'Dégagement', 'Rangement', 'Séjour', 'Cave', 'Salle de bain', 'Chambre']
end
end
|
require 'singleton'
require_relative './subscription'
### dummy implementation of a PubSub
### Useful for decoupling
### Ideally, we would be using a tool specially designed for this (like Redis pubsub)
class PubSub
include Singleton
def initialize
clean_subscriptions
end
def subscribe(topic, subscribe... |
# frozen_string_literal: true
class EventsController < ApplicationController
include IcalHelper
expose(:events) { Event.ordered.page(params[:page]) }
expose(:event) { Event.includes(materials: :user, topics: :user, participants: :user).from_param(params[:id]) }
def index
respond_to do |format|
for... |
require 'fission-package-builder'
module Fission
module PackageBuilder
module Formatters
class Slack < Fission::Formatter
SOURCE = :package_builder
DESTINATION = :slack
def format(payload)
if(payload.get(:data, :package_builder, :keys))
pkg = payload[:data][... |
# ==========================
# Author: Dennis Son Le
# ==========================
require 'rubygems'
require 'gosu'
require './circle'
# The screen has layers: Background, middle, top
module ZOrder
BACKGROUND, MIDDLE, TOP = *0..2
end
class DemoWindow < Gosu::Window
def initialize
super(800, 600, false)
s... |
require 'spec_helper'
describe ProductLength do
let(:product_length) { FactoryGirl.create(:product_length) }
subject { product_length }
describe "validations" do
it { should be_an_instance_of(ProductLength) }
it { should be_valid }
it { should validate_presence_of(:name) }
it { should validate_... |
require 'rails_helper'
RSpec.describe User, :type => :model do
it "is valid with valid attributes" do
user = build(:user)
expect(user).to be_valid
end
it "is not valid without an email" do
user = build(:user)
user.email = ""
expect(user).to_not be_valid
end
it "is not valid with invalid e... |
module Batsd
#
# Handles gauge measurements ("|g")
#
# Gauge measurements are corrected for sample rate
# (or more accurately, scale), if provided and written
# to redis without any manipulation or collection.
#
class Handler::Gauge < Handler
# Process an incoming gauge measurement
#
#... |
class AddReviewReferencesToGoods < ActiveRecord::Migration[5.2]
def change
rename_column :goods, :seller, :is_seller
add_reference :goods, :seller, foreign_key: {to_table: :reviews}, null: true
add_reference :goods, :buyer, foreign_key: {to_table: :reviews}, null: true
end
end
|
task :env do
require 'mongo'
require 'json'
require 'open-uri'
end
URL = "http://ci.seleniumhq.org/jarib/ignores.json"
namespace :db do
desc "Take a snapshot of current ignores from #{URL}"
task :snapshot => :env do
collection = Mongo::Connection.new.db("selenium").collection("ignores")
url = ENV['... |
require "redis_mutexer/version"
require "redis"
#require "pry"
module RedisMutexer
class Configuration
attr_accessor :redis, :host, :port, :db, :time, :logger
def initialize
@host = 'localhost' #host
@port = 6379 #port
@db = 'redis_mutexer' #database namespace
@time = 6... |
=begin
Cook Skill
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
Allows you to cook enemies and cause them to drop a set item.
----------------------
Instructions
----------------------
By default an enemy is only eatable if you set them to have
a cooked drop item. To set it notetag the en... |
require 'test_helper'
class EntityTermsParserTest < ActiveSupport::TestCase
test "basic parsing" do
p = EntityTermsParser.new("")
assert_nil p.proceed
p = EntityTermsParser.new(":")
expected = [{"term" => "", "locale" => "*"}]
assert_nil p.proceed
p = EntityTermsParser.new(":fr")
expec... |
require 'spec_helper'
describe 'fmw_jdk::internal::rng_service_redhat', :type => :class do
describe 'on RedHat 7 platform' do
let(:facts) {{ osfamily: 'RedHat',
operatingsystemmajrelease: '7' }}
it {
should contain_exec('sed rngd.service').with(
co... |
class BodyShape < ActiveEnum::Base
value :id => 1,
:name => 'Slim'
value :id => 2,
:name => 'Average'
value :id => 3,
:name => 'Slight Curve'
value :id => 4,
:name => 'Curvy'
value :id => 5,
:name => 'Extra-Curvy'
end |
#!/usr/bin/env ruby
require_relative './lib/month'
month = ARGV[0].to_i
year = ARGV[1].to_i
def arg_error
puts "Date not in acceptable format/range"
end
if ARGV.empty? || year < 1800 || year > 3000
arg_error
else
m = Month.new(month, year)
puts m.to_s
end
|
require 'rails_helper'
@omniauth_test
describe User, :type => :model do
context ".from_omniauth" do
before :each do
@time = DateTime.now
@auth = {
provider: "github",
uid: "44305943",
info: {
name: "Devina Dhuri",
... |
FactoryBot.define do
factory :user do
nickname { Faker::Name.initials }
email { Faker::Internet.free_email }
password = '1a' + Faker::Internet.password(min_length: 4)
password { password }
password_confirmation { password }
last_name { Faker::Japanese::Name.last_name }
first_name { Faker::... |
require 'rails_helper'
RSpec.describe DebitNote, type: :model do
describe 'associations' do
it { should belong_to(:supplier).class_name('Company') }
it { should belong_to(:purchase_order) }
it { should belong_to(:delivery) }
it { should have_many(:debit_note_items) }
end
describe 'validations' d... |
# chef_server_upgrade
# Recipe:: csutest-prod
#
# Create test nodes that associate to the 'prod' org on
# the cs_prod server for testing chef_server_upgrades
require 'chef/provisioning/aws_driver'
require_relative '../libraries/helpers'
role = 'csutest'
org = 'prod'
inbound_ip = '108.56.0.0/16'
role_org = role ... |
class Post < ActiveRecord::Base
has_many :posts_positions, foreign_key: :post_id
has_many :positions, through: :posts_positions
end
|
module Types
class UserType < BaseObject
field :id, Int, null: false
field :username, String, null: false
field :email, String, null: false
field :first_name, String, null: false
field :last_name, String, null: false
field :followers, [Integer], null: true, method: :followers
... |
require 'rails_helper'
feature "Pages", :type => :feature, js: true do
it "can be created by admin user" do
user = create(:user)
user.role = :admin
user.save
login_as(user, scope: :user)
visit new_page_path
fill_in 'page_title', with: Faker::Lorem.sentence
fill_in 'page_alias', with: Fa... |
module JenkinsLight
class Monitor
attr_accessor :url, :username, :password
def initialize output, input, traffic_light
@output = output
@input = input
@traffic_light = traffic_light
end
def start
@output.puts "Jenkins Build Light Monitor Started"
if (@url.nil?)
... |
class AddMoreFieldsToInstance < ActiveRecord::Migration
def change
add_column :instances, :security_group, :string
add_column :instances, :key_pair, :string
end
end
|
class Location < ActiveRecord::Base
extend ActiveHash::Associations::ActiveRecordExtensions
has_many :copies
belongs_to_active_hash :library_system
has_and_belongs_to_many :users
validates_presence_of :library_system_id, :name
end
|
Spree::TaxonsController.class_eval do
include Spree::BaseHelper
def show
@taxon = Spree::Taxon.find_by_permalink!(params[:id])
return unless @taxon
@searcher = build_searcher(params.merge(taxon: @taxon.id))
@products = @searcher.retrieve_products
@response = @searcher.elastic_response
@taxo... |
require './board'
class MineBoard < Board
MINE = -1
EMPTY = 0
def initialize(width, height, no_of_mines)
super(width, height, EMPTY)
generate(no_of_mines)
calculate_counts
end
def mine?(x, y)
get(x, y) == MINE
end
def generate(no_of_mines)
while no_of_mines > 0
x = rand(@wid... |
control 'Secure Cookie' do
impact 'high'
title 'secure-cookie-key is set'
desc 'The secure cookie should be set so that it matches the load balancer (auth-proxy) key' \
'https://docs.rstudio.com/ide/server-pro/latest/load-balancing.html'
tag 'rstudio'
describe file('/var/lib/rstudio-server/secure-cookie-ke... |
class Array
def my_each(&prc)
idx = 0
while idx < length
prc.call(self[idx])
idx += 1
end
self
end
def my_select(&prc)
selections = []
my_each do |el|
selections << el if prc.call(el)
end
selections
end
def my_reject(&prc)
selections = []
my_each do |el|
selections << el unless p... |
class AddCountToSubjectUsers < ActiveRecord::Migration
def self.up
add_column :subject_users, :subject_posts_count, :integer, :default=>0
add_column :subject_users, :week_subject_posts_count, :integer, :default=>0
end
def self.down
remove_column :subject_users, :week_subject_posts_count
remove_co... |
# encoding: UTF-8
module CDI
module V1
module Users
class PostSignupUpdateService < BaseActionService
action_name :post_signup_update_user
attr_reader :user
def initialize(user, options={})
@user = user
super(options)
end
def user_can_execute_... |
module WordSearch
class SuffixSearcher
class Hit < Struct.new(:term, :suffix_number, :offset, :fulltext_reader)
def context(size)
strip_markers(self.fulltext_reader.get_data(offset - size, 2 * size), size)
end
def text(size)
strip_markers(self.fulltext_reader.get_data(offset,... |
module PostsHelper
def status_badge(post)
case post.status
when "submitted" then "badge-primary"
when "approved" then "badge-success"
when "rejected" then "badge-danger"
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.