hexsha stringlengths 40 40 | size int64 2 1.01M | content stringlengths 2 1.01M | avg_line_length float64 1.5 100 | max_line_length int64 2 1k | alphanum_fraction float64 0.25 1 |
|---|---|---|---|---|---|
e8fda51f4fdd3ce854e1ab0f6599d41cd8288cb0 | 849 | # LeetCode #15 - 3Sum
# https://leetcode.com/problems/3sum/
# By two pointers, repeated for each suffix, avoiding duplicates.
# @param {Integer[]} nums
# @return {Integer[][]}
def three_sum(nums)
nums.sort!
triplets = []
while nums.size > 2
first = nums.shift
pairs = two_sum(nums, -first)
triplets.c... | 18.456522 | 65 | 0.614841 |
2892569cc1e6c2574a76edad2feffbf832106bc1 | 695 | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe Canto, type: :model do
let(:blank_instance) { described_class.new }
context 'with an attribute-less instance' do
it { expect(blank_instance).to_not be_valid }
end
describe '#destroy' do
let(:stanza) { Fabricate(:stanza) }
let(:c... | 23.965517 | 56 | 0.697842 |
6111d23bab15db334ab9ea9185c5f2f18564474d | 2,038 | require 'mimetype_fu'
require 'mime-types'
require 'mime/types'
require 'rack/rewrite'
require 'rack/csrf'
require 'rack/session/moneta'
require 'rack/builder'
require 'rack/lint'
require 'dragonfly/middleware'
require_relative 'middlewares'
if ENV['PROFILER']
require 'mongo'
require 'rack-mini-profiler'
end
mo... | 22.644444 | 63 | 0.58685 |
ff400008b044f62e40f57cf287347201c9bdbcb5 | 1,025 | require 'rails_helper'
RSpec.describe Store, type: :model do
it "has valid attributes" do
store = Store.create(name: "Guess", slug: "guess", status:"active")
expect(store.name).to eq("Guess")
expect(store.slug).to eq("guess")
expect(store.status).to eq("active")
end
it "has to have a name to be... | 25 | 71 | 0.653659 |
7a75a529168f40f566d1929e91ae7c389920c33d | 736 | module SmartAnswer
module Question
class Value < Base
def initialize(flow, name, options = {}, &block)
@parse = options[:parse]
super(flow, name, &block)
end
def parse_input(raw_input)
if Integer == @parse
begin
Integer(raw_input)
rescue T... | 22.30303 | 54 | 0.527174 |
5d95cbef5e4288baa618ce74aed3266afab9ce72 | 325 | module Anilibria
module Api
module Types
Feed = DryTypes::Array.of(
DryTypes.Constructor(Types::Base) do |i|
case i.keys.first
when :title then Types::Title.new(i[:title])
when :youtube then Types::YouTube.new(i[:youtube])
end
end
)
end
end... | 21.666667 | 60 | 0.566154 |
330651a42c4a4aa440730ebb30123432649fba40 | 932 | first_lambda = lambda { puts "my first lambda"}
first_lambda.call
##################
first_lambda = -> { puts "my first lambda"}
first_lambda.call
###################
first_lambda = -> (names){ names.each { |name |puts name} }
names = ["joão", "maria", "pedro"]
first_lambda.call(names)
####################
... | 20.26087 | 59 | 0.607296 |
6a352facb1f89b691e656b55233c3da62f86f447 | 1,327 | # encoding: UTF-8
require_relative '../metadata/column'
module GoodData
module Model
##
# GoodData display form abstraction. Represents a default representation
# of an attribute column or an additional representation defined in a LABEL
# field
#
class Label < Column
attr_accessor :att... | 25.037736 | 111 | 0.584778 |
332d029114c010b9d73d7ed76a146d91b7f5f954 | 334 | class Restaurant < ActiveRecord::Base
validates_presence_of :cuisine, :location #:overall_rating
validates :name, presence: true, uniqueness: true #validates restaurant name to ensure uniqueness/prevent same restaurant from being persisted to database more than once.
has_many :reviews
has_many :users, through:... | 41.75 | 172 | 0.799401 |
2630a0f3a43e94db2ecdd9f6ed96553b9823316e | 13,611 | # encoding: utf-8
require "cases/helper"
require 'models/owner'
require 'tempfile'
require 'support/ddl_helper'
module ActiveRecord
module ConnectionAdapters
class SQLite3AdapterTest < ActiveRecord::TestCase
include DdlHelper
self.use_transactional_fixtures = false
class DualEncoding < Active... | 30.934091 | 131 | 0.58607 |
d5d182b6196e3834d0604d2db7c6821e49745910 | 9,177 | Pod::Spec.new do |s|
s.name = "TQKit"
s.version = "2.0.2"
s.summary = "TQKit is iOS TQ Project"
s.description = <<-DESC
新增去除字符串所有空格的方法,新增获取网络时间的方法
DESC
s.homepage = "https://github.com/love0912/TQKit"
s.license = { :type => "MIT", :file => "LICENSE" }
s.aut... | 41.90411 | 99 | 0.544296 |
872f45d9c9d4cbda3bc798ed67c9a0eb3246bde6 | 1,330 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'bocci/version'
Gem::Specification.new do |spec|
spec.name = "bocci"
spec.version = Bocci::VERSION
spec.authors = ["mrpero"]
spec.email = ["abe@zikuu.jp"]
s... | 35.945946 | 96 | 0.654135 |
bb7e94f1c633c94f76399789ba027f98a88e436f | 2,133 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... | 43.530612 | 95 | 0.741678 |
ff65db486870670f09fa4e28364947e54642a45b | 1,949 | #-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork ... | 39.77551 | 91 | 0.768086 |
f7e4ea6383f180aff003c9dbf8e9a202cb2ba257 | 1,456 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
#... | 45.5 | 98 | 0.757555 |
bf67b336b14a775b75101a2c5f7d8b9ae5a03b6a | 1,282 | # frozen_string_literal: true
module Pipedawg
# util class
class Util
def self.expand_env_vars(item) # rubocop:disable Metrics/MethodLength
case item
when Array
item.map { |i| expand_env_vars(i) }
when Hash
item.each { |k, v| item[k] = expand_env_vars(v) }
item.transfo... | 28.488889 | 73 | 0.562402 |
3999d51225e6e68baf436ddeba91a245fa916fb8 | 734 | cask 'xamarin-jdk' do
version '7.71'
sha256 '70a18547b529a111c4e5cf133532082e142908819b0d61e273c21dee86fcc87a'
url "https://download.xamarin.com/Installer/MonoForAndroid/jdk-#{version.major}u#{version.minor}-macosx-x64.dmg"
appcast 'https://static.xamarin.com/installer_assets/v3/Mac/Universal/InstallationManif... | 45.875 | 114 | 0.779292 |
21648c17c50a3673835d173c07fce66bd2b3ed9d | 3,303 | require 'rails_helper'
describe "upload TaggedAnimalAssessment category", type: :feature do
let(:user) { User.create({ :email => "admin@test.com",
:password => "password",
:password_confirmation => "password" }) }
let(:valid_file) { "db/sample_data_files/tagged_animal_assessment/T... | 39.795181 | 152 | 0.703603 |
26e90e8cf8c0618bb90d11c7301916758be88d8f | 6,718 | # frozen_string_literal: true
class GitPushService < BaseService
attr_accessor :push_data, :push_commits
include Gitlab::Access
include Gitlab::Utils::StrongMemoize
# The N most recent commits to process in a single push payload.
PROCESS_COMMIT_LIMIT = 100
# This method will be called after each git upda... | 28.956897 | 108 | 0.72343 |
915854a9bdf4a1e28c78b6eea5b7875be67f522a | 47 | module Inspec
VERSION = "4.18.25".freeze
end
| 11.75 | 28 | 0.702128 |
26a2a34f0934d57744099d1a8975a143719b3605 | 509 | # Dump JSON Schema from YAML
#
# Run thes following command in the repo root directory:
# bundle exec ruby bin/schema-generator.rb ./data/sde/fsd/blueprints.yaml
require "json-schema-generator"
require "yaml"
y = File.open(ARGV[0], "r") { |f| YAML.load_file(f) }
File.open("./tmp/tmp.json", "w") { |f| f.write(y.to_j... | 29.941176 | 91 | 0.679764 |
91cad6a19249cf4b82876f79fa2f53d8cbfa6eab | 1,790 | # Copyright (c) 2008 Google 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 to in wr... | 35.098039 | 109 | 0.684916 |
e940a2f009ede541c280de1e2c83c015aa3bb47f | 303 | class StaticPagesController < ApplicationController
include HideBlockingUser
def home
if logged_in?
@micropost = current_user.microposts.build
@feed_items = current_user.feed.paginate(page: params[:page])
end
end
def help
end
def about
end
def contact
end
end
| 15.15 | 67 | 0.709571 |
61cbbf84fa58befbd53f5b009b8ae191245ff412 | 654 | RSpec.describe Directions::North do
before(:each) do
@north = Directions::North.new
end
describe "#turn_left" do
it "returns WEST" do
expect(@north.turn_left).to eq(Directions::WEST)
end
end
describe "#turn_right" do
it "returns EAST" do
expect(@n... | 21.096774 | 55 | 0.568807 |
38e4feca8a3f99d4cb0a5f947dc37d3d1a7469dc | 3,810 | =begin
#Datadog API V1 Collection
#Collection of all Datadog Public endpoints.
The version of the OpenAPI document: 1.0
Contact: support@datadoghq.com
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
Unless explicitly stated otherwise all files in this repository are licensed ... | 28.863636 | 226 | 0.665879 |
ed3cc4f78833f2086bbd733990fb40d9ed0e54cc | 2,123 | #
# Be sure to run `pod lib lint MLNCore.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'MLN'
... | 36.603448 | 98 | 0.581253 |
11600a21b36d8d64d1e94e21e80cf91e9194ed80 | 8,339 | # -*- coding: binary -*-
require 'rex/socket'
require 'rex/proto/http'
require 'rex/proto/http/handler'
module Rex
module Proto
module Http
###
#
# Runtime extension of the HTTP clients that connect to the server.
#
###
module ServerClient
#
# Initialize a new request instance.
#
def init_cli(server)
self.requ... | 21.716146 | 106 | 0.669025 |
f78bf0bebc625d22775c4ea23c411e2162c3d4f3 | 434 | require "spec_helper"
describe "a parser with two terminal rules which overlap" do
let(:parser) do
Class.new(Whittle::Parser) do
rule("def")
rule("define")
rule(:id => /[a-z_]+/)
rule(:prog) do |r|
r["def"]
r["define"]
r[:id]
end
start(:prog)
end
... | 18.083333 | 63 | 0.564516 |
186008634ec4feb232cc7522c01b0ad892c92284 | 246 | require_relative 'resource'
module Contentful
# An Assets's file info
class File
include Contentful::Resource
property :fileName, :string
property :contentType, :string
property :details
property :url, :string
end
end
| 17.571429 | 34 | 0.715447 |
0184440d87744ffe2d27ae2284f6256a21d81206 | 697 | require_relative '../../../spec_helper'
require 'rexml/document'
describe "REXML::CData#initialize" do
it "creates a new CData object" do
c = REXML::CData.new("some text")
c.should be_kind_of(REXML::CData)
c.should be_kind_of(REXML::Text)
end
it "respects whitespace if whitespace is true" do
... | 27.88 | 55 | 0.645624 |
1dfb7bc86de0e7c6e38122e0a5e1c7412c616653 | 1,630 | # frozen_string_literal: true
class Fisk
module Instructions
# Instruction SUBSS: Subtract Scalar Single-Precision Floating-Point Values
SUBSS = Instruction.new("SUBSS", [
# subss: xmm, xmm
Form.new([
OPERAND_TYPES[23],
OPERAND_TYPES[24],
].freeze, [
Class.new(Fisk::En... | 28.103448 | 79 | 0.497546 |
333d94081ec0544beccd1c3c6d6faf187a4bec34 | 570 | module ReverseMarkdown
module Converters
class Del < Base
def convert(node, state = {})
content = treat_children(node, state.merge(already_crossed_out: true))
if disabled? || content.strip.empty? || state[:already_crossed_out]
content
else
"~~#{content}~~"
... | 21.111111 | 78 | 0.582456 |
1c874766bf1256d4167e00356eba70118911e914 | 1,390 | $: << File.join(File.dirname(__FILE__),'lib')
require 'calculations'
include Calculations
# MyWorker defines the behaviour of workers.
# Here is where the real processing takes place
class MyWorker < ScbiMapreduce::Worker
# starting_worker method is called one time at initialization
# and allows you to initializ... | 24.385965 | 65 | 0.72446 |
e89af1cd7cb701debef8bb906162eaaebbe20a19 | 1,130 | module Vitals::Formats
class HostLastFormat
attr_accessor :environment
attr_accessor :host
attr_accessor :facility
def initialize(environment:'development', facility:'default', host:'localhost')
@environment = environment
@facility = facility
@host = host
@host = Vitals::Util... | 41.851852 | 120 | 0.649558 |
e28b237f518f0ff7fc4844600750f22fa87bd159 | 115 | class AddTypeToImages < ActiveRecord::Migration[4.2]
def change
add_column :images, :type, :string
end
end
| 19.166667 | 52 | 0.730435 |
3309caa3907ec2ce37203895a77ec7aed34bf6cc | 126 | require "fullcalendar/rails/version"
module Fullcalendar
module Rails
class Engine < ::Rails::Engine
end
end
end
| 14 | 36 | 0.722222 |
d5082b413247bdf86dd666deea39e38653e88b08 | 9,689 | class WorkPaper < ApplicationRecord
include Auditable
include ParameterSelector
include Comparable
include WorkPapers::LocalFiles
include WorkPapers::Review
# Named scopes
scope :list, -> { where(organization_id: Current.organization&.id) }
scope :sorted_by_code, -> { order(code: :asc) }
scope :with_... | 30.955272 | 106 | 0.672825 |
085866deb8d05c688a341ac0d5a7e86f0d73dc51 | 933 | module VagrantPlugins
module GuestLinux
module Cap
class ShellExpandGuestPath
def self.shell_expand_guest_path(machine, path)
real_path = nil
path = path.gsub(/ /, '\ ')
machine.communicate.execute("echo; printf #{path}") do |type, data|
if type == :stdout
... | 28.272727 | 77 | 0.55627 |
01b178f7ef13a2fb7f2b41ffd52f82f61fd37887 | 621 | require 'umu/common'
module Umu
module ConcreteSyntax
module Module
module Pattern
class Abstract < Abstraction::Model
def desugar_value(expr, env)
E::Tracer.trace(
env.pref,
env.trace_stack.count,
'Desu(Val)',
self.class,
self.pos,
self.to_s
) { |event|
__desugar_value__... | 13.5 | 42 | 0.697262 |
ed94c52228e7b334c7d4cb23f8f7cec63688461d | 29 | module UnauthRsvpsHelper
end
| 9.666667 | 24 | 0.896552 |
1d770060a7779dddb20149ead94a3c489fdde45c | 2,663 | # Effective Engine concern
module EffectiveGem
extend ActiveSupport::Concern
EXCLUDED_GETTERS = [
:config, :setup, :send_email, :parent_mailer_class,
:deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject
]
included do
raise("expected self.config_keys method") unless resp... | 29.921348 | 268 | 0.711603 |
abaced02b17a195bfcfa9160f0b9648e131aa2c4 | 72 | class StaticPagesController < ApplicationController
def home
end
end
| 12 | 51 | 0.833333 |
1d26b0acefd277f716dbed96513314fd5060c8d8 | 2,353 | require 'fog/aws/elbv2/default_tg_attributes'
Shindo.tests('AWS::elbv2 | target_group', ['aws', 'elbv2', 'models']) do
Fog::Compute::AWS::Mock.reset if Fog.mocking?
ELBV2 = Fog::AWS[:elbv2]
@server1 = Fog::Compute[:aws].servers.create
@server1.wait_for { ready? }
@server2 = Fog::Compute[:aws].servers.crea... | 33.614286 | 104 | 0.691033 |
792d50a193d10a7093c30a226a6a4b4a44b688eb | 3,063 | require 'arduino_firmata'
require 'active_support/core_ext/hash/except'
class HardwareConfig
def initialize()
@config = Hardware.first_or_create
@led = {
normal: @config.normal_mode_led,
reset: @config.reset_mode_led,
a: @config.a_led_pin,
x: @config.x_led_pin,
up: @config.a_led... | 24.701613 | 96 | 0.612798 |
1c11dd40f2cfe9605769ad4b09bdee44cf2d35d2 | 382 | require 'puppet/provider/confine'
class Puppet::Provider::Confine::False < Puppet::Provider::Confine
def self.summarize(confines)
confines.inject(0) { |count, confine| count + confine.summary }
end
def pass?(value)
! value
end
def message(value)
"true value when expecting false"
end
def su... | 19.1 | 67 | 0.683246 |
e8e53e3b43daaeddeedd7c41fe5a83f18240f975 | 81 | require 'omniauth-http-header/version'
require 'omniauth/strategies/http_header'
| 27 | 41 | 0.839506 |
7af32b46fdc5888ea8c0be8cf17bfb4649d34450 | 1,601 | module Fog
module Rackspace
class Monitoring
class Real
def get_system_info(agent_id)
request(
:expects => [200, 203],
:method => 'GET',
:path => "agents/#{agent_id}/host_info/system"
)
end
end
class Mock
def... | 30.788462 | 73 | 0.413492 |
b92460aa0e158fa145845684e672d34e7dd175ed | 4,090 | require 'spec_helper'
describe Admin::CoursesController do
before { sign_in_teacher }
let(:valid_attributes) { build(:course).attributes }
let(:unit) { create :unit }
describe "GET show" do
let(:course) { create :course, unit: unit }
it "assigns the requested course as @course" do
get :show, u... | 33.801653 | 109 | 0.655501 |
f8346c148524362c0cc883e0ef2083f8fde9fbb5 | 6,355 | require_relative '../test_helper'
describe Game do
describe "#all" do
# describe "if there are no games in the database" do
# it "should return an empty array" do
# assert_equal [], Game.all
# end
# end
describe "if there are games" do
before do
create_game("Bob", "3", "... | 30.552885 | 106 | 0.555625 |
f77addb735a46a4496e1514be35d37a8bcf7c2bd | 5,010 | require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold... | 35.28169 | 100 | 0.697605 |
ed711af545b8fe6c0899f47781009ed3ba60ee7d | 1,838 | # encoding: utf-8
# This file is autogenerated. Do not edit it manually.
# If you want change the content of this file, edit
#
# /spec/fixtures/responses/whois.cctld.uz/uz/status_registered.expected
#
# and regenerate the tests with the following rake task
#
# $ rake spec:generate
#
require 'spec_helper'
require ... | 27.029412 | 77 | 0.683896 |
e8debb5475d5684b7c1c95986fdb780a6a1a231b | 383 | module Billimatic
module Entities
class AddressInformation < Base
attribute :id, Integer
attribute :address, String
attribute :number, String
attribute :complement, String
attribute :district, String
attribute :zipcode, String
attribute :city, String
attribute :stat... | 23.9375 | 35 | 0.678851 |
627a2d0ca8a198e4f3264be4865fb0ffe7c0379a | 1,000 | # Author:: radiospiel (mailto:eno@radiospiel.org)
# Copyright:: Copyright (c) 2011, 2012 radiospiel
# License:: Distributes under the terms of the Modified BSD License, see LICENSE.BSD for details.
require_relative 'test_helper'
require "contracts"
class ContractsModuleTest < Test::Unit::TestCase
module M
... | 20.408163 | 100 | 0.681 |
793426cb7dc3f31ad4b5ad985b5f6a9c644a6b9b | 857 | # = Archon.populated_recordset
module Archon
def self.populated_recordset(base, rows = [])
return Nodes::PopulatedRecordset.new base, rows
end
module Nodes
# = PopulatedRecordset
#
# This ARel node creates a populated recordset from a JSON generated by the given ruby array of
# hashes.
cl... | 27.645161 | 99 | 0.662777 |
1ac4f14ad3c7f82240e677cad35554b894a754a9 | 6,324 | =begin
#Selling Partner API for Product Fees
#The Selling Partner API for Product Fees lets you programmatically retrieve estimated fees for a product. You can then account for those fees in your pricing.
OpenAPI spec version: v0
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen versio... | 31.152709 | 232 | 0.636622 |
ab4f2eec020ae307c632dd1d972c9c3cb9fc7dcf | 3,546 | # frozen_string_literal: true
# Cloud Foundry TomEE Buildpack
# Copyright 2013-2019 the original author or 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
#
# http://www.apache... | 38.543478 | 118 | 0.740835 |
b903ea68172fed33f8be58af553d9b4d4a0db10b | 5,734 | =begin
PureCloud Platform API
With the PureCloud Platform API, you can control all aspects of your PureCloud environment. With the APIs you can access the system configuration, manage conversations and more.
OpenAPI spec version: v2
Contact: DeveloperEvangelists@genesys.com
Generated by: https://github.com/swagger-ap... | 22.224806 | 177 | 0.565051 |
ff866b93bb6ba1b94befeecfa66c919d17b164b0 | 702 | module Pump
class Install::Firewall < Launchctl
PLIST_DIR = "/Library/LaunchDaemons"
PLIST = File.join(PLIST_DIR, "#{SERVICE_NAME_TEMPLATE}.plist")
def self.service_name
"firewall"
end
# Create and load plist under root
def self.install
mkdir_plist
create_plist
Base.l... | 26 | 93 | 0.659544 |
0113bbe2d9b85250f12c12e988030c73178c9bc7 | 130 | class RenameForkedAppId < ActiveRecord::Migration
def change
rename_column :apps, :forked_play_id, :forked_app_id
end
end
| 21.666667 | 56 | 0.784615 |
3944dc8734c14c0ad97fe3ff4b7a3ab6b53af0eb | 148 | class Element < ActiveRecord::Base
belongs_to :dimension
has_many :scripts
has_many :scenes, through: :scripts
translates :description
end
| 18.5 | 37 | 0.77027 |
875b0451d8611f0a6f1101db7ff8183d6b03de1f | 245 | # frozen_string_literal: true
require 'feature_test'
class TestGraphicsFeature < FeatureTest
feature :graphics do
report = Thinreports::Report.new layout: template_path
report.start_new_page
assert_pdf report.generate
end
end
| 18.846154 | 58 | 0.779592 |
38dca22a6ac70358968ccd6cadaff59dd8956ed6 | 5,182 | ## --- BEGIN LICENSE BLOCK ---
# Original work Copyright (c) 2015-present the fastlane authors
# Modified work Copyright 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 ... | 29.611429 | 109 | 0.609996 |
085f6fad3120abfca7f2956d247c54886b96c678 | 411 | class CreateContractApprovers < ActiveRecord::Migration
def change
create_table :contract_approvers do |t|
t.references :contract, index: true
t.references :user, index: true
t.string :approved
t.string :notified
t.text :log
t.timestamps null: false
end
add_foreign_key... | 25.6875 | 55 | 0.705596 |
bfdbe0987a9be6ebf8175710116a091ad35ccec1 | 90 | #!/usr/bin/ruby
require_relative '../../../lib/kvm'
KVM.load_conf
puts DomainList.info
| 11.25 | 35 | 0.688889 |
b95d0bdb7689fb144bc136529b579d4c8088db5d | 5,462 | require "set"
require "tempfile"
require "vagrant/util/retryable"
require "vagrant/util/template_renderer"
module VagrantPlugins
module GuestFedora
module Cap
class ConfigureNetworks
extend Vagrant::Util::Retryable
include Vagrant::Util
def self.configure_networks(machine, network... | 40.459259 | 160 | 0.613328 |
f8b6592875826f2223d9b29c1eb97f4cf2d55545 | 1,108 | # frozen_string_literal: true
module Gitlab
class GroupSearchResults < SearchResults
attr_reader :group
def initialize(current_user, query, limit_projects = nil, group:, default_project_filter: false)
@group = group
super(current_user, query, limit_projects, default_project_filter: default_proj... | 29.945946 | 100 | 0.701264 |
6179d02a9ecf0ea09db2ae9e830ddc7ceee53177 | 860 | class Order < ApplicationRecord
include AASM
belongs_to :user, dependent: :destroy
has_many :order_items
validates :recipient, :tel, :address, presence: true
before_create :generate_order_num
aasm column: 'state' do
state :pending, initial: true
state :paid, :delivered, :cancelled
event :p... | 20.97561 | 69 | 0.666279 |
e9441817de1b3d512587cbc3627088d4a38fe11a | 9,655 | # encoding: utf-8
module Mail
# Provides access to a header object.
#
# ===Per RFC2822
#
# 2.2. Header Fields
#
# Header fields are lines composed of a field name, followed by a colon
# (":"), followed by a field body, and terminated by CRLF. A field
# name MUST be composed of printable ... | 33.408304 | 178 | 0.627343 |
79408fb2ff10bef328b7cba01802d9c75adfd388 | 6,269 |
require 'sass/plugin'
require 'compass'
require 'compass/commands'
require 'fileutils'
module Jekyll
module Compass
# This is the main generator plugin for Jekyll. Jekyll finds these plugins
# itself, we just need to be setup by the user as a gem plugin for their
# website. The plugin will onl... | 31.034653 | 81 | 0.553517 |
fff602328b69ba2b6a83daf36041ef0499699957 | 1,818 | # frozen_string_literal: true
require_relative "capture_code_context"
require_relative "display_code_with_line_numbers"
module DeadEnd
# Used for formatting invalid blocks
class DisplayInvalidBlocks
attr_reader :filename
def initialize(code_lines:, blocks:, io: $stderr, filename: nil, terminal: DEFAULT_V... | 21.388235 | 93 | 0.612211 |
08e2b8d4cf8001c1b0d69761ad6e9c32f34cd19a | 2,302 | # frozen_string_literal: true
module Spotlight
module Concerns
##
# Search context helpers
module CatalogSearchContext
protected
def current_page_context
@current_page_context ||= if current_search_session_from_home_page?
current_exhibit.home_page ... | 38.366667 | 110 | 0.643354 |
62599229f11e0514a2d5a11f943de53fc5038126 | 522 | require('net/http')
address = ENV['PUMA_BIND_ADDRESS'] || 'localhost'
port = ENV['PUMA_BIND_PORT'] || 9292
http_class = Net::HTTP
target_address = URI.parse("http://#{address}:#{port}/health-check")
request_setup = { open_timeout: 5, read_timeout: 5 }
get_configuration = http_class::Get.new(target_address.to_s)
resp... | 24.857143 | 90 | 0.733716 |
bbba363f017d1110be26cb6471c8134784155854 | 48 | # 引用 rails engine
require 'company_info/engine'
| 16 | 29 | 0.791667 |
28e16e5b53d34fa4b2b2d427385a5d63f89c2aaf | 2,621 | # frozen_string_literal: true
require("config")
require("ctci/ctci_c3_p3")
module CTCI
module C3
class TestP3 < Minitest::Test
def setup
@stack = P3.new(3)
end
def test_size
@stack.push(0)
assert_equal(1, @stack.size)
end
def test_size_when_empty
a... | 22.401709 | 58 | 0.579168 |
d508d2a84a3ebcc213b47a86f76423c2021dd840 | 708 | require 'pry'
class Spells
attr_accessor :_id, :index, :name, :desc, :higher_level, :range, :components, :material, :ritual, :duration, :concentration, :casting_time, :level, :attack_type, :damage, :school, :classes, :subclasses, :url, :dc, :heal_at_slot_level,
:area_of_effect
@@all = []
def initialize(attributes)
... | 22.83871 | 234 | 0.704802 |
abc85c0f29c15b3bb5c13ca2548a8e46ba2d9189 | 1,613 | #
# Be sure to run `pod lib lint MGXRouter.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'MGXRouter... | 35.065217 | 110 | 0.631122 |
f7f3954cec3cf6582adf7c6058e0a07868780ed5 | 223 | # Converts a blank node ID into a dummy URI
class ConvertBnodeToUri
def self.call(value)
return value unless value.is_a?(String) && value.starts_with?('_:')
"https://credreg.net/bnodes/#{value[2..-1]}"
end
end
| 24.777778 | 71 | 0.690583 |
0857fc162782f8ad6e0eaa9a9af8a09c357e3eb2 | 96 | class RestaurantSerializer < ActiveModel::Serializer
attributes :id, :name, :sample_image
end
| 24 | 52 | 0.802083 |
bb20ab91eec21fb70d914025924d42b8c431f457 | 1,066 | # encoding: utf-8
RSpec.describe TTY::Prompt::Result do
it "checks value to be invalid" do
question = double(:question)
result = TTY::Prompt::Result.new(question, nil)
answer = result.with { |quest, value|
if value.nil?
[value, ["`#{value}` provided cannot be empty"]]
else
va... | 26 | 64 | 0.613508 |
08c75563a6d13a03b209f074ad66ea4fdabaf574 | 820 | require 'test_helper'
module DocusignTransactionRooms
class ConfigurationTest < Minitest::Test
class ModifiedSettings < Minitest::Test
def test_the_api_url_can_be_set
assert_equal "https://demo.rooms.docusign.com", DocusignTransactionRooms.configuration.api_url
DocusignTransactionRooms.c... | 29.285714 | 102 | 0.75122 |
2114bb6201635862ee0153f3e1c3205ee274f8f1 | 2,207 | # frozen_string_literal: true
require 'rails_helper'
feature 'Admins can browse car categories' do
before :each do
log_user_in!
end
scenario 'and view car models links inside a dropdown' do
honda = Manufacturer.create! name: 'Honda'
fiat = Manufacturer.create! name: 'Fiat'
sedan = CarCategory.... | 44.14 | 91 | 0.613956 |
38fa9d61a40ceee56223fd79d088ac6d3759dc47 | 150 | class ChangeAddressesCountryToCountryCode < ActiveRecord::Migration[4.2]
def change
rename_column :addresses, :country, :country_code
end
end
| 25 | 72 | 0.793333 |
acb6482a64fcdcd32482d8b00c4ba33b2983d78a | 464 | #!/usr/bin/env ruby
require "./lib/orphaned_statefiles"
s3 = Aws::S3::Resource.new(
region: ENV.fetch("TF_STATE_BUCKET_REGION"),
access_key_id: ENV.fetch("TF_STATE_BUCKET_AWS_ACCESS_KEY_ID"),
secret_access_key: ENV.fetch("TF_STATE_BUCKET_AWS_SECRET_ACCESS_KEY"),
)
ctsf = DeletedClusterTerraformStateFiles.new(
... | 25.777778 | 72 | 0.75431 |
1da64b5643b3058997f34fd2a2c3a6940f7a8a7b | 166 | # This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Samplewebservice::Application
| 33.2 | 67 | 0.783133 |
d5c63bdd0ce68f5dfcad5d1414be23f211402ff4 | 729 |
class Publicaciones < Referencia
attr_reader :nombre
def initialize(autores,titulo,nombre)
super(autores,titulo)
@nombre = nombre
end
def ==(other)
if (super(other))
for i in (0..nombre.length)
... | 20.828571 | 53 | 0.377229 |
616991fcfd6b7f9d9d02687708229e60ee22cf8e | 881 | class Api::V1::DoctorsController < ApplicationController
before_action :set_doctor, only: [:show, :update, :destroy]
def show
render json: @doctor
end
def create
@doctor = Doctor.new(doctor_params)
if @doctor.save
render json: @doctor
else
... | 21.487805 | 83 | 0.561862 |
8752ea265b8eed3af0d26c900ff2af52409f07cb | 1,088 | require "rails_helper"
describe "GET /zones", type: :feature do
context "User with viewer permissions" do
before do
login_as create(:user, :reader)
end
it "lists zones" do
zone = create :zone
zone2 = create :zone, name: "test.example.com"
visit "/dns"
expect(page).to have_... | 24.177778 | 60 | 0.653493 |
33806679220d870ed67a3cc89bb70a243eeeb73e | 5,389 | # encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
module Azure::Policy::Mgmt::V2017_06_01_preview
#
# A service client - single point of access to the REST API.
#
class PolicyClient < MsRestAzure::A... | 39.625 | 154 | 0.696048 |
1d4e4ee713c562ed815e47f690e14ac595bc5430 | 1,599 | require 'open3'
module Wisepdf
class Writer
def initialize(wkhtmltopdf = nil, options = {})
self.wkhtmltopdf = wkhtmltopdf unless wkhtmltopdf.nil?
self.options = options
end
def to_pdf(string, options={})
invoke = self.command(options).join(' ')
self.log(invoke) if Wisepdf::... | 24.984375 | 127 | 0.601626 |
3947e1b9d7b562a6d09cd2550896bc3c37f78c86 | 1,888 | cask 'cocktail' do
if MacOS.release == :snow_leopard
version '5.1'
sha256 '630fc5236e95d5ec36c0de4b487f8ece76d8f02ecd00ec4b37124ddd0eed0f34'
url "http://www.maintain.se/downloads/sparkle/snowleopard/Cocktail_#{version}.zip"
appcast 'http://www.maintain.se/downloads/sparkle/snowleopard/snowleopard.xml... | 41.043478 | 87 | 0.768008 |
61b252075d61754d5a9ab341e9f4fb2f5ee5d390 | 2,938 | # frozen_string_literal: true
require 'dopp'
require 'dopp/section/cid_type0_font'
module Dopp
module Font
# CID font "MS Mincho".
class MsMincho
include ::Dopp::Error
include ::Dopp::Font
# Font names.
NAMES ||= %w[
MS明朝 MS-Mincho
].tap { |v| ::Dopp::Util.deep_freeze(... | 26.468468 | 61 | 0.566031 |
1a0359b20cd5444f8ab84bc70f5ae0f9c293b137 | 3,648 | require 'spec_helper'
RSpec.describe 'OkexSwap integration specs' do
let(:client) { Cryptoexchange::Client.new }
let(:xbt_usd_pair) { Cryptoexchange::Models::MarketPair.new(base: 'BTC', target: 'USD', market: 'okex_swap', contract_interval: "perpetual", inst_id: "BTC-USD-SWAP") }
let(:xbt_usd_pair_weekly) { Cryp... | 36.118812 | 175 | 0.712719 |
d579df1303fa05f61334f168e566a3a0f61ca23c | 310 | class CreateFaces < ActiveRecord::Migration
def change
create_table :faces do |t|
t.integer :photo_id
t.string :database_uuid
t.string :face_uuid
t.float :x
t.float :y
t.float :w
t.float :h
t.integer :person_id
t.string :timestamps
end
end
end
| 19.375 | 43 | 0.609677 |
b9640f68a511fbdc14c9d99da8a8666ca06f8915 | 2,448 | require 'spec_helper'
describe 'octavia::quota' do
let :default_params do
{
:default_load_balancer_quota => '<SERVICE DEFAULT>',
:default_listener_quota => '<SERVICE DEFAULT>',
:default_member_quota => '<SERVICE DEFAULT>',
:default_pool_quota => '<SERVICE DEFAULT>... | 37.090909 | 129 | 0.705065 |
e9c55648ce605ab724ea3b8405571afa1ee8cc9e | 2,393 | describe 'Additional Attribute data type', js: true do
context 'when viewing the descriptive keywords form' do
before do
login
draft = create(:collection_draft, user: User.where(urs_uid: 'testuser').first)
visit collection_draft_path(draft)
within '.metadata' do
click_on 'Descript... | 28.488095 | 101 | 0.602591 |
7adf892d34c7e032f078e4ac95ef375f95a98abf | 292 | module Backline
module Attributes
class Attribute < Struct.new(:name, :options)
def initialize(name, options = {})
super(name.to_s, options)
end
def getter_method
name
end
def setter_method
"#{name}="
end
end
end
end | 15.368421 | 49 | 0.568493 |
1d81837a9315a263000ab907009b788f6f4ac18d | 806 |
Puppet::Type.newtype(:oneandone_firewall) do
@doc = 'Type representing a 1&1 firewall policy.'
ensurable
newparam(:name, namevar: true) do
desc 'The name of the firewall policy.'
validate do |value|
raise('The name should be a String.') unless value.is_a?(String)
end
end
newproperty(:rul... | 21.210526 | 70 | 0.657568 |
9150aa543a0925480be57ab12ac57af640978e83 | 1,240 | class Cbmc < Formula
desc "C Bounded Model Checker"
homepage "https://www.cprover.org/cbmc/"
url "https://github.com/diffblue/cbmc.git",
tag: "cbmc-5.18.0",
revision: "7ff70ee00d85ff9d84c2534db9b975d8e04d4559"
license "BSD-4-Clause"
bottle do
cellar :any_skip_relocation
sha256 "ed3c1... | 27.555556 | 93 | 0.654839 |
331dbe2d6e1e001bb3e359ce01b56548a9ccc4b8 | 1,617 | class Crane < Formula
desc "Tool for interacting with remote images and registries"
homepage "https://github.com/google/go-containerregistry"
url "https://github.com/google/go-containerregistry/archive/v0.6.0.tar.gz"
sha256 "e9d9e9c662f6c9140083eb884bec9f2fc94554bb1d989aa6846e9cf2f69a27d5"
license "Apache-2.0... | 50.53125 | 123 | 0.788497 |
d5b1aca0ea20039b70ab77b4172e1b0a3173ff22 | 771 | # frozen_string_literal: true
# extract logic here
class VotesController < ApplicationController
include SessionsHelper
include UsersHelper
before_action :authenticate_user
def new; end
def create
if current_user.active_membership?
@user = current_user
active_vote = @user.active_vote
@... | 22.028571 | 98 | 0.701686 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.