text
stringlengths
10
2.61M
class ItemsController < ApplicationController before_action :authenticate_user!, only: [:create] def index @items=Item.all.order("created_at desc") end def new redirect_to new_user_session_path unless user_signed_in? @item = Item.new end def create redirect_to new_user_session_path unless u...
# encoding: UTF-8 $: << '../lib' require 'minitest/autorun' require 'ruby-hl7' class PidSegment < MiniTest::Test def setup @base = "PID|||333||LastName^FirstName^MiddleInitial^SR^NickName||19760228|F||||||||||555. 55|012345678" end def test_create_pid pid = Ruby::HL7::PID.new @base refute_nil pid ...
class ChangeIsBrokenInWeapons < ActiveRecord::Migration def up remove_column :weapons, :is_broken add_column :weapons, :condition, :string, default: 'New' end def down remove_column :weapons, :condition add_column :weapons, :is_broken, :boolean end end
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
shared :set_constructor do |klass| describe "#{klass}.[]" do it "returns a new #{klass} populated with the passed Objects" do set = klass[1, 2, 3] set.instance_of?(klass).should be_true set.size.should eql(3) set.should include(1) set.should include(2) set.should include(3) ...
# web elements and functions for page class DynamicPropertiesPage include Capybara::DSL include RSpec::Matchers include Capybara::RSpecMatchers def initialize @enable_after_btn = Element.new(:css, '#enableAfter') @color_change_btn = Element.new(:css, '#colorChange') @visible_after_btn = Element.new...
require 'benchmark' [10000, 100000, 1000000, 10000000].each do |size| Benchmark.bm do |b| b.report("chainable #{size}") do hashes = (1..size).select(&:even?).map(&:hash).map(&:to_s) end end Benchmark.bm do |b| b.report("one iteration #{size}") do hashes = (1..siz...
# frozen_string_literal: true require 'rails_helper' require 'sidekiq/testing' Sidekiq::Testing.fake! RSpec.describe EVSS::DisabilityCompensationForm::SubmitUploads, type: :job do before(:each) do Sidekiq::Worker.clear_all end let(:user) { FactoryBot.create(:user, :loa3) } let(:auth_headers) do EVSS:...
class CreateConfigUserPermissions < ActiveRecord::Migration[4.2] def change create_table :config_user_permissions do |t| t.string :form_name, null: false t.boolean :is_accepting, default: false t.boolean :is_only_show, default: false t.timestamps null: false end end end
class Household < ApplicationRecord has_many :people, dependent: :destroy has_many :vehicles, through: :people validates :address, :zip, :city, :state, :number_of_bedrooms, presence: true end
require 'minitest/autorun' require 'minitest/pride' require './lib/card' class CardTest < Minitest::Test def test_it_exists card = Card.new("Ace", "Spades") assert_instance_of Card, card end def test_it_has_a_value card = Card.new("Ace", "Spades") assert_equal "Ace", card.value end def tes...
require 'test_helper' class SubmissionImageTest < ActiveSupport::TestCase setup do @file_path = File.join(Rails.root, 'test', 'fixtures', 'files', 'FLCL.jpg') end test "created a submission with an image should have its type set to SubmissionImage" do image = Rack::Test::UploadedFile.new(@file...
# frozen_string_literal: true class BaseQuery include ActiveModel::Validations attr_reader :result def call_with_transaction ::ActiveRecord::Base.transaction(requires_new: true) do return true if call raise ::ActiveRecord::Rollback, "Aborting transaction: #{error_message}" end false ...
class RenameContentToGuid < ActiveRecord::Migration[6.0] def change rename_column :user_holders, :content, :objectguid end end
# Conversion calasses for converting data deserialized from puppet reports # using safe_yaml into structures expected by the model code. # Note that this must be updated whenever any of those changes. # module ReportSanitizer #:nodoc: class << self def sanitize(raw) case when raw.include?('report_fo...
# encoding: UTF-8 namespace :db do desc "Erase and fill database" task :populate => :environment do require 'populator' require 'ffaker' require "progress_bar" def spec_names %w(стилист визажист парикмахер косметолог массажист) end def spec_descs ["Кропотливая специальность","О...
class FontTengwarTelcontar < Formula version "008" sha256 "f88780510e5c14f66e252fabce5d58febc7bec962d5c17f21ac82002ce85b925" url "https://downloads.sourceforge.net/freetengwar/TengwarTelcontar.#{version}.zip" desc "Tengwar Telcontar" desc "Tengwar Telcontar - a Unicode Tengwar font" homepage "http://freeten...
module SpriteEdit class AnimatedPreview < Chingu::GameObject trait :bounding_box, debug: DEBUG include Gui::Clickable def initialize options = {} options = { delay: 200, bounce: false, zorder: ZOrder::PREVIEW, rotation_center: :top_left }.merge options super options @f_name = options[:f_nam...
require 'aws' module Process::Naf class LogArchiver < ::Process::Naf::Application NAF_JOBS_LOG_PATH = "#{::Naf::PREFIX_PATH}/#{::Naf.schema_name}/jobs/" NAF_RUNNERS_LOG_PATH = "#{::Naf::PREFIX_PATH}/#{::Naf.schema_name}/runners/" DATE_REGEX = /\d{8}_\d{6}/ LOG_RETENTION = 1 def work # Use...
# frozen_string_literal: true # rubocop:disable Metrics/ClassLength class DutiesController < ApplicationController load_and_authorize_resource only: [:export] def index @header_iter = generate_header_iter set_start_end_dates # Eager load all rows in Place @places = Place.all.map { |p| p } prepa...
class NaturesController < ApplicationController skip_before_action :authenticate_user def index natures = Nature.all render json: {natures: natures} end end
require 'spec_helper' describe Repository do context "when created" do it "should be valid" do FactoryGirl.build(:repository).should be_valid end it "should be invalid without name" do FactoryGirl.build(:repository, name: nil).should_not be_valid end it "should return users" do ...
# Subject model class class Subject < ApplicationRecord has_many :questions scope :uniq_subjects, -> { distinct.pluck(:subject) } end
class AddColumnDrugstoreIdToDrugstoreComments < ActiveRecord::Migration def change add_column :drugstore_comments, :drugstore_id, :integer end end
require 'sinatra' module PhotoDir class Server < Sinatra::Base set :photo_dir, Proc.new { ENV['PHOTO_DIR'] || "./example_dir" } set :public_folder, Proc.new { settings.photo_dir } set :bind, "0.0.0.0" get '/' do photo_dir = settings.photo_dir img_files = Dir.entries(photo_dir) img_...
class CreateItemGroups < ActiveRecord::Migration def change create_table :item_groups do |t| t.string :item_group_name t.string :regist_user t.string :update_user t.timestamps null: false end end end
class Member < ApplicationRecord has_many :profile # validates :name, length: { maximum: 80 }, presence: true # validates :nameFurigana, length: { maximum: 80 }, presence: true # validates :phoneNum, length: { maximum: 11 }, presence: true # Include default devise modules. Others available are: # :locka...
require "rails_helper" RSpec.describe SchoolsController do describe "GET /schools" do context "when invalid params" do it "does not create a new school" do expect do post :create, params: { school: { name: "St. Paul" } } end.not_to change(School, :count) end it "sets ...
require 'spec_helper' describe "couples/index.html.erb" do before(:each) do assign(:couples, [ stub_model(Couple), stub_model(Couple) ]) end it "renders a list of couples" do render end end
require 'rails_helper' RSpec.describe "payments/index", type: :view do before(:each) do assign(:payments, [ Payment.create!( :bookedseat => "", :amount => "9.99", :mode_of_payment => "Mode Of Payment", :status_of_payment => false, :is_deleted => false ), ...
require 'user' describe User do it "gives user a name" do user = User.new('Imogen', 'imogenmisso123', 'imogenmisso@hotmail.co.uk', 'blueskies1') expect(user.name).to eq 'Imogen' end it "gives user a username" do user = User.new('Imogen', 'imogenmisso123', 'imogenmisso@hotmail.co.uk', 'blueskies1') ...
require 'test_helper' class MemberTest < ActiveSupport::TestCase test "student id should work" do x = Member.new x.studentid = "32165480" x.email = "a@b.com" x.name = "haha" assert x.valid? end test "invalid student id" do x = Member.new x.studentid = "3216548" x.email = "a@b.com" x.name = "haha...
class Appointment < ActiveRecord::Base attr_accessible :staff_id,:organization_id,:appointment_date,:is_locked,:status,:created_by,:appointment_recurring_id,:appointment_unique_id,:service_id,:cost,:appointment_time,:time,:duration,:first_name,:last_name,:gender,:email,:state,:city,:address,:postal_code,:country,:pho...
class CreateCathedras < ActiveRecord::Migration def change create_table :cathedras do |t| t.string :name t.text :description t.string :ground_date t.string :phone_number t.string :address t.string :head t.timestamps null: false end end end
require 'spec_helper' describe ConsultManagement::Susanoo::Exports::JsonCreator do describe "#initialize" do let!(:consults) { [ create(:consult) ] } before do @json_creator = ConsultManagement::Susanoo::Exports::JsonCreator.new end it "consultを全件セットしていること" do expect(@json_creator.insta...
# frozen_string_literal: true require 'rails_helper' describe Book, type: :model do let(:book) { create(:book) } it 'to be mongoid document' do expect(Book).to be_mongoid_document end it 'have timestamps' do expect(Book).to have_timestamps end it 'will be correctly save in DB' do expect(bo...
class ApplicationController < ActionController::API include ActionController::Cookies before_action :set_current_user private def set_current_user return @current_user if @current_user session_id = cookies[:session_id] r = SessionStorage.get(session_id) user_id = r.data if user_id.nil? ...
require 'fedex_trakpak/helpers' module FedexTrakpak class Credentials include Helpers attr_reader :api_key, :mode def initialize(options={}) requires!(options, :api_key) @api_key = options[:api_key] @mode = options[:mode] end end end
# frozen_string_literal: true module ApplicationHelper def on_home_page? controller_name == "catalog" && params[:action] == "index" && !has_search_parameters? end end
require 'test_helper' class StaticPagesControllerTest < ActionDispatch::IntegrationTest def setup @base_title = "Mysize(マイサイズ) -スニーカーSNS-" end test "should get home" do get root_path assert_response :success assert_select "title", "#{@base_title}" end test "should get help" do get help...
require "#{File.dirname(__FILE__)}/default_adapter" require "#{File.dirname(__FILE__)}/devise_adapter" module Lolita class NoAuthenticationDefinedError < ArgumentError; end module Extensions module Authentication class Proxy attr_accessor :adapter def initialize context,options={...
ActiveAdmin.register User do menu :priority => 3 permit_params :email,:password,:password_confirmation,:first_name,:last_name,:address_line_1,:address_line_2,:mobile_number,:city,:state,:country,:zip_code index do selectable_column column :email column :first_name column :last_name column :m...
class DifferentiateController < ApplicationController def differentiate polynomio = params[:polynomio].split('/').reject(&:empty?).map(&:to_i) cal = BI::Calculator.new derivated = cal.derive_polynomio(polynomio) render json: { answer: cal.polynomio_to_s(derivated) }, status: :ok end end
class AgencyIdentity < ApplicationRecord belongs_to :user belongs_to :agency validates :uuid, presence: true def agency_enabled? !FeatureManagement.agencies_with_agency_based_uuids.index(agency_id).nil? end end
class AddGenderToTidepoolIdentities < ActiveRecord::Migration def change add_column :tidepool_identities, :gender, :string end end
# frozen_string_literal: true module GraphQL module Introspection class SchemaType < Introspection::BaseObject graphql_name "__Schema" description "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all "\ "available types and directives on the server, as well...
FactoryBot.define do factory :order_items do post {"111-1111"} prefecture_id {"2"} city {"札幌市"} address {"菰野町"} phone_number {"09038772175"} token {"tok132hbjkmgbgkkgfi"} end end
class CreateCottages < ActiveRecord::Migration def self.up create_table :cottages do |t| t.integer :bedrooms t.integer :beds_king t.integer :beds_queen t.integer :beds_double t.integer :beds_single t.integer :beds_pullout t.float :bathrooms t.boolean :kitchen ...
# 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). gym = Gym.create!(name: "Boomslang Fitness", phone_number: "336-707-7939", subdomain: "boomslangfitness"...
Rails.application.routes.draw do root to: "static_pages#home", as: "home" get 'test', to: 'static_pages#test', as: 'test' end
# frozen_string_literal: true module Dry module Monads module Do # Do::All automatically wraps methods defined in a class with an unwrapping block. # Similar to what `Do.for(...)` does except wraps every method so you don't have # to list them explicitly. # # @example annotated exam...
require 'rails_helper' #画像が空だと登録されない describe Image do it "is invalid without an image" do image = Image.new(image: nil) image.valid? expect(image.errors[:image]).to include("can't be blank") end end
class DashboardPage include PageObject link(:main_tab_link, :xpath => "//a[contains(@title,'Plan')]") #https://github.com/cheezy/page-object/wiki/Elements #:link_text locates the element without me having to explicitly having to write the xpath(//a[text()='User Stories']) link(:sub_tab_link, :link_text => "User S...
class CreateClients < ActiveRecord::Migration def change create_table :clients do |t| t.attachment :logo t.attachment :stamp t.string :social_name t.string :fantasy_name t.string :cnpj t.string :site t.string :municipal_registration t.string :state_registration ...
class ApplicationController < ActionController::Base protect_from_forgery def current_user if session[:user_id] # ||= assigns only if not already assigned (only calling db if necessary) @current_user ||= User.find(session[:user_id]) end @current_user end def logged_in? # !! Ruby trick - double-negate ...
#!/usr/bin/env ruby # Copyright (c) 2009-2011 VMware, Inc. # ENV["BUNDLE_GEMFILE"] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' require 'vcap_services_base' $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'service_broker/async_gateway' class VCAP::Services::Service...
require 'test_helper' class RecitalPlacesControllerTest < ActionController::TestCase setup do @recital_place = recital_places(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:recital_places) end test "should get new" do get :new assert...
require 'rails_helper' RSpec.feature "posts to the news page are listed" do rand_str = lambda { rand.to_s.split(".").last.to_i.to_s(16) } post1 = FactoryGirl.build(:post, title: rand_str.call, author: rand_str.call, body: rand_str.call, blurb: rand_str.call, published: true) post1.save(validate: false) post2...
require 'spec_helper' describe Combine do let(:combine) { described_class.new } describe "#two_schemas" do context "for identical schemas" do [ ['a', 'b'], [1, 2], [{ a: 1 }, { a: 2 }], [[1], [2]], [[{ a: 'asdf' }], [{ a: 'jkl' }]], ].each do |a, b| ...
class BoardsController < ApplicationController def index @boards = Board.all end def create @board = Board.create(board_params) respond_to do |format| format.html { redirect_to root_path } format.js end end def show @board = Board.find(params[:id]) @lists = @board.lists ...
require_relative "test_helper" describe "Recipient Class" do describe "self.list" do it "raises an Error if invoked directly (without subclassing)" do expect { Slack::Recipient.list }.must_raise NotImplementedError end end describe "#send_message" do it "raises an Error if incorr...
class AddOverlapToWorkingArticle < ActiveRecord::Migration[5.2] def change add_column :working_articles, :overlap, :text end end
class Image < ActiveRecord::Base has_and_belongs_to_many :tags def full_path "/images/#{path}" end def tag_group tags.map(&:name).join(',') end def tag_group= tag_input current_tags = tags.map(&:name) new_tags = tag_input .split(',') .map(&:strip) ...
# frozen_string_literal: true require 'evss/response' module EVSS module PCIUAddress class StatesResponse < EVSS::Response attribute :states, Array[String] def initialize(status, response = nil) states = response&.body&.dig('cnp_states') || response&.body&.dig('states') super(status...
Rails.application.routes.draw do # get 'page/index' get '/about', to: "page#about" get '/work', to: "page#work" get '/blog', to: "page#blog" get '/contact', to: "page#contact" get "/", to: "page#index", as: "root" # For details on the DSL available within this file, see http://guides.rubyonrails.org/rout...
module BookKeeping VERSION = 3 end class Hamming def self.compute(strand1, strand2) raise ArgumentError, 'Strands do not match in length' unless strand1.length == strand2.length strand1.chars.zip(strand2.chars).count { |chr1, chr2| chr1 != chr2 } end end
require 'rails_helper' RSpec.describe Skill, :type => :model do describe "class methods" do subject(:subject) { described_class } describe "#years_range", freeze: '2010/05/05' do before do allow(described_class).to receive(:all).and_return([2001, 2006].map{ |year| described_class.new(since: ye...
class Member < ActiveRecord::Base validates :phone, :phony_plausible => true phony_normalize :phone, :default_country_code => 'US' has_many :questions def send_message(msg) @twilio_number = ENV['TWILIO_PHONE_NUMBER'] @client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN'] mess...
# frozen_string_literal: true Rails.application.routes.draw do # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html namespace :api do namespace :v1 do get '/me', to: 'users#show' post '/register', to: 'registrations#create' post '/login', to: '...
# +--------------------+--------------+------+-----+---------+----------------+ # | id | int(11) | NO | PRI | NULL | auto_increment | # | user_assignment_id | int(11) | NO | | NULL | | # | audio_file_name | varchar(255) | YES | | NULL | | ...
class Customer attr_reader :id, :first_name, :last_name, :created_at, :updated_at, :repo def initialize(row, repo=nil) @id = row[:id].to_i @first_name = row[:first_name] @last_name = row[:last_name] @created_at = row[:created_at] @updated_at = row[:updated_at] @repo = repo ...
class User < ApplicationRecord def self.find_or_create_from_auth(data) user = User.find_or_create_by(provider: data.provider, uid: data.uid) user.name = data.info.nickname user.provider = data.provider user.uid = data.uid user.image = data.info.image user.token = data.credentials.token us...
class Board def initialize (game:, size_x:, size_y:) @game = game @size_x = size_x @size_y = size_y @spaces = initialize_spaces end def [] (x, y) @spaces[[x, y]] end def []= (x, y, value) @spaces[[x, y]] = value end def has_space? (location) @spaces.has_key?(location) ...
require 'directors_database' # Write a method that, given an NDS creates a new Hash # The return value should be like: # # { directorOne => allTheMoneyTheyMade, ... } def directors_totals(nds) counter = 0 total = {} while counter < nds.length do director_hash = nds[counter] director_name = nds[co...
# frozen_string_literal: true require_relative './enum_value' module GQLi # Base class for GraphQL type wrappers class Base attr_reader :__name, :__depth, :__nodes def initialize(name = nil, depth = 0, &block) @__name = name @__depth = depth @__nodes = [] instance_eval(&block) unl...
class Wine < ApplicationRecord has_many :tastings has_many :users, through: :tastings has_many :parties, through: :tastings validates :brand, :wine_type, presence: true validates :name, presence: {message: "required. If name not unknown, input variety."} validates :variety, presence: {messa...
# frozen_string_literal: true Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "s...
class BookingsController < ApplicationController def create @room = Room.find(params[:room_id]) @band = Band.find_by(id: params["booking"]["band_name"]) @booking = Booking.new(booking_params.merge(room_id: @room.id, band_id: @band.id)) authorize @room authorize @band if @booking.save red...
require 'prime' # The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number 600851475143? # N = 13195 N = 600851475143 @primes = [] def check_division divide_x, by_n result = (divide_x / by_n) if is_whole?(result) @primes << by_n is_prime?(result) ? (@primes << res...
# -*- encoding : utf-8 -*- class WorkDissertationsController < ApplicationController # GET /work_dissertations before_filter :check_auth # GET /work_dissertations.json def index @work_dissertations = WorkDissertation.all respond_to do |format| format.html # index.html.erb format.j...
Rails.application.routes.draw do resources :posts resources :users do resources :posts, only: [:index] end # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root 'posts#show' get "/login" => 'sessions#new', as: :login post "/login" => 'sessions#create...
# encoding: utf-8 module Ktl class Cluster < Command desc 'stats', 'Show statistics about cluster' option :zookeeper, aliases: %w[-z], required: true, desc: 'ZooKeeper URI' def stats with_zk_client do |zk_client| task = ClusterStatsTask.new(zk_client, shell) task.execute end ...
require_relative 'sudoku_space' class SudokuPuzzle attr_reader :spaces COLUMNS = %w[ 1 2 3 4 5 6 7 8 9 ] ROWS = %w[ A B C D E F G H I] #PUZZLE FOR REFERENCE: # =begin 1 2 3 4 5 6 7 8 9 A 3 0 6 |0 1 5 |0 0 0 B 0 0 4 |0 0 0 |3 0 0 C 0 0 0 |0 6 8 |1 9 4 ------+------+------ D 0 8 0 |0 0 6 |0 0 0 E 0 0 ...
# -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" require 'yaml' teamcity_nodes = YAML.load_file('teamcity.yaml') # Multi-machine setup based on: http://blog.scottlowe.org/2014/10/22/multi-machine-vagrant-with-yaml/ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| teamcity_nodes.each d...
class Country < ApplicationRecord has_many :cities has_many :customers end
set :application, "ditag" set :repository, "http://ditag.googlecode.com/svn/trunk/ditag" # If you aren't deploying to /u/apps/#{application} on the target # servers (which is the default), you can specify the actual location # via the :deploy_to variable: set :deploy_to, "/home/moddwebc/railsapps/#{application}" set ...
# 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 rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
module WpImportDsl module Wxr # Item's postmeta data class Postmeta < Base POSSIBLE_KEYS = [ 'delicious', 'geo_latitude', 'geo_longitude', 'geo_accuracy', 'geo_address', 'geo_public', 'email_notification', '_wpas_done_yup', '_wpas_d...
require 'spec_helper' require 'addressable/uri' describe GoogleAnalyticsFeeds::DataFeed do it "builds a URI" do request = described_class.new. profile(123). metrics(:foo, :bar). dimensions(:baz). dates(Date.new(2010, 3, 14), Date.new(2010, 3, 14)). max_results(50). start_index...
=begin Glassomium - web-based TUIO-enabled window manager http://www.glassomium.org Copyright 2012 The Glassomium Authors 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 h...
class Post < ActiveRecord::Base belongs_to :stream has_many :links has_many :medias belongs_to :service acts_as_taggable include Ping SUPPORTED_MARKUP_FORMATS = [ ['textile', 'textile'], ['markdown', 'markdown'], ['html', ''] ] def after_save if self.type == 'article' && se...
require_relative('../../lib/uninstaller') Installer = Class.new unless Kernel.const_defined?('Installer') describe Uninstaller do let(:install_dir) { mock 'a directory where elastic search is installed' } before do Installer.stub(:elastic_install_dir => install_dir) Kernel.stub(:system) end context ...
require 'spec_helper' RSpec.describe Ultron::Event::Sender do let(:serial) { double(RubySerial::Posix::Termios) } let(:mqtt) { MQTT::Client.new(host: 'localhost', port: 1883) } let(:instance) { described_class.new(serial, mqtt) } describe '#execute' do subject { instance.execute } context 'when has m...
# matrix = [ # [1, 2, 3], # [4, 5, 6], # [7, 8, 9] # ] # matrix = [ # [1, 5, 8], # [4, 7, 2], # [3, 9, 6] # ] # matrix = [ # [1, 4, 7], # [2, 5, 8], # [3, 6, 9] # ] # create a new array of arrays # maually move each item to the right spot # use # def transpose(array) # new_arr = [] # new_a...
Given(/^I have projects$/) do |table| table.hashes.each do |row| create(:project, name: row['name'], start_date: Date.strptime(row['start_date'], '%m/%d/%Y'), end_date: Date.strptime(row['end_date'], '%m/%d/%Y') ) end end Given(/^I visit projects path$/) do visit admin_projects_path en...
require 'zipf' require_relative 'grammar' require_relative 'hypergraph' module Parse def Parse::visit i, l, r, x=0 i.upto(r-x) { |span| l.upto(r-span) { |k| yield k, k+span } } end class Chart def initialize n @n = n @m = [] (n+1).times { a = [] (n+1).times { a << [] } ...
# This migration comes from forem (originally 20120302152918) class AddForemViewFields < ActiveRecord::Migration def up add_column :forem_views, :current_viewed_at, :datetime add_column :forem_views, :past_viewed_at, :datetime add_column :forem_topics, :views_count, :integer, :default=>0 add_column :f...
# frozen_string_literal: true module Cernight RESERVED_ATTRIBUTES = %w[ address nickname birthdate phone_number email picture family_name preferred_username gender profile given_name zoneinfo locale updated_at middle_name website name ].freeze end...
=begin :align :angle :attach :autoplay :bottom :cap :center :change :checked :click :curve :displace_left :displace_top :emphasis :family :fill :font :group :height :hidden :inner :items :justify :kerning :leading :left :margin :margin_bottom :margin_left :margin_right :margin_top :outer :points :radius :right :rise :s...
module Liql module GraphQL class << self attr_accessor :network_layer attr_accessor :schema end def self.render_liquid(template) ast = Liql.parse(template) query = Compiler.new(ast).compile response = self.network_layer.query(query) data = response["data"] temp...