query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Retrieve the next subsection in the audit. :callseq: next_subsection(subsection) > subsection Returns the next subsection in the current section. If the current subsection is the last subsection in the section then the first subsection in the next section is returned. If there is no section following the current sectio... | def next_subsection(subsection)
section = self.checklist.sections.detect { |s| s.id == subsection.section_id}
i = section.subsections.index(subsection)
if i < section.subsections.size - 1
return section.subsections[i+1]
else
j = self.checklist.sections.index(section)
if j < self.check... | [
"def next_section\n @current_section = Elf.elf_nextscn(self,@current_section)\n\n if @current_section.null?\n @current_section = nil\n return nil\n else\n return Section.new(@current_section)\n end\n end",
"def previous_subsection(subsection)\n\n sect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve the previous subsection in the audit. :callseq: previous_subsection(subsection) > subsection Returns the previous subsection in the current section. If the current subsection is the first subsection in the section then the last subsection in the previous section is returned. If there is no section preceeding t... | def previous_subsection(subsection)
section = self.checklist.sections.detect { |s| s.id == subsection.section_id}
i = section.subsections.index(subsection)
if i > 0
return section.subsections[i-1]
else
j = self.checklist.sections.index(section)
if j > 0
return self.checklist.s... | [
"def previous_segment\n return nil if sibling_segments.empty?\n index = sibling_segments.sort_by(&:index).index(self)\n if index && index >= 1\n sibling_segments[index - 1]\n else\n nil\n end\n end",
"def previous_section\n section = course.sections.whe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update the audit's design check. :callseq: update_design_check(design_check_update, user) > nil Determine the type of update that was passed in, self or peer, and use the information to make the update to the stored design check. Also make sure that any update that requires a comment includes the comment. If a required... | def update_design_check(design_check_update, user)
self.errors.clear
self_audit_result = design_check_update[:designer_result]
peer_audit_result = design_check_update[:auditor_result]
updated = false
design_check = DesignCheck.find(design_check_update[:design_check_id])
if self_audit_resu... | [
"def process_design_checks(design_check_list, user)\n\n # Go through the paramater list and pull out the checks.\n design_check_list.each { |design_check_update|\n\n design_check = DesignCheck.find(design_check_update[:design_check_id])\n\n if self.self_update?(user)\n result = design_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dump the audit and all of the associated design checks :callseq: dump_all() > [] Produces a dump of the audit. | def dump_all
puts "----------------------------------------------------------------------"
puts " AUDIT ID: #{self.id}\t\t\tDESIGN: #{self.design.directory_name}"
puts " DESIGN CHECKS: #{self.design_checks.size.to_s}"
puts " SELF COMPLETE: #{self.designer_complete?.to_s} " +
" #{self.desi... | [
"def audit\n audit_content([])\n end",
"def dump_constraints\n cs = constraints.map do |c|\n c = c.dup\n type = c.delete(:type)\n case type\n when :check\n raise(Error, \"can't dump check/constraint specified with Proc\") if c[:check].is_a?(Proc)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reset the audit and all of the associated design checks :callseq: reset() > [] Updates the audit record to reset as well as all of the associated design check records. | def reset
self.skip = false
self.designer_complete = false
self.designer_completed_checks = 0
self.auditor_complete = false
self.auditor_completed_checks = 0
self.save
now = Time.now
self.design_checks.each do |design_check|
design_check.audi... | [
"def reset_check_list\n audit_id = params[:audit_id]\n audit = Audit.find(audit_id)\n design_name = audit.design.name\n audit.clear_all_checks\n flash['notice'] = \"checklists for '#{design_name}' cleared\"\n #redirect_to(\"/audit/show_sections/#{params[:audit_id]}\")\n redirect_to( :action => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate an refund Use the payment of the transaction as refund money if amount is not explicitly specified | def generate_refund(transaction, amount = nil, options = {})
raise ArgumentError, "Invalid transaction state: #{transaction.state}" if transaction.state != "completed"
raise ArgumentError, "Transaction is not belongs to the order" if transaction.order != self
refunds.create(options.merge(amount: amount || ... | [
"def refund(amount: nil)\n api_request(\"/charges/#{id}/refund\", :post, amount: amount)\n end",
"def refund(money, card, transaction_id, options = {})\n if options[:refund_all].present?\n transaction { refund_all(transaction_id) }\n else\n transaction do\n refun... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Bootstrap styled flash helper | def bootstrap_flash_tag
return if flash.blank?
css_mapping = {notice: 'success', alert: 'danger', info: 'info'}
[:notice, :alert, :info].select{|type| flash[type].present?}.inject("") do |result, type|
inner_html = content_tag(:a, "x", class: "close", :'data-dismiss' => 'alert', href: "#") + flash[typ... | [
"def flash_notice\n if flash[:notice].present?\n content_tag(\"div\", h(flash[:notice]), {id: \"flash_notice\"})\n end\n end",
"def bootstrap_flash\n flash_messages = []\n flash.each do |type, message|\n # Skip empty messages, e.g. for devise messages set to nothing in a locale file.\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Displays a Bootstrap labeltag in green or red, depending on what +expression+ evaluates to. The default label content is 'Ja' or 'Nein' respectively and can be over === Parameters +expression+: determines green (truey) or red (falsey) label colour +value+: Alternative conditional output. Expected to be an Array like ['... | def boolean_label(expression, value = nil)
value = Array(value).compact
value = %w(Ja Nein) if value.empty?
value = expression ? value.first : value.last
content_tag :span, value, :class => "label label-#{expression ? 'success' : 'danger'}"
end | [
"def truth_label(is_true, true_label = 'true', false_label = 'false')\n content_tag(:span, is_true ? true_label : false_label,\n class: ['label', is_true ? 'label-success' : 'label-danger'])\n end",
"def true_label(is_true, true_label = 'true')\n content_tag(:span, true_label, class:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /expriences/1 GET /expriences/1.json | def show
@exprience = Exprience.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @exprience }
end
end | [
"def index\n @absences = @employee.absences\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @absences }\n end\n end",
"def index\n @excos = Exco.current.by_course_number\n\n respond_to do |format|\n format.html # index.html.haml\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /expriences/new GET /expriences/new.json | def new
@exprience = Exprience.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @exprience }
end
end | [
"def new\n @evidence = Evidence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evidence }\n end\n end",
"def new\n @negociation = Negociation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @neg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /expriences POST /expriences.json | def create
user=User.find_by_id(current_user.id)
@exprience = Exprience.new(params[:exprience])
@exprience.user=user
respond_to do |format|
if @exprience.save
format.html { redirect_to @exprience, notice: 'Exprience was successfully created.' }
format.json { render json: @exprience, status... | [
"def new\n @exprience = Exprience.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exprience }\n end\n end",
"def create\n @expence = Expence.new(expence_params)\n\n respond_to do |format|\n if @expence.save\n format.html { redirect_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /expriences/1 PUT /expriences/1.json | def update
@exprience = Exprience.find(params[:id])
respond_to do |format|
if @exprience.update_attributes(params[:exprience])
format.html { redirect_to @exprience, notice: 'Exprience was successfully updated.' }
format.json { head :no_content }
else
format.html { render act... | [
"def update\n @expence = Expence.find(params[:id])\n\n respond_to do |format|\n if @expence.update_attributes(params[:expence])\n format.html { redirect_to @expence, notice: 'Expence was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /expriences/1 DELETE /expriences/1.json | def destroy
@exprience = Exprience.find(params[:id])
@exprience.destroy
respond_to do |format|
format.html { redirect_to expriences_url }
format.json { head :no_content }
end
end | [
"def destroy\n @expence = Expence.find(params[:id])\n @expence.destroy\n\n respond_to do |format|\n format.html { redirect_to expences_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @annex = Annex.find(params[:id])\n @annex.destroy\n\n respond_to do |format|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new context starting with "given " | def given(name, parent=self, &block)
context("given " + name, parent, &block)
end | [
"def new_context(env)\n\n makara_context, makara_status = makara_values(env)\n\n context = nil\n\n # if the previous request was a redirect, let's keep that context\n if makara_status.to_s =~ /^3/ # 300+ redirect\n context = makara_context\n end\n\n context ||= Makara::Context.g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define the teardown for this context. It will also be run for any subcontexts, after their own teardown blocks | def teardown(&block)
self.teardown_blocks << block
end | [
"def teardown( *args )\n\t\t\tself.class.teardownMethods.each {|tblock|\n\t\t\t\tself.send( tblock )\n\t\t\t}\n\t\tend",
"def teardowns\n @parent.teardowns + @teardowns\n end",
"def teardown(&block)\n block ? @teardown << block : @teardown\n end",
"def teardown(*args, &block)\n set_ca... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this context has no known failed tests. | def passed?
failures.empty?
end | [
"def failed?\n !@test_case.search('./failure').empty?\n end",
"def any_work_units_failed?\n self.work_units.failed.count > 0\n end",
"def failed?\n\t\t\t\t@failures > 0\n\t\t\tend",
"def failed?\n return (@failed > 0)\n end",
"def failed_tests\n @failed_tests\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of tests in this and all subcontexts which failed in the previous run | def failures
ran_tests.select { |t| !t.passed? } + subcontexts.map { |s| s.failures }.flatten
end | [
"def failed_tests\n @failed_tests\n end",
"def failing_tests\n return self.product_tests.includes(:test_executions).select do |test|\n test.execution_state == :failed\n end\n end",
"def bugs_failed\n return @bug_differences if @bug_differences\n fail = []\n if self.tests and self.t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hydrate all the records in this collection from a database query | def load!
records_by_identity = index_by { |record| record.key_values }
record_set.find_each_row do |row|
identity = row.values_at(*record_set.key_column_names)
records_by_identity[identity].hydrate(row)
end
loaded_count = count { |record| record.loaded? }
i... | [
"def hydrate_objects_from_query(query_to_hydrate)\n hydrate_objects_query = HydrateObjectsQuery.new(\n klass: klass,\n query: query_to_hydrate,\n select_columns: [ klass.arel_table[Arel.star], :permission_actions ]\n )\n\n HydrateObjects.new(\n query: hydrate_objects_query... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /gethotelstaticdatagds/1 GET /gethotelstaticdatagds/1.json | def show
@gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @gethotelstaticdatagd }
end
end | [
"def show\n @gethotelstaticdatum = Gethotelstaticdatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gethotelstaticdatum }\n end\n end",
"def new\n # @gethotelstaticdatagd = Gethotelstaticdatagd.new\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /gethotelstaticdatagds/new GET /gethotelstaticdatagds/new.json | def new
# @gethotelstaticdatagd = Gethotelstaticdatagd.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @gethotelstaticdatagd }
end
end | [
"def new\n #@gethotelstaticdatum = Gethotelstaticdatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gethotelstaticdatum }\n end\n end",
"def new\n @gpath = Gpath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.js... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /gethotelstaticdatagds POST /gethotelstaticdatagds.json | def create
gethotelstaticdatagd = Gethotelstaticdatagd.get_hotel_static_data_gds(params)
respond_to do |format|
if gethotelstaticdatagd.body.include?("<boolean xmlns=\"http://www.reconline.com/\">true</boolean>")
flash[:notice] = 'Gethotelstaticdatagd was successfully created.'
format.htm... | [
"def new\n # @gethotelstaticdatagd = Gethotelstaticdatagd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gethotelstaticdatagd }\n end\n end",
"def create\n @gpsd = Gpsd.new(gpsd_params)\n\n if @gpsd.save\n render json: @gpsd, status: :create... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /gethotelstaticdatagds/1 PUT /gethotelstaticdatagds/1.json | def update
@gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])
respond_to do |format|
if @gethotelstaticdatagd.update_attributes(params[:gethotelstaticdatagd])
format.html { redirect_to @gethotelstaticdatagd, notice: 'Gethotelstaticdatagd was successfully updated.' }
format.jso... | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def set_or_update_arrays_for_floorplan(args = {}) \n id = args['id']\n temp_path = \"/floorplans.json/{floorplanId}/arrays\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"floorplanId\")\n args.de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /gethotelstaticdatagds/1 DELETE /gethotelstaticdatagds/1.json | def destroy
@gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])
@gethotelstaticdatagd.destroy
respond_to do |format|
format.html { redirect_to gethotelstaticdatagds_url }
format.json { head :no_content }
end
end | [
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @gethotelstaticdatum = Gethotelstaticdatum.find(params[:id])\n @gethotelstaticdatum.destroy\n\n respond_to do |format|\n format.html { redirect_to gethotelstaticdata_url }\n format.json { h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
display a single generic object | def show_single_generic_object
return unless init_show_variables
@lastaction = 'generic_object'
@item = @record.generic_objects.find { |e| e[:id] == params[:generic_object_id].to_i }
drop_breadcrumb(:name => _("%{name} (All Generic Objects)") % {:name => @record.name}, :url => show_link(@record, :displ... | [
"def show\n\t\t@typesobject = Typesobject.find(params[:id])\n\t\t# objets pouvant etre types\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xml => @typesobject }\n\t\tend\n\tend",
"def show\n @objecttype = Objecttype.find(params[:id])\n\n respond_to do |format|\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Replace the right cell of the explorer | def replace_right_cell(options = {})
if @flash_array && @refresh_partial == "layouts/flash_msg"
javascript_flash
return
end
action, replace_trees = options.values_at(:action, :replace_trees)
@explorer = true
partial, action_url, @right_cell_text = set_right_cell_vars(action) if action # ... | [
"def top_left_cell; end",
"def rightClicked\n\t\tcoreCell.secondaryChange()\n\tend",
"def cell=(cell); end",
"def edit_table_cell(table, coords)\n append_to_script \"edit_table_cell \\\"#{table}\\\" , \\\"#{coords}\\\"\"\n end",
"def active_cell; end",
"def set_cell(position, marker)\n grid[positio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Cleans up ThreadAccessor state after given block executes | def clean_thread_context(logger: nil, namespace: nil)
if store(namespace).present?
if logger.nil?
puts "WARNING: ThreadAccessor variables set outside ThreadAccessor context: #{store(namespace).keys.join(", ")}"
else
logger.warn("ThreadAccessor variables set outside Th... | [
"def without_locking(&block)\n self.class.without_locking(&block)\n end",
"def parallelize_teardown(&block)\n ActiveSupport::Testing::Parallelization.run_cleanup_hook(&block)\n end",
"def unblock(handle, offset, length); end",
"def destroy_block(&block)\n shrine_class.opts... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes issues tagged from multiple repos and combines them into a single array to use in ticket field | def combine_multiple_repos_issues
all_tagged_issues_array = []
repos = ENV[ "GIT_ISSUES_REPO" ]
repos = repos.split(' ')
repos.each do | a |
repos_issues = get_issues( a, ENV[ "GIT_LABEL" ] )
all_tagged_issues_array.push( repos_issues ).flatten!
end
return all_tagged_issues_array
end | [
"def repo_issues_and_prs(repo = nil)\n issue_ar = []\n pr_ar = []\n LetsGetBetter::Github.issues.each do |_id, issue_data|\n next unless issue_data['repository'] == repo || repo.nil?\n # sort based on the identified type\n if issue_data['is_pr']\n pr_ar << issue_data\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get issues from github repo and return the issues with a specific label This is separated from the cleaned issues as it may be used to provide a useful user facing display of issues | def get_issues( url, label )
issues = @git.client.issues( url, :per_page => 100 )
cleaned_issues = parse_issue_array( issues, label )
puts cleaned_issues.inspect
return cleaned_issues
end | [
"def issue_labels\n github_client.labels_for_issue(context.repo, context.issue_id).map { |l| l[:name] }\n end",
"def get_labels (pull_request)\n labels_url = pull_request[\"issue_url\"] + \"/labels\"\n labels = get_github_data labels_url\n\n return labels\nend",
"def open_issues_for(repo:, label: nil)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes an array of git issue hashes and puts what's needed into a santized array of hashes to display a cleaned title and tag in Zendesk | def clean_array_for_zendesk( issue_array )
titles = []
issue_array.each do | a |
issues = {}
title = a[ 'title' ]
url = a[ 'url' ]
url = url.gsub(/^https:\/\/github.com\/CozyCo\//, '')
url = url.gsub(/\/issue\w/, '')
url = url.to_s
issues[ 'name' ] = title + ' (' + url + ')'
url.gsub!(/\//, ... | [
"def collect_issues_from_commits \n all_issues = []\n git.commits.each do |c|\n captures = c.message.match(/^\\[(\\w+-\\d+)\\]*./)&.captures\n if captures\n all_issues.push(captures[0])\n end\n end\n all_issues.uniq\n end",
"def collect_issues_from_comm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Back up a file to our bucket | def backup(file)
raise(ArgumentError, "File #{file} does not exist") unless ::File.exist?(file)
contents = IO.binread(file)
begin
file_bucket_file = Puppet::FileBucket::File.new(contents, :bucket_path => @local_path)
files_original_path = absolutize_path(file)
dest_path = "#{@rest_path}#{f... | [
"def backup_to_s3(dir_name, file_path)\n connection = Fog::Storage.new(\n provider: 'AWS',\n aws_access_key_id: Figaro.env.aws_access_key,\n aws_secret_access_key: Figaro.env.aws_secret_access_key\n )\n\n bucket_name = Figaro.env.aws_source_files_backup_bucket\n bucket = connection.direct... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve a file by sum. | def getfile(sum)
source_path = "#{@rest_path}md5/#{sum}"
file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path)
raise Puppet::Error, "File not found" unless file_bucket_file
file_bucket_file.to_s
end | [
"def file_by_key_value(project_id, key_value)\n get(\"/files/#{project_id}/ByKeyValue\", value: key_value)\n end",
"def file_find(name)\n @file_hash[name]\n end",
"def get_file(name)\n=begin \t\n if name in @files:\n # Get only the first file\n return @files.geton... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Normalises the filename for use across platforms. | def normalize_filename
self.filename = Pathname.normalize_path(filename)
end | [
"def normalize(filename)\n str_strip(filename) + \".html\"\n end",
"def format_filename(filename)\n filename.gsub(/\\s/, '_').gsub(/\\W/, '').downcase \n end",
"def file_name(name)\n name.to_s.gsub(/-/, \"_\").underscore\n end",
"def file_name(s)\n s.gsub(/[\\s\\\\\\/]/, '_')\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of all the account employees. | def employees
emps = []
url = prefix + "liste"
users = response(url)
if users.class == Array #success
users.each do |u|
emps << User.new(u["id"], @authid, @subdomain)
end
return emps
else #failed
return users
end
end | [
"def get_employees\n @employees = User.find_user_not_admin_not_client(get_company_id)\n end",
"def list_employees(opts = {})\n data, _status_code, _headers = list_employees_with_http_info(opts)\n return data\n end",
"def employee_list\n \t@employees.map {|x| x.name}.join \"\\n\"\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of all the account clients. | def clients
clis = []
url = prefix + "listc"
users = response(url)
if users.class == Array #success
users.each do |u|
clis << User.new(u["id"], @authid, @subdomain, u)
end
return clis
else #failed
return users
end
end | [
"def list\n perform_request(action: \"client-list\")\n returned_parameters[\"clients\"]\n end",
"def all_clients\n clients.values\n end",
"def client_list\n request(:client_list)\n end",
"def all\n @clients.map {|identity, record| record.client }\n end",
"def list_al... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
has_primary_key postgres supports `db.primary_key`, mysql doesn't, so fall back to analyzing the schema. | def has_primary_key(db, table, key)
return db.primary_key(table) == key.to_s if db.respond_to?(:primary_key)
pk_column_info = db.schema(table).find { |column_info| column_info[0] == key }
return false if pk_column_info.nil?
pk_column_info[1][:primary_key] == true
end | [
"def primary_key?\n schema && schema[:primary_key]\n end",
"def primary_key?\n self.primary_key\n end",
"def need_associated_primary_key?\n true\n end",
"def need_associated_primary_key?\n true\n end",
"def schema_autoincrementing_primary_key?(schema)\n !!(schema... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: Remove any nested client channels that have empty UIDs, so that they don't fail validations when the user doesn't want to add them. | def remove_ignored_client_channel_uids
remove_ignored_uid_fields!(params[:client][:client_channels_attributes]) if params[:client]
true
end | [
"def prune_empty_groups\n @channels.each_value do |channel|\n channel.leave_group if channel.group? && channel.recipients.empty?\n end\n end",
"def clean_chans\n\t\tusers = self.users\n\t\t@chan.delete_if { |k, v|\n\t\t\tv.users &= users\n\t\t\tv.ops &= users\n\t\t\tv.voices &= users\n\t\t\tv.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /parent_types GET /parent_types.json | def index
@parent_types = ParentType.all
end | [
"def type_and_parent_types\n parents = Array.new\n parents.push(self)\n if self.parent\n parents.push(*self.parent.type_and_parent_types)\n end\n return parents\n end",
"def show\n @parent_type = ParentType.find(params[:id])\n end",
"def parent_type_from_request\n [*belongs_to]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /parent_types/1 GET /parent_types/1.json | def show
@parent_type = ParentType.find(params[:id])
end | [
"def index\n @parent_types = ParentType.all\n end",
"def parent_type\n @parent_type ||= parent_type_from_params || parent_type_from_request\n end",
"def parent_type\n @parent_type ||= parent_type_from_params || parent_type_from_request\n end",
"def parent_type_from_request\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /parent_types POST /parent_types.json | def create
@parent_types = ParentType.all
@parent_type = ParentType.create(parent_type_params)
=begin
respond_to do |format|
if @parent_type.save
format.html { redirect_to @parent_type, notice: 'Parent type was successfully created.' }
format.json { render :show, status: :created, loc... | [
"def create\n @shape_type = ShapeType.new(params[:shape_type])\n\n\t\t# get the parent shape type\n\t\tparent = ShapeType.find(params[:parent_shape])\n\n respond_to do |format|\n\t\t\tif parent.nil?\n format.html { render action: \"new\" }\n format.json { render json: @shape_type.errors, status:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /parent_types/1 PATCH/PUT /parent_types/1.json | def update
@parent_types = ParentType.all
@parent_type = ParentType.find(params[:id])
@parent_type.update_attributes(parent_type_params)
=begin
respond_to do |format|
if @parent_type.update(parent_type_params)
format.html { redirect_to @parent_type, notice: 'Parent type was successfully... | [
"def update\n @shape_type = ShapeType.find(params[:id])\n\n\t\t# get the parent shape type\n\t\tparent = ShapeType.find(params[:parent_shape])\n\n respond_to do |format|\n\t\t\tif parent.nil?\n\t format.html { render action: \"edit\" }\n\t format.json { render json: @shape_type.errors, status: :unpr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /parent_types/1 DELETE /parent_types/1.json | def destroy
@parent_types = ParentType.all
@parent_type = ParentType.find(params[:id])
@parent_type.destroy
=begin
@parent_type.destroy
respond_to do |format|
format.html { redirect_to parent_types_url, notice: 'Parent type was successfully destroyed.' }
format.json { head :no_content ... | [
"def destroy\n @parent.destroy\n respond_to do |format|\n format.html { redirect_to parents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent_of.destroy\n respond_to do |format|\n format.html { redirect_to parent_ofs_url }\n format.json { head :no_co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /expenses/1 PATCH/PUT /expenses/1.json | def update
respond_with Expense.update(params[:id], expense_params), status: 204
end | [
"def update\n @expense = Expense.find params.fetch(:id)\n\n if @expense.update(expense_params)\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_expense.update(api_v1_expense_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sorts the words (alphabetically). | def sortwords(words
return words.sort
end | [
"def sort_words\n audit\n @_sort_words ||= words.sort { |a, b| b.last <=> a.last }\n end",
"def sort_words(words)\n words.sort()\nend",
"def sortwords(words)\n return words.sort\nend",
"def word_sort\n result = nil\n result = self.seperate.sort\n result\n end",
"def sort( words )\n sorted... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints the last word after popping it off. | def 2print_last_word(words)
word = words.pop
puts word
end | [
"def print_last_word(words)\r\n puts words.pop\r\n end",
"def print_last_word(words)\n puts words.pop\n end",
"def prints_last_word(words)\n\tword = words.pop(1)\n\tputs word\nend",
"def print_first_word(words)\r\n puts word = words.pop(1)\r\n end",
"def prints_first_word(words)\n\tword = words.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ask the storage if the given file is movable. | def movable?(io, context)
storage.respond_to?(:move) && storage.movable?(io, context[:location])
end | [
"def movable?(destination = nil)\n deletable? && (!destination || (Page.find(destination) || Page.new(destination)).writable?)\n end",
"def movable?(user, destination = nil)\n deletable?(user) && (!destination || (Resource.find(destination) || Page.new(destination)).writable?(user))\n end",
"def can_mov... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pile state notionally contains whether a pile is Contraband this turn; but that's actually stored on the Game object because we wipe that clean each turn. Synthesise it onto the pile. | def state
ret = self[:state] || {}
if game.facts[:contraband] && game.facts[:contraband].include?(card_type)
ret[:contraband] = true
end
return ret
end | [
"def can_use_replacement_piles?\n hands.product(central_pile.top_cards).map { |hand, card| hand.possible_play?(card) }.none?\n end",
"def still_on_something?\n if carrying_card?\n card.hit?(mouse_pos)\n elsif pile\n pile.hit?(mouse_pos)\n else\n false\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Init a Syncer object, and start syncing | def start
syncer = Syncer.new(@local_directory, @store)
syncer.sync
end | [
"def start\n init_client unless @client\n\n log.info 'Bot starting to sync'\n\n @client.start_syncing\n end",
"def init_sync\n print \"starting sync\"\n things_projects_to_harvest\n puts \".finished. ciao!\"\n end",
"def initialize\n super\n\n self.callbacks = ::Act... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates in place the query values in params by folding the named procedures passed in through the values. | def process_params!(params, procedures)
params ||= {}
procedures ||= []
params["processed"] = true
ops = params_field_ops(params)
ops.each { |op, f|
query_key, query_value = f
# Fold the procedures onto the query value.
params[query_key] = procedures.reduce(query_v... | [
"def process_params!(params, procedures)\n params ||= {}\n procedures ||= []\n params[\"processed\"] = true\n\n # Do not process non query values\n ops = params.fetch(\"operator\", \"q\" => \"default\")\n .select { |key, value| key.match?(/^q/) }\n\n # query_key are like \"q_1\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Helper function that transforms the params in the typical blacklight_params advanced search format into a list of tuples of the form [[op, field])] where op is the operator and field is a key value pair, [query_key, query_value]. | def params_field_ops(params)
begin
fields = params.to_unsafe_h.compact.select { |k| k.match(/(^q$|^q_)/) }
ops = params.to_unsafe_h.fetch("op_row", ["default"])
ops.zip(fields)
rescue
[]
end
end | [
"def extract_params(query, params = nil)\n if params.nil?\n if query.key? :query\n params = {}\n else\n params, query = query, nil\n end\n end\n [query, params]\n end",
"def params_array_from(raw_params)\n raw_params.map { |param|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Description: Following action will list all the snacks in listing page. Argument: NIL Return: Products with(id, name) =end | def get_snacks_list
@complete_snacks_list = Spree::Product.select('id, name').limit(10).order("updated_at desc")
end | [
"def snacks\n\n @snacks = Spree::Product.limit(5).order('id desc')\n @snacks.sort_by! { |x| x[:name].downcase }\n end",
"def index\n @snacks = Snack.all\n end",
"def list_snacks\n snacks = Snack.all\n snacks.each do |snack|\n puts \"#{snack.name}\"\n snack.machines.each do |machine|\n pu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is a helper method for adding methods to return the paths of each of the versions of an image. The attachment_name parameter should be the name of the attachment as created in the model. The param_name is the name by which it is referred to in the drop. So, if you have an attachment called 'hack' in the model and ... | def has_attached_image(attachment_name, param_name=nil)
Spritz::ASSET_STYLES.keys.each do |image_name|
method_name = (param_name.blank? ? '' : "#{param_name}_") + "#{image_name}_path"
eval <<-END
def #{method_name}
@#{attachment_name}_#{image_name}_path ||= source.#{attachment_name}.fi... | [
"def define_attachment_methods!\n attachment = self\n name = attachment_name\n\n define_method :\"#{name}_attacher\" do |**options|\n if !instance_variable_get(:\"@#{name}_attacher\") || options.any?\n instance_variable_set(:\"@#{name}_attacher\", attachment.build_attacher(s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This will copy the key to the desired host | def copyKey (ip, username)
puts "Connecting to #{ip} with User -> #{username}....."
# Magic Command - the mirror to ssh-copy-id
system "cat ~/.ssh/id_rsa.pub | ssh #{username}@#{ip} 'mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys'"
end | [
"def copy_ssh_key\n copy_file_to_storage_directory(full_keypair_path)\n end",
"def copy_keydist_to( ca_sut = master, host_keydist_dir = nil )\n if !host_keydist_dir\n modulepath = on(ca_sut, 'puppet config print modulepath --environment production' ).output.chomp.split(':')\n host_keydis... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Let sum_of_proper_divisors(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If we run a number, num1, through the function, we will get num2. What if we run num2 through the function? If sum_of_proper_divisors(num1) == num2 AND sum_of_proper_divisors(num2) == num1, wher... | def sum_of_proper_divisors(n)
sum_factor1 = factors_numbers(n).reduce(:+)
number2 = sum_factor1
sum_factor2 = factors_numbers(number2).reduce(:+)
if (n == sum_factor2) && (number2 == sum_factor1) && (n != number2)
return "Yes, amicable with #{number2}"
else
"No"
end
end | [
"def find_proper_divisors_sum(num)\n\tsum = 0\n\tsqrt = Math.sqrt(num)\n\n\t# add all divisors into sum\n\t(1..sqrt).each do |n|\n\t\t# if num is a proper divisor\n\t\tif num % n == 0\n\t\t\t# add it--and its pair (other than 1 and sqrt)--into sum\n\t\t\tif [1,sqrt].include?(n)\n\t\t\t\tsum += n\n\t\t\telse\n\t\t\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Count the palindromes. Determine how many palindromes are in a string. Order of the string must be preserved. A palindrome is a string that is the same characters reading it forwards as reading it backwards. Anagram must be of length 3 or more and preserve the given order. EX: is_palindrome?("banana") == 2 there are 2 ... | def is_palindrome?(string)
counter = 0
if string.length == 0 || string.length == 1
return counter
elsif string[0]==string[-1]
is_palindrome?(string[1..-2])
counter += 1
elsif string[0]!=string[-1]
is_palindrome?(string[1..-1])
else
false
end
end | [
"def num_of_palindromes str\n total = 0\nfor i in 0...str.length do\n if(check_palindromes (str[i...str.length])) > 0\n total += check_palindromes (str[i...str.length])\n end\nend\ntotal\nend",
"def palindrome_permutation?\n normalized_string = downcase.gsub(/\\s+/, \"\")\n return true if normaliz... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define a method that chunks an array into a nested array of subarrays of length n. The last array may be of length less than n if the original array's size does not divide evenly by n. chunk([1,2,3,4,5], 2) => [[1,2], [3,4], [5]] | def chunk(array, n)
arr_result = []
sub_arr = []
i = 0
while i < array.length
num = array[i]
if sub_arr.length == n
arr_result << sub_arr
sub_arr = []
end
sub_arr << num
i += 1
end
arr_result << sub_arr
arr_result
end | [
"def chunk(array, n)\n result = []\n array.each_slice(n).each {|el| result << el}\n\n result\nend",
"def chunk(array, n)\n result = []\n i = array.size\n while i > 0\n slice = array[0,2]\n result << slice if slice != nil\n array = array[2..-1]\n i -= 2\n end\n result \nend",
"def chunk(array... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Define a method that multiplies the frequencies of the periods, commas, hyphens, semicolons, question marks, and exclamation points in a given string and returns the product. If any punctuation does not occur, don't include it in the product, i.e., don't multiply by zero! | def product_punctuation(str)
sign_str = "!.,-;?"
result = 1
if str == sign_str
return result
end
numbers_sign = str.each_char.count {|elem| sign_str.include?(elem)}
result *= numbers_sign
end | [
"def product_punctuation(str)\n #create a has with periods, commas, hyphens, semicolons, question marks, and exclamation points\n #select the pairs that have a value creater than 0\n #take the values and multiply them together\n\n punctuation_only = str.chars.select {|letter| \".,-;?!\".include?(letter) }\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /programmes GET /programmes.json | def index
@programmes = Programme.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @programmes }
end
end | [
"def index\n @programs = Program.where(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programs }\n end\n end",
"def show\n @programme = Programme.find(params[:id])\n\n respond_to do |format|\n format.html # show.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /programmes/1 GET /programmes/1.json | def show
@programme = Programme.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @programme }
end
end | [
"def index\n @programmes = Programme.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programmes }\n end\n end",
"def index\n @programs = Program.where(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /programmes POST /programmes.json | def create
@programme = Programme.new(params[:programme])
respond_to do |format|
if @programme.save
format.html { redirect_to @programme, notice: 'Programme was successfully created.' }
format.json { render json: @programme, status: :created, location: @programme }
else
form... | [
"def create\n @programme = Programme.new(programme_params)\n\n respond_to do |format|\n if @programme.save\n format.html { redirect_to @programme, notice: 'Programme was successfully created.' }\n format.json { render :show, status: :created, location: @programme }\n else\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /programmes/1 DELETE /programmes/1.json | def destroy
@programme = Programme.find(params[:id])
@programme.destroy
respond_to do |format|
format.html { redirect_to @programme.registration }
format.json { head :no_content }
end
end | [
"def destroy\n @programme = Programme.find(params[:id])\n @programme.destroy\n\n respond_to do |format|\n format.html { redirect_to programmes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @programme.destroy\n respond_to do |format|\n format.html { redirec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to generate the forecast text for the wind | def generate_forecast_text
@text = I18n.t("forecast_text.wind.text_start")
@text.concat(create_strength_text)
@text.concat(create_wind_text)
nil
end | [
"def generate_forecast_text\n @text = I18n.t(\"forecast_text.temperature.text_start\")\n @text.concat(create_warmth_text).concat(\".\")\n @text.concat(create_temperature_text)\n nil\n end",
"def generate_forecast_text\n if (!shall_it_rain?)\n @text = I18n.t(\"forec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to generate the warning text for the measurand | def generate_warning_text
@warnings
end | [
"def generate_warning_text\n if (@thresholds[:frost_day].is_active && !@thresholds[:ice_day].is_active)\n @warnings.concat\"\\n\" if (!@warnings.empty?)\n @warnings.concat(@thresholds[:frost_day].warning_text)\n end \n @warnings\n end",
"def warning_message; end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to generate the text with wind values | def create_wind_text
text = I18n.t("forecast_text.wind.text_maximum")
text.concat((@extreme_values.maximum * 3.6).ceil.to_s)
text.concat(I18n.t("forecast_text.wind.text_maximum_unit"))
text.concat(create_prevalent_direction_text)
text.concat(I18n.t("forecast_text.wind.text_mean")... | [
"def generate_forecast_text\n @text = I18n.t(\"forecast_text.wind.text_start\")\n @text.concat(create_strength_text)\n @text.concat(create_wind_text)\n nil\n end",
"def create_rain_text\n text = I18n.t(\"forecast_text.rain.text_maximum\")\n if (@thresholds[:continous... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to create the text for the prevalent wind direction | def create_prevalent_direction_text
if (@prevalent_direction == nil)
return I18n.t("forecast_text.wind.direction_circular")
end
return WrfForecast::Directions.new().get_direction_string(@prevalent_direction)
end | [
"def create_wind_text\n text = I18n.t(\"forecast_text.wind.text_maximum\")\n text.concat((@extreme_values.maximum * 3.6).ceil.to_s)\n text.concat(I18n.t(\"forecast_text.wind.text_maximum_unit\"))\n text.concat(create_prevalent_direction_text)\n text.concat(I18n.t(\"forecast_text.w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reads the database row identified by the primary key, and instantiates a model. | def read(id)
sql = "SELECT * FROM #{table_name} WHERE "
sql += Database.quote_identifier(@primary_key.name)
sql += " = "
sql += Database.quote_value(id, @primary_key.type)
sql += " LIMIT 1"
result = Database.execute(sql)
if result.cmd_tuples == 0
... | [
"def row_for_record\n raise IdMissing.new(\"You must set an ID before save.\") if record.id.blank?\n\n MassiveRecord::Wrapper::Row.new({\n :id => record.id,\n :table => klass.table\n })\n end",
"def load_model(mid)\n url = Configuration::P... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Let's check has been route setted or not. If not returns message, if yes, returns true | def route_check_true
if @route.nil?
puts 'Маршрут не установлен!!!'
else
true
end
end | [
"def any_empty_routing?\n self.empty?(self, \"routings\", false)\n end",
"def routes?\n @routes.any?\n end",
"def route?(addr)\n t(addr).route?(addr)\n end",
"def routing_params?\n routing_params.any?\n end",
"def route_exists?(route)\n !!self.route_for(route.nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Here we are setting previous station | def previous_station
if @current_station == @route.stations.first
@current_station
else
@current_station = @route.stations[@route.stations.index(@current_station) - 1]
end
end | [
"def go_to_previous_station\n @current_station.send_train self\n @current_station = previous_station\n @current_station.accept_train self\n end",
"def previous_station\n shift_station(-1) if @current_station != @route.stations.first\n end",
"def prev_station\n @route.stations[@current_station -... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Here we are setting next station | def next_station
if @current_station == @route.stations.last
@current_station
else
@current_station = @route.stations[@route.stations.index(@current_station) + 1]
end
end | [
"def go_to_next_station\n @current_station.send_train self\n @current_station = next_station\n @current_station.accept_train self\n end",
"def next_station\n shift_station(1) if @current_station != @route.stations.last\n end",
"def next_station\n @route.stations[@current_station + 1] if @route.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Moving ahead if route is setted | def ahead
if self.route_check_true
if @current_station != @route.stations.last
@route.stations[@route.stations.index(@current_station)].departure(self)
@current_station = next_station
@route.stations[@route.stations.index(@current_station)].coming(self)
end
end
end | [
"def ahead\n if self.route_check_true\n if @current_station != @route.stations.last\n @current_station = next_station\n end\n end\n end",
"def ahead\n @current_station = next_station if route_check_true && @current_station != @route.stations.last\n end",
"def process_route_end\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Moving back if route is setted | def backward
if self.route_check_true
if @current_station != @route.stations.first
@route.stations[@route.stations.index(@current_station)].departure(self)
@current_station = previous_station
@route.stations[@route.stations.index(@current_station)].coming(self)
end
end
end | [
"def backward\n if self.route_check_true\n if @current_station != @route.stations.first\n @current_station = previous_station\n end\n end\n end",
"def process_route_end\n if @move_route.repeat\n @move_route_index = -1\n elsif @move_route_forcing\n @move_route_forcing = fals... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
More like this is a separate function for returning similar documents, but it's included in the main search API. All other parameters are ignored if "similar_to" is present. | def more_like_this_query_hash
docs = content_index_names.reduce([]) do |documents, index_name|
documents << {
_id: search_params.similar_to,
_index: index_name,
}
end
{
more_like_this: {
like: docs,
min_doc_freq: 0, # Revert to the ES 1.... | [
"def search_similar(*args)\n Collection.search_similar(self, *args)\n end",
"def similar_documents\n Document.search do\n fulltext self.title\n end\n end",
"def find_similar(per_page = 11)\n query = self.body.split.collect do |word|\n word.gsub! /[^\\w]/, ''\n word if word.s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The total number of pages. | def page_count
@total_pages
end | [
"def total_pages\n pages.size\n end",
"def page_count\r\n @total_pages\r\n end",
"def total_pages\n (Float(total) / pagesize).ceil\n end",
"def number_of_pages\n return @number_of_pages\n end",
"def total_pages\n\t\t\t\treturn 0 if @total_results == ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
current_page + 1 or nil if there is no next page | def next_page
current_page < page_count ? (current_page + 1) : nil
end | [
"def next_page\r\n current_page < page_count ? (current_page + 1) : nil\r\n end",
"def next_page\n current_page < page_count ? (current_page + 1) : nil\n end",
"def next_page\n @current_page < num_pages ? (@current_page + 1): nil\n end",
"def next_page_number\n last_page? ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
time_taken? Takes a room or instructor, and given the time parameters from the form, check against all times object currently has. Attack this problem like a bounding box collision detection type of problem. If any time is invalid, time is not taken, so return false We work in 24h format, since we are going to use the ... | def time_taken?(model, ss_obj, params)
stime = time_format(params[:stime_h], params[:stime_m], params[:stime_p])
etime = time_format(params[:etime_h], params[:etime_m], params[:etime_p])
# Invalid time, do not care
return false if stime.nil? || etime.nil?
time_wanted = get_range_times(stime, etime... | [
"def check_time_ranges\n now = Time.current.strftime('%H:%M')\n s_time = start_time.strftime('%H:%M')\n e_time = end_time.strftime('%H:%M')\n now.between?(s_time, e_time)\n end",
"def timeRangeCheck(key, time)\n\t\tvalue = self.fetch(key.downcase, nil)\n\t\tif value and value =~ /(\\d\\d)(\\d\\d)(\\d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true only if we can determine that they do not have a qualification in maths or physics. If they are not sure about their ITT specialism, they may still qualify, otherwise we require that they have an ITT in maths or physics or a degree in either maths or physics. | def no_maths_or_physics_qualification?
!itt_specialism_not_sure? &&
!initial_teacher_training_specialised_in_maths_or_physics? &&
(has_uk_maths_or_physics_degree == "no")
end | [
"def qualifications_valid?\n not self.qualifications.empty?\n end",
"def requisites_met?(attributes)\n attributes_intrinsic_base_ids = attributes.map(&:intrinsic_base_id)\n intrinsic_base_ids.each do |id|\n return false unless attributes_intrinsic_base_ids.include? id\n end\n\n return true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When `greet` is invoked with `puts`, it should output the following: Hello World Make sure you add a space between `"Hello"` and `"World"`, however, you're not allowed to modify hello or world. ANSWER ====== For this problem, our `greet` method will return a string which will be the interpolation of the results of invo... | def greet
"#{hello} #{world}"
end | [
"def greet\n\thello + \" \" + world\nend",
"def greet\n puts '------------------------'\n puts \"Greetings to you #{@name}\"\n end",
"def greet(name)\n\tp \"Hello, #{name}!\"\nend",
"def greeting2(name, age)\n puts (\"Hola \" + name + \"! You are my new best \" + age.to_s + \" year old friend!\" )\nen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
construct_changes_strings sub: model_names series | def construct_changes_strings(model,operation,count=1)
expected=model_names model
case operation
when 'delet' then changed=expected.pop count
when 'add'
changed=series "added#{ 'picture'==model ? '.png' : '-name' }", count
expected=expected.take(count).concat changed
end
... | [
"def create_scenario_name(modifications)\n modifications.reduce('') do |acc, mod|\n name, value = mod.values_at( \"name\", \"value\")\n acc << \"#{name}=#{value}_\"\n end\nend",
"def new_model_names\n new_translations_model_name_keys - existing_model_names_keys\n end",
"def model_name_st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
mock_expected Perhaps, change: rename to, 'mock_all_my_models_expected'. Not show. sub: applicationdependent: mock_file_tags mock_directory_pictures mock_unpaired_names | def mock_expected(model,expected)
other='tag'==model ? [] : :all
t,p ='tag'==model ? [expected,other] : [other,expected]
mock_file_tags t
mock_directory_pictures p
mock_unpaired_names []
end | [
"def mock_model_bad_names(model,expected)\n model.expects(:find_bad_names).returns expected.sort.reverse\n end",
"def mock_model_unpaired_names(model,expected)\n model.expects(:find_unpaired_names).at_least_once.returns(\n expected.sort.reverse)\n end",
"def mock_model_simple(model,expe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
mock_model (pairs only) Perhaps, change, to use: 'model_pairs' (defined above). Or, pass two models. sub: (none) | def mock_model(model,method,expected)
expected=case
# See ActiveRecord::Base method, '==='. Another way is to use object_id:
when DirectoryPicture==model then Picture
when FileTag ==model then Tag
end.all.map &method if :all==expected
model.expects(:all).at_least_once.returns(expec... | [
"def mock_model_simple(model,expected=:all)\n mock_model model, :name, expected\n end",
"def mock_expected(model,expected)\n other='tag'==model ? [] : :all\n t,p ='tag'==model ? [expected,other] : [other,expected]\n mock_file_tags t\n mock_directory_pictures p\n mock_unp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
mock_model_bad_names Was, 'mock_directory_picture_bad_names', etc. Perhaps, change: instead, parameterize the model, making it: Invoke 'mock_model_bad_names(DirectoryPicture,expected)'. sub: (none) | def mock_model_bad_names(model,expected)
model.expects(:find_bad_names).returns expected.sort.reverse
end | [
"def mock_expected(model,expected)\n other='tag'==model ? [] : :all\n t,p ='tag'==model ? [expected,other] : [other,expected]\n mock_file_tags t\n mock_directory_pictures p\n mock_unpaired_names []\n end",
"def mock_model_simple(model,expected=:all)\n mock_model model, :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
mock_model_simple Was: mock_directory_pictures itself applicationdependent Perhaps, change: instead, parameterize the model, making it: Instead, invoke 'mock_model_simple(DirectoryPicture,expected)'. sub: mock_model | def mock_model_simple(model,expected=:all)
mock_model model, :name, expected
end | [
"def mock_model(model,method,expected)\n expected=case\n# See ActiveRecord::Base method, '==='. Another way is to use object_id:\n when DirectoryPicture==model then Picture\n when FileTag ==model then Tag\n end.all.map &method if :all==expected\n model.expects(:all).at_least_once.re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
mock_model_unpaired_names Was: mock_unpaired_names Perhaps, change: instead, parameterize the model, making it: Instead, invoke 'mock_model_bad_names(DirectoryPicture,expected)'. sub: (none) | def mock_model_unpaired_names(model,expected)
model.expects(:find_unpaired_names).at_least_once.returns(
expected.sort.reverse)
end | [
"def mock_model_bad_names(model,expected)\n model.expects(:find_bad_names).returns expected.sort.reverse\n end",
"def mock_expected(model,expected)\n other='tag'==model ? [] : :all\n t,p ='tag'==model ? [expected,other] : [other,expected]\n mock_file_tags t\n mock_directory_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
see_output good, as is Note: required is, 'App.root'. Is this automatic, in Rails? sub: (none) So, in a test, whether controller or view, you can say: see_output or see_output some_string and the generated web page will be copied, complete, into the file, 'out/seeoutput'. | def see_output(s=nil)
a = %w[rendered response].map{|e|(!respond_to? e) ? nil : (send e)}
a.push(a.pop.body) if a.last
(a.unshift s).compact!
assert_present a, 'nothing defined'
f=App.root.join('out/see-output').open 'w'
f.print a.first
f.close
end | [
"def output\n @output ||= get_test_case_metadata('output')\n end",
"def output\n @location + \"output\"\n end",
"def test_omakase_command_line_output\n omakase_state = @base_states[:omakase_state]\n\n render_inline(\n Shared::CommandLine::Output::Component.new(\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the list of Virtual Server names | def get_names(snmp = nil)
snmp = @snmp_manager unless snmp
if snmp
@names.clear
begin
snmp.walk([OID_LTM_VIRTUAL_SERV_STAT_NAME]) do |row|
row.each do |vb|
@names.push(vb.value)
end
end
rescue Exception =... | [
"def virtual_server_names\n get_virtual_server_configs.keys.sort\n end",
"def all\n @virtual_servers\n end",
"def vservers\n @vservers=get_endpoint('vservers').keys\n end",
"def serverlist\n execute([executable, \"--serverlist\"]).split(\"\\n\")\n end",
"def virtualserver... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get user info code from jwt | def get_user_info_from_id_token id_token
token_parts = id_token.split(".")
encoded_token = token_parts[1]
leftovers = token_parts[1].length.modulo(4)
if leftovers == 2
encoded_token << "=="
elsif leftovers == 3
encoded_token << "="
end
decoded_token = Base64.urlsafe_decode64(enco... | [
"def API_get_user_from_token(reqeust)\r\n \r\n # Get the token\r\n jwt_token = request.headers['Authorization'][4..-1]\r\n\r\n begin\r\n token_decoded = JWT.decode jwt_token, Rails.application.secrets.secret_key_base, true, { :algorithm => 'HS256' }\r\n user_id = token_decoded[0][\"sub\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
promote an artifact to a different environment | def promote_artifact
source_key = "#{ @environment_name }/#{ @artifact }/#{ @source_version }.gpg"
target_key = "#{ @target_environment_name }/#{ @artifact }/#{ @version }.gpg"
subsection "Promote artifact from s3://#{ @bucket.name }/#{ source_key } to s3://#{ @bucket.name }/#{ target_key }", c... | [
"def promote!(environment)\n environments << environment\n self.project.save!\n end",
"def promote_package(pkg, ref, platform_tag, repository, debian_component = nil)\n # load package metadata\n yaml_content = retrieve_yaml_data(pkg, ref)\n yaml_data = YAML::safe_load(yaml_content, [Symbol])... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If no adapter has been configured, use memory, then run the `after_initialize` method defined in the adapter if it's there | def initialize_adapter
# if no adapter has been initialized, use memory adapter
config[:adapter] ||= Adapters::Memory
extend config[:adapter]
after_initialize if respond_to? :after_initialize
end | [
"def after_initialize\n configuration.after_initialize_block.call if configuration.after_initialize_block\n end",
"def adapter_initialize\n end",
"def after_initialize\n end",
"def after_initialize\n self.class.after_initialize_hooks.each{ |hook| instance_exec(&hook) }\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the ticket is a server admin ticket | def server_admin_ticket?
# note that serverAdministrationFlag comes from the server as an Integer (0, or 1)
self['serverAdministrationFlag'] != 0
end | [
"def is_tracker_admin?\n self.tracker_admin_role != nil\n end",
"def is_admin\n admin = Configuration.find_by_key(\"admin\")\n if admin\n return fel_id[:user_id] == admin.value\n else\n return false\n end\n end",
"def admin?\n @admin ||= !!(session[:timer_admin_url_keys] && session... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override of service from ModelBase. Returns the SoftLayer_Ticket service set up to talk to the ticket with my ID. | def service
return softlayer_client[:Ticket].object_with_id(self.id)
end | [
"def service_ticket service_url\n ticket = request.params['ticket']\n return unless ticket\n ticket_class = ticket =~ /^PT-/ ?\n ::CASClient::ProxyTicket :\n ::CASClient::ServiceTicket\n\n st = ticket_class.new(ticket, service_url, false)\n log \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert the name into a legal C identifier | def identifier
name.gsub(/[^A-Za-z0-9_]/, '_')
end | [
"def idfy(name)\n name = 'x' + name unless /^[a-zA-Z]/ =~ name\n name.scan(/[-a-zA-Z0-9_:.]+/).join('_')\n end",
"def identifier_name\n return nil if (code = @codes[@pos]).nil?\n\n pos0 = @pos\n chars = []\n if code == 0x5c and ucode = unicode_escape? and identifier_start?(u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert the name into a legal C identifier | def identifier
name.gsub(/[^A-Za-z0-9_]/, '_')
end | [
"def idfy(name)\n name = 'x' + name unless /^[a-zA-Z]/ =~ name\n name.scan(/[-a-zA-Z0-9_:.]+/).join('_')\n end",
"def identifier_name\n return nil if (code = @codes[@pos]).nil?\n\n pos0 = @pos\n chars = []\n if code == 0x5c and ucode = unicode_escape? and identifier_start?(u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /item_acompanhamentos GET /item_acompanhamentos.json | def index
@item_acompanhamentos = ItemAcompanhamento.all
end | [
"def index\n @itemmodos = Itemmodo.all\n\n render json: @itemmodos\n end",
"def show\n @item_compra = ItemCompra.find(params[:id])\n $compra = @item_compra.compra\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_compra }\n end\n end",
"def i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /item_acompanhamentos POST /item_acompanhamentos.json | def create
@item_acompanhamento = ItemAcompanhamento.new(item_acompanhamento_params)
respond_to do |format|
if @item_acompanhamento.save
format.html { redirect_to @item_acompanhamento, notice: 'Item acompanhamento was successfully created.' }
format.json { render :show, status: :created, ... | [
"def create\n @item_compra = ItemCompra.new(params[:item_compra])\n\n respond_to do |format|\n if @item_compra.save\n $compra = @item_compra.compra\n flash[:notice] = 'Item compra criado com Sucesso.'\n format.html { redirect_to action: \"new\" }\n format.json { render json: @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /item_acompanhamentos/1 PATCH/PUT /item_acompanhamentos/1.json | def update
respond_to do |format|
if @item_acompanhamento.update(item_acompanhamento_params)
format.html { redirect_to @item_acompanhamento, notice: 'Item acompanhamento was successfully updated.' }
format.json { render :show, status: :ok, location: @item_acompanhamento }
else
fo... | [
"def update\n @item_compra = ItemCompra.find(params[:id])\n\n respond_to do |format|\n if @item_compra.update_attributes(params[:item_compra])\n format.html { redirect_to @item_compra, notice: 'Item Atualizado com Sucesso.' }\n format.json { head :no_content }\n else\n format.ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /item_acompanhamentos/1 DELETE /item_acompanhamentos/1.json | def destroy
@item_acompanhamento.destroy
respond_to do |format|
format.html { redirect_to item_acompanhamentos_url, notice: 'Item acompanhamento was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @item_consignado = ItemConsignado.find(params[:id])\n @item_consignado.destroy\n\n respond_to do |format|\n format.html { redirect_to item_consignados_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /administradors GET /administradors.json | def index
@administradors = Administrador.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @administradors }
end
end | [
"def administrators\n response = get('/admins.json')\n response.map{|item| Hashie::Mash.new(item)}\n end",
"def index\n @adminstrators = Adminstrator.all\n end",
"def index\n @administradors = Administrador.all\n end",
"def index\n @administrators = Administrator.all\n end",
"def in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /administradors/new GET /administradors/new.json | def new
@administrador = Administrador.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @administrador }
end
end | [
"def new\n @new = true\n @administrativo = Administrativo.new\n @administrativo.build_user\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @administrativo }\n end\n end",
"def new\n unless current_user.try(:admin?)\n redirect_to \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /usages/1 PATCH/PUT /usages/1.json | def update
respond_to do |format|
if @usage.update(usage_params)
format.html { redirect_to @usage, notice: 'Usage was successfully updated.' }
format.json { render :show, status: :ok, location: @usage }
else
format.html { render :edit }
format.json { render json: @usage.e... | [
"def update\n respond_to do |format|\n if @usage.update(usage_params)\n format.html { redirect_to @usage, notice: 'Usage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @usage.errors,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A has_many assocation with Containment via the item | def containments
item.containments
end | [
"def line_items\n has_many_association_proxy :line_items, (super || []), inverse_of: :container\n end",
"def items\n associations[:items] ||= Resource::DataBagItemCollectionProxy.new(self)\n end",
"def related_items\n related_items = { :coffee_pods => related_coffee_pods }\n related_items\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
fedex does not have address validation test service | def test_address_validation
response = nil
assert_nothing_raised do
#response = @carrier_prod.validate_addresses({'address_from' => @locations[:ottawa], 'address_to' => @locations[:beverly_hills]}, :test=>false)
@carrier_prod.validate_addresses({'address_from' => Location.new(
... | [
"def address_validation\n \"Y\"\n end",
"def check_address\n return unless migrated_for_validation?\n self.validated = deliverable_address?\n errors[:base] << Spree.t(:invalid_address) unless validated?\n end",
"def aramex_address_validation\n zones = Spree::ShippingMethod.where(['LOWER... | {
"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.