text stringlengths 10 2.61M |
|---|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
apipie
root to: 'application#welcome'
namespace :api, defaults: { format: :json } do
namespace :v1 do
resources :languages, except: [:new, :edit]
get 'user/langua... |
def most_recent_activity(officer)
dates = officer.incidents.pluck(:report_date).map { |rd| rd.sub(/ .*/, "") }
dates.max
end
def concerning_articles(officer)
officer.articles_officers.confirmed.where(concerning: true).count > 0
end
def uniq_action_taken(officer)
officer.complaint_officers.pluck(:action_taken)... |
class Series < ActiveRecord::Base
belongs_to :vendor
has_many :devices
has_and_belongs_to_many :series, :join_table => 'compatibility', :association_foreign_key => 'destination_id', :foreign_key => 'source_id'
end
|
class MembershipsController < ApplicationController
before_action :set_project
before_action :set_membership, only: [:destroy]
def create
@project.memberships.create(memberships_params)
redirect_to @project
#flash below uses custom method in project model
flash[:success] = "#{@project.newest_member.email... |
# part 2 only
class Spiral
INPUT = 325489
attr_accessor :x, :y, :dir, :grid
def initialize
@grid = Hash.new { |h, k| h[k] = Hash.new 0}
@x = 0
@y = 0
@dir = "east"
end
def fill
val = 1
grid[x][y] = val
while val < INPUT
step
val = calculate_value
grid[x][y] = ... |
require 'spec_helper'
module Foortran
describe Parser do
let(:grammar) { "foortran_90" }
let(:parser) { Parser.new(grammar) }
describe ".new" do
it "sets the grammar attribute" do
expect(parser.grammar).to eq(grammar)
end
end
end
end
|
require 'pry'
class Solution
def self.add(first, second)
result_node = result_root = ListNode.new(value: 0)
carry = 0
while first
digit_sum = first.value + second.value + carry
carry = digit_sum % 10 + 1 if digit_sum > 9
result_node.right = ListNode.new(value: digit_sum % 10)
res... |
require 'spec_helper'
require 'rails_helper'
feature 'mailers' do
scenario "delete a game request" do
user = FactoryGirl.create(:user)
gr = FactoryGirl.create(:gamerequest, user: user)
admin = FactoryGirl.create(:admin)
visit root_path
click_link "Login Admin"
fill_in "Email", with: admin.em... |
Pod::Spec.new do |s|
s.name = 'DSPFramework'
s.swift_version = '5.0'
s.version = '1.0.0'
s.license = { :type => 'Apache License, Version 2.0', :text => <<-LICENSE
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may ... |
# -*- mode: ruby -*-
# # vi: set ft=ruby :
require 'fileutils'
Vagrant.require_version ">= 1.6.0"
# Defaults for config options defined in CONFIG
$num_instances = 6
$instance_name_prefix = "centos"
$enable_serial_logging = false
$share_home = false
$vm_gui = false
$vm_memory = 3072
$vm_cpus = 2
$forwarded_ports = {5... |
class ArtistsController < ApplicationController
before_action :set_artist, only: [:show, :destroy]
def index
@artists = Artist.all
end
def show
@albums = @artist.albums
end
def destroy
if @artist.destroy
redirect_to root_path
else
redirect_to artist_path(@artist)
end
end... |
class RemoveRowAndColFromPlantings < ActiveRecord::Migration
def change
remove_column :plantings, :row
remove_column :plantings, :column
end
end
|
### VERSION SORTER
# Instructions:
# The version sort takes into account the fact that file names frequently include indices or version numbers. Standard sorting functions usually do not produce the ordering that people expect because comparisons are made on a character-by-character basis. The version sort addresses t... |
# the following code is "stolen" from homebrew Library/utils
class Tty
class <<self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def yellow; underline 33 ; end
def reset; escape 0; end
def em; underline 39; end
private
def color n
escape "0;#{n}"
e... |
module Nidyx
class Model
attr_accessor :properties, :dependencies
attr_reader :name
def initialize(name)
@name = name
@properties = []
@dependencies = Set.new
end
end
end
|
class RequestMailer < ApplicationMailer
helper_method :feedback_url
attr_reader :req
def send_request(req)
@req = req
mail to: to, subject: subject
end
private
def to
address = Mail::Address.new(req.customer_email)
address.display_name = req.customer_name
address
end
def subjec... |
class Point
attr_accessor :x
attr_accessor :y
def initialize(x=0, y=0)
@x, @y = x, y
end
def inspect
"(#{ @x }, #{ @y })"
end
# 二元运算符
def +(other)
self.class.new(@x + other.x, @y + other.y)
end
def -(other)
self.class.new(@x - other.x, @y - other.y)
end
# 一元运算符
def +@
dup
... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
helper_method :current_user
protect_from_forgery with: :exception
#Autentykacja
def authenticate
#authenticate_or_request_with_http_ba... |
class Api::V1::EventsController < Api::V1::ApiController
def create
event = Event.new(event_params)
if event.save
render json: { result: { event: event } }, status: 201
else
render json: { errors: { internal: event.errors } }, :status => 500
end
end
private
def event_params
... |
class Daylite::Keywordorganizationjoin < Daylite::Base
belongs_to :organization, class_name: 'Organization', foreign_key: 'organizationid'
belongs_to :keyword, class_name: 'Keyword', foreign_key: 'keywordid'
end
|
# -*- encoding : utf-8 -*-
require 'spec_helper'
describe GroupHelper do
describe :abbreviate_long_name do
before(:each) do
@group = mock_model(Group)
@group.stub(:abbreviation).and_return("LIM")
end
context "group name is too loong" do
before(:each) do
@group.stub(:name).and_r... |
require 'spec_helper'
describe NagiosPlugin::Plugin do
before do
class MyPlugin < NagiosPlugin::Plugin; end
@plugin = MyPlugin.new
class MergedOptionsPlugin < NagiosPlugin::Plugin
def initialize(options, &blk)
super(options, &blk)
@foo = options[:foo]
end
attr_reader :w... |
require "json"
module Alfred
def self.display(entries=[])
puts({:items => Array(entries)}.to_json)
end
class Item
attr_accessor :uid, :title, :subtitle, :arg, :icon, :valid, :autocomplete
attr_accessor :type, :mods, :text, :quicklook, :variables
# uid - optional unique identifier for ... |
# encoding: UTF-8
module API
module Helpers
module V1
module PresentationsHelpers
extend Grape::API::Helpers
def serialized_presentation(presentation, options = {})
options = { serializer: :presentation }.merge(options)
serialized_object(presentation, options)
... |
module MailUp
module Console
class Import
attr_accessor :api
def initialize(id, api)
@api = api
@id = id
end
# Get import status.
#
# @return [JSON] A Status object with the following attributes:
# * idImport [Integer]
# * Completed [Boolean]
... |
require 'erb'
class Mech::Compiler::Format
include Mech::Configurator
def compile(data, params = {}, &block)
raise 'Compile method not exist'
end
def initialize(*args)
@data = {}
end
def with_template
ERB.new(File.read(tmp_path)).result(binding)
end
def tmp_path
raise 'Not defined ... |
class CreateDocumentSubjects < ActiveRecord::Migration
def change
create_table :document_subjects do |t|
t.references :document, index: true, foreign_key: true, null: false
t.references :subject, index: true, foreign_key: true, null: false
t.timestamps null: false
end
add_index :documen... |
require 'rails_helper'
RSpec.describe ImagesController, type: :controller do
allow_user_to(:manage, Image)
describe "GET#new" do
it "renders properly" do
get :new
expect(response).to render_template :new
expect(response).to have_http_status(200)
expect(assigns(:image)).to be_a_new(Imag... |
# This source is part of the Ruby bindings for stb_image.
# It is released into the public domain, as with stb_image itself.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NO... |
class AddCategoriesAndCategoriesArticlesTable < ActiveRecord::Migration
def change
create_table :categories do |t|
t.string :name
end
create_table :categories_articles do |f|
f.integer :category_id
f.integer :article_id
end
end
end
|
class UserShipment < ActiveRecord::Base
belongs_to :user
belongs_to :shipment
after_create :send_carrier_email
# send a signup email to the user, pass in the user object that contains the user's email address
def send_signup_email(user)
@user = user
mail( :to => @user.email,
:subject => 'Thanks for... |
class CategorySerializer
include JSONAPI::Serializer
attributes :id, :title
end
|
require 'rails_helper'
RSpec.describe Agent, type: :model do
describe '.acquire_access_token!' do
let(:agent) { FactoryBot.create(:agent) }
it 'return access_token if exist' do
access_token = 'fksahdfkadbshbkjdfsa'
agent.access_token = access_token
agent.save!
agent.acquire_access_tok... |
require 'rails_helper'
require 'json'
RSpec.describe 'Users', type: :request do
before(:all) do
post '/tokens'
data = JSON.parse(response.body)
@token = data['token']
@id = data['id']
@user = create(:user, username: 'Richard', email: 'richard@gmail.com')
end
after(:all) do
Token.destroy_... |
class Festival < ApplicationRecord
has_many :festival_artists, dependent: :destroy
has_many :artists, through: :festival_artists
validates :name, presence: true
validates :url, presence: true
end
|
class FontHindMysuru < Formula
head "https://github.com/google/fonts.git", branch: "main", only_path: "ofl/hindmysuru"
desc "Hind Mysuru"
homepage "https://github.com/itfoundry/hind-mysuru"
def install
(share/"fonts").install "HindMysuru-Bold.ttf"
(share/"fonts").install "HindMysuru-Light.ttf"
(shar... |
# This line will print the string
puts "I will now count my chickens:"
# this line will print Hens and then the math equation inside the the brackets
puts "Hens #{25.0 + 30.0 / 6.0}"
puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}"
## This line will print the string
puts "Now I will count the eggs:"
# this line will print t... |
# frozen_string_literal: true
class ListNode
attr_accessor :val, :next
def initialize(val, n = nil)
@val = val
@next = n
end
end
# @param {ListNode} l1
# @param {ListNode} l2
# @return {ListNode}
def add_two_numbers(l1, l2)
carry = 0
dummy_head = n = ListNode.new(0)
while !l1.nil? || !l2.nil? || ... |
class Player < ApplicationRecord
belongs_to :user
belongs_to :tournament
has_many :ratings, dependent: :destroy
has_many :game_ranks, dependent: :destroy
has_many :championship_players, dependent: :destroy
STREAK_THRESHOLD = 3
def self.active(at = Time.zone.now)
where('players.end_at IS NULL OR pla... |
require 'minitest/autorun'
require './digits_check.rb'
class TestDigitsCheck < MiniTest::Unit::TestCase
def test_simple_digit
test = "0123"
assert digits_check(test)
assert digits_check2(test)
assert digits_check_regex(test)
end
def test_simple_nondigit
test = "0123a"
assert !digits_check(test)
asse... |
require 'artii'
require 'CSV'
class Record
attr_accessor :artist, :album, :yearofrelease
def initialize (artist,album, yearofrelease)
@artist = artist
@album = album
@yearofrelease = yearofrelease
end
end
def add_record(records)
artistname = read_string("Please enter artist name :... |
class Track < ActiveRecord::Base
has_many :events
belongs_to :pack
validates_numericality_of :total_lanes
validates_presence_of :total_lanes
validates_presence_of :name
def name_pack
"#{self.name}-#{self.pack.name}"
end
def name_lanes
"#{self.name}-#{self.total_lanes} lanes"
end
... |
class Mailer < ActionMailer::Base
def signup(user)
setup user, "sales@editfu.com"
subject "Welcome to EditFu. Now meet the ninjas."
end
def editor_invitation(user)
setup user, "noreply@editfu.com"
subject "Content editor invitation."
end
def reset_password(user)
setup user, "norepl... |
class TypesController < ApplicationController
before_action :authenticate_user!
def index
@types = Type.all
end
def new
@type = Type.new
end
def create
@type = Type.new(set_type)
if @type.save
redirect_to types_path, notice: 'Type add successfully!'
else
render :new
end
... |
class CountriesController < ApplicationController
def index
@countries = Country.all
end
def new
@country = Country.new
end
def create
@country = Country.new(country_params)
if @country.save
redirect_to countries_path
else
render :new
end
end
private
def country_par... |
class Cartitem < ApplicationRecord
belongs_to :cart
belongs_to :product
def cartitem_subtotal
return (self.qty * self.cost).round(2)
end
end
|
class City < ActiveRecord::Base
has_many :regions, dependent: :destroy
has_many :playgrounds
validates :name, presence: true
end |
class Tag < ApplicationRecord
has_many :join_tag_gossips
has_many :gossips, through: :join_tag_gossips
end
|
# create a custom renderer that allows highlighting of code blocks
class HTMLwithAlbino < Redcarpet::Render::HTML
def block_code(code, language)
RubyPython.start(:python_exe => "python2.6")
Pygments.highlight(code, :lexer => language)
end
end
module ApplicationHelper
include Twitter::Autolink
def sit... |
class Topic < ApplicationRecord
validates_presence_of :name
validates_presence_of :author
enum state: { open: 0, closed: 1 }
end
|
# frozen_string_literal: true
class Stack
class StackOutOfSpaceError < StandardError; end
attr_accessor :base, :top_element, :size
def initialize(size)
@size = size
@top_element = 0
@base = []
end
def push(element)
raise StackOutOfSpaceError unless @base.size < size
@top_element += 1
... |
# frozen_string_literal: true
module Boring
module Bootstrap
class InstallGenerator < Rails::Generators::Base
desc "Adds Bootstrap to the application"
source_root File.expand_path("templates", __dir__)
def add_bootstrap_package
say "Adding bootstrap packages", :green
run "yarn ... |
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
geocoded_by :address
after_validation :geocode, if: :user_address_changed?
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :... |
module HelloWorld
# You can use a class here too, but a module is a bit more appropriate
# since modules are typically for methods, and classes are more about objects
def self.hello
return 'Hello, World!'
end
end |
class AddAttachmentImgpalleteToColor < ActiveRecord::Migration
def self.up
add_column :colors, :imgpallete_file_name, :string
add_column :colors, :imgpallete_content_type, :string
add_column :colors, :imgpallete_file_size, :integer
add_column :colors, :imgpallete_updated_at, :datetime
end
def sel... |
class Post
# has a title
# belongs to an author
attr_accessor :title, :author
# is initialized with an argument of a title
def initialize(title)
@title = title
end
# knows the name of its author
# returns nil if the post does not have an author
def author_name
self.author ? self.author.name ... |
require 'shanty/plugin'
require 'shanty/project'
module Shanty
module Plugins
# Public: Cucumber plugin for testing ruby projects.
class CucumberPlugin < Plugin
# By default, we'll detect Cucumber in a project if has a dependency on it in a Gemfile or *.gemspec file. If you
# don't use these file... |
class ApplicationController < ActionController::Base
http_basic_authenticate_with name: Rails.application.secrets.basic_user,
password: Rails.application.secrets.basic_auth
protect_from_forgery with: :exception
end
|
require 'pp'
class Tank < Vehicle
HEALTH = 100
FUEL = 100
def initialize(options = {})
@position = options[:position] || Position.new
@bearing = options[:bearing] || 0
@weapon_primary = Cannon.new
@weapon_secondary = Machinegun.new
@health = HEALTH
@fuel... |
# frozen_string_literal: true
FactoryBot.define do
factory :branch do
name { Faker::Company.name }
region { 0 }
end
end
|
class Booking < ActiveRecord::Base
belongs_to :cart
belongs_to :item, inverse_of: :bookings
has_many :line_items, dependent: :destroy
validates :item_id, :quantity, :name_at_checkout,
presence: true
before_validation :set_vals
def sms_summary
"#{checkin}-#{checkout}/item.short"
end
def checkin... |
class AddRolesToUser < ActiveRecord::Migration
def change
add_column :users, :superadmin, :boolean
add_column :users, :admin, :boolean
add_column :users, :operator, :boolean
add_column :users, :first_name, :string
add_column :users, :last_name, :string
add_column :users, :phone, :string
end
end
|
class CertifyAccountJob < ApplicationJob
queue_as :default
PROFILE_PATHS = {
"furaffinity" => [
'.maintable'
],
"sofurry" => [
'#sf-section-1'
],
"inkbunny" => [
'.elephant_white'
],
"weasyl" => [
'#user-profile'
],
"commissio" => [
'.profile-info'
... |
class ArticleDecorator < Draper::Decorator
# include Draper::LazyHelpers
delegate_all
decorates_association :author
decorates_association :author, with: AuthorDecorator
decorates_finders
def publication_status
if published?
"Published at #{published_at}"
else
"Unpublished"
end
en... |
#
# Author:: Manuel David Franco Barrios (<mafraba@gmail.com>)
# © Copyright IBM Corporation 2015.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#
module Fog
module Softlayer
class Compute
class Mock
# Powers on a VM
# @param [Integer] id
# @return [Excon::Response]
... |
module FormHelper
def link_to_remove_nested_fields(*args, &block)
if block_given?
element = args.first || {}
html_options = args.second
link_to_remove_fields(capture(&block), element, html_options)
else
name = args[0]
element = args[1]
html_options = args[2] || {}
el... |
class BoatPropertyTypesController < ApplicationController
before_action :check_grants
def index
@boat_property_types = BoatType.property_types
@property_types = PropertyType.for_select_list
@title = @header = "Характеристики лодок"
end
def create
BoatPropertyType.update_properties_list(boat_p... |
require 'spec_helper'
describe DynaStruct::Full do
describe '.new' do
subject { described_class.new(info) }
context 'given a hash' do
context 'with valid info' do
let(:info) { { a: ?a, b: ?b, ab: 12, a18: nil } }
it 'should assign instance variables corresponding to the Hash' do
... |
# クラスを定義する
class User
attr_reader :first_name, :last_name, :age
def initialize(first_name, last_name, age)
@first_name = first_name
@last_name = last_name
@age = age
end
# 名前を表示するメソッド
def full_name
"#{first_name} #{last_name}"
end
end
# ユーザーのデータ作成
users = []
users << User.new('Alice', 'Ruby', 25)
users... |
Gem::Specification.new do |s|
s.name = 'english_spellchecker'
s.version = '0.3.1'
s.summary = 'A basic English dictionary spellchecker which returns ' +
' the correctly spelled word or nil if the word was not found.'
s.authors = ['James Robertson']
s.files = Dir['lib/english_spellchecker.rb']
s.add_r... |
require File.dirname(__FILE__) + '/../spec_helper'
describe Assetify do
it "should create one js asset secretary per asset (dup)" do
Assetify.send(:instance_variable_set, :@secretaries, {})
Assetify::AssetSecretary.should_receive(:new).once.and_return(mock(Object, :full_concatenation => "dood"))
Assetify... |
class Actor < ActiveRecord::Base
has_and_belongs_to_many :movies, :join_table => "movies_actors"
end
|
# a program which asks us to type in as many words as we want
# one word per line, continuing until we just press Enter on an empty line
# and which then repeats the words back to us in alphabetical order
textList = []
i = 0
while ((text = gets.chomp).length > 0 )
# puts text
textList[i] = text
i += 1
end
textLis... |
Pod::Spec.new do |s|
version = "0.1.1"
s.name = "HXTag"
s.version = version
s.summary = "HXTag is a Tag layout for diversification."
s.homepage = "https://github.com/CapriHuang/HXPodSpec.git"
s.author = { "CapriHuang" => "1187395293@qq.com" }
s.source = { :git => "https:/... |
require 'spec_helper'
describe "31178705 has_sage_flow_states adds a filter to set the state for new records if its not already set default state" do
before(:each) do
class Foo < Sample
has_sage_flow_states :foo, :bar
end
end
it "Should have a value for sage_flow_state" do
f = Foo.new
f.sag... |
# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module MobileCenterApi
#
# Microsoft Visual Studio Mobile Center API
#
class Repositories
#
# Creates and initializes a new instance... |
# frozen_string_literal: true
module Zendesk
class Snitcher
class Ticket < Zendesk::Snitcher
def do_action(ticket, thread, options)
actions_by(ticket, thread, options) unless ticket.reply_count_equal?(thread.reply_count)
end
private
def actions_by(ticket, thread, options)
... |
Rails.application.routes.draw do
root 'wellcome#index'
resources :products
end
|
module TestBench
class CLI
class Run
Error = Class.new(RuntimeError)
def test_run
@test_run ||= TestBench::Run::Substitute.build
end
attr_writer :test_run
def exclude_file_pattern
@exclude_file_pattern ||= Defaults.exclude_file_pattern
end
attr_writer :e... |
FactoryBot.define do
sequence :title do |n|
"title#{n}"
end
factory :question do
title
user
body { "MyText" }
end
trait :invalid do
title { nil }
end
trait :with_links do
before :create do |question|
create_list(:link, 3, linkable: question)
end
end
trait :with_fi... |
class ListsController < ApplicationController
def index
@user = current_user
@lists = @user.lists.all
end
def show
@list = List.find(params[:id])
auth_check
end
def new
@list = List.new
end
def create
@list = List.new(allowed_params)
@list.user = current_user
if @list.sa... |
class PicasaWebRemotePhoto < RemotePhoto
def initialize(photo)
@id = photo.elements['gphoto:id'].text
@title = photo.elements['title'].text
@source_url = photo.elements['content'].attribute('src').value
@source_created_at = Time.at(photo.elements['gphoto:timestamp'].text.to_i/1000)
@thumbnai... |
require "rails_helper"
RSpec.describe "As a visitor on a flights show page" do
before :each do
@flight = Flight.create!(
number: "1737",
date: "10/20/20",
time: "10:00 AM",
departure_city: "Tampa",
arrival_city: "Las Vegas"
)
@passenger1 = @flight.passengers.create(
na... |
class Identity < CouchRest::Model::Base
include ::OmniAuth::Identity::Model
include ::OmniAuth::Identity::SecurePassword
validates_presence_of :name, :message => "Name is missing"
validates_uniqueness_of :email, :message => "We already have an account with that Email Address"
validates_format_of :email, :wit... |
#!/usr/bin/env ruby
require 'twitter_friendly'
client =
TwitterFriendly::Client.new(
consumer_key: 'CONSUMER_KEY',
consumer_secret: 'CONSUMER_SECRET',
access_token: 'ACCESS_TOKEN',
access_token_secret: 'ACCESS_TOKEN_SECRET',
expires_in: 86400 # 1day
)
ids = []
begin
... |
class AddContactsTemplatesTranslations < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.integer :student_id
t.string :Name
t.string :Phone_Number
t.string :Email
t.string :language, :default=> "english"
t.boolean :can_text, :default=> true
t.timestamp... |
require 'optparse'
require 'securerandom'
module Polidea::Artifacts
class Cli
attr_reader :options, :argv, :paths
attr_accessor :command, :client
VALID_COMMANDS = ['upload', 'dropbox_authorize']
def initialize(argv = nil)
@argv = argv || ARGV
@options = { :obfuscate_names => false }
... |
class UpdateTelegramBotJob < ApplicationJob
require 'telegram/bot'
queue_as :default
CHAT_IDS = [
ENV["TELEGRAM_FURRYMART_LIVE_CHANNEL_ID"]
]
def perform(proposal)
token = ENV["TELEGRAM_BOT_API_TOKEN"]
return unless proposal.visible? && token.present?
Telegram::Bot::Client.run(token) do ... |
# frozen_string_literal: true
require 'spec_helper'
describe Monologue::PostsController, type: :controller do
before do
@routes = Monologue::Engine.routes
end
describe 'GET #index' do
context 'archive_posts' do
before do
site = FactoryGirl.create(:site)
archive_post1 = FactoryGirl.... |
module Beats
class Kit
class LabelNotFoundError < RuntimeError; end
PLACEHOLDER_TRACK_NAME = "empty_track_placeholder_name_234hkj32hjk4hjkhds23"
def initialize(items, num_channels, bits_per_sample)
@items = items
@labels = @items.keys.freeze
@num_channels = num_channels
@bits_per... |
require 'minitest/autorun'
require 'minitest/spec'
require_relative("../lib/order")
describe ItemOrder do
describe "#create" do
describe "when you create a new ItemOrder" do
it "remembers the count and code" do
a = ItemOrder.new(12, "R234")
a.count.must_equal 12
a.code.must_equal "R... |
# frozen_string_literal: true
# Use model
class Use < ApplicationRecord
belongs_to :step
belongs_to :ingredient
validates :quantity, presence: true, numericality: { greater_than: 0,
less_than: 50_000 }
validates :measure, presence: true, length: { maximum... |
class WorkoutClassController < ApplicationController
skip_before_action :authenticate_user!
def index
@user = current_user
@gym = @user.gym
@classes = @gym.workout_classes.where(active: true).sort_by(&:title)
end
def create
WorkoutClass.transaction do
session_data = params[:selected_days... |
class AddIndexesInOnlineExamOptions < ActiveRecord::Migration
def self.up
add_index :online_exam_options, [:online_exam_question_id]
add_index :online_exam_options, [:is_answer]
end
def self.down
remove_index :online_exam_options, [:online_exam_question_id]
remove_index :online_exam_options, [:is... |
class MemberMailerWorker
include Sidekiq::Worker
sidekiq_options retry: false
def perform(options = {})
send(options['perform'], options) if respond_to? options['perform']
end
def send_registration_success_to_employer(options)
member = Member.find options['member_id']
MemberMailer.send_registrat... |
class AddSampleIdAndSupplierIdToMedicineStockRecords < ActiveRecord::Migration[5.0]
def change
add_column :medicine_stock_records, :sample_id, :integer
add_column :medicine_stock_records, :supplier_id, :integer
end
end
|
# frozen_string_literal: true
module Slack
class Request
class Chat < Slack::Request
SOURCE = "chat"
attr_reader :channel_id, :text, :thread_ts
def initialize(params)
@channel_id = params[:channel_id]
@text = params[:text]
@thread_ts = params[:thread_ts]
super... |
require 'minitest/autorun'
require_relative 'test_helper.rb'
describe FSM::State do
it 'initializes' do
state = FSM::State.new(:a_state) { puts "do nothing" }
assert_equal :a_state, state.name
assert_nil state.setup
assert_empty state.events
end
... |
#
# Cookbook Name:: development
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
group node.default['developer']['group']
user node.default['developer']['user'] do
action :create
comment "James Meldrum <james@htmldrum.com>"
group node.default['developer']... |
# frozen_string_literal: true
require 'statistic_calcs/distributions/binomial'
require 'statistic_calcs/helpers/alias_attributes'
require 'statistic_calcs/inference/errorable'
module StatisticCalcs
module Inference
# In a Bernoulli process, if the sampling is made to the Binomial
# the size of the sample `n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.