text stringlengths 10 2.61M |
|---|
# Longest String
# I worked on this challenge [by myself, with: ].
# longest_string is a method that takes an array of strings as its input
# and returns the longest string
#
# +list_of_words+ is an array of strings
# longest_string(list_of_words) should return the longest string in +list_of_words+
#
# If +list_of_wo... |
class ExerciseDescription < ActiveRecord::Base
default_scope { where(ended_at: nil) }
belongs_to :user
has_many :exercises
has_many :taggings, as: :taggable
has_many :tags, through: :taggings
before_validation :set_uniquable_name
# Validate associations
validates :user, presence: true
# Validate a... |
require 'rosalind'
describe Rosalind do
let(:rosalind) { Rosalind.new }
it "counts A, C, G and T #1" do
actual = rosalind.counts_symbol("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")
expected = "20 12 17 21"
expect(actual).to eq(expected)
end
it "counts A, C, G and T #... |
require 'lib/episode_helpers'
###
# Compass
###
compass_config do |config|
# Require any additional compass plugins here.
config.add_import_path "bower_components/foundation/scss"
# Set this to the root of your project when deployed:
config.http_path = "/"
config.css_dir = "stylesheets"
config.sass_dir = ... |
require 'test/unit'
require 'logger'
require 'pp'
require 'active_record'
require 'action_controller'
require 'marginalia'
ActiveRecord::Base.establish_connection({
:adapter => ENV["DRIVER"] || "mysql",
:host => "localhost",
:username => "root",
:database => "marginalia_test"
})
RAILS_ROOT = __FILE__
cl... |
class PlanActivity < ApplicationRecord
belongs_to :plan
belongs_to :activity
end |
#!/usr/bin/env ruby
#
# This script let you expand an ERB template from the command line
# while optionally passing variables that will be expanded in the
# template.
#
# Joint copyright:
# Copyright 2012, Antoine "hashar" Musso
# Copyright 2012, Wikimedia Foundation
# Command line option parsing library
require 'optp... |
require 'action_view'
class BasePresenter
include ActionView::Helpers::UrlHelper,
ActionView::Helpers::DateHelper,
ActionView::Helpers::AssetTagHelper
attr_reader :object
def initialize(object)
@object = object
end
def object_age_in_words
distance_of_time_in_words(object.created_at.to_dat... |
module Infuser
module Helpers
module Hashie
def camelize_hash(hash)
hash.each_with_object({}) do |(key, value), h|
camelized_key = get_camelized_key(key)
h[camelized_key] = value
end
end
def get_camelized_key(key)
camelized_key = key.to_s.split('_').... |
require 'spec_helper'
describe PresentationTrack do
subject { PresentationTrack.new app_session: app_session }
let(:app_session) { FactoryGirl.create :app_session }
let(:local_file) { File.new File.join Rails.root, '.gitignore' }
describe '#after_create' do
let(:app_session) { FactoryGirl.create :app_sess... |
# encoding: utf-8
require "#{File.dirname(__FILE__)}/lib/unicode_utils/version"
suffix = ENV["SUFFIX"]
gem_filename = "unicode_utils-#{UnicodeUtils::VERSION}.gem"
task "default" => "quick-test"
desc "Run unit tests."
task "test" do
ruby "-I lib test/suite.rb"
end
desc "Quick test run."
task "quick-test" do
ru... |
require 'rethinkdb'
class SetInstanceThreshold
include RethinkDB::Shortcuts
def id(id:)
@id = id
end
def threshold(threshold:)
@threshold = threshold
end
def execute(connection:)
r.table('instance').get(@id).update({threshold: @threshold}).run(connection)
end
end |
class CreateAdminAddresses < ActiveRecord::Migration
def change
create_table :admin_addresses do |t|
t.text :address
t.text :name
t.timestamp :latest
t.boolean :biostat
t.timestamps
end
end
end
|
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@joe = users(:joe)
end
# Enforces validation for fields
test "Requires first_name, last_name, and email attributes" do
@joe.first_name = nil
assert !@joe.valid?, "User was created with invalid attributes!... |
require 'rails_helper'
RSpec.describe 'Stageモデルのテスト', type: :model do
describe 'モデルのテスト' do
it "有効なStageの場合は保存されるか" do
expect(FactoryBot.build(:stage)).to be_valid
end
end
describe 'バリデーションのテスト' do
subject { stage.valid? }
let!(:other_stage) { create(:stage) }
let(:stage) { build(:stag... |
module Api
module V1
module Admin
# app/controllers/users_controller.rb
class RolesController < BaseApiController
before_action :set_role, only: [:show, :update, :destroy]
=begin
@api {post} /admin/clients Crear clientes
@apiName CreateClients
@apiGroup Clients
... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe Mongo::Collection::View do
let(:filter) do
{}
end
let(:options) do
{}
end
let(:view) do
described_class.new(authorized_collection, filter, options)
end
before do
authorized_collection.delete_many
end
... |
require 'os' # gem install os
require 'pathname'
if not OS.windows? then
puts("Firefox settings link only supported on windows.")
exit(1)
end
def link(from, to)
File.symlink(from, to)
end
def find_firefox_profile()
appDataPath = ENV['APPDATA']
firefoxAllProfilesPath = "#{appDataPath}\\Mozilla\\Fi... |
require "rails_helper"
RSpec.describe WatchedPokemonsController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/watched_pokemons").to route_to("watched_pokemons#index")
end
it "routes to #new" do
expect(:get => "/watched_pokemons/new").to route_to("watched... |
class Api::Users::SignUpOp
class << self
def execute(params)
User.create!(params[:login]) do |user|
user.attributes = user_params(params)
end
end
def allowed?(*)
true
end
private
def user_params(params)
(params[:user].presence || params).slice(:login, :passwo... |
FactoryGirl.define do
factory :link, :class => Refinery::Fg::Link do
sequence(:name) { |n| "refinery#{n}" }
end
end
|
module AnsiChameleon
module SequenceGenerator
class InvalidColorValueError < ArgumentError; end
class InvalidEffectValueError < ArgumentError; end
COLORS = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]
EFFECTS = { :none => 0, :bright => 1, :underline => 4, :blink => 5, :reverse =>... |
class RegistrationsController < Devise::RegistrationsController
prepend_before_action :set_minimum_password_length
private
def sign_up_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :institution)
end
def account_update_params
params.require(:u... |
require 'spec_helper'
describe "static_pages" do
subject { page }
describe "home page" do
before { visit home_path }
it { should have_title("LVE | Home") }
end
describe "about page" do
before { visit about_path }
it { should have_title("LVE | About") }
end
describe "help page" do
... |
require 'spec_helper'
describe Api::V1::FormsController do
describe "GET #show" do
before(:each) do
@form = FactoryGirl.create :form
get :show, id: @form.id
end
it "returns the information about a reporter on a hash" do
form_response = json_response
expect(form_response[:name]).t... |
class CreateHistories < ActiveRecord::Migration
def change
create_table :histories do |t|
t.integer :won_by_id
t.integer :lost_by_id
t.integer :card_id
t.timestamps
end
add_index :histories, :won_by_id
add_index :histories, :lost_by_id
add_index :histories, :card_id
... |
# == Schema Information
#
# Table name: artists
#
# id :integer not null, primary key
# name :string(255)
# body :text
# description :text
# url :string(255)
# myspace_url :string(255)
# facebook_url ... |
# 1)
def largest?(array, value)
array.each do |item|
return false if item > value
end
return true
end
# This is O(n) because the data grows proportionately along with the loop.
# 2)
def info_dump(customers)
puts "Customer Names: "
customers.each do |customer|
puts "#{customer[:name]}"
end
put... |
module ManageIQ::Providers::Amazon::CloudManager::Provision::Cloning
def do_clone_task_check(clone_task_ref)
source.with_provider_connection(:sdk_v2 => true) do |ec2|
instance = ec2.instance(clone_task_ref)
return false, :pending unless instance.exists?
status = instance.state.name.to_sym
... |
require 'spec_helper'
describe 'User API' do
before :each do
Ingredient.destroy_all
User.destroy_all
FactoryGirl.create :user
end
after :each do
Ingredient.destroy_all
User.destroy_all
end
it 'allows you to add an ingredient' do
api_login
post user_ingredients_path(response... |
require 'aethyr/core/objects/info/terrain'
require 'aethyr/core/util/log'
require 'aethyr/core/objects/inventory'
require 'aethyr/core/util/guid'
require 'aethyr/core/objects/info/info'
module Location
def initialize(*args, terrain_type: nil, indoors: nil, swimming: nil)
super
if info.terrain.nil?
inf... |
require 'minitest/autorun'
require './robot'
class TestRobotOutput < MiniTest::Unit::TestCase
def setup
@robot1 = Robot.new
@robot2 = Robot.new
end
# def test_robot_exists
# assert_equal "HKN65",@robot1.name
# end
def test_robot_nameis_5_characters
assert_equal 5,@robot1.name.length
e... |
class Kalculator
module Transform
def self.run(node, &block)
new_node = yield node
if is_terminal?(new_node)
new_node
elsif new_node.first.is_a?(Symbol)
args = new_node[1..-1].map{ |arg| run(arg, &block) }
args.unshift(new_node.first)
else
new_node.map{|node... |
require 'test_helper'
class People::Friend::ContactsControllerTest < ActionController::TestCase
setup do
@friend = friends(:Friend_1)
@person = people(:Person_1)
@contact = contacts(:Contact_1)
end
test "should get index contacts" do
get :index, person_id: @person, friend_id: @friend
assert_... |
class AddColumnsToContract < ActiveRecord::Migration
def change
add_column :contracts,:projectname, :string
add_column :contracts,:buyerparty, :string
add_column :contracts,:projectaddr, :string
add_column :contracts,:remark, :string
add_column :contracts,:contractno, :string
add_column :contr... |
[
:desc,
:props,
:returns,
:methods,
:class_methods,
:belongs_to,
:has_many,
:has_one,
:klass
].each do |dsl|
require_relative "./dsl/#{dsl}_provider"
end
[
:methods,
:class_methods,
:klass,
:args
].each do |dsl|
require_relative "./dsl/#{dsl}"
end
require_relative './dsl/box'
module Pa... |
class Companies::DepartmentsController < ApplicationController
#Developer: Marco&Marius
# === Callbacks ===
before_action :set_company, only: [:index]
def index
@departments = Department.where(company_id: @company.id)
end
private
def set_company
@company = Company.includes(:departments).find(... |
class DropTableClimbsTickLists < ActiveRecord::Migration
def change
drop_table :climbs_tick_lists
end
end
|
require_relative 'web_helpers'
feature 'Registering a new user' do
scenario 'visit /users/new and fill in the form' do
visit '/users/new'
expect(page).to have_content('Please sign up to use Chitter')
fill_in('email', with: 'acav@gmail.com')
fill_in('password', with: 'password')
click_button('Sign... |
module Skeptick
class DslContext
def swap(*args)
if args.size != 0 && args.size != 2
raise ArgumentError,
"wrong number of arguments (#{args.size} for 0, 2)"
end
args.empty? ? set('+swap') : set(:swap, args.join(','))
end
end
end
|
require 'rails_helper'
feature 'Comments' do
scenario 'Logged in user can add comments to task show, commenter is linked to user show page' do
password = 'password'
user = create_user(:password => password)
project = create_project
create_membership(project, user)
task = create_task(project)
... |
require 'spec_helper'
require 'account'
describe Account do
let(:statement) { double(:statement) }
let(:date_formatter) { double(:date_formatter, show_date: '01/01/2001') }
let(:subject) { described_class.new(statement, date_formatter) }
context('transactions') do
describe('#deposit') do
it('adds am... |
module ResourceAuthentication
module ActsAsResourceAuthentic
module Base
def self.included(klass)
klass.class_eval do
extend Config
end
end
module Config
def acts_as_resource_authentic(&block)
yield self if block_given?
acts_as_resourc... |
class Sandbox < ApplicationRecord
validates :name, presence: true
validates :sandbox_type, presence: true
validates :description, presence: true
validates :start_date, presence: true
validates :expected_end_date, presence: true
validates :owner, presence: true
validates :owner_team, presence: true
end
|
class MadsElement < ActiveFedora::Rdf::Resource
property :elementValue, predicate: MADS.elementValue
end |
class FixColumnDateFromOrderOfService < ActiveRecord::Migration
def change
change_column :order_of_services, :date_of_service, :date
change_column :order_of_services, :date_of_issue, :date
end
end
|
require 'rails_helper'
RSpec.describe User, type: :model do
user = FactoryGirl.create(:user)
it { is_expected.to have_many(:documents) }
it { is_expected.to validate_presence_of(:fullname) }
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_presence_of(:password) }
describe... |
# == Schema Information
#
# Table name: projects
#
# id :integer not null, primary key
# name :string not null
# slug :string not null
# team_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_proje... |
##
#This class is generated by gem ActiveAdmin for creating Admin users
# the class has no additional code
ActiveAdmin.register AdminUser do
##
# the index page of admin_users
index do
column :email
column :current_sign_in_at
column :last_sign_... |
Given(/^some fields$/) do
@user_data = {name: 'samuel', last_name: 'fisher'}
end
When(/^call new method$/) do
@user = User.new(@user_data)
end
Then(/^I see the new object with a given fields$/) do
expect(@user.instance_variables).not_to be_nil
expect(@user.instance_variables.length).to be >= 1
end
Given(/^a n... |
class AddAccessibileToProjects < ActiveRecord::Migration[5.2]
def change
add_column :projects, :accessible, :boolean
end
end
|
Gem::Specification.new do |s|
s.name = 'xml_file_renamer'
s.version = '0.0.9'
s.add_runtime_dependency "nokogiri", ["= 1.6.1"]
s.executables << 'xml_file_renamer'
s.date = '2014-08-14'
s.summary = "Batch rename XML files - rule the world!"
s.description = "A command line e... |
ActiveAdmin.register User, as: 'Runner' do
# == Allowed attributes
permit_params :first_name, :last_name, :email, :dni, :sex, :dob, :city, :gym,
:phone, :emergency_phone, :medical_insurance, :shirt_size
# == Filters
filter :first_name
filter :last_name
filter :dni
filter :email
filter ... |
require_relative 'client'
require_relative 'config'
module PuppetX
module CenturyLink
class Clc < Puppet::Provider
def self.read_only(*methods)
methods.each do |method|
define_method("#{method}=") do |v|
fail "#{method} property is read-only once #{resource.type} created"
... |
class Surrogate
::RSpec::Matchers.define :substitute_for do |original_class, options={}|
comparison = nil
subset_only = options[:subset]
match do |mocked_class|
comparison = ApiComparer.new(mocked_class, original_class).compare
if subset_only
(comparison[:instance][:not_on_actual] + ... |
class Used_Bicycle < Bicycle
attr_reader :age
def initialize(input_options)
super
@age = input_options[:age]
end
end |
Given(/^there is a project item ingest workflow in state '(.*)'$/) do |state|
FactoryBot.create(:workflow_project_item_ingest, state: state)
end
And(/^I perform project item ingest workflows$/) do
Workflow::ProjectItemIngest.all.each do |workflow|
workflow.perform
end
end
Then(/^there should be (\d+) projec... |
def uni_chars(string)
# edge cases? empty string
if string.length == 0
return true
end
# declare an empty hash
dict = {}
# iterate over the split string and for each letter, add one to the value of the hash for that letter
string.split('').each do |letter|
# check the hash already has a key for... |
require 'spec_helper'
describe City do
fixtures :cities, :locations
before(:each) do
@valid_attributes = { :city => "Delhi"}
end
it "should create a new instance given valid attributes" do
City.create!(@valid_attributes)
end
it "should require a valid city name" do
City.new(:city => " ").sh... |
module Web::Controllers::Team::Positions
class Show
include Web::Action
params do
required(:team_id).filled(:int?)
required(:id).filled(:int?)
end
expose :results
def call(params)
@results = GameRepository.compare_team(params[:team_id], params[:id])
end
end
end
|
class CreateMagazines < ActiveRecord::Migration
def change
create_table :magazines do |t|
t.integer :client_id
t.string :comment
t.date :startmag
t.date :stopmag
t.decimal :price
t.timestamps
end
end
end
|
require 'spec_helper'
describe JanusGateway::Transport::WebSocket do
let(:url) { 'ws://example.com' }
let(:protocol) { 'janus-protocol' }
let(:ws_client) { Events::EventEmitter.new }
let(:transport) { JanusGateway::Transport::WebSocket.new(url) }
let(:data) { { 'janus' => 'success', 'transaction' => 'ABCDEFG... |
require 'capistrano-scrip/utils'
# monit is a free, open source process supervision tool for Unix and Linux.
Capistrano::Configuration.instance.load do
# Path to monit configuration template
_cset(:monit_config_template) { "monit/monit_#{app_server}.conf.erb" }
# The remote location of monit's config file
_cse... |
module Healthtap
# Supports adding, reading, and updating items from DynamoDB
class NoSql
@db = nil
@table_prefix = nil
def self.connection
if @db.nil?
consul_settings = App.settings.consul
access_key_id = consul_settings[:aws][:access_key_id]
secret_access_key = consul_se... |
require 'socket'
class MicropostMailer < ActionMailer::Base
def participated(participant, micropost)
@participant = participant
@micropost = micropost
return mail(to: micropost.user.email, from: participant.name + " via Happpening <notification@happpening.com>", subject: participant.name + " ... |
Gem::Specification.new do |s|
s.name = 'dialogue'
s.version = '0.0.0'
s.date = '2013-07-17'
s.summary = "dialogue"
s.description = "A model for generating sequences with n-gram models"
s.authors = ["Farhan Mannan"]
s.email = 'farhanmannan@mac.com'
s.homepage = 'http://... |
class Light < ActiveRecord::Base
ALLOWED = %w[red yellow green]
extend FriendlyId
friendly_id :name, use: :finders
# Associations
has_many :operators
has_many :users, through: :operators
has_many :watchers
has_many :requests
accepts_nested_attributes_for :operators, reject_if: :all_blank, allow_de... |
require "spec_helper"
describe "Artist" do
let (:artist) { Artist.new }
let (:song) { Song.new }
let (:genre) { Genre.new }
it "can initialize an artist" do
expect(artist).to be_an_instance_of(Artist)
end
it "has a name" do
artist.name = "Tupac"
expect(artist.name).to eq("Tupac")
end
de... |
#!/usr/bin/env ruby
# https://adventofcode.com/2022/day/6
# --- Day 6: Tuning Trouble ---
# The preparations are finally complete; you and the Elves leave camp on foot and begin to make your way toward the star fruit grove.
# As you move through the dense undergrowth, one of the Elves gives you a handheld device. He... |
module Locomotive
class EditableLongText < EditableShortText
## methods ##
def as_json(options = {})
Locomotive::EditableLongTextPresenter.new(self).as_json
end
end
end |
#!/usr/bin/env ruby
$:.push File.dirname(__FILE__)
require 'helpers/core'
require 'helpers/db'
USAGE = "look up something remembered with !remember"
usage USAGE
unless input
puts "Usage: #{USAGE}"
exit 1
end
query = input.strip
value = DB[:memory][query.downcase]
if value
puts "#{query.capitalize} is: #{valu... |
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... |
module Ricer::Plug::Params
class StaticParam < Base
def expected_static_text(message)
message.plugin.t("static_param_#{options[:text]}".to_sym) rescue options[:text]
end
def convert_in!(input, message)
failed_input unless input == options[:text] || input == expected_static_text(messa... |
class AddLastActivityAtToUsers < ActiveRecord::Migration
def change
add_column :users, :last_activity_at, :datetime, null: false, default: Time.now
end
end
|
# frozen_string_literal: true
module LoginSteps
step 'I am logged in' do
create_user
log_in
end
step 'I have a user account' do
create_user
end
step 'I should be prompted for a login' do
expect(page).to have_content('Log in')
end
step 'I log in' do
log_in
end
step 'I should be... |
require_relative 'game'
require_relative 'guess'
class GuessPrinter
def initialize(guess_history)
@guess_history = guess_history
@last_guess = guess_history.last
if @last_guess.results[:full_match]
print_guess_history
else
system('clear')
print_guess_history
# puts "Last gues... |
require_relative 'literals'
require_relative '../scanner/scanner'
require 'pry'
module Scheme
class Parser
def initialize(input)
@scanner = Scheme::Scanner.new(input)
end
def pretty_print
root = parse_next_exp
while root
root.pprint(0)
root = parse_next_exp
end
... |
class AddEditedColumnToRoutes < ActiveRecord::Migration[6.0]
def change
add_column :routes, :edited, :boolean, default: false
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe FullSimulation, type: :model do
before(:each) do
@full_simulation = create(:full_simulation)
end
context 'validations' do
it 'is valid with valid attributes' do
expect(@full_simulation).to be_a(FullSimulation)
expect(@full_... |
class UpdateMailerPreview < ActionMailer::Preview
def update_email
UpdateMailer.with(owner: Owner.first).update_email
end
end |
require 'spec_helper'
describe 'PHP 7.2' do
include_context 'php' do
let(:php_version) { '7.2' }
let(:php_packages) { Constants::PHP72_PACKAGES }
let(:apache_version) { '2.4.18' }
let(:apache_php_mod) { 'php7_module' }
let(:ubuntu_version) { '16.04' }
end
before(:all) do
image_name = "#{... |
# frozen_string_literal: true
class DelaySerializer < ActiveModel::Serializer
attributes :delay_in_minutes
end
|
class CreateMeetings < ActiveRecord::Migration
def change
create_table :meetings do |t|
t.integer :message_id
t.integer :meeting_state, :default => 0
t.string :alt_email
t.integer :alt_phone
t.date :meeting_date
t.date :won_lost_date
t.string :pipeline_state
t.strin... |
#!/usr/bin/env ruby
require 'aliyun/oss'
require 'optparse'
require 'fileutils'
require 'progress_bar'
options = {
delimiter: '/',
max_depth: 1,
download_dir: '.'
}
OptionParser.new do |opts|
opts.banner = "Usage: oss-client command [options]"
opts.on("--endpoint [STRING]", "Aliyun oss endpoint") do |str|
... |
class UserSerializer < ActiveModel::Serializer
attributes :name, :id
has_many :comments, except: [:post, :user]
has_many :posts, only: [:title, :id]
end
|
class AddDateTimeStringColumns < ActiveRecord::Migration
def change
add_column :events, :start_str, :string
add_column :events, :end_str, :string
add_column :events, :sales_start_str, :string
add_column :events, :sales_end_str, :string
end
end
|
module Super
module Kafka
class Producer
include Super::Component
DEFAULT_SETTINGS = {
flush_interval: 1,
timeout_interval: 30,
max_buffer_size: 10
}.freeze
inst_accessor :pool
interface :configure, :boot, :produce, :flush, :shutdown
%w[topic flush_i... |
class ConferenceInvitee < ActiveRecord::Base
attr_accessible :pin, :speaker, :moderator, :phone_number, :phone_number_attributes
belongs_to :conference
belongs_to :phone_book_entry
has_one :phone_number, :as => :phone_numberable, :dependent => :destroy
accepts_nested_attributes_for :phone_number
before_... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
current_dir = File.dirname(File.expand_path(__FILE__))
config_dir = "#{current_dir}/config"
if File.file?("#{config_dir}/dev.yml")
config = YAML.load_file("#{config_dir}/dev.yml")
print "Loaded dev config: #{config}\n"
else
config = YAML.load_file("#{config... |
# encoding: utf-8
require 'net/http'
require 'uri'
require 'json'
require 'singleton'
require 'open3'
require_relative 'config'
require_relative 'mfile'
# Class to store language information
class MLanguages
attr_reader :raw
def initialize(json)
@raw = json['data']['detections']
end
# Return all poss... |
class Seller < ActiveRecord::Base
belongs_to :member
belongs_to :shipping_term
has_many :products
has_many :line_items, :through => :products, :order => "order_id DESC", :include => [:feedback]
validates_presence_of :name
validates_length_of :name, :within => 3..120
validates_uniqueness_of... |
explanatory_variable :normalized_addr_la do
type :numeric
input Transaction
dependencies :addr_la
description "addr_la shifted and scaled by mean and standard deviation"
calculate do |trans|
((addr_la.nil? ? current_sample.mean(:addr_la) : addr_la) - current_sample.mean(:addr_la)) / current_sample.stdev(:... |
#--
# Copyright (c) 2006 Stephan Toggweiler
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publi... |
class MenusController < ApplicationController
skip_before_action :authenticate_user!
before_action :set_storage
def show
# FIXME: Use a better abstraction for menu
@items = @storage.items
end
private
def set_storage
@storage = Storage.new(point_of_sale_id: params[:id])
end
end
|
class AddPriceToOrderHistory < ActiveRecord::Migration
def change
add_column :order_histories, :price, :money
add_column :order_histories, :quantity, :float
add_column :order_histories, :quantity_unit, :string, limit: 5
end
end
|
module HTTP
class People
include HTTParty
base_uri 'https://m.mit.edu/apis/people'
def person(kerberos)
JSON.parse(self.class.get("/#{kerberos}").body)
end
end
end
|
module TheCityAdmin
FactoryGirl.define do
factory :group_role, :class => TheCityAdmin::GroupRole do
created_at "04/30/2012"
title nil
user_api_url "https://api.onthecity.org/users/494335566"
id 265005445
user_type "Offline User"
user_id 494335566
last_engaged nil... |
class CreateTasks < ActiveRecord::Migration[5.1]
def change
create_table :tasks do |t|
t.references :service, foreign_key: true
t.integer :contact
t.references :motif, foreign_key: true
t.datetime :time_limit
t.datetime :processing_date
t.boolean :status, default: true
t.... |
class View < ActiveRecord::Base
attr_accessible :viewed_id, :viewer_id
belongs_to :viewer, class_name: 'User', foreign_key: 'viewer_id'
belongs_to :viewed, class_name: 'User', foreign_key: 'viewed_id'
end
|
class PaymentMailer < ActionMailer::Base
default from: "Blue Arch Store Support <service.bluearchstore@gmail.com>"
def payment_confirmation(payment)
@payment = payment
mail(to: @payment.email, subject: 'Please confirm payment and sign it')
end
def payment_pdf(payment)
@payment = payment
mail(t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.