query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Triggers given action on a specific resource.
def trigger(resource_type_identifier, action) # TODO: not tested if @model.kinds.select { |kind| kind.term == resource_type }.any? type_identifier = @model.kinds.select { |kind| kind.term == resource_type_identifier }.first.type_identifier location ...
[ "def trigger(resource_type_identifier, action); end", "def resource_action(resource)\n resource.action if resource.respond_to?(:action)\n end", "def enqueue_action_single_resource(action, type, id)\n raise BadRequestError, \"Must specify an id for changing a #{type} resource\" unless id\n\n ph...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Refreshes the Occi::Model used inside the client. Useful for updating the model without creating a new instance or reconnecting. Saves a lot of time in an interactive mode.
def refresh # re-download the model from the server set_model end
[ "def refresh\n # re-download the model from the server\n set_model\n end", "def reload!\n # TODO reload OData entity\n #reset_changes\n end", "def refresh(model)\n response = client.get(find_path(model.primary_key))\n if (200..299).include?(response.code)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Performs POST requests and returns URI locations. Resource data must be provided in an Occi::Collection instance.
def post(path, collection) # remove the leading slash path = path.gsub(/\A\//, '') headers = self.class.headers.clone headers['Content-Type'] = @media_type response = case @media_type when 'application/occi+json' self.class....
[ "def post(path, collection)\n # remove the leading slash\n path = path.gsub(/\\A\\//, '')\n\n headers = self.class.headers.clone\n headers['Content-Type'] = @media_type\n\n response = case @media_type\n when 'application/occi+json'\n self.class.post(@...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks whether the given endpoint URI is valid and adds a trailing slash if necessary.
def prepare_endpoint(endpoint) raise 'Endpoint not a valid URI' if (endpoint =~ URI::ABS_URI).nil? @endpoint = endpoint.chomp('/') + '/' end
[ "def ensure_url_ends_with_slash(url)\n return \"#{url}/\" unless url.end_with?(\"/\")\n\n return url\n end", "def valid_endpoint(ep)\n if ep == nil\n raise ArgumentError, \"Request: An endpoint must be set\", caller\n elsif not ep.is_a? String\n raise TypeError, \"Request: An ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets media type. Will choose either application/occi+json or text/plain based on the formats supported by the server.
def set_media_type media_types = self.class.head(@endpoint).headers['accept'] Occi::Log.debug("Available media types: #{media_types}") @media_type = case media_types when /application\/occi\+json/ 'application/occi+json' ...
[ "def content_type=(value)\n self.header['Content-Type'] = value\n end", "def set_content_type(response, format)\n response[:content_type] = format_to_mime(format)\n end", "def media_type\n @media_type ||= MediaType.new(env['HTTP_ACCEPT'])\n end", "def media_type=(value)\n @media_type ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /employees_courses GET /employees_courses.json
def index @employees_courses = EmployeesCourse.all end
[ "def getCourses\n\t\treturn getFromAPI(API_URL)\n\tend", "def index\n\t\t@courses = @teacher.courses\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @courses }\n end\n end", "def index\n @courses = @student.courses\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /employees_courses POST /employees_courses.json
def create @employees_course = EmployeesCourse.new(employees_course_params) respond_to do |format| if @employees_course.save format.html { redirect_to @employees_course, notice: 'Employees course was successfully created.' } format.json { render :show, status: :created, location: @employe...
[ "def create\n # render plain: params[:courses].inspect\n @courses = Courses.new(courses_params)\n\n respond_to do |format|\n if @courses.save\n format.html { redirect_to @courses, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @cour...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /employees_courses/1 PATCH/PUT /employees_courses/1.json
def update respond_to do |format| if @employees_course.update(employees_course_params) format.html { redirect_to @employees_course, notice: 'Employees course was successfully updated.' } format.json { render :show, status: :ok, location: @employees_course } else format.html { ren...
[ "def update\n # TODO Strip company_id out of params here\n @v1_employee = V1::Employee.find(params[:id])\n\n if @v1_employee.update_attributes(employee_params)\n render json: @v1_employee, status: :ok\n else\n render json: @v1_employee.errors, status: :unprocessable_entity\n end\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /employees_courses/1 DELETE /employees_courses/1.json
def destroy @employees_course.destroy respond_to do |format| format.html { redirect_to employees_courses_url, notice: 'Employees course was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @exam_course = ExamCourse.find(params[:id])\n @exam_course.destroy\n\n respond_to do |format|\n format.html { redirect_to exam_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lab_course = LabCourse.find(params[:id])\n @lab_course.destroy\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
==========Validating book, with unique UUID=================================================
def validate_books csv_text = open(file.url) csv = CSV.parse(csv_text, :headers => true) csv.each do |row| book_hash = Book.new book_hash.title = row["Book title"] book_hash.author = Author.find_or_create_by(name: row["Book author"]) book_ha...
[ "def valid?\n UUID_REGEX.match?(uuid)\n end", "def valid_uuid?\n UUID_REGEX.match?(uuid)\n end", "def verify_uuid(uuid,data)\n\t\tgenerate_uuid(data) == uuid\n\tend", "def uuid?\n !match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/).nil?\n end", "def valid_uuid?(uui...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
INSTANCE METHODS Returns the date the last email of a specified category was sent
def email_sent_at(category) emails = self.email_logs.select {|e| e.category == category} emails.collect {|e| e.created_at}.sort.last end
[ "def emails_sent_at(category)\r\n emails = self.email_logs.select {|e|e.category == category}\r\n emails.collect {|e| e.created_at}.sort\r\n end", "def last_activity\n if topics.empty?\n # If there are no topics yet in thic category then:\n updated_at\n else\n # Otherwise last activity...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array of the dates the email of a specified category was sent
def emails_sent_at(category) emails = self.email_logs.select {|e|e.category == category} emails.collect {|e| e.created_at}.sort end
[ "def email_sent_at(category)\r\n emails = self.email_logs.select {|e| e.category == category}\r\n emails.collect {|e| e.created_at}.sort.last\r\n end", "def emails(category = nil)\r\n return category ? self.email_logs.select {|e| e.category == category} : self.email_logs\r\n end", "def daily_messeng...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns all emails or all emails of a specified category (if given)
def emails(category = nil) return category ? self.email_logs.select {|e| e.category == category} : self.email_logs end
[ "def email_sent_at(category)\r\n emails = self.email_logs.select {|e| e.category == category}\r\n emails.collect {|e| e.created_at}.sort.last\r\n end", "def emails_sent_at(category)\r\n emails = self.email_logs.select {|e|e.category == category}\r\n emails.collect {|e| e.created_at}.sort\r\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Deposit Money in a pot amount The amount to deposit, in pennies. source_account_id The account_id of the account to withdraw from. dedupe_id (optional) A random string, to prevent duplicate deposits. Returns self: a single Monzo::Pot
def deposit!(amount, source_account_id, dedupe_id = SecureRandom.uuid) data = { amount: amount, source_account_id: source_account_id, dedupe_id: dedupe_id, } response = Monzo.client.put("/pots/#{@id}/deposit", data) parsed_response = parse_response(response) update...
[ "def withdraw!(amount, destination_account_id, dedupe_id = SecureRandom.uuid)\n data = {\n amount: amount,\n destination_account_id: destination_account_id,\n dedupe_id: dedupe_id,\n }\n\n response = Monzo.client.put(\"/pots/#{@id}/withdraw\", data)\n parsed_response = parse...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Withdraw Money from a pot amount The amount to withdraw, in pennies. destination_account_id The account_id of the account to deposit into. dedupe_id (optional) A random string, to prevent duplicate deposits. Returns self: a single Monzo::Pot
def withdraw!(amount, destination_account_id, dedupe_id = SecureRandom.uuid) data = { amount: amount, destination_account_id: destination_account_id, dedupe_id: dedupe_id, } response = Monzo.client.put("/pots/#{@id}/withdraw", data) parsed_response = parse_response(respo...
[ "def deposit!(amount, source_account_id, dedupe_id = SecureRandom.uuid)\n data = {\n amount: amount,\n source_account_id: source_account_id,\n dedupe_id: dedupe_id,\n }\n\n response = Monzo.client.put(\"/pots/#{@id}/deposit\", data)\n parsed_response = parse_response(respons...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: Update the Pot instance variables parsed_response a hash whose keys exactly match the instance variables for Monzo::Pot. Returns self (an instance of Monzo::Pot)
def update_self(parsed_response) instance_variables.each do |iv| instance_variable_set(iv, parsed_response[iv.to_s[1..-1].to_sym]) end self end
[ "def update_from(response)\n load_response_api(response.is_a?(Hash) ? response : JSON.parse(response))\n\n # attributes to remove\n (@values.keys - raw['response'].keys).each { |key| remove_accessor(key) }\n\n update_attributes(raw['response'])\n\n self\n end", "def parse(response)\n\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializes a FSEvent worker and adds a watcher for each directory passed to the adapter.
def init_worker FSEvent.new.tap do |worker| worker.watch(@directories.dup, :latency => @latency) do |changes| next if @paused @mutex.synchronize do changes.each { |path| @changed_dirs << path.sub(LAST_SEPARATOR_REGEX, '') } end end en...
[ "def _init_worker\n FSEvent.new.tap do |worker|\n worker.watch(_directories_path, latency: _latency) do |changes|\n paths = _changes_path(changes)\n paths.each { |path| _notify_change(path, type: 'Dir') }\n end\n end\n end", "def init_worker\n work...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /providers/1 GET /providers/1.json
def show @provider = current_company.providers.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @provider } end end
[ "def index\n @providers = Provider.all\n\n render json: @providers\n end", "def providers(params = {})\n response = default_scope.get('providers/') do |request|\n request.params = params\n end\n JSON.parse(response.body)\n end", "def providers\n url = url_with_api_version(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /providers/new GET /providers/new.json
def new @provider = current_company.providers.new respond_to do |format| format.html # new.html.erb format.json { render json: @provider } end end
[ "def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @provider }\n end\n end", "def new\n @provider = Provider.new\n respond_to do |format|\n format.html # new.html.erb\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /providers POST /providers.json
def create @provider = current_company.providers.new(params[:provider]) respond_to do |format| if @provider.save format.html { redirect_to @provider, notice: 'Provider was successfully created.' } format.json { render json: @provider, status: :created, location: @provider } else ...
[ "def create\n @provider = Provider.new(provider_params)\n\n if @provider.save\n render json: @provider, status: :created, location: @provider\n else\n render json: @provider.errors, status: :unprocessable_entity\n end\n end", "def create\n @provider = Provider.new(provider_params)\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /providers/1 PUT /providers/1.json
def update @provider = current_company.providers.find(params[:id]) respond_to do |format| if @provider.update_attributes(params[:provider]) format.html { redirect_to @provider, notice: 'Provider was successfully updated.' } format.json { head :no_content } else format.html {...
[ "def update\n @provider = Provider.find(params[:id])\n\n if @provider.update(provider_params)\n head :no_content\n else\n render json: @provider.errors, status: :unprocessable_entity\n end\n end", "def update\n if @provider.update(provider_params)\n head :no_content\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
it can start if all requests are valid
def validate_can_start if aasm_states_to_check cannot_start! if requests_have_notices? end end
[ "def check_requests\n if requests.empty?\n errors.add('requests', 'there were no requests')\n return\n end\n\n requests.each do |request|\n next if request.valid?\n\n request.errors.each do |k, v|\n errors.add(k, v)\n end\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is the passed candidate a better match than any of the current matches? ARG: `other` another Candidate instance to check against the current set
def better_match?( other ) return true if prefers?( other ) && free? preference_index = preferences.index other match_preference_indexes = matches.map { | match | preferences.index match } preference_index and match_preference_indexes.any? { |i| i > preference_index } end
[ "def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Have all possible preferences been cycled through?
def exhausted_preferences? preference_position >= preferences.size - 1 end
[ "def has_pref?(preference)\n !prefs[preference].to_s.empty?\nend", "def empty_preferences?\n preferences.empty?\n end", "def check_if_all_donors_ready\n self.donor_preferences.each do |donor_preference|\n return false if !donor_preference.is_ready\n end\n return true\n end", "def prefers?(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete the leastpreferred candidate from the matches array
def free! return false if matches.empty? match_preference_indexes = matches.map { | match | preferences.index match } max = match_preference_indexes.max # The index of the match with the lowest preference candidate_to_reject = preferences[ max ] # Delete from bot...
[ "def delete_candidate(val)\n\t\t@candidates.delete(val)\n\tend", "def remove_match\n contest = Contest.get_contest_with_id(params[:contest]) \n winning_scores = contest.get_team_scores(Team.get_team_with_id(contest.get_winner))\n losing_scores = contest.get_team_scores(Team.get_team_with_id(contest.get_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Match with another Candidate ARG: `other` another Candidate instance to match with
def match!( other ) return false unless prefers?( other ) && !matched?( other ) matches << other other.matches << self end
[ "def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If no argument is passed: Do we have at least as many matches as available `match_positions`? If another Candidate is passed: Is that candidate included in the matches? ARG: `other` [optional] another Candidate instance
def matched?( other = nil ) return full? if other.nil? matches.include? other end
[ "def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Increment `preference_position` and return the preference at that position
def next_preference! self.preference_position += 1 preferences.fetch preference_position end
[ "def preference\n return @preference\n end", "def preference=(value)\n @preference = value\n end", "def increment_position\n in_list? && update_position(current_position + 1)\n end", "def add_preference(name, value); end", "def add_preference(name,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Is there a preference for the passed Candidate? ARG: `other` another Candidate instance
def prefers?( other ) preferences.include? other end
[ "def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Track that a proposal was made then ask the other Candidate to respond to a proposal ARG: `other` another Candidate instance
def propose_to( other ) proposals << other other.respond_to_proposal_from self end
[ "def respond_to_proposal_from( other )\n case\n # Is there a preference for the candidate?\n when !prefers?( other )\n false\n\n # Are there available positions for more matches?\n when free?\n match! other\n\n # Is the passed Candidate a better match than a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Given another candidate, respond properly based on current state ARG: `other` another Candidate instance
def respond_to_proposal_from( other ) case # Is there a preference for the candidate? when !prefers?( other ) false # Are there available positions for more matches? when free? match! other # Is the passed Candidate a better match than any other match?...
[ "def apply(candidate)\n raise NotImplementedError, \"Not yet?\"\n end", "def absorb other\n my_voter_ids = self.voter_ids\n other.votes.each { |vote| vote.voter.vote(self, vote.up) unless my_voter_ids.include?(vote.user_id) }\n super if defined? super\n end", "def == other\n case...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tcm_patient_infos GET /tcm_patient_infos.json
def index @tcm_patient_infos = TcmPatientInfo.all end
[ "def get_patient_list\n getProfile\n @patientlist = TherapistPatient.get_my_patients @therapist.user_id\n respond_to do |format|\n format.html { render :template => 'therapist/get_patient_list' }\n format.json { render :status => 200, :json => { action: :get_patient_list,\n patient_list: @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /tcm_patient_infos POST /tcm_patient_infos.json
def create @tcm_patient_info = TcmPatientInfo.new(tcm_patient_info_params) respond_to do |format| if @tcm_patient_info.save format.html { redirect_to @tcm_patient_info, notice: 'Tcm patient info was successfully created.' } format.json { render :show, status: :created, location: @tcm_pati...
[ "def create\n @patient_info = PatientInfo.new(patient_info_params)\n\n respond_to do |format|\n if @patient_info.save\n format.html { redirect_to @patient_info, notice: 'Patient info was successfully created.' }\n format.json { render :show, status: :created, location: @patient_info }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /tcm_patient_infos/1 PATCH/PUT /tcm_patient_infos/1.json
def update respond_to do |format| if @tcm_patient_info.update(tcm_patient_info_params) format.html { redirect_to @tcm_patient_info, notice: 'Tcm patient info was successfully updated.' } format.json { render :show, status: :ok, location: @tcm_patient_info } else format.html { ren...
[ "def update\n @patient = @client.patients.find(params[:id])\n\n respond_to do |format|\n if @patient.update_attributes(params[:patient])\n format.html { redirect_to @patient, notice: 'Patient was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /tcm_patient_infos/1 DELETE /tcm_patient_infos/1.json
def destroy @tcm_patient_info.destroy respond_to do |format| format.html { redirect_to tcm_patient_infos_url, notice: 'Tcm patient info was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @patient.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @patient_info.destroy\n respond_to do |format|\n format.html { redirect_to patient_infos_url, notice: 'Patient info was successfully destroyed.' }\n format.json {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets three tweets from the passed in user. GET /api/getThreeTweets
def getThreeTweets render json: TwitterAPI.get_top_3_tweets(params[:twitter_id]) end
[ "def recent_tweets(user, options = {})\n if @skip_until\n return [] if @skip_until > Time.now\n @skip_until = nil\n end\n\n cache = Ramaze::Cache.plugin\n options = {:count => 5}.merge(options)\n count = options[:count].to_i\n\n count += 10 unless Conf...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /api/getMatchCount Gets the number of matches
def getMatchCount render json: Match.count(:user1 => params[:twitter_id]) end
[ "def matched_count\n @results[MATCHED_COUNT]\n end", "def matched_count\n results.map(&:matched_count).reduce(&:+)\n end", "def number_match_count\n\t\t\ttotal_match_count - exact_match_count\n\t\tend", "def count\n hits.count\n end", "def count_results\n # TODO respond wi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The list of rsync server resources in the resource collection
def rsync_resources ::ObjectSpace.each_object(::Chef::Resource).select do |resource| resource.resource_name == :rsync_serve end end
[ "def rsync_resources\n run_context.resource_collection.select do |resource|\n resource.is_a?(Chef::Resource::RsyncServe)\n end\n end", "def resources_list(session, is_sync)\n # Get resource type to list\n resource_type = session.gets.chomp.to_sym\n\n # Cache dir na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /http_requests/1 PATCH/PUT /http_requests/1.json
def update respond_to do |format| if @http_request.update(http_request_params) format.html { redirect_to @http_request, notice: 'Http request was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json...
[ "def patch *args\n make_request :patch, *args\n end", "def patch(path, params: {}, headers: {})\n request_json :patch, path, params, headers\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def parallel_patch(requests, options = {})\n base_para...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /http_requests/1 DELETE /http_requests/1.json
def destroy @http_request.destroy respond_to do |format| format.html { redirect_to http_requests_url } format.json { head :no_content } end end
[ "def delete\n RestClient.delete \"#{@uri}/api/requests/request/#{@data['requestId']||@data['id']}\"\n puts ' Deleted request: '.red + \"#{@data['requestId']||@data['id']}\".light_blue\n end", "def delete_request\n client.create_request('DELETE', url_path)\n end", "def destroy\n @request....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Obtain a latex representation of the matrix
def latex_matrix if @type == "controlled" @matrix.map { |value, matrix| [value, latex_matrix_for(matrix)] } else latex_matrix_for @matrix end end
[ "def latex_matrix(matrix)\n output = \"\\\\begin{tabular}{|#{'r|' * matrix.first.length}}\\n\"\n output << \"\\\\hline\\n\"\n output << matrix.map { |line| line.join(' & ') }.join(\"\\\\\\\\\\n\\\\hline\\n\")\n output << \"\\\\\\\\\\n\"\n output << \"\\\\hline\\n\"\n output << \"\\\\end{tabular}\\n\"\n outpu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /invoice_taxes/new GET /invoice_taxes/new.json
def new @invoice_tax = InvoiceTax.new respond_to do |format| format.html # new.html.erb format.json { render json: @invoice_tax } end end
[ "def new\r\n @tax_invoice = TaxInvoice.new\r\n @products = Product.all\r\n @orders = Order.all\r\n @companies = Company.all\r\n\r\n\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @tax_invoice }\r\n end\r\n end", "def new\n @breadcrumb...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /invoice_taxes/1 PUT /invoice_taxes/1.json
def update @invoice_tax = InvoiceTax.find(params[:id]) respond_to do |format| if @invoice_tax.update_attributes(params[:invoice_tax]) format.html { redirect_to @invoice_tax, notice: 'Invoice tax was successfully updated.' } format.json { head :no_content } else format.html {...
[ "def send_tax_invoice\n response = JSON.parse(@client.patch(\"items/#{send(:id)}/send_tax_invoice\").body)\n @attributes = response['items']\n true\n end", "def request_tax_invoice\n response = JSON.parse(@client.patch(\"items/#{send(:id)}/request_tax_invoice\").body)\n @attributes = r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /invoice_taxes/1 DELETE /invoice_taxes/1.json
def destroy @invoice_tax = InvoiceTax.find(params[:id]) @invoice_tax.destroy respond_to do |format| format.html { redirect_to invoice_taxes_url } format.json { head :no_content } end end
[ "def delete_tax(id)\n @client.raw('delete', \"/ecommerce/taxes/#{id}\")\n end", "def destroy\r\n @tax_invoice = TaxInvoice.find(params[:id])\r\n @tax_invoice.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to tax_invoices_url }\r\n format.json { head :no_content }\r\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Notify all connection listeners, that a notice message was received.
def handle(context) # Notify all connection listeners by calling their on_server_response method. super(context) # Notify all connection listeners by calling their on_notice method. notify(context) do |connection_listener| connection_listener.on_notice(contex...
[ "def notify_on_changes!\n ensure_connection! { register_callback(notifier) }\n end", "def on_notifications\n self.before_listen if self.respond_to?(:before_listen)\n\n self.class.connection.execute('LISTEN %s' % channel)\n loop do\n handle_notifications do |incoming|\n yield incom...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
execute /bin/sh from vi
def send_vi_shell send_ctrl_escape data = ":!/bin/sh" + "\n" session.shell_write(data) end
[ "def vi\n system \"vim ~/.scratchvim.rb\"\nend", "def execute!\n \tsystem(\"vim #{file} -c 'execute \\\"normal i#{escaped_commands}\\\\<Esc>\\\"' -c 'execute \\\":wq\\\"'\")\n File.read(file)\n end", "def sh command\n system command\n end", "def vim(*args)\n\t\tvi *args\n\tend", "def edit *arg...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
exit vi without saving
def send_vi_exit_nosave send_ctrl_escape data = ":q!" + "\n" session.shell_write(data) end
[ "def send_vi_exit_save\n send_ctrl_escape\n data = \":x!\" + \"\\n\"\n session.shell_write(data)\n end", "def file_exit\n set_focus\n keystroke(VK_MENU, VK_F, VK_X)\n if message_dialog_confirm(:timeout => 0)\n keystroke(VK_N)\n end\n end", "def vi\n system \"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
exit vi with saving
def send_vi_exit_save send_ctrl_escape data = ":x!" + "\n" session.shell_write(data) end
[ "def send_vi_exit_nosave\n send_ctrl_escape\n data = \":q!\" + \"\\n\"\n session.shell_write(data)\n end", "def file_exit\n set_focus\n keystroke(VK_MENU, VK_F, VK_X)\n if message_dialog_confirm(:timeout => 0)\n keystroke(VK_N)\n end\n end", "def file_save\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
for assigning teacher to a course
def teacher_assign @course_allocation = CourseAllocation.find_by_course_id(params[:id]) @course = Course.find(params[:id]) @teachers = get_teachers_for_institute end
[ "def teacher=(value)\n @teacher = value\n end", "def teacher\n self.course_person.first(:type => \"teacher\").person\n end", "def assignment_by_teacher(student_user)\n self.line_break\n puts \"Please select a teacher by typing out their full name below:\".colori...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
creates a button and form with a hidden field in order to pass ids across to new objects
def my_button_to(text, path, objs) s = "<form method=\"get\" action=\"#{path}\" class=\"button_to\"> <div><input type=\"submit\" value=\"#{text}\"/></div>" for obj in objs if(!obj.nil?) s+= "<input type=\"hidden\" name=\"#{obj.class.to_s.downcase}_id\" value=\"#{obj.id}\" />" end...
[ "def button_set_form_vars\n @sb[:buttons_node] = true\n @edit = {}\n if session[:resolve] && session[:resolve][:instance_name]\n @resolve = session[:resolve]\n else\n build_resolve_screen\n end\n @resolve[:target_class] = if x_active_tree == :sandt_tree\n \...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Function to build a radio button list
def radio_list(items) rl = "<ul>" if(!items.empty?) for item in items if(item.is_a?(Category)) #not currently used rl += "#{radio_button_tag "category_ids[]", item.id, @items_to_select.include?(item), :id=>"a#{item.id}"}" + "<label for=\"a#{item.id}\">#{item.name}</label...
[ "def radiobuttons; end", "def radio_buttons(model, method, values, options = {})\n values = values.is_a?(Hash) ? values.to_a : values.map{|v| [v,v]}\n radios = values.map do |value|\n html = radio_button(model, method, value[0].to_s)\n html << '&nbsp; ' << value[1].to_s\n content_tag('label',...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Function to build a checkbox list only usable for an array of the same class
def checkbox_list(items) cl = "<ul>" if(!items.empty?) item_class = items[0].class.to_s item_class_sub = item_class[0..0].to_s for item in items cl += "<li>#{check_box_tag(item_class +"_ids[]", item.id, @items_to_select.include?(item), :id=>"#{item_class_sub + "" + item.id.to_s}")}" ...
[ "def checkboxes_for coll, &blok\n \n @checkbox ||= Class.new do \n \n def initialize &blok\n instance_eval(&blok)\n end\n \n def text txt\n @text = txt\n end\n \n def value txt\n @value = txt\n end\n \n def name txt\n @name = t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash for all groups
def all_group_hash hash = {} for group in @all_groups hash[group] = {} end return hash end
[ "def create_group_hash(group_names, groups)\n group_hash = Hash.new\n for i in 0..group_names.length-1\n group_hash[group_names[i]] = groups[i]\n end\n group_hash\nend", "def group_list\n @group_list = {}\n @group.each { |m| @group_list[m] = 0 }\n @group_list\n end", "def group\n @_group |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash for all properties
def all_property_hash hash = {} items = @all_properties for prop in items hash[prop] = {} end return hash end
[ "def to_hash()\n hash = {}\n @properties.each{ |key, property|\n hash[key.to_s] = property.get_value()\n }\n return hash\n end", "def property_objects\n hash = {}\n self.class.properties.each { |prop| hash[prop] = @properties[prop] }\n hash\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash for all products
def all_product_hash hash = {} items = @all_products for prod in items hash[prod] = {} end return hash end
[ "def cart_hash\n return Digest::MD5.hexdigest(items_to_buy.collect { |i| i.product.id.to_s }.join(':'))\n end", "def products_hash\n return {} if @products.nil?\n products_hash = {}\n @products.map { |p| products_hash[p.code] = p.price }\n products_hash\n end", "def all_prod_comp_hash...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash for all valuefields
def all_valuefield_hash hash = {} items = @all_valuefields for vf in items hash[vf] = {} end return hash end
[ "def values_hash\n hashify(:value)\n end", "def fields_hash\n each_pair.to_h\n end", "def field_hash\n\n self.yattributes || fields.inject({}) { |r, f| r[f.fkey] = f.value; r }\n end", "def hash\n strs = FIELDS.collect {|f| \"#{f}:#{send(f).inspect}\"}\n Digest::S...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash for all images
def all_image_hash hash = {} items = @all_images for img in items hash[img] = {} end return hash end
[ "def uniqueness_hash\n @uniqueness_hash ||= begin\n sum = Digest::MD5.new\n sum << SPRITE_VERSION\n sum << path\n sum << layout\n images.each do |image|\n [:relative_file, :height, :width, :repeat, :spacing, :position, :digest].each do |at...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a hash for all products and components
def all_prod_comp_hash(item=nil) hash = {} if(!item.nil?) items = item.components else items = @all_products end for comp in items hash[comp] = all_prod_comp_hash(comp) end return hash end
[ "def all_product_hash\n hash = {}\n items = @all_products\n for prod in items\n hash[prod] = {}\n end\n return hash\n end", "def products_hash\n return {} if @products.nil?\n products_hash = {}\n @products.map { |p| products_hash[p.code] = p.price }\n products_hash\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
checks if move is on the board or if the position is taken
def valid_move?(board, position) position.between?(0, 8) && !position_taken?(board, position) end
[ "def valid_move?(board, origin, destination)\n\n end", "def valid_move?(to_row, to_col, board, color)\r\n return false if super == false\r\n return legal_move?(to_row, to_col, board) && move_not_in_check?(@row, @col, to_row, to_col, board)\r\n\tend", "def valid_move?\n\t\t@table.stays_on_table?(@...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate the video tag +options+ you can specify height/width/allowfullscreen for an individual video here
def video_tag(options = {}) options = ActiveRecord::Acts::Cinema::DEFAULT_OPTIONS.merge(options) video_url = read_attribute(ActiveRecord::Acts::Cinema::SOURCE_PARAM) width = options[:width] height = options[:height] allow_full_screen = options[:allow_full_screen] ? "tr...
[ "def video(*sources)\n options = sources.extract_options!.symbolize_keys\n sources = sources.shift if sources.size == 1\n\n if options[:poster]\n options[:poster] = asset_path(options[:poster])\n end\n\n if size = options.delete(:size)\n options[:width], options...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Prints the elements inside tree nodes in a PARENT LEFT RIGHT manner x Node, Preferably a root node Examples NOTE: Based on the mock tree structure at LINE:61 preoder_tree_walk(F) => F B A D C E G I H
def preoder_tree_walk(x) unless x.nil? p x.key preoder_tree_walk(x.left) preoder_tree_walk(x.right) end end
[ "def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left: \"\n puts \"#{print_tree(tree.children[0])}\"\n print \"Right: \"\n puts \"#{print_tree(tree.children[1])}\"\nend", "def print_tree\n space = 0\n print_tree_helper(@root, space)\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the minimum element in a row
def min (row_num) row = @rows[row_num] min = row[0] row.each do |num| if min == 0 then min = num end if (num < min) && (num != 0) then min = num end end return min end
[ "def min\n encontrado = false\n value = 0\n i = -1\n # Se revisan todos los elementos de la matriz.\n while encontrado == false\n i += 1\n j = 0\n while j < self.cols\n if self[i][j] != nil and val...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the common factor of a row
def has_common (row_num, row_min) row = @rows[row_num] result = false if row_min != 0 then result = true row.each do |num| if result == true then if (num != 0) && ((num.abs).modulo(row_min.abs) != 0) then result = false end end end end ...
[ "def common_x\n ah, bh, ch = [a,b,c].map {|arr| arr.each_with_object(Hash.new(0)) {|e,h| h[e] += 1}}\n (a & b & c).inject(0) {|sum, e| sum += e * [ah[e], bh[e], ch[e]].min}\nend", "def getCommonClass(rows)\n return rows.inject(rows[0].class) { |klass, el| break if klass != el.class ; klass }\nend", "def grea...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Divides a whole row by its common factor (Row , Common Factor)
def reduce (row_num, row_min) row = @rows[row_num] for i in 0..(row.length - 1) do @rows[row_num][i] = (@rows[row_num][i])/row_min if @rows[row_num][i] == -0.0 then @rows[row_num][i] = 0.0 end end num, den = row_min.to_fraction if den == 1 then puts "R#{row_num + 1} -...
[ "def div_row_vector!(s); divi_row_vector(s); end", "def divide_constant(matrix, constant)\n mat = clone_matrix(matrix)\n constant = constant.to_f\n mat.each do |row|\n row.map! do |element|\n element / constant\n end\n end\n return mat\nend", "def row_checksum(row)\n row = row.split\n row = ro...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Swaps two rows with each other (Index 's)
def swap (row1, row2) row1_copy = @rows[row1] row2_copy = @rows[row2] new_row1 = row2_copy new_row2 = row1_copy @rows[row1] = new_row1 @rows[row2] = new_row2 puts "R#{row1 + 1} <-> R#{row2 + 1}" end
[ "def swap_rows ( r1, r2 )\r\n new_matrix = [] \r\n @matrix.each do |r|\r\n case\r\n when r == row(r1)\r\n new_matrix << row(r2)\r\n when r == row(r2)\r\n new_matrix << row(r1)\r\n else\r\n new_matrix << r\r\n end\r\n end \r\n Matrix.new( ne...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Substitutes Pivot Row (Array Index) with the row you are performing a row operation on (Array Index). Applies cancel_val (See cancel_val above) as the multiplier
def substitute (pivot_row_num, cancel_row_num, cancel_val) for i in 0..(((@rows[pivot_row_num]).length) - 1) @rows[cancel_row_num][i] = @rows[cancel_row_num][i] - (cancel_val)*(@rows[pivot_row_num][i]) if @rows[cancel_row_num][i] == -0.0 then @rows[cancel_row_num][i] = 0.0 end end ...
[ "def inverted_rows(options = {})\n rows = voucher_rows\n rows.reject!(&:canceled?) unless options[:canceled]\n rows.map do |old|\n vr = old.dup\n vr.sum *= -1\n vr\n end\n end", "def calculate_table_row(value)\n @row_values.collect {|x| x * value}\n end", "def replace_row idx, *c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints matrix to Standard Output
def print_matrix width = @rows.flatten.max.to_s.size if width > 4 then width = width - 0.5 end puts @rows.map { |a| "|#{ a.map { |i| outp = "" num, den = i.to_fraction if den == 1 then outp += "#{num}" else outp += "#{num}/#{den}" end "#{ou...
[ "def print_matrix\n @matrix.each do |m|\n print \"#{m}\\n\"\n end\n end", "def print_matrix\n $matrix.each do |rows|\n rows.each do |col|\n puts col\n end\n end\n end", "def pretty_print\n puts\n puts \"Matrix:\\n\"\n puts @matrix.to_a.map(&:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get process information by command 'ps auxw | grep serverId | grep pid'
def get_ps_info args={}, &block return if OS.windows? pid = args[:pid] EM.system('sh', proc{ |process| process.send_data "ps auxw | grep " + pid.to_s + " | grep -v 'grep'\n" process.send_data "exit\n" }) { |output, status| if status.exitstatus == 0 format args...
[ "def ps\n `ps haxo pid,ppid,cmd`\n end", "def mon_pid\n shell = systemu(\"ps auxw | grep -v grep | grep bixby-monitoring-daemon\")\n lines = shell.stdout.split(/\\n/).reject{ |s| s.empty? }\n return nil if lines.empty?\n lines = lines.map{ |s| s.split(/\\s+/) }\n lines.reject!{ |l| l.first != \...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Example For n = 29, the output should be addTwoDigits(n) = 11.
def addTwoDigits(n) result = 0 n.to_s.split("").each {|number| result += number.to_i } result end
[ "def add_digits(num)\n return num if num.to_s.length == 1\n int_array = split_digits(num)\n sum = add_array_ints(int_array)\n return add_digits(sum)\n end", "def sum_digits(number)\n number = number.to_i * 2\n right_digit(number) + left_digit(number)\nend", "def two_digit_sum(int)\n digit1 = (in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /session_replicas GET /session_replicas.json
def index @session_replicas = SessionReplica.all end
[ "def replicas\n data[:replicas]\n end", "def get_all_replicas(id, options = GetAllReplicasOptions.new) end", "def replicas; end", "def destroy\n @session_replica.destroy\n respond_to do |format|\n format.html { redirect_to session_replicas_url }\n format.json { head :no_content }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /session_replicas POST /session_replicas.json
def create @session_replica = SessionReplica.new(session_replica_params) respond_to do |format| if @session_replica.save format.html { redirect_to @session_replica} format.json { render :show, status: :created, location: @session_replica } else format.html { render :new } ...
[ "def index\n @session_replicas = SessionReplica.all\n end", "def replicas\n data[:replicas]\n end", "def destroy\n @session_replica.destroy\n respond_to do |format|\n format.html { redirect_to session_replicas_url }\n format.json { head :no_content }\n end\n end", "def incremen...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /session_replicas/1 PATCH/PUT /session_replicas/1.json
def update respond_to do |format| if @session_replica.update(session_replica_params) format.html { redirect_to @session_replica} format.json { render :show, status: :ok, location: @session_replica } else format.html { render :edit } format.json { render json: @session_rep...
[ "def increment_replica_count\n self.original['spec']['replicas'] += 1\n end", "def index\n @session_replicas = SessionReplica.all\n end", "def replication(path, replnum, options = {})\n WebHDFS.check_options(options, OPT_TABLE['SETREPLICATION'])\n res = operate_requests('PUT', path, 'S...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /session_replicas/1 DELETE /session_replicas/1.json
def destroy @session_replica.destroy respond_to do |format| format.html { redirect_to session_replicas_url } format.json { head :no_content } end end
[ "def destroy\n @image_replica.destroy\n respond_to do |format|\n format.html { redirect_to replicas_url, notice: 'ImageReplica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n replication_agent = client(resource).replication_agent(resource[:run_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete participant by ID.
def delete_participant(account_id, participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/participants/{participantId}' _query_builder = APIHelper.append_url_with_template_parameter...
[ "def destroy\n @participant = Participant__c.find(params[:id])\n @participant.delete\n\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :ok }\n end\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List participants in a session.
def list_session_participants(account_id, session_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants' _query_builder = APIHelper.append_url_with_tem...
[ "def get_participants\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n users = meeting.participants\n send_json(users)\n else\n send_error 401\n end\n end", "def participants\n\n get_participant_map....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a participant to a session. Subscriptions can optionally be provided as part of this call.
def add_participant_to_session(account_id, session_id, participant_id, body: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts...
[ "def add_participant_to_session(account_id, session_id, participant_id, opts = {})\n add_participant_to_session_with_http_info(account_id, session_id, participant_id, opts)\n nil\n end", "def add_participant(participant_id)\n #TODO\n end", "def add_participant\n user = self.load_us...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove a participant from a session. This will automatically remove any subscriptions the participant has associated with this session.
def remove_participant_from_session(account_id, session_id, participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId...
[ "def remove_participant_from_session(account_id, session_id, participant_id, opts = {})\n remove_participant_from_session_with_http_info(account_id, session_id, participant_id, opts)\n nil\n end", "def unsubscribe\n participant = SportSessionParticipant.where(:user_id => params[:user_id], :sport_s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get a participant's subscriptions.
def get_participant_subscriptions(account_id, session_id, participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/part...
[ "def get_subscriptions\n get_subscriptions_from(@nodename)\n end", "def get_subscriptions_from_node\n iq = basic_pubsub_active_calls_query(:get)\n\n entities = iq.pubsub.add(REXML::Element.new('subscriptions'))\n entities.attributes['node'] = \"/me/#{@jid}\"\n\n res = []\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update a participant's subscriptions. This is a full update that will replace the participant's subscriptions. First call `getParticipantSubscriptions` if you need the current subscriptions. Call this function with no `Subscriptions` object to remove all subscriptions.
def update_participant_subscriptions(account_id, session_id, participant_id, body: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _que...
[ "def update_participant_subscriptions(account_id, session_id, participant_id, opts = {})\n update_participant_subscriptions_with_http_info(account_id, session_id, participant_id, opts)\n nil\n end", "def update_subscriptions(opts = {})\n data, _status_code, _headers = update_subscriptions_with_h...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
other sport name actions are scoped to venue; we need all possible sport names for all venues
def sport_name_options authorize :report sport_names = company.venues. flat_map { |venue| venue.supported_sports_options }. uniq { |hash| hash[:value] } render json: sport_names end
[ "def unusual_sport; end", "def national_sport; end", "def unusual_sport\n fetch('sport.unusual')\n end", "def venue_name\n venue ? venue.name : \"\"\n end", "def national_sport\n fetch('team.sport')\n end", "def winter_olympics_sport; end", "def summer_olympics_sport; end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds an HTTP header to the request
def add_http_header(key, value) @http_headers[key] = value end
[ "def add_headers\n @headers.each do |field, value|\n @request_header << \"#{field}: #{value}\"\n end\n end", "def add_headers value\n API.add_headers value\n end", "def http_header(k, v)\r\n @message_headers[\"http_header_#{k}\".to_sym] = v\r\n end", "def set_http_heade...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
load the workflow view
def show name = params[:name] action = params[:id] ? "show" : "index" action = params[:view] if params[:view].present? @page = ("Workflows::#{name.to_s.capitalize}::#{action.capitalize}").constantize.new(params, { user: current_user, cookies: cookies }) render(html: @page.item.display) and return ...
[ "def load_view\r\n @view = XamlReader.load_from_path view_path if File.exists? view_path\r\n @view ||= view_name.to_s.gsub(/(.*::)+/, '').classify.new \r\n @view\r\n end", "def load_view(path, parent, loader)\n sheet = Qt::File.new(path)\n sheet.open(Qt::File::ReadOnly)\n view = l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /evolutions/1 GET /evolutions/1.json
def show @evolution = Evolution.find(params[:id]) end
[ "def show\n @evolution = Evolution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evolution }\n end\n end", "def index\n @character_class_evolutions = CharacterClassEvolution.all\n\n render json: @character_class_evolutions\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
configures the target page (using a Dynarex document) for a new day
def new_day() puts 'inside new_day' if @debug @archive_path = Time.now.strftime("%Y/%b/%-d").downcase @indexpath = File.join(@filepath, @archive_path, 'index.xml') FileX.mkdir_p File.dirname(@indexpath) if FileX.exists? @indexpath then @dx = Dynarex.new @indexpath else puts 'cr...
[ "def setup_launching_soon_page\n @css_file = LAUNCHING_SOON_CONFIG[:css_file_name]\n @launching_date = Time.zone.parse(LAUNCHING_SOON_CONFIG[:launching_date]).utc\n render :template => File.join('launching_soon', LAUNCHING_SOON_CONFIG[:html_file_name]), :layout => \"launching_soon\"\n end", "def twenty_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
guesses random word of appropriate length
def guess_word(word_length) self.sample(dict.select { |word| word.length == word_length } ) end
[ "def random_word(difficulty)\n map = word_map()\n words = map[difficulty]\n words[rand(words.length)]\nend", "def ramdon_word(words_array)\n random_number = rand(0..words_array.length)\n word = words_array[random_number].gsub!(/\\r/, \"\")\n if word.length >= 5 && word.length <= 12\n return word.downcase...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds Single match via the supplied ID Usage: match = PUBG::Match(1337) Arguments: id: (Integer)
def match(id) self.get("/matches/#{id}") end
[ "def match(id_or_hash, hash={})\n url = Base + 'match'\n if id_or_hash.kind_of? String\n id = id_or_hash\n url += \"/#{id}\"\n params_hash = hash\n elsif id_or_hash.kind_of? Hash\n id = nil\n params_hash = id_or_hash\n else\n raise ArgumentError, \"first...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Builds the query that will be passed to the matches request, based on what options are supplied (if any)
def query_builder(options) parsed_options = [] options.each do |key,value| case key when :offset parsed_options << "page[offset]=#{value}" when :limit parsed_options << "page[limit]=#{value}" when :sort parsed_options << "sort=#{value}" when :cre...
[ "def build_query\n query = '?'\n query_hash = @entity.query\n return if query_hash.empty?\n query += \"$select=#{query_hash[:select]}&\" unless query_hash[:select].nil?\n query += \"$filter=#{query_hash[:filters]}&\" unless query_hash[:filters].nil?\n query += \"$orderby=#{...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Makes a Web Scrapper to get the twitter description
def fetch_twitter_informations unparsed_html = Nokogiri::HTML(open(twitter_profile_address)) self.twitter_username = fetch_twitter_username(unparsed_html) self.twitter_description = fetch_twitter_description(unparsed_html) end
[ "def scraper\n url = 'https://twitter.com/DataScienceCtrl' # This gets the url to scrape\n\n raw_page = HTTParty.get(url) # This is just used to get the page itself Nokogiri will do the rest\n\n parsed_page = Nokogiri::HTML(raw_page) # This puts it it into Nokogiri::XML::NodeSet\n # puts parsed_page # Pr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return all the elements containing currency input text field
def get_currency_input_field_elements elements(xpath: './/label[contains(text(),"Limit") or contains(text(), "Accounts Receivable") or contains(text(), "On Premises") or contains(text(), "Off Premises")]//following-sibling::app-currency-input/input[1]') end
[ "def get_sum_of_all_elements\n @logger.info(\"Searching element #{[value1, value2, value3, value4, value5]}\")\n allelements = @driver.find_elements(By.xpath(\"//*[contains(@id, 'txt_val_')]\"))\n\n if allelements.all? { |elem| elem.value.start_with?(\"$\") }\n elements = allelements...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Clear input field of all the elements containing currency input text field
def clear_currency_input_field_elements get_currency_input_field_elements.each do |ele| # This is a temporary work around for clearing the currency input field as '.clear' on element is not working ele.send_keys(:control, a) end end
[ "def clear_input\n @input_values.clear\n end", "def clear_input\n begin\n $results.log_action(\"#{@action}(#{@params[0]})\")\n @driver.find_element(:id, $session.form + @params[0]).clear\n $results.success\n rescue => ex\n $results.fail(\"#{@action}(#{@params[0]})\", ex)\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DNA to RNA Conversion Deoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T'). Ribonucleic acid, RNA, is the primary messenger molecule in cells. RNA differs slightly from DNA ...
def DNAtoRNA(dna) dna.gsub("T", "U") end
[ "def DNAtoRNA(dna)\n rna = dna.gsub('T', 'U')\n\n rna \nend", "def dna_to_rna(string)\n index = 0\n rna_strand = \"\"\n while index < string.length\n if string[index] == \"G\"\n rna_strand << \"C\"\n elsif string[index] == \"C\"\n rna_strand << \"G\"\n elsif string[index] == \"T\"\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Do a shelllike path lookup for prog_script and return the results. If we can't find anything return prog_script.
def whence_file(prog_script) if prog_script.index(File::SEPARATOR) # Don't search since this name has path separator components return prog_script end for dirname in ENV['PATH'].split(File::PATH_SEPARATOR) do prog_script_try = File.join(dirname, prog_script) return prog_script_try if File.exist?(p...
[ "def whence_file(prog_script)\n if prog_script.index(File::SEPARATOR)\n # Don't search since this name has path separator components\n return prog_script\n end\n\n ENV['PATH'].split(File::PATH_SEPARATOR).each do |dirname|\n prog_script_try = File.join(dirname, prog_script)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A method to convert an openlayersformat bbox string into an rgeo bbox object
def bbox_from_string(string, factory) return unless string minlon, minlat, maxlon, maxlat = string.split(',').collect { |i| i.to_f } bbox = RGeo::Cartesian::BoundingBox.new(factory) bbox.add(factory.point(minlon, minlat)).add(factory.point(maxlon, maxlat)) end
[ "def bbox_from_string(string, factory)\n return unless string\n minlon, minlat, maxlon, maxlat = string.split(',').collect(&:to_f)\n bbox = RGeo::Cartesian::BoundingBox.new(factory)\n bbox.add(factory.point(minlon, minlat)).add(factory.point(maxlon, maxlat))\n end", "def bbox_from_string(string, fact...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method: walk_automation_objects Purpose: Recursively walk and record the automation object hierarchy from $evm.root downwards Arguments: service_object Returns: A completed Struct::ServiceObject data structure
def walk_automation_objects(service_object) automation_object = Struct::ServiceObject.new(service_object.to_s, "", Array.new) if service_object.to_s == $evm.root.to_s automation_object.position = 'root' elsif service_object.to_s == $evm.parent.to_s automation_object.position = 'parent' elsif service_obj...
[ "def print_automation_objects(indent_level, hierarchy)\n case hierarchy.position\n when 'root'\n print_line(indent_level, \"#{hierarchy.obj_name} ($evm.root)\")\n when 'parent'\n print_line(indent_level, \"#{hierarchy.obj_name} ($evm.parent)\")\n when 'object'\n print_line(indent_level, \"#{hierarchy...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of walk_object_hierarchy Method: print_automation_objects Purpose: recursively walk & dump the service object hierarchy discovered by walk_automation_objects Arguments: hierarchy: the service object hierarchy indent_level: the indentation string Returns: Nothing
def print_automation_objects(indent_level, hierarchy) case hierarchy.position when 'root' print_line(indent_level, "#{hierarchy.obj_name} ($evm.root)") when 'parent' print_line(indent_level, "#{hierarchy.obj_name} ($evm.parent)") when 'object' print_line(indent_level, "#{hierarchy.obj_name} ($evm...
[ "def inspect_hierarchy(object_to_inspect, object_to_inspect_class)\n puts \"#{object_to_inspect} instance of \\\"#{object_to_inspect_class.name}\\\"\"\n\n print \"Hierarchy : \"\n object_to_inspect_class.ancestors.each do |ancestor|\n print \"#{ancestor} -> \"\n end\n puts\n puts \"#{Util::ge...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of walk_object_hierarchy Method: print_line Purpose: Wraps $evm.log(:info....) Arguments: indent_level: the indentation string string: the actual message to print Returns: Nothing
def print_line(indent_level, string) $evm.log("info", "#{$method}:[#{indent_level.to_s}] #{string}") end
[ "def print_automation_objects(indent_level, hierarchy)\n case hierarchy.position\n when 'root'\n print_line(indent_level, \"#{hierarchy.obj_name} ($evm.root)\")\n when 'parent'\n print_line(indent_level, \"#{hierarchy.obj_name} ($evm.parent)\")\n when 'object'\n print_line(indent_level, \"#{hierarchy...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of ping_attr Method: str_or_sym Purpose: format a string containing the argument correctly depending on whether the value is a symbol or string Arguments: value: the thing to be stringformatted Returns: string containing either ":value" or "'value'"
def str_or_sym(value) value_as_string = "" if value.is_a?(Symbol) value_as_string = ":#{value}" else value_as_string = "\'#{value}\'" end return value_as_string end
[ "def to_str(arg)\n if arg.is_a?(Symbol)\n \":\" + arg.to_s\n elsif arg.nil?\n \"nil\"\n elsif arg.is_a?(String)\n \"'#{arg}'\"\n else\n arg.to_s\n end\n end", "def attribute_name(sym_or_str)\n str = sym_or_str.to_s.downcase\n \n # Does str match 'something='? Sti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of str_or_sym Method: print_attributes Purpose: Print the attributes of an object Arguments: object_string : friendly text string name for the object this_object : the Ruby object whose virtual_column_names are to be dumped Returns: None
def print_attributes(object_string, this_object) begin # # Print the attributes of this object # if this_object.respond_to?(:attributes) print_line($recursion_level, "Debug: this_object.inspected = #{this_object.inspect}") if $debug if this_object.attributes.respond_to?(:keys) if t...
[ "def dump_attributes(object_string, this_object, indent_string)\n begin\n #\n # Print the attributes of this object\n #\n if this_object.respond_to?(:attributes)\n log(:info, \"#{indent_string}#{@method}: Debug: this_object.inspected = #{this_object.inspect}\") if @debug\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of print_attributes Method: print_virtual_columns Purpose: Prints the virtual_columns_names of the object passed to it Arguments: object_string : friendly text string name for the object this_object : the Ruby object whose virtual_column_names are to be dumped this_object_class : the class of the object whose assoc...
def print_virtual_columns(object_string, this_object, this_object_class) begin # # Only dump the virtual columns of an MiqAeMethodService::* class # if this_object.method_missing(:class).to_s =~ /^MiqAeMethodService.*/ # # Print the virtual columns of this object # virtual_col...
[ "def dump_virtual_columns(object_string, this_object, this_object_class, indent_string)\n begin\n #\n # Print the virtual columns of this object\n #\n if this_object.respond_to?(:virtual_column_names)\n log(:info, \"#{indent_string}#{@method}: --- virtual columns follow -...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End of print_virtual_columns Method: is_plural? Purpose: Test whether a string is plural (as opposed to singular) Arguments: astring: text string to be tested Returns: Boolean
def is_plural?(astring) astring.singularize != astring end
[ "def is_plural?(astring)\n astring.singularize != astring\n end", "def pluralize?(str)\n str.pluralize == str\n end", "def is_plural?(value)\n\t(value > 1) || (value < 1)\nend", "def plural?\n !singular?\n end", "def plural?\n self.class.pluralized || false\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }