query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Return list of gem dev dependencies for which we have no corresponding requirements | def missing_dev_deps_for(gem)
# Same note as in #missing_deps_for above
gem.dev_deps.select { |dep| build_requirements_for_gem(dep.name).empty? }
end | [
"def missing_dev_deps_for(gem)\n # Same note as in #missing_deps_for above\n gem.dev_deps.select { |dep| build_requirements_for_gem(dep.name).empty? }\n end",
"def dependent_gems(check_dev=true)\n out = []\n Gem::Specification.each do |spec|\n deps = check_dev ? spec.dependencies : s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return list of dependencies of upstream gem which have not been included | def excluded_deps
missing_deps_for(upstream_gem)
end | [
"def excluded_deps\n missing_deps_for(upstream_gem)\n end",
"def excluded_dev_deps\n missing_dev_deps_for(upstream_gem)\n end",
"def remaining_dependencies\n dependencies = []\n @current_packages.each do |_, package|\n package.spec.dependencies.each do |dep|\n next ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return boolean indicating if the specified gem is on excluded list | def excludes_dep?(gem_name)
excluded_deps.any? { |d| d.name == gem_name }
end | [
"def excludes_dep?(gem_name)\n excluded_deps.any? { |d| d.name == gem_name }\n end",
"def excluded?(pkg_name)\n exclusions.include?(pkg_name)\n end",
"def ignore_gem?(name, version)\n ignored_gems[name].include?(version)\n end",
"def excludes_dev_dep?(gem_name)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return list of dev dependencies of upstream gem which have not been included | def excluded_dev_deps
missing_dev_deps_for(upstream_gem)
end | [
"def excluded_dev_deps\n missing_dev_deps_for(upstream_gem)\n end",
"def excluded_deps\n missing_deps_for(upstream_gem)\n end",
"def excluded_deps\n missing_deps_for(upstream_gem)\n end",
"def missing_dev_deps_for(gem)\n # Same note as in #missing_deps_for abov... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return boolean indicating if the specified gem is on excluded dev dep list | def excludes_dev_dep?(gem_name)
excluded_dev_deps.any? { |d| d.name == gem_name }
end | [
"def excludes_dev_dep?(gem_name)\n excluded_dev_deps.any? { |d| d.name == gem_name }\n end",
"def excludes_dep?(gem_name)\n excluded_deps.any? { |d| d.name == gem_name }\n end",
"def excludes_dep?(gem_name)\n excluded_deps.any? { |d| d.name == gem_name }\n end",
"def ex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all gem Requires | def gem_requirements
@metadata[:requires].nil? ? [] :
@metadata[:requires].select { |r| r.gem? }
end | [
"def gem_requirements\n requires.select { |r| r.gem? }\n end",
"def required_gem_list\n Mack::Utils::GemManager.instance.required_gem_list\n end",
"def do_requires\n @required_gem_list.each do |g|\n begin\n if g.version?\n gem(g.name, g.version)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all gem BuildRequires | def gem_build_requirements
@metadata[:build_requires].nil? ? [] :
@metadata[:build_requires].select { |r| r.gem? }
end | [
"def gem_build_requirements\n build_requires.select { |r| r.gem? }\n end",
"def gem_requirements\n requires.select { |r| r.gem? }\n end",
"def gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem? }\n end",
"def build_re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all non gem Requires | def non_gem_requirements
@metadata[:requires].nil? ? [] :
@metadata[:requires].select { |r| !r.gem? }
end | [
"def non_gem_requirements\n requires.select { |r| !r.gem? }\n end",
"def non_gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| !r.gem? }\n end",
"def non_gem_build_requirements\n build_requires.select { |r| !r.ge... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return all non gem BuildRequires | def non_gem_build_requirements
@metadata[:build_requires].nil? ? [] :
@metadata[:build_requires].select { |r| !r.gem? }
end | [
"def non_gem_build_requirements\n build_requires.select { |r| !r.gem? }\n end",
"def gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem? }\n end",
"def non_gem_requirements\n requires.select { |r| !r.gem? }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update spec dependencies from new source | def update_deps_from(new_source)
@metadata[:requires] =
non_gem_requirements +
extra_gem_requirements(new_source) +
new_source.deps.select { |r| !excludes_dep?(r.name) }
.collect { |r| RPM::Requirement.from_gem_dep(r) }.flatten
@metadata[:bu... | [
"def regenerate_specs\n existing_deps, _, _ = manifest.dependencies\n\n existing_deps.each do |dep|\n dep.regenerate_spec\n end\n end",
"def update!\n puts \"Updating gems...\"\n Bundler::CLI.new.update\n @new_spec_set = Bundler.definition.specs\n compute_changes\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal helper to update spec files from new source | def update_files_from(new_source)
to_add = new_source.file_paths
@metadata[:files] ||= {}
@metadata[:files].each { |pkg,spec_files|
(new_source.file_paths & to_add).each { |gem_file|
# skip files already included in spec or in dir in spec
has_file = ... | [
"def update_specfiles(version)\n spec_files.each do |spec_file|\n spec = File.read(spec_file)\n spec.gsub!(/^(\\s*)Version:(\\s*).*$/, \"\\\\1Version:\\\\2#{version}\")\n File.write(spec_file, spec)\n end\nend",
"def update_specs\n # download new specs to a temp directory\n new_specs_path = g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal helper to update spec metadata from new source | def update_metadata_from(new_source)
# update to new version
@metadata[:version] = new_source.version
@metadata[:release] = "1%{?dist}"
# add changelog entry
changelog_entry = <<EOS
* #{Time.now.strftime("%a %b %d %Y")} #{RPM::Spec.current_author} - #{@metadata[:versio... | [
"def update_files_from(new_source)\n to_add = new_source.file_paths\n @metadata[:files] ||= {}\n @metadata[:files].each { |pkg,spec_files|\n (new_source.file_paths & to_add).each { |gem_file|\n # skip files already included in spec or in dir in spec\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compare this spec to a sepecified upstream gem source and return result. upstream_source should be an instance of Polisher::Gem, Polisher::Gemfile, or other class defining a 'deps' accessor that returns an array of Gem::Requirement dependencies Result will be a hash containing the shared dependencies as well as those t... | def compare(upstream_source)
same = {}
diff = {}
upstream_source.deps.each do |d|
spec_reqs = self.requirements_for_gem(d.name)
spec_reqs_specifier = spec_reqs.empty? ? nil :
spec_reqs.collect { |req| req.specifier }
if spec_reqs.nil?
... | [
"def candidate_version_from_file(gem_dependency, source)\n spec = spec_from_file(source)\n if spec.satisfies_requirement?(gem_dependency)\n logger.trace { \"found candidate gem version #{spec.version} from local gem package #{source}\" }\n spec.version\n el... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Rotates the image based on the EXIF Orientation | def fix_exif_rotation
manipulate! do |img|
img.auto_orient
img = yield(img) if block_given?
img
end
end | [
"def rotate(img)\n exif = img.get_exif_by_entry(:Orientation)\n return img if !(exif && exif[0] && exif[0][0] == :Orientation)\n case exif[0][1]\n when '1' # Normal\n img\n when '6' # 90 degree\n img.rotate(90) # 90[deg] to clock direction\n when '8'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Are there any prerequisites with a later time than the given time stamp? | def out_of_date?(stamp)
@prerequisites.any? { |n| application[n].timestamp > stamp}
end | [
"def out_of_date?(stamp)\n @prerequisites.any? do |n| \n prereq_time = application[n, @scope].timestamp\n return false if prereq_time == Rake::EARLY\n\n prereq_time > stamp\n end\n end",
"def passed?(time = Time.zone.now)\n last = phases.order('phases.start ASC').l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
module Rake Declare a file task. Example: file "config.cfg" => ["config.template"] do open("config.cfg", "w") do |outfile| open("config.template") do |infile| while line = infile.gets outfile.puts line end end end end | def file(*args, &block)
Rake::FileTask.define_task(*args, &block)
end | [
"def file(*args, &block) # :doc:\n Rake::FileTask.define_task(*args, &block)\n end",
"def file(*args, &block)\n Rake::FileTask.define_task(*args, &block)\n end",
"def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\nend",
"def file_create(*args, &block)\n Rak... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Declare a file creation task. (Mainly used for the directory command). | def file_create(args, &block)
Rake::FileCreationTask.define_task(args, &block)
end | [
"def file_create(*args, &block)\n Rake::FileCreationTask.define_task(*args, &block)\n end",
"def file_create(args, &block)\n Rake::FileCreationTask.define_task(args, &block)\n end",
"def CreateFileTask(paramBag)\n filePath = paramBag[:filePath]\n dependencies = paramBag[:dependencies]\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Declare a set of files tasks to create the given directories on demand. Example: directory "testdata/doc" | def directory(dir)
Rake.each_dir_parent(dir) do |d|
file_create d do |t|
mkdir_p t.name if ! File.exist?(t.name)
end
end
end | [
"def create_rake_files(base_dir)\n\n one_task_fn = File.join(base_dir, 'one_task.rake')\n make_tasks_in_file(['one_task'], one_task_fn) if ok_to_create?(one_task_fn)\n\n another_task_fn = File.join(base_dir, 'another_task.rake')\n make_tasks_in_file(['another_task'], another_task_fn) if ok_to_create?(an... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Faster implementation of count. Instead of parsing the whole file with Ruby, shell out to `wc l` to get the line count less the header row. | def count
`wc -l < #{filepath}`.to_i - 1
end | [
"def line_count(file_list)\n file_list.empty? ?\n nil :\n %x{wc -l #{file_list.join(' ')} | awk 'END {print $1}'}.to_i\n end",
"def count_number_of_lines(file_path)\n File.foreach(file_path).inject(0) { |count, line| count + 1 }\n end",
"def count_lines\n @file.size\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
appends a new node of data: value | def append(value)
new_node = Node.new(value)
node = @node
while node.next
node = node.next
end
node.next = new_node
end | [
"def append_node(doc, hash_value)\n hash_value.to_xml(doc)\n end",
"def add_data_xml(value)\n @children['data-xml'][:value] << value\n end",
"def push(data_value)\r\n @head_value = LinkedListNode.new(data_value, @head_value)\r\n end",
"def append_data(data); end",
"def add(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Render 401 page and stop the work | def access_denied!
render partial: 'errors/401', status: 401 && return
end | [
"def halt_unauthorized(errors, render_options = {})\n halt_error(401, errors, render_options)\n end",
"def authorize_fail\n if request.format == :json\n render :text => \"Unauthorized action.\"\n else\n render :file => \"static/401\", :formats => [:html], :status => :unauthorized\n end\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Localize a fieldName if obj is present | def t_field(field_label = nil, obj = '')
return '' if field_label.blank?
case obj
when Class
I18n.t(field_label, scope: "activerecord.attributes.#{obj.class}", default: field_label).try(:capitalize)
when String
I18n.t(field_label, scope: "activerecord.attributes.#{obj}", default: field_labe... | [
"def localize(field)\n if klass.fields[field.to_s].try(:localized?)\n field = \"#{field}.#{::I18n.locale}\".to_sym\n end\n field\n end",
"def t_field(field_label = nil, obj = '')\n return '' if field_label.blank?\n\n case obj\n when Class\n t(field_label, scope: \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /staff_workers POST /staff_workers.json | def create
@staff_worker = StaffWorker.new(staff_worker_params)
respond_to do |format|
if @staff_worker.save
format.html { redirect_to @staff_worker, notice: 'Данные сохранены' }
format.json { render :show, status: :created, location: @staff_worker }
else
format.html { rende... | [
"def create\n @worker = @user.workers.create(worker_params)\n\n respond_to do |format|\n if @worker.save\n format.html { redirect_to @worker, notice: 'Worker was successfully created.' }\n format.json { render action: 'show', status: :created, location: @worker }\n else\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /staff_workers/1 PATCH/PUT /staff_workers/1.json | def update
respond_to do |format|
if @staff_worker.update(staff_worker_params)
format.html { redirect_to @staff_worker, notice: 'Данные сохранены' }
format.json { render :show, status: :ok, location: @staff_worker }
else
format.html { render :edit }
format.json { render j... | [
"def update\n @worker = Worker.find(params[:id])\n\n respond_to do |format|\n if @worker.update_attributes(params[:worker])\n format.html { redirect_to @worker, :notice => 'Worker was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /staff_workers/1 DELETE /staff_workers/1.json | def destroy
@staff_worker.destroy
respond_to do |format|
format.html { redirect_to staff_workers_url, notice: 'Staff worker was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @worker.destroy\n respond_to do |format|\n format.html { redirect_to workers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @worker = Worker.find(params[:id])\n @worker.destroy\n\n respond_to do |format|\n format.html { redirect_to workers_ur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /positives POST /positives.json | def create
@positive = Positive.new(positive_params)
respond_to do |format|
if @positive.save
format.html { redirect_to @positive, notice: 'Positive was successfully created.' }
format.json { render :show, status: :created, location: @positive }
else
format.html { render :ne... | [
"def create\n @positon = Positon.new(positon_params)\n\n respond_to do |format|\n if @positon.save\n format.html { redirect_to @positon, notice: 'Positon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @positon }\n else\n format.ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /positives/1 DELETE /positives/1.json | def destroy
@positive.destroy
respond_to do |format|
format.html { redirect_to positives_url, notice: 'Positive was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @positive = Positive.find(params[:id])\n @positive.destroy\n\n respond_to do |format|\n format.html { redirect_to positives_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @positon.destroy\n respond_to do |format|\n format.html { redirect_to p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a number, find the level that includes it Ex: Number 7 returns level 1 Level 1: Min Value: 2 Max Value: 9 | def find_level
level = 0
max_value = max_number_of_a_level(level)
while max_value < input
level += 1
max_value = max_number_of_a_level(level)
end
level
end | [
"def by_level(range, max_at:)\n level >= max_at ? range.last :\n range.first + (((range.size - 1)/max_at.to_f)*level).to_i\n end",
"def level(value)\n current_node = @root\n tracker = 1\n\n until current_node.nil? || current_node.value == value\n tracker += 1\n current_node = c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update product cache stock | def update_product_cache_stock
self.product.update_cache_stock if self.product.present?
end | [
"def update_product_cache_stock\n\t\t\tself.state_check_details.each do |scd|\n scd.update_product_cache_stock\n end\n\t\tend",
"def maintain_stock(order)\n product = Product.find(order.product_id)\n product.update_attributes(:stock => (product.stock - order.quantity))\n end",
"def perform\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def remove_all_children self.to_be_removed = true self.save self.tags.each do |i| i.to_be_removed = true i.save end end | def retrieve_all_children
self.to_be_removed = false
self.save
self.tags.each do |i|
i.to_be_removed = false
i.save
end
end | [
"def remove_children\n @children.clear\n end",
"def destroy_children!\n self.children.each do |child|\n child.destroy\n end\n end",
"def destroy_children\n children.destroy_all\n end",
"def clean_up_tags\n self.tags.each do |tag|\n if tag.todos.count == 1\n t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /moresmalltrials/1 GET /moresmalltrials/1.json | def show
@moresmalltrial = Moresmalltrial.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @moresmalltrial }
end
end | [
"def show\n @moresmalltrialstatus = Moresmalltrialstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmalltrialstatus }\n end\n end",
"def new\n @moresmalltrialstatus = Moresmalltrialstatus.new\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /moresmalltrials POST /moresmalltrials.json | def create
@moresmalltrial = Moresmalltrial.new(params[:moresmalltrial])
respond_to do |format|
if @moresmalltrial.save
format.html { redirect_to @moresmalltrial, notice: 'Moresmalltrial was successfully created.' }
format.json { render json: @moresmalltrial, status: :created, location: @... | [
"def create\n @moresmalltrialstatus = Moresmalltrialstatus.new(params[:moresmalltrialstatus])\n\n respond_to do |format|\n if @moresmalltrialstatus.save\n format.html { redirect_to @moresmalltrialstatus, notice: 'Moresmalltrialstatus was successfully created.' }\n format.json { render json:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /moresmalltrials/1 PUT /moresmalltrials/1.json | def update
@moresmalltrial = Moresmalltrial.find(params[:id])
respond_to do |format|
if @moresmalltrial.update_attributes(params[:moresmalltrial])
format.html { redirect_to @moresmalltrial, notice: 'Moresmalltrial was successfully updated.' }
format.json { head :no_content }
else
... | [
"def update\n @moresmalltrialstatus = Moresmalltrialstatus.find(params[:id])\n\n respond_to do |format|\n if @moresmalltrialstatus.update_attributes(params[:moresmalltrialstatus])\n format.html { redirect_to @moresmalltrialstatus, notice: 'Moresmalltrialstatus was successfully updated.' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /moresmalltrials/1 DELETE /moresmalltrials/1.json | def destroy
@moresmalltrial = Moresmalltrial.find(params[:id])
@moresmalltrial.destroy
respond_to do |format|
format.html { redirect_to moresmalltrials_url }
format.json { head :no_content }
end
end | [
"def destroy\n @moresmalltrialstatus = Moresmalltrialstatus.find(params[:id])\n @moresmalltrialstatus.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmalltrialstatuses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @smalltrial = Smalltrial.find(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /moresmalltrials/select_mobunits GET /moresmalltrials/1/select_mobunits | def select_mobunits
@def_unit_data = Moresmallmobunit.where('cur_map_id = ?', params[:map_id]).where('tgt_map_id = ?', params[:map_id]).where('is_prepared = "t"').collect{|m| [m.name, m.id]}
@atk_unit_data = Moresmallmobunit.where('cur_map_id != ?', params[:map_id]).where('tgt_map_id = ?', params[:map_id]).wher... | [
"def select_mob_and_unit\n @mobs = Moresmallmob.find_all_by_moresmalluser_id(params[:user_id]).collect{|m| [m.name, m.id]}\n @selected_mob = Moresmallmobsquad.find(params[:id]).mob_ids unless Moresmallmobsquad.find_by_moresmalluser_id(params[:user_id]).nil?\n @units = Moresmallmobunit.find_all_by_moresmall... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This scripts checks the group membership of each user on the machine to to see if they are in the local admin group | def local_admins
list_of_users_tocheck = []
for x in Dir.entries("/Users")
if !x.start_with?(".")
list_of_users_tocheck.push(x)
end
end
localadmins = []
for x in list_of_users_tocheck
if `dsmemberutil checkmembership -U #{x} -G admin 2>/dev/null`.chomp == "user is a member of the group"
localadmins.pus... | [
"def user_in_admin_group?\r\n cmd_exec(\"groups `whoami`\").split(/\\s+/).include?(SUDOER_GROUP)\r\n end",
"def user_is_admin?\n\t`groups`.split.include? \"admin\"\n end",
"def user_has_admin_from_group?(client, user, admin_access)\r\n resp = client.list_groups_for_user(\r\n user_name: user.user_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the list of available page layouts | def list_page_layouts(layouts=[])
if layouts.empty?
layouts_path = Rails.root + "app/views/layouts"
if Dir.exists? layouts_path
Dir.foreach(layouts_path) do |file_name|
if file_name.include? '.html.haml'
layouts << File.basename(file_name,'.html.haml')
... | [
"def get_available_layouts\n if xml_has_layouts\n xml[\"layouts\"][\"layout\"].map{ |l| l[\"name\"] }.uniq\n else\n nil\n end\n end",
"def available_layouts\n\t\treturn (@configuration['sa_layouts'].nil? || @configuration['sa_layouts'].empty?) ? [] : @configuration['sa_layouts']\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compares two die values from AllowedDice, useable for +sort+ _if_ you use it with a block. i.e.: [:d6, :d10, :d8].sort do |d1, d2| compare_dice(d1, d2) end => [:d6, :d8, :d10] | def compare_dice(die1, die2)
idx1 = AllowedDiceOrder.index(die1)
idx2 = AllowedDiceOrder.index(die2)
# This handles values -not- in AllowedDice
idx1 = -1 if idx1.nil?
idx2 = -1 if idx2.nil?
return idx1 <=> idx2
end | [
"def sort_dice(dice=[])\n return [] if not dice.is_a?(Array)\n return dice.sort {|d1, d2| compare_dice(d1, d2) }\n end",
"def challenge(args) #args = dice: x, value: y\n dice_challenged = []\n\n @dice_on_table.each do |die|\n dice_challenged << die if die == args[:value]\n end\n\n @players... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Used to sort an array of dice. NOTE: Values not in AllowedDice end up at the front of the array. | def sort_dice(dice=[])
return [] if not dice.is_a?(Array)
return dice.sort {|d1, d2| compare_dice(d1, d2) }
end | [
"def compare_dice(die1, die2)\n idx1 = AllowedDiceOrder.index(die1)\n idx2 = AllowedDiceOrder.index(die2)\n\n # This handles values -not- in AllowedDice\n idx1 = -1 if idx1.nil?\n idx2 = -1 if idx2.nil?\n\n return idx1 <=> idx2\n end",
"def sort_possible_attacks\n attack_priority = { king: 1... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /authors/1 GET /authors/1.xml | def show
@author = Author.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @author }
end
end | [
"def get_authors\n return @client.raw(\"get\", \"/content/authors\")\n end",
"def show\n @name_author = NameAuthor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @name_author }\n end\n end",
"def show\n @author_repositor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a scope for this object by its identifier | def get_scope_by_id(id)
id = id.to_s
scopes.find{|s| s.id == id }
end | [
"def get_scope_by_id(id)\n id = id.to_s\n scopes.find { |s| s.id == id }\n end",
"def scope\n return @scope\n end",
"def scope\n return @scope\n end",
"def scope_id\n return @scope_id\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Procedure to reduce the life of the player | def lose_life()
@life -= 1
end | [
"def reduce_life\n if @lives > 0\n @lives -= 1\n end\n end",
"def take_life\n @lives -= 1\n end",
"def remove_life\r\n @lives -= 1\r\n end",
"def reset_lives\n @player_1.life = 3\n @player_2.life = 3\n end",
"def subtract_player_life\n @player.lose_life\n end",
"def lives_de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Move the Space Ship to the right | def move_right
if @x + @vel_x < SCREEN_WIDTH - GAME_PRESET["player_move_right"]
@x += @vel_x
end
end | [
"def move_right\n puts_if_debug_mode \"move right\"\n self.current_cell += 1\n self.remaining_moves -= 1\n end",
"def move_right\n if xn + 1 > Vedeu.width\n dx = x\n dxn = xn\n else\n dx = x + 1\n dxn = xn + 1\n end\n\n @attributes = attr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the score of the Game | def get_score()
return @player.score()
end | [
"def score(game)\n count\n 0\n end",
"def winning_score\n return 0 unless winning_team_game\n winning_team_game.total_score\n end",
"def score\n\t\tif @game.winner == @player\n\t\t 10 \n\t\telsif @game.winner == @opponent\n\t\t -10\n\t\telse\n\t\t 0\n\t\tend \t\n\t end",
"def score\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the time of the Gameplay | def get_game_play_time()
return @game_play_time
end | [
"def play_time\n @data.trainer.play_time_text\n end",
"def play_time\n sum = 0\n @tracks.each {|n| sum += n.total_time}\n return Time.at(sum/1000.0).strftime('%R:%S')\n end",
"def time\n [self.game_begins, [self.game_ends, Time.now].min].max\n end",
"def play_time_text\n time = @pla... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removing the bullets which have moved pass the screen | def remove_unused_bullets()
# All the bullet objects are looped through
@bullets.dup.each { |bullet|
# Determines if a bullet is outside the screen
bullet.x > SCREEN_HEIGHT || bullet.x < 0
}
end | [
"def remove_bullets_of_screen args\n args.state.bullets = args.state.bullets.reject { |bullet| bullet.x > 1280 } # screen width is 1280\nend",
"def clear_bullets\n @bullets.reject! do |bullet|\n if bullet.x < -64 || bullet.x > SCREEN_WIDTH + bullet.radius\n true\n else... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Procedure for the aliens to fire bullets | def alien_fire_bullet()
# The aliens will fire bullets at random,
# The randomness is controlled by @alien_fire_rand
@aliens.each { |alien|
if rand(@alien_fire_rand) == 0
@bullets.push Bullet.new(alien.x, alien.y+ 40, 'evil')
end
}
end | [
"def fire \n\n # Could end up spawning a number of bullets, depending on the weapon\n bullets = []\n\n # For now, we'll just spawn a small green laser bolt!\n bullets << Laser.new( :laser_small_red, @x + 105, @y + 46, true )\n\n\n # And just hand back that collection of bullets\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Procedure allows the player to fire bullets | def player_fire_bullet()
# This makes sure that bullets are fired after certain intervals
if Gosu.milliseconds > (@seconds_elapsed * COUNTER)
@seconds_elapsed = Gosu.milliseconds
@bullet_sound.bmp.play()
# Generating a bullet object
@bullets.push Bullet.new((@player.x+ 33), @player... | [
"def fire \n\n # Could end up spawning a number of bullets, depending on the weapon\n bullets = []\n\n # For now, we'll just spawn a small green laser bolt!\n bullets << Laser.new( :laser_small_red, @x + 105, @y + 46, true )\n\n\n # And just hand back that collection of bullets\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Introcusing a new fleet of aliens in the game | def add_alien_fleet()
# Only generate new fleet of aliens if the current count of fleets is less than @fleet_limit
if rand(@random) == 0 and @fleet < @fleet_limit
@fleet +=1
position = rand(SCREEN_WIDTH/2)
@height -= GAME_PRESET["space_fleet"]
# Calling the procedure to generate al... | [
"def generate_aliens(position, height)\r\n # Looping until the number of Aliens in a fleet is reached\r\n for i in 0...@alien_count\r\n @aliens.push(Alien.new(i, position, height))\r\n @alien_sound.bmp.play\r\n end\r\n end",
"def add_soldier bee\n @soldiers << bee\n end",
"def new_player... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Procedure to generate aliens | def generate_aliens(position, height)
# Looping until the number of Aliens in a fleet is reached
for i in 0...@alien_count
@aliens.push(Alien.new(i, position, height))
@alien_sound.bmp.play
end
end | [
"def create_aliens \n @aliens.each do |alien|\n alien.each do |element|\n element.draw\n end\n end\n end",
"def aliens\n self.populations.map do |pop|\n pop.alien\n end\n end",
"def synthesize(protein)\n adn = ''\n for a in (0..protein.length-1)\n aminoacido =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Procedure to add the visuals of explosion | def explode()
# drawing explosion scene
@explosion.bmp.draw(@explode_x, @explode_y, ZOrder::TOP)
# Playing the sound of an explosion
@explosion_sound.bmp.play
@count += 1
# Showing the visual for 20 update() counts
if @count == 20
@explode = false
@count = 0
e... | [
"def explosion; end",
"def create_explosion\n explosion = ParticleFactory.buildParticles(\"big\", 80).set! :emission_direction => Vector3f.new(0, 1, 0),\n :maximum_angle => FastMath::PI, :speed => 1, :minimum_life_time => 600, \n :start_size => 3, :end_size => 7, \n :start_color => ColorRGBA.new... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Procedure to place button on the screen | def place_button(x, y, message)
Gosu.draw_rect(x, y, 70, 45, Gosu::Color::GREEN, ZOrder::MIDDLE, mode=:default)
@button_font.draw_text(message, x+5, y+10, ZOrder::TOP, 1.0, 1.0, Gosu::Color::BLACK)
end | [
"def add_the_button\n @theButton = UIButton.buttonWithType(UIButtonTypeRoundedRect)\n @theButton.setTitle('Refresh Weather!', forState:UIControlStateNormal)\n # @theButton.setTitleColor(BW.rgb_color(255, 255, 255), forState:UIControlStateNormal)\n @theButton.backgroundColor = BW.rgb_color(255, 255, 255)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When a user hovers over a button draw a border | def draw_border(x1, y)
if @function_UI.mouse_over_button(mouse_x, mouse_y)
draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
draw_line(x1, y,G... | [
"def draw_border(x1, y, mouse_x, mouse_y)\r\n if @function_UI.mouse_over_button(mouse_x, mouse_y)\r\n draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When a user hovers over a button draw a border | def draw_border(x1, y, mouse_x, mouse_y)
if @function_UI.mouse_over_button(mouse_x, mouse_y)
draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)
draw_line... | [
"def draw_border(x1, y)\r\n if @function_UI.mouse_over_button(mouse_x, mouse_y)\r\n draw_line(x1, y, Gosu::Color::BLUE, x1+60, y, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw_line(x1, y+35, Gosu::Color::BLUE, x1+60, y+35, Gosu::Color::BLUE, ZOrder::TOP, mode=:default)\r\n draw... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /principal_establecs/1 GET /principal_establecs/1.json | def show
@principal_establec = PrincipalEstablec.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @principal_establec }
end
end | [
"def show\n @principal = Principal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @principal }\n end\n end",
"def new\n @principal_establec = PrincipalEstablec.new\n\n respond_to do |format|\n format.html # new.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /principal_establecs/new GET /principal_establecs/new.json | def new
@principal_establec = PrincipalEstablec.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @principal_establec }
end
end | [
"def new\n authorize! :index, @user, :message => 'Not authorized.'\n @principal = Principal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @principal }\n end\n end",
"def create\n @principal_establec = PrincipalEstablec.new(params[:principal_esta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /principal_establecs POST /principal_establecs.json | def create
@principal_establec = PrincipalEstablec.new(params[:principal_establec])
respond_to do |format|
if @principal_establec.save
format.html { redirect_to @principal_establec, notice: 'Registro creado satisfactoriamente.' }
format.json { render json: @principal_establec, status: :cr... | [
"def new\n @principal_establec = PrincipalEstablec.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @principal_establec }\n end\n end",
"def create\n authorize! :index, @user, :message => 'Not authorized.'\n @principal = Principal.new(params[:princ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /principal_establecs/1 PUT /principal_establecs/1.json | def update
@principal_establec = PrincipalEstablec.find(params[:id])
respond_to do |format|
if @principal_establec.update_attributes(params[:principal_establec])
format.html { redirect_to @principal_establec, notice: 'Registro editado satisfactoriamente.' }
format.json { head :no_content ... | [
"def update\n authorize! :index, @user, :message => 'Not authorized.'\n @principal = Principal.find(params[:id])\n\n respond_to do |format|\n if @principal.update_attributes(params[:principal])\n format.html { redirect_to @principal, notice: 'Principal was successfully updated.' }\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /principal_establecs/1 DELETE /principal_establecs/1.json | def destroy
@principal_establec = PrincipalEstablec.find(params[:id])
@principal_establec.destroy
respond_to do |format|
format.html { redirect_to principal_establecs_url, notice: 'Registro eliminado satisfactoriamente.' }
format.json { head :no_content }
end
end | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n authorize! :index, @user, :message => 'Not authorized.'\n @principal = Principal.find(params[:id])\n @principal.destroy\n\n respond_to do |format|\n format.html { redirect_to pri... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns an array of userIds of the opponents of a bet | def get_bet_opponents(bet_id)
opps = []
Bet.find(bet_id).invites.each do |i|
opps.push i.invitee if i.status == "accepted"
end
return opps
end | [
"def get_opponent_ids\n losing_opponents = []\n winning_opponents = []\n # all matchups involving competitor\n faceoff_wins = Matchup.where({\"winner_competitor_id\" => self.id})\n faceoff_losses = Matchup.where({\"loser_competitor_id\" => self.id})\n \n # all opponents\n faceoff_wins.each... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /clubs/1 DELETE /clubs/1.json | def destroy
@club = Club.find(params[:id])
@club.destroy
respond_to do |format|
format.html { redirect_to root_url }
format.json { head :no_content }
end
end | [
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { redirect_to clubs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @club = Club.find(params[:id])\n @club.destroy\n\n respond_to do |format|\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Array of all builds for the given project that have the status `pending` | def pending_builds(project: nil)
not_implemented(__method__)
end | [
"def pending_build_shas_needing_rebuilds(project:)\n all_builds = list_builds(project: project)\n\n all_completed_builds_shas = all_builds\n .reject { |build| build.status == \"pending\" }\n .map(&:sha)\n .u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add or update a build | def add_build!(project: nil, build: nil)
not_implemented(__method__)
end | [
"def bumpBuild()\n\t\t\t\t@build += 1\n\t\t\tend",
"def add_build(params)\n raise \"Must specify a Build NVR to add to this advisory\" if params[:nvr].blank?\n raise \"Must specify a product_version for the NVR to add to this advisory\" if params[:product_version].blank?\n manage_build(\"#{post_suf... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns how many courts of the sport passed as parameter the club has if no parameter is sent it passes all quantities | def court_quantity sport=nil
if @sports.blank?
@sports = self.courts.includes(:sport).map {|c| c.sport.name }
end
qty_hash = Hash.new 0
@sports.each do |sp|
qty_hash[sp.downcase] += 1
end
return qty_hash[sport.downcase] unless sport.blank?
qty_hash
end | [
"def total_number_of_parcels\n end",
"def goals(season = Season.current_date)\n count = 0\n self.details.goals.each do |detail|\n if detail.season == season\n count += 1\n end\n end\n\n return count\n end",
"def goals_against(club)\n if finished?\n if club == local\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates or destroy courts to match the quantity indicated by the user Can be refactored | def create_courts
futbol = Sport.where(:name => 'futbol').first
tenis = Sport.where(:name => 'tenis').first
paddle = Sport.where(:name => 'paddle').first
# court_quantity '*' indicates how many courts already has
# @*_quantity indicates how many tha user wants
### Futbol Courts
... | [
"def create\n params.permit!\n @course = Course.new(params[:course])\n if @course.save\n if TaughtBy.new(professor_id: Professor.find_by(account_id: current_account.id).id,\n course_id: Course.order('created_at').last.id).save\n redirect_to courses_path\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the value of the property If status is not supplied, the status will default to 200 for nonnull properties, and 404 for null properties. | def set(property_name, value, status = nil)
status = value.nil? ? 404 : 200 if status.nil?
result[property_name] = [status, value]
end | [
"def set(property_name, value, status = nil)\n status = value.nil? ? 404 : 200 if status.nil?\n\n # If this is an ALLPROPS request and the property is\n # unknown, add it to the result; else ignore it:\n unless @result.key?(property_name)\n @result[property_name] = [status, valu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the current status code for a property name. If the property does not appear in the list of requested properties, null will be returned. | def status(property_name)
result.key?(property_name) ? result[property_name][0] : 404
end | [
"def status(property_name)\n @result.key?(property_name) ? @result[property_name][0] : nil\n end",
"def get_property( propname )\n resp = conn.get('/users/'+name+'/props/'+propname+'/')\n \n case resp.code.to_i\n when 200\n return JSON.parse( resp.body )\n when 404\n case resp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all propertynames that have a 404 status, and thus don't have a value yet. | def get404_properties
result = []
self.result.each do |property_name, stuff|
result << property_name if stuff[0] == 404
end
# If there's nothing in this list, we're adding one fictional item.
result << '{http://sabredav.org/ns}idk' if result.empty?
... | [
"def load_404_properties\n return [] if @items_left == 0\n result = []\n @result.each do |property_name, stuff|\n result << property_name if stuff[0] == 404\n end\n result\n end",
"def status(property_name)\n result.key?(property_name) ? result[property_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /c_videos/1 GET /c_videos/1.json | def show
@c_video = CVideo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @c_video }
end
end | [
"def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end",
"def show\n @api_v1_video = Api::V1::Video.find(params[:id])\n\n render json: @api_v1_video\n end",
"def list\n @videos = Video.all\n\n respond_to do |format|\n format.html # list.html.erb\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /c_videos/1 DELETE /c_videos/1.json | def destroy
@c_video = CVideo.find(params[:id])
@c_video.destroy
respond_to do |format|
format.html { redirect_to c_videos_url }
format.json { head :no_content }
end
end | [
"def destroy\n @api_v1_video = Api::V1::Video.find(params[:id])\n @api_v1_video.destroy\n\n head :no_content\n end",
"def destroy\n @video.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @video = Video.find(params[:id])\n @video.des... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the file list content as JSON for rendering in the list container The actual metadata returned varies based on the view_type requested, in order to speed up large directories | def content
setup_download_list
except_list = case view_type
when 'icons'
%i[file_metadata last_process_name_run updated_at created_at user_id file_hash
content_type nfs_store_stored_file_id]
else
%... | [
"def redactor_list\n type, owner_type, owner_id = request[:type], prepare_owner_type(request[:owner_type]), request[:owner_id]\n\n type ||= 'file'\n\n begin\n file_class = \"Neofiles::#{type.classify}\".constantize\n rescue\n raise ArgumentError.new I18n.t('neofiles.unknown_file_type', type: t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Setup the list of download file items, handling item flags if needed. | def setup_download_list
return unless @container.readable?
# Check if we should show flags for classifications on each of the types of container file
@allow_show_flags = {}
%i[stored_file archived_file].each do |rt|
full_name = "nfs_store__manage__#{rt}"
show_flag = !!Classifica... | [
"def setup_items(selected_items, for_action)\n # Retrieve each file's details. The container_id will be passed if this is a\n # multi container download, otherwise it will be ignored\n selected_items.each do |s|\n container = self.container || Browse.open_container(id: s[:container_id], user: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /spents GET /spents.json | def index
@spents = Spent.all
end | [
"def index\n @points_spents = PointsSpent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @points_spents }\n end\n end",
"def index\n @spots = Spot.all\n render json: @spots\n end",
"def spots\n @spots = Spot.find_all_by_discipline_id(para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /spents POST /spents.json | def create
@spent = Spent.new(spent_params)
respond_to do |format|
if @spent.save
format.html { redirect_to @spent, notice: 'Spent was successfully created.' }
format.json { render :show, status: :created, location: @spent }
else
format.html { render :new }
format.js... | [
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, ur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=== Description Your application should override this method. Implement the main entry point. === Parameters argv:: (Array) of positional arguments Basically left over after processing command line options starting with dash(s) as defined in get_options. === Returns (Integer) exit code | def main(argv)
# override this; no default action in main
end | [
"def run\n code = 0\n opt = OptionParser.new\n define_options(opt)\n default_options(opt)\n define_exit_codes(opt)\n argv = opt.parse!\n\n if @help\n puts_msg(opt.help)\n\n else\n begin\n main(argv)\n rescue Exception => e\n arr = @@exit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=== Description Parse options, and run the main method === Returns (Integer) exit code | def run
code = 0
opt = OptionParser.new
define_options(opt)
default_options(opt)
define_exit_codes(opt)
argv = opt.parse!
if @help
puts_msg(opt.help)
else
begin
main(argv)
rescue Exception => e
arr = @@exit_code_map[e.class]
... | [
"def go!\n setup_defaults\n opts.post_setup\n opts.parse!\n opts.check_args!\n result = call_main\n if result.kind_of? Integer\n exit result\n else\n exit 0\n end\n rescue OptionParser::ParseError => ex\n logger.error ex.message\n puts\n puts o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=== Description Print out msg to STDERR in red color | def puts_err(msg)
STDERR.puts(msg.to_s.red)
end | [
"def print_red_alert(msg)\n $stderr.print \"#{red}#{msg}#{reset}\\n\"\n #print_error \"#{red}#{msg}#{reset}\\n\"\n #puts_error \"#{red}#{msg}#{reset}\"\n end",
"def error(message)\n message = message.red unless message.color?\n puts(stderr, message)\n end",
"def colour(msg)\n puts ms... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates all stations from BOM website. | def update_stations
State.all.each do |s|
fetch_stations(s)
end
end | [
"def update_station_list\n log('This script overwrites your local copy of config/stations.yml with the latest data from nationalrail.co.uk and '\\\n 'railwaycodes.org.uk')\n log('Press [ENTER] to continue or [Ctrl+c] to quit')\n gets\n # Fetch data from the web\n stations = fetch_stations\n locations = fe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves a list of the URLS for each weather station given a State. Each url is then passed to the extract_station method. | def fetch_stations(state)
scraper_logger.info("Fetching stations for #{state.name}")
doc = Nokogiri::HTML(open(state.url))
doc.css('a').each do |s|
Global::OBSERVATION_PRODUCT_CODE.each do |c|
if s.attr('href').include?(c) and s.attr('href').include?(state.product_group)
extract_s... | [
"def extract_station(url, state)\n\n id, json_url = nil\n\n doc = Nokogiri::HTML(open(\"#{Global::BOM_BASE_URL}#{url}\"))\n doc.css('a').each do |l|\n\n if l.attr('href').include?('json')\n json_url = l.attr('href')\n id = l.attr('href').split('.')\n id = id[1]\n end\n\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new, or updates an existing, Station given it's URL and the State to which it belongs. | def extract_station(url, state)
id, json_url = nil
doc = Nokogiri::HTML(open("#{Global::BOM_BASE_URL}#{url}"))
doc.css('a').each do |l|
if l.attr('href').include?('json')
json_url = l.attr('href')
id = l.attr('href').split('.')
id = id[1]
end
end
begin
... | [
"def station\n if Station.exists?(code: params[:STATION_CODE])\n @station ||= Station.find_by(code: params[:STATION_CODE])\n else\n @station ||= Station.create!(station_attrs)\n end\n end",
"def create\n @station = Station.new(station_params)\n\n if @station.save\n render json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Will retrieve all new observations given a Station. | def fetch_observations(station)
scraper_logger.info("Fetching latest weather observations for #{station.id} - #{station.name}")
new = 0
json = extract_observations(station.json_url)
json['observations']['data'].each do |o|
Time.zone = 'UTC'
recording_time = Time.zone.parse("#{o['aifstime... | [
"def get_all_stations(subway_dataset) \n all_station = [] \n for x in 0..472\n new_station = Subway_station.new(subway_dataset[\"data\"][x][10], subway_dataset[\"data\"][x][13])\n all_station.push(new_station) \n end\n return all_station\nend",
"def index\n @station_data = StationDat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a JSON feed containing a group of BOM observations, along with an Observation, this method will create all necessary Reading records based on ReadingType records. | def parse_readings(json, observation)
ReadingType.all.each do |r|
reading = Reading.new
reading.observation = observation
reading.reading_type = r
unless json[r.bom_field_name].nil?
if r.numeric
reading.numeric_value = json[r.bom_field_name].to_d unless json[r.bom_field_... | [
"def create\n device = Device.find_by(uid: params[:uid])\n reading = device.readings.build(reading_params)\n reading.data = JSON.parse(reading_params[:data])\n reading.timestamp = Time.at(reading_params[:timestamp])\n if reading.save\n render json: reading, status: :created\n else\n rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Welcome_email is a eMail sent to the Channel Admin, after setting up the channel and contains the Sec_Hash | def welcome_email(channel)
@channel = channel
@url = 'http://example.com/login'
mail(to: @channel.email, subject: 'Welcome to your Constructeev Channel')
end | [
"def email_welcome\n MailerHelper::send_mail_to_user(self, \"Your Expertiza password has been created\", \"user_welcome\", clear_password)\n end",
"def email_welcome\n # this will send an account creation notification to user via email.\n MailerHelper.send_mail_to_user(self, 'Your Expertiza account and ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /forum_cat_l1s/1 GET /forum_cat_l1s/1.xml | def show
@forum_cat_l1 = ForumCatL1.find(params[:id])
@forum_cat_l2s = ForumCatL2.find(:all, :conditions => ["forum_cat_l1_id = ?", params[:id]])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @forum_cat_l1 }
end
end | [
"def index \n @forum_cat_l2s = ForumCatL2.find(:all, :include => [:forum_posts => :forum_replies])\n @categories = ForumCatL1.find(:all)\n @page_description = t(:forums_descriptions)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @forum_cat_l2s ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /forum_cat_l1s/new GET /forum_cat_l1s/new.xml | def new
@forum_cat_l1 = ForumCatL1.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @forum_cat_l1 }
end
end | [
"def new\n @forum_cat_l2 = ForumCatL2.new\n @forum_cat_l1s = ForumCatL1.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_cat_l2 }\n end\n end",
"def create\n @forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1])\n\n respond_to do... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /forum_cat_l1s POST /forum_cat_l1s.xml | def create
@forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1])
respond_to do |format|
if @forum_cat_l1.save
flash[:notice] = t(:category1_created)
format.html { redirect_to(@forum_cat_l1) }
format.xml { render :xml => @forum_cat_l1, :status => :created, :location => @forum_cat_... | [
"def create\n @forum_cat_l2 = ForumCatL2.new(params[:forum_cat_l2])\n\n respond_to do |format|\n if @forum_cat_l2.save\n flash[:notice] = t(:category2_created)\n format.html { redirect_to(@forum_cat_l2) }\n format.xml { render :xml => @forum_cat_l2, :status => :created, :location =>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /forum_cat_l1s/1 PUT /forum_cat_l1s/1.xml | def update
@forum_cat_l1 = ForumCatL1.find(params[:id])
respond_to do |format|
if @forum_cat_l1.update_attributes(params[:forum_cat_l1])
flash[:notice] = t(:category_updated)
format.html { redirect_to(@forum_cat_l1) }
format.xml { head :ok }
else
format.html { rende... | [
"def update\n @forum_cat_l2 = ForumCatL2.find(params[:id])\n\n respond_to do |format|\n if @forum_cat_l2.update_attributes(params[:forum_cat_l2])\n flash[:notice] = t(:category_updated)\n format.html { redirect_to(@forum_cat_l2) }\n format.xml { head :ok }\n else\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /forum_cat_l1s/1 DELETE /forum_cat_l1s/1.xml | def destroy
@forum_cat_l1 = ForumCatL1.find(params[:id])
@forum_cat_l1.destroy
respond_to do |format|
format.html { redirect_to(forum_cat_l1s_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @forum_cat_l2 = ForumCatL2.find(params[:id])\n @forum_cat_l2.destroy\n\n respond_to do |format|\n format.html { redirect_to(forum_cat_l2s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @forum_category = ForumCategory.find(params[:id])\n @forum_category.d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /portal/learners GET /portal/learners.xml | def index
@portal_learners = Portal::Learner.search(params[:search], params[:page], nil)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @portal_learners }
end
end | [
"def show\n @learner = Portal::Learner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @learner }\n end\n end",
"def index\n @learners = Learner.all\n end",
"def new\n @learner = Portal::Learner.new\n\n respond_to do |format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /portal/learners/1/open_response_report GET /portal/learners/1/open_response_report.xml | def open_response_report
@portal_learner = Portal::Learner.find(params[:id])
respond_to do |format|
format.html # report.html.haml
end
end | [
"def open_response_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::L... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /portal/learners/1/multiple_choice_report GET /portal/learners/1/multiple_choice_report.xml | def multiple_choice_report
@portal_learner = Portal::Learner.find(params[:id])
respond_to do |format|
format.html # report.html.haml
end
end | [
"def multiple_choice_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /portal/learners/1/bundle_report GET /portal/learners/1/bundle_report.xml | def bundle_report
@portal_learner = Portal::Learner.find(params[:id])
respond_to do |format|
format.html # report.html.haml
end
end | [
"def bundle_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /portal/learners/new GET /portal/learners/new.xml | def new
@portal_learner = Portal::Learner.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @portal_learner }
end
end | [
"def new\n @learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @learner }\n end\n end",
"def create\n @learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @learner.save\n flash[:noti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /portal/learners POST /portal/learners.xml | def create
@portal_learner = Portal::Learner.new(params[:learner])
respond_to do |format|
if @portal_learner.save
flash[:notice] = 'Portal::Learner was successfully created.'
format.html { redirect_to(@portal_learner) }
format.xml { render :xml => @portal_learner, :status => :cre... | [
"def create\n @learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@learner) }\n format.xml { render :xml => @learner, :status => :created, :location ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /portal/learners/1 PUT /portal/learners/1.xml | def update
@portal_learner = Portal::Learner.find(params[:id])
respond_to do |format|
if @portal_learner.update_attributes(params[:learner])
flash[:notice] = 'Portal::Learner was successfully updated.'
format.html { redirect_to(@portal_learner) }
format.xml { head :ok }
els... | [
"def update\n @learner = Portal::Learner.find(params[:id])\n\n respond_to do |format|\n if @learner.update_attributes(params[:learner])\n flash[:notice] = 'Portal::Learner was successfully updated.'\n format.html { redirect_to(@learner) }\n format.xml { head :ok }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /portal/learners/1 DELETE /portal/learners/1.xml | def destroy
@portal_learner = Portal::Learner.find(params[:id])
@portal_learner.destroy
respond_to do |format|
format.html { redirect_to(portal_learners_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @learner = Portal::Learner.find(params[:id])\n @learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find insta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adjusts the hash storage and redistributes the entries among the new bins. Any Iterator instance will be invalid after a call to redistribute. Does not recalculate the cached key_hash values. See +rehash+. | def redistribute(entries)
capacity = @capacity
# Rather than using __setup__, initialize the specific values we need to
# change so we don't eg overwrite @state.
if @size > @max_entries
@capacity = capacity * 2
@max_entries = @max_entries * 2
@min_entries = @min_entries * 2
els... | [
"def redistribute(rehash = true)\n if @count >= MAX_DENSITY * @records\n new_size = @records * 2\n elsif @count < MIN_DENSITY * @records and @records > MIN_SIZE\n new_size = @records / 2\n else\n return unless rehash\n new_size = @records\n end\n\n i = to_iter\n @records = new_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract any payment errors from pending offer orders | def payment_error_notifications
payment_logs = order_logs
.joins(:order => :offer_order)
.where("orders.status IN ('pending') AND lower(order_logs.action) IN ('bill', 'payment')")
.order('order_logs.created_at')
payment_logs.group_by(&:order_id).reduce([]) do |a, (order_id, logs)|
log... | [
"def return_shipment_errors\n [\"#{@shipment}.buy(no rates found for this shipment)\", @shipment, @shipment]\n end",
"def capture_pending_payments\n success = true\n order.payments.pending.each do |payment|\n unless payment.capture!\n copy_errors(payment)\n success =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute the actual value of a field for a given serializer instance. | def value(serializer)
if block
serializer.instance_eval(&block)
else
serializer.read_attribute_for_serialization(name)
end
end | [
"def field_value(resource, field, value)\n custom_field_values(resource, field)\n .reduce({}) { |result, (k,v)| result.tap { |result| result[k.to_s] = v } }\n .fetch(value.to_s, value)\n end",
"def instance_value(obj, field)\n case field[:type]\n when :string\n field[:valu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:callseq: add(MyReleaseClass) Add a Release implementation to the list of available Release classes. | def add(release)
@list ||= []
@list |= [release]
end | [
"def add_release(release)\n if @releases.key?(release.name)\n raise DeploymentDuplicateReleaseName,\n \"Duplicate release name '#{release.name}'\"\n end\n @releases[release.name] = release\n end",
"def define_on_distro_release(distro, release, name, version=nil)\n... | {
"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.