query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
gets the next video in the order. accepts an id.
def next_video(current_id) @video_ids = airings.map {|a| a.video_id } @current_index = @video_ids.index current_id.to_i if @current_index next_index = (@current_index + 1) % self.videos.count Video.find(@video_ids[next_index]) else # give the next video or the first if current_index no...
[ "def next_video!\n set_next_video\n save if @video_changed\n end", "def next\n video = playlist.next\n play(video) if video\n video\n end", "def next\n room.players.where(\"id > ?\", id).first || room.players.first\n end", "def next_video\n if episode?\n episode = content....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
All the shows where the contact is the promoter.
def promoter_shows Show.where(promoter_id: id) end
[ "def index\n @promoters = Promoter.find(:all).sort_by{|p| p.name_or_contact_info}\n end", "def promoter\n Contact.find(promoter_id)\n end", "def presenters\n find_related_frbr_objects( :is_presented_by, :which_roles?) \n end", "def opportunities\n\t\t@active_nav = :opportunities\n\t\t@...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Connect a venue to the contact.
def connect(venue) ContactVenueRelationship.create(contact_id: id, venue_id: venue.id) end
[ "def connect(contact)\n ContactVenueRelationship.create(contact_id: contact.id,\n venue_id: id)\n end", "def add_venue\n end", "def create\n @venue = Venue.create(venue_params)\n \n redirect_to venue_url(@venue)\n end", "def play_in_venue(venue, date)\n con...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Unconnects the contact and a venue.
def unconnect relationship = ContactVenueRelationship.find_by(contact_id: id, venue_id: venue.id) relationship.destroy end
[ "def unconnect(contact)\n relationship = ContactVenueRelationship.find_by(venue_id: id,\n contact_id: contact.id)\n relationship.destroy\n end", "def unsubscribe!(contact)\n # try to find the contact in the case watcher list\n subscriber = Case_Watch...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The venues that are not connected to the contact.
def unconnected_venues unconnected = [] Venue.all.each do |venue| unconnected << venue if venues.exclude? venue end return unconnected end
[ "def get_nearby_venues\n Venue.where([\"neighbourhood_id = ? and id <> ?\", self.neighbourhood_id, self.id])\n end", "def is_not_at_facility\n Venue.all - self.venues\n end", "def used_venues\n venues.joins(performances: :contest_category)\n .where(\"performances.stage_time IS NOT NULL AND c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initialize the EC2 Client object
def initialize(aws_region:) @ec2_client ||= Aws::EC2::Client.new(region: aws_region) end
[ "def client\n @client ||= EC2::Client.new(region: region)\n rescue Errors::ServiceError\n raise\n rescue\n raise Errors::EnvironmentError, 'Unable to initialize EC2 client'\n end", "def client\n @client ||= Aws::EC2::Client.new(\n region: ENV['AWS_REGION'],\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
fixed argument lists are represented as :array nodes, e.g. [:array, [argnode1, argnode2, ...]]
def process_args(args_node) return [] unless args_node if args_node.first == :array args_node.last.map { |node| to_sexp(node) } else raise "variable arguments not allowed" end end
[ "def aryfy(arg)\n ast AST::ASTArray, :children => [arg]\n end", "def convert_args_node(node)\n if node.kind_of?(String) || node.kind_of?(Symbol) || node.kind_of?(Numeric) || \n node.kind_of?(TrueClass) || node.kind_of?(FalseClass) || node.kind_of?(NilClass)\n node\n elsif node.instance_of?(Ar...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Internal: Receives a collection of inputs and interpolates the values to fit the end year of the new scenario. For example, if the start year is 2020 and the source scenario is 2050, and an input starts and 0 and the source value is 100, and the new scenario is based in 2030, the input value will be 50. Returns the int...
def interpolate_input_collection(collection) num_years = @scenario.end_year - @year total_years = @scenario.end_year - @scenario.start_year collection.each_with_object(collection.class.new) do |(key, value), interp| if (input = Input.get(key)) interp[key] = interpolate_input(input, value, tot...
[ "def interpolate_input(input, value, total_years, num_years)\n return value if input.enum?\n\n start = input.start_value_for(@scenario)\n change_per_year = (value - start) / total_years\n\n start + change_per_year * (total_years - num_years)\n end", "def interpolate_linearly\n interpolated_data = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Internal: Calculates the interpolated value of an input based on its current value in the original scenario. Returns a Numeric or String value for the new user values.
def interpolate_input(input, value, total_years, num_years) return value if input.enum? start = input.start_value_for(@scenario) change_per_year = (value - start) / total_years start + change_per_year * (total_years - num_years) end
[ "def numeric_transformation(value); end", "def USER_INPUT()\n input = scope.input_value\n\n if input.is_a?(Numeric)\n input / input_factor\n else\n input\n end\n end", "def interpolate(index, property, value, desired_property)\n property = property.intern\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
and a result which is also an array that is empty at first. The all_perms method is a recursive method. We make a list of the elements that are not present in the result. We add the first element from this to the result. All the permutations of the prefix in the result with the remaining elements are printed. The added...
def perms(arr) result = [] all_perms(arr, 0, result) end
[ "def permutations(array)\n return [array] if array.length <= 1\n\n # # pop off the last element\n # first = array.shift\n\n # make the recursive call\n\n # take the base and join with the rest\n perms = permutations(array[0...-1])\n # dla permutacji [1,2,3]\n\n # wiemy, że permutacja([2,3]) -> [[2,3],[3,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /image_position_templates GET /image_position_templates.json
def index @image_position_templates = ImagePositionTemplate.ordered respond_to do |format| format.html # index.html.erb format.json { render json: @image_position_templates } end end
[ "def show\n @image_position_template = ImagePositionTemplate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @image_position_template }\n end\n end", "def new\n @image_position_template = ImagePositionTemplate.new\n\n respond_to do ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /image_position_templates/1 GET /image_position_templates/1.json
def show @image_position_template = ImagePositionTemplate.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @image_position_template } end end
[ "def index\n @image_position_templates = ImagePositionTemplate.ordered\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @image_position_templates }\n end\n end", "def new\n @image_position_template = ImagePositionTemplate.new\n\n respond_to do |forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /image_position_templates/new GET /image_position_templates/new.json
def new @image_position_template = ImagePositionTemplate.new respond_to do |format| format.html # new.html.erb format.json { render json: @image_position_template } end end
[ "def create\n @image_position_template = ImagePositionTemplate.new(params[:image_position_template])\n\n respond_to do |format|\n if @image_position_template.save\n format.html { redirect_to @image_position_template, notice: 'Image position template was successfully created.' }\n format.jso...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /image_position_templates POST /image_position_templates.json
def create @image_position_template = ImagePositionTemplate.new(params[:image_position_template]) respond_to do |format| if @image_position_template.save format.html { redirect_to @image_position_template, notice: 'Image position template was successfully created.' } format.json { render ...
[ "def new\n @image_position_template = ImagePositionTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @image_position_template }\n end\n end", "def create\n @template_position = TemplatePosition.new(template_position_params)\n\n respond_to d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /image_position_templates/1 PUT /image_position_templates/1.json
def update @image_position_template = ImagePositionTemplate.find(params[:id]) respond_to do |format| if @image_position_template.update_attributes(params[:image_position_template]) format.html { redirect_to @image_position_template, notice: 'Image position template was successfully updated.' } ...
[ "def update_template_with_image_id(template)\n params = template.parameters\n params.each do |key, value|\n update_params_with_image_id(params, key, value)\n end\n end", "def create\n @image_position_template = ImagePositionTemplate.new(params[:image_position_templa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /image_position_templates/1 DELETE /image_position_templates/1.json
def destroy @image_position_template = ImagePositionTemplate.find(params[:id]) @image_position_template.destroy respond_to do |format| format.html { redirect_to image_position_templates_url } format.json { head :no_content } end end
[ "def destroy\n @image_template = ImageTemplate.find(params[:id])\n @image_template.destroy\n\n respond_to do |format|\n format.html { redirect_to image_templates_url }\n format.json { head :ok }\n end\n end", "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check to see if the virtual machine is in execute mode.
def execute_mode? @context[:mode] == :execute end
[ "def executable?\n respond_to?(:execute)\n end", "def executing?\n self.status == :executing\n end", "def running?\n ck_valid\n kvm = File.basename(SysConf.value_for :kvm_bin)\n cmdline =~ /#{kvm}/\n end", "def execute?\n self.action == :execute\n end", "def executable_real...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test_request comes mostly from the guts of route! in Sinatra::Base
def test_request(method, path, params={}) @params = indifferent_params(params) @request = Sinatra::Request.new(env) @request.path_info = path # sinatra 1.3.3 @__protected_ivars = instance_variables + ["@__protected_ivars"] # routes are stored by uppercase method, but I wanted the test i...
[ "def setup\n @requester = Rack::MockRequest.new(SampleApp)\n end", "def _request(verb, uri, params={}, env={}, &block)\n send(\"rack_test_#{verb}\", uri, params, env)\n #require 'pry'\n #if uri == '/research'\n # binding.pry\n #end\n self.class.metadata[:request] = \...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
gets called from the form to enqueue a new job
def create arg = params[:email] counter = Job.enqueue(arg) render :status => :accepted, :json => { jobId: counter } end
[ "def queue_job; end", "def enqueue\n # We need to save before passing to perform_later b/c perform_later will need our ID.\n # For this reason, the job_id col can't have a null constraint.\n save! unless persisted?\n job = job_class.constantize.perform_later(self, **job_params)\n update!(job_id: jo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the body as String.
def to_s @body.to_s end
[ "def body_as_string\n end", "def request_body_as_string\n @request_body_as_string ||=\n begin\n request.body.rewind\n request.body.read\n end\n end", "def getBody\n @body\n end", "def body_for_stomp\n\n case \n when @is_json\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Detect and geocode any location information present in the report text
def detect_location if self.text LOCATION_PATTERNS.find { |p| self.text[p] } self.location = Location.geocode($1) if $1 self.zip = location.postal_code if !self.zip && (self.location && location.postal_code) end if !self.location && self.zip self.location = Location.geocode(self.zip)...
[ "def detect_location\n if self.text\n LOCATION_PATTERNS.find { |p| self.text[p] }\n self.location = Location.geocode($1) if $1\n self.zip = location.postal_code if self.location && location.postal_code\n end\n self.location = self.reporter.location if !self.location && self.reporter && self....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
append tag_string to report text if supplied (iphone, android)
def append_tags self.text += (" "+self.tag_string) if !self.tag_string.blank? true end
[ "def build_text_notification_message(reason, taglist)\r\n term = \"\\r\\n\"\r\n strNotification = \"\"\r\n strNotification += \"#Thinkify RFID Reader Auto Notification Message\" + term \r\n strNotification += \"#Readername: #{@config[:readername]}\" + term \r\n strNotification += \"#ReaderType: Think...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create an integration for the specified app.
def create_integration(app_id, integration_create_body, opts = {}) data, _status_code, _headers = create_integration_with_http_info(app_id, integration_create_body, opts) return data end
[ "def create_integration_with_http_info(app_id, integration_create_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: IntegrationApi.create_integration ...\"\n end\n # verify the required parameter 'app_id' is set\n if @api_client.config.cli...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create an integration for the specified app.
def create_integration_with_http_info(app_id, integration_create_body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: IntegrationApi.create_integration ..." end # verify the required parameter 'app_id' is set if @api_client.config.client_side_val...
[ "def create_integration(app_id, integration_create_body, opts = {})\n data, _status_code, _headers = create_integration_with_http_info(app_id, integration_create_body, opts)\n return data\n end", "def create_app\n post_app('name' => app_name)\n end", "def create(app_id_or_app_name, body = {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the specified integration.
def get_integration(app_id, integration_id, opts = {}) data, _status_code, _headers = get_integration_with_http_info(app_id, integration_id, opts) return data end
[ "def integration\n @integration\n end", "def [](integration_name, key = :default)\n integration = fetch_integration(integration_name)\n integration.resolve(key) unless integration.nil?\n end", "def [](integration_name, key = :default)\n integration = f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List integrations for the specified app.
def list_integrations(app_id, opts = {}) data, _status_code, _headers = list_integrations_with_http_info(app_id, opts) return data end
[ "def load_app_integrations\n app_tags = @artifact.try(:software_list) || []\n app_tags.push(params[:apps]) if params[:apps].present?\n\n @app_integrations = App.tagged_with(app_tags, any: true).where(has_integration: true)\n end", "def list_integrations_with_http_info(app_id, opts = {})\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List integrations for the specified app.
def list_integrations_with_http_info(app_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: IntegrationApi.list_integrations ..." end # verify the required parameter 'app_id' is set if @api_client.config.client_side_validation && app_id.nil? ...
[ "def list_integrations(app_id, opts = {})\n data, _status_code, _headers = list_integrations_with_http_info(app_id, opts)\n return data\n end", "def load_app_integrations\n app_tags = @artifact.try(:software_list) || []\n app_tags.push(params[:apps]) if params[:apps].present?\n\n @app_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get History Returns the transaction history for an address or addresses.
def get_history(coin_type, addresses, opts = {}) data, _status_code, _headers = get_history_with_http_info(coin_type, addresses, opts) data end
[ "def get_history(coin, addresses, opts = {})\n data, _status_code, _headers = get_history_with_http_info(coin, addresses, opts)\n return data\n end", "def account_history\n get('account/history')\n end", "def history\n\t\th = \"Transaction History\\\\n\"\n\t\t@transactions.each do |t|\n\t\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns USVolume object with size equal to the number in cups.
def cups Measurements::USVolume.new(self, :cup) end
[ "def in_cups\n @size / 48\n end", "def volume_size\n # If not user-specified, I'm using a fudge factor of 1.5 on the volume size -- arbitrarily chosen\n @volume_size || (`du -x #{volume_to_bundle}`.split(/\\n/)[-1].split[0].to_f * 1.5 / 1024).ceil\n end", "def size\n sku.size * amount\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns USVolume object with size equal to the number in pints.
def pints Measurements::USVolume.new(self, :pint) end
[ "def volume_size\n # If not user-specified, I'm using a fudge factor of 1.5 on the volume size -- arbitrarily chosen\n @volume_size || (`du -x #{volume_to_bundle}`.split(/\\n/)[-1].split[0].to_f * 1.5 / 1024).ceil\n end", "def in_pints\n @size / 96\n end", "def bid_volume\n @bids.map { |x|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns USVolume object with size equal to the number in quarts.
def quarts Measurements::USVolume.new(self, :quart) end
[ "def in_quarts\n @size / 192\n end", "def volume_size\n # If not user-specified, I'm using a fudge factor of 1.5 on the volume size -- arbitrarily chosen\n @volume_size || (`du -x #{volume_to_bundle}`.split(/\\n/)[-1].split[0].to_f * 1.5 / 1024).ceil\n end", "def size\n sku.size * amount\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns USVolume object with size equal to the number in gallons.
def gallons Measurements::USVolume.new(self, :gallon) end
[ "def preboil_volume_gallons\n boil_off_gallons + @batch_size_gallons\n end", "def volume_size\n # If not user-specified, I'm using a fudge factor of 1.5 on the volume size -- arbitrarily chosen\n @volume_size || (`du -x #{volume_to_bundle}`.split(/\\n/)[-1].split[0].to_f * 1.5 / 1024).ceil\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Purchase the article, and redirect to it
def purchase load_and_verify_payment_method(params) redirect_to new_article_order_path(@article, payment_method_params) and return unless @payment_method @order = current_user.orders.create :article=>@article @transaction = Samurai::Processor.the_processor.purchase( @payment_method.token, ...
[ "def purchase\r\n redirect_to \"http://www.1shoppingcart.com/app/javanof.asp?MerchantID=31593&ProductID=3257357\"\r\n end", "def purchase\n load_and_verify_payment_method(params)\n redirect_to transparent_redirect_payment_form_path(payment_method_params) and return unless @payment_method\n\n @transac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /billing_infos/1 GET /billing_infos/1.json
def show @billing_info = BillingInfo.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @billing_info } end end
[ "def index\n @billing_infos = BillingInfo.all\n end", "def billing(info=nil)\n\t\tresponse = @client.get(\n\t\t\t@description[\"resources\"][\"billing\"][\"url\"],\n\t\t\t:headers => {\n\t\t\t\t\"Accept\" => \"application/json\"\n\t\t\t})\n\t\traise \"Error getting billing plans: #{response.status}\" if respo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /billing_infos/new GET /billing_infos/new.json
def new @billing_info = BillingInfo.new respond_to do |format| format.html # new.html.erb format.json { render json: @billing_info } end end
[ "def create\n @billing_info = BillingInfo.new(params[:billing_info])\n\n respond_to do |format|\n if @billing_info.save\n format.html { redirect_to @billing_info, notice: 'Billing info was successfully created.' }\n format.json { render json: @billing_info, status: :created, location: @bill...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /billing_infos POST /billing_infos.json
def create @billing_info = BillingInfo.new(params[:billing_info]) respond_to do |format| if @billing_info.save format.html { redirect_to @billing_info, notice: 'Billing info was successfully created.' } format.json { render json: @billing_info, status: :created, location: @billing_info } ...
[ "def create\n @billing_info = BillingInfo.new(billing_info_params)\n @payment_detail = PaymentDetail.find_by(id: session[:current_payment_detail])\n \n respond_to do |format|\n if @billing_info.save\n @payment_detail.billing_info = @billing_info\n @payment_detail.save\n \n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /billing_infos/1 PUT /billing_infos/1.json
def update @billing_info = BillingInfo.find(params[:id]) respond_to do |format| if @billing_info.update_attributes(params[:billing_info]) format.html { redirect_to @billing_info, notice: 'Billing info was successfully updated.' } format.json { head :no_content } else format....
[ "def update\n respond_to do |format|\n if @billing_info.update(billing_info_params)\n format.html { redirect_to @billing_info, notice: 'Billing info was successfully updated.' }\n format.json { render :show, status: :ok, location: @billing_info }\n else\n format.html { render :edit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /billing_infos/1 DELETE /billing_infos/1.json
def destroy @billing_info = BillingInfo.find(params[:id]) @billing_info.destroy respond_to do |format| format.html { redirect_to billing_infos_url } format.json { head :no_content } end end
[ "def destroy\n @billing_info.destroy\n respond_to do |format|\n format.html { redirect_to billing_infos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @billing_info.destroy\n respond_to do |format|\n format.html { redirect_to billing_infos_url, notice: 'Billin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Provides a route to redirect after order completion
def completion_route order_path(@order, :checkout_complete => true) end
[ "def redirect(&block)\n builder = RouteBuilder.new(context())\n builder.instance_eval(&block)\n return builder.product()\n end", "def perform_redirect\n redirect_params = {\n community: @current_community,\n plan:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send +message+ back to the HipChat server. If +to+ == +:room+, replies to the room. If +to+ == nil, responds in the manner the original message was sent. Otherwise, PMs the message to +to+.
def reply(message, to = nil) if to == :room reply_to.reply(message, nil) else reply_to.reply(message, to || private_sender) end end
[ "def reply(message, to = nil)\n if to == :room\n connection.reply(message, nil)\n else\n connection.reply(message, to || private_sender)\n end\n end", "def reply(message)\n bot.say @room, message if @room\n end", "def broadcast_to(room, msg)\n\t\t\tm = GreyGoo::Message.new({ from: se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
An ordered list of all words in the message with any reference to the bot's nick stripped out. If +command+ is passed in, it is also stripped out. This is useful to separate the 'parameters' from the 'commands' in a message.
def words(message, command = nil) reply = at_nick.downcase command = command.downcase if command message.split.reject {|word| word.downcase == reply || word.downcase == command } end
[ "def words(message, command = nil)\n reply = at_nick\n command = command.downcase if command\n message.split.reject {|word| word.downcase == reply || word.downcase == command }\n end", "def args_without_command\n @args.dup.join(' ').sub(command_name_from_args, '').split\n end", "def words\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes the first word in message if it is a reference to the bot's nick
def without_nick(message) possible_nick, command = message.split(' ', 2) if possible_nick.casecmp(at_nick) == 0 command else message end end
[ "def without_nick(message)\n possible_nick, command = message.split(' ', 2)\n if possible_nick == at_nick\n command\n else\n message\n end\n end", "def remove_prefix(msg)\n msg.sub(PREFIX_REGEX, \"|\")\n end", "def strip_prefix(body)\n return unless p=body.to_s.strip.match(@confi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find and run all the actions associated with matchers that match +message+.
def find_match(message) matchers.each do |regexp, options, action, description| if options[:sent_to_me] && !sent_to_me?(message) next end if match_data = without_nick(message).match(regexp) # Return true explicitly if this matcher explicitly returned true break true if ins...
[ "def match_message(message)\n @routes\n .reduce(Set.new) do |memo, (matcher, handlers)|\n memo = memo.merge(handlers) if matcher.matches_message?(message)\n memo\n end\n end", "def route(message)\n message.action.perform\n end", "def _invoke_li...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /disatance_and_times GET /disatance_and_times.json
def index @disatance_and_times = DisatanceAndTime.all end
[ "def index\n @timecards = TimeCard.all\n render :json => @timecards.to_json(:include => :time_entry), status: :ok\n end", "def index\n @dis_durations = DisDuration.all\n end", "def index\n @discharges = Discharge.all\n render json: @discharges\n end", "def index\n @time_reasons = Time::Re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /disatance_and_times POST /disatance_and_times.json
def create @disatance_and_time = DisatanceAndTime.new(disatance_and_time_params) respond_to do |format| if @disatance_and_time.save format.html { redirect_to @disatance_and_time, notice: 'Disatance and time was successfully created.' } format.json { render :show, status: :created, locatio...
[ "def index\n @disatance_and_times = DisatanceAndTime.all\n end", "def destroy\n @disatance_and_time.destroy\n respond_to do |format|\n format.html { redirect_to disatance_and_times_url, notice: 'Disatance and time was successfully destroyed.' }\n format.json { head :no_content }\n end\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /disatance_and_times/1 PATCH/PUT /disatance_and_times/1.json
def update respond_to do |format| if @disatance_and_time.update(disatance_and_time_params) format.html { redirect_to @disatance_and_time, notice: 'Disatance and time was successfully updated.' } format.json { render :show, status: :ok, location: @disatance_and_time } else format....
[ "def update\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n if @time_off_request.update_attributes(params[:time_off_request])\n format.html { redirect_to time_off_requests_url, notice: 'Time off request was successfully updated.' }\n format.json { head :ok ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /disatance_and_times/1 DELETE /disatance_and_times/1.json
def destroy @disatance_and_time.destroy respond_to do |format| format.html { redirect_to disatance_and_times_url, notice: 'Disatance and time was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @food_time = FoodTime.find(params[:id])\n @food_time.destroy\n\n respond_to do |format|\n format.html { redirect_to food_times_url }\n format.json { head :ok }\n end\n end", "def destroy\n @nursing_time = NursingTime.find(params[:id])\n @nursing_time.destroy\n\n resp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build an order by expression for the given db relation based on the criteria
def order(criteria, relation) return relation unless criteria.order? order_str = convert_order_exprs(criteria.order_by) relation.order(order_str) end
[ "def ordered_expression_sql(oe)\n \"#{literal(oe.expression)} #{oe.descending ? 'DESC' : 'ASC'}\"\n end", "def ordered_expression_sql_append(sql, oe)\n literal_append(sql, oe.expression)\n sql << (oe.descending ? ' DESC' : ' ASC')\n case oe.nulls\n when :first\n sql << \" NULLS ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reads from the socket until an EOT is found Extra characters may be read from the socket, but they are kept in a buffer to be used with the next call to read_until_eot(). If there is a gap in transmission longer than the timeout, nil will be returned. The total time spent waiting for data may be longer than the timeout...
def read_until_eot(timeout) #Read until eot or timeout. eot_index = @buf.index("\004") received = nil gotMessage = nil #Do we already have a message ready? unless eot_index #Read until EOT or timeout while gotMessage = IO.select([@socket], nil, nil, timeout) do ...
[ "def timed_read( length=65535, timeout=def_read_timeout )\n\t\tresult = ''\n\n\t\tbegin\n\t\t\tTimeout.timeout( timeout ) {\n\t\t\t\twhile( true )\n\t\t\t\t\tif( @datagrams.empty? )\n\t\t\t\t\t\tRex::ThreadSafe.sleep( 0.2 )\n\t\t\t\t\t\tnext\n\t\t\t\t\tend\n\t\t\t\t\tresult = self.read( length )\n\t\t\t\t\tbreak\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /test_suites/1 GET /test_suites/1.json
def show @test_suite = TestSuite.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @test_suite } end end
[ "def index\n @testsuites = Testsuite.all\n end", "def suites\n @api.get_suites( :project_id => @id )\n end", "def suites(project_id)\n get(\"get_suites/#{project_id}\")\n end", "def show\n render :json => Project.find(params[:project_id]).test_sets.find(params[:id])\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /test_suites/new GET /test_suites/new.json
def new @test_suite = TestSuite.new respond_to do |format| format.html # new.html.erb format.json { render json: @test_suite } end end
[ "def new\n @old_test_case = OldTestCase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @old_test_case }\n end\n end", "def new\n @test_case = TestCase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render js...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /test_suites POST /test_suites.json
def create @test_suite = TestSuite.new(params[:test_suite]) respond_to do |format| if @test_suite.save format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' } format.json { render json: @test_suite, status: :created, location: @test_suite } else ...
[ "def create\n @test_suite = TestSuite.new(test_suite_params)\n\n respond_to do |format|\n if @test_suite.save\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully created.' }\n format.json { render :show, status: :created, location: @test_suite }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /test_suites/1 PUT /test_suites/1.json
def update @test_suite = TestSuite.find(params[:id]) respond_to do |format| if @test_suite.update_attributes(params[:test_suite]) format.html { redirect_to @test_suite, notice: 'Test suite was successfully updated.' } format.json { head :no_content } else format.html { rende...
[ "def update\n respond_to do |format|\n if @test_suite.update(test_suite_params)\n format.html { redirect_to @test_suite, notice: 'Test suite was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_suite }\n else\n format.html { render :edit }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /test_suites/1 DELETE /test_suites/1.json
def destroy @test_suite = TestSuite.find(params[:id]) @test_suite.destroy respond_to do |format| format.html { redirect_to test_suites_url } format.json { head :no_content } end end
[ "def destroy\n @testsuite.destroy\n respond_to do |format|\n format.html { redirect_to testsuites_url, notice: 'Testsuite was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_suite.destroy\n respond_to do |format|\n format.html { redir...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns an array of moved packages
def moved_packages raise RuntimeError, "#{self.class} needs to overwrite moved_packages" end
[ "def move_packages\n begin\n files_to_copy = Dir.glob(File.join(@rpmdir, 'noarch', \"#{@package_name}-*-#{@plugin.metadata[:version]}-#{@plugin.revision}.noarch.rpm\"))\n files_to_copy << File.join(@srpmdir, \"#{@package_name}-#{@plugin.metadata[:version]}-#{@plugin.revision}.src.rpm\")\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns true if pkgname is an autoproj meta package
def is_metapackage?(package_name) raise RuntimeError, "#{self.class} needs to overwrite is_metapackage?" end
[ "def custom_package?\n packaging_type == :your\n end", "def has_package?(name)\n packages.has_key?(name) || os_package_resolver.include?(name)\n end", "def has_package?(name)\n packages.has_key?(name)\n end", "def pkgname?(s)\n s.is_a?(String) and s =~ /^#{PKGNAM...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns a PackageInfo from an autobuild package
def pkginfo_from_pkg(package) raise RuntimeError, "#{self.class} needs to overwrite pkginfo_from_pkg" end
[ "def build_package package\n pack = get_package package\n pack.info = @info\n return pack.build\n end", "def find_autobuild_package(name)\n find_package_definition(name)&.autobuild\n end", "def extract_info(package)\n require 'rexml/document'\n build_path(\"expand\").ta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sort by package set order can be used with any packages array of objects providing a name(), that is, works with both autobuild packages and PackageInfos returns a sorted array populated from elements of packages
def sort_by_package_sets(packages, pkg_set_order) raise RuntimeError, "#{self.class} needs to overwrite sort_by_package_sets" end
[ "def sort_by_package_sets(packages, pkg_set_order)\n priority_lists = Array.new\n (0..pkg_set_order.size).each do |i|\n priority_lists << Array.new\n end\n\n packages.each do |package|\n pkg_name = package\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send accumulated events into Sensu's socket, unless environment variable PROM_DEBUG is set.
def dispatch(event) if ENV.key?('PROM_DEBUG') log.debug("PROM_DEBUG set, not dispatching event to Sensu: #{event}") return end # :nocov: begin s = TCPSocket.open(@sensu_address, @sensu_port) s.puts(JSON.generate(event)) ...
[ "def drain()\n if @socket.ready?\n $stderr.puts \"Draining extra data found in socket => [#{@socket.gets.chomp}]\"\n end\n end", "def debug_on\n @debug_socket = true\n end", "def run\n\t\tself.setup_event_socket\n\t\tsuper\n\tend", "def run()\n # let's install signal handlers\n S...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read Sensu address and port from environment.
def read_env_address_and_port @sensu_address = ENV['SENSU_SOCKET_ADDRESS'] \ if ENV.key?('SENSU_SOCKET_ADDRESS') @sensu_port = ENV['SENSU_SOCKET_PORT'].to_i \ if ENV.key?('SENSU_SOCKET_PORT') end
[ "def myservices_environment_details_host\n ENV['ENV_DETAILS'].nil? ? 'esu2v871:9080' : ENV['ENV_DETAILS']\n end", "def read_env_from_environment\n opts_hash = {\n host: ENV[ENV_BOSH_HOST],\n port: ENV[ENV_BOSH_PORT],\n username: ENV[ENV_BOSH_USERNAME],\n password: ENV[ENV_BOSH_PASSWORD]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /globus_tokens or /globus_tokens.json
def index @globus_tokens = GlobusToken.all end
[ "def index \n @tokens = @user.tokens\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tokens }\n end\n end", "def fetch_some_tokens\n # GET /<tokens_list_url>?page=@page&per_page=@per_page\n @page += 1\n response = @resources['tokens_list'].get ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /globus_tokens or /globus_tokens.json
def create @globus_token = GlobusToken.new(globus_token_params) respond_to do |format| if @globus_token.save format.html { redirect_to globus_token_url(@globus_token), notice: "Globus token was successfully created." } format.json { render :show, status: :created, location: @globus_token ...
[ "def get_tokens(params)\n check_params params\n\n params = params.load_params\n\n RequestBuilder.new(@user_key, @alternate_url + TOKENS_ENDPOINT,\n @http_client, BINDING_VERSION, params, @url_parameters)\n .send_post_request\n end", "def add_token\n #if params[:t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /globus_tokens/1 or /globus_tokens/1.json
def update respond_to do |format| if @globus_token.update(globus_token_params) format.html { redirect_to globus_token_url(@globus_token), notice: "Globus token was successfully updated." } format.json { render :show, status: :ok, location: @globus_token } else format.html { rende...
[ "def update\n @token = Token.find_by_name(params[:id]) || Token.find(params[:id])\n\n respond_to do |format|\n if @token.update_attributes(params[:token])\n format.html { redirect_to @token, notice: 'Token was successfully updated.' }\n format.json { head :no_content }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /globus_tokens/1 or /globus_tokens/1.json
def destroy @globus_token.destroy respond_to do |format| format.html { redirect_to globus_tokens_url, notice: "Globus token was successfully destroyed." } format.json { head :no_content } end end
[ "def destroy\n @token = @user.tokens.find(params[:id])\n @user.tokens.delete(@token)\n @user.save\n\n respond_to do |format|\n format.html { redirect_to user_tokens_url }\n format.json { head :no_content }\n end\n end", "def remove_token\n res = {\n success: false,\n type: '...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a date within the specified Range. The Range can be Date or String objects. Example: min = Date.parse('19661115') max = Date.parse('19900101') Random.date(min..max) => a Date between 11/15/1996 and 1/1/1990 Random.date('19661115'..'19900101') => a Date between 11/15/1996 and 1/1/1990
def date_between(range) min_date = range.min.is_a?(Date) ? range.min : Date.parse(range.min) max_date = range.max.is_a?(Date) ? range.max : Date.parse(range.max) diff = (max_date - min_date).to_i min_date + rand(diff) end
[ "def random_date(min_days_from_now, max_days_from_now)\n rng = Random.new\n (DateTime.now + rng.rand(min_days_from_now..max_days_from_now)).to_date\nend", "def parse_date_range(start_date, end_date)\n raise InvalidParameterError, 'start_date is required' if start_date.blank?\n raise InvalidParameterEr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create time stamped spreadsheet using base name connect to excel and open base workbook create instance of excel (xl) returns a nested array containing spreadsheet and script parameters
def xls_timestamp(s_s) new_ss = (s_s.chomp(".xls")<<'_'<<Time.now.to_a.reverse[5..9].to_s<<(".xls")) new_ss1 = new_ss.sub('driver','result') xl = new_xls(s_s,1) #open base driver ss with new excel session ws = xl[2] # worksheet param = Array.new # contains no elements. just used as a place holder here ...
[ "def xls_timestamp(g,s_s,type=nil,rs_name=nil)\r\n new_ss = (s_s.chomp(\".xls\")<<'_'<<g.t_stamp<<(\".xls\"))\r\n new_ss1 = new_ss.sub(/Tools\\\\.+\\\\/,\"result\\\\#{rs_name}\\\\\")\r\n if (type == 'ind') # driver was launched independently\r\n xl = g.new_xls(s_s,1) #open base driver ss with new excel sessio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates the line starting with coordinate [x,y]. It calls the block to find the next position in the line. It can be used to generate snake lines if necessary.
def get_line_coords(x, y) line = [[x,y]] loop do next_x, next_y = yield x, y @box[next_x] && @box[next_x][next_y] ? line << [next_x, next_y] : break x, y = next_x, next_y end line end
[ "def points_on_line start_x, start_y, rise, run, distance\n distance.times.map do |i| # perform an action\n [start_x + run * i, start_y + rise * i] # definition of point\n end\n end", "def line(x0, y0, x1, y1)\n move_to(x0, y0).line_to(x1, y1)\n end", "def drawline(coord1, coord2, colour)\n c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Replaces ? and with \w? and \w in each word so that it could be used as the regex to support wildcard letter matching.
def regexize_words(words) words.each {|word|word.gsub!(/(\?|\*)/, '\w\1')} end
[ "def replace_vowels_with_question_mark(word)\n 'aeiou'.split('').each do |l|\n word = word.gsub(l, '?')\n end\n\n word\nend", "def replace_keywords_by_patterns\n pattern.gsub(KEYWORD_IDENTIFIER) { |match|\n name = match.sub(KEYWORD_IDENTIFIER, '\\1')\n field = source.find_custom_field_id_by_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the current indentation and folding state.
def get_state() [ indent_depth, folding_depth ] end
[ "def indent_level\n @indent\n end", "def indentation; end", "def relative_indent; end", "def indentation\n Psych::LibPsych.get_indentation_level(@emitter_context.emitter)\n end", "def indentation\n s = \"\"\n lv = method_stack.empty? ? 0 : method_stack.size-1 \n lv.times { s <...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adjust the indentation depth. Returns the indent depth BEFORE it was adjusted.
def adj_indent(adjust = 1) old, self.indent_depth = indent_depth, (indent_depth+adjust) self.indent_str = (indenting == true) ? (TAB * indent_depth) : EMPTY old end
[ "def indentation(depth)\n \" \" * 4 * depth\nend", "def increment_indent_level(increment = get_indent_increment)\n set_indent_level( get_indent_level + increment )\n end", "def update_depth\n @depth = 1\n end", "def set_fix_depth(depth)\n @fix_depth = depth\n left.set_fix_depth(depth+1) if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Open a folding section. Returns the folding depth BEFORE folding_open().
def folding_open() self.folding_depth += 1 fh.puts FOLDING_OPEN if folding and not disabled folding_depth - 1 end
[ "def get_state() [ indent_depth, folding_depth ] end", "def depth\n @cur_level - @base_level + 1\n end", "def open_sidebar(cfg, sect)\n puts \"open sidebar #{sect}\"\n visited(sect[:title])\n #sect_h = @sections[sect_s]\n #sect_cls = sect_h['class']\n #@toc.each { |k,v| v.send(k == se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
this should be used when checking access to multilpe objects it will call `read?` on each object of the array if the operation used a scope to find records from an association, then `authorized_via_parent` could be true, in which case, the loop would be skipped. TODO: think of a way to override the authorized_via_paren...
def read_all? return true if authorized_via_parent # This is expensive, so try to avoid it # TODO: look in to creating a cache for # these look ups that's invalidated upon # object save accessible = object.map { |ea| read?(ea) } accessible.all? end
[ "def can_read_parent?(resource)\n can?(:read, resource.decorate.parent&.object)\n end", "def authorize_edit_parent_rights!\n authorize! :edit, parent_id\n end", "def can_read?(obj)\n return true if self.is_admin?\n return true if self == obj.user\n entity = obj.is_a?(Comment) ? obj.enti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /rols/1 GET /rols/1.xml
def show @rol = Rol.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @rol } end end
[ "def show\n @rol = Rol.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @rol }\n end\n end", "def show\n @rol = Rol.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rol }\n end\n end", "def index\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /rols/new GET /rols/new.xml
def new @rol = Rol.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @rol } end end
[ "def create\n @rol = Rol.new(params[:rol])\n\n respond_to do |format|\n if @rol.save\n flash[:notice] = nil\n format.html { redirect_to(rols_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rol.err...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /rols POST /rols.xml
def create @rol = Rol.new(params[:rol]) respond_to do |format| if @rol.save format.html { redirect_to(@rol, :notice => 'Rol was successfully created.') } format.xml { render :xml => @rol, :status => :created, :location => @rol } else format.html { render :action => "new" } ...
[ "def create\n @rol = Rol.new(params[:rol])\n\n respond_to do |format|\n if @rol.save\n flash[:notice] = nil\n format.html { redirect_to(rols_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @rol.err...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /rols/1 PUT /rols/1.xml
def update @rol = Rol.find(params[:id]) respond_to do |format| if @rol.update_attributes(params[:rol]) format.html { redirect_to(@rol, :notice => 'Rol was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { r...
[ "def update\n @rol = Rol.find(params[:id])\n\n respond_to do |format|\n if @rol.update_attributes(params[:rol])\n flash[:notice] = nil\n format.html { redirect_to(rols_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /rols/1 DELETE /rols/1.xml
def destroy @rol = Rol.find(params[:id]) @rol.destroy respond_to do |format| format.html { redirect_to(rols_url) } format.xml { head :ok } end end
[ "def destroy\n @rol.destroy\n respond_to do |format|\n format.html { redirect_to rols_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @menus_rol = MenusRol.find(params[:id])\n @menus_rol.destroy\n\n respond_to do |format|\n format.html { redirect_to(menu_rol...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
compress a file and move it to the backup folder
def backup_file folder,file @manager ||= Conf::LocalFileManager.new newp = File.join(Conf::directories.backup,@curr_source.name.to_s,folder) file.zip! unless file.zip? @manager.move_files [file],newp end
[ "def compress(src_path, archive_path)\n src_dir = File.dirname( File.expand_path( src_path ) )\n src_file = File.basename( src_path )\n archive_path = File.expand_path( archive_path )\n dest_dir = File.dirname( archive_path )\n\n puts \"src_dir: #{src_dir}\"\n puts \"src_path: #{src_path}\"\n p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /entity/new GET /entity/new.json
def new @entity = @klass.new respond_to do |format| format.html # new.html.erb format.json { render json: @entity } end end
[ "def new\n @entity = Entity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end", "def new\n @entity = Entity.new\n\n render json: @entity\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This helper timestamps asset files (css, js etc). Typically used in 'skin' files to precalculate the actual path. TEMP version: just attaches the $build number. ++
def timestamp_asset(path) return "#{path}?t=#$app_build" end
[ "def add_time_stamp(path)\n logger.debug \"sprockets cache busting: #{File.basename path}\"\n lines = File.readlines path\n lines.slice!(0) if lines.first.match(/^#=Timestamp/)\n lines = [\"#=Timestamp #{Time.now}\\n\"] + lines\n File.open(path, \"w\") do |f|\n lines.each{|l| f.write l}\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
desc: gets the given number of mails from the given mailbox and return it to ajax call. output: js
def mails begin @imap = WmailImapUtils.current_imap if not @imap.blank? @mailbox = params['mailbox'] @min = params['min'].to_i @max = params['max'].to_i @total = params['total'].to_i @imap.select(@mailbox) @mails = @imap.fetch(...
[ "def get_read\n pagesize = Settings.pagesize # set number of messages to display at once. Could be user defined someday.\n @page = params[:page].to_i||0 \n @messages = Message.get_read_messages(current_user.id,pagesize,@page)\n count = Message.count_all_read_messages(current_user.id)\n @page += 1\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instantiates a new securityKubernetesPodEvidence and sets the default values.
def initialize() super @odata_type = "#microsoft.graph.security.kubernetesPodEvidence" end
[ "def initialize()\n super\n @odata_type = \"#microsoft.graph.security.kubernetesServiceAccountEvidence\"\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.security.kubernetesServiceEvidence\"\n end", "def initia...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the containers property value. The list of pod containers which are not init or ephemeral containers.
def containers=(value) @containers = value end
[ "def ephemeral_containers=(value)\n @ephemeral_containers = value\n end", "def containers= p\n self[:containers] = p ? p : nil\n end", "def init_containers=(value)\n @init_containers = value\n end", "def containers\n @containers ||= Docker::Contai...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the controller property value. The pod controller.
def controller return @controller end
[ "def controller=(value)\n @controller = value\n end", "def controller=(value)\n @property_flush[:controller] = value\n end", "def controller\n @controller ||= controller_name.constantize\n end", "def controller\n MSPhysics::Newton::Spring.get_controller(@address)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the controller property value. The pod controller.
def controller=(value) @controller = value end
[ "def controller=(value)\n @property_flush[:controller] = value\n end", "def controller=(value)\n MSPhysics::Newton::Spring.set_controller(@address, value)\n end", "def controller=(value)\n MSPhysics::Newton::Slider.set_controller(@address, value)\n end", "def controller=(value)\n MSPh...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the ephemeralContainers property value. The list of pod ephemeral containers.
def ephemeral_containers return @ephemeral_containers end
[ "def ephemeral_containers=(value)\n @ephemeral_containers = value\n end", "def get_list_container_instances_response\n\n # http://docs.aws.amazon.com/sdkforruby/api/Aws/ECS/Client.html#list_container_instances-instance_method\n instances = @ecs.list_container_instances({\n clu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the ephemeralContainers property value. The list of pod ephemeral containers.
def ephemeral_containers=(value) @ephemeral_containers = value end
[ "def ephemeral_containers\n return @ephemeral_containers\n end", "def containers=(value)\n @containers = value\n end", "def containers= p\n self[:containers] = p ? p : nil\n end", "def push_ephemerals(ephemeral_scopes)\n ephemeral_scopes.each { |ephem...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the initContainers property value. The list of pod init containers.
def init_containers return @init_containers end
[ "def get_containers\n init_folder unless @init # have I been initialized?\n return @containers \n end", "def init_containers=(value)\n @init_containers = value\n end", "def containers\n container_names = self.ls\n container_names.map do |container_name|\n LXC:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the initContainers property value. The list of pod init containers.
def init_containers=(value) @init_containers = value end
[ "def init_containers\n return @init_containers\n end", "def containers=(value)\n @containers = value\n end", "def get_containers\n init_folder unless @init # have I been initialized?\n return @containers \n end", "def ephemeral_containers=(val...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the labels property value. The pod labels.
def labels return @labels end
[ "def labels\n @labels ||= client.getLabelsById(record_id).collect {|label| label[\"name\"]}\n end", "def pod_labels\n kubernetes_release.pod_labels.merge(role: kubernetes_role.label_name, role_id: kubernetes_role.id.to_s)\n end", "def labels\n multi_value? ? label_ids.collect{|l_id| Label.fin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the labels property value. The pod labels.
def labels=(value) @labels = value end
[ "def labels=(value)\n removed_labels = labels - value\n added_labels = value - labels\n\n client.removeLabelByName(removed_labels.join(\" \"), record_id) unless removed_labels.empty?\n client.addLabelByName(added_labels.join(\" \"), record_id) unless added_labels.empty?\n\n @labels = value\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the namespace property value. The pod namespace.
def namespace return @namespace end
[ "def namespace\n @namespace ||= metadata.attributes['Namespace'].value\n end", "def namespace\n read_property 'RootNamespace'\n end", "def namespace\n unless @namespace\n available = available_namespaces\n @namespace = available[namespace_name] || available[XMLNS_PREFIX...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the namespace property value. The pod namespace.
def namespace=(value) @namespace = value end
[ "def namespace=(value)\n @namespace = value\n end", "def set_Namespace(value)\n set_input(\"Namespace\", value)\n end", "def namespace=(name)\n Namespace.validate_namespace_name(name)\n @namespace = name\n end", "def namespace=(namespace)\n namespaces[\"xm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the podIp property value. The pod IP.
def pod_ip return @pod_ip end
[ "def pod_ip=(value)\n @pod_ip = value\n end", "def ip_address\n return @ip_address\n end", "def ip\n @vps.ip \n end", "def public_ip\n get('tools/public_ip').body['ipv4'] || get('tools/public_ip').body['ipv6']\n end", "def pod\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the podIp property value. The pod IP.
def pod_ip=(value) @pod_ip = value end
[ "def ip=(value)\n @ip = value\n end", "def ip_address=(value)\n @ip_address = value\n end", "def set_ip_addr(ip_addr)\n @ip_addr = ip_addr\n end", "def pod=(value)\n @pod = value\n end", "def set_ip\n @ip = get_ip(request.remote_ip.to_s)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the serviceAccount property value. The pod service account.
def service_account return @service_account end
[ "def service_account=(value)\n @service_account = value\n end", "def service_principal\n return @service_principal\n end", "def service_principal_name\n return @service_principal_name\n end", "def service_principal_id\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the serviceAccount property value. The pod service account.
def service_account=(value) @service_account = value end
[ "def service=(value)\n @service = value\n end", "def service_principal=(value)\n @service_principal = value\n end", "def []=(key, service)\n set(key, service)\n end", "def set_mints_service_account_client\r\n # Initialize service account client\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /outlet_goods_receive_note_items GET /outlet_goods_receive_note_items.xml
def index @outlet_goods_receive_note_items = OutletGoodsReceiveNoteItem.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @outlet_goods_receive_note_items } end end
[ "def show\n @goods_receive_note = GoodsReceiveNote.find(params[:id])\n @items = @goods_receive_note.goods_receive_note_items\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @goods_receive_note }\n end\n end", "def index\n @outlet_goods_receive_notes ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /outlet_goods_receive_note_items/new GET /outlet_goods_receive_note_items/new.xml
def new @outlet_goods_receive_note_item = OutletGoodsReceiveNoteItem.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @outlet_goods_receive_note_item } end end
[ "def new\n @outlet_goods_receive_note = OutletGoodsReceiveNote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @outlet_goods_receive_note }\n end\n end", "def new\n items = (0...20).collect { ReceiptItem.new } \n @receipt = Receipt.new(:items =>...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /outlet_goods_receive_note_items POST /outlet_goods_receive_note_items.xml
def create @outlet_goods_receive_note_item = OutletGoodsReceiveNoteItem.new(params[:outlet_goods_receive_note_item]) respond_to do |format| if @outlet_goods_receive_note_item.save flash[:notice] = 'OutletGoodsReceiveNoteItem was successfully created.' format.html { redirect_to(@outlet_goo...
[ "def create\n @sale_note_item = Sale::Note::Item.new(sale_note_item_params)\n\n respond_to do |format|\n if @sale_note_item.save\n format.html { redirect_to @sale_note_item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @sale_note_item ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }