text stringlengths 10 2.61M |
|---|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
#Josh Goebel
class HanoiRack
class Peg
attr_reader :id, :rings
def initialize( id )
@id = id
@rings = []
end
def push( ring_size )
if @rings.last < ring_size
raise "Cannot put #{ring_size} on top of #{@rings.last}"
end unless @rings.empty?
@rings << ring_size
... |
class ProjectsController < ApplicationController
before_action :set_project, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
def index
@projects = current_user.projects
end
def new
@project = Project.new
end
def edit
end
def create
@project = current_user.proje... |
module Shanty
# Public: Encapsulates the directory tree of a Shanty project. This provides a
# way to glob the project tree in a performant way without globing through
# files that are ignored by Git, SVN some other VCS.
#
# FIXME: The ignores are not implemented yet, this work has been recorded in
# issue ... |
class Item < ActiveRecord::Base
belongs_to :store
belongs_to :category
validates_presence_of :quantity, :name, :price
validates :quantity, :price, numericality: { greater_than: 0 }
end
|
require "spec_helper"
describe Lita::Handlers::Enhance::ChefIndexer do
include_context 'mocks'
include_context 'redis'
let(:indexer) { described_class.new(redis, {}) }
let(:config) { double('Lita::Configuration', handlers: double(enhance: double(size_attribute: 'base.size'))) }
it 'should be able to creat... |
# This controller allows a teacher to add students to a team using a GET and POST request.
class TeamController < ApplicationController
protect_from_forgery except: :create
before_action :authenticate_user!
before_action :select_course!
# The GET request renders all the students in the current course
def i... |
module CamaleonCms
class PostComment < CamaleonRecord
include CamaleonCms::Metas
include CamaleonCms::CommonRelationships
self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}comments"
# attr_accessible :user_id, :post_id, :content, :author, :author_email, :author_url, :author_IP, :appro... |
require "application_system_test_case"
class PearlsTest < ApplicationSystemTestCase
setup do
@pearl = pearls(:one)
end
test "visiting the index" do
visit pearls_url
assert_selector "h1", text: "Pearls"
end
test "creating a Pearl" do
visit pearls_url
click_on "New Pearl"
fill_in "Qu... |
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(
name: "Example User",
email: "someone@example.com",
password: "foobar",
password_confirmation: "foobar"
)
end
test "should be valid" do
assert @user.valid?
end
test "name should ... |
class UsersController < ApplicationController
before_action :authenticate_user!
def index
@users = User.all.offset(1)
end
end
|
class CreatePosts < ActiveRecord::Migration[5.2]
def change
create_table :posts do |t|
t.text :content
t.timestamps
end
end
end
|
require_relative 'westpac'
module Fiat
module TransferIns
class Beyond < Westpac
def self.convert(westpac)
bank = {}
bank[:source_id] = self.generate_id(westpac)
bank[:source_name] = "Beyond Bank Statement"
bank[:source_code] = westpac[:bank_account].to_json
... |
Rails.application.routes.draw do
scope PluginRoutes.system_info['relative_url_root'] do
scope module: 'camaleon_cms', as: 'cama' do
namespace :admin, path: PluginRoutes.system_info['admin_path_name'] do
get '/' => :dashboard
get 'dashboard'
get 'ajax'
get 'search'
get... |
json.array!(@diploma_people) do |diploma_person|
json.extract! diploma_person, :id, :diploma_id, :person_id, :old_lastname, :is_teacher, :is_staffteacher, :is_student, :is_postgrad, :details
json.url diploma_person_url(diploma_person, format: :json)
end
|
dep 'ripgrep' do
met? {
shell?('which rg')
}
meet do
log_shell('Installing ripgrep', 'brew install ripgrep')
end
end
|
# rubocop:disable Metrics/ModuleLength just mocks; don't care
module ApiHelpers
def api_url(path)
"#{ENV['API_ROOT']}v1/#{path}"
end
def mock_task_id
'2d98639e-5260-411f-a5ee-61847a2e067c'
end
def mock_correcting_task_id
'b847e0f7-027e-4b95-afa2-3490b8d05a1d'
end
def mock_submission_id
... |
require "spec_helper"
require "fog/brightbox/models/compute/server"
describe Fog::Compute::Brightbox::Server do
include ModelSetup
include SupportsResourceLocking
subject { service.servers.new }
describe "when asked for collection name" do
it "responds 'servers'" do
assert_equal "servers", subject.... |
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: ruby-style-guide 0.1.5 ruby lib
Gem::Specification.new do |s|
s.name = "ruby-style-guide"
s.version = "0.1.5"
s.required_rubygems_version = Gem::Requiremen... |
class AddIconToGrouptextblocks < ActiveRecord::Migration
def change
add_attachment :grouptextblocks, :icon
end
end
|
Rails.application.routes.draw do
scope ENV['BASE_HREF'] do
resources :posts, only: %i[index show]
end
end
|
# frozen_string_literal: true
require 'active_encryption/encryptor'
module ActiveEncryption
module Encryptable
# InstanceMethodsOnActivation adds instance methods for the attribute
# "attribute_name" to the including class.
class InstanceMethodsOnActivation < Module
def initialize(attribute_name, ... |
class RemarkSet < ActiveRecord::Base
belongs_to :assessment_plan
has_many :gradebook_remarks, :as => :remarkable, :dependent=>:destroy
# before_validation :check_assessment_report_settings
TARGET_TYPE = { "AssessmentGroup" => "Exam Report Remark", "AssessmentTerm" => "Term Report Remark", "AssessmentPlan" =>... |
class CmisClient
class Folder < CmisObject
include XmlUtils
def get_children_link
get_link(DOWN_REL, ATOM_XML_FEED_TYPE_P)
end
def get_children
children_url = get_children_link
result = @cmis_client.get(children_url)
entry_elements = ... |
# file name: second_demultiplex.rb
# performs plateseq demultiplexing
# splits fastq files based on barcode
# barcode matching using hamming distance (<=1 to real and >1 to the other)
# generates a set of possible codes with hd <=1 as a hash
require 'zlib'
require 'multiple_files_gzip_reader'
def main
inputdir = AR... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
require 'spec_helper'
require 'tent-client/link_header'
describe TentClient::LinkHeader do
def new_link(link, attrs={})
TentClient::LinkHeader::Link.new(link, attrs)
end
it 'parses a simple link' do
link_header = %Q(<http://example.com/TheBook/chapter2>; rel="previous";\n title="previous chapter")
... |
# 3. Estamos desarrollando un módulo de compras para su página de ventas, y se dió cuenta que
# muchas de las personas que ingresan lo hacen desde diferentes países, por lo que dejar un solo
# precio de un solo país no lo hace muy práctico. Utilizando los métodos gets y puts, se deben
# generar la siguiente opciones pa... |
##
# This file adapted from activerecord gem
#
module Pools
class Middleware
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
ensure
Pools.handler.clear_active_connections!
end
end
end |
#!/bin/env ruby
# frozen_string_literal: true
require 'rubygems'
# Integer Class Utilities
class Integer
KB = 1024
SIZE_MAPPING = {
'B' => KB,
'KB' => KB * KB,
'MB' => KB * KB * KB,
'GB' => KB * KB * KB * KB,
'TB' => KB * KB * KB * KB * KB,
'PB' => KB * KB * KB * KB * KB * KB,
'EB' => ... |
require 'chemistry/element'
Chemistry::Element.define "Iridium" do
symbol "Ir"
atomic_number 77
atomic_weight 192.217
melting_point '2716K'
end
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string not null
# email :string default(""), not null
# encrypted_password :string default(""),... |
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
if Rails.env.development?
config.omniauth :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET'],
{:scope => 'email, offline_access'... |
module MiniTest
class Spec
class << self
def context desc, &block
describe desc, &block
end
end
def mock
MiniTest::Mock.new
end
end
end
|
require "spec_helper"
require 'rails_helper'
describe Contact do
it { should validate_presence_of :email } # В модели Contact должна присутвовать валидация поля :email
it { should validate_presence_of :message }
end |
class UpcomingLiveCourse < LiveCourse
default_scope { where(:class_type => "live").includes(:live_class_dates).where('live_class_dates.start_date >= ?', Date.today).references(:live_class_dates).order('live_class_dates.start_date ASC') }
RailsAdmin.config do |config|
config.model UpcomingLiveCourse do
... |
class Survey::Info < ActiveRecord::Base
has_many :quests, class_name: "Survey::Quest",
foreign_key: :survey_id, dependent: :destroy
has_many :ans_sets, class_name: "Survey::AnsSet"
has_many :ans, class_name: "Survey::Ans", through: :ans_sets
has_many :contest, class_name: "Contest::Info",
foreign_key:... |
# Get suggestions to build up to a word
class CanBecome
def initialize(word)
@word = Word.new(word)
end
def suggestions
Dictionary.words.find_all do |word|
@word.contains?(word)
end.map do |word|
Match.new(word, @word)
end.find_all(&:valid?).sort
end
end
|
# frozen_string_literal: true
RSpec.describe Prependers::Prepender do
context 'without a namespace' do
before do
class Dog; end
module Dog::AddBarking # rubocop:disable Style/ClassAndModuleChildren
include Prependers::Prepender.new
module ClassMethods
def bark
... |
class AddPosColumnsToCountries < ActiveRecord::Migration
def change
add_column :countries, :x, :integer
add_column :countries, :y, :integer
end
end
|
module Sumac
module Messages
# Representes a _Sumac_ +call_response+ message.
# @api private
class CallResponse < Message
# Build a new {CallResponse} message.
# An +exception+ or +rejected_exception+ can be passed, but not at the same time.
# A +rejected_exception+ is set when the cal... |
require 'spec_helper'
module Mirren
module Info
RSpec.describe Endpoints do
let(:request) { double }
let(:client) { MockClient.new(Endpoints).call(request) }
let(:response) do
"{ \"success\": #{response_success?}," \
" \"data\": #{response_data} }"
end
let(:name) { ... |
require 'spec_helper'
describe "Authenication pages" do
subject { page }
let!(:admin) { create(:admin, email: "admin@alameda.org") }
before do
visit root_path
end
describe "user signin" do
before do
fill_in "Email", with: admin.email
fill_in "Password", with: admin.password
click... |
# Angry boss. Write an angry boss program that rudely asks what you want. Whatever you answer, the angry boss should yell it back to you and then fire you. For example, if you type in "I want a raise", it should yell back: WHADDAYA MEAN "I WANT A RAISE?!? YOU'RE FIRED!!"
puts 'What the hell do you want?';
your_answer ... |
#
# Cookbook Name:: zabbix
# Attributes:: default
case node['platform_family']
when 'windows'
if ENV['ProgramFiles'] == ENV['ProgramFiles(x86)']
# if user has never logged into an interactive session then ENV['homedrive'] will be nil
default['zabbix']['etc_dir'] = ::File.join((ENV['homedrive'] || 'C:'), '... |
require 'rails_helper'
RSpec.describe CategoriesController, type: :controller do
login_user
let(:category) { create(:category, user: subject.current_user) }
let(:parent_category) { create(:category, user: subject.current_user) }
let(:valid_attributes) { attributes_for(:category) }
let(:invalid_attributes) {... |
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
require 'greed/score'
class GreedScoreTest < Given::TestCase
Invariant { @score.bust? == (@score.points == 0) }
Invariant {
if @score.unused == 0
expect(@score.remaining) == 5
else
expect(@score.remaining) == @score.un... |
def max_windowed_range(array, window_size)
current_max_range = 0
(0..array.size-window_size).each do |idx|
sub_array = array[idx..idx+window_size-1]
p sub_array
max = sub_array.max
min = sub_array.min
current_max_range = max - min unless current_max_range > max - min
end
current_max_range
en... |
require_relative '../test_helper'
class UserCanEditExistingTaskTest < Minitest::Test
include Capybara::DSL
include TestHelpers
def test_user_can_delete_a_skill
create_skills(1)
visit '/skills'
within ".skills" do
assert page.has_content? "test name"
end
click_button("Delete")
as... |
# Methods and Variables
# Pretty much anything can be passed into a method as arguments
# as long as it fits the parameters
# Function definition for the examples in this exercise
def cheese_and_crackers(cheese_count, boxes_of_crackers)
puts "You have #{cheese_count} cheeses!"
puts "You have #{boxes_of_crackers}... |
=begin
The code provided is supposed replace all the dots . in the specified String str with dashes -
But it's not working properly.
Task
Fix the bug so we can all go home early.
Notes
String str will never be null.
=end
#Solution
def replaceDots(str)
str.sub(/./, '-')
end
#other solution:
def replaceDots(str)
... |
# frozen_string_literal: true
require 'test_helper'
module Dealersocket
module Client
class VersionTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil VERSION
end
end
end
end
|
class React < ApplicationRecord
enum react: %i[like love joy wow sad angry]
belongs_to :timeline
belongs_to :reactor, polymorphic: true
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
# Method current_user visible in views
helper_method :current_user
def current_user
return nil if session[:user... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environmen... |
# -*- coding: utf-8 -*-
#
#= Page のクラスメソッド、インスタンスメソッドを管理するモジュール
#
module Concerns::Page::Method
extend ActiveSupport::Concern
included do
after_destroy :clean_jobs
after_destroy :remove_attachment_dir
# ページ検索用
scope :search, ->(genre, opt={}, additional={}) {
order_column = additional[:order... |
# Transaction Class
class Transaction
attr_reader :balance, :account_statement
def initialize
@balance = 0
@account_statement = []
end
def account_balance
@balance
end
def deposit(amount)
number = amount.to_f.round(2)
@balance += number
@account_statement << { date: date, credit:... |
require 'test_helper'
class PostTest < ActiveSupport::TestCase
test "post save" do
post = Post.new({
title: 'post test title',
content: 'post test content',
user_id: 1
})
assert post.save, 'Fail to save' # boolean 값을 넣는다.
end
test "post length validation" do
post = Post.new({... |
#puts "Hello World!"
#puts "Name is Honey"
#Comments
# puts "This will ignored."
#puts "This will run."
#NUMBERS
#puts "What is 3 + 2? #{3 + 2}"#Valid Expression
#puts "Is it true that 3 + 2 < 5 - 7?" #Invalid_Epressions
#puts "Is greater? #{6 > -2}"
#puts "Is greater or equal? #{-2 >= -2}"
#puts "Is less or equal? #... |
regex = /position=\<(?<coord>.*)\> velocity=\<(?<velocity>.*)\>/
input = DATA.read
class Point
attr_accessor :x, :y
def initialize(x, y, vx, vy)
@x = x
@y = y
@vx = vx
@vy = vy
end
def tick!(n = 1)
@x += @vx * n
@y += @vy * n
end
def untick!(n = 1)
@x -= @vx * n
@y -= @vy... |
module Yito
module Model
module Booking
class BookingCatalog
include DataMapper::Resource
extend Yito::Model::Finder
storage_names[:default] = 'bookds_catalogs'
property :code, String, :length => 20, :key => true
property :description, String, :length => 255
... |
module Moria
# represent a attribute in a UIView
class ViewAttribute
attr_accessor :view
attr_accessor :layout_attribute
attr_accessor :constant
def initialize(view, layout_attribute)
@view = view
@layout_attribute = layout_attribute
@constant = nil
end
def size_attribute... |
module ApiBlueprint
class Blueprint < ApiBlueprint::Struct
attribute :http_method, Types::Symbol.default(:get).enum(*Faraday::Connection::METHODS)
attribute :url, Types::String
attribute :headers, Types::Hash.default(Hash.new)
attribute :params, Types::Hash.default(Hash.new)
attribute :body, Types... |
# == Schema Information
#
# Table name: pokemons
#
# id :integer not null, primary key
# user_id :integer
# base_pokemon_id :integer
# nickname :string
# level :integer
# gender :string
# shiny :boolean
# held_item :string
# pokeball ... |
class FixInventoryTableName < ActiveRecord::Migration
def change
rename_column :inventories, :pName , :name
rename_column :inventories, :pQuantity , :quantity
rename_column :inventories, :pMeter , :meter
rename_column :inventories, :pWeight , :weight
rename_column :inventories, :pSellPrice , :sellprice... |
class UpdateColumnOfShows < ActiveRecord::Migration[6.1]
def change
remove_reference :shows, :show
add_reference :shows, :venue, null: false, foreign_key: true
end
end
|
require 'test_helper'
class ListingBooksTest < ActionDispatch::IntegrationTest
setup do
@distopian = Genre.create!(name: 'distopian')
@distopian.books.create!(title: "Mockingjay", rating: 3)
@distopian.books.create!(title: "1984", rating: 5)
end
test 'listing books' do
get '/api/books'
asse... |
class Api::EmployeesController < ApiController
lock_with_feature :hr_enhancement
filter_access_to :all
def index
@xml = Builder::XmlMarkup.new
@employees = Employee.search(params[:search])
respond_to do |format|
unless params[:search].present?
render "single_access_tokens/500.xml", :... |
class User < ActiveRecord::Base
has_secure_password
# Relations
has_one :user_info
# has_many :sent_messages, -> { where( :foreign_key => 'author_id' ) }, through: :messages,
has_many :friendships
has_many :inverse_friendships, :class_name => 'Friendship', :foreign_key => 'friend_id'
has_many :acti... |
# frozen_string_literal: true
desc 'Test API SDK end-to-end against an AlgoSec machine'
task :e2e, %i[app host user password] => [] do |_t, args|
require 'algosec-sdk'
args.with_defaults(
app: 'TEST',
host: 'local.algosec.com',
user: 'admin',
password: 'algosec'
)
options = {
host: args.hos... |
class CreateFollowers < ActiveRecord::Migration
def change
create_join_table :groups, :users, table_name: :followings
end
end
|
# Analyze the Errors
# I worked on this challenge [by myself].
# I spent [#] hours on this challenge.
# --- error -------------------------------------------------------
#"Screw you guys " + "I'm going home." = cartmans_phrase
#cartmans_phrase = "Screw you guys " + "I'm going home."
# This error was analyzed in the ... |
class Parser::IadCases20200815 < Parser::Csv
KEY_MAPPING = {
title_rank_snap_: :title,
}
def category
"iad_cases_20200815"
end
def map_key(key)
KEY_MAPPING.fetch(key, key)
end
end
|
module Apress
module Images
# Public: Базовый класс для хранения изображений
class Image < ::ActiveRecord::Base
include Apress::Images::Imageable
self.abstract_class = true
acts_as_image
end
end
end
|
#Extended built in class
class Array
def shuffle
sort_by{rand}
end
end
class Integer
def factorial
raise "No negative integers!" if self < 0
(self <= 1) ? 1 : self * (self-1).factorial
end
def to_roman
raise "Positive integers only." if self <= 0
roman = ""
roman << [["M" * (self ... |
require('json')
require('date')
require_relative('./order_form')
require_relative('./order_item')
require_relative('./read-object-json')
require_relative('./omnifocus')
class Engine
attr_accessor :order_form, :file_name
def initialize(input)
@file_name = select_file(input)
data = ReadObjectJSON.get_order_... |
require 'rails_helper'
RSpec.describe Schedule, type: :model do
it { is_expected.to validate_presence_of(:initial_date) }
it { is_expected.to validate_presence_of(:end_date) }
it { is_expected.to validate_presence_of(:initial_hour) }
it { is_expected.to validate_presence_of(:end_hour) }
end
|
class StopsController < ApplicationController
before_action :authenticate_user!
before_action :set_trip, only: [:new, :create, :edit, :update, :destroy, :search_stop]
before_action :set_stop, only: [:edit, :update, :destroy]
def new
@stop = @trip.stops.new(stop_new_params)
end
def create
authori... |
class Admin::UsersController < Admin::BaseController
def show
@user = current_user
end
end
|
class Player
@hand
attr_accessor :hand
def initialize
@hand = []
end
def play_card(card, deck)
if self.hand.include? card
i = self.hand.index card
deck.hand_played self, card
return self.hand.delete_at i
else
raise Card::InvalidCardError.new "Card not found in play... |
node['sqlshell']['postgres']['active_instances'].each do |instance_key|
service_key = "Database_#{instance_key}"
db_config = Chef::Services.lookup(node, service_key, :scope => :environment)
db_host = RealityForge::AttributeTools.ensure_attribute(db_config, 'host', String, "services.#{service_key}")
db_port = R... |
module Refunge
class Interpreter
attr_reader :cursor,
:direction,
:program,
:stack,
:output
def initialize(raw_program)
@program = Program.new(raw_program)
@cursor = Cursor.new(program.width, program.height)
@stack = Stack.new
... |
class CreateDiskArrays < ActiveRecord::Migration
# 磁盘阵列 disk_array
#
#最大存储容量 max_capacity
#插槽数量 slot_qty
#数据接口 interface
#传输速率 baud_rate
#高速缓存 cache
#平均故障间隔时间 mtbf
def self.up
create_table :disk_arrays do |t|
t.integer "max_capacity"
t.integer "slot_qty"
t.string ... |
require 'spec_helper'
describe Tweet do
context "with links" do
it "returns linked text for anchors" do
text = "this a sentence with a link http://google.com"
tweet = FactoryGirl.create(:tweet, text: text)
tweet.text.should == "this a sentence with a link <a href='http://google.com' target='_blank'>http:/... |
class AddDatesToEvents < ActiveRecord::Migration
def self.up
add_column :events, :start_date, :date
add_column :events, :end_date, :date
add_column :events, :website_url, :string
add_column :events, :place, :string
end
def self.down
remove_column :events, :place
remove_column :events, :we... |
class ArticlesController < ApplicationController
def index
@articles = Article.all
end
def new
@article = Article.new
@article.build_movie
end
def create
@article = Article.new(article_params.merge(:admin_id => current_admin.id))
if @article.save
flash[:success] = "Writing an articl... |
require 'spec_helper'
describe UserTeam do
before do
mock_geocoding!
@team = FactoryGirl.create(:team)
@user = FactoryGirl.create(:user)
@user_team = @user.user_teams.build(team_id:@team.id)
end
subject { @user_team }
it { should respond_to(:team) }
it { should respond_to(:user) }
end
|
class Drinker < ApplicationRecord
has_many :drinkings
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
# TODO: パスフレー... |
#!/usr/bin/env ruby
#
# Copyright (c) 2017 joshua stein <jcs@jcs.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS... |
class CreateMessages < ActiveRecord::Migration
def self.up
create_table :messages do |t|
t.integer :from_user_id, :null => false
t.integer :to_user_id, :null => false
t.integer :review_id, :null => false
t.integer :message_id # reply to another message?
t.text :body, :null => false
t.date... |
module Logical::Naf::ConstructionZone
class ApplicationWorkOrder < WorkOrder
def initialize(application,
application_run_group_restriction = ::Naf::ApplicationRunGroupRestriction.limited_per_all_machines,
application_run_group_name = :command,
application_r... |
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# body :text not null
# parent_comment_id :integer
# post_id :integer not null
# user_id :integer not null
# created_at :datetime
# ... |
class Shelter
attr_accessor :name, :address, :clients, :animals
def initialize (name, address)
@name = name
@address = address
@clients = {} # {Shelter.clients: Person.new}
@animals = {} # {Shelter.animal: Animal.new}
end
end
|
#!/usr/bin/env ruby
require 'set'
require 'slop'
require 'conway_deathmatch'
require 'conway_deathmatch/shapes'
# process cmdline options
#
opts = Slop.parse do |o|
o.banner = "Usage: proving_ground [options]"
o.int '-w', '--width', 'Grid width'
o.int '--height', 'Grid height'
o.int '-n', '--num_ticks',... |
require 'httparty'
require 'nokogiri'
#require './models'
require './mongoid'
module HTML
def self.options_to_hash options, remove_first_elem=true
hash = Hash.new
options.each { |o| hash[o.attr(:value)] = o.text }
hash.delete("0") if remove_first_elem
hash
end
end
class Fipe
include HTTParty
... |
class Messenger
def self.send_message(number, message, from_number: nil, logger: nil)
logger.info %("Sending message \"#{message}\" to #{number}") unless logger.nil?
if Rails.env.production?
from_number = ENV.fetch('PHONE_NUMBER')
account_sid = ENV.fetch("TWILIO_ACCOUNT_SID")
auth_token = E... |
=begin
Test d'intégration de la réponse à un commentaire
Cas : Offlin - Administrateur
=end
require 'spec_helper'
$i_screenshot = 0
def screenshot
ind = "%02d" % ($i_screenshot += 1)
TI::screenshot("add_reponse_#{ind}")
end
describe "Ajout d'une réponse à une question", :not_phil => true do
def get_last_i... |
class PostSerializer < ActiveModel::Serializer
attributes :id, :title, :content, :img, :username, :time_mark, :likes, :comments, :integerTime, :type, :avatar
def username
self.object.user.username
end
def time_mark
self.object.time_mark
end
def likes
self.object.likes
end
def comments
... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
desc "This task is called by the Heroku scheduler add-on"
require 'duo_calculator'
task :notify_duos => :environment do
if Time.now.friday?
puts "Building duos and notifying..."
DuoCalculator.get_duos
puts "complete."
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.