query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Get the first tag by attribute that exactly matches value. | def find_ele_by_attr_include tag, attr, value
@driver.find_element :xpath, %Q(#{tag}[contains(@#{attr}, '#{value}')])
end | [
"def find_by(attribute, value)\n res_coll.each do |item|\n return item if item.__send__(attribute) == value\n end\n return nil\n end",
"def _getAttribElem(data, attribute, value)\n data.each do |g|\n attrib = Rack::Utils.parse_query URI(g).query\n if(attrib[attribute] == value) \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get tags by attribute that include value. | def find_eles_by_attr_include tag, attr, value
@driver.find_elements :xpath, %Q(#{tag}[contains(@#{attr}, '#{value}')])
end | [
"def find_ele_by_attr_include tag, attr, value\n @driver.find_element :xpath, %Q(#{tag}[contains(@#{attr}, '#{value}')])\n end",
"def sr_search_by_tag(tag)\n all_sr = sr_list('include', true)\n all_sr['Value'].select! do |sr_uuid|\n sr_get_tags(sr_uuid)['Value'].include?(tag)\n end\n all_sr\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the tags that include text. | def find_eles_by_text_include tag, text
find_eles_by_attr_include tag, :text, text
end | [
"def list_same_tag_data(text, tag)\n text.scan(/<#{tag}( [^ \\/>]+)*?>(?<tag_text>.*?)<\\/#{tag}>/m).map(&:first)\n end",
"def parse_tags\n poss_tags = @html.css(\"p\").select{|ele| ele.text.include?(\"Tagged\")}\n poss_tags.first.text.gsub(\"Tagged: \", \"\").split(\", \") if poss_tags && !poss_tag... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the first tag that matches tag_name | def first_ele tag_name
# XPath index starts at 1
find_element :xpath, "//#{tag_name}[1]"
end | [
"def get_tag(tag_string)\n Tag.all.select { |tag| tag[\"name\"] == tag_string }[0] unless Tag.all.empty?\n end",
"def tag_name\n tag_names.first if has_single_tag?\n end",
"def tag(name:)\n select { |release| release[:tag_name] == name }.first\n end",
"def first_tag(name, opts = nil, conte... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the last tag that matches tag_name | def last_ele tag_name
xpath "//#{tag_name}[last()]"
end | [
"def latest_tag\n match = \"\"\n matches = log.scan(/tag:\\s(.+?),\\s/)\n if matches.nil?\n \"\"\n else\n matches.each do |tag|\n if !tag.first.include? \"jenkins\"\n match = tag.first\n break\n end\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all elements that exactly match name | def find_names name
find_elements :name, name
end | [
"def element_named(name)\n @elements.find{|e| e.name.to_s == name.to_s}\n end",
"def elements(name)\n root.search(root_path(name))\n end",
"def find_elements(element_name, response)\n response.body.xpath(\".//x:#{element_name}\", 'x' => response.body.namespace.href)\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all elements matching tag_name | def tags tag_name
find_elements :tag_name, tag_name
end | [
"def find_all_by_tag( tag_name )\n find_all_by_tag!(tag_name)\n rescue\n []\n end",
"def all_tags(name, opts = nil, contents = browser_contents)\n found = [] unless block_given?\n contents.scan(/(<\\s*#{name}\\s*(.*?)\\/?>)/) do |match|\n tag = Tag.new(match[0], name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts pixel values to window relative values ```ruby px_to_window_rel x: 50, y: 150 ``` | def px_to_window_rel opts={}
w = $driver.window_size
x = opts.fetch :x, 0
y = opts.fetch :y, 0
OpenStruct.new( x: "#{x.to_f} / #{w.width.to_f}",
y: "#{y.to_f} / #{w.height.to_f}" )
end | [
"def px_to_window_rel(opts = {}, driver = $driver)\n w = driver.window_size\n x = opts.fetch :x, 0\n y = opts.fetch :y, 0\n\n OpenStruct.new(x: \"#{x.to_f} / #{w.width.to_f}\",\n y: \"#{y.to_f} / #{w.height.to_f}\")\n end",
"def px_to_com x, y\n # make it complex to w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search strings.xml's values for target. | def xml_keys target
lazy_load_strings
@strings_xml.select { |key, value| key.downcase.include? target.downcase }
end | [
"def xml_values target\n lazy_load_strings\n @strings_xml.select { |key, value| value.downcase.include? target.downcase }\n end",
"def xml_values(target)\n lazy_load_strings\n @lazy_load_strings.select { |_key, value| value.downcase.include? target.downcase }\n end",
"def xml_keys(target)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search strings.xml's keys for target. | def xml_values target
lazy_load_strings
@strings_xml.select { |key, value| value.downcase.include? target.downcase }
end | [
"def xml_keys target\n lazy_load_strings\n @strings_xml.select { |key, value| key.downcase.include? target.downcase }\n end",
"def xml_keys(target)\n lazy_load_strings\n @lazy_load_strings.select { |key, _value| key.downcase.include? target.downcase }\n end",
"def xml_values(target)\n l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resolve id in strings.xml and return the value. | def resolve_id id
lazy_load_strings
@strings_xml[id]
end | [
"def get_localized_string(id)\n $g_localized_strings||=read_xml($g_lang_strings_file)\n if $g_localized_strings[id]==nil\n puts(\"id #{id} string not found\")\n fail(\"id #{id} string not found\")\n end\n return $g_localized_strings[id]\n end",
"def getIdString\r\n\t\t\t\t\r\n\t\t\t\t\tretu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Used to error when finding a single element fails. | def raise_no_element_error
raise Selenium::WebDriver::Error::NoSuchElementError, 'An element could not be located on the page using the given search parameters.'
end | [
"def error(doc)\n begin\n xml_content xpath(doc,'//error').first\n rescue\n xml_content xpath(doc,'//errors').first\n end\n end",
"def find_elem\n begin\n $results.log_action(\"#{@action}(#{@params.join(' ')})\")\n $session.success = false\n case @params[0]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
make a request to tripsta like: plane("INV", "LON", "211113") | def plane(origin, destination, date)
param_date = date[0,2] + "%2f" + date[2,2] + "%2f20" + date[4,2]
url = "http://www.tripsta.co.uk/airline-tickets/results?dep=#{origin}&arr=#{destination}&passengersAdult=1&passengersChild=0&passengersInfant=0&class=&airlineCode=&directFlightsOnly=0&extendedDates=0&isRoundtrip=0&ob... | [
"def project_to_plane(plane)\n end",
"def get_plane\n end",
"def set_plane(plane)\n end",
"def doStationboardRequest(_params)\n definedParams = [\"station\",\"id\"]\n parm = _params.length > 0 ? _params : {\"station\" => \"Neuchatel\"}\n if hasOneParam(parm, definedParams) \n url = TRANSPORT_EP + \"/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a contributor whose quiz is to be taken if available, otherwise will raise an error | def contributor_for_quiz(reviewer, topic)
raise 'Please select a topic.' if topics? && topic.nil?
raise 'This assignment does not have topics.' unless topics? || !topic
# This condition might happen if the reviewer/quiz taker waited too much time in the
# select topic page and other students have alrea... | [
"def contributor_for_quiz(reviewer, topic)\n raise \"Please select a topic\" if has_topics? and topic.nil?\n raise \"This assignment does not have topics\" if !has_topics? and topic\n\n # This condition might happen if the reviewer/quiz taker waited too much time in the\n # select topic page and other s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /project_messages/1 GET /project_messages/1.json | def show
@project_message = ProjectMessage.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @project_message }
end
end | [
"def getPublicMessages *args\n options = fill_args [:projectid],[:projectid],*args\n request \"/Project/getPublicMessages.json\",options\n end",
"def new\n @project_message = ProjectMessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @proje... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /project_messages/new GET /project_messages/new.json | def new
@project_message = ProjectMessage.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @project_message }
end
end | [
"def new\n @message = Message.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @message }\n end\n end",
"def new\n @new_project = NewProject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_proje... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /project_messages POST /project_messages.json | def create
@project_message = ProjectMessage.new(params[:project_message])
respond_to do |format|
if @project_message.save
format.html { redirect_to @project_message, notice: 'Project message was successfully created.' }
format.json { render json: @project_message, status: :created, locat... | [
"def postPublicMessage *args\n options = fill_args [:projectid,:messagetext],[:projectid,:messagetext],*args\n request \"/Project/postPublicMessage.json\",options\n end",
"def new\n @project_message = ProjectMessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /project_messages/1 PUT /project_messages/1.json | def update
@project_message = ProjectMessage.find(params[:id])
respond_to do |format|
if @project_message.update_attributes(params[:project_message])
format.html { redirect_to @project_message, notice: 'Project message was successfully updated.' }
format.json { head :no_content }
el... | [
"def update\n respond_to do |format|\n @message.update!(message_params)\n format.json { head :no_content }\n end\n end",
"def update\n message = Message.find(params[:id])\n message.update(message_params)\n render json: message\n end",
"def update\n @system_message = SystemMessage.f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /project_messages/1 DELETE /project_messages/1.json | def destroy
@project_message = ProjectMessage.find(params[:id])
@project_message.destroy
respond_to do |format|
format.html { redirect_to project_messages_url }
format.json { head :no_content }
end
end | [
"def destroy\n @message.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete\n msg = @user.messages.find(params[:id])\n if msg.nil?\n render json_status_response(404, \"Message not found\")\n return\n end\n\n msg.destroy\n render jso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /slideshows/new GET /slideshows/new.json | def new
@slideshow = Slideshow.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @slideshow }
end
end | [
"def new\n @slideshow_item = SlideshowItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @slideshow_item }\n end\n end",
"def new\n @slideshow_image = SlideshowImage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /slideshows POST /slideshows.json | def create
@slideshow = Slideshow.new(params[:slideshow])
respond_to do |format|
if @slideshow.save
format.html { redirect_to @slideshow, notice: 'Slideshow was successfully created.' }
format.json { render json: @slideshow, status: :created, location: @slideshow }
else
form... | [
"def upload_slideshow(options={})\n response = get(\"upload_slideshow/\", options)\n end",
"def create\n @slide_show = SlideShow.create(params[:slide_show])\n params[:slides].each_value do |v|\n @slide_show.slides.create(v)\n end\n\n respond_to do |format|\n if @slide_show.save\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /slideshows/1 PUT /slideshows/1.json | def update
@slideshow = Slideshow.find(params[:id])
respond_to do |format|
if @slideshow.update_attributes(params[:slideshow])
format.html { redirect_to @slideshow, notice: 'Slideshow was successfully updated.' }
format.json { head :no_content }
else
format.html { render act... | [
"def update\n @slideshow = @user.slideshows.find(params[:id])\n @user.slideshows << @slideshow\n\n respond_to do |format|\n if @slideshow.update_attributes(params[:slideshow])\n format.html { redirect_to @slideshow, notice: 'Slideshow was successfully updated.' }\n format.json { head :no... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs a onetimeuse authorize_endpoint. This method will use a new nonce on each invocation. | def authorize_endpoint_url
uri = URI(openid_config['authorization_endpoint'])
uri.query = URI.encode_www_form(client_id: client_id,
redirect_uri: callback_url,
response_mode: response_mode,
... | [
"def initialize(config, type = 'authorize')\n self.config = config\n super(\n config['client_id'],\n Rails.application.secrets.dotloop_secret_key,\n site: config[\"#{type}_site\"], authorize_url: config['authorize_url'])\n end",
"def initialize(url, key_name, access_key, lifetime = 10, diges... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The client id of the calling application. This must be configured where AD is installed as an OmniAuth strategy. | def client_id
return options.client_id if options.client_id
fail StandardError, 'No client_id specified in AzureAD configuration.'
end | [
"def client_app_id\n return @client_app_id\n end",
"def client_id\n ENV['ORCID_CLIENT_ID']\n end",
"def client_app_id=(value)\n @client_app_id = value\n end",
"def default_client_id\n \"1B47512E-9743-11E2-8092-7F654762BE04\"\n end",
"def cl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The expected id token issuer taken from the discovery endpoint. | def issuer
openid_config['issuer']
end | [
"def get_issuer(did_token)\n decode(did_token).last[\"iss\"]\n end",
"def issuer\n @issuer ||= begin\n node = REXML::XPath.first(document, \"/p:Response/a:Issuer\", { \"p\" => PROTOCOL, \"a\" => ASSERTION })\n node ||= xpath_first_from_signed_assertion('/a:Issuer')\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches the current signing keys for Azure AD. Note that there should always two available, and that they have a 6 week rollover. Each key is a hash with the following fields: kty, use, kid, x5t, n, e, x5c | def fetch_signing_keys
response = JSON.parse(Net::HTTP.get(URI(signing_keys_url)))
response['keys']
rescue JSON::ParserError
raise StandardError, 'Unable to fetch AzureAD signing keys.'
end | [
"def signing_keys\n @signing_keys ||= fetch_signing_keys\n end",
"def get_keys\n keys = []\n int = 30\n now = Time.now.to_i / int\n key = Base32.decode @secret_key\n sha = OpenSSL::Digest::Digest.new('sha1')\n\n (-1..1).each do |x|\n bytes = [ now + x ].pack('>q').reverse\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches the OpenId Connect configuration for the AzureAD tenant. This contains several import values, including: authorization_endpoint token_endpoint token_endpoint_auth_methods_supported jwks_uri response_types_supported response_modes_supported subject_types_supported id_token_signing_alg_values_supported scopes_sup... | def fetch_openid_config
JSON.parse(Net::HTTP.get(URI(openid_config_url)))
rescue JSON::ParserError
raise StandardError, 'Unable to fetch OpenId configuration for ' \
'AzureAD tenant.'
end | [
"def openid_config_url\n \"https://login.windows.net/#{tenant}/.well-known/openid-configuration\"\n end",
"def retrieve_open_id_configuration()\n startAnonymous.uri('/.well-known/openid-configuration')\n .get()\n .go()\n end",
"def openid_config_url\n options[:openid... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A memoized version of fetch_openid_config. | def openid_config
@openid_config ||= fetch_openid_config
end | [
"def fetch_openid_config\n JSON.parse(Net::HTTP.get(URI(openid_config_url)))\n rescue JSON::ParserError\n raise StandardError, 'Unable to fetch OpenId configuration for ' \\\n 'AzureAD tenant.'\n end",
"def get_configuration\n Rails.logger.debug \"------ Call... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The location of the OpenID configuration for the tenant. | def openid_config_url
"https://login.windows.net/#{tenant}/.well-known/openid-configuration"
end | [
"def openid_config_url\n options[:openid_config_url] ||\n \"https://login.windows.net/#{tenant}/.well-known/openid-configuration\"\n end",
"def config_endpoint\n \"#{client_options.auth_server_uri}/.well-known/openid-configuration\"\n end",
"def retrieve_open_id_configuration()\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The response_type that will be set in the authorization request query parameters. Can be overridden by the client, but it shouldn't need to be. | def response_type
options[:response_type] || DEFAULT_RESPONSE_TYPE
end | [
"def response_type\n return @response_type\n end",
"def response_type=(value)\n @response_type = value\n end",
"def content_type\n self.class.response_content_type\n end",
"def allowed_types\n config.allowed_response_types\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The response_mode that will be set in the authorization request query parameters. Can be overridden by the client, but it shouldn't need to be. | def response_mode
options[:response_mode] || DEFAULT_RESPONSE_MODE
end | [
"def authorization_mode=(mode); end",
"def authorization_mode; end",
"def set_ResponseMode(value)\n set_input(\"ResponseMode\", value)\n end",
"def authentication_mode=(value)\n @authentication_mode = value\n end",
"def authentication_mode\n return @a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The keys used to sign the id token JWTs. This is just a memoized version of fetch_signing_keys. | def signing_keys
@signing_keys ||= fetch_signing_keys
end | [
"def key_ids\n @keys.keys\n end",
"def key_ids\n return @key_ids\n end",
"def keys\n RubyKongAuth::KeyAuth.all consumer_id: self.id\n end",
"def public_keys\n fetch_public_keys_cached.map do |jwk_data|\n ::JWT::JWK.import(jwk_data).keypair\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The location of the public keys of the token signer. This is parsed from the OpenId config response. | def signing_keys_url
return openid_config['jwks_uri'] if openid_config.include? 'jwks_uri'
fail StandardError, 'No jwks_uri in OpenId config response.'
end | [
"def retrieve_jwt_public_keys()\n start.uri('/api/jwt/public-key')\n .get()\n .go()\n end",
"def public_keys\n @public_keys\n end",
"def public_ek\n @endorsement_key[:public]\n end",
"def public_key\n # The public key is provided as a JSON Web Key Set (JWKS) by the j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The tenant of the calling application. Note that this must be explicitly configured when installing the AzureAD OmniAuth strategy. | def tenant
return options.tenant if options.tenant
fail StandardError, 'No tenant specified in AzureAD configuration.'
end | [
"def azure_tenant_id\n return @azure_tenant_id\n end",
"def current_tenant\n Thread.current[:current_tenant]\n end",
"def current_tenant\n ActsAsTenant.current_tenant\n end",
"def current_tenant\n Thread.current[:current_tenant]\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
traverse from [0,0] to the bottom right, only going either right or down. utilize memoization to keep track of paths return all valid paths as output most likely solved with a buttomup approach start at the bottom right and | def traverse_grid(rows, cols, dead_zones, paths)
paths ||= Array.new(rows) {Array.new(cols)}
#recursive step
return traverse_grid(rows-1, cols) || traverse_grid(rows, cols-1)
end | [
"def path_finder(here, visited_cells=[])\n return false if out_of_bounds?(here) or visited_cells.include?(here) or @maze[here] == \"#\"\n return true if @maze[here] == 'B'\n visited_cells << here\n return (path_finder(here-1, visited_cells) or path_finder(here+1, visited_cells) or path_finder(here-@maze... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method takes 2 inputs . one is the hash map of test_file => class name and the other is output of check_marker() i.e using_or is 'true / false' And then builds the file groups that need to run. | def test_file_to_group(test_file_map, using_or)
puts "\nAnalyzing #{@test_files.length} test files... Stand by."
@test_files.each do |tf|
@skip = false
################
test_class = Kernel.const_get(test_file_map[tf])
# Lower cases the group only if each element in the grouping ar... | [
"def setup_class_group_test_data\n class_group_file_stubber('none', get_non_file)\n @class_group_foo = tmp_file(<<-EOT\nclasses:\n - one\n - two\n - three\nEOT\n )\n @class_group_bar = tmp_file(<<-EOT\nclasses:\n - \"%{four}\"\nclass_groups:\n - baz\nEOT\n )\n @class_group_baz = tmp_file(<<-E... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /lead_entries GET /lead_entries.json | def index
@lead_entries = LeadEntry.where(:lead_id => params[:lead_id]).paginate(:page => params[:page])
respond_to do |format|
format.html { render action: 'index' }
format.json {
render :json => {
:amount => @lead_entries.length,
:success => true,
:html => (r... | [
"def index\n @ads_entries = AdsEntry.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads_entries }\n end\n end",
"def index\n @leads = Lead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @le... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /lead_entries POST /lead_entries.json | def create
@lead_entry = LeadEntry.new lead_entry_params
respond_to do |format|
if @lead_entry.save
format.html { redirect_to @lead_entry, notice: 'Lead entry was successfully created.' }
format.json { render :json => {
:success => true,
:html => (render_to_string ... | [
"def create\n @ledger_entry = LedgerEntry.new(params[:ledger_entry])\n\n respond_to do |format|\n if @ledger_entry.save\n format.html { redirect_to @ledger_entry, :notice => 'Ledger entry was successfully created.' }\n format.json { render :json => @ledger_entry, :status => :created, :locat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /lead_entries/1 PATCH/PUT /lead_entries/1.json | def update
respond_to do |format|
if @lead_entry.update(lead_entry_params)
format.html { redirect_to @lead_entry, notice: 'Lead entry was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @lead_... | [
"def update\n @lead = Lead.find(params[:id])\n\n respond_to do |format|\n if @lead.update_attributes(params[:lead])\n format.html { redirect_to @lead, notice: 'Lead was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /lead_entries/1 DELETE /lead_entries/1.json | def destroy
@lead_entry.destroy
respond_to do |format|
format.html { redirect_to lead_entries_url }
format.json { head :no_content }
end
end | [
"def destroy\n @lead = Lead.find(params[:id])\n @lead.delete\n\n respond_to do |format|\n format.html { redirect_to leads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ads_entry = AdsEntry.find(params[:id])\n @ads_entry.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert block_size and quantity to a humanreadable disk size. | def blocks_to_bytes(block_size, qty)
size = ( block_size / 1024 ) * qty
if size < 1000
output = "#{size} KB"
elsif size < 1000000
output = "#{size / 1000} MB"
elsif size < 1000000000
output = "#{size / 1000000} GB"
else
output = "#{size / 1000000000} TB"
end
return output
end | [
"def convert_size(block_size,blocks)\n size = block_size * blocks\n if size > SIZE_GB\n return [(size / SIZE_GB).to_i,\"GB\"]\n else\n return [(size / SIZE_MB).to_i,\"MB\"]\n end\n end",
"def size\n ['o', 'k', 'G'].inject(super.to_f) do |s, unit|\n # recusively div... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /hospital_categories GET /hospital_categories.json | def index
@hospital_categories = HospitalCategory.all
end | [
"def get_department_categories\n department = Department.find(params[:department_id])\n categories = department.categories\n json_response(categories)\n end",
"def get_appcon_categories \n get(\"/appcon.json/categories\")\nend",
"def get_appcon_categories \n get(\"/appcon.json/categories\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /hospital_categories POST /hospital_categories.json | def create
@hospital_category = HospitalCategory.new(hospital_category_params)
respond_to do |format|
if @hospital_category.save
format.html { redirect_to @hospital_category, notice: 'hospital_category was successfully created.' }
format.json { render :show, status: :created, location: @h... | [
"def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend",
"def index\n @hospital_categories = HospitalCategory.all\n end",
"def create\n @incidentcategory = Incidentcategory.new(incidentcategory_params)\n\n if @incidentcategor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /hospital_categories/1 PATCH/PUT /hospital_categories/1.json | def update
respond_to do |format|
if @hospital_category.update(hospital_category_params)
format.html { redirect_to @hospital_category, notice: 'hospital_category was successfully updated.' }
format.json { render :show, status: :ok, location: @hospital_category }
else
format.html ... | [
"def update\n respond_to do |format|\n if @incidentcategory.update(incidentcategory_params)\n json_response(@incidentcategory)\n else\n render json: @incidentcategory.errors, status: :unprocessable_entity\n end\n end\n end",
"def update\n respond_to do |format|\n if @ch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /hospital_categories/1 DELETE /hospital_categories/1.json | def destroy
@hospital_category.destroy
respond_to do |format|
format.html { redirect_to hospital_categories_url, notice: 'hospital_category was successfully deleted.' }
format.json { head :no_content }
end
end | [
"def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end",
"def destroy\n @hospitalization = Hospitalization.find(params[:id])\n @hospitalization.destroy\n\n respond_to do |format|\n format.html { redirect_to client_hospitalizations_url(@client) }\n format.json { he... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /server_infos/1 GET /server_infos/1.json | def show
@server_info = ServerInfo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @server_info }
end
end | [
"def show\n @name_server = NameServer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @name_server }\n end\n end",
"def server_info\n return @server_info if @server_info.present?\n response = request :get, SERVER_INFO_PATH\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /server_infos/new GET /server_infos/new.json | def new
@server_info = ServerInfo.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @server_info }
end
end | [
"def new\n @server = Server.new\n @creating_new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server }\n\n end\n end",
"def new\n @server = Server.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /server_infos POST /server_infos.json | def create
@server_info = ServerInfo.new(params[:server_info])
respond_to do |format|
if @server_info.save
format.html { redirect_to @server_info, notice: 'Server info was successfully created.' }
format.json { render json: @server_info, status: :created, location: @server_info }
el... | [
"def new\n @server_info = ServerInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_info }\n end\n end",
"def server_info\n update_server_info if @info_hash.nil?\n @info_hash\n end",
"def server_info\n {\n server:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /server_infos/1 PUT /server_infos/1.json | def update
@server_info = ServerInfo.find(params[:id])
respond_to do |format|
if @server_info.update_attributes(params[:server_info])
format.html { redirect_to @server_info, notice: 'Server info was successfully updated.' }
format.json { head :no_content }
else
format.html {... | [
"def update\n @server = compute.get_server(params[:id]).update(:name=>params[:name])\n respond_to do |format|\n format.html { redirect_to servers_path, :notice => 'Server was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def modify_server(server_uuid, params)\n data... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /server_infos/1 DELETE /server_infos/1.json | def destroy
@server_info = ServerInfo.find(params[:id])
@server_info.destroy
respond_to do |format|
format.html { redirect_to server_infos_url }
format.json { head :no_content }
end
end | [
"def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @server1 = Server1.find(params[:id])\n @serve... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optimize the left operand | def optimize_left
Function.optimize_operand(operation.left)
end | [
"def left_optimizable?\n !left.equal?(operation.left)\n end",
"def optimize_right\n Function.optimize_operand(operation.right)\n end",
"def wrap_left\n wrap_operand(operand.left)\n end",
"def left_restriction\n operand.left.restrict(partition.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Optimize the right operand | def optimize_right
Function.optimize_operand(operation.right)
end | [
"def optimize_right\n right = operation.right\n\n if right.respond_to?(:to_inclusive)\n optimize_right_range\n elsif right.respond_to?(:select)\n optimize_right_enumerable\n else\n right\n end\n end",
"def optim... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test if the left operand is optimizable | def left_optimizable?
!left.equal?(operation.left)
end | [
"def right_optimizable?\n !right.equal?(operation.right)\n end",
"def optimize_left\n Function.optimize_operand(operation.left)\n end",
"def optimizable?\n super || !predicate.equal?(operation.predicate)\n end",
"def calculated?\n if @op_optimized == ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test if the right operand is optimizable | def right_optimizable?
!right.equal?(operation.right)
end | [
"def optimize_right\n Function.optimize_operand(operation.right)\n end",
"def left_optimizable?\n !left.equal?(operation.left)\n end",
"def optimize_right\n right = operation.right\n\n if right.respond_to?(:to_inclusive)\n optimize_right_ran... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Marks inventory units short shipped. Adjusts the order based on the value of the inventory. Sends an email to the customer about what inventory has been short shipped. | def short_ship(inventory_units, whodunnit:nil)
if inventory_units.map(&:order_id).uniq != [@order.id]
raise ArgumentError, "Not all inventory units belong to this order"
end
unit_cancels = []
Spree::OrderMutex.with_lock!(@order) do
Spree::InventoryUnit.transaction do
inventory_unit... | [
"def ship(inventory_units:, stock_location:, address:, shipping_method:,\n shipped_at: Time.current, external_number: nil, tracking_number: nil, suppress_mailer: false)\n\n carton = nil\n\n Spree::InventoryUnit.transaction do\n inventory_units.each(&:ship!)\n\n carton = Spree::Carton.creat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Marks inventory unit canceled. Optionally allows specifying the reason why and who is performing the action. | def cancel_unit(inventory_unit, reason: Spree::UnitCancel::DEFAULT_REASON, whodunnit:nil)
unit_cancel = nil
Spree::OrderMutex.with_lock!(@order) do
unit_cancel = Spree::UnitCancel.create!(
inventory_unit: inventory_unit,
reason: reason,
created_by: whodunnit
)
invento... | [
"def cancel!(reason = nil)\n throw :cancel_transaction, reason\n end",
"def cancel(reason = nil)\n\t raise EventCanceled.new(self), (reason || \"event canceled\")\n\tend",
"def cancel(reason = nil)\n raise EventCanceled.new(self), (reason || \"event canceled\")\n end",
"def ca... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reimburses inventory units due to cancellation. | def reimburse_units(inventory_units)
reimbursement = nil
Spree::OrderMutex.with_lock!(@order) do
return_items = inventory_units.map(&:current_or_new_return_item)
reimbursement = Spree::Reimbursement.new(order: @order, return_items: return_items)
reimbursement.return_all
end
reimburse... | [
"def cancel!\n if charged && !canceled\n refund!\n recharge!\n end\n end",
"def cancel!(e, quantity)\n [e, e.matchee].each do |ex|\n ex.quantity -= quantity\n quantity.times {ex.registrations.pop}\n ex.save\n end\n end",
"def destroy_along_with_units\n sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /reservacions GET /reservacions.json | def index
@reservacions = Reservacion.all
end | [
"def index\n @reservacions = Reservacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reservacions }\n end\n end",
"def index\n # @user = current_user\n # @vacations = @user.vacations\n # @vacations = Vacation.find(user_id: current_user.i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find the maximum sub array in an array | def max_sub_array
(0...self.size).inject([self.first]) do |max_sub,i|
(i...self.size).each do |j|
if max_sub.int_sum < self[i..j].int_sum
max_sub = self[i..j]
end
end
max_sub
end
end | [
"def max_sub_array\n (0...self.size).inject([self.first]) do |max_sub,i|\n (i...self.size).each do |j|\n if max_sub.int_sum < self[i..j].int_sum\n max_sub = self[i..j]\n end\n end\n max_sub\n end\n end",
"def maxSubarray(arr)\n [_ma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /messages_comments/1 GET /messages_comments/1.json | def show
@messages_comment = MessagesComment.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @messages_comment }
end
end | [
"def new\n @messages_comment = MessagesComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @messages_comment }\n end\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /messages_comments/new GET /messages_comments/new.json | def new
@messages_comment = MessagesComment.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @messages_comment }
end
end | [
"def new\n @comment = @commentable.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /messages_comments POST /messages_comments.json | def create
@messages_comment = MessagesComment.new(params[:messages_comment])
respond_to do |format|
if @messages_comment.save
format.html { redirect_to @messages_comment, notice: 'Messages comment was successfully created.' }
format.json { render json: @messages_comment, status: :created... | [
"def create\n\t\t@comment = Comment.new\n\t\t@comment.comment = params[:message] \n\t\t@comment.user = current_user\n\t\t\n\t\t@comment.save\n\t\trespond_with(@comment)\n end",
"def create_comment\n @user = User.find(params[:user_id])\n @message = Message.find(params[:message_id])\n @comment = @message.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /messages_comments/1 PUT /messages_comments/1.json | def update
@messages_comment = MessagesComment.find(params[:id])
respond_to do |format|
if @messages_comment.update_attributes(params[:messages_comment])
format.html { redirect_to @messages_comment, notice: 'Messages comment was successfully updated.' }
format.json { head :no_content }
... | [
"def update\n @api_v1_comment = @post.comments.find(params[:id])\n params[:comment].delete :created_at\n params[:comment].delete :updated_at\n respond_to do |format|\n if @api_v1_comment.update_attributes(params[:comment])\n format.html { redirect_to @api_v1_comment, notice: 'Comment was suc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /messages_comments/1 DELETE /messages_comments/1.json | def destroy
@messages_comment = MessagesComment.find(params[:id])
@messages_comment.destroy
respond_to do |format|
format.html { redirect_to messages_comments_url }
format.json { head :no_content }
end
end | [
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @message.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n chat_id = @chat_comment.chat_id\n @chat_comment.d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Summary: Uploads the given file to the bucket, then gives up permissions to the bucket owner Details : intended to allow files to be uploaded to S3, but not allowing the files to be interfered with should the web server get hacked. In truth, S3 permissions aren't adequate and the best we can do is that the file can't b... | def upload_backup(aFileName,aBucketName,aObjectName = nil)
aObjectName ||= File.basename(aFileName)
AWS::S3::S3Object.store(aObjectName, open(aFileName), aBucketName)
bucket_owner = AWS::S3::Bucket.acl(aBucketName).owner
policy = AWS::S3::S3Object.acl(aObjectName,aBucketName)
policy.grants.clear
policy = po... | [
"def add_file_to_bucket(bucket_name, file_name)\n\t#init bucket object\n\tbucket = @s3.buckets[bucket_name]\n\n\t#check if file exists\n\tif !File.exist?(file_name)\n\t\tputs \"File '#{file_name}' does not exist. Please correct file path.\"\n\telse\n\t\tif bucket.exists?\n\t\t\t# upload a file\n\t\t\tbasename = Fil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check to see if there is already a scheduled job for the listserv id | def duplicate_scheduled_job?(listserv)
scheduled_queue = Sidekiq::ScheduledSet.new
scheduled_queue.any? { |job| check_for_duplicate(listserv, job) }
end | [
"def scheduled?(job_or_job_id)\n\n job, _ = fetch(job_or_job_id)\n\n !! (job && job.unscheduled_at.nil? && job.next_time != nil)\n end",
"def job_schedule_next\n # Check there isn't another job of this probe scheduled or waiting.\n if (self.jobs_waiting == 0)\n return true if (Sidekiq::Cli... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /pagemasters GET /pagemasters.json | def index
@pagemasters = Pagemaster.all
end | [
"def index\n @puppetmasters = Puppetmaster.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puppetmasters }\n end\n end",
"def index\n @page_masters = PageMaster.all\n end",
"def index\n @pharmaceutical_masters = PharmaceuticalMaster.page(par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /pagemasters POST /pagemasters.json | def create
@pagemaster = Pagemaster.new(pagemaster_params)
respond_to do |format|
if @pagemaster.save
format.html { redirect_to @pagemaster, notice: 'Pagemaster was successfully created.' }
format.json { render :show, status: :created, location: @pagemaster }
else
format.htm... | [
"def create\n @page_master = PageMaster.new(page_master_params)\n\n respond_to do |format|\n if @page_master.save\n format.html { redirect_to @page_master, notice: 'Page master was successfully created.' }\n format.json { render :show, status: :created, location: @page_master }\n else\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /pagemasters/1 PATCH/PUT /pagemasters/1.json | def update
respond_to do |format|
if @pagemaster.update(pagemaster_params)
format.html { redirect_to @pagemaster, notice: 'Pagemaster was successfully updated.' }
format.json { render :show, status: :ok, location: @pagemaster }
else
format.html { render :edit }
format.jso... | [
"def update\n respond_to do |format|\n if @page_master.update(page_master_params)\n format.html { redirect_to @page_master, notice: 'Page master was successfully updated.' }\n format.json { render :show, status: :ok, location: @page_master }\n else\n format.html { render :edit }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /pagemasters/1 DELETE /pagemasters/1.json | def destroy
@pagemaster.destroy
respond_to do |format|
format.html { redirect_to pagemasters_url, notice: 'Pagemaster was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @page_master.destroy\n respond_to do |format|\n format.html { redirect_to page_masters_url, notice: 'Page master was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gs1_master.destroy\n respond_to do |format|\n format.html {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load all words from a text file (one word per line) Keep only words that are 5 ascii letters or more Words all all lower case | def load(file)
words = File.readlines(file)
words = words.collect {|word| Word.new(word.chomp.downcase) }
change_wordlist(words.select {|word| word.word.length >= 5 && word.word =~ /^([a-z])+$/ })
self
end | [
"def words(filename)\n File.readlines(filename, encoding: 'iso-8859-1').\n map { |line| line.strip }.\n reject { |word| word != word.downcase }\nend",
"def load_words(file_name)\n words_loaded = []\n File.open(file_name).readlines.each do |line|\n words_loaded << line if line.length.betwee... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a new Dictionary with only the words of the given length | def with_only_words_of_size(len)
other = Dictionary.new
@dictionary_per_size[len] ||= @words.select{|word| word.word.length == len }
words = @dictionary_per_size[len]
other.add_words(words)
other
end | [
"def filter_by_length(length)\n filtered = @data.select { |word| word.length == length }\n Dictionary.new(filtered)\n end",
"def collect_words_of_length\n\t\t@dictionary.select! { |el| el.length == @word_length + 1 }\n\t\tmake_smart_dictionary\n\tend",
"def keep_only_words_of_length(len)\n cha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Access each Word individually | def [](index)
@words[index].word
end | [
"def display_words\n words = self.dictionary.map do |dictionary_entry|\n dictionary_entry.word.lexical_item\n end\n words \n end",
"def each_word(data=nil)\n\t\t\t#\tfrom our words\n\t\t\tself.words(data).each {|word| yield word }\n\t\tend",
"def idx_get_word(i)\n @tparses[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Filter out all words that don't have the given length | def keep_only_words_of_length(len)
change_wordlist(@words.select{|word,letters| word.word.length == len })
end | [
"def filter_lengths(strings, length=5)\n big_words = []\n strings.each { |ele| big_words << ele if ele.length >= length }\n return big_words\nend",
"def filter_lengths(strings, length=5)\n strings.select { |each| each.length >= length }\nend",
"def filter_lengths(strings, length=5)\n strings.select... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Filter out all words that contain the given letter | def reject_words_that_contain(letter)
change_wordlist(@words.select { |word,letters| word.word.index(letter) == nil })
end | [
"def wordsWithLetter(words, letter)\n #only select the words that contain that letter\n words.select{|word| word.include?(letter)} \nend",
"def words_with(*letters)\n @lines.select{ |term| \n letters.any?{ |letter|\n term.match(/#{letter}/) \n }\n }\n end",
"def remove_non_alpha_w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Keep only the words that match the partial solution | def keep_only_words_that_match(hangman_pattern)
pattern = Regexp.new('^' + hangman_pattern.gsub(/-/,'.') + '$')
change_wordlist(@words.select { |word,letters| word.word =~ pattern })
end | [
"def get_perfect_words\n filtered_text.split(WORDS_DELIMITER).reject { |w| !(3..9).include?(w.length) }\n end",
"def clean_results_of_partial_phrases(results)\n cleaned_results = []\n results.each do |current_result|\n current_result_phrase = current_result[0]\n\n cleaned_results << current_re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the number of words in the dictionary that contain the given letter | def words_that_contain(letter)
letter_count(letter)
end | [
"def word_count_by_letter(letter)\n\t\tputs \"#{@dictionary_analyzer.word_count_by_letter(letter, @dictionary)} words begin with the letter #{letter}\"\n\tend",
"def letter_counts(word) =\n word.chars.each_with_object(Hash.new(0)) { |c, counts| counts[c] += 1 }",
"def letter_frequency(letter)\n inner_word.c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a HangMan Solver puzzle should be a string of '' as long as the word to guess dictionary is a Dictionary. The solver can find words that are not in the dictionary strategy is an optional parameter to determine the letter choosing strategy a Strategy object should implement one method score_for(letter,dictionary)... | def initialize(puzzle,dictionary,strategy=MostFrequentStrategy.new)
@solution = puzzle.dup
@dictionary = dictionary.with_only_words_of_size(puzzle.length)
@possible_letters = ('a'..'z').to_a
@strategy = strategy
end | [
"def make_guess\n\t\tletter_occurrences = []\n\n\t\tif self.dictionary.length > 1\n\t\t\tLETTERS.each_with_index do |letter|\n\t\t\t\tletter_count = 0\n\n\t\t\t\tif letters_guessed.include?(letter.to_s)\n\t\t\t\t\tletter_occurrences << letter_count\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\t# next if letters_guessed.inc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the letter that the solver guesses Uses the strategy to determine the letter with the lowest score | def guess
letters = @possible_letters.collect {|letter| [ score_for(letter),letter ]}
letter = letters.min {|letter1,letter2| letter1 <=> letter2 }
letter[1]
end | [
"def make_guess\n\t\tletter_occurrences = []\n\n\t\tif self.dictionary.length > 1\n\t\t\tLETTERS.each_with_index do |letter|\n\t\t\t\tletter_count = 0\n\n\t\t\t\tif letters_guessed.include?(letter.to_s)\n\t\t\t\t\tletter_occurrences << letter_count\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\t# next if letters_guessed.inc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tell the solver that the letter does not appear in the solution | def wrong_guess(letter)
@possible_letters.delete(letter)
@dictionary.reject_words_that_contain(letter)
end | [
"def reject_words_that_contain(letter)\n change_wordlist(@words.select { |word,letters| word.word.index(letter) == nil })\n end",
"def guessed_wrong_letter()\n if $hidden_word_arr.exclude?($input)\n $guessed.append($input)\n end\n end",
"def letter_in_puzzle\n @display = []\n @excl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ramais GET /ramais.json | def index
@ramais = Ramal.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @ramais }
end
end | [
"def show\n @ramal = Ramal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ramal }\n end\n end",
"def index\n @aromas = Aroma.order(\"lower(name) ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ramais/1 GET /ramais/1.json | def show
@ramal = Ramal.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @ramal }
end
end | [
"def index\n @ramais = Ramal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ramais }\n end\n end",
"def show\n @raman = Raman.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ramais/new GET /ramais/new.json | def new
@ramal = Ramal.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @ramal }
end
end | [
"def new\n @ram = Ram.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ram }\n end\n end",
"def new\n @aroma = Aroma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @aroma }\n end\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /ramais POST /ramais.json | def create
@ramal = Ramal.new(params[:ramal])
respond_to do |format|
if @ramal.save
format.html { redirect_to @ramal, notice: 'Ramal criado com sucesso!' }
format.json { render json: @ramal, status: :created, location: @ramal }
else
format.html { render action: "new" }
... | [
"def create\n @alram = Alram.new(alram_params)\n\n respond_to do |format|\n if @alram.save\n format.html { redirect_to @alram, notice: 'Alram was successfully created.' }\n format.json { render :show, status: :created, location: @alram }\n else\n format.html { render :new }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /ramais/1 PUT /ramais/1.json | def update
@ramal = Ramal.find(params[:id])
respond_to do |format|
if @ramal.update_attributes(params[:ramal])
format.html { redirect_to @ramal, notice: 'Ramal alterado com sucesso!' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format... | [
"def update\n respond_to do |format|\n if @ramen.update(ramen_params)\n format.html { redirect_to @ramen, notice: 'Ramen was successfully updated.' }\n format.json { render :show, status: :ok, location: @ramen }\n else\n format.html { render :edit }\n format.json { render js... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /ramais/1 DELETE /ramais/1.json | def destroy
@ramal = Ramal.find(params[:id])
@ramal.destroy
respond_to do |format|
format.html { redirect_to ramais_url }
format.json { head :no_content }
end
end | [
"def destroy\n @raman = Raman.find(params[:id])\n @raman.destroy\n\n respond_to do |format|\n format.html { redirect_to ramen_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @alianza = Alianza.find(params[:id])\n @alianza.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Roundcurrent_card returns the current card to be answered. | def current_card
@deck.cards[@turns.count]
end | [
"def current_card\n @deck.cards[@round]\n end",
"def current_round\n response = @connection.get \"/contest/#{MPC_TOKEN}/round\"\n response.body\n end",
"def current_suit\n eight_played ? picked_suit : top_card.suit\n end",
"def current_value\n top_card.value\n end",
"def current_round\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Roundnumber_correct_by_category returns the amount of correct turns for a category. | def number_correct_by_category(category_select)
# Count the cards that are in the selected category and are guessed correct.
@turns.count do |turn|
turn.correct? && turn.card.category == category_select
end
end | [
"def number_correct_by_category(category)\n # isolate only turns where cards are in category\n cat_turns = []\n self.turns.each do |turn|\n if turn.card.category == category\n cat_turns << turn\n end\n end\n #check total number correct in this category specific turns array\n # cre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Roundpercent_correct returns the percentage of correct turns. | def percent_correct
# Check for divide by zero. Than calculate the percentage otherwise.
if @turns.size == 0
0.0
else
# Calculate percentage, truncate value to one decimal place.
((number_correct.to_f / @turns.size.to_f) * 100.0).truncate(1)
end
end | [
"def percent_correct\n # divide the current # of correct guesses by the total # of turns\n # multiply by 100 to change from fraction to percent\n if turns.length > 0\n perc = (self.number_correct.to_f / self.turns.length)* 100\n else\n perc = 0\n end\n return perc\n end",
"def questio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Roundpercent_correct_by_category returns the percentage of correct turns for a category. | def percent_correct_by_category(category_select)
# Count the current cards in the turns that match the category selected.
current_cards_category = @turns.count do |element|
element.card.category == category_select
end
# Check for divide by zero. Than calculate the percentage otherwise.
if @tu... | [
"def percent_correct_by_category(category)\n # get # of turns in category\n cat_turns = []\n self.turns.each do |turn|\n if turn.card.category == category\n cat_turns << turn\n end\n end\n # divide the current # of correct guesses by the total # of turns\n # multiply by 100 to cha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET a single time entry Return Teamwork::Thing | def time_entry(id)
object_from_response(:get, "time_entries/#{id}", "time-entry")
end | [
"def get_time_entry(xero_tenant_id, project_id, time_entry_id, opts = {})\n data, _status_code, _headers = get_time_entry_with_http_info(xero_tenant_id, project_id, time_entry_id, opts)\n data\n end",
"def show\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT a single time entry Return Teamwork::Thing | def update_time_entry(options = {})
object_from_response(:put, "time_entries/#{id}", "time-entry", "time-entry" => options)
end | [
"def update\n @time_entry = TimeEntry.find(params[:id])\n\n respond_to do |format|\n if @time_entry.update_attributes(params[:time_entry])\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method adds an +after_validation+ callback. ==== Parameters +polymorphic_association_name+ Name of the tree polumorphic association with container and component as the name of polymorphic attributes +type+ The component type in which to look for collection +collection_name+ The association name that should be used... | def validates_uniqueness_in_memory_for_tree_polymorphism(polymorphic_association_name, type, collection_name, attribute, options = {})
after_validation do
validate_unique_nested_attributes_for_tree_polymorphism self, polymorphic_association_name, type, collection_name, attribute, options
end
... | [
"def _setup_ldap_association_callback\n ldap_options[:associations].each do |ldap_attribute,assoc_a|\n assoc = assoc_a[0]\n method = assoc_a[1]\n raise \"Missing ldap_attribute\" unless ldap_attribute\n raise \"Missing association name\" unless assoc\n raise \"Mis... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /managers POST /managers.json | def create
@manager = Manager.new(manager_params)
if @manager.save
render :show, status: :created, location: @manager
else
render json: @manager.errors, status: :unprocessable_entity
end
end | [
"def create\n\n @manager = Manager.new(params[:manager])\n\n respond_to do |format|\n if @manager.save\n format.html { redirect_to @manager, notice: 'Manager was successfully created.' }\n format.json { render json: @manager, status: :created, location: @manager }\n else\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /brothers GET /brothers.xml | def index
@brothers = Brother.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @brothers }
end
end | [
"def show\n @brothers = Brother.all\n @brother = Brother.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @brother }\n end\n end",
"def index\n @brothers = Brother.all\n end",
"def show\n @brother = Brother.find(params[:id])\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /brothers/1 GET /brothers/1.xml | def show
@brothers = Brother.all
@brother = Brother.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @brother }
end
end | [
"def index\n @brothers = Brother.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @brothers }\n end\n end",
"def index\n @brothers = Brother.all\n end",
"def show\n @brother = Brother.find(params[:id])\n\n respond_to do |format|\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /brothers/new GET /brothers/new.xml | def new
@brother = Brother.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @brother }
end
end | [
"def new\n @pneighbour = Pneighbour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pneighbour }\n end\n end",
"def new\n @brother = Brother.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /brothers POST /brothers.xml | def create
@brother = Brother.new(params[:brother])
respond_to do |format|
if @brother.save
flash[:notice] = 'Brother was successfully created.'
format.html { render :back }
format.xml { render :xml => @brother, :status => :created, :location => @brother }
else
form... | [
"def create\n @brother = Brother.new(brother_params)\n\n respond_to do |format|\n if @brother.save\n format.html { redirect_to @brother, notice: 'Brother was successfully created.' }\n format.json { render action: 'show', status: :created, location: @brother }\n else\n format.ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /brothers/1 PUT /brothers/1.xml | def update
@brother = Brother.find(params[:id])
respond_to do |format|
if @brother.update_attributes(params[:brother])
flash[:notice] = 'Brother was successfully updated.'
format.html { redirect_to roster_show_path(@brother) }
format.xml { head :ok }
else
#debugger
... | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end",
"def update\n @brot... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /brothers/1 DELETE /brothers/1.xml | def destroy
@brother = Brother.find(params[:id])
@brother.destroy
respond_to do |format|
format.html { redirect_to(brothers_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @browsenodeid = Browsenodeid.find(params[:id])\n @browsenodeid.destroy\n\n respond_to do |format|\n format.html { redirect_to(browsenodeids_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @brother = Brother.find(params[:id])\n @brother.destroy\n\n resp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.