_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 30 4.3k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q23400 | JGrep.Scanner.get_token | train | def get_token
return nil if @token_index >= @arguments.size
begin
case chr(@arguments[@token_index])
when "["
return "statement", gen_substatement
when "]"
return "]"
when "("
return "(", "("
when ")"
return ")", ")"
... | ruby | {
"resource": ""
} |
q23401 | ArgParser.Definition.<< | train | def <<(arg)
case arg
when PositionalArgument, KeywordArgument, FlagArgument, RestArgument
if @arguments[arg.key]
raise ArgumentError, "An argument with key '#{arg.key}' has already been defined"
end
if arg.short_key && @short_ke... | ruby | {
"resource": ""
} |
q23402 | ArgParser.Definition.positional_arg | train | def positional_arg(key, desc, opts = {}, &block)
| ruby | {
"resource": ""
} |
q23403 | ArgParser.Definition.keyword_arg | train | def keyword_arg(key, desc, opts = {}, &block)
| ruby | {
"resource": ""
} |
q23404 | ArgParser.Definition.flag_arg | train | def flag_arg(key, desc, opts = {}, &block)
| ruby | {
"resource": ""
} |
q23405 | ArgParser.Definition.rest_arg | train | def rest_arg(key, desc, opts = {}, &block)
| ruby | {
"resource": ""
} |
q23406 | ArgParser.Definition.validate_requirements | train | def validate_requirements(args)
errors = []
@require_set.each do |req, sets|
sets.each do |set|
count = set.count{ |arg| args.has_key?(arg.key) && args[arg.key] }
case req
when :one
if count == 0
... | ruby | {
"resource": ""
} |
q23407 | ArgParser.Definition.show_usage | train | def show_usage(out = STDERR, width = 80)
lines = ['']
pos_args = positional_args
opt_args = size - pos_args.size
usage_args = pos_args.map(&:to_use)
usage_args << (requires_some? ? 'OPTIONS' : '[OPTIONS]') if opt_args > 0
usage_args << rest_args.to... | ruby | {
"resource": ""
} |
q23408 | ArgParser.Definition.show_help | train | def show_help(out = STDOUT, width = 80)
lines = ['', '']
lines << title
lines << title.gsub(/./, '=')
lines << ''
if purpose
lines.concat(wrap_text(purpose, width))
lines << ''
end
if copyright
... | ruby | {
"resource": ""
} |
q23409 | ArgParser.Definition.wrap_text | train | def wrap_text(text, width)
if width > 0 && (text.length > width || text.index("\n"))
lines = []
start, nl_pos, ws_pos, wb_pos, end_pos = 0, 0, 0, 0, text.rindex(/[^\s]/)
while start < end_pos
last_start = start
nl_pos = ... | ruby | {
"resource": ""
} |
q23410 | ArgParser.Parser.parse | train | def parse(tokens = ARGV)
@show_usage = nil
@show_help = nil
@errors = []
begin
pos_vals, kw_vals, rest_vals = classify_tokens(tokens)
args = process_args(pos_vals, kw_vals, rest_vals) unless @show_help
rescue | ruby | {
"resource": ""
} |
q23411 | ArgParser.Parser.process_arg_val | train | def process_arg_val(arg, val, hsh, is_default = false)
if is_default && arg.required? && (val.nil? || val.empty?)
self.errors << "No value was specified for required argument '#{arg}'"
return
end
if !is_default && val.nil? && KeywordArgument === arg
... | ruby | {
"resource": ""
} |
q23412 | Postcodes.Base.method_missing | train | def method_missing(name, *args, &block)
return @info[name.to_s] if @info.key? name.to_s
return | ruby | {
"resource": ""
} |
q23413 | Resque.JRubyWorker.prune_dead_workers | train | def prune_dead_workers
all_workers = self.class.all
return if all_workers.empty?
known_workers = JRUBY ? worker_thread_ids : []
pids = nil, hostname = self.hostname
all_workers.each do |worker|
host, pid, thread, queues = self.class.split_id(worker.id)
next if host != hostn... | ruby | {
"resource": ""
} |
q23414 | Resque.JRubyWorker.worker_thread_ids | train | def worker_thread_ids
thread_group = java.lang.Thread.currentThread.getThreadGroup
threads = java.lang.reflect.Array.newInstance(
java.lang.Thread.java_class, thread_group.activeCount)
thread_group.enumerate(threads)
# NOTE: we shall check the name from $servlet_context.getServletContext... | ruby | {
"resource": ""
} |
q23415 | Resque.JRubyWorker.update_native_thread_name | train | def update_native_thread_name
thread = JRuby.reference(Thread.current)
set_thread_name = Proc.new do |prefix, suffix|
self.class.with_global_lock do
count = self.class.system_registered_workers.size
thread.native_thread.name = "#{prefix}##{count}#{suffix}"
end
end
... | ruby | {
"resource": ""
} |
q23416 | Resque.JRubyWorker.system_unregister_worker | train | def system_unregister_worker # :nodoc
self.class.with_global_lock do
workers = self.class.system_registered_workers
| ruby | {
"resource": ""
} |
q23417 | Ngannotate.ProcessorCommon.parse_ngannotate_options | train | def parse_ngannotate_options
opt = config.options.clone
if ENV['NG_OPT']
opt_str = ENV['NG_OPT']
if opt_str
opt = Hash[opt_str.split(',').map { |e| e.split('=') }]
| ruby | {
"resource": ""
} |
q23418 | Spiceweasel.Knife.validate | train | def validate(command, allknifes)
return if allknifes.index { |x| x.start_with?("knife #{command}") }
| ruby | {
"resource": ""
} |
q23419 | Guacamole.DocumentModelMapper.document_to_model | train | def document_to_model(document)
identity_map.retrieve_or_store model_class, document.key do
model = model_class.new(document.to_h)
model.key = document.key
| ruby | {
"resource": ""
} |
q23420 | Guacamole.DocumentModelMapper.model_to_document | train | def model_to_document(model)
document = model.attributes.dup.except(:key, :rev)
handle_embedded_models(model, | ruby | {
"resource": ""
} |
q23421 | TrustyCms.Initializer.initialize_metal | train | def initialize_metal
Rails::Rack::Metal.requested_metals = configuration.metals
Rails::Rack::Metal.metal_paths = ["#{TRUSTY_CMS_ROOT}/app/metal"] # reset Rails default to TRUSTY_CMS_ROOT
Rails::Rack::Metal.metal_paths += plugin_loader.engine_metal_paths
Rails::Rack::Metal.metal_paths += extensio... | ruby | {
"resource": ""
} |
q23422 | TrustyCms.Initializer.initialize_i18n | train | def initialize_i18n
radiant_locale_paths = Dir[File.join(TRUSTY_CMS_ROOT, 'config', 'locales', '*.{rb,yml}')]
configuration.i18n.load_path = | ruby | {
"resource": ""
} |
q23423 | Spiceweasel.Nodes.validate_run_list | train | def validate_run_list(node, run_list, cookbooks, roles)
run_list.split(",").each do |item|
if item.start_with?("recipe[")
# recipe[foo] or recipe[foo::bar]
cb = item.split(/\[|\]/)[1].split(":")[0]
unless cookbooks.member?(cb)
STDERR.puts "ERROR: '#{node}' run lis... | ruby | {
"resource": ""
} |
q23424 | Spiceweasel.Nodes.validate_options | train | def validate_options(node, options, environments)
if options =~ /-E/ # check for environments
env = options.split("-E")[1].split[0]
unless environments.member?(env)
| ruby | {
"resource": ""
} |
q23425 | Spiceweasel.Nodes.validate_node_file | train | def validate_node_file(name)
# read in the file
node = Chef::JSONCompat.from_json(IO.read("nodes/#{name}.json"))
# check the node name vs. contents of the file
return unless node["name"] != name
| ruby | {
"resource": ""
} |
q23426 | Spiceweasel.Nodes.process_providers | train | def process_providers(names, count, name, options, run_list, create_command_options, knifecommands) # rubocop:disable CyclomaticComplexity
provider = names[0]
validate_provider(provider, names, count, options, knifecommands) unless Spiceweasel::Config[:novalidation]
provided_names = []
if name.n... | ruby | {
"resource": ""
} |
q23427 | Spiceweasel.Nodes.validate_provider | train | def validate_provider(provider, names, _count, options, knifecommands)
unless knifecommands.index { |x| x.start_with?("knife #{provider}") }
STDERR.puts "ERROR: 'knife #{provider}' is not a currently installed plugin for knife."
exit(-1)
end
return unless provider.eql?("google")
| ruby | {
"resource": ""
} |
q23428 | Spiceweasel.Nodes.chef_client_search | train | def chef_client_search(name, run_list, environment)
search = []
search.push("name:#{name}") if name
search.push("chef_environment:#{environment}") if environment
run_list.split(",").each do |item|
| ruby | {
"resource": ""
} |
q23429 | Spiceweasel.Cookbooks.validate_metadata | train | def validate_metadata(cookbook, version)
# check metadata.rb for requested version
metadata = @loader.cookbooks_by_name[cookbook].metadata
Spiceweasel::Log.debug("validate_metadata: #{cookbook} #{metadata.name} #{metadata.version}")
# Should the cookbook directory match the name in the metadata?... | ruby | {
"resource": ""
} |
q23430 | Spiceweasel.Cookbooks.validate_dependencies | train | def validate_dependencies
Spiceweasel::Log.debug("cookbook validate_dependencies: '#{@dependencies}'")
@dependencies.each do |dep|
unless member?(dep)
| ruby | {
"resource": ""
} |
q23431 | Renogen.Generator.generate! | train | def generate!
changelog = extraction_stratagy.extract
changelog.version = version
changelog.date | ruby | {
"resource": ""
} |
q23432 | Guacamole.AqlQuery.perfom_query | train | def perfom_query(iterator_with_mapping, &block)
iterator = perform_mapping? ? iterator_with_mapping | ruby | {
"resource": ""
} |
q23433 | Spiceweasel.Clusters.cluster_process_nodes | train | def cluster_process_nodes(cluster, environment, cookbooks, environments, roles, knifecommands, rootoptions)
Spiceweasel::Log.debug("cluster::cluster_process_nodes '#{environment}' '#{cluster[environment]}'")
cluster[environment].each do |node|
node_name = node.keys.first
options = node[node_... | ruby | {
"resource": ""
} |
q23434 | TrustyCms.ExtensionLoader.activate_extensions | train | def activate_extensions
initializer.initialize_views
ordered_extensions = []
configuration = TrustyCms::Application.config
if configuration.extensions.first == :all
ordered_extensions = extensions
| ruby | {
"resource": ""
} |
q23435 | Jekyll.JekyllAppEngine.source_partial_exists? | train | def source_partial_exists?
if @site.respond_to?(:in_source_dir)
File.exists? @site.in_source_dir("_app.yaml") | ruby | {
"resource": ""
} |
q23436 | Jekyll.JekyllAppEngine.document_overrides | train | def document_overrides(document)
if document.respond_to?(:data) and document.data.has_key?("app_engine") | ruby | {
"resource": ""
} |
q23437 | Jekyll.JekyllAppEngine.app_yaml_exists? | train | def app_yaml_exists?
if @site.respond_to?(:in_source_dir)
File.exists? @site.in_source_dir("app.yaml")
| ruby | {
"resource": ""
} |
q23438 | Spiceweasel.DataBags.validate_item | train | def validate_item(db, item)
unless File.exist?("data_bags/#{db}/#{item}.json")
STDERR.puts "ERROR: data bag '#{db}' item '#{item}' file 'data_bags/#{db}/#{item}.json' does not exist"
exit(-1)
end
f = File.read("data_bags/#{db}/#{item}.json")
begin
itemfile = JSON.parse(f)... | ruby | {
"resource": ""
} |
q23439 | Coercible.Coercer.initialize_coercer | train | def initialize_coercer(klass)
coercers[klass] =
begin
coercer = Coercer::Object.determine_type(klass) || Coercer::Object | ruby | {
"resource": ""
} |
q23440 | Guacamole.Transaction.write_collections | train | def write_collections
edge_collections.flat_map do |target_state|
[target_state.edge_collection_name] +
| ruby | {
"resource": ""
} |
q23441 | Guacamole.Transaction.transaction | train | def transaction
transaction = database.create_transaction(transaction_code,
write: write_collections,
| ruby | {
"resource": ""
} |
q23442 | PDUTools.Helpers.decode16bit | train | def decode16bit data, length
data.split('').in_groups_of(4).collect()
double_octets = data.split('').in_groups_of(4).map(&:join).map{|x| x.to_i(16) | ruby | {
"resource": ""
} |
q23443 | Guacamole.Query.each | train | def each(&block)
return to_enum(__callee__) unless block_given?
perfom_query ->(document) | ruby | {
"resource": ""
} |
q23444 | Guacamole.Query.perfom_query | train | def perfom_query(iterator, &block)
if example
connection.by_example(example, options).each(&iterator) | ruby | {
"resource": ""
} |
q23445 | Mapnik.Map.style | train | def style(name)
style = Mapnik::Style.new
yield style
| ruby | {
"resource": ""
} |
q23446 | Mapnik.Map.layer | train | def layer(name, srs = nil)
layer = Mapnik::Layer.new(name, srs) | ruby | {
"resource": ""
} |
q23447 | Mapnik.Map.render_to_file | train | def render_to_file(filename, format = nil)
if format
__render_to_file_with_format__(filename, format) | ruby | {
"resource": ""
} |
q23448 | Rfm.Error.getError | train | def getError(code, message=nil)
klass = find_by_code(code)
message = build_message(klass, code, message)
| ruby | {
"resource": ""
} |
q23449 | Mondo.Client.request | train | def request(method, path, opts = {})
raise ClientError, 'Access token missing' unless @access_token
opts[:headers] = {} if opts[:headers].nil?
opts[:headers]['Accept'] = 'application/json'
opts[:headers]['Content-Type'] = 'application/json' unless method == :get
opts[:headers]['User-Agent... | ruby | {
"resource": ""
} |
q23450 | Rfm.Server.connect | train | def connect(action, args, options = {})
post = args.merge(expand_options(options)).merge({action | ruby | {
"resource": ""
} |
q23451 | CopycopterClient.I18nBackend.available_locales | train | def available_locales
cached_locales = cache.keys.map { |key| key.split('.').first }
(cached_locales | ruby | {
"resource": ""
} |
q23452 | RAR.Archive.create! | train | def create!
rar_process = IO.popen command_line
# Wait for the child rar process to finish.
_, status = Process.wait2 rar_process.pid
if status.exitstatus > 1 | ruby | {
"resource": ""
} |
q23453 | CopycopterClient.Client.upload | train | def upload(data)
connect do |http|
response = http.post(uri('draft_blurbs'), data.to_json, 'Content-Type' => 'application/json')
| ruby | {
"resource": ""
} |
q23454 | CopycopterClient.Client.deploy | train | def deploy
connect do |http|
response = http.post(uri('deploys'), '')
| ruby | {
"resource": ""
} |
q23455 | Hooray.Seek.nodes | train | def nodes
return @nodes if @nodes
@nodes = sweep.map do |k, v|
Node.new(ip: k, mac: Hooray::Local.arp_table[k.to_s], ports: v)
| ruby | {
"resource": ""
} |
q23456 | Hooray.Seek.ping_class | train | def ping_class
return Net::Ping::External unless ports
return Net::Ping::TCP unless @protocol =~ | ruby | {
"resource": ""
} |
q23457 | Hooray.Seek.scan_bot | train | def scan_bot(ip)
(ports || [nil]).each do |port|
Thread.new do
if ping_class.new(ip.to_s, port, | ruby | {
"resource": ""
} |
q23458 | Hooray.Seek.sweep | train | def sweep
network.to_range.each do |ip|
@scan[ip] = []
scan_bot(ip)
end
Thread.list.reject { |t| t == | ruby | {
"resource": ""
} |
q23459 | CopycopterClient.Cache.export | train | def export
keys = {}
lock do
@blurbs.sort.each do |(blurb_key, value)|
current = keys
yaml_keys = blurb_key.split('.')
0.upto(yaml_keys.size - 2) do |i|
key = yaml_keys[i]
# Overwrite en.key with en.sub.key
unless current[key].class... | ruby | {
"resource": ""
} |
q23460 | CopycopterClient.Cache.wait_for_download | train | def wait_for_download
if pending?
logger.info 'Waiting for first download'
if logger.respond_to? :flush
logger.flush
| ruby | {
"resource": ""
} |
q23461 | RTurk.RegisterHITType.validate | train | def validate
missing_parameters = []
required_fields.each do |param|
missing_parameters << param.to_s unless | ruby | {
"resource": ""
} |
q23462 | TableHelper.CollectionTable.default_class | train | def default_class
if collection.respond_to?(:proxy_reflection)
collection.proxy_reflection.klass
| ruby | {
"resource": ""
} |
q23463 | TableHelper.RowBuilder.undef_cell | train | def undef_cell(name)
method_name = name.gsub('-', '_')
klass = class << self; self; end
| ruby | {
"resource": ""
} |
q23464 | TableHelper.Row.cell | train | def cell(name, *args)
name = name.to_s if name
options = args.last.is_a?(Hash) ? args.pop : {}
options[:namespace] = table.object_name
args << options
| ruby | {
"resource": ""
} |
q23465 | TableHelper.Header.column | train | def column(*names)
# Clear the header row if this is being customized by the user
unless @customized
@customized = true
clear
end
# Extract configuration
options = names.last.is_a?(Hash) ? names.pop : {}
content = names.last.is_a?(String) ? names.pop : nil
... | ruby | {
"resource": ""
} |
q23466 | TableHelper.Header.html | train | def html
html_options = @html_options.dup
html_options[:style] = 'display: none;' if table.empty? && hide_when_empty
| ruby | {
"resource": ""
} |
q23467 | Aliyun.Service.gen_request_parameters | train | def gen_request_parameters method, params
#add common parameters
params.merge! self.service.default_parameters
params.merge! self.options
params[:Action] = method.to_s
params[:Timestamp] = | ruby | {
"resource": ""
} |
q23468 | Aliyun.Service.compute_signature | train | def compute_signature params
if $DEBUG
puts "keys before sorted: #{params.keys}"
end
sorted_keys = params.keys.sort
if $DEBUG
puts "keys after sorted: #{sorted_keys}"
end
canonicalized_query_string = ""
canonicalized_query_string = sorted_keys.map {|key|
... | ruby | {
"resource": ""
} |
q23469 | Aliyun.Service.calculate_signature | train | def calculate_signature key, string_to_sign
hmac = HMAC::SHA1.new(key)
hmac.update(string_to_sign)
| ruby | {
"resource": ""
} |
q23470 | SubtitleIt.Subtitle.encode_dump | train | def encode_dump(dump)
dump = dump.read unless dump.is_a?(String)
enc = CharlockHolmes::EncodingDetector.detect(dump)
if enc[:encoding] != 'UTF-8'
puts "Converting `#{enc[:encoding]}` to `UTF-8`".yellow | ruby | {
"resource": ""
} |
q23471 | BlockScore.Collection.create | train | def create(params = {})
fail Error, 'Create parent first' unless parent.id
assoc_params = default_params.merge(params) | ruby | {
"resource": ""
} |
q23472 | BlockScore.Collection.retrieve | train | def retrieve(id)
each do |item|
return item if | ruby | {
"resource": ""
} |
q23473 | BlockScore.Collection.parent_id? | train | def parent_id?(item)
parent.id | ruby | {
"resource": ""
} |
q23474 | BlockScore.Collection.register_to_parent | train | def register_to_parent(item)
fail Error, 'None belonging' unless parent_id?(item)
ids | ruby | {
"resource": ""
} |
q23475 | TableHelper.Body.build_row | train | def build_row(object, index = table.collection.index(object))
row = BodyRow.new(object, self)
row.alternate = alternate ? index.send("#{alternate}?") : false
| ruby | {
"resource": ""
} |
q23476 | PokerEngine.Cards.values_desc_by_occurency | train | def values_desc_by_occurency
values = cards.map(&:value)
values.sort do |a, b|
coefficient_occurency = (values.count(a) <=> values.count(b))
| ruby | {
"resource": ""
} |
q23477 | TableHelper.BodyRow.content | train | def content
number_to_skip = 0 # Keeps track of the # of columns to skip
html = ''
table.header.column_names.each do |column|
number_to_skip -= 1 and next if number_to_skip > 0
if cell = @cells[column]
| ruby | {
"resource": ""
} |
q23478 | Beaker.AwsSdk.kill_instances | train | def kill_instances(instances)
running_instances = instances.compact.select do |instance|
instance_by_id(instance.instance_id).state.name == 'running'
end
instance_ids = running_instances.map(&:instance_id)
return nil if instance_ids.empty?
| ruby | {
"resource": ""
} |
q23479 | Beaker.AwsSdk.kill_zombie_volumes | train | def kill_zombie_volumes
# Occasionaly, tearing down ec2 instances leaves orphaned EBS volumes behind -- these stack up quickly.
# This simply looks for EBS volumes that are not in use
@logger.notify("aws-sdk: Kill Zombie Volumes!")
volume_count = 0
regions.each do |region|
@logger... | ruby | {
"resource": ""
} |
q23480 | Beaker.AwsSdk.launch_all_nodes | train | def launch_all_nodes
@logger.notify("aws-sdk: launch all hosts in configuration")
ami_spec = YAML.load_file(@options[:ec2_yaml])["AMI"]
global_subnet_id = @options['subnet_id']
global_subnets = @options['subnet_ids']
if global_subnet_id and global_subnets
raise RuntimeError, 'Confi... | ruby | {
"resource": ""
} |
q23481 | Beaker.AwsSdk.wait_for_status_netdev | train | def wait_for_status_netdev()
@hosts.each do |host|
if host['platform'] =~ /f5-|netscaler/
wait_for_status(:running, @hosts)
wait_for_status(nil, @hosts) do |instance|
instance_status_collection = client.describe_instance_status({:instance_ids => [instance.instance_id]})
... | ruby | {
"resource": ""
} |
q23482 | Beaker.AwsSdk.add_tags | train | def add_tags
@hosts.each do |host|
instance = host['instance']
# Define tags for the instance
@logger.notify("aws-sdk: Add tags for #{host.name}")
tags = [
{
:key => 'jenkins_build_url',
:value => @options[:jenkins_build_url],
},
... | ruby | {
"resource": ""
} |
q23483 | Beaker.AwsSdk.modify_network_interface | train | def modify_network_interface
@hosts.each do |host|
instance = host['instance']
host['sg_cidr_ips'] = host['sg_cidr_ips'] || '0.0.0.0/0';
sg_cidr_ips = host['sg_cidr_ips'].split(',')
# Define tags for the instance
@logger.notify("aws-sdk: Update network_interface for #{host... | ruby | {
"resource": ""
} |
q23484 | Beaker.AwsSdk.populate_dns | train | def populate_dns
# Obtain the IP addresses and dns_name for each host
@hosts.each do |host|
@logger.notify("aws-sdk: Populate DNS for #{host.name}")
instance = host['instance']
host['ip'] = instance.public_ip_address || instance.private_ip_address
host['private_ip'] = instanc... | ruby | {
"resource": ""
} |
q23485 | Beaker.AwsSdk.enable_root | train | def enable_root(host)
if host['user'] != 'root'
if host['platform'] =~ /f5-/
enable_root_f5(host)
elsif host['platform'] =~ /netscaler/
enable_root_netscaler(host)
else
copy_ssh_to_root(host, @options)
| ruby | {
"resource": ""
} |
q23486 | Beaker.AwsSdk.ensure_key_pair | train | def ensure_key_pair(region)
pair_name = key_name()
delete_key_pair(region, pair_name)
| ruby | {
"resource": ""
} |
q23487 | Beaker.AwsSdk.delete_key_pair_all_regions | train | def delete_key_pair_all_regions(keypair_name_filter=nil)
region_keypairs_hash = my_key_pairs(keypair_name_filter)
region_keypairs_hash.each_pair do |region, keypair_name_array|
| ruby | {
"resource": ""
} |
q23488 | Beaker.AwsSdk.my_key_pairs | train | def my_key_pairs(name_filter=nil)
keypairs_by_region = {}
key_name_filter = name_filter ? "#{name_filter}-*" : key_name
regions.each do |region|
keypairs_by_region[region] = client(region).describe_key_pairs(
| ruby | {
"resource": ""
} |
q23489 | Beaker.AwsSdk.delete_key_pair | train | def delete_key_pair(region, pair_name)
kp = client(region).describe_key_pairs(:key_names => [pair_name]).key_pairs.first
unless kp.nil?
@logger.debug("aws-sdk: delete key pair in region: #{region}")
| ruby | {
"resource": ""
} |
q23490 | Beaker.AwsSdk.create_new_key_pair | train | def create_new_key_pair(region, pair_name)
@logger.debug("aws-sdk: importing new key pair: #{pair_name}")
client(region).import_key_pair(:key_name => pair_name, :public_key_material => public_key)
| ruby | {
"resource": ""
} |
q23491 | Beaker.AwsSdk.group_id | train | def group_id(ports)
if ports.nil? or ports.empty?
raise ArgumentError, "Ports list cannot be nil or empty"
end
unless ports.is_a? Set
ports = Set.new(ports)
end
| ruby | {
"resource": ""
} |
q23492 | Beaker.AwsSdk.create_ping_group | train | def create_ping_group(region_or_vpc, sg_cidr_ips = ['0.0.0.0/0'])
@logger.notify("aws-sdk: Creating group #{PING_SECURITY_GROUP_NAME}")
cl = region_or_vpc.is_a?(String) ? client(region_or_vpc) : client
params = {
:description => 'Custom Beaker security group to enable ping',
:group_na... | ruby | {
"resource": ""
} |
q23493 | Beaker.AwsSdk.create_group | train | def create_group(region_or_vpc, ports, sg_cidr_ips = ['0.0.0.0/0'])
name = group_id(ports)
@logger.notify("aws-sdk: Creating group #{name} for ports #{ports.to_s}")
@logger.notify("aws-sdk: Creating group #{name} with CIDR IPs #{sg_cidr_ips.to_s}")
cl = region_or_vpc.is_a?(String) ? client(regio... | ruby | {
"resource": ""
} |
q23494 | Beaker.AwsSdk.add_ingress_rule | train | def add_ingress_rule(cl, sg_group, cidr_ip, from_port, to_port, protocol = 'tcp')
cl.authorize_security_group_ingress(
| ruby | {
"resource": ""
} |
q23495 | Beaker.AwsSdk.load_fog_credentials | train | def load_fog_credentials(dot_fog = '.fog')
default = get_fog_credentials(dot_fog)
raise "You must specify an aws_access_key_id in your .fog file (#{dot_fog}) for ec2 instances!" unless default[:aws_access_key_id]
raise "You must specify an aws_secret_access_key in your .fog file (#{dot_fog}) for | ruby | {
"resource": ""
} |
q23496 | RailsApiBenchmark.ResultSet.compute_relative_speed | train | def compute_relative_speed
@results = @results.map do |r|
avgs = averages
res = r[:results]
avg_rt = avgs[:response_time]
avg_rps = avgs[:req_per_sec]
f_rt = ((res[:response_time].to_f - avg_rt) / avg_rt * 100).round(1) | ruby | {
"resource": ""
} |
q23497 | Attrio.Helpers.symbolize_hash_keys | train | def symbolize_hash_keys(hash)
hash.inject({}) do |new_hash, (key, value)|
new_hash[(key.to_sym | ruby | {
"resource": ""
} |
q23498 | FcrepoWrapper.Instance.start | train | def start
extract_and_configure
if config.managed?
@pid = spawn(config.env, *process_arguments)
# Wait for fcrepo to start
| ruby | {
"resource": ""
} |
q23499 | FcrepoWrapper.Instance.stop | train | def stop
if config.managed? && started?
Process.kill 'HUP', pid
# Wait for fcrepo | ruby | {
"resource": ""
} |
Subsets and Splits
SQL Console for CoIR-Retrieval/CodeSearchNet-ccr-ruby-queries-corpus
Retrieves a large number of entries in the 'ruby' language, providing basic information but limited analytical value.