query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102 values |
|---|---|---|---|---|---|---|
Retrieves all available entity type identifiers. | def get_entity_type_identifiers
get_entity_types_related_to Occi::Core::Entity.kind.type_identifier
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end",
"def get_entity_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Entity.kind.type_identifier\n end",
"def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kind... | [
"0.7877693",
"0.7785234",
"0.7623249",
"0.74239135",
"0.70781195",
"0.70505285",
"0.70373416",
"0.7035693",
"0.7035693",
"0.6972683",
"0.6924417",
"0.6717979",
"0.6654311",
"0.6612976",
"0.6455192",
"0.6455192",
"0.6282917",
"0.6266731",
"0.6251797",
"0.6141238",
"0.61367184"... | 0.80748206 | 0 |
Retrieves all available resource types. | def get_resource_types
Occi::Log.debug("Getting resource types ...")
collection = @model.get Occi::Core::Resource.kind
collection.kinds.collect { |kind| kind.term }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def all_of_type\n Resource::AllOfType.new(type)\n end",
"def list_resource_types(feed_id = nil)\n if feed_id.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape_id feed_id\n ... | [
"0.8586148",
"0.7548137",
"0.73330396",
"0.7196875",
"0.71729606",
"0.69619936",
"0.69221973",
"0.6907189",
"0.6850253",
"0.68476236",
"0.66748494",
"0.6610756",
"0.6590624",
"0.6531334",
"0.6490618",
"0.64234513",
"0.6422633",
"0.63303614",
"0.62601733",
"0.6220727",
"0.6213... | 0.8548611 | 1 |
Retrieves all available resource type identifiers. | def get_resource_type_identifiers
get_entity_types_related_to Occi::Core::Resource.kind.type_identifier
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def get_reso... | [
"0.7927595",
"0.7786789",
"0.7720512",
"0.6979698",
"0.68479896",
"0.67314774",
"0.66892487",
"0.6682988",
"0.6543309",
"0.6467696",
"0.63946545",
"0.6316076",
"0.6258884",
"0.6214816",
"0.62119234",
"0.6149411",
"0.61451304",
"0.61367136",
"0.61224055",
"0.60580385",
"0.6056... | 0.78809315 | 1 |
Retrieves all available link types. | def get_link_types
Occi::Log.debug("Getting link types ...")
collection = @model.get Occi::Core::Link.kind
collection.kinds.collect { |kind| kind.term }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_link_types\n get_types(Occi::Core::Link.kind)\n end",
"def get_link_type_identifiers\n get_entity_types_related_to Occi::Core::Link.kind.type_identifier\n end",
"def get_link_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Link.kind.type_identifier... | [
"0.81939846",
"0.69282293",
"0.67540115",
"0.6429698",
"0.63668627",
"0.6271843",
"0.6156096",
"0.60497063",
"0.604643",
"0.59481764",
"0.59287405",
"0.588149",
"0.5840851",
"0.5813125",
"0.5807189",
"0.5807189",
"0.5807189",
"0.5793381",
"0.57657623",
"0.5747395",
"0.5736831... | 0.83286625 | 0 |
Retrieves all available link type identifiers. | def get_link_type_identifiers
get_entity_types_related_to Occi::Core::Link.kind.type_identifier
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_link_types\n get_types(Occi::Core::Link.kind)\n end",
"def get_link_types\n Occi::Log.debug(\"Getting link types ...\")\n collection = @model.get Occi::Core::Link.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def get_link_type_identifiers\n ... | [
"0.78509283",
"0.7835411",
"0.7781284",
"0.6346669",
"0.6222234",
"0.6172147",
"0.60230136",
"0.60179436",
"0.5991234",
"0.58334816",
"0.57899904",
"0.57544655",
"0.5732094",
"0.56883484",
"0.56710947",
"0.56587434",
"0.5650522",
"0.5612827",
"0.5600657",
"0.5600102",
"0.5558... | 0.78948075 | 0 |
Looks up a mixin using its name and, optionally, a type as well. Will return mixin's full location (a link) or a description. | def find_mixin(name, type = nil, describe = false)
Occi::Log.debug("Looking for mixin #{name} + #{type} + #{describe}")
# is type valid?
if type
raise "Unknown mixin type! [#{type}]" unless @mixins.has_key? type.to_sym
end
# TODO: extend this code to support multiple matches and regex filters
# should we look for links or descriptions?
if describe
# we are looking for descriptions
if type
# get the first match from either os_tpls or resource_tpls
case
when type == "os_tpl"
get_os_templates.select { |mixin| mixin.term == name }.first
when type == "resource_tpl"
get_resource_templates.select { |template| template.term == name }.first
else
nil
end
else
# try in os_tpls first
found = get_os_templates.select { |os| os.term == name }.first
# then try in resource_tpls
found = get_resource_templates.select {
|template| template.term == name
}.first unless found
found
end
else
# we are looking for links
# prefix mixin name with '#' to simplify the search
name = "#" + name
if type
# return the first match with the selected type
@mixins[type.to_sym].select {
|mixin| mixin.to_s.reverse.start_with? name.reverse
}.first
else
# there is no type preference, return first global match
@mixins.flatten(2).select {
|mixin| mixin.to_s.reverse.start_with? name.reverse
}.first
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_mixin(name)\n @mixins.fetch(name.to_s) { |k| @parent ? @parent.lookup_mixin(k) : nil }\n end",
"def resolve_mixin(mixin, cur_tool, loader)\n mod =\n case mixin\n when ::String\n cur_tool.lookup_mixin(mixin)\n when ::Symbol\n l... | [
"0.68363106",
"0.62106866",
"0.59954774",
"0.5880233",
"0.5870427",
"0.5768124",
"0.54502344",
"0.5387423",
"0.53281236",
"0.5076696",
"0.4999048",
"0.49348515",
"0.47635597",
"0.47428054",
"0.47157726",
"0.46905813",
"0.4618577",
"0.46107185",
"0.45893195",
"0.45359218",
"0.... | 0.7950162 | 0 |
Retrieves available mixins of a specified type or all available mixins if the type wasn't specified. Mixins are returned in the form of mixin identifiers. | def get_mixins(type = nil)
if type
# is type valid?
raise "Unknown mixin type! #{type}" unless @mixins.has_key? type.to_sym
# return mixin of the selected type
@mixins[type.to_sym]
else
# we did not get a type, return all mixins
mixins = []
# flatten the hash and remove its keys
get_mixin_types.each do |ltype|
mixins.concat @mixins[ltype.to_sym]
end
mixins
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_mixin(name, type = nil, describe = false)\n\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n\n # is type valid?\n if type\n raise \"Unknown mixin type! [#{type}]\" unless @mixins.has_key? type.to_sym\n end\n\n # TODO: extend... | [
"0.6220817",
"0.6093635",
"0.5246576",
"0.5061629",
"0.50506806",
"0.5022578",
"0.49531978",
"0.49368724",
"0.481214",
"0.47991818",
"0.47848308",
"0.47665864",
"0.47330073",
"0.4672994",
"0.4659485",
"0.4655962",
"0.45904776",
"0.45505047",
"0.45398846",
"0.44896248",
"0.448... | 0.8676375 | 0 |
Retrieves available mixin types. Mixin types are presented in a shortened format (i.e. not as type identifiers). | def get_mixin_types
@mixins.keys.map { |k| k.to_s }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n\n # return mixin of the selected type\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mi... | [
"0.71516925",
"0.66711587",
"0.56752825",
"0.5498893",
"0.5451157",
"0.5315886",
"0.5297385",
"0.5184562",
"0.51687837",
"0.5104759",
"0.5085771",
"0.50241375",
"0.49645305",
"0.4962468",
"0.49435604",
"0.49228716",
"0.4891364",
"0.48911783",
"0.4879527",
"0.48722428",
"0.486... | 0.8134472 | 0 |
Retrieves available mixin type identifiers. | def get_mixin_type_identifiers
identifiers = []
get_mixin_types.each do |mixin_type|
identifiers << 'http://schemas.ogf.org/occi/infrastructure#' + mixin_type
end
identifiers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mixin_types\n @mixins.keys.map { |k| k.to_s }\n end",
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n\n # return mixin of the selected type\n @mixins... | [
"0.80996203",
"0.66814935",
"0.5944612",
"0.5617854",
"0.56126696",
"0.528932",
"0.52736497",
"0.5213063",
"0.5212991",
"0.52109706",
"0.5203591",
"0.5188573",
"0.51802635",
"0.5156073",
"0.5111223",
"0.50855166",
"0.5084374",
"0.505663",
"0.49910834",
"0.49840686",
"0.497432... | 0.7986701 | 1 |
Retrieves available resources represented by resource locations (URIs). If no type identifier is specified, all available resource are listed. Type identifier can be specified in its shortened format (e.g. "compute", "storage", "network"). | def list(resource_type_identifier=nil)
if resource_type_identifier
# convert type to type identifier
resource_type_identifier = @model.kinds.select {
|kind| kind.term == resource_type_identifier
}.first.type_identifier if @model.kinds.select {
|kind| kind.term == resource_type_identifier
}.any?
# check some basic pre-conditions
raise "Endpoint is not connected!" unless @connected
raise "Unkown resource type identifier! [#{resource_type_identifier}]" unless @model.get_by_id resource_type_identifier
# split the type identifier and get the most important part
uri_part = resource_type_identifier.split('#').last
# request uri-list from the server
path = uri_part + '/'
else
path = '/'
end
headers = self.class.headers.clone
headers['Accept'] = 'text/uri-list'
# TODO: remove the gsub OCCI-OS hack
response = self.class.get(
@endpoint + path,
:headers => headers
).body.gsub(/\# uri:\/(compute|storage|network)\/[\n]?/, '').split("\n").compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_resources(type)\n resource_collection.all_resources.select do |resource|\n resource_name(resource) == type.to_sym\n end\n end",
"def get_linked_resources(resource_type, filters = {})\n Util.convert_to_clever_object Clever.request(:get, get_uri(resource_type), filters)[:data]\n ... | [
"0.6890208",
"0.6706383",
"0.66487217",
"0.6572492",
"0.6482573",
"0.6240925",
"0.62383497",
"0.61966914",
"0.6074262",
"0.60742515",
"0.60742307",
"0.60664564",
"0.60151577",
"0.5987299",
"0.597916",
"0.5952805",
"0.59348273",
"0.5921658",
"0.59107345",
"0.5903388",
"0.59033... | 0.6691865 | 2 |
Retrieves descriptions for available resources specified by a type identifier or resource location. If no type identifier or location is specified, all available resources in all available resource types will be described. | def describe(resource_type_identifier=nil)
# convert type to type identifier
resource_type_identifier = @model.kinds.select {
|kind| kind.term == resource_type_identifier
}.first.type_identifier if @model.kinds.select {
|kind| kind.term == resource_type_identifier
}.any?
# check some basic pre-conditions
raise "Endpoint is not connected!" unless @connected
descriptions = []
if resource_type_identifier.nil?
descriptions << get('/')
elsif @model.get_by_id resource_type_identifier
# we got type identifier
# get all available resources of this type
locations = list resource_type_identifier
# make the requests
locations.each do |location|
descriptions << get(sanitize_resource_link(location))
end
elsif resource_type_identifier.start_with?(@endpoint) || resource_type_identifier.start_with?('/')
# we got resource link
# make the request
descriptions << get(sanitize_resource_link(resource_type_identifier))
else
raise "Unkown resource type identifier! [#{resource_type_identifier}]"
end
descriptions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_resources(resource_descr, resource_type, authorizer)\n debug \"find_resources: descr: '#{resource_descr.inspect}'\"\n if resource_descr.kind_of? Hash\n can_handle = eval(\"OMF::SFA::Model::#{resource_type.classify}\").respond_to? :handle_rest_get_resource\n if can_handle\n ... | [
"0.6783209",
"0.65141547",
"0.6345092",
"0.6174524",
"0.6174524",
"0.5971894",
"0.5926456",
"0.5900285",
"0.5882157",
"0.5881542",
"0.58698535",
"0.58470976",
"0.58366823",
"0.58180326",
"0.58154243",
"0.57796943",
"0.5745785",
"0.56759906",
"0.56659013",
"0.56436163",
"0.559... | 0.74328613 | 0 |
Creates a new resource on the server. Resource must be provided as an instance of Occi::Core::Entity, e.g. instantiated using the get_resource method. | def create(entity)
# check some basic pre-conditions
raise "Endpoint is not connected!" unless @connected
raise "#{entity} not an entity" unless entity.kind_of? Occi::Core::Entity
# is this entity valid?
entity.model = @model
entity.check
Occi::Log.debug "Entity kind: #{entity.kind}"
kind = entity.kind
raise "No kind found for #{entity}" unless kind
# get location for this kind of entity
Occi::Log.debug "Kind location: #{entity.kind.location}"
location = kind.location
collection = Occi::Collection.new
# is this entity a Resource or a Link?
Occi::Log.debug "Entity class: #{entity.class.name}"
collection.resources << entity if entity.kind_of? Occi::Core::Resource
collection.links << entity if entity.kind_of? Occi::Core::Link
# make the request
post location, collection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_resource(_params)\n resource_class.new(resource_params)\n end",
"def create_resource\n class_name.new(get_secure_params).tap do |model|\n model.save\n set_resource_ivar model\n end\n end",
"def create(resource, options = {}, format = nil)\n bas... | [
"0.762519",
"0.755148",
"0.7535406",
"0.74369746",
"0.74257165",
"0.7417434",
"0.7379857",
"0.73388016",
"0.7309319",
"0.72849506",
"0.72480965",
"0.72105575",
"0.7192749",
"0.717456",
"0.7119396",
"0.7067439",
"0.70616174",
"0.70416933",
"0.701883",
"0.70005614",
"0.6995206"... | 0.0 | -1 |
Deploys a compute resource based on an OVF/OVA descriptor available on a local file system. | def deploy(location)
media_types = self.class.head(@endpoint).headers['accept'].to_s
raise "File #{location} does not exist" unless File.exist? location
file = File.read(location)
if location.include? '.ovf'
if media_types.include? 'application/ovf'
headers = self.class.headers.clone
headers['Content-Type'] = 'application/ovf'
self.class.post(@endpoint + '/compute/',
:body => file,
:headers => headers)
end
elsif location.include? '.ova'
if media_types.include? ' application/ova '
headers = self.class.headers.clone
headers['Content-Type'] = 'application/ova'
self.class.post(@endpoint + '/compute/',
:body => file,
:headers => headers)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_file(filename)\n cookbook_file '/var/opt/dynatrace-managed/sources/' + filename do\n source '' + filename\n owner node['dynatrace-quickstart-gcp']['user']\n group node['dynatrace-quickstart-gcp']['user']\n mode '644'\n action :create\n end\nend",
"def deploy_ovf\n... | [
"0.5762656",
"0.56625205",
"0.5618709",
"0.56102574",
"0.5570687",
"0.55029815",
"0.5497632",
"0.5478713",
"0.54700017",
"0.545718",
"0.5423394",
"0.5391553",
"0.5349144",
"0.5340445",
"0.53124243",
"0.52754676",
"0.5273615",
"0.5273008",
"0.5272535",
"0.5266649",
"0.5237224"... | 0.57692736 | 0 |
Deletes a resource or all resource of a certain resource type from the server. | def delete(resource_type_identifier)
# convert type to type identifier
raise "Endpoint is not connected!" unless @connected
path = path_for_resource_type resource_type_identifier
del path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_resource(type, id, data = {})\n model = fetch_generic_object_definition(type, id, data)\n delete_resource_main_action(type, model, data)\n model\n rescue => err\n raise BadRequestError, \"Deleting #{model_ident(model, type)} - #{err}\"\n end",
"def remove(resource)\n res... | [
"0.7760187",
"0.74323684",
"0.7356856",
"0.7341942",
"0.7256082",
"0.724888",
"0.72461456",
"0.7186073",
"0.7185984",
"0.71690214",
"0.71549994",
"0.6961346",
"0.6944077",
"0.6941925",
"0.6936339",
"0.6931385",
"0.69293946",
"0.69055855",
"0.6877403",
"0.6840426",
"0.6837754"... | 0.73212755 | 4 |
Triggers given action on a specific resource. | def trigger(resource_type_identifier, action)
# TODO: not tested
if @model.kinds.select { |kind| kind.term == resource_type }.any?
type_identifier = @model.kinds.select {
|kind| kind.term == resource_type_identifier
}.first.type_identifier
location = @model.get_by_id(type_identifier).location
resource_type_identifier = @endpoint + location
end
# check some basic pre-conditions
raise "Endpoint is not connected!" unless @connected
raise "Unknown resource identifier! #{resource_type_identifier}" unless resource_type_identifier.start_with? @endpoint
# encapsulate the acion in a collection
collection = Occi::Collection.new
scheme, term = action.split(' #')
collection.actions << Occi::Core::Action.new(scheme + '#', term)
# make the request
path = sanitize_resource_link(resource_type_identifier) + '?action=' + term
post path, collection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_action\n raise \"Action for resource #{self.class} is nil!\" if @action.nil?\n\t\t\tif (self.respond_to? @action)\n\t\t\t\tself.send(@action)\n\t\t\tend\n\t\tend",
"def resource_action(resource)\n resource.action if resource.respond_to?(:action)\n end",
"def trigger(resource_type_ide... | [
"0.72843325",
"0.68376297",
"0.66839916",
"0.6670168",
"0.6620549",
"0.63868994",
"0.6315961",
"0.6310027",
"0.6249608",
"0.61784345",
"0.6167657",
"0.611064",
"0.6110357",
"0.6109257",
"0.61065155",
"0.6082767",
"0.6062792",
"0.6048649",
"0.60390425",
"0.60064507",
"0.595970... | 0.6943681 | 1 |
Refreshes the Occi::Model used inside the client. Useful for updating the model without creating a new instance or reconnecting. Saves a lot of time in an interactive mode. | def refresh
# re-download the model from the server
set_model
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh\n if new_model?\n return WscSdk::Errors.model_does_not_exist(self.endpoint)\n else\n return self.endpoint.refresh(self)\n end\n end",
"def reload!\n ensure_service!\n @gapi_json = service.get_model dataset_id, model_id\n @reference = nil\n ... | [
"0.72774494",
"0.69155174",
"0.6836855",
"0.6687198",
"0.6518902",
"0.6508058",
"0.64933074",
"0.6480971",
"0.6407291",
"0.6396982",
"0.6396982",
"0.63861495",
"0.6360549",
"0.6360549",
"0.6346192",
"0.6346192",
"0.6329491",
"0.623688",
"0.6203208",
"0.6203208",
"0.62001175",... | 0.82634836 | 0 |
Performs GET request and parses the responses to collections. | def get(path='', filter=nil)
# remove the leading slash
path = path.gsub(/\A\//, '')
response = if filter
categories = filter.categories.collect { |category| category.to_text }.join(',')
attributes = filter.entities.collect { |entity| entity.attributes.combine.collect { |k, v| k + '=' + v } }.join(',')
headers = self.class.headers.clone
headers['Content-Type'] = 'text/occi'
headers['Category'] = categories unless categories.empty?
headers['X-OCCI-Attributes'] = attributes unless attributes.empty?
self.class.get(@endpoint + path, :headers => headers)
else
self.class.get(@endpoint + path)
end
response_msg = response_message response
raise "HTTP GET failed! #{response_msg}" unless response.code.between? 200, 300
Occi::Log.debug "Response location: #{('/' + path).match(/\/.*\//).to_s}"
kind = @model.get_by_location(('/' + path).match(/\/.*\//).to_s) if @model
Occi::Log.debug "Response kind: #{kind}"
if kind
kind.related_to? Occi::Core::Resource ? entity_type = Occi::Core::Resource : entity_type = nil
entity_type = Occi::Core::Link if kind.related_to? Occi::Core::Link
end
Occi::Log.debug "Parser call: #{response.content_type} #{entity_type} #{path.include?('-/')}"
collection = Occi::Parser.parse(response.content_type, response.body, path.include?('-/'), entity_type, response.headers)
Occi::Log.debug "Parsed collection: empty? #{collection.empty?}"
collection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch(options = {})\n url = build_url(options)\n puts \"Getting #{url}\"\n\n json = get_response(url)\n\n if self.is_json?\n data = JSON.parse(json)\n else\n data = XmlSimple.xml_in(json)\n end\n\n # TODO: Raise hell if there is a problem\n\n ... | [
"0.7126692",
"0.68431854",
"0.68389094",
"0.6793959",
"0.662105",
"0.662105",
"0.64062643",
"0.631757",
"0.6298959",
"0.62942183",
"0.62928504",
"0.62890637",
"0.62890637",
"0.6245959",
"0.6221773",
"0.6149454",
"0.61449116",
"0.6141196",
"0.6135513",
"0.60983306",
"0.6075992... | 0.60493284 | 24 |
Performs POST requests and returns URI locations. Resource data must be provided in an Occi::Collection instance. | def post(path, collection)
# remove the leading slash
path = path.gsub(/\A\//, '')
headers = self.class.headers.clone
headers['Content-Type'] = @media_type
response = case @media_type
when 'application/occi+json'
self.class.post(@endpoint + path,
:body => collection.to_json,
:headers => headers)
when 'text/occi'
self.class.post(@endpoint + path,
:headers => collection.to_header.merge(headers))
else
self.class.post(@endpoint + path,
:body => collection.to_text,
:headers => headers)
end
response_msg = response_message response
case response.code
when 200
collection = Occi::Parser.parse(response.header["content-type"].split(";").first, response)
if collection.empty?
Occi::Parser.locations(response.header["content-type"].split(";").first, response.body, response.header).first
else
collection.resources.first.location if collection.resources.first
end
when 201
Occi::Parser.locations(response.header["content-type"].split(";").first, response.body, response.header).first
else
raise "HTTP POST failed! #{response_msg}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(path, collection)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = @media_type\n\n response = case @media_type\n when 'application/occi+json'\n self.class.post(@... | [
"0.6200585",
"0.5874095",
"0.58321387",
"0.56579345",
"0.5649235",
"0.5547596",
"0.5384626",
"0.5366917",
"0.5357277",
"0.5171335",
"0.5162472",
"0.51528513",
"0.5135156",
"0.50979334",
"0.5093289",
"0.5046608",
"0.50332016",
"0.50166285",
"0.50048697",
"0.50016797",
"0.50004... | 0.6008173 | 1 |
Performs PUT requests and parses responses to collections. | def put(path, collection)
# remove the leading slash
path = path.gsub(/\A\//, '')
headers = self.class.headers.clone
headers['Content-Type'] = @media_type
response = case @media_type
when 'application/occi+json'
self.class.post(@endpoint + path,
:body => collection.to_json,
:headers => headers)
when 'text/occi'
self.class.post(@endpoint + path,
:headers => collection.to_header.merge(headers))
else
self.class.post(@endpoint + path,
:body => collection.to_text,
:headers => headers)
end
response_msg = response_message response
case response.code
when 200, 201
Occi::Parser.parse(response.header["content-type"].split(";").first, response)
else
raise "HTTP POST failed! #{response_msg}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_put_with_objects_from_collection(path, options, klass, collection_name)\n perform_request_with_objects_from_collection(:put, path, options, klass, collection_name)\n end",
"def update\n render_json :status => :forbidden and return unless @collection.write?(@user, @client)\n if !para... | [
"0.65280616",
"0.6281938",
"0.6096951",
"0.60133374",
"0.5982197",
"0.59089094",
"0.5884129",
"0.5857716",
"0.5815823",
"0.5771142",
"0.57020533",
"0.56889784",
"0.5671537",
"0.5665331",
"0.5625474",
"0.55587906",
"0.5538064",
"0.5535803",
"0.55294317",
"0.5424259",
"0.541564... | 0.61211956 | 2 |
Performs DELETE requests and returns True on success. | def del(path, filter=nil)
# remove the leading slash
path = path.gsub(/\A\//, '')
response = self.class.delete(@endpoint + path)
response_msg = response_message response
raise "HTTP DELETE failed! #{response_msg}" unless response.code.between? 200, 300
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(api_path)\n true\n rescue Error::HTTPError\n false\n end",
"def delete\n client.delete(api_path)\n true\n rescue Error::HTTPError\n false\n end",
"def delete\n ensure_client && ensure_uri\n response = @client.rest_delete(@data['uri'... | [
"0.76359123",
"0.76359123",
"0.7346285",
"0.732964",
"0.7224901",
"0.7188649",
"0.7170333",
"0.71282035",
"0.71282035",
"0.7117946",
"0.7095823",
"0.7095823",
"0.70018715",
"0.69749314",
"0.6956935",
"0.69361585",
"0.69131804",
"0.69006157",
"0.68136466",
"0.676404",
"0.67482... | 0.6231254 | 72 |
Creates a link of a specified kind and binds it to the given resource. | def link(kind, source, target_location, target_kind, attributes=Occi::Core::Attributes.new, mixins=[])
link = Occi::Core::Link.new(kind)
link.mixins = mixins
link.attributes = attributes
link.target = (target_location.kind_of? URI::Generic) ? target_location.path : target_location.to_s
link.rel = target_kind
jj link
link.check @model
source.links << link
link
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link(href, opts={})\n @resource.tap {|obj| obj.add_link(@rel, href, opts) }\n end",
"def link(resource,tag)\n self.class.link(self,resource,tag)\n end",
"def link!(resource, uuid)\n build_link(resource, uuid).save!\n end",
"def create_link(resource, *args)\n link = ''.h... | [
"0.66841847",
"0.66141325",
"0.63976157",
"0.63182503",
"0.62598115",
"0.62305516",
"0.596212",
"0.5918566",
"0.58841217",
"0.5785351",
"0.57206076",
"0.5716628",
"0.5707941",
"0.56757027",
"0.5627898",
"0.5571536",
"0.5528279",
"0.5518384",
"0.5507917",
"0.5470062",
"0.54669... | 0.6589466 | 2 |
Checks whether the given endpoint URI is valid and adds a trailing slash if necessary. | def prepare_endpoint(endpoint)
raise 'Endpoint not a valid URI' if (endpoint =~ URI::ABS_URI).nil?
@endpoint = endpoint.chomp('/') + '/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_url_ends_with_slash(url)\n return \"#{url}/\" unless url.end_with?(\"/\")\n\n return url\n end",
"def valid_endpoint(ep)\n if ep == nil\n raise ArgumentError, \"Request: An endpoint must be set\", caller\n elsif not ep.is_a? String\n raise TypeError, \"Request: An ... | [
"0.6731609",
"0.67035586",
"0.6083759",
"0.5896076",
"0.5839203",
"0.5778053",
"0.5755815",
"0.5754997",
"0.57444066",
"0.5742326",
"0.5742126",
"0.5670484",
"0.5648423",
"0.5637107",
"0.56367683",
"0.55857885",
"0.55705106",
"0.55676526",
"0.55026746",
"0.545672",
"0.5445191... | 0.6924188 | 0 |
Creates an Occi::Model from data retrieved from the server. | def set_model
# check credentials and handle OpenStack Keystone
# TODO: check expiration dates on Keystone tokens
raise "You are not authorized to use this endpoint!" unless check_authn
#
model = get('/-/')
@model = Occi::Model.new(model)
@mixins = {
:os_tpl => [],
:resource_tpl => []
}
#
get_os_templates.each do |os_tpl|
unless os_tpl.nil? || os_tpl.type_identifier.nil?
tid = os_tpl.type_identifier.strip
@mixins[:os_tpl] << tid unless tid.empty?
end
end
#
get_resource_templates.each do |res_tpl|
unless res_tpl.nil? || res_tpl.type_identifier.nil?
tid = res_tpl.type_identifier.strip
@mixins[:resource_tpl] << tid unless tid.empty?
end
end
model
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_from_database(data)\n return nil if data.blank?\n \n # Create an instance of the object\n obj = self.new(data['data'])\n obj.raw_data = data\n obj\n end",
"def load_model(mid)\n url = Configuration::PROPERTIES.get_property :url\n ... | [
"0.6568126",
"0.64901936",
"0.6371203",
"0.61468875",
"0.6092849",
"0.59625506",
"0.5923423",
"0.58872247",
"0.58774096",
"0.58416146",
"0.5789686",
"0.57629895",
"0.5742137",
"0.5742137",
"0.57298857",
"0.5726659",
"0.57034713",
"0.5622811",
"0.5595958",
"0.5557227",
"0.5554... | 0.5835865 | 10 |
Checks provided credentials and attempts transparent authentication with OS Keystone using the "wwwauthenticate" header. | def check_authn
response = self.class.head @endpoint
return true if response.success?
if response.code == 401 && response.headers["www-authenticate"]
if response.headers["www-authenticate"].start_with? "Keystone"
keystone_uri = /^Keystone uri='(.+)'$/.match(response.headers["www-authenticate"])[1]
if keystone_uri
if @auth_options[:type] == "x509"
body = { "auth" => { "voms" => true } }
else
body = {
"auth" => {
"passwordCredentials" => {
"username" => @auth_options[:username],
"password" => @auth_options[:password]
}
}
}
end
headers = self.class.headers.clone
headers['Content-Type'] = "application/json"
headers['Accept'] = headers['Content-Type']
response = self.class.post(keystone_uri + "/v2.0/tokens", :body => body.to_json, :headers => headers)
if response.success?
self.class.headers['X-Auth-Token'] = response['access']['token']['id']
return true
end
end
end
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate\n @shoonga = authenticate_or_request_with_http_basic do |username, password|\n username == \"4vght\" && password == \"we8vds\"\n end\nend",
"def require_http_auth\n if `hostname` =~ /soykaf|lanpartei/i \n if auth = APP_CONFIG['http_auth']\n authenticate_or_request_with_http_basi... | [
"0.6616653",
"0.6610217",
"0.6591077",
"0.6467743",
"0.64342606",
"0.6394454",
"0.63747376",
"0.6332156",
"0.63221663",
"0.63221663",
"0.6290899",
"0.6213805",
"0.62025535",
"0.6185606",
"0.61678123",
"0.6153708",
"0.6149189",
"0.61356413",
"0.60988295",
"0.6094547",
"0.60850... | 0.6344343 | 7 |
Retrieves available os_tpls from the model. | def get_os_templates
@model.get.mixins.select { |mixin| mixin.related.select { |rel| rel.end_with? 'os_tpl' }.any? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @otps = Otp.all\n end",
"def index\n @os_types = OsType.all\n end",
"def list_os_tpl\n filters = []\n filters << { name: 'image-type', values: ['machine'] }\n filters << { name: 'image-id', values: @image_filtering_image_list } if IMAGE_FILTERING_POLICIES_LISTED.include... | [
"0.66119236",
"0.61167836",
"0.5930667",
"0.55483913",
"0.55057704",
"0.5491602",
"0.53610384",
"0.53115463",
"0.52023",
"0.51256156",
"0.51229453",
"0.5073297",
"0.5066521",
"0.5062969",
"0.505601",
"0.5055738",
"0.5055738",
"0.5018897",
"0.49838662",
"0.49722463",
"0.496967... | 0.52801335 | 8 |
Retrieves available resource_tpls from the model. | def get_resource_templates
@model.get.mixins.select { |mixin| mixin.related.select { |rel| rel.end_with? 'resource_tpl' }.any? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_resource_tpl\n @resource_tpl\n end",
"def resource_list\n self.resources\n end",
"def resources\n return @resources\n end",
"def resources\n return @resources\n end",
"def resources\n return @resources\n ... | [
"0.6471842",
"0.6261758",
"0.5737077",
"0.5737077",
"0.5737077",
"0.57069266",
"0.56951815",
"0.56611663",
"0.56594324",
"0.5631535",
"0.5616914",
"0.5565891",
"0.5564209",
"0.5559923",
"0.555733",
"0.5487962",
"0.54526114",
"0.5382644",
"0.537395",
"0.53714687",
"0.53413194"... | 0.6003903 | 2 |
Sets media type. Will choose either application/occi+json or text/plain based on the formats supported by the server. | def set_media_type
media_types = self.class.head(@endpoint).headers['accept']
Occi::Log.debug("Available media types: #{media_types}")
@media_type = case media_types
when /application\/occi\+json/
'application/occi+json'
else
'text/plain'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_type ctype=nil\n @content_type = ctype if ctype\n @content_type ||=\n \"#{self.class.media_type}/#{self.class.api_name}+#{@env['kiwi.format']}\"\n end",
"def set_content_type\n format = settings[:format] = params[:format].to_sym\n content_type content_types[format]\n end",
... | [
"0.7306967",
"0.7081636",
"0.6980447",
"0.69575226",
"0.69351524",
"0.6924226",
"0.68415236",
"0.68415236",
"0.68244916",
"0.6807563",
"0.6763445",
"0.6716374",
"0.66997755",
"0.6679754",
"0.66793036",
"0.6673945",
"0.66519827",
"0.66429466",
"0.6641115",
"0.66336405",
"0.662... | 0.88380545 | 0 |
Generates a humanreadable response message based on the HTTP response code. | def response_message(response)
@last_response = response
'HTTP Response status: [' + response.code.to_s + '] ' + reason_phrase(response.code)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_code_message(response_code)\n case response_code\n when 1\n \"Success\"\n when 2\n \"Error\"\n when 3\n \"Server Too Busy\"\n when 4\n \"Protocol Error\"\n when 5\n \"Operation Not Supported\"\n when 6\n \"Recursion Count Too... | [
"0.8226038",
"0.7770849",
"0.7633927",
"0.7080703",
"0.70004135",
"0.69469523",
"0.6858639",
"0.68527424",
"0.67523706",
"0.66270095",
"0.66270095",
"0.66270095",
"0.6576122",
"0.6544994",
"0.6522589",
"0.6458999",
"0.6457684",
"0.644042",
"0.64309216",
"0.64275944",
"0.64014... | 0.7045315 | 5 |
Fields Values tpArma : 0 Uso permitido; 1 Uso restrito; | def initialize(attrs = {})
# Tipo de Arma
@kind = attrs[:tpArma]
# Serie
@serie = attrs[:nSerie]
# Cano
@barrel = attrs[:nCano]
# Descricao
@description = attrs[:descr]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def campoord_inicial\n 'fecharec'\n end",
"def formata_valor_abatimento(tamanho = 13)\n format_value(:valor_abatimento, tamanho)\n end",
"def mc_cop_aae_alt_aae(row)\n #se copertura:arboreo,arbustivo ed erbaceo == 0, le altezze rispettive devono essere null [Presi singolarmente]\n #a ... | [
"0.5674164",
"0.55173147",
"0.5446915",
"0.5426774",
"0.540927",
"0.53601927",
"0.5344993",
"0.5312879",
"0.52759033",
"0.52449137",
"0.5227873",
"0.5226284",
"0.51891553",
"0.5179375",
"0.516617",
"0.51629794",
"0.51572335",
"0.51319295",
"0.5114985",
"0.5087379",
"0.5071145... | 0.0 | -1 |
GET /employees_courses GET /employees_courses.json | def index
@employees_courses = EmployeesCourse.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end",
"def index\n\t\t@courses = Course.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @courses }\n\t\t... | [
"0.7282056",
"0.7093469",
"0.6999676",
"0.6976667",
"0.68742204",
"0.68742204",
"0.6874116",
"0.6848213",
"0.68420035",
"0.68248683",
"0.68147564",
"0.68008804",
"0.6742614",
"0.6714613",
"0.66907656",
"0.66861355",
"0.66812384",
"0.66668737",
"0.66541517",
"0.6651596",
"0.66... | 0.73660785 | 0 |
GET /employees_courses/1 GET /employees_courses/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do |format|\n format.json { render json: @courses }\n end\n end",
"def index\n @employees_courses = EmployeesCourse.all\n end",
"def index\n @courses = Course.all\n render json: @courses, s... | [
"0.7301036",
"0.7217574",
"0.70010316",
"0.6949505",
"0.691728",
"0.69040585",
"0.69040585",
"0.68803537",
"0.68727565",
"0.6860377",
"0.6775294",
"0.67416734",
"0.67115134",
"0.6642404",
"0.66336876",
"0.66256374",
"0.66235274",
"0.66015244",
"0.6587697",
"0.65312487",
"0.64... | 0.0 | -1 |
POST /employees_courses POST /employees_courses.json | def create
@employees_course = EmployeesCourse.new(employees_course_params)
respond_to do |format|
if @employees_course.save
format.html { redirect_to @employees_course, notice: 'Employees course was successfully created.' }
format.json { render :show, status: :created, location: @employees_course }
else
format.html { render :new }
format.json { render json: @employees_course.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # render plain: params[:courses].inspect\n @courses = Courses.new(courses_params)\n\n respond_to do |format|\n if @courses.save\n format.html { redirect_to @courses, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @cour... | [
"0.6910871",
"0.6702445",
"0.6649024",
"0.65967023",
"0.6588424",
"0.65450495",
"0.6512265",
"0.6501965",
"0.6476073",
"0.647102",
"0.64575523",
"0.64249516",
"0.64211714",
"0.64192003",
"0.64189523",
"0.64103806",
"0.6395128",
"0.6394402",
"0.63934445",
"0.63852435",
"0.6381... | 0.740562 | 0 |
PATCH/PUT /employees_courses/1 PATCH/PUT /employees_courses/1.json | def update
respond_to do |format|
if @employees_course.update(employees_course_params)
format.html { redirect_to @employees_course, notice: 'Employees course was successfully updated.' }
format.json { render :show, status: :ok, location: @employees_course }
else
format.html { render :edit }
format.json { render json: @employees_course.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @people_course.update(people_course_params)\n format.html { redirect_to @people_course, notice: 'People course was successfully updated.' }\n format.json { render :show, status: :ok, location: @people_course }\n else\n format.html { render ... | [
"0.6617335",
"0.65584505",
"0.6534825",
"0.64913106",
"0.6380788",
"0.63575864",
"0.6347183",
"0.63464504",
"0.6316902",
"0.630994",
"0.6300922",
"0.62957674",
"0.6293419",
"0.6285283",
"0.628249",
"0.6281093",
"0.627873",
"0.6277494",
"0.6276635",
"0.6276635",
"0.6276635",
... | 0.7268662 | 0 |
DELETE /employees_courses/1 DELETE /employees_courses/1.json | def destroy
@employees_course.destroy
respond_to do |format|
format.html { redirect_to employees_courses_url, notice: 'Employees course was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @lab_course = LabCourse.find(params[:id])\n @lab_course.destroy\n\n respond_to do |format|\n format.html { redirect_to lab_courses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_course.destroy\n respond_to do |format|\n format.html { r... | [
"0.7250819",
"0.716362",
"0.7140621",
"0.7129735",
"0.7129735",
"0.7129735",
"0.7129735",
"0.71178794",
"0.71085334",
"0.71012354",
"0.70828307",
"0.70738924",
"0.70675176",
"0.7064452",
"0.706285",
"0.7058525",
"0.7053691",
"0.7052165",
"0.70478106",
"0.7047593",
"0.7047593"... | 0.74800825 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_employees_course
@employees_course = EmployeesCourse.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def employees_course_params
params[:employees_course]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
==========Validating book, with unique UUID================================================= | def validate_books
csv_text = open(file.url)
csv = CSV.parse(csv_text, :headers => true)
csv.each do |row|
book_hash = Book.new
book_hash.title = row["Book title"]
book_hash.author = Author.find_or_create_by(name: row["Book author"])
book_hash.published_at = Date.parse(row["Date published"])
book_hash.uuid = row["Unique identifier for the book"]
book_hash.publisher_name = row["Publisher name"]
book_hash.user_id = user_id
unless book_hash.valid?
self.errors[:base] << "UUID Already exist for #{row["Unique identifier for the book"]}"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_uuid_format?(uuid)\n !!(uuid =~ /^[A-Za-z0-9_\\-]{16,}$/)\n end",
"def uuid?(uuid)\n uuid_regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/\n uuid_regex.match?(uuid.to_s.downcase)\nend",
"def test_unique_book_isbn\n \n book = Book.new(:title =>... | [
"0.67580456",
"0.6702425",
"0.6605779",
"0.6515341",
"0.6489125",
"0.6405775",
"0.63885117",
"0.6324985",
"0.62857693",
"0.6285451",
"0.6285451",
"0.62851685",
"0.62572175",
"0.62572175",
"0.6249086",
"0.6175638",
"0.616393",
"0.6134245",
"0.5933415",
"0.5877097",
"0.5877097"... | 0.69789755 | 0 |
Write your code here. | def batch_badge_creator (attendees)
attendees.collect do |name| badge_maker (name)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def run\n \n end",
"def run\n \n end",
"def method\n\t\t# code code\n\tend",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"... | [
"0.7117752",
"0.7117752",
"0.7117752",
"0.7117752",
"0.7117752",
"0.7117752",
"0.7117752",
"0.6527089",
"0.6527089",
"0.6524399",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.6418008",
"0.6343... | 0.0 | -1 |
define mothods ==, greater then >, less then < | def ==(other)
@value = other
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operator; end",
"def >=(other); end",
"def <=(other); end",
"def define_comparison_method(methods)\n define_method(:cmp?) do |comparator, other|\n methods.all? { |method| send(method).send(comparator, other.send(method)) }\n end\n end",
"def comparison_op\n match(%w(== != > >= < ... | [
"0.6768962",
"0.6676357",
"0.65216523",
"0.6515424",
"0.64881575",
"0.63542193",
"0.63537806",
"0.62864095",
"0.6270962",
"0.6234819",
"0.6209086",
"0.62059563",
"0.619499",
"0.61385083",
"0.61215836",
"0.6112204",
"0.6090393",
"0.6090393",
"0.6088981",
"0.60871416",
"0.60675... | 0.0 | -1 |
INSTANCE METHODS Returns the date the last email of a specified category was sent | def email_sent_at(category)
emails = self.email_logs.select {|e| e.category == category}
emails.collect {|e| e.created_at}.sort.last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emails_sent_at(category)\r\n emails = self.email_logs.select {|e|e.category == category}\r\n emails.collect {|e| e.created_at}.sort\r\n end",
"def last_contacted\n object.channels.where(is_private: true).first.last_message_time\n end",
"def last_delivered_date_time\n return @last_... | [
"0.6987794",
"0.6244684",
"0.60381854",
"0.60023266",
"0.59639037",
"0.59062535",
"0.58860993",
"0.58854175",
"0.57728815",
"0.5771505",
"0.5694127",
"0.5636091",
"0.5574436",
"0.5558278",
"0.55399436",
"0.54809076",
"0.5477554",
"0.5466854",
"0.54450583",
"0.5421657",
"0.540... | 0.80622375 | 0 |
Returns an array of the dates the email of a specified category was sent | def emails_sent_at(category)
emails = self.email_logs.select {|e|e.category == category}
emails.collect {|e| e.created_at}.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_sent_at(category)\r\n emails = self.email_logs.select {|e| e.category == category}\r\n emails.collect {|e| e.created_at}.sort.last\r\n end",
"def emails(category = nil)\r\n return category ? self.email_logs.select {|e| e.category == category} : self.email_logs\r\n end",
"def get_mails\n ... | [
"0.8045334",
"0.7213177",
"0.59212357",
"0.5675265",
"0.56417847",
"0.5412332",
"0.53950673",
"0.5337325",
"0.5273472",
"0.527337",
"0.52124107",
"0.52004474",
"0.51962835",
"0.5196167",
"0.5133509",
"0.50920033",
"0.5091613",
"0.5084544",
"0.5077146",
"0.5075498",
"0.5065847... | 0.8071173 | 0 |
Returns all emails or all emails of a specified category (if given) | def emails(category = nil)
return category ? self.email_logs.select {|e| e.category == category} : self.email_logs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_sent_at(category)\r\n emails = self.email_logs.select {|e| e.category == category}\r\n emails.collect {|e| e.created_at}.sort.last\r\n end",
"def index\n @emails = Email.where(\"category=?\", current_user.id%2).paginate(:page => params[:page])\n # @emails = Email.where(\"category=?\", curr... | [
"0.62495255",
"0.61910415",
"0.6139023",
"0.6003403",
"0.56699127",
"0.5651843",
"0.5591714",
"0.55803734",
"0.54984456",
"0.5470508",
"0.5468105",
"0.5408793",
"0.53955835",
"0.53639007",
"0.5339856",
"0.5300101",
"0.52669877",
"0.52366275",
"0.5226064",
"0.5197954",
"0.5150... | 0.8209447 | 0 |
Public: Initialize an Pot. params A Hash of pot parameters. | def initialize(params)
@id = params[:id]
@name = params[:name]
@style = params[:style]
@balance = params[:balance]
@currency = params[:currency]
@created = params[:created]
@updated = params[:updated]
@deleted = params[:deleted]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(params:, robot:, surface:)\n self.params = Hash[*[self.class::PARAMS_CONFIG, params].transpose.flatten(1)]\n self.robot = robot\n self.surface = surface\n end",
"def initialize(params = {})\n parameters(params)\n end",
"def initialize(params={})\n\t\t\t\tparams.... | [
"0.6911692",
"0.670716",
"0.6407503",
"0.6378588",
"0.6344991",
"0.6344991",
"0.6267009",
"0.62593484",
"0.6170548",
"0.6168719",
"0.6154312",
"0.61437327",
"0.61195296",
"0.6116495",
"0.6112937",
"0.6112329",
"0.61016273",
"0.6084338",
"0.6073246",
"0.60727644",
"0.6063524",... | 0.0 | -1 |
Public: Deposit Money in a pot amount The amount to deposit, in pennies. source_account_id The account_id of the account to withdraw from. dedupe_id (optional) A random string, to prevent duplicate deposits. Returns self: a single Monzo::Pot | def deposit!(amount, source_account_id, dedupe_id = SecureRandom.uuid)
data = {
amount: amount,
source_account_id: source_account_id,
dedupe_id: dedupe_id,
}
response = Monzo.client.put("/pots/#{@id}/deposit", data)
parsed_response = parse_response(response)
update_self(parsed_response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def withdraw!(amount, destination_account_id, dedupe_id = SecureRandom.uuid)\n data = {\n amount: amount,\n destination_account_id: destination_account_id,\n dedupe_id: dedupe_id,\n }\n\n response = Monzo.client.put(\"/pots/#{@id}/withdraw\", data)\n parsed_response = parse... | [
"0.63066536",
"0.54378045",
"0.52988845",
"0.5282323",
"0.5272958",
"0.52329355",
"0.5188685",
"0.51588774",
"0.5135322",
"0.5135322",
"0.5124892",
"0.50152",
"0.49326217",
"0.4913594",
"0.49131262",
"0.49029785",
"0.48937592",
"0.4889848",
"0.48779532",
"0.4859872",
"0.48578... | 0.78251565 | 0 |
Public: Withdraw Money from a pot amount The amount to withdraw, in pennies. destination_account_id The account_id of the account to deposit into. dedupe_id (optional) A random string, to prevent duplicate deposits. Returns self: a single Monzo::Pot | def withdraw!(amount, destination_account_id, dedupe_id = SecureRandom.uuid)
data = {
amount: amount,
destination_account_id: destination_account_id,
dedupe_id: dedupe_id,
}
response = Monzo.client.put("/pots/#{@id}/withdraw", data)
parsed_response = parse_response(response)
update_self(parsed_response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deposit!(amount, source_account_id, dedupe_id = SecureRandom.uuid)\n data = {\n amount: amount,\n source_account_id: source_account_id,\n dedupe_id: dedupe_id,\n }\n\n response = Monzo.client.put(\"/pots/#{@id}/deposit\", data)\n parsed_response = parse_response(respons... | [
"0.70585525",
"0.5388718",
"0.5341916",
"0.5332373",
"0.51238686",
"0.51234907",
"0.51031196",
"0.5100767",
"0.5096095",
"0.50661516",
"0.50661516",
"0.50245917",
"0.49921238",
"0.49921238",
"0.498018",
"0.49618948",
"0.495959",
"0.49303898",
"0.48987123",
"0.48985964",
"0.48... | 0.7733153 | 0 |
Private: Update the Pot instance variables parsed_response a hash whose keys exactly match the instance variables for Monzo::Pot. Returns self (an instance of Monzo::Pot) | def update_self(parsed_response)
instance_variables.each do |iv|
instance_variable_set(iv, parsed_response[iv.to_s[1..-1].to_sym])
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pot\n @pot = Pot.find(params[:id])\n end",
"def set_pot\n @pot = Pot.find(params[:pot_id])\n end",
"def parse_response(response)\n response = sanitize_response_keys(response.parsed_response)\n end",
"def update\n pot = Pot.find_by(game_id: params[:id])\n\n player... | [
"0.5730362",
"0.5544215",
"0.5327246",
"0.5315911",
"0.53124005",
"0.5204266",
"0.51660633",
"0.51212996",
"0.50939006",
"0.5052703",
"0.50027585",
"0.49511257",
"0.49487406",
"0.4944145",
"0.4937013",
"0.4935006",
"0.49239412",
"0.4900529",
"0.48654515",
"0.48588693",
"0.485... | 0.6521878 | 0 |
Initializes a FSEvent worker and adds a watcher for each directory passed to the adapter. | def init_worker
FSEvent.new.tap do |worker|
worker.watch(@directories.dup, :latency => @latency) do |changes|
next if @paused
@mutex.synchronize do
changes.each { |path| @changed_dirs << path.sub(LAST_SEPARATOR_REGEX, '') }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_worker\n worker = FChange::Notifier.new\n @directories.each do |directory|\n watcher = worker.watch(directory, :all_events, :recursive) do |event|\n next if @paused\n @mutex.synchronize do\n @changed_dirs << File.expand_path(event.watcher.path)\n ... | [
"0.8124498",
"0.78232884",
"0.7797833",
"0.7709866",
"0.73683584",
"0.73361504",
"0.7202465",
"0.7145659",
"0.6529733",
"0.65076244",
"0.6358155",
"0.61851114",
"0.6147244",
"0.61304307",
"0.6000078",
"0.5930538",
"0.58909774",
"0.58385676",
"0.58384943",
"0.5820677",
"0.5814... | 0.7931124 | 1 |
GET /providers GET /providers.json | def index
@providers = current_company.providers.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @providers }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def providers(params = {})\n response = default_scope.get('providers/') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end",
"def providers\n url = url_with_api_version(@base_url, 'providers')\n resp = rest_get(url)\n JSON.parse(resp.body)... | [
"0.7952771",
"0.76017314",
"0.72677416",
"0.7190118",
"0.706321",
"0.70238805",
"0.6972535",
"0.6780555",
"0.6780555",
"0.6702626",
"0.6662831",
"0.6654126",
"0.66216713",
"0.65760744",
"0.6559313",
"0.65415585",
"0.6507612",
"0.6411908",
"0.6400059",
"0.6364796",
"0.63533163... | 0.72843695 | 2 |
GET /providers/1 GET /providers/1.json | def show
@provider = current_company.providers.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @provider }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def providers(params = {})\n response = default_scope.get('providers/') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end",
"def index\n @providers = current_company.providers.all\n\n respond_to do |format|\n format.html # index.html.erb\n for... | [
"0.7272243",
"0.71885544",
"0.7069674",
"0.7069674",
"0.7021322",
"0.7003939",
"0.6984918",
"0.69745284",
"0.6815935",
"0.68077725",
"0.6729551",
"0.663642",
"0.6533136",
"0.6529574",
"0.649691",
"0.649691",
"0.6464657",
"0.6430917",
"0.6402912",
"0.63958097",
"0.634581",
"... | 0.72955817 | 0 |
GET /providers/new GET /providers/new.json | def new
@provider = current_company.providers.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @provider }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end",
"def new\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\... | [
"0.8272507",
"0.80500466",
"0.80500466",
"0.7682416",
"0.7482539",
"0.74049795",
"0.7310524",
"0.7274704",
"0.7225364",
"0.7138865",
"0.71240705",
"0.70831877",
"0.70654607",
"0.7050149",
"0.6999865",
"0.6998997",
"0.694804",
"0.6858532",
"0.6855384",
"0.68447495",
"0.6811392... | 0.8236406 | 1 |
POST /providers POST /providers.json | def create
@provider = current_company.providers.new(params[:provider])
respond_to do |format|
if @provider.save
format.html { redirect_to @provider, notice: 'Provider was successfully created.' }
format.json { render json: @provider, status: :created, location: @provider }
else
format.html { render action: "new" }
format.json { render json: @provider.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @provider = Provider.new(provider_params)\n\n if @provider.save\n render json: @provider, status: :created, location: @provider\n else\n render json: @provider.errors, status: :unprocessable_entity\n end\n end",
"def create\n @provider = Provider.new(params[:provider])\n\n ... | [
"0.7196066",
"0.6896307",
"0.6886106",
"0.6805139",
"0.67927444",
"0.6713015",
"0.6592217",
"0.65495884",
"0.64063054",
"0.63403493",
"0.6326314",
"0.63182",
"0.6274265",
"0.62492526",
"0.6234781",
"0.6211055",
"0.6205681",
"0.618968",
"0.61692774",
"0.61692774",
"0.6157692",... | 0.69564795 | 1 |
PUT /providers/1 PUT /providers/1.json | def update
@provider = current_company.providers.find(params[:id])
respond_to do |format|
if @provider.update_attributes(params[:provider])
format.html { redirect_to @provider, notice: 'Provider was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @provider.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @provider = Provider.find(params[:id])\n\n if @provider.update(provider_params)\n head :no_content\n else\n render json: @provider.errors, status: :unprocessable_entity\n end\n end",
"def update_provider!(provider, provider_info = {}, access = {})\n Api::Request.new do |r... | [
"0.69004023",
"0.6817214",
"0.6646538",
"0.6624912",
"0.6624912",
"0.6613555",
"0.6586571",
"0.644157",
"0.64100003",
"0.63752437",
"0.6365661",
"0.63542736",
"0.6322013",
"0.6146228",
"0.61225057",
"0.6073541",
"0.6050184",
"0.6047935",
"0.60016364",
"0.5998813",
"0.5991263"... | 0.68262064 | 1 |
DELETE /providers/1 DELETE /providers/1.json | def destroy
@provider = current_company.providers.find(params[:id])
@provider.destroy
respond_to do |format|
format.html { redirect_to providers_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @provider = Provider.find(params[:id])\n @provider.destroy\n\n respond_to do |format|\n format.html { redirect_to providers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @provider.destroy\n respond_to do |format|\n format.html { redirect_to provider... | [
"0.7473128",
"0.74667734",
"0.74512416",
"0.74512416",
"0.74512416",
"0.73346823",
"0.72772837",
"0.72772837",
"0.72772837",
"0.7225288",
"0.7218178",
"0.7041858",
"0.7011474",
"0.69845635",
"0.6982556",
"0.6958283",
"0.6934727",
"0.6932733",
"0.6914863",
"0.6914221",
"0.6895... | 0.73810977 | 5 |
Use cssstyle padding declaration, i.e. 10 (all sides) 10 5 (top/bottom, left/right) 10 5 10 (top, left/right, bottom) 10 5 10 5 (top, right, bottom, left) | def parse_padding_string(str)
padding_parts = str.gsub('px','').split(/\s+/).map{|px| px.to_i}
case padding_parts.size
when 1
p = padding_parts.first
[p,p,p,p]
when 2
p,q = padding_parts
[p,q,p,q]
when 3
p,q,r = padding_parts
[p,q,r,q]
when 4
padding_parts
else raise ArgumentError, "Couldn't parse padding string '#{str}' - should be a css-style string"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_padding(value)\n values = Array(value)\n sides = %i[top right bottom left]\n\n # Treat :margin as CSS shorthand with 1-4 values.\n positions = {\n 4 => [0, 1, 2, 3], 3 => [0, 1, 2, 1],\n 2 => [0, 1, 0, 1], 1 => [0, 0, 0, 0],\n 0 => []\n }[va... | [
"0.7250208",
"0.704926",
"0.6977006",
"0.6965564",
"0.68581045",
"0.6857524",
"0.6857524",
"0.6807115",
"0.67163956",
"0.66191053",
"0.66191053",
"0.66191053",
"0.66191053",
"0.6576584",
"0.6512658",
"0.6434529",
"0.6215733",
"0.61662763",
"0.61662763",
"0.6143774",
"0.611730... | 0.6174092 | 17 |
Use callbacks to share common setup or constraints between actions. | def set_ghost_log
@ghost_log = BattleLog.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def ghost_log_params
params.require(:ghost_log).permit(:battle_id, :description, :utility_type, :bMessage, :user_id, :pet_id, :item_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def user_params
params.require(:user).permit(:email, :password, :name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7123669",
"0.7054077",
"0.69472784",
"0.6902165",
"0.6736001",
"0.671985",
"0.6687218",
"0.6676269",
"0.66602534",
"0.6556639",
"0.6527985",
"0.645892",
"0.645072",
"0.64494324",
"0.6445436",
"0.64350927",
"0.6415061",
"0.6415061",
"0.6393001",
"0.6378958",
"0.6378958",
... | 0.0 | -1 |
rule: each UUID consists of 32 hexademical characters, typically into 5 section like: "f65c57f6a6aa17a8faa1a67f2dc9fa91" | def generate_UUID
characters = []
(0..9).each { |digit| characters << digit.to_s }
('a'..'f').each { |digit| characters << digit }
uuid = ""
sections = [8, 4, 4, 4, 12] # integers representing the number of characters in each section
sections.each_with_index do |section, index|
section.times { uuid += characters.sample }
uuid += '-' unless index >= sections.size - 1 # index >= 4
end
uuid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uuid2\n hexchars = (('0'..'9').to_a).concat(('a'..'f').to_a)\n sections = [8, 4, 4, 4, 12]\n result = ''\n\n sections.each do |section|\n section.times do\n result << hexchars.sample.to_s\n end\n result << '-'\n end\n\n result.chop # to cut off trailing char\nend",
"def uuid_method\nh... | [
"0.7799495",
"0.7649068",
"0.7612097",
"0.7478002",
"0.7441284",
"0.7414751",
"0.7398642",
"0.7385393",
"0.7306251",
"0.72930104",
"0.7287261",
"0.72737557",
"0.7272527",
"0.7268871",
"0.72629714",
"0.7260032",
"0.7249609",
"0.72369576",
"0.72293633",
"0.721839",
"0.7216759",... | 0.7324725 | 8 |
run state to perform validations for | def aasm_states_to_check
started? || aasm_event == 'start' || ignore_states
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_validations\n true\n end",
"def validate!\n # pass\n end",
"def validate\n \n \n end",
"def validate\r\n\r\n end",
"def run_validations\n run_callbacks :validation do\n failed_validators.clear\n validation_chain.run(self)\n @validat... | [
"0.6959219",
"0.6887224",
"0.68273747",
"0.6814786",
"0.68040824",
"0.67583615",
"0.6722753",
"0.6713828",
"0.668381",
"0.66754466",
"0.6671527",
"0.66414136",
"0.66309375",
"0.66309375",
"0.66309375",
"0.6621335",
"0.66170293",
"0.6614299",
"0.66137165",
"0.660946",
"0.66094... | 0.0 | -1 |
it can start if all requests are valid | def validate_can_start
if aasm_states_to_check
cannot_start! if requests_have_notices?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_requests\n if requests.empty?\n errors.add('requests', 'there were no requests')\n return\n end\n\n requests.each do |request|\n next if request.valid?\n\n request.errors.each do |k, v|\n errors.add(k, v)\n end\n end\n ... | [
"0.6673162",
"0.61371994",
"0.60237217",
"0.5910861",
"0.5910861",
"0.58853775",
"0.58444864",
"0.58149236",
"0.5792667",
"0.5693341",
"0.56818587",
"0.5677432",
"0.5666639",
"0.5664971",
"0.5627509",
"0.5614598",
"0.5600875",
"0.5568299",
"0.5568299",
"0.5558949",
"0.5557413... | 0.6370992 | 1 |
it creates a random arrays of array of random numbers beetween the desviation and the points wishes. Also add a wish_ouput to use after in neuronal networs | def initialize(desviation, quantity, x, y, z, wish_output)
if !z
initialize_2d(desviation, quantity, x, y, wish_output)
else
initalize_3d(desviation, quantity, x, y, z, wish_output)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rand_population(n)\r\n\t\treturn Array.new(n) { Snek.new(@start_x,@start_y, Array.new(@nb_heuristic) { @random.rand(-5.0..5.0) }) }\r\n\tend",
"def prox\n\t\trandom_weighted @jugadas\n\t\t\n\tend",
"def generate\n #create random number generator\n rng = Random.new\n @points = Array.new\n\n #num... | [
"0.6243649",
"0.59217685",
"0.5893277",
"0.5856784",
"0.5776432",
"0.5721965",
"0.56852",
"0.5674304",
"0.56340545",
"0.5625456",
"0.55678463",
"0.5542437",
"0.55388623",
"0.55388623",
"0.5529226",
"0.55228037",
"0.545155",
"0.54489034",
"0.54425913",
"0.5438104",
"0.54278755... | 0.0 | -1 |
Function for 2d points, x and y | def initialize_2d(desviacion, cantidad, xpos, ypos, yd)
@matrix = []
cantidad.times do
@matrix << ([xpos + 2 * desviacion * rand - desviacion, ypos + 2 * desviacion * rand - desviacion, yd])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def point(x,y)\n [x,y]\nend",
"def to_xy\n [x, y]\n end",
"def Point2dFromXY(arg0, arg1)\n ret = _invoke(1610743822, [arg0, arg1], [VT_R8, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end",
"def draw_points(x0, y0, x1, y1)\n\t\t# Get array of points on line\n\t\tpoints = get_line(x0,x1... | [
"0.7030014",
"0.6635354",
"0.64439845",
"0.6437325",
"0.62981975",
"0.6279076",
"0.62583995",
"0.619676",
"0.61566496",
"0.615411",
"0.61453784",
"0.6118823",
"0.60863805",
"0.6083407",
"0.6077611",
"0.60636264",
"0.6033049",
"0.6029379",
"0.6028767",
"0.60246813",
"0.6001519... | 0.0 | -1 |
Function for 3d points, x, y and z | def initalize_3d(desviacion, cantidad, xpos, ypos, zpos, yd)
@matrix = Array.new
cantidad.times do
@matrix.push([xpos + 2 * desviacion * rand - desviacion, ypos + 2 * desviacion * rand - desviacion, zpos + 2 * desviacion * rand - desviacion, yd])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_point3d(pt)\n case pt\n when Array\n pt_a = pt.map(&:to_f)\n x, y, z = pt_a\n z ||= 0.0\n Point3d.new(x, y, z)\n when Point3d\n pt\n when WIN32OLE_RECORD\n Point3d.from_ole(pt) if pt.typename == \"Point3d\"\n end\n end",
"def to_ole_poi... | [
"0.71749216",
"0.6974889",
"0.693681",
"0.6843874",
"0.6802184",
"0.67917955",
"0.6784242",
"0.6745902",
"0.6725012",
"0.67101145",
"0.67022556",
"0.66521394",
"0.659573",
"0.65872043",
"0.65732133",
"0.65732133",
"0.65595686",
"0.655315",
"0.65271926",
"0.65048665",
"0.64970... | 0.0 | -1 |
watch all exist files modify event. | def start_watch_files
coffee_files.each do |file|
@notifier.watch(file, :modify) do
CoffeeCompiler.compile_file(file, true, true)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listen_for_changes\n @semaphore.synchronize do\n @files_alive = []\n\n paths = initialize_paths(@paths, @dirs)\n directories = handle_paths(paths)\n if @opts[:recurse]\n update_changed_files(directories)\n end\n\n deleted_files = @file_cache.keys - @files... | [
"0.71931547",
"0.71086633",
"0.70951724",
"0.70945454",
"0.70710593",
"0.7065802",
"0.70382",
"0.702989",
"0.6975102",
"0.68732846",
"0.6819397",
"0.67969084",
"0.6793798",
"0.67830676",
"0.6729054",
"0.6675304",
"0.6675304",
"0.66505307",
"0.66266274",
"0.6611319",
"0.653203... | 0.70518184 | 6 |
return the version of the package TODO deal with multiple publishers | def latest
version = nil
pkg(:list, "-Ha", @resource[:name]).each_line do |line|
v = parse_line(line.chomp)[:status]
case v
when "known"
return v
when "installed"
version = v
else
Puppet.warn "unknown package state for #{@resource[:name]}: #{v}"
end
end
version
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_version\n @semver.to_s '%M.%m.%p%s'\n end",
"def version(packagename)\n\t\t\t\treturn(packages()[packagename].version)\n\t\t\tend",
"def version\n @version ||= if token.nil? || Array(packages).empty?\n '0.1.0'\n else\n p... | [
"0.7481352",
"0.73648554",
"0.73506063",
"0.73107624",
"0.7064462",
"0.6987189",
"0.6973328",
"0.693692",
"0.68902993",
"0.68707144",
"0.6868122",
"0.6843051",
"0.6841027",
"0.68358505",
"0.6825646",
"0.68088144",
"0.6806174",
"0.6798599",
"0.6782503",
"0.67744935",
"0.677350... | 0.66101414 | 72 |
update the package to the latest version available | def update
self.install
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n install\n end",
"def update\n # Install in pacman can be used for update, too\n self.install\n end",
"def update\n # Install in pacman can be used for update, too\n self.install\n end",
"def update!(**args)\n @package_name = args[:package_name] if args.key?(:package_na... | [
"0.7670873",
"0.7574621",
"0.7574621",
"0.7141967",
"0.6950891",
"0.687627",
"0.6835481",
"0.67902696",
"0.6747972",
"0.6730853",
"0.67028064",
"0.66699004",
"0.66044164",
"0.6574911",
"0.6557067",
"0.6554257",
"0.65267116",
"0.6522931",
"0.64822567",
"0.6467083",
"0.6465875"... | 0.72198856 | 4 |
list a specific package | def query
begin
output = pkg(:list, "-H", @resource[:name])
rescue Puppet::ExecutionFailure
# pkg returns 1 if the package is not found.
return {:ensure => :absent, :name => @resource[:name]}
end
hash = self.class.parse_line(output.chomp) || {:ensure => :absent, :name => @resource[:name]}
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_packages\n res = []\n out = Aptly::runcmd \"aptly mirror show -with-packages #{@name.quote}\"\n Aptly::parse_indented_list out.lines\n end",
"def packages\n FileList[package_path('.*')]\n end",
"def package_list(packages, version)\n Array(packages[:base]).join(' ') + ' ' + Arr... | [
"0.72322726",
"0.69187444",
"0.68011403",
"0.6794119",
"0.6770573",
"0.66273046",
"0.6320337",
"0.6291789",
"0.6259277",
"0.62124026",
"0.61893344",
"0.6161955",
"0.61603963",
"0.6127052",
"0.61255234",
"0.6121941",
"0.607312",
"0.60133165",
"0.6004784",
"0.6002743",
"0.60027... | 0.0 | -1 |
Cache the transposed vector, it gets used a lot | def transposed_search_vector
@transposed_search_vector ||= super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache\n @transpose\n end",
"def transposed(matrix, size)\n # TODO (Step 2): Implement on CPU\n return [1.0, 2.0, 3.0, 4.0]\nend",
"def transpose() end",
"def transpose\n Matrix[self.to_a]\n end",
"def transpose; end",
"def transpose(matrix)\n matrix[0][0], matrix[1][0], matrix[2][0], m... | [
"0.726309",
"0.6704453",
"0.66432786",
"0.66375405",
"0.661326",
"0.6556241",
"0.64950514",
"0.6457604",
"0.6386165",
"0.6369163",
"0.6305857",
"0.6291343",
"0.6288887",
"0.61494726",
"0.61116374",
"0.6098272",
"0.60681313",
"0.6062541",
"0.605699",
"0.60386384",
"0.603795",
... | 0.612385 | 14 |
Clear the cache before we continue on | def raw_vector_with(word_list)
clear_cache!
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_cache; end",
"def clear_cache() @cache = {}; end",
"def clear_cache!\n @cache = {}\n end",
"def clear_cache!\n @cache = {}\n end",
"def clear\n cache.clear\n end",
"def clear_cache\n @cache = {}\n end",
"def clear\r\n @cache.flu... | [
"0.8854878",
"0.8634191",
"0.85568637",
"0.85568637",
"0.8543571",
"0.849489",
"0.8375541",
"0.83753085",
"0.8345576",
"0.8217096",
"0.8191377",
"0.8136908",
"0.80884296",
"0.80801725",
"0.80136675",
"0.8001174",
"0.7894996",
"0.7894996",
"0.78758943",
"0.7863244",
"0.7832587... | 0.0 | -1 |
We don't want the cached_data here | def marshal_dump
[@lsi_vector, @lsi_norm, @raw_vector, @raw_norm, @categories, @word_hash]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cached?; end",
"def cache(data); end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache_value?; end",
"def disable_caching=(_arg0); end",
"def cache_on?; end",
"def cache_on?; end",
"def disable_ca... | [
"0.79779893",
"0.79286397",
"0.7774408",
"0.7774408",
"0.7774408",
"0.7774408",
"0.7774408",
"0.7774408",
"0.7774408",
"0.7592871",
"0.7531231",
"0.73953855",
"0.73953855",
"0.7389803",
"0.7370729",
"0.7344182",
"0.7344182",
"0.7316475",
"0.7253996",
"0.7253996",
"0.72289556"... | 0.0 | -1 |
Is the passed candidate a better match than any of the current matches? ARG: `other` another Candidate instance to check against the current set | def better_match?( other )
return true if prefers?( other ) && free?
preference_index = preferences.index other
match_preference_indexes = matches.map { | match | preferences.index match }
preference_index and match_preference_indexes.any? { |i| i > preference_index }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a... | [
"0.68644595",
"0.6494814",
"0.6171067",
"0.61165327",
"0.6103533",
"0.60148656",
"0.59837264",
"0.59695625",
"0.59534496",
"0.5951573",
"0.5924914",
"0.591324",
"0.5906214",
"0.5900777",
"0.5891475",
"0.58822894",
"0.5877805",
"0.5814154",
"0.58112717",
"0.5763609",
"0.574657... | 0.7467674 | 0 |
Have all possible preferences been cycled through? | def exhausted_preferences?
preference_position >= preferences.size - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_options_main?\n no_preference_options.none? && not_counted_options.none?\n end",
"def has_pref?(preference)\n !prefs[preference].to_s.empty?\nend",
"def all_present?(values, preferences)\n values.map { |v| preferences.present?(key, v) }.inject(&:&)\n end",
"def check_if_all_donors_ready\n ... | [
"0.6566466",
"0.62994796",
"0.6233791",
"0.5991729",
"0.5973898",
"0.59432155",
"0.5911168",
"0.58726835",
"0.58512074",
"0.577376",
"0.5747453",
"0.57448065",
"0.5718785",
"0.567215",
"0.5671604",
"0.5659553",
"0.5609859",
"0.5583733",
"0.5580997",
"0.55703056",
"0.55646974"... | 0.7163214 | 0 |
Is there available positions for more matches based on the defined `match_positions`? | def free?
matches.length < match_positions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matched_positions\n _response_entity.fetch(\"matchingTokens\", [])\n end",
"def near_match\n (0..3).each do |guess_index|\n compare_for_near_match(guess_index)\n end\n end",
"def match_at? rexp, pos = 0\n MatchAt.match_at? self, rexp, pos\n end",
"def exact_matches(loc... | [
"0.694176",
"0.6779318",
"0.6534157",
"0.64967436",
"0.6483444",
"0.63267237",
"0.6311977",
"0.6306766",
"0.6263883",
"0.62590885",
"0.6214159",
"0.6184969",
"0.61677545",
"0.6165823",
"0.61492443",
"0.61165196",
"0.61048514",
"0.6076623",
"0.60729676",
"0.60236967",
"0.60121... | 0.61427236 | 15 |
Delete the leastpreferred candidate from the matches array | def free!
return false if matches.empty?
match_preference_indexes = matches.map { | match | preferences.index match }
max = match_preference_indexes.max # The index of the match with the lowest preference
candidate_to_reject = preferences[ max ]
# Delete from both sides
candidate_to_reject.matches.delete self
self.matches.delete candidate_to_reject
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trim(leaderboard, spectrum, n)\n lb_map = {}\n leaderboard.each do |peptide|\n linear_score = cyclopeptide_scoring_linear(peptide, spectrum)\n lb_map[peptide] = linear_score\n end\n sorted = lb_map.sort_by {|k,v| v}.reverse\n #puts sorted.join(\" \")\n for j in n..leaderboard.size-1\n if sorted[... | [
"0.6545749",
"0.60591125",
"0.5935808",
"0.59275573",
"0.5898502",
"0.58506805",
"0.5818517",
"0.5804726",
"0.57909524",
"0.5759192",
"0.5740732",
"0.56597257",
"0.56142044",
"0.5611859",
"0.55642396",
"0.55610824",
"0.55266535",
"0.55067164",
"0.5456877",
"0.5454079",
"0.544... | 0.772396 | 0 |
Are there no remaining positions available for matches? | def full?
!free?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def free?\n matches.length < match_positions\n end",
"def all_positions_full?\n available_positions.empty?\n end",
"def hit_itself?\n # list.uniq removes all repeated elements from a list\n @positions.uniq.length != @positions.length\n end",
"def finished?\n #positions = {:a => 25, :b =... | [
"0.72957855",
"0.71186346",
"0.69953686",
"0.6336867",
"0.63244295",
"0.6281883",
"0.62613785",
"0.6230664",
"0.62231404",
"0.6207515",
"0.61934894",
"0.61807793",
"0.61236614",
"0.61038893",
"0.6059299",
"0.604182",
"0.60335237",
"0.60127807",
"0.6002813",
"0.5997226",
"0.59... | 0.0 | -1 |
Match with another Candidate ARG: `other` another Candidate instance to match with | def match!( other )
return false unless prefers?( other ) && !matched?( other )
matches << other
other.matches << self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a... | [
"0.6603004",
"0.6441187",
"0.6122854",
"0.6087162",
"0.6007609",
"0.5985993",
"0.5949671",
"0.58849823",
"0.58587086",
"0.57798433",
"0.570371",
"0.56930345",
"0.5680121",
"0.56729513",
"0.5651722",
"0.55331445",
"0.55325097",
"0.55183464",
"0.5515873",
"0.5504669",
"0.549498... | 0.6870588 | 0 |
If no argument is passed: Do we have at least as many matches as available `match_positions`? If another Candidate is passed: Is that candidate included in the matches? ARG: `other` [optional] another Candidate instance | def matched?( other = nil )
return full? if other.nil?
matches.include? other
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a... | [
"0.6844583",
"0.60324234",
"0.59679455",
"0.5843598",
"0.5828867",
"0.57141393",
"0.57013077",
"0.5695834",
"0.5681551",
"0.56805193",
"0.5590659",
"0.55807596",
"0.55698407",
"0.5568948",
"0.5542452",
"0.55119556",
"0.5470464",
"0.5466821",
"0.5452096",
"0.5418991",
"0.54105... | 0.6479525 | 1 |
Increment `preference_position` and return the preference at that position | def next_preference!
self.preference_position += 1
preferences.fetch preference_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_preference(name, value); end",
"def add_preference(name, value); end",
"def increment_position\n return unless in_list?\n # in_collection.where(:pos => my_position).\n adjust!(position_key => 1) \n save!\n end",
"def set_preference\n @preference = @user.preferenc... | [
"0.5632839",
"0.5632839",
"0.55967325",
"0.54378754",
"0.5403117",
"0.53960943",
"0.5393127",
"0.53751713",
"0.5368596",
"0.5325805",
"0.5211627",
"0.5195549",
"0.51651406",
"0.51442546",
"0.5065651",
"0.49772644",
"0.4976477",
"0.4962286",
"0.4920744",
"0.49167368",
"0.49121... | 0.81344205 | 0 |
Is there a preference for the passed Candidate? ARG: `other` another Candidate instance | def prefers?( other )
preferences.include? other
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a... | [
"0.7430928",
"0.636545",
"0.6227747",
"0.62044257",
"0.61707366",
"0.6098413",
"0.60582626",
"0.6042046",
"0.5794268",
"0.5698413",
"0.5522648",
"0.5522648",
"0.5487993",
"0.54670405",
"0.5453134",
"0.54225063",
"0.54152876",
"0.5410544",
"0.5353254",
"0.5337093",
"0.53259563... | 0.686246 | 1 |
Track that a proposal was made then ask the other Candidate to respond to a proposal ARG: `other` another Candidate instance | def propose_to( other )
proposals << other
other.respond_to_proposal_from self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a... | [
"0.7188241",
"0.6226746",
"0.6129741",
"0.5652433",
"0.557418",
"0.5371597",
"0.5369692",
"0.5364737",
"0.53149235",
"0.5302787",
"0.5280947",
"0.52681935",
"0.5231875",
"0.52081865",
"0.51805854",
"0.51798797",
"0.5179091",
"0.517543",
"0.51699144",
"0.51572734",
"0.5151744"... | 0.7088853 | 1 |
Given another candidate, respond properly based on current state ARG: `other` another Candidate instance | def respond_to_proposal_from( other )
case
# Is there a preference for the candidate?
when !prefers?( other )
false
# Are there available positions for more matches?
when free?
match! other
# Is the passed Candidate a better match than any other match?
when better_match?( other )
free!
match! other
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chosen(already, owner, other)\n\t\tif already && already.owner_id == owner.id && current_user\n\t\t\t\"chosen\"\n\t\telse\n\t\t\tother\n\t\tend\n\tend",
"def ==(other)\n @candidate == other.candidate\n end",
"def candidate\n @candidate\n end",
"def absorb other\n self.about = other.about if se... | [
"0.58686155",
"0.56267965",
"0.54296243",
"0.5399437",
"0.5344745",
"0.5316683",
"0.531268",
"0.52848715",
"0.5253057",
"0.523432",
"0.5177804",
"0.51527923",
"0.5124434",
"0.511018",
"0.511018",
"0.50795925",
"0.5076306",
"0.50705546",
"0.50595284",
"0.50595284",
"0.50595284... | 0.68670064 | 0 |
ensure version is in "x.x.x" format | def normalize_version(str)
default = "0.0.1"
if str.nil? or str.empty?
default
elsif str.match /^(\d)+[.](\d)+[.](\d)+$/
str
elsif str.match /^((\d)+[.])*(\d)+$/
fix_version(str)
else
raise VersionError, "need a valid version number of the form 0.0.0"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_version(v)\n return true if (!version || version[0..4].gsub(\".\",\"\").to_i>=v)\n return false\n end",
"def valid_version?(arg)\n return true if arg == 'latest'\n arg =~ /^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9]+)?$/ ? true : false\n end",
"def version_mismatch_d... | [
"0.73347974",
"0.7259682",
"0.72094333",
"0.7175039",
"0.70156807",
"0.69588107",
"0.68472767",
"0.68078417",
"0.6803388",
"0.67892855",
"0.6786683",
"0.6756367",
"0.6751995",
"0.6734794",
"0.66410625",
"0.66205883",
"0.6609274",
"0.6573203",
"0.65553063",
"0.6544871",
"0.653... | 0.7015186 | 5 |
GET /tcm_patient_infos GET /tcm_patient_infos.json | def index
@tcm_patient_infos = TcmPatientInfo.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patients\n patients = User.patients\n render json: { status: 200, data: patients }\n end",
"def show\n @patient = Patient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patient }\n end\n end",
"def show\n @patient = Pat... | [
"0.70554125",
"0.67892295",
"0.67892295",
"0.67892295",
"0.67364836",
"0.66602945",
"0.66163933",
"0.6597303",
"0.6548129",
"0.6547083",
"0.65153813",
"0.6514795",
"0.65094537",
"0.64854074",
"0.64829165",
"0.6451389",
"0.6451389",
"0.64378923",
"0.6431249",
"0.6373956",
"0.6... | 0.7402122 | 0 |
GET /tcm_patient_infos/1 GET /tcm_patient_infos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tcm_patient_infos = TcmPatientInfo.all\n end",
"def show\n @patient = Patient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patient }\n end\n end",
"def show\n @patient = Patient.find(params[:id])\n\n respond_... | [
"0.7225858",
"0.702762",
"0.702762",
"0.702762",
"0.7006487",
"0.69137836",
"0.68889594",
"0.6773486",
"0.6773486",
"0.6765949",
"0.6754877",
"0.6745859",
"0.67421997",
"0.6732377",
"0.66520077",
"0.6649397",
"0.6593893",
"0.65794694",
"0.65771186",
"0.6571416",
"0.65298915",... | 0.0 | -1 |
POST /tcm_patient_infos POST /tcm_patient_infos.json | def create
@tcm_patient_info = TcmPatientInfo.new(tcm_patient_info_params)
respond_to do |format|
if @tcm_patient_info.save
format.html { redirect_to @tcm_patient_info, notice: 'Tcm patient info was successfully created.' }
format.json { render :show, status: :created, location: @tcm_patient_info }
else
format.html { render :new }
format.json { render json: @tcm_patient_info.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @patient = Patient.new(patient_params)\n if @patient.save\n render :json => {\n id: @patient.id,\n email: @patient.email,\n firstName: @patient.first_name,\n lastName: @patient.last_name,\n sex: @patient.sex,\n birthday: @patient.birthday,\n ... | [
"0.7071312",
"0.6810582",
"0.6775352",
"0.67720807",
"0.6768563",
"0.67647874",
"0.6763522",
"0.6763522",
"0.6763522",
"0.6752355",
"0.6729753",
"0.67196226",
"0.6707423",
"0.67057556",
"0.66948557",
"0.66915494",
"0.6676042",
"0.66522706",
"0.6624962",
"0.6589317",
"0.658829... | 0.76556325 | 0 |
PATCH/PUT /tcm_patient_infos/1 PATCH/PUT /tcm_patient_infos/1.json | def update
respond_to do |format|
if @tcm_patient_info.update(tcm_patient_info_params)
format.html { redirect_to @tcm_patient_info, notice: 'Tcm patient info was successfully updated.' }
format.json { render :show, status: :ok, location: @tcm_patient_info }
else
format.html { render :edit }
format.json { render json: @tcm_patient_info.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @patient = @client.patients.find(params[:id])\n\n respond_to do |format|\n if @patient.update_attributes(params[:patient])\n format.html { redirect_to @patient, notice: 'Patient was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render a... | [
"0.725539",
"0.7012029",
"0.6971339",
"0.6951263",
"0.6946573",
"0.69266677",
"0.6917158",
"0.6913407",
"0.6913407",
"0.68744105",
"0.6867139",
"0.68494684",
"0.6809252",
"0.6809252",
"0.6809252",
"0.6809252",
"0.6809252",
"0.6809252",
"0.6809252",
"0.6809252",
"0.6809252",
... | 0.7417913 | 0 |
DELETE /tcm_patient_infos/1 DELETE /tcm_patient_infos/1.json | def destroy
@tcm_patient_info.destroy
respond_to do |format|
format.html { redirect_to tcm_patient_infos_url, notice: 'Tcm patient info was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @patient.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @patient = @client.patients.find(params[:id]) unless current_user.admin?\n @patient = Patient.find(params[:id]) if current_user.admin?\n if @patient.deleted_at.blank?\n ... | [
"0.74712026",
"0.724691",
"0.7223435",
"0.72109574",
"0.72109574",
"0.72109574",
"0.72109574",
"0.7210253",
"0.7210253",
"0.7210253",
"0.7210253",
"0.72084016",
"0.7202416",
"0.7188496",
"0.7169685",
"0.7144111",
"0.7080055",
"0.7076126",
"0.7060444",
"0.7043352",
"0.70326054... | 0.7604018 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_tcm_patient_info
@tcm_patient_info = TcmPatientInfo.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def tcm_patient_info_params
params.fetch(:tcm_patient_info, {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
is the user an admin or a customer? | def role
@role ||=
if is_admin?
:admin
else
:customer
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin?\n\tif session[:customer_id].nil?\n\t\treturn\n\telse\n signed_in? == true\n\t@current_customer == Customer.find_by_id(3)\n\tend\nend",
"def admin? ; user.instance_of? User and user.role >= 2 ; end",
"def customer?\n role?(UserRoles::CUSTOMER)\n end",
"def admin_user?\n\t\treturn self.user_c... | [
"0.8346972",
"0.8169137",
"0.815209",
"0.8103464",
"0.8088938",
"0.80479586",
"0.8045988",
"0.7993833",
"0.7981102",
"0.79658324",
"0.79582185",
"0.7937235",
"0.7902522",
"0.7897135",
"0.7884077",
"0.7874257",
"0.7831813",
"0.782672",
"0.781979",
"0.7819062",
"0.78189355",
... | 0.0 | -1 |
Methode extract from RestClient maybe need some test | def process_payload(p=nil, parent_key=nil)
unless p.is_a?(Hash)
p
else
p.keys.map do |k|
key = parent_key ? "#{parent_key}[#{k}]" : k
if p[k].is_a? Hash
process_payload(p[k], key)
elsif p[k].is_a? Array
p[k].map do |v|
value = URI.escape(v.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
"#{key}[]=#{value}"
end
else
value = URI.escape(p[k].to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
"#{key}=#{value}"
end
end.join("&")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoke_request(url)\n site = RestClient::Resource.new(url, \"dHgVM1emGoTyr8zHmVNH\")\n return JSON.parse(site.get(:accept=>\"application/json\"))\nend",
"def invoke_request(url)\n site = RestClient::Resource.new(url, \"dHgVM1emGoTyr8zHmVNH\")\n return JSON.parse(site.get(:accept=>\"application/json\"))\n... | [
"0.68007314",
"0.68007314",
"0.66991985",
"0.6648439",
"0.664728",
"0.6642553",
"0.6429192",
"0.6427094",
"0.6423713",
"0.64099985",
"0.6333346",
"0.6315692",
"0.62648267",
"0.6262084",
"0.6244502",
"0.6177767",
"0.61741346",
"0.61678636",
"0.6162164",
"0.61322016",
"0.611754... | 0.0 | -1 |
takes population density, population, and states and puts them in to predicted death and speed of spread methods | def virus_effects
predicted_deaths
speed_of_spread
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virus_effects \n predicted_deaths(@population_density, @population, @state)\n speed_of_spread(@population_density, @state)\n end",
"def virus_effects\n predicted_deaths(@population_density, @population)\n speed_of_spread(@population_density)\n # Deleted out @state because it isn't being used... | [
"0.7437621",
"0.7377336",
"0.736164",
"0.7346512",
"0.7339851",
"0.73228055",
"0.73001295",
"0.72830653",
"0.7275434",
"0.7275434",
"0.7269767",
"0.72584915",
"0.7237899",
"0.7237899",
"0.7212133",
"0.7212133",
"0.7212133",
"0.7212133",
"0.7212133",
"0.7212133",
"0.7212133",
... | 0.0 | -1 |
Takes the parameters pop density, population, and state and runs them through the conditional statements | def predicted_deaths
# predicted deaths is solely based on population density
if @population_density >= 200
number_of_deaths = (@population * 0.4).floor
elsif @population_density >= 150
number_of_deaths = (@population * 0.3).floor
elsif @population_density >= 100
number_of_deaths = (@population * 0.2).floor
elsif @population_density >= 50
number_of_deaths = (@population * 0.1).floor
else
number_of_deaths = (@population * 0.05).floor
end
print "#{@state} will lose #{number_of_deaths} people in this outbreak"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicted_deaths #(population_density, population, state)\n # predicted deaths is solely based on population density\n if @population_density >= 200\n @number_of_deaths = (@population * 0.4).floor\n elsif @population_density >= 150\n @number_of_deaths = (@population * 0.3).floor\n elsif @... | [
"0.7036398",
"0.6908338",
"0.69037753",
"0.6847088",
"0.6781773",
"0.6760485",
"0.67540187",
"0.6753874",
"0.674867",
"0.67290246",
"0.67227477",
"0.66753614",
"0.66596746",
"0.6631879",
"0.65896523",
"0.6585168",
"0.6583145",
"0.65785795",
"0.65470827",
"0.6517331",
"0.65078... | 0.0 | -1 |
puts parameters population density, and state and runs them through the coniditonal statements | def speed_of_spread #in months
# We are still perfecting our formula here. The speed is also affected
# by additional factors we haven't added into this functionality.
speed = 0.0
# As population density increases, the rate of spread decreases
if @population_density >= 200
speed += 0.5
elsif @population_density >= 150
speed += 1
elsif @population_density >= 100
speed += 1.5
elsif @population_density >= 50
speed += 2
else
speed += 2.5
end
puts " and will spread across the state in #{speed} months.\n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report\r\n\r\n STATE_DATA.each do |key, value|\r\n\r\n initialize(key, value[:population_density], value[:population]) \r\n virus_effects\r\n end\r\n \r\n end",
"def initialize(state_of_origin, population_density, population)\n puts \"creating\"\n @state = state_of_origin\n @populati... | [
"0.6645474",
"0.6482796",
"0.6440358",
"0.6244643",
"0.619875",
"0.6190849",
"0.6184927",
"0.6177318",
"0.6130628",
"0.60846585",
"0.60603523",
"0.60567284",
"0.60440904",
"0.59962815",
"0.5994581",
"0.5978851",
"0.59768224",
"0.59495056",
"0.5948602",
"0.5948602",
"0.5948602... | 0.0 | -1 |
Gets three tweets from the passed in user. GET /api/getThreeTweets | def getThreeTweets
render json: TwitterAPI.get_top_3_tweets(params[:twitter_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\tuser = User.find_by(id: params[:user_id])\n\t\tif user.present?\n\t\t\tfollower_ids = user.followers.pluck(:id)\n\t\t\ttweets = Tweet.where(\"user_id IN (?)\", follower_ids).order(\"updated_at DESC\")\n\t\t\trender json: {:status=>\"success\", :code=>200, :message=>\"List of tweets from the users yo... | [
"0.62984455",
"0.62487525",
"0.62227035",
"0.616522",
"0.60715705",
"0.6037786",
"0.6032513",
"0.6025714",
"0.599853",
"0.5938325",
"0.59228003",
"0.58438045",
"0.5835036",
"0.5819893",
"0.58130115",
"0.57984716",
"0.57883453",
"0.57881767",
"0.57866645",
"0.5759745",
"0.5749... | 0.8384098 | 0 |
GET /api/getMatchCount Gets the number of matches | def getMatchCount
render json: Match.count(:user1 => params[:twitter_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matched_count\n @results[MATCHED_COUNT]\n end",
"def return_count\n return @matchedCount\n end",
"def count\n Jhead.call(\"-c\", @match, @pattern).split(\"\\n\").size\n end",
"def total\n #use group matches instead of numFound for grouped response\n if response[:numFound].nil? \... | [
"0.7811867",
"0.73680633",
"0.6772427",
"0.6696992",
"0.6686159",
"0.6679146",
"0.6644658",
"0.6642344",
"0.659905",
"0.65537834",
"0.6549743",
"0.6533666",
"0.65194166",
"0.6441293",
"0.6402503",
"0.6402503",
"0.6402503",
"0.63880044",
"0.63629204",
"0.63445127",
"0.63402873... | 0.7972879 | 0 |
this is where users arrive after visiting the email confirmation link | def edit
@resource = resource_class.reset_password_by_token(
reset_password_token: resource_params[:reset_password_token]
)
if @resource&.id
# ensure that user is confirmed
@resource.skip_confirmation! unless @resource.confirmed_at
@resource.save!
update_refresh_token_cookie
redirect_header_options = {
override_proof: OVERRIDE_PROOF,
reset_password: true
}
redirect_headers = @resource.create_named_token_pair
.merge(redirect_header_options)
redirect_to_link = DeviseJwtAuth::Url.generate(params[:redirect_url], redirect_headers)
redirect_to redirect_to_link
else
raise ActionController::RoutingError, 'Not Found'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def referral_confirmation_email\n\n end",
"def email_confirm\n end",
"def confirm_email(user)\n @user = user\n @confirm_url = \"http://www.yscalumni.org/confirm/\" + user.confirmation_code\n mail(:to => user.email, :subject => \"Welcome to yscalumni.org! Please confirm your email!\")\n end",
"def... | [
"0.7300888",
"0.73001945",
"0.7100166",
"0.7017477",
"0.69846773",
"0.6976349",
"0.69351697",
"0.69184804",
"0.6866249",
"0.6859204",
"0.68310654",
"0.6824817",
"0.6824623",
"0.67849064",
"0.67771435",
"0.6767912",
"0.6765077",
"0.6742052",
"0.6729067",
"0.6727901",
"0.671426... | 0.0 | -1 |
Walk collection for :add rsync_serve resources Build and write the config template | def write_conf
template(new_resource.config_path) do
source 'rsyncd.conf.erb'
cookbook 'rsync'
owner 'root'
group 'root'
mode '0640'
variables(
globals: global_modules,
modules: rsync_modules
)
notifies :restart, "service[#{node['rsyncd']['service']}]", :delayed
end
service node['rsyncd']['service'] do
action :nothing
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rsync_resources\n run_context.resource_collection.select do |resource|\n resource.is_a?(Chef::Resource::RsyncServe)\n end\n end",
"def rsync_resources\n ::ObjectSpace.each_object(::Chef::Resource).select do |resource|\n resource.resource_name == :rsync_serve\n end\nend",
"d... | [
"0.6089597",
"0.606924",
"0.5902413",
"0.5877497",
"0.571682",
"0.5593962",
"0.5571538",
"0.55506176",
"0.551628",
"0.5492206",
"0.5453311",
"0.54517996",
"0.5436677",
"0.5424625",
"0.5402557",
"0.53704333",
"0.53440094",
"0.53433233",
"0.5320235",
"0.5317486",
"0.5311866",
... | 0.56860846 | 5 |
The list of attributes for this resource. | def resource_attributes
%w(
auth_users
comment
dont_compress
exclude
exclude_from
fake_super
gid
hosts_allow
hosts_deny
include
include_from
incoming_chmod
list
lock_file
log_file
log_format
max_connections
munge_symlinks
numeric_ids
outgoing_chmod
path
postxfer_exec
prexfer_exec
read_only
refuse_options
secrets_file
strict_modes
timeout
transfer_logging
uid
use_chroot
write_only
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes\n @list.map(&:attributes)\n end",
"def attributes\n @attributes ||= []\n @attributes\n end",
"def attributes\n @attributes ||= []\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def resource_attributes\n resource_class.attrib... | [
"0.7989403",
"0.788354",
"0.7675028",
"0.7657532",
"0.7603037",
"0.75566626",
"0.7534158",
"0.75312907",
"0.7497598",
"0.7497598",
"0.7497598",
"0.7493286",
"0.74056476",
"0.73006874",
"0.72975993",
"0.7279237",
"0.7216928",
"0.7211664",
"0.7211239",
"0.7186131",
"0.7169184",... | 0.0 | -1 |
The list of rsync server resources in the resource collection | def rsync_resources
::ObjectSpace.each_object(::Chef::Resource).select do |resource|
resource.resource_name == :rsync_serve
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rsync_resources\n run_context.resource_collection.select do |resource|\n resource.is_a?(Chef::Resource::RsyncServe)\n end\n end",
"def all_servers\n Infrataster::Server.defined_servers.map { |i| server(i.name) }\nend",
"def resources\n @resources ||= []\n end",
"def l... | [
"0.8124576",
"0.6612449",
"0.65967375",
"0.6571224",
"0.6555147",
"0.6550174",
"0.64710927",
"0.63614774",
"0.63614774",
"0.63614774",
"0.63580257",
"0.63524985",
"0.6347986",
"0.63440347",
"0.63440347",
"0.63204473",
"0.6296061",
"0.6217164",
"0.61819506",
"0.6160323",
"0.61... | 0.7518149 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.