text stringlengths 10 2.61M |
|---|
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{aclatraz}
s.version = "0.1.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Chris Kowalik"]
s.date = %q{2011-08-04}
s.description = %q{Extremaly fast, flexible and in... |
def set_port
#reads the port from file
port = ((File.open("/home/pablo/Desktop/TercerIntento/V8/spec/Test_settings.txt", &:readline)).split)[2]
#if there is a problem readig the file the test uses the default value 8080
port ||= 8080
return port
end
def user_input(input)
allow($stdin).to receive(:gets).and... |
class Post < ActiveRecord::Base
#attr_accessible :photo, :titulo
FOTOS= File.join Rails.root, 'public', 'photo_store'
after_save :guardar_foto
def photo=(file_data)
unless file_data.blank?
@file_data=file_data
self.extension=file_data.original_filename.split('.').last.downcase
end
end
def has_ph... |
# frozen_string_literal: true
require "economic/entity"
module Economic
# Represents a creditor in E-conomic.
#
# API documentation: https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=Company_GetData
#
# Examples
#
# # Get company:
# creditor = economic.company.get
#
class Compan... |
# frozen_string_literal: true
module ViewComponent
module Storybook
module MethodArgs
##
# Class representing arguments passed to a method which can be validated
# against the args of the target method
# I addition the args and kwargs can contain Controls the values of which can
# b... |
# frozen_string_literal: true
module PassingTestsHelper
def result_percent_color(passing_test)
percent = passing_test.result_percent
if passing_test.test_passed?
"<span style='color: green'>#{percent}%</span>".html_safe
else
"<span style='color: red'>#{percent}%</span>".html_safe
end
en... |
#encode: US-ASCII
require "zlib"
require 'openssl'
require 'pp'
class String
def to_binary
str = self.clean
target = ''
while str.length != 0
arr = str.unpack("a2a*")
int = arr[0].hex
target += [int].pack("C")
str = arr[1]
... |
RSpec.describe JobsCrawler do
it "has a version number" do
expect(JobsCrawler::VERSION).not_to be nil
end
it "responds to crawl" do
is_expected.to respond_to(:crawl)
end
end
|
module CourtRemindersImporter
def self.generate_reminders(court_dates, court_locations, court_date_csv, options = {})
time_zone_offset = '-0600' # Make sure this is by instance eventually
total_rrs = 0
Message.transaction do
Rails.logger.tagged('court reminders') do
Rails.logger.info { 'Begi... |
class AddColumnsToProject < ActiveRecord::Migration[5.1]
def change
# 对应项目经理(仅为 form, 不真实记录)
add_column :projects, :pm_id, :integer
# 项目级别
add_column :projects, :project_class, :string
# 客户名
add_column :projects, :customer_name, :string
# 客户联系人姓名
add_column :projects, :customer_contact... |
class MockAnalytics
attr_accessor :identifications
def initialize
self.identifications = []
end
def identify(options = {})
self.identifications << options
end
end
Before do
@unmocked_analytics = Analytics
silence_warnings do
Analytics = MockAnalytics.new
end
end
After do
silence_warnin... |
class AddEditorsReservesIndex < ActiveRecord::Migration[6.0]
def change
add_index :editors_reserves, [:reserve_id, :editor_id]
add_index :editors_reserves, [:editor_id, :reserve_id]
end
end
|
class GroupsController < ApplicationController
def index
# イベントデータの一覧を返す
render json: Group.all
end
def show
# 指定したidのイベントデータを返す
render json: Group.find(params[:id])
end
def create
# パラメータの値でイベントデータを作成する
group = Group.new(group_params)
if group.save
render json: group
... |
require('rspec')
require('phoneNumber')
describe(PhoneNumber) do
before() do
PhoneNumber.clear()
end
describe('#area_code') do
it('returns the area code of the phoneNumber') do
test_phoneNumber = PhoneNumber.new(213)
expect(test_phoneNumber.area_code()).to(eq(213))
end
end
describe(... |
class Producto
def initialize(this,tipo,material,identificacion)
@tipo = tipo
@material = material
@identificacion = identificacion
end
def tipo
return @tipo
end
def material
return @material
end
def identificacion
return @identificacion
end
def tipo=(tipo)
@tipo ... |
require "capistrano/node-deploy"
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.c... |
class AddDescriptionAndPublicateDateToOffers < ActiveRecord::Migration[6.1]
def change
add_column :offers, :description, :text
add_column :offers, :publication_date, :date
end
end
|
class MaintenancePlan < ActiveRecord::Base
attr_accessible :enterprise_id, :name, :description, :task_name
has_many :plan_tasks
accepts_nested_attributes_for :plan_tasks, :reject_if => lambda { |a| a[:task_id].blank? }, :allow_destroy => true
attr_accessor :task_name
end
|
#!/usr/bin/env ruby
require "fuzz"
TOKENS_DIRECTORY = File.expand_path("~/.password-store/tokens")
class Token
def initialize(gpg_file_path)
@path = gpg_file_path
end
def to_s
path.split("/").last.sub(".gpg", "")
end
def totp_code
`~/.bin/2fa #{ to_s }`.strip
end
private
attr_reader :... |
# 7-1
# 問1
=begin
def order
puts "カフェラテをください"
end
order
# 7-2
# 問2
def area(x)
x * x
end
puts area(3)
# 問3
def dice
[1,2,3,4,5,6].sample
end
dice
# 7-3
# 問4
def order(drink)
puts "#{drink}をください"
end
order("カフェラテ")
order("モカ")
# 問5
def dice
x = [1,2,3,4,5,6].sample
if x = 1
puts "もう一回"
x = [1,2,3,4,5... |
class Model::Domain::ImagePromotion < Model::Domain::Content
attr_accessor :destination
attr_accessor :button_text
attr_accessor :internal_ref
def initialize
@title = "Promotion Title #{Time.current.strftime("%T")} #{String.random(4)}"
@internal_ref = "Promotion Internal Ref #{Time.current.strftime("%T... |
class Users::RegistrationsController < Devise::RegistrationsController
include UserAddress
include Rectify::ControllerHelpers
before_action -> { set_addresses current_user }, only: [:edit, :update]
def self.new_with_session(params, session)
super.tap do |user|
if data = session["devise.facebook_... |
require 'spec_helper'
describe "EventQueue" do
it "should return added event" do
q = RotRails::EventQueue.new
q.add("a", 100)
expect(q.get()).to eq ("a")
end
it "should return nil when no events are available" do
q = RotRails::EventQueue.new
expect(q.get()).to eq (nil)
end
it "should remove returned e... |
class PostsController < ApplicationController
before_action :authenticate_user!
def index
@posts = Post.all
@users = User.all
end
def new
@post = Post.new
end
def show
@post = Post.find(params[:id])
end
def edit
end
def like
@post = Post.find(params[:id])
@post.liked_... |
# TASK 980
module Cultivation
class CalculateProductCost
prepend SimpleCommand
attr_reader :current_user, :task_id, :task
def initialize(current_user, task_id)
@current_user = current_user
@task_id = task_id
@task = Cultivation::Task.find(task_id)
end
def call
task.estima... |
# required the original so that with can overwrite it
require 'net/sftp'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/module/delegation'
module Net
class SftpFile
attr_reader :name, :path
def initialize path
@path = path
@name = File.basename(pat... |
# frozen_string_literal: true
require_relative 'model'
# Candidate represents BambooHR's potential employee
class Candidate < Model
def initialize(hash)
read_from_hash!(hash)
self.city = address['city']
self.state = address['state']
self.country = address['country']
self.address = address['addre... |
module JackCompiler
module Transformer
class ScopeAnalyzer
def visit(node)
if node.kind == :subroutineDec
node.scope = node.subroutine_name
else
node.scope = node.parent&.scope || :class
end
node.descendants.each do |child|
child.accept(self)
... |
# encoding: UTF-8
require 'json'
class BusStopGroup < Delegator
attr_reader :bus_stops
# TODO: Block initializer
def initialize(arg)
super @bus_stops
case arg
when BusStop
@bus_stops = [arg]
when Array
@bus_stops = arg
end
end
def self.get_longest_common_prefix(str1, str2)... |
class Instructor < ApplicationRecord
has_one :account, as: :user
has_many :spin_classes
has_many :studios, through: :spin_classes
has_many :locations, through: :spin_classes
has_many :instructor_reviews
has_secure_password
end
|
# -*- encoding : utf-8 -*-
class Admin::CoursesController < ApplicationController
layout 'admin'
before_filter :get_admin
#before_filter :get_admin
# GET /admin/courses
# GET /admin/courses.json
def index
@courses = Course.order(:name).page(params[:page])
respond_to do |format|
format.html # i... |
class Book < ApplicationRecord
belongs_to :author
has_many :reviews
has_many :inventories
has_many :users, through: :inventories
has_many :book_clubs
end
|
module UserWithSummarySerializer
def UserWithSummarySerializer.serialize(user_with_summary_and_downlines)
return if user_with_summary_and_downlines.nil?
user_with_summary_and_downlines
end
end
|
require 'context-io/error/server_error'
module ContextIO
# Raised when Context.IO returns the HTTP status code 500.
#
# @api public
class Error::InternalServerError < ContextIO::Error::ServerError
end
end
|
require 'rails_helper'
RSpec.feature 'View pages', type: :feature, skip: 'Disabled for 30 Jun 2021 service closure' do
scenario 'Root URL should be the guidance page' do
visit '/'
expect(page).to have_selector 'h1', text: I18n.t('service_name')
end
scenario 'Navigate to guidance page' do
visit '/pag... |
require 'spec_helper'
describe "Menus" do
describe "Menu related pages" do
describe "Edit menu" do
it "should appropriate content" do
visit '/menus'
expect(page).to have_content('Admin Page - Edit Menu')
end
it "should have the correct title" do
visit '/menus'
expect(page).to have_t... |
require 'test_helper'
require 'cassandra_object/railties/controller_runtime'
class CassandraObject::Railties::ControllerRuntimeTest < MiniTest::Test
class TestRuntime
def self.log_process_action(payload)
['sweet']
end
def cleanup_view_runtime
12
end
def append_info_to_payload(payloa... |
require 'httparty'
require 'active_support/json/decoding'
require 'active_support/core_ext/object/to_param'
require 'active_support/core_ext/object/to_query'
require 'active_support/concern'
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/hash/deep_merge'
require 'active_support/core_ext/st... |
# Start out moving one unit to the right.
class VerticalStep < Step
attr_reader :x, :y_1, :y_2
def initialize(x, y_1, y_2)
@x = x
@y_1 = y_1
@y_2 = y_2
end
def self.new_paths(path)
[
path + [VerticalStep.up(path)],
path + [VerticalStep.down(path)]
]
end
def self.up(path)
... |
# ======================================
# = Script to wrap wkhtmltopdf in xvfb =
# ======================================
template '/usr/local/bin/wkhtmltopdf.sh' do
source "wkhtmltopdf.sh"
owner "deploy"
mode "0755"
end |
class CreateCurrencyRates < ActiveRecord::Migration[6.0]
def change
create_table :currency_rates do |t|
t.integer :code, null: false, default: 0
t.integer :name, null: false, default: 0
t.float :buy, null: false, default: 0.0
t.float :sell, null: false, default: 0.0
t.timestamps
... |
class TestPassage < ApplicationRecord
THRESHOLD = 85
belongs_to :user
belongs_to :test
belongs_to :current_question, class_name: 'Question', optional: true
before_validation :before_validation_set_first_question, on: :create
before_update :before_update_next_question
def completed?
current_question... |
class Parser
def initialize(file)
@string = open(file)
@headers = nil
@content =nil
@hashes = []
end
# Opens file and saves it to the instance of string. Called in intialize
def open(file)
@string = File.open(file, "r") do |f|
f.read
end
end
# Removes whitespace and CR/LF an... |
class AddLinkToEdPursuits < ActiveRecord::Migration[6.0]
def change
add_column :ed_pursuits, :link, :string
add_column :ed_pursuits, :short_description, :text
end
end
|
class NafSchema < ActiveRecord::Migration
def up
# Define a schema_name, the scheduling tables fall under:
schema_name = Naf.schema_name
# affinities
# names: normal, canary, perennial
# location: ip address
# application/release on machine: application-release-number
execute <<-SQL
... |
class Article < ActiveRecord::Base
def next
@article = Article.where(author_id: self.author_id).where("id > ?", self.id).order("id ASC").first || Article.where(author_id: self.author_id).first
end
def prev
@article = Article.where(author_id: self.author_id).where("id < ?", self.id).order("id DESC").first ... |
require 'httparty'
class CustomerClient
include HTTParty
base_uri "http://localhost:8080"
format :json
def self.register(cust)
post '/customers', body: cust.to_json,
headers: { 'Content-Type' => 'application/json', 'ACCEPT' => 'application/json' }
end
def self... |
class Api::VehiclesController < ApiController
filter_access_to :all
def index
@xml = Builder::XmlMarkup.new
@vehicles = Vehicle.all
respond_to do |format|
format.xml { render :vehicles }
end
end
def vehicle_details
@xml = Builder::XmlMarkup.new
@vehicles = Vehicle.search(params... |
class FontGidole < Formula
head "https://github.com/gidole/Gidole-Typefaces/raw/master/gidole.zip", verified: "github.com/gidole/"
desc "Gidole"
homepage "https://gidole.github.io/"
def install
parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEMP'] || '/tmp') ? '../' : ''
(share/"fonts").install "#{pa... |
# frozen_string_literal: true
module Vedeu
module Interfaces
# DSL for creating interfaces.
#
# @api private
#
class DSL
include Vedeu::Common
include Vedeu::DSL
include Vedeu::DSL::Cursors
include Vedeu::DSL::Border
include Vedeu::DSL::Geometry
include Vede... |
require "spec_helper" # TODO remove dependency by moving the concept of a time into extra class. FUCK YOU AcitveRecord!
describe "SinglesFormatter" do
describe "#as_text" do
let(:subject) { SinglesFormatter.new singles }
context "one single" do
let(:singles) { [Single.new(:time => 12320)] }
it ... |
class User < ActiveRecord::Base
has_many :locations, dependent: :destroy
has_many :friendships
has_many :friends, through: :friendships
before_save { self.email = email.downcase }
has_secure_password
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email,
presence: true,
fo... |
# frozen_string_literal: true
FactoryBot.define do
factory :contractor do
sequence(:contractor_name) { |n| "contractor-#{n}" }
address
end
end
|
# frozen_string_literal: true
require 'common/models/base'
module EVSS
module Letters
class BenefitInformation < Common::Base
attribute :monthly_award_amount, Float
attribute :service_connected_percentage, Integer
attribute :award_effective_date, DateTime
attribute :has_chapter35_eligibi... |
class EventsController < ApplicationController
before_filter :authenticate_manager!, :except => [:show, :attend]
# GET /events
# GET /events.xml
# def index
# @events = Event.all
# @title = "Campus Taps | Events"
#
# respond_to do |format|
# format.html # index.html.erb
# format.xm... |
class Pathfinder
def find_path(locations, distribution_point = DISTRIBUTION_POINT, nof_couriers = 1)
result = Array.new(nof_couriers) { |_index| [distribution_point] }
sorted_locations = locations.sort_by { |location| location.distance(distribution_point).to_m }
# iterate over locations and find nearest... |
require 'sinatra'
require 'sinatra/sequel'
require_relative 'config/database.rb'
root = ::File.dirname(__FILE__)
configure :development do
#set :database, "sqlite:///#{root}/data/spice.db"
set :database, ENV['DATABASE_URL']
set :show_exceptions, true
end
configure :production do
set :database, URI.parse(ENV[... |
require_dependency 'juridical/application_controller'
module Juridical
class ComplementsController < ApplicationController # :nodoc:
before_action :set_legal_advice, except: %i[update_status resend_email]
before_action :set_complements, only: %i[index create destroy update]
before_action :set_complement,... |
require 'rails_helper'
RSpec.describe "Languages management", :type => :request do
let(:user) { FactoryGirl.create(:user) }
let(:headers) { {'HTTP_X_USER_EMAIL': user.email, 'HTTP_X_USER_TOKEN': user.authentication_token, 'HTTP_ACCEPT': 'application/json'} }
let(:no_headers) { {'HTTP_ACCEPT': 'application/json... |
module SessionHelper
def session_logged_in?
!session[:user_id].nil?
end
def session_current_user
begin
@current_user ||= User.find(session[:user_id])
rescue ActiveRecord::RecordNotFound => e
session.clear
@current_user = nil
end
end
def session_logout
session.clear
e... |
require 'uri'
require 'net/http'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)
api_endpoins = {
"prod" => "https://api.mobile.azure.com",
"dev" => "https://bifrost-int.trafficmanager.net"
}
swagger_path = "/previe... |
class GameGif < ApplicationRecord
belongs_to :game
belongs_to :gif
end
|
# Write a method that implements a miniature stack-and-register-based programming language that has the following commands:
# n Place a value n in the "register". Do not modify the stack.
# PUSH Push the register value on to the stack. Leave the value in the register.
# ADD Pops a value from the stack and adds it to t... |
# --- Day 1: Not Quite Lisp ---
# Santa was hoping for a white Christmas, but his weather machine's "snow"
# function is powered by stars, and he's fresh out! To save Christmas, he
# needs you to collect fifty stars by December 25th.
# Collect stars by helping Santa solve puzzles. Two puzzles will be made
# available... |
require 'yaml'
module MasterRecord
class YAML
include Enumerable
def each
@datum.each do|k,v|
yield ([k] + @fields.map{|name,t| v[name.to_s]}).flatten
end
end
def self.load_file(fields,file)
datum = ::YAML.load_file(file)
new(fields,datum)
end
def initialize(f... |
module MarkdownHelper
def markdown(text)
text = text ? text : ""
options = {
filter_html: true,
hard_wrap: true,
space_after_headers: true,
fenced_code_blocks: true
}
extensions = {
autolink: true,
superscript: true,
disable_indente... |
class SetDefaultValueForZone < ActiveRecord::Migration
def change
change_column :adoption_requests, :zone, :string, :null => false, :default => ""
end
end
|
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# name :text
# content :text
# created_at :datetime not null
# updated_at :datetime not null
#
class Post < ApplicationRecord
def as_json(options={})
{
id: self.id,
name... |
class CentroRepository < BaseRepository
def initialize
super(:centros)
@table_join_prestaciones = :prestaciones_de_centros
end
def save(centro)
validate(centro)
id = insert(centro)
centro.id = id
centro
end
def add_prestacion_to_centro(centro, prestacion_id)
raise CentroYaContien... |
module CustomTokenResponse
def body
user_details = User.find(@token.resource_owner_id)
# call original `#body` method and merge its result with the additional data hash
super.merge({
email: user_details.email,
id: user_details.id,
avatar_url: user_details[:avatar_url]
})
end
end
|
Given(/^I am on the login page testing register$/) do
visit "http:localhost:8080/Mosaicss/login.jsp"
click_button("Register")
end
When(/^I fill in the username with halfond - register$/) do
fill_in('username', :with => 'halfond')
end
And(/^I fill in the password with password - register$/) do
fill_in('passwor... |
# 1) Cada maça custa R$ 0,30, porém, se levar uma dúzia ou mais, o preço de cada uma baixa para R$ 0,25.
# Considerando essa precificação, escreva uma função chamada "preco_maca" que deve receber como parâmetro a quantidade de maçãs e deve retornar o valor em reais a ser pago por elas.
# Valide se a quantidade é um nú... |
# bundle exec rspec spec/p03_hash_set_spec.rb
class HashSet
attr_reader :count
def initialize(num_buckets = 8)
@store = Array.new(num_buckets) { Array.new }
@count = 0
end
def insert(key) #
if !include?(key) #O(1) - iterate through bucket ~1 item per bucket
if @count < num_buckets #O(1) ope... |
require 'rest_client'
module Stanford
class AssetRepository
attr_reader :base
def initialize(base=nil)
base = Settings.asset_server.uri if base.nil?
base.chop! if /\/$/.match(base)
@base = base
end
#
# This method gets the thumbnail for the asset form the asset repository. Thu... |
class CreateDuties < ActiveRecord::Migration
def change
create_table :duties do |t|
t.string :flow
t.string :conteng
t.string :mainpoint
t.timestamps null: false
end
end
end
|
class MatchesController < ApplicationController
def index
@matches = Match.all
end
def show
@match = Match.find(params[:id])
end
def edit
@match = Match.find(params[:id])
end
def new
@match = Match.new({local_team_points: 0, visiting_team_points: 0})
end
def create
@match =... |
class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.string :prefix
t.string :first_name, null: false
t.string :last_name, null: false
t.string :email, null: false
t.string :landline
t.string :mobile
t.text :comment
# audit
... |
require "rails_helper"
RSpec.describe TripFamily do
context "associations" do
it { is_expected.to belong_to(:family) }
it { is_expected.to belong_to(:trip) }
end
context "validations" do
it { is_expected.to validate_presence_of(:family) }
it { is_expected.to validate_presence_of(:trip) }
end
e... |
class Piece
attr_reader :color
attr_accessor :pos
def initialize(board, pos, color)
@board = board
@pos = pos
@color = color
end
def attack_moves
moves
end
def valid_moves
moves.reject { |move| move_into_check?(move) }
end
def move_into_check?(end_pos)
# Duplicate the boa... |
class UserSerializer < ActiveModel::Serializer
attributes :id, :email, :username
has_many :books
has_many :following
end
|
class Comment < ApplicationRecord
default_scope { order(created_at: :asc) }
belongs_to :user
belongs_to :commentable, polymorphic: true
has_many :comments, as: :commentable, dependent: :destroy
has_many :reactions, as: :reactable, dependent: :destroy
end
|
# encoding: utf-8
class SessionsController < ApplicationController
def new
end
def create
user = User.authenticate(params[:session][:email],params[:session][:password])
if user.nil?
flash.now[:error] = "Invalid email/password combination"
render 'new'
else
# 어드민이면 관리페이지, 업체면 자기 페이지
sign_in use... |
class Recipe < ActiveRecord::Base
has many :user_recipes
belongs_to :user, through: :user_recipes
end
|
class AddIndexesToManyTables < ActiveRecord::Migration
def change
add_index "events", ["organizer_id"], :name => "index_events_on_organizer_id"
add_index "invites", ["event_id"], :name => "index_invites_on_event_id"
add_index "invites", ["user_id", "event_id"], :name => "index_invites_on_user_id_and_event... |
module ActionSubscriber
class Configuration
attr_accessor :allow_low_priority_methods,
:decoder,
:default_exchange,
:error_handler,
:heartbeat,
:timeout,
:host,
:hosts,
:... |
require 'rails_helper'
RSpec.describe Group, type: :model do
let(:my_group) { Group.create(name: 'Yoga') }
it { should have_and_belong_to_many(:users) }
it { should validate_presence_of(:name) }
describe "attributes" do
it "has name" do
expect(my_group).to have_attributes(name: 'Yoga')
end
... |
# 2017-07-25
# David Lin
# Method: Brute force, TLE
# @param {Integer[]} nums
# @return {Integer}
def triangle_number(nums)
nums.sort!
count = 0
for i in (0...nums.length)
for j in ((i+1)...nums.length)
for k in ((j+1)...nums.length)
if nums[i] + nums[j] > nums[k]
count += 1
e... |
class Skill < ApplicationRecord
belongs_to :experience
validates :name, :description, :level, presence: true
end
|
class User < ActiveRecord::Base
attr_reader :password
attr_accessible :username, :password, :password_confirmation, :admin
belongs_to :domain
validates :password, :confirmation => true, :length => { :minimum => 6 }, :unless => 'password.blank?'
validates :password, :presence => true, :on => :create
validat... |
class ProductPhoto < ApplicationRecord
belongs_to :product_article
validates :url, presence: true
end
|
ActiveAdmin.register Event do
index do
column :happened_at
column :source
column :external_reference
column :created_at
column :updated_at
actions
end
filter :source
filter :happened_at
show do
attributes_table do
row :id
row :happened_at
row :source
row :... |
require "csv"
@students = []
def print_header
print "The students of March 2015 cohort at Makers Academy\n"
print "--------------\n"
end
def print_students_list
@students.each_with_index do |student, index|
linewidth = 30
print "#{index + 1}. #{student[:name]} of #{student[:cohort]} cohort".ljust(linewi... |
class SoldItem < ActiveRecord::Base
belongs_to :invoice
belongs_to :store_item
attr_accessor :item_name
#validate :rate, :quantity, :numericality => { :greater_than_or_equal_to => 0 }, :allow_nil => true
validates_numericality_of :quantity, :only_integer => true, :greater_than => 0#,# :on => [:create, :updat... |
Gem::Specification.new do |s|
s.name = "riot-mongo_mapper"
s.version = "0.1.0"
s.required_rubygems_version = ">= 1.3.6"
s.authors = ["Arthur Chiu"]
s.date = Time.now.strftime("%Y-%m-%d")
s.description = "A collection of assertion macros for testing MongoMapper with Riot"
s.email = "mr.arthur.chiu@gmail.co... |
class NilClass
def email?(string)
false
end
def phone?(string)
false
end
end
class String
def email?(string)
email_regex = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
email_regex.match(string) ? true : false
end
def phone?
end
end |
class AddTrackOpensToDebates < ActiveRecord::Migration
def change
add_column :debates, :track_opens, :boolean, default: true
end
end
|
class Post < ApplicationRecord
validates :title, presence: true
validates :body, presence: true
has_many :likes, dependent: :destroy
end
|
require 'spec_helper'
describe 'Basic Icinga 2 Installation' do
context package('icinga2') do
it { should be_installed }
end
context service('icinga2') do
it { should be_enabled }
it { should be_running }
end
end
describe 'API Feature' do
context port(5665) do
it { should be_listening.with(... |
require 'rails_helper'
RSpec.describe Api::V1::Customers::CitiesController, type: :controller do
include Serializable
let(:customer) { FactoryBot.create(:customer) }
let(:city) { FactoryBot.create(:city) }
describe 'GET #index' do
it 'return 200 with array of cities' do
customer.acquire_access_token!... |
class LoginController < UIViewController
# include KVO
def viewDidLoad
super
self.edgesForExtendedLayout = UIRectEdgeAll
rmq.stylesheet = LoginStylesheet
rmq(self.view).apply_style :root_view
init_nav
# Create your views here
@username = rmq.append(UITextField, :username_text_field).... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.