query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Returns a css class name for kind of file
def icon_css_class case file_mime_type when *ARCHIVE_FILE_TYPES then "archive" when *AUDIO_FILE_TYPES then "audio" when *IMAGE_FILE_TYPES then "image" when *VIDEO_FILE_TYPES then "video" when "application/x-shockwave-flash" ...
[ "def get_class_name\n \"#{ file_name }\".chop.capitalize\n end", "def icon_css_class\n case file_mime_type\n when \"application/pdf\"\n \"file-pdf\"\n when \"application/msword\"\n \"file-word\"\n when *TEXT_FILE_TYPES\n \"file-alt\"\n when *EXCEL_FILE_TYPES\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /references/new GET /references/new.json
def new @reference = @account.references.new end
[ "def new\n @reference = Reference.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reference }\n end\n end", "def new\n @refer = Refer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @refer }\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /internets GET /internets.json
def index @internets = Internet.all end
[ "def index\n @internet_types = InternetType.all\n end", "def index\n @networkings = Networking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @networkings }\n end\n end", "def test_get_site_list\r\n endpoint = \"/sites\"\r\n uri =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /internets POST /internets.json
def create @internet = Internet.new(internet_params) respond_to do |format| if @internet.save format.html { redirect_to @internet, notice: 'Internet was successfully created.' } format.json { render :show, status: :created, location: @internet } else format.html { render :ne...
[ "def create\n @internet = Internet.new(internet_params)\n\n respond_to do |format|\n if @internet.save\n InternetMailer.welcome_email(@internet).deliver_now\n InternetMailer.new_signup_email(@internet).deliver_now\n format.html { redirect_to thankyou_path from: 'internet' }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /internets/1 PATCH/PUT /internets/1.json
def update respond_to do |format| if @internet.update(internet_params) format.html { redirect_to @internet, notice: 'Internet was successfully updated.' } format.json { render :show, status: :ok, location: @internet } else format.html { render :edit } format.json { render...
[ "def patch *args\n make_request :patch, *args\n end", "def update\n @internet_address = InternetAddress.find(params[:id])\n\n respond_to do |format|\n if @internet_address.update_attributes(params[:internet_address])\n format.html { redirect_to @internet_address, :notice => 'Internet address...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /internets/1 DELETE /internets/1.json
def destroy @internet.destroy respond_to do |format| format.html { redirect_to internets_url, notice: 'Internet was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @access_internet.destroy\n respond_to do |format|\n format.html { redirect_to access_internets_url, notice: 'Access internet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @internet_address = InternetAddress.find(params[:id])\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /admin/restaurants POST /admin/restaurants.json
def create @admin_restaurant = Admin::Restaurant.new(admin_restaurant_params) respond_to do |format| if @admin_restaurant.save format.html { redirect_to @admin_restaurant, notice: 'Restaurant was successfully created.' } format.json { render :show, status: :created, location: @admin_resta...
[ "def create\n @restaurant = Restaurant.new(params[:restaurant])\n\n respond_to do |format|\n if @restaurant.save\n format.html { redirect_to admin_restaurant_path(@restaurant), notice: 'Restaurant was successfully created.' }\n format.json { render json: @restaurant, status: :created, locat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /admin/restaurants/1 PATCH/PUT /admin/restaurants/1.json
def update respond_to do |format| if @admin_restaurant.update(admin_restaurant_params) format.html { redirect_to @admin_restaurant, notice: 'Restaurant was successfully updated.' } format.json { render :show, status: :ok, location: @admin_restaurant } else format.html { render :e...
[ "def update\n json_response(@restaurant.update!(restaurant_params))\n end", "def update\n @restaurant_admin = Restaurant::Admin.find(params[:id])\n\n respond_to do |format|\n if @restaurant_admin.update_attributes(params[:restaurant_admin])\n format.html { redirect_to @restaurant_adm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /admin/restaurants/1 DELETE /admin/restaurants/1.json
def destroy @admin_restaurant.destroy respond_to do |format| format.html { redirect_to admin_restaurants_url, notice: 'Restaurant was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @restaurant_admin = Restaurant::Admin.find(params[:id])\n @restaurant_admin.destroy\n\n respond_to do |format|\n format.html { redirect_to restaurant_admins_url }\n format.json { head :ok }\n end\n end", "def destroy\n @restaurant_restaurant = Restaurant::Restaurant.find(p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /isps GET /isps.json
def index @isps = Isp.all end
[ "def index\n @isps_details = IspsDetail.all\n end", "def index\n @snps = Snp.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @snps }\n end\n end", "def show\n @sop = Sop.find(params[:id])\n\n respond_to do |format|\n format.html # sho...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /isps POST /isps.json
def create @isp = Isp.new(isp_params) respond_to do |format| if @isp.save format.html { redirect_to @isp, notice: 'Isp was successfully created.' } format.json { render :show, status: :created, location: @isp } else format.html { render :new } format.json { render js...
[ "def create\n @isps_detail = IspsDetail.new(isps_detail_params)\n\n respond_to do |format|\n if @isps_detail.save\n format.html { redirect_to @isps_detail, notice: 'Isps detail was successfully created.' }\n format.json { render :show, status: :created, location: @isps_detail }\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /isps/1 PATCH/PUT /isps/1.json
def update respond_to do |format| if @isp.update(isp_params) format.html { redirect_to @isp, notice: 'Isp was successfully updated.' } format.json { render :show, status: :ok, location: @isp } else format.html { render :edit } format.json { render json: @isp.errors, statu...
[ "def update\n @sop = Sop.find(params[:id])\n\n respond_to do |format|\n if @sop.update_attributes(params[:sop])\n format.html { redirect_to @sop, notice: 'Sop was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /isps/1 DELETE /isps/1.json
def destroy @isp.destroy respond_to do |format| format.html { redirect_to isps_url, notice: 'Isp was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @sop = Sop.find(params[:id])\n @sop.destroy\n\n respond_to do |format|\n format.html { redirect_to sops_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @isps_detail.destroy\n respond_to do |format|\n format.html { redirect_to isps_details_url,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get dispute details Returns all the details of a dispute using the dispute identifier.
def get_dispute_details(dispute_id, opts = {}) data, _status_code, _headers = get_dispute_details_with_http_info(dispute_id, opts) data end
[ "def details(disbursement_id)\n API::request(:get, \"disbursements/#{disbursement_id}\")\n end", "def list_dispute_evidence(dispute_id:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/disputes/{dispute_id}/evidence'\n _query_builder = APIHelp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get dispute details Returns all the details of a dispute using the dispute identifier.
def get_dispute_details_with_http_info(dispute_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DisputesApi.get_dispute_details ...' end # verify the required parameter 'dispute_id' is set if @api_client.config.client_side_validation && dispute...
[ "def get_dispute_details(dispute_id, opts = {})\n data, _status_code, _headers = get_dispute_details_with_http_info(dispute_id, opts)\n data\n end", "def details(disbursement_id)\n API::request(:get, \"disbursements/#{disbursement_id}\")\n end", "def list_dispute_evidence(dispute_id:)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get dispute evidence Retrieves a list of the evidence submitted in response to a specific dispute.
def get_dispute_evidence(dispute_id, opts = {}) data, _status_code, _headers = get_dispute_evidence_with_http_info(dispute_id, opts) data end
[ "def list_dispute_evidence(dispute_id:)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v2/disputes/{dispute_id}/evidence'\n _query_builder = APIHelper.append_url_with_template_parameters(\n _query_builder,\n 'dispute_id' => { 'value' => dispute_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get disputes Returns a list of all disputes against your business. The results will be returned in reverse chronological order, showing the last modified dispute (for example, where you've recently added a piece of evidence) first. You can use the optional parameters below to skip or limit results.
def get_disputes(opts = {}) data, _status_code, _headers = get_disputes_with_http_info(opts) data end
[ "def index\n @disputes = Dispute.all\n end", "def get_dispute(params = {})\n commit(EbayTrading::Requests::GetDispute, params)\n end", "def disputes\n @disputes ||= DisputesApi.new config\n end", "def get_dispute(params = {})\n commit(Ebay::Requests::GetDispute, params)\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Submit dispute evidence With this final request, you can submit the evidence that you have previously provided. Make sure you have provided all the relevant information before using this request. You will not be able to amend your evidence once you have submitted it.
def submit_dispute_evidence(dispute_id, opts = {}) submit_dispute_evidence_with_http_info(dispute_id, opts) nil end
[ "def submit_evidence(dispute_id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/disputes/{dispute_id}/submit-evidence',\n 'default')\n .template_param(new_parameter(dispute_id, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Login to Cherwell using the given credentials. Return true if login succeeded, or raise `LoginFailed` if login failed.
def login(username=nil, password=nil) creds = { :userId => username || @username, :password => password || @password, } begin response = @client.call(:login, :message => creds) rescue => e # This can happen if a bad URL is given raise Cherby::LoginFailed, ...
[ "def login\n username = find_username\n password = find_password\n\n Log.info(\"Logging in as #{username}... \", newline: false)\n\n conn = Faraday.new(url: \"https://redacted.ch/\")\n response = conn.post do |request|\n request.url \"login.php\"\n request.headers[\"User-Agent\"] = Redacted...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the Cherwell incident with the given public ID, and return an Incident object.
def incident(id) incident_xml = get_object_xml('Incident', id) error = self.last_error if error raise Cherby::NotFound.new("Cannot find Incident '#{id}': #{error}") else return Incident.new(incident_xml.to_s) end end
[ "def create_incident(data)\n incident = Incident.create(data)\n result = @client.create_business_object({\n :busObNameOrId => 'Incident',\n :creationXml => incident.to_xml\n })\n\n # Result contains the public ID of the new incident, or nil if the\n # incident-creation failed....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get the Cherwell task with the given public ID, and return a Task object.
def task(id) task_xml = get_object_xml('Task', id) error = self.last_error if error raise Cherby::NotFound.new("Cannot find Task '#{id}': #{error}") else return Task.new(task_xml.to_s) end end
[ "def get_task_by_id(id)\n require_relative 'task'\n Task.new(@api, @api.do_request(\"GET\", get_base_api_path() + \"/tasks/#{id}\"))\n end", "def getTaskByID(id) \n @Tasks.each do |task|\n return task if task.ID == id\n end\n return nil \n end", "def task(project_id, task_id)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get a BusinessObject instance
def get_business_object(object_type, id) xml = self.get_object_xml(object_type, id) return BusinessObject.new(xml) end
[ "def get_instance(payload)\n BusinessInstance.new(@version, payload, )\n end", "def get_instance(payload)\n BrandInstance.new(@version, payload, business_sid: @solution[:business_sid], )\n end", "def business(business_id)\n begin\n get_hash_by_object(@client.b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update a given Cherwell object by submitting its XML to the SOAP interface.
def update_object_xml(object_type, id, xml) @client.update_business_object_by_public_id({ :busObNameOrId => object_type, :busObPublicId => id, :updateXml => xml }) return last_error end
[ "def update\n @client.soap_client.call(:update, message: \"<Entity xsi:type=\\\"#{self.class.to_s.demodulize}\\\">#{fields_to_xml}</Entity>\")\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update(obj)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Save the given Cherwell incident
def save_incident(incident) update_object_xml('Incident', incident.id, incident.to_xml) end
[ "def store_incident_code(choice_event)\n log(\"#{choice_event.inspect}\")\n @incident ||= {}\n @incident['id'] = choice_event\n @incident['data'] = INCIDENTS[choice_event]\n log(\"##############################Incident is: #{@incident['id']}: #{@incident['data']}\") if DEBUG\n end", "def attach_to...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a new Cherwell incident with the given data. If creation succeeds, return the Incident instance; otherwise, return `nil`.
def create_incident(data) incident = Incident.create(data) result = @client.create_business_object({ :busObNameOrId => 'Incident', :creationXml => incident.to_xml }) # Result contains the public ID of the new incident, or nil if the # incident-creation failed. if !re...
[ "def incident(id)\n incident_xml = get_object_xml('Incident', id)\n error = self.last_error\n if error\n raise Cherby::NotFound.new(\"Cannot find Incident '#{id}': #{error}\")\n else\n return Incident.new(incident_xml.to_s)\n end\n end", "def incident_create(statuspage_id...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get a business object definition as a hash ex. get_object_definition('Incident') TODO: Use this as the basis for building templates?
def get_object_definition(object_type) result = {} definition = @client.get_business_object_definition(object_type) selector = 'BusinessObjectDef > FieldList > Field' Nokogiri::XML(definition).css(selector).map do |field| result[field['Name']] = field.css('Description').inner_html ...
[ "def find_object_definition_name\n if Rails.env.test?\n @object_definition_name = request.env[\"X_AP_OBJECT_DEFINITION_NAME\"]\n else\n @object_definition_name = request.env[\"HTTP_X_AP_OBJECT_DEFINITION_NAME\"]\n end\n end", "def object(conf); {\n :fields => conf.fields.map...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Redirects to a single constituency given an external source and an id that identifies this constituency in that source.
def lookup @constituency = @request.get.first redirect_to constituency_path(@constituency.graph_id) end
[ "def redirect\n id = params[\"id\"]\n content_type = request.headers.env[\"HTTP_ACCEPT\"]\n if content_type == APPLICATION_JSON\n url = individual_export_url(id: id, format: \"jsonld\")\n elsif content_type == TEXT_TURTLE\n url = individual_export_url(id: id, format: \"ttl\")\n elsif conten...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Post method which accepts form parameters from postcode lookup and redirects to constituency_path.
def postcode_lookup flash[:postcode] = params[:postcode] redirect_to constituency_path(params[:constituency_id]) end
[ "def redirect_submit\n # for amendments, provide the amendment reason and check if they want to request a repayment\n if @lbtt_return.amendment?\n redirect_to returns_lbtt_amendment_reason_path\n elsif @lbtt_return.any_lease_review?\n redirect_to returns_lbtt_repayment_claim_path\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Renders a constituency that has a constituency area object on map view given a constituency id. Will respond with GeoJSON data using the geosparqltogeojson gem if JSON is requested.
def map respond_to do |format| format.html do @constituency = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup').first @json_location = constituency_map_path(@constituency.graph_id, format: 'json') end format.json do @constituency = Parliament:...
[ "def show\n @constituency = Constituency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @constituency }\n end\n end", "def show\n @curriculum_area = CurriculumArea.find(params[:id])\n\n respond_to do |format|\n format.html # s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
UC2 Put information about Users and contracts with Vendors
def put_contract(q) $LOG.info('put_contract'); @USER=q["USER"]; @CONTRACT=q["CONTRACT"]; @CID=@USER["CID"]; @user=$CACHE.get("USER",@CID) $LOG.info(@USER.to_s()+' - '+@CONTRACT.to_s()); if (@user == nil) @user=$STORAGE.get("USER",@CID) if (@user == nil) $STORAGE.put("USER",@CID,@USER) @user=$STORAGE...
[ "def create\n @vendor = current_user.vendors.new(vendor_params)\n\n respond_to do |format|\n if @vendor.save\n format.html { redirect_to @vendor, notice: 'Vendor was successfully created.' }\n format.json { render :show, status: :created, location: @vendor }\n else\n format.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new SexpProcessor. Use super to invoke this initializer from SexpProcessor subclasses, then use the attributes above to customize the functionality of the SexpProcessor
def initialize @expected = Sexp # we do this on an instance basis so we can subclass it for # different processors. @processors = {} @context = [] public_methods.each do |name| if name.to_s.start_with? "process_" then @processors[name[8..-1].to_sym] = name.to_sym ...
[ "def initialize\n @expected = Sexp\n @processors = self.class.processors\n @context = []\n\n if @processors.empty?\n public_methods.each do |name|\n if name.to_s.start_with? \"process_\" then\n @processors[name[8..-1].to_sym] = name.to_sym\n end\n end\n end\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Default Sexp processor. Invokes process_ methods matching the Sexp type given. Performs additional checks as specified by the initializer.
def process(exp) return nil if exp.nil? result = nil type = exp.first raise "type should be a Symbol, not: #{exp.first.inspect}" unless Symbol === type in_context type do # now do a pass with the real processor (or generic) meth = @processors[type] if meth then if ...
[ "def process exp\n return nil if exp.nil?\n\n unless Sexp === exp then\n raise SexpTypeError, \"exp must be a Sexp, was #{exp.class}:#{exp.inspect}\"\n end\n\n if self.context.empty? then\n p :rewriting unless debug.empty?\n exp = self.rewrite(exp)\n p :done_rewriting unless debug.em...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A fairly generic processor for a dummy node. Dummy nodes are used when your processor is doing a complicated rewrite that replaces the current sexp with multiple sexps. Bogus Example: def process_something(exp) return s(:dummy, process(exp), s(:extra, 42)) end
def process_dummy(exp) result = @expected.new(:dummy) rescue @expected.new until exp.empty? do result << self.process(exp.shift) end result end
[ "def process_dummy exp\n result = @expected.new(:dummy) rescue @expected.new\n result << self.process(exp.shift) until exp.empty?\n result\n end", "def process exp\n return nil if exp.nil?\n\n unless Sexp === exp then\n raise SexpTypeError, \"exp must be a Sexp, was #{exp.class}:#{exp.inspect...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /bid_winners GET /bid_winners.json
def index @bid_winners = BidWinner.all end
[ "def index\n @winners = Winner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winners }\n end\n end", "def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end", "def all_booking_of_client\n\t\t@bo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /bid_winners POST /bid_winners.json
def create @bid_winner = BidWinner.new(bid_winner_params) respond_to do |format| if @bid_winner.save format.html { redirect_to @bid_winner, notice: 'Bid winner was successfully created.' } format.json { render :show, status: :created, location: @bid_winner } else format.html...
[ "def index\n @bid_winners = BidWinner.all\n end", "def create\n @bet_winner = BetWinner.new(bet_winner_params)\n\n respond_to do |format|\n if @bet_winner.save\n format.html { redirect_to @bet_winner, notice: 'Bet winner was successfully created.' }\n format.json { render :show, statu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /bid_winners/1 PATCH/PUT /bid_winners/1.json
def update respond_to do |format| if @bid_winner.update(bid_winner_params) format.html { redirect_to @bid_winner, notice: 'Bid winner was successfully updated.' } format.json { render :show, status: :ok, location: @bid_winner } else format.html { render :edit } format.jso...
[ "def update\n @bid = @swarm_request.bids.find(params[:id])\n\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n format.html { redirect_to(swarm_request_bid_url(:id => @bid.to_param, :swarm_request_id => @swarm_request.to_param), :notice => 'Bid was successfully updated.') }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /bid_winners/1 DELETE /bid_winners/1.json
def destroy @bid_winner.destroy respond_to do |format| format.html { redirect_to bid_winners_url, notice: 'Bid winner was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @bid = @swarm_request.bids.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to(swarm_request_bids_url(:swarm_request_id => @swarm_request.to_param)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @bid = Bid.find(params[:id])\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build an instance of TrunkInstance
def get_instance(payload) TrunkInstance.new(@version, payload) end
[ "def trunk code, options = {}\n TrunkCode.new code, options\n end", "def get_instance(payload)\n TranscriptInstance.new(@version, payload)\n end", "def get_instance(payload)\n RecordingInstance.new(@version, payload, trunk_sid: @solution[:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: Write a method that rotates an array by moving the first element to the end of the array. The original array should not be modified. Do not use the method Arrayrotate or Arrayrotate! for your implementation. E: rotate_array([7, 3, 5, 2, 9, 1]) == [...
def rotate_array(array_of_numbers) rotated_array = array_of_numbers.clone rotated_array << rotated_array.shift rotated_array end
[ "def rotate_array(input_array)\n return input_array if input_array.size <= 1\n new_array = []\n index_counter = 1\n loop do\n new_array << input_array[index_counter]\n index_counter += 1\n break if index_counter >= input_array.size\n end\n new_array << input_array[0]\n new_array\nend", "def rotate...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Problem 4: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: You have a bank of switches before you, numbered from 1 to n. Each switch is connected to exactly one light that is initially off. You walk down the row of switches and toggle every one of them. You go back to the beginning, and on this ...
def light_sequence(n) lights = {} n.times {|num| lights[num+1] = "on"} n.times do |num| lights.each do |light, status| if light % (num+1) == 0 lights[light] == "on" ? lights[light] = "off" : lights[light] = "on" end end end lights.select {|light, status| status == 'off'}.keys end
[ "def light_switches(n)\n light_hash = {}\n 1.upto(n) { |i| light_hash[i] = true }\n 2.upto(n) do |current_pass|\n light_hash.map do |light, state|\n light_hash[light] = !state if light % current_pass == 0\n end\n end\n lights_left_on = light_hash.select do |_, state|\n state\n end\n result = []...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /resource_types/new GET /resource_types/new.json
def new @resource_type = ResourceType.new respond_to do |format| format.html # new.html.erb format.json { render json: @resource_type } end end
[ "def new\n @resource_type = ResourceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_type }\n end\n end", "def create\n @resource_type = ResourceType.new(resource_type_params)\n\n respond_to do |format|\n if @resource_type.save\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /resource_types POST /resource_types.jsojoins(:field_type)n
def create @resource_type = ResourceType.new(params[:resource_type]) respond_to do |format| if @resource_type.save if params[:fields] params[:fields].each do |param| @field = Field.new( :name => param[:name], :field_type_id ...
[ "def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end", "def get_field_basic_types\n custom_form = CustomForms::CustomForm.find(params[:custom_form_id])\n @basic_field_types = custom_form.basic_field_types\n respond_to do |format|\n format.js\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /resource_types/1 DELETE /resource_types/1.json
def destroy begin if @resource_type.destroy respond_to do |format| format.html { redirect_to resource_types_url } format.json { head :no_content } end end rescue respond_to do |format| format.html { redirect_to "index", notice: "Resource_type cann'...
[ "def destroy\n @resource_type = ResourceType.find(params[:id])\n @resource_type.destroy\n\n respond_to do |format|\n format.html { redirect_to resource_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @resource_type = ResourceType.find(params[:id])\n @resource_type....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the comments on the given startup.
def startup_comments(id) get("1/startups/#{id}/comments") end
[ "def startup_comments_url\n 'https://api.angel.co/1/startups/%s/comments?access_token=%s' % [\n startup_id, access_token]\n end", "def description\n comment_sections.first\n end", "def get_comments\n self.comments = []\n IO.popen \"svn log r#{self.end_revision}\" do |f|\n revision = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns up to 50 startups at a time, given an Array of ids.
def get_startups(ids) params = { :ids => ids.join(',') } get("1/startups/batch", params) end
[ "def gather_user_profiles_from_ids(ids)\n ids = ids.map{|i| Integer(i) }\n profiles = []\n count = 0\n ids.each_slice(100) do |arr|\n count += 1\n puts \"On count: #{count}\"\n begin\n data = Twit.fetch_users_by_ids(arr)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Search for a startup given a URL slug. Responds like GET /startups/:id.
def startup_search(options={}) get("1/startups/search", options) end
[ "def startup_search(options={})\n get(\"1/startups/search\", options, :format => :json, :phoenix => true)\n end", "def find_by_slug(slug)\n find(Client.get(\"/families/#{slug}\")['id'])\n end", "def find_competition(slug)\n self.competitions.where(slug: slug.downcase).first\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
output to a file, and the streaming output handler
def log_and_stream(output) write_file output, @filename if @filename @block.call(output) end
[ "def output_handle\n if @options[:output].is_a? String\n File.open(@options[:output], 'w')\n else\n $stdout\n end\n end", "def output_file\n @output\n end", "def write_to_output filename, content = nil # :yields: file\n self.create_output_file(filename) do ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
pokemon_name = [] def pokemons_names(pokemon_name) Pokemon.each do |pokemon| pokemon_name << pokemon[:name] end pokemon_name end def pokemons_names pokemon_name = [] Pokemon.each do |pokemon| pokemon_name << pokemon[:name] end pokemon_name end
def pokemons_names Pokemon.collect do |pokemon| pokemon[:name] end end
[ "def pokemon_names(pokemon)\n pokemon.collect{|poke_profile|\n poke_profile[:name]\n }\nend", "def all_names(pokemon_array)\n pokemon_name = []\n pokemon_array.each do |monster_hash|\n pokemon_name << monster_hash[:name]\n end\n pokemon_name\nend", "def list_pokemon_names(list = @silph_dex)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update institution by id Handling errors from not finding the id and wrong data
def update institution = Institution.find(params[:id]) if institution.update(institution_params) render json: { status: '200', message: "Updated Institution with id #{params[:id]}", data: institution }, status: :ok else render json: { status: '422', error: 'Institution not up...
[ "def update\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n if @institution.update_attributes(params[:institution])\n format.html { redirect_to @institution, notice: 'Institution was successfully updated.' }\n format.json { head :no_content }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes the specified class. Examples: const_get 'String' String const_get ['ActiveRecord', 'Base'] ActiveRecord::Base
def const_remove(klass) klass = [klass] unless klass.kind_of? Array if klass.length > 1 Utility.const_get(klass[0..-2]).send :remove_const, klass.last elsif klass.any? Object.send :remove_const, klass.last end end
[ "def delete_class(klass)\n Object.class_eval do\n remove_const(klass.name.intern) if const_defined?(klass.name.intern)\n end\n end", "def force_remove_const(klass, const)\n klass.send(:remove_const, const) if klass.const_defined?(const)\n end", "def remove_constant(const)\n ba...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Iterates through contours and yields them.
def with_each_contour contours.each do |contour| # Generate a MASK based on the current contour, and erode it so # that we can get rid of some of the shadow around the piece. # The whole map is black and the piece is white. yield contour, grab_color_from_contour(contour) ...
[ "def findContours(group)\n\t\t\tcontours = []\n\t\t\twhile group.length > 0\n\t\t\t\tcontours << findContour(group)\n\t\t\tend\n\t\t\tcontours\n\t\tend", "def plot_contour; end", "def get_contour_points_adv()\r\n result = []\r\n idx = 0\r\n result[idx] = Offset.vertices(@active_face.outer_loop.vertices, -...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /nature_financings GET /nature_financings.json
def index @nature_financings = NatureFinancing.all end
[ "def index\n @financings = Financing.all\n end", "def show\n @financiation = Financiation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @financiation }\n end\n end", "def show\n @nature_of_business = NatureOfBusiness.find(param...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /nature_financings POST /nature_financings.json
def create @nature_financing = NatureFinancing.new(nature_financing_params) @nature_financing.institute = current_institute respond_to do |format| if @nature_financing.save format.html { redirect_to @nature_financing, notice: 'Nature financing was successfully created.' } format.json ...
[ "def create\n @financiation = Financiation.new(params[:financiation])\n\n respond_to do |format|\n if @financiation.save\n format.html { redirect_to @financiation, notice: 'Financiation was successfully created.' }\n format.json { render json: @financiation, status: :created, location: @fin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /nature_financings/1 PATCH/PUT /nature_financings/1.json
def update respond_to do |format| if @nature_financing.update(nature_financing_params) format.html { redirect_to @nature_financing, notice: 'Nature financing was successfully updated.' } format.json { render :show, status: :ok, location: @nature_financing } else format.html { ren...
[ "def update\n json_update(factType,factType_params, FactType)\n end", "def update\n @nature_of_business = NatureOfBusiness.find(params[:id])\n\n respond_to do |format|\n if @nature_of_business.update_attributes(params[:nature_of_business])\n format.html { redirect_to @nature_of_business, not...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /nature_financings/1 DELETE /nature_financings/1.json
def destroy @nature_financing.destroy respond_to do |format| format.html { redirect_to nature_financings_url, notice: 'Nature financing was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @financing.destroy\n respond_to do |format|\n format.html { redirect_to financings_url, notice: 'Данные о финансировании успешно удалены.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @financiation = Financiation.find(params[:id])\n @financiation.destr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /inventory_snapshot_contents GET /inventory_snapshot_contents.json
def index @inventory_snapshot_contents = InventorySnapshotContent.all end
[ "def show\n @inventory_snapshot = InventorySnapshot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inventory_snapshot }\n end\n end", "def index\n @inventory_snapshots = InventorySnapshot.all\n end", "def new\n @inventory_snaps...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /inventory_snapshot_contents POST /inventory_snapshot_contents.json
def create @inventory_snapshot_content = InventorySnapshotContent.new(inventory_snapshot_content_params) respond_to do |format| if @inventory_snapshot_content.save format.html { redirect_to @inventory_snapshot_content, notice: 'Inventory snapshot content was successfully created.' } form...
[ "def index\n @inventory_snapshot_contents = InventorySnapshotContent.all\n end", "def create\n @inventory_snapshot = InventorySnapshot.new(params[:inventory_snapshot])\n\n respond_to do |format|\n if @inventory_snapshot.save\n format.html { redirect_to @inventory_snapshot, notice: 'Inventory...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /inventory_snapshot_contents/1 PATCH/PUT /inventory_snapshot_contents/1.json
def update respond_to do |format| if @inventory_snapshot_content.update(inventory_snapshot_content_params) format.html { redirect_to @inventory_snapshot_content, notice: 'Inventory snapshot content was successfully updated.' } format.json { render :show, status: :ok, location: @inventory_snaps...
[ "def update\n respond_to do |format|\n if @inventory_snapshot.update(inventory_snapshot_params)\n format.html { redirect_to @inventory_snapshot, notice: 'Inventory snapshot was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventory_snapshot }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /inventory_snapshot_contents/1 DELETE /inventory_snapshot_contents/1.json
def destroy @inventory_snapshot_content.destroy respond_to do |format| format.html { redirect_to inventory_snapshot_contents_url, notice: 'Inventory snapshot content was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @inventory_snapshot = InventorySnapshot.find(params[:id])\n @inventory_snapshot.destroy\n\n respond_to do |format|\n format.html { redirect_to inventory_snapshots_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @inventory_snapshot.destroy\n respond...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Take a file, get all the lines until matching termination_pattern. We are searching for // in particular, which are the termination characters for the cds. TODO: make the method general for any String object, and not for file objects.
def get_sequence(file, termination_pattern, keep_last = nil) assert(file.class == File, "#{file} is not a valid File object.") assert(termination_pattern.class == Regexp, "#{termination_pattern} is not a valid Regexp object.") out = "" line = file.gets # Continue reading file lines until file ends or # lin...
[ "def get_sequence(file, termination_pattern)\n \n assert(file.class == File, \"#{file} is not a valid File object.\")\n assert(termination_pattern.class == Regexp, \"#{termination_pattern} is not a valid Regexp object.\")\n out = \"\"\n line = file.gets\n matchp = !!line.match(termination_pattern) # initializ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
group sequence in 80 characters lines long the 80th character is '\n' TODO: try to pass sequence by reference (think 'yeld' statement is involved)
def group_sequence (sequence, length) temp_sequence = "" index = 0; cont = 0 while sequence[index] != nil do temp_sequence += sequence[index] index += 1 if cont < length - 1 cont += 1 else temp_sequence += "\n" cont = 0 end end temp_sequence end
[ "def group_sequence (sequence)\n\n temp_sequence = \"\"\n index = 0; cont = 0\n while sequence[index] != nil do\n temp_sequence += sequence[index]\n index += 1\n if cont < $MAX_LENGTH - 1\n cont += 1\n else\n temp_sequence += \"\\n\"\n cont = 0\n end\n end\n temp_sequence\nend", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send the user an email saying the bulk observation import encountered an error.
def bulk_observation_error( user, filename, error_details ) @user = user @message = error_details[:reason] @errors = error_details[:errors] @field_options = error_details[:field_options] mail_with_defaults( to: "#{user.name} <#{user.email}>", subject: [ :were_sorry_b...
[ "def bulk_observation_error(user, observation_file, error_details)\n setup_email(user)\n @subject << \"We're sorry but your bulk import of #{observation_file} has failed.\"\n\n @message = error_details[:reason]\n @errors = error_details[:errors]\n @field_options = error_details[:field_op...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send the user an email saying the bulk observation import was successful.
def bulk_observation_success( user, filename ) @user = user @filename = filename mail_with_defaults( to: "#{user.name} <#{user.email}>", subject: [ :bulk_import_of_filename_is_complete, { filename: filename } ] ) end
[ "def bulk_observation_success(user, observation_file)\n setup_email(user)\n @subject << \"The bulk import of #{observation_file} has been completed successfully.\"\n @filename = observation_file\n mail(:to => \"#{user.name} <#{user.email}>\", :subject => @subject, :from => @from)\n end", "def bulk_ob...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns name; converts broadcast label to shared to be consistent with google
def name @name == 'broadcast' ? 'shared' : @name end
[ "def symbol_to_name(sym)\n parts = sym.to_s.split(\"_\").map(&:capitalize)\n parts[0].downcase!\n \"ga:\" + parts.join('')\n end", "def handle_name(event)\n broadcast :name, @room, @name = event['content']['name']\n end", "def label\n @client.get('host', :name_label, @uuid)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Usage: Google::Reader::Label.new('friends').entries Google::Reader::Label.new('friends').entries(:all, :n => 25) Google::Reader::Label.new('friends').entries(:unread) Google::Reader::Label.new('friends').entries(:unread, :n => 25) To use with continuations: unread = Google::Reader::Label.new('friends').entries(:unread)...
def entries(which=nil, o={}) options = {:n => 15,}.merge(o) query_str = valid_keys_to_query_string(o) url = case which.to_s when 'unread' sprintf(LABEL_URL, @name) + "?xt=#{State::READ}&#{query_str}" else sprintf(LABEL_URL, @name) end self.clas...
[ "def unread_items(limit = 5)\n # Find labeled items, excluding read items.\n label = \"atom/user/-/label/#{CGI.escape @label}\"\n filter = \"user/-/state/com.google/read\"\n order = \"o\" # oldest first\n response = @google_reader_api.get_link label, :n => limit, :xt => filter, :r => order\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /multi_boards/1 GET /multi_boards/1.json
def show @multi_board = MultiBoard.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @multi_board } end end
[ "def index\n\t\tuid = current_user().id\n\t\t@boards = User.find(uid).boards\n\n\t\trender :json => @boards\n end", "def new\n @multi_board = MultiBoard.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @multi_board }\n end\n end", "def boards\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /multi_boards/new GET /multi_boards/new.json
def new @multi_board = MultiBoard.new respond_to do |format| format.html # new.html.erb format.json { render json: @multi_board } end end
[ "def create\n @multi_board = MultiBoard.new(params[:multi_board])\n\n respond_to do |format|\n if @multi_board.save\n format.html { redirect_to @multi_board, notice: 'Multi board was successfully created.' }\n format.json { render json: @multi_board, status: :created, location: @multi_board...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /multi_boards POST /multi_boards.json
def create @multi_board = MultiBoard.new(params[:multi_board]) respond_to do |format| if @multi_board.save format.html { redirect_to @multi_board, notice: 'Multi board was successfully created.' } format.json { render json: @multi_board, status: :created, location: @multi_board } el...
[ "def new\n @multi_board = MultiBoard.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @multi_board }\n end\n end", "def create\n @board = current_user.boards.new(board_params)\n if @board.save\n render :show, status: :created\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /multi_boards/1 PUT /multi_boards/1.json
def update @multi_board = MultiBoard.find(params[:id]) respond_to do |format| if @multi_board.update_attributes(params[:multi_board]) format.html { redirect_to @multi_board, notice: 'Multi board was successfully updated.' } format.json { head :no_content } else format.html {...
[ "def update\n @user = User.find(params[:user_id])\n @board = @user.boards.find(params[:id])\n @board.update_column(:content, params[:board].as_json)\n respond_to do |format|\n format.json { render json: @board }\n end\n end", "def update\n authorize @board\n @board.update!(board_params)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /multi_boards/1 DELETE /multi_boards/1.json
def destroy @multi_board = MultiBoard.find(params[:id]) @multi_board.destroy respond_to do |format| format.html { redirect_to multi_boards_url } format.json { head :no_content } end end
[ "def destroy\n @board = Board.find(params[:id])\n @board.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_boards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @m3_board.destroy\n respond_to do |format|\n format.html { redirect_to m3_boa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve the client vpn config for current user Returns the client vpn config for the currently loggedin user.
def find_current_user_vpn_config(code, opts = {}) data, _status_code, _headers = find_current_user_vpn_config_with_http_info(code, opts) data end
[ "def client_config\r\n JSON.parse(api_get('Configurations.egg', 'IphoneClient').body)\r\n end", "def vpn_configuration_id\n return @vpn_configuration_id\n end", "def get_current_user_options\n response = get_current_user_meta('options')\n ret = {}\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Turn off vpn for the current user Turns off vpn for the currently loggedin user.
def turn_off_current_user_vpn(opts = {}) turn_off_current_user_vpn_with_http_info(opts) nil end
[ "def turn_off_current_user_vpn_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VPNApi.turn_off_current_user_vpn ...'\n end\n # resource path\n local_var_path = '/user/vpn'\n\n # query parameters\n query_params = opts[:q...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Turn off vpn for the current user Turns off vpn for the currently loggedin user.
def turn_off_current_user_vpn_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: VPNApi.turn_off_current_user_vpn ...' end # resource path local_var_path = '/user/vpn' # query parameters query_params = opts[:query_params] ...
[ "def turn_off_current_user_vpn(opts = {})\n turn_off_current_user_vpn_with_http_info(opts)\n nil\n end", "def deactivate_user(user_id)\n start.uri('/api/user')\n .url_segment(user_id)\n .delete()\n .go()\n end", "def deactivate_user(user_id)\n start.uri('/...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Turn on vpn for the current user Turns on vpn for the currently loggedin user.
def turn_on_current_user_vpn(opts = {}) turn_on_current_user_vpn_with_http_info(opts) nil end
[ "def activate_user(user_id)\n post(\"/users/#{user_id}/activate\")\n end", "def activate_user(user)\n user.status_id=0\n user.save\n end", "def set_ViaUser(value)\n set_input(\"ViaUser\", value)\n end", "def activate!(user)\n return false if self.active?\n\n @user ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Define breakfast, lunch and dinner methods that return the meal choice passed into them. If nothing is passed in, it shoud default to the foods on the readme (frosted flake, grilled cheese, salmon)
def meal(breakfast = "frosted flakes", lunch = "grilled cheese", dinner = "salmon") puts "Morning is the best time for #{breakfast}!" puts "Noon is the best time for #{lunch}!" puts "Evening is the best time for #{dinner}!" end
[ "def meal_choice(breakfast=\"frosted flakes\",lunch=\"grilled cheese\",dinner=\"salmon\")\n puts \"Morning is the best time for #{breakfast}!\"\n puts \"Lunch time is a good time to eat #{lunch}.\"\n puts \"At dinner time, we eat #{dinner}.\"\n\nend", "def myfood(food)\r\n case food\r\n when \"Steak\"\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin dada una palabra clave(llave) construlle una tabla tipo vigenere polialfabetica. =end
def crea_tabla(llave) renglon = Array.new tam = llave.length tam.times do |i| tmp = "" << llave[i] if ALFABETO.include? tmp renglon.push(tmp) ALFABETO.delete! tmp end end ALFABETO.chars{|c| renglon.push(c)} tabla = Array.new tabla.push(renglon.to_s) for i in (1...26) aux = re...
[ "def tabla_pasos(contador,array_anterior)\n aux=0\n tabla = Terminal::Table.new do |a|\n a.title= \"ELEMENTOS A ORDENAR: #{array_anterior}\"\n a.headings = [{value:'DATO', alignment: :center},{value:'ESTRUCTURA', alignment: :center}]\n for i in 0..contador-1\n a.add_row([\n aux+=1,\n @pasoL[i]\n ])\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper method to generate the proper url for Mailgun unsubscribe API calls
def unsubscribe_url(address=nil) "#{@mailgun.base_url}/#{@domain}/unsubscribes#{'/' + address if address}" end
[ "def unsubscribe_url\n nil\n end", "def unsubscribe_url(id:, email:)\n token =\n Base64.encode64(\"#{id}:#{email}\")\n\n \"#{connection.url_prefix}unsubscribe?token=#{token}\"\n end", "def campaign_unsubscribes_url(domain, campaign_id=nil)\n \"#{@mailgun.base_url}/#{doma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list whose elements may also be integers or other lists. Example 1: Given the list [[1,1],2,[1,1]], return 10. (four 1's at depth 2, one 2 at depth 1)
def sum_depth ( x, weight = 1 ) sum = 0 x = [ x ] if x.is_a? Integer x.each do | n | if n.is_a? Array sum += sum_depth( n, weight + 1 ) else sum += n * weight end end return sum end
[ "def sum_nested(lst)\n sum = 0\n\n lst.each do |element|\n if element.is_a?(Array)\n sum += sum_nested(element)\n else\n sum += element\n end\n end\n\n sum\nend", "def sum_nested_collection\n nested_numbers = [[1,2,3], [5,6,7,5], [9,10,13,6], [1]]\nend", "def deep_count_x(arr)\n arr.map...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if the user is the author of a reply
def reply_author(reply) logged_in? && current_user.id == reply.user_id end
[ "def reply_author(reply)\n user_signed_in? && current_user.id == reply.user_id\n end", "def answered_by?(user)\n replies.exists?(:user_id => user)\n end", "def author?(user)\n self.user == user\n end", "def author?(user)\n authors.member?(user)\n end", "def already_replied? client, user\n c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /tipo_venta POST /tipo_venta.json
def create @tipo_ventum = TipoVentum.new(tipo_ventum_params) respond_to do |format| if @tipo_ventum.save format.html { redirect_to @tipo_ventum, notice: 'Tipo ventum was successfully created.' } format.json { render :show, status: :created, location: @tipo_ventum } else form...
[ "def create\n @tipo_evento = TipoEvento.new(tipo_evento_params)\n\n respond_to do |format|\n if @tipo_evento.save\n format.html { redirect_to :eventos, notice: 'Tipo evento was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_evento }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /tipo_venta/1 DELETE /tipo_venta/1.json
def destroy @tipo_ventum.destroy respond_to do |format| format.html { redirect_to tipo_venta_url, notice: 'Tipo ventum was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @tipo_evento = TipoEvento.find(params[:id])\n @tipo_evento.destroy\n\n respond_to do |format|\n format.html { redirect_to tipi_evento_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_evento = TipoEvento.find(params[:id])\n @tipo_evento.destroy...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if other period is inside this period. This means that both starts_at and ends_at of other period have to be included in this period.
def include?(other_period) inside?(other_period.starts_at) && inside?(other_period.ends_at) end
[ "def overlaps_with_reservation?(other)\n other.overlaps?(begins_at, ends_at)\n end", "def overlaps\n other_orders.overlaps start_date, end_date\n end", "def overlaps(other_date_range)\n if contains(other_date_range.start_date) || contains(other_date_range.end_date)\n true\n elsif other_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We can't serialize the explainer, so clear it before we transmit
def prepare_to_send statement.explainer = nil end
[ "def prepare_to_send\n statement.explainer = nil\n end", "def clear_generated_description; end", "def clear\n @recorded = ''\n end", "def clear\n @answers = Hash.new\n @title = \"\"\n @version = 1.1\n end", "def clear_description\n @description = Mongo::S...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
`Paginatedlast_page(count)` Compute the maximum page number which could be meaningfully displayed.
def last_page(count) (count / PER_PAGE.to_f).ceil end
[ "def last_page\n (@count / @per_page.to_f).ceil\n end", "def last_page\n page(page_count)\n end", "def last_page_number\n number_of_pages\n end", "def bound_last(last, count)\n if last > last_page(count) then last_page(count) else last end\n end", "def last_page\n (max...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
`Paginatedpage(req)` Retrieve the current page out of the `req` instance.
def page(req) req.params.fetch('page', default='1').to_i end
[ "def pagination_page\n page = params[:page].to_i\n page = 1 if page == 0\n page\n end", "def page\n\t\t\t@page ||= request.headers[\"page\"] || 1\n\t\tend", "def paginate(request)\n pkey = httpize(PuppetHerald::Models::Pagination::KEYS[:page])\n lkey = httpize(PuppetHeral...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
`Paginatedpage_nums(req, count)` Compute the range of page numbers to display based on the current `req` and the total `count` of items contained in the paginated collection.
def page_nums(req, count) first = page(req) - SPREAD last = bound_first(first) + (SPREAD * 2) first = bound_last(last, count) - (SPREAD * 2) if bound_last(last, count) == last_page(count) bound_first(first)..bound_last(last, count) end
[ "def calc_pages(count, page_size)\n ( (count.to_i-1) / page_size.to_i ).to_i + 1\n end", "def page_count=(num)\n @page_count = num\n end", "def xdes_page_numbers\n (0..(@pages / pages_per_xdes_page)).map { |n| n * pages_per_xdes_page }\n end", "def pagination_numbers(pages, args={})\n resul...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
`Paginatedbound_first(first)` Private method to calculate the first page based on the current value of `first` to display taking into account the lower display bound or minimum page number (1).
def bound_first(first) if first < 1 then 1 else first end end
[ "def first_page\n return nil if total_pages < 1\n return 1\n end", "def first_page\n page(1)\n end", "def lower_bound\n (pagenum - 1) * pagesize\n end", "def first_page_number\n 1\n end", "def first_page\n previous_page? ? resource_class.where(original_params.merge(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
`Paginatedbound_last(last, count)` Private method to calculate the last page number to display accounting for the maximum page number display bound represented by `last_page`. Returns a value less than or equal to `last_page` based on the current value of `last` and the total `count` of items in the collection.
def bound_last(last, count) if last > last_page(count) then last_page(count) else last end end
[ "def last_page\n (@count / @per_page.to_f).ceil\n end", "def last_page(count)\n (count / PER_PAGE.to_f).ceil\n end", "def last_page\n page(page_count)\n end", "def last_page\n self[page_count] \n end", "def last_page_number\n number_of_pages\n end", "def last_page\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Approve a particular Store in the database
def approve_store_app(uid) Store.unlock.where(uid: uid) end
[ "def approve!\n self.update_attribute(:status, APPROVED)\n self.stock_entries.update_all(status: StockEntry::ACTIVE)\n true\n end", "def approve\n @expense = Expense.find(params[:id])\n @expense.approve!\n\n if @expense.save\n flash[:notice] = \"La nota de venta fue aprobada.\"\n else\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reject a particular Store in the database
def reject_store_app(uid) Store.lock.where(uid: uid) end
[ "def remove_store\n @admin_market = Market.find(params[:id])\n store = Store.find(params[:store_id])\n \n @admin_market.stores.delete(store) if @admin_market.stores.include? store\n unless @admin_market.stores.include? store\n flash[:success] = 'Success add store to market'\n end\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Edit a particular Store in the database
def edit_store(edited_store) store = Store.find(edited_store.uid) store.attributes = edited_store.attributes store.save! end
[ "def edit\n @store = Store.find(params[:id])\n end", "def update\n @store = Store.find(params[:id])\n\n respond_to do |format|\n if @store.update_attributes(params[:store])\n format.html { redirect_to(stores_path, :notice => 'Store was successfully updated.') }\n format.xml { head :o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a particular Store in the database
def delete_store(uid) store = Store.find(uid) store.delete! end
[ "def destroy\n store_id = params[:id]\n Store.find(store_id).destroy\n render plain: \"Deleted store with id #{store_id}\"\n end", "def remove_store\n @admin_market = Market.find(params[:id])\n store = Store.find(params[:store_id])\n \n @admin_market.stores.delete(store) if @admin_market.sto...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
vai pegar os componentes e as quantidade de cada produto/componente
def iterando_nos_componente_enviados quantidade = params[:produto_quantidade] i = 1 for i in quantidade.to_i do @componentesenviados << Produto.all(params[:exibeformcomponente_id]) end end
[ "def n_itens\n n = 0\n self.produtos_quantidades.each { |c| n += c.qtd }\n return n\n end", "def get_price_by_product_price_definition_set_by_component(quantity,components,dimension_x,dimension_y,options={})\n accumalte_total_price = 0\n success = false\n components.each do |element...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /backend/conf_activities GET /backend/conf_activities.json
def index @backend_conf_activities = Conf::Activity.all end
[ "def all_activities\n get('activities.json')\n end", "def activity(activity_id)\n get(\"activities/#{activity_id}.json\")\n end", "def frequent_activities\n get(\"/user/#{@user_id}/activities/frequent.json\")\n end", "def frequent_activities()\n get(\"/user/#{@user_id}/activities/...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /backend/conf_activities POST /backend/conf_activities.json
def create @backend_conf_activity = Conf::Activity.new(backend_conf_activity_params) respond_to do |format| if @backend_conf_activity.save format.html { redirect_to backend_conf_activity_path(@backend_conf_activity), notice: 'Conf activity was successfully created.' } format.json { render...
[ "def index\n @backend_conf_activities = Conf::Activity.all\n end", "def activities=(value)\n @activities = value\n end", "def create\n raise Request::NoRequiredFields unless params[:activities]\n Request.add( params[:org_id], current_user, \"ac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /backend/conf_activities/1 PATCH/PUT /backend/conf_activities/1.json
def update respond_to do |format| if @backend_conf_activity.update(backend_conf_activity_params) format.html { redirect_to backend_conf_activity_path(@backend_conf_activity), notice: 'Conf activity was successfully updated.' } format.json { render :show, status: :ok, location: backend_conf_act...
[ "def update\n respond_to do |format|\n @activity.status = Activity::SETTED if @activity.setting?\n if @activity.update(activity_params)\n format.html { redirect_to activities_url, notice: 'Activity was successfully updated.' }\n format.json { head :no_content }\n else\n format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /backend/conf_activities/1 DELETE /backend/conf_activities/1.json
def destroy @backend_conf_activity.destroy respond_to do |format| format.html { redirect_to backend_conf_activities_url, notice: 'Conf activity was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @dev_activity.destroy\n respond_to do |format|\n format.html { redirect_to dev_activities_url }\n format.json { head :no_content }\n end\n end", "def delete_object_activity(id)\n @client.raw('delete', \"/helpers/object-activities/#{id}\")\n end", "def delete\n @activity...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a flat array containing all the possible child terms for this given ontology term
def all_child_terms get_all_child_lists return @all_child_terms end
[ "def get_children( node=self )\n sql = <<-SQL\n select\n subject_term.identifier as child_identifier,\n subject_term.term_name as child_term,\n predicate_term.term_name as relation,\n object_term.identifier as parent_identifier,\n object_term.term_name as parent_te...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper function to query the OLS database and grab the full details of the ontology term.
def get_term_details # This query ensures we look at the most recent fully loaded ontologies sql = <<-SQL select term.* from term join ontology on ontology.ontology_id = term.ontology_id where term.identifier = ? order by ontology.fully_loaded desc, ontology.load_date asc SQL ...
[ "def get_term_from_synonym\n sql = <<-SQL\n select term.*\n from term\n join ontology on ontology.ontology_id = term.ontology_id\n join term_synonym on term.term_pk = term_synonym.term_pk\n where term_synonym.synonym_value = ?\n order by ontology.fully_loaded desc, ontology.load_dat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper function to try to find an ontology term via a synonym.
def get_term_from_synonym sql = <<-SQL select term.* from term join ontology on ontology.ontology_id = term.ontology_id join term_synonym on term.term_pk = term_synonym.term_pk where term_synonym.synonym_value = ? order by ontology.fully_loaded desc, ontology.load_date asc SQ...
[ "def find_synonyms(word)\r\n require 'open-uri'\r\n require 'timeout'\r\n timeout(5) do\r\n open(SYNONYM_LOOKUP_URI % word) do |stream|\r\n # Grab words linked to dictionary entries as possible synonyms\r\n data = stream.read.gsub(\"&nbsp;\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }