_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 30 4.3k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q4500 | CephRuby.Cluster.connect | train | def connect
log("connect")
ret = Lib::Rados.rados_connect(handle) | ruby | {
"resource": ""
} |
q4501 | Jshintrb.JshintTask.define | train | def define # :nodoc:
actual_name = Hash === name ? name.keys.first : name
unless ::Rake.application.last_comment
desc "Run JShint"
end
task name do
unless js_file_list.empty?
result = Jshintrb::report(js_file_list, @options, @globals, STDERR)
| ruby | {
"resource": ""
} |
q4502 | SSSA.Utils.split_ints | train | def split_ints(secret)
result = []
secret.split('').map { |x|
data = x.unpack("H*")[0]
"0"*(data.size % 2) + data
}.join("").scan(/.{1,64}/) { |segment|
| ruby | {
"resource": ""
} |
q4503 | Comable.Order.inherit! | train | def inherit!(order)
self.bill_address ||= order.bill_address
self.ship_address ||= order.ship_address
| ruby | {
"resource": ""
} |
q4504 | Qe.Element.duplicate | train | def duplicate(page, parent = nil)
new_element = self.class.new(self.attributes)
case parent.class.to_s
when ChoiceField
new_element.conditional_id = parent.id
when QuestionGrid, QuestionGridWithTotal
new_element.question_grid_id = parent.id
end
new_element.save(:valid... | ruby | {
"resource": ""
} |
q4505 | REHTML.Tokenizer.decode | train | def decode(html)
html.gsub(ENTITIES::REGEXP){
if $1
if ENTITIES::MAP[$1]
ENTITIES::MAP[$1]
else
$&
end
| ruby | {
"resource": ""
} |
q4506 | Qe.Notifier.notification | train | def notification(p_recipients, p_from, template_name, template_params = {}, options = {})
email_template = EmailTemplate.find_by_name(template_name)
if email_template.nil?
raise "Email Template #{template_name} could not be found"
else
@recipients = p_recipients
@from = p_... | ruby | {
"resource": ""
} |
q4507 | VCloudSdk.Catalog.find_item | train | def find_item(name, item_type = nil)
link = find_item_link(name)
item = VCloudSdk::CatalogItem.new(@session, link)
| ruby | {
"resource": ""
} |
q4508 | GetnetApi.Configure.set_endpoint | train | def set_endpoint
if ambiente == :producao
return GetnetApi::Configure::URL[:producao]
elsif ambiente == :homologacao
| ruby | {
"resource": ""
} |
q4509 | UriSigner.RequestSignature.signature | train | def signature
core_signature = [self.http_method, self.encoded_base_uri]
| ruby | {
"resource": ""
} |
q4510 | UriSigner.QueryHashParser.to_s | train | def to_s
parts = @query_hash.sort.inject([]) do |arr, (key,value)|
if value.kind_of?(Array)
value.each do |nested|
arr << "%s=%s" % [key, nested]
end
| ruby | {
"resource": ""
} |
q4511 | Macros.Sexp.sfind | train | def sfind(sexp, specs)
specs.inject(sexp) do |node, spec|
return NotFound if node.nil?
if spec.is_a?(Symbol) && node.type == spec
node
elsif spec.is_a?(Integer) && node.children.length > spec
node.children[spec]
elsif spec.is_a?(Array)
node.children.g... | ruby | {
"resource": ""
} |
q4512 | MiniSpec.ClassAPI.helper | train | def helper helper, opts = {}, &proc
proc || raise(ArgumentError, | ruby | {
"resource": ""
} |
q4513 | MiniSpec.Utils.symbol_thrown? | train | def symbol_thrown? expected_symbol, expected_value, context, &block
thrown_symbol, thrown_value = catch_symbol(expected_symbol, &block)
if context[:right_proc]
expected_symbol && raise(ArgumentError, 'Both arguments and block given. Please use either one.')
return | ruby | {
"resource": ""
} |
q4514 | MiniSpec.Utils.catch_symbol | train | def catch_symbol expected_symbol, &block
thrown_symbol, thrown_value = nil
begin
if expected_symbol
thrown_value = catch :__ms__nothing_thrown do
catch expected_symbol do
block.call
throw :__ms__nothing_thrown, :__ms__nothing_thrown
end
... | ruby | {
"resource": ""
} |
q4515 | MiniSpec.Utils.extract_thrown_symbol | train | def extract_thrown_symbol exception
return unless exception.is_a?(Exception)
return unless s | ruby | {
"resource": ""
} |
q4516 | BioTable.Table.find_fields | train | def find_fields rowname
row = row_by_name(rowname)
fields = (row ? row.fields : [])
# fill fields with nil to match header length
# say header=5 fields=2 fill=2 | ruby | {
"resource": ""
} |
q4517 | Fibre.FiberPool.checkout | train | def checkout(&b)
spec = { block: b, parent: ::Fiber.current }
if @pool.empty?
raise "The fiber queue has been overflowed" if @queue.size > @pool_queue_size
@queue.push spec
return
end
| ruby | {
"resource": ""
} |
q4518 | Fibre.FiberPool.fiber_entry | train | def fiber_entry(spec)
loop do
raise "wrong spec in fiber block" unless spec.is_a?(Hash)
begin
before!(spec)
spec[:block].call# *Fiber.current.args
after!(spec)
# catch ArgumentError, IOError, EOFError, IndexError, LocalJumpError, NameError, NoMethodError
... | ruby | {
"resource": ""
} |
q4519 | Fibre.FiberPool.checkin | train | def checkin(result=nil)
@reserved.delete ::Fiber.current.object_id | ruby | {
"resource": ""
} |
q4520 | Less.Tree.anonymous_function | train | def anonymous_function(block)
lambda do |*args|
# args: (this, node) v8 >= 0.10, otherwise (node) | ruby | {
"resource": ""
} |
q4521 | Less.Tree.extend_js | train | def extend_js(mod)
extend mod
mod.public_instance_methods.each do |method_name|
add_function(sym_to_css(method_name)) { |tree, cxt|
| ruby | {
"resource": ""
} |
q4522 | REHTML.REXMLBuilder.append | train | def append(node)
if node.is_a?(EndTag)
return if empty_tag?(node.name)
po = @pos
while po.parent and po.name != node.name
po = po.parent
end
if po.name == node.name
@pos = po.parent
end
else
rexml = to_rexml(node)
# if node... | ruby | {
"resource": ""
} |
q4523 | GetnetApi.Payment.to_request | train | def to_request obj, type
payment = {
seller_id: GetnetApi.seller_id.to_s,
amount: self.amount.to_i,
currency: self.currency.to_s,
order: self.order.to_request,
customer: self.customer.to_request(:payment),
} | ruby | {
"resource": ""
} |
q4524 | Svn.Revision.diff | train | def diff( path, options={} )
raise Svn::Error, "cannot diff directory #{path}@#{to_s}" if dir? path
other = options[:with] if options[:with].is_a? Root
other = repo.revision(options[:with]) if options[:with].is_a? Numeric
other ||= repo.revision(to_i - 1)
return other.diff( path, :with =... | ruby | {
"resource": ""
} |
q4525 | RedditBot.Bot.resp_with_token | train | def resp_with_token mtd, path, form
fail unless path.start_with? ?/
timeout = 5
begin
reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
"Authorization" => "bearer #{token}",
"User-Agent" => "bot/#{@user_agent || @name}/#{RedditBot::VERSION} by /u/nakilon",
... | ruby | {
"resource": ""
} |
q4526 | Ideone.Client.languages | train | def languages
unless @languages_cache
response = call_request(:get_languages)
languages = response.to_hash[:get_languages_response][:return][:item][1][:value][:item]
# Create a sorted hash
| ruby | {
"resource": ""
} |
q4527 | GetnetApi.Boleto.to_request | train | def to_request
boleto = {
our_number: self.our_number,
document_number: self.document_number,
expiration_date: self.expiration_date,
| ruby | {
"resource": ""
} |
q4528 | Diameter.Message.all_avps_by_name | train | def all_avps_by_name(name)
code, _type, vendor | ruby | {
"resource": ""
} |
q4529 | WebPageParser.BaseRegexpParser.encode | train | def encode(s)
return s if s.nil?
return s if s.valid_encoding?
if s.force_encoding("iso-8859-1").valid_encoding?
| ruby | {
"resource": ""
} |
q4530 | WebPageParser.BaseRegexpParser.retrieve_page | train | def retrieve_page(rurl = nil)
durl = rurl || url
return nil unless durl
durl = filter_url(durl) if self.respond_to?(:filter_url)
self.class.retrieve_session | ruby | {
"resource": ""
} |
q4531 | WebPageParser.BaseRegexpParser.title | train | def title
return @title if @title
if matches = class_const(:TITLE_RE).match(page)
@title = matches[1].to_s.strip
| ruby | {
"resource": ""
} |
q4532 | WebPageParser.BaseRegexpParser.content | train | def content
return @content if @content
matches = class_const(:CONTENT_RE).match(page)
if matches
@content = class_const(:KILL_CHARS_RE).gsub(matches[1].to_s, '')
content_processor
| ruby | {
"resource": ""
} |
q4533 | NIFTI.NImage.[] | train | def [](index)
# Dealing with Ranges is useful when the image represents a tensor
if (index.is_a?(Fixnum) && index >= self.shape[0]) || (index.is_a?(Range) && index.last >= self.shape[0])
raise IndexError.new("Index over bounds")
| ruby | {
"resource": ""
} |
q4534 | NIFTI.NImage.[]= | train | def []=(index,value)
if self.shape.count != 1 or index >= self.shape[0]
raise IndexError.new("You can | ruby | {
"resource": ""
} |
q4535 | Qe.QuestionSet.post | train | def post(params, answer_sheet)
questions_indexed = @questions.index_by {|q| q.id}
# loop over form values
params ||= {}
params.each do |question_id, response|
| ruby | {
"resource": ""
} |
q4536 | Qe.QuestionSet.posted_values | train | def posted_values(param)
if param.kind_of?(Hash) and param.has_key?('year') and param.has_key?('month')
year = param['year']
month = param['month']
if month.blank? or year.blank?
values = ''
else
values = [Date.new(year.to_i, month.to_i, 1).strftime('%m/%d/... | ruby | {
"resource": ""
} |
q4537 | MiniSpec.InstanceAPI.mock | train | def mock object, method, visibility = nil, &proc
if method.is_a?(Hash)
proc && raise(ArgumentError, 'Both Hash and block given. Please use either one.')
method.each_pair {|m,r| mock(object, m, visibility, &proc {r})}
return MiniSpec::Mocks::HashedStub
end
visibility ||= MiniSpe... | ruby | {
"resource": ""
} |
q4538 | MiniSpec.InstanceAPI.proxy | train | def proxy object, method_name
# do not proxify doubles
return if object.respond_to?(:__ms__double_instance)
# do not proxify stubs
return if (x = @__ms__stubs__originals) && (x = x[object]) && x[method_name]
proxies = (@__ms__proxies[object] ||= [])
return if proxies.include?(metho... | ruby | {
"resource": ""
} |
q4539 | Qe.AnswerSheetsController.index | train | def index
# TODO dynamically reference this
# @answer_sheets = answer_sheet_type.find(:all, :order => 'created_at')
@answer_sheets = AnswerSheet.find(:all, :order => 'created_at')
# drop down of sheets to | ruby | {
"resource": ""
} |
q4540 | TelestreamCloud::Qc.QcApi.create_job | train | def create_job(project_id, data, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q4541 | TelestreamCloud::Qc.QcApi.get_job | train | def get_job(project_id, job_id, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q4542 | TelestreamCloud::Qc.QcApi.get_project | train | def get_project(project_id, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q4543 | TelestreamCloud::Qc.QcApi.list_jobs | train | def list_jobs(project_id, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q4544 | AutomaticForeignKey::ActiveRecord::ConnectionAdapters.TableDefinition.belongs_to | train | def belongs_to(table, options = {})
options = options.merge(:references => table)
options[:on_delete] | ruby | {
"resource": ""
} |
q4545 | Svn.Stream.read_all | train | def read_all
content = String.new
while bytes = read and !bytes.empty?
| ruby | {
"resource": ""
} |
q4546 | Svn.Stream.to_string_io | train | def to_string_io
content = StringIO.new
while bytes = read and !bytes.empty?
| ruby | {
"resource": ""
} |
q4547 | NIFTI.Stream.decode | train | def decode(length, type)
# Check if values are valid:
if (@index + length) > @string.length
# The index number is bigger then the length of the binary string.
# We have reached the end and will return nil.
value = nil
else
if type == "AT"
value = decode_tag
... | ruby | {
"resource": ""
} |
q4548 | NIFTI.Stream.encode | train | def encode(value, type)
value = [value] unless | ruby | {
"resource": ""
} |
q4549 | BioTable.TableApply.parse_row | train | def parse_row(line_num, line, header, column_idx, prev_fields, options)
fields = LineParser::parse(line, options[:in_format], options[:split_on])
return nil,nil if fields.compact == []
if options[:pad_fields] and fields.size < header.size
fields += [''] * (header.size - fields.size)
end... | ruby | {
"resource": ""
} |
q4550 | JSON.Lexer.nextclean | train | def nextclean
while true
c = self.nextchar()
if (c == '/')
case self.nextchar()
when '/'
c = self.nextchar()
while c != "\n" && c != "\r" && c != "\0"
c = self.nextchar()
end
when '*'
while true
c = self.nextchar()
raise "unclosed comment" if (c == "\0") | ruby | {
"resource": ""
} |
q4551 | JSON.Lexer.utf8str | train | def utf8str(code)
if (code & ~(0x7f)) == 0
# UCS-4 range 0x00000000 - 0x0000007F
return(code.chr)
end
buf = ""
if (code & ~(0x7ff)) == 0
# UCS-4 range 0x00000080 - 0x000007FF
buf << (0b11000000 | (code >> 6)).chr
buf << (0b10000000 | (code & 0b00111111)).... | ruby | {
"resource": ""
} |
q4552 | JSON.Lexer.nextto | train | def nextto(regex)
buf = ""
while (true)
c = self.nextchar()
if !(regex =~ c).nil? || | ruby | {
"resource": ""
} |
q4553 | JSON.Lexer.nextvalue | train | def nextvalue
c = self.nextclean
s = ""
case c
when /\"|\'/
return(self.nextstring(c))
when '{'
self.back()
return(Hash.new.from_json(self))
when '['
self.back()
return(Array.new.from_json(self))
else
buf = ""
while ((c =~ /"| |:|,|\]|\}|\/|\0/).nil?)
buf += c... | ruby | {
"resource": ""
} |
q4554 | Bombshell.Completor.complete | train | def complete(fragment)
self.class.filter(shell.instance_methods).grep | ruby | {
"resource": ""
} |
q4555 | Beaker.Openstack.flavor | train | def flavor f
@logger.debug "OpenStack: Looking up flavor '#{f}'"
@compute_client.flavors.find { |x| | ruby | {
"resource": ""
} |
q4556 | Beaker.Openstack.image | train | def image i
@logger.debug "OpenStack: Looking up image '#{i}'"
@compute_client.images.find { |x| | ruby | {
"resource": ""
} |
q4557 | Beaker.Openstack.network | train | def network n
@logger.debug "OpenStack: Looking up network '#{n}'"
@network_client.networks.find { |x| | ruby | {
"resource": ""
} |
q4558 | Beaker.Openstack.security_groups | train | def security_groups sgs
for sg in sgs
@logger.debug "Openstack: Looking up security group '#{sg}'" | ruby | {
"resource": ""
} |
q4559 | Beaker.Openstack.provision_storage | train | def provision_storage host, vm
volumes = get_volumes(host)
if !volumes.empty?
# Lazily create the volume client if needed
volume_client_create
volumes.keys.each_with_index do |volume, index|
@logger.debug "Creating volume #{volume} for OpenStack host #{host.name}"
... | ruby | {
"resource": ""
} |
q4560 | Beaker.Openstack.cleanup_storage | train | def cleanup_storage vm
vm.volumes.each do |vol|
@logger.debug "Deleting volume #{vol.name} for OpenStack host #{vm.name}"
| ruby | {
"resource": ""
} |
q4561 | Beaker.Openstack.get_ip | train | def get_ip
begin
@logger.debug "Creating IP"
ip = @compute_client.addresses.create
rescue Fog::Compute::OpenStack::NotFound
# If there are no more floating IP addresses, allocate a
# new one and try again.
@compute_client.allocate_address(@options[:floating_ip_pool])... | ruby | {
"resource": ""
} |
q4562 | Beaker.Openstack.provision | train | def provision
@logger.notify "Provisioning OpenStack"
@hosts.each do |host|
ip = get_ip
hostname = ip.ip.gsub('.','-')
host[:vmhostname] = hostname + '.rfc1918.puppetlabs.net'
create_or_associate_keypair(host, hostname)
@logger.debug "Provisioning #{host.name} (#{hos... | ruby | {
"resource": ""
} |
q4563 | Beaker.Openstack.cleanup | train | def cleanup
@logger.notify "Cleaning up OpenStack"
@vms.each do |vm|
cleanup_storage(vm) if @options[:openstack_volume_support]
@logger.debug "Release floating IPs for OpenStack host #{vm.name}"
floating_ips = vm.all_addresses # fetch and release its floating IPs
floating_ips... | ruby | {
"resource": ""
} |
q4564 | Beaker.Openstack.create_or_associate_keypair | train | def create_or_associate_keypair(host, keyname)
if @options[:openstack_keyname]
@logger.debug "Adding optional key_name #{@options[:openstack_keyname]} to #{host.name} (#{host[:vmhostname]})"
keyname = @options[:openstack_keyname]
else
@logger.debug "Generate a new rsa key"
#... | ruby | {
"resource": ""
} |
q4565 | Pinboard.Client.get | train | def get(params = {})
params[:dt] = params[:dt].to_date.to_s if params.is_a? Time
params[:meta] = params[:meta] ? 'yes' : 'no' if params.has_key?(:meta)
options = create_params(params)
posts = self.class.get('/posts/get', options)['posts']['post'] | ruby | {
"resource": ""
} |
q4566 | Pinboard.Client.suggest | train | def suggest(url)
options = create_params({url: url})
suggested = self.class.get('/posts/suggest', options)['suggested']
popular = suggested['popular']
popular = [] if popular.nil?
| ruby | {
"resource": ""
} |
q4567 | Pinboard.Client.recent | train | def recent(params={})
options = create_params(params)
posts = self.class.get('/posts/recent', options)['posts']['post']
posts = [] if posts.nil?
| ruby | {
"resource": ""
} |
q4568 | Pinboard.Client.dates | train | def dates(tag=nil)
params = {}
params[:tag] = tag if tag
options = create_params(params)
dates = self.class.get('/posts/dates', options)['dates']['date']
dates = [] if dates.nil?
| ruby | {
"resource": ""
} |
q4569 | Pinboard.Client.tags_get | train | def tags_get(params={})
options = create_params(params)
tags = self.class.get('/tags/get', options)['tags']['tag']
tags = [] if tags.nil?
| ruby | {
"resource": ""
} |
q4570 | Pinboard.Client.tags_rename | train | def tags_rename(old_tag, new_tag=nil)
params = {}
params[:old] = old_tag
params[:new] = new_tag if new_tag
options = create_params(params)
result_code | ruby | {
"resource": ""
} |
q4571 | Pinboard.Client.tags_delete | train | def tags_delete(tag)
params = { tag: tag }
options | ruby | {
"resource": ""
} |
q4572 | Pinboard.Client.notes_list | train | def notes_list
options = create_params({})
notes = self.class.get('/notes/list', options)['notes']['note']
notes = [] if notes.nil?
notes | ruby | {
"resource": ""
} |
q4573 | Pinboard.Client.notes_get | train | def notes_get(id)
options = create_params({})
note = self.class.get("/notes/#{id}", options)['note']
return nil unless note
# Complete hack, because the API is still broken
content = '__content__'
Note.new({
id: note['id'],
# Remove whitespace around | ruby | {
"resource": ""
} |
q4574 | Pinboard.Client.create_params | train | def create_params params
options = {}
options[:query] = params
if @auth_token
| ruby | {
"resource": ""
} |
q4575 | VCloudSdk.VM.memory | train | def memory
m = entity_xml
.hardware_section
.memory
allocation_units = m.get_rasd_content(Xml::RASD_TYPES[:ALLOCATION_UNITS])
bytes = eval_memory_allocation_units(allocation_units)
virtual_quantity = m.get_rasd_content(Xml::RASD_TYPES[:VIRTUAL_QUANTITY]).to_i
memor... | ruby | {
"resource": ""
} |
q4576 | VCloudSdk.VM.memory= | train | def memory=(size)
fail(CloudError,
"Invalid vm memory size #{size}MB") if size <= 0
Config
.logger
.info "Changing the vm memory to #{size}MB."
payload = entity_xml
payload.change_memory(size)
| ruby | {
"resource": ""
} |
q4577 | VCloudSdk.VM.vcpu | train | def vcpu
cpus = entity_xml
.hardware_section
.cpu
.get_rasd_content(Xml::RASD_TYPES[:VIRTUAL_QUANTITY])
fail CloudError,
| ruby | {
"resource": ""
} |
q4578 | VCloudSdk.VM.vcpu= | train | def vcpu=(count)
fail(CloudError,
"Invalid virtual CPU count #{count}") if count <= 0
Config
.logger
.info "Changing the virtual CPU count to #{count}."
payload = entity_xml
payload.change_cpu_count(count) | ruby | {
"resource": ""
} |
q4579 | SimpleSearchFilter.Filter.get_order_dir_for_column | train | def get_order_dir_for_column(name)
name = name.to_s
current_column = get_order_column
return nil unless current_column==name
| ruby | {
"resource": ""
} |
q4580 | ElFinderS3.Connector.run | train | def run(params)
@adapter = ElFinderS3::Adapter.new(@options[:server], @options[:cache_connector])
@root = ElFinderS3::Pathname.new(adapter, @options[:root]) #Change - Pass the root dir here
begin
@params = params.dup
@headers = {}
@response = {}
@response[:errorData] ... | ruby | {
"resource": ""
} |
q4581 | Diameter.Stack.add_handler | train | def add_handler(app_id, opts={}, &blk)
vendor = opts.fetch(:vendor, 0)
auth = opts.fetch(:auth, false)
acct = opts.fetch(:acct, false)
| ruby | {
"resource": ""
} |
q4582 | Diameter.Stack.connect_to_peer | train | def connect_to_peer(peer_uri, peer_host, realm)
peer = Peer.new(peer_host, realm)
@peer_table[peer_host] = peer
@peer_table[peer_host].state = :WAITING
# Will move to :UP when the CEA is received
uri = URI(peer_uri)
cxn = @tcp_helper.setup_new_connection(uri.host, uri.port)
@p... | ruby | {
"resource": ""
} |
q4583 | GetnetApi.Credit.to_request | train | def to_request
credit = {
delayed: self.delayed,
authenticated: self.authenticated,
pre_authorization: self.pre_authorization,
save_card_data: self.save_card_data,
transaction_type: self.transaction_type,
number_install... | ruby | {
"resource": ""
} |
q4584 | Newegg.Api.stores | train | def stores
return self._stores if not self._stores.empty?
response = api_get("Stores.egg")
stores = JSON.parse(response.body)
stores.each do |store|
self._stores | ruby | {
"resource": ""
} |
q4585 | Newegg.Api.categories | train | def categories(store_id)
return [] if store_id.nil?
response = api_get("Stores.egg", "Categories", store_id)
categories = JSON.parse(response.body)
categories = categories.collect do |category|
| ruby | {
"resource": ""
} |
q4586 | Newegg.Api.store_content | train | def store_content(store_id, category_id = -1, node_id = -1, store_type = 4, page_number = 1)
params = {
'storeId' => store_id,
'categoryId' => category_id,
'nodeId' => node_id,
'storeType' => | ruby | {
"resource": ""
} |
q4587 | Newegg.Api.search | train | def search(options={})
options = {store_id: -1, category_id: -1, sub_category_id: -1, node_id: -1, page_number: 1, sort: "FEATURED",
keywords: ""}.merge(options)
request = {
'IsUPCCodeSearch' => false,
'IsSubCategorySearch' => options[:sub_category_id] > 0,
... | ruby | {
"resource": ""
} |
q4588 | Newegg.Api.combo_deals | train | def combo_deals(item_number, options={})
options = {sub_category: -1, sort_field: 0, page_number: 1}.merge(options)
params = {
'SubCategory' => options[:sub_category],
'SortField' => options[:sort_field],
| ruby | {
"resource": ""
} |
q4589 | Newegg.Api.reviews | train | def reviews(item_number, page_number = 1, options={})
options = {time: 'all', rating: 'All', sort: 'date posted'}.merge(options)
params = {
'filter.time' => options[:time],
'filter.rating' => options[:rating],
'sort' | ruby | {
"resource": ""
} |
q4590 | CamperVan.Channel.current_mode_string | train | def current_mode_string
n = room.membership_limit
s = room.open_to_guests? ? "" : "s"
| ruby | {
"resource": ""
} |
q4591 | CamperVan.Channel.user_for_message | train | def user_for_message(message)
if user = users[message.user_id]
yield message, user
else
message.user | ruby | {
"resource": ""
} |
q4592 | MiniSpec.ClassAPI.around | train | def around *matchers, &proc
proc || raise(ArgumentError, 'block is missing')
matchers.flatten!
matchers = [:*] if matchers.empty?
return if around?.find {|x| x[0] == matchers && | ruby | {
"resource": ""
} |
q4593 | QuestionproRails.EmailList.statistics | train | def statistics
extracted_statistics = []
unless self.qp_statistics.nil? | ruby | {
"resource": ""
} |
q4594 | CapIt.Capture.capture_command | train | def capture_command
cmd = "#{@cutycapt_path} --url='#{@url}'"
cmd += " --out='#{@folder}/#{@filename}'"
cmd += " --max-wait=#{@max_wait}"
cmd += " --delay=#{@delay}" if @delay
cmd += " --user-agent='#{@user_agent}'"
cmd += " --min-width='#{@min_width}'"
cmd += " --min-h... | ruby | {
"resource": ""
} |
q4595 | Munin.Parser.parse_config | train | def parse_config(data)
config = {'graph' => {}, 'metrics' => {}}
data.each do |l|
if l =~ /^graph_/
key_name, value = l.scan(/^graph_([\w]+)\s(.*)/).flatten
config['graph'][key_name] = value
# according to http://munin-monitoring.org/wiki/notes_on_datasource_names
... | ruby | {
"resource": ""
} |
q4596 | Munin.Parser.parse_error | train | def parse_error(lines)
if lines.size == 1
case lines.first
when '# Unknown service' then raise UnknownService
when '# | ruby | {
"resource": ""
} |
q4597 | Munin.Parser.parse_config_args | train | def parse_config_args(args)
result = {}
args.scan(/--?([a-z\-\_]+)\s([\d]+)\s?/).each do |arg|
| ruby | {
"resource": ""
} |
q4598 | DeviseOtt.Tokens.register | train | def register(token, email, granted_to_email, access_count, expire)
save_config(token, {email: email, granted_to_email: granted_to_email, | ruby | {
"resource": ""
} |
q4599 | DeviseOtt.Tokens.access | train | def access(token, email)
config = load_config(token)
return false unless config
return false unless config[:email].to_s == email.to_s
return false unless config[:access_count] > 0
| 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.