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 |
|---|---|---|---|---|---|
383e0a2d09985c45490409f64ae4d794da321041 | 46 | class GeneticAlgorithm
VERSION = '0.0.1'
end | 15.333333 | 22 | 0.73913 |
5d0ebdbc78e8d1368c7b1a391e404c2526df2f1d | 186 | # This migration comes from spree (originally 20130222032153)
class AddOrderIdIndexToShipments < ActiveRecord::Migration
def change
add_index :spree_shipments, :order_id
end
end
| 26.571429 | 61 | 0.806452 |
ed09e65240faa64b4feadf0e57e746f46aa08a8c | 933 | module MCTS
class Root < Node
def initialize(game_state)
super game_state, nil, nil
end
def root?
true
end
def best_child
children.max_by &:win_percentage
end
def best_move
best_child.move
end
def explore_tree
selected_node = select
playout_n... | 18.66 | 75 | 0.557342 |
ed674c05129ab69a9d0534b7e7ff199ed9dda546 | 1,237 |
Pod::Spec.new do |s|
s.name = 'JXPhotoBrowser'
s.version = '2.2.1'
s.summary = 'Elegant photo browser in Swift.'
s.description = 'Elegant photo browser in Swift. Inspired by WeChat.'
s.homepage = 'https://github.com/JiongXing/PhotoBrowser'
s.scree... | 34.361111 | 108 | 0.58367 |
6a4257631eaeb72ee567c52630d38368b02d5f2b | 407 | class CreateOpenStaxAccountsGroupOwners < ActiveRecord::Migration[4.2]
def change
create_table :openstax_accounts_group_owners do |t|
t.references :group, null: false
t.references :user, null: false
t.timestamps null: false
end
add_index :openstax_accounts_group_owners, [:group_id, :us... | 29.071429 | 82 | 0.744472 |
186166175ff0dd6ac78053363270f60b434f7a7f | 1,012 | class Rmtrash < Formula
desc "Move files to OS X's Trash"
homepage "http://www.nightproductions.net/cli.htm"
url "http://www.nightproductions.net/downloads/rmtrash_source.tar.gz"
sha256 "9b30561454529e5923ffb62327d3fe009d23495263efc958534ac6b637e361d6"
version "0.3.3"
bottle do
cellar :any
sha256 "... | 31.625 | 95 | 0.727273 |
187dffdcd98067cb8b10cb0fba5e497ad451def7 | 10,965 | # encoding: utf-8
require "logstash/inputs/base"
require 'logstash/plugin_mixins/http_client'
require 'logstash/event'
require 'logstash/json'
require "stud/interval"
require "socket" # for Socket.gethostname
require "rufus/scheduler"
require "json"
require "ostruct"
# DISCLAIMER: Functions for this plugin are made p... | 33.027108 | 173 | 0.619061 |
ff760a652e769c70687b98955eee9ccd0fc62445 | 917 | Pod::Spec.new do |s|
s.name = 'CNIconLabel'
s.version = '1.0.2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.homepage = 'https://github.com/congni/CNIconLabel-OC.git'
s.authors = { "葱泥" => "983818495@qq.com" }
s.summary = 'OC图标按钮控件'
s.description = <<-DESC
... | 41.681818 | 102 | 0.536532 |
f7dfe8f772bcd22e5df09751d8bdaa6014f9bca1 | 1,621 | require 'addressable/uri'
module OAuth2::Provider::Rack::Responses
def self.unauthorized(error = nil)
challenge = "OAuth2"
challenge << %{ error="#{error}"} if error
[401, {'Content-Type' => 'text/plain', 'Content-Length' => '0', 'WWW-Authenticate' => challenge}, []]
end
def self.only_supported(supp... | 31.784314 | 127 | 0.673041 |
5de9ace9635772ac9ee916397283f3962b322722 | 339 | class CreateAgentRevisions < ActiveRecord::Migration
def change
create_table :agent_revisions do |t|
t.integer :agent_code
t.date :date_start
t.date :date_end
t.integer :status
t.string :data_file
t.timestamps
end
add_index :agent_revisions, [:date_start, :date_end] #... | 19.941176 | 65 | 0.669617 |
f8eaab9a671c6fa1921275eadda69de6bd49ba75 | 332 | class CreateDevices < ActiveRecord::Migration
def change
create_table :devices do |t|
t.string :device_ip
t.references :scenario, index: true
t.timestamps null: false
end
add_foreign_key :devices, :scenarios
add_column :devices, :isReportRequired, "enum('yes','no')", :default => 'no... | 25.538462 | 80 | 0.677711 |
611a2fa88dac54a4b308f51d9280c16b09a98290 | 10,567 | # -*- encoding: utf-8 -*-
#
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
#
# Copyright (C) 2012, Fletcher Nichol
#
# 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.o... | 25.836186 | 79 | 0.613325 |
26188caf113125b4028ce2ce9965d638d9466cfb | 1,791 |
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "tour/version"
Gem::Specification.new do |spec|
spec.name = "tour"
spec.version = Tour::VERSION
spec.authors = ["'Stela Capsa'"]
spec.email = ["'stela.capsa@gmail.com'"]
s... | 42.642857 | 96 | 0.670017 |
18142b492cdeb811c1626da2f6e417d4e9164d68 | 2,871 | class Sbcl < Formula
desc "Steel Bank Common Lisp system"
homepage "http://www.sbcl.org/"
url "https://downloads.sourceforge.net/project/sbcl/sbcl/2.0.10/sbcl-2.0.10-source.tar.bz2"
sha256 "51754110b6c54dcd3857a213d6113628a89b4d43348cfd38c1fac373927a0557"
license all_of: [:public_domain, "MIT", "Xerox", "BSD-... | 34.590361 | 111 | 0.669453 |
e97264a862ff35768ac45a36b41bce36ac68bed8 | 4,651 | require 'parser/current'
module Solargraph
module Parser
module Legacy
module ClassMethods
# @param code [String]
# @param filename [String]
# @return [Array(Parser::AST::Node, Array<Parser::Source::Comment>)]
def parse_with_comments code, filename = nil
... | 32.985816 | 104 | 0.536659 |
1de7f98476713bef0c0ec96135fc33723e0ae68e | 5,429 | require 'addressable/uri'
module Koala
module Facebook
class API
# A light wrapper for collections returned from the Graph API.
# It extends Array to allow you to page backward and forward through
# result sets, and providing easy access to paging information.
class GraphCollection < Arra... | 42.085271 | 171 | 0.63345 |
acb02df56aa8f07d58c447a677cda2b268c5f43a | 704 | # frozen_string_literal: true
Synvert::Rewriter.new 'rspec', 'stub_and_mock_to_double' do
description <<~EOS
It converts stub and mock to double.
```ruby
stub('something')
mock('something')
```
=>
```ruby
double('something')
double('something')
```
EOS
if_gem 'rspec-co... | 20.705882 | 61 | 0.620739 |
ab8cc1993f5ad7f1b12579eb7b917dd67f192bab | 266 | class Hr::EmployeePosition < ApplicationRecord
validates_presence_of :name, :employee_category_id
validates_uniqueness_of :name,:scope=>:employee_category_id
scope :active, -> { where(:status => true) }
belongs_to :employee_category
has_many :employee
end
| 33.25 | 61 | 0.785714 |
1a4a33e15a0bdac13bdc4d28b2644b6682b45cd3 | 4,374 | #
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Christopher Brown (<cb@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You... | 29.554054 | 112 | 0.683128 |
4aa98db3e0236a4e239878dec114cd6eea00c409 | 421 | require 'formula'
class Rnv < Formula
homepage 'http://freshmeat.net/projects/rnv'
url 'http://downloads.sourceforge.net/project/rnv/Sources/1.7.11/rnv-1.7.11.tar.bz2'
sha1 '1a4475cbb6ff6da9e98cd8cceae7356e9a9f72b4'
depends_on 'expat'
def install
system "./configure", "--disable-debug", "--disable-depe... | 26.3125 | 86 | 0.674584 |
614ed6424493da3f65be2443e322f32997a08cc1 | 6,498 | # frozen_string_literal: true
require 'test_helper'
class ComparesControllerTest < ActionController::TestCase
# projects
test 'should render with no projects passed in' do
get :projects
assert_response :success
assert_select 'input#project_0', 1
assert_select 'input#project_1', 1
assert_select... | 42.470588 | 109 | 0.719606 |
bf2434e812fe8017dc49e116786d73e166e54563 | 14,126 | =begin
#NSX-T Data Center Policy API
#VMware NSX-T Data Center Policy REST API
OpenAPI spec version: 3.1.0.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.19
=end
require 'date'
module NSXTPolicy
# Child wrapper for TraceflowConfig, used in hierarchical API
cl... | 34.965347 | 508 | 0.644485 |
4aaee8f8d817ac1c7917586bbbaa513993236bcf | 2,551 | require 'one_gadget/gadget'
# https://gitlab.com/libcdb/libcdb/blob/master/libc/libc0.1-i386-2.24-0experimental1/lib32/libc-2.24.so
#
# Intel 80386
#
# GNU C Library (Debian GLIBC 2.24-0experimental1) stable release version 2.24, by Roland McGrath et al.
# Copyright (C) 2016 Free Software Foundation, Inc.
# This is f... | 54.276596 | 150 | 0.589573 |
0397a1b5f3b82e326616ad7510704062665a64c7 | 127 | class Message < ApplicationRecord
enum message_type: {
message: 1,
callback_query: 2
}, _prefix: :message_type
end
| 18.142857 | 33 | 0.708661 |
115ffef8de5970a423d347992927db22c18ef5d8 | 478 | class User < ApplicationRecord
belongs_to :department
has_many :tasks
has_many :user_projects
has_many :projects, through: :user_projects
has_one :project, foreign_key: 'creator_id'
has_many :messages_sent, class_name: "Message", foreign_key: "sender_id"
has_many :messages_received, c... | 25.157895 | 82 | 0.73431 |
d53732587848f05b66435ed14313096d1b4a1a62 | 532 | class CreateContainerGroups < ActiveRecord::Migration[4.2]
def up
create_table :container_groups do |t|
t.string :ems_ref
t.string :name
t.timestamp :creation_timestamp
t.string :namespace
t.string :resource_version
t.string :restart_policy
t.string ... | 24.181818 | 58 | 0.656015 |
f717531a237b07238b3c907d391f4101803e5365 | 2,580 | # snippet-comment:[These are tags for the AWS doc team's sample catalog. Do not remove.]
# snippet-sourceauthor:[Doug-AWS]
# snippet-sourcedescription:[Give public read access to an S3 bucket and item.]
# snippet-keyword:[Amazon Simple Storage Service]
# snippet-keyword:[get_bucket_acl method]
# snippet-keyword:[put_bu... | 33.076923 | 88 | 0.734109 |
bf016fbb27e802d801c136061818700983e21d88 | 810 | require "test_helper"
describe "Fog::Network[:telefonica] | subnet" do
describe "success" do
before do
@instance = network.subnets.create(
:name => 'subnet_name',
:network_id => 'net_id',
:cidr => '10.2.2.0/24',
:ip_version => 4,
:... | 23.823529 | 56 | 0.517284 |
1df5d946d3b2538e3f6245461d9db17133bbc601 | 304 | require 'spec_helper'
describe "Class variables" do
it "should always be returned as s(:cvar)" do
opal_parse("@@foo").should == [:cvar, :@@foo]
end
it "should always be converted to s(:cvdecl) on assignment" do
opal_parse("@@foo = 100").should == [:cvdecl, :@@foo, [:int, 100]]
end
end
| 25.333333 | 70 | 0.641447 |
e987cfddaf566f07da1ca59bb910ad04e68054e6 | 892 | require 'thread'
require 'socket'
module Aws
module ClientSideMonitoring
# @api private
class Publisher
attr_reader :agent_port
def initialize(opts = {})
@agent_port = opts[:agent_port]
@mutex = Mutex.new
end
def agent_port=(value)
@mutex.synchronize do
... | 21.238095 | 59 | 0.580717 |
01ad45fc57c6d531dd50ed6ebc8229bdea474423 | 960 | # encoding: UTF-8
# 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.
#
# Note that this schema.rb definition is the authoritative sou... | 41.73913 | 86 | 0.765625 |
bf0616cb6786c902ac3eab6ad2f6b00d38f4d055 | 436 | class Friendship < ApplicationRecord
belongs_to :user
belongs_to :friend, :class_name => "User"
def self.connections_with(user)
connections = self.where(user_id: user.id) + self.where(friend_id: user.id)
end
def friend_of(current_user)
self.user == current_user ? self.friend : self.user
end
de... | 22.947368 | 79 | 0.727064 |
1164528fcdee71586314f58d947dad4a231963cf | 1,079 | require 'rails_helper'
describe Abstractor::AbstractorSubjectGroup do
let!(:abstractor_subject_group) { FactoryGirl.create(:abstractor_subject_group) }
it "is valid with valid attributes", focus: false do
expect(abstractor_subject_group).to be_valid
r = Abstractor::AbstractorSubjectGroup.new(cardinality: 5... | 39.962963 | 93 | 0.765524 |
91127e9edd0e81c3f370a4de96c9b552a20f88f1 | 1,016 | class <%= class_name %> < ActiveRecord::Base
# Default validations:
exclude_validations = %w{id created_at updated_at}
columns.each do |column|
unless exclude_validations.include?(column.name)
validates_presence_of column.name unless column.null
validates_numericality_of column.name, :allow_blank... | 46.181818 | 257 | 0.673228 |
7ae79e04fe7fd01077c89361ff4a5f271b1f38de | 2,476 | # frozen_string_literal: true
module RuboCop
module Cop
module Lint
# This cop checks for interpolated literals.
#
# @example
#
# # bad
#
# "result is #{10}"
#
# @example
#
# # good
#
# "result is 10"
class LiteralInInter... | 26.913043 | 79 | 0.565024 |
01d6f1bebc0c97f140671d17ae281171138b196c | 158 | class AddCustomerToOrders < ActiveRecord::Migration
def change
add_column :orders, :customer_id, :integer
add_index :orders, :customer_id
end
end
| 22.571429 | 51 | 0.759494 |
b9e517c3a7c0b5cbdb5870671738fe11a41db102 | 1,154 | #
# Copyright:: 2019, Chef Software, 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 ... | 32.971429 | 110 | 0.728769 |
623631d7bc8bd361e40b5a836eab1b761cdac3b8 | 125 | require "test_helper"
class MezosoicEraTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
| 15.625 | 47 | 0.712 |
bb39fbf65fc4815be13ccdf83f5347e7bc1de1ae | 1,683 | require 'yaml'
module Oct
class Settings
def initialize(working_dir, options={})
@working_dir = working_dir
@options = options
configure
end
def options
@options
end
private
# read options from YAML config
def configure
# config file default options
... | 27.590164 | 111 | 0.567439 |
eda5ed8f58ba65765586cdb8b39caa40f2568143 | 21,958 | require 'puppet/node'
require 'puppet/indirector'
require 'puppet/simple_graph'
require 'puppet/transaction'
require 'puppet/util/pson'
require 'puppet/util/tagging'
# This class models a node catalog. It is the thing
# meant to be passed from server to client, and it contains all
# of the information in the catalo... | 33.169184 | 151 | 0.678796 |
1808ee9d23c819fd7078421b9058c1c85b17761f | 3,371 | # encoding: utf-8
# frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in
# config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your ap... | 38.306818 | 79 | 0.760012 |
38bb85478876043094415a500fdf450dbce8dff0 | 7,177 | =begin
#RDA Collections API
#The RDA Collections API Recommendation is a unified model and interface specification for CRUD operations on data collections, with particular observance of persistent identification and typing aspects. The recommendation allows building collections within diverse domains and then sharing ... | 32.040179 | 328 | 0.651247 |
6a510af59b56e71dd0a0cb2d59c95b6df9f82f39 | 607 | # 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::MediaServices::Mgmt::V2018_03_30_preview
module Models
#
# Defines values for EncoderNamedPreset
#
module EncoderNamedPreset... | 30.35 | 70 | 0.756178 |
1ac0ecf2e649d03a6cfbdd1f5067c59a6cf74838 | 2,848 | # frozen_string_literal: true
module Geo
class RepositoryVerificationSecondaryService < BaseRepositoryVerificationService
def initialize(registry, type)
@registry = registry
@type = type.to_sym
end
def execute
return unless Gitlab::Geo.geo_database_configured?
return unless G... | 28.48 | 119 | 0.674157 |
ed61cccac018eab0d70036ff86da8c81c7de0b6a | 153 | a = Array.new(42){rand(42)-21}
v=[]
0.upto(b=a.size-1){|i|i.upto(b){|j|v<<a[i..j]}}
p v.inject([a.max]){|z,m|z.inject{|s,i|s+i}>m.inject{|s,i|s+i}?z:m}
| 25.5 | 67 | 0.535948 |
18b75d1e4a105e4e13823cadc90fc5f3fb1d713b | 4,437 | class Api::V10::PopulationController < ApplicationController
def population
@title = 'Population'
population_json = File.read("storage/#{ENV['place_code']}/population/population.json")
@population = JSON.parse(population_json)
respond_to do |format|
format.j... | 41.083333 | 138 | 0.529863 |
031fb8ca37f9398ea51a15986bfddce9f0f344f5 | 2,747 | module Virtus
# Extensions common for both classes and instances
module Extensions
WRITER_METHOD_REGEXP = /=\z/.freeze
INVALID_WRITER_METHODS = %w[ == != === []= attributes= ].to_set.freeze
RESERVED_NAMES = [:attributes].to_set.freeze
# A hook called when an object is extended with Virtu... | 25.915094 | 87 | 0.583546 |
f79112d71a49ca8c0430f1721c837a3fef39b460 | 1,139 | # -*- encoding: utf-8 -*-
# stub: jekyll-theme-leap-day 0.1.0 ruby lib
Gem::Specification.new do |s|
s.name = "jekyll-theme-leap-day".freeze
s.version = "0.1.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.a... | 35.59375 | 112 | 0.684811 |
7a8cb54fa1d6894d41fec1378add5482a68b18d3 | 306 | require 'twitter/base'
module Twitter
class Trend < Twitter::Base
lazy_attr_reader :events, :name, :promoted_content, :query, :url
# @param other [Twitter::Trend]
# @return [Boolean]
def ==(other)
super || (other.class == self.class && other.name == self.name)
end
end
end
| 20.4 | 69 | 0.637255 |
1ad4ce0d164d0df3dff9c68b7c08bc8a938985e0 | 86 | FactoryBot.define do
factory :tagging do
post { nil }
tag { nil }
end
end
| 12.285714 | 21 | 0.616279 |
7a1c89b1c0314286e17d1abfa0d0011f2edca64e | 63 | class Function < ActiveRecord::Base
has_one :personality
end
| 15.75 | 35 | 0.793651 |
1d9425cd220cdd0b5b1d115cf83b221df20e3d6d | 1,544 | require 'test_helper'
class UsersLoginTest < ActionDispatch::IntegrationTest
def setup
@user = users(:michael)
end
test "Login with invalid information" do
get login_path
assert_template 'sessions/new'
post login_path, params: { session: { email: "", password: "" } }
assert_template "sessio... | 28.072727 | 86 | 0.702073 |
ed43210cdb3dfd59a1075fa60acb7ce341f4e160 | 8,403 | #-- 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 ... | 34.158537 | 114 | 0.675592 |
7a269d466f82104cd56737c371db9a1cd9584824 | 1,688 | # frozen_string_literal: true
# Mechanize - A Monkeypatch for the mechanize progressbar
class Mechanize
include MechanizeProgressBarAPI # (1of7)a
class HTTP
# Agent - A Monkeypatch for the mechanize progressbar
class Agent
def response_read(response, request, _uri = nil)
body_io = StringIO.ne... | 34.44898 | 120 | 0.626777 |
ffcb2a6ea2ba2d1583a415c846a36954a3c8ba72 | 317 | require_relative "load_libs"
load_libs(use = ARGV[1])
a = Numo::DFloat.new(1000,1000).seq
b = Numo::DFloat.eye(1000)
n = 10
rep = ARGV[0].to_i
cap = ARGV[2]=="cap" ? Benchmark::CAPTION : ""
Benchmark.benchmark(cap,16) do |x|
rep.times do
x.report(use){ n.times{ Numo::Linalg::Lapack.dgels(a,b) } }
end
end
| 19.8125 | 63 | 0.656151 |
5d13e1a30969464122d4628172a109cb7e6d6198 | 9,233 | require File.expand_path(File.join(File.dirname(__FILE__), 'whiskey_disk', 'config'))
class WhiskeyDisk
attr_writer :configuration, :config
attr_reader :results
def initialize(options = {})
@staleness_checks = true if options[:staleness_checks]
end
def buffer
@buffer ||= []
end
def confi... | 28.496914 | 148 | 0.644753 |
ffafdcbd9d2234955d32519374b6b6422a504498 | 248 | class AddSortOrderToUserOrganizationFilters < ActiveRecord::Migration
def change
if ActiveRecord::Base.connection.table_exists?(:user_organization_filters)
add_column :user_organization_filters, :sort_order, :integer
end
end
end
| 31 | 78 | 0.798387 |
0855d868f94e7611a7ea34e69a5a28d025ec08b5 | 2,489 | require 'spec_helper'
shared_examples_for "a simp_apache class" do
it { is_expected.to compile.with_all_deps }
it { is_expected.to create_class('simp_apache') }
it { is_expected.to create_class('simp_apache::install') }
it { is_expected.to create_class('simp_apache::conf') }
# it { is_expected.to contain_file... | 40.803279 | 92 | 0.660908 |
2818617c3f3da6528277ff2f9e917ec5b8308286 | 2,148 | # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/cloud/datacatalog/v1/table_spec.proto
require 'google/api/field_behavior_pb'
require 'google/api/resource_pb'
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_file("google/cloud/datacatalog/v1/table_spe... | 42.96 | 154 | 0.744413 |
ac2154add2eaaefdab0683e26f661e779abfa710 | 740 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe JabberAdmin::Commands::SendStanzaC2s do
it_behaves_like 'a command',
with_name: 'send_stanza_c2s',
with_input_args: [
user: 'admin@ejabberd.local/bot',
stanza: '<message to=... | 35.238095 | 78 | 0.47973 |
f85b1ea828d8ec084512b4cdc4ec6c5cd1f86cb0 | 1,863 | module Locomotive
class SitePolicy < ApplicationPolicy
class Scope < ApplicationPolicy::Scope
def resolve
if membership.account.super_admin?
scope.all
else
membership.account.sites
end
end
end
def index?
true
end
def show?
tr... | 22.719512 | 192 | 0.63285 |
38af29b1021291a2c7b7773d318562177c2257c1 | 382 | class ConfirmingUserFormPresenter < ConfirmingFormPresenter
def full_name_block(name1, name2, label_text, options = {})
markup(:div, class: "input-block") do |m|
m << decorated_label(name1, label_text)
m.div(object.send(name1) + " " + object.send(name2),
class: "field-value")
m << hidden... | 34.727273 | 61 | 0.659686 |
338c1f192da91637e98c511d29b85fac319822d4 | 560 | # frozen_string_literal: true
module RuboCop
module Cop
module Metrics
# This cop checks if the length a class exceeds some maximum value.
# Comment lines can optionally be ignored.
# The maximum allowed length is configurable.
class ClassLength < Cop
include ClassishLength
... | 22.4 | 73 | 0.633929 |
62322f6fc659fe6472b54eb5bb40b542250d249e | 2,450 | module Frontapp
class Client
module Channels
def channels(params = {})
list("channels", params)
end
# Parameters
# Name Type Description
# -------------------------------
# channel_id string Id of the requested channel
# -----------------------------... | 36.029412 | 125 | 0.448163 |
bff133bce2e3c653df4aa9c98f60f62a6eedd54e | 1,646 | module Spree
Order.class_eval do
# Se re-define cuales son pagos pendientes
def pending_payments
payments.select{ |payment| payment.checkout? or payment.completed? }
end
# Step only visible when payment failure
insert_checkout_step :webpay_ws, :after => :payment, if: Proc.new {|order| orde... | 31.056604 | 164 | 0.707776 |
1cbe21089a3c681a7972897572c3d7b7cb8d04c4 | 3,807 | module Neo4j
module Transaction
extend self
module Instance
# @private
def register_instance
@pushed_nested = 0
Neo4j::Transaction.register(self)
end
# Marks this transaction as failed, which means that it will unconditionally be rolled back when close() is called. Al... | 26.255172 | 150 | 0.639874 |
26ae541739a001a08b5f1668eefdf1f92d5f4e0a | 539 | class UsersController < ApplicationController
def new
@user = User.new
end
def show
@user = User.find(params[:id])
@time = Time.now
end
def create
@user = User.new(user_params)
if @user.save # if this returns true, means that it is valid
log_in @user
flash[:success] = "Welcom... | 19.25 | 84 | 0.638219 |
e8a1722fec540977e345977198499b80e23f9487 | 1,028 | require 'spec_helper_acceptance'
# Ensure SELinux is not disabled in bootloader configuration - Section 1.6.1.1
describe file('/etc/default/grub') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 644 }
its(:content) { should match /G... | 33.16129 | 78 | 0.703307 |
210667eb69a52bc0cb774316892fb563d929ea47 | 589 | require 'spec_helper'
describe 'infinality' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
it { should compile.with_all_deps }
it { should contain_class('infinality') }
it { should contain_class('infinality::install') }
end
end
... | 19.633333 | 71 | 0.617997 |
d5448b01d8e6fcbc19bb5a035081dbe0f8ebe7d8 | 217 | # Copyright (c) 2015 Vault12, Inc.
# MIT License https://opensource.org/licenses/MIT
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
| 36.166667 | 69 | 0.718894 |
9169aa23bc1905e9a7e61119ef37af0306fa6426 | 660 | require 'spec_helper'
EVENT_ID = 9099588
module Stubhub
module LCS
describe Event do
before :each do
VCR.insert_cassette 'event' do
end
end
after :each do
VCR.eject_cassette
end
context ".find_by_event_id" do
it "finds find the event with event id #{... | 21.290323 | 62 | 0.586364 |
3838010f28a03e6dbf0961f0bd7dc9d6ba28e9e4 | 3,797 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... | 41.271739 | 102 | 0.757703 |
e99b88390926b124948e1e122ec884e5313a06bd | 789 | module ScopingHelpers
extend ActiveSupport::Concern
private
def scoped_submissions(tutorial_group, submissions)
scoped_submissions = submissions.order(submitted_at: :desc)
case params[:submission_scope]
when 'unmatched'
scoped_submissions.unmatched
when 'all'
scoped_submissions
... | 25.451613 | 140 | 0.741445 |
1c72fbdd14ee1e08fd4d2037f189504d9158bb5d | 558 | cask 'eclipse-jee' do
version '4.6.1,neon:1a'
sha256 'c64da846dfb762ce6650e4d842c566a61836b14c0a77b1f5395f4f9842a66aad'
url "https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/#{version.after_comma.before_colon}/#{version.after_colon}/eclipse-jee-#{version.after_comma.before_co... | 32.823529 | 254 | 0.765233 |
03406d7c4ad2f56f266aa12912729a8646480756 | 198 | class UserDropColumnProfilePictureUrl < ActiveRecord::Migration
def up
remove_column :users, :profile_picture_url
end
def down
add_column :users, :profile_picture_url, :text
end
end
| 22 | 63 | 0.772727 |
18d111f655615aa5227c72fdf89b86d68991aa1a | 445 | # frozen_string_literal: true
module API
module Validations
module Types
class WorkhorseFile < Virtus::Attribute
def coerce(input)
# Processing of multipart file objects
# is already taken care of by Gitlab::Middleware::Multipart.
# Nothing to do here.
input
... | 21.190476 | 70 | 0.602247 |
b96569f341af84cd6497e789af09036a76c32001 | 257 | 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 hello
render text: "hello, world!"
end
end
| 25.7 | 56 | 0.747082 |
793c81a23773fae4c406096aabe6ef97cf2df683 | 358 | # encoding: UTF-8
module Vines
class Stream
class Server
class Outbound
class Start < State
def initialize(stream, success=TLS)
super
end
def node(node)
raise StreamErrors::NotAuthorized unless stream?(node)
advance
end
... | 17.047619 | 66 | 0.536313 |
e90fdba585b39c04fb0df0d8987c6428c94861c3 | 575 | require 'mspec/runner/actions/filter'
class DebugAction < ActionFilter
def initialize(tags=nil, descs=nil)
super
if defined?(RUBY_ENGINE) and RUBY_ENGINE == "rbx"
require 'debugger'
@use_rubinius = true
else
@use_rubinius = false
end
end
def before(state)
if self === state... | 16.428571 | 53 | 0.638261 |
acd919de0683100f62d9c4be5699777410ca396a | 1,340 | #
# Be sure to run `pod lib lint HSBStoryboardInitializable.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 ... | 39.411765 | 117 | 0.66194 |
b94dbc13a12e509fe7e2f38aa3b7883fa07d08d6 | 5,828 | =begin
#Kubernetes
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v1.8.3
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.2.3
=end
require 'date'
module Kubernetes
# HTTPHeader describes a cu... | 27.752381 | 107 | 0.613761 |
8757729935273c218269e330674af570f2d7acd7 | 914 | require 'yutani'
describe Yutani::Hiera do
before do
Yutani::Hiera.hiera('hiera_config_file' => 'spec/hiera.yaml')
Yutani.scope(a: 1, b: 2) do |s|
Yutani.scope(c: 3, d: 4) do |s|
@scope = Yutani::Hiera.scope
@scope_values = s.values
end
end
end
it "should instantiate h... | 22.292683 | 65 | 0.612691 |
bf99cdf5b2811d66e4aa8ab79963fa471d994a3f | 4,402 | ENV["RAILS_ENV"] ||= "test"
ENV['PROJECT_CREATED_NOTIFY_ADDRESS'] = 'blah@example.com'
if ENV['CODECLIMATE_REPO_TOKEN']
require 'codeclimate-test-reporter'
CodeClimate::TestReporter.start
elsif ENV['COVERAGE']
require 'simplecov'
SimpleCov.start 'rails'
end
require_relative '../config/environment'
require 'r... | 26.359281 | 141 | 0.700591 |
219fb0105b554e9a855264bc80c06e1d4a17cb0e | 5,634 | # frozen_string_literal: true
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to expl... | 39.125 | 93 | 0.742279 |
611c0bf6fbec03fb635bd7c0007a2046f8908212 | 854 | #
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint scan.podspec' to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'scan'
s.version = '0.0.1'
s.summary = 'A new flutter plugin project.'
s.description = <<-DES... | 35.583333 | 105 | 0.579625 |
7a47ebd44bcfb96f0b10d936722705e8bbcecff0 | 2,307 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... | 36.046875 | 86 | 0.764196 |
269e876cfacff289c0fd6b9505694eb4d26b111a | 466 | # frozen_string_literal: true
require_relative '../command'
class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
def self.build(extension, dest_path, results, args=[], lib_dir=nil, cmake_dir=Dir.pwd)
unless File.exist?(File.join(cmake_dir, 'Makefile'))
cmd = ["cmake", ".", "-DCMAKE_INSTALL_PREFIX=#{dest_path}"... | 27.411765 | 91 | 0.697425 |
87b637b2048d274fcba6f7f43e7d52be45e50904 | 735 | class User < ActiveRecord::Base
attr_accessible :name
scope :tall, lambda {|*args| where("height > '#{User.average_height}'") }
scope :blah, where("thinger = '#{BLAH}'") #No longer warns on constants
scope :dah, lambda {|*args| { :conditions => "dah = '#{args[1]}'"}}
scope :phooey, :conditions => "phoee... | 25.344828 | 75 | 0.62585 |
e977a5603f4540cbb4e9d36c8ea81dc62600b0cf | 2,549 | module Engine
# Sprite objects are the different moving elements of the game. For example, a
# space ship, an enemy, a bullet, etc.
#
# Custom sprite classes should inherit from this one.
class Sprite
attr_reader :x, :y, :z, :image, :blend_mode, :alpha, :angle, :radius, :size
# Constructor. Note... | 25.237624 | 97 | 0.550804 |
62bf91fe88a4545770fe657db4c67d2c6fac58e2 | 2,586 |
require 'faraday'
require 'faraday_middleware'
require 'synowebapi/api'
module SYNOWebAPI
class Client
attr_reader :url, :api, :session_id, :session_name
def initialize(url)
@url = url
@session_id = @session_name = ''
@conn = Faraday.new(:url => @url) do |f|
f.request(:url_encoded... | 25.352941 | 85 | 0.567672 |
5d3f9b12640ac3422836774615a202ff5523a5e2 | 308 | class Texturepacker < Cask
version '3.3.1'
sha256 '00f922d036bd7ec991bbe5ee5fcad1431c3c4884bc2b371fdff92cecdaa11339'
url "https://www.codeandweb.com/download/texturepacker/#{version}/TexturePacker-#{version}-uni.dmg"
homepage 'http://www.codeandweb.com/texturepacker'
app 'TexturePacker.app'
end
| 30.8 | 101 | 0.788961 |
18ff52ed15f214bc279adc7efea3c2e08a8d3bc9 | 2,516 | require 'spec_helper'
describe "SQL statements /" do
before(:all) do
plsql.connect! CONNECTION_PARAMS
plsql.connection.autocommit = false
end
after(:all) do
plsql.logoff
end
after(:each) do
plsql.rollback
end
describe "SELECT" do
before(:all) do
plsql.execute "DROP TABLE test... | 27.347826 | 98 | 0.63434 |
1aaffb7a200cf1329badb2b27f844ef6231966fa | 670 | # frozen_string_literal: true
module GoogleAssistant
class Argument
attr_reader :name, :raw_text, :text_value
def self.from(opts)
case opts["name"]
when "permission_granted"
PermissionArgument.new(opts)
when "text"
TextArgument.new(opts)
else
Argument.new(opts... | 18.611111 | 45 | 0.637313 |
e93282963cda1ccc74d08c03a189da853f57f697 | 136 | Rails.application.config.middleware.use OmniAuth::Builder do
provider :yahoo_auth, ENV['YAHOO_CLIENT_ID'], ENV['YAHOO_APP_SECRET']
end | 45.333333 | 71 | 0.808824 |
7a15bfb21f01f57f54f04b7e215efecc606d1dbb | 5,769 | # An object that collects stored objects from the central cache and returns
# them to the current host, yo.
class Puppet::Parser::Collector
attr_accessor :type, :scope, :vquery, :equery, :form
attr_accessor :resources, :overrides, :collected
# Call the collection method, mark all of the returned objects as
# n... | 32.410112 | 119 | 0.656093 |
1adc81db8d4d956677c50cd1c73fdfb295bbd77d | 339 | require 'rubygems'
# Set up gems listed in the parent Gemfile.
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if F... | 24.214286 | 59 | 0.710914 |
38ba4dbfb60f8f25a7185057bef1f916a8413921 | 3,128 | # The MIT License (MIT)
# Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc.
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the r... | 40.102564 | 110 | 0.659847 |
4a20a340e0e11883e9b48cf8e7d05dba8af33cd5 | 905 | Pod::Spec.new do |spec|
spec.name = "OrderedCollections"
spec.version = "1.0.2"
spec.summary = "Swift Collections is an open-source package of data structure implementations for the Swift programming language."
spec.description = <<-DESC
Swift Collections is an open-source package of data structure implement... | 41.136364 | 132 | 0.702762 |
fffcd143ca3a7b6c6c421de75093a2d6cd3432b6 | 4,268 | # coding: UTF-8
require "spec_helper"
require "json"
require "rack/test"
require "dea/directory_server/directory_server_v2"
require "dea/staging/staging_task"
require "dea/staging/staging_task_registry"
describe Dea::DirectoryServerV2::StagingTasks do
include Rack::Test::Methods
include_context "tmpdir"
let(... | 32.830769 | 131 | 0.657685 |
3951273936b1b52151415d11003cea6646959e58 | 1,870 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::DastProfilesController, type: :request do
let(:project) { create(:project) }
let(:user) { create(:user) }
describe 'GET #index' do
context 'feature available' do
before do
stub_feature_flags(security_on_demand_scans_... | 25.27027 | 74 | 0.651872 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.