text stringlengths 10 2.61M |
|---|
class User < ActiveRecord::Base
after_create :send_notification
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :name, presence: true, length: {maximum: 25}
has_many :charges
has_many :memberships
has_many :courses, through: ... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don"t touch unless you know what you"re doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ffuenf/debian-8.2.0-amd64"
config.vm.hostname = ENV["VM_HOSTNAME"] || "rubylive-builder"
... |
require 'net/http'
require 'uri'
require 'digest/sha2'
require 'erb'
def formula(git_tag, sha256)
erb_string = File.read('formula.erb')
ERB.new(erb_string).result(binding.tap{|b|
b.local_variable_set(:git_tag, git_tag)
b.local_variable_set(:sha256, sha256)
})
end
def fetch(url, depth = 0)
res = Net::H... |
class Enquit < ActiveRecord::Base
belongs_to :user
has_many :votes
validates :title, presence: true
validates :option1, presence: true
validates :option2, presence: true
validates :option3, presence: true
validates :option4, presence: true
end
|
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :post
validates_presence_of :title, message: "The title cannot be blank."
validates_presence_of :body, message: "Your comment cannot be blank."
end
|
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :use_mobile_view
helper_method :better_time
$markdown = Redcarpet::Markdown.new(Redcarpet::Render::H... |
# *******************************_lucky_sevens?_*******************************
# Write a function lucky_sevens?(numbers), which takes in an array of integers and returns true if any three consecutive elements sum to 7.
# lucky_sevens?([2,1,5,1,0]) == true # => 1 + 5 + 1 == 7# lucky_sevens?([0,-2,1,8]) == true # => -... |
require 'chemistry/element'
Chemistry::Element.define "Lead" do
symbol "Pb"
atomic_number 82
atomic_weight 207.2
melting_point '600.75K'
end
|
class Api::PhotosController < ApplicationController
before_action :require_logged_in!
def index
@photos = current_user.fetch_photos(fetch_params)
.includes(:user)
.includes(:likes)
.includes(:comments)
if @photos
render :index
else
render json: {}
end
end
def cre... |
# frozen_string_literal: true
class Rogare::Commands::QuickCheck
extend Rogare::Command
command Rogare.prefix
usage '`!%` - Quick check of things'
handle_help
match_empty :execute
def execute(m, _param)
if defined? Rogare::Commands::Project
pro = Rogare::Commands::Project.new
pro.show_cur... |
class Task
# : signifies symbol, one location in memory entire time
attr_accessor :title
attr_accessor :priority
attr_accessor :completed
def initialize(title, priority = 10)
self.title = title
self.priority = priority
self.completed = false
end
def complete?()
completed
end
def complete
self.c... |
Rails.application.routes.draw do
# CLIENT SITE
scope module: :client do
root to: 'welcome#index'
match 'auth/:provider/callback', to: 'sessions#create', via: [:get, :post]
match 'auth/failure', to: redirect('/'), via: [:get, :post]
match 'signout', to: 'sessions#destroy', as: 'signout', via: [:get,... |
require_relative "./shared/intcode"
TILES = [".", "|", "#", "_", "o"].freeze
def render(tiles)
screen = Hash.new(0)
score = 0
tiles.each_slice(3) do |x, y, value|
if x == -1 && y == 0
score = value
else
screen[[x, y]] = value
end
end
[screen, score]
end
cabinet = Computer.new(INTC... |
class Artists::QuotationsController < ApplicationController
include SlugRedirectable
before_action :authenticate_user!, except: [:index]
before_action :set_artist, only: [:new, :create, :index, :edit, :update]
before_action :set_quotation, only: [:edit, :update, :destroy, :publish, :unpublish]
def index
... |
# frozen_string_literal: true
class Queries::SeriesQuery < Queries::BaseQuery
type Types::SeriesType.connection_type, null: false
argument :ids, [ID], required: false, default_value: nil
argument :resource_type, String, required: false, default_value: nil
def resolve(ids:, resource_type:)
scope(ids, resou... |
class Visit
include Mongoid::Document
include Mongoid::Timestamps
field :referral_link, :type => String
field :ip_address, :type => String
embedded_in :url
validates_presence_of :url
validates_associated :url
end
|
class Prey < Cask
url 'http://preyproject.com/releases/current/prey-0.6.2-mac-batch.mpkg.zip'
homepage 'https://preyproject.com'
version '0.6.2'
sha1 'c6c8de5adeb813ecfd517aab36dc2b7391ce8498'
install 'prey-0.6.2-mac-batch.mpkg'
uninstall :pkgutil => 'com.forkhq.prey'
def caveats; <<-EOS.undent
Prey ... |
class StatisticsIndexTestTemplate < StatisticsIndexTemplate
def initialize
super
@state = 'active'
@index_name = "#{@configuration['index_patterns'][0..-3].gsub(/^stats-/, 'tests-')}"
@configuration.delete('aliases')
@configuration['index_patterns'] = "#{@index_name}-*"
end
end
|
FactoryBot.define do
factory :user do
nickname { Faker::Internet.username(specifier: 40) }
email { Faker::Internet.unique.free_email }
password = Faker::Lorem.characters(number: 6, min_alpha: 1, min_numeric: 1)
password { password }
password_confirmation { password }
familyname { Gimei.last.ka... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
private
def current_usr
@current_usr ||= if session[:usr_id]
Usr.find_by_id(session[:usr_id])
end
end
helper_method :current_usr
end
|
require 'test_helper'
class OAuth2::TokenControllerTest < ActionDispatch::IntegrationTest
test 'should fail /oauth2/token with invalid Content-Type' do
post(oauth2_token_path(ServiceProvider.first.id), headers: { 'CONTENT_TYPE': 'text/plain' })
assert_response(:bad_request)
json = JSON.parse(response.bod... |
class Queue
def initialize
@queue = []
end
def enqueue(el)
queue << el
end
def dequeue
queue.shift
end
def show
queue
end
private
attr_accessor :queue
end
queue = Queue.new
queue.enqueue("i")
queue.enqueue("love")
queue.enqueue("ruby")
p queue.show
queue.dequeue
p queue.show
|
class UserSerializer < ActiveModel::Serializer
attributes :id, :first_name, :last_name, :username, :expenses, :income
has_many :debts
has_one :plan
end
|
module Parser
class PageView
def initialize(log_path)
@log_path = log_path
end
def all
sort
end
def uniq
sort(uniq: true)
end
private
def sort(uniq: false)
scope = logs
scope.uniq! if uniq
scope.
group_by(&:path).
map { |path... |
#!/usr/bin/env ruby
require_relative '../lib/move.rb'
# Code your CLI Here
#Lines 8 and 9-13 Display opening message and begininng board state
puts "Welcome to Tic Tac Toe!"
board = [" "," "," "," "," "," "," "," "," "]
puts display_board(board)
puts "Where would you like to go?"
puts "Please enter a number 1-9:"
#... |
require 'spec_helper'
describe ResourcesController do
let(:user) { create :member_user }
let(:book) { create :book }
let(:resource) { create :resource, :user => user, :book => book }
describe "GET#new" do
describe "unauthenticated" do
it "should not allow anonymous access" do
get :new
... |
require 'spec_helper'
feature "Viewing activities" do
let!(:user) { FactoryGirl.create(:user) }
let!(:activity) { FactoryGirl.create(:activity) }
before do
sign_in_as!(user)
define_permission!(user, :view, activity)
end
scenario "Listing all activities" do
FactoryGirl.create(:activity, name: "H... |
require 'test_helper'
class BruteForceTest < Minitest::Test
def test_has_a_version_number
refute_nil ::BruteForce::VERSION
end
def test_starts_with_option
generator = ::BruteForce::Generator.new(starts_from: 'abcdef')
assert_equal(generator.next, 'abcdef')
end
def test_letters_option
genera... |
# ------------------------------------------------------------------
# Der Twitter-User.
#
# In der Tabelle werden nur wenige Kernattribute gehalten.
#
# Attribute:
# t.string "name"
# t.string "tw_id_str"
# t.string "screen_name"
# t.integer "followers_count"
# t.integer "friends_count"
# t.s... |
class Cour < ApplicationRecord
validates :title, presence: true, length: { minimum: 5 }
has_many :lecons, dependent: :destroy
end
|
control 'redis-server-0' do
impact 1.0
title 'ensure redis-server presence'
describe port(6379) do
it { is_expected.to be_listening }
end
describe service('redis-server') do
it { should be_enabled }
it { should be_running }
end
end
control 'postgresql-0' do
title 'ensure postgresql presence... |
# ref: https://en.wikipedia.org/wiki/Pet#Domesticated
PET_SPECIES = %w(alpaca camel cat cow dog donkey ferret goat hedgehog horse llama pig rabbit fox rodent sheep buffalo yak bird fish).freeze
|
class X8664ElfBinutils < Formula
desc "GNU binutils for i386 & x86_64 (ELF/EFI PE)"
homepage "http://www.gnu.org/software/binutils/"
url "http://ftpmirror.gnu.org/binutils/binutils-2.26.tar.bz2"
sha256 "c2ace41809542f5237afc7e3b8f32bb92bc7bc53c6232a84463c423b0714ecd9"
def install
args = []
args << "-... |
require 'rails_helper'
describe 'GET /v1/users' do
let(:path) { '/v1/users' }
it 'should get index' do
get_user path
expect(response).to be_success
expect(response.status).to eq 200
end
end
|
class User
# attr_accessor :username
attr_reader :username
attr_writer :username
@@all = []
def initialize(username)
@username = username
@@all << self
end
def post_tweet(message)
@tweet = Tweet.new(self, message)
end
def self.all
@@all
end
def tweets
Tweet.all.select do |... |
require 'concurrent/executor/ruby_thread_pool_executor'
module Concurrent
# @!macro cached_thread_pool
class RubyCachedThreadPool < RubyThreadPoolExecutor
# Create a new thread pool.
#
# @param [Hash] opts the options defining pool behavior.
# number of seconds a thread may be idle before it is... |
# frozen_string_literal: true
version = File.read(File.expand_path('../VERSION', __dir__)).strip
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = 'problem_details-rails'
spec.version = version
spec.authors ... |
# frozen_string_literal: true
class FakeBroker
def initialize
@messages = {}
@partition_errors = {}
end
def messages
messages = []
@messages.each do |topic, messages_for_topic|
messages_for_topic.each do |partition, messages_for_partition|
messages_for_partition.each do |message|
... |
FactoryBot.define do
factory :user do
name { "sample" }
email { "sample@123.com"}
password {"sample123"}
password_confirmation {"sample123"}
end
# FactoryBot.create(:user_with_tasks) do
# transient do
# tasks_count 3
# end
# after(:create) do |user, evaluator|
# create_li... |
require File.join(File.dirname(__FILE__), '..', 'test_helper')
# index
# -----
class IQ::Crud::Actions::Index::IndexTest < Test::Unit::TestCase
def setup
['', 'admin_'].each do |prefix|
send(prefix + 'crudified_instance').stubs(:find_collection).with().returns(valid_collection)
end
end
def test... |
require "spec_helper"
describe ReuniaosController do
describe "routing" do
it "routes to #index" do
get("/reuniaos").should route_to("reuniaos#index")
end
it "routes to #new" do
get("/reuniaos/new").should route_to("reuniaos#new")
end
it "routes to #show" do
get("/reuniaos/1"... |
module Cabinet
class AdminController < ApplicationController
before_action :authenticate_user!
before_action :authorize_user!
layout "admin"
def authorize_user!
return render_not_authorized if current_user.customer?
end
end
end |
module HTTPalooza
# Request presents a standard interface for describing an HTTP request that Players can translate into the underlying library's representation.
class Request
STANDARD_METHODS = [:get, :post, :put, :patch, :delete, :options, :head]
attr_reader :url, :method, :params, :payload, :headers
... |
module BackpackTF
module Price
# Process reponses from IGetPrices
class Response < BackpackTF::Response
@response = nil
@items = nil
def self.raw_usd_value
@response['raw_usd_value']
end
def self.usd_currency
@response['usd_currency']
end
def self.u... |
RedisAdmin::Application.routes.draw do
root :to => 'keys#index'
end
|
#TODO
# create second array for user input
# merge those two arrays
#Add the arrays
# create second array for user input
# add the arrays
# reset = clear the second array
require 'colorize'
require 'pry'
class Answers
attr_accessor :response, :combo, :user_arr
#comment
def initialize
@response_easter_e... |
require 'spec_helper'
describe OpenAssets::Protocol::AssetDefinitionLoader, :network => :testnet do
describe 'initialize' do
context 'http or https' do
subject{
OpenAssets::Protocol::AssetDefinitionLoader.new('http://goo.gl/fS4mEj').loader
}
it do
expect(subject).to be_a(OpenA... |
# frozen_string_literal: true
FactoryBot.define do
factory :item do
name { Faker::Lorem.words(3).join }
end
end
|
class OrdersController < ApplicationController
before_action :authenticate_user!
# TODO: talvez possa fazer tudo com o edit e o update
def answer
@order = Order.find(params[:id])
end
def index
@status = params[:status]
unless @status.nil?
@orders = Order.where(status: @status).order(creat... |
class Article < ApplicationRecord
#association
has_many :carousels, as: :carouselable, dependent: :destroy
accepts_nested_attributes_for :carousels, allow_destroy: true
#carrierwave uploader
mount_uploader :image, ImageUploader
mount_uploader :og_image, ImageUploader
#tagging
acts_as_taggable_on :t... |
class RenameColumnInRectangles < ActiveRecord::Migration
def change
rename_column :rectangles, :fillColor, :fill_color
end
end
|
require "spec_helper"
describe Destructive do
context "when the user creates 5 destructive reports on 2012" do
before { Timecop.freeze Time.new.change(year: 2012, month: 1, day: 1) }
before do
5.times do
r = Report.new
dt = Destructive.new
dt.report = r
if not dt.save
... |
require "net/http"
require "json"
require "openssl"
# Interface for connecting with M2X API service.
#
# This class provides convenience methods to access M2X most common resources.
# It can also be used to access any endpoint directly like this:
#
# m2x = M2X::Client.new("<YOUR-API-KEY>")
# m2x.get("/some_pat... |
#
# Copyright 2013, Seth Vargo <sethvargo@gmail.com>
# Copyright 2013, Opscode, Inc.
#
# 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
#
# Unl... |
module Ai
class Tile
attr_accessor :x, :y, :value, :merged
def initialize x, y, value = 2, merged = false
@x = x;
@y = y;
@value = value;
@merged = false
end
end
end |
class AddColumnsToTasks < ActiveRecord::Migration
def change
# modify column
change_column :tasks, :description, :text
# adding new columns
add_column :tasks, :category, :string
add_column :tasks, :sub_category, :string
add_column :tasks, :created_by, :string
add_column :tasks, :assig... |
class AnswersController < ApplicationController
before_action :authenticate_user!
before_action :load_question
before_action :load_answer, except: :create
def create
@answer = @question.answers.create(answer_params.merge(user: current_user))
end
def update
@answer.update(answer_params) if current_... |
class CreateTalks < ActiveRecord::Migration
def change
create_table :talks do |t|
t.integer :sender_user_id
t.integer :sender_car_id
t.integer :receiver_user_id
t.integer :receiver_car_id
t.boolean :received
t.timestamps
end
add_index :talks, :sender_user_id
add_i... |
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string
# email :string
# login :string
# created_at :datetime not null
# updated_at :datetime not null
# password_digest :string
# remember_d... |
class CategoryPage < SitePrism::Page
element :parent_category_dropdown, :xpath, ".//form[@id='commentReplyForm']//div/select"
element :title_field, :xpath, "//*[@id='commentReplyForm']//input[@name='title']"
element :summary_field, :xpath, "//*[@id='commentReplyForm']//input[@name='desc']"
element :tags_field,... |
json.array!(@prodcutos) do |prodcuto|
json.extract! prodcuto, :id, :codigo, :nombre, :fecha_vencimiento, :cantidad
json.url prodcuto_url(prodcuto, format: :json)
end
|
require 'rails_helper'
describe 'Comment' do
it 'is valid with a user' do
expect(create_comment).to be_valid
end
it 'should have an associated user' do
user = create_user
comment = create_comment(user_id: user.id)
expect(comment.user_id).to eq(user.id)
end
end
|
class Book < ActiveRecord::Base
attr_accessible :title
has_many :pictures, :dependent => :destroy
belongs_to :user
end
|
# frozen_string_literal: true
class UsersController < ApplicationController
# POST /users
def create
form = Account::SignUpForm.new(user_params)
if form.save
render(json: SimpleResponse.call(200, 'ok'))
else
render(json: SimpleError.call(400, form.errors))
end
end
# GET /users
d... |
class PurchasesController < ApplicationController
before_action :logged_in_user, only: [:create]
def create
secure_post = params.require(:purchase).permit(:guitarid, :delivery, :address, :country)
@purchase = current_user.purchases.build(secure_post)
if @purchase.save
flash[:s... |
# frozen_string_literal: true
require 'datadog/lambda'
require 'yake'
module Yake
module Datadog
class MockContext < Struct.new(
:clock_diff,
:deadline_ms,
:aws_request_id,
:invoked_function_arn,
:log_group_name,
:log_stream_name,
:function_name,
:memory_limit_in_... |
require 'rails_helper'
RSpec.describe UsersHelper, type: :helper do
describe '#super_admin?' do
context 'when user is super admin' do
let(:user) { double(email: 'admin@arsenal.com.br') }
it 'returns true' do
expect(helper.super_admin?(user)).to be_truthy
end
end
context 'when ... |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
require 'rubygems'
require 'rexml/document'
#require 'bells/recipes/apache' # This one requires the Bells gem
set :application, "musicbox"
set :domain, "stg.mobile"
role :app, "stg.mobile"
# Set the Unix user and group that will actually perform each ta... |
class ReplaceSharedStringAst
attr_accessor :shared_strings
def initialize(shared_strings)
@shared_strings = shared_strings.map do |s|
s[/^(.*?)\n$/,1]
end
end
def map(ast)
if ast.is_a?(Array)
operator = ast.shift
if respond_to?(operator)
send(operator,*ast)
... |
class SubtaskSerializer
include FastJsonapi::ObjectSerializer
attributes :title, :estimated_duration
end
|
require 'test_helper'
class AllDelegatesControllerTest < ActionController::TestCase
setup do
@all_delegate = all_delegates(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:all_delegates)
end
test "should get new" do
get :new
assert_res... |
class Site < ActiveRecord::Base
extend DeleteableModel
has_and_belongs_to_many :users, join_table: "site_users"
attr_accessible :description
@@gridColumns = {:id => "Id", :name => "Name", :description => "Description", :created_at => "Created At"}
@@gridRenderers = {:created_at => 'dateRenderer'}
@@colu... |
# Install StreamMachine
include_recipe "nodejs"
include_recipe "git"
if node.streammachine.install_ffmpeg
include_recipe "streammachine::ffmpeg"
end
if node.streammachine.install_redis
include_recipe "streammachine::install_redis"
end
# -- Create our User -- #
user node.streammachine.user do
action :creat... |
require "spec_helper"
describe ActiveRecord::Turntable::Migration do
describe ".target_shards" do
subject { migration_class.new.target_shards }
context "With clusters definitions" do
let(:migration_class) {
Class.new(ActiveRecord::Migration[5.0]) {
clusters :user_cluster
}
... |
# frozen_string_literal: true
module Bolt
module Transport
class Local < Sudoable
OPTIONS = {
"interpreters" => "A map of an extension name to the absolute path of an executable, "\
"enabling you to override the shebang defined in a task executable. The "\
... |
class Subway < ActiveRecord::Base
has_many :restaurant_subways, dependent: :destroy
has_many :restaurants, :through => :restaurant_subways
end |
require "test_helper"
describe ArInterval do
it "has a version number" do
refute_nil ::ArInterval::VERSION
end
before do
Occurence.destroy_all
end
it "has Occurence test model configured" do
assert Occurence.count == 0
end
describe "one occurence" do
before do
Occurence.create(
... |
class CvSweeper < ActionController::Caching::Sweeper
observe Person, Company, Project, Responsibility, Skill, School, Task
def after_create(record)
expire_page root_url
end
def after_update(record)
expire_page root_url
end
def after_destroy(record)
expire_page root_url
end
end |
require_relative 'db_connection'
require_relative '01_mass_object'
require 'active_support/inflector'
require 'debugger'
class MassObject
def self.parse_all(results)
parsed_all = []
results.each do |result|
object = self.new(result)
parsed_all << object
end
parsed_all
end
end
class SQLO... |
require 'i18n'
class EventNotificationJob < ActiveJob::Base
queue_as :notifications
def perform(event_id, chat_id)
event = Event.find_by(id: event_id).to_s
Telegram.bot.send_message(chat_id: chat_id, text: I18n.t('event_string', event: event))
end
end
|
class New < ActiveRecord::Base
validate :validation_method
attr_accessible :photo, :title, :description, :show, :date, :photo_file_name, :link
has_attached_file :photo,
:styles => {
:thumb=> "50x45#",
:medium => "110x100#",
:large... |
class CreateUsers < ActiveRecord::Migration[5.0]
# Set'up'
def up
create_table :users do |t|
# Longhand
t.column "name", :string
# Shorthand
t.boolean "anonymous", :default => false
t.timestamps
# 't.timestamps' auto creates both 'created_at' and 'updated_at' fields
# ... |
class BirthdayDealVoucherStateTransition < ActiveRecord::Base
belongs_to :birthday_deal_voucher
end
|
require_relative 'rental'
require_relative 'rental_action'
class RentalModification
attr_reader :id, :rental, :start_date, :end_date, :distance
def initialize(args)
@id = args[:id]
@rental = args[:rental]
@start_date = args[:start_date]
@end_date = args[:end_date]
@distance = args[:distance]
... |
class TagsController < ApplicationController
caches_page :index
# GET /blogs/1/tags
# GET /blogs/1/users/1/tags
def index
@blog = Blog.published.find(params[:blog_id])
if params[:user_id]
@user = User.find(params[:user_id])
@tags = @blog.tags.by_user(@user)
elsif @blog
@tags = @b... |
require_relative '../lib/identifier_replacer'
describe IdentifierReplacer do
let(:code) do
%q^this.is(someCode)^
end
let(:words) do
['the', 'bear', 'car']
end
it 'replaces the code with the words' do
expect(IdentifierReplacer.replace(code, words)).to eq 'the.bear(car)'
end
end
|
class ShippingAddressesController < ApiController
load_and_authorize_resource
before_action :authenticate_user!
before_action :set_shipping_address, only: [:update, :deactivate]
# POST /shipping_addresses
def create
begin
@shipping_address = ShippingAddress.create!(shipping_address_params)
... |
class Customer < ActiveRecord::Base
attr_accessible :email, :first_name, :last_name, :anonymous_donation,
:billing_address_attributes, :terms, :communicate_with_site
has_many :certificates
has_many :newsletter_subscriptions, :dependent => :destroy
has_address :billing
accepts_nested_attributes_for :billi... |
# FIND
# Find out how to access files with and without code blocks. What is the benefit of the code block?
# Using File.open
# Without a block, we open a file that is always open for our use throughout the code.
# It will only close if we tell it to or the program terminates
# also what is returned by File... |
class Api::AuthorsController < ApplicationController
def index
@authors = Author.all
render 'index.json.jbuilder'
end
def create
@author = Author.new(
first_name: params[:first_name],
last_name: params[:last_name],
biography... |
class AddTableAppointmentsServices < ActiveRecord::Migration
def up
create_table :appointments_services, id: false do |t|
t.integer :appointment_id
t.integer :service_id
end
end
def down
drop_table :appointments_services
end
end
|
module CDI
module V1
module ServiceConcerns
module MultimediaParams
extend ActiveSupport::Concern
WHITELIST_ATTRIBUTES = [
:file,
:link,
:name,
:category_ids,
:tags
]
included do
def multimedia_params
... |
require "openssl"
require "webrick"
require "logstash/namespace"
require "logstash/inputs/base"
require "thread"
# Reads log events from a http endpoint.
#
# Configuring this plugin can be done using the following basic configuration:
#
# input {
# http { }
# }
#
# This will open a http server on port ... |
class ExperimentWatcher
def self.watch_experiments
Rails.logger.debug('[experiment_watcher] Watch experiments')
Thread.new do
while true do
Rails.logger.debug("[experiment_watcher] #{Time.now} --- running")
DataFarmingExperiment.get_running_experiments.each do |experiment|
Ra... |
require 'rails_helper'
RSpec.describe Home, type: :model do
describe "Associations" do
it { should have_many(:rents) }
end
end |
class CreateDevices < ActiveRecord::Migration[6.0]
def change
create_table :devices do |t|
t.integer :actor_id, null: false
t.string :actor_type, null: false, limit: 32
t.integer :user_id, null: false
t.string :uuid, null: false, limit: 64
t.string :refresh_token, null: false, limit:... |
class CreateContracts < ActiveRecord::Migration
def change
create_table :contracts do |t|
t.string :contract_no
t.date :contract_start
t.date :contract_end
t.string :duty_officer
t.decimal :fees, precision: 8, scale: 2
t.timestamps null: false
end
end
end
|
phone_book = {
"Winston Salem" => "336",
"High Point" => "336",
"Kernersville" => "336",
"Thomasville" => "336",
"Rural Hall" => "336",
"Charlotte" => "704",
"Imaginville" => "336",
"Here" => "704",
"Billyville" => "555",
"Wonkaland" => "619",
}
def display_city(somehash)
somehash.each { |k, v| p... |
class AddColumnCities < ActiveRecord::Migration[5.2]
def change
add_column :cities, :map, :text
add_column :cities, :facility, :text
add_column :cities, :distance, :string
add_column :cities, :url, :string
end
end
|
#!/usr/bin/env ruby
require 'openssl'
# define CA paths
@katello_default_ca = '/etc/pki/katello/certs/katello-default-ca.crt'
@katello_server_ca = '/etc/pki/katello/certs/katello-server-ca.crt'
@puppet_ca = '/var/lib/puppet/ssl/certs/ca.pem'
# set FQDN to variable
fqdn = `hostname -f`.chomp
# define SSL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.