text
stringlengths
10
2.61M
# frozen_string_literal: true class VinValidation TRANSLITERATE_CHARS = '0123456789.ABCDEFGH..JKLMN.P.R..STUVWXYZ' def initialize(vin) @vin = vin end def call valid_vin? end private attr_reader :vin def valid_vin? return VinMessages.vin_size_error_msg(vin) unless vin.size == 17 if...
require "spec_helper" describe MissedItBucket do describe 'slug generation' do subject { create :missed_it_bucket, title: "What What", slug: nil } its(:slug) { should eq "what-what" } end end
module ThumbImages extend ActiveSupport::Concern included do include DynamicAssociationCallback cattr_accessor :thumb_association_options, :thumbimages_asset_host @@thumb_association_options = {} end module ClassMethods def thumb_association(association_name, field = :image, options = {}) ...
require 'rbconfig' LIB_ZK_SO = 'lib/libzookeeper_mt_gem.la' TARBALL = FileList['zkc-*.tar.gz'].first raise "Where is the zkc tarball!?" unless TARBALL namespace :zkrb do task :clean do if File.exists?('Makefile') sh 'make clean' rm 'Makefile' # yep, regenerate this else $stderr.puts "not...
class Place < ApplicationRecord has_many :shares has_many :users, through: :shares end
module Hammerofgod module CLI class Hn < Thor desc "search URL", "Search hn.algolia.com for a url mentioned on Hackernews" option :tags def search( url ) puts "Looks like you are looking for #{url} with tags #{options[:tags]}" end end end end
# -*- encoding: utf-8 -*- =begin -------------------------------------------------------------------------------------------------------------------- <copyright company="Aspose" file="aspose_html_cloud.gemspec"> </copyright> Copyright (c) 2022 Aspose.HTML for Cloud <summary> Permission is hereby g...
require 'spec_helper' describe "resources/edit" do before(:each) do @resource = assign(:resource, stub_model(Resource, :user_id => 1, :title => "MyString", :source => "MyString", :categ_a => "MyString", :categ_b => "MyString", :level => "MyString", :year => 1, :cos...
require 'csv' class Api::QuizzesController < ApiController def index data = drugs @quiz = Quiz.new(data, "Block 5").quiz render json: @quiz end private def drugs begin drug_query rescue Exception YAML::load_file(Rails.root.join("config", "drugs.yml")) end end def drug_q...
class ChangeStartLongitudeToBeFloatInConnections < ActiveRecord::Migration[5.2] def change change_column :connections, :start_longitude, :float end end
class Question < ApplicationRecord belongs_to :user has_many :likes validates :title, :content, presence: true, uniqueness: true end
class Book def title=(t) @title = t end def title do_not_capitalize = [ "and", "or", "for", "by", "with", "without", "at", "a", "an", "the", "there", "in", "on", "over", "under", "after", "of", "from" ] words ...
# 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...
# !/usr/bin/env ruby -w class Launcher def initialize app_map @app_map = app_map end def run file_name application = select_app file_name system "#{application} #{file_name}" end def select_app file_name ftype = file_type file_name @app_map[...
class Customer < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable # :validatable 消しました。uploadの際にパスワード変更ない為。 has_many :orders, de...
#encoding: utf-8 require_relative File::expand_path('./config', __dir__) require 'app_logger' require 'singleton' module VmstatCat # 静的メンバしか持たないため、単一オブジェクトとする。 class Analyzer include Singleton @@logger = AppLogger::get module Part @@logger = AppLogger::get Header = lambda{|read_data| ...
class Dogecoin < Cask url 'https://github.com/dogecoin/dogecoin/releases/download/v1.3/dogecoin-qt-v13-Mac.zip' homepage 'http://dogecoin.com/' version '1.3' sha1 'ab78275b219966220f9caafaa0f9235c64ae82e0' link 'dogecoin-qt.app' end
ActiveAdmin.register Skill do menu false scope("All") { |scope| scope.latest } scope("Popular (>5)") { |scope| scope.popular.latest } scope("Canon") { |scope| scope.canon.latest } scope("Non-Canon") { |scope| scope.non_canon.latest } index do selectable_column column :id col...
source 'https://github.com/CocoaPods/Specs.git' # 对于Swift应用来说下面两句是必须的 platform :ios, '8.0' use_frameworks! target 'SwiftRN’ do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! pod 'Alamofire','>=4.0' # Pods for New2Swift4 pod 'MJRefresh', ...
class Account < ApplicationRecord belongs_to :user has_many :transactions has_many :transfers after_create :reload end
require_relative "../support/service" class StoryServices::UnzipUploadService < Koal::Service attr_accessor :story_folder, :temp_folder def call(zipfile:, story_file_name: nil) @temp_folder = Dir.mktmpdir system("unzip #{zipfile} -d #{@temp_folder} >/dev/null") story_file_name = if story_file_name ...
require 'active_support/concern' # Defines a reconciler for the model. I.e: # # class MyModel < ActiveRecord::Base # include Reconcilable # end # # my_model = MyModel.new # my_model.reconciler # => <MyModelReconciler> # my_model.reconcile(context, options) # module Reconcilable extend ActiveSupport::C...
# brick_stack = [ # [4], # [1, 3, 5, 8], # [0, 2, 5, 7], # [1, 6], # [1, 3, 5, 7] # ] # ┏━━━┓ # ┏━━━┳━┻━┳━┻━┓ ┏━━━┓ # ┏━┻━┳━┛━┳━╋━━━╋━┻━┳━┛ # ┗━┳━┻━┳━┛ ┗━┳━┻━┳━┛ # ┣━━━╋━━━┳━┻━┳━┻━┓ # ┗━━━┻━━━┻━━━┻━━━┛ # 0 1 2 3 4 5 6 7 8 9 A B def drop_brick(brick_stack, position) sublayer_index = brick_sta...
class DashboardPolicy < Struct.new(:user, :dashboard) def index? !@user.nil? end # ... end
require 'rails_helper' describe GroupsController, :type => :controller do before do @group = FactoryGirl.create(:group) @user = FactoryGirl.create(:user, group_id: @group.id) @email = FactoryGirl.create(:email, user_id: @user.id) @group2 = FactoryGirl.create(:group) end describe "GET #index" do ...
require_relative 'db_connection' require_relative '01_sql_object' module Searchable def where(params) where_line = params.map {|attr_name, _| "#{attr_name} = ?"}.join(" AND ") inputs = params.map {|_, value| value} results = DBConnection.execute(<<-SQL, *inputs) SELECT * FROM #{t...
FactoryBot.define do factory :integration do app sequence(:name) {|n| "integration#{n}" } service "outgoing_webhook" config ({ webhook_url: "http://webhook.url" }.to_json) end end
class Api::DevicesController < ApplicationController skip_before_filter :verify_authenticity_token before_filter :authenticate_request! def create device = current_user_api.devices.new(token: params[:token]) if device.save render json: {status: 1, message_success: 'success'} else render ...
require 'minitest/autorun' require './main' describe 'decolor' do it 'removes light cyan' do str = "=> \e[1;36m" decolor(str).must_equal "" end it 'removes yellow' do str = "=> \e[33m" decolor(str).must_equal "" end it 'removes other yellow' do str = "[1;35m" decolor(str).must_equal...
#!/usr/env/ruby # Takes an old CSV and a new CSV and outputs any new data in the new CSV in the form of a CSV. # csv-diff <old-csv> <new-csv> -o <output-file> => <changes> module CSVDiff require "csv" require "rest_client" require "json" require "fileutils" require "net/http" def self.verbose; @verbose; ...
module SequelSpec module Matchers module Association class HaveManyToManyMatcher < AssociationMatcher def association_type :many_to_many end end def have_many_to_many(*args) HaveManyToManyMatcher.new(*args) end end end end
# See the Twitter API docs for more available options: # https://dev.twitter.com/docs/api/1/get/statuses/user_timeline module CacheTasks class Twitter < Task DEFAULTS = { :count => 6, :trim_user => 0, :include_rts => 1, :exclude_replies => 1, :include_en...
class Api::GamesController < ApplicationController def index @popular = Game.popular render json: @popular, serializer: MainPageSerializer, each_serializer: ShortGameSerializer end end
class DirectoriesController < ApplicationController def index @directories = DocDirectory.all render json: @directories end def show @directory = DocDirectory.byid(params[:id]) render json: @directory end end
class MethodCallsController < ApplicationController # GET /method_calls # GET /method_calls.json def index @method_calls = MethodCall.find_all_by_scenario_id(session[:scenario_id]) respond_to do |format| format.html # index.html.erb format.json { render json: @method_calls } end end ...
require 'rails_helper' RSpec.describe Section, type: :model do describe 'Require validations' do it 'should has a name' do should validate_presence_of(:name) end it 'should has a unique name' do should validate_uniqueness_of(:name).case_insensitive end end describe 'Has Associations...
require 'spec_helper' describe TimedLRU do subject { described_class.new max_size: 4 } def full_chain return [] unless head res = [head] loop do current = res.last.right break unless current expect(current.left).to eq(res.last) res << current end expect(head.left).to ...
=begin Write a method that takes a floating point number that represents an angle between 0 and 360 degrees and returns a String that represents that angle in degrees, minutes, and seconds. You should use a degree symbol (˚) to represent degrees, a single quote (') to represent minutes, and a double quote (") to repr...
execute 'sys_upgrade' do command 'yum -y upgrade' user 'root' action :run end
class Document < ApplicationRecord::Attachment has_attached_file :file validates_attachment :file, content_type: {content_type: ["application/pdf", "application/vnd.ms-excel", "application/vnd.ope...
# frozen_string_literal: true #Для проверки можно использовать функцию test с тестовым хэшом def fench_purchases(purchases = {}) loop do puts 'Input product, price and amount. To close check put \'stop\' instead product ' product = gets.chomp.to_s break if product == 'stop' price = gets.chomp.to_f ...
FactoryBot.define do factory :artist do name { Faker::Kpop.ii_groups } end end
class AddTipoAndCampoAndValorProvaToProvas < ActiveRecord::Migration def self.up add_column :provas, :tipo, :string add_column :provas, :campo, :string add_column :provas, :valor_prova, :integer end def self.down remove_column :provas, :valor_prova remove_column :provas, :campo remove_col...
class AddNecessaryInfoForUser < ActiveRecord::Migration[5.1] def change add_column :users, :address, :string add_column :users, :contact, :string add_column :users, :employed?, :boolean, default: false end end
class User < ApplicationRecord has_many :wastings, dependent: :destroy validates :name, presence: true validates :line_id, presence: true, uniqueness: true def self.line_login(code) uri = URI.parse('https://api.line.me/oauth2/v2.1/token') req = Net::HTTP::Post.new(uri) req.content_type = 'applicati...
class AddCountryIdToProfile < ActiveRecord::Migration[5.1] def up rename_column :profiles, :country, :country_id change_column :profiles, :country_id, 'integer USING CAST(country_id AS integer)' end def down change_column :profiles, :country_id, :string rename_column :profiles, :country_id,...
# To find all the prime numbers less than or equal to a given integer n by Eratosthenes' method: # Create a list of consecutive integers from 2 through n: (2, 3, 4, ..., n). # Initially, let p equal 2, the smallest prime number. # Enumerate the multiples of p by counting to n from 2p in increments of p, and mark them ...
class AddPhotosToHouses < ActiveRecord::Migration[5.0] def change add_column :houses, :photos, :json end end
module Shoperb module Theme module Editor module Mounter module Model class CustomerSubscriptionPlan < Sequel::Model extend Base::SequelClass include Base::Sequel fields :id, :name, :invoice_name, :description, :handle, :interval, :interval_count, :item_price, :setup_cost...
module Avocado class Middleware::RequestSerialization def call(package) @request = package.request Avocado::RequestStore.instance.json.merge! request: serialize(@request) yield end private def serialize(request) { method: request.method, path: req...
# 13章は配列(Array)クラス # 1. 1〜100の整数、昇順配列を作成 a = (1..100).to_a # 2. 1を100倍にした配列を作成(新配列 / 破壊的の 2種類) a2 = a.map { |a| a * 100 } #新配列 a.map! { |a| a * 100 } #破壊的 # 3. 1から3の倍数のみの新配列を作成、そのまま3の倍数以外を消去する a = (1..100).to_a a3 = a.collect { |a| a if a % 3 == 0 } a3.compact! # もっとスマートに書ける # a3 = a.reject{|i| i % 3 != 0 } a.delete...
class ApplicantJobPost < ActiveRecord::Base belongs_to :applicant belongs_to :job_post end
class User < ActiveRecord::Base attr_accessible :email, :password, :password_confirmation, :username has_secure_password has_many :messages validates :username, presence: true validates :password, presence: true, confirmation: true validates :password_confirmation, presence: true...
class Server def self.lamps lamps = [] (0..7).each do |col| lamps << Lamp.lamps_for_column(col).map{|x| x.lit? ? 1 : 0}.join("") end lamps.join(" ") end end
class Book def initialize (title, author, pages, year) @title = title @author = author @pages = pages @year = year @count_readed = 0 end attr_reader :title, :author, :pages, :year attr_writer :title, :author, :pages, :year def to_s "#{@title}" end end book_1 = Book.new("Pan Tadeus...
class TableInterpretationAliasColumnAliasnameMustBePresent < ActiveRecord::Migration[5.1] def change ActiveRecord::Base.record_timestamps = false begin InterpretationAlias.all.each do |ialias| if ialias.aliasname.blank? ialias.aliasname = "#{ialias.intent.intentname}_#{ialias.position_...
class Erfa < Formula desc "Essential Routines for Fundamental Astronomy" homepage "https://github.com/liberfa/erfa" url "https://github.com/liberfa/erfa/releases/download/v2.0.0/erfa-2.0.0.tar.gz" def install system "./configure", "--disable-debug", "--disable-dependency-tracking"...
class AddSortIdToDanceFrame < ActiveRecord::Migration def change add_column :dance_frames, :sort_id, :text end end
class PostsController < ApplicationController respond_to :html, :json def show @post = Post.includes(:category).find(params[:id]) @category = @post.category @nav_highlight = @category.slug @recent_posts_this_category = Post.published.where("category_id = ?", @category.id).where('id !...
module Roglew module WGL BACK_COLOR_BUFFER_BIT_ARB ||= 0x00000002 DEPTH_BUFFER_BIT_ARB ||= 0x00000004 FRONT_COLOR_BUFFER_BIT_ARB ||= 0x00000001 STENCIL_BUFFER_BIT_ARB ||= 0x00000008 end end module WGL_ARB_buffer_region module RenderHandle include Roglew::RenderHandleExtension ...
require 'tempfile' class Admins::TemplatesController < Admins::BaseController before_action :set_templable before_action :set_parents before_action :set_template, only: [ :update, :upload, :preview, :destroy ] before_action :set_titles before_filter :set_view_path, only: [:preview, :preview_new] before_ac...
require 'test_helper' class NobreaksControllerTest < ActionController::TestCase setup do @nobreak = nobreaks(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:nobreaks) end test "should get new" do get :new assert_response :success en...
describe :clean do it "adds field to @clean" do c = Class.new { include Datoki field(:nick_name) { varchar 1,50 } def create clean :nick_name skip :db end def happy? true end } c.create(:state=>:happy, :nick_name=>'Bob'). clean[:nick_n...
class TollsController < ApplicationController def index @tolls = Toll.all render json: @tolls end def new @toll = Toll.new end def create @toll = Toll.create(toll_params) @toll.save respond_to do |format| format.html { redirect_to "/tolls"} format.json { render json: @toll } ...
module Generator::Programs FORMS = {'_ОФО' => 'очная', '_ЗФО'=> 'заочная', '_ОЗФО'=> 'очно-заочная'} LEVELS = ['среднее профессиональное образование', # 0 'высшее образование - бакалавриат', # 1 'высшее образование - специалитет', ...
class ActiveCharityPolicy include Virtus include ActiveModel::Validations attr_reader :charity, :basic_information, :picture, :description, :contact_information MESSAGES = { :basic_information => 'Create a basic account.', :picture => 'Add a picture to display on charity page.', :d...
require 'sumac' # make sure it exists describe Sumac::RemoteObject do # remote object should be an ExposedObject example do object_request_broker = instance_double('Sumac::ObjectRequestBroker') reference = instance_double('Sumac::Objects::RemoteReference') object = Sumac::RemoteObject.new(object_reque...
class AddPermalinkToScreenShots < ActiveRecord::Migration def change add_column :screen_shots, :permalink, :string end end
class SetNextUpdateDatesForTaskAttributeRevisions < ActiveRecord::Migration class TaskAttributeRevisions < ActiveRecord::Base end def up TaskAttributeRevisions.order( :task_id, :computed, :attribute_name, :update_date, :sequence_number ).all.chunk do |rev| [rev.task_id...
class NotFoundException < StandardError end class BaseHandler def self.incoming( params_str, thread ) method, params = params_str.split( ' ', 2 ) puts "Method: #{method};" case method.upcase when 'ADD' self.add params, thread else self.custom_incoming method.upcase, params, thread ...
module SheetSync class SheetRow ATTRIBUTE_COLUMNS = { artist: 1, album: 2, genre: 3, source: 4, review: 5, reviewer: 6, date_reviewed: 7, rating: 8, aotm: 9, recommended_by: 10 }.freeze ATTRIBUTE_COLUMNS.each_pair do |attr, column_index| d...
class PerformanceResource < BaseResource PERFORMANCE_CONTENT_TYPE = "application/vnd.com.example.performance+json" # The content types this resource can be rendered in. # Support HTML and custom json. def content_types_provided [['text/html', :to_html], [PERFORMANCE_CONTENT_TYPE, :to_perf_json]] end ...
class Xgrep < Formula desc "Grep-like utility for XML files" homepage "http://wohlberg.net/public/software/xml/xgrep/" url "http://wohlberg.net/public/software/xml/xgrep/xgrep-0.08.tar.gz" sha256 "41894e5b1d0ab53258fb67ddd6b2cecf418c6bc02033c42e8160cc658faad5b7" depends_on "makedepend" => :build def insta...
require_dependency "roadblock/application_controller" module Roadblock class PermissionsController < ApplicationController before_action :load_permission, only: [:show, :edit, :update, :destroy] def index @permissions = Permission.ordered end def show end def new @permission = ...
# frozen_string_literal: true require 'prawn' require 'prawn/measurement_extensions' require 'prawn-svg' module FasTMassMailing class PDF < Prawn::Document def initialize(options = {}) super @first_page_added = false @stamps = [] fill_color '000000' stroke_color '000000' f...
class CreateHrReports < ActiveRecord::Migration def self.up create_table :hr_reports do |t| t.string :report_name t.string :name t.text :report_columns t.text :report_filters t.timestamps end end def self.down drop_table :hr_reports end end
# -*- encoding : utf-8 -*- module UsersHelper # 通过 user 的 email 获取在 gravatar 的头像 def gravatar_for(user, size=80, https=false) gravatar_id = Digest::MD5.hexdigest(user.email.downcase) image_tag("http#{https ? "s://secure" : "://www"}.gravatar.com/avatar/#{gravatar_id}?s=#{size}", alt: user.name, class: 'grav...
require_relative '../scripts/attributes_transpose' require_relative 'data/attributes_transpose_input' require "minitest/autorun" class TestAttributeTranspose < MiniTest::Test def setup @transposer = AttributeTranspose.new @data = { "arguments": [ { "id": "111122", ...
require 'rhodes_analytics/analytics_object' module RhodesAnalytics class Pageview < AnalyticsObject HITTYPE = "pageview" FIELD_MAPPING = { hostname: "dh", path: "dp", title: "dt" } end end
FactoryBot.define do sequence(:company_number_sequence) { |n| format("%08d", n) } factory :dsc_organisation, class: Organisation do name { generate(:company_name) } # Make this optional as organisation is first created without it in app trait :contact do association :dsc_contact, factory: :conta...
module DateTranslations MONTH_TO_NUMBER = { :januari => 1, :februari => 2, :maart => 3, :april => 4, :mei => 5, :juni => 6, :juli => 7, :augustus => 8, :september => 9, :oktober => 10, :november => 11, :december => 12 } def par...
class User < ActiveRecord::Base has_many :rounds has_many :guesses, through: :rounds end
require 'rails_helper' RSpec.feature "Makes a post", type: :feature do scenario "User can make a posts" do visit "/" click_link "New post" attach_file('Photo', File.absolute_path('./spec/features/Pineapple.png')) fill_in "Message", with: "Hello there!" click_button "Create Post" expect(page)...
describe Musterb::HashExtractor do it "can pull values out from a hash" do extractor = Musterb::HashExtractor.new({"foo" => "bar"}, nil) extractor["foo"].should eq "bar" end it "can pull values out from a symbol" do extractor = Musterb::HashExtractor.new({:foo => "bar"}, nil) extractor["foo"].sho...
# frozen_string_literal: true # node in a binary search tree class Node include Comparable attr_reader :data, :left, :right def <=>(other) @data <=> other.data end def initialize(data) @data = data @left = nil @right = nil end # @param node [Node] # @return [Node] def insert(node)...
class CreateDrinkSteps < ActiveRecord::Migration[5.1] def change create_table :drink_steps do |t| t.integer :drink_id t.integer :step_id t.timestamps end end end
require 'spec_helper' describe ConferencesController do login_admin before do @league = FactoryGirl.create(:league) end it "should have current_admin" do subject.current_admin.should_not be_nil end def valid_attributes { name:"NFC", league_id: @league.id } end describe "GET index" d...
require 'rails_helper' RSpec.describe FilestackRails::Transform do let!(:transform) do get_transform('someapikey') end describe "#transform_object" do it "considers av_convert bad transform" do expect{transform.av_convert(width:100)}.to raise_error(RuntimeError) en...
require './spec/spec_helper' RSpec.describe Antlr4::Runtime do it "can create IntervalSets using IntervalSet::of" do set1 = Antlr4::Runtime::IntervalSet.of(1) set2 = Antlr4::Runtime::IntervalSet.of(1, 2) expect(set1.intervals).not_to be(nil) expect(set1.intervals.length).to eq(1) expect(set1.int...
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' require 'omniauth-twitter' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtu...
class RefreshTokenService < ApplicationService def initialize(refresh_params) super() @refresh_params = refresh_params end def json_view {access_token: @access_token, refresh_token: @refresh_token} end def refresh storage_service = Jwt::RefreshTokenStorageService.new(@refresh_params[:refresh...
require 'rails_helper' RSpec.describe Report, type: :model do it "is valid" do expect(create(:report)).to be_valid end end
# Copyright 2014 Square Inc. # # 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.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed ...
require "xencoder/version" require 'xencoder/xbase' require 'xencoder/encoder' require 'ruby2_keywords' module Xencoder class << self ruby2_keywords def new(*args) Encoder.new(*args) end def encoder @encoder ||= Encoder.new( '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV...
Given /^a plateau with upper\-right coordinates of (\d+) (\d+)$/ do |x, y| @plateau = MarsRover::Plateau.new(x, y) end Given /^a Mars Rover in position (\d+) (\d+) facing "([^"]*)"$/ do |x, y, orientation| @rover = @plateau.new_rover(x, y, orientation) end When /^I tell the rover "([^"]*)"$/ do |command| @rover...
require_relative '../../lib/mince_dynamo_db/connection' describe MinceDynamoDb::Connection do subject { described_class.instance } let(:connection) { mock 'an amazon dynamo db object' } let(:access_key_id) { mock 'access key id provided by amazon'} let(:secret_access_key) { mock 'secret access key provided by...
# frozen_string_literal: true class Item < ApplicationRecord belongs_to :merchant has_many :invoice_items, dependent: :destroy has_many :invoices, through: :invoice_items validates :name, presence: true validates :description, presence: true validates :unit_price, presence: true, numericality: true vali...
require 'set' def dijkstra(graph, source) dist = {} prev = {} q = Set[] graph.each do |v| dist[v] = Float::INFINITY prev[v] = nil q << v end dist[source] = 0 while !q.empty? u = find_min_dist(dist, q) q.delete(u) u.neighbours.each do |v| alt = dist[u] + u.distance_...
class FontDeliciousHandrawn < Formula head "https://github.com/google/fonts/raw/main/ofl/delicioushandrawn/DeliciousHandrawn-Regular.ttf" desc "Delicious Handrawn" desc "Font inspired by agung rohmat's handwriting" homepage "https://github.com/alphArtype/Delicious-Handrawn" def install (share/"fonts").ins...
require "sticky_params/version" require "sticky_params/railtie" if defined?(Rails) require "sticky_params/base_params" require "sticky_params/session_params" require "sticky_params/strong_session_params" # Sticky Parameters is a nice hack that allows the 'remembering' a given param # between page requests. When a para...