query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Adds errors if ptainstructor_is_valid? returns false | def ptainstructor_is_valid
errors.add(:ptainstructor,'No PTA instructor was selected.') unless ptainstructor_is_valid?
end | [
"def ptainstructor_is_valid?\n return self.ptainstructor_id != nil\n end",
"def teacher_is_valid\n errors.add(:teacher,'No classroom location was selected.') unless teacher_is_valid?\n end",
"def active_instructor\n return if self.instructor.nil?\n errors.add(:instructor, \"is not active\") unless... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests that the course's ptainstructor_id is not nil and returns true or false. | def ptainstructor_is_valid?
return self.ptainstructor_id != nil
end | [
"def can_create_course?\n ptainstructors = Ptainstructor.find_by_semester_id(self.id)\n teachers = Teacher.find_by_semester_id(self.id)\n if ((ptainstructors == nil) or (teachers == nil))\n return false\n end\n return true\n end",
"def ptainstructor_is_valid\n errors.add(:ptainstructor,'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if teacher_is_valid? returns false | def teacher_is_valid
errors.add(:teacher,'No classroom location was selected.') unless teacher_is_valid?
end | [
"def teacher_is_valid?\n return self.teacher_id != nil\n end",
"def teacher_required\n unless current_user.is_teacher == true\n redirect_to education_path\n end\n end",
"def validateTeacher\n user = getActiveUser(cookies)\n if user.user_account_type == 'teacher'\n return true\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests that the course's teacher_id is not nil and returns true or false. | def teacher_is_valid?
return self.teacher_id != nil
end | [
"def course_tutor?(current_user, course)\n !course.tutors.where(user_id: current_user.id, course_id: course.id).empty?\n end",
"def teacher_does_not_exist_yet(teacher_id)\n needs_to_be_created = true\n if !@teachers.nil? and @teachers.size > 0\n @teachers.each do |school, current_teachers|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns array with number of students in course and class_max. | def class_how_full?
return [self.students.count, self.class_max]
end | [
"def expected_grades\n assignment.course.students.count\n end",
"def num_grades(student)\n @grades[student].length\n end",
"def num_grades (student)\n @grades[student].length\n end",
"def find_largest_smaller_ten(courses_array)\n num = -1\n target = nil # If no course with less t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Characterizes the file at 'filepath' if available, otherwise, pulls a copy from the repository and runs characterization on that file. | def perform(file_set, file_id, filepath = nil, user = nil)
@event_start = DateTime.current
@relation = file_set.class.characterization_proxy
file = file_set.characterization_proxy
raise "#{@relation} was not found for FileSet #{file_set.id}" unless file_set.characterization_proxy?
filepath = Hyrax::... | [
"def perform(file_set, file_id, filepath = nil)\n raise \"#{file_set.class.characterization_proxy} was not found for FileSet #{file_set.id}\" unless file_set.characterization_proxy?\n # Ensure a fresh copy of the repo file's latest version is being worked on, if no filepath is directly provided\n filepath ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns array of tokens that cover the value that the parameter token has as its default Search forward to find value assigned to this parameter We want to find the thing after `=` and before `,` | def extract_default_value_tokens(ptok)
value_tokens = []
token = ptok.next_code_token
nesting = 0
while token
case token.type
when :LPAREN, :LBRACK
nesting += 1
when :RBRACK
nesting -= 1
when :RPAREN
nesting -= 1
if nesting.negative?
# Th... | [
"def scan_for_commas(token); end",
"def get_hash_tokens_for_parameter(tokens,parameter)\n get_tokens_between(tokens,:BRACE,parameter)\n end",
"def parameters\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 74 )\n return_value = ParametersReturnValue.ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of tokens that cover the data type of the parameter ptok Search backwards until we either bump into a comma (whilst not nested), or reach the opening LPAREN | def extract_type_tokens(ptok)
type_tokens = []
token = ptok.prev_code_token
nesting = 0
while token
case token.type
when :LBRACK
nesting += 1
when :LPAREN
nesting += 1
if nesting.positive?
# This is the LPAREN at the start of the parameter list
... | [
"def extract_default_value_tokens(ptok)\n value_tokens = []\n token = ptok.next_code_token\n nesting = 0\n while token\n case token.type\n when :LPAREN, :LBRACK\n nesting += 1\n when :RBRACK\n nesting -= 1\n when :RPAREN\n nesting -= 1\n if nesting.negativ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns true if this location has no more offerings | def isEmpty?
return self.offerings.count == 0
end | [
"def has_onsite_holdings?\n return false unless self[:location_facet].present?\n\n # consider each location for this record....\n self[:location_facet].each do |location_facet|\n # skip over anything that's offsite...\n next if location_facet =~ /^Offsite/\n next if location_facet =~ /ReCAP/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Format share descriptions a bit nicer by converting and to spaces. | def share_description(value)
raw(value).gsub("<br>", " ").gsub("<br />", " ")
end | [
"def share_description(value) \n raw(value).gsub(\"<br>\", \" \").gsub(\"<br />\", \" \")\n end",
"def format_description description\n \"#{description}\".ljust(30)\n end",
"def format_description(title, text=nil, indent=0, bullet=true)\n string = ' '*indent\n string << '- ' if bullet\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Link helper takes a URL and outputs a link with a custom label with http and www stripped out | def link_helper(url)
# set up another variable for the link
link = url
# add http if missing from url
if !url.include?("http://") && !url.include?("https://")
url = "http://" + url
end
# strip out http/https from link
if link.include?("http://") || link.include?("https://")
lin... | [
"def format_link_or_text(url)\n return url\n end",
"def external_link(label, path, **opt, &block)\n opt[:target] = '_blank' unless opt.key?(:target)\n make_link(label, path, **opt, &block)\n end",
"def link_to(text, url)\n \"<a href='#{url}' title='#{text}'>#{text}</a>\"\n end",
"def link(u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
SVG Image Helper Converts a dragonflystored SVG image to inline SVG with a missing asset fallback. | def svg_image(image)
raw image.data
rescue Dragonfly::Job::Fetch::NotFound
"Image missing"
end | [
"def svg!\n attr = ->(node) { ['src', 'data'].find {|k| node[k]} }\n @doc.css('img,iframe,embed,object[type=\"image/svg+xml\"]').select do |node|\n src = attr.call node\n Transformer.local_img?(node, ['src', 'data']) && MiniMime.lookup_by_filename(node[src])&.content_type == 'image/svg+xml'\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /feelings/1 GET /feelings/1.json | def show
@feeling = Feeling.find(params[:id])
@sake = Sake.find(params[:sake_id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @feeling }
end
end | [
"def update\n feeling = Feeling.find(params[:id])\n feeling.update(feeling_params)\n render json: feeling\n end",
"def index\n @feelings = Feeling.where(user: current_user).all\n end",
"def show\n @featuring = Featuring.find(params[:id])\n\n respond_to do |format|\n format.html ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /feelings/new GET /feelings/new.json | def new
@sake= Sake.find(params[:sake_id])
@feeling = Feeling.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @feeling }
end
end | [
"def new\n @featuring = Featuring.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @featuring }\n end\n end",
"def new\n @fatigue = Fatigue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fatigue ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /feelings/1 PUT /feelings/1.json | def update
@feeling = Feeling.find(params[:id])
respond_to do |format|
if @feeling.update_attributes(params[:feeling])
format.html { redirect_to @feeling, notice: 'Feeling was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
... | [
"def update\n feeling = Feeling.find(params[:id])\n feeling.update(feeling_params)\n render json: feeling\n end",
"def update\n respond_to do |format|\n if @feel.update(feel_params)\n format.html { redirect_to @feel, notice: 'Feel was successfully updated.' }\n format.json ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /feelings/1 DELETE /feelings/1.json | def destroy
@feeling = Feeling.find(params[:id])
@feeling.destroy
respond_to do |format|
format.html { redirect_to feelings_url }
format.json { head :ok }
end
end | [
"def destroy\n @featuring = Featuring.find(params[:id])\n @featuring.destroy\n\n respond_to do |format|\n format.html { redirect_to featurings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feel_swatch.destroy\n respond_to do |format|\n format.html { redir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends the notice unless it is one of the default ignored exceptions | def notify_or_ignore(exception, opts = {})
notice = build_notice_for(exception, opts)
send_notice(notice) unless notice.ignore?
end | [
"def notify_or_ignore(exception, context = {})\n send_notification(exception, context = {}) unless ignored?(exception)\n end",
"def notice_error(exception)\n return unless enabled? && agent\n\n agent.notice_error(exception)\n end",
"def notice!\n self.severity = :NOTICE\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If there is a file saved on the server for the record, this method sets its permissions using the nix +chmod+ command. +permissions+ should be an octalformat integer. The default setting when saving files is 0644. | def chmod(permissions = nil)
permissions ||= self.class.upload_options[:chmod]
File.chmod(permissions, full_path) if file_exists?
end | [
"def update_permissions_on_storage\n if @options[:perms]\n response = system(\"chmod -R o+w #{File.join(@path, 'storage')}\")\n if response\n say_success \"Updated permissions on storage/ directory.\"\n else\n say_failed \"Could not update permissions on storage/ director... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the full system path (including +RAILS_ROOT+) to the uploaded file, as specified by the record's current attributes. Used by +full_path+ in the event that no file exists. | def full_path_from_current_attributes
path = self.class.upload_options[:directory].
gsub(Regexp.new("^(#{RAILS_ROOT})?/?"), RAILS_ROOT + '/') + '/' +
instance_directory + '/' + send(self.class.upload_options[:filename])
path.gsub(/\/+/, '/')
end | [
"def file_full_path\n Rails.root.to_s + file_path.to_s\n end",
"def full_path\n if app_root.nil? || app_root.empty?\n path\n else\n File.join app_root, path\n end\n end",
"def path\n return self.saved? ? @realfile.path : nil\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Renames the uploaded file stored in the filesystem if the record's attribute changes have caused the file's path to change. Only works if the path is a function only of the record's own properties, not of the properties of any associations. Called using the +before_update+ callback in ActiveRecord::Base. | def rename_uploaded_file
return unless @uploaded_file.nil?
if file_exists? and full_path != full_path_from_current_attributes
ensure_directory_exists
File.rename(full_path, full_path_from_current_attributes)
remove_empty_directory
@saved_full_path = full_path_from_curre... | [
"def rename_file\n return unless filename_changed?\n\n old_full_filename = [base_path, filename_was].join(\"/\")\n\n object = self.class.bucket.objects.find(old_full_filename)\n new_object = object.copy(:key => full_filename, :acl => attachment_options[:acl])\n object.de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Makes sure that the appropriate directory exists so the file can be saved into it. | def ensure_directory_exists
dir = File.dirname(full_path_from_current_attributes)
FileUtils.mkdir_p(dir) unless File.exists?(dir)
end | [
"def ensure_tmpfile_dir_exists!\n FileUtils.mkdir_p(tmpfile_dir_pathname)\n end",
"def verify_directory\n FileUtils.makedirs @new_location\n end",
"def ensure_meta_info_dir_exists!\n FileUtils.mkdir_p(RubyFileReader::Reader.meta_info_dir_pathname)\n end",
"def ensure_directory(dir, fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes the file's directory if it is empty. Recusively deletes directories going up the tree until it reaches a nonempty directory. Thumbs.db and .DS_Store files are removed if they are the only contents of a directory. | def remove_empty_directory(path = nil)
dir = path || File.dirname(full_path)
dir.gsub!(/(\/+\.\.?\/*)*$/, '')
system_files = %w(Thumbs.db .DS_Store)
if File.directory?(dir) and !File.symlink?(dir) and (Dir.entries(dir) - %w(. ..) - system_files).empty?
system_files.each { |sys| File... | [
"def rm_empty_tree(path)\n raise ArgumentError, \"path cannot be a non-directory file\" if path.file?\n begin\n FileUtils.rmdir path, parents: true\n rescue Errno::ENOTEMPTY, Errno::EEXIST, Errno::ENOENT\n end\n end",
"def remove_empty_fs_dirs(path)\n return if (! File.exist? ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /exhibitior_categories/new GET /exhibitior_categories/new.json | def new
@exhibitior_category = ExhibitiorCategory.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @exhibitior_category }
end
end | [
"def new\n @new_category = NewCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_category }\n end\n end",
"def new\n @categorize = Categorize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /exhibitior_categories POST /exhibitior_categories.json | def create
@exhibitior_category = ExhibitiorCategory.new(params[:exhibitior_category])
respond_to do |format|
if @exhibitior_category.save
format.html { redirect_to @exhibitior_category, notice: 'Exhibitior category was successfully created.' }
format.json { render json: @exhibitior_categ... | [
"def create\n @categoria = Categoria.new(categoria_params)\n if @categoria.save\n render json: @categoria\n else\n render json: @categoria.errors, status: :unprocessable_entity\n end\n end",
"def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CA... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /exhibitior_categories/1 PUT /exhibitior_categories/1.json | def update
@exhibitior_category = ExhibitiorCategory.find(params[:id])
respond_to do |format|
if @exhibitior_category.update_attributes(params[:exhibitior_category])
format.html { redirect_to @exhibitior_category, notice: 'Exhibitior category was successfully updated.' }
format.json { hea... | [
"def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n req.url \"categories\"\n req.body = options.to_json\n end\n\n resp.status \n end",
"def update\n if @categoria.upd... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /exhibitior_categories/1 DELETE /exhibitior_categories/1.json | def destroy
@exhibitior_category = ExhibitiorCategory.find(params[:id])
@exhibitior_category.destroy
respond_to do |format|
format.html { redirect_to exhibitior_categories_url }
format.json { head :no_content }
end
end | [
"def destroy\n @exhibitor_category = ExhibitorCategory.find(params[:id])\n @exhibitor_category.destroy\n\n respond_to do |format|\n format.html { redirect_to exhibitor_categories_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n EconomicCategory.delete_hack(params[:id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Payments history for calendar month +month_period+ +month_period+ A string like 'yyyyMM' that represent month of year | def get_payments_history(month_period)
request('getPaymentsHistory', base_api_parameters.merge({ monthPeriod: month_period }))
end | [
"def month() end",
"def period\n case self.recurring_month\n when 12\n 1.year # 1.year != 12.months\n else\n self.recurring_month.months\n end\n end",
"def month(input) = (day_of_year(input) - 1) / 30 + 1",
"def months; end",
"def months() 30 * days end",
"def expiration_month\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Summary expenses report for calendar month +month_period+ +month_period+ A string like 'yyyyMM' that represent month of year | def get_expenses_summary(month_period)
request('getExpensesSummary', base_api_parameters.merge({ monthPeriod: month_period }))
end | [
"def total_month_expenses\n sum_expenses(expenses_this_month)\n end",
"def month() end",
"def expenses_this_month \n self.get_specific_expenses(30)\n end",
"def monthly_expenses\n expenses.group(:expended_at).sum(:amount).to_a.map{ |k,v| [ k.strftime('%v'), v ] }\n end",
"def Extract... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an Array of dependencies on the target | def dependency_list
@target.dependencies.map(&:display_name)
end | [
"def dependencies\n return @dependencies ||= []\n end",
"def dependencies\n @target_dependencies + (@parent ? @parent.dependencies : [])\n end",
"def dependencies\n @dependencies.collect { |name, dependency| dependency }\n end",
"def dependencies\n []\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns names of files with duplicates imports. | def files_with_duplicate_imports
files.select(&:has_duplicate_import?)
end | [
"def remove_duplicate_imports\n files.each(&:remove_duplicate_imports)\n end",
"def duplicate_imports_info\n import_frequency_mapping = {}\n all_imports.uniq.each do |item|\n item_occurrence = all_imports.count(item)\n if item_occurrence > 1\n import_frequency_mapping[item.chomp] = item... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the unused dependencies on the target | def unused_dependencies_list
imports = all_unique_imports.map { |import| import.split.last }
dependency_list - imports
end | [
"def remove_unused_dependencies\n # puts 'removing unused dependencies list.'\n dependencies = @target.dependencies\n dependencies.each do |dependency|\n dependency.remove_from_project if unused_dependencies_list.include? dependency.display_name\n end\n end",
"def remaining_dependencies\n dep... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removed the unused target dependencies on the target. | def remove_unused_dependencies
# puts 'removing unused dependencies list.'
dependencies = @target.dependencies
dependencies.each do |dependency|
dependency.remove_from_project if unused_dependencies_list.include? dependency.display_name
end
end | [
"def remove_all_dependencies\n super\n end",
"def delete_dependencies\n raise 'Not implemented'\n end",
"def prune_dependencies\n class_names = @classes.map {|klass| klass.name}\n @classes.each do |klass|\n klass.dependencies = klass.dependencies.uniq.keep_if {|dep| class_names.incl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes all the duplicate import statements from all the files linked to the target | def remove_duplicate_imports
files.each(&:remove_duplicate_imports)
end | [
"def remove_duplicate_imports\n duplicate_imports_mapping = duplicate_imports_info\n duplicate_imports = duplicate_imports_mapping.keys\n file_lines = IO.readlines(@path, chomp: true).select do |line|\n if duplicate_imports.include? line\n if duplicate_imports_mapping[line] <= 1\n line... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /businessbooks GET /businessbooks.json | def index
@businessbooks = Businessbook.search(params[:search]).paginate(:per_page => 18, :page => params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @businessbooks }
end
end | [
"def show\n @businessbook = Businessbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @businessbook }\n end\n end",
"def index\n @biblebooks = Biblebook.all\n\n respond_to do |format|\n format.html\n format.json{ ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /businessbooks/1 GET /businessbooks/1.json | def show
@businessbook = Businessbook.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @businessbook }
end
end | [
"def index\n @businessbooks = Businessbook.search(params[:search]).paginate(:per_page => 18, :page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @businessbooks }\n end\n end",
"def index\n @biblebooks = Biblebook.all\n\n respo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /businessbooks/new GET /businessbooks/new.json | def new
@businessbook = Businessbook.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @businessbook }
end
end | [
"def new\n @book = Book.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book }\n end\n end",
"def new\n @title = \"New Book\"\n @book = Book.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 /businessbooks POST /businessbooks.json | def create
@businessbook = Businessbook.new(params[:businessbook])
respond_to do |format|
if @businessbook.save
format.html { redirect_to @businessbook, :notice => 'Businessbook was successfully created.' }
format.json { render :json => @businessbook, :status => :created, :location => @bu... | [
"def create\n @books_on_loan = BooksOnLoan.new(params[:books_on_loan])\n respond_to do |format|\n if @books_on_loan.save\n format.json { render json: @books_on_loan, status: :created, \n location: @books_on_loan }\n else\n format.json {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /businessbooks/1 PUT /businessbooks/1.json | def update
@businessbook = Businessbook.find(params[:id])
respond_to do |format|
if @businessbook.update_attributes(params[:businessbook])
format.html { redirect_to @businessbook, :notice => 'Businessbook was successfully updated.' }
format.json { head :no_content }
else
for... | [
"def update\n @api_book = Api::Book.find(params[:id])\n\n if @api_book.update(api_book_params)\n head :no_content\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /businessbooks/1 DELETE /businessbooks/1.json | def destroy
@businessbook = Businessbook.find(params[:id])
@businessbook.destroy
respond_to do |format|
format.html { redirect_to businessbooks_url }
format.json { head :no_content }
end
end | [
"def destroy\n @api_book.destroy\n\n head :no_content\n end",
"def destroy\n @business = Business.find(params[:id])\n @business.destroy\n\n respond_to do |format|\n format.html { redirect_to businesses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @books_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /admin/digersayfas GET /admin/digersayfas.json | def index
@admin_digersayfas = Admin::Digersayfa.all
end | [
"def index\n @admin_pricing_kalafs = [Admin::Pricing::Kalaf.last] - [nil]\n\n respond_to do |format|\n format.html\n format.json { render json: @admin_pricing_kalafs.map { |i| { value: i.id, text: i.to_s } }, status: :ok }\n end\n end",
"def index\n @almanac_days = AlmanacDay.all\n\n res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /admin/digersayfas POST /admin/digersayfas.json | def create
@admin_digersayfa = Admin::Digersayfa.new(admin_digersayfa_params)
@turad = { 0 => "Bilim İnsanları", 1 => "Resmi Evraklar", 2 => "İlginç Bilgiler", 3 => "Motivasyon", 4 => "Sınav Sistemi"}
@tur = { 0 => "biliminsanlari", 1 => "resmievraklar", 2 => "ilgincbilgiler", 3 => "motivasyon", 4 => "sinav... | [
"def update\n respond_to do |format|\n if @admin_digersayfa.update(admin_digersayfa_params)\n format.html { redirect_to @admin_digersayfa, notice: 'Digersayfa was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_digersayfa }\n else\n format.html ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /admin/digersayfas/1 PATCH/PUT /admin/digersayfas/1.json | def update
respond_to do |format|
if @admin_digersayfa.update(admin_digersayfa_params)
format.html { redirect_to @admin_digersayfa, notice: 'Digersayfa was successfully updated.' }
format.json { render :show, status: :ok, location: @admin_digersayfa }
else
format.html { render :e... | [
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /admin/digersayfas/1 DELETE /admin/digersayfas/1.json | def destroy
@admin_digersayfa.destroy
respond_to do |format|
format.html { redirect_to admin_digersayfas_url, notice: 'Digersayfa was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete_guest_access_portal(args = {}) \n delete(\"/guestaccess.json/gap/#{args[:portalId]}\", args)\nend",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /instituicoes GET /instituicoes.json | def index
@instituicoes = Instituicao.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @instituicoes }
end
end | [
"def show\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instituicao }\n end\n end",
"def index\n @instituicos = Instituico.all\n end",
"def index\n @instituicaos = Instituicao.all\n end",
"def s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /instituicoes/1 GET /instituicoes/1.json | def show
@instituicao = Instituicao.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @instituicao }
end
end | [
"def index\n @instituicoes = Instituicao.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instituicoes }\n end\n end",
"def show\n @instalacion = Instalacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /instituicoes/new GET /instituicoes/new.json | def new
@instituicao = Instituicao.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @instituicao }
end
end | [
"def new\n @instalacion = Instalacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instalacion }\n end\n end",
"def new\n @indicativo = Indicativo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render jso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /instituicoes POST /instituicoes.json | def create
@instituicao = Instituicao.new(params[:instituicao])
respond_to do |format|
if @instituicao.save
format.html { redirect_to @instituicao, notice: 'Instituicao was successfully created.' }
format.json { render json: @instituicao, status: :created, location: @instituicao }
e... | [
"def create\n @instituico = Instituico.new(instituico_params)\n\n respond_to do |format|\n if @instituico.save\n format.html { redirect_to @instituico, notice: 'Instituição criada com sucesso.' }\n format.json { render :show, status: :created, location: @instituico }\n else\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /instituicoes/1 PUT /instituicoes/1.json | def update
@instituicao = Instituicao.find(params[:id])
respond_to do |format|
if @instituicao.update_attributes(params[:instituicao])
format.html { redirect_to @instituicao, notice: 'Instituicao was successfully updated.' }
format.json { head :no_content }
else
format.html ... | [
"def update\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n if @instituicao.update_attributes(params[:instituicao])\n format.html { redirect_to(@instituicao, :notice => 'Instituicao was successfully updated.') }\n format.xml { head :ok }\n else\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /instituicoes/1 DELETE /instituicoes/1.json | def destroy
@instituicao = Instituicao.find(params[:id])
@instituicao.destroy
respond_to do |format|
format.html { redirect_to instituicoes_url }
format.json { head :no_content }
end
end | [
"def destroy\n @instituicao.destroy\n respond_to do |format|\n format.html { redirect_to instituicaos_url, notice: 'Instituição deletada com sucesso..' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instalacion = Instalacion.find(params[:id])\n @instalacion.destroy\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /data_items POST /data_items.json | def create
@data_item = DataItem.new(data_item_params)
respond_to do |format|
if @data_item.save
format.html { redirect_to @data_item, notice: 'Data item was successfully created.' }
format.json { render :show, status: :created, location: @data_item }
else
format.html { rend... | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n @item_data = ItemData.new(item_data_params)\n\n respond_to do |format|\n if @item_data.save\n format.html { redirect_to @item_data, notice: 'Item datum was successfully created.' }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the underlying type size in bits | def type_size
@type.size
end | [
"def bit_size_of(type)\n C.size_of_type_in_bits(self, type)\n end",
"def bitsize\n @length\n end",
"def sizeof(type)\n size_ptr = Pointer.new(:ulong_long)\n align_ptr = Pointer.new(:ulong_long)\n NSGetSizeAndAlignment(type, size_ptr, align_ptr)\n size_ptr[0]\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the size and signedness of the underlying type | def set_type_size(sz, signed = false)
tname = "#{signed ? "" : "U"}Int#{sz}"
t = eval tname
raise "unsupported bitfield type #{tname}" unless t
@type = t
@signed = signed
return sz
end | [
"def size=(s)\n self.width = self.height = @size = s\n end",
"def set_size(size = BlockSize)\n if size > MaxSize\n return @size_allowed = false\n end\n\n @biff_size = size\n @book_size = [size, BlockSize].max\n @size_allowed = true\n end",
"def set_integer!(value)\n @objects ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When people refer to a mountain they can use Mount Name, Name Mountain, Mt. Name, Name mtn ...etc | def aliases
myAliases = ""
if ['Mount ',' Mountain',' Peak'].any? {|word| self.name.include?(word)}
short = shortname
myAliases = "#{short} Mountain, Mount #{short}, Mt. #{short}, Mt #{short}, #{shortname} mt, #{shortname} mtn, #{short} mtn., #{short} Peak"
end
myAliases
end | [
"def pony_full_name(abbrev)\n \n name = \"\"\n if abbrev == \"rainbow\"\n name = \"Rainbow Dash\"\n elsif abbrev == \"fluttershy\"\n name = \"Fluttershy\"\n elsif abbrev == \"twilight\"\n name = \"Twilight Sparkle\"\n elsif abbrev == \"rarity\"\n name = \"Rarity\"\n elsif ab... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Searches for the nearest higher mountain in a given radius and sets that as the parent mountain Sets distance to parent mountain as well | def set_parent_mountain_by_radius radius
Place.find_by_radius(centerLatitude, centerLongitude, radius, (height||0)+1).where("type = 'Mountain'").each do |mountain|
distance = dist(mountain.centerLatitude, mountain.centerLongitude)
if distance < dist_to_parent && self != mountain
self.di... | [
"def refresh_nearby_mountains\n return unless self.height_changed? || self.latitude_changed? || self.longitude_changed?\n Mountain.find_by_radius(self.latitude,self.longitude,self.dist_to_parent + 20).where(\"type = 'Mountain'\").each do |mountain|\n next if mountain.height.nil? || mountain.dist_to_paren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look for mountains within radius to parent or 30km whichever is higher. If this mountain is higher than a mountain in this radius and closer than its parent then change that mountains parent to be this mountain and update its dist_to_parent | def refresh_nearby_mountains
return unless self.height_changed? || self.latitude_changed? || self.longitude_changed?
Mountain.find_by_radius(self.latitude,self.longitude,self.dist_to_parent + 20).where("type = 'Mountain'").each do |mountain|
next if mountain.height.nil? || mountain.dist_to_parent.nil?
... | [
"def set_parent_mountain_by_radius radius\n Place.find_by_radius(centerLatitude, centerLongitude, radius, (height||0)+1).where(\"type = 'Mountain'\").each do |mountain|\n distance = dist(mountain.centerLatitude, mountain.centerLongitude) \n if distance < dist_to_parent && self != mountain\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of Licensee::License instances | def licenses(options = {})
Licensee::License.all(options)
end | [
"def licenses\n @licenses ||= self.details['licenses'].collect{|l| License.new(self, l)}\n end",
"def licenses\n licenses = []\n uris = metadata[dataset_uri][dct.license.to_s]\n if uris.nil?\n []\n else\n uris.each do |uri|\n l = metadata[uri]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the license for a given path | def license(path)
Licensee.project(path).license
end | [
"def license\n File.read file_path('LICENSE') if license?\n end",
"def license_file_path(path = NULL)\n if null?(path)\n @license_file_path || File.join(install_dir, \"LICENSE\")\n else\n @license_file_path = File.join(install_dir, path)\n end\n end",
"def license_file\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Inverse of the confidence threshold, represented as a float By default this will be 0.1 | def inverse_confidence_threshold
@inverse ||= (1 - Licensee.confidence_threshold / 100.0).round(2)
end | [
"def inverse_confidence_threshold\n @inverse_confidence_threshold ||=\n (1 - (Licensee.confidence_threshold / 100.0)).round(2)\n end",
"def inverse_probability(p)\n case\n when p <= 0\n -1 / 0.0\n when p >= 1\n 1 / 0.0\n when (p - 0.5).abs <= Float::EPSILON\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the list of linked workitems ['role1:wid1', ..., 'roleN:widN'] | def links
tmp = []
@doc.xpath('//field[@id="linkedWorkItems"]/list/struct').each do |struct|
linked_wid = struct.xpath('item[@id="workItem"]').text
role = struct.xpath('item[@id="role"]').text
tmp << "#{role}:#{linked_wid}"
end
return tmp
end | [
"def workitems (store_name=nil)\n\n return load_user_workitems if store_name == 'users'\n return (@workitems[store_name] || []) if store_name\n\n # then return all the workitems the user has access to\n\n wis = load_user_workitems\n\n @store_names.inject(wis) do |r, sname|\n r += (@workitems[sna... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a link to another workitem with specified role | def add_link(lh)
lnk_wid = lh[:wid]
lnk_role = lh[:role]
# find or create the attach node
if @doc.xpath('//field[@id="linkedWorkItems"]/list').last.nil?
Nokogiri::XML::Builder.with(@doc.xpath('//work-item').last) do
field(:id => 'linkedWorkItems') {
list {}
}
end
end
... | [
"def add_link_to_work(source, work, work_item)\n node = MarcNode.new(\"work\", \"856\", \"\", \"##\")\n node.add_at(MarcNode.new(\"work\", \"u\", \"/admin/sources/#{work_item['id']}\", nil), 0)\n node.add_at(MarcNode.new(\"work\", \"z\", \"#{work_item['cmp']}: #{work_item['std_title']}\", nil), 0)\n nod... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete an organization's routing settings | def delete_routing_settings(opts = {})
delete_routing_settings_with_http_info(opts)
return nil
end | [
"def destroy\n @org_setting.destroy\n\n head :no_content\n end",
"def destroy\n @canonical_route.destroy\n end",
"def destroy\n @settings_path = SettingsPath.find(params[:id])\n @settings_path.destroy\n\n respond_to do |format|\n format.html { redirect_to(settings_paths_url) }\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the wrapup codes for a queue | def get_routing_queue_wrapupcodes(queue_id, opts = {})
data, _status_code, _headers = get_routing_queue_wrapupcodes_with_http_info(queue_id, opts)
return data
end | [
"def commands_for_key_queue\n (0).upto(self.key_queue.size - 1) do |i|\n key_sequence = self.key_queue[i..-1].map(&:to_s).join\n number_prefix = key_sequence.scan(/^[1-9][0-9]*/)[0] # 0 can be used in normal mappings.\n key_sequence = key_sequence[number_prefix.size..-1] if number_prefix\n co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get an organization's routing settings | def get_routing_settings(opts = {})
data, _status_code, _headers = get_routing_settings_with_http_info(opts)
return data
end | [
"def account_organization\n get('account/organization')\n end",
"def show\n @org_settings = current_user.organization.settings\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @settings }\n end\n end",
"def routing_mode\n return @ro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get Contact Center Settings | def get_routing_settings_contactcenter(opts = {})
data, _status_code, _headers = get_routing_settings_contactcenter_with_http_info(opts)
return data
end | [
"def get_account_settings\n acc_settings = self.quote.project.account.account_setting\n end",
"def get_settings\n settings = {}\n settings['sharing_scope'] = self.sharing_scope\n settings['access_type'] = self.access_type\n settings['use_custom_sharing'] = self.use_custom_sharing\n settin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the list of routing skills. | def get_routing_skills(opts = {})
data, _status_code, _headers = get_routing_skills_with_http_info(opts)
return data
end | [
"def skills\n\t\t[]\n\tend",
"def get_skills\r\n Skill.where(\"opportunity_id = ?\", opportunity_id).all\r\n end",
"def skills\n return @skills\n end",
"def get_profile_skills\n profile_skills = find_elements PROFILE_SKILLS_LOCATOR\n get_skills profile_skills\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add bulk routing language to user. Max limit 50 languages | def patch_user_routinglanguages_bulk(user_id, body, opts = {})
data, _status_code, _headers = patch_user_routinglanguages_bulk_with_http_info(user_id, body, opts)
return data
end | [
"def process_language_redirect\n # Add languages\n record.parts.each do |part|\n # Get language redirect configuration\n if part.name == 'config'\n # Loop all languages\n languages = []\n part.content.each_line do |language|\n # Get language name and bas... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Just calling model_cls.new(attrs) fails to account for embedded associations that are inherited with _type. We check for embedded associations and ensure that embeds_many and embeds_one are handled properly. | def _reify model_cls, attrs
disc_key = model_cls.discriminator_key
model_cls = attrs[disc_key].constantize if attrs[disc_key]
instance = model_cls.new
attrs.each do |k, v|
if (rel = model_cls.relations[k]) && rel.embedded?
# Reify the subrel
if rel.is_a... | [
"def nested_attributes_create(reflection, attributes)\n obj = reflection.associated_class.new\n nested_attributes_set_attributes(reflection, obj, attributes)\n after_validation_hook{validate_associated_object(reflection, obj)}\n if reflection.returns_array?\n send(refl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given an array of nonuniform length arrays, rightpad all arrays with zeros so they're the same size, then transpose the array. This is a destructive operation: the zeropadding modifies the arrayofarrays | def jagged_transpose(arrays)
max_length = arrays.map{ |a| a.length }.max
arrays.map{ |a| a.fill(0, a.length, max_length - a.length) }.transpose
end | [
"def pad_and_transpose(rounds_arr)\n rounds_arr.collect do |games_arr|\n case games_arr.size\n when 16 then [ 4, 9,14,19].each{|idx| games_arr.insert(idx, [nil]*4)}\n when 8 then [ 2, 5, 8,11].each{|idx| games_arr.insert(idx, [nil]*6)}\n when 4 then [ 1, 3, 5, 7].each{|idx| games_arr.insert... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /stock_gabarras/1 GET /stock_gabarras/1.xml | def show
@stock_gabarra = StockGabarra.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @stock_gabarra }
end
end | [
"def show\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n @stock_gabarra = StockGabarra.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /stock_gabarras/new GET /stock_gabarras/new.xml | def new
@stock_gabarra = StockGabarra.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @stock_gabarra }
end
end | [
"def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock }\n end\n end",
"def new\n @stock_set = StockSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @stock_set }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /stock_gabarras POST /stock_gabarras.xml | def create
@stock_gabarra = StockGabarra.new(params[:stock_gabarra])
respond_to do |format|
if @stock_gabarra.save
flash[:notice] = 'StockGabarra was successfully created.'
format.html { redirect_to(@stock_gabarra) }
format.xml { render :xml => @stock_gabarra, :status => :created... | [
"def create\n @stock = Stock.new(params[:stock])\n\n respond_to do |format|\n if @stock.save\n format.html { redirect_to(@stock, :notice => 'Stock was successfully created.') }\n format.xml { render :xml => @stock, :status => :created, :location => @stock }\n else\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /stock_gabarras/1 PUT /stock_gabarras/1.xml | def update
@stock_gabarra = StockGabarra.find(params[:id])
respond_to do |format|
if @stock_gabarra.update_attributes(params[:stock_gabarra])
flash[:notice] = 'StockGabarra was successfully updated.'
format.html { redirect_to(@stock_gabarra) }
format.xml { head :ok }
else
... | [
"def update\n @stock = Stock.find(params[:id])\n\n respond_to do |format|\n if @stock.update_attributes(params[:stock])\n flash[:notice] = 'Stock was successfully updated.'\n format.html { redirect_to(@stock) }\n format.xml { head :ok }\n else\n format.html { render :act... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /stock_gabarras/1 DELETE /stock_gabarras/1.xml | def destroy
@stock_gabarra = StockGabarra.find(params[:id])
@stock_gabarra.destroy
respond_to do |format|
format.html { redirect_to(stock_gabarras_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(scrap_xmls_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @stock = Stock.find(params[:id])\n @stock.destroy\n\n respond_to do |format|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an optional workout sumary If defaults are set returns standard summary. Otherwaise returns the start_workout partial | def workout_program(user)
return workout_summary(user) if user.started?
start_workout(user)
end | [
"def summary_default\n @summarizer.default if @summarizer.respond_to?(:default)\n end",
"def summary\n #render unless @output\n @summary\n end",
"def apply_summary; nil; end",
"def workout\n WorkoutPlan.new(plan)\n end",
"def total_workouts\n set_sport_by_user.count || 0\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
>> quiz = [0,0,0,1,0,0,1,1,0,1] >> count_quiz_completions(quiz) => "The number of participants who did not attempt Quiz 1 is 6 out of 10 total participants." | def count_quiz_completions(quiz_results)
no_quiz = quiz_results.count(0)
total = quiz_results.count
"The number of participants who did not attempt Quiz 1"\
" is #{no_quiz} out of #{total} total participants."
end | [
"def question_count\n return people.first.answered.size if people.length == 1\n\n people_answering = people.length\n questions = Hash.new 0\n people.each do |person|\n person.answered.each do |char|\n questions[char] += 1\n end\n end\n\n count = 0\n questions.each do |_, value|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Enables or disables the generation of events in the Page domain. | def page_events=(new_page_events)
new_page_events = !!new_page_events
if new_page_events != page_events
@rpc.call(new_page_events ? 'Page.enable' : 'Page.disable')
@page_events = new_page_events
end
new_page_events
end | [
"def enable\n @page.enabled = !@page.enabled\n @page.save\n redirect_to_pages\n end",
"def disable\n {\n method: \"Page.disable\"\n }\n end",
"def enable!\n @events_tracker = EventsTracker.new(events)\n end",
"def is_site_pages_creation_enabled=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns string containing respondent's first and last name | def respondent_full_name
[respondent_first_name, respondent_last_name].compact.join(' ')
end | [
"def full_name\n return \"#{first_name} #{last_name}\"\n end",
"def full_name_last_first\n return self.first_name unless (self.last_name.length > 0)\n return (self.last_name + \", \" + self.first_name)\n end",
"def full_client_name\n \"#{last_name}, #{first_name}\"\n end",
"def get_first_an... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
fixes birth number badly transfered from candidates | def fix_bad_birth_numbers(students = nil)
ActiveRecord::Base.connection.execute('SET NAMES UTF8')
notfound = []
students ||= Student.find(:all)
@@mylog.info "There are %i students" % students.size
students.each do |student|
if c = Candidate.find(:all, :conditions => ["birth_number ... | [
"def celebrate_birthday(age)\n\t\t@age = age + 1\n\t\treturn @age\n\tend",
"def fix_leader!(leader)\n\n if leader.length < 24\n # pad it to 24 bytes, leader is supposed to be 24 bytes\n leader.replace( leader.ljust(24, ' ') )\n elsif leader.length > 24\n # Also a problem, slice it... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
reads sident from webservice and change it for students | def repair_sident(indices)
@@mylog.info "There are %i students" % indices.size
@client = SOAP::NetHttpClient.new
service = SERVICE_URL + SIDENT_SERVICE_PATH
f = File.new("sident_errs.txt", "wb")
indices.each do |index|
@@mylog.info "Procesing index #%i" % index.id
service_... | [
"def student\n unless logged_user.student? then\n render_403 and return\n end\n\n if request.get? then\n @student = logged_user.student\n elsif request.put? then\n student = Student.find(logged_user.student.id)\n student.specialty_id = params[:specialty]\n student.course = param... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
copies corridor subject from one to another corridor | def copy_corridor_subject(from_specialization, to_specialization)
SpecializationSubject.find_all_by_specialization_id(from_specialization).each {|cs|
csn = cs.clone
csn.update_attribute(:specialization_id, to_specialization)
}
end | [
"def copy!(new_subject)\n copy(new_subject).save!\n end",
"def copy!(new_subject)\n copy(new_subject).save!\n end",
"def copy(new_subject)\n self.class.new(@attrs.merge(_subject: new_subject))\n end",
"def copy(set, mailbox); end",
"def change_subject item, subject\n return un... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
adds corridor subjects from type and subjects ids | def add_corridor_subjects(specialization_id, type, *ids)
ids.each {|i|
type.create(:subject_id => i, :specialization_id => specialization_id)
}
end | [
"def receiver_subjects(subject_type, options = {})\n # FIXME: DRY!\n subject_class = subject_type.to_s.classify.constantize\n\n cs = subject_class.\n select(\"DISTINCT #{ subject_class.quoted_table_name }.*\").\n with_received_ties &\n Tie.sent_by(self)\n\n if options[:incl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For each keyvalue pair in the second provided hash, predict the email given the format(s) in company_email_format_hash | def predict_email(prediction_dataset_hash)
prediction_dataset_hash.each do |name, domain|
new_email = EmailObject.new(name)
new_email.domain = domain
if @company_email_format_hash.key? domain
new_email.email_format = @company_email_format_hash[domain]
puts "Name: #{new_email.name} ... | [
"def emails_to_hash(emails)\n {\n :primary => emails.find { |email| email.primary }.email,\n :additional => emails.select { |email| !email.primary && email.verified}.map { |email| email.email }\n }\nend",
"def similarity_email e1, e2\n return { full: 1.0,\n name: 1.0,\n do... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
1. For a given person, return their favourite tv show | def tv_show(person)
return person[:favourites][:tv_show]
end | [
"def tv_show(person)\n return person[:favourites][:tv_show]\nend",
"def same_tv_show(people)\n tv_shows = {}\n same_tv_shows = {}\n\n for person in people\n show = person[:favourites][:tv_show]\n if tv_shows[show] != nil\n tv_shows[show] << person[:name]\n else\n tv_shows[show] = [person[:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def bin_decision_backup(past_yield, desired_yield) if(past_yield <= desired_yield) bin = 1 else bin = rand(2..10) end return bin end | def bin_decision(threshold)
tmp = rand(1..100)
if(tmp <= threshold)
bin = 1
else
bin = rand(2..10)
end
return bin
end | [
"def probability chance=5\n (rand(10)+1) <= chance\nend",
"def make_bet\n #TODO: strategic, semi-random bet based on hand and cash\n @bet = @min_bet\n end",
"def get_signal(rand_gen, a = 1)\r\n rand_gen.rand(2) == 0 ? -a : a\r\nend",
"def generate_binary\n binary_num = []\n\n 8.times do... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find a move number of a possible fork: | def move_number_fork
current = @game.current_player
if current == :O
@count_spots.last if @game.fork?.size > 1
end
end | [
"def forks_number\n number = fork? ? fork.forks_count : forks_count\n number ||= 0\n end",
"def fork_check(wins, player, opponent)\n block_fork = find_fork(wins, opponent, player)\n get_fork = find_fork(wins, player, opponent)\n if get_fork.size > 0 # if possible to create fork, do it\n move... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return an array of primary region replicas tableName table to return regions for | def getPrimaryRegionEncodedNames(tableName)
c = HBaseConfiguration.new()
tableNameObj = TableName.valueOf(tableName)
t = HTable.new(c, tableNameObj)
regions = t.getRegionsInRange(t.getStartKeys[0],
t.getEndKeys[t.getEndKeys.size-1])
priRegions = Array.new
regions.each do |r|
... | [
"def table_regions(name, start_row = nil, end_row = nil)\n raise NotImplementedError, \"Getting the table regions is not supported yet\"\n end",
"def index\n @region_tables = RegionTable.all\n end",
"def regions_for_select\n \t\tRegion.all.map { |p| [p.name, p.id] }\n \tend",
"def regions\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Distribute the regions in the array passed uniformly across the server array provided | def distributePrimaryRegions(priRegions)
c = HBaseConfiguration.new()
admin = HBaseAdmin.new(c)
servers = Array.new()
dServers = Array.new()
dServers = admin.getClusterStatus.getDeadServerNames()
serv = admin.getClusterStatus.getServers()
serv.each do |s|
if (!dServers.include?(s))
servers << s.... | [
"def shards(m, r=1); div(m).map{|n| [n,m/n*r]}; end",
"def distribute population\n\t\thowManyGroups=population.size / @groupSize\n\t\tif howManyGroups > @amountGroups\n\t\t\thowManyGroups=@amountGroups\n\t\tend\n\t\t \n\t\t@arrayGroups=Array.new\n\t\thowManyGroups.times do\n\t\t\tgroup=Group.new @groupSize\n\t\t\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes a new Ban object | def initialize(raw_ban)
@raw_ban = raw_ban
end | [
"def initialize (number, bots, flag)\n @number = number\n @bots = bots\n @ap = $ACTION_POINTS\n @flag = flag\n @mana = $MAX_MANA\n end",
"def initialize()\n @bet = \"user:#{settings.id}:bet\"\n @redis = settings.redis\n @redis_money = \"user:#{settings.id}:money\"\n @redis_chip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The player's Steam 64 bit ID | def steam_id
raw_ban['SteamId'].to_i
end | [
"def id\n raw_profile['steamid'].to_i\n end",
"def steam_id64\n @steam_id64 ||= self.class.resolve_vanity_url(@custom_url)\n end",
"def to_steamID64\n # overwrite 1 as universe for reasons\n return SteamID64.new(1, 1, 1, accountID * 2 + id)\n end",
"def id\n @custom_url || @s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
String containing the player's ban status in the economy. | def economy_banned_status
raw_ban['EconomyBan']
end | [
"def status_string\n if accepted?\n 'Loan Accepted'\n else\n \"Loan Rejected: #{reason}\"\n end\n end",
"def ban_reason\n info['banReason']\n end",
"def status_string\n [\"Pending\", \"Approved\", \"Denied\"].at(status)\n end",
"def status\n\t\tif @status_ == :victory\n\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Due to `if Jets::Stack.has_resources?` check early on in the bootstraping process The code has not been built at that point. So we use a placeholder and will replace the placeholder as part of the cfn template build process after the code has been built and the code_s3_key with md5 is available. | def code_s3_key
"code_s3_key_placeholder"
end | [
"def calculate_s3_key\n filename && place_id && source_id && \"places/#{place_id}/#{source_id}/#{filename}\" || nil\n end",
"def calculate_s3_key\n if photo && photo.filename && photo.source_id && name\n \"places/#{photo.place_id}/#{photo.source_id}/#{photo.file_parts[:root... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dump given message to the log device without any formatting. If no log device exists, return +nil+. | def <<(msg)
unless @logdev.nil?
@logdev.write(msg)
end
end | [
"def debug message\n @syslog.debug '%s', message\n end",
"def log message\n logger.info(\"[Pdftk] #{message}\") if logging?\n end",
"def debugonce(message)\n logger.debugonce(message)\n nil\n end",
"def print(message)\n out.print(message) unless silent?\n end",
"def log_capt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Close the logging device. | def close
@logdev.close if @logdev
end | [
"def close\n @logdev.close if @logdev\n end",
"def close\n @logdevs.each do |name, ld|\n ld[:dev].close\n end\n end",
"def closeLog()\n @logger.close() ;\n end",
"def close\n @log_file.close\n end",
"def close\n flush\n @log.close if @log.respond_to?(:close)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ios_topbars/new GET /ios_topbars/new.json | def new
@ios_topbar = @user.build_ios_topbar
respond_to do |format|
format.html # new.html.erb
format.json { render json: @ios_topbar }
end
end | [
"def new\n @topbar = Topbar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topbar }\n end\n end",
"def create\n @topbar = Topbar.new(params[:topbar])\n\n respond_to do |format|\n if @topbar.save\n format.html { redirect_to @topbar, n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /ios_topbars POST /ios_topbars.json | def create
@ios_topbar = @user.build_ios_topbar(params[:ios_topbar])
respond_to do |format|
if @ios_topbar.save
format.html { redirect_to user_ios_topbar_url, :flash => { success: 'Top Bar Color successfully created.' } }
format.json { render json: @ios_topbar, status: :created, location:... | [
"def create\n @topbar = Topbar.new(params[:topbar])\n\n respond_to do |format|\n if @topbar.save\n format.html { redirect_to @topbar, notice: 'Topbar was successfully created.' }\n format.json { render json: @topbar, status: :created, location: @topbar }\n else\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /ios_topbars/1 PUT /ios_topbars/1.json | def update
@ios_topbar = @user.ios_topbar
respond_to do |format|
if @ios_topbar.update_attributes(params[:ios_topbar])
format.html { redirect_to user_ios_topbar_url, :flash => { success: 'Top Bar Color successfully updated.' } }
format.json { head :no_content }
else
format.h... | [
"def update\n @topbar = Topbar.find(params[:id])\n\n respond_to do |format|\n if @topbar.update_attributes(params[:topbar])\n format.html { redirect_to @topbar, notice: 'Topbar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /ios_topbars/1 DELETE /ios_topbars/1.json | def destroy
@ios_topbar = @user.ios_topbar
@ios_topbar.destroy
respond_to do |format|
format.html { redirect_to new_user_ios_topbar_url, :flash => { success: 'Top Bar Color successfully deleted.' } }
format.json { head :no_content }
end
end | [
"def destroy\n @topbar = Topbar.find(params[:id])\n @topbar.destroy\n\n respond_to do |format|\n format.html { redirect_to topbars_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @android_topbar = @user.android_topbar\n @android_topbar.destroy\n\n respond_to d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Description Test useful to check correctness of conversion and cross browser visibility of all elements of kind Video Mode Html Specific filters ApplicationControlleradmin_authenticate Skipped filters ApplicationControllerauthenticate ApplicationControllerinitialize_location ApplicationControllerinitialize_players_coun... | def videos_test
end | [
"def validate_video_element(video_doc, video_options)\n expect(video_doc.at_xpath('video:thumbnail_loc').text).to eq(video_options[:thumbnail_loc])\n expect(video_doc.at_xpath('video:thumbnail_loc').text).to eq(video_options[:thumbnail_loc])\n expect(video_doc.at_xpath('video:gallery_loc').text).to eq(vi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Description Test useful to check correctness of conversion and cross browser visibility of all elements of kind Audio Mode Html Specific filters ApplicationControlleradmin_authenticate Skipped filters ApplicationControllerauthenticate ApplicationControllerinitialize_location ApplicationControllerinitialize_players_coun... | def audios_test
end | [
"def videos_test\n end",
"def show_display_page\n \tget \"/music_page/display\"\n \tassert_response :success\n \tassert_template \"display\"\n \tassert_equal 2, session[:music].size\n end",
"def test_wd_st_015\n printf \"\\n+ Test 015\"\n open_warning_diff_file\n click $warning_diff_x... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Description Main page of the section 'elements'. When it's called via ajax it's because of the application of filters, paginations, or after an operation that changed the number of items in the page. Mode Html + Ajax Specific filters ApplicationControllerinitialize_layout MediaElementsControllerinitialize_paginator | def index
get_own_media_elements
if @page > @pages_amount && @pages_amount != 0
@page = @pages_amount
get_own_media_elements
end
render_js_or_html_index
end | [
"def advance_search \n if params[:entity_type]==\"static-fragment\"\n @page_properties={:selected_menu=>'static_fragment',:menu_title=>'Static Fragment List'}\n else\n @page_properties={:selected_menu=>'static_articles',:menu_title=>'Static Page List'}\n end \n @search=true \n @search_data=Searc... | {
"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.