text stringlengths 10 2.61M |
|---|
require 'funl/message-sequencer-select'
require 'funl/message-sequencer-nio'
require 'socket'
require 'tmpdir'
include Funl
class BenchmarkTask
attr_reader :name, :params
def initialize name, **params
@name = name
@params = params
end
def inspect
ps = params.map{|k,v| "#{k}: #{v}" }
pstr = p... |
PlantingSeasonApi::Application.routes.draw do
namespace :api do
namespace :v1 do
get '/plantings/for_bed/:id', to: 'plantings#for_bed', as: "for_bed_path"
get '/beds/for_user/:id', to: 'beds#for_user', as: "for_user_path"
get '/beds/default_for_user/:id', to: 'beds#default_for_user', as: "defaul... |
module Geopath
module Insights
module Models
module Inventory
class Search < Geopath::Insights::Models::BaseModel
def inventory_items
@inventory_items ||= @data['inventory_items'].map do |inventory_item|
InventoryItem.new(inventory_item)
end
... |
module ObjectHistory
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def track_history_of(*methods, &block)
attr_accessor :__history
methods.each do |method|
track_method = "__#{method}__track__"
unless private_instance_methods.include?(track_method)
... |
class ChangeCaptionToText < ActiveRecord::Migration[6.0]
def change
change_column :posts, :caption, :text
end
end
|
def input_students
puts "Please enter the names of the students."
puts "To finish, just hit return twice!"
students = []
name = gets.chomp
while !name.empty? do
students << {name: name, cohort: :november}
puts "Now we have #{students.count} students!"
name = gets.chomp
end
students
end
def p... |
# This module defines a whole bunch of environment variables that are required
# by the Whedon gem when executing tasks.
module ConfigHelper
def set_env(nwo, issue_id, config)
ENV['REVIEW_REPOSITORY'] = nwo
ENV['DOI_PREFIX'] = config.doi_prefix
ENV['JOURNAL_ALIAS'] = config.journal_alias
ENV['PAPER_R... |
class ReaderUser < ActiveRecord::Base
validates :name, uniqueness: true
def redis_key(string)
"user:#{self.name}:#{string}"
end
end
|
class PostsController < ApplicationController
before_action :find_post, only: [:edit, :update, :show, :destroy]
def edit
end
def create
@post = Post.new(post_params)
@post.author_id = current_user.id
unless @post.save
flash[:message] = @post.error_string
en... |
class InstagramProxyController < ApplicationController
def find_tags_for_team
theTeam = Team.find(params[:team_id])
theWrapper = InstagramWrapper.new(user_signed_in? ? current_user.instagram_user_token : nil)
theTags = theWrapper.getSortedInstagramTags(theTeam.social_info.hash_tags)
respond_to d... |
class LoginPage < SitePrism::Page
set_url "https://demo.suiteondemand.com/index.php"
element :username_field, "input[placeholder='Username']"
element :password_field, "input[placeholder='Password']"
element :login_button, "input[title='Log In']"
def login (nome,senha,login)
username_field.set(nome)
passwor... |
include_recipe 'td-agent'
data_bag = Chef::EncryptedDataBagItem.load('webhook_urls', 'knock')
mackerel_credentials = Chef::EncryptedDataBagItem.load('credentials', 'mackerel')
color = node[:instance_kind][:color]
%w(
fluent-plugin-slack
fluent-plugin-mackerel
fluent-plugin-forest
fluent-plugin-record-reformer
... |
class Author < ActiveRecord::Base
has_many :assignments
has_many :stories, through: :assignments
has_secure_password
enum role: [ :author, :editor ]
end
|
json.attributes Transaction.column_names
json.models do
json.array!(@transactions) do |transaction|
json.extract! transaction, :id, :credit_id, :debit_id, :amount, :comment, :paid_at, :created_at, :updated_at
json.url transaction_url(transaction, format: :json)
end
end
|
# frozen_string_literal: true
RSpec.shared_examples_for "a monad" do
describe "#to_monad" do
it "returns self" do
expect(subject.to_monad).to be(subject)
end
end
end
|
module Tictail
class Store
# @param [Mechanize::Page] page
def initialize(page)
@page = page
@api = Tictail::Api.new
@api.store_id = store_id
@api.sign_in(ENV['TICTAIL_EMAIL'], ENV['TICTAIL_PASSWORD'])
end
# @return [Fixnum]
def store_id
store_data["id"]
end
... |
require 'json'
require 'datamine/jira'
# Create a JIRA client that interacts with the API.
def configure_jira options
url = options[:url]
# This feels a bit weird, but can't see an obviously better way to share
# command-global variables.
options[:client] = Datamine::Jira::REST.factory url
end
module Datam... |
# frozen_string_literal: true
require "dry-logic"
RSpec.describe "Rules" do
specify "defining an anonymous rule with an arbitrary predicate" do
rule = Dry::Logic.Rule { |value| value.is_a?(Integer) }
expect(rule.(1)).to be_success
expect(rule[1]).to be(true)
end
specify "defining a conjunction" do... |
json.array!(@pants) do |pant|
json.extract! pant, :name, :year, :style, :price_range
json.url pant_url(pant, format: :json)
end
|
require './src/Core'
module Core_Div
module Exp_Div # modulo responsavel por implementar a forma de printar expressao para divisao
include Core::Exp
def print()
return "(" + @left.print + "/" + @right.print + ")"
end
end
class C_Div
include Exp_Div
... |
module UsersHelper
# Returns the Gravatar image for the user
def gravatar_for(user, size: 80 )
#an MD5 hash algorithm (implemented using the 'hexdigest' method [part of the Digest library]) converts the email into an MD5 hash (case-sensitive)
gravatar_id = Digest::MD5::hexdigest(user.email.down... |
class AddClassroomRefToFeedbackRequests < ActiveRecord::Migration[5.0]
def change
add_reference :feedback_requests, :classroom, foreign_key: true
end
end
|
class AddPeopleToTask < ActiveRecord::Migration
def change
add_column :tasks, :people, :integer
add_column :tasks, :need, :integer
end
end
|
class CreateInterviews < ActiveRecord::Migration
def self.up
create_table :interviews do |t|
t.column :candidate_id, :integer
t.column :user_id, :integer
t.column :date, :datetime
t.column :process, :string, :size => 40, :default => "no date yet"
... |
require 'rails_helper'
describe 'Items Index API' do
before :each do
@items = create_list(:item, 100)
end
describe 'happy path' do
it "sends a list of items in an array called 'data'" do
get api_v1_items_path
expect(response).to be_successful
items = JSON.parse(response.body, symboli... |
# Make a widget
class DBLRuby::Widget
BASE_URL = 'https://discordbots.org/api/widget/'.freeze
# Make a new widget
# @param size ['large', 'small'] The size of the widget.
# @param file_type ['png', 'svg'] The file type of the image
# @param small_type ['owner', 'status', 'upvotes', 'servers', 'lib'] The type... |
class Item < ApplicationRecord
has_many :reservations
has_many :users, through: :reservations
has_many :reviews, through: :reservations
belongs_to :location
belongs_to :tool_type
validates :name, presence: true
validates :brand, presence: true
validates :tool_type_id, presence: true
validates :cost_d... |
require 'ostruct'
module Localwiki
##
# create instance (of correct type) for resource
# @param type resource type "site", "page", "user", "file", "map", "tag", "page_tags"
# @param json_hash [Hash] hash object from parsed json
# @return new instance - child class of Localwiki::Resource
def self.make_one(... |
class AddPublishedToEvent < ActiveRecord::Migration
def change
add_column :events, :published, :boolean
add_column :events, :url, :string
add_column :products, :quantity, :integer
end
end
|
class AddRelationshipToPerson < ActiveRecord::Migration
def change
add_column :people, :People, :string
add_reference :people, :Relationship, index: true, foreign_key: true
end
end
|
require 'spec_helper'
feature 'Editing Folders' do
let!(:activity) { FactoryGirl.create(:activity) }
let!(:user) { FactoryGirl.create(:user) }
let!(:folder) do
folder = FactoryGirl.create(:folder, activity: activity )
folder.update(user: user)
folder
end
before do
define_permission!(user, "v... |
module York
class FileUrlTag < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@filename = York.parse_tag_params(text, 1).first
end
def render(context)
example = context.registers[EXAMPLE_REGISTER] || ''
site = context.registers[:site]
site_dest = Pathname.ne... |
module IGMarkets
# This class contains methods for printing a REST request and its response for inspection and debugging. Request
# printing is enabled by setting {enabled} to `true`.
#
# @private
class RequestPrinter
class << self
# Whether the request printer is enabled.
#
# @return [B... |
module CookbookGit
def self.test_cookbook_name
"git"
end
def self.test_run_path
File.join(Chef.node["chef-acceptance"]["suite-dir"], "test_run")
end
def self.acceptance_path
File.expand_path("..", Chef.node["chef-acceptance"]["suite-dir"])
end
def self.acceptance_gemfile
File.join(accep... |
class CreateColumnAuthorApplies < ActiveRecord::Migration
def self.up
create_table :column_author_applies do |t|
t.integer :user_id
t.string :real_name
t.string :gender
t.string :identity_type
t.string :identity_id
t.string :tel
t.string :mobile
t.string :blog
... |
Vagrant.configure("2") do |config|
# Ubuntu 13.04 box
# See vms/README.md
config.vm.box = "raring64-packer"
config.vm.define "aio-stage" do |box|
# RAM: 1.5GB
box.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1536"]
end
# FIXME: setup two interfaces (public... |
module Slack
class Client
attr_reader :options, :token
def initialize(token)
@token = token
end
def messages(name, type, options)
channel = case type
when 'channel' then channels.find { |item| item['name'] == name }
when 'group' then groups.find { |item| item['name'] == name ... |
class Dose < ApplicationRecord
validates :description, :cocktail, :ingredient, presence: true
validates_uniqueness_of :cocktail_id, :scope => [:ingredient_id]
belongs_to :cocktail
belongs_to :ingredient
end
|
module SQS::Job
# One Handler instance is created per SQS message
# received, and is responsible for processing it
# by instantiating a Message::Base subclass and
# calling its #invoke! method. The "main" method
# is #run!.
#
# Messages have the following structure:
# {type: 'create', params: { ... ... |
require 'rmagick'
require 'opencv' if ENV['RACK_ENV'] != 'test'
class ProcessedImage
TARGET_WIDTH = 542.to_f
attr_reader :url, :width, :height
def initialize(file)
@file = file
@url = nil
end
def process
success = false
image = Magick::Image.read(@file).first
image_file = Pathname.new... |
class FamilyMailer < ApplicationMailer
def invite_to_family(family_invitation)
@family_invitation = family_invitation
from_user = @family_invitation.inviter_profile
mail(
from: from_user.user.email,
to: @family_invitation.email,
subject: "#{from_user.full_name} invited you to join his/he... |
# frozen_string_literal: true
RSpec.describe Might::SortParameter do
context '#direction' do
subject(:parameter) { described_class.new(:asc, definition) }
subject(:direction) { parameter.direction }
context 'when reversed direction defined' do
let(:definition) { Might::SortParameterDefinition.new(:... |
# Problema :
# Imagine uma brincadeira onde crianças falam um número em ordem (1,2,3…).
# Se o número for múltiplo de 3 então a criança deve dizer Fizz ao invés do número,
# se o número for múltiplo de 5 então a criança deve dizer Buzz,
# por fim se as duas condições forem verdadeiras então a criança precisa dizer Fizz... |
module ApplicationHelper
def km(meters)
(meters / 1000).round(2)
end
def duration(seconds)
hours = seconds / 3600
minutes = (seconds % 3600) / 60
seconds = seconds % 60
if hours > 0
return "#{hours}h#{minutes < 10 ? "0#{minutes}" : minutes}"
else
return "#{minutes}min #{second... |
class AddEmploymentStatus < ActiveRecord::Migration[5.1]
def change
add_column :work_experiences, :employment_status, :boolean, default: false
end
end
|
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_one :identity, dependent: :destroy
has_one ... |
class ChangeWineryFromWines < ActiveRecord::Migration
def change
change_column :wines, :winery, :string, limit: 100
end
end
|
# frozen_string_literal: true
require 'active_support/core_ext/object/blank.rb'
require 'active_support/core_ext/string/conversions.rb'
require 'active_support/core_ext/string/filters.rb'
require 'rufus-scheduler'
load "#{__dir__}/mfc_case/change_state_to.rb"
load "#{__dir__}/mfc_case/rejector.rb"
load "#{__dir__}/mf... |
# frozen_string_literal: true
require "test_helper"
class Primer::ViewComponentsTest < Minitest::Test
def test_generate_statuses
statuses = Primer::ViewComponents.generate_statuses
assert_equal Hash, statuses.class
assert_equal String, statuses.values.first.class
end
def test_written_statuses_are_... |
FactoryGirl.define do
factory :district do
name FFaker::Name.name
city
permalink "link"
end
end
|
# The business logic for events.
#
# This code is part of the Stoffi Music Player Project.
# Visit our website at: stoffiplayer.com
#
# Author:: Christoffer Brodd-Reijer (christoffer@stoffiplayer.com)
# Copyright:: Copyright (c) 2015 Simplare
# License:: GNU General Public License (stoffiplayer.com/license)
... |
class RenameGameQuestionOptionsToBaseQuestionOptions < ActiveRecord::Migration
def change
rename_table :game_question_options, :base_question_options
add_column :base_question_options, :type, :string, index: true
rename_column :base_question_options, :game_question_id, :base_question_id
end
end
|
# encoding: utf-8
module TextUtils
module HypertextHelper
def strip_tags( ht )
### to be done
## strip markup tags; return plain text; use brute force for now
# check at least for presence of required a-z+ tag names
#
# note: make sure we cover h1/h2/h3/h4/h5/h6 tag w/ number!!
### ht.gsub( /<[^>]+>... |
# some custom extensions
module TaggingExtra
# Returns all the tags present in a collection of items. The tags
# are only present once in the returned value. When called whithout
# parameters, all the site items are considered.
def tag_set(items = nil)
items = @items if items.nil?
tags = Set.new
i... |
require 'test_helper'
class ListenersTest < Test::Unit::TestCase
def test_default_listerers_contains_listeners
listeners = Listeners.default_listeners
assert_kind_of Array, listeners
assert_not_empty listeners
listeners.each do |listener|
assert_respond_to listener, :call
end
end
end
|
require 'spec_helper'
RSpec.describe DynamodbOrm::Model::Callbacks do
include_context(
'with dynamodb table',
:sample_table,
attribute_definitions: [{
attribute_name: 'id',
attribute_type: 'S'
}],
key_schema: [{
attribute_name: 'id',
key_type: 'HASH'
}]
)
context ... |
module AuthenticationHelper
def stub_sign_in(user)
user.update(token: 'letmein')
session[:remember_token] = user.remember_token
end
def sign_in_as(user, token = 'letmein')
stub_oauth(
username: user.github_username,
email: user.email_address,
token: token
)
stub_scopes_reque... |
class CreateReceivers < ActiveRecord::Migration[6.0]
def change
create_table :receivers do |t|
t.string :postcode, default: "", null: false
t.integer :prefecture_id, null: false
t.string :city, default: "", null: false
t.string :block, default: "", ... |
json.array!(@propiedades) do |propiedad|
json.extract! propiedad, :id, :nombre, :direccion, :valor, :estrato, :persona_id
json.url propiedad_url(propiedad, format: :json)
end
|
class Roman
def self.to_roman(input)
one = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']
ten = ['X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC']
hundred = ['C', 'CC', 'CCC', 'CD', 'D' ,'DC', 'DCC', 'DCCC', 'CM']
thousand = ['M', 'MM', 'MMM']
roman_numbers = [one, ten, hundred, ... |
require 'faker'
# 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 R... |
class FollowsController < ApplicationController
before_filter :need_login_user,:need_login_name_user
before_filter :get_space_user
layout "space"
def index
conditions = ["1=1"]
conditions << "is_fans=1" if params[:tp] == "friends"
@follows = @space_user.follows.paginate(:page=>params[:page]||1, ... |
class Invoice < ApplicationRecord
scope :paid, -> { joins(:transactions).merge(Transaction.successful) }
scope :cancelled, -> { where(status: 0) }
scope :in_progress, -> { where(status: 1) }
scope :completed, -> { where(status: 2) }
enum status: { cancelled: 0, 'in progress': 1, completed: 2 }
belongs_to ... |
class Game
attr_accessor :board, :player_1, :player_2
def initialize(player1 = Player::Human.new("X"), player2 = Player::Human.new("O"), board = Board.new)
@player_1 = player1
@player_2 = player2
@board = board
end
WIN_COMBINATIONS = [
[0,1,2], #top row
[3,4,5], #middle row
[6,7,8], #b... |
require "rspec"
require_relative "../lib/determine_price.rb"
describe DeterminePrice do
let(:determine_price) {
described_class.new(
filename: filename,
start_date: start_date,
end_date: end_date)
}
context "rates are weekend vs. weekday" do
let(:filename) { "sample_weekend_weekday.... |
class Podcast < ApplicationRecord
belongs_to :educator_profile
end
|
# frozen_string_literal: true
module GraphQL
module StaticValidation
# The validation context gets passed to each validator.
#
# It exposes a {GraphQL::Language::Visitor} where validators may add hooks. ({Language::Visitor#visit} is called in {Validator#validate})
#
# It provides access to the sch... |
require 'rails_helper'
describe SalesController do
describe "routes for Sales" do
it "routes get /sales/:id to the sales controller, show action with id" do
expect(get("/sales/1")).to route_to("sales#show", :id => "1")
end
it "routes post /sales to the sales controller, create action" do
exp... |
class AddTeamsToGames < ActiveRecord::Migration[5.0]
def change
add_reference :games, :home_team
add_reference :games, :away_team
end
end
|
class User < ApplicationRecord
include Devise::JWT::RevocationStrategies::JTIMatcher
include Tokenizable
has_many :team_users
has_many :tracks
has_many :teams, through: :team_users
has_many :projects #, through: :teams, source: :projects
belongs_to :company
# Include default devise modules. Others ava... |
class ListPhotoSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
attributes :created_at, :title, :description, :photos, :links
def photos
ActiveModelSerializers::SerializableResource.new(
object.photos.select(Partner::Photo.base_columns).limit(10),
each_serializer:... |
require 'test_helper'
class MainAppRootUrlTest < ActionDispatch::IntegrationTest
test "root_url link points to main_app.root_url" do
visit "/pointless_feedback"
assert page.has_link?("Homepage", :href => current_host + "/")
end
end
|
# Problem 325: Stone Game II
# http://projecteuler.net/problem=325
#
# A game is played with two piles of stones and two players. At her turn, a player removes a number of stones from the larger pile. The number of stones she removes must be a positive multiple of the number of stones in the smaller pile.
#
#
#
# ... |
class RenameTopicNameToThreadName < ActiveRecord::Migration
def change
rename_column :topics, :topic_name, :thread_name
end
end
|
# Choice Model
class Choice < ApplicationRecord
belongs_to :campaign
has_many :votes
validates_presence_of :name
validates_uniqueness_of :name, scope: :campaign_id, case_sensitive: false
end
|
class Bottles
def verse(bottles)
#capitalize Uppercase first letter to words
"#{how_many_bottles(bottles).capitalize} of beer on the wall, #{how_many_bottles(bottles)} of beer.\n#{do_what(bottles)}, #{how_many_bottles(bottles - 1)} of beer on the wall.\n"
end
def verses(first, last)
... |
module Joybox
module UI
class Menu < CCMenu
alias_method :align_items_vertically, :alignItemsVertically
alias_method :align_items_vertically_width_padding, :alignItemsVerticallyWithPadding
alias_method :align_items_horizontally, :alignItemsHorizontally
alias_method :align_items_horizonta... |
class Patient < ActiveRecord::Base
validates :location_id, :presence => true
validates :first_name, :presence => true
validates :last_name, :presence => true
# validates :address_street1, :presence => true
# validates :address_city, :presence => true
# validates :address_state, :presence => true
# validates :... |
module Day13
class Cart
attr_accessor :row, :column, :removed
attr_reader :direction, :turn_conductor
def initialize(row:, column:, direction:, cart_id: nil)
@cart_id = cart_id
@row, @column = row, column
@direction = direction
@turn_conductor = IntersectionConductor.new
@re... |
require "rails_helper"
RSpec.describe Subscription, type: :model do
it { is_expected.to have_many(:payments) }
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:package) }
end
|
class Shipment < ActiveRecord::Base
attr_accessible :packing_slip_attributes, :refrigerate, :submitter_id, :assigned_to_id, :bill_to_id, :reference_number, :classification_id, :bol_pro_number, :carrier_id, :carrier_invoice_number, :cost, :deliver_by_date, :picked_up_at, :stock_transfer_wo_number, :debit_memo_number, ... |
# frozen_string_literal: true
# player input to board coordinate
module BoardCoords
def self.create_coord(input)
arr = []
input = input.split('')
x_coord = input[1]
y_coord = input[0]
case x_coord.to_i
when 1
arr << 7
when 2
arr << 6
when 3
arr << 5
when 4
... |
require 'test_helper'
class UsersLoginTest < ActionDispatch::IntegrationTest
def setup
@user = User.new(name: "Foo", email: "bbbbb@aa.cc", password: "edcedcedc")
end
test "login invalid, get flash and redirect" do
get login_path
assert_template 'sessions/new'
post login_path, session: {email: @user.ema... |
class TransportAdditionalField < ActiveRecord::Base
validates_presence_of :name
# validates_uniqueness_of :name,:case_sensitive => false
validates_uniqueness_of :name, :scope => :type ,:case_sensitive => false
validates_format_of :name, :with => /^[^~`@%$*()\-\[\]{}"':;\/.,\\=+|]*$/i,
:message => :must... |
require 'sequel'
require 'jdbc/dss'
Jdbc::DSS.load_driver
Java.com.gooddata.dss.jdbc.driver.DssDriver
class Helpers::ADS
def initialize(config={})
@username = config.delete(:username)
@password = config.delete(:password)
@ads_instance_url = config.delete(:ads_instance_url)
if @username==''... |
class EARMMS::UserSettingsIDController < EARMMS::ApplicationController
get '/' do
unless logged_in?
flash(:error, "You must be logged in to access this page.")
next redirect('/auth')
end
@title = "User ID"
haml :'user_settings/userid'
end
end
|
require_relative '../../environment'
require 'minitest/spec'
require 'minitest/autorun'
require 'classes/body_part'
require 'classes/equippable_item'
describe BodyPart do
before do
@type = :hand
@name = "Left hand"
@container = true
@item = EquippableItem.new("Sword", :sword, 4, :hand)
@injury = ... |
class Post < ActiveRecord::Base
belongs_to :user
has_and_belongs_to_many :subcategories
has_many :comments, as: :commentable
validates :title, :body, :user, presence: true
validates_uniqueness_of :title, scope: [:user_id]
def timestamp
created_at.strftime('%d %B %Y %H:%M:%S')
end
searcha... |
require 'rails_helper'
RSpec.describe ActivityLogger do
describe '#initilize' do
shared_examples 'no error' do
it 'does not raise an error' do
expect { ActivityLogger.new(object, action) }.
to_not raise_error
end
end
context 'when object is valid' do
let(:action){ A... |
Rails.application.routes.draw do
root 'pages#index'
resources :tracker_projects, only: [:show]
resources :users
resources :projects do
resources :memberships
resources :tasks do
resources :comments, only: [:new, :create]
end
end
get '/about', to: 'about#about', as: :about
get '/term... |
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} root
# @param {Integer} k
# @return {Integer}
#
def kth_smallest(root, k)
heap = [] # to save the output... |
class AddIndexToManufacture < ActiveRecord::Migration[5.2]
def change
add_index :manufactures, [:e_no, :result_no, :generate_no], :unique => false, :name => 'resultno_eno'
add_index :manufactures, :facility_name
add_index :manufactures, :facility_effect
add_index :manufactures, :facility_lv
add_in... |
### GENRE CLASS
class Genre
attr_accessor :name
@@genre_array = []
def initialize
@@genre_array << self
end
def self.reset_genres
@@genre_array = []
end
def songs
@songs ||= []
end
def artists
songs.collect{|song| song.artist}.uniq
end
def self.all
@@genre_array
end
end |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :player do
user_id { FactoryGirl.create(:user).id }
game_id { FactoryGirl.create(:game).id }
end
end
|
class CompanyInfo
include Mongoid::Document
include Mongoid::Timestamps::Short
field :name, type: String
field :phone, type: String
field :fax, type: String
field :website, type: String
field :state_license, type: String
field :tax_id, type: String
field :timezone, type: String, default: 'Pacific Tim... |
require_relative '00_tree_node'
class KnightPathFinder
attr_reader :visited_positions, :root_node
POSSIBLE_MOVES = [
[-1, 2],
[-1, -2],
[1, 2],
[1, -2],
[2, -1],
[2, 1],
[-2, 1],
[-2, -1]
]
def initialize
@root_node = PolyTreeNode.new([0,0])
@visited_positions = [[0,0]... |
{
'info' => {
'service_account_email' => '',
'p12_file_name' => '',
'impersonated_username' => '',
'enable_debug_logging' => 'Yes'
},
'parameters' => {
'group_name' => 'Test Admin SDK',
'group_id' => 'test.admin.sdk.55101@ajaea.com',
'group_description' => 'A group testing the new Admi... |
class JsonSaver
def self.register_save_on_exit(bot)
at_exit do
bot.save_to_file
end
end
end
|
class User < ActiveRecord::Base
validates :username, :password_digest, :session_token, :first_name, :last_name, :avatar, :email, :address, presence: true
validates :username, uniqueness: true
validates :password, length: {minimum: 6, allow_nil: true}
after_initialize :ensure_session_token
after_initialize :a... |
module Dashboard
class MailersController < Dashboard::BaseController
before_filter :prepare_everything
def new
end
def finalists
end
def participants
end
def create
if valid_email_params?
collaborators = Member.find_all_by_id(parse_members) if params[:members]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.