query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Returns a mapping representing whether the current user has permission to view the embed for the project. Determined in a batch | def user_access_by_embed
strong_memoize(:user_access_by_embed) do
unique_embeds.each_with_object({}) do |embed, access|
project = projects_by_path[embed.project_path]
access[embed] = Ability.allowed?(user, embed.permission, project)
end
end
end | [
"def visible_permissions(user = User.current)\n return @wiki_page_permissions if user.wiki_manager?(@project)\n dp = user.delegate_permission_for(@project)\n @wiki_page_permissions.select{|wpp| wpp if dp.principals_for_delegate.include?(wpp.principal)}\n end",
"def visible?(user=User.current)\n user.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a unique list of embeds | def unique_embeds
embeds_by_node.values.uniq
end | [
"def embed_ids\n pluck(:embed_id)\n end",
"def embedments\n @embedments ||= {}\n end",
"def get_all_embeds()\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/graph/embed\", nil, nil, false)\n end",
"def embedments\n model.embedments\n end",
"def embeddables... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Maps a project's full path to a Project object. Contains all of the Projects referenced in the metrics placeholder elements of the current document | def projects_by_path
strong_memoize(:projects_by_path) do
Project.eager_load(:route, namespace: [:route])
.where_full_path_in(unique_project_paths)
.index_by(&:full_path)
end
end | [
"def projects_hash\n @projects ||= Project.eager_load(:route, namespace: [:route])\n .where_full_path_in(projects)\n .index_by(&:full_path)\n .transform_keys(&:downcase)\n end",
"def build\n nodes.locate('Project'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of the full_paths of every project which has an embed in the doc | def unique_project_paths
embeds_by_node.values.map(&:project_path).uniq
end | [
"def relevant_directory_paths\n drafts.map { |doc| relative_draft_path(doc).split(\"/\")[0] }.uniq\n end",
"def resources\n repo.doc_resources self.path\n end",
"def projects\n refs = Set.new\n\n nodes.each do |node|\n node.to_html.scan(Project.markdown_reference_patte... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:nodoc: Creates a new Cartage instance. If provided a Cartage::Config object in +config+, sets the configuration and resolves it. If +config+ is not provided, the default configuration will be loaded. | def initialize(config = nil)
self.config = config || Cartage::Config.load(:default)
end | [
"def cartage(config = nil)\n if defined?(@cartage) && @cartage && config\n fail \"Cannot provide another configuration after initialization.\"\n end\n @cartage ||= Cartage.new(config)\n end",
"def set_config(config)\n\t\tend",
"def initialize(config)\n case config\n when Strin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:attr_accessor: compression The compression to be applied to any tarballs created (either the final tarball or the dependency cache tarball). | def compression
unless defined?(@compression)
@compression = :bzip2
reset_computed_values
end
@compression
end | [
"def compression\n configuration[:copy_compression] || :gzip\n end",
"def tar_compression_flag\n case compression\n when :bzip2, \"bzip2\", nil\n \"j\"\n when :gzip, \"gzip\"\n \"z\"\n when :none, \"none\"\n \"\"\n end\n end",
"def compress\n @env[:ui]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:attr_accessor: dependency_cache_path Reads or sets the vendored dependency cache path. This is where the tarball of vendored dependencies in the working path will reside. On a CI system, this should be written somewhere that the CI system uses for build caching. On Semaphore CI, this would be $SEMAPHORE_CACHE. | def dependency_cache_path
self.dependency_cache_path = tmp_path unless defined?(@dependency_cache_path)
@dependency_cache_path
end | [
"def cache_path\n File.join(Config.git_cache_dir, @install_dir)\n end",
"def cache_path\n @cache_path ||= ensure_dir(File.join(gem_home, 'cache'))\n end",
"def dependency_cache\n @dependency_cache ||= {}\n end",
"def cache_repository_path\n File.absolute_path(File.join(Rails... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The cartage configuration object, implemented as a recursive OpenStruct. This can return just the subset of configuration for a command or plugin by providing the +for_plugin+ or +for_command+ parameters. | def config(for_plugin: nil, for_command: nil)
if for_plugin && for_command
fail ArgumentError, "Cannot get config for plug-in and command together"
elsif for_plugin
@config.dig(:plugins, for_plugin.to_sym) || OpenStruct.new
elsif for_command
@config.dig(:commands, for_command.to_sym) || Op... | [
"def config\n yield @@config_options\n end",
"def configurations\n return @configurations if @configurations\n \n configurations = CONFIGURATIONS_CLASS.new\n configurations.extend(IndifferentAccess) if @use_indifferent_access\n \n ancestors.reverse.each do |ancestor|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The release metadata that will be written for the package. | def release_metadata
@release_metadata ||= {
package: {
name: name,
repo: {
type: "git", # Hardcoded until we have other support
url: repo_url
},
hashref: release_hashref,
timestamp: timestamp
}
}
end | [
"def final_release_metadata_json\n @final_release_metadata_json ||= Pathname(\"#{final_name}-release-metadata.json\")\n end",
"def package_metadata\n @package_metadata ||= ::ChefDk::Helpers.metadata_for(\n channel: channel,\n version: version,\n platform: node['platform'],\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the release hashref. | def release_hashref
@release_hashref ||= `git rev-parse HEAD`.chomp
end | [
"def release_hashref(save_to: nil)\n @release_hashref ||= %x(git rev-parse HEAD).chomp\n File.open(save_to, 'w') { |f| f.write @release_hashref } if save_to\n @release_hashref\n end",
"def final_release_hashref\n @final_release_hashref ||=\n Pathname(\"#{final_name}-release-hashref.txt\")\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The working path for the job, in tmp_path. | def work_path
@work_path ||= tmp_path.join(name)
end | [
"def tmp_path\n @tmpfile.path\n end",
"def tmp_path\n File.join(home_path, \"tmp\")\n end",
"def tmp_path\n Default.tmp_path / pool.name / name\n end",
"def tmp_path(path)\n return File.expand_path(File.join(@@config['tmpPath'], path))\n end",
"def tmp_dir\n File.expand_path... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The path to the resulting releasemetadata.json file. | def final_release_metadata_json
@final_release_metadata_json ||= Pathname("#{final_name}-release-metadata.json")
end | [
"def path_for(package)\n \"#{package.path}.metadata.json\"\n end",
"def path_for(package)\n \"#{package.path}.metadata.json\"\n end",
"def metadatafile\n @tagdir + '/' + @name + '.json'\n end",
"def save_release_metadata(local: false)\n display \"Saving release metadata.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create the release package(s). Requests: +:vendor_dependencies+ (vendor_dependencies, path) +:pre_build_package+ +:build_package+ +:post_build_package+ | def build_package
# Force timestamp to be initialized before anything else. This gives us a
# stable timestamp for the process.
timestamp
# Prepare the work area: copy files from root_path to work_path based on
# the resolved Manifest.txt.
prepare_work_area
# Anything that has been modified ... | [
"def create_package(package_meta, release_dir)\n name = package_meta['name']\n version = package_meta['version']\n\n package_attrs = {\n release: @release_model,\n name: name,\n sha1: nil,\n blobstore_id: nil,\n fingerprint: package_meta['fingerprint... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Just save the release metadata. | def save_release_metadata(local: false)
display "Saving release metadata..."
json = JSON.generate(release_metadata)
if local
Pathname(".").join("release-metadata.json").write(json)
else
work_path.join("release-metadata.json").write(json)
final_release_metadata_json.write(json)
end... | [
"def release_metadata\n @release_metadata ||= {\n package: {\n name: name,\n repo: {\n type: \"git\", # Hardcoded until we have other support\n url: repo_url\n },\n hashref: release_hashref,\n timestamp: timestamp\n }\n }\n end",
"def save_meta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the flag to use with +tar+ given the value of +compression+. | def tar_compression_flag
case compression
when :bzip2, "bzip2", nil
"j"
when :gzip, "gzip"
"z"
when :none, "none"
""
end
end | [
"def tar_compression_flag(path)\n case path\n when /\\.tar\\.bz2$/\n return \"-j\"\n when /\\.tar\\.gz$|\\.tgz$/\n return \"-z\"\n when /\\.tar\\.xz$/\n return \"-J\"\n else\n return nil\n end\n end",
"def tar_compression_extension\n case compression\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the extension to use with +tar+ given the value of +compression+. | def tar_compression_extension
case compression
when :bzip2, "bzip2", nil
".bz2"
when :gzip, "gzip"
".gz"
when :none, "none"
""
end
end | [
"def tar_compression_flag\n case compression\n when :bzip2, \"bzip2\", nil\n \"j\"\n when :gzip, \"gzip\"\n \"z\"\n when :none, \"none\"\n \"\"\n end\n end",
"def tar_compression_flag(path)\n case path\n when /\\.tar\\.bz2$/\n return \"-j\"\n when /\\.tar\\.gz$|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Recursively copy a provided +path+ to the work_path, using a tar pipeline. The target location can be amended by the use of the +to+ parameter as a relative path to work_path. If a relative +path+ is provided, it will be treated as relative to root_path, and it will be used unmodified for writing to the target location... | def recursive_copy(path, to: nil)
path = Pathname(path)
to = Pathname(to) if to
if path.to_s =~ %r{\.\./} || (to && to.to_s =~ %r{\.\./})
fail StandardError, "Recursive copy parameters cannot contain '/../'"
end
if path.relative?
parent = root_path
else
parent, path = path.sp... | [
"def copy(from, to, recursive = false)\n allTargets = []\n from = [from] unless from.kind_of?(Array)\n from.each { |t| allTargets.concat(dirGlob(t)) }\n\n raise \"copy: no source files matched\" if allTargets.length == 0\n if allTargets.length > 1 || recursive\n raise \"copy: destination directo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This started out as a straight line drawn to step barbs, but at a certain point it also started being used to draw straight lines with no arrow heads from step barbs to calm barbs. | def render_to_step_barb(calm=false)
stroke ARROW_STROKE_COLOR
stroke_weight ARROW_STROKE_WEIGHT
# Initial trig calculations for the arrow head
adj = @to_barb.pos.x - @from_barb.pos.x
opp = @to_barb.pos.y - @from_barb.pos.y
angle = Math.atan(opp/adj)
if adj>0 and opp<0.001 and opp>-0.001
line_from... | [
"def straight\n @line_type = '--'\n self\n end",
"def draw_line; draw_horizontal_line(@draw_y + (line_height / 2) - 1, 2); end",
"def forward(steps)\n validate_steps(steps)\n normal_radians = to_rad(flip_turtle_and_normal(@heading))\n new_pt = [@xy[0] + steps * cos(normal_radians),\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hovers the widget defined by +name+ and optional +args+. | def hover(name, *args)
widget(name, *args).hover
end | [
"def hover(*args)\n if args.empty?\n root.hover\n else\n widget(*args).hover\n end\n end",
"def hover(&blk)\n @__app__.current_slot.hover(blk)\n end",
"def show_hover_alert(name = \"\", icon = 0, *args)\n if (name.nil? || name.empty?) && (icon.nil? || icon ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Double clicks the widget defined by +name+ and optional +args+. | def double_click(name, *args)
widget(name, *args).double_click
end | [
"def double_click(*args)\n if args.empty?\n root.double_click\n else\n widget(*args).double_click\n end\n end",
"def right_click(name, *args)\n widget(name, *args).right_click\n end",
"def double_click(*args)\n case args.length\n when 1 then cl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Right clicks the widget defined by +name+ and optional +args+. | def right_click(name, *args)
widget(name, *args).right_click
end | [
"def double_click(name, *args)\n widget(name, *args).double_click\n end",
"def right_click(*args)\n if args.empty?\n root.right_click\n else\n widget(*args).right_click\n end\n end",
"def click(*args)\n if args.empty?\n root.click\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a widget instance for the given name. | def widget(name, *args)
eventually { document.widget(name, *args) }
end | [
"def get_object(name)\n gtk_builder_get_object(@builder, name)\n end",
"def jmaki_load_widget(name)\n # Return previously parsed content (if any)\n if !@jmaki_widgets\n @jmaki_widgets = { }\n end\n previous = @jmaki_widgets[name]\n if previous\n return previous\n end\n conte... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of widget instances for the given name. | def widgets(name, *args)
document.widgets(name, *args)
end | [
"def widgets(win_name)\n @driver.getQuickWidgetList(win_name).map do |java_widget|\n case java_widget.getType\n when QuickWidget::WIDGET_ENUM_MAP[:button]\n QuickButton.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:checkbox]\n QuickCheckbox.new(self,j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
D: return the objects total face count. | def get_face_count
count = 0
@groups.each_value do |grp|
count += grp.faces.size
end
return count
end | [
"def game_objects_count\n @game_objects.count\n end",
"def count_objects\n ObjectSpace.count_objects\n end",
"def count\n \n return @objects.count\n \n end",
"def size() \n return @n_objects\n end",
"def number_of_verts\n\t\t@number_of_verts ||= begin\n\t\t\tsize = 0\n\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
D: Read a .obj file and turn the lines into data points to create the object. | def parse
wo_lines = IO.readlines( @file_dir )
@current_group = get_group( "default" )
@current_material_name = "default"
puts("+Loading .obj file:\n \"#{@file_dir.sub(ROOT, '')}\"") if @verbose
# parse file context
wo_lines.each do |line|
tokens = line.split
# make ... | [
"def read_objects(file, objects)\n objects.each do |data_type|\n num = DataNumber.new.read(file).data\n\n # use i to indentify the type of object.\n num.times do ||\n _obj = data_type.new.read(file)\n end\n end\n end",
"def parse\n infile = File.open @infilename\n \n whi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Records when was the world seen into the world's coordinator record | def add_record(id, time = Time.now)
record = find_world id
@executor[id] ||= record.data[:class] == 'Dynflow::Coordinator::ExecutorWorld'
record.data[:meta].update(:last_seen => self.class.format_time(time))
@world.coordinator.update_record(record)
end | [
"def last_seen_at() ; info_time(:last_seen) ; end",
"def record_seen(headers)\n return unless headers.include?(\"seen-by\")\n\n c_out = processor_type == \"federation\" ? \"collective\" : \"federation\"\n c_in = processor_type\n\n (headers[\"seen-by\"] ||= []) << [\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Looks into the cache whether the world has an executor | def executor?(id)
@executor[id]
end | [
"def _loaded?\n !!@executed\n end",
"def cached?(name)\n @cached.include?(name)\n end",
"def is_executor_for? proj\n if proj.team.team_memberships.where(:team_member_id => self.id).present?\n return (proj.team.team_memberships.where(:team_member_id => self.id).first.role ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Loads the coordinator record from the database and checks whether the world was last seen within the time limit | def fresh_record?(id)
record = find_world(id)
return false if record.nil?
@executor[id] = record.data[:class] == 'Dynflow::Coordinator::ExecutorWorld'
time = self.class.load_time(record.data[:meta][:last_seen])
time >= Time.now - @max_age
end | [
"def check_if_possible_duplicate\n return unless self.foursquare_place_id.present?\n last_time = LocationContext.where(:user_id => self.user_id).order('created_at DESC').limit(1)\n if last_time.present? and last_time.first.foursquare_place_id == self.foursquare_place_id and last_time.first.created_at > Tim... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Records when was the world with provided id last seen using a PingCache | def add_ping_cache_record(id)
log Logger::DEBUG, "adding ping cache record for #{id}"
@ping_cache.add_record id
end | [
"def last_seen_at() ; info_time(:last_seen) ; end",
"def add_record(id, time = Time.now)\n record = find_world id\n @executor[id] ||= record.data[:class] == 'Dynflow::Coordinator::ExecutorWorld'\n record.data[:meta].update(:last_seen => self.class.format_time(time))\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tries to reduce the number of sent Ping requests by first looking into a cache. If the destination world is an executor world, the result is resolved solely from the cache. For client worlds the Ping might be sent if the cache record is stale. | def with_ping_request_caching(request, future)
return yield unless request.is_a?(Dynflow::Dispatcher::Ping)
return yield unless request.use_cache
if @ping_cache.fresh_record?(request.receiver_id)
future.fulfill(true)
else
if @ping_cache.executor?(request.receiver_id)... | [
"def test_pulls_from_cache_if_in_cache_and_not_expired\n actual = @apache.resolve_ip '1.1.1.1'\n\n assert_equal '1111.org', actual\n end",
"def try_route_with_internal_cache(type, name)\n if host = self.cache[name]\n logger.debug \"Found '#{host}' for #{type} '#{name}' from Internal Cache.\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /dor_masters GET /dor_masters.json | def index
@dor_masters = DorMaster.all
end | [
"def index\n @djrmasters = Djrmaster.all\n end",
"def index\n @masters = Master.all\n end",
"def index\n @nomination_masters = NominationMaster.all\n end",
"def index\n @puppetmasters = Puppetmaster.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /dor_masters POST /dor_masters.json | def create
@dor_master = DorMaster.new(dor_master_params)
respond_to do |format|
if @dor_master.save
format.html { redirect_to @dor_master, notice: 'Dor master was successfully created.' }
format.json { render :show, status: :created, location: @dor_master }
else
format.html... | [
"def create\n @master = Master.new(master_params)\n\n respond_to do |format|\n if @master.save\n format.html { redirect_to @master, notice: \"Master was successfully created.\" }\n format.json { render :show, status: :created, location: @master }\n else\n format.html { render :n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /dor_masters/1 PATCH/PUT /dor_masters/1.json | def update
respond_to do |format|
if @dor_master.update(dor_master_params)
format.html { redirect_to @dor_master, notice: 'Dor master was successfully updated.' }
format.json { render :show, status: :ok, location: @dor_master }
else
format.html { render :edit }
format.jso... | [
"def update_master\n respond_to do |format|\n if @rider.update(rider_params)\n format.json { render :show, status: :ok, location: api_v1_master_rider_url(@rider) }\n else\n format.json { render json: @rider.errors, status: :unprocessable_entity }\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /dor_masters/1 DELETE /dor_masters/1.json | def destroy
@dor_master.destroy
respond_to do |format|
format.html { redirect_to dor_masters_url, notice: 'Dor master was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @gs1_master.destroy\n respond_to do |format|\n format.html { redirect_to gs1_masters_url, notice: DELETE_NOTICE }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mastery.destroy\n respond_to do |format|\n format.html { redirect_to masteries_url }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
What is the longest height based on width of dp[i][j] | def expand(dp, i, j)
height = 0
width = dp[i][j]
# Up
i.downto(0).each do |m|
break if dp[m][j] < width
height += 1
end
# Down
(i+1..dp.size-1).each do |m|
break if dp[m][j] < width
height += 1
end
height*width
end | [
"def size_longest_side(img, size)\n img.resize_to_fit(size)\n end",
"def height\n [self.left_height, self.right_height].max\n end",
"def largestRectangle(h)\n max = 0\n h.each_with_index do |element, index|\n height = 0\n # height += 1\n height += get_from_right(h[index..h.length], element)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /announcements/new GET /announcements/new.xml | def new
@announcement = Announcement.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @announcement }
end
end | [
"def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @announce }\n end\n end",
"def new\n @announce = Announce.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @announc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /announcements POST /announcements.xml | def create
@announcement = Announcement.new(params[:announcement])
respond_to do |format|
if @announcement.save
flash[:notice] = 'Announcement was successfully created.'
format.html { redirect_to announcements_path }
format.xml { render :xml => @announcement, :status => :created,... | [
"def create\n @announcement = Announcement.new(params[:announcement])\n\n respond_to do |format|\n if @announcement.save\n flash[:notice] = 'Announcement was successfully created.'\n format.html { redirect_to(@announcement) }\n format.xml { render :xml => @announcement, :status => :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A utility method for escaping XML names of tags and names of attributes. xml_name_escape('1 "1___2___3" It follows the requirements of the specification: | def xml_name_escape(name)
name = name.to_s
return "" if name.blank?
return name if name.match?(SAFE_XML_TAG_NAME_REGEXP)
starting_char = name[0]
starting_char.gsub!(INVALID_TAG_NAME_START_REGEXP, TAG_NAME_REPLACEMENT_CHAR)
return starting_char if name.size == 1
following_cha... | [
"def xml_name_escape(name); end",
"def xml_escape(input); end",
"def xml_attr_escape\n replacements = {\"<\" => \"<\", \">\" => \">\", \"&\" => \"&\", \"\\\"\" => \""\", \"'\" => \"'\"}\n gsub(/([<>&\\'\\\"])/) { replacements[$1] }\n end",
"def html_attribute_name_escape(n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ps:dynos [QTY] DEPRECATED: use `heroku ps:scale dynos=N` scale to QTY web processes if QTY is not specified, display the number of web processes currently running Example: $ heroku ps:dynos 3 Scaling dynos... done, now running 3 | def dynos
# deprecation notice added to v2.21.3 on 03/16/12
display("~ `heroku ps:dynos QTY` has been deprecated and replaced with `heroku ps:scale dynos=QTY`")
dynos = shift_argument
validate_arguments!
if dynos
action("Scaling dynos") do
new_dynos = api.put_dynos(app, dynos).body["... | [
"def set_dynos qty\n progress \"starting #{qty} dyno(s) \"\n\n heroku.post_ps_scale app, 'web', qty\n # heroku.set_dynos app, qty\n while true\n progress \".\"\n sleep 1.0\n dynos = heroku.get_ps(app).body\n web_synos = []\n dynos.ea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ps:workers [QTY] DEPRECATED: use `heroku ps:scale workers=N` scale to QTY background processes if QTY is not specified, display the number of background processes currently running Example: $ heroku ps:dynos 3 Scaling workers... done, now running 3 | def workers
# deprecation notice added to v2.21.3 on 03/16/12
display("~ `heroku ps:workers QTY` has been deprecated and replaced with `heroku ps:scale workers=QTY`")
workers = shift_argument
validate_arguments!
if workers
action("Scaling workers") do
new_workers = api.put_workers(ap... | [
"def scale\n app = extract_app\n current_process = nil\n changes = args.inject({}) do |hash, process_amount|\n if process_amount =~ /^([a-zA-Z0-9_]+)([=+-]\\d+)$/\n hash[$1] = $2\n end\n hash\n end\n\n error \"Usage: heroku ps:scale web=2 worker+1\" if changes.empty?\n\n chan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ps:restart [DYNO] restart an app dyno if DYNO is not specified, restarts all dynos on the app Examples: $ heroku ps:restart web.1 Restarting web.1 dyno... done $ heroku ps:restart web Restarting web dyno... done $ heroku ps:restart Restarting dynos... done | def restart
dyno = shift_argument
validate_arguments!
message, options = case dyno
when NilClass
["Restarting dynos", {}]
when /.+\..+/
ps = args.first
["Restarting #{ps} dyno", { :ps => ps }]
else
type = args.first
["Restarting #{type} dynos", { :type => type }]
... | [
"def restart\n app = extract_app\n\n opts = case args.first\n when NilClass then\n display \"Restarting processes... \", false\n {}\n when /.+\\..+/\n ps = args.first\n display \"Restarting #{ps} process... \", false\n { :ps => ps }\n else\n type = args.first\n disp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ps:stop DYNOS stop an app dyno Examples: $ heroku stop run.3 Stopping run.3 dyno... done $ heroku stop run Stopping run dynos... done | def stop
dyno = shift_argument
validate_arguments!
message, options = case dyno
when NilClass
error("Usage: heroku ps:stop DYNO\nMust specify DYNO to stop.")
when /.+\..+/
ps = args.first
["Stopping #{ps} dyno", { :ps => ps }]
else
type = args.first
["Stopping #{ty... | [
"def kill_process(ps)\n heroku.post_ps_stop(\n ENV['APP_NAME'],\n ps: ps\n )\nend",
"def stop\n app = extract_app\n opt =\n if (args.first =~ /.+\\..+/)\n ps = args.first\n display \"Stopping #{ps} process... \", false\n {:ps => ps}\n elsif args.first\n type = a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ps:type [TYPE | DYNO=TYPE [DYNO=TYPE ...]] manage dyno types called with no arguments shows the current dyno type called with one argument sets the type where type is one of free|hobby|standard1x|standard2x|performance called with 1..n DYNO=TYPE arguments sets the type per dyno | def type
requires_preauth
app
formation = get_formation
changes = if args.any?{|arg| arg =~ /=/}
args.map do |arg|
if arg =~ /^([a-zA-Z0-9_]+)=([\w-]+)$/
type, new_size = $1, $2
current_p = formation.find{|f| f["type"] == type}
... | [
"def dynos\n # deprecation notice added to v2.21.3 on 03/16/12\n display(\"~ `heroku ps:dynos QTY` has been deprecated and replaced with `heroku ps:scale dynos=QTY`\")\n\n dynos = shift_argument\n validate_arguments!\n\n if dynos\n action(\"Scaling dynos\") do\n new_dynos = api.put_dynos(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds multiple Populator::Record instances and calls save_records them when :per_query limit option is reached. | def build_records(amount, per_query, &block)
amount.times do
record = Record.new(@model_class, last_id_in_database + @records.size + 1)
@records << record
block.call(record) if block
save_records if @records.size >= per_query
end
end | [
"def build_records(amount, &block)\n amount.times do\n record = Record.new(@collection)\n block.call(record) if block\n @records << record.attributes.delete_if {|k,v| v.is_a?(MongoSkip) }\n save_records \n end\n end",
"def create_retrievals\n work_ids = Work.pluck(:id)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Saves the records to the database by calling populate on the current database adapter. | def save_records
unless @records.empty?
@model_class.connection.populate(@model_class.quoted_table_name, columns_sql, rows_sql_arr, "#{@model_class.name} Populate")
@last_id_in_database = @records.last.id
@records.clear
end
end | [
"def save_records\n @records.each do |record|\n @collection.insert(record)\n end\n @records.clear\n end",
"def save\n storage.save(records)\n end",
"def save(record)\n @db.put_item(table_name: record.table, item: record.items)\n end",
"def save_all\n RelaxDB.bulk_save... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
in the array. The array will never be empty and the numbers will always be positive integers. given an array of integer calculate the average of all numbers numbers are all > 0 iterate over array , sum them and divide by the size of the array | def average(array)
return 0 if array.empty?
array.sum / array.size
end | [
"def average(array)\n sum = 0\n array.each do |int|\n sum += int\n end\n sum / array.length\nend",
"def average(array)\n sum = 0.0 # Initialize as float to avoid integer division\n\n for int in array # Sum all numbers in array\n sum += int\n end\n\n sum / array.size # Divide by number of n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /families/1 GET /families/1.xml | def show
@family ||= Family.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @family }
end
end | [
"def index\n @families = Family.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @families }\n end\n end",
"def index\n @families = Family.find_all_by_member_and_current(true,true, :order => :name)\n\n respond_to do |format|\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /families/new GET /families/new.xml | def new
@family = Family.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @family }
end
end | [
"def new\n @family = Family.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @family }\n end\n end",
"def new\n @child = @family.children.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @child ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /families POST /families.xml | def create
@family = Family.new(params[:family])
respond_to do |format|
if @family.save
flash[:notice] = 'Family was successfully created.'
format.html { redirect_to(@family) }
format.xml { render :xml => @family, :status => :created, :location => @family }
else
form... | [
"def create_family(family_id, request)\n start.uri('/api/user/family')\n .url_segment(family_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end",
"def create_family(family_id, request)\n start.uri('/api/user/family')\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /families/1 PUT /families/1.xml | def update
@family ||= Family.find(params[:id])
respond_to do |format|
if @family.update_attributes(params[:family])
flash[:notice] = 'Family was successfully updated.'
format.html { redirect_to(@family) }
format.xml { head :ok }
else
format.html { render :action => "e... | [
"def update\n @family = Family.find(params[:id])\n\n respond_to do |format|\n if @family.update_attributes(params[:family])\n AuditTrail.audit(\"Family #{@family.familyname} updated by #{current_user.login}\", family_url(@family))\n flash[:notice] = 'Families was successfully updated.'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /families/1 DELETE /families/1.xml | def destroy
@family ||= Family.find(params[:id])
@family.destroy
respond_to do |format|
format.html { redirect_to(families_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @family = Family.find(params[:id])\n @family.destroy\n\n respond_to do |format|\n format.html { redirect_to(families_url) }\n format.xml { head :ok }\n end\n end",
"def delete_family(id)\n !!Client.delete(\"/kits/#{@id}/families/#{id}\")\n end",
"def delete_family(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /contact_stores GET /contact_stores.json | def index
@contact_stores = ContactStore.all
end | [
"def index\n @stores = Store.all\n\n render json: @stores\n end",
"def index\n @stores = Store.all\n render json: @stores\n end",
"def index\n @api_v1_stores = Store.all\n json_response(@api_v1_stores)\n end",
"def index\n @admin_stores = Admin::Store.all\n\n respond_to do |fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /contact_stores POST /contact_stores.json | def create
@contact_store = ContactStore.new(contact_store_params)
respond_to do |format|
if @contact_store.save
format.html { redirect_to @contact_store, notice: 'Contact store was successfully created.' }
format.json { render :show, status: :created, location: @contact_store }
els... | [
"def create\n @store = Store.new(store_params)\n\n if @store.save\n render json: @store, status: :created, location: @store\n else\n render json: @store.errors, status: :unprocessable_entity\n end\n end",
"def create\n @customer_store = CustomerStore.new(customer_store_params)\n\n res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /contact_stores/1 PATCH/PUT /contact_stores/1.json | def update
respond_to do |format|
if @contact_store.update(contact_store_params)
format.html { redirect_to @contact_store, notice: 'Contact store was successfully updated.' }
format.json { render :show, status: :ok, location: @contact_store }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n if @store.update(store_params)\n format.html { redirect_to [:phone, @store], notice: 'Store was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sto... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /contact_stores/1 DELETE /contact_stores/1.json | def destroy
@contact_store.destroy
respond_to do |format|
format.html { redirect_to contact_stores_url, notice: 'Contact store was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @store = Store.find(params[:id])\n @store.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_stores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cakestore.destroy\n respond_to do |format|\n format.html { redirect_to cake... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
SUPPLEMENTS SUMMARY Total summary | def total_summary
products = {}
products.store(:item_cost, item_cost)
products.store(:extras_cost, extras_cost)
supplements = {}
supplements.store(:pick_up_place, pickup_place_cost)
supplements.store(:return_place, return_place_cost)
supplements.store(:time_from... | [
"def summary; end",
"def apply_summary; nil; end",
"def summary\n return \"\\nNo results identified.\\n\" if tally.keys.empty?\n result = [ \"\\nSummary of identified results:\\n\" ]\n sum = 0\n tally.keys.sort_by {|k| -1*tally[k] }.each do |k|\n sum += tally[k]\n result << \"%... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
BOOKING LINES Add a booking line to the reservation == Parameters:: item_id:: The item id quantity:: The quantity | def add_booking_line(item_id, quantity)
# Check if the booking includes the item_id
product_lines = self.booking_lines.select do |booking_line|
booking_line.item_id == item_id
end
if product_lines.empty?
if product = ::Yito::Model::Booking::BookingCategory.get(item_id)
... | [
"def adds_line_item(fields)\r\n @b.link(:id, \"add_line_item\").click\r\n @b.wait()\r\n \r\n trows = line_items_rows\r\n index = trows.length\r\n edits_line_item(index, fields)\r\n index\r\n end",
"def create_line_item_from_inventory_item inventory_item, qty, payable_party, b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Destroy a booking line == Parameters:: item_id:: The item line id | def destroy_booking_line(item_id)
product_lines = self.booking_lines.select do |booking_line|
booking_line.item_id == item_id
end
if booking_line = product_lines.first
transaction do
self.item_cost -= booking_line.item_cost
self.product_deposit_cost -= book... | [
"def destroy\n @item_line = ItemLine.find(params[:id])\n @item_line.destroy\n\n respond_to do |format|\n format.html { redirect_to item_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @receivable = Receivable.find(params[:receivable_id])\n @receivable_line ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
EXTRAS Add a booking extra to the reservation | def add_booking_extra(extra_id, quantity)
booking_extras = self.booking_extras.select do |booking_extra|
booking_extra.extra_id == extra_id
end
if booking_extras.empty?
if extra = ::Yito::Model::Booking::BookingExtra.get(extra_id)
extra_translation = extra.translate(c... | [
"def add_reservation(start_date, end_date)\n @bookings << [start_date, end_date]\n end",
"def add_reservation(reservation)\n @reservations << reservation\n end",
"def add_extra_fields(*args)\n @extra_fields += [ *args ]\n @retain_fields += [ *args ]\n end",
"def add_extra(extra_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
BOOKING CHARGE Add a booking charge | def add_booking_charge(date, amount, payment_method_id)
transaction do
charge = Payments::Charge.new
charge.date = date
charge.amount = amount
charge.payment_method_id = payment_method_id
charge.status = :pending
charge.currency = SystemConfiguration::Variab... | [
"def add_charge()\n prompt = TTY::Prompt.new(symbols: {marker: \">\"})\n system('clear')\n puts \"Add new charge to #{@name} account ID: #{@id}\\n\\n\\n\"\n\n description = prompt.ask(\"Description:\", default: \"Work done on #{Debug::Date}\") do |q|\n q.validate(/^[\\:\\-\\/\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Destroy a booking charge | def destroy_booking_charge(charge_id)
if booking_charge = BookingDataSystem::BookingCharge.first(:booking_id => self.id,
:charge_id => charge_id)
charge = booking_charge.charge
transaction do
if charge.status == :done... | [
"def destroy\n @booking_slot.destroy\n\n head :no_content\n end",
"def destroy\n @charge = Charge.find(params[:id])\n @charge.destroy\n\n respond_to do |format|\n format.html { redirect_to charges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @set_booking... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the category of the reserved items | def category
booking_lines and booking_lines.size > 0 ? ::Yito::Model::Booking::BookingCategory.get(booking_lines[0].item_id) : nil
end | [
"def category\n fetch('fishbrain.equipment.categories')\n end",
"def assigned_categories\n cats = quotations.collect { |q| q.categories }.flatten\n cat_ids = cats.collect { |c| c.id }.uniq\n Category.find(cat_ids)\n end",
"def categories_for(item)\n return [] unless @items[item]\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check the payment cadence is allowed | def payment_cadence_allowed?
begin
config_payment_cadence = SystemConfiguration::Variable.get_value('booking.payment_cadence').to_i
_date_from_str = "#{self.date_from.strftime('%Y-%m-%d')}T#{self.time_from}:00#{self.date_from.strftime("%:z")}"
_date_from = DateTime.strptime(_da... | [
"def charge_is_allowed?\n\t\tif not customer_has_authorized_payment?\n\t\t\terrors.add :base, I18n.t('views.customer_file.new_charge.you_are_not_authorized')\n\t\t\tfalse\n\t\telsif valid? and charge_amount.present? and authorized_amount and charge_amount.to_i <= authorized_amount\n\t\t\ttrue\n\t\telse\n\t\t\terror... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if the booking deposit can be paid | def can_pay_deposit?
conf_payment_enabled = SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool
conf_payment_deposit = (['deposit','deposit_and_total'].include?(SystemConfiguration::Variable.get_value('booking.payment_amount_setup', 'deposit')))
if self.status == :pending_... | [
"def can_pay_pending?\n conf_payment_enabled = SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool\n conf_payment_deposit = (['deposit','deposit_and_total'].include?(SystemConfiguration::Variable.get_value('booking.payment_amount_setup', 'deposit')))\n conf_payment_pending ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if the booking pending amout can be paid | def can_pay_pending?
conf_payment_enabled = SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool
conf_payment_deposit = (['deposit','deposit_and_total'].include?(SystemConfiguration::Variable.get_value('booking.payment_amount_setup', 'deposit')))
conf_payment_pending = System... | [
"def paid_in_full?\n !payment_outstanding?\n end",
"def is_pending?\n generated_at.nil? && !paid_on.nil?\n end",
"def check_if_unpaying\n return false if self.paid_changed? && self.paid == false\n end",
"def partially_paid?\n state_name == :partially_paid\n end",
"def can_pay_deposit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if the booking total can be paid | def can_pay_total?
conf_payment_enabled = SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool
conf_payment_total = (['total','deposit_and_total'].include?(SystemConfiguration::Variable.get_value('booking.payment_amount_setup', 'deposit')))
if self.status == :pending_confir... | [
"def paid_enough?\n errors.add(:paid,'You don\\'t paid enough') unless self.product.value <= self.total_paid\n end",
"def can_pay_pending?\n conf_payment_enabled = SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool\n conf_payment_deposit = (['deposit','deposit_and_total'].... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a list of the other people involved in the contract (extracted from resources) | def contract_other_people
result = []
booking_line_resources.each do |resource|
result << { :name => resource.resource_user_name,
:surname => resource.resource_user_surname,
:document_id => resource.resource_user_document_id,
:phone =... | [
"def involved_users\n involv_splits = self.project_splits.where(role: \"Involved\")\n names = []\n if involv_splits.any?\n\n # put names into array\n involv_splits.each do |x|\n names << x.user.name\n end\n # Return names in array\n names\n else\n names << \"None\"\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates an online charge | def create_online_charge!(charge_payment, charge_payment_method_id)
if total_pending > 0 and
charge_payment_method = Payments::PaymentMethod.get(charge_payment_method_id.to_sym) and
not charge_payment_method.is_a?Payments::OfflinePaymentMethod and
!([:deposit, :pending, :to... | [
"def create_online_charge!(charge_payment, charge_payment_method_id)\n \n if total_pending > 0 and \n charge_payment_method = Payments::PaymentMethod.get(charge_payment_method_id.to_sym) and\n not charge_payment_method.is_a?Payments::OfflinePaymentMethod \n\n amount =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Confirms the booking A booking can only be confirmed if it's pending confirmation and contains a done charge | def confirm
if status == :pending_confirmation and
not charges.select { |charge| charge.status == :done }.empty?
transaction do
self.status = :confirmed
self.save
# Assign available stock
assign_available_stock if SystemConfiguration::Variable.get_va... | [
"def confirm!\n if @status == Done then\n @status = Confirmed\n @completed_at = Date.today\n end\n end",
"def confirm!\n self.pending = false\n self.save\n self.createDebts\n end",
"def confirm\n if status == :pending_co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Confirm the booking without checking the charges | def confirm!
if status == :pending_confirmation
transaction do
update(:status => :confirmed)
# Assign available stock
assign_available_stock if SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation', 'false').to_bool
# Cre... | [
"def confirm\n if status == :pending_confirmation and\n not charges.select { |charge| charge.status == :done }.empty?\n transaction do\n self.status = :confirmed\n self.save\n # Assign available stock\n assign_available_stock if SystemConfiguration::Var... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Cancels a booking A booking can only be cancelled if it isn't already cancelled | def cancel
unless status == :cancelled
transaction do
if total_paid > 0
update(:status => :cancelled, :payment_status => :refunded, :total_paid => 0, :total_pending => total_cost)
else
update(:status => :cancelled)
end
# Crea... | [
"def canceled?\n !!booking.try(:canceled?)\n end",
"def cancel_booking\n @booking = Booking.find(params[:id])\n if @booking.booking_date > Time.now\n if params[:cancellation_message].strip == \"\" || params[:cancellation_message].nil?\n flash[:danger] = \"Message needs to be specified be... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the payment method instance | def payment_method
if payment_method_id.nil?
return nil
else
@payment_method ||= Payments::PaymentMethod.get(payment_method_id.to_sym)
end
end | [
"def payment_method\n @payment_method ||= PaymentMethod.get(payment_method_id.to_sym)\n end",
"def payment_method\n Zapi::Models::PaymentMethod.new\n end",
"def payment_method\n @payment_method ||= PAYMENT_METHOD[mapping_for()]\n end",
"def payment_method\n @payment_met... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Automatic resource assignation Assign available stock to unassigned items | def assign_available_stock
stock_detail, category_occupation = BookingDataSystem::Booking.categories_availability(self.rental_location_code,
self.date_from,
... | [
"def review_assigned_stock\n\n automatic_assignation = SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation', 'false').to_bool\n\n # Search availability\n product_search = ::Yito::Model::Booking::BookingCategory.search(self.rental_location_code,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Review the assigned stock when the user changes dates | def review_assigned_stock
automatic_assignation = SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation', 'false').to_bool
# Search availability
product_search = ::Yito::Model::Booking::BookingCategory.search(self.rental_location_code,
... | [
"def update_due_date(item_name,new_due_date)\n \t@items.each do |value|\n \t if value.description == item_name # check each item against input item\n \t\t value.due_date = new_due_date\n \t\t @report_file.puts \"Item: #{item_name} due date updated to #{new_due_date}\"\n \t end\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new business event to notify a booking has been created | def create_new_booking_business_event!
BusinessEvents::BusinessEvent.fire_event(:new_booking,
{:booking_id => id})
end | [
"def create\n @business_event = BusinessEvent.new(business_event_params)\n\n respond_to do |format|\n if @business_event.save\n format.html { redirect_to @business_event, notice: 'Business event was successfully created.' }\n format.json { render :show, status: :created, location: @business... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
First octet of the SMSDELIVER PDU | def sms_deliver_first_octet
octet = 0
octet |= 0x04 unless @opts[:more_to_send]
octet |= 0x80 if @opts[:has_udh]
octet.chr
end | [
"def sms_submit_first_octet\n octet = 1\n octet |= 0x80 if @opts[:has_udh]\n octet.chr\n end",
"def pdu\n message.pdu\n end",
"def service_number\n @binary_components[0]\n end",
"def prepend_length(msg)\n size = msg.length.to_s(16) # 16 bit \n header = size.to_s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
First octet of the SMSSUBMIT PDU | def sms_submit_first_octet
octet = 1
octet |= 0x80 if @opts[:has_udh]
octet.chr
end | [
"def sms_deliver_first_octet\n octet = 0\n octet |= 0x04 unless @opts[:more_to_send]\n octet |= 0x80 if @opts[:has_udh]\n octet.chr\n end",
"def pdu\n message.pdu\n end",
"def get_signature\n str_sz = get(1).unpack('C')[0]\n ret = @buffy.slice(@idx, str_sz)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Consider the following "magic" 3gon ring, filled with the numbers 1 to 6, and each line adding to nine. (4) \ (3) / \ (1)(2)(6) / (5) Working clockwise, and starting from the group of three with the numerically lowest external node (4,3,2 in this example), each solution can be described uniquely. For example, the above... | def solve( n = 16 )
max = 0
(1..10).each do |a|
(1..10).each do |b|
next if b == a
(1..10).each do |c|
next if c == b || c == a
(1..10).each do |d|
next if d == c || d == b || d == a
(1..10).each do |e|
next if e == d || e == c... | [
"def tetragon_ring\n [*1..6].reverse.permutation do |a,b,c,d,e,f|\n sum = a+d+e\n next unless b+e+f == sum && c+f+d == sum && a < b && a < c\n return [[a,d,e],[b,e,f],[c,f,d]].flatten.join.to_i\n end\nend",
"def gen_rings\n shortc = (0..9).collect{|i| i unless @longc.include?(i) }.compact\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The xpath to the collection that the item belongs to (relative path from the item node) | def collection_xpath
"ancestor::#{Ead::Collection.root_xpath}[1]"
end | [
"def item_xpath\n \"ancestor::#{Ead::Item.root_xpath}[1]\"\n end",
"def xpaths\n self.feeds.last.xpaths\n end",
"def xpath\n [parent_xpath, local_xpath].flatten.compact.join(\"/\")\n end",
"def xpath\n attr_value('xpath')\n end",
"def xpath\n xml.xpath\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Overridden from the Commits::CreateService, to skip some validations we don't need: validate_on_branch! Not needed, the patches are applied on top of HEAD if the branch did not exist validate_branch_existence! Not needed because we continue applying patches on the branch if it already existed, and create it if it did n... | def validate!
validate_patches!
validate_new_branch_name! if new_branch?
validate_permissions!
end | [
"def create_patch(repo_path, commit, branch)\n `(cd \"#{repo_path}\" && git format-patch --stdout #{commit}..#{branch})`\n end",
"def create_default_branch!\n target_repository.create_file(\n git_user,\n \".CopyDesignCollectionService_#{Time.now.to_i}\",\n '.gitlab',\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
share_folders sets up the shared folder definitions on the VirtualBox VM. The transient parameter determines if we're FORCING transient or not. If this is false, then any shared folders will be shared as nontransient unless they've specifically asked for transient. | def share_folders(machine, folders, transient)
defs = []
warn_user_symlink = false
folders.each do |id, data|
hostpath = data[:hostpath]
if !data[:hostpath_exact]
hostpath = Vagrant::Util::Platform.cygwin_windows_path(hostpath)
end
enable_sym... | [
"def share_folders(prefix, folders)\n folders.each do |type, local_path, remote_path|\n if type == :host\n env[:machine].config.vm.share_folder(\n \"v-#{prefix}-#{self.class.get_and_update_counter(:shared_folder)}\",\n remote_path, local_path, :nfs => c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /corges GET /corges.json | def index
@corges = Corge.all
end | [
"def index\n @cages = Cage.where(query_params)\n render json: @cages\n end",
"def index\n @corredors = Corredor.all\n end",
"def index\n @corals = Coral.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @corals }\n end\n end",
"def index\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /corges POST /corges.json | def create
@corge = Corge.new(corge_params)
respond_to do |format|
if @corge.save
format.html { redirect_to @corge, notice: 'Corge was successfully created.' }
format.json { render :show, status: :created, location: @corge }
else
format.html { render :new }
format.js... | [
"def create\n @cage = Cage.new(cage_params)\n\n if @cage.save\n render json: @cage, status: :created, location: @cage\n else\n render json: @cage.errors, status: :unprocessable_entity\n end\n end",
"def create\n @corrida = Corrida.new(corrida_params)\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /corges/1 PATCH/PUT /corges/1.json | def update
respond_to do |format|
if @corge.update(corge_params)
format.html { redirect_to @corge, notice: 'Corge was successfully updated.' }
format.json { render :show, status: :ok, location: @corge }
else
format.html { render :edit }
format.json { render json: @corge.e... | [
"def patch *args\n make_request :patch, *args\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def patch(path, params: {}, headers: {})\n request_json :patch, path, params, headers\n end",
"def api_patch(path, data = {})\n api_reque... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes the large amount of words from enable.txt and puts them into an array. | def generate_words
ret = []
File.open('enable.txt').each do |line|
new_line = line
# We don't care for the new line character in the game of hangman.
new_line = new_line.delete("\n")
ret << new_line
end
return ret
end | [
"def word_array(sort_file)\n get_file(sort_file).downcase.gsub(/[^a-z0-9\\s\\--]/,'').split(' ')\nend",
"def ReadFromFile()\n wordArray = Array.new\n File.open(\"mastermindWordList.txt\", \"r\") do |file| # Uncomment this to have a larger list (466000+ words)\n # Note: Only use if in original repository... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converting PDF to PNG | def convert_to_png(input_pdf, output_file)
pdf = Magick::ImageList.new(input_pdf) { self.density = 200 }
pdf.write(output_file)
end | [
"def convert_pdf_to_png(pdfPage, pngOut)\n command = \"convert -density 600x600 -resize 800x560 -quality 90 #{pdfPage} #{pngOut}\"\n proc = subprocess.Popen(command, shell=True)\n # Wait for the process to finish\n proc.wait() \n end",
"def process_pdf(image_path, new_image_path)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adding QR and label to the PNG | def embed_info(input_file, qr, label, x_coord, y_coord)
img_template = ChunkyPNG::Image.from_file(input_file)
img_label = ChunkyPNG::Image.from_file(label)
img_template.compose!(qr, x_coord, y_coord)
img_template.compose!(img_label, x_coord + 255, y_coord)
rename_file = input_file[5..-1]
img_template.save("... | [
"def customQRcode(inputStr) \n qrcode = RQRCode::QRCode.new(inputStr).as_png(fill: 'white', color: 'black', file: 'abc.png')\n avatar = ChunkyPNG::Image.from_file('abc.png')\n\n # alogo.png being the logo file\n badge = ChunkyPNG::Image.from_file('alogo.png')\n\n print(\"height of backgound:\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method can be used to manually link an asset to an acts_as_asset_box object in tests or otherwise. The object needs to be saved afterward so that the Effective::Attachment is saved (and the association is saved). For example: class User < ActiveRecord::Base acts_as_asset_box :avatar end asset = Effective::Asset.ne... | def add_to_asset_box(box, *items)
box = (box.present? ? box.to_s : 'assets')
boxes = box.pluralize
items = [items].flatten.compact
if items.present? && items.any? { |obj| !obj.kind_of?(Effective::Asset) }
raise ArgumentError.new('add_to_asset_box expects one or more Effective::Assets, or an Array... | [
"def add_asset\n asset = Asset.find_by_object_key(params[:asset])\n if asset.nil?\n notify_user(:alert, \"Unable to add asset. Record not found!\")\n return\n else\n @activity_line_item.assets << asset\n notify_user(:notice, \"Asset was successfully added to the ALI\")\n end\n red... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make sure there are conversation member objects for all users, if there is a converation associated with the availability | def ensure_conversation_members
convo = Conversation.where(availability_id: id).first
if convo
convo.conversation_members.create(user: user, admin: admin) if convo.conversation_members.where(user: user).first.nil?
end
end | [
"def match_availability_message_to_convo\n if conversation_id.nil? && !availability_id.nil?\n conversation = Conversation.where(availability_id: availability_id).first\n if conversation.nil?\n conversation = Conversation.create(availability_id: availability_id, name: \"Teaching #{availability.st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Truncated project identifier (shortname & part of the description) | def project_identifier(p, length=26)
truncate([p.shortname, p.description].join(" - "), :length => length)
end | [
"def project_name\n project_tag_id = 'Project : '\n content_tag = AdministrativeTags.for(identifier: cocina_obj.externalIdentifier).select { |tag| tag.include?(project_tag_id) }\n content_tag.empty? ? '' : content_tag[0].gsub(project_tag_id, '').strip\n end",
"def identifier\n [project.key, sequence]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Display an edit link if the entry belongs to the logged in user | def display_edit_link(entry)
if entry.user == current_user
link_to (image_tag 'edit.png'), edit_entry_path(entry)
end
end | [
"def show_edit_entry_link?\n user_signed_in? && @document.present? && (entry = @document.model_object).present? && can?(:edit, entry)\n end",
"def edit\n return unless access?(:update, @author)\n end",
"def user_edit\n if (user_signed_in? && (current_user.id == @book.user_id))\n @can_edit =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /time_entries/1 DELETE /time_entries/1.json | def destroy
@time_entry = TimeEntry.with_deleted.find(params[:id])
@time_entry.destroy
respond_to do |format|
format.html { redirect_to time_entries_url }
format.json { head :no_content }
end
end | [
"def destroy\n @time_entry = TimeEntry.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to time_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_entry = TimeEntry.find(params[:id])\n @time_entry.destroy\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Runs a string given in input as Ruby code or buffers it if the command is incomplete Test against level or input to check if the command has been executed | def run str
@input ||= ''
@level += str.scan(LEVEL_UP).length
@level -= str.scan(/(^|\s)end($|\s)/).length # Will probably fail with a character chain
@input += str + "\n"
if @level <= 0
tmp = input
reset
eval tmp, context
end
end | [
"def pre_cmd(input); end",
"def parseRunCommands\n didRun = false\n\n Dir.chdir($outputDir) {\n File.open($benchmarkDirectory + $benchmark) {\n | inp |\n inp.each_line {\n | line |\n begin\n doesMatch = line =~ /^\\/\\/@/\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return size, always 3. | def size
return 3
end | [
"def size\n\t\treturn 3\n\tend",
"def size(*) end",
"def length\n 3\n end",
"def size\n variables.size\n end",
"def size\n @size ||= approximate_size\n end",
"def size\n # atributo del objeto 1\n @size\n end",
"def current_size; end",
"def size\n items.size\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the exterior product. | def exterior_product(vec)
self.class.exterior_product(self, vec)
end | [
"def exterior_product(vec)\n\t\tself.class.exterior_product(self, vec)\n\tend",
"def base_product\n product_num\n end",
"def product\n self.product_size.product\n end",
"def product_version_operator\n return @product_version_operator\n end",
"def product_set\n product_se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
finding instrument user clicked on and creating inctance of booking for form | def show
@instrument = Instrument.find(params[:id])
@booking = Booking.new
end | [
"def create\n @instrument =\n current_facility.instruments.find_by!(url_name: params[:instrument_id])\n @reservation = @instrument.admin_reservations.new\n @reservation_form = AdminReservationForm.new(@reservation)\n @reservation_form.assign_attributes(admin_reservation_params.merge(created_by: cur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
now actually creating the new instrument with user params and saving it rendering new page if user did not input all params | def create
@instrument = Instrument.new(instrument_params)
@instrument.user = current_user
if @instrument.save
redirect_to instrument_path(@instrument), notice: 'Created new instrument.'
else
render :new
end
end | [
"def create\n p \"*******INST CREATE*********\"\n user = User.find_by(id: session[:user_id])\n instrument = user.instruments.build(instrument_params)\n if instrument.save\n render json: instrument, status: :created\n else\n render json: {error: \"Not Created\"}, status: :not_created\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
finding instrument to destroy destroying the instrument redirecting to root_path | def destroy
@instrument = Instrument.find(params[:id])
@instrument.destroy
redirect_to root_path
end | [
"def destroy\n @instrument = Instrument.find(params[:id])\n @instrument.destroy\n\n respond_to do |format|\n format.html { redirect_to(instruments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @instrumento = Instrumento.find(params[:id])\n @instrumento.destroy\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
finding instrument to update updating instrument with user_params redirecting to instrument_path | def update
@instrument = Instrument.find(params[:id])
@instrument.update(instrument_params)
redirect_to instrument_path(@instrument)
end | [
"def update\n params = profile_has_instrument_params\n params[:profile_id] = Profile.find_by_user_id(current_user.id).user_id\n respond_to do |format|\n if @profile_has_instrument.update(params)\n format.html { redirect_to root_path, notice: 'Instrument was successfully changed.' }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Implicitly hints that a uniform exists. | def uniform_location(uniform_name)
uniform_sym = uniform_name.to_sym
@uniform_locations[uniform_sym] ||=
Gl.glGetUniformLocation(@name, uniform_name.to_s)
end | [
"def set_texture_uniform(name, uniform)\n \n end",
"def bind_uniform(name, location)\n return if location == NO_UNIFORM\n value = self[name]\n return unless value\n\n type, length, address =\n if value.kind_of? PackedValue\n [value.type, value.length, value.value]\n elsif value.... | {
"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.