text stringlengths 10 2.61M |
|---|
FactoryGirl.define do
factory :profile do
user { create(:user) }
photo_url "https://dummyimage.com/52x52/000/fff.png"
intro { FFaker::Lorem.sentence(3) }
sex { %w(male female other).sample }
religion { %w(Christian Jewish Agnostic).sample }
political_party { %w(Libertarian Republican Democrat)... |
require "json"
version = JSON.parse(File.read("package.json"))["version"]
Pod::Spec.new do |s|
s.name = "RNIronSource"
s.version = version
s.summary = "RNIronSource"
s.description = <<-DESC
Iron Source SDK React Native bridge
DESC
s.homepage = "http... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# NOTE: The following variables must be set according your aws configuration:
$AWS_ACCESS_KEY='XXXXXXXXXXXXXXXXXXXXXXX'
$AWS_SECRET_KEY='XXXXXXXXXXXXXXXXXXXXXXX'
$AWS_PRIVATE_KEY_PATH='key-devops-vagrant.pem'
$AWS_DEFAULT_REGION='us-east-1'
#$AWS_D... |
#!/usr/bin/env ruby
OPENSSL_REQ_CONFIG_FILEPATH = File.absolute_path(File.join(__dir__, "tmp/req.conf"))
OUTPUT_CSR_PATH = File.absolute_path(File.join(__dir__, "tmp/example.csr"))
OUTPUT_CSR_DESCRIPTION_PATH = File.absolute_path(File.join(__dir__, "tmp/example.csr.description.txt"))
OUTPUT_PRIVATE_KEY_PATH = File.abs... |
class AccountUpdateMailer < ApplicationMailer
default from: 'contact@email.com'
require 'sendgrid-ruby'
include SendGrid
def update_user(user)
from = Email.new(email: 'contact@email.com')
to = Email.new(email: user.email)
subject = 'Alert Account has been updated!'
content = Content.new(type:... |
Rails.application.routes.draw do
resources :definitions
devise_for :users
root 'definitions#index'
end
|
class AddUserIdAndRestrictionIndexToPosts < ActiveRecord::Migration
def change
add_index :posts, :restriction
add_index :posts, [:user_id, :restriction, :created_at]
end
end
|
class Todo < ActiveRecord::Base
has_many :categorizations, :dependent => :destroy
has_many :categories, :through => :categorizations
def self.incomplete
where(:completed_on => nil)
end
def self.complete
where("completed_on IS NOT NULL")
end
def complete!
update(:completed_on => Date.today)
... |
FactoryBot.define do
factory :building do
street_address { Faker::Address.street_address }
zip_code { "10004" }
end
end
|
require 'spec_helper'
class Tester
include DeployConfig::Parser
include DeployConfig::Validations
end
describe DeployConfig::Parser do
let(:tester) { Tester.new }
it 'parses application configuration' do
expect { tester.parse_application({}) }.to raise_error "App name required"
expect { tester.parse_... |
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :user_name, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
t.integer :role, :null => false, :default => 2
t.integer :created_by
t.int... |
require File.dirname(__FILE__) + '/spec_helper'
describe 'Test::Unit::TestCase', "when extended with mocked_fixtures" do
def klass
Test::Unit::TestCase
end
it "should include the mock_fixtures class method" do
klass.methods.should include('mock_fixtures')
end
it "should include aliased setup metho... |
ActiveAdmin.register NpcShift do
menu false
includes character_event: :character
batch_action :close_out_shifts do |ids|
batch_action_collection.find(ids).each do |ns|
ns.close_shift(ns.closing || Time.now)
end
redirect_to collection_path, notice: "#{[ids]} were closed out."
end
... |
class CreateFinanceCaches < ActiveRecord::Migration
def change
create_table :finance_caches do |t|
t.text :hist_data
t.text :curr_data
t.integer :category
t.references :company, index: { unique: false }, foreign_key: true
t.timestamps null: false
end
end
end
|
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'vedeu'
TESTCASE = '342_streams'
class DSLApp
Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
Vedeu.configure do
height 10
debug!
log Dir.tmpdir + '/vedeu.log'
renderers(Vedeu::Renderers::Terminal.new(
... |
module BookKeeping
VERSION = 4
end
class Complement
COMPLEMENTS = Hash[*%w(G C C G T A A U)].freeze
def self.of_dna(strand)
transcribe.(strand)
rescue KeyError
''
end
private_class_method
def self.transcribe
->(strand) { strand.chars.map(&COMPLEMENTS.method(:fetch)).join }
end
end
|
module Zillow
class API
attr_reader :key
def initialize
@key = ENV['ZILLOW_ZWSID']
connect!
end
def pull_property_details(zpid)
log("Starting pull_property_details for #{zpid}")
ZillowReport::HomeValuation.add_new_response(home_valuation(zpid).as_json.deep_symbolize_keys!)
... |
class RenameHours < ActiveRecord::Migration[5.1]
def change
rename_column :hours, :hours, :total_hours
rename_column :hours, :sno_hours, :total_sno_hours
end
end
|
class CreateMaids < ActiveRecord::Migration
def change
create_table :maids do |t|
t.string :name, null: false
t.string :floor
t.string :twitter_id
t.timestamps null: false
end
end
end
|
class DeleteTwitterIdToMaids < ActiveRecord::Migration
def change
remove_column :maids, :twitter_id
end
end
|
require 'spec_helper'
describe Youcrawl do
it 'has a version number' do
expect(Youcrawl::VERSION).not_to be nil
end
it 'parses json form a HTTP GET method' do
res = Helper.parse_url('http://jsonplaceholder.typicode.com/posts/1')
expect(res).not_to be nil
end
it 'turns a YouTube comment into a h... |
require 'logger'
class TestHost
include Sanford::Host
attr_accessor :init_has_been_called
init do
self.init_has_been_called = true
end
ip 'localhost'
port 12000
pid_file File.expand_path('../../../tmp/test_host.pid', __FILE__)
logger(Logger.new(File.expand_path("../../../log/test.log"... |
# `rails generate model` creates one class per model, but I'd rather
# have one file with the definitions of the entire intial database
# schema, and subsequent alterations will be in their own files.
class InitialSchema < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :email
... |
class Note < ApplicationRecord
has_many :todo_lists, dependent: :destroy
scope :asc_order, -> { order("created_at DESC") }
extend FriendlyId
friendly_id :title, use: :slugged
validates_presence_of :title
end
|
class Partner
class ProfileSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
attributes [*Partner::Profile.base_columns, :favorited]
def favorited
return false if DataCenter.current_user.nil?
DataCenter.current_user.favorited?(object.partner_id)
end
de... |
class UrlsController < ApplicationController
def index
@urls = Url.all
end
def new
@url = Url.new
end
def create
@url = Url.create url_params
@url['random_string'] = SecureRandom.base64(8)
@url.save
#binding.pry
redirect_to url_path(@url)
end
def show
#... |
RSpec.describe ApplicationController, type: :controller do
it 'responds ok' do
get :status
expect(response).to have_http_status(:ok)
end
it 'has no cache' do
expect(controller).to receive(:expires_now).once
get :status
end
end
|
class Bill < ActiveRecord::Base
belongs_to :shareholder
belongs_to :account
belongs_to :bill_type
has_many :bill_share_balance_entries, dependent: :destroy, autosave: true
has_one :bill_offset_balance_entry, dependent: :destroy, autosave: true
has_one :pot_balance_entry, dependent: :... |
class Madden18::RightTackleScorer < BaseScorer
def score
case @style
when 'balanced'
(@card.pass_block * 1.1) +
(@card.run_block * 1.1) +
(@card.impact_blocking * 1.1) +
(@card.strength * 1.0) +
(@card.awareness * 1.0) +
(@card.stamina * 1.0)... |
# frozen_string_literal: true
require 'sidekiq'
class Crawler
include Sidekiq::Worker
sidekiq_options retry: false
def perform
# Step 1: Get posts
posts = adapters.flat_map do |adapter|
adapter.fetch(hashtag: 'wearemagma', amount: 5)
end
# Step 2: Store them in db and separate new ones ... |
module Spree
# Singleton class to access the configuration object (Spree::AppConfiguration.first by default) and its preferences.
#
# Usage:
# Spree::Config[:foo] # Returns the +foo+ preference
# Spree::Config[] # Returns a Hash with all the application preferences
... |
class Review < ActiveRecord::Base
belongs_to :product
belongs_to :user
default_scope { order(created_at: :desc) }
delegate :firstname, :lastname, to: :user, prefix: true, allow_nil: true
validates :rating, :content, :user_id, presence: true
end
|
class RefundOrderWorker
include Sidekiq::Worker
def perform(order_id)
order = Order.find_by(id: order_id)
return if order.blank? || !!order.state.in?(["error", "cancelled"]) || order.provider_payment_charge_reference.blank?
Stripe::Refund.create({ charge: order.provider_payment_charge_reference })
... |
class Binary < ActiveRecord::Base
has_many :uploads
def file_data=(input_data)
self.data = input_data.read
end
end
|
module Fog
module Storage
class Aliyun
class Real
# Get details for object
#
# ==== Parameters
# * object<~String> - Name of object to look for
#
def get_object(object, range = nil, options = {})
options = options.reject {|key, value| value.nil?}
... |
require 'rails_helper'
RSpec.describe "authentications/index", :type => :view do
before(:each) do
assign(:authentications, [
Authentication.create!(
:user_id => 1,
:provider => "Provider",
:uid => "Uid"
),
Authentication.create!(
:user_id => 1,
:provider ... |
require "debugger"
namespace :cards do
desc "add cards to <deck> from the specified <file>"
task :import, [:deck, :file] => :environment do |t, args|
card=nil
File.open(args[:file]).each_line do |line|
next if (line=="" or line.match(/<xml>/i) or line.match(/<\//))
if line.match(/<card>/)
... |
class ChangeFilterIdFromIntegerToString < ActiveRecord::Migration
def self.up
change_column "comments", "filter_id", :string, :limit => 25
end
def self.down
change_column "comments", "filter_id", :integer
end
end
|
class BetMailer < ActionMailer::Base
helper BetsHelper
default from: "notifications@wager.com"
def invitee_confirmation(bet)
@bet = bet
@confirmation_url = bet_confirmation_url(@bet.id, @bet.confirmation_token)
@revise_terms_url = bet_revise_terms_url(@bet.id)
mail(to: @bet.invitee.email, subjec... |
module NotesHelper
include ActsAsTaggableOn::TagsHelper
def book_name
Book.find(params[:book_id]).name
end
end
|
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'permalink_constructor/version'
Gem::Specification.new do |gem|
gem.name = "permalink_constructor"
gem.version = PermalinkConstructor::VERSION
gem.authors = ["... |
require 'rspec/expectations'
RSpec::Matchers.define :have_a_default_of do |expected|
match do |actual|
actual == expected
end
failure_message_for_should do |actual|
"expected that the default value would be #{expected}, but it was #{actual}"
end
end
RSpec::Matchers.define :have_no_default do
match ... |
class Stack
attr_reader :stack
def initialize
@stack = []
end
def push(el)
stack.push(el)
end
def pop
stack.pop
end
def peek
stack.last
end
end
class Queue
attr_reader :stack
def initialize
@queue = []
end
def enqueue(el)
push(el)
end
def dequeue... |
# frozen_string_literal: true
class Course < ApplicationRecord
has_many :groups
has_many :themes
validates :name, presence: true,
length: { minimum: 3, maximum: 100 }
end
|
Pod::Spec.new do |s|
s.name = "SuperJJLib"
s.version = "0.0.3"
s.summary = "SuperJJLib"
s.description = "SuperJJLib 这是详细描述,字数一定要比s.summary长"
s.homepage = "https://github.com/wxj1996/SuperJJLib"
s.license = { :type => "MIT", :file => "FILE_LICENSE" }
s.author = { "w... |
require 'belafonte/errors'
require 'belafonte/help'
require 'belafonte/parser'
require 'belafonte/helpers'
require 'wrapomatic'
module Belafonte
module Rhythm
def execute!
parse_command_line
@command = arg(:command).shift if arg(:command)
kernel.exit calculate_exit_status
end
private
... |
require 'dm-timestamps'
class Peep
include DataMapper::Resource
property :id, Serial
property :content, String, length: 140, required: true
property :created_at, DateTime
property :updated_at, DateTime
belongs_to :user
has n, :replies
end
|
class Vigil
class Pipeline
def initialize(session, args={})
@session = session
post_initialize(args)
end
def run
notify(:build_started)
log = Log.new
res = Class.new {def self.status; true; end}
tasks.each {|t| log << res = t.call if res.status }
return Report.n... |
require 'vending'
describe Vending do
context 'has' do
let (:container){Container.new}
let (:machine) {Vending.new( products: container )}
it 'an accesible product container when created' do
expect(machine.products.items).to eq([])
end
end
context 'can' do
let (:cake) {double "cake", pric... |
shared_examples_for 'resources controller' do |resource_name|
http_login
let(:controller_name) { controller.controller_name }
let(:resource_params) do
attributes_for(resource_name).merge(name: name)
end
let(:name) { Faker::Name.name }
describe 'POST create' do
let(:params) do
{
... |
class InviteCode < ActiveRecord::Base
belongs_to :user, :counter_cache => true
belongs_to :signuped_user,:class_name=> "User",:foreign_key => "signuped_user_id"
validates_presence_of :email
validates_uniqueness_of :invite_code
def self.create_invite_code(email,user)
email = email.downcase.strip
... |
class UsersController < ApplicationController
before_action :set_user, only: [:show, :activate, :deactivate]
# GET /users
# GET /users.json
def index
# @users = User.all
# authorize @users
@users = policy_scope(User)
authorize @users
end
# GET /companies/1
# GET /companies/1.json
d... |
module Hermes
module Plugin
##
# Plugin for retrieving tweets based on usernames, hash tags or tweet IDs.
#
class Twitter
include Cinch::Plugin
match(/tw\s+(.+)/, :method => :execute)
match(/twitter\s+(.+)/, :method => :execute)
set :help => 'tw/twitter [USERNAME|HASH TA... |
require 'byebug/command'
module Byebug
#
# Execute a file containing byebug commands.
#
# It can be used to restore a previously saved debugging session.
#
class SourceCommand < Command
self.allow_in_control = true
def regexp
/^\s* so(?:urce)? (?:\s+(\S+))? \s*$/x
end
def execute
... |
require 'strscan'
input = File.readlines("/Users/hhh/JungleGym/advent_of_code/2021/inputs/day16.in")
class Packet
attr_accessor :version, :type, :body, :length_type, :parent, :subpackets, :scanner, :sp_size
def initialize v, t, parent, scanner
@version = v
@type = t
@parent = parent
@subpackets = ... |
require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "a user should enter a first name" do
user = User.new
assert !user.save
assert !user.errors[:first_name].empty?
end
test "a user should enter a last name" do
user = User.new
assert !user.save
assert !user.errors[:last_name].empty?
... |
class Topic < ApplicationRecord
belongs_to :user
has_many :comments, dependent: :destroy
validates :title, :description, presence: true
end
|
FactoryBot.define do
factory :product, class: "Product" do
producer_id { "1" }
product_name { "赤貝" }
content { "赤貝" }
picture { Rack::Test::UploadedFile.new(File.join("#{Rails.root}/public/pictures/products/akagai.JPG")) }
explanation { "赤貝" }
category_id { "1" }
price_tax_excluded { 12... |
class RemoveStatusFromOrdersItems < ActiveRecord::Migration[5.2]
def change
remove_column :orders_items, :status, :integer
end
end
|
module API
# WorkLogs API
class WorkLogs < Grape::API
before { authenticate! }
resource :projects do
desc "Returns all work logs for a given task."
get ":id/tasks/:task_id/work_logs" do
authorize! :read_project, user_project
@task = user_project.tasks.find(params[:task_id])
... |
#!/usr/bin/env ruby
require 'eventmachine'
require 'em-http'
require 'yajl'
require 'yaml'
require 'json'
require 'optparse'
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
DEFAULT_CONFIG_FILE = File.expand_path("../../config/default.yml",__FILE__)
class PurgeOrphan
def initialize()
@con... |
class AvenantsController < ApplicationController
def create
@avenant = Avenant.new(avenant_params)
# we need `restaurant_id` to asssociate review with corresponding restaurant
@avenant.contrat = Contrat.find(params[:contrat_id])
if @avenant.save
redirect_to contrat_path(@avenant.contrat)
else... |
#!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.unshift(File.expand_path(File.join(__dir__, '..', 'spec', 'lib')))
require 'bolt'
require 'bolt/inventory'
require 'bolt_spec/conn'
require 'bolt_spec/bolt_server'
task = ARGV[0]
target = ARGV[1]
params = ARGV[2] || '{}'
unless task && target
puts(<<~MS... |
module ShopifyImport
module DataParsers
module Products
class BaseData
def initialize(shopify_product)
@shopify_product = shopify_product
end
def product_attributes
{
name: @shopify_product.title,
description: @shopify_product.body_html,
... |
require 'rspec'
require_relative '../repository'
describe Repository::CampaignRepo do
let(:campaign) { Campaign.new('1') } #this is our sample campaign with fixtures in spec folder
let(:top_banners_based_on_clicks) { ["banner:5", "banner:4", "banner:3", "banner:2", "banner:1"] }
let(:repo) { Repository::Camp... |
load "Grille_jeu.rb"
load "Utils.rb"
##
# La classe Tuto permet au joueur de découvrir le jeu au travers d'un tuto qui explique les règles du jeu
##
# * +win+ La fenetre de l'application
# * +box2+ Le layout principal pour le placement dans la fenetre
# * +boutonUndo+ Le bouton perm... |
class MesTErpOutProjectIss < ActiveRecord::Base
establish_connection :leimes
self.primary_key = :uuid
self.table_name = :t_erp_out_project_iss
end |
# frozen_string_literal: true
describe Zafira::Api::TestSuite::Create do
let(:client) do
build(:zafira_client, :with_environment, :with_test_suite_owner, :rspec)
end
let(:environment) { client.environment }
let(:test_suite) { Zafira::Api::TestSuite::Create.new(client) }
describe '#create' do
before... |
run_unless_marker_file_exists("hosts_file") do
template "/etc/hosts" do
source "hosts.erb"
owner "root"
group "wheel"
mode 0644
end
end |
class CommentsController < ApplicationController
before_filter :load_sprint_task
# GET /comments
# GET /comments.xml
def index
@comments = @task.comments.find(:all, :order => 'created_at DESC')
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @comments ... |
# frozen_string_literal: true
module GQLi
# Module for creating a Github GraphQL client
module Github
# Creates a Github GraphQL client
def self.create(access_token, validate_query: true)
GQLi::Client.new(
'https://api.github.com/graphql',
headers: {
'Authorization' => "Bear... |
module Rdomino
##
# enables updateing of a model while logging the changes
# requires view 'System\Model\Person'
# m = Model.new db, :Person, \
# :ident => :cwid,
# :view => 'System/key',
# :logger => 'Notes',
class Model
include Enumerable
delegate :each, :find, :find!, :to... |
Factory.define :user do |u|
u.sequence(:email) { |n| "person#{n}@example.com" }
u.password "password"
end
Factory.define :confirmed_user, :parent => :user do |f|
f.after_create { |user| user.confirm! }
end
Factory.define :supplier do |u|
u.name "ACME Export"
end
Factory.define :invoice do... |
github_binary 'ghq' do
repository 'motemen/ghq'
version 'v0.10.0'
archive "ghq_#{node[:os]}_amd64.zip"
binary_path "ghq_#{node[:os]}_amd64/ghq"
end
include_cookbook 'git'
|
require_relative "card"
# ^ So this means, essentially, I need to communicate with the Card class
# and use it's instance variables and methods
# very similar to us requiring packages in Node
class Deck
def initialize
@cards = []
# Setting of empty of cards to eventually push card values to
Card::SUITS.... |
class Contract < ActiveRecord::Base
belongs_to :organization
validates :number, presence: true, uniqueness: true, format: { with: /\A[-a-zA-Z0-9._\/]*\z/}
validates :vendor_mnt, format: { with: /\A\w*\z/}
validates :product_list, format: { with: /\A[0-9.,; ]*\z/}
validates :start_date, :end_date, format: { w... |
module Repositories
module Interactors
module Bitbucket
class Scan
CONFIG_FILE_NAME = 'geartranslations.yml'.freeze
DEFAULT_LAST_UPDATE_DATE = DateTime.new(2012, 8, 29, 22, 0, 0)
GT_CLIENT_COMMIT_MESSAGE = 'gt-api-client'.freeze
include Interactor
# context:
... |
class String
define_method(:word_counter) do
string_input = self.split(" ")
words = []
string_input.each() do |string|
words.push(string.count())
end
words
end
end
|
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string default(""), not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_password_sent_at :datetime
# r... |
require "test_helper"
class BooksControllerTest < ActionDispatch::IntegrationTest
test "Should get index" do
get books_url
assert_response :success
end
test "Should create new book" do
post "/books", params: { book: { title: "Learn RoR", author: "Someone", edition: 2 }}
assert_redirected_to "/bo... |
require_relative '../../db/config'
class Politician < ActiveRecord::Base
def self.scrub_csv_data(attributes_hash = {})
clean_attributes = {}
clean_attributes = {title: attributes_hash[:title],
name: "#{attributes_hash[:firstname]} #{attributes_hash[:middlename]} #{attributes... |
class Dj < ActiveRecord::Base
validates_presence_of :dj_name
belongs_to :club_night
has_many :events, :through => :bookings
has_many :bookings
end
|
class Result < ActiveRecord::Base
# association
belongs_to :user
belongs_to :indoorkadai
belongs_to :indoor
#validation
validates :trial, presence: true
validates :climbtype, presence: true
end
|
class CreateFoods < ActiveRecord::Migration[5.2]
def change
create_table :foods do |t|
t.boolean :contains_gluten
t.boolean :contains_dairy
t.boolean :contains_treenuts
t.boolean :contains_beef
t.boolean :contains_pork
t.boolean :contains_soy
t.boolean :contains_egg
... |
require 'httparty'
class BetsController < ApplicationController
before_action :authentication
def index
bets = current_user.bets.includes(:entries).order(created_at: :DESC).order('entries.updated_at')
render json: bets.to_json(
include: [:entries]
)
end
def create
bet = current_user.be... |
class ApplicationMailer < ActionMailer::Base
default from: "noreply@rails-tutorial-shuted.c9users.io"
layout 'mailer'
end
|
class RemoveEvaluationFileColumnFromEvaluations < ActiveRecord::Migration[5.0]
def up
remove_column :evaluations, :evaluation_file
end
def down
add_column :evaluations, :evaluation_file, :string
end
end
|
# frozen_string_literal: false
class RobotsGeneratorService
# Generate a robots.txt with the default values
def self.default
file_path = Rails.root.join("public", "robots.txt")
robots = RobotsGeneratorService.new(
path: file_path,
disallowed_paths: Rails.configuration.robots.disallowed_paths
... |
require 'test_helper'
class PlaylistsControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup do
@playlist = users(:alice).playlists.first
@playlist2 = users(:bob).playlists.first
@user = users(:alice)
@request.env["devise.mapping"] = Devise.mappings[:user]
end
test "should get inde... |
class Histogram
attr_reader :red_channel, :green_channel, :blue_channel
def initialize(image)
# Requires image generated from ChunkyPNG Library
@image = image
# Initialize all color channels within RGB color space
@red_channel = Hash[[*0..255].map {|v| [v,0]}]
@blue_channel = Hash[... |
json.array!(@coverages) do |coverage|
json.extract! coverage,
:id,
:key
end
|
def num_islands(grid)
count = 0
puts "original grid: #{grid}"
grid.each_with_index.map do |row, row_idx|
row.each_with_index.map do |column_value, column_idx|
puts "\n"
puts "column_value: '#{column_value}'"
if column_value == '1'
# I am surprised that passing grid here is destructi... |
class Review < ActiveRecord::Base
belongs_to :problem
validates :rate, :inclusion => { :in => 0..10, :message => "Avalie
o problema com uma nota entre 0 e 10"}
end
|
class Post < ActiveRecord::Base
belongs_to :sender, class_name: "User"
belongs_to :recipient, class_name: "User"
has_many :tasks
has_one :epic
# intents
Intents = {
coach: {
sending_todays_goal: 8,
reminding_todays_goal: 9,
completed_todays_goal: 0,
showing_ta... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Coercers
describe EditorLine do
let(:described) { Vedeu::Coercers::EditorLine }
let(:instance) { described.new(_value) }
let(:_value) {}
let(:klass) { Vedeu::Editor::Line }
describe '#initialize' do... |
class Word < ActiveRecord::Base
belongs_to :passage
has_many :highlights
end
|
class PagesController < ApplicationController
# HM: look up include ViewHelpers to use Ruby view helpers with ajax requests
def index
# To run any terminal commands in rails use the backticks ` `
@lotto_numbers = Array(1..45).sample(6).join(', ')
@uptime = ` uptime `
@fortune = ` fortune `
end
... |
class Trip < ActiveRecord::Base
include PublicActivity::Model
tracked owner: Proc.new{|controller, model| controller.current_user}
belongs_to :user
has_many :item_subscriptions
has_many :items, :through => :item_subscriptions
validates :name, presence: true
validates_date :ends_on, :on_or_after => :starts_on... |
# == Schema Information
#
# Table name: schedules
#
# id :integer not null, primary key
# begin :datetime
# end :datetime
# teacher_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class Schedule < ActiveRecord::Base
has_and_belongs_to_m... |
# Problem 74: Digit factorial chains
# http://projecteuler.net/problem=74
#
# The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145:
# 1! + 4! + 5! = 1 + 24 + 120 = 145
# Perhaps less well known is 169, in that it produces the longest chain of numbers that link back... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.