text
stringlengths
10
2.61M
class CreateEventProviders < ActiveRecord::Migration[5.0] def change create_table :event_providers do |t| t.belongs_to :meal_event, index: true t.belongs_to :provider, index: true t.belongs_to :contract, index: true t.integer :status, null: false, default: 0 t.integer :priority ...
# Activity model for customisation & custom methods class Activity < PublicActivity::Activity def action type, _action = key.split('.') I18n.t("activity.models.#{type}.actions.#{_action}") end end
# frozen_string_literal: true class InviteController < ApplicationController SUBSCRIBER_TEMPLATE = Subscriber.new(email: '{{subscriber_email}}', name: '{{subscriber_name}}').freeze CURRENT_USER_TEMPLATE = Subscriber.new(email: '{{current_user_email}}', name: '{{current_user_name}}').freeze MAIL_TEMPLATES = [ ...
#練習問題 #• OrangeTreeクラスを作ってみなさい。 このクラスには、木の高さを返すheightメソッドと、 メソッドを呼ぶことで、1年分時間を進めるoneYearPassesメソッドがあります。 毎年、この木は成長し大きくなります(オレンジの木が1年に伸びる分だけ)。 そして、ある年限が来たら(これもメソッド呼び出しによります) その木は死んでしまいます。最初の2,3年は実をつけませんが、その後は 実がなる様にします。で、成長した木は若い木よりたくさん実をつけます。 このあたりはあなたが納得するよう調節してみましょう。 そして、もちろんcountTheOranges(木になっているオレンジの数を返す)メソッドと、 pi...
require "singleton" module S3DirectUpload class Config include Singleton ATTRIBUTES = [:access_key_id, :secret_access_key, :bucket, :prefix_to_clean, :region, :url] attr_accessor *ATTRIBUTES end def self.config if block_given? yield Config.instance end Config.instance end end
#Find the length of the longest subsequence of a given sequence such that all elements of the subsequence are sorted in increasing order #Length of LIS { 10, 22, 9, 33, 21, 50, 41, 60, 80 } is 6 and LIS is {10, 22, 33, 50, 60, 80} #10,22,33,50,60,80 #10,11,21,22,50,60,80 #10,22,11 => {10,11}, {10,22} def longest_in...
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 def authenticate if !signed_in? redirect_to new_session_path end end def signed_in? current...
module Polepin class Utility def self.model_classes ActiveRecord::Base.descendants.select { |klass| klass.table_exists? }.uniq.sort_by(&:name) end def self.timestamp_columns(model_class) %w(created_at updated_at) & model_class.column_names end def self.boolean_columns(model_clas...
def initialize_repos_on_host(host) if host['platform'].include? 'el-6' on host, "rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm" on host, "sed -i.bak -e '/\\[puppetlabs-devel\\]/,/^$/ s|enabled=0|enabled=1|' /etc/yum.repos.d/puppetlabs.repo" on host, "curl #{ENV...
class Type < ApplicationRecord validates_presence_of :nome before_save :maiusculo def maiusculo self.nome.upcase! end end
class AddCfsToRivers < ActiveRecord::Migration def change add_column :rivers, :cfs, :integer end end
module HasModerated module ModerationModel def self.included(base) base.class_eval do alias_method_chain :destroy, :moderation_callbacks cattr_accessor :moderation_disabled self.moderation_disabled = false def self.without_moderation(do_disable = true) already_disa...
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'gawky/version' Gem::Specification.new do |spec| spec.name = "gawky" spec.version = Gawky::VERSION spec.authors = ["Bruno Oliveira"] spec.email = ["bruno@abstr...
class ChangestartTimeTostarttime < ActiveRecord::Migration def change rename_column :tests, :startTime, :starttime rename_column :tests, :endTime, :endtime rename_column :tests, :conductedBy, :conductedby rename_column :tests, :tType, :ttype end end
class AddHotelEndToUsers < ActiveRecord::Migration[6.1] def change add_column :users, :hotel_end, :string end end
# frozen_string_literal: true require 'json' require 'date' class AppGas attr_accessor :delivery_date, :shipments, :supplier, :items attr_reader :products def initialize @delivery_date = delivery_date @shipments = [] @supplier = supplier @items = items @products = [] end # private meth...
class StockItemSerializer < ActiveModel::Serializer attributes :id, :name, :price, :available_date, :description, :taxable belongs_to :store end
class AddConsumptionToCustomer < ActiveRecord::Migration def self.up add_column :customers, :consumption, :integer, :default => 0 Customer.update_all ["consumption = 0"] end def self.down remove_column :customers, :consumption end end
class Store < ActiveRecord::Base belongs_to :owner, :class_name => "User" has_many :inventory_items has_many :items, through: :inventory_items validates :name, presence: true, uniqueness: true, length: { maximum: 63 } geocoded_by :address after_validation :geocode, :if => :address_changed? has_attached_...
require 'stringio' module Java module ClassFile class BigEndianFile < File def read_u4 self.read(4).unpack("N").first end def read_u2 self.read(2).unpack("n").first end def read_u1 self.read(1).unpack("C").first end end class ClassDefinition attr_reader :constant_pool, :fie...
class Vacation < ApplicationRecord has_many :groups, foreign_key: 'vacation_name' has_many :invoices, foreign_key: 'vacation_name' belongs_to :organizer, foreign_key: 'organizer_nip' validates :name, presence: true, uniqueness: true validates :start_date, presence: true validates :end_date, pres...
# frozen_string_literal: true module Kafkat module Logging def print_err(message) STDERR.print message end end end
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.require_plugin "vagrant-omnibus" Vagrant.require_plugin "vagrant-cachier" Vagrant.require_plugin "vagrant-berkshelf" Vagrant.require_plugin "vagrant-serverspec" Vagrant.configure("2") do |config| # All Vagrant configuration is done here. The most common configuration...
require_relative 'core' require_relative 'error' require_relative 'modules/main' require_relative 'modules/net' module Xion VERSION = 0.1 Opts = Options.instance App = Application.instance App.register_module('main') App.register_module('net') puts "Xion: Version #{VERSION}" loop do App.show_prom...
Ppweb::Application.routes.draw do get "/about" => "home#about" get "/contact" => "home#contact" get "/jobs" => "home#jobs" get "/notifications" => "notifications#index", as: "notifications" get "/signup" => "users#signup", as: "signup" get "/login" => "users#login", as: "login" post "/create_login_ses...
class UserSerializer < ActiveModel::Serializer attributes :id, :first_name, :email, :updated_at def count User.pluck(:id).count end end
class HomeController < ApplicationController def display page = params[:page] render "home/#{page}" end end
class Page < ApplicationRecord validates :name, :description, presence: true end
class AddBasecampRefreshToBasecampAccount < ActiveRecord::Migration def change add_column :basecamp_accounts, :basecamp_refresh, :datetime end end
require 'active_record/connection_adapters/abstract/schema_definitions' module ActiveRecord module ConnectionAdapters class ColumnDefinition attr_accessor :unsigned end class TableDefinition def primary_key(name, type = :primary_key, options = {}) column(name, type, options.merge(pri...
require 'spec_helper' describe Recurrence do before :each do @recurrence = Recurrence::Root.new end describe Recurrence::Root do before :each do module Recurrence class First < Recurrence::Base child self class Second < Recurrence::Base child self ...
class Sinatra::ContentFor2::ErbHandler < Sinatra::ContentFor2::BaseHandler attr_reader :output_buffer def initialize(template) super @output_buffer = get_buf end def is_type? ! self.output_buffer.nil? end def block_is_type?(block) is_type? || (block && eval('defined?(__in_erb_template)', ...
# frozen_string_literal: true class Types::StepType < Types::BaseObject include Rails.application.routes.url_helpers field :id, ID, null: false field :name, String, null: false field :content, String, null: true field :location_connection_steps, Types::Location::Connection::StepType.connection_type, null: f...
class OperationsController < ApplicationController before_action :signed_in_user, only: [:index, :create, :destroy, :edit] before_action :correct_user, only: [:index, :create, :show] before_action :correct_user_for_operation, only: [:destroy, :edit, :update] def index @category = User.find(params[:user_id...
class Player::ConvocationsController < ApplicationController before_action :set_convocation, only: [:accept, :refuse] def index @user = current_user @pending_convocations = @user.convocations.pending_ones @current_convocations = @user.convocations.current_ones respond_to do |format| format...
module PostValidations extend ActiveSupport::Concern include ActiveEvent::Validations validation_target :'CreatePostCommand' validation_target :'UpdatePostCommand' included do validates :title, presence: true, length: 3..100 validates :text, presence: true validates :user_id, presence: true ...
class SearchesController < ApplicationController def index @searches = Search.all end def new @search = Search.new end def create @search = Search.new(search_params) if @search.save redirect_to searches_path else render 'new' end end def edit @search = Search.find(params[:id]) end def...
class CreateChemicalsHousesJoin < ActiveRecord::Migration def change create_table :chemicals_houses, :id => false do |t| t.integer :house_id t.integer :chemical_id end add_index :chemicals_houses, :house_id add_index :chemicals_houses, :chemical_id end end
class Video < ActiveRecord::Base belongs_to :trail validates :src, presence: true end
class GameTrueFalse < ActiveRecord::Base include Accessable include Historiable include Statusable include GameScorable include GameQuestionableClonable amoeba do nullify [:user_id, :status, :status_changed_at] exclude_association [:origin, :edition_histories, :answers, :user_scores, :questions] ...
class SearchingKeywordLog include Mongoid::Document include Mongoid::Timestamps store_in database: 'sribulancer_development', collection: 'searching_keyword_logs' field :keyword end
module Sequel module Vertica module DatabaseMethods extend Sequel::Database::ResetIdentifierMangling TEMPORARY = 'TEMP '.freeze # Vertica uses the :vertica database type def database_type :vertica end private def connection_configuration_sqls sqls = []...
class Card < ApplicationRecord validates_presence_of :name validates_presence_of :artist validates_presence_of :text validates_presence_of :mana_cost validates_presence_of :power validates_presence_of :toughness validates :cmc, presence: true, numericality: { only_integer: true } belongs_to :color be...
class Malariafactview < ActiveRecord::Base belongs_to :malariafact belongs_to :user end
class EvidencesController < ApplicationController before_action :login_to_add_evidence require 'httparty' def create @fact = Fact.find(params[:fact_id]) @evidence = @fact.evidences.build(evidence_params) @evidence.user = current_user @evidence.grab_metadata # If user already has 5 eviden...
class PostsController < ApplicationController def index render json: Post.all end def show end def new end def edit end def delete Post.find(params[:id]).destroy render json: { message: 'Post deleted' } end private def post_params params.require(:post).permit(:first_name, ...
class AdjustBankAccountDefaults < ActiveRecord::Migration[5.0] def change change_column_default(:bank_accounts, :balance_currency, nil) change_column_default(:bank_accounts, :line_of_credit_currency, nil) change_column_default(:bank_transactions, :funds_currency, nil) reversib...
require 'rails_helper' RSpec.describe Book do describe "validation" do let(:book) { Book.new(image_url: "/path/smething") } it "is not valid" do expect(book.invalid?).to be true end it "image_url has no error" do book.invalid? expect(book.errors[:image_url].any?).to be false ...
class Comment include Mongoid::Document include Mongoid::Timestamps #Field field :content, type: String, default: "" #Relation belongs_to :student belongs_to :post #Validation validates :content, :presence => true validates :student, :presence => true end
# == Schema Information # # Table name: bookmarks # # id :integer not null, primary key # title :string(150) not null # domain :string(75) not null # path :string(255) default("/"), not null # query_string :string(255) # port :integer defaul...
# frozen_string_literal: true require 'jiji/test/test_configuration' describe Jiji::Messaging::MailComposer do include_context 'use data_builder' include_context 'use container' let(:composer) { container.lookup(:mail_composer) } let(:repository) { container.lookup(:setting_repository) } let(:setting) { re...
require 'nokogiri' require 'open-uri' # :first_in sets how long it takes before the job is first run. In this case, it is run immediately SCHEDULER.every '1m', :first_in => 0 do |job| html = Nokogiri::HTML open("http://www.randomfunfacts.com") fact = html.css("strong").text send_event('fact', { text: fact }) end
# frozen_string_literal: true ## --- BEGIN LICENSE BLOCK --- # Copyright (c) 2016-present WeWantToKnow AS # # 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 wit...
# # Recipe to copy log data from nodes into HDFS # Flume is used to copy data and runs as an agent on the nodes # #**** Attention ***** Attention **** # This should be the last recipe in the runlist for any role since # individual recipes can make requests to copy log files to HDFS # This can be achieved by adding th...
require "spec_helper" module Stirlitz describe Spy do it "extends rspec mock" do a_spy = spy("something", :method_1 => 1, :method_two => 'two') a_spy.method_1.should == 1 a_spy.method_two.should == 'two' end it "doesn't complain about undeclared methods" do a_spy = spy("something...
class UserChoicesController < ApplicationController def create @vote = Vote.find(params[:user_choice][:vote_id]) @choice = current_user.user_choices.build(user_choice_params) if @choice.save flash[:notice] = "Voted succesfully" redirect_to @vote.event else render 'new' end end...
# # Cookbook Name:: multi_mysql # Recipe:: default # # Copyright (C) 2014 Adam Mielke, (C) Regents of the University of Minnesota # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http:/...
#in coderpad.io/sandbox, copy file binary_search_tree.rb #to the bottom of this file and comment out this #require line below. require './binary_search_tree' #comment out this line below for standlone RSpec (i.e when NOT in coderpad) require 'rspec/autorun' ##The above statements are useful when running in ##coderpad.i...
#!/usr/bin/env ruby -w require "rubygems" require "nokogiri" require "open-uri" module Hulu class Show attr_accessor :name, :show_title, :season, :episode, :running_time @@shows = [] @@subscribed_shows = [ 'Psych', 'Burn Notice', 'Warehouse 13', 'Community', 'Bones', ...
class NegativesNotAllowed < StandardError; end class StringCalculator def add(input) numbers = numbers_in(input) negatives = numbers.select{|n| n<0} raise NegativesNotAllowed.new(negatives.join(", ")) unless negatives.empty? numbers.reduce(:+).to_i end private def regex %r{(//(?<delimit...
# encoding: utf-8 # copyright: 2016, you # license: All rights reserved # date: 2015-08-28 # description: All directives specified in this STIG must be specifically set (i.e. the server is not allowed to revert to programmed defaults for these directives). Included files should be reviewed if they are used. Procedure...
require 'snmp2mkr/config_types/base' require 'snmp2mkr/config_types/templates_list' require 'snmp2mkr/config_types/host_snmp_definition' module Snmp2mkr module ConfigTypes class HostDefinition < Base def setup(kv) raise TypeError, "#{self.class} must be given an Array (BUG?)" unless kv.kind_of?(Arr...
class SlackService < NotificationService CHANNEL = "#general".freeze def self.send_message(message:) if false #if Rails.env.production? slack = Slack::Notifier.new(ENV["SLACK_URL"]) attachhment = {text: message} slack_response = slack.ping(channel: channel, attachments: [attachment]) ...
require 'bundler/capistrano' set :application, "LearnHVAC Web" set :keep_releases, 5 set :deploy_via, :remote_cache set :git_shallow_clone, 1 set :repository, "git@github.com:martianinteractive/LearnHVAC_web.git" set :branch, 'master' set :scm, 'git' set :user, 'deploy' set :deploy_to, "/var/www/app.learnhvac.org" se...
class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :authorize include SessionsHelper def authorize redirect_to sign_in_path unless user_signed_in? end end
require 'rails_helper' RSpec.describe FeedsController do let(:profile) { create(:profile) } describe 'GET #edit' do let!(:feed) { create(:feed) } specify do get :edit, id: feed.id expect(response).to render_template :edit end end describe 'GET #show' do let!(:feed) { c...
# frozen_string_literal: true class InvalidLetterAddressEdipi < ActiveRecord::Base validates :edipi, presence: true, uniqueness: true end
=begin Construit et renvoie le synopsis du film :film_id Identifiant du film :scene_ids Liste des identifiants des scènes à prendre en compte C'est un string avec séparateur virgule @Return :synopsis String. Le synopsis =end film = Film.new param(:film_id) if film.exists?...
class PagesController < ApplicationController def show # /contact|about|help/ if params[:id].match /about|contact|help/ render params[:id] else render '/pages/not_found.html.erb', :status => 404 end end def home render '/pages/home.html.erb' end end
include Rails.application.routes.url_helpers class Activities::DashboardSerializer < ApplicationSerializer object_as :activity, model: "PublicActivity::Activity" attributes( :id, :trackable_type, :trackable_id, :owner_type, :owner_id, :key, :parameters, :recipient_type, :recipi...
class MixPartsController < ApplicationController before_action :set_mix_part, only: [:show, :edit, :update, :destroy] # GET /mix_parts # GET /mix_parts.json def index @mix_parts = MixPart.all end # GET /mix_parts/1 # GET /mix_parts/1.json def show end # GET /mix_parts/new def new @mix_p...
require 'openssl' module Certlib class EasyCA def initialize(root_ca) @root_ca = root_ca end def new_csr(subject: nil, cn: nil, key: nil) csr = OpenSSL::X509::Request.new csr.version = 0 csubject = nil if subject.class == OpenSSL::X509::Name csubject = subject elsif subject.class == Str...
class Book < ActiveRecord::Base belongs_to :page attr_accessible :author, :country, :publisher, :released_on, :subtitle, :title, :translator, :cover, :remote_cover_url, :alt_title, :isbn, :pages, :binding, :summary, :genre mount_uploader :cover, ImageUploader validates...
########################################################################### ## ## stream_consumer ## ## Multi-threaded HTTP stream consumer, with asynchronous spooling ## and multi-threaded production. ## ## David Tompkins -- 05/30/2013 ## tompkins@adobe_dot_com ## ######################################################...
require 'rails_helper' RSpec.describe "reporter_graphics/show", type: :view do before(:each) do @reporter_graphic = assign(:reporter_graphic, ReporterGraphic.create!( :user => nil, :title => "Title", :caption => "Caption", :source => "Source", :wire_pictures => "Wire Pictures", ...
class FileUpload < ActiveRecord::Base mount_uploader :file, FileUploader before_save :update_file_attributes validates_presence_of :file, unless: :file_cache private def update_file_attributes if file.present? && file_changed? self.content_type = file.file.content_type self.file_size = fi...
module CDI class BaseUpdateService < BaseCrudService def execute if can_execute_action? set_history_user track_attributes_changes @updated_record = update_record @updated_record ||= @record if success_updated? track_record_versions success_res...
require 'helper' describe Syn::Literal::Array do before do @literal = described_class.new end it do name = Syn::Literal::Name.new name.string = 'some_name' symbol = Syn::Literal::Symbol.new symbol.string = 'some_symbol' string = Syn::Literal::String.new string.string = 'some string...
require 'bigdecimal' class MoneyChange def initialize(values = [100, 50, 20, 10, 5, 1, 0.5, 0.2, 0.1, 0.05, 0.01]) @values = values.sort.reverse end def calculate_change(money) number = BigDecimal.new(money.to_s) answer = {} return answer if number < @values.last current_idx = 0 while nu...
# frozen_string_literal: true class MetaTagsComponent < ViewComponent::Base def initialize(meta_robots_index:, meta_robots_follow:, meta_title:, meta_description:, meta_type:, meta_image:) @meta_robots_index = meta_robots_index @meta_robots_follow = meta_robots_follow @meta_title = meta_title || "default...
class Result < ActiveRecord::Base belongs_to :report belongs_to :subject validates :classmark, presence: true validates :testmark, presence: true validates_presence_of :report validates_presence_of :subject end
# New spacer content # # I’m looking for a terrific environment to continue my journey growing as a developer. A place I can find a mentor or just a great pairing partner, a place that’s fun, witty, smart and a place that is as driven as I am to grow outside the bounds of where we are today.
module Ironwood class Game attr_accessor :status_bar, :map, :time, :player, :map_display attr_reader :game_over, :score def initialize(screen_width, screen_height) @status_bar = StatusBar.new(self) @time = GameTime.new @game_over = false @map = GenMap.new(time) @player = Player.new map, $X,...
# frozen_string_literal: true # # Cookbook Name:: sc # Attribute:: default # # Copyright 2018, Roblox Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
dep 'oh-my-zsh and janus' do met? { "~/.oh-my-zsh/custom/j2fly_shortcuts.zsh".p.exists? && "~/.vim/colors/j2fly.vim".p.exists? } meet { log "Initializing the submodule for .oh-my-zsh and .vim" shell 'cd ~/.dotfiles; git submodule init; git submodule update;' log_shell "Symlinking j2fly_shortcuts....
class FacilitiesManagement::DirectAwardSpreadsheet def initialize(contract_id) @contract = FacilitiesManagement::ProcurementSupplier.find(contract_id) @procurement = @contract.procurement @active_procurement_buildings = @procurement.active_procurement_buildings.order_by_building_name @supplier_name =...
# # Author:: Celso Fernandes (<fernandes@zertico.com>) # © Copyright IBM Corporation 2014. # # LICENSE: MIT (http://opensource.org/licenses/MIT) # module Fog module Softlayer class DNS class Mock def delete_record(id) # Get the domain @domain = @softlayer_domains.each do |domain...
require "spec_helper" describe EventsController do describe "GET /index" do describe "view" do render_views it "renders the view" do get :index end end describe "controller" do it "assigns @events using upcoming_and_current scope" do past = create :event, :pub...
require 'set' class Reader def read_input_to_number_set(file) f = File.open(file, "r") all = Set.new f.each_line do |line| all.add(line.to_i) end all end def read_input_to_number_array(file) f = File.open(file, "r") all = [] f.each_line do |line| all << line.to_i ...
module PdfTempura class Document::Table < Document::Field::Base attr_accessor :columns,:name,:row_height,:padding,:cell_padding,:row_count validates :row_height, type: Numeric validates :row_count, type: Numeric validates :padding, type: Array, inner_type: Numeric, count: 4 validates :cell_paddi...
class CreateTables < ActiveRecord::Migration def change create_table :players do |player| player.string :name end create_table :games do |game| game.string :outcome game.timestamps end create_table :games_players, :id => false do |t| t.references :game t.references :p...
# frozen_string_literal: true module AppealsApi class NoticeOfDisagreementPdfOptions def initialize(notice_of_disagreement) @notice_of_disagreement = notice_of_disagreement end def veteran_name name 'Veteran' end def veteran_last_name last_name 'Veteran' end def veter...
class ApiController < ApplicationController include ActionView::Helpers::TextHelper def location render :json => ongs_and_events_nearby(params[:km], params[:lat], params[:lng], params[:page]).to_json(:only => only, :methods => methods) end def recently_added @recently_added = (Ong.last(5) + Event.last(5)...
FactoryBot.define do factory :facilities_management_procurement, class: FacilitiesManagement::Procurement do name { Faker::Name.unique.name } contract_name { 'Contract name' } estimated_cost_known { 12345 } tupe { false } initial_call_off_period { 1 } service_codes { ['C.1', 'C.2'] } assoc...
require 'rails_helper' RSpec.describe "As a user" do describe "when i visit the styles index page" do it "i can see all styles and descriptions" do @style_1 = create(:style) @style_2 = create(:style, name: "Traditional") @style_3 = create(:style, name: "Tribal") visit ...
class Post < ActiveRecord::Base include Calliope::Models::Post has_many :comments, :as => :commentable, :order => 'created_at ASC' end
require 'spec_helper' require 'erb' include ERB::Util describe Api::V1::XferslipController do describe "PATCH route" do let(:xferslip) { FactoryGirl.create(:xferslip) } before :all do # create access token @token = ApiKey.create!.access_token end def test_patch(route, params, autht...
#encoding: UTF-8 # Converts a string with tones from numbers (e.g., "pin1yin1") to diacritics # (e.g., "pīnyīn"), and vice versa # # Examples # # Pinyin.to_accents('huan1ying2 guan1lin2!') # # => "huānyíng guānlín!" # # Pinyin.to_numbers('huānyíng guānlín!') # # => "huan1ying2 guan1lin2!" class Pinyin # sour...
class PhotoitemsController < ApplicationController before_filter :authenticate_user def index @photoitems = Photoitem.all respond_to do |format| format.html # index.html.erb format.json { render json: @photoitems } end end def show @photoitem = Photoitem.find(params[:id]) res...
# Elijah Gonzales-Intharakhumhang # CSCE 431-500 # 725000232 # When done, submit this entire file to the autograder. # Part 1 def sum arr arr.inject(0, :+) end def max_2_sum arr arr.sort.last(2).sum end def sum_to_n? arr, n if arr == [] return false else (arr.empty? && n.zero?) || arr.permutation(...