query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Returns the number of lines that are visible
def num_lines_in_view() last_line_in_view() - first_line_in_view() + 1 end
[ "def visible_count\n (0..@len - 1).map{|y|\n (0..@len - 1).map{|x|\n visible?(y, x)\n }\n }.flatten.filter{|x| x}.count\n end", "def count\n return line_points.count\n end", "def visible\n\t\tres = []\n\t\ti = 0\n\t\twhile i < @lines.size\n\t\t\tres << i\n\t\t\ti += @lines[i].fol...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds 'amount' to all line indices with a current value greater than or equal to 'threshold'
def adjust_line_indices_after(threshold, amount) @line_indices.map! { |l| l >= threshold ? l + amount : l } end
[ "def add_threshold(file, operator, value)\n @threshold << [operator, file, value]\n end", "def threshold=(value)\n @threshold = value\n end", "def add_threshold(file, operator, value)\n if operator == :>=\n @gte << [file, value]\n end\n end", "def sum_thresh_low_dice dresul...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes the line numbered 'line_num'
def remove_line(line_num) if @line_indices == [] @text = "" else length = line_index(line_num + 1) - line_index(line_num) @text[line_index(line_num) + 1 .. line_index(line_num + 1)] = "" @line_indices.delete_at(line_num) (line_num...@line_indices.length).each { |i| @line_indices[i] -= length } end ...
[ "def noteboard_delete(line_number)\n \n\n end", "def remove_line(line)\n\t\t@lines.delete(line)\n\tend", "def removeLine(row_index)\n @board.delete_at(row_index)\n @board.unshift(emptyLine())\n end", "def strip_line_numbers(str_with_ruby_code)\n str_with_ruby_code.gsub(/ *\\d+: ? ?/, ''...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes from 'line_from', 'index_from' up to but not including 'line_to', 'index_to'
def remove_range(line_from, index_from, line_to, index_to) ix1 = index_of_position(line_from, index_from) ix2 = index_of_position(line_to, index_to) @text[ix1 ... ix2] = "" @line_indices.delete_if { |i| i.between?(ix1, ix2) } adjust_line_indices_after(ix2, -(ix2 - ix1)) end
[ "def remove_lines(start, stop) \n start, stop = parse_range(start, stop)\n if start > stop\n return \"start index must be larger than or equal to stop index\"\n end\n (start..stop).each{|index|\n line_removed(index)\n }\n @lines.slice!(start..stop)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets text from 'line_from', 'index_from' up to but not including 'line_to', 'index_to'
def get_range(line_from, index_from, line_to, index_to) ix1 = index_of_position(line_from, index_from) ix2 = index_of_position(line_to, index_to) @text[ix1 ... ix2] end
[ "def remove_range(line_from, index_from, line_to, index_to) \n\t\tix1 = index_of_position(line_from, index_from)\n\t\tix2 = index_of_position(line_to, index_to)\n\t\t@text[ix1 ... ix2] = \"\"\n\t\t@line_indices.delete_if { |i| i.between?(ix1, ix2) }\n\t\tadjust_line_indices_after(ix2, -(ix2 - ix1))\n\tend", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Inserts text 'text' at line 'line', before column 'col'
def insert_text(line, col, text) index = index_of_position(line, col) @text.insert(index, text) i = 0 i += 1 while i < @line_indices.length and @line_indices[i] < index (0...text.length).each do |c| if text[c,1] == "\n" @line_indices.insert(i, index + c) i += 1 end end (i ... @line_indices....
[ "def insert_text_at_cursor(text) \n\t\tinsert_text(@cursor_row, @cursor_col, text)\n\t\n\t\tif text.include?(\"\\n\")\n\t\t\t#todo what about multiple \\n's\n\t\t\t@cursor_row += 1\n\t\t\t@cursor_col = 0\n\t\t\t#resize_contents(500, line_num_to_coord(@text.num_lines + 1))\n\t\t\temit_changed(@cursor_row - 1)\n\t\te...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Changes the text of line 'line_num' to 'text
def change_line(line_num, text) raise "no newlines here yet please" if text =~ /\n/ ix1, ix2 = line_index(line_num) + 1, line_index(line_num + 1) @text[ix1...ix2] = text (line_num...@line_indices.length).each { |i| @line_indices[i] += text.length - (ix2 - ix1) } end
[ "def remove_line(line_num)\n\t\tif @line_indices == []\n\t\t\t@text = \"\"\n\t\telse\n\t\t\tlength = line_index(line_num + 1) - line_index(line_num)\n\t\t\t@text[line_index(line_num) + 1 .. line_index(line_num + 1)] = \"\"\n\t\t\t@line_indices.delete_at(line_num)\n\t\t\t(line_num...@line_indices.length).each { |i| ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the line numbered 'num' (first line is 0)
def line(num) lines(num, 1) end
[ "def line_number\n @current_line\n end", "def get_number(lines)\n lines.shift.to_i\n end", "def lineno\n ensure_open\n\n @lineno\n end", "def goto_line(num)\n\t\t\tgoto buffer.line_index(num)\n\t\tend", "def line(nb)\n return @lines[nb]\n end", "def line_id\n @line_number -...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns 'num' lines starting from line 'start'
def lines(start, num) @text[index_of_position(start)...index_of_position(start + num) - 1] end
[ "def take_lines(start_line, num_lines); end", "def take_lines(start_line, num_lines)\n start_idx =\n if start_line >= 0\n @lines.index { |loc| loc.lineno >= start_line } || @lines.length\n else\n [@lines.length + start_line, 0].max\n end\n\n alter do\n @line...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the cursor's position to 'row', 'col'
def set_cursor_position(row, col) invalid_rows = [@cursor_row, row] @cursor_row, @cursor_col = row, col if @cursor_row < first_line_in_view set_contents_pos(0, line_num_to_coord(@cursor_row)) emit_changed(nil) elsif @cursor_row > last_line_in_view set_contents_pos(0, line_num_to_coord(@cursor_row - num...
[ "def cursor_position=(params)\n col,row = params\n send_command( 0x47, col, row )\n end", "def restore_cursor_position() set_cursor_position(@event[\"line\"], @event[\"column\"]) end", "def update_pos\n # If cursor go right beyond the view.\n if @curs.col >= (@col + @cols) then\n # Set cursor ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Inserts text at the cursor's current position and updates cursor
def insert_text_at_cursor(text) insert_text(@cursor_row, @cursor_col, text) if text.include?("\n") #todo what about multiple \n's @cursor_row += 1 @cursor_col = 0 #resize_contents(500, line_num_to_coord(@text.num_lines + 1)) emit_changed(@cursor_row - 1) else @cursor_col += text.length emi...
[ "def insert_block(text, cursor = nil)\n mark = @view.buffer.selection_bound # get mark of cursor place\n iter = @view.buffer.get_iter_at(mark: mark) # get iter from mark\n text.gsub!(\"\\n\", \"\\n#{\" \" * iter.line_offset}\") # adjust indent of text (add space after line...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes the character before the cursor (like pressing backspace)
def backspace() #todo if @cursor_col > 0 line = line(@cursor_row) line[@cursor_col - 1.. @cursor_col - 1] = "" change_line(@cursor_row, line) @cursor_col -= 1 emit_changed(@cursor_row) end end
[ "def delete_current_character() \n\t\tif @selection_start != -1\n\t\t\tl1, i1 = index_line_and_col(@selection_start)\n\t\t\tl2, i2 = index_line_and_col(@selection_end)\n\t\t\tremove_range(l1, i1, l2, i2)\n\t\t\tclear_selection\n\t\t\temit_changed((l1...num_lines)) #todo\n\t\telse\n\t\t\tline = line(@cursor_row)\n\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes the character at the cursor (like pressing delete)
def delete_current_character() if @selection_start != -1 l1, i1 = index_line_and_col(@selection_start) l2, i2 = index_line_and_col(@selection_end) remove_range(l1, i1, l2, i2) clear_selection emit_changed((l1...num_lines)) #todo else line = line(@cursor_row) line[@cursor_col.. @cursor_col] = "...
[ "def delete_character\n @lines = lines.delete_character(y, x - 1)\n\n left\n\n refresh\n end", "def delete_character\n return self if document_start?\n\n if first_char? && y > 0\n delete_line\n\n return\n\n else\n @lines = lines.delete_char...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Highlights all instances of 'pattern' in the text
def highlight(pattern) pattern = Regexp.new(pattern) if pattern.is_a?(String) @highlights = [[0, Qt::black]] # todo factor this invalid_rows = [] (0...num_lines).each do |index| line = line(index) if line =~ pattern #todo #@highlights << HighlightData.new(index, $~.begin(0), index, $~.end(0), Qt::...
[ "def highlight(pattern, color=:light_yellow, &block)\n pattern = Regexp.new(Regexp.escape(pattern)) if pattern.is_a? String\n\n if block_given?\n gsub(pattern, &block)\n else\n gsub(pattern) { |match| match.send(color) }\n end\n end", "def highlight(keywords, replacement_pattern)\n s = s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /api/v1/poll_responses GET /api/v1/poll_responses.json
def index @api_v1_poll_responses = Api::V1::PollResponse.all end
[ "def show\n @poll_response = PollResponse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_response }\n end\n end", "def index\n @api_v1_polls = Api::V1::Poll.all\n end", "def polster\n\t\turi =\"http://elections.huffingtonpost...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /api/v1/poll_responses POST /api/v1/poll_responses.json
def create @api_v1_poll_response = Api::V1::PollResponse.new(api_v1_poll_response_params) respond_to do |format| if @api_v1_poll_response.save format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully created.' } format.json { render :show, status: :created,...
[ "def create\n @poll_response = PollResponse.new(params[:poll_response])\n\n respond_to do |format|\n if @poll_response.save\n format.html { redirect_to @poll_response, notice: 'Poll response was successfully created.' }\n format.json { render json: @poll_response, status: :created, location...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /api/v1/poll_responses/1 PATCH/PUT /api/v1/poll_responses/1.json
def update respond_to do |format| if @api_v1_poll_response.update(api_v1_poll_response_params) format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully updated.' } format.json { render :show, status: :ok, location: @api_v1_poll_response } else form...
[ "def update_single_poll(id,polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n raise \"polls__que...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /api/v1/poll_responses/1 DELETE /api/v1/poll_responses/1.json
def destroy @api_v1_poll_response.destroy respond_to do |format| format.html { redirect_to api_v1_poll_responses_url, notice: 'Poll response was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @poll_response = PollResponse.find(params[:id])\n @poll_response.destroy\n\n respond_to do |format|\n format.html { redirect_to poll_responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_poll.destroy\n respond_to do |format|\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the folder at the root of the task scheduler
def root_folder scheduler_service.GetFolder("\\") end
[ "def job_folder\n File.join(Session.current.root, job_key)\n end", "def working_directory\n check_for_active_task\n\n dir = nil\n\n @task.Definition.Actions.each do |action|\n dir = action.WorkingDirectory if action.Type == 0\n end\n\n dir\n end", "def run_dir\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Load a local profile return the SharedCredentials object or nil
def loadProfile(profile=nil) # CAUTION: We are returning if profile is nil because otherwise AWS will try to use "Default" profile return nil if profile.nil? begin #ruby syntax equivalant to try # Read the credentials from the given profile credentials = Aws::SharedCredentials.new(profile_name: profile) ...
[ "def load_creds\n load_creds! rescue nil\n end", "def load_credentials\n open(path, 'r') { |f| JSON.parse(f.read) }\n rescue\n nil\n end", "def loadProfile()\n $profile_path.each { |file| \n if file and File.file?(file)\n puts \"Loading profile %s\\n\" % [File.realpath(file)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
helper function to return a new RDS client
def createRDSClient(region,credentials) begin return Aws::RDS::Client.new(region: region,credentials: credentials) rescue Exception => e puts "\e[31mCould not create new RDS client." puts "#{e.message}\e[0m" exit 1 end end
[ "def new_client\n Mysql2::Client.new(username: @username, password: @password, database: @database, host: @host)\n end", "def new_client\n Client.new(self)\n end", "def aws_client\n Mnemosyne::Clients::RDS.instance\n end", "def new_client(credentials)\n safely do\n return SBCCl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
helper function to return a new EC2 client
def createEC2Client(region,credentials) begin return Aws::EC2::Client.new(region: region,credentials: credentials) rescue Exception => e puts "\e[31mCould not create new EC2 client" puts "#{e.message}\e[0m" exit 1 end end
[ "def client\n @client ||= EC2::Client.new(region: region)\n rescue Errors::ServiceError\n raise\n rescue\n raise Errors::EnvironmentError, 'Unable to initialize EC2 client'\n end", "def initiate_aws_ec2_client(options)\n begin\n ec2 = Aws::EC2::Client.new(\n :region ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper function to create a snapshot of an EBS volume
def createEBSSnapshot(client=nil,description='',volume_id=nil) return false if volume_id.nil? || client.nil? # Fetch the Volume Name. This will be used in the description of the snapshot resp = client.describe_volumes({dry_run: false, volume_ids: [volume_id] }) resp.volumes[0].tags.each do |t| if t.key=='Na...
[ "def create_snapshot\n @snapshot = ec2.volumes[volume_id].\n create_snapshot(\"#{description}\")\n message.info \"Created snapshot \\\"#{snapshot.id}\\\"\"\n tag_snapshot\n return @snapshot\n end", "def create_volume_from_snapshot(snapshot_id, availability_zone)\n post_message(\"going to crea...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
helper function to create RDS Snapshots return the response on success, otherwise false.
def createRDSSnapshot(client=nil,db_instance=nil,snapshot_name=nil,tags=[]) return false if db_instance.nil? || client.nil? if snapshot_name.nil? snapshot_name="#{db_instance}-#{Time.now.to_i}" end unless tags.instance_of? Array puts "\e[31mtags must be an Array\e[0m" return false end begin ...
[ "def create_snapshot(rds_resource, db_instance_name)\n id = \"snapshot-#{rand(10**6)}\"\n db_instance = rds_resource.db_instance(db_instance_name)\n db_instance.create_snapshot({\n db_snapshot_identifier: id\n })\nrescue Aws::Errors::ServiceError => e\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /discipline_sections GET /discipline_sections.json
def index @discipline_sections = DisciplineSection.all end
[ "def index\n @course = Course.find(params[:course_id])\n @disciplines = Discipline.where(:course_id => params[:course_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @disciplines }\n end\n end", "def get_exam_sections(user_id, course_id, exam_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /discipline_sections POST /discipline_sections.json
def create @discipline_section = DisciplineSection.new(discipline_section_params) respond_to do |format| if @discipline_section.save #format.html { redirect_to @discipline_section, notice: 'Discipline section was successfully created.' } #format.json { render :show, status: :created, locat...
[ "def index\n @discipline_sections = DisciplineSection.all\n end", "def create_sections; end", "def create\n @course = Course.find(params[:course_id])\n @course_section = @course.course_sections.new(params[:course_section])\n\n respond_to do |format|\n if @course_section.save\n format.ht...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /discipline_sections/1 PATCH/PUT /discipline_sections/1.json
def update respond_to do |format| if @discipline_section.update(discipline_section_params) format.html { redirect_to @discipline_section, notice: 'Раздел дисциплины был успешно обновлен' } format.json { render :show, status: :ok, location: @discipline_section } else format.html {...
[ "def update\n @userdisciplines = UserDisciplines.find(params[:id])\n\n respond_to do |format|\n if @userdisciplines.update_attributes(params[:discipline])\n format.html { redirect_to @userdisciplines, notice: t(:discipline_successfully_updated) }\n format.json { head :ok }\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete bean from scope
def delete_bean(bean_metadata) RequestStore.store[:_iocrb_beans].delete(bean_metadata.name) end
[ "def delete_bean(bean_metadata)\n end", "def delete_bean(bean_metadata)\n @beans.delete(bean_metadata.name)\n end", "def delete_beancount\n current_user.delete_beancount\n end", "def destroy\n @bean.destroy\n respond_to do |format|\n format.html { redirect_to farm_beans_url }\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetch our current inheritable settings, which are inherited by nested scopes but not shared across siblings.
def inheritable_setting @inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting } end
[ "def inheritable_settings\n return @inheritable_settings\n end", "def settings\n @settings ||= (parent&.settings || Settings).for(self)\n end", "def build_top_level_setting\n if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fork our inheritable settings to a new instance, copied from our parent's, but separate so we won't modify it. Every call to this method should have an answering call to namespace_end.
def namespace_start @inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting } end
[ "def inherited(subclass)\n subclass.settings = settings.dup unless settings.nil?\n end", "def point_in_time_copy\n self.class.new.tap do |new_setting|\n point_in_time_copies << new_setting\n new_setting.point_in_time_copies = []\n\n new_setting.namespace = namespa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Builds the current class :inheritable_setting. If available, it inherits from the superclass's :inheritable_setting.
def build_top_level_setting Grape::Util::InheritableSetting.new.tap do |setting| # Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to # +inheritable_setting+, however, it doesn't contain any user-defined settings. # Otherwise, it would lead to an ext...
[ "def inheritable_setting\n @inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting }\n end", "def build_top_level_setting\n if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates the RBS lines for this method.
def generate_rbs(indent_level, options) definition = "def #{class_method ? 'self.' : ''}#{name}: " lines = generate_comments(indent_level, options) # Handle each signature signatures.each.with_index do |sig, i| this_sig_lines = [] # Start off the first line of the s...
[ "def get_ruling_lines!\n self.get_rulings\n end", "def generate_rbs(indent_level, options) \n lines = generate_comments(indent_level, options)\n lines << options.indented(indent_level, \"module #{name}\")\n lines += generate_body(indent_level + 1, options)\n lines << options...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This object's stroke alpha value
def stroke_alpha dsl&.stroke&.alpha end
[ "def stroke_alpha\n dsl.stroke.alpha if dsl.stroke\n end", "def alpha\n @color.alpha\n end", "def alpha=(val)\n @color.alpha = val\n end", "def alpha\n @rgb.a\n end", "def alpha\n (rgba & 0x7F000000) >> 24\n end", "def fill_alpha\n fill.alpha\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /question_option_selections GET /question_option_selections.json
def index @question_option_selections = @question_answer.question_option_selections end
[ "def index\n\t\tselections = Selection.all\n\n\t\trespond_to do |format|\n\t\t\tformat.json { render :json => selections }\n\t\tend\n\tend", "def index\n @selections = Selection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @selections }\n end\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /question_option_selections POST /question_option_selections.json
def create @question_option_selection = @question_answer.question_option_selection.build(question_option_selection_params) respond_to do |format| if @question_option_selection.save format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question optio...
[ "def index\n @question_option_selections = @question_answer.question_option_selections\n end", "def add_option\n render json: Option.create_default_option(params[:question_id])\n end", "def add_others_option\n render json: Option.add_others_option(params[:question_id])\n end", "def cre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /question_option_selections/1 PATCH/PUT /question_option_selections/1.json
def update respond_to do |format| if @question_option_selection.update(question_option_selection_params) format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully updated.' } format.json { render :show, stat...
[ "def update\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n if @questions_option.update_attributes(params[:questions_option])\n format.html { redirect_to @questions_option, notice: 'Questions option was successfully updated.' }\n format.json { head :no_c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Encodes a list of traces in chunks. Before serializing, all traces are normalized. Trace nesting is not changed.
def encode_in_chunks(traces) encoded_traces = if traces.respond_to?(:filter_map) # DEV Supported since Ruby 2.7, saves an intermediate object creation traces.filter_map { |t| encode_one(t) } else ...
[ "def encode_traces(encoder, traces)\n trace_hashes = traces.map do |trace|\n encode_trace(trace)\n end\n\n # Wrap traces & encode them\n encoder.encode(traces: trace_hashes)\n end", "def encode_traces(traces)\n to_send = []\n traces.e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The alphabet is a series of characters used to create the bijection E.g: "wrdcuyjpbiflaqzesgmhvtknxo" The booster is used to avoid generating sequences that are too short E.g: If booster is zero then encoding an id close to zero will produce only one character. If you want a minimum of three then you should set your bo...
def initialize(alphabet, booster = 0) raise ArgumentError, "You must provide an alphabet" if alphabet.blank? @alphabet = alphabet @booster = booster end
[ "def encode(number)\n i = number + @booster\n return @alphabet[0] if i == 0\n s = StringIO.new\n base = @alphabet.length\n while i > 0\n s << @alphabet[i.modulo(base)]\n i /= base\n end\n s.string.reverse\n end", "def scramble\n alphabet = (\"a\"..\"z\").to_a\n p string.chars...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Transform an integer into a unique string using the engine alphabet and booster
def encode(number) i = number + @booster return @alphabet[0] if i == 0 s = StringIO.new base = @alphabet.length while i > 0 s << @alphabet[i.modulo(base)] i /= base end s.string.reverse end
[ "def obfuscate_id_default_spin\n alphabet = Array(\"a\"..\"z\")\n number = name.split(\"\").collect do |char|\n alphabet.index(char)\n end\n\n number.shift(12).join.to_i\n end", "def obfuscate_id_default_spin\n alphabet = Array(\"a\"..\"z\") \n number = name.split(\"\").col...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
load xml rules as a string
def load_xml_rules_as_string( str ) begin doc = REXML::Document.new str doc.elements.each( "rule-set") { |rs| facts = rs.elements.each( "facts") { |f| facts( f.attributes["name"] ) do f.text.strip end } rules = rs.elements.each( "rule"...
[ "def load_rb_rules_as_string( str )\r\n instance_eval(str) \r\n end", "def load_rules\n @rules = RuleDsl.load(File.join(File.dirname(__FILE__), 'rules.rb'))\n end", "def load_rules\n @rules = RuleDsl.load([File.join(File.dirname(__FILE__), 'rules.rb')] +\n @last_options[:include_r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
load ruby rules as a string
def load_rb_rules_as_string( str ) instance_eval(str) end
[ "def load_rules\n @rules = RuleDsl.load([File.join(File.dirname(__FILE__), 'rules.rb')] +\n @last_options[:include_rules], @last_options[:repl])\n end", "def load_rules\n @rules = RuleDsl.load(File.join(File.dirname(__FILE__), 'rules.rb'))\n end", "def load_rules(rules)\n self.instan...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns an array of facts
def get_facts @facts end
[ "def facts\n @facts\n end", "def list\n load_all\n return @facts.keys\n end", "def facts\n @facts ||= compute_facts\n end", "def list\n load_all\n @facts.keys\n end", "def all_facts\n @facts.values.collect { |property_facts| property_facts.values }.flatten\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A single fact can be an single object of a particular class type or a collection of objects of a particular type
def fact( obj ) #begin # check if facts already exist for that class # if so, we need to add it to the existing list cls = obj.class.to_s.downcase cls.gsub!(/:/, '_') if @facts.key? cls logger.debug( "adding to facts: #{cls}") if logger @facts[cl...
[ "def fact_class\r\n owning_class\r\n end", "def fact_class\n cube.class.fact_class\n end", "def fact_class\n fact_class_name.constantize\n end", "def fact_class\n cube_class.fact_class\n end", "def find\n if collection?\n prefind_collection\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete all existing facts
def delete_facts @facts = {} end
[ "def delete_all\n each(&:delete)\n end", "def delete_all\n @configuration = nil\n end", "def delete_all\n with_associations {|t,_| t.delete_all}\n end", "def destroy_all\n find(:all).each do |object|\n object.destroy\n end\n end", "def destroy_all\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Stops the current assertion. Does not indicate failure.
def stop(message = nil) @assert = false end
[ "def stop_test(test)\n puts \"Test was stopped mid execution: #{test.uri}\"\n end", "def stop_test_case\n return logger.error { \"Could not stop test case, no test case is running\" } unless @current_test_case\n\n logger.debug { \"Stopping test case: #{@current_test_case.name}\" }\n @current_te...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Stops the current assertion and change status to :fail
def fail(message = nil) @status = FAIL @assert = false end
[ "def stop(message = nil)\r\n @assert = false\r\n end", "def fail_now\n fail\n raise TestFail\n end", "def assert_failure?\n @__state[:option][:assert_abort]\n end", "def test_end_fail\r\n \t@test_prospector.move_count = 1\r\n \tassert_equal false, @test_prospector.end?\r\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
for a particular fact, we need to retrieve the relevant rules and add them to the relevant list
def add_relevant_rules_for_fact fact @rules.values.select { |rule| if !@relevant_rules.include?( rule) if rule.parameters_match?(fact.value) @relevant_rules << rule logger.debug "#{rule} is relevant" if logger else logger.debug "#...
[ "def get_relevant_rules\r\n @relevant_rules = Array.new\r\n @facts.each { |k,f| \r\n add_relevant_rules_for_fact f\r\n }\r\n sort_relevant_rules\r\n end", "def rules_from_step_content\n @rules_from_step_content ||= content_items.each_with_object({}) do |content_item, items|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
relevant rules need to be sorted in priority order
def sort_relevant_rules # sort array in rule priority order @relevant_rules = @relevant_rules.sort do |r1, r2| r2.priority <=> r1.priority end end
[ "def sort_rules\n @rules.sort_by! { |rule| [rule.priority, rule.name] } \n end", "def by_priority\n @rules.sort_by(&:priority)\n end", "def optimize_order!(rules)\n first_can_in_group = -1\n rules.each_with_index do |rule, i|\n (first_can_in_group = -1) && next unless...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get all relevant rules for all specified facts
def get_relevant_rules @relevant_rules = Array.new @facts.each { |k,f| add_relevant_rules_for_fact f } sort_relevant_rules end
[ "def get_rules\n # ensure we substitute all variables\n substitute_variables if @string_to_var\n @rules\n end", "def find_applicable_rules(rules)\n # select rules which ticktes exist in this domain\n rules.select do |rule|\n rule.input_tickets.pieces.all? do |ticket|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
evaluate all relevant rules for specified facts
def evaluate @status = PASS @assert = true @num_executed = 0; @num_evaluated = 0; get_relevant_rules() logger.debug("no relevant rules") if logger && @relevant_rules.size==0 #begin #rescue # loop through the available_rules, evaluating ...
[ "def evaluate\n #Clone the rule base so we aren't adding new facts to the actual rule base\n rb = self.rule_base.clone\n #Add new facts and evaluate\n new_facts.each {|fact| rb.add_fact(fact)} unless new_facts.nil?\n rb.evaluate\n if type == DETERMINE_TRUTH\n return nil if rb.facts.nil? #No f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
lookup app name either in the file or if already cached look in the metadata variable
def lookup(app_name) unless @metadata.key?(app_name) data = YAML.load_file("./data/applications/#{app_name}.yaml") @metadata[app_name] = data['cots::app_metadata'] end @metadata[app_name] end
[ "def app_name\n @app_name ||= package_json['name']\n end", "def fetch_app_details\n # Extract app_id\n app_id = Nutella.current_app.config['name']\n return app_id, Dir.pwd\n end", "def find_application_name(val_installpath)\n index_file = ['index.html','index.htm','index.php','index...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
s.request(link) do|success,body| body if success end
def request(link, &blk) link = hook(link) log "request: #{link} -> #{blk.inspect}" @multi.add( Curl::Easy.new(link) do|c| c.follow_location = true c.headers["User-Agent"] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.1 Sa...
[ "def make_get_request(uri)\n response = Net::HTTP.get_response(uri)\n response.is_a?(Net::HTTPSuccess) ? response.body : nil\nend", "def do_request url\n Nokogiri::HTML(HTTParty.get(url))\nend", "def parse(uri, response, body); end", "def test_link(link, resource=nil)\n # If the result method can't ma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End point: (PATCH) Usage: FundAmerica::Entity.update(entity_id, options) Output: Updates an entity person or company Uses test_mode update when used in sandbox mode
def update(entity_id, options) API::request(:patch, "entities/#{entity_id}", options) end
[ "def update(entity_id, options)\n end_point_url = FundAmerica.base_uri + \"#{FundAmerica.mode == 'sandbox' ? 'test_mode/' : ''}\" + \"entities/#{entity_id}\"\n API::request(:patch, end_point_url, options)\n end", "def update\n @options[:body] = @entity.attrs[:body]\n @options[:headers...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End point: (GET) Usage: FundAmerica::Entity.details(entity_id), request options &_expand[]=1 Output: Returns the details of an entity with matching id
def details(entity_id, request_options = "") API::request(:get, "entities/#{entity_id}" + request_options) end
[ "def details(entity_id, request_options = \"\")\n API::request(:get, FundAmerica.base_uri + \"entities/#{entity_id}\" + request_options)\n end", "def details(entity)\n details_by_type_and_name(entity.properties[:type], entity.properties[:name])\n end", "def details(entity_relationship_id)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End point: (GET) Usage: FundAmerica::Entity.ach_authorizations(entity_id) Output: Returns ACH authorizations of an entity
def ach_authorizations(entity_id) API::request(:get, "entities/#{entity_id}/ach_authorizations") end
[ "def ach_authorizations(entity_id)\n API::request(:get, FundAmerica.base_uri + \"entities/#{entity_id}/ach_authorizations\")\n end", "def details(ach_authorization_id)\n API::request(:get, \"ach_authorizations/#{ach_authorization_id}\")\n end", "def list_authorizations\n _client.aut...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End point: (GET) Usage: FundAmerica::Entity.cash_blotter(entity_id)
def cash_blotter(entity_id) API::request(:get, "entities/#{entity_id}/cash_blotter") end
[ "def cash_blotter(entity_id)\n API::request(:get, FundAmerica.base_uri + \"entities/#{entity_id}/cash_blotter\")\n end", "def bank_transfer_method(entity_id)\n API::request(:get, FundAmerica.base_uri + \"entities/#{entity_id}/bank_transfer_methods\")\n end", "def bank_transfer_method(ent...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End point: (GET) Usage: FundAmerica::Entity.investor_suitability_details(entity_id)
def investor_suitability_details(entity_id) API::request(:get, "entities/#{entity_id}/investor_suitability") end
[ "def investor_suitability_details(entity_id)\n API::request(:get, FundAmerica.base_uri + \"entities/#{entity_id}/investor_suitability\")\n end", "def investor_suitability_update(entity_id, options)\n API::request(:patch, FundAmerica.base_uri + \"entities/#{entity_id}/investor_suitability\", opt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End point: (PATCH) Usage: FundAmerica::Entity.investor_suitability_update(entity_id, options)
def investor_suitability_update(entity_id, options) API::request(:patch, "entities/#{entity_id}/investor_suitability", options) end
[ "def investor_suitability_update(entity_id, options)\n API::request(:patch, FundAmerica.base_uri + \"entities/#{entity_id}/investor_suitability\", options)\n end", "def update(investor_id, options)\n end_point_url = FundAmerica.base_uri + \"#{FundAmerica.mode == 'sandbox' ? 'test_mode/' : ''}\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
End point: (GET) Usage: FundAmerica::Entity.investor_payments(entity_id)
def investor_payments(entity_id) API::request(:get, "entities/#{entity_id}/investor_payments") end
[ "def investor_payments(entity_id)\n API::request(:get, FundAmerica.base_uri + \"entities/#{entity_id}/investor_payments\")\n end", "def investment_payments(investment_id)\n API::request(:get, \"investments/#{investment_id}/investment_payments\")\n end", "def investor_payments(distributio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(GET) Usage: FundAmerica::Entity.bank_transfer_methods Output: Returns Bank Transfer Method informations of an entity
def bank_transfer_method(entity_id) API::request(:get, "entities/#{entity_id}/bank_transfer_methods") end
[ "def bank_transfer_method(entity_id)\n API::request(:get, FundAmerica.base_uri + \"entities/#{entity_id}/bank_transfer_methods\")\n end", "def fetch_banks\n base_url = rave_object.base_url\n response = get_request(\"#{base_url}#{BASE_ENDPOINTS::BANKS_ENDPOINT}\", {:json => 1})\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(GET) Usage: FundAmerica::Entity.child_entities Output: Returns child entities of an entity
def child_entities(entity_id) API::request(:get, "entities/#{entity_id}/child_entities") end
[ "def child_entities\n entities = Array.new\n\n self.class.child_entities.each do |field|\n value = instance_variable_get '@' + field\n\n if value.is_a? Entity\n entities.push value\n\n # Hashes\n elsif value.is_a? Hash\n entities.concat filter_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(GET) Usage: FundAmerica::Entity.parent_entities Output: Returns parent entities of an entity
def parent_entities(entity_id) API::request(:get, "entities/#{entity_id}/parent_entities") end
[ "def parents\n @parents ||= Array(nesting).collect do |p|\n if p.is_a?(Class) && p < ActiveRecord::Base\n parent_entry(p)\n else\n p\n end\n end\n end", "def parents\n @parents ||= Array(nesting).map do |p|\n if p.is_a?(Class) && p < ActiveRecord::Ba...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(GET) Usage: FundAmerica::Entity.relationships_as_child Output: Returns relationships_as_child details for entity
def relationships_as_child(entity_id) API::request(:get, "entities/#{entity_id}/relationships_as_child") end
[ "def child_rels(*args)\n options = args.extract_options!\n rels = relationships.flat_map(&:children).uniq\n Relationship.filter_by_resource_type(rels, options)\n end", "def child_ontology_relationships(options = {}) # :yields: Array of OntologyRelationships\n opt = {\n :relationship_type => 'all...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(GET) Usage: FundAmerica::Entity.relationships_as_parent Output: Returns relationships_as_parent details for entity
def relationships_as_parent(entity_id) API::request(:get, "entities/#{entity_id}/relationships_as_parent") end
[ "def relationships_as_child(entity_id)\n API::request(:get, \"entities/#{entity_id}/relationships_as_child\")\n end", "def relation_to_parent\n _response_word.fetch(\"relationToParent\", nil)\n end", "def relationship_ancestry(*args)\n stringify_options = args.extract_options!\n option...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(GET) Usage: FundAmerica::Entity.investor_accreditation Output: Returns entity specific investor accreditation information
def investor_accreditation(entity_id) API::request(:get, "entities/#{entity_id}/investor_accreditation") end
[ "def index\n @accreditations = Accreditation.all\n end", "def course_accreditations(institution, course, kismode, options={})\n self.class.get(\"/Institution/#{institution}/Course/#{course}/#{kismode}/Accreditation.json\", options).parsed_response\n end", "def set_accreditation\n @accreditation = Acc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
(GET) Usage: FundAmerica::Entity.platform_investor Output: Returns entity specific platform_investor information Note: FA platform investor information will also be included with investor information
def platform_investor(entity_id ) API::request(:get, "entities/#{entity_id}/platform_investor") end
[ "def details(investor_id)\n API::request(:get, \"investors/#{investor_id}\")\n end", "def platform_details\n data[:platform_details]\n end", "def details\n get(\"platform/details\")[\"platform\"]\n end", "def platform_details\n @platform_details ||= @platform.details\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Logs an incoming GET WEBrick request.
def do_GET(request, _response) log_request(request) end
[ "def do_GET(request, _response)\n log_request(request)\n end", "def log_request; end", "def global_request_logging \n http_request_header_keys = request.headers.keys.select{|header_name| header_name.match(\"^HTTP.*\")}\n http_request_headers = request.headers.select{|header_name, header_value| htt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Logs and parses an incoming POST request. Parses `multipart/formdata` and `application/json` contenttypes. Parsed requests are added to the requests list.
def do_POST(request, response) @aspecto_repeater.repeat request @bugsnag_repeater.repeat request # Turn the WEBrick HttpRequest into our internal HttpRequest delegate request = Maze::HttpRequest.new(request) content_type = request['Content-Type'] if %r{^multipart/form-...
[ "def do_POST(request, response)\n log_request(request)\n case request['Content-Type']\n when %r{^multipart/form-data; boundary=([^;]+)}\n boundary = WEBrick::HTTPUtils::dequote($1)\n body = WEBrick::HTTPUtils.parse_form_data(request.body, boundary)\n hash = {\n body: bod...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks the BugsnagIntegrity header, if present, against the request and based on configuration. If the header is present, if the digest must be correct. However, the header need only be present if configuration says so.
def check_digest(request) header = request['Bugsnag-Integrity'] if header.nil? && Maze.config.enforce_bugsnag_integrity && %i[sessions errors traces].include?(@request_type) raise "Bugsnag-Integrity header must be present for #{@request_type} according to Maze.config.enforce_bugsnag_integrity...
[ "def valid_bugsnag_integrity_header(request)\n header = request[:request]['Bugsnag-Integrity']\n return !Maze.config.enforce_bugsnag_integrity if header.nil?\n\n digests = request[:digests]\n if header.start_with?('sha1')\n computed_digest = \"sha1 #{digests[:sha1]}\"\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add planet to array
def planet_add(planet) @planets.push(planet) return @planets end
[ "def add_planets(new_planet_array)\n @planets.concat(new_planet_array)\n end", "def add_planet (planet)\n @planets << planet\n end", "def add_new_planet(planet)\n @solar_system << planet\n end", "def add new_planet\n @planets << new_planet\n end", "def add_planet_list (planet_list)\n @pla...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
pp get_mystates_from_highstate('module','chocolatey','bootstrap') pp get_mystates_from_highstate('module','user','current') pp get_mystates_from_highstate('state','system','hostname')
def get_highstate_from_minion if defined?(@cache_highstate_from_minion) Inspec::Log.debug('Returning cached @cache_highstate_from_minion.') return @cache_highstate_from_minion end # ingest_from_minion('yaml', 'C:\salt\salt-call.bat --config-dir=C:\Users\vagrant\AppData\Local\Temp\kitchen\etc\salt state.sh...
[ "def print_state(machine)\n puts \"[#{machine[:stack]}, #{machine[:register]}]\"\nend", "def known_states; end", "def service_states\n svcs(\"-H\", \"-o\", \"state,nstate\", @resource[:name]).chomp.split\n end", "def system_state\n get_request(\"/system/state\")\n end", "def state_machines\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
example: get_saltstack_package_full_name('7zip') = '7Zip'
def get_saltstack_package_full_name(package) # pillar = YAML.safe_load(File.read('test/salt/pillar/windows.sls')) url = 'https://raw.githubusercontent.com/saltstack/salt-winrepo-ng/master/' files = [package + '.sls', package + '/init.sls'] # example: package = "7zip"=>{"version"=>"18.06.00.0", "refresh_minion_e...
[ "def package_name()\n\t\t\t\tpackage_name = self.class.name.to_s\n\t\t\t\tpackage_name = package_name.gsub(/^(.+?)(Package)?$/, '\\1')\n\t\t\t\treturn package_name\n\t\t\tend", "def package_name\n name = package_drop_last(slug_parts)\n name.empty? ? '_root_' : name\n end", "def package_name\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instance methods collection/key/graph Gets the graph for the specified kind of relation.
def orchio_get_graph(kind) # add_relation_kind kind if cache.enabled? and response = cache_request.get_graph(id, kind) if response.header.status == :cache docs = response.body.documents count = docs.length end else response = client.send_request :get, inst_a...
[ "def each_relation_graph\n return enum_for(__method__) unless block_given?\n\n relation_graphs.each do |k, g|\n yield(g) if g.has_vertex?(self) && (k == g)\n end\n end", "def task_relation_graph_for(model)\n task_relation_graphs...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a graph/relation to the collection. Store the to_key's 'ref' value if caching is enabled.
def orchio_put_graph(kind, to_collection, to_key) # add_relation_kind kind if cache.enabled? ref = simple_cache.get_ref to_collection, to_key simple_cache.get_cc(ocollection).save_graph Metadata.new( { from_key: @id, kind: kind, ref: ref } ) end response = cli...
[ "def put_relation(collection, key, kind, to_collection, to_key)\n send_request :put, [collection, key, 'relation', kind, to_collection, to_key]\n end", "def add_reference(reference_data, key: nil, ref: nil)\n reference = build_reference(reference_data, ref)\n specific_references = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the ref value for the current instance. The ref value is an immutable value assigned to each version of primary_key data in an orchestrate.io collection.
def orchestrate_ref_value __ref_value__ end
[ "def reference\n value_for('reference')\n end", "def reference_key\n options.fetch(:reference_key) { owner.identity.name }\n end", "def reference\n first('ref_ssm') || fetch('id')\n end", "def reference\n @reference ||= Reference.where(FeedXrefKey: self.OrderKey).to_a.first\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
After a successful PUT request, updates the current instance's ref value (also referred to as the etag) and calls orchio_update_ref_table.
def set_ref_value(response) unless response.header.code != 201 || response.header.etag.blank? @__ref_value__ = response.header.etag orchio_update_ref_table response.header.timestamp end end
[ "def orchio_update_ref_table(timestamp)\n return if ocollection == RefTable.get_collection_name\n\n if RefTable.enabled?\n primary_key = __ref_value__.gsub(/\"/, '')\n doc = {\n xcollection: ocollection,\n xkey: id,\n xref: primary_key,\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates the ref table collection with key/value data consisting of the current instance's collection, key, timestamp and ref values , using the ref value as the primary key. When the ref table feature is enabled, the ref table is updated after each sucessful put_key request.
def orchio_update_ref_table(timestamp) return if ocollection == RefTable.get_collection_name if RefTable.enabled? primary_key = __ref_value__.gsub(/"/, '') doc = { xcollection: ocollection, xkey: id, xref: primary_key, ti...
[ "def store_key_references; end", "def store_key_references=(_arg0); end", "def update_reference_ids\n self.copy_tables.each do |t|\n rows = no_sql_connection.select_rows(t.name)\n Mongify::Status.publish('update_references', :size => rows.count, :name => \"Updating References #{t.name}\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns handle to the SimpleCacheStore singleton instance.
def simple_cache @@cache_store end
[ "def cache\n @@cache ||= SimpleCacheStore.instance\n end", "def cache_store\n Rails.cache\n end", "def cache_store\n ActionController::Base.cache_store\n end", "def store_instance\n if defined? @store and defined? @@stores[@store] then \n @@stores[@store] \n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
puts num_of_ones puts num_of_twos puts num_of_ones num_of_twos PART TWO example = '0222112222120000' layers = split_into_layers(example, width: 2, height: 2) print_layers layers
def flatten_layers(layers) layers = layers.reverse display = layers[0] layers.slice(1..-1).each do |layer| layer.each_with_index do |row, y| row.each_with_index do |digit, x| display[y][x] = digit unless digit == 2 end end end return display end
[ "def layers(wide, tall, data)\n layer_width = wide * tall\n layers_count = (data.length / layer_width)\n\n (0...layers_count).map { |layer|\n offset = layer * layer_width\n\n data\n .slice(offset...(offset + layer_width))\n .chars\n .map(&:to_i)\n .each_slice(wide)\n .to_a\n }\nen...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /package_items GET /package_items.json
def index @package_items = @package.package_items end
[ "def show\n @package_item = PackageItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @package_item }\n end\n end", "def getItems()\n return mergeWithAPI(@item_json)['data']\n end", "def index\n @user_packages = UserPackage.all...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /package_items POST /package_items.json
def create @package_item = PackageItem.new(package_item_params) @package_item.package = @package respond_to do |format| if @package_item.save format.html { redirect_to package_items_path(@package), notice: 'Package item was successfully created.' } format.json { render :show, status: ...
[ "def create\n @package_item = PackageItem.new(params[:package_item])\n\n respond_to do |format|\n if @package_item.save\n format.html { redirect_to @package_item, notice: 'Package item was successfully created.' }\n format.json { render json: @package_item, status: :created, location: @pack...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /package_items/1 PATCH/PUT /package_items/1.json
def update respond_to do |format| @package_item.package = @package if @package_item.update(package_item_params) format.html { redirect_to package_items_path(@package), notice: 'Package item was successfully updated.' } format.json { render :show, status: :ok, location: @package_item } ...
[ "def update\n respond_to do |format|\n add_items\n if @package.update(package_params)\n format.html { redirect_to @package, notice: 'Package was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /package_items/1 DELETE /package_items/1.json
def destroy @package_item.destroy respond_to do |format| format.html { redirect_to package_items_url, notice: 'Package item was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @package_item = PackageItem.find(params[:id])\n @package_item.destroy\n\n respond_to do |format|\n format.html { redirect_to package_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @package.status = nil\n @package.save!\n respond_to do |fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def active_audits self.audits.where("end_date <= ?", Date.today) end
def active_audits_with_skipped self.audits.where("end_date >= ?", Date.today) - SkippedAuditReminder.audits end
[ "def audits\n Audit.active.where(:id => audit_results.pluck(:audit_id).uniq)\n end", "def active_flight_schedules\n self.flight_schedules.where.has{end_active_at >= DateTime.now }\n end", "def audits\n Audit.where(user: self)\n end", "def goals_ending\n goals = self.goals\n goals.collect {|g...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SHA1 hash in salted form
def sha1_hex Digest::SHA1.hexdigest(salted_name) end
[ "def salted_sha1(password)\n salt = SecureRandom.random_bytes(4)\n hash = Digest::SHA1.hexdigest(salt + password)\n SaltedSHA1.new((convert_to_hex(salt) + hash).upcase)\n end", "def sha1; end", "def sha1_hash\n return @sha1_hash\n end", "def sha1\n @sha1\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
generates a random salt based upon the characters returned by salt()
def rand_salt result = '' salt().length.times {result << salt()[rand(salt().length),1]} result end
[ "def make_salt\n rand(26**5).to_s(26)\n end", "def gen_salt\n chars = []\n 8.times do\n chars << SALT_CHARS[rand(SALT_CHARS.size)]\n end\n chars.join('')\n end", "def gen_salt\n chars = []\n 8.times { chars << SALT_CHARS[rand(SALT_CHARS.size)] }\n chars.join('') \n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the voltage in mV. The possible range is 0V to 5V (05000). Calling this function will set the mode to 0 (see BrickletAnalogOutset_mode). The default value is 0 (with mode 1).
def set_voltage(voltage) send_request(FUNCTION_SET_VOLTAGE, [voltage], 'S', 0, '') end
[ "def set_output_voltage(voltage)\n send_request(FUNCTION_SET_OUTPUT_VOLTAGE, [voltage], 'S', 0, '')\n end", "def voltage=(new_voltage)\n Klass.setVoltage(@handle, @index, new_voltage.to_f)\n new_voltage\n end", "def voltage\n lfac_device = '/sys/bus/iio/devices/iio:device0/'\n raw_vol...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Scans keys between `start` and `stop`.
def keys(start, stop, opts = {}) limit = opts[:limit] || -1 mon_synchronize do perform ["keys", start, stop, limit], :multi => true end end
[ "def keys(start, stop, opts = {})\n limit = opts[:limit] || -1\n mon_synchronize do\n perform [\"keys\", start, stop, limit], multi: true\n end\n end", "def search(start_key, end_key, limit, offset, reverse, with_keys)\n offset ||= 0\n \n start_node = find_by_prefix(start_key, revers...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the `score` of `member` at `key`.
def zset(key, member, score) mon_synchronize do perform ["zset", key, member, score], :proc => T_BOOL end end
[ "def zset(key, member, score)\n mon_synchronize do\n perform [\"zset\", key, member, score], proc: T_BOOL\n end\n end", "def []=(key, score)\n @write_lock.synchronize do\n current_score = @hash[key]\n if !current_score || current_score < score\n @hash[key] = score\n end\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Increments the `member` in `key` by `score`
def zincr(key, member, score = 1) mon_synchronize do perform ["zincr", key, member, score], :proc => T_INT end end
[ "def increment(member, score)\n @driver_instance.increment_sorted_set(@key, member, score)\n end", "def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], proc: T_INT\n end\n end", "def increment_sorted_set(key, member, score)\n raise NoMet...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Decrements the `member` in `key` by `score`
def zdecr(key, member, score = 1) mon_synchronize do perform ["zdecr", key, member, score], :proc => T_INT end end
[ "def decrement(member, score)\n @driver_instance.increment_sorted_set(@key, member, score*-1)\n end", "def zdecr(key, member, score = 1)\n mon_synchronize do\n perform [\"zdecr\", key, member, score], proc: T_INT\n end\n end", "def delete_score\n transaction do\n self.player.poin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks existence of a zset at `key`.
def zexists(key) mon_synchronize do perform ["zexists", key], :proc => T_BOOL end end
[ "def zexists(key)\n mon_synchronize do\n perform [\"zexists\", key], proc: T_BOOL\n end\n end", "def check_for_existenz(key)\n if (@repository[key] != nil)\n puts \"Info: A data set with this key already exists. Overwriting...\"\n end\n end", "def exist(key)\n check_return_cod...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete an `member` from a zset `key`.
def zdel(key, member) mon_synchronize do perform ["zdel", key, member], :proc => T_BOOL end end
[ "def zdel(key, member)\n mon_synchronize do\n perform [\"zdel\", key, member], proc: T_BOOL\n end\n end", "def remove_sorted_set(key, member)\n @kvs_instance.zrem(safe_key(key), member)\n end", "def srem(key, *members); end", "def delete(member)\n\t\t@list.delete(member)\n\tend", "def re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
record a file download event
def record_file_download_event( id, user = nil ) puts "==> file download event: file id #{id}" event = find_todays_existing_download_event( id, user ) if event.nil? == false event.downloads += 1 else event = create_new_download_event( id, user ) end save_safely( event ) end
[ "def download\n record_activity(\"downloaded \" + params[:file_name])\n send_file Rails.root.join('public', 'uploads', params[:file_name])\n end", "def download(event)\n @logger.info '----------------------------------------------------------------'\n @logger.info \"Downloading event '#{event}'.....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get an aggregate count of work views
def get_work_view_count( work ) return WorkViewStat.where( 'work_id = ?', work.id ).sum( :work_views ) end
[ "def view_count\n return self.views || 0 if attributes.has_key? 'views'\n viewings.count \n end", "def viewCount\n\tviewtickets = $client.views.find(:id => 61136848)\n\tviewtickets.tickets.each { |x| puts x }\nend", "def viewCountCreate\n @db.save_doc({\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get an aggregate count of work downloads
def get_work_download_count( work ) return 0 if work.filesets.blank? sum = 0 work.filesets.each { |fs| sum += get_file_download_count( fs.id ) } return sum end
[ "def download_count\n download_registrations.inject(0){|total,r| total += r.download_count.to_i}\n end", "def total_download_count\n sum(:api_download_count) + sum(:web_download_count)\n end", "def download_count\n web_download_count + api_download_count\n end", "def downloads_count\n G...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get an aggregate size of the work files
def get_work_aggregate_size( work ) return 0 if work.filesets.blank? sum = 0 work.filesets.each { |fs| sum += fs.file_size } return sum end
[ "def total_size\n if multiple_files?\n calculate_size_from_multiple_files\n else\n calculate_size_from_single_file\n end\n end", "def size_in_bytes\n files.inject(0) do |sum, f|\n path = File.join self.path, f\n sum + File.size(path)\n end\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get an aggregate count of file downloads
def get_file_download_count( fileset_id ) return FileDownloadStat.where( 'file_id = ?', fileset_id ).sum( :downloads ) end
[ "def total_download_count\n sum(:api_download_count) + sum(:web_download_count)\n end", "def download_count\n download_registrations.inject(0){|total,r| total += r.download_count.to_i}\n end", "def download_count\n web_download_count + api_download_count\n end", "def total_downloads_size\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get a list of download events that are identified by user
def get_all_identified_download_events FileDownloadStat.where( 'user_id is not NULL' ) end
[ "def get_events()\n @client.make_request(:get, @client.concat_user_path(\"#{CALL_PATH}/#{id}/events\"))[0]\n end", "def events(user)\n get(:standard, {:method => \"user.getEvents\", :user => user})\n end", "def user_events\n @user_events ||= users.map { |u| u.events }.flatten\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
anonymize the supplied view event
def anonymize_work_view_event( view_event ) # find an anomomyzed version event = find_existing_view_event( view_event.date, view_event.work_id, nil ) if event.nil? == false event.work_views += view_event.work_views else event = create_new_view_event( view_event.work_id, nil ) event...
[ "def post_visit(_view, context: nil); end", "def forwarding(event, to); super if defined? super end", "def handle_event(event)\n\n\t\tend", "def rendered_views=(_arg0); end", "def view_modal\n handle_view\n end", "def set_view(view)\n add_actions \"SetView(#{view})\"\n end", "def view_fl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }